@namzu/cli 41.2.2 → 42.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 (487) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/dist/bin-main.d.ts.map +1 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/chunks/{acp-5RFAFTQU.js → acp-ADQ2PRAY.js} +48 -48
  5. package/dist/chunks/{activity-command-XLF5EAM5.js → activity-command-JROQLBPA.js} +14 -15
  6. package/dist/chunks/activity-command-JROQLBPA.js.map +6 -0
  7. package/dist/chunks/{add-Z6Y5DOCM.js → add-ILLLF6YP.js} +25 -25
  8. package/dist/chunks/{agent-U4NFC4DT.js → agent-YQI5KOPV.js} +34 -35
  9. package/dist/chunks/agent-session-3MUZCWQ4.js +58 -0
  10. package/dist/chunks/{archive-P47MRHE2.js → archive-55KJKGJB.js} +11 -11
  11. package/dist/chunks/{bin-main-B3QOTIEH.js → bin-main-332F5KRZ.js} +13 -6
  12. package/dist/chunks/{bin-main-B3QOTIEH.js.map → bin-main-332F5KRZ.js.map} +1 -1
  13. package/dist/chunks/{browser-QN24UC7K.js → browser-C6AOJ3CH.js} +6 -6
  14. package/dist/chunks/{chat-HRORSJPH.js → chat-45H5F3KI.js} +16 -16
  15. package/dist/chunks/{chunk-TU46IHIV.js → chunk-23NRJ2RC.js} +5 -5
  16. package/dist/chunks/chunk-27R3OTVS.js +14 -0
  17. package/dist/chunks/chunk-27R3OTVS.js.map +6 -0
  18. package/dist/chunks/{chunk-LFI6O7WL.js → chunk-2OVZNENW.js} +43 -2
  19. package/dist/chunks/chunk-2OVZNENW.js.map +6 -0
  20. package/dist/chunks/{chunk-CEIYJWZ2.js → chunk-35VTE7V5.js} +2 -2
  21. package/dist/chunks/chunk-3F3V2PB7.js +56 -0
  22. package/dist/chunks/chunk-3F3V2PB7.js.map +6 -0
  23. package/dist/chunks/{chunk-72CFHDKQ.js → chunk-3LNTQLQ4.js} +14 -14
  24. package/dist/chunks/{chunk-NTPBXJMK.js → chunk-4IIEEOCA.js} +66 -6
  25. package/dist/chunks/chunk-4IIEEOCA.js.map +6 -0
  26. package/dist/chunks/{chunk-WBTXYSAB.js → chunk-4NO5XFK2.js} +2 -2
  27. package/dist/chunks/chunk-4TS6ZPOZ.js +363 -0
  28. package/dist/chunks/chunk-4TS6ZPOZ.js.map +6 -0
  29. package/dist/chunks/{chunk-UEXQA2UW.js → chunk-5XWMKWQQ.js} +65 -5
  30. package/dist/chunks/chunk-5XWMKWQQ.js.map +6 -0
  31. package/dist/chunks/{chunk-4SP6H34B.js → chunk-6GBZAUYW.js} +2 -2
  32. package/dist/chunks/{chunk-L2GZVP5H.js → chunk-6LVWHXT6.js} +10 -15
  33. package/dist/chunks/chunk-6LVWHXT6.js.map +6 -0
  34. package/dist/chunks/{chunk-2UPDDG7V.js → chunk-6PNBIMWH.js} +3 -3
  35. package/dist/chunks/{chunk-25XPE4N6.js → chunk-6S4R2USK.js} +3 -3
  36. package/dist/chunks/{chunk-4WWLRVYU.js → chunk-7E3V7NNN.js} +1282 -523
  37. package/dist/chunks/chunk-7E3V7NNN.js.map +6 -0
  38. package/dist/chunks/{chunk-VCKNYZYH.js → chunk-A3AF5WXZ.js} +6 -6
  39. package/dist/chunks/{chunk-G34P5PIK.js → chunk-A4CKLHKM.js} +4 -4
  40. package/dist/chunks/{chunk-Y5QV6NZK.js → chunk-AZPS37AQ.js} +2 -2
  41. package/dist/chunks/{chunk-2UYBHC3L.js → chunk-BDLDDNNO.js} +37 -6
  42. package/dist/chunks/chunk-BDLDDNNO.js.map +6 -0
  43. package/dist/chunks/{chunk-WJ7XYOSE.js → chunk-BRKD6FMO.js} +2 -2
  44. package/dist/chunks/{chunk-I55BEPVH.js → chunk-CW2N2QS2.js} +4 -4
  45. package/dist/chunks/{chunk-2VQ475KY.js → chunk-DLL2FPUY.js} +2 -2
  46. package/dist/chunks/{chunk-CIIMESY2.js → chunk-ESZ7X37S.js} +4 -4
  47. package/dist/chunks/{chunk-CAPC66Q6.js → chunk-EWSIGY2A.js} +4 -4
  48. package/dist/chunks/{chunk-JEULHVUH.js → chunk-F6WVRMVY.js} +864 -283
  49. package/dist/chunks/chunk-F6WVRMVY.js.map +6 -0
  50. package/dist/chunks/{chunk-CM2I2L4G.js → chunk-FMEGRBJP.js} +2 -2
  51. package/dist/chunks/{chunk-JKXCLMMZ.js → chunk-FSKJ3EZC.js} +2 -2
  52. package/dist/chunks/chunk-G5RAECIB.js +144 -0
  53. package/dist/chunks/chunk-G5RAECIB.js.map +6 -0
  54. package/dist/chunks/{chunk-C2IABASE.js → chunk-GOGBOZKO.js} +666 -27
  55. package/dist/chunks/chunk-GOGBOZKO.js.map +6 -0
  56. package/dist/chunks/chunk-HO2ZUI5Y.js +1189 -0
  57. package/dist/chunks/chunk-HO2ZUI5Y.js.map +6 -0
  58. package/dist/chunks/{chunk-2QXVOSJM.js → chunk-HOIDWHGC.js} +6 -6
  59. package/dist/chunks/{chunk-U2AVT6OB.js → chunk-HOY7BUGW.js} +3 -3
  60. package/dist/chunks/{chunk-WKGECHMV.js → chunk-HQZ3GBQI.js} +7 -7
  61. package/dist/chunks/{chunk-Z7DJAGBK.js → chunk-HXAWIWOZ.js} +2 -2
  62. package/dist/chunks/{chunk-CT23IU3D.js → chunk-IQQ6TY4W.js} +3 -3
  63. package/dist/chunks/{chunk-SEVUBJMR.js → chunk-J4IES4SO.js} +5 -5
  64. package/dist/chunks/{chunk-SEVUBJMR.js.map → chunk-J4IES4SO.js.map} +1 -1
  65. package/dist/chunks/{chunk-QNFMVN4D.js → chunk-JD2HLKFO.js} +2 -2
  66. package/dist/chunks/chunk-JHDNGNQT.js +95 -0
  67. package/dist/chunks/chunk-JHDNGNQT.js.map +6 -0
  68. package/dist/chunks/{chunk-H6B6AROX.js → chunk-JQIBPPOL.js} +69 -46
  69. package/dist/chunks/chunk-JQIBPPOL.js.map +6 -0
  70. package/dist/chunks/{chunk-ZDEFWEEI.js → chunk-JXT47VT6.js} +113 -35
  71. package/dist/chunks/chunk-JXT47VT6.js.map +6 -0
  72. package/dist/chunks/{chunk-LVDRURI4.js → chunk-K6LLMOB2.js} +2 -2
  73. package/dist/chunks/{chunk-EUBCYTOK.js → chunk-KONYGNG6.js} +152 -3
  74. package/dist/chunks/chunk-KONYGNG6.js.map +6 -0
  75. package/dist/chunks/{chunk-BHR2CNBZ.js → chunk-L3QW53QL.js} +223 -247
  76. package/dist/chunks/chunk-L3QW53QL.js.map +6 -0
  77. package/dist/chunks/{chunk-2HDIUUMX.js → chunk-M46GKTOI.js} +2 -2
  78. package/dist/chunks/{chunk-RKSYVIQX.js → chunk-N3C5X6BW.js} +6 -6
  79. package/dist/chunks/chunk-N4OY22M2.js +256 -0
  80. package/dist/chunks/chunk-N4OY22M2.js.map +6 -0
  81. package/dist/chunks/{chunk-E7FQPIJB.js → chunk-N56FVHCU.js} +26 -2
  82. package/dist/chunks/chunk-N56FVHCU.js.map +6 -0
  83. package/dist/chunks/chunk-PCUMISO3.js +92 -0
  84. package/dist/chunks/chunk-PCUMISO3.js.map +6 -0
  85. package/dist/chunks/{chunk-3RC4ATZI.js → chunk-QRGO6R2O.js} +12 -6
  86. package/dist/chunks/chunk-QRGO6R2O.js.map +6 -0
  87. package/dist/chunks/{chunk-37DRD4QM.js → chunk-QT6KYBCC.js} +3 -3
  88. package/dist/chunks/{chunk-QZYTSINZ.js → chunk-QUELENQP.js} +4 -4
  89. package/dist/chunks/{chunk-ZQRO6GGZ.js → chunk-QWBR6FBY.js} +89 -20
  90. package/dist/chunks/chunk-QWBR6FBY.js.map +6 -0
  91. package/dist/chunks/{chunk-7B5YTYHY.js → chunk-R2LYGFCI.js} +4 -4
  92. package/dist/chunks/{chunk-BNMFWLWH.js → chunk-RGVJHSMU.js} +5 -5
  93. package/dist/chunks/{chunk-YYX7O3T2.js → chunk-RVSVVL6O.js} +3 -3
  94. package/dist/chunks/{chunk-A6J2VJL5.js → chunk-S4KDR6G5.js} +53 -6
  95. package/dist/chunks/chunk-S4KDR6G5.js.map +6 -0
  96. package/dist/chunks/chunk-SIG7WHBU.js +78 -0
  97. package/dist/chunks/chunk-SIG7WHBU.js.map +6 -0
  98. package/dist/chunks/{chunk-RM4XZZL3.js → chunk-SIWZZF4M.js} +15 -15
  99. package/dist/chunks/{chunk-J67SASGK.js → chunk-SNC5D5UG.js} +18 -18
  100. package/dist/chunks/{chunk-CLADMV2E.js → chunk-SRYIMLOK.js} +2 -2
  101. package/dist/chunks/{chunk-3OP32UHN.js → chunk-TW5BCDA5.js} +3 -3
  102. package/dist/chunks/{chunk-5XJC5G7N.js → chunk-URJ7TITR.js} +8 -8
  103. package/dist/chunks/{chunk-4SBUXWX3.js → chunk-W2PJ6ZHY.js} +12 -47
  104. package/dist/chunks/chunk-W2PJ6ZHY.js.map +6 -0
  105. package/dist/chunks/{chunk-ZMZR4UTZ.js → chunk-WHOSI6UQ.js} +2 -2
  106. package/dist/chunks/{chunk-ANUGFVZI.js → chunk-XCMCPWMB.js} +4 -4
  107. package/dist/chunks/{chunk-VALR7WUL.js → chunk-XGVCAMNT.js} +2 -2
  108. package/dist/chunks/{chunk-DHV3KMEC.js → chunk-XMOKHCPV.js} +116 -40
  109. package/dist/chunks/chunk-XMOKHCPV.js.map +6 -0
  110. package/dist/chunks/{chunk-34L6FTQV.js → chunk-XXUL6HHM.js} +2 -2
  111. package/dist/chunks/{chunk-PKBHQFT6.js → chunk-Y2DZ27P6.js} +4 -4
  112. package/dist/chunks/{chunk-WN7YMX22.js → chunk-Y3I7AAD6.js} +4 -4
  113. package/dist/chunks/{chunk-UM4ECTUS.js → chunk-Y74CPWYC.js} +13 -13
  114. package/dist/chunks/chunk-YM4DUQ3P.js +59 -0
  115. package/dist/chunks/chunk-YM4DUQ3P.js.map +6 -0
  116. package/dist/chunks/{chunk-DQKQKNDY.js → chunk-YP7AINGL.js} +9 -9
  117. package/dist/chunks/{chunk-ZGBKTT7X.js → chunk-YPHXWFKQ.js} +2 -2
  118. package/dist/chunks/{chunk-OFNGIO53.js → chunk-YVIM3MXU.js} +2 -2
  119. package/dist/chunks/{cli-runtime-7GSPWSYW.js → cli-runtime-HW6GQKC6.js} +23 -20
  120. package/dist/chunks/cli-runtime-HW6GQKC6.js.map +6 -0
  121. package/dist/chunks/{commands-LU5AOF65.js → commands-JZT6JJY5.js} +5 -5
  122. package/dist/chunks/{crash-report-YDSO3QZP.js → crash-report-TWMWHNKY.js} +9 -7
  123. package/dist/chunks/{dist-7JBTU4ZA.js → dist-4EGZFRWY.js} +12 -2
  124. package/dist/chunks/dist-4EGZFRWY.js.map +6 -0
  125. package/dist/chunks/{dist-SLWBMTWO.js → dist-6ORFQIRV.js} +7 -2
  126. package/dist/chunks/{dist-SLWBMTWO.js.map → dist-6ORFQIRV.js.map} +1 -1
  127. package/dist/chunks/{dist-FI4O2BO3.js → dist-AZ5T257L.js} +22 -2
  128. package/dist/chunks/dist-AZ5T257L.js.map +6 -0
  129. package/dist/chunks/{dist-BJMHCL2F.js → dist-CLKFY67B.js} +8 -4
  130. package/dist/chunks/{dist-BJMHCL2F.js.map → dist-CLKFY67B.js.map} +1 -1
  131. package/dist/chunks/{dist-JWX7FPMB.js → dist-K5JIOWIQ.js} +8 -3
  132. package/dist/chunks/dist-K5JIOWIQ.js.map +6 -0
  133. package/dist/chunks/{dist-7PFXZB32.js → dist-MVLQAON2.js} +12 -2
  134. package/dist/chunks/{dist-7PFXZB32.js.map → dist-MVLQAON2.js.map} +1 -1
  135. package/dist/chunks/{dist-47WGWXP5.js → dist-POSMI3PI.js} +18 -4
  136. package/dist/chunks/{dist-47WGWXP5.js.map → dist-POSMI3PI.js.map} +1 -1
  137. package/dist/chunks/{doctor-ZK3CTBDR.js → doctor-UVZBNUNF.js} +15 -9
  138. package/dist/chunks/{drain-CVQW35OB.js → drain-27E6XUNK.js} +11 -10
  139. package/dist/chunks/drain-27E6XUNK.js.map +6 -0
  140. package/dist/chunks/{eval-PBRDQ7GI.js → eval-NRRIWDET.js} +2 -2
  141. package/dist/chunks/{exec-ZVOPAVQC.js → exec-KX46LZ36.js} +159 -62
  142. package/dist/chunks/exec-KX46LZ36.js.map +6 -0
  143. package/dist/chunks/{home-QPIQIIAR.js → home-RT2I6VTQ.js} +3 -3
  144. package/dist/chunks/{host-queries-UUG7LHPF.js → host-queries-ZXGOA6ZL.js} +23 -17
  145. package/dist/chunks/host-queries-ZXGOA6ZL.js.map +6 -0
  146. package/dist/chunks/install-LVQAT4QP.js +15 -0
  147. package/dist/chunks/{learn-AILV7XYA.js → learn-5KKZ4ZFX.js} +15 -14
  148. package/dist/chunks/learn-5KKZ4ZFX.js.map +6 -0
  149. package/dist/chunks/{learn-builtin-I2RMG7OE.js → learn-builtin-MSUF4MEJ.js} +18 -17
  150. package/dist/chunks/learn-builtin-MSUF4MEJ.js.map +6 -0
  151. package/dist/chunks/{lifecycle-ZZ5HDP6F.js → lifecycle-TZU6D46R.js} +29 -30
  152. package/dist/chunks/{list-TMHSX32S.js → list-QCWNMQED.js} +23 -23
  153. package/dist/chunks/live-V7HRF5KR.js +34 -0
  154. package/dist/chunks/{login-VUIOQEA2.js → login-QFP3PIXG.js} +8 -8
  155. package/dist/chunks/{logs-QQTFNNSW.js → logs-XTXMS4JF.js} +4 -4
  156. package/dist/chunks/{mcp-6H3YELN6.js → mcp-WQFJJ4NO.js} +81 -23
  157. package/dist/chunks/mcp-WQFJJ4NO.js.map +6 -0
  158. package/dist/chunks/{message-command-IQTT76ZY.js → message-command-QVNUJN47.js} +40 -41
  159. package/dist/chunks/message-command-QVNUJN47.js.map +6 -0
  160. package/dist/chunks/{operator-tools-ISZGHK3F.js → operator-tools-2OYRNPCH.js} +14 -14
  161. package/dist/chunks/{output-schema-63NLKBRY.js → output-schema-ETVPLUXE.js} +3 -3
  162. package/dist/chunks/{pal-RAIDDDNH.js → pal-BYFZCLE2.js} +12 -13
  163. package/dist/chunks/pal-BYFZCLE2.js.map +6 -0
  164. package/dist/chunks/plain-report-73WHPLHX.js +146 -0
  165. package/dist/chunks/plain-report-73WHPLHX.js.map +6 -0
  166. package/dist/chunks/{providers-N2UXL3XT.js → providers-KP5JHTTK.js} +6 -6
  167. package/dist/chunks/{resident-CWT62J2M.js → resident-BROBTK35.js} +35 -32
  168. package/dist/chunks/resident-BROBTK35.js.map +6 -0
  169. package/dist/chunks/resume-7V44GSEU.js +23 -0
  170. package/dist/chunks/{resume-command-DNNLB5SK.js → resume-command-OKJ2MJPB.js} +4 -4
  171. package/dist/chunks/{schedule-6N33GN2Z.js → schedule-TVR3FE32.js} +8 -8
  172. package/dist/chunks/{service-77ZFLYDC.js → service-6A3TOQKV.js} +35 -36
  173. package/dist/chunks/service-6A3TOQKV.js.map +6 -0
  174. package/dist/chunks/session-step-N4GHA2YE.js +33 -0
  175. package/dist/chunks/{skills-SAIXOU7Z.js → skills-WXYSPDKL.js} +9 -8
  176. package/dist/chunks/skills-WXYSPDKL.js.map +6 -0
  177. package/dist/chunks/start-check-BUCN5MCU.js +12 -0
  178. package/dist/chunks/{state-J4NZZP7B.js → state-PVAVIXHK.js} +3 -3
  179. package/dist/chunks/{store-QLG76DQG.js → store-D3XUEEAF.js} +6 -6
  180. package/dist/chunks/store-D3XUEEAF.js.map +6 -0
  181. package/dist/chunks/{store-YRVVPTUX.js → store-NB3KR4XA.js} +15 -11
  182. package/dist/chunks/store-NB3KR4XA.js.map +6 -0
  183. package/dist/chunks/{store-2JQLHCG4.js → store-O3KC2PPZ.js} +4 -4
  184. package/dist/chunks/store-O3KC2PPZ.js.map +6 -0
  185. package/dist/chunks/{tui-77L5I5EV.js → tui-2XOSCALL.js} +788 -217
  186. package/dist/chunks/tui-2XOSCALL.js.map +6 -0
  187. package/dist/chunks/undici-LWANNIOV.js +26906 -0
  188. package/dist/chunks/undici-LWANNIOV.js.map +6 -0
  189. package/dist/chunks/upgrade-FY5ULZQF.js +456 -0
  190. package/dist/chunks/upgrade-FY5ULZQF.js.map +6 -0
  191. package/dist/chunks/{worktree-5ETUFJAC.js → worktree-MVW62U5G.js} +13 -13
  192. package/dist/cli-runtime.d.ts +1 -0
  193. package/dist/cli-runtime.d.ts.map +1 -1
  194. package/dist/cli.d.ts.map +1 -1
  195. package/dist/commands/append-system.d.ts +19 -0
  196. package/dist/commands/append-system.d.ts.map +1 -0
  197. package/dist/commands/desktop-host.d.ts +6 -0
  198. package/dist/commands/desktop-host.d.ts.map +1 -1
  199. package/dist/commands/doctor.d.ts.map +1 -1
  200. package/dist/commands/exec-flags.d.ts +33 -0
  201. package/dist/commands/exec-flags.d.ts.map +1 -1
  202. package/dist/commands/exec-json.d.ts +6 -0
  203. package/dist/commands/exec-json.d.ts.map +1 -1
  204. package/dist/commands/exec.d.ts +4 -2
  205. package/dist/commands/exec.d.ts.map +1 -1
  206. package/dist/commands/host-queries.d.ts.map +1 -1
  207. package/dist/commands/mcp.d.ts.map +1 -1
  208. package/dist/commands/resident-flags.d.ts.map +1 -1
  209. package/dist/commands/run-flags.d.ts +32 -0
  210. package/dist/commands/run-flags.d.ts.map +1 -0
  211. package/dist/commands/upgrade.d.ts +23 -25
  212. package/dist/commands/upgrade.d.ts.map +1 -1
  213. package/dist/config/load.d.ts +20 -1
  214. package/dist/config/load.d.ts.map +1 -1
  215. package/dist/config/schema.d.ts +36 -1
  216. package/dist/config/schema.d.ts.map +1 -1
  217. package/dist/config/turn-guards.d.ts +3 -0
  218. package/dist/config/turn-guards.d.ts.map +1 -1
  219. package/dist/context/instruction-glob.d.ts +5 -0
  220. package/dist/context/instruction-glob.d.ts.map +1 -0
  221. package/dist/context/instruction-scope.d.ts +78 -0
  222. package/dist/context/instruction-scope.d.ts.map +1 -0
  223. package/dist/context/project-tracker.d.ts +10 -1
  224. package/dist/context/project-tracker.d.ts.map +1 -1
  225. package/dist/context/project.d.ts +46 -2
  226. package/dist/context/project.d.ts.map +1 -1
  227. package/dist/context/runtime-message.d.ts +8 -1
  228. package/dist/context/runtime-message.d.ts.map +1 -1
  229. package/dist/doctor/checks/cache-lifetime.d.ts +19 -0
  230. package/dist/doctor/checks/cache-lifetime.d.ts.map +1 -0
  231. package/dist/doctor/checks/index.d.ts +3 -1
  232. package/dist/doctor/checks/index.d.ts.map +1 -1
  233. package/dist/doctor/checks/network.d.ts +15 -0
  234. package/dist/doctor/checks/network.d.ts.map +1 -0
  235. package/dist/doctor/checks/updates.d.ts +6 -0
  236. package/dist/doctor/checks/updates.d.ts.map +1 -0
  237. package/dist/doctor/live.d.ts +15 -0
  238. package/dist/doctor/live.d.ts.map +1 -0
  239. package/dist/doctor/plain-report.d.ts +19 -0
  240. package/dist/doctor/plain-report.d.ts.map +1 -0
  241. package/dist/index.js +38 -32
  242. package/dist/integrations/auto-update/apply.d.ts +193 -0
  243. package/dist/integrations/auto-update/apply.d.ts.map +1 -0
  244. package/dist/integrations/auto-update/download.d.ts +35 -0
  245. package/dist/integrations/auto-update/download.d.ts.map +1 -0
  246. package/dist/integrations/auto-update/install-kind.d.ts +55 -0
  247. package/dist/integrations/auto-update/install-kind.d.ts.map +1 -0
  248. package/dist/integrations/auto-update/installed-version.d.ts +3 -0
  249. package/dist/integrations/auto-update/installed-version.d.ts.map +1 -0
  250. package/dist/integrations/auto-update/policy.d.ts +28 -0
  251. package/dist/integrations/auto-update/policy.d.ts.map +1 -0
  252. package/dist/integrations/auto-update/start-check.d.ts +21 -0
  253. package/dist/integrations/auto-update/start-check.d.ts.map +1 -0
  254. package/dist/integrations/auto-update/start.d.ts +25 -0
  255. package/dist/integrations/auto-update/start.d.ts.map +1 -0
  256. package/dist/integrations/auto-update/state.d.ts +109 -0
  257. package/dist/integrations/auto-update/state.d.ts.map +1 -0
  258. package/dist/integrations/auto-update/status.d.ts +37 -0
  259. package/dist/integrations/auto-update/status.d.ts.map +1 -0
  260. package/dist/integrations/auto-update/updater.d.ts +79 -0
  261. package/dist/integrations/auto-update/updater.d.ts.map +1 -0
  262. package/dist/integrations/mcp/project-approval.d.ts +41 -0
  263. package/dist/integrations/mcp/project-approval.d.ts.map +1 -0
  264. package/dist/integrations/mcp/shared-file.d.ts +36 -0
  265. package/dist/integrations/mcp/shared-file.d.ts.map +1 -0
  266. package/dist/integrations/npm-global.d.ts +40 -0
  267. package/dist/integrations/npm-global.d.ts.map +1 -0
  268. package/dist/integrations/plugins/hook-host.d.ts +18 -0
  269. package/dist/integrations/plugins/hook-host.d.ts.map +1 -0
  270. package/dist/integrations/plugins/runtime.d.ts +4 -2
  271. package/dist/integrations/plugins/runtime.d.ts.map +1 -1
  272. package/dist/integrations/providers/fallback-flag.d.ts +29 -0
  273. package/dist/integrations/providers/fallback-flag.d.ts.map +1 -0
  274. package/dist/integrations/providers/prompt-cache-ttl.d.ts +3 -0
  275. package/dist/integrations/providers/prompt-cache-ttl.d.ts.map +1 -1
  276. package/dist/integrations/resident/runner-worker.js +32 -25
  277. package/dist/integrations/resident/runner-worker.js.map +1 -1
  278. package/dist/integrations/sessions/conversation-search.d.ts +1 -1
  279. package/dist/integrations/sessions/conversation-search.d.ts.map +1 -1
  280. package/dist/integrations/sessions/store.d.ts +23 -0
  281. package/dist/integrations/sessions/store.d.ts.map +1 -1
  282. package/dist/integrations/subagents/runtime.d.ts +8 -2
  283. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  284. package/dist/integrations/trust/folder-grants.d.ts +12 -1
  285. package/dist/integrations/trust/folder-grants.d.ts.map +1 -1
  286. package/dist/integrations/updates.d.ts +15 -1
  287. package/dist/integrations/updates.d.ts.map +1 -1
  288. package/dist/network/install.d.ts +38 -0
  289. package/dist/network/install.d.ts.map +1 -0
  290. package/dist/network/settings.d.ts +50 -0
  291. package/dist/network/settings.d.ts.map +1 -0
  292. package/dist/pals/agent-session.d.ts.map +1 -1
  293. package/dist/permissions/mode.d.ts +3 -1
  294. package/dist/permissions/mode.d.ts.map +1 -1
  295. package/dist/permissions/read-only-gate.d.ts +28 -0
  296. package/dist/permissions/read-only-gate.d.ts.map +1 -0
  297. package/dist/permissions/sandbox-shell.d.ts +37 -0
  298. package/dist/permissions/sandbox-shell.d.ts.map +1 -0
  299. package/dist/permissions/tool-flags.d.ts +36 -0
  300. package/dist/permissions/tool-flags.d.ts.map +1 -0
  301. package/dist/plan/approval.d.ts +1 -0
  302. package/dist/plan/approval.d.ts.map +1 -1
  303. package/dist/plan/enter-plan-mode-tool.d.ts +28 -0
  304. package/dist/plan/enter-plan-mode-tool.d.ts.map +1 -0
  305. package/dist/plan/plan-file.d.ts +8 -0
  306. package/dist/plan/plan-file.d.ts.map +1 -1
  307. package/dist/reminders/task-nudge.d.ts +9 -1
  308. package/dist/reminders/task-nudge.d.ts.map +1 -1
  309. package/dist/skills/store.d.ts +6 -0
  310. package/dist/skills/store.d.ts.map +1 -1
  311. package/dist/tui/App.d.ts +1 -1
  312. package/dist/tui/App.d.ts.map +1 -1
  313. package/dist/tui/Checklist.d.ts +2 -0
  314. package/dist/tui/Checklist.d.ts.map +1 -1
  315. package/dist/tui/Composer.d.ts +7 -1
  316. package/dist/tui/Composer.d.ts.map +1 -1
  317. package/dist/tui/ContextGridRow.d.ts.map +1 -1
  318. package/dist/tui/LiveActivity.d.ts +2 -0
  319. package/dist/tui/LiveActivity.d.ts.map +1 -1
  320. package/dist/tui/ResumePicker.d.ts +10 -1
  321. package/dist/tui/ResumePicker.d.ts.map +1 -1
  322. package/dist/tui/StatusBar.d.ts +7 -1
  323. package/dist/tui/StatusBar.d.ts.map +1 -1
  324. package/dist/tui/TrustPrompt.d.ts +2 -0
  325. package/dist/tui/TrustPrompt.d.ts.map +1 -1
  326. package/dist/tui/agent.d.ts +31 -1
  327. package/dist/tui/agent.d.ts.map +1 -1
  328. package/dist/tui/capability-notice.d.ts +11 -1
  329. package/dist/tui/capability-notice.d.ts.map +1 -1
  330. package/dist/tui/context-grid.d.ts +7 -0
  331. package/dist/tui/context-grid.d.ts.map +1 -1
  332. package/dist/tui/context-usage.d.ts +4 -0
  333. package/dist/tui/context-usage.d.ts.map +1 -1
  334. package/dist/tui/conversation-in-use.d.ts +18 -0
  335. package/dist/tui/conversation-in-use.d.ts.map +1 -0
  336. package/dist/tui/foreground-handoff.d.ts +15 -0
  337. package/dist/tui/foreground-handoff.d.ts.map +1 -0
  338. package/dist/tui/launch-settings.d.ts +6 -3
  339. package/dist/tui/launch-settings.d.ts.map +1 -1
  340. package/dist/tui/pause-auto-resume.d.ts +33 -0
  341. package/dist/tui/pause-auto-resume.d.ts.map +1 -0
  342. package/dist/tui/permission-review.d.ts.map +1 -1
  343. package/dist/tui/plain-interruption.d.ts +8 -0
  344. package/dist/tui/plain-interruption.d.ts.map +1 -1
  345. package/dist/tui/restored-rows.d.ts +4 -0
  346. package/dist/tui/restored-rows.d.ts.map +1 -1
  347. package/dist/tui/resume-picker-state.d.ts +40 -0
  348. package/dist/tui/resume-picker-state.d.ts.map +1 -0
  349. package/dist/tui/slashCommands.d.ts +12 -1
  350. package/dist/tui/slashCommands.d.ts.map +1 -1
  351. package/dist/tui/system-rows.d.ts +3 -0
  352. package/dist/tui/system-rows.d.ts.map +1 -1
  353. package/dist/tui/tidy-tool-output.d.ts +2 -0
  354. package/dist/tui/tidy-tool-output.d.ts.map +1 -1
  355. package/dist/tui/turn-interruption.d.ts +2 -0
  356. package/dist/tui/turn-interruption.d.ts.map +1 -1
  357. package/dist/tui/types.d.ts +10 -1
  358. package/dist/tui/types.d.ts.map +1 -1
  359. package/dist/tui/update-notice.d.ts +13 -0
  360. package/dist/tui/update-notice.d.ts.map +1 -1
  361. package/dist/tui/working-label.d.ts +9 -0
  362. package/dist/tui/working-label.d.ts.map +1 -0
  363. package/dist/tui/zen-free-refusal.d.ts +12 -0
  364. package/dist/tui/zen-free-refusal.d.ts.map +1 -1
  365. package/dist/user-commands/store.d.ts +30 -1
  366. package/dist/user-commands/store.d.ts.map +1 -1
  367. package/package.json +11 -10
  368. package/dist/chunks/activity-command-XLF5EAM5.js.map +0 -6
  369. package/dist/chunks/agent-session-LHOJDS75.js +0 -59
  370. package/dist/chunks/chunk-2UYBHC3L.js.map +0 -6
  371. package/dist/chunks/chunk-3RC4ATZI.js.map +0 -6
  372. package/dist/chunks/chunk-4SBUXWX3.js.map +0 -6
  373. package/dist/chunks/chunk-4WWLRVYU.js.map +0 -6
  374. package/dist/chunks/chunk-A6J2VJL5.js.map +0 -6
  375. package/dist/chunks/chunk-BHR2CNBZ.js.map +0 -6
  376. package/dist/chunks/chunk-C2IABASE.js.map +0 -6
  377. package/dist/chunks/chunk-D2M5K6UY.js +0 -440
  378. package/dist/chunks/chunk-D2M5K6UY.js.map +0 -6
  379. package/dist/chunks/chunk-DHV3KMEC.js.map +0 -6
  380. package/dist/chunks/chunk-E7FQPIJB.js.map +0 -6
  381. package/dist/chunks/chunk-EUBCYTOK.js.map +0 -6
  382. package/dist/chunks/chunk-H6B6AROX.js.map +0 -6
  383. package/dist/chunks/chunk-JEULHVUH.js.map +0 -6
  384. package/dist/chunks/chunk-L2GZVP5H.js.map +0 -6
  385. package/dist/chunks/chunk-LFI6O7WL.js.map +0 -6
  386. package/dist/chunks/chunk-NTPBXJMK.js.map +0 -6
  387. package/dist/chunks/chunk-O2B3B2TM.js +0 -138
  388. package/dist/chunks/chunk-O2B3B2TM.js.map +0 -6
  389. package/dist/chunks/chunk-UEXQA2UW.js.map +0 -6
  390. package/dist/chunks/chunk-XSCT3DLE.js +0 -161
  391. package/dist/chunks/chunk-XSCT3DLE.js.map +0 -6
  392. package/dist/chunks/chunk-ZDEFWEEI.js.map +0 -6
  393. package/dist/chunks/chunk-ZQRO6GGZ.js.map +0 -6
  394. package/dist/chunks/cli-runtime-7GSPWSYW.js.map +0 -6
  395. package/dist/chunks/dist-7JBTU4ZA.js.map +0 -6
  396. package/dist/chunks/dist-FI4O2BO3.js.map +0 -6
  397. package/dist/chunks/dist-JWX7FPMB.js.map +0 -6
  398. package/dist/chunks/drain-CVQW35OB.js.map +0 -6
  399. package/dist/chunks/exec-ZVOPAVQC.js.map +0 -6
  400. package/dist/chunks/host-queries-UUG7LHPF.js.map +0 -6
  401. package/dist/chunks/learn-AILV7XYA.js.map +0 -6
  402. package/dist/chunks/learn-builtin-I2RMG7OE.js.map +0 -6
  403. package/dist/chunks/mcp-6H3YELN6.js.map +0 -6
  404. package/dist/chunks/message-command-IQTT76ZY.js.map +0 -6
  405. package/dist/chunks/pal-RAIDDDNH.js.map +0 -6
  406. package/dist/chunks/resident-CWT62J2M.js.map +0 -6
  407. package/dist/chunks/resume-PKATLA4S.js +0 -23
  408. package/dist/chunks/service-77ZFLYDC.js.map +0 -6
  409. package/dist/chunks/session-step-I5DFTYDV.js +0 -30
  410. package/dist/chunks/skills-SAIXOU7Z.js.map +0 -6
  411. package/dist/chunks/tui-77L5I5EV.js.map +0 -6
  412. package/dist/chunks/upgrade-ZTG65H5Q.js +0 -315
  413. package/dist/chunks/upgrade-ZTG65H5Q.js.map +0 -6
  414. /package/dist/chunks/{acp-5RFAFTQU.js.map → acp-ADQ2PRAY.js.map} +0 -0
  415. /package/dist/chunks/{add-Z6Y5DOCM.js.map → add-ILLLF6YP.js.map} +0 -0
  416. /package/dist/chunks/{agent-U4NFC4DT.js.map → agent-YQI5KOPV.js.map} +0 -0
  417. /package/dist/chunks/{agent-session-LHOJDS75.js.map → agent-session-3MUZCWQ4.js.map} +0 -0
  418. /package/dist/chunks/{archive-P47MRHE2.js.map → archive-55KJKGJB.js.map} +0 -0
  419. /package/dist/chunks/{browser-QN24UC7K.js.map → browser-C6AOJ3CH.js.map} +0 -0
  420. /package/dist/chunks/{chat-HRORSJPH.js.map → chat-45H5F3KI.js.map} +0 -0
  421. /package/dist/chunks/{chunk-TU46IHIV.js.map → chunk-23NRJ2RC.js.map} +0 -0
  422. /package/dist/chunks/{chunk-CEIYJWZ2.js.map → chunk-35VTE7V5.js.map} +0 -0
  423. /package/dist/chunks/{chunk-72CFHDKQ.js.map → chunk-3LNTQLQ4.js.map} +0 -0
  424. /package/dist/chunks/{chunk-WBTXYSAB.js.map → chunk-4NO5XFK2.js.map} +0 -0
  425. /package/dist/chunks/{chunk-4SP6H34B.js.map → chunk-6GBZAUYW.js.map} +0 -0
  426. /package/dist/chunks/{chunk-2UPDDG7V.js.map → chunk-6PNBIMWH.js.map} +0 -0
  427. /package/dist/chunks/{chunk-25XPE4N6.js.map → chunk-6S4R2USK.js.map} +0 -0
  428. /package/dist/chunks/{chunk-VCKNYZYH.js.map → chunk-A3AF5WXZ.js.map} +0 -0
  429. /package/dist/chunks/{chunk-G34P5PIK.js.map → chunk-A4CKLHKM.js.map} +0 -0
  430. /package/dist/chunks/{chunk-Y5QV6NZK.js.map → chunk-AZPS37AQ.js.map} +0 -0
  431. /package/dist/chunks/{chunk-WJ7XYOSE.js.map → chunk-BRKD6FMO.js.map} +0 -0
  432. /package/dist/chunks/{chunk-I55BEPVH.js.map → chunk-CW2N2QS2.js.map} +0 -0
  433. /package/dist/chunks/{chunk-2VQ475KY.js.map → chunk-DLL2FPUY.js.map} +0 -0
  434. /package/dist/chunks/{chunk-CIIMESY2.js.map → chunk-ESZ7X37S.js.map} +0 -0
  435. /package/dist/chunks/{chunk-CAPC66Q6.js.map → chunk-EWSIGY2A.js.map} +0 -0
  436. /package/dist/chunks/{chunk-CM2I2L4G.js.map → chunk-FMEGRBJP.js.map} +0 -0
  437. /package/dist/chunks/{chunk-JKXCLMMZ.js.map → chunk-FSKJ3EZC.js.map} +0 -0
  438. /package/dist/chunks/{chunk-2QXVOSJM.js.map → chunk-HOIDWHGC.js.map} +0 -0
  439. /package/dist/chunks/{chunk-U2AVT6OB.js.map → chunk-HOY7BUGW.js.map} +0 -0
  440. /package/dist/chunks/{chunk-WKGECHMV.js.map → chunk-HQZ3GBQI.js.map} +0 -0
  441. /package/dist/chunks/{chunk-Z7DJAGBK.js.map → chunk-HXAWIWOZ.js.map} +0 -0
  442. /package/dist/chunks/{chunk-CT23IU3D.js.map → chunk-IQQ6TY4W.js.map} +0 -0
  443. /package/dist/chunks/{chunk-QNFMVN4D.js.map → chunk-JD2HLKFO.js.map} +0 -0
  444. /package/dist/chunks/{chunk-LVDRURI4.js.map → chunk-K6LLMOB2.js.map} +0 -0
  445. /package/dist/chunks/{chunk-2HDIUUMX.js.map → chunk-M46GKTOI.js.map} +0 -0
  446. /package/dist/chunks/{chunk-RKSYVIQX.js.map → chunk-N3C5X6BW.js.map} +0 -0
  447. /package/dist/chunks/{chunk-37DRD4QM.js.map → chunk-QT6KYBCC.js.map} +0 -0
  448. /package/dist/chunks/{chunk-QZYTSINZ.js.map → chunk-QUELENQP.js.map} +0 -0
  449. /package/dist/chunks/{chunk-7B5YTYHY.js.map → chunk-R2LYGFCI.js.map} +0 -0
  450. /package/dist/chunks/{chunk-BNMFWLWH.js.map → chunk-RGVJHSMU.js.map} +0 -0
  451. /package/dist/chunks/{chunk-YYX7O3T2.js.map → chunk-RVSVVL6O.js.map} +0 -0
  452. /package/dist/chunks/{chunk-RM4XZZL3.js.map → chunk-SIWZZF4M.js.map} +0 -0
  453. /package/dist/chunks/{chunk-J67SASGK.js.map → chunk-SNC5D5UG.js.map} +0 -0
  454. /package/dist/chunks/{chunk-CLADMV2E.js.map → chunk-SRYIMLOK.js.map} +0 -0
  455. /package/dist/chunks/{chunk-3OP32UHN.js.map → chunk-TW5BCDA5.js.map} +0 -0
  456. /package/dist/chunks/{chunk-5XJC5G7N.js.map → chunk-URJ7TITR.js.map} +0 -0
  457. /package/dist/chunks/{chunk-ZMZR4UTZ.js.map → chunk-WHOSI6UQ.js.map} +0 -0
  458. /package/dist/chunks/{chunk-ANUGFVZI.js.map → chunk-XCMCPWMB.js.map} +0 -0
  459. /package/dist/chunks/{chunk-VALR7WUL.js.map → chunk-XGVCAMNT.js.map} +0 -0
  460. /package/dist/chunks/{chunk-34L6FTQV.js.map → chunk-XXUL6HHM.js.map} +0 -0
  461. /package/dist/chunks/{chunk-PKBHQFT6.js.map → chunk-Y2DZ27P6.js.map} +0 -0
  462. /package/dist/chunks/{chunk-WN7YMX22.js.map → chunk-Y3I7AAD6.js.map} +0 -0
  463. /package/dist/chunks/{chunk-UM4ECTUS.js.map → chunk-Y74CPWYC.js.map} +0 -0
  464. /package/dist/chunks/{chunk-DQKQKNDY.js.map → chunk-YP7AINGL.js.map} +0 -0
  465. /package/dist/chunks/{chunk-ZGBKTT7X.js.map → chunk-YPHXWFKQ.js.map} +0 -0
  466. /package/dist/chunks/{chunk-OFNGIO53.js.map → chunk-YVIM3MXU.js.map} +0 -0
  467. /package/dist/chunks/{commands-LU5AOF65.js.map → commands-JZT6JJY5.js.map} +0 -0
  468. /package/dist/chunks/{crash-report-YDSO3QZP.js.map → crash-report-TWMWHNKY.js.map} +0 -0
  469. /package/dist/chunks/{doctor-ZK3CTBDR.js.map → doctor-UVZBNUNF.js.map} +0 -0
  470. /package/dist/chunks/{eval-PBRDQ7GI.js.map → eval-NRRIWDET.js.map} +0 -0
  471. /package/dist/chunks/{home-QPIQIIAR.js.map → home-RT2I6VTQ.js.map} +0 -0
  472. /package/dist/chunks/{lifecycle-ZZ5HDP6F.js.map → install-LVQAT4QP.js.map} +0 -0
  473. /package/dist/chunks/{login-VUIOQEA2.js.map → lifecycle-TZU6D46R.js.map} +0 -0
  474. /package/dist/chunks/{list-TMHSX32S.js.map → list-QCWNMQED.js.map} +0 -0
  475. /package/dist/chunks/{output-schema-63NLKBRY.js.map → live-V7HRF5KR.js.map} +0 -0
  476. /package/dist/chunks/{providers-N2UXL3XT.js.map → login-QFP3PIXG.js.map} +0 -0
  477. /package/dist/chunks/{logs-QQTFNNSW.js.map → logs-XTXMS4JF.js.map} +0 -0
  478. /package/dist/chunks/{operator-tools-ISZGHK3F.js.map → operator-tools-2OYRNPCH.js.map} +0 -0
  479. /package/dist/chunks/{resume-PKATLA4S.js.map → output-schema-ETVPLUXE.js.map} +0 -0
  480. /package/dist/chunks/{resume-command-DNNLB5SK.js.map → providers-KP5JHTTK.js.map} +0 -0
  481. /package/dist/chunks/{session-step-I5DFTYDV.js.map → resume-7V44GSEU.js.map} +0 -0
  482. /package/dist/chunks/{store-2JQLHCG4.js.map → resume-command-OKJ2MJPB.js.map} +0 -0
  483. /package/dist/chunks/{schedule-6N33GN2Z.js.map → schedule-TVR3FE32.js.map} +0 -0
  484. /package/dist/chunks/{store-QLG76DQG.js.map → session-step-N4GHA2YE.js.map} +0 -0
  485. /package/dist/chunks/{store-YRVVPTUX.js.map → start-check-BUCN5MCU.js.map} +0 -0
  486. /package/dist/chunks/{state-J4NZZP7B.js.map → state-PVAVIXHK.js.map} +0 -0
  487. /package/dist/chunks/{worktree-5ETUFJAC.js.map → worktree-MVW62U5G.js.map} +0 -0
