@namzu/cli 40.0.0 → 41.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-E7XNZWFV.js → acp-CLFVQCFH.js} +35 -35
  4. package/dist/chunks/{activity-command-QANVT2PA.js → activity-command-XULXEUGH.js} +11 -11
  5. package/dist/chunks/{add-VDRMBSNZ.js → add-BALM5DGZ.js} +15 -15
  6. package/dist/chunks/{agent-PPQJZWBO.js → agent-CLYE4KWV.js} +28 -26
  7. package/dist/chunks/agent-session-2MVAYKJC.js +54 -0
  8. package/dist/chunks/{archive-SH4IG6KC.js → archive-FWXFWMZJ.js} +9 -9
  9. package/dist/chunks/{bin-main-D45Q7FMM.js → bin-main-HO4CMSMY.js} +3 -3
  10. package/dist/chunks/{browser-EUFWHKYD.js → browser-Z46YPGWH.js} +6 -6
  11. package/dist/chunks/{chat-QDWGHEEL.js → chat-NOXE5RTE.js} +14 -14
  12. package/dist/chunks/{chunk-7M6IZGAK.js → chunk-37S7MY2T.js} +12 -6
  13. package/dist/chunks/chunk-37S7MY2T.js.map +6 -0
  14. package/dist/chunks/{chunk-AHPIP5IE.js → chunk-3WAQN6DX.js} +2 -2
  15. package/dist/chunks/{chunk-GDVYFXOR.js → chunk-4GJSW2KC.js} +12 -12
  16. package/dist/chunks/{chunk-O3L5C2WT.js → chunk-4JQUY3DT.js} +2 -2
  17. package/dist/chunks/{chunk-R7XQP4PZ.js → chunk-5OVI35QS.js} +3 -3
  18. package/dist/chunks/{chunk-XDGIOXTU.js → chunk-65CAAE7I.js} +5 -5
  19. package/dist/chunks/{chunk-G6LK7V7F.js → chunk-6CCX6DPQ.js} +2 -2
  20. package/dist/chunks/{chunk-BZJNXGWW.js → chunk-6RNVFKSZ.js} +3 -3
  21. package/dist/chunks/{chunk-JAHVXTO4.js → chunk-AGN45S6D.js} +2 -2
  22. package/dist/chunks/{chunk-DWSATEAY.js → chunk-AOHJCFG3.js} +2 -2
  23. package/dist/chunks/{chunk-KOYEUNX7.js → chunk-AUZB4LKS.js} +4 -4
  24. package/dist/chunks/{chunk-BJNHDKU6.js → chunk-AX4Z3H7N.js} +2 -2
  25. package/dist/chunks/{chunk-ZPIHARMI.js → chunk-B2RMIYPZ.js} +4 -4
  26. package/dist/chunks/{chunk-RVNLS4BN.js → chunk-B6BQ5ULO.js} +2 -2
  27. package/dist/chunks/{chunk-L2GX4GAQ.js → chunk-BPRT5LV7.js} +2 -2
  28. package/dist/chunks/{chunk-C3ZJQLUX.js → chunk-CBL2FUHG.js} +2 -2
  29. package/dist/chunks/{chunk-AUFSSABF.js → chunk-DMPPM3IA.js} +3 -3
  30. package/dist/chunks/{chunk-PXKXXNFU.js → chunk-EL6GXINV.js} +2 -2
  31. package/dist/chunks/{chunk-X54VNEWE.js → chunk-FLYE25VX.js} +2 -2
  32. package/dist/chunks/{chunk-EKFNDKPO.js → chunk-G4LCCGQR.js} +2 -2
  33. package/dist/chunks/{chunk-SUDXOGE6.js → chunk-HE7K6IZ2.js} +28 -28
  34. package/dist/chunks/{chunk-2I3Z65TV.js → chunk-IR3AZZFJ.js} +60 -22
  35. package/dist/chunks/chunk-IR3AZZFJ.js.map +6 -0
  36. package/dist/chunks/{chunk-HLYTSH5W.js → chunk-JSGZ4V7Y.js} +2 -2
  37. package/dist/chunks/{chunk-D63T5UQN.js → chunk-K5OXOYM5.js} +13542 -12692
  38. package/dist/chunks/chunk-K5OXOYM5.js.map +6 -0
  39. package/dist/chunks/{chunk-DGV5W2BU.js → chunk-KD4Q2INM.js} +2 -2
  40. package/dist/chunks/{chunk-BZ4U5L7N.js → chunk-M5RW7JBV.js} +9 -9
  41. package/dist/chunks/{chunk-SOE4Q55L.js → chunk-MDG3THRR.js} +2 -2
  42. package/dist/chunks/{chunk-FBY4LGL7.js → chunk-MNDFPZVQ.js} +3 -3
  43. package/dist/chunks/{chunk-HBDBVQ3R.js → chunk-MZI4TLFB.js} +12 -12
  44. package/dist/chunks/{chunk-I7LUF577.js → chunk-NQGMYAXK.js} +3 -3
  45. package/dist/chunks/{chunk-WYULBUCG.js → chunk-O6FOUL5S.js} +4 -4
  46. package/dist/chunks/{chunk-C723P7SP.js → chunk-O6JILDEY.js} +6 -6
  47. package/dist/chunks/{chunk-KWRJTEV5.js → chunk-OUQEMJ26.js} +3 -3
  48. package/dist/chunks/{chunk-RVSGU3JS.js → chunk-P3JHLZH4.js} +2 -2
  49. package/dist/chunks/{chunk-6UDJ3PVE.js → chunk-PDZZ64IH.js} +7 -7
  50. package/dist/chunks/{chunk-GTWNJ7GL.js → chunk-PKLBJMCY.js} +4 -4
  51. package/dist/chunks/{chunk-U5PL5D27.js → chunk-PPZKCA6K.js} +2 -2
  52. package/dist/chunks/{chunk-YTEGBYGL.js → chunk-PSZ44BRO.js} +4 -4
  53. package/dist/chunks/{chunk-73G5WDGM.js → chunk-PTJI2QA4.js} +3 -3
  54. package/dist/chunks/{chunk-53GEER6F.js → chunk-QSDPQR3F.js} +3 -3
  55. package/dist/chunks/{chunk-XLGTH7JD.js → chunk-QY77MJS4.js} +4 -4
  56. package/dist/chunks/{chunk-LM3W6AEK.js → chunk-RWOPUQNS.js} +2 -2
  57. package/dist/chunks/{chunk-HPLVGTBH.js → chunk-SE5UKEXD.js} +2 -2
  58. package/dist/chunks/{chunk-KKYIGLKI.js → chunk-SEYEOYMT.js} +4 -4
  59. package/dist/chunks/{chunk-C3APHRQB.js → chunk-SMR6TQN2.js} +2 -2
  60. package/dist/chunks/{chunk-U5KONGAN.js → chunk-SPZWLMZY.js} +3 -3
  61. package/dist/chunks/{chunk-BQ7PN64G.js → chunk-V2NG7LLL.js} +5 -5
  62. package/dist/chunks/{chunk-IAL3F2OI.js → chunk-V2ZSQXYQ.js} +8 -8
  63. package/dist/chunks/{chunk-6PAE7AWD.js → chunk-V4PHIKLW.js} +2 -2
  64. package/dist/chunks/{chunk-RLMKDLGK.js → chunk-VUZYMKPD.js} +7 -7
  65. package/dist/chunks/{chunk-AQL5A442.js → chunk-WLAVNIFG.js} +3 -3
  66. package/dist/chunks/{chunk-5HSG2XFD.js → chunk-WQRBEQ2P.js} +2 -2
  67. package/dist/chunks/{chunk-RAS4ZA5C.js → chunk-WV7XGYNQ.js} +5 -5
  68. package/dist/chunks/{chunk-ILTHOMHL.js → chunk-WZPN6PWE.js} +4 -4
  69. package/dist/chunks/{chunk-4HUZHYCY.js → chunk-XRX3DHEW.js} +4 -4
  70. package/dist/chunks/{chunk-T6INV7EZ.js → chunk-XWLQH2NW.js} +7 -7
  71. package/dist/chunks/{chunk-QPEGCKRA.js → chunk-YGV3VBYL.js} +2 -2
  72. package/dist/chunks/{chunk-TTDBVPB2.js → chunk-YXZBHG5N.js} +2358 -1993
  73. package/dist/chunks/chunk-YXZBHG5N.js.map +6 -0
  74. package/dist/chunks/{cli-runtime-YD7OZGEU.js → cli-runtime-5H7CTXF2.js} +10 -10
  75. package/dist/chunks/{commands-5P4RLRXG.js → commands-XC67PG6L.js} +5 -5
  76. package/dist/chunks/{crash-report-F5G32A7S.js → crash-report-UE423ET4.js} +6 -6
  77. package/dist/chunks/{dist-Y6SGSSMO.js → dist-4ACX6FL7.js} +2 -2
  78. package/dist/chunks/{dist-7B6PZO7C.js → dist-DCOPEJDN.js} +2 -2
  79. package/dist/chunks/{dist-DFLFYX3A.js → dist-DSK2VZQB.js} +2 -2
  80. package/dist/chunks/{dist-6O3HSFZP.js → dist-OXUHOXCU.js} +2 -2
  81. package/dist/chunks/{dist-ZAGIMP7N.js → dist-SN7QXPO2.js} +2 -2
  82. package/dist/chunks/{dist-WB355CNL.js → dist-SY7OYS74.js} +2 -2
  83. package/dist/chunks/{dist-SX66KAH4.js → dist-YZRXSX7C.js} +2 -2
  84. package/dist/chunks/{doctor-2AOB47IO.js → doctor-VCCIYKNL.js} +8 -8
  85. package/dist/chunks/{drain-M6AGCMJX.js → drain-QKEXEMCO.js} +10 -10
  86. package/dist/chunks/{eval-YHY3VO7B.js → eval-K47YMZVT.js} +2 -2
  87. package/dist/chunks/{exec-KCISQ4M7.js → exec-K3LRQU6R.js} +27 -27
  88. package/dist/chunks/{home-AC5LQKDR.js → home-OSHELFKX.js} +3 -3
  89. package/dist/chunks/{host-queries-YQVRKUWC.js → host-queries-TV3XH3YV.js} +14 -14
  90. package/dist/chunks/{lifecycle-CQXCTLAZ.js → lifecycle-R3QWZ664.js} +23 -23
  91. package/dist/chunks/{list-LNKKJZSZ.js → list-L5QFDBPX.js} +11 -11
  92. package/dist/chunks/{login-YA652CIL.js → login-N4EO2F45.js} +8 -8
  93. package/dist/chunks/{logs-2PREHSOD.js → logs-264INNUN.js} +4 -4
  94. package/dist/chunks/{mcp-WJB2UVQW.js → mcp-7H3G3KLD.js} +16 -16
  95. package/dist/chunks/{message-command-IXUASFZO.js → message-command-JOQ24TAL.js} +32 -32
  96. package/dist/chunks/{operator-tools-QOZZZVEC.js → operator-tools-O2MDVMJP.js} +12 -12
  97. package/dist/chunks/{output-schema-JTPOC3NL.js → output-schema-LKM35JS4.js} +3 -3
  98. package/dist/chunks/{pal-FNSNP47Q.js → pal-N56IUOUP.js} +11 -11
  99. package/dist/chunks/{providers-M5HWW7DH.js → providers-B352G4OM.js} +6 -6
  100. package/dist/chunks/{resident-R2RCAHYR.js → resident-SMWDKMJP.js} +20 -20
  101. package/dist/chunks/resume-EXHKGQII.js +22 -0
  102. package/dist/chunks/{resume-command-LPN33FIF.js → resume-command-OHQBIY5P.js} +4 -4
  103. package/dist/chunks/{schedule-J2IY3SVE.js → schedule-VHP2VGEF.js} +8 -8
  104. package/dist/chunks/{service-LEAVOYGP.js → service-RHWPRJJO.js} +22 -22
  105. package/dist/chunks/session-step-NJRR3Q2L.js +30 -0
  106. package/dist/chunks/{skills-X2V3TNTK.js → skills-JS3FQPHU.js} +8 -8
  107. package/dist/chunks/{state-VDTYWZ5S.js → state-A56X2FGB.js} +2 -2
  108. package/dist/chunks/{store-DRPRQLDD.js → store-IMV6NZTT.js} +9 -9
  109. package/dist/chunks/{store-C27Q22UV.js → store-SEPPZ7H6.js} +4 -4
  110. package/dist/chunks/{store-S4QRR5DH.js → store-WJEK5ZI2.js} +6 -6
  111. package/dist/chunks/{tui-RU6CRMLX.js → tui-BP7MYQG2.js} +1708 -1258
  112. package/dist/chunks/tui-BP7MYQG2.js.map +6 -0
  113. package/dist/chunks/{upgrade-I2GMLDWZ.js → upgrade-2A7CIVAY.js} +2 -2
  114. package/dist/chunks/{worktree-F632OJNE.js → worktree-ERUU4NVZ.js} +11 -11
  115. package/dist/context/doctrine.d.ts +2 -1
  116. package/dist/context/doctrine.d.ts.map +1 -1
  117. package/dist/context/environment.d.ts +37 -1
  118. package/dist/context/environment.d.ts.map +1 -1
  119. package/dist/context/identity.d.ts +27 -0
  120. package/dist/context/identity.d.ts.map +1 -0
  121. package/dist/context/project-tracker.d.ts.map +1 -1
  122. package/dist/context/system-prompt.d.ts +99 -0
  123. package/dist/context/system-prompt.d.ts.map +1 -0
  124. package/dist/index.js +12 -12
  125. package/dist/integrations/resident/runner-worker.js +18 -18
  126. package/dist/integrations/sessions/conversation-search.d.ts +1 -1
  127. package/dist/integrations/sessions/conversation-search.d.ts.map +1 -1
  128. package/dist/integrations/subagents/runtime.d.ts +2 -0
  129. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  130. package/dist/integrations/workflows/doctrine.d.ts.map +1 -1
  131. package/dist/integrations/workflows/host.d.ts +0 -5
  132. package/dist/integrations/workflows/host.d.ts.map +1 -1
  133. package/dist/integrations/workflows/offering.d.ts +0 -2
  134. package/dist/integrations/workflows/offering.d.ts.map +1 -1
  135. package/dist/integrations/workflows/size.d.ts +9 -1
  136. package/dist/integrations/workflows/size.d.ts.map +1 -1
  137. package/dist/permissions/session-allow.d.ts +10 -0
  138. package/dist/permissions/session-allow.d.ts.map +1 -1
  139. package/dist/reminders/environment.d.ts +20 -0
  140. package/dist/reminders/environment.d.ts.map +1 -0
  141. package/dist/reminders/frame.d.ts +1 -1
  142. package/dist/reminders/frame.d.ts.map +1 -1
  143. package/dist/reminders/index.d.ts +11 -1
  144. package/dist/reminders/index.d.ts.map +1 -1
  145. package/dist/reminders/mode.d.ts +11 -0
  146. package/dist/reminders/mode.d.ts.map +1 -0
  147. package/dist/tui/App.d.ts.map +1 -1
  148. package/dist/tui/LiveActivity.d.ts +2 -0
  149. package/dist/tui/LiveActivity.d.ts.map +1 -1
  150. package/dist/tui/PermissionOverlay.d.ts +25 -4
  151. package/dist/tui/PermissionOverlay.d.ts.map +1 -1
  152. package/dist/tui/agent.d.ts +22 -2
  153. package/dist/tui/agent.d.ts.map +1 -1
  154. package/dist/tui/connector-label.d.ts +19 -0
  155. package/dist/tui/connector-label.d.ts.map +1 -0
  156. package/dist/tui/per-call-review.d.ts +50 -0
  157. package/dist/tui/per-call-review.d.ts.map +1 -0
  158. package/dist/tui/permission-asks.d.ts +68 -0
  159. package/dist/tui/permission-asks.d.ts.map +1 -0
  160. package/dist/tui/queued-calls.d.ts +47 -0
  161. package/dist/tui/queued-calls.d.ts.map +1 -0
  162. package/dist/tui/tidy-tool-output.d.ts +5 -0
  163. package/dist/tui/tidy-tool-output.d.ts.map +1 -1
  164. package/dist/tui/tool-end-rows.d.ts.map +1 -1
  165. package/package.json +5 -5
  166. package/skills/schedule-task/SKILL.md +6 -34
  167. package/dist/chunks/agent-session-PISYPFO2.js +0 -54
  168. package/dist/chunks/chunk-2I3Z65TV.js.map +0 -6
  169. package/dist/chunks/chunk-7M6IZGAK.js.map +0 -6
  170. package/dist/chunks/chunk-D63T5UQN.js.map +0 -6
  171. package/dist/chunks/chunk-TTDBVPB2.js.map +0 -6
  172. package/dist/chunks/resume-UKK4HVCO.js +0 -22
  173. package/dist/chunks/session-step-2B46NVE7.js +0 -30
  174. package/dist/chunks/tui-RU6CRMLX.js.map +0 -6
  175. /package/dist/chunks/{acp-E7XNZWFV.js.map → acp-CLFVQCFH.js.map} +0 -0
  176. /package/dist/chunks/{activity-command-QANVT2PA.js.map → activity-command-XULXEUGH.js.map} +0 -0
  177. /package/dist/chunks/{add-VDRMBSNZ.js.map → add-BALM5DGZ.js.map} +0 -0
  178. /package/dist/chunks/{agent-PPQJZWBO.js.map → agent-CLYE4KWV.js.map} +0 -0
  179. /package/dist/chunks/{agent-session-PISYPFO2.js.map → agent-session-2MVAYKJC.js.map} +0 -0
  180. /package/dist/chunks/{archive-SH4IG6KC.js.map → archive-FWXFWMZJ.js.map} +0 -0
  181. /package/dist/chunks/{bin-main-D45Q7FMM.js.map → bin-main-HO4CMSMY.js.map} +0 -0
  182. /package/dist/chunks/{browser-EUFWHKYD.js.map → browser-Z46YPGWH.js.map} +0 -0
  183. /package/dist/chunks/{chat-QDWGHEEL.js.map → chat-NOXE5RTE.js.map} +0 -0
  184. /package/dist/chunks/{chunk-AHPIP5IE.js.map → chunk-3WAQN6DX.js.map} +0 -0
  185. /package/dist/chunks/{chunk-GDVYFXOR.js.map → chunk-4GJSW2KC.js.map} +0 -0
  186. /package/dist/chunks/{chunk-O3L5C2WT.js.map → chunk-4JQUY3DT.js.map} +0 -0
  187. /package/dist/chunks/{chunk-R7XQP4PZ.js.map → chunk-5OVI35QS.js.map} +0 -0
  188. /package/dist/chunks/{chunk-XDGIOXTU.js.map → chunk-65CAAE7I.js.map} +0 -0
  189. /package/dist/chunks/{chunk-G6LK7V7F.js.map → chunk-6CCX6DPQ.js.map} +0 -0
  190. /package/dist/chunks/{chunk-BZJNXGWW.js.map → chunk-6RNVFKSZ.js.map} +0 -0
  191. /package/dist/chunks/{chunk-JAHVXTO4.js.map → chunk-AGN45S6D.js.map} +0 -0
  192. /package/dist/chunks/{chunk-DWSATEAY.js.map → chunk-AOHJCFG3.js.map} +0 -0
  193. /package/dist/chunks/{chunk-KOYEUNX7.js.map → chunk-AUZB4LKS.js.map} +0 -0
  194. /package/dist/chunks/{chunk-BJNHDKU6.js.map → chunk-AX4Z3H7N.js.map} +0 -0
  195. /package/dist/chunks/{chunk-ZPIHARMI.js.map → chunk-B2RMIYPZ.js.map} +0 -0
  196. /package/dist/chunks/{chunk-RVNLS4BN.js.map → chunk-B6BQ5ULO.js.map} +0 -0
  197. /package/dist/chunks/{chunk-L2GX4GAQ.js.map → chunk-BPRT5LV7.js.map} +0 -0
  198. /package/dist/chunks/{chunk-C3ZJQLUX.js.map → chunk-CBL2FUHG.js.map} +0 -0
  199. /package/dist/chunks/{chunk-AUFSSABF.js.map → chunk-DMPPM3IA.js.map} +0 -0
  200. /package/dist/chunks/{chunk-PXKXXNFU.js.map → chunk-EL6GXINV.js.map} +0 -0
  201. /package/dist/chunks/{chunk-X54VNEWE.js.map → chunk-FLYE25VX.js.map} +0 -0
  202. /package/dist/chunks/{chunk-EKFNDKPO.js.map → chunk-G4LCCGQR.js.map} +0 -0
  203. /package/dist/chunks/{chunk-SUDXOGE6.js.map → chunk-HE7K6IZ2.js.map} +0 -0
  204. /package/dist/chunks/{chunk-HLYTSH5W.js.map → chunk-JSGZ4V7Y.js.map} +0 -0
  205. /package/dist/chunks/{chunk-DGV5W2BU.js.map → chunk-KD4Q2INM.js.map} +0 -0
  206. /package/dist/chunks/{chunk-BZ4U5L7N.js.map → chunk-M5RW7JBV.js.map} +0 -0
  207. /package/dist/chunks/{chunk-SOE4Q55L.js.map → chunk-MDG3THRR.js.map} +0 -0
  208. /package/dist/chunks/{chunk-FBY4LGL7.js.map → chunk-MNDFPZVQ.js.map} +0 -0
  209. /package/dist/chunks/{chunk-HBDBVQ3R.js.map → chunk-MZI4TLFB.js.map} +0 -0
  210. /package/dist/chunks/{chunk-I7LUF577.js.map → chunk-NQGMYAXK.js.map} +0 -0
  211. /package/dist/chunks/{chunk-WYULBUCG.js.map → chunk-O6FOUL5S.js.map} +0 -0
  212. /package/dist/chunks/{chunk-C723P7SP.js.map → chunk-O6JILDEY.js.map} +0 -0
  213. /package/dist/chunks/{chunk-KWRJTEV5.js.map → chunk-OUQEMJ26.js.map} +0 -0
  214. /package/dist/chunks/{chunk-RVSGU3JS.js.map → chunk-P3JHLZH4.js.map} +0 -0
  215. /package/dist/chunks/{chunk-6UDJ3PVE.js.map → chunk-PDZZ64IH.js.map} +0 -0
  216. /package/dist/chunks/{chunk-GTWNJ7GL.js.map → chunk-PKLBJMCY.js.map} +0 -0
  217. /package/dist/chunks/{chunk-U5PL5D27.js.map → chunk-PPZKCA6K.js.map} +0 -0
  218. /package/dist/chunks/{chunk-YTEGBYGL.js.map → chunk-PSZ44BRO.js.map} +0 -0
  219. /package/dist/chunks/{chunk-73G5WDGM.js.map → chunk-PTJI2QA4.js.map} +0 -0
  220. /package/dist/chunks/{chunk-53GEER6F.js.map → chunk-QSDPQR3F.js.map} +0 -0
  221. /package/dist/chunks/{chunk-XLGTH7JD.js.map → chunk-QY77MJS4.js.map} +0 -0
  222. /package/dist/chunks/{chunk-LM3W6AEK.js.map → chunk-RWOPUQNS.js.map} +0 -0
  223. /package/dist/chunks/{chunk-HPLVGTBH.js.map → chunk-SE5UKEXD.js.map} +0 -0
  224. /package/dist/chunks/{chunk-KKYIGLKI.js.map → chunk-SEYEOYMT.js.map} +0 -0
  225. /package/dist/chunks/{chunk-C3APHRQB.js.map → chunk-SMR6TQN2.js.map} +0 -0
  226. /package/dist/chunks/{chunk-U5KONGAN.js.map → chunk-SPZWLMZY.js.map} +0 -0
  227. /package/dist/chunks/{chunk-BQ7PN64G.js.map → chunk-V2NG7LLL.js.map} +0 -0
  228. /package/dist/chunks/{chunk-IAL3F2OI.js.map → chunk-V2ZSQXYQ.js.map} +0 -0
  229. /package/dist/chunks/{chunk-6PAE7AWD.js.map → chunk-V4PHIKLW.js.map} +0 -0
  230. /package/dist/chunks/{chunk-RLMKDLGK.js.map → chunk-VUZYMKPD.js.map} +0 -0
  231. /package/dist/chunks/{chunk-AQL5A442.js.map → chunk-WLAVNIFG.js.map} +0 -0
  232. /package/dist/chunks/{chunk-5HSG2XFD.js.map → chunk-WQRBEQ2P.js.map} +0 -0
  233. /package/dist/chunks/{chunk-RAS4ZA5C.js.map → chunk-WV7XGYNQ.js.map} +0 -0
  234. /package/dist/chunks/{chunk-ILTHOMHL.js.map → chunk-WZPN6PWE.js.map} +0 -0
  235. /package/dist/chunks/{chunk-4HUZHYCY.js.map → chunk-XRX3DHEW.js.map} +0 -0
  236. /package/dist/chunks/{chunk-T6INV7EZ.js.map → chunk-XWLQH2NW.js.map} +0 -0
  237. /package/dist/chunks/{chunk-QPEGCKRA.js.map → chunk-YGV3VBYL.js.map} +0 -0
  238. /package/dist/chunks/{cli-runtime-YD7OZGEU.js.map → cli-runtime-5H7CTXF2.js.map} +0 -0
  239. /package/dist/chunks/{commands-5P4RLRXG.js.map → commands-XC67PG6L.js.map} +0 -0
  240. /package/dist/chunks/{crash-report-F5G32A7S.js.map → crash-report-UE423ET4.js.map} +0 -0
  241. /package/dist/chunks/{dist-Y6SGSSMO.js.map → dist-4ACX6FL7.js.map} +0 -0
  242. /package/dist/chunks/{dist-7B6PZO7C.js.map → dist-DCOPEJDN.js.map} +0 -0
  243. /package/dist/chunks/{dist-DFLFYX3A.js.map → dist-DSK2VZQB.js.map} +0 -0
  244. /package/dist/chunks/{dist-6O3HSFZP.js.map → dist-OXUHOXCU.js.map} +0 -0
  245. /package/dist/chunks/{dist-ZAGIMP7N.js.map → dist-SN7QXPO2.js.map} +0 -0
  246. /package/dist/chunks/{dist-WB355CNL.js.map → dist-SY7OYS74.js.map} +0 -0
  247. /package/dist/chunks/{dist-SX66KAH4.js.map → dist-YZRXSX7C.js.map} +0 -0
  248. /package/dist/chunks/{doctor-2AOB47IO.js.map → doctor-VCCIYKNL.js.map} +0 -0
  249. /package/dist/chunks/{drain-M6AGCMJX.js.map → drain-QKEXEMCO.js.map} +0 -0
  250. /package/dist/chunks/{eval-YHY3VO7B.js.map → eval-K47YMZVT.js.map} +0 -0
  251. /package/dist/chunks/{exec-KCISQ4M7.js.map → exec-K3LRQU6R.js.map} +0 -0
  252. /package/dist/chunks/{home-AC5LQKDR.js.map → home-OSHELFKX.js.map} +0 -0
  253. /package/dist/chunks/{host-queries-YQVRKUWC.js.map → host-queries-TV3XH3YV.js.map} +0 -0
  254. /package/dist/chunks/{lifecycle-CQXCTLAZ.js.map → lifecycle-R3QWZ664.js.map} +0 -0
  255. /package/dist/chunks/{list-LNKKJZSZ.js.map → list-L5QFDBPX.js.map} +0 -0
  256. /package/dist/chunks/{login-YA652CIL.js.map → login-N4EO2F45.js.map} +0 -0
  257. /package/dist/chunks/{logs-2PREHSOD.js.map → logs-264INNUN.js.map} +0 -0
  258. /package/dist/chunks/{mcp-WJB2UVQW.js.map → mcp-7H3G3KLD.js.map} +0 -0
  259. /package/dist/chunks/{message-command-IXUASFZO.js.map → message-command-JOQ24TAL.js.map} +0 -0
  260. /package/dist/chunks/{operator-tools-QOZZZVEC.js.map → operator-tools-O2MDVMJP.js.map} +0 -0
  261. /package/dist/chunks/{output-schema-JTPOC3NL.js.map → output-schema-LKM35JS4.js.map} +0 -0
  262. /package/dist/chunks/{pal-FNSNP47Q.js.map → pal-N56IUOUP.js.map} +0 -0
  263. /package/dist/chunks/{providers-M5HWW7DH.js.map → providers-B352G4OM.js.map} +0 -0
  264. /package/dist/chunks/{resident-R2RCAHYR.js.map → resident-SMWDKMJP.js.map} +0 -0
  265. /package/dist/chunks/{resume-UKK4HVCO.js.map → resume-EXHKGQII.js.map} +0 -0
  266. /package/dist/chunks/{resume-command-LPN33FIF.js.map → resume-command-OHQBIY5P.js.map} +0 -0
  267. /package/dist/chunks/{schedule-J2IY3SVE.js.map → schedule-VHP2VGEF.js.map} +0 -0
  268. /package/dist/chunks/{service-LEAVOYGP.js.map → service-RHWPRJJO.js.map} +0 -0
  269. /package/dist/chunks/{session-step-2B46NVE7.js.map → session-step-NJRR3Q2L.js.map} +0 -0
  270. /package/dist/chunks/{skills-X2V3TNTK.js.map → skills-JS3FQPHU.js.map} +0 -0
  271. /package/dist/chunks/{state-VDTYWZ5S.js.map → state-A56X2FGB.js.map} +0 -0
  272. /package/dist/chunks/{store-C27Q22UV.js.map → store-IMV6NZTT.js.map} +0 -0
  273. /package/dist/chunks/{store-DRPRQLDD.js.map → store-SEPPZ7H6.js.map} +0 -0
  274. /package/dist/chunks/{store-S4QRR5DH.js.map → store-WJEK5ZI2.js.map} +0 -0
  275. /package/dist/chunks/{upgrade-I2GMLDWZ.js.map → upgrade-2A7CIVAY.js.map} +0 -0
  276. /package/dist/chunks/{worktree-F632OJNE.js.map → worktree-ERUU4NVZ.js.map} +0 -0
