@namzu/cli 38.2.0 → 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 (391) hide show
  1. package/CHANGELOG.md +111 -50
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-JU4DX3RK.js → acp-NZITIX4C.js} +40 -37
  4. package/dist/chunks/acp-NZITIX4C.js.map +6 -0
  5. package/dist/chunks/{activity-command-TERANSMO.js → activity-command-NKOTZ5FK.js} +11 -11
  6. package/dist/chunks/{add-MZ6KIHY3.js → add-AONYUNXG.js} +17 -17
  7. package/dist/chunks/{agent-JZFFS4IP.js → agent-YPKFE66C.js} +29 -28
  8. package/dist/chunks/agent-session-HFOLAFFL.js +53 -0
  9. package/dist/chunks/{archive-SXYHKL3H.js → archive-SUE5OUZZ.js} +9 -9
  10. package/dist/chunks/{bin-main-TFKZQ7NF.js → bin-main-55PUHGTA.js} +3 -3
  11. package/dist/chunks/{browser-3U3YBKL6.js → browser-HYPSUDAZ.js} +6 -6
  12. package/dist/chunks/{chat-37QA7HHN.js → chat-6OULID33.js} +14 -14
  13. package/dist/chunks/{chunk-7S5UB6DX.js → chunk-233DQVSC.js} +6 -6
  14. package/dist/chunks/{chunk-D5SIC3SF.js → chunk-263WNQB4.js} +9 -9
  15. package/dist/chunks/{chunk-XKEMUEI5.js → chunk-2KKF45DQ.js} +2 -2
  16. package/dist/chunks/{chunk-N57QO3AA.js → chunk-2VMMTC2V.js} +2 -2
  17. package/dist/chunks/{chunk-KUNQW3N3.js → chunk-2WQFRVVQ.js} +4 -4
  18. package/dist/chunks/{chunk-FOGCQUIH.js → chunk-3JB5NDB4.js} +11 -23
  19. package/dist/chunks/chunk-3JB5NDB4.js.map +6 -0
  20. package/dist/chunks/{chunk-LPYWPRIF.js → chunk-3OAGXDRM.js} +4 -4
  21. package/dist/chunks/{chunk-CDZT7WGY.js → chunk-47TGPZWD.js} +3 -3
  22. package/dist/chunks/{chunk-IG4O4UAL.js → chunk-4K2NRXHJ.js} +2 -2
  23. package/dist/chunks/{chunk-2SVXX5QK.js → chunk-5CGH647C.js} +5 -5
  24. package/dist/chunks/{chunk-ZJHOWWXZ.js → chunk-74U3P65Q.js} +12 -12
  25. package/dist/chunks/{chunk-ZJMUPGWD.js → chunk-7EASYULO.js} +8 -8
  26. package/dist/chunks/{chunk-KG2YA6TI.js → chunk-7YXHOSHD.js} +3 -3
  27. package/dist/chunks/{chunk-EKMOETAY.js → chunk-AZ3YHVFA.js} +2 -2
  28. package/dist/chunks/{chunk-7O4X4GYL.js → chunk-B2357ETN.js} +7 -7
  29. package/dist/chunks/{chunk-TCXFKEYW.js → chunk-B73OIFL6.js} +4 -4
  30. package/dist/chunks/{chunk-TCXFKEYW.js.map → chunk-B73OIFL6.js.map} +1 -1
  31. package/dist/chunks/{chunk-XIURI2PQ.js → chunk-BEFTUDYP.js} +7 -7
  32. package/dist/chunks/chunk-CDYUGK7F.js +70 -0
  33. package/dist/chunks/chunk-CDYUGK7F.js.map +6 -0
  34. package/dist/chunks/{chunk-DQICYFIG.js → chunk-CL5TCY4F.js} +2 -2
  35. package/dist/chunks/{chunk-5G3VKTLZ.js → chunk-CUOWARJI.js} +2 -2
  36. package/dist/chunks/{chunk-WLHI2QSC.js → chunk-CZEU2JYJ.js} +3 -3
  37. package/dist/chunks/{chunk-WLHI2QSC.js.map → chunk-CZEU2JYJ.js.map} +1 -1
  38. package/dist/chunks/{chunk-M2EJQU3F.js → chunk-DFA5OB46.js} +4 -4
  39. package/dist/chunks/{chunk-B5344NIV.js → chunk-E3HCZYGN.js} +3 -3
  40. package/dist/chunks/{chunk-Z4LTK3HY.js → chunk-EA6SWPO4.js} +4 -4
  41. package/dist/chunks/{chunk-XNHYUV6G.js → chunk-EUU4TDTH.js} +2 -2
  42. package/dist/chunks/{chunk-VFBIR3UC.js → chunk-FBNKKDIY.js} +4 -4
  43. package/dist/chunks/{chunk-PETRJVXF.js → chunk-FQZFVLJB.js} +4 -4
  44. package/dist/chunks/{chunk-FMJCN6JZ.js → chunk-GU5YARBU.js} +90 -6
  45. package/dist/chunks/chunk-GU5YARBU.js.map +6 -0
  46. package/dist/chunks/{chunk-5PDW6VPO.js → chunk-HI2KXIGA.js} +3 -3
  47. package/dist/chunks/{chunk-LC5VGZO2.js → chunk-HU35YAIZ.js} +2 -2
  48. package/dist/chunks/{chunk-S5U4BG57.js → chunk-HV77F4SF.js} +3 -52
  49. package/dist/chunks/chunk-HV77F4SF.js.map +6 -0
  50. package/dist/chunks/{chunk-2UT6U22B.js → chunk-IAYIUJMI.js} +2 -2
  51. package/dist/chunks/{chunk-6A7P3I3N.js → chunk-ID334ALD.js} +29 -28
  52. package/dist/chunks/{chunk-6A7P3I3N.js.map → chunk-ID334ALD.js.map} +1 -1
  53. package/dist/chunks/{chunk-U3JIZFOS.js → chunk-IE5XIE4W.js} +2 -2
  54. package/dist/chunks/{chunk-2UUBILYI.js → chunk-II57E2QW.js} +4 -4
  55. package/dist/chunks/{chunk-CZVHXYGD.js → chunk-IYPP6HSK.js} +4 -32
  56. package/dist/chunks/chunk-IYPP6HSK.js.map +6 -0
  57. package/dist/chunks/{chunk-OA5772RG.js → chunk-LFVQSMJG.js} +4 -4
  58. package/dist/chunks/{chunk-2WHVZCLT.js → chunk-M3TJHQF7.js} +18 -2
  59. package/dist/chunks/{chunk-2WHVZCLT.js.map → chunk-M3TJHQF7.js.map} +1 -1
  60. package/dist/chunks/{chunk-U75JG2RT.js → chunk-MCNEFI5Q.js} +2 -2
  61. package/dist/chunks/{chunk-JN6M424Z.js → chunk-N3FI7O4U.js} +2 -2
  62. package/dist/chunks/{chunk-3NIZKJJG.js → chunk-N72DH6D5.js} +2 -2
  63. package/dist/chunks/{chunk-V2VHVH5S.js → chunk-NLKIBRXJ.js} +3 -3
  64. package/dist/chunks/{chunk-LBPM46OY.js → chunk-OLOTFDTU.js} +2 -2
  65. package/dist/chunks/{chunk-LLZ32DHS.js → chunk-OXJEMOBQ.js} +860 -253
  66. package/dist/chunks/chunk-OXJEMOBQ.js.map +6 -0
  67. package/dist/chunks/{chunk-7MLTWXEW.js → chunk-P2Y4LUPJ.js} +2 -2
  68. package/dist/chunks/{chunk-KONWJQLM.js → chunk-QNF6COCY.js} +2 -2
  69. package/dist/chunks/{chunk-TNTP3CNT.js → chunk-QO5JUKFG.js} +2 -2
  70. package/dist/chunks/{chunk-GTXD263T.js → chunk-RB36O3CE.js} +2 -2
  71. package/dist/chunks/{chunk-A64X23MU.js → chunk-RQBT4RVE.js} +401 -56
  72. package/dist/chunks/chunk-RQBT4RVE.js.map +6 -0
  73. package/dist/chunks/{chunk-LH6J5QQ7.js → chunk-SBPCN24X.js} +2 -2
  74. package/dist/chunks/{chunk-CK4TOW2N.js → chunk-SIK62TDI.js} +2 -2
  75. package/dist/chunks/{chunk-XEOZYKPJ.js → chunk-T75ITEN6.js} +3 -3
  76. package/dist/chunks/{chunk-2T7TZDUE.js → chunk-TJTRVZFN.js} +2 -2
  77. package/dist/chunks/{chunk-AHVF22PV.js → chunk-UBOPUGDN.js} +5 -5
  78. package/dist/chunks/{chunk-UQZNYNX7.js → chunk-UIDLXA2K.js} +2 -2
  79. package/dist/chunks/{chunk-FI7TIM5P.js → chunk-UTMGJDC3.js} +2 -2
  80. package/dist/chunks/{chunk-CLIP7QVU.js → chunk-UUUNXKL3.js} +3 -3
  81. package/dist/chunks/{chunk-EUHPTASG.js → chunk-UZCA37QE.js} +2 -2
  82. package/dist/chunks/{chunk-Z56MZ7UW.js → chunk-W27ZDC4R.js} +4 -4
  83. package/dist/chunks/{chunk-ICBHR27I.js → chunk-XEHLRJXR.js} +16 -13
  84. package/dist/chunks/{chunk-ICBHR27I.js.map → chunk-XEHLRJXR.js.map} +1 -1
  85. package/dist/chunks/{chunk-HOOY63EB.js → chunk-XJ4IUCH6.js} +15 -15
  86. package/dist/chunks/{chunk-Q6SF7T77.js → chunk-YKEPC6NH.js} +3 -3
  87. package/dist/chunks/{chunk-3PBSWF6X.js → chunk-Z7XA4Y43.js} +3 -3
  88. package/dist/chunks/{cli-runtime-PRG53LL6.js → cli-runtime-G3FHYTCI.js} +13 -13
  89. package/dist/chunks/{commands-QMF4AHAY.js → commands-TIRZH2TK.js} +5 -5
  90. package/dist/chunks/{crash-report-BSZ6SUOF.js → crash-report-E4J7KQ32.js} +6 -6
  91. package/dist/chunks/{dist-HRWBXBF3.js → dist-2IUQEIEI.js} +2 -2
  92. package/dist/chunks/{dist-GNI4DIHI.js → dist-2U6NNEPY.js} +3 -3
  93. package/dist/chunks/{dist-QSOTJL6Z.js → dist-CVDGKJEI.js} +2 -2
  94. package/dist/chunks/{dist-JDUOF4K7.js → dist-MKQZKCB4.js} +2 -2
  95. package/dist/chunks/{dist-MYWLKPXK.js → dist-QCKKBLDW.js} +2 -2
  96. package/dist/chunks/{dist-SO6XBKFN.js → dist-QHKTYYMX.js} +2 -2
  97. package/dist/chunks/{dist-XDA5OMB2.js → dist-YX7Q3EJR.js} +3 -3
  98. package/dist/chunks/{doctor-5MS7V3JB.js → doctor-ASXICRC5.js} +10 -10
  99. package/dist/chunks/{drain-YGGEC4UE.js → drain-CGS3KBU3.js} +10 -10
  100. package/dist/chunks/{eval-GWP6MISH.js → eval-XWC3UCFI.js} +2 -2
  101. package/dist/chunks/{exec-YDIFQY7C.js → exec-FOUQBA6I.js} +42 -30
  102. package/dist/chunks/{exec-YDIFQY7C.js.map → exec-FOUQBA6I.js.map} +1 -1
  103. package/dist/chunks/{home-IZ2H7PM3.js → home-76YLI2M6.js} +3 -3
  104. package/dist/chunks/{host-queries-UCVJBJXU.js → host-queries-ODUQHYBN.js} +14 -14
  105. package/dist/chunks/{lifecycle-U52Z5ZMZ.js → lifecycle-JN43XQSS.js} +25 -25
  106. package/dist/chunks/{list-SVKI2XOL.js → list-TC7TYJDR.js} +11 -11
  107. package/dist/chunks/{login-MNDG4XIT.js → login-CTC6CAM4.js} +10 -10
  108. package/dist/chunks/{logs-M7RCXYPY.js → logs-2NGJFIQI.js} +4 -4
  109. package/dist/chunks/{mcp-KEQMYKDA.js → mcp-BPH7KWZ6.js} +18 -18
  110. package/dist/chunks/{message-command-FZ6VEUK5.js → message-command-A4XU7QQQ.js} +35 -34
  111. package/dist/chunks/message-command-A4XU7QQQ.js.map +6 -0
  112. package/dist/chunks/{operator-tools-C57ZIYRG.js → operator-tools-6RYAHVSL.js} +12 -12
  113. package/dist/chunks/{output-schema-IYQRSIUA.js → output-schema-GSWZHKSI.js} +3 -3
  114. package/dist/chunks/{pal-NXMTLY6Z.js → pal-4QXXG42H.js} +13 -13
  115. package/dist/chunks/{providers-TZBRQDXE.js → providers-6PIIF3WR.js} +8 -8
  116. package/dist/chunks/{resident-DBIZBLOV.js → resident-UP7W6MV6.js} +20 -20
  117. package/dist/chunks/resume-GJHTPMJS.js +22 -0
  118. package/dist/chunks/{resume-command-36S3HXPO.js → resume-command-2RFT7AGW.js} +4 -4
  119. package/dist/chunks/{schedule-UR54S44B.js → schedule-FZISVF6A.js} +8 -8
  120. package/dist/chunks/{service-VMXEAJCI.js → service-4WADXOUI.js} +24 -24
  121. package/dist/chunks/session-step-FX6B4TSE.js +29 -0
  122. package/dist/chunks/{skills-RXYS26H3.js → skills-BJQGVQ23.js} +8 -8
  123. package/dist/chunks/{state-NS47IVWW.js → state-2KKVQPZ2.js} +2 -2
  124. package/dist/chunks/{store-3U2GZAZS.js → store-LO4SSRYI.js} +9 -9
  125. package/dist/chunks/{store-TO65IAIZ.js → store-TKJKR5NM.js} +6 -6
  126. package/dist/chunks/{store-GNFHH2LZ.js → store-YFTJ24WU.js} +4 -4
  127. package/dist/chunks/{tui-STU5UZBC.js → tui-HA3JIVON.js} +1802 -1076
  128. package/dist/chunks/tui-HA3JIVON.js.map +6 -0
  129. package/dist/chunks/{upgrade-USIXROFG.js → upgrade-3QLPPCII.js} +4 -3
  130. package/dist/chunks/upgrade-3QLPPCII.js.map +6 -0
  131. package/dist/chunks/{worktree-AYI5VJ5H.js → worktree-3HYAYSGW.js} +11 -11
  132. package/dist/cli.d.ts.map +1 -1
  133. package/dist/commands/acp.d.ts.map +1 -1
  134. package/dist/commands/desktop-model-catalogue.d.ts +1 -1
  135. package/dist/commands/exec-json.d.ts.map +1 -1
  136. package/dist/commands/exec.d.ts.map +1 -1
  137. package/dist/commands/resume.d.ts +1 -1
  138. package/dist/config/load.d.ts +1 -2
  139. package/dist/config/load.d.ts.map +1 -1
  140. package/dist/config/schema.d.ts +20 -3
  141. package/dist/config/schema.d.ts.map +1 -1
  142. package/dist/context/doctrine.d.ts +4 -4
  143. package/dist/context/doctrine.d.ts.map +1 -1
  144. package/dist/index.js +14 -14
  145. package/dist/integrations/harness/codex-protocol.d.ts +1 -1
  146. package/dist/integrations/harness/codex-protocol.d.ts.map +1 -1
  147. package/dist/integrations/mcp/tool-search.d.ts +3 -4
  148. package/dist/integrations/mcp/tool-search.d.ts.map +1 -1
  149. package/dist/integrations/notifications/idle.d.ts +2 -2
  150. package/dist/integrations/notifications/idle.d.ts.map +1 -1
  151. package/dist/integrations/providers/identity.d.ts +1 -1
  152. package/dist/integrations/resident/runner-worker.js +20 -20
  153. package/dist/integrations/subagents/activity.d.ts +4 -0
  154. package/dist/integrations/subagents/activity.d.ts.map +1 -1
  155. package/dist/integrations/subagents/label-ledger.d.ts +2 -3
  156. package/dist/integrations/subagents/label-ledger.d.ts.map +1 -1
  157. package/dist/integrations/subagents/runtime.d.ts +40 -6
  158. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  159. package/dist/integrations/subagents/workflow-assignment.d.ts +13 -0
  160. package/dist/integrations/subagents/workflow-assignment.d.ts.map +1 -0
  161. package/dist/integrations/workflows/doctrine.d.ts +4 -3
  162. package/dist/integrations/workflows/doctrine.d.ts.map +1 -1
  163. package/dist/integrations/workflows/host.d.ts +5 -0
  164. package/dist/integrations/workflows/host.d.ts.map +1 -1
  165. package/dist/integrations/workflows/offering.d.ts +9 -27
  166. package/dist/integrations/workflows/offering.d.ts.map +1 -1
  167. package/dist/integrations/workflows/size.d.ts +51 -0
  168. package/dist/integrations/workflows/size.d.ts.map +1 -0
  169. package/dist/permissions/live-mode.d.ts +1 -2
  170. package/dist/permissions/live-mode.d.ts.map +1 -1
  171. package/dist/permissions/local-settings.d.ts +4 -4
  172. package/dist/permissions/mode.d.ts +1 -1
  173. package/dist/permissions/rules.d.ts +1 -2
  174. package/dist/permissions/rules.d.ts.map +1 -1
  175. package/dist/permissions/session-allow.d.ts +12 -12
  176. package/dist/permissions/session-allow.d.ts.map +1 -1
  177. package/dist/plan/approval.d.ts +1 -2
  178. package/dist/plan/approval.d.ts.map +1 -1
  179. package/dist/reminders/frame.d.ts +1 -1
  180. package/dist/reminders/frame.d.ts.map +1 -1
  181. package/dist/reminders/hypermode.d.ts +31 -0
  182. package/dist/reminders/hypermode.d.ts.map +1 -0
  183. package/dist/reminders/index.d.ts +7 -1
  184. package/dist/reminders/index.d.ts.map +1 -1
  185. package/dist/reminders/plan-mode.d.ts +1 -1
  186. package/dist/reminders/task-nudge.d.ts +1 -1
  187. package/dist/schedule/fire/fire.d.ts.map +1 -1
  188. package/dist/tui/AgentExplorer.d.ts +25 -6
  189. package/dist/tui/AgentExplorer.d.ts.map +1 -1
  190. package/dist/tui/App.d.ts +10 -1
  191. package/dist/tui/App.d.ts.map +1 -1
  192. package/dist/tui/BackgroundAgentRows.d.ts +13 -0
  193. package/dist/tui/BackgroundAgentRows.d.ts.map +1 -0
  194. package/dist/tui/BackgroundJobsPanel.d.ts.map +1 -1
  195. package/dist/tui/ChoicePicker.d.ts.map +1 -1
  196. package/dist/tui/Composer.d.ts +8 -4
  197. package/dist/tui/Composer.d.ts.map +1 -1
  198. package/dist/tui/ComposerFrame.d.ts +1 -1
  199. package/dist/tui/EffortSlider.d.ts +4 -4
  200. package/dist/tui/EffortSlider.d.ts.map +1 -1
  201. package/dist/tui/LiveActivity.d.ts.map +1 -1
  202. package/dist/tui/PendingInputPanel.d.ts +1 -1
  203. package/dist/tui/PendingInputPanel.d.ts.map +1 -1
  204. package/dist/tui/PermissionOverlay.d.ts +1 -1
  205. package/dist/tui/PlanApprovalOverlay.d.ts +2 -2
  206. package/dist/tui/QuestionDialog.d.ts +1 -1
  207. package/dist/tui/StatusBar.d.ts +6 -3
  208. package/dist/tui/StatusBar.d.ts.map +1 -1
  209. package/dist/tui/Transcript.d.ts +5 -6
  210. package/dist/tui/Transcript.d.ts.map +1 -1
  211. package/dist/tui/agent-stop-all.d.ts +11 -0
  212. package/dist/tui/agent-stop-all.d.ts.map +1 -1
  213. package/dist/tui/agent-transcript-rows.d.ts +28 -15
  214. package/dist/tui/agent-transcript-rows.d.ts.map +1 -1
  215. package/dist/tui/agent-view-commands.d.ts +3 -5
  216. package/dist/tui/agent-view-commands.d.ts.map +1 -1
  217. package/dist/tui/agent.d.ts +26 -12
  218. package/dist/tui/agent.d.ts.map +1 -1
  219. package/dist/tui/background-agents.d.ts +46 -0
  220. package/dist/tui/background-agents.d.ts.map +1 -0
  221. package/dist/tui/choice-selection.d.ts +3 -1
  222. package/dist/tui/choice-selection.d.ts.map +1 -1
  223. package/dist/tui/composer-hints.d.ts +26 -0
  224. package/dist/tui/composer-hints.d.ts.map +1 -0
  225. package/dist/tui/context-meter.d.ts +1 -1
  226. package/dist/tui/diff-rows.d.ts +30 -18
  227. package/dist/tui/diff-rows.d.ts.map +1 -1
  228. package/dist/tui/diff-view.d.ts +99 -0
  229. package/dist/tui/diff-view.d.ts.map +1 -0
  230. package/dist/tui/hint-counts.d.ts +7 -0
  231. package/dist/tui/hint-counts.d.ts.map +1 -0
  232. package/dist/tui/hypermode.d.ts +20 -26
  233. package/dist/tui/hypermode.d.ts.map +1 -1
  234. package/dist/tui/index.d.ts.map +1 -1
  235. package/dist/tui/live-window.d.ts +1 -1
  236. package/dist/tui/live-window.d.ts.map +1 -1
  237. package/dist/tui/markdown-table.d.ts +1 -2
  238. package/dist/tui/markdown-table.d.ts.map +1 -1
  239. package/dist/tui/paste-chips.d.ts +22 -0
  240. package/dist/tui/paste-chips.d.ts.map +1 -0
  241. package/dist/tui/placeholder-examples.d.ts +5 -0
  242. package/dist/tui/placeholder-examples.d.ts.map +1 -0
  243. package/dist/tui/restored-rows.d.ts +3 -1
  244. package/dist/tui/restored-rows.d.ts.map +1 -1
  245. package/dist/tui/schedule/source-deliveries.d.ts +1 -1
  246. package/dist/tui/schedule/source-deliveries.d.ts.map +1 -1
  247. package/dist/tui/shell-cell.d.ts +15 -0
  248. package/dist/tui/shell-cell.d.ts.map +1 -1
  249. package/dist/tui/slashCommands.d.ts.map +1 -1
  250. package/dist/tui/status-line/StatusLineRows.d.ts +1 -2
  251. package/dist/tui/status-line/StatusLineRows.d.ts.map +1 -1
  252. package/dist/tui/status-line/controller.d.ts +1 -1
  253. package/dist/tui/status-line/output.d.ts +2 -2
  254. package/dist/tui/status-line/payload.d.ts +2 -2
  255. package/dist/tui/status-line/run-command.d.ts +1 -1
  256. package/dist/tui/system-rows.d.ts +8 -0
  257. package/dist/tui/system-rows.d.ts.map +1 -1
  258. package/dist/tui/terminal-choice-text.d.ts +7 -0
  259. package/dist/tui/terminal-choice-text.d.ts.map +1 -1
  260. package/dist/tui/theme.d.ts +21 -0
  261. package/dist/tui/theme.d.ts.map +1 -1
  262. package/dist/tui/tool-end-rows.d.ts +9 -1
  263. package/dist/tui/tool-end-rows.d.ts.map +1 -1
  264. package/dist/tui/tool-failure-text.d.ts +13 -0
  265. package/dist/tui/tool-failure-text.d.ts.map +1 -0
  266. package/dist/tui/triggers/context-text.d.ts +3 -3
  267. package/dist/tui/triggers/context-text.d.ts.map +1 -1
  268. package/dist/tui/triggers/copy.d.ts +7 -11
  269. package/dist/tui/triggers/copy.d.ts.map +1 -1
  270. package/dist/tui/triggers/registry.d.ts +2 -3
  271. package/dist/tui/triggers/registry.d.ts.map +1 -1
  272. package/dist/tui/typed-input.d.ts +14 -0
  273. package/dist/tui/typed-input.d.ts.map +1 -0
  274. package/dist/tui/types.d.ts +7 -5
  275. package/dist/tui/types.d.ts.map +1 -1
  276. package/dist/tui/user-text-view.d.ts +25 -0
  277. package/dist/tui/user-text-view.d.ts.map +1 -0
  278. package/dist/tui/workflow-runs.d.ts.map +1 -1
  279. package/dist/tui/workspace-diff.d.ts +3 -4
  280. package/dist/tui/workspace-diff.d.ts.map +1 -1
  281. package/package.json +6 -5
  282. package/dist/chunks/acp-JU4DX3RK.js.map +0 -6
  283. package/dist/chunks/agent-session-YS3JWF6Z.js +0 -52
  284. package/dist/chunks/chunk-A64X23MU.js.map +0 -6
  285. package/dist/chunks/chunk-CZVHXYGD.js.map +0 -6
  286. package/dist/chunks/chunk-FMJCN6JZ.js.map +0 -6
  287. package/dist/chunks/chunk-FOGCQUIH.js.map +0 -6
  288. package/dist/chunks/chunk-LLZ32DHS.js.map +0 -6
  289. package/dist/chunks/chunk-S5U4BG57.js.map +0 -6
  290. package/dist/chunks/message-command-FZ6VEUK5.js.map +0 -6
  291. package/dist/chunks/resume-GG6RMJXQ.js +0 -22
  292. package/dist/chunks/session-step-VJCHKPWD.js +0 -29
  293. package/dist/chunks/tui-STU5UZBC.js.map +0 -6
  294. package/dist/chunks/upgrade-USIXROFG.js.map +0 -6
  295. package/dist/integrations/subagents/failure-text.d.ts +0 -13
  296. package/dist/integrations/subagents/failure-text.d.ts.map +0 -1
  297. /package/dist/chunks/{activity-command-TERANSMO.js.map → activity-command-NKOTZ5FK.js.map} +0 -0
  298. /package/dist/chunks/{add-MZ6KIHY3.js.map → add-AONYUNXG.js.map} +0 -0
  299. /package/dist/chunks/{agent-JZFFS4IP.js.map → agent-YPKFE66C.js.map} +0 -0
  300. /package/dist/chunks/{agent-session-YS3JWF6Z.js.map → agent-session-HFOLAFFL.js.map} +0 -0
  301. /package/dist/chunks/{archive-SXYHKL3H.js.map → archive-SUE5OUZZ.js.map} +0 -0
  302. /package/dist/chunks/{bin-main-TFKZQ7NF.js.map → bin-main-55PUHGTA.js.map} +0 -0
  303. /package/dist/chunks/{browser-3U3YBKL6.js.map → browser-HYPSUDAZ.js.map} +0 -0
  304. /package/dist/chunks/{chat-37QA7HHN.js.map → chat-6OULID33.js.map} +0 -0
  305. /package/dist/chunks/{chunk-7S5UB6DX.js.map → chunk-233DQVSC.js.map} +0 -0
  306. /package/dist/chunks/{chunk-D5SIC3SF.js.map → chunk-263WNQB4.js.map} +0 -0
  307. /package/dist/chunks/{chunk-XKEMUEI5.js.map → chunk-2KKF45DQ.js.map} +0 -0
  308. /package/dist/chunks/{chunk-N57QO3AA.js.map → chunk-2VMMTC2V.js.map} +0 -0
  309. /package/dist/chunks/{chunk-KUNQW3N3.js.map → chunk-2WQFRVVQ.js.map} +0 -0
  310. /package/dist/chunks/{chunk-LPYWPRIF.js.map → chunk-3OAGXDRM.js.map} +0 -0
  311. /package/dist/chunks/{chunk-CDZT7WGY.js.map → chunk-47TGPZWD.js.map} +0 -0
  312. /package/dist/chunks/{chunk-IG4O4UAL.js.map → chunk-4K2NRXHJ.js.map} +0 -0
  313. /package/dist/chunks/{chunk-2SVXX5QK.js.map → chunk-5CGH647C.js.map} +0 -0
  314. /package/dist/chunks/{chunk-ZJHOWWXZ.js.map → chunk-74U3P65Q.js.map} +0 -0
  315. /package/dist/chunks/{chunk-ZJMUPGWD.js.map → chunk-7EASYULO.js.map} +0 -0
  316. /package/dist/chunks/{chunk-KG2YA6TI.js.map → chunk-7YXHOSHD.js.map} +0 -0
  317. /package/dist/chunks/{chunk-EKMOETAY.js.map → chunk-AZ3YHVFA.js.map} +0 -0
  318. /package/dist/chunks/{chunk-7O4X4GYL.js.map → chunk-B2357ETN.js.map} +0 -0
  319. /package/dist/chunks/{chunk-XIURI2PQ.js.map → chunk-BEFTUDYP.js.map} +0 -0
  320. /package/dist/chunks/{chunk-DQICYFIG.js.map → chunk-CL5TCY4F.js.map} +0 -0
  321. /package/dist/chunks/{chunk-5G3VKTLZ.js.map → chunk-CUOWARJI.js.map} +0 -0
  322. /package/dist/chunks/{chunk-M2EJQU3F.js.map → chunk-DFA5OB46.js.map} +0 -0
  323. /package/dist/chunks/{chunk-B5344NIV.js.map → chunk-E3HCZYGN.js.map} +0 -0
  324. /package/dist/chunks/{chunk-Z4LTK3HY.js.map → chunk-EA6SWPO4.js.map} +0 -0
  325. /package/dist/chunks/{chunk-XNHYUV6G.js.map → chunk-EUU4TDTH.js.map} +0 -0
  326. /package/dist/chunks/{chunk-VFBIR3UC.js.map → chunk-FBNKKDIY.js.map} +0 -0
  327. /package/dist/chunks/{chunk-PETRJVXF.js.map → chunk-FQZFVLJB.js.map} +0 -0
  328. /package/dist/chunks/{chunk-5PDW6VPO.js.map → chunk-HI2KXIGA.js.map} +0 -0
  329. /package/dist/chunks/{chunk-LC5VGZO2.js.map → chunk-HU35YAIZ.js.map} +0 -0
  330. /package/dist/chunks/{chunk-2UT6U22B.js.map → chunk-IAYIUJMI.js.map} +0 -0
  331. /package/dist/chunks/{chunk-U3JIZFOS.js.map → chunk-IE5XIE4W.js.map} +0 -0
  332. /package/dist/chunks/{chunk-2UUBILYI.js.map → chunk-II57E2QW.js.map} +0 -0
  333. /package/dist/chunks/{chunk-OA5772RG.js.map → chunk-LFVQSMJG.js.map} +0 -0
  334. /package/dist/chunks/{chunk-U75JG2RT.js.map → chunk-MCNEFI5Q.js.map} +0 -0
  335. /package/dist/chunks/{chunk-JN6M424Z.js.map → chunk-N3FI7O4U.js.map} +0 -0
  336. /package/dist/chunks/{chunk-3NIZKJJG.js.map → chunk-N72DH6D5.js.map} +0 -0
  337. /package/dist/chunks/{chunk-V2VHVH5S.js.map → chunk-NLKIBRXJ.js.map} +0 -0
  338. /package/dist/chunks/{chunk-LBPM46OY.js.map → chunk-OLOTFDTU.js.map} +0 -0
  339. /package/dist/chunks/{chunk-7MLTWXEW.js.map → chunk-P2Y4LUPJ.js.map} +0 -0
  340. /package/dist/chunks/{chunk-KONWJQLM.js.map → chunk-QNF6COCY.js.map} +0 -0
  341. /package/dist/chunks/{chunk-TNTP3CNT.js.map → chunk-QO5JUKFG.js.map} +0 -0
  342. /package/dist/chunks/{chunk-GTXD263T.js.map → chunk-RB36O3CE.js.map} +0 -0
  343. /package/dist/chunks/{chunk-LH6J5QQ7.js.map → chunk-SBPCN24X.js.map} +0 -0
  344. /package/dist/chunks/{chunk-CK4TOW2N.js.map → chunk-SIK62TDI.js.map} +0 -0
  345. /package/dist/chunks/{chunk-XEOZYKPJ.js.map → chunk-T75ITEN6.js.map} +0 -0
  346. /package/dist/chunks/{chunk-2T7TZDUE.js.map → chunk-TJTRVZFN.js.map} +0 -0
  347. /package/dist/chunks/{chunk-AHVF22PV.js.map → chunk-UBOPUGDN.js.map} +0 -0
  348. /package/dist/chunks/{chunk-UQZNYNX7.js.map → chunk-UIDLXA2K.js.map} +0 -0
  349. /package/dist/chunks/{chunk-FI7TIM5P.js.map → chunk-UTMGJDC3.js.map} +0 -0
  350. /package/dist/chunks/{chunk-CLIP7QVU.js.map → chunk-UUUNXKL3.js.map} +0 -0
  351. /package/dist/chunks/{chunk-EUHPTASG.js.map → chunk-UZCA37QE.js.map} +0 -0
  352. /package/dist/chunks/{chunk-Z56MZ7UW.js.map → chunk-W27ZDC4R.js.map} +0 -0
  353. /package/dist/chunks/{chunk-HOOY63EB.js.map → chunk-XJ4IUCH6.js.map} +0 -0
  354. /package/dist/chunks/{chunk-Q6SF7T77.js.map → chunk-YKEPC6NH.js.map} +0 -0
  355. /package/dist/chunks/{chunk-3PBSWF6X.js.map → chunk-Z7XA4Y43.js.map} +0 -0
  356. /package/dist/chunks/{cli-runtime-PRG53LL6.js.map → cli-runtime-G3FHYTCI.js.map} +0 -0
  357. /package/dist/chunks/{commands-QMF4AHAY.js.map → commands-TIRZH2TK.js.map} +0 -0
  358. /package/dist/chunks/{crash-report-BSZ6SUOF.js.map → crash-report-E4J7KQ32.js.map} +0 -0
  359. /package/dist/chunks/{dist-HRWBXBF3.js.map → dist-2IUQEIEI.js.map} +0 -0
  360. /package/dist/chunks/{dist-GNI4DIHI.js.map → dist-2U6NNEPY.js.map} +0 -0
  361. /package/dist/chunks/{dist-QSOTJL6Z.js.map → dist-CVDGKJEI.js.map} +0 -0
  362. /package/dist/chunks/{dist-JDUOF4K7.js.map → dist-MKQZKCB4.js.map} +0 -0
  363. /package/dist/chunks/{dist-MYWLKPXK.js.map → dist-QCKKBLDW.js.map} +0 -0
  364. /package/dist/chunks/{dist-SO6XBKFN.js.map → dist-QHKTYYMX.js.map} +0 -0
  365. /package/dist/chunks/{dist-XDA5OMB2.js.map → dist-YX7Q3EJR.js.map} +0 -0
  366. /package/dist/chunks/{doctor-5MS7V3JB.js.map → doctor-ASXICRC5.js.map} +0 -0
  367. /package/dist/chunks/{drain-YGGEC4UE.js.map → drain-CGS3KBU3.js.map} +0 -0
  368. /package/dist/chunks/{eval-GWP6MISH.js.map → eval-XWC3UCFI.js.map} +0 -0
  369. /package/dist/chunks/{home-IZ2H7PM3.js.map → home-76YLI2M6.js.map} +0 -0
  370. /package/dist/chunks/{host-queries-UCVJBJXU.js.map → host-queries-ODUQHYBN.js.map} +0 -0
  371. /package/dist/chunks/{lifecycle-U52Z5ZMZ.js.map → lifecycle-JN43XQSS.js.map} +0 -0
  372. /package/dist/chunks/{list-SVKI2XOL.js.map → list-TC7TYJDR.js.map} +0 -0
  373. /package/dist/chunks/{login-MNDG4XIT.js.map → login-CTC6CAM4.js.map} +0 -0
  374. /package/dist/chunks/{logs-M7RCXYPY.js.map → logs-2NGJFIQI.js.map} +0 -0
  375. /package/dist/chunks/{mcp-KEQMYKDA.js.map → mcp-BPH7KWZ6.js.map} +0 -0
  376. /package/dist/chunks/{operator-tools-C57ZIYRG.js.map → operator-tools-6RYAHVSL.js.map} +0 -0
  377. /package/dist/chunks/{output-schema-IYQRSIUA.js.map → output-schema-GSWZHKSI.js.map} +0 -0
  378. /package/dist/chunks/{pal-NXMTLY6Z.js.map → pal-4QXXG42H.js.map} +0 -0
  379. /package/dist/chunks/{providers-TZBRQDXE.js.map → providers-6PIIF3WR.js.map} +0 -0
  380. /package/dist/chunks/{resident-DBIZBLOV.js.map → resident-UP7W6MV6.js.map} +0 -0
  381. /package/dist/chunks/{resume-GG6RMJXQ.js.map → resume-GJHTPMJS.js.map} +0 -0
  382. /package/dist/chunks/{resume-command-36S3HXPO.js.map → resume-command-2RFT7AGW.js.map} +0 -0
  383. /package/dist/chunks/{schedule-UR54S44B.js.map → schedule-FZISVF6A.js.map} +0 -0
  384. /package/dist/chunks/{service-VMXEAJCI.js.map → service-4WADXOUI.js.map} +0 -0
  385. /package/dist/chunks/{session-step-VJCHKPWD.js.map → session-step-FX6B4TSE.js.map} +0 -0
  386. /package/dist/chunks/{skills-RXYS26H3.js.map → skills-BJQGVQ23.js.map} +0 -0
  387. /package/dist/chunks/{state-NS47IVWW.js.map → state-2KKVQPZ2.js.map} +0 -0
  388. /package/dist/chunks/{store-3U2GZAZS.js.map → store-LO4SSRYI.js.map} +0 -0
  389. /package/dist/chunks/{store-GNFHH2LZ.js.map → store-TKJKR5NM.js.map} +0 -0
  390. /package/dist/chunks/{store-TO65IAIZ.js.map → store-YFTJ24WU.js.map} +0 -0
  391. /package/dist/chunks/{worktree-AYI5VJ5H.js.map → worktree-3HYAYSGW.js.map} +0 -0
