@namzu/cli 53.0.1 → 53.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-IOWTKF2X.js → acp-3FNB6MSI.js} +101 -82
  4. package/dist/chunks/acp-3FNB6MSI.js.map +6 -0
  5. package/dist/chunks/{activity-command-U2AOTIVF.js → activity-command-IBOJOCRF.js} +15 -15
  6. package/dist/chunks/{add-YYQLPCP2.js → add-LYBL3IC7.js} +27 -27
  7. package/dist/chunks/{agent-WL6NX4W6.js → agent-LTLWJW3P.js} +47 -43
  8. package/dist/chunks/agent-session-BD2AHK5S.js +77 -0
  9. package/dist/chunks/{apply-at-exit-BRXYTQVG.js → apply-at-exit-7BF3KBU2.js} +8 -8
  10. package/dist/chunks/{archive-UE756BME.js → archive-FCPUCOYT.js} +14 -14
  11. package/dist/chunks/{bin-main-XR2DJOI6.js → bin-main-AVPCWJHJ.js} +14 -14
  12. package/dist/chunks/{binding-HCIPLFUO.js → binding-OZCOSUYV.js} +3 -3
  13. package/dist/chunks/{browser-7SFVCKSO.js → browser-LR25NVO7.js} +6 -6
  14. package/dist/chunks/{chat-K6GQGRUA.js → chat-PP7XU7US.js} +22 -22
  15. package/dist/chunks/{chunk-3NAVAACC.js → chunk-2KNLSJFS.js} +2 -2
  16. package/dist/chunks/{chunk-2VSICYQP.js → chunk-2O6LZGGG.js} +2 -2
  17. package/dist/chunks/{chunk-V7VNFYA4.js → chunk-32LCSSAN.js} +18 -14
  18. package/dist/chunks/chunk-32LCSSAN.js.map +6 -0
  19. package/dist/chunks/{chunk-Z5NMQ2YN.js → chunk-3Q42HHZM.js} +2 -2
  20. package/dist/chunks/{chunk-RAPO3KLG.js → chunk-3WTIGIDA.js} +4 -4
  21. package/dist/chunks/chunk-4JBQTRTF.js +452 -0
  22. package/dist/chunks/chunk-4JBQTRTF.js.map +6 -0
  23. package/dist/chunks/{chunk-NICPMJJQ.js → chunk-4KMFIIWV.js} +6 -5
  24. package/dist/chunks/{chunk-NICPMJJQ.js.map → chunk-4KMFIIWV.js.map} +1 -1
  25. package/dist/chunks/{chunk-5NDRDTNX.js → chunk-4NVFHP23.js} +6 -6
  26. package/dist/chunks/chunk-4NVFHP23.js.map +6 -0
  27. package/dist/chunks/{chunk-FX7BSCB4.js → chunk-4Q4J3KDG.js} +4 -4
  28. package/dist/chunks/{chunk-KO2N6EIF.js → chunk-4VB264C5.js} +13 -13
  29. package/dist/chunks/{chunk-HJILJSZO.js → chunk-4VXS3UYL.js} +2 -2
  30. package/dist/chunks/{chunk-2WDF5N2A.js → chunk-5FEAC3G5.js} +9 -9
  31. package/dist/chunks/{chunk-BHOZPFJM.js → chunk-5HCZHDPA.js} +5 -5
  32. package/dist/chunks/chunk-5OAKUXE3.js +41 -0
  33. package/dist/chunks/chunk-5OAKUXE3.js.map +6 -0
  34. package/dist/chunks/{chunk-U4XNJBDB.js → chunk-5WORROIE.js} +8 -1
  35. package/dist/chunks/{chunk-U4XNJBDB.js.map → chunk-5WORROIE.js.map} +1 -1
  36. package/dist/chunks/{chunk-Z5FDI74K.js → chunk-5YNAPIUZ.js} +6 -6
  37. package/dist/chunks/{chunk-A47ZNTW7.js → chunk-6SHOR62K.js} +3 -3
  38. package/dist/chunks/{chunk-46VSU4QF.js → chunk-72IJ3FQU.js} +2 -2
  39. package/dist/chunks/{chunk-DHS5CQNC.js → chunk-AO4A56EG.js} +12 -12
  40. package/dist/chunks/{chunk-KAPCNFMC.js → chunk-BFCUL4BW.js} +3 -3
  41. package/dist/chunks/{chunk-DOFQWVBL.js → chunk-CKWDYYBE.js} +3 -3
  42. package/dist/chunks/{chunk-J3PHMXN4.js → chunk-CSBKGTBA.js} +4 -4
  43. package/dist/chunks/{chunk-ZMKEYARZ.js → chunk-D3JJE6VZ.js} +6 -6
  44. package/dist/chunks/{chunk-UWN4WNQZ.js → chunk-DEEK2FOC.js} +2 -2
  45. package/dist/chunks/chunk-DEH4YIDN.js +247 -0
  46. package/dist/chunks/chunk-DEH4YIDN.js.map +6 -0
  47. package/dist/chunks/{chunk-F3SQRGKZ.js → chunk-DSMBM5LQ.js} +2 -2
  48. package/dist/chunks/chunk-DZBCLR75.js +526 -0
  49. package/dist/chunks/chunk-DZBCLR75.js.map +6 -0
  50. package/dist/chunks/{chunk-4FV2VZS6.js → chunk-EC2F3CWT.js} +3 -3
  51. package/dist/chunks/{chunk-OBMHA7OP.js → chunk-EMXH2RJN.js} +3 -3
  52. package/dist/chunks/{chunk-MYVF3JRV.js → chunk-EQGE25MQ.js} +6 -6
  53. package/dist/chunks/{chunk-RDW6L3PV.js → chunk-F2TXNDKC.js} +3 -3
  54. package/dist/chunks/{chunk-UMHKTV2L.js → chunk-FAWY4LRG.js} +3 -3
  55. package/dist/chunks/{chunk-LMLJ7NS5.js → chunk-FK6WJQ5T.js} +5 -5
  56. package/dist/chunks/{chunk-EKMHZKVP.js → chunk-FRADQASS.js} +2 -2
  57. package/dist/chunks/{chunk-N56NUKMT.js → chunk-FS7CUHOG.js} +2 -2
  58. package/dist/chunks/{chunk-C5XQHEYB.js → chunk-GFZFGTDZ.js} +2 -2
  59. package/dist/chunks/{chunk-VVWI4EB7.js → chunk-GXCOSOVM.js} +3 -3
  60. package/dist/chunks/{chunk-TI6FFONP.js → chunk-HJJNIG33.js} +2 -2
  61. package/dist/chunks/{chunk-MHXJYXOF.js → chunk-HUDP4HTK.js} +5 -5
  62. package/dist/chunks/{chunk-SHUA4YUK.js → chunk-IBPN346S.js} +2 -2
  63. package/dist/chunks/chunk-IERT7D34.js +226 -0
  64. package/dist/chunks/chunk-IERT7D34.js.map +6 -0
  65. package/dist/chunks/{chunk-Z6J7SVOB.js → chunk-IPAGLYU3.js} +2 -2
  66. package/dist/chunks/{chunk-ZDZ35MMZ.js → chunk-ISHCON5Z.js} +2 -2
  67. package/dist/chunks/{chunk-FEIIR46G.js → chunk-J6I6MCWR.js} +5 -5
  68. package/dist/chunks/{chunk-HGZYNEQE.js → chunk-JFLX34FA.js} +14 -7
  69. package/dist/chunks/chunk-JFLX34FA.js.map +6 -0
  70. package/dist/chunks/{chunk-YELRULQ7.js → chunk-JTEWIH66.js} +4478 -2713
  71. package/dist/chunks/chunk-JTEWIH66.js.map +6 -0
  72. package/dist/chunks/{chunk-X6SREM2V.js → chunk-JXJIKAAE.js} +7 -7
  73. package/dist/chunks/{chunk-POOJ2MUS.js → chunk-K3QEZ7D7.js} +3 -3
  74. package/dist/chunks/{chunk-4RTQTX5R.js → chunk-KFWQSTT3.js} +2 -2
  75. package/dist/chunks/{chunk-DI4L3GH5.js → chunk-KHQAU33M.js} +2 -2
  76. package/dist/chunks/{chunk-CCYAWSZL.js → chunk-KNBFV3DC.js} +5 -5
  77. package/dist/chunks/{chunk-HTHNDZ3L.js → chunk-L2Q7APTU.js} +2 -2
  78. package/dist/chunks/{chunk-DIWEKTYK.js → chunk-LHZ632YK.js} +5 -5
  79. package/dist/chunks/chunk-LQZIENWB.js +686 -0
  80. package/dist/chunks/chunk-LQZIENWB.js.map +6 -0
  81. package/dist/chunks/{chunk-TYTE2GIF.js → chunk-LWYW2DAK.js} +5 -5
  82. package/dist/chunks/{chunk-NZMKMXGG.js → chunk-MKAQAKHE.js} +2 -2
  83. package/dist/chunks/{chunk-QPR3UA4L.js → chunk-MXJAJXE7.js} +2 -2
  84. package/dist/chunks/{chunk-SPSWX3QZ.js → chunk-MXR77LCX.js} +2 -2
  85. package/dist/chunks/{chunk-PSLNHLZI.js → chunk-NSGEVYJC.js} +3 -3
  86. package/dist/chunks/{chunk-EKQ6J5KA.js → chunk-O4GHSR2X.js} +2 -2
  87. package/dist/chunks/chunk-P3LYPSD6.js +137 -0
  88. package/dist/chunks/chunk-P3LYPSD6.js.map +6 -0
  89. package/dist/chunks/{chunk-J7SA5BCI.js → chunk-PNEFIK4E.js} +4 -4
  90. package/dist/chunks/chunk-PTPVAPCA.js +44 -0
  91. package/dist/chunks/chunk-PTPVAPCA.js.map +6 -0
  92. package/dist/chunks/{chunk-XHLFI6F6.js → chunk-QXKCTJWO.js} +2 -2
  93. package/dist/chunks/{chunk-P7FHJL3V.js → chunk-SK3JQNO5.js} +2 -2
  94. package/dist/chunks/{chunk-RJWPNAYL.js → chunk-SU5VBBRS.js} +12 -12
  95. package/dist/chunks/{chunk-SVMGV4AS.js → chunk-SWH4CAIH.js} +56 -47
  96. package/dist/chunks/chunk-SWH4CAIH.js.map +6 -0
  97. package/dist/chunks/{chunk-7AWFHVMT.js → chunk-T2CHZ6V7.js} +3 -3
  98. package/dist/chunks/{chunk-P5E6ITP5.js → chunk-TE4MIRMA.js} +5 -5
  99. package/dist/chunks/{chunk-24N42TGE.js → chunk-THOVK7I5.js} +6 -6
  100. package/dist/chunks/{chunk-YSKCWH72.js → chunk-TIMEEDY6.js} +203 -32
  101. package/dist/chunks/chunk-TIMEEDY6.js.map +6 -0
  102. package/dist/chunks/{chunk-DSKNFDTL.js → chunk-TLTD26JG.js} +2 -2
  103. package/dist/chunks/{chunk-CQKYKQEF.js → chunk-TUEZKY7I.js} +4 -4
  104. package/dist/chunks/{chunk-LOWGGJOB.js → chunk-U3IK5VKD.js} +6 -111
  105. package/dist/chunks/chunk-U3IK5VKD.js.map +6 -0
  106. package/dist/chunks/{chunk-2U357RJS.js → chunk-UUQY5P7K.js} +10 -10
  107. package/dist/chunks/{chunk-WOSL3OZD.js → chunk-VBRCNXMM.js} +4 -4
  108. package/dist/chunks/{chunk-VYLCV6W3.js → chunk-VI66HXJT.js} +9 -9
  109. package/dist/chunks/{chunk-HOKSVFIC.js → chunk-VQ5KK7YF.js} +79 -7
  110. package/dist/chunks/chunk-VQ5KK7YF.js.map +6 -0
  111. package/dist/chunks/{chunk-AGFGC7SI.js → chunk-VQCP7LOK.js} +3 -3
  112. package/dist/chunks/{chunk-OAHCS42A.js → chunk-VTS2SVX6.js} +2 -2
  113. package/dist/chunks/{chunk-HUONDMU4.js → chunk-W5TE6NIA.js} +2 -2
  114. package/dist/chunks/{chunk-UJOWXA23.js → chunk-WDY7OHLQ.js} +777 -261
  115. package/dist/chunks/chunk-WDY7OHLQ.js.map +6 -0
  116. package/dist/chunks/{chunk-ZZNHDQAD.js → chunk-WV45Z5QQ.js} +2 -2
  117. package/dist/chunks/{chunk-TUXH7IXQ.js → chunk-X44EPHHA.js} +2 -2
  118. package/dist/chunks/{chunk-6CFPN6I4.js → chunk-XFCFWWFK.js} +2 -2
  119. package/dist/chunks/{chunk-PV65WQHD.js → chunk-XGS5WUCQ.js} +12 -12
  120. package/dist/chunks/{chunk-NTV2XD2J.js → chunk-Y4MKRX73.js} +2 -2
  121. package/dist/chunks/{chunk-WSMX3IQE.js → chunk-YCJOAIDG.js} +518 -395
  122. package/dist/chunks/chunk-YCJOAIDG.js.map +6 -0
  123. package/dist/chunks/{chunk-SB3A7KUJ.js → chunk-YDGUEMBB.js} +4 -4
  124. package/dist/chunks/{chunk-7JT7DNR7.js → chunk-YIZXVNUY.js} +3 -3
  125. package/dist/chunks/{chunk-PYSZ7JTU.js → chunk-YNBAVIQA.js} +2 -2
  126. package/dist/chunks/{chunk-O326HKCW.js → chunk-YPLYAESJ.js} +3 -3
  127. package/dist/chunks/{chunk-5I45HTKW.js → chunk-ZH5MQMMF.js} +182 -40
  128. package/dist/chunks/chunk-ZH5MQMMF.js.map +6 -0
  129. package/dist/chunks/{chunk-M3AUPUII.js → chunk-ZI5FFFBJ.js} +6 -6
  130. package/dist/chunks/{chunk-EA73SWCT.js → chunk-ZIRQSGOG.js} +4 -4
  131. package/dist/chunks/{chunk-HOB6FTE2.js → chunk-ZVLTZDC4.js} +5 -4
  132. package/dist/chunks/{chunk-HOB6FTE2.js.map → chunk-ZVLTZDC4.js.map} +1 -1
  133. package/dist/chunks/{chunk-KNQ7R54U.js → chunk-ZZK2BVEH.js} +911 -670
  134. package/dist/chunks/chunk-ZZK2BVEH.js.map +6 -0
  135. package/dist/chunks/{cli-runtime-SVXU6U4V.js → cli-runtime-V2FI7PIQ.js} +25 -25
  136. package/dist/chunks/{commands-A2E3OV7F.js → commands-R2LZBXLK.js} +5 -5
  137. package/dist/chunks/{cost-NA7APCZD.js → cost-PQWWLMOO.js} +8 -8
  138. package/dist/chunks/{crash-report-C6QXQJAK.js → crash-report-MY27ZDU6.js} +9 -9
  139. package/dist/chunks/{dist-3PE5MOU6.js → dist-3HCAPKP5.js} +2 -2
  140. package/dist/chunks/{dist-5SZ7VOLE.js → dist-4RNVO224.js} +2 -2
  141. package/dist/chunks/{dist-6CHQ5OPZ.js → dist-7A7PB34A.js} +2 -2
  142. package/dist/chunks/{dist-G4BSVJKY.js → dist-MSFQTEPK.js} +2 -2
  143. package/dist/chunks/{dist-LBTLFSNF.js → dist-MT3MTMRF.js} +68 -2
  144. package/dist/chunks/{dist-HYKH6P7F.js → dist-PH7MWV7K.js} +2 -2
  145. package/dist/chunks/{dist-GVGW7AZ2.js → dist-TIMUM4OR.js} +2 -2
  146. package/dist/chunks/{dist-HASAHQL3.js → dist-Y4Q4SXRE.js} +2 -2
  147. package/dist/chunks/{doctor-Y5PQ2R7D.js → doctor-JRVQJERE.js} +46 -42
  148. package/dist/chunks/{drain-RG275P5J.js → drain-YOE55I26.js} +14 -14
  149. package/dist/chunks/{entry-BJY7UE6P.js → entry-QAXRBCG3.js} +6 -6
  150. package/dist/chunks/{eval-GG2BH7CQ.js → eval-UPNYQIHO.js} +12 -12
  151. package/dist/chunks/{exec-63SUPKUV.js → exec-LLOKYQZY.js} +92 -64
  152. package/dist/chunks/exec-LLOKYQZY.js.map +6 -0
  153. package/dist/chunks/{github-MGIA7MTZ.js → github-Z3JQNLXA.js} +5 -5
  154. package/dist/chunks/{home-KMZDOTX5.js → home-7TSSDRFT.js} +3 -3
  155. package/dist/chunks/hooks-JNM3P24H.js +210 -0
  156. package/dist/chunks/hooks-JNM3P24H.js.map +6 -0
  157. package/dist/chunks/hooks-report-GGRTQH23.js +39 -0
  158. package/dist/chunks/{host-OB5CL3GG.js → host-M2CYP3TP.js} +12 -12
  159. package/dist/chunks/{host-queries-2GQM7BTI.js → host-queries-L7P5FQ36.js} +15 -15
  160. package/dist/chunks/{learn-LUEHNOMA.js → learn-CBIMGXXS.js} +12 -12
  161. package/dist/chunks/{learn-builtin-R2Z27LDI.js → learn-builtin-UHGQ6CNQ.js} +17 -17
  162. package/dist/chunks/{lifecycle-DCLLAROM.js → lifecycle-NJGOR77O.js} +37 -37
  163. package/dist/chunks/{list-5UW5SFIX.js → list-QZUWOS4I.js} +19 -19
  164. package/dist/chunks/{live-YUE4AKRQ.js → live-LHKUQFEO.js} +44 -40
  165. package/dist/chunks/load-LF7GZYTP.js +75 -0
  166. package/dist/chunks/{login-ELIGI6HT.js → login-F4NOOGD5.js} +13 -13
  167. package/dist/chunks/{logs-PXASK6XI.js → logs-6CJCV6YU.js} +5 -5
  168. package/dist/chunks/{mcp-YVV35X7H.js → mcp-C7FQLLXL.js} +34 -34
  169. package/dist/chunks/{message-command-QVGOKB4W.js → message-command-BJPPVBGT.js} +59 -55
  170. package/dist/chunks/message-command-BJPPVBGT.js.map +6 -0
  171. package/dist/chunks/{open-MDT2NTF4.js → open-GLWFBW4C.js} +8 -8
  172. package/dist/chunks/{operator-tools-LYY2FXSO.js → operator-tools-KQV2T5UU.js} +14 -14
  173. package/dist/chunks/{output-schema-VR43KZNJ.js → output-schema-XXKTMSU6.js} +3 -3
  174. package/dist/chunks/{pal-YXOWNULV.js → pal-4OZ7KPSC.js} +19 -19
  175. package/dist/chunks/{peers-CJOTRI4W.js → peers-4DMT2KZ2.js} +18 -18
  176. package/dist/chunks/{peers-6M4UPHDF.js → peers-SMOALKZW.js} +6 -6
  177. package/dist/chunks/{plugin-IVIHCAEO.js → plugin-IDW4AYIK.js} +101 -20
  178. package/dist/chunks/plugin-IDW4AYIK.js.map +6 -0
  179. package/dist/chunks/{providers-7WDY37V3.js → providers-7HLI5PWI.js} +11 -11
  180. package/dist/chunks/{pty-CLDDZT5T.js → pty-SQBYCAX4.js} +3 -3
  181. package/dist/chunks/resume-2HBHZF54.js +23 -0
  182. package/dist/chunks/{resume-command-TXPTYQFF.js → resume-command-VCMPAWTN.js} +4 -4
  183. package/dist/chunks/{running-KBISZDIQ.js → running-DR4MSZ7B.js} +5 -5
  184. package/dist/chunks/{schedule-ECZVNZLH.js → schedule-W3QPDJRS.js} +8 -8
  185. package/dist/chunks/{send-VUJ33MJM.js → send-QDBFAZ5P.js} +16 -16
  186. package/dist/chunks/{send-person-WXM7Y5PZ.js → send-person-O5OJ7KHD.js} +13 -13
  187. package/dist/chunks/{service-DORQ3PNE.js → service-5Z47V5KC.js} +42 -42
  188. package/dist/chunks/{skills-W7KY3WX4.js → skills-XYT6UUTP.js} +45 -16
  189. package/dist/chunks/skills-XYT6UUTP.js.map +6 -0
  190. package/dist/chunks/{start-check-KECY75IO.js → start-check-OKCRZ67I.js} +2 -2
  191. package/dist/chunks/{startup-failure-MS7TPUMI.js → startup-failure-N3RO73Z4.js} +2 -2
  192. package/dist/chunks/{state-YK5JWP5I.js → state-7CLHPA4P.js} +6 -6
  193. package/dist/chunks/{store-XIPDR26B.js → store-CNEKBGKD.js} +6 -6
  194. package/dist/chunks/{store-TM7VDQ5G.js → store-GA3I7BMG.js} +4 -4
  195. package/dist/chunks/{store-H4IVAEZK.js → store-YFAH5XGW.js} +3 -3
  196. package/dist/chunks/store-YFAH5XGW.js.map +6 -0
  197. package/dist/chunks/{store-7SFKBFX6.js → store-ZDFRYDWS.js} +12 -10
  198. package/dist/chunks/store-ZDFRYDWS.js.map +6 -0
  199. package/dist/chunks/{tui-XKAQI3DD.js → tui-T6VPVMEV.js} +95 -89
  200. package/dist/chunks/tui-T6VPVMEV.js.map +6 -0
  201. package/dist/chunks/{upgrade-GLEEEZWO.js → upgrade-SW474CXN.js} +10 -10
  202. package/dist/chunks/{watch-XZKKDKAF.js → watch-OIYLZVDF.js} +134 -101
  203. package/dist/chunks/watch-OIYLZVDF.js.map +6 -0
  204. package/dist/chunks/{workspaces-GS6D72XT.js → workspaces-YQW2E6PE.js} +22 -22
  205. package/dist/chunks/worktree-ZMMQI2Z5.js +204 -0
  206. package/dist/chunks/worktree-ZMMQI2Z5.js.map +6 -0
  207. package/dist/cli.d.ts.map +1 -1
  208. package/dist/commands/acp.d.ts.map +1 -1
  209. package/dist/commands/desktop-host.d.ts +7 -0
  210. package/dist/commands/desktop-host.d.ts.map +1 -1
  211. package/dist/commands/exec-json.d.ts.map +1 -1
  212. package/dist/commands/exec.d.ts.map +1 -1
  213. package/dist/commands/hooks.d.ts +13 -0
  214. package/dist/commands/hooks.d.ts.map +1 -0
  215. package/dist/commands/manifest.d.ts +1 -0
  216. package/dist/commands/manifest.d.ts.map +1 -1
  217. package/dist/commands/worktree.d.ts.map +1 -1
  218. package/dist/config/hook-common-shape.d.ts +2 -0
  219. package/dist/config/hook-common-shape.d.ts.map +1 -1
  220. package/dist/config/hook-layers.d.ts.map +1 -1
  221. package/dist/config/hooks-report.d.ts +162 -0
  222. package/dist/config/hooks-report.d.ts.map +1 -0
  223. package/dist/config/load.d.ts +53 -1
  224. package/dist/config/load.d.ts.map +1 -1
  225. package/dist/config/skill-hooks-reader.d.ts +46 -0
  226. package/dist/config/skill-hooks-reader.d.ts.map +1 -0
  227. package/dist/doctor/checks/hooks.d.ts +7 -2
  228. package/dist/doctor/checks/hooks.d.ts.map +1 -1
  229. package/dist/index.js +49 -45
  230. package/dist/integrations/plugins/hook-activity.d.ts +62 -0
  231. package/dist/integrations/plugins/hook-activity.d.ts.map +1 -0
  232. package/dist/integrations/plugins/hook-entries.d.ts +126 -0
  233. package/dist/integrations/plugins/hook-entries.d.ts.map +1 -0
  234. package/dist/integrations/plugins/runtime.d.ts +52 -2
  235. package/dist/integrations/plugins/runtime.d.ts.map +1 -1
  236. package/dist/integrations/plugins/validate.d.ts.map +1 -1
  237. package/dist/integrations/sessions/conversation-facts.d.ts +12 -0
  238. package/dist/integrations/sessions/conversation-facts.d.ts.map +1 -1
  239. package/dist/integrations/sessions/store.d.ts +11 -1
  240. package/dist/integrations/sessions/store.d.ts.map +1 -1
  241. package/dist/integrations/sessions/watch-view.d.ts +2 -0
  242. package/dist/integrations/sessions/watch-view.d.ts.map +1 -1
  243. package/dist/integrations/subagents/NamzuCliAgent.d.ts +9 -1
  244. package/dist/integrations/subagents/NamzuCliAgent.d.ts.map +1 -1
  245. package/dist/integrations/subagents/agent-hooks.d.ts +116 -0
  246. package/dist/integrations/subagents/agent-hooks.d.ts.map +1 -0
  247. package/dist/integrations/subagents/definitions.d.ts +18 -0
  248. package/dist/integrations/subagents/definitions.d.ts.map +1 -1
  249. package/dist/integrations/subagents/replay.d.ts +6 -0
  250. package/dist/integrations/subagents/replay.d.ts.map +1 -1
  251. package/dist/integrations/subagents/runtime.d.ts +23 -0
  252. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  253. package/dist/integrations/subagents/worktree-driver.d.ts +20 -5
  254. package/dist/integrations/subagents/worktree-driver.d.ts.map +1 -1
  255. package/dist/integrations/trust/folder-grants.d.ts.map +1 -1
  256. package/dist/integrations/worktrees/hook-host.d.ts +23 -0
  257. package/dist/integrations/worktrees/hook-host.d.ts.map +1 -0
  258. package/dist/integrations/worktrees/managed.d.ts +20 -2
  259. package/dist/integrations/worktrees/managed.d.ts.map +1 -1
  260. package/dist/integrations/worktrees/untrusted-hook.d.ts +16 -0
  261. package/dist/integrations/worktrees/untrusted-hook.d.ts.map +1 -0
  262. package/dist/schedule/fire/fire.d.ts.map +1 -1
  263. package/dist/skills/audit.d.ts +11 -0
  264. package/dist/skills/audit.d.ts.map +1 -1
  265. package/dist/skills/catalog.d.ts +3 -0
  266. package/dist/skills/catalog.d.ts.map +1 -1
  267. package/dist/skills/restore-skill-hooks.d.ts +16 -0
  268. package/dist/skills/restore-skill-hooks.d.ts.map +1 -0
  269. package/dist/skills/skill-hooks.d.ts +73 -0
  270. package/dist/skills/skill-hooks.d.ts.map +1 -0
  271. package/dist/skills/store.d.ts +3 -0
  272. package/dist/skills/store.d.ts.map +1 -1
  273. package/dist/skills/use-hooks.d.ts +25 -0
  274. package/dist/skills/use-hooks.d.ts.map +1 -0
  275. package/dist/tui/App.d.ts.map +1 -1
  276. package/dist/tui/ReadSearchGroup.d.ts.map +1 -1
  277. package/dist/tui/Transcript.d.ts.map +1 -1
  278. package/dist/tui/agent-transcript-rows.d.ts +3 -1
  279. package/dist/tui/agent-transcript-rows.d.ts.map +1 -1
  280. package/dist/tui/agent.d.ts +73 -1
  281. package/dist/tui/agent.d.ts.map +1 -1
  282. package/dist/tui/fullscreen/layout.d.ts +9 -1
  283. package/dist/tui/fullscreen/layout.d.ts.map +1 -1
  284. package/dist/tui/fullscreen/markdown-rows.d.ts +18 -18
  285. package/dist/tui/fullscreen/markdown-rows.d.ts.map +1 -1
  286. package/dist/tui/fullscreen/reply-rows.d.ts +83 -0
  287. package/dist/tui/fullscreen/reply-rows.d.ts.map +1 -0
  288. package/dist/tui/hint-fit.d.ts +36 -0
  289. package/dist/tui/hint-fit.d.ts.map +1 -0
  290. package/dist/tui/plugin-view.d.ts.map +1 -1
  291. package/dist/tui/restored-rows.d.ts +6 -0
  292. package/dist/tui/restored-rows.d.ts.map +1 -1
  293. package/dist/tui/slashCommands.d.ts +44 -1
  294. package/dist/tui/slashCommands.d.ts.map +1 -1
  295. package/dist/tui/transcript-scroll.d.ts +1 -1
  296. package/dist/tui/transcript-scroll.d.ts.map +1 -1
  297. package/dist/user-commands/store.d.ts +2 -0
  298. package/dist/user-commands/store.d.ts.map +1 -1
  299. package/package.json +5 -5
  300. package/dist/chunks/acp-IOWTKF2X.js.map +0 -6
  301. package/dist/chunks/agent-session-L6J5GZVX.js +0 -73
  302. package/dist/chunks/chunk-5I45HTKW.js.map +0 -6
  303. package/dist/chunks/chunk-5NDRDTNX.js.map +0 -6
  304. package/dist/chunks/chunk-AME342DQ.js +0 -245
  305. package/dist/chunks/chunk-AME342DQ.js.map +0 -6
  306. package/dist/chunks/chunk-HGZYNEQE.js.map +0 -6
  307. package/dist/chunks/chunk-HOKSVFIC.js.map +0 -6
  308. package/dist/chunks/chunk-KNQ7R54U.js.map +0 -6
  309. package/dist/chunks/chunk-LOWGGJOB.js.map +0 -6
  310. package/dist/chunks/chunk-SVMGV4AS.js.map +0 -6
  311. package/dist/chunks/chunk-UJOWXA23.js.map +0 -6
  312. package/dist/chunks/chunk-V7VNFYA4.js.map +0 -6
  313. package/dist/chunks/chunk-WSMX3IQE.js.map +0 -6
  314. package/dist/chunks/chunk-YELRULQ7.js.map +0 -6
  315. package/dist/chunks/chunk-YSKCWH72.js.map +0 -6
  316. package/dist/chunks/exec-63SUPKUV.js.map +0 -6
  317. package/dist/chunks/message-command-QVGOKB4W.js.map +0 -6
  318. package/dist/chunks/plugin-IVIHCAEO.js.map +0 -6
  319. package/dist/chunks/resume-ZRVTAGB6.js +0 -23
  320. package/dist/chunks/skills-W7KY3WX4.js.map +0 -6
  321. package/dist/chunks/tui-XKAQI3DD.js.map +0 -6
  322. package/dist/chunks/watch-XZKKDKAF.js.map +0 -6
  323. package/dist/chunks/worktree-Z456JZKA.js +0 -119
  324. package/dist/chunks/worktree-Z456JZKA.js.map +0 -6
  325. /package/dist/chunks/{activity-command-U2AOTIVF.js.map → activity-command-IBOJOCRF.js.map} +0 -0
  326. /package/dist/chunks/{add-YYQLPCP2.js.map → add-LYBL3IC7.js.map} +0 -0
  327. /package/dist/chunks/{agent-WL6NX4W6.js.map → agent-LTLWJW3P.js.map} +0 -0
  328. /package/dist/chunks/{agent-session-L6J5GZVX.js.map → agent-session-BD2AHK5S.js.map} +0 -0
  329. /package/dist/chunks/{apply-at-exit-BRXYTQVG.js.map → apply-at-exit-7BF3KBU2.js.map} +0 -0
  330. /package/dist/chunks/{archive-UE756BME.js.map → archive-FCPUCOYT.js.map} +0 -0
  331. /package/dist/chunks/{bin-main-XR2DJOI6.js.map → bin-main-AVPCWJHJ.js.map} +0 -0
  332. /package/dist/chunks/{binding-HCIPLFUO.js.map → binding-OZCOSUYV.js.map} +0 -0
  333. /package/dist/chunks/{browser-7SFVCKSO.js.map → browser-LR25NVO7.js.map} +0 -0
  334. /package/dist/chunks/{chat-K6GQGRUA.js.map → chat-PP7XU7US.js.map} +0 -0
  335. /package/dist/chunks/{chunk-3NAVAACC.js.map → chunk-2KNLSJFS.js.map} +0 -0
  336. /package/dist/chunks/{chunk-2VSICYQP.js.map → chunk-2O6LZGGG.js.map} +0 -0
  337. /package/dist/chunks/{chunk-Z5NMQ2YN.js.map → chunk-3Q42HHZM.js.map} +0 -0
  338. /package/dist/chunks/{chunk-RAPO3KLG.js.map → chunk-3WTIGIDA.js.map} +0 -0
  339. /package/dist/chunks/{chunk-FX7BSCB4.js.map → chunk-4Q4J3KDG.js.map} +0 -0
  340. /package/dist/chunks/{chunk-KO2N6EIF.js.map → chunk-4VB264C5.js.map} +0 -0
  341. /package/dist/chunks/{chunk-HJILJSZO.js.map → chunk-4VXS3UYL.js.map} +0 -0
  342. /package/dist/chunks/{chunk-2WDF5N2A.js.map → chunk-5FEAC3G5.js.map} +0 -0
  343. /package/dist/chunks/{chunk-BHOZPFJM.js.map → chunk-5HCZHDPA.js.map} +0 -0
  344. /package/dist/chunks/{chunk-Z5FDI74K.js.map → chunk-5YNAPIUZ.js.map} +0 -0
  345. /package/dist/chunks/{chunk-A47ZNTW7.js.map → chunk-6SHOR62K.js.map} +0 -0
  346. /package/dist/chunks/{chunk-46VSU4QF.js.map → chunk-72IJ3FQU.js.map} +0 -0
  347. /package/dist/chunks/{chunk-DHS5CQNC.js.map → chunk-AO4A56EG.js.map} +0 -0
  348. /package/dist/chunks/{chunk-KAPCNFMC.js.map → chunk-BFCUL4BW.js.map} +0 -0
  349. /package/dist/chunks/{chunk-DOFQWVBL.js.map → chunk-CKWDYYBE.js.map} +0 -0
  350. /package/dist/chunks/{chunk-J3PHMXN4.js.map → chunk-CSBKGTBA.js.map} +0 -0
  351. /package/dist/chunks/{chunk-ZMKEYARZ.js.map → chunk-D3JJE6VZ.js.map} +0 -0
  352. /package/dist/chunks/{chunk-UWN4WNQZ.js.map → chunk-DEEK2FOC.js.map} +0 -0
  353. /package/dist/chunks/{chunk-F3SQRGKZ.js.map → chunk-DSMBM5LQ.js.map} +0 -0
  354. /package/dist/chunks/{chunk-4FV2VZS6.js.map → chunk-EC2F3CWT.js.map} +0 -0
  355. /package/dist/chunks/{chunk-OBMHA7OP.js.map → chunk-EMXH2RJN.js.map} +0 -0
  356. /package/dist/chunks/{chunk-MYVF3JRV.js.map → chunk-EQGE25MQ.js.map} +0 -0
  357. /package/dist/chunks/{chunk-RDW6L3PV.js.map → chunk-F2TXNDKC.js.map} +0 -0
  358. /package/dist/chunks/{chunk-UMHKTV2L.js.map → chunk-FAWY4LRG.js.map} +0 -0
  359. /package/dist/chunks/{chunk-LMLJ7NS5.js.map → chunk-FK6WJQ5T.js.map} +0 -0
  360. /package/dist/chunks/{chunk-EKMHZKVP.js.map → chunk-FRADQASS.js.map} +0 -0
  361. /package/dist/chunks/{chunk-N56NUKMT.js.map → chunk-FS7CUHOG.js.map} +0 -0
  362. /package/dist/chunks/{chunk-C5XQHEYB.js.map → chunk-GFZFGTDZ.js.map} +0 -0
  363. /package/dist/chunks/{chunk-VVWI4EB7.js.map → chunk-GXCOSOVM.js.map} +0 -0
  364. /package/dist/chunks/{chunk-TI6FFONP.js.map → chunk-HJJNIG33.js.map} +0 -0
  365. /package/dist/chunks/{chunk-MHXJYXOF.js.map → chunk-HUDP4HTK.js.map} +0 -0
  366. /package/dist/chunks/{chunk-SHUA4YUK.js.map → chunk-IBPN346S.js.map} +0 -0
  367. /package/dist/chunks/{chunk-Z6J7SVOB.js.map → chunk-IPAGLYU3.js.map} +0 -0
  368. /package/dist/chunks/{chunk-ZDZ35MMZ.js.map → chunk-ISHCON5Z.js.map} +0 -0
  369. /package/dist/chunks/{chunk-FEIIR46G.js.map → chunk-J6I6MCWR.js.map} +0 -0
  370. /package/dist/chunks/{chunk-X6SREM2V.js.map → chunk-JXJIKAAE.js.map} +0 -0
  371. /package/dist/chunks/{chunk-POOJ2MUS.js.map → chunk-K3QEZ7D7.js.map} +0 -0
  372. /package/dist/chunks/{chunk-4RTQTX5R.js.map → chunk-KFWQSTT3.js.map} +0 -0
  373. /package/dist/chunks/{chunk-DI4L3GH5.js.map → chunk-KHQAU33M.js.map} +0 -0
  374. /package/dist/chunks/{chunk-CCYAWSZL.js.map → chunk-KNBFV3DC.js.map} +0 -0
  375. /package/dist/chunks/{chunk-HTHNDZ3L.js.map → chunk-L2Q7APTU.js.map} +0 -0
  376. /package/dist/chunks/{chunk-DIWEKTYK.js.map → chunk-LHZ632YK.js.map} +0 -0
  377. /package/dist/chunks/{chunk-TYTE2GIF.js.map → chunk-LWYW2DAK.js.map} +0 -0
  378. /package/dist/chunks/{chunk-NZMKMXGG.js.map → chunk-MKAQAKHE.js.map} +0 -0
  379. /package/dist/chunks/{chunk-QPR3UA4L.js.map → chunk-MXJAJXE7.js.map} +0 -0
  380. /package/dist/chunks/{chunk-SPSWX3QZ.js.map → chunk-MXR77LCX.js.map} +0 -0
  381. /package/dist/chunks/{chunk-PSLNHLZI.js.map → chunk-NSGEVYJC.js.map} +0 -0
  382. /package/dist/chunks/{chunk-EKQ6J5KA.js.map → chunk-O4GHSR2X.js.map} +0 -0
  383. /package/dist/chunks/{chunk-J7SA5BCI.js.map → chunk-PNEFIK4E.js.map} +0 -0
  384. /package/dist/chunks/{chunk-XHLFI6F6.js.map → chunk-QXKCTJWO.js.map} +0 -0
  385. /package/dist/chunks/{chunk-P7FHJL3V.js.map → chunk-SK3JQNO5.js.map} +0 -0
  386. /package/dist/chunks/{chunk-RJWPNAYL.js.map → chunk-SU5VBBRS.js.map} +0 -0
  387. /package/dist/chunks/{chunk-7AWFHVMT.js.map → chunk-T2CHZ6V7.js.map} +0 -0
  388. /package/dist/chunks/{chunk-P5E6ITP5.js.map → chunk-TE4MIRMA.js.map} +0 -0
  389. /package/dist/chunks/{chunk-24N42TGE.js.map → chunk-THOVK7I5.js.map} +0 -0
  390. /package/dist/chunks/{chunk-DSKNFDTL.js.map → chunk-TLTD26JG.js.map} +0 -0
  391. /package/dist/chunks/{chunk-CQKYKQEF.js.map → chunk-TUEZKY7I.js.map} +0 -0
  392. /package/dist/chunks/{chunk-2U357RJS.js.map → chunk-UUQY5P7K.js.map} +0 -0
  393. /package/dist/chunks/{chunk-WOSL3OZD.js.map → chunk-VBRCNXMM.js.map} +0 -0
  394. /package/dist/chunks/{chunk-VYLCV6W3.js.map → chunk-VI66HXJT.js.map} +0 -0
  395. /package/dist/chunks/{chunk-AGFGC7SI.js.map → chunk-VQCP7LOK.js.map} +0 -0
  396. /package/dist/chunks/{chunk-OAHCS42A.js.map → chunk-VTS2SVX6.js.map} +0 -0
  397. /package/dist/chunks/{chunk-HUONDMU4.js.map → chunk-W5TE6NIA.js.map} +0 -0
  398. /package/dist/chunks/{chunk-ZZNHDQAD.js.map → chunk-WV45Z5QQ.js.map} +0 -0
  399. /package/dist/chunks/{chunk-TUXH7IXQ.js.map → chunk-X44EPHHA.js.map} +0 -0
  400. /package/dist/chunks/{chunk-6CFPN6I4.js.map → chunk-XFCFWWFK.js.map} +0 -0
  401. /package/dist/chunks/{chunk-PV65WQHD.js.map → chunk-XGS5WUCQ.js.map} +0 -0
  402. /package/dist/chunks/{chunk-NTV2XD2J.js.map → chunk-Y4MKRX73.js.map} +0 -0
  403. /package/dist/chunks/{chunk-SB3A7KUJ.js.map → chunk-YDGUEMBB.js.map} +0 -0
  404. /package/dist/chunks/{chunk-7JT7DNR7.js.map → chunk-YIZXVNUY.js.map} +0 -0
  405. /package/dist/chunks/{chunk-PYSZ7JTU.js.map → chunk-YNBAVIQA.js.map} +0 -0
  406. /package/dist/chunks/{chunk-O326HKCW.js.map → chunk-YPLYAESJ.js.map} +0 -0
  407. /package/dist/chunks/{chunk-M3AUPUII.js.map → chunk-ZI5FFFBJ.js.map} +0 -0
  408. /package/dist/chunks/{chunk-EA73SWCT.js.map → chunk-ZIRQSGOG.js.map} +0 -0
  409. /package/dist/chunks/{cli-runtime-SVXU6U4V.js.map → cli-runtime-V2FI7PIQ.js.map} +0 -0
  410. /package/dist/chunks/{commands-A2E3OV7F.js.map → commands-R2LZBXLK.js.map} +0 -0
  411. /package/dist/chunks/{cost-NA7APCZD.js.map → cost-PQWWLMOO.js.map} +0 -0
  412. /package/dist/chunks/{crash-report-C6QXQJAK.js.map → crash-report-MY27ZDU6.js.map} +0 -0
  413. /package/dist/chunks/{dist-3PE5MOU6.js.map → dist-3HCAPKP5.js.map} +0 -0
  414. /package/dist/chunks/{dist-5SZ7VOLE.js.map → dist-4RNVO224.js.map} +0 -0
  415. /package/dist/chunks/{dist-6CHQ5OPZ.js.map → dist-7A7PB34A.js.map} +0 -0
  416. /package/dist/chunks/{dist-G4BSVJKY.js.map → dist-MSFQTEPK.js.map} +0 -0
  417. /package/dist/chunks/{dist-LBTLFSNF.js.map → dist-MT3MTMRF.js.map} +0 -0
  418. /package/dist/chunks/{dist-HYKH6P7F.js.map → dist-PH7MWV7K.js.map} +0 -0
  419. /package/dist/chunks/{dist-GVGW7AZ2.js.map → dist-TIMUM4OR.js.map} +0 -0
  420. /package/dist/chunks/{dist-HASAHQL3.js.map → dist-Y4Q4SXRE.js.map} +0 -0
  421. /package/dist/chunks/{doctor-Y5PQ2R7D.js.map → doctor-JRVQJERE.js.map} +0 -0
  422. /package/dist/chunks/{drain-RG275P5J.js.map → drain-YOE55I26.js.map} +0 -0
  423. /package/dist/chunks/{entry-BJY7UE6P.js.map → entry-QAXRBCG3.js.map} +0 -0
  424. /package/dist/chunks/{eval-GG2BH7CQ.js.map → eval-UPNYQIHO.js.map} +0 -0
  425. /package/dist/chunks/{github-MGIA7MTZ.js.map → github-Z3JQNLXA.js.map} +0 -0
  426. /package/dist/chunks/{home-KMZDOTX5.js.map → home-7TSSDRFT.js.map} +0 -0
  427. /package/dist/chunks/{host-OB5CL3GG.js.map → hooks-report-GGRTQH23.js.map} +0 -0
  428. /package/dist/chunks/{lifecycle-DCLLAROM.js.map → host-M2CYP3TP.js.map} +0 -0
  429. /package/dist/chunks/{host-queries-2GQM7BTI.js.map → host-queries-L7P5FQ36.js.map} +0 -0
  430. /package/dist/chunks/{learn-LUEHNOMA.js.map → learn-CBIMGXXS.js.map} +0 -0
  431. /package/dist/chunks/{learn-builtin-R2Z27LDI.js.map → learn-builtin-UHGQ6CNQ.js.map} +0 -0
  432. /package/dist/chunks/{live-YUE4AKRQ.js.map → lifecycle-NJGOR77O.js.map} +0 -0
  433. /package/dist/chunks/{list-5UW5SFIX.js.map → list-QZUWOS4I.js.map} +0 -0
  434. /package/dist/chunks/{login-ELIGI6HT.js.map → live-LHKUQFEO.js.map} +0 -0
  435. /package/dist/chunks/{open-MDT2NTF4.js.map → load-LF7GZYTP.js.map} +0 -0
  436. /package/dist/chunks/{output-schema-VR43KZNJ.js.map → login-F4NOOGD5.js.map} +0 -0
  437. /package/dist/chunks/{logs-PXASK6XI.js.map → logs-6CJCV6YU.js.map} +0 -0
  438. /package/dist/chunks/{mcp-YVV35X7H.js.map → mcp-C7FQLLXL.js.map} +0 -0
  439. /package/dist/chunks/{peers-6M4UPHDF.js.map → open-GLWFBW4C.js.map} +0 -0
  440. /package/dist/chunks/{operator-tools-LYY2FXSO.js.map → operator-tools-KQV2T5UU.js.map} +0 -0
  441. /package/dist/chunks/{providers-7WDY37V3.js.map → output-schema-XXKTMSU6.js.map} +0 -0
  442. /package/dist/chunks/{pal-YXOWNULV.js.map → pal-4OZ7KPSC.js.map} +0 -0
  443. /package/dist/chunks/{peers-CJOTRI4W.js.map → peers-4DMT2KZ2.js.map} +0 -0
  444. /package/dist/chunks/{pty-CLDDZT5T.js.map → peers-SMOALKZW.js.map} +0 -0
  445. /package/dist/chunks/{resume-ZRVTAGB6.js.map → providers-7HLI5PWI.js.map} +0 -0
  446. /package/dist/chunks/{resume-command-TXPTYQFF.js.map → pty-SQBYCAX4.js.map} +0 -0
  447. /package/dist/chunks/{running-KBISZDIQ.js.map → resume-2HBHZF54.js.map} +0 -0
  448. /package/dist/chunks/{send-VUJ33MJM.js.map → resume-command-VCMPAWTN.js.map} +0 -0
  449. /package/dist/chunks/{send-person-WXM7Y5PZ.js.map → running-DR4MSZ7B.js.map} +0 -0
  450. /package/dist/chunks/{schedule-ECZVNZLH.js.map → schedule-W3QPDJRS.js.map} +0 -0
  451. /package/dist/chunks/{start-check-KECY75IO.js.map → send-QDBFAZ5P.js.map} +0 -0
  452. /package/dist/chunks/{store-7SFKBFX6.js.map → send-person-O5OJ7KHD.js.map} +0 -0
  453. /package/dist/chunks/{service-DORQ3PNE.js.map → service-5Z47V5KC.js.map} +0 -0
  454. /package/dist/chunks/{store-H4IVAEZK.js.map → start-check-OKCRZ67I.js.map} +0 -0
  455. /package/dist/chunks/{startup-failure-MS7TPUMI.js.map → startup-failure-N3RO73Z4.js.map} +0 -0
  456. /package/dist/chunks/{state-YK5JWP5I.js.map → state-7CLHPA4P.js.map} +0 -0
  457. /package/dist/chunks/{store-TM7VDQ5G.js.map → store-CNEKBGKD.js.map} +0 -0
  458. /package/dist/chunks/{store-XIPDR26B.js.map → store-GA3I7BMG.js.map} +0 -0
  459. /package/dist/chunks/{upgrade-GLEEEZWO.js.map → upgrade-SW474CXN.js.map} +0 -0
  460. /package/dist/chunks/{workspaces-GS6D72XT.js.map → workspaces-YQW2E6PE.js.map} +0 -0
