@namzu/cli 44.1.0 → 44.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bin-main.d.ts +1 -1
  3. package/dist/bin-main.d.ts.map +1 -1
  4. package/dist/bin.js +2 -2
  5. package/dist/bin.js.map +1 -1
  6. package/dist/chunks/acp-OUBJWH5B.js +7754 -0
  7. package/dist/chunks/acp-OUBJWH5B.js.map +6 -0
  8. package/dist/chunks/{activity-command-UCUGH2LW.js → activity-command-R7MUSZIY.js} +16 -15
  9. package/dist/chunks/activity-command-R7MUSZIY.js.map +6 -0
  10. package/dist/chunks/{add-TNGQA6CH.js → add-PSEIDDRW.js} +22 -19
  11. package/dist/chunks/add-PSEIDDRW.js.map +6 -0
  12. package/dist/chunks/{agent-F7HY5T3U.js → agent-YPEXUYPH.js} +36 -31
  13. package/dist/chunks/agent-session-EZB2OYG3.js +65 -0
  14. package/dist/chunks/{archive-3L6VJWS4.js → archive-ET4PXE34.js} +11 -10
  15. package/dist/chunks/archive-ET4PXE34.js.map +6 -0
  16. package/dist/chunks/{bin-main-YEEDVZXH.js → bin-main-PMB57AZJ.js} +25 -15
  17. package/dist/chunks/bin-main-PMB57AZJ.js.map +6 -0
  18. package/dist/chunks/binding-K6RIQ5AP.js +17 -0
  19. package/dist/chunks/{browser-UHJ43DUU.js → browser-SKTIAVBF.js} +7 -7
  20. package/dist/chunks/{chat-DDPHHLQJ.js → chat-AVIVXXMD.js} +20 -19
  21. package/dist/chunks/chat-AVIVXXMD.js.map +6 -0
  22. package/dist/chunks/chunk-26C37THH.js +867 -0
  23. package/dist/chunks/chunk-26C37THH.js.map +6 -0
  24. package/dist/chunks/{chunk-4YJ4EI4X.js → chunk-2EHPXO4E.js} +3 -3
  25. package/dist/chunks/{chunk-F37FVPVW.js → chunk-2NI5NS5S.js} +3 -3
  26. package/dist/chunks/{chunk-SEYQW7MF.js → chunk-2U5M5IYH.js} +6 -6
  27. package/dist/chunks/{chunk-ZRPLJYFM.js → chunk-2X6JZAKH.js} +12 -12
  28. package/dist/chunks/{chunk-72ZSHKT7.js → chunk-2Y26DLOF.js} +27 -10
  29. package/dist/chunks/{chunk-72ZSHKT7.js.map → chunk-2Y26DLOF.js.map} +1 -1
  30. package/dist/chunks/{chunk-4Z4VYMTT.js → chunk-3QGJXD7U.js} +5 -5
  31. package/dist/chunks/{chunk-UZYTWQYW.js → chunk-435DYOG4.js} +2 -2
  32. package/dist/chunks/{chunk-CFHRQGO2.js → chunk-4OXIJ2EF.js} +3 -3
  33. package/dist/chunks/{chunk-SYOISB7S.js → chunk-6EJFXJDO.js} +219 -76
  34. package/dist/chunks/chunk-6EJFXJDO.js.map +6 -0
  35. package/dist/chunks/{chunk-VPZBVRXT.js → chunk-6FWFSPUL.js} +5 -3
  36. package/dist/chunks/chunk-6FWFSPUL.js.map +6 -0
  37. package/dist/chunks/chunk-6HTC5TQ3.js +89 -0
  38. package/dist/chunks/chunk-6HTC5TQ3.js.map +6 -0
  39. package/dist/chunks/chunk-6IDFHPY3.js +413 -0
  40. package/dist/chunks/chunk-6IDFHPY3.js.map +6 -0
  41. package/dist/chunks/chunk-7FPKSX4M.js +61 -0
  42. package/dist/chunks/chunk-7FPKSX4M.js.map +6 -0
  43. package/dist/chunks/{chunk-MT4ONV77.js → chunk-7QQOUCGI.js} +16 -14
  44. package/dist/chunks/chunk-7QQOUCGI.js.map +6 -0
  45. package/dist/chunks/{chunk-3A4UOMMU.js → chunk-7TEXDZVO.js} +17 -3
  46. package/dist/chunks/chunk-7TEXDZVO.js.map +6 -0
  47. package/dist/chunks/{chunk-WEAIQEWJ.js → chunk-A5GTZ7R2.js} +2 -2
  48. package/dist/chunks/{chunk-DYJY4COC.js → chunk-ACSG5R5P.js} +3 -3
  49. package/dist/chunks/{chunk-6WXVHAS6.js → chunk-AI6PBE5G.js} +2 -2
  50. package/dist/chunks/{chunk-HI7UZRIV.js → chunk-AX5ESG6K.js} +2 -2
  51. package/dist/chunks/{chunk-WOY7SAUB.js → chunk-B3XIVOLM.js} +2 -2
  52. package/dist/chunks/{chunk-B45X6IGD.js → chunk-BGKQCLLH.js} +242 -447
  53. package/dist/chunks/chunk-BGKQCLLH.js.map +6 -0
  54. package/dist/chunks/chunk-BT7ZELXJ.js +63 -0
  55. package/dist/chunks/chunk-BT7ZELXJ.js.map +6 -0
  56. package/dist/chunks/{chunk-ZNY5ZPBB.js → chunk-DECJPLLA.js} +13 -13
  57. package/dist/chunks/{chunk-AH3DBEMR.js → chunk-DFCJYRT5.js} +2 -2
  58. package/dist/chunks/{chunk-TKCRF7DK.js → chunk-DQLSLXDF.js} +7 -7
  59. package/dist/chunks/chunk-EXFSMYH4.js +83 -0
  60. package/dist/chunks/chunk-EXFSMYH4.js.map +6 -0
  61. package/dist/chunks/{chunk-KEOBHC65.js → chunk-FHQTXWDA.js} +19 -7
  62. package/dist/chunks/chunk-FHQTXWDA.js.map +6 -0
  63. package/dist/chunks/chunk-G73G2WGR.js +242 -0
  64. package/dist/chunks/chunk-G73G2WGR.js.map +6 -0
  65. package/dist/chunks/{chunk-CLVP63AB.js → chunk-GANFMGV7.js} +5 -5
  66. package/dist/chunks/{chunk-GKMPPOXW.js → chunk-GBS6ATYF.js} +2 -2
  67. package/dist/chunks/{chunk-5PJIJTP2.js → chunk-GCCFTP47.js} +4 -4
  68. package/dist/chunks/{chunk-UXDNVRJ5.js → chunk-GNEDN6MU.js} +14 -14
  69. package/dist/chunks/{chunk-7DYH6R67.js → chunk-HB5ZN5KQ.js} +2 -2
  70. package/dist/chunks/{chunk-BKZW4DRY.js → chunk-HELINLSD.js} +2 -2
  71. package/dist/chunks/{chunk-OERIIND6.js → chunk-HKCIZR5P.js} +13 -13
  72. package/dist/chunks/chunk-HRJPVPSU.js +164 -0
  73. package/dist/chunks/chunk-HRJPVPSU.js.map +6 -0
  74. package/dist/chunks/{chunk-4LHT2QDO.js → chunk-HTBMDD6Y.js} +8 -8
  75. package/dist/chunks/{chunk-WTPIGLX7.js → chunk-I5E4MT3C.js} +4 -4
  76. package/dist/chunks/{chunk-GX74LDJL.js → chunk-IJZ7SLBV.js} +3 -3
  77. package/dist/chunks/{chunk-WIU25RLZ.js → chunk-ITA57VY5.js} +7 -5
  78. package/dist/chunks/chunk-ITA57VY5.js.map +6 -0
  79. package/dist/chunks/{chunk-OZLMT5WB.js → chunk-IZVN6K6U.js} +4 -4
  80. package/dist/chunks/{chunk-XHCUNLST.js → chunk-JL64XHSL.js} +55 -5
  81. package/dist/chunks/chunk-JL64XHSL.js.map +6 -0
  82. package/dist/chunks/chunk-KLKAK2O5.js +5817 -0
  83. package/dist/chunks/chunk-KLKAK2O5.js.map +6 -0
  84. package/dist/chunks/{chunk-VKYIL6BJ.js → chunk-L2NNJ4XL.js} +3 -3
  85. package/dist/chunks/{chunk-IDU2KLLT.js → chunk-LF76CVOZ.js} +4 -4
  86. package/dist/chunks/{chunk-N4IDJ5V2.js → chunk-LFPTXRMM.js} +2 -2
  87. package/dist/chunks/chunk-LG27EJU6.js +189 -0
  88. package/dist/chunks/chunk-LG27EJU6.js.map +6 -0
  89. package/dist/chunks/{chunk-SBKOTD2M.js → chunk-LKJBDF7W.js} +15 -3
  90. package/dist/chunks/chunk-LKJBDF7W.js.map +6 -0
  91. package/dist/chunks/chunk-LKODRKMZ.js +575 -0
  92. package/dist/chunks/chunk-LKODRKMZ.js.map +6 -0
  93. package/dist/chunks/{chunk-I47Q4G4X.js → chunk-LQRP2VRQ.js} +4 -4
  94. package/dist/chunks/{chunk-PEJV6XTK.js → chunk-LYGD5P7O.js} +3 -3
  95. package/dist/chunks/{chunk-JS4C7HNH.js → chunk-M2OZ4SVS.js} +3 -3
  96. package/dist/chunks/{chunk-RBTQ5ZQU.js → chunk-MGZSEPDY.js} +2 -2
  97. package/dist/chunks/{chunk-W6OOY44A.js → chunk-MJBGVVI5.js} +3 -3
  98. package/dist/chunks/{chunk-76DOZYZP.js → chunk-MYL75RA4.js} +2 -2
  99. package/dist/chunks/chunk-PIVHVYCN.js +3925 -0
  100. package/dist/chunks/chunk-PIVHVYCN.js.map +6 -0
  101. package/dist/chunks/{chunk-B5KDTZYH.js → chunk-PMX2WTZL.js} +2 -2
  102. package/dist/chunks/{chunk-J7PV6OOX.js → chunk-QWSZ5P4C.js} +6 -6
  103. package/dist/chunks/{chunk-TBIX6JRE.js → chunk-R66H2G5R.js} +12 -1
  104. package/dist/chunks/chunk-R66H2G5R.js.map +6 -0
  105. package/dist/chunks/{chunk-EBN4YPIN.js → chunk-RSIWTHYS.js} +3 -3
  106. package/dist/chunks/{chunk-IYNTTEQA.js → chunk-S4QOQGAT.js} +2 -2
  107. package/dist/chunks/chunk-S7WRWA25.js +33 -0
  108. package/dist/chunks/chunk-S7WRWA25.js.map +6 -0
  109. package/dist/chunks/{chunk-UVSKCXL6.js → chunk-SGRO4RJP.js} +2 -2
  110. package/dist/chunks/{chunk-NB5LGTUL.js → chunk-SJFPZPOJ.js} +83 -20
  111. package/dist/chunks/chunk-SJFPZPOJ.js.map +6 -0
  112. package/dist/chunks/{chunk-3LCJJT2F.js → chunk-TZZOQ62Z.js} +2 -2
  113. package/dist/chunks/chunk-U4SST7AD.js +219 -0
  114. package/dist/chunks/chunk-U4SST7AD.js.map +6 -0
  115. package/dist/chunks/{chunk-3UK2GDVX.js → chunk-UGDZ7MLG.js} +4 -4
  116. package/dist/chunks/chunk-VDKDXDOH.js +290 -0
  117. package/dist/chunks/chunk-VDKDXDOH.js.map +6 -0
  118. package/dist/chunks/{chunk-DASSBULE.js → chunk-VFVWHYHT.js} +4 -4
  119. package/dist/chunks/{chunk-WQ72OU4F.js → chunk-VZ4PKWLF.js} +2 -2
  120. package/dist/chunks/{chunk-Y6HB4AJE.js → chunk-WKFHQQOU.js} +2 -2
  121. package/dist/chunks/{chunk-WUUZJCAA.js → chunk-WKPRYH24.js} +3 -3
  122. package/dist/chunks/{chunk-7HRVTREO.js → chunk-WQFHJ4TO.js} +3 -3
  123. package/dist/chunks/{chunk-OAISYZM4.js → chunk-WYJ3CNXX.js} +83 -41
  124. package/dist/chunks/chunk-WYJ3CNXX.js.map +6 -0
  125. package/dist/chunks/{chunk-V2EGJD7W.js → chunk-XPLHAOGE.js} +2 -2
  126. package/dist/chunks/{chunk-WG5LLHJX.js → chunk-XX2SP5AM.js} +3 -3
  127. package/dist/chunks/{chunk-YSGVHT54.js → chunk-YDSWGJWF.js} +2 -2
  128. package/dist/chunks/{chunk-MZUVCANX.js → chunk-YJ6NWB2B.js} +2 -2
  129. package/dist/chunks/{chunk-OKDDIWD7.js → chunk-YTE3QIH3.js} +99941 -80958
  130. package/dist/chunks/chunk-YTE3QIH3.js.map +6 -0
  131. package/dist/chunks/{chunk-EYYWIMVU.js → chunk-YUYNIAJX.js} +6 -6
  132. package/dist/chunks/{chunk-RMBD3YZ5.js → chunk-YXIG4OT2.js} +2 -2
  133. package/dist/chunks/{cli-runtime-VRAUDAKZ.js → cli-runtime-F4MEMBDL.js} +11 -10
  134. package/dist/chunks/cli-runtime-F4MEMBDL.js.map +6 -0
  135. package/dist/chunks/{commands-Q3FSPHGU.js → commands-ZCNZVYTG.js} +6 -6
  136. package/dist/chunks/{crash-report-6XW44BV6.js → crash-report-K53VF4H5.js} +6 -6
  137. package/dist/chunks/{dist-VEEXDONU.js → dist-6IPPA55L.js} +2 -2
  138. package/dist/chunks/{dist-KNYBFHXB.js → dist-H53G25BE.js} +2 -2
  139. package/dist/chunks/{dist-6XC3YARD.js → dist-L5LBM77I.js} +2 -2
  140. package/dist/chunks/{dist-4SPA7VSK.js → dist-RIH2Q2ER.js} +2 -2
  141. package/dist/chunks/{dist-VYUROH2A.js → dist-RTIKLSUV.js} +2 -2
  142. package/dist/chunks/{dist-5DDSGOSA.js → dist-T6KE7URX.js} +2 -2
  143. package/dist/chunks/dist-VSJGDIXP.js +2754 -0
  144. package/dist/chunks/{dist-NG6RAO2C.js → dist-XNGK3C4G.js} +2 -2
  145. package/dist/chunks/{doctor-ZDXK5W6E.js → doctor-DOCGTBME.js} +18 -16
  146. package/dist/chunks/{drain-NQLOKED3.js → drain-LT3J2MEA.js} +13 -13
  147. package/dist/chunks/entry-UHKDLPDS.js +232 -0
  148. package/dist/chunks/entry-UHKDLPDS.js.map +6 -0
  149. package/dist/chunks/{eval-A2G4KS62.js → eval-DH26W2QK.js} +2 -2
  150. package/dist/chunks/{exec-EWGVFJNZ.js → exec-QGAHWUUQ.js} +57 -47
  151. package/dist/chunks/exec-QGAHWUUQ.js.map +6 -0
  152. package/dist/chunks/{github-FH7PPWVW.js → github-JTMZJAZL.js} +4 -4
  153. package/dist/chunks/{home-5N3FSKF7.js → home-GGVNSCCU.js} +3 -3
  154. package/dist/chunks/host-6CUYPX4T.js +23 -0
  155. package/dist/chunks/{host-queries-R2KVVFTJ.js → host-queries-4EW7M54U.js} +16 -15
  156. package/dist/chunks/host-queries-4EW7M54U.js.map +6 -0
  157. package/dist/chunks/{learn-SAVZB4Q7.js → learn-PAO3IOYA.js} +13 -13
  158. package/dist/chunks/{learn-builtin-ZWX7Q3X2.js → learn-builtin-DXZUXOGG.js} +19 -19
  159. package/dist/chunks/{lifecycle-2RFARBGC.js → lifecycle-KDN4D7DP.js} +31 -27
  160. package/dist/chunks/{list-D63Z2LT4.js → list-KSP6S57Z.js} +16 -15
  161. package/dist/chunks/list-KSP6S57Z.js.map +6 -0
  162. package/dist/chunks/{live-XC3V46W3.js → live-XWJ2JOFO.js} +16 -14
  163. package/dist/chunks/{login-NIX66V67.js → login-3Q2HKQUW.js} +10 -8
  164. package/dist/chunks/{logs-LJSWQUT5.js → logs-UYB55HOX.js} +5 -5
  165. package/dist/chunks/{mcp-OCEDFJA5.js → mcp-JWSI4KA6.js} +25 -22
  166. package/dist/chunks/mcp-JWSI4KA6.js.map +6 -0
  167. package/dist/chunks/{message-command-THJZ4EIM.js → message-command-YP6TGD3K.js} +50 -45
  168. package/dist/chunks/message-command-YP6TGD3K.js.map +6 -0
  169. package/dist/chunks/open-QUDHJK5H.js +19 -0
  170. package/dist/chunks/{operator-tools-C7KZGWFJ.js → operator-tools-43NL7HKO.js} +15 -14
  171. package/dist/chunks/operator-tools-43NL7HKO.js.map +6 -0
  172. package/dist/chunks/{output-schema-4BLF2AFQ.js → output-schema-TLW5FA37.js} +3 -3
  173. package/dist/chunks/{pal-7IB6LZJX.js → pal-EZE2KLYZ.js} +16 -14
  174. package/dist/chunks/pal-EZE2KLYZ.js.map +6 -0
  175. package/dist/chunks/palette-WDPS7W6Q.js +15 -0
  176. package/dist/chunks/peers-OBENILN2.js +18 -0
  177. package/dist/chunks/prefix-MLAG4KTK.js +14 -0
  178. package/dist/chunks/{providers-NCGZXLFH.js → providers-PJIHLTXP.js} +22 -18
  179. package/dist/chunks/pty-HDEXCPR6.js +29 -0
  180. package/dist/chunks/pty-HDEXCPR6.js.map +6 -0
  181. package/dist/chunks/{resident-EODT4UTE.js → resident-2GHB3BKR.js} +30 -28
  182. package/dist/chunks/resident-2GHB3BKR.js.map +6 -0
  183. package/dist/chunks/resume-FHPY2RU3.js +24 -0
  184. package/dist/chunks/resume-FHPY2RU3.js.map +6 -0
  185. package/dist/chunks/{resume-command-YJ6LCKON.js → resume-command-VB6VA64L.js} +5 -5
  186. package/dist/chunks/resume-command-VB6VA64L.js.map +6 -0
  187. package/dist/chunks/{schedule-LWY6AMC3.js → schedule-42N4JOQJ.js} +9 -9
  188. package/dist/chunks/{service-RQZF7NCJ.js → service-6WGZKKI4.js} +34 -30
  189. package/dist/chunks/service-6WGZKKI4.js.map +6 -0
  190. package/dist/chunks/{session-step-YIL6LV2J.js → session-step-SBWIM4MZ.js} +15 -15
  191. package/dist/chunks/session-step-SBWIM4MZ.js.map +6 -0
  192. package/dist/chunks/{skills-3KYQHENX.js → skills-V3VDOL3D.js} +11 -11
  193. package/dist/chunks/spaces-6II4JYTZ.js +231 -0
  194. package/dist/chunks/spaces-6II4JYTZ.js.map +6 -0
  195. package/dist/chunks/{start-check-OKGZSWUG.js → start-check-MRSPS5JT.js} +2 -2
  196. package/dist/chunks/start-check-MRSPS5JT.js.map +6 -0
  197. package/dist/chunks/{state-ER7R4WEN.js → state-HX3XRNPC.js} +2 -2
  198. package/dist/chunks/store-7P462EUD.js +17 -0
  199. package/dist/chunks/store-7P462EUD.js.map +6 -0
  200. package/dist/chunks/{store-C654AJPG.js → store-FUQE7EWU.js} +13 -10
  201. package/dist/chunks/store-FUQE7EWU.js.map +6 -0
  202. package/dist/chunks/{store-EQQRW7NJ.js → store-IX6KNJA4.js} +6 -6
  203. package/dist/chunks/store-IX6KNJA4.js.map +6 -0
  204. package/dist/chunks/{store-HWGRIA5X.js → store-MQXI7G2H.js} +4 -4
  205. package/dist/chunks/store-MQXI7G2H.js.map +6 -0
  206. package/dist/chunks/{tui-UYHIDUPB.js → tui-PH5B6UCO.js} +1844 -838
  207. package/dist/chunks/tui-PH5B6UCO.js.map +6 -0
  208. package/dist/chunks/{upgrade-D6Q5EAMR.js → upgrade-HDW5MWLE.js} +6 -6
  209. package/dist/chunks/{worktree-UFFQMC2B.js → worktree-MLFYZF56.js} +13 -12
  210. package/dist/chunks/worktree-MLFYZF56.js.map +6 -0
  211. package/dist/cli.d.ts.map +1 -1
  212. package/dist/commands/exec-json.d.ts.map +1 -1
  213. package/dist/commands/manifest.d.ts +1 -0
  214. package/dist/commands/manifest.d.ts.map +1 -1
  215. package/dist/commands/spaces.d.ts +42 -0
  216. package/dist/commands/spaces.d.ts.map +1 -0
  217. package/dist/config/load.d.ts.map +1 -1
  218. package/dist/config/schema.d.ts +7 -0
  219. package/dist/config/schema.d.ts.map +1 -1
  220. package/dist/doctor/checks/index.d.ts +2 -1
  221. package/dist/doctor/checks/index.d.ts.map +1 -1
  222. package/dist/doctor/checks/terminal.d.ts +12 -0
  223. package/dist/doctor/checks/terminal.d.ts.map +1 -0
  224. package/dist/index.js +24 -21
  225. package/dist/integrations/accounts/activity.d.ts +39 -0
  226. package/dist/integrations/accounts/activity.d.ts.map +1 -0
  227. package/dist/integrations/accounts/binding.d.ts +30 -0
  228. package/dist/integrations/accounts/binding.d.ts.map +1 -0
  229. package/dist/integrations/accounts/codex-login.d.ts +33 -0
  230. package/dist/integrations/accounts/codex-login.d.ts.map +1 -0
  231. package/dist/integrations/accounts/host-facts.d.ts +22 -0
  232. package/dist/integrations/accounts/host-facts.d.ts.map +1 -0
  233. package/dist/integrations/accounts/open.d.ts +23 -0
  234. package/dist/integrations/accounts/open.d.ts.map +1 -0
  235. package/dist/integrations/accounts/rows.d.ts +45 -0
  236. package/dist/integrations/accounts/rows.d.ts.map +1 -0
  237. package/dist/integrations/peers/runtime.d.ts +12 -0
  238. package/dist/integrations/peers/runtime.d.ts.map +1 -1
  239. package/dist/integrations/providers/codex-account.d.ts +30 -0
  240. package/dist/integrations/providers/codex-account.d.ts.map +1 -0
  241. package/dist/integrations/providers/codex-oauth.d.ts +12 -0
  242. package/dist/integrations/providers/codex-oauth.d.ts.map +1 -1
  243. package/dist/integrations/providers/preferences.d.ts +8 -0
  244. package/dist/integrations/providers/preferences.d.ts.map +1 -1
  245. package/dist/integrations/resident/runner-worker.js +26 -25
  246. package/dist/integrations/resident/runner-worker.js.map +1 -1
  247. package/dist/integrations/sessions/store.d.ts +13 -1
  248. package/dist/integrations/sessions/store.d.ts.map +1 -1
  249. package/dist/integrations/subagents/activity.d.ts.map +1 -1
  250. package/dist/spaces/git.d.ts +27 -0
  251. package/dist/spaces/git.d.ts.map +1 -0
  252. package/dist/spaces/goto.d.ts +31 -0
  253. package/dist/spaces/goto.d.ts.map +1 -0
  254. package/dist/spaces/host.d.ts +380 -0
  255. package/dist/spaces/host.d.ts.map +1 -0
  256. package/dist/spaces/input.d.ts +87 -0
  257. package/dist/spaces/input.d.ts.map +1 -0
  258. package/dist/spaces/keymap.d.ts +30 -0
  259. package/dist/spaces/keymap.d.ts.map +1 -0
  260. package/dist/spaces/layout.d.ts +34 -0
  261. package/dist/spaces/layout.d.ts.map +1 -0
  262. package/dist/spaces/overlay.d.ts +105 -0
  263. package/dist/spaces/overlay.d.ts.map +1 -0
  264. package/dist/spaces/palette.d.ts +35 -0
  265. package/dist/spaces/palette.d.ts.map +1 -0
  266. package/dist/spaces/peers.d.ts +19 -0
  267. package/dist/spaces/peers.d.ts.map +1 -0
  268. package/dist/spaces/prefix.d.ts +19 -0
  269. package/dist/spaces/prefix.d.ts.map +1 -0
  270. package/dist/spaces/roster.d.ts +111 -0
  271. package/dist/spaces/roster.d.ts.map +1 -0
  272. package/dist/spaces/session.d.ts +83 -0
  273. package/dist/spaces/session.d.ts.map +1 -0
  274. package/dist/spaces/sidebar.d.ts +99 -0
  275. package/dist/spaces/sidebar.d.ts.map +1 -0
  276. package/dist/spaces/signal.d.ts +28 -0
  277. package/dist/spaces/signal.d.ts.map +1 -0
  278. package/dist/spaces/status.d.ts +20 -0
  279. package/dist/spaces/status.d.ts.map +1 -0
  280. package/dist/spaces/store.d.ts +69 -0
  281. package/dist/spaces/store.d.ts.map +1 -0
  282. package/dist/spaces/tabbar.d.ts +36 -0
  283. package/dist/spaces/tabbar.d.ts.map +1 -0
  284. package/dist/spaces/tiling.d.ts +90 -0
  285. package/dist/spaces/tiling.d.ts.map +1 -0
  286. package/dist/terminal/host/cell.d.ts +35 -0
  287. package/dist/terminal/host/cell.d.ts.map +1 -0
  288. package/dist/terminal/host/frame.d.ts +64 -0
  289. package/dist/terminal/host/frame.d.ts.map +1 -0
  290. package/dist/terminal/host/index.d.ts +5 -0
  291. package/dist/terminal/host/index.d.ts.map +1 -0
  292. package/dist/terminal/host/writer.d.ts +21 -0
  293. package/dist/terminal/host/writer.d.ts.map +1 -0
  294. package/dist/terminal/host/xterm-source.d.ts +18 -0
  295. package/dist/terminal/host/xterm-source.d.ts.map +1 -0
  296. package/dist/terminal/pty.d.ts.map +1 -1
  297. package/dist/terminal/screen.d.ts +12 -0
  298. package/dist/terminal/screen.d.ts.map +1 -1
  299. package/dist/termination-state.d.ts +4 -0
  300. package/dist/termination-state.d.ts.map +1 -1
  301. package/dist/termination.d.ts.map +1 -1
  302. package/dist/tui/App.d.ts +106 -1
  303. package/dist/tui/App.d.ts.map +1 -1
  304. package/dist/tui/Composer.d.ts +7 -1
  305. package/dist/tui/Composer.d.ts.map +1 -1
  306. package/dist/tui/ResumePicker.d.ts.map +1 -1
  307. package/dist/tui/TextPrompt.d.ts +5 -1
  308. package/dist/tui/TextPrompt.d.ts.map +1 -1
  309. package/dist/tui/account-flow.d.ts +126 -0
  310. package/dist/tui/account-flow.d.ts.map +1 -0
  311. package/dist/tui/agent.d.ts +17 -1
  312. package/dist/tui/agent.d.ts.map +1 -1
  313. package/dist/tui/compaction-rows.d.ts.map +1 -1
  314. package/dist/tui/context-usage.d.ts +14 -0
  315. package/dist/tui/context-usage.d.ts.map +1 -1
  316. package/dist/tui/index.d.ts.map +1 -1
  317. package/dist/tui/launch-settings.d.ts +5 -2
  318. package/dist/tui/launch-settings.d.ts.map +1 -1
  319. package/dist/tui/plain-failure.d.ts.map +1 -1
  320. package/dist/tui/plain-interruption.d.ts +3 -1
  321. package/dist/tui/plain-interruption.d.ts.map +1 -1
  322. package/dist/tui/resume-picker-state.d.ts +7 -0
  323. package/dist/tui/resume-picker-state.d.ts.map +1 -1
  324. package/dist/tui/slashCommands.d.ts +11 -0
  325. package/dist/tui/slashCommands.d.ts.map +1 -1
  326. package/dist/tui/tidy-tool-output.d.ts +3 -1
  327. package/dist/tui/tidy-tool-output.d.ts.map +1 -1
  328. package/dist/tui/tool-end-rows.d.ts +2 -0
  329. package/dist/tui/tool-end-rows.d.ts.map +1 -1
  330. package/dist/tui/zoom/entry.d.ts +34 -0
  331. package/dist/tui/zoom/entry.d.ts.map +1 -0
  332. package/dist/tui/zoom/gesture.d.ts +51 -0
  333. package/dist/tui/zoom/gesture.d.ts.map +1 -0
  334. package/dist/tui/zoom/leave.d.ts +11 -0
  335. package/dist/tui/zoom/leave.d.ts.map +1 -0
  336. package/dist/tui/zoom/local.d.ts +55 -0
  337. package/dist/tui/zoom/local.d.ts.map +1 -0
  338. package/dist/tui/zoom/proxy.d.ts +40 -0
  339. package/dist/tui/zoom/proxy.d.ts.map +1 -0
  340. package/package.json +6 -5
  341. package/dist/chunks/acp-JCGPYVIA.js +0 -13601
  342. package/dist/chunks/acp-JCGPYVIA.js.map +0 -6
  343. package/dist/chunks/activity-command-UCUGH2LW.js.map +0 -6
  344. package/dist/chunks/add-TNGQA6CH.js.map +0 -6
  345. package/dist/chunks/agent-session-FFLSUP5P.js +0 -60
  346. package/dist/chunks/archive-3L6VJWS4.js.map +0 -6
  347. package/dist/chunks/bin-main-YEEDVZXH.js.map +0 -6
  348. package/dist/chunks/chat-DDPHHLQJ.js.map +0 -6
  349. package/dist/chunks/chunk-3A4UOMMU.js.map +0 -6
  350. package/dist/chunks/chunk-B45X6IGD.js.map +0 -6
  351. package/dist/chunks/chunk-KEOBHC65.js.map +0 -6
  352. package/dist/chunks/chunk-MT4ONV77.js.map +0 -6
  353. package/dist/chunks/chunk-NB5LGTUL.js.map +0 -6
  354. package/dist/chunks/chunk-OAISYZM4.js.map +0 -6
  355. package/dist/chunks/chunk-OKDDIWD7.js.map +0 -6
  356. package/dist/chunks/chunk-SBKOTD2M.js.map +0 -6
  357. package/dist/chunks/chunk-SYOISB7S.js.map +0 -6
  358. package/dist/chunks/chunk-TBIX6JRE.js.map +0 -6
  359. package/dist/chunks/chunk-UEPYLY5U.js +0 -1415
  360. package/dist/chunks/chunk-UEPYLY5U.js.map +0 -6
  361. package/dist/chunks/chunk-VPZBVRXT.js.map +0 -6
  362. package/dist/chunks/chunk-WIU25RLZ.js.map +0 -6
  363. package/dist/chunks/chunk-XHCUNLST.js.map +0 -6
  364. package/dist/chunks/cli-runtime-VRAUDAKZ.js.map +0 -6
  365. package/dist/chunks/exec-EWGVFJNZ.js.map +0 -6
  366. package/dist/chunks/host-queries-R2KVVFTJ.js.map +0 -6
  367. package/dist/chunks/list-D63Z2LT4.js.map +0 -6
  368. package/dist/chunks/mcp-OCEDFJA5.js.map +0 -6
  369. package/dist/chunks/message-command-THJZ4EIM.js.map +0 -6
  370. package/dist/chunks/operator-tools-C7KZGWFJ.js.map +0 -6
  371. package/dist/chunks/pal-7IB6LZJX.js.map +0 -6
  372. package/dist/chunks/resident-EODT4UTE.js.map +0 -6
  373. package/dist/chunks/resume-2RX7TSTR.js +0 -23
  374. package/dist/chunks/service-RQZF7NCJ.js.map +0 -6
  375. package/dist/chunks/tui-UYHIDUPB.js.map +0 -6
  376. package/dist/chunks/worktree-UFFQMC2B.js.map +0 -6
  377. /package/dist/chunks/{agent-F7HY5T3U.js.map → agent-YPEXUYPH.js.map} +0 -0
  378. /package/dist/chunks/{agent-session-FFLSUP5P.js.map → agent-session-EZB2OYG3.js.map} +0 -0
  379. /package/dist/chunks/{commands-Q3FSPHGU.js.map → binding-K6RIQ5AP.js.map} +0 -0
  380. /package/dist/chunks/{browser-UHJ43DUU.js.map → browser-SKTIAVBF.js.map} +0 -0
  381. /package/dist/chunks/{chunk-4YJ4EI4X.js.map → chunk-2EHPXO4E.js.map} +0 -0
  382. /package/dist/chunks/{chunk-F37FVPVW.js.map → chunk-2NI5NS5S.js.map} +0 -0
  383. /package/dist/chunks/{chunk-SEYQW7MF.js.map → chunk-2U5M5IYH.js.map} +0 -0
  384. /package/dist/chunks/{chunk-ZRPLJYFM.js.map → chunk-2X6JZAKH.js.map} +0 -0
  385. /package/dist/chunks/{chunk-4Z4VYMTT.js.map → chunk-3QGJXD7U.js.map} +0 -0
  386. /package/dist/chunks/{chunk-UZYTWQYW.js.map → chunk-435DYOG4.js.map} +0 -0
  387. /package/dist/chunks/{chunk-CFHRQGO2.js.map → chunk-4OXIJ2EF.js.map} +0 -0
  388. /package/dist/chunks/{chunk-WEAIQEWJ.js.map → chunk-A5GTZ7R2.js.map} +0 -0
  389. /package/dist/chunks/{chunk-DYJY4COC.js.map → chunk-ACSG5R5P.js.map} +0 -0
  390. /package/dist/chunks/{chunk-6WXVHAS6.js.map → chunk-AI6PBE5G.js.map} +0 -0
  391. /package/dist/chunks/{chunk-HI7UZRIV.js.map → chunk-AX5ESG6K.js.map} +0 -0
  392. /package/dist/chunks/{chunk-WOY7SAUB.js.map → chunk-B3XIVOLM.js.map} +0 -0
  393. /package/dist/chunks/{chunk-ZNY5ZPBB.js.map → chunk-DECJPLLA.js.map} +0 -0
  394. /package/dist/chunks/{chunk-AH3DBEMR.js.map → chunk-DFCJYRT5.js.map} +0 -0
  395. /package/dist/chunks/{chunk-TKCRF7DK.js.map → chunk-DQLSLXDF.js.map} +0 -0
  396. /package/dist/chunks/{chunk-CLVP63AB.js.map → chunk-GANFMGV7.js.map} +0 -0
  397. /package/dist/chunks/{chunk-GKMPPOXW.js.map → chunk-GBS6ATYF.js.map} +0 -0
  398. /package/dist/chunks/{chunk-5PJIJTP2.js.map → chunk-GCCFTP47.js.map} +0 -0
  399. /package/dist/chunks/{chunk-UXDNVRJ5.js.map → chunk-GNEDN6MU.js.map} +0 -0
  400. /package/dist/chunks/{chunk-7DYH6R67.js.map → chunk-HB5ZN5KQ.js.map} +0 -0
  401. /package/dist/chunks/{chunk-BKZW4DRY.js.map → chunk-HELINLSD.js.map} +0 -0
  402. /package/dist/chunks/{chunk-OERIIND6.js.map → chunk-HKCIZR5P.js.map} +0 -0
  403. /package/dist/chunks/{chunk-4LHT2QDO.js.map → chunk-HTBMDD6Y.js.map} +0 -0
  404. /package/dist/chunks/{chunk-WTPIGLX7.js.map → chunk-I5E4MT3C.js.map} +0 -0
  405. /package/dist/chunks/{chunk-GX74LDJL.js.map → chunk-IJZ7SLBV.js.map} +0 -0
  406. /package/dist/chunks/{chunk-OZLMT5WB.js.map → chunk-IZVN6K6U.js.map} +0 -0
  407. /package/dist/chunks/{chunk-VKYIL6BJ.js.map → chunk-L2NNJ4XL.js.map} +0 -0
  408. /package/dist/chunks/{chunk-IDU2KLLT.js.map → chunk-LF76CVOZ.js.map} +0 -0
  409. /package/dist/chunks/{chunk-N4IDJ5V2.js.map → chunk-LFPTXRMM.js.map} +0 -0
  410. /package/dist/chunks/{chunk-I47Q4G4X.js.map → chunk-LQRP2VRQ.js.map} +0 -0
  411. /package/dist/chunks/{chunk-PEJV6XTK.js.map → chunk-LYGD5P7O.js.map} +0 -0
  412. /package/dist/chunks/{chunk-JS4C7HNH.js.map → chunk-M2OZ4SVS.js.map} +0 -0
  413. /package/dist/chunks/{chunk-RBTQ5ZQU.js.map → chunk-MGZSEPDY.js.map} +0 -0
  414. /package/dist/chunks/{chunk-W6OOY44A.js.map → chunk-MJBGVVI5.js.map} +0 -0
  415. /package/dist/chunks/{chunk-76DOZYZP.js.map → chunk-MYL75RA4.js.map} +0 -0
  416. /package/dist/chunks/{chunk-B5KDTZYH.js.map → chunk-PMX2WTZL.js.map} +0 -0
  417. /package/dist/chunks/{chunk-J7PV6OOX.js.map → chunk-QWSZ5P4C.js.map} +0 -0
  418. /package/dist/chunks/{chunk-EBN4YPIN.js.map → chunk-RSIWTHYS.js.map} +0 -0
  419. /package/dist/chunks/{chunk-IYNTTEQA.js.map → chunk-S4QOQGAT.js.map} +0 -0
  420. /package/dist/chunks/{chunk-UVSKCXL6.js.map → chunk-SGRO4RJP.js.map} +0 -0
  421. /package/dist/chunks/{chunk-3LCJJT2F.js.map → chunk-TZZOQ62Z.js.map} +0 -0
  422. /package/dist/chunks/{chunk-3UK2GDVX.js.map → chunk-UGDZ7MLG.js.map} +0 -0
  423. /package/dist/chunks/{chunk-DASSBULE.js.map → chunk-VFVWHYHT.js.map} +0 -0
  424. /package/dist/chunks/{chunk-WQ72OU4F.js.map → chunk-VZ4PKWLF.js.map} +0 -0
  425. /package/dist/chunks/{chunk-Y6HB4AJE.js.map → chunk-WKFHQQOU.js.map} +0 -0
  426. /package/dist/chunks/{chunk-WUUZJCAA.js.map → chunk-WKPRYH24.js.map} +0 -0
  427. /package/dist/chunks/{chunk-7HRVTREO.js.map → chunk-WQFHJ4TO.js.map} +0 -0
  428. /package/dist/chunks/{chunk-V2EGJD7W.js.map → chunk-XPLHAOGE.js.map} +0 -0
  429. /package/dist/chunks/{chunk-WG5LLHJX.js.map → chunk-XX2SP5AM.js.map} +0 -0
  430. /package/dist/chunks/{chunk-YSGVHT54.js.map → chunk-YDSWGJWF.js.map} +0 -0
  431. /package/dist/chunks/{chunk-MZUVCANX.js.map → chunk-YJ6NWB2B.js.map} +0 -0
  432. /package/dist/chunks/{chunk-EYYWIMVU.js.map → chunk-YUYNIAJX.js.map} +0 -0
  433. /package/dist/chunks/{chunk-RMBD3YZ5.js.map → chunk-YXIG4OT2.js.map} +0 -0
  434. /package/dist/chunks/{crash-report-6XW44BV6.js.map → commands-ZCNZVYTG.js.map} +0 -0
  435. /package/dist/chunks/{doctor-ZDXK5W6E.js.map → crash-report-K53VF4H5.js.map} +0 -0
  436. /package/dist/chunks/{dist-VEEXDONU.js.map → dist-6IPPA55L.js.map} +0 -0
  437. /package/dist/chunks/{dist-KNYBFHXB.js.map → dist-H53G25BE.js.map} +0 -0
  438. /package/dist/chunks/{dist-6XC3YARD.js.map → dist-L5LBM77I.js.map} +0 -0
  439. /package/dist/chunks/{dist-4SPA7VSK.js.map → dist-RIH2Q2ER.js.map} +0 -0
  440. /package/dist/chunks/{dist-VYUROH2A.js.map → dist-RTIKLSUV.js.map} +0 -0
  441. /package/dist/chunks/{dist-5DDSGOSA.js.map → dist-T6KE7URX.js.map} +0 -0
  442. /package/dist/chunks/{home-5N3FSKF7.js.map → dist-VSJGDIXP.js.map} +0 -0
  443. /package/dist/chunks/{dist-NG6RAO2C.js.map → dist-XNGK3C4G.js.map} +0 -0
  444. /package/dist/chunks/{lifecycle-2RFARBGC.js.map → doctor-DOCGTBME.js.map} +0 -0
  445. /package/dist/chunks/{drain-NQLOKED3.js.map → drain-LT3J2MEA.js.map} +0 -0
  446. /package/dist/chunks/{eval-A2G4KS62.js.map → eval-DH26W2QK.js.map} +0 -0
  447. /package/dist/chunks/{github-FH7PPWVW.js.map → github-JTMZJAZL.js.map} +0 -0
  448. /package/dist/chunks/{live-XC3V46W3.js.map → home-GGVNSCCU.js.map} +0 -0
  449. /package/dist/chunks/{login-NIX66V67.js.map → host-6CUYPX4T.js.map} +0 -0
  450. /package/dist/chunks/{learn-SAVZB4Q7.js.map → learn-PAO3IOYA.js.map} +0 -0
  451. /package/dist/chunks/{learn-builtin-ZWX7Q3X2.js.map → learn-builtin-DXZUXOGG.js.map} +0 -0
  452. /package/dist/chunks/{output-schema-4BLF2AFQ.js.map → lifecycle-KDN4D7DP.js.map} +0 -0
  453. /package/dist/chunks/{providers-NCGZXLFH.js.map → live-XWJ2JOFO.js.map} +0 -0
  454. /package/dist/chunks/{resume-2RX7TSTR.js.map → login-3Q2HKQUW.js.map} +0 -0
  455. /package/dist/chunks/{logs-LJSWQUT5.js.map → logs-UYB55HOX.js.map} +0 -0
  456. /package/dist/chunks/{resume-command-YJ6LCKON.js.map → open-QUDHJK5H.js.map} +0 -0
  457. /package/dist/chunks/{session-step-YIL6LV2J.js.map → output-schema-TLW5FA37.js.map} +0 -0
  458. /package/dist/chunks/{start-check-OKGZSWUG.js.map → palette-WDPS7W6Q.js.map} +0 -0
  459. /package/dist/chunks/{store-C654AJPG.js.map → peers-OBENILN2.js.map} +0 -0
  460. /package/dist/chunks/{store-EQQRW7NJ.js.map → prefix-MLAG4KTK.js.map} +0 -0
  461. /package/dist/chunks/{store-HWGRIA5X.js.map → providers-PJIHLTXP.js.map} +0 -0
  462. /package/dist/chunks/{schedule-LWY6AMC3.js.map → schedule-42N4JOQJ.js.map} +0 -0
  463. /package/dist/chunks/{skills-3KYQHENX.js.map → skills-V3VDOL3D.js.map} +0 -0
  464. /package/dist/chunks/{state-ER7R4WEN.js.map → state-HX3XRNPC.js.map} +0 -0
  465. /package/dist/chunks/{upgrade-D6Q5EAMR.js.map → upgrade-HDW5MWLE.js.map} +0 -0
