@namzu/cli 47.0.0 → 49.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-DK7NWANO.js → acp-2INAZYZT.js} +49 -48
  4. package/dist/chunks/acp-2INAZYZT.js.map +6 -0
  5. package/dist/chunks/{activity-command-4KBMQECC.js → activity-command-J676MIML.js} +13 -13
  6. package/dist/chunks/{add-62XIPWOO.js → add-LI4SX4YZ.js} +21 -21
  7. package/dist/chunks/{agent-MBJAM4JS.js → agent-LUK4L4AW.js} +37 -36
  8. package/dist/chunks/agent-session-5ZG6WNTC.js +69 -0
  9. package/dist/chunks/{archive-GKFLV2WT.js → archive-IZRS7P6C.js} +11 -11
  10. package/dist/chunks/{bin-main-6JRUHZMN.js → bin-main-XNB6LHOP.js} +10 -10
  11. package/dist/chunks/{binding-CWY25KUP.js → binding-3EE2IYAM.js} +3 -3
  12. package/dist/chunks/{browser-RR45SAA5.js → browser-NI2ZPG4N.js} +7 -7
  13. package/dist/chunks/{chat-A3D7JCSI.js → chat-5OEOFTSO.js} +16 -16
  14. package/dist/chunks/{chunk-LRWJQU4R.js → chunk-2FMMT4JD.js} +2 -2
  15. package/dist/chunks/{chunk-4GIMYVA3.js → chunk-2GBI7JYG.js} +2 -2
  16. package/dist/chunks/{chunk-FQNYAUE4.js → chunk-43Q3E36I.js} +2 -2
  17. package/dist/chunks/{chunk-4OB6KSBS.js → chunk-4ET34X7Z.js} +2 -2
  18. package/dist/chunks/{chunk-PRCUNNM6.js → chunk-4GFWZYTR.js} +5 -5
  19. package/dist/chunks/{chunk-POHZFIQB.js → chunk-4IYPPPIR.js} +4 -4
  20. package/dist/chunks/{chunk-KL4RR7B2.js → chunk-4UXO3V22.js} +4 -4
  21. package/dist/chunks/chunk-4UXO3V22.js.map +6 -0
  22. package/dist/chunks/{chunk-XT5ZTOUV.js → chunk-4WFAYG6V.js} +1749 -1456
  23. package/dist/chunks/chunk-4WFAYG6V.js.map +6 -0
  24. package/dist/chunks/{chunk-P4KL7PEP.js → chunk-564OI5HN.js} +2 -2
  25. package/dist/chunks/{chunk-2PEBRNOT.js → chunk-56IRGZRX.js} +3 -3
  26. package/dist/chunks/{chunk-U7RXQG6Z.js → chunk-5AQVWTHV.js} +2 -2
  27. package/dist/chunks/{chunk-TYN5YUYW.js → chunk-5WOHNIH4.js} +5 -2
  28. package/dist/chunks/chunk-5WOHNIH4.js.map +6 -0
  29. package/dist/chunks/{chunk-IE43BX3W.js → chunk-6CZOIEKE.js} +236 -17
  30. package/dist/chunks/chunk-6CZOIEKE.js.map +6 -0
  31. package/dist/chunks/{chunk-XORDVIA3.js → chunk-6T7HV4J5.js} +43 -17
  32. package/dist/chunks/chunk-6T7HV4J5.js.map +6 -0
  33. package/dist/chunks/{chunk-CRAV2EQ5.js → chunk-6TUISLKZ.js} +2 -2
  34. package/dist/chunks/{chunk-CGHQCFUS.js → chunk-753B7NQX.js} +56 -40
  35. package/dist/chunks/chunk-753B7NQX.js.map +6 -0
  36. package/dist/chunks/chunk-7DSJTL5S.js +129 -0
  37. package/dist/chunks/chunk-7DSJTL5S.js.map +6 -0
  38. package/dist/chunks/{chunk-3TR5UJ65.js → chunk-AOKRFS3Z.js} +2 -2
  39. package/dist/chunks/{chunk-PKCR5ORA.js → chunk-BCFC5GGU.js} +12 -12
  40. package/dist/chunks/{chunk-P36IISLH.js → chunk-BPW5AT4B.js} +3 -3
  41. package/dist/chunks/{chunk-W3RVMJZC.js → chunk-CDOLJHIB.js} +2 -2
  42. package/dist/chunks/{chunk-RWTKMA2O.js → chunk-CDT745GI.js} +4 -4
  43. package/dist/chunks/{chunk-4ZVP3RG2.js → chunk-DKJHMWCA.js} +8 -8
  44. package/dist/chunks/{chunk-TBGYJ7RC.js → chunk-E6XGUJ2I.js} +3 -3
  45. package/dist/chunks/{chunk-JRAJ3WVY.js → chunk-EISC5X74.js} +2 -2
  46. package/dist/chunks/{chunk-FHK74RKX.js → chunk-EPS5ROMN.js} +9 -9
  47. package/dist/chunks/{chunk-FZ6XQ3PG.js → chunk-G4SE3TXK.js} +10 -10
  48. package/dist/chunks/{chunk-554QWHL6.js → chunk-G5LUEMDI.js} +1011 -182
  49. package/dist/chunks/chunk-G5LUEMDI.js.map +6 -0
  50. package/dist/chunks/{chunk-QQ76RA5Y.js → chunk-GBRTN4AK.js} +3 -3
  51. package/dist/chunks/{chunk-QO6TNEJ5.js → chunk-GCIBSVYX.js} +4 -4
  52. package/dist/chunks/{chunk-KWTHQ7Z3.js → chunk-GEX2EXU3.js} +4 -4
  53. package/dist/chunks/{chunk-MSR3JAA4.js → chunk-GXSMCKZJ.js} +3 -3
  54. package/dist/chunks/{chunk-BU3K3A3C.js → chunk-HNBF54TV.js} +5 -5
  55. package/dist/chunks/{chunk-65ZRHVSK.js → chunk-HUUVQBZR.js} +3 -3
  56. package/dist/chunks/{chunk-JCFGOQEJ.js → chunk-HXV7TDNY.js} +2 -2
  57. package/dist/chunks/{chunk-UWQE4YXM.js → chunk-KZNMCCYK.js} +5 -5
  58. package/dist/chunks/{chunk-TUK5FMGP.js → chunk-L3VAFXRU.js} +7 -7
  59. package/dist/chunks/{chunk-CF4GQ7DX.js → chunk-LJHHAKBL.js} +3 -3
  60. package/dist/chunks/{chunk-BIYLO4OA.js → chunk-LNDECWNR.js} +2 -2
  61. package/dist/chunks/{chunk-3VD5SYFR.js → chunk-LYSN3FIQ.js} +3 -3
  62. package/dist/chunks/{chunk-A324JRGL.js → chunk-MCTUVMMB.js} +4 -124
  63. package/dist/chunks/chunk-MCTUVMMB.js.map +6 -0
  64. package/dist/chunks/{chunk-DO7ISOWW.js → chunk-NJWCOR7Z.js} +2 -2
  65. package/dist/chunks/{chunk-LB4PI7W2.js → chunk-OOWGXPY2.js} +2 -2
  66. package/dist/chunks/{chunk-MAXR2ZGX.js → chunk-P2CHZ6FL.js} +3 -3
  67. package/dist/chunks/{chunk-IJVO3ADL.js → chunk-P3KXW262.js} +2 -2
  68. package/dist/chunks/{chunk-TONATYGN.js → chunk-P7YVC6KA.js} +2 -2
  69. package/dist/chunks/{chunk-GFI4VC4I.js → chunk-PVCJHQP5.js} +6 -6
  70. package/dist/chunks/{chunk-HSBF2FOJ.js → chunk-QUKAQLNS.js} +10 -10
  71. package/dist/chunks/{chunk-G4CRHJNT.js → chunk-R2KYP3AT.js} +2 -2
  72. package/dist/chunks/{chunk-5EV5IK2Z.js → chunk-R7TYDKKC.js} +4 -4
  73. package/dist/chunks/{chunk-QYKOUCC2.js → chunk-RR3ASZMK.js} +3 -3
  74. package/dist/chunks/{chunk-QC7GZD65.js → chunk-SLRBCV4D.js} +2 -2
  75. package/dist/chunks/{chunk-RR4EGG5X.js → chunk-SMJQ7LVL.js} +2 -2
  76. package/dist/chunks/{chunk-WLFOCFXF.js → chunk-SR32C4A7.js} +3 -3
  77. package/dist/chunks/{chunk-PKJBQHH4.js → chunk-TP62BP32.js} +9 -9
  78. package/dist/chunks/{chunk-HIQP3VW2.js → chunk-USIRIOSH.js} +7 -6
  79. package/dist/chunks/chunk-USIRIOSH.js.map +6 -0
  80. package/dist/chunks/{chunk-6U2A23ZF.js → chunk-UZX4K743.js} +3 -3
  81. package/dist/chunks/{chunk-XEOK46KB.js → chunk-VJAVIDVB.js} +4 -4
  82. package/dist/chunks/{chunk-NUE3KLZZ.js → chunk-W3M3UGWQ.js} +4 -4
  83. package/dist/chunks/{chunk-NYVB7FXR.js → chunk-WI5ADHTS.js} +2 -2
  84. package/dist/chunks/{chunk-5LA7JXET.js → chunk-WX6B7RLT.js} +2 -2
  85. package/dist/chunks/{chunk-7YN3AIGW.js → chunk-XK4ANTIO.js} +20 -27
  86. package/dist/chunks/chunk-XK4ANTIO.js.map +6 -0
  87. package/dist/chunks/{chunk-RGDAXLFK.js → chunk-XKRU6FOU.js} +3 -3
  88. package/dist/chunks/{chunk-DJBMH64L.js → chunk-Y34RP2OI.js} +6 -6
  89. package/dist/chunks/{chunk-FILKHWTR.js → chunk-YFKC2GZP.js} +4 -4
  90. package/dist/chunks/{chunk-3U4NIDHY.js → chunk-YJPHE4O3.js} +5 -5
  91. package/dist/chunks/{chunk-3XNDGHLQ.js → chunk-YJYFQW2F.js} +3 -3
  92. package/dist/chunks/{chunk-Y7B67G22.js → chunk-YMWHDGCW.js} +5 -1
  93. package/dist/chunks/chunk-YMWHDGCW.js.map +6 -0
  94. package/dist/chunks/{chunk-WUNYN6NP.js → chunk-YNJ3SWIL.js} +4 -4
  95. package/dist/chunks/{chunk-F3XIXEHW.js → chunk-YPKTYCDZ.js} +4 -4
  96. package/dist/chunks/{chunk-FINB6Z5M.js → chunk-YW3GNCCK.js} +3 -3
  97. package/dist/chunks/{chunk-F27BEK5J.js → chunk-YYLILI2G.js} +2 -2
  98. package/dist/chunks/{chunk-ZQ25EYMP.js → chunk-ZBLTMOOD.js} +2 -2
  99. package/dist/chunks/{chunk-VOPYXSBT.js → chunk-ZFBUNTJO.js} +3 -3
  100. package/dist/chunks/{chunk-ZOBRME5K.js → chunk-ZLQ5BZ4X.js} +18 -2
  101. package/dist/chunks/chunk-ZLQ5BZ4X.js.map +6 -0
  102. package/dist/chunks/{chunk-KRMDJQ4R.js → chunk-ZP4KWNIL.js} +13 -13
  103. package/dist/chunks/{cli-runtime-FANRE6WO.js → cli-runtime-EDDXHFSX.js} +14 -11
  104. package/dist/chunks/cli-runtime-EDDXHFSX.js.map +6 -0
  105. package/dist/chunks/{commands-NVJNY4NX.js → commands-KESYD3SM.js} +6 -6
  106. package/dist/chunks/{computer-GXDY4H35.js → computer-UE2AN7NW.js} +2 -2
  107. package/dist/chunks/{crash-report-36PQYTVT.js → crash-report-JRRCPLE7.js} +6 -6
  108. package/dist/chunks/{dist-ZQQIBMSH.js → dist-7V7KU2WK.js} +126 -10
  109. package/dist/chunks/dist-7V7KU2WK.js.map +6 -0
  110. package/dist/chunks/{dist-3RJDVE7Q.js → dist-DLVIWPSW.js} +2 -2
  111. package/dist/chunks/{dist-LVHVXOTN.js → dist-EGALCLMC.js} +2 -2
  112. package/dist/chunks/{dist-NSCCQGTM.js → dist-F3BMUZ3P.js} +2 -2
  113. package/dist/chunks/{dist-DLQ3LSAW.js → dist-GZSRTUES.js} +2 -2
  114. package/dist/chunks/{dist-QZ727W5D.js → dist-IEWJJJHL.js} +4 -2
  115. package/dist/chunks/{dist-US3P32VD.js → dist-ML6MP7J3.js} +2 -2
  116. package/dist/chunks/{dist-UWF7KNT4.js → dist-XUIAXPXU.js} +2 -2
  117. package/dist/chunks/{doctor-26PQNJ5S.js → doctor-URLWCDCG.js} +17 -17
  118. package/dist/chunks/{drain-DV4J6KCT.js → drain-XYBMXTKG.js} +11 -11
  119. package/dist/chunks/{entry-GCKBXU7M.js → entry-BTK3MMFH.js} +6 -6
  120. package/dist/chunks/{eval-WBDZ2D6C.js → eval-SS6TIGOD.js} +2 -2
  121. package/dist/chunks/{exec-PIS2ZG7N.js → exec-MGDFWPM2.js} +41 -40
  122. package/dist/chunks/exec-MGDFWPM2.js.map +6 -0
  123. package/dist/chunks/{github-PRKZKRWW.js → github-VS24TC5M.js} +2 -2
  124. package/dist/chunks/{home-C7N5MVA3.js → home-PPWVKIU6.js} +3 -3
  125. package/dist/chunks/{host-Z4PQXKYU.js → host-RHMJMJAH.js} +10 -10
  126. package/dist/chunks/{host-queries-FVOBWLMN.js → host-queries-DUR62LWA.js} +15 -15
  127. package/dist/chunks/{learn-MRAYMRYD.js → learn-AF7N7BLO.js} +12 -12
  128. package/dist/chunks/{learn-builtin-RFYJXVQP.js → learn-builtin-J7GKFBXU.js} +15 -15
  129. package/dist/chunks/{lifecycle-ZIS6VGCP.js → lifecycle-RGXBSC3L.js} +30 -30
  130. package/dist/chunks/{list-YA4TQIYK.js → list-YOLX5SWE.js} +13 -12
  131. package/dist/chunks/list-YOLX5SWE.js.map +6 -0
  132. package/dist/chunks/{live-H73CD2SQ.js → live-RVNUQYAY.js} +15 -15
  133. package/dist/chunks/{login-3COTV7E2.js → login-RFNV3I7R.js} +14 -14
  134. package/dist/chunks/{logs-F5A43MAN.js → logs-RTREGKV5.js} +5 -5
  135. package/dist/chunks/{mcp-VIYXZ75T.js → mcp-SPQQPLJE.js} +22 -22
  136. package/dist/chunks/{message-command-SICLMEQR.js → message-command-E7V5KLFO.js} +44 -43
  137. package/dist/chunks/message-command-E7V5KLFO.js.map +6 -0
  138. package/dist/chunks/{open-TW55TLQU.js → open-P43XO4HN.js} +8 -8
  139. package/dist/chunks/{operator-tools-72O5UTU7.js → operator-tools-O43OOXJJ.js} +13 -13
  140. package/dist/chunks/{output-schema-KJRO6XW4.js → output-schema-HQ37VOZT.js} +3 -3
  141. package/dist/chunks/{pal-SI54TM7M.js → pal-24C6YOEW.js} +17 -17
  142. package/dist/chunks/{peers-2ZGIYBG6.js → peers-722AUQGX.js} +6 -6
  143. package/dist/chunks/peers-IPO7XN5V.js +417 -0
  144. package/dist/chunks/peers-IPO7XN5V.js.map +6 -0
  145. package/dist/chunks/{providers-IDK7PSD7.js → providers-5OKXU3AF.js} +11 -11
  146. package/dist/chunks/{pty-E3JYXJVK.js → pty-2YQ4ASHS.js} +3 -3
  147. package/dist/chunks/resume-IP4SVMRZ.js +23 -0
  148. package/dist/chunks/{resume-command-6X7E3EWS.js → resume-command-SGKIUUR7.js} +4 -4
  149. package/dist/chunks/{schedule-HDB2HQ5B.js → schedule-6JFYGG2R.js} +9 -9
  150. package/dist/chunks/{service-L4YBQA43.js → service-WJ5VNXQ5.js} +30 -30
  151. package/dist/chunks/{skills-5X6HJD3P.js → skills-PCETONZ5.js} +9 -9
  152. package/dist/chunks/{start-check-GZNLUM5K.js → start-check-UJOG3VAS.js} +2 -2
  153. package/dist/chunks/{startup-failure-7VVRANSQ.js → startup-failure-Q5I6S7KQ.js} +2 -2
  154. package/dist/chunks/{state-ACRKR6MN.js → state-NUXXHBA5.js} +3 -3
  155. package/dist/chunks/{store-EWFTHK64.js → store-3R5KTEP5.js} +6 -6
  156. package/dist/chunks/{store-WBNQQLWE.js → store-A2RYRTI6.js} +3 -3
  157. package/dist/chunks/{store-Z3DPT7U5.js → store-KO52OXSR.js} +4 -4
  158. package/dist/chunks/{store-MFJOJI64.js → store-XO6CFKZI.js} +10 -10
  159. package/dist/chunks/{tui-5LWJ4L7M.js → tui-AAB7734Z.js} +2720 -1293
  160. package/dist/chunks/tui-AAB7734Z.js.map +6 -0
  161. package/dist/chunks/{upgrade-WOZHZGTO.js → upgrade-NPINYN5F.js} +10 -10
  162. package/dist/chunks/{upgrade-WOZHZGTO.js.map → upgrade-NPINYN5F.js.map} +1 -1
  163. package/dist/chunks/{workspaces-PIEP6ESF.js → workspaces-BGRV6TQ6.js} +16 -16
  164. package/dist/chunks/{worktree-3LUC7G77.js → worktree-5LYQWD4H.js} +13 -13
  165. package/dist/cli.d.ts.map +1 -1
  166. package/dist/commands/manifest.d.ts +1 -0
  167. package/dist/commands/manifest.d.ts.map +1 -1
  168. package/dist/commands/peer-input.d.ts +20 -0
  169. package/dist/commands/peer-input.d.ts.map +1 -0
  170. package/dist/commands/peers.d.ts +23 -0
  171. package/dist/commands/peers.d.ts.map +1 -0
  172. package/dist/config/load.d.ts +1 -1
  173. package/dist/config/load.d.ts.map +1 -1
  174. package/dist/config/schema.d.ts +17 -0
  175. package/dist/config/schema.d.ts.map +1 -1
  176. package/dist/context/file-placement.d.ts +11 -0
  177. package/dist/context/file-placement.d.ts.map +1 -0
  178. package/dist/context/system-prompt.d.ts +5 -0
  179. package/dist/context/system-prompt.d.ts.map +1 -1
  180. package/dist/exit-codes.d.ts +4 -0
  181. package/dist/exit-codes.d.ts.map +1 -1
  182. package/dist/index.js +22 -22
  183. package/dist/integrations/auto-update/apply.d.ts +10 -4
  184. package/dist/integrations/auto-update/apply.d.ts.map +1 -1
  185. package/dist/integrations/decision/connection.d.ts +89 -0
  186. package/dist/integrations/decision/connection.d.ts.map +1 -0
  187. package/dist/integrations/decision/model.d.ts +21 -8
  188. package/dist/integrations/decision/model.d.ts.map +1 -1
  189. package/dist/integrations/decision/openrouter.d.ts +68 -0
  190. package/dist/integrations/decision/openrouter.d.ts.map +1 -0
  191. package/dist/integrations/decision/paste.d.ts +19 -0
  192. package/dist/integrations/decision/paste.d.ts.map +1 -0
  193. package/dist/integrations/decision/setup.d.ts +62 -0
  194. package/dist/integrations/decision/setup.d.ts.map +1 -0
  195. package/dist/integrations/decision/token.d.ts +34 -0
  196. package/dist/integrations/decision/token.d.ts.map +1 -0
  197. package/dist/integrations/peers/runtime.d.ts.map +1 -1
  198. package/dist/integrations/peers/send-once.d.ts +44 -0
  199. package/dist/integrations/peers/send-once.d.ts.map +1 -0
  200. package/dist/integrations/providers/credential-store.d.ts +6 -0
  201. package/dist/integrations/providers/credential-store.d.ts.map +1 -1
  202. package/dist/integrations/providers/discover.d.ts.map +1 -1
  203. package/dist/memory/curation-runtime.d.ts +8 -1
  204. package/dist/memory/curation-runtime.d.ts.map +1 -1
  205. package/dist/memory/lifecycle.d.ts +62 -0
  206. package/dist/memory/lifecycle.d.ts.map +1 -0
  207. package/dist/memory/manage.d.ts +37 -2
  208. package/dist/memory/manage.d.ts.map +1 -1
  209. package/dist/memory/sweep.d.ts +66 -0
  210. package/dist/memory/sweep.d.ts.map +1 -0
  211. package/dist/memory/usage.d.ts +79 -0
  212. package/dist/memory/usage.d.ts.map +1 -0
  213. package/dist/tui/App.d.ts +33 -0
  214. package/dist/tui/App.d.ts.map +1 -1
  215. package/dist/tui/StatusBar.d.ts +5 -1
  216. package/dist/tui/StatusBar.d.ts.map +1 -1
  217. package/dist/tui/ViewportBound.d.ts +8 -1
  218. package/dist/tui/ViewportBound.d.ts.map +1 -1
  219. package/dist/tui/agent.d.ts +10 -2
  220. package/dist/tui/agent.d.ts.map +1 -1
  221. package/dist/tui/decision-setup-flow.d.ts +57 -0
  222. package/dist/tui/decision-setup-flow.d.ts.map +1 -0
  223. package/dist/tui/fast-mode.d.ts +24 -0
  224. package/dist/tui/fast-mode.d.ts.map +1 -0
  225. package/dist/tui/fullscreen/FullscreenTranscript.d.ts +43 -0
  226. package/dist/tui/fullscreen/FullscreenTranscript.d.ts.map +1 -0
  227. package/dist/tui/fullscreen/layout.d.ts +31 -0
  228. package/dist/tui/fullscreen/layout.d.ts.map +1 -0
  229. package/dist/tui/fullscreen/mode.d.ts +21 -0
  230. package/dist/tui/fullscreen/mode.d.ts.map +1 -0
  231. package/dist/tui/fullscreen/mouse-wheel.d.ts +44 -0
  232. package/dist/tui/fullscreen/mouse-wheel.d.ts.map +1 -0
  233. package/dist/tui/fullscreen/viewport.d.ts +105 -0
  234. package/dist/tui/fullscreen/viewport.d.ts.map +1 -0
  235. package/dist/tui/index.d.ts.map +1 -1
  236. package/dist/tui/launch-settings.d.ts +2 -0
  237. package/dist/tui/launch-settings.d.ts.map +1 -1
  238. package/dist/tui/model-refusal.d.ts +3 -1
  239. package/dist/tui/model-refusal.d.ts.map +1 -1
  240. package/dist/tui/slashCommands.d.ts +9 -0
  241. package/dist/tui/slashCommands.d.ts.map +1 -1
  242. package/dist/tui/transcript-scroll.d.ts +13 -0
  243. package/dist/tui/transcript-scroll.d.ts.map +1 -1
  244. package/dist/tui/working-folder-notice.d.ts +9 -0
  245. package/dist/tui/working-folder-notice.d.ts.map +1 -0
  246. package/package.json +3 -3
  247. package/dist/chunks/acp-DK7NWANO.js.map +0 -6
  248. package/dist/chunks/agent-session-B4TDRJON.js +0 -68
  249. package/dist/chunks/chunk-554QWHL6.js.map +0 -6
  250. package/dist/chunks/chunk-7YN3AIGW.js.map +0 -6
  251. package/dist/chunks/chunk-A324JRGL.js.map +0 -6
  252. package/dist/chunks/chunk-CGHQCFUS.js.map +0 -6
  253. package/dist/chunks/chunk-HIQP3VW2.js.map +0 -6
  254. package/dist/chunks/chunk-IE43BX3W.js.map +0 -6
  255. package/dist/chunks/chunk-KL4RR7B2.js.map +0 -6
  256. package/dist/chunks/chunk-TYN5YUYW.js.map +0 -6
  257. package/dist/chunks/chunk-XORDVIA3.js.map +0 -6
  258. package/dist/chunks/chunk-XT5ZTOUV.js.map +0 -6
  259. package/dist/chunks/chunk-Y7B67G22.js.map +0 -6
  260. package/dist/chunks/chunk-ZOBRME5K.js.map +0 -6
  261. package/dist/chunks/cli-runtime-FANRE6WO.js.map +0 -6
  262. package/dist/chunks/dist-ZQQIBMSH.js.map +0 -6
  263. package/dist/chunks/exec-PIS2ZG7N.js.map +0 -6
  264. package/dist/chunks/list-YA4TQIYK.js.map +0 -6
  265. package/dist/chunks/message-command-SICLMEQR.js.map +0 -6
  266. package/dist/chunks/resume-MQKO2JL2.js +0 -23
  267. package/dist/chunks/tui-5LWJ4L7M.js.map +0 -6
  268. /package/dist/chunks/{activity-command-4KBMQECC.js.map → activity-command-J676MIML.js.map} +0 -0
  269. /package/dist/chunks/{add-62XIPWOO.js.map → add-LI4SX4YZ.js.map} +0 -0
  270. /package/dist/chunks/{agent-MBJAM4JS.js.map → agent-LUK4L4AW.js.map} +0 -0
  271. /package/dist/chunks/{agent-session-B4TDRJON.js.map → agent-session-5ZG6WNTC.js.map} +0 -0
  272. /package/dist/chunks/{archive-GKFLV2WT.js.map → archive-IZRS7P6C.js.map} +0 -0
  273. /package/dist/chunks/{bin-main-6JRUHZMN.js.map → bin-main-XNB6LHOP.js.map} +0 -0
  274. /package/dist/chunks/{binding-CWY25KUP.js.map → binding-3EE2IYAM.js.map} +0 -0
  275. /package/dist/chunks/{browser-RR45SAA5.js.map → browser-NI2ZPG4N.js.map} +0 -0
  276. /package/dist/chunks/{chat-A3D7JCSI.js.map → chat-5OEOFTSO.js.map} +0 -0
  277. /package/dist/chunks/{chunk-LRWJQU4R.js.map → chunk-2FMMT4JD.js.map} +0 -0
  278. /package/dist/chunks/{chunk-4GIMYVA3.js.map → chunk-2GBI7JYG.js.map} +0 -0
  279. /package/dist/chunks/{chunk-FQNYAUE4.js.map → chunk-43Q3E36I.js.map} +0 -0
  280. /package/dist/chunks/{chunk-4OB6KSBS.js.map → chunk-4ET34X7Z.js.map} +0 -0
  281. /package/dist/chunks/{chunk-PRCUNNM6.js.map → chunk-4GFWZYTR.js.map} +0 -0
  282. /package/dist/chunks/{chunk-POHZFIQB.js.map → chunk-4IYPPPIR.js.map} +0 -0
  283. /package/dist/chunks/{chunk-P4KL7PEP.js.map → chunk-564OI5HN.js.map} +0 -0
  284. /package/dist/chunks/{chunk-2PEBRNOT.js.map → chunk-56IRGZRX.js.map} +0 -0
  285. /package/dist/chunks/{chunk-U7RXQG6Z.js.map → chunk-5AQVWTHV.js.map} +0 -0
  286. /package/dist/chunks/{chunk-CRAV2EQ5.js.map → chunk-6TUISLKZ.js.map} +0 -0
  287. /package/dist/chunks/{chunk-3TR5UJ65.js.map → chunk-AOKRFS3Z.js.map} +0 -0
  288. /package/dist/chunks/{chunk-PKCR5ORA.js.map → chunk-BCFC5GGU.js.map} +0 -0
  289. /package/dist/chunks/{chunk-P36IISLH.js.map → chunk-BPW5AT4B.js.map} +0 -0
  290. /package/dist/chunks/{chunk-W3RVMJZC.js.map → chunk-CDOLJHIB.js.map} +0 -0
  291. /package/dist/chunks/{chunk-RWTKMA2O.js.map → chunk-CDT745GI.js.map} +0 -0
  292. /package/dist/chunks/{chunk-4ZVP3RG2.js.map → chunk-DKJHMWCA.js.map} +0 -0
  293. /package/dist/chunks/{chunk-TBGYJ7RC.js.map → chunk-E6XGUJ2I.js.map} +0 -0
  294. /package/dist/chunks/{chunk-JRAJ3WVY.js.map → chunk-EISC5X74.js.map} +0 -0
  295. /package/dist/chunks/{chunk-FHK74RKX.js.map → chunk-EPS5ROMN.js.map} +0 -0
  296. /package/dist/chunks/{chunk-FZ6XQ3PG.js.map → chunk-G4SE3TXK.js.map} +0 -0
  297. /package/dist/chunks/{chunk-QQ76RA5Y.js.map → chunk-GBRTN4AK.js.map} +0 -0
  298. /package/dist/chunks/{chunk-QO6TNEJ5.js.map → chunk-GCIBSVYX.js.map} +0 -0
  299. /package/dist/chunks/{chunk-KWTHQ7Z3.js.map → chunk-GEX2EXU3.js.map} +0 -0
  300. /package/dist/chunks/{chunk-MSR3JAA4.js.map → chunk-GXSMCKZJ.js.map} +0 -0
  301. /package/dist/chunks/{chunk-BU3K3A3C.js.map → chunk-HNBF54TV.js.map} +0 -0
  302. /package/dist/chunks/{chunk-65ZRHVSK.js.map → chunk-HUUVQBZR.js.map} +0 -0
  303. /package/dist/chunks/{chunk-JCFGOQEJ.js.map → chunk-HXV7TDNY.js.map} +0 -0
  304. /package/dist/chunks/{chunk-UWQE4YXM.js.map → chunk-KZNMCCYK.js.map} +0 -0
  305. /package/dist/chunks/{chunk-TUK5FMGP.js.map → chunk-L3VAFXRU.js.map} +0 -0
  306. /package/dist/chunks/{chunk-CF4GQ7DX.js.map → chunk-LJHHAKBL.js.map} +0 -0
  307. /package/dist/chunks/{chunk-BIYLO4OA.js.map → chunk-LNDECWNR.js.map} +0 -0
  308. /package/dist/chunks/{chunk-3VD5SYFR.js.map → chunk-LYSN3FIQ.js.map} +0 -0
  309. /package/dist/chunks/{chunk-DO7ISOWW.js.map → chunk-NJWCOR7Z.js.map} +0 -0
  310. /package/dist/chunks/{chunk-LB4PI7W2.js.map → chunk-OOWGXPY2.js.map} +0 -0
  311. /package/dist/chunks/{chunk-MAXR2ZGX.js.map → chunk-P2CHZ6FL.js.map} +0 -0
  312. /package/dist/chunks/{chunk-IJVO3ADL.js.map → chunk-P3KXW262.js.map} +0 -0
  313. /package/dist/chunks/{chunk-TONATYGN.js.map → chunk-P7YVC6KA.js.map} +0 -0
  314. /package/dist/chunks/{chunk-GFI4VC4I.js.map → chunk-PVCJHQP5.js.map} +0 -0
  315. /package/dist/chunks/{chunk-HSBF2FOJ.js.map → chunk-QUKAQLNS.js.map} +0 -0
  316. /package/dist/chunks/{chunk-G4CRHJNT.js.map → chunk-R2KYP3AT.js.map} +0 -0
  317. /package/dist/chunks/{chunk-5EV5IK2Z.js.map → chunk-R7TYDKKC.js.map} +0 -0
  318. /package/dist/chunks/{chunk-QYKOUCC2.js.map → chunk-RR3ASZMK.js.map} +0 -0
  319. /package/dist/chunks/{chunk-QC7GZD65.js.map → chunk-SLRBCV4D.js.map} +0 -0
  320. /package/dist/chunks/{chunk-RR4EGG5X.js.map → chunk-SMJQ7LVL.js.map} +0 -0
  321. /package/dist/chunks/{chunk-WLFOCFXF.js.map → chunk-SR32C4A7.js.map} +0 -0
  322. /package/dist/chunks/{chunk-PKJBQHH4.js.map → chunk-TP62BP32.js.map} +0 -0
  323. /package/dist/chunks/{chunk-6U2A23ZF.js.map → chunk-UZX4K743.js.map} +0 -0
  324. /package/dist/chunks/{chunk-XEOK46KB.js.map → chunk-VJAVIDVB.js.map} +0 -0
  325. /package/dist/chunks/{chunk-NUE3KLZZ.js.map → chunk-W3M3UGWQ.js.map} +0 -0
  326. /package/dist/chunks/{chunk-NYVB7FXR.js.map → chunk-WI5ADHTS.js.map} +0 -0
  327. /package/dist/chunks/{chunk-5LA7JXET.js.map → chunk-WX6B7RLT.js.map} +0 -0
  328. /package/dist/chunks/{chunk-RGDAXLFK.js.map → chunk-XKRU6FOU.js.map} +0 -0
  329. /package/dist/chunks/{chunk-DJBMH64L.js.map → chunk-Y34RP2OI.js.map} +0 -0
  330. /package/dist/chunks/{chunk-FILKHWTR.js.map → chunk-YFKC2GZP.js.map} +0 -0
  331. /package/dist/chunks/{chunk-3U4NIDHY.js.map → chunk-YJPHE4O3.js.map} +0 -0
  332. /package/dist/chunks/{chunk-3XNDGHLQ.js.map → chunk-YJYFQW2F.js.map} +0 -0
  333. /package/dist/chunks/{chunk-WUNYN6NP.js.map → chunk-YNJ3SWIL.js.map} +0 -0
  334. /package/dist/chunks/{chunk-F3XIXEHW.js.map → chunk-YPKTYCDZ.js.map} +0 -0
  335. /package/dist/chunks/{chunk-FINB6Z5M.js.map → chunk-YW3GNCCK.js.map} +0 -0
  336. /package/dist/chunks/{chunk-F27BEK5J.js.map → chunk-YYLILI2G.js.map} +0 -0
  337. /package/dist/chunks/{chunk-ZQ25EYMP.js.map → chunk-ZBLTMOOD.js.map} +0 -0
  338. /package/dist/chunks/{chunk-VOPYXSBT.js.map → chunk-ZFBUNTJO.js.map} +0 -0
  339. /package/dist/chunks/{chunk-KRMDJQ4R.js.map → chunk-ZP4KWNIL.js.map} +0 -0
  340. /package/dist/chunks/{commands-NVJNY4NX.js.map → commands-KESYD3SM.js.map} +0 -0
  341. /package/dist/chunks/{computer-GXDY4H35.js.map → computer-UE2AN7NW.js.map} +0 -0
  342. /package/dist/chunks/{crash-report-36PQYTVT.js.map → crash-report-JRRCPLE7.js.map} +0 -0
  343. /package/dist/chunks/{dist-3RJDVE7Q.js.map → dist-DLVIWPSW.js.map} +0 -0
  344. /package/dist/chunks/{dist-LVHVXOTN.js.map → dist-EGALCLMC.js.map} +0 -0
  345. /package/dist/chunks/{dist-NSCCQGTM.js.map → dist-F3BMUZ3P.js.map} +0 -0
  346. /package/dist/chunks/{dist-DLQ3LSAW.js.map → dist-GZSRTUES.js.map} +0 -0
  347. /package/dist/chunks/{dist-QZ727W5D.js.map → dist-IEWJJJHL.js.map} +0 -0
  348. /package/dist/chunks/{dist-US3P32VD.js.map → dist-ML6MP7J3.js.map} +0 -0
  349. /package/dist/chunks/{dist-UWF7KNT4.js.map → dist-XUIAXPXU.js.map} +0 -0
  350. /package/dist/chunks/{doctor-26PQNJ5S.js.map → doctor-URLWCDCG.js.map} +0 -0
  351. /package/dist/chunks/{drain-DV4J6KCT.js.map → drain-XYBMXTKG.js.map} +0 -0
  352. /package/dist/chunks/{entry-GCKBXU7M.js.map → entry-BTK3MMFH.js.map} +0 -0
  353. /package/dist/chunks/{eval-WBDZ2D6C.js.map → eval-SS6TIGOD.js.map} +0 -0
  354. /package/dist/chunks/{github-PRKZKRWW.js.map → github-VS24TC5M.js.map} +0 -0
  355. /package/dist/chunks/{home-C7N5MVA3.js.map → home-PPWVKIU6.js.map} +0 -0
  356. /package/dist/chunks/{host-Z4PQXKYU.js.map → host-RHMJMJAH.js.map} +0 -0
  357. /package/dist/chunks/{host-queries-FVOBWLMN.js.map → host-queries-DUR62LWA.js.map} +0 -0
  358. /package/dist/chunks/{learn-MRAYMRYD.js.map → learn-AF7N7BLO.js.map} +0 -0
  359. /package/dist/chunks/{learn-builtin-RFYJXVQP.js.map → learn-builtin-J7GKFBXU.js.map} +0 -0
  360. /package/dist/chunks/{lifecycle-ZIS6VGCP.js.map → lifecycle-RGXBSC3L.js.map} +0 -0
  361. /package/dist/chunks/{live-H73CD2SQ.js.map → live-RVNUQYAY.js.map} +0 -0
  362. /package/dist/chunks/{login-3COTV7E2.js.map → login-RFNV3I7R.js.map} +0 -0
  363. /package/dist/chunks/{logs-F5A43MAN.js.map → logs-RTREGKV5.js.map} +0 -0
  364. /package/dist/chunks/{mcp-VIYXZ75T.js.map → mcp-SPQQPLJE.js.map} +0 -0
  365. /package/dist/chunks/{open-TW55TLQU.js.map → open-P43XO4HN.js.map} +0 -0
  366. /package/dist/chunks/{operator-tools-72O5UTU7.js.map → operator-tools-O43OOXJJ.js.map} +0 -0
  367. /package/dist/chunks/{output-schema-KJRO6XW4.js.map → output-schema-HQ37VOZT.js.map} +0 -0
  368. /package/dist/chunks/{pal-SI54TM7M.js.map → pal-24C6YOEW.js.map} +0 -0
  369. /package/dist/chunks/{peers-2ZGIYBG6.js.map → peers-722AUQGX.js.map} +0 -0
  370. /package/dist/chunks/{providers-IDK7PSD7.js.map → providers-5OKXU3AF.js.map} +0 -0
  371. /package/dist/chunks/{pty-E3JYXJVK.js.map → pty-2YQ4ASHS.js.map} +0 -0
  372. /package/dist/chunks/{resume-MQKO2JL2.js.map → resume-IP4SVMRZ.js.map} +0 -0
  373. /package/dist/chunks/{resume-command-6X7E3EWS.js.map → resume-command-SGKIUUR7.js.map} +0 -0
  374. /package/dist/chunks/{schedule-HDB2HQ5B.js.map → schedule-6JFYGG2R.js.map} +0 -0
  375. /package/dist/chunks/{service-L4YBQA43.js.map → service-WJ5VNXQ5.js.map} +0 -0
  376. /package/dist/chunks/{skills-5X6HJD3P.js.map → skills-PCETONZ5.js.map} +0 -0
  377. /package/dist/chunks/{start-check-GZNLUM5K.js.map → start-check-UJOG3VAS.js.map} +0 -0
  378. /package/dist/chunks/{startup-failure-7VVRANSQ.js.map → startup-failure-Q5I6S7KQ.js.map} +0 -0
  379. /package/dist/chunks/{state-ACRKR6MN.js.map → state-NUXXHBA5.js.map} +0 -0
  380. /package/dist/chunks/{store-EWFTHK64.js.map → store-3R5KTEP5.js.map} +0 -0
  381. /package/dist/chunks/{store-MFJOJI64.js.map → store-A2RYRTI6.js.map} +0 -0
  382. /package/dist/chunks/{store-WBNQQLWE.js.map → store-KO52OXSR.js.map} +0 -0
  383. /package/dist/chunks/{store-Z3DPT7U5.js.map → store-XO6CFKZI.js.map} +0 -0
  384. /package/dist/chunks/{workspaces-PIEP6ESF.js.map → workspaces-BGRV6TQ6.js.map} +0 -0
  385. /package/dist/chunks/{worktree-3LUC7G77.js.map → worktree-5LYQWD4H.js.map} +0 -0