@@ -1,24 +1,15 @@
1
1
  import { createRequire as __namzuCreateRequire } from 'node:module';
2
2
  const require = __namzuCreateRequire(import.meta.url);
3
3
  import {
4
+ createCliPluginRuntime,
4
5
  openManagedWorktrees
5
- } from "./chunk-AME342DQ.js";
6
+ } from "./chunk-LQZIENWB.js";
6
7
  import {
7
- connectMcpServers,
8
- startMcpServers
9
- } from "./chunk-EA73SWCT.js";
10
- import {
11
- openInBrowser
12
- } from "./chunk-C5XQHEYB.js";
13
- import {
14
- PluginSettingsStore,
15
- listMarkdownNames,
16
- readPluginFileSources,
17
- resolvePluginFileDirs
18
- } from "./chunk-LOWGGJOB.js";
8
+ readPluginFileSources
9
+ } from "./chunk-U3IK5VKD.js";
19
10
  import {
20
11
  createSessionSkillCatalog
21
- } from "./chunk-HOB6FTE2.js";
12
+ } from "./chunk-ZVLTZDC4.js";
22
13
  import {
23
14
  KEY_MISMATCH_MESSAGE,
24
15
  MAX_SCRIPT_BYTES,
@@ -42,16 +33,23 @@ import {
42
33
  viewFromJournal,
43
34
  workflowJournalKey,
44
35
  writeEditableCopy
45
- } from "./chunk-NTV2XD2J.js";
36
+ } from "./chunk-Y4MKRX73.js";
46
37
  import {
47
38
  runGeneratorCycle
48
- } from "./chunk-KAPCNFMC.js";
39
+ } from "./chunk-BFCUL4BW.js";
49
40
  import {
50
41
  createSessionLearningFeed,
51
42
  openLearningTarget,
52
43
  readProjectGuidance,
53
44
  withSessionLearningFeed
54
- } from "./chunk-SB3A7KUJ.js";
45
+ } from "./chunk-YDGUEMBB.js";
46
+ import {
47
+ connectMcpServers,
48
+ startMcpServers
49
+ } from "./chunk-ZIRQSGOG.js";
50
+ import {
51
+ openInBrowser
52
+ } from "./chunk-GFZFGTDZ.js";
55
53
  import {
56
54
  createBrowserControl
57
55
  } from "./chunk-WHODOMXA.js";
@@ -60,10 +58,10 @@ import {
60
58
  } from "./chunk-YOWYTBJS.js";
61
59
  import {
62
60
  migrateAccountKeys
63
- } from "./chunk-LMLJ7NS5.js";
61
+ } from "./chunk-FK6WJQ5T.js";
64
62
  import {
65
63
  openCliAccounts
66
- } from "./chunk-CCYAWSZL.js";
64
+ } from "./chunk-KNBFV3DC.js";
67
65
  import {
68
66
  CredentialRefreshRejectedError,
69
67
  CredentialWithdrawnError as CredentialWithdrawnError2,
@@ -71,16 +69,17 @@ import {
71
69
  ensureFreshStoredCodexCredential,
72
70
  readSubscriptionCredential,
73
71
  sameOAuthCredential
74
- } from "./chunk-CQKYKQEF.js";
72
+ } from "./chunk-TUEZKY7I.js";
75
73
  import {
76
74
  conversationLogPath,
77
75
  ensureSessionStarted,
78
76
  openConversationLog,
77
+ readConversationFacts,
79
78
  recordAccountBound
80
- } from "./chunk-HOKSVFIC.js";
79
+ } from "./chunk-VQ5KK7YF.js";
81
80
  import {
82
81
  readIdentity
83
- } from "./chunk-7AWFHVMT.js";
82
+ } from "./chunk-T2CHZ6V7.js";
84
83
  import {
85
84
  INSTRUCTIONS_FILENAME,
86
85
  MAX_CHARS_PER_FILE,
@@ -91,12 +90,12 @@ import {
91
90
  } from "./chunk-JQIBPPOL.js";
92
91
  import {
93
92
  isDefaultAccountId
94
- } from "./chunk-OAHCS42A.js";
93
+ } from "./chunk-VTS2SVX6.js";
95
94
  import {
96
95
  createLazyCodeAnalysis,
97
96
  promptCacheTtl,
98
97
  setPromptCacheTtl
99
- } from "./chunk-UMHKTV2L.js";
98
+ } from "./chunk-FAWY4LRG.js";
100
99
  import {
101
100
  DEFAULT_MAX_HOOK_REFUSALS,
102
101
  SAVE_SKILL_TOOL_NAME,
@@ -106,76 +105,45 @@ import {
106
105
  turnConfigFields,
107
106
  withSandboxShell,
108
107
  workingDirectoryProblem
109
- } from "./chunk-Z5FDI74K.js";
108
+ } from "./chunk-5YNAPIUZ.js";
110
109
  import {
111
110
  CHECK_HINT
112
111
  } from "./chunk-BBTPD3DU.js";