@@ -2,13 +2,16 @@ import { createRequire as __namzuCreateRequire } from 'node:module';
2
2
  const require = __namzuCreateRequire(import.meta.url);
3
3
  import {
4
4
  openManagedWorktrees
5
- } from "./chunk-WN7YMX22.js";
5
+ } from "./chunk-Y3I7AAD6.js";
6
6
  import {
7
- createBrowserControl
8
- } from "./chunk-WHODOMXA.js";
7
+ connectMcpServers
8
+ } from "./chunk-A4CKLHKM.js";
9
+ import {
10
+ openInBrowser
11
+ } from "./chunk-4NO5XFK2.js";
9
12
  import {
10
13
  createSessionSkillCatalog
11
- } from "./chunk-25XPE4N6.js";
14
+ } from "./chunk-6S4R2USK.js";
12
15
  import {
13
16
  SAVE_SKILL_TOOL_NAME,
14
17
  attachAgentView,
@@ -24,23 +27,25 @@ import {
24
27
  settledElapsed,
25
28
  theme,
26
29
  viewFromJournal,
30
+ withSandboxShell,
27
31
  workingDirectoryProblem
28
- } from "./chunk-A6J2VJL5.js";
32
+ } from "./chunk-S4KDR6G5.js";
29
33
  import {
30
34
  runGeneratorCycle
31
- } from "./chunk-37DRD4QM.js";
35
+ } from "./chunk-QT6KYBCC.js";
32
36
  import {
33
37
  createSessionLearningFeed,
34
38
  openLearningTarget,
35
39
  readProjectGuidance,
36
40
  withSessionLearningFeed
37
- } from "./chunk-RKSYVIQX.js";
41
+ } from "./chunk-N3C5X6BW.js";
38
42
  import {
39
- connectMcpServers
40
- } from "./chunk-G34P5PIK.js";
43
+ createBrowserControl
44
+ } from "./chunk-WHODOMXA.js";
41
45
  import {
42
- openInBrowser
43
- } from "./chunk-WBTXYSAB.js";
46
+ conversationInUseSentence,
47
+ minutesUntilFree
48
+ } from "./chunk-4IIEEOCA.js";
44
49
  import {
45
50
  CredentialRefreshRejectedError,
46
51
  CredentialWithdrawnError,
@@ -48,7 +53,12 @@ import {
48
53
  ensureFreshStoredCodexCredential,
49
54
  readSubscriptionCredential,
50
55
  sameOAuthCredential
51
- } from "./chunk-I55BEPVH.js";
56
+ } from "./chunk-CW2N2QS2.js";
57
+ import {
58
+ createLazyCodeAnalysis,
59
+ promptCacheTtl,
60
+ setPromptCacheTtl
61
+ } from "./chunk-N56FVHCU.js";
52
62
  import {
53
63
  debugRequested
54
64
  } from "./chunk-GNBMKISG.js";
