@namzu/cli 38.1.1 → 39.0.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 (454) hide show
  1. package/CHANGELOG.md +142 -50
  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-GBQKP3SQ.js → acp-NZITIX4C.js} +41 -38
  6. package/dist/chunks/acp-NZITIX4C.js.map +6 -0
  7. package/dist/chunks/{activity-command-6CVS5DZI.js → activity-command-NKOTZ5FK.js} +11 -11
  8. package/dist/chunks/{add-VVRTXHDQ.js → add-AONYUNXG.js} +18 -18
  9. package/dist/chunks/{agent-UZHYPLYW.js → agent-YPKFE66C.js} +32 -29
  10. package/dist/chunks/agent-session-HFOLAFFL.js +53 -0
  11. package/dist/chunks/{archive-YWLKZACK.js → archive-SUE5OUZZ.js} +9 -9
  12. package/dist/chunks/{bin-main-LVQFA6PZ.js → bin-main-55PUHGTA.js} +3 -3
  13. package/dist/chunks/{browser-HD24O6AL.js → browser-HYPSUDAZ.js} +6 -6
  14. package/dist/chunks/{chat-VOBGMUI3.js → chat-6OULID33.js} +14 -14
  15. package/dist/chunks/{chunk-7M3YW2NF.js → chunk-233DQVSC.js} +6 -6
  16. package/dist/chunks/{chunk-HAJ7UV4Y.js → chunk-263WNQB4.js} +9 -9
  17. package/dist/chunks/{chunk-W47OQU6P.js → chunk-2KKF45DQ.js} +2 -2
  18. package/dist/chunks/{chunk-UASN4SLO.js → chunk-2VMMTC2V.js} +2 -2
  19. package/dist/chunks/{chunk-IP36P4KT.js → chunk-2WQFRVVQ.js} +4 -4
  20. package/dist/chunks/{chunk-5BZSCNGR.js → chunk-3JB5NDB4.js} +62 -155
  21. package/dist/chunks/chunk-3JB5NDB4.js.map +6 -0
  22. package/dist/chunks/{chunk-MSNMI4KG.js → chunk-3OAGXDRM.js} +4 -4
  23. package/dist/chunks/{chunk-XBCEWEQN.js → chunk-47TGPZWD.js} +3 -3
  24. package/dist/chunks/{chunk-GIBXNY7Z.js → chunk-4K2NRXHJ.js} +2 -2
  25. package/dist/chunks/{chunk-42GHVPZE.js → chunk-5CGH647C.js} +5 -5
  26. package/dist/chunks/{chunk-7LMPS6TV.js → chunk-74U3P65Q.js} +12 -12
  27. package/dist/chunks/{chunk-XNOORMEP.js → chunk-7EASYULO.js} +8 -8
  28. package/dist/chunks/{chunk-MKPICNP7.js → chunk-7YXHOSHD.js} +3 -3
  29. package/dist/chunks/{chunk-US5ZFPAU.js → chunk-AXCOWIIH.js} +2 -7
  30. package/dist/chunks/{chunk-US5ZFPAU.js.map → chunk-AXCOWIIH.js.map} +1 -1
  31. package/dist/chunks/{chunk-AEB7KCO6.js → chunk-AZ3YHVFA.js} +2 -2
  32. package/dist/chunks/{chunk-YUX6OJOD.js → chunk-B2357ETN.js} +7 -7
  33. package/dist/chunks/{chunk-TCXFKEYW.js → chunk-B73OIFL6.js} +4 -4
  34. package/dist/chunks/{chunk-TCXFKEYW.js.map → chunk-B73OIFL6.js.map} +1 -1
  35. package/dist/chunks/{chunk-J7RNZR6A.js → chunk-BEFTUDYP.js} +7 -7
  36. package/dist/chunks/chunk-CDYUGK7F.js +70 -0
  37. package/dist/chunks/chunk-CDYUGK7F.js.map +6 -0
  38. package/dist/chunks/{chunk-NR6YON2Q.js → chunk-CL5TCY4F.js} +2 -2
  39. package/dist/chunks/{chunk-52E6DDZD.js → chunk-CUOWARJI.js} +2 -2
  40. package/dist/chunks/{chunk-FHDYGPGC.js → chunk-CZEU2JYJ.js} +3 -3
  41. package/dist/chunks/{chunk-FHDYGPGC.js.map → chunk-CZEU2JYJ.js.map} +1 -1
  42. package/dist/chunks/{chunk-FDAOPSRK.js → chunk-DFA5OB46.js} +4 -4
  43. package/dist/chunks/{chunk-JFZF3FQ2.js → chunk-E3HCZYGN.js} +3 -3
  44. package/dist/chunks/{chunk-BSBFGZLW.js → chunk-EA6SWPO4.js} +4 -4
  45. package/dist/chunks/{chunk-WWGLUAHZ.js → chunk-EUU4TDTH.js} +2 -2
  46. package/dist/chunks/{chunk-ZAUFSEHS.js → chunk-FBNKKDIY.js} +4 -4
  47. package/dist/chunks/{chunk-DTMONWML.js → chunk-FQZFVLJB.js} +4 -4
  48. package/dist/chunks/{chunk-OUTFB7EJ.js → chunk-GU5YARBU.js} +93 -7
  49. package/dist/chunks/chunk-GU5YARBU.js.map +6 -0
  50. package/dist/chunks/{chunk-MDEIMYQU.js → chunk-HI2KXIGA.js} +20 -83
  51. package/dist/chunks/chunk-HI2KXIGA.js.map +6 -0
  52. package/dist/chunks/{chunk-WTF2RVKD.js → chunk-HU35YAIZ.js} +2 -2
  53. package/dist/chunks/{chunk-AMT74CY7.js → chunk-HV77F4SF.js} +42 -60
  54. package/dist/chunks/chunk-HV77F4SF.js.map +6 -0
  55. package/dist/chunks/{chunk-2UBCLXGV.js → chunk-IAYIUJMI.js} +2 -2
  56. package/dist/chunks/{chunk-BGM3PULY.js → chunk-ID334ALD.js} +39 -31
  57. package/dist/chunks/{chunk-BGM3PULY.js.map → chunk-ID334ALD.js.map} +1 -1
  58. package/dist/chunks/{chunk-U3JIZFOS.js → chunk-IE5XIE4W.js} +2 -2
  59. package/dist/chunks/{chunk-SDABAQVK.js → chunk-II57E2QW.js} +4 -4
  60. package/dist/chunks/{chunk-CZVHXYGD.js → chunk-IYPP6HSK.js} +4 -32
  61. package/dist/chunks/chunk-IYPP6HSK.js.map +6 -0
  62. package/dist/chunks/{chunk-54BF5YUB.js → chunk-LFVQSMJG.js} +4 -4
  63. package/dist/chunks/chunk-M3TJHQF7.js +134 -0
  64. package/dist/chunks/chunk-M3TJHQF7.js.map +6 -0
  65. package/dist/chunks/{chunk-MW3PKVXY.js → chunk-MCNEFI5Q.js} +2 -2
  66. package/dist/chunks/{chunk-YA4IH46E.js → chunk-N3FI7O4U.js} +4 -4
  67. package/dist/chunks/{chunk-XXBN2OWW.js → chunk-N72DH6D5.js} +2 -2
  68. package/dist/chunks/{chunk-LWXTAX2V.js → chunk-NLKIBRXJ.js} +18 -8
  69. package/dist/chunks/chunk-NLKIBRXJ.js.map +6 -0
  70. package/dist/chunks/{chunk-TDDCRQZZ.js → chunk-OLOTFDTU.js} +2 -2
  71. package/dist/chunks/{chunk-WXMFE5SS.js → chunk-OXJEMOBQ.js} +1179 -302
  72. package/dist/chunks/chunk-OXJEMOBQ.js.map +6 -0
  73. package/dist/chunks/{chunk-G6QXPPH3.js → chunk-P2Y4LUPJ.js} +2 -2
  74. package/dist/chunks/{chunk-65Y4XRJ7.js → chunk-QNF6COCY.js} +3 -3
  75. package/dist/chunks/{chunk-Q3IWEW4F.js → chunk-QO5JUKFG.js} +25 -19
  76. package/dist/chunks/chunk-QO5JUKFG.js.map +6 -0
  77. package/dist/chunks/{chunk-GXE2VIGI.js → chunk-RB36O3CE.js} +2 -2
  78. package/dist/chunks/{chunk-XM3W7NMM.js → chunk-RQBT4RVE.js} +1206 -326
  79. package/dist/chunks/chunk-RQBT4RVE.js.map +6 -0
  80. package/dist/chunks/{chunk-ALNCCKDI.js → chunk-SBPCN24X.js} +2 -2
  81. package/dist/chunks/{chunk-XNY2DD22.js → chunk-SIK62TDI.js} +2 -2
  82. package/dist/chunks/{chunk-VXHYLNLR.js → chunk-T75ITEN6.js} +3 -3
  83. package/dist/chunks/{chunk-6GJXAHUO.js → chunk-TJTRVZFN.js} +2 -2
  84. package/dist/chunks/{chunk-42CAONYE.js → chunk-UBOPUGDN.js} +26 -11
  85. package/dist/chunks/chunk-UBOPUGDN.js.map +6 -0
  86. package/dist/chunks/{chunk-H3LH5GZ5.js → chunk-UIDLXA2K.js} +2 -2
  87. package/dist/chunks/{chunk-YBZMF6LC.js → chunk-UTMGJDC3.js} +2 -2
  88. package/dist/chunks/{chunk-YE2PFKVU.js → chunk-UUUNXKL3.js} +3 -3
  89. package/dist/chunks/{chunk-6ARSJBCV.js → chunk-UZCA37QE.js} +2 -2
  90. package/dist/chunks/{chunk-LQFMXCHI.js → chunk-W27ZDC4R.js} +4 -4
  91. package/dist/chunks/{chunk-P7OXZHTL.js → chunk-XEHLRJXR.js} +16 -13
  92. package/dist/chunks/{chunk-P7OXZHTL.js.map → chunk-XEHLRJXR.js.map} +1 -1
  93. package/dist/chunks/{chunk-5DJ5YIHY.js → chunk-XJ4IUCH6.js} +15 -15
  94. package/dist/chunks/{chunk-6N6HLU4F.js → chunk-YKEPC6NH.js} +3 -3
  95. package/dist/chunks/{chunk-HQ37JKI2.js → chunk-Z7XA4Y43.js} +3 -3
  96. package/dist/chunks/{cli-runtime-53GYDVBD.js → cli-runtime-G3FHYTCI.js} +20 -14
  97. package/dist/chunks/cli-runtime-G3FHYTCI.js.map +6 -0
  98. package/dist/chunks/{commands-X2P7B7M6.js → commands-TIRZH2TK.js} +5 -5
  99. package/dist/chunks/{crash-report-YKKJEHWY.js → crash-report-E4J7KQ32.js} +7 -7
  100. package/dist/chunks/{dist-E24W5SI7.js → dist-2IUQEIEI.js} +2 -2
  101. package/dist/chunks/{dist-TTCX7GFK.js → dist-2U6NNEPY.js} +3 -3
  102. package/dist/chunks/{dist-ADL22Y3L.js → dist-56CMMYUT.js} +48 -5
  103. package/dist/chunks/dist-56CMMYUT.js.map +6 -0
  104. package/dist/chunks/{dist-KP5U4QDN.js → dist-CVDGKJEI.js} +2 -2
  105. package/dist/chunks/{dist-TYCOBKDT.js → dist-MKQZKCB4.js} +2 -2
  106. package/dist/chunks/{dist-EO3WQFRN.js → dist-QCKKBLDW.js} +2 -2
  107. package/dist/chunks/{dist-6ABVUWX5.js → dist-QHKTYYMX.js} +2 -2
  108. package/dist/chunks/{dist-5KZ4SS57.js → dist-YX7Q3EJR.js} +3 -3
  109. package/dist/chunks/{doctor-QTMSOOEO.js → doctor-ASXICRC5.js} +10 -10
  110. package/dist/chunks/{drain-FWONJITS.js → drain-CGS3KBU3.js} +10 -10
  111. package/dist/chunks/{eval-GQTJX6WI.js → eval-XWC3UCFI.js} +2 -2
  112. package/dist/chunks/{exec-A5BM63JW.js → exec-FOUQBA6I.js} +43 -30
  113. package/dist/chunks/exec-FOUQBA6I.js.map +6 -0
  114. package/dist/chunks/{home-QAEAKEUG.js → home-76YLI2M6.js} +3 -3
  115. package/dist/chunks/{host-queries-NY6FDVNU.js → host-queries-ODUQHYBN.js} +14 -14
  116. package/dist/chunks/{lifecycle-EJQ57UR7.js → lifecycle-JN43XQSS.js} +26 -26
  117. package/dist/chunks/{list-P5KDSX7R.js → list-TC7TYJDR.js} +12 -12
  118. package/dist/chunks/{login-PQAWB3YL.js → login-CTC6CAM4.js} +10 -10
  119. package/dist/chunks/{logs-PYWTK275.js → logs-2NGJFIQI.js} +4 -4
  120. package/dist/chunks/{mcp-QJRY437O.js → mcp-BPH7KWZ6.js} +19 -19
  121. package/dist/chunks/{message-command-RGUNGNNC.js → message-command-A4XU7QQQ.js} +36 -35
  122. package/dist/chunks/message-command-A4XU7QQQ.js.map +6 -0
  123. package/dist/chunks/{operator-tools-UH4SJXQJ.js → operator-tools-6RYAHVSL.js} +12 -12
  124. package/dist/chunks/{output-schema-BN6UL2BB.js → output-schema-GSWZHKSI.js} +3 -3
  125. package/dist/chunks/{pal-NAJGPRTW.js → pal-4QXXG42H.js} +13 -13
  126. package/dist/chunks/{providers-VTT4SK6S.js → providers-6PIIF3WR.js} +8 -8
  127. package/dist/chunks/{resident-AQYBL2GF.js → resident-UP7W6MV6.js} +21 -21
  128. package/dist/chunks/resume-GJHTPMJS.js +22 -0
  129. package/dist/chunks/{resume-command-AOT7YZT5.js → resume-command-2RFT7AGW.js} +4 -4
  130. package/dist/chunks/{schedule-WYFFJI6G.js → schedule-FZISVF6A.js} +8 -8
  131. package/dist/chunks/{service-HAMHYSEA.js → service-4WADXOUI.js} +25 -25
  132. package/dist/chunks/session-step-FX6B4TSE.js +29 -0
  133. package/dist/chunks/{skills-5TJTJEDG.js → skills-BJQGVQ23.js} +8 -8
  134. package/dist/chunks/{state-ABEFSCFQ.js → state-2KKVQPZ2.js} +2 -2
  135. package/dist/chunks/{store-BL5L6BOI.js → store-LO4SSRYI.js} +9 -9
  136. package/dist/chunks/{store-UKFFPFLI.js → store-TKJKR5NM.js} +6 -6
  137. package/dist/chunks/{store-WBED64YS.js → store-YFTJ24WU.js} +4 -4
  138. package/dist/chunks/{tui-EWFJ5CEO.js → tui-HA3JIVON.js} +4258 -2163
  139. package/dist/chunks/tui-HA3JIVON.js.map +6 -0
  140. package/dist/chunks/{upgrade-2HP3BTOT.js → upgrade-3QLPPCII.js} +4 -3
  141. package/dist/chunks/upgrade-3QLPPCII.js.map +6 -0
  142. package/dist/chunks/{worktree-PNFBTACG.js → worktree-3HYAYSGW.js} +11 -11
  143. package/dist/cli.d.ts.map +1 -1
  144. package/dist/commands/acp.d.ts.map +1 -1
  145. package/dist/commands/desktop-model-catalogue.d.ts +1 -1
  146. package/dist/commands/exec-json.d.ts.map +1 -1
  147. package/dist/commands/exec.d.ts.map +1 -1
  148. package/dist/commands/resume.d.ts +1 -1
  149. package/dist/config/composer-triggers.d.ts +1 -1
  150. package/dist/config/composer-triggers.d.ts.map +1 -1
  151. package/dist/config/load.d.ts +1 -2
  152. package/dist/config/load.d.ts.map +1 -1
  153. package/dist/config/schema.d.ts +22 -5
  154. package/dist/config/schema.d.ts.map +1 -1
  155. package/dist/context/doctrine.d.ts +4 -4
  156. package/dist/context/doctrine.d.ts.map +1 -1
  157. package/dist/index.js +15 -15
  158. package/dist/integrations/harness/codex-protocol.d.ts +1 -1
  159. package/dist/integrations/harness/codex-protocol.d.ts.map +1 -1
  160. package/dist/integrations/mcp/tool-search.d.ts +3 -4
  161. package/dist/integrations/mcp/tool-search.d.ts.map +1 -1
  162. package/dist/integrations/notifications/approval.d.ts +36 -0
  163. package/dist/integrations/notifications/approval.d.ts.map +1 -0
  164. package/dist/integrations/notifications/idle.d.ts +2 -2
  165. package/dist/integrations/notifications/idle.d.ts.map +1 -1
  166. package/dist/integrations/providers/identity.d.ts +1 -1
  167. package/dist/integrations/resident/runner-worker.js +20 -20
  168. package/dist/integrations/sessions/journal-trail.d.ts +6 -0
  169. package/dist/integrations/sessions/journal-trail.d.ts.map +1 -0
  170. package/dist/integrations/sessions/store.d.ts.map +1 -1
  171. package/dist/integrations/subagents/activity.d.ts +4 -0
  172. package/dist/integrations/subagents/activity.d.ts.map +1 -1
  173. package/dist/integrations/subagents/label-ledger.d.ts +2 -3
  174. package/dist/integrations/subagents/label-ledger.d.ts.map +1 -1
  175. package/dist/integrations/subagents/runtime.d.ts +40 -4
  176. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  177. package/dist/integrations/subagents/workflow-assignment.d.ts +13 -0
  178. package/dist/integrations/subagents/workflow-assignment.d.ts.map +1 -0
  179. package/dist/integrations/trust/folder-grants.d.ts +20 -0
  180. package/dist/integrations/trust/folder-grants.d.ts.map +1 -0
  181. package/dist/integrations/workflows/doctrine.d.ts +4 -3
  182. package/dist/integrations/workflows/doctrine.d.ts.map +1 -1
  183. package/dist/integrations/workflows/host.d.ts +12 -0
  184. package/dist/integrations/workflows/host.d.ts.map +1 -1
  185. package/dist/integrations/workflows/notice.d.ts.map +1 -1
  186. package/dist/integrations/workflows/offering.d.ts +9 -19
  187. package/dist/integrations/workflows/offering.d.ts.map +1 -1
  188. package/dist/integrations/workflows/size.d.ts +51 -0
  189. package/dist/integrations/workflows/size.d.ts.map +1 -0
  190. package/dist/permissions/consent-prompt.d.ts.map +1 -1
  191. package/dist/permissions/live-mode.d.ts +1 -2
  192. package/dist/permissions/live-mode.d.ts.map +1 -1
  193. package/dist/permissions/local-settings.d.ts +4 -4
  194. package/dist/permissions/mode.d.ts +1 -1
  195. package/dist/permissions/rules.d.ts +1 -2
  196. package/dist/permissions/rules.d.ts.map +1 -1
  197. package/dist/permissions/session-allow.d.ts +12 -12
  198. package/dist/permissions/session-allow.d.ts.map +1 -1
  199. package/dist/plan/approval.d.ts +1 -2
  200. package/dist/plan/approval.d.ts.map +1 -1
  201. package/dist/reminders/frame.d.ts +1 -1
  202. package/dist/reminders/frame.d.ts.map +1 -1
  203. package/dist/reminders/hypermode.d.ts +31 -0
  204. package/dist/reminders/hypermode.d.ts.map +1 -0
  205. package/dist/reminders/index.d.ts +7 -1
  206. package/dist/reminders/index.d.ts.map +1 -1
  207. package/dist/reminders/plan-mode.d.ts +1 -1
  208. package/dist/reminders/task-nudge.d.ts +1 -1
  209. package/dist/schedule/fire/fire.d.ts.map +1 -1
  210. package/dist/tui/AgentExplorer.d.ts +37 -10
  211. package/dist/tui/AgentExplorer.d.ts.map +1 -1
  212. package/dist/tui/App.d.ts +23 -3
  213. package/dist/tui/App.d.ts.map +1 -1
  214. package/dist/tui/BackgroundAgentRows.d.ts +13 -0
  215. package/dist/tui/BackgroundAgentRows.d.ts.map +1 -0
  216. package/dist/tui/BackgroundJobsPanel.d.ts.map +1 -1
  217. package/dist/tui/BrandHeader.d.ts +2 -0
  218. package/dist/tui/BrandHeader.d.ts.map +1 -1
  219. package/dist/tui/ChoicePicker.d.ts +8 -1
  220. package/dist/tui/ChoicePicker.d.ts.map +1 -1
  221. package/dist/tui/Composer.d.ts +12 -4
  222. package/dist/tui/Composer.d.ts.map +1 -1
  223. package/dist/tui/ComposerFrame.d.ts +1 -1
  224. package/dist/tui/EffortSlider.d.ts +4 -4
  225. package/dist/tui/EffortSlider.d.ts.map +1 -1
  226. package/dist/tui/LiveActivity.d.ts +8 -3
  227. package/dist/tui/LiveActivity.d.ts.map +1 -1
  228. package/dist/tui/PendingInputPanel.d.ts +1 -1
  229. package/dist/tui/PendingInputPanel.d.ts.map +1 -1
  230. package/dist/tui/PermissionOverlay.d.ts +1 -1
  231. package/dist/tui/PermissionOverlay.d.ts.map +1 -1
  232. package/dist/tui/PlanApprovalOverlay.d.ts +2 -2
  233. package/dist/tui/QuestionDialog.d.ts +1 -1
  234. package/dist/tui/ResumePicker.d.ts.map +1 -1
  235. package/dist/tui/StatusBar.d.ts +22 -7
  236. package/dist/tui/StatusBar.d.ts.map +1 -1
  237. package/dist/tui/Transcript.d.ts +6 -5
  238. package/dist/tui/Transcript.d.ts.map +1 -1
  239. package/dist/tui/TrustPrompt.d.ts +11 -1
  240. package/dist/tui/TrustPrompt.d.ts.map +1 -1
  241. package/dist/tui/agent-stop-all.d.ts +36 -0
  242. package/dist/tui/agent-stop-all.d.ts.map +1 -0
  243. package/dist/tui/agent-transcript-rows.d.ts +34 -19
  244. package/dist/tui/agent-transcript-rows.d.ts.map +1 -1
  245. package/dist/tui/agent-view-commands.d.ts +3 -5
  246. package/dist/tui/agent-view-commands.d.ts.map +1 -1
  247. package/dist/tui/agent.d.ts +55 -7
  248. package/dist/tui/agent.d.ts.map +1 -1
  249. package/dist/tui/background-agents.d.ts +46 -0
  250. package/dist/tui/background-agents.d.ts.map +1 -0
  251. package/dist/tui/browser-notices.d.ts +3 -3
  252. package/dist/tui/browser-notices.d.ts.map +1 -1
  253. package/dist/tui/choice-selection.d.ts +3 -1
  254. package/dist/tui/choice-selection.d.ts.map +1 -1
  255. package/dist/tui/compaction-rows.d.ts +51 -0
  256. package/dist/tui/compaction-rows.d.ts.map +1 -0
  257. package/dist/tui/composer-hints.d.ts +26 -0
  258. package/dist/tui/composer-hints.d.ts.map +1 -0
  259. package/dist/tui/context-meter.d.ts +1 -1
  260. package/dist/tui/diff-rows.d.ts +41 -0
  261. package/dist/tui/diff-rows.d.ts.map +1 -0
  262. package/dist/tui/diff-view.d.ts +99 -0
  263. package/dist/tui/diff-view.d.ts.map +1 -0
  264. package/dist/tui/display-path.d.ts +10 -0
  265. package/dist/tui/display-path.d.ts.map +1 -0
  266. package/dist/tui/exit-hint.d.ts +3 -0
  267. package/dist/tui/exit-hint.d.ts.map +1 -0
  268. package/dist/tui/hint-counts.d.ts +7 -0
  269. package/dist/tui/hint-counts.d.ts.map +1 -0
  270. package/dist/tui/hypermode.d.ts +20 -26
  271. package/dist/tui/hypermode.d.ts.map +1 -1
  272. package/dist/tui/index.d.ts.map +1 -1
  273. package/dist/tui/job-exit-row.d.ts +1 -1
  274. package/dist/tui/job-exit-row.d.ts.map +1 -1
  275. package/dist/tui/live-window.d.ts +1 -1
  276. package/dist/tui/live-window.d.ts.map +1 -1
  277. package/dist/tui/markdown-table.d.ts +1 -2
  278. package/dist/tui/markdown-table.d.ts.map +1 -1
  279. package/dist/tui/markdown-wrap.d.ts.map +1 -1
  280. package/dist/tui/paste-chips.d.ts +22 -0
  281. package/dist/tui/paste-chips.d.ts.map +1 -0
  282. package/dist/tui/pause-clock.d.ts +15 -0
  283. package/dist/tui/pause-clock.d.ts.map +1 -0
  284. package/dist/tui/permission-review.d.ts +6 -0
  285. package/dist/tui/permission-review.d.ts.map +1 -1
  286. package/dist/tui/placeholder-examples.d.ts +5 -0
  287. package/dist/tui/placeholder-examples.d.ts.map +1 -0
  288. package/dist/tui/plain-interruption.d.ts +9 -1
  289. package/dist/tui/plain-interruption.d.ts.map +1 -1
  290. package/dist/tui/restored-rows.d.ts +85 -0
  291. package/dist/tui/restored-rows.d.ts.map +1 -0
  292. package/dist/tui/schedule/source-deliveries.d.ts +8 -1
  293. package/dist/tui/schedule/source-deliveries.d.ts.map +1 -1
  294. package/dist/tui/shell-cell.d.ts +15 -0
  295. package/dist/tui/shell-cell.d.ts.map +1 -1
  296. package/dist/tui/shell-escape.d.ts +4 -1
  297. package/dist/tui/shell-escape.d.ts.map +1 -1
  298. package/dist/tui/slashCommands.d.ts +6 -0
  299. package/dist/tui/slashCommands.d.ts.map +1 -1
  300. package/dist/tui/stall-colour.d.ts +20 -0
  301. package/dist/tui/stall-colour.d.ts.map +1 -0
  302. package/dist/tui/status-line/StatusLineRows.d.ts +1 -2
  303. package/dist/tui/status-line/StatusLineRows.d.ts.map +1 -1
  304. package/dist/tui/status-line/controller.d.ts +1 -1
  305. package/dist/tui/status-line/output.d.ts +2 -2
  306. package/dist/tui/status-line/payload.d.ts +2 -2
  307. package/dist/tui/status-line/run-command.d.ts +1 -1
  308. package/dist/tui/system-rows.d.ts +85 -0
  309. package/dist/tui/system-rows.d.ts.map +1 -0
  310. package/dist/tui/terminal-choice-text.d.ts +7 -0
  311. package/dist/tui/terminal-choice-text.d.ts.map +1 -1
  312. package/dist/tui/theme.d.ts +21 -0
  313. package/dist/tui/theme.d.ts.map +1 -1
  314. package/dist/tui/tidy-tool-output.d.ts +2 -14
  315. package/dist/tui/tidy-tool-output.d.ts.map +1 -1
  316. package/dist/tui/tool-end-rows.d.ts +61 -0
  317. package/dist/tui/tool-end-rows.d.ts.map +1 -0
  318. package/dist/tui/tool-failure-text.d.ts +13 -0
  319. package/dist/tui/tool-failure-text.d.ts.map +1 -0
  320. package/dist/tui/triggers/context-text.d.ts +3 -3
  321. package/dist/tui/triggers/context-text.d.ts.map +1 -1
  322. package/dist/tui/triggers/copy.d.ts +14 -11
  323. package/dist/tui/triggers/copy.d.ts.map +1 -1
  324. package/dist/tui/triggers/detect.d.ts.map +1 -1
  325. package/dist/tui/triggers/registry.d.ts +3 -4
  326. package/dist/tui/triggers/registry.d.ts.map +1 -1
  327. package/dist/tui/triggers/setting.d.ts.map +1 -1
  328. package/dist/tui/truncation.d.ts +27 -0
  329. package/dist/tui/truncation.d.ts.map +1 -0
  330. package/dist/tui/turn-interruption.d.ts +2 -0
  331. package/dist/tui/turn-interruption.d.ts.map +1 -1
  332. package/dist/tui/typed-input.d.ts +14 -0
  333. package/dist/tui/typed-input.d.ts.map +1 -0
  334. package/dist/tui/types.d.ts +16 -1
  335. package/dist/tui/types.d.ts.map +1 -1
  336. package/dist/tui/units.d.ts +17 -1
  337. package/dist/tui/units.d.ts.map +1 -1
  338. package/dist/tui/user-text-view.d.ts +25 -0
  339. package/dist/tui/user-text-view.d.ts.map +1 -0
  340. package/dist/tui/web-activity.d.ts.map +1 -1
  341. package/dist/tui/workflow-runs.d.ts.map +1 -1
  342. package/dist/tui/workspace-diff.d.ts +19 -0
  343. package/dist/tui/workspace-diff.d.ts.map +1 -1
  344. package/package.json +8 -7
  345. package/dist/chunks/acp-GBQKP3SQ.js.map +0 -6
  346. package/dist/chunks/agent-session-CQ52CRGK.js +0 -52
  347. package/dist/chunks/chunk-42CAONYE.js.map +0 -6
  348. package/dist/chunks/chunk-5BZSCNGR.js.map +0 -6
  349. package/dist/chunks/chunk-AMT74CY7.js.map +0 -6
  350. package/dist/chunks/chunk-CZVHXYGD.js.map +0 -6
  351. package/dist/chunks/chunk-LWXTAX2V.js.map +0 -6
  352. package/dist/chunks/chunk-MDEIMYQU.js.map +0 -6
  353. package/dist/chunks/chunk-OUTFB7EJ.js.map +0 -6
  354. package/dist/chunks/chunk-Q3IWEW4F.js.map +0 -6
  355. package/dist/chunks/chunk-WXMFE5SS.js.map +0 -6
  356. package/dist/chunks/chunk-XM3W7NMM.js.map +0 -6
  357. package/dist/chunks/cli-runtime-53GYDVBD.js.map +0 -6
  358. package/dist/chunks/dist-ADL22Y3L.js.map +0 -6
  359. package/dist/chunks/exec-A5BM63JW.js.map +0 -6
  360. package/dist/chunks/message-command-RGUNGNNC.js.map +0 -6
  361. package/dist/chunks/resume-KV2D6FK4.js +0 -22
  362. package/dist/chunks/session-step-QNH35CYJ.js +0 -29
  363. package/dist/chunks/tui-EWFJ5CEO.js.map +0 -6
  364. package/dist/chunks/upgrade-2HP3BTOT.js.map +0 -6
  365. /package/dist/chunks/{activity-command-6CVS5DZI.js.map → activity-command-NKOTZ5FK.js.map} +0 -0
  366. /package/dist/chunks/{add-VVRTXHDQ.js.map → add-AONYUNXG.js.map} +0 -0
  367. /package/dist/chunks/{agent-UZHYPLYW.js.map → agent-YPKFE66C.js.map} +0 -0
  368. /package/dist/chunks/{agent-session-CQ52CRGK.js.map → agent-session-HFOLAFFL.js.map} +0 -0
  369. /package/dist/chunks/{archive-YWLKZACK.js.map → archive-SUE5OUZZ.js.map} +0 -0
  370. /package/dist/chunks/{bin-main-LVQFA6PZ.js.map → bin-main-55PUHGTA.js.map} +0 -0
  371. /package/dist/chunks/{browser-HD24O6AL.js.map → browser-HYPSUDAZ.js.map} +0 -0
  372. /package/dist/chunks/{chat-VOBGMUI3.js.map → chat-6OULID33.js.map} +0 -0
  373. /package/dist/chunks/{chunk-7M3YW2NF.js.map → chunk-233DQVSC.js.map} +0 -0
  374. /package/dist/chunks/{chunk-HAJ7UV4Y.js.map → chunk-263WNQB4.js.map} +0 -0
  375. /package/dist/chunks/{chunk-W47OQU6P.js.map → chunk-2KKF45DQ.js.map} +0 -0
  376. /package/dist/chunks/{chunk-UASN4SLO.js.map → chunk-2VMMTC2V.js.map} +0 -0
  377. /package/dist/chunks/{chunk-IP36P4KT.js.map → chunk-2WQFRVVQ.js.map} +0 -0
  378. /package/dist/chunks/{chunk-MSNMI4KG.js.map → chunk-3OAGXDRM.js.map} +0 -0
  379. /package/dist/chunks/{chunk-XBCEWEQN.js.map → chunk-47TGPZWD.js.map} +0 -0
  380. /package/dist/chunks/{chunk-GIBXNY7Z.js.map → chunk-4K2NRXHJ.js.map} +0 -0
  381. /package/dist/chunks/{chunk-42GHVPZE.js.map → chunk-5CGH647C.js.map} +0 -0
  382. /package/dist/chunks/{chunk-7LMPS6TV.js.map → chunk-74U3P65Q.js.map} +0 -0
  383. /package/dist/chunks/{chunk-XNOORMEP.js.map → chunk-7EASYULO.js.map} +0 -0
  384. /package/dist/chunks/{chunk-MKPICNP7.js.map → chunk-7YXHOSHD.js.map} +0 -0
  385. /package/dist/chunks/{chunk-AEB7KCO6.js.map → chunk-AZ3YHVFA.js.map} +0 -0
  386. /package/dist/chunks/{chunk-YUX6OJOD.js.map → chunk-B2357ETN.js.map} +0 -0
  387. /package/dist/chunks/{chunk-J7RNZR6A.js.map → chunk-BEFTUDYP.js.map} +0 -0
  388. /package/dist/chunks/{chunk-NR6YON2Q.js.map → chunk-CL5TCY4F.js.map} +0 -0
  389. /package/dist/chunks/{chunk-52E6DDZD.js.map → chunk-CUOWARJI.js.map} +0 -0
  390. /package/dist/chunks/{chunk-FDAOPSRK.js.map → chunk-DFA5OB46.js.map} +0 -0
  391. /package/dist/chunks/{chunk-JFZF3FQ2.js.map → chunk-E3HCZYGN.js.map} +0 -0
  392. /package/dist/chunks/{chunk-BSBFGZLW.js.map → chunk-EA6SWPO4.js.map} +0 -0
  393. /package/dist/chunks/{chunk-WWGLUAHZ.js.map → chunk-EUU4TDTH.js.map} +0 -0
  394. /package/dist/chunks/{chunk-ZAUFSEHS.js.map → chunk-FBNKKDIY.js.map} +0 -0
  395. /package/dist/chunks/{chunk-DTMONWML.js.map → chunk-FQZFVLJB.js.map} +0 -0
  396. /package/dist/chunks/{chunk-WTF2RVKD.js.map → chunk-HU35YAIZ.js.map} +0 -0
  397. /package/dist/chunks/{chunk-2UBCLXGV.js.map → chunk-IAYIUJMI.js.map} +0 -0
  398. /package/dist/chunks/{chunk-U3JIZFOS.js.map → chunk-IE5XIE4W.js.map} +0 -0
  399. /package/dist/chunks/{chunk-SDABAQVK.js.map → chunk-II57E2QW.js.map} +0 -0
  400. /package/dist/chunks/{chunk-54BF5YUB.js.map → chunk-LFVQSMJG.js.map} +0 -0
  401. /package/dist/chunks/{chunk-MW3PKVXY.js.map → chunk-MCNEFI5Q.js.map} +0 -0
  402. /package/dist/chunks/{chunk-YA4IH46E.js.map → chunk-N3FI7O4U.js.map} +0 -0
  403. /package/dist/chunks/{chunk-XXBN2OWW.js.map → chunk-N72DH6D5.js.map} +0 -0
  404. /package/dist/chunks/{chunk-TDDCRQZZ.js.map → chunk-OLOTFDTU.js.map} +0 -0
  405. /package/dist/chunks/{chunk-G6QXPPH3.js.map → chunk-P2Y4LUPJ.js.map} +0 -0
  406. /package/dist/chunks/{chunk-65Y4XRJ7.js.map → chunk-QNF6COCY.js.map} +0 -0
  407. /package/dist/chunks/{chunk-GXE2VIGI.js.map → chunk-RB36O3CE.js.map} +0 -0
  408. /package/dist/chunks/{chunk-ALNCCKDI.js.map → chunk-SBPCN24X.js.map} +0 -0
  409. /package/dist/chunks/{chunk-XNY2DD22.js.map → chunk-SIK62TDI.js.map} +0 -0
  410. /package/dist/chunks/{chunk-VXHYLNLR.js.map → chunk-T75ITEN6.js.map} +0 -0
  411. /package/dist/chunks/{chunk-6GJXAHUO.js.map → chunk-TJTRVZFN.js.map} +0 -0
  412. /package/dist/chunks/{chunk-H3LH5GZ5.js.map → chunk-UIDLXA2K.js.map} +0 -0
  413. /package/dist/chunks/{chunk-YBZMF6LC.js.map → chunk-UTMGJDC3.js.map} +0 -0
  414. /package/dist/chunks/{chunk-YE2PFKVU.js.map → chunk-UUUNXKL3.js.map} +0 -0
  415. /package/dist/chunks/{chunk-6ARSJBCV.js.map → chunk-UZCA37QE.js.map} +0 -0
  416. /package/dist/chunks/{chunk-LQFMXCHI.js.map → chunk-W27ZDC4R.js.map} +0 -0
  417. /package/dist/chunks/{chunk-5DJ5YIHY.js.map → chunk-XJ4IUCH6.js.map} +0 -0
  418. /package/dist/chunks/{chunk-6N6HLU4F.js.map → chunk-YKEPC6NH.js.map} +0 -0
  419. /package/dist/chunks/{chunk-HQ37JKI2.js.map → chunk-Z7XA4Y43.js.map} +0 -0
  420. /package/dist/chunks/{commands-X2P7B7M6.js.map → commands-TIRZH2TK.js.map} +0 -0
  421. /package/dist/chunks/{crash-report-YKKJEHWY.js.map → crash-report-E4J7KQ32.js.map} +0 -0
  422. /package/dist/chunks/{dist-E24W5SI7.js.map → dist-2IUQEIEI.js.map} +0 -0
  423. /package/dist/chunks/{dist-TTCX7GFK.js.map → dist-2U6NNEPY.js.map} +0 -0
  424. /package/dist/chunks/{dist-KP5U4QDN.js.map → dist-CVDGKJEI.js.map} +0 -0
  425. /package/dist/chunks/{dist-TYCOBKDT.js.map → dist-MKQZKCB4.js.map} +0 -0
  426. /package/dist/chunks/{dist-EO3WQFRN.js.map → dist-QCKKBLDW.js.map} +0 -0
  427. /package/dist/chunks/{dist-6ABVUWX5.js.map → dist-QHKTYYMX.js.map} +0 -0
  428. /package/dist/chunks/{dist-5KZ4SS57.js.map → dist-YX7Q3EJR.js.map} +0 -0
  429. /package/dist/chunks/{doctor-QTMSOOEO.js.map → doctor-ASXICRC5.js.map} +0 -0
  430. /package/dist/chunks/{drain-FWONJITS.js.map → drain-CGS3KBU3.js.map} +0 -0
  431. /package/dist/chunks/{eval-GQTJX6WI.js.map → eval-XWC3UCFI.js.map} +0 -0
  432. /package/dist/chunks/{home-QAEAKEUG.js.map → home-76YLI2M6.js.map} +0 -0
  433. /package/dist/chunks/{host-queries-NY6FDVNU.js.map → host-queries-ODUQHYBN.js.map} +0 -0
  434. /package/dist/chunks/{lifecycle-EJQ57UR7.js.map → lifecycle-JN43XQSS.js.map} +0 -0
  435. /package/dist/chunks/{list-P5KDSX7R.js.map → list-TC7TYJDR.js.map} +0 -0
  436. /package/dist/chunks/{login-PQAWB3YL.js.map → login-CTC6CAM4.js.map} +0 -0
  437. /package/dist/chunks/{logs-PYWTK275.js.map → logs-2NGJFIQI.js.map} +0 -0
  438. /package/dist/chunks/{mcp-QJRY437O.js.map → mcp-BPH7KWZ6.js.map} +0 -0
  439. /package/dist/chunks/{operator-tools-UH4SJXQJ.js.map → operator-tools-6RYAHVSL.js.map} +0 -0
  440. /package/dist/chunks/{output-schema-BN6UL2BB.js.map → output-schema-GSWZHKSI.js.map} +0 -0
  441. /package/dist/chunks/{pal-NAJGPRTW.js.map → pal-4QXXG42H.js.map} +0 -0
  442. /package/dist/chunks/{providers-VTT4SK6S.js.map → providers-6PIIF3WR.js.map} +0 -0
  443. /package/dist/chunks/{resident-AQYBL2GF.js.map → resident-UP7W6MV6.js.map} +0 -0
  444. /package/dist/chunks/{resume-KV2D6FK4.js.map → resume-GJHTPMJS.js.map} +0 -0
  445. /package/dist/chunks/{resume-command-AOT7YZT5.js.map → resume-command-2RFT7AGW.js.map} +0 -0
  446. /package/dist/chunks/{schedule-WYFFJI6G.js.map → schedule-FZISVF6A.js.map} +0 -0
  447. /package/dist/chunks/{service-HAMHYSEA.js.map → service-4WADXOUI.js.map} +0 -0
  448. /package/dist/chunks/{session-step-QNH35CYJ.js.map → session-step-FX6B4TSE.js.map} +0 -0
  449. /package/dist/chunks/{skills-5TJTJEDG.js.map → skills-BJQGVQ23.js.map} +0 -0
  450. /package/dist/chunks/{state-ABEFSCFQ.js.map → state-2KKVQPZ2.js.map} +0 -0
  451. /package/dist/chunks/{store-BL5L6BOI.js.map → store-LO4SSRYI.js.map} +0 -0
  452. /package/dist/chunks/{store-UKFFPFLI.js.map → store-TKJKR5NM.js.map} +0 -0
  453. /package/dist/chunks/{store-WBED64YS.js.map → store-YFTJ24WU.js.map} +0 -0
  454. /package/dist/chunks/{worktree-PNFBTACG.js.map → worktree-3HYAYSGW.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 {
@@ -9342,7 +9342,7 @@ function codeFromMessage(message, status) {
9342
9342
  // a plain invalid request — which is not retryable, and which the
9343
9343
  // overflow rescue tests for by exact equality. The turn died holding
9344
9344
  // the remedy.
9345
- m.includes("too long for") || // The reference terminal's own wordings (its `context window` and
9345
+ m.includes("too long for") || // Known wordings: `context window` and
9346
9346
  // `input length and max_tokens exceed context limit` matchers).
9347
9347
  // Only where the status cannot say otherwise: a 429, 5xx or 401 that
9348
9348
  // mentions the window is still a rate limit, a server fault or an auth
@@ -9781,14 +9781,14 @@ function revisionFileSegment(value) {
9781
9781
  return out;
9782
9782
  }
9783
9783
  __name(revisionFileSegment, "revisionFileSegment");
9784
- function decodeRevisionFileSegment(segment) {
9785
- if (segment === "~empty")
9784
+ function decodeRevisionFileSegment(segment2) {
9785
+ if (segment2 === "~empty")
9786
9786
  return "";
9787
- if (segment.length === 0)
9787
+ if (segment2.length === 0)
9788
9788
  return null;
9789
9789
  let value = "";
9790
- for (let i = 0; i < segment.length; i++) {
9791
- const char = segment[i];
9790
+ for (let i = 0; i < segment2.length; i++) {
9791
+ const char = segment2[i];
9792
9792
  if (char === void 0)
9793
9793
  return null;
9794
9794
  if (char !== "~") {
@@ -9797,13 +9797,13 @@ function decodeRevisionFileSegment(segment) {
9797
9797
  value += char;
9798
9798
  continue;
9799
9799
  }
9800
- const escaped = segment.slice(i + 1, i + 5);
9800
+ const escaped = segment2.slice(i + 1, i + 5);
9801
9801
  if (!/^[0-9a-f]{4}$/u.test(escaped))
9802
9802
  return null;
9803
9803
  value += String.fromCharCode(Number.parseInt(escaped, 16));
9804
9804
  i += 4;
9805
9805
  }
9806
- return revisionFileSegment(value) === segment ? value : null;
9806
+ return revisionFileSegment(value) === segment2 ? value : null;
9807
9807
  }
9808
9808
  __name(decodeRevisionFileSegment, "decodeRevisionFileSegment");
9809
9809
  var DiskRevisionRecordStore = class {
@@ -10379,10 +10379,10 @@ var DiskSessionGoalStore = class extends SessionGoalStoreBase {
10379
10379
  }
10380
10380
  location(sessionId5) {
10381
10381
  const root = join4(this.config.rootDir, "goals");
10382
- const segment = revisionFileSegment(sessionId5);
10382
+ const segment2 = revisionFileSegment(sessionId5);
10383
10383
  return {
10384
- legacyPath: join4(root, `${segment}.json`),
10385
- revisionsDir: join4(root, ".revisions", segment)
10384
+ legacyPath: join4(root, `${segment2}.json`),
10385
+ revisionsDir: join4(root, ".revisions", segment2)
10386
10386
  };
10387
10387
  }
10388
10388
  async put(record3) {
@@ -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
 
@@ -15841,8 +15849,8 @@ var OVERFLOW_BODY_PATTERNS = [
15841
15849
  // length" — so a pattern anchored on "exceeded" misses it entirely.
15842
15850
  /exceeds?\s+(?:the\s+)?(?:model'?s?\s+)?context\s+(?:length|window|size)/i,
15843
15851
  /context\s+(?:length|window|size)\s+exceed/i,
15844
- // The reference terminal's own list matches the bare phrase "context
15845
- // window". Here it must sit next to a verb that says the request did not
15852
+ // The bare phrase "context
15853
+ // window" is too broad on its own. Here it must sit next to a verb that says the request did not
15846
15854
  // fit ("larger than the model context window of N tokens"), so a 400 that
15847
15855
  // only names the window ("does not support this parameter with the 1M
15848
15856
  // context window beta") stays an invalid request. The same pattern lives in
@@ -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:
@@ -23103,8 +23111,8 @@ var FILE_NAMES = new Set(PROTECTED_FILE_NAMES.map(fold));
23103
23111
  var NESTED = PROTECTED_NESTED_DIRECTORIES.map((sequence) => sequence.map(fold));
23104
23112
  function isProtectedPath(path2) {
23105
23113
  const segments = path2.split(/[\\/]+/).map(fold);
23106
- for (const segment of segments) {
23107
- if (DIRECTORIES.has(segment))
23114
+ for (const segment2 of segments) {
23115
+ if (DIRECTORIES.has(segment2))
23108
23116
  return true;
23109
23117
  }
23110
23118
  for (const sequence of NESTED) {
@@ -23337,10 +23345,10 @@ function checkTarget(program, args, spelled, word2, scope) {
23337
23345
  __name(checkTarget, "checkTarget");
23338
23346
  function hasParentAfterName(path2) {
23339
23347
  let named = false;
23340
- for (const segment of path2.split(/[\\/]+/)) {
23341
- if (segment === "" || segment === ".")
23348
+ for (const segment2 of path2.split(/[\\/]+/)) {
23349
+ if (segment2 === "" || segment2 === ".")
23342
23350
  continue;
23343
- if (segment === "..") {
23351
+ if (segment2 === "..") {
23344
23352
  if (named)
23345
23353
  return true;
23346
23354
  } else
@@ -25613,15 +25621,15 @@ function applyOne(content, input) {
25613
25621
  __name(applyOne, "applyOne");
25614
25622
  function applyLineInsert(content, input) {
25615
25623
  const hasTrailingNewline = content.endsWith("\n");
25616
- const lines2 = content.split("\n");
25624
+ const lines = content.split("\n");
25617
25625
  if (hasTrailingNewline)
25618
- lines2.pop();
25619
- 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);
25620
25628
  const inserted = input.newString.endsWith("\n") ? input.newString.slice(0, -1).split("\n") : input.newString.split("\n");
25621
- lines2.splice(line, 0, ...inserted);
25629
+ lines.splice(line, 0, ...inserted);
25622
25630
  return {
25623
25631
  success: true,
25624
- content: `${lines2.join("\n")}${hasTrailingNewline ? "\n" : ""}`,
25632
+ content: `${lines.join("\n")}${hasTrailingNewline ? "\n" : ""}`,
25625
25633
  replacements: 1
25626
25634
  };
25627
25635
  }
@@ -25798,6 +25806,770 @@ function jsonStringEscapes(where) {
25798
25806
  }
25799
25807
  __name(jsonStringEscapes, "jsonStringEscapes");
25800
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/util/string.js
26015
+ function longestCommonPrefix(str1, str2) {
26016
+ let i;
26017
+ for (i = 0; i < str1.length && i < str2.length; i++) {
26018
+ if (str1[i] != str2[i]) {
26019
+ return str1.slice(0, i);
26020
+ }
26021
+ }
26022
+ return str1.slice(0, i);
26023
+ }
26024
+ __name(longestCommonPrefix, "longestCommonPrefix");
26025
+ function longestCommonSuffix(str1, str2) {
26026
+ let i;
26027
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
26028
+ return "";
26029
+ }
26030
+ for (i = 0; i < str1.length && i < str2.length; i++) {
26031
+ if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
26032
+ return str1.slice(-i);
26033
+ }
26034
+ }
26035
+ return str1.slice(-i);
26036
+ }
26037
+ __name(longestCommonSuffix, "longestCommonSuffix");
26038
+ function replacePrefix(string, oldPrefix, newPrefix) {
26039
+ if (string.slice(0, oldPrefix.length) != oldPrefix) {
26040
+ throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
26041
+ }
26042
+ return newPrefix + string.slice(oldPrefix.length);
26043
+ }
26044
+ __name(replacePrefix, "replacePrefix");
26045
+ function replaceSuffix(string, oldSuffix, newSuffix) {
26046
+ if (!oldSuffix) {
26047
+ return string + newSuffix;
26048
+ }
26049
+ if (string.slice(-oldSuffix.length) != oldSuffix) {
26050
+ throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
26051
+ }
26052
+ return string.slice(0, -oldSuffix.length) + newSuffix;
26053
+ }
26054
+ __name(replaceSuffix, "replaceSuffix");
26055
+ function removePrefix(string, oldPrefix) {
26056
+ return replacePrefix(string, oldPrefix, "");
26057
+ }
26058
+ __name(removePrefix, "removePrefix");
26059
+ function removeSuffix(string, oldSuffix) {
26060
+ return replaceSuffix(string, oldSuffix, "");
26061
+ }
26062
+ __name(removeSuffix, "removeSuffix");
26063
+ function maximumOverlap(string1, string2) {
26064
+ return string2.slice(0, overlapCount(string1, string2));
26065
+ }
26066
+ __name(maximumOverlap, "maximumOverlap");
26067
+ function overlapCount(a, b) {
26068
+ let startA = 0;
26069
+ if (a.length > b.length) {
26070
+ startA = a.length - b.length;
26071
+ }
26072
+ let endB = b.length;
26073
+ if (a.length < b.length) {
26074
+ endB = a.length;
26075
+ }
26076
+ const map = Array(endB);
26077
+ let k = 0;
26078
+ map[0] = 0;
26079
+ for (let j = 1; j < endB; j++) {
26080
+ if (b[j] == b[k]) {
26081
+ map[j] = map[k];
26082
+ } else {
26083
+ map[j] = k;
26084
+ }
26085
+ while (k > 0 && b[j] != b[k]) {
26086
+ k = map[k];
26087
+ }
26088
+ if (b[j] == b[k]) {
26089
+ k++;
26090
+ }
26091
+ }
26092
+ k = 0;
26093
+ for (let i = startA; i < a.length; i++) {
26094
+ while (k > 0 && a[i] != b[k]) {
26095
+ k = map[k];
26096
+ }
26097
+ if (a[i] == b[k]) {
26098
+ k++;
26099
+ }
26100
+ }
26101
+ return k;
26102
+ }
26103
+ __name(overlapCount, "overlapCount");
26104
+ function segment(string, segmenter) {
26105
+ const parts = [];
26106
+ for (const segmentObj of Array.from(segmenter.segment(string))) {
26107
+ const segment2 = segmentObj.segment;
26108
+ if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment2)) {
26109
+ parts[parts.length - 1] += segment2;
26110
+ } else {
26111
+ parts.push(segment2);
26112
+ }
26113
+ }
26114
+ return parts;
26115
+ }
26116
+ __name(segment, "segment");
26117
+ function trailingWs(string, segmenter) {
26118
+ if (segmenter) {
26119
+ return leadingAndTrailingWs(string, segmenter)[1];
26120
+ }
26121
+ let i;
26122
+ for (i = string.length - 1; i >= 0; i--) {
26123
+ if (!string[i].match(/\s/)) {
26124
+ break;
26125
+ }
26126
+ }
26127
+ return string.substring(i + 1);
26128
+ }
26129
+ __name(trailingWs, "trailingWs");
26130
+ function leadingWs(string, segmenter) {
26131
+ if (segmenter) {
26132
+ return leadingAndTrailingWs(string, segmenter)[0];
26133
+ }
26134
+ const match2 = string.match(/^\s*/);
26135
+ return match2 ? match2[0] : "";
26136
+ }
26137
+ __name(leadingWs, "leadingWs");
26138
+ function leadingAndTrailingWs(string, segmenter) {
26139
+ if (!segmenter) {
26140
+ return [leadingWs(string), trailingWs(string)];
26141
+ }
26142
+ if (segmenter.resolvedOptions().granularity != "word") {
26143
+ throw new Error('The segmenter passed must have a granularity of "word"');
26144
+ }
26145
+ const segments = segment(string, segmenter);
26146
+ const firstSeg = segments[0];
26147
+ const lastSeg = segments[segments.length - 1];
26148
+ const head2 = /\s/.test(firstSeg) ? firstSeg : "";
26149
+ const tail = /\s/.test(lastSeg) ? lastSeg : "";
26150
+ return [head2, tail];
26151
+ }
26152
+ __name(leadingAndTrailingWs, "leadingAndTrailingWs");
26153
+
26154
+ // ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/word.js
26155
+ var extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
26156
+ var tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
26157
+ var WordDiff = class extends Diff {
26158
+ static {
26159
+ __name(this, "WordDiff");
26160
+ }
26161
+ equals(left, right, options) {
26162
+ if (options.ignoreCase) {
26163
+ left = left.toLowerCase();
26164
+ right = right.toLowerCase();
26165
+ }
26166
+ return left.trim() === right.trim();
26167
+ }
26168
+ tokenize(value, options = {}) {
26169
+ let parts;
26170
+ if (options.intlSegmenter) {
26171
+ const segmenter = options.intlSegmenter;
26172
+ if (segmenter.resolvedOptions().granularity != "word") {
26173
+ throw new Error('The segmenter passed must have a granularity of "word"');
26174
+ }
26175
+ parts = segment(value, segmenter);
26176
+ } else {
26177
+ parts = value.match(tokenizeIncludingWhitespace) || [];
26178
+ }
26179
+ const tokens = [];
26180
+ let prevPart = null;
26181
+ parts.forEach((part2) => {
26182
+ if (/\s/.test(part2)) {
26183
+ if (prevPart == null) {
26184
+ tokens.push(part2);
26185
+ } else {
26186
+ tokens.push(tokens.pop() + part2);
26187
+ }
26188
+ } else if (prevPart != null && /\s/.test(prevPart)) {
26189
+ if (tokens[tokens.length - 1] == prevPart) {
26190
+ tokens.push(tokens.pop() + part2);
26191
+ } else {
26192
+ tokens.push(prevPart + part2);
26193
+ }
26194
+ } else {
26195
+ tokens.push(part2);
26196
+ }
26197
+ prevPart = part2;
26198
+ });
26199
+ return tokens;
26200
+ }
26201
+ join(tokens) {
26202
+ return tokens.map((token, i) => {
26203
+ if (i == 0) {
26204
+ return token;
26205
+ } else {
26206
+ return token.replace(/^\s+/, "");
26207
+ }
26208
+ }).join("");
26209
+ }
26210
+ postProcess(changes, options) {
26211
+ if (!changes || options.oneChangePerToken) {
26212
+ return changes;
26213
+ }
26214
+ let lastKeep = null;
26215
+ let insertion = null;
26216
+ let deletion = null;
26217
+ changes.forEach((change) => {
26218
+ if (change.added) {
26219
+ insertion = change;
26220
+ } else if (change.removed) {
26221
+ deletion = change;
26222
+ } else {
26223
+ if (insertion || deletion) {
26224
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);
26225
+ }
26226
+ lastKeep = change;
26227
+ insertion = null;
26228
+ deletion = null;
26229
+ }
26230
+ });
26231
+ if (insertion || deletion) {
26232
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);
26233
+ }
26234
+ return changes;
26235
+ }
26236
+ };
26237
+ var wordDiff = new WordDiff();
26238
+ function diffWords(oldStr, newStr, options) {
26239
+ if ((options === null || options === void 0 ? void 0 : options.ignoreWhitespace) != null && !options.ignoreWhitespace) {
26240
+ return diffWordsWithSpace(oldStr, newStr, options);
26241
+ }
26242
+ return wordDiff.diff(oldStr, newStr, options);
26243
+ }
26244
+ __name(diffWords, "diffWords");
26245
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {
26246
+ if (deletion && insertion) {
26247
+ const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);
26248
+ const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);
26249
+ if (startKeep) {
26250
+ const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
26251
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
26252
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
26253
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
26254
+ }
26255
+ if (endKeep) {
26256
+ const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
26257
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
26258
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
26259
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
26260
+ }
26261
+ } else if (insertion) {
26262
+ if (startKeep) {
26263
+ const ws = leadingWs(insertion.value, segmenter);
26264
+ insertion.value = insertion.value.substring(ws.length);
26265
+ }
26266
+ if (endKeep) {
26267
+ const ws = leadingWs(endKeep.value, segmenter);
26268
+ endKeep.value = endKeep.value.substring(ws.length);
26269
+ }
26270
+ } else if (startKeep && endKeep) {
26271
+ const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);
26272
+ const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
26273
+ deletion.value = removePrefix(deletion.value, newWsStart);
26274
+ const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
26275
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
26276
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
26277
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
26278
+ } else if (endKeep) {
26279
+ const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);
26280
+ const deletionWsSuffix = trailingWs(deletion.value, segmenter);
26281
+ const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
26282
+ deletion.value = removeSuffix(deletion.value, overlap);
26283
+ } else if (startKeep) {
26284
+ const startKeepWsSuffix = trailingWs(startKeep.value, segmenter);
26285
+ const deletionWsPrefix = leadingWs(deletion.value, segmenter);
26286
+ const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
26287
+ deletion.value = removePrefix(deletion.value, overlap);
26288
+ }
26289
+ }
26290
+ __name(dedupeWhitespaceInChangeObjects, "dedupeWhitespaceInChangeObjects");
26291
+ var WordsWithSpaceDiff = class extends Diff {
26292
+ static {
26293
+ __name(this, "WordsWithSpaceDiff");
26294
+ }
26295
+ tokenize(value) {
26296
+ const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
26297
+ return value.match(regex) || [];
26298
+ }
26299
+ };
26300
+ var wordsWithSpaceDiff = new WordsWithSpaceDiff();
26301
+ function diffWordsWithSpace(oldStr, newStr, options) {
26302
+ return wordsWithSpaceDiff.diff(oldStr, newStr, options);
26303
+ }
26304
+ __name(diffWordsWithSpace, "diffWordsWithSpace");
26305
+
26306
+ // ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/line.js
26307
+ var LineDiff = class extends Diff {
26308
+ static {
26309
+ __name(this, "LineDiff");
26310
+ }
26311
+ constructor() {
26312
+ super(...arguments);
26313
+ this.tokenize = tokenize;
26314
+ }
26315
+ equals(left, right, options) {
26316
+ if (options.ignoreWhitespace) {
26317
+ if (!options.newlineIsToken || !left.includes("\n")) {
26318
+ left = left.trim();
26319
+ }
26320
+ if (!options.newlineIsToken || !right.includes("\n")) {
26321
+ right = right.trim();
26322
+ }
26323
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
26324
+ if (left.endsWith("\n")) {
26325
+ left = left.slice(0, -1);
26326
+ }
26327
+ if (right.endsWith("\n")) {
26328
+ right = right.slice(0, -1);
26329
+ }
26330
+ }
26331
+ return super.equals(left, right, options);
26332
+ }
26333
+ };
26334
+ var lineDiff = new LineDiff();
26335
+ function diffLines(oldStr, newStr, options) {
26336
+ return lineDiff.diff(oldStr, newStr, options);
26337
+ }
26338
+ __name(diffLines, "diffLines");
26339
+ function tokenize(value, options) {
26340
+ if (options.stripTrailingCr) {
26341
+ value = value.replace(/\r\n/g, "\n");
26342
+ }
26343
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
26344
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
26345
+ linesAndNewlines.pop();
26346
+ }
26347
+ for (let i = 0; i < linesAndNewlines.length; i++) {
26348
+ const line = linesAndNewlines[i];
26349
+ if (i % 2 && !options.newlineIsToken) {
26350
+ retLines[retLines.length - 1] += line;
26351
+ } else {
26352
+ retLines.push(line);
26353
+ }
26354
+ }
26355
+ return retLines;
26356
+ }
26357
+ __name(tokenize, "tokenize");
26358
+
26359
+ // ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/patch/create.js
26360
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
26361
+ let optionsObj;
26362
+ if (!options) {
26363
+ optionsObj = {};
26364
+ } else if (typeof options === "function") {
26365
+ optionsObj = { callback: options };
26366
+ } else {
26367
+ optionsObj = options;
26368
+ }
26369
+ if (typeof optionsObj.context === "undefined") {
26370
+ optionsObj.context = 4;
26371
+ }
26372
+ const context2 = optionsObj.context;
26373
+ if (optionsObj.newlineIsToken) {
26374
+ throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
26375
+ }
26376
+ if (!optionsObj.callback) {
26377
+ return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
26378
+ } else {
26379
+ const { callback } = optionsObj;
26380
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: /* @__PURE__ */ __name((diff) => {
26381
+ const patch = diffLinesResultToPatch(diff);
26382
+ callback(patch);
26383
+ }, "callback") }));
26384
+ }
26385
+ function diffLinesResultToPatch(diff) {
26386
+ if (!diff) {
26387
+ return;
26388
+ }
26389
+ diff.push({ value: "", lines: [] });
26390
+ function contextLines(lines) {
26391
+ return lines.map(function(entry) {
26392
+ return " " + entry;
26393
+ });
26394
+ }
26395
+ __name(contextLines, "contextLines");
26396
+ const hunks2 = [];
26397
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
26398
+ for (let i = 0; i < diff.length; i++) {
26399
+ const current = diff[i], lines = current.lines || splitLines(current.value);
26400
+ current.lines = lines;
26401
+ if (current.added || current.removed) {
26402
+ if (!oldRangeStart) {
26403
+ const prev = diff[i - 1];
26404
+ oldRangeStart = oldLine;
26405
+ newRangeStart = newLine;
26406
+ if (prev) {
26407
+ curRange = context2 > 0 ? contextLines(prev.lines.slice(-context2)) : [];
26408
+ oldRangeStart -= curRange.length;
26409
+ newRangeStart -= curRange.length;
26410
+ }
26411
+ }
26412
+ for (const line of lines) {
26413
+ curRange.push((current.added ? "+" : "-") + line);
26414
+ }
26415
+ if (current.added) {
26416
+ newLine += lines.length;
26417
+ } else {
26418
+ oldLine += lines.length;
26419
+ }
26420
+ } else {
26421
+ if (oldRangeStart) {
26422
+ if (lines.length <= context2 * 2 && i < diff.length - 2) {
26423
+ for (const line of contextLines(lines)) {
26424
+ curRange.push(line);
26425
+ }
26426
+ } else {
26427
+ const contextSize = Math.min(lines.length, context2);
26428
+ for (const line of contextLines(lines.slice(0, contextSize))) {
26429
+ curRange.push(line);
26430
+ }
26431
+ const hunk = {
26432
+ oldStart: oldRangeStart,
26433
+ oldLines: oldLine - oldRangeStart + contextSize,
26434
+ newStart: newRangeStart,
26435
+ newLines: newLine - newRangeStart + contextSize,
26436
+ lines: curRange
26437
+ };
26438
+ hunks2.push(hunk);
26439
+ oldRangeStart = 0;
26440
+ newRangeStart = 0;
26441
+ curRange = [];
26442
+ }
26443
+ }
26444
+ oldLine += lines.length;
26445
+ newLine += lines.length;
26446
+ }
26447
+ }
26448
+ for (const hunk of hunks2) {
26449
+ for (let i = 0; i < hunk.lines.length; i++) {
26450
+ if (hunk.lines[i].endsWith("\n")) {
26451
+ hunk.lines[i] = hunk.lines[i].slice(0, -1);
26452
+ } else {
26453
+ hunk.lines.splice(i + 1, 0, "\");
26454
+ i++;
26455
+ }
26456
+ }
26457
+ }
26458
+ return {
26459
+ oldFileName,
26460
+ newFileName,
26461
+ oldHeader,
26462
+ newHeader,
26463
+ hunks: hunks2
26464
+ };
26465
+ }
26466
+ __name(diffLinesResultToPatch, "diffLinesResultToPatch");
26467
+ }
26468
+ __name(structuredPatch, "structuredPatch");
26469
+ function splitLines(text9) {
26470
+ const hasTrailingNl = text9.endsWith("\n");
26471
+ const result = text9.split("\n").map((line) => line + "\n");
26472
+ if (hasTrailingNl) {
26473
+ result.pop();
26474
+ } else {
26475
+ result.push(result.pop().slice(0, -1));
26476
+ }
26477
+ return result;
26478
+ }
26479
+ __name(splitLines, "splitLines");
26480
+
26481
+ // ../sdk/dist/tools/builtins/line-diff.js
26482
+ var CONTEXT_LINES = 3;
26483
+ var DIFF_TIMEOUT_MS = 5e3;
26484
+ var MAX_CARRIED_DIFF_LINES = 400;
26485
+ var MAX_CARRIED_LINE_CHARS = 500;
26486
+ function cutRow(row) {
26487
+ if (row.length <= MAX_CARRIED_LINE_CHARS)
26488
+ return row;
26489
+ const cut = row.slice(0, MAX_CARRIED_LINE_CHARS - 1).replace(/[\uD800-\uDBFF]$/, "");
26490
+ return `${cut}\u2026`;
26491
+ }
26492
+ __name(cutRow, "cutRow");
26493
+ function splitKeepingTerminators(text9) {
26494
+ return text9.length === 0 ? [] : text9.match(/[^\n]*\n|[^\n]+$/g) ?? [];
26495
+ }
26496
+ __name(splitKeepingTerminators, "splitKeepingTerminators");
26497
+ function coarseDiff(before, after) {
26498
+ const a = splitKeepingTerminators(before);
26499
+ const b = splitKeepingTerminators(after);
26500
+ let head2 = 0;
26501
+ while (head2 < a.length && head2 < b.length && a[head2] === b[head2])
26502
+ head2++;
26503
+ let tail = 0;
26504
+ while (tail < a.length - head2 && tail < b.length - head2 && a[a.length - 1 - tail] === b[b.length - 1 - tail])
26505
+ tail++;
26506
+ const removed = a.slice(head2, a.length - tail);
26507
+ const added = b.slice(head2, b.length - tail);
26508
+ const rows = [
26509
+ ...removed.map((line) => `-${line.replace(/\n$/, "")}`),
26510
+ ...added.map((line) => `+${line.replace(/\n$/, "")}`)
26511
+ ];
26512
+ const kept = rows.slice(0, MAX_CARRIED_DIFF_LINES).map(cutRow);
26513
+ return {
26514
+ added: added.length,
26515
+ removed: removed.length,
26516
+ hunks: rows.length === 0 ? [] : [
26517
+ {
26518
+ oldStart: head2 + 1,
26519
+ oldLines: removed.length,
26520
+ newStart: head2 + 1,
26521
+ newLines: added.length,
26522
+ lines: kept
26523
+ }
26524
+ ],
26525
+ truncated: rows.length > kept.length
26526
+ };
26527
+ }
26528
+ __name(coarseDiff, "coarseDiff");
26529
+ function lineDiff2(before, after) {
26530
+ if (before === after)
26531
+ return { added: 0, removed: 0, hunks: [], truncated: false };
26532
+ const patch = structuredPatch("a", "a", before, after, void 0, void 0, {
26533
+ context: CONTEXT_LINES,
26534
+ timeout: DIFF_TIMEOUT_MS
26535
+ });
26536
+ if (patch === void 0)
26537
+ return coarseDiff(before, after);
26538
+ let added = 0;
26539
+ let removed = 0;
26540
+ let budget = MAX_CARRIED_DIFF_LINES;
26541
+ let truncated = false;
26542
+ const hunks2 = [];
26543
+ for (const hunk of patch.hunks) {
26544
+ const rows = [];
26545
+ for (const row of hunk.lines) {
26546
+ if (row.startsWith("\\"))
26547
+ continue;
26548
+ if (row.startsWith("+"))
26549
+ added++;
26550
+ else if (row.startsWith("-"))
26551
+ removed++;
26552
+ if (budget > 0) {
26553
+ rows.push(cutRow(row));
26554
+ budget--;
26555
+ } else {
26556
+ truncated = true;
26557
+ }
26558
+ }
26559
+ if (rows.length > 0) {
26560
+ hunks2.push({
26561
+ oldStart: hunk.oldStart,
26562
+ oldLines: hunk.oldLines,
26563
+ newStart: hunk.newStart,
26564
+ newLines: hunk.newLines,
26565
+ lines: rows
26566
+ });
26567
+ }
26568
+ }
26569
+ return { added, removed, hunks: hunks2, truncated };
26570
+ }
26571
+ __name(lineDiff2, "lineDiff");
26572
+
25801
26573
  // ../sdk/dist/tools/builtins/edit.js
25802
26574
  var inputSchema3 = external_exports.object({
25803
26575
  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."),
@@ -25994,6 +26766,22 @@ function admitAgainstRead(context2, key5, content, operations) {
25994
26766
  }
25995
26767
  __name(admitAgainstRead, "admitAgainstRead");
25996
26768
  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.';
26769
+ function editFacts(path2, replacements, before, after) {
26770
+ const diff = lineDiff2(before, after);
26771
+ return {
26772
+ diff,
26773
+ facts: {
26774
+ kind: "edit",
26775
+ path: path2,
26776
+ replacements,
26777
+ added: diff.added,
26778
+ removed: diff.removed,
26779
+ ...diff.hunks.length > 0 ? { hunks: diff.hunks } : {},
26780
+ ...diff.truncated ? { hunksTruncated: true } : {}
26781
+ }
26782
+ };
26783
+ }
26784
+ __name(editFacts, "editFacts");
25997
26785
  var EditTool = defineTool({
25998
26786
  name: "edit",
25999
26787
  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.',
@@ -26099,19 +26887,16 @@ var EditTool = defineTool({
26099
26887
  }
26100
26888
  await context2.sandbox.writeFile(parsed.data.path, result2.content);
26101
26889
  recordEditedContent(context2, parsed.data.path, result2.content);
26890
+ const changed2 = editFacts(parsed.data.path, result2.replacements, content2, result2.content);
26102
26891
  return {
26103
26892
  success: true,
26104
- output: `Edited ${parsed.data.path}: ${result2.replacements} replacement(s) [sandboxed]`,
26893
+ output: `Edited ${parsed.data.path}: ${result2.replacements} replacement(s) (+${changed2.diff.added} -${changed2.diff.removed}) [sandboxed]`,
26105
26894
  data: {
26106
26895
  path: parsed.data.path,
26107
26896
  replacements: result2.replacements,
26108
26897
  sandboxed: true
26109
26898
  },
26110
- facts: {
26111
- kind: "edit",
26112
- path: parsed.data.path,
26113
- replacements: result2.replacements
26114
- }
26899
+ facts: changed2.facts
26115
26900
  };
26116
26901
  }
26117
26902
  const hostPath = filePath;
@@ -26124,15 +26909,12 @@ var EditTool = defineTool({
26124
26909
  return { success: false, output: "", error: result.error };
26125
26910
  await atomicWriteFile2(hostPath, result.content);
26126
26911
  recordEditedContent(context2, hostPath, result.content);
26912
+ const changed = editFacts(hostPath, result.replacements, content, result.content);
26127
26913
  return {
26128
26914
  success: true,
26129
- output: `Edited ${hostPath}: ${result.replacements} replacement(s)`,
26915
+ output: `Edited ${hostPath}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed})`,
26130
26916
  data: { path: hostPath, replacements: result.replacements },
26131
- facts: {
26132
- kind: "edit",
26133
- path: hostPath,
26134
- replacements: result.replacements
26135
- }
26917
+ facts: changed.facts
26136
26918
  };
26137
26919
  });
26138
26920
  }
@@ -26168,13 +26950,13 @@ function clipTail(text9, max) {
26168
26950
  __name(clipTail, "clipTail");
26169
26951
  function windowText(text9, totalBytes = Buffer.byteLength(text9, "utf8")) {
26170
26952
  const body = text9.endsWith("\n") ? text9.slice(0, -1) : text9;
26171
- const lines2 = body.length === 0 ? [] : body.split("\n");
26172
- const totalLines = lines2.length;
26953
+ const lines = body.length === 0 ? [] : body.split("\n");
26954
+ const totalLines = lines.length;
26173
26955
  if (totalLines <= WINDOW_HEAD_LINES + WINDOW_TAIL_LINES && body.length <= WINDOW_HALF_CHARS * 2) {
26174
26956
  return { head: body, totalLines, totalBytes };
26175
26957
  }
26176
- const headLines = lines2.slice(0, WINDOW_HEAD_LINES);
26177
- const tailLines = totalLines > WINDOW_HEAD_LINES ? lines2.slice(Math.max(WINDOW_HEAD_LINES, totalLines - WINDOW_TAIL_LINES)) : [];
26958
+ const headLines = lines.slice(0, WINDOW_HEAD_LINES);
26959
+ const tailLines = totalLines > WINDOW_HEAD_LINES ? lines.slice(Math.max(WINDOW_HEAD_LINES, totalLines - WINDOW_TAIL_LINES)) : [];
26178
26960
  const head2 = clipHead(headLines.join("\n"), WINDOW_HALF_CHARS);
26179
26961
  const tail = clipTail(tailLines.join("\n"), WINDOW_HALF_CHARS);
26180
26962
  const omittedLines = totalLines - headLines.length - tailLines.length;
@@ -26211,15 +26993,15 @@ __name(looksBinary, "looksBinary");
26211
26993
  // ../sdk/dist/tools/builtins/read-render.js
26212
26994
  var DEFAULT_READ_LINES = 2e3;
26213
26995
  function renderNumberedRead(content, input) {
26214
- const lines2 = content.split("\n");
26215
- const { start, end } = resolveReadWindow(input, lines2.length);
26216
- const selected = lines2.slice(start, end);
26996
+ const lines = content.split("\n");
26997
+ const { start, end } = resolveReadWindow(input, lines.length);
26998
+ const selected = lines.slice(start, end);
26217
26999
  const numbered2 = selected.map((line, i) => `${start + i + 1} ${line}`).join("\n");
26218
27000
  return {
26219
- output: numbered2 + partialViewNotice(start, selected.length, lines2.length),
26220
- totalLines: lines2.length,
27001
+ output: numbered2 + partialViewNotice(start, selected.length, lines.length),
27002
+ totalLines: lines.length,
26221
27003
  returnedLines: selected.length,
26222
- partial: selected.length < lines2.length
27004
+ partial: selected.length < lines.length
26223
27005
  };
26224
27006
  }
26225
27007
  __name(renderNumberedRead, "renderNumberedRead");
@@ -26281,9 +27063,9 @@ function renderCappedRead(content, byteLength, input, options) {
26281
27063
  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}`
26282
27064
  };
26283
27065
  }
26284
- const lines2 = content.split("\n");
26285
- const { start, end } = resolveReadWindow(input, lines2.length);
26286
- const selected = lines2.slice(start, end);
27066
+ const lines = content.split("\n");
27067
+ const { start, end } = resolveReadWindow(input, lines.length);
27068
+ const selected = lines.slice(start, end);
26287
27069
  const selectedText = selected.join("\n");
26288
27070
  const selectedBytes = Buffer.byteLength(selectedText, "utf8");
26289
27071
  if (selectedBytes > maxTokens * SELECTED_BYTES_PER_TOKEN) {
@@ -26305,7 +27087,7 @@ function renderCappedRead(content, byteLength, input, options) {
26305
27087
  }
26306
27088
  return {
26307
27089
  ok: true,
26308
- rendered: trimFirstPage(selected, lines2.length, selectedText, tokens, maxTokens, options.path)
27090
+ rendered: trimFirstPage(selected, lines.length, selectedText, tokens, maxTokens, options.path)
26309
27091
  };
26310
27092
  }
26311
27093
  __name(renderCappedRead, "renderCappedRead");
@@ -26351,8 +27133,8 @@ function trimFirstPage(selected, totalLines, selectedText, tokens, maxTokens, pa
26351
27133
  };
26352
27134
  }
26353
27135
  __name(trimFirstPage, "trimFirstPage");
26354
- function numbered(lines2) {
26355
- return lines2.map((line, i) => `${i + 1} ${line}`).join("\n");
27136
+ function numbered(lines) {
27137
+ return lines.map((line, i) => `${i + 1} ${line}`).join("\n");
26356
27138
  }
26357
27139
  __name(numbered, "numbered");
26358
27140
 
@@ -26569,33 +27351,19 @@ import { dirname as dirname9 } from "node:path";
26569
27351
 
26570
27352
  // ../sdk/dist/tools/builtins/file-write-result.js
26571
27353
  import { createHash as createHash8 } from "node:crypto";
26572
- function lines(text9) {
26573
- if (text9 === "")
26574
- return [];
26575
- const result = text9.split("\n");
26576
- if (result.at(-1) === "")
26577
- result.pop();
26578
- return result;
27354
+ function previewSide(hunks2, changed) {
27355
+ return hunks2.flatMap((hunk) => hunk.lines).filter((row) => row.startsWith(" ") || row.startsWith(changed)).map((row) => `${row.slice(1)}
27356
+ `).join("");
26579
27357
  }
26580
- __name(lines, "lines");
27358
+ __name(previewSide, "previewSide");
26581
27359
  function fileWriteResult(path2, before, after, sandboxed = false) {
26582
27360
  const operation = before === null ? "write" : before === void 0 ? "create" : before === after ? "unchanged" : "replace";
26583
- const oldLines = lines(before ?? "");
26584
- const newLines = lines(after);
26585
- let start = 0;
26586
- let end = 0;
26587
- if (typeof before === "string") {
26588
- while (start < oldLines.length && start < newLines.length && oldLines[start] === newLines[start])
26589
- start++;
26590
- while (end < oldLines.length - start && end < newLines.length - start && oldLines[oldLines.length - end - 1] === newLines[newLines.length - end - 1])
26591
- end++;
26592
- }
26593
- const removed = oldLines.slice(start, oldLines.length - end);
26594
- const added = newLines.slice(start, newLines.length - end);
27361
+ const diff = lineDiff2(typeof before === "string" ? before : "", after);
27362
+ const known = before !== null;
26595
27363
  const bytes = Buffer.byteLength(after, "utf8");
26596
27364
  const label5 = operation === "create" ? "Created" : operation === "replace" ? "Updated" : operation === "unchanged" ? "Unchanged" : "Wrote";
26597
27365
  const newlineChanged = typeof before === "string" && before.endsWith("\n") !== after.endsWith("\n");
26598
- const summary2 = `${label5} ${path2}${before === null ? "" : ` (+${added.length} -${removed.length})`}${newlineChanged ? " \xB7 final newline changed" : ""}`;
27366
+ const summary2 = `${label5} ${path2}${before === null ? "" : ` (+${diff.added} -${diff.removed})`}${newlineChanged ? " \xB7 final newline changed" : ""}`;
26599
27367
  return {
26600
27368
  success: true,
26601
27369
  output: `${summary2} \xB7 ${bytes} bytes`,
@@ -26604,7 +27372,12 @@ function fileWriteResult(path2, before, after, sandboxed = false) {
26604
27372
  path: path2,
26605
27373
  operation: operation === "create" ? "created" : operation === "replace" ? "updated" : operation === "unchanged" ? "unchanged" : "wrote",
26606
27374
  bytes,
26607
- ...before === null ? {} : { added: added.length, removed: removed.length }
27375
+ ...known ? {
27376
+ added: diff.added,
27377
+ removed: diff.removed,
27378
+ ...diff.hunks.length > 0 ? { hunks: diff.hunks } : {},
27379
+ ...diff.truncated ? { hunksTruncated: true } : {}
27380
+ } : {}
26608
27381
  },
26609
27382
  data: {
26610
27383
  path: path2,
@@ -26614,15 +27387,13 @@ function fileWriteResult(path2, before, after, sandboxed = false) {
26614
27387
  operation,
26615
27388
  ...before === null ? {} : {
26616
27389
  preview: {
26617
- before: removed.length ? `${removed.join("\n")}
26618
- ` : "",
26619
- after: added.length ? `${added.join("\n")}
26620
- ` : ""
27390
+ before: previewSide(diff.hunks, "-"),
27391
+ after: previewSide(diff.hunks, "+")
26621
27392
  }
26622
27393
  },
26623
27394
  bytes,
26624
27395
  sha256: createHash8("sha256").update(after, "utf8").digest("hex"),
26625
- ...before === null ? {} : { added: added.length, removed: removed.length, newlineChanged }
27396
+ ...before === null ? {} : { added: diff.added, removed: diff.removed, newlineChanged }
26626
27397
  }
26627
27398
  }
26628
27399
  };
@@ -27092,24 +27863,24 @@ function observeRead(history, call2, claims, withBody, budget) {
27092
27863
  }
27093
27864
  __name(observeRead, "observeRead");
27094
27865
  function wholeFileRenderUnits(body, window2) {
27095
- const lines2 = countLines(body);
27096
- const { start, end } = resolveReadWindow(window2, lines2);
27097
- if (start !== 0 || end < lines2)
27866
+ const lines = countLines(body);
27867
+ const { start, end } = resolveReadWindow(window2, lines);
27868
+ if (start !== 0 || end < lines)
27098
27869
  return void 0;
27099
- return body.length + lines2 + lineNumberUnits(lines2);
27870
+ return body.length + lines + lineNumberUnits(lines);
27100
27871
  }
27101
27872
  __name(wholeFileRenderUnits, "wholeFileRenderUnits");
27102
27873
  function countLines(body) {
27103
- let lines2 = 1;
27874
+ let lines = 1;
27104
27875
  for (let at = body.indexOf("\n"); at !== -1; at = body.indexOf("\n", at + 1))
27105
- lines2++;
27106
- return lines2;
27876
+ lines++;
27877
+ return lines;
27107
27878
  }
27108
27879
  __name(countLines, "countLines");
27109
- function lineNumberUnits(lines2) {
27880
+ function lineNumberUnits(lines) {
27110
27881
  let units = 0;
27111
- for (let width = 1, first = 1; first <= lines2; width++, first *= 10)
27112
- units += (Math.min(lines2, first * 10 - 1) - first + 1) * width;
27882
+ for (let width = 1, first = 1; first <= lines; width++, first *= 10)
27883
+ units += (Math.min(lines, first * 10 - 1) - first + 1) * width;
27113
27884
  return units;
27114
27885
  }
27115
27886
  __name(lineNumberUnits, "lineNumberUnits");
@@ -28354,7 +29125,7 @@ function evaluateRule(rule, toolName, toolInput, toolDef, compiledPattern, nameS
28354
29125
  if (rule.decision === "deny" || rule.decision === "review") {
28355
29126
  if (compiledPattern.test(subject))
28356
29127
  return rule.decision;
28357
- if (segments.some((segment) => compiledPattern.test(segment)))
29128
+ if (segments.some((segment2) => compiledPattern.test(segment2)))
28358
29129
  return rule.decision;
28359
29130
  if (isUrl)
28360
29131
  return null;
@@ -28362,7 +29133,7 @@ function evaluateRule(rule, toolName, toolInput, toolDef, compiledPattern, nameS
28362
29133
  }
28363
29134
  if (opaque2)
28364
29135
  return null;
28365
- return segments.every((segment) => compiledPattern.test(segment)) ? "allow" : null;
29136
+ return segments.every((segment2) => compiledPattern.test(segment2)) ? "allow" : null;
28366
29137
  }
28367
29138
  case "allow_by_tier": {
28368
29139
  if (toolDef?.tier && rule.tiers.includes(toolDef.tier)) {
@@ -29472,51 +30243,51 @@ function renderPlan(plan) {
29472
30243
  }
29473
30244
  __name(renderPlan, "renderPlan");
29474
30245
  function renderFiles(files) {
29475
- const lines2 = [];
30246
+ const lines = [];
29476
30247
  for (const [, slot] of files) {
29477
- lines2.push(`- \`${slot.path}\``);
30248
+ lines.push(`- \`${slot.path}\``);
29478
30249
  for (const action of slot.actions) {
29479
30250
  if (action.type === "delete") {
29480
- lines2.push(" - deleted");
30251
+ lines.push(" - deleted");
29481
30252
  } else {
29482
30253
  const desc = "detail" in action ? action.detail : action.summary;
29483
- lines2.push(` - ${action.type}: ${desc ?? ""}`);
30254
+ lines.push(` - ${action.type}: ${desc ?? ""}`);
29484
30255
  }
29485
30256
  }
29486
30257
  }
29487
- return lines2.join("\n");
30258
+ return lines.join("\n");
29488
30259
  }
29489
30260
  __name(renderFiles, "renderFiles");
29490
30261
  function renderList(items, evictedCount = 0) {
29491
- const lines2 = items.map((item) => `- ${item}`);
30262
+ const lines = items.map((item) => `- ${item}`);
29492
30263
  if (evictedCount > 0) {
29493
30264
  const noun = evictedCount === 1 ? "entry" : "entries";
29494
- lines2.push(`- _(${evictedCount} ${noun} dropped to stay within the state budget)_`);
30265
+ lines.push(`- _(${evictedCount} ${noun} dropped to stay within the state budget)_`);
29495
30266
  }
29496
- return lines2.join("\n");
30267
+ return lines.join("\n");
29497
30268
  }
29498
30269
  __name(renderList, "renderList");
29499
30270
  function renderToolResults(results, evictedCount = 0) {
29500
- const lines2 = results.map((r) => `- **${r.tool}**: ${r.summary}`);
30271
+ const lines = results.map((r) => `- **${r.tool}**: ${r.summary}`);
29501
30272
  if (evictedCount > 0) {
29502
30273
  const noun = evictedCount === 1 ? "result" : "results";
29503
- lines2.push(`- _(${evictedCount} earlier tool ${noun} dropped to stay within the state budget)_`);
30274
+ lines.push(`- _(${evictedCount} earlier tool ${noun} dropped to stay within the state budget)_`);
29504
30275
  }
29505
- return lines2.join("\n");
30276
+ return lines.join("\n");
29506
30277
  }
29507
30278
  __name(renderToolResults, "renderToolResults");
29508
30279
  function renderPins(state) {
29509
30280
  const pins = state.pins ? [...state.pins.values()] : [];
29510
30281
  if (pins.length === 0)
29511
30282
  return null;
29512
- const lines2 = pins.map((p) => `- **${p.key}**: ${p.text} _(${p.source})_`);
30283
+ const lines = pins.map((p) => `- **${p.key}**: ${p.text} _(${p.source})_`);
29513
30284
  const dropped = state.evicted.pins ?? 0;
29514
30285
  if (dropped > 0) {
29515
- lines2.push(`- _(${dropped} older ${dropped === 1 ? "pin" : "pins"} dropped to stay within the pin budget)_`);
30286
+ lines.push(`- _(${dropped} older ${dropped === 1 ? "pin" : "pins"} dropped to stay within the pin budget)_`);
29516
30287
  }
29517
30288
  return `${SECTION_HEADERS.pins}
29518
30289
 
29519
- ${lines2.join("\n")}`;
30290
+ ${lines.join("\n")}`;
29520
30291
  }
29521
30292
  __name(renderPins, "renderPins");
29522
30293
  function serializeState(state) {
@@ -30868,24 +31639,23 @@ var TurnRecorder = class {
30868
31639
  const durable = next.filter((entry) => !entry.transient);
30869
31640
  const recordedOrder = new Map(this.#view.filter((entry) => entry.id).map((entry, index) => [entry.id, index]));
30870
31641
  const first = durable.findIndex((entry) => entry.id !== void 0);
30871
- let last = -1;
30872
- for (let i = durable.length - 1; i >= 0; i--) {
30873
- if (durable[i]?.id !== void 0) {
30874
- last = i;
30875
- break;
31642
+ let runEnd = first < 0 ? 0 : first + 1;
31643
+ if (first >= 0) {
31644
+ let prev = recordedOrder.get(durable[first]?.id) ?? -1;
31645
+ for (let i = first + 1; i < durable.length; i++) {
31646
+ const id3 = durable[i]?.id;
31647
+ if (id3 === void 0)
31648
+ break;
31649
+ const order = recordedOrder.get(id3) ?? -1;
31650
+ if (order <= prev)
31651
+ break;
31652
+ prev = order;
31653
+ runEnd = i + 1;
30876
31654
  }
30877
31655
  }
30878
- const middle = first < 0 ? [] : durable.slice(first, last + 1);
30879
- let ordered = middle.every((entry) => entry.id !== void 0);
30880
- for (let i = 1; ordered && i < middle.length; i++) {
30881
- const before = recordedOrder.get(middle[i - 1]?.id) ?? -1;
30882
- const after = recordedOrder.get(middle[i]?.id) ?? -1;
30883
- if (after <= before)
30884
- ordered = false;
30885
- }
30886
- const summaryEntries = !ordered ? durable : first < 0 ? durable : durable.slice(0, first);
30887
- const keptEntries = ordered ? middle : [];
30888
- const tailEntries = ordered && first >= 0 ? durable.slice(last + 1) : [];
31656
+ const summaryEntries = first < 0 ? [] : durable.slice(0, first);
31657
+ const keptEntries = first < 0 ? [] : durable.slice(first, runEnd);
31658
+ const tailEntries = durable.slice(first < 0 ? 0 : runEnd);
30889
31659
  for (const entry of summaryEntries) {
30890
31660
  entry.id = void 0;
30891
31661
  this.#ids.delete(entry.message);
@@ -30912,6 +31682,8 @@ var TurnRecorder = class {
30912
31682
  }).catch(() => void 0);
30913
31683
  for (const entry of tailEntries) {
30914
31684
  const message = entry.message;
31685
+ this.#ids.delete(message);
31686
+ this.#recorded.delete(message);
30915
31687
  const id3 = this.#idFor(message);
30916
31688
  entry.id = id3;
30917
31689
  void this.#enqueue(() => this.#append({
@@ -31361,7 +32133,7 @@ function buildAdvisoryTools(opts) {
31361
32133
  async execute() {
31362
32134
  const advisors = advisoryCtx.registry.listAll();
31363
32135
  const budget = advisoryCtx.getBudgetStatus();
31364
- const lines2 = advisors.map((a) => {
32136
+ const lines = advisors.map((a) => {
31365
32137
  const domains = a.domains && a.domains.length > 0 ? a.domains.join(", ") : "general";
31366
32138
  return `- ${a.id}: ${a.name} [domains: ${domains}]`;
31367
32139
  });
@@ -31369,7 +32141,7 @@ function buildAdvisoryTools(opts) {
31369
32141
  return {
31370
32142
  success: true,
31371
32143
  output: advisors.length === 0 ? "No advisors configured." : `${advisors.length} advisor(s) available:
31372
- ${lines2.join("\n")}
32144
+ ${lines.join("\n")}
31373
32145
 
31374
32146
  ${budgetLine}`,
31375
32147
  data: {
@@ -33549,9 +34321,20 @@ var CompletionInbox = class {
33549
34321
  * `log` is optional and unresolved until it is actually needed (the
33550
34322
  * eviction-warning path in `hold()`), same reason as `LocalTaskScheduler`.
33551
34323
  */
33552
- constructor(log) {
34324
+ constructor(log, options = {}) {
33553
34325
  this.log = log;
34326
+ this.holdsTurnOpen = options.holdsTurnOpen !== false;
33554
34327
  }
34328
+ /**
34329
+ * Whether a turn about to end waits here for the tasks still running.
34330
+ *
34331
+ * `true` (the default) is the original contract: the turn parks at its settle
34332
+ * point until the tasks it launched report back, so their results enter the
34333
+ * same turn. `false` lets the turn end with them still running; the host owns
34334
+ * their completion from then on (it keeps them alive and wakes the model when
34335
+ * they end). Completions that have already arrived are delivered either way.
34336
+ */
34337
+ holdsTurnOpen;
33555
34338
  /**
33556
34339
  * Start listening.
33557
34340
  *
@@ -33727,6 +34510,14 @@ var CompletionInbox = class {
33727
34510
  get hasPendingWork() {
33728
34511
  return this.unheard.size > 0 || this.outstanding.size > 0;
33729
34512
  }
34513
+ /**
34514
+ * Whether the turn has a reason to wait at its settle point: anything
34515
+ * pending when it {@link holdsTurnOpen}, else only a completion already in
34516
+ * hand (waiting for its persistence gate).
34517
+ */
34518
+ get holdsTurn() {
34519
+ return this.holdsTurnOpen ? this.hasPendingWork : this.unheard.size > 0;
34520
+ }
33730
34521
  /**
33731
34522
  * Wait for the next completion, deadline or abort, whichever comes first.
33732
34523
  * Aborting releases only this waiter; work and undelivered results remain owned.
@@ -33955,7 +34746,7 @@ ${partial.content}`;
33955
34746
  attributes: { agent: handle.agentId, task: handle.taskId },
33956
34747
  provenance: `This is the output of the delegated agent "${handle.agentId}", not this agent's own work.`
33957
34748
  }, neutralizeNotificationDelimiter(shown)) : "(the task produced no output)";
33958
- const lines2 = [
34749
+ const lines = [
33959
34750
  `task_id: ${handle.taskId}`,
33960
34751
  `agent: ${handle.agentId}`,
33961
34752
  `state: ${handle.state}`,
@@ -33976,7 +34767,7 @@ ${partial.content}`;
33976
34767
  ...overLimit ? [`\u2026 truncated. Call wait_for_task with task_id "${handle.taskId}" for the full output.`] : []
33977
34768
  ];
33978
34769
  return `<task-notification>
33979
- ${lines2.join("\n")}
34770
+ ${lines.join("\n")}
33980
34771
  </task-notification>`;
33981
34772
  });
33982
34773
  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.`;
@@ -34613,7 +35404,7 @@ function awaitedJobGraceMs(remainingBeforeFinalizeMs) {
34613
35404
  }
34614
35405
  __name(awaitedJobGraceMs, "awaitedJobGraceMs");
34615
35406
  async function* holdForOutstandingWork(ctx, iterationNum, hasToolCalls2, deliverInbound) {
34616
- const inbox = ctx.completionInbox?.hasPendingWork ? ctx.completionInbox : void 0;
35407
+ const inbox = ctx.completionInbox?.holdsTurn ? ctx.completionInbox : void 0;
34617
35408
  const jobs = ctx.awaitedJobs?.hasPendingWork ? ctx.awaitedJobs : void 0;
34618
35409
  if (!inbox && !jobs)
34619
35410
  return false;
@@ -34738,7 +35529,12 @@ function settleOutstandingWork(ctx) {
34738
35529
  __name(settleOutstandingWork, "settleOutstandingWork");
34739
35530
  function recordAbandonedWork(ctx) {
34740
35531
  const abandoned = ctx.completionInbox?.outstandingTaskIds ?? [];
34741
- if (abandoned.length > 0) {
35532
+ if (abandoned.length > 0 && ctx.completionInbox?.holdsTurnOpen === false) {
35533
+ ctx.log.info("Turn ended with delegated work left running in the background", {
35534
+ [NAMZU.TURN_ID]: ctx.recorder.turnId,
35535
+ "namzu.runtime.tasks": abandoned
35536
+ });
35537
+ } else if (abandoned.length > 0) {
34742
35538
  ctx.log.warn("Turn ended with delegated work still running", {
34743
35539
  [NAMZU.TURN_ID]: ctx.recorder.turnId,
34744
35540
  "namzu.runtime.tasks": abandoned
@@ -34866,7 +35662,7 @@ function splitIdentifier(raw) {
34866
35662
  return parts.length > 1 ? parts : [];
34867
35663
  }
34868
35664
  __name(splitIdentifier, "splitIdentifier");
34869
- function tokenize(text9) {
35665
+ function tokenize2(text9) {
34870
35666
  const out = [];
34871
35667
  for (const match2 of text9.matchAll(WORD)) {
34872
35668
  const raw = match2[0].replace(/^[.\-/\\:]+|[.\-/\\:]+$/g, "");
@@ -34877,11 +35673,11 @@ function tokenize(text9) {
34877
35673
  out.push(whole);
34878
35674
  const segments = raw.split(/[/\\.:\-]+/).filter((s) => s.length > 0);
34879
35675
  if (segments.length > 1) {
34880
- for (const segment of segments) {
34881
- const lower = segment.toLowerCase();
35676
+ for (const segment2 of segments) {
35677
+ const lower = segment2.toLowerCase();
34882
35678
  if (!STOP_WORDS.has(lower) && lower !== whole)
34883
35679
  out.push(lower);
34884
- for (const part2 of splitIdentifier(segment))
35680
+ for (const part2 of splitIdentifier(segment2))
34885
35681
  out.push(part2.toLowerCase());
34886
35682
  }
34887
35683
  } else {
@@ -34894,7 +35690,7 @@ function tokenize(text9) {
34894
35690
  }
34895
35691
  return out;
34896
35692
  }
34897
- __name(tokenize, "tokenize");
35693
+ __name(tokenize2, "tokenize");
34898
35694
  function termFrequencies(tokens) {
34899
35695
  const tf = /* @__PURE__ */ new Map();
34900
35696
  for (const token of tokens)
@@ -34907,7 +35703,7 @@ __name(termFrequencies, "termFrequencies");
34907
35703
  var K1 = 1.2;
34908
35704
  var B = 0.75;
34909
35705
  function indexDocument(text9) {
34910
- const tokens = tokenize(text9);
35706
+ const tokens = tokenize2(text9);
34911
35707
  return { tf: termFrequencies(tokens), length: tokens.length };
34912
35708
  }
34913
35709
  __name(indexDocument, "indexDocument");
@@ -35045,10 +35841,10 @@ function scoreMessages(messages, options) {
35045
35841
  const n = messages.length;
35046
35842
  const texts = messages.map(messageText);
35047
35843
  const richContent = messages.map(hasRichContent);
35048
- const tokenLists = texts.map(tokenize);
35844
+ const tokenLists = texts.map(tokenize2);
35049
35845
  const documents = texts.map(indexDocument);
35050
35846
  const index = buildIndex(documents);
35051
- const goalTokens = tokenize(options.goal);
35847
+ const goalTokens = tokenize2(options.goal);
35052
35848
  const rawRelevance = documents.map((doc) => bm25Score(index, doc, goalTokens));
35053
35849
  const maxRelevance = Math.max(0, ...rawRelevance.filter((_, i) => {
35054
35850
  const m = messages[i];
@@ -36409,6 +37205,14 @@ async function runCompactionCheckInner(ctx, pass, options) {
36409
37205
  });
36410
37206
  }
36411
37207
  }
37208
+ await ctx.emitEvent?.({
37209
+ type: "compaction_started",
37210
+ turnId: ctx.recorder.turnId,
37211
+ iteration: ctx.recorder.currentIteration,
37212
+ reason: pass.reason,
37213
+ tokensBefore: estimatedTokens,
37214
+ contextWindowTokens: budget
37215
+ });
36412
37216
  const reducer = ctx.contextReducer ?? (config.strategy === "sliding-window" ? createSlidingWindowReducer() : void 0);
36413
37217
  if (reducer) {
36414
37218
  if (!options?.force && await stopOnRefill(ctx))
@@ -46152,35 +46956,35 @@ __name(assertTurnMayStart, "assertTurnMayStart");
46152
46956
  // ../sdk/dist/runtime/query/prompt.js
46153
46957
  function buildEnvContext(workingDirectory, config) {
46154
46958
  const { runtimeContext, tools, allowedTools } = config;
46155
- const lines2 = [
46959
+ const lines = [
46156
46960
  `<env>
46157
46961
  Working directory: ${workingDirectory}
46158
46962
  ${config.sandboxed ? "Host platform" : "Platform"}: ${process.platform}`
46159
46963
  ];
46160
46964
  if (runtimeContext?.label) {
46161
- lines2.push(`Runtime: ${runtimeContext.label}`);
46965
+ lines.push(`Runtime: ${runtimeContext.label}`);
46162
46966
  }
46163
46967
  if (runtimeContext?.outputDirectory) {
46164
- lines2.push(`Output directory: ${runtimeContext.outputDirectory}`);
46968
+ lines.push(`Output directory: ${runtimeContext.outputDirectory}`);
46165
46969
  }
46166
46970
  if (runtimeContext?.outputFileMarker) {
46167
- lines2.push(`Output file marker: ${runtimeContext.outputFileMarker}`);
46971
+ lines.push(`Output file marker: ${runtimeContext.outputFileMarker}`);
46168
46972
  }
46169
46973
  if (runtimeContext?.notes?.length) {
46170
- lines2.push("Runtime notes:");
46974
+ lines.push("Runtime notes:");
46171
46975
  for (const note of runtimeContext.notes) {
46172
- lines2.push(`- ${note}`);
46976
+ lines.push(`- ${note}`);
46173
46977
  }
46174
46978
  }
46175
- lines2.push(`</env>
46979
+ lines.push(`</env>
46176
46980
 
46177
46981
  Resolve relative paths against the working directory above; use supplied absolute paths as given.`);
46178
46982
  if (hasFilesystemTools(tools, allowedTools)) {
46179
- lines2.push("When file contents are needed, read known file paths directly. Discover unknown paths with available filesystem tools using targeted directories and patterns.");
46983
+ lines.push("When file contents are needed, read known file paths directly. Discover unknown paths with available filesystem tools using targeted directories and patterns.");
46180
46984
  const canGlob = tools.has("glob") && (!allowedTools || allowedTools.includes("glob")) && tools.availability("glob") === "active";
46181
- 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.");
46985
+ 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.");
46182
46986
  }
46183
- return lines2.join("\n");
46987
+ return lines.join("\n");
46184
46988
  }
46185
46989
  __name(buildEnvContext, "buildEnvContext");
46186
46990
  function hasFilesystemTools(tools, allowedTools) {
@@ -46198,18 +47002,18 @@ function hasFilesystemTools(tools, allowedTools) {
46198
47002
  }
46199
47003
  __name(hasFilesystemTools, "hasFilesystemTools");
46200
47004
  function buildShellContext(config) {
46201
- const lines2 = [];
47005
+ const lines = [];
46202
47006
  for (const name2 of config.allowedTools ?? config.tools.listNames()) {
46203
47007
  const tool = config.tools.get(name2);
46204
47008
  if (!tool?.commandArgument || !tool.commandDialect || config.tools.availability(name2) !== "active")
46205
47009
  continue;
46206
47010
  const dialect = tool.commandDialect({ sandboxed: config.sandboxed === true });
46207
47011
  const gitBash = !config.sandboxed && dialect === "bash" && isWindowsBash();
46208
- lines2.push(`Execution shell for ${name2}: ${dialect}${config.sandboxed ? " (sandbox guest)" : gitBash ? " (Git Bash on Windows, host)" : " (host)"}.`);
47012
+ lines.push(`Execution shell for ${name2}: ${dialect}${config.sandboxed ? " (sandbox guest)" : gitBash ? " (Git Bash on Windows, host)" : " (host)"}.`);
46209
47013
  if (dialect === "cmd")
46210
- 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.");
47014
+ 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.");
46211
47015
  }
46212
- return lines2.length > 0 ? lines2.join("\n") : void 0;
47016
+ return lines.length > 0 ? lines.join("\n") : void 0;
46213
47017
  }
46214
47018
  __name(buildShellContext, "buildShellContext");
46215
47019
  var PromptBuilder = class {
@@ -47124,11 +47928,11 @@ function normalizeLine(line) {
47124
47928
  return line.replace(/^\s*\d+[\s:.|)]+/, "").replace(/\d+/g, "N");
47125
47929
  }
47126
47930
  __name(normalizeLine, "normalizeLine");
47127
- function collapseRepeated(lines2) {
47931
+ function collapseRepeated(lines) {
47128
47932
  const result = [];
47129
47933
  let prevNorm = "";
47130
47934
  let repeatCount = 0;
47131
- for (const line of lines2) {
47935
+ for (const line of lines) {
47132
47936
  const norm = normalizeLine(line);
47133
47937
  if (norm === prevNorm && norm.trim().length > 0) {
47134
47938
  repeatCount++;
@@ -47152,14 +47956,14 @@ function compressShellOutputFull(raw, options) {
47152
47956
  const minReduction = options?.minReductionPercent ?? DEFAULT_MIN_REDUCTION;
47153
47957
  const maxStackFrames = options?.maxStackFrames ?? DEFAULT_MAX_STACK_FRAMES;
47154
47958
  const maxPassLines = options?.maxPassLines ?? DEFAULT_MAX_PASS_LINES;
47155
- const lines2 = raw.split("\n");
47156
- if (lines2.length < minLines) {
47959
+ const lines = raw.split("\n");
47960
+ if (lines.length < minLines) {
47157
47961
  return { text: raw, original: null };
47158
47962
  }
47159
47963
  const pass1 = [];
47160
47964
  let stackCount = 0;
47161
47965
  let passCount = 0;
47162
- for (const line of lines2) {
47966
+ for (const line of lines) {
47163
47967
  if (NOISE_RE.test(line)) {
47164
47968
  continue;
47165
47969
  }
@@ -53614,7 +54418,7 @@ function createMemoryRecallStep(options) {
53614
54418
  const terms2 = [
53615
54419
  .../* @__PURE__ */ new Set([
53616
54420
  ...anchors,
53617
- ...tokenize(options.identifierGrounding === true ? query2.slice(-4e3).normalize("NFKC") : query2.slice(-4e3))
54421
+ ...tokenize2(options.identifierGrounding === true ? query2.slice(-4e3).normalize("NFKC") : query2.slice(-4e3))
53618
54422
  ])
53619
54423
  ].filter((term) => term.length > 1 && !GLUE.has(term)).slice(0, 32);
53620
54424
  if (terms2.length === 0 || charBudget <= HEADER.length)
@@ -55587,13 +56391,13 @@ function parseValue(raw, file, line) {
55587
56391
  __name(parseValue, "parseValue");
55588
56392
  function parseMemoryFile(raw, file) {
55589
56393
  const text9 = raw.startsWith("\uFEFF") ? raw.slice(1) : raw;
55590
- const lines2 = text9.split("\n");
55591
- if (!FENCE.test((lines2[0] ?? "").replace(/\r$/, ""))) {
56394
+ const lines = text9.split("\n");
56395
+ if (!FENCE.test((lines[0] ?? "").replace(/\r$/, ""))) {
55592
56396
  throw new MemoryFileFormatError(file, "a memory file must start with a --- frontmatter fence", 1);
55593
56397
  }
55594
56398
  let closing = -1;
55595
- for (let i = 1; i < lines2.length; i++) {
55596
- if (FENCE.test((lines2[i] ?? "").replace(/\r$/, ""))) {
56399
+ for (let i = 1; i < lines.length; i++) {
56400
+ if (FENCE.test((lines[i] ?? "").replace(/\r$/, ""))) {
55597
56401
  closing = i;
55598
56402
  break;
55599
56403
  }
@@ -55611,7 +56415,7 @@ function parseMemoryFile(raw, file) {
55611
56415
  }, "closeList");
55612
56416
  for (let i = 1; i < closing; i++) {
55613
56417
  const lineNumber = i + 1;
55614
- const line = (lines2[i] ?? "").replace(/\r$/, "");
56418
+ const line = (lines[i] ?? "").replace(/\r$/, "");
55615
56419
  if (!line.trim() || line.trimStart().startsWith("#"))
55616
56420
  continue;
55617
56421
  const item = ITEM_LINE.exec(line);
@@ -55645,7 +56449,7 @@ function parseMemoryFile(raw, file) {
55645
56449
  values.set(typedKey, parseValue(rawValue, file, lineNumber));
55646
56450
  }
55647
56451
  closeList();
55648
- let body = lines2.slice(closing + 1).join("\n");
56452
+ let body = lines.slice(closing + 1).join("\n");
55649
56453
  body = body.replace(/^\r?\n/, "").replace(/\r?\n$/, "");
55650
56454
  return { values, body };
55651
56455
  }
@@ -55663,9 +56467,9 @@ function formatValue(value) {
55663
56467
  }
55664
56468
  __name(formatValue, "formatValue");
55665
56469
  function formatMemoryFile(fields2, body) {
55666
- const lines2 = ["---"];
56470
+ const lines = ["---"];
55667
56471
  const put = /* @__PURE__ */ __name((key5, value) => {
55668
- lines2.push(`${key5}: ${formatValue(value)}`);
56472
+ lines.push(`${key5}: ${formatValue(value)}`);
55669
56473
  }, "put");
55670
56474
  put("name", fields2.name);
55671
56475
  put("description", fields2.description);
@@ -55674,7 +56478,7 @@ function formatMemoryFile(fields2, body) {
55674
56478
  put("createdAt", new Date(fields2.createdAt).toISOString());
55675
56479
  put("updatedAt", new Date(fields2.updatedAt).toISOString());
55676
56480
  if (fields2.tags.length > 0)
55677
- lines2.push(`tags: ${JSON.stringify(fields2.tags)}`);
56481
+ lines.push(`tags: ${JSON.stringify(fields2.tags)}`);
55678
56482
  put("id", fields2.id);
55679
56483
  if (fields2.title !== fields2.name)
55680
56484
  put("title", fields2.title);
@@ -55683,9 +56487,9 @@ function formatMemoryFile(fields2, body) {
55683
56487
  if (fields2.format !== "markdown")
55684
56488
  put("format", fields2.format);
55685
56489
  if (fields2.metadata !== void 0)
55686
- lines2.push(`metadata: ${JSON.stringify(fields2.metadata)}`);
55687
- lines2.push("---", "", body);
55688
- return `${lines2.join("\n")}${body.endsWith("\r") ? "\r\n" : "\n"}`;
56490
+ lines.push(`metadata: ${JSON.stringify(fields2.metadata)}`);
56491
+ lines.push("---", "", body);
56492
+ return `${lines.join("\n")}${body.endsWith("\r") ? "\r\n" : "\n"}`;
55689
56493
  }
55690
56494
  __name(formatMemoryFile, "formatMemoryFile");
55691
56495
 
@@ -56969,8 +57773,8 @@ var DiskMessageFeedbackStore = class {
56969
57773
  }
56970
57774
  ids.set(messageId4, messageId4);
56971
57775
  }
56972
- for (const segment of await records2.scanNames(this.revisionsDir(sessionId5), "")) {
56973
- const decoded = decodeRevisionFileSegment(segment);
57776
+ for (const segment2 of await records2.scanNames(this.revisionsDir(sessionId5), "")) {
57777
+ const decoded = decodeRevisionFileSegment(segment2);
56974
57778
  if (decoded === null)
56975
57779
  continue;
56976
57780
  const messageId4 = asMessageId(decoded);
@@ -60055,9 +60859,9 @@ var StdioTransport = class {
60055
60859
  return this.connected;
60056
60860
  }
60057
60861
  processBuffer() {
60058
- const lines2 = this.buffer.split("\n");
60059
- this.buffer = lines2.pop() ?? "";
60060
- for (const line of lines2) {
60862
+ const lines = this.buffer.split("\n");
60863
+ this.buffer = lines.pop() ?? "";
60864
+ for (const line of lines) {
60061
60865
  const trimmed = line.trim();
60062
60866
  if (!trimmed)
60063
60867
  continue;
@@ -60806,11 +61610,11 @@ function parseSseMessages(raw) {
60806
61610
  const messages = [];
60807
61611
  let lastEventId;
60808
61612
  for (const event of events) {
60809
- const lines2 = event.split("\n");
60810
- const idLines = lines2.filter((line) => line.startsWith("id:")).map((line) => line.slice("id:".length).trim());
61613
+ const lines = event.split("\n");
61614
+ const idLines = lines.filter((line) => line.startsWith("id:")).map((line) => line.slice("id:".length).trim());
60811
61615
  if (idLines.length > 0)
60812
61616
  lastEventId = idLines.at(-1);
60813
- const dataLines = lines2.filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trimStart());
61617
+ const dataLines = lines.filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trimStart());
60814
61618
  if (dataLines.length === 0)
60815
61619
  continue;
60816
61620
  const data = dataLines.join("\n").trim();
@@ -61253,7 +62057,7 @@ async function resolveMcpEra(input) {
61253
62057
  __name(resolveMcpEra, "resolveMcpEra");
61254
62058
 
61255
62059
  // ../sdk/dist/version.js
61256
- var VERSION2 = "52.6.0";
62060
+ var VERSION2 = "53.0.0";
61257
62061
 
61258
62062
  // ../sdk/dist/connector/mcp/client.js
61259
62063
  var MAX_LIST_PAGES = 100;
@@ -62843,18 +63647,18 @@ var MCPToolDiscovery = class {
62843
63647
 
62844
63648
  // ../sdk/dist/connector/mcp/prompt-adapter.js
62845
63649
  function renderPromptMessages(serverName, promptName, messages, description) {
62846
- const lines2 = [];
63650
+ const lines = [];
62847
63651
  if (description)
62848
- lines2.push(description, "");
63652
+ lines.push(description, "");
62849
63653
  for (const message of messages) {
62850
63654
  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}]`;
62851
- lines2.push(`[${message.role}] ${body}`, "");
63655
+ lines.push(`[${message.role}] ${body}`, "");
62852
63656
  }
62853
63657
  return wrapUntrusted({
62854
63658
  kind: "mcp-prompt",
62855
63659
  attributes: { server: serverName, name: promptName },
62856
63660
  provenance: "This is content the named server composed, not this agent."
62857
- }, lines2.join("\n").trimEnd());
63661
+ }, lines.join("\n").trimEnd());
62858
63662
  }
62859
63663
  __name(renderPromptMessages, "renderPromptMessages");
62860
63664
  function argumentSchema(prompt) {
@@ -64138,7 +64942,7 @@ function derivedUncertainty(report) {
64138
64942
  }
64139
64943
  __name(derivedUncertainty, "derivedUncertainty");
64140
64944
  function formatReport(report) {
64141
- const lines2 = [
64945
+ const lines = [
64142
64946
  `${report.name}: ${report.passed}/${report.cases.length} passed (mean ${report.mean.toFixed(2)}) in ${report.durationMs}ms`,
64143
64947
  // On its own line and always printed, including when the interval is
64144
64948
  // undefined. A mean printed alone is the thing that has been
@@ -64150,41 +64954,41 @@ function formatReport(report) {
64150
64954
  ""
64151
64955
  ];
64152
64956
  if (report.inconclusive > 0) {
64153
- lines2.push(` ${report.inconclusive} case${report.inconclusive === 1 ? "" : "s"} could not be judged \u2014 the numbers below cover the rest`, "");
64957
+ lines.push(` ${report.inconclusive} case${report.inconclusive === 1 ? "" : "s"} could not be judged \u2014 the numbers below cover the rest`, "");
64154
64958
  }
64155
64959
  for (const [name2, mean] of Object.entries(report.byScorer)) {
64156
- lines2.push(` ${name2}: ${mean.toFixed(2)}`);
64960
+ lines.push(` ${name2}: ${mean.toFixed(2)}`);
64157
64961
  }
64158
64962
  const failures = report.cases.filter((c) => c.status === "failed");
64159
64963
  if (failures.length > 0) {
64160
- lines2.push("", "Failures:");
64964
+ lines.push("", "Failures:");
64161
64965
  for (const failure2 of failures) {
64162
- lines2.push(` \u2717 ${failure2.case} (${failure2.mean.toFixed(2)})`);
64966
+ lines.push(` \u2717 ${failure2.case} (${failure2.mean.toFixed(2)})`);
64163
64967
  if (failure2.failedGates && failure2.failedGates.length > 0) {
64164
- lines2.push(` gate missed: ${failure2.failedGates.join(", ")}`);
64968
+ lines.push(` gate missed: ${failure2.failedGates.join(", ")}`);
64165
64969
  }
64166
64970
  for (const [name2, score] of Object.entries(failure2.scores)) {
64167
64971
  if (score.unavailable === true) {
64168
- lines2.push(` ${name2}: not judged \u2014 ${score.reason}`);
64972
+ lines.push(` ${name2}: not judged \u2014 ${score.reason}`);
64169
64973
  } else if (score.score < 1) {
64170
- lines2.push(` ${name2}: ${score.reason}`);
64974
+ lines.push(` ${name2}: ${score.reason}`);
64171
64975
  }
64172
64976
  }
64173
64977
  if (failure2.turn.error)
64174
- lines2.push(` error: ${failure2.turn.error}`);
64978
+ lines.push(` error: ${failure2.turn.error}`);
64175
64979
  }
64176
64980
  }
64177
64981
  const unjudged = report.cases.filter((c) => c.status === "inconclusive");
64178
64982
  if (unjudged.length > 0) {
64179
- lines2.push("", "Not judged:");
64983
+ lines.push("", "Not judged:");
64180
64984
  for (const item of unjudged) {
64181
- lines2.push(` ? ${item.case}`);
64985
+ lines.push(` ? ${item.case}`);
64182
64986
  for (const [name2, score] of Object.entries(item.scores)) {
64183
- lines2.push(` ${name2}: ${score.reason}`);
64987
+ lines.push(` ${name2}: ${score.reason}`);
64184
64988
  }
64185
64989
  }
64186
64990
  }
64187
- return lines2.join("\n");
64991
+ return lines.join("\n");
64188
64992
  }
64189
64993
  __name(formatReport, "formatReport");
64190
64994
 
@@ -64427,8 +65231,6 @@ var PLAN_MODE_DOCTRINE = `## Plan mode
64427
65231
  You are in plan mode. Read, search and think; do not change anything. \`read\`, \`grep\`, \`glob\` and the other read-only tools work as usual, and you may keep a task list. Any \`edit\`, \`write\` or shell command that changes state will be refused, so do not attempt one.
64428
65232
 
64429
65233
  When you have understood the task, reply with the plan: what you would change, in which files, in what order, and what you would verify. Be concrete \u2014 name files and functions \u2014 and short enough to read in one screen. Then stop and wait; the user will leave plan mode to have the plan carried out, and that switch is their approval.`;
64430
- var CODING_AGENT_HYPERMODE_DOCTRINE = `### Hypermode
64431
- This session has hypermode on: treat delegation through \`Agent\` as the default for substantive work, not the exception. Before doing multi-step work yourself, ask whether an independent piece of it \u2014 a lookup, a draft, a check \u2014 could run as its own delegation, and prefer delegating it when the answer is yes. This changes only how eagerly you reach for \`Agent\` on work you would otherwise do inline; it does not mount a roster or start any delegation by itself. Agents in the same phase are launched in the same response, each with \`run_in_background: true\` when you mean to wait for them together; a phase is never started one agent at a time.`;
64432
65234
 
64433
65235
  // ../sdk/dist/manager/resident/learning.js
64434
65236
  import { createHash as createHash23 } from "node:crypto";
@@ -68979,8 +69781,8 @@ var WorkerCodeRuntime = class {
68979
69781
  calls
68980
69782
  };
68981
69783
  }
68982
- const appendOutput = /* @__PURE__ */ __name((lines2) => {
68983
- for (const line of lines2) {
69784
+ const appendOutput = /* @__PURE__ */ __name((lines) => {
69785
+ for (const line of lines) {
68984
69786
  if (truncated)
68985
69787
  return;
68986
69788
  const next = printCount === 0 ? line : `${output}
@@ -69660,6 +70462,15 @@ var PRELUDE_SOURCE = String.raw`(function (config) {
69660
70462
  if (t === 'object') return typeof value.then === 'function' ? 'a promise' : 'an object';
69661
70463
  return 'a ' + t;
69662
70464
  }
70465
+ function overBudget() {
70466
+ return config.tokenLimit !== null && config.tokenLimit > 0 && spent.tokensUsed >= config.tokenLimit;
70467
+ }
70468
+ function budgetError() {
70469
+ var e = new Error('Workflow token budget exceeded (' + spent.tokensUsed.toLocaleString('en-US') + ' / ' + config.tokenLimit.toLocaleString('en-US') + ' output tokens). Stopping further agent() calls. Agents already running will finish and their results are kept.');
70470
+ e.name = 'WorkflowBudgetExceededError';
70471
+ return e;
70472
+ }
70473
+ function isBudgetError(e) { return !!e && e.name === 'WorkflowBudgetExceededError'; }
69663
70474
  async function agent(prompt, opts) {
69664
70475
  if (typeof prompt !== 'string' || prompt.length === 0) {
69665
70476
  throw new TypeError('agent(prompt, options?): the prompt must be a non-empty string, got ' + kind(prompt));
@@ -69668,6 +70479,7 @@ var PRELUDE_SOURCE = String.raw`(function (config) {
69668
70479
  if (typeof o !== 'object' || Array.isArray(o)) {
69669
70480
  throw new TypeError('agent(prompt, options?): options must be an object, got ' + kind(o));
69670
70481
  }
70482
+ if (overBudget()) throw budgetError();
69671
70483
  var request = { prompt: prompt, cursor: cursor };
69672
70484
  if (o.label != null) request.label = clean(o.label, 120);
69673
70485
  if (o.phase != null) request.phase = clean(o.phase, 120);
@@ -69688,7 +70500,16 @@ var PRELUDE_SOURCE = String.raw`(function (config) {
69688
70500
  throw new TypeError('parallel(thunks): item ' + (p + 1) + ' must be a function (wrap the work as () => agent(...)), got ' + kind(thunks[p]));
69689
70501
  }
69690
70502
  }
69691
- return Promise.all(thunks.map(function (t) { return t(); }));
70503
+ var dropped = 0;
70504
+ var results = await Promise.all(thunks.map(function (t, n) {
70505
+ return Promise.resolve().then(t).catch(function (e) {
70506
+ if (isBudgetError(e)) { dropped++; return null; }
70507
+ log('Step ' + (n + 1) + ' stopped: ' + clean(e && e.message ? e.message : e, 300));
70508
+ return null;
70509
+ });
70510
+ }));
70511
+ if (dropped > 0) log('parallel: ' + dropped + (dropped === 1 ? ' item' : ' items') + ' dropped because the token budget is spent.');
70512
+ return results;
69692
70513
  }
69693
70514
  async function pipeline(items) {
69694
70515
  if (!Array.isArray(items)) {
@@ -69700,16 +70521,31 @@ var PRELUDE_SOURCE = String.raw`(function (config) {
69700
70521
  throw new TypeError('pipeline(items, ...stages): stage ' + (s + 1) + ' must be a function, got ' + kind(stages[s]));
69701
70522
  }
69702
70523
  }
69703
- return Promise.all(items.map(async function (item, index) {
70524
+ if (items.length > 0 && overBudget()) throw budgetError();
70525
+ var dropped = 0;
70526
+ var results = await Promise.all(items.map(async function (item, index) {
69704
70527
  var value = item;
69705
70528
  for (var i = 0; i < stages.length; i++) {
69706
- value = await stages[i](value, index, item);
70529
+ try {
70530
+ value = await stages[i](value, item, index);
70531
+ } catch (e) {
70532
+ if (isBudgetError(e)) { dropped++; return null; }
70533
+ log('Item ' + (index + 1) + ' stopped at step ' + (i + 1) + ': ' + clean(e && e.message ? e.message : e, 300));
70534
+ return null;
70535
+ }
69707
70536
  if (value === null || value === undefined) return null;
69708
70537
  }
69709
70538
  return value;
69710
70539
  }));
70540
+ if (dropped > 0) log('pipeline: ' + dropped + (dropped === 1 ? ' item' : ' items') + ' dropped because the token budget is spent.');
70541
+ return results;
69711
70542
  }
69712
70543
  var budget = Object.freeze({
70544
+ get total() { return config.tokenLimit; },
70545
+ spent: function () { return spent.tokensUsed; },
70546
+ remaining: function () {
70547
+ return config.tokenLimit === null ? Infinity : Math.max(0, config.tokenLimit - spent.tokensUsed);
70548
+ },
69713
70549
  get tokensUsed() { return spent.tokensUsed; },
69714
70550
  get tokenLimit() { return config.tokenLimit === null ? undefined : config.tokenLimit; },
69715
70551
  });
@@ -69888,6 +70724,11 @@ var AGENT_CALL_KEYS = /* @__PURE__ */ new Set([
69888
70724
  "model",
69889
70725
  "effort"
69890
70726
  ]);
70727
+ function defaultAgentLabel(prompt, index) {
70728
+ const label5 = prompt.slice(0, 60).replace(/\s+/g, " ").trim();
70729
+ return label5.length > 0 ? label5 : `Agent ${index}`;
70730
+ }
70731
+ __name(defaultAgentLabel, "defaultAgentLabel");
69891
70732
  function integer4(name2, value, min, max) {
69892
70733
  if (!Number.isSafeInteger(value) || value < min || value > max) {
69893
70734
  throw new RangeError(`${name2} must be an integer between ${min} and ${max}.`);
@@ -69896,10 +70737,10 @@ function integer4(name2, value, min, max) {
69896
70737
  }
69897
70738
  __name(integer4, "integer");
69898
70739
  function resolveWorkflowLimits(limits = {}) {
69899
- const defaultConcurrency = Math.min(8, Math.max(1, cpus().length - 2));
70740
+ const defaultConcurrency = Math.min(16, Math.max(2, cpus().length - 2));
69900
70741
  return {
69901
70742
  maxConcurrency: integer4("maxConcurrency", limits.maxConcurrency ?? defaultConcurrency, 1, 16),
69902
- maxAgents: integer4("maxAgents", limits.maxAgents ?? 200, 1, 1e3),
70743
+ maxAgents: integer4("maxAgents", limits.maxAgents ?? 1e3, 1, 1e3),
69903
70744
  maxSourceBytes: integer4("maxSourceBytes", limits.maxSourceBytes ?? 256 * 1024, 1, 4 * 1024 * 1024),
69904
70745
  memoryLimitBytes: integer4("memoryLimitBytes", limits.memoryLimitBytes ?? 64 * 1024 * 1024, 16 * 1024 * 1024, 256 * 1024 * 1024),
69905
70746
  maxValueBytes: integer4("maxValueBytes", limits.maxValueBytes ?? 1024 * 1024, 1, 16 * 1024 * 1024),
@@ -70231,7 +71072,7 @@ var WorkflowRuntime = class {
70231
71072
  const queuedAt = now();
70232
71073
  const agent = {
70233
71074
  index,
70234
- label: call2.label || `Agent ${index}`,
71075
+ label: call2.label || defaultAgentLabel(call2.prompt, index),
70235
71076
  prompt: call2.prompt,
70236
71077
  ...phase ? { phaseIndex: phase.index, phaseTitle: phase.title } : {},
70237
71078
  ...call2.agentType !== void 0 ? { agentType: call2.agentType } : {},
@@ -73020,7 +73861,7 @@ function pathOf(toolInput) {
73020
73861
  return void 0;
73021
73862
  }
73022
73863
  __name(pathOf, "pathOf");
73023
- var REFERENCE_EVENT_NAMES = {
73864
+ var PASCAL_EVENT_NAMES = {
73024
73865
  user_prompt_submit: "UserPromptSubmit",
73025
73866
  session_start: "SessionStart",
73026
73867
  session_end: "SessionEnd",
@@ -73099,7 +73940,7 @@ function readShellHookJson(event, stdout) {
73099
73940
  if (typeof named !== "string") {
73100
73941
  return { invalid: "`hookSpecificOutput` is missing its `hookEventName`" };
73101
73942
  }
73102
- if (named !== event && named !== REFERENCE_EVENT_NAMES[event]) {
73943
+ if (named !== event && named !== PASCAL_EVENT_NAMES[event]) {
73103
73944
  return {
73104
73945
  invalid: `\`hookSpecificOutput.hookEventName\` is "${named}" but this hook ran for ${event}`
73105
73946
  };
@@ -73708,7 +74549,7 @@ var AgentManager = class {
73708
74549
  }
73709
74550
  /**
73710
74551
  * The refusal for a delegation past the depth limit. It tells the model what
73711
- * to do instead (the reference terminal's rule): a bare limit leaves it
74552
+ * to do instead: a bare limit leaves it
73712
74553
  * retrying the same spawn, while an instruction to do the work itself ends the
73713
74554
  * attempt. The limit is `AgentManagerConfig.maxDepth`; there is no env override.
73714
74555
  */
@@ -76796,17 +77637,17 @@ function planWalk(root, options) {
76796
77637
  });
76797
77638
  });
76798
77639
  const sets = matchers.flatMap((matcher) => matcher.set);
76799
- if (sets.some((set3) => set3.some((segment) => segment === ".."))) {
77640
+ if (sets.some((set3) => set3.some((segment2) => segment2 === ".."))) {
76800
77641
  throw new Error("Expanded file walk pattern escapes its root");
76801
77642
  }
76802
77643
  const patternDepth = Math.max(1, ...sets.map((set3) => set3.includes(GLOBSTAR) ? Number.POSITIVE_INFINITY : set3.length));
76803
77644
  const maxDepth = Math.min(patternDepth, options.maxDepth === void 0 ? Number.POSITIVE_INFINITY : positiveInteger(options.maxDepth, "maxDepth"));
76804
77645
  const prefix = [];
76805
77646
  for (let index = 0; sets.length > 0; index += 1) {
76806
- const segment = sets[0]?.[index];
76807
- if (typeof segment !== "string" || !segment || segment === "." || sets.some((set3) => index >= set3.length - 1 || set3[index] !== segment))
77647
+ const segment2 = sets[0]?.[index];
77648
+ if (typeof segment2 !== "string" || !segment2 || segment2 === "." || sets.some((set3) => index >= set3.length - 1 || set3[index] !== segment2))
76808
77649
  break;
76809
- prefix.push(segment);
77650
+ prefix.push(segment2);
76810
77651
  }
76811
77652
  const expressions = matchers.flatMap((matcher) => {
76812
77653
  const expression = matcher.makeRe();
@@ -76820,7 +77661,7 @@ function planWalk(root, options) {
76820
77661
  maxEntries: positiveInteger(options.maxEntries, "maxEntries"),
76821
77662
  maxVisitedEntries: positiveInteger(options.maxVisitedEntries ?? 2e4, "maxVisitedEntries"),
76822
77663
  includeHidden: options.includeHidden ?? false,
76823
- patterns: sets.map((set3) => set3.map((segment) => segment === GLOBSTAR ? null : typeof segment === "string" ? segment : { source: segment.source, flags: segment.flags }))
77664
+ patterns: sets.map((set3) => set3.map((segment2) => segment2 === GLOBSTAR ? null : typeof segment2 === "string" ? segment2 : { source: segment2.source, flags: segment2.flags }))
76824
77665
  };
76825
77666
  }
76826
77667
  __name(planWalk, "planWalk");
@@ -76837,11 +77678,11 @@ function directoryMatcher(plan) {
76837
77678
  for (const name2 of relative10.split("/")) {
76838
77679
  const next = /* @__PURE__ */ new Set();
76839
77680
  for (const index of states) {
76840
- const segment = pattern[index];
76841
- if (segment === null) {
77681
+ const segment2 = pattern[index];
77682
+ if (segment2 === null) {
76842
77683
  if (plan.includeHidden || !name2.startsWith("."))
76843
77684
  next.add(index);
76844
- } else if (typeof segment === "string" ? segment === name2 : segment?.test(name2))
77685
+ } else if (typeof segment2 === "string" ? segment2 === name2 : segment2?.test(name2))
76845
77686
  next.add(index + 1);
76846
77687
  }
76847
77688
  states = closure(next);
@@ -78122,11 +78963,11 @@ __name(isStrictDescendant, "isStrictDescendant");
78122
78963
  function parseWorktreeList(stdout, worktreePath) {
78123
78964
  const blocks = stdout.split(/\n\n+/);
78124
78965
  for (const block of blocks) {
78125
- const lines2 = block.split("\n").filter((l) => l.length > 0);
78966
+ const lines = block.split("\n").filter((l) => l.length > 0);
78126
78967
  let path2;
78127
78968
  let head2;
78128
78969
  let branch;
78129
- for (const line of lines2) {
78970
+ for (const line of lines) {
78130
78971
  if (line.startsWith("worktree "))
78131
78972
  path2 = line.slice("worktree ".length);
78132
78973
  else if (line.startsWith("HEAD "))
@@ -86270,17 +87111,17 @@ var CodeAnalysisTool = defineTool({
86270
87111
  });
86271
87112
  return render3(result, (value) => {
86272
87113
  const f = value.files;
86273
- const lines2 = [
87114
+ const lines = [
86274
87115
  `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.`,
86275
87116
  `${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."}`
86276
87117
  ];
86277
87118
  if (value.truncated)
86278
- lines2.push(value.truncated);
87119
+ lines.push(value.truncated);
86279
87120
  const reasons = Object.entries(value.skippedReasons);
86280
87121
  if (reasons.length > 0) {
86281
- lines2.push(`Skipped: ${reasons.map(([why, n]) => `${n} ${why}`).join(", ")}.`);
87122
+ lines.push(`Skipped: ${reasons.map(([why, n]) => `${n} ${why}`).join(", ")}.`);
86282
87123
  }
86283
- return lines2;
87124
+ return lines;
86284
87125
  });
86285
87126
  }
86286
87127
  case "find_literal": {
@@ -86315,13 +87156,13 @@ var CodeAnalysisTool = defineTool({
86315
87156
  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.`
86316
87157
  ];
86317
87158
  }
86318
- const lines2 = [describeFunction(value.function, root)];
87159
+ const lines = [describeFunction(value.function, root)];
86319
87160
  if (value.parents.length > 0) {
86320
- lines2.push(`parents: ${value.parents.map(shortFunction).join(" < ")}`);
87161
+ lines.push(`parents: ${value.parents.map(shortFunction).join(" < ")}`);
86321
87162
  }
86322
87163
  if (value.source)
86323
- lines2.push(...sourceLines(value.source));
86324
- return lines2;
87164
+ lines.push(...sourceLines(value.source));
87165
+ return lines;
86325
87166
  });
86326
87167
  }
86327
87168
  case "function_source": {
@@ -86445,8 +87286,8 @@ function relativeTo(root, path2) {
86445
87286
  }
86446
87287
  __name(relativeTo, "relativeTo");
86447
87288
  function shortFunction(fn) {
86448
- const lines2 = fn.endLine === fn.line ? `L${fn.line}` : `L${fn.line}-${fn.endLine}`;
86449
- return `${fn.qualifiedName ?? fn.name ?? "(anonymous)"}#${fn.id} ${lines2}`;
87289
+ const lines = fn.endLine === fn.line ? `L${fn.line}` : `L${fn.line}-${fn.endLine}`;
87290
+ return `${fn.qualifiedName ?? fn.name ?? "(anonymous)"}#${fn.id} ${lines}`;
86450
87291
  }
86451
87292
  __name(shortFunction, "shortFunction");
86452
87293
  function describeFunction(fn, root) {
@@ -86464,21 +87305,21 @@ function describeEdge(edge) {
86464
87305
  }
86465
87306
  __name(describeEdge, "describeEdge");
86466
87307
  function sourceLines(slice) {
86467
- const lines2 = ["--- source ---", slice.text];
87308
+ const lines = ["--- source ---", slice.text];
86468
87309
  if (slice.truncated) {
86469
- 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 ---`);
87310
+ 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 ---`);
86470
87311
  }
86471
- return lines2;
87312
+ return lines;
86472
87313
  }
86473
87314
  __name(sourceLines, "sourceLines");
86474
87315
  function evidenceLines(evidence) {
86475
- const lines2 = [];
87316
+ const lines = [];
86476
87317
  if (evidence.observed.length > 0)
86477
- lines2.push(`observed: ${evidence.observed.join("; ")}`);
87318
+ lines.push(`observed: ${evidence.observed.join("; ")}`);
86478
87319
  if (evidence.inferred.length > 0)
86479
- lines2.push(`inferred: ${evidence.inferred.join("; ")}`);
86480
- lines2.push(evidence.coverage.status === "complete" ? "coverage: complete" : `coverage: partial - ${evidence.coverage.reasons.join("; ")}`);
86481
- return lines2;
87320
+ lines.push(`inferred: ${evidence.inferred.join("; ")}`);
87321
+ lines.push(evidence.coverage.status === "complete" ? "coverage: complete" : `coverage: partial - ${evidence.coverage.reasons.join("; ")}`);
87322
+ return lines;
86482
87323
  }
86483
87324
  __name(evidenceLines, "evidenceLines");
86484
87325
  function render3(result, body, data) {
@@ -86504,18 +87345,18 @@ function renderPage(result, line, fileOf) {
86504
87345
  if (page.items.length === 0) {
86505
87346
  return [page.total === 0 ? "No results." : "No results on this page."];
86506
87347
  }
86507
- const lines2 = [];
87348
+ const lines = [];
86508
87349
  let current;
86509
87350
  for (const item of page.items) {
86510
87351
  const file = fileOf?.(item);
86511
87352
  if (file !== void 0 && file !== current) {
86512
- lines2.push(file);
87353
+ lines.push(file);
86513
87354
  current = file;
86514
87355
  }
86515
- lines2.push(file === void 0 ? line(item) : ` ${line(item)}`);
87356
+ lines.push(file === void 0 ? line(item) : ` ${line(item)}`);
86516
87357
  }
86517
- 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.`);
86518
- return lines2;
87358
+ 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.`);
87359
+ return lines;
86519
87360
  }, (page) => ({
86520
87361
  total: page.total,
86521
87362
  count: page.items.length,
@@ -87082,15 +87923,15 @@ function grantNotice(allowed, grant, canGrant) {
87082
87923
 
87083
87924
  [This skill lists allowed-tools (${allowed.join(", ")}), but this host applies no pre-approval, so those calls are reviewed as usual. ${unchanged}]`;
87084
87925
  }
87085
- const lines2 = [];
87086
- 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.");
87926
+ const lines = [];
87927
+ 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.");
87087
87928
  for (const { entry, reason: reason2 } of grant.ignored) {
87088
- lines2.push(`Ignored allowed-tools entry "${entry}": ${reason2}.`);
87929
+ lines.push(`Ignored allowed-tools entry "${entry}": ${reason2}.`);
87089
87930
  }
87090
- lines2.push(unchanged);
87931
+ lines.push(unchanged);
87091
87932
  return `
87092
87933
 
87093
- [${lines2.join(" ")}]`;
87934
+ [${lines.join(" ")}]`;
87094
87935
  }
87095
87936
  __name(grantNotice, "grantNotice");
87096
87937
 
@@ -88380,38 +89221,38 @@ function buildDescription(host, caps, settings) {
88380
89221
  const available = availableActions(host, caps);
88381
89222
  const unavailable3 = unavailableHostActions(host, caps);
88382
89223
  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.`;
88383
- const lines2 = [intro, `Available actions: ${available.join("; ") || "none"}.`];
89224
+ const lines = [intro, `Available actions: ${available.join("; ") || "none"}.`];
88384
89225
  if (unavailable3.length > 0) {
88385
- 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(", ")}.`);
89226
+ 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(", ")}.`);
88386
89227
  }
88387
89228
  if (!available.includes("screenshot"))
88388
- return finish(lines2, caps, available);
88389
- 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.");
89229
+ return finish(lines, caps, available);
89230
+ 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.");
88390
89231
  if (settings.screenshotAfterActions)
88391
- 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.`);
88392
- 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.`);
89232
+ 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.`);
89233
+ 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.`);
88393
89234
  if (available.includes("batch"))
88394
- 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"}.`);
89235
+ 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"}.`);
88395
89236
  if (caps.displayServer === "win32" && available.includes("key") && available.includes("type_text"))
88396
- 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.");
89237
+ 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.");
88397
89238
  if (available.includes("list_windows"))
88398
- lines2.push("list_windows names the open windows with their ids; focus_window brings one to the front.");
89239
+ lines.push("list_windows names the open windows with their ids; focus_window brings one to the front.");
88399
89240
  if (windowCaptureAvailable(host, caps))
88400
- 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.`);
89241
+ 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.`);
88401
89242
  if (available.includes("ui_snapshot"))
88402
- 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.`);
88403
- 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.");
89243
+ 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.`);
89244
+ 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.");
88404
89245
  if (available.includes("list_windows"))
88405
- 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).");
88406
- return finish(lines2, caps, available);
89246
+ 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).");
89247
+ return finish(lines, caps, available);
88407
89248
  }
88408
89249
  __name(buildDescription, "buildDescription");
88409
- function finish(lines2, caps, available) {
89250
+ function finish(lines, caps, available) {
88410
89251
  if (caps.mouseClickButtons && available.includes("mouse_click"))
88411
- lines2.push(`Click buttons: ${caps.mouseClickButtons.join(", ") || "none"}.`);
89252
+ lines.push(`Click buttons: ${caps.mouseClickButtons.join(", ") || "none"}.`);
88412
89253
  if (caps.mouseDragButtons && available.includes("mouse_drag"))
88413
- lines2.push(`Drag buttons: ${caps.mouseDragButtons.join(", ") || "none"}.`);
88414
- return lines2.join(" ");
89254
+ lines.push(`Drag buttons: ${caps.mouseDragButtons.join(", ") || "none"}.`);
89255
+ return lines.join(" ");
88415
89256
  }
88416
89257
  __name(finish, "finish");
88417
89258
  function pointModelSchema(description) {
@@ -88986,7 +89827,7 @@ function createComputerUseTool(host, options = {}) {
88986
89827
  const refs = /* @__PURE__ */ new Map();
88987
89828
  const latest = frames.latest();
88988
89829
  const frame = latest?.window ? void 0 : latest;
88989
- const lines2 = [];
89830
+ const lines = [];
88990
89831
  let chars = 0;
88991
89832
  let shown = 0;
88992
89833
  let total = 0;
@@ -89002,7 +89843,7 @@ function createComputerUseTool(host, options = {}) {
89002
89843
  if (chars + line.length + 1 > MAX_UI_SNAPSHOT_CHARS) {
89003
89844
  cut = true;
89004
89845
  } else {
89005
- lines2.push(line);
89846
+ lines.push(line);
89006
89847
  chars += line.length + 1;
89007
89848
  shown += 1;
89008
89849
  if (ref) {
@@ -89029,7 +89870,7 @@ function createComputerUseTool(host, options = {}) {
89029
89870
  ...snapshot.app !== void 0 ? [`Application ${quotedText(snapshot.app)}`] : [],
89030
89871
  ...snapshot.title !== void 0 && snapshot.title !== snapshot.root.name ? [`Window title ${quotedText(snapshot.title)}`] : []
89031
89872
  ];
89032
- const body = [...about, ...lines2].join("\n");
89873
+ const body = [...about, ...lines].join("\n");
89033
89874
  const footer = cut || snapshot.truncated ? [
89034
89875
  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."
89035
89876
  ] : [];
@@ -89081,7 +89922,7 @@ function createComputerUseTool(host, options = {}) {
89081
89922
  return "no windows are open";
89082
89923
  const latest = frames.latest();
89083
89924
  const frame = latest?.window ? void 0 : latest;
89084
- const lines2 = windows.slice(0, MAX_LISTED_WINDOWS).map((window2) => {
89925
+ const lines = windows.slice(0, MAX_LISTED_WINDOWS).map((window2) => {
89085
89926
  const where = frame ? (() => {
89086
89927
  const rect = window2.minimized ? null : desktopRectOnImage(frame, window2.bounds);
89087
89928
  return rect ? `at ${pointLabel(rect)} ${rect.width}x${rect.height} in ${frame.id}` : window2.minimized ? "minimized" : `not on the display of ${frame.id}`;
@@ -89099,7 +89940,7 @@ function createComputerUseTool(host, options = {}) {
89099
89940
  ${wrapUntrusted({
89100
89941
  kind: "desktop-windows",
89101
89942
  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."
89102
- }, [...lines2, ...more].join("\n"))}`;
89943
+ }, [...lines, ...more].join("\n"))}`;
89103
89944
  }, "listWindows");
89104
89945
  const describeFrame = /* @__PURE__ */ __name((frame) => {
89105
89946
  if (frame.window) {
@@ -89413,17 +90254,17 @@ import { isAbsolute as isAbsolute13, join as join43, relative as relative8, sep
89413
90254
  // ../sdk/dist/tools/posix-path.js
89414
90255
  function normalizeSegments(path2) {
89415
90256
  const out = [];
89416
- for (const segment of path2.split("/")) {
89417
- if (segment === "" || segment === ".")
90257
+ for (const segment2 of path2.split("/")) {
90258
+ if (segment2 === "" || segment2 === ".")
89418
90259
  continue;
89419
- if (segment === "..") {
90260
+ if (segment2 === "..") {
89420
90261
  if (out.length > 0 && out[out.length - 1] !== "..")
89421
90262
  out.pop();
89422
90263
  else
89423
90264
  out.push("..");
89424
90265
  continue;
89425
90266
  }
89426
- out.push(segment);
90267
+ out.push(segment2);
89427
90268
  }
89428
90269
  return out;
89429
90270
  }
@@ -89734,12 +90575,12 @@ var GrepTool = defineTool({
89734
90575
  unreadableFiles++;
89735
90576
  continue;
89736
90577
  }
89737
- const lines2 = content.split("\n");
90578
+ const lines = content.split("\n");
89738
90579
  let fileMatches = 0;
89739
90580
  const relPath = sandbox ? `./${relativePosix(sandbox.rootDir, filePath)}` : `./${relative9(context2.workingDirectory, join44(lexicalRoot, relative9(root, filePath))).split(sep13).join("/")}`;
89740
- for (let i = 0; i < lines2.length; i++) {
90581
+ for (let i = 0; i < lines.length; i++) {
89741
90582
  context2.abortSignal?.throwIfAborted();
89742
- const line = lines2[i] ?? "";
90583
+ const line = lines[i] ?? "";
89743
90584
  regex.lastIndex = 0;
89744
90585
  if (!regex.test(line))
89745
90586
  continue;
@@ -89753,13 +90594,13 @@ var GrepTool = defineTool({
89753
90594
  continue;
89754
90595
  if (input.context_lines > 0) {
89755
90596
  const start = Math.max(0, i - input.context_lines);
89756
- const end = Math.min(lines2.length - 1, i + input.context_lines);
90597
+ const end = Math.min(lines.length - 1, i + input.context_lines);
89757
90598
  if (results.length > 0) {
89758
90599
  results.push("--");
89759
90600
  }
89760
90601
  for (let j = start; j <= end; j++) {
89761
90602
  const prefix = j === i ? ":" : "-";
89762
- const text9 = lines2[j] ?? "";
90603
+ const text9 = lines[j] ?? "";
89763
90604
  results.push(`${relPath}${prefix}${j + 1}${prefix}${clipLine(text9, j === i ? "matching" : "context")}`);
89764
90605
  }
89765
90606
  } else {
@@ -90298,11 +91139,11 @@ var VerifyOutputsTool = defineTool({
90298
91139
  failed: failed.length,
90299
91140
  min_bytes: minBytes
90300
91141
  };
90301
- 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")}`);
91142
+ 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")}`);
90302
91143
  const header = `Verify outputs: ${passed}/${results.length} passed (min ${minBytes}B)`;
90303
91144
  return {
90304
91145
  success: failed.length === 0,
90305
- output: [header, "", ...lines2].join("\n"),
91146
+ output: [header, "", ...lines].join("\n"),
90306
91147
  error: failed.length > 0 ? `${failed.length} of ${results.length} expected outputs failed verification` : void 0,
90307
91148
  data: { results, summary: summary2 }
90308
91149
  };
@@ -91014,13 +91855,13 @@ function renderSnapshot(snapshot, maxChars2) {
91014
91855
  text9 = text9.slice(0, maxChars2);
91015
91856
  cut = true;
91016
91857
  }
91017
- const lines2 = [formatBrowserPageHeader(snapshot.page), wrapPageText(snapshot.page, text9)];
91858
+ const lines = [formatBrowserPageHeader(snapshot.page), wrapPageText(snapshot.page, text9)];
91018
91859
  if (snapshot.nextCursor !== void 0) {
91019
- lines2.push(`More of this page follows: call browser with action "snapshot" and cursor ${JSON.stringify(snapshot.nextCursor)}.`);
91860
+ lines.push(`More of this page follows: call browser with action "snapshot" and cursor ${JSON.stringify(snapshot.nextCursor)}.`);
91020
91861
  } else if (cut) {
91021
- lines2.push(`The snapshot was cut at ${maxChars2} characters. Take a snapshot of one region with ref to see the rest.`);
91862
+ lines.push(`The snapshot was cut at ${maxChars2} characters. Take a snapshot of one region with ref to see the rest.`);
91022
91863
  }
91023
- return lines2.join("\n");
91864
+ return lines.join("\n");
91024
91865
  }
91025
91866
  __name(renderSnapshot, "renderSnapshot");
91026
91867
  function hostMessage(message) {
@@ -91628,13 +92469,13 @@ function defineSearchMemoryTool(search) {
91628
92469
  };
91629
92470
  }
91630
92471
  const now = Date.now();
91631
- const lines2 = result.entries.map((e, i) => {
92472
+ const lines = result.entries.map((e, i) => {
91632
92473
  const kind = [e.name, e.type, describeMemoryAge(e.updatedAt, now)].filter(Boolean).join(", ");
91633
92474
  return `${i + 1}. [${e.id}] ${e.title} (${kind}) \u2014 ${e.description ?? e.summary}${e.tags.length > 0 ? ` [${e.tags.join(", ")}]` : ""}`;
91634
92475
  });
91635
92476
  const output = result.totalCount > result.entries.length ? `Found ${result.totalCount} memories${page} (showing ${result.entries.length}):
91636
- ${lines2.join("\n")}${continuation}` : `Found ${result.totalCount} memories${page}:
91637
- ${lines2.join("\n")}${continuation}`;
92477
+ ${lines.join("\n")}${continuation}` : `Found ${result.totalCount} memories${page}:
92478
+ ${lines.join("\n")}${continuation}`;
91638
92479
  return {
91639
92480
  success: true,
91640
92481
  output,
@@ -92058,8 +92899,8 @@ async function list(host, input) {
92058
92899
  }
92059
92900
  if (jobs.length === 0)
92060
92901
  return { success: true, output: "No scheduled jobs.", data: { jobs: [] } };
92061
- 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)" : ""}`);
92062
- return { success: true, output: lines2.join("\n"), data: { jobs } };
92902
+ 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)" : ""}`);
92903
+ return { success: true, output: lines.join("\n"), data: { jobs } };
92063
92904
  }
92064
92905
  __name(list, "list");
92065
92906
  var CHANGEABLE = [
@@ -92391,6 +93232,37 @@ function pick2(entries2) {
92391
93232
  return out;
92392
93233
  }
92393
93234
  __name(pick2, "pick");
93235
+ var MAX_HUNKS = 100;
93236
+ var MAX_HUNK_ROWS = 400;
93237
+ var MAX_ROW_CHARS = 600;
93238
+ function hunks(value) {
93239
+ if (!Array.isArray(value) || value.length > MAX_HUNKS)
93240
+ return void 0;
93241
+ const out = [];
93242
+ let rows = 0;
93243
+ for (const entry of value) {
93244
+ if (!isRecord4(entry) || !Array.isArray(entry.lines))
93245
+ return void 0;
93246
+ const oldStart = count6(entry.oldStart);
93247
+ const oldLines = count6(entry.oldLines);
93248
+ const newStart = count6(entry.newStart);
93249
+ const newLines = count6(entry.newLines);
93250
+ if (oldStart === void 0 || oldLines === void 0 || newStart === void 0 || newLines === void 0)
93251
+ return void 0;
93252
+ rows += entry.lines.length;
93253
+ if (rows > MAX_HUNK_ROWS)
93254
+ return void 0;
93255
+ const lines = [];
93256
+ for (const row of entry.lines) {
93257
+ if (typeof row !== "string" || row.length > MAX_ROW_CHARS || !(row.startsWith(" ") || row.startsWith("+") || row.startsWith("-")))
93258
+ return void 0;
93259
+ lines.push(row);
93260
+ }
93261
+ out.push({ oldStart, oldLines, newStart, newLines, lines });
93262
+ }
93263
+ return out.length > 0 ? out : void 0;
93264
+ }
93265
+ __name(hunks, "hunks");
92394
93266
  function admitToolFacts(value) {
92395
93267
  if (!isRecord4(value))
92396
93268
  return void 0;
@@ -92449,7 +93321,11 @@ function admitToolFacts(value) {
92449
93321
  return pick2({
92450
93322
  kind: "edit",
92451
93323
  path: text8(value.path),
92452
- replacements: count6(value.replacements)
93324
+ replacements: count6(value.replacements),
93325
+ added: count6(value.added),
93326
+ removed: count6(value.removed),
93327
+ hunks: hunks(value.hunks),
93328
+ hunksTruncated: flag(value.hunksTruncated)
92453
93329
  });
92454
93330
  case "write": {
92455
93331
  const path2 = text8(value.path);
@@ -92462,7 +93338,9 @@ function admitToolFacts(value) {
92462
93338
  operation,
92463
93339
  bytes: count6(value.bytes),
92464
93340
  added: count6(value.added),
92465
- removed: count6(value.removed)
93341
+ removed: count6(value.removed),
93342
+ hunks: hunks(value.hunks),
93343
+ hunksTruncated: flag(value.hunksTruncated)
92466
93344
  });
92467
93345
  }
92468
93346
  case "failure": {
@@ -92709,6 +93587,7 @@ export {
92709
93587
  findPendingCheckpoint,
92710
93588
  isTerminalAgentTaskState,
92711
93589
  CompletionInbox,
93590
+ formatCompletionNotification,
92712
93591
  buildAskUserQuestionTool,
92713
93592
  resolveTriggerThreshold,
92714
93593
  resolveContextWindow,
@@ -92741,6 +93620,8 @@ export {
92741
93620
  InMemorySessionTokenBudgetStore,
92742
93621
  DiskSessionCheckpointStore,
92743
93622
  createFileReadTracker,
93623
+ diffWords,
93624
+ structuredPatch,
92744
93625
  dryRunEdit,
92745
93626
  seedObservationLedger,
92746
93627
  toolResultInjectionGuardrail,
@@ -92822,7 +93703,6 @@ export {
92822
93703
  CODING_AGENT_WORKING_DOCTRINE,
92823
93704
  CODING_AGENT_DELEGATION_DOCTRINE,
92824
93705
  PLAN_MODE_DOCTRINE,
92825
- CODING_AGENT_HYPERMODE_DOCTRINE,
92826
93706
  projectResidentLearning,
92827
93707
  createResidentStepContributions,
92828
93708
  createResidentStepContext,
@@ -92902,4 +93782,4 @@ export {
92902
93782
  buildResidentToolEvidenceTools,
92903
93783
  createPalMessagingTools
92904
93784
  };
92905
- //# sourceMappingURL=chunk-XM3W7NMM.js.map
93785
+ //# sourceMappingURL=chunk-RQBT4RVE.js.map