@@ -2,21 +2,21 @@ import { createRequire as __namzuCreateRequire } from 'node:module';
2
2
  const require = __namzuCreateRequire(import.meta.url);
3
3
  import {
4
4
  reportCrash
5
- } from "./chunk-U5PL5D27.js";
5
+ } from "./chunk-PPZKCA6K.js";
6
6
  import {
7
7
  BYPASS_CONSENT_BODY,
8
8
  BYPASS_CONSENT_TITLE,
9
9
  acknowledgeBypass,
10
10
  hasAcknowledgedBypass
11
- } from "./chunk-RVNLS4BN.js";
11
+ } from "./chunk-B6BQ5ULO.js";
12
12
  import {
13
13
  settleAnsweredPark
14
- } from "./chunk-T6INV7EZ.js";
14
+ } from "./chunk-XWLQH2NW.js";
15
15
  import {
16
16
  DELIVERY_READ_LIMIT,
17
17
  readSourceDeliveryPage,
18
18
  takeSuppressedCount
19
- } from "./chunk-HBDBVQ3R.js";
19
+ } from "./chunk-MZI4TLFB.js";
20
20
  import {
21
21
  callsCount
22
22
  } from "./chunk-E5VLANCO.js";
@@ -37,7 +37,7 @@ import {
37
37
  confirmationView,
38
38
  describeChanges,
39
39
  permissionsChanged
40
- } from "./chunk-C3APHRQB.js";
40
+ } from "./chunk-SMR6TQN2.js";
41
41
  import {
42
42
  visibleScheduleMessage
43
43
  } from "./chunk-NADQQMMG.js";
@@ -54,25 +54,25 @@ import {
54
54
  runsPerDay,
55
55
  scriptShellUnavailableReason,
56
56
  verifyScheduledScript
57
- } from "./chunk-XLGTH7JD.js";
57
+ } from "./chunk-QY77MJS4.js";
58
58
  import {
59
59
  allowsCommands,
60
60
  compileJobPolicy,
61
61
  compileScriptCheckPolicy,
62
62
  isPresetName
63
- } from "./chunk-KOYEUNX7.js";
64
- import "./chunk-HPLVGTBH.js";
63
+ } from "./chunk-AUZB4LKS.js";
64
+ import "./chunk-SE5UKEXD.js";
65
65
  import {
66
66
  formatResumeShellCommand,
67
67
  parkedRunWords,
68
68
  resumeCommand
69
- } from "./chunk-DGV5W2BU.js";
69
+ } from "./chunk-KD4Q2INM.js";
70
70
  import {
71
71
  appendHistory,
72
72
  nextFireOf,
73
73
  readHistory,
74
74
  readState
75
- } from "./chunk-C3ZJQLUX.js";
75
+ } from "./chunk-CBL2FUHG.js";
76
76
  import {
77
77
  TURN_LIMIT_FIELDS,
78
78
  ThemeEpochContext,
@@ -108,7 +108,7 @@ import {
108
108
  useReducedMotion,
109
109
  useThemeEpoch,
110
110
  useThemeSubscription
111
- } from "./chunk-RLMKDLGK.js";
111
+ } from "./chunk-VUZYMKPD.js";
112
112
  import {
113
113
  capChoiceLines,
114
114
  choiceDisplayText,
@@ -121,12 +121,12 @@ import {
121
121
  } from "./chunk-LFI6O7WL.js";
122
122
  import {
123
123
  handleTerminationSignals
124
- } from "./chunk-L2GX4GAQ.js";
124
+ } from "./chunk-BPRT5LV7.js";
125
125
  import "./chunk-TBIX6JRE.js";
126
126
  import {
127
127
  deleteUserConfigValue,
128
128
  setUserConfigValue
129
- } from "./chunk-AQL5A442.js";
129
+ } from "./chunk-WLAVNIFG.js";
130
130
  import {
131
131
  describeAllCredentialsLogout,
132
132
  describeCodexDeviceLoginStart,
@@ -148,14 +148,14 @@ import {
148
148
  sectionHeading,
149
149
  withAutoChoice,
150
150
  writeConversationExport
151
- } from "./chunk-BZJNXGWW.js";
151
+ } from "./chunk-6RNVFKSZ.js";
152
152
  import {
153
153
  tuiPalDefinition,
154
154
  tuiPalEnvironment,
155
155
  tuiPalOwner,
156
156
  tuiPalPreferences
157
- } from "./chunk-RAS4ZA5C.js";
158
- import "./chunk-IAL3F2OI.js";
157
+ } from "./chunk-WV7XGYNQ.js";
158
+ import "./chunk-V2ZSQXYQ.js";
159
159
  import {
160
160
  COMPACTED_HINT,
161
161
  COMPACTING_LABEL,
@@ -177,6 +177,7 @@ import {
177
177
  WORKFLOW_BACKGROUND_NOTE,
178
178
  WORKFLOW_TOOL_NAME,
179
179
  WORKSPACE_PREVIEW_ROWS,
180
+ allowsFor,
180
181
  allowsForBatch,
181
182
  appendMemoryWithStatus,
182
183
  assistantTranscriptTexts,
@@ -184,6 +185,7 @@ import {
184
185
  clipText,
185
186
  combineBatches,
186
187
  compactionSummaryLines,
188
+ connectorToolLabel,
187
189
  createAgentSession,
188
190
  declinedLine,
189
191
  describeAllows,
@@ -202,6 +204,8 @@ import {
202
204
  liveBatches,
203
205
  mergeGroups,
204
206
  modelListingCause,
207
+ mustAskPerson,
208
+ plainConnectorSummary,
205
209
  plainDiffRows,
206
210
  planApprovalRows,
207
211
  probeAgentSession,
@@ -215,6 +219,7 @@ import {
215
219
  renderStoredMemorySection,
216
220
  renderTypedNoteResult,
217
221
  resolveModelSwitch,
222
+ sameAllow,
218
223
  spansText,
219
224
  toAgentEvent,
220
225
  turnLabel,
@@ -226,12 +231,12 @@ import {
226
231
  webLiveStatus,
227
232
  webSettledLine,
228
233
  withDebugDetail
229
- } from "./chunk-TTDBVPB2.js";
234
+ } from "./chunk-YXZBHG5N.js";
230
235
  import {
231
236
  openManagedWorktrees,
232
237
  worktreeOpenHint
233
- } from "./chunk-ZPIHARMI.js";
234
- import "./chunk-U5KONGAN.js";
238
+ } from "./chunk-B2RMIYPZ.js";
239
+ import "./chunk-SPZWLMZY.js";
235
240
  import {
236
241
  describeBrowserStatus
237
242
  } from "./chunk-WHODOMXA.js";
@@ -258,22 +263,22 @@ import {
258
263
  settledElapsed,
259
264
  theme,
260
265
  tokenColor
261
- } from "./chunk-XDGIOXTU.js";
266
+ } from "./chunk-65CAAE7I.js";
262
267
  import {
263
268
  describePlainInterruption,
264
269
  describeProviderWait,
265
270
  describeProviderWaitClock
266
- } from "./chunk-I7LUF577.js";
267
- import "./chunk-WYULBUCG.js";
271
+ } from "./chunk-NQGMYAXK.js";
272
+ import "./chunk-O6FOUL5S.js";
268
273
  import {
269
274
  openInBrowser
270
- } from "./chunk-HLYTSH5W.js";
275
+ } from "./chunk-JSGZ4V7Y.js";
271
276
  import "./chunk-NUGPLXVK.js";
272
277
  import {
273
278
  beginCodexDeviceLogin,
274
279
  beginSubscriptionLogin,
275
280
  parsePastedInput
276
- } from "./chunk-YTEGBYGL.js";
281
+ } from "./chunk-PSZ44BRO.js";
277
282
  import {
278
283
  NO_SKILLS_FOUND,
279
284
  composeSkillsPrompt,
@@ -281,13 +286,13 @@ import {
281
286
  loadSkillBody,
282
287
  renderSkillRoster,
283
288
  skillTierLabel
284
- } from "./chunk-73G5WDGM.js";
285
- import "./chunk-KWRJTEV5.js";
286
- import "./chunk-C723P7SP.js";
289
+ } from "./chunk-PTJI2QA4.js";
290
+ import "./chunk-OUQEMJ26.js";
291
+ import "./chunk-O6JILDEY.js";
287
292
  import {
288
293
  claimPalConversation,
289
294
  listPalConversations
290
- } from "./chunk-KKYIGLKI.js";
295
+ } from "./chunk-SEYEOYMT.js";
291
296
  import "./chunk-ZWA2JRJV.js";
292
297
  import {
293
298
  pinTrustedProjectPath,
@@ -308,12 +313,12 @@ import {
308
313
  loadConfigWithProvenance,
309
314
  readPermissionLayers,
310
315
  resolveComposerTriggers
311
- } from "./chunk-7M6IZGAK.js";
316
+ } from "./chunk-37S7MY2T.js";
312
317
  import "./chunk-XSCT3DLE.js";
313
318
  import {
314
319
  THEME_CHOICES,
315
320
  formatConfigSource
316
- } from "./chunk-G6LK7V7F.js";
321
+ } from "./chunk-6CCX6DPQ.js";
317
322
  import {
318
323
  displayPath,
319
324
  formatSize,
@@ -339,7 +344,7 @@ import {
339
344
  writeJsonAtomic
340
345
  } from "./chunk-OEW7CJKK.js";
341
346
  import "./chunk-HE7WUOX2.js";
342
- import "./chunk-PXKXXNFU.js";
347
+ import "./chunk-EL6GXINV.js";
343
348
  import {
344
349
  EXIT_INTERNAL_ERROR
345
350
  } from "./chunk-Y7B67G22.js";
@@ -357,7 +362,7 @@ import {
357
362
  primaryProvider,
358
363
  signedInSubscriptionProviders,
359
364
  writePreferences
360
- } from "./chunk-2I3Z65TV.js";
365
+ } from "./chunk-IR3AZZFJ.js";
361
366
  import {
362
367
  ALL_PROVIDER_IDS,
363
368
  PROVIDER_REGISTRY,
@@ -367,21 +372,21 @@ import {
367
372
  } from "./chunk-6LLJQ3KY.js";
368
373
  import {
369
374
  applyProviderFlags
370
- } from "./chunk-FBY4LGL7.js";
375
+ } from "./chunk-MNDFPZVQ.js";
371
376
  import "./chunk-XEUQN4JC.js";
372
377
  import {
373
378
  PAUSED_TURN_LINES,
374
379
  currentTimeLine,
375
380
  describeTurnStop,
376
381
  handoffContinuationNote
377
- } from "./chunk-EKFNDKPO.js";
382
+ } from "./chunk-G4LCCGQR.js";
378
383
  import {
379
384
  autoAvailable,
380
385
  nextCycleMode,
381
386
  permissionModeDescription,
382
387
  permissionModeLabel,
383
388
  permissionModeName
384
- } from "./chunk-LM3W6AEK.js";
389
+ } from "./chunk-RWOPUQNS.js";
385
390
  import {
386
391
  expandTabs,
387
392
  terminalDisplayText
@@ -408,21 +413,21 @@ import {
408
413
  titlesOf,
409
414
  typedTextOf,
410
415
  unarchiveConversation
411
- } from "./chunk-BQ7PN64G.js";
416
+ } from "./chunk-V2NG7LLL.js";
412
417
  import "./chunk-H6B6AROX.js";
413
- import "./chunk-O3L5C2WT.js";
414
- import "./chunk-4HUZHYCY.js";
418
+ import "./chunk-4JQUY3DT.js";
419
+ import "./chunk-XRX3DHEW.js";
415
420
  import {
416
421
  isTrusted,
417
422
  trustDir
418
- } from "./chunk-QPEGCKRA.js";
423
+ } from "./chunk-YGV3VBYL.js";
419
424
  import "./chunk-LXB3S4IC.js";
420
- import "./chunk-R7XQP4PZ.js";
425
+ import "./chunk-5OVI35QS.js";
421
426
  import "./chunk-WMEZTDLT.js";
422
427
  import {
423
428
  contextLogging,
424
429
  installCliLogging
425
- } from "./chunk-SOE4Q55L.js";
430
+ } from "./chunk-MDG3THRR.js";
426
431
  import {
427
432
  isFullWidth,
428
433
  isWide,
@@ -432,7 +437,7 @@ import {
432
437
  import "./chunk-OH6TB27S.js";
433
438
  import "./chunk-IE5XIE4W.js";
434
439
  import "./chunk-B73OIFL6.js";
435
- import "./chunk-6PAE7AWD.js";
440
+ import "./chunk-V4PHIKLW.js";
436
441
  import "./chunk-JORONMD3.js";
437
442
  import {
438
443
  clearAllStoredCredentials,
@@ -446,10 +451,10 @@ import {
446
451
  readStoredSubscriptionCredential,
447
452
  restrictToOwner,
448
453
  writeStoredGeminiApiKey
449
- } from "./chunk-X54VNEWE.js";
454
+ } from "./chunk-FLYE25VX.js";
450
455
  import {
451
456
  namzuHomePath
452
- } from "./chunk-DWSATEAY.js";
457
+ } from "./chunk-AOHJCFG3.js";
453
458
  import {
454
459
  ACCEPT_EDITS_TOOLS,
455
460
  DECLINED_TOOL_CALL_FEEDBACK,
@@ -510,7 +515,7 @@ import {
510
515
  validateTimeZone,
511
516
  wrapUntrusted,
512
517
  writePeerRecord
513
- } from "./chunk-D63T5UQN.js";
518
+ } from "./chunk-K5OXOYM5.js";
514
519
  import {
515
520
  __commonJS,
516
521
  __export,
@@ -42912,9 +42917,19 @@ function LiveActivity({
42912
42917
  });
42913
42918
  if (!active) return null;
42914
42919
  if (waitingForYou) {
42915
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { marginTop: 1, children: [
42916
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.secondary, children: "Waiting for you" }),
42917
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.muted, children: " \xB7 the question below" })
42920
+ const queued = activeTools.filter((tool) => tool.queued === true);
42921
+ const shownQueued = queued.slice(0, MAX_VISIBLE_TOOLS);
42922
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
42923
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { children: [
42924
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.secondary, children: "Waiting for you" }),
42925
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.muted, children: " \xB7 the question below" })
42926
+ ] }),
42927
+ shownQueued.map((tool) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(QueuedToolRow, { tool }, tool.id)),
42928
+ queued.length > shownQueued.length ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Box_default, { paddingLeft: 2, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Text, { color: theme.text.muted, children: [
42929
+ "+",
42930
+ queued.length - shownQueued.length,
42931
+ " more waiting"
42932
+ ] }) }) : null
42918
42933
  ] });
42919
42934
  }
42920
42935
  const now = Date.now();
@@ -42997,7 +43012,7 @@ function LiveActivity({
42997
43012
  waitingRow,
42998
43013
  noticeRow,
42999
43014
  visibleTools.map((t, index) => {
43000
- if (t.command !== void 0) {
43015
+ if (t.command !== void 0 && !t.queued) {
43001
43016
  const blink = motion ? Math.floor(tick / 5) % 2 === 0 : true;
43002
43017
  const rows = shellRunningRows(t.tail ?? [], formatElapsed(now - t.startedAt));
43003
43018
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "column", children: [
@@ -43014,6 +43029,7 @@ function LiveActivity({
43014
43029
  )) })
43015
43030
  ] }, t.id);
43016
43031
  }
43032
+ if (t.queued) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(QueuedToolRow, { tool: t }, t.id);
43017
43033
  const percent = t.fraction === void 0 ? "" : `${Math.round(t.fraction * 100)}% \xB7 `;
43018
43034
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 2, children: [
43019
43035
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "row", children: [
@@ -43045,6 +43061,19 @@ function LiveActivity({
43045
43061
  ] });
43046
43062
  }
43047
43063
  __name(LiveActivity, "LiveActivity");
43064
+ function QueuedToolRow({ tool }) {
43065
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "column", children: [
43066
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "row", children: [
43067
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Box_default, { width: 2, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.muted, children: "\u25CF" }) }),
43068
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.secondary, wrap: "truncate-end", children: terminalDisplayText(tool.label) })
43069
+ ] }),
43070
+ tool.command !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Box_default, { paddingLeft: RESULT_GUTTER_INDENT, children: [
43071
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Box_default, { width: RESULT_GUTTER_WIDTH, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: theme.text.muted, children: "\u23BF" }) }),
43072
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { color: shellToneColor("dim"), children: "Waiting\u2026" })
43073
+ ] }) : null
43074
+ ] });
43075
+ }
43076
+ __name(QueuedToolRow, "QueuedToolRow");
43048
43077
  function waitingLine(tools) {
43049
43078
  if (tools.length === 0 || !tools.every((tool) => tool.waitingOn !== void 0)) return void 0;
43050
43079
  const names = [...new Set(tools.map((tool) => tool.waitingOn))];
@@ -43278,7 +43307,7 @@ function permissionTitle(toolCalls) {
43278
43307
  case "workflow":
43279
43308
  return "Start a workflow";
43280
43309
  default:
43281
- return first.name;
43310
+ return connectorToolLabel(first.name);
43282
43311
  }
43283
43312
  }
43284
43313
  if (toolCalls.length > 0 && toolCalls.every((call) => call.name === "Agent")) {
@@ -43305,7 +43334,7 @@ function permissionQuestion(toolCalls) {
43305
43334
  case "workflow":
43306
43335
  return "Do you want to start this workflow?";
43307
43336
  default:
43308
- return `Do you want to run ${first.name}?`;
43337
+ return `Do you want to run ${connectorToolLabel(first.name)}?`;
43309
43338
  }
43310
43339
  }
43311
43340
  if (toolCalls.length > 0 && toolCalls.every((call) => call.name === "Agent")) {
@@ -43374,10 +43403,6 @@ function extraAnswer(toolCalls, options) {
43374
43403
  };
43375
43404
  }
43376
43405
  __name(extraAnswer, "extraAnswer");