@@ -60,19 +70,19 @@ import {
60
70
  sessionWorkflowSizeAdvice,
61
71
  unmatchedPassthroughTools,
62
72
  workflowTokenCeiling
63
- } from "./chunk-C2IABASE.js";
73
+ } from "./chunk-GOGBOZKO.js";
74
+ import {
75
+ require_dist
76
+ } from "./chunk-KONYGNG6.js";
77
+ import {
78
+ resolveGeneratorSettings
79
+ } from "./chunk-LCGXWCVU.js";
64
80
  import {
65
81
  formatSize,
66
82
  homePath,
67
83
  plural,
68
84
  productName
69
85
  } from "./chunk-XPS3W7FC.js";
70
- import {
71
- resolveGeneratorSettings
72
- } from "./chunk-LCGXWCVU.js";
73
- import {
74
- createLazyCodeAnalysis
75
- } from "./chunk-E7FQPIJB.js";
76
86
  import {
77
87
  canSelectModel,
78
88
  chainCapabilityDisagreements,
@@ -97,7 +107,7 @@ import {
97
107
  requiresCredentialForModel,
98
108
  resolveChainCapabilities,
99
109
  unresolvedMembers
100
- } from "./chunk-UM4ECTUS.js";
110
+ } from "./chunk-Y74CPWYC.js";
101
111
  import {
102
112
  PROVIDER_REGISTRY,
103
113
  missingCredentialMessage,
@@ -106,48 +116,49 @@ import {
106
116
  import {
107
117
  isPermissionMode,
108
118
  permissionModeLabel
109
- } from "./chunk-SEVUBJMR.js";
119
+ } from "./chunk-J4IES4SO.js";
110
120
  import {
111
121
  conversationLogPath,
112
122
  ensureSessionStarted,
113
123
  openConversationLog
114
- } from "./chunk-ZQRO6GGZ.js";
124
+ } from "./chunk-QWBR6FBY.js";
115
125
  import {
116
126
  readIdentity
117
- } from "./chunk-CT23IU3D.js";
127
+ } from "./chunk-IQQ6TY4W.js";
118
128
  import {
119
129
  INSTRUCTIONS_FILENAME,
120
130
  MAX_CHARS_PER_FILE,
121
131
  cliProjectRoot,
122
132
  instructionSearchPath,
123
- loadProjectInstructions
124
- } from "./chunk-H6B6AROX.js";
133
+ isContainedBy,
134
+ readInstructionAt
135
+ } from "./chunk-JQIBPPOL.js";
136
+ import {
137
+ probeCapabilities
138
+ } from "./chunk-OH6TB27S.js";
125
139
  import {
126
140
  compilePermissions,
127
141
  isPermissionEffect
128
- } from "./chunk-U2AVT6OB.js";
142
+ } from "./chunk-HOY7BUGW.js";
129
143
  import {
130
144
  cliLogger
131
- } from "./chunk-QNFMVN4D.js";
145
+ } from "./chunk-JD2HLKFO.js";
132
146
  import {
133
147
  stringWidth
134
148
  } from "./chunk-U5UV2YRE.js";
135
- import {
136
- probeCapabilities
137
- } from "./chunk-OH6TB27S.js";
138
149
  import {
139
150
  activeZenCatalogue,
140
151
  isOfferableModel
141
152
  } from "./chunk-IE5XIE4W.js";
