@namzu/cli 38.1.0 → 38.2.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 (347) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/checkpoints/store.d.ts +4 -4
  4. package/dist/checkpoints/store.d.ts.map +1 -1
  5. package/dist/chunks/{acp-QDANXLMJ.js → acp-JU4DX3RK.js} +36 -36
  6. package/dist/chunks/{activity-command-A7WTUUNC.js → activity-command-TERANSMO.js} +11 -11
  7. package/dist/chunks/{add-LLZNHWGY.js → add-MZ6KIHY3.js} +16 -16
  8. package/dist/chunks/{agent-SOBO2IVC.js → agent-JZFFS4IP.js} +29 -27
  9. package/dist/chunks/agent-session-YS3JWF6Z.js +52 -0
  10. package/dist/chunks/{archive-I3XW27GP.js → archive-SXYHKL3H.js} +9 -9
  11. package/dist/chunks/{bin-main-5PYT3T7X.js → bin-main-TFKZQ7NF.js} +3 -3
  12. package/dist/chunks/{browser-G3MJZ3DG.js → browser-3U3YBKL6.js} +6 -6
  13. package/dist/chunks/{chat-T5D5DCNK.js → chat-37QA7HHN.js} +14 -14
  14. package/dist/chunks/{chunk-OGBOS4O6.js → chunk-2SVXX5QK.js} +5 -5
  15. package/dist/chunks/{chunk-EMHNNAAL.js → chunk-2T7TZDUE.js} +2 -2
  16. package/dist/chunks/{chunk-6UXRPOEE.js → chunk-2UT6U22B.js} +2 -2
  17. package/dist/chunks/{chunk-BOMYJAHT.js → chunk-2UUBILYI.js} +4 -4
  18. package/dist/chunks/chunk-2WHVZCLT.js +118 -0
  19. package/dist/chunks/chunk-2WHVZCLT.js.map +6 -0
  20. package/dist/chunks/{chunk-PB72XLZI.js → chunk-3NIZKJJG.js} +2 -2
  21. package/dist/chunks/{chunk-ASSTPA4A.js → chunk-3PBSWF6X.js} +3 -3
  22. package/dist/chunks/{chunk-RDPCXVEX.js → chunk-5G3VKTLZ.js} +2 -2
  23. package/dist/chunks/{chunk-3WIGPA6H.js → chunk-5PDW6VPO.js} +20 -83
  24. package/dist/chunks/chunk-5PDW6VPO.js.map +6 -0
  25. package/dist/chunks/{chunk-OYZ6SZ3E.js → chunk-6A7P3I3N.js} +38 -31
  26. package/dist/chunks/{chunk-OYZ6SZ3E.js.map → chunk-6A7P3I3N.js.map} +1 -1
  27. package/dist/chunks/{chunk-SFHP62ET.js → chunk-7MLTWXEW.js} +2 -2
  28. package/dist/chunks/{chunk-T3NBZFUV.js → chunk-7O4X4GYL.js} +7 -7
  29. package/dist/chunks/{chunk-73XHOUDX.js → chunk-7S5UB6DX.js} +6 -6
  30. package/dist/chunks/{chunk-2UGC7RUB.js → chunk-A64X23MU.js} +1002 -286
  31. package/dist/chunks/chunk-A64X23MU.js.map +6 -0
  32. package/dist/chunks/{chunk-MKT3L5E6.js → chunk-AHVF22PV.js} +26 -11
  33. package/dist/chunks/chunk-AHVF22PV.js.map +6 -0
  34. package/dist/chunks/{chunk-US5ZFPAU.js → chunk-AXCOWIIH.js} +2 -7
  35. package/dist/chunks/{chunk-US5ZFPAU.js.map → chunk-AXCOWIIH.js.map} +1 -1
  36. package/dist/chunks/{chunk-P34B6ZYV.js → chunk-B5344NIV.js} +3 -3
  37. package/dist/chunks/{chunk-FAAPXKG2.js → chunk-CDZT7WGY.js} +3 -3
  38. package/dist/chunks/{chunk-JLZXFOT7.js → chunk-CK4TOW2N.js} +2 -2
  39. package/dist/chunks/{chunk-6WMPFHXX.js → chunk-CLIP7QVU.js} +3 -3
  40. package/dist/chunks/{chunk-E4RUPCFR.js → chunk-D5SIC3SF.js} +9 -9
  41. package/dist/chunks/{chunk-ZWG3EZTX.js → chunk-DQICYFIG.js} +2 -2
  42. package/dist/chunks/{chunk-KHUNDRQB.js → chunk-EKMOETAY.js} +2 -2
  43. package/dist/chunks/{chunk-AJVXO5QA.js → chunk-EUHPTASG.js} +2 -2
  44. package/dist/chunks/{chunk-N37EFNAV.js → chunk-FI7TIM5P.js} +2 -2
  45. package/dist/chunks/{chunk-5TXMCMJL.js → chunk-FMJCN6JZ.js} +7 -5
  46. package/dist/chunks/chunk-FMJCN6JZ.js.map +6 -0
  47. package/dist/chunks/{chunk-ZFQFLT7V.js → chunk-FOGCQUIH.js} +59 -140
  48. package/dist/chunks/chunk-FOGCQUIH.js.map +6 -0
  49. package/dist/chunks/{chunk-PQNLAOAW.js → chunk-GTXD263T.js} +2 -2
  50. package/dist/chunks/{chunk-JF3HMHOH.js → chunk-HOOY63EB.js} +13 -13
  51. package/dist/chunks/{chunk-OOU7VJHG.js → chunk-ICBHR27I.js} +12 -12
  52. package/dist/chunks/{chunk-R5DD4NG3.js → chunk-IG4O4UAL.js} +2 -2
  53. package/dist/chunks/{chunk-IMVIKNHR.js → chunk-JN6M424Z.js} +4 -4
  54. package/dist/chunks/{chunk-TR7AV6E5.js → chunk-KG2YA6TI.js} +3 -3
  55. package/dist/chunks/{chunk-PRDAOS7E.js → chunk-KONWJQLM.js} +3 -3
  56. package/dist/chunks/{chunk-ALNAYYZH.js → chunk-KUNQW3N3.js} +4 -4
  57. package/dist/chunks/{chunk-PN76O25X.js → chunk-LBPM46OY.js} +2 -2
  58. package/dist/chunks/{chunk-NI4DVRFU.js → chunk-LC5VGZO2.js} +2 -2
  59. package/dist/chunks/{chunk-N7CZKWKN.js → chunk-LH6J5QQ7.js} +2 -2
  60. package/dist/chunks/{chunk-Y6O5MV4Y.js → chunk-LLZ32DHS.js} +494 -224
  61. package/dist/chunks/chunk-LLZ32DHS.js.map +6 -0
  62. package/dist/chunks/{chunk-Z2P34MZS.js → chunk-LPYWPRIF.js} +4 -4
  63. package/dist/chunks/{chunk-6BHLLXPK.js → chunk-M2EJQU3F.js} +4 -4
  64. package/dist/chunks/{chunk-YI4HMJOG.js → chunk-N57QO3AA.js} +2 -2
  65. package/dist/chunks/{chunk-AIV33BFR.js → chunk-OA5772RG.js} +4 -4
  66. package/dist/chunks/{chunk-KQCP3QBI.js → chunk-PETRJVXF.js} +4 -4
  67. package/dist/chunks/{chunk-7N5PZOSU.js → chunk-Q6SF7T77.js} +3 -3
  68. package/dist/chunks/{chunk-TSSO2X7U.js → chunk-S5U4BG57.js} +51 -20
  69. package/dist/chunks/chunk-S5U4BG57.js.map +6 -0
  70. package/dist/chunks/{chunk-BV57PYGE.js → chunk-TNTP3CNT.js} +25 -19
  71. package/dist/chunks/chunk-TNTP3CNT.js.map +6 -0
  72. package/dist/chunks/{chunk-JOLXEWMZ.js → chunk-U75JG2RT.js} +2 -2
  73. package/dist/chunks/{chunk-ZBZVDIWU.js → chunk-UQZNYNX7.js} +2 -2
  74. package/dist/chunks/{chunk-2UWTSQHA.js → chunk-V2VHVH5S.js} +18 -8
  75. package/dist/chunks/chunk-V2VHVH5S.js.map +6 -0
  76. package/dist/chunks/{chunk-ZDDZWL3G.js → chunk-VFBIR3UC.js} +4 -4
  77. package/dist/chunks/{chunk-PBBISRKF.js → chunk-WLHI2QSC.js} +3 -3
  78. package/dist/chunks/{chunk-ZJ575MQN.js → chunk-XEOZYKPJ.js} +3 -3
  79. package/dist/chunks/{chunk-JVCMPZ3K.js → chunk-XIURI2PQ.js} +7 -7
  80. package/dist/chunks/{chunk-4UEMLMAO.js → chunk-XKEMUEI5.js} +2 -2
  81. package/dist/chunks/{chunk-GL4E6OIO.js → chunk-XNHYUV6G.js} +2 -2
  82. package/dist/chunks/{chunk-EAIHS7DX.js → chunk-Z4LTK3HY.js} +4 -4
  83. package/dist/chunks/{chunk-NTC7YGAM.js → chunk-Z56MZ7UW.js} +4 -4
  84. package/dist/chunks/{chunk-CNCIPIHC.js → chunk-ZJHOWWXZ.js} +12 -12
  85. package/dist/chunks/{chunk-54U4UGTC.js → chunk-ZJMUPGWD.js} +8 -8
  86. package/dist/chunks/{cli-runtime-K4F3EBQS.js → cli-runtime-PRG53LL6.js} +18 -12
  87. package/dist/chunks/cli-runtime-PRG53LL6.js.map +6 -0
  88. package/dist/chunks/{commands-YC7L2QOH.js → commands-QMF4AHAY.js} +5 -5
  89. package/dist/chunks/{crash-report-WQQLBSON.js → crash-report-BSZ6SUOF.js} +7 -7
  90. package/dist/chunks/{dist-ADL22Y3L.js → dist-56CMMYUT.js} +48 -5
  91. package/dist/chunks/dist-56CMMYUT.js.map +6 -0
  92. package/dist/chunks/{dist-ZHXYP3JL.js → dist-GNI4DIHI.js} +2 -2
  93. package/dist/chunks/{dist-WQG6JF6S.js → dist-HRWBXBF3.js} +2 -2
  94. package/dist/chunks/{dist-KLZG5KHA.js → dist-JDUOF4K7.js} +2 -2
  95. package/dist/chunks/{dist-5NERUTGE.js → dist-MYWLKPXK.js} +2 -2
  96. package/dist/chunks/{dist-X566F3HM.js → dist-QSOTJL6Z.js} +2 -2
  97. package/dist/chunks/{dist-GY7DEOFW.js → dist-SO6XBKFN.js} +2 -2
  98. package/dist/chunks/{dist-K6Y4TDTR.js → dist-XDA5OMB2.js} +2 -2
  99. package/dist/chunks/{doctor-CCRTV4U3.js → doctor-5MS7V3JB.js} +8 -8
  100. package/dist/chunks/{drain-HBQ7PSPY.js → drain-YGGEC4UE.js} +10 -10
  101. package/dist/chunks/{eval-QTEMU2EM.js → eval-GWP6MISH.js} +2 -2
  102. package/dist/chunks/{exec-AEZSAZZD.js → exec-YDIFQY7C.js} +27 -26
  103. package/dist/chunks/exec-YDIFQY7C.js.map +6 -0
  104. package/dist/chunks/{home-WZUWH5PC.js → home-IZ2H7PM3.js} +3 -3
  105. package/dist/chunks/{host-queries-4VJ5CEAH.js → host-queries-UCVJBJXU.js} +14 -14
  106. package/dist/chunks/{lifecycle-NWT4MPRY.js → lifecycle-U52Z5ZMZ.js} +24 -24
  107. package/dist/chunks/{list-JVUC64TK.js → list-SVKI2XOL.js} +12 -12
  108. package/dist/chunks/{login-D5YWQ2UL.js → login-MNDG4XIT.js} +8 -8
  109. package/dist/chunks/{logs-Y7UAV3Z7.js → logs-M7RCXYPY.js} +4 -4
  110. package/dist/chunks/{mcp-INYNL2GU.js → mcp-KEQMYKDA.js} +17 -17
  111. package/dist/chunks/{message-command-EBQSLXJB.js → message-command-FZ6VEUK5.js} +33 -33
  112. package/dist/chunks/{operator-tools-NFB6XCBI.js → operator-tools-C57ZIYRG.js} +12 -12
  113. package/dist/chunks/{output-schema-Q2SRX2K6.js → output-schema-IYQRSIUA.js} +3 -3
  114. package/dist/chunks/{pal-4ASOF2MF.js → pal-NXMTLY6Z.js} +11 -11
  115. package/dist/chunks/{providers-G6HLQTQM.js → providers-TZBRQDXE.js} +6 -6
  116. package/dist/chunks/{resident-O6O7PAKU.js → resident-DBIZBLOV.js} +21 -21
  117. package/dist/chunks/resume-GG6RMJXQ.js +22 -0
  118. package/dist/chunks/{resume-command-ZVB7EIXM.js → resume-command-36S3HXPO.js} +4 -4
  119. package/dist/chunks/{schedule-DWQ3ALQA.js → schedule-UR54S44B.js} +8 -8
  120. package/dist/chunks/{service-WDU7FPLA.js → service-VMXEAJCI.js} +23 -23
  121. package/dist/chunks/session-step-VJCHKPWD.js +29 -0
  122. package/dist/chunks/{skills-2IL52ZCI.js → skills-RXYS26H3.js} +8 -8
  123. package/dist/chunks/{state-3O5DDQHZ.js → state-NS47IVWW.js} +2 -2
  124. package/dist/chunks/{store-ZUIHCZSM.js → store-3U2GZAZS.js} +9 -9
  125. package/dist/chunks/{store-QDL2I4V7.js → store-GNFHH2LZ.js} +4 -4
  126. package/dist/chunks/{store-JYYMPLRL.js → store-TO65IAIZ.js} +6 -6
  127. package/dist/chunks/{tui-D24IQIYO.js → tui-STU5UZBC.js} +2922 -1553
  128. package/dist/chunks/tui-STU5UZBC.js.map +6 -0
  129. package/dist/chunks/{upgrade-EBQQIOHS.js → upgrade-USIXROFG.js} +2 -2
  130. package/dist/chunks/{worktree-CWBTAWWO.js → worktree-AYI5VJ5H.js} +11 -11
  131. package/dist/cli.d.ts.map +1 -1
  132. package/dist/config/composer-triggers.d.ts +1 -1
  133. package/dist/config/composer-triggers.d.ts.map +1 -1
  134. package/dist/config/schema.d.ts +2 -2
  135. package/dist/config/schema.d.ts.map +1 -1
  136. package/dist/index.js +13 -13
  137. package/dist/integrations/notifications/approval.d.ts +36 -0
  138. package/dist/integrations/notifications/approval.d.ts.map +1 -0
  139. package/dist/integrations/resident/runner-worker.js +18 -18
  140. package/dist/integrations/sessions/journal-trail.d.ts +6 -0
  141. package/dist/integrations/sessions/journal-trail.d.ts.map +1 -0
  142. package/dist/integrations/sessions/store.d.ts.map +1 -1
  143. package/dist/integrations/subagents/activity.d.ts.map +1 -1
  144. package/dist/integrations/subagents/failure-text.d.ts +13 -0
  145. package/dist/integrations/subagents/failure-text.d.ts.map +1 -0
  146. package/dist/integrations/subagents/runtime.d.ts +2 -0
  147. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  148. package/dist/integrations/trust/folder-grants.d.ts +20 -0
  149. package/dist/integrations/trust/folder-grants.d.ts.map +1 -0
  150. package/dist/integrations/workflows/host.d.ts +7 -0
  151. package/dist/integrations/workflows/host.d.ts.map +1 -1
  152. package/dist/integrations/workflows/notice.d.ts.map +1 -1
  153. package/dist/integrations/workflows/offering.d.ts +12 -4
  154. package/dist/integrations/workflows/offering.d.ts.map +1 -1
  155. package/dist/permissions/consent-prompt.d.ts.map +1 -1
  156. package/dist/tui/AgentExplorer.d.ts +14 -6
  157. package/dist/tui/AgentExplorer.d.ts.map +1 -1
  158. package/dist/tui/App.d.ts +13 -2
  159. package/dist/tui/App.d.ts.map +1 -1
  160. package/dist/tui/BackgroundJobsPanel.d.ts.map +1 -1
  161. package/dist/tui/BrandHeader.d.ts +2 -0
  162. package/dist/tui/BrandHeader.d.ts.map +1 -1
  163. package/dist/tui/ChoicePicker.d.ts +8 -1
  164. package/dist/tui/ChoicePicker.d.ts.map +1 -1
  165. package/dist/tui/Composer.d.ts +5 -1
  166. package/dist/tui/Composer.d.ts.map +1 -1
  167. package/dist/tui/LiveActivity.d.ts +8 -3
  168. package/dist/tui/LiveActivity.d.ts.map +1 -1
  169. package/dist/tui/PermissionOverlay.d.ts.map +1 -1
  170. package/dist/tui/ResumePicker.d.ts.map +1 -1
  171. package/dist/tui/StatusBar.d.ts +17 -5
  172. package/dist/tui/StatusBar.d.ts.map +1 -1
  173. package/dist/tui/Transcript.d.ts +4 -2
  174. package/dist/tui/Transcript.d.ts.map +1 -1
  175. package/dist/tui/TrustPrompt.d.ts +11 -1
  176. package/dist/tui/TrustPrompt.d.ts.map +1 -1
  177. package/dist/tui/agent-stop-all.d.ts +25 -0
  178. package/dist/tui/agent-stop-all.d.ts.map +1 -0
  179. package/dist/tui/agent-transcript-rows.d.ts +6 -4
  180. package/dist/tui/agent-transcript-rows.d.ts.map +1 -1
  181. package/dist/tui/agent.d.ts +35 -1
  182. package/dist/tui/agent.d.ts.map +1 -1
  183. package/dist/tui/browser-notices.d.ts +3 -3
  184. package/dist/tui/browser-notices.d.ts.map +1 -1
  185. package/dist/tui/compaction-rows.d.ts +51 -0
  186. package/dist/tui/compaction-rows.d.ts.map +1 -0
  187. package/dist/tui/diff-rows.d.ts +29 -0
  188. package/dist/tui/diff-rows.d.ts.map +1 -0
  189. package/dist/tui/display-path.d.ts +10 -0
  190. package/dist/tui/display-path.d.ts.map +1 -0
  191. package/dist/tui/exit-hint.d.ts +3 -0
  192. package/dist/tui/exit-hint.d.ts.map +1 -0
  193. package/dist/tui/job-exit-row.d.ts +1 -1
  194. package/dist/tui/job-exit-row.d.ts.map +1 -1
  195. package/dist/tui/markdown-wrap.d.ts.map +1 -1
  196. package/dist/tui/pause-clock.d.ts +15 -0
  197. package/dist/tui/pause-clock.d.ts.map +1 -0
  198. package/dist/tui/permission-review.d.ts +6 -0
  199. package/dist/tui/permission-review.d.ts.map +1 -1
  200. package/dist/tui/plain-interruption.d.ts +9 -1
  201. package/dist/tui/plain-interruption.d.ts.map +1 -1
  202. package/dist/tui/restored-rows.d.ts +83 -0
  203. package/dist/tui/restored-rows.d.ts.map +1 -0
  204. package/dist/tui/schedule/source-deliveries.d.ts +8 -1
  205. package/dist/tui/schedule/source-deliveries.d.ts.map +1 -1
  206. package/dist/tui/shell-cell.d.ts.map +1 -1
  207. package/dist/tui/shell-escape.d.ts +4 -1
  208. package/dist/tui/shell-escape.d.ts.map +1 -1
  209. package/dist/tui/slashCommands.d.ts +6 -0
  210. package/dist/tui/slashCommands.d.ts.map +1 -1
  211. package/dist/tui/stall-colour.d.ts +20 -0
  212. package/dist/tui/stall-colour.d.ts.map +1 -0
  213. package/dist/tui/system-rows.d.ts +77 -0
  214. package/dist/tui/system-rows.d.ts.map +1 -0
  215. package/dist/tui/tidy-tool-output.d.ts +2 -14
  216. package/dist/tui/tidy-tool-output.d.ts.map +1 -1
  217. package/dist/tui/tool-end-rows.d.ts +53 -0
  218. package/dist/tui/tool-end-rows.d.ts.map +1 -0
  219. package/dist/tui/triggers/context-text.d.ts.map +1 -1
  220. package/dist/tui/triggers/copy.d.ts +9 -2
  221. package/dist/tui/triggers/copy.d.ts.map +1 -1
  222. package/dist/tui/triggers/detect.d.ts.map +1 -1
  223. package/dist/tui/triggers/registry.d.ts +1 -1
  224. package/dist/tui/triggers/registry.d.ts.map +1 -1
  225. package/dist/tui/triggers/setting.d.ts.map +1 -1
  226. package/dist/tui/truncation.d.ts +27 -0
  227. package/dist/tui/truncation.d.ts.map +1 -0
  228. package/dist/tui/turn-interruption.d.ts +2 -0
  229. package/dist/tui/turn-interruption.d.ts.map +1 -1
  230. package/dist/tui/types.d.ts +14 -1
  231. package/dist/tui/types.d.ts.map +1 -1
  232. package/dist/tui/units.d.ts +17 -1
  233. package/dist/tui/units.d.ts.map +1 -1
  234. package/dist/tui/web-activity.d.ts.map +1 -1
  235. package/dist/tui/workspace-diff.d.ts +20 -0
  236. package/dist/tui/workspace-diff.d.ts.map +1 -1
  237. package/package.json +6 -6
  238. package/dist/chunks/agent-session-RBHNKEGD.js +0 -52
  239. package/dist/chunks/chunk-2UGC7RUB.js.map +0 -6
  240. package/dist/chunks/chunk-2UWTSQHA.js.map +0 -6
  241. package/dist/chunks/chunk-3WIGPA6H.js.map +0 -6
  242. package/dist/chunks/chunk-5TXMCMJL.js.map +0 -6
  243. package/dist/chunks/chunk-BV57PYGE.js.map +0 -6
  244. package/dist/chunks/chunk-MKT3L5E6.js.map +0 -6
  245. package/dist/chunks/chunk-TSSO2X7U.js.map +0 -6
  246. package/dist/chunks/chunk-Y6O5MV4Y.js.map +0 -6
  247. package/dist/chunks/chunk-ZFQFLT7V.js.map +0 -6
  248. package/dist/chunks/cli-runtime-K4F3EBQS.js.map +0 -6
  249. package/dist/chunks/dist-ADL22Y3L.js.map +0 -6
  250. package/dist/chunks/exec-AEZSAZZD.js.map +0 -6
  251. package/dist/chunks/resume-BMR3VCES.js +0 -22
  252. package/dist/chunks/session-step-OUDE34A6.js +0 -29
  253. package/dist/chunks/tui-D24IQIYO.js.map +0 -6
  254. /package/dist/chunks/{acp-QDANXLMJ.js.map → acp-JU4DX3RK.js.map} +0 -0
  255. /package/dist/chunks/{activity-command-A7WTUUNC.js.map → activity-command-TERANSMO.js.map} +0 -0
  256. /package/dist/chunks/{add-LLZNHWGY.js.map → add-MZ6KIHY3.js.map} +0 -0
  257. /package/dist/chunks/{agent-SOBO2IVC.js.map → agent-JZFFS4IP.js.map} +0 -0
  258. /package/dist/chunks/{agent-session-RBHNKEGD.js.map → agent-session-YS3JWF6Z.js.map} +0 -0
  259. /package/dist/chunks/{archive-I3XW27GP.js.map → archive-SXYHKL3H.js.map} +0 -0
  260. /package/dist/chunks/{bin-main-5PYT3T7X.js.map → bin-main-TFKZQ7NF.js.map} +0 -0
  261. /package/dist/chunks/{browser-G3MJZ3DG.js.map → browser-3U3YBKL6.js.map} +0 -0
  262. /package/dist/chunks/{chat-T5D5DCNK.js.map → chat-37QA7HHN.js.map} +0 -0
  263. /package/dist/chunks/{chunk-OGBOS4O6.js.map → chunk-2SVXX5QK.js.map} +0 -0
  264. /package/dist/chunks/{chunk-EMHNNAAL.js.map → chunk-2T7TZDUE.js.map} +0 -0
  265. /package/dist/chunks/{chunk-6UXRPOEE.js.map → chunk-2UT6U22B.js.map} +0 -0
  266. /package/dist/chunks/{chunk-BOMYJAHT.js.map → chunk-2UUBILYI.js.map} +0 -0
  267. /package/dist/chunks/{chunk-PB72XLZI.js.map → chunk-3NIZKJJG.js.map} +0 -0
  268. /package/dist/chunks/{chunk-ASSTPA4A.js.map → chunk-3PBSWF6X.js.map} +0 -0
  269. /package/dist/chunks/{chunk-RDPCXVEX.js.map → chunk-5G3VKTLZ.js.map} +0 -0
  270. /package/dist/chunks/{chunk-SFHP62ET.js.map → chunk-7MLTWXEW.js.map} +0 -0
  271. /package/dist/chunks/{chunk-T3NBZFUV.js.map → chunk-7O4X4GYL.js.map} +0 -0
  272. /package/dist/chunks/{chunk-73XHOUDX.js.map → chunk-7S5UB6DX.js.map} +0 -0
  273. /package/dist/chunks/{chunk-P34B6ZYV.js.map → chunk-B5344NIV.js.map} +0 -0
  274. /package/dist/chunks/{chunk-FAAPXKG2.js.map → chunk-CDZT7WGY.js.map} +0 -0
  275. /package/dist/chunks/{chunk-JLZXFOT7.js.map → chunk-CK4TOW2N.js.map} +0 -0
  276. /package/dist/chunks/{chunk-6WMPFHXX.js.map → chunk-CLIP7QVU.js.map} +0 -0
  277. /package/dist/chunks/{chunk-E4RUPCFR.js.map → chunk-D5SIC3SF.js.map} +0 -0
  278. /package/dist/chunks/{chunk-ZWG3EZTX.js.map → chunk-DQICYFIG.js.map} +0 -0
  279. /package/dist/chunks/{chunk-KHUNDRQB.js.map → chunk-EKMOETAY.js.map} +0 -0
  280. /package/dist/chunks/{chunk-AJVXO5QA.js.map → chunk-EUHPTASG.js.map} +0 -0
  281. /package/dist/chunks/{chunk-N37EFNAV.js.map → chunk-FI7TIM5P.js.map} +0 -0
  282. /package/dist/chunks/{chunk-PQNLAOAW.js.map → chunk-GTXD263T.js.map} +0 -0
  283. /package/dist/chunks/{chunk-JF3HMHOH.js.map → chunk-HOOY63EB.js.map} +0 -0
  284. /package/dist/chunks/{chunk-OOU7VJHG.js.map → chunk-ICBHR27I.js.map} +0 -0
  285. /package/dist/chunks/{chunk-R5DD4NG3.js.map → chunk-IG4O4UAL.js.map} +0 -0
  286. /package/dist/chunks/{chunk-IMVIKNHR.js.map → chunk-JN6M424Z.js.map} +0 -0
  287. /package/dist/chunks/{chunk-TR7AV6E5.js.map → chunk-KG2YA6TI.js.map} +0 -0
  288. /package/dist/chunks/{chunk-PRDAOS7E.js.map → chunk-KONWJQLM.js.map} +0 -0
  289. /package/dist/chunks/{chunk-ALNAYYZH.js.map → chunk-KUNQW3N3.js.map} +0 -0
  290. /package/dist/chunks/{chunk-PN76O25X.js.map → chunk-LBPM46OY.js.map} +0 -0
  291. /package/dist/chunks/{chunk-NI4DVRFU.js.map → chunk-LC5VGZO2.js.map} +0 -0
  292. /package/dist/chunks/{chunk-N7CZKWKN.js.map → chunk-LH6J5QQ7.js.map} +0 -0
  293. /package/dist/chunks/{chunk-Z2P34MZS.js.map → chunk-LPYWPRIF.js.map} +0 -0
  294. /package/dist/chunks/{chunk-6BHLLXPK.js.map → chunk-M2EJQU3F.js.map} +0 -0
  295. /package/dist/chunks/{chunk-YI4HMJOG.js.map → chunk-N57QO3AA.js.map} +0 -0
  296. /package/dist/chunks/{chunk-AIV33BFR.js.map → chunk-OA5772RG.js.map} +0 -0
  297. /package/dist/chunks/{chunk-KQCP3QBI.js.map → chunk-PETRJVXF.js.map} +0 -0
  298. /package/dist/chunks/{chunk-7N5PZOSU.js.map → chunk-Q6SF7T77.js.map} +0 -0
  299. /package/dist/chunks/{chunk-JOLXEWMZ.js.map → chunk-U75JG2RT.js.map} +0 -0
  300. /package/dist/chunks/{chunk-ZBZVDIWU.js.map → chunk-UQZNYNX7.js.map} +0 -0
  301. /package/dist/chunks/{chunk-ZDDZWL3G.js.map → chunk-VFBIR3UC.js.map} +0 -0
  302. /package/dist/chunks/{chunk-PBBISRKF.js.map → chunk-WLHI2QSC.js.map} +0 -0
  303. /package/dist/chunks/{chunk-ZJ575MQN.js.map → chunk-XEOZYKPJ.js.map} +0 -0
  304. /package/dist/chunks/{chunk-JVCMPZ3K.js.map → chunk-XIURI2PQ.js.map} +0 -0
  305. /package/dist/chunks/{chunk-4UEMLMAO.js.map → chunk-XKEMUEI5.js.map} +0 -0
  306. /package/dist/chunks/{chunk-GL4E6OIO.js.map → chunk-XNHYUV6G.js.map} +0 -0
  307. /package/dist/chunks/{chunk-EAIHS7DX.js.map → chunk-Z4LTK3HY.js.map} +0 -0
  308. /package/dist/chunks/{chunk-NTC7YGAM.js.map → chunk-Z56MZ7UW.js.map} +0 -0
  309. /package/dist/chunks/{chunk-CNCIPIHC.js.map → chunk-ZJHOWWXZ.js.map} +0 -0
  310. /package/dist/chunks/{chunk-54U4UGTC.js.map → chunk-ZJMUPGWD.js.map} +0 -0
  311. /package/dist/chunks/{commands-YC7L2QOH.js.map → commands-QMF4AHAY.js.map} +0 -0
  312. /package/dist/chunks/{crash-report-WQQLBSON.js.map → crash-report-BSZ6SUOF.js.map} +0 -0
  313. /package/dist/chunks/{dist-ZHXYP3JL.js.map → dist-GNI4DIHI.js.map} +0 -0
  314. /package/dist/chunks/{dist-WQG6JF6S.js.map → dist-HRWBXBF3.js.map} +0 -0
  315. /package/dist/chunks/{dist-KLZG5KHA.js.map → dist-JDUOF4K7.js.map} +0 -0
  316. /package/dist/chunks/{dist-5NERUTGE.js.map → dist-MYWLKPXK.js.map} +0 -0
  317. /package/dist/chunks/{dist-X566F3HM.js.map → dist-QSOTJL6Z.js.map} +0 -0
  318. /package/dist/chunks/{dist-GY7DEOFW.js.map → dist-SO6XBKFN.js.map} +0 -0
  319. /package/dist/chunks/{dist-K6Y4TDTR.js.map → dist-XDA5OMB2.js.map} +0 -0
  320. /package/dist/chunks/{doctor-CCRTV4U3.js.map → doctor-5MS7V3JB.js.map} +0 -0
  321. /package/dist/chunks/{drain-HBQ7PSPY.js.map → drain-YGGEC4UE.js.map} +0 -0
  322. /package/dist/chunks/{eval-QTEMU2EM.js.map → eval-GWP6MISH.js.map} +0 -0
  323. /package/dist/chunks/{home-WZUWH5PC.js.map → home-IZ2H7PM3.js.map} +0 -0
  324. /package/dist/chunks/{host-queries-4VJ5CEAH.js.map → host-queries-UCVJBJXU.js.map} +0 -0
  325. /package/dist/chunks/{lifecycle-NWT4MPRY.js.map → lifecycle-U52Z5ZMZ.js.map} +0 -0
  326. /package/dist/chunks/{list-JVUC64TK.js.map → list-SVKI2XOL.js.map} +0 -0
  327. /package/dist/chunks/{login-D5YWQ2UL.js.map → login-MNDG4XIT.js.map} +0 -0
  328. /package/dist/chunks/{logs-Y7UAV3Z7.js.map → logs-M7RCXYPY.js.map} +0 -0
  329. /package/dist/chunks/{mcp-INYNL2GU.js.map → mcp-KEQMYKDA.js.map} +0 -0
  330. /package/dist/chunks/{message-command-EBQSLXJB.js.map → message-command-FZ6VEUK5.js.map} +0 -0
  331. /package/dist/chunks/{operator-tools-NFB6XCBI.js.map → operator-tools-C57ZIYRG.js.map} +0 -0
  332. /package/dist/chunks/{output-schema-Q2SRX2K6.js.map → output-schema-IYQRSIUA.js.map} +0 -0
  333. /package/dist/chunks/{pal-4ASOF2MF.js.map → pal-NXMTLY6Z.js.map} +0 -0
  334. /package/dist/chunks/{providers-G6HLQTQM.js.map → providers-TZBRQDXE.js.map} +0 -0
  335. /package/dist/chunks/{resident-O6O7PAKU.js.map → resident-DBIZBLOV.js.map} +0 -0
  336. /package/dist/chunks/{resume-BMR3VCES.js.map → resume-GG6RMJXQ.js.map} +0 -0
  337. /package/dist/chunks/{resume-command-ZVB7EIXM.js.map → resume-command-36S3HXPO.js.map} +0 -0
  338. /package/dist/chunks/{schedule-DWQ3ALQA.js.map → schedule-UR54S44B.js.map} +0 -0
  339. /package/dist/chunks/{service-WDU7FPLA.js.map → service-VMXEAJCI.js.map} +0 -0
  340. /package/dist/chunks/{session-step-OUDE34A6.js.map → session-step-VJCHKPWD.js.map} +0 -0
  341. /package/dist/chunks/{skills-2IL52ZCI.js.map → skills-RXYS26H3.js.map} +0 -0
  342. /package/dist/chunks/{state-3O5DDQHZ.js.map → state-NS47IVWW.js.map} +0 -0
  343. /package/dist/chunks/{store-JYYMPLRL.js.map → store-3U2GZAZS.js.map} +0 -0
  344. /package/dist/chunks/{store-QDL2I4V7.js.map → store-GNFHH2LZ.js.map} +0 -0
  345. /package/dist/chunks/{store-ZUIHCZSM.js.map → store-TO65IAIZ.js.map} +0 -0
  346. /package/dist/chunks/{upgrade-EBQQIOHS.js.map → upgrade-USIXROFG.js.map} +0 -0
  347. /package/dist/chunks/{worktree-CWBTAWWO.js.map → worktree-AYI5VJ5H.js.map} +0 -0