@@ -2,17 +2,19 @@ import { createRequire as __namzuCreateRequire } from 'node:module';
2
2
  const require = __namzuCreateRequire(import.meta.url);
3
3
  import {
4
4
  openManagedWorktrees
5
- } from "./chunk-OA5772RG.js";
5
+ } from "./chunk-LFVQSMJG.js";
6
6
  import {
7
7
  createSessionSkillCatalog
8
- } from "./chunk-Q6SF7T77.js";
8
+ } from "./chunk-YKEPC6NH.js";
9
+ import {
10
+ diffColors,
11
+ theme
12
+ } from "./chunk-CDYUGK7F.js";
9
13
  import {
10
14
  createBrowserControl
11
15
  } from "./chunk-WHODOMXA.js";
12
16
  import {
13
17
  SAVE_SKILL_TOOL_NAME,
14
- WORKFLOW_TOOL_DESCRIPTION,
15
- WORKFLOW_TOOL_NAME,
16
18
  attachAgentView,
17
19
  closeOpenAgents,
18
20
  completionNotice,
@@ -22,16 +24,14 @@ import {
22
24
  reduceRunView,
23
25
  resolveTurnGuards,
24
26
  settledElapsed,
25
- viewFromJournal,
26
- workflowOffered,
27
- workflowRefusal
28
- } from "./chunk-S5U4BG57.js";
27
+ viewFromJournal
28
+ } from "./chunk-HV77F4SF.js";
29
29
  import {
30
30
  connectMcpServers
31
- } from "./chunk-Z56MZ7UW.js";
31
+ } from "./chunk-W27ZDC4R.js";
32
32
  import {
33
33
  openInBrowser
34
- } from "./chunk-XNHYUV6G.js";
34
+ } from "./chunk-EUU4TDTH.js";
35
35
  import {
36
36
  CredentialRefreshRejectedError,
37
37
  CredentialWithdrawnError,
@@ -39,25 +39,30 @@ import {
39
39
  ensureFreshStoredCodexCredential,
40
40
  readSubscriptionCredential,
41
41
  sameOAuthCredential
42
- } from "./chunk-M2EJQU3F.js";
42
+ } from "./chunk-DFA5OB46.js";
43
43
  import {
44
44
  debugRequested
45
45
  } from "./chunk-GNBMKISG.js";