142
153
  import {
143
154
  ensurePrivateStateDirectory
144
- } from "./chunk-2VQ475KY.js";
155
+ } from "./chunk-DLL2FPUY.js";
145
156
  import {
146
157
  restrictToOwner
147
- } from "./chunk-WJ7XYOSE.js";
158
+ } from "./chunk-BRKD6FMO.js";
148
159
  import {
149
160
  namzuHomePath
150
- } from "./chunk-OFNGIO53.js";
161
+ } from "./chunk-YVIM3MXU.js";
151
162
  import {
152
163
  AgentManager,
153
164
  AgentRegistry,
@@ -186,6 +197,9 @@ import {
186
197
  MemoryContentRejectedError,
187
198
  MemoryNameConflictError,
188
199
  NOOP_LOGGER,
200
+ PLAN_AGENT_DESCRIPTION,
201
+ PLAN_AGENT_ID,
202
+ PLAN_AGENT_PROMPT,
189
203
  PLAN_MODE_DOCTRINE,
190
204
  PluginLifecycleManager,
191
205
  PluginRegistry,
@@ -273,6 +287,7 @@ import {
273
287
  getMonitorTools,
274
288
  isCompactionMessage,
275
289
  isEntityId,
290
+ isNamzuError,
276
291
  isProjectInstructionMessageSource,
277
292
  isReminderMessage,
278
293
  isReviewExempt,
@@ -306,6 +321,7 @@ import {
306
321
  selectTaskContext,
307
322
  slugifyMemoryName,
308
323
  structuredPatch,
324
+ toPlatformError,
309
325
  toToolSourceRef,
310
326
  toolWireSchema,
311
327
  toolset,
@@ -315,9 +331,10 @@ import {
315
331
  windowsShellNotice,
316
332
  withProviderFallback,
317
333
  wrapUntrusted
318
- } from "./chunk-4WWLRVYU.js";
334
+ } from "./chunk-7E3V7NNN.js";
319
335
  import {
320
- __name
336
+ __name,
337
+ __toESM
321
338
  } from "./chunk-76FLAFCG.js";
322
339
 
323
340
  // src/integrations/compaction/idle-compaction.ts
@@ -533,17 +550,6 @@ var TextOnlyModels = class {
533
550
  }
534
551
  };
535
552
 
536
- // src/integrations/providers/prompt-cache-ttl.ts
537
- var configured;
538
- function setPromptCacheTtl(ttl) {
539
- configured = ttl;
540
- }
541
- __name(setPromptCacheTtl, "setPromptCacheTtl");
542
- function promptCacheTtl() {
543
- return configured;
544
- }
545
- __name(promptCacheTtl, "promptCacheTtl");
546
-
547
553
  // src/integrations/web/open-url.ts
548
554
  var OPEN_URL_TOOL_NAME = "open_url";
549
555
  var inputSchema = {
@@ -608,10 +614,10 @@ var tail = Promise.resolve();
608
614
  var nextStart = 0;
609
615
  function cancelled(promise, signal) {
610
616
  signal.throwIfAborted();
611
- return new Promise((resolve14, reject) => {
617
+ return new Promise((resolve15, reject) => {
612
618
  const abort = /* @__PURE__ */ __name(() => reject(signal.reason), "abort");
613
619
  signal.addEventListener("abort", abort, { once: true });
614
- promise.then(resolve14, reject).finally(() => signal.removeEventListener("abort", abort));
620
+ promise.then(resolve15, reject).finally(() => signal.removeEventListener("abort", abort));
615
621
  });
616
622
  }
617
623
  __name(cancelled, "cancelled");
@@ -652,8 +658,8 @@ async function searchExa(query2, limit, context) {
652
658
  const deadline = Date.now() + DEADLINE_MS;
653
659
  const previous = tail;
654
660
  let release;
655
- tail = new Promise((resolve14) => {
656
- release = resolve14;
661
+ tail = new Promise((resolve15) => {
662
+ release = resolve15;
657
663
  });
658
664
  let acquired = false;
659
665
  try {
@@ -838,6 +844,8 @@ function describeHistoryRepairNotice(input) {
838
844
  return name ? `${name} didn\u2019t accept ${what}. Namzu kept the file but will leave it out of later messages. Attach a corrected copy to try again.` : `${what.charAt(0).toUpperCase()}${what.slice(1)} wasn\u2019t accepted. Namzu kept the file but will leave it out of later messages. Attach a corrected copy to try again.`;
839
845
  }
840
846
  if ((input.interruptedCalls ?? 0) > 0) {
847
+ if (input.neverRanCalls === input.interruptedCalls)
848
+ return "Some tool calls in this conversation never started, so Namzu marked them as not run. Nothing they asked for happened.";
841
849
  return input.source === "abandoned-checkpoint" ? "Your last reply was cut off before its steps finished, so Namzu marked them as unfinished. Check any files or commands they touched before asking again." : "Some steps in this conversation never finished, so Namzu marked them as unfinished. Check any files or commands they touched before asking again.";
842
850
  }
843
851
  return "Namzu cleaned up some leftover steps from earlier in this conversation. Nothing you need to do.";
@@ -853,8 +861,17 @@ var FALLBACK_WHY = {
853
861
  not_found: "does not have that model"
854
862
  };
855
863
  function describeProviderFallbackNotice(input) {
856
- const from = productName(input.fromProviderId) ?? "The first provider";
857
- const to = productName(input.toProviderId) ?? "another provider";
864
+ const named = /* @__PURE__ */ __name((id, model, unknown) => {
865
+ const product = productName(id) ?? unknown;
866
+ return model ? `${product} (${model})` : product;
867
+ }, "named");
868
+ const sameProvider = input.fromProviderId === input.toProviderId;
869
+ const from = named(
870
+ input.fromProviderId,
871
+ sameProvider ? input.fromModel : void 0,
872
+ "The first provider"
873
+ );
874
+ const to = named(input.toProviderId, input.toModel, "another provider");
858
875
  const why = FALLBACK_WHY[input.reason] ?? "could not answer";
859
876
  return `${from} ${why}, so Namzu used ${to} for the rest of that reply.`;
860
877
  }
@@ -1545,6 +1562,7 @@ __name(proposedBody, "proposedBody");
1545
1562
  // src/tui/tidy-tool-output.ts
1546
1563
  import { stripVTControlCharacters } from "node:util";
1547
1564
  var BACKGROUND_NOTE = "Running in the background (\u2193 to manage)";
1565
+ var CONTINUED_NOTE = "Continues in the background (\u2193 to manage)";
1548
1566
  function looksBinary(text2) {
1549
1567
  if (text2.includes("\0")) return true;
1550
1568
  if (text2.length === 0) return false;
@@ -1649,7 +1667,11 @@ function tidyCommandOutput(facts, raw) {
1649
1667
  }
1650
1668
  return withFailure(
1651
1669
  tidyTerminalOutput(raw).output,
1652
- cell([], [], facts.background ? BACKGROUND_NOTE : facts.exitNote)
1670
+ cell(
1671
+ [],
1672
+ [],
1673
+ facts.background ? facts.continued ? CONTINUED_NOTE : BACKGROUND_NOTE : facts.exitNote
1674
+ )
1653
1675
  );
1654
1676
  }
1655
1677
  __name(tidyCommandOutput, "tidyCommandOutput");
@@ -1722,6 +1744,7 @@ function factsHeadline(facts) {
1722
1744
  case "read": {
1723
1745
  const name = fileName(facts.path);
1724
1746
  if (facts.binary) return `Read ${name} \xB7 not text`;
1747
+ if (facts.unchanged) return `Read ${name} \xB7 unchanged`;
1725
1748
  if (facts.partial && facts.returnedLines !== void 0 && facts.totalLines !== void 0) {
1726
1749
  return `Read ${name} \xB7 ${facts.returnedLines.toLocaleString("en-US")} of ${plural(facts.totalLines, "line")}`;
1727
1750
  }
@@ -1821,7 +1844,7 @@ __name(oneLine, "oneLine");
1821
1844
  // src/tui/agent.ts
1822
1845
  import { SubprocessComputerUseHost } from "@namzu/computer-use";
1823
1846
  import { realpath as realpath4, stat as stat4 } from "node:fs/promises";
1824
- import { join as join14, parse, resolve as resolve13 } from "node:path";
1847
+ import { join as join15, parse, resolve as resolve14 } from "node:path";
1825
1848
 
1826
1849
  // src/checkpoints/store.ts
1827
1850
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -3333,8 +3356,9 @@ var NAMZU_IDENTITY = [
3333
3356
  var FOREGROUND_BASH_DESCRIPTION = "Executes one shell command in the foreground and returns stdout/stderr. Calls run one at a time, in order, because shell commands may change the same workspace; independent calls may still share one response.";
3334
3357
 
3335
3358
  // src/context/project-tracker.ts
3336
- import { realpathSync } from "node:fs";
3337
- import { dirname as dirname2, isAbsolute as isAbsolute5, join as join3, relative as relative4, resolve as resolve5, sep as sep2 } from "node:path";
3359
+ import { realpathSync as realpathSync2 } from "node:fs";
3360
+ import { homedir as homedir2 } from "node:os";
3361
+ import { dirname as dirname3, isAbsolute as isAbsolute5, join as join4, relative as relative5, resolve as resolve6, sep as sep3 } from "node:path";
3338
3362
 
3339
3363
  // src/context/project-path.ts
3340
3364
  function visibleProjectInstructionPath(path) {
@@ -3346,42 +3370,326 @@ function visibleProjectInstructionPath(path) {
3346
3370
  }
3347
3371
  __name(visibleProjectInstructionPath, "visibleProjectInstructionPath");
3348
3372
 
3373
+ // src/context/instruction-scope.ts
3374
+ import { lstatSync, readdirSync, realpathSync } from "node:fs";
3375
+ import { homedir } from "node:os";
3376
+ import { dirname as dirname2, extname, join as join3, relative as relative4, resolve as resolve5, sep as sep2 } from "node:path";
3377
+ var import_yaml = __toESM(require_dist(), 1);
3378
+
3379
+ // src/context/instruction-glob.ts
3380
+ function globToRegExp(glob) {
3381
+ let out = "";
3382
+ let braces = 0;
3383
+ for (let i = 0; i < glob.length; i += 1) {
3384
+ const ch = glob.charAt(i);
3385
+ if (ch === "*") {
3386
+ if (glob.charAt(i + 1) === "*") {
3387
+ if (glob.charAt(i + 2) === "/") {
3388
+ out += "(?:.*/)?";
3389
+ i += 2;
3390
+ } else {
3391
+ out += ".*";
3392
+ i += 1;
3393
+ }
3394
+ } else {
3395
+ out += "[^/]*";
3396
+ }
3397
+ } else if (ch === "?") {
3398
+ out += "[^/]";
3399
+ } else if (ch === "{") {
3400
+ braces += 1;
3401
+ out += "(?:";
3402
+ } else if (ch === "}" && braces > 0) {
3403
+ braces -= 1;
3404
+ out += ")";
3405
+ } else if (ch === "," && braces > 0) {
3406
+ out += "|";
3407
+ } else {
3408
+ out += ch.replace(/[.+^$()|[\]\\]/g, "\\$&");
3409
+ }
3410
+ }
3411
+ out += ")".repeat(braces);
3412
+ return new RegExp(`^${out}$`);
3413
+ }
3414
+ __name(globToRegExp, "globToRegExp");
3415
+ function matchesAnyGlob(relativePath, globs) {
3416
+ return globs.some((glob) => {
3417
+ try {
3418
+ return globToRegExp(glob.replace(/^\.\//, "")).test(relativePath);
3419
+ } catch {
3420
+ return false;
3421
+ }
3422
+ });
3423
+ }
3424
+ __name(matchesAnyGlob, "matchesAnyGlob");
3425
+
3426
+ // src/context/instruction-scope.ts
3427
+ var LOCAL_INSTRUCTIONS_FILENAME = "AGENTS.local.md";
3428
+ var RULES_DIRECTORY = join3(".namzu", "rules");
3429
+ var MAX_IMPORT_DEPTH = 5;
3430
+ var MAX_RULE_FILES = 200;
3431
+ var IMPORTABLE_EXTENSIONS = /* @__PURE__ */ new Set([
3432
+ ".md",
3433
+ ".markdown",
3434
+ ".mdx",
3435
+ ".txt",
3436
+ ".text",
3437
+ ".json",
3438
+ ".yaml",
3439
+ ".yml",
3440
+ ".toml"
3441
+ ]);
3442
+ function realKey(path) {
3443
+ try {
3444
+ return realpathSync(path);
3445
+ } catch {
3446
+ return resolve5(path);
3447
+ }
3448
+ }
3449
+ __name(realKey, "realKey");
3450
+ function ruleHeader(text2) {
3451
+ const match = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text2);
3452
+ if (!match) return { body: text2, globs: null };
3453
+ let data;
3454
+ try {
3455
+ data = (0, import_yaml.parse)(match[1] ?? "");
3456
+ } catch {
3457
+ return { body: text2, globs: null };
3458
+ }
3459
+ const body2 = text2.slice(match[0].length).trim();
3460
+ const raw = typeof data === "object" && data !== null ? data.paths : null;
3461
+ const list = (typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw : []).filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
3462
+ if (list.length === 0 || list.some((entry) => entry === "**" || entry === "**/*")) {
3463
+ return { body: body2, globs: null };
3464
+ }
3465
+ return { body: body2, globs: list };
3466
+ }
3467
+ __name(ruleHeader, "ruleHeader");
3468
+ function extractImportTokens(text2) {
3469
+ const tokens = [];
3470
+ let fence = null;
3471
+ for (const line of text2.split("\n")) {
3472
+ const marker = /^\s*(```+|~~~+)/.exec(line)?.[1];
3473
+ if (marker) {
3474
+ if (fence === null) fence = marker.charAt(0);
3475
+ else if (marker.startsWith(fence)) fence = null;
3476
+ continue;
3477
+ }
3478
+ if (fence !== null) continue;
3479
+ const plain = line.replace(/`[^`]*`/g, (span) => " ".repeat(span.length));
3480
+ for (const found of plain.matchAll(/(?:^|\s)@((?:\\ |[^\s])+)/g)) {
3481
+ if (found[1]) tokens.push(found[1]);
3482
+ }
3483
+ }
3484
+ return tokens;
3485
+ }
3486
+ __name(extractImportTokens, "extractImportTokens");
3487
+ function resolveImport(token, importer) {
3488
+ const cleaned = token.replace(/\\ /g, " ").replace(/#.*$/, "");
3489
+ if (cleaned.length === 0) return null;
3490
+ let path;
3491
+ if (cleaned.startsWith("~/")) path = join3(homedir(), cleaned.slice(2));
3492
+ else if (cleaned.startsWith("/")) path = cleaned;
3493
+ else path = resolve5(dirname2(importer), cleaned);
3494
+ return IMPORTABLE_EXTENSIONS.has(extname(path).toLowerCase()) ? path : null;
3495
+ }
3496
+ __name(resolveImport, "resolveImport");
3497
+ function followImports(collector, parent, depth) {
3498
+ if (depth > MAX_IMPORT_DEPTH) return;
3499
+ for (const token of extractImportTokens(parent.text)) {
3500
+ const candidate = resolveImport(token, parent.path);
3501
+ if (candidate === null) continue;
3502
+ let target;
3503
+ try {
3504
+ target = realpathSync(candidate);
3505
+ } catch {
3506
+ continue;
3507
+ }
3508
+ let isFile = false;
3509
+ try {
3510
+ isFile = lstatSync(target).isFile();
3511
+ } catch {
3512
+ continue;
3513
+ }
3514
+ if (!isFile) continue;
3515
+ if (!isContainedBy(target, collector.roots)) {
3516
+ collector.skipped.push({
3517
+ path: candidate,
3518
+ reason: `it is included by ${parent.path} but lies outside the folders an instruction file may include from`
3519
+ });
3520
+ continue;
3521
+ }
3522
+ if (collector.processed.has(target)) continue;
3523
+ collector.processed.add(target);
3524
+ const outcome = readInstructionAt(candidate, collector.roots);
3525
+ if (outcome.kind === "skipped") {
3526
+ collector.skipped.push(outcome.file);
3527
+ continue;
3528
+ }
3529
+ if (outcome.kind === "absent") continue;
3530
+ const imported = {
3531
+ ...outcome.file,
3532
+ kind: "import",
3533
+ importedBy: parent.path,
3534
+ ...parent.scopeDir ? { scopeDir: parent.scopeDir } : {}
3535
+ };
3536
+ collector.files.push(imported);
3537
+ followImports(collector, imported, depth + 1);
3538
+ }
3539
+ }
3540
+ __name(followImports, "followImports");
3541
+ function addTopLevel(collector, path, kind, scopeDir, rule) {
3542
+ const outcome = readInstructionAt(path, collector.roots);
3543
+ if (outcome.kind === "skipped") {
3544
+ collector.skipped.push(outcome.file);
3545
+ return;
3546
+ }
3547
+ if (outcome.kind === "absent") return;
3548
+ const key = realKey(path);
3549
+ if (collector.processed.has(key)) return;
3550
+ let file = {
3551
+ ...outcome.file,
3552
+ kind,
3553
+ ...scopeDir ? { scopeDir } : {}
3554
+ };
3555
+ if (rule) {
3556
+ const header = ruleHeader(file.text);
3557
+ if (header.globs !== null) {
3558
+ const active = collector.touched.some((touched) => {
3559
+ const rel = relative4(collector.matchBase, touched);
3560
+ return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep2}`) && matchesAnyGlob(rel.split(sep2).join("/"), header.globs ?? []);
3561
+ });
3562
+ if (!active) return;
3563
+ }
3564
+ if (header.body.length === 0) return;
3565
+ file = { ...file, text: header.body };
3566
+ }
3567
+ collector.processed.add(key);
3568
+ collector.files.push(file);
3569
+ followImports(collector, file, 1);
3570
+ }
3571
+ __name(addTopLevel, "addTopLevel");
3572
+ function listRuleFiles(directory, collector) {
3573
+ const found = [];
3574
+ const walk = /* @__PURE__ */ __name((dir, depth) => {
3575
+ if (depth > 8) return;
3576
+ let entries;
3577
+ try {
3578
+ entries = readdirSync(dir);
3579
+ } catch {
3580
+ return;
3581
+ }
3582
+ for (const name of [...entries].sort()) {
3583
+ const path = join3(dir, name);
3584
+ let stat5;
3585
+ try {
3586
+ stat5 = lstatSync(path);
3587
+ } catch {
3588
+ continue;
3589
+ }
3590
+ if (stat5.isDirectory()) walk(path, depth + 1);
3591
+ else if ((stat5.isFile() || stat5.isSymbolicLink()) && name.toLowerCase().endsWith(".md"))
3592
+ found.push(path);
3593
+ }
3594
+ }, "walk");
3595
+ walk(directory, 0);
3596
+ if (found.length > MAX_RULE_FILES) {
3597
+ collector.skipped.push({
3598
+ path: directory,
3599
+ reason: `it holds more than ${MAX_RULE_FILES} rule files, and only the first ${MAX_RULE_FILES} were read`
3600
+ });
3601
+ return found.slice(0, MAX_RULE_FILES);
3602
+ }
3603
+ return found;
3604
+ }
3605
+ __name(listRuleFiles, "listRuleFiles");
3606
+ function newCollector(options, matchBase) {
3607
+ return {
3608
+ roots: options.roots,
3609
+ touched: options.touched ?? [],
3610
+ matchBase,
3611
+ processed: /* @__PURE__ */ new Set(),
3612
+ files: [],
3613
+ skipped: []
3614
+ };
3615
+ }
3616
+ __name(newCollector, "newCollector");
3617
+ function loadScopeInstructions(directory, options) {
3618
+ const collector = newCollector(options, options.matchBase ?? directory);
3619
+ addTopLevel(collector, join3(directory, INSTRUCTIONS_FILENAME), "project", directory, false);
3620
+ for (const rule of listRuleFiles(join3(directory, RULES_DIRECTORY), collector)) {
3621
+ addTopLevel(collector, rule, "rule", directory, true);
3622
+ }
3623
+ addTopLevel(collector, join3(directory, LOCAL_INSTRUCTIONS_FILENAME), "local", directory, false);
3624
+ return { files: collector.files, skipped: collector.skipped };
3625
+ }
3626
+ __name(loadScopeInstructions, "loadScopeInstructions");
3627
+ function loadUserInstructions(namzuHome, options = {}) {
3628
+ const roots = [namzuHome, homedir()];
3629
+ const collector = newCollector({ ...options, roots }, options.matchBase ?? namzuHome);
3630
+ addTopLevel(collector, join3(namzuHome, INSTRUCTIONS_FILENAME), "user", void 0, false);
3631
+ for (const rule of listRuleFiles(join3(namzuHome, "rules"), collector)) {
3632
+ addTopLevel(collector, rule, "user", void 0, true);
3633
+ }
3634
+ return { files: collector.files, skipped: collector.skipped };
3635
+ }
3636
+ __name(loadUserInstructions, "loadUserInstructions");
3637
+ function userInstructionHome() {
3638
+ try {
3639
+ return resolveNamzuHome();
3640
+ } catch {
3641
+ return null;
3642
+ }
3643
+ }
3644
+ __name(userInstructionHome, "userInstructionHome");
3645
+
3349
3646
  // src/context/project-tracker.ts
3350
3647
  var MAX_TOTAL_PROJECT_INSTRUCTION_CHARS = 256e3;
3648
+ function emptyScope(directory) {
3649
+ return { directory, files: [], skipped: [] };
3650
+ }
3651
+ __name(emptyScope, "emptyScope");
3351
3652
  function canonicalRoot(path) {
3352
3653
  try {
3353
- return realpathSync(path);
3654
+ return realpathSync2(path);
3354
3655
  } catch {
3355
- return resolve5(path);
3656
+ return resolve6(path);
3356
3657
  }
3357
3658
  }
3358
3659
  __name(canonicalRoot, "canonicalRoot");
3359
3660
  function contained(root, candidate) {
3360
- const rel = relative4(root, candidate);
3361
- return rel === "" || !isAbsolute5(rel) && rel !== ".." && !rel.startsWith(`..${sep2}`);
3661
+ const rel = relative5(root, candidate);
3662
+ return rel === "" || !isAbsolute5(rel) && rel !== ".." && !rel.startsWith(`..${sep3}`);
3362
3663
  }
3363
3664
  __name(contained, "contained");
3364
3665
  function relativeInstructionPath(root, file) {
3365
- return relative4(root, file).split(sep2).join("/");
3666
+ return relative5(root, file).split(sep3).join("/");
3366
3667
  }
3367
3668
  __name(relativeInstructionPath, "relativeInstructionPath");
3368
- function scopeDepth(root, file) {
3369
- const rel = relative4(root, dirname2(file.path));
3370
- return rel === "" ? 0 : rel.split(sep2).length;
3669
+ function directoryDepth(root, directory) {
3670
+ const rel = relative5(root, directory);
3671
+ return rel === "" ? 0 : rel.split(sep3).length;
3672
+ }
3673
+ __name(directoryDepth, "directoryDepth");
3674
+ function displayPath2(root, path) {
3675
+ if (contained(root, path)) return relativeInstructionPath(root, path);
3676
+ const home = homedir2();
3677
+ return contained(home, path) ? `~/${relativeInstructionPath(home, path)}` : path;
3371
3678
  }
3372
- __name(scopeDepth, "scopeDepth");
3679
+ __name(displayPath2, "displayPath");
3373
3680
  function composeLivePrompt(root, files) {
3374
3681
  if (files.length === 0) return null;
3375
3682
  const sections = files.map((file) => {
3376
- const rel = relativeInstructionPath(root, file.path);
3377
- const scope2 = rel.split("/").slice(0, -1).join("/");
3378
- const applies = scope2.length === 0 ? "the whole project" : `only paths under \`${visibleProjectInstructionPath(scope2)}/\``;
3683
+ const kind = file.kind ?? "project";
3684
+ const scope2 = relativeInstructionPath(root, file.scopeDir ?? root);
3685
+ const applies = kind === "user" ? "every project" : scope2.length === 0 ? "the whole project" : `only paths under \`${visibleProjectInstructionPath(scope2)}/\``;
3686
+ const note = kind === "local" ? " This file is private to this checkout." : kind === "import" && file.importedBy ? ` Included from \`${visibleProjectInstructionPath(displayPath2(root, file.importedBy))}\`.` : "";
3379
3687
  const cut = file.omittedChars > 0 ? `
3380
3688
 
3381
3689
  (This file was cut at ${MAX_CHARS_PER_FILE} characters; ${file.omittedChars} more were not included. Read it with a tool if needed.)` : "";
3382
- return `### ${visibleProjectInstructionPath(rel)}
3690
+ return `### ${visibleProjectInstructionPath(displayPath2(root, file.path))}
3383
3691
 
3384
- Applies to ${applies}.
3692
+ Applies to ${applies}.${note}
3385
3693
 
3386
3694
  ${file.text}${cut}`;
3387
3695
  });
@@ -3393,7 +3701,8 @@ ${file.text}${cut}`;
3393
3701
  "nested file only inside its directory subtree; where applicable files",
3394
3702
  "conflict, the more specific directory wins. A sibling scope never applies",
3395
3703
  "outside its own subtree. These files win over Namzu's default style and",
3396
- "workflow, and never over safety or permission rules.",
3704
+ "workflow, and never over safety or permission rules. Your own file, when there",
3705
+ "is one, comes first and applies to every project.",
3397
3706
  "",
3398
3707
  sections.join("\n\n")
3399
3708
  ].join("\n");
@@ -3406,9 +3715,14 @@ var ProjectInstructionTracker = class {
3406
3715
  cwd;
3407
3716
  root;
3408
3717
  scopes = /* @__PURE__ */ new Map();
3409
- constructor(cwd) {
3718
+ userHome;
3719
+ /** Real paths the session has read or changed; they switch conditional rules on. */
3720
+ touched = /* @__PURE__ */ new Set();
3721
+ user = { files: [], skipped: [] };
3722
+ constructor(cwd, options = {}) {
3410
3723
  this.cwd = canonicalRoot(cwd);
3411
3724
  this.root = canonicalRoot(instructionSearchPath(this.cwd)[0] ?? this.cwd);
3725
+ this.userHome = options.userHome === void 0 ? userInstructionHome() : options.userHome;
3412
3726
  this.refreshDirectories(instructionSearchPath(this.cwd));
3413
3727
  }
3414
3728
  /** Re-read only paths named by validated provenance; persisted text is ignored. */
@@ -3417,9 +3731,9 @@ var ProjectInstructionTracker = class {
3417
3731
  if (message2.role !== "user" || message2.source?.type !== "project-instructions") continue;
3418
3732
  if (!isProjectInstructionMessageSource(message2.source)) continue;
3419
3733
  for (const file of message2.source.files) {
3420
- const absolute = resolve5(this.root, file);
3734
+ const absolute = resolve6(this.root, file);
3421
3735
  if (!contained(this.root, absolute)) continue;
3422
- this.registerPath(dirname2(absolute));
3736
+ this.registerPath(dirname3(absolute));
3423
3737
  }
3424
3738
  }
3425
3739
  this.refreshDirectories(this.scopes.keys());
@@ -3440,8 +3754,9 @@ var ProjectInstructionTracker = class {
3440
3754
  }, "observeToolResult")
3441
3755
  };
3442
3756
  }
3757
+ /** The files the person can edit; an included file is part of its includer. */
3443
3758
  get instructionFiles() {
3444
- return this.view().files.map((file) => file.path);
3759
+ return this.view().files.filter((file) => file.kind !== "import").map((file) => file.path);
3445
3760
  }
3446
3761
  get skippedInstructionFiles() {
3447
3762
  return this.view().skipped;
@@ -3454,88 +3769,100 @@ var ProjectInstructionTracker = class {
3454
3769
  return;
3455
3770
  }
3456
3771
  const rawPath = observation.input.path;
3457
- const lexical = resolve5(this.cwd, rawPath);
3772
+ const lexical = resolve6(this.cwd, rawPath);
3458
3773
  let target;
3459
3774
  try {
3460
- target = realpathSync(lexical);
3775
+ target = realpathSync2(lexical);
3461
3776
  } catch {
3462
3777
  return;
3463
3778
  }
3464
3779
  if (!contained(this.root, target)) return;
3465
- this.registerPath(dirname2(target));
3780
+ this.touched.add(target);
3781
+ this.registerPath(dirname3(target));
3466
3782
  this.refreshDirectories(this.scopes.keys());
3467
3783
  }
3468
3784
  registerPath(directory) {
3469
- const target = resolve5(directory);
3785
+ const target = resolve6(directory);
3470
3786
  if (!contained(this.root, target)) return;
3471
- const rel = relative4(this.root, target);
3787
+ const rel = relative5(this.root, target);
3472
3788
  let current = this.root;
3473
- if (!this.scopes.has(current)) this.scopes.set(current, { directory: current });
3789
+ if (!this.scopes.has(current)) this.scopes.set(current, emptyScope(current));
3474
3790
  if (rel === "") return;
3475
- for (const part of rel.split(sep2)) {
3476
- current = join3(current, part);
3477
- if (!this.scopes.has(current)) this.scopes.set(current, { directory: current });
3791
+ for (const part of rel.split(sep3)) {
3792
+ current = join4(current, part);
3793
+ if (!this.scopes.has(current)) this.scopes.set(current, emptyScope(current));
3478
3794
  }
3479
3795
  }
3480
3796
  refreshDirectories(directories) {
3797
+ const touched = [...this.touched];
3798
+ this.user = this.userHome === null ? { files: [], skipped: [] } : loadUserInstructions(this.userHome, { touched, matchBase: this.root });
3481
3799
  for (const directory of [...directories]) {
3482
3800
  this.registerPath(directory);
3483
- const loaded = loadProjectInstructions(directory);
3484
- const expected = join3(directory, INSTRUCTIONS_FILENAME);
3485
- const file = loaded.files.find((candidate) => candidate.path === expected);
3486
- const skipped = loaded.skipped.find((candidate) => candidate.path === expected);
3801
+ const loaded = loadScopeInstructions(directory, { roots: [this.root], touched });
3487
3802
  this.scopes.set(directory, {
3488
3803
  directory,
3489
- ...file ? { file } : {},
3490
- ...skipped ? { skipped } : {}
3804
+ files: loaded.files,
3805
+ skipped: loaded.skipped
3491
3806
  });
3492
3807
  }
3493
3808
  }
3494
3809
  view() {
3495
- const loaded = [...this.scopes.values()].flatMap((scope2) => scope2.file ? [scope2.file] : []);
3496
- const rootFile = loaded.find((file) => dirname2(file.path) === this.root);
3497
- const candidates = loaded.filter((file) => file !== rootFile).sort(
3498
- (a, b) => scopeDepth(this.root, b) - scopeDepth(this.root, a) || a.path.localeCompare(b.path)
3810
+ const scopes = [...this.scopes.values()];
3811
+ const bundles = scopes.filter((scope2) => scope2.files.length > 0).map((scope2) => ({ directory: scope2.directory, files: scope2.files }));
3812
+ const userBundle = this.user.files.length > 0 ? { directory: null, files: this.user.files } : null;
3813
+ const rootBundle = bundles.find((bundle) => bundle.directory === this.root);
3814
+ const candidates = bundles.filter((bundle) => bundle !== rootBundle).sort(
3815
+ (a, b) => directoryDepth(this.root, b.directory ?? this.root) - directoryDepth(this.root, a.directory ?? this.root) || (a.directory ?? "").localeCompare(b.directory ?? "")
3499
3816
  );
3500
3817
  const selected = [];
3501
3818
  let used = 0;
3502
- const skipped = [...this.scopes.values()].flatMap(
3503
- (scope2) => scope2.skipped ? [scope2.skipped] : []
3504
- );
3505
- for (const file of rootFile ? [rootFile, ...candidates] : candidates) {
3506
- const sourcePath = relativeInstructionPath(this.root, file.path);
3507
- if (!isProjectInstructionMessageSource({ type: "project-instructions", files: [sourcePath] })) {
3819
+ const skipped = [...scopes.flatMap((scope2) => scope2.skipped), ...this.user.skipped];
3820
+ const sourcePath = /* @__PURE__ */ __name((bundle) => bundle.directory === null || bundle.directory === this.root ? INSTRUCTIONS_FILENAME : `${relativeInstructionPath(this.root, bundle.directory)}/${INSTRUCTIONS_FILENAME}`, "sourcePath");
3821
+ const order = [
3822
+ ...userBundle ? [userBundle] : [],
3823
+ ...rootBundle ? [rootBundle] : [],
3824
+ ...candidates
3825
+ ];
3826
+ for (const bundle of order) {
3827
+ const chars = bundle.files.reduce((sum, file) => sum + file.text.length, 0);
3828
+ const bundleName = sourcePath(bundle);
3829
+ if (!isProjectInstructionMessageSource({
3830
+ type: "project-instructions",
3831
+ files: [bundleName]
3832
+ })) {
3508
3833
  skipped.push({
3509
- path: file.path,
3834
+ path: join4(bundle.directory ?? this.root, INSTRUCTIONS_FILENAME),
3510
3835
  reason: "its project-relative provenance is not a canonical bounded AGENTS.md path"
3511
3836
  });
3512
3837
  continue;
3513
3838
  }
3514
- if (selected.length >= MAX_PROJECT_INSTRUCTION_SOURCE_FILES || used + file.text.length > MAX_TOTAL_PROJECT_INSTRUCTION_CHARS) {
3839
+ if (selected.length >= MAX_PROJECT_INSTRUCTION_SOURCE_FILES || used + chars > MAX_TOTAL_PROJECT_INSTRUCTION_CHARS) {
3515
3840
  skipped.push({
3516
- path: file.path,
3841
+ path: join4(bundle.directory ?? this.root, INSTRUCTIONS_FILENAME),
3517
3842
  reason: `the live project-instruction snapshot is limited to ${MAX_TOTAL_PROJECT_INSTRUCTION_CHARS} characters and ${MAX_PROJECT_INSTRUCTION_SOURCE_FILES} files`
3518
3843
  });
3519
3844
  continue;
3520
3845
  }
3521
- selected.push(file);
3522
- used += file.text.length;
3846
+ selected.push(bundle);
3847
+ used += chars;
3523
3848
  }
3524
- selected.sort(
3525
- (a, b) => scopeDepth(this.root, a) - scopeDepth(this.root, b) || a.path.localeCompare(b.path)
3526
- );
3849
+ selected.sort((a, b) => {
3850
+ if (a.directory === null || b.directory === null) {
3851
+ return a.directory === b.directory ? 0 : a.directory === null ? -1 : 1;
3852
+ }
3853
+ return directoryDepth(this.root, a.directory) - directoryDepth(this.root, b.directory) || a.directory.localeCompare(b.directory);
3854
+ });
3855
+ const sources = [...new Set(selected.map(sourcePath))];
3527
3856
  return {
3528
- files: selected,
3529
- skipped: skipped.sort((a, b) => a.path.localeCompare(b.path))
3857
+ files: selected.flatMap((bundle) => bundle.files),
3858
+ skipped: skipped.sort((a, b) => a.path.localeCompare(b.path)),
3859
+ sources
3530
3860
  };
3531
3861
  }
3532
3862
  snapshot() {
3533
- const { files } = this.view();
3863
+ const { files, sources } = this.view();
3534
3864
  const prompt = composeLivePrompt(this.root, files);
3535
- return prompt ? createProjectInstructionMessage(
3536
- prompt,
3537
- files.map((file) => relativeInstructionPath(this.root, file.path))
3538
- ) : null;
3865
+ return prompt ? createProjectInstructionMessage(prompt, sources) : null;
3539
3866
  }
3540
3867
  snapshotKey(snapshot) {
3541
3868
  return snapshot ? JSON.stringify([
@@ -3606,7 +3933,7 @@ __name(sandboxResolvedSeverity, "sandboxResolvedSeverity");
3606
3933
 
3607
3934
  // src/integrations/sessions/conversation-search.ts
3608
3935
  import { randomBytes as randomBytes2 } from "node:crypto";
3609
- import { resolve as resolve6 } from "node:path";
3936
+ import { resolve as resolve7 } from "node:path";
3610
3937
 
3611
3938
  // src/integrations/sessions/evidence-page-validation.ts
3612
3939
  var integer = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0, "integer");
@@ -3653,7 +3980,7 @@ __name(assertEvidenceReadPage, "assertEvidenceReadPage");
3653
3980
  // src/integrations/sessions/conversation-search.ts
3654
3981
  var CONVERSATION_RETRIEVAL_TOOLS = ["read_conversation", "search_conversation"];
3655
3982
  var CONVERSATION_EVIDENCE_GUIDANCE = `## Conversation evidence
3656
- When a question asks about an earlier observation, use the evidence already in context. If the detail is missing or clipped, use search_conversation to locate the original recorded output, then read_conversation for exact text beyond an excerpt. Pass a supplied recall continuation's cursor to search_conversation to continue from the scan's existing position. This works before compaction as well as after compaction or restart, within this conversation only. New searches omit successful search_conversation/read_conversation outputs, which repeat earlier records. To inspect those outputs themselves, start a new search with includeRetrievalResults=true. excerptComplete=true means the entire full-retained text part is already shown: reading the same unchanged part adds no text or independent evidence. False or absent means partial or unknown. This does not establish the truth of a prior claim or exhaust the conversation.
3983
+ When a question asks about an earlier observation, use the evidence already in context. Before you investigate an error again, search this conversation for a short phrase from it, because an earlier turn may already hold the cause or the fix and finding it saves repeating the work. If the detail is missing or clipped, use search_conversation to locate the original recorded output, then read_conversation for exact text beyond an excerpt. Pass a supplied recall continuation's cursor to search_conversation to continue from the scan's existing position. This works before compaction as well as after compaction or restart, within this conversation only. New searches omit successful search_conversation/read_conversation outputs, which repeat earlier records. To inspect those outputs themselves, start a new search with includeRetrievalResults=true. excerptComplete=true means the entire full-retained text part is already shown: reading the same unchanged part adds no text or independent evidence. False or absent means partial or unknown. In recalled evidence, each \`visibleEvidence\` item holds a \`textQuote\` (a short exact match from text already in your context), the \`recordKind\` of the record it came from, the \`toolName\` that produced it and \`isError\` (whether that call failed); \`omittedVisibleEvidence\` counts quotes left out, and \`excerptGuidance\`, \`recordKindGuidance\` and \`visibleEvidenceGuidance\` are notes on reading these fields. This does not establish the truth of a prior claim or exhaust the conversation.
3657
3984
  A path following "The full output was written to:" is a file of this conversation's own retained output. Open it with the read tool when that tool is available (offset and limit page through it); for anything else from earlier, use search_conversation and read_conversation, which verify ownership and retained-byte integrity. Do not use bash or grep to get around a workspace-path refusal when recovering archived output.
3658
3985
  recordedAt is the event recorder\u2019s wall-clock time in Unix milliseconds, not the time its text became true. For compaction_shed it dates the copy, not the original observation. compaction_shed:summary identifies derived summary text, not an independent observation. Missing stamps stay unknown; clocks can move backwards or differ. seq orders the records of this conversation's log; it is not a clock.
3659
3986
  For what a file contained earlier, recover its earlier observation; reading or searching the current file cannot establish its past contents. For what is true now, inspect the current source when freshness matters. Do not substitute one time for the other. Report unavailable historical evidence honestly.`;
@@ -3692,7 +4019,7 @@ function parseQueryIdentity(identity) {
3692
4019
  }
3693
4020
  __name(parseQueryIdentity, "parseQueryIdentity");
3694
4021
  function conversationScope(sessions, sessionId) {
3695
- return JSON.stringify([resolve6(sessions.root), sessions.tenantId, sessions.projectId, sessionId]);
4022
+ return JSON.stringify([resolve7(sessions.root), sessions.tenantId, sessions.projectId, sessionId]);
3696
4023
  }
3697
4024
  __name(conversationScope, "conversationScope");
3698
4025
  var readLocations = /* @__PURE__ */ new Map();
@@ -5221,19 +5548,19 @@ function createBackgroundLearning(options) {
5221
5548
  const release = /* @__PURE__ */ __name(() => {
5222
5549
  const ready = waiters;
5223
5550
  waiters = [];
5224
- for (const resolve14 of ready) resolve14();
5551
+ for (const resolve15 of ready) resolve15();
5225
5552
  }, "release");
5226
5553
  const quiet = /* @__PURE__ */ __name(() => active === 0 && !options.questions?.isOpen(), "quiet");
5227
- const untilIdle = /* @__PURE__ */ __name((signal) => new Promise((resolve14, reject) => {
5554
+ const untilIdle = /* @__PURE__ */ __name((signal) => new Promise((resolve15, reject) => {
5228
5555
  if (signal.aborted) return reject(signal.reason);
5229
- if (quiet()) return resolve14();
5556
+ if (quiet()) return resolve15();
5230
5557
  const onAbort = /* @__PURE__ */ __name(() => {
5231
5558
  waiters = waiters.filter((w) => w !== done);
5232
5559
  reject(signal.reason);
5233
5560
  }, "onAbort");
5234
5561
  const done = /* @__PURE__ */ __name(() => {
5235
5562
  signal.removeEventListener("abort", onAbort);
5236
- resolve14();
5563
+ resolve15();
5237
5564
  }, "done");
5238
5565
  signal.addEventListener("abort", onAbort, { once: true });
5239
5566
  waiters.push(done);
@@ -5501,6 +5828,29 @@ __name(createMonitorInbox, "createMonitorInbox");
5501
5828
  // src/integrations/monitors/web-access-hint.ts
5502
5829
  var MONITOR_WEB_ACCESS_HINT = "To allow it, set `web.fetch: true` in the Namzu config file (~/.namzu/config.yaml); it cannot be switched on from the environment.";
5503
5830
 
5831
+ // src/integrations/plugins/hook-host.ts
5832
+ function hookPermissionMode(mode) {
5833
+ switch (mode) {
5834
+ case "accept-edits":
5835
+ return "acceptEdits";
5836
+ case "plan":
5837
+ return "plan";
5838
+ case "bypass":
5839
+ return "bypassPermissions";
5840
+ case "auto":
5841
+ return "bypassPermissions";
5842
+ case "classify":
5843
+ return "auto";
5844
+ default:
5845
+ return "default";
5846
+ }
5847
+ }
5848
+ __name(hookPermissionMode, "hookPermissionMode");
5849
+ function hookSessionMode(live, configured) {
5850
+ return hookPermissionMode(live ?? configured ?? "prompt");
5851
+ }
5852
+ __name(hookSessionMode, "hookSessionMode");
5853
+
5504
5854
  // src/integrations/plugins/settings.ts
5505
5855
  import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
5506
5856
  import {
@@ -5508,19 +5858,19 @@ import {
5508
5858
  closeSync,
5509
5859
  fstatSync,
5510
5860
  fsyncSync,
5511
- lstatSync,
5861
+ lstatSync as lstatSync2,
5512
5862
  openSync,
5513
5863
  readSync,
5514
5864
  renameSync,
5515
5865
  unlinkSync,
5516
5866
  writeFileSync
5517
5867
  } from "node:fs";
5518
- import { join as join4 } from "node:path";
5868
+ import { join as join5 } from "node:path";
5519
5869
  var MAX_RECORD_BYTES = 64 * 1024;
5520
5870
  var PluginSettingsStore = class {
5521
5871
  constructor(home) {
5522
5872
  this.home = home;
5523
- this.directory = join4(home, "plugin-settings");
5873
+ this.directory = join5(home, "plugin-settings");
5524
5874
  }
5525
5875
  home;
5526
5876
  static {
@@ -5529,17 +5879,17 @@ var PluginSettingsStore = class {
5529
5879
  directory;
5530
5880
  path(plugin) {
5531
5881
  const key = createHash3("sha256").update(JSON.stringify([plugin.rootDir, plugin.name])).digest("hex");
5532
- return join4(this.directory, `${key}.json`);
5882
+ return join5(this.directory, `${key}.json`);
5533
5883
  }
5534
5884
  read(plugin) {
5535
5885
  const path = this.path(plugin);
5536
5886
  try {
5537
5887
  try {
5538
- const directory = lstatSync(this.directory);
5888
+ const directory = lstatSync2(this.directory);
5539
5889
  if (!directory.isDirectory() || directory.isSymbolicLink()) {
5540
5890
  throw new Error("settings directory must be a real directory");
5541
5891
  }
5542
- const entry = lstatSync(path);
5892
+ const entry = lstatSync2(path);
5543
5893
  if (!entry.isFile() || entry.isSymbolicLink()) {
5544
5894
  throw new Error("setting must be a regular file");
5545
5895
  }
@@ -5605,7 +5955,7 @@ function message(error) {
5605
5955
  return error instanceof Error ? error.message : String(error);
5606
5956
  }
5607
5957
  __name(message, "message");
5608
- async function createCliPluginRuntime(config, cwd, hooks) {
5958
+ async function createCliPluginRuntime(config, cwd, hooks, hookHost) {
5609
5959
  const pluginsEnabled = config?.enabled === true;
5610
5960
  const hookCount = hooks ? Object.values(hooks).reduce((n, list) => n + (list?.length ?? 0), 0) : 0;
5611
5961
  if (!pluginsEnabled && hookCount === 0) return void 0;
@@ -5621,7 +5971,7 @@ async function createCliPluginRuntime(config, cwd, hooks) {
5621
5971
  log,
5622
5972
  ...config?.hookTimeoutMs !== void 0 ? { hookTimeoutMs: config.hookTimeoutMs } : {}
5623
5973
  });
5624
- if (hooks && hookCount > 0) attachShellHooks(manager, hooks, { cwd, log });
5974
+ if (hooks && hookCount > 0) attachShellHooks(manager, hooks, { cwd, log, ...hookHost });
5625
5975
  const allowedScopes = config?.allowedScopes ?? ["project", "user"];
5626
5976
  const discovered = pluginsEnabled ? await discoverAllPluginDirs(cwd, {
5627
5977
  enabled: true,
@@ -6225,7 +6575,7 @@ function estimateTokens(text2) {
6225
6575
  __name(estimateTokens, "estimateTokens");
6226
6576
  function createSideModel(deps) {
6227
6577
  const routes = /* @__PURE__ */ new Map();
6228
- const resolve14 = /* @__PURE__ */ __name(async (sessionId, signal) => {
6578
+ const resolve15 = /* @__PURE__ */ __name(async (sessionId, signal) => {
6229
6579
  const active = deps.active();
6230
6580
  if (deps.configured !== void 0) {
6231
6581
  const target = parseSmallModel(deps.configured, active.providerId, deps.isKnownProvider);
@@ -6262,7 +6612,7 @@ ${active.model}
6262
6612
  ${deps.configured ?? ""}`;
6263
6613
  let pending = routes.get(key);
6264
6614
  if (pending === void 0) {
6265
- pending = resolve14(sessionId, signal);
6615
+ pending = resolve15(sessionId, signal);
6266
6616
  routes.set(key, pending);
6267
6617
  void pending.then((value) => {
6268
6618
  if (signal.aborted && value.source === "main" && routes.get(key) === pending) {
@@ -7394,13 +7744,13 @@ function combineBatches(live, finished) {
7394
7744
  __name(combineBatches, "combineBatches");
7395
7745
 
7396
7746
  // src/integrations/subagents/definitions.ts
7397
- import { join as join5 } from "node:path";
7747
+ import { join as join6 } from "node:path";
7398
7748
  function userAgentsDir(home) {
7399
- return join5(namzuHomePath(home), "agents");
7749
+ return join6(namzuHomePath(home), "agents");
7400
7750
  }
7401
7751
  __name(userAgentsDir, "userAgentsDir");
7402
7752
  function projectAgentsDir(cwd) {
7403
- return join5(cwd, ".namzu", "agents");
7753
+ return join6(cwd, ".namzu", "agents");
7404
7754
  }
7405
7755
  __name(projectAgentsDir, "projectAgentsDir");
7406
7756
  function discoverAgentDefinitions2(opts) {
@@ -7425,7 +7775,7 @@ __name(prepareDelegatedEffort, "prepareDelegatedEffort");
7425
7775
 
7426
7776
  // src/integrations/subagents/operator-journal.ts
7427
7777
  import { appendFile, open as open2 } from "node:fs/promises";
7428
- import { join as join6 } from "node:path";
7778
+ import { join as join7 } from "node:path";
7429
7779
  var MAX_READ_BYTES = 256 * 1024;
7430
7780
  var MAX_CONTEXT_CHARACTERS = 32e3;
7431
7781
  function formatChildOperatorAdmission(input) {
@@ -7435,7 +7785,7 @@ function formatChildOperatorAdmission(input) {
7435
7785
  }
7436
7786
  __name(formatChildOperatorAdmission, "formatChildOperatorAdmission");
7437
7787
  async function readChildOperatorNotices(paths, sessionId) {
7438
- const path = join6(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
7788
+ const path = join7(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
7439
7789
  let file;
7440
7790
  try {
7441
7791
  file = await open2(path, "r");
@@ -7506,7 +7856,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
7506
7856
  })
7507
7857
  ).join("\n");
7508
7858
  await appendFile(
7509
- join6(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
7859
+ join7(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
7510
7860
  `${lines}
7511
7861
  `,
7512
7862
  { mode: 384 }
@@ -7515,7 +7865,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
7515
7865
  __name(acknowledgeChildOperatorNotices, "acknowledgeChildOperatorNotices");
7516
7866
  async function recordChildOperatorReport(paths, sessionId, notice) {
7517
7867
  await appendFile(
7518
- join6(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
7868
+ join7(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
7519
7869
  `${JSON.stringify({ ...notice, status: "child-report", source: "host", at: (/* @__PURE__ */ new Date()).toISOString() })}
7520
7870
  `,
7521
7871
  { mode: 384 }
@@ -7565,80 +7915,80 @@ __name(resolveSubagentParent, "resolveSubagentParent");
7565
7915
  // src/integrations/subagents/runtime.ts
7566
7916
  import { randomUUID as randomUUID4 } from "node:crypto";
7567
7917
  import { appendFile as appendFile2, mkdir as mkdir4 } from "node:fs/promises";
7568
- import { join as join10 } from "node:path";
7918
+ import { join as join11 } from "node:path";
7569
7919
 
7570
7920
  // src/memory/typed.ts
7571
7921
  import { createHash as createHash4 } from "node:crypto";
7572
7922
  import { access, readFile as readFile3, rename as rename3, writeFile as writeFile2 } from "node:fs/promises";
7573
- import { join as join9 } from "node:path";
7923
+ import { join as join10 } from "node:path";
7574
7924
 
7575
7925
  // src/memory/io.ts
7576
7926
  import {
7577
7927
  constants as constants2,
7578
7928
  closeSync as closeSync2,
7579
7929
  fstatSync as fstatSync2,
7580
- lstatSync as lstatSync2,
7930
+ lstatSync as lstatSync3,
7581
7931
  mkdirSync,
7582
7932
  openSync as openSync2,
7583
7933
  readSync as readSync2,
7584
- realpathSync as realpathSync2,
7934
+ realpathSync as realpathSync3,
7585
7935
  writeSync
7586
7936
  } from "node:fs";
7587
- import { isAbsolute as isAbsolute6, join as join7, relative as relative5, resolve as resolve7, sep as sep3 } from "node:path";
7937
+ import { isAbsolute as isAbsolute6, join as join8, relative as relative6, resolve as resolve8, sep as sep4 } from "node:path";
7588
7938
  var MEMORY_FILE_MAX_BYTES = 1024 * 1024;
7589
7939
  function missing(error) {
7590
7940
  return error.code === "ENOENT";
7591
7941
  }
7592
7942
  __name(missing, "missing");
7593
7943
  function within(path, root) {
7594
- const part = relative5(root, path);
7595
- return !isAbsolute6(part) && part !== ".." && !part.startsWith(`..${sep3}`);
7944
+ const part = relative6(root, path);
7945
+ return !isAbsolute6(part) && part !== ".." && !part.startsWith(`..${sep4}`);
7596
7946
  }
7597
7947
  __name(within, "within");
7598
7948
  function resolveMemoryPath(location, createParents = false) {
7599
- const root = resolve7(location.root);
7600
- const path = resolve7(location.path);
7949
+ const root = resolve8(location.root);
7950
+ const path = resolve8(location.path);
7601
7951
  if (!within(path, root)) throw new Error("Memory path is outside its allowed scope.");
7602
7952
  let rootStat;
7603
7953
  try {
7604
- rootStat = lstatSync2(root);
7954
+ rootStat = lstatSync3(root);
7605
7955
  } catch (error) {
7606
7956
  if (!missing(error)) throw error;
7607
7957
  if (!createParents) return null;
7608
7958
  mkdirSync(root, { recursive: true, mode: 448 });
7609
- rootStat = lstatSync2(root);
7959
+ rootStat = lstatSync3(root);
7610
7960
  }
7611
7961
  if (rootStat.isSymbolicLink())
7612
7962
  throw new Error("Memory scope root is a symlink outside its allowed scope.");
7613
7963
  if (!rootStat.isDirectory()) throw new Error("Memory scope root must be a directory.");
7614
- const canonicalRoot2 = realpathSync2(root);
7615
- const parts = relative5(root, path).split(sep3);
7964
+ const canonicalRoot2 = realpathSync3(root);
7965
+ const parts = relative6(root, path).split(sep4);
7616
7966
  let candidate = canonicalRoot2;
7617
7967
  for (let i = 0; i < parts.length; i += 1) {
7618
7968
  const part = parts[i];
7619
7969
  if (part === void 0) throw new Error("Memory path has an invalid segment.");
7620
- candidate = join7(candidate, part);
7970
+ candidate = join8(candidate, part);
7621
7971
  const leaf = i === parts.length - 1;
7622
7972
  let stat5;
7623
7973
  try {
7624
- stat5 = lstatSync2(candidate);
7974
+ stat5 = lstatSync3(candidate);
7625
7975
  } catch (error) {
7626
7976
  if (!missing(error)) throw error;
7627
7977
  if (!createParents) return null;
7628
7978
  if (leaf) return candidate;
7629
7979
  mkdirSync(candidate, { mode: 448 });
7630
- stat5 = lstatSync2(candidate);
7980
+ stat5 = lstatSync3(candidate);
7631
7981
  }
7632
7982
  if (stat5.isSymbolicLink()) {
7633
7983
  try {
7634
- candidate = realpathSync2(candidate);
7984
+ candidate = realpathSync3(candidate);
7635
7985
  } catch (error) {
7636
7986
  if (missing(error)) throw new Error("Memory path contains a broken symlink.");
7637
7987
  throw error;
7638
7988
  }
7639
7989
  if (!within(candidate, canonicalRoot2))
7640
7990
  throw new Error("Memory path resolves outside its allowed scope.");
7641
- stat5 = lstatSync2(candidate);
7991
+ stat5 = lstatSync3(candidate);
7642
7992
  }
7643
7993
  if (leaf ? !stat5.isFile() : !stat5.isDirectory()) {
7644
7994
  throw new Error(
@@ -7681,7 +8031,7 @@ function openMemory(location, append) {
7681
8031
  let existed = true;
7682
8032
  let before;
7683
8033
  try {
7684
- before = lstatSync2(path);
8034
+ before = lstatSync3(path);
7685
8035
  } catch (error) {
7686
8036
  if (!append || !missing(error)) throw error;
7687
8037
  existed = false;
@@ -7694,7 +8044,7 @@ function openMemory(location, append) {
7694
8044
  if (currentPath !== path || before && (opened.dev !== before.dev || opened.ino !== before.ino)) {
7695
8045
  throw new Error("Memory path changed while opening it; no content was read or appended.");
7696
8046
  }
7697
- const current = lstatSync2(path);
8047
+ const current = lstatSync3(path);
7698
8048
  if (!opened.isFile() || current.dev !== opened.dev || current.ino !== opened.ino) {
7699
8049
  throw new Error("Memory path changed or is not a regular file.");
7700
8050
  }
@@ -7741,32 +8091,32 @@ function appendMemoryFile(location, text2) {
7741
8091
  __name(appendMemoryFile, "appendMemoryFile");
7742
8092
 
7743
8093
  // src/memory/store.ts
7744
- import { realpathSync as realpathSync3 } from "node:fs";
7745
- import { join as join8, resolve as resolve8 } from "node:path";
8094
+ import { realpathSync as realpathSync4 } from "node:fs";
8095
+ import { join as join9, resolve as resolve9 } from "node:path";
7746
8096
  var MEMORY_SECTION_MAX_CHARS = 8e3;
7747
8097
  function memoryDir(home) {
7748
8098
  return namzuHomePath(home);
7749
8099
  }
7750
8100
  __name(memoryDir, "memoryDir");
7751
8101
  function userFilePath(home) {
7752
- return join8(memoryDir(home), "USER.md");
8102
+ return join9(memoryDir(home), "USER.md");
7753
8103
  }
7754
8104
  __name(userFilePath, "userFilePath");
7755
8105
  function memoryFilePath(home) {
7756
- return join8(memoryDir(home), "MEMORY.md");
8106
+ return join9(memoryDir(home), "MEMORY.md");
7757
8107
  }
7758
8108
  __name(memoryFilePath, "memoryFilePath");
7759
8109
  function projectMemoryFilePath(cwd) {
7760
- let directory = resolve8(cwd);
8110
+ let directory = resolve9(cwd);
7761
8111
  try {
7762
- directory = realpathSync3(directory);
8112
+ directory = realpathSync4(directory);
7763
8113
  } catch (error) {
7764
8114
  if (error.code !== "ENOENT") throw error;
7765
8115
  }
7766
8116
  const root = cliProjectRoot(directory);
7767
- const local = join8(directory, ".namzu", "MEMORY.md");
8117
+ const local = join9(directory, ".namzu", "MEMORY.md");
7768
8118
  if (resolveMemoryPath({ path: local, root }) !== null) return local;
7769
- return join8(root, ".namzu", "MEMORY.md");
8119
+ return join9(root, ".namzu", "MEMORY.md");
7770
8120
  }
7771
8121
  __name(projectMemoryFilePath, "projectMemoryFilePath");
7772
8122
  function projectMemoryLocation(cwd) {
@@ -7774,7 +8124,7 @@ function projectMemoryLocation(cwd) {
7774
8124
  }
7775
8125
  __name(projectMemoryLocation, "projectMemoryLocation");
7776
8126
  function projectLocation(cwd) {
7777
- const directory = realpathSync3(resolve8(cwd));
8127
+ const directory = realpathSync4(resolve9(cwd));
7778
8128
  return { path: projectMemoryFilePath(directory), root: cliProjectRoot(directory) };
7779
8129
  }
7780
8130
  __name(projectLocation, "projectLocation");
@@ -7796,27 +8146,27 @@ function readMemory(home, cwd) {
7796
8146
  }
7797
8147
  }, "read");
7798
8148
  const userRoot = memoryDir(home);
7799
- const user = read(join8(userRoot, "USER.md"), () => ({
8149
+ const user = read(join9(userRoot, "USER.md"), () => ({
7800
8150
  root: userRoot,
7801
- path: join8(userRoot, "USER.md")
8151
+ path: join9(userRoot, "USER.md")
7802
8152
  }));
7803
- const memory = read(join8(userRoot, "MEMORY.md"), () => ({
8153
+ const memory = read(join9(userRoot, "MEMORY.md"), () => ({
7804
8154
  root: userRoot,
7805
- path: join8(userRoot, "MEMORY.md")
8155
+ path: join9(userRoot, "MEMORY.md")
7806
8156
  }));
7807
- const project = cwd && !isUserMemoryFile(join8(resolve8(cwd), ".namzu", "MEMORY.md"), userRoot) ? read(join8(resolve8(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
8157
+ const project = cwd && !isUserMemoryFile(join9(resolve9(cwd), ".namzu", "MEMORY.md"), userRoot) ? read(join9(resolve9(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
7808
8158
  return { user, memory, project, ...diagnostics.length > 0 ? { diagnostics } : {} };
7809
8159
  }
7810
8160
  __name(readMemory, "readMemory");
7811
8161
  function isUserMemoryFile(projectPath, userRoot) {
7812
8162
  const canonical = /* @__PURE__ */ __name((path) => {
7813
8163
  try {
7814
- return realpathSync3(path);
8164
+ return realpathSync4(path);
7815
8165
  } catch {
7816
- return resolve8(path);
8166
+ return resolve9(path);
7817
8167
  }
7818
8168
  }, "canonical");
7819
- return canonical(projectPath) === canonical(join8(userRoot, "MEMORY.md"));
8169
+ return canonical(projectPath) === canonical(join9(userRoot, "MEMORY.md"));
7820
8170
  }
7821
8171
  __name(isUserMemoryFile, "isUserMemoryFile");
7822
8172
  function capped(text2, file) {
@@ -7908,7 +8258,7 @@ async function saveTypedNote(store, text2, type = "project") {
7908
8258
  saved: false,
7909
8259
  duplicate: true,
7910
8260
  type: record.entry.type ?? type,
7911
- ...record.entry.name ? { name: record.entry.name, path: join9(store.path, `${record.entry.name}.md`) } : {}
8261
+ ...record.entry.name ? { name: record.entry.name, path: join10(store.path, `${record.entry.name}.md`) } : {}
7912
8262
  };
7913
8263
  }
7914
8264
  }
@@ -7923,7 +8273,7 @@ async function saveTypedNote(store, text2, type = "project") {
7923
8273
  return {
7924
8274
  saved: true,
7925
8275
  type,
7926
- ...entry.name ? { name: entry.name, path: join9(store.path, `${entry.name}.md`) } : {}
8276
+ ...entry.name ? { name: entry.name, path: join10(store.path, `${entry.name}.md`) } : {}
7927
8277
  };
7928
8278
  }
7929
8279
  __name(saveTypedNote, "saveTypedNote");
@@ -7959,14 +8309,14 @@ function composeMemoryGuidance(options) {
7959
8309
  "- When you find a memory is wrong, correct or remove it, so a later session is not misled.",
7960
8310
  "- When the person asks you to remember something, save it. If the repository already records it, save only what was surprising or non-obvious about it. When they ask you to forget something, find it and remove it.",
7961
8311
  "",
7962
- "A recalled memory is a note from the past. Before acting on one that names a file, function, flag or command, check it against the current code, and trust what you observe now over the note."
8312
+ "A recalled memory is a note from the past. Before acting on one that names a file, function, flag or command, check it against the current code, and trust what you observe now over the note. A recalled line gives `updatedAt` (when the memory last changed, as a timestamp in milliseconds) and `sourceTurn` (the turn that saved it, when known)."
7963
8313
  ].join("\n");
7964
8314
  }
7965
8315
  __name(composeMemoryGuidance, "composeMemoryGuidance");
7966
8316
  var MARKER2 = "migration.json";
7967
8317
  async function readMarker(directory) {
7968
8318
  try {
7969
- const parsed = JSON.parse(await readFile3(join9(directory, MARKER2), "utf8"));
8319
+ const parsed = JSON.parse(await readFile3(join10(directory, MARKER2), "utf8"));
7970
8320
  return parsed !== null && typeof parsed === "object" ? parsed : {};
7971
8321
  } catch (error) {
7972
8322
  if (error.code === "ENOENT") return {};
@@ -7979,7 +8329,7 @@ async function markCuratedFile(directory, path, state) {
7979
8329
  const files = { ...marker.curatedFiles ?? {} };
7980
8330
  files[path] = { ...files[path] ?? {}, ...state };
7981
8331
  await writeFile2(
7982
- join9(directory, MARKER2),
8332
+ join10(directory, MARKER2),
7983
8333
  `${JSON.stringify({ ...marker, curatedFiles: files }, null, 2)}
7984
8334
  `,
7985
8335
  { mode: 384 }
@@ -8046,7 +8396,7 @@ async function migrateMemoryOnce(options) {
8046
8396
  const skippedRecords = [];
8047
8397
  let importedRecords = 0;
8048
8398
  let notesOffer;
8049
- const indexPath = join9(directory, "index.json");
8399
+ const indexPath = join10(directory, "index.json");
8050
8400
  if (await exists(indexPath)) {
8051
8401
  try {
8052
8402
  const disk = new DiskMemoryStore({ baseDir: directory, directory });
@@ -8069,11 +8419,11 @@ async function migrateMemoryOnce(options) {
8069
8419
  }
8070
8420
  }
8071
8421
  await retire(indexPath);
8072
- const content = join9(directory, "content");
8422
+ const content = join10(directory, "content");
8073
8423
  const retiredContent = await exists(content) ? await retire(content) : content;
8074
8424
  for (const record of refused) {
8075
8425
  skippedRecords.push(
8076
- `"${record.title}" (${record.id}) was not moved: ${record.reason} It is kept in ${join9(retiredContent, `${record.id}.json`)}.`
8426
+ `"${record.title}" (${record.id}) was not moved: ${record.reason} It is kept in ${join10(retiredContent, `${record.id}.json`)}.`
8077
8427
  );
8078
8428
  }
8079
8429
  } catch (error) {
@@ -8359,7 +8709,7 @@ function createSavedAgentHistory(scope2) {
8359
8709
  }
8360
8710
  __name(createSavedAgentHistory, "createSavedAgentHistory");
8361
8711
  var SAVED_AGENTS_KEY = "saved-agents";
8362
- var SAVED_AGENTS_ROWS = `Each row gives the agent's session id, what it was asked to do, and its status. Rows are listed once, when they are new or their status changed; "omitted" counts older agents that are not listed.`;
8712
+ var SAVED_AGENTS_ROWS = 'The JSON lists the agents under "savedAgents". Each row gives the agent\'s session id (`sessionId`), what it was asked to do (`description`), and its `status`. Rows are listed once, when they are new or their status changed; "omitted" counts older agents that are not listed.';
8363
8713
  function recordedRows(entries) {
8364
8714
  const known = /* @__PURE__ */ new Map();
8365
8715
  for (const entry of entries) {
@@ -8441,7 +8791,7 @@ __name(settledAnswer, "settledAnswer");
8441
8791
  // src/integrations/subagents/worktree-driver.ts
8442
8792
  import { execFile as execFile2 } from "node:child_process";
8443
8793
  import { mkdir as mkdir3, realpath as realpath3 } from "node:fs/promises";
8444
- import { isAbsolute as isAbsolute7, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
8794
+ import { isAbsolute as isAbsolute7, relative as relative7, resolve as resolve10, sep as sep5 } from "node:path";
8445
8795
  import { promisify as promisify2 } from "node:util";
8446
8796
  var runFile = promisify2(execFile2);
8447
8797
  var DelegatedWorktreeDriver = class {
@@ -8460,9 +8810,9 @@ var DelegatedWorktreeDriver = class {
8460
8810
  this.ready ??= openManagedWorktrees(this.cwd, {
8461
8811
  stateRoot: this.stateRoot
8462
8812
  }).then(async (managed) => {
8463
- const selectedDirectory = await realpath3(resolve9(this.cwd));
8464
- const subdirectory = relative6(managed.sourceRoot, selectedDirectory);
8465
- if (isAbsolute7(subdirectory) || subdirectory === ".." || subdirectory.startsWith(`..${sep4}`)) {
8813
+ const selectedDirectory = await realpath3(resolve10(this.cwd));
8814
+ const subdirectory = relative7(managed.sourceRoot, selectedDirectory);
8815
+ if (isAbsolute7(subdirectory) || subdirectory === ".." || subdirectory.startsWith(`..${sep5}`)) {
8466
8816
  throw new Error("Selected directory is outside its Git checkout");
8467
8817
  }
8468
8818
  return {
@@ -8508,6 +8858,18 @@ var MAX_NARRATION_INPUT_CODE_UNITS = MAX_NARRATION_CODE_UNITS * 2;
8508
8858
  var GENERAL_PURPOSE_SUBAGENT = "general-purpose";
8509
8859
  var EXPLORE_SUBAGENT = EXPLORE_AGENT_ID;
8510
8860
  var EXPLORE_PROMPT = [EXPLORE_AGENT_PROMPT, "", NAMZU_CHILD_WORKING_DOCTRINE].join("\n");
8861
+ var PLAN_SUBAGENT = PLAN_AGENT_ID;
8862
+ var PLAN_PROMPT = [PLAN_AGENT_PROMPT, "", NAMZU_CHILD_WORKING_DOCTRINE].join("\n");
8863
+ var READ_ONLY_PROMPTS = /* @__PURE__ */ new Map([
8864
+ [EXPLORE_SUBAGENT, EXPLORE_PROMPT],
8865
+ [PLAN_SUBAGENT, PLAN_PROMPT]
8866
+ ]);
8867
+ function readOnlyRoster(opts) {
8868
+ return opts.buildTools().map(
8869
+ (ts) => filtered(ts, (tool) => isTrustedReadOnly(tool, void 0, toToolSourceRef(ts.source)))
8870
+ );
8871
+ }
8872
+ __name(readOnlyRoster, "readOnlyRoster");
8511
8873
  function fileAgentTools(definition, opts) {
8512
8874
  return () => {
8513
8875
  const source = definition.readOnly ? opts.buildTools().map(
@@ -8606,9 +8968,16 @@ async function createSubagentRuntime(input) {
8606
8968
  EXPLORE_AGENT_DESCRIPTION,
8607
8969
  EXPLORE_PROMPT,
8608
8970
  opts,
8609
- () => opts.buildTools().map(
8610
- (ts) => filtered(ts, (tool) => isTrustedReadOnly(tool, void 0, toToolSourceRef(ts.source)))
8611
- )
8971
+ () => readOnlyRoster(opts)
8972
+ )
8973
+ );
8974
+ registry.register(
8975
+ buildDefinition(
8976
+ PLAN_SUBAGENT,
8977
+ PLAN_AGENT_DESCRIPTION,
8978
+ PLAN_PROMPT,
8979
+ opts,
8980
+ () => readOnlyRoster(opts)
8612
8981
  )
8613
8982
  );
8614
8983
  const fileAgents = /* @__PURE__ */ new Map();
@@ -8626,7 +8995,9 @@ async function createSubagentRuntime(input) {
8626
8995
  )
8627
8996
  );
8628
8997
  }
8629
- const agentTypeIds = [GENERAL_PURPOSE_SUBAGENT, EXPLORE_SUBAGENT, ...fileAgents.keys()];
8998
+ const agentTypeIds = [
8999
+ .../* @__PURE__ */ new Set([GENERAL_PURPOSE_SUBAGENT, EXPLORE_SUBAGENT, PLAN_SUBAGENT, ...fileAgents.keys()])
9000
+ ];
8630
9001
  const fileAgentSummary = [...fileAgents.values()].map((definition) => `"${definition.name}" \u2014 ${definition.description}`).join("; ");
8631
9002
  const conversations = /* @__PURE__ */ new Map();
8632
9003
  const taskViews = /* @__PURE__ */ new Map();
@@ -9094,7 +9465,7 @@ async function createSubagentRuntime(input) {
9094
9465
  } = input2;
9095
9466
  if (!requestedModel && (requestedProvider || requestedEffort))
9096
9467
  throw new Error("Supply model when selecting a child provider or effort.");
9097
- const explore = subagent_type === EXPLORE_SUBAGENT;
9468
+ const readOnlyType = subagent_type !== void 0 && READ_ONLY_PROMPTS.has(subagent_type) ? subagent_type : void 0;
9098
9469
  const fileAgent = subagent_type !== void 0 ? fileAgents.get(subagent_type) : void 0;
9099
9470
  const inherited = opts.resolveTurnModel?.(context.turnId);
9100
9471
  const parentModel = inherited?.model ?? opts.model;
@@ -9113,13 +9484,13 @@ async function createSubagentRuntime(input) {
9113
9484
  // of a turn on another model than the session's runs on that one.
9114
9485
  fileAgent?.model === void 0 ? inherited : void 0
9115
9486
  );
9116
- let agentId = fileAgent?.name ?? (explore ? EXPLORE_SUBAGENT : GENERAL_PURPOSE_SUBAGENT);
9487
+ let agentId = fileAgent?.name ?? readOnlyType ?? GENERAL_PURPOSE_SUBAGENT;
9117
9488
  const persona = typeof role === "string" ? role.trim() : "";
9118
9489
  const dynamic = persona.length > 0 || selection !== void 0;
9119
9490
  if (dynamic) {
9120
9491
  agentId = registerSpecialist({
9121
9492
  fileAgent,
9122
- explore,
9493
+ readOnlyType,
9123
9494
  persona,
9124
9495
  selection,
9125
9496
  model: selection?.model ?? fileAgent?.model ?? parentModel
@@ -9222,7 +9593,7 @@ async function createSubagentRuntime(input) {
9222
9593
  // has one cannot be rebuilt.
9223
9594
  ...persona.length === 0 ? {
9224
9595
  continuationProfile: {
9225
- agent: fileAgent?.name ?? (explore ? EXPLORE_SUBAGENT : GENERAL_PURPOSE_SUBAGENT),
9596
+ agent: fileAgent?.name ?? readOnlyType ?? GENERAL_PURPOSE_SUBAGENT,
9226
9597
  // The short name the operator saw, so a later run shows the same one.
9227
9598
  ...savedDescription(description) ? { description: savedDescription(description) } : {},
9228
9599
  ...selection ? {
@@ -9273,7 +9644,7 @@ async function createSubagentRuntime(input) {
9273
9644
  }
9274
9645
  }, "launchChild");
9275
9646
  const registerSpecialist = /* @__PURE__ */ __name((input2) => {
9276
- const { fileAgent, explore, persona, selection } = input2;
9647
+ const { fileAgent, readOnlyType, persona, selection } = input2;
9277
9648
  const id = `dyn-${++dynCounter}`;
9278
9649
  registry.register(
9279
9650
  buildDefinition(
@@ -9281,14 +9652,9 @@ async function createSubagentRuntime(input) {
9281
9652
  `Dynamic specialist: ${id}`,
9282
9653
  fileAgent ? `${fileAgent.prompt}
9283
9654
 
9284
- ${persona}` : persona || (explore ? EXPLORE_PROMPT : SUBAGENT_PROMPT),
9655
+ ${persona}` : persona || (readOnlyType !== void 0 ? READ_ONLY_PROMPTS.get(readOnlyType) ?? SUBAGENT_PROMPT : SUBAGENT_PROMPT),
9285
9656
  opts,
9286
- fileAgent ? fileAgentTools(fileAgent, opts) : explore ? () => opts.buildTools().map(
9287
- (ts) => filtered(
9288
- ts,
9289
- (tool) => isTrustedReadOnly(tool, void 0, toToolSourceRef(ts.source))
9290
- )
9291
- ) : opts.buildTools,
9657
+ fileAgent ? fileAgentTools(fileAgent, opts) : readOnlyType !== void 0 ? () => readOnlyRoster(opts) : opts.buildTools,
9292
9658
  input2.model,
9293
9659
  selection
9294
9660
  )
@@ -9301,10 +9667,11 @@ ${persona}` : persona || (explore ? EXPLORE_PROMPT : SUBAGENT_PROMPT),
9301
9667
  opts.backgroundByDefault === true ? "Delegate a self-contained task to a sub-agent. Agents run in the background by default: you get the task ID at once and are notified automatically when one ends, so continue with other work or answer the user instead of sleeping, polling or checking on its progress. Pass run_in_background: false only when your very next action depends on the result and nothing else could usefully happen while it runs. Operator input can also release a blocking wait while the child keeps working; answer the operator first and keep the child work unless they ask to cancel or change it. Use agent_task_list for current agent status (task_list is only the planning list), send_message to correct a running task, cancel_agent to stop only one owned task, and wait_for_task to retrieve its result; launch each piece of work once." : "Delegate a self-contained task to a sub-agent. Set run_in_background: true to receive its task ID immediately and continue independent work; completion arrives as a task notification. Otherwise wait for its result. Operator input can also release a blocking wait while the child keeps working; answer the operator first and keep the child work unless they ask to cancel or change it. Use agent_task_list for current agent status (task_list is only the planning list), send_message to correct a running task, cancel_agent to stop only one owned task, and wait_for_task to retrieve its result; launch each piece of work once.",
9302
9668
  opts.backgroundByDefault === true ? "For a request to run multiple independent tasks in parallel, issue all Agent calls together in one response. A blocking Agent call (run_in_background: false) followed by another call runs them sequentially." : "For a request to run multiple independent tasks in parallel, issue all Agent calls together in one response, or set run_in_background: true on each launch before waiting. A single blocking Agent call followed by another call runs them sequentially.",
9303
9669
  'Pick `subagent_type: "explore"` for anything that only needs to look \u2014 where is X defined, which files reference Y, how does Z work \u2014 it has reading and searching tools only and never asks for permission.',
9670
+ 'Pick `subagent_type: "plan"` when you need a design before changing code \u2014 it reads the code the same way and returns a step plan with the files to change and the risks, and cannot edit anything.',
9304
9671
  'Use the default "general-purpose" when the task must change files or run commands.',
9305
9672
  'Set `workspace: "worktree"` when the child needs its own Git checkout. It starts from this checkout\'s committed HEAD; uncommitted parent changes are absent. The checkout and its edits remain after the child ends, so report its path and branch to the operator.',
9306
9673
  "Define a specialist inline with `role` \u2014 a system prompt describing who the sub-agent is and how to behave (e.g.",
9307
- '"You are a security auditor; flag vulnerabilities and rate severity"); with `subagent_type: "explore"` the role keeps the read-only roster.',
9674
+ '"You are a security auditor; flag vulnerabilities and rate severity"); with `subagent_type: "explore"` or `"plan"` the role keeps the read-only roster.',
9308
9675
  "Omit `role` for the plain sub-agent.",
9309
9676
  "The sub-agent runs in its own context with its own tools and cannot see this conversation \u2014 put everything it needs in `prompt`.",
9310
9677
  "Call this multiple times in one response to run specialists in parallel. Tasks beyond the project's live-agent capacity wait in a queue and start as slots become available. Queued tasks have not started execution and start by themselves, so launch each once.",
@@ -9335,7 +9702,7 @@ ${persona}` : persona || (explore ? EXPLORE_PROMPT : SUBAGENT_PROMPT),
9335
9702
  subagent_type: {
9336
9703
  type: "string",
9337
9704
  enum: agentTypeIds,
9338
- description: `"explore" for read-only lookups (find, search, explain); "general-purpose" (default) when the task changes files or runs commands.${fileAgentSummary.length > 0 ? ` This project also defines: ${fileAgentSummary}. Prefer a project-defined type when its description fits the task.` : ""}`
9705
+ description: `"explore" for read-only lookups (find, search, explain); "plan" for a read-only step plan before a change; "general-purpose" (default) when the task changes files or runs commands.${fileAgentSummary.length > 0 ? ` This project also defines: ${fileAgentSummary}. Prefer a project-defined type when its description fits the task.` : ""}`
9339
9706
  },
9340
9707
  model: {
9341
9708
  type: "string",
@@ -9726,7 +10093,7 @@ ${step}`;
9726
10093
  const fileAgent = fileAgents.get(base);
9727
10094
  const id = registerSpecialist({
9728
10095
  fileAgent,
9729
- explore: base === EXPLORE_SUBAGENT,
10096
+ readOnlyType: READ_ONLY_PROMPTS.has(base) ? base : void 0,
9730
10097
  persona: "",
9731
10098
  selection: {
9732
10099
  provider: profile.provider,
@@ -10137,8 +10504,8 @@ ${step}`;
10137
10504
  owned.busy = true;
10138
10505
  let settleAdmission = /* @__PURE__ */ __name(() => {
10139
10506
  }, "settleAdmission");
10140
- owned.admitting = new Promise((resolve14) => {
10141
- settleAdmission = resolve14;
10507
+ owned.admitting = new Promise((resolve15) => {
10508
+ settleAdmission = resolve15;
10142
10509
  });
10143
10510
  const id = randomUUID4();
10144
10511
  let journal;
@@ -10173,7 +10540,7 @@ ${step}`;
10173
10540
  sessionId: parent.sessionId
10174
10541
  });
10175
10542
  await mkdir4(directory, { recursive: true, mode: 448 });
10176
- journal = join10(directory, "child-operator-messages.jsonl");
10543
+ journal = join11(directory, "child-operator-messages.jsonl");
10177
10544
  }
10178
10545
  await audit("submitted");
10179
10546
  signal.throwIfAborted();
@@ -10363,7 +10730,7 @@ ${step}`;
10363
10730
  if (typeof type !== "string") return false;
10364
10731
  const fileAgent = fileAgents.get(type);
10365
10732
  if (fileAgent) return fileAgent.readOnly && inherits(fileAgent.model);
10366
- return type === EXPLORE_SUBAGENT;
10733
+ return READ_ONLY_PROMPTS.has(type);
10367
10734
  },
10368
10735
  activity,
10369
10736
  launchWorkflowAgent,
@@ -10605,7 +10972,7 @@ __name(buildDefinition, "buildDefinition");
10605
10972
 
10606
10973
  // src/integrations/workflows/history.ts
10607
10974
  import { readFile as readFile4, readdir as readdir2 } from "node:fs/promises";
10608
- import { join as join11 } from "node:path";
10975
+ import { join as join12 } from "node:path";
10609
10976
  var RUN_ID = /^w[0-9a-z]{8}$/;
10610
10977
  async function readWorkflowJournal(file) {
10611
10978
  let text2;
@@ -10631,7 +10998,7 @@ async function readWorkflowJournal(file) {
10631
10998
  __name(readWorkflowJournal, "readWorkflowJournal");
10632
10999
  async function readWorkflowRun(runsDirectory, runId) {
10633
11000
  if (!RUN_ID.test(runId)) return void 0;
10634
- const records = await readWorkflowJournal(join11(runsDirectory, runId, "workflow", "journal.jsonl"));
11001
+ const records = await readWorkflowJournal(join12(runsDirectory, runId, "workflow", "journal.jsonl"));
10635
11002
  return viewFromJournal(records);
10636
11003
  }
10637
11004
  __name(readWorkflowRun, "readWorkflowRun");
@@ -10652,7 +11019,7 @@ __name(listWorkflowRuns, "listWorkflowRuns");
10652
11019
 
10653
11020
  // src/integrations/workflows/host.ts
10654
11021
  import { randomBytes as randomBytes3 } from "node:crypto";
10655
- import { join as join12 } from "node:path";
11022
+ import { join as join13 } from "node:path";
10656
11023
 
10657
11024
  // src/integrations/workflows/offering.ts
10658
11025
  var WORKFLOW_TOOL_NAME = "workflow";
@@ -10666,7 +11033,7 @@ var WORKFLOW_TOOL_DESCRIPTION = [
10666
11033
  'export const meta = { name: "audit", description: "One line the operator reads before it starts", phases: [{ title: "Scan" }, { title: "Fix", detail: "safe fixes only" }] }',
10667
11034
  "",
10668
11035
  "Then plain code. Everything below is a global:",
10669
- '- agent(prompt, opts?) starts one subagent and resolves to its final text, or to a parsed value when opts.schema (a JSON Schema) is given, or to null when it failed or was skipped. Always handle null. opts: label (a short row title), phase (a phase title), schema, agentType ("general-purpose", "explore", or a project agent), model, effort. The subagent cannot see this conversation or your variables: put everything it needs in the prompt.',
11036
+ '- agent(prompt, opts?) starts one subagent and resolves to its final text, or to a parsed value when opts.schema (a JSON Schema) is given, or to null when it failed or was skipped. Always handle null. opts: label (a short row title), phase (a phase title), schema, agentType ("general-purpose", "explore", "plan", or a project agent), model, effort. The subagent cannot see this conversation or your variables: put everything it needs in the prompt.',
10670
11037
  "- parallel([() => agent(...), ...]) starts every thunk now and resolves when all are done. It never rejects: a thunk that throws becomes null in its place and the reason goes through log(), so filter the nulls (.filter(Boolean)).",
10671
11038
  "- pipeline(items, stage1, stage2, ...) runs one chain per item with no barrier between stages; a stage gets (prevResult, originalItem, index), where the first stage gets the item as prevResult, and an item whose stage gives null stops there. It never rejects either: a stage that throws drops its item to null and the reason goes through log(), so filter the nulls.",
10672
11039
  "- phase(title) names the stage that the following agents belong to; inside parallel() or pipeline() pass opts.phase instead. Use the same titles as in meta.phases.",
@@ -10786,11 +11153,11 @@ var WorkflowRunRegistry = class {
10786
11153
  whenIdle(signal) {
10787
11154
  const going = /* @__PURE__ */ __name(() => [...this.runs.values()].some((run2) => !run2.finalized), "going");
10788
11155
  if (!going() || signal?.aborted) return Promise.resolve();
10789
- return new Promise((resolve14) => {
11156
+ return new Promise((resolve15) => {
10790
11157
  const done = /* @__PURE__ */ __name(() => {
10791
11158
  off();
10792
11159
  signal?.removeEventListener("abort", done);
10793
- resolve14();
11160
+ resolve15();
10794
11161
  }, "done");
10795
11162
  const off = this.subscribe(() => {
10796
11163
  if (!going()) done();
@@ -10998,13 +11365,13 @@ function createWorkflowHost(options) {
10998
11365
  const turn = options.openRunTurn(context.turnId, runId);
10999
11366
  const runs = options.runsDirectory(context.turnId);
11000
11367
  const limits = options.limitsFor?.(context.turnId);
11001
- const journal = runs === void 0 ? void 0 : new FileWorkflowJournal(join12(runs, runId, "workflow"));
11368
+ const journal = runs === void 0 ? void 0 : new FileWorkflowJournal(join13(runs, runId, "workflow"));
11002
11369
  const phaseDetail = /* @__PURE__ */ __name((title) => title === void 0 ? void 0 : meta.phases.find((phase) => phase.title.trim() === title.trim())?.detail, "phaseDetail");
11003
11370
  let launching = true;
11004
11371
  let settleLaunch = /* @__PURE__ */ __name(() => {
11005
11372
  }, "settleLaunch");
11006
- const launch = new Promise((resolve14) => {
11007
- settleLaunch = resolve14;
11373
+ const launch = new Promise((resolve15) => {
11374
+ settleLaunch = resolve15;
11008
11375
  });
11009
11376
  const detach = /* @__PURE__ */ __name(() => {
11010
11377
  if (!launching) return;
@@ -11330,14 +11697,29 @@ function createLiveModeControl(options) {
11330
11697
  }
11331
11698
  __name(createLiveModeControl, "createLiveModeControl");
11332
11699
 
11700
+ // src/permissions/read-only-gate.ts
11701
+ var NETWORK_CATEGORY = "network";
11702
+ var SEARCH_ALLOWANCE = { type: "allow_by_name", toolNames: ["web_search"] };
11703
+ function cliGate(rules) {
11704
+ return {
11705
+ enabled: true,
11706
+ allowReadOnlyTools: true,
11707
+ allowReadOnlyExcludeCategories: [NETWORK_CATEGORY],
11708
+ denyDangerousPatterns: true,
11709
+ logDecisions: false,
11710
+ rules: [...rules ?? [], SEARCH_ALLOWANCE]
11711
+ };
11712
+ }
11713
+ __name(cliGate, "cliGate");
11714
+
11333
11715
  // src/permissions/local-settings.ts
11334
11716
  import { execFile as execFile3 } from "node:child_process";
11335
11717
  import { existsSync, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
11336
11718
  import { appendFile as appendFile3, mkdir as mkdir5, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
11337
- import { homedir } from "node:os";
11338
- import { dirname as dirname3, isAbsolute as isAbsolute8, join as join13, resolve as resolve10 } from "node:path";
11719
+ import { homedir as homedir3 } from "node:os";
11720
+ import { dirname as dirname4, isAbsolute as isAbsolute8, join as join14, resolve as resolve11 } from "node:path";
11339
11721
  function localConfigPath(cwd) {
11340
- return resolve10(cwd, LOCAL_CONFIG_FILE);
11722
+ return resolve11(cwd, LOCAL_CONFIG_FILE);
11341
11723
  }
11342
11724
  __name(localConfigPath, "localConfigPath");
11343
11725
  function isRecord2(value) {
@@ -11412,14 +11794,14 @@ function git2(args, cwd, env) {
11412
11794
  });
11413
11795
  }
11414
11796
  __name(git2, "git");
11415
- function globalIgnorePath(configured2, env) {
11416
- const home = env.HOME ?? env.USERPROFILE ?? homedir();
11417
- const value = configured2.trim();
11418
- if (value === "~" || value.startsWith("~/")) return join13(home, value.slice(2));
11797
+ function globalIgnorePath(configured, env) {
11798
+ const home = env.HOME ?? env.USERPROFILE ?? homedir3();
11799
+ const value = configured.trim();
11800
+ if (value === "~" || value.startsWith("~/")) return join14(home, value.slice(2));
11419
11801
  if (value !== "" && isAbsolute8(value)) return value;
11420
11802
  const xdg = env.XDG_CONFIG_HOME;
11421
- if (xdg && isAbsolute8(xdg)) return join13(xdg, "git", "ignore");
11422
- return join13(home, ".config", "git", "ignore");
11803
+ if (xdg && isAbsolute8(xdg)) return join14(xdg, "git", "ignore");
11804
+ return join14(home, ".config", "git", "ignore");
11423
11805
  }
11424
11806
  __name(globalIgnorePath, "globalIgnorePath");
11425
11807
  async function ensureLocalConfigIgnored(cwd, env = process.env) {
@@ -11428,10 +11810,10 @@ async function ensureLocalConfigIgnored(cwd, env = process.env) {
11428
11810
  if (inside.code !== 0 || inside.stdout.trim() !== "true") return { state: "not-a-repository" };
11429
11811
  const ignored = /* @__PURE__ */ __name(async () => (await git2(["check-ignore", "--", LOCAL_CONFIG_FILE], cwd, env)).code === 0, "ignored");
11430
11812
  if (await ignored()) return { state: "ignored", written: false };
11431
- const configured2 = await git2(["config", "--global", "--get", "core.excludesfile"], cwd, env);
11432
- const file = globalIgnorePath(configured2.code === 0 ? configured2.stdout : "", env);
11813
+ const configured = await git2(["config", "--global", "--get", "core.excludesfile"], cwd, env);
11814
+ const file = globalIgnorePath(configured.code === 0 ? configured.stdout : "", env);
11433
11815
  const line = `**/${LOCAL_CONFIG_FILE}`;
11434
- await mkdir5(dirname3(file), { recursive: true });
11816
+ await mkdir5(dirname4(file), { recursive: true });
11435
11817
  let existing = "";
11436
11818
  try {
11437
11819
  existing = await readFile5(file, "utf-8");
@@ -11737,20 +12119,135 @@ function planApprovalRows(bypassAvailable) {
11737
12119
  }
11738
12120
  __name(planApprovalRows, "planApprovalRows");
11739
12121
  var EXIT_PLAN_MODE_TOOL_NAME = "exit_plan_mode";
12122
+ var ENTER_PLAN_MODE_TOOL_NAME = "enter_plan_mode";
12123
+
12124
+ // src/plan/enter-plan-mode-tool.ts
12125
+ var YES = "plan-first";
12126
+ var NO = "go-ahead";
12127
+ function enterPlanModeQuestion() {
12128
+ return {
12129
+ questionId: "enter-plan-mode",
12130
+ question: "Enter plan mode?",
12131
+ header: "Plan first",
12132
+ options: [
12133
+ {
12134
+ id: YES,
12135
+ label: "Yes, plan first",
12136
+ description: "Namzu reads and explores without changing anything, then shows a plan for your approval.",
12137
+ recommended: true
12138
+ },
12139
+ {
12140
+ id: NO,
12141
+ label: "No, go ahead",
12142
+ description: "Namzu carries on with the change as it is."
12143
+ }
12144
+ ],
12145
+ multiSelect: false,
12146
+ allowFreeText: false
12147
+ };
12148
+ }
12149
+ __name(enterPlanModeQuestion, "enterPlanModeQuestion");
12150
+ function enteredPlanModeText(planPath) {
12151
+ return [
12152
+ "Plan mode is on. Explore the codebase and design the approach without changing any file except the plan file.",
12153
+ "",
12154
+ "In plan mode:",
12155
+ "1. Read the code that the change touches and the patterns it should follow.",
12156
+ "2. Compare the realistic approaches and their trade-offs.",
12157
+ "3. Ask the user, with ask_user_question, whatever only they can decide.",
12158
+ `4. Write the plan to ${planPath}.`,
12159
+ `5. Present it with ${EXIT_PLAN_MODE_TOOL_NAME}; the user approves it or sends it back with changes.`
12160
+ ].join("\n");
12161
+ }
12162
+ __name(enteredPlanModeText, "enteredPlanModeText");
12163
+ var DECLINED_PLAN_MODE_TEXT = "The user chose not to plan first. Carry on with the change directly, and ask when something needs their decision.";
12164
+ var NOBODY_TO_ASK_TEXT = "Nobody can be asked about plan mode in this session. Carry on with the change directly.";
12165
+ function buildEnterPlanModeTool(host) {
12166
+ return defineTool({
12167
+ name: ENTER_PLAN_MODE_TOOL_NAME,
12168
+ description: `Ask the user to switch to plan mode before a change that is not small. In plan mode you explore read-only and present a plan for approval. Use it for a new feature, a change that has several reasonable approaches, an edit that spans several files or alters existing behaviour, an architectural choice, or a task whose scope you must explore first. Skip it for a one-line fix, a single function with clear requirements, a change the user has already specified in detail, and pure research. It takes no arguments and returns whether plan mode is on. Once on, write the plan to the plan file and present it with ${EXIT_PLAN_MODE_TOOL_NAME}.`,
12169
+ inputSchema: mcpJsonSchemaToZod({
12170
+ type: "object",
12171
+ properties: {},
12172
+ additionalProperties: false
12173
+ }),
12174
+ category: "custom",
12175
+ permissions: [],
12176
+ // Asks the person and changes nothing until they agree.
12177
+ readOnly: true,
12178
+ destructive: false,
12179
+ concurrencySafe: false,
12180
+ timeoutMs: 30 * 6e4,
12181
+ presentCall: /* @__PURE__ */ __name(() => ({
12182
+ kind: "generic",
12183
+ label: "Propose planning first",
12184
+ presentation: "activity"
12185
+ }), "presentCall"),
12186
+ presentResult: /* @__PURE__ */ __name((_input, result) => {
12187
+ const outcome = result.data?.outcome;
12188
+ if (outcome === "entered")
12189
+ return { kind: "generic", label: "Plan mode on", visibility: "hidden" };
12190
+ return outcome === "declined" ? { kind: "generic", label: "Going ahead without a plan", outcome: "cancelled" } : void 0;
12191
+ }, "presentResult"),
12192
+ async execute(_input, context) {
12193
+ context.abortSignal?.throwIfAborted();
12194
+ const mode = host.mode();
12195
+ if (mode === "plan") {
12196
+ return {
12197
+ success: true,
12198
+ output: "Plan mode is already on. Keep exploring, then present the plan with exit_plan_mode.",
12199
+ data: { outcome: "already" }
12200
+ };
12201
+ }
12202
+ if (mode !== "classify") {
12203
+ const ask = host.ask();
12204
+ if (!ask) {
12205
+ return {
12206
+ success: true,
12207
+ output: NOBODY_TO_ASK_TEXT,
12208
+ data: { outcome: "declined" }
12209
+ };
12210
+ }
12211
+ let answer;
12212
+ try {
12213
+ answer = await ask(enterPlanModeQuestion(), context.abortSignal);
12214
+ } catch {
12215
+ answer = { kind: "skip" };
12216
+ }
12217
+ context.abortSignal?.throwIfAborted();
12218
+ const chosen = answer.kind === "answer" && answer.selectedOptionIds.includes(YES);
12219
+ if (!chosen) {
12220
+ return {
12221
+ success: true,
12222
+ output: DECLINED_PLAN_MODE_TEXT,
12223
+ data: { outcome: "declined" }
12224
+ };
12225
+ }
12226
+ }
12227
+ await host.enter();
12228
+ return {
12229
+ success: true,
12230
+ output: enteredPlanModeText(host.planPath()),
12231
+ data: { outcome: "entered" }
12232
+ };
12233
+ }
12234
+ });
12235
+ }
12236
+ __name(buildEnterPlanModeTool, "buildEnterPlanModeTool");
11740
12237
 
11741
12238
  // src/plan/plan-file.ts
11742
12239
  import { readFile as readFile6 } from "node:fs/promises";
11743
- import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
12240
+ import { isAbsolute as isAbsolute9, resolve as resolve12 } from "node:path";
11744
12241
  var WRITERS = /* @__PURE__ */ new Set(["write", "edit"]);
11745
12242
  function isPlanFileWrite(planPath, cwd) {
11746
- const target = resolve11(planPath);
12243
+ const target = resolve12(planPath);
11747
12244
  return (call) => {
11748
12245
  if (!WRITERS.has(call.name)) return false;
11749
12246
  const input = call.input;
11750
12247
  if (input === null || typeof input !== "object") return false;
11751
12248
  const path = input.path;
11752
12249
  if (typeof path !== "string" || path.length === 0 || path.includes("\0")) return false;
11753
- return resolve11(isAbsolute9(path) ? path : resolve11(cwd, path)) === target;
12250
+ return resolve12(isAbsolute9(path) ? path : resolve12(cwd, path)) === target;
11754
12251
  };
11755
12252
  }
11756
12253
  __name(isPlanFileWrite, "isPlanFileWrite");
@@ -11763,6 +12260,23 @@ async function readPlan(planPath) {
11763
12260
  }
11764
12261
  }
11765
12262
  __name(readPlan, "readPlan");
12263
+ var MAX_CARRIED_PLAN_CHARS = 2e4;
12264
+ async function planCarriedAcrossCompaction(planPath) {
12265
+ const plan = await readPlan(planPath);
12266
+ if (plan === void 0) return void 0;
12267
+ const text2 = plan.length > MAX_CARRIED_PLAN_CHARS ? `${plan.slice(0, MAX_CARRIED_PLAN_CHARS)}
12268
+ \u2026 [the rest of the plan is in the file]` : plan;
12269
+ return [
12270
+ "### Plan file",
12271
+ "",
12272
+ `A plan from plan mode is saved at ${planPath}. Its current text:`,
12273
+ "",
12274
+ text2.trimEnd(),
12275
+ "",
12276
+ "If this plan is relevant to the work in progress, keep following it."
12277
+ ].join("\n");
12278
+ }
12279
+ __name(planCarriedAcrossCompaction, "planCarriedAcrossCompaction");
11766
12280
 
11767
12281
  // src/plan/exit-plan-mode-tool.ts
11768
12282
  function approvedPlanText(plan, planPath, answer) {
@@ -12135,6 +12649,7 @@ __name(planModeReminders, "planModeReminders");
12135
12649
  // src/reminders/task-nudge.ts
12136
12650
  var TASK_NUDGE_AFTER_TURNS = 10;
12137
12651
  var TASK_NUDGE_EVERY_TURNS = 10;
12652
+ var TASK_NUDGE_MIN_STEPS = 3;
12138
12653
  var TASK_TOOLS = /* @__PURE__ */ new Set(["task_create", "task_update"]);
12139
12654
  function taskNudgeCounts(messages) {
12140
12655
  let sinceTaskTool = 0;
@@ -12156,6 +12671,16 @@ function taskNudgeCounts(messages) {
12156
12671
  return { sinceTaskTool, sinceNudge };
12157
12672
  }
12158
12673
  __name(taskNudgeCounts, "taskNudgeCounts");
12674
+ function stepsThisRequest(messages) {
12675
+ let steps = 0;
12676
+ for (let i = messages.length - 1; i >= 0; i--) {
12677
+ const message2 = messages[i];
12678
+ if (isOperatorTurn(message2)) break;
12679
+ if (message2.role === "assistant" && (message2.toolCalls?.length ?? 0) > 0) steps++;
12680
+ }
12681
+ return steps;
12682
+ }
12683
+ __name(stepsThisRequest, "stepsThisRequest");
12159
12684
  function listText(tasks) {
12160
12685
  return tasks.map((task) => `#${task.id}. [${task.status}] ${task.subject}`).join("\n");
12161
12686
  }
@@ -12164,7 +12689,8 @@ function taskNudge(messages, tasks) {
12164
12689
  if (messages.length === 0) return [];
12165
12690
  const { sinceTaskTool, sinceNudge } = taskNudgeCounts(messages);
12166
12691
  if (sinceTaskTool < TASK_NUDGE_AFTER_TURNS || sinceNudge < TASK_NUDGE_EVERY_TURNS) return [];
12167
- const head = "You have not used the task tools for a while. If this work has steps worth tracking, add them with task_create and keep their status current with task_update (in_progress when you start one, completed when it is done); if the list has gone stale, tidy it. Only do so if it fits the work; otherwise ignore this note.";
12692
+ if (stepsThisRequest(messages) < TASK_NUDGE_MIN_STEPS) return [];
12693
+ const head = "This work has run several steps without the task tools. If it has three or more steps worth tracking, add them with task_create and keep their status current with task_update (in_progress when you start one, completed when it is done); if the list has gone stale, tidy it. Otherwise ignore this note. It is for you alone, so keep it out of your replies to the user.";
12168
12694
  return [
12169
12695
  frameReminder(
12170
12696
  "task-nudge",
@@ -12364,19 +12890,19 @@ async function resolveModelSwitch(request, options) {
12364
12890
  listed.set(detected.entry.id, listing);
12365
12891
  return listing.kind === "ok" && listing.models.some((candidate) => candidate.id === model);
12366
12892
  }, "inspect");
12367
- const resolve14 = /* @__PURE__ */ __name((detected) => ({
12893
+ const resolve15 = /* @__PURE__ */ __name((detected) => ({
12368
12894
  kind: "resolved",
12369
12895
  selection: { id: detected.entry.id, model }
12370
12896
  }), "resolve");
12371
12897
  const first = selected ?? usable.find(({ entry }) => entry.id === options.currentProvider);
12372
- if (first && await inspect(first)) return resolve14(first);
12898
+ if (first && await inspect(first)) return resolve15(first);
12373
12899
  const candidates = selected ? [selected] : usable;
12374
12900
  const matches = selected ? [] : (await Promise.all(
12375
12901
  candidates.filter((candidate) => candidate !== first).map(async (candidate) => await inspect(candidate) ? candidate : void 0)
12376
12902
  )).filter((candidate) => candidate !== void 0);
12377
12903
  signal?.throwIfAborted();
12378
12904
  const uniqueMatch = matches.length === 1 ? matches[0] : void 0;
12379
- if (uniqueMatch) return resolve14(uniqueMatch);
12905
+ if (uniqueMatch) return resolve15(uniqueMatch);
12380
12906
  if (matches.length > 1) {
12381
12907
  return {
12382
12908
  kind: "rejected",
@@ -12406,8 +12932,8 @@ async function resolveModelSwitch(request, options) {
12406
12932
  __name(resolveModelSwitch, "resolveModelSwitch");
12407
12933
 
12408
12934
  // src/tui/read-search-group.ts
12409
- import { homedir as homedir2 } from "node:os";
12410
- import { isAbsolute as isAbsolute10, relative as relative7, resolve as resolve12, sep as sep5 } from "node:path";
12935
+ import { homedir as homedir4 } from "node:os";
12936
+ import { isAbsolute as isAbsolute10, relative as relative8, resolve as resolve13, sep as sep6 } from "node:path";
12411
12937
  var EMPTY_GROUP = {
12412
12938
  readKeys: [],
12413
12939
  anonymousReads: 0,
@@ -12645,17 +13171,17 @@ function classifyShell(command) {
12645
13171
  return void 0;
12646
13172
  }
12647
13173
  __name(classifyShell, "classifyShell");
12648
- function displayPath2(path, cwd) {
12649
- const abs = cwd && !isAbsolute10(path) ? resolve12(cwd, path) : path;
13174
+ function displayPath3(path, cwd) {
13175
+ const abs = cwd && !isAbsolute10(path) ? resolve13(cwd, path) : path;
12650
13176
  if (cwd) {
12651
- const rel = relative7(cwd, abs);
13177
+ const rel = relative8(cwd, abs);
12652
13178
  if (rel.length > 0 && !rel.startsWith("..") && !isAbsolute10(rel)) return rel;
12653
13179
  }
12654
- const home = homedir2();
12655
- if (home && (abs === home || abs.startsWith(home + sep5))) return `~${abs.slice(home.length)}`;
13180
+ const home = homedir4();
13181
+ if (home && (abs === home || abs.startsWith(home + sep6))) return `~${abs.slice(home.length)}`;
12656
13182
  return abs;
12657
13183
  }
12658
- __name(displayPath2, "displayPath");
13184
+ __name(displayPath3, "displayPath");
12659
13185
  function text(value) {
12660
13186
  return typeof value === "string" && value.length > 0 ? value : void 0;
12661
13187
  }
@@ -12683,7 +13209,7 @@ function classifyCall(call) {
12683
13209
  case "view_image": {
12684
13210
  const path = text(input.path);
12685
13211
  if (!path) return void 0;
12686
- const shown = displayPath2(path, call.cwd);
13212
+ const shown = displayPath3(path, call.cwd);
12687
13213
  return { kind: "read", key: shown, hint: shown };
12688
13214
  }
12689
13215
  case "grep":
@@ -12693,7 +13219,7 @@ function classifyCall(call) {
12693
13219
  }
12694
13220
  case "ls": {
12695
13221
  const path = text(input.path);
12696
- return { kind: "list", ...path ? { hint: displayPath2(path, call.cwd) } : {} };
13222
+ return { kind: "list", ...path ? { hint: displayPath3(path, call.cwd) } : {} };
12697
13223
  }
12698
13224
  case "bash": {
12699
13225
  const command = text(input.command);
@@ -12836,8 +13362,8 @@ var SessionOperationOwner = class {
12836
13362
  })()[Symbol.asyncIterator]();
12837
13363
  let settled = false;
12838
13364
  let settle;
12839
- const settlement = new Promise((resolve14) => {
12840
- settle = resolve14;
13365
+ const settlement = new Promise((resolve15) => {
13366
+ settle = resolve15;
12841
13367
  });
12842
13368
  let operationTail = Promise.resolve();
12843
13369
  let returnStarted = false;
@@ -13098,10 +13624,10 @@ function clipRequestContext(prompt, limit, kind) {
13098
13624
  __name(clipRequestContext, "clipRequestContext");
13099
13625
  async function createAgentSession(prefs, detected, options = {}) {
13100
13626
  if (options.palEnvironment) {
13101
- const { createPalAgentSession } = await import("./agent-session-LHOJDS75.js");
13627
+ const { createPalAgentSession } = await import("./agent-session-3MUZCWQ4.js");
13102
13628
  return createPalAgentSession(prefs, detected, options);
13103
13629
  }
13104
- const { palAtWorkspace } = await import("./store-QLG76DQG.js");
13630
+ const { palAtWorkspace } = await import("./store-D3XUEEAF.js");
13105
13631
  if (palAtWorkspace(options.cwd ?? process.cwd()))
13106
13632
  throw new Error("This Pal requires its owned virtual computer. Open it with namzu pal chat.");
13107
13633
  const commandArguments = builtinCommandArguments();
@@ -13109,7 +13635,7 @@ async function createAgentSession(prefs, detected, options = {}) {
13109
13635
  const sessionAllows = createSessionAllows(commandArguments, {
13110
13636
  cwd: /* @__PURE__ */ __name(() => cwd, "cwd")
13111
13637
  });
13112
- const sessionRules = [...options.rules ?? [], sessionAllows.rule];
13638
+ let sessionRules = [...options.rules ?? [], sessionAllows.rule];
13113
13639
  const fileObservations = /* @__PURE__ */ new Map();
13114
13640
  const observationsFor = /* @__PURE__ */ __name((id, prior) => {
13115
13641
  let seeded = fileObservations.get(id);
@@ -13138,7 +13664,7 @@ async function createAgentSession(prefs, detected, options = {}) {
13138
13664
  }
13139
13665
  return seeded;
13140
13666
  }, "observationsFor");
13141
- const requestedCwd = resolve13(options.cwd ?? process.cwd());
13667
+ const requestedCwd = resolve14(options.cwd ?? process.cwd());
13142
13668
  let cwd;
13143
13669
  try {
13144
13670
  const entry2 = await stat4(requestedCwd);
@@ -13170,13 +13696,13 @@ async function createAgentSession(prefs, detected, options = {}) {
13170
13696
  paths = options.conversationSessions.paths;
13171
13697
  projectId = options.conversationSessions.projectId;
13172
13698
  } else {
13173
- const home = resolve13(options.stateRoot ?? resolveNamzuHome());
13699
+ const home = resolve14(options.stateRoot ?? resolveNamzuHome());
13174
13700
  ensurePrivateStateDirectory(home, "projects");
13175
13701
  const project = await ensureProject({ home, cwd: cliProjectRoot(cwd) });
13176
13702
  paths = new SessionPaths({ home, slug: project.slug });
13177
13703
  projectId = project.projectId;
13178
13704
  }
13179
- ensurePrivateStateDirectory(resolve13(paths.projectDir(), ".."), paths.slug);
13705
+ ensurePrivateStateDirectory(resolve14(paths.projectDir(), ".."), paths.slug);
13180
13706
  ensurePrivateStateDirectory(paths.projectDir(), "memory");
13181
13707
  } catch (error) {
13182
13708
  return emptySession(
@@ -13428,6 +13954,7 @@ async function createAgentSession(prefs, detected, options = {}) {
13428
13954
  });
13429
13955
  throw err;
13430
13956
  }
13957
+ sessionRules = withSandboxShell(sessionRules, sandbox);
13431
13958
  cliLogger()[sandboxResolvedSeverity(sandbox)](sandbox.notice, {
13432
13959
  [EVENT_NAME_ATTRIBUTE]: BOOT_EVENT_NAMES.SANDBOX_RESOLVED,
13433
13960
  "namzu.sandbox.unconfined": sandbox.unconfined
@@ -13470,8 +13997,8 @@ async function createAgentSession(prefs, detected, options = {}) {
13470
13997
  }
13471
13998
  const directories = [];
13472
13999
  for (const dir of options.additionalDirectories ?? []) {
13473
- const absolute = resolve13(cwd, dir);
13474
- if (absolute !== resolve13(cwd) && !directories.includes(absolute)) directories.push(absolute);
14000
+ const absolute = resolve14(cwd, dir);
14001
+ if (absolute !== resolve14(cwd) && !directories.includes(absolute)) directories.push(absolute);
13475
14002
  }
13476
14003
  const sessionDirectories = createSessionDirectories(cwd, directories);
13477
14004
  const checkpoints = new FileCheckpointStore(
@@ -13675,7 +14202,7 @@ async function createAgentSession(prefs, detected, options = {}) {
13675
14202
  }
13676
14203
  let sideModel;
13677
14204
  let learning;
13678
- const webCapability = options.web?.fetch ? {
14205
+ const webCapability = options.web?.fetch !== false ? {
13679
14206
  // A page may be ten mebibytes; the guard's own
13680
14207
  // default is two.
13681
14208
  fetch: new GuardedFetchProvider({ maxBytes: WEB_FETCH_MAX_BYTES }),
@@ -13994,7 +14521,7 @@ async function createAgentSession(prefs, detected, options = {}) {
13994
14521
  runsDirectory: /* @__PURE__ */ __name((turnId) => {
13995
14522
  if (options.ephemeral) return void 0;
13996
14523
  const owner = delegationScopes.get(turnId) ?? scope2;
13997
- return join14(paths.sessionDir({ sessionId: owner.sessionId }), "runs");
14524
+ return join15(paths.sessionDir({ sessionId: owner.sessionId }), "runs");
13998
14525
  }, "runsDirectory"),
13999
14526
  refusal: /* @__PURE__ */ __name((turnId) => {
14000
14527
  const auth = delegatedWorkflowAuth.get(turnId);
@@ -14195,6 +14722,20 @@ async function createAgentSession(prefs, detected, options = {}) {
14195
14722
  })
14196
14723
  ])
14197
14724
  );
14725
+ toolsets.push(
14726
+ deferred(
14727
+ toolset("plan-mode-entry", [
14728
+ buildEnterPlanModeTool({
14729
+ mode: /* @__PURE__ */ __name(() => currentPlanHost?.mode() ?? "prompt", "mode"),
14730
+ planPath: /* @__PURE__ */ __name(() => currentPlanHost?.planPath ?? paths.planFile({ sessionId: scope2.sessionId }), "planPath"),
14731
+ ask: /* @__PURE__ */ __name(() => currentOnQuestion, "ask"),
14732
+ enter: /* @__PURE__ */ __name(async () => {
14733
+ await currentPlanHost?.enter?.();
14734
+ }, "enter")
14735
+ })
14736
+ ])
14737
+ )
14738
+ );
14198
14739
  }
14199
14740
  if (options.extraTools && options.extraTools.length > 0) {
14200
14741
  toolsets.push(toolset("extra", options.extraTools));
@@ -14213,7 +14754,7 @@ async function createAgentSession(prefs, detected, options = {}) {
14213
14754
  );
14214
14755
  toolsets.push(options.toolLoading === "eager" ? monitorToolset : deferred(monitorToolset));
14215
14756
  }
14216
- const operatorPals = await import("./operator-tools-ISZGHK3F.js");
14757
+ const operatorPals = await import("./operator-tools-2OYRNPCH.js");
14217
14758
  toolsets.push(
14218
14759
  readyWhen(
14219
14760
  toolset(
@@ -14276,9 +14817,13 @@ async function createAgentSession(prefs, detected, options = {}) {
14276
14817
  const hasSaveSkillTool = (options.extraTools ?? []).some(
14277
14818
  (tool) => tool.name === SAVE_SKILL_TOOL_NAME
14278
14819
  );
14820
+ let readHookMode;
14279
14821
  let pluginRuntime;
14280
14822
  try {
14281
- pluginRuntime = await createCliPluginRuntime(options.plugins, cwd, options.hooks);
14823
+ pluginRuntime = await createCliPluginRuntime(options.plugins, cwd, options.hooks, {
14824
+ permissionMode: /* @__PURE__ */ __name(() => hookSessionMode(readHookMode?.(), options.permissionMode), "permissionMode"),
14825
+ transcriptPath: /* @__PURE__ */ __name((sessionId) => options.ephemeral ? void 0 : paths.sessionLog({ sessionId }), "transcriptPath")
14826
+ });
14282
14827
  } catch (error) {
14283
14828
  await Promise.allSettled([mcp.close(), computerUseHost?.dispose(), browserControl?.dispose()]);
14284
14829
  return emptySession(
@@ -14628,6 +15173,7 @@ async function createAgentSession(prefs, detected, options = {}) {
14628
15173
  ],
14629
15174
  ...options.compaction?.consolidate ? { consolidateInto: memoryStore } : { promoteMemory },
14630
15175
  projectInstructionContext: projectInstructions.createTurnContext(),
15176
+ ...resumePlanPath ? { postCompactionContext: /* @__PURE__ */ __name(() => planCarriedAcrossCompaction(resumePlanPath), "postCompactionContext") } : {},
14631
15177
  paths,
14632
15178
  ...sandbox.provider ? { sandboxProvider: sandbox.provider } : {},
14633
15179
  ...options.sandbox?.teardownTimeoutMs !== void 0 ? { sandboxTeardownTimeoutMs: options.sandbox.teardownTimeoutMs } : {},
@@ -14652,7 +15198,10 @@ async function createAgentSession(prefs, detected, options = {}) {
14652
15198
  // The gate's deny rules still apply.
14653
15199
  resumeHandler,
14654
15200
  approvalPolicyName: modeControl.initialName,
14655
- onApprovalPolicy: /* @__PURE__ */ __name((box) => modeControl.attach(box), "onApprovalPolicy"),
15201
+ onApprovalPolicy: /* @__PURE__ */ __name((box) => {
15202
+ readHookMode = /* @__PURE__ */ __name(() => modeControl.current(), "readHookMode");
15203
+ modeControl.attach(box);
15204
+ }, "onApprovalPolicy"),
14656
15205
  reviewAllowedCalls,
14657
15206
  signal: ownedSignal,
14658
15207
  // Attribution comes from the ENTRY, not from this session: the turn
@@ -14765,8 +15314,8 @@ async function createAgentSession(prefs, detected, options = {}) {
14765
15314
  if (mapped) yield mapped;
14766
15315
  }
14767
15316
  if (settled) break;
14768
- await new Promise((resolve14) => {
14769
- wake = resolve14;
15317
+ await new Promise((resolve15) => {
15318
+ wake = resolve15;
14770
15319
  });
14771
15320
  wake = void 0;
14772
15321
  }
@@ -14819,8 +15368,10 @@ async function createAgentSession(prefs, detected, options = {}) {
14819
15368
  const sessionId = scope2.sessionId;
14820
15369
  const sessions = options.conversationSessions;
14821
15370
  await prepareProviderCredential(signal);
15371
+ const planNote = options.planApproval && !options.ephemeral ? await planCarriedAcrossCompaction(paths.planFile({ sessionId })) : void 0;
14822
15372
  const common = {
14823
15373
  config: compactionConfigFor(options.compaction),
15374
+ ...planNote ? { restoreNote: planNote } : {},
14824
15375
  provider: providerForSession(sessionId),
14825
15376
  model,
14826
15377
  signal,
@@ -14922,6 +15473,15 @@ async function createAgentSession(prefs, detected, options = {}) {
14922
15473
  currentTaskStore,
14923
15474
  resetTaskStore,
14924
15475
  jobs: /* @__PURE__ */ __name(() => ownedJobs?.list() ?? [], "jobs"),
15476
+ ...jobRegistry ? {
15477
+ foreground: {
15478
+ commands: /* @__PURE__ */ __name(() => jobRegistry.foregroundCommands(jobOwner), "commands"),
15479
+ background: /* @__PURE__ */ __name((reason) => jobRegistry.backgroundForeground(jobOwner, reason), "background"),
15480
+ onChange: /* @__PURE__ */ __name((listener) => jobRegistry.onForegroundChange((owner) => {
15481
+ if (owner === jobOwner) listener();
15482
+ }), "onChange")
15483
+ }
15484
+ } : {},
14925
15485
  ...ownedJobs ? {
14926
15486
  readJob: /* @__PURE__ */ __name((id, fromOffset) => ownedJobs.read(id, fromOffset === void 0 ? {} : { fromOffset }), "readJob"),
14927
15487
  stopJob: /* @__PURE__ */ __name((id) => ownedJobs.kill(id), "stopJob")
@@ -14966,7 +15526,7 @@ async function createAgentSession(prefs, detected, options = {}) {
14966
15526
  const live = host.registry.list();
14967
15527
  const known = new Set(live.map((view) => view.runId));
14968
15528
  const saved = options.ephemeral ? [] : await listWorkflowRuns(
14969
- join14(paths.sessionDir({ sessionId: scope2.sessionId }), "runs")
15529
+ join15(paths.sessionDir({ sessionId: scope2.sessionId }), "runs")
14970
15530
  ).catch(() => []);
14971
15531
  return [
14972
15532
  ...[...live].sort((a, b) => b.startedAt - a.startedAt),
@@ -15308,6 +15868,7 @@ async function createAgentSession(prefs, detected, options = {}) {
15308
15868
  mode: /* @__PURE__ */ __name(() => modeControl.current(), "mode"),
15309
15869
  planPath,
15310
15870
  approval: opts?.onPlanExit,
15871
+ enter: opts?.onPlanEnter,
15311
15872
  bypassAvailable: opts?.bypassAvailable ?? (() => false)
15312
15873
  } : void 0;
15313
15874
  const [environmentFacts, turnSnapshot] = await Promise.all([
@@ -15331,6 +15892,12 @@ async function createAgentSession(prefs, detected, options = {}) {
15331
15892
  for (const contribution of pluginRuntime?.manager.promptContributions ?? []) {
15332
15893
  promptContributions.register(contribution);
15333
15894
  }
15895
+ if (options.appendSystem)
15896
+ promptContributions.register({
15897
+ id: "namzu.cli.append-system",
15898
+ placement: "dynamic",
15899
+ render: /* @__PURE__ */ __name(() => options.appendSystem ?? null, "render")
15900
+ });
15334
15901
  for (const [serverName, spec] of Object.entries(options.mcpServers ?? {})) {
15335
15902
  if (spec?.instructions !== true) continue;
15336
15903
  promptContributions.register({
@@ -15593,10 +16160,14 @@ async function createAgentSession(prefs, detected, options = {}) {
15593
16160
  systemPrompt,
15594
16161
  messages,
15595
16162
  projectInstructionContext: projectInstructions.createTurnContext(),
16163
+ ...planPath ? { postCompactionContext: /* @__PURE__ */ __name(() => planCarriedAcrossCompaction(planPath), "postCompactionContext") } : {},
15596
16164
  opts: turnOpts,
15597
16165
  resumeHandler,
15598
16166
  approvalPolicyName: modeControl.initialName,
15599
- onApprovalPolicy: /* @__PURE__ */ __name((box) => modeControl.attach(box), "onApprovalPolicy"),
16167
+ onApprovalPolicy: /* @__PURE__ */ __name((box) => {
16168
+ readHookMode = /* @__PURE__ */ __name(() => modeControl.current(), "readHookMode");
16169
+ modeControl.attach(box);
16170
+ }, "onApprovalPolicy"),
15600
16171
  reviewAllowedCalls: modeControl.reviewAllowedCalls,
15601
16172
  taskGateway: await subagentRuntime?.gatewayForTurn(turnId),
15602
16173
  completionInbox: await subagentRuntime?.completionInboxForTurn(turnId),
@@ -16043,15 +16614,8 @@ function mintScope(projectId, sessionId) {
16043
16614
  };
16044
16615
  }
16045
16616
  __name(mintScope, "mintScope");
16046
- var VERIFICATION_GATE = {
16047
- enabled: true,
16048
- allowReadOnlyTools: true,
16049
- denyDangerousPatterns: true,
16050
- logDecisions: false,
16051
- rules: []
16052
- };
16053
16617
  function gateFor(rules) {
16054
- return { ...VERIFICATION_GATE, rules: [...rules ?? []] };
16618
+ return cliGate(rules);
16055
16619
  }
16056
16620
  __name(gateFor, "gateFor");
16057
16621
  var MAX_OUTPUT_CONTINUATIONS = 3;
@@ -16292,20 +16856,28 @@ async function* runTurn({
16292
16856
  }
16293
16857
  } catch (err) {
16294
16858
  if (isTurnInProgressError(err)) {
16859
+ const freeInMinutes = err.state === "running" ? minutesUntilFree(
16860
+ await (sessionLog ?? DiskSessionLog.at(paths, { sessionId: scope2.sessionId })).lease().catch(() => null),
16861
+ Date.now()
16862
+ ) : void 0;
16295
16863
  yield {
16296
16864
  kind: "error",
16297
- message: `This conversation already has a ${err.state} reply. ${err.state === "running" ? "Wait for it to finish." : "Resume it with /resume, or close it with /abandon."}`,
16865
+ message: freeInMinutes !== void 0 ? conversationInUseSentence(freeInMinutes) : `This conversation already has a ${err.state} reply. ${err.state === "running" ? "Wait for it to finish." : "Resume it with /resume, or close it with /abandon."}`,
16298
16866
  turnInProgress: {
16299
16867
  sessionId: String(err.sessionId),
16300
16868
  activeTurnId: String(err.activeTurnId),
16301
- state: err.state
16869
+ state: err.state,
16870
+ ...freeInMinutes !== void 0 ? { freeInMinutes } : {}
16302
16871
  }
16303
16872
  };
16304
16873
  return;
16305
16874
  }
16306
16875
  yield {
16307
16876
  kind: "error",
16308
- message: err instanceof Error ? err.message : String(err)
16877
+ message: err instanceof Error ? err.message : String(err),
16878
+ // A refusal Namzu raised before the turn began carries its facts (which
16879
+ // model, which limit), so a screen can say it in plain words.
16880
+ ...isNamzuError(err) ? { failure: toPlatformError(err) } : {}
16309
16881
  };
16310
16882
  } finally {
16311
16883
  turnManager.dispose();
@@ -16627,7 +17199,11 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
16627
17199
  ...event.windowSource !== void 0 ? { windowSource: event.windowSource } : {}
16628
17200
  };
16629
17201
  case "provider_fallback":
16630
- return { kind: "provider-fallback", text: describeFallback(event) };
17202
+ return {
17203
+ kind: "provider-fallback",
17204
+ text: describeFallback(event),
17205
+ ...event.restart ? { restart: true } : {}
17206
+ };
16631
17207
  case "capability_warning":
16632
17208
  return {
16633
17209
  kind: "capability-warning",
@@ -16660,6 +17236,7 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
16660
17236
  duplicateResults: event.duplicateToolResultsRemoved,
16661
17237
  orphanedResults: event.orphanedToolResultsRemoved,
16662
17238
  interruptedCalls: event.syntheticToolResultsInserted,
17239
+ ...event.neverRanToolResultsInserted ? { neverRanCalls: event.neverRanToolResultsInserted } : {},
16663
17240
  text: `Tool history repaired before the model call: ${changes.join("; ")}. Verify external state before retrying non-idempotent tools.`
16664
17241
  };
16665
17242
  }
@@ -16671,6 +17248,7 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
16671
17248
  subject: event.subject,
16672
17249
  status: event.status,
16673
17250
  ...event.blockedBy ? { blockedBy: event.blockedBy.map(String) } : {},
17251
+ ...event.activeForm ? { activeForm: event.activeForm } : {},
16674
17252
  ...event.type === "task_updated" && event.deleted ? { removed: true } : {}
16675
17253
  };
16676
17254
  case "turn_paused":
@@ -16765,7 +17343,9 @@ function describeFallback(event) {
16765
17343
  describeProviderFallbackNotice({
16766
17344
  fromProviderId: event.fromProviderId,
16767
17345
  toProviderId: event.toProviderId,
16768
- reason: event.code
17346
+ reason: event.code,
17347
+ ...event.fromModel ? { fromModel: event.fromModel } : {},
17348
+ ...event.toModel ? { toModel: event.toModel } : {}
16769
17349
  }),
16770
17350
  raw,
16771
17351
  debugRequested()
@@ -17018,6 +17598,7 @@ export {
17018
17598
  createCurrentCredentialReader,
17019
17599
  createTaskContextStep,
17020
17600
  createLiveModeControl,
17601
+ cliGate,
17021
17602
  IdleCompactor,
17022
17603
  IDLE_COMPACTION_NOTICE,
17023
17604
  describeCapabilityNotice,
@@ -17116,4 +17697,4 @@ export {
17116
17697
  RESULT_SUMMARY_WHOLE_MAX,
17117
17698
  resultSummaryLine
17118
17699
  };
17119
- //# sourceMappingURL=chunk-JEULHVUH.js.map
17700
+ //# sourceMappingURL=chunk-F6WVRMVY.js.map