@@ -1832,7 +1832,7 @@ function formatSystemEvent(event, options = {}) {
1832
1832
  renderedBody
1833
1833
  ]);
1834
1834
  const closingTag = `</system-event-${nonce}>`;
1835
- const lines2 = [
1835
+ const lines = [
1836
1836
  `<system-event-${nonce} kind="${escapeAttribute2(event.kind)}" id="${escapeAttribute2(event.id)}" status="${escapeAttribute2(event.status)}">`,
1837
1837
  SYSTEM_EVENT_HEADER,
1838
1838
  nonceClosureStatement(closingTag),
@@ -1844,7 +1844,7 @@ function formatSystemEvent(event, options = {}) {
1844
1844
  renderedBody,
1845
1845
  closingTag
1846
1846
  ];
1847
- return lines2.join("\n");
1847
+ return lines.join("\n");
1848
1848
  }
1849
1849
  __name(formatSystemEvent, "formatSystemEvent");
1850
1850
 
@@ -1937,7 +1937,7 @@ function createMonitorStream(options) {
1937
1937
  const clearTimer = options.clearTimer ?? ((handle) => clearTimeout(handle));
1938
1938
  let closed = false;
1939
1939
  let partial = "";
1940
- let lines2 = [];
1940
+ let lines = [];
1941
1941
  let timer;
1942
1942
  let timerArmed = false;
1943
1943
  let tokens = MONITOR_BUCKET_CAPACITY;
@@ -1993,10 +1993,10 @@ function createMonitorStream(options) {
1993
1993
  clearTimer(timer);
1994
1994
  timerArmed = false;
1995
1995
  }
1996
- if (lines2.length === 0)
1996
+ if (lines.length === 0)
1997
1997
  return;
1998
- let batch = lines2.join("\n");
1999
- lines2 = [];
1998
+ let batch = lines.join("\n");
1999
+ lines = [];
2000
2000
  if (batch.length > MONITOR_BATCH_MAX_CHARS) {
2001
2001
  batch = batch.slice(0, MONITOR_BATCH_MAX_CHARS) + BATCH_TRUNCATED;
2002
2002
  }
@@ -2006,7 +2006,7 @@ function createMonitorStream(options) {
2006
2006
  const line = raw.trim();
2007
2007
  if (line.length === 0)
2008
2008
  return;
2009
- lines2.push(line.length > MONITOR_LINE_MAX_CHARS ? line.slice(0, MONITOR_LINE_MAX_CHARS) + LINE_TRUNCATED : line);
2009
+ lines.push(line.length > MONITOR_LINE_MAX_CHARS ? line.slice(0, MONITOR_LINE_MAX_CHARS) + LINE_TRUNCATED : line);
2010
2010
  if (!timerArmed) {
2011
2011
  timerArmed = true;
2012
2012
  timer = setTimer(() => {
@@ -2022,7 +2022,7 @@ function createMonitorStream(options) {
2022
2022
  clearTimer(timer);
2023
2023
  timerArmed = false;
2024
2024
  }
2025
- lines2 = [];
2025
+ lines = [];
2026
2026
  partial = "";
2027
2027
  }, "stop");
2028
2028
  return {
@@ -12928,7 +12928,8 @@ var EPHEMERAL_EVENT_TYPES = /* @__PURE__ */ new Set([
12928
12928
  "tool_input_delta",
12929
12929
  "reasoning_delta",
12930
12930
  "tool_progress",
12931
- "monitor_event"
12931
+ "monitor_event",
12932
+ "compaction_started"
12932
12933
  ]);
12933
12934
  function isEphemeralEvent(event) {
12934
12935
  return EPHEMERAL_EVENT_TYPES.has(event.type);
@@ -13339,6 +13340,7 @@ var SESSION_EVENT_TYPE_TABLE = {
13339
13340
  approval_policy_changed: true,
13340
13341
  request_envelope: true,
13341
13342
  iteration_completed: true,
13343
+ compaction_started: true,
13342
13344
  compaction_shed: true,
13343
13345
  compaction_completed: true,
13344
13346
  compaction_tool_results_cleared: true,
@@ -14721,6 +14723,7 @@ var BOUNDARY_TYPES = /* @__PURE__ */ new Set([
14721
14723
  "log_repaired"
14722
14724
  ]);
14723
14725
  var PREVIEW_CHARS = 2e3;
14726
+ var COMPACTION_SPILL_ABOVE_BYTES = 256 * 1024;
14724
14727
  var ZERO_USAGE = {
14725
14728
  promptTokens: 0,
14726
14729
  completionTokens: 0,
@@ -14750,6 +14753,7 @@ var SessionLogCore = class {
14750
14753
  #spills;
14751
14754
  #now;
14752
14755
  #spillAbove;
14756
+ #compactionSpillAbove;
14753
14757
  #structuredResultSpilling;
14754
14758
  #sync;
14755
14759
  #mutex = new Mutex();
@@ -14773,6 +14777,7 @@ var SessionLogCore = class {
14773
14777
  this.#structuredResultSpilling = options.structuredResultSpilling ?? false;
14774
14778
  this.#now = options.now ?? Date.now;
14775
14779
  this.#spillAbove = Math.min(options.spillAboveBytes ?? SESSION_RECORD_MAX_BYTES, SESSION_RECORD_MAX_BYTES);
14780
+ this.#compactionSpillAbove = Math.min(options.compactionSpillAboveBytes ?? COMPACTION_SPILL_ABOVE_BYTES, this.#spillAbove);
14776
14781
  this.#sync = options.sync ?? "boundaries";
14777
14782
  }
14778
14783
  // ── state ──
@@ -15014,7 +15019,8 @@ var SessionLogCore = class {
15014
15019
  return candidate;
15015
15020
  const size = Buffer.byteLength(`${JSON.stringify(candidate)}
15016
15021
  `, "utf8");
15017
- if (size <= this.#spillAbove)
15022
+ const spillAbove = type === "compaction" ? this.#compactionSpillAbove : this.#spillAbove;
15023
+ if (size <= spillAbove)
15018
15024
  return candidate;
15019
15025
  if (type === "turn_completed") {
15020
15026
  if (typeof candidate.result !== "string")
@@ -15164,10 +15170,10 @@ async function* walkSessionLog(medium, options) {
15164
15170
  let anchorSeen = false;
15165
15171
  let stopped = false;
15166
15172
  outer: for await (const chunk of medium.stream(start)) {
15167
- let lines2;
15173
+ let lines;
15168
15174
  try {
15169
- lines2 = splitter.push(chunk);
15170
- for (const { line, offset } of lines2) {
15175
+ lines = splitter.push(chunk);
15176
+ for (const { line, offset } of lines) {
15171
15177
  let entry;
15172
15178
  try {
15173
15179
  entry = chain.accept(line, offset);
@@ -15325,6 +15331,7 @@ var DiskSessionLog = class _DiskSessionLog extends SessionLogCore {
15325
15331
  spills: new DiskSpillStore(options.sessionDir, options.now),
15326
15332
  now: options.now,
15327
15333
  spillAboveBytes: options.spillAboveBytes,
15334
+ compactionSpillAboveBytes: options.compactionSpillAboveBytes,
15328
15335
  structuredResultSpilling: options.structuredResultSpilling,
15329
15336
  sync: options.sync
15330
15337
  });
@@ -15412,6 +15419,7 @@ var InMemorySessionLog = class _InMemorySessionLog extends SessionLogCore {
15412
15419
  spills,
15413
15420
  now: options.now,
15414
15421
  spillAboveBytes: options.spillAboveBytes,
15422
+ compactionSpillAboveBytes: options.compactionSpillAboveBytes,
15415
15423
  structuredResultSpilling: options.structuredResultSpilling,
15416
15424
  sync: "none"
15417
15425
  });
@@ -15538,23 +15546,23 @@ function renderSkillsSection(skills) {
15538
15546
  if (forModel.length === 0)
15539
15547
  return null;
15540
15548
  const available = forModel.map((s) => {
15541
- const lines2 = [
15549
+ const lines = [
15542
15550
  "<skill>",
15543
15551
  `<name>${s.metadata.name}</name>`,
15544
15552
  `<description>${s.metadata.description.trim()}</description>`,
15545
15553
  `<location>${s.dirPath}/SKILL.md</location>`
15546
15554
  ];
15547
15555
  if (s.metadata.compatibility) {
15548
- lines2.push(`<compatibility>${s.metadata.compatibility}</compatibility>`);
15556
+ lines.push(`<compatibility>${s.metadata.compatibility}</compatibility>`);
15549
15557
  }
15550
15558
  if (s.metadata.license) {
15551
- lines2.push(`<license>${s.metadata.license}</license>`);
15559
+ lines.push(`<license>${s.metadata.license}</license>`);
15552
15560
  }
15553
15561
  if (s.metadata.allowedTools) {
15554
- lines2.push(`<pre_approved_tools>${s.metadata.allowedTools}</pre_approved_tools>`);
15562
+ lines.push(`<pre_approved_tools>${s.metadata.allowedTools}</pre_approved_tools>`);
15555
15563
  }
15556
- lines2.push("</skill>");
15557
- return lines2.join("\n");
15564
+ lines.push("</skill>");
15565
+ return lines.join("\n");
15558
15566
  }).join("\n");
15559
15567
  const loadedSkills = forModel.filter((s) => s.body);
15560
15568
  const sections = [
@@ -15586,23 +15594,23 @@ ${skillSections.join("\n\n")}`);
15586
15594
  }
15587
15595
  __name(renderSkillsSection, "renderSkillsSection");
15588
15596
  function renderOutputDiscipline(discipline) {
15589
- const lines2 = [];
15597
+ const lines = [];
15590
15598
  if (discipline.betweenToolCalls === "silent") {
15591
- lines2.push("- Emit zero words between tool calls. Call tools back-to-back with no narration.");
15599
+ lines.push("- Emit zero words between tool calls. Call tools back-to-back with no narration.");
15592
15600
  } else {
15593
- lines2.push("- Emit minimal text between tool calls. Keep inter-tool narration to a single short sentence.");
15601
+ lines.push("- Emit minimal text between tool calls. Keep inter-tool narration to a single short sentence.");
15594
15602
  }
15595
15603
  if (discipline.suppressInnerMonologue) {
15596
- lines2.push("- Do not output inner monologue, reasoning traces, or planning text between turns.");
15604
+ lines.push("- Do not output inner monologue, reasoning traces, or planning text between turns.");
15597
15605
  }
15598
15606
  if (discipline.finalResponse?.singleFileMaxWords) {
15599
- lines2.push(`- Final response for single-file changes: ${discipline.finalResponse.singleFileMaxWords} words maximum. Describe the why, not the what.`);
15607
+ lines.push(`- Final response for single-file changes: ${discipline.finalResponse.singleFileMaxWords} words maximum. Describe the why, not the what.`);
15600
15608
  }
15601
15609
  if (discipline.finalResponse?.multiFileMaxWords) {
15602
- lines2.push(`- Final response for multi-file changes: ${discipline.finalResponse.multiFileMaxWords} words maximum. Summarize intent and scope.`);
15610
+ lines.push(`- Final response for multi-file changes: ${discipline.finalResponse.multiFileMaxWords} words maximum. Summarize intent and scope.`);
15603
15611
  }
15604
15612
  return `## Output Discipline
15605
- ${lines2.join("\n")}`;
15613
+ ${lines.join("\n")}`;
15606
15614
  }
15607
15615
  __name(renderOutputDiscipline, "renderOutputDiscipline");
15608
15616
 
@@ -17769,13 +17777,13 @@ function describeRequiredInput(schema) {
17769
17777
  if (required.length === 0)
17770
17778
  return "No required parameters known.";
17771
17779
  const props = json2.properties ?? {};
17772
- const lines2 = required.map((name2) => {
17780
+ const lines = required.map((name2) => {
17773
17781
  const def = props[name2] ?? {};
17774
17782
  const type = def.type ?? "value";
17775
17783
  const desc = def.description ? ` \u2014 ${def.description}` : "";
17776
17784
  return `${name2}: ${type}${desc}`;
17777
17785
  });
17778
- return `Required: ${lines2.join(", ")}.`;
17786
+ return `Required: ${lines.join(", ")}.`;
17779
17787
  } catch {
17780
17788
  return "Could not introspect required parameters.";
17781
17789
  }
@@ -18172,7 +18180,7 @@ Additional note from the user: "${freeText}"`;
18172
18180
  __name(describeSingle, "describeSingle");
18173
18181
  var labelOf = /* @__PURE__ */ __name((item) => item.header ?? item.question, "labelOf");
18174
18182
  function describeBatch(answers) {
18175
- const lines2 = answers.map((answer) => {
18183
+ const lines = answers.map((answer) => {
18176
18184
  const { item, selected, freeText } = answer;
18177
18185
  if (selected.length > 0) {
18178
18186
  const joined3 = selected.map((s) => `"${s.label}"`).join(", ");
@@ -18185,7 +18193,7 @@ function describeBatch(answers) {
18185
18193
  const answered = answers.filter(isAnswered).length;
18186
18194
  return {
18187
18195
  output: `The user answered ${answered} of ${answers.length} questions:
18188
- ${lines2.join("\n")}`,
18196
+ ${lines.join("\n")}`,
18189
18197
  data: {
18190
18198
  questions: answers.map(({ item }) => ({
18191
18199
  questionId: item.id,
@@ -22772,9 +22780,9 @@ function renderEntry(entry) {
22772
22780
  return JSON.stringify(body).replaceAll("<", "\\u003c");
22773
22781
  }
22774
22782
  __name(renderEntry, "renderEntry");
22775
- function renderedLength(lines2) {
22783
+ function renderedLength(lines) {
22776
22784
  let total = 0;
22777
- for (const line of lines2)
22785
+ for (const line of lines)
22778
22786
  total += line.length + 1;
22779
22787
  return total;
22780
22788
  }
@@ -22954,7 +22962,7 @@ function createAutoReviewClassifier(options) {
22954
22962
  excludeCallIds: /* @__PURE__ */ new Set([request.call.id]),
22955
22963
  ...options.maxEntryChars !== void 0 ? { maxEntryChars: options.maxEntryChars } : {}
22956
22964
  });
22957
- const lines2 = entries2.map(renderEntry);
22965
+ const lines = entries2.map(renderEntry);
22958
22966
  const projected = projectAction(request.call.name, request.call.input, request.tools, ACTION_CHARS);
22959
22967
  if (projected.truncated) {
22960
22968
  return blocked(started, 0, "unreadable", "the action is too long for the safety check to read in full, so it was not run");
@@ -22964,10 +22972,10 @@ function createAutoReviewClassifier(options) {
22964
22972
  name: request.call.name,
22965
22973
  input: projected.text
22966
22974
  });
22967
- if (renderedLength(lines2) + action.length > maxChars2)
22975
+ if (renderedLength(lines) + action.length > maxChars2)
22968
22976
  return { verdict: "too_long" };
22969
22977
  const body = `<transcript>
22970
- ${lines2.join("\n")}
22978
+ ${lines.join("\n")}
22971
22979
  </transcript>
22972
22980
 
22973
22981
  The action under review:
@@ -25303,6 +25311,175 @@ function measureContent(content) {
25303
25311
  }
25304
25312
  __name(measureContent, "measureContent");
25305
25313
 
25314
+ // ../sdk/dist/tools/builtins/edit-match.js
25315
+ var LEFT_SINGLE_QUOTE = "\u2018";
25316
+ var RIGHT_SINGLE_QUOTE = "\u2019";
25317
+ var LEFT_DOUBLE_QUOTE = "\u201C";
25318
+ var RIGHT_DOUBLE_QUOTE = "\u201D";
25319
+ var HAS_UNICODE_ESCAPE = /\\u[0-9a-fA-F]{4}/;
25320
+ var HAS_NON_ASCII = /[\u0080-￿]/;
25321
+ function straightenQuotes(text9) {
25322
+ return text9.replaceAll(LEFT_SINGLE_QUOTE, "'").replaceAll(RIGHT_SINGLE_QUOTE, "'").replaceAll(LEFT_DOUBLE_QUOTE, '"').replaceAll(RIGHT_DOUBLE_QUOTE, '"');
25323
+ }
25324
+ __name(straightenQuotes, "straightenQuotes");
25325
+ function decodeUnicodeEscapes(text9) {
25326
+ return text9.replace(/(\\\\)|\\u([0-9a-fA-F]{4})/g, (whole, backslashes, hex2) => backslashes !== void 0 ? whole : String.fromCharCode(Number.parseInt(hex2, 16)));
25327
+ }
25328
+ __name(decodeUnicodeEscapes, "decodeUnicodeEscapes");
25329
+ function escapedLength(text9) {
25330
+ let nonAscii = 0;
25331
+ for (let i = 0; i < text9.length; i++)
25332
+ if (text9.charCodeAt(i) >= 128)
25333
+ nonAscii++;
25334
+ return text9.length + 5 * nonAscii;
25335
+ }
25336
+ __name(escapedLength, "escapedLength");
25337
+ function trailingBackslashes2(text9, at) {
25338
+ let count7 = 0;
25339
+ while (text9[at - 1 - count7] === "\\")
25340
+ count7++;
25341
+ return count7;
25342
+ }
25343
+ __name(trailingBackslashes2, "trailingBackslashes");
25344
+ function escapeRegExp(text9) {
25345
+ return text9.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
25346
+ }
25347
+ __name(escapeRegExp, "escapeRegExp");
25348
+ function buildEscapeTolerantPattern(model) {
25349
+ let pattern = "";
25350
+ for (let i = 0; i < model.length; i++) {
25351
+ const code = model.charCodeAt(i);
25352
+ if (code >= 128) {
25353
+ pattern += "\\\\u";
25354
+ for (const digit of code.toString(16).padStart(4, "0"))
25355
+ pattern += digit >= "a" ? `[${digit}${digit.toUpperCase()}]` : digit;
25356
+ } else {
25357
+ pattern += escapeRegExp(model[i]);
25358
+ }
25359
+ }
25360
+ return pattern;
25361
+ }
25362
+ __name(buildEscapeTolerantPattern, "buildEscapeTolerantPattern");
25363
+ function findEscapedForm(model, file) {
25364
+ if (trailingBackslashes2(model, model.length) % 2 === 1)
25365
+ return null;
25366
+ const sensitiveOffsets = model[0] === "\\" ? [0] : [];
25367
+ let offset = 0;
25368
+ for (let i = 0; i < model.length; i++) {
25369
+ if (model.charCodeAt(i) >= 128) {
25370
+ sensitiveOffsets.push(offset);
25371
+ offset += 6;
25372
+ } else {
25373
+ offset += 1;
25374
+ }
25375
+ }
25376
+ let regex;
25377
+ try {
25378
+ regex = new RegExp(buildEscapeTolerantPattern(model), "g");
25379
+ } catch {
25380
+ return null;
25381
+ }
25382
+ for (let match2 = regex.exec(file); match2 !== null; match2 = regex.exec(file)) {
25383
+ const at = match2.index;
25384
+ if (sensitiveOffsets.every((o) => trailingBackslashes2(file, at + o) % 2 === 0)) {
25385
+ return file.indexOf(match2[0]) === at ? match2[0] : null;
25386
+ }
25387
+ regex.lastIndex = at + 1;
25388
+ }
25389
+ return null;
25390
+ }
25391
+ __name(findEscapedForm, "findEscapedForm");
25392
+ function resolveOldString(content, oldString) {
25393
+ if (content.includes(oldString))
25394
+ return oldString;
25395
+ const straight = straightenQuotes(oldString);
25396
+ const quoteIndex = straightenQuotes(content).indexOf(straight);
25397
+ if (quoteIndex !== -1)
25398
+ return content.substring(quoteIndex, quoteIndex + oldString.length);
25399
+ if (HAS_UNICODE_ESCAPE.test(oldString)) {
25400
+ const decoded = decodeUnicodeEscapes(oldString);
25401
+ if (decoded !== oldString && content.includes(decoded))
25402
+ return decoded;
25403
+ }
25404
+ if (HAS_NON_ASCII.test(oldString)) {
25405
+ if (escapedLength(oldString) > content.length || !content.includes("\\u"))
25406
+ return null;
25407
+ return findEscapedForm(oldString, content);
25408
+ }
25409
+ return null;
25410
+ }
25411
+ __name(resolveOldString, "resolveOldString");
25412
+ function isOpeningPosition(chars, index) {
25413
+ if (index === 0)
25414
+ return true;
25415
+ const before = chars[index - 1];
25416
+ return before === " " || before === " " || before === "\n" || before === "\r" || before === "(" || before === "[" || before === "{" || before === "\u2014" || before === "\u2013";
25417
+ }
25418
+ __name(isOpeningPosition, "isOpeningPosition");
25419
+ function curlifyDoubleQuotes(text9) {
25420
+ const chars = [...text9];
25421
+ return chars.map((char, index) => char === '"' ? isOpeningPosition(chars, index) ? LEFT_DOUBLE_QUOTE : RIGHT_DOUBLE_QUOTE : char).join("");
25422
+ }
25423
+ __name(curlifyDoubleQuotes, "curlifyDoubleQuotes");
25424
+ function curlifySingleQuotes(text9) {
25425
+ const chars = [...text9];
25426
+ return chars.map((char, index) => {
25427
+ if (char !== "'")
25428
+ return char;
25429
+ const before = index > 0 ? chars[index - 1] : void 0;
25430
+ const after = index < chars.length - 1 ? chars[index + 1] : void 0;
25431
+ const betweenLetters = before !== void 0 && new RegExp("\\p{L}", "u").test(before) && after !== void 0 && new RegExp("\\p{L}", "u").test(after);
25432
+ if (betweenLetters)
25433
+ return RIGHT_SINGLE_QUOTE;
25434
+ return isOpeningPosition(chars, index) ? LEFT_SINGLE_QUOTE : RIGHT_SINGLE_QUOTE;
25435
+ }).join("");
25436
+ }
25437
+ __name(curlifySingleQuotes, "curlifySingleQuotes");
25438
+ function reconcileNewString(oldString, resolved2, newString) {
25439
+ if (resolved2 === oldString)
25440
+ return newString;
25441
+ if (HAS_NON_ASCII.test(oldString) && escapedLength(oldString) === resolved2.length && findEscapedForm(oldString, resolved2) !== null) {
25442
+ const perChar = /* @__PURE__ */ new Map();
25443
+ let upper = 0;
25444
+ let lower = 0;
25445
+ for (let oldIndex = 0, resolvedIndex = 0; oldIndex < oldString.length; oldIndex++) {
25446
+ const code = oldString.charCodeAt(oldIndex);
25447
+ if (code >= 128) {
25448
+ const hex2 = resolved2.slice(resolvedIndex + 2, resolvedIndex + 6);
25449
+ perChar.set(code, hex2);
25450
+ for (const digit of hex2)
25451
+ if (digit >= "a" && digit <= "f")
25452
+ lower++;
25453
+ else if (digit >= "A" && digit <= "F")
25454
+ upper++;
25455
+ resolvedIndex += 6;
25456
+ } else {
25457
+ resolvedIndex += 1;
25458
+ }
25459
+ }
25460
+ return newString.replace(/[\u0080-￿]/g, (char) => {
25461
+ const code = char.charCodeAt(0);
25462
+ const known = perChar.get(code);
25463
+ if (known !== void 0)
25464
+ return `\\u${known}`;
25465
+ const hex2 = code.toString(16).padStart(4, "0");
25466
+ return `\\u${upper > lower ? hex2.toUpperCase() : hex2}`;
25467
+ });
25468
+ }
25469
+ if (HAS_UNICODE_ESCAPE.test(oldString) && decodeUnicodeEscapes(oldString) === resolved2) {
25470
+ return decodeUnicodeEscapes(newString);
25471
+ }
25472
+ const hasCurlyDouble = resolved2.includes(LEFT_DOUBLE_QUOTE) || resolved2.includes(RIGHT_DOUBLE_QUOTE);
25473
+ const hasCurlySingle = resolved2.includes(LEFT_SINGLE_QUOTE) || resolved2.includes(RIGHT_SINGLE_QUOTE);
25474
+ let reconciled = newString;
25475
+ if (hasCurlyDouble)
25476
+ reconciled = curlifyDoubleQuotes(reconciled);
25477
+ if (hasCurlySingle)
25478
+ reconciled = curlifySingleQuotes(reconciled);
25479
+ return reconciled;
25480
+ }
25481
+ __name(reconcileNewString, "reconcileNewString");
25482
+
25306
25483
  // ../sdk/dist/tools/builtins/edit-apply.js
25307
25484
  function normalizeEditInput(input) {
25308
25485
  if (input.edits !== void 0) {
@@ -25398,23 +25575,35 @@ function applyOne(content, input) {
25398
25575
  return applyLineInsert(content, input);
25399
25576
  }
25400
25577
  const replacement = normalizeLineEndings(content, input);
25401
- if (!content.includes(replacement.oldString)) {
25402
- return {
25403
- success: false,
25404
- error: "old_string/oldStr not found in file. Make sure the string matches exactly, including whitespace and indentation."
25405
- };
25578
+ let oldString = replacement.oldString;
25579
+ let newString = replacement.newString;
25580
+ if (!content.includes(oldString)) {
25581
+ const resolved2 = resolveOldString(content, oldString);
25582
+ if (resolved2 === null) {
25583
+ return {
25584
+ success: false,
25585
+ error: "old_string/oldStr not found in file. Make sure the string matches exactly, including whitespace and indentation."
25586
+ };
25587
+ }
25588
+ newString = reconcileNewString(oldString, resolved2, newString);
25589
+ oldString = resolved2;
25590
+ }
25591
+ if (newString === "" && !oldString.endsWith("\n") && content.includes(`${oldString}
25592
+ `)) {
25593
+ oldString = `${oldString}
25594
+ `;
25406
25595
  }
25407
25596
  if (replacement.replace_all) {
25408
- const parts = content.split(replacement.oldString);
25597
+ const parts = content.split(oldString);
25409
25598
  const replacements = parts.length - 1;
25410
25599
  return {
25411
25600
  success: true,
25412
- content: parts.join(replacement.newString),
25601
+ content: parts.join(newString),
25413
25602
  replacements
25414
25603
  };
25415
25604
  }
25416
- const firstIndex = content.indexOf(replacement.oldString);
25417
- const secondIndex = content.indexOf(replacement.oldString, firstIndex + 1);
25605
+ const firstIndex = content.indexOf(oldString);
25606
+ const secondIndex = content.indexOf(oldString, firstIndex + 1);
25418
25607
  if (secondIndex !== -1) {
25419
25608
  const lineNumber = content.slice(0, firstIndex).split("\n").length;
25420
25609
  const secondLine = content.slice(0, secondIndex).split("\n").length;
@@ -25425,22 +25614,22 @@ function applyOne(content, input) {
25425
25614
  }
25426
25615
  return {
25427
25616
  success: true,
25428
- content: content.slice(0, firstIndex) + replacement.newString + content.slice(firstIndex + replacement.oldString.length),
25617
+ content: content.slice(0, firstIndex) + newString + content.slice(firstIndex + oldString.length),
25429
25618
  replacements: 1
25430
25619
  };
25431
25620
  }
25432
25621
  __name(applyOne, "applyOne");
25433
25622
  function applyLineInsert(content, input) {
25434
25623
  const hasTrailingNewline = content.endsWith("\n");
25435
- const lines2 = content.split("\n");
25624
+ const lines = content.split("\n");
25436
25625
  if (hasTrailingNewline)
25437
- lines2.pop();
25438
- const line = input.insertLine === "end" ? lines2.length : Math.min(Math.max(input.insertLine, 0), lines2.length);
25626
+ lines.pop();
25627
+ const line = input.insertLine === "end" ? lines.length : Math.min(Math.max(input.insertLine, 0), lines.length);
25439
25628
  const inserted = input.newString.endsWith("\n") ? input.newString.slice(0, -1).split("\n") : input.newString.split("\n");
25440
- lines2.splice(line, 0, ...inserted);
25629
+ lines.splice(line, 0, ...inserted);
25441
25630
  return {
25442
25631
  success: true,
25443
- content: `${lines2.join("\n")}${hasTrailingNewline ? "\n" : ""}`,
25632
+ content: `${lines.join("\n")}${hasTrailingNewline ? "\n" : ""}`,
25444
25633
  replacements: 1
25445
25634
  };
25446
25635
  }
@@ -25617,6 +25806,478 @@ function jsonStringEscapes(where) {
25617
25806
  }
25618
25807
  __name(jsonStringEscapes, "jsonStringEscapes");
25619
25808
 
25809
+ // ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js
25810
+ var Diff = class {
25811
+ static {
25812
+ __name(this, "Diff");
25813
+ }
25814
+ diff(oldStr, newStr, options = {}) {
25815
+ let callback;
25816
+ if (typeof options === "function") {
25817
+ callback = options;
25818
+ options = {};
25819
+ } else if ("callback" in options) {
25820
+ callback = options.callback;
25821
+ }
25822
+ const oldString = this.castInput(oldStr, options);
25823
+ const newString = this.castInput(newStr, options);
25824
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
25825
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
25826
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
25827
+ }
25828
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
25829
+ var _a2;
25830
+ const done = /* @__PURE__ */ __name((value) => {
25831
+ value = this.postProcess(value, options);
25832
+ if (callback) {
25833
+ setTimeout(function() {
25834
+ callback(value);
25835
+ }, 0);
25836
+ return void 0;
25837
+ } else {
25838
+ return value;
25839
+ }
25840
+ }, "done");
25841
+ const newLen = newTokens.length, oldLen = oldTokens.length;
25842
+ let editLength = 1;
25843
+ let maxEditLength = newLen + oldLen;
25844
+ if (options.maxEditLength != null) {
25845
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
25846
+ }
25847
+ const maxExecutionTime = (_a2 = options.timeout) !== null && _a2 !== void 0 ? _a2 : Infinity;
25848
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
25849
+ const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
25850
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
25851
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
25852
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
25853
+ }
25854
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
25855
+ const execEditLength = /* @__PURE__ */ __name(() => {
25856
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
25857
+ let basePath;
25858
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
25859
+ if (removePath) {
25860
+ bestPath[diagonalPath - 1] = void 0;
25861
+ }
25862
+ let canAdd = false;
25863
+ if (addPath) {
25864
+ const addPathNewPos = addPath.oldPos - diagonalPath;
25865
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
25866
+ }
25867
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
25868
+ if (!canAdd && !canRemove) {
25869
+ bestPath[diagonalPath] = void 0;
25870
+ continue;
25871
+ }
25872
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
25873
+ basePath = this.addToPath(addPath, true, false, 0, options);
25874
+ } else {
25875
+ basePath = this.addToPath(removePath, false, true, 1, options);
25876
+ }
25877
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
25878
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
25879
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
25880
+ } else {
25881
+ bestPath[diagonalPath] = basePath;
25882
+ if (basePath.oldPos + 1 >= oldLen) {
25883
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
25884
+ }
25885
+ if (newPos + 1 >= newLen) {
25886
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
25887
+ }
25888
+ }
25889
+ }
25890
+ editLength++;
25891
+ }, "execEditLength");
25892
+ if (callback) {
25893
+ (/* @__PURE__ */ __name(function exec() {
25894
+ setTimeout(function() {
25895
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
25896
+ return callback(void 0);
25897
+ }
25898
+ if (!execEditLength()) {
25899
+ exec();
25900
+ }
25901
+ }, 0);
25902
+ }, "exec"))();
25903
+ } else {
25904
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
25905
+ const ret = execEditLength();
25906
+ if (ret) {
25907
+ return ret;
25908
+ }
25909
+ }
25910
+ }
25911
+ }
25912
+ addToPath(path2, added, removed, oldPosInc, options) {
25913
+ const last = path2.lastComponent;
25914
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
25915
+ return {
25916
+ oldPos: path2.oldPos + oldPosInc,
25917
+ lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
25918
+ };
25919
+ } else {
25920
+ return {
25921
+ oldPos: path2.oldPos + oldPosInc,
25922
+ lastComponent: { count: 1, added, removed, previousComponent: last }
25923
+ };
25924
+ }
25925
+ }
25926
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
25927
+ const newLen = newTokens.length, oldLen = oldTokens.length;
25928
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
25929
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
25930
+ newPos++;
25931
+ oldPos++;
25932
+ commonCount++;
25933
+ if (options.oneChangePerToken) {
25934
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
25935
+ }
25936
+ }
25937
+ if (commonCount && !options.oneChangePerToken) {
25938
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
25939
+ }
25940
+ basePath.oldPos = oldPos;
25941
+ return newPos;
25942
+ }
25943
+ equals(left, right, options) {
25944
+ if (options.comparator) {
25945
+ return options.comparator(left, right);
25946
+ } else {
25947
+ return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
25948
+ }
25949
+ }
25950
+ removeEmpty(array) {
25951
+ const ret = [];
25952
+ for (let i = 0; i < array.length; i++) {
25953
+ if (array[i]) {
25954
+ ret.push(array[i]);
25955
+ }
25956
+ }
25957
+ return ret;
25958
+ }
25959
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25960
+ castInput(value, options) {
25961
+ return value;
25962
+ }
25963
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25964
+ tokenize(value, options) {
25965
+ return Array.from(value);
25966
+ }
25967
+ join(chars) {
25968
+ return chars.join("");
25969
+ }
25970
+ postProcess(changeObjects, options) {
25971
+ return changeObjects;
25972
+ }
25973
+ get useLongestToken() {
25974
+ return false;
25975
+ }
25976
+ buildValues(lastComponent, newTokens, oldTokens) {
25977
+ const components = [];
25978
+ let nextComponent;
25979
+ while (lastComponent) {
25980
+ components.push(lastComponent);
25981
+ nextComponent = lastComponent.previousComponent;
25982
+ delete lastComponent.previousComponent;
25983
+ lastComponent = nextComponent;
25984
+ }
25985
+ components.reverse();
25986
+ const componentLen = components.length;
25987
+ let componentPos = 0, newPos = 0, oldPos = 0;
25988
+ for (; componentPos < componentLen; componentPos++) {
25989
+ const component = components[componentPos];
25990
+ if (!component.removed) {
25991
+ if (!component.added && this.useLongestToken) {
25992
+ let value = newTokens.slice(newPos, newPos + component.count);
25993
+ value = value.map(function(value2, i) {
25994
+ const oldValue = oldTokens[oldPos + i];
25995
+ return oldValue.length > value2.length ? oldValue : value2;
25996
+ });
25997
+ component.value = this.join(value);
25998
+ } else {
25999
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
26000
+ }
26001
+ newPos += component.count;
26002
+ if (!component.added) {
26003
+ oldPos += component.count;
26004
+ }
26005
+ } else {
26006
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
26007
+ oldPos += component.count;
26008
+ }
26009
+ }
26010
+ return components;
26011
+ }
26012
+ };
26013
+
26014
+ // ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/line.js
26015
+ var LineDiff = class extends Diff {
26016
+ static {
26017
+ __name(this, "LineDiff");
26018
+ }
26019
+ constructor() {
26020
+ super(...arguments);
26021
+ this.tokenize = tokenize;
26022
+ }
26023
+ equals(left, right, options) {
26024
+ if (options.ignoreWhitespace) {
26025
+ if (!options.newlineIsToken || !left.includes("\n")) {
26026
+ left = left.trim();
26027
+ }
26028
+ if (!options.newlineIsToken || !right.includes("\n")) {
26029
+ right = right.trim();
26030
+ }
26031
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
26032
+ if (left.endsWith("\n")) {
26033
+ left = left.slice(0, -1);
26034
+ }
26035
+ if (right.endsWith("\n")) {
26036
+ right = right.slice(0, -1);
26037
+ }
26038
+ }
26039
+ return super.equals(left, right, options);
26040
+ }
26041
+ };
26042
+ var lineDiff = new LineDiff();
26043
+ function diffLines(oldStr, newStr, options) {
26044
+ return lineDiff.diff(oldStr, newStr, options);
26045
+ }
26046
+ __name(diffLines, "diffLines");
26047
+ function tokenize(value, options) {
26048
+ if (options.stripTrailingCr) {
26049
+ value = value.replace(/\r\n/g, "\n");
26050
+ }
26051
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
26052
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
26053
+ linesAndNewlines.pop();
26054
+ }
26055
+ for (let i = 0; i < linesAndNewlines.length; i++) {
26056
+ const line = linesAndNewlines[i];
26057
+ if (i % 2 && !options.newlineIsToken) {
26058
+ retLines[retLines.length - 1] += line;
26059
+ } else {
26060
+ retLines.push(line);
26061
+ }
26062
+ }
26063
+ return retLines;
26064
+ }
26065
+ __name(tokenize, "tokenize");
26066
+
26067
+ // ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/patch/create.js
26068
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
26069
+ let optionsObj;
26070
+ if (!options) {
26071
+ optionsObj = {};
26072
+ } else if (typeof options === "function") {
26073
+ optionsObj = { callback: options };
26074
+ } else {
26075
+ optionsObj = options;
26076
+ }
26077
+ if (typeof optionsObj.context === "undefined") {
26078
+ optionsObj.context = 4;
26079
+ }
26080
+ const context2 = optionsObj.context;
26081
+ if (optionsObj.newlineIsToken) {
26082
+ throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
26083
+ }
26084
+ if (!optionsObj.callback) {
26085
+ return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
26086
+ } else {
26087
+ const { callback } = optionsObj;
26088
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: /* @__PURE__ */ __name((diff) => {
26089
+ const patch = diffLinesResultToPatch(diff);
26090
+ callback(patch);
26091
+ }, "callback") }));
26092
+ }
26093
+ function diffLinesResultToPatch(diff) {
26094
+ if (!diff) {
26095
+ return;
26096
+ }
26097
+ diff.push({ value: "", lines: [] });
26098
+ function contextLines(lines) {
26099
+ return lines.map(function(entry) {
26100
+ return " " + entry;
26101
+ });
26102
+ }
26103
+ __name(contextLines, "contextLines");
26104
+ const hunks2 = [];
26105
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
26106
+ for (let i = 0; i < diff.length; i++) {
26107
+ const current = diff[i], lines = current.lines || splitLines(current.value);
26108
+ current.lines = lines;
26109
+ if (current.added || current.removed) {
26110
+ if (!oldRangeStart) {
26111
+ const prev = diff[i - 1];
26112
+ oldRangeStart = oldLine;
26113
+ newRangeStart = newLine;
26114
+ if (prev) {
26115
+ curRange = context2 > 0 ? contextLines(prev.lines.slice(-context2)) : [];
26116
+ oldRangeStart -= curRange.length;
26117
+ newRangeStart -= curRange.length;
26118
+ }
26119
+ }
26120
+ for (const line of lines) {
26121
+ curRange.push((current.added ? "+" : "-") + line);
26122
+ }
26123
+ if (current.added) {
26124
+ newLine += lines.length;
26125
+ } else {
26126
+ oldLine += lines.length;
26127
+ }
26128
+ } else {
26129
+ if (oldRangeStart) {
26130
+ if (lines.length <= context2 * 2 && i < diff.length - 2) {
26131
+ for (const line of contextLines(lines)) {
26132
+ curRange.push(line);
26133
+ }
26134
+ } else {
26135
+ const contextSize = Math.min(lines.length, context2);
26136
+ for (const line of contextLines(lines.slice(0, contextSize))) {
26137
+ curRange.push(line);
26138
+ }
26139
+ const hunk = {
26140
+ oldStart: oldRangeStart,
26141
+ oldLines: oldLine - oldRangeStart + contextSize,
26142
+ newStart: newRangeStart,
26143
+ newLines: newLine - newRangeStart + contextSize,
26144
+ lines: curRange
26145
+ };
26146
+ hunks2.push(hunk);
26147
+ oldRangeStart = 0;
26148
+ newRangeStart = 0;
26149
+ curRange = [];
26150
+ }
26151
+ }
26152
+ oldLine += lines.length;
26153
+ newLine += lines.length;
26154
+ }
26155
+ }
26156
+ for (const hunk of hunks2) {
26157
+ for (let i = 0; i < hunk.lines.length; i++) {
26158
+ if (hunk.lines[i].endsWith("\n")) {
26159
+ hunk.lines[i] = hunk.lines[i].slice(0, -1);
26160
+ } else {
26161
+ hunk.lines.splice(i + 1, 0, "\");
26162
+ i++;
26163
+ }
26164
+ }
26165
+ }
26166
+ return {
26167
+ oldFileName,
26168
+ newFileName,
26169
+ oldHeader,
26170
+ newHeader,
26171
+ hunks: hunks2
26172
+ };
26173
+ }
26174
+ __name(diffLinesResultToPatch, "diffLinesResultToPatch");
26175
+ }
26176
+ __name(structuredPatch, "structuredPatch");
26177
+ function splitLines(text9) {
26178
+ const hasTrailingNl = text9.endsWith("\n");
26179
+ const result = text9.split("\n").map((line) => line + "\n");
26180
+ if (hasTrailingNl) {
26181
+ result.pop();
26182
+ } else {
26183
+ result.push(result.pop().slice(0, -1));
26184
+ }
26185
+ return result;
26186
+ }
26187
+ __name(splitLines, "splitLines");
26188
+
26189
+ // ../sdk/dist/tools/builtins/line-diff.js
26190
+ var CONTEXT_LINES = 3;
26191
+ var DIFF_TIMEOUT_MS = 5e3;
26192
+ var MAX_CARRIED_DIFF_LINES = 400;
26193
+ var MAX_CARRIED_LINE_CHARS = 500;
26194
+ function cutRow(row) {
26195
+ if (row.length <= MAX_CARRIED_LINE_CHARS)
26196
+ return row;
26197
+ const cut = row.slice(0, MAX_CARRIED_LINE_CHARS - 1).replace(/[\uD800-\uDBFF]$/, "");
26198
+ return `${cut}\u2026`;
26199
+ }
26200
+ __name(cutRow, "cutRow");
26201
+ function splitKeepingTerminators(text9) {
26202
+ return text9.length === 0 ? [] : text9.match(/[^\n]*\n|[^\n]+$/g) ?? [];
26203
+ }
26204
+ __name(splitKeepingTerminators, "splitKeepingTerminators");
26205
+ function coarseDiff(before, after) {
26206
+ const a = splitKeepingTerminators(before);
26207
+ const b = splitKeepingTerminators(after);
26208
+ let head2 = 0;
26209
+ while (head2 < a.length && head2 < b.length && a[head2] === b[head2])
26210
+ head2++;
26211
+ let tail = 0;
26212
+ while (tail < a.length - head2 && tail < b.length - head2 && a[a.length - 1 - tail] === b[b.length - 1 - tail])
26213
+ tail++;
26214
+ const removed = a.slice(head2, a.length - tail);
26215
+ const added = b.slice(head2, b.length - tail);
26216
+ const rows = [
26217
+ ...removed.map((line) => `-${line.replace(/\n$/, "")}`),
26218
+ ...added.map((line) => `+${line.replace(/\n$/, "")}`)
26219
+ ];
26220
+ const kept = rows.slice(0, MAX_CARRIED_DIFF_LINES).map(cutRow);
26221
+ return {
26222
+ added: added.length,
26223
+ removed: removed.length,
26224
+ hunks: rows.length === 0 ? [] : [
26225
+ {
26226
+ oldStart: head2 + 1,
26227
+ oldLines: removed.length,
26228
+ newStart: head2 + 1,
26229
+ newLines: added.length,
26230
+ lines: kept
26231
+ }
26232
+ ],
26233
+ truncated: rows.length > kept.length
26234
+ };
26235
+ }
26236
+ __name(coarseDiff, "coarseDiff");
26237
+ function lineDiff2(before, after) {
26238
+ if (before === after)
26239
+ return { added: 0, removed: 0, hunks: [], truncated: false };
26240
+ const patch = structuredPatch("a", "a", before, after, void 0, void 0, {
26241
+ context: CONTEXT_LINES,
26242
+ timeout: DIFF_TIMEOUT_MS
26243
+ });
26244
+ if (patch === void 0)
26245
+ return coarseDiff(before, after);
26246
+ let added = 0;
26247
+ let removed = 0;
26248
+ let budget = MAX_CARRIED_DIFF_LINES;
26249
+ let truncated = false;
26250
+ const hunks2 = [];
26251
+ for (const hunk of patch.hunks) {
26252
+ const rows = [];
26253
+ for (const row of hunk.lines) {
26254
+ if (row.startsWith("\\"))
26255
+ continue;
26256
+ if (row.startsWith("+"))
26257
+ added++;
26258
+ else if (row.startsWith("-"))
26259
+ removed++;
26260
+ if (budget > 0) {
26261
+ rows.push(cutRow(row));
26262
+ budget--;
26263
+ } else {
26264
+ truncated = true;
26265
+ }
26266
+ }
26267
+ if (rows.length > 0) {
26268
+ hunks2.push({
26269
+ oldStart: hunk.oldStart,
26270
+ oldLines: hunk.oldLines,
26271
+ newStart: hunk.newStart,
26272
+ newLines: hunk.newLines,
26273
+ lines: rows
26274
+ });
26275
+ }
26276
+ }
26277
+ return { added, removed, hunks: hunks2, truncated };
26278
+ }
26279
+ __name(lineDiff2, "lineDiff");
26280
+
25620
26281
  // ../sdk/dist/tools/builtins/edit.js
25621
26282
  var inputSchema3 = external_exports.object({
25622
26283
  path: external_exports.string().refine((value) => value.trim().length > 0, "Path must not be empty.").describe("Path to the file to edit. Must not be empty."),
@@ -25813,6 +26474,22 @@ function admitAgainstRead(context2, key5, content, operations) {
25813
26474
  }
25814
26475
  __name(admitAgainstRead, "admitAgainstRead");
25815
26476
  var EDIT_SHAPES = 'Three shapes. Replace: {"path":"file.md","old_string":"exact unique text","new_string":"replacement text"} (optional "replace_all": true). Insert: {"path":"file.md","insertLine":"end","new_string":"text to add"} where insertLine is a non-negative line number or "end". Batch: {"path":"file.md","edits":[{"old_string":"a","new_string":"b"},{"old_string":"c","new_string":"d"}]} applied in order, all or nothing. Exactly one of old_string, insertLine or edits \u2014 a call carrying more than one of them is refused rather than resolved.';
26477
+ function editFacts(path2, replacements, before, after) {
26478
+ const diff = lineDiff2(before, after);
26479
+ return {
26480
+ diff,
26481
+ facts: {
26482
+ kind: "edit",
26483
+ path: path2,
26484
+ replacements,
26485
+ added: diff.added,
26486
+ removed: diff.removed,
26487
+ ...diff.hunks.length > 0 ? { hunks: diff.hunks } : {},
26488
+ ...diff.truncated ? { hunksTruncated: true } : {}
26489
+ }
26490
+ };
26491
+ }
26492
+ __name(editFacts, "editFacts");
25816
26493
  var EditTool = defineTool({
25817
26494
  name: "edit",
25818
26495
  description: 'Makes targeted edits to a file using exact string find-and-replace or line insertion. THIS IS THE PREFERRED WAY TO MODIFY AN EXISTING FILE \u2014 never reach for `write` to change a file that already exists, because `write` overwrites the whole body and discards earlier work on partial failure. `edit` keeps the rest of the file byte-for-byte intact and is recoverable: if a single edit fails (old_string/oldStr ambiguous, broader restructuring needed), follow up with another `edit` instead of re-emitting the entire file via `write`. The old_string/oldStr must be unique in the file unless replace_all is true. For insertions, pass insertLine plus new_string/newStr; use insertLine: "end" to extend a file at the end. Self-budget new_string/newStr under 12000 characters before emitting the tool call; use repeated bounded edits for long sections. Preserves file formatting and indentation. To make several changes to ONE file that only make sense together, send them as `edits`: a list of {old_string, new_string} applied in order and committed as one write \u2014 if any of them does not apply, nothing is written and the reply names which one, so the file is never left half-changed.',
@@ -25918,19 +26595,16 @@ var EditTool = defineTool({
25918
26595
  }
25919
26596
  await context2.sandbox.writeFile(parsed.data.path, result2.content);
25920
26597
  recordEditedContent(context2, parsed.data.path, result2.content);
26598
+ const changed2 = editFacts(parsed.data.path, result2.replacements, content2, result2.content);
25921
26599
  return {
25922
26600
  success: true,
25923
- output: `Edited ${parsed.data.path}: ${result2.replacements} replacement(s) [sandboxed]`,
26601
+ output: `Edited ${parsed.data.path}: ${result2.replacements} replacement(s) (+${changed2.diff.added} -${changed2.diff.removed}) [sandboxed]`,
25924
26602
  data: {
25925
26603
  path: parsed.data.path,
25926
26604
  replacements: result2.replacements,
25927
26605
  sandboxed: true
25928
26606
  },
25929
- facts: {
25930
- kind: "edit",
25931
- path: parsed.data.path,
25932
- replacements: result2.replacements
25933
- }
26607
+ facts: changed2.facts
25934
26608
  };
25935
26609
  }
25936
26610
  const hostPath = filePath;
@@ -25943,15 +26617,12 @@ var EditTool = defineTool({
25943
26617
  return { success: false, output: "", error: result.error };
25944
26618
  await atomicWriteFile2(hostPath, result.content);
25945
26619
  recordEditedContent(context2, hostPath, result.content);
26620
+ const changed = editFacts(hostPath, result.replacements, content, result.content);
25946
26621
  return {
25947
26622
  success: true,
25948
- output: `Edited ${hostPath}: ${result.replacements} replacement(s)`,
26623
+ output: `Edited ${hostPath}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed})`,
25949
26624
  data: { path: hostPath, replacements: result.replacements },
25950
- facts: {
25951
- kind: "edit",
25952
- path: hostPath,
25953
- replacements: result.replacements
25954
- }
26625
+ facts: changed.facts
25955
26626
  };
25956
26627
  });
25957
26628
  }
@@ -25987,13 +26658,13 @@ function clipTail(text9, max) {
25987
26658
  __name(clipTail, "clipTail");
25988
26659
  function windowText(text9, totalBytes = Buffer.byteLength(text9, "utf8")) {
25989
26660
  const body = text9.endsWith("\n") ? text9.slice(0, -1) : text9;
25990
- const lines2 = body.length === 0 ? [] : body.split("\n");
25991
- const totalLines = lines2.length;
26661
+ const lines = body.length === 0 ? [] : body.split("\n");
26662
+ const totalLines = lines.length;
25992
26663
  if (totalLines <= WINDOW_HEAD_LINES + WINDOW_TAIL_LINES && body.length <= WINDOW_HALF_CHARS * 2) {
25993
26664
  return { head: body, totalLines, totalBytes };
25994
26665
  }
25995
- const headLines = lines2.slice(0, WINDOW_HEAD_LINES);
25996
- const tailLines = totalLines > WINDOW_HEAD_LINES ? lines2.slice(Math.max(WINDOW_HEAD_LINES, totalLines - WINDOW_TAIL_LINES)) : [];
26666
+ const headLines = lines.slice(0, WINDOW_HEAD_LINES);
26667
+ const tailLines = totalLines > WINDOW_HEAD_LINES ? lines.slice(Math.max(WINDOW_HEAD_LINES, totalLines - WINDOW_TAIL_LINES)) : [];
25997
26668
  const head2 = clipHead(headLines.join("\n"), WINDOW_HALF_CHARS);
25998
26669
  const tail = clipTail(tailLines.join("\n"), WINDOW_HALF_CHARS);
25999
26670
  const omittedLines = totalLines - headLines.length - tailLines.length;
@@ -26030,15 +26701,15 @@ __name(looksBinary, "looksBinary");
26030
26701
  // ../sdk/dist/tools/builtins/read-render.js
26031
26702
  var DEFAULT_READ_LINES = 2e3;
26032
26703
  function renderNumberedRead(content, input) {
26033
- const lines2 = content.split("\n");
26034
- const { start, end } = resolveReadWindow(input, lines2.length);
26035
- const selected = lines2.slice(start, end);
26704
+ const lines = content.split("\n");
26705
+ const { start, end } = resolveReadWindow(input, lines.length);
26706
+ const selected = lines.slice(start, end);
26036
26707
  const numbered2 = selected.map((line, i) => `${start + i + 1} ${line}`).join("\n");
26037
26708
  return {
26038
- output: numbered2 + partialViewNotice(start, selected.length, lines2.length),
26039
- totalLines: lines2.length,
26709
+ output: numbered2 + partialViewNotice(start, selected.length, lines.length),
26710
+ totalLines: lines.length,
26040
26711
  returnedLines: selected.length,
26041
- partial: selected.length < lines2.length
26712
+ partial: selected.length < lines.length
26042
26713
  };
26043
26714
  }
26044
26715
  __name(renderNumberedRead, "renderNumberedRead");
@@ -26100,9 +26771,9 @@ function renderCappedRead(content, byteLength, input, options) {
26100
26771
  message: `File content (${humanBytes(byteLength)}) exceeds the maximum allowed size (${humanBytes(maxBytes)}). Use offset and limit to read part of it, or search for what you need instead of reading all of it.${hint}`
26101
26772
  };
26102
26773
  }
26103
- const lines2 = content.split("\n");
26104
- const { start, end } = resolveReadWindow(input, lines2.length);
26105
- const selected = lines2.slice(start, end);
26774
+ const lines = content.split("\n");
26775
+ const { start, end } = resolveReadWindow(input, lines.length);
26776
+ const selected = lines.slice(start, end);
26106
26777
  const selectedText = selected.join("\n");
26107
26778
  const selectedBytes = Buffer.byteLength(selectedText, "utf8");
26108
26779
  if (selectedBytes > maxTokens * SELECTED_BYTES_PER_TOKEN) {
@@ -26124,7 +26795,7 @@ function renderCappedRead(content, byteLength, input, options) {
26124
26795
  }
26125
26796
  return {
26126
26797
  ok: true,
26127
- rendered: trimFirstPage(selected, lines2.length, selectedText, tokens, maxTokens, options.path)
26798
+ rendered: trimFirstPage(selected, lines.length, selectedText, tokens, maxTokens, options.path)
26128
26799
  };
26129
26800
  }
26130
26801
  __name(renderCappedRead, "renderCappedRead");
@@ -26170,8 +26841,8 @@ function trimFirstPage(selected, totalLines, selectedText, tokens, maxTokens, pa
26170
26841
  };
26171
26842
  }
26172
26843
  __name(trimFirstPage, "trimFirstPage");
26173
- function numbered(lines2) {
26174
- return lines2.map((line, i) => `${i + 1} ${line}`).join("\n");
26844
+ function numbered(lines) {
26845
+ return lines.map((line, i) => `${i + 1} ${line}`).join("\n");
26175
26846
  }
26176
26847
  __name(numbered, "numbered");
26177
26848
 
@@ -26388,33 +27059,19 @@ import { dirname as dirname9 } from "node:path";
26388
27059
 
26389
27060
  // ../sdk/dist/tools/builtins/file-write-result.js
26390
27061
  import { createHash as createHash8 } from "node:crypto";
26391
- function lines(text9) {
26392
- if (text9 === "")
26393
- return [];
26394
- const result = text9.split("\n");
26395
- if (result.at(-1) === "")
26396
- result.pop();
26397
- return result;
27062
+ function previewSide(hunks2, changed) {
27063
+ return hunks2.flatMap((hunk) => hunk.lines).filter((row) => row.startsWith(" ") || row.startsWith(changed)).map((row) => `${row.slice(1)}
27064
+ `).join("");
26398
27065
  }
26399
- __name(lines, "lines");
27066
+ __name(previewSide, "previewSide");
26400
27067
  function fileWriteResult(path2, before, after, sandboxed = false) {
26401
27068
  const operation = before === null ? "write" : before === void 0 ? "create" : before === after ? "unchanged" : "replace";
26402
- const oldLines = lines(before ?? "");
26403
- const newLines = lines(after);
26404
- let start = 0;
26405
- let end = 0;
26406
- if (typeof before === "string") {
26407
- while (start < oldLines.length && start < newLines.length && oldLines[start] === newLines[start])
26408
- start++;
26409
- while (end < oldLines.length - start && end < newLines.length - start && oldLines[oldLines.length - end - 1] === newLines[newLines.length - end - 1])
26410
- end++;
26411
- }
26412
- const removed = oldLines.slice(start, oldLines.length - end);
26413
- const added = newLines.slice(start, newLines.length - end);
27069
+ const diff = lineDiff2(typeof before === "string" ? before : "", after);
27070
+ const known = before !== null;
26414
27071
  const bytes = Buffer.byteLength(after, "utf8");
26415
27072
  const label5 = operation === "create" ? "Created" : operation === "replace" ? "Updated" : operation === "unchanged" ? "Unchanged" : "Wrote";
26416
27073
  const newlineChanged = typeof before === "string" && before.endsWith("\n") !== after.endsWith("\n");
26417
- const summary2 = `${label5} ${path2}${before === null ? "" : ` (+${added.length} -${removed.length})`}${newlineChanged ? " \xB7 final newline changed" : ""}`;
27074
+ const summary2 = `${label5} ${path2}${before === null ? "" : ` (+${diff.added} -${diff.removed})`}${newlineChanged ? " \xB7 final newline changed" : ""}`;
26418
27075
  return {
26419
27076
  success: true,
26420
27077
  output: `${summary2} \xB7 ${bytes} bytes`,
@@ -26423,7 +27080,12 @@ function fileWriteResult(path2, before, after, sandboxed = false) {
26423
27080
  path: path2,
26424
27081
  operation: operation === "create" ? "created" : operation === "replace" ? "updated" : operation === "unchanged" ? "unchanged" : "wrote",
26425
27082
  bytes,
26426
- ...before === null ? {} : { added: added.length, removed: removed.length }
27083
+ ...known ? {
27084
+ added: diff.added,
27085
+ removed: diff.removed,
27086
+ ...diff.hunks.length > 0 ? { hunks: diff.hunks } : {},
27087
+ ...diff.truncated ? { hunksTruncated: true } : {}
27088
+ } : {}
26427
27089
  },
26428
27090
  data: {
26429
27091
  path: path2,
@@ -26433,15 +27095,13 @@ function fileWriteResult(path2, before, after, sandboxed = false) {
26433
27095
  operation,
26434
27096
  ...before === null ? {} : {
26435
27097
  preview: {
26436
- before: removed.length ? `${removed.join("\n")}
26437
- ` : "",
26438
- after: added.length ? `${added.join("\n")}
26439
- ` : ""
27098
+ before: previewSide(diff.hunks, "-"),
27099
+ after: previewSide(diff.hunks, "+")
26440
27100
  }
26441
27101
  },
26442
27102
  bytes,
26443
27103
  sha256: createHash8("sha256").update(after, "utf8").digest("hex"),
26444
- ...before === null ? {} : { added: added.length, removed: removed.length, newlineChanged }
27104
+ ...before === null ? {} : { added: diff.added, removed: diff.removed, newlineChanged }
26445
27105
  }
26446
27106
  }
26447
27107
  };
@@ -26911,24 +27571,24 @@ function observeRead(history, call2, claims, withBody, budget) {
26911
27571
  }
26912
27572
  __name(observeRead, "observeRead");
26913
27573
  function wholeFileRenderUnits(body, window2) {
26914
- const lines2 = countLines(body);
26915
- const { start, end } = resolveReadWindow(window2, lines2);
26916
- if (start !== 0 || end < lines2)
27574
+ const lines = countLines(body);
27575
+ const { start, end } = resolveReadWindow(window2, lines);
27576
+ if (start !== 0 || end < lines)
26917
27577
  return void 0;
26918
- return body.length + lines2 + lineNumberUnits(lines2);
27578
+ return body.length + lines + lineNumberUnits(lines);
26919
27579
  }
26920
27580
  __name(wholeFileRenderUnits, "wholeFileRenderUnits");
26921
27581
  function countLines(body) {
26922
- let lines2 = 1;
27582
+ let lines = 1;
26923
27583
  for (let at = body.indexOf("\n"); at !== -1; at = body.indexOf("\n", at + 1))
26924
- lines2++;
26925
- return lines2;
27584
+ lines++;
27585
+ return lines;
26926
27586
  }
26927
27587
  __name(countLines, "countLines");
26928
- function lineNumberUnits(lines2) {
27588
+ function lineNumberUnits(lines) {
26929
27589
  let units = 0;
26930
- for (let width = 1, first = 1; first <= lines2; width++, first *= 10)
26931
- units += (Math.min(lines2, first * 10 - 1) - first + 1) * width;
27590
+ for (let width = 1, first = 1; first <= lines; width++, first *= 10)
27591
+ units += (Math.min(lines, first * 10 - 1) - first + 1) * width;
26932
27592
  return units;
26933
27593
  }
26934
27594
  __name(lineNumberUnits, "lineNumberUnits");
@@ -29291,51 +29951,51 @@ function renderPlan(plan) {
29291
29951
  }
29292
29952
  __name(renderPlan, "renderPlan");
29293
29953
  function renderFiles(files) {
29294
- const lines2 = [];
29954
+ const lines = [];
29295
29955
  for (const [, slot] of files) {
29296
- lines2.push(`- \`${slot.path}\``);
29956
+ lines.push(`- \`${slot.path}\``);
29297
29957
  for (const action of slot.actions) {
29298
29958
  if (action.type === "delete") {
29299
- lines2.push(" - deleted");
29959
+ lines.push(" - deleted");
29300
29960
  } else {
29301
29961
  const desc = "detail" in action ? action.detail : action.summary;
29302
- lines2.push(` - ${action.type}: ${desc ?? ""}`);
29962
+ lines.push(` - ${action.type}: ${desc ?? ""}`);
29303
29963
  }
29304
29964
  }
29305
29965
  }
29306
- return lines2.join("\n");
29966
+ return lines.join("\n");
29307
29967
  }
29308
29968
  __name(renderFiles, "renderFiles");
29309
29969
  function renderList(items, evictedCount = 0) {
29310
- const lines2 = items.map((item) => `- ${item}`);
29970
+ const lines = items.map((item) => `- ${item}`);
29311
29971
  if (evictedCount > 0) {
29312
29972
  const noun = evictedCount === 1 ? "entry" : "entries";
29313
- lines2.push(`- _(${evictedCount} ${noun} dropped to stay within the state budget)_`);
29973
+ lines.push(`- _(${evictedCount} ${noun} dropped to stay within the state budget)_`);
29314
29974
  }
29315
- return lines2.join("\n");
29975
+ return lines.join("\n");
29316
29976
  }
29317
29977
  __name(renderList, "renderList");
29318
29978
  function renderToolResults(results, evictedCount = 0) {
29319
- const lines2 = results.map((r) => `- **${r.tool}**: ${r.summary}`);
29979
+ const lines = results.map((r) => `- **${r.tool}**: ${r.summary}`);
29320
29980
  if (evictedCount > 0) {
29321
29981
  const noun = evictedCount === 1 ? "result" : "results";
29322
- lines2.push(`- _(${evictedCount} earlier tool ${noun} dropped to stay within the state budget)_`);
29982
+ lines.push(`- _(${evictedCount} earlier tool ${noun} dropped to stay within the state budget)_`);
29323
29983
  }
29324
- return lines2.join("\n");
29984
+ return lines.join("\n");
29325
29985
  }
29326
29986
  __name(renderToolResults, "renderToolResults");
29327
29987
  function renderPins(state) {
29328
29988
  const pins = state.pins ? [...state.pins.values()] : [];
29329
29989
  if (pins.length === 0)
29330
29990
  return null;
29331
- const lines2 = pins.map((p) => `- **${p.key}**: ${p.text} _(${p.source})_`);
29991
+ const lines = pins.map((p) => `- **${p.key}**: ${p.text} _(${p.source})_`);
29332
29992
  const dropped = state.evicted.pins ?? 0;
29333
29993
  if (dropped > 0) {
29334
- lines2.push(`- _(${dropped} older ${dropped === 1 ? "pin" : "pins"} dropped to stay within the pin budget)_`);
29994
+ lines.push(`- _(${dropped} older ${dropped === 1 ? "pin" : "pins"} dropped to stay within the pin budget)_`);
29335
29995
  }
29336
29996
  return `${SECTION_HEADERS.pins}
29337
29997
 
29338
- ${lines2.join("\n")}`;
29998
+ ${lines.join("\n")}`;
29339
29999
  }
29340
30000
  __name(renderPins, "renderPins");
29341
30001
  function serializeState(state) {
@@ -30687,24 +31347,23 @@ var TurnRecorder = class {
30687
31347
  const durable = next.filter((entry) => !entry.transient);
30688
31348
  const recordedOrder = new Map(this.#view.filter((entry) => entry.id).map((entry, index) => [entry.id, index]));
30689
31349
  const first = durable.findIndex((entry) => entry.id !== void 0);
30690
- let last = -1;
30691
- for (let i = durable.length - 1; i >= 0; i--) {
30692
- if (durable[i]?.id !== void 0) {
30693
- last = i;
30694
- break;
31350
+ let runEnd = first < 0 ? 0 : first + 1;
31351
+ if (first >= 0) {
31352
+ let prev = recordedOrder.get(durable[first]?.id) ?? -1;
31353
+ for (let i = first + 1; i < durable.length; i++) {
31354
+ const id3 = durable[i]?.id;
31355
+ if (id3 === void 0)
31356
+ break;
31357
+ const order = recordedOrder.get(id3) ?? -1;
31358
+ if (order <= prev)
31359
+ break;
31360
+ prev = order;
31361
+ runEnd = i + 1;
30695
31362
  }
30696
31363
  }
30697
- const middle = first < 0 ? [] : durable.slice(first, last + 1);
30698
- let ordered = middle.every((entry) => entry.id !== void 0);
30699
- for (let i = 1; ordered && i < middle.length; i++) {
30700
- const before = recordedOrder.get(middle[i - 1]?.id) ?? -1;
30701
- const after = recordedOrder.get(middle[i]?.id) ?? -1;
30702
- if (after <= before)
30703
- ordered = false;
30704
- }
30705
- const summaryEntries = !ordered ? durable : first < 0 ? durable : durable.slice(0, first);
30706
- const keptEntries = ordered ? middle : [];
30707
- const tailEntries = ordered && first >= 0 ? durable.slice(last + 1) : [];
31364
+ const summaryEntries = first < 0 ? [] : durable.slice(0, first);
31365
+ const keptEntries = first < 0 ? [] : durable.slice(first, runEnd);
31366
+ const tailEntries = durable.slice(first < 0 ? 0 : runEnd);
30708
31367
  for (const entry of summaryEntries) {
30709
31368
  entry.id = void 0;
30710
31369
  this.#ids.delete(entry.message);
@@ -30731,6 +31390,8 @@ var TurnRecorder = class {
30731
31390
  }).catch(() => void 0);
30732
31391
  for (const entry of tailEntries) {
30733
31392
  const message = entry.message;
31393
+ this.#ids.delete(message);
31394
+ this.#recorded.delete(message);
30734
31395
  const id3 = this.#idFor(message);
30735
31396
  entry.id = id3;
30736
31397
  void this.#enqueue(() => this.#append({
@@ -31180,7 +31841,7 @@ function buildAdvisoryTools(opts) {
31180
31841
  async execute() {
31181
31842
  const advisors = advisoryCtx.registry.listAll();
31182
31843
  const budget = advisoryCtx.getBudgetStatus();
31183
- const lines2 = advisors.map((a) => {
31844
+ const lines = advisors.map((a) => {
31184
31845
  const domains = a.domains && a.domains.length > 0 ? a.domains.join(", ") : "general";
31185
31846
  return `- ${a.id}: ${a.name} [domains: ${domains}]`;
31186
31847
  });
@@ -31188,7 +31849,7 @@ function buildAdvisoryTools(opts) {
31188
31849
  return {
31189
31850
  success: true,
31190
31851
  output: advisors.length === 0 ? "No advisors configured." : `${advisors.length} advisor(s) available:
31191
- ${lines2.join("\n")}
31852
+ ${lines.join("\n")}
31192
31853
 
31193
31854
  ${budgetLine}`,
31194
31855
  data: {
@@ -33774,7 +34435,7 @@ ${partial.content}`;
33774
34435
  attributes: { agent: handle.agentId, task: handle.taskId },
33775
34436
  provenance: `This is the output of the delegated agent "${handle.agentId}", not this agent's own work.`
33776
34437
  }, neutralizeNotificationDelimiter(shown)) : "(the task produced no output)";
33777
- const lines2 = [
34438
+ const lines = [
33778
34439
  `task_id: ${handle.taskId}`,
33779
34440
  `agent: ${handle.agentId}`,
33780
34441
  `state: ${handle.state}`,
@@ -33795,7 +34456,7 @@ ${partial.content}`;
33795
34456
  ...overLimit ? [`\u2026 truncated. Call wait_for_task with task_id "${handle.taskId}" for the full output.`] : []
33796
34457
  ];
33797
34458
  return `<task-notification>
33798
- ${lines2.join("\n")}
34459
+ ${lines.join("\n")}
33799
34460
  </task-notification>`;
33800
34461
  });
33801
34462
  const preamble = handles.length === 1 ? "A task you launched has finished. This is its result \u2014 you were not waiting on it, so it arrives here rather than as a tool result." : `${handles.length} tasks you launched have finished. These are their results \u2014 you were not waiting on them, so they arrive here rather than as tool results.`;
@@ -34685,7 +35346,7 @@ function splitIdentifier(raw) {
34685
35346
  return parts.length > 1 ? parts : [];
34686
35347
  }
34687
35348
  __name(splitIdentifier, "splitIdentifier");
34688
- function tokenize(text9) {
35349
+ function tokenize2(text9) {
34689
35350
  const out = [];
34690
35351
  for (const match2 of text9.matchAll(WORD)) {
34691
35352
  const raw = match2[0].replace(/^[.\-/\\:]+|[.\-/\\:]+$/g, "");
@@ -34713,7 +35374,7 @@ function tokenize(text9) {
34713
35374
  }
34714
35375
  return out;
34715
35376
  }
34716
- __name(tokenize, "tokenize");
35377
+ __name(tokenize2, "tokenize");
34717
35378
  function termFrequencies(tokens) {
34718
35379
  const tf = /* @__PURE__ */ new Map();
34719
35380
  for (const token of tokens)
@@ -34726,7 +35387,7 @@ __name(termFrequencies, "termFrequencies");
34726
35387
  var K1 = 1.2;
34727
35388
  var B = 0.75;
34728
35389
  function indexDocument(text9) {
34729
- const tokens = tokenize(text9);
35390
+ const tokens = tokenize2(text9);
34730
35391
  return { tf: termFrequencies(tokens), length: tokens.length };
34731
35392
  }
34732
35393
  __name(indexDocument, "indexDocument");
@@ -34864,10 +35525,10 @@ function scoreMessages(messages, options) {
34864
35525
  const n = messages.length;
34865
35526
  const texts = messages.map(messageText);
34866
35527
  const richContent = messages.map(hasRichContent);
34867
- const tokenLists = texts.map(tokenize);
35528
+ const tokenLists = texts.map(tokenize2);
34868
35529
  const documents = texts.map(indexDocument);
34869
35530
  const index = buildIndex(documents);
34870
- const goalTokens = tokenize(options.goal);
35531
+ const goalTokens = tokenize2(options.goal);
34871
35532
  const rawRelevance = documents.map((doc) => bm25Score(index, doc, goalTokens));
34872
35533
  const maxRelevance = Math.max(0, ...rawRelevance.filter((_, i) => {
34873
35534
  const m = messages[i];
@@ -36228,6 +36889,14 @@ async function runCompactionCheckInner(ctx, pass, options) {
36228
36889
  });
36229
36890
  }
36230
36891
  }
36892
+ await ctx.emitEvent?.({
36893
+ type: "compaction_started",
36894
+ turnId: ctx.recorder.turnId,
36895
+ iteration: ctx.recorder.currentIteration,
36896
+ reason: pass.reason,
36897
+ tokensBefore: estimatedTokens,
36898
+ contextWindowTokens: budget
36899
+ });
36231
36900
  const reducer = ctx.contextReducer ?? (config.strategy === "sliding-window" ? createSlidingWindowReducer() : void 0);
36232
36901
  if (reducer) {
36233
36902
  if (!options?.force && await stopOnRefill(ctx))
@@ -45971,35 +46640,35 @@ __name(assertTurnMayStart, "assertTurnMayStart");
45971
46640
  // ../sdk/dist/runtime/query/prompt.js
45972
46641
  function buildEnvContext(workingDirectory, config) {
45973
46642
  const { runtimeContext, tools, allowedTools } = config;
45974
- const lines2 = [
46643
+ const lines = [
45975
46644
  `<env>
45976
46645
  Working directory: ${workingDirectory}
45977
46646
  ${config.sandboxed ? "Host platform" : "Platform"}: ${process.platform}`
45978
46647
  ];
45979
46648
  if (runtimeContext?.label) {
45980
- lines2.push(`Runtime: ${runtimeContext.label}`);
46649
+ lines.push(`Runtime: ${runtimeContext.label}`);
45981
46650
  }
45982
46651
  if (runtimeContext?.outputDirectory) {
45983
- lines2.push(`Output directory: ${runtimeContext.outputDirectory}`);
46652
+ lines.push(`Output directory: ${runtimeContext.outputDirectory}`);
45984
46653
  }
45985
46654
  if (runtimeContext?.outputFileMarker) {
45986
- lines2.push(`Output file marker: ${runtimeContext.outputFileMarker}`);
46655
+ lines.push(`Output file marker: ${runtimeContext.outputFileMarker}`);
45987
46656
  }
45988
46657
  if (runtimeContext?.notes?.length) {
45989
- lines2.push("Runtime notes:");
46658
+ lines.push("Runtime notes:");
45990
46659
  for (const note of runtimeContext.notes) {
45991
- lines2.push(`- ${note}`);
46660
+ lines.push(`- ${note}`);
45992
46661
  }
45993
46662
  }
45994
- lines2.push(`</env>
46663
+ lines.push(`</env>
45995
46664
 
45996
46665
  Resolve relative paths against the working directory above; use supplied absolute paths as given.`);
45997
46666
  if (hasFilesystemTools(tools, allowedTools)) {
45998
- lines2.push("When file contents are needed, read known file paths directly. Discover unknown paths with available filesystem tools using targeted directories and patterns.");
46667
+ lines.push("When file contents are needed, read known file paths directly. Discover unknown paths with available filesystem tools using targeted directories and patterns.");
45999
46668
  const canGlob = tools.has("glob") && (!allowedTools || allowedTools.includes("glob")) && tools.availability("glob") === "active";
46000
- lines2.push(canGlob ? "For an immediate directory overview, use glob with pattern '*' or an available directory listing tool. Use '**' only when recursive discovery is needed." : "For an immediate directory overview, use an available directory listing tool.", "Keep discovery within the task's scope; do not recursively inventory unrelated home directories or cache trees.");
46669
+ lines.push(canGlob ? "For an immediate directory overview, use glob with pattern '*' or an available directory listing tool. Use '**' only when recursive discovery is needed." : "For an immediate directory overview, use an available directory listing tool.", "Keep discovery within the task's scope; do not recursively inventory unrelated home directories or cache trees.");
46001
46670
  }
46002
- return lines2.join("\n");
46671
+ return lines.join("\n");
46003
46672
  }
46004
46673
  __name(buildEnvContext, "buildEnvContext");
46005
46674
  function hasFilesystemTools(tools, allowedTools) {
@@ -46017,18 +46686,18 @@ function hasFilesystemTools(tools, allowedTools) {
46017
46686
  }
46018
46687
  __name(hasFilesystemTools, "hasFilesystemTools");
46019
46688
  function buildShellContext(config) {
46020
- const lines2 = [];
46689
+ const lines = [];
46021
46690
  for (const name2 of config.allowedTools ?? config.tools.listNames()) {
46022
46691
  const tool = config.tools.get(name2);
46023
46692
  if (!tool?.commandArgument || !tool.commandDialect || config.tools.availability(name2) !== "active")
46024
46693
  continue;
46025
46694
  const dialect = tool.commandDialect({ sandboxed: config.sandboxed === true });
46026
46695
  const gitBash = !config.sandboxed && dialect === "bash" && isWindowsBash();
46027
- lines2.push(`Execution shell for ${name2}: ${dialect}${config.sandboxed ? " (sandbox guest)" : gitBash ? " (Git Bash on Windows, host)" : " (host)"}.`);
46696
+ lines.push(`Execution shell for ${name2}: ${dialect}${config.sandboxed ? " (sandbox guest)" : gitBash ? " (Git Bash on Windows, host)" : " (host)"}.`);
46028
46697
  if (dialect === "cmd")
46029
- lines2.push("Use native Windows CMD command syntax. Single quotes do not quote arguments; backslashes do not escape shell operators. PowerShell syntax requires explicitly invoking PowerShell. Command-specific automatic permission grants are unavailable; an exact-call review may be required.");
46698
+ lines.push("Use native Windows CMD command syntax. Single quotes do not quote arguments; backslashes do not escape shell operators. PowerShell syntax requires explicitly invoking PowerShell. Command-specific automatic permission grants are unavailable; an exact-call review may be required.");
46030
46699
  }
46031
- return lines2.length > 0 ? lines2.join("\n") : void 0;
46700
+ return lines.length > 0 ? lines.join("\n") : void 0;
46032
46701
  }
46033
46702
  __name(buildShellContext, "buildShellContext");
46034
46703
  var PromptBuilder = class {
@@ -46943,11 +47612,11 @@ function normalizeLine(line) {
46943
47612
  return line.replace(/^\s*\d+[\s:.|)]+/, "").replace(/\d+/g, "N");
46944
47613
  }
46945
47614
  __name(normalizeLine, "normalizeLine");
46946
- function collapseRepeated(lines2) {
47615
+ function collapseRepeated(lines) {
46947
47616
  const result = [];
46948
47617
  let prevNorm = "";
46949
47618
  let repeatCount = 0;
46950
- for (const line of lines2) {
47619
+ for (const line of lines) {
46951
47620
  const norm = normalizeLine(line);
46952
47621
  if (norm === prevNorm && norm.trim().length > 0) {
46953
47622
  repeatCount++;
@@ -46971,14 +47640,14 @@ function compressShellOutputFull(raw, options) {
46971
47640
  const minReduction = options?.minReductionPercent ?? DEFAULT_MIN_REDUCTION;
46972
47641
  const maxStackFrames = options?.maxStackFrames ?? DEFAULT_MAX_STACK_FRAMES;
46973
47642
  const maxPassLines = options?.maxPassLines ?? DEFAULT_MAX_PASS_LINES;
46974
- const lines2 = raw.split("\n");
46975
- if (lines2.length < minLines) {
47643
+ const lines = raw.split("\n");
47644
+ if (lines.length < minLines) {
46976
47645
  return { text: raw, original: null };
46977
47646
  }
46978
47647
  const pass1 = [];
46979
47648
  let stackCount = 0;
46980
47649
  let passCount = 0;
46981
- for (const line of lines2) {
47650
+ for (const line of lines) {
46982
47651
  if (NOISE_RE.test(line)) {
46983
47652
  continue;
46984
47653
  }
@@ -53433,7 +54102,7 @@ function createMemoryRecallStep(options) {
53433
54102
  const terms2 = [
53434
54103
  .../* @__PURE__ */ new Set([
53435
54104
  ...anchors,
53436
- ...tokenize(options.identifierGrounding === true ? query2.slice(-4e3).normalize("NFKC") : query2.slice(-4e3))
54105
+ ...tokenize2(options.identifierGrounding === true ? query2.slice(-4e3).normalize("NFKC") : query2.slice(-4e3))
53437
54106
  ])
53438
54107
  ].filter((term) => term.length > 1 && !GLUE.has(term)).slice(0, 32);
53439
54108
  if (terms2.length === 0 || charBudget <= HEADER.length)
@@ -55406,13 +56075,13 @@ function parseValue(raw, file, line) {
55406
56075
  __name(parseValue, "parseValue");
55407
56076
  function parseMemoryFile(raw, file) {
55408
56077
  const text9 = raw.startsWith("\uFEFF") ? raw.slice(1) : raw;
55409
- const lines2 = text9.split("\n");
55410
- if (!FENCE.test((lines2[0] ?? "").replace(/\r$/, ""))) {
56078
+ const lines = text9.split("\n");
56079
+ if (!FENCE.test((lines[0] ?? "").replace(/\r$/, ""))) {
55411
56080
  throw new MemoryFileFormatError(file, "a memory file must start with a --- frontmatter fence", 1);
55412
56081
  }
55413
56082
  let closing = -1;
55414
- for (let i = 1; i < lines2.length; i++) {
55415
- if (FENCE.test((lines2[i] ?? "").replace(/\r$/, ""))) {
56083
+ for (let i = 1; i < lines.length; i++) {
56084
+ if (FENCE.test((lines[i] ?? "").replace(/\r$/, ""))) {
55416
56085
  closing = i;
55417
56086
  break;
55418
56087
  }
@@ -55430,7 +56099,7 @@ function parseMemoryFile(raw, file) {
55430
56099
  }, "closeList");
55431
56100
  for (let i = 1; i < closing; i++) {
55432
56101
  const lineNumber = i + 1;
55433
- const line = (lines2[i] ?? "").replace(/\r$/, "");
56102
+ const line = (lines[i] ?? "").replace(/\r$/, "");
55434
56103
  if (!line.trim() || line.trimStart().startsWith("#"))
55435
56104
  continue;
55436
56105
  const item = ITEM_LINE.exec(line);
@@ -55464,7 +56133,7 @@ function parseMemoryFile(raw, file) {
55464
56133
  values.set(typedKey, parseValue(rawValue, file, lineNumber));
55465
56134
  }
55466
56135
  closeList();
55467
- let body = lines2.slice(closing + 1).join("\n");
56136
+ let body = lines.slice(closing + 1).join("\n");
55468
56137
  body = body.replace(/^\r?\n/, "").replace(/\r?\n$/, "");
55469
56138
  return { values, body };
55470
56139
  }
@@ -55482,9 +56151,9 @@ function formatValue(value) {
55482
56151
  }
55483
56152
  __name(formatValue, "formatValue");
55484
56153
  function formatMemoryFile(fields2, body) {
55485
- const lines2 = ["---"];
56154
+ const lines = ["---"];
55486
56155
  const put = /* @__PURE__ */ __name((key5, value) => {
55487
- lines2.push(`${key5}: ${formatValue(value)}`);
56156
+ lines.push(`${key5}: ${formatValue(value)}`);
55488
56157
  }, "put");
55489
56158
  put("name", fields2.name);
55490
56159
  put("description", fields2.description);
@@ -55493,7 +56162,7 @@ function formatMemoryFile(fields2, body) {
55493
56162
  put("createdAt", new Date(fields2.createdAt).toISOString());
55494
56163
  put("updatedAt", new Date(fields2.updatedAt).toISOString());
55495
56164
  if (fields2.tags.length > 0)
55496
- lines2.push(`tags: ${JSON.stringify(fields2.tags)}`);
56165
+ lines.push(`tags: ${JSON.stringify(fields2.tags)}`);
55497
56166
  put("id", fields2.id);
55498
56167
  if (fields2.title !== fields2.name)
55499
56168
  put("title", fields2.title);
@@ -55502,9 +56171,9 @@ function formatMemoryFile(fields2, body) {
55502
56171
  if (fields2.format !== "markdown")
55503
56172
  put("format", fields2.format);
55504
56173
  if (fields2.metadata !== void 0)
55505
- lines2.push(`metadata: ${JSON.stringify(fields2.metadata)}`);
55506
- lines2.push("---", "", body);
55507
- return `${lines2.join("\n")}${body.endsWith("\r") ? "\r\n" : "\n"}`;
56174
+ lines.push(`metadata: ${JSON.stringify(fields2.metadata)}`);
56175
+ lines.push("---", "", body);
56176
+ return `${lines.join("\n")}${body.endsWith("\r") ? "\r\n" : "\n"}`;
55508
56177
  }
55509
56178
  __name(formatMemoryFile, "formatMemoryFile");
55510
56179
 
@@ -59874,9 +60543,9 @@ var StdioTransport = class {
59874
60543
  return this.connected;
59875
60544
  }
59876
60545
  processBuffer() {
59877
- const lines2 = this.buffer.split("\n");
59878
- this.buffer = lines2.pop() ?? "";
59879
- for (const line of lines2) {
60546
+ const lines = this.buffer.split("\n");
60547
+ this.buffer = lines.pop() ?? "";
60548
+ for (const line of lines) {
59880
60549
  const trimmed = line.trim();
59881
60550
  if (!trimmed)
59882
60551
  continue;
@@ -60625,11 +61294,11 @@ function parseSseMessages(raw) {
60625
61294
  const messages = [];
60626
61295
  let lastEventId;
60627
61296
  for (const event of events) {
60628
- const lines2 = event.split("\n");
60629
- const idLines = lines2.filter((line) => line.startsWith("id:")).map((line) => line.slice("id:".length).trim());
61297
+ const lines = event.split("\n");
61298
+ const idLines = lines.filter((line) => line.startsWith("id:")).map((line) => line.slice("id:".length).trim());
60630
61299
  if (idLines.length > 0)
60631
61300
  lastEventId = idLines.at(-1);
60632
- const dataLines = lines2.filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trimStart());
61301
+ const dataLines = lines.filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trimStart());
60633
61302
  if (dataLines.length === 0)
60634
61303
  continue;
60635
61304
  const data = dataLines.join("\n").trim();
@@ -61072,7 +61741,7 @@ async function resolveMcpEra(input) {
61072
61741
  __name(resolveMcpEra, "resolveMcpEra");
61073
61742
 
61074
61743
  // ../sdk/dist/version.js
61075
- var VERSION2 = "52.5.0";
61744
+ var VERSION2 = "52.7.0";
61076
61745
 
61077
61746
  // ../sdk/dist/connector/mcp/client.js
61078
61747
  var MAX_LIST_PAGES = 100;
@@ -62662,18 +63331,18 @@ var MCPToolDiscovery = class {
62662
63331
 
62663
63332
  // ../sdk/dist/connector/mcp/prompt-adapter.js
62664
63333
  function renderPromptMessages(serverName, promptName, messages, description) {
62665
- const lines2 = [];
63334
+ const lines = [];
62666
63335
  if (description)
62667
- lines2.push(description, "");
63336
+ lines.push(description, "");
62668
63337
  for (const message of messages) {
62669
63338
  const body = message.content.type === "text" ? message.content.text : message.content.type === "resource" ? message.content.resource.text ?? `[resource ${message.content.resource.uri}]` : `[${message.content.type}]`;
62670
- lines2.push(`[${message.role}] ${body}`, "");
63339
+ lines.push(`[${message.role}] ${body}`, "");
62671
63340
  }
62672
63341
  return wrapUntrusted({
62673
63342
  kind: "mcp-prompt",
62674
63343
  attributes: { server: serverName, name: promptName },
62675
63344
  provenance: "This is content the named server composed, not this agent."
62676
- }, lines2.join("\n").trimEnd());
63345
+ }, lines.join("\n").trimEnd());
62677
63346
  }
62678
63347
  __name(renderPromptMessages, "renderPromptMessages");
62679
63348
  function argumentSchema(prompt) {
@@ -63957,7 +64626,7 @@ function derivedUncertainty(report) {
63957
64626
  }
63958
64627
  __name(derivedUncertainty, "derivedUncertainty");
63959
64628
  function formatReport(report) {
63960
- const lines2 = [
64629
+ const lines = [
63961
64630
  `${report.name}: ${report.passed}/${report.cases.length} passed (mean ${report.mean.toFixed(2)}) in ${report.durationMs}ms`,
63962
64631
  // On its own line and always printed, including when the interval is
63963
64632
  // undefined. A mean printed alone is the thing that has been
@@ -63969,41 +64638,41 @@ function formatReport(report) {
63969
64638
  ""
63970
64639
  ];
63971
64640
  if (report.inconclusive > 0) {
63972
- lines2.push(` ${report.inconclusive} case${report.inconclusive === 1 ? "" : "s"} could not be judged \u2014 the numbers below cover the rest`, "");
64641
+ lines.push(` ${report.inconclusive} case${report.inconclusive === 1 ? "" : "s"} could not be judged \u2014 the numbers below cover the rest`, "");
63973
64642
  }
63974
64643
  for (const [name2, mean] of Object.entries(report.byScorer)) {
63975
- lines2.push(` ${name2}: ${mean.toFixed(2)}`);
64644
+ lines.push(` ${name2}: ${mean.toFixed(2)}`);
63976
64645
  }
63977
64646
  const failures = report.cases.filter((c) => c.status === "failed");
63978
64647
  if (failures.length > 0) {
63979
- lines2.push("", "Failures:");
64648
+ lines.push("", "Failures:");
63980
64649
  for (const failure2 of failures) {
63981
- lines2.push(` \u2717 ${failure2.case} (${failure2.mean.toFixed(2)})`);
64650
+ lines.push(` \u2717 ${failure2.case} (${failure2.mean.toFixed(2)})`);
63982
64651
  if (failure2.failedGates && failure2.failedGates.length > 0) {
63983
- lines2.push(` gate missed: ${failure2.failedGates.join(", ")}`);
64652
+ lines.push(` gate missed: ${failure2.failedGates.join(", ")}`);
63984
64653
  }
63985
64654
  for (const [name2, score] of Object.entries(failure2.scores)) {
63986
64655
  if (score.unavailable === true) {
63987
- lines2.push(` ${name2}: not judged \u2014 ${score.reason}`);
64656
+ lines.push(` ${name2}: not judged \u2014 ${score.reason}`);
63988
64657
  } else if (score.score < 1) {
63989
- lines2.push(` ${name2}: ${score.reason}`);
64658
+ lines.push(` ${name2}: ${score.reason}`);
63990
64659
  }
63991
64660
  }
63992
64661
  if (failure2.turn.error)
63993
- lines2.push(` error: ${failure2.turn.error}`);
64662
+ lines.push(` error: ${failure2.turn.error}`);
63994
64663
  }
63995
64664
  }
63996
64665
  const unjudged = report.cases.filter((c) => c.status === "inconclusive");
63997
64666
  if (unjudged.length > 0) {
63998
- lines2.push("", "Not judged:");
64667
+ lines.push("", "Not judged:");
63999
64668
  for (const item of unjudged) {
64000
- lines2.push(` ? ${item.case}`);
64669
+ lines.push(` ? ${item.case}`);
64001
64670
  for (const [name2, score] of Object.entries(item.scores)) {
64002
- lines2.push(` ${name2}: ${score.reason}`);
64671
+ lines.push(` ${name2}: ${score.reason}`);
64003
64672
  }
64004
64673
  }
64005
64674
  }
64006
- return lines2.join("\n");
64675
+ return lines.join("\n");
64007
64676
  }
64008
64677
  __name(formatReport, "formatReport");
64009
64678
 
@@ -68798,8 +69467,8 @@ var WorkerCodeRuntime = class {
68798
69467
  calls
68799
69468
  };
68800
69469
  }
68801
- const appendOutput = /* @__PURE__ */ __name((lines2) => {
68802
- for (const line of lines2) {
69470
+ const appendOutput = /* @__PURE__ */ __name((lines) => {
69471
+ for (const line of lines) {
68803
69472
  if (truncated)
68804
69473
  return;
68805
69474
  const next = printCount === 0 ? line : `${output}
@@ -69507,7 +70176,12 @@ var PRELUDE_SOURCE = String.raw`(function (config) {
69507
70176
  throw new TypeError('parallel(thunks): item ' + (p + 1) + ' must be a function (wrap the work as () => agent(...)), got ' + kind(thunks[p]));
69508
70177
  }
69509
70178
  }
69510
- return Promise.all(thunks.map(function (t) { return t(); }));
70179
+ return Promise.all(thunks.map(function (t, n) {
70180
+ return Promise.resolve().then(t).catch(function (e) {
70181
+ log('parallel item ' + (n + 1) + ' failed: ' + clean(e && e.message ? e.message : e, 300));
70182
+ return null;
70183
+ });
70184
+ }));
69511
70185
  }
69512
70186
  async function pipeline(items) {
69513
70187
  if (!Array.isArray(items)) {
@@ -69522,7 +70196,12 @@ var PRELUDE_SOURCE = String.raw`(function (config) {
69522
70196
  return Promise.all(items.map(async function (item, index) {
69523
70197
  var value = item;
69524
70198
  for (var i = 0; i < stages.length; i++) {
69525
- value = await stages[i](value, index, item);
70199
+ try {
70200
+ value = await stages[i](value, index, item);
70201
+ } catch (e) {
70202
+ log('pipeline item ' + (index + 1) + ' stopped at stage ' + (i + 1) + ': ' + clean(e && e.message ? e.message : e, 300));
70203
+ return null;
70204
+ }
69526
70205
  if (value === null || value === undefined) return null;
69527
70206
  }
69528
70207
  return value;
@@ -77941,11 +78620,11 @@ __name(isStrictDescendant, "isStrictDescendant");
77941
78620
  function parseWorktreeList(stdout, worktreePath) {
77942
78621
  const blocks = stdout.split(/\n\n+/);
77943
78622
  for (const block of blocks) {
77944
- const lines2 = block.split("\n").filter((l) => l.length > 0);
78623
+ const lines = block.split("\n").filter((l) => l.length > 0);
77945
78624
  let path2;
77946
78625
  let head2;
77947
78626
  let branch;
77948
- for (const line of lines2) {
78627
+ for (const line of lines) {
77949
78628
  if (line.startsWith("worktree "))
77950
78629
  path2 = line.slice("worktree ".length);
77951
78630
  else if (line.startsWith("HEAD "))
@@ -86089,17 +86768,17 @@ var CodeAnalysisTool = defineTool({
86089
86768
  });
86090
86769
  return render3(result, (value) => {
86091
86770
  const f = value.files;
86092
- const lines2 = [
86771
+ const lines = [
86093
86772
  `Indexed ${value.root}: ${f.indexed} files (${f.parsed} parsed, ${f.unchanged} unchanged, ${f.removed} removed, ${f.skipped} skipped, ${f.withParseErrors} with parse errors) in ${value.durationMs} ms.`,
86094
86773
  `${value.functions} functions, ${value.strings} string literals, ${value.calls} calls. ${value.persisted ? "Cached on disk." : "Held in memory only; it is gone when this process exits."}`
86095
86774
  ];
86096
86775
  if (value.truncated)
86097
- lines2.push(value.truncated);
86776
+ lines.push(value.truncated);
86098
86777
  const reasons = Object.entries(value.skippedReasons);
86099
86778
  if (reasons.length > 0) {
86100
- lines2.push(`Skipped: ${reasons.map(([why, n]) => `${n} ${why}`).join(", ")}.`);
86779
+ lines.push(`Skipped: ${reasons.map(([why, n]) => `${n} ${why}`).join(", ")}.`);
86101
86780
  }
86102
- return lines2;
86781
+ return lines;
86103
86782
  });
86104
86783
  }
86105
86784
  case "find_literal": {
@@ -86134,13 +86813,13 @@ var CodeAnalysisTool = defineTool({
86134
86813
  value.inClass !== void 0 ? `${place} is in the body of class ${value.inClass}, outside every method; not inside any function.` : `${place} is not inside any function.`
86135
86814
  ];
86136
86815
  }
86137
- const lines2 = [describeFunction(value.function, root)];
86816
+ const lines = [describeFunction(value.function, root)];
86138
86817
  if (value.parents.length > 0) {
86139
- lines2.push(`parents: ${value.parents.map(shortFunction).join(" < ")}`);
86818
+ lines.push(`parents: ${value.parents.map(shortFunction).join(" < ")}`);
86140
86819
  }
86141
86820
  if (value.source)
86142
- lines2.push(...sourceLines(value.source));
86143
- return lines2;
86821
+ lines.push(...sourceLines(value.source));
86822
+ return lines;
86144
86823
  });
86145
86824
  }
86146
86825
  case "function_source": {
@@ -86264,8 +86943,8 @@ function relativeTo(root, path2) {
86264
86943
  }
86265
86944
  __name(relativeTo, "relativeTo");
86266
86945
  function shortFunction(fn) {
86267
- const lines2 = fn.endLine === fn.line ? `L${fn.line}` : `L${fn.line}-${fn.endLine}`;
86268
- return `${fn.qualifiedName ?? fn.name ?? "(anonymous)"}#${fn.id} ${lines2}`;
86946
+ const lines = fn.endLine === fn.line ? `L${fn.line}` : `L${fn.line}-${fn.endLine}`;
86947
+ return `${fn.qualifiedName ?? fn.name ?? "(anonymous)"}#${fn.id} ${lines}`;
86269
86948
  }
86270
86949
  __name(shortFunction, "shortFunction");
86271
86950
  function describeFunction(fn, root) {
@@ -86283,21 +86962,21 @@ function describeEdge(edge) {
86283
86962
  }
86284
86963
  __name(describeEdge, "describeEdge");
86285
86964
  function sourceLines(slice) {
86286
- const lines2 = ["--- source ---", slice.text];
86965
+ const lines = ["--- source ---", slice.text];
86287
86966
  if (slice.truncated) {
86288
- lines2.push(slice.window ? `--- cut: showing ${slice.text.length} of ${slice.chars} characters, the function's first ${slice.window.headerChars} and the part around the position; raise max_chars to see more ---` : `--- cut: showing ${slice.text.length} of ${slice.chars} characters; raise max_chars to see more ---`);
86967
+ lines.push(slice.window ? `--- cut: showing ${slice.text.length} of ${slice.chars} characters, the function's first ${slice.window.headerChars} and the part around the position; raise max_chars to see more ---` : `--- cut: showing ${slice.text.length} of ${slice.chars} characters; raise max_chars to see more ---`);
86289
86968
  }
86290
- return lines2;
86969
+ return lines;
86291
86970
  }
86292
86971
  __name(sourceLines, "sourceLines");
86293
86972
  function evidenceLines(evidence) {
86294
- const lines2 = [];
86973
+ const lines = [];
86295
86974
  if (evidence.observed.length > 0)
86296
- lines2.push(`observed: ${evidence.observed.join("; ")}`);
86975
+ lines.push(`observed: ${evidence.observed.join("; ")}`);
86297
86976
  if (evidence.inferred.length > 0)
86298
- lines2.push(`inferred: ${evidence.inferred.join("; ")}`);
86299
- lines2.push(evidence.coverage.status === "complete" ? "coverage: complete" : `coverage: partial - ${evidence.coverage.reasons.join("; ")}`);
86300
- return lines2;
86977
+ lines.push(`inferred: ${evidence.inferred.join("; ")}`);
86978
+ lines.push(evidence.coverage.status === "complete" ? "coverage: complete" : `coverage: partial - ${evidence.coverage.reasons.join("; ")}`);
86979
+ return lines;
86301
86980
  }
86302
86981
  __name(evidenceLines, "evidenceLines");
86303
86982
  function render3(result, body, data) {
@@ -86323,18 +87002,18 @@ function renderPage(result, line, fileOf) {
86323
87002
  if (page.items.length === 0) {
86324
87003
  return [page.total === 0 ? "No results." : "No results on this page."];
86325
87004
  }
86326
- const lines2 = [];
87005
+ const lines = [];
86327
87006
  let current;
86328
87007
  for (const item of page.items) {
86329
87008
  const file = fileOf?.(item);
86330
87009
  if (file !== void 0 && file !== current) {
86331
- lines2.push(file);
87010
+ lines.push(file);
86332
87011
  current = file;
86333
87012
  }
86334
- lines2.push(file === void 0 ? line(item) : ` ${line(item)}`);
87013
+ lines.push(file === void 0 ? line(item) : ` ${line(item)}`);
86335
87014
  }
86336
- lines2.push(page.nextCursor !== void 0 ? `-- ${page.items.length} of ${page.total} shown. next cursor: ${page.nextCursor}` : `-- ${page.items.length} of ${page.total} shown. last page.`);
86337
- return lines2;
87015
+ lines.push(page.nextCursor !== void 0 ? `-- ${page.items.length} of ${page.total} shown. next cursor: ${page.nextCursor}` : `-- ${page.items.length} of ${page.total} shown. last page.`);
87016
+ return lines;
86338
87017
  }, (page) => ({
86339
87018
  total: page.total,
86340
87019
  count: page.items.length,
@@ -86901,15 +87580,15 @@ function grantNotice(allowed, grant, canGrant) {
86901
87580
 
86902
87581
  [This skill lists allowed-tools (${allowed.join(", ")}), but this host applies no pre-approval, so those calls are reviewed as usual. ${unchanged}]`;
86903
87582
  }
86904
- const lines2 = [];
86905
- lines2.push(grant.granted.length > 0 ? `Pre-approved for the rest of this turn: ${grant.granted.join(", ")}. Deny and ask rules, plan and strict mode, and review of destructive calls still apply.` : "Nothing in allowed-tools could be pre-approved.");
87583
+ const lines = [];
87584
+ lines.push(grant.granted.length > 0 ? `Pre-approved for the rest of this turn: ${grant.granted.join(", ")}. Deny and ask rules, plan and strict mode, and review of destructive calls still apply.` : "Nothing in allowed-tools could be pre-approved.");
86906
87585
  for (const { entry, reason: reason2 } of grant.ignored) {
86907
- lines2.push(`Ignored allowed-tools entry "${entry}": ${reason2}.`);
87586
+ lines.push(`Ignored allowed-tools entry "${entry}": ${reason2}.`);
86908
87587
  }
86909
- lines2.push(unchanged);
87588
+ lines.push(unchanged);
86910
87589
  return `
86911
87590
 
86912
- [${lines2.join(" ")}]`;
87591
+ [${lines.join(" ")}]`;
86913
87592
  }
86914
87593
  __name(grantNotice, "grantNotice");
86915
87594
 
@@ -88199,38 +88878,38 @@ function buildDescription(host, caps, settings) {
88199
88878
  const available = availableActions(host, caps);
88200
88879
  const unavailable3 = unavailableHostActions(host, caps);
88201
88880
  const intro = hostActionAvailable(caps, "screenshot") ? `Controls the user's desktop on a ${caps.displayServer} host: screenshots, mouse and keyboard, for GUI tasks.` : windowCaptureAvailable(host, caps) ? `Controls named windows on a ${caps.displayServer} host: window screenshots, mouse and keyboard, for GUI tasks.` : available.length > 0 ? `Offers the available computer controls on a ${caps.displayServer} host.` : `Computer control is unavailable on this ${caps.displayServer} host; this tool reports the limitation.`;
88202
- const lines2 = [intro, `Available actions: ${available.join("; ") || "none"}.`];
88881
+ const lines = [intro, `Available actions: ${available.join("; ") || "none"}.`];
88203
88882
  if (unavailable3.length > 0) {
88204
- lines2.push(caps.unavailableReason ? `Unavailable on this host: ${unavailable3.join(", ")} \u2014 ${caps.unavailableReason} Do not retry; tell the user.` : `Unavailable on this host: ${unavailable3.join(", ")}.`);
88883
+ lines.push(caps.unavailableReason ? `Unavailable on this host: ${unavailable3.join(", ")} \u2014 ${caps.unavailableReason} Do not retry; tell the user.` : `Unavailable on this host: ${unavailable3.join(", ")}.`);
88205
88884
  }
88206
88885
  if (!available.includes("screenshot"))
88207
- return finish(lines2, caps, available);
88208
- lines2.push('Coordinates: every x/y you send is a pixel of the most recent screenshot this tool returned \u2014 origin at its top-left, x to the right, y down \u2014 never a screen pixel. Each screenshot states its id and size (for example "s3: 1456x819"); stay inside it. Display screenshots map onto the display. To aim at an earlier display screenshot, pass its id as screenshot_id.', "Take a screenshot before your first click.");
88886
+ return finish(lines, caps, available);
88887
+ lines.push('Coordinates: every x/y you send is a pixel of the most recent screenshot this tool returned \u2014 origin at its top-left, x to the right, y down \u2014 never a screen pixel. Each screenshot states its id and size (for example "s3: 1456x819"); stay inside it. Display screenshots map onto the display. To aim at an earlier display screenshot, pass its id as screenshot_id.', "Take a screenshot before your first click.");
88209
88888
  if (settings.screenshotAfterActions)
88210
- lines2.push(`After any action that changes something, the tool waits ${settings.settleMs} ms and returns a new screenshot \u2014 do not call screenshot again after acting.`);
88211
- lines2.push("zoom returns a closer, sharper view of region {x, y, width, height} of the screenshot; your coordinates still refer to the screenshot, not to the zoomed image.", `wait pauses for ms milliseconds (at most ${settings.maxWaitMs} per call, a batch's waits together) and then shows the screen.`);
88889
+ lines.push(`After any action that changes something, the tool waits ${settings.settleMs} ms and returns a new screenshot \u2014 do not call screenshot again after acting.`);
88890
+ lines.push("zoom returns a closer, sharper view of region {x, y, width, height} of the screenshot; your coordinates still refer to the screenshot, not to the zoomed image.", `wait pauses for ms milliseconds (at most ${settings.maxWaitMs} per call, a batch's waits together) and then shows the screen.`);
88212
88891
  if (available.includes("batch"))
88213
- lines2.push(`batch: {"type":"batch","actions":[...]} runs up to ${settings.maxBatchActions} actions in order, stops at the first one that fails, and returns one screenshot at the end. Every call costs a model round trip of several seconds, so put the steps you can already predict into one batch (click a field, type, press ENTER) rather than one call each \u2014 but end the batch at any step that should bring up a new window, and look before typing into it. A batch cannot contain screenshot${available.includes("ui_snapshot") ? ", zoom or ui_snapshot" : " or zoom"}.`);
88892
+ lines.push(`batch: {"type":"batch","actions":[...]} runs up to ${settings.maxBatchActions} actions in order, stops at the first one that fails, and returns one screenshot at the end. Every call costs a model round trip of several seconds, so put the steps you can already predict into one batch (click a field, type, press ENTER) rather than one call each \u2014 but end the batch at any step that should bring up a new window, and look before typing into it. A batch cannot contain screenshot${available.includes("ui_snapshot") ? ", zoom or ui_snapshot" : " or zoom"}.`);
88214
88893
  if (caps.displayServer === "win32" && available.includes("key") && available.includes("type_text"))
88215
- lines2.push("To start a Windows program, a shell command (Start-Process notepad, or cmd.exe /c start calc) is surest when you have a shell tool. The Start menu searches by display names in the system language, and ENTER on a name it does not find opens a web search in the browser.");
88894
+ lines.push("To start a Windows program, a shell command (Start-Process notepad, or cmd.exe /c start calc) is surest when you have a shell tool. The Start menu searches by display names in the system language, and ENTER on a name it does not find opens a web search in the browser.");
88216
88895
  if (available.includes("list_windows"))
88217
- lines2.push("list_windows names the open windows with their ids; focus_window brings one to the front.");
88896
+ lines.push("list_windows names the open windows with their ids; focus_window brings one to the front.");
88218
88897
  if (windowCaptureAvailable(host, caps))
88219
- lines2.push(`When the user names an application or window, ${available.includes("list_windows") ? "use list_windows then screenshot {window_id}" : "use screenshot {window_id} with a host-provided window id"} to capture pixels for that window. Its x/y are pixels of that window image; clicks, drags, typing and keys target that window. Window pointer input uses background delivery only; if a click or drag is refused, inspect a fresh image before any other action. ${caps.windowScroll === false ? `Window pixel scrolling is unavailable on this host; for a browser page use key PAGE_DOWN or ARROW_DOWN with delivery_mode:"foreground"${hostActionAvailable(caps, "screenshot") ? ", or deliberately take a display screenshot for display scrolling" : ""}. ` : ""}To type into a browser field, first mouse_click its point in the window image, then type_text with delivery_mode:"foreground" if background text is unavailable. This may briefly bring the verified window to the front. For browser shortcuts such as CTRL+L, use key with delivery_mode:"foreground". A stale or moved window is refused; take a fresh window screenshot. ${hostActionAvailable(caps, "screenshot") ? "Plain screenshot still shows the display. " : "screenshot requires window_id on this host. "}Browser permission bubbles outside the window may be absent. If the window image is blank or shows another window, do not click it; focus the target and capture it again.`);
88898
+ lines.push(`When the user names an application or window, ${available.includes("list_windows") ? "use list_windows then screenshot {window_id}" : "use screenshot {window_id} with a host-provided window id"} to capture pixels for that window. Its x/y are pixels of that window image; clicks, drags, typing and keys target that window. Window pointer input uses background delivery only; if a click or drag is refused, inspect a fresh image before any other action. ${caps.windowScroll === false ? `Window pixel scrolling is unavailable on this host; for a browser page use key PAGE_DOWN or ARROW_DOWN with delivery_mode:"foreground"${hostActionAvailable(caps, "screenshot") ? ", or deliberately take a display screenshot for display scrolling" : ""}. ` : ""}To type into a browser field, first mouse_click its point in the window image, then type_text with delivery_mode:"foreground" if background text is unavailable. This may briefly bring the verified window to the front. For browser shortcuts such as CTRL+L, use key with delivery_mode:"foreground". A stale or moved window is refused; take a fresh window screenshot. ${hostActionAvailable(caps, "screenshot") ? "Plain screenshot still shows the display. " : "screenshot requires window_id on this host. "}Browser permission bubbles outside the window may be absent. If the window image is blank or shows another window, do not click it; focus the target and capture it again.`);
88220
88899
  if (available.includes("ui_snapshot"))
88221
- lines2.push(`ui_snapshot {window_id} reads a window's controls (its accessibility tree) as text, each control you can act on with a ref such as e12; without window_id it reads the window in front. ui_act {ref, action, value} acts on one control: invoke (press a button, open a menu item), set_value (replace a field's text with value), toggle, select, expand, collapse. Prefer ui_act to clicking pixels when the control is in the tree: it does not depend on coordinates or on which window is in front, and a batch of ui_act steps (for example pressing several buttons) runs in one call. Refs are valid only until the next ui_snapshot; take a new one after the window changes.`);
88222
- lines2.push(windowCaptureAvailable(host, caps) ? "After a display screenshot, typing and keys go to whichever window has focus: confirm on that screenshot that the right window is in front before type_text or key. After a named-window screenshot, input targets the captured window." : "Typing and keys go to whichever window has focus: confirm on a screenshot that the right window is in front before type_text or key.");
88900
+ lines.push(`ui_snapshot {window_id} reads a window's controls (its accessibility tree) as text, each control you can act on with a ref such as e12; without window_id it reads the window in front. ui_act {ref, action, value} acts on one control: invoke (press a button, open a menu item), set_value (replace a field's text with value), toggle, select, expand, collapse. Prefer ui_act to clicking pixels when the control is in the tree: it does not depend on coordinates or on which window is in front, and a batch of ui_act steps (for example pressing several buttons) runs in one call. Refs are valid only until the next ui_snapshot; take a new one after the window changes.`);
88901
+ lines.push(windowCaptureAvailable(host, caps) ? "After a display screenshot, typing and keys go to whichever window has focus: confirm on that screenshot that the right window is in front before type_text or key. After a named-window screenshot, input targets the captured window." : "Typing and keys go to whichever window has focus: confirm on a screenshot that the right window is in front before type_text or key.");
88223
88902
  if (available.includes("list_windows"))
88224
- lines2.push("type_text and key are refused while a terminal window is in front \u2014 usually the one running this agent, or the user\u2019s own; bring the window you mean to the front first (focus_window, or click it).");
88225
- return finish(lines2, caps, available);
88903
+ lines.push("type_text and key are refused while a terminal window is in front \u2014 usually the one running this agent, or the user\u2019s own; bring the window you mean to the front first (focus_window, or click it).");
88904
+ return finish(lines, caps, available);
88226
88905
  }
88227
88906
  __name(buildDescription, "buildDescription");
88228
- function finish(lines2, caps, available) {
88907
+ function finish(lines, caps, available) {
88229
88908
  if (caps.mouseClickButtons && available.includes("mouse_click"))
88230
- lines2.push(`Click buttons: ${caps.mouseClickButtons.join(", ") || "none"}.`);
88909
+ lines.push(`Click buttons: ${caps.mouseClickButtons.join(", ") || "none"}.`);
88231
88910
  if (caps.mouseDragButtons && available.includes("mouse_drag"))
88232
- lines2.push(`Drag buttons: ${caps.mouseDragButtons.join(", ") || "none"}.`);
88233
- return lines2.join(" ");
88911
+ lines.push(`Drag buttons: ${caps.mouseDragButtons.join(", ") || "none"}.`);
88912
+ return lines.join(" ");
88234
88913
  }
88235
88914
  __name(finish, "finish");
88236
88915
  function pointModelSchema(description) {
@@ -88805,7 +89484,7 @@ function createComputerUseTool(host, options = {}) {
88805
89484
  const refs = /* @__PURE__ */ new Map();
88806
89485
  const latest = frames.latest();
88807
89486
  const frame = latest?.window ? void 0 : latest;
88808
- const lines2 = [];
89487
+ const lines = [];
88809
89488
  let chars = 0;
88810
89489
  let shown = 0;
88811
89490
  let total = 0;
@@ -88821,7 +89500,7 @@ function createComputerUseTool(host, options = {}) {
88821
89500
  if (chars + line.length + 1 > MAX_UI_SNAPSHOT_CHARS) {
88822
89501
  cut = true;
88823
89502
  } else {
88824
- lines2.push(line);
89503
+ lines.push(line);
88825
89504
  chars += line.length + 1;
88826
89505
  shown += 1;
88827
89506
  if (ref) {
@@ -88848,7 +89527,7 @@ function createComputerUseTool(host, options = {}) {
88848
89527
  ...snapshot.app !== void 0 ? [`Application ${quotedText(snapshot.app)}`] : [],
88849
89528
  ...snapshot.title !== void 0 && snapshot.title !== snapshot.root.name ? [`Window title ${quotedText(snapshot.title)}`] : []
88850
89529
  ];
88851
- const body = [...about, ...lines2].join("\n");
89530
+ const body = [...about, ...lines].join("\n");
88852
89531
  const footer = cut || snapshot.truncated ? [
88853
89532
  cut ? `The tree was cut at ${MAX_UI_SNAPSHOT_CHARS} characters after ${shown} of ${total} controls. Read a smaller window, or use a screenshot for the rest.` : "The host stopped reading the tree before it ended; controls further down are missing. Use a screenshot for the rest."
88854
89533
  ] : [];
@@ -88900,7 +89579,7 @@ function createComputerUseTool(host, options = {}) {
88900
89579
  return "no windows are open";
88901
89580
  const latest = frames.latest();
88902
89581
  const frame = latest?.window ? void 0 : latest;
88903
- const lines2 = windows.slice(0, MAX_LISTED_WINDOWS).map((window2) => {
89582
+ const lines = windows.slice(0, MAX_LISTED_WINDOWS).map((window2) => {
88904
89583
  const where = frame ? (() => {
88905
89584
  const rect = window2.minimized ? null : desktopRectOnImage(frame, window2.bounds);
88906
89585
  return rect ? `at ${pointLabel(rect)} ${rect.width}x${rect.height} in ${frame.id}` : window2.minimized ? "minimized" : `not on the display of ${frame.id}`;
@@ -88918,7 +89597,7 @@ function createComputerUseTool(host, options = {}) {
88918
89597
  ${wrapUntrusted({
88919
89598
  kind: "desktop-windows",
88920
89599
  provenance: "The open windows on the user's desktop, as the host listed them. Titles are whatever each application shows, which can include text anyone wrote."
88921
- }, [...lines2, ...more].join("\n"))}`;
89600
+ }, [...lines, ...more].join("\n"))}`;
88922
89601
  }, "listWindows");
88923
89602
  const describeFrame = /* @__PURE__ */ __name((frame) => {
88924
89603
  if (frame.window) {
@@ -89553,12 +90232,12 @@ var GrepTool = defineTool({
89553
90232
  unreadableFiles++;
89554
90233
  continue;
89555
90234
  }
89556
- const lines2 = content.split("\n");
90235
+ const lines = content.split("\n");
89557
90236
  let fileMatches = 0;
89558
90237
  const relPath = sandbox ? `./${relativePosix(sandbox.rootDir, filePath)}` : `./${relative9(context2.workingDirectory, join44(lexicalRoot, relative9(root, filePath))).split(sep13).join("/")}`;
89559
- for (let i = 0; i < lines2.length; i++) {
90238
+ for (let i = 0; i < lines.length; i++) {
89560
90239
  context2.abortSignal?.throwIfAborted();
89561
- const line = lines2[i] ?? "";
90240
+ const line = lines[i] ?? "";
89562
90241
  regex.lastIndex = 0;
89563
90242
  if (!regex.test(line))
89564
90243
  continue;
@@ -89572,13 +90251,13 @@ var GrepTool = defineTool({
89572
90251
  continue;
89573
90252
  if (input.context_lines > 0) {
89574
90253
  const start = Math.max(0, i - input.context_lines);
89575
- const end = Math.min(lines2.length - 1, i + input.context_lines);
90254
+ const end = Math.min(lines.length - 1, i + input.context_lines);
89576
90255
  if (results.length > 0) {
89577
90256
  results.push("--");
89578
90257
  }
89579
90258
  for (let j = start; j <= end; j++) {
89580
90259
  const prefix = j === i ? ":" : "-";
89581
- const text9 = lines2[j] ?? "";
90260
+ const text9 = lines[j] ?? "";
89582
90261
  results.push(`${relPath}${prefix}${j + 1}${prefix}${clipLine(text9, j === i ? "matching" : "context")}`);
89583
90262
  }
89584
90263
  } else {
@@ -90117,11 +90796,11 @@ var VerifyOutputsTool = defineTool({
90117
90796
  failed: failed.length,
90118
90797
  min_bytes: minBytes
90119
90798
  };
90120
- const lines2 = results.map((r) => r.ok ? `- OK ${r.path}${typeof r.size_bytes === "number" ? ` (${r.size_bytes}B)` : ""}` : `- FAIL ${r.path} \u2014 ${r.error ?? (r.exists ? `size ${r.size_bytes ?? 0}B < min ${minBytes}B` : "missing")}`);
90799
+ const lines = results.map((r) => r.ok ? `- OK ${r.path}${typeof r.size_bytes === "number" ? ` (${r.size_bytes}B)` : ""}` : `- FAIL ${r.path} \u2014 ${r.error ?? (r.exists ? `size ${r.size_bytes ?? 0}B < min ${minBytes}B` : "missing")}`);
90121
90800
  const header = `Verify outputs: ${passed}/${results.length} passed (min ${minBytes}B)`;
90122
90801
  return {
90123
90802
  success: failed.length === 0,
90124
- output: [header, "", ...lines2].join("\n"),
90803
+ output: [header, "", ...lines].join("\n"),
90125
90804
  error: failed.length > 0 ? `${failed.length} of ${results.length} expected outputs failed verification` : void 0,
90126
90805
  data: { results, summary: summary2 }
90127
90806
  };
@@ -90833,13 +91512,13 @@ function renderSnapshot(snapshot, maxChars2) {
90833
91512
  text9 = text9.slice(0, maxChars2);
90834
91513
  cut = true;
90835
91514
  }
90836
- const lines2 = [formatBrowserPageHeader(snapshot.page), wrapPageText(snapshot.page, text9)];
91515
+ const lines = [formatBrowserPageHeader(snapshot.page), wrapPageText(snapshot.page, text9)];
90837
91516
  if (snapshot.nextCursor !== void 0) {
90838
- lines2.push(`More of this page follows: call browser with action "snapshot" and cursor ${JSON.stringify(snapshot.nextCursor)}.`);
91517
+ lines.push(`More of this page follows: call browser with action "snapshot" and cursor ${JSON.stringify(snapshot.nextCursor)}.`);
90839
91518
  } else if (cut) {
90840
- lines2.push(`The snapshot was cut at ${maxChars2} characters. Take a snapshot of one region with ref to see the rest.`);
91519
+ lines.push(`The snapshot was cut at ${maxChars2} characters. Take a snapshot of one region with ref to see the rest.`);
90841
91520
  }
90842
- return lines2.join("\n");
91521
+ return lines.join("\n");
90843
91522
  }
90844
91523
  __name(renderSnapshot, "renderSnapshot");
90845
91524
  function hostMessage(message) {
@@ -91447,13 +92126,13 @@ function defineSearchMemoryTool(search) {
91447
92126
  };
91448
92127
  }
91449
92128
  const now = Date.now();
91450
- const lines2 = result.entries.map((e, i) => {
92129
+ const lines = result.entries.map((e, i) => {
91451
92130
  const kind = [e.name, e.type, describeMemoryAge(e.updatedAt, now)].filter(Boolean).join(", ");
91452
92131
  return `${i + 1}. [${e.id}] ${e.title} (${kind}) \u2014 ${e.description ?? e.summary}${e.tags.length > 0 ? ` [${e.tags.join(", ")}]` : ""}`;
91453
92132
  });
91454
92133
  const output = result.totalCount > result.entries.length ? `Found ${result.totalCount} memories${page} (showing ${result.entries.length}):
91455
- ${lines2.join("\n")}${continuation}` : `Found ${result.totalCount} memories${page}:
91456
- ${lines2.join("\n")}${continuation}`;
92134
+ ${lines.join("\n")}${continuation}` : `Found ${result.totalCount} memories${page}:
92135
+ ${lines.join("\n")}${continuation}`;
91457
92136
  return {
91458
92137
  success: true,
91459
92138
  output,
@@ -91877,8 +92556,8 @@ async function list(host, input) {
91877
92556
  }
91878
92557
  if (jobs.length === 0)
91879
92558
  return { success: true, output: "No scheduled jobs.", data: { jobs: [] } };
91880
- const lines2 = jobs.map((j) => `${j.name} \xB7 ${j.state} \xB7 ${j.schedule}${j.nextFireAt ? ` \xB7 next ${j.nextFireAt}` : ""}${j.lastStatus ? ` \xB7 last ${j.lastStatus}` : ""} \xB7 ${j.folder}${j.inSessionFolder ? " (this folder)" : ""}`);
91881
- return { success: true, output: lines2.join("\n"), data: { jobs } };
92559
+ const lines = jobs.map((j) => `${j.name} \xB7 ${j.state} \xB7 ${j.schedule}${j.nextFireAt ? ` \xB7 next ${j.nextFireAt}` : ""}${j.lastStatus ? ` \xB7 last ${j.lastStatus}` : ""} \xB7 ${j.folder}${j.inSessionFolder ? " (this folder)" : ""}`);
92560
+ return { success: true, output: lines.join("\n"), data: { jobs } };
91882
92561
  }
91883
92562
  __name(list, "list");
91884
92563
  var CHANGEABLE = [
@@ -92210,6 +92889,37 @@ function pick2(entries2) {
92210
92889
  return out;
92211
92890
  }
92212
92891
  __name(pick2, "pick");
92892
+ var MAX_HUNKS = 100;
92893
+ var MAX_HUNK_ROWS = 400;
92894
+ var MAX_ROW_CHARS = 600;
92895
+ function hunks(value) {
92896
+ if (!Array.isArray(value) || value.length > MAX_HUNKS)
92897
+ return void 0;
92898
+ const out = [];
92899
+ let rows = 0;
92900
+ for (const entry of value) {
92901
+ if (!isRecord4(entry) || !Array.isArray(entry.lines))
92902
+ return void 0;
92903
+ const oldStart = count6(entry.oldStart);
92904
+ const oldLines = count6(entry.oldLines);
92905
+ const newStart = count6(entry.newStart);
92906
+ const newLines = count6(entry.newLines);
92907
+ if (oldStart === void 0 || oldLines === void 0 || newStart === void 0 || newLines === void 0)
92908
+ return void 0;
92909
+ rows += entry.lines.length;
92910
+ if (rows > MAX_HUNK_ROWS)
92911
+ return void 0;
92912
+ const lines = [];
92913
+ for (const row of entry.lines) {
92914
+ if (typeof row !== "string" || row.length > MAX_ROW_CHARS || !(row.startsWith(" ") || row.startsWith("+") || row.startsWith("-")))
92915
+ return void 0;
92916
+ lines.push(row);
92917
+ }
92918
+ out.push({ oldStart, oldLines, newStart, newLines, lines });
92919
+ }
92920
+ return out.length > 0 ? out : void 0;
92921
+ }
92922
+ __name(hunks, "hunks");
92213
92923
  function admitToolFacts(value) {
92214
92924
  if (!isRecord4(value))
92215
92925
  return void 0;
@@ -92268,7 +92978,11 @@ function admitToolFacts(value) {
92268
92978
  return pick2({
92269
92979
  kind: "edit",
92270
92980
  path: text8(value.path),
92271
- replacements: count6(value.replacements)
92981
+ replacements: count6(value.replacements),
92982
+ added: count6(value.added),
92983
+ removed: count6(value.removed),
92984
+ hunks: hunks(value.hunks),
92985
+ hunksTruncated: flag(value.hunksTruncated)
92272
92986
  });
92273
92987
  case "write": {
92274
92988
  const path2 = text8(value.path);
@@ -92281,7 +92995,9 @@ function admitToolFacts(value) {
92281
92995
  operation,
92282
92996
  bytes: count6(value.bytes),
92283
92997
  added: count6(value.added),
92284
- removed: count6(value.removed)
92998
+ removed: count6(value.removed),
92999
+ hunks: hunks(value.hunks),
93000
+ hunksTruncated: flag(value.hunksTruncated)
92285
93001
  });
92286
93002
  }
92287
93003
  case "failure": {
@@ -92721,4 +93437,4 @@ export {
92721
93437
  buildResidentToolEvidenceTools,
92722
93438
  createPalMessagingTools
92723
93439
  };
92724
- //# sourceMappingURL=chunk-2UGC7RUB.js.map
93440
+ //# sourceMappingURL=chunk-A64X23MU.js.map