113
- import {
114
- conversationInUseSentence,
115
- minutesUntilFree
116
- } from "./chunk-M3AUPUII.js";
117
- import {
118
- debugRequested
119
- } from "./chunk-GNBMKISG.js";
120
112
  import {
121
113
  ensureLocalConfigIgnored,
122
114
  logIgnoreOutcome,
123
115
  probeCapabilities,
124
116
  writeLocalAllows
125
- } from "./chunk-WOSL3OZD.js";
126
- import {
127
- LOCAL_CONFIG_FILE,
128
- configuredPassthroughTools,
129
- parseTokenTarget,
130
- readBoundDecisionKey,
131
- resolveToolResultScreens,
132
- sessionWorkflowSizeAdvice,
133
- takeConfigWarnings,
134
- unmatchedPassthroughTools,
135
- workflowTokenCeiling
136
- } from "./chunk-WSMX3IQE.js";
137
- import {
138
- compilePermissions,
139
- isPathRuleTool,
140
- pathRule,
141
- pathRuleTools
142
- } from "./chunk-5NDRDTNX.js";
143
- import {
144
- resolveGeneratorSettings
145
- } from "./chunk-LCGXWCVU.js";
117
+ } from "./chunk-VBRCNXMM.js";
146
118
  import {
147
- cliLogger
148
- } from "./chunk-HUONDMU4.js";
149
- import {
150
- readModelLaunchEnvironment
151
- } from "./chunk-LVVD32KJ.js";
152
- import {
153
- formatSize,
154
- homePath,
155
- plural,
156
- productName
157
- } from "./chunk-6PWRKA5T.js";
119
+ conversationInUseSentence,
120
+ minutesUntilFree
121
+ } from "./chunk-ZI5FFFBJ.js";
158
122
  import {
159
- require_dist
160
- } from "./chunk-KONYGNG6.js";
123
+ debugRequested
124
+ } from "./chunk-GNBMKISG.js";
161
125
  import {
162
126
  isPermissionMode,
163
127
  permissionModeLabel
164
- } from "./chunk-QPR3UA4L.js";
165
- import {
166
- PERMISSION_MODE_NAMES
167
- } from "./chunk-WMEZTDLT.js";
128
+ } from "./chunk-MXJAJXE7.js";
168
129
  import {
169
130
  diffColors,
170
131
  theme
171
132
  } from "./chunk-WD2F6EO3.js";
172
133
  import {
173
- stringWidth
174
- } from "./chunk-U5UV2YRE.js";
134
+ discoverAgentDefinitions
135
+ } from "./chunk-P3LYPSD6.js";
136
+ import {
137
+ createAgentHooksHost
138
+ } from "./chunk-DEH4YIDN.js";
175
139
  import {
176
- discoverSkills,
177
- loadSkillBody
178
- } from "./chunk-HGZYNEQE.js";
140
+ readSkillHooks,
141
+ withoutConversationEvents,
142
+ withoutSessionStart
143
+ } from "./chunk-IERT7D34.js";
144
+ import {
145
+ parseSkillMarkdown
146
+ } from "./chunk-JFLX34FA.js";
179
147
  import {
180
148
  chainCapabilityDisagreements,
181
149
  chainPositionName,
@@ -187,7 +155,7 @@ import {
187
155
  readPreferences,
188
156
  resolveChainCapabilities,
189
157
  unresolvedMembers
190
- } from "./chunk-PV65WQHD.js";
158
+ } from "./chunk-XGS5WUCQ.js";
191
159
  import {
192
160
  canSelectModel,
193
161
  createGeminiAccessTokenResolver,
@@ -195,11 +163,46 @@ import {
195
163
  findDetected,
196
164
  hasApiCredential,
197
165
  requiresCredentialForModel
198
- } from "./chunk-X6SREM2V.js";
166
+ } from "./chunk-JXJIKAAE.js";
199
167
  import {
200
168
  activeZenCatalogue,
201
169
  isOfferableModel
202
170
  } from "./chunk-4QIWRKJO.js";