@@ -2,10 +2,10 @@ import { createRequire as __namzuCreateRequire } from 'node:module';
2
2
  const require = __namzuCreateRequire(import.meta.url);
3
3
  import {
4
4
  openManagedWorktrees
5
- } from "./chunk-QO6TNEJ5.js";
5
+ } from "./chunk-GCIBSVYX.js";
6
6
  import {
7
7
  createSessionSkillCatalog
8
- } from "./chunk-6U2A23ZF.js";
8
+ } from "./chunk-UZX4K743.js";
9
9
  import {
10
10
  KEY_MISMATCH_MESSAGE,
11
11
  MAX_SCRIPT_BYTES,
@@ -36,37 +36,35 @@ import {
36
36
  workflowJournalKey,
37
37
  workingDirectoryProblem,
38
38
  writeEditableCopy
39
- } from "./chunk-FINB6Z5M.js";
39
+ } from "./chunk-YW3GNCCK.js";
40
40
  import {
41
41
  runGeneratorCycle
42
- } from "./chunk-TBGYJ7RC.js";
42
+ } from "./chunk-E6XGUJ2I.js";
43
43
  import {
44
44
  createSessionLearningFeed,
45
45
  openLearningTarget,
46
46
  readProjectGuidance,
47
47
  withSessionLearningFeed
48
- } from "./chunk-5EV5IK2Z.js";
48
+ } from "./chunk-R7TYDKKC.js";
49
49
  import {
50
50
  connectMcpServers,
51
51
  startMcpServers
52
- } from "./chunk-WUNYN6NP.js";
52
+ } from "./chunk-YNJ3SWIL.js";
53
53
  import {
54
54
  openInBrowser
55
- } from "./chunk-JRAJ3WVY.js";
55
+ } from "./chunk-EISC5X74.js";
56
+ import {
57
+ conversationInUseSentence,
58
+ minutesUntilFree
59
+ } from "./chunk-YJYFQW2F.js";
56
60
  import {
57
61
  ensureLocalConfigIgnored,
58
- isPermissionMode,
59
62
  logIgnoreOutcome,
60
- permissionModeLabel,
61
63
  writeLocalAllows
62
- } from "./chunk-A324JRGL.js";
64
+ } from "./chunk-MCTUVMMB.js";
63
65
  import {
64
66
  createBrowserControl
65
67
  } from "./chunk-WHODOMXA.js";