46
46
  import {
47
+ DEFAULT_WORKFLOW_SIZE_GUIDELINE,
47
48
  LOCAL_CONFIG_FILE,
48
49
  configuredPassthroughTools,
50
+ parseTokenTarget,
49
51
  resolveToolResultScreens,
50
- unmatchedPassthroughTools
51
- } from "./chunk-FMJCN6JZ.js";
52
+ unmatchedPassthroughTools,
53
+ workflowSizeAdvice,
54
+ workflowTokenCeiling
55
+ } from "./chunk-GU5YARBU.js";
52
56
  import {
53
57
  formatSize,
54
58
  homePath,
55
59
  plural,
56
- productName
60
+ productName,
61
+ stringWidth
57
62
  } from "./chunk-AXCOWIIH.js";
58
63
  import {
59
64
  createLazyCodeAnalysis
60
- } from "./chunk-JN6M424Z.js";
65
+ } from "./chunk-N3FI7O4U.js";
61
66
  import {
62
67
  canSelectModel,
63
68
  chainCapabilityDisagreements,
@@ -80,7 +85,7 @@ import {
80
85
  requiresCredentialForModel,
81
86
  resolveChainCapabilities,
82
87
  unresolvedMembers
83
- } from "./chunk-HOOY63EB.js";
88
+ } from "./chunk-XJ4IUCH6.js";
84
89
  import {
85
90
  PROVIDER_REGISTRY,
86
91
  missingCredentialMessage,
@@ -89,11 +94,11 @@ import {
89
94
  import {
90
95
  isPermissionMode,
91
96
  permissionModeLabel
92
- } from "./chunk-N57QO3AA.js";
97
+ } from "./chunk-2VMMTC2V.js";
93
98
  import {
94
99
  conversationLogPath,
95
100
  ensureSessionStarted
96
- } from "./chunk-AHVF22PV.js";
101
+ } from "./chunk-UBOPUGDN.js";
97
102
  import {
98
103
  INSTRUCTIONS_FILENAME,
99
104
  MAX_CHARS_PER_FILE,
@@ -104,26 +109,26 @@ import {
104
109
  import {
105
110
  compilePermissions,
106
111
  isPermissionEffect
107
- } from "./chunk-WLHI2QSC.js";
112
+ } from "./chunk-CZEU2JYJ.js";
108
113
  import {
109
114
  cliLogger
110
- } from "./chunk-5G3VKTLZ.js";
115
+ } from "./chunk-CUOWARJI.js";
111
116
  import {
112
117
  probeCapabilities
113
118
  } from "./chunk-OH6TB27S.js";