@@ -11,7 +11,7 @@ import {
11
11
  confirmationView,
12
12
  describeChanges,
13
13
  permissionsChanged
14
- } from "./chunk-IYNTTEQA.js";
14
+ } from "./chunk-S4QOQGAT.js";
15
15
  import {
16
16
  visibleScheduleMessage
17
17
  } from "./chunk-NADQQMMG.js";
@@ -57,15 +57,15 @@ import {
57
57
  useReducedMotion,
58
58
  useThemeEpoch,
59
59
  useThemeSubscription
60
- } from "./chunk-72ZSHKT7.js";
60
+ } from "./chunk-2Y26DLOF.js";
61
61
  import {
62
62
  handleTerminationSignals
63
- } from "./chunk-VPZBVRXT.js";
64
- import "./chunk-TBIX6JRE.js";
63
+ } from "./chunk-6FWFSPUL.js";
64
+ import "./chunk-R66H2G5R.js";
65
65
  import {
66
66
  deleteUserConfigValue,
67
67
  setUserConfigValue
68
- } from "./chunk-PEJV6XTK.js";
68
+ } from "./chunk-LYGD5P7O.js";
69
69
  import {
70
70
  describeAllCredentialsLogout,
71
71
  describeCodexDeviceLoginStart,
@@ -73,15 +73,32 @@ import {
73
73
  describeLoginStart,
74
74
  describeProviderLogout
75
75
  } from "./chunk-JV3LONAU.js";
76
+ import {
77
+ BYPASS_CONSENT_BODY,
78
+ BYPASS_CONSENT_TITLE,
79
+ acknowledgeBypass,
80
+ hasAcknowledgedBypass
81
+ } from "./chunk-MYL75RA4.js";
82
+ import {
83
+ applyFallbackFlag,
84
+ capChoiceLines,
85
+ choiceDisplayText,
86
+ choiceDisplayWidth,
87
+ eraseLastChoiceGrapheme,
88
+ truncateAtSeparator,
89
+ truncateChoiceText,
90
+ wrapBalancedText,
91
+ wrapChoiceText
92
+ } from "./chunk-2OVZNENW.js";
76
93
  import {
77
94
  settleAnsweredPark
78
- } from "./chunk-OERIIND6.js";
79
- import "./chunk-GWQEMJFS.js";
95
+ } from "./chunk-HKCIZR5P.js";
80
96
  import {
81
97
  DELIVERY_READ_LIMIT,
82
98
  readSourceDeliveryPage,
83
99
  takeSuppressedCount
84
- } from "./chunk-ZNY5ZPBB.js";
100
+ } from "./chunk-DECJPLLA.js";
101
+ import "./chunk-GWQEMJFS.js";
85
102
  import {
86
103
  DEFAULT_MAX_ITERATIONS,
87
104
  DEFAULT_TIMEOUT_MS,
@@ -94,7 +111,7 @@ import {
94
111
  runsPerDay,
95
112
  scriptShellUnavailableReason,
96
113
  verifyScheduledScript
97
- } from "./chunk-3UK2GDVX.js";
114
+ } from "./chunk-UGDZ7MLG.js";
98
115
  import {
99
116
  callsCount
100
117
  } from "./chunk-E5VLANCO.js";
@@ -103,43 +120,42 @@ import {
103
120
  compileJobPolicy,
104
121
  compileScriptCheckPolicy,
105
122
  isPresetName
106
- } from "./chunk-IDU2KLLT.js";
107
- import "./chunk-HI7UZRIV.js";
123
+ } from "./chunk-LF76CVOZ.js";
124
+ import "./chunk-AX5ESG6K.js";
108
125
  import {
109
126
  formatResumeShellCommand,
110
127
  parkedRunWords,
111
128
  resumeCommand
112
- } from "./chunk-Y6HB4AJE.js";
129
+ } from "./chunk-WKFHQQOU.js";
113
130
  import {
114
131
  appendHistory,
115
132
  nextFireOf,
116
133
  readHistory,
117
134
  readState
118
- } from "./chunk-WEAIQEWJ.js";
135
+ } from "./chunk-A5GTZ7R2.js";
119
136
  import {
120
137
  callEndpoint,
121
138
  readEndpoint
122
139
  } from "./chunk-6YG7D7U4.js";
123
140
  import {
124
141
  reportCrash
125
- } from "./chunk-RMBD3YZ5.js";
142
+ } from "./chunk-YXIG4OT2.js";
126
143
  import {
127
- BYPASS_CONSENT_BODY,
128
- BYPASS_CONSENT_TITLE,
129
- acknowledgeBypass,
130
- hasAcknowledgedBypass
131
- } from "./chunk-76DOZYZP.js";
144
+ MAY_BE_LIMITED_WINDOW_MS,
145
+ accountProductName,
146
+ accountRows,
147
+ accountState,
148
+ describeState,
149
+ endpointHost,
150
+ hostedByHost,
151
+ spacesSignal
152
+ } from "./chunk-HRJPVPSU.js";
132
153
  import {
133
- applyFallbackFlag,
134
- capChoiceLines,
135
- choiceDisplayText,
136
- choiceDisplayWidth,
137
- eraseLastChoiceGrapheme,
138
- truncateAtSeparator,
139
- truncateChoiceText,
140
- wrapBalancedText,
141
- wrapChoiceText
142
- } from "./chunk-2OVZNENW.js";
154
+ buildPeerTools,
155
+ openLivePeers,
156
+ peerMailLabel,
157
+ peerMailMessage
158
+ } from "./chunk-6IDFHPY3.js";
143
159
  import {
144
160
  AUTO_CHOICE_ID,
145
161
  PR_NONE,
@@ -153,18 +169,25 @@ import {
153
169
  sectionHeading,
154
170
  withAutoChoice,
155
171
  writeConversationExport
156
- } from "./chunk-GX74LDJL.js";
172
+ } from "./chunk-IJZ7SLBV.js";
157
173
  import {
158
174
  tuiPalDefinition,
159
175
  tuiPalEnvironment,
160
176
  tuiPalOwner,
161
177
  tuiPalPreferences
162
- } from "./chunk-TKCRF7DK.js";
178
+ } from "./chunk-DQLSLXDF.js";
163
179
  import {
164
180
  isModelOnlyContext,
165
181
  runtimeContextLabel
166
182
  } from "./chunk-3F3V2PB7.js";
167
- import "./chunk-MT4ONV77.js";
183
+ import "./chunk-4OXIJ2EF.js";
184
+ import "./chunk-ZWA2JRJV.js";
185
+ import "./chunk-7QQOUCGI.js";
186
+ import "./chunk-YUYNIAJX.js";
187
+ import {
188
+ claimPalConversation,
189
+ listPalConversations
190
+ } from "./chunk-LQRP2VRQ.js";
168
191
  import {
169
192
  COMPACTED_HINT,
170
193
  COMPACTING_LABEL,
@@ -244,20 +267,12 @@ import {
244
267
  webLiveStatus,
245
268
  webSettledLine,
246
269
  withDebugDetail
247
- } from "./chunk-SYOISB7S.js";
270
+ } from "./chunk-6EJFXJDO.js";
248
271
  import {
249
272
  openManagedWorktrees,
250
273
  worktreeOpenHint
251
- } from "./chunk-WTPIGLX7.js";
252
- import {
253
- MCP_OUTPUT_CHARS,
254
- boundedMcpText,
255
- validatePromptArguments
256
- } from "./chunk-DASSBULE.js";
257
- import {
258
- openInBrowser
259
- } from "./chunk-AH3DBEMR.js";
260
- import "./chunk-VKYIL6BJ.js";
274
+ } from "./chunk-I5E4MT3C.js";
275
+ import "./chunk-L2NNJ4XL.js";
261
276
  import {
262
277
  SAVE_SKILL_TOOL_NAME,
263
278
  SKILL_CREATOR_SKILL,
@@ -282,9 +297,18 @@ import {
282
297
  settledElapsed,
283
298
  theme,
284
299
  tokenColor
285
- } from "./chunk-KEOBHC65.js";
286
- import "./chunk-WUUZJCAA.js";
287
- import "./chunk-4Z4VYMTT.js";
300
+ } from "./chunk-FHQTXWDA.js";
301
+ import "./chunk-WKPRYH24.js";
302
+ import "./chunk-3QGJXD7U.js";
303
+ import {
304
+ MCP_OUTPUT_CHARS,
305
+ boundedMcpText,
306
+ validatePromptArguments
307
+ } from "./chunk-VFVWHYHT.js";
308
+ import {
309
+ openInBrowser
310
+ } from "./chunk-DFCJYRT5.js";
311
+ import "./chunk-GCCFTP47.js";
288
312
  import {
289
313
  describeBrowserStatus
290
314
  } from "./chunk-WHODOMXA.js";
@@ -292,15 +316,9 @@ import {
292
316
  describePlainInterruption,
293
317
  describeProviderWait,
294
318
  describeProviderWaitClock,
295
- isSelfMending
296
- } from "./chunk-3A4UOMMU.js";
297
- import "./chunk-5PJIJTP2.js";
298
- import "./chunk-NUGPLXVK.js";
299
- import {
300
- beginCodexDeviceLogin,
301
- beginSubscriptionLogin,
302
- parsePastedInput
303
- } from "./chunk-B45X6IGD.js";
319
+ isSelfMending,
320
+ isSpentAllowance
321
+ } from "./chunk-7TEXDZVO.js";
304
322
  import {
305
323
  NO_SKILLS_FOUND,
306
324
  composeSkillsPrompt,
@@ -308,24 +326,30 @@ import {
308
326
  loadSkillBody,
309
327
  renderSkillRoster,
310
328
  skillTierLabel
311
- } from "./chunk-4YJ4EI4X.js";
312
- import "./chunk-CFHRQGO2.js";
313
- import "./chunk-EYYWIMVU.js";
329
+ } from "./chunk-2EHPXO4E.js";
330
+ import "./chunk-NUGPLXVK.js";
314
331
  import {
315
- claimPalConversation,
316
- listPalConversations
317
- } from "./chunk-I47Q4G4X.js";
318
- import "./chunk-ZWA2JRJV.js";
332
+ beginSubscriptionLogin,
333
+ parsePastedInput
334
+ } from "./chunk-G73G2WGR.js";
319
335
  import {
320
- startAutoUpdate
321
- } from "./chunk-WG5LLHJX.js";
336
+ API_KEY_ACCOUNT_PROVIDERS,
337
+ openCliAccounts,
338
+ storedAccountSignedIn
339
+ } from "./chunk-VDKDXDOH.js";
322
340
  import {
323
- resolveNpmInvocation
324
- } from "./chunk-GKMPPOXW.js";
341
+ beginCodexDeviceLogin
342
+ } from "./chunk-BGKQCLLH.js";
343
+ import {
344
+ startAutoUpdate
345
+ } from "./chunk-XX2SP5AM.js";
325
346
  import {
326
347
  readManifest
327
348
  } from "./chunk-AK2U3N2A.js";