43377
- function permissionChoices(toolCalls, options = {}) {
43378
- return permissionAnswers(toolCalls, options).map((answer) => answer.label);
43379
- }
43380
- __name(permissionChoices, "permissionChoices");
43381
43406
  function readableBody(summaryText, single2) {
43382
43407
  if (!single2) return summaryText;
43383
43408
  const lines = summaryText.split("\n");
@@ -43399,8 +43424,9 @@ function PermissionOverlay({
43399
43424
  detailsOpen,
43400
43425
  reviewOffset = 0,
43401
43426
  choice: choice2 = 0,
43402
- queuedCount = 0,
43403
- sourceLabel: sourceLabel3,
43427
+ count: count2,
43428
+ from,
43429
+ reason,
43404
43430
  columns,
43405
43431
  rows: terminalRows,
43406
43432
  batchOnly = false,
@@ -43409,9 +43435,10 @@ function PermissionOverlay({
43409
43435
  rememberWhere,
43410
43436
  siteNotes = [],
43411
43437
  screenConsent,
43412
- withheld = []
43438
+ withheld = [],
43439
+ endsTurn = false
43413
43440
  }) {
43414
- const pageRows = Math.max(1, permissionReviewPageRows(terminalRows) - (sourceLabel3 ? 1 : 0));
43441
+ const pageRows = Math.max(1, permissionReviewPageRows(terminalRows));
43415
43442
  const single2 = toolCalls.length === 1;
43416
43443
  const compact2 = !detailsOpen && summary2.compactText !== void 0;
43417
43444
  const source = detailsOpen ? summary2.expandedText !== void 0 ? readableBody(summary2.expandedText, single2) : review : summary2.compactText ?? readableBody(summary2.text, single2);
@@ -43425,16 +43452,27 @@ function PermissionOverlay({
43425
43452
  const last = Math.min(rows.length, offset + pageRows);
43426
43453
  const destructive = toolCalls.some((call) => call.isDestructive);
43427
43454
  const sharing = screenConsent !== void 0;
43428
- const choices2 = permissionChoices(toolCalls, {
43455
+ const answerOptions = {
43429
43456
  batchOnly,
43430
43457
  screenConsent: sharing,
43431
43458
  withheld: withheld.length > 0,
43459
+ endsTurn,
43432
43460
  ...mode ? { mode } : {},
43433
43461
  ...commandArguments ? { commandArguments } : {},
43434
43462
  ...rememberWhere ? { rememberWhere } : {}
43435
- });
43463
+ };
43464
+ const answers = permissionAnswers(toolCalls, answerOptions);
43465
+ const choices2 = answers.map((answer) => answer.label);
43466
+ const onRefusal = answers[choice2]?.kind === "reject";
43467
+ const offersEdits = answers.some((answer) => answer.kind === "approve-edits");
43468
+ const typing = reason !== void 0;
43436
43469
  const escalationNotes = permissionEscalationNotes(toolCalls);
43437
43470
  const sharingNotes = sharing ? screenConsentNotes(screenConsent.provider) : [];
43471
+ const titleText = detailsOpen ? scriptView ? "Workflow script" : "Exact prepared input" : sharing ? "Share your screen" : terminalDisplayText(permissionTitle(toolCalls));
43472
+ const destructiveText = destructive ? toolCalls.every((call) => call.name === "write") ? summary2.text.includes("New file") ? " \xB7 new file" : " \xB7 may overwrite" : " \xB7 destructive" : "";
43473
+ const countText = count2 ? `${count2.position} of ${count2.total}` : void 0;
43474
+ const countFits = countText !== void 0 && stringWidth(`${titleText}${destructiveText}${from ? ` \xB7 ${terminalDisplayText(from)}` : ""}`) + 1 + stringWidth(countText) <= boxedHintWidth(columns);
43475
+ const shownCount = countFits ? countText : void 0;
43438
43476
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
43439
43477
  Box_default,
43440
43478
  {
@@ -43444,16 +43482,14 @@ function PermissionOverlay({
43444
43482
  paddingX: 1,
43445
43483
  marginTop: 1,
43446
43484
  children: [
43447
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Text, { children: [
43448
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.status.warn, bold: true, children: detailsOpen ? scriptView ? "Workflow script" : "Exact prepared input" : sharing ? "Share your screen" : terminalDisplayText(permissionTitle(toolCalls)) }),
43449
- queuedCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Text, { color: theme.text.muted, children: [
43450
- " \xB7 ",
43451
- queuedCount,
43452
- " more awaiting approval"
43453
- ] }) : null,
43454
- destructive ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.status.error, children: toolCalls.every((call) => call.name === "write") ? summary2.text.includes("New file") ? " \xB7 new file" : " \xB7 may overwrite" : " \xB7 destructive" }) : null
43485
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "row", children: [
43486
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Box_default, { flexShrink: 1, flexGrow: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Text, { wrap: "truncate-end", children: [
43487
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.status.warn, bold: true, children: titleText }),
43488
+ destructive ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.status.error, children: destructiveText }) : null,
43489
+ from ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.muted, children: ` \xB7 ${terminalDisplayText(from)}` }) : null
43490
+ ] }) }),
43491
+ shownCount ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Box_default, { flexShrink: 0, marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.muted, children: shownCount }) }) : null
43455
43492
  ] }),
43456
- sourceLabel3 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.secondary, wrap: "truncate-end", children: terminalDisplayText(sourceLabel3) }) : null,
43457
43493
  sharingNotes.map((note) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.primary, children: terminalDisplayText(note) }, note)),
43458
43494
  escalationNotes.map((note) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.status.error, children: terminalDisplayText(note) }, note)),
43459
43495
  withheld.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.muted, children: terminalDisplayText(withheldNotice(withheld, toolCalls.length)) }) : null,
@@ -43468,7 +43504,16 @@ function PermissionOverlay({
43468
43504
  rows.length,
43469
43505
  " \xB7 PgUp/PgDn page \xB7 Home/End"
43470
43506
  ] }) : null,
43471
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", paddingTop: 1, children: [
43507
+ typing ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", paddingTop: 1, children: [
43508
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.primary, bold: true, children: "Tell Namzu what to do differently" }),
43509
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "row", children: [
43510
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Box_default, { flexShrink: 0, width: 2, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.accent.user, children: "\u276F " }) }),
43511
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Box_default, { flexGrow: 1, flexShrink: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Text, { color: theme.text.primary, wrap: "wrap", children: [
43512
+ terminalDisplayText(reason),
43513
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.accent.user, children: "\u258C" })
43514
+ ] }) })
43515
+ ] })
43516
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", paddingTop: 1, children: [
43472
43517
  !compact2 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.primary, bold: true, children: terminalDisplayText(
43473
43518
  sharing ? "Let Namzu see your screen for the rest of this conversation?" : permissionQuestion(toolCalls)
43474
43519
  ) }) : null,
@@ -43482,10 +43527,14 @@ function PermissionOverlay({
43482
43527
  })
43483
43528
  ] }),