66
- import {
67
- conversationInUseSentence,
68
- minutesUntilFree
69
- } from "./chunk-3XNDGHLQ.js";
70
68
  import {
71
69
  accountProductName
72
70
  } from "./chunk-YOWYTBJS.js";
@@ -74,16 +72,20 @@ import {
74
72
  diffColors,
75
73
  theme
76
74
  } from "./chunk-2IPDTDB3.js";
75
+ import {
76
+ isPermissionMode,
77
+ permissionModeLabel
78
+ } from "./chunk-7DSJTL5S.js";
77
79
  import {
78
80
  discoverSkills,
79
81
  loadSkillBody
80
- } from "./chunk-MAXR2ZGX.js";
82
+ } from "./chunk-P2CHZ6FL.js";
81
83
  import {
82
84
  migrateAccountKeys
83
- } from "./chunk-3U4NIDHY.js";
85
+ } from "./chunk-YJPHE4O3.js";
84
86
  import {
85
87
  openCliAccounts
86
- } from "./chunk-BU3K3A3C.js";
88
+ } from "./chunk-HNBF54TV.js";
87
89
  import {
88
90
  CredentialRefreshRejectedError,
89
91
  CredentialWithdrawnError as CredentialWithdrawnError2,
@@ -91,16 +93,16 @@ import {
91
93
  ensureFreshStoredCodexCredential,
92
94
  readSubscriptionCredential,
93
95
  sameOAuthCredential
94
- } from "./chunk-POHZFIQB.js";
96
+ } from "./chunk-4IYPPPIR.js";
95
97
  import {
96
98
  conversationLogPath,
97
99
  ensureSessionStarted,
98
100
  openConversationLog,
99
101
  recordAccountBound
100
- } from "./chunk-DJBMH64L.js";
102
+ } from "./chunk-Y34RP2OI.js";
101
103
  import {
102
104
  readIdentity
103
- } from "./chunk-MSR3JAA4.js";
105
+ } from "./chunk-GXSMCKZJ.js";
104
106
  import {
105
107
  INSTRUCTIONS_FILENAME,
106
108
  MAX_CHARS_PER_FILE,
@@ -111,12 +113,15 @@ import {
111
113
  } from "./chunk-JQIBPPOL.js";
112
114
  import {
113
115
  isDefaultAccountId
114
- } from "./chunk-4OB6KSBS.js";
116
+ } from "./chunk-4ET34X7Z.js";
117
+ import {
118
+ debugRequested
119
+ } from "./chunk-GNBMKISG.js";
115
120
  import {
116
121
  createLazyCodeAnalysis,
117
122
  promptCacheTtl,
118
123
  setPromptCacheTtl
119
- } from "./chunk-VOPYXSBT.js";
124
+ } from "./chunk-ZFBUNTJO.js";
120
125
  import {
121
126
  probeCapabilities
122
127
  } from "./chunk-OH6TB27S.js";
@@ -124,12 +129,13 @@ import {
124
129
  LOCAL_CONFIG_FILE,
125
130
  configuredPassthroughTools,
126
131
  parseTokenTarget,
132
+ readBoundDecisionKey,
127
133
  resolveToolResultScreens,
128
134
  sessionWorkflowSizeAdvice,
129
135
  takeConfigWarnings,
130
136
  unmatchedPassthroughTools,
131
137
  workflowTokenCeiling
132
- } from "./chunk-IE43BX3W.js";
138
+ } from "./chunk-6CZOIEKE.js";
133
139
  import {
134
140
  require_dist
135
141
  } from "./chunk-KONYGNG6.js";
@@ -138,25 +144,22 @@ import {
138
144
  } from "./chunk-LCGXWCVU.js";
139
145
  import {
140
146
  compilePermissions
141
- } from "./chunk-UWQE4YXM.js";
142
- import {
143
- PERMISSION_MODE_NAMES
144
- } from "./chunk-WMEZTDLT.js";
147
+ } from "./chunk-KZNMCCYK.js";
145
148
  import {
146
149
  cliLogger
147
- } from "./chunk-IJVO3ADL.js";
150
+ } from "./chunk-P3KXW262.js";
148
151
  import {
149
152
  readModelLaunchEnvironment
150
153
  } from "./chunk-LVVD32KJ.js";
151
- import {
152
- debugRequested
153
- } from "./chunk-GNBMKISG.js";
154
154
  import {
155
155
  formatSize,
156
156
  homePath,
157
157
  plural,
158
158
  productName
159
159
  } from "./chunk-6PWRKA5T.js";
160
+ import {
161
+ PERMISSION_MODE_NAMES
162
+ } from "./chunk-WMEZTDLT.js";
160
163
  import {
161
164
  stringWidth
162
165
  } from "./chunk-U5UV2YRE.js";