171
+ import {
172
+ LOCAL_CONFIG_FILE,
173
+ configuredPassthroughTools,
174
+ parseTokenTarget,
175
+ readBoundDecisionKey,
176
+ resolveToolResultScreens,
177
+ sessionWorkflowSizeAdvice,
178
+ takeConfigWarnings,
179
+ unmatchedPassthroughTools,
180
+ workflowTokenCeiling
181
+ } from "./chunk-YCJOAIDG.js";
182
+ import {
183
+ resolveGeneratorSettings
184
+ } from "./chunk-LCGXWCVU.js";
185
+ import {
186
+ compilePermissions
187
+ } from "./chunk-4NVFHP23.js";
188
+ import {
189
+ cliLogger
190
+ } from "./chunk-W5TE6NIA.js";
191
+ import {
192
+ readModelLaunchEnvironment
193
+ } from "./chunk-LVVD32KJ.js";
194
+ import {
195
+ formatSize,
196
+ homePath,
197
+ plural,
198
+ productName
199
+ } from "./chunk-6PWRKA5T.js";
200
+ import {
201
+ require_dist
202
+ } from "./chunk-KONYGNG6.js";
203
+ import {
204
+ stringWidth
205
+ } from "./chunk-U5UV2YRE.js";
203
206
  import {
204
207
  PROVIDER_REGISTRY,
205
208
  missingCredentialMessage,
@@ -208,20 +211,23 @@ import {
208
211
  import {
209
212
  isAnthropicOAuthToken,
210
213
  readCodexCredentialFile
211
- } from "./chunk-UWN4WNQZ.js";
214
+ } from "./chunk-DEEK2FOC.js";
212
215
  import {
213
216
  composeEnvironmentPrompt,
214
217
  detectWsl,
215
218
  environmentFactLines,
216
219
  permissionSentence,
217
220
  readEnvironmentFacts
218
- } from "./chunk-EKMHZKVP.js";
221
+ } from "./chunk-FRADQASS.js";
219
222
  import {
220
223
  ensurePrivateStateDirectory
221
- } from "./chunk-EKQ6J5KA.js";
224
+ } from "./chunk-O4GHSR2X.js";
225
+ import {
226
+ isTrusted
227
+ } from "./chunk-DSMBM5LQ.js";
222
228
  import {
223
229
  namzuHomePath
224
- } from "./chunk-3NAVAACC.js";
230
+ } from "./chunk-2KNLSJFS.js";
225
231
  import {
226
232
  AgentManager,
227
233
  AgentRegistry,
@@ -248,7 +254,6 @@ import {
248
254
  EXPLORE_AGENT_ID,
249
255
  EXPLORE_AGENT_PROMPT,
250
256
  FileWorkflowJournal,
251
- GitWorktreeDriver,
252
257
  GoalConfirmation,
253
258
  GuardedFetchProvider,
254
259
  InMemorySessionLog,
@@ -270,8 +275,6 @@ import {
270
275
  PLAN_AGENT_ID,
271
276
  PLAN_AGENT_PROMPT,
272
277
  PLAN_MODE_DOCTRINE,
273
- PluginLifecycleManager,
274
- PluginRegistry,
275
278
  PromptContributionRegistry,
276
279
  ProviderRegistry,
277
280
  QueryAgent,
@@ -282,11 +285,11 @@ import {
282
285
  SESSION_GOAL_TOOL_NAMES,
283
286
  SESSION_MEMORY_TAG,
284
287
  SHELL_HOOKS_PLUGIN_ID,
288
+ SHELL_HOOK_EVENTS,
285
289
  SearchToolsTool,
286
290
  SessionEvidenceOffsetError,
287
291
  SessionPaths,
288
292
  SessionSummaryMaterializer,
289
- SkillRegistry,
290
293
  ToolManager,
291
294
  TopicArchivedError,
292
295
  TopicManager,
@@ -299,7 +302,6 @@ import {
299
302
  asSessionId,
300
303
  asTaskId,
301
304
  asTurnId,
302
- attachShellHooks,
303
305
  backgroundTasksDisabled,
304
306
  batchNeedsReview,
305
307
  bindOwner,
@@ -326,6 +328,7 @@ import {
326
328
  createProjectInstructionMessage,
327
329
  createReviewHandler,
328
330
  createSessionTextEvidenceSource,
331
+ createShellHook,
329
332
  createSkillTool,
330
333
  createSystemMessage,
331
334
  createToolMessage,
@@ -337,8 +340,6 @@ import {
337
340
  describeToolCatalogTokens,
338
341
  diffLines,
339
342
  diffWords,
340
- discoverAgentDefinitions,
341
- discoverAllPluginDirs,
342
343
  ensureProject,
343
344
  external_exports,
344
345
  filtered,
@@ -414,8 +415,9 @@ import {
414
415
  windowsShellNotice,
415
416
  withModelWindowSuffixStripped,
416
417
  withProviderFallback,
418
+ worktreeHookHost,
417
419
  wrapUntrusted
418
- } from "./chunk-YELRULQ7.js";
420
+ } from "./chunk-JTEWIH66.js";
419
421
  import {
420
422
  __name,
421
423
  __toESM
@@ -737,10 +739,10 @@ var tail = Promise.resolve();
737
739
  var nextStart = 0;
738
740
  function cancelled(promise, signal) {
739
741
  signal.throwIfAborted();
740
- return new Promise((resolve15, reject) => {
742
+ return new Promise((resolve16, reject) => {
741
743
  const abort = /* @__PURE__ */ __name(() => reject(signal.reason), "abort");
742
744
  signal.addEventListener("abort", abort, { once: true });
743
- promise.then(resolve15, reject).finally(() => signal.removeEventListener("abort", abort));
745
+ promise.then(resolve16, reject).finally(() => signal.removeEventListener("abort", abort));
744
746
  });
745
747
  }
746
748
  __name(cancelled, "cancelled");
@@ -781,8 +783,8 @@ async function searchExa(query2, limit, context) {
781
783
  const deadline = Date.now() + DEADLINE_MS;
782
784
  const previous = tail;
783
785
  let release;
784
- tail = new Promise((resolve15) => {
785
- release = resolve15;
786
+ tail = new Promise((resolve16) => {
787
+ release = resolve16;
786
788
  });
787
789
  let acquired = false;
788
790
  try {
@@ -839,11 +841,11 @@ async function searchExa(query2, limit, context) {
839
841
  ).filter(Boolean);
840
842
  for (const payload of payloads) {
841
843
  if (payload.trim() === "[DONE]") continue;
842
- const message2 = JSON.parse(payload);
843
- if (!message2 || typeof message2 !== "object" || message2.id !== id) continue;
844
- if (message2.error)
844
+ const message = JSON.parse(payload);
845
+ if (!message || typeof message !== "object" || message.id !== id) continue;
846
+ if (message.error)
845
847
  throw new Error("Exa rejected the search RPC request; no results were retrieved.");
846
- const result = message2.result;
848
+ const result = message.result;
847
849
  if (!result || !Array.isArray(result.content))
848
850
  throw new Error("Exa returned an invalid search response.");
849
851
  const content = result.content.filter(
@@ -1024,10 +1026,10 @@ var COMPACT_RESULT_TEXT = "Compacted";
1024
1026
  var COMPACT_RESULT_HINT = "(ctrl+o to see full summary)";
1025
1027
  function estimateHistoryTokens(messages) {
1026
1028
  let chars = 0;
1027
- for (const message2 of messages) {
1028
- if (typeof message2.content === "string") chars += message2.content.length;
1029
- else if (message2.content) {
1030
- for (const block of message2.content) if (block.type === "text") chars += block.text.length;
1029
+ for (const message of messages) {
1030
+ if (typeof message.content === "string") chars += message.content.length;
1031
+ else if (message.content) {
1032
+ for (const block of message.content) if (block.type === "text") chars += block.text.length;
1031
1033
  }
1032
1034
  }
1033
1035
  return Math.ceil(chars / 4);
@@ -1207,8 +1209,8 @@ function cutLine(code) {
1207
1209
  return { code: code.slice(0, end), cut: code.length - end };
1208
1210
  }
1209
1211
  __name(cutLine, "cutLine");
1210
- function truncationNote(cut) {
1211
- return ` \u2026 [+${cut.toLocaleString("en-US")} chars]`;
1212
+ function truncationNote(cut2) {
1213
+ return ` \u2026 [+${cut2.toLocaleString("en-US")} chars]`;
1212
1214
  }
1213
1215
  __name(truncationNote, "truncationNote");
1214
1216
  function wrapRuns(runs, width) {
@@ -1241,8 +1243,8 @@ function entriesOf(hunk) {
1241
1243
  for (const row of hunk.lines) {
1242
1244
  if (row.startsWith("\\")) continue;
1243
1245
  const kind = row.startsWith("+") ? "add" : row.startsWith("-") ? "remove" : "same";
1244
- const { code, cut } = cutLine(expandTabs(row.slice(1)));
1245
- entries.push({ kind, code, cut, number: 0 });
1246
+ const { code, cut: cut2 } = cutLine(expandTabs(row.slice(1)));
1247
+ entries.push({ kind, code, cut: cut2, number: 0 });
1246
1248
  }
1247
1249
  for (let i = 0; i < entries.length; ) {
1248
1250
  if (entries[i]?.kind !== "remove") {
@@ -1394,8 +1396,8 @@ function fileViewRows(hunks, options) {
1394
1396
  for (const hunk of hunks) {
1395
1397
  for (const line of hunk.lines) {
1396
1398
  if (line.startsWith("\\")) continue;
1397
- const { code, cut } = cutLine(expandTabs(line.slice(1)));
1398
- const note = cut > 0 ? truncationNote(cut) : "";
1399
+ const { code, cut: cut2 } = cutLine(expandTabs(line.slice(1)));
1400
+ const note = cut2 > 0 ? truncationNote(cut2) : "";
1399
1401
  const pieces = wrapRuns([{ text: code, mark: false }], width);
1400
1402
  const last = pieces.at(-1) ?? [];
1401
1403
  const used = last.reduce((sum, run2) => sum + stringWidth(run2.text), 0);
@@ -1763,9 +1765,9 @@ function shortCommand(command) {
1763
1765
  const line = command?.split("\n")[0]?.replace(/\s+/g, " ").trim();
1764
1766
  if (!line) return void 0;
1765
1767
  if (line.length <= 60) return line;
1766
- const cut = line.slice(0, 59);
1767
- const space = cut.lastIndexOf(" ");
1768
- return `${(space > 20 ? cut.slice(0, space) : cut).trimEnd()}\u2026`;
1768
+ const cut2 = line.slice(0, 59);
1769
+ const space = cut2.lastIndexOf(" ");
1770
+ return `${(space > 20 ? cut2.slice(0, space) : cut2).trimEnd()}\u2026`;
1769
1771
  }
1770
1772
  __name(shortCommand, "shortCommand");
1771
1773
  function endedHow(facts) {
@@ -2040,7 +2042,7 @@ __name(screenApprover, "screenApprover");
2040
2042
 
2041
2043
  // src/tui/agent.ts
2042
2044
  import { realpath as realpath5, stat as stat7 } from "node:fs/promises";
2043
- import { join as join19, parse as parse2, resolve as resolve14, sep as sep8 } from "node:path";
2045
+ import { join as join19, parse as parse2, resolve as resolve15, sep as sep9 } from "node:path";
2044
2046
 
2045
2047
  // src/checkpoints/store.ts
2046
2048
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -2318,8 +2320,8 @@ var PlanError = class extends Error {
2318
2320
  static {
2319
2321
  __name(this, "PlanError");
2320
2322
  }
2321
- constructor(message2) {
2322
- super(message2);
2323
+ constructor(message) {
2324
+ super(message);
2323
2325
  this.name = "PlanError";
2324
2326
  }
2325
2327
  };
@@ -3921,14 +3923,14 @@ function composeLivePrompt(root, files) {
3921
3923
  const scope2 = relativeInstructionPath(root, file.scopeDir ?? root);
3922
3924
  const applies = kind === "user" ? "every project" : scope2.length === 0 ? "the whole project" : `only paths under \`${visibleProjectInstructionPath(scope2)}/\``;
3923
3925
  const note = kind === "local" ? " This file is private to this checkout." : kind === "import" && file.importedBy ? ` Included from \`${visibleProjectInstructionPath(displayPath2(root, file.importedBy))}\`.` : "";
3924
- const cut = file.omittedChars > 0 ? `
3926
+ const cut2 = file.omittedChars > 0 ? `
3925
3927
 
3926
3928
  (This file was cut at ${MAX_CHARS_PER_FILE} characters; ${file.omittedChars} more were not included. Read it with a tool if needed.)` : "";
3927
3929
  return `### ${visibleProjectInstructionPath(displayPath2(root, file.path))}
3928
3930
 
3929
3931
  Applies to ${applies}.${note}
3930
3932
 
3931
- ${file.text}${cut}`;
3933
+ ${file.text}${cut2}`;
3932
3934
  });
3933
3935
  return [
3934
3936
  "## Project instructions",
@@ -3964,10 +3966,10 @@ var ProjectInstructionTracker = class {
3964
3966
  }
3965
3967
  /** Re-read only paths named by validated provenance; persisted text is ignored. */
3966
3968
  rehydrate(messages) {
3967
- for (const message2 of messages) {
3968
- if (message2.role !== "user" || message2.source?.type !== "project-instructions") continue;
3969
- if (!isProjectInstructionMessageSource(message2.source)) continue;
3970
- for (const file of message2.source.files) {
3969
+ for (const message of messages) {
3970
+ if (message.role !== "user" || message.source?.type !== "project-instructions") continue;
3971
+ if (!isProjectInstructionMessageSource(message.source)) continue;
3972
+ for (const file of message.source.files) {
3971
3973
  const absolute = resolve6(this.root, file);
3972
3974
  if (!contained(this.root, absolute)) continue;
3973
3975
  this.registerPath(dirname3(absolute));
@@ -4109,9 +4111,9 @@ var ProjectInstructionTracker = class {
4109
4111
  }
4110
4112
  snapshotKeyFromMessages(messages) {
4111
4113
  for (let index = messages.length - 1; index >= 0; index -= 1) {
4112
- const message2 = messages[index];
4113
- if (message2?.role === "user" && message2.source?.type === "project-instructions" && isProjectInstructionMessageSource(message2.source)) {
4114
- return this.snapshotKey(message2);
4114
+ const message = messages[index];
4115
+ if (message?.role === "user" && message.source?.type === "project-instructions" && isProjectInstructionMessageSource(message.source)) {
4116
+ return this.snapshotKey(message);
4115
4117
  }
4116
4118
  }
4117
4119
  return "null";
@@ -4287,8 +4289,8 @@ function encodeCursor(cursor) {
4287
4289
  }
4288
4290
  __name(encodeCursor, "encodeCursor");
4289
4291
  var EvidenceCursorError = class extends Error {
4290
- constructor(code, message2) {
4291
- super(message2);
4292
+ constructor(code, message) {
4293
+ super(message);
4292
4294
  this.code = code;
4293
4295
  }
4294
4296
  code;
@@ -5547,8 +5549,8 @@ var DecisionError = class extends Error {
5547
5549
  }
5548
5550
  status;
5549
5551
  code;
5550
- constructor(message2, status, code) {
5551
- super(message2);
5552
+ constructor(message, status, code) {
5553
+ super(message);
5552
5554
  this.status = status;
5553
5555
  this.code = code;
5554
5556
  this.name = "DecisionError";
@@ -5942,12 +5944,12 @@ function findAzOnPath(env) {
5942
5944
  return void 0;
5943
5945
  }
5944
5946
  __name(findAzOnPath, "findAzOnPath");
5945
- var defaultRunAz = /* @__PURE__ */ __name((command, args) => new Promise((resolve15, reject) => {
5947
+ var defaultRunAz = /* @__PURE__ */ __name((command, args) => new Promise((resolve16, reject) => {
5946
5948
  execFile2(
5947
5949
  command,
5948
5950
  [...args],
5949
5951
  { timeout: AZ_TIMEOUT_MS, windowsHide: true, shell: process.platform === "win32" },
5950
- (error, stdout) => error ? reject(error) : resolve15(stdout)
5952
+ (error, stdout) => error ? reject(error) : resolve16(stdout)
5951
5953
  );
5952
5954
  }), "defaultRunAz");
5953
5955
  function parseAzTokenOutput(output) {
@@ -6390,19 +6392,19 @@ function createBackgroundLearning(options) {
6390
6392
  const release = /* @__PURE__ */ __name(() => {
6391
6393
  const ready = waiters;
6392
6394
  waiters = [];
6393
- for (const resolve15 of ready) resolve15();
6395
+ for (const resolve16 of ready) resolve16();
6394
6396
  }, "release");
6395
6397
  const quiet = /* @__PURE__ */ __name(() => active === 0 && !options.questions?.isOpen(), "quiet");
6396
- const untilIdle = /* @__PURE__ */ __name((signal) => new Promise((resolve15, reject) => {
6398
+ const untilIdle = /* @__PURE__ */ __name((signal) => new Promise((resolve16, reject) => {
6397
6399
  if (signal.aborted) return reject(signal.reason);
6398
- if (quiet()) return resolve15();
6400
+ if (quiet()) return resolve16();
6399
6401
  const onAbort = /* @__PURE__ */ __name(() => {
6400
6402
  waiters = waiters.filter((w) => w !== done);
6401
6403
  reject(signal.reason);
6402
6404
  }, "onAbort");
6403
6405
  const done = /* @__PURE__ */ __name(() => {
6404
6406
  signal.removeEventListener("abort", onAbort);
6405
- resolve15();
6407
+ resolve16();
6406
6408
  }, "done");
6407
6409
  signal.addEventListener("abort", onAbort, { once: true });
6408
6410
  waiters.push(done);
@@ -7411,226 +7413,6 @@ function hookSessionMode(live, configured) {
7411
7413
  }
7412
7414
  __name(hookSessionMode, "hookSessionMode");
7413
7415
 
7414
- // src/integrations/plugins/hook-path-filter.ts
7415
- function createHookPathFilter(cwd) {
7416
- return (tool, pattern, callTool, toolInput) => {
7417
- if (!isPathRuleTool(tool)) return void 0;
7418
- if (!pathRuleTools(tool).includes(callTool)) return false;
7419
- const input = toolInput !== null && typeof toolInput === "object" ? toolInput : void 0;
7420
- const written = input?.path;
7421
- const searchTool = callTool === "grep" || callTool === "glob" || callTool === "ls";
7422
- if (!(typeof written === "string" && written !== "") && !searchTool) return void 0;
7423
- const rule = pathRule(tool, pattern, "ask", { cwd });
7424
- if (rule.type !== "predicate") return void 0;
7425
- try {
7426
- return rule.decide({
7427
- toolName: callTool,
7428
- toolInput,
7429
- toolDef: void 0,
7430
- commandDialect: "sh"
7431
- }) !== null;
7432
- } catch {
7433
- return void 0;
7434
- }
7435
- };
7436
- }
7437
- __name(createHookPathFilter, "createHookPathFilter");
7438
-
7439
- // src/integrations/plugins/runtime.ts
7440
- var SESSION_END_HOOK_TIMEOUT_MS = 5e3;
7441
- var MAX_HOOK_TIMEOUT_MS = 10 * 6e4;
7442
- function sessionEndHookBudgetMs(hooks) {
7443
- let longest = 0;
7444
- for (const entry of hooks?.session_end ?? []) {
7445
- if ("async" in entry && entry.async === true) continue;
7446
- const own = entry.timeoutMs ?? SESSION_END_HOOK_TIMEOUT_MS;
7447
- longest = Math.max(longest, Math.min(MAX_HOOK_TIMEOUT_MS, Math.max(1, own)));
7448
- }
7449
- return longest;
7450
- }
7451
- __name(sessionEndHookBudgetMs, "sessionEndHookBudgetMs");
7452
- function hookTimeoutLine(info) {
7453
- const seconds = info.timeoutMs / 1e3;
7454
- return `The ${info.event} hook \`${info.hook}\` did not finish within ${seconds} second${seconds === 1 ? "" : "s"} and was ended.`;
7455
- }
7456
- __name(hookTimeoutLine, "hookTimeoutLine");
7457
- function message(error) {
7458
- return error instanceof Error ? error.message : String(error);
7459
- }
7460
- __name(message, "message");
7461
- async function createCliPluginRuntime(config, cwd, hooks, hookHost) {
7462
- const pluginsEnabled = config?.enabled === true;
7463
- const launchDirs = config?.launchDirs ?? [];
7464
- const hookCount = hooks ? Object.values(hooks).reduce((n, list) => n + (list?.length ?? 0), 0) : 0;
7465
- if (!pluginsEnabled && hookCount === 0 && launchDirs.length === 0) return void 0;
7466
- const log = cliLogger();
7467
- const userRoot = resolveNamzuHome();
7468
- const settings = new PluginSettingsStore(userRoot);
7469
- const plugins = new PluginRegistry();
7470
- const skills = new SkillRegistry(log);
7471
- const manager = new PluginLifecycleManager({
7472
- pluginRegistry: plugins,
7473
- skillRegistry: skills,
7474
- scopeRoots: { project: cwd, user: userRoot },
7475
- log,
7476
- ...config?.hookTimeoutMs !== void 0 ? { hookTimeoutMs: config.hookTimeoutMs } : {}
7477
- });
7478
- if (hooks && hookCount > 0) {
7479
- attachShellHooks(manager, hooks, {
7480
- cwd,
7481
- // The folder the session was started for, for a hook script to find its own files.
7482
- projectDir: cwd,
7483
- pathFilter: createHookPathFilter(cwd),
7484
- log,
7485
- defaultTimeoutMs: { session_end: SESSION_END_HOOK_TIMEOUT_MS },
7486
- // Only the close of a session says so out loud: it is the one place
7487
- // a person is left waiting with nothing on screen to explain it.
7488
- onTimeout: /* @__PURE__ */ __name((info) => {
7489
- if (info.event === "session_end") process.stderr.write(`${hookTimeoutLine(info)}
7490
- `);
7491
- }, "onTimeout"),
7492
- ...hookHost
7493
- });
7494
- }
7495
- const allowedScopes = config?.allowedScopes ?? ["project", "user"];
7496
- const discovered = pluginsEnabled ? await discoverAllPluginDirs(cwd, {
7497
- enabled: true,
7498
- autoDiscovery: config?.autoDiscovery ?? true,
7499
- allowedScopes,
7500
- userRoot,
7501
- log
7502
- }) : { project: [], user: [] };
7503
- const installed = [];
7504
- try {
7505
- for (const scope2 of allowedScopes) {
7506
- const dirs = [...discovered[scope2]].sort((a, b) => a.localeCompare(b));
7507
- for (const dir of dirs) {
7508
- const plugin = await manager.install(dir, scope2);
7509
- installed.push(plugin);
7510
- const enabled = settings.read({ rootDir: plugin.rootDir, name: plugin.manifest.name });
7511
- if (enabled) await manager.enable(plugin.id);
7512
- }
7513
- }
7514
- for (const dir of launchDirs) {
7515
- const plugin = await manager.install(dir, "user", { authorityRoot: dir });
7516
- installed.push(plugin);
7517
- const enabled = settings.read({ rootDir: plugin.rootDir, name: plugin.manifest.name });
7518
- if (enabled) await manager.enable(plugin.id);
7519
- }
7520
- } catch (error) {
7521
- const cleanupErrors = [];
7522
- for (const plugin of [...installed].reverse()) {
7523
- try {
7524
- await manager.uninstall(plugin.id);
7525
- } catch (cleanupError) {
7526
- cleanupErrors.push(cleanupError);
7527
- }
7528
- }
7529
- const cleanupSuffix = cleanupErrors.length === 0 ? "" : ` Cleanup also failed: ${cleanupErrors.map(message).join("; ")}`;
7530
- throw new Error(`Plugin runtime could not start: ${message(error)}.${cleanupSuffix}`, {
7531
- cause: error
7532
- });
7533
- }
7534
- let closePromise;
7535
- let closed = false;
7536
- let mutation;
7537
- const contributedToolNames = /* @__PURE__ */ __name((prefix) => manager.toolsets.flatMap((ts) => ts.tools()).map((tool) => tool.name).filter((name) => name.startsWith(prefix)).sort(), "contributedToolNames");
7538
- return {
7539
- manager,
7540
- skills,
7541
- pluginCount: installed.length,
7542
- sessionEndBudgetMs: sessionEndHookBudgetMs(hooks),
7543
- pluginHooks: /* @__PURE__ */ __name(() => manager.listHooks().filter((hook) => hook.pluginId !== SHELL_HOOKS_PLUGIN_ID).map((hook) => ({
7544
- plugin: plugins.get(hook.pluginId)?.manifest.name ?? String(hook.pluginId),
7545
- event: hook.event
7546
- })), "pluginHooks"),
7547
- list: /* @__PURE__ */ __name(() => plugins.getAll().map((plugin) => {
7548
- const prefix = `${plugin.manifest.name}__`;
7549
- let startupEnabled;
7550
- let startupError;
7551
- try {
7552
- startupEnabled = settings.read({ rootDir: plugin.rootDir, name: plugin.manifest.name });
7553
- } catch (error) {
7554
- startupError = message(error);
7555
- }
7556
- return {
7557
- name: plugin.manifest.name,
7558
- version: plugin.manifest.version,
7559
- description: plugin.manifest.description,
7560
- scope: plugin.scope,
7561
- rootDir: plugin.rootDir,
7562
- status: plugin.status === "installed" ? "disabled" : plugin.status,
7563
- ...startupEnabled !== void 0 ? { startupEnabled } : {},
7564
- ...startupError ? { startupError } : {},
7565
- tools: contributedToolNames(prefix),
7566
- skills: skills.list().map((skill) => skill.metadata.name).filter((name) => name.startsWith(prefix)).sort(),
7567
- hookModules: [...plugin.manifest.hooks ?? []],
7568
- mcpServers: (plugin.manifest.mcpServers ?? []).map((server) => server.name),
7569
- commands: resolvePluginFileDirs(
7570
- plugin.manifest.name,
7571
- plugin.rootDir,
7572
- plugin.manifest.commands
7573
- ).dirs.flatMap(
7574
- (source) => listMarkdownNames(source.dir).map((file) => `${prefix}${file}`)
7575
- ),
7576
- agents: resolvePluginFileDirs(
7577
- plugin.manifest.name,
7578
- plugin.rootDir,
7579
- plugin.manifest.agents
7580
- ).dirs.flatMap(
7581
- (source) => listMarkdownNames(source.dir).map((file) => `${prefix}${file}`)
7582
- )
7583
- };
7584
- }).sort((a, b) => a.name.localeCompare(b.name)), "list"),
7585
- async setEnabled(name, enabled) {
7586
- if (closed) throw new Error("Plugin runtime is closed.");
7587
- if (mutation) throw new Error("Another plugin change is in progress.");
7588
- const plugin = plugins.findByName(name);
7589
- if (!plugin) throw new Error(`Plugin "${name}" is not loaded in this session.`);
7590
- if (enabled && plugin.status === "enabled" || !enabled && (plugin.status === "disabled" || plugin.status === "installed"))
7591
- return;
7592
- mutation = enabled ? manager.enable(plugin.id) : manager.disable(plugin.id);
7593
- try {
7594
- await mutation;
7595
- } finally {
7596
- mutation = void 0;
7597
- }
7598
- },
7599
- async rememberState(name) {
7600
- if (closed) throw new Error("Plugin runtime is closed.");
7601
- if (mutation) throw new Error("Another plugin change is in progress.");
7602
- const plugin = plugins.findByName(name);
7603
- if (!plugin) throw new Error(`Plugin "${name}" is not loaded in this session.`);
7604
- if (!["enabled", "disabled", "installed"].includes(plugin.status)) {
7605
- throw new Error("Resolve the plugin error before remembering its state.");
7606
- }
7607
- const enabled = plugin.status === "enabled";
7608
- settings.write({ rootDir: plugin.rootDir, name }, enabled);
7609
- },
7610
- close() {
7611
- if (closePromise) return closePromise;
7612
- closed = true;
7613
- closePromise = (async () => {
7614
- if (mutation) await mutation.catch(() => {
7615
- });
7616
- const errors = [];
7617
- for (const plugin of [...installed].reverse()) {
7618
- try {
7619
- await manager.uninstall(plugin.id);
7620
- } catch (error) {
7621
- errors.push(error);
7622
- }
7623
- }
7624
- if (errors.length > 0) {
7625
- throw new AggregateError(errors, "One or more plugins could not be uninstalled.");
7626
- }
7627
- })();
7628
- return closePromise;
7629
- }
7630
- };
7631
- }
7632
- __name(createCliPluginRuntime, "createCliPluginRuntime");
7633
-
7634
7416
  // src/integrations/providers/anthropic-endpoint.ts
7635
7417
  var VENDOR_HOST = "api.anthropic.com";
7636
7418
  function readAnthropicEndpoint(env = process.env) {
@@ -7899,19 +7681,19 @@ function createContextInventoryStep() {
7899
7681
  const blocks = [];
7900
7682
  let totalChars = 0;
7901
7683
  let imageCount = 0;
7902
- for (const [position, message2] of messages.entries()) {
7903
- if (message2.role !== "tool") continue;
7684
+ for (const [position, message] of messages.entries()) {
7685
+ if (message.role !== "tool") continue;
7904
7686
  let chars = 0;
7905
7687
  let images = 0;
7906
- if (typeof message2.content === "string") chars = message2.content.length;
7907
- else if (Array.isArray(message2.content))
7908
- for (const block of message2.content) {
7688
+ if (typeof message.content === "string") chars = message.content.length;
7689
+ else if (Array.isArray(message.content))
7690
+ for (const block of message.content) {
7909
7691
  if (block.type === "text") chars += block.text.length;
7910
7692
  else images++;
7911
7693
  }
7912
7694
  totalChars += chars;
7913
7695
  imageCount += images;
7914
- blocks.push({ position, chars, images, pinned: message2.retain === true });
7696
+ blocks.push({ position, chars, images, pinned: message.retain === true });
7915
7697
  }
7916
7698
  const pressure = contextBudget && contextBudget.remainingTokens < contextBudget.windowTokens / 4;
7917
7699
  if (totalChars < 16e3 && !pressure) return void 0;
@@ -8186,7 +7968,7 @@ function estimateTokens(text2) {
8186
7968
  __name(estimateTokens, "estimateTokens");
8187
7969
  function createSideModel(deps) {
8188
7970
  const routes = /* @__PURE__ */ new Map();
8189
- const resolve15 = /* @__PURE__ */ __name(async (sessionId, signal) => {
7971
+ const resolve16 = /* @__PURE__ */ __name(async (sessionId, signal) => {
8190
7972
  const active = deps.active();
8191
7973
  if (deps.configured !== void 0) {
8192
7974
  const target = parseSmallModel(deps.configured, active.providerId, deps.isKnownProvider);
@@ -8223,7 +8005,7 @@ ${active.model}
8223
8005
  ${deps.configured ?? ""}`;
8224
8006
  let pending = routes.get(key);
8225
8007
  if (pending === void 0) {
8226
- pending = resolve15(sessionId, signal);
8008
+ pending = resolve16(sessionId, signal);
8227
8009
  routes.set(key, pending);
8228
8010
  void pending.then((value) => {
8229
8011
  if (signal.aborted && value.source === "main" && routes.get(key) === pending) {
@@ -8291,98 +8073,6 @@ __name(createSideModel, "createSideModel");
8291
8073
  // src/integrations/state/retention.ts
8292
8074
  var CLI_CHECKPOINT_RETENTION = 10;
8293
8075
 
8294
- // src/integrations/subagents/definitions.ts
8295
- import { join as join7 } from "node:path";
8296
- function userAgentsDir(home) {
8297
- return join7(namzuHomePath(home), "agents");
8298
- }
8299
- __name(userAgentsDir, "userAgentsDir");
8300
- function projectAgentsDir(cwd) {
8301
- return join7(cwd, ".namzu", "agents");
8302
- }
8303
- __name(projectAgentsDir, "projectAgentsDir");
8304
- var AGENT_FILE_PERMISSION_MODES = /* @__PURE__ */ new Set([
8305
- ...PERMISSION_MODE_NAMES,
8306
- "inherit"
8307
- ]);
8308
- async function discoverAgentDefinitions2(opts) {
8309
- const fromPlugins = await Promise.all(
8310
- (opts.pluginAgentDirs ?? []).map(async ({ plugin, dir }) => {
8311
- const found2 = await discoverAgentDefinitions([{ dir, source: "plugin" }], {
8312
- permissionModes: AGENT_FILE_PERMISSION_MODES
8313
- });
8314
- return {
8315
- definitions: found2.definitions.map((definition) => ({
8316
- ...definition,
8317
- name: `${plugin}__${definition.name}`
8318
- })),
8319
- skipped: found2.skipped
8320
- };
8321
- })
8322
- );
8323
- const own = await discoverAgentDefinitions(
8324
- [
8325
- { dir: userAgentsDir(opts.home), source: "user" },
8326
- { dir: projectAgentsDir(opts.cwd), source: "project" }
8327
- ],
8328
- { permissionModes: AGENT_FILE_PERMISSION_MODES }
8329
- );
8330
- const byName = /* @__PURE__ */ new Map();
8331
- for (const set of fromPlugins)
8332
- for (const definition of set.definitions) byName.set(definition.name, definition);
8333
- for (const definition of own.definitions) byName.set(definition.name, definition);
8334
- const found = {
8335
- definitions: [...byName.values()],
8336
- skipped: [...fromPlugins.flatMap((set) => set.skipped), ...own.skipped]
8337
- };
8338
- if (!found.definitions.some((definition) => definition.skills !== void 0)) {
8339
- return { ...found, missingSkills: [] };
8340
- }
8341
- const roster = new Map(
8342
- discoverSkills({
8343
- cwd: opts.cwd,
8344
- ...opts.home !== void 0 ? { home: opts.home } : {},
8345
- ...opts.skills ? { config: opts.skills } : {}
8346
- }).map((skill) => [skill.name, skill])
8347
- );
8348
- const missingSkills = [];
8349
- const definitions = found.definitions.map((definition) => {
8350
- if (definition.skills === void 0) return definition;
8351
- const blocks = [];
8352
- for (const name of definition.skills) {
8353
- const skill = roster.get(name);
8354
- if (!skill || skill.problem !== void 0) {
8355
- missingSkills.push({
8356
- path: definition.path,
8357
- reason: `skill ${name} ${skill?.problem ? `cannot be used: ${skill.problem}` : "was not found"}`
8358
- });
8359
- continue;
8360
- }
8361
- try {
8362
- blocks.push(`### Skill: ${name}
8363
-
8364
- ${loadSkillBody(skill)}`);
8365
- } catch (error) {
8366
- missingSkills.push({
8367
- path: definition.path,
8368
- reason: `skill ${name} could not be read: ${error instanceof Error ? error.message : String(error)}`
8369
- });
8370
- }
8371
- }
8372
- if (blocks.length === 0) return definition;
8373
- return {
8374
- ...definition,
8375
- prompt: `${definition.prompt}
8376
-
8377
- These skills are loaded for you. Apply their guidance when it fits the task.
8378
-
8379
- ${blocks.join("\n\n")}`
8380
- };
8381
- });
8382
- return { definitions, skipped: found.skipped, missingSkills };
8383
- }
8384
- __name(discoverAgentDefinitions2, "discoverAgentDefinitions");
8385
-
8386
8076
  // src/integrations/subagents/model-effort.ts
8387
8077
  async function prepareDelegatedEffort(provider, model, signal) {
8388
8078
  if ((provider.reasoningEffortLevelsFor?.(model) ?? provider.effortLevelsFor?.(model)) !== void 0)
@@ -8397,7 +8087,7 @@ __name(prepareDelegatedEffort, "prepareDelegatedEffort");
8397
8087
 
8398
8088
  // src/integrations/subagents/operator-journal.ts
8399
8089
  import { appendFile, open as open2 } from "node:fs/promises";
8400
- import { join as join8 } from "node:path";
8090
+ import { join as join7 } from "node:path";
8401
8091
  var MAX_READ_BYTES = 256 * 1024;
8402
8092
  var MAX_CONTEXT_CHARACTERS = 32e3;
8403
8093
  function formatChildOperatorAdmission(input) {
@@ -8407,7 +8097,7 @@ function formatChildOperatorAdmission(input) {
8407
8097
  }
8408
8098
  __name(formatChildOperatorAdmission, "formatChildOperatorAdmission");
8409
8099
  async function readChildOperatorNotices(paths, sessionId) {
8410
- const path = join8(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
8100
+ const path = join7(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
8411
8101
  let file;
8412
8102
  try {
8413
8103
  file = await open2(path, "r");
@@ -8478,7 +8168,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
8478
8168
  })
8479
8169
  ).join("\n");
8480
8170
  await appendFile(
8481
- join8(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8171
+ join7(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8482
8172
  `${lines}
8483
8173
  `,
8484
8174
  { mode: 384 }
@@ -8487,7 +8177,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
8487
8177
  __name(acknowledgeChildOperatorNotices, "acknowledgeChildOperatorNotices");
8488
8178
  async function recordChildOperatorReport(paths, sessionId, notice2) {
8489
8179
  await appendFile(
8490
- join8(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8180
+ join7(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8491
8181
  `${JSON.stringify({ ...notice2, status: "child-report", source: "host", at: (/* @__PURE__ */ new Date()).toISOString() })}
8492
8182
  `,
8493
8183
  { mode: 384 }
@@ -8534,6 +8224,9 @@ async function resolveSubagentParent(scope2, cwd, records) {
8534
8224
  }
8535
8225
  __name(resolveSubagentParent, "resolveSubagentParent");
8536
8226
 
8227
+ // src/integrations/subagents/replay.ts
8228
+ import { readFile as readFile4 } from "node:fs/promises";
8229
+
8537
8230
  // src/integrations/subagents/activity.ts
8538
8231
  import { Buffer as Buffer2 } from "node:buffer";
8539
8232
 
@@ -9329,7 +9022,11 @@ async function readSavedChildrenPage(scope2, limit) {
9329
9022
  const found = [];
9330
9023
  for (const child of children.slice(0, Math.max(0, limit))) {
9331
9024
  try {
9332
- found.push({ ...child, logPath: scope2.paths.subagentLog(scope2.session, child.sessionId) });
9025
+ found.push({
9026
+ ...child,
9027
+ logPath: scope2.paths.subagentLog(scope2.session, child.sessionId),
9028
+ metaPath: scope2.paths.subagentMeta(scope2.session, child.sessionId)
9029
+ });
9333
9030
  } catch (error) {
9334
9031
  scope2.log?.warn("A saved child names an id the session layout refuses", {
9335
9032
  "namzu.subagent.replay.child_session_id": String(child.sessionId),
@@ -9357,7 +9054,9 @@ async function replaySavedChildren(children, log) {
9357
9054
  monitor.replay(
9358
9055
  {
9359
9056
  agentId: evidence.agentId ?? child.kind,
9360
- description: child.description,
9057
+ // The short name the operator saw, when it was kept; else what the
9058
+ // parent's log recorded, which is the start of the prompt.
9059
+ description: await savedShortName(child) ?? child.description,
9361
9060
  ...evidence.prompt !== void 0 ? { prompt: evidence.prompt } : {},
9362
9061
  ...evidence.model ? { model: evidence.model } : {},
9363
9062
  sessionId: child.sessionId,
@@ -9383,6 +9082,18 @@ async function replaySavedChildren(children, log) {
9383
9082
  return monitor.getSnapshot();
9384
9083
  }
9385
9084
  __name(replaySavedChildren, "replaySavedChildren");
9085
+ async function savedShortName(child) {
9086
+ if (child.metaPath === void 0) return void 0;
9087
+ try {
9088
+ const meta = JSON.parse(await readFile4(child.metaPath, "utf8"));
9089
+ const profile = meta?.continuation?.profile;
9090
+ const name = profile?.description;
9091
+ return typeof name === "string" && name.trim().length > 0 ? name.trim() : void 0;
9092
+ } catch {
9093
+ return void 0;
9094
+ }
9095
+ }
9096
+ __name(savedShortName, "savedShortName");
9386
9097
  async function replaySavedChildrenFor(scope2) {
9387
9098
  return replaySavedChildren(await listSavedChildren(scope2), scope2.log);
9388
9099
  }
@@ -9514,7 +9225,7 @@ __name(errorMessage2, "errorMessage");
9514
9225
  import { randomUUID as randomUUID4 } from "node:crypto";
9515
9226
  import { existsSync as existsSync2 } from "node:fs";
9516
9227
  import { appendFile as appendFile2, mkdir as mkdir4 } from "node:fs/promises";
9517
- import { join as join12 } from "node:path";
9228
+ import { join as join11 } from "node:path";
9518
9229
 
9519
9230
  // src/integrations/subagents/fork.ts
9520
9231
  var FORK_SUBAGENT = "fork";
@@ -9545,16 +9256,16 @@ function forkDirective(prompt, options) {
9545
9256
  __name(forkDirective, "forkDirective");
9546
9257
  function isForkConversation(messages) {
9547
9258
  const marker = `<${DIRECTIVE_TAG}>`;
9548
- return messages.some((message2) => message2.role === "user" && message2.content.includes(marker));
9259
+ return messages.some((message) => message.role === "user" && message.content.includes(marker));
9549
9260
  }
9550
9261
  __name(isForkConversation, "isForkConversation");
9551
9262
  function forkSeed(history, toolUseId) {
9552
- const messages = history.filter((message2) => message2.role !== "system" || message2.source).map(withoutRecordId);
9263
+ const messages = history.filter((message) => message.role !== "system" || message.source).map(withoutRecordId);
9553
9264
  let issuing = -1;
9554
9265
  if (toolUseId !== void 0) {
9555
9266
  for (let index = messages.length - 1; index >= 0; index -= 1) {
9556
- const message2 = messages[index];
9557
- if (message2?.role === "assistant" && message2.toolCalls?.some((call) => call.id === toolUseId)) {
9267
+ const message = messages[index];
9268
+ if (message?.role === "assistant" && message.toolCalls?.some((call) => call.id === toolUseId)) {
9558
9269
  issuing = index;
9559
9270
  break;
9560
9271
  }
@@ -9572,20 +9283,20 @@ function forkSeed(history, toolUseId) {
9572
9283
  return completeExchanges(messages);
9573
9284
  }
9574
9285
  __name(forkSeed, "forkSeed");
9575
- function withoutRecordId(message2) {
9576
- const { id: _id, ...rest } = message2;
9286
+ function withoutRecordId(message) {
9287
+ const { id: _id, ...rest } = message;
9577
9288
  return rest;
9578
9289
  }
9579
9290
  __name(withoutRecordId, "withoutRecordId");
9580
9291
  function completeExchanges(messages) {
9581
9292
  const answered = /* @__PURE__ */ new Set();
9582
- for (const message2 of messages) {
9583
- if (message2.role === "tool") answered.add(message2.toolCallId);
9293
+ for (const message of messages) {
9294
+ if (message.role === "tool") answered.add(message.toolCallId);
9584
9295
  }
9585
9296
  for (let index = messages.length - 1; index >= 0; index -= 1) {
9586
- const message2 = messages[index];
9587
- if (message2?.role !== "assistant") continue;
9588
- if ((message2.toolCalls ?? []).every((call) => answered.has(call.id))) break;
9297
+ const message = messages[index];
9298
+ if (message?.role !== "assistant") continue;
9299
+ if ((message.toolCalls ?? []).every((call) => answered.has(call.id))) break;
9589
9300
  return messages.slice(0, index);
9590
9301
  }
9591
9302
  return [...messages];
@@ -9600,7 +9311,7 @@ function createIdleWatch(options) {
9600
9311
  let tripped;
9601
9312
  return {
9602
9313
  quietForMs: /* @__PURE__ */ __name(() => tripped, "quietForMs"),
9603
- wait: /* @__PURE__ */ __name((signal) => new Promise((resolve15) => {
9314
+ wait: /* @__PURE__ */ __name((signal) => new Promise((resolve16) => {
9604
9315
  if (signal.aborted) return;
9605
9316
  const timer = setInterval(() => {
9606
9317
  const last = options.lastProgressAt();
@@ -9610,7 +9321,7 @@ function createIdleWatch(options) {
9610
9321
  tripped = quiet;
9611
9322
  clearInterval(timer);
9612
9323
  signal.removeEventListener("abort", stop);
9613
- resolve15();
9324
+ resolve16();
9614
9325
  }, pollMs);
9615
9326
  const stop = /* @__PURE__ */ __name(() => clearInterval(timer), "stop");
9616
9327
  signal.addEventListener("abort", stop, { once: true });
@@ -9627,8 +9338,8 @@ __name(describeQuietTask, "describeQuietTask");
9627
9338
 
9628
9339
  // src/memory/typed.ts
9629
9340
  import { createHash as createHash3 } from "node:crypto";
9630
- import { access, readFile as readFile4, rename as rename3, writeFile as writeFile2 } from "node:fs/promises";
9631
- import { join as join11 } from "node:path";
9341
+ import { access, readFile as readFile5, rename as rename3, writeFile as writeFile2 } from "node:fs/promises";
9342
+ import { join as join10 } from "node:path";
9632
9343
 
9633
9344
  // src/memory/io.ts
9634
9345
  import {
@@ -9642,7 +9353,7 @@ import {
9642
9353
  realpathSync as realpathSync3,
9643
9354
  writeSync
9644
9355
  } from "node:fs";
9645
- import { isAbsolute as isAbsolute7, join as join9, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
9356
+ import { isAbsolute as isAbsolute7, join as join8, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
9646
9357
  var MEMORY_FILE_MAX_BYTES = 1024 * 1024;
9647
9358
  function missing(error) {
9648
9359
  return error.code === "ENOENT";
@@ -9675,7 +9386,7 @@ function resolveMemoryPath(location, createParents = false) {
9675
9386
  for (let i = 0; i < parts.length; i += 1) {
9676
9387
  const part = parts[i];
9677
9388
  if (part === void 0) throw new Error("Memory path has an invalid segment.");
9678
- candidate = join9(candidate, part);
9389
+ candidate = join8(candidate, part);
9679
9390
  const leaf = i === parts.length - 1;
9680
9391
  let stat8;
9681
9392
  try {
@@ -9800,18 +9511,18 @@ __name(appendMemoryFile, "appendMemoryFile");
9800
9511
 
9801
9512
  // src/memory/store.ts
9802
9513
  import { realpathSync as realpathSync4 } from "node:fs";
9803
- import { join as join10, resolve as resolve10 } from "node:path";
9514
+ import { join as join9, resolve as resolve10 } from "node:path";
9804
9515
  var MEMORY_SECTION_MAX_CHARS = 8e3;
9805
9516
  function memoryDir(home) {
9806
9517
  return namzuHomePath(home);
9807
9518
  }
9808
9519
  __name(memoryDir, "memoryDir");
9809
9520
  function userFilePath(home) {
9810
- return join10(memoryDir(home), "USER.md");
9521
+ return join9(memoryDir(home), "USER.md");
9811
9522
  }
9812
9523
  __name(userFilePath, "userFilePath");
9813
9524
  function memoryFilePath(home) {
9814
- return join10(memoryDir(home), "MEMORY.md");
9525
+ return join9(memoryDir(home), "MEMORY.md");
9815
9526
  }
9816
9527
  __name(memoryFilePath, "memoryFilePath");
9817
9528
  function projectMemoryFilePath(cwd) {
@@ -9822,9 +9533,9 @@ function projectMemoryFilePath(cwd) {
9822
9533
  if (error.code !== "ENOENT") throw error;
9823
9534
  }
9824
9535
  const root = cliProjectRoot(directory);
9825
- const local = join10(directory, ".namzu", "MEMORY.md");
9536
+ const local = join9(directory, ".namzu", "MEMORY.md");
9826
9537
  if (resolveMemoryPath({ path: local, root }) !== null) return local;
9827
- return join10(root, ".namzu", "MEMORY.md");
9538
+ return join9(root, ".namzu", "MEMORY.md");
9828
9539
  }
9829
9540
  __name(projectMemoryFilePath, "projectMemoryFilePath");
9830
9541
  function projectMemoryLocation(cwd) {
@@ -9854,15 +9565,15 @@ function readMemory(home, cwd) {
9854
9565
  }
9855
9566
  }, "read");
9856
9567
  const userRoot = memoryDir(home);
9857
- const user = read2(join10(userRoot, "USER.md"), () => ({
9568
+ const user = read2(join9(userRoot, "USER.md"), () => ({
9858
9569
  root: userRoot,
9859
- path: join10(userRoot, "USER.md")
9570
+ path: join9(userRoot, "USER.md")
9860
9571
  }));
9861
- const memory = read2(join10(userRoot, "MEMORY.md"), () => ({
9572
+ const memory = read2(join9(userRoot, "MEMORY.md"), () => ({
9862
9573
  root: userRoot,
9863
- path: join10(userRoot, "MEMORY.md")
9574
+ path: join9(userRoot, "MEMORY.md")
9864
9575
  }));
9865
- const project = cwd && !isUserMemoryFile(join10(resolve10(cwd), ".namzu", "MEMORY.md"), userRoot) ? read2(join10(resolve10(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
9576
+ const project = cwd && !isUserMemoryFile(join9(resolve10(cwd), ".namzu", "MEMORY.md"), userRoot) ? read2(join9(resolve10(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
9866
9577
  return { user, memory, project, ...diagnostics.length > 0 ? { diagnostics } : {} };
9867
9578
  }
9868
9579
  __name(readMemory, "readMemory");
@@ -9874,7 +9585,7 @@ function isUserMemoryFile(projectPath, userRoot) {
9874
9585
  return resolve10(path);
9875
9586
  }
9876
9587
  }, "canonical");
9877
- return canonical(projectPath) === canonical(join10(userRoot, "MEMORY.md"));
9588
+ return canonical(projectPath) === canonical(join9(userRoot, "MEMORY.md"));
9878
9589
  }
9879
9590
  __name(isUserMemoryFile, "isUserMemoryFile");
9880
9591
  function capped(text2, file) {
@@ -9883,8 +9594,8 @@ function capped(text2, file) {
9883
9594
  const last = text2.charCodeAt(end - 1);
9884
9595
  if (last >= 55296 && last <= 56319) end -= 1;
9885
9596
  const head = text2.slice(0, end);
9886
- const cut = head.lastIndexOf("\n");
9887
- const kept = cut > MEMORY_SECTION_MAX_CHARS / 2 ? head.slice(0, cut) : head;
9597
+ const cut2 = head.lastIndexOf("\n");
9598
+ const kept = cut2 > MEMORY_SECTION_MAX_CHARS / 2 ? head.slice(0, cut2) : head;
9888
9599
  return `${kept}
9889
9600
 
9890
9601
  (\u2026 ${text2.length - kept.length} more characters in ${file} were not included; the file wants curating.)`;
@@ -9966,7 +9677,7 @@ async function saveTypedNote(store, text2, type = "project") {
9966
9677
  saved: false,
9967
9678
  duplicate: true,
9968
9679
  type: record.entry.type ?? type,
9969
- ...record.entry.name ? { name: record.entry.name, path: join11(store.path, `${record.entry.name}.md`) } : {}
9680
+ ...record.entry.name ? { name: record.entry.name, path: join10(store.path, `${record.entry.name}.md`) } : {}
9970
9681
  };
9971
9682
  }
9972
9683
  }
@@ -9981,7 +9692,7 @@ async function saveTypedNote(store, text2, type = "project") {
9981
9692
  return {
9982
9693
  saved: true,
9983
9694
  type,
9984
- ...entry.name ? { name: entry.name, path: join11(store.path, `${entry.name}.md`) } : {}
9695
+ ...entry.name ? { name: entry.name, path: join10(store.path, `${entry.name}.md`) } : {}
9985
9696
  };
9986
9697
  }
9987
9698
  __name(saveTypedNote, "saveTypedNote");
@@ -10024,7 +9735,7 @@ __name(composeMemoryGuidance, "composeMemoryGuidance");
10024
9735
  var MARKER2 = "migration.json";
10025
9736
  async function readMarker(directory) {
10026
9737
  try {
10027
- const parsed = JSON.parse(await readFile4(join11(directory, MARKER2), "utf8"));
9738
+ const parsed = JSON.parse(await readFile5(join10(directory, MARKER2), "utf8"));
10028
9739
  return parsed !== null && typeof parsed === "object" ? parsed : {};
10029
9740
  } catch (error) {
10030
9741
  if (error.code === "ENOENT") return {};
@@ -10037,7 +9748,7 @@ async function markCuratedFile(directory, path, state) {
10037
9748
  const files = { ...marker.curatedFiles ?? {} };
10038
9749
  files[path] = { ...files[path] ?? {}, ...state };
10039
9750
  await writeFile2(
10040
- join11(directory, MARKER2),
9751
+ join10(directory, MARKER2),
10041
9752
  `${JSON.stringify({ ...marker, curatedFiles: files }, null, 2)}
10042
9753
  `,
10043
9754
  { mode: 384 }
@@ -10104,7 +9815,7 @@ async function migrateMemoryOnce(options) {
10104
9815
  const skippedRecords = [];
10105
9816
  let importedRecords = 0;
10106
9817
  let notesOffer;
10107
- const indexPath = join11(directory, "index.json");
9818
+ const indexPath = join10(directory, "index.json");
10108
9819
  if (await exists(indexPath)) {
10109
9820
  try {
10110
9821
  const disk = new DiskMemoryStore({ baseDir: directory, directory });
@@ -10127,11 +9838,11 @@ async function migrateMemoryOnce(options) {
10127
9838
  }
10128
9839
  }
10129
9840
  await retire(indexPath);
10130
- const content = join11(directory, "content");
9841
+ const content = join10(directory, "content");
10131
9842
  const retiredContent = await exists(content) ? await retire(content) : content;
10132
9843
  for (const record of refused) {
10133
9844
  skippedRecords.push(
10134
- `"${record.title}" (${record.id}) was not moved: ${record.reason} It is kept in ${join11(retiredContent, `${record.id}.json`)}.`
9845
+ `"${record.title}" (${record.id}) was not moved: ${record.reason} It is kept in ${join10(retiredContent, `${record.id}.json`)}.`
10135
9846
  );
10136
9847
  }
10137
9848
  } catch (error) {
@@ -10227,12 +9938,25 @@ __name(describeCuratedNotesImport, "describeCuratedNotesImport");
10227
9938
 
10228
9939
  // src/integrations/subagents/NamzuCliAgent.ts
10229
9940
  var NamzuCliAgent = class extends QueryAgent {
9941
+ constructor(metadata, log, scope2) {
9942
+ super({ ...metadata, type: "namzu-cli" }, log);
9943
+ this.scope = scope2;
9944
+ }
9945
+ scope;
10230
9946
  static {
10231
9947
  __name(this, "NamzuCliAgent");
10232
9948
  }
10233
9949
  type = "namzu-cli";
10234
- constructor(metadata, log) {
10235
- super({ ...metadata, type: "namzu-cli" }, log);
9950
+ async run(...args) {
9951
+ const [input, config] = args;
9952
+ const sessionId = input.managedScope?.sessionId ?? config.sessionId;
9953
+ if (!this.scope || sessionId === void 0) return super.run(...args);
9954
+ const end = this.scope(String(sessionId));
9955
+ try {
9956
+ return await super.run(...args);
9957
+ } finally {
9958
+ end();
9959
+ }
10236
9960
  }
10237
9961
  };
10238
9962
 
@@ -10613,12 +10337,14 @@ import { isAbsolute as isAbsolute8, relative as relative7, resolve as resolve11,
10613
10337
  import { promisify as promisify2 } from "node:util";
10614
10338
  var runFile = promisify2(execFile3);
10615
10339
  var DelegatedWorktreeDriver = class {
10616
- constructor(cwd, stateRoot) {
10340
+ constructor(cwd, stateRoot, hooks) {
10617
10341
  this.cwd = cwd;
10618
10342
  this.stateRoot = stateRoot;
10343
+ this.hooks = hooks;
10619
10344
  }
10620
10345
  cwd;
10621
10346
  stateRoot;
10347
+ hooks;
10622
10348
  static {
10623
10349
  __name(this, "DelegatedWorktreeDriver");
10624
10350
  }
@@ -10626,10 +10352,11 @@ var DelegatedWorktreeDriver = class {
10626
10352
  ready;
10627
10353
  async open() {
10628
10354
  this.ready ??= openManagedWorktrees(this.cwd, {
10629
- stateRoot: this.stateRoot
10355
+ stateRoot: this.stateRoot,
10356
+ ...this.hooks ? { hooks: this.hooks.host, onNotice: this.hooks.onNotice } : {}
10630
10357
  }).then(async (managed) => {
10631
10358
  const selectedDirectory = await realpath3(resolve11(this.cwd));
10632
- const subdirectory = relative7(managed.sourceRoot, selectedDirectory);
10359
+ const subdirectory = managed.isGit ? relative7(managed.sourceRoot, selectedDirectory) : "";
10633
10360
  if (isAbsolute8(subdirectory) || subdirectory === ".." || subdirectory.startsWith(`..${sep5}`)) {
10634
10361
  throw new Error("Selected directory is outside its Git checkout");
10635
10362
  }
@@ -10637,11 +10364,9 @@ var DelegatedWorktreeDriver = class {
10637
10364
  sourceRoot: managed.sourceRoot,
10638
10365
  subdirectory,
10639
10366
  worktreesDir: managed.worktreesDir,
10640
- driver: new GitWorktreeDriver({
10641
- repoRoot: managed.repoRoot,
10642
- worktreesDir: managed.worktreesDir,
10643
- logger: cliLogger()
10644
- })
10367
+ // Hooks first, the kernel's Git logic otherwise: one driver for both.
10368
+ driver: managed.workspaceDriver,
10369
+ isGit: managed.isGit
10645
10370
  };
10646
10371
  }).catch((error) => {
10647
10372
  this.ready = void 0;
@@ -10649,15 +10374,27 @@ var DelegatedWorktreeDriver = class {
10649
10374
  });
10650
10375
  return this.ready;
10651
10376
  }
10377
+ /** A failure a hook caused is a line for the person, in the hook's own words. */
10378
+ say(cause) {
10379
+ if (this.hooks && cause instanceof Error && cause.name === "WorktreeHookError") {
10380
+ this.hooks.onNotice(cause.message);
10381
+ }
10382
+ }
10652
10383
  /** Preserve the selected cwd beneath its checkout root for child execution. */
10653
10384
  async selectedSubdirectory() {
10654
10385
  return (await this.open()).subdirectory || void 0;
10655
10386
  }
10656
10387
  async create(params) {
10657
- const { sourceRoot, worktreesDir, driver } = await this.open();
10658
- const head = (await runFile("git", ["-C", sourceRoot, "rev-parse", "HEAD"])).stdout.trim();
10388
+ const { sourceRoot, worktreesDir, driver, isGit } = await this.open();
10389
+ const head = isGit ? (await runFile("git", ["-C", sourceRoot, "rev-parse", "HEAD"])).stdout.trim() : void 0;
10659
10390
  await mkdir3(worktreesDir, { recursive: true, mode: 448 });
10660
- return driver.create({ ...params, baseRef: params.baseRef ?? head });
10391
+ const baseRef = params.baseRef ?? head;
10392
+ try {
10393
+ return await driver.create({ ...params, ...baseRef !== void 0 ? { baseRef } : {} });
10394
+ } catch (cause) {
10395
+ this.say(cause);
10396
+ throw cause;
10397
+ }
10661
10398
  }
10662
10399
  async branch(source, params) {
10663
10400
  return (await this.open()).driver.branch(source, params);
@@ -10666,7 +10403,12 @@ var DelegatedWorktreeDriver = class {
10666
10403
  return (await this.open()).driver.inspect(ref);
10667
10404
  }
10668
10405
  async dispose(ref) {
10669
- return (await this.open()).driver.dispose(ref);
10406
+ try {
10407
+ return await (await this.open()).driver.dispose(ref);
10408
+ } catch (cause) {
10409
+ this.say(cause);
10410
+ throw cause;
10411
+ }
10670
10412
  }
10671
10413
  };
10672
10414
 
@@ -10756,10 +10498,10 @@ var ParentTaskScheduler = class extends LocalTaskScheduler {
10756
10498
  if (isTerminalAgentTaskState(task.state)) return task;
10757
10499
  return super.waitForTask(taskId);
10758
10500
  }
10759
- async continueTask(taskId, message2) {
10501
+ async continueTask(taskId, message) {
10760
10502
  if (!this.owns(taskId)) throw new Error(`No task with ID ${taskId} in this conversation.`);
10761
10503
  await this.validateContinuation();
10762
- await super.continueTask(taskId, message2);
10504
+ await super.continueTask(taskId, message);
10763
10505
  }
10764
10506
  };
10765
10507
  var refuseUnownedChildReview = /* @__PURE__ */ __name(async () => ({
@@ -10804,6 +10546,9 @@ async function createSubagentRuntime(input) {
10804
10546
  )
10805
10547
  );
10806
10548
  const fileAgents = /* @__PURE__ */ new Map();
10549
+ const refusedAgents = new Map(
10550
+ (opts.refusedDefinitions ?? []).map((refused) => [refused.name, refused])
10551
+ );
10807
10552
  for (const definition of opts.definitions ?? []) {
10808
10553
  fileAgents.set(definition.name, definition);
10809
10554
  registry.replace(
@@ -10821,6 +10566,7 @@ async function createSubagentRuntime(input) {
10821
10566
  )
10822
10567
  );
10823
10568
  }
10569
+ const refusedTypeIds = [...refusedAgents.keys()].filter((name) => !fileAgents.has(name));
10824
10570
  const agentTypeIds = [
10825
10571
  .../* @__PURE__ */ new Set([
10826
10572
  GENERAL_PURPOSE_SUBAGENT,
@@ -10859,7 +10605,11 @@ async function createSubagentRuntime(input) {
10859
10605
  const parents = /* @__PURE__ */ new Map();
10860
10606
  const readyParents = /* @__PURE__ */ new WeakMap();
10861
10607
  const sessions = /* @__PURE__ */ new Map();
10862
- const worktreeDriver = new DelegatedWorktreeDriver(opts.cwd, opts.worktreeStateRoot);
10608
+ const worktreeDriver = new DelegatedWorktreeDriver(
10609
+ opts.cwd,
10610
+ opts.worktreeStateRoot,
10611
+ opts.worktreeHooks
10612
+ );
10863
10613
  const tokenBudgetStore = opts.tokenBudgetStore ?? (opts.paths ? new DiskSessionTokenBudgetStore({ paths: opts.paths }) : new InMemorySessionTokenBudgetStore());
10864
10614
  let closed = false;
10865
10615
  const sessionKey = /* @__PURE__ */ __name(({ project, sessionId }) => JSON.stringify([project.tenantId, project.id, sessionId]), "sessionKey");
@@ -11341,6 +11091,8 @@ async function createSubagentRuntime(input) {
11341
11091
  } = input2;
11342
11092
  if (!requestedModel && (requestedProvider || requestedEffort))
11343
11093
  throw new Error("Supply model when selecting a child provider or effort.");
11094
+ const refusedFile = subagent_type !== void 0 && !fileAgents.has(subagent_type) ? refusedAgents.get(subagent_type) : void 0;
11095
+ if (refusedFile) throw new Error(refusedFile.line);
11344
11096
  const agentName = typeof input2.name === "string" ? input2.name.trim() : "";
11345
11097
  if (agentName.length > 0) {
11346
11098
  const problem = agentNameProblem(agentName);
@@ -11412,7 +11164,8 @@ async function createSubagentRuntime(input) {
11412
11164
  })
11413
11165
  }),
11414
11166
  ...selection ? { model: selection.model, effort: selection.effort } : {},
11415
- ...Object.keys(context.env ?? {}).length > 0 ? { env: context.env } : {},
11167
+ // The same object, not a copy: a variable a hook sets later reaches a child that is still working.
11168
+ ...context.env !== void 0 ? { env: context.env } : {},
11416
11169
  // The parent turn's tool-result screens, so a sub-agent judges a
11417
11170
  // connected answer the way the turn that asked for the work
11418
11171
  // does. Without it the child's executor installs the shipped
@@ -11613,8 +11366,8 @@ ${persona}` : persona || (readOnlyType !== void 0 ? READ_ONLY_PROMPTS.get(readOn
11613
11366
  },
11614
11367
  subagent_type: {
11615
11368
  type: "string",
11616
- enum: agentTypeIds,
11617
- 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; "fork" to continue this conversation in a side task.${fileAgentSummary.length > 0 ? ` This project also defines: ${fileAgentSummary}. Prefer a project-defined type when its description fits the task.` : ""}`
11369
+ enum: [...agentTypeIds, ...refusedTypeIds],
11370
+ 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; "fork" to continue this conversation in a side task.${fileAgentSummary.length > 0 ? ` This project also defines: ${fileAgentSummary}. Prefer a project-defined type when its description fits the task.` : ""}${refusedTypeIds.length > 0 ? ` Not available (their files cannot be loaded; starting one is refused): ${refusedTypeIds.join(", ")}.` : ""}`
11618
11371
  },
11619
11372
  model: {
11620
11373
  type: "string",
@@ -11696,6 +11449,8 @@ ${persona}` : persona || (readOnlyType !== void 0 ? READ_ONLY_PROMPTS.get(readOn
11696
11449
  }
11697
11450
  });
11698
11451
  const launchWorkflowAgent = /* @__PURE__ */ __name(async (launch) => {
11452
+ const refusedLaunch = launch.agentType !== void 0 && !fileAgents.has(launch.agentType) ? refusedAgents.get(launch.agentType) : void 0;
11453
+ if (refusedLaunch) throw new Error(refusedLaunch.line);
11699
11454
  if (launch.agentType !== void 0 && !agentTypeIds.includes(launch.agentType)) {
11700
11455
  throw new Error(
11701
11456
  `Unknown agent type "${launch.agentType}". Available: ${agentTypeIds.join(", ")}.`
@@ -12178,7 +11933,8 @@ ${step}`;
12178
11933
  model: savedModel,
12179
11934
  ...kept.profile.effort ? { effort: kept.profile.effort } : {}
12180
11935
  } : {},
12181
- ...Object.keys(context.env ?? {}).length > 0 ? { env: context.env } : {},
11936
+ // The same object, not a copy: a variable a hook sets later reaches a child that is still working.
11937
+ ...context.env !== void 0 ? { env: context.env } : {},
12182
11938
  ...context.toolResultGuardrails ? { toolResultGuardrails: context.toolResultGuardrails } : {}
12183
11939
  },
12184
11940
  ...fileAgents.get(kept.profile.agent ?? kept.agentId)?.permissionMode ? { declaredMode: fileAgents.get(kept.profile.agent ?? kept.agentId)?.permissionMode } : {},
@@ -12223,8 +11979,8 @@ ${step}`;
12223
11979
  concurrencySafe: false,
12224
11980
  async execute(input2, context) {
12225
11981
  context.abortSignal.throwIfAborted();
12226
- const { task_id, message: message2 } = input2;
12227
- if (!message2.trim())
11982
+ const { task_id, message } = input2;
11983
+ if (!message.trim())
12228
11984
  return {
12229
11985
  success: false,
12230
11986
  output: "",
@@ -12255,7 +12011,7 @@ ${step}`;
12255
12011
  if (found.kind === "settled") {
12256
12012
  const label = found.owned.seed.agentId;
12257
12013
  try {
12258
- await messageChild(found.viewId, message2, context.turnId, context.abortSignal, "parent");
12014
+ await messageChild(found.viewId, message, context.turnId, context.abortSignal, "parent");
12259
12015
  } catch (error) {
12260
12016
  return {
12261
12017
  success: false,
@@ -12280,7 +12036,7 @@ ${step}`;
12280
12036
  error: `Task ${taskId} has finished and cannot be resumed from here.`
12281
12037
  };
12282
12038
  try {
12283
- await messageChild(shown.viewId, message2, context.turnId, context.abortSignal, "parent");
12039
+ await messageChild(shown.viewId, message, context.turnId, context.abortSignal, "parent");
12284
12040
  } catch (error) {
12285
12041
  return {
12286
12042
  success: false,
@@ -12295,8 +12051,8 @@ ${step}`;
12295
12051
  };
12296
12052
  }
12297
12053
  context.abortSignal.throwIfAborted();
12298
- await gateway.continueTask(taskId, message2);
12299
- activity.recordMessage(String(taskId), message2, "to-child");
12054
+ await gateway.continueTask(taskId, message);
12055
+ activity.recordMessage(String(taskId), message, "to-child");
12300
12056
  return {
12301
12057
  success: true,
12302
12058
  output: `Message queued for delivery to task ${taskId} at its next tool round. If it finishes first, it is resumed with the message and notifies again, so wait for that notification before resending.`,
@@ -12387,14 +12143,14 @@ ${step}`;
12387
12143
  concurrencySafe: true,
12388
12144
  async execute(input2, context) {
12389
12145
  context.abortSignal.throwIfAborted();
12390
- const { to, message: message2 } = input2;
12146
+ const { to, message } = input2;
12391
12147
  if (to !== "main")
12392
12148
  return {
12393
12149
  success: false,
12394
12150
  output: "",
12395
12151
  error: `No agent named '${to}' is currently addressable. Only "main" can be messaged from here.`
12396
12152
  };
12397
- if (!message2.trim())
12153
+ if (!message.trim())
12398
12154
  return { success: false, output: "", error: "Message must not be blank." };
12399
12155
  const shown = activity.getSnapshot().find((entry) => entry.sessionId === String(context.sessionId));
12400
12156
  const owned = shown ? conversations.get(shown.viewId) : void 0;
@@ -12413,7 +12169,7 @@ ${step}`;
12413
12169
  agentId: shown.agentId,
12414
12170
  description: shown.description,
12415
12171
  ...shown.taskId ? { taskId: shown.taskId } : {},
12416
- text: message2
12172
+ text: message
12417
12173
  });
12418
12174
  } catch {
12419
12175
  }
@@ -12502,9 +12258,9 @@ ${step}`;
12502
12258
  };
12503
12259
  }
12504
12260
  });
12505
- const messageChild = /* @__PURE__ */ __name(async (viewId, message2, turnId, signal, source = "operator") => {
12261
+ const messageChild = /* @__PURE__ */ __name(async (viewId, message, turnId, signal, source = "operator") => {
12506
12262
  if (closed) throw new Error("Sub-agent runtime is closed.");
12507
- if (!message2.trim() || message2.length > 16e3)
12263
+ if (!message.trim() || message.length > 16e3)
12508
12264
  throw new Error("A child message must contain 1\u201316000 characters.");
12509
12265
  const owned = conversations.get(viewId);
12510
12266
  const shown = activity.getSnapshot().find((value) => value.viewId === viewId);
@@ -12521,8 +12277,8 @@ ${step}`;
12521
12277
  owned.busy = true;
12522
12278
  let settleAdmission = /* @__PURE__ */ __name(() => {
12523
12279
  }, "settleAdmission");
12524
- owned.admitting = new Promise((resolve15) => {
12525
- settleAdmission = resolve15;
12280
+ owned.admitting = new Promise((resolve16) => {
12281
+ settleAdmission = resolve16;
12526
12282
  });
12527
12283
  const id = randomUUID4();
12528
12284
  let journal;
@@ -12540,7 +12296,7 @@ ${step}`;
12540
12296
  parentTurnId: turnId,
12541
12297
  taskId: owned.publicTaskId,
12542
12298
  viewId,
12543
- message: message2,
12299
+ message,
12544
12300
  at: (/* @__PURE__ */ new Date()).toISOString()
12545
12301
  })}
12546
12302
  `,
@@ -12557,14 +12313,14 @@ ${step}`;
12557
12313
  sessionId: parent.sessionId
12558
12314
  });
12559
12315
  await mkdir4(directory, { recursive: true, mode: 448 });
12560
- journal = join12(directory, "child-operator-messages.jsonl");
12316
+ journal = join11(directory, "child-operator-messages.jsonl");
12561
12317
  }
12562
12318
  await audit("submitted");
12563
12319
  signal.throwIfAborted();
12564
12320
  const current = owned.gateway.getTask(owned.task.taskId) ?? owned.task;
12565
12321
  let task;
12566
12322
  if (!isTerminalAgentTaskState(current.state)) {
12567
- await owned.gateway.continueTask(current.taskId, message2);
12323
+ await owned.gateway.continueTask(current.taskId, message);
12568
12324
  task = current;
12569
12325
  } else {
12570
12326
  if (owned.workspace !== "shared")
@@ -12585,7 +12341,7 @@ ${step}`;
12585
12341
  task = await gateway.createTask({
12586
12342
  agentId: owned.agentId,
12587
12343
  resumeSessionId: sessionId,
12588
- prompt: message2,
12344
+ prompt: message,
12589
12345
  workingDirectory: opts.cwd,
12590
12346
  workspace: { mode: "shared" },
12591
12347
  configOverrides: {
@@ -12627,7 +12383,7 @@ ${step}`;
12627
12383
  admitted = true;
12628
12384
  activity.recordMessage(
12629
12385
  String(task.taskId),
12630
- message2,
12386
+ message,
12631
12387
  source === "operator" ? "operator-to-child" : "to-child",
12632
12388
  kind === "started" ? "started" : "queued"
12633
12389
  );
@@ -12647,7 +12403,7 @@ ${step}`;
12647
12403
  id,
12648
12404
  viewId,
12649
12405
  taskId: owned.publicTaskId,
12650
- message: message2,
12406
+ message,
12651
12407
  kind
12652
12408
  }),
12653
12409
  ...auditWarning ? { auditWarning } : {}
@@ -12891,7 +12647,7 @@ function completedAgentResult(completed, shownTaskId = completed.taskId) {
12891
12647
  let resultText = typeof value === "string" ? value : value === void 0 ? "" : JSON.stringify(value);
12892
12648
  if (!resultText && turn?.stopReason && turn.stopReason !== "end_turn") {
12893
12649
  const partial = [...turn.messages].reverse().find(
12894
- (message2) => message2.role === "assistant" && typeof message2.content === "string" && message2.content.trim().length > 0
12650
+ (message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim().length > 0
12895
12651
  )?.content;
12896
12652
  if (typeof partial === "string") resultText = partial;
12897
12653
  }
@@ -12945,13 +12701,28 @@ function cappedTurns(limit, fileCap) {
12945
12701
  }
12946
12702
  __name(cappedTurns, "cappedTurns");
12947
12703
  function buildDefinition(id, description, systemPrompt, opts, tools = opts.buildTools, model = opts.model, selection, inheritedPrompt, file) {
12948
- const agent2 = new NamzuCliAgent({
12704
+ const metadata = {
12949
12705
  id,
12950
12706
  name: id,
12951
12707
  version: "1.0.0",
12952
12708
  category: "general",
12953
12709
  description
12954
- });
12710
+ };
12711
+ const carried = file?.hooksSource !== void 0 ? {
12712
+ name: file.name ?? id,
12713
+ path: file.path ?? id,
12714
+ source: file.source ?? "project",
12715
+ hooksSource: file.hooksSource
12716
+ } : void 0;
12717
+ const runScope = carried ? (sessionId) => {
12718
+ if (!opts.agentHooks) {
12719
+ throw new Error(
12720
+ `Agent "${carried.name}" is not started: ${carried.path} carries hooks and this host does not attach them, so it would run without the guard its file wrote.`
12721
+ );
12722
+ }
12723
+ return opts.agentHooks.attachRun(carried, sessionId);
12724
+ } : void 0;
12725
+ const agent2 = new NamzuCliAgent(metadata, void 0, runScope);
12955
12726
  const base = inheritedPrompt !== void 0 || systemPrompt === SUBAGENT_PROMPT ? systemPrompt : `${systemPrompt}
12956
12727
 
12957
12728
  ${SUBAGENT_PROMPT}`;
@@ -12968,6 +12739,10 @@ ${SUBAGENT_PROMPT}`;
12968
12739
  // NamzuCliAgent is Agent<NamzuCliAgentConfig,…>; the registry stores the
12969
12740
  // erased Agent<BaseAgentConfig,…>. configBuilder supplies the richer config.
12970
12741
  typedAgent: agent2,
12742
+ // One shell per run, each with the same scope: `forTurn` would rebuild it without.
12743
+ ...runScope ? {
12744
+ createAgent: /* @__PURE__ */ __name(() => new NamzuCliAgent(metadata, void 0, runScope), "createAgent")
12745
+ } : {},
12971
12746
  configBuilder: /* @__PURE__ */ __name(async (options) => {
12972
12747
  const limits = resolveTurnGuards(
12973
12748
  opts,
@@ -13029,13 +12804,13 @@ ${SUBAGENT_PROMPT}`;
13029
12804
  __name(buildDefinition, "buildDefinition");
13030
12805
 
13031
12806
  // src/integrations/workflows/history.ts
13032
- import { readFile as readFile5, readdir as readdir2 } from "node:fs/promises";
13033
- import { join as join13 } from "node:path";
12807
+ import { readFile as readFile6, readdir as readdir2 } from "node:fs/promises";
12808
+ import { join as join12 } from "node:path";
13034
12809
  var RUN_ID = /^w[0-9a-z]{8}$/;
13035
12810
  async function readWorkflowJournal(file) {
13036
12811
  let text2;
13037
12812
  try {
13038
- text2 = await readFile5(file, "utf8");
12813
+ text2 = await readFile6(file, "utf8");
13039
12814
  } catch (error) {
13040
12815
  if (error.code === "ENOENT") return [];
13041
12816
  throw error;
@@ -13056,7 +12831,7 @@ async function readWorkflowJournal(file) {
13056
12831
  __name(readWorkflowJournal, "readWorkflowJournal");
13057
12832
  async function readWorkflowRun(runsDirectory, runId) {
13058
12833
  if (!RUN_ID.test(runId)) return void 0;
13059
- const records = await readWorkflowJournal(join13(runsDirectory, runId, "workflow", "journal.jsonl"));
12834
+ const records = await readWorkflowJournal(join12(runsDirectory, runId, "workflow", "journal.jsonl"));
13060
12835
  return viewFromJournal(records);
13061
12836
  }
13062
12837
  __name(readWorkflowRun, "readWorkflowRun");
@@ -13078,8 +12853,8 @@ __name(listWorkflowRuns, "listWorkflowRuns");
13078
12853
  // src/integrations/workflows/host.ts
13079
12854
  import { randomBytes as randomBytes3 } from "node:crypto";
13080
12855
  import { existsSync as existsSync3 } from "node:fs";
13081
- import { readFile as readFile6 } from "node:fs/promises";
13082
- import { join as join14 } from "node:path";
12856
+ import { readFile as readFile7 } from "node:fs/promises";
12857
+ import { join as join13 } from "node:path";
13083
12858
 
13084
12859
  // src/integrations/workflows/offering.ts
13085
12860
  var WORKFLOW_TOOL_NAME = "workflow";
@@ -13236,11 +13011,11 @@ var WorkflowRunRegistry = class {
13236
13011
  whenIdle(signal) {
13237
13012
  const going = /* @__PURE__ */ __name(() => [...this.runs.values()].some((run2) => !run2.finalized), "going");
13238
13013
  if (!going() || signal?.aborted) return Promise.resolve();
13239
- return new Promise((resolve15) => {
13014
+ return new Promise((resolve16) => {
13240
13015
  const done = /* @__PURE__ */ __name(() => {
13241
13016
  off();
13242
13017
  signal?.removeEventListener("abort", done);
13243
- resolve15();
13018
+ resolve16();
13244
13019
  }, "done");
13245
13020
  const off = this.subscribe(() => {
13246
13021
  if (!going()) done();
@@ -13530,7 +13305,7 @@ function createWorkflowHost(options) {
13530
13305
  }
13531
13306
  let checked;
13532
13307
  try {
13533
- checked = await new FileWorkflowJournal(join14(runs, runId, "workflow"), {
13308
+ checked = await new FileWorkflowJournal(join13(runs, runId, "workflow"), {
13534
13309
  runId,
13535
13310
  ...key !== void 0 ? { key } : {}
13536
13311
  }).read();
@@ -13550,7 +13325,7 @@ function createWorkflowHost(options) {
13550
13325
  }
13551
13326
  resumeState = loadWorkflowResume(checked);
13552
13327
  if (!resumeState.resumable) {
13553
- const mismatch = key !== void 0 && await readFile6(join14(runs, runId, "workflow", "journal.jsonl"), "utf8").then(
13328
+ const mismatch = key !== void 0 && await readFile7(join13(runs, runId, "workflow", "journal.jsonl"), "utf8").then(
13554
13329
  (text2) => journalKeyMismatch(text2, runId, key),
13555
13330
  () => false
13556
13331
  );
@@ -13570,12 +13345,12 @@ function createWorkflowHost(options) {
13570
13345
  if (state === "ended") registry.discard(runId);
13571
13346
  } else {
13572
13347
  runId = createWorkflowRunId(
13573
- (id) => registry.get(id) !== void 0 || runs !== void 0 && existsSync3(join14(runs, id))
13348
+ (id) => registry.get(id) !== void 0 || runs !== void 0 && existsSync3(join13(runs, id))
13574
13349
  );
13575
13350
  }
13576
13351
  const turn = options.openRunTurn(context.turnId, runId);
13577
13352
  const limits = options.limitsFor?.(context.turnId);
13578
- const journalDirectory = runs === void 0 ? void 0 : join14(runs, runId, "workflow");
13353
+ const journalDirectory = runs === void 0 ? void 0 : join13(runs, runId, "workflow");
13579
13354
  const journal = journalDirectory === void 0 ? void 0 : new FileWorkflowJournal(journalDirectory, {
13580
13355
  runId,
13581
13356
  ...key !== void 0 ? { key } : {}
@@ -13596,8 +13371,8 @@ function createWorkflowHost(options) {
13596
13371
  let launching = true;
13597
13372
  let settleLaunch = /* @__PURE__ */ __name(() => {
13598
13373
  }, "settleLaunch");
13599
- const launch = new Promise((resolve15) => {
13600
- settleLaunch = resolve15;
13374
+ const launch = new Promise((resolve16) => {
13375
+ settleLaunch = resolve16;
13601
13376
  });
13602
13377
  const detach = /* @__PURE__ */ __name(() => {
13603
13378
  if (!launching) return;
@@ -13616,7 +13391,7 @@ function createWorkflowHost(options) {
13616
13391
  ...journal ? { journal } : {},
13617
13392
  ...resumeState ? { resume: resumeState } : {},
13618
13393
  ...editable !== void 0 ? { scriptPath: editable } : {},
13619
- ...journalDirectory !== void 0 ? { journalPath: join14(journalDirectory, "journal.jsonl") } : {},
13394
+ ...journalDirectory !== void 0 ? { journalPath: join13(journalDirectory, "journal.jsonl") } : {},
13620
13395
  spawn: /* @__PURE__ */ __name(async (request, signal, viewed) => {
13621
13396
  const detail = phaseDetail(request.phaseTitle);
13622
13397
  const outcome2 = await options.subagents.launchWorkflowAgent({
@@ -13700,8 +13475,8 @@ __name(createWorkflowHost, "createWorkflowHost");
13700
13475
 
13701
13476
  // src/integrations/workflows/orphans.ts
13702
13477
  import { existsSync as existsSync4 } from "node:fs";
13703
- import { readFile as readFile7, readdir as readdir3, writeFile as writeFile3 } from "node:fs/promises";
13704
- import { join as join15 } from "node:path";
13478
+ import { readFile as readFile8, readdir as readdir3, writeFile as writeFile3 } from "node:fs/promises";
13479
+ import { join as join14 } from "node:path";
13705
13480
  var NOTICE_FILE = "orphan-notice.json";
13706
13481
  var MAX_ORPHAN_NOTICES = 20;
13707
13482
  var NO_USAGE = {
@@ -13720,12 +13495,12 @@ function quotedName(name) {
13720
13495
  }
13721
13496
  __name(quotedName, "quotedName");
13722
13497
  function noticePath(runsDirectory, runId) {
13723
- return join15(runsDirectory, runId, "workflow", NOTICE_FILE);
13498
+ return join14(runsDirectory, runId, "workflow", NOTICE_FILE);
13724
13499
  }
13725
13500
  __name(noticePath, "noticePath");
13726
13501
  async function readStored(runsDirectory, runId) {
13727
13502
  try {
13728
- const parsed = JSON.parse(await readFile7(noticePath(runsDirectory, runId), "utf8"));
13503
+ const parsed = JSON.parse(await readFile8(noticePath(runsDirectory, runId), "utf8"));
13729
13504
  if (typeof parsed !== "object" || parsed === null) return void 0;
13730
13505
  const stored = parsed;
13731
13506
  if (typeof stored.text === "string" && typeof stored.line === "string" && typeof stored.name === "string" && typeof stored.pass === "number" && typeof stored.delivered === "boolean") {
@@ -13752,7 +13527,7 @@ async function recoverUnfinishedWorkflows(options) {
13752
13527
  for (const runId of entries.filter((name) => RUN_ID_PATTERN.test(name)).sort()) {
13753
13528
  if (options.liveRunIds.has(runId)) continue;
13754
13529
  const stored = await readStored(options.runsDirectory, runId);
13755
- const dir = join15(options.runsDirectory, runId, "workflow");
13530
+ const dir = join14(options.runsDirectory, runId, "workflow");
13756
13531
  const journal = new FileWorkflowJournal(dir, {
13757
13532
  runId,
13758
13533
  ...options.key !== void 0 ? { key: options.key } : {}
@@ -13861,7 +13636,7 @@ __name(recoverUnfinishedWorkflows, "recoverUnfinishedWorkflows");
13861
13636
  async function keyMismatchOf(dir, runId, key) {
13862
13637
  if (key === void 0) return false;
13863
13638
  try {
13864
- return journalKeyMismatch(await readFile7(join15(dir, "journal.jsonl"), "utf8"), runId, key);
13639
+ return journalKeyMismatch(await readFile8(join14(dir, "journal.jsonl"), "utf8"), runId, key);
13865
13640
  } catch {
13866
13641
  return false;
13867
13642
  }
@@ -13896,7 +13671,7 @@ __name(markOrphanNoticesDelivered, "markOrphanNoticesDelivered");
13896
13671
 
13897
13672
  // src/memory/anchors.ts
13898
13673
  import { createHash as createHash4 } from "node:crypto";
13899
- import { readFile as readFile8, realpath as realpath4, stat as stat4 } from "node:fs/promises";
13674
+ import { readFile as readFile9, realpath as realpath4, stat as stat4 } from "node:fs/promises";
13900
13675
  import { basename as basename3, isAbsolute as isAbsolute9, relative as relative8, resolve as resolve12, sep as sep6 } from "node:path";
13901
13676
  var ANCHOR_MAX = 5;
13902
13677
  var ANCHOR_HASH_MAX_BYTES = 1048576;
@@ -13908,7 +13683,7 @@ var nodeAnchorFs = {
13908
13683
  return info.isFile() ? { size: info.size, mtimeMs: Math.trunc(info.mtimeMs) } : void 0;
13909
13684
  }, "stat"),
13910
13685
  realpath: /* @__PURE__ */ __name((path) => realpath4(path), "realpath"),
13911
- readFile: /* @__PURE__ */ __name((path) => readFile8(path), "readFile")
13686
+ readFile: /* @__PURE__ */ __name((path) => readFile9(path), "readFile")
13912
13687
  };
13913
13688
  var digest2 = /* @__PURE__ */ __name((bytes) => createHash4("sha256").update(bytes).digest("hex"), "digest");
13914
13689
  function inside(root, path) {
@@ -14075,7 +13850,7 @@ import { dirname as dirname4 } from "node:path";
14075
13850
  import { createHash as createHash5 } from "node:crypto";
14076
13851
 
14077
13852
  // src/memory/manage.ts
14078
- import { join as join16 } from "node:path";
13853
+ import { join as join15 } from "node:path";
14079
13854
 
14080
13855
  // src/memory/presentation.ts
14081
13856
  var MEMORY_PREVIEW_MAX_CHARS = 2e3;
@@ -14340,7 +14115,7 @@ async function loadManagedMemories(store, directory, lookups = {}) {
14340
14115
  createdAt: record.entry.createdAt,
14341
14116
  updatedAt: record.entry.updatedAt,
14342
14117
  revision: record.revision,
14343
- path: record.entry.name ? join16(directory, `${record.entry.name}.md`) : directory,
14118
+ path: record.entry.name ? join15(directory, `${record.entry.name}.md`) : directory,
14344
14119
  ...replaced ? { replaces: replaced } : {},
14345
14120
  ...state !== "active" ? { state } : {},
14346
14121
  ...retiredReason !== void 0 ? { retiredReason } : {},
@@ -15029,11 +14804,11 @@ var MemoryCurator = class {
15029
14804
  else context.signal?.addEventListener("abort", onAbort, { once: true });
15030
14805
  const deadlineMs = this.#deps.deadlineMs ?? CURATE_DEADLINE_MS;
15031
14806
  let timer;
15032
- const deadline = new Promise((resolve15) => {
14807
+ const deadline = new Promise((resolve16) => {
15033
14808
  timer = setTimeout(() => {
15034
14809
  timedOut = true;
15035
14810
  controller.abort(new Error(`Memory curation exceeded ${deadlineMs}ms.`));
15036
- resolve15("deadline");
14811
+ resolve16("deadline");
15037
14812
  }, deadlineMs);
15038
14813
  });
15039
14814
  let reply;
@@ -15499,14 +15274,14 @@ import {
15499
15274
  appendFile as appendFile4,
15500
15275
  mkdir as mkdir6,
15501
15276
  open as open3,
15502
- readFile as readFile9,
15277
+ readFile as readFile10,
15503
15278
  readdir as readdir4,
15504
15279
  rename as rename4,
15505
15280
  stat as stat5,
15506
15281
  unlink as unlink3,
15507
15282
  writeFile as writeFile4
15508
15283
  } from "node:fs/promises";
15509
- import { basename as basename4, dirname as dirname5, join as join17 } from "node:path";
15284
+ import { basename as basename4, dirname as dirname5, join as join16 } from "node:path";
15510
15285
  var INBOX_BATCH_SIZE = 8;
15511
15286
  var INBOX_MAX_BATCHES = 3;
15512
15287
  var INBOX_CLAIM_STALE_MS = 12e4;
@@ -15540,7 +15315,7 @@ var serialize = /* @__PURE__ */ __name((entries) => entries.map((entry) => `${JS
15540
15315
  `).join(""), "serialize");
15541
15316
  async function readIfPresent(path) {
15542
15317
  try {
15543
- return await readFile9(path, "utf8");
15318
+ return await readFile10(path, "utf8");
15544
15319
  } catch (error) {
15545
15320
  if (error.code === "ENOENT") return void 0;
15546
15321
  throw error;
@@ -15601,7 +15376,7 @@ var MemoryInbox = class {
15601
15376
  return dedupe(texts.flatMap((text2) => text2 === void 0 ? [] : parseLines(text2)));
15602
15377
  }
15603
15378
  #newClaimPath(now) {
15604
- return join17(
15379
+ return join16(
15605
15380
  dirname5(this.#file),
15606
15381
  `${basename4(this.#file, ".jsonl")}.claim-${now}-${this.#newId()}.jsonl`
15607
15382
  );
@@ -15620,7 +15395,7 @@ var MemoryInbox = class {
15620
15395
  if (!name.startsWith(prefix)) continue;
15621
15396
  const match = CLAIM_PATTERN.exec(name);
15622
15397
  if (!match) continue;
15623
- out.push({ path: join17(dirname5(this.#file), name), at: Number(match[1]) });
15398
+ out.push({ path: join16(dirname5(this.#file), name), at: Number(match[1]) });
15624
15399
  }
15625
15400
  return out.sort((a, b) => a.at - b.at);
15626
15401
  }
@@ -15902,7 +15677,7 @@ var MemoryLifecycle = class {
15902
15677
 
15903
15678
  // src/memory/screen-archive.ts
15904
15679
  import { access as access2, writeFile as writeFile5 } from "node:fs/promises";
15905
- import { join as join18 } from "node:path";
15680
+ import { join as join17 } from "node:path";
15906
15681
  var SCREEN_MARKER_FILE = ".derived-screen-v1";
15907
15682
  var HEADINGS = {
15908
15683
  "What the user requires": "userRequirements",
@@ -15961,7 +15736,7 @@ ${body2}`) !== void 0) return true;
15961
15736
  __name(wouldNotBeWritten, "wouldNotBeWritten");
15962
15737
  async function archiveUnscreenedRecords(options) {
15963
15738
  const { store, directory, log } = options;
15964
- const marker = join18(directory, SCREEN_MARKER_FILE);
15739
+ const marker = join17(directory, SCREEN_MARKER_FILE);
15965
15740
  try {
15966
15741
  if (await access2(marker).then(
15967
15742
  () => true,
@@ -16099,11 +15874,11 @@ function createMemorySelector(deps) {
16099
15874
  if (input.signal.aborted) onAbort();
16100
15875
  else input.signal.addEventListener("abort", onAbort, { once: true });
16101
15876
  let timer;
16102
- const deadline = new Promise((resolve15) => {
15877
+ const deadline = new Promise((resolve16) => {
16103
15878
  timer = setTimeout(() => {
16104
15879
  timedOut = true;
16105
15880
  controller.abort(new Error(`Memory selection exceeded ${deadlineMs}ms.`));
16106
- resolve15("deadline");
15881
+ resolve16("deadline");
16107
15882
  }, deadlineMs);
16108
15883
  });
16109
15884
  try {
@@ -16143,11 +15918,11 @@ __name(memorySelectionOptions, "memorySelectionOptions");
16143
15918
 
16144
15919
  // src/memory/usage.ts
16145
15920
  import { randomUUID as randomUUID6 } from "node:crypto";
16146
- import { mkdir as mkdir7, readFile as readFile10, rename as rename5, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
15921
+ import { mkdir as mkdir7, readFile as readFile11, rename as rename5, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
16147
15922
  import { dirname as dirname6 } from "node:path";
16148
15923
  var VERSION = 1;
16149
15924
  var nodeUsageFs = {
16150
- readFile: /* @__PURE__ */ __name((path) => readFile10(path, "utf8"), "readFile"),
15925
+ readFile: /* @__PURE__ */ __name((path) => readFile11(path, "utf8"), "readFile"),
16151
15926
  writeFile: /* @__PURE__ */ __name((path, data) => writeFile6(path, data, { mode: 384 }), "writeFile"),
16152
15927
  rename: rename5,
16153
15928
  mkdir: /* @__PURE__ */ __name(async (path) => {
@@ -16648,8 +16423,8 @@ function lower(text2) {
16648
16423
  }
16649
16424
  __name(lower, "lower");
16650
16425
  function commandName(value) {
16651
- const cut = Math.max(value.lastIndexOf("/"), value.lastIndexOf("\\"));
16652
- return lower(cut < 0 ? value : value.slice(cut + 1)).replace(CLI_EXTENSIONS, "");
16426
+ const cut2 = Math.max(value.lastIndexOf("/"), value.lastIndexOf("\\"));
16427
+ return lower(cut2 < 0 ? value : value.slice(cut2 + 1)).replace(CLI_EXTENSIONS, "");
16653
16428
  }
16654
16429
  __name(commandName, "commandName");
16655
16430
  function namesCli(value) {
@@ -17309,15 +17084,15 @@ ${text2.trim()}
17309
17084
  </system-reminder>`;
17310
17085
  }
17311
17086
  __name(frameReminder, "frameReminder");
17312
- function reminderKindOf(message2) {
17313
- if (!isReminderMessage(message2) || typeof message2.content !== "string") return void 0;
17314
- const kind = TAG.exec(message2.content)?.[1];
17087
+ function reminderKindOf(message) {
17088
+ if (!isReminderMessage(message) || typeof message.content !== "string") return void 0;
17089
+ const kind = TAG.exec(message.content)?.[1];
17315
17090
  return kind !== void 0 && KINDS.has(kind) ? kind : void 0;
17316
17091
  }
17317
17092
  __name(reminderKindOf, "reminderKindOf");
17318
- function isOperatorTurn(message2) {
17319
- if (message2.role !== "user") return false;
17320
- const source = message2.source;
17093
+ function isOperatorTurn(message) {
17094
+ if (message.role !== "user") return false;
17095
+ const source = message.source;
17321
17096
  return source === void 0 || source.type === "goal-round" || source.type === "runtime-context" && source.kind === "steering";
17322
17097
  }
17323
17098
  __name(isOperatorTurn, "isOperatorTurn");
@@ -17375,8 +17150,8 @@ function changedSnippet(before, after, maxChars = CHANGED_FILE_MAX_CHARS) {
17375
17150
  const marker = "\n... [more lines not shown; read the file for the rest] ...";
17376
17151
  if (marker.length >= limit) return "";
17377
17152
  const room = limit - marker.length;
17378
- const cut = text2.lastIndexOf("\n", room);
17379
- const kept = text2.slice(0, cut > 0 ? cut : room);
17153
+ const cut2 = text2.lastIndexOf("\n", room);
17154
+ const kept = text2.slice(0, cut2 > 0 ? cut2 : room);
17380
17155
  return `${kept}${marker}`;
17381
17156
  }
17382
17157
  __name(changedSnippet, "changedSnippet");
@@ -17435,9 +17210,9 @@ var FIRST = "These are facts about right now. Prefer them over any date or branc
17435
17210
  var CHANGED = "The date or the working environment changed since you were last told. This needs no announcement to the user; use it where it matters.";
17436
17211
  function lastTold(messages) {
17437
17212
  for (let i = messages.length - 1; i >= 0; i--) {
17438
- const message2 = messages[i];
17439
- if (reminderKindOf(message2) === "environment" && typeof message2.content === "string") {
17440
- return message2.content;
17213
+ const message = messages[i];
17214
+ if (reminderKindOf(message) === "environment" && typeof message.content === "string") {
17215
+ return message.content;
17441
17216
  }
17442
17217
  }
17443
17218
  return void 0;
@@ -17464,10 +17239,10 @@ var EXIT = "Hypermode is off: the `workflow` tool's standard opt-in rule applies
17464
17239
  function scan(messages) {
17465
17240
  let turns = 0;
17466
17241
  for (let i = messages.length - 1; i >= 0; i--) {
17467
- const message2 = messages[i];
17468
- const kind = reminderKindOf(message2);
17242
+ const message = messages[i];
17243
+ const kind = reminderKindOf(message);
17469
17244
  if (kind === "hypermode-on" || kind === "hypermode-exit") return { last: kind, turns };
17470
- if (isOperatorTurn(message2)) turns++;
17245
+ if (isOperatorTurn(message)) turns++;
17471
17246
  }
17472
17247
  return { last: void 0, turns };
17473
17248
  }
@@ -17509,11 +17284,11 @@ function instructionsDigest(text2) {
17509
17284
  __name(instructionsDigest, "instructionsDigest");
17510
17285
  function announced(messages) {
17511
17286
  const told = /* @__PURE__ */ new Map();
17512
- for (const message2 of messages) {
17513
- if (reminderKindOf(message2) !== "mcp-instructions" || typeof message2.content !== "string") {
17287
+ for (const message of messages) {
17288
+ if (reminderKindOf(message) !== "mcp-instructions" || typeof message.content !== "string") {
17514
17289
  continue;
17515
17290
  }
17516
- for (const line of message2.content.split("\n")) {
17291
+ for (const line of message.content.split("\n")) {
17517
17292
  const open5 = OPEN.exec(line);
17518
17293
  if (open5) told.set(JSON.parse(open5[1]), open5[2]);
17519
17294
  const gone = GONE.exec(line);
@@ -17558,9 +17333,9 @@ function digestOf2(text2) {
17558
17333
  __name(digestOf2, "digestOf");
17559
17334
  function announced2(messages) {
17560
17335
  const told = /* @__PURE__ */ new Map();
17561
- for (const message2 of messages) {
17562
- if (reminderKindOf(message2) !== "memory-index" || typeof message2.content !== "string") continue;
17563
- for (const line of message2.content.split("\n")) {
17336
+ for (const message of messages) {
17337
+ if (reminderKindOf(message) !== "memory-index" || typeof message.content !== "string") continue;
17338
+ for (const line of message.content.split("\n")) {
17564
17339
  const match = SECTION.exec(line);
17565
17340
  if (match?.[1] !== void 0 && match[2] !== void 0) told.set(match[1], match[2]);
17566
17341
  }
@@ -17681,8 +17456,8 @@ This identifies the selected route for this turn, not a change to your Namzu ide
17681
17456
  The available model metadata does not establish a knowledge cutoff. Do not invent one or infer one from the model name.`
17682
17457
  );
17683
17458
  for (let i = messages.length - 1; i >= 0; i--) {
17684
- const message2 = messages[i];
17685
- if (reminderKindOf(message2) === "model") return message2.content === text2 ? [] : [text2];
17459
+ const message = messages[i];
17460
+ if (reminderKindOf(message) === "model") return message.content === text2 ? [] : [text2];
17686
17461
  }
17687
17462
  return [text2];
17688
17463
  }
@@ -17698,8 +17473,8 @@ function scan2(messages) {
17698
17473
  let hasExited = false;
17699
17474
  let inStretch = true;
17700
17475
  for (let i = messages.length - 1; i >= 0; i--) {
17701
- const message2 = messages[i];
17702
- const kind = reminderKindOf(message2);
17476
+ const message = messages[i];
17477
+ const kind = reminderKindOf(message);
17703
17478
  if (kind === "plan-exit") {
17704
17479
  hasExited = true;
17705
17480
  if (!hasReminder) inStretch = false;
@@ -17710,7 +17485,7 @@ function scan2(messages) {
17710
17485
  if (kind === "plan-mode") sent++;
17711
17486
  continue;
17712
17487
  }
17713
- if (!hasReminder && isOperatorTurn(message2)) turns++;
17488
+ if (!hasReminder && isOperatorTurn(message)) turns++;
17714
17489
  }
17715
17490
  return { turnsSinceReminder: turns, hasReminder, sent, hasExited };
17716
17491
  }
@@ -17782,9 +17557,9 @@ function skillListingLine(skill) {
17782
17557
  __name(skillListingLine, "skillListingLine");
17783
17558
  function announced4(messages) {
17784
17559
  const told = /* @__PURE__ */ new Map();
17785
- for (const message2 of messages) {
17786
- if (reminderKindOf(message2) !== "skill-listing" || typeof message2.content !== "string") continue;
17787
- for (const line of message2.content.split("\n")) {
17560
+ for (const message of messages) {
17561
+ if (reminderKindOf(message) !== "skill-listing" || typeof message.content !== "string") continue;
17562
+ for (const line of message.content.split("\n")) {
17788
17563
  const withdrawn = WITHDRAWAL.exec(line)?.[1];
17789
17564
  if (withdrawn !== void 0) {
17790
17565
  told.delete(withdrawn);
@@ -17834,14 +17609,14 @@ function taskNudgeCounts(messages) {
17834
17609
  let sawTool = false;
17835
17610
  let sawNudge = false;
17836
17611
  for (let i = messages.length - 1; i >= 0 && !(sawTool && sawNudge); i--) {
17837
- const message2 = messages[i];
17838
- if (message2.role === "assistant") {
17839
- if (!sawTool && message2.toolCalls?.some((call) => TASK_TOOLS.has(call.function.name))) {
17612
+ const message = messages[i];
17613
+ if (message.role === "assistant") {
17614
+ if (!sawTool && message.toolCalls?.some((call) => TASK_TOOLS.has(call.function.name))) {
17840
17615
  sawTool = true;
17841
17616
  }
17842
17617
  if (!sawTool) sinceTaskTool++;
17843
17618
  if (!sawNudge) sinceNudge++;
17844
- } else if (!sawNudge && reminderKindOf(message2) === "task-nudge") {
17619
+ } else if (!sawNudge && reminderKindOf(message) === "task-nudge") {
17845
17620
  sawNudge = true;
17846
17621
  }
17847
17622
  }
@@ -17851,9 +17626,9 @@ __name(taskNudgeCounts, "taskNudgeCounts");
17851
17626
  function stepsThisRequest(messages) {
17852
17627
  let steps = 0;
17853
17628
  for (let i = messages.length - 1; i >= 0; i--) {
17854
- const message2 = messages[i];
17855
- if (isOperatorTurn(message2)) break;
17856
- if (message2.role === "assistant" && (message2.toolCalls?.length ?? 0) > 0) steps++;
17629
+ const message = messages[i];
17630
+ if (isOperatorTurn(message)) break;
17631
+ if (message.role === "assistant" && (message.toolCalls?.length ?? 0) > 0) steps++;
17857
17632
  }
17858
17633
  return steps;
17859
17634
  }
@@ -17942,10 +17717,354 @@ function createSkillDirectoryResolver(options) {
17942
17717
  }
17943
17718
  __name(createSkillDirectoryResolver, "createSkillDirectoryResolver");
17944
17719
 
17720
+ // src/skills/restore-skill-hooks.ts
17721
+ import { readFileSync as readFileSync2 } from "node:fs";
17722
+ import { isAbsolute as isAbsolute11, join as join18, relative as relative10, resolve as resolve13, sep as sep7 } from "node:path";
17723
+ var SKILL_FILE = "SKILL.md";
17724
+ function isInsideFolder(root, directory) {
17725
+ const inside2 = relative10(resolve13(root), resolve13(directory));
17726
+ return inside2 === "" || !inside2.startsWith(`..${sep7}`) && inside2 !== ".." && !isAbsolute11(inside2);
17727
+ }
17728
+ __name(isInsideFolder, "isInsideFolder");
17729
+ function readSkillNow(directory) {
17730
+ const path = join18(directory, SKILL_FILE);
17731
+ let raw;
17732
+ try {
17733
+ raw = readFileSync2(path, "utf8");
17734
+ } catch (error) {
17735
+ const code = error.code;
17736
+ return code === "ENOENT" || code === "ENOTDIR" ? { problem: `its file is gone (${path})` } : { problem: `its file could not be read (${path}): ${error.message}` };
17737
+ }
17738
+ try {
17739
+ return { hooksSource: parseSkillMarkdown(raw, path).hooksSource };
17740
+ } catch (error) {
17741
+ return { problem: `its file can no longer be read (${path}): ${error.message}` };
17742
+ }
17743
+ }
17744
+ __name(readSkillNow, "readSkillNow");
17745
+ function restoreSkillHooks(host, facts, readNow = readSkillNow) {
17746
+ const notes = [];
17747
+ for (const fact of facts) {
17748
+ const note = host.restore({
17749
+ name: fact.skill,
17750
+ dirPath: fact.directory,
17751
+ now: readNow(fact.directory)
17752
+ });
17753
+ if (note !== void 0) notes.push(note);
17754
+ }
17755
+ return notes;
17756
+ }
17757
+ __name(restoreSkillHooks, "restoreSkillHooks");
17758
+
17759
+ // src/skills/skill-hooks.ts
17760
+ import { createHash as createHash8 } from "node:crypto";
17761
+ function skillHookEnv(skillRoot) {
17762
+ return { NAMZU_SKILL_ROOT: skillRoot };
17763
+ }
17764
+ __name(skillHookEnv, "skillHookEnv");
17765
+ function withSkillRoot(entry, skillRoot) {
17766
+ if (entry.type === "http" || entry.type === "prompt") return entry;
17767
+ const put = /* @__PURE__ */ __name((text2) => text2.split("${NAMZU_SKILL_ROOT}").join(skillRoot), "put");
17768
+ return {
17769
+ ...entry,
17770
+ command: put(entry.command),
17771
+ ...entry.args !== void 0 ? { args: entry.args.map(put) } : {}
17772
+ };
17773
+ }
17774
+ __name(withSkillRoot, "withSkillRoot");
17775
+ var MAX_NOTICE_CHARS = 600;
17776
+ function describeRuns(entry) {
17777
+ if (entry.type === "http") return `POST ${entry.url}`;
17778
+ if (entry.type === "prompt") return `ask: ${entry.prompt.replace(/\s+/g, " ").slice(0, 60)}`;
17779
+ return [entry.command, ...entry.args ?? []].join(" ");
17780
+ }
17781
+ __name(describeRuns, "describeRuns");
17782
+ function digestOf3(text2) {
17783
+ return createHash8("sha256").update(text2).digest("hex").slice(0, 16);
17784
+ }
17785
+ __name(digestOf3, "digestOf");
17786
+ function cut(text2) {
17787
+ return text2.length > MAX_NOTICE_CHARS ? `${text2.slice(0, MAX_NOTICE_CHARS)}...` : text2;
17788
+ }
17789
+ __name(cut, "cut");
17790
+ function firstSentence(problems, severity) {
17791
+ const found = problems.filter((problem) => problem.severity === severity);
17792
+ return found.map((problem) => `${problem.event} ${problem.message}`).join(" ");
17793
+ }
17794
+ __name(firstSentence, "firstSentence");
17795
+ function createSkillHooksHost(options) {
17796
+ const live = /* @__PURE__ */ new Set();
17797
+ const listeners = /* @__PURE__ */ new Set();
17798
+ const told = /* @__PURE__ */ new Set();
17799
+ const tell = /* @__PURE__ */ __name((line) => {
17800
+ if (told.has(line)) return;
17801
+ told.add(line);
17802
+ for (const listener of listeners) listener(line);
17803
+ }, "tell");
17804
+ const inert2 = { remove: /* @__PURE__ */ __name(() => void 0, "remove") };
17805
+ const prepare = /* @__PURE__ */ __name((skill, how, resumed = false) => {
17806
+ const name = skill.name;
17807
+ if (options.hooksSwitch() !== void 0) {
17808
+ return { withholdGrants: false, attach: /* @__PURE__ */ __name(() => inert2, "attach") };
17809
+ }
17810
+ const refuse = /* @__PURE__ */ __name((why) => {
17811
+ const line = `Skill ${name}: ${why} None of its hooks are attached and its allowed-tools are not pre-approved.`;
17812
+ tell(cut(line));
17813
+ return {
17814
+ notice: cut(line),
17815
+ withholdGrants: true,
17816
+ ...how.forked ? {} : { resumable: true },
17817
+ attach: /* @__PURE__ */ __name(() => inert2, "attach")
17818
+ };
17819
+ }, "refuse");
17820
+ const inProject = options.isProjectSkill(name) || resumed && skill.dirPath !== void 0 && options.isInProject?.(skill.dirPath) === true;
17821
+ if (inProject && !options.projectTrusted()) {
17822
+ return refuse("it is in a folder that is not trusted.");
17823
+ }
17824
+ const readAll = withoutSessionStart(readSkillHooks(skill.hooksSource, `skill ${name}`));
17825
+ const read2 = how.forked ? withoutConversationEvents(readAll) : readAll;
17826
+ if (read2.guardLost && read2.count === 0) {
17827
+ return refuse(firstSentence(read2.problems, "problem"));
17828
+ }
17829
+ if (read2.count === 0 && read2.problems.length === 0) {
17830
+ return { withholdGrants: false, attach: /* @__PURE__ */ __name(() => inert2, "attach") };
17831
+ }
17832
+ const manager = options.manager();
17833
+ const base = options.hookOptions();
17834
+ if (!manager || !base) {
17835
+ return refuse("this session has no hook runtime.");
17836
+ }
17837
+ const root = skill.dirPath ?? "";
17838
+ const digest3 = digestOf3(skill.hooksSource);
17839
+ const events = SHELL_HOOK_EVENTS.filter((event) => (read2.hooks[event]?.length ?? 0) > 0);
17840
+ const setAside = firstSentence(read2.problems, "note");
17841
+ const unreadable = read2.guardLost ? firstSentence(read2.problems, "problem") : "";
17842
+ if (setAside) tell(cut(`Skill ${name}: ${setAside}`));
17843
+ const partial = unreadable ? ` Not loaded: ${unreadable} Its allowed-tools are not pre-approved.` : "";
17844
+ if (unreadable) tell(cut(`Skill ${name}:${partial}`));
17845
+ const sameMessage = !how.forked && (events.includes("pre_tool_use") || events.includes("permission_request")) ? " Calls written in the same message as this skill were checked before these hooks attached; make the calls they should guard in a later message." : "";
17846
+ const notice2 = cut(
17847
+ read2.count === 0 ? `Skill ${name}: no hook of its could be loaded. ${setAside}` : how.forked ? `Skill ${name}: its hooks (${events.join(", ")}) apply to the delegated agent's run only.${setAside ? ` Set aside: ${setAside}` : ""}${partial}` : `Skill ${name}: its hooks (${events.join(", ")}) were attached to this conversation when it was loaded. They stay until the conversation is cleared, and are attached again if it is continued later while this skill's file still loads and its folder is trusted; a note tells you when they are not.${setAside ? ` Set aside: ${setAside}` : ""}${partial}`
17848
+ ) + (read2.count === 0 ? "" : sameMessage);
17849
+ return {
17850
+ notice: notice2,
17851
+ withholdGrants: read2.guardLost,
17852
+ ...how.forked || read2.count === 0 ? {} : { resumable: true },
17853
+ attach: /* @__PURE__ */ __name(() => {
17854
+ if (read2.count === 0) return inert2;
17855
+ if (!how.forked) {
17856
+ for (const found of live) {
17857
+ if (found.skill !== name || found.scope !== "conversation") continue;
17858
+ if (found.digest === digest3) return inert2;
17859
+ found.attachment.remove();
17860
+ live.delete(found);
17861
+ }
17862
+ }
17863
+ const scoped = how.forked ? childScope(how.sessionId, how.prompt) : void 0;
17864
+ const rows = [];
17865
+ const defs = [];
17866
+ const own = {};
17867
+ for (const event of SHELL_HOOK_EVENTS) {
17868
+ for (const configured of read2.hooks[event] ?? []) {
17869
+ const cooked = {
17870
+ ...withSkillRoot(configured, root),
17871
+ source: `skill ${name}`
17872
+ };
17873
+ const once = cooked.once === true;
17874
+ const { once: _once, ...withoutOnce } = cooked;
17875
+ let runs = 0;
17876
+ const created = createShellHook(event, withoutOnce, {
17877
+ ...base,
17878
+ extraEnv: { ...base.extraEnv, ...skillHookEnv(root) },
17879
+ skillRoot: root,
17880
+ onRun: /* @__PURE__ */ __name((info) => {
17881
+ runs += 1;
17882
+ base.onRun?.(info);
17883
+ }, "onRun")
17884
+ });
17885
+ const index = defs.length;
17886
+ rows.push({
17887
+ skill: name,
17888
+ event,
17889
+ runs: describeRuns(cooked),
17890
+ ...cooked.matcher !== void 0 ? { matcher: cooked.matcher } : {},
17891
+ once,
17892
+ scope: how.forked ? "agent" : "conversation",
17893
+ gone: false
17894
+ });
17895
+ defs.push({
17896
+ ...created,
17897
+ handler: /* @__PURE__ */ __name(async (context) => {
17898
+ if (scoped && !scoped.covers(context)) return { action: "continue" };
17899
+ const before = runs;
17900
+ const result = await created.handler(context);
17901
+ if (once && runs > before && result.action !== "error") {
17902
+ const row = rows[index];
17903
+ if (row) row.gone = true;
17904
+ own.entry?.attachment.removeAt(index);
17905
+ }
17906
+ return result;
17907
+ }, "handler")
17908
+ });
17909
+ }
17910
+ }
17911
+ const binders = scoped ? scoped.definitions(() => own.entry?.attachment.remove()) : [];
17912
+ const attachment = manager.attachHooks(SHELL_HOOKS_PLUGIN_ID, [...binders, ...defs]);
17913
+ const offset = binders.length;
17914
+ const entry = {
17915
+ skill: name,
17916
+ scope: how.forked ? "agent" : "conversation",
17917
+ digest: digest3,
17918
+ attachment: {
17919
+ size: attachment.size - offset,
17920
+ remove: /* @__PURE__ */ __name(() => {
17921
+ live.delete(entry);
17922
+ return attachment.remove();
17923
+ }, "remove"),
17924
+ removeAt: /* @__PURE__ */ __name((index) => attachment.removeAt(index + offset), "removeAt")
17925
+ },
17926
+ rows
17927
+ };
17928
+ own.entry = entry;
17929
+ live.add(entry);
17930
+ return {
17931
+ remove: /* @__PURE__ */ __name(() => {
17932
+ entry.attachment.remove();
17933
+ }, "remove")
17934
+ };
17935
+ }, "attach")
17936
+ };
17937
+ }, "prepare");
17938
+ const prepareHooks = /* @__PURE__ */ __name((skill, how) => prepare(skill, how), "prepareHooks");
17939
+ return {
17940
+ prepareHooks,
17941
+ use: /* @__PURE__ */ __name((skill) => {
17942
+ prepareHooks(skill, { forked: false }).attach();
17943
+ }, "use"),
17944
+ say: /* @__PURE__ */ __name((line) => {
17945
+ const cutLine2 = cut(line);
17946
+ tell(cutLine2);
17947
+ return cutLine2;
17948
+ }, "say"),
17949
+ restore: /* @__PURE__ */ __name((skill) => {
17950
+ const name = skill.name;
17951
+ if (options.hooksSwitch() !== void 0) return void 0;
17952
+ const unattached = /* @__PURE__ */ __name((why) => {
17953
+ const line = cut(
17954
+ `Skill ${name}: its hooks are not attached after this conversation was continued, because ${why} Its allowed-tools are not pre-approved.`
17955
+ );
17956
+ tell(line);
17957
+ return line;
17958
+ }, "unattached");
17959
+ if ("problem" in skill.now) return unattached(`${skill.now.problem}.`);
17960
+ const source = skill.now.hooksSource;
17961
+ if (source === void 0) {
17962
+ return unattached("its file no longer carries hooks.");
17963
+ }
17964
+ const plan = prepare(
17965
+ { name, dirPath: skill.dirPath, hooksSource: source },
17966
+ { forked: false },
17967
+ true
17968
+ );
17969
+ plan.attach();
17970
+ if (plan.withholdGrants) return plan.notice;
17971
+ const hasRows = [...live].some((found) => found.skill === name);
17972
+ return hasRows ? void 0 : unattached("its file no longer carries a hook that can be loaded.");
17973
+ }, "restore"),
17974
+ attached: /* @__PURE__ */ __name(() => [...live].flatMap(
17975
+ (found) => found.rows.filter((row) => !row.gone).map(({ gone: _gone, ...row }) => row)
17976
+ ), "attached"),
17977
+ endConversation: /* @__PURE__ */ __name(() => {
17978
+ for (const found of [...live]) found.attachment.remove();
17979
+ live.clear();
17980
+ told.clear();
17981
+ }, "endConversation"),
17982
+ subscribe: /* @__PURE__ */ __name((listener) => {
17983
+ listeners.add(listener);
17984
+ return () => {
17985
+ listeners.delete(listener);
17986
+ };
17987
+ }, "subscribe")
17988
+ };
17989
+ }
17990
+ __name(createSkillHooksHost, "createSkillHooksHost");
17991
+ function childScope(parent, prompt) {
17992
+ const bound = /* @__PURE__ */ new Set();
17993
+ const candidates = /* @__PURE__ */ new Set();
17994
+ let primary;
17995
+ const wanted = prompt?.trim();
17996
+ const isTheSkillsPrompt = /* @__PURE__ */ __name((given) => {
17997
+ const text2 = (given ?? "").trim();
17998
+ if (wanted === void 0 || wanted === "") return true;
17999
+ return text2 !== "" && (text2.includes(wanted) || wanted.includes(text2));
18000
+ }, "isTheSkillsPrompt");
18001
+ const definitions = /* @__PURE__ */ __name((end) => {
18002
+ const out = [
18003
+ {
18004
+ event: "subagent_start",
18005
+ // First, so the agent is covered for its own start events.
18006
+ priority: 0,
18007
+ handler: /* @__PURE__ */ __name(async (context) => {
18008
+ const self = String(context.sessionId);
18009
+ const above = context.parentSessionId !== void 0 ? String(context.parentSessionId) : void 0;
18010
+ if (primary === void 0 && (parent === void 0 || above === parent)) {
18011
+ if (wanted === void 0) {
18012
+ primary = self;
18013
+ } else {
18014
+ candidates.add(self);
18015
+ }
18016
+ bound.add(self);
18017
+ } else if (above !== void 0 && bound.has(above)) {
18018
+ bound.add(self);
18019
+ }
18020
+ return { action: "continue" };
18021
+ }, "handler")
18022
+ },
18023
+ {
18024
+ event: "subagent_stop",
18025
+ handler: /* @__PURE__ */ __name(async (context) => {
18026
+ const self = String(context.sessionId);
18027
+ if (primary !== void 0 && self === primary) {
18028
+ queueMicrotask(end);
18029
+ } else if (candidates.delete(self)) {
18030
+ queueMicrotask(() => bound.delete(self));
18031
+ }
18032
+ return { action: "continue" };
18033
+ }, "handler")
18034
+ }
18035
+ ];
18036
+ if (wanted !== void 0) {
18037
+ out.push({
18038
+ event: "user_prompt_submit",
18039
+ priority: 0,
18040
+ handler: /* @__PURE__ */ __name(async (context) => {
18041
+ const self = String(context.sessionId);
18042
+ if (!candidates.has(self)) return { action: "continue" };
18043
+ candidates.delete(self);
18044
+ if (primary === void 0 && isTheSkillsPrompt(context.prompt)) {
18045
+ primary = self;
18046
+ for (const other of candidates) bound.delete(other);
18047
+ candidates.clear();
18048
+ } else {
18049
+ bound.delete(self);
18050
+ }
18051
+ return { action: "continue" };
18052
+ }, "handler")
18053
+ });
18054
+ }
18055
+ return out;
18056
+ }, "definitions");
18057
+ return {
18058
+ covers: /* @__PURE__ */ __name((context) => bound.has(String(context.sessionId)), "covers"),
18059
+ definitions
18060
+ };
18061
+ }
18062
+ __name(childScope, "childScope");
18063
+
17945
18064
  // src/tui/conversation-history.ts
17946
- function assistantTranscriptTexts(message2) {
17947
- const content = typeof message2.content === "string" ? message2.content : "";
17948
- const parts = message2.textParts;
18065
+ function assistantTranscriptTexts(message) {
18066
+ const content = typeof message.content === "string" ? message.content : "";
18067
+ const parts = message.textParts;
17949
18068
  const valid = Array.isArray(parts) && parts.every(
17950
18069
  (part) => part !== null && typeof part === "object" && typeof part.id === "string" && typeof part.text === "string" && (part.phase === void 0 || part.phase === "commentary" || part.phase === "final_answer")
17951
18070
  );
@@ -17955,7 +18074,7 @@ function assistantTranscriptTexts(message2) {
17955
18074
  __name(assistantTranscriptTexts, "assistantTranscriptTexts");
17956
18075
  function projectTurnConversation(messages) {
17957
18076
  return messages.filter(
17958
- (message2) => message2.role !== "system" || isCompactionMessage(message2.content)
18077
+ (message) => message.role !== "system" || isCompactionMessage(message.content)
17959
18078
  );
17960
18079
  }
17961
18080
  __name(projectTurnConversation, "projectTurnConversation");
@@ -18075,19 +18194,19 @@ async function resolveModelSwitch(request, options) {
18075
18194
  listed.set(detected.entry.id, listing);
18076
18195
  return listing.kind === "ok" && listing.models.some((candidate) => candidate.id === stripModelWindowSuffix(model));
18077
18196
  }, "inspect");
18078
- const resolve15 = /* @__PURE__ */ __name((detected) => ({
18197
+ const resolve16 = /* @__PURE__ */ __name((detected) => ({
18079
18198
  kind: "resolved",
18080
18199
  selection: { id: detected.entry.id, model }
18081
18200
  }), "resolve");
18082
18201
  const first = selected ?? usable.find(({ entry }) => entry.id === options.currentProvider);
18083
- if (first && await inspect(first)) return resolve15(first);
18202
+ if (first && await inspect(first)) return resolve16(first);
18084
18203
  const candidates = selected ? [selected] : usable;
18085
18204
  const matches = selected ? [] : (await Promise.all(
18086
18205
  candidates.filter((candidate) => candidate !== first).map(async (candidate) => await inspect(candidate) ? candidate : void 0)
18087
18206
  )).filter((candidate) => candidate !== void 0);
18088
18207
  signal?.throwIfAborted();
18089
18208
  const uniqueMatch = matches.length === 1 ? matches[0] : void 0;
18090
- if (uniqueMatch) return resolve15(uniqueMatch);
18209
+ if (uniqueMatch) return resolve16(uniqueMatch);
18091
18210
  if (matches.length > 1) {
18092
18211
  return {
18093
18212
  kind: "rejected",
@@ -18118,7 +18237,7 @@ __name(resolveModelSwitch, "resolveModelSwitch");
18118
18237
 
18119
18238
  // src/tui/read-search-group.ts
18120
18239
  import { homedir as homedir3 } from "node:os";
18121
- import { isAbsolute as isAbsolute11, relative as relative10, resolve as resolve13, sep as sep7 } from "node:path";
18240
+ import { isAbsolute as isAbsolute12, relative as relative11, resolve as resolve14, sep as sep8 } from "node:path";
18122
18241
  var EMPTY_GROUP = {
18123
18242
  readKeys: [],
18124
18243
  anonymousReads: 0,
@@ -18488,13 +18607,13 @@ function classifyShell(command) {
18488
18607
  }
18489
18608
  __name(classifyShell, "classifyShell");
18490
18609
  function displayPath3(path, cwd) {
18491
- const abs = cwd && !isAbsolute11(path) ? resolve13(cwd, path) : path;
18610
+ const abs = cwd && !isAbsolute12(path) ? resolve14(cwd, path) : path;
18492
18611
  if (cwd) {
18493
- const rel = relative10(cwd, abs);
18494
- if (rel.length > 0 && !rel.startsWith("..") && !isAbsolute11(rel)) return rel;
18612
+ const rel = relative11(cwd, abs);
18613
+ if (rel.length > 0 && !rel.startsWith("..") && !isAbsolute12(rel)) return rel;
18495
18614
  }
18496
18615
  const home = homedir3();
18497
- if (home && (abs === home || abs.startsWith(home + sep7))) return `~${abs.slice(home.length)}`;
18616
+ if (home && (abs === home || abs.startsWith(home + sep8))) return `~${abs.slice(home.length)}`;
18498
18617
  return abs;
18499
18618
  }
18500
18619
  __name(displayPath3, "displayPath");
@@ -19038,8 +19157,8 @@ var SessionOperationOwner = class {
19038
19157
  })()[Symbol.asyncIterator]();
19039
19158
  let settled = false;
19040
19159
  let settle;
19041
- const settlement = new Promise((resolve15) => {
19042
- settle = resolve15;
19160
+ const settlement = new Promise((resolve16) => {
19161
+ settle = resolve16;
19043
19162
  });
19044
19163
  let operationTail = Promise.resolve();
19045
19164
  let returnStarted = false;
@@ -19303,11 +19422,11 @@ __name(clipRequestContext, "clipRequestContext");
19303
19422
  async function createAgentSession(prefs, detectedProviders, options = {}) {
19304
19423
  const modelEnvironment = readModelLaunchEnvironment();
19305
19424
  if (options.palEnvironment) {
19306
- const { createPalAgentSession } = await import("./agent-session-L6J5GZVX.js");
19425
+ const { createPalAgentSession } = await import("./agent-session-BD2AHK5S.js");
19307
19426
  return createPalAgentSession(prefs, detectedProviders, options);
19308
19427
  }
19309
19428
  let detected = detectedProviders;
19310
- const { palAtWorkspace } = await import("./store-XIPDR26B.js");
19429
+ const { palAtWorkspace } = await import("./store-CNEKBGKD.js");
19311
19430
  if (palAtWorkspace(options.cwd ?? process.cwd()))
19312
19431
  throw new Error("This Pal requires its owned virtual computer. Open it with namzu pal chat.");
19313
19432
  const commandArguments = builtinCommandArguments();
@@ -19344,7 +19463,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19344
19463
  }
19345
19464
  return seeded;
19346
19465
  }, "observationsFor");
19347
- const requestedCwd = resolve14(options.cwd ?? process.cwd());
19466
+ const requestedCwd = resolve15(options.cwd ?? process.cwd());
19348
19467
  let cwd;
19349
19468
  try {
19350
19469
  const entry2 = await stat7(requestedCwd);
@@ -19376,13 +19495,13 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19376
19495
  paths = options.conversationSessions.paths;
19377
19496
  projectId = options.conversationSessions.projectId;
19378
19497
  } else {
19379
- const home = resolve14(options.stateRoot ?? resolveNamzuHome());
19498
+ const home = resolve15(options.stateRoot ?? resolveNamzuHome());
19380
19499
  ensurePrivateStateDirectory(home, "projects");
19381
19500
  const project = await ensureProject({ home, cwd: cliProjectRoot(cwd) });
19382
19501
  paths = new SessionPaths({ home, slug: project.slug });
19383
19502
  projectId = project.projectId;
19384
19503
  }
19385
- ensurePrivateStateDirectory(resolve14(paths.projectDir(), ".."), paths.slug);
19504
+ ensurePrivateStateDirectory(resolve15(paths.projectDir(), ".."), paths.slug);
19386
19505
  ensurePrivateStateDirectory(paths.projectDir(), "memory");
19387
19506
  } catch (error) {
19388
19507
  return emptySession(
@@ -19763,8 +19882,8 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19763
19882
  }
19764
19883
  const directories = [];
19765
19884
  for (const dir of options.additionalDirectories ?? []) {
19766
- const absolute = resolve14(cwd, dir);
19767
- if (absolute !== resolve14(cwd) && !directories.includes(absolute)) directories.push(absolute);
19885
+ const absolute = resolve15(cwd, dir);
19886
+ if (absolute !== resolve15(cwd) && !directories.includes(absolute)) directories.push(absolute);
19768
19887
  }
19769
19888
  const sessionDirectories = createSessionDirectories(cwd, directories);
19770
19889
  const checkpoints = new FileCheckpointStore(
@@ -20113,12 +20232,26 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20113
20232
  for (const problem of pluginFiles.problems) cliLogger().warn(problem);
20114
20233
  let subagentRuntime;
20115
20234
  let allowedAgentIds = [];
20235
+ const agentHooks = createAgentHooksHost({
20236
+ manager: /* @__PURE__ */ __name(() => pluginRuntime?.manager, "manager"),
20237
+ hookOptions: /* @__PURE__ */ __name(() => pluginRuntime?.hookOptions, "hookOptions"),
20238
+ hooksSwitch: /* @__PURE__ */ __name(() => options.hooksSwitch, "hooksSwitch"),
20239
+ projectTrusted: /* @__PURE__ */ __name(() => options.folderTrusted === true || isTrusted(cwd), "projectTrusted")
20240
+ });
20241
+ let agentHookCarriers = [];
20242
+ let refusedAgents = [];
20116
20243
  try {
20117
- const discovered = await discoverAgentDefinitions2({
20244
+ const discovered = await discoverAgentDefinitions({
20118
20245
  cwd,
20119
20246
  pluginAgentDirs: pluginFiles.agents,
20120
- ...options.skills ? { skills: options.skills } : {}
20247
+ ...options.skills ? { skills: options.skills } : {},
20248
+ hooks: {
20249
+ hooksSwitch: options.hooksSwitch,
20250
+ projectTrusted: options.folderTrusted === true || isTrusted(cwd)
20251
+ }
20121
20252
  });
20253
+ agentHookCarriers = discovered.definitions.filter((definition) => definition.hooksSource !== void 0).map((definition) => definition.name);
20254
+ refusedAgents = discovered.refused;
20122
20255
  for (const missing2 of discovered.missingSkills) {
20123
20256
  cliLogger().warn("agent definition skill missing", {
20124
20257
  "namzu.agent.definition.path": missing2.path,
@@ -20126,7 +20259,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20126
20259
  });
20127
20260
  }
20128
20261
  for (const skipped of discovered.skipped) {
20129
- const inPlugin = pluginFiles.agents.some(({ dir }) => skipped.path.startsWith(`${dir}${sep8}`));
20262
+ const inPlugin = pluginFiles.agents.some(({ dir }) => skipped.path.startsWith(`${dir}${sep9}`));
20130
20263
  cliLogger().warn("agent definition skipped", {
20131
20264
  "namzu.agent.definition.path": skipped.path,
20132
20265
  "namzu.agent.definition.reason": inPlugin ? `${skipped.reason}. ${CHECK_HINT}` : skipped.reason
@@ -20136,6 +20269,12 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20136
20269
  cwd,
20137
20270
  // Plugins are initialized later; resolve the shared manager when a child starts.
20138
20271
  resolvePluginManager: /* @__PURE__ */ __name(() => pluginRuntime?.manager, "resolvePluginManager"),
20272
+ // A hook on worktree_create or worktree_remove takes over making and
20273
+ // removing the worktree of a delegated child.
20274
+ worktreeHooks: {
20275
+ host: /* @__PURE__ */ __name(() => pluginRuntime ? worktreeHookHost(pluginRuntime.manager, () => String(scope2.sessionId)) : void 0, "host"),
20276
+ onNotice: /* @__PURE__ */ __name((line) => pluginRuntime?.hookActivity.notify(line), "onNotice")
20277
+ },
20139
20278
  ...options.ephemeral ? { ephemeral: true } : {},
20140
20279
  // An operator is watching: agents run in the background by default and
20141
20280
  // the turn ends without waiting for them.
@@ -20161,6 +20300,8 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20161
20300
  resolveTurnModel: /* @__PURE__ */ __name((turnId) => delegationModels.get(turnId), "resolveTurnModel"),
20162
20301
  timeoutMs: options.limits?.timeoutMs,
20163
20302
  definitions: discovered.definitions,
20303
+ agentHooks,
20304
+ refusedDefinitions: discovered.refused,
20164
20305
  // Children log under the parent's `<session-id>/subagents/`; an
20165
20306
  // ephemeral session keeps them in memory with its own log.
20166
20307
  ...options.ephemeral ? {} : { paths },
@@ -20311,7 +20452,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20311
20452
  return found != null && canSelectModel(found.entry, found.apiKey, listed.id) && isOfferableModel(providerId, listed.id);
20312
20453
  }, "offerable"),
20313
20454
  ledger: sub.sideLedger,
20314
- debug: /* @__PURE__ */ __name((message2, error) => cliLogger().debug(message2, exceptionAttributes(error)), "debug")
20455
+ debug: /* @__PURE__ */ __name((message, error) => cliLogger().debug(message, exceptionAttributes(error)), "debug")
20315
20456
  });
20316
20457
  const learningLedger = createLearningLedger();
20317
20458
  learning = createSideLearningModel({
@@ -20328,7 +20469,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20328
20469
  return found != null && canSelectModel(found.entry, found.apiKey, listed.id) && isOfferableModel(providerId, listed.id);
20329
20470
  }, "offerable"),
20330
20471
  ledger: learningLedger,
20331
- debug: /* @__PURE__ */ __name((message2, error) => cliLogger().debug(message2, exceptionAttributes(error)), "debug")
20472
+ debug: /* @__PURE__ */ __name((message, error) => cliLogger().debug(message, exceptionAttributes(error)), "debug")
20332
20473
  }),
20333
20474
  ledger: learningLedger,
20334
20475
  sessionId: scope2.sessionId
@@ -20591,7 +20732,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20591
20732
  );
20592
20733
  toolsets.push(options.toolLoading === "eager" ? monitorToolset : deferred(monitorToolset));
20593
20734
  }
20594
- const operatorPals = await import("./operator-tools-LYY2FXSO.js");
20735
+ const operatorPals = await import("./operator-tools-KQV2T5UU.js");
20595
20736
  toolsets.push(
20596
20737
  readyWhen(
20597
20738
  toolset(
@@ -20677,7 +20818,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20677
20818
  const memoryUsage = new MemoryUsage({
20678
20819
  file: join19(paths.home, "memory-usage", `${paths.slug}.json`),
20679
20820
  now: Date.now,
20680
- log: /* @__PURE__ */ __name((message2, fields) => cliLogger().debug(message2, fields), "log")
20821
+ log: /* @__PURE__ */ __name((message, fields) => cliLogger().debug(message, fields), "log")
20681
20822
  });
20682
20823
  const memoryCaution = createAnchorCaution({ root: cliProjectRoot(cwd), usage: memoryUsage });
20683
20824
  const memoryLifecycle = new MemoryLifecycle({
@@ -20693,7 +20834,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20693
20834
  return handle;
20694
20835
  }, "setTimer"),
20695
20836
  clearTimer: /* @__PURE__ */ __name((handle) => clearTimeout(handle), "clearTimer"),
20696
- log: /* @__PURE__ */ __name((message2, fields) => cliLogger().info(message2, fields), "log"),
20837
+ log: /* @__PURE__ */ __name((message, fields) => cliLogger().info(message, fields), "log"),
20697
20838
  onSwept: /* @__PURE__ */ __name((report) => {
20698
20839
  const lines = [
20699
20840
  `Retired ${report.archived.length} ${report.archived.length === 1 ? "memory" : "memories"} that were not used. /memory restores ${report.archived.length === 1 ? "it" : "them"}.`
@@ -20724,21 +20865,34 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20724
20865
  let readHookMode;
20725
20866
  let pluginRuntime;
20726
20867
  try {
20727
- pluginRuntime = await createCliPluginRuntime(options.plugins, cwd, options.hooks, {
20728
- permissionMode: /* @__PURE__ */ __name(() => hookSessionMode(readHookMode?.(), options.permissionMode), "permissionMode"),
20729
- transcriptPath: /* @__PURE__ */ __name((sessionId) => options.ephemeral ? void 0 : paths.sessionLog({ sessionId }), "transcriptPath"),
20730
- // A `prompt` hook asks the small model, and its tokens count against the
20731
- // turn it fired in. Outside a turn there is no ledger, so it is not asked.
20732
- judge: /* @__PURE__ */ __name(async (request) => sideModel === void 0 || request.turnId === void 0 ? void 0 : sideModel.ask({
20733
- sessionId: request.sessionId,
20734
- turnId: request.turnId,
20735
- instruction: request.instruction,
20736
- body: request.body,
20737
- maxTokens: 300,
20738
- signal: request.signal,
20739
- timing: "beside-turn"
20740
- }), "judge")
20741
- });
20868
+ pluginRuntime = await createCliPluginRuntime(
20869
+ options.plugins,
20870
+ cwd,
20871
+ options.hooks,
20872
+ {
20873
+ // Read at each event: a conversation cleared in place changes the id.
20874
+ sessionId: /* @__PURE__ */ __name(() => String(scope2.sessionId), "sessionId"),
20875
+ permissionMode: /* @__PURE__ */ __name(() => hookSessionMode(readHookMode?.(), options.permissionMode), "permissionMode"),
20876
+ transcriptPath: /* @__PURE__ */ __name((sessionId) => options.ephemeral ? void 0 : paths.sessionLog({ sessionId }), "transcriptPath"),
20877
+ // A `prompt` hook asks the small model, and its tokens count against the
20878
+ // turn it fired in. Outside a turn there is no ledger, so it is not asked.
20879
+ judge: /* @__PURE__ */ __name(async (request) => sideModel === void 0 || request.turnId === void 0 ? void 0 : sideModel.ask({
20880
+ sessionId: request.sessionId,
20881
+ turnId: request.turnId,
20882
+ instruction: request.instruction,
20883
+ body: request.body,
20884
+ maxTokens: 300,
20885
+ signal: request.signal,
20886
+ timing: "beside-turn"
20887
+ }), "judge")
20888
+ },
20889
+ {
20890
+ // The same switch plugin entries obey; none of the hooks attach under it.
20891
+ ...options.hooksSwitch ? { hooksSwitch: options.hooksSwitch } : {},
20892
+ // A skill that carries hooks attaches them to this manager when it is used.
20893
+ keepForSkills: options.hooksSwitch === void 0 && (agentHookCarriers.length > 0 || skillCatalog.fileSkills.some((skill) => skill.hooksSource !== void 0))
20894
+ }
20895
+ );
20742
20896
  } catch (error) {
20743
20897
  await Promise.allSettled([mcp.close(), computerUseHost?.dispose(), browserControl?.dispose()]);
20744
20898
  return emptySession(
@@ -20755,6 +20909,14 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20755
20909
  const withheldTools = new Set(options.withheldTools ?? []);
20756
20910
  const webToolsWithheld = withheldTools.has("web_fetch") && withheldTools.has("web_search");
20757
20911
  const sessionPlugins = pluginRuntime;
20912
+ const skillHooks = createSkillHooksHost({
20913
+ manager: /* @__PURE__ */ __name(() => sessionPlugins?.manager, "manager"),
20914
+ hookOptions: /* @__PURE__ */ __name(() => sessionPlugins?.hookOptions, "hookOptions"),
20915
+ hooksSwitch: /* @__PURE__ */ __name(() => options.hooksSwitch, "hooksSwitch"),
20916
+ projectTrusted: /* @__PURE__ */ __name(() => options.folderTrusted === true || isTrusted(cwd), "projectTrusted"),
20917
+ isProjectSkill: /* @__PURE__ */ __name((name) => skillCatalog.fileSkills.some((skill) => skill.name === name && skill.source === "project"), "isProjectSkill"),
20918
+ isInProject: /* @__PURE__ */ __name((directory) => isInsideFolder(cwd, directory), "isInProject")
20919
+ });
20758
20920
  const sessionToolsets = toolsets.flatMap((ts) => {
20759
20921
  const wrapped = withheldTools.size > 0 ? filtered(ts, (tool) => !withheldTools.has(tool.name)) : ts;
20760
20922
  return options.toolLoading === "deferred" ? deferExceptToolset(wrapped, EAGER_TOOLS_WHEN_DEFERRED) : [wrapped];
@@ -20801,13 +20963,16 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20801
20963
  const turnSkillsFor = /* @__PURE__ */ __name((turnModel) => skillCatalog.forTurn({
20802
20964
  toolNames: liveManager().listNames(),
20803
20965
  contextWindowTokens: resolveContextWindow(options.compaction?.contextWindowTokens, turnModel).tokens,
20804
- ...sessionPlugins ? { pluginSkills: sessionPlugins.skills } : {}
20966
+ ...sessionPlugins ? { pluginSkills: sessionPlugins.skills } : {},
20967
+ skillHooks
20805
20968
  }), "turnSkillsFor");
20806
20969
  let lastSystemPromptText;
20807
20970
  let sessionStarted = false;
20808
20971
  let sessionHookContext;
20809
20972
  let conversationGeneration = 0;
20810
20973
  let nextSessionSource;
20974
+ let skillHooksRestoredFor;
20975
+ let skillHooksNotAttached = [];
20811
20976
  const conversationEnds = /* @__PURE__ */ new Set();
20812
20977
  const announceSessionStart = /* @__PURE__ */ __name(async (counted2) => {
20813
20978
  if (!sessionPlugins || sessionStarted) return;
@@ -20821,10 +20986,14 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20821
20986
  });
20822
20987
  if (generation !== conversationGeneration) return;
20823
20988
  sessionHookContext = sessionStartHookContext(results);
20989
+ sessionPlugins.hookActivity.absorbSessionStart(results);
20824
20990
  }, "announceSessionStart");
20825
20991
  const changeConversation = /* @__PURE__ */ __name((change) => {
20826
20992
  if (!sessionPlugins) return Promise.resolve();
20827
20993
  conversationGeneration += 1;
20994
+ skillHooks.endConversation();
20995
+ skillHooksRestoredFor = void 0;
20996
+ skillHooksNotAttached = [];
20828
20997
  sessionStarted = false;
20829
20998
  sessionHookContext = void 0;
20830
20999
  nextSessionSource = change.starting;
@@ -20833,6 +21002,30 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20833
21002
  void ended.then(() => conversationEnds.delete(ended));
20834
21003
  return ended;
20835
21004
  }, "changeConversation");
21005
+ const putSkillHooksBack = /* @__PURE__ */ __name(async (sessionId, hasEarlierTurns) => {
21006
+ if (skillHooksRestoredFor === String(sessionId)) return;
21007
+ skillHooksRestoredFor = String(sessionId);
21008
+ skillHooksNotAttached = [];
21009
+ if (!options.conversationSessions || !hasEarlierTurns) return;
21010
+ let readFailure;
21011
+ const known = await readConversationFacts(
21012
+ options.conversationSessions,
21013
+ sessionId,
21014
+ "tolerant"
21015
+ ).catch((error) => {
21016
+ readFailure = error;
21017
+ return null;
21018
+ });
21019
+ if (readFailure !== void 0) {
21020
+ skillHooksNotAttached = [
21021
+ skillHooks.say(
21022
+ `The skills this conversation used could not be checked for hooks, so none are attached again: ${describeError2(readFailure)}.`
21023
+ )
21024
+ ];
21025
+ } else if (known && known.skillHooks.length > 0) {
21026
+ skillHooksNotAttached = restoreSkillHooks(skillHooks, known.skillHooks);
21027
+ }
21028
+ }, "putSkillHooksBack");
20836
21029
  let sessionEndReason = "exit";
20837
21030
  let sessionClosing = false;
20838
21031
  if (pluginRuntime) {
@@ -21020,6 +21213,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21020
21213
  const route = await pinnedResumeRoute(pinned, entry2.sessionId, ownedSignal);
21021
21214
  const resumeWebSearch = route ? routedWebSearch(route) : nativeWebSearch;
21022
21215
  const turnSkills = await turnSkillsFor(route?.model ?? model);
21216
+ await putSkillHooksBack(entry2.sessionId, true);
21023
21217
  const curatedMemory = readMemory(void 0, cwd);
21024
21218
  for (const notice2 of formatMemoryDiagnostics(curatedMemory)) cliLogger().warn(notice2);
21025
21219
  const storedMemory = await storedMemoryPrompt();
@@ -21057,7 +21251,9 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21057
21251
  workflowOffered: false,
21058
21252
  permissionMode: permissionMode ?? options.permissionMode ?? "auto",
21059
21253
  extraSystem,
21060
- systemNote
21254
+ ...([systemNote, ...skillHooksNotAttached].filter(Boolean).join("\n") || void 0) !== void 0 ? {
21255
+ systemNote: [systemNote, ...skillHooksNotAttached].filter(Boolean).join("\n")
21256
+ } : {}
21061
21257
  }
21062
21258
  )
21063
21259
  );
@@ -21334,8 +21530,8 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21334
21530
  if (mapped) yield mapped;
21335
21531
  }
21336
21532
  if (settled) break;
21337
- await new Promise((resolve15) => {
21338
- wake = resolve15;
21533
+ await new Promise((resolve16) => {
21534
+ wake = resolve16;
21339
21535
  });
21340
21536
  wake = void 0;
21341
21537
  }
@@ -21490,9 +21686,9 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21490
21686
  })
21491
21687
  );
21492
21688
  }
21493
- const at = /* @__PURE__ */ __name((message2, fallback) => {
21494
- if (!message2) return fallback;
21495
- const found = messages.indexOf(message2);
21689
+ const at = /* @__PURE__ */ __name((message, fallback) => {
21690
+ if (!message) return fallback;
21691
+ const found = messages.indexOf(message);
21496
21692
  if (found < 0) {
21497
21693
  throw new Error(
21498
21694
  "That message is no longer in the active context. Choose a more recent message."
@@ -21559,7 +21755,31 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21559
21755
  stopJob: /* @__PURE__ */ __name((id) => ownedJobs.kill(id), "stopJob")
21560
21756
  } : {},
21561
21757
  ...options.hooks ? { hooks: options.hooks } : {},
21758
+ skillHooks: {
21759
+ attached: /* @__PURE__ */ __name(() => skillHooks.attached(), "attached"),
21760
+ use: /* @__PURE__ */ __name((skill) => skillHooks.use(skill), "use"),
21761
+ subscribe: /* @__PURE__ */ __name((listener) => skillHooks.subscribe(listener), "subscribe"),
21762
+ carriers: /* @__PURE__ */ __name(() => skillCatalog.fileSkills.filter((skill) => skill.hooksSource !== void 0).map((skill) => skill.name), "carriers")
21763
+ },
21764
+ agentHooks: {
21765
+ attached: /* @__PURE__ */ __name(() => agentHooks.attached(), "attached"),
21766
+ subscribe: /* @__PURE__ */ __name((listener) => agentHooks.subscribe(listener), "subscribe"),
21767
+ carriers: /* @__PURE__ */ __name(() => agentHookCarriers, "carriers"),
21768
+ refused: /* @__PURE__ */ __name(() => refusedAgents.map((refused) => ({ name: refused.name, line: refused.line })), "refused")
21769
+ },
21562
21770
  ...pluginRuntime ? { pluginHooks: /* @__PURE__ */ __name(() => pluginRuntime?.pluginHooks() ?? [], "pluginHooks") } : {},
21771
+ ...pluginRuntime ? {
21772
+ pluginHookEntries: /* @__PURE__ */ __name(() => pluginRuntime?.pluginHookEntries() ?? [], "pluginHookEntries"),
21773
+ pluginHookProblems: /* @__PURE__ */ __name(() => pluginRuntime?.pluginHookProblems() ?? [], "pluginHookProblems"),
21774
+ hookActivity: /* @__PURE__ */ __name(() => pluginRuntime.hookActivity.describe(), "hookActivity"),
21775
+ hookNotices: {
21776
+ subscribe: /* @__PURE__ */ __name((listener) => pluginRuntime.hookActivity.onNotice(listener), "subscribe")
21777
+ },
21778
+ worktreeHooks: {
21779
+ host: /* @__PURE__ */ __name(() => worktreeHookHost(pluginRuntime.manager, () => String(scope2.sessionId)), "host"),
21780
+ onNotice: /* @__PURE__ */ __name((line) => pluginRuntime.hookActivity.notify(line), "onNotice")
21781
+ }
21782
+ } : {},
21563
21783
  checkpoints,
21564
21784
  markFilesChanged: /* @__PURE__ */ __name(async (changed) => {
21565
21785
  const seeded = fileObservations.get(scope2.sessionId);
@@ -21667,7 +21887,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21667
21887
  onSubagentCompletion: /* @__PURE__ */ __name((listener) => subagentRuntime?.onBackgroundCompletion(listener) ?? (() => {
21668
21888
  }), "onSubagentCompletion"),
21669
21889
  stopSubagent: /* @__PURE__ */ __name((viewId) => subagentRuntime?.stopChild(viewId) ?? false, "stopSubagent"),
21670
- messageSubagent: /* @__PURE__ */ __name((viewId, message2, opts) => operations.promise(opts?.signal, async (signal) => {
21890
+ messageSubagent: /* @__PURE__ */ __name((viewId, message, opts) => operations.promise(opts?.signal, async (signal) => {
21671
21891
  const runtime = subagentRuntime;
21672
21892
  if (!runtime) throw new Error("Delegation is unavailable.");
21673
21893
  const turnScope = { ...scope2 };
@@ -21722,7 +21942,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21722
21942
  signal.throwIfAborted();
21723
21943
  if (scope2.sessionId !== turnScope.sessionId)
21724
21944
  throw new Error("The parent conversation changed before admission.");
21725
- const receipt = await runtime.messageChild(viewId, message2, turnId, signal);
21945
+ const receipt = await runtime.messageChild(viewId, message, turnId, signal);
21726
21946
  if (receipt.kind === "started") {
21727
21947
  const gateway = await runtime.gatewayForTurn(turnId);
21728
21948
  const cancel = /* @__PURE__ */ __name(() => gateway.cancelTask(asTaskId(receipt.taskId), "user"), "cancel");
@@ -21866,6 +22086,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
21866
22086
  ),
21867
22087
  ...fallbackPlan.notices,
21868
22088
  ...takeConfigWarnings(),
22089
+ ...pluginRuntime?.takePluginHookWarnings() ?? [],
21869
22090
  ...compatibleEndpointNotices(),
21870
22091
  ...memoryMigrationNotices,
21871
22092
  ...computerUseNotices
@@ -22155,8 +22376,20 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
22155
22376
  );
22156
22377
  lastSystemPromptText = systemPrompt;
22157
22378
  await announceSessionStart(
22158
- messages.filter((message2) => message2.role === "user").length > 1 ? "resume" : "startup"
22379
+ messages.filter((message) => message.role === "user").length > 1 ? "resume" : "startup"
22159
22380
  );
22381
+ await putSkillHooksBack(
22382
+ turnScope.sessionId,
22383
+ messages.filter((message) => message.role === "user").length > 1
22384
+ );
22385
+ if (skillHooksNotAttached.length > 0) {
22386
+ const notAttached = skillHooksNotAttached.join("\n");
22387
+ promptContributions.register({
22388
+ id: "namzu.hooks.skill-restore",
22389
+ placement: "context",
22390
+ render: /* @__PURE__ */ __name(() => notAttached, "render")
22391
+ });
22392
+ }
22160
22393
  if (sessionHookContext !== void 0) {
22161
22394
  const hookContext = frameOperatorHookContext([sessionHookContext]);
22162
22395
  promptContributions.register({
@@ -22330,6 +22563,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
22330
22563
  toolsets: runToolsets,
22331
22564
  ...screensConfig !== void 0 ? { toolResultGuardrails: screensConfig } : {},
22332
22565
  pluginManager: pluginRuntime?.manager,
22566
+ hookActivity: pluginRuntime?.hookActivity,
22333
22567
  skillRegistry: turnSkills.registry,
22334
22568
  // The skill list is announced through the reminders, so a skill added
22335
22569
  // mid-session leaves the cached prefix alone.
@@ -22968,6 +23202,7 @@ async function* runTurn({
22968
23202
  toolsets,
22969
23203
  toolResultGuardrails,
22970
23204
  pluginManager,
23205
+ hookActivity,
22971
23206
  skillRegistry,
22972
23207
  skills,
22973
23208
  scope: scope2,
@@ -23047,6 +23282,10 @@ async function* runTurn({
23047
23282
  toolsets,
23048
23283
  ...toolResultGuardrails !== void 0 ? { toolResultGuardrails } : {},
23049
23284
  ...pluginManager ? { pluginManager } : {},
23285
+ ...hookActivity ? {
23286
+ // Told once per real change of the shell's folder, before the next command.
23287
+ onWorkingDirectoryChange: /* @__PURE__ */ __name((change) => hookActivity.changeDirectory(change), "onWorkingDirectoryChange")
23288
+ } : {},
23050
23289
  ...skillRegistry ? { skillRegistry } : {},
23051
23290
  ...skills ? { skills } : {},
23052
23291
  // Withheld at both provider and executor boundaries on every ordinary
@@ -23083,6 +23322,9 @@ async function* runTurn({
23083
23322
  ...opts?.effort !== void 0 ? { effort: opts.effort } : {},
23084
23323
  ...opts?.speed === "fast" ? { speed: opts.speed } : {},
23085
23324
  ...webSearch ? { webSearch } : {},
23325
+ // The variables hooks set for this session's commands: one live object,
23326
+ // read at each command, so a hook that sets one mid-session is heard.
23327
+ ...hookActivity ? { env: hookActivity.variables } : {},
23086
23328
  ...turnConfigFields(resolveTurnGuards(limits), {
23087
23329
  completionAudit: true,
23088
23330
  detectChanges: changeDetectorFor(workingDirectory, {
@@ -24038,7 +24280,6 @@ export {
24038
24280
  describePendingWorkflowNotices,
24039
24281
  thirdPartyHost,
24040
24282
  sessionLogCheckpointView,
24041
- discoverAgentDefinitions2 as discoverAgentDefinitions,
24042
24283
  DEFAULT_AGENT_WORKFLOW,
24043
24284
  DEFAULT_AGENT_PHASE,
24044
24285
  readMemory,
@@ -24116,4 +24357,4 @@ export {
24116
24357
  RESULT_SUMMARY_WHOLE_MAX,
24117
24358
  resultSummaryLine
24118
24359
  };
24119
- //# sourceMappingURL=chunk-KNQ7R54U.js.map
24360
+ //# sourceMappingURL=chunk-ZZK2BVEH.js.map