114
119
  import {
115
120
  activeZenCatalogue,
116
121
  isOfferableModel
117
- } from "./chunk-U3JIZFOS.js";
122
+ } from "./chunk-IE5XIE4W.js";
118
123
  import {
119
124
  ensurePrivateStateDirectory
120
- } from "./chunk-IG4O4UAL.js";
125
+ } from "./chunk-4K2NRXHJ.js";
121
126
  import {
122
127
  restrictToOwner
123
- } from "./chunk-U75JG2RT.js";
128
+ } from "./chunk-MCNEFI5Q.js";
124
129
  import {
125
130
  namzuHomePath
126
- } from "./chunk-EKMOETAY.js";
131
+ } from "./chunk-AZ3YHVFA.js";
127
132
  import {
128
133
  AgentManager,
129
134
  AgentRegistry,
@@ -131,7 +136,6 @@ import {
131
136
  BOOT_EVENT_NAMES,
132
137
  BackgroundJobRegistry,
133
138
  CODING_AGENT_DELEGATION_DOCTRINE,
134
- CODING_AGENT_HYPERMODE_DOCTRINE,
135
139
  CODING_AGENT_WORKING_DOCTRINE,
136
140
  COMPUTER_USE_TOOL_NAME,
137
141
  CompletionInbox,
@@ -221,11 +225,13 @@ import {
221
225
  createUserMessage,
222
226
  deferred,
223
227
  defineTool,
228
+ diffWords,
224
229
  discoverAgentDefinitions,
225
230
  discoverAllPluginDirs,
226
231
  ensureProject,
227
232
  external_exports,
228
233
  filtered,
234
+ formatCompletionNotification,
229
235
  formatMonitorEnd,
230
236
  formatMonitorEvent,
231
237
  generateSessionId,
@@ -269,6 +275,7 @@ import {
269
275
  selectAssistantText,
270
276
  selectTaskContext,
271
277
  slugifyMemoryName,
278
+ structuredPatch,
272
279
  toToolSourceRef,
273
280
  toolWireSchema,
274
281
  toolset,
@@ -277,7 +284,7 @@ import {
277
284
  windowsShellNotice,
278
285
  withProviderFallback,
279
286
  wrapUntrusted
280
- } from "./chunk-A64X23MU.js";
287
+ } from "./chunk-RQBT4RVE.js";
281
288
  import {
282
289
  __name
283
290
  } from "./chunk-76FLAFCG.js";
@@ -432,10 +439,10 @@ var tail = Promise.resolve();
432
439
  var nextStart = 0;
433
440
  function cancelled(promise, signal) {
434
441
  signal.throwIfAborted();
435
- return new Promise((resolve12, reject) => {
442
+ return new Promise((resolve13, reject) => {
436
443
  const abort = /* @__PURE__ */ __name(() => reject(signal.reason), "abort");
437
444
  signal.addEventListener("abort", abort, { once: true });
438
- promise.then(resolve12, reject).finally(() => signal.removeEventListener("abort", abort));
445
+ promise.then(resolve13, reject).finally(() => signal.removeEventListener("abort", abort));
439
446
  });
440
447
  }
441
448
  __name(cancelled, "cancelled");
@@ -476,8 +483,8 @@ async function searchExa(query2, limit, context) {
476
483
  const deadline = Date.now() + DEADLINE_MS;
477
484
  const previous = tail;
478
485
  let release;
479
- tail = new Promise((resolve12) => {
480
- release = resolve12;
486
+ tail = new Promise((resolve13) => {
487
+ release = resolve13;
481
488
  });
482
489
  let acquired = false;
483
490
  try {
@@ -747,6 +754,10 @@ function describeCompactionFailure(event, debug) {
747
754
  }
748
755
  __name(describeCompactionFailure, "describeCompactionFailure");
749
756
 
757
+ // src/tui/diff-rows.ts
758
+ import { readFileSync, statSync } from "node:fs";
759
+ import { isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
760
+
750
761
  // src/tui/truncation.ts
751
762
  var EXPAND_HINT = "(ctrl+o to expand)";
752
763
  var HIDDEN_SIZE_FROM_CHARS = 1e3;
@@ -767,54 +778,350 @@ function clipText(text, max) {
767
778
  }
768
779
  __name(clipText, "clipText");
769
780
 
770
- // src/tui/diff-rows.ts
781
+ // src/tui/diff-view.ts
771
782
  var CREATE_PREVIEW_ROWS = 10;
772
- var EDIT_PREVIEW_ROWS = 40;
783
+ var WORKSPACE_PREVIEW_ROWS = 40;
784
+ var MAX_LINE_CHARS = 2e3;
785
+ var WORD_DIFF_RATIO = 0.4;
786
+ var TAB_STOP = 8;
773
787
  var HUNK_GAP = "...";
774
- var ROW = /^\s*\d+ ([+-]) /;
775
- function diffRowMarker(row) {
776
- const marker = ROW.exec(row)?.[1];
777
- return marker === "+" || marker === "-" ? marker : void 0;
778
- }
779
- __name(diffRowMarker, "diffRowMarker");
780
- function diffRows(hunks) {
781
- const last = hunks.reduce(
782
- (most, hunk) => Math.max(most, hunk.oldStart + hunk.oldLines, hunk.newStart + hunk.newLines),
783
- 1
784
- );
785
- const width = String(last).length;
788
+ var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
789
+ function expandTabs(text) {
790
+ if (!text.includes(" ")) return text;
791
+ let out = "";
792
+ let column = 0;
793
+ for (const { segment } of segmenter.segment(text)) {
794
+ if (segment === " ") {
795
+ const fill = TAB_STOP - column % TAB_STOP;
796
+ out += " ".repeat(fill);
797
+ column += fill;
798
+ } else {
799
+ out += segment;
800
+ column += stringWidth(segment);
801
+ }
802
+ }
803
+ return out;
804
+ }
805
+ __name(expandTabs, "expandTabs");
806
+ function cutLine(code) {
807
+ if (code.length <= MAX_LINE_CHARS) return { code, cut: 0 };
808
+ let end = MAX_LINE_CHARS;
809
+ const last = code.charCodeAt(end - 1);
810
+ if (last >= 55296 && last <= 56319) end -= 1;
811
+ return { code: code.slice(0, end), cut: code.length - end };
812
+ }
813
+ __name(cutLine, "cutLine");
814
+ function truncationNote(cut) {
815
+ return ` \u2026 [+${cut.toLocaleString("en-US")} chars]`;
816
+ }
817
+ __name(truncationNote, "truncationNote");
818
+ function wrapRuns(runs, width) {
819
+ const rows = [[]];
820
+ let used = 0;
821
+ for (const run2 of runs) {
822
+ let pending = "";
823
+ const flush = /* @__PURE__ */ __name(() => {
824
+ if (pending.length === 0) return;
825
+ rows[rows.length - 1]?.push({ text: pending, mark: run2.mark });
826
+ pending = "";
827
+ }, "flush");
828
+ for (const { segment } of segmenter.segment(run2.text)) {
829
+ const w = stringWidth(segment);
830
+ if (used + w > width && used > 0) {
831
+ flush();
832
+ rows.push([]);
833
+ used = 0;
834
+ }
835
+ pending += segment;
836
+ used += w;
837
+ }
838
+ flush();
839
+ }
840
+ return rows;
841
+ }
842
+ __name(wrapRuns, "wrapRuns");
843
+ function entriesOf(hunk) {
844
+ const entries = [];
845
+ for (const row of hunk.lines) {
846
+ if (row.startsWith("\\")) continue;
847
+ const kind = row.startsWith("+") ? "add" : row.startsWith("-") ? "remove" : "same";
848
+ const { code, cut } = cutLine(expandTabs(row.slice(1)));
849
+ entries.push({ kind, code, cut, number: 0 });
850
+ }
851
+ for (let i = 0; i < entries.length; ) {
852
+ if (entries[i]?.kind !== "remove") {
853
+ i++;
854
+ continue;
855
+ }
856
+ let j = i;
857
+ while (entries[j]?.kind === "remove") j++;
858
+ let k = j;
859
+ while (entries[k]?.kind === "add") k++;
860
+ const pairs = Math.min(j - i, k - j);
861
+ for (let n = 0; n < pairs; n++) {
862
+ const gone = entries[i + n];
863
+ const came = entries[j + n];
864
+ if (gone && came) {
865
+ gone.pair = came;
866
+ came.pair = gone;
867
+ }
868
+ }
869
+ i = k > j ? k : j;
870
+ }
871
+ let counter = hunk.oldStart;
872
+ for (let i = 0; i < entries.length; i++) {
873
+ const entry = entries[i];
874
+ if (!entry) continue;
875
+ if (entry.kind === "remove") {
876
+ entry.number = counter;
877
+ let run2 = 0;
878
+ while (entries[i + 1]?.kind === "remove") {
879
+ counter++;
880
+ i++;
881
+ run2++;
882
+ const next = entries[i];
883
+ if (next) next.number = counter;
884
+ }
885
+ counter -= run2;
886
+ } else {
887
+ entry.number = counter;
888
+ counter++;
889
+ }
890
+ }
891
+ return entries;
892
+ }
893
+ __name(entriesOf, "entriesOf");
894
+ function gutterWidth(entries) {
895
+ const most = entries.reduce((max, entry) => Math.max(max, entry.number), 0);
896
+ return String(most).length + 1;
897
+ }
898
+ __name(gutterWidth, "gutterWidth");
899
+ var MARKER = { add: "+", remove: "-", same: " " };
900
+ function diffViewRows(hunks, options) {
901
+ const colors = options.colors ?? diffColors();
902
+ const text = options.text ?? theme.text.primary;
903
+ const dim = options.dim === true;
904
+ const width = Math.max(1, Math.floor(options.width));
786
905
  const rows = [];
787
- hunks.forEach((hunk, index) => {
788
- if (index > 0) rows.push(HUNK_GAP);
789
- let oldLine = hunk.oldStart;
790
- let newLine = hunk.newStart;
791
- for (const row of hunk.lines) {
792
- const marker = row[0] ?? " ";
793
- const text = row.slice(1);
794
- const number = marker === "-" ? oldLine : newLine;
795
- if (marker === "-") oldLine += 1;
796
- else if (marker === "+") newLine += 1;
797
- else {
798
- oldLine += 1;
799
- newLine += 1;
906
+ let first = true;
907
+ for (const hunk of hunks) {
908
+ const entries = entriesOf(hunk);
909
+ if (entries.length === 0) continue;
910
+ if (!first) rows.push([{ text: HUNK_GAP, dim: true }]);
911
+ first = false;
912
+ const m = gutterWidth(entries);
913
+ for (const entry of entries) rows.push(...entryRows(entry, m, width, dim, colors, text));
914
+ }
915
+ return rows;
916
+ }
917
+ __name(diffViewRows, "diffViewRows");
918
+ function backgroundOf(kind, dim, colors) {
919
+ if (kind === "add") return dim ? colors.addedDimmed : colors.added;
920
+ if (kind === "remove") return dim ? colors.removedDimmed : colors.removed;
921
+ return void 0;
922
+ }
923
+ __name(backgroundOf, "backgroundOf");
924
+ function entryRows(entry, m, width, dim, colors, text) {
925
+ const bg = backgroundOf(entry.kind, dim, colors);
926
+ const fg = bg === void 0 ? void 0 : text;
927
+ const marker = MARKER[entry.kind];
928
+ const words = wordRuns(entry, dim);
929
+ const room = Math.max(1, width - m - 1 - (words ? marker.length : 2));
930
+ const pieces = wrapRuns(words ?? [{ text: entry.code, mark: false }], room);
931
+ const note = entry.cut > 0 ? truncationNote(entry.cut) : "";
932
+ let noteRow = -1;
933
+ if (note) {
934
+ const last = pieces.at(-1) ?? [];
935
+ const used = last.reduce((sum, run2) => sum + stringWidth(run2.text), 0);
936
+ if (used + stringWidth(note) > room) pieces.push([]);
937
+ noteRow = pieces.length - 1;
938
+ }
939
+ const wordBg = entry.kind === "add" ? colors.addedWord : colors.removedWord;
940
+ return pieces.map((runs, index) => {
941
+ const number = index === 0 ? String(entry.number).padStart(m) : " ".repeat(m);
942
+ const gutter = `${number} `;
943
+ const code = runs.reduce((sum, run2) => sum + stringWidth(run2.text), 0);
944
+ const tail2 = index === noteRow ? note : "";
945
+ const pad = Math.max(0, width - (gutter.length + marker.length + code + stringWidth(tail2)));
946
+ const row = [
947
+ {
948
+ text: `${gutter}${marker}`,
949
+ ...bg ? { bg } : {},
950
+ ...fg ? { fg } : {},
951
+ ...dim || entry.kind === "same" ? { dim: true } : {}
800
952
  }
801
- rows.push(`${String(number).padStart(width)} ${marker} ${text}`);
953
+ ];
954
+ for (const run2 of runs) {
955
+ row.push({
956
+ text: run2.text,
957
+ ...run2.mark ? { bg: wordBg } : bg ? { bg } : {},
958
+ ...fg ? { fg } : {},
959
+ ...dim ? { dim: true } : {}
960
+ });
802
961
  }
962
+ if (tail2) row.push({ text: tail2, dim: true });
963
+ if (bg && pad > 0) {
964
+ row.push({ text: " ".repeat(pad), bg, ...fg ? { fg } : {}, ...dim ? { dim: true } : {} });
965
+ }
966
+ return row;
803
967
  });
968
+ }
969
+ __name(entryRows, "entryRows");
970
+ function wordRuns(entry, dim) {
971
+ const partner = entry.pair;
972
+ if (dim || !partner) return void 0;
973
+ const [old, now] = entry.kind === "remove" ? [entry.code, partner.code] : [partner.code, entry.code];
974
+ const parts = diffWords(old, now);
975
+ const changed = parts.filter((part) => part.added || part.removed).reduce((sum, part) => sum + part.value.length, 0);
976
+ const total = old.length + now.length;
977
+ if (total === 0 || changed / total > WORD_DIFF_RATIO) return void 0;
978
+ const runs = [];
979
+ for (const part of parts) {
980
+ if (entry.kind === "add") {
981
+ if (part.removed) continue;
982
+ runs.push({ text: part.value, mark: part.added === true });
983
+ } else {
984
+ if (part.added) continue;
985
+ runs.push({ text: part.value, mark: part.removed === true });
986
+ }
987
+ }
988
+ return runs;
989
+ }
990
+ __name(wordRuns, "wordRuns");
991
+ function viewRowText(row) {
992
+ return row.map((segment) => segment.text).join("");
993
+ }
994
+ __name(viewRowText, "viewRowText");
995
+ function fileViewRows(hunks, options) {
996
+ const width = Math.max(1, Math.floor(options.width));
997
+ const rows = [];
998
+ for (const hunk of hunks) {
999
+ for (const line of hunk.lines) {
1000
+ if (line.startsWith("\\")) continue;
1001
+ const { code, cut } = cutLine(expandTabs(line.slice(1)));
1002
+ const note = cut > 0 ? truncationNote(cut) : "";
1003
+ const pieces = wrapRuns([{ text: code, mark: false }], width);
1004
+ const last = pieces.at(-1) ?? [];
1005
+ const used = last.reduce((sum, run2) => sum + stringWidth(run2.text), 0);
1006
+ if (note && used + stringWidth(note) > width) pieces.push([]);
1007
+ pieces.forEach((runs, index) => {
1008
+ const segments = runs.map((run2) => ({
1009
+ text: run2.text,
1010
+ ...options.dim ? { dim: true } : {}
1011
+ }));
1012
+ if (note && index === pieces.length - 1) segments.push({ text: note, dim: true });
1013
+ rows.push(segments);
1014
+ });
1015
+ }
1016
+ }
804
1017
  return rows;
805
1018
  }
806
- __name(diffRows, "diffRows");
807
- function diffBodyFromFacts(facts) {
808
- if (!facts || facts.kind !== "edit" && facts.kind !== "write") return void 0;
809
- const hunks = facts.hunks;
810
- if (!hunks || hunks.length === 0) return void 0;
811
- const created = facts.kind === "write" && facts.operation === "created";
812
- return {
813
- rows: diffRows(hunks).map((row) => clipText(row, 600)),
814
- preview: created ? CREATE_PREVIEW_ROWS : EDIT_PREVIEW_ROWS
815
- };
1019
+ __name(fileViewRows, "fileViewRows");
1020
+ function allRows(info, width) {
1021
+ const dim = info.dim ? { dim: true } : {};
1022
+ if (info.files) {
1023
+ const rows = [];
1024
+ for (const file of info.files) {
1025
+ if (rows.length > 0) rows.push([{ text: "" }]);
1026
+ rows.push([{ text: file.heading }]);
1027
+ rows.push(...diffViewRows(file.hunks, { width, ...dim }));
1028
+ }
1029
+ for (const line of info.footer ?? []) rows.push([{ text: line, dim: true }]);
1030
+ return rows;
1031
+ }
1032
+ return info.mode === "file" ? fileViewRows(info.hunks, { width, ...dim }) : diffViewRows(info.hunks, { width, ...dim });
1033
+ }
1034
+ __name(allRows, "allRows");
1035
+ function diffViewBody(info, options) {
1036
+ const all = allRows(info, options.width);
1037
+ const limit = options.expanded || info.preview === void 0 ? all.length : info.preview;
1038
+ const shown = all.slice(0, limit);
1039
+ const carried = info.hunks.reduce(
1040
+ (count, hunk) => count + hunk.lines.filter((line) => line.startsWith("+")).length,
1041
+ 0
1042
+ );
1043
+ const missing2 = info.mode === "file" && info.truncated && info.added !== void 0 ? Math.max(0, info.added - carried) : 0;
1044
+ const hidden = all.length - shown.length + (shown.length === all.length ? 0 : missing2);
1045
+ if (hidden > 0) {
1046
+ shown.push([
1047
+ {
1048
+ text: hiddenLinesHint(hidden, { canExpand: options.canExpand }),
1049
+ dim: true
1050
+ }
1051
+ ]);
1052
+ } else if (info.truncated) {
1053
+ shown.push([{ text: "\u2026 more changes are not shown", dim: true }]);
1054
+ }
1055
+ return shown;
816
1056
  }
817
- __name(diffBodyFromFacts, "diffBodyFromFacts");
1057
+ __name(diffViewBody, "diffViewBody");
1058
+ function plainDiffRows(info) {
1059
+ const rows = [];
1060
+ if (info.files) {
1061
+ for (const file of info.files) {
1062
+ if (rows.length > 0) rows.push("");
1063
+ rows.push(file.heading, ...plainDiffRows({ mode: "hunks", hunks: file.hunks }));
1064
+ }
1065
+ rows.push(...info.footer ?? []);
1066
+ return rows;
1067
+ }
1068
+ if (info.mode === "file") {
1069
+ for (const hunk of info.hunks) {
1070
+ for (const line of hunk.lines) {
1071
+ if (!line.startsWith("\\")) rows.push(expandTabs(line.slice(1)));
1072
+ }
1073
+ }
1074
+ return rows;
1075
+ }
1076
+ let first = true;
1077
+ for (const hunk of info.hunks) {
1078
+ const entries = entriesOf(hunk);
1079
+ if (entries.length === 0) continue;
1080
+ if (!first) rows.push(HUNK_GAP);
1081
+ first = false;
1082
+ const m = gutterWidth(entries);
1083
+ for (const entry of entries) {
1084
+ rows.push(`${String(entry.number).padStart(m)} ${MARKER[entry.kind]}${entry.code}`);
1085
+ }
1086
+ }
1087
+ return rows;
1088
+ }
1089
+ __name(plainDiffRows, "plainDiffRows");
1090
+ function plural2(count, one, many) {
1091
+ return count === 1 ? one : many;
1092
+ }
1093
+ __name(plural2, "plural");
1094
+ function bold(count) {
1095
+ return { text: count.toLocaleString("en-US"), bold: true };
1096
+ }
1097
+ __name(bold, "bold");
1098
+ function editSummary(added, removed) {
1099
+ const spans = [];
1100
+ if (added > 0) {
1101
+ spans.push({ text: "Added " }, bold(added), { text: ` ${plural2(added, "line", "lines")}` });
1102
+ }
1103
+ if (added > 0 && removed > 0) spans.push({ text: ", " });
1104
+ if (removed > 0) {
1105
+ spans.push({ text: added === 0 ? "Removed " : "removed " }, bold(removed), {
1106
+ text: ` ${plural2(removed, "line", "lines")}`
1107
+ });
1108
+ }
1109
+ return spans;
1110
+ }
1111
+ __name(editSummary, "editSummary");
1112
+ function writeSummary(lines, path) {
1113
+ return [
1114
+ { text: "Wrote " },
1115
+ bold(lines),
1116
+ { text: ` ${plural2(lines, "line", "lines")} to ` },
1117
+ { text: path, bold: true }
1118
+ ];
1119
+ }
1120
+ __name(writeSummary, "writeSummary");
1121
+ function spansText(spans) {
1122
+ return spans.map((span) => span.text).join("");
1123
+ }
1124
+ __name(spansText, "spansText");
818
1125
 
819
1126
  // src/tui/display-path.ts
820
1127
  import { isAbsolute, relative, resolve } from "node:path";
@@ -831,6 +1138,149 @@ function displayPath(path, cwd, home) {
831
1138
  }
832
1139
  __name(displayPath, "displayPath");
833
1140
 
1141
+ // src/tui/diff-rows.ts
1142
+ function countRows(hunks) {
1143
+ let added = 0;
1144
+ let removed = 0;
1145
+ for (const hunk of hunks) {
1146
+ for (const row of hunk.lines) {
1147
+ if (row.startsWith("+")) added += 1;
1148
+ else if (row.startsWith("-")) removed += 1;
1149
+ }
1150
+ }
1151
+ return { added, removed };
1152
+ }
1153
+ __name(countRows, "countRows");
1154
+ function bodyOf(info) {
1155
+ return { rows: plainDiffRows(info).map((row) => clipText(row, 600)), diff: info };
1156
+ }
1157
+ __name(bodyOf, "bodyOf");
1158
+ function diffBodyFromFacts(facts, cwd) {
1159
+ if (!facts || facts.kind !== "edit" && facts.kind !== "write") return void 0;
1160
+ const hunks = facts.hunks ?? [];
1161
+ const carried = countRows(hunks);
1162
+ const added = facts.added ?? carried.added;
1163
+ const removed = facts.removed ?? carried.removed;
1164
+ const created = facts.kind === "write" && facts.operation === "created";
1165
+ if (hunks.length === 0 && (created ? added === 0 : added === 0 && removed === 0)) return void 0;
1166
+ if (facts.kind === "write" && (facts.operation === "unchanged" || facts.operation === "wrote"))
1167
+ return void 0;
1168
+ const truncated = facts.hunksTruncated === true ? { truncated: true } : {};
1169
+ if (created) {
1170
+ return bodyOf({
1171
+ mode: "file",
1172
+ hunks,
1173
+ preview: CREATE_PREVIEW_ROWS,
1174
+ added,
1175
+ removed,
1176
+ ...truncated,
1177
+ summary: writeSummary(added, displayPath(facts.path, cwd))
1178
+ });
1179
+ }
1180
+ return bodyOf({
1181
+ mode: "hunks",
1182
+ hunks,
1183
+ added,
1184
+ removed,
1185
+ ...truncated,
1186
+ summary: editSummary(added, removed)
1187
+ });
1188
+ }
1189
+ __name(diffBodyFromFacts, "diffBodyFromFacts");
1190
+ var PROPOSED_LINE_CAP = 400;
1191
+ var LOCATE_MAX_BYTES = 2 * 1024 * 1024;
1192
+ function proposedFromInput(toolName2, input) {
1193
+ if (typeof input !== "object" || input === null) return void 0;
1194
+ const fields = input;
1195
+ const name = toolName2.toLowerCase();
1196
+ if (name === "write") {
1197
+ const content = fields.content ?? fields.newStr;
1198
+ return typeof content === "string" && content.length > 0 ? { kind: "write", content } : void 0;
1199
+ }
1200
+ if (name === "edit") {
1201
+ const before = fields.old_string ?? fields.oldStr;
1202
+ const after = fields.new_string ?? fields.newStr;
1203
+ if (typeof before !== "string" || typeof after !== "string") return void 0;
1204
+ return {
1205
+ kind: "edit",
1206
+ ...typeof fields.path === "string" ? { path: fields.path } : {},
1207
+ before,
1208
+ after
1209
+ };
1210
+ }
1211
+ return void 0;
1212
+ }
1213
+ __name(proposedFromInput, "proposedFromInput");
1214
+ function startLine(path, snippet, cwd) {
1215
+ if (!path || snippet.length === 0) return 1;
1216
+ try {
1217
+ const full = isAbsolute2(path) ? path : resolve2(cwd ?? process.cwd(), path);
1218
+ if (statSync(full).size > LOCATE_MAX_BYTES) return 1;
1219
+ const text = readFileSync(full, "utf8");
1220
+ const at = text.indexOf(snippet);
1221
+ if (at < 0) return 1;
1222
+ let line = 1;
1223
+ for (let i = text.indexOf("\n"); i >= 0 && i < at; i = text.indexOf("\n", i + 1)) line += 1;
1224
+ return line;
1225
+ } catch {
1226
+ return 1;
1227
+ }
1228
+ }
1229
+ __name(startLine, "startLine");
1230
+ function withNewline(text) {
1231
+ return text.length === 0 || text.endsWith("\n") ? text : `${text}
1232
+ `;
1233
+ }
1234
+ __name(withNewline, "withNewline");
1235
+ function proposedBody(proposed, cwd) {
1236
+ if (!proposed) return void 0;
1237
+ if (proposed.kind === "write") {
1238
+ const lines = withNewline(proposed.content).split("\n");
1239
+ lines.pop();
1240
+ const carried = lines.slice(0, PROPOSED_LINE_CAP);
1241
+ return bodyOf({
1242
+ mode: "file",
1243
+ hunks: [
1244
+ {
1245
+ oldStart: 0,
1246
+ oldLines: 0,
1247
+ newStart: 1,
1248
+ newLines: carried.length,
1249
+ lines: carried.map((line) => `+${line}`)
1250
+ }
1251
+ ],
1252
+ preview: CREATE_PREVIEW_ROWS,
1253
+ added: lines.length,
1254
+ removed: 0,
1255
+ dim: true,
1256
+ ...lines.length > carried.length ? { truncated: true } : {}
1257
+ });
1258
+ }
1259
+ const patch = structuredPatch(
1260
+ "a",
1261
+ "a",
1262
+ withNewline(proposed.before),
1263
+ withNewline(proposed.after),
1264
+ void 0,
1265
+ void 0,
1266
+ {
1267
+ context: 3
1268
+ }
1269
+ );
1270
+ const offset = startLine(proposed.path, proposed.before, cwd) - 1;
1271
+ const hunks = patch.hunks.map((hunk) => ({
1272
+ oldStart: hunk.oldStart + offset,
1273
+ oldLines: hunk.oldLines,
1274
+ newStart: hunk.oldStart + offset,
1275
+ newLines: hunk.newLines,
1276
+ lines: hunk.lines.filter((row) => !row.startsWith("\\"))
1277
+ }));
1278
+ if (hunks.length === 0) return void 0;
1279
+ const counts = countRows(hunks);
1280
+ return bodyOf({ mode: "hunks", hunks, dim: true, ...counts });
1281
+ }
1282
+ __name(proposedBody, "proposedBody");
1283
+
834
1284
  // src/tui/plain-failure.ts
835
1285
  var StartupRefusal = class extends Error {
836
1286
  static {
@@ -1171,7 +1621,7 @@ __name(oneLine, "oneLine");
1171
1621
  // src/tui/agent.ts
1172
1622
  import { SubprocessComputerUseHost } from "@namzu/computer-use";
1173
1623
  import { realpath as realpath4, stat as stat4 } from "node:fs/promises";
1174
- import { join as join14, parse, resolve as resolve11 } from "node:path";
1624
+ import { join as join14, parse, resolve as resolve12 } from "node:path";
1175
1625
 
1176
1626
  // src/checkpoints/store.ts
1177
1627
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -1187,7 +1637,7 @@ import {
1187
1637
  unlink as unlink2,
1188
1638
  writeFile
1189
1639
  } from "node:fs/promises";
1190
- import { basename, dirname, isAbsolute as isAbsolute2, join as join2, relative as relative2, resolve as resolve2, sep } from "node:path";
1640
+ import { basename, dirname, isAbsolute as isAbsolute3, join as join2, relative as relative2, resolve as resolve3, sep } from "node:path";
1191
1641
 
1192
1642
  // src/checkpoints/manifest.ts
1193
1643
  import { createHash, randomBytes } from "node:crypto";
@@ -1586,7 +2036,7 @@ var FileCheckpointStore = class {
1586
2036
  // -- paths ------------------------------------------------------------------
1587
2037
  realCwdPromise;
1588
2038
  realCwd() {
1589
- this.realCwdPromise ??= realExisting(resolve2(this.cwd)).catch(() => resolve2(this.cwd));
2039
+ this.realCwdPromise ??= realExisting(resolve3(this.cwd)).catch(() => resolve3(this.cwd));
1590
2040
  return this.realCwdPromise;
1591
2041
  }
1592
2042
  /**
@@ -1605,12 +2055,12 @@ var FileCheckpointStore = class {
1605
2055
  }
1606
2056
  insideReal(real, root) {
1607
2057
  const rel = relative2(root, real);
1608
- return rel.length > 0 && !rel.startsWith("..") && !isAbsolute2(rel);
2058
+ return rel.length > 0 && !rel.startsWith("..") && !isAbsolute3(rel);
1609
2059
  }
1610
2060
  /** Whether a host path is one this store would cover. */
1611
2061
  covers(hostPath) {
1612
- const rel = relative2(this.cwd, resolve2(this.cwd, hostPath));
1613
- return rel.length > 0 && !rel.startsWith("..") && !isAbsolute2(rel);
2062
+ const rel = relative2(this.cwd, resolve3(this.cwd, hostPath));
2063
+ return rel.length > 0 && !rel.startsWith("..") && !isAbsolute3(rel);
1614
2064
  }
1615
2065
  // -- turns ------------------------------------------------------------------
1616
2066
  /**
@@ -1818,7 +2268,7 @@ var FileCheckpointStore = class {
1818
2268
  });
1819
2269
  }
1820
2270
  async snapshotNow(history, rec, hostPath, meta) {
1821
- const lexical = resolve2(this.cwd, hostPath);
2271
+ const lexical = resolve3(this.cwd, hostPath);
1822
2272
  if (!this.covers(lexical)) {
1823
2273
  await this.skipNow(history, rec, lexical, "outside-cwd");
1824
2274
  return "outside";
@@ -1871,7 +2321,7 @@ var FileCheckpointStore = class {
1871
2321
  const history = await this.load(root);
1872
2322
  const rec = outcome.turnId !== void 0 ? this.byId.get(outcome.turnId) : this.current;
1873
2323
  if (!rec || rec.root === void 0) return;
1874
- const lexical = resolve2(this.cwd, hostPath);
2324
+ const lexical = resolve3(this.cwd, hostPath);
1875
2325
  const path = await this.canonical(lexical).catch(() => null) ?? lexical;
1876
2326
  const entry = rec.m.entries.find((e) => sameFile(e.path, path));
1877
2327
  if (!entry) return;
@@ -1894,7 +2344,7 @@ var FileCheckpointStore = class {
1894
2344
  const root = this.rootOf(turnId);
1895
2345
  return this.locked(root, async () => {
1896
2346
  const history = await this.load(root);
1897
- await this.skipNow(history, this.resolveRec(turnId), resolve2(this.cwd, hostPath), reason);
2347
+ await this.skipNow(history, this.resolveRec(turnId), resolve3(this.cwd, hostPath), reason);
1898
2348
  });
1899
2349
  }
1900
2350
  async skipNow(history, rec, path, reason) {
@@ -2529,18 +2979,18 @@ __name(withShellNote, "withShellNote");
2529
2979
 
2530
2980
  // src/context/directories.ts
2531
2981
  import { realpath as realpath2, stat as stat3 } from "node:fs/promises";
2532
- import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve3 } from "node:path";
2982
+ import { isAbsolute as isAbsolute4, relative as relative3, resolve as resolve4 } from "node:path";
2533
2983
  function isInside(root, candidate) {
2534
2984
  const rel = relative3(root, candidate);
2535
- return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
2985
+ return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
2536
2986
  }
2537
2987
  __name(isInside, "isInside");
2538
2988
  function createSessionDirectories(cwd, directories) {
2539
- const root = resolve3(cwd);
2989
+ const root = resolve4(cwd);
2540
2990
  return {
2541
2991
  list: /* @__PURE__ */ __name(() => [...directories], "list"),
2542
2992
  add: /* @__PURE__ */ __name(async (path, options) => {
2543
- const absolute = resolve3(root, path);
2993
+ const absolute = resolve4(root, path);
2544
2994
  if (absolute === root)
2545
2995
  return { added: false, path: absolute, reason: "That is the working directory." };
2546
2996
  if (directories.includes(absolute))
@@ -2583,7 +3033,7 @@ You are in plan mode. Read, search and think; the only file you may change is th
2583
3033
 
2584
3034
  // src/context/project-tracker.ts
2585
3035
  import { realpathSync } from "node:fs";
2586
- import { dirname as dirname2, isAbsolute as isAbsolute4, join as join3, relative as relative4, resolve as resolve4, sep as sep2 } from "node:path";
3036
+ import { dirname as dirname2, isAbsolute as isAbsolute5, join as join3, relative as relative4, resolve as resolve5, sep as sep2 } from "node:path";
2587
3037
 
2588
3038
  // src/context/project-path.ts
2589
3039
  function visibleProjectInstructionPath(path) {
@@ -2601,13 +3051,13 @@ function canonicalRoot(path) {
2601
3051
  try {
2602
3052
  return realpathSync(path);
2603
3053
  } catch {
2604
- return resolve4(path);
3054
+ return resolve5(path);
2605
3055
  }
2606
3056
  }
2607
3057
  __name(canonicalRoot, "canonicalRoot");
2608
3058
  function contained(root, candidate) {
2609
3059
  const rel = relative4(root, candidate);
2610
- return rel === "" || !isAbsolute4(rel) && rel !== ".." && !rel.startsWith(`..${sep2}`);
3060
+ return rel === "" || !isAbsolute5(rel) && rel !== ".." && !rel.startsWith(`..${sep2}`);
2611
3061
  }
2612
3062
  __name(contained, "contained");
2613
3063
  function relativeInstructionPath(root, file) {
@@ -2665,7 +3115,7 @@ var ProjectInstructionTracker = class {
2665
3115
  if (message2.role !== "user" || message2.source?.type !== "project-instructions") continue;
2666
3116
  if (!isProjectInstructionMessageSource(message2.source)) continue;
2667
3117
  for (const file of message2.source.files) {
2668
- const absolute = resolve4(this.root, file);
3118
+ const absolute = resolve5(this.root, file);
2669
3119
  if (!contained(this.root, absolute)) continue;
2670
3120
  this.registerPath(dirname2(absolute));
2671
3121
  }
@@ -2702,7 +3152,7 @@ var ProjectInstructionTracker = class {
2702
3152
  return;
2703
3153
  }
2704
3154
  const rawPath = observation.input.path;
2705
- const lexical = resolve4(this.cwd, rawPath);
3155
+ const lexical = resolve5(this.cwd, rawPath);
2706
3156
  let target;
2707
3157
  try {
2708
3158
  target = realpathSync(lexical);
@@ -2714,7 +3164,7 @@ var ProjectInstructionTracker = class {
2714
3164
  this.refreshDirectories(this.scopes.keys());
2715
3165
  }
2716
3166
  registerPath(directory) {
2717
- const target = resolve4(directory);
3167
+ const target = resolve5(directory);
2718
3168
  if (!contained(this.root, target)) return;
2719
3169
  const rel = relative4(this.root, target);
2720
3170
  let current = this.root;
@@ -2857,7 +3307,7 @@ var GIT_TIMEOUT_MS = 2e3;
2857
3307
  var GIT_MAX_BUFFER = 4 * 1024 * 1024;
2858
3308
  var MAX_STATUS_LINES = 30;
2859
3309
  var RECENT_COMMITS = 5;
2860
- var MAX_LINE_CHARS = 200;
3310
+ var MAX_LINE_CHARS2 = 200;
2861
3311
  async function git(cwd, args) {
2862
3312
  try {
2863
3313
  const { stdout } = await run("git", [...args], {
@@ -2873,7 +3323,7 @@ async function git(cwd, args) {
2873
3323
  __name(git, "git");
2874
3324
  function boundLine(line) {
2875
3325
  const printable = line.replace(new RegExp("\\p{Cc}", "gu"), "");
2876
- return printable.length > MAX_LINE_CHARS ? `${printable.slice(0, MAX_LINE_CHARS)}\u2026` : printable;
3326
+ return printable.length > MAX_LINE_CHARS2 ? `${printable.slice(0, MAX_LINE_CHARS2)}\u2026` : printable;
2877
3327
  }
2878
3328
  __name(boundLine, "boundLine");
2879
3329
  async function readTurnSnapshot(cwd) {
@@ -3997,7 +4447,7 @@ __name(createContextInventoryStep, "createContextInventoryStep");
3997
4447
 
3998
4448
  // src/integrations/sessions/conversation-search.ts
3999
4449
  import { randomBytes as randomBytes2 } from "node:crypto";
4000
- import { resolve as resolve5 } from "node:path";
4450
+ import { resolve as resolve6 } from "node:path";
4001
4451
 
4002
4452
  // src/integrations/sessions/evidence-page-validation.ts
4003
4453
  var integer = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0, "integer");
@@ -4083,7 +4533,7 @@ function parseQueryIdentity(identity) {
4083
4533
  }
4084
4534
  __name(parseQueryIdentity, "parseQueryIdentity");
4085
4535
  function conversationScope(sessions, sessionId) {
4086
- return JSON.stringify([resolve5(sessions.root), sessions.tenantId, sessions.projectId, sessionId]);
4536
+ return JSON.stringify([resolve6(sessions.root), sessions.tenantId, sessions.projectId, sessionId]);
4087
4537
  }
4088
4538
  __name(conversationScope, "conversationScope");
4089
4539
  var readLocations = /* @__PURE__ */ new Map();
@@ -4597,15 +5047,15 @@ function newScan(terms) {
4597
5047
  return { terms, started: false };
4598
5048
  }
4599
5049
  __name(newScan, "newScan");
4600
- function advanceScan(scans, scan2, nextCursor, excerpts, hasDerivedSummaries, canRefine) {
4601
- scan2.started = true;
4602
- scan2.cursor = nextCursor;
5050
+ function advanceScan(scans, scan3, nextCursor, excerpts, hasDerivedSummaries, canRefine) {
5051
+ scan3.started = true;
5052
+ scan3.cursor = nextCursor;
4603
5053
  if (!canRefine || scans.length !== 1 || !nextCursor) return;
4604
5054
  if (hasDerivedSummaries) {
4605
- scans.push({ ...newScan(scan2.terms), excludeDerivedSummaries: true });
5055
+ scans.push({ ...newScan(scan3.terms), excludeDerivedSummaries: true });
4606
5056
  return;
4607
5057
  }
4608
- const focused = refineEvidenceRecallTerms(scan2.terms, excerpts);
5058
+ const focused = refineEvidenceRecallTerms(scan3.terms, excerpts);
4609
5059
  if (focused) scans.push(newScan(focused));
4610
5060
  }
4611
5061
  __name(advanceScan, "advanceScan");
@@ -4630,8 +5080,8 @@ function createConversationEvidenceRecall(sessions, sessionId, assertOwner, reso
4630
5080
  let excludedSummaries = 0;
4631
5081
  const scans = [newScan(terms)];
4632
5082
  for (let pages = 0; pages < RECALL_PAGES; pages++) {
4633
- const scan2 = [...scans].reverse().find((s) => !s.started || s.cursor);
4634
- if (!scan2) break;
5083
+ const scan3 = [...scans].reverse().find((s) => !s.started || s.cursor);
5084
+ if (!scan3) break;
4635
5085
  signal.throwIfAborted();
4636
5086
  const remaining = maxReadBytes - scannedBytes;
4637
5087
  if (remaining < 1024 * 1024) {
@@ -4642,12 +5092,12 @@ function createConversationEvidenceRecall(sessions, sessionId, assertOwner, reso
4642
5092
  sessions,
4643
5093
  sessionId,
4644
5094
  {
4645
- terms: scan2.terms,
5095
+ terms: scan3.terms,
4646
5096
  matchMode: "token",
4647
5097
  excludeSuccessfulTools: CONVERSATION_RETRIEVAL_TOOLS,
4648
- excludeDerivedSummaries: scan2.excludeDerivedSummaries ?? false,
5098
+ excludeDerivedSummaries: scan3.excludeDerivedSummaries ?? false,
4649
5099
  maxReadBytes: remaining,
4650
- ...scan2.cursor ? { cursor: scan2.cursor } : {}
5100
+ ...scan3.cursor ? { cursor: scan3.cursor } : {}
4651
5101
  },
4652
5102
  signal,
4653
5103
  active
@@ -4678,7 +5128,7 @@ function createConversationEvidenceRecall(sessions, sessionId, assertOwner, reso
4678
5128
  }
4679
5129
  advanceScan(
4680
5130
  scans,
4681
- scan2,
5131
+ scan3,
4682
5132
  page.nextCursor,
4683
5133
  page.matches.map((match) => match.text),
4684
5134
  page.matches.some((match) => match.source === "compaction_shed:summary"),
@@ -4688,9 +5138,9 @@ function createConversationEvidenceRecall(sessions, sessionId, assertOwner, reso
4688
5138
  }
4689
5139
  assertOwner(turnId);
4690
5140
  signal.throwIfAborted();
4691
- const continuations = [...scans].reverse().filter((scan2) => scan2.cursor !== void 0).map((scan2) => ({
5141
+ const continuations = [...scans].reverse().filter((scan3) => scan3.cursor !== void 0).map((scan3) => ({
4692
5142
  toolName: "search_conversation",
4693
- input: { cursor: scan2.cursor }
5143
+ input: { cursor: scan3.cursor }
4694
5144
  }));
4695
5145
  return {
4696
5146
  candidates,
@@ -4848,7 +5298,7 @@ function estimateTokens(text) {
4848
5298
  __name(estimateTokens, "estimateTokens");
4849
5299
  function createSideModel(deps) {
4850
5300
  const routes = /* @__PURE__ */ new Map();
4851
- const resolve12 = /* @__PURE__ */ __name(async (sessionId, signal) => {
5301
+ const resolve13 = /* @__PURE__ */ __name(async (sessionId, signal) => {
4852
5302
  const active = deps.active();
4853
5303
  if (deps.configured !== void 0) {
4854
5304
  const target = parseSmallModel(deps.configured, active.providerId, deps.isKnownProvider);
@@ -4885,7 +5335,7 @@ ${active.model}
4885
5335
  ${deps.configured ?? ""}`;
4886
5336
  let pending = routes.get(key);
4887
5337
  if (pending === void 0) {
4888
- pending = resolve12(sessionId, signal);
5338
+ pending = resolve13(sessionId, signal);
4889
5339
  routes.set(key, pending);
4890
5340
  void pending.then((value) => {
4891
5341
  if (signal.aborted && value.source === "main" && routes.get(key) === pending) {
@@ -4942,49 +5392,15 @@ __name(createSideModel, "createSideModel");
4942
5392
  // src/integrations/state/retention.ts
4943
5393
  var CLI_CHECKPOINT_RETENTION = 10;
4944
5394
 
4945
- // src/integrations/subagents/failure-text.ts
4946
- var CAUSES = [
4947
- [
4948
- /rate limited by the provider/i,
4949
- "The provider was too busy for this agent. Wait a moment, then message the agent to try again."
4950
- ],
4951
- [
4952
- /could not reach the provider/i,
4953
- "Namzu could not reach the provider. Check the connection, then message the agent to try again."
4954
- ],
4955
- [
4956
- /the provider rejected the request credentials/i,
4957
- "The provider did not accept the sign-in. Sign in again, then start the task again."
4958
- ],
4959
- [
4960
- /exceeded the model context window/i,
4961
- "The task was too large for the model. Start it again with a smaller task."
4962
- ],
4963
- [
4964
- /the provider rejected the request as invalid/i,
4965
- "The provider could not use this request. Start the task again, or choose another model."
4966
- ],
4967
- [
4968
- /the provider failed to complete the request/i,
4969
- "The provider ran into a problem. Wait a moment, then message the agent to try again."
4970
- ]
4971
- ];
4972
- var GENERIC = "This agent stopped because of an error. Run with --debug for details.";
4973
- function isPlainSentence(text) {
4974
- if (text.length < 8 || text.length > 220) return false;
4975
- if (!/^[A-Z]/u.test(text) || !/[.!?]$/u.test(text)) return false;
4976
- return !/[\n\r{}[\]\\]|\w\/\w|~\/|\bat \S+:\d+|\b(?:undefined|null|NaN)\b|\bHTTP \d{3}\b/u.test(
4977
- text
4978
- );
4979
- }
4980
- __name(isPlainSentence, "isPlainSentence");
4981
- function plainAgentFailure(raw, debug = debugRequested()) {
4982
- const text = raw.trim();
4983
- const plain = CAUSES.find(([pattern]) => pattern.test(text))?.[1] ?? (isPlainSentence(text) ? text : GENERIC);
4984
- return debug && text !== "" && text !== plain ? `${plain}
4985
- ${text}` : plain;
5395
+ // src/integrations/subagents/workflow-assignment.ts
5396
+ var WORKFLOW_STEP_ASSIGNMENT = "This step is your assigned job. The person who started this workflow approved the script that gives it to you, so carry it out and report what you found or did; do not decline it or skip it.";
5397
+ function stepTaskOnly(prompt) {
5398
+ const opening = `${WORKFLOW_STEP_ASSIGNMENT}
5399
+
5400
+ `;
5401
+ return prompt.startsWith(opening) ? prompt.slice(opening.length) : prompt;
4986
5402
  }
4987
- __name(plainAgentFailure, "plainAgentFailure");
5403
+ __name(stepTaskOnly, "stepTaskOnly");
4988
5404
 
4989
5405
  // src/integrations/subagents/activity.ts
4990
5406
  var MAX_RETAINED_AGENTS = 80;
@@ -5080,7 +5496,7 @@ var SubagentActivityMonitor = class {
5080
5496
  } : {},
5081
5497
  description: bounded(input.description, MAX_AGENT_ACTIVITY_LABEL_CODE_UNITS),
5082
5498
  ...input.background ? { background: true } : {},
5083
- prompt: bounded(input.prompt, MAX_PROMPT_CODE_UNITS),
5499
+ prompt: bounded(stepTaskOnly(input.prompt), MAX_PROMPT_CODE_UNITS),
5084
5500
  batchId,
5085
5501
  ...input.toolUseId ? { toolUseId: bounded(input.toolUseId, MAX_IDENTITY_LABEL_CODE_UNITS) } : {},
5086
5502
  workflowId,
@@ -5138,13 +5554,10 @@ var SubagentActivityMonitor = class {
5138
5554
  if (!owned) return;
5139
5555
  const cancelled2 = cancellationLike(error);
5140
5556
  owned.status = cancelled2 ? "cancelled" : "failed";
5557
+ if (cancelled2 && !owned.stoppedBy) owned.stoppedBy = "user";
5141
5558
  owned.completedAt = Date.now();
5142
5559
  owned.latestActivity = terminalLabel(owned.status);
5143
- pushRow(owned, {
5144
- id: `${owned.viewId}:failure`,
5145
- kind: "system",
5146
- text: bounded(plainAgentFailure(errorMessage(error)), MAX_ROW_CODE_UNITS)
5147
- });
5560
+ pushFailure(owned, `${owned.viewId}:failure`, errorMessage(error));
5148
5561
  owned.closed = true;
5149
5562
  this.prune();
5150
5563
  this.notifyNow();
@@ -5347,6 +5760,7 @@ var SubagentActivityMonitor = class {
5347
5760
  startedAt: record.startedAt,
5348
5761
  ...record.completedAt !== void 0 ? { completedAt: record.completedAt } : {},
5349
5762
  ...record.latestActivity ? { latestActivity: record.latestActivity } : {},
5763
+ ...failureOf(record) !== void 0 ? { error: failureOf(record) } : {},
5350
5764
  transcript: Object.freeze(record.rows.map((row) => Object.freeze({ ...row })))
5351
5765
  });
5352
5766
  }
@@ -5614,30 +6028,38 @@ function projectEvent(record, event) {
5614
6028
  record.status = "failed";
5615
6029
  record.completedAt = Date.now();
5616
6030
  record.latestActivity = "Failed";
5617
- pushRow(record, {
5618
- id: `${record.viewId}:agent-failed`,
5619
- kind: "system",
5620
- text: bounded(plainAgentFailure(event.error), MAX_ROW_CODE_UNITS)
5621
- });
6031
+ pushFailure(record, `${record.viewId}:agent-failed`, event.error);
5622
6032
  return;
5623
6033
  case "agent_canceled":
5624
6034
  record.status = "cancelled";
6035
+ if (!record.stoppedBy) record.stoppedBy = "user";
5625
6036
  record.completedAt = Date.now();
5626
6037
  record.latestActivity = "Cancelled";
5627
6038
  return;
5628
6039
  case "turn_failed":
5629
6040
  record.latestActivity = "Failed";
5630
- pushRow(record, {
5631
- id: `${record.viewId}:turn-failed`,
5632
- kind: "system",
5633
- text: bounded(plainAgentFailure(event.error), MAX_ROW_CODE_UNITS)
5634
- });
6041
+ pushFailure(record, `${record.viewId}:turn-failed`, event.error);
5635
6042
  return;
5636
6043
  default:
5637
6044
  return;
5638
6045
  }
5639
6046
  }
5640
6047
  __name(projectEvent, "projectEvent");
6048
+ function pushFailure(record, id, error) {
6049
+ const text = error.trim();
6050
+ if (text === "") return;
6051
+ pushRow(record, { id, kind: "system", text: bounded(text, MAX_ROW_CODE_UNITS), failure: true });
6052
+ }
6053
+ __name(pushFailure, "pushFailure");
6054
+ function failureOf(record) {
6055
+ if (record.status !== "failed") return void 0;
6056
+ for (let index = record.rows.length - 1; index >= 0; index -= 1) {
6057
+ const row = record.rows[index];
6058
+ if (row?.kind === "system" && row.failure) return row.text;
6059
+ }
6060
+ return void 0;
6061
+ }
6062
+ __name(failureOf, "failureOf");
5641
6063
  function pushRow(record, row) {
5642
6064
  record.rows.push(row);
5643
6065
  if (record.rows.length > MAX_TRANSCRIPT_ROWS) {
@@ -6450,7 +6872,7 @@ __name(settledAnswer, "settledAnswer");
6450
6872
  // src/integrations/subagents/worktree-driver.ts
6451
6873
  import { execFile as execFile2 } from "node:child_process";
6452
6874
  import { mkdir as mkdir3, realpath as realpath3 } from "node:fs/promises";
6453
- import { isAbsolute as isAbsolute5, relative as relative5, resolve as resolve6, sep as sep3 } from "node:path";
6875
+ import { isAbsolute as isAbsolute6, relative as relative5, resolve as resolve7, sep as sep3 } from "node:path";
6454
6876
  import { promisify as promisify2 } from "node:util";
6455
6877
  var runFile = promisify2(execFile2);
6456
6878
  var DelegatedWorktreeDriver = class {
@@ -6469,9 +6891,9 @@ var DelegatedWorktreeDriver = class {
6469
6891
  this.ready ??= openManagedWorktrees(this.cwd, {
6470
6892
  stateRoot: this.stateRoot
6471
6893
  }).then(async (managed) => {
6472
- const selectedDirectory = await realpath3(resolve6(this.cwd));
6894
+ const selectedDirectory = await realpath3(resolve7(this.cwd));
6473
6895
  const subdirectory = relative5(managed.sourceRoot, selectedDirectory);
6474
- if (isAbsolute5(subdirectory) || subdirectory === ".." || subdirectory.startsWith(`..${sep3}`)) {
6896
+ if (isAbsolute6(subdirectory) || subdirectory === ".." || subdirectory.startsWith(`..${sep3}`)) {
6475
6897
  throw new Error("Selected directory is outside its Git checkout");
6476
6898
  }
6477
6899
  return {
@@ -6514,7 +6936,6 @@ var DelegatedWorktreeDriver = class {
6514
6936
  // src/integrations/subagents/runtime.ts
6515
6937
  var NARRATION_TOOL_NAME = "narrate_work";
6516
6938
  var MAX_NARRATION_INPUT_CODE_UNITS = MAX_NARRATION_CODE_UNITS * 2;
6517
- var WORKFLOW_STEP_ASSIGNMENT = "This step is your assigned job. The person who started this workflow approved the script that gives it to you, so carry it out and report what you found or did; do not decline it or skip it.";
6518
6939
  var GENERAL_PURPOSE_SUBAGENT = "general-purpose";
6519
6940
  var EXPLORE_SUBAGENT = EXPLORE_AGENT_ID;
6520
6941
  var EXPLORE_PROMPT = [EXPLORE_AGENT_PROMPT, "", CODING_AGENT_WORKING_DOCTRINE].join("\n");
@@ -6591,6 +7012,7 @@ var refuseUnownedChildReview = /* @__PURE__ */ __name(async () => ({
6591
7012
  }), "refuseUnownedChildReview");
6592
7013
  async function createSubagentRuntime(input) {
6593
7014
  const childMessageListeners = /* @__PURE__ */ new Set();
7015
+ const backgroundCompletionListeners = /* @__PURE__ */ new Set();
6594
7016
  const opts = {
6595
7017
  ...input,
6596
7018
  childExtraTools: /* @__PURE__ */ __name(() => childMessageListeners.size > 0 ? [toolset("agents:message-main", [messageMainTool])] : [], "childExtraTools")
@@ -6794,12 +7216,16 @@ async function createSubagentRuntime(input) {
6794
7216
  await refreshLimits(lease.shared, current);
6795
7217
  assertOwned();
6796
7218
  });
6797
- const completionInbox = new CompletionInbox();
7219
+ const completionInbox = new CompletionInbox(void 0, {
7220
+ holdsTurnOpen: opts.backgroundByDefault !== true
7221
+ });
6798
7222
  completionInbox.attach(gateway);
6799
7223
  const runtime = {
6800
7224
  gateway,
6801
7225
  completionInbox,
6802
7226
  budget,
7227
+ parentSessionId: String(parent.sessionId),
7228
+ retired: false,
6803
7229
  close() {
6804
7230
  if (released) return;
6805
7231
  released = true;
@@ -6892,11 +7318,65 @@ async function createSubagentRuntime(input) {
6892
7318
  if (oldest !== void 0) releasedTurns.delete(oldest);
6893
7319
  }
6894
7320
  parents.delete(turnId);
6895
- await pending.then(
6896
- (runtime) => runtime.close(),
6897
- () => void 0
6898
- );
7321
+ const runtime = await pending.catch(() => void 0);
7322
+ if (runtime === void 0) return;
7323
+ if (runtime.retired) {
7324
+ parents.set(turnId, pending);
7325
+ return;
7326
+ }
7327
+ if (!closed && opts.backgroundByDefault === true && retireWithRunningTasks(turnId, runtime)) {
7328
+ parents.set(turnId, pending);
7329
+ return;
7330
+ }
7331
+ runtime.close();
6899
7332
  }, "releaseTurn");
7333
+ const retireWithRunningTasks = /* @__PURE__ */ __name((turnId, runtime) => {
7334
+ const running = runtime.gateway.listTasks().filter((task) => !isTerminalAgentTaskState(task.state));
7335
+ const unheard = runtime.completionInbox.drain();
7336
+ for (const handle of unheard) reportBackgroundCompletion(turnId, runtime, handle);
7337
+ if (running.length === 0) return false;
7338
+ runtime.retired = true;
7339
+ let remaining = running.length;
7340
+ for (const task of running) {
7341
+ runtime.gateway.waitForTask(task.taskId).then(
7342
+ (handle) => reportBackgroundCompletion(turnId, runtime, handle),
7343
+ () => void 0
7344
+ ).finally(() => {
7345
+ remaining -= 1;
7346
+ if (remaining > 0 || parents.get(turnId) === void 0) return;
7347
+ parents.delete(turnId);
7348
+ runtime.close();
7349
+ });
7350
+ }
7351
+ return true;
7352
+ }, "retireWithRunningTasks");
7353
+ const reportBackgroundCompletion = /* @__PURE__ */ __name((turnId, runtime, handle) => {
7354
+ if (closed || backgroundCompletionListeners.size === 0) return;
7355
+ if (!isTerminalAgentTaskState(handle.state)) return;
7356
+ runtime.completionInbox.claim(handle.taskId);
7357
+ const shown = activity.getSnapshot().find((entry) => entry.taskId === String(handle.taskId));
7358
+ const completion = {
7359
+ parentSessionId: runtime.parentSessionId,
7360
+ taskId: String(handle.taskId),
7361
+ ...shown ? { viewId: shown.viewId } : {},
7362
+ agentId: shown?.agentId ?? String(handle.agentId),
7363
+ description: shown?.description ?? String(handle.agentId),
7364
+ state: handle.state === "completed" ? "completed" : handle.state === "canceled" ? "cancelled" : "failed",
7365
+ ...shown?.stoppedBy ? { stoppedBy: shown.stoppedBy } : {},
7366
+ text: formatCompletionNotification([handle])
7367
+ };
7368
+ for (const listener of [...backgroundCompletionListeners]) listener(completion);
7369
+ }, "reportBackgroundCompletion");
7370
+ const gatewayHolding = /* @__PURE__ */ __name(async (taskId, turnId) => {
7371
+ const own = await gatewayForTurn(turnId);
7372
+ if (own.getTask(taskId)) return own;
7373
+ for (const [otherId, pending] of parents) {
7374
+ if (otherId === turnId) continue;
7375
+ const runtime = await pending.catch(() => void 0);
7376
+ if (runtime?.retired && runtime.gateway.getTask(taskId)) return runtime.gateway;
7377
+ }
7378
+ return own;
7379
+ }, "gatewayHolding");
6900
7380
  const completionInboxForTurn = /* @__PURE__ */ __name(async (turnId) => {
6901
7381
  await gatewayForTurn(turnId);
6902
7382
  const pending = parents.get(turnId);
@@ -7129,8 +7609,8 @@ ${persona}` : persona || (explore ? EXPLORE_PROMPT : SUBAGENT_PROMPT),
7129
7609
  const agentTool = defineTool({
7130
7610
  name: "Agent",
7131
7611
  description: [
7132
- "Delegate a self-contained task to a sub-agent. Set run_in_background: true to receive its task ID immediately and continue independent work; completion arrives as a task notification. Otherwise wait for its result. Operator input can also release a blocking wait while the child keeps working. Use agent_task_list for current agent status (task_list is only the planning list), send_message to correct a running task, cancel_agent to stop only one owned task, and wait_for_task to retrieve its result; never launch duplicate work.",
7133
- "For a request to run multiple independent tasks in parallel, issue all Agent calls together in one response, or set run_in_background: true on each launch before waiting. A single blocking Agent call followed by another call runs them sequentially.",
7612
+ opts.backgroundByDefault === true ? "Delegate a self-contained task to a sub-agent. Agents run in the background by default: you get the task ID at once and are notified automatically when one ends, so do not sleep, poll or check on its progress; continue with other work or answer the user instead. Pass run_in_background: false only when your very next action depends on the result and nothing else could usefully happen while it runs. Operator input can also release a blocking wait while the child keeps working. Use agent_task_list for current agent status (task_list is only the planning list), send_message to correct a running task, cancel_agent to stop only one owned task, and wait_for_task to retrieve its result; never launch duplicate work." : "Delegate a self-contained task to a sub-agent. Set run_in_background: true to receive its task ID immediately and continue independent work; completion arrives as a task notification. Otherwise wait for its result. Operator input can also release a blocking wait while the child keeps working. Use agent_task_list for current agent status (task_list is only the planning list), send_message to correct a running task, cancel_agent to stop only one owned task, and wait_for_task to retrieve its result; never launch duplicate work.",
7613
+ opts.backgroundByDefault === true ? "For a request to run multiple independent tasks in parallel, issue all Agent calls together in one response. A blocking Agent call (run_in_background: false) followed by another call runs them sequentially." : "For a request to run multiple independent tasks in parallel, issue all Agent calls together in one response, or set run_in_background: true on each launch before waiting. A single blocking Agent call followed by another call runs them sequentially.",
7134
7614
  'Pick `subagent_type: "explore"` for anything that only needs to look \u2014 where is X defined, which files reference Y, how does Z work \u2014 it has reading and searching tools only and never asks for permission.',
7135
7615
  'Use the default "general-purpose" when the task must change files or run commands.',
7136
7616
  'Set `workspace: "worktree"` when the child needs its own Git checkout. It starts from this checkout\'s committed HEAD; uncommitted parent changes are absent. The checkout and its edits remain after the child ends, so report its path and branch to the operator.',
@@ -7156,7 +7636,7 @@ ${persona}` : persona || (explore ? EXPLORE_PROMPT : SUBAGENT_PROMPT),
7156
7636
  },
7157
7637
  run_in_background: {
7158
7638
  type: "boolean",
7159
- description: "Return after launch so the parent can continue independent work. Defaults to false."
7639
+ description: opts.backgroundByDefault === true ? "Agents run in the background by default; you will be notified when one completes. Set to false only when your very next action depends on this agent's result and nothing else could usefully happen while it runs; otherwise leave it in the background so the user can hand you other work." : "Return after launch so the parent can continue independent work. Defaults to false."
7160
7640
  },
7161
7641
  workspace: {
7162
7642
  type: "string",
@@ -7223,8 +7703,10 @@ ${persona}` : persona || (explore ? EXPLORE_PROMPT : SUBAGENT_PROMPT),
7223
7703
  concurrencySafe: true,
7224
7704
  timeoutMs: opts.resolveLimits ? 0 : opts.timeoutMs ?? CLI_INTERACTIVE_TURN_TIMEOUT_MS,
7225
7705
  async execute(input2, context) {
7226
- const { description, run_in_background } = input2;
7227
- const { outcome, agentId } = await launchChild(input2, context);
7706
+ const call = input2;
7707
+ const run_in_background = call.run_in_background ?? opts.backgroundByDefault === true;
7708
+ const { description } = call;
7709
+ const { outcome, agentId } = await launchChild({ ...call, run_in_background }, context);
7228
7710
  if (outcome.kind === "yielded") {
7229
7711
  const progress = outcome.handle.state === "pending" ? "queued for an available slot" : "still running";
7230
7712
  return {
@@ -7373,7 +7855,12 @@ ${step}`;
7373
7855
  };
7374
7856
  }
7375
7857
  const gateway = await gatewayForTurn(context.turnId);
7376
- const tasks = gateway.listTasks();
7858
+ const tasks = [...gateway.listTasks()];
7859
+ for (const [otherId, pending] of parents) {
7860
+ if (otherId === context.turnId) continue;
7861
+ const runtime = await pending.catch(() => void 0);
7862
+ if (runtime?.retired) tasks.push(...runtime.gateway.listTasks());
7863
+ }
7377
7864
  const snapshot = activity.getSnapshot();
7378
7865
  const labels = new Map(snapshot.map((entry) => [entry.taskId, entry.description]));
7379
7866
  const shown = tasks.slice(-40).map((task) => ({
@@ -7420,7 +7907,7 @@ ${step}`;
7420
7907
  concurrencySafe: true,
7421
7908
  timeoutMs: opts.resolveLimits ? 0 : opts.timeoutMs ?? CLI_INTERACTIVE_TURN_TIMEOUT_MS,
7422
7909
  async execute(input2, context) {
7423
- const gateway = await gatewayForTurn(context.turnId);
7910
+ let gateway = await gatewayForTurn(context.turnId);
7424
7911
  let taskId;
7425
7912
  const asked = input2.task_id;
7426
7913
  if (typeof asked === "string" && /^w[0-9a-z]{8}$/.test(asked.trim())) {
@@ -7439,6 +7926,7 @@ ${step}`;
7439
7926
  error: "task_id must be a task UUID returned by Agent or a task notification."
7440
7927
  };
7441
7928
  }
7929
+ gateway = await gatewayHolding(taskId, context.turnId);
7442
7930
  const task = gateway.getTask(taskId);
7443
7931
  if (!task)
7444
7932
  return {
@@ -7510,7 +7998,7 @@ ${step}`;
7510
7998
  error: "Message must not be blank."
7511
7999
  };
7512
8000
  const taskId = asTaskId(task_id);
7513
- const gateway = await gatewayForTurn(context.turnId);
8001
+ const gateway = await gatewayHolding(taskId, context.turnId);
7514
8002
  const task = gateway.getTask(taskId);
7515
8003
  if (!task)
7516
8004
  return {
@@ -7574,7 +8062,7 @@ ${step}`;
7574
8062
  async execute(input2, context) {
7575
8063
  context.abortSignal.throwIfAborted();
7576
8064
  const taskId = asTaskId(input2.task_id);
7577
- const gateway = await gatewayForTurn(context.turnId);
8065
+ const gateway = await gatewayHolding(taskId, context.turnId);
7578
8066
  const task = gateway.getTask(taskId);
7579
8067
  if (!task)
7580
8068
  return {
@@ -7944,6 +8432,12 @@ ${step}`;
7944
8432
  childMessageListeners.delete(listener);
7945
8433
  };
7946
8434
  },
8435
+ onBackgroundCompletion(listener) {
8436
+ backgroundCompletionListeners.add(listener);
8437
+ return () => {
8438
+ backgroundCompletionListeners.delete(listener);
8439
+ };
8440
+ },
7947
8441
  cancelAgentTool,
7948
8442
  modelCatalogueTool,
7949
8443
  messageChild,
@@ -8194,9 +8688,13 @@ __name(buildDefinition, "buildDefinition");
8194
8688
 
8195
8689
  // src/integrations/workflows/doctrine.ts
8196
8690
  var WORKFLOW_DOCTRINE = [
8197
- "The `workflow` tool is available this turn because the operator asked for orchestration.",
8198
- "Use it for work with several phases or many agents: write the script once, call `workflow`, and the runtime schedules the agents and groups them by phase. Keep `Agent` calls (with a `workflow` label and a `phase`) for a small fan-out of a few agents, and for a single subagent.",
8199
- "A workflow runs in the background and the operator approves the script before it starts. After you start one, tell the operator in one sentence that it is running; its result reaches you in a single message when it ends, and you then report the outcome."
8691
+ "The `workflow` tool starts many agents on one decision. Call it only after an explicit opt-in, which is one of:",
8692
+ `- the operator's message included the keyword "hypermode" or "workflow" (a note from Namzu confirms it for that turn);`,
8693
+ "- hypermode is on for the session (a note from Namzu confirms it); then it is a standing opt-in for every substantive task, and you work alone only on conversational or trivial turns;",
8694
+ "- the operator asked for a workflow or for multi-agent orchestration in their own words;",
8695
+ "- the operator named a specific saved workflow to run.",
8696
+ "For any other task, even one that would clearly benefit from parallelism, do not call it: use `Agent` for a single subagent or a small fan-out of a few agents.",
8697
+ "Use it for work with several phases or many agents: write the script once, call `workflow`, and the runtime schedules the agents and groups them by phase. A workflow runs in the background and the operator approves the script before it starts. After you start one, tell the operator in one sentence that it is running; its result reaches you in a single message when it ends, and you then report the outcome."
8200
8698
  ].join("\n");
8201
8699
 
8202
8700
  // src/integrations/workflows/history.ts
@@ -8250,6 +8748,43 @@ __name(listWorkflowRuns, "listWorkflowRuns");
8250
8748
  import { randomBytes as randomBytes3 } from "node:crypto";
8251
8749
  import { join as join9 } from "node:path";
8252
8750
 
8751
+ // src/integrations/workflows/offering.ts
8752
+ var WORKFLOW_TOOL_NAME = "workflow";
8753
+ var WORKFLOW_BACKGROUND_NOTE = "Running in the background (\u2193 to manage)";
8754
+ var WORKFLOW_TOOL_DESCRIPTION = [
8755
+ `Run a workflow: a short JavaScript program you write once that starts many subagents, in order and in parallel, and returns one value. It runs in the background: this call returns once the first agent is requested, and one message arrives when the run ends. A script that fails before it requests any agent is an error of this call, and one that finishes without any returns its result here. ONLY call it after an explicit opt-in: the operator's message included the keyword "hypermode" or "workflow" (a note confirms it), hypermode is on for the session (a note confirms it), the operator asked for a workflow or multi-agent orchestration in their own words, or they named a saved workflow to run. For any other task, even one that would clearly benefit from parallelism, do not call it; for a single subagent or a small fan-out, use the Agent tool.`,
8756
+ "",
8757
+ "The script is confined: no files, no network, no commands, no timers, no imports. Its only power is agent(), which starts a subagent with the same tools, permissions, sandbox and budget the Agent tool gives. A prompt you pass is data for that subagent and cannot widen what it may do.",
8758
+ "",
8759
+ "The first statement must be a pure literal, with no variables, calls or spreads:",
8760
+ 'export const meta = { name: "audit", description: "One line the operator reads before it starts", phases: [{ title: "Scan" }, { title: "Fix", detail: "safe fixes only" }] }',
8761
+ "",
8762
+ "Then plain code. Everything below is a global:",
8763
+ '- agent(prompt, opts?) starts one subagent and resolves to its final text, or to a parsed value when opts.schema (a JSON Schema) is given, or to null when it failed or was skipped. Always handle null. opts: label (a short row title), phase (a phase title), schema, agentType ("general-purpose", "explore", or a project agent), model, effort. The subagent cannot see this conversation or your variables: put everything it needs in the prompt.',
8764
+ "- parallel([() => agent(...), ...]) starts every thunk now and resolves when all are done. It never rejects: a thunk that throws becomes null in its place and the reason goes through log(), so filter the nulls (.filter(Boolean)).",
8765
+ "- pipeline(items, stage1, stage2, ...) runs one chain per item with no barrier between stages; a stage gets (prevResult, originalItem, index), where the first stage gets the item as prevResult, and an item whose stage gives null stops there. It never rejects either: a stage that throws drops its item to null and the reason goes through log(), so filter the nulls.",
8766
+ "- phase(title) names the stage that the following agents belong to; inside parallel() or pipeline() pass opts.phase instead. Use the same titles as in meta.phases.",
8767
+ '- log(message) writes a progress line. args is exactly the JSON you pass in the args input of the call (undefined when you omit it). budget is { total, spent(), remaining() }: total is the token target the person typed (a standalone "+500k" in their message) or null when there is none; spent() is the tokens this run has used; remaining() is max(0, total - spent()), or Infinity with no target. The target is a hard ceiling: once spent() reaches total, agent() throws, so wrap loops in try/catch and guard them on budget.total (with no target remaining() is Infinity). Example: while (budget.total && budget.remaining() > 50_000) { ... }.',
8768
+ "- return a small JSON value: it is what you get back, capped at about 8000 characters. Have agents write large results to files and return the paths.",
8769
+ "",
8770
+ "Limits: a handful of agents run at once (the cap comes from the configuration; usually up to 16) and at most 1000 start per run (fewer if configured); a script that asks for more fails, so give any loop a hard iteration cap. The script may be up to 256 KiB and args 64 KiB, but the operator reads the script before it starts, so keep it as short as it can be: loops over lists, shared helpers, prompts built from args. Put long per-agent instructions in a file the agents read.",
8771
+ "",
8772
+ "Quality patterns, when hypermode is on or the task is large: adversarial verify (a second agent tries to disprove each finding), a judge panel (several agents score the same candidates, keep the consensus), loop until dry (repeat a sweep until a pass finds nothing new), and a completeness critic (a last agent lists what the others missed). Pick what fits; skip them for trivial or already verified work.",
8773
+ "",
8774
+ "Before it starts the operator sees the name, description, phases, limits and the script, and approves or declines. If they decline, do not retry with the same script; ask what to change."
8775
+ ].join("\n");
8776
+ function workflowToolDescription(sizeAdvice = "") {
8777
+ return sizeAdvice === "" ? WORKFLOW_TOOL_DESCRIPTION : `${WORKFLOW_TOOL_DESCRIPTION}
8778
+
8779
+ ${sizeAdvice}`;
8780
+ }
8781
+ __name(workflowToolDescription, "workflowToolDescription");
8782
+ function workflowRefusal(turn) {
8783
+ if (turn.mode === "auto" || turn.mode === "bypass" || turn.interactive) return void 0;
8784
+ return "A workflow starts many agents on one decision, so a person has to approve it first. This session has nobody to ask and is not set to run without asking, so no workflow was started. Run it from the terminal, or start the session with --permission-mode bypass.";
8785
+ }
8786
+ __name(workflowRefusal, "workflowRefusal");
8787
+
8253
8788
  // src/integrations/workflows/registry.ts
8254
8789
  var WorkflowRunRegistry = class {
8255
8790
  static {
@@ -8349,11 +8884,11 @@ var WorkflowRunRegistry = class {
8349
8884
  whenIdle(signal) {
8350
8885
  const going = /* @__PURE__ */ __name(() => [...this.runs.values()].some((run2) => !run2.finalized), "going");
8351
8886
  if (!going() || signal?.aborted) return Promise.resolve();
8352
- return new Promise((resolve12) => {
8887
+ return new Promise((resolve13) => {
8353
8888
  const done = /* @__PURE__ */ __name(() => {
8354
8889
  off();
8355
8890
  signal?.removeEventListener("abort", done);
8356
- resolve12();
8891
+ resolve13();
8357
8892
  }, "done");
8358
8893
  const off = this.subscribe(() => {
8359
8894
  if (!going()) done();
@@ -8502,7 +9037,7 @@ function createWorkflowHost(options) {
8502
9037
  const registry = options.registry ?? new WorkflowRunRegistry();
8503
9038
  const tool = defineTool({
8504
9039
  name: WORKFLOW_TOOL_NAME,
8505
- description: WORKFLOW_TOOL_DESCRIPTION,
9040
+ description: workflowToolDescription(options.sizeAdvice),
8506
9041
  inputSchema: mcpJsonSchemaToZod({
8507
9042
  type: "object",
8508
9043
  properties: {
@@ -8566,8 +9101,8 @@ function createWorkflowHost(options) {
8566
9101
  let launching = true;
8567
9102
  let settleLaunch = /* @__PURE__ */ __name(() => {
8568
9103
  }, "settleLaunch");
8569
- const launch = new Promise((resolve12) => {
8570
- settleLaunch = resolve12;
9104
+ const launch = new Promise((resolve13) => {
9105
+ settleLaunch = resolve13;
8571
9106
  });
8572
9107
  const detach = /* @__PURE__ */ __name(() => {
8573
9108
  if (!launching) return;
@@ -8666,7 +9201,7 @@ __name(createWorkflowHost, "createWorkflowHost");
8666
9201
 
8667
9202
  // src/memory/store.ts
8668
9203
  import { realpathSync as realpathSync3 } from "node:fs";
8669
- import { join as join11, resolve as resolve8 } from "node:path";
9204
+ import { join as join11, resolve as resolve9 } from "node:path";
8670
9205
 
8671
9206
  // src/memory/io.ts
8672
9207
  import {
@@ -8680,7 +9215,7 @@ import {
8680
9215
  realpathSync as realpathSync2,
8681
9216
  writeSync
8682
9217
  } from "node:fs";
8683
- import { isAbsolute as isAbsolute6, join as join10, relative as relative6, resolve as resolve7, sep as sep4 } from "node:path";
9218
+ import { isAbsolute as isAbsolute7, join as join10, relative as relative6, resolve as resolve8, sep as sep4 } from "node:path";
8684
9219
  var MEMORY_FILE_MAX_BYTES = 1024 * 1024;
8685
9220
  function missing(error) {
8686
9221
  return error.code === "ENOENT";
@@ -8688,12 +9223,12 @@ function missing(error) {
8688
9223
  __name(missing, "missing");
8689
9224
  function within(path, root) {
8690
9225
  const part = relative6(root, path);
8691
- return !isAbsolute6(part) && part !== ".." && !part.startsWith(`..${sep4}`);
9226
+ return !isAbsolute7(part) && part !== ".." && !part.startsWith(`..${sep4}`);
8692
9227
  }
8693
9228
  __name(within, "within");
8694
9229
  function resolveMemoryPath(location, createParents = false) {
8695
- const root = resolve7(location.root);
8696
- const path = resolve7(location.path);
9230
+ const root = resolve8(location.root);
9231
+ const path = resolve8(location.path);
8697
9232
  if (!within(path, root)) throw new Error("Memory path is outside its allowed scope.");
8698
9233
  let rootStat;
8699
9234
  try {
@@ -8851,7 +9386,7 @@ function memoryFilePath(home) {
8851
9386
  }
8852
9387
  __name(memoryFilePath, "memoryFilePath");
8853
9388
  function projectMemoryFilePath(cwd) {
8854
- let directory = resolve8(cwd);
9389
+ let directory = resolve9(cwd);
8855
9390
  try {
8856
9391
  directory = realpathSync3(directory);
8857
9392
  } catch (error) {
@@ -8868,7 +9403,7 @@ function projectMemoryLocation(cwd) {
8868
9403
  }
8869
9404
  __name(projectMemoryLocation, "projectMemoryLocation");
8870
9405
  function projectLocation(cwd) {
8871
- const directory = realpathSync3(resolve8(cwd));
9406
+ const directory = realpathSync3(resolve9(cwd));
8872
9407
  return { path: projectMemoryFilePath(directory), root: cliProjectRoot(directory) };
8873
9408
  }
8874
9409
  __name(projectLocation, "projectLocation");
@@ -8898,7 +9433,7 @@ function readMemory(home, cwd) {
8898
9433
  root: userRoot,
8899
9434
  path: join11(userRoot, "MEMORY.md")
8900
9435
  }));
8901
- const project = cwd && !isUserMemoryFile(join11(resolve8(cwd), ".namzu", "MEMORY.md"), userRoot) ? read(join11(resolve8(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
9436
+ const project = cwd && !isUserMemoryFile(join11(resolve9(cwd), ".namzu", "MEMORY.md"), userRoot) ? read(join11(resolve9(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
8902
9437
  return { user, memory, project, ...diagnostics.length > 0 ? { diagnostics } : {} };
8903
9438
  }
8904
9439
  __name(readMemory, "readMemory");
@@ -8907,7 +9442,7 @@ function isUserMemoryFile(projectPath, userRoot) {
8907
9442
  try {
8908
9443
  return realpathSync3(path);
8909
9444
  } catch {
8910
- return resolve8(path);
9445
+ return resolve9(path);
8911
9446
  }
8912
9447
  }, "canonical");
8913
9448
  return canonical(projectPath) === canonical(join11(userRoot, "MEMORY.md"));
@@ -9114,10 +9649,10 @@ function composeStoredMemoryPrompt(index) {
9114
9649
  ].join("\n");
9115
9650
  }
9116
9651
  __name(composeStoredMemoryPrompt, "composeStoredMemoryPrompt");
9117
- var MARKER = "migration.json";
9652
+ var MARKER2 = "migration.json";
9118
9653
  async function readMarker(directory) {
9119
9654
  try {
9120
- const parsed = JSON.parse(await readFile4(join12(directory, MARKER), "utf8"));
9655
+ const parsed = JSON.parse(await readFile4(join12(directory, MARKER2), "utf8"));
9121
9656
  return parsed !== null && typeof parsed === "object" ? parsed : {};
9122
9657
  } catch (error) {
9123
9658
  if (error.code === "ENOENT") return {};
@@ -9130,7 +9665,7 @@ async function markCuratedFile(directory, path, state) {
9130
9665
  const files = { ...marker.curatedFiles ?? {} };
9131
9666
  files[path] = { ...files[path] ?? {}, ...state };
9132
9667
  await writeFile2(
9133
- join12(directory, MARKER),
9668
+ join12(directory, MARKER2),
9134
9669
  `${JSON.stringify({ ...marker, curatedFiles: files }, null, 2)}
9135
9670
  `,
9136
9671
  { mode: 384 }
@@ -9312,9 +9847,9 @@ function describeCuratedNotesImport(result, directory) {
9312
9847
  if (result.found === 0) {
9313
9848
  return `No top-level bullets to copy in ${result.path}; it is unchanged.`;
9314
9849
  }
9315
- const plural2 = /* @__PURE__ */ __name((n) => n === 1 ? "" : "s", "plural");
9850
+ const plural3 = /* @__PURE__ */ __name((n) => n === 1 ? "" : "s", "plural");
9316
9851
  const already = result.alreadyStored > 0 ? ` ${result.alreadyStored} ${result.alreadyStored === 1 ? "was" : "were"} already stored and not copied again.` : "";
9317
- return `Copied ${result.copied} of ${result.found} bullet${plural2(result.found)} from ${result.path} into typed memory files in ${directory}.${already} ${result.path} is unchanged: its bullets are still curated text in every turn. Delete the ones you no longer want there yourself.`;
9852
+ return `Copied ${result.copied} of ${result.found} bullet${plural3(result.found)} from ${result.path} into typed memory files in ${directory}.${already} ${result.path} is unchanged: its bullets are still curated text in every turn. Delete the ones you no longer want there yourself.`;
9318
9853
  }
9319
9854
  __name(describeCuratedNotesImport, "describeCuratedNotesImport");
9320
9855
 
@@ -9470,12 +10005,12 @@ __name(createLiveModeControl, "createLiveModeControl");
9470
10005
 
9471
10006
  // src/permissions/local-settings.ts
9472
10007
  import { execFile as execFile3 } from "node:child_process";
9473
- import { existsSync, readFileSync, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
10008
+ import { existsSync, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
9474
10009
  import { appendFile as appendFile3, mkdir as mkdir5, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
9475
10010
  import { homedir } from "node:os";
9476
- import { dirname as dirname3, isAbsolute as isAbsolute7, join as join13, resolve as resolve9 } from "node:path";
10011
+ import { dirname as dirname3, isAbsolute as isAbsolute8, join as join13, resolve as resolve10 } from "node:path";
9477
10012
  function localConfigPath(cwd) {
9478
- return resolve9(cwd, LOCAL_CONFIG_FILE);
10013
+ return resolve10(cwd, LOCAL_CONFIG_FILE);
9479
10014
  }
9480
10015
  __name(localConfigPath, "localConfigPath");
9481
10016
  function isRecord2(value) {
@@ -9510,7 +10045,7 @@ function writeLocalAllows(cwd, additions) {
9510
10045
  if (existsSync(path)) {
9511
10046
  let parsed;
9512
10047
  try {
9513
- parsed = JSON.parse(readFileSync(path, "utf-8"));
10048
+ parsed = JSON.parse(readFileSync2(path, "utf-8"));
9514
10049
  } catch (cause) {
9515
10050
  return {
9516
10051
  path,
@@ -9554,9 +10089,9 @@ function globalIgnorePath(configured, env) {
9554
10089
  const home = env.HOME ?? env.USERPROFILE ?? homedir();
9555
10090
  const value = configured.trim();
9556
10091
  if (value === "~" || value.startsWith("~/")) return join13(home, value.slice(2));
9557
- if (value !== "" && isAbsolute7(value)) return value;
10092
+ if (value !== "" && isAbsolute8(value)) return value;
9558
10093
  const xdg = env.XDG_CONFIG_HOME;
9559
- if (xdg && isAbsolute7(xdg)) return join13(xdg, "git", "ignore");
10094
+ if (xdg && isAbsolute8(xdg)) return join13(xdg, "git", "ignore");
9560
10095
  return join13(home, ".config", "git", "ignore");
9561
10096
  }
9562
10097
  __name(globalIgnorePath, "globalIgnorePath");
@@ -9874,17 +10409,17 @@ var EXIT_PLAN_MODE_TOOL_NAME = "exit_plan_mode";
9874
10409
 
9875
10410
  // src/plan/plan-file.ts
9876
10411
  import { readFile as readFile6 } from "node:fs/promises";
9877
- import { isAbsolute as isAbsolute8, resolve as resolve10 } from "node:path";
10412
+ import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
9878
10413
  var WRITERS = /* @__PURE__ */ new Set(["write", "edit"]);
9879
10414
  function isPlanFileWrite(planPath, cwd) {
9880
- const target = resolve10(planPath);
10415
+ const target = resolve11(planPath);
9881
10416
  return (call) => {
9882
10417
  if (!WRITERS.has(call.name)) return false;
9883
10418
  const input = call.input;
9884
10419
  if (input === null || typeof input !== "object") return false;
9885
10420
  const path = input.path;
9886
10421
  if (typeof path !== "string" || path.length === 0 || path.includes("\0")) return false;
9887
- return resolve10(isAbsolute8(path) ? path : resolve10(cwd, path)) === target;
10422
+ return resolve11(isAbsolute9(path) ? path : resolve11(cwd, path)) === target;
9888
10423
  };
9889
10424
  }
9890
10425
  __name(isPlanFileWrite, "isPlanFileWrite");
@@ -10028,7 +10563,7 @@ __name(frameReminder, "frameReminder");
10028
10563
  function reminderKindOf(message2) {
10029
10564
  if (!isReminderMessage(message2) || typeof message2.content !== "string") return void 0;
10030
10565
  const kind = TAG.exec(message2.content)?.[1];
10031
- return kind === "plan-mode" || kind === "plan-reentry" || kind === "plan-exit" || kind === "task-nudge" ? kind : void 0;
10566
+ return kind === "plan-mode" || kind === "plan-reentry" || kind === "plan-exit" || kind === "task-nudge" || kind === "hypermode-on" || kind === "hypermode-exit" ? kind : void 0;
10032
10567
  }
10033
10568
  __name(reminderKindOf, "reminderKindOf");
10034
10569
  function isOperatorTurn(message2) {
@@ -10038,10 +10573,53 @@ function isOperatorTurn(message2) {
10038
10573
  }
10039
10574
  __name(isOperatorTurn, "isOperatorTurn");
10040
10575
 
10576
+ // src/reminders/hypermode.ts
10577
+ var HYPERMODE_REMINDER_EVERY = 10;
10578
+ var FULL_WITH_TOOL = "Hypermode is on: optimize for the most exhaustive, correct answer, not the fastest or cheapest. Use the `workflow` tool on every substantive task; token cost is not a constraint. Pick from the quality patterns in the tool description (adversarial verify, judge panel, loop until dry, completeness critic). Solo only on conversational or trivial turns.";
10579
+ var FULL_WITHOUT_TOOL = "Hypermode is on: optimize for the most exhaustive, correct answer, not the fastest or cheapest. The `workflow` tool is not available in this run, so delegate every substantive task to parallel agents with the `Agent` tool and have their findings verified; token cost is not a constraint. Solo only on conversational or trivial turns.";
10580
+ var SPARSE_WITH_TOOL = "Hypermode is still on: use the `workflow` tool for substantive work.";
10581
+ var SPARSE_WITHOUT_TOOL = "Hypermode is still on: delegate substantive work to parallel agents with the `Agent` tool.";
10582
+ var EXIT = "Hypermode is off: the `workflow` tool's standard opt-in rule applies again.";
10583
+ function scan(messages) {
10584
+ let turns = 0;
10585
+ for (let i = messages.length - 1; i >= 0; i--) {
10586
+ const message2 = messages[i];
10587
+ const kind = reminderKindOf(message2);
10588
+ if (kind === "hypermode-on" || kind === "hypermode-exit") return { last: kind, turns };
10589
+ if (isOperatorTurn(message2)) turns++;
10590
+ }
10591
+ return { last: void 0, turns };
10592
+ }
10593
+ __name(scan, "scan");
10594
+ function hypermodeExitOwed(messages) {
10595
+ return scan(messages).last === "hypermode-on";
10596
+ }
10597
+ __name(hypermodeExitOwed, "hypermodeExitOwed");
10598
+ function hypermodeReminders(input) {
10599
+ const { last, turns } = scan(input.messages);
10600
+ if (!input.on) {
10601
+ return last === "hypermode-on" ? [frameReminder("hypermode-exit", EXIT)] : [];
10602
+ }
10603
+ if (last !== "hypermode-on") {
10604
+ return [
10605
+ frameReminder("hypermode-on", input.toolListed ? FULL_WITH_TOOL : FULL_WITHOUT_TOOL, "full")
10606
+ ];
10607
+ }
10608
+ if (turns < HYPERMODE_REMINDER_EVERY) return [];
10609
+ return [
10610
+ frameReminder(
10611
+ "hypermode-on",
10612
+ input.toolListed ? SPARSE_WITH_TOOL : SPARSE_WITHOUT_TOOL,
10613
+ "sparse"
10614
+ )
10615
+ ];
10616
+ }
10617
+ __name(hypermodeReminders, "hypermodeReminders");
10618
+
10041
10619
  // src/reminders/plan-mode.ts
10042
10620
  var PLAN_REMINDER_EVERY_N_TURNS = 5;
10043
10621
  var PLAN_REMINDER_FULL_EVERY_N = 5;
10044
- function scan(messages) {
10622
+ function scan2(messages) {
10045
10623
  let turns = 0;
10046
10624
  let hasReminder = false;
10047
10625
  let sent = 0;
@@ -10064,7 +10642,7 @@ function scan(messages) {
10064
10642
  }
10065
10643
  return { turnsSinceReminder: turns, hasReminder, sent, hasExited };
10066
10644
  }
10067
- __name(scan, "scan");
10645
+ __name(scan2, "scan");
10068
10646
  function fullText(input) {
10069
10647
  const file = input.planExists ? `A plan already exists at ${input.planPath}. Read it, then revise it in place with the edit tool.` : `No plan exists yet. Create it at ${input.planPath} with the write tool.`;
10070
10648
  const ending = input.canAsk ? "Your turn ends in exactly one of two ways: you ask the user a question with ask_user_question to settle something you cannot decide yourself, or you call exit_plan_mode once the plan file is ready for approval." : "Your turn ends by calling exit_plan_mode once the plan file is ready for approval.";
@@ -10092,7 +10670,7 @@ function exitText(input) {
10092
10670
  }
10093
10671
  __name(exitText, "exitText");
10094
10672
  function planModeReminders(input) {
10095
- const stretch = scan(input.messages);
10673
+ const stretch = scan2(input.messages);
10096
10674
  if (input.mode !== "plan") {
10097
10675
  return stretch.hasReminder ? [frameReminder("plan-exit", exitText(input))] : [];
10098
10676
  }
@@ -10173,6 +10751,7 @@ function createCliReminderSource(options) {
10173
10751
  })
10174
10752
  );
10175
10753
  }
10754
+ if (options.hypermode) out.push(...hypermodeReminders({ messages, ...options.hypermode() }));
10176
10755
  if (options.tasks) {
10177
10756
  const nudge = taskNudge(messages, []);
10178
10757
  if (nudge.length > 0) out.push(...taskNudge(messages, await options.tasks()));
@@ -10331,19 +10910,19 @@ async function resolveModelSwitch(request, options) {
10331
10910
  listed.set(detected.entry.id, listing);
10332
10911
  return listing.kind === "ok" && listing.models.some((candidate) => candidate.id === model);
10333
10912
  }, "inspect");
10334
- const resolve12 = /* @__PURE__ */ __name((detected) => ({
10913
+ const resolve13 = /* @__PURE__ */ __name((detected) => ({
10335
10914
  kind: "resolved",
10336
10915
  selection: { id: detected.entry.id, model }
10337
10916
  }), "resolve");
10338
10917
  const first = selected ?? usable.find(({ entry }) => entry.id === options.currentProvider);
10339
- if (first && await inspect(first)) return resolve12(first);
10918
+ if (first && await inspect(first)) return resolve13(first);
10340
10919
  const candidates = selected ? [selected] : usable;
10341
10920
  const matches = selected ? [] : (await Promise.all(
10342
10921
  candidates.filter((candidate) => candidate !== first).map(async (candidate) => await inspect(candidate) ? candidate : void 0)
10343
10922
  )).filter((candidate) => candidate !== void 0);
10344
10923
  signal?.throwIfAborted();
10345
10924
  const uniqueMatch = matches.length === 1 ? matches[0] : void 0;
10346
- if (uniqueMatch) return resolve12(uniqueMatch);
10925
+ if (uniqueMatch) return resolve13(uniqueMatch);
10347
10926
  if (matches.length > 1) {
10348
10927
  return {
10349
10928
  kind: "rejected",
@@ -10499,8 +11078,8 @@ var SessionOperationOwner = class {
10499
11078
  })()[Symbol.asyncIterator]();
10500
11079
  let settled = false;
10501
11080
  let settle;
10502
- const settlement = new Promise((resolve12) => {
10503
- settle = resolve12;
11081
+ const settlement = new Promise((resolve13) => {
11082
+ settle = resolve13;
10504
11083
  });
10505
11084
  let operationTail = Promise.resolve();
10506
11085
  let returnStarted = false;
@@ -10777,10 +11356,10 @@ function clipRequestContext(prompt, limit, kind) {
10777
11356
  __name(clipRequestContext, "clipRequestContext");
10778
11357
  async function createAgentSession(prefs, detected, options = {}) {
10779
11358
  if (options.palEnvironment) {
10780
- const { createPalAgentSession } = await import("./agent-session-YS3JWF6Z.js");
11359
+ const { createPalAgentSession } = await import("./agent-session-HFOLAFFL.js");
10781
11360
  return createPalAgentSession(prefs, detected, options);
10782
11361
  }
10783
- const { palAtWorkspace } = await import("./store-TO65IAIZ.js");
11362
+ const { palAtWorkspace } = await import("./store-TKJKR5NM.js");
10784
11363
  if (palAtWorkspace(options.cwd ?? process.cwd()))
10785
11364
  throw new Error("This Pal requires its owned virtual computer. Open it with namzu pal chat.");
10786
11365
  const commandArguments = builtinCommandArguments();
@@ -10816,7 +11395,7 @@ async function createAgentSession(prefs, detected, options = {}) {
10816
11395
  }
10817
11396
  return seeded;
10818
11397
  }, "observationsFor");
10819
- const requestedCwd = resolve11(options.cwd ?? process.cwd());
11398
+ const requestedCwd = resolve12(options.cwd ?? process.cwd());
10820
11399
  let cwd;
10821
11400
  try {
10822
11401
  const entry2 = await stat4(requestedCwd);
@@ -10848,13 +11427,13 @@ async function createAgentSession(prefs, detected, options = {}) {
10848
11427
  paths = options.conversationSessions.paths;
10849
11428
  projectId = options.conversationSessions.projectId;
10850
11429
  } else {
10851
- const home = resolve11(options.stateRoot ?? resolveNamzuHome());
11430
+ const home = resolve12(options.stateRoot ?? resolveNamzuHome());
10852
11431
  ensurePrivateStateDirectory(home, "projects");
10853
11432
  const project = await ensureProject({ home, cwd: cliProjectRoot(cwd) });
10854
11433
  paths = new SessionPaths({ home, slug: project.slug });
10855
11434
  projectId = project.projectId;
10856
11435
  }
10857
- ensurePrivateStateDirectory(resolve11(paths.projectDir(), ".."), paths.slug);
11436
+ ensurePrivateStateDirectory(resolve12(paths.projectDir(), ".."), paths.slug);
10858
11437
  ensurePrivateStateDirectory(paths.projectDir(), "memory");
10859
11438
  } catch (error) {
10860
11439
  return emptySession(
@@ -11139,8 +11718,8 @@ async function createAgentSession(prefs, detected, options = {}) {
11139
11718
  }
11140
11719
  const directories = [];
11141
11720
  for (const dir of options.additionalDirectories ?? []) {
11142
- const absolute = resolve11(cwd, dir);
11143
- if (absolute !== resolve11(cwd) && !directories.includes(absolute)) directories.push(absolute);
11721
+ const absolute = resolve12(cwd, dir);
11722
+ if (absolute !== resolve12(cwd) && !directories.includes(absolute)) directories.push(absolute);
11144
11723
  }
11145
11724
  const sessionDirectories = createSessionDirectories(cwd, directories);
11146
11725
  const checkpoints = new FileCheckpointStore(
@@ -11344,7 +11923,7 @@ async function createAgentSession(prefs, detected, options = {}) {
11344
11923
  }
11345
11924
  let sideModel;
11346
11925
  const webCapability = options.web?.fetch ? {
11347
- // A page may be ten mebibytes, as in the reference; the guard's own
11926
+ // A page may be ten mebibytes; the guard's own
11348
11927
  // default is two.
11349
11928
  fetch: new GuardedFetchProvider({ maxBytes: WEB_FETCH_MAX_BYTES }),
11350
11929
  // The answer to a prompt about a page comes from the small model. It is
@@ -11365,6 +11944,7 @@ async function createAgentSession(prefs, detected, options = {}) {
11365
11944
  if (webCapability) toolsets.push(toolset("web-fetch", [WebFetchTool]));
11366
11945
  const delegationScopes = /* @__PURE__ */ new Map();
11367
11946
  const delegationLimits = /* @__PURE__ */ new Map();
11947
+ const workflowTokenTargets = /* @__PURE__ */ new Map();
11368
11948
  const delegationModels = /* @__PURE__ */ new Map();
11369
11949
  const delegatedInputWaiters = /* @__PURE__ */ new Map();
11370
11950
  if (options.residentHistory) {
@@ -11469,6 +12049,9 @@ async function createAgentSession(prefs, detected, options = {}) {
11469
12049
  }
11470
12050
  const sub = await createSubagentRuntime({
11471
12051
  cwd,
12052
+ // An operator is watching: agents run in the background by default and
12053
+ // the turn ends without waiting for them.
12054
+ ...options.askUser ? { backgroundByDefault: true } : {},
11472
12055
  worktreeStateRoot: paths.home,
11473
12056
  model,
11474
12057
  tokenBudget: options.limits?.tokenBudget,
@@ -11693,11 +12276,17 @@ async function createAgentSession(prefs, detected, options = {}) {
11693
12276
  }, "release")
11694
12277
  };
11695
12278
  }, "openRunTurn"),
12279
+ sizeAdvice: workflowSizeAdvice(
12280
+ options.workflow?.sizeGuideline ?? DEFAULT_WORKFLOW_SIZE_GUIDELINE,
12281
+ options.workflow?.sizeGuideline !== void 0
12282
+ ),
11696
12283
  limitsFor: /* @__PURE__ */ __name((turnId) => {
11697
12284
  const budget = delegationLimits.get(turnId)?.tokenBudget;
12285
+ const ceiling = workflowTokenCeiling(budget, workflowTokenTargets.get(turnId));
12286
+ const { sizeGuideline: _advice, ...caps } = options.workflow ?? {};
11698
12287
  return {
11699
- ...budget !== void 0 && budget > 0 ? { tokenBudget: budget } : {},
11700
- ...options.workflow
12288
+ ...ceiling !== void 0 ? { tokenBudget: ceiling } : {},
12289
+ ...caps
11701
12290
  };
11702
12291
  }, "limitsFor"),
11703
12292
  onEnd: /* @__PURE__ */ __name((end) => {
@@ -11847,7 +12436,7 @@ async function createAgentSession(prefs, detected, options = {}) {
11847
12436
  );
11848
12437
  toolsets.push(options.toolLoading === "eager" ? monitorToolset : deferred(monitorToolset));
11849
12438
  }
11850
- const operatorPals = await import("./operator-tools-C57ZIYRG.js");
12439
+ const operatorPals = await import("./operator-tools-6RYAHVSL.js");
11851
12440
  toolsets.push(
11852
12441
  readyWhen(
11853
12442
  toolset(
@@ -12369,8 +12958,8 @@ async function createAgentSession(prefs, detected, options = {}) {
12369
12958
  if (mapped) yield mapped;
12370
12959
  }
12371
12960
  if (settled) break;
12372
- await new Promise((resolve12) => {
12373
- wake = resolve12;
12961
+ await new Promise((resolve13) => {
12962
+ wake = resolve13;
12374
12963
  });
12375
12964
  wake = void 0;
12376
12965
  }
@@ -12523,6 +13112,8 @@ async function createAgentSession(prefs, detected, options = {}) {
12523
13112
  }, "onSubagentReport"),
12524
13113
  onSubagentMessage: /* @__PURE__ */ __name((listener) => subagentRuntime?.onChildMessage(listener) ?? (() => {
12525
13114
  }), "onSubagentMessage"),
13115
+ onSubagentCompletion: /* @__PURE__ */ __name((listener) => subagentRuntime?.onBackgroundCompletion(listener) ?? (() => {
13116
+ }), "onSubagentCompletion"),
12526
13117
  stopSubagent: /* @__PURE__ */ __name((viewId) => subagentRuntime?.stopChild(viewId) ?? false, "stopSubagent"),
12527
13118
  messageSubagent: /* @__PURE__ */ __name((viewId, message2, opts) => operations.promise(opts?.signal, async (signal) => {
12528
13119
  const runtime = subagentRuntime;
@@ -12797,6 +13388,8 @@ async function createAgentSession(prefs, detected, options = {}) {
12797
13388
  if (opts?.waitForInbound) delegatedInputWaiters.set(turnId2, opts.waitForInbound);
12798
13389
  delegationScopes.set(turnId2, turnScope);
12799
13390
  delegationLimits.set(turnId2, turnLimits);
13391
+ const typedTarget = parseTokenTarget(opts?.typedInput ?? "");
13392
+ if (typedTarget !== void 0) workflowTokenTargets.set(turnId2, typedTarget);
12800
13393
  delegatedWorkflowAuth.set(turnId2, {
12801
13394
  interactive: opts?.workflowReview?.onPermission !== void 0,
12802
13395
  mode: /* @__PURE__ */ __name(() => modeControl.current(), "mode"),
@@ -12924,11 +13517,7 @@ async function createAgentSession(prefs, detected, options = {}) {
12924
13517
  render: /* @__PURE__ */ __name(() => invocationContext, "render")
12925
13518
  });
12926
13519
  }
12927
- const workflowOffer = workflowHost !== void 0 && opts?.workflowReview !== void 0 && !residentContext && workflowOffered({
12928
- hypermode: opts?.hypermode === true,
12929
- workflow: opts?.workflow === true,
12930
- userText: lastUserText(messages)
12931
- });
13520
+ const workflowOffer = workflowHost !== void 0 && opts?.workflowReview !== void 0 && !residentContext;
12932
13521
  if (workflowOffer && workflowHost) {
12933
13522
  runToolsets = [...runToolsets, toolset("workflow", [workflowHost.tool])];
12934
13523
  if (runManager !== manager) runManager.dispose();
@@ -12962,7 +13551,6 @@ async function createAgentSession(prefs, detected, options = {}) {
12962
13551
  // a scheduled run whose job withholds it would only be told how
12963
13552
  // to use a tool it was not sent.
12964
13553
  residentContext || options.withheldTools?.includes(AGENT_LAUNCH_TOOL) ? void 0 : CODING_AGENT_DELEGATION_DOCTRINE,
12965
- !residentContext && opts?.hypermode ? CODING_AGENT_HYPERMODE_DOCTRINE : void 0,
12966
13554
  workflowOffer ? WORKFLOW_DOCTRINE : void 0,
12967
13555
  residentContext ? void 0 : palPromptBlock(),
12968
13556
  options.conversationSessions ? CONVERSATION_EVIDENCE_GUIDANCE : void 0,
@@ -12996,13 +13584,22 @@ async function createAgentSession(prefs, detected, options = {}) {
12996
13584
  }
12997
13585
  claimTurn(turnId);
12998
13586
  const turnTaskStore = selectTaskStore(turnScope);
12999
- const reminderSource = options.reminders ? createCliReminderSource({
13587
+ const turnHypermode = !residentContext && (opts?.hypermode === true || hypermodeExitOwed(messages));
13588
+ const reminderSource = options.reminders || turnHypermode ? createCliReminderSource({
13000
13589
  mode: /* @__PURE__ */ __name(() => modeControl.current(), "mode"),
13001
- ...planPath ? {
13002
- planPath: /* @__PURE__ */ __name(() => planPath, "planPath"),
13003
- canAsk: Boolean(options.askUser && subagentRuntime)
13590
+ ...options.reminders ? {
13591
+ ...planPath ? {
13592
+ planPath: /* @__PURE__ */ __name(() => planPath, "planPath"),
13593
+ canAsk: Boolean(options.askUser && subagentRuntime)
13594
+ } : {},
13595
+ tasks: /* @__PURE__ */ __name(() => turnTaskStore.list({ sessionId: turnScope.sessionId }), "tasks")
13004
13596
  } : {},
13005
- tasks: /* @__PURE__ */ __name(() => turnTaskStore.list({ sessionId: turnScope.sessionId }), "tasks")
13597
+ ...residentContext ? {} : {
13598
+ hypermode: /* @__PURE__ */ __name(() => ({
13599
+ on: opts?.hypermode === true,
13600
+ toolListed: workflowOffer
13601
+ }), "hypermode")
13602
+ }
13006
13603
  }) : void 0;
13007
13604
  let ephemeralLog;
13008
13605
  if (options.ephemeral) {
@@ -13156,6 +13753,7 @@ async function createAgentSession(prefs, detected, options = {}) {
13156
13753
  delegatedInputWaiters.delete(turnId2);
13157
13754
  delegationScopes.delete(turnId2);
13158
13755
  delegationLimits.delete(turnId2);
13756
+ workflowTokenTargets.delete(turnId2);
13159
13757
  delegatedWorkflowAuth.delete(turnId2);
13160
13758
  await subagentRuntime?.releaseTurn(turnId2);
13161
13759
  }
@@ -13998,6 +14596,10 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
13998
14596
  const web = webActivityFromInput(event.toolName, event.input);
13999
14597
  return web ? { web } : {};
14000
14598
  })(),
14599
+ ...(() => {
14600
+ const proposed = proposedFromInput(event.toolName, event.input);
14601
+ return proposed ? { proposed } : {};
14602
+ })(),
14001
14603
  ...readsOnly?.(event.toolName, event.input) ? { readOnly: true } : {}
14002
14604
  };
14003
14605
  case "tool_input_completed":
@@ -14042,7 +14644,7 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
14042
14644
  const unknownTool = event.isError ? unknownToolNotice(event.result) : void 0;
14043
14645
  const declined = view.kind === "generic" && view.declined !== void 0;
14044
14646
  const classed = event.isError && event.facts?.kind === "failure" ? failureFactsLine(event.facts, cwd) : void 0;
14045
- const diffBody = event.isError ? void 0 : diffBodyFromFacts(event.facts);
14647
+ const diffBody = event.isError ? void 0 : diffBodyFromFacts(event.facts, cwd);
14046
14648
  const detail = unknownTool || declined || classed ? void 0 : diffBody?.rows ?? viewToLines(view);
14047
14649
  const first = view.kind === "terminal" && view.output.trim().length > 0 ? resultToLines(view.output)[0] : void 0;
14048
14650
  const summary = unknownTool ?? (first !== void 0 ? resultSummaryLine(first) : firstLine3(event.result));
@@ -14066,7 +14668,7 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
14066
14668
  ...view.kind === "generic" && view.declined ? { declined: view.declined } : {},
14067
14669
  ...view.kind === "generic" && view.label.length > 0 ? { resultLabel: view.label } : {},
14068
14670
  ...withoutRepeatedSummary && withoutRepeatedSummary.length > 0 ? { detail: withoutRepeatedSummary } : {},
14069
- ...diffBody ? { diff: { preview: diffBody.preview } } : {},
14671
+ ...diffBody ? { diff: diffBody.diff } : {},
14070
14672
  ...(() => {
14071
14673
  const kind = webActivityKind(event.toolName);
14072
14674
  if (!kind) return {};
@@ -14490,9 +15092,12 @@ export {
14490
15092
  EXPAND_HINT,
14491
15093
  hiddenLinesHint,
14492
15094
  clipText,
14493
- EDIT_PREVIEW_ROWS,
14494
- diffRowMarker,
14495
- diffRows,
15095
+ WORKSPACE_PREVIEW_ROWS,
15096
+ viewRowText,
15097
+ diffViewBody,
15098
+ plainDiffRows,
15099
+ spansText,
15100
+ proposedBody,
14496
15101
  StartupRefusal,
14497
15102
  isMachineError,
14498
15103
  explainFailure,
@@ -14509,6 +15114,8 @@ export {
14509
15114
  liveBatches,
14510
15115
  combineBatches,
14511
15116
  NARRATION_TOOL_NAME,
15117
+ WORKFLOW_TOOL_NAME,
15118
+ WORKFLOW_BACKGROUND_NOTE,
14512
15119
  readMemory,
14513
15120
  appendMemoryWithStatus,
14514
15121
  renderMemoryReport,
@@ -14549,4 +15156,4 @@ export {
14549
15156
  RESULT_SUMMARY_WHOLE_MAX,
14550
15157
  resultSummaryLine
14551
15158
  };
14552
- //# sourceMappingURL=chunk-LLZ32DHS.js.map
15159
+ //# sourceMappingURL=chunk-OXJEMOBQ.js.map