@@ -171,7 +174,7 @@ import {
171
174
  readPreferences,
172
175
  resolveChainCapabilities,
173
176
  unresolvedMembers
174
- } from "./chunk-PKCR5ORA.js";
177
+ } from "./chunk-BCFC5GGU.js";
175
178
  import {
176
179
  canSelectModel,
177
180
  createGeminiAccessTokenResolver,
@@ -179,7 +182,7 @@ import {
179
182
  findDetected,
180
183
  hasApiCredential,
181
184
  requiresCredentialForModel
182
- } from "./chunk-HIQP3VW2.js";
185
+ } from "./chunk-USIRIOSH.js";
183
186
  import {
184
187
  activeZenCatalogue,
185
188
  isOfferableModel
@@ -192,23 +195,23 @@ import {
192
195
  import {
193
196
  isAnthropicOAuthToken,
194
197
  readCodexCredentialFile
195
- } from "./chunk-LRWJQU4R.js";
198
+ } from "./chunk-2FMMT4JD.js";
196
199
  import {
197
200
  composeEnvironmentPrompt,
198
201
  detectWsl,
199
202
  environmentFactLines,
200
203
  permissionSentence,
201
204
  readEnvironmentFacts
202
- } from "./chunk-F27BEK5J.js";
205
+ } from "./chunk-YYLILI2G.js";
203
206
  import {
204
207
  ensurePrivateStateDirectory
205
- } from "./chunk-JCFGOQEJ.js";
208
+ } from "./chunk-HXV7TDNY.js";
206
209
  import {
207
210
  restrictToOwner
208
- } from "./chunk-ZOBRME5K.js";
211
+ } from "./chunk-ZLQ5BZ4X.js";
209
212
  import {
210
213
  namzuHomePath
211
- } from "./chunk-U7RXQG6Z.js";
214
+ } from "./chunk-5AQVWTHV.js";
212
215
  import {
213
216
  AgentManager,
214
217
  AgentRegistry,
@@ -394,7 +397,7 @@ import {
394
397
  withModelWindowSuffixStripped,
395
398
  withProviderFallback,
396
399
  wrapUntrusted
397
- } from "./chunk-XT5ZTOUV.js";
400
+ } from "./chunk-4WFAYG6V.js";
398
401
  import {
399
402
  __name,
400
403
  __toESM
@@ -901,8 +904,8 @@ function describeCapabilityNotice(input) {
901
904
  __name(describeCapabilityNotice, "describeCapabilityNotice");
902
905
  function describeHistoryRepairNotice(input) {
903
906
  if (input.source === "provider-rejected-image") {
904
- const count = input.rejectedImages ?? 0;
905
- const what = count > 1 ? `${count.toLocaleString("en-US")} pictures you attached` : "a picture you attached";
907
+ const count2 = input.rejectedImages ?? 0;
908
+ const what = count2 > 1 ? `${count2.toLocaleString("en-US")} pictures you attached` : "a picture you attached";
906
909
  const name = productName(input.providerId);
907
910
  return name ? `${name} didn\u2019t accept ${what}. Namzu kept the file but will leave it out of later messages. Attach a corrected copy to try again.` : `${what.charAt(0).toUpperCase()}${what.slice(1)} wasn\u2019t accepted. Namzu kept the file but will leave it out of later messages. Attach a corrected copy to try again.`;
908
911
  }
@@ -1370,7 +1373,7 @@ function diffViewBody(info, options) {
1370
1373
  const limit = options.expanded || info.preview === void 0 ? all.length : info.preview;
1371
1374
  const shown = all.slice(0, limit);
1372
1375
  const carried = info.hunks.reduce(
1373
- (count, hunk) => count + hunk.lines.filter((line) => line.startsWith("+")).length,
1376
+ (count2, hunk) => count2 + hunk.lines.filter((line) => line.startsWith("+")).length,
1374
1377
  0
1375
1378
  );
1376
1379
  const missing2 = info.mode === "file" && info.truncated && info.added !== void 0 ? Math.max(0, info.added - carried) : 0;
@@ -1420,12 +1423,12 @@ function plainDiffRows(info) {
1420
1423
  return rows;
1421
1424
  }
1422
1425
  __name(plainDiffRows, "plainDiffRows");
1423
- function plural2(count, one, many) {
1424
- return count === 1 ? one : many;
1426
+ function plural2(count2, one, many) {
1427
+ return count2 === 1 ? one : many;
1425
1428
  }
1426
1429
  __name(plural2, "plural");
1427
- function bold(count) {
1428
- return { text: count.toLocaleString("en-US"), bold: true };
1430
+ function bold(count2) {
1431
+ return { text: count2.toLocaleString("en-US"), bold: true };
1429
1432
  }
1430
1433
  __name(bold, "bold");
1431
1434
  function editSummary(added, removed) {
@@ -1910,8 +1913,8 @@ function countListedResults(output) {
1910
1913
  const lines = output.split("\n");
1911
1914
  const numbered = lines.filter((line) => /^\s{0,3}\d+\.\s+\S/.test(line)).length;
1912
1915
  const addressed = lines.filter((line) => /^\s*URL:\s*\S/.test(line)).length;
1913
- const count = Math.max(numbered, addressed);
1914
- return count > 0 ? count : void 0;
1916
+ const count2 = Math.max(numbered, addressed);
1917
+ return count2 > 0 ? count2 : void 0;
1915
1918
  }
1916
1919
  __name(countListedResults, "countListedResults");
1917
1920
  var formatBytes = formatSize;
@@ -1964,7 +1967,7 @@ __name(screenApprover, "screenApprover");
1964
1967
 
1965
1968
  // src/tui/agent.ts
1966
1969
  import { realpath as realpath4, stat as stat6 } from "node:fs/promises";
1967
- import { join as join20, parse, resolve as resolve13 } from "node:path";
1970
+ import { join as join21, parse as parse2, resolve as resolve13 } from "node:path";
1968
1971
 
1969
1972
  // src/checkpoints/store.ts
1970
1973
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -3454,6 +3457,47 @@ function createSessionDirectories(cwd, directories) {
3454
3457
  }
3455
3458
  __name(createSessionDirectories, "createSessionDirectories");
3456
3459
 
3460
+ // src/context/file-placement.ts
3461
+ var PLATFORM_LINES = {
3462
+ linux: "- App data, config, caches, logs: ~/.config, ~/.local/share, ~/.local/state, ~/.cache. A system-wide service (as root): /opt/<app>, /etc/<app>, /var/lib/<app>, /var/log/<app>, run by systemd.",
3463
+ darwin: "- App data, config, caches, logs: ~/Library/Application Support, ~/Library/Caches, ~/Library/Logs. A system-wide service (as admin): /usr/local/<app> or /opt/<app>, a LaunchDaemon in /Library/LaunchDaemons.",
3464
+ win32: "- App data, config, caches, logs: %APPDATA% and %LOCALAPPDATA%. A system-wide service (as admin): Program Files and ProgramData, run as a Windows service."
3465
+ };
3466
+ var COMMON_LINES = [
3467
+ "- Temporary work: the session scratchpad, or the OS temp folder.",
3468
+ "- A container stack: its compose and config files in a dedicated, named project folder the person agrees to; its data in named volumes.",
3469
+ "- A repository the person will work on: their projects folder. Ask when you do not know it."
3470
+ ];
3471
+ var RULES = [
3472
+ "- Never create or delete a top-level entry in the home folder or the filesystem root without asking first, even when tools run without approval.",
3473
+ "- Tell the person the full path of every folder you create. Use `rm -rf` only on a path this session created and that you checked first.",
3474
+ "- A service, daemon, container stack or agent that keeps running is a service, not a terminal job. Run through this checklist:",
3475
+ " - Identity: a dedicated service account with no login, not the person\u2019s own account.",
3476
+ " - Configuration: /opt/<vendor>/<service> or /usr/local/..., owned by root (Windows: Program Files, ProgramData).",
3477
+ " - Data: /var/lib/<service> or a dedicated volume or disk (containers: named volumes).",
3478
+ " - Logs: /var/log/<service> or the system journal.",
3479
+ " - Supervisor: the system init (a systemd system unit, a LaunchDaemon that starts at boot, a Windows service), not a per-user agent or a terminal.",
3480
+ " - Secrets: a secret store or key manager; change default passwords before the service is reachable.",
3481
+ " - State: retention limits and backups, so data does not grow forever.",
3482
+ " - Monitoring: watch the service itself, so someone is told if it dies.",
3483
+ " - Host: a stable address on a server or VM, not a developer desktop or personal account. If it must run on a personal machine, say so as a limitation.",
3484
+ "- When the person\u2019s setup forces a deviation (no root, a personal machine), name each item that deviates and why.",
3485
+ "- When a setup finishes, give a short receipt: what was installed, where, how it starts, how to remove it."
3486
+ ];
3487
+ function composeFilePlacementGuidance(platform) {
3488
+ const platformLine = PLATFORM_LINES[platform === "darwin" || platform === "win32" ? platform : "linux"];
3489
+ return [
3490
+ "# Where files go",
3491
+ "Put what you create where this platform expects it:",
3492
+ COMMON_LINES[0],
3493
+ platformLine,
3494
+ COMMON_LINES[1],
3495
+ COMMON_LINES[2],
3496
+ ...RULES
3497
+ ].join("\n");
3498
+ }
3499
+ __name(composeFilePlacementGuidance, "composeFilePlacementGuidance");
3500
+
3457
3501
  // src/context/identity.ts
3458
3502
  var AGENT_LAUNCH_TOOL = "Agent";
3459
3503
  var bash = BashTool.name;
@@ -4925,6 +4969,7 @@ function sessionPromptInput(facts, turn) {
4925
4969
  conversationEvidence: facts.conversationSessions ? CONVERSATION_EVIDENCE_GUIDANCE : void 0,
4926
4970
  memoryGuidance: facts.memoryGuidance,
4927
4971
  shellEscapeGuidance: facts.shellEscapeGuidance,
4972
+ filePlacementGuidance: facts.filePlacementGuidance,
4928
4973
  toolsDeferred: facts.toolLoading === "deferred" || facts.anyToolDeferred,
4929
4974
  planInReminders: turn.planInReminders,
4930
4975
  permissionMode: turn.permissionMode,
@@ -4947,6 +4992,7 @@ function composeSessionSystemPrompt(input) {
4947
4992
  input.workflowOffered ? [WORKFLOW_DOCTRINE, input.workflowSizeAdvice].filter(Boolean).join("\n\n") : void 0,
4948
4993
  input.palBlock,
4949
4994
  input.conversationEvidence,
4995
+ input.filePlacementGuidance,
4950
4996
  input.memoryGuidance,
4951
4997
  input.shellEscapeGuidance,
4952
4998
  // Whenever anything is deferred: a deferred tool the model was never
@@ -5642,22 +5688,151 @@ function createDecisionTool(model, options = {}) {
5642
5688
  }
5643
5689
  __name(createDecisionTool, "createDecisionTool");
5644
5690
 
5691
+ // src/integrations/decision/token.ts
5692
+ import { execFile as execFile2 } from "node:child_process";
5693
+ import { existsSync } from "node:fs";
5694
+ import { delimiter, join as join6 } from "node:path";
5695
+ var AZURE_TOKEN_RESOURCE = "https://cognitiveservices.azure.com";
5696
+ var DEFAULT_TOKEN_ENV = "AZURE_FOUNDRY_TOKEN";
5697
+ var TOKEN_EARLY_EXPIRY_MS = 5 * 60 * 1e3;
5698
+ var AZ_TIMEOUT_MS = 15e3;
5699
+ function findAzOnPath(env) {
5700
+ const path = env.PATH ?? env.Path ?? "";
5701
+ const names = process.platform === "win32" ? ["az.cmd", "az.exe", "az.bat"] : ["az"];
5702
+ for (const dir of path.split(delimiter)) {
5703
+ if (!dir) continue;
5704
+ for (const name of names) {
5705
+ const candidate = join6(dir, name);
5706
+ if (existsSync(candidate)) return candidate;
5707
+ }
5708
+ }
5709
+ return void 0;
5710
+ }
5711
+ __name(findAzOnPath, "findAzOnPath");
5712
+ var defaultRunAz = /* @__PURE__ */ __name((command, args) => new Promise((resolve14, reject) => {
5713
+ execFile2(
5714
+ command,
5715
+ [...args],
5716
+ { timeout: AZ_TIMEOUT_MS, windowsHide: true, shell: process.platform === "win32" },
5717
+ (error, stdout) => error ? reject(error) : resolve14(stdout)
5718
+ );
5719
+ }), "defaultRunAz");
5720
+ function parseAzTokenOutput(output) {
5721
+ try {
5722
+ const parsed = JSON.parse(output);
5723
+ const token = parsed.accessToken;
5724
+ if (typeof token !== "string" || token.length === 0) return void 0;
5725
+ const epoch = parsed.expires_on;
5726
+ let expiresAt;
5727
+ if (typeof epoch === "number") expiresAt = epoch * 1e3;
5728
+ else if (typeof epoch === "string" && /^\d+$/.test(epoch)) expiresAt = Number(epoch) * 1e3;
5729
+ else if (typeof parsed.expiresOn === "string") {
5730
+ const ms = Date.parse(parsed.expiresOn.replace(" ", "T"));
5731
+ if (!Number.isNaN(ms)) expiresAt = ms;
5732
+ }
5733
+ return expiresAt === void 0 ? void 0 : { token, expiresAt };
5734
+ } catch {
5735
+ return void 0;
5736
+ }
5737
+ }
5738
+ __name(parseAzTokenOutput, "parseAzTokenOutput");
5739
+ function createAzureTokenSource(tokenEnv, deps) {
5740
+ const now = deps.now ?? Date.now;
5741
+ const runAz = deps.runAz ?? defaultRunAz;
5742
+ const findAz = deps.findAz ?? findAzOnPath;
5743
+ let cached;
5744
+ let inflight;
5745
+ const fromAz = /* @__PURE__ */ __name(async () => {
5746
+ const az = findAz(deps.env);
5747
+ if (!az) return "";
5748
+ try {
5749
+ const output = await runAz(az, [
5750
+ "account",
5751
+ "get-access-token",
5752
+ "--resource",
5753
+ AZURE_TOKEN_RESOURCE,
5754
+ "--output",
5755
+ "json"
5756
+ ]);
5757
+ const parsed = parseAzTokenOutput(output);
5758
+ if (!parsed) return "";
5759
+ cached = parsed;
5760
+ return parsed.token;
5761
+ } catch {
5762
+ return "";
5763
+ }
5764
+ }, "fromAz");
5765
+ return async () => {
5766
+ const fromEnv = deps.env[tokenEnv ?? DEFAULT_TOKEN_ENV];
5767
+ if (fromEnv) return fromEnv;
5768
+ if (tokenEnv !== void 0) return "";
5769
+ if (cached && now() < cached.expiresAt - TOKEN_EARLY_EXPIRY_MS) return cached.token;
5770
+ inflight ??= fromAz().finally(() => {
5771
+ inflight = void 0;
5772
+ });
5773
+ return inflight;
5774
+ };
5775
+ }
5776
+ __name(createAzureTokenSource, "createAzureTokenSource");
5777
+
5645
5778
  // src/integrations/decision/model.ts
5646
- function buildDecisionProviderConfig(cfg, env) {
5779
+ function buildDecisionProviderConfig(cfg, env, deps = {}) {
5780
+ const address = cfg.provider === "azure" ? cfg.endpoint : cfg.url;
5781
+ const readStored2 = deps.readStoredKey ?? readBoundDecisionKey;
5782
+ const read2 = /* @__PURE__ */ __name(() => readStored2(address), "read");
5783
+ let stored;
5784
+ const storedKey = /* @__PURE__ */ __name(() => {
5785
+ if (stored === void 0) {
5786
+ try {
5787
+ stored = read2();
5788
+ } catch {
5789
+ stored = null;
5790
+ }
5791
+ }
5792
+ return stored;
5793
+ }, "storedKey");
5794
+ const fetchPart = deps.fetch ? { fetch: deps.fetch } : {};
5647
5795
  if (cfg.provider === "azure") {
5796
+ const named2 = cfg.apiKeyEnv;
5797
+ const keyed = named2 !== void 0 || cfg.tokenEnv === void 0 && storedKey() !== null;
5648
5798
  return {
5649
5799
  provider: "azure",
5650
5800
  endpoint: cfg.endpoint,
5651
5801
  deployment: cfg.deployment,
5802
+ ...fetchPart,
5652
5803
  // A key, read at each call, or a bearer token; never both (the loader refuses a config naming both).
5653
- ...cfg.apiKeyEnv ? { getApiKey: /* @__PURE__ */ __name(() => env[cfg.apiKeyEnv] ?? "", "getApiKey") } : { getToken: /* @__PURE__ */ __name(async () => env[cfg.tokenEnv ?? "AZURE_FOUNDRY_TOKEN"] ?? "", "getToken") }
5804
+ ...keyed ? { getApiKey: /* @__PURE__ */ __name(() => named2 ? env[named2] ?? "" : storedKey() ?? "", "getApiKey") } : {
5805
+ getToken: createAzureTokenSource(cfg.tokenEnv, {
5806
+ env,
5807
+ ...deps.now ? { now: deps.now } : {},
5808
+ ...deps.runAz ? { runAz: deps.runAz } : {},
5809
+ ...deps.findAz ? { findAz: deps.findAz } : {}
5810
+ })
5811
+ }
5812
+ };
5813
+ }
5814
+ const named = cfg.apiKeyEnv;
5815
+ if (named) {
5816
+ return {
5817
+ provider: "http",
5818
+ url: cfg.url,
5819
+ ...cfg.model !== void 0 ? { model: cfg.model } : {},
5820
+ ...fetchPart,
5821
+ apiKey: env[named]
5654
5822
  };
5655
5823
  }
5824
+ const baseFetch = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
5656
5825
  return {
5657
5826
  provider: "http",
5658
5827
  url: cfg.url,
5659
5828
  ...cfg.model !== void 0 ? { model: cfg.model } : {},
5660
- ...cfg.apiKeyEnv ? { apiKey: env[cfg.apiKeyEnv] } : {}
5829
+ fetch: /* @__PURE__ */ __name((input, init) => {
5830
+ const key = storedKey();
5831
+ if (!key) return baseFetch(input, init);
5832
+ const headers = new Headers(init?.headers);
5833
+ headers.set("Authorization", `Bearer ${key}`);
5834
+ return baseFetch(input, { ...init, headers });
5835
+ }, "fetch")
5661
5836
  };
5662
5837
  }
5663
5838
  __name(buildDecisionProviderConfig, "buildDecisionProviderConfig");
@@ -5666,14 +5841,14 @@ function decisionSwitchedOff(env) {
5666
5841
  return env[DECISION_KILL_SWITCH] === "1";
5667
5842
  }
5668
5843
  __name(decisionSwitchedOff, "decisionSwitchedOff");
5669
- function maybeCreateDecisionTool(cfg, env) {
5844
+ function maybeCreateDecisionTool(cfg, env, deps = {}) {
5670
5845
  if (!cfg || decisionSwitchedOff(env)) return void 0;
5671
- return createDecisionTool(createDecisionModel(buildDecisionProviderConfig(cfg, env)));
5846
+ return createDecisionTool(createDecisionModel(buildDecisionProviderConfig(cfg, env, deps)));
5672
5847
  }
5673
5848
  __name(maybeCreateDecisionTool, "maybeCreateDecisionTool");
5674
- function maybeCreateDecisionModel(cfg, env) {
5849
+ function maybeCreateDecisionModel(cfg, env, deps = {}) {
5675
5850
  if (!cfg || decisionSwitchedOff(env)) return void 0;
5676
- return createDecisionModel(buildDecisionProviderConfig(cfg, env));
5851
+ return createDecisionModel(buildDecisionProviderConfig(cfg, env, deps));
5677
5852
  }
5678
5853
  __name(maybeCreateDecisionModel, "maybeCreateDecisionModel");
5679
5854
 
@@ -6944,7 +7119,7 @@ __name(readWorkStatus, "readWorkStatus");
6944
7119
 
6945
7120
  // src/integrations/plugins/files.ts
6946
7121
  import { readdirSync as readdirSync2, realpathSync as realpathSync3 } from "node:fs";
6947
- import { isAbsolute as isAbsolute6, join as join7, relative as relative6, sep as sep4 } from "node:path";
7122
+ import { isAbsolute as isAbsolute6, join as join8, relative as relative6, sep as sep4 } from "node:path";
6948
7123
 
6949
7124
  // src/integrations/plugins/settings.ts
6950
7125
  import { createHash as createHash3, randomUUID as randomUUID4 } from "node:crypto";
@@ -6960,12 +7135,12 @@ import {
6960
7135
  unlinkSync,
6961
7136
  writeFileSync
6962
7137
  } from "node:fs";
6963
- import { join as join6 } from "node:path";
7138
+ import { join as join7 } from "node:path";
6964
7139
  var MAX_RECORD_BYTES = 64 * 1024;
6965
7140
  var PluginSettingsStore = class {
6966
7141
  constructor(home) {
6967
7142
  this.home = home;
6968
- this.directory = join6(home, "plugin-settings");
7143
+ this.directory = join7(home, "plugin-settings");
6969
7144
  }
6970
7145
  home;
6971
7146
  static {
@@ -6974,7 +7149,7 @@ var PluginSettingsStore = class {
6974
7149
  directory;
6975
7150
  path(plugin) {
6976
7151
  const key = createHash3("sha256").update(JSON.stringify([plugin.rootDir, plugin.name])).digest("hex");
6977
- return join6(this.directory, `${key}.json`);
7152
+ return join7(this.directory, `${key}.json`);
6978
7153
  }
6979
7154
  read(plugin) {
6980
7155
  const path = this.path(plugin);
@@ -7056,7 +7231,7 @@ function resolvePluginFileDirs(plugin, rootDir, declared) {
7056
7231
  const problems = [];
7057
7232
  for (const rel of declared ?? []) {
7058
7233
  try {
7059
- const real = realpathSync3(join7(rootDir, rel));
7234
+ const real = realpathSync3(join8(rootDir, rel));
7060
7235
  const within2 = relative6(realpathSync3(rootDir), real);
7061
7236
  if (within2 === ".." || within2.startsWith(`..${sep4}`) || isAbsolute6(within2)) {
7062
7237
  problems.push(
@@ -7948,13 +8123,13 @@ __name(createSideModel, "createSideModel");
7948
8123
  var CLI_CHECKPOINT_RETENTION = 10;
7949
8124
 
7950
8125
  // src/integrations/subagents/definitions.ts
7951
- import { join as join8 } from "node:path";
8126
+ import { join as join9 } from "node:path";
7952
8127
  function userAgentsDir(home) {
7953
- return join8(namzuHomePath(home), "agents");
8128
+ return join9(namzuHomePath(home), "agents");
7954
8129
  }
7955
8130
  __name(userAgentsDir, "userAgentsDir");
7956
8131
  function projectAgentsDir(cwd) {
7957
- return join8(cwd, ".namzu", "agents");
8132
+ return join9(cwd, ".namzu", "agents");
7958
8133
  }
7959
8134
  __name(projectAgentsDir, "projectAgentsDir");
7960
8135
  var AGENT_FILE_PERMISSION_MODES = /* @__PURE__ */ new Set([
@@ -8053,7 +8228,7 @@ __name(prepareDelegatedEffort, "prepareDelegatedEffort");
8053
8228
 
8054
8229
  // src/integrations/subagents/operator-journal.ts
8055
8230
  import { appendFile, open as open2 } from "node:fs/promises";
8056
- import { join as join9 } from "node:path";
8231
+ import { join as join10 } from "node:path";
8057
8232
  var MAX_READ_BYTES = 256 * 1024;
8058
8233
  var MAX_CONTEXT_CHARACTERS = 32e3;
8059
8234
  function formatChildOperatorAdmission(input) {
@@ -8063,7 +8238,7 @@ function formatChildOperatorAdmission(input) {
8063
8238
  }
8064
8239
  __name(formatChildOperatorAdmission, "formatChildOperatorAdmission");
8065
8240
  async function readChildOperatorNotices(paths, sessionId) {
8066
- const path = join9(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
8241
+ const path = join10(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
8067
8242
  let file;
8068
8243
  try {
8069
8244
  file = await open2(path, "r");
@@ -8134,7 +8309,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
8134
8309
  })
8135
8310
  ).join("\n");
8136
8311
  await appendFile(
8137
- join9(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8312
+ join10(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8138
8313
  `${lines}
8139
8314
  `,
8140
8315
  { mode: 384 }
@@ -8143,7 +8318,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
8143
8318
  __name(acknowledgeChildOperatorNotices, "acknowledgeChildOperatorNotices");
8144
8319
  async function recordChildOperatorReport(paths, sessionId, notice2) {
8145
8320
  await appendFile(
8146
- join9(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8321
+ join10(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8147
8322
  `${JSON.stringify({ ...notice2, status: "child-report", source: "host", at: (/* @__PURE__ */ new Date()).toISOString() })}
8148
8323
  `,
8149
8324
  { mode: 384 }
@@ -9168,9 +9343,9 @@ __name(errorMessage2, "errorMessage");
9168
9343
 
9169
9344
  // src/integrations/subagents/runtime.ts
9170
9345
  import { randomUUID as randomUUID5 } from "node:crypto";
9171
- import { existsSync } from "node:fs";
9346
+ import { existsSync as existsSync2 } from "node:fs";
9172
9347
  import { appendFile as appendFile2, mkdir as mkdir4 } from "node:fs/promises";
9173
- import { join as join13 } from "node:path";
9348
+ import { join as join14 } from "node:path";
9174
9349
 
9175
9350
  // src/integrations/subagents/fork.ts
9176
9351
  var FORK_SUBAGENT = "fork";
@@ -9284,7 +9459,7 @@ __name(describeQuietTask, "describeQuietTask");
9284
9459
  // src/memory/typed.ts
9285
9460
  import { createHash as createHash4 } from "node:crypto";
9286
9461
  import { access, readFile as readFile3, rename as rename3, writeFile as writeFile2 } from "node:fs/promises";
9287
- import { join as join12 } from "node:path";
9462
+ import { join as join13 } from "node:path";
9288
9463
 
9289
9464
  // src/memory/io.ts
9290
9465
  import {
@@ -9298,7 +9473,7 @@ import {
9298
9473
  realpathSync as realpathSync4,
9299
9474
  writeSync
9300
9475
  } from "node:fs";
9301
- import { isAbsolute as isAbsolute7, join as join10, relative as relative7, resolve as resolve8, sep as sep5 } from "node:path";
9476
+ import { isAbsolute as isAbsolute7, join as join11, relative as relative7, resolve as resolve8, sep as sep5 } from "node:path";
9302
9477
  var MEMORY_FILE_MAX_BYTES = 1024 * 1024;
9303
9478
  function missing(error) {
9304
9479
  return error.code === "ENOENT";
@@ -9331,7 +9506,7 @@ function resolveMemoryPath(location, createParents = false) {
9331
9506
  for (let i = 0; i < parts.length; i += 1) {
9332
9507
  const part = parts[i];
9333
9508
  if (part === void 0) throw new Error("Memory path has an invalid segment.");
9334
- candidate = join10(candidate, part);
9509
+ candidate = join11(candidate, part);
9335
9510
  const leaf = i === parts.length - 1;
9336
9511
  let stat7;
9337
9512
  try {
@@ -9372,12 +9547,12 @@ function readBounded(fd) {
9372
9547
  let total = 0;
9373
9548
  while (total <= MEMORY_FILE_MAX_BYTES) {
9374
9549
  const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, MEMORY_FILE_MAX_BYTES + 1 - total));
9375
- const count = readSync2(fd, chunk, 0, chunk.length, total);
9376
- if (count === 0) break;
9377
- total += count;
9550
+ const count2 = readSync2(fd, chunk, 0, chunk.length, total);
9551
+ if (count2 === 0) break;
9552
+ total += count2;
9378
9553
  if (total > MEMORY_FILE_MAX_BYTES)
9379
9554
  throw new Error(`Memory exceeds the ${MEMORY_FILE_MAX_BYTES}-byte file limit.`);
9380
- chunks.push(chunk.subarray(0, count));
9555
+ chunks.push(chunk.subarray(0, count2));
9381
9556
  }
9382
9557
  let text2;
9383
9558
  try {
@@ -9456,18 +9631,18 @@ __name(appendMemoryFile, "appendMemoryFile");
9456
9631
 
9457
9632
  // src/memory/store.ts
9458
9633
  import { realpathSync as realpathSync5 } from "node:fs";
9459
- import { join as join11, resolve as resolve9 } from "node:path";
9634
+ import { join as join12, resolve as resolve9 } from "node:path";
9460
9635
  var MEMORY_SECTION_MAX_CHARS = 8e3;
9461
9636
  function memoryDir(home) {
9462
9637
  return namzuHomePath(home);
9463
9638
  }
9464
9639
  __name(memoryDir, "memoryDir");
9465
9640
  function userFilePath(home) {
9466
- return join11(memoryDir(home), "USER.md");
9641
+ return join12(memoryDir(home), "USER.md");
9467
9642
  }
9468
9643
  __name(userFilePath, "userFilePath");
9469
9644
  function memoryFilePath(home) {
9470
- return join11(memoryDir(home), "MEMORY.md");
9645
+ return join12(memoryDir(home), "MEMORY.md");
9471
9646
  }
9472
9647
  __name(memoryFilePath, "memoryFilePath");
9473
9648
  function projectMemoryFilePath(cwd) {
@@ -9478,9 +9653,9 @@ function projectMemoryFilePath(cwd) {
9478
9653
  if (error.code !== "ENOENT") throw error;
9479
9654
  }
9480
9655
  const root = cliProjectRoot(directory);
9481
- const local = join11(directory, ".namzu", "MEMORY.md");
9656
+ const local = join12(directory, ".namzu", "MEMORY.md");
9482
9657
  if (resolveMemoryPath({ path: local, root }) !== null) return local;
9483
- return join11(root, ".namzu", "MEMORY.md");
9658
+ return join12(root, ".namzu", "MEMORY.md");
9484
9659
  }
9485
9660
  __name(projectMemoryFilePath, "projectMemoryFilePath");
9486
9661
  function projectMemoryLocation(cwd) {
@@ -9510,15 +9685,15 @@ function readMemory(home, cwd) {
9510
9685
  }
9511
9686
  }, "read");
9512
9687
  const userRoot = memoryDir(home);
9513
- const user = read2(join11(userRoot, "USER.md"), () => ({
9688
+ const user = read2(join12(userRoot, "USER.md"), () => ({
9514
9689
  root: userRoot,
9515
- path: join11(userRoot, "USER.md")
9690
+ path: join12(userRoot, "USER.md")
9516
9691
  }));
9517
- const memory = read2(join11(userRoot, "MEMORY.md"), () => ({
9692
+ const memory = read2(join12(userRoot, "MEMORY.md"), () => ({
9518
9693
  root: userRoot,
9519
- path: join11(userRoot, "MEMORY.md")
9694
+ path: join12(userRoot, "MEMORY.md")
9520
9695
  }));
9521
- const project = cwd && !isUserMemoryFile(join11(resolve9(cwd), ".namzu", "MEMORY.md"), userRoot) ? read2(join11(resolve9(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
9696
+ const project = cwd && !isUserMemoryFile(join12(resolve9(cwd), ".namzu", "MEMORY.md"), userRoot) ? read2(join12(resolve9(cwd), ".namzu", "MEMORY.md"), () => projectLocation(cwd)) : null;
9522
9697
  return { user, memory, project, ...diagnostics.length > 0 ? { diagnostics } : {} };
9523
9698
  }
9524
9699
  __name(readMemory, "readMemory");
@@ -9530,7 +9705,7 @@ function isUserMemoryFile(projectPath, userRoot) {
9530
9705
  return resolve9(path);
9531
9706
  }
9532
9707
  }, "canonical");
9533
- return canonical(projectPath) === canonical(join11(userRoot, "MEMORY.md"));
9708
+ return canonical(projectPath) === canonical(join12(userRoot, "MEMORY.md"));
9534
9709
  }
9535
9710
  __name(isUserMemoryFile, "isUserMemoryFile");
9536
9711
  function capped(text2, file) {
@@ -9622,7 +9797,7 @@ async function saveTypedNote(store, text2, type = "project") {
9622
9797
  saved: false,
9623
9798
  duplicate: true,
9624
9799
  type: record.entry.type ?? type,
9625
- ...record.entry.name ? { name: record.entry.name, path: join12(store.path, `${record.entry.name}.md`) } : {}
9800
+ ...record.entry.name ? { name: record.entry.name, path: join13(store.path, `${record.entry.name}.md`) } : {}
9626
9801
  };
9627
9802
  }
9628
9803
  }
@@ -9637,7 +9812,7 @@ async function saveTypedNote(store, text2, type = "project") {
9637
9812
  return {
9638
9813
  saved: true,
9639
9814
  type,
9640
- ...entry.name ? { name: entry.name, path: join12(store.path, `${entry.name}.md`) } : {}
9815
+ ...entry.name ? { name: entry.name, path: join13(store.path, `${entry.name}.md`) } : {}
9641
9816
  };
9642
9817
  }
9643
9818
  __name(saveTypedNote, "saveTypedNote");
@@ -9680,7 +9855,7 @@ __name(composeMemoryGuidance, "composeMemoryGuidance");
9680
9855
  var MARKER2 = "migration.json";
9681
9856
  async function readMarker(directory) {
9682
9857
  try {
9683
- const parsed = JSON.parse(await readFile3(join12(directory, MARKER2), "utf8"));
9858
+ const parsed = JSON.parse(await readFile3(join13(directory, MARKER2), "utf8"));
9684
9859
  return parsed !== null && typeof parsed === "object" ? parsed : {};
9685
9860
  } catch (error) {
9686
9861
  if (error.code === "ENOENT") return {};
@@ -9693,7 +9868,7 @@ async function markCuratedFile(directory, path, state) {
9693
9868
  const files = { ...marker.curatedFiles ?? {} };
9694
9869
  files[path] = { ...files[path] ?? {}, ...state };
9695
9870
  await writeFile2(
9696
- join12(directory, MARKER2),
9871
+ join13(directory, MARKER2),
9697
9872
  `${JSON.stringify({ ...marker, curatedFiles: files }, null, 2)}
9698
9873
  `,
9699
9874
  { mode: 384 }
@@ -9760,7 +9935,7 @@ async function migrateMemoryOnce(options) {
9760
9935
  const skippedRecords = [];
9761
9936
  let importedRecords = 0;
9762
9937
  let notesOffer;
9763
- const indexPath = join12(directory, "index.json");
9938
+ const indexPath = join13(directory, "index.json");
9764
9939
  if (await exists(indexPath)) {
9765
9940
  try {
9766
9941
  const disk = new DiskMemoryStore({ baseDir: directory, directory });
@@ -9783,11 +9958,11 @@ async function migrateMemoryOnce(options) {
9783
9958
  }
9784
9959
  }
9785
9960
  await retire(indexPath);
9786
- const content = join12(directory, "content");
9961
+ const content = join13(directory, "content");
9787
9962
  const retiredContent = await exists(content) ? await retire(content) : content;
9788
9963
  for (const record of refused) {
9789
9964
  skippedRecords.push(
9790
- `"${record.title}" (${record.id}) was not moved: ${record.reason} It is kept in ${join12(retiredContent, `${record.id}.json`)}.`
9965
+ `"${record.title}" (${record.id}) was not moved: ${record.reason} It is kept in ${join13(retiredContent, `${record.id}.json`)}.`
9791
9966
  );
9792
9967
  }
9793
9968
  } catch (error) {
@@ -9862,9 +10037,9 @@ function describeMemoryMigration(report, directory) {
9862
10037
  }
9863
10038
  for (const skipped of report.skippedRecords) notices.push(`Stored memory: ${skipped}`);
9864
10039
  if (report.notesOffer) {
9865
- const { path, count } = report.notesOffer;
10040
+ const { path, count: count2 } = report.notesOffer;
9866
10041
  notices.push(
9867
- `Stored memory: ${path} has ${count} top-level bullet${count === 1 ? "" : "s"}, some perhaps notes #note saved before notes became typed memory files. They stay curated and still reach every turn. Run /memory import-notes to copy them into ${directory} as typed memories; the curated file is never changed. New #note and /memory add notes are saved there already.`
10042
+ `Stored memory: ${path} has ${count2} top-level bullet${count2 === 1 ? "" : "s"}, some perhaps notes #note saved before notes became typed memory files. They stay curated and still reach every turn. Run /memory import-notes to copy them into ${directory} as typed memories; the curated file is never changed. New #note and /memory add notes are saved there already.`
9868
10043
  );
9869
10044
  }
9870
10045
  notices.push(...report.problems);
@@ -10263,11 +10438,11 @@ function taskActivityOutput(activity, settled) {
10263
10438
  __name(taskActivityOutput, "taskActivityOutput");
10264
10439
 
10265
10440
  // src/integrations/subagents/worktree-driver.ts
10266
- import { execFile as execFile2 } from "node:child_process";
10441
+ import { execFile as execFile3 } from "node:child_process";
10267
10442
  import { mkdir as mkdir3, realpath as realpath3 } from "node:fs/promises";
10268
10443
  import { isAbsolute as isAbsolute8, relative as relative8, resolve as resolve10, sep as sep6 } from "node:path";
10269
10444
  import { promisify as promisify2 } from "node:util";
10270
- var runFile = promisify2(execFile2);
10445
+ var runFile = promisify2(execFile3);
10271
10446
  var DelegatedWorktreeDriver = class {
10272
10447
  constructor(cwd, stateRoot) {
10273
10448
  this.cwd = cwd;
@@ -12198,7 +12373,7 @@ ${step}`;
12198
12373
  sessionId: parent.sessionId
12199
12374
  });
12200
12375
  await mkdir4(directory, { recursive: true, mode: 448 });
12201
- journal = join13(directory, "child-operator-messages.jsonl");
12376
+ journal = join14(directory, "child-operator-messages.jsonl");
12202
12377
  }
12203
12378
  await audit("submitted");
12204
12379
  signal.throwIfAborted();
@@ -12502,12 +12677,12 @@ function agentTaskOutcome(task) {
12502
12677
  __name(agentTaskOutcome, "agentTaskOutcome");
12503
12678
  function workspaceData(task) {
12504
12679
  const meta = task.workspace?.meta;
12505
- return meta?.backend === "git-worktree" && existsSync(meta.worktreePath) ? { workspace_path: meta.worktreePath, workspace_branch: meta.branch } : {};
12680
+ return meta?.backend === "git-worktree" && existsSync2(meta.worktreePath) ? { workspace_path: meta.worktreePath, workspace_branch: meta.branch } : {};
12506
12681
  }
12507
12682
  __name(workspaceData, "workspaceData");
12508
12683
  function workspaceRemoved(task) {
12509
12684
  const meta = task.workspace?.meta;
12510
- return meta?.backend === "git-worktree" && !existsSync(meta.worktreePath);
12685
+ return meta?.backend === "git-worktree" && !existsSync2(meta.worktreePath);
12511
12686
  }
12512
12687
  __name(workspaceRemoved, "workspaceRemoved");
12513
12688
  function workspaceNote(task) {
@@ -12657,7 +12832,7 @@ __name(buildDefinition, "buildDefinition");
12657
12832
 
12658
12833
  // src/integrations/workflows/history.ts
12659
12834
  import { readFile as readFile4, readdir as readdir2 } from "node:fs/promises";
12660
- import { join as join14 } from "node:path";
12835
+ import { join as join15 } from "node:path";
12661
12836
  var RUN_ID = /^w[0-9a-z]{8}$/;
12662
12837
  async function readWorkflowJournal(file) {
12663
12838
  let text2;
@@ -12683,7 +12858,7 @@ async function readWorkflowJournal(file) {
12683
12858
  __name(readWorkflowJournal, "readWorkflowJournal");
12684
12859
  async function readWorkflowRun(runsDirectory, runId) {
12685
12860
  if (!RUN_ID.test(runId)) return void 0;
12686
- const records = await readWorkflowJournal(join14(runsDirectory, runId, "workflow", "journal.jsonl"));
12861
+ const records = await readWorkflowJournal(join15(runsDirectory, runId, "workflow", "journal.jsonl"));
12687
12862
  return viewFromJournal(records);
12688
12863
  }
12689
12864
  __name(readWorkflowRun, "readWorkflowRun");
@@ -12704,9 +12879,9 @@ __name(listWorkflowRuns, "listWorkflowRuns");
12704
12879
 
12705
12880
  // src/integrations/workflows/host.ts
12706
12881
  import { randomBytes as randomBytes3 } from "node:crypto";
12707
- import { existsSync as existsSync2 } from "node:fs";
12882
+ import { existsSync as existsSync3 } from "node:fs";
12708
12883
  import { readFile as readFile5 } from "node:fs/promises";
12709
- import { join as join15 } from "node:path";
12884
+ import { join as join16 } from "node:path";
12710
12885
 
12711
12886
  // src/integrations/workflows/offering.ts
12712
12887
  var WORKFLOW_TOOL_NAME = "workflow";
@@ -13156,7 +13331,7 @@ function createWorkflowHost(options) {
13156
13331
  }
13157
13332
  let checked;
13158
13333
  try {
13159
- checked = await new FileWorkflowJournal(join15(runs, runId, "workflow"), {
13334
+ checked = await new FileWorkflowJournal(join16(runs, runId, "workflow"), {
13160
13335
  runId,
13161
13336
  ...key !== void 0 ? { key } : {}
13162
13337
  }).read();
@@ -13176,7 +13351,7 @@ function createWorkflowHost(options) {
13176
13351
  }
13177
13352
  resumeState = loadWorkflowResume(checked);
13178
13353
  if (!resumeState.resumable) {
13179
- const mismatch = key !== void 0 && await readFile5(join15(runs, runId, "workflow", "journal.jsonl"), "utf8").then(
13354
+ const mismatch = key !== void 0 && await readFile5(join16(runs, runId, "workflow", "journal.jsonl"), "utf8").then(
13180
13355
  (text2) => journalKeyMismatch(text2, runId, key),
13181
13356
  () => false
13182
13357
  );
@@ -13196,12 +13371,12 @@ function createWorkflowHost(options) {
13196
13371
  if (state === "ended") registry.discard(runId);
13197
13372
  } else {
13198
13373
  runId = createWorkflowRunId(
13199
- (id) => registry.get(id) !== void 0 || runs !== void 0 && existsSync2(join15(runs, id))
13374
+ (id) => registry.get(id) !== void 0 || runs !== void 0 && existsSync3(join16(runs, id))
13200
13375
  );
13201
13376
  }
13202
13377
  const turn = options.openRunTurn(context.turnId, runId);
13203
13378
  const limits = options.limitsFor?.(context.turnId);
13204
- const journalDirectory = runs === void 0 ? void 0 : join15(runs, runId, "workflow");
13379
+ const journalDirectory = runs === void 0 ? void 0 : join16(runs, runId, "workflow");
13205
13380
  const journal = journalDirectory === void 0 ? void 0 : new FileWorkflowJournal(journalDirectory, {
13206
13381
  runId,
13207
13382
  ...key !== void 0 ? { key } : {}
@@ -13235,7 +13410,7 @@ function createWorkflowHost(options) {
13235
13410
  ...journal ? { journal } : {},
13236
13411
  ...resumeState ? { resume: resumeState } : {},
13237
13412
  ...editable !== void 0 ? { scriptPath: editable } : {},
13238
- ...journalDirectory !== void 0 ? { journalPath: join15(journalDirectory, "journal.jsonl") } : {},
13413
+ ...journalDirectory !== void 0 ? { journalPath: join16(journalDirectory, "journal.jsonl") } : {},
13239
13414
  spawn: /* @__PURE__ */ __name(async (request, signal, viewed) => {
13240
13415
  const detail = phaseDetail(request.phaseTitle);
13241
13416
  const outcome2 = await options.subagents.launchWorkflowAgent({
@@ -13318,9 +13493,9 @@ function createWorkflowHost(options) {
13318
13493
  __name(createWorkflowHost, "createWorkflowHost");
13319
13494
 
13320
13495
  // src/integrations/workflows/orphans.ts
13321
- import { existsSync as existsSync3 } from "node:fs";
13496
+ import { existsSync as existsSync4 } from "node:fs";
13322
13497
  import { readFile as readFile6, readdir as readdir3, writeFile as writeFile3 } from "node:fs/promises";
13323
- import { join as join16 } from "node:path";
13498
+ import { join as join17 } from "node:path";
13324
13499
  var NOTICE_FILE = "orphan-notice.json";
13325
13500
  var MAX_ORPHAN_NOTICES = 20;
13326
13501
  var NO_USAGE = {
@@ -13339,7 +13514,7 @@ function quotedName(name) {
13339
13514
  }
13340
13515
  __name(quotedName, "quotedName");
13341
13516
  function noticePath(runsDirectory, runId) {
13342
- return join16(runsDirectory, runId, "workflow", NOTICE_FILE);
13517
+ return join17(runsDirectory, runId, "workflow", NOTICE_FILE);
13343
13518
  }
13344
13519
  __name(noticePath, "noticePath");
13345
13520
  async function readStored(runsDirectory, runId) {
@@ -13355,8 +13530,8 @@ async function readStored(runsDirectory, runId) {
13355
13530
  return void 0;
13356
13531
  }
13357
13532
  __name(readStored, "readStored");
13358
- function words(count, noun) {
13359
- return `${count} ${noun}${count === 1 ? "" : "s"}`;
13533
+ function words(count2, noun) {
13534
+ return `${count2} ${noun}${count2 === 1 ? "" : "s"}`;
13360
13535
  }
13361
13536
  __name(words, "words");
13362
13537
  async function recoverUnfinishedWorkflows(options) {
@@ -13371,7 +13546,7 @@ async function recoverUnfinishedWorkflows(options) {
13371
13546
  for (const runId of entries.filter((name) => RUN_ID_PATTERN.test(name)).sort()) {
13372
13547
  if (options.liveRunIds.has(runId)) continue;
13373
13548
  const stored = await readStored(options.runsDirectory, runId);
13374
- const dir = join16(options.runsDirectory, runId, "workflow");
13549
+ const dir = join17(options.runsDirectory, runId, "workflow");
13375
13550
  const journal = new FileWorkflowJournal(dir, {
13376
13551
  runId,
13377
13552
  ...options.key !== void 0 ? { key: options.key } : {}
@@ -13422,7 +13597,7 @@ async function recoverUnfinishedWorkflows(options) {
13422
13597
  (key) => !state.results.has(key) && !state.failed.has(key)
13423
13598
  ).length;
13424
13599
  const copy = editableCopyPath(options.runsDirectory, name, runId);
13425
- const script = started.scriptPath ?? (existsSync3(copy) ? copy : void 0);
13600
+ const script = started.scriptPath ?? (existsSync4(copy) ? copy : void 0);
13426
13601
  text2 = [
13427
13602
  `Background workflow ${quotedName(name)} (run ${runId}) didn't finish before the previous session ended.`,
13428
13603
  `No finish record was found for it, so the process most likely exited while it ran. ${words(state.results.size, "agent")} had finished and saved their results; ${unfinished} had started and not finished.`,
@@ -13480,7 +13655,7 @@ __name(recoverUnfinishedWorkflows, "recoverUnfinishedWorkflows");
13480
13655
  async function keyMismatchOf(dir, runId, key) {
13481
13656
  if (key === void 0) return false;
13482
13657
  try {
13483
- return journalKeyMismatch(await readFile6(join16(dir, "journal.jsonl"), "utf8"), runId, key);
13658
+ return journalKeyMismatch(await readFile6(join17(dir, "journal.jsonl"), "utf8"), runId, key);
13484
13659
  } catch {
13485
13660
  return false;
13486
13661
  }
@@ -13521,7 +13696,7 @@ import { dirname as dirname4 } from "node:path";
13521
13696
  import { createHash as createHash5 } from "node:crypto";
13522
13697
 
13523
13698
  // src/memory/manage.ts
13524
- import { join as join17 } from "node:path";
13699
+ import { join as join18 } from "node:path";
13525
13700
 
13526
13701
  // src/memory/presentation.ts
13527
13702
  var MEMORY_PREVIEW_MAX_CHARS = 2e3;
@@ -13602,32 +13777,178 @@ ${preview(derived.text, directory)}`
13602
13777
  }
13603
13778
  __name(renderStoredMemorySection, "renderStoredMemorySection");
13604
13779
 
13605
- // src/memory/manage.ts
13780
+ // src/memory/sweep.ts
13781
+ var DEFAULT_RETIRE_AFTER_DAYS = 21;
13782
+ var RETIRED_UNUSED = "unused";
13783
+ var RETIRED_DUPLICATE = "duplicate";
13606
13784
  var DAY_MS = 864e5;
13607
- async function loadManagedMemories(store, directory) {
13785
+ var normalize = /* @__PURE__ */ __name((text2) => text2.normalize("NFKC").replace(/\s+/gu, " ").trim().toLowerCase(), "normalize");
13786
+ function retiredReasonOf(metadata) {
13787
+ const reason = metadata?.retiredReason;
13788
+ return typeof reason === "string" && typeof metadata?.retiredAt === "number" ? reason : void 0;
13789
+ }
13790
+ __name(retiredReasonOf, "retiredReasonOf");
13791
+ function isUnused(input) {
13792
+ const counters = input.usage.get(input.id);
13793
+ const reference = Math.max(input.touchedAt, counters?.lastRecalledAt ?? 0, input.usage.since);
13794
+ return input.at - reference >= input.retireAfterDays * DAY_MS;
13795
+ }
13796
+ __name(isUnused, "isUnused");
13797
+ async function sweepMemory(deps) {
13798
+ const { store, usage, now, retireAfterDays, shouldStop } = deps;
13799
+ const at = now();
13608
13800
  const { entries } = await store.list({ status: "active" });
13609
- const items = [];
13801
+ const archived = [];
13802
+ const possiblyStale = [];
13803
+ let kept = 0;
13804
+ const unusedSkipped = retireAfterDays <= 0 ? "off" : usage.state === "unknown" ? "unknown" : void 0;
13805
+ const derived = [];
13806
+ const unusedRow = /* @__PURE__ */ __name((row) => {
13807
+ if (unusedSkipped) return false;
13808
+ return isUnused({
13809
+ usage,
13810
+ id: row.id,
13811
+ touchedAt: row.record.entry.updatedAt,
13812
+ at,
13813
+ retireAfterDays
13814
+ });
13815
+ }, "unusedRow");
13610
13816
  for (const entry of entries) {
13611
13817
  const record = await store.getVersionedRecord(entry.id);
13612
13818
  if (!record || record.entry.status !== "active") continue;
13613
- const supersedes = record.content.metadata?.supersedes;
13614
- const replaced = typeof supersedes === "string" ? (await store.getRecord(supersedes))?.entry.title : void 0;
13615
- items.push({
13616
- id: record.entry.id,
13617
- name: record.entry.name,
13618
- title: record.entry.title,
13619
- type: record.entry.type,
13620
- origin: memoryOrigin(record.content.metadata),
13621
- createdAt: record.entry.createdAt,
13622
- updatedAt: record.entry.updatedAt,
13623
- revision: record.revision,
13624
- path: record.entry.name ? join17(directory, `${record.entry.name}.md`) : directory,
13625
- ...replaced ? { replaces: replaced } : {}
13626
- });
13819
+ const row = { id: entry.id, record };
13820
+ if (memoryOrigin(record.content.metadata) === "derived") derived.push(row);
13821
+ else if (unusedRow(row)) possiblyStale.push(entry.id);
13822
+ }
13823
+ const archive = /* @__PURE__ */ __name(async (row, reason, extra = {}) => {
13824
+ if (shouldStop?.() === true) return;
13825
+ try {
13826
+ await store.updateIfRevision(
13827
+ row.id,
13828
+ {
13829
+ status: "archived",
13830
+ metadata: {
13831
+ ...row.record.content.metadata,
13832
+ retiredAt: at,
13833
+ retiredReason: reason,
13834
+ ...extra
13835
+ }
13836
+ },
13837
+ row.record.revision
13838
+ );
13839
+ archived.push({ id: row.id, title: row.record.entry.title, reason });
13840
+ } catch (error) {
13841
+ if (!(error instanceof MemoryRevisionConflictError)) throw error;
13842
+ kept += 1;
13843
+ }
13844
+ }, "archive");
13845
+ const groups = /* @__PURE__ */ new Map();
13846
+ for (const row of derived) {
13847
+ const key = [
13848
+ row.record.entry.type ?? "",
13849
+ normalize(row.record.entry.title),
13850
+ normalize(row.record.content.content)
13851
+ ].join("\0");
13852
+ groups.set(key, [...groups.get(key) ?? [], row]);
13853
+ }
13854
+ const settled = /* @__PURE__ */ new Set();
13855
+ for (const group of groups.values()) {
13856
+ if (group.length < 2) continue;
13857
+ const [newest, ...older] = [...group].sort(
13858
+ (a, b) => b.record.entry.updatedAt - a.record.entry.updatedAt || b.record.entry.createdAt - a.record.entry.createdAt || (a.id < b.id ? -1 : 1)
13859
+ );
13860
+ if (!newest) continue;
13861
+ for (const row of older) {
13862
+ settled.add(row.id);
13863
+ await archive(row, RETIRED_DUPLICATE, { supersededBy: newest.id });
13864
+ }
13865
+ }
13866
+ for (const row of derived) {
13867
+ if (settled.has(row.id) || !unusedRow(row)) continue;
13868
+ await archive(row, RETIRED_UNUSED);
13869
+ }
13870
+ return {
13871
+ archived,
13872
+ possiblyStale,
13873
+ kept,
13874
+ ...unusedSkipped ? { unusedSkipped } : {}
13875
+ };
13876
+ }
13877
+ __name(sweepMemory, "sweepMemory");
13878
+ function describeSweep(report, retireAfterDays) {
13879
+ const lines = [];
13880
+ if (report.archived.length === 0) lines.push("Nothing to tidy: no memory was set aside.");
13881
+ else {
13882
+ lines.push(
13883
+ `Retired ${report.archived.length} ${report.archived.length === 1 ? "memory" : "memories"}. /memory restores them.`
13884
+ );
13885
+ for (const item of report.archived)
13886
+ lines.push(
13887
+ ` ${item.title.replace(/\s+/gu, " ").trim()} \xB7 ${item.reason === RETIRED_DUPLICATE ? "a newer copy exists" : `not recalled for ${retireAfterDays} days`}`
13888
+ );
13889
+ }
13890
+ if (report.unusedSkipped === "unknown")
13891
+ lines.push(
13892
+ "Use counts are not known yet, so no memory was retired for being unused. They start counting now."
13893
+ );
13894
+ if (report.unusedSkipped === "off")
13895
+ lines.push("memory.retireAfterDays is 0, so no memory is retired for being unused.");
13896
+ if (report.possiblyStale.length > 0)
13897
+ lines.push(
13898
+ `${report.possiblyStale.length} you or Namzu saved ${report.possiblyStale.length === 1 ? "has" : "have"} not been recalled for ${retireAfterDays} days. They stay; /memory marks them.`
13899
+ );
13900
+ if (report.kept > 0) lines.push(`${report.kept} changed while tidying and stayed.`);
13901
+ return lines.join("\n");
13902
+ }
13903
+ __name(describeSweep, "describeSweep");
13904
+
13905
+ // src/memory/manage.ts
13906
+ var DAY_MS2 = 864e5;
13907
+ async function loadManagedMemories(store, directory, lookups = {}) {
13908
+ const items = [];
13909
+ const { usage } = lookups;
13910
+ const at = lookups.now ?? Date.now();
13911
+ for (const status of ["active", "archived"]) {
13912
+ const { entries } = await store.list({ status });
13913
+ for (const entry of entries) {
13914
+ const record = await store.getVersionedRecord(entry.id);
13915
+ if (!record || record.entry.status !== status) continue;
13916
+ const metadata = record.content.metadata;
13917
+ const retiredReason = status === "archived" ? retiredReasonOf(metadata) : void 0;
13918
+ if (status === "archived" && retiredReason === void 0) continue;
13919
+ const origin = memoryOrigin(metadata);
13920
+ const supersedes = metadata?.supersedes;
13921
+ const replaced = typeof supersedes === "string" ? (await store.getRecord(supersedes))?.entry.title : void 0;
13922
+ const state = status === "archived" ? "retired" : usage?.isSetAside(entry.id) ? "set-aside" : "active";
13923
+ const stale = status === "active" && origin !== "derived" && usage !== void 0 && lookups.retireAfterDays !== void 0 && lookups.retireAfterDays > 0 && usage.state === "known" && isUnused({
13924
+ usage,
13925
+ id: entry.id,
13926
+ touchedAt: record.entry.updatedAt,
13927
+ at,
13928
+ retireAfterDays: lookups.retireAfterDays
13929
+ });
13930
+ items.push({
13931
+ id: record.entry.id,
13932
+ name: record.entry.name,
13933
+ title: record.entry.title,
13934
+ type: record.entry.type,
13935
+ origin,
13936
+ createdAt: record.entry.createdAt,
13937
+ updatedAt: record.entry.updatedAt,
13938
+ revision: record.revision,
13939
+ path: record.entry.name ? join18(directory, `${record.entry.name}.md`) : directory,
13940
+ ...replaced ? { replaces: replaced } : {},
13941
+ ...state !== "active" ? { state } : {},
13942
+ ...retiredReason !== void 0 ? { retiredReason } : {},
13943
+ ...state === "retired" && usage?.isSetAside(entry.id) ? { alsoSetAside: true } : {},
13944
+ ...stale ? { possiblyStale: true } : {}
13945
+ });
13946
+ }
13627
13947
  }
13628
13948
  return sortManagedMemories(items);
13629
13949
  }
13630
13950
  __name(loadManagedMemories, "loadManagedMemories");
13951
+ var STATE_RANK = { active: 0, "set-aside": 1, retired: 2 };
13631
13952
  var ORIGIN_RANK = {
13632
13953
  operator: 0,
13633
13954
  model: 1,
@@ -13635,7 +13956,7 @@ var ORIGIN_RANK = {
13635
13956
  };
13636
13957
  function sortManagedMemories(items) {
13637
13958
  return [...items].sort(
13638
- (a, b) => ORIGIN_RANK[a.origin] - ORIGIN_RANK[b.origin] || b.updatedAt - a.updatedAt || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)
13959
+ (a, b) => STATE_RANK[a.state ?? "active"] - STATE_RANK[b.state ?? "active"] || ORIGIN_RANK[a.origin] - ORIGIN_RANK[b.origin] || b.updatedAt - a.updatedAt || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)
13639
13960
  );
13640
13961
  }
13641
13962
  __name(sortManagedMemories, "sortManagedMemories");
@@ -13644,7 +13965,7 @@ function originLabel(origin) {
13644
13965
  }
13645
13966
  __name(originLabel, "originLabel");
13646
13967
  function ageLabel(updatedAt, now = Date.now()) {
13647
- const days = Math.max(0, Math.floor((now - updatedAt) / DAY_MS));
13968
+ const days = Math.max(0, Math.floor((now - updatedAt) / DAY_MS2));
13648
13969
  if (days === 0) return "today";
13649
13970
  return `${days} day${days === 1 ? "" : "s"} ago`;
13650
13971
  }
@@ -13654,8 +13975,17 @@ function memoryLabel(item) {
13654
13975
  return line;
13655
13976
  }
13656
13977
  __name(memoryLabel, "memoryLabel");
13978
+ function stateLabel(item) {
13979
+ if (item.state === "set-aside") return "set aside: a refused request carried it";
13980
+ if (item.state === "retired") {
13981
+ const why = item.retiredReason === RETIRED_DUPLICATE ? "a newer copy exists" : "not recalled for a while";
13982
+ return item.alsoSetAside ? `retired and set aside: ${why}` : `retired: ${why}`;
13983
+ }
13984
+ return item.possiblyStale ? "possibly stale: not recalled for a while" : void 0;
13985
+ }
13986
+ __name(stateLabel, "stateLabel");
13657
13987
  function memoryDescription(item, now = Date.now()) {
13658
- return [originLabel(item.origin), item.type, ageLabel(item.updatedAt, now)].filter((part) => Boolean(part)).join(" \xB7 ");
13988
+ return [stateLabel(item), originLabel(item.origin), item.type, ageLabel(item.updatedAt, now)].filter((part) => Boolean(part)).join(" \xB7 ");
13659
13989
  }
13660
13990
  __name(memoryDescription, "memoryDescription");
13661
13991
  var DELETE_ALL_RECORDED = "__delete-all-recorded__";
@@ -13709,6 +14039,7 @@ function renderMemoryDetail(item, body2) {
13709
14039
  return [
13710
14040
  memoryLabel(item),
13711
14041
  `Written by: ${originLabel(item.origin)}`,
14042
+ ...stateLabel(item) ? [`State: ${stateLabel(item)}`] : [],
13712
14043
  ...item.replaces ? [`Replaced: ${item.replaces.replace(/\s+/g, " ").trim()}`] : [],
13713
14044
  ...item.type ? [`Type: ${item.type}`] : [],
13714
14045
  `Created: ${stamp(item.createdAt)}`,
@@ -13733,6 +14064,33 @@ async function deleteManagedMemory(store, item) {
13733
14064
  }
13734
14065
  }
13735
14066
  __name(deleteManagedMemory, "deleteManagedMemory");
14067
+ async function restoreManagedMemory(store, item, liftSetAside) {
14068
+ if (item.state === "set-aside") {
14069
+ await liftSetAside(item.id);
14070
+ return "restored";
14071
+ }
14072
+ if (item.state !== "retired") return "not-needed";
14073
+ try {
14074
+ const record = await store.getVersionedRecord(item.id);
14075
+ if (!record) return "gone";
14076
+ const { retiredAt: _at, retiredReason: _reason, ...rest } = record.content.metadata ?? {};
14077
+ await store.updateIfRevision(item.id, { status: "active", metadata: rest }, item.revision);
14078
+ await liftSetAside(item.id);
14079
+ return "restored";
14080
+ } catch (error) {
14081
+ if (!(error instanceof MemoryRevisionConflictError)) throw error;
14082
+ return await store.getRecord(item.id) ? "changed" : "gone";
14083
+ }
14084
+ }
14085
+ __name(restoreManagedMemory, "restoreManagedMemory");
14086
+ function restoreOutcomeLine(item, outcome) {
14087
+ if (outcome === "restored") return `Restored \u201C${memoryLabel(item)}\u201D. Namzu may recall it again.`;
14088
+ if (outcome === "changed")
14089
+ return `\u201C${memoryLabel(item)}\u201D changed since it was listed, so it was left as it was. /memory lists it again.`;
14090
+ if (outcome === "gone") return `\u201C${memoryLabel(item)}\u201D was already gone.`;
14091
+ return `\u201C${memoryLabel(item)}\u201D needs no restoring.`;
14092
+ }
14093
+ __name(restoreOutcomeLine, "restoreOutcomeLine");
13736
14094
  async function deleteMemories(store, items) {
13737
14095
  let deleted = 0;
13738
14096
  let kept = 0;
@@ -14003,10 +14361,10 @@ __name(screenCandidate, "screenCandidate");
14003
14361
  function screenMemoryPromotion(promote, log) {
14004
14362
  return (candidate) => {
14005
14363
  const { candidate: screened, dropped } = screenCandidate(candidate);
14006
- for (const [reason, count] of Object.entries(dropped)) {
14364
+ for (const [reason, count2] of Object.entries(dropped)) {
14007
14365
  log.info("memory claims dropped", {
14008
14366
  "namzu.memory.screen.reason": reason,
14009
- "namzu.memory.screen.dropped_count": count
14367
+ "namzu.memory.screen.dropped_count": count2
14010
14368
  });
14011
14369
  }
14012
14370
  return promote(screened);
@@ -14135,9 +14493,9 @@ function parseOps(reply, candidateCount) {
14135
14493
  const o = raw;
14136
14494
  const candidate = typeof o.candidate === "number" ? Math.trunc(o.candidate) - 1 : Number.NaN;
14137
14495
  if (!Number.isInteger(candidate) || candidate < 0 || candidate >= candidateCount) continue;
14138
- const count = (perCandidate.get(candidate) ?? 0) + 1;
14139
- perCandidate.set(candidate, count);
14140
- if (count > OPS_PER_CANDIDATE) continue;
14496
+ const count2 = (perCandidate.get(candidate) ?? 0) + 1;
14497
+ perCandidate.set(candidate, count2);
14498
+ if (count2 > OPS_PER_CANDIDATE) continue;
14141
14499
  const op = OPS.find((kind) => kind === o.op);
14142
14500
  if (op === void 0) {
14143
14501
  out.push({ candidate, invalid: true });
@@ -14550,9 +14908,14 @@ var CurationRuntime = class {
14550
14908
  #deps;
14551
14909
  #timer = null;
14552
14910
  #disposed = false;
14911
+ #draining = 0;
14553
14912
  constructor(deps) {
14554
14913
  this.#deps = deps;
14555
14914
  }
14915
+ /** Whether a drain is in flight right now. */
14916
+ get draining() {
14917
+ return this.#draining > 0;
14918
+ }
14556
14919
  #cancel() {
14557
14920
  if (this.#timer === null) return;
14558
14921
  this.#deps.clearTimer(this.#timer);
@@ -14606,6 +14969,7 @@ var CurationRuntime = class {
14606
14969
  this.#deps.report?.(reason, "skipped");
14607
14970
  return void 0;
14608
14971
  }
14972
+ this.#draining += 1;
14609
14973
  try {
14610
14974
  const lines = [];
14611
14975
  const result = await inbox.drain(async (entries) => {
@@ -14626,18 +14990,24 @@ var CurationRuntime = class {
14626
14990
  } catch {
14627
14991
  this.#deps.report?.(reason, "failed");
14628
14992
  return void 0;
14993
+ } finally {
14994
+ this.#draining -= 1;
14629
14995
  }
14630
14996
  }
14631
14997
  };
14632
14998
  function createCurationLog(file) {
14633
- let directory;
14634
- return (entry) => {
14635
- directory ??= mkdir5(dirname4(file), { recursive: true, mode: 448 }).catch(() => {
14636
- });
14637
- void directory.then(() => appendFile3(file, `${JSON.stringify(entry)}
14638
- `, { mode: 384 })).catch(() => {
14999
+ let tail2;
15000
+ const write = /* @__PURE__ */ __name((entry) => {
15001
+ const line = `${JSON.stringify(entry)}
15002
+ `;
15003
+ tail2 ??= mkdir5(dirname4(file), { recursive: true, mode: 448 }).then(
15004
+ () => void 0,
15005
+ () => void 0
15006
+ );
15007
+ tail2 = tail2.then(() => appendFile3(file, line, { mode: 384 })).catch(() => {
14639
15008
  });
14640
- };
15009
+ }, "write");
15010
+ return Object.assign(write, { settled: /* @__PURE__ */ __name(() => tail2 ?? Promise.resolve(), "settled") });
14641
15011
  }
14642
15012
  __name(createCurationLog, "createCurationLog");
14643
15013
  function inboxPromotion(options) {
@@ -14681,7 +15051,7 @@ import {
14681
15051
  unlink as unlink3,
14682
15052
  writeFile as writeFile4
14683
15053
  } from "node:fs/promises";
14684
- import { basename as basename3, dirname as dirname5, join as join18 } from "node:path";
15054
+ import { basename as basename3, dirname as dirname5, join as join19 } from "node:path";
14685
15055
  var INBOX_BATCH_SIZE = 8;
14686
15056
  var INBOX_MAX_BATCHES = 3;
14687
15057
  var INBOX_CLAIM_STALE_MS = 12e4;
@@ -14776,7 +15146,7 @@ var MemoryInbox = class {
14776
15146
  return dedupe(texts.flatMap((text2) => text2 === void 0 ? [] : parseLines(text2)));
14777
15147
  }
14778
15148
  #newClaimPath(now) {
14779
- return join18(
15149
+ return join19(
14780
15150
  dirname5(this.#file),
14781
15151
  `${basename3(this.#file, ".jsonl")}.claim-${now}-${this.#newId()}.jsonl`
14782
15152
  );
@@ -14795,7 +15165,7 @@ var MemoryInbox = class {
14795
15165
  if (!name.startsWith(prefix)) continue;
14796
15166
  const match = CLAIM_PATTERN.exec(name);
14797
15167
  if (!match) continue;
14798
- out.push({ path: join18(dirname5(this.#file), name), at: Number(match[1]) });
15168
+ out.push({ path: join19(dirname5(this.#file), name), at: Number(match[1]) });
14799
15169
  }
14800
15170
  return out.sort((a, b) => a.at - b.at);
14801
15171
  }
@@ -14905,9 +15275,169 @@ async function atomicWrite(path, text2) {
14905
15275
  }
14906
15276
  __name(atomicWrite, "atomicWrite");
14907
15277
 
15278
+ // src/memory/lifecycle.ts
15279
+ var SWEEP_IDLE_MS = 15e3;
15280
+ var SWEEP_MIN_GAP_MS = 6 * 36e5;
15281
+ var MemoryLifecycle = class {
15282
+ static {
15283
+ __name(this, "MemoryLifecycle");
15284
+ }
15285
+ #deps;
15286
+ #timer = null;
15287
+ #turnRunning = false;
15288
+ /** The sweep in flight, so a second one queues behind it. */
15289
+ #inflight;
15290
+ #lastSweepAt;
15291
+ #disposed = false;
15292
+ /** A refused request was retried without the memories it carried. */
15293
+ #withheld = false;
15294
+ constructor(deps) {
15295
+ this.#deps = deps;
15296
+ }
15297
+ /** The keys a refused request is retried without. */
15298
+ withholdOnRefusal = [RECALLED_MEMORY_KEY];
15299
+ /** Keys withheld from every request of the session once one refusal was retried without them. */
15300
+ withheldKeys() {
15301
+ return this.#withheld ? [RECALLED_MEMORY_KEY] : [];
15302
+ }
15303
+ /** The ids recall must not offer. */
15304
+ excluded = /* @__PURE__ */ __name(() => this.#deps.usage.setAsideIds(), "excluded");
15305
+ /** Read the usage file and arm the first idle sweep. */
15306
+ async start() {
15307
+ await this.#deps.usage.load();
15308
+ this.#arm();
15309
+ }
15310
+ /** Every session event of a turn. */
15311
+ observe(event) {
15312
+ switch (event.type) {
15313
+ case "memory_recalled": {
15314
+ const ids = event.memories.map((memory) => memory.id);
15315
+ const chosen = event.memories.filter((memory) => memory.reason !== void 0 && memory.reason !== "matched words").map((memory) => memory.id);
15316
+ this.#deps.usage.recalled(ids, chosen);
15317
+ return;
15318
+ }
15319
+ case "model_refusal":
15320
+ if (event.outcome === "withheld") {
15321
+ this.#withheld = true;
15322
+ const ids = event.withheldMemoryIds ?? [];
15323
+ this.#deps.usage.setAside(ids);
15324
+ this.#deps.log?.("memory set aside after a refusal", {
15325
+ "namzu.memory.lifecycle.set_aside_count": ids.length
15326
+ });
15327
+ void this.#deps.usage.flush();
15328
+ }
15329
+ return;
15330
+ case "turn_completed":
15331
+ case "turn_failed":
15332
+ this.turnSettled();
15333
+ return;
15334
+ default:
15335
+ }
15336
+ }
15337
+ /** A turn is starting: the idle sweep is off. */
15338
+ turnStarted() {
15339
+ if (this.#disposed) return;
15340
+ this.#turnRunning = true;
15341
+ this.#cancel();
15342
+ }
15343
+ /** A turn released: write the counts, then wait for quiet. */
15344
+ turnSettled() {
15345
+ if (this.#disposed) return;
15346
+ this.#turnRunning = false;
15347
+ void this.#deps.usage.flush();
15348
+ this.#arm();
15349
+ }
15350
+ /** Lift the set-aside of one record and write it. */
15351
+ async restore(id) {
15352
+ this.#deps.usage.restore(id);
15353
+ await this.#deps.usage.flush();
15354
+ }
15355
+ /** The sweep, now. Never waits for quiet. */
15356
+ async tidy() {
15357
+ await this.#deps.usage.flush();
15358
+ const report = await this.#serial(() => this.#sweep());
15359
+ this.#lastSweepAt = this.#deps.now();
15360
+ return report;
15361
+ }
15362
+ /** One sweep at a time: a run waits for the one in flight. */
15363
+ async #serial(run2) {
15364
+ const behind = this.#inflight;
15365
+ const current = (async () => {
15366
+ if (behind) await behind.catch(() => void 0);
15367
+ return run2();
15368
+ })();
15369
+ this.#inflight = current;
15370
+ try {
15371
+ return await current;
15372
+ } finally {
15373
+ if (this.#inflight === current) this.#inflight = void 0;
15374
+ }
15375
+ }
15376
+ async #sweep(shouldStop) {
15377
+ const report = await sweepMemory({
15378
+ store: this.#deps.store,
15379
+ usage: this.#deps.usage,
15380
+ now: this.#deps.now,
15381
+ retireAfterDays: this.#deps.retireAfterDays,
15382
+ ...shouldStop ? { shouldStop } : {}
15383
+ });
15384
+ this.#deps.log?.("memory sweep finished", {
15385
+ "namzu.memory.sweep.archived_count": report.archived.length,
15386
+ "namzu.memory.sweep.unused_count": report.archived.filter((item) => item.reason === "unused").length,
15387
+ "namzu.memory.sweep.duplicate_count": report.archived.filter(
15388
+ (item) => item.reason === "duplicate"
15389
+ ).length,
15390
+ "namzu.memory.sweep.possibly_stale_count": report.possiblyStale.length,
15391
+ "namzu.memory.sweep.kept_count": report.kept
15392
+ });
15393
+ return report;
15394
+ }
15395
+ #cancel() {
15396
+ if (this.#timer === null) return;
15397
+ this.#deps.clearTimer(this.#timer);
15398
+ this.#timer = null;
15399
+ }
15400
+ #arm() {
15401
+ if (this.#disposed || this.#turnRunning) return;
15402
+ this.#cancel();
15403
+ this.#timer = this.#deps.setTimer(() => {
15404
+ this.#timer = null;
15405
+ return this.#idle();
15406
+ }, SWEEP_IDLE_MS);
15407
+ }
15408
+ async #idle() {
15409
+ if (this.#disposed || this.#turnRunning || this.#inflight) return;
15410
+ if (this.#deps.isBusy?.() === true || this.#deps.isDraining?.() === true) {
15411
+ this.#arm();
15412
+ return;
15413
+ }
15414
+ const last = this.#lastSweepAt;
15415
+ if (last !== void 0 && this.#deps.now() - last < SWEEP_MIN_GAP_MS) return;
15416
+ try {
15417
+ await this.#deps.usage.flush();
15418
+ const report = await this.#serial(
15419
+ () => this.#sweep(
15420
+ () => this.#turnRunning || this.#disposed || this.#deps.isDraining?.() === true
15421
+ )
15422
+ );
15423
+ this.#lastSweepAt = this.#deps.now();
15424
+ if (report.archived.length > 0) this.#deps.onSwept?.(report);
15425
+ } catch {
15426
+ this.#deps.log?.("memory sweep failed", { "namzu.memory.sweep.reason": "store" });
15427
+ }
15428
+ }
15429
+ /** Write what is pending and stop arming. */
15430
+ async dispose() {
15431
+ if (this.#disposed) return;
15432
+ this.#disposed = true;
15433
+ this.#cancel();
15434
+ await this.#deps.usage.flush();
15435
+ }
15436
+ };
15437
+
14908
15438
  // src/memory/screen-archive.ts
14909
15439
  import { access as access2, writeFile as writeFile5 } from "node:fs/promises";
14910
- import { join as join19 } from "node:path";
15440
+ import { join as join20 } from "node:path";
14911
15441
  var SCREEN_MARKER_FILE = ".derived-screen-v1";
14912
15442
  var HEADINGS = {
14913
15443
  "What the user requires": "userRequirements",
@@ -14966,7 +15496,7 @@ ${body2}`) !== void 0) return true;
14966
15496
  __name(wouldNotBeWritten, "wouldNotBeWritten");
14967
15497
  async function archiveUnscreenedRecords(options) {
14968
15498
  const { store, directory, log } = options;
14969
- const marker = join19(directory, SCREEN_MARKER_FILE);
15499
+ const marker = join20(directory, SCREEN_MARKER_FILE);
14970
15500
  try {
14971
15501
  if (await access2(marker).then(
14972
15502
  () => true,
@@ -15146,6 +15676,250 @@ function memorySelectionOptions(setting, deps) {
15146
15676
  }
15147
15677
  __name(memorySelectionOptions, "memorySelectionOptions");
15148
15678
 
15679
+ // src/memory/usage.ts
15680
+ import { randomUUID as randomUUID7 } from "node:crypto";
15681
+ import { mkdir as mkdir7, readFile as readFile8, rename as rename5, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
15682
+ import { dirname as dirname6 } from "node:path";
15683
+ var VERSION = 1;
15684
+ var nodeUsageFs = {
15685
+ readFile: /* @__PURE__ */ __name((path) => readFile8(path, "utf8"), "readFile"),
15686
+ writeFile: /* @__PURE__ */ __name((path, data) => writeFile6(path, data, { mode: 384 }), "writeFile"),
15687
+ rename: rename5,
15688
+ mkdir: /* @__PURE__ */ __name(async (path) => {
15689
+ await mkdir7(path, { recursive: true, mode: 448 });
15690
+ }, "mkdir"),
15691
+ rm: /* @__PURE__ */ __name((path) => rm3(path, { force: true }), "rm")
15692
+ };
15693
+ function isRecord3(value) {
15694
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15695
+ }
15696
+ __name(isRecord3, "isRecord");
15697
+ function count(value) {
15698
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
15699
+ }
15700
+ __name(count, "count");
15701
+ function parse(text2) {
15702
+ let raw;
15703
+ try {
15704
+ raw = JSON.parse(text2);
15705
+ } catch {
15706
+ return void 0;
15707
+ }
15708
+ if (!isRecord3(raw) || raw.version !== VERSION) return void 0;
15709
+ const since = count(raw.since);
15710
+ if (since === void 0 || !isRecord3(raw.records) || !isRecord3(raw.setAside)) return void 0;
15711
+ const records = {};
15712
+ for (const [id, value] of Object.entries(raw.records)) {
15713
+ if (!isRecord3(value)) return void 0;
15714
+ const recalls = count(value.recalls);
15715
+ const selected = count(value.selected);
15716
+ const lastRecalledAt = count(value.lastRecalledAt);
15717
+ if (recalls === void 0 || selected === void 0 || lastRecalledAt === void 0)
15718
+ return void 0;
15719
+ records[id] = { recalls, selected, lastRecalledAt };
15720
+ }
15721
+ const setAside = {};
15722
+ for (const [id, value] of Object.entries(raw.setAside)) {
15723
+ if (!isRecord3(value)) return void 0;
15724
+ const at = count(value.at);
15725
+ if (at === void 0) return void 0;
15726
+ setAside[id] = { at, reason: "refused" };
15727
+ }
15728
+ return { version: VERSION, since, records, setAside };
15729
+ }
15730
+ __name(parse, "parse");
15731
+ var MemoryUsage = class {
15732
+ static {
15733
+ __name(this, "MemoryUsage");
15734
+ }
15735
+ #file;
15736
+ #now;
15737
+ #fs;
15738
+ #log;
15739
+ #state = "unknown";
15740
+ #since = 0;
15741
+ #baseRecords = {};
15742
+ #baseAside = {};
15743
+ #records = /* @__PURE__ */ new Map();
15744
+ #setAside = /* @__PURE__ */ new Map();
15745
+ #deltas = /* @__PURE__ */ new Map();
15746
+ #asideAdded = /* @__PURE__ */ new Map();
15747
+ #asideLifted = /* @__PURE__ */ new Set();
15748
+ #flushing = Promise.resolve();
15749
+ constructor(deps) {
15750
+ this.#file = deps.file;
15751
+ this.#now = deps.now;
15752
+ this.#fs = deps.fs ?? nodeUsageFs;
15753
+ this.#log = deps.log;
15754
+ }
15755
+ /** Whether the counters can be trusted. Before `load`, and after a read that failed, `unknown`. */
15756
+ get state() {
15757
+ return this.#state;
15758
+ }
15759
+ /** When this file began counting; 0 while `unknown`. */
15760
+ get since() {
15761
+ return this.#since;
15762
+ }
15763
+ /** Read the file. Never rejects: a file that cannot be read leaves the state `unknown`. */
15764
+ async load() {
15765
+ const read2 = await this.#read();
15766
+ if (read2 === "missing" || read2 === "unreadable" || read2 === "blocked") {
15767
+ this.#state = "unknown";
15768
+ this.#merge(void 0);
15769
+ return;
15770
+ }
15771
+ this.#state = "known";
15772
+ this.#since = read2.since;
15773
+ this.#baseRecords = read2.records;
15774
+ this.#baseAside = read2.setAside;
15775
+ this.#merge(read2);
15776
+ }
15777
+ /**
15778
+ * The file as it is now: 'missing', 'unreadable' (bad content, moved aside),
15779
+ * 'blocked' (there, but neither readable nor movable: never overwritten),
15780
+ * or its content.
15781
+ */
15782
+ async #read() {
15783
+ let text2;
15784
+ try {
15785
+ text2 = await this.#fs.readFile(this.#file);
15786
+ } catch (error) {
15787
+ if (error.code === "ENOENT") return "missing";
15788
+ this.#log?.("memory usage unreadable", { "namzu.memory.usage.reason": "read" });
15789
+ return "blocked";
15790
+ }
15791
+ const parsed = parse(text2);
15792
+ if (parsed) return parsed;
15793
+ this.#log?.("memory usage unreadable", { "namzu.memory.usage.reason": "corrupt" });
15794
+ try {
15795
+ await this.#fs.rename(this.#file, `${this.#file}.corrupt`);
15796
+ } catch {
15797
+ return "blocked";
15798
+ }
15799
+ return "unreadable";
15800
+ }
15801
+ /** The file's content with this process's pending changes laid over it. */
15802
+ #merge(file) {
15803
+ const records = new Map(Object.entries(file?.records ?? {}));
15804
+ for (const [id, delta] of this.#deltas) {
15805
+ const base = records.get(id);
15806
+ records.set(id, {
15807
+ recalls: (base?.recalls ?? 0) + delta.recalls,
15808
+ selected: (base?.selected ?? 0) + delta.selected,
15809
+ lastRecalledAt: Math.max(base?.lastRecalledAt ?? 0, delta.lastRecalledAt)
15810
+ });
15811
+ }
15812
+ const aside = new Map(Object.entries(file?.setAside ?? {}));
15813
+ for (const [id, entry] of this.#asideAdded) aside.set(id, entry);
15814
+ for (const id of this.#asideLifted) aside.delete(id);
15815
+ this.#records = records;
15816
+ this.#setAside = aside;
15817
+ }
15818
+ /** The counters of one record, or undefined when nothing was counted for it. */
15819
+ get(id) {
15820
+ return this.#records.get(id);
15821
+ }
15822
+ /** Recall put these records in front of the model. `selected` are those a selector chose. */
15823
+ recalled(ids, selected = []) {
15824
+ if (ids.length === 0) return;
15825
+ const at = this.#now();
15826
+ const chosen = new Set(selected);
15827
+ for (const id of new Set(ids)) {
15828
+ const delta = this.#deltas.get(id) ?? { recalls: 0, selected: 0, lastRecalledAt: 0 };
15829
+ delta.recalls += 1;
15830
+ if (chosen.has(id)) delta.selected += 1;
15831
+ delta.lastRecalledAt = at;
15832
+ this.#deltas.set(id, delta);
15833
+ }
15834
+ this.#merge(this.#base());
15835
+ }
15836
+ /** Set records aside: recall does not offer them again until `restore`. */
15837
+ setAside(ids) {
15838
+ const at = this.#now();
15839
+ for (const id of ids) {
15840
+ this.#asideLifted.delete(id);
15841
+ this.#asideAdded.set(id, { at, reason: "refused" });
15842
+ }
15843
+ this.#merge(this.#base());
15844
+ }
15845
+ /** Lift the set-aside of one record. */
15846
+ restore(id) {
15847
+ this.#asideAdded.delete(id);
15848
+ this.#asideLifted.add(id);
15849
+ this.#merge(this.#base());
15850
+ }
15851
+ isSetAside(id) {
15852
+ return this.#setAside.has(id);
15853
+ }
15854
+ /** The ids recall must skip. A fresh set each call. */
15855
+ setAsideIds() {
15856
+ return new Set(this.#setAside.keys());
15857
+ }
15858
+ /** What the file held when last read, without pending changes. */
15859
+ #base() {
15860
+ return {
15861
+ version: VERSION,
15862
+ since: this.#since,
15863
+ records: this.#baseRecords,
15864
+ setAside: this.#baseAside
15865
+ };
15866
+ }
15867
+ /** Whether anything waits to be written. */
15868
+ get dirty() {
15869
+ return this.#deltas.size > 0 || this.#asideAdded.size > 0 || this.#asideLifted.size > 0;
15870
+ }
15871
+ /** Write what is pending. Never rejects; calls queue behind one another. */
15872
+ flush() {
15873
+ this.#flushing = this.#flushing.then(() => this.#write());
15874
+ return this.#flushing;
15875
+ }
15876
+ async #write() {
15877
+ if (!this.dirty) return;
15878
+ try {
15879
+ const read2 = await this.#read();
15880
+ if (read2 === "blocked") {
15881
+ this.#log?.("memory usage not written", { "namzu.memory.usage.reason": "blocked" });
15882
+ return;
15883
+ }
15884
+ const current = read2 === "missing" || read2 === "unreadable" ? void 0 : read2;
15885
+ const since = current?.since ?? this.#since;
15886
+ const startedAt = since > 0 ? since : this.#now();
15887
+ this.#since = startedAt;
15888
+ this.#baseRecords = current?.records ?? {};
15889
+ this.#baseAside = current?.setAside ?? {};
15890
+ this.#merge(current ?? { version: VERSION, since: startedAt, records: {}, setAside: {} });
15891
+ const body2 = {
15892
+ version: VERSION,
15893
+ since: startedAt,
15894
+ records: Object.fromEntries(this.#records),
15895
+ setAside: Object.fromEntries(this.#setAside)
15896
+ };
15897
+ await this.#fs.mkdir(dirname6(this.#file));
15898
+ const temporary = `${this.#file}.${randomUUID7()}.tmp`;
15899
+ try {
15900
+ await this.#fs.writeFile(temporary, `${JSON.stringify(body2)}
15901
+ `);
15902
+ await this.#fs.rename(temporary, this.#file);
15903
+ } catch (error) {
15904
+ await this.#fs.rm(temporary).catch(() => void 0);
15905
+ throw error;
15906
+ }
15907
+ this.#deltas.clear();
15908
+ this.#asideAdded.clear();
15909
+ this.#asideLifted.clear();
15910
+ this.#baseRecords = body2.records;
15911
+ this.#baseAside = body2.setAside;
15912
+ this.#state = "known";
15913
+ this.#log?.("memory usage written", {
15914
+ "namzu.memory.usage.records": Object.keys(body2.records).length,
15915
+ "namzu.memory.usage.set_aside": Object.keys(body2.setAside).length
15916
+ });
15917
+ } catch {
15918
+ this.#log?.("memory usage not written", { "namzu.memory.usage.reason": "write" });
15919
+ }
15920
+ }
15921
+ };
15922
+
15149
15923
  // src/permissions/auto-classifier.ts
15150
15924
  import { AsyncLocalStorage } from "node:async_hooks";
15151
15925
  var SMALL_MODEL_KEYWORD = "smallModel";
@@ -15360,10 +16134,10 @@ __name(cliGate, "cliGate");
15360
16134
  var WEB_FETCH_TOOL = "web_fetch";
15361
16135
  var MAX_LABEL_COMMAND = 60;
15362
16136
  var MAX_RULES_PER_ANSWER = 5;
15363
- function isRecord3(value) {
16137
+ function isRecord4(value) {
15364
16138
  return typeof value === "object" && value !== null && !Array.isArray(value);
15365
16139
  }
15366
- __name(isRecord3, "isRecord");
16140
+ __name(isRecord4, "isRecord");
15367
16141
  function alwaysAsked(call) {
15368
16142
  return mustAskPerson(call) || call.isDestructive === true;
15369
16143
  }
@@ -15448,7 +16222,7 @@ function plainCommands(line) {
15448
16222
  __name(plainCommands, "plainCommands");
15449
16223
  function allowsFor(call, commands) {
15450
16224
  if (alwaysAsked(call)) return void 0;
15451
- const input = isRecord3(call.input) ? call.input : void 0;
16225
+ const input = isRecord4(call.input) ? call.input : void 0;
15452
16226
  const commandArgument = commands.get(call.name);
15453
16227
  if (commandArgument !== void 0) {
15454
16228
  const line = input?.[commandArgument];
@@ -15566,7 +16340,7 @@ function createSessionAllows(_commands, options = {}) {
15566
16340
  );
15567
16341
  }, "rebuild");
15568
16342
  const allowed = /* @__PURE__ */ __name((call) => {
15569
- if (isRecord3(call.toolInput) && call.toolInput.dangerously_disable_sandbox === true)
16343
+ if (isRecord4(call.toolInput) && call.toolInput.dangerously_disable_sandbox === true)
15570
16344
  return false;
15571
16345
  const result = gate?.evaluate(call);
15572
16346
  return result !== void 0 && result.matchedRule !== null && result.decision === "allow";
@@ -15745,7 +16519,7 @@ function buildEnterPlanModeTool(host) {
15745
16519
  __name(buildEnterPlanModeTool, "buildEnterPlanModeTool");
15746
16520
 
15747
16521
  // src/plan/plan-file.ts
15748
- import { readFile as readFile8 } from "node:fs/promises";
16522
+ import { readFile as readFile9 } from "node:fs/promises";
15749
16523
  import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
15750
16524
  var WRITERS = /* @__PURE__ */ new Set(["write", "edit"]);
15751
16525
  function isPlanFileWrite(planPath, cwd) {
@@ -15762,7 +16536,7 @@ function isPlanFileWrite(planPath, cwd) {
15762
16536
  __name(isPlanFileWrite, "isPlanFileWrite");
15763
16537
  async function readPlan(planPath) {
15764
16538
  try {
15765
- const text2 = await readFile8(planPath, "utf8");
16539
+ const text2 = await readFile9(planPath, "utf8");
15766
16540
  return text2.trim().length > 0 ? text2 : void 0;
15767
16541
  } catch {
15768
16542
  return void 0;
@@ -15903,7 +16677,7 @@ function terminalProviderRetry(restartableOutput) {
15903
16677
  __name(terminalProviderRetry, "terminalProviderRetry");
15904
16678
 
15905
16679
  // src/reminders/index.ts
15906
- import { existsSync as existsSync4 } from "node:fs";
16680
+ import { existsSync as existsSync5 } from "node:fs";
15907
16681
 
15908
16682
  // src/reminders/changed-files.ts
15909
16683
  import { open as open4, stat as stat5 } from "node:fs/promises";
@@ -16532,7 +17306,7 @@ function createCliReminderSource(options) {
16532
17306
  messages,
16533
17307
  mode: options.mode(),
16534
17308
  planPath,
16535
- planExists: (options.planExists ?? existsSync4)(planPath),
17309
+ planExists: (options.planExists ?? existsSync5)(planPath),
16536
17310
  canAsk: options.canAsk === true
16537
17311
  })
16538
17312
  );
@@ -17441,11 +18215,11 @@ __name(clipRequestContext, "clipRequestContext");
17441
18215
  async function createAgentSession(prefs, detectedProviders, options = {}) {
17442
18216
  const modelEnvironment = readModelLaunchEnvironment();
17443
18217
  if (options.palEnvironment) {
17444
- const { createPalAgentSession } = await import("./agent-session-B4TDRJON.js");
18218
+ const { createPalAgentSession } = await import("./agent-session-5ZG6WNTC.js");
17445
18219
  return createPalAgentSession(prefs, detectedProviders, options);
17446
18220
  }
17447
18221
  let detected = detectedProviders;
17448
- const { palAtWorkspace } = await import("./store-EWFTHK64.js");
18222
+ const { palAtWorkspace } = await import("./store-3R5KTEP5.js");
17449
18223
  if (palAtWorkspace(options.cwd ?? process.cwd()))
17450
18224
  throw new Error("This Pal requires its owned virtual computer. Open it with namzu pal chat.");
17451
18225
  const commandArguments = builtinCommandArguments();
@@ -17501,7 +18275,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
17501
18275
  );
17502
18276
  }
17503
18277
  const sandboxWorkspace = options.sandbox?.workspace ?? "working-directory";
17504
- if (options.sandbox?.enabled !== false && sandboxWorkspace === "working-directory" && cwd === parse(cwd).root) {
18278
+ if (options.sandbox?.enabled !== false && sandboxWorkspace === "working-directory" && cwd === parse2(cwd).root) {
17505
18279
  return emptySession(
17506
18280
  "Namzu will not run in the top-level folder of the disk with the sandbox on. Choose a project folder, or use a temporary workspace.",
17507
18281
  "invocation"
@@ -18475,7 +19249,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18475
19249
  runsDirectory: /* @__PURE__ */ __name((turnId) => {
18476
19250
  if (options.ephemeral) return void 0;
18477
19251
  const owner = delegationScopes.get(turnId) ?? scope2;
18478
- return join20(paths.sessionDir({ sessionId: owner.sessionId }), "runs");
19252
+ return join21(paths.sessionDir({ sessionId: owner.sessionId }), "runs");
18479
19253
  }, "runsDirectory"),
18480
19254
  refusal: /* @__PURE__ */ __name((turnId) => {
18481
19255
  const auth = delegatedWorkflowAuth.get(turnId);
@@ -18711,7 +19485,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18711
19485
  );
18712
19486
  toolsets.push(options.toolLoading === "eager" ? monitorToolset : deferred(monitorToolset));
18713
19487
  }
18714
- const operatorPals = await import("./operator-tools-72O5UTU7.js");
19488
+ const operatorPals = await import("./operator-tools-O43OOXJJ.js");
18715
19489
  toolsets.push(
18716
19490
  readyWhen(
18717
19491
  toolset(
@@ -18766,7 +19540,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18766
19540
  );
18767
19541
  const curationListeners = /* @__PURE__ */ new Set();
18768
19542
  const memoryInbox = new MemoryInbox({
18769
- file: join20(paths.home, "memory-inbox", `${paths.slug}.jsonl`),
19543
+ file: join21(paths.home, "memory-inbox", `${paths.slug}.jsonl`),
18770
19544
  now: Date.now
18771
19545
  });
18772
19546
  const curation = options.memory?.curation === "off" || options.compaction?.consolidate ? void 0 : new CurationRuntime({
@@ -18775,7 +19549,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18775
19549
  store: memoryStore,
18776
19550
  sideModel: /* @__PURE__ */ __name(() => sideModel, "sideModel"),
18777
19551
  fallback: screenedPromoter,
18778
- log: createCurationLog(join20(paths.home, "memory", "curation.jsonl"))
19552
+ log: createCurationLog(join21(paths.home, "memory", "curation.jsonl"))
18779
19553
  }),
18780
19554
  setTimer: /* @__PURE__ */ __name((run2, ms) => {
18781
19555
  const handle = setTimeout(run2, ms);
@@ -18793,6 +19567,31 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18793
19567
  "namzu.memory.curation.result": typeof result === "string" ? result : `${result.applied}/${result.kept}/${result.dropped}`
18794
19568
  }), "report")
18795
19569
  });
19570
+ const memoryUsage = new MemoryUsage({
19571
+ file: join21(paths.home, "memory-usage", `${paths.slug}.json`),
19572
+ now: Date.now,
19573
+ log: /* @__PURE__ */ __name((message2, fields) => cliLogger().debug(message2, fields), "log")
19574
+ });
19575
+ const memoryLifecycle = new MemoryLifecycle({
19576
+ store: memoryStore,
19577
+ usage: memoryUsage,
19578
+ now: Date.now,
19579
+ retireAfterDays: options.memory?.retireAfterDays ?? DEFAULT_RETIRE_AFTER_DAYS,
19580
+ isDraining: /* @__PURE__ */ __name(() => curation?.draining === true, "isDraining"),
19581
+ setTimer: /* @__PURE__ */ __name((run2, ms) => {
19582
+ const handle = setTimeout(run2, ms);
19583
+ handle.unref?.();
19584
+ return handle;
19585
+ }, "setTimer"),
19586
+ clearTimer: /* @__PURE__ */ __name((handle) => clearTimeout(handle), "clearTimer"),
19587
+ log: /* @__PURE__ */ __name((message2, fields) => cliLogger().info(message2, fields), "log"),
19588
+ onSwept: /* @__PURE__ */ __name((report) => {
19589
+ const lines = [
19590
+ `Retired ${report.archived.length} ${report.archived.length === 1 ? "memory" : "memories"} that were not used. /memory restores ${report.archived.length === 1 ? "it" : "them"}.`
19591
+ ];
19592
+ for (const listener of curationListeners) listener(lines);
19593
+ }, "onSwept")
19594
+ });
18796
19595
  const promoteMemory = composeMemoryPromotion({
18797
19596
  curation,
18798
19597
  inbox: memoryInbox,
@@ -18855,6 +19654,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18855
19654
  (ts) => ts.tools().some((tool) => tool.name === "save_memory")
18856
19655
  ) ? composeMemoryGuidance({ taskList: !withheldTools.has("task_create") }) : void 0;
18857
19656
  const shellEscapeGuidance = options.askUser ? SHELL_ESCAPE_GUIDANCE : void 0;
19657
+ const filePlacementGuidance = composeFilePlacementGuidance(process.platform);
18858
19658
  const manager = new ToolManager({
18859
19659
  toolsets: sessionToolsets,
18860
19660
  ...screensConfig !== void 0 ? { resultGuardrails: screensConfig } : {},
@@ -18921,12 +19721,14 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18921
19721
  [EVENT_NAME_ATTRIBUTE]: BOOT_EVENT_NAMES.BOOT_READY
18922
19722
  });
18923
19723
  curation?.start();
19724
+ void memoryLifecycle.start();
18924
19725
  const reasoningLookup = new AbortController();
18925
19726
  const ephemeralLogs = /* @__PURE__ */ new Map();
18926
19727
  const ephemeralScopeKey = /* @__PURE__ */ __name((value) => JSON.stringify([value.tenantId, value.projectId, value.topicId, value.sessionId]), "ephemeralScopeKey");
18927
19728
  const operations = new SessionOperationOwner(async () => {
18928
19729
  reasoningLookup.abort();
18929
19730
  await curation?.dispose();
19731
+ await memoryLifecycle.dispose();
18930
19732
  workflowHost?.registry.close();
18931
19733
  const results = await Promise.allSettled([
18932
19734
  Promise.resolve().then(() => manager.dispose()),
@@ -19093,6 +19895,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19093
19895
  withheldTools: options.withheldTools,
19094
19896
  memoryGuidance,
19095
19897
  shellEscapeGuidance,
19898
+ filePlacementGuidance,
19096
19899
  conversationSessions: options.conversationSessions,
19097
19900
  toolLoading: options.toolLoading,
19098
19901
  anyToolDeferred: anyDeferred(sessionToolsets),
@@ -19161,6 +19964,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19161
19964
  delegationScopes.set(entry2.turnId, turnScope);
19162
19965
  latestTurn = { sessionId: turnScope.sessionId, turnId: entry2.turnId };
19163
19966
  curation?.turnStarted();
19967
+ memoryLifecycle.turnStarted();
19164
19968
  delegationLimits.set(entry2.turnId, resumedLimits);
19165
19969
  if (route && pinned)
19166
19970
  delegationModels.set(entry2.turnId, {
@@ -19205,6 +20009,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19205
20009
  store: memoryStore,
19206
20010
  identifierGrounding: options.memory?.identifierGrounding,
19207
20011
  record: true,
20012
+ excluded: memoryLifecycle.excluded,
19208
20013
  ...memorySelection
19209
20014
  })
19210
20015
  ],
@@ -19407,6 +20212,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19407
20212
  },
19408
20213
  providerSummary: entry.id === "anthropic" ? withEndpointHost(entry.label) : entry.label,
19409
20214
  modelSummary: model,
20215
+ providerId: entry.id,
19410
20216
  get autoRoute() {
19411
20217
  return lastAutoRoute;
19412
20218
  },
@@ -19607,7 +20413,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19607
20413
  const live = host.registry.list();
19608
20414
  const known = new Set(live.map((view) => view.runId));
19609
20415
  const saved = options.ephemeral ? [] : await listWorkflowRuns(
19610
- join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs")
20416
+ join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs")
19611
20417
  ).catch(() => []);
19612
20418
  return [
19613
20419
  ...[...live].sort((a, b) => b.startedAt - a.startedAt),
@@ -19617,14 +20423,14 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19617
20423
  readScript: /* @__PURE__ */ __name((path) => {
19618
20424
  const saved = readSavedScript(
19619
20425
  path,
19620
- scriptsDirectory(join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"))
20426
+ scriptsDirectory(join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"))
19621
20427
  );
19622
20428
  if (!saved.ok) return void 0;
19623
20429
  reviewedScripts.record(saved.path, saved.text);
19624
20430
  return saved.text;
19625
20431
  }, "readScript"),
19626
20432
  describeResume: /* @__PURE__ */ __name((runId, script) => describeResume(
19627
- join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
20433
+ join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
19628
20434
  runId,
19629
20435
  script,
19630
20436
  options.ephemeral ? void 0 : workflowJournalKey(paths.home)
@@ -19632,13 +20438,13 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19632
20438
  recoverUnfinished: /* @__PURE__ */ __name(async () => {
19633
20439
  if (options.ephemeral) return [];
19634
20440
  return recoverUnfinishedWorkflows({
19635
- runsDirectory: join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
20441
+ runsDirectory: join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
19636
20442
  liveRunIds: new Set(host.registry.list().map((view) => view.runId)),
19637
20443
  ...workflowJournalKey(paths.home) !== void 0 ? { key: workflowJournalKey(paths.home) } : {}
19638
20444
  });
19639
20445
  }, "recoverUnfinished"),
19640
20446
  noticesDelivered: /* @__PURE__ */ __name((runIds) => markOrphanNoticesDelivered(
19641
- join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
20447
+ join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
19642
20448
  runIds
19643
20449
  ), "noticesDelivered"),
19644
20450
  onEnd: /* @__PURE__ */ __name((listener) => {
@@ -19704,6 +20510,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19704
20510
  delegationScopes.set(turnId, turnScope);
19705
20511
  latestTurn = { sessionId: turnScope.sessionId, turnId };
19706
20512
  curation?.turnStarted();
20513
+ memoryLifecycle.turnStarted();
19707
20514
  delegationLimits.set(turnId, resolveTurnGuards(options.limits, opts?.limits));
19708
20515
  delegatedResumeHandlers.set(turnId, control.handler);
19709
20516
  delegatedReviewAllowedCalls.set(turnId, control.reviewAllowedCalls);
@@ -19895,7 +20702,15 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19895
20702
  })
19896
20703
  }), "storedMemoryIndex"),
19897
20704
  storedMemories: {
19898
- load: /* @__PURE__ */ __name(() => loadManagedMemories(memoryStore, memoryDirectory), "load"),
20705
+ load: /* @__PURE__ */ __name(() => loadManagedMemories(memoryStore, memoryDirectory, {
20706
+ usage: memoryUsage,
20707
+ retireAfterDays: options.memory?.retireAfterDays ?? DEFAULT_RETIRE_AFTER_DAYS
20708
+ }), "load"),
20709
+ restore: /* @__PURE__ */ __name((item) => restoreManagedMemory(memoryStore, item, (id) => memoryLifecycle.restore(id)), "restore"),
20710
+ tidy: /* @__PURE__ */ __name(async () => {
20711
+ const retireAfterDays = options.memory?.retireAfterDays ?? DEFAULT_RETIRE_AFTER_DAYS;
20712
+ return describeSweep(await memoryLifecycle.tidy(), retireAfterDays);
20713
+ }, "tidy"),
19899
20714
  read: /* @__PURE__ */ __name((item) => readMemoryBody(memoryStore, item.id), "read"),
19900
20715
  remove: /* @__PURE__ */ __name((item) => deleteManagedMemory(memoryStore, item), "remove"),
19901
20716
  removeRecorded: /* @__PURE__ */ __name((items) => deleteRecordedMemories(memoryStore, items), "removeRecorded"),
@@ -19995,6 +20810,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19995
20810
  delegationScopes.set(turnId2, turnScope);
19996
20811
  latestTurn = { sessionId: turnScope.sessionId, turnId: turnId2 };
19997
20812
  curation?.turnStarted();
20813
+ memoryLifecycle.turnStarted();
19998
20814
  delegationLimits.set(turnId2, turnLimits);
19999
20815
  const typedTarget = parseTokenTarget(opts?.typedInput ?? "");
20000
20816
  if (typedTarget !== void 0) workflowTokenTargets.set(turnId2, typedTarget);
@@ -20124,6 +20940,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20124
20940
  withheldTools: options.withheldTools,
20125
20941
  memoryGuidance,
20126
20942
  shellEscapeGuidance,
20943
+ filePlacementGuidance,
20127
20944
  conversationSessions: options.conversationSessions,
20128
20945
  toolLoading: options.toolLoading,
20129
20946
  anyToolDeferred: anyDeferred(runToolsets),
@@ -20324,6 +21141,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20324
21141
  reviewAnswer: options.reviewAnswer,
20325
21142
  maxAnswerReviews: options.maxAnswerReviews,
20326
21143
  promoteMemory: options.compaction?.consolidate ? void 0 : promoteMemory,
21144
+ ...options.memory?.recall === false ? {} : { memoryLifecycle },
20327
21145
  prepareStep: [
20328
21146
  createTaskContextStep(turnTaskStore, turnScope.tenantId),
20329
21147
  outstandingWorkStep,
@@ -20335,6 +21153,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20335
21153
  query: lastPromptText(messages),
20336
21154
  identifierGrounding: options.memory?.identifierGrounding,
20337
21155
  record: true,
21156
+ excluded: memoryLifecycle.excluded,
20338
21157
  ...memorySelection
20339
21158
  })
20340
21159
  ],
@@ -20937,6 +21756,7 @@ async function* runTurn({
20937
21756
  reviewAnswer,
20938
21757
  maxAnswerReviews,
20939
21758
  promoteMemory,
21759
+ memoryLifecycle,
20940
21760
  prepareStep,
20941
21761
  resumeHandler,
20942
21762
  approvalPolicyName,
@@ -20972,6 +21792,10 @@ async function* runTurn({
20972
21792
  const events = query({
20973
21793
  maxOutputContinuations: MAX_OUTPUT_CONTINUATIONS,
20974
21794
  ...opts?.refusalFallback ? { refusalFallback: opts.refusalFallback } : {},
21795
+ ...memoryLifecycle ? {
21796
+ withholdOnRefusal: memoryLifecycle.withholdOnRefusal,
21797
+ withheldKeys: memoryLifecycle.withheldKeys()
21798
+ } : {},
20975
21799
  ...retainedToolPreviewChars !== void 0 ? { retainedToolPreviewChars } : {},
20976
21800
  ...fileReadTracker ? { fileReadTracker } : {},
20977
21801
  ...structuredOutput ? { structuredOutput } : {},
@@ -21025,6 +21849,7 @@ async function* runTurn({
21025
21849
  model,
21026
21850
  ...sandboxProvider ? { sandbox: { workspace: sandboxWorkspace } } : {},
21027
21851
  ...opts?.effort !== void 0 ? { effort: opts.effort } : {},
21852
+ ...opts?.speed === "fast" ? { speed: opts.speed } : {},
21028
21853
  ...webSearch ? { webSearch } : {},
21029
21854
  ...turnConfigFields(resolveTurnGuards(limits), { completionAudit: true }),
21030
21855
  maxResponseTokens: limits?.maxResponseTokens ?? 8192,
@@ -21088,6 +21913,7 @@ async function* runTurn({
21088
21913
  claimTurn(event.turnId);
21089
21914
  }
21090
21915
  onSessionEvent?.(event);
21916
+ memoryLifecycle?.observe(event);
21091
21917
  if (signal?.aborted) {
21092
21918
  if (!abortReported) {
21093
21919
  abortReported = true;
@@ -21488,15 +22314,15 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
21488
22314
  };
21489
22315
  case "message_history_repaired": {
21490
22316
  if (event.source === "provider-rejected-image") {
21491
- const count = event.providerRejectedImagesSuppressed ?? 0;
22317
+ const count2 = event.providerRejectedImagesSuppressed ?? 0;
21492
22318
  return {
21493
22319
  kind: "history-repair",
21494
22320
  source: event.source,
21495
22321
  duplicateResults: event.duplicateToolResultsRemoved,
21496
22322
  orphanedResults: event.orphanedToolResultsRemoved,
21497
22323
  interruptedCalls: event.syntheticToolResultsInserted,
21498
- rejectedImages: count,
21499
- text: `The provider rejected ${count} image occurrence${count === 1 ? "" : "s"}. The original attachment bytes were kept, but that image will be omitted from later model requests; attach a corrected copy to try again.`
22324
+ rejectedImages: count2,
22325
+ text: `The provider rejected ${count2} image occurrence${count2 === 1 ? "" : "s"}. The original attachment bytes were kept, but that image will be omitted from later model requests; attach a corrected copy to try again.`
21500
22326
  };
21501
22327
  }
21502
22328
  const changes = [
@@ -21875,6 +22701,7 @@ export {
21875
22701
  renderRestoreNote,
21876
22702
  PluginSettingsStore,
21877
22703
  validateComposerSendSettings,
22704
+ DecisionError,
21878
22705
  maybeCreateDecisionTool,
21879
22706
  maybeCreateDecisionModel,
21880
22707
  resolveAutoDefault,
@@ -21927,6 +22754,7 @@ export {
21927
22754
  PROGRESS_LOOK_MIN_GAP_MS,
21928
22755
  PHASE_NOTE_KEY_PREFIX,
21929
22756
  describePendingWorkflowNotices,
22757
+ thirdPartyHost,
21930
22758
  sessionLogCheckpointView,
21931
22759
  discoverAgentDefinitions2 as discoverAgentDefinitions,
21932
22760
  DEFAULT_AGENT_WORKFLOW,
@@ -21951,6 +22779,7 @@ export {
21951
22779
  matchMemories,
21952
22780
  listMatches,
21953
22781
  renderMemoryDetail,
22782
+ restoreOutcomeLine,
21954
22783
  RECALLED_MEMORY_KEY,
21955
22784
  historyHoldsAnyMemory,
21956
22785
  deleteOutcomeLine,
@@ -22000,4 +22829,4 @@ export {
22000
22829
  RESULT_SUMMARY_WHOLE_MAX,
22001
22830
  resultSummaryLine
22002
22831
  };
22003
- //# sourceMappingURL=chunk-554QWHL6.js.map
22832
+ //# sourceMappingURL=chunk-G5LUEMDI.js.map