43484
43529
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Box_default, { flexDirection: "column", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { color: theme.text.muted, children: fitHints(
43485
- [
43530
+ typing ? [
43531
+ { text: "enter send", rank: 5 },
43532
+ { text: "esc back", rank: 5 },
43533
+ { text: "ctrl+c stop", rank: 4 }
43534
+ ] : [
43486
43535
  // The arrow keys are the first of the answer keys to go: enter and y / n
43487
43536
  // still answer, and the list shows which row is selected.
43488
- { text: "\u2191\u2193 select", rank: 4 },
43537
+ { text: "\u2191\u2193 select", rank: 3 },
43489
43538
  { text: "enter confirm", rank: 5 },
43490
43539
  {
43491
43540
  text: "y / n answer",
@@ -43495,6 +43544,7 @@ function PermissionOverlay({
43495
43544
  rank: scriptView ? 4 : 5
43496
43545
  },
43497
43546
  { text: "esc cancel", rank: 5 },
43547
+ ...offersEdits ? [{ text: "shift+tab accept edits", rank: 3 }] : [],
43498
43548
  {
43499
43549
  text: "ctrl+c stop",
43500
43550
  rank: scriptView ? 3 : 4
@@ -43505,7 +43555,11 @@ function PermissionOverlay({
43505
43555
  // The only way to the exact input: it outranks the stop hint,
43506
43556
  // whose key works without being shown.
43507
43557
  rank: 5
43508
- }
43558
+ },
43559
+ // On the No row the way to give a reason is the one hint that cannot be
43560
+ // guessed, so it outlasts the arrows and the stop key. Last of its rank,
43561
+ // it gives way first, and says less before it does.
43562
+ ...onRefusal ? [{ text: "tab say why", short: "tab why", rank: 5 }] : []
43509
43563
  ],
43510
43564
  boxedHintWidth(columns)
43511
43565
  ) }) })
@@ -48392,6 +48446,258 @@ function isRepeatedNotice(last, candidate) {
48392
48446
  }
48393
48447
  __name(isRepeatedNotice, "isRepeatedNotice");
48394
48448
 
48449
+ // src/tui/per-call-review.ts
48450
+ var REASON_MAX_CHARS = 500;
48451
+ function cleanReason(text) {
48452
+ let out = "";
48453
+ let gap = false;
48454
+ for (const ch of text) {
48455
+ const code = ch.codePointAt(0);
48456
+ const control = code <= 31 || code >= 127 && code <= 159;
48457
+ if (control || ch === " ") {
48458
+ gap = out.length > 0;
48459
+ continue;
48460
+ }
48461
+ if (gap) out += " ";
48462
+ gap = false;
48463
+ out += ch;
48464
+ }
48465
+ return Array.from(out).slice(0, REASON_MAX_CHARS).join("");
48466
+ }
48467
+ __name(cleanReason, "cleanReason");
48468
+ function appendTypedReason(current, typed) {
48469
+ let out = current;
48470
+ let count2 = Array.from(current).length;
48471
+ for (const ch of typed) {
48472
+ if (count2 >= REASON_MAX_CHARS) break;
48473
+ const code = ch.codePointAt(0);
48474
+ const control = code <= 31 || code >= 127 && code <= 159;
48475
+ if (control && ch !== "\n" && ch !== " ") continue;
48476
+ out += control ? " " : ch;
48477
+ count2 += 1;
48478
+ }
48479
+ return out;
48480
+ }
48481
+ __name(appendTypedReason, "appendTypedReason");
48482
+ function plainNo(endsTurn) {
48483
+ return { kind: "reject", declined: {}, ...endsTurn ? { endTurn: true } : {} };
48484
+ }
48485
+ __name(plainNo, "plainNo");
48486
+ function noWithReason(reason) {
48487
+ const note = cleanReason(reason);
48488
+ if (note === "") return void 0;
48489
+ return {
48490
+ kind: "reject",
48491
+ feedback: `The user declined this and said: ${note}`,
48492
+ declined: { note }
48493
+ };
48494
+ }
48495
+ __name(noWithReason, "noWithReason");
48496
+ function notShownInFull(call) {
48497
+ const review = buildPermissionReview([
48498
+ { id: call.id, name: call.name, input: call.input, isDestructive: false }
48499
+ ]);
48500
+ return !review.ok || review.withheld.length > 0;
48501
+ }
48502
+ __name(notShownInFull, "notShownInFull");
48503
+ function createTerminalPerCallReview(host) {
48504
+ const listeners = /* @__PURE__ */ new Set();
48505
+ const held = /* @__PURE__ */ new Map();
48506
+ const modeCovers = /* @__PURE__ */ __name((call) => {
48507
+ if (mustAskPerson(call)) return false;
48508
+ switch (host.mode()) {
48509
+ case "bypass":
48510
+ return true;
48511
+ case "accept-edits":
48512
+ return ACCEPT_EDITS_TOOLS.has(call.name) && call.isDestructive !== true;
48513
+ default:
48514
+ return false;
48515
+ }
48516
+ }, "modeCovers");
48517
+ return {
48518
+ config: {
48519
+ onRulesChanged: /* @__PURE__ */ __name((listener) => {
48520
+ listeners.add(listener);
48521
+ return () => {
48522
+ listeners.delete(listener);
48523
+ };
48524
+ }, "onRulesChanged"),
48525
+ covers: /* @__PURE__ */ __name((call) => modeCovers(call), "covers"),
48526
+ // A call marked as not shown in full stays open. A call the screen has
48527
+ // not reached yet (queued behind another question) is judged by its own
48528
+ // input, the way the screen will judge it when it gets there.
48529
+ neverCover: /* @__PURE__ */ __name((call) => held.get(call.id) ?? notShownInFull(call), "neverCover")
48530
+ },
48531
+ rulesChanged: /* @__PURE__ */ __name(() => {
48532
+ for (const listener of [...listeners]) listener();
48533
+ }, "rulesChanged"),
48534
+ hold: /* @__PURE__ */ __name((callId, notShownInFull2) => {
48535
+ held.set(callId, notShownInFull2);
48536
+ }, "hold"),
48537
+ release: /* @__PURE__ */ __name((callId) => {
48538
+ held.set(callId, true);
48539
+ }, "release"),
48540
+ modeCovers
48541
+ };
48542
+ }
48543
+ __name(createTerminalPerCallReview, "createTerminalPerCallReview");
48544
+
48545
+ // src/tui/permission-asks.ts
48546
+ var CLOSED_QUESTION = {
48547
+ kind: "reject",
48548
+ feedback: "The question was closed."
48549
+ };
48550
+ var AskQueue = class {
48551
+ static {
48552
+ __name(this, "AskQueue");
48553
+ }
48554
+ #shown = null;
48555
+ #waiting = [];
48556
+ #settled = 0;
48557
+ #onShow;
48558
+ #onChange;
48559
+ /**
48560
+ * `onShow` is told which question is on screen whenever that changes (`null`:
48561
+ * none); `onChange` after any change at all, the count behind the title included.
48562
+ */
48563
+ constructor(onShow, onChange = () => {
48564
+ }) {
48565
+ this.#onShow = onShow;
48566
+ this.#onChange = onChange;
48567
+ }
48568
+ /** The question on screen. */
48569
+ get shown() {
48570
+ return this.#shown?.value ?? null;
48571
+ }
48572
+ /** Questions open now: the one on screen and those waiting. */
48573
+ get open() {
48574
+ return (this.#shown ? 1 : 0) + this.#waiting.length;
48575
+ }
48576
+ /** Questions waiting behind the one on screen. */
48577
+ get waiting() {
48578
+ return this.#waiting.length;
48579
+ }
48580
+ /**
48581
+ * The "k of N" for the question on screen, or none while the set holds fewer
48582
+ * than two questions (those settled since it began and those open now).
48583
+ */
48584
+ count() {
48585
+ if (this.open === 0) return void 0;
48586
+ const total = this.#settled + this.open;
48587
+ if (total < 2) return void 0;
48588
+ return { position: this.#settled + 1, total };
48589
+ }
48590
+ /** Every open question, the one on screen first. */
48591
+ values() {
48592
+ return [...this.#shown ? [this.#shown.value] : [], ...this.#waiting.map((a) => a.value)];
48593
+ }
48594
+ /**
48595
+ * Put a question to the person. The promise settles with the answer, or with
48596
+ * {@link CLOSED_QUESTION} when `signal` aborts first.
48597
+ */
48598
+ enqueue(value, options = {}) {
48599
+ const signal = options.signal;
48600
+ if (signal?.aborted) return Promise.resolve(CLOSED_QUESTION);
48601
+ return new Promise((resolve9) => {
48602
+ const onAbort = /* @__PURE__ */ __name(() => this.#close(ask, CLOSED_QUESTION), "onAbort");
48603
+ const ask = {
48604
+ value,
48605
+ resolve: resolve9,
48606
+ background: options.background === true,
48607
+ detach: /* @__PURE__ */ __name(() => signal?.removeEventListener("abort", onAbort), "detach")
48608
+ };
48609
+ signal?.addEventListener("abort", onAbort, { once: true });
48610
+ if (this.#shown === null) {
48611
+ this.#shown = ask;
48612
+ this.#onShow(value);
48613
+ this.#onChange();
48614
+ return;
48615
+ }
48616
+ if (ask.background) {
48617
+ this.#waiting.push(ask);
48618
+ } else {
48619
+ const firstBackground = this.#waiting.findIndex((other) => other.background);
48620
+ if (firstBackground < 0) this.#waiting.push(ask);
48621
+ else this.#waiting.splice(firstBackground, 0, ask);
48622
+ }
48623
+ this.#onChange();
48624
+ });
48625
+ }
48626
+ /** Answer the question on screen. Returns whether there was one. */
48627
+ answer(decision) {
48628
+ const ask = this.#shown;
48629
+ if (!ask) return false;
48630
+ this.#close(ask, decision);
48631
+ return true;
48632
+ }
48633
+ /**
48634
+ * Close every open question the rule decides, shown or waiting, with the
48635
+ * decision it returns. A question the rule leaves (`undefined`) stays open.
48636
+ * Returns how many were closed.
48637
+ */
48638
+ settleWhere(decide) {
48639
+ const decided = [];
48640
+ if (this.#shown) {
48641
+ const decision = decide(this.#shown.value, true);
48642
+ if (decision) decided.push([this.#shown, decision]);
48643
+ }
48644
+ for (const ask of this.#waiting) {
48645
+ const decision = decide(ask.value, false);
48646
+ if (decision) decided.push([ask, decision]);
48647
+ }
48648
+ if (decided.length === 0) return 0;
48649
+ const closing = new Set(decided.map(([ask]) => ask));
48650
+ const shownClosing = this.#shown !== null && closing.has(this.#shown);
48651
+ this.#waiting = this.#waiting.filter((ask) => !closing.has(ask));
48652
+ this.#settled += decided.length;
48653
+ if (shownClosing) {
48654
+ this.#shown = this.#waiting.shift() ?? null;
48655
+ this.#onShow(this.#shown?.value ?? null);
48656
+ }
48657
+ this.#restartCount();
48658
+ this.#onChange();
48659
+ for (const [ask, decision] of decided) {
48660
+ ask.detach();
48661
+ ask.resolve(decision);
48662
+ }
48663
+ return decided.length;
48664
+ }
48665
+ /** Answer every open question the same way and start the count over. */
48666
+ closeAll(decision) {
48667
+ const all = [...this.#shown ? [this.#shown] : [], ...this.#waiting];
48668
+ this.#shown = null;
48669
+ this.#waiting = [];
48670
+ this.#settled = 0;
48671
+ if (all.length === 0) return;
48672
+ this.#onShow(null);
48673
+ this.#onChange();
48674
+ for (const ask of all) {
48675
+ ask.detach();
48676
+ ask.resolve(decision);
48677
+ }
48678
+ }
48679
+ #close(ask, decision) {
48680
+ if (this.#shown === ask) {
48681
+ this.#settled += 1;
48682
+ this.#shown = this.#waiting.shift() ?? null;
48683
+ this.#restartCount();
48684
+ this.#onShow(this.#shown?.value ?? null);
48685
+ } else {
48686
+ const index = this.#waiting.indexOf(ask);
48687
+ if (index < 0) return;
48688
+ this.#waiting.splice(index, 1);
48689
+ this.#settled += 1;
48690
+ this.#restartCount();
48691
+ }
48692
+ this.#onChange();
48693
+ ask.detach();
48694
+ ask.resolve(decision);
48695
+ }
48696
+ #restartCount() {
48697
+ if (this.open === 0) this.#settled = 0;
48698
+ }
48699
+ };
48700
+
48395
48701
  // src/tui/plugin-view.ts
48396
48702
  import { join as join4 } from "node:path";
48397
48703
  function pluginOption(plugin) {
@@ -48458,272 +48764,891 @@ function selectPrimaryProvider(previous, selection) {
48458
48764
  }
48459
48765
  __name(selectPrimaryProvider, "selectPrimaryProvider");
48460
48766
 
48461
- // src/tui/schedule/host-commands.ts
48462
- import { isAbsolute, relative, resolve as resolve3 } from "node:path";
48463
-
48464
- // src/tui/schedule/loop-host.ts
48465
- import { randomBytes as randomBytes2 } from "node:crypto";
48466
- import { readFileSync as readFileSync5 } from "node:fs";
48467
- var MAX_LOOPS = 20;
48468
- var LOOP_LIFETIME_MS = 7 * 24 * 60 * 60 * 1e3;
48469
- function loopSpec(interval, now) {
48470
- const text = interval.trim();
48471
- if (/^\d+\s*[a-z]+$/i.test(text))
48472
- return parseScheduleSpec(`every ${text}`, { now, tz: hostTimeZone() });
48473
- return parseScheduleSpec(text, { now, tz: hostTimeZone() });
48474
- }
48475
- __name(loopSpec, "loopSpec");
48476
- var SessionLoopScheduler = class {
48477
- static {
48478
- __name(this, "SessionLoopScheduler");
48479
- }
48480
- #deps;
48481
- #file;
48482
- #loops = [];
48483
- constructor(deps) {
48484
- this.#deps = deps;
48485
- }
48486
- #now() {
48487
- return (this.#deps.now ?? Date.now)();
48488
- }
48489
- /** Follow the conversation on screen: load its loops when it changes. */
48490
- #sync() {
48491
- const file = this.#deps.file();
48492
- if (file === this.#file) return;
48493
- const carried = this.#file === void 0 ? this.#loops : [];
48494
- this.#file = file;
48495
- this.#loops = [];
48496
- if (!file) return;
48497
- try {
48498
- const parsed = JSON.parse(readFileSync5(file, "utf8"));
48499
- if (parsed.kind === "session-loops" && Array.isArray(parsed.loops)) {
48500
- const now = this.#now();
48501
- this.#loops = parsed.loops.filter(
48502
- (l) => (!l.expiresAt || Date.parse(l.expiresAt) > now) && // A one-shot whose time passed is not restored.
48503
- !(l.spec.kind === "at" && Date.parse(l.spec.at) <= now)
48504
- );
48505
- }
48506
- } catch {
48507
- }
48508
- if (carried.length > 0) {
48509
- this.#loops = [...this.#loops, ...carried].slice(0, MAX_LOOPS);
48510
- this.#save();
48511
- }
48512
- }
48513
- #save() {
48514
- if (!this.#file) return;
48515
- try {
48516
- writeJsonAtomic(this.#file, {
48517
- v: 1,
48518
- kind: "session-loops",
48519
- loops: this.#loops
48520
- });
48521
- } catch {
48522
- }
48767
+ // src/tui/conversation-evidence-view.ts
48768
+ function conversationEvidenceView(toolName, output) {
48769
+ if (toolName !== "search_conversation" && toolName !== "read_conversation") return void 0;
48770
+ let value;
48771
+ try {
48772
+ value = JSON.parse(output);
48773
+ } catch {
48774
+ return void 0;
48523
48775
  }
48524
- async create(request) {
48525
- this.#sync();
48526
- if (this.#loops.length >= MAX_LOOPS)
48527
- throw new Error(`A conversation holds at most ${MAX_LOOPS} loops.`);
48528
- const now = new Date(this.#now());
48529
- const spec = loopSpec(request.interval, now);
48530
- const loop = {
48531
- id: randomBytes2(3).toString("hex"),
48532
- schedule: describeSchedule(spec, { tz: hostTimeZone() }),
48533
- prompt: request.prompt,
48534
- createdAt: now.toISOString(),
48535
- expiresAt: new Date(now.getTime() + LOOP_LIFETIME_MS).toISOString(),
48536
- createdBy: request.createdBy,
48537
- spec
48538
- };
48539
- this.#loops.push(loop);
48540
- this.#save();
48541
- return loop;
48776
+ if (!record(value)) return void 0;
48777
+ const rows = toolName === "search_conversation" ? searchRows(value) : readRows(value);
48778
+ if (!rows) return void 0;
48779
+ return { content: rows.join("\n"), detail: JSON.stringify(value, null, 2).split("\n") };
48780
+ }
48781
+ __name(conversationEvidenceView, "conversationEvidenceView");
48782
+ function record(value) {
48783
+ return value !== null && typeof value === "object" && !Array.isArray(value);
48784
+ }
48785
+ __name(record, "record");
48786
+ function count(value) {
48787
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
48788
+ }
48789
+ __name(count, "count");
48790
+ function preview2(text, limit = 96) {
48791
+ const units = Array.from(text.replace(/\s+/gu, " ").trim());
48792
+ return units.length > limit ? `${units.slice(0, limit - 1).join("")}\u2026` : units.join("");
48793
+ }
48794
+ __name(preview2, "preview");
48795
+ function sourceLabel2(value) {
48796
+ switch (value.recordKind) {
48797
+ case "assistant_message":
48798
+ return "Assistant message";
48799
+ case "user_message":
48800
+ return "User message";
48801
+ case "system_message":
48802
+ return "System message";
48803
+ case "derived_summary":
48804
+ return "Derived summary";
48805
+ case "tool_result":
48806
+ return `Tool result${typeof value.toolName === "string" ? ` (${preview2(value.toolName, 48)})` : ""}`;
48807
+ default:
48808
+ return "Source unknown";
48542
48809
  }
48543
- list() {
48544
- this.#sync();
48545
- return this.#loops;
48810
+ }
48811
+ __name(sourceLabel2, "sourceLabel");
48812
+ function searchRows(value) {
48813
+ if (!Array.isArray(value.matches) || !value.matches.every((match) => record(match) && typeof match.text === "string") || typeof value.incomplete !== "boolean" || !count(value.unavailable))
48814
+ return void 0;
48815
+ const rows = [
48816
+ `Conversation search \xB7 ${plural(value.matches.length, "match", "matches")} on this page`
48817
+ ];
48818
+ rows.push(
48819
+ value.incomplete || value.nextCursor ? `Search not finished${value.nextCursor ? " \xB7 more to scan" : ""} \xB7 a missing result may not have been reached yet` : "Search finished"
48820
+ );
48821
+ if (value.unavailable > 0) rows.push(`${plural(value.unavailable, "record")} unavailable`);
48822
+ for (const match of value.matches.slice(0, 3)) {
48823
+ rows.push(
48824
+ `${sourceLabel2(match)}${match.retained === "preview" ? " \xB7 preview flagged" : ""}${match.isError === true ? " \xB7 original reported error" : ""}: ${preview2(match.text)}`
48825
+ );
48546
48826
  }
48547
- async delete(id) {
48548
- this.#sync();
48549
- const before = this.#loops.length;
48550
- this.#loops = id === "all" ? [] : this.#loops.filter((l) => l.id !== id);
48551
- this.#save();
48552
- return before - this.#loops.length;
48827
+ if (value.matches.length > 3)
48828
+ rows.push(`+${plural(value.matches.length - 3, "more match", "more matches")} in details`);
48829
+ return rows;
48830
+ }
48831
+ __name(searchRows, "searchRows");
48832
+ function readRows(value) {
48833
+ if (typeof value.text !== "string" || typeof value.complete !== "boolean" || typeof value.retainedPreview !== "boolean" || !count(value.offset))
48834
+ return void 0;
48835
+ const rows = [`Conversation read \xB7 ${sourceLabel2(value)}`];
48836
+ if (value.retainedPreview) rows.push("Preview flagged \xB7 original may be incomplete");
48837
+ if (!value.complete) {
48838
+ rows.push(
48839
+ value.nextCursor ? value.text.length === 0 ? "Locating retained text \xB7 continue scan" : "Partial page \xB7 more retained text available" : "Read incomplete \xB7 no continuation supplied"
48840
+ );
48841
+ } else {
48842
+ rows.push(
48843
+ value.offset > 0 ? "Last page \xB7 earlier text is not on this page" : "Selected retained part returned"
48844
+ );
48553
48845
  }
48554
- /** Fire what is due, when idle. Called on a timer and when a turn ends. */
48555
- tick() {
48556
- this.#sync();
48557
- const now = this.#now();
48558
- let changed = false;
48559
- const kept = [];
48560
- let fired = false;
48561
- for (const loop of this.#loops) {
48562
- if (loop.expiresAt && Date.parse(loop.expiresAt) <= now) {
48563
- changed = true;
48564
- continue;
48565
- }
48566
- const last = Date.parse(loop.lastFiredAt ?? loop.createdAt);
48567
- const due = nextFireTime(loop.spec, new Date(last));
48568
- const isDue = loop.pending || due !== null && due.getTime() <= now;
48569
- if (!isDue) {
48570
- kept.push(loop);
48571
- continue;
48572
- }
48573
- if (fired || !this.#deps.isIdle()) {
48574
- if (!loop.pending) changed = true;
48575
- kept.push({ ...loop, pending: true });
48576
- continue;
48577
- }
48578
- fired = true;
48579
- changed = true;
48580
- const done = loop.spec.kind === "at";
48581
- const { pending: _pending, ...rest } = loop;
48582
- if (!done) kept.push({ ...rest, lastFiredAt: new Date(now).toISOString() });
48583
- this.#deps.fire(loop);
48584
- }
48585
- this.#loops = kept;
48586
- if (changed) this.#save();
48846
+ if (value.recordKind === "tool_result") {
48847
+ rows.push(
48848
+ value.isError === true ? "Original tool reported an error" : value.isError === false ? "Original tool reported no error" : "Original tool status unknown"
48849
+ );
48587
48850
  }
48588
- };
48589
- function describeLoops(loops) {
48590
- if (loops.length === 0) return "No loops in this conversation. /loop 5m <prompt> adds one.";
48591
- return loops.map(
48592
- (l) => `\u21BB ${l.id} ${l.schedule}${l.createdBy === "model" ? " (created by the model)" : ""}${l.lastFiredAt ? ` last ${new Date(l.lastFiredAt).toLocaleTimeString()}` : ""}
48593
- ${l.prompt.replace(/\s+/g, " ").slice(0, 100)}`
48594
- ).join("\n");
48851
+ if (value.text.length > 0) rows.push(`Excerpt: ${preview2(value.text, 160)}`);
48852
+ return rows;
48595
48853
  }
48596
- __name(describeLoops, "describeLoops");
48854
+ __name(readRows, "readRows");
48597
48855
 
48598
- // src/tui/schedule/host-commands.ts
48599
- var USAGE = [
48600
- "/schedule jobs, and what needs you",
48601
- "/schedule confirm <job> confirm a job created without a terminal, or held after an edit",
48602
- "/schedule pause|resume <job>",
48603
- "/schedule run <job> run it now through the scheduler",
48604
- "/schedule remove <job>",
48605
- '/schedule add <name> "<when>" <read-only|edit-in-folder> <prompt\u2026>',
48606
- "A run waiting for approval: /resume its conversation (Scheduled: <job> \xB7 <time>) in its folder."
48607
- ].join("\n");
48608
- async function schedulerLine(home) {
48609
- const paths = schedulePaths(home);
48610
- const endpoint = readEndpoint(paths.endpoint);
48611
- if (endpoint && await callEndpoint(endpoint, "status", {}, 500)) return "Scheduler: running.";
48612
- let installed = false;
48856
+ // src/tui/model-catalogue-view.ts
48857
+ function modelCatalogueView(output) {
48858
+ let value;
48613
48859
  try {
48614
- installed = readManifest(paths) !== void 0;
48860
+ value = JSON.parse(output);
48615
48861
  } catch {
48862
+ return void 0;
48616
48863
  }
48617
- return installed ? "Scheduler: installed but not answering \u2014 namzu schedule status." : "Scheduler: not installed \u2014 namzu schedule install. Jobs do not run until it is.";
48864
+ if (!record2(value) || !Array.isArray(value.models) || !Number.isSafeInteger(value.omitted) || value.omitted < 0)
48865
+ return void 0;
48866
+ const models = value.models;
48867
+ if (!models.every(
48868
+ (model) => record2(model) && typeof model.provider === "string" && (typeof model.id === "string" && typeof model.name === "string" || model.status === "catalogue unavailable")
48869
+ ))
48870
+ return void 0;
48871
+ const rows = ["Available models"];
48872
+ if (models.length === 0) rows.push("No matching models.");
48873
+ for (const model of models.slice(0, 5)) {
48874
+ if (model.status === "catalogue unavailable") {
48875
+ rows.push(`${model.provider} \xB7 catalogue unavailable`);
48876
+ continue;
48877
+ }
48878
+ rows.push(`${model.name} \xB7 ${model.provider}`);
48879
+ rows.push(` ${model.id}`);
48880
+ const facts = [];
48881
+ if (typeof model.contextWindow === "number" && Number.isSafeInteger(model.contextWindow) && model.contextWindow > 0)
48882
+ facts.push(
48883
+ `Context ${new Intl.NumberFormat("en", { notation: "compact", maximumFractionDigits: 1 }).format(model.contextWindow)}`
48884
+ );
48885
+ const effort = model.reasoningEffortLevels ?? model.effortLevels;
48886
+ if (Array.isArray(effort) && effort.every((item) => typeof item === "string"))
48887
+ facts.push(effort.length ? `Effort ${effort.join(" \xB7 ")}` : "Effort not supported");
48888
+ facts.push(priceFact(model));
48889
+ if (facts.length) rows.push(` ${facts.join(" | ")}`);
48890
+ }
48891
+ const omitted = value.omitted + Math.max(0, models.length - 5);
48892
+ if (omitted) rows.push(`+${omitted} more \xB7 narrow the search`);
48893
+ return rows.join("\n");
48618
48894
  }
48619
- __name(schedulerLine, "schedulerLine");
48620
- function when(iso, tz) {
48621
- if (!iso) return "\u2014";
48622
- return new Intl.DateTimeFormat("en-GB", {
48623
- dateStyle: "medium",
48624
- timeStyle: "short",
48625
- timeZone: tz
48626
- }).format(new Date(iso));
48895
+ __name(modelCatalogueView, "modelCatalogueView");
48896
+ function record2(value) {
48897
+ return value !== null && typeof value === "object" && !Array.isArray(value);
48627
48898
  }
48628
- __name(when, "when");
48629
- async function listScheduleJobs(ctx) {
48630
- const paths = schedulePaths(ctx.home);
48631
- const { jobs, errors } = listJobs(paths);
48632
- const lines = [];
48633
- for (const job of jobs) {
48634
- const tz = job.schedule.kind === "cron" ? job.schedule.tz : hostTimeZone();
48635
- const state = readState(paths, job.id);
48636
- 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]" : "";
48637
- const kind = job.runKind === "script" ? " [script, 0 tokens]" : job.runKind === "script+agent" ? " [script+agent]" : "";
48638
- lines.push(
48639
- `${job.name} [${job.state}]${kind}${mark}
48640
- ${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)}` : ""}
48641
- ${job.workspace === "none" ? "Private scheduler workspace (no project)" : job.folder.canonical}`
48642
- );
48643
- if (job.delivery?.kind === "source-conversation")
48644
- lines.push(` Results return to source conversation ${job.delivery.sessionId}`);
48645
- if (state.activeRun?.status === "awaiting-approval" && state.activeRun.sessionId) {
48646
- const command = resumeCommand(job, state.activeRun.sessionId);
48647
- const verb = state.activeRun.handoff ? "when that is done, continue it" : "answer it";
48648
- lines.push(
48649
- job.folder.canonical === ctx.cwd ? ` ${verb}: /resume and pick "Scheduled: ${job.name}", or ${command}` : ` ${verb}: ${command}`
48650
- );
48899
+ __name(record2, "record");
48900
+ function priceFact(model) {
48901
+ const input = model.inputPrice;
48902
+ const output = model.outputPrice;
48903
+ if (typeof input !== "number" || typeof output !== "number") return "Price unknown";
48904
+ if (input === 0 && output === 0) return "Free";
48905
+ return `$${input}/$${output} per Mtok`;
48906
+ }
48907
+ __name(priceFact, "priceFact");
48908
+
48909
+ // src/tui/task-activity.ts
48910
+ var TASK_TOOLS = /* @__PURE__ */ new Set(["task_create", "task_update", "task_list"]);
48911
+ function isTaskTool(toolName) {
48912
+ return TASK_TOOLS.has(toolName);
48913
+ }
48914
+ __name(isTaskTool, "isTaskTool");
48915
+ function taskOperationFor(previous, next) {
48916
+ const subject = next.subject;
48917
+ if (!previous) return { kind: "added", subject };
48918
+ if (previous.status !== next.status) {
48919
+ switch (next.status) {
48920
+ case "in_progress":
48921
+ return { kind: "started", subject };
48922
+ case "completed":
48923
+ return { kind: "completed", subject };
48924
+ case "failed":
48925
+ return { kind: "failed", subject };
48926
+ case "pending":
48927
+ return { kind: "reopened", subject };
48651
48928
  }
48652
48929
  }
48653
- return visibleScheduleMessage(
48654
- [
48655
- 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"),
48656
- ...errors.length > 0 ? [
48657
- `${errors.length} job file${errors.length === 1 ? "" : "s"} could not be read; inspect or repair the files under NAMZU_HOME.`
48658
- ] : [],
48659
- await schedulerLine(ctx.home)
48660
- ].join("\n")
48661
- );
48930
+ if (previous.subject !== next.subject) return { kind: "renamed", subject };
48931
+ return null;
48662
48932
  }
48663
- __name(listScheduleJobs, "listScheduleJobs");
48664
- async function confirmInTui(ctx, job, verb) {
48665
- const say = /* @__PURE__ */ __name((message) => ctx.say(visibleScheduleMessage(message)), "say");
48666
- const paths = schedulePaths(ctx.home);
48667
- const layers = readPermissionLayers({
48668
- cwd: job.folder.canonical,
48669
- home: ctx.home,
48670
- ...job.workspace === "none" ? { includeProject: false } : {}
48671
- });
48672
- const policy = compileJobPolicy(job.permissions, {
48673
- layers,
48674
- namzuHome: paths.home,
48675
- folder: job.folder
48676
- });
48677
- if (policy.diagnostics.length > 0) {
48678
- say(`The rules do not compile: ${policy.diagnostics.join("; ")}`);
48679
- return "cancel";
48680
- }
48681
- const runKind = job.runKind ?? "agent";
48682
- if (runKind !== "agent" && runKind !== "script" && runKind !== "script+agent") {
48683
- say(`The job has an unknown run kind: ${String(runKind)}`);
48684
- return "cancel";
48685
- }
48686
- if (runKind !== "agent") {
48687
- if (!job.script) {
48688
- say(`The ${runKind} job has no script recorded.`);
48689
- return "cancel";
48690
- }
48691
- const selectedShell = installedCommandShellForDialect(job.script.shell);
48692
- if (!selectedShell) {
48693
- say(scriptShellUnavailableReason(job.script.shell));
48694
- return "cancel";
48695
- }
48696
- const scriptPolicy = compileScriptCheckPolicy(job.permissions, {
48697
- layers,
48698
- namzuHome: paths.home,
48699
- folder: job.folder
48700
- });
48701
- const checked = verifyScheduledScript(job.script.body, selectedShell.dialect, scriptPolicy);
48702
- if (!checked.ok) {
48703
- say(
48704
- `The ${runKind === "script" ? "script" : "wake-gate script"} was refused: ${checked.reason}`
48705
- );
48706
- return "cancel";
48707
- }
48933
+ __name(taskOperationFor, "taskOperationFor");
48934
+ function removeTask(tasks, id, subject) {
48935
+ const known = tasks.find((task) => task.id === id);
48936
+ if (!known) return { tasks, operation: null };
48937
+ return {
48938
+ tasks: tasks.filter((task) => task.id !== id),
48939
+ operation: { kind: "removed", subject: subject || known.subject }
48940
+ };
48941
+ }
48942
+ __name(removeTask, "removeTask");
48943
+ function upsertTask(tasks, item) {
48944
+ const index = tasks.findIndex((task) => task.id === item.id);
48945
+ return index < 0 ? [...tasks, item] : tasks.map((task, i) => i === index ? item : task);
48946
+ }
48947
+ __name(upsertTask, "upsertTask");
48948
+ var SINGLE = {
48949
+ added: "Added task",
48950
+ started: "Started",
48951
+ completed: "Completed",
48952
+ failed: "Failed",
48953
+ reopened: "Reopened",
48954
+ renamed: "Renamed task",
48955
+ removed: "Removed task"
48956
+ };
48957
+ var MANY = {
48958
+ added: "Added",
48959
+ started: "Started",
48960
+ completed: "Completed",
48961
+ failed: "Failed",
48962
+ reopened: "Reopened",
48963
+ renamed: "Renamed",
48964
+ removed: "Removed"
48965
+ };
48966
+ function countTasks(count2) {
48967
+ return `${count2} task${count2 === 1 ? "" : "s"}`;
48968
+ }
48969
+ __name(countTasks, "countTasks");
48970
+ function taskBlockHeader(operations, checklist) {
48971
+ const [first] = operations;
48972
+ if (!first) return checklist.length === 0 ? "No tasks yet" : checklistProgress(checklist);
48973
+ if (operations.length === 1)
48974
+ return `${SINGLE[first.kind]} \xB7 ${first.subject.replace(/\s+/g, " ").trim()}`;
48975
+ if (operations.every((operation) => operation.kind === first.kind)) {
48976
+ return `${MANY[first.kind]} ${countTasks(operations.length)}`;
48708
48977
  }
48709
- const scriptSection = runKind !== "agent" && job.script ? [
48710
- `${runKind === "script" ? "Script" : "Wake-gate script"} (exactly as it will run, ${job.script.shell}; shell commands checked against the scheduled-run floor and deny rules)`,
48711
- ...job.script.body.split("\n").map((line) => ` \u2502 ${line}`),
48712
- ...job.script.report === "json-v1" ? [
48713
- "Script report: JSON v1 (quiet/changed; optional scheduler state); stdout must be one JSON object line."
48714
- ] : [],
48715
- "Code passed to another interpreter is not parsed by the shell checker; review it here."
48716
- ] : [];
48717
- const now = /* @__PURE__ */ new Date();
48718
- const fullText = visibleScheduleMessage(
48719
- [
48720
- ...previewLines(job, policy, now),
48721
- ...changesBlock(changesSinceConfirmed(readHistory(paths, job.id))),
48722
- ...scriptSection,
48723
- ...runKind === "script" ? [] : [
48724
- runKind === "script+agent" ? "Prompt (used only when the wake-gate says wake: true)" : "Prompt",
48725
- ...job.prompt.split("\n").map((l) => ` \u2502 ${l}`)
48726
- ]
48978
+ return checklistProgress(checklist);
48979
+ }
48980
+ __name(taskBlockHeader, "taskBlockHeader");
48981
+ function extendable(messages, input) {
48982
+ const last = messages.at(-1);
48983
+ if (!last?.taskBlock || last.taskBlock.key !== input.key || last.pending) return void 0;
48984
+ const finalizedIndex = messages.slice(0, -1).filter((message) => !message.pending).length;
48985
+ return finalizedIndex >= input.settled ? last : void 0;
48986
+ }
48987
+ __name(extendable, "extendable");
48988
+ function applyTaskOperation(messages, input) {
48989
+ const open = extendable(messages, input);
48990
+ const operations = [
48991
+ ...open?.taskBlock?.operations ?? [],
48992
+ ...input.operation ? [input.operation] : []
48993
+ ];
48994
+ if (!open && operations.length === 0 && input.checklist.length === 0) return messages;
48995
+ const row = {
48996
+ id: open?.id ?? input.id,
48997
+ role: "tool",
48998
+ content: taskBlockHeader(operations, input.checklist),
48999
+ glyph: "\u2713",
49000
+ ...input.glyphColor ? { glyphColor: input.glyphColor } : {},
49001
+ checklist: input.checklist,
49002
+ taskBlock: { key: input.key, operations }
49003
+ };
49004
+ return open ? [...messages.slice(0, -1), row] : [...messages, row];
49005
+ }
49006
+ __name(applyTaskOperation, "applyTaskOperation");
49007
+ var CHECKLIST_STATUSES = /* @__PURE__ */ new Set([
49008
+ "pending",
49009
+ "in_progress",
49010
+ "completed",
49011
+ "failed"
49012
+ ]);
49013
+ function taskReportChecklist(rows) {
49014
+ const items = [];
49015
+ for (const [index, row] of rows.entries()) {
49016
+ const { subject, status, id } = row;
49017
+ if (typeof subject !== "string" || typeof status !== "string") return void 0;
49018
+ if (!CHECKLIST_STATUSES.has(status)) return void 0;
49019
+ items.push({
49020
+ id: typeof id === "string" ? id : String(index),
49021
+ subject,
49022
+ status
49023
+ });
49024
+ }
49025
+ return items;
49026
+ }
49027
+ __name(taskReportChecklist, "taskReportChecklist");
49028
+
49029
+ // src/tui/tool-failure-text.ts
49030
+ var WHOLE_TOOL_ERROR = /^\s*<tool_use_error>([\s\S]*)<\/tool_use_error>\s*$/i;
49031
+ var NESTED_TOOL_ERROR = /<\/?tool_use_error\b/i;
49032
+ var BAD_ARGUMENTS = /^(?:InputValidationError: |Validation failed for "|Tool "[^"]+" was called with no arguments\.)/;
49033
+ function toolFailureText(output, expanded) {
49034
+ if (output === void 0) return "Tool execution failed";
49035
+ const inner = WHOLE_TOOL_ERROR.exec(output)?.[1];
49036
+ const unwrapped = inner !== void 0 && !NESTED_TOOL_ERROR.test(inner) ? inner : output;
49037
+ const text = unwrapped.replace(/<sandbox_violations>[\s\S]*?<\/sandbox_violations>/g, "").replace(/<\/?error>/g, "").trim();
49038
+ if (!expanded && BAD_ARGUMENTS.test(text)) return "Invalid tool parameters";
49039
+ return text.startsWith("Error: ") || text.startsWith("Cancelled: ") ? text : `Error: ${text}`;
49040
+ }
49041
+ __name(toolFailureText, "toolFailureText");
49042
+ function firstLineOf(text) {
49043
+ return text.split("\n", 1)[0] ?? "";
49044
+ }
49045
+ __name(firstLineOf, "firstLineOf");
49046
+
49047
+ // src/tui/tool-end-rows.ts
49048
+ var DISPLAY_NAMES = { edit: "Update" };
49049
+ function formatToolCall(toolName, summary2, standalone = false) {
49050
+ if (standalone) return summary2;
49051
+ if (toolName.startsWith("mcp__")) {
49052
+ const label = connectorToolLabel(toolName);
49053
+ const plain = plainConnectorSummary(summary2);
49054
+ return plain.length > 0 ? `${label}(${plain})` : label;
49055
+ }
49056
+ const words = toolName.replace(/[_-]+/g, " ");
49057
+ const display = DISPLAY_NAMES[toolName.toLowerCase()] ?? (words.length > 0 ? words[0]?.toUpperCase() + words.slice(1) : words);
49058
+ return summary2.length > 0 ? `${display}(${summary2})` : display;
49059
+ }
49060
+ __name(formatToolCall, "formatToolCall");
49061
+ function failureBody(lines, folded) {
49062
+ return { stdout: [], stderr: lines, failed: true, byLine: true, ...folded ? { folded } : {} };
49063
+ }
49064
+ __name(failureBody, "failureBody");
49065
+ function foldOf(start) {
49066
+ if (start?.fold) return start.fold;
49067
+ return start?.activity === "exploration" ? { kind: "read", key: start.label } : void 0;
49068
+ }
49069
+ __name(foldOf, "foldOf");
49070
+ function failedCallRows(event, start) {
49071
+ const head = {
49072
+ role: "tool",
49073
+ content: headOf(event, start),
49074
+ glyph: "\u25CF",
49075
+ glyphColor: tokenColor("status.error")
49076
+ };
49077
+ const said = event.output ?? (event.summary.length > 0 ? event.summary : void 0);
49078
+ const full = toolFailureText(said, true).split("\n");
49079
+ if (event.plainFailure !== void 0) {
49080
+ return [
49081
+ head,
49082
+ {
49083
+ role: "tool",
49084
+ content: event.plainFailure,
49085
+ glyph: "\u23BF",
49086
+ contentColor: event.plainFailureTone === "muted" ? tokenColor("text.muted") : tokenColor("status.error"),
49087
+ ...said !== void 0 && said.trim().length > 0 ? { detail: full, meta: EXPAND_HINT, activity: "agent-result" } : {}
49088
+ }
49089
+ ];
49090
+ }
49091
+ const text = toolFailureText(said, false);
49092
+ const lines = text.split("\n");
49093
+ return [
49094
+ {
49095
+ ...head,
49096
+ detail: full,
49097
+ shell: failureBody(full, text !== full.join("\n") ? lines : void 0)
49098
+ }
49099
+ ];
49100
+ }
49101
+ __name(failedCallRows, "failedCallRows");
49102
+ function headOf(event, start) {
49103
+ return start?.label ?? formatToolCall(event.toolName, event.summary);
49104
+ }
49105
+ __name(headOf, "headOf");
49106
+ function toolEndRows(event, start, ctx) {
49107
+ const rows = /* @__PURE__ */ __name((list2) => ({ kind: "rows", rows: list2 }), "rows");
49108
+ const fold2 = foldOf(start);
49109
+ if (!event.isError && !event.declined && fold2) {
49110
+ const raw = event.output !== void 0 ? event.output.split("\n") : [...event.summary ? [event.summary] : [], ...event.detail ?? []];
49111
+ const answer = event.shell?.note;
49112
+ const output = answer !== void 0 && raw.join("").trim().toLowerCase() === "(no output)" ? [answer] : raw;
49113
+ const state = foldOp(EMPTY_GROUP, { ...fold2, hint: void 0 }, 0);
49114
+ const headline = event.headline ?? start?.label ?? headOf(event, start);
49115
+ return rows([
49116
+ {
49117
+ role: "tool",
49118
+ content: groupText(state, false),
49119
+ detail: [headline, ...output],
49120
+ glyph: " ",
49121
+ glyphColor: tokenColor("text.muted"),
49122
+ meta: EXPAND_HINT,
49123
+ activity: "exploration",
49124
+ group: state
49125
+ }
49126
+ ]);
49127
+ }
49128
+ if (event.isError && !event.declined && !event.cancelled && fold2) {
49129
+ const said = event.output ?? (event.summary.length > 0 ? event.summary : void 0);
49130
+ const state = foldOp(EMPTY_GROUP, { ...fold2, hint: void 0 }, 0);
49131
+ return rows([
49132
+ {
49133
+ role: "tool",
49134
+ content: groupText(state, false),
49135
+ detail: [start?.label ?? headOf(event, start), ...toolFailureText(said, true).split("\n")],
49136
+ glyph: " ",
49137
+ glyphColor: tokenColor("text.muted"),
49138
+ meta: EXPAND_HINT,
49139
+ activity: "exploration",
49140
+ group: state
49141
+ }
49142
+ ]);
49143
+ }
49144
+ const web = event.web ?? start?.web;
49145
+ if (web && !event.isError) {
49146
+ const activity = {
49147
+ ...web,
49148
+ ...event.web?.target ?? start?.web?.target ? { target: event.web?.target ?? start?.web?.target } : {}
49149
+ };
49150
+ const durationMs = event.durationMs ?? ctx.elapsedMs;
49151
+ const output = web.hosted ? void 0 : event.output;
49152
+ const outputLines = output !== void 0 ? output.split("\n") : void 0;
49153
+ return rows([
49154
+ {
49155
+ role: "tool",
49156
+ content: webCallTitle(activity),
49157
+ glyph: "\u25CF",
49158
+ glyphColor: tokenColor("status.ok"),
49159
+ activity: "web"
49160
+ },
49161
+ {
49162
+ role: "tool",
49163
+ content: webSettledLine(activity, {
49164
+ ...durationMs !== void 0 ? { durationMs } : {},
49165
+ ...activity.kind === "fetch" && output !== void 0 ? { bytes: Buffer.byteLength(output, "utf8") } : {}
49166
+ }),
49167
+ glyph: "\u23BF",
49168
+ ...outputLines ? { detail: outputLines } : {},
49169
+ ...outputLines && outputLines.length > 0 ? { meta: EXPAND_HINT } : {},
49170
+ activity: "web"
49171
+ }
49172
+ ]);
49173
+ }
49174
+ if (isTaskTool(event.toolName) && !event.isError) {
49175
+ if (event.toolName !== "task_list") return { kind: "none" };
49176
+ if (ctx.hasPlan) return { kind: "task-block" };
49177
+ const said = event.resultLabel ?? "";
49178
+ return rows([
49179
+ {
49180
+ role: "tool",
49181
+ content: start?.label ?? formatToolCall(event.toolName, event.summary, true),
49182
+ glyph: "\u25CF",
49183
+ glyphColor: tokenColor("status.ok")
49184
+ },
49185
+ ...said.length > 0 ? [
49186
+ {
49187
+ role: "tool",
49188
+ content: said,
49189
+ glyph: "\u23BF"
49190
+ }
49191
+ ] : []
49192
+ ]);
49193
+ }
49194
+ if (event.declined) {
49195
+ const refused = proposedBody(start?.proposed, ctx.cwd);
49196
+ return rows([
49197
+ {
49198
+ role: "tool",
49199
+ content: headOf(event, start),
49200
+ glyph: "\u25CF",
49201
+ glyphColor: tokenColor("status.error")
49202
+ },
49203
+ {
49204
+ role: "tool",
49205
+ content: declinedLine(event.declined.note),
49206
+ glyph: "\u23BF",
49207
+ ...refused ? { detail: refused.rows, diff: refused.diff } : {}
49208
+ }
49209
+ ]);
49210
+ }
49211
+ if (event.cancelled) {
49212
+ return rows([
49213
+ {
49214
+ role: "tool",
49215
+ content: headOf(event, start),
49216
+ glyph: "\u25CF",
49217
+ glyphColor: tokenColor("text.muted"),
49218
+ ...settledElapsed(event.durationMs) !== void 0 ? { meta: settledElapsed(event.durationMs) } : {}
49219
+ },
49220
+ { role: "tool", content: event.resultLabel ?? "Cancelled", glyph: "\u23BF" }
49221
+ ]);
49222
+ }
49223
+ if (!event.isError && event.toolName === WORKFLOW_TOOL_NAME && isBackgroundLaunch(event.output ?? "")) {
49224
+ return rows([
49225
+ {
49226
+ role: "tool",
49227
+ content: headOf(event, start),
49228
+ glyph: "\u25CF",
49229
+ glyphColor: tokenColor("accent.assistant")
49230
+ },
49231
+ { role: "tool", content: WORKFLOW_BACKGROUND_NOTE, glyph: "\u23BF" }
49232
+ ]);
49233
+ }
49234
+ if (event.isError && event.toolName === WORKFLOW_TOOL_NAME && event.output !== void 0) {
49235
+ const said = [`\u2718 ${firstLineOf(event.output)}`];
49236
+ return rows([
49237
+ {
49238
+ role: "tool",
49239
+ content: headOf(event, start),
49240
+ glyph: "\u25CF",
49241
+ glyphColor: tokenColor("status.error"),
49242
+ detail: said,
49243
+ shell: failureBody(said)
49244
+ }
49245
+ ]);
49246
+ }
49247
+ if (event.isError && event.toolName.toLowerCase() === "agent") {
49248
+ const text = toolFailureText(event.output, false);
49249
+ const full = toolFailureText(event.output, true).split("\n");
49250
+ const lines = text.split("\n");
49251
+ return rows([
49252
+ {
49253
+ role: "tool",
49254
+ content: headOf(event, start),
49255
+ glyph: "\u25CF",
49256
+ glyphColor: tokenColor("status.error"),
49257
+ detail: full,
49258
+ shell: failureBody(full, text !== full.join("\n") ? lines : void 0)
49259
+ }
49260
+ ]);
49261
+ }
49262
+ const catalogue = !event.isError && event.toolName === "agent_models" && event.output !== void 0 ? modelCatalogueView(event.output) : void 0;
49263
+ if (catalogue !== void 0) {
49264
+ return rows([
49265
+ {
49266
+ role: "tool",
49267
+ content: catalogue,
49268
+ glyph: "\u25CF",
49269
+ detail: event.output?.split("\n"),
49270
+ glyphColor: tokenColor("status.ok"),
49271
+ meta: EXPAND_HINT,
49272
+ activity: "catalogue"
49273
+ }
49274
+ ]);
49275
+ }
49276
+ const evidence = !event.isError && event.output !== void 0 ? conversationEvidenceView(event.toolName, event.output) : void 0;
49277
+ if (evidence !== void 0) {
49278
+ return rows([
49279
+ {
49280
+ role: "tool",
49281
+ content: evidence.content,
49282
+ glyph: "\u25CF",
49283
+ detail: evidence.detail,
49284
+ glyphColor: tokenColor("status.ok"),
49285
+ meta: EXPAND_HINT,
49286
+ activity: "evidence"
49287
+ }
49288
+ ]);
49289
+ }
49290
+ if (event.shell && start?.command !== void 0) {
49291
+ const failed = event.isError || event.shell.failed;
49292
+ const command = start.command;
49293
+ const header = command ? formatToolCall(event.toolName, shellCommandHeader(command)) : start.label;
49294
+ const full = command ? formatToolCall(event.toolName, shellCommandFull(command)) : void 0;
49295
+ const settled2 = event.isError && event.shell.stderr.length === 0 ? { ...event.shell, stdout: [], stderr: event.shell.stdout, failed: true } : { ...event.shell, failed };
49296
+ return rows([
49297
+ {
49298
+ role: "tool",
49299
+ content: header,
49300
+ glyph: "\u25CF",
49301
+ detail: [...settled2.stdout, ...settled2.stderr],
49302
+ glyphColor: failed ? tokenColor("status.error") : tokenColor("status.ok"),
49303
+ shell: full !== void 0 && full !== header ? { ...settled2, fullHeader: full } : settled2
49304
+ }
49305
+ ]);
49306
+ }
49307
+ if (event.isError) return rows(failedCallRows(event, start));
49308
+ const elapsed2 = settledElapsed(event.durationMs ?? ctx.elapsedMs);
49309
+ const list = [
49310
+ {
49311
+ role: "tool",
49312
+ content: headOf(event, start),
49313
+ glyph: "\u25CF",
49314
+ // The change to a file is drawn once, under its result.
49315
+ detail: event.diff ? void 0 : start?.detail,
49316
+ glyphColor: tokenColor("status.ok"),
49317
+ ...elapsed2 !== void 0 ? { meta: elapsed2 } : {}
49318
+ }
49319
+ ];
49320
+ if (!event.hidden && (event.summary.length > 0 || (event.detail?.length ?? 0) > 0)) {
49321
+ list.push({
49322
+ role: "tool",
49323
+ content: event.diff?.summary ? spansText(event.diff.summary) : event.summary,
49324
+ glyph: "\u23BF",
49325
+ detail: event.detail,
49326
+ ...event.diff ? { diff: event.diff } : {}
49327
+ });
49328
+ }
49329
+ return rows(list);
49330
+ }
49331
+ __name(toolEndRows, "toolEndRows");
49332
+
49333
+ // src/tui/queued-calls.ts
49334
+ function queuedToolRow(call, turnId, presenter, cwd2, now) {
49335
+ const event = toAgentEvent(
49336
+ {
49337
+ type: "tool_executing",
49338
+ ...turnId ? { turnId } : {},
49339
+ toolUseId: call.id,
49340
+ toolName: call.name,
49341
+ input: call.input
49342
+ },
49343
+ presenter,
49344
+ void 0,
49345
+ cwd2
49346
+ );
49347
+ if (event?.kind !== "tool-start") return void 0;
49348
+ return {
49349
+ id: event.toolUseId,
49350
+ ...event.turnId ? { turnId: event.turnId } : {},
49351
+ toolName: event.toolName,
49352
+ ...event.activity ? { activity: event.activity } : {},
49353
+ label: event.web ? webCallTitle(event.web) : formatToolCall(event.toolName, event.summary, event.standalone),
49354
+ startedAt: now,
49355
+ queued: true,
49356
+ detail: event.detail,
49357
+ ...event.command ? { command: event.command } : {},
49358
+ ...event.web ? { web: event.web } : {}
49359
+ };
49360
+ }
49361
+ __name(queuedToolRow, "queuedToolRow");
49362
+ function withQueuedRow(rows, row) {
49363
+ return rows.some((other) => other.id === row.id && other.turnId === row.turnId) ? rows : [...rows, row];
49364
+ }
49365
+ __name(withQueuedRow, "withQueuedRow");
49366
+ function withoutQueuedRow(rows, callId) {
49367
+ return rows.filter((row) => !(row.id === callId && row.queued === true));
49368
+ }
49369
+ __name(withoutQueuedRow, "withoutQueuedRow");
49370
+ function withStartedRow(rows, callId, now) {
49371
+ return rows.map((row) => {
49372
+ if (row.id !== callId || row.queued !== true) return row;
49373
+ const { queued: _queued, ...running } = row;
49374
+ return { ...running, startedAt: now };
49375
+ });
49376
+ }
49377
+ __name(withStartedRow, "withStartedRow");
49378
+ function withTakenOverRow(rows, started) {
49379
+ const at = rows.findIndex(
49380
+ (row) => row.id === started.id && (started.turnId === void 0 || row.turnId === void 0 || row.turnId === started.turnId)
49381
+ );
49382
+ return at < 0 ? [...rows, started] : [...rows.slice(0, at), started, ...rows.slice(at + 1)];
49383
+ }
49384
+ __name(withTakenOverRow, "withTakenOverRow");
49385
+
49386
+ // src/tui/schedule/host-commands.ts
49387
+ import { isAbsolute, relative, resolve as resolve3 } from "node:path";
49388
+
49389
+ // src/tui/schedule/loop-host.ts
49390
+ import { randomBytes as randomBytes2 } from "node:crypto";
49391
+ import { readFileSync as readFileSync5 } from "node:fs";
49392
+ var MAX_LOOPS = 20;
49393
+ var LOOP_LIFETIME_MS = 7 * 24 * 60 * 60 * 1e3;
49394
+ function loopSpec(interval, now) {
49395
+ const text = interval.trim();
49396
+ if (/^\d+\s*[a-z]+$/i.test(text))
49397
+ return parseScheduleSpec(`every ${text}`, { now, tz: hostTimeZone() });
49398
+ return parseScheduleSpec(text, { now, tz: hostTimeZone() });
49399
+ }
49400
+ __name(loopSpec, "loopSpec");
49401
+ var SessionLoopScheduler = class {
49402
+ static {
49403
+ __name(this, "SessionLoopScheduler");
49404
+ }
49405
+ #deps;
49406
+ #file;
49407
+ #loops = [];
49408
+ constructor(deps) {
49409
+ this.#deps = deps;
49410
+ }
49411
+ #now() {
49412
+ return (this.#deps.now ?? Date.now)();
49413
+ }
49414
+ /** Follow the conversation on screen: load its loops when it changes. */
49415
+ #sync() {
49416
+ const file = this.#deps.file();
49417
+ if (file === this.#file) return;
49418
+ const carried = this.#file === void 0 ? this.#loops : [];
49419
+ this.#file = file;
49420
+ this.#loops = [];
49421
+ if (!file) return;
49422
+ try {
49423
+ const parsed = JSON.parse(readFileSync5(file, "utf8"));
49424
+ if (parsed.kind === "session-loops" && Array.isArray(parsed.loops)) {
49425
+ const now = this.#now();
49426
+ this.#loops = parsed.loops.filter(
49427
+ (l) => (!l.expiresAt || Date.parse(l.expiresAt) > now) && // A one-shot whose time passed is not restored.
49428
+ !(l.spec.kind === "at" && Date.parse(l.spec.at) <= now)
49429
+ );
49430
+ }
49431
+ } catch {
49432
+ }
49433
+ if (carried.length > 0) {
49434
+ this.#loops = [...this.#loops, ...carried].slice(0, MAX_LOOPS);
49435
+ this.#save();
49436
+ }
49437
+ }
49438
+ #save() {
49439
+ if (!this.#file) return;
49440
+ try {
49441
+ writeJsonAtomic(this.#file, {
49442
+ v: 1,
49443
+ kind: "session-loops",
49444
+ loops: this.#loops
49445
+ });
49446
+ } catch {
49447
+ }
49448
+ }
49449
+ async create(request) {
49450
+ this.#sync();
49451
+ if (this.#loops.length >= MAX_LOOPS)
49452
+ throw new Error(`A conversation holds at most ${MAX_LOOPS} loops.`);
49453
+ const now = new Date(this.#now());
49454
+ const spec = loopSpec(request.interval, now);
49455
+ const loop = {
49456
+ id: randomBytes2(3).toString("hex"),
49457
+ schedule: describeSchedule(spec, { tz: hostTimeZone() }),
49458
+ prompt: request.prompt,
49459
+ createdAt: now.toISOString(),
49460
+ expiresAt: new Date(now.getTime() + LOOP_LIFETIME_MS).toISOString(),
49461
+ createdBy: request.createdBy,
49462
+ spec
49463
+ };
49464
+ this.#loops.push(loop);
49465
+ this.#save();
49466
+ return loop;
49467
+ }
49468
+ list() {
49469
+ this.#sync();
49470
+ return this.#loops;
49471
+ }
49472
+ async delete(id) {
49473
+ this.#sync();
49474
+ const before = this.#loops.length;
49475
+ this.#loops = id === "all" ? [] : this.#loops.filter((l) => l.id !== id);
49476
+ this.#save();
49477
+ return before - this.#loops.length;
49478
+ }
49479
+ /** Fire what is due, when idle. Called on a timer and when a turn ends. */
49480
+ tick() {
49481
+ this.#sync();
49482
+ const now = this.#now();
49483
+ let changed = false;
49484
+ const kept = [];
49485
+ let fired = false;
49486
+ for (const loop of this.#loops) {
49487
+ if (loop.expiresAt && Date.parse(loop.expiresAt) <= now) {
49488
+ changed = true;
49489
+ continue;
49490
+ }
49491
+ const last = Date.parse(loop.lastFiredAt ?? loop.createdAt);
49492
+ const due = nextFireTime(loop.spec, new Date(last));
49493
+ const isDue = loop.pending || due !== null && due.getTime() <= now;
49494
+ if (!isDue) {
49495
+ kept.push(loop);
49496
+ continue;
49497
+ }
49498
+ if (fired || !this.#deps.isIdle()) {
49499
+ if (!loop.pending) changed = true;
49500
+ kept.push({ ...loop, pending: true });
49501
+ continue;
49502
+ }
49503
+ fired = true;
49504
+ changed = true;
49505
+ const done = loop.spec.kind === "at";
49506
+ const { pending: _pending, ...rest } = loop;
49507
+ if (!done) kept.push({ ...rest, lastFiredAt: new Date(now).toISOString() });
49508
+ this.#deps.fire(loop);
49509
+ }
49510
+ this.#loops = kept;
49511
+ if (changed) this.#save();
49512
+ }
49513
+ };
49514
+ function describeLoops(loops) {
49515
+ if (loops.length === 0) return "No loops in this conversation. /loop 5m <prompt> adds one.";
49516
+ return loops.map(
49517
+ (l) => `\u21BB ${l.id} ${l.schedule}${l.createdBy === "model" ? " (created by the model)" : ""}${l.lastFiredAt ? ` last ${new Date(l.lastFiredAt).toLocaleTimeString()}` : ""}
49518
+ ${l.prompt.replace(/\s+/g, " ").slice(0, 100)}`
49519
+ ).join("\n");
49520
+ }
49521
+ __name(describeLoops, "describeLoops");
49522
+
49523
+ // src/tui/schedule/host-commands.ts
49524
+ var USAGE = [
49525
+ "/schedule jobs, and what needs you",
49526
+ "/schedule confirm <job> confirm a job created without a terminal, or held after an edit",
49527
+ "/schedule pause|resume <job>",
49528
+ "/schedule run <job> run it now through the scheduler",
49529
+ "/schedule remove <job>",
49530
+ '/schedule add <name> "<when>" <read-only|edit-in-folder> <prompt\u2026>',
49531
+ "A run waiting for approval: /resume its conversation (Scheduled: <job> \xB7 <time>) in its folder."
49532
+ ].join("\n");
49533
+ async function schedulerLine(home) {
49534
+ const paths = schedulePaths(home);
49535
+ const endpoint = readEndpoint(paths.endpoint);
49536
+ if (endpoint && await callEndpoint(endpoint, "status", {}, 500)) return "Scheduler: running.";
49537
+ let installed = false;
49538
+ try {
49539
+ installed = readManifest(paths) !== void 0;
49540
+ } catch {
49541
+ }
49542
+ return installed ? "Scheduler: installed but not answering \u2014 namzu schedule status." : "Scheduler: not installed \u2014 namzu schedule install. Jobs do not run until it is.";
49543
+ }
49544
+ __name(schedulerLine, "schedulerLine");
49545
+ function when(iso, tz) {
49546
+ if (!iso) return "\u2014";
49547
+ return new Intl.DateTimeFormat("en-GB", {
49548
+ dateStyle: "medium",
49549
+ timeStyle: "short",
49550
+ timeZone: tz
49551
+ }).format(new Date(iso));
49552
+ }
49553
+ __name(when, "when");
49554
+ async function listScheduleJobs(ctx) {
49555
+ const paths = schedulePaths(ctx.home);
49556
+ const { jobs, errors } = listJobs(paths);
49557
+ const lines = [];
49558
+ for (const job of jobs) {
49559
+ const tz = job.schedule.kind === "cron" ? job.schedule.tz : hostTimeZone();
49560
+ const state = readState(paths, job.id);
49561
+ 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]" : "";
49562
+ const kind = job.runKind === "script" ? " [script, 0 tokens]" : job.runKind === "script+agent" ? " [script+agent]" : "";
49563
+ lines.push(
49564
+ `${job.name} [${job.state}]${kind}${mark}
49565
+ ${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)}` : ""}
49566
+ ${job.workspace === "none" ? "Private scheduler workspace (no project)" : job.folder.canonical}`
49567
+ );
49568
+ if (job.delivery?.kind === "source-conversation")
49569
+ lines.push(` Results return to source conversation ${job.delivery.sessionId}`);
49570
+ if (state.activeRun?.status === "awaiting-approval" && state.activeRun.sessionId) {
49571
+ const command = resumeCommand(job, state.activeRun.sessionId);
49572
+ const verb = state.activeRun.handoff ? "when that is done, continue it" : "answer it";
49573
+ lines.push(
49574
+ job.folder.canonical === ctx.cwd ? ` ${verb}: /resume and pick "Scheduled: ${job.name}", or ${command}` : ` ${verb}: ${command}`
49575
+ );
49576
+ }
49577
+ }
49578
+ return visibleScheduleMessage(
49579
+ [
49580
+ 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"),
49581
+ ...errors.length > 0 ? [
49582
+ `${errors.length} job file${errors.length === 1 ? "" : "s"} could not be read; inspect or repair the files under NAMZU_HOME.`
49583
+ ] : [],
49584
+ await schedulerLine(ctx.home)
49585
+ ].join("\n")
49586
+ );
49587
+ }
49588
+ __name(listScheduleJobs, "listScheduleJobs");
49589
+ async function confirmInTui(ctx, job, verb) {
49590
+ const say = /* @__PURE__ */ __name((message) => ctx.say(visibleScheduleMessage(message)), "say");
49591
+ const paths = schedulePaths(ctx.home);
49592
+ const layers = readPermissionLayers({
49593
+ cwd: job.folder.canonical,
49594
+ home: ctx.home,
49595
+ ...job.workspace === "none" ? { includeProject: false } : {}
49596
+ });
49597
+ const policy = compileJobPolicy(job.permissions, {
49598
+ layers,
49599
+ namzuHome: paths.home,
49600
+ folder: job.folder
49601
+ });
49602
+ if (policy.diagnostics.length > 0) {
49603
+ say(`The rules do not compile: ${policy.diagnostics.join("; ")}`);
49604
+ return "cancel";
49605
+ }
49606
+ const runKind = job.runKind ?? "agent";
49607
+ if (runKind !== "agent" && runKind !== "script" && runKind !== "script+agent") {
49608
+ say(`The job has an unknown run kind: ${String(runKind)}`);
49609
+ return "cancel";
49610
+ }
49611
+ if (runKind !== "agent") {
49612
+ if (!job.script) {
49613
+ say(`The ${runKind} job has no script recorded.`);
49614
+ return "cancel";
49615
+ }
49616
+ const selectedShell = installedCommandShellForDialect(job.script.shell);
49617
+ if (!selectedShell) {
49618
+ say(scriptShellUnavailableReason(job.script.shell));
49619
+ return "cancel";
49620
+ }
49621
+ const scriptPolicy = compileScriptCheckPolicy(job.permissions, {
49622
+ layers,
49623
+ namzuHome: paths.home,
49624
+ folder: job.folder
49625
+ });
49626
+ const checked = verifyScheduledScript(job.script.body, selectedShell.dialect, scriptPolicy);
49627
+ if (!checked.ok) {
49628
+ say(
49629
+ `The ${runKind === "script" ? "script" : "wake-gate script"} was refused: ${checked.reason}`
49630
+ );
49631
+ return "cancel";
49632
+ }
49633
+ }
49634
+ const scriptSection = runKind !== "agent" && job.script ? [
49635
+ `${runKind === "script" ? "Script" : "Wake-gate script"} (exactly as it will run, ${job.script.shell}; shell commands checked against the scheduled-run floor and deny rules)`,
49636
+ ...job.script.body.split("\n").map((line) => ` \u2502 ${line}`),
49637
+ ...job.script.report === "json-v1" ? [
49638
+ "Script report: JSON v1 (quiet/changed; optional scheduler state); stdout must be one JSON object line."
49639
+ ] : [],
49640
+ "Code passed to another interpreter is not parsed by the shell checker; review it here."
49641
+ ] : [];
49642
+ const now = /* @__PURE__ */ new Date();
49643
+ const fullText = visibleScheduleMessage(
49644
+ [
49645
+ ...previewLines(job, policy, now),
49646
+ ...changesBlock(changesSinceConfirmed(readHistory(paths, job.id))),
49647
+ ...scriptSection,
49648
+ ...runKind === "script" ? [] : [
49649
+ runKind === "script+agent" ? "Prompt (used only when the wake-gate says wake: true)" : "Prompt",
49650
+ ...job.prompt.split("\n").map((l) => ` \u2502 ${l}`)
49651
+ ]
48727
49652
  ].join("\n")
48728
49653
  );
48729
49654
  if (ctx.review) {
@@ -50401,186 +51326,66 @@ function writeSuggestionLedger(namzuHome, ledger) {
50401
51326
  writeFileSync(temp, `${JSON.stringify(ledger)}
50402
51327
  `, { mode: 384 });
50403
51328
  renameSync(temp, path);
50404
- } catch {
50405
- }
50406
- }
50407
- __name(writeSuggestionLedger, "writeSuggestionLedger");
50408
- function admitSuggestion(ledger) {
50409
- if (ledger.stopped) return { show: "nothing" };
50410
- if (ledger.unanswered >= SUGGESTION_IGNORE_LIMIT) {
50411
- return { show: "stopped-notice", next: { ...ledger, stopped: true } };
50412
- }
50413
- return { show: "proposal", next: { ...ledger, unanswered: ledger.unanswered + 1 } };
50414
- }
50415
- __name(admitSuggestion, "admitSuggestion");
50416
-
50417
- // src/tui/spinner-tips-setting.ts
50418
- function setSpinnerTips(on, opts = {}) {
50419
- try {
50420
- setUserConfigValue(["tui", "spinnerTips"], on, {
50421
- ...opts.home ? { home: opts.home } : {},
50422
- ...opts.env ? { env: opts.env } : {}
50423
- });
50424
- } catch (error) {
50425
- return `${explainFailure(error, "Could not save that setting.")} This conversation ${on ? "shows" : "hides"} tips until it ends.`;
50426
- }
50427
- const saved = on ? "Tips are on: one short tip shows under the working row." : "Tips are off. /config tips on turns them back on. The next task still shows under the working row.";
50428
- let resolved;
50429
- try {
50430
- resolved = loadConfigWithProvenance(opts);
50431
- } catch (error) {
50432
- return `${saved} ${explainFailure(error, "Could not check the other config files.")} This conversation follows your choice.`;
50433
- }
50434
- const effective = resolved.config.tui?.spinnerTips !== false;
50435
- if (effective === on) return saved;
50436
- const source = resolved.provenance.tui;
50437
- const winner = source ? formatConfigSource(source) : "another config layer";
50438
- return `${saved} But ${winner} turns them ${effective ? "on" : "off"}, so from the next start they will be ${effective ? "on" : "off"}; this conversation follows your choice.`;
50439
- }
50440
- __name(setSpinnerTips, "setSpinnerTips");
50441
-
50442
- // src/tui/stale-history-retry.ts
50443
- async function* sendWithRebuiltHistory(send, input) {
50444
- let prior = [...input.history, ...input.tail];
50445
- for (let attempt = 0; ; attempt += 1) {
50446
- let refused;
50447
- for await (const event of send(prior)) {
50448
- if (attempt === 0 && event.kind === "error" && event.failure?.code === "stale_cached_history") {
50449
- refused = event;
50450
- break;
50451
- }
50452
- yield event;
50453
- }
50454
- if (!refused) return;
50455
- const fresh = await input.rebuild().catch(() => void 0);
50456
- if (!fresh) {
50457
- yield refused;
50458
- return;
50459
- }
50460
- prior = [...fresh, ...input.tail];
50461
- }
50462
- }
50463
- __name(sendWithRebuiltHistory, "sendWithRebuiltHistory");
50464
-
50465
- // src/tui/task-activity.ts
50466
- var TASK_TOOLS = /* @__PURE__ */ new Set(["task_create", "task_update", "task_list"]);
50467
- function isTaskTool(toolName) {
50468
- return TASK_TOOLS.has(toolName);
50469
- }
50470
- __name(isTaskTool, "isTaskTool");
50471
- function taskOperationFor(previous, next) {
50472
- const subject = next.subject;
50473
- if (!previous) return { kind: "added", subject };
50474
- if (previous.status !== next.status) {
50475
- switch (next.status) {
50476
- case "in_progress":
50477
- return { kind: "started", subject };
50478
- case "completed":
50479
- return { kind: "completed", subject };
50480
- case "failed":
50481
- return { kind: "failed", subject };
50482
- case "pending":
50483
- return { kind: "reopened", subject };
50484
- }
50485
- }
50486
- if (previous.subject !== next.subject) return { kind: "renamed", subject };
50487
- return null;
50488
- }
50489
- __name(taskOperationFor, "taskOperationFor");
50490
- function removeTask(tasks, id, subject) {
50491
- const known = tasks.find((task) => task.id === id);
50492
- if (!known) return { tasks, operation: null };
50493
- return {
50494
- tasks: tasks.filter((task) => task.id !== id),
50495
- operation: { kind: "removed", subject: subject || known.subject }
50496
- };
50497
- }
50498
- __name(removeTask, "removeTask");
50499
- function upsertTask(tasks, item) {
50500
- const index = tasks.findIndex((task) => task.id === item.id);
50501
- return index < 0 ? [...tasks, item] : tasks.map((task, i) => i === index ? item : task);
50502
- }
50503
- __name(upsertTask, "upsertTask");
50504
- var SINGLE = {
50505
- added: "Added task",
50506
- started: "Started",
50507
- completed: "Completed",
50508
- failed: "Failed",
50509
- reopened: "Reopened",
50510
- renamed: "Renamed task",
50511
- removed: "Removed task"
50512
- };
50513
- var MANY = {
50514
- added: "Added",
50515
- started: "Started",
50516
- completed: "Completed",
50517
- failed: "Failed",
50518
- reopened: "Reopened",
50519
- renamed: "Renamed",
50520
- removed: "Removed"
50521
- };
50522
- function countTasks(count2) {
50523
- return `${count2} task${count2 === 1 ? "" : "s"}`;
50524
- }
50525
- __name(countTasks, "countTasks");
50526
- function taskBlockHeader(operations, checklist) {
50527
- const [first] = operations;
50528
- if (!first) return checklist.length === 0 ? "No tasks yet" : checklistProgress(checklist);
50529
- if (operations.length === 1)
50530
- return `${SINGLE[first.kind]} \xB7 ${first.subject.replace(/\s+/g, " ").trim()}`;
50531
- if (operations.every((operation) => operation.kind === first.kind)) {
50532
- return `${MANY[first.kind]} ${countTasks(operations.length)}`;
50533
- }
50534
- return checklistProgress(checklist);
50535
- }
50536
- __name(taskBlockHeader, "taskBlockHeader");
50537
- function extendable(messages, input) {
50538
- const last = messages.at(-1);
50539
- if (!last?.taskBlock || last.taskBlock.key !== input.key || last.pending) return void 0;
50540
- const finalizedIndex = messages.slice(0, -1).filter((message) => !message.pending).length;
50541
- return finalizedIndex >= input.settled ? last : void 0;
51329
+ } catch {
51330
+ }
50542
51331
  }
50543
- __name(extendable, "extendable");
50544
- function applyTaskOperation(messages, input) {
50545
- const open = extendable(messages, input);
50546
- const operations = [
50547
- ...open?.taskBlock?.operations ?? [],
50548
- ...input.operation ? [input.operation] : []
50549
- ];
50550
- if (!open && operations.length === 0 && input.checklist.length === 0) return messages;
50551
- const row = {
50552
- id: open?.id ?? input.id,
50553
- role: "tool",
50554
- content: taskBlockHeader(operations, input.checklist),
50555
- glyph: "\u2713",
50556
- ...input.glyphColor ? { glyphColor: input.glyphColor } : {},
50557
- checklist: input.checklist,
50558
- taskBlock: { key: input.key, operations }
50559
- };
50560
- return open ? [...messages.slice(0, -1), row] : [...messages, row];
51332
+ __name(writeSuggestionLedger, "writeSuggestionLedger");
51333
+ function admitSuggestion(ledger) {
51334
+ if (ledger.stopped) return { show: "nothing" };
51335
+ if (ledger.unanswered >= SUGGESTION_IGNORE_LIMIT) {
51336
+ return { show: "stopped-notice", next: { ...ledger, stopped: true } };
51337
+ }
51338
+ return { show: "proposal", next: { ...ledger, unanswered: ledger.unanswered + 1 } };
50561
51339
  }
50562
- __name(applyTaskOperation, "applyTaskOperation");
50563
- var CHECKLIST_STATUSES = /* @__PURE__ */ new Set([
50564
- "pending",
50565
- "in_progress",
50566
- "completed",
50567
- "failed"
50568
- ]);
50569
- function taskReportChecklist(rows) {
50570
- const items = [];
50571
- for (const [index, row] of rows.entries()) {
50572
- const { subject, status, id } = row;
50573
- if (typeof subject !== "string" || typeof status !== "string") return void 0;
50574
- if (!CHECKLIST_STATUSES.has(status)) return void 0;
50575
- items.push({
50576
- id: typeof id === "string" ? id : String(index),
50577
- subject,
50578
- status
51340
+ __name(admitSuggestion, "admitSuggestion");
51341
+
51342
+ // src/tui/spinner-tips-setting.ts
51343
+ function setSpinnerTips(on, opts = {}) {
51344
+ try {
51345
+ setUserConfigValue(["tui", "spinnerTips"], on, {
51346
+ ...opts.home ? { home: opts.home } : {},
51347
+ ...opts.env ? { env: opts.env } : {}
50579
51348
  });
51349
+ } catch (error) {
51350
+ return `${explainFailure(error, "Could not save that setting.")} This conversation ${on ? "shows" : "hides"} tips until it ends.`;
50580
51351
  }
50581
- return items;
51352
+ const saved = on ? "Tips are on: one short tip shows under the working row." : "Tips are off. /config tips on turns them back on. The next task still shows under the working row.";
51353
+ let resolved;
51354
+ try {
51355
+ resolved = loadConfigWithProvenance(opts);
51356
+ } catch (error) {
51357
+ return `${saved} ${explainFailure(error, "Could not check the other config files.")} This conversation follows your choice.`;
51358
+ }
51359
+ const effective = resolved.config.tui?.spinnerTips !== false;
51360
+ if (effective === on) return saved;
51361
+ const source = resolved.provenance.tui;
51362
+ const winner = source ? formatConfigSource(source) : "another config layer";
51363
+ return `${saved} But ${winner} turns them ${effective ? "on" : "off"}, so from the next start they will be ${effective ? "on" : "off"}; this conversation follows your choice.`;
50582
51364
  }
50583
- __name(taskReportChecklist, "taskReportChecklist");
51365
+ __name(setSpinnerTips, "setSpinnerTips");
51366
+
51367
+ // src/tui/stale-history-retry.ts
51368
+ async function* sendWithRebuiltHistory(send, input) {
51369
+ let prior = [...input.history, ...input.tail];
51370
+ for (let attempt = 0; ; attempt += 1) {
51371
+ let refused;
51372
+ for await (const event of send(prior)) {
51373
+ if (attempt === 0 && event.kind === "error" && event.failure?.code === "stale_cached_history") {
51374
+ refused = event;
51375
+ break;
51376
+ }
51377
+ yield event;
51378
+ }
51379
+ if (!refused) return;
51380
+ const fresh = await input.rebuild().catch(() => void 0);
51381
+ if (!fresh) {
51382
+ yield refused;
51383
+ return;
51384
+ }
51385
+ prior = [...fresh, ...input.tail];
51386
+ }
51387
+ }
51388
+ __name(sendWithRebuiltHistory, "sendWithRebuiltHistory");
50584
51389
 
50585
51390
  // src/tui/triggers/registry.ts
50586
51391
  var both = /* @__PURE__ */ __name((pattern) => ({ pattern, edges: "both" }), "both");
@@ -50754,7 +51559,7 @@ __name(triggerDefinition, "triggerDefinition");
50754
51559
  // src/tui/triggers/context-text.ts
50755
51560
  var TEXTS = {
50756
51561
  hypermode: HYPERMODE_KEYWORD_TEXT,
50757
- workflow: "The operator asked for a workflow for THIS turn only: their message named it, and it is not on for the session. This opts the turn into the `workflow` tool. When the work is large enough to split into phases of agents, write one workflow script for it; the operator reads the script and approves it before anything starts. For a small piece of work, answer or use the Agent tool as usual.",
51562
+ workflow: "The operator asked for a workflow for this turn only: their message named it, and it is not on for the session. This opts the turn into the `workflow` tool. When the work is large enough to split into phases of agents, write one workflow script for it; the operator reads the script and approves it before anything starts. For a small piece of work, answer or use the Agent tool as usual.",
50758
51563
  "save-skill": "The operator asked namzu to save this work as a skill after this turn. namzu runs /skills save itself once the turn ends, and that ends on the operator's own confirmation screen. Finish the task; do not call save_skill in this turn.",
50759
51564
  schedule: "The operator asked for this to run on a schedule. When the task is clear, propose a job with the `schedule` tool; the operator confirms it on screen. Do not create a `session_loop`; if a repeat inside this open session fits better, tell the operator to use /loop."
50760
51565
  };
@@ -51369,668 +52174,227 @@ async function runBrowserSlash(control, args, options) {
51369
52174
  };
51370
52175
  }
51371
52176
  const [verb, name, ...rest] = args;
51372
- if (verb === void 0 || verb === "status" && name === void 0) {
51373
- return { text: describeBrowserStatus(control.status()) };
51374
- }
51375
- if (verb === "profile" && rest.length === 0) {
51376
- if (name === void 0) {
51377
- return {
51378
- text: `Profile: ${control.status().profile}. Switch with /browser profile <name>; list profiles with \`namzu browser list\`.`
51379
- };
51380
- }
51381
- if (options.busy) {
51382
- return {
51383
- text: "The profile cannot change while a reply is running. Try again when it ends."
51384
- };
51385
- }
51386
- try {
51387
- const status = await control.switchProfile(name);
51388
- return {
51389
- text: `The browser uses profile ${status.profile} from the next browser call on, in this conversation. Sign in to a site once with \`namzu browser login ${status.profile} <url>\`.`,
51390
- profile: status.profile
51391
- };
51392
- } catch (error) {
51393
- return {
51394
- text: error instanceof Error && error.message ? error.message : explainFailure(error, "Could not switch the browser profile.")
51395
- };
51396
- }
51397
- }
51398
- return { text: `Usage:
51399
- ${BROWSER_SLASH_USAGE}` };
51400
- }
51401
- __name(runBrowserSlash, "runBrowserSlash");
51402
-
51403
- // src/tui/exit-hint.ts
51404
- var EXIT_HINT_MS = 800;
51405
-
51406
- // src/tui/group-rows.ts
51407
- function joinSections(body, section) {
51408
- if (section.length === 0) return body ?? [];
51409
- return body && body.length > 0 ? [...body, "", ...section] : section;
51410
- }
51411
- __name(joinSections, "joinSections");
51412
- function mergeGroupRows(rows) {
51413
- const out = [];
51414
- for (const row of rows) {
51415
- const last = out.at(-1);
51416
- if (row.group && !row.pending && last?.group && !last.pending) {
51417
- const group = mergeGroups(last.group, row.group);
51418
- out[out.length - 1] = {
51419
- ...last,
51420
- group,
51421
- content: groupText(group, false),
51422
- detail: joinSections(last.detail, row.detail ?? [])
51423
- };
51424
- continue;
51425
- }
51426
- out.push(row);
51427
- }
51428
- return out;
51429
- }
51430
- __name(mergeGroupRows, "mergeGroupRows");
51431
-
51432
- // src/tui/pause-clock.ts
51433
- var PauseClock = class {
51434
- static {
51435
- __name(this, "PauseClock");
51436
- }
51437
- #total = 0;
51438
- #since = null;
51439
- /** The person is now being waited on. A second call while waiting changes nothing. */
51440
- begin(now) {
51441
- if (this.#since === null) this.#since = now;
51442
- }
51443
- /** The wait is over. */
51444
- end(now) {
51445
- if (this.#since === null) return;
51446
- this.#total += Math.max(0, now - this.#since);
51447
- this.#since = null;
51448
- }
51449
- /** Milliseconds waited so far, counting a wait that is still open. */
51450
- total(now) {
51451
- return this.#total + (this.#since === null ? 0 : Math.max(0, now - this.#since));
51452
- }
51453
- };
51454
-
51455
- // src/tui/placeholder-examples.ts
51456
- import { execFile as execFile3 } from "node:child_process";
51457
- var PLAIN_EXAMPLES = [
51458
- "fix lint errors",
51459
- "fix typecheck errors",
51460
- "how do I log an error?",
51461
- "create a util logging.py that..."
51462
- ];
51463
- var FILE_EXAMPLES = [
51464
- (file) => `how does ${file} work?`,
51465
- (file) => `refactor ${file}`,
51466
- (file) => `edit ${file} to...`,
51467
- (file) => `write a test for ${file}`
51468
- ];
51469
- function examplePlaceholder(file, seed) {
51470
- const pool = [
51471
- ...PLAIN_EXAMPLES,
51472
- ...file ? FILE_EXAMPLES.map((make) => make(file)) : []
51473
- ];
51474
- const at = Math.min(pool.length - 1, Math.floor(Math.max(0, seed) * pool.length));
51475
- return `Try "${pool[at]}"`;
51476
- }
51477
- __name(examplePlaceholder, "examplePlaceholder");
51478
- function isExampleFile(path) {
51479
- if (/(^|\/)(node_modules|dist|build|\.changeset|docs)\//.test(path)) return false;
51480
- if (/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|CHANGELOG\.md|log\.md)$/.test(path))
51481
- return false;
51482
- return /\.(ts|tsx|js|jsx|mjs|cjs|py|rs|go|java|rb|c|cc|cpp|h|cs|swift|kt)$/.test(path);
51483
- }
51484
- __name(isExampleFile, "isExampleFile");
51485
- function frequentlyModifiedFile(cwd2, signal) {
51486
- return new Promise((resolve9) => {
51487
- execFile3(
51488
- "git",
51489
- ["log", "--name-only", "--pretty=format:", "-n", "200"],
51490
- { cwd: cwd2, signal, maxBuffer: 4 * 1024 * 1024, timeout: 5e3 },
51491
- (error, stdout) => {
51492
- if (error) return resolve9(void 0);
51493
- const counts2 = /* @__PURE__ */ new Map();
51494
- for (const line of stdout.split("\n")) {
51495
- const path = line.trim();
51496
- if (path && isExampleFile(path)) counts2.set(path, (counts2.get(path) ?? 0) + 1);
51497
- }
51498
- let best;
51499
- let bestCount = 0;
51500
- for (const [path, count2] of counts2) {
51501
- if (count2 > bestCount) {
51502
- best = path;
51503
- bestCount = count2;
51504
- }
51505
- }
51506
- resolve9(best);
51507
- }
51508
- );
51509
- });
51510
- }
51511
- __name(frequentlyModifiedFile, "frequentlyModifiedFile");
51512
-
51513
- // src/tui/recap-setting.ts
51514
- var OFF_WORDS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
51515
- var ON_WORDS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
51516
- function recapEnabled(input) {
51517
- const word = input.env.NAMZU_RECAP?.trim().toLowerCase();
51518
- if (word !== void 0 && OFF_WORDS.has(word)) return false;
51519
- if (word !== void 0 && ON_WORDS.has(word)) return true;
51520
- if (!input.interactive) return false;
51521
- return input.tui?.recap !== false;
51522
- }
51523
- __name(recapEnabled, "recapEnabled");
51524
- function recapWaitMs(env3) {
51525
- const raw = env3.NAMZU_RECAP_WAIT_MS?.trim();
51526
- if (raw === void 0 || !/^\d{1,9}$/u.test(raw)) return RECAP_WAIT_MS;
51527
- return Number(raw);
51528
- }
51529
- __name(recapWaitMs, "recapWaitMs");
51530
- function setRecapSetting(on, opts = {}) {
51531
- const env3 = opts.env ?? process.env;
51532
- try {
51533
- const target = { ...opts.home ? { home: opts.home } : {}, env: env3 };
51534
- if (on) deleteUserConfigValue(["tui", "recap"], target);
51535
- else setUserConfigValue(["tui", "recap"], false, target);
51536
- } catch (error) {
51537
- return `${explainFailure(error, "Could not save that setting.")} This conversation ${on ? "shows" : "skips"} recaps until it ends.`;
51538
- }
51539
- const saved = on ? "Recaps are on: after a few minutes away, a one-line recap of where things stand is shown when you come back." : "Recaps are off. /config recap on turns them back on; /recap still writes one on request.";
51540
- const word = env3.NAMZU_RECAP?.trim().toLowerCase();
51541
- if (word !== void 0 && (OFF_WORDS.has(word) || ON_WORDS.has(word))) {
51542
- const forced = ON_WORDS.has(word);
51543
- if (forced !== on) {
51544
- return `${saved} But NAMZU_RECAP is set in the environment and turns them ${forced ? "on" : "off"} on the next start; this conversation follows your choice.`;
51545
- }
51546
- }
51547
- return saved;
51548
- }
51549
- __name(setRecapSetting, "setRecapSetting");
51550
- function describeRecapSetting(input) {
51551
- const fromFiles = input.tui?.recap !== false;
51552
- const word = input.env.NAMZU_RECAP?.trim().toLowerCase();
51553
- const lines = [`Recaps: ${input.enabledNow ? "on" : "off"} in this conversation.`];
51554
- lines.push(`Config files: ${fromFiles ? "on (the default)" : "off"}.`);
51555
- if (word !== void 0 && (OFF_WORDS.has(word) || ON_WORDS.has(word))) {
51556
- lines.push(`NAMZU_RECAP is set and turns them ${ON_WORDS.has(word) ? "on" : "off"}.`);
51557
- }
51558
- lines.push("/config recap on|off changes it; /recap writes one now.");
51559
- return lines.join("\n");
51560
- }
51561
- __name(describeRecapSetting, "describeRecapSetting");
51562
-
51563
- // src/tui/recap-turns.ts
51564
- function kindOf(message) {
51565
- if (message.kind === "recap") return "recap";
51566
- if (message.pending) return void 0;
51567
- if (message.role === "user" && !message.sourceDelivery && message.content.trim().length > 0) {
51568
- return "prompt";
51569
- }
51570
- if (message.role === "assistant" && message.content.trim().length > 0) return "reply";
51571
- return void 0;
51572
- }
51573
- __name(kindOf, "kindOf");
51574
- function recapRows(messages) {
51575
- const rows = [];
51576
- for (const message of messages) {
51577
- const kind = kindOf(message);
51578
- if (kind !== void 0) rows.push(kind);
51579
- }
51580
- return rows;
51581
- }
51582
- __name(recapRows, "recapRows");
51583
- function recapTurns(messages) {
51584
- const turns = [];
51585
- for (const message of messages) {
51586
- const kind = kindOf(message);
51587
- if (kind === "prompt") turns.push({ role: "user", text: message.content });
51588
- else if (kind === "reply") turns.push({ role: "assistant", text: message.content });
51589
- }
51590
- return turns;
51591
- }
51592
- __name(recapTurns, "recapTurns");
51593
-
51594
- // src/tui/conversation-evidence-view.ts
51595
- function conversationEvidenceView(toolName, output) {
51596
- if (toolName !== "search_conversation" && toolName !== "read_conversation") return void 0;
51597
- let value;
51598
- try {
51599
- value = JSON.parse(output);
51600
- } catch {
51601
- return void 0;
51602
- }
51603
- if (!record(value)) return void 0;
51604
- const rows = toolName === "search_conversation" ? searchRows(value) : readRows(value);
51605
- if (!rows) return void 0;
51606
- return { content: rows.join("\n"), detail: JSON.stringify(value, null, 2).split("\n") };
51607
- }
51608
- __name(conversationEvidenceView, "conversationEvidenceView");
51609
- function record(value) {
51610
- return value !== null && typeof value === "object" && !Array.isArray(value);
51611
- }
51612
- __name(record, "record");
51613
- function count(value) {
51614
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
51615
- }
51616
- __name(count, "count");
51617
- function preview2(text, limit = 96) {
51618
- const units = Array.from(text.replace(/\s+/gu, " ").trim());
51619
- return units.length > limit ? `${units.slice(0, limit - 1).join("")}\u2026` : units.join("");
51620
- }
51621
- __name(preview2, "preview");
51622
- function sourceLabel2(value) {
51623
- switch (value.recordKind) {
51624
- case "assistant_message":
51625
- return "Assistant message";
51626
- case "user_message":
51627
- return "User message";
51628
- case "system_message":
51629
- return "System message";
51630
- case "derived_summary":
51631
- return "Derived summary";
51632
- case "tool_result":
51633
- return `Tool result${typeof value.toolName === "string" ? ` (${preview2(value.toolName, 48)})` : ""}`;
51634
- default:
51635
- return "Source unknown";
51636
- }
51637
- }
51638
- __name(sourceLabel2, "sourceLabel");
51639
- function searchRows(value) {
51640
- if (!Array.isArray(value.matches) || !value.matches.every((match) => record(match) && typeof match.text === "string") || typeof value.incomplete !== "boolean" || !count(value.unavailable))
51641
- return void 0;
51642
- const rows = [
51643
- `Conversation search \xB7 ${plural(value.matches.length, "match", "matches")} on this page`
51644
- ];
51645
- rows.push(
51646
- value.incomplete || value.nextCursor ? `Search not finished${value.nextCursor ? " \xB7 more to scan" : ""} \xB7 a missing result may not have been reached yet` : "Search finished"
51647
- );
51648
- if (value.unavailable > 0) rows.push(`${plural(value.unavailable, "record")} unavailable`);
51649
- for (const match of value.matches.slice(0, 3)) {
51650
- rows.push(
51651
- `${sourceLabel2(match)}${match.retained === "preview" ? " \xB7 preview flagged" : ""}${match.isError === true ? " \xB7 original reported error" : ""}: ${preview2(match.text)}`
51652
- );
51653
- }
51654
- if (value.matches.length > 3)
51655
- rows.push(`+${plural(value.matches.length - 3, "more match", "more matches")} in details`);
51656
- return rows;
51657
- }
51658
- __name(searchRows, "searchRows");
51659
- function readRows(value) {
51660
- if (typeof value.text !== "string" || typeof value.complete !== "boolean" || typeof value.retainedPreview !== "boolean" || !count(value.offset))
51661
- return void 0;
51662
- const rows = [`Conversation read \xB7 ${sourceLabel2(value)}`];
51663
- if (value.retainedPreview) rows.push("Preview flagged \xB7 original may be incomplete");
51664
- if (!value.complete) {
51665
- rows.push(
51666
- value.nextCursor ? value.text.length === 0 ? "Locating retained text \xB7 continue scan" : "Partial page \xB7 more retained text available" : "Read incomplete \xB7 no continuation supplied"
51667
- );
51668
- } else {
51669
- rows.push(
51670
- value.offset > 0 ? "Last page \xB7 earlier text is not on this page" : "Selected retained part returned"
51671
- );
51672
- }
51673
- if (value.recordKind === "tool_result") {
51674
- rows.push(
51675
- value.isError === true ? "Original tool reported an error" : value.isError === false ? "Original tool reported no error" : "Original tool status unknown"
51676
- );
51677
- }
51678
- if (value.text.length > 0) rows.push(`Excerpt: ${preview2(value.text, 160)}`);
51679
- return rows;
51680
- }
51681
- __name(readRows, "readRows");
51682
-
51683
- // src/tui/model-catalogue-view.ts
51684
- function modelCatalogueView(output) {
51685
- let value;
51686
- try {
51687
- value = JSON.parse(output);
51688
- } catch {
51689
- return void 0;
51690
- }
51691
- if (!record2(value) || !Array.isArray(value.models) || !Number.isSafeInteger(value.omitted) || value.omitted < 0)
51692
- return void 0;
51693
- const models = value.models;
51694
- if (!models.every(
51695
- (model) => record2(model) && typeof model.provider === "string" && (typeof model.id === "string" && typeof model.name === "string" || model.status === "catalogue unavailable")
51696
- ))
51697
- return void 0;
51698
- const rows = ["Available models"];
51699
- if (models.length === 0) rows.push("No matching models.");
51700
- for (const model of models.slice(0, 5)) {
51701
- if (model.status === "catalogue unavailable") {
51702
- rows.push(`${model.provider} \xB7 catalogue unavailable`);
51703
- continue;
51704
- }
51705
- rows.push(`${model.name} \xB7 ${model.provider}`);
51706
- rows.push(` ${model.id}`);
51707
- const facts = [];
51708
- if (typeof model.contextWindow === "number" && Number.isSafeInteger(model.contextWindow) && model.contextWindow > 0)
51709
- facts.push(
51710
- `Context ${new Intl.NumberFormat("en", { notation: "compact", maximumFractionDigits: 1 }).format(model.contextWindow)}`
51711
- );
51712
- const effort = model.reasoningEffortLevels ?? model.effortLevels;
51713
- if (Array.isArray(effort) && effort.every((item) => typeof item === "string"))
51714
- facts.push(effort.length ? `Effort ${effort.join(" \xB7 ")}` : "Effort not supported");
51715
- facts.push(priceFact(model));
51716
- if (facts.length) rows.push(` ${facts.join(" | ")}`);
51717
- }
51718
- const omitted = value.omitted + Math.max(0, models.length - 5);
51719
- if (omitted) rows.push(`+${omitted} more \xB7 narrow the search`);
51720
- return rows.join("\n");
51721
- }
51722
- __name(modelCatalogueView, "modelCatalogueView");
51723
- function record2(value) {
51724
- return value !== null && typeof value === "object" && !Array.isArray(value);
51725
- }
51726
- __name(record2, "record");
51727
- function priceFact(model) {
51728
- const input = model.inputPrice;
51729
- const output = model.outputPrice;
51730
- if (typeof input !== "number" || typeof output !== "number") return "Price unknown";
51731
- if (input === 0 && output === 0) return "Free";
51732
- return `$${input}/$${output} per Mtok`;
51733
- }
51734
- __name(priceFact, "priceFact");
51735
-
51736
- // src/tui/tool-failure-text.ts
51737
- var WHOLE_TOOL_ERROR = /^\s*<tool_use_error>([\s\S]*)<\/tool_use_error>\s*$/i;
51738
- var NESTED_TOOL_ERROR = /<\/?tool_use_error\b/i;
51739
- var BAD_ARGUMENTS = /^(?:InputValidationError: |Validation failed for "|Tool "[^"]+" was called with no arguments\.)/;
51740
- function toolFailureText(output, expanded) {
51741
- if (output === void 0) return "Tool execution failed";
51742
- const inner = WHOLE_TOOL_ERROR.exec(output)?.[1];
51743
- const unwrapped = inner !== void 0 && !NESTED_TOOL_ERROR.test(inner) ? inner : output;
51744
- const text = unwrapped.replace(/<sandbox_violations>[\s\S]*?<\/sandbox_violations>/g, "").replace(/<\/?error>/g, "").trim();
51745
- if (!expanded && BAD_ARGUMENTS.test(text)) return "Invalid tool parameters";
51746
- return text.startsWith("Error: ") || text.startsWith("Cancelled: ") ? text : `Error: ${text}`;
51747
- }
51748
- __name(toolFailureText, "toolFailureText");
51749
- function firstLineOf(text) {
51750
- return text.split("\n", 1)[0] ?? "";
51751
- }
51752
- __name(firstLineOf, "firstLineOf");
51753
-
51754
- // src/tui/tool-end-rows.ts
51755
- var DISPLAY_NAMES = { edit: "Update" };
51756
- function formatToolCall(toolName, summary2, standalone = false) {
51757
- if (standalone) return summary2;
51758
- const words = toolName.replace(/[_-]+/g, " ");
51759
- const display = DISPLAY_NAMES[toolName.toLowerCase()] ?? (words.length > 0 ? words[0]?.toUpperCase() + words.slice(1) : words);
51760
- return summary2.length > 0 ? `${display}(${summary2})` : display;
51761
- }
51762
- __name(formatToolCall, "formatToolCall");
51763
- function failureBody(lines, folded) {
51764
- return { stdout: [], stderr: lines, failed: true, byLine: true, ...folded ? { folded } : {} };
51765
- }
51766
- __name(failureBody, "failureBody");
51767
- function foldOf(start) {
51768
- if (start?.fold) return start.fold;
51769
- return start?.activity === "exploration" ? { kind: "read", key: start.label } : void 0;
51770
- }
51771
- __name(foldOf, "foldOf");
51772
- function failedCallRows(event, start) {
51773
- const head = {
51774
- role: "tool",
51775
- content: headOf(event, start),
51776
- glyph: "\u25CF",
51777
- glyphColor: tokenColor("status.error")
51778
- };
51779
- const said = event.output ?? (event.summary.length > 0 ? event.summary : void 0);
51780
- const full = toolFailureText(said, true).split("\n");
51781
- if (event.plainFailure !== void 0) {
51782
- return [
51783
- head,
51784
- {
51785
- role: "tool",
51786
- content: event.plainFailure,
51787
- glyph: "\u23BF",
51788
- contentColor: event.plainFailureTone === "muted" ? tokenColor("text.muted") : tokenColor("status.error"),
51789
- ...said !== void 0 && said.trim().length > 0 ? { detail: full, meta: EXPAND_HINT, activity: "agent-result" } : {}
51790
- }
51791
- ];
52177
+ if (verb === void 0 || verb === "status" && name === void 0) {
52178
+ return { text: describeBrowserStatus(control.status()) };
51792
52179
  }
51793
- const text = toolFailureText(said, false);
51794
- const lines = text.split("\n");
51795
- return [
51796
- {
51797
- ...head,
51798
- detail: full,
51799
- shell: failureBody(full, text !== full.join("\n") ? lines : void 0)
52180
+ if (verb === "profile" && rest.length === 0) {
52181
+ if (name === void 0) {
52182
+ return {
52183
+ text: `Profile: ${control.status().profile}. Switch with /browser profile <name>; list profiles with \`namzu browser list\`.`
52184
+ };
51800
52185
  }
51801
- ];
52186
+ if (options.busy) {
52187
+ return {
52188
+ text: "The profile cannot change while a reply is running. Try again when it ends."
52189
+ };
52190
+ }
52191
+ try {
52192
+ const status = await control.switchProfile(name);
52193
+ return {
52194
+ text: `The browser uses profile ${status.profile} from the next browser call on, in this conversation. Sign in to a site once with \`namzu browser login ${status.profile} <url>\`.`,
52195
+ profile: status.profile
52196
+ };
52197
+ } catch (error) {
52198
+ return {
52199
+ text: error instanceof Error && error.message ? error.message : explainFailure(error, "Could not switch the browser profile.")
52200
+ };
52201
+ }
52202
+ }
52203
+ return { text: `Usage:
52204
+ ${BROWSER_SLASH_USAGE}` };
51802
52205
  }
51803
- __name(failedCallRows, "failedCallRows");
51804
- function headOf(event, start) {
51805
- return start?.label ?? formatToolCall(event.toolName, event.summary);
52206
+ __name(runBrowserSlash, "runBrowserSlash");
52207
+
52208
+ // src/tui/exit-hint.ts
52209
+ var EXIT_HINT_MS = 800;
52210
+
52211
+ // src/tui/group-rows.ts
52212
+ function joinSections(body, section) {
52213
+ if (section.length === 0) return body ?? [];
52214
+ return body && body.length > 0 ? [...body, "", ...section] : section;
51806
52215
  }
51807
- __name(headOf, "headOf");
51808
- function toolEndRows(event, start, ctx) {
51809
- const rows = /* @__PURE__ */ __name((list2) => ({ kind: "rows", rows: list2 }), "rows");
51810
- const fold2 = foldOf(start);
51811
- if (!event.isError && !event.declined && fold2) {
51812
- const raw = event.output !== void 0 ? event.output.split("\n") : [...event.summary ? [event.summary] : [], ...event.detail ?? []];
51813
- const answer = event.shell?.note;
51814
- const output = answer !== void 0 && raw.join("").trim().toLowerCase() === "(no output)" ? [answer] : raw;
51815
- const state = foldOp(EMPTY_GROUP, { ...fold2, hint: void 0 }, 0);
51816
- const headline = event.headline ?? start?.label ?? headOf(event, start);
51817
- return rows([
51818
- {
51819
- role: "tool",
51820
- content: groupText(state, false),
51821
- detail: [headline, ...output],
51822
- glyph: " ",
51823
- glyphColor: tokenColor("text.muted"),
51824
- meta: EXPAND_HINT,
51825
- activity: "exploration",
51826
- group: state
51827
- }
51828
- ]);
51829
- }
51830
- if (event.isError && !event.declined && !event.cancelled && fold2) {
51831
- const said = event.output ?? (event.summary.length > 0 ? event.summary : void 0);
51832
- const state = foldOp(EMPTY_GROUP, { ...fold2, hint: void 0 }, 0);
51833
- return rows([
51834
- {
51835
- role: "tool",
51836
- content: groupText(state, false),
51837
- detail: [start?.label ?? headOf(event, start), ...toolFailureText(said, true).split("\n")],
51838
- glyph: " ",
51839
- glyphColor: tokenColor("text.muted"),
51840
- meta: EXPAND_HINT,
51841
- activity: "exploration",
51842
- group: state
51843
- }
51844
- ]);
51845
- }
51846
- const web = event.web ?? start?.web;
51847
- if (web && !event.isError) {
51848
- const activity = {
51849
- ...web,
51850
- ...event.web?.target ?? start?.web?.target ? { target: event.web?.target ?? start?.web?.target } : {}
51851
- };
51852
- const durationMs = event.durationMs ?? ctx.elapsedMs;
51853
- const output = web.hosted ? void 0 : event.output;
51854
- const outputLines = output !== void 0 ? output.split("\n") : void 0;
51855
- return rows([
51856
- {
51857
- role: "tool",
51858
- content: webCallTitle(activity),
51859
- glyph: "\u25CF",
51860
- glyphColor: tokenColor("status.ok"),
51861
- activity: "web"
51862
- },
51863
- {
51864
- role: "tool",
51865
- content: webSettledLine(activity, {
51866
- ...durationMs !== void 0 ? { durationMs } : {},
51867
- ...activity.kind === "fetch" && output !== void 0 ? { bytes: Buffer.byteLength(output, "utf8") } : {}
51868
- }),
51869
- glyph: "\u23BF",
51870
- ...outputLines ? { detail: outputLines } : {},
51871
- ...outputLines && outputLines.length > 0 ? { meta: EXPAND_HINT } : {},
51872
- activity: "web"
51873
- }
51874
- ]);
52216
+ __name(joinSections, "joinSections");
52217
+ function mergeGroupRows(rows) {
52218
+ const out = [];
52219
+ for (const row of rows) {
52220
+ const last = out.at(-1);
52221
+ if (row.group && !row.pending && last?.group && !last.pending) {
52222
+ const group = mergeGroups(last.group, row.group);
52223
+ out[out.length - 1] = {
52224
+ ...last,
52225
+ group,
52226
+ content: groupText(group, false),
52227
+ detail: joinSections(last.detail, row.detail ?? [])
52228
+ };
52229
+ continue;
52230
+ }
52231
+ out.push(row);
51875
52232
  }
51876
- if (isTaskTool(event.toolName) && !event.isError) {
51877
- if (event.toolName !== "task_list") return { kind: "none" };
51878
- if (ctx.hasPlan) return { kind: "task-block" };
51879
- const said = event.resultLabel ?? "";
51880
- return rows([
51881
- {
51882
- role: "tool",
51883
- content: start?.label ?? formatToolCall(event.toolName, event.summary, true),
51884
- glyph: "\u25CF",
51885
- glyphColor: tokenColor("status.ok")
51886
- },
51887
- ...said.length > 0 ? [
51888
- {
51889
- role: "tool",
51890
- content: said,
51891
- glyph: "\u23BF"
51892
- }
51893
- ] : []
51894
- ]);
52233
+ return out;
52234
+ }
52235
+ __name(mergeGroupRows, "mergeGroupRows");
52236
+
52237
+ // src/tui/pause-clock.ts
52238
+ var PauseClock = class {
52239
+ static {
52240
+ __name(this, "PauseClock");
51895
52241
  }
51896
- if (event.declined) {
51897
- const refused = proposedBody(start?.proposed, ctx.cwd);
51898
- return rows([
51899
- {
51900
- role: "tool",
51901
- content: headOf(event, start),
51902
- glyph: "\u25CF",
51903
- glyphColor: tokenColor("text.muted")
51904
- },
51905
- {
51906
- role: "tool",
51907
- content: declinedLine(event.declined.note),
51908
- glyph: "\u23BF",
51909
- ...refused ? { detail: refused.rows, diff: refused.diff } : {}
51910
- }
51911
- ]);
52242
+ #total = 0;
52243
+ #since = null;
52244
+ /** The person is now being waited on. A second call while waiting changes nothing. */
52245
+ begin(now) {
52246
+ if (this.#since === null) this.#since = now;
51912
52247
  }
51913
- if (event.cancelled) {
51914
- return rows([
51915
- {
51916
- role: "tool",
51917
- content: headOf(event, start),
51918
- glyph: "\u25CF",
51919
- glyphColor: tokenColor("text.muted"),
51920
- ...settledElapsed(event.durationMs) !== void 0 ? { meta: settledElapsed(event.durationMs) } : {}
51921
- },
51922
- { role: "tool", content: event.resultLabel ?? "Cancelled", glyph: "\u23BF" }
51923
- ]);
52248
+ /** The wait is over. */
52249
+ end(now) {
52250
+ if (this.#since === null) return;
52251
+ this.#total += Math.max(0, now - this.#since);
52252
+ this.#since = null;
51924
52253
  }
51925
- if (!event.isError && event.toolName === WORKFLOW_TOOL_NAME && isBackgroundLaunch(event.output ?? "")) {
51926
- return rows([
51927
- {
51928
- role: "tool",
51929
- content: headOf(event, start),
51930
- glyph: "\u25CF",
51931
- glyphColor: tokenColor("accent.assistant")
51932
- },
51933
- { role: "tool", content: WORKFLOW_BACKGROUND_NOTE, glyph: "\u23BF" }
51934
- ]);
52254
+ /** Milliseconds waited so far, counting a wait that is still open. */
52255
+ total(now) {
52256
+ return this.#total + (this.#since === null ? 0 : Math.max(0, now - this.#since));
51935
52257
  }
51936
- if (event.isError && event.toolName === WORKFLOW_TOOL_NAME && event.output !== void 0) {
51937
- const said = [`\u2718 ${firstLineOf(event.output)}`];
51938
- return rows([
51939
- {
51940
- role: "tool",
51941
- content: headOf(event, start),
51942
- glyph: "\u25CF",
51943
- glyphColor: tokenColor("status.error"),
51944
- detail: said,
51945
- shell: failureBody(said)
52258
+ };
52259
+
52260
+ // src/tui/placeholder-examples.ts
52261
+ import { execFile as execFile3 } from "node:child_process";
52262
+ var PLAIN_EXAMPLES = [
52263
+ "fix lint errors",
52264
+ "fix typecheck errors",
52265
+ "how do I log an error?",
52266
+ "create a util logging.py that..."
52267
+ ];
52268
+ var FILE_EXAMPLES = [
52269
+ (file) => `how does ${file} work?`,
52270
+ (file) => `refactor ${file}`,
52271
+ (file) => `edit ${file} to...`,
52272
+ (file) => `write a test for ${file}`
52273
+ ];
52274
+ function examplePlaceholder(file, seed) {
52275
+ const pool = [
52276
+ ...PLAIN_EXAMPLES,
52277
+ ...file ? FILE_EXAMPLES.map((make) => make(file)) : []
52278
+ ];
52279
+ const at = Math.min(pool.length - 1, Math.floor(Math.max(0, seed) * pool.length));
52280
+ return `Try "${pool[at]}"`;
52281
+ }
52282
+ __name(examplePlaceholder, "examplePlaceholder");
52283
+ function isExampleFile(path) {
52284
+ if (/(^|\/)(node_modules|dist|build|\.changeset|docs)\//.test(path)) return false;
52285
+ if (/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|CHANGELOG\.md|log\.md)$/.test(path))
52286
+ return false;
52287
+ return /\.(ts|tsx|js|jsx|mjs|cjs|py|rs|go|java|rb|c|cc|cpp|h|cs|swift|kt)$/.test(path);
52288
+ }
52289
+ __name(isExampleFile, "isExampleFile");
52290
+ function frequentlyModifiedFile(cwd2, signal) {
52291
+ return new Promise((resolve9) => {
52292
+ execFile3(
52293
+ "git",
52294
+ ["log", "--name-only", "--pretty=format:", "-n", "200"],
52295
+ { cwd: cwd2, signal, maxBuffer: 4 * 1024 * 1024, timeout: 5e3 },
52296
+ (error, stdout) => {
52297
+ if (error) return resolve9(void 0);
52298
+ const counts2 = /* @__PURE__ */ new Map();
52299
+ for (const line of stdout.split("\n")) {
52300
+ const path = line.trim();
52301
+ if (path && isExampleFile(path)) counts2.set(path, (counts2.get(path) ?? 0) + 1);
52302
+ }
52303
+ let best;
52304
+ let bestCount = 0;
52305
+ for (const [path, count2] of counts2) {
52306
+ if (count2 > bestCount) {
52307
+ best = path;
52308
+ bestCount = count2;
52309
+ }
52310
+ }
52311
+ resolve9(best);
51946
52312
  }
51947
- ]);
52313
+ );
52314
+ });
52315
+ }
52316
+ __name(frequentlyModifiedFile, "frequentlyModifiedFile");
52317
+
52318
+ // src/tui/recap-setting.ts
52319
+ var OFF_WORDS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
52320
+ var ON_WORDS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
52321
+ function recapEnabled(input) {
52322
+ const word = input.env.NAMZU_RECAP?.trim().toLowerCase();
52323
+ if (word !== void 0 && OFF_WORDS.has(word)) return false;
52324
+ if (word !== void 0 && ON_WORDS.has(word)) return true;
52325
+ if (!input.interactive) return false;
52326
+ return input.tui?.recap !== false;
52327
+ }
52328
+ __name(recapEnabled, "recapEnabled");
52329
+ function recapWaitMs(env3) {
52330
+ const raw = env3.NAMZU_RECAP_WAIT_MS?.trim();
52331
+ if (raw === void 0 || !/^\d{1,9}$/u.test(raw)) return RECAP_WAIT_MS;
52332
+ return Number(raw);
52333
+ }
52334
+ __name(recapWaitMs, "recapWaitMs");
52335
+ function setRecapSetting(on, opts = {}) {
52336
+ const env3 = opts.env ?? process.env;
52337
+ try {
52338
+ const target = { ...opts.home ? { home: opts.home } : {}, env: env3 };
52339
+ if (on) deleteUserConfigValue(["tui", "recap"], target);
52340
+ else setUserConfigValue(["tui", "recap"], false, target);
52341
+ } catch (error) {
52342
+ return `${explainFailure(error, "Could not save that setting.")} This conversation ${on ? "shows" : "skips"} recaps until it ends.`;
51948
52343
  }
51949
- if (event.isError && event.toolName.toLowerCase() === "agent") {
51950
- const text = toolFailureText(event.output, false);
51951
- const full = toolFailureText(event.output, true).split("\n");
51952
- const lines = text.split("\n");
51953
- return rows([
51954
- {
51955
- role: "tool",
51956
- content: headOf(event, start),
51957
- glyph: "\u25CF",
51958
- glyphColor: tokenColor("status.error"),
51959
- detail: full,
51960
- shell: failureBody(full, text !== full.join("\n") ? lines : void 0)
51961
- }
51962
- ]);
52344
+ const saved = on ? "Recaps are on: after a few minutes away, a one-line recap of where things stand is shown when you come back." : "Recaps are off. /config recap on turns them back on; /recap still writes one on request.";
52345
+ const word = env3.NAMZU_RECAP?.trim().toLowerCase();
52346
+ if (word !== void 0 && (OFF_WORDS.has(word) || ON_WORDS.has(word))) {
52347
+ const forced = ON_WORDS.has(word);
52348
+ if (forced !== on) {
52349
+ return `${saved} But NAMZU_RECAP is set in the environment and turns them ${forced ? "on" : "off"} on the next start; this conversation follows your choice.`;
52350
+ }
51963
52351
  }
51964
- const catalogue = !event.isError && event.toolName === "agent_models" && event.output !== void 0 ? modelCatalogueView(event.output) : void 0;
51965
- if (catalogue !== void 0) {
51966
- return rows([
51967
- {
51968
- role: "tool",
51969
- content: catalogue,
51970
- glyph: "\u25CF",
51971
- detail: event.output?.split("\n"),
51972
- glyphColor: tokenColor("status.ok"),
51973
- meta: EXPAND_HINT,
51974
- activity: "catalogue"
51975
- }
51976
- ]);
52352
+ return saved;
52353
+ }
52354
+ __name(setRecapSetting, "setRecapSetting");
52355
+ function describeRecapSetting(input) {
52356
+ const fromFiles = input.tui?.recap !== false;
52357
+ const word = input.env.NAMZU_RECAP?.trim().toLowerCase();
52358
+ const lines = [`Recaps: ${input.enabledNow ? "on" : "off"} in this conversation.`];
52359
+ lines.push(`Config files: ${fromFiles ? "on (the default)" : "off"}.`);
52360
+ if (word !== void 0 && (OFF_WORDS.has(word) || ON_WORDS.has(word))) {
52361
+ lines.push(`NAMZU_RECAP is set and turns them ${ON_WORDS.has(word) ? "on" : "off"}.`);
51977
52362
  }
51978
- const evidence = !event.isError && event.output !== void 0 ? conversationEvidenceView(event.toolName, event.output) : void 0;
51979
- if (evidence !== void 0) {
51980
- return rows([
51981
- {
51982
- role: "tool",
51983
- content: evidence.content,
51984
- glyph: "\u25CF",
51985
- detail: evidence.detail,
51986
- glyphColor: tokenColor("status.ok"),
51987
- meta: EXPAND_HINT,
51988
- activity: "evidence"
51989
- }
51990
- ]);
52363
+ lines.push("/config recap on|off changes it; /recap writes one now.");
52364
+ return lines.join("\n");
52365
+ }
52366
+ __name(describeRecapSetting, "describeRecapSetting");
52367
+
52368
+ // src/tui/recap-turns.ts
52369
+ function kindOf(message) {
52370
+ if (message.kind === "recap") return "recap";
52371
+ if (message.pending) return void 0;
52372
+ if (message.role === "user" && !message.sourceDelivery && message.content.trim().length > 0) {
52373
+ return "prompt";
51991
52374
  }
51992
- if (event.shell && start?.command !== void 0) {
51993
- const failed = event.isError || event.shell.failed;
51994
- const command = start.command;
51995
- const header = command ? formatToolCall(event.toolName, shellCommandHeader(command)) : start.label;
51996
- const full = command ? formatToolCall(event.toolName, shellCommandFull(command)) : void 0;
51997
- const settled2 = event.isError && event.shell.stderr.length === 0 ? { ...event.shell, stdout: [], stderr: event.shell.stdout, failed: true } : { ...event.shell, failed };
51998
- return rows([
51999
- {
52000
- role: "tool",
52001
- content: header,
52002
- glyph: "\u25CF",
52003
- detail: [...settled2.stdout, ...settled2.stderr],
52004
- glyphColor: failed ? tokenColor("status.error") : tokenColor("status.ok"),
52005
- shell: full !== void 0 && full !== header ? { ...settled2, fullHeader: full } : settled2
52006
- }
52007
- ]);
52375
+ if (message.role === "assistant" && message.content.trim().length > 0) return "reply";
52376
+ return void 0;
52377
+ }
52378
+ __name(kindOf, "kindOf");
52379
+ function recapRows(messages) {
52380
+ const rows = [];
52381
+ for (const message of messages) {
52382
+ const kind = kindOf(message);
52383
+ if (kind !== void 0) rows.push(kind);
52008
52384
  }
52009
- if (event.isError) return rows(failedCallRows(event, start));
52010
- const elapsed2 = settledElapsed(event.durationMs ?? ctx.elapsedMs);
52011
- const list = [
52012
- {
52013
- role: "tool",
52014
- content: headOf(event, start),
52015
- glyph: "\u25CF",
52016
- // The change to a file is drawn once, under its result.
52017
- detail: event.diff ? void 0 : start?.detail,
52018
- glyphColor: tokenColor("status.ok"),
52019
- ...elapsed2 !== void 0 ? { meta: elapsed2 } : {}
52020
- }
52021
- ];
52022
- if (!event.hidden && (event.summary.length > 0 || (event.detail?.length ?? 0) > 0)) {
52023
- list.push({
52024
- role: "tool",
52025
- content: event.diff?.summary ? spansText(event.diff.summary) : event.summary,
52026
- glyph: "\u23BF",
52027
- detail: event.detail,
52028
- ...event.diff ? { diff: event.diff } : {}
52029
- });
52385
+ return rows;
52386
+ }
52387
+ __name(recapRows, "recapRows");
52388
+ function recapTurns(messages) {
52389
+ const turns = [];
52390
+ for (const message of messages) {
52391
+ const kind = kindOf(message);
52392
+ if (kind === "prompt") turns.push({ role: "user", text: message.content });
52393
+ else if (kind === "reply") turns.push({ role: "assistant", text: message.content });
52030
52394
  }
52031
- return rows(list);
52395
+ return turns;
52032
52396
  }
52033
- __name(toolEndRows, "toolEndRows");
52397
+ __name(recapTurns, "recapTurns");
52034
52398
 
52035
52399
  // src/tui/restored-rows.ts
52036
52400
  var NO_TRAIL = {
@@ -54410,20 +54774,73 @@ ${blocks.join("\n\n")}`;
54410
54774
  setActiveTools([]);
54411
54775
  }, []);
54412
54776
  const permissionResolveRef = (0, import_react59.useRef)(null);
54413
- const permissionQueueRef = (0, import_react59.useRef)([]);
54414
54777
  const permissionShownRef = (0, import_react59.useRef)(null);
54415
- const [queuedPermissionCount, setQueuedPermissionCount] = (0, import_react59.useState)(0);
54778
+ const [permissionReason, setPermissionReasonState] = (0, import_react59.useState)(null);
54779
+ const permissionReasonRef = (0, import_react59.useRef)(null);
54780
+ const setPermissionReason = (0, import_react59.useCallback)((next) => {
54781
+ permissionReasonRef.current = next;
54782
+ setPermissionReasonState(next);
54783
+ }, []);
54784
+ const [permissionCount, setPermissionCount] = (0, import_react59.useState)(void 0);
54785
+ const perCallReviewRef = (0, import_react59.useRef)(null);
54786
+ if (perCallReviewRef.current === null) {
54787
+ perCallReviewRef.current = createTerminalPerCallReview({
54788
+ mode: /* @__PURE__ */ __name(() => permissionModeRef.current, "mode")
54789
+ });
54790
+ }
54791
+ const refusalEndedTurnRef = (0, import_react59.useRef)(false);
54792
+ const permissionAsksRef = (0, import_react59.useRef)(null);
54793
+ if (permissionAsksRef.current === null) {
54794
+ permissionAsksRef.current = new AskQueue(
54795
+ (pending) => {
54796
+ setPermissionReviewOffset(0);
54797
+ setPermissionChoice(0);
54798
+ setPermissionReason(null);
54799
+ permissionShownRef.current = pending;
54800
+ if (pending) {
54801
+ permissionOpenedAtRef.current = Date.now();
54802
+ permissionResolveRef.current = (decision) => permissionAsksRef.current?.answer(decision);
54803
+ setPermissionDetailsOpen(!pending.summary.complete);
54804
+ setPermission(pending);
54805
+ setState("awaiting-permission");
54806
+ } else {
54807
+ permissionOpenedAtRef.current = null;
54808
+ permissionResolveRef.current = null;
54809
+ setPermissionDetailsOpen(false);
54810
+ setPermission(null);
54811
+ setState((current) => current === "awaiting-permission" ? "thinking" : current);
54812
+ }
54813
+ },
54814
+ () => setPermissionCount(permissionAsksRef.current?.count())
54815
+ );
54816
+ }
54817
+ const permissionAsks = permissionAsksRef.current;
54818
+ const rulesChanged = (0, import_react59.useCallback)(
54819
+ (newAllows) => {
54820
+ queueMicrotask(() => {
54821
+ const perCallReview = perCallReviewRef.current;
54822
+ perCallReview?.rulesChanged();
54823
+ const commands = session?.commandArguments;
54824
+ permissionAsks.settleWhere((pending) => {
54825
+ if (pending.perCall || pending.batchOnly || pending.screenConsent) return void 0;
54826
+ if (pending.withheld.length > 0 || pending.toolCalls.length === 0) return void 0;
54827
+ const covered = pending.toolCalls.every((call) => {
54828
+ if (perCallReview?.modeCovers(call)) return true;
54829
+ if (!newAllows || !commands) return false;
54830
+ const allows = allowsFor(call, commands);
54831
+ return allows?.every((allow) => newAllows.some((added) => sameAllow(added, allow))) === true;
54832
+ });
54833
+ return covered ? { kind: "approve" } : void 0;
54834
+ });
54835
+ });
54836
+ },
54837
+ [permissionAsks, session]
54838
+ );
54416
54839
  (0, import_react59.useEffect)(
54417
54840
  () => () => {
54418
- const decision = {
54419
- kind: "reject",
54420
- feedback: "The approval screen closed."
54421
- };
54422
- permissionResolveRef.current?.(decision);
54423
- permissionResolveRef.current = null;
54424
- for (const pending of permissionQueueRef.current.splice(0)) pending.resolve(decision);
54841
+ permissionAsks.closeAll({ kind: "reject", feedback: "The approval screen closed." });
54425
54842
  },
54426
- []
54843
+ [permissionAsks]
54427
54844
  );
54428
54845
  const permissionOpenedAtRef = (0, import_react59.useRef)(null);
54429
54846
  const trustShownAtRef = (0, import_react59.useRef)(null);
@@ -55380,6 +55797,7 @@ ${blocks.join("\n\n")}`;
55380
55797
  permissionModeSourceRef.current = "session";
55381
55798
  setPermissionModeState(mode);
55382
55799
  void session.setPermissionMode?.(mode);
55800
+ rulesChanged();
55383
55801
  if (announce) {
55384
55802
  pushMessage(
55385
55803
  "system",
@@ -55393,7 +55811,7 @@ ${blocks.join("\n\n")}`;
55393
55811
  );
55394
55812
  }
55395
55813
  },
55396
- [pushMessage, session]
55814
+ [pushMessage, rulesChanged, session]
55397
55815
  );
55398
55816
  const applyPermissionMode = (0, import_react59.useCallback)(
55399
55817
  (mode, announce = true) => {
@@ -57268,6 +57686,8 @@ ${blocks.join("\n\n")}`;
57268
57686
  permissionMode: permissionModeRef.current,
57269
57687
  currentPermissionMode: /* @__PURE__ */ __name(() => permissionModeRef.current, "currentPermissionMode"),
57270
57688
  onAutoModeLimit: handleAutoModeLimit,
57689
+ // The skills the operator has on, as a new turn carries them.
57690
+ extraSystem: composeSkillsPrompt(activeSkills) || void 0,
57271
57691
  ...resume?.handoffReason ? {
57272
57692
  systemNote: handoffContinuationNote(resume.handoffReason)
57273
57693
  } : {}
@@ -57292,6 +57712,7 @@ ${blocks.join("\n\n")}`;
57292
57712
  return true;
57293
57713
  },
57294
57714
  [
57715
+ activeSkills,
57295
57716
  advanceQueueContinuation,
57296
57717
  detected,
57297
57718
  finalizeMessage,
@@ -57390,58 +57811,33 @@ ${blocks.join("\n\n")}`;
57390
57811
  batchOnly: pending.batchOnly === true,
57391
57812
  screenConsent: pending.screenConsent === true,
57392
57813
  withheld: pending.withheld.length > 0,
57814
+ endsTurn: endsTurnOnNo(pending),
57393
57815
  mode: permissionModeRef.current,
57394
57816
  ...session?.allowForSession && session.commandArguments ? {
57395
57817
  commandArguments: session.commandArguments,
57396
57818
  rememberWhere: displayPath(ctx.cwd, 28)
57397
57819
  } : {}
57398
57820
  }), "permissionAnswerOptions");
57399
- const resolvePermission = (0, import_react59.useCallback)(
57400
- (requested) => {
57401
- const resolve9 = permissionResolveRef.current;
57402
- const shown = permissionShownRef.current;
57403
- permissionShownRef.current = null;
57404
- let decision = requested;
57405
- if (requested.kind === "approve" && shown) {
57406
- const again = buildPermissionReview(shown.source.toolCalls);
57407
- if (!again.ok || again.envelopeHash !== shown.envelopeHash)
57408
- decision = {
57409
- kind: "reject",
57410
- feedback: "Refused: the tool input changed after it was shown for approval."
57411
- };
57412
- }
57413
- permissionResolveRef.current = null;
57414
- permissionOpenedAtRef.current = null;
57415
- setPermissionReviewOffset(0);
57416
- setPermissionDetailsOpen(false);
57417
- setPermissionChoice(0);
57418
- setPermission(null);
57419
- if (resolve9) {
57420
- setState("thinking");
57421
- resolve9(decision);
57422
- }
57423
- const next = permissionQueueRef.current.shift();
57424
- setQueuedPermissionCount(permissionQueueRef.current.length);
57425
- if (next) {
57426
- permissionResolveRef.current = next.resolve;
57427
- permissionOpenedAtRef.current = Date.now();
57428
- setPermissionDetailsOpen(!next.permission.summary.complete);
57429
- permissionShownRef.current = next.permission;
57430
- setPermission(next.permission);
57431
- setState("awaiting-permission");
57432
- }
57433
- },
57434
- [setPermissionDetailsOpen, setPermissionReviewOffset]
57435
- );
57821
+ const resolvePermission = (0, import_react59.useCallback)((requested) => {
57822
+ const shown = permissionShownRef.current;
57823
+ if (!shown) return;
57824
+ let decision = requested;
57825
+ if (requested.kind === "approve") {
57826
+ const again = buildPermissionReview(shown.source.toolCalls);
57827
+ if (!again.ok || again.envelopeHash !== shown.envelopeHash)
57828
+ decision = {
57829
+ kind: "reject",
57830
+ feedback: "Refused: the tool input changed after it was shown for approval."
57831
+ };
57832
+ }
57833
+ setState("thinking");
57834
+ if (decision.kind === "reject" && decision.endTurn === true) refusalEndedTurnRef.current = true;
57835
+ permissionAsksRef.current?.answer(decision);
57836
+ }, []);
57436
57837
  const interruptTurn = (0, import_react59.useCallback)(
57437
57838
  (recoverInput = false) => {
57438
57839
  const cancelledSwitch = cancelPendingModelSwitch();
57439
- for (const pending of permissionQueueRef.current.splice(0)) {
57440
- pending.resolve({ kind: "reject", feedback: "User interrupted." });
57441
- }
57442
- setQueuedPermissionCount(0);
57443
- if (permissionResolveRef.current)
57444
- resolvePermission({ kind: "reject", feedback: "User interrupted." });
57840
+ permissionAsksRef.current?.closeAll({ kind: "reject", feedback: "User interrupted." });
57445
57841
  const ac = abortRef.current;
57446
57842
  if (!ac) {
57447
57843
  if (admissionRef.current) {
@@ -57488,7 +57884,6 @@ ${blocks.join("\n\n")}`;
57488
57884
  discardQueued,
57489
57885
  goalActivation,
57490
57886
  replaceQueued,
57491
- resolvePermission,
57492
57887
  setQueuePause,
57493
57888
  wakeGoalDriver
57494
57889
  ]
@@ -58376,43 +58771,60 @@ ${plain(err)}`
58376
58771
  withheld: review.withheld
58377
58772
  });
58378
58773
  const siteNotes = browserSiteNotes(req.toolCalls, browserControlRef.current?.status());
58379
- return new Promise((resolve9) => {
58380
- if (permissionResolveRef.current) {
58381
- permissionQueueRef.current.push({
58382
- permission: {
58383
- ...req,
58384
- review: review.text,
58385
- summary: summary2,
58386
- siteNotes,
58387
- withheld: review.withheld,
58388
- source: req,
58389
- envelopeHash: review.envelopeHash
58390
- },
58391
- resolve: resolve9
58392
- });
58393
- setQueuedPermissionCount(permissionQueueRef.current.length);
58394
- return;
58774
+ const pending = {
58775
+ ...req,
58776
+ review: review.text,
58777
+ summary: summary2,
58778
+ siteNotes,
58779
+ withheld: review.withheld,
58780
+ source: req,
58781
+ envelopeHash: review.envelopeHash
58782
+ };
58783
+ const asks = permissionAsksRef.current;
58784
+ const perCallReview = perCallReviewRef.current;
58785
+ if (!asks || !perCallReview) {
58786
+ return Promise.resolve({
58787
+ kind: "reject",
58788
+ feedback: "The approval screen closed."
58789
+ });
58790
+ }
58791
+ if (req.perCall) {
58792
+ const presenter = reviewSessionRef.current?.presenter;
58793
+ for (const [index, call] of req.toolCalls.entries()) {
58794
+ perCallReview.hold(
58795
+ call.id,
58796
+ review.withheld.some((held) => held.index === index)
58797
+ );
58798
+ const row = presenter ? queuedToolRow(call, req.turnId, presenter, ctxRef.current.cwd, Date.now()) : void 0;
58799
+ if (row) {
58800
+ activeToolsRef.current = withQueuedRow(activeToolsRef.current, row);
58801
+ setActiveTools(activeToolsRef.current);
58802
+ }
58395
58803
  }
58396
- permissionResolveRef.current = resolve9;
58397
- permissionOpenedAtRef.current = Date.now();
58398
- setPermissionReviewOffset(0);
58399
- setPermissionDetailsOpen(!summary2.complete);
58400
- const shown = {
58401
- ...req,
58402
- review: review.text,
58403
- summary: summary2,
58404
- siteNotes,
58405
- withheld: review.withheld,
58406
- source: req,
58407
- envelopeHash: review.envelopeHash
58408
- };
58409
- permissionShownRef.current = shown;
58410
- setPermission(shown);
58411
- setState("awaiting-permission");
58412
- announceApproval();
58804
+ }
58805
+ const background = reviewSource(req, scopeRef.current?.sessionId) !== void 0;
58806
+ const answered = asks.enqueue(pending, {
58807
+ background,
58808
+ ...req.signal ? { signal: req.signal } : {}
58809
+ });
58810
+ if (asks.shown === pending) announceApproval();
58811
+ return answered.then((decision) => {
58812
+ if (req.perCall) {
58813
+ for (const call of req.toolCalls) {
58814
+ perCallReview.release(call.id);
58815
+ if (decision === CLOSED_QUESTION) continue;
58816
+ activeToolsRef.current = decision.kind === "approve" ? withStartedRow(
58817
+ activeToolsRef.current,
58818
+ call.id,
58819
+ Date.now()
58820
+ ) : withoutQueuedRow(activeToolsRef.current, call.id);
58821
+ }
58822
+ setActiveTools(activeToolsRef.current);
58823
+ }
58824
+ return decision;
58413
58825
  });
58414
58826
  },
58415
- [announceApproval, setPermissionDetailsOpen, setPermissionReviewOffset]
58827
+ [announceApproval]
58416
58828
  );
58417
58829
  const askQuestion = (0, import_react59.useCallback)(
58418
58830
  (question, signal) => new Promise((resolve9) => {
@@ -58769,7 +59181,7 @@ ${plain(err)}`
58769
59181
  ...event.proposed ? { proposed: event.proposed } : {},
58770
59182
  ...event.web ? { web: event.web, progress: webLiveStatus(event.web) } : {}
58771
59183
  };
58772
- activeToolsRef.current = [...activeToolsRef.current, tool];
59184
+ activeToolsRef.current = withTakenOverRow(activeToolsRef.current, tool);
58773
59185
  setActiveTools(activeToolsRef.current);
58774
59186
  break;
58775
59187
  }
@@ -58985,6 +59397,13 @@ ${plain(err)}`
58985
59397
  outcome: st.completed ? "completed" : "stopped"
58986
59398
  };
58987
59399
  closeAssistant();
59400
+ if (refusalEndedTurnRef.current) {
59401
+ refusalEndedTurnRef.current = false;
59402
+ if (event.stopReason === "cancelled") {
59403
+ const row = interruptionRow({ callRunning: false });
59404
+ pushMessage("system", row.content, false, row.glyph, void 0, row.color);
59405
+ }
59406
+ }
58988
59407
  const stopNotice = describeTurnStop(event.stopReason, event.budget);
58989
59408
  if (stopNotice) pushSystem("warning", stopNotice);
58990
59409
  if (st.startedAt !== void 0) {
@@ -59266,6 +59685,7 @@ ${jobLines.map(([, line]) => `- ${line}`).join("\n")}`] : []
59266
59685
  };
59267
59686
  }, "markNonGoalAbnormal");
59268
59687
  abortRef.current = ac;
59688
+ refusalEndedTurnRef.current = false;
59269
59689
  activeTurnTokenRef.current = turnToken;
59270
59690
  const turnGeneration = conversationGenRef.current;
59271
59691
  unsettledTurnGenerationsRef.current.set(turnToken, turnGeneration);
@@ -59481,6 +59901,8 @@ ${[...workflowNoticeSnapshot.values()].join("\n\n")}` : void 0,
59481
59901
  ...goalRound ? { goalRound } : {},
59482
59902
  // The mode above decides whether this callback is consulted.
59483
59903
  onPermission: askPermission,
59904
+ // The terminal asks about one call at a time while the batch runs.
59905
+ ...perCallReviewRef.current ? { perCallReview: perCallReviewRef.current.config } : {},
59484
59906
  // A workflow this turn starts outlives it, so its agents cannot borrow
59485
59907
  // `askPermission`, which belongs to this turn. They ask through the
59486
59908
  // conversation instead, for as long as it is the one on screen.
@@ -59646,19 +60068,10 @@ ${[...workflowNoticeSnapshot.values()].join("\n\n")}` : void 0,
59646
60068
  }
59647
60069
  abortRef.current = null;
59648
60070
  if (ownsTurn) activeTurnTokenRef.current = null;
59649
- permissionResolveRef.current?.({
60071
+ permissionAsksRef.current?.closeAll({
59650
60072
  kind: "reject",
59651
60073
  feedback: "The owning turn ended."
59652
60074
  });
59653
- for (const pending2 of permissionQueueRef.current.splice(0))
59654
- pending2.resolve({
59655
- kind: "reject",
59656
- feedback: "The owning turn ended."
59657
- });
59658
- setQueuedPermissionCount(0);
59659
- permissionResolveRef.current = null;
59660
- permissionOpenedAtRef.current = null;
59661
- setPermission(null);
59662
60075
  clearActiveTools();
59663
60076
  setState("idle");
59664
60077
  if (ownsTurn) {
@@ -62118,6 +62531,30 @@ ${plugins.map((plugin) => {
62118
62531
  }
62119
62532
  if (permissionResolveRef.current) {
62120
62533
  const ch = input.toLowerCase();
62534
+ const typing = permissionReasonRef.current;
62535
+ if (typing !== null) {
62536
+ if (key.ctrl && input === "c") {
62537
+ interruptTurn();
62538
+ return;
62539
+ }
62540
+ if (key.escape) {
62541
+ setPermissionReason(null);
62542
+ return;
62543
+ }
62544
+ if (key.return) {
62545
+ const refusal = noWithReason(typing);
62546
+ if (refusal) resolvePermission(refusal);
62547
+ return;
62548
+ }
62549
+ if (key.backspace || key.delete) {
62550
+ setPermissionReason(Array.from(typing).slice(0, -1).join(""));
62551
+ return;
62552
+ }
62553
+ if (!key.ctrl && !key.meta && !key.tab && !key.upArrow && !key.downArrow) {
62554
+ setPermissionReason(appendTypedReason(typing, input));
62555
+ }
62556
+ return;
62557
+ }
62121
62558
  if (permission && ch === "d") {
62122
62559
  setPermissionReviewOffset(0);
62123
62560
  setPermissionDetailsOpen(!permissionDetailsOpenRef.current);
@@ -62133,10 +62570,7 @@ ${plugins.map((plugin) => {
62133
62570
  if (permission && (key.pageUp || key.pageDown || key.home || key.end)) {
62134
62571
  const source = permissionDetailsOpenRef.current ? permission.review : permission.summary.compactText ?? permission.summary.text;
62135
62572
  const count2 = permissionReviewRows(source, terminal.columns).length;
62136
- const pageRows = Math.max(
62137
- 1,
62138
- permissionReviewPageRows(terminal.rows) - (reviewSource(permission, scopeRef.current?.sessionId) ? 1 : 0)
62139
- );
62573
+ const pageRows = Math.max(1, permissionReviewPageRows(terminal.rows));
62140
62574
  const maxOffset = Math.max(0, count2 - pageRows);
62141
62575
  const current = Math.min(permissionReviewOffsetRef.current, maxOffset);
62142
62576
  const next = key.home ? 0 : key.end ? maxOffset : key.pageUp ? Math.max(0, current - pageRows) : Math.min(maxOffset, current + pageRows);
@@ -62144,21 +62578,30 @@ ${plugins.map((plugin) => {
62144
62578
  return;
62145
62579
  }
62146
62580
  if (key.ctrl && input === "c") {
62147
- interruptTurn();
62581
+ if (permission && endsTurnOnNo(permission)) {
62582
+ resolvePermission(plainNo(true));
62583
+ return;
62584
+ }
62585
+ interruptWithRow(false);
62148
62586
  return;
62149
62587
  }
62588
+ const noDecision = permission ? plainNo(endsTurnOnNo(permission)) : plainNo(false);
62150
62589
  if (ch === "n" || key.escape) {
62151
- resolvePermission({ kind: "reject", declined: {} });
62590
+ resolvePermission(noDecision);
62152
62591
  return;
62153
62592
  }
62154
- if (!approvalIsDeliberate(permissionOpenedAtRef.current, Date.now())) return;
62155
62593
  const answers = permission ? permissionAnswers(permission.toolCalls, permissionAnswerOptions(permission)) : [];
62594
+ if (key.tab && !key.shift) {
62595
+ if (answers[permissionChoiceRef.current]?.kind === "reject") setPermissionReason("");
62596
+ return;
62597
+ }
62598
+ if (!approvalIsDeliberate(permissionOpenedAtRef.current, Date.now())) return;
62156
62599
  const numbered = /^[1-9]$/.test(ch) ? Number(ch) - 1 : null;
62157
62600
  const chosen = key.return ? permissionChoiceRef.current : numbered;
62158
- const answer = ch === "y" ? answers[0] : chosen !== null ? answers[chosen] : void 0;
62601
+ const answer = key.tab && key.shift ? answers.find((candidate) => candidate.kind === "approve-edits") : ch === "y" ? answers[0] : chosen !== null ? answers[chosen] : void 0;
62159
62602
  if (!answer) return;
62160
62603
  if (answer.kind === "reject") {
62161
- resolvePermission({ kind: "reject", declined: {} });
62604
+ resolvePermission(noDecision);
62162
62605
  return;
62163
62606
  }
62164
62607
  if (answer.kind === "approve-edits") applyPermissionMode("accept-edits", false);
@@ -62167,6 +62610,7 @@ ${plugins.map((plugin) => {
62167
62610
  if (notice) pushMessage("system", notice);
62168
62611
  }
62169
62612
  resolvePermission({ kind: "approve" });
62613
+ if (answer.kind === "approve-rule") rulesChanged(answer.allows);
62170
62614
  return;
62171
62615
  }
62172
62616
  const shellView = jobSurfaceRef.current;
@@ -62800,7 +63244,7 @@ ${plugins.map((plugin) => {
62800
63244
  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 ? "enter continue \xB7 esc stop" : goalStatus && phase === "ready" && state === "idle" ? void 0 : hintForPhase(phase, state, composerHasDraft);
62801
63245
  const permissionSource = reviewSource(permission, scopeRef.current?.sessionId);
62802
63246
  const permissionOwner = permissionSource ? subagents.find((agent) => agent.sessionId === permissionSource) : void 0;
62803
- const permissionSourceLabel = permissionSource ? permissionOwner ? `Agent: ${permissionOwner.description}` : "Agent: another agent" : void 0;
63247
+ const permissionSourceLabel = permissionSource ? permissionOwner ? `from the ${permissionOwner.description} agent` : "from another agent" : void 0;
62804
63248
  const displayedPermissionMode = permissionMode;
62805
63249
  const highestEffort = highestReasoningEffort(session?.reasoningEffortLevels);
62806
63250
  const composerTriggers = composerTriggersOn ? {
@@ -62974,8 +63418,10 @@ ${plugins.map((plugin) => {
62974
63418
  detailsOpen: permissionDetailsOpen,
62975
63419
  reviewOffset: permissionReviewOffset,
62976
63420
  choice: permissionChoice,
62977
- queuedCount: queuedPermissionCount,
62978
- sourceLabel: permissionSourceLabel,
63421
+ ...permissionCount ? { count: permissionCount } : {},
63422
+ ...permissionSourceLabel ? { from: permissionSourceLabel } : {},
63423
+ ...permissionReason !== null ? { reason: permissionReason } : {},
63424
+ endsTurn: endsTurnOnNo(permission),
62979
63425
  columns: terminal.columns,
62980
63426
  rows: terminal.rows,
62981
63427
  batchOnly: permission.batchOnly === true,
@@ -63311,6 +63757,10 @@ function reviewSource(request, currentSessionId) {
63311
63757
  return typeof sessionId === "string" && sessionId !== currentSessionId ? sessionId : void 0;
63312
63758
  }
63313
63759
  __name(reviewSource, "reviewSource");
63760
+ function endsTurnOnNo(pending) {
63761
+ return pending.perCall === true && pending.batchOnly !== true && pending.screenConsent !== true;
63762
+ }
63763
+ __name(endsTurnOnNo, "endsTurnOnNo");
63314
63764
  function labelOfOption(question, optionId) {
63315
63765
  return question.options.find((option) => option.id === optionId)?.label ?? optionId;
63316
63766
  }
@@ -64072,4 +64522,4 @@ react/cjs/react-jsx-runtime.development.js:
64072
64522
  * LICENSE file in the root directory of this source tree.
64073
64523
  *)
64074
64524
  */
64075
- //# sourceMappingURL=tui-RU6CRMLX.js.map
64525
+ //# sourceMappingURL=tui-BP7MYQG2.js.map