328
- import "./chunk-EBN4YPIN.js";
349
+ import {
350
+ resolveNpmInvocation
351
+ } from "./chunk-GBS6ATYF.js";
352
+ import "./chunk-RSIWTHYS.js";
329
353
  import {
330
354
  ScheduleConflictError,
331
355
  confirmationHolds,
@@ -335,9 +359,15 @@ import {
335
359
  listJobs,
336
360
  updateJob
337
361
  } from "./chunk-SKKWMMFP.js";
362
+ import {
363
+ schedulePaths
364
+ } from "./chunk-A22MBIYU.js";
338
365
  import {
339
366
  writeJsonAtomic
340
367
  } from "./chunk-OEW7CJKK.js";
368
+ import {
369
+ EXIT_INTERNAL_ERROR
370
+ } from "./chunk-Y7B67G22.js";
341
371
  import {
342
372
  pinTrustedProjectPath,
343
373
  resolveTrustedProjectContext
@@ -347,10 +377,7 @@ import {
347
377
  describeCacheLifetime,
348
378
  promptCacheTtl,
349
379
  providerOffersCacheLifetime
350
- } from "./chunk-B5KDTZYH.js";
351
- import {
352
- debugRequested
353
- } from "./chunk-GNBMKISG.js";
380
+ } from "./chunk-PMX2WTZL.js";
354
381
  import {
355
382
  COMPOSER_TRIGGER_DEFAULTS,
356
383
  COMPOSER_TRIGGER_IDS,
@@ -369,9 +396,12 @@ import {
369
396
  pendingServersMessage,
370
397
  readPermissionLayers,
371
398
  resolveComposerTriggers
372
- } from "./chunk-SBKOTD2M.js";
399
+ } from "./chunk-LKJBDF7W.js";
373
400
  import "./chunk-KONYGNG6.js";
374
401
  import "./chunk-LCGXWCVU.js";
402
+ import {
403
+ debugRequested
404
+ } from "./chunk-GNBMKISG.js";
375
405
  import {
376
406
  displayPath,
377
407
  formatSize,
@@ -380,12 +410,7 @@ import {
380
410
  plural,
381
411
  productName
382
412
  } from "./chunk-XPS3W7FC.js";
383
- import {
384
- EXIT_INTERNAL_ERROR
385
- } from "./chunk-Y7B67G22.js";
386
- import {
387
- schedulePaths
388
- } from "./chunk-A22MBIYU.js";
413
+ import "./chunk-S7WRWA25.js";
389
414
  import {
390
415
  automaticChoice,
391
416
  automaticKind,
@@ -393,11 +418,10 @@ import {
393
418
  describeAutomaticChoice,
394
419
  discoverProviders,
395
420
  hasApiCredential,
396
- isAnthropicOAuthToken,
397
421
  primaryProvider,
398
422
  signedInSubscriptionProviders,
399
423
  writePreferences
400
- } from "./chunk-UEPYLY5U.js";
424
+ } from "./chunk-26C37THH.js";
401
425
  import {
402
426
  ALL_PROVIDER_IDS,
403
427
  PROVIDER_REGISTRY,
@@ -405,24 +429,29 @@ import {
405
429
  providerEntriesOfVendor,
406
430
  unsupportedProviderMessage
407
431
  } from "./chunk-6LLJQ3KY.js";
432
+ import {
433
+ isAnthropicOAuthToken,
434
+ readCodexCredentialFile
435
+ } from "./chunk-LKODRKMZ.js";
408
436
  import {
409
437
  applyProviderFlags
410
- } from "./chunk-F37FVPVW.js";
438
+ } from "./chunk-2NI5NS5S.js";
411
439
  import "./chunk-XEUQN4JC.js";
412
- import "./chunk-SEYQW7MF.js";
413
- import {
414
- PAUSED_TURN_LINES,
415
- currentTimeLine,
416
- describeTurnStop,
417
- handoffContinuationNote
418
- } from "./chunk-MZUVCANX.js";
440
+ import "./chunk-2U5M5IYH.js";
419
441
  import {
420
442
  autoAvailable,
421
443
  nextCycleMode,
422
444
  permissionModeDescription,
423
445
  permissionModeLabel,
424
446
  permissionModeName
425
- } from "./chunk-WQ72OU4F.js";
447
+ } from "./chunk-VZ4PKWLF.js";
448
+ import {
449
+ PAUSED_TURN_LINES,
450
+ currentTimeLine,
451
+ describeTurnStop,
452
+ handoffContinuationNote,
453
+ retryAfterMs
454
+ } from "./chunk-YJ6NWB2B.js";
426
455
  import {
427
456
  expandTabs,
428
457
  terminalDisplayText
@@ -446,6 +475,7 @@ import {
446
475
  openSessions,
447
476
  pullRequestLabel,
448
477
  pullRequestOfShellCall,
478
+ readConversationFacts,
449
479
  recordGeneratedTitle,
450
480
  requireWritableConversation,
451
481
  setTitle,
@@ -455,22 +485,27 @@ import {
455
485
  typedTextOf,
456
486
  unansweredReviewPark,
457
487
  unarchiveConversation
458
- } from "./chunk-XHCUNLST.js";
459
- import "./chunk-W6OOY44A.js";
488
+ } from "./chunk-JL64XHSL.js";
489
+ import "./chunk-MJBGVVI5.js";
460
490
  import "./chunk-JQIBPPOL.js";
461
- import "./chunk-V2EGJD7W.js";
462
- import "./chunk-OZLMT5WB.js";
491
+ import "./chunk-XPLHAOGE.js";
492
+ import "./chunk-IZVN6K6U.js";
463
493
  import {
464
494
  isTrusted,
465
495
  trustDir
466
- } from "./chunk-YSGVHT54.js";
496
+ } from "./chunk-YDSWGJWF.js";
497
+ import {
498
+ bindAccount,
499
+ findAccountByName,
500
+ isDefaultAccountId
501
+ } from "./chunk-BT7ZELXJ.js";
467
502
  import "./chunk-OH6TB27S.js";
468
- import "./chunk-JS4C7HNH.js";
503
+ import "./chunk-M2OZ4SVS.js";
469
504
  import "./chunk-WMEZTDLT.js";
470
505
  import {
471
506
  contextLogging,
472
507
  installCliLogging
473
- } from "./chunk-WOY7SAUB.js";
508
+ } from "./chunk-B3XIVOLM.js";
474
509
  import {
475
510
  PROJECT_MCP_FILE,
476
511
  parseMcpServerFile
@@ -484,7 +519,7 @@ import {
484
519
  } from "./chunk-U5UV2YRE.js";
485
520
  import "./chunk-IE5XIE4W.js";
486
521
  import "./chunk-B73OIFL6.js";
487
- import "./chunk-BKZW4DRY.js";
522
+ import "./chunk-HELINLSD.js";
488
523
  import "./chunk-JORONMD3.js";
489
524
  import {
490
525
  clearAllStoredCredentials,
@@ -496,14 +531,14 @@ import {
496
531
  readStoredCodexCredential,
497
532
  readStoredGeminiApiKey,
498
533
  readStoredSubscriptionCredential,
499
- restrictToOwner,
500
534
  writeStoredGeminiApiKey
501
- } from "./chunk-3LCJJT2F.js";
535
+ } from "./chunk-TZZOQ62Z.js";
502
536
  import {
503
537
  namzuHomePath
504
- } from "./chunk-7DYH6R67.js";
538
+ } from "./chunk-HB5ZN5KQ.js";
505
539
  import {
506
540
  ACCEPT_EDITS_TOOLS,
541
+ AccountRegistryError,
507
542
  DECLINED_TOOL_CALL_FEEDBACK,
508
543
  DEFAULT_MAX_GOAL_ROUNDS,
509
544
  DiskMessageFeedbackStore,
@@ -511,8 +546,6 @@ import {
511
546
  GoalRoundLimitError,
512
547
  HostCommandRegistry,
513
548
  MONITOR_TOOL_NAME,
514
- PEER_PROTOCOL_VERSION,
515
- PeerClient,
516
549
  REVIEW_EXEMPT_WRITES,
517
550
  SKILL_TOOL_NAME,
518
551
  SessionGoalActivation,
@@ -525,44 +558,33 @@ import {
525
558
  buildScheduleTools,
526
559
  buildSessionLoopTools,
527
560
  createAssistantMessage,
528
- createPeerEndpoint,
529
561
  createRuntimeContextMessage,
530
562
  createUserMessage,
531
- defineTool,
532
- derivePeerRef,
533
563
  describeMonitorEnd,
534
564
  describeSchedule,
535
565
  estimateTextTokens,
536
566
  execHostShell,
537
567
  findPendingCheckpoint,
538
- formatPeerMessage,
539
568
  generateSessionId,
540
569
  generateTurnId,
541
- hardenPeerRuntimeDir,
542
570
  hostTimeZone,
543
571
  installedCommandShellForDialect,
544
572
  isCompactionMessage,
545
- isPeerRecordLive,
546
573
  jsonLinesSink,
547
574
  kernelHostCommands,
548
- mcpJsonSchemaToZod,
549
575
  nextFireTime,
576
+ parseAccountId,
550
577
  parseScheduleSpec,
551
578
  parseWorkflowMeta,
552
- pipePeerAddress,
553
579
  prettySink,
554
- readPeerRecords,
555
- removePeerRecord,
580
+ resolveBoundAccount,
556
581
  resolveNamzuHome,
557
- resolvePeerRuntimeDir,
558
582
  resolveTriggerThreshold,
559
583
  resolveWorkflowLimits,
560
- udsPeerAddress,
561
584
  upcomingFireTimes,
562
585
  validateTimeZone,
563
- wrapUntrusted,
564
- writePeerRecord
565
- } from "./chunk-OKDDIWD7.js";
586
+ wrapUntrusted
587
+ } from "./chunk-YTE3QIH3.js";
566
588
  import {
567
589
  __commonJS,
568
590
  __export,
@@ -30954,7 +30976,7 @@ var Output = class {
30954
30976
  if (operation.type === "write") {
30955
30977
  const { text, transformers } = operation;
30956
30978
  let { x, y } = operation;
30957
- let lines = text.split("\n");
30979
+ let lines2 = text.split("\n");
30958
30980
  const clip = clips.at(-1);
30959
30981
  if (clip) {
30960
30982
  const clipHorizontally = typeof clip?.x1 === "number" && typeof clip?.x2 === "number";
@@ -30966,13 +30988,13 @@ var Output = class {
30966
30988
  }
30967
30989
  }
30968
30990
  if (clipVertically) {
30969
- const height = lines.length;
30991
+ const height = lines2.length;
30970
30992
  if (y + height < clip.y1 || y > clip.y2) {
30971
30993
  continue;
30972
30994
  }
30973
30995
  }
30974
30996
  if (clipHorizontally) {
30975
- lines = lines.map((line) => {
30997
+ lines2 = lines2.map((line) => {
30976
30998
  const from = x < clip.x1 ? clip.x1 - x : 0;
30977
30999
  const width = this.caches.getStringWidth(line);
30978
31000
  const to = x + width > clip.x2 ? clip.x2 - x : width;
@@ -30984,16 +31006,16 @@ var Output = class {
30984
31006
  }
30985
31007
  if (clipVertically) {
30986
31008
  const from = y < clip.y1 ? clip.y1 - y : 0;
30987
- const height = lines.length;
31009
+ const height = lines2.length;
30988
31010
  const to = y + height > clip.y2 ? clip.y2 - y : height;
30989
- lines = lines.slice(from, to);
31011
+ lines2 = lines2.slice(from, to);
30990
31012
  if (y < clip.y1) {
30991
31013
  y = clip.y1;
30992
31014
  }
30993
31015
  }
30994
31016
  }
30995
31017
  let offsetY = 0;
30996
- for (let [index, line] of lines.entries()) {
31018
+ for (let [index, line] of lines2.entries()) {
30997
31019
  const currentLine = output[y + offsetY];
30998
31020
  if (!currentLine) {
30999
31021
  continue;
@@ -31181,7 +31203,7 @@ cliCursor.toggle = (force, writableStream) => {
31181
31203
  var cli_cursor_default = cliCursor;
31182
31204
 
31183
31205
  // ../../node_modules/.pnpm/ink@7.0.3_@types+react@19.2.15_react@19.2.6/node_modules/ink/build/log-update.js
31184
- var visibleLineCount = /* @__PURE__ */ __name((lines, str) => str.endsWith("\n") ? lines.length - 1 : lines.length, "visibleLineCount");
31206
+ var visibleLineCount = /* @__PURE__ */ __name((lines2, str) => str.endsWith("\n") ? lines2.length - 1 : lines2.length, "visibleLineCount");
31185
31207
  var createStandard = /* @__PURE__ */ __name((stream2, { showCursor = false } = {}) => {
31186
31208
  let previousLineCount = 0;
31187
31209
  let previousOutput = "";
@@ -31206,8 +31228,8 @@ var createStandard = /* @__PURE__ */ __name((stream2, { showCursor = false } = {
31206
31228
  if (!hasChanges(str, activeCursor)) {
31207
31229
  return false;
31208
31230
  }
31209
- const lines = str.split("\n");
31210
- const visibleCount = visibleLineCount(lines, str);
31231
+ const lines2 = str.split("\n");
31232
+ const visibleCount = visibleLineCount(lines2, str);
31211
31233
  const cursorSuffix = buildCursorSuffix(visibleCount, activeCursor);
31212
31234
  if (str === previousOutput && cursorChanged) {
31213
31235
  stream2.write(buildCursorOnlySequence({
@@ -31221,7 +31243,7 @@ var createStandard = /* @__PURE__ */ __name((stream2, { showCursor = false } = {
31221
31243
  previousOutput = str;
31222
31244
  const returnPrefix = buildReturnToBottomPrefix(cursorWasShown, previousLineCount, previousCursorPosition);
31223
31245
  stream2.write(returnPrefix + base_exports.eraseLines(previousLineCount) + str + cursorSuffix);
31224
- previousLineCount = lines.length;
31246
+ previousLineCount = lines2.length;
31225
31247
  }
31226
31248
  previousCursorPosition = activeCursor ? { ...activeCursor } : void 0;
31227
31249
  cursorWasShown = activeCursor !== void 0;
@@ -31254,14 +31276,14 @@ var createStandard = /* @__PURE__ */ __name((stream2, { showCursor = false } = {
31254
31276
  render2.sync = (str) => {
31255
31277
  const activeCursor = cursorDirty ? cursorPosition : void 0;
31256
31278
  cursorDirty = false;
31257
- const lines = str.split("\n");
31279
+ const lines2 = str.split("\n");
31258
31280
  previousOutput = str;
31259
- previousLineCount = lines.length;
31281
+ previousLineCount = lines2.length;
31260
31282
  if (!activeCursor && cursorWasShown) {
31261
31283
  stream2.write(hideCursorEscape);
31262
31284
  }
31263
31285
  if (activeCursor) {
31264
- stream2.write(buildCursorSuffix(visibleLineCount(lines, str), activeCursor));
31286
+ stream2.write(buildCursorSuffix(visibleLineCount(lines2, str), activeCursor));
31265
31287
  }
31266
31288
  previousCursorPosition = activeCursor ? { ...activeCursor } : void 0;
31267
31289
  cursorWasShown = activeCursor !== void 0;
@@ -31381,14 +31403,14 @@ var createIncremental = /* @__PURE__ */ __name((stream2, { showCursor = false }
31381
31403
  render2.sync = (str) => {
31382
31404
  const activeCursor = cursorDirty ? cursorPosition : void 0;
31383
31405
  cursorDirty = false;
31384
- const lines = str.split("\n");
31406
+ const lines2 = str.split("\n");
31385
31407
  previousOutput = str;
31386
- previousLines = lines;
31408
+ previousLines = lines2;
31387
31409
  if (!activeCursor && cursorWasShown) {
31388
31410
  stream2.write(hideCursorEscape);
31389
31411
  }
31390
31412
  if (activeCursor) {
31391
- stream2.write(buildCursorSuffix(visibleLineCount(lines, str), activeCursor));
31413
+ stream2.write(buildCursorSuffix(visibleLineCount(lines2, str), activeCursor));
31392
31414
  }
31393
31415
  previousCursorPosition = activeCursor ? { ...activeCursor } : void 0;
31394
31416
  cursorWasShown = activeCursor !== void 0;
@@ -31748,11 +31770,11 @@ var codeExcerpt = /* @__PURE__ */ __name((source, line, options = {}) => {
31748
31770
  if (!line || line < 1) {
31749
31771
  throw new TypeError("Line number must start from `1`.");
31750
31772
  }
31751
- const lines = dist_default2(source).split(/\r?\n/);
31752
- if (line > lines.length) {
31773
+ const lines2 = dist_default2(source).split(/\r?\n/);
31774
+ if (line > lines2.length) {
31753
31775
  return;
31754
31776
  }
31755
- return generateLineNumbers(line, (_a = options.around) !== null && _a !== void 0 ? _a : 3).filter((line2) => lines[line2 - 1] !== void 0).map((line2) => ({ line: line2, value: lines[line2 - 1] }));
31777
+ return generateLineNumbers(line, (_a = options.around) !== null && _a !== void 0 ? _a : 3).filter((line2) => lines2[line2 - 1] !== void 0).map((line2) => ({ line: line2, value: lines2[line2 - 1] }));
31756
31778
  }, "codeExcerpt");
31757
31779
  var dist_default3 = codeExcerpt;
31758
31780
 
@@ -33925,380 +33947,12 @@ var measure_element_default = measureElement;
33925
33947
  var import_react61 = __toESM(require_react(), 1);
33926
33948
 
33927
33949
  // src/tui/App.tsx
33928
- import { existsSync as existsSync2 } from "node:fs";
33929
- import { join as join7, relative as relative3, resolve as resolve7 } from "node:path";
33950
+ import { existsSync as existsSync2, rmSync as rmSync3 } from "node:fs";
33951
+ import { join as join8, relative as relative3, resolve as resolve7 } from "node:path";
33930
33952
  var import_react60 = __toESM(require_react(), 1);
33931
33953
 
33932
- // src/integrations/peers/runtime.ts
33933
- import { createHash, randomBytes } from "node:crypto";
33934
- import { realpathSync } from "node:fs";
33935
- import { basename } from "node:path";
33936
- var INBOX_CAPACITY = 32;
33937
- var DEDUP_CAPACITY = 256;
33938
- function peerMailMessage(mail) {
33939
- return createRuntimeContextMessage(formatPeerMessage(mail), "peer-message");
33940
- }
33941
- __name(peerMailMessage, "peerMailMessage");
33942
- function peerMailLabel(mail) {
33943
- return `Message from ${mail.from.name}: ${mail.text}`;
33944
- }
33945
- __name(peerMailLabel, "peerMailLabel");
33946
- async function openLivePeers(options) {
33947
- const uid = process.getuid?.();
33948
- const runtime2 = resolvePeerRuntimeDir({
33949
- env: options.env ?? process.env,
33950
- namzuHome: options.home,
33951
- uid,
33952
- hardenDirectory: /* @__PURE__ */ __name((path, owner) => {
33953
- resolvePeerRuntimeDirHardening(path, owner);
33954
- }, "hardenDirectory")
33955
- });
33956
- const sessionId = generateSessionId();
33957
- const ref = derivePeerRef(sessionId);
33958
- const cwd2 = realpathSync(options.cwd);
33959
- const address = process.platform === "win32" ? pipePeerAddress(
33960
- createHash("sha256").update(options.home).digest("hex").slice(0, 16),
33961
- sessionId
33962
- ) : udsPeerAddress(runtime2.path, sessionId);
33963
- const token = randomBytes(32).toString("hex");
33964
- const startedAt = Date.now();
33965
- let enabled = true;
33966
- let closed = false;
33967
- let closing;
33968
- const pending = [];
33969
- const accepted = /* @__PURE__ */ new Map();
33970
- const client = new PeerClient();
33971
- const record3 = /* @__PURE__ */ __name(() => ({
33972
- v: 1,
33973
- sessionId,
33974
- ref,
33975
- pid: process.pid,
33976
- startedAt,
33977
- kind: "tui",
33978
- title: basename(cwd2),
33979
- cwd: cwd2,
33980
- permissionMode: options.mode(),
33981
- state: options.state(),
33982
- acceptsMessages: enabled && options.ready() && !closed,
33983
- address,
33984
- token,
33985
- protocol: PEER_PROTOCOL_VERSION,
33986
- cliVersion: options.version
33987
- }), "record");
33988
- const from = /* @__PURE__ */ __name(() => {
33989
- const current = record3();
33990
- return {
33991
- sessionId,
33992
- ref,
33993
- name: current.title ?? ref,
33994
- address,
33995
- mode: current.permissionMode,
33996
- kind: "tui"
33997
- };
33998
- }, "from");
33999
- const publish = /* @__PURE__ */ __name(() => {
34000
- if (closed) return;
34001
- discardStale();
34002
- try {
34003
- writePeerRecord(runtime2.sessionsDir, record3());
34004
- } catch (error) {
34005
- if (enabled)
34006
- options.report(
34007
- `Peer messaging is off because its live record could not be updated: ${String(error)}`
34008
- );
34009
- enabled = false;
34010
- }
34011
- }, "publish");
34012
- const discardStale = /* @__PURE__ */ __name(() => {
34013
- const owner = options.owner();
34014
- const mode = options.mode();
34015
- let dropped = 0;
34016
- let modeChanged = 0;
34017
- for (let index = pending.length - 1; index >= 0; index--) {
34018
- const mail = pending[index];
34019
- if (!mail) continue;
34020
- if (mail.owner !== owner) {
34021
- pending.splice(index, 1);
34022
- dropped++;
34023
- } else if (mail.from.mode !== mode) {
34024
- pending.splice(index, 1);
34025
- modeChanged++;
34026
- }
34027
- }
34028
- if (dropped)
34029
- options.report(
34030
- `${dropped} peer message(s) were not delivered because the conversation changed.`
34031
- );
34032
- if (modeChanged)
34033
- options.report(
34034
- `${modeChanged} peer message(s) were not delivered because the permission mode changed.`
34035
- );
34036
- }, "discardStale");
34037
- const receive = /* @__PURE__ */ __name((request) => {
34038
- if (!request.text.trim()) return { status: "refused", reason: "Message must contain text." };
34039
- if (closed || !enabled || !options.ready())
34040
- return {
34041
- status: "refused",
34042
- reason: "This terminal is not accepting messages."
34043
- };
34044
- const sender = readPeerRecords(runtime2.sessionsDir).find(
34045
- (peer) => peer.sessionId === request.from.sessionId
34046
- );
34047
- if (!sender || sender.cwd !== cwd2 || sender.kind !== "tui")
34048
- return {
34049
- status: "refused",
34050
- reason: "Only live terminals in the same project may send here."
34051
- };
34052
- if (request.from.mode !== options.mode())
34053
- return {
34054
- status: "refused",
34055
- reason: "The terminals have different permission modes."
34056
- };
34057
- const key = `${request.from.sessionId}:${request.id}`;
34058
- const previous = accepted.get(key);
34059
- if (previous)
34060
- return previous.text === request.text && previous.owner === options.owner() ? { status: "queued", reason: "Already accepted; not queued twice." } : {
34061
- status: "refused",
34062
- reason: "This message id belongs to different content or a previous conversation."
34063
- };
34064
- discardStale();
34065
- if (pending.length >= INBOX_CAPACITY)
34066
- return { status: "refused", reason: "The receiving inbox is full." };
34067
- const owner = options.owner();
34068
- accepted.set(key, { text: request.text, owner });
34069
- if (accepted.size > DEDUP_CAPACITY) accepted.delete(accepted.keys().next().value);
34070
- pending.push({
34071
- id: request.id,
34072
- owner,
34073
- from: request.from,
34074
- text: request.text
34075
- });
34076
- options.available();
34077
- return {
34078
- status: "queued",
34079
- reason: "Accepted in the live inbox; this is not proof of model delivery."
34080
- };
34081
- }, "receive");
34082
- const endpoint = await createPeerEndpoint({
34083
- address,
34084
- token,
34085
- uid,
34086
- sessionsDir: runtime2.sessionsDir,
34087
- getState: options.state,
34088
- onDeliver: receive,
34089
- onSubscribeIdle: /* @__PURE__ */ __name(() => ({
34090
- status: "refused",
34091
- reason: "Idle subscriptions are not supported by this terminal."
34092
- }), "onSubscribeIdle"),
34093
- onNotice: /* @__PURE__ */ __name(() => {
34094
- }, "onNotice")
34095
- });
34096
- try {
34097
- writePeerRecord(runtime2.sessionsDir, record3());
34098
- } catch (error) {
34099
- await endpoint.close();
34100
- throw error;
34101
- }
34102
- const list = /* @__PURE__ */ __name(async () => {
34103
- const records = readPeerRecords(runtime2.sessionsDir).filter(
34104
- (peer) => peer.cwd === cwd2 && peer.kind === "tui"
34105
- );
34106
- const live = await Promise.all(
34107
- records.map(async (peer) => await isPeerRecordLive(peer) ? peer : void 0)
34108
- );
34109
- return live.filter((peer) => peer !== void 0).map((peer) => ({
34110
- session_id: peer.sessionId,
34111
- ref: peer.ref,
34112
- title: peer.title,
34113
- cwd: peer.cwd,
34114
- permission_mode: peer.permissionMode,
34115
- state: peer.state,
34116
- accepts_messages: peer.acceptsMessages,
34117
- self: peer.sessionId === sessionId
34118
- }));
34119
- }, "list");
34120
- const send = /* @__PURE__ */ __name(async (target, message) => {
34121
- if (closed || !enabled) return { status: "refused", reason: "Peer messaging is off." };
34122
- if (!message.trim() || Buffer.byteLength(message) > 32 * 1024)
34123
- return {
34124
- status: "refused",
34125
- reason: "Message must contain text and fit in 32 KiB."
34126
- };
34127
- publish();
34128
- if (!enabled) return { status: "refused", reason: "Peer messaging is off." };
34129
- const candidates = readPeerRecords(runtime2.sessionsDir).filter(
34130
- (peer2) => peer2.cwd === cwd2 && peer2.kind === "tui" && (peer2.sessionId === target || peer2.ref === target || peer2.title === target || peer2.address === target)
34131
- );
34132
- if (candidates.length !== 1)
34133
- return {
34134
- status: "refused",
34135
- reason: candidates.length ? "Target is ambiguous; use its exact live session id." : "No matching terminal in this project. Use list_sessions."
34136
- };
34137
- const peer = candidates[0];
34138
- if (!peer) return { status: "refused", reason: "No matching terminal." };
34139
- if (peer.sessionId === sessionId)
34140
- return {
34141
- status: "refused",
34142
- reason: "Cannot send to this same terminal."
34143
- };
34144
- if (!peer.acceptsMessages)
34145
- return {
34146
- status: "refused",
34147
- reason: "The target is not accepting messages."
34148
- };
34149
- if (!await isPeerRecordLive(peer))
34150
- return {
34151
- status: "unreachable",
34152
- reason: "The target did not answer. No message was sent."
34153
- };
34154
- const id = generateSessionId();
34155
- const result = await client.deliver(peer, {
34156
- id,
34157
- from: from(),
34158
- text: message
34159
- });
34160
- return result.kind === "responded" ? {
34161
- id,
34162
- session_id: peer.sessionId,
34163
- status: result.status,
34164
- reason: result.reason
34165
- } : {
34166
- id,
34167
- status: "unreachable",
34168
- reason: "No receipt arrived; acceptance is unknown. Do not automatically retry."
34169
- };
34170
- }, "send");
34171
- return {
34172
- id: sessionId,
34173
- ref,
34174
- publish,
34175
- list,
34176
- send,
34177
- get enabled() {
34178
- return enabled;
34179
- },
34180
- get pending() {
34181
- discardStale();
34182
- return pending.length;
34183
- },
34184
- setEnabled(value) {
34185
- enabled = value;
34186
- publish();
34187
- if (value) options.available();
34188
- },
34189
- peek(owner) {
34190
- discardStale();
34191
- return closed || !enabled || owner !== options.owner() ? [] : [...pending];
34192
- },
34193
- takeExact(owner, id) {
34194
- discardStale();
34195
- if (closed || !enabled || owner !== options.owner()) return void 0;
34196
- const index = pending.findIndex((mail) => mail.id === id && mail.owner === owner);
34197
- return index < 0 ? void 0 : pending.splice(index, 1)[0];
34198
- },
34199
- take(owner, limit = INBOX_CAPACITY) {
34200
- discardStale();
34201
- if (closed || !enabled || owner !== options.owner()) return [];
34202
- return pending.splice(0, limit);
34203
- },
34204
- close() {
34205
- if (closing) return closing;
34206
- closed = true;
34207
- enabled = false;
34208
- if (pending.length)
34209
- options.report(
34210
- `${pending.length} peer message(s) were not delivered before this terminal closed.`
34211
- );
34212
- pending.length = 0;
34213
- closing = endpoint.close().finally(() => removePeerRecord(runtime2.sessionsDir, sessionId, uid));
34214
- return closing;
34215
- }
34216
- };
34217
- }
34218
- __name(openLivePeers, "openLivePeers");
34219
- function resolvePeerRuntimeDirHardening(path, uid) {
34220
- hardenPeerRuntimeDir(path, uid);
34221
- restrictToOwner(path);
34222
- }
34223
- __name(resolvePeerRuntimeDirHardening, "resolvePeerRuntimeDirHardening");
34224
- function buildPeerTools(current) {
34225
- return [
34226
- defineTool({
34227
- name: "list_sessions",
34228
- description: "List live terminals in this project for peer messaging. These are independent processes, not child tasks or archived conversations. Tokens are never returned.",
34229
- inputSchema: mcpJsonSchemaToZod({
34230
- type: "object",
34231
- properties: {},
34232
- additionalProperties: false
34233
- }),
34234
- category: "custom",
34235
- permissions: [],
34236
- readOnly: true,
34237
- destructive: false,
34238
- concurrencySafe: true,
34239
- async execute() {
34240
- const peers = current();
34241
- if (!peers)
34242
- return {
34243
- success: false,
34244
- output: "",
34245
- error: "Peer messaging is not ready."
34246
- };
34247
- const sessions = await peers.list();
34248
- return {
34249
- success: true,
34250
- output: JSON.stringify(sessions),
34251
- data: { sessions }
34252
- };
34253
- }
34254
- }),
34255
- defineTool({
34256
- name: "send_session_message",
34257
- description: "Send context to another live terminal found by list_sessions. Queued means accepted, not read or completed. Idle receivers start a turn; busy receivers read at their next safe request boundary. Does not grant approvals, interrupt, spawn, or restart a terminal. Use send_message for owned child tasks.",
34258
- inputSchema: mcpJsonSchemaToZod({
34259
- type: "object",
34260
- properties: {
34261
- target: {
34262
- type: "string",
34263
- description: "Exact live session id, short ref or unambiguous title from list_sessions."
34264
- },
34265
- message: {
34266
- type: "string",
34267
- description: "Peer context; carries no operator authority."
34268
- }
34269
- },
34270
- required: ["target", "message"],
34271
- additionalProperties: false
34272
- }),
34273
- category: "custom",
34274
- permissions: [],
34275
- readOnly: false,
34276
- destructive: false,
34277
- concurrencySafe: false,
34278
- async execute(input, context) {
34279
- context.abortSignal.throwIfAborted();
34280
- const peers = current();
34281
- if (!peers)
34282
- return {
34283
- success: false,
34284
- output: "",
34285
- error: "Peer messaging is not ready."
34286
- };
34287
- const { target, message } = input;
34288
- const receipt = await peers.send(target, message);
34289
- return {
34290
- success: receipt.status === "queued",
34291
- output: JSON.stringify(receipt),
34292
- data: receipt
34293
- };
34294
- }
34295
- })
34296
- ];
34297
- }
34298
- __name(buildPeerTools, "buildPeerTools");
34299
-
34300
33954
  // src/tui/permission-review.ts
34301
- import { createHash as createHash2 } from "node:crypto";
33955
+ import { createHash } from "node:crypto";
34302
33956
  import { readFileSync as readFileSync2, statSync } from "node:fs";
34303
33957
  var MAX_REVIEW_VALUE_CHARS = 2e5;
34304
33958
  var REVIEW_ALLOCATION_BYTES = 1024 * 1024;
@@ -34379,7 +34033,7 @@ function buildPermissionReview(calls, limits = permissionReviewLimits(
34379
34033
  const chunks = [];
34380
34034
  let bytes = 0;
34381
34035
  const active = /* @__PURE__ */ new WeakSet();
34382
- const hash = createHash2("sha256");
34036
+ const hash = createHash("sha256");
34383
34037
  const withheldChars = /* @__PURE__ */ new Map();
34384
34038
  const omittedCalls = /* @__PURE__ */ new Set();
34385
34039
  let currentCall = 0;
@@ -34392,7 +34046,7 @@ function buildPermissionReview(calls, limits = permissionReviewLimits(
34392
34046
  }, "append");
34393
34047
  const withhold = /* @__PURE__ */ __name((characters, digestOf) => {
34394
34048
  if (silent) {
34395
- if (digestOf !== void 0) hash.update(createHash2("sha256").update(digestOf).digest("hex"));
34049
+ if (digestOf !== void 0) hash.update(createHash("sha256").update(digestOf).digest("hex"));
34396
34050
  return;
34397
34051
  }
34398
34052
  withheldChars.set(currentCall, (withheldChars.get(currentCall) ?? 0) + characters);
@@ -34401,7 +34055,7 @@ function buildPermissionReview(calls, limits = permissionReviewLimits(
34401
34055
  bytes += Buffer.byteLength(placeholder, "utf8");
34402
34056
  chunks.push(placeholder);
34403
34057
  hash.update(
34404
- `<withheld ${characters} ${digestOf === void 0 ? "" : createHash2("sha256").update(digestOf).digest("hex")}>`
34058
+ `<withheld ${characters} ${digestOf === void 0 ? "" : createHash("sha256").update(digestOf).digest("hex")}>`
34405
34059
  );
34406
34060
  }, "withhold");
34407
34061
  const exhausted = /* @__PURE__ */ __name(() => !silent && bytes >= limits.totalBytes, "exhausted");
@@ -34710,8 +34364,8 @@ function summarizeKnownCall(name, input, context = {}) {
34710
34364
  // exact view has to show, not one this summary may pick a half of.
34711
34365
  input.content === void 0 !== (input.newStr === void 0);
34712
34366
  if (shapeIsKnown) {
34713
- const lines = body === "" ? [] : body.split("\n");
34714
- if (lines.at(-1) === "") lines.pop();
34367
+ const lines2 = body === "" ? [] : body.split("\n");
34368
+ if (lines2.at(-1) === "") lines2.pop();
34715
34369
  return {
34716
34370
  // The box title already names the file; the first row says what the
34717
34371
  // write does to it.
@@ -34719,8 +34373,8 @@ function summarizeKnownCall(name, input, context = {}) {
34719
34373
  `${(() => {
34720
34374
  const exists = fileExistsSafely(context, input.path);
34721
34375
  return exists === void 0 ? "Write" : exists ? "Replaces the existing file" : "New file";
34722
- })()} \xB7 ${lines.length} line${lines.length === 1 ? "" : "s"}`,
34723
- ...lines.map((line) => ` ${line}`)
34376
+ })()} \xB7 ${lines2.length} line${lines2.length === 1 ? "" : "s"}`,
34377
+ ...lines2.map((line) => ` ${line}`)
34724
34378
  ],
34725
34379
  complete: true
34726
34380
  };
@@ -34846,7 +34500,7 @@ function summarizeWorkflow(input, context) {
34846
34500
  const scriptLines = script.split("\n");
34847
34501
  const shown = scriptLines.slice(0, WORKFLOW_SCRIPT_PREVIEW_LINES);
34848
34502
  const hidden = scriptLines.length - shown.length;
34849
- const body = /* @__PURE__ */ __name((lines) => lines.map((line) => ` ${line}`), "body");
34503
+ const body = /* @__PURE__ */ __name((lines2) => lines2.map((line) => ` ${line}`), "body");
34850
34504
  const count2 = `Script \xB7 ${scriptLines.length} line${scriptLines.length === 1 ? "" : "s"}`;
34851
34505
  return {
34852
34506
  lines: [
@@ -34893,7 +34547,7 @@ function summarizeComputerUse(input, context) {
34893
34547
  if (!Object.keys(input).every((key) => ["type", "actions", "screenshot_id"].includes(key)))
34894
34548
  return null;
34895
34549
  if (!Array.isArray(input.actions) || input.actions.length === 0) return null;
34896
- const lines = [];
34550
+ const lines2 = [];
34897
34551
  let coordinates = false;
34898
34552
  for (const [index, item] of input.actions.entries()) {
34899
34553
  if (!isRecord(item) || item.type === "batch" || Object.hasOwn(item, "screenshot_id"))
@@ -34901,13 +34555,13 @@ function summarizeComputerUse(input, context) {
34901
34555
  const action2 = computerUseAction(item, [], context);
34902
34556
  if (!action2) return null;
34903
34557
  coordinates ||= action2.coordinates;
34904
- lines.push(`${index + 1}. ${action2.line}`);
34558
+ lines2.push(`${index + 1}. ${action2.line}`);
34905
34559
  }
34906
34560
  const count2 = input.actions.length;
34907
34561
  return {
34908
34562
  lines: [
34909
34563
  `${count2} desktop action${count2 === 1 ? "" : "s"}, in order; stops at the first that fails`,
34910
- ...lines,
34564
+ ...lines2,
34911
34565
  ...coordinates ? [space] : []
34912
34566
  ],
34913
34567
  complete: true
@@ -35018,7 +34672,7 @@ var FORMATTED_TOOLS = /* @__PURE__ */ new Set([
35018
34672
  "workflow"
35019
34673
  ]);
35020
34674
  function compactAgentPlan(calls) {
35021
- const lines = [];
34675
+ const lines2 = [];
35022
34676
  let previousGroup = "";
35023
34677
  for (const [index, call] of calls.entries()) {
35024
34678
  const input = call.input;
@@ -35028,9 +34682,9 @@ function compactAgentPlan(calls) {
35028
34682
  const group = JSON.stringify([workflow, phase]);
35029
34683
  if (group !== previousGroup) {
35030
34684
  if (workflow || phase) {
35031
- lines.push([workflow, phase].filter(Boolean).join(" / "));
35032
- if (phaseDetail) lines.push(` ${phaseDetail}`);
35033
- } else if (previousGroup) lines.push("Other agents");
34685
+ lines2.push([workflow, phase].filter(Boolean).join(" / "));
34686
+ if (phaseDetail) lines2.push(` ${phaseDetail}`);
34687
+ } else if (previousGroup) lines2.push("Other agents");
35034
34688
  previousGroup = group;
35035
34689
  }
35036
34690
  const type = input.subagent_type;
@@ -35038,11 +34692,11 @@ function compactAgentPlan(calls) {
35038
34692
  const background = input.run_in_background === true ? " \xB7 background" : "";
35039
34693
  const selection = [input.provider, input.model, input.effort].filter((value) => typeof value === "string").map((value) => oneLine(String(value))).join(" / ");
35040
34694
  const modelLabel = selection ? ` \xB7 ${selection}` : "";
35041
- lines.push(
34695
+ lines2.push(
35042
34696
  `${index === calls.length - 1 ? "\u2514" : "\u251C"}\u2500 [ ${index + 1}. ${oneLine(String(input.description))} \xB7 ${access}${modelLabel}${background}${call.isDestructive ? " \xB7 destructive" : ""} ]`
35043
34697
  );
35044
34698
  }
35045
- return terminalDisplayText(lines.join("\n"));
34699
+ return terminalDisplayText(lines2.join("\n"));
35046
34700
  }
35047
34701
  __name(compactAgentPlan, "compactAgentPlan");
35048
34702
  function agentTypeLabel(type) {
@@ -35057,9 +34711,9 @@ function oneLine(value) {
35057
34711
  }
35058
34712
  __name(oneLine, "oneLine");
35059
34713
  var DIFF_PREVIEW_LINES = 40;
35060
- function diffLines(sign, lines) {
35061
- const shown = lines.slice(0, DIFF_PREVIEW_LINES).map((line) => `${sign} ${line}`);
35062
- const hidden = lines.length - shown.length;
34714
+ function diffLines(sign, lines2) {
34715
+ const shown = lines2.slice(0, DIFF_PREVIEW_LINES).map((line) => `${sign} ${line}`);
34716
+ const hidden = lines2.length - shown.length;
35063
34717
  return hidden > 0 ? [...shown, `${sign} \u2026 ${hidden} more line${hidden === 1 ? "" : "s"}`] : shown;
35064
34718
  }
35065
34719
  __name(diffLines, "diffLines");
@@ -35084,7 +34738,7 @@ function summarizeEdit(input, context = {}) {
35084
34738
  if (replaceAll2 !== void 0 && typeof replaceAll2 !== "boolean") return null;
35085
34739
  if (input.edits !== void 0) {
35086
34740
  if (!Array.isArray(input.edits) || oldText.value !== null || newText.value !== null) return null;
35087
- const lines = [
34741
+ const lines2 = [
35088
34742
  `${path} \xB7 ${input.edits.length} replacement${input.edits.length === 1 ? "" : "s"}`
35089
34743
  ];
35090
34744
  let disk = diskTextOf(context, path);
@@ -35098,12 +34752,12 @@ function summarizeEdit(input, context = {}) {
35098
34752
  )) {
35099
34753
  return null;
35100
34754
  }
35101
- lines.push(`@ ${index + 1}${edit.replace_all ? " \xB7 every occurrence" : ""}`);
34755
+ lines2.push(`@ ${index + 1}${edit.replace_all ? " \xB7 every occurrence" : ""}`);
35102
34756
  const shown2 = showOnDisk(disk, edit.old_string, edit.new_string, edit.replace_all === true);
35103
- lines.push(...shown2.notes, ...diffLines("-", shown2.before), ...diffLines("+", shown2.after));
34757
+ lines2.push(...shown2.notes, ...diffLines("-", shown2.before), ...diffLines("+", shown2.after));
35104
34758
  disk = shown2.next;
35105
34759
  }
35106
- return { lines, complete: true };
34760
+ return { lines: lines2, complete: true };
35107
34761
  }
35108
34762
  if (input.insertLine !== void 0) {
35109
34763
  const at = input.insertLine;
@@ -35198,8 +34852,8 @@ function pickString(input, name, alias) {
35198
34852
  }
35199
34853
  __name(pickString, "pickString");
35200
34854
  function readableField(label, value) {
35201
- const lines = value.split("\n");
35202
- return lines.map(
34855
+ const lines2 = value.split("\n");
34856
+ return lines2.map(
35203
34857
  (line, index) => index === 0 ? `${label}: ${line}` : `${" ".repeat(label.length + 2)}${line}`
35204
34858
  );
35205
34859
  }
@@ -35380,12 +35034,12 @@ function backgroundJobOutputRows(output, columns) {
35380
35034
  const bytes = Buffer.from(output.chunk, "utf8");
35381
35035
  const omittedHere = Math.max(0, bytes.length - MAX_VISIBLE_OUTPUT_BYTES);
35382
35036
  const latest = bytes.subarray(omittedHere).toString("utf8").replace(/\n$/u, "");
35383
- const lines = [
35037
+ const lines2 = [
35384
35038
  ...output.droppedBytes > 0 ? [`Earlier output was dropped (${formatSize(output.droppedBytes)}).`] : [],
35385
35039
  ...omittedHere > 0 ? [`Showing the latest ${formatSize(MAX_VISIBLE_OUTPUT_BYTES)}.`] : [],
35386
35040
  latest.length > 0 ? latest : "No output yet."
35387
35041
  ];
35388
- return permissionReviewRows(lines.join("\n").replace(/\t/gu, " "), columns).map(
35042
+ return permissionReviewRows(lines2.join("\n").replace(/\t/gu, " "), columns).map(
35389
35043
  (row) => row.text
35390
35044
  );
35391
35045
  }
@@ -36023,27 +35677,27 @@ function classify(line, next) {
36023
35677
  }
36024
35678
  __name(classify, "classify");
36025
35679
  function scanBlocks(src) {
36026
- const lines = src.split("\n");
35680
+ const lines2 = src.split("\n");
36027
35681
  const segments = [];
36028
35682
  let i = 0;
36029
- while (i < lines.length) {
36030
- const line = lines[i] ?? "";
36031
- switch (classify(line, lines[i + 1])) {
35683
+ while (i < lines2.length) {
35684
+ const line = lines2[i] ?? "";
35685
+ switch (classify(line, lines2[i + 1])) {
36032
35686
  case "blank":
36033
35687
  i++;
36034
35688
  break;
36035
35689
  case "code": {
36036
35690
  let end = i + 1;
36037
- while (end < lines.length && !FENCE.test(lines[end] ?? "")) end++;
36038
- const last = Math.min(end, lines.length - 1);
36039
- segments.push(lines.slice(i, last + 1).join("\n"));
35691
+ while (end < lines2.length && !FENCE.test(lines2[end] ?? "")) end++;
35692
+ const last = Math.min(end, lines2.length - 1);
35693
+ segments.push(lines2.slice(i, last + 1).join("\n"));
36040
35694
  i = end + 1;
36041
35695
  break;
36042
35696
  }
36043
35697
  case "table": {
36044
35698
  let end = i + 2;
36045
- while (end < lines.length && continuesTable(lines[end] ?? "")) end++;
36046
- segments.push(lines.slice(i, end).join("\n"));
35699
+ while (end < lines2.length && continuesTable(lines2[end] ?? "")) end++;
35700
+ segments.push(lines2.slice(i, end).join("\n"));
36047
35701
  i = end;
36048
35702
  break;
36049
35703
  }
@@ -36054,8 +35708,8 @@ function scanBlocks(src) {
36054
35708
  break;
36055
35709
  default: {
36056
35710
  let end = i;
36057
- while (end < lines.length && classify(lines[end] ?? "", lines[end + 1]) === "text") end++;
36058
- segments.push(lines.slice(i, end).join("\n"));
35711
+ while (end < lines2.length && classify(lines2[end] ?? "", lines2[end + 1]) === "text") end++;
35712
+ segments.push(lines2.slice(i, end).join("\n"));
36059
35713
  i = end;
36060
35714
  break;
36061
35715
  }
@@ -36065,24 +35719,24 @@ function scanBlocks(src) {
36065
35719
  }
36066
35720
  __name(scanBlocks, "scanBlocks");
36067
35721
  function parseBlock(raw) {
36068
- const lines = raw.split("\n");
36069
- const first = lines[0] ?? "";
36070
- switch (classify(first, lines[1])) {
35722
+ const lines2 = raw.split("\n");
35723
+ const first = lines2[0] ?? "";
35724
+ switch (classify(first, lines2[1])) {
36071
35725
  case "code": {
36072
35726
  const lang = FENCE.exec(first)?.[1];
36073
- const closed = FENCE.test(lines[lines.length - 1] ?? "");
35727
+ const closed = FENCE.test(lines2[lines2.length - 1] ?? "");
36074
35728
  return {
36075
35729
  type: "code",
36076
35730
  ...lang ? { lang } : {},
36077
- lines: closed ? lines.slice(1, -1) : lines.slice(1)
35731
+ lines: closed ? lines2.slice(1, -1) : lines2.slice(1)
36078
35732
  };
36079
35733
  }
36080
35734
  case "table": {
36081
- const align = tableAlign(lines[1] ?? "");
35735
+ const align = tableAlign(lines2[1] ?? "");
36082
35736
  return {
36083
35737
  type: "table",
36084
35738
  headers: tableCells(first),
36085
- rows: lines.slice(2).map(tableCells),
35739
+ rows: lines2.slice(2).map(tableCells),
36086
35740
  ...align ? { align } : {}
36087
35741
  };
36088
35742
  }
@@ -36102,7 +35756,7 @@ function parseBlock(raw) {
36102
35756
  };
36103
35757
  }
36104
35758
  default:
36105
- return { type: "paragraph", text: lines.map((l) => l.trim()).join(" ") };
35759
+ return { type: "paragraph", text: lines2.map((l) => l.trim()).join(" ") };
36106
35760
  }
36107
35761
  }
36108
35762
  __name(parseBlock, "parseBlock");
@@ -36379,19 +36033,19 @@ function gridLayout(headers, rows, align, width) {
36379
36033
  if (!widths) return void 0;
36380
36034
  const wrapRow = /* @__PURE__ */ __name((row) => widths.map((w, c) => wrapSpans(row[c] ?? [], w)), "wrapRow");
36381
36035
  const body = rows.map(wrapRow);
36382
- if (body.some((cells) => Math.max(...cells.map((lines2) => lines2.length)) > MAX_ROW_LINES))
36036
+ if (body.some((cells) => Math.max(...cells.map((lines3) => lines3.length)) > MAX_ROW_LINES))
36383
36037
  return void 0;
36384
36038
  const rule = /* @__PURE__ */ __name((left, middle, right2) => [
36385
36039
  { text: `${left}${widths.map((w) => "\u2500".repeat(w + 2)).join(middle)}${right2}`, border: true }
36386
36040
  ], "rule");
36387
- const lines = [rule("\u250C", "\u252C", "\u2510")];
36388
- lines.push(...drawRow(wrapRow(headers), widths, () => "center", true));
36041
+ const lines2 = [rule("\u250C", "\u252C", "\u2510")];
36042
+ lines2.push(...drawRow(wrapRow(headers), widths, () => "center", true));
36389
36043
  for (const cells of body) {
36390
- lines.push(rule("\u251C", "\u253C", "\u2524"));
36391
- lines.push(...drawRow(cells, widths, (c) => align?.[c] ?? "left", false));
36044
+ lines2.push(rule("\u251C", "\u253C", "\u2524"));
36045
+ lines2.push(...drawRow(cells, widths, (c) => align?.[c] ?? "left", false));
36392
36046
  }
36393
- lines.push(rule("\u2514", "\u2534", "\u2518"));
36394
- return { mode: "grid", lines };
36047
+ lines2.push(rule("\u2514", "\u2534", "\u2518"));
36048
+ return { mode: "grid", lines: lines2 };
36395
36049
  }
36396
36050
  __name(gridLayout, "gridLayout");
36397
36051
  function columnWidths(want, least, room) {
@@ -36433,12 +36087,12 @@ function columnWidths(want, least, room) {
36433
36087
  }
36434
36088
  __name(columnWidths, "columnWidths");
36435
36089
  function drawRow(cells, widths, alignOf, header) {
36436
- const height = Math.max(1, ...cells.map((lines) => lines.length));
36090
+ const height = Math.max(1, ...cells.map((lines2) => lines2.length));
36437
36091
  const out = [];
36438
36092
  for (let r = 0; r < height; r++) {
36439
36093
  const line = [{ text: "\u2502", border: true }];
36440
- cells.forEach((lines, c) => {
36441
- const content = lines[r] ?? [];
36094
+ cells.forEach((lines2, c) => {
36095
+ const content = lines2[r] ?? [];
36442
36096
  const w = widths[c] ?? 0;
36443
36097
  const gap = Math.max(0, w - displayWidth(content));
36444
36098
  const align = alignOf(c);
@@ -36454,28 +36108,28 @@ function drawRow(cells, widths, alignOf, header) {
36454
36108
  }
36455
36109
  __name(drawRow, "drawRow");
36456
36110
  function stackedLines(headers, rows, width) {
36457
- const lines = [];
36111
+ const lines2 = [];
36458
36112
  const rule = [
36459
36113
  { text: "\u2500".repeat(Math.max(1, Math.min(width, STACKED_RULE_MAX))), border: true }
36460
36114
  ];
36461
36115
  rows.forEach((row, r) => {
36462
- if (r > 0) lines.push(rule);
36116
+ if (r > 0) lines2.push(rule);
36463
36117
  headers.forEach((header, c) => {
36464
36118
  const label = [
36465
36119
  ...header.map((s) => ({ ...s, bold: true })),
36466
36120
  { text: ": ", bold: true }
36467
36121
  ];
36468
- lines.push(...wrapSpans([...label, ...row[c] ?? []], width));
36122
+ lines2.push(...wrapSpans([...label, ...row[c] ?? []], width));
36469
36123
  });
36470
36124
  });
36471
36125
  if (rows.length === 0)
36472
- lines.push(
36126
+ lines2.push(
36473
36127
  ...wrapSpans(
36474
36128
  headers.flatMap((h, c) => c > 0 ? [{ text: " \xB7 " }, ...h] : h),
36475
36129
  width
36476
36130
  )
36477
36131
  );
36478
- return lines;
36132
+ return lines2;
36479
36133
  }
36480
36134
  __name(stackedLines, "stackedLines");
36481
36135
  function tableHeight(table, width) {
@@ -36626,8 +36280,8 @@ function WrappedSpans({
36626
36280
  color,
36627
36281
  hyperlinks = false
36628
36282
  }) {
36629
- const lines = wrapSpans(spans, width);
36630
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: lines.map((line, i) => (
36283
+ const lines2 = wrapSpans(spans, width);
36284
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: lines2.map((line, i) => (
36631
36285
  // biome-ignore lint/suspicious/noArrayIndexKey: rows are positional.
36632
36286
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react35.Fragment, { children: [
36633
36287
  line.map((span, j) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -36639,7 +36293,7 @@ function WrappedSpans({
36639
36293
  },
36640
36294
  `s-${j}`
36641
36295
  )),
36642
- i < lines.length - 1 ? "\n" : null
36296
+ i < lines2.length - 1 ? "\n" : null
36643
36297
  ] }, `l-${i}`)
36644
36298
  )) });
36645
36299
  }
@@ -36698,8 +36352,8 @@ __name(cutUserText, "cutUserText");
36698
36352
  function hiddenTextNote(cut3) {
36699
36353
  const kb = Math.max(1, Math.round(cut3.hiddenChars / 1e3)).toLocaleString("en-US");
36700
36354
  if (cut3.hiddenLines === 0) return `(~${kb} KB hidden)`;
36701
- const lines = cut3.hiddenLines.toLocaleString("en-US");
36702
- return `(${lines} ${cut3.hiddenLines === 1 ? "line" : "lines"}, ~${kb} KB hidden)`;
36355
+ const lines2 = cut3.hiddenLines.toLocaleString("en-US");
36356
+ return `(${lines2} ${cut3.hiddenLines === 1 ? "line" : "lines"}, ~${kb} KB hidden)`;
36703
36357
  }
36704
36358
  __name(hiddenTextNote, "hiddenTextNote");
36705
36359
  function hiddenTextRule(note, width) {
@@ -36848,11 +36502,11 @@ __name(buildGridCells, "buildGridCells");
36848
36502
  function buildLegend(breakdown) {
36849
36503
  const window2 = breakdown.windowTokens;
36850
36504
  const pct = /* @__PURE__ */ __name((tokens) => window2 > 0 ? (tokens / window2 * 100).toFixed(1) : "0.0", "pct");
36851
- const lines = [];
36505
+ const lines2 = [];
36852
36506
  for (const category of breakdown.categories) {
36853
36507
  if (category.tokens <= 0 || category.kind === "free") continue;
36854
36508
  if (category.kind === "buffer" && breakdown.autoCompact) continue;
36855
- lines.push({
36509
+ lines2.push({
36856
36510
  glyph: GLYPH_FULL,
36857
36511
  color: CONTEXT_COLORS[category.id],
36858
36512
  dimGlyph: false,
@@ -36863,7 +36517,7 @@ function buildLegend(breakdown) {
36863
36517
  }
36864
36518
  const free = breakdown.categories.find((c) => c.kind === "free");
36865
36519
  if (free && free.tokens > 0) {
36866
- lines.push({
36520
+ lines2.push({
36867
36521
  glyph: GLYPH_FREE,
36868
36522
  color: CONTEXT_COLORS.free,
36869
36523
  dimGlyph: true,
@@ -36874,7 +36528,7 @@ function buildLegend(breakdown) {
36874
36528
  }
36875
36529
  const buffer = breakdown.categories.find((c) => c.kind === "buffer");
36876
36530
  if (buffer && buffer.tokens > 0 && breakdown.autoCompact) {
36877
- lines.push({
36531
+ lines2.push({
36878
36532
  glyph: GLYPH_BUFFER,
36879
36533
  color: CONTEXT_COLORS.buffer,
36880
36534
  dimGlyph: false,
@@ -36883,7 +36537,7 @@ function buildLegend(breakdown) {
36883
36537
  dimName: true
36884
36538
  });
36885
36539
  }
36886
- return lines;
36540
+ return lines2;
36887
36541
  }
36888
36542
  __name(buildLegend, "buildLegend");
36889
36543
  var SUGGEST_TOOL_SHARE_PERCENT = 15;
@@ -37016,28 +36670,28 @@ function buildContextView(input) {
37016
36670
  autoCompact: input.autoCompact,
37017
36671
  memoryFiles: input.memoryFiles
37018
36672
  });
37019
- const lines = ["Context usage"];
37020
- if (overLimit) lines.push(overLimit);
37021
- if (input.model) lines.push(input.model);
37022
- lines.push(usage2, "", "Estimated usage by category");
37023
- for (const line of legend) lines.push(`${line.glyph} ${line.name}: ${line.value}`);
37024
- if (windowNote) lines.push("", `${windowNote.label}${windowNote.value}`);
36673
+ const lines2 = ["Context usage"];
36674
+ if (overLimit) lines2.push(overLimit);
36675
+ if (input.model) lines2.push(input.model);
36676
+ lines2.push(usage2, "", "Estimated usage by category");
36677
+ for (const line of legend) lines2.push(`${line.glyph} ${line.name}: ${line.value}`);
36678
+ if (windowNote) lines2.push("", `${windowNote.label}${windowNote.value}`);
37025
36679
  const cacheNote = input.cacheLifetime ? { label: "Prompt cache lifetime: ", value: input.cacheLifetime } : void 0;
37026
- if (cacheNote) lines.push(...windowNote ? [] : [""], `${cacheNote.label}${cacheNote.value}`);
36680
+ if (cacheNote) lines2.push(...windowNote ? [] : [""], `${cacheNote.label}${cacheNote.value}`);
37027
36681
  for (const section of input.sections) {
37028
- lines.push("", `${section.title} \xB7 ${section.hint}`);
36682
+ lines2.push("", `${section.title} \xB7 ${section.hint}`);
37029
36683
  for (const group of section.groups) {
37030
- if (group.heading) lines.push(` ${group.heading}`);
37031
- for (const item of group.items) lines.push(` ${item.label}: ${item.value}`);
36684
+ if (group.heading) lines2.push(` ${group.heading}`);
36685
+ for (const item of group.items) lines2.push(` ${item.label}: ${item.value}`);
37032
36686
  }
37033
36687
  }
37034
36688
  if (suggestions.length > 0) {
37035
- lines.push("", "Suggestions");
36689
+ lines2.push("", "Suggestions");
37036
36690
  for (const s of suggestions) {
37037
- lines.push(
36691
+ lines2.push(
37038
36692
  `${s.level === "warning" ? "!" : "-"} ${s.title}${s.savings > 0 ? ` \u2192 save ~${formatTokens(s.savings)}` : ""}`
37039
36693
  );
37040
- lines.push(` ${s.detail}`);
36694
+ lines2.push(` ${s.detail}`);
37041
36695
  }
37042
36696
  }
37043
36697
  return {
@@ -37050,7 +36704,7 @@ function buildContextView(input) {
37050
36704
  ...cacheNote ? { cacheNote } : {},
37051
36705
  sections: input.sections,
37052
36706
  suggestions,
37053
- text: lines.join("\n")
36707
+ text: lines2.join("\n")
37054
36708
  };
37055
36709
  }
37056
36710
  __name(buildContextView, "buildContextView");
@@ -37191,7 +36845,7 @@ __name(ReadSearchGroup, "ReadSearchGroup");
37191
36845
 
37192
36846
  // src/tui/status-panel-layout.ts
37193
36847
  function wrap2(value, width) {
37194
- const lines = [];
36848
+ const lines2 = [];
37195
36849
  let line = "";
37196
36850
  let cells = 0;
37197
36851
  for (const { segment } of new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(
@@ -37199,15 +36853,15 @@ function wrap2(value, width) {
37199
36853
  )) {
37200
36854
  const size = stringWidth(segment);
37201
36855
  if (cells + size > width && line) {
37202
- lines.push(line);
36856
+ lines2.push(line);
37203
36857
  line = "";
37204
36858
  cells = 0;
37205
36859
  }
37206
36860
  line += segment;
37207
36861
  cells += size;
37208
36862
  }
37209
- lines.push(line);
37210
- return lines;
36863
+ lines2.push(line);
36864
+ return lines2;
37211
36865
  }
37212
36866
  __name(wrap2, "wrap");
37213
36867
  function statusPanelLayout(source, columns = 80) {
@@ -37284,9 +36938,9 @@ function cutSurrogate(text) {
37284
36938
  }
37285
36939
  __name(cutSurrogate, "cutSurrogate");
37286
36940
  function shellCommandHeader(command) {
37287
- const lines = command.replace(/\r\n/g, "\n").trim().split("\n");
37288
- let text = lines.slice(0, SHELL_HEADER_LINES).join("\n");
37289
- let cut3 = lines.length > SHELL_HEADER_LINES;
36941
+ const lines2 = command.replace(/\r\n/g, "\n").trim().split("\n");
36942
+ let text = lines2.slice(0, SHELL_HEADER_LINES).join("\n");
36943
+ let cut3 = lines2.length > SHELL_HEADER_LINES;
37290
36944
  if (text.length > SHELL_HEADER_CHARS) {
37291
36945
  text = cutSurrogate(text.slice(0, SHELL_HEADER_CHARS));
37292
36946
  cut3 = true;
@@ -37358,9 +37012,9 @@ function wrapWords(line, width) {
37358
37012
  return rows;
37359
37013
  }
37360
37014
  __name(wrapWords, "wrapWords");
37361
- function visualLines(lines, width) {
37362
- if (width === void 0) return [...lines];
37363
- return lines.flatMap((line) => wrapShellLine(line, width));
37015
+ function visualLines(lines2, width) {
37016
+ if (width === void 0) return [...lines2];
37017
+ return lines2.flatMap((line) => wrapShellLine(line, width));
37364
37018
  }
37365
37019
  __name(visualLines, "visualLines");
37366
37020
  function weight(text) {
@@ -37368,11 +37022,11 @@ function weight(text) {
37368
37022
  return gap ? Number((gap[1] ?? "1").replaceAll(",", "")) : 1;
37369
37023
  }
37370
37024
  __name(weight, "weight");
37371
- function lineStream(lines, tone, limit, options) {
37025
+ function lineStream(lines2, tone, limit, options) {
37372
37026
  const wrap3 = /* @__PURE__ */ __name((line) => options.width === void 0 ? [line] : wrapWords(line, options.width), "wrap");
37373
- const shown = options.expanded ? lines : lines.slice(0, limit);
37027
+ const shown = options.expanded ? lines2 : lines2.slice(0, limit);
37374
37028
  const rows = shown.flatMap(wrap3).map((text) => ({ text, tone }));
37375
- const hidden = options.expanded ? 0 : lines.slice(limit).reduce((count2, line) => count2 + weight(line), 0);
37029
+ const hidden = options.expanded ? 0 : lines2.slice(limit).reduce((count2, line) => count2 + weight(line), 0);
37376
37030
  if (hidden <= 0) return rows;
37377
37031
  return [
37378
37032
  ...rows,
@@ -37380,9 +37034,9 @@ function lineStream(lines, tone, limit, options) {
37380
37034
  ];
37381
37035
  }
37382
37036
  __name(lineStream, "lineStream");
37383
- function stream(lines, tone, limit, options) {
37384
- if (options.byLine) return lineStream(lines, tone, limit, options);
37385
- const rows = visualLines(lines, options.width).map((text) => ({ text, tone }));
37037
+ function stream(lines2, tone, limit, options) {
37038
+ if (options.byLine) return lineStream(lines2, tone, limit, options);
37039
+ const rows = visualLines(lines2, options.width).map((text) => ({ text, tone }));
37386
37040
  if (options.expanded || rows.length <= limit) return rows;
37387
37041
  const hidden = rows.slice(limit).reduce((count2, row) => count2 + weight(row.text), 0);
37388
37042
  if (hidden === 1 && !options.byLine) return rows;
@@ -37418,7 +37072,7 @@ function shellCollapses(shell) {
37418
37072
  const limit = shell.failed ? SHELL_FAILURE_LINES : SHELL_PREVIEW_LINES;
37419
37073
  if (shell.folded) return true;
37420
37074
  return [shell.stdout, shell.stderr].some(
37421
- (lines) => lines.length > limit || !shell.byLine && lines.some((line) => stringWidth(line) > 60)
37075
+ (lines2) => lines2.length > limit || !shell.byLine && lines2.some((line) => stringWidth(line) > 60)
37422
37076
  );
37423
37077
  }
37424
37078
  __name(shellCollapses, "shellCollapses");
@@ -37694,13 +37348,13 @@ function messageCollapses(message) {
37694
37348
  }
37695
37349
  __name(messageCollapses, "messageCollapses");
37696
37350
  function DetailBlock({
37697
- lines,
37351
+ lines: lines2,
37698
37352
  expanded,
37699
37353
  detailRef,
37700
37354
  diff: diff2
37701
37355
  }) {
37702
37356
  if (diff2) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DiffBlock, { info: diff2, expanded, canExpand: detailRef !== void 0 });
37703
- const shown = splitDetail(lines.map(terminalDisplayText), expanded, detailRef);
37357
+ const shown = splitDetail(lines2.map(terminalDisplayText), expanded, detailRef);
37704
37358
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { flexDirection: "column", paddingLeft: SHELL_RESULT_INDENT, children: shown.map((line, i) => (
37705
37359
  // biome-ignore lint/suspicious/noArrayIndexKey: these rows have no local state; expansion replaces their text in place.
37706
37360
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { flexDirection: "row", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { flexGrow: 1, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: detailLineColor(line), wrap: "wrap", children: line.length > 0 ? line : " " }) }) }, `d-${i}`)
@@ -37743,12 +37397,12 @@ function willCollapse(detail, diff2) {
37743
37397
  return detail.length > COLLAPSE_LINES || detail.some((line) => terminalDisplayText(line).length > PREVIEW_LINE_CHARS);
37744
37398
  }
37745
37399
  __name(willCollapse, "willCollapse");
37746
- function splitDetail(lines, expanded, detailRef) {
37747
- if (expanded) return lines;
37400
+ function splitDetail(lines2, expanded, detailRef) {
37401
+ if (expanded) return lines2;
37748
37402
  const canExpand = detailRef !== void 0;
37749
37403
  const fragmentLines = COLLAPSE_LINES / 2;
37750
- const selected = lines.length > COLLAPSE_LINES ? [...lines.slice(0, fragmentLines), ...lines.slice(-fragmentLines)] : lines;
37751
- const folded = lines.length > COLLAPSE_LINES ? lines.slice(fragmentLines, lines.length - fragmentLines) : [];
37404
+ const selected = lines2.length > COLLAPSE_LINES ? [...lines2.slice(0, fragmentLines), ...lines2.slice(-fragmentLines)] : lines2;
37405
+ const folded = lines2.length > COLLAPSE_LINES ? lines2.slice(fragmentLines, lines2.length - fragmentLines) : [];
37752
37406
  const hidden = folded.reduce((count2, line) => {
37753
37407
  const gap = NOT_SHOWN_LINE.exec(line);
37754
37408
  return count2 + (gap ? Number((gap[1] ?? "1").replaceAll(",", "")) : 1);
@@ -37781,12 +37435,12 @@ function renderedBodyLines(message, columns) {
37781
37435
  ...message.shell.byLine === true && columns !== void 0 ? { width: shellBodyWidth(Math.max(10, columns - 4)) } : {}
37782
37436
  }).map((row) => " ".repeat(SHELL_RESULT_INDENT) + terminalDisplayText(row.text));
37783
37437
  }
37784
- const lines = message.detail;
37785
- if (!lines || lines.length === 0 || message.activity !== void 0 && !message.detailExpanded)
37438
+ const lines2 = message.detail;
37439
+ if (!lines2 || lines2.length === 0 || message.activity !== void 0 && !message.detailExpanded)
37786
37440
  return [];
37787
- if (message.diff) return renderedDiffLines(lines, message, columns);
37441
+ if (message.diff) return renderedDiffLines(lines2, message, columns);
37788
37442
  const shown = splitDetail(
37789
- lines.map(terminalDisplayText),
37443
+ lines2.map(terminalDisplayText),
37790
37444
  message.detailExpanded === true,
37791
37445
  message.detailRef
37792
37446
  );
@@ -37794,7 +37448,7 @@ function renderedBodyLines(message, columns) {
37794
37448
  return shown.map((line) => gutter + line);
37795
37449
  }
37796
37450
  __name(renderedBodyLines, "renderedBodyLines");
37797
- function renderedDiffLines(lines, message, columns) {
37451
+ function renderedDiffLines(lines2, message, columns) {
37798
37452
  const indent = " ".repeat(SHELL_RESULT_INDENT);
37799
37453
  if (message.diff && columns !== void 0) {
37800
37454
  const drawn = diffViewBody(message.diff, {
@@ -37805,11 +37459,11 @@ function renderedDiffLines(lines, message, columns) {
37805
37459
  return drawn.map((row) => `${indent}${terminalDisplayText(viewRowText(row))}`);
37806
37460
  }
37807
37461
  const preview3 = message.diff?.preview;
37808
- const limit = message.detailExpanded === true || preview3 === void 0 ? lines.length : preview3;
37809
- const shown = lines.slice(0, limit).map((line) => `${indent}${terminalDisplayText(line)}..`);
37810
- if (lines.length > limit) {
37462
+ const limit = message.detailExpanded === true || preview3 === void 0 ? lines2.length : preview3;
37463
+ const shown = lines2.slice(0, limit).map((line) => `${indent}${terminalDisplayText(line)}..`);
37464
+ if (lines2.length > limit) {
37811
37465
  shown.push(
37812
- `${indent}${hiddenLinesHint(lines.length - limit, { canExpand: message.detailRef !== void 0 })}`
37466
+ `${indent}${hiddenLinesHint(lines2.length - limit, { canExpand: message.detailRef !== void 0 })}`
37813
37467
  );
37814
37468
  }
37815
37469
  return shown;
@@ -38020,6 +37674,101 @@ function TranscriptScreen({
38020
37674
  }
38021
37675
  __name(TranscriptScreen, "TranscriptScreen");
38022
37676
 
37677
+ // src/integrations/accounts/codex-login.ts
37678
+ import { spawn as nodeSpawn } from "node:child_process";
37679
+ import { mkdirSync, rmSync } from "node:fs";
37680
+ import { join as join2 } from "node:path";
37681
+ function loginAddressIn(line) {
37682
+ return /https?:\/\/[^\s"'<>]+/.exec(line)?.[0];
37683
+ }
37684
+ __name(loginAddressIn, "loginAddressIn");
37685
+ function lines(sink) {
37686
+ let rest = "";
37687
+ return (chunk) => {
37688
+ rest += chunk.toString();
37689
+ const parts = rest.split(/\r?\n/);
37690
+ rest = parts.pop() ?? "";
37691
+ for (const part of parts) if (part.trim().length > 0) sink(part);
37692
+ };
37693
+ }
37694
+ __name(lines, "lines");
37695
+ async function runCodexLogin(options) {
37696
+ const cleanup = /* @__PURE__ */ __name(() => {
37697
+ rmSync(options.dir, { recursive: true, force: true });
37698
+ }, "cleanup");
37699
+ if (options.signal.aborted) return { kind: "cancelled" };
37700
+ mkdirSync(options.dir, { recursive: true, mode: 448 });
37701
+ const start = options.spawn ?? nodeSpawn;
37702
+ let child;
37703
+ try {
37704
+ child = start(options.command ?? "codex", ["login"], {
37705
+ env: { ...options.env ?? process.env, CODEX_HOME: options.dir },
37706
+ stdio: ["ignore", "pipe", "pipe"]
37707
+ });
37708
+ } catch (error) {
37709
+ cleanup();
37710
+ return {
37711
+ kind: "failed",
37712
+ message: error instanceof Error ? error.message : String(error)
37713
+ };
37714
+ }
37715
+ const sink = options.onOutput ?? (() => void 0);
37716
+ child.stdout?.on("data", lines(sink));
37717
+ child.stderr?.on("data", lines(sink));
37718
+ const outcome = await new Promise((resolveOutcome) => {
37719
+ const stop = /* @__PURE__ */ __name(() => {
37720
+ child.kill("SIGTERM");
37721
+ }, "stop");
37722
+ const finish = /* @__PURE__ */ __name((result) => {
37723
+ options.signal.removeEventListener("abort", stop);
37724
+ resolveOutcome(result);
37725
+ }, "finish");
37726
+ child.once("error", (error) => finish({ kind: "error", error }));
37727
+ child.once("exit", (code) => finish({ kind: "exit", code }));
37728
+ options.signal.addEventListener("abort", stop, { once: true });
37729
+ if (options.signal.aborted) stop();
37730
+ });
37731
+ if (options.signal.aborted) {
37732
+ cleanup();
37733
+ return { kind: "cancelled" };
37734
+ }
37735
+ if (outcome.kind === "error") {
37736
+ cleanup();
37737
+ return outcome.error.code === "ENOENT" ? {
37738
+ kind: "failed",
37739
+ missing: true,
37740
+ message: "Codex is not installed on this computer. Install it, then add the account again."
37741
+ } : { kind: "failed", message: outcome.error.message };
37742
+ }
37743
+ const credential = readCodexCredentialFile(join2(options.dir, "auth.json"));
37744
+ if (outcome.code !== 0 || !credential) {
37745
+ cleanup();
37746
+ return {
37747
+ kind: "failed",
37748
+ message: outcome.code === 0 ? "The Codex sign-in finished without signing in. Try adding the account again." : "The Codex sign-in did not finish. Try adding the account again."
37749
+ };
37750
+ }
37751
+ return { kind: "signed-in", accountId: credential.accountId };
37752
+ }
37753
+ __name(runCodexLogin, "runCodexLogin");
37754
+
37755
+ // src/integrations/accounts/host-facts.ts
37756
+ function hostAccountFacts(input) {
37757
+ const { accountId, activity, now } = input;
37758
+ const label = isDefaultAccountId(accountId) ? void 0 : accountId === void 0 ? void 0 : parseAccountId(accountId)?.label;
37759
+ const until = accountId === void 0 ? void 0 : activity?.limitedUntil[accountId];
37760
+ const noted = accountId === void 0 ? void 0 : activity?.mayBeLimited[accountId];
37761
+ const liveUntil = until !== void 0 && until > now ? until : void 0;
37762
+ const maybe = noted !== void 0 && now - noted < MAY_BE_LIMITED_WINDOW_MS;
37763
+ const limited = input.stopped || liveUntil !== void 0 || maybe;
37764
+ return {
37765
+ ...label ? { account: label } : {},
37766
+ limited,
37767
+ ...limited && liveUntil !== void 0 ? { limitedUntil: liveUntil } : {}
37768
+ };
37769
+ }
37770
+ __name(hostAccountFacts, "hostAccountFacts");
37771
+
38023
37772
  // src/integrations/clipboard/text.ts
38024
37773
  var MAX_CLIPBOARD_TEXT_BYTES = 1e5;
38025
37774
  function writeClipboardText(text, output) {
@@ -38274,14 +38023,14 @@ function recapInput(turns) {
38274
38023
  const usable = turns.map((turn) => ({ role: turn.role, text: cut(turn.text, RECAP_TURN_MAX_CHARS) })).filter((turn) => turn.text.length > 0);
38275
38024
  if (!usable.some((turn) => turn.role === "user")) return void 0;
38276
38025
  if (!usable.some((turn) => turn.role === "assistant")) return void 0;
38277
- const lines = /* @__PURE__ */ __name((list) => list.map((turn) => `${turn.role === "user" ? "Person" : "Namzu"}: ${turn.text}`), "lines");
38026
+ const lines2 = /* @__PURE__ */ __name((list) => list.map((turn) => `${turn.role === "user" ? "Person" : "Namzu"}: ${turn.text}`), "lines");
38278
38027
  let picked = usable.slice(-RECAP_DIGEST_TURNS);
38279
38028
  const newestPrompt = [...usable].reverse().find((turn) => turn.role === "user");
38280
- while (picked.length > 1 && lines(picked).join("\n").length > RECAP_DIGEST_MAX_CHARS) {
38029
+ while (picked.length > 1 && lines2(picked).join("\n").length > RECAP_DIGEST_MAX_CHARS) {
38281
38030
  picked = picked.slice(1);
38282
38031
  }
38283
38032
  if (!picked.includes(newestPrompt)) picked = [newestPrompt, ...picked];
38284
- return lines(picked).join("\n");
38033
+ return lines2(picked).join("\n");
38285
38034
  }
38286
38035
  __name(recapInput, "recapInput");
38287
38036
  function parseRecap(reply) {
@@ -38334,12 +38083,12 @@ function cut2(text, max) {
38334
38083
  __name(cut2, "cut");
38335
38084
  function sideQuestionExcerpt(turns) {
38336
38085
  const usable = turns.map((turn) => ({ role: turn.role, text: cut2(turn.text, SIDE_QUESTION_TURN_MAX_CHARS) })).filter((turn) => turn.text.length > 0);
38337
- const lines = /* @__PURE__ */ __name((list) => list.map((turn) => `${turn.role === "user" ? "Person" : "Namzu"}: ${turn.text}`), "lines");
38086
+ const lines2 = /* @__PURE__ */ __name((list) => list.map((turn) => `${turn.role === "user" ? "Person" : "Namzu"}: ${turn.text}`), "lines");
38338
38087
  let picked = usable.slice(-SIDE_QUESTION_TURNS);
38339
- while (picked.length > 1 && lines(picked).join("\n").length > SIDE_QUESTION_EXCERPT_MAX_CHARS) {
38088
+ while (picked.length > 1 && lines2(picked).join("\n").length > SIDE_QUESTION_EXCERPT_MAX_CHARS) {
38340
38089
  picked = picked.slice(1);
38341
38090
  }
38342
- return lines(picked).join("\n");
38091
+ return lines2(picked).join("\n");
38343
38092
  }
38344
38093
  __name(sideQuestionExcerpt, "sideQuestionExcerpt");
38345
38094
  function sideQuestionBody(question, turns) {
@@ -38612,13 +38361,13 @@ var PHASE_DETAIL_LINE_BUDGET = 3;
38612
38361
  var REPLAYED_TRANSCRIPT_NOTICE = "Replayed from the saved record. This agent has finished and cannot be continued.";
38613
38362
  var COCKPIT_CHROME_ROWS = 2;
38614
38363
  var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
38615
- function AgentNarrationBand({ lines }) {
38616
- if (lines.length === 0) return null;
38364
+ function AgentNarrationBand({ lines: lines2 }) {
38365
+ if (lines2.length === 0) return null;
38617
38366
  return (
38618
38367
  // paddingLeft 3 lands the text where the rail's `main` label starts —
38619
38368
  // past its pointer and bullet cells, the rail being drawn one cell out
38620
38369
  // into the app's own margin — so the two columns line up.
38621
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { flexDirection: "column", paddingLeft: 3, paddingRight: 4, children: lines.map((line) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: theme.text.muted, wrap: "truncate-end", children: terminalDisplayText(oneLine4(line.text)) }) }, line.id)) })
38370
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { flexDirection: "column", paddingLeft: 3, paddingRight: 4, children: lines2.map((line) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: theme.text.muted, wrap: "truncate-end", children: terminalDisplayText(oneLine4(line.text)) }) }, line.id)) })
38622
38371
  );
38623
38372
  }
38624
38373
  __name(AgentNarrationBand, "AgentNarrationBand");
@@ -38787,33 +38536,33 @@ function workflowRowVariants(workflow, now) {
38787
38536
  const count2 = `${workflow.done}/${workflow.total}`;
38788
38537
  const elapsed2 = formatElapsed(Math.max(0, (workflow.endedAt ?? now) - workflow.startedAt));
38789
38538
  const spent = workflow.tokens === void 0 ? void 0 : formatCompactCount(workflow.tokens);
38790
- const join10 = /* @__PURE__ */ __name((parts) => parts.filter((part) => part !== void 0).join(" \xB7 "), "join");
38539
+ const join11 = /* @__PURE__ */ __name((parts) => parts.filter((part) => part !== void 0).join(" \xB7 "), "join");
38791
38540
  const [wide, mid, narrow] = WORKFLOW_BAR_WIDTHS;
38792
38541
  const warned = workflow.large ? [
38793
38542
  {
38794
38543
  barWidth: wide,
38795
- text: join10([count2, elapsed2, spent && `\u2193 ${spent} tokens`, LARGE_WORKFLOW_WARNING])
38544
+ text: join11([count2, elapsed2, spent && `\u2193 ${spent} tokens`, LARGE_WORKFLOW_WARNING])
38796
38545
  },
38797
38546
  {
38798
38547
  barWidth: wide,
38799
- text: join10([count2, elapsed2, spent && `\u2193 ${spent} tokens`, LARGE_WORKFLOW_WARNING_SHORT])
38548
+ text: join11([count2, elapsed2, spent && `\u2193 ${spent} tokens`, LARGE_WORKFLOW_WARNING_SHORT])
38800
38549
  },
38801
38550
  {
38802
38551
  barWidth: wide,
38803
- text: join10([elapsed2, spent && `\u2193 ${spent}`, LARGE_WORKFLOW_WARNING_SHORT])
38552
+ text: join11([elapsed2, spent && `\u2193 ${spent}`, LARGE_WORKFLOW_WARNING_SHORT])
38804
38553
  }
38805
38554
  ] : [];
38806
38555
  const variants = [
38807
38556
  ...warned,
38808
38557
  {
38809
38558
  barWidth: wide,
38810
- text: join10([count2, elapsed2, spent && `\u2193 ${spent} tokens`])
38559
+ text: join11([count2, elapsed2, spent && `\u2193 ${spent} tokens`])
38811
38560
  },
38812
- { barWidth: wide, text: join10([elapsed2, spent && `\u2193 ${spent} tokens`]) },
38813
- { barWidth: wide, text: join10([elapsed2, spent && `\u2193 ${spent}`]) },
38814
- { barWidth: wide, text: join10([spent && `\u2193 ${spent}`]) },
38815
- { barWidth: mid, text: join10([spent && `\u2193 ${spent}`]) },
38816
- { barWidth: narrow, text: join10([spent && `\u2193 ${spent}`]) },
38561
+ { barWidth: wide, text: join11([elapsed2, spent && `\u2193 ${spent} tokens`]) },
38562
+ { barWidth: wide, text: join11([elapsed2, spent && `\u2193 ${spent}`]) },
38563
+ { barWidth: wide, text: join11([spent && `\u2193 ${spent}`]) },
38564
+ { barWidth: mid, text: join11([spent && `\u2193 ${spent}`]) },
38565
+ { barWidth: narrow, text: join11([spent && `\u2193 ${spent}`]) },
38817
38566
  { barWidth: narrow, text: "" }
38818
38567
  ];
38819
38568
  return variants.filter(
@@ -39767,11 +39516,11 @@ function AgentView({
39767
39516
  terminalColumns,
39768
39517
  notice
39769
39518
  }) {
39770
- const lines = agentTranscriptRows(agent, terminalColumns + 5);
39519
+ const lines2 = agentTranscriptRows(agent, terminalColumns + 5);
39771
39520
  const room = Math.max(1, pageRows - (notice ? 1 : 0));
39772
- const offset = Math.min(Math.max(0, tailOffset), Math.max(0, lines.length - room));
39773
- const end = lines.length - offset;
39774
- const shown = lines.slice(Math.max(0, end - room), end);
39521
+ const offset = Math.min(Math.max(0, tailOffset), Math.max(0, lines2.length - room));
39522
+ const end = lines2.length - offset;
39523
+ const shown = lines2.slice(Math.max(0, end - room), end);
39775
39524
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { flexDirection: "column", height: pageRows, flexShrink: 0, justifyContent: "flex-end", children: [
39776
39525
  shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text, { color: theme.text.muted, children: "Waiting for output\u2026" }) : shown.map((line) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Box_default, { height: 1, flexShrink: 0, overflow: "hidden", children: [
39777
39526
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box_default, { width: 2, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -39845,7 +39594,7 @@ function agentTranscriptRows(agent, terminalColumns) {
39845
39594
  }))
39846
39595
  ];
39847
39596
  const width = Math.max(1, (terminalColumns ?? 80) - 10);
39848
- const lines = [];
39597
+ const lines2 = [];
39849
39598
  for (const source of sources) {
39850
39599
  let sourceLine = 0;
39851
39600
  const failure = source.source !== "prompt" && source.source.kind === "system" && source.source.failure;
@@ -39861,7 +39610,7 @@ function agentTranscriptRows(agent, terminalColumns) {
39861
39610
  const boundary = text.lastIndexOf(" ") + 1;
39862
39611
  const split = boundary > 0 && text.slice(0, boundary).trim().length > 0 ? boundary : text.length;
39863
39612
  const rest = text.slice(split);
39864
- lines.push({
39613
+ lines2.push({
39865
39614
  id: `${source.id}:${sourceLine++}`,
39866
39615
  text: text.slice(0, split),
39867
39616
  continuation,
@@ -39875,7 +39624,7 @@ function agentTranscriptRows(agent, terminalColumns) {
39875
39624
  text += point;
39876
39625
  cells += pointCells;
39877
39626
  }
39878
- lines.push({
39627
+ lines2.push({
39879
39628
  id: `${source.id}:${sourceLine++}`,
39880
39629
  text,
39881
39630
  continuation,
@@ -39884,7 +39633,7 @@ function agentTranscriptRows(agent, terminalColumns) {
39884
39633
  });
39885
39634
  }
39886
39635
  }
39887
- return lines;
39636
+ return lines2;
39888
39637
  }
39889
39638
  __name(agentTranscriptRows, "agentTranscriptRows");
39890
39639
  function expandTabs3(line) {
@@ -39932,19 +39681,19 @@ __name(phaseStatus, "phaseStatus");
39932
39681
  function wrapPhaseDetailLines(text, width) {
39933
39682
  const safeWidth = Math.max(1, width);
39934
39683
  const words = oneLine4(text).split(" ").filter((word) => word.length > 0);
39935
- const lines = [];
39684
+ const lines2 = [];
39936
39685
  let line = "";
39937
39686
  for (const word of words) {
39938
39687
  const candidate = line ? `${line} ${word}` : word;
39939
39688
  if (line && stringWidth(candidate) > safeWidth) {
39940
- lines.push(line);
39689
+ lines2.push(line);
39941
39690
  line = word;
39942
39691
  } else {
39943
39692
  line = candidate;
39944
39693
  }
39945
39694
  }
39946
- if (line) lines.push(line);
39947
- return lines;
39695
+ if (line) lines2.push(line);
39696
+ return lines2;
39948
39697
  }
39949
39698
  __name(wrapPhaseDetailLines, "wrapPhaseDetailLines");
39950
39699
  function isTerminalStatus(status) {
@@ -40274,15 +40023,15 @@ var import_react40 = __toESM(require_react(), 1);
40274
40023
 
40275
40024
  // src/integrations/clipboard/image.ts
40276
40025
  import { execFileSync as execFileSync2 } from "node:child_process";
40277
- import { readFileSync as readFileSync4, rmSync } from "node:fs";
40026
+ import { readFileSync as readFileSync4, rmSync as rmSync2 } from "node:fs";
40278
40027
  import { tmpdir } from "node:os";
40279
40028
  import { platform as platform2 } from "node:os";
40280
- import { join as join2 } from "node:path";
40029
+ import { join as join3 } from "node:path";
40281
40030
  var TIMEOUT_MS = 5e3;
40282
40031
  function readClipboardImage() {
40283
40032
  const unavailable2 = clipboardUnavailable();
40284
40033
  if (unavailable2 !== null) return { kind: "unavailable", detail: unavailable2 };
40285
- const file = join2(tmpdir(), `namzu-clip-${Date.now()}.png`);
40034
+ const file = join3(tmpdir(), `namzu-clip-${Date.now()}.png`);
40286
40035
  try {
40287
40036
  if (!saveClipboardImageTo(file)) return { kind: "empty" };
40288
40037
  const buf = readFileSync4(file);
@@ -40292,7 +40041,7 @@ function readClipboardImage() {
40292
40041
  return { kind: "empty" };
40293
40042
  } finally {
40294
40043
  try {
40295
- rmSync(file, { force: true });
40044
+ rmSync2(file, { force: true });
40296
40045
  } catch {
40297
40046
  }
40298
40047
  }
@@ -40407,7 +40156,7 @@ __name(createUndoStack, "createUndoStack");
40407
40156
 
40408
40157
  // src/tui/mentions.ts
40409
40158
  import { execFile as execFile2 } from "node:child_process";
40410
- import { randomBytes as randomBytes2 } from "node:crypto";
40159
+ import { randomBytes } from "node:crypto";
40411
40160
  import { promisify } from "node:util";
40412
40161
 
40413
40162
  // src/tui/mention-file.ts
@@ -40417,7 +40166,7 @@ import {
40417
40166
  fstatSync,
40418
40167
  openSync,
40419
40168
  readSync,
40420
- realpathSync as realpathSync2,
40169
+ realpathSync,
40421
40170
  statSync as statSync2
40422
40171
  } from "node:fs";
40423
40172
  import { resolve as resolve2, sep } from "node:path";
@@ -40427,15 +40176,15 @@ var CHUNK_BYTES = 16 * 1024;
40427
40176
  function readMentionFile(cwd2, rel, range, maxChars, budget) {
40428
40177
  let fd;
40429
40178
  try {
40430
- const root = realpathSync2(resolve2(cwd2));
40431
- const abs = realpathSync2(resolve2(root, rel));
40179
+ const root = realpathSync(resolve2(cwd2));
40180
+ const abs = realpathSync(resolve2(root, rel));
40432
40181
  const inside = /* @__PURE__ */ __name((path) => path === root || path.startsWith(root + sep), "inside");
40433
40182
  if (!inside(abs)) return null;
40434
40183
  const before = statSync2(abs);
40435
40184
  if (!before.isFile()) return null;
40436
40185
  fd = openSync(abs, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
40437
40186
  const opened = fstatSync(fd);
40438
- if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino || !inside(realpathSync2(abs))) {
40187
+ if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino || !inside(realpathSync(abs))) {
40439
40188
  return null;
40440
40189
  }
40441
40190
  const scanLimit = Math.min(opened.size, MAX_SCAN_BYTES, budget.bytes);
@@ -40621,10 +40370,10 @@ __name(subsequenceMatch, "subsequenceMatch");
40621
40370
  function mentionRank(path, query) {
40622
40371
  if (query.length === 0) return [0, path.length, path];
40623
40372
  const normalized2 = path.toLowerCase();
40624
- const basename5 = normalized2.slice(normalized2.lastIndexOf("/") + 1);
40625
- if (basename5.startsWith(query)) return [0, path.length, path];
40373
+ const basename4 = normalized2.slice(normalized2.lastIndexOf("/") + 1);
40374
+ if (basename4.startsWith(query)) return [0, path.length, path];
40626
40375
  if (normalized2.startsWith(query)) return [1, path.length, path];
40627
- if (basename5.includes(query)) return [2, path.length, path];
40376
+ if (basename4.includes(query)) return [2, path.length, path];
40628
40377
  if (normalized2.includes(query)) return [3, path.length, path];
40629
40378
  if (subsequenceMatch(normalized2, query)) return [4, path.length, path];
40630
40379
  return null;
@@ -40726,7 +40475,7 @@ __name(agentNote, "agentNote");
40726
40475
  async function attachMentionedResources(expanded, original, read, maxChars = MAX_FILE_CHARS) {
40727
40476
  const wanted = expanded.resources ?? [];
40728
40477
  if (wanted.length === 0) return expanded;
40729
- const marker = randomBytes2(6).toString("hex");
40478
+ const marker = randomBytes(6).toString("hex");
40730
40479
  const blocks = [];
40731
40480
  const attached = [...expanded.attached];
40732
40481
  let remaining = Math.min(
@@ -41958,10 +41707,58 @@ function overrideMap(overrides) {
41958
41707
  }
41959
41708
  __name(overrideMap, "overrideMap");
41960
41709
 
41710
+ // src/tui/zoom/gesture.ts
41711
+ var REPEAT_MS = 150;
41712
+ var EDITED_MS = 2e3;
41713
+ var ARM_MS = 3e3;
41714
+ var COOLDOWN_MS = 1e3;
41715
+ var LeftGesture = class {
41716
+ constructor(now = Date.now) {
41717
+ this.now = now;
41718
+ }
41719
+ now;
41720
+ static {
41721
+ __name(this, "LeftGesture");
41722
+ }
41723
+ lastPress;
41724
+ lastActed;
41725
+ emptiedAt;
41726
+ armedAt;
41727
+ /** The composer went from holding text to being empty through editing. */
41728
+ noteEmptied() {
41729
+ this.emptiedAt = this.now();
41730
+ this.armedAt = void 0;
41731
+ }
41732
+ /** The composer holds text again: whatever was armed is dropped. */
41733
+ noteFilled() {
41734
+ this.emptiedAt = void 0;
41735
+ this.armedAt = void 0;
41736
+ }
41737
+ press(press) {
41738
+ if (!press.empty || press.attachments || press.shift || press.ctrl || press.meta) return "pass";
41739
+ const at = this.now();
41740
+ const previous = this.lastPress;
41741
+ this.lastPress = at;
41742
+ if (previous !== void 0 && at - previous < REPEAT_MS) return "swallow";
41743
+ if (this.lastActed !== void 0 && at - this.lastActed < COOLDOWN_MS) return "swallow";
41744
+ const armed2 = this.armedAt !== void 0 && at - this.armedAt <= ARM_MS;
41745
+ if (!armed2 && this.emptiedAt !== void 0 && at - this.emptiedAt < EDITED_MS) {
41746
+ this.armedAt = at;
41747
+ this.lastActed = at;
41748
+ return "arm";
41749
+ }
41750
+ this.armedAt = void 0;
41751
+ this.emptiedAt = void 0;
41752
+ this.lastActed = at;
41753
+ return "fire";
41754
+ }
41755
+ };
41756
+
41961
41757
  // src/tui/Composer.tsx
41962
41758
  var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
41963
41759
  var ESC_CLEAR_KEY = "escape-again-to-clear";
41964
41760
  var STASH_KEY = "draft-stash";
41761
+ var SPACES_HINT_KEY = "spaces-arm";
41965
41762
  var STASH_NOTICE_MS = 3e3;
41966
41763
  var STASH_RESTORED_NOTICE_MS = 5e3;
41967
41764
  var ESC_CLEAR_WINDOW_MS = 800;
@@ -42014,12 +41811,12 @@ function suggestionWindowSize(rows) {
42014
41811
  }
42015
41812
  __name(suggestionWindowSize, "suggestionWindowSize");
42016
41813
  function clampDescription(description, width) {
42017
- const lines = wrapChoiceText(description, width);
42018
- if (lines.length <= 2) return lines;
42019
- const second = lines[1] ?? "";
41814
+ const lines2 = wrapChoiceText(description, width);
41815
+ if (lines2.length <= 2) return lines2;
41816
+ const second = lines2[1] ?? "";
42020
41817
  const room = Math.max(1, width - 1);
42021
41818
  const cut3 = second.length > room ? second.slice(0, room).replace(/\s+\S*$/, "") || second.slice(0, room) : second;
42022
- return [lines[0] ?? "", `${cut3.trimEnd()}\u2026`];
41819
+ return [lines2[0] ?? "", `${cut3.trimEnd()}\u2026`];
42023
41820
  }
42024
41821
  __name(clampDescription, "clampDescription");
42025
41822
  function graphemeBoundaries(source) {
@@ -42092,7 +41889,7 @@ function verticalCursor(source, cursor, direction, preferredColumn) {
42092
41889
  };
42093
41890
  }
42094
41891
  __name(verticalCursor, "verticalCursor");
42095
- function composerDisplayValue(source, cursor, codeUnits = COMPOSER_DISPLAY_CODE_UNITS, lines = COMPOSER_DISPLAY_LINES) {
41892
+ function composerDisplayValue(source, cursor, codeUnits = COMPOSER_DISPLAY_CODE_UNITS, lines2 = COMPOSER_DISPLAY_LINES) {
42096
41893
  let start = Math.max(0, cursor - Math.floor(codeUnits / 2));
42097
41894
  let end = Math.min(source.length, start + codeUnits);
42098
41895
  if (end === source.length) start = Math.max(0, end - codeUnits);
@@ -42104,13 +41901,13 @@ function composerDisplayValue(source, cursor, codeUnits = COMPOSER_DISPLAY_CODE_
42104
41901
  for (let index = cursor; index < end; index += 1) {
42105
41902
  if (source.charCodeAt(index) !== 10) continue;
42106
41903
  afterBreaks += 1;
42107
- if (afterBreaks === Math.min(3, lines - 1)) {
41904
+ if (afterBreaks === Math.min(3, lines2 - 1)) {
42108
41905
  end = index;
42109
41906
  break;
42110
41907
  }
42111
41908
  }
42112
41909
  let beforeBreaks = 0;
42113
- const beforeBudget = lines - afterBreaks;
41910
+ const beforeBudget = lines2 - afterBreaks;
42114
41911
  for (let index = cursor - 1; index >= start; index -= 1) {
42115
41912
  if (source.charCodeAt(index) !== 10) continue;
42116
41913
  beforeBreaks += 1;
@@ -42202,6 +41999,7 @@ function Composer({
42202
41999
  onDraftPresenceChange,
42203
42000
  onOpenAgentPanel,
42204
42001
  onOpenAgents,
42002
+ onOpenSpaces,
42205
42003
  onScrollTranscript,
42206
42004
  onRecallQueued,
42207
42005
  queuedEdit,
@@ -42216,6 +42014,7 @@ function Composer({
42216
42014
  }) {
42217
42015
  const terminal = use_window_size_default();
42218
42016
  const [value, setValueState] = (0, import_react40.useState)("");
42017
+ const leftGestureRef = (0, import_react40.useRef)(new LeftGesture());
42219
42018
  const valueRef = (0, import_react40.useRef)("");
42220
42019
  const [cursor, setCursorState] = (0, import_react40.useState)(0);
42221
42020
  const cursorRef = (0, import_react40.useRef)(0);
@@ -42340,6 +42139,9 @@ function Composer({
42340
42139
  const descriptionWidth = Math.max(8, menuTextWidth - commandColumnWidth - 1);
42341
42140
  const setBuffer = (0, import_react40.useCallback)(
42342
42141
  (nextValue, nextCursor = nextValue.length, origin = "recalled", spans) => {
42142
+ if (valueRef.current.length > 0 && nextValue.length === 0)
42143
+ leftGestureRef.current.noteEmptied();
42144
+ else if (nextValue.length > 0) leftGestureRef.current.noteFilled();
42343
42145
  valueRef.current = nextValue;
42344
42146
  cursorRef.current = nextCursor;
42345
42147
  spansRef.current = spans ?? replaceAll(nextValue.length, origin);
@@ -42420,6 +42222,7 @@ function Composer({
42420
42222
  historyDraftRef.current = null;
42421
42223
  setHistorySearch(null);
42422
42224
  setBuffer("", 0, "typed");
42225
+ leftGestureRef.current.noteFilled();
42423
42226
  setHistoryIndex(-1);
42424
42227
  setSelectedIndex(0);
42425
42228
  clearPastes();
@@ -42879,7 +42682,30 @@ function Composer({
42879
42682
  setCursorState(next);
42880
42683
  return;
42881
42684
  }
42882
- if (key.leftArrow && !key.shift && onOpenAgents && valueRef.current.length === 0 && attachmentsRef.current.length === 0) {
42685
+ if (key.leftArrow && onOpenSpaces) {
42686
+ const verdict = leftGestureRef.current.press({
42687
+ empty: valueRef.current.length === 0,
42688
+ attachments: attachmentsRef.current.length > 0,
42689
+ shift: key.shift,
42690
+ ctrl: key.ctrl,
42691
+ meta: key.meta
42692
+ });
42693
+ if (verdict === "fire") {
42694
+ onFooterNoticeRemove?.(SPACES_HINT_KEY);
42695
+ onOpenSpaces();
42696
+ return;
42697
+ }
42698
+ if (verdict === "arm") {
42699
+ onFooterNotice?.({
42700
+ key: SPACES_HINT_KEY,
42701
+ text: "Press \u2190 again to open spaces",
42702
+ priority: "immediate",
42703
+ timeoutMs: ARM_MS
42704
+ });
42705
+ return;
42706
+ }
42707
+ if (verdict === "swallow") return;
42708
+ } else if (key.leftArrow && !key.shift && onOpenAgents && valueRef.current.length === 0 && attachmentsRef.current.length === 0) {
42883
42709
  onOpenAgents();
42884
42710
  return;
42885
42711
  }
@@ -43498,7 +43324,7 @@ function EffortSlider({
43498
43324
  }
43499
43325
  __name(EffortSlider, "EffortSlider");
43500
43326
  function wrapWords2(text, width) {
43501
- const lines = [];
43327
+ const lines2 = [];
43502
43328
  let line = "";
43503
43329
  for (const word of text.split(" ")) {
43504
43330
  const candidate = line.length === 0 ? word : `${line} ${word}`;
@@ -43506,11 +43332,11 @@ function wrapWords2(text, width) {
43506
43332
  line = candidate;
43507
43333
  continue;
43508
43334
  }
43509
- if (line.length > 0) lines.push(line);
43335
+ if (line.length > 0) lines2.push(line);
43510
43336
  line = stringWidth(word) <= width ? word : truncateChoiceText(word, width);
43511
43337
  }
43512
- if (line.length > 0) lines.push(line);
43513
- return lines;
43338
+ if (line.length > 0) lines2.push(line);
43339
+ return lines2;
43514
43340
  }
43515
43341
  __name(wrapWords2, "wrapWords");
43516
43342
 
@@ -43964,7 +43790,7 @@ function PendingInputPanel({
43964
43790
  __name(PendingInputPanel, "PendingInputPanel");
43965
43791
 
43966
43792
  // src/tui/PermissionOverlay.tsx
43967
- import { basename as basename2 } from "node:path";
43793
+ import { basename } from "node:path";
43968
43794
  var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
43969
43795
  function screenConsentNotes(provider) {
43970
43796
  return [
@@ -44077,7 +43903,7 @@ function permissionQuestion(toolCalls) {
44077
43903
  case "bash":
44078
43904
  return "Do you want to proceed?";
44079
43905
  case "edit":
44080
- return path ? `Do you want to make this edit to ${basename2(path)}?` : "Do you want to make this edit?";
43906
+ return path ? `Do you want to make this edit to ${basename(path)}?` : "Do you want to make this edit?";
44081
43907
  case "write":
44082
43908
  return "Do you want to write this file?";
44083
43909
  case "Agent":
@@ -44156,8 +43982,8 @@ function extraAnswer(toolCalls, options) {
44156
43982
  __name(extraAnswer, "extraAnswer");
44157
43983
  function readableBody(summaryText, single2) {
44158
43984
  if (!single2) return summaryText;
44159
- const lines = summaryText.split("\n");
44160
- const body = lines.length > 1 && /^1\. /.test(lines[0] ?? "") ? lines.slice(1) : lines;
43985
+ const lines2 = summaryText.split("\n");
43986
+ const body = lines2.length > 1 && /^1\. /.test(lines2[0] ?? "") ? lines2.slice(1) : lines2;
44161
43987
  return body.map((line) => line.startsWith(" ") ? line.slice(3) : line).join("\n");
44162
43988
  }
44163
43989
  __name(readableBody, "readableBody");
@@ -45527,7 +45353,7 @@ function ModelStepView({
45527
45353
  " change provider"
45528
45354
  ] }) }),
45529
45355
  otherProviders.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box_default, { minWidth: 0, flexShrink: 1, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Text, { color: theme.text.muted, wrap: "truncate-end", children: [
45530
- " \xB7 ",
45356
+ " \xB7 others: ",
45531
45357
  otherProviders.slice(0, 2).map(terminalDisplayText).join(" / "),
45532
45358
  otherProviders.length > 2 ? ` / +${otherProviders.length - 2} more` : ""
45533
45359
  ] }) }) : null
@@ -45774,12 +45600,12 @@ __name(HintLines, "HintLines");
45774
45600
  function rowSourceLines(row, contentWidth, currentMark = "") {
45775
45601
  const text = row.detected.length > 0 ? rowSourceText(row) : rowCredentialNeed(row) ?? "";
45776
45602
  const shape = rowShape(row, contentWidth, currentMark);
45777
- const lines = capChoiceLines(
45603
+ const lines2 = capChoiceLines(
45778
45604
  wrapChoiceText(text, Math.max(1, shape.sourceColumns)),
45779
45605
  MAX_SOURCE_LINES,
45780
45606
  Math.max(1, shape.sourceColumns)
45781
45607
  );
45782
- return shape.stacked ? lines.filter((line) => line !== "") : lines;
45608
+ return shape.stacked ? lines2.filter((line) => line !== "") : lines2;
45783
45609
  }
45784
45610
  __name(rowSourceLines, "rowSourceLines");
45785
45611
  function rowShape(row, contentWidth, currentMark) {
@@ -45804,9 +45630,9 @@ __name(rowShape, "rowShape");
45804
45630
  function rowHeight(row, contentWidth, currentMark = "") {
45805
45631
  const shape = rowShape(row, contentWidth, currentMark);
45806
45632
  const source = rowSourceLines(row, contentWidth, currentMark).length;
45807
- const lines = shape.stacked ? 1 + source : source;
45633
+ const lines2 = shape.stacked ? 1 + source : source;
45808
45634
  const below = currentMark !== "" && !shape.inline;
45809
- return below ? lines + 1 : lines;
45635
+ return below ? lines2 + 1 : lines2;
45810
45636
  }
45811
45637
  __name(rowHeight, "rowHeight");
45812
45638
  function rowWindowWithMarkers(rows, cursor, budget, contentWidth) {
@@ -46428,9 +46254,9 @@ function filterConversations(conversations, query) {
46428
46254
  });
46429
46255
  }
46430
46256
  __name(filterConversations, "filterConversations");
46431
- function openingLines(firstPrompt, lines = 3, width = 200) {
46257
+ function openingLines(firstPrompt, lines2 = 3, width = 200) {
46432
46258
  if (!firstPrompt) return [];
46433
- return firstPrompt.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).slice(0, lines).map((line) => line.length > width ? `${line.slice(0, width - 1)}\u2026` : line);
46259
+ return firstPrompt.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).slice(0, lines2).map((line) => line.length > width ? `${line.slice(0, width - 1)}\u2026` : line);
46434
46260
  }
46435
46261
  __name(openingLines, "openingLines");
46436
46262
  function editLine(text, key) {
@@ -46447,6 +46273,27 @@ function resumeScopeLabel(scope) {
46447
46273
  return scope === "all" ? "All folders" : "This folder";
46448
46274
  }
46449
46275
  __name(resumeScopeLabel, "resumeScopeLabel");
46276
+ function distinguishingTails(conversations) {
46277
+ const titleOf2 = /* @__PURE__ */ __name((conversation) => displayConversationTitle(conversation.title).trim().toLowerCase(), "titleOf");
46278
+ const groups = /* @__PURE__ */ new Map();
46279
+ for (const conversation of conversations) {
46280
+ const group = groups.get(titleOf2(conversation));
46281
+ if (group) group.push(conversation);
46282
+ else groups.set(titleOf2(conversation), [conversation]);
46283
+ }
46284
+ const tails = /* @__PURE__ */ new Map();
46285
+ for (const group of groups.values()) {
46286
+ if (group.length < 2) continue;
46287
+ const lasts = group.map((conversation) => conversation.preview?.trim() ?? "");
46288
+ for (const [index, conversation] of group.entries()) {
46289
+ const last = lasts[index];
46290
+ const unique = last !== "" && lasts.filter((other) => other === last).length === 1;
46291
+ tails.set(conversation.id, unique ? `last: ${last}` : plural(conversation.count, "message"));
46292
+ }
46293
+ }
46294
+ return tails;
46295
+ }
46296
+ __name(distinguishingTails, "distinguishingTails");
46450
46297
 
46451
46298
  // src/tui/ResumePicker.tsx
46452
46299
  var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
@@ -46462,6 +46309,7 @@ function ResumePicker({
46462
46309
  const { stdout } = use_stdout_default();
46463
46310
  const showPreview = (stdout.rows ?? 24) >= 20;
46464
46311
  const { start, items: visible } = selectionWindow(conversations, selected);
46312
+ const tails = distinguishingTails(conversations);
46465
46313
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Box_default, { flexDirection: "column", borderStyle: "round", borderColor: theme.border.focus, paddingX: 1, children: [
46466
46314
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Box_default, { justifyContent: "space-between", children: [
46467
46315
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { color: theme.accent.user, bold: true, children: mode === "restore" ? "Restore an archived conversation" : "Resume a conversation" }),
@@ -46488,13 +46336,19 @@ function ResumePicker({
46488
46336
  const index = start + visibleIndex;
46489
46337
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Box_default, { children: [
46490
46338
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Box_default, { width: 2, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { color: theme.accent.user, children: index === selected ? "\u203A" : " " }) }),
46491
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Box_default, { flexGrow: 1, flexShrink: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
46339
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Box_default, { flexGrow: 1, flexShrink: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
46492
46340
  Text,
46493
46341
  {
46494
46342
  color: index === selected ? theme.text.primary : theme.text.secondary,
46495
46343
  bold: index === selected,
46496
46344
  wrap: "truncate-end",
46497
- children: c.named ? `"${displayConversationTitle(c.title)}"` : displayConversationTitle(c.title)
46345
+ children: [
46346
+ c.named ? `"${displayConversationTitle(c.title)}"` : displayConversationTitle(c.title),
46347
+ tails.has(c.id) && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Text, { color: theme.text.muted, children: [
46348
+ " \xB7 ",
46349
+ tails.get(c.id)
46350
+ ] })
46351
+ ]
46498
46352
  }
46499
46353
  ) }),
46500
46354
  c.pr !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Text, { color: theme.text.muted, children: [
@@ -46564,7 +46418,7 @@ function relativeTime(iso) {
46564
46418
  __name(relativeTime, "relativeTime");
46565
46419
 
46566
46420
  // src/tui/rewind.ts
46567
- import { basename as basename3 } from "node:path";
46421
+ import { basename as basename2 } from "node:path";
46568
46422
  function durableUsers(history) {
46569
46423
  const users = [];
46570
46424
  let ordinal = 0;
@@ -46660,7 +46514,7 @@ function rewindRowDetail(files) {
46660
46514
  case "changes": {
46661
46515
  const names = files.summary?.files ?? files.paths;
46662
46516
  if (names.length === 0) return "No code changes";
46663
- const head = names.length === 1 ? basename3(names[0]) : `${names.length} files changed`;
46517
+ const head = names.length === 1 ? basename2(names[0]) : `${names.length} files changed`;
46664
46518
  return `${head}${countsText(files.summary)}`;
46665
46519
  }
46666
46520
  }
@@ -46675,7 +46529,7 @@ function restoreFilesLine(files) {
46675
46529
  if (files.kind !== "changes") return void 0;
46676
46530
  const names = files.summary?.files ?? files.paths;
46677
46531
  if (names.length === 0) return "The code has not changed (nothing will be restored).";
46678
- const where = names.length === 1 ? basename3(names[0]) : names.length === 2 ? `${basename3(names[0])} and ${basename3(names[1])}` : `${basename3(names[0])} and ${names.length - 1} other files`;
46532
+ const where = names.length === 1 ? basename2(names[0]) : names.length === 2 ? `${basename2(names[0])} and ${basename2(names[1])}` : `${basename2(names[0])} and ${names.length - 1} other files`;
46679
46533
  return `The code will be restored${countsText(files.summary)} in ${where}.`;
46680
46534
  }
46681
46535
  __name(restoreFilesLine, "restoreFilesLine");
@@ -47738,6 +47592,8 @@ function TextPrompt({
47738
47592
  placeholder,
47739
47593
  initialValue = "",
47740
47594
  emptyNotice = "A value is required. Press Esc to cancel.",
47595
+ mask = false,
47596
+ allowEmpty = false,
47741
47597
  hidden = false,
47742
47598
  columns,
47743
47599
  onSubmit,
@@ -47770,7 +47626,7 @@ function TextPrompt({
47770
47626
  }
47771
47627
  if (key.return) {
47772
47628
  const submitted = valueRef.current.trim();
47773
- if (submitted.length === 0) {
47629
+ if (submitted.length === 0 && !allowEmpty) {
47774
47630
  setNotice(emptyNotice);
47775
47631
  return;
47776
47632
  }
@@ -47827,7 +47683,11 @@ function TextPrompt({
47827
47683
  { isActive: !hidden }
47828
47684
  );
47829
47685
  if (hidden) return null;
47830
- const visible = visibleInput(value, cursor, inputWidth);
47686
+ const visible = visibleInput(
47687
+ mask ? "\u2022".repeat([...value].length) : value,
47688
+ mask ? [...value.slice(0, cursor)].length : cursor,
47689
+ inputWidth
47690
+ );
47831
47691
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Box_default, { flexDirection: "column", borderStyle: "round", borderColor: theme.border.focus, paddingX: 1, children: [
47832
47692
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Text, { color: theme.accent.user, bold: true, children: truncateChoiceText(title, contentWidth) }),
47833
47693
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Box_default, { paddingTop: 1, children: [
@@ -47845,7 +47705,10 @@ function TextPrompt({
47845
47705
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Box_default, { paddingTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Text, { color: theme.text.muted, children: truncateChoiceText(
47846
47706
  fitHints(
47847
47707
  [
47848
- { text: "enter save", rank: 5 },
47708
+ {
47709
+ text: allowEmpty ? "enter skip or continue" : mask ? "enter continue" : "enter save",
47710
+ rank: 5
47711
+ },
47849
47712
  { text: "esc cancel", rank: 5 },
47850
47713
  { text: "Ctrl+W delete word", rank: 1 }
47851
47714
  ],
@@ -48122,41 +47985,41 @@ function trustGrantLines(grants, columns) {
48122
47985
  if (!grants || grants.allowRules.length === 0 && grants.directories.length === 0 && grants.toolServers.length === 0)
48123
47986
  return [];
48124
47987
  const room = trustPathWidth(columns);
48125
- const lines = [];
47988
+ const lines2 = [];
48126
47989
  if (grants.allowRules.length > 0) {
48127
- lines.push(
47990
+ lines2.push(
48128
47991
  `This folder allows ${countOf(grants.allowRules.length, "action", "actions")} without asking:`
48129
47992
  );
48130
47993
  for (const rule of grants.allowRules.slice(0, MAX_SHOWN_GRANT_RULES)) {
48131
- lines.push(` ${rule.length + 2 > room ? `${rule.slice(0, Math.max(1, room - 3))}\u2026` : rule}`);
47994
+ lines2.push(` ${rule.length + 2 > room ? `${rule.slice(0, Math.max(1, room - 3))}\u2026` : rule}`);
48132
47995
  }
48133
47996
  const more = grants.allowRules.length - MAX_SHOWN_GRANT_RULES;
48134
- if (more > 0) lines.push(` and ${more} more`);
47997
+ if (more > 0) lines2.push(` and ${more} more`);
48135
47998
  }
48136
47999
  if (grants.directories.length > 0) {
48137
- lines.push(
48000
+ lines2.push(
48138
48001
  `This folder adds ${countOf(grants.directories.length, "folder", "folders")} to the workspace:`
48139
48002
  );
48140
48003
  for (const dir of grants.directories.slice(0, MAX_SHOWN_GRANT_RULES)) {
48141
- lines.push(` ${displayPath(dir, Math.max(1, room - 2))}`);
48004
+ lines2.push(` ${displayPath(dir, Math.max(1, room - 2))}`);
48142
48005
  }
48143
48006
  const more = grants.directories.length - MAX_SHOWN_GRANT_RULES;
48144
- if (more > 0) lines.push(` and ${more} more`);
48007
+ if (more > 0) lines2.push(` and ${more} more`);
48145
48008
  }
48146
48009
  if (grants.toolServers.length > 0) {
48147
- lines.push(
48010
+ lines2.push(
48148
48011
  `This folder starts ${countOf(grants.toolServers.length, "tool server", "tool servers")}:`
48149
48012
  );
48150
48013
  for (const server of shownToolServers(grants)) {
48151
- lines.push(
48014
+ lines2.push(
48152
48015
  ...wrapHard(`${server.name}: ${server.runs}`, Math.max(1, room - 2)).map((l) => ` ${l}`)
48153
48016
  );
48154
48017
  }
48155
48018
  const more = grants.toolServers.length - MAX_SHOWN_GRANT_RULES;
48156
- if (more > 0) lines.push(` and ${more} more, which stay waiting for your approval`);
48019
+ if (more > 0) lines2.push(` and ${more} more, which stay waiting for your approval`);
48157
48020
  }
48158
- lines.push(...wrapBalancedText(GRANTS_NOTICE, room));
48159
- return lines;
48021
+ lines2.push(...wrapBalancedText(GRANTS_NOTICE, room));
48022
+ return lines2;
48160
48023
  }
48161
48024
  __name(trustGrantLines, "trustGrantLines");
48162
48025
  function trustChoiceRows(columns) {
@@ -48192,7 +48055,7 @@ function TrustPrompt({ cwd: cwd2, grants }) {
48192
48055
  trustTitleLines(terminal.columns).map((line) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Text, { color: theme.status.warn, bold: true, children: line }, line)),
48193
48056
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Text, { color: theme.accent.user, children: displayPath(cwd2, trustPathWidth(terminal.columns)) }) }),
48194
48057
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Box_default, { marginTop: 1, flexDirection: "column", children: trustSentenceLines(terminal.columns).flatMap(
48195
- (lines, sentence) => lines.map((line, at) => (
48058
+ (lines2, sentence) => lines2.map((line, at) => (
48196
48059
  // biome-ignore lint/suspicious/noArrayIndexKey: wrapped lines have no identity beyond their order.
48197
48060
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Text, { color: theme.text.secondary, children: line }, `${sentence}-${at}`)
48198
48061
  ))
@@ -48238,6 +48101,223 @@ function ViewportBound({ rows, display = "flex", children }) {
48238
48101
  }
48239
48102
  __name(ViewportBound, "ViewportBound");
48240
48103
 
48104
+ // src/tui/account-flow.ts
48105
+ var ADD_ACCOUNT_VALUE = "__add_account__";
48106
+ function buildAccountPicker(input) {
48107
+ const rows = accountRows({
48108
+ accounts: input.accounts,
48109
+ activity: input.activity,
48110
+ currentId: input.currentId,
48111
+ now: input.now,
48112
+ signedIn: input.signedIn,
48113
+ hidden: /* @__PURE__ */ __name((account) => account.label === "default" && !input.hasUsualSignIn(account.provider), "hidden")
48114
+ });
48115
+ const options = rows.map((row) => {
48116
+ const { account } = row;
48117
+ const host = endpointHost(account);
48118
+ const detail = [describeState(row.state, input.now, input.locale), host].filter((part) => part !== void 0).join(" \xB7 ");
48119
+ return {
48120
+ label: `${accountProductName(account.provider)} \xB7 ${account.label}`,
48121
+ description: input.activity.autoSwitch[account.id] ? `${detail} \xB7 switches automatically` : detail,
48122
+ current: row.current,
48123
+ searchText: `${account.provider} ${account.label} ${host ?? ""}`,
48124
+ ...row.state.kind === "needs-sign-in" ? { selectedDescription: "Needs to be signed in again. Pick Add an account to do that." } : {}
48125
+ };
48126
+ });
48127
+ const values = rows.map((row) => row.account.id);
48128
+ options.push({
48129
+ label: "Add an account\u2026",
48130
+ description: "A Codex sign-in or an API key",
48131
+ ruleBefore: rows.length > 0,
48132
+ searchText: "add new account"
48133
+ });
48134
+ values.push(ADD_ACCOUNT_VALUE);
48135
+ return {
48136
+ title: input.limitedLabel ? `${input.limitedLabel} has used up its allowance` : "Accounts",
48137
+ notice: input.limitedLabel ? "Choose another account to continue this reply." : "Applies to this conversation from its next reply \xB7 other conversations are unaffected",
48138
+ values,
48139
+ options
48140
+ };
48141
+ }
48142
+ __name(buildAccountPicker, "buildAccountPicker");
48143
+ var ACCOUNT_PICKER_HINTS = [
48144
+ { text: "type to filter", rank: 3 },
48145
+ { text: "\u2191\u2193 select", rank: 5 },
48146
+ { text: "enter use", rank: 5 },
48147
+ { text: "ctrl+r rename", rank: 2 },
48148
+ { text: "ctrl+x remove", rank: 2 },
48149
+ { text: "ctrl+a switch automatically", rank: 1 },
48150
+ { text: "esc back", rank: 4 }
48151
+ ];
48152
+ var ADD_KIND_VALUES = ["codex", "api-key"];
48153
+ function addKindPicker() {
48154
+ return {
48155
+ title: "Add an account",
48156
+ values: ADD_KIND_VALUES,
48157
+ options: [
48158
+ {
48159
+ label: "Codex",
48160
+ description: "Sign in with ChatGPT in your browser, using the official Codex sign-in."
48161
+ },
48162
+ {
48163
+ label: "API key",
48164
+ description: "A labelled key for a provider, with an optional address and starting model."
48165
+ }
48166
+ ]
48167
+ };
48168
+ }
48169
+ __name(addKindPicker, "addKindPicker");
48170
+ function apiKeyProviderPicker() {
48171
+ return {
48172
+ title: "Which provider is the key for?",
48173
+ values: API_KEY_ACCOUNT_PROVIDERS,
48174
+ options: API_KEY_ACCOUNT_PROVIDERS.map((provider) => ({
48175
+ label: accountProductName(provider),
48176
+ description: provider === "openai" ? "OpenAI, or any service that speaks its API (give its address next)" : ""
48177
+ }))
48178
+ };
48179
+ }
48180
+ __name(apiKeyProviderPicker, "apiKeyProviderPicker");
48181
+ var LABEL = /^[a-z0-9-]{1,32}$/;
48182
+ function suggestLabel(base, taken) {
48183
+ const root = base.toLowerCase().replace(/[^a-z0-9-]+/g, "-").slice(0, 28) || "account";
48184
+ if (!taken.includes(root) && root !== "default") return root;
48185
+ for (let n = 2; n < 1e3; n++) {
48186
+ const candidate = `${root}-${n}`;
48187
+ if (!taken.includes(candidate)) return candidate;
48188
+ }
48189
+ return `${root}-x`;
48190
+ }
48191
+ __name(suggestLabel, "suggestLabel");
48192
+ function promptFor(wizard, taken) {
48193
+ if (wizard.kind === "codex") {
48194
+ return {
48195
+ title: "Name this Codex account",
48196
+ placeholder: "work",
48197
+ initialValue: suggestLabel("codex", taken),
48198
+ emptyNotice: "A name is required. Press Esc to cancel."
48199
+ };
48200
+ }
48201
+ if (wizard.kind === "rename") {
48202
+ return {
48203
+ title: "New name for this account",
48204
+ placeholder: "work",
48205
+ initialValue: "",
48206
+ emptyNotice: "A name is required. Press Esc to cancel."
48207
+ };
48208
+ }
48209
+ const product = accountProductName(wizard.provider);
48210
+ switch (wizard.step) {
48211
+ case "baseUrl":
48212
+ return {
48213
+ title: `${product} address (optional)`,
48214
+ placeholder: "Press Enter to use the usual address",
48215
+ initialValue: "",
48216
+ emptyNotice: "",
48217
+ allowEmpty: true
48218
+ };
48219
+ case "key":
48220
+ return {
48221
+ title: `${product} API key`,
48222
+ placeholder: "Paste the key \xB7 it is saved privately and never shown",
48223
+ initialValue: "",
48224
+ emptyNotice: "A key is required. Press Esc to cancel.",
48225
+ mask: true
48226
+ };
48227
+ case "label":
48228
+ return {
48229
+ title: "Name this account",
48230
+ placeholder: "work",
48231
+ initialValue: suggestLabel(wizard.provider, taken),
48232
+ emptyNotice: "A name is required. Press Esc to cancel."
48233
+ };
48234
+ case "model":
48235
+ return {
48236
+ title: "Starting model (optional)",
48237
+ placeholder: "Press Enter to use the usual model",
48238
+ initialValue: "",
48239
+ emptyNotice: "",
48240
+ allowEmpty: true
48241
+ };
48242
+ }
48243
+ }
48244
+ __name(promptFor, "promptFor");
48245
+ function validateLabel(value, taken) {
48246
+ if (value === "default") return 'The name "default" belongs to your usual sign-in.';
48247
+ if (!LABEL.test(value)) {
48248
+ return "A name is 1 to 32 characters: lowercase letters, digits and hyphens.";
48249
+ }
48250
+ if (taken.includes(value)) return `There is already an account called "${value}".`;
48251
+ return void 0;
48252
+ }
48253
+ __name(validateLabel, "validateLabel");
48254
+ function advanceWizard(wizard, value, taken) {
48255
+ const text = value.trim();
48256
+ if (wizard.kind === "codex") {
48257
+ const problem = validateLabel(text, taken);
48258
+ return problem ? { kind: "retry", notice: problem } : { kind: "sign-in-codex", label: text };
48259
+ }
48260
+ if (wizard.kind === "rename") {
48261
+ const problem = validateLabel(text, taken);
48262
+ return problem ? { kind: "retry", notice: problem } : { kind: "rename", id: wizard.id, label: text };
48263
+ }
48264
+ switch (wizard.step) {
48265
+ case "baseUrl": {
48266
+ if (text.length === 0) return { kind: "next", wizard: { ...wizard, step: "key" } };
48267
+ let url;
48268
+ try {
48269
+ url = new URL(text);
48270
+ } catch {
48271
+ return { kind: "retry", notice: "That is not a web address. Start it with https://." };
48272
+ }
48273
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
48274
+ return { kind: "retry", notice: "The address must start with https:// or http://." };
48275
+ }
48276
+ if (url.username !== "" || url.password !== "") {
48277
+ return { kind: "retry", notice: "Leave the user name and password out of the address." };
48278
+ }
48279
+ return { kind: "next", wizard: { ...wizard, step: "key", baseUrl: text } };
48280
+ }
48281
+ case "key":
48282
+ return text.length === 0 ? { kind: "retry", notice: "A key is required." } : { kind: "next", wizard: { ...wizard, step: "label", key: text } };
48283
+ case "label": {
48284
+ const problem = validateLabel(text, taken);
48285
+ return problem ? { kind: "retry", notice: problem } : { kind: "next", wizard: { ...wizard, step: "model", label: text } };
48286
+ }
48287
+ case "model": {
48288
+ if (/\s/.test(text)) return { kind: "retry", notice: "A model is one name, without spaces." };
48289
+ return {
48290
+ kind: "add-key",
48291
+ provider: wizard.provider,
48292
+ key: wizard.key ?? "",
48293
+ label: wizard.label ?? "",
48294
+ ...wizard.baseUrl !== void 0 ? { baseUrl: wizard.baseUrl } : {},
48295
+ ...text.length > 0 ? { defaultModel: text } : {}
48296
+ };
48297
+ }
48298
+ }
48299
+ }
48300
+ __name(advanceWizard, "advanceWizard");
48301
+ function startApiKeyWizard(provider) {
48302
+ return {
48303
+ kind: "api-key",
48304
+ provider,
48305
+ step: "baseUrl"
48306
+ };
48307
+ }
48308
+ __name(startApiKeyWizard, "startApiKeyWizard");
48309
+ var CONTINUE_WITH_ANOTHER_ACCOUNT = "enter continue with another account \xB7 esc dismiss";
48310
+ function accountProblem(error, fallback) {
48311
+ return error instanceof AccountRegistryError ? error.message : fallback;
48312
+ }
48313
+ __name(accountProblem, "accountProblem");
48314
+ function wizardProvider(wizard) {
48315
+ if (wizard.kind === "codex") return "codex";
48316
+ if (wizard.kind === "api-key") return wizard.provider;
48317
+ return parseAccountId(wizard.id)?.provider ?? "";
48318
+ }
48319
+ __name(wizardProvider, "wizardProvider");
48320
+
48241
48321
  // src/tui/agent-stop-all.ts
48242
48322
  var STOP_ALL_CONFIRM_MS = 3e3;
48243
48323
  function stoppableBackgroundAgents(agents) {
@@ -48558,6 +48638,16 @@ __name(contextNotice, "contextNotice");
48558
48638
 
48559
48639
  // src/tui/context-usage.ts
48560
48640
  import { readFile } from "node:fs/promises";
48641
+ function effectiveContextWindow(reported, autoCompactWindowTokens) {
48642
+ const lowered = autoCompactWindowTokens !== void 0 && autoCompactWindowTokens > 0 && autoCompactWindowTokens < reported.windowTokens;
48643
+ const source = lowered ? "config" : reported.windowSource;
48644
+ return {
48645
+ windowTokens: lowered ? autoCompactWindowTokens : reported.windowTokens,
48646
+ ...source ? { windowSource: source } : {},
48647
+ windowAssumed: source !== "provider" && source !== "config"
48648
+ };
48649
+ }
48650
+ __name(effectiveContextWindow, "effectiveContextWindow");
48561
48651
  var SOURCE_ORDER = ["Project", "User", "Built-in"];
48562
48652
  function sourceLabel(source) {
48563
48653
  if (source === "project") return "Project";
@@ -48748,15 +48838,15 @@ __name(buildContextRow, "buildContextRow");
48748
48838
 
48749
48839
  // src/tui/copy-targets.ts
48750
48840
  function copyTargetsForResponse(source) {
48751
- const lines = sourceLines(source);
48841
+ const lines2 = sourceLines(source);
48752
48842
  const positioned = [];
48753
- for (let line = 0; line < lines.length; line += 1) {
48754
- const opening = parseFence(lines[line]?.body ?? "");
48843
+ for (let line = 0; line < lines2.length; line += 1) {
48844
+ const opening = parseFence(lines2[line]?.body ?? "");
48755
48845
  if (!opening) continue;
48756
48846
  const body = [];
48757
48847
  let cursor = line + 1;
48758
- for (; cursor < lines.length; cursor += 1) {
48759
- const current = lines[cursor];
48848
+ for (; cursor < lines2.length; cursor += 1) {
48849
+ const current = lines2[cursor];
48760
48850
  if (!current) break;
48761
48851
  const unquoted = stripQuoteDepth(current.body, opening.quoteDepth);
48762
48852
  if (unquoted === null) break;
@@ -48777,12 +48867,12 @@ function copyTargetsForResponse(source) {
48777
48867
  });
48778
48868
  line = Math.max(line, cursor - 1);
48779
48869
  }
48780
- for (let line = 0; line < lines.length; line += 1) {
48781
- if (stripOneQuotePrefix(lines[line]?.body ?? "") === null) continue;
48870
+ for (let line = 0; line < lines2.length; line += 1) {
48871
+ if (stripOneQuotePrefix(lines2[line]?.body ?? "") === null) continue;
48782
48872
  const content = [];
48783
48873
  let cursor = line;
48784
- for (; cursor < lines.length; cursor += 1) {
48785
- const current = lines[cursor];
48874
+ for (; cursor < lines2.length; cursor += 1) {
48875
+ const current = lines2[cursor];
48786
48876
  if (!current) break;
48787
48877
  const stripped = stripOneQuotePrefix(current.body);
48788
48878
  if (stripped === null) break;
@@ -48809,22 +48899,22 @@ function copyTargetsForResponse(source) {
48809
48899
  }
48810
48900
  __name(copyTargetsForResponse, "copyTargetsForResponse");
48811
48901
  function sourceLines(source) {
48812
- const lines = [];
48902
+ const lines2 = [];
48813
48903
  let start = 0;
48814
48904
  while (start < source.length) {
48815
48905
  const lf = source.indexOf("\n", start);
48816
48906
  if (lf < 0) {
48817
- lines.push({ body: source.slice(start), ending: "" });
48907
+ lines2.push({ body: source.slice(start), ending: "" });
48818
48908
  break;
48819
48909
  }
48820
48910
  const crlf = lf > start && source.charCodeAt(lf - 1) === 13;
48821
- lines.push({
48911
+ lines2.push({
48822
48912
  body: source.slice(start, crlf ? lf - 1 : lf),
48823
48913
  ending: crlf ? "\r\n" : "\n"
48824
48914
  });
48825
48915
  start = lf + 1;
48826
48916
  }
48827
- return lines;
48917
+ return lines2;
48828
48918
  }
48829
48919
  __name(sourceLines, "sourceLines");
48830
48920
  function parseFence(body) {
@@ -48889,9 +48979,9 @@ function stripQuoteDepth(body, depth) {
48889
48979
  return rest;
48890
48980
  }
48891
48981
  __name(stripQuoteDepth, "stripQuoteDepth");
48892
- function quoteHasProse(lines) {
48982
+ function quoteHasProse(lines2) {
48893
48983
  let fence = null;
48894
- for (const line of lines) {
48984
+ for (const line of lines2) {
48895
48985
  if (fence) {
48896
48986
  if (isClosingFence(stripQuoteDepth(line.body, fence.quoteDepth) ?? line.body, fence)) {
48897
48987
  fence = null;
@@ -48947,7 +49037,7 @@ __name(editablePrompts, "editablePrompts");
48947
49037
  import { spawn as spawn2 } from "node:child_process";
48948
49038
  import { lstat, mkdtemp, readFile as readFile2, rm, writeFile } from "node:fs/promises";
48949
49039
  import { tmpdir as tmpdir2 } from "node:os";
48950
- import { join as join3 } from "node:path";
49040
+ import { join as join4 } from "node:path";
48951
49041
  var MAX_EDITED_DRAFT_BYTES = 4 * 1024 * 1024;
48952
49042
  var ExternalEditorError = class extends Error {
48953
49043
  static {
@@ -49033,8 +49123,8 @@ __name(resolveExternalEditorCommand, "resolveExternalEditorCommand");
49033
49123
  async function editDraftInExternalEditor(seed, options) {
49034
49124
  options.signal?.throwIfAborted();
49035
49125
  const command = resolveExternalEditorCommand(options.env, options.pressed);
49036
- const directory = await mkdtemp(join3(options.temporaryRoot ?? tmpdir2(), "namzu-editor-"));
49037
- const draftPath = join3(directory, "draft.md");
49126
+ const directory = await mkdtemp(join4(options.temporaryRoot ?? tmpdir2(), "namzu-editor-"));
49127
+ const draftPath = join4(directory, "draft.md");
49038
49128
  let edited;
49039
49129
  let failure;
49040
49130
  try {
@@ -49170,17 +49260,24 @@ __name(monitorEndRow, "monitorEndRow");
49170
49260
 
49171
49261
  // src/tui/launch-settings.ts
49172
49262
  function choosesModel(settings) {
49173
- return Boolean(settings?.provider || settings?.model || settings?.fallbackModels?.length);
49263
+ return Boolean(
49264
+ settings?.provider || settings?.account || settings?.model || settings?.fallbackModels?.length
49265
+ );
49174
49266
  }
49175
49267
  __name(choosesModel, "choosesModel");
49176
- function launchPreferences(saved, settings) {
49268
+ function launchPreferences(saved, settings, accounts) {
49177
49269
  const base = saved ?? { version: 3, providers: [], subagents: { active: [] } };
49270
+ const accountId = settings.account;
49271
+ const provider = accountId ? parseAccountId(accountId)?.provider : settings.provider;
49178
49272
  const applied = applyProviderFlags(base, {
49179
- provider: settings.provider ?? null,
49273
+ provider: provider ?? settings.provider ?? null,
49180
49274
  model: settings.model ?? null
49181
49275
  });
49182
49276
  const chained = applyFallbackFlag(applied, settings.fallbackModels ?? []);
49183
- return chained.providers.length > 0 ? chained : null;
49277
+ if (chained.providers.length === 0) return null;
49278
+ if (!accountId) return chained;
49279
+ const account = accounts?.registry.get(accountId);
49280
+ return account ? bindAccount(chained, account, { model: settings.model }) : null;
49184
49281
  }
49185
49282
  __name(launchPreferences, "launchPreferences");
49186
49283
 
@@ -49611,7 +49708,7 @@ var AskQueue = class {
49611
49708
  };
49612
49709
 
49613
49710
  // src/tui/plugin-view.ts
49614
- import { join as join4 } from "node:path";
49711
+ import { join as join5 } from "node:path";
49615
49712
  function pluginOption(plugin) {
49616
49713
  return {
49617
49714
  label: plugin.name,
@@ -49654,9 +49751,9 @@ function emptyPluginReport(config, cwd2) {
49654
49751
  const reason = config?.enabled !== true ? "Plugins are off. Set plugins.enabled: true in your Namzu configuration to load trusted plugins at startup." : config.autoDiscovery === false ? "Plugin discovery is off (plugins.autoDiscovery: false)." : scopes.length === 0 ? "No plugin scopes are allowed (plugins.allowedScopes: [])." : "No plugins are loaded in this conversation.";
49655
49752
  return [
49656
49753
  reason,
49657
- `Configuration: ${join4(home, "config.yaml")}`,
49658
- ...scopes.includes("project") ? [`Project plugins: ${join4(cwd2, ".namzu", "plugins")}`] : [],
49659
- ...scopes.includes("user") ? [`User plugins: ${join4(home, "plugins")}`] : [],
49754
+ `Configuration: ${join5(home, "config.yaml")}`,
49755
+ ...scopes.includes("project") ? [`Project plugins: ${join5(cwd2, ".namzu", "plugins")}`] : [],
49756
+ ...scopes.includes("user") ? [`User plugins: ${join5(home, "plugins")}`] : [],
49660
49757
  "Each plugin directory contains plugin.json. Only Namzu plugin manifests are supported.",
49661
49758
  "Tools, hooks and MCP servers can execute code. Enable only plugins you trust, then restart Namzu."
49662
49759
  ].map(choiceDisplayText).join("\n");
@@ -49972,8 +50069,8 @@ function formatToolCall(toolName, summary2, standalone = false) {
49972
50069
  return summary2.length > 0 ? `${display}(${summary2})` : display;
49973
50070
  }
49974
50071
  __name(formatToolCall, "formatToolCall");
49975
- function failureBody(lines, folded) {
49976
- return { stdout: [], stderr: lines, failed: true, byLine: true, ...folded ? { folded } : {} };
50072
+ function failureBody(lines2, folded) {
50073
+ return { stdout: [], stderr: lines2, failed: true, byLine: true, ...folded ? { folded } : {} };
49977
50074
  }
49978
50075
  __name(failureBody, "failureBody");
49979
50076
  function foldOf(start) {
@@ -50004,12 +50101,12 @@ function failedCallRows(event, start) {
50004
50101
  ];
50005
50102
  }
50006
50103
  const text = toolFailureText(said, false);
50007
- const lines = text.split("\n");
50104
+ const lines2 = text.split("\n");
50008
50105
  return [
50009
50106
  {
50010
50107
  ...head,
50011
50108
  detail: full,
50012
- shell: failureBody(full, text !== full.join("\n") ? lines : void 0)
50109
+ shell: failureBody(full, text !== full.join("\n") ? lines2 : void 0)
50013
50110
  }
50014
50111
  ];
50015
50112
  }
@@ -50117,7 +50214,7 @@ function toolEndRows(event, start, ctx) {
50117
50214
  },
50118
50215
  {
50119
50216
  role: "tool",
50120
- content: declinedLine(event.declined.note),
50217
+ content: declinedLine(event.declined.note, ctx.stoppedByPerson === true),
50121
50218
  glyph: "\u23BF",
50122
50219
  ...refused ? { detail: refused.rows, diff: refused.diff } : {}
50123
50220
  }
@@ -50162,7 +50259,7 @@ function toolEndRows(event, start, ctx) {
50162
50259
  if (event.isError && event.toolName.toLowerCase() === "agent") {
50163
50260
  const text = toolFailureText(event.output, false);
50164
50261
  const full = toolFailureText(event.output, true).split("\n");
50165
- const lines = text.split("\n");
50262
+ const lines2 = text.split("\n");
50166
50263
  return rows([
50167
50264
  {
50168
50265
  role: "tool",
@@ -50170,7 +50267,7 @@ function toolEndRows(event, start, ctx) {
50170
50267
  glyph: "\u25CF",
50171
50268
  glyphColor: tokenColor("status.error"),
50172
50269
  detail: full,
50173
- shell: failureBody(full, text !== full.join("\n") ? lines : void 0)
50270
+ shell: failureBody(full, text !== full.join("\n") ? lines2 : void 0)
50174
50271
  }
50175
50272
  ]);
50176
50273
  }
@@ -50314,7 +50411,7 @@ __name(noResumeText, "noResumeText");
50314
50411
  import { isAbsolute, relative, resolve as resolve3 } from "node:path";
50315
50412
 
50316
50413
  // src/tui/schedule/loop-host.ts
50317
- import { randomBytes as randomBytes3 } from "node:crypto";
50414
+ import { randomBytes as randomBytes2 } from "node:crypto";
50318
50415
  import { readFileSync as readFileSync5 } from "node:fs";
50319
50416
  var MAX_LOOPS = 20;
50320
50417
  var LOOP_LIFETIME_MS = 7 * 24 * 60 * 60 * 1e3;
@@ -50380,7 +50477,7 @@ var SessionLoopScheduler = class {
50380
50477
  const now = new Date(this.#now());
50381
50478
  const spec = loopSpec(request.interval, now);
50382
50479
  const loop = {
50383
- id: randomBytes3(3).toString("hex"),
50480
+ id: randomBytes2(3).toString("hex"),
50384
50481
  schedule: describeSchedule(spec, { tz: hostTimeZone() }),
50385
50482
  prompt: request.prompt,
50386
50483
  createdAt: now.toISOString(),
@@ -50481,30 +50578,30 @@ __name(when, "when");
50481
50578
  async function listScheduleJobs(ctx) {
50482
50579
  const paths = schedulePaths(ctx.home);
50483
50580
  const { jobs, errors } = listJobs(paths);
50484
- const lines = [];
50581
+ const lines2 = [];
50485
50582
  for (const job of jobs) {
50486
50583
  const tz = job.schedule.kind === "cron" ? job.schedule.tz : hostTimeZone();
50487
50584
  const state = readState(paths, job.id);
50488
50585
  const mark = state.activeRun?.status === "awaiting-approval" ? state.activeRun.handoff ? ` [${parkedRunWords(state.activeRun)}]` : " [waiting for your approval]" : job.state === "pending-confirmation" ? " [needs confirmation]" : job.state === "active" && !confirmationHolds(job) ? " [on hold: changed outside namzu]" : state.activeRun?.status === "running" ? " [running]" : "";
50489
50586
  const kind = job.runKind === "script" ? " [script, 0 tokens]" : job.runKind === "script+agent" ? " [script+agent]" : "";
50490
- lines.push(
50587
+ lines2.push(
50491
50588
  `${job.name} [${job.state}]${kind}${mark}
50492
50589
  ${describeSchedule(job.schedule, { tz })} \xB7 next ${when(nextFireOf(job, state), tz)}${state.lastRun ? ` \xB7 last ${state.lastRun.status}${callsCount(state.lastRun) ? ` (${callsCount(state.lastRun)})` : ""} ${when(state.lastRun.endedAt, tz)}` : ""}
50493
50590
  ${job.workspace === "none" ? "Private scheduler workspace (no project)" : job.folder.canonical}`
50494
50591
  );
50495
50592
  if (job.delivery?.kind === "source-conversation")
50496
- lines.push(` Results return to source conversation ${job.delivery.sessionId}`);
50593
+ lines2.push(` Results return to source conversation ${job.delivery.sessionId}`);
50497
50594
  if (state.activeRun?.status === "awaiting-approval" && state.activeRun.sessionId) {
50498
50595
  const command = resumeCommand(job, state.activeRun.sessionId);
50499
50596
  const verb = state.activeRun.handoff ? "when that is done, continue it" : "answer it";
50500
- lines.push(
50597
+ lines2.push(
50501
50598
  job.folder.canonical === ctx.cwd ? ` ${verb}: /resume and pick "Scheduled: ${job.name}", or ${command}` : ` ${verb}: ${command}`
50502
50599
  );
50503
50600
  }
50504
50601
  }
50505
50602
  return visibleScheduleMessage(
50506
50603
  [
50507
- jobs.length === 0 ? errors.length > 0 ? "No readable scheduled jobs." : 'No scheduled jobs. Ask for one ("run this every night at 3"), or /schedule add.' : lines.join("\n"),
50604
+ jobs.length === 0 ? errors.length > 0 ? "No readable scheduled jobs." : 'No scheduled jobs. Ask for one ("run this every night at 3"), or /schedule add.' : lines2.join("\n"),
50508
50605
  ...errors.length > 0 ? [
50509
50606
  `${errors.length} job file${errors.length === 1 ? "" : "s"} could not be read; inspect or repair the files under NAMZU_HOME.`
50510
50607
  ] : [],
@@ -50857,7 +50954,7 @@ async function runLoopCommand(args, loops, say) {
50857
50954
  __name(runLoopCommand, "runLoopCommand");
50858
50955
 
50859
50956
  // src/tui/schedule/resume.ts
50860
- import { realpathSync as realpathSync3 } from "node:fs";
50957
+ import { realpathSync as realpathSync2 } from "node:fs";
50861
50958
  import { resolve as resolve4 } from "node:path";
50862
50959
  async function findScheduledPark(home, sessionId) {
50863
50960
  const paths = schedulePaths(home);
@@ -50935,7 +51032,7 @@ __name(recordedTurnModel, "recordedTurnModel");
50935
51032
  var STRICTER = ["plan", "strict"];
50936
51033
  function canonical(path) {
50937
51034
  try {
50938
- return realpathSync3(path);
51035
+ return realpathSync2(path);
50939
51036
  } catch {
50940
51037
  return resolve4(path);
50941
51038
  }
@@ -51111,7 +51208,7 @@ __name(prepareScheduledResume, "prepareScheduledResume");
51111
51208
 
51112
51209
  // src/tui/schedule/startup.ts
51113
51210
  import { readFileSync as readFileSync6 } from "node:fs";
51114
- import { join as join5 } from "node:path";
51211
+ import { join as join6 } from "node:path";
51115
51212
  function ago(ms) {
51116
51213
  if (ms < 36e5) return `${Math.max(1, Math.round(ms / 6e4))} min`;
51117
51214
  if (ms < 1728e5) return `${Math.round(ms / 36e5)} h`;
@@ -51193,7 +51290,7 @@ function scheduleStartupLine(home, cwd2, now = Date.now()) {
51193
51290
  parts.push("The scheduler is installed but has not started \u2014 namzu schedule status");
51194
51291
  }
51195
51292
  }
51196
- const suppressed = takeSuppressedCount(join5(paths.daemon, "notify.json"));
51293
+ const suppressed = takeSuppressedCount(join6(paths.daemon, "notify.json"));
51197
51294
  if (suppressed > 0)
51198
51295
  parts.push(
51199
51296
  `${plural(suppressed, "scheduled notification")} ${suppressed === 1 ? "was" : "were"} held back`
@@ -51211,7 +51308,7 @@ function scheduleStartupLine(home, cwd2, now = Date.now()) {
51211
51308
  __name(scheduleStartupLine, "scheduleStartupLine");
51212
51309
 
51213
51310
  // src/tui/schedule/tool-host.ts
51214
- import { realpathSync as realpathSync4 } from "node:fs";
51311
+ import { realpathSync as realpathSync3 } from "node:fs";
51215
51312
  import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve5 } from "node:path";
51216
51313
  function within(root, path) {
51217
51314
  const rel = relative2(root, path);
@@ -51220,7 +51317,7 @@ function within(root, path) {
51220
51317
  __name(within, "within");
51221
51318
  function canonicalCwd(cwd2) {
51222
51319
  try {
51223
- return realpathSync4(cwd2);
51320
+ return realpathSync3(cwd2);
51224
51321
  } catch {
51225
51322
  return resolve5(cwd2);
51226
51323
  }
@@ -51264,7 +51361,7 @@ async function credentialText(provider) {
51264
51361
  }
51265
51362
  }
51266
51363
  __name(credentialText, "credentialText");
51267
- function confirmationBody(p, findings, lines) {
51364
+ function confirmationBody(p, findings, lines2) {
51268
51365
  const scriptSection = p.runKind && p.runKind !== "agent" && p.script ? [
51269
51366
  `${p.runKind === "script" ? "Script" : "Wake-gate script"} (exactly as it will run, ${p.script.shell}; shell commands checked against the scheduled-run floor and deny rules)`,
51270
51367
  ...p.script.body.split("\n").map((l) => ` \u2502 ${l}`),
@@ -51278,7 +51375,7 @@ function confirmationBody(p, findings, lines) {
51278
51375
  ...p.prompt.split("\n").map((l) => ` \u2502 ${l}`)
51279
51376
  ] : [];
51280
51377
  return [
51281
- ...lines,
51378
+ ...lines2,
51282
51379
  ...p.runKind === "script" ? [] : [`Credential ${p.credentialSource ?? "unknown"}`],
51283
51380
  ...p.warnings.filter((w) => !(p.networkAccess && w === "This run can reach the network.")).map((w) => `Warning ${w}`),
51284
51381
  ...findings.map((f) => `Warning ${f}`),
@@ -51287,16 +51384,16 @@ function confirmationBody(p, findings, lines) {
51287
51384
  ];
51288
51385
  }
51289
51386
  __name(confirmationBody, "confirmationBody");
51290
- function renderConfirmation(request, lines) {
51387
+ function renderConfirmation(request, lines2) {
51291
51388
  return visibleScheduleMessage(
51292
51389
  [
51293
51390
  "PROPOSED BY THE MODEL, NOT BY YOU \u2014 a scheduled job that runs later with nobody watching.",
51294
- ...confirmationBody(request.preview, request.promptFindings, lines)
51391
+ ...confirmationBody(request.preview, request.promptFindings, lines2)
51295
51392
  ].join("\n")
51296
51393
  );
51297
51394
  }
51298
51395
  __name(renderConfirmation, "renderConfirmation");
51299
- function renderUpdateConfirmation(request, lines) {
51396
+ function renderUpdateConfirmation(request, lines2) {
51300
51397
  return visibleScheduleMessage(
51301
51398
  [
51302
51399
  `PROPOSED BY THE MODEL, NOT BY YOU \u2014 a change to the scheduled job ${request.preview.name}, which runs later with nobody watching.`,
@@ -51304,7 +51401,7 @@ function renderUpdateConfirmation(request, lines) {
51304
51401
  ...request.permissionsChange ? [
51305
51402
  "Warning THE PERMISSIONS CHANGE: from its next run the job may do what the rules below allow."
51306
51403
  ] : [],
51307
- ...confirmationBody(request.preview, request.promptFindings, lines)
51404
+ ...confirmationBody(request.preview, request.promptFindings, lines2)
51308
51405
  ].join("\n")
51309
51406
  );
51310
51407
  }
@@ -51668,16 +51765,16 @@ function createScheduleToolHost(ui) {
51668
51765
  ), "view");
51669
51766
  const differs = describeChanges(view(current), view(job));
51670
51767
  if (differs.length === 0) throw new Error(`That changes nothing in "${current.name}".`);
51671
- const lines = [...changesSinceConfirmed(readHistory(paths(), current.id)), ...differs];
51768
+ const lines2 = [...changesSinceConfirmed(readHistory(paths(), current.id)), ...differs];
51672
51769
  proposedUpdates.set(preview3, {
51673
51770
  current,
51674
51771
  job,
51675
51772
  lines: previewLines(job, policy, now),
51676
- changes: lines
51773
+ changes: lines2
51677
51774
  });
51678
51775
  return {
51679
51776
  preview: preview3,
51680
- changes: lines,
51777
+ changes: lines2,
51681
51778
  permissionsChange: permissionsChanged(current, job)
51682
51779
  };
51683
51780
  },
@@ -52247,12 +52344,12 @@ function setSkillSuggestions(on, opts = {}) {
52247
52344
  __name(setSkillSuggestions, "setSkillSuggestions");
52248
52345
 
52249
52346
  // src/tui/skills/suggestion-ledger.ts
52250
- import { mkdirSync, readFileSync as readFileSync7, renameSync, writeFileSync } from "node:fs";
52251
- import { dirname, join as join6 } from "node:path";
52347
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync7, renameSync, writeFileSync } from "node:fs";
52348
+ import { dirname, join as join7 } from "node:path";
52252
52349
  var SUGGESTION_IGNORE_LIMIT = 3;
52253
52350
  var FRESH_LEDGER = { v: 1, unanswered: 0, stopped: false };
52254
52351
  function suggestionLedgerPath(namzuHome) {
52255
- return join6(namzuHome, "skills", ".suggestions.json");
52352
+ return join7(namzuHome, "skills", ".suggestions.json");
52256
52353
  }
52257
52354
  __name(suggestionLedgerPath, "suggestionLedgerPath");
52258
52355
  function readSuggestionLedger(namzuHome) {
@@ -52268,7 +52365,7 @@ __name(readSuggestionLedger, "readSuggestionLedger");
52268
52365
  function writeSuggestionLedger(namzuHome, ledger) {
52269
52366
  const path = suggestionLedgerPath(namzuHome);
52270
52367
  try {
52271
- mkdirSync(dirname(path), { recursive: true });
52368
+ mkdirSync2(dirname(path), { recursive: true });
52272
52369
  const temp = `${path}.${process.pid}.tmp`;
52273
52370
  writeFileSync(temp, `${JSON.stringify(ledger)}
52274
52371
  `, { mode: 384 });
@@ -53361,13 +53458,13 @@ __name(setRecapSetting, "setRecapSetting");
53361
53458
  function describeRecapSetting(input) {
53362
53459
  const fromFiles = input.tui?.recap !== false;
53363
53460
  const word = input.env.NAMZU_RECAP?.trim().toLowerCase();
53364
- const lines = [`Recaps: ${input.enabledNow ? "on" : "off"} in this conversation.`];
53365
- lines.push(`Config files: ${fromFiles ? "on (the default)" : "off"}.`);
53461
+ const lines2 = [`Recaps: ${input.enabledNow ? "on" : "off"} in this conversation.`];
53462
+ lines2.push(`Config files: ${fromFiles ? "on (the default)" : "off"}.`);
53366
53463
  if (word !== void 0 && (OFF_WORDS.has(word) || ON_WORDS.has(word))) {
53367
- lines.push(`NAMZU_RECAP is set and turns them ${ON_WORDS.has(word) ? "on" : "off"}.`);
53464
+ lines2.push(`NAMZU_RECAP is set and turns them ${ON_WORDS.has(word) ? "on" : "off"}.`);
53368
53465
  }
53369
- lines.push("/config recap on|off changes it; /recap writes one now.");
53370
- return lines.join("\n");
53466
+ lines2.push("/config recap on|off changes it; /recap writes one now.");
53467
+ return lines2.join("\n");
53371
53468
  }
53372
53469
  __name(describeRecapSetting, "describeRecapSetting");
53373
53470
 
@@ -53913,18 +54010,18 @@ function sanitiseStatusLineOutput(stdout) {
53913
54010
  new RegExp(`${HOLD}(\\d+)${HOLD}`, "gu"),
53914
54011
  (_m, index) => kept[Number(index)] ?? ""
53915
54012
  );
53916
- const lines = cleaned.trim().split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
53917
- return lines.length > 0 ? lines.join("\n") : void 0;
54013
+ const lines2 = cleaned.trim().split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
54014
+ return lines2.length > 0 ? lines2.join("\n") : void 0;
53918
54015
  }
53919
54016
  __name(sanitiseStatusLineOutput, "sanitiseStatusLineOutput");
53920
54017
  function carryStyleAcrossLines(text) {
53921
- const lines = text.split("\n");
53922
- if (lines.length === 1) return lines;
53923
- const out = [lines[0] ?? ""];
54018
+ const lines2 = text.split("\n");
54019
+ if (lines2.length === 1) return lines2;
54020
+ const out = [lines2[0] ?? ""];
53924
54021
  let carried = "";
53925
- for (let index = 1; index < lines.length; index++) {
53926
- carried += (lines[index - 1]?.match(KEPT) ?? []).join("");
53927
- out.push(carried + (lines[index] ?? ""));
54022
+ for (let index = 1; index < lines2.length; index++) {
54023
+ carried += (lines2[index - 1]?.match(KEPT) ?? []).join("");
54024
+ out.push(carried + (lines2[index] ?? ""));
53928
54025
  }
53929
54026
  return out;
53930
54027
  }
@@ -54170,7 +54267,7 @@ __name(runStatusLineCommand, "runStatusLineCommand");
54170
54267
 
54171
54268
  // src/tui/status-line/workspace-git.ts
54172
54269
  import { execFile as execFile4 } from "node:child_process";
54173
- import { basename as basename4, resolve as resolve6 } from "node:path";
54270
+ import { basename as basename3, resolve as resolve6 } from "node:path";
54174
54271
  var GIT_TIMEOUT_MS = 3e3;
54175
54272
  function parseRemoteUrl(url) {
54176
54273
  const trimmed = url.trim();
@@ -54204,7 +54301,7 @@ async function readWorkspaceGit(cwd2, git2 = runGit) {
54204
54301
  try {
54205
54302
  const [gitDir, commonDir, top] = (await git2(["rev-parse", "--git-dir", "--git-common-dir", "--show-toplevel"], cwd2)).trim().split("\n");
54206
54303
  if (gitDir && commonDir && top && resolve6(cwd2, gitDir) !== resolve6(cwd2, commonDir)) {
54207
- out.gitWorktree = basename4(top);
54304
+ out.gitWorktree = basename3(top);
54208
54305
  }
54209
54306
  } catch {
54210
54307
  }
@@ -54262,14 +54359,14 @@ __name(useStatusLine, "useStatusLine");
54262
54359
  var FENCE2 = /^ {0,3}(```|~~~)/;
54263
54360
  function splitCompleteBlocks(buffer) {
54264
54361
  if (buffer.length === 0) return { ready: "", rest: "" };
54265
- const lines = buffer.split("\n");
54362
+ const lines2 = buffer.split("\n");
54266
54363
  let fenceOpen = false;
54267
54364
  let cut3 = -1;
54268
54365
  let offset = 0;
54269
54366
  let sawContent = false;
54270
- for (let i = 0; i < lines.length; i++) {
54271
- const line = lines[i];
54272
- const isLast = i === lines.length - 1;
54367
+ for (let i = 0; i < lines2.length; i++) {
54368
+ const line = lines2[i];
54369
+ const isLast = i === lines2.length - 1;
54273
54370
  if (FENCE2.test(line)) {
54274
54371
  fenceOpen = !fenceOpen;
54275
54372
  sawContent = true;
@@ -54320,13 +54417,13 @@ __name(splitSafeCut, "splitSafeCut");
54320
54417
  var PIPE_ROW = /^\s*\|/;
54321
54418
  function holdTableHeader(buffer, cut3) {
54322
54419
  const ready = buffer.slice(0, cut3);
54323
- const lines = ready.split("\n");
54324
- const last = ready.endsWith("\n") ? lines.length - 2 : lines.length - 1;
54420
+ const lines2 = ready.split("\n");
54421
+ const last = ready.endsWith("\n") ? lines2.length - 2 : lines2.length - 1;
54325
54422
  let first = last;
54326
- while (first >= 0 && PIPE_ROW.test(lines[first] ?? "")) first -= 1;
54423
+ while (first >= 0 && PIPE_ROW.test(lines2[first] ?? "")) first -= 1;
54327
54424
  first += 1;
54328
54425
  if (last - first + 1 !== 1) return { ready, rest: buffer.slice(cut3) };
54329
- const at = first === 0 ? 0 : lines.slice(0, first).join("\n").length + 1;
54426
+ const at = first === 0 ? 0 : lines2.slice(0, first).join("\n").length + 1;
54330
54427
  return { ready: buffer.slice(0, at), rest: buffer.slice(at) };
54331
54428
  }
54332
54429
  __name(holdTableHeader, "holdTableHeader");
@@ -54937,6 +55034,7 @@ __name(reviewMergeBase, "reviewMergeBase");
54937
55034
 
54938
55035
  // src/tui/App.tsx
54939
55036
  var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
55037
+ var AUTO_MODE_NOTICE_KEY = "auto-mode";
54940
55038
  var SESSION_CLOSE_ON_EXIT_MS = 5e3;
54941
55039
  var FREE_TEXT_ANSWER = "__free_text__";
54942
55040
  var SHELLS_FOCUS = "shells";
@@ -55132,6 +55230,10 @@ function AppBody({
55132
55230
  onExitSummary,
55133
55231
  externalEditor = defaultExternalEditor,
55134
55232
  terminationExit,
55233
+ repaint,
55234
+ onOpenSpaces,
55235
+ onConfirmExit,
55236
+ beforeExit,
55135
55237
  examplePrompts = false,
55136
55238
  queuedHintCount,
55137
55239
  tipHistory
@@ -55169,11 +55271,11 @@ function AppBody({
55169
55271
  });
55170
55272
  flushLearnedRef.current = () => {
55171
55273
  if (stateRef.current !== "idle" || abortRef.current !== null) return;
55172
- const lines = learnedQueueRef.current.splice(0);
55173
- if (lines.length === 0) return;
55274
+ const lines2 = learnedQueueRef.current.splice(0);
55275
+ if (lines2.length === 0) return;
55174
55276
  setMessages((prev) => [
55175
55277
  ...prev,
55176
- ...lines.map((content) => ({
55278
+ ...lines2.map((content) => ({
55177
55279
  id: nextId(),
55178
55280
  role: "system",
55179
55281
  content,
@@ -55326,11 +55428,11 @@ function AppBody({
55326
55428
  if (idleJobNoticesRef.current.ownerSession !== session) return { ids: [] };
55327
55429
  const pending = idleJobNoticesRef.current.pending;
55328
55430
  if (pending.size === 0) return { ids: [] };
55329
- const lines = [...pending.values()];
55431
+ const lines2 = [...pending.values()];
55330
55432
  return {
55331
55433
  ids: [...pending.keys()],
55332
55434
  text: `Background jobs that ended since your last turn:
55333
- ${lines.map((l) => `- ${l}`).join("\n")}`
55435
+ ${lines2.map((l) => `- ${l}`).join("\n")}`
55334
55436
  };
55335
55437
  }, "snapshotIdleJobNotices");
55336
55438
  const snapshotMonitorNotices = /* @__PURE__ */ __name(() => session?.monitors?.peek() ?? { ids: [] }, "snapshotMonitorNotices");
@@ -55552,6 +55654,14 @@ ${blocks.join("\n\n")}`;
55552
55654
  const [textPrompt, setTextPromptState] = (0, import_react60.useState)(null);
55553
55655
  const textPromptRef = (0, import_react60.useRef)(null);
55554
55656
  const textPromptTokenRef = (0, import_react60.useRef)(0);
55657
+ const accountLoginRef = (0, import_react60.useRef)(null);
55658
+ const accountWizardRef = (0, import_react60.useRef)(null);
55659
+ const pendingAccountSwitchRef = (0, import_react60.useRef)(null);
55660
+ const sessionAccountRef = (0, import_react60.useRef)(null);
55661
+ const accountReasonRef = (0, import_react60.useRef)(null);
55662
+ const resumeAccountRef = (0, import_react60.useRef)(null);
55663
+ const accountFellBackNoticeRef = (0, import_react60.useRef)(null);
55664
+ const lastHumanTurnRef = (0, import_react60.useRef)(null);
55555
55665
  const setTextPrompt = (0, import_react60.useCallback)((next) => {
55556
55666
  textPromptRef.current = next;
55557
55667
  setTextPromptState(next);
@@ -55564,6 +55674,7 @@ ${blocks.join("\n\n")}`;
55564
55674
  const setHandoffPark = (0, import_react60.useCallback)((value) => {
55565
55675
  handoffParkRef.current = value;
55566
55676
  setHandoffParkState(value);
55677
+ peersRef.current?.publish();
55567
55678
  }, []);
55568
55679
  const autoResumeAttemptRef = (0, import_react60.useRef)(0);
55569
55680
  const selfMendingPauseRowRef = (0, import_react60.useRef)(new SelfMendingPauseRow());
@@ -55939,6 +56050,7 @@ ${blocks.join("\n\n")}`;
55939
56050
  mode: /* @__PURE__ */ __name(() => permissionModeRef.current, "mode")
55940
56051
  });
55941
56052
  }
56053
+ const stoppedAtPromptRef = (0, import_react60.useRef)(/* @__PURE__ */ new Set());
55942
56054
  const refusalEndedTurnRef = (0, import_react60.useRef)(false);
55943
56055
  const learningQuestionsRef = (0, import_react60.useRef)(null);
55944
56056
  if (learningQuestionsRef.current === null) learningQuestionsRef.current = createQuestionGate();
@@ -55952,6 +56064,7 @@ ${blocks.join("\n\n")}`;
55952
56064
  setPermissionReason(null);
55953
56065
  permissionShownRef.current = pending;
55954
56066
  if (pending) {
56067
+ readSearchGroup.close();
55955
56068
  permissionOpenedAtRef.current = Date.now();
55956
56069
  permissionResolveRef.current = (decision) => permissionAsksRef.current?.answer(decision);
55957
56070
  setPermissionDetailsOpen(!pending.summary.complete);
@@ -56043,7 +56156,7 @@ ${blocks.join("\n\n")}`;
56043
56156
  const scope = scopeRef.current;
56044
56157
  if (!sessions || !scope || !conversationMaterializedRef.current) return void 0;
56045
56158
  try {
56046
- return join7(sessions.paths.sessionDir({ sessionId: scope.sessionId }), "loops.json");
56159
+ return join8(sessions.paths.sessionDir({ sessionId: scope.sessionId }), "loops.json");
56047
56160
  } catch {
56048
56161
  return void 0;
56049
56162
  }
@@ -56143,15 +56256,28 @@ ${blocks.join("\n\n")}`;
56143
56256
  closing,
56144
56257
  new Promise((resolve9) => setTimeout(resolve9, SESSION_CLOSE_ON_EXIT_MS).unref?.())
56145
56258
  ]);
56146
- void bounded.catch(() => void 0).finally(() => exit());
56147
- }, [cancelPendingModelSwitch, exit, session]);
56148
- const exitWithSummary = (0, import_react60.useCallback)(() => {
56259
+ void bounded.catch(() => void 0).then(() => beforeExit?.()).catch(() => void 0).finally(() => exit());
56260
+ }, [beforeExit, cancelPendingModelSwitch, exit, session]);
56261
+ const exitNow = (0, import_react60.useCallback)(() => {
56149
56262
  onExitSummary?.({
56150
56263
  ...palDefinitionRef.current ? { palId: palDefinitionRef.current.id } : {},
56151
56264
  ...conversationMaterializedRef.current && scopeRef.current?.sessionId ? { conversationId: scopeRef.current.sessionId } : {}
56152
56265
  });
56153
56266
  closeAndExit();
56154
56267
  }, [closeAndExit, onExitSummary]);
56268
+ const exitAsking = (0, import_react60.useRef)(false);
56269
+ const exitWithSummary = (0, import_react60.useCallback)(() => {
56270
+ if (!onConfirmExit) {
56271
+ exitNow();
56272
+ return;
56273
+ }
56274
+ if (exitAsking.current) return;
56275
+ exitAsking.current = true;
56276
+ void onConfirmExit().catch(() => true).then((leave) => {
56277
+ exitAsking.current = false;
56278
+ if (leave) exitNow();
56279
+ });
56280
+ }, [exitNow, onConfirmExit]);
56155
56281
  const [exitHint, setExitHint] = (0, import_react60.useState)(null);
56156
56282
  const exitTimerRef = (0, import_react60.useRef)(null);
56157
56283
  const notices = useNotifications();
@@ -56240,6 +56366,13 @@ ${blocks.join("\n\n")}`;
56240
56366
  },
56241
56367
  [stdout.isTTY, writeStdout]
56242
56368
  );
56369
+ (0, import_react60.useEffect)(() => {
56370
+ if (!repaint) return;
56371
+ repaint.current = () => resetTranscript({ preserveTranscriptScreen: true });
56372
+ return () => {
56373
+ repaint.current = null;
56374
+ };
56375
+ }, [repaint, resetTranscript]);
56243
56376
  const scrollWasOpenRef = (0, import_react60.useRef)(false);
56244
56377
  (0, import_react60.useEffect)(() => {
56245
56378
  const wasOpen = scrollWasOpenRef.current;
@@ -56966,13 +57099,15 @@ ${blocks.join("\n\n")}`;
56966
57099
  );
56967
57100
  } else if (mode === "classify" && !autoModeNoticeShownRef.current) {
56968
57101
  autoModeNoticeShownRef.current = true;
56969
- pushMessage(
56970
- "system",
56971
- "Auto mode: a second model checks each call you would be asked about."
56972
- );
57102
+ addNotice({
57103
+ key: AUTO_MODE_NOTICE_KEY,
57104
+ text: "Auto mode: a second model checks each call you would be asked about.",
57105
+ priority: "immediate"
57106
+ });
56973
57107
  }
57108
+ if (mode !== "classify") removeNotice(AUTO_MODE_NOTICE_KEY);
56974
57109
  },
56975
- [pushMessage, rulesChanged, session]
57110
+ [addNotice, pushMessage, removeNotice, rulesChanged, session]
56976
57111
  );
56977
57112
  const applyPermissionMode = (0, import_react60.useCallback)(
56978
57113
  (mode, announce = true) => {
@@ -57746,6 +57881,10 @@ ${blocks.join("\n\n")}`;
57746
57881
  removeStoredCredential(value);
57747
57882
  return;
57748
57883
  }
57884
+ if (picker.kind === "account" || picker.kind === "account-add" || picker.kind === "account-provider" || picker.kind === "account-remove") {
57885
+ accountActionsRef.current?.choose(picker, value);
57886
+ return;
57887
+ }
57749
57888
  if (picker.kind === "reasoning-effort" && value === HYPERMODE_VALUE) {
57750
57889
  applyHypermode(!hypermodeRef.current, picker.selectedSession);
57751
57890
  return;
@@ -57929,6 +58068,22 @@ ${blocks.join("\n\n")}`;
57929
58068
  const restored = await loadResumableConversation(sessions, requestedConversationId);
57930
58069
  sessionId = asSessionId(requestedConversationId);
57931
58070
  modelHistoryRef.current = restored;
58071
+ try {
58072
+ const facts = await readConversationFacts(sessions, sessionId, "tolerant");
58073
+ const lastBinding = facts?.records.filter((record3) => record3.type === "account_bound").at(-1);
58074
+ if (facts && lastBinding?.type === "account_bound") {
58075
+ const bound = resolveBoundAccount(
58076
+ facts.records,
58077
+ lastBinding.provider,
58078
+ openCliAccounts({ defaultProviders: [] }).registry
58079
+ );
58080
+ if (!isDefaultAccountId(bound.accountId)) resumeAccountRef.current = bound.accountId;
58081
+ else if (bound.fellBack) {
58082
+ accountFellBackNoticeRef.current = "The account this conversation used was removed. It continues on your usual sign-in.";
58083
+ }
58084
+ }
58085
+ } catch {
58086
+ }
57932
58087
  let named;
57933
58088
  try {
57934
58089
  named = await titleOf(sessions, asSessionId(requestedConversationId));
@@ -58018,6 +58173,36 @@ ${blocks.join("\n\n")}`;
58018
58173
  const definition = await tuiPalDefinition(activeCtx.cwd, scope.sessionId, activeCtx.palId);
58019
58174
  const palEnvironment = definition ? await tuiPalEnvironment(definition, scope.sessionId, signal) : void 0;
58020
58175
  const prefs = definition && palRouteSessionRef.current !== scope.sessionId ? tuiPalPreferences(definition, palDefaultPreferencesRef.current ?? requestedPrefs) ?? requestedPrefs : requestedPrefs;
58176
+ let sessionPrefs = prefs;
58177
+ let nextAccount = null;
58178
+ {
58179
+ const head = prefs.providers[0];
58180
+ const recorded = resumeAccountRef.current;
58181
+ if (head?.account && !isDefaultAccountId(head.account)) {
58182
+ nextAccount = {
58183
+ id: head.account,
58184
+ reason: accountReasonRef.current ?? sessionAccountRef.current?.reason ?? "start"
58185
+ };
58186
+ } else if (head && recorded && !definition) {
58187
+ try {
58188
+ const found = openCliAccounts({ defaultProviders: [] }).registry.get(recorded);
58189
+ if (found) {
58190
+ sessionPrefs = bindAccount(prefs, found);
58191
+ nextAccount = { id: found.id, reason: "start" };
58192
+ }
58193
+ } catch {
58194
+ }
58195
+ } else if (head && sessionAccountRef.current && parseAccountId(sessionAccountRef.current.id)?.provider === head.id) {
58196
+ nextAccount = sessionAccountRef.current;
58197
+ sessionPrefs = {
58198
+ ...prefs,
58199
+ providers: [
58200
+ { ...head, account: nextAccount.id },
58201
+ ...prefs.providers.slice(1).filter((member) => member.id !== head.id)
58202
+ ]
58203
+ };
58204
+ }
58205
+ }
58021
58206
  const primary = prefs.providers[0];
58022
58207
  if (primary && scheduleLiveRef.current) {
58023
58208
  scheduleLiveRef.current.model = {
@@ -58035,9 +58220,10 @@ ${blocks.join("\n\n")}`;
58035
58220
  ...browserConfig.keepOpen ? { keepOpen: true } : {},
58036
58221
  ...sessionsRef.current ? { home: sessionsRef.current.root } : {}
58037
58222
  } : void 0;
58038
- const s = await createAgentSession(prefs, detectedNow, {
58223
+ const s = await createAgentSession(sessionPrefs, detectedNow, {
58039
58224
  scope,
58040
58225
  cwd: activeCtx.cwd,
58226
+ ...nextAccount ? { accountReason: nextAccount.reason } : accountReasonRef.current ? { accountReason: accountReasonRef.current } : {},
58041
58227
  ...activeCtx.reloadPermissionRules ? { reloadPermissionRules: activeCtx.reloadPermissionRules } : {},
58042
58228
  // The composer opens on the saved or automatic model. The effort menu
58043
58229
  // waits for the provider's model listing, not the person.
@@ -58151,6 +58337,9 @@ ${blocks.join("\n\n")}`;
58151
58337
  autoActiveRef.current = autoOn;
58152
58338
  setAutoActive(autoOn);
58153
58339
  savedPrefsRef.current = prefs;
58340
+ sessionAccountRef.current = nextAccount;
58341
+ peersRef.current?.publish();
58342
+ resumeAccountRef.current = null;
58154
58343
  palDefinitionRef.current = definition;
58155
58344
  palRouteSessionRef.current = definition ? scope.sessionId : null;
58156
58345
  if (permissionModeSourceRef.current === "default") {
@@ -58206,6 +58395,10 @@ ${blocks.join("\n\n")}`;
58206
58395
  if (s.hasProvider) {
58207
58396
  setTranscriptOwned(true);
58208
58397
  setPhase("ready");
58398
+ if (accountFellBackNoticeRef.current) {
58399
+ pushMessage("system", accountFellBackNoticeRef.current);
58400
+ accountFellBackNoticeRef.current = null;
58401
+ }
58209
58402
  if (definition && (!previousInstructionFiles || previousPalDefinition?.revision !== definition.revision || announce)) {
58210
58403
  pushMessage(
58211
58404
  "system",
@@ -58439,7 +58632,11 @@ ${blocks.join("\n\n")}`;
58439
58632
  const launch = ctxRef.current.launchSettings;
58440
58633
  if (launch && launchModelPendingRef.current) {
58441
58634
  launchModelPendingRef.current = false;
58442
- const requested = launchPreferences(probe.preferences, launch);
58635
+ const requested = launchPreferences(
58636
+ probe.preferences,
58637
+ launch,
58638
+ launch.account ? openCliAccounts({ defaultProviders: [] }) : void 0
58639
+ );
58443
58640
  const admissionSignal = signal ?? appLifetime.signal;
58444
58641
  const toPicker = /* @__PURE__ */ __name((notice) => {
58445
58642
  setPickerDetected(null);
@@ -58451,7 +58648,7 @@ ${blocks.join("\n\n")}`;
58451
58648
  }, "toPicker");
58452
58649
  if (!requested) {
58453
58650
  toPicker(
58454
- launch.model || !launch.fallbackModels?.length ? "--model needs --provider here: no provider is saved to apply it to." : "--fallback-model needs a provider to fall over from: none is saved, so choose one first."
58651
+ launch.account ? "That account is no longer set up. Choose another with /auth." : launch.model || !launch.fallbackModels?.length ? "--model needs --provider here: no provider is saved to apply it to." : "--fallback-model needs a provider to fall over from: none is saved, so choose one first."
58455
58652
  );
58456
58653
  return;
58457
58654
  }
@@ -59076,7 +59273,7 @@ ${blocks.join("\n\n")}`;
59076
59273
  doctorRunningRef.current = true;
59077
59274
  const progressId = pushMessage("system", "Checking\u2026");
59078
59275
  try {
59079
- const { runLiveDoctor } = await import("./live-XC3V46W3.js");
59276
+ const { runLiveDoctor } = await import("./live-XWJ2JOFO.js");
59080
59277
  const { describePlainDoctor } = await import("./plain-report-IOYN4O6N.js");
59081
59278
  const report = await runLiveDoctor({
59082
59279
  ...ctxRef.current.telemetry ? { telemetry: ctxRef.current.telemetry } : {}
@@ -59284,12 +59481,12 @@ ${blocks.join("\n\n")}`;
59284
59481
  if (!terminationExit) return;
59285
59482
  terminationExit.current = () => {
59286
59483
  interruptTurn();
59287
- exitWithSummary();
59484
+ exitNow();
59288
59485
  };
59289
59486
  return () => {
59290
59487
  terminationExit.current = null;
59291
59488
  };
59292
- }, [terminationExit, interruptTurn, exitWithSummary]);
59489
+ }, [terminationExit, interruptTurn, exitNow]);
59293
59490
  const resumeConversation = (0, import_react60.useCallback)(
59294
59491
  async (conv) => {
59295
59492
  const sessions = sessionsRef.current;
@@ -59722,6 +59919,10 @@ ${blocks.join("\n\n")}`;
59722
59919
  });
59723
59920
  return;
59724
59921
  }
59922
+ if (prompt.kind === "account-step") {
59923
+ accountActionsRef.current?.submitStep(value);
59924
+ return;
59925
+ }
59725
59926
  const scope = scopeRef.current;
59726
59927
  if (!scope || scope.sessionId !== prompt.sessionId) {
59727
59928
  pushMessage(
@@ -59768,6 +59969,7 @@ ${blocks.join("\n\n")}`;
59768
59969
  queueMicrotask(() => {
59769
59970
  if (textPromptRef.current === prompt) setTextPrompt(null);
59770
59971
  if (prompt?.kind === "user-question") resolveQuestion({ kind: "skip" });
59972
+ if (prompt?.kind === "account-step") accountWizardRef.current = null;
59771
59973
  });
59772
59974
  }, [resolveQuestion, setTextPrompt]);
59773
59975
  const doFork = (0, import_react60.useCallback)(async () => {
@@ -60672,7 +60874,8 @@ ${plain(err)}`
60672
60874
  const built = toolEndRows(event, done, {
60673
60875
  ...done ? { elapsedMs: Date.now() - done.startedAt } : {},
60674
60876
  hasPlan: tasksRef.current.length > 0,
60675
- cwd: ctxRef.current.cwd
60877
+ cwd: ctxRef.current.cwd,
60878
+ stoppedByPerson: stoppedAtPromptRef.current.delete(event.toolUseId)
60676
60879
  });
60677
60880
  if (built.kind === "task-block") {
60678
60881
  writeTaskBlock(st, null, tasksRef.current);
@@ -60696,10 +60899,14 @@ ${plain(err)}`
60696
60899
  ...event.contextTokens !== void 0 && event.contextWindowTokens !== void 0 ? {
60697
60900
  context: {
60698
60901
  tokens: event.contextTokens,
60699
- windowTokens: event.contextWindowTokens,
60700
60902
  measured: event.contextMeasuredBy === "provider",
60701
- windowAssumed: event.windowSource !== "provider" && event.windowSource !== "config",
60702
- ...event.windowSource ? { windowSource: event.windowSource } : {}
60903
+ ...effectiveContextWindow(
60904
+ {
60905
+ windowTokens: event.contextWindowTokens,
60906
+ ...event.windowSource ? { windowSource: event.windowSource } : {}
60907
+ },
60908
+ ctxRef.current.compaction?.autoCompactWindowTokens
60909
+ )
60703
60910
  }
60704
60911
  } : {}
60705
60912
  });
@@ -60924,6 +61131,7 @@ ${plain(err)}`
60924
61131
  if (event.message !== "aborted") {
60925
61132
  st.notification = { kind: "turn-settled", outcome: "failed" };
60926
61133
  pushSystem("error", describePlainInterruption(event, plainOptions()));
61134
+ if (isSpentAllowance(event)) accountActionsRef.current?.noteSpentAllowance(event);
60927
61135
  } else st.notification = null;
60928
61136
  break;
60929
61137
  }
@@ -60958,6 +61166,7 @@ ${plain(err)}`
60958
61166
  if (prompt.kind === "notice" && prompt.generation !== conversationGenRef.current) return;
60959
61167
  setContextHidden(false);
60960
61168
  const { text: promptText } = prompt;
61169
+ if (prompt.kind === "human") lastHumanTurnRef.current = prompt;
60961
61170
  let text = promptText;
60962
61171
  const attachments = prompt.kind === "human" ? prompt.attachments : void 0;
60963
61172
  const goalRound = prompt.kind === "goal" ? prompt.goalRound : void 0;
@@ -61769,6 +61978,514 @@ ${[...workflowNoticeSnapshot.values()].join("\n\n")}` : void 0,
61769
61978
  wakeGoalDriver
61770
61979
  ]
61771
61980
  );
61981
+ const accountActionsRef = (0, import_react60.useRef)(null);
61982
+ const openAccounts = (0, import_react60.useCallback)(
61983
+ () => openCliAccounts({
61984
+ defaultProviders: detected.filter((item) => hasApiCredential(item.entry, item.apiKey)).map((item) => item.entry.id)
61985
+ }),
61986
+ [detected]
61987
+ );
61988
+ const accountSwitchBlocked = (0, import_react60.useCallback)(
61989
+ () => !session || !currentProvider || state !== "idle" || phase !== "ready" || abortRef.current !== null || hasUnsettledTurn() || pendingModelSwitchRef.current !== null || permissionResolveRef.current !== null || compactingRef.current || conversationMutationRef.current !== null || exportingRef.current || goalDriveInFlightRef.current,
61990
+ [session, currentProvider, state, phase, hasUnsettledTurn]
61991
+ );
61992
+ const performAccountSwitch = (0, import_react60.useCallback)(
61993
+ async (account, reason, resubmit) => {
61994
+ const owner = session;
61995
+ const base = savedPrefsRef.current;
61996
+ if (!owner || !base) {
61997
+ pushMessage("system", "No model is connected yet, so there is nothing to switch.");
61998
+ return;
61999
+ }
62000
+ const controller = new AbortController();
62001
+ const pending = {
62002
+ turnToken: {},
62003
+ generation: conversationGenRef.current,
62004
+ sessionId: scopeRef.current?.sessionId,
62005
+ ownerSession: owner,
62006
+ controller,
62007
+ signal: AbortSignal.any([appLifetime.signal, controller.signal])
62008
+ };
62009
+ pendingModelSwitchRef.current = pending;
62010
+ setModelSwitchVersion((version) => version + 1);
62011
+ const owns = /* @__PURE__ */ __name(() => pendingModelSwitchRef.current === pending && !pending.signal.aborted && conversationGenRef.current === pending.generation && scopeRef.current?.sessionId === pending.sessionId && previousSessionRef.current === owner, "owns");
62012
+ const label = `${accountProductName(account.provider)} \xB7 ${account.label}`;
62013
+ const previousBound = sessionAccountRef.current;
62014
+ try {
62015
+ await persistenceTailRef.current;
62016
+ if (!owns()) return;
62017
+ accountReasonRef.current = reason;
62018
+ sessionAccountRef.current = null;
62019
+ await hydrateSession(bindAccount(base, account), detected, {
62020
+ signal: pending.signal,
62021
+ persistSelection: false,
62022
+ beforePublish: /* @__PURE__ */ __name(() => {
62023
+ if (!owns() || abortRef.current || hasUnsettledTurn()) {
62024
+ throw new Error("The conversation changed before the account could be switched.");
62025
+ }
62026
+ }, "beforePublish")
62027
+ });
62028
+ if (previousSessionRef.current !== owner) {
62029
+ pushMessage("system", `Now using ${label}.`);
62030
+ if (resubmit) enqueueQueued(resubmit);
62031
+ }
62032
+ } catch (error) {
62033
+ if (previousSessionRef.current === owner) sessionAccountRef.current = previousBound;
62034
+ if (owns()) {
62035
+ pushMessage(
62036
+ "system",
62037
+ `${explainFailure(error, `Could not switch to ${label}.`)} This conversation stays on its current account.`
62038
+ );
62039
+ }
62040
+ } finally {
62041
+ accountReasonRef.current = null;
62042
+ if (pendingModelSwitchRef.current === pending) {
62043
+ pendingModelSwitchRef.current = null;
62044
+ setModelSwitchVersion((version) => version + 1);
62045
+ wakeGoalDriver();
62046
+ }
62047
+ }
62048
+ },
62049
+ [
62050
+ session,
62051
+ detected,
62052
+ hasUnsettledTurn,
62053
+ hydrateSession,
62054
+ pushMessage,
62055
+ enqueueQueued,
62056
+ wakeGoalDriver,
62057
+ appLifetime.signal
62058
+ ]
62059
+ );
62060
+ const requestAccountSwitch = (0, import_react60.useCallback)(
62061
+ (account, reason, resubmit) => {
62062
+ if (accountSwitchBlocked()) {
62063
+ pendingAccountSwitchRef.current = { account, reason, resubmit };
62064
+ if (reason === "user_switch") {
62065
+ pushMessage(
62066
+ "system",
62067
+ `Will use ${accountProductName(account.provider)} \xB7 ${account.label} from the next reply.`
62068
+ );
62069
+ }
62070
+ return;
62071
+ }
62072
+ void performAccountSwitch(account, reason, resubmit);
62073
+ },
62074
+ [accountSwitchBlocked, performAccountSwitch, pushMessage]
62075
+ );
62076
+ (0, import_react60.useEffect)(() => {
62077
+ const pending = pendingAccountSwitchRef.current;
62078
+ if (!pending || accountSwitchBlocked()) return;
62079
+ pendingAccountSwitchRef.current = null;
62080
+ void performAccountSwitch(pending.account, pending.reason, pending.resubmit);
62081
+ }, [state, phase, queued, modelSwitchVersion, accountSwitchBlocked, performAccountSwitch]);
62082
+ const currentAccountId = (0, import_react60.useCallback)(
62083
+ () => sessionAccountRef.current?.id ?? (currentProvider ? `${currentProvider}:default` : void 0),
62084
+ [currentProvider]
62085
+ );
62086
+ const openAccountPicker = (0, import_react60.useCallback)(
62087
+ (limit) => {
62088
+ const accounts = openAccounts();
62089
+ let list;
62090
+ try {
62091
+ list = accounts.registry.list();
62092
+ } catch (error) {
62093
+ pushSystem("error", explainFailure(error, "Could not read your accounts."));
62094
+ return;
62095
+ }
62096
+ const activity = accounts.activity.read();
62097
+ const currentId = currentAccountId();
62098
+ const usual = new Set(
62099
+ detected.filter((item) => hasApiCredential(item.entry, item.apiKey)).map((item) => item.entry.id)
62100
+ );
62101
+ const model = buildAccountPicker({
62102
+ accounts: list,
62103
+ activity,
62104
+ currentId,
62105
+ now: Date.now(),
62106
+ signedIn: storedAccountSignedIn,
62107
+ hasUsualSignIn: /* @__PURE__ */ __name((provider) => usual.has(provider), "hasUsualSignIn"),
62108
+ ...limit ? { limitedLabel: limit.label } : {}
62109
+ });
62110
+ const at = limit ? model.values.findIndex((id) => id !== currentId && id !== ADD_ACCOUNT_VALUE) : model.values.indexOf(currentId ?? "");
62111
+ setSelectedChoice(Math.max(0, at));
62112
+ setChoicePicker({
62113
+ kind: "account",
62114
+ title: model.title,
62115
+ ...model.notice ? { notice: model.notice } : {},
62116
+ values: model.values,
62117
+ options: model.options,
62118
+ ...limit ? { limit: { resubmit: limit.resubmit } } : {}
62119
+ });
62120
+ },
62121
+ [openAccounts, currentAccountId, detected, pushSystem, setChoicePicker, setSelectedChoice]
62122
+ );
62123
+ const takenLabels = (0, import_react60.useCallback)(
62124
+ (provider) => {
62125
+ try {
62126
+ return openAccounts().registry.list(provider).map((account) => account.label);
62127
+ } catch {
62128
+ return [];
62129
+ }
62130
+ },
62131
+ [openAccounts]
62132
+ );
62133
+ const openWizardPrompt = (0, import_react60.useCallback)(
62134
+ (wizard) => {
62135
+ const scope = scopeRef.current;
62136
+ if (!scope) return;
62137
+ accountWizardRef.current = wizard;
62138
+ const prompt = promptFor(wizard, takenLabels(wizardProvider(wizard)));
62139
+ textPromptTokenRef.current += 1;
62140
+ setChoicePicker(null);
62141
+ setTextPrompt({
62142
+ token: textPromptTokenRef.current,
62143
+ kind: "account-step",
62144
+ title: prompt.title,
62145
+ placeholder: prompt.placeholder,
62146
+ emptyNotice: prompt.emptyNotice,
62147
+ initialValue: prompt.initialValue,
62148
+ sessionId: scope.sessionId,
62149
+ ...prompt.mask ? { mask: true } : {},
62150
+ ...prompt.allowEmpty ? { allowEmpty: true } : {}
62151
+ });
62152
+ },
62153
+ [takenLabels, setChoicePicker, setTextPrompt]
62154
+ );
62155
+ const signInCodexAccount = (0, import_react60.useCallback)(
62156
+ async (label) => {
62157
+ const accounts = openAccounts();
62158
+ const controller = new AbortController();
62159
+ accountLoginRef.current = controller;
62160
+ accountWizardRef.current = null;
62161
+ pushMessage(
62162
+ "system",
62163
+ `Signing in ${label} with Codex. Finish in the browser window \xB7 Esc cancels.`
62164
+ );
62165
+ const dir = accounts.codexHomeFor(label);
62166
+ let result;
62167
+ try {
62168
+ result = await runCodexLogin({
62169
+ dir,
62170
+ signal: controller.signal,
62171
+ onOutput: /* @__PURE__ */ __name((line) => {
62172
+ const address = loginAddressIn(line);
62173
+ if (address) pushMessage("system", `If no window opened, go to ${address}`);
62174
+ }, "onOutput")
62175
+ });
62176
+ } finally {
62177
+ if (accountLoginRef.current === controller) accountLoginRef.current = null;
62178
+ }
62179
+ if (result.kind === "cancelled") {
62180
+ pushMessage("system", "Sign-in cancelled. Nothing was added.");
62181
+ return;
62182
+ }
62183
+ if (result.kind === "failed") {
62184
+ pushMessage("system", result.message);
62185
+ return;
62186
+ }
62187
+ try {
62188
+ const sameSignIn = accounts.registry.list("codex").find(
62189
+ (other) => other.source.kind === "codex-home" && readCodexCredentialFile(join8(other.source.dir, "auth.json"))?.accountId === result.accountId
62190
+ );
62191
+ if (sameSignIn) {
62192
+ rmSync3(dir, { recursive: true, force: true });
62193
+ pushMessage("system", `That ChatGPT account is already added as ${sameSignIn.label}.`);
62194
+ return;
62195
+ }
62196
+ accounts.registry.add({
62197
+ provider: "codex",
62198
+ label,
62199
+ kind: "codex-home",
62200
+ display: result.accountId.slice(-4)
62201
+ });
62202
+ pushMessage("system", `Added Codex \xB7 ${label}.`);
62203
+ openAccountPicker();
62204
+ } catch (error) {
62205
+ rmSync3(dir, { recursive: true, force: true });
62206
+ pushMessage("system", accountProblem(error, "Could not add the account."));
62207
+ }
62208
+ },
62209
+ [openAccounts, pushMessage, openAccountPicker]
62210
+ );
62211
+ const submitAccountStep = (0, import_react60.useCallback)(
62212
+ (value) => {
62213
+ const wizard = accountWizardRef.current;
62214
+ if (!wizard) return;
62215
+ const step = advanceWizard(wizard, value, takenLabels(wizardProvider(wizard)));
62216
+ switch (step.kind) {
62217
+ case "retry":
62218
+ pushMessage("system", step.notice);
62219
+ openWizardPrompt(wizard);
62220
+ return;
62221
+ case "next":
62222
+ openWizardPrompt(step.wizard);
62223
+ return;
62224
+ case "sign-in-codex":
62225
+ void signInCodexAccount(step.label);
62226
+ return;
62227
+ case "rename": {
62228
+ accountWizardRef.current = null;
62229
+ try {
62230
+ const accounts = openAccounts();
62231
+ const renamed = accounts.registry.rename(step.id, step.label);
62232
+ accounts.activity.forget(step.id);
62233
+ pushMessage("system", `Renamed to ${renamed.label}.`);
62234
+ } catch (error) {
62235
+ pushMessage("system", accountProblem(error, "Could not rename the account."));
62236
+ }
62237
+ openAccountPicker();
62238
+ return;
62239
+ }
62240
+ case "add-key": {
62241
+ accountWizardRef.current = null;
62242
+ try {
62243
+ openAccounts().registry.add({
62244
+ provider: step.provider,
62245
+ label: step.label,
62246
+ kind: "api-key",
62247
+ apiKey: step.key,
62248
+ ...step.baseUrl !== void 0 ? { baseUrl: step.baseUrl } : {},
62249
+ ...step.defaultModel !== void 0 ? { defaultModel: step.defaultModel } : {}
62250
+ });
62251
+ pushMessage("system", `Added ${accountProductName(step.provider)} \xB7 ${step.label}.`);
62252
+ } catch (error) {
62253
+ pushMessage("system", accountProblem(error, "Could not add the account."));
62254
+ }
62255
+ openAccountPicker();
62256
+ return;
62257
+ }
62258
+ }
62259
+ },
62260
+ [
62261
+ takenLabels,
62262
+ openWizardPrompt,
62263
+ signInCodexAccount,
62264
+ openAccounts,
62265
+ openAccountPicker,
62266
+ pushMessage
62267
+ ]
62268
+ );
62269
+ const chooseAccountItem = (0, import_react60.useCallback)(
62270
+ (picker, value) => {
62271
+ if (picker.kind === "account") {
62272
+ if (value === ADD_ACCOUNT_VALUE) {
62273
+ const add2 = addKindPicker();
62274
+ setSelectedChoice(0);
62275
+ setChoicePicker({ kind: "account-add", ...add2, back: picker });
62276
+ return;
62277
+ }
62278
+ let account;
62279
+ try {
62280
+ account = openAccounts().registry.get(value);
62281
+ } catch {
62282
+ account = void 0;
62283
+ }
62284
+ if (!account) {
62285
+ pushMessage("system", "That account is no longer set up.");
62286
+ setChoicePicker(null);
62287
+ return;
62288
+ }
62289
+ if (!storedAccountSignedIn(account)) {
62290
+ pushMessage(
62291
+ "system",
62292
+ `${account.label} needs to be signed in again. Remove it with Ctrl+X, then add it once more.`
62293
+ );
62294
+ setChoicePicker(null);
62295
+ return;
62296
+ }
62297
+ setChoicePicker(null);
62298
+ if (value === currentAccountId()) {
62299
+ pushMessage("system", `Already using ${account.label}.`);
62300
+ if (picker.limit?.resubmit) enqueueQueued(picker.limit.resubmit);
62301
+ return;
62302
+ }
62303
+ requestAccountSwitch(
62304
+ account,
62305
+ picker.limit ? "limit_switch" : "user_switch",
62306
+ picker.limit?.resubmit ?? null
62307
+ );
62308
+ return;
62309
+ }
62310
+ if (picker.kind === "account-add") {
62311
+ if (value === "codex") openWizardPrompt({ kind: "codex" });
62312
+ else {
62313
+ const providers = apiKeyProviderPicker();
62314
+ setSelectedChoice(0);
62315
+ setChoicePicker({ kind: "account-provider", ...providers, back: picker });
62316
+ }
62317
+ return;
62318
+ }
62319
+ if (picker.kind === "account-provider") {
62320
+ openWizardPrompt(startApiKeyWizard(value));
62321
+ return;
62322
+ }
62323
+ if (picker.kind === "account-remove") {
62324
+ if (value === "remove") {
62325
+ try {
62326
+ const accounts = openAccounts();
62327
+ accounts.registry.remove(picker.accountId);
62328
+ accounts.activity.forget(picker.accountId);
62329
+ pushMessage("system", "Account removed.");
62330
+ } catch (error) {
62331
+ pushMessage("system", accountProblem(error, "Could not remove the account."));
62332
+ }
62333
+ }
62334
+ openAccountPicker();
62335
+ }
62336
+ },
62337
+ [
62338
+ openAccounts,
62339
+ currentAccountId,
62340
+ enqueueQueued,
62341
+ openWizardPrompt,
62342
+ openAccountPicker,
62343
+ requestAccountSwitch,
62344
+ pushMessage,
62345
+ setChoicePicker,
62346
+ setSelectedChoice
62347
+ ]
62348
+ );
62349
+ const manageAccount = (0, import_react60.useCallback)(
62350
+ (action, id) => {
62351
+ if (parseAccountId(id)?.label === "default") {
62352
+ pushMessage("system", "Your usual sign-in is managed with /login and /logout.");
62353
+ return;
62354
+ }
62355
+ let account;
62356
+ try {
62357
+ account = openAccounts().registry.get(id);
62358
+ } catch {
62359
+ account = void 0;
62360
+ }
62361
+ if (!account) return;
62362
+ if (action === "auto") {
62363
+ if (account.source.kind !== "api-key") {
62364
+ pushMessage("system", "Only API-key accounts can switch automatically.");
62365
+ return;
62366
+ }
62367
+ const accounts = openAccounts();
62368
+ const on = accounts.activity.read().autoSwitch[id] !== true;
62369
+ accounts.activity.setAutoSwitch(id, on);
62370
+ pushMessage(
62371
+ "system",
62372
+ on ? `${account.label} will switch to another API-key account by itself when its allowance runs out.` : `${account.label} will stop and ask when its allowance runs out.`
62373
+ );
62374
+ openAccountPicker();
62375
+ return;
62376
+ }
62377
+ if (id === sessionAccountRef.current?.id) {
62378
+ pushMessage(
62379
+ "system",
62380
+ `This conversation is using ${account.label}. Switch to another account first.`
62381
+ );
62382
+ return;
62383
+ }
62384
+ if (action === "rename") {
62385
+ openWizardPrompt({ kind: "rename", id });
62386
+ return;
62387
+ }
62388
+ const picker = choicePickerRef.current ?? void 0;
62389
+ setSelectedChoice(0);
62390
+ setChoicePicker({
62391
+ kind: "account-remove",
62392
+ title: `Remove ${account.label}?`,
62393
+ notice: account.source.kind === "api-key" ? "The saved key is deleted from this computer." : "Its Codex sign-in is deleted from this computer.",
62394
+ accountId: id,
62395
+ values: ["cancel", "remove"],
62396
+ options: [
62397
+ { label: "Keep it", description: "" },
62398
+ { label: "Remove", description: "Conversations using it will need another account." }
62399
+ ],
62400
+ ...picker ? { back: picker } : {}
62401
+ });
62402
+ },
62403
+ [
62404
+ openAccounts,
62405
+ openAccountPicker,
62406
+ openWizardPrompt,
62407
+ pushMessage,
62408
+ setChoicePicker,
62409
+ setSelectedChoice
62410
+ ]
62411
+ );
62412
+ const noteSpentAllowance = (0, import_react60.useCallback)(
62413
+ (event) => {
62414
+ const currentId = currentAccountId();
62415
+ if (!currentId) return;
62416
+ const accounts = openAccounts();
62417
+ const now = Date.now();
62418
+ const returnsIn = retryAfterMs(event);
62419
+ if (returnsIn === void 0) accounts.activity.markMayBeLimited(currentId, now);
62420
+ else accounts.activity.markLimited(currentId, now + returnsIn);
62421
+ peersRef.current?.publish();
62422
+ let list = [];
62423
+ try {
62424
+ list = accounts.registry.list();
62425
+ } catch {
62426
+ return;
62427
+ }
62428
+ const activity = accounts.activity.read();
62429
+ const usual = new Set(
62430
+ detected.filter((item) => hasApiCredential(item.entry, item.apiKey)).map((item) => item.entry.id)
62431
+ );
62432
+ const others = list.filter(
62433
+ (account) => account.id !== currentId && !(account.label === "default" && !usual.has(account.provider)) && storedAccountSignedIn(account) && (activity.limitedUntil[account.id] ?? 0) <= now && accountState(account, activity, now).kind !== "may-be-limited"
62434
+ );
62435
+ if (others.length === 0) return;
62436
+ const current = list.find((account) => account.id === currentId);
62437
+ const label = current ? `${accountProductName(current.provider)} \xB7 ${current.label}` : "This account";
62438
+ if (current?.source.kind === "api-key" && activity.autoSwitch[current.id] === true) {
62439
+ const target = others.find(
62440
+ (account) => account.provider === current.provider && account.source.kind === "api-key"
62441
+ );
62442
+ if (target) {
62443
+ pushMessage("system", `${label} used up its allowance. Continuing on ${target.label}.`);
62444
+ requestAccountSwitch(target, "limit_switch", lastHumanTurnRef.current);
62445
+ return;
62446
+ }
62447
+ }
62448
+ setHandoffPark({
62449
+ turnId: "allowance",
62450
+ spentAllowance: { resubmit: lastHumanTurnRef.current, label }
62451
+ });
62452
+ },
62453
+ [currentAccountId, openAccounts, detected, pushMessage, requestAccountSwitch, setHandoffPark]
62454
+ );
62455
+ accountActionsRef.current = {
62456
+ open: openAccountPicker,
62457
+ choose: chooseAccountItem,
62458
+ manage: manageAccount,
62459
+ submitStep: submitAccountStep,
62460
+ noteSpentAllowance,
62461
+ startAdd: /* @__PURE__ */ __name(() => {
62462
+ const add2 = addKindPicker();
62463
+ setSelectedChoice(0);
62464
+ setChoicePicker({ kind: "account-add", ...add2 });
62465
+ }, "startAdd"),
62466
+ switchByName: /* @__PURE__ */ __name((name) => {
62467
+ let found;
62468
+ try {
62469
+ found = findAccountByName(openAccounts().registry, name);
62470
+ } catch (error) {
62471
+ pushSystem("error", explainFailure(error, "Could not read your accounts."));
62472
+ return;
62473
+ }
62474
+ if ("error" in found) {
62475
+ pushMessage("system", found.error);
62476
+ return;
62477
+ }
62478
+ if (found.account.id === currentAccountId()) {
62479
+ pushMessage("system", `Already using ${found.account.label}.`);
62480
+ return;
62481
+ }
62482
+ if (!storedAccountSignedIn(found.account)) {
62483
+ pushMessage("system", `${found.account.label} needs to be signed in again.`);
62484
+ return;
62485
+ }
62486
+ requestAccountSwitch(found.account, "user_switch", null);
62487
+ }, "switchByName")
62488
+ };
61772
62489
  const rememberProjectNote = (0, import_react60.useCallback)(
61773
62490
  async (note, type) => {
61774
62491
  try {
@@ -62527,6 +63244,16 @@ ${answer}`
62527
63244
  setChoicePicker(effortChooser ?? null);
62528
63245
  return;
62529
63246
  }
63247
+ case "auth": {
63248
+ if (palDefinitionRef.current) {
63249
+ pushMessage("system", "A Pal keeps its own sign-in, so /auth does not apply here.");
63250
+ return;
63251
+ }
63252
+ if (slash.add) accountActionsRef.current?.startAdd();
63253
+ else if (slash.name) accountActionsRef.current?.switchByName(slash.name);
63254
+ else accountActionsRef.current?.open();
63255
+ return;
63256
+ }
62530
63257
  case "login":
62531
63258
  void startOrFinishLogin(slash.pasted);
62532
63259
  return;
@@ -63813,6 +64540,20 @@ ${plugins.map((plugin) => {
63813
64540
  peersStartingRef.current = true;
63814
64541
  let disposed = false;
63815
64542
  let opened = null;
64543
+ const hostFacts = /* @__PURE__ */ __name(() => {
64544
+ let activity;
64545
+ try {
64546
+ activity = openCliAccounts({ defaultProviders: [] }).activity.read();
64547
+ } catch {
64548
+ activity = void 0;
64549
+ }
64550
+ return hostAccountFacts({
64551
+ accountId: sessionAccountRef.current?.id,
64552
+ stopped: handoffParkRef.current?.spentAllowance !== void 0,
64553
+ activity,
64554
+ now: Date.now()
64555
+ });
64556
+ }, "hostFacts");
63816
64557
  const onClose = /* @__PURE__ */ __name(() => {
63817
64558
  disposed = true;
63818
64559
  if (peersRef.current === opened) peersRef.current = null;
@@ -63831,7 +64572,16 @@ ${plugins.map((plugin) => {
63831
64572
  activeTurnInboxRef.current?.notify();
63832
64573
  wakePeers((version) => version + 1);
63833
64574
  }, "available"),
63834
- report: /* @__PURE__ */ __name((text) => pushMessage("system", text), "report")
64575
+ report: /* @__PURE__ */ __name((text) => pushMessage("system", text), "report"),
64576
+ ...process.env.NAMZU_SPACE_SLOT ? { hostSlot: process.env.NAMZU_SPACE_SLOT } : {},
64577
+ // Only a session inside a spaces host writes the new record fields, so a plain
64578
+ // session stays readable by builds that predate them.
64579
+ ...process.env.NAMZU_SPACE_SLOT ? {
64580
+ conversation: /* @__PURE__ */ __name(() => conversationMaterializedRef.current ? scopeRef.current?.sessionId : void 0, "conversation"),
64581
+ account: /* @__PURE__ */ __name(() => hostFacts().account, "account"),
64582
+ limited: /* @__PURE__ */ __name(() => hostFacts().limited, "limited"),
64583
+ limitedUntil: /* @__PURE__ */ __name(() => hostFacts().limitedUntil, "limitedUntil")
64584
+ } : {}
63835
64585
  }).then((peers) => {
63836
64586
  peersStartingRef.current = false;
63837
64587
  opened = peers;
@@ -64193,6 +64943,7 @@ ${plugins.map((plugin) => {
64193
64943
  }
64194
64944
  if (isAction("app:interrupt", input, key)) {
64195
64945
  if (permission && endsTurnOnNo(permission)) {
64946
+ for (const call of permission.toolCalls) stoppedAtPromptRef.current.add(call.id);
64196
64947
  resolvePermission(plainNo(true));
64197
64948
  return;
64198
64949
  }
@@ -64661,6 +65412,17 @@ ${plugins.map((plugin) => {
64661
65412
  }
64662
65413
  return;
64663
65414
  }
65415
+ if (picker.kind === "account" && key.ctrl && (input === "r" || input === "x" || input === "a")) {
65416
+ const chosen = options[selectedChoiceRef.current];
65417
+ const id = chosen ? picker.values[picker.options.indexOf(chosen)] : void 0;
65418
+ if (id && id !== ADD_ACCOUNT_VALUE) {
65419
+ accountActionsRef.current?.manage(
65420
+ input === "r" ? "rename" : input === "x" ? "remove" : "auto",
65421
+ id
65422
+ );
65423
+ }
65424
+ return;
65425
+ }
64664
65426
  if (key.home || key.end || key.pageUp || key.pageDown) {
64665
65427
  const pageSize2 = choicePickerWindowSize({
64666
65428
  rows: terminal.rows,
@@ -64772,9 +65534,17 @@ ${plugins.map((plugin) => {
64772
65534
  resetTranscript();
64773
65535
  return;
64774
65536
  }
65537
+ if (key.escape && accountLoginRef.current) {
65538
+ accountLoginRef.current.abort();
65539
+ return;
65540
+ }
64775
65541
  if (handoffParkRef.current && phase === "ready" && state === "idle" && !abortRef.current && (key.return && !composerHasDraft || key.escape)) {
64776
65542
  const parked = handoffParkRef.current;
64777
65543
  setHandoffPark(null);
65544
+ if (parked.spentAllowance) {
65545
+ if (key.return) accountActionsRef.current?.open(parked.spentAllowance);
65546
+ return;
65547
+ }
64778
65548
  if (key.return) {
64779
65549
  autoResumeAttemptRef.current = 0;
64780
65550
  selfMendingPauseRowRef.current.forget();
@@ -64860,7 +65630,7 @@ ${plugins.map((plugin) => {
64860
65630
  const dialogShowing = permission !== null || scheduleReviewPrompt !== null || saveSkillPrompt !== null || planPrompt !== null || questionDialog !== null || textPrompt !== null || choicePicker !== null || copyPicker !== null || phase === "resume" || phase === "unarchive" || phase === "edit" || phase === "picker";
64861
65631
  const currentNotice = notices.current;
64862
65632
  const noticeIsImmediate = currentNotice?.priority === "immediate";
64863
- const statusHint = exitHint ? `Press ${exitHint} again to exit` : noticeIsImmediate ? void 0 : conversationMutation === "fork" ? "forking conversation \u2014 input is paused" : conversationMutation === "edit" ? "branching before prompt \u2014 input is paused" : conversationMutation === "archive" ? "archiving conversation \u2014 input is paused" : conversationMutation === "new" ? "starting a fresh conversation \u2014 input is paused" : compacting ? "compacting conversation \u2014 input is paused" : boxOwnsKeys ? void 0 : handoffPark && phase === "ready" && state === "idle" && !composerHasDraft ? handoffPark.autoResume ? `trying again in ${formatSpan(Math.max(0, handoffPark.autoResume.at - Date.now()))} \xB7 enter try now \xB7 esc stop` : "enter continue \xB7 esc stop" : goalStatus && phase === "ready" && state === "idle" ? void 0 : hintForPhase(phase, state, composerHasDraft);
65633
+ const statusHint = exitHint ? `Press ${exitHint} again to exit` : noticeIsImmediate ? void 0 : conversationMutation === "fork" ? "forking conversation \u2014 input is paused" : conversationMutation === "edit" ? "branching before prompt \u2014 input is paused" : conversationMutation === "archive" ? "archiving conversation \u2014 input is paused" : conversationMutation === "new" ? "starting a fresh conversation \u2014 input is paused" : compacting ? "compacting conversation \u2014 input is paused" : boxOwnsKeys ? void 0 : handoffPark && phase === "ready" && state === "idle" && !composerHasDraft ? handoffPark.spentAllowance ? CONTINUE_WITH_ANOTHER_ACCOUNT : handoffPark.autoResume ? `trying again in ${formatSpan(Math.max(0, handoffPark.autoResume.at - Date.now()))} \xB7 enter try now \xB7 esc stop` : "enter continue \xB7 esc stop" : goalStatus && phase === "ready" && state === "idle" ? void 0 : hintForPhase(phase, state, composerHasDraft);
64864
65634
  const permissionSource = reviewSource(permission, scopeRef.current?.sessionId);
64865
65635
  const permissionOwner = permissionSource ? subagents.find((agent) => agent.sessionId === permissionSource) : void 0;
64866
65636
  const permissionSourceLabel = permissionSource ? permissionOwner ? `from the ${permissionOwner.description} agent` : "from another agent" : void 0;
@@ -65111,6 +65881,8 @@ ${plugins.map((plugin) => {
65111
65881
  placeholder: textPrompt.placeholder,
65112
65882
  initialValue: textPrompt.initialValue,
65113
65883
  emptyNotice: textPrompt.emptyNotice,
65884
+ mask: textPrompt.mask === true,
65885
+ allowEmpty: textPrompt.allowEmpty === true,
65114
65886
  hidden: permission !== null || scheduleReviewPrompt !== null || childSurfaceOpen,
65115
65887
  onSubmit: submitTextPrompt,
65116
65888
  onCancel: cancelTextPrompt
@@ -65137,6 +65909,7 @@ ${plugins.map((plugin) => {
65137
65909
  subtitle: choicePicker.subtitle,
65138
65910
  hints: workflowRunsHints(workflowPickerCanStop)
65139
65911
  } : {},
65912
+ ...choicePicker.kind === "account" ? { hints: ACCOUNT_PICKER_HINTS } : {},
65140
65913
  options: filterChoiceOptions(choicePicker.options, choiceQuery),
65141
65914
  query: choicePickerSearchable(choicePicker) ? choiceQuery : void 0,
65142
65915
  selected: selectedChoice,
@@ -65202,6 +65975,9 @@ ${plugins.map((plugin) => {
65202
65975
  onDraftPresenceChange: setComposerHasDraft,
65203
65976
  onOpenAgentPanel: focusAgentRail,
65204
65977
  onOpenAgents: () => void openAgentCockpit(),
65978
+ onOpenSpaces: onOpenSpaces ? () => void onOpenSpaces().then((opened) => {
65979
+ if (!opened) void openAgentCockpit();
65980
+ }) : void 0,
65205
65981
  onScrollTranscript: () => setScrollOpen(true),
65206
65982
  onRecallQueued: recallQueuedPrompt,
65207
65983
  queuedHintCount,
@@ -65236,7 +66012,11 @@ ${plugins.map((plugin) => {
65236
66012
  StatusBar,
65237
66013
  {
65238
66014
  provider: session?.providerSummary ?? null,
65239
- model: autoActive && ctx.routing && !palDefinitionRef.current ? autoModelLabel(session?.autoRoute) : session?.modelSummary ?? null,
66015
+ model: withAccountLabel(
66016
+ autoActive && ctx.routing && !palDefinitionRef.current ? autoModelLabel(session?.autoRoute) : session?.modelSummary ?? null,
66017
+ session?.providerSummary ?? null,
66018
+ session?.account?.label
66019
+ ),
65240
66020
  effort: reasoningEffort,
65241
66021
  hypermode,
65242
66022
  goal: statusGoal,
@@ -65258,8 +66038,8 @@ ${plugins.map((plugin) => {
65258
66038
  monitorCount: showComposerSurface && !childSurfaceOpen ? runningMonitorCount : 0,
65259
66039
  pr: prStatus,
65260
66040
  hyperlinks,
65261
- agentCount: footerKeysLive ? runningAgentCount : 0,
65262
- workflowCount: footerKeysLive ? runningWorkflowCount : 0,
66041
+ agentCount: footerKeysLive && !onOpenSpaces ? runningAgentCount : 0,
66042
+ workflowCount: footerKeysLive && !onOpenSpaces ? runningWorkflowCount : 0,
65263
66043
  canManage: footerKeysLive && railFocus === null && (runningShellCount > 0 || railHasRows),
65264
66044
  shellsSelected: railFocus === SHELLS_FOCUS,
65265
66045
  ...railHintText !== void 0 ? { railHint: railHintText } : {}
@@ -65441,8 +66221,15 @@ function relativeStart(startedAt) {
65441
66221
  return `${Math.round(hours / 24)}d ago`;
65442
66222
  }
65443
66223
  __name(relativeStart, "relativeStart");
66224
+ function withAccountLabel(model, provider, account) {
66225
+ const base = model ?? provider;
66226
+ return account === void 0 || base === null ? model : `${base} \xB7 ${account}`;
66227
+ }
66228
+ __name(withAccountLabel, "withAccountLabel");
65444
66229
  function choicePickerSearchable(picker) {
65445
- return ["command", "skill", "plugin", "review-branch", "review-commit"].includes(picker.kind);
66230
+ return ["command", "skill", "plugin", "review-branch", "review-commit", "account"].includes(
66231
+ picker.kind
66232
+ );
65446
66233
  }
65447
66234
  __name(choicePickerSearchable, "choicePickerSearchable");
65448
66235
  function loadedPluginPicker(owner) {
@@ -65737,12 +66524,12 @@ __name(installFocusReporting, "installFocusReporting");
65737
66524
 
65738
66525
  // src/tui/hint-counts.ts
65739
66526
  import { randomUUID } from "node:crypto";
65740
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync8, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
65741
- import { dirname as dirname2, join as join8 } from "node:path";
66527
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync8, renameSync as renameSync2, rmSync as rmSync4, writeFileSync as writeFileSync2 } from "node:fs";
66528
+ import { dirname as dirname2, join as join9 } from "node:path";
65742
66529
  var FILE_MODE = 384;
65743
66530
  var DIR_MODE = 448;
65744
66531
  function hintCountsPath(home) {
65745
- return join8(namzuHomePath(home), "hint-counts.json");
66532
+ return join9(namzuHomePath(home), "hint-counts.json");
65746
66533
  }
65747
66534
  __name(hintCountsPath, "hintCountsPath");
65748
66535
  function readAll(path) {
@@ -65767,14 +66554,14 @@ function writeHintCount(name, count2, home) {
65767
66554
  const path = hintCountsPath(home);
65768
66555
  const temp = `${path}.${randomUUID()}.tmp`;
65769
66556
  try {
65770
- mkdirSync2(dirname2(path), { recursive: true, mode: DIR_MODE });
66557
+ mkdirSync3(dirname2(path), { recursive: true, mode: DIR_MODE });
65771
66558
  writeFileSync2(temp, `${JSON.stringify({ ...readAll(path), [name]: count2 }, null, 2)}
65772
66559
  `, {
65773
66560
  mode: FILE_MODE
65774
66561
  });
65775
66562
  renameSync2(temp, path);
65776
66563
  } catch {
65777
- rmSync2(temp, { force: true });
66564
+ rmSync4(temp, { force: true });
65778
66565
  }
65779
66566
  }
65780
66567
  __name(writeHintCount, "writeHintCount");
@@ -65906,13 +66693,13 @@ __name(askTerminal, "askTerminal");
65906
66693
 
65907
66694
  // src/tui/tip-history.ts
65908
66695
  import { randomUUID as randomUUID2 } from "node:crypto";
65909
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync9, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
65910
- import { dirname as dirname3, join as join9 } from "node:path";
66696
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync3, rmSync as rmSync5, writeFileSync as writeFileSync3 } from "node:fs";
66697
+ import { dirname as dirname3, join as join10 } from "node:path";
65911
66698
  var FILE_MODE2 = 384;
65912
66699
  var DIR_MODE2 = 448;
65913
66700
  var EMPTY_TIP_HISTORY = { launches: 0, shown: {}, used: {} };
65914
66701
  function tipHistoryPath(home) {
65915
- return join9(namzuHomePath(home), "tip-history.json");
66702
+ return join10(namzuHomePath(home), "tip-history.json");
65916
66703
  }
65917
66704
  __name(tipHistoryPath, "tipHistoryPath");
65918
66705
  function wholeNumber(value) {
@@ -65946,13 +66733,13 @@ __name(readTipHistory, "readTipHistory");
65946
66733
  function writeTipHistory(path, history) {
65947
66734
  const temp = `${path}.${randomUUID2()}.tmp`;
65948
66735
  try {
65949
- mkdirSync3(dirname3(path), { recursive: true, mode: DIR_MODE2 });
66736
+ mkdirSync4(dirname3(path), { recursive: true, mode: DIR_MODE2 });
65950
66737
  writeFileSync3(temp, `${JSON.stringify(history, null, 2)}
65951
66738
  `, { mode: FILE_MODE2 });
65952
66739
  renameSync3(temp, path);
65953
66740
  } catch {
65954
66741
  try {
65955
- rmSync3(temp, { force: true });
66742
+ rmSync5(temp, { force: true });
65956
66743
  } catch {
65957
66744
  }
65958
66745
  }
@@ -65979,7 +66766,172 @@ function fileTipHistory(home) {
65979
66766
  }
65980
66767
  __name(fileTipHistory, "fileTipHistory");
65981
66768
 
66769
+ // src/tui/zoom/leave.ts
66770
+ async function leaveSpacesBounded(options) {
66771
+ let wanted = true;
66772
+ let timer;
66773
+ const hand = /* @__PURE__ */ __name(async () => {
66774
+ if (await options.release(() => wanted)) {
66775
+ if (wanted) await options.flush();
66776
+ }
66777
+ }, "hand");
66778
+ try {
66779
+ await Promise.race([
66780
+ hand().catch(() => void 0),
66781
+ new Promise((resolve9) => {
66782
+ timer = setTimeout(resolve9, options.limitMs);
66783
+ })
66784
+ ]);
66785
+ } finally {
66786
+ wanted = false;
66787
+ clearTimeout(timer);
66788
+ }
66789
+ }
66790
+ __name(leaveSpacesBounded, "leaveSpacesBounded");
66791
+
66792
+ // src/tui/zoom/proxy.ts
66793
+ import { EventEmitter as EventEmitter3 } from "node:events";
66794
+ var HIDE = "\x1B[?25l";
66795
+ var SHOW = "\x1B[?25h";
66796
+ var PASTE_ON = "\x1B[?2004h";
66797
+ var PASTE_OFF = "\x1B[?2004l";
66798
+ var RESIZE = "resize";
66799
+ function createTerminalProxy(realOut, realIn) {
66800
+ let zoomed = null;
66801
+ let keyHandler = null;
66802
+ const realResizes = /* @__PURE__ */ new Set();
66803
+ const injected = [];
66804
+ let announced = false;
66805
+ let cursorHidden = false;
66806
+ let bracketedPaste = false;
66807
+ const resizes = new EventEmitter3();
66808
+ let subscribed = false;
66809
+ const noteModes = /* @__PURE__ */ __name((chunk) => {
66810
+ if (typeof chunk !== "string") return;
66811
+ if (chunk.includes("\x1B[?25")) {
66812
+ const hide = chunk.lastIndexOf(HIDE);
66813
+ const show2 = chunk.lastIndexOf(SHOW);
66814
+ if (hide !== show2) cursorHidden = hide > show2;
66815
+ }
66816
+ if (chunk.includes("\x1B[?2004")) {
66817
+ const on = chunk.lastIndexOf(PASTE_ON);
66818
+ const off = chunk.lastIndexOf(PASTE_OFF);
66819
+ if (on !== off) bracketedPaste = on > off;
66820
+ }
66821
+ }, "noteModes");
66822
+ const subscribe = /* @__PURE__ */ __name(() => {
66823
+ if (subscribed) return;
66824
+ subscribed = true;
66825
+ realOut.on(RESIZE, () => {
66826
+ if (zoomed) for (const listener of [...realResizes]) listener();
66827
+ else resizes.emit(RESIZE);
66828
+ });
66829
+ }, "subscribe");
66830
+ const out = new Proxy(realOut, {
66831
+ get(target, prop) {
66832
+ if (prop === "write") {
66833
+ return (chunk, ...rest) => {
66834
+ noteModes(chunk);
66835
+ if (zoomed === null)
66836
+ return Reflect.apply(target.write, target, [chunk, ...rest]);
66837
+ zoomed.write(typeof chunk === "string" ? chunk : String(chunk));
66838
+ const done = rest.find((r) => typeof r === "function");
66839
+ done?.();
66840
+ return true;
66841
+ };
66842
+ }
66843
+ if (prop === "columns") return zoomed ? zoomed.columns : target.columns;
66844
+ if (prop === "rows") return zoomed ? zoomed.rows : target.rows;
66845
+ if (prop === "getWindowSize") {
66846
+ return () => zoomed ? [zoomed.columns, zoomed.rows] : target.getWindowSize();
66847
+ }
66848
+ if (prop === "on" || prop === "addListener" || prop === "once" || prop === "off" || prop === "removeListener") {
66849
+ return (event, listener) => {
66850
+ if (event !== RESIZE) {
66851
+ Reflect.apply(target[prop], target, [event, listener]);
66852
+ return out;
66853
+ }
66854
+ subscribe();
66855
+ resizes[prop](event, listener);
66856
+ return out;
66857
+ };
66858
+ }
66859
+ const value = Reflect.get(target, prop, target);
66860
+ return typeof value === "function" ? value.bind(target) : value;
66861
+ }
66862
+ });
66863
+ const inn = new Proxy(realIn, {
66864
+ get(target, prop) {
66865
+ if (prop === "read") {
66866
+ return (...args) => {
66867
+ for (; ; ) {
66868
+ const next = injected.shift();
66869
+ if (next !== void 0) return next;
66870
+ const chunk = Reflect.apply(target.read, target, args);
66871
+ if (typeof chunk !== "string") return chunk;
66872
+ if (zoomed !== null && keyHandler !== null) {
66873
+ const kept = keyHandler(chunk);
66874
+ if (kept !== null) return kept;
66875
+ continue;
66876
+ }
66877
+ return chunk;
66878
+ }
66879
+ };
66880
+ }
66881
+ const value = Reflect.get(target, prop, target);
66882
+ return typeof value === "function" ? value.bind(target) : value;
66883
+ }
66884
+ });
66885
+ return {
66886
+ stdout: out,
66887
+ stdin: inn,
66888
+ get mode() {
66889
+ return zoomed ? "zoomed" : "direct";
66890
+ },
66891
+ get cursorHidden() {
66892
+ return cursorHidden;
66893
+ },
66894
+ get bracketedPaste() {
66895
+ return bracketedPaste;
66896
+ },
66897
+ enterZoomed(output, onKey) {
66898
+ zoomed = output;
66899
+ keyHandler = onKey;
66900
+ resizes.emit(RESIZE);
66901
+ },
66902
+ leaveZoomed() {
66903
+ zoomed = null;
66904
+ keyHandler = null;
66905
+ resizes.emit(RESIZE);
66906
+ },
66907
+ resizeZoomed(columns, rows) {
66908
+ if (!zoomed) return;
66909
+ zoomed.columns = columns;
66910
+ zoomed.rows = rows;
66911
+ resizes.emit(RESIZE);
66912
+ },
66913
+ onRealResize(listener) {
66914
+ realResizes.add(listener);
66915
+ subscribe();
66916
+ return () => {
66917
+ realResizes.delete(listener);
66918
+ };
66919
+ },
66920
+ inject(chunk) {
66921
+ injected.push(chunk);
66922
+ if (announced) return;
66923
+ announced = true;
66924
+ queueMicrotask(() => {
66925
+ announced = false;
66926
+ if (injected.length > 0) realIn.emit("readable");
66927
+ });
66928
+ }
66929
+ };
66930
+ }
66931
+ __name(createTerminalProxy, "createTerminalProxy");
66932
+
65982
66933
  // src/tui/index.tsx
66934
+ var LEAVE_SPACES_MS = 2e3;
65983
66935
  async function launchTui(ctx, options = {}) {
65984
66936
  const invocation = {
65985
66937
  cwd: resolve8(ctx.cwd),
@@ -66007,7 +66959,55 @@ async function launchTui(ctx, options = {}) {
66007
66959
  process.stdout,
66008
66960
  (focused) => terminalFocus.set(focused)
66009
66961
  );
66962
+ const hosted = hostedByHost(process.env, process.ppid);
66963
+ const proxy = !hosted && consoleInput === void 0 && process.platform !== "win32" && process.stdout.isTTY === true && inputStream.isTTY === true ? createTerminalProxy(process.stdout, inputStream) : null;
66010
66964
  const terminationExit = { current: null };
66965
+ const repaint = { current: null };
66966
+ const spaces = {
66967
+ current: null
66968
+ };
66969
+ const spacesEntry = /* @__PURE__ */ __name(() => {
66970
+ spaces.current ??= import("./entry-UHKDLPDS.js").then(
66971
+ (m) => m.createSpacesEntry({
66972
+ proxy,
66973
+ realOut: process.stdout,
66974
+ env: process.env,
66975
+ cwd: process.cwd(),
66976
+ entry: process.argv[1],
66977
+ prefixSetting: ctx.tui?.spacesPrefix,
66978
+ requestExit: /* @__PURE__ */ __name(() => terminationExit.current ? terminationExit.current() : instance.unmount(), "requestExit"),
66979
+ repaint: /* @__PURE__ */ __name(() => repaint.current?.(), "repaint")
66980
+ })
66981
+ );
66982
+ return spaces.current;
66983
+ }, "spacesEntry");
66984
+ const onOpenSpaces = hosted ? () => {
66985
+ process.stdout.write(spacesSignal("zoom-out"));
66986
+ return Promise.resolve(true);
66987
+ } : proxy !== null ? async () => {
66988
+ try {
66989
+ return await (await spacesEntry()).open();
66990
+ } catch {
66991
+ return false;
66992
+ }
66993
+ } : void 0;
66994
+ const onConfirmExit = !hosted && proxy !== null ? async () => {
66995
+ try {
66996
+ return spaces.current === null ? true : await (await spaces.current).confirmExit();
66997
+ } catch {
66998
+ return true;
66999
+ }
67000
+ } : void 0;
67001
+ const beforeExit = !hosted && proxy !== null ? async () => {
67002
+ if (spaces.current === null) return;
67003
+ await leaveSpacesBounded({
67004
+ release: /* @__PURE__ */ __name((stillWanted) => spaces.current.then(
67005
+ (entry) => entry.release(stillWanted)
67006
+ ), "release"),
67007
+ flush: /* @__PURE__ */ __name(() => instance.waitUntilRenderFlush(), "flush"),
67008
+ limitMs: LEAVE_SPACES_MS
67009
+ });
67010
+ } : void 0;
66011
67011
  let terminatedBy = null;
66012
67012
  const instance = render_default(
66013
67013
  import_react61.default.createElement(App2, {
@@ -66016,14 +67016,18 @@ async function launchTui(ctx, options = {}) {
66016
67016
  exitSummary = summary2;
66017
67017
  }, "onExitSummary"),
66018
67018
  terminationExit,
67019
+ repaint,
67020
+ ...onOpenSpaces ? { onOpenSpaces } : {},
67021
+ ...onConfirmExit ? { onConfirmExit } : {},
67022
+ ...beforeExit ? { beforeExit } : {},
66019
67023
  examplePrompts: true,
66020
67024
  queuedHintCount: fileQueuedHintCount(),
66021
67025
  tipHistory
66022
67026
  }),
66023
67027
  {
66024
- stdout: process.stdout,
67028
+ stdout: proxy?.stdout ?? process.stdout,
66025
67029
  stderr: process.stderr,
66026
- stdin: inputStream,
67030
+ stdin: proxy?.stdin ?? inputStream,
66027
67031
  exitOnCtrlC: false,
66028
67032
  // A CI marker in the environment must not blank a real terminal (see render-mode.ts).
66029
67033
  ...liveRenderOption(process.stdout, process.stdin, consoleInput !== void 0),
@@ -66042,10 +67046,12 @@ async function launchTui(ctx, options = {}) {
66042
67046
  if (terminationExit.current) terminationExit.current();
66043
67047
  else instance.unmount();
66044
67048
  await instance.waitUntilExit();
67049
+ if (spaces.current !== null) await (await spaces.current).shutdown();
66045
67050
  });
66046
67051
  try {
66047
67052
  await instance.waitUntilExit();
66048
67053
  } finally {
67054
+ if (spaces.current !== null) await (await spaces.current).shutdown();
66049
67055
  termination.dispose();
66050
67056
  stopSizeWatch?.();
66051
67057
  stopFocusReporting();
@@ -66149,4 +67155,4 @@ react/cjs/react-jsx-runtime.development.js:
66149
67155
  * LICENSE file in the root directory of this source tree.
66150
67156
  *)
66151
67157
  */
66152
- //# sourceMappingURL=tui-UYHIDUPB.js.map
67158
+ //# sourceMappingURL=tui-PH5B6UCO.js.map