@namzu/cli 48.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 (331) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-QUCU36XL.js → acp-2INAZYZT.js} +45 -45
  4. package/dist/chunks/{activity-command-W6575T4W.js → activity-command-J676MIML.js} +12 -12
  5. package/dist/chunks/{add-GLFGOQVN.js → add-LI4SX4YZ.js} +19 -19
  6. package/dist/chunks/{agent-VBCJRRQU.js → agent-LUK4L4AW.js} +35 -35
  7. package/dist/chunks/agent-session-5ZG6WNTC.js +69 -0
  8. package/dist/chunks/{archive-QEPJAF7T.js → archive-IZRS7P6C.js} +10 -10
  9. package/dist/chunks/{bin-main-D4Q3AFND.js → bin-main-XNB6LHOP.js} +7 -7
  10. package/dist/chunks/{binding-CEZSAC3K.js → binding-3EE2IYAM.js} +3 -3
  11. package/dist/chunks/{browser-XZZSBZG7.js → browser-NI2ZPG4N.js} +6 -6
  12. package/dist/chunks/{chat-ESJVUJKJ.js → chat-5OEOFTSO.js} +15 -15
  13. package/dist/chunks/{chunk-BYQSDH2F.js → chunk-2FMMT4JD.js} +2 -2
  14. package/dist/chunks/{chunk-2EPEWMI7.js → chunk-2GBI7JYG.js} +2 -2
  15. package/dist/chunks/{chunk-JWMBGGFY.js → chunk-43Q3E36I.js} +2 -2
  16. package/dist/chunks/{chunk-JIUBDOX4.js → chunk-4ET34X7Z.js} +2 -2
  17. package/dist/chunks/{chunk-6E63NHFK.js → chunk-4GFWZYTR.js} +5 -5
  18. package/dist/chunks/{chunk-6YIA342V.js → chunk-4IYPPPIR.js} +4 -4
  19. package/dist/chunks/{chunk-K5IWQLOE.js → chunk-4UXO3V22.js} +3 -3
  20. package/dist/chunks/{chunk-SJTDYH2Q.js → chunk-4WFAYG6V.js} +972 -860
  21. package/dist/chunks/{chunk-SJTDYH2Q.js.map → chunk-4WFAYG6V.js.map} +3 -3
  22. package/dist/chunks/{chunk-UXYOP32R.js → chunk-564OI5HN.js} +2 -2
  23. package/dist/chunks/{chunk-HAYKZJ4W.js → chunk-56IRGZRX.js} +3 -3
  24. package/dist/chunks/{chunk-YJV5ARUB.js → chunk-5AQVWTHV.js} +2 -2
  25. package/dist/chunks/{chunk-5EIUKBFJ.js → chunk-5WOHNIH4.js} +5 -2
  26. package/dist/chunks/chunk-5WOHNIH4.js.map +6 -0
  27. package/dist/chunks/{chunk-JHGICKYH.js → chunk-6CZOIEKE.js} +225 -16
  28. package/dist/chunks/chunk-6CZOIEKE.js.map +6 -0
  29. package/dist/chunks/{chunk-SPLCWH4W.js → chunk-6T7HV4J5.js} +35 -11
  30. package/dist/chunks/{chunk-SPLCWH4W.js.map → chunk-6T7HV4J5.js.map} +1 -1
  31. package/dist/chunks/{chunk-E7STKX6D.js → chunk-6TUISLKZ.js} +2 -2
  32. package/dist/chunks/{chunk-T5MEHPLZ.js → chunk-753B7NQX.js} +40 -33
  33. package/dist/chunks/chunk-753B7NQX.js.map +6 -0
  34. package/dist/chunks/{chunk-U6LKWLSO.js → chunk-7DSJTL5S.js} +2 -2
  35. package/dist/chunks/{chunk-7R42TMRR.js → chunk-AOKRFS3Z.js} +2 -2
  36. package/dist/chunks/{chunk-QKE5HLHV.js → chunk-BCFC5GGU.js} +12 -12
  37. package/dist/chunks/{chunk-26JTVEWV.js → chunk-BPW5AT4B.js} +3 -3
  38. package/dist/chunks/{chunk-ZEHU7KPN.js → chunk-CDOLJHIB.js} +2 -2
  39. package/dist/chunks/{chunk-C3F76W74.js → chunk-CDT745GI.js} +4 -4
  40. package/dist/chunks/{chunk-N47CNO6M.js → chunk-DKJHMWCA.js} +7 -7
  41. package/dist/chunks/{chunk-ZKBZZ4SV.js → chunk-E6XGUJ2I.js} +3 -3
  42. package/dist/chunks/{chunk-ESXU3WTP.js → chunk-EISC5X74.js} +2 -2
  43. package/dist/chunks/{chunk-ZSJUNNOB.js → chunk-EPS5ROMN.js} +9 -9
  44. package/dist/chunks/{chunk-MGLG65W5.js → chunk-G4SE3TXK.js} +10 -10
  45. package/dist/chunks/{chunk-RXUDOOPL.js → chunk-G5LUEMDI.js} +953 -172
  46. package/dist/chunks/chunk-G5LUEMDI.js.map +6 -0
  47. package/dist/chunks/{chunk-WYT7R7OV.js → chunk-GBRTN4AK.js} +3 -3
  48. package/dist/chunks/{chunk-QQM7JSEY.js → chunk-GCIBSVYX.js} +4 -4
  49. package/dist/chunks/{chunk-X4XZVFAV.js → chunk-GEX2EXU3.js} +4 -4
  50. package/dist/chunks/{chunk-HLJHOUY5.js → chunk-GXSMCKZJ.js} +3 -3
  51. package/dist/chunks/{chunk-MHF4AD7R.js → chunk-HNBF54TV.js} +5 -5
  52. package/dist/chunks/{chunk-BFBE2M7Q.js → chunk-HUUVQBZR.js} +3 -3
  53. package/dist/chunks/{chunk-6DTG2DJM.js → chunk-HXV7TDNY.js} +2 -2
  54. package/dist/chunks/{chunk-YBRLTSWM.js → chunk-KZNMCCYK.js} +3 -3
  55. package/dist/chunks/{chunk-HF22LWEO.js → chunk-L3VAFXRU.js} +6 -6
  56. package/dist/chunks/{chunk-KCVKLMKN.js → chunk-LJHHAKBL.js} +3 -3
  57. package/dist/chunks/{chunk-5BA47MKJ.js → chunk-LNDECWNR.js} +2 -2
  58. package/dist/chunks/{chunk-UYP5QIPH.js → chunk-LYSN3FIQ.js} +3 -3
  59. package/dist/chunks/{chunk-HMAF5UAO.js → chunk-MCTUVMMB.js} +4 -4
  60. package/dist/chunks/{chunk-QSIMY7WM.js → chunk-NJWCOR7Z.js} +2 -2
  61. package/dist/chunks/{chunk-WUSDW5Z5.js → chunk-OOWGXPY2.js} +2 -2
  62. package/dist/chunks/{chunk-2FHIHK3T.js → chunk-P2CHZ6FL.js} +3 -3
  63. package/dist/chunks/{chunk-V3MC2IFR.js → chunk-P3KXW262.js} +2 -2
  64. package/dist/chunks/{chunk-XRNUFV7Q.js → chunk-P7YVC6KA.js} +2 -2
  65. package/dist/chunks/{chunk-F3ZHJSWR.js → chunk-PVCJHQP5.js} +6 -6
  66. package/dist/chunks/{chunk-5NOMF3HN.js → chunk-QUKAQLNS.js} +9 -9
  67. package/dist/chunks/{chunk-XX6ZE5ZO.js → chunk-R2KYP3AT.js} +2 -2
  68. package/dist/chunks/{chunk-YVV5ZHID.js → chunk-R7TYDKKC.js} +4 -4
  69. package/dist/chunks/{chunk-A3H6DYWZ.js → chunk-RR3ASZMK.js} +3 -3
  70. package/dist/chunks/{chunk-7M3ACGKA.js → chunk-SLRBCV4D.js} +2 -2
  71. package/dist/chunks/{chunk-66YF5N2J.js → chunk-SMJQ7LVL.js} +2 -2
  72. package/dist/chunks/{chunk-DDXZZ7TR.js → chunk-SR32C4A7.js} +3 -3
  73. package/dist/chunks/{chunk-VRO3BSVC.js → chunk-TP62BP32.js} +9 -9
  74. package/dist/chunks/{chunk-X3YRAYJU.js → chunk-USIRIOSH.js} +4 -4
  75. package/dist/chunks/{chunk-CKAVXPSD.js → chunk-UZX4K743.js} +3 -3
  76. package/dist/chunks/{chunk-AHSWXUMT.js → chunk-VJAVIDVB.js} +4 -4
  77. package/dist/chunks/{chunk-A7RJ323Z.js → chunk-W3M3UGWQ.js} +4 -4
  78. package/dist/chunks/{chunk-ONLVC5X5.js → chunk-WI5ADHTS.js} +2 -2
  79. package/dist/chunks/{chunk-GYIRPQFB.js → chunk-WX6B7RLT.js} +2 -2
  80. package/dist/chunks/{chunk-LHCRLCMO.js → chunk-XK4ANTIO.js} +2 -2
  81. package/dist/chunks/{chunk-XD26GMKP.js → chunk-XKRU6FOU.js} +2 -2
  82. package/dist/chunks/{chunk-RBH5ZABR.js → chunk-Y34RP2OI.js} +6 -6
  83. package/dist/chunks/{chunk-NLVUDQEQ.js → chunk-YFKC2GZP.js} +4 -4
  84. package/dist/chunks/{chunk-UVR7C4T5.js → chunk-YJPHE4O3.js} +5 -5
  85. package/dist/chunks/{chunk-LE4QZ6HS.js → chunk-YJYFQW2F.js} +3 -3
  86. package/dist/chunks/{chunk-YRBLDFMI.js → chunk-YNJ3SWIL.js} +4 -4
  87. package/dist/chunks/{chunk-6EP5UWMA.js → chunk-YPKTYCDZ.js} +3 -3
  88. package/dist/chunks/{chunk-UT5XJ2JQ.js → chunk-YW3GNCCK.js} +3 -3
  89. package/dist/chunks/{chunk-IQCUP4GF.js → chunk-YYLILI2G.js} +2 -2
  90. package/dist/chunks/{chunk-HZU57YBL.js → chunk-ZBLTMOOD.js} +2 -2
  91. package/dist/chunks/{chunk-QROBMHWX.js → chunk-ZFBUNTJO.js} +3 -3
  92. package/dist/chunks/{chunk-FXPGZQWX.js → chunk-ZLQ5BZ4X.js} +2 -2
  93. package/dist/chunks/{chunk-AWRDGYDV.js → chunk-ZP4KWNIL.js} +13 -13
  94. package/dist/chunks/{cli-runtime-YLIWHNME.js → cli-runtime-EDDXHFSX.js} +11 -10
  95. package/dist/chunks/cli-runtime-EDDXHFSX.js.map +6 -0
  96. package/dist/chunks/{commands-WT4OLTGL.js → commands-KESYD3SM.js} +5 -5
  97. package/dist/chunks/{crash-report-BTL3U5HH.js → crash-report-JRRCPLE7.js} +6 -6
  98. package/dist/chunks/{dist-2NYSROLX.js → dist-7V7KU2WK.js} +126 -10
  99. package/dist/chunks/dist-7V7KU2WK.js.map +6 -0
  100. package/dist/chunks/{dist-OHQWXZ7N.js → dist-DLVIWPSW.js} +2 -2
  101. package/dist/chunks/{dist-LRK6JYLM.js → dist-EGALCLMC.js} +2 -2
  102. package/dist/chunks/{dist-3PNUHQCO.js → dist-F3BMUZ3P.js} +2 -2
  103. package/dist/chunks/{dist-N4TBL3SN.js → dist-GZSRTUES.js} +2 -2
  104. package/dist/chunks/{dist-3R6SQ3VB.js → dist-IEWJJJHL.js} +4 -2
  105. package/dist/chunks/{dist-4TCR3HDF.js → dist-ML6MP7J3.js} +2 -2
  106. package/dist/chunks/{dist-X7K5G5NH.js → dist-XUIAXPXU.js} +2 -2
  107. package/dist/chunks/{doctor-5JQK6UNK.js → doctor-URLWCDCG.js} +16 -16
  108. package/dist/chunks/{drain-EHO3BUHW.js → drain-XYBMXTKG.js} +9 -9
  109. package/dist/chunks/{entry-F2EIOWAT.js → entry-BTK3MMFH.js} +6 -6
  110. package/dist/chunks/{eval-7YEMHHIB.js → eval-SS6TIGOD.js} +2 -2
  111. package/dist/chunks/{exec-WV7BS5UD.js → exec-MGDFWPM2.js} +34 -34
  112. package/dist/chunks/{home-GOMDEEXP.js → home-PPWVKIU6.js} +3 -3
  113. package/dist/chunks/{host-MNPHBQWG.js → host-RHMJMJAH.js} +10 -10
  114. package/dist/chunks/{host-queries-SKWE7PF5.js → host-queries-DUR62LWA.js} +15 -15
  115. package/dist/chunks/{learn-BUEAUHTD.js → learn-AF7N7BLO.js} +11 -11
  116. package/dist/chunks/{learn-builtin-XZFBPA3W.js → learn-builtin-J7GKFBXU.js} +14 -14
  117. package/dist/chunks/{lifecycle-HMSOBI6F.js → lifecycle-RGXBSC3L.js} +28 -28
  118. package/dist/chunks/{list-HNSWMLVN.js → list-YOLX5SWE.js} +11 -10
  119. package/dist/chunks/list-YOLX5SWE.js.map +6 -0
  120. package/dist/chunks/{live-ER3OZKC6.js → live-RVNUQYAY.js} +15 -15
  121. package/dist/chunks/{login-EBEFMEA2.js → login-RFNV3I7R.js} +13 -13
  122. package/dist/chunks/{logs-5UJZYNN2.js → logs-RTREGKV5.js} +4 -4
  123. package/dist/chunks/{mcp-BLERKK2H.js → mcp-SPQQPLJE.js} +20 -20
  124. package/dist/chunks/{message-command-XH2M4BTB.js → message-command-E7V5KLFO.js} +41 -41
  125. package/dist/chunks/{open-ZYWPDOR6.js → open-P43XO4HN.js} +8 -8
  126. package/dist/chunks/{operator-tools-CZ2SXR3G.js → operator-tools-O43OOXJJ.js} +13 -13
  127. package/dist/chunks/{output-schema-MFZZP7GF.js → output-schema-HQ37VOZT.js} +3 -3
  128. package/dist/chunks/{pal-7OYQHUKF.js → pal-24C6YOEW.js} +16 -16
  129. package/dist/chunks/{peers-FCVTBNI5.js → peers-722AUQGX.js} +6 -6
  130. package/dist/chunks/{peers-V3Z3ZQSN.js → peers-IPO7XN5V.js} +7 -7
  131. package/dist/chunks/{providers-43RE2SWA.js → providers-5OKXU3AF.js} +11 -11
  132. package/dist/chunks/{pty-QSS3UQ7C.js → pty-2YQ4ASHS.js} +3 -3
  133. package/dist/chunks/resume-IP4SVMRZ.js +23 -0
  134. package/dist/chunks/{resume-command-WZY42BAB.js → resume-command-SGKIUUR7.js} +4 -4
  135. package/dist/chunks/{schedule-LHXNUQHJ.js → schedule-6JFYGG2R.js} +8 -8
  136. package/dist/chunks/{service-ZU5YIBW4.js → service-WJ5VNXQ5.js} +28 -28
  137. package/dist/chunks/{skills-K2MFIY4H.js → skills-PCETONZ5.js} +8 -8
  138. package/dist/chunks/{start-check-AODGFYJD.js → start-check-UJOG3VAS.js} +2 -2
  139. package/dist/chunks/{startup-failure-B6ESBTLZ.js → startup-failure-Q5I6S7KQ.js} +2 -2
  140. package/dist/chunks/{state-ZWXVSLS2.js → state-NUXXHBA5.js} +2 -2
  141. package/dist/chunks/{store-MNI5IJHC.js → store-3R5KTEP5.js} +6 -6
  142. package/dist/chunks/{store-JAI2RWQT.js → store-A2RYRTI6.js} +3 -3
  143. package/dist/chunks/{store-U6SG2CON.js → store-KO52OXSR.js} +4 -4
  144. package/dist/chunks/{store-NKISDMPC.js → store-XO6CFKZI.js} +10 -10
  145. package/dist/chunks/{tui-TM5QW6KY.js → tui-AAB7734Z.js} +1084 -98
  146. package/dist/chunks/tui-AAB7734Z.js.map +6 -0
  147. package/dist/chunks/{upgrade-27ZDBTX7.js → upgrade-NPINYN5F.js} +7 -7
  148. package/dist/chunks/{workspaces-X7W7ZQU3.js → workspaces-BGRV6TQ6.js} +16 -16
  149. package/dist/chunks/{worktree-SIA6C5NS.js → worktree-5LYQWD4H.js} +12 -12
  150. package/dist/cli.d.ts.map +1 -1
  151. package/dist/config/load.d.ts.map +1 -1
  152. package/dist/config/schema.d.ts +10 -0
  153. package/dist/config/schema.d.ts.map +1 -1
  154. package/dist/index.js +19 -19
  155. package/dist/integrations/decision/connection.d.ts +89 -0
  156. package/dist/integrations/decision/connection.d.ts.map +1 -0
  157. package/dist/integrations/decision/model.d.ts +21 -8
  158. package/dist/integrations/decision/model.d.ts.map +1 -1
  159. package/dist/integrations/decision/openrouter.d.ts +68 -0
  160. package/dist/integrations/decision/openrouter.d.ts.map +1 -0
  161. package/dist/integrations/decision/paste.d.ts +19 -0
  162. package/dist/integrations/decision/paste.d.ts.map +1 -0
  163. package/dist/integrations/decision/setup.d.ts +62 -0
  164. package/dist/integrations/decision/setup.d.ts.map +1 -0
  165. package/dist/integrations/decision/token.d.ts +34 -0
  166. package/dist/integrations/decision/token.d.ts.map +1 -0
  167. package/dist/memory/curation-runtime.d.ts +8 -1
  168. package/dist/memory/curation-runtime.d.ts.map +1 -1
  169. package/dist/memory/lifecycle.d.ts +62 -0
  170. package/dist/memory/lifecycle.d.ts.map +1 -0
  171. package/dist/memory/manage.d.ts +37 -2
  172. package/dist/memory/manage.d.ts.map +1 -1
  173. package/dist/memory/sweep.d.ts +66 -0
  174. package/dist/memory/sweep.d.ts.map +1 -0
  175. package/dist/memory/usage.d.ts +79 -0
  176. package/dist/memory/usage.d.ts.map +1 -0
  177. package/dist/tui/App.d.ts +23 -0
  178. package/dist/tui/App.d.ts.map +1 -1
  179. package/dist/tui/StatusBar.d.ts +5 -1
  180. package/dist/tui/StatusBar.d.ts.map +1 -1
  181. package/dist/tui/agent.d.ts +10 -2
  182. package/dist/tui/agent.d.ts.map +1 -1
  183. package/dist/tui/decision-setup-flow.d.ts +57 -0
  184. package/dist/tui/decision-setup-flow.d.ts.map +1 -0
  185. package/dist/tui/fast-mode.d.ts +24 -0
  186. package/dist/tui/fast-mode.d.ts.map +1 -0
  187. package/dist/tui/index.d.ts.map +1 -1
  188. package/dist/tui/launch-settings.d.ts +2 -0
  189. package/dist/tui/launch-settings.d.ts.map +1 -1
  190. package/dist/tui/model-refusal.d.ts +3 -1
  191. package/dist/tui/model-refusal.d.ts.map +1 -1
  192. package/dist/tui/slashCommands.d.ts +9 -0
  193. package/dist/tui/slashCommands.d.ts.map +1 -1
  194. package/package.json +7 -7
  195. package/dist/chunks/agent-session-FZI6GVBH.js +0 -69
  196. package/dist/chunks/chunk-5EIUKBFJ.js.map +0 -6
  197. package/dist/chunks/chunk-JHGICKYH.js.map +0 -6
  198. package/dist/chunks/chunk-RXUDOOPL.js.map +0 -6
  199. package/dist/chunks/chunk-T5MEHPLZ.js.map +0 -6
  200. package/dist/chunks/cli-runtime-YLIWHNME.js.map +0 -6
  201. package/dist/chunks/dist-2NYSROLX.js.map +0 -6
  202. package/dist/chunks/list-HNSWMLVN.js.map +0 -6
  203. package/dist/chunks/resume-WN2TIOQK.js +0 -23
  204. package/dist/chunks/tui-TM5QW6KY.js.map +0 -6
  205. /package/dist/chunks/{acp-QUCU36XL.js.map → acp-2INAZYZT.js.map} +0 -0
  206. /package/dist/chunks/{activity-command-W6575T4W.js.map → activity-command-J676MIML.js.map} +0 -0
  207. /package/dist/chunks/{add-GLFGOQVN.js.map → add-LI4SX4YZ.js.map} +0 -0
  208. /package/dist/chunks/{agent-VBCJRRQU.js.map → agent-LUK4L4AW.js.map} +0 -0
  209. /package/dist/chunks/{agent-session-FZI6GVBH.js.map → agent-session-5ZG6WNTC.js.map} +0 -0
  210. /package/dist/chunks/{archive-QEPJAF7T.js.map → archive-IZRS7P6C.js.map} +0 -0
  211. /package/dist/chunks/{bin-main-D4Q3AFND.js.map → bin-main-XNB6LHOP.js.map} +0 -0
  212. /package/dist/chunks/{binding-CEZSAC3K.js.map → binding-3EE2IYAM.js.map} +0 -0
  213. /package/dist/chunks/{browser-XZZSBZG7.js.map → browser-NI2ZPG4N.js.map} +0 -0
  214. /package/dist/chunks/{chat-ESJVUJKJ.js.map → chat-5OEOFTSO.js.map} +0 -0
  215. /package/dist/chunks/{chunk-BYQSDH2F.js.map → chunk-2FMMT4JD.js.map} +0 -0
  216. /package/dist/chunks/{chunk-2EPEWMI7.js.map → chunk-2GBI7JYG.js.map} +0 -0
  217. /package/dist/chunks/{chunk-JWMBGGFY.js.map → chunk-43Q3E36I.js.map} +0 -0
  218. /package/dist/chunks/{chunk-JIUBDOX4.js.map → chunk-4ET34X7Z.js.map} +0 -0
  219. /package/dist/chunks/{chunk-6E63NHFK.js.map → chunk-4GFWZYTR.js.map} +0 -0
  220. /package/dist/chunks/{chunk-6YIA342V.js.map → chunk-4IYPPPIR.js.map} +0 -0
  221. /package/dist/chunks/{chunk-K5IWQLOE.js.map → chunk-4UXO3V22.js.map} +0 -0
  222. /package/dist/chunks/{chunk-UXYOP32R.js.map → chunk-564OI5HN.js.map} +0 -0
  223. /package/dist/chunks/{chunk-HAYKZJ4W.js.map → chunk-56IRGZRX.js.map} +0 -0
  224. /package/dist/chunks/{chunk-YJV5ARUB.js.map → chunk-5AQVWTHV.js.map} +0 -0
  225. /package/dist/chunks/{chunk-E7STKX6D.js.map → chunk-6TUISLKZ.js.map} +0 -0
  226. /package/dist/chunks/{chunk-U6LKWLSO.js.map → chunk-7DSJTL5S.js.map} +0 -0
  227. /package/dist/chunks/{chunk-7R42TMRR.js.map → chunk-AOKRFS3Z.js.map} +0 -0
  228. /package/dist/chunks/{chunk-QKE5HLHV.js.map → chunk-BCFC5GGU.js.map} +0 -0
  229. /package/dist/chunks/{chunk-26JTVEWV.js.map → chunk-BPW5AT4B.js.map} +0 -0
  230. /package/dist/chunks/{chunk-ZEHU7KPN.js.map → chunk-CDOLJHIB.js.map} +0 -0
  231. /package/dist/chunks/{chunk-C3F76W74.js.map → chunk-CDT745GI.js.map} +0 -0
  232. /package/dist/chunks/{chunk-N47CNO6M.js.map → chunk-DKJHMWCA.js.map} +0 -0
  233. /package/dist/chunks/{chunk-ZKBZZ4SV.js.map → chunk-E6XGUJ2I.js.map} +0 -0
  234. /package/dist/chunks/{chunk-ESXU3WTP.js.map → chunk-EISC5X74.js.map} +0 -0
  235. /package/dist/chunks/{chunk-ZSJUNNOB.js.map → chunk-EPS5ROMN.js.map} +0 -0
  236. /package/dist/chunks/{chunk-MGLG65W5.js.map → chunk-G4SE3TXK.js.map} +0 -0
  237. /package/dist/chunks/{chunk-WYT7R7OV.js.map → chunk-GBRTN4AK.js.map} +0 -0
  238. /package/dist/chunks/{chunk-QQM7JSEY.js.map → chunk-GCIBSVYX.js.map} +0 -0
  239. /package/dist/chunks/{chunk-X4XZVFAV.js.map → chunk-GEX2EXU3.js.map} +0 -0
  240. /package/dist/chunks/{chunk-HLJHOUY5.js.map → chunk-GXSMCKZJ.js.map} +0 -0
  241. /package/dist/chunks/{chunk-MHF4AD7R.js.map → chunk-HNBF54TV.js.map} +0 -0
  242. /package/dist/chunks/{chunk-BFBE2M7Q.js.map → chunk-HUUVQBZR.js.map} +0 -0
  243. /package/dist/chunks/{chunk-6DTG2DJM.js.map → chunk-HXV7TDNY.js.map} +0 -0
  244. /package/dist/chunks/{chunk-YBRLTSWM.js.map → chunk-KZNMCCYK.js.map} +0 -0
  245. /package/dist/chunks/{chunk-HF22LWEO.js.map → chunk-L3VAFXRU.js.map} +0 -0
  246. /package/dist/chunks/{chunk-KCVKLMKN.js.map → chunk-LJHHAKBL.js.map} +0 -0
  247. /package/dist/chunks/{chunk-5BA47MKJ.js.map → chunk-LNDECWNR.js.map} +0 -0
  248. /package/dist/chunks/{chunk-UYP5QIPH.js.map → chunk-LYSN3FIQ.js.map} +0 -0
  249. /package/dist/chunks/{chunk-HMAF5UAO.js.map → chunk-MCTUVMMB.js.map} +0 -0
  250. /package/dist/chunks/{chunk-QSIMY7WM.js.map → chunk-NJWCOR7Z.js.map} +0 -0
  251. /package/dist/chunks/{chunk-WUSDW5Z5.js.map → chunk-OOWGXPY2.js.map} +0 -0
  252. /package/dist/chunks/{chunk-2FHIHK3T.js.map → chunk-P2CHZ6FL.js.map} +0 -0
  253. /package/dist/chunks/{chunk-V3MC2IFR.js.map → chunk-P3KXW262.js.map} +0 -0
  254. /package/dist/chunks/{chunk-XRNUFV7Q.js.map → chunk-P7YVC6KA.js.map} +0 -0
  255. /package/dist/chunks/{chunk-F3ZHJSWR.js.map → chunk-PVCJHQP5.js.map} +0 -0
  256. /package/dist/chunks/{chunk-5NOMF3HN.js.map → chunk-QUKAQLNS.js.map} +0 -0
  257. /package/dist/chunks/{chunk-XX6ZE5ZO.js.map → chunk-R2KYP3AT.js.map} +0 -0
  258. /package/dist/chunks/{chunk-YVV5ZHID.js.map → chunk-R7TYDKKC.js.map} +0 -0
  259. /package/dist/chunks/{chunk-A3H6DYWZ.js.map → chunk-RR3ASZMK.js.map} +0 -0
  260. /package/dist/chunks/{chunk-7M3ACGKA.js.map → chunk-SLRBCV4D.js.map} +0 -0
  261. /package/dist/chunks/{chunk-66YF5N2J.js.map → chunk-SMJQ7LVL.js.map} +0 -0
  262. /package/dist/chunks/{chunk-DDXZZ7TR.js.map → chunk-SR32C4A7.js.map} +0 -0
  263. /package/dist/chunks/{chunk-VRO3BSVC.js.map → chunk-TP62BP32.js.map} +0 -0
  264. /package/dist/chunks/{chunk-X3YRAYJU.js.map → chunk-USIRIOSH.js.map} +0 -0
  265. /package/dist/chunks/{chunk-CKAVXPSD.js.map → chunk-UZX4K743.js.map} +0 -0
  266. /package/dist/chunks/{chunk-AHSWXUMT.js.map → chunk-VJAVIDVB.js.map} +0 -0
  267. /package/dist/chunks/{chunk-A7RJ323Z.js.map → chunk-W3M3UGWQ.js.map} +0 -0
  268. /package/dist/chunks/{chunk-ONLVC5X5.js.map → chunk-WI5ADHTS.js.map} +0 -0
  269. /package/dist/chunks/{chunk-GYIRPQFB.js.map → chunk-WX6B7RLT.js.map} +0 -0
  270. /package/dist/chunks/{chunk-LHCRLCMO.js.map → chunk-XK4ANTIO.js.map} +0 -0
  271. /package/dist/chunks/{chunk-XD26GMKP.js.map → chunk-XKRU6FOU.js.map} +0 -0
  272. /package/dist/chunks/{chunk-RBH5ZABR.js.map → chunk-Y34RP2OI.js.map} +0 -0
  273. /package/dist/chunks/{chunk-NLVUDQEQ.js.map → chunk-YFKC2GZP.js.map} +0 -0
  274. /package/dist/chunks/{chunk-UVR7C4T5.js.map → chunk-YJPHE4O3.js.map} +0 -0
  275. /package/dist/chunks/{chunk-LE4QZ6HS.js.map → chunk-YJYFQW2F.js.map} +0 -0
  276. /package/dist/chunks/{chunk-YRBLDFMI.js.map → chunk-YNJ3SWIL.js.map} +0 -0
  277. /package/dist/chunks/{chunk-6EP5UWMA.js.map → chunk-YPKTYCDZ.js.map} +0 -0
  278. /package/dist/chunks/{chunk-UT5XJ2JQ.js.map → chunk-YW3GNCCK.js.map} +0 -0
  279. /package/dist/chunks/{chunk-IQCUP4GF.js.map → chunk-YYLILI2G.js.map} +0 -0
  280. /package/dist/chunks/{chunk-HZU57YBL.js.map → chunk-ZBLTMOOD.js.map} +0 -0
  281. /package/dist/chunks/{chunk-QROBMHWX.js.map → chunk-ZFBUNTJO.js.map} +0 -0
  282. /package/dist/chunks/{chunk-FXPGZQWX.js.map → chunk-ZLQ5BZ4X.js.map} +0 -0
  283. /package/dist/chunks/{chunk-AWRDGYDV.js.map → chunk-ZP4KWNIL.js.map} +0 -0
  284. /package/dist/chunks/{commands-WT4OLTGL.js.map → commands-KESYD3SM.js.map} +0 -0
  285. /package/dist/chunks/{crash-report-BTL3U5HH.js.map → crash-report-JRRCPLE7.js.map} +0 -0
  286. /package/dist/chunks/{dist-OHQWXZ7N.js.map → dist-DLVIWPSW.js.map} +0 -0
  287. /package/dist/chunks/{dist-LRK6JYLM.js.map → dist-EGALCLMC.js.map} +0 -0
  288. /package/dist/chunks/{dist-3PNUHQCO.js.map → dist-F3BMUZ3P.js.map} +0 -0
  289. /package/dist/chunks/{dist-N4TBL3SN.js.map → dist-GZSRTUES.js.map} +0 -0
  290. /package/dist/chunks/{dist-3R6SQ3VB.js.map → dist-IEWJJJHL.js.map} +0 -0
  291. /package/dist/chunks/{dist-4TCR3HDF.js.map → dist-ML6MP7J3.js.map} +0 -0
  292. /package/dist/chunks/{dist-X7K5G5NH.js.map → dist-XUIAXPXU.js.map} +0 -0
  293. /package/dist/chunks/{doctor-5JQK6UNK.js.map → doctor-URLWCDCG.js.map} +0 -0
  294. /package/dist/chunks/{drain-EHO3BUHW.js.map → drain-XYBMXTKG.js.map} +0 -0
  295. /package/dist/chunks/{entry-F2EIOWAT.js.map → entry-BTK3MMFH.js.map} +0 -0
  296. /package/dist/chunks/{eval-7YEMHHIB.js.map → eval-SS6TIGOD.js.map} +0 -0
  297. /package/dist/chunks/{exec-WV7BS5UD.js.map → exec-MGDFWPM2.js.map} +0 -0
  298. /package/dist/chunks/{home-GOMDEEXP.js.map → home-PPWVKIU6.js.map} +0 -0
  299. /package/dist/chunks/{host-MNPHBQWG.js.map → host-RHMJMJAH.js.map} +0 -0
  300. /package/dist/chunks/{host-queries-SKWE7PF5.js.map → host-queries-DUR62LWA.js.map} +0 -0
  301. /package/dist/chunks/{learn-BUEAUHTD.js.map → learn-AF7N7BLO.js.map} +0 -0
  302. /package/dist/chunks/{learn-builtin-XZFBPA3W.js.map → learn-builtin-J7GKFBXU.js.map} +0 -0
  303. /package/dist/chunks/{lifecycle-HMSOBI6F.js.map → lifecycle-RGXBSC3L.js.map} +0 -0
  304. /package/dist/chunks/{live-ER3OZKC6.js.map → live-RVNUQYAY.js.map} +0 -0
  305. /package/dist/chunks/{login-EBEFMEA2.js.map → login-RFNV3I7R.js.map} +0 -0
  306. /package/dist/chunks/{logs-5UJZYNN2.js.map → logs-RTREGKV5.js.map} +0 -0
  307. /package/dist/chunks/{mcp-BLERKK2H.js.map → mcp-SPQQPLJE.js.map} +0 -0
  308. /package/dist/chunks/{message-command-XH2M4BTB.js.map → message-command-E7V5KLFO.js.map} +0 -0
  309. /package/dist/chunks/{open-ZYWPDOR6.js.map → open-P43XO4HN.js.map} +0 -0
  310. /package/dist/chunks/{operator-tools-CZ2SXR3G.js.map → operator-tools-O43OOXJJ.js.map} +0 -0
  311. /package/dist/chunks/{output-schema-MFZZP7GF.js.map → output-schema-HQ37VOZT.js.map} +0 -0
  312. /package/dist/chunks/{pal-7OYQHUKF.js.map → pal-24C6YOEW.js.map} +0 -0
  313. /package/dist/chunks/{peers-FCVTBNI5.js.map → peers-722AUQGX.js.map} +0 -0
  314. /package/dist/chunks/{peers-V3Z3ZQSN.js.map → peers-IPO7XN5V.js.map} +0 -0
  315. /package/dist/chunks/{providers-43RE2SWA.js.map → providers-5OKXU3AF.js.map} +0 -0
  316. /package/dist/chunks/{pty-QSS3UQ7C.js.map → pty-2YQ4ASHS.js.map} +0 -0
  317. /package/dist/chunks/{resume-WN2TIOQK.js.map → resume-IP4SVMRZ.js.map} +0 -0
  318. /package/dist/chunks/{resume-command-WZY42BAB.js.map → resume-command-SGKIUUR7.js.map} +0 -0
  319. /package/dist/chunks/{schedule-LHXNUQHJ.js.map → schedule-6JFYGG2R.js.map} +0 -0
  320. /package/dist/chunks/{service-ZU5YIBW4.js.map → service-WJ5VNXQ5.js.map} +0 -0
  321. /package/dist/chunks/{skills-K2MFIY4H.js.map → skills-PCETONZ5.js.map} +0 -0
  322. /package/dist/chunks/{start-check-AODGFYJD.js.map → start-check-UJOG3VAS.js.map} +0 -0
  323. /package/dist/chunks/{startup-failure-B6ESBTLZ.js.map → startup-failure-Q5I6S7KQ.js.map} +0 -0
  324. /package/dist/chunks/{state-ZWXVSLS2.js.map → state-NUXXHBA5.js.map} +0 -0
  325. /package/dist/chunks/{store-JAI2RWQT.js.map → store-3R5KTEP5.js.map} +0 -0
  326. /package/dist/chunks/{store-MNI5IJHC.js.map → store-A2RYRTI6.js.map} +0 -0
  327. /package/dist/chunks/{store-NKISDMPC.js.map → store-KO52OXSR.js.map} +0 -0
  328. /package/dist/chunks/{store-U6SG2CON.js.map → store-XO6CFKZI.js.map} +0 -0
  329. /package/dist/chunks/{upgrade-27ZDBTX7.js.map → upgrade-NPINYN5F.js.map} +0 -0
  330. /package/dist/chunks/{workspaces-X7W7ZQU3.js.map → workspaces-BGRV6TQ6.js.map} +0 -0
  331. /package/dist/chunks/{worktree-SIA6C5NS.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-QQM7JSEY.js";
5
+ } from "./chunk-GCIBSVYX.js";
6
6
  import {
7
7
  createSessionSkillCatalog
8
- } from "./chunk-CKAVXPSD.js";
8
+ } from "./chunk-UZX4K743.js";
9
9
  import {
10
10
  KEY_MISMATCH_MESSAGE,
11
11
  MAX_SCRIPT_BYTES,
@@ -36,32 +36,32 @@ import {
36
36
  workflowJournalKey,
37
37
  workingDirectoryProblem,
38
38
  writeEditableCopy
39
- } from "./chunk-UT5XJ2JQ.js";
39
+ } from "./chunk-YW3GNCCK.js";
40
40
  import {
41
41
  runGeneratorCycle
42
- } from "./chunk-ZKBZZ4SV.js";
42
+ } from "./chunk-E6XGUJ2I.js";
43
43
  import {
44
44
  createSessionLearningFeed,
45
45
  openLearningTarget,
46
46
  readProjectGuidance,
47
47
  withSessionLearningFeed
48
- } from "./chunk-YVV5ZHID.js";
48
+ } from "./chunk-R7TYDKKC.js";
49
49
  import {
50
50
  connectMcpServers,
51
51
  startMcpServers
52
- } from "./chunk-YRBLDFMI.js";
52
+ } from "./chunk-YNJ3SWIL.js";
53
53
  import {
54
54
  openInBrowser
55
- } from "./chunk-ESXU3WTP.js";
55
+ } from "./chunk-EISC5X74.js";
56
56
  import {
57
57
  conversationInUseSentence,
58
58
  minutesUntilFree
59
- } from "./chunk-LE4QZ6HS.js";
59
+ } from "./chunk-YJYFQW2F.js";
60
60
  import {
61
61
  ensureLocalConfigIgnored,
62
62
  logIgnoreOutcome,
63
63
  writeLocalAllows
64
- } from "./chunk-HMAF5UAO.js";
64
+ } from "./chunk-MCTUVMMB.js";
65
65
  import {
66
66
  createBrowserControl
67
67
  } from "./chunk-WHODOMXA.js";
@@ -75,17 +75,17 @@ import {
75
75
  import {
76
76
  isPermissionMode,
77
77
  permissionModeLabel
78
- } from "./chunk-U6LKWLSO.js";
78
+ } from "./chunk-7DSJTL5S.js";
79
79
  import {
80
80
  discoverSkills,
81
81
  loadSkillBody
82
- } from "./chunk-2FHIHK3T.js";
82
+ } from "./chunk-P2CHZ6FL.js";
83
83
  import {
84
84
  migrateAccountKeys
85
- } from "./chunk-UVR7C4T5.js";
85
+ } from "./chunk-YJPHE4O3.js";
86
86
  import {
87
87
  openCliAccounts
88
- } from "./chunk-MHF4AD7R.js";
88
+ } from "./chunk-HNBF54TV.js";
89
89
  import {
90
90
  CredentialRefreshRejectedError,
91
91
  CredentialWithdrawnError as CredentialWithdrawnError2,
@@ -93,16 +93,16 @@ import {
93
93
  ensureFreshStoredCodexCredential,
94
94
  readSubscriptionCredential,
95
95
  sameOAuthCredential
96
- } from "./chunk-6YIA342V.js";
96
+ } from "./chunk-4IYPPPIR.js";
97
97
  import {
98
98
  conversationLogPath,
99
99
  ensureSessionStarted,
100
100
  openConversationLog,
101
101
  recordAccountBound
102
- } from "./chunk-RBH5ZABR.js";
102
+ } from "./chunk-Y34RP2OI.js";
103
103
  import {
104
104
  readIdentity
105
- } from "./chunk-HLJHOUY5.js";
105
+ } from "./chunk-GXSMCKZJ.js";
106
106
  import {
107
107
  INSTRUCTIONS_FILENAME,
108
108
  MAX_CHARS_PER_FILE,
@@ -113,7 +113,7 @@ import {
113
113
  } from "./chunk-JQIBPPOL.js";
114
114
  import {
115
115
  isDefaultAccountId
116
- } from "./chunk-JIUBDOX4.js";
116
+ } from "./chunk-4ET34X7Z.js";
117
117
  import {
118
118
  debugRequested
119
119
  } from "./chunk-GNBMKISG.js";
@@ -121,7 +121,7 @@ import {
121
121
  createLazyCodeAnalysis,
122
122
  promptCacheTtl,
123
123
  setPromptCacheTtl
124
- } from "./chunk-QROBMHWX.js";
124
+ } from "./chunk-ZFBUNTJO.js";
125
125
  import {
126
126
  probeCapabilities
127
127
  } from "./chunk-OH6TB27S.js";
@@ -129,12 +129,13 @@ import {
129
129
  LOCAL_CONFIG_FILE,
130
130
  configuredPassthroughTools,
131
131
  parseTokenTarget,
132
+ readBoundDecisionKey,
132
133
  resolveToolResultScreens,
133
134
  sessionWorkflowSizeAdvice,
134
135
  takeConfigWarnings,
135
136
  unmatchedPassthroughTools,
136
137
  workflowTokenCeiling
137
- } from "./chunk-JHGICKYH.js";
138
+ } from "./chunk-6CZOIEKE.js";
138
139
  import {
139
140
  require_dist
140
141
  } from "./chunk-KONYGNG6.js";
@@ -143,10 +144,10 @@ import {
143
144
  } from "./chunk-LCGXWCVU.js";
144
145
  import {
145
146
  compilePermissions
146
- } from "./chunk-YBRLTSWM.js";
147
+ } from "./chunk-KZNMCCYK.js";
147
148
  import {
148
149
  cliLogger
149
- } from "./chunk-V3MC2IFR.js";
150
+ } from "./chunk-P3KXW262.js";
150
151
  import {
151
152
  readModelLaunchEnvironment
152
153
  } from "./chunk-LVVD32KJ.js";
@@ -173,7 +174,7 @@ import {
173
174
  readPreferences,
174
175
  resolveChainCapabilities,
175
176
  unresolvedMembers
176
- } from "./chunk-QKE5HLHV.js";
177
+ } from "./chunk-BCFC5GGU.js";
177
178
  import {
178
179
  canSelectModel,
179
180
  createGeminiAccessTokenResolver,
@@ -181,7 +182,7 @@ import {
181
182
  findDetected,
182
183
  hasApiCredential,
183
184
  requiresCredentialForModel
184
- } from "./chunk-X3YRAYJU.js";
185
+ } from "./chunk-USIRIOSH.js";
185
186
  import {
186
187
  activeZenCatalogue,
187
188
  isOfferableModel
@@ -194,23 +195,23 @@ import {
194
195
  import {
195
196
  isAnthropicOAuthToken,
196
197
  readCodexCredentialFile
197
- } from "./chunk-BYQSDH2F.js";
198
+ } from "./chunk-2FMMT4JD.js";
198
199
  import {
199
200
  composeEnvironmentPrompt,
200
201
  detectWsl,
201
202
  environmentFactLines,
202
203
  permissionSentence,
203
204
  readEnvironmentFacts
204
- } from "./chunk-IQCUP4GF.js";
205
+ } from "./chunk-YYLILI2G.js";
205
206
  import {
206
207
  ensurePrivateStateDirectory
207
- } from "./chunk-6DTG2DJM.js";
208
+ } from "./chunk-HXV7TDNY.js";
208
209
  import {
209
210
  restrictToOwner
210
- } from "./chunk-FXPGZQWX.js";
211
+ } from "./chunk-ZLQ5BZ4X.js";
211
212
  import {
212
213
  namzuHomePath
213
- } from "./chunk-YJV5ARUB.js";
214
+ } from "./chunk-5AQVWTHV.js";
214
215
  import {
215
216
  AgentManager,
216
217
  AgentRegistry,
@@ -396,7 +397,7 @@ import {
396
397
  withModelWindowSuffixStripped,
397
398
  withProviderFallback,
398
399
  wrapUntrusted
399
- } from "./chunk-SJTDYH2Q.js";
400
+ } from "./chunk-4WFAYG6V.js";
400
401
  import {
401
402
  __name,
402
403
  __toESM
@@ -903,8 +904,8 @@ function describeCapabilityNotice(input) {
903
904
  __name(describeCapabilityNotice, "describeCapabilityNotice");
904
905
  function describeHistoryRepairNotice(input) {
905
906
  if (input.source === "provider-rejected-image") {
906
- const count = input.rejectedImages ?? 0;
907
- 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";
908
909
  const name = productName(input.providerId);
909
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.`;
910
911
  }
@@ -1372,7 +1373,7 @@ function diffViewBody(info, options) {
1372
1373
  const limit = options.expanded || info.preview === void 0 ? all.length : info.preview;
1373
1374
  const shown = all.slice(0, limit);
1374
1375
  const carried = info.hunks.reduce(
1375
- (count, hunk) => count + hunk.lines.filter((line) => line.startsWith("+")).length,
1376
+ (count2, hunk) => count2 + hunk.lines.filter((line) => line.startsWith("+")).length,
1376
1377
  0
1377
1378
  );
1378
1379
  const missing2 = info.mode === "file" && info.truncated && info.added !== void 0 ? Math.max(0, info.added - carried) : 0;
@@ -1422,12 +1423,12 @@ function plainDiffRows(info) {
1422
1423
  return rows;
1423
1424
  }
1424
1425
  __name(plainDiffRows, "plainDiffRows");
1425
- function plural2(count, one, many) {
1426
- return count === 1 ? one : many;
1426
+ function plural2(count2, one, many) {
1427
+ return count2 === 1 ? one : many;
1427
1428
  }
1428
1429
  __name(plural2, "plural");
1429
- function bold(count) {
1430
- return { text: count.toLocaleString("en-US"), bold: true };
1430
+ function bold(count2) {
1431
+ return { text: count2.toLocaleString("en-US"), bold: true };
1431
1432
  }
1432
1433
  __name(bold, "bold");
1433
1434
  function editSummary(added, removed) {
@@ -1912,8 +1913,8 @@ function countListedResults(output) {
1912
1913
  const lines = output.split("\n");
1913
1914
  const numbered = lines.filter((line) => /^\s{0,3}\d+\.\s+\S/.test(line)).length;
1914
1915
  const addressed = lines.filter((line) => /^\s*URL:\s*\S/.test(line)).length;
1915
- const count = Math.max(numbered, addressed);
1916
- return count > 0 ? count : void 0;
1916
+ const count2 = Math.max(numbered, addressed);
1917
+ return count2 > 0 ? count2 : void 0;
1917
1918
  }
1918
1919
  __name(countListedResults, "countListedResults");
1919
1920
  var formatBytes = formatSize;
@@ -1966,7 +1967,7 @@ __name(screenApprover, "screenApprover");
1966
1967
 
1967
1968
  // src/tui/agent.ts
1968
1969
  import { realpath as realpath4, stat as stat6 } from "node:fs/promises";
1969
- 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";
1970
1971
 
1971
1972
  // src/checkpoints/store.ts
1972
1973
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -5687,22 +5688,151 @@ function createDecisionTool(model, options = {}) {
5687
5688
  }
5688
5689
  __name(createDecisionTool, "createDecisionTool");
5689
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
+
5690
5778
  // src/integrations/decision/model.ts
5691
- 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 } : {};
5692
5795
  if (cfg.provider === "azure") {
5796
+ const named2 = cfg.apiKeyEnv;
5797
+ const keyed = named2 !== void 0 || cfg.tokenEnv === void 0 && storedKey() !== null;
5693
5798
  return {
5694
5799
  provider: "azure",
5695
5800
  endpoint: cfg.endpoint,
5696
5801
  deployment: cfg.deployment,
5802
+ ...fetchPart,
5697
5803
  // A key, read at each call, or a bearer token; never both (the loader refuses a config naming both).
5698
- ...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]
5699
5822
  };
5700
5823
  }
5824
+ const baseFetch = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
5701
5825
  return {
5702
5826
  provider: "http",
5703
5827
  url: cfg.url,
5704
5828
  ...cfg.model !== void 0 ? { model: cfg.model } : {},
5705
- ...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")
5706
5836
  };
5707
5837
  }
5708
5838
  __name(buildDecisionProviderConfig, "buildDecisionProviderConfig");
@@ -5711,14 +5841,14 @@ function decisionSwitchedOff(env) {
5711
5841
  return env[DECISION_KILL_SWITCH] === "1";
5712
5842
  }
5713
5843
  __name(decisionSwitchedOff, "decisionSwitchedOff");
5714
- function maybeCreateDecisionTool(cfg, env) {
5844
+ function maybeCreateDecisionTool(cfg, env, deps = {}) {
5715
5845
  if (!cfg || decisionSwitchedOff(env)) return void 0;
5716
- return createDecisionTool(createDecisionModel(buildDecisionProviderConfig(cfg, env)));
5846
+ return createDecisionTool(createDecisionModel(buildDecisionProviderConfig(cfg, env, deps)));
5717
5847
  }
5718
5848
  __name(maybeCreateDecisionTool, "maybeCreateDecisionTool");
5719
- function maybeCreateDecisionModel(cfg, env) {
5849
+ function maybeCreateDecisionModel(cfg, env, deps = {}) {
5720
5850
  if (!cfg || decisionSwitchedOff(env)) return void 0;
5721
- return createDecisionModel(buildDecisionProviderConfig(cfg, env));
5851
+ return createDecisionModel(buildDecisionProviderConfig(cfg, env, deps));
5722
5852
  }
5723
5853
  __name(maybeCreateDecisionModel, "maybeCreateDecisionModel");
5724
5854
 
@@ -6989,7 +7119,7 @@ __name(readWorkStatus, "readWorkStatus");
6989
7119
 
6990
7120
  // src/integrations/plugins/files.ts
6991
7121
  import { readdirSync as readdirSync2, realpathSync as realpathSync3 } from "node:fs";
6992
- 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";
6993
7123
 
6994
7124
  // src/integrations/plugins/settings.ts
6995
7125
  import { createHash as createHash3, randomUUID as randomUUID4 } from "node:crypto";
@@ -7005,12 +7135,12 @@ import {
7005
7135
  unlinkSync,
7006
7136
  writeFileSync
7007
7137
  } from "node:fs";
7008
- import { join as join6 } from "node:path";
7138
+ import { join as join7 } from "node:path";
7009
7139
  var MAX_RECORD_BYTES = 64 * 1024;
7010
7140
  var PluginSettingsStore = class {
7011
7141
  constructor(home) {
7012
7142
  this.home = home;
7013
- this.directory = join6(home, "plugin-settings");
7143
+ this.directory = join7(home, "plugin-settings");
7014
7144
  }
7015
7145
  home;
7016
7146
  static {
@@ -7019,7 +7149,7 @@ var PluginSettingsStore = class {
7019
7149
  directory;
7020
7150
  path(plugin) {
7021
7151
  const key = createHash3("sha256").update(JSON.stringify([plugin.rootDir, plugin.name])).digest("hex");
7022
- return join6(this.directory, `${key}.json`);
7152
+ return join7(this.directory, `${key}.json`);
7023
7153
  }
7024
7154
  read(plugin) {
7025
7155
  const path = this.path(plugin);
@@ -7101,7 +7231,7 @@ function resolvePluginFileDirs(plugin, rootDir, declared) {
7101
7231
  const problems = [];
7102
7232
  for (const rel of declared ?? []) {
7103
7233
  try {
7104
- const real = realpathSync3(join7(rootDir, rel));
7234
+ const real = realpathSync3(join8(rootDir, rel));
7105
7235
  const within2 = relative6(realpathSync3(rootDir), real);
7106
7236
  if (within2 === ".." || within2.startsWith(`..${sep4}`) || isAbsolute6(within2)) {
7107
7237
  problems.push(
@@ -7993,13 +8123,13 @@ __name(createSideModel, "createSideModel");
7993
8123
  var CLI_CHECKPOINT_RETENTION = 10;
7994
8124
 
7995
8125
  // src/integrations/subagents/definitions.ts
7996
- import { join as join8 } from "node:path";
8126
+ import { join as join9 } from "node:path";
7997
8127
  function userAgentsDir(home) {
7998
- return join8(namzuHomePath(home), "agents");
8128
+ return join9(namzuHomePath(home), "agents");
7999
8129
  }
8000
8130
  __name(userAgentsDir, "userAgentsDir");
8001
8131
  function projectAgentsDir(cwd) {
8002
- return join8(cwd, ".namzu", "agents");
8132
+ return join9(cwd, ".namzu", "agents");
8003
8133
  }
8004
8134
  __name(projectAgentsDir, "projectAgentsDir");
8005
8135
  var AGENT_FILE_PERMISSION_MODES = /* @__PURE__ */ new Set([
@@ -8098,7 +8228,7 @@ __name(prepareDelegatedEffort, "prepareDelegatedEffort");
8098
8228
 
8099
8229
  // src/integrations/subagents/operator-journal.ts
8100
8230
  import { appendFile, open as open2 } from "node:fs/promises";
8101
- import { join as join9 } from "node:path";
8231
+ import { join as join10 } from "node:path";
8102
8232
  var MAX_READ_BYTES = 256 * 1024;
8103
8233
  var MAX_CONTEXT_CHARACTERS = 32e3;
8104
8234
  function formatChildOperatorAdmission(input) {
@@ -8108,7 +8238,7 @@ function formatChildOperatorAdmission(input) {
8108
8238
  }
8109
8239
  __name(formatChildOperatorAdmission, "formatChildOperatorAdmission");
8110
8240
  async function readChildOperatorNotices(paths, sessionId) {
8111
- const path = join9(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
8241
+ const path = join10(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl");
8112
8242
  let file;
8113
8243
  try {
8114
8244
  file = await open2(path, "r");
@@ -8179,7 +8309,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
8179
8309
  })
8180
8310
  ).join("\n");
8181
8311
  await appendFile(
8182
- join9(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8312
+ join10(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8183
8313
  `${lines}
8184
8314
  `,
8185
8315
  { mode: 384 }
@@ -8188,7 +8318,7 @@ async function acknowledgeChildOperatorNotices(paths, sessionId, notices) {
8188
8318
  __name(acknowledgeChildOperatorNotices, "acknowledgeChildOperatorNotices");
8189
8319
  async function recordChildOperatorReport(paths, sessionId, notice2) {
8190
8320
  await appendFile(
8191
- join9(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8321
+ join10(paths.sessionDir({ sessionId }), "child-operator-messages.jsonl"),
8192
8322
  `${JSON.stringify({ ...notice2, status: "child-report", source: "host", at: (/* @__PURE__ */ new Date()).toISOString() })}
8193
8323
  `,
8194
8324
  { mode: 384 }
@@ -9213,9 +9343,9 @@ __name(errorMessage2, "errorMessage");
9213
9343
 
9214
9344
  // src/integrations/subagents/runtime.ts
9215
9345
  import { randomUUID as randomUUID5 } from "node:crypto";
9216
- import { existsSync } from "node:fs";
9346
+ import { existsSync as existsSync2 } from "node:fs";
9217
9347
  import { appendFile as appendFile2, mkdir as mkdir4 } from "node:fs/promises";
9218
- import { join as join13 } from "node:path";
9348
+ import { join as join14 } from "node:path";
9219
9349
 
9220
9350
  // src/integrations/subagents/fork.ts
9221
9351
  var FORK_SUBAGENT = "fork";
@@ -9329,7 +9459,7 @@ __name(describeQuietTask, "describeQuietTask");
9329
9459
  // src/memory/typed.ts
9330
9460
  import { createHash as createHash4 } from "node:crypto";
9331
9461
  import { access, readFile as readFile3, rename as rename3, writeFile as writeFile2 } from "node:fs/promises";
9332
- import { join as join12 } from "node:path";
9462
+ import { join as join13 } from "node:path";
9333
9463
 
9334
9464
  // src/memory/io.ts
9335
9465
  import {
@@ -9343,7 +9473,7 @@ import {
9343
9473
  realpathSync as realpathSync4,
9344
9474
  writeSync
9345
9475
  } from "node:fs";
9346
- 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";
9347
9477
  var MEMORY_FILE_MAX_BYTES = 1024 * 1024;
9348
9478
  function missing(error) {
9349
9479
  return error.code === "ENOENT";
@@ -9376,7 +9506,7 @@ function resolveMemoryPath(location, createParents = false) {
9376
9506
  for (let i = 0; i < parts.length; i += 1) {
9377
9507
  const part = parts[i];
9378
9508
  if (part === void 0) throw new Error("Memory path has an invalid segment.");
9379
- candidate = join10(candidate, part);
9509
+ candidate = join11(candidate, part);
9380
9510
  const leaf = i === parts.length - 1;
9381
9511
  let stat7;
9382
9512
  try {
@@ -9417,12 +9547,12 @@ function readBounded(fd) {
9417
9547
  let total = 0;
9418
9548
  while (total <= MEMORY_FILE_MAX_BYTES) {
9419
9549
  const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, MEMORY_FILE_MAX_BYTES + 1 - total));
9420
- const count = readSync2(fd, chunk, 0, chunk.length, total);
9421
- if (count === 0) break;
9422
- total += count;
9550
+ const count2 = readSync2(fd, chunk, 0, chunk.length, total);
9551
+ if (count2 === 0) break;
9552
+ total += count2;
9423
9553
  if (total > MEMORY_FILE_MAX_BYTES)
9424
9554
  throw new Error(`Memory exceeds the ${MEMORY_FILE_MAX_BYTES}-byte file limit.`);
9425
- chunks.push(chunk.subarray(0, count));
9555
+ chunks.push(chunk.subarray(0, count2));
9426
9556
  }
9427
9557
  let text2;
9428
9558
  try {
@@ -9501,18 +9631,18 @@ __name(appendMemoryFile, "appendMemoryFile");
9501
9631
 
9502
9632
  // src/memory/store.ts
9503
9633
  import { realpathSync as realpathSync5 } from "node:fs";
9504
- import { join as join11, resolve as resolve9 } from "node:path";
9634
+ import { join as join12, resolve as resolve9 } from "node:path";
9505
9635
  var MEMORY_SECTION_MAX_CHARS = 8e3;
9506
9636
  function memoryDir(home) {
9507
9637
  return namzuHomePath(home);
9508
9638
  }
9509
9639
  __name(memoryDir, "memoryDir");
9510
9640
  function userFilePath(home) {
9511
- return join11(memoryDir(home), "USER.md");
9641
+ return join12(memoryDir(home), "USER.md");
9512
9642
  }
9513
9643
  __name(userFilePath, "userFilePath");
9514
9644
  function memoryFilePath(home) {
9515
- return join11(memoryDir(home), "MEMORY.md");
9645
+ return join12(memoryDir(home), "MEMORY.md");
9516
9646
  }
9517
9647
  __name(memoryFilePath, "memoryFilePath");
9518
9648
  function projectMemoryFilePath(cwd) {
@@ -9523,9 +9653,9 @@ function projectMemoryFilePath(cwd) {
9523
9653
  if (error.code !== "ENOENT") throw error;
9524
9654
  }
9525
9655
  const root = cliProjectRoot(directory);
9526
- const local = join11(directory, ".namzu", "MEMORY.md");
9656
+ const local = join12(directory, ".namzu", "MEMORY.md");
9527
9657
  if (resolveMemoryPath({ path: local, root }) !== null) return local;
9528
- return join11(root, ".namzu", "MEMORY.md");
9658
+ return join12(root, ".namzu", "MEMORY.md");
9529
9659
  }
9530
9660
  __name(projectMemoryFilePath, "projectMemoryFilePath");
9531
9661
  function projectMemoryLocation(cwd) {
@@ -9555,15 +9685,15 @@ function readMemory(home, cwd) {
9555
9685
  }
9556
9686
  }, "read");
9557
9687
  const userRoot = memoryDir(home);
9558
- const user = read2(join11(userRoot, "USER.md"), () => ({
9688
+ const user = read2(join12(userRoot, "USER.md"), () => ({
9559
9689
  root: userRoot,
9560
- path: join11(userRoot, "USER.md")
9690
+ path: join12(userRoot, "USER.md")
9561
9691
  }));
9562
- const memory = read2(join11(userRoot, "MEMORY.md"), () => ({
9692
+ const memory = read2(join12(userRoot, "MEMORY.md"), () => ({
9563
9693
  root: userRoot,
9564
- path: join11(userRoot, "MEMORY.md")
9694
+ path: join12(userRoot, "MEMORY.md")
9565
9695
  }));
9566
- 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;
9567
9697
  return { user, memory, project, ...diagnostics.length > 0 ? { diagnostics } : {} };
9568
9698
  }
9569
9699
  __name(readMemory, "readMemory");
@@ -9575,7 +9705,7 @@ function isUserMemoryFile(projectPath, userRoot) {
9575
9705
  return resolve9(path);
9576
9706
  }
9577
9707
  }, "canonical");
9578
- return canonical(projectPath) === canonical(join11(userRoot, "MEMORY.md"));
9708
+ return canonical(projectPath) === canonical(join12(userRoot, "MEMORY.md"));
9579
9709
  }
9580
9710
  __name(isUserMemoryFile, "isUserMemoryFile");
9581
9711
  function capped(text2, file) {
@@ -9667,7 +9797,7 @@ async function saveTypedNote(store, text2, type = "project") {
9667
9797
  saved: false,
9668
9798
  duplicate: true,
9669
9799
  type: record.entry.type ?? type,
9670
- ...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`) } : {}
9671
9801
  };
9672
9802
  }
9673
9803
  }
@@ -9682,7 +9812,7 @@ async function saveTypedNote(store, text2, type = "project") {
9682
9812
  return {
9683
9813
  saved: true,
9684
9814
  type,
9685
- ...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`) } : {}
9686
9816
  };
9687
9817
  }
9688
9818
  __name(saveTypedNote, "saveTypedNote");
@@ -9725,7 +9855,7 @@ __name(composeMemoryGuidance, "composeMemoryGuidance");
9725
9855
  var MARKER2 = "migration.json";
9726
9856
  async function readMarker(directory) {
9727
9857
  try {
9728
- const parsed = JSON.parse(await readFile3(join12(directory, MARKER2), "utf8"));
9858
+ const parsed = JSON.parse(await readFile3(join13(directory, MARKER2), "utf8"));
9729
9859
  return parsed !== null && typeof parsed === "object" ? parsed : {};
9730
9860
  } catch (error) {
9731
9861
  if (error.code === "ENOENT") return {};
@@ -9738,7 +9868,7 @@ async function markCuratedFile(directory, path, state) {
9738
9868
  const files = { ...marker.curatedFiles ?? {} };
9739
9869
  files[path] = { ...files[path] ?? {}, ...state };
9740
9870
  await writeFile2(
9741
- join12(directory, MARKER2),
9871
+ join13(directory, MARKER2),
9742
9872
  `${JSON.stringify({ ...marker, curatedFiles: files }, null, 2)}
9743
9873
  `,
9744
9874
  { mode: 384 }
@@ -9805,7 +9935,7 @@ async function migrateMemoryOnce(options) {
9805
9935
  const skippedRecords = [];
9806
9936
  let importedRecords = 0;
9807
9937
  let notesOffer;
9808
- const indexPath = join12(directory, "index.json");
9938
+ const indexPath = join13(directory, "index.json");
9809
9939
  if (await exists(indexPath)) {
9810
9940
  try {
9811
9941
  const disk = new DiskMemoryStore({ baseDir: directory, directory });
@@ -9828,11 +9958,11 @@ async function migrateMemoryOnce(options) {
9828
9958
  }
9829
9959
  }
9830
9960
  await retire(indexPath);
9831
- const content = join12(directory, "content");
9961
+ const content = join13(directory, "content");
9832
9962
  const retiredContent = await exists(content) ? await retire(content) : content;
9833
9963
  for (const record of refused) {
9834
9964
  skippedRecords.push(
9835
- `"${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`)}.`
9836
9966
  );
9837
9967
  }
9838
9968
  } catch (error) {
@@ -9907,9 +10037,9 @@ function describeMemoryMigration(report, directory) {
9907
10037
  }
9908
10038
  for (const skipped of report.skippedRecords) notices.push(`Stored memory: ${skipped}`);
9909
10039
  if (report.notesOffer) {
9910
- const { path, count } = report.notesOffer;
10040
+ const { path, count: count2 } = report.notesOffer;
9911
10041
  notices.push(
9912
- `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.`
9913
10043
  );
9914
10044
  }
9915
10045
  notices.push(...report.problems);
@@ -10308,11 +10438,11 @@ function taskActivityOutput(activity, settled) {
10308
10438
  __name(taskActivityOutput, "taskActivityOutput");
10309
10439
 
10310
10440
  // src/integrations/subagents/worktree-driver.ts
10311
- import { execFile as execFile2 } from "node:child_process";
10441
+ import { execFile as execFile3 } from "node:child_process";
10312
10442
  import { mkdir as mkdir3, realpath as realpath3 } from "node:fs/promises";
10313
10443
  import { isAbsolute as isAbsolute8, relative as relative8, resolve as resolve10, sep as sep6 } from "node:path";
10314
10444
  import { promisify as promisify2 } from "node:util";
10315
- var runFile = promisify2(execFile2);
10445
+ var runFile = promisify2(execFile3);
10316
10446
  var DelegatedWorktreeDriver = class {
10317
10447
  constructor(cwd, stateRoot) {
10318
10448
  this.cwd = cwd;
@@ -12243,7 +12373,7 @@ ${step}`;
12243
12373
  sessionId: parent.sessionId
12244
12374
  });
12245
12375
  await mkdir4(directory, { recursive: true, mode: 448 });
12246
- journal = join13(directory, "child-operator-messages.jsonl");
12376
+ journal = join14(directory, "child-operator-messages.jsonl");
12247
12377
  }
12248
12378
  await audit("submitted");
12249
12379
  signal.throwIfAborted();
@@ -12547,12 +12677,12 @@ function agentTaskOutcome(task) {
12547
12677
  __name(agentTaskOutcome, "agentTaskOutcome");
12548
12678
  function workspaceData(task) {
12549
12679
  const meta = task.workspace?.meta;
12550
- 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 } : {};
12551
12681
  }
12552
12682
  __name(workspaceData, "workspaceData");
12553
12683
  function workspaceRemoved(task) {
12554
12684
  const meta = task.workspace?.meta;
12555
- return meta?.backend === "git-worktree" && !existsSync(meta.worktreePath);
12685
+ return meta?.backend === "git-worktree" && !existsSync2(meta.worktreePath);
12556
12686
  }
12557
12687
  __name(workspaceRemoved, "workspaceRemoved");
12558
12688
  function workspaceNote(task) {
@@ -12702,7 +12832,7 @@ __name(buildDefinition, "buildDefinition");
12702
12832
 
12703
12833
  // src/integrations/workflows/history.ts
12704
12834
  import { readFile as readFile4, readdir as readdir2 } from "node:fs/promises";
12705
- import { join as join14 } from "node:path";
12835
+ import { join as join15 } from "node:path";
12706
12836
  var RUN_ID = /^w[0-9a-z]{8}$/;
12707
12837
  async function readWorkflowJournal(file) {
12708
12838
  let text2;
@@ -12728,7 +12858,7 @@ async function readWorkflowJournal(file) {
12728
12858
  __name(readWorkflowJournal, "readWorkflowJournal");
12729
12859
  async function readWorkflowRun(runsDirectory, runId) {
12730
12860
  if (!RUN_ID.test(runId)) return void 0;
12731
- const records = await readWorkflowJournal(join14(runsDirectory, runId, "workflow", "journal.jsonl"));
12861
+ const records = await readWorkflowJournal(join15(runsDirectory, runId, "workflow", "journal.jsonl"));
12732
12862
  return viewFromJournal(records);
12733
12863
  }
12734
12864
  __name(readWorkflowRun, "readWorkflowRun");
@@ -12749,9 +12879,9 @@ __name(listWorkflowRuns, "listWorkflowRuns");
12749
12879
 
12750
12880
  // src/integrations/workflows/host.ts
12751
12881
  import { randomBytes as randomBytes3 } from "node:crypto";
12752
- import { existsSync as existsSync2 } from "node:fs";
12882
+ import { existsSync as existsSync3 } from "node:fs";
12753
12883
  import { readFile as readFile5 } from "node:fs/promises";
12754
- import { join as join15 } from "node:path";
12884
+ import { join as join16 } from "node:path";
12755
12885
 
12756
12886
  // src/integrations/workflows/offering.ts
12757
12887
  var WORKFLOW_TOOL_NAME = "workflow";
@@ -13201,7 +13331,7 @@ function createWorkflowHost(options) {
13201
13331
  }
13202
13332
  let checked;
13203
13333
  try {
13204
- checked = await new FileWorkflowJournal(join15(runs, runId, "workflow"), {
13334
+ checked = await new FileWorkflowJournal(join16(runs, runId, "workflow"), {
13205
13335
  runId,
13206
13336
  ...key !== void 0 ? { key } : {}
13207
13337
  }).read();
@@ -13221,7 +13351,7 @@ function createWorkflowHost(options) {
13221
13351
  }
13222
13352
  resumeState = loadWorkflowResume(checked);
13223
13353
  if (!resumeState.resumable) {
13224
- 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(
13225
13355
  (text2) => journalKeyMismatch(text2, runId, key),
13226
13356
  () => false
13227
13357
  );
@@ -13241,12 +13371,12 @@ function createWorkflowHost(options) {
13241
13371
  if (state === "ended") registry.discard(runId);
13242
13372
  } else {
13243
13373
  runId = createWorkflowRunId(
13244
- (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))
13245
13375
  );
13246
13376
  }
13247
13377
  const turn = options.openRunTurn(context.turnId, runId);
13248
13378
  const limits = options.limitsFor?.(context.turnId);
13249
- const journalDirectory = runs === void 0 ? void 0 : join15(runs, runId, "workflow");
13379
+ const journalDirectory = runs === void 0 ? void 0 : join16(runs, runId, "workflow");
13250
13380
  const journal = journalDirectory === void 0 ? void 0 : new FileWorkflowJournal(journalDirectory, {
13251
13381
  runId,
13252
13382
  ...key !== void 0 ? { key } : {}
@@ -13280,7 +13410,7 @@ function createWorkflowHost(options) {
13280
13410
  ...journal ? { journal } : {},
13281
13411
  ...resumeState ? { resume: resumeState } : {},
13282
13412
  ...editable !== void 0 ? { scriptPath: editable } : {},
13283
- ...journalDirectory !== void 0 ? { journalPath: join15(journalDirectory, "journal.jsonl") } : {},
13413
+ ...journalDirectory !== void 0 ? { journalPath: join16(journalDirectory, "journal.jsonl") } : {},
13284
13414
  spawn: /* @__PURE__ */ __name(async (request, signal, viewed) => {
13285
13415
  const detail = phaseDetail(request.phaseTitle);
13286
13416
  const outcome2 = await options.subagents.launchWorkflowAgent({
@@ -13363,9 +13493,9 @@ function createWorkflowHost(options) {
13363
13493
  __name(createWorkflowHost, "createWorkflowHost");
13364
13494
 
13365
13495
  // src/integrations/workflows/orphans.ts
13366
- import { existsSync as existsSync3 } from "node:fs";
13496
+ import { existsSync as existsSync4 } from "node:fs";
13367
13497
  import { readFile as readFile6, readdir as readdir3, writeFile as writeFile3 } from "node:fs/promises";
13368
- import { join as join16 } from "node:path";
13498
+ import { join as join17 } from "node:path";
13369
13499
  var NOTICE_FILE = "orphan-notice.json";
13370
13500
  var MAX_ORPHAN_NOTICES = 20;
13371
13501
  var NO_USAGE = {
@@ -13384,7 +13514,7 @@ function quotedName(name) {
13384
13514
  }
13385
13515
  __name(quotedName, "quotedName");
13386
13516
  function noticePath(runsDirectory, runId) {
13387
- return join16(runsDirectory, runId, "workflow", NOTICE_FILE);
13517
+ return join17(runsDirectory, runId, "workflow", NOTICE_FILE);
13388
13518
  }
13389
13519
  __name(noticePath, "noticePath");
13390
13520
  async function readStored(runsDirectory, runId) {
@@ -13400,8 +13530,8 @@ async function readStored(runsDirectory, runId) {
13400
13530
  return void 0;
13401
13531
  }
13402
13532
  __name(readStored, "readStored");
13403
- function words(count, noun) {
13404
- return `${count} ${noun}${count === 1 ? "" : "s"}`;
13533
+ function words(count2, noun) {
13534
+ return `${count2} ${noun}${count2 === 1 ? "" : "s"}`;
13405
13535
  }
13406
13536
  __name(words, "words");
13407
13537
  async function recoverUnfinishedWorkflows(options) {
@@ -13416,7 +13546,7 @@ async function recoverUnfinishedWorkflows(options) {
13416
13546
  for (const runId of entries.filter((name) => RUN_ID_PATTERN.test(name)).sort()) {
13417
13547
  if (options.liveRunIds.has(runId)) continue;
13418
13548
  const stored = await readStored(options.runsDirectory, runId);
13419
- const dir = join16(options.runsDirectory, runId, "workflow");
13549
+ const dir = join17(options.runsDirectory, runId, "workflow");
13420
13550
  const journal = new FileWorkflowJournal(dir, {
13421
13551
  runId,
13422
13552
  ...options.key !== void 0 ? { key: options.key } : {}
@@ -13467,7 +13597,7 @@ async function recoverUnfinishedWorkflows(options) {
13467
13597
  (key) => !state.results.has(key) && !state.failed.has(key)
13468
13598
  ).length;
13469
13599
  const copy = editableCopyPath(options.runsDirectory, name, runId);
13470
- const script = started.scriptPath ?? (existsSync3(copy) ? copy : void 0);
13600
+ const script = started.scriptPath ?? (existsSync4(copy) ? copy : void 0);
13471
13601
  text2 = [
13472
13602
  `Background workflow ${quotedName(name)} (run ${runId}) didn't finish before the previous session ended.`,
13473
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.`,
@@ -13525,7 +13655,7 @@ __name(recoverUnfinishedWorkflows, "recoverUnfinishedWorkflows");
13525
13655
  async function keyMismatchOf(dir, runId, key) {
13526
13656
  if (key === void 0) return false;
13527
13657
  try {
13528
- return journalKeyMismatch(await readFile6(join16(dir, "journal.jsonl"), "utf8"), runId, key);
13658
+ return journalKeyMismatch(await readFile6(join17(dir, "journal.jsonl"), "utf8"), runId, key);
13529
13659
  } catch {
13530
13660
  return false;
13531
13661
  }
@@ -13566,7 +13696,7 @@ import { dirname as dirname4 } from "node:path";
13566
13696
  import { createHash as createHash5 } from "node:crypto";
13567
13697
 
13568
13698
  // src/memory/manage.ts
13569
- import { join as join17 } from "node:path";
13699
+ import { join as join18 } from "node:path";
13570
13700
 
13571
13701
  // src/memory/presentation.ts
13572
13702
  var MEMORY_PREVIEW_MAX_CHARS = 2e3;
@@ -13647,32 +13777,178 @@ ${preview(derived.text, directory)}`
13647
13777
  }
13648
13778
  __name(renderStoredMemorySection, "renderStoredMemorySection");
13649
13779
 
13650
- // 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";
13651
13784
  var DAY_MS = 864e5;
13652
- 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();
13653
13800
  const { entries } = await store.list({ status: "active" });
13654
- 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");
13655
13816
  for (const entry of entries) {
13656
13817
  const record = await store.getVersionedRecord(entry.id);
13657
13818
  if (!record || record.entry.status !== "active") continue;
13658
- const supersedes = record.content.metadata?.supersedes;
13659
- const replaced = typeof supersedes === "string" ? (await store.getRecord(supersedes))?.entry.title : void 0;
13660
- items.push({
13661
- id: record.entry.id,
13662
- name: record.entry.name,
13663
- title: record.entry.title,
13664
- type: record.entry.type,
13665
- origin: memoryOrigin(record.content.metadata),
13666
- createdAt: record.entry.createdAt,
13667
- updatedAt: record.entry.updatedAt,
13668
- revision: record.revision,
13669
- path: record.entry.name ? join17(directory, `${record.entry.name}.md`) : directory,
13670
- ...replaced ? { replaces: replaced } : {}
13671
- });
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
+ }
13672
13947
  }
13673
13948
  return sortManagedMemories(items);
13674
13949
  }
13675
13950
  __name(loadManagedMemories, "loadManagedMemories");
13951
+ var STATE_RANK = { active: 0, "set-aside": 1, retired: 2 };
13676
13952
  var ORIGIN_RANK = {
13677
13953
  operator: 0,
13678
13954
  model: 1,
@@ -13680,7 +13956,7 @@ var ORIGIN_RANK = {
13680
13956
  };
13681
13957
  function sortManagedMemories(items) {
13682
13958
  return [...items].sort(
13683
- (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)
13684
13960
  );
13685
13961
  }
13686
13962
  __name(sortManagedMemories, "sortManagedMemories");
@@ -13689,7 +13965,7 @@ function originLabel(origin) {
13689
13965
  }
13690
13966
  __name(originLabel, "originLabel");
13691
13967
  function ageLabel(updatedAt, now = Date.now()) {
13692
- const days = Math.max(0, Math.floor((now - updatedAt) / DAY_MS));
13968
+ const days = Math.max(0, Math.floor((now - updatedAt) / DAY_MS2));
13693
13969
  if (days === 0) return "today";
13694
13970
  return `${days} day${days === 1 ? "" : "s"} ago`;
13695
13971
  }
@@ -13699,8 +13975,17 @@ function memoryLabel(item) {
13699
13975
  return line;
13700
13976
  }
13701
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");
13702
13987
  function memoryDescription(item, now = Date.now()) {
13703
- 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 ");
13704
13989
  }
13705
13990
  __name(memoryDescription, "memoryDescription");
13706
13991
  var DELETE_ALL_RECORDED = "__delete-all-recorded__";
@@ -13754,6 +14039,7 @@ function renderMemoryDetail(item, body2) {
13754
14039
  return [
13755
14040
  memoryLabel(item),
13756
14041
  `Written by: ${originLabel(item.origin)}`,
14042
+ ...stateLabel(item) ? [`State: ${stateLabel(item)}`] : [],
13757
14043
  ...item.replaces ? [`Replaced: ${item.replaces.replace(/\s+/g, " ").trim()}`] : [],
13758
14044
  ...item.type ? [`Type: ${item.type}`] : [],
13759
14045
  `Created: ${stamp(item.createdAt)}`,
@@ -13778,6 +14064,33 @@ async function deleteManagedMemory(store, item) {
13778
14064
  }
13779
14065
  }
13780
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");
13781
14094
  async function deleteMemories(store, items) {
13782
14095
  let deleted = 0;
13783
14096
  let kept = 0;
@@ -14048,10 +14361,10 @@ __name(screenCandidate, "screenCandidate");
14048
14361
  function screenMemoryPromotion(promote, log) {
14049
14362
  return (candidate) => {
14050
14363
  const { candidate: screened, dropped } = screenCandidate(candidate);
14051
- for (const [reason, count] of Object.entries(dropped)) {
14364
+ for (const [reason, count2] of Object.entries(dropped)) {
14052
14365
  log.info("memory claims dropped", {
14053
14366
  "namzu.memory.screen.reason": reason,
14054
- "namzu.memory.screen.dropped_count": count
14367
+ "namzu.memory.screen.dropped_count": count2
14055
14368
  });
14056
14369
  }
14057
14370
  return promote(screened);
@@ -14180,9 +14493,9 @@ function parseOps(reply, candidateCount) {
14180
14493
  const o = raw;
14181
14494
  const candidate = typeof o.candidate === "number" ? Math.trunc(o.candidate) - 1 : Number.NaN;
14182
14495
  if (!Number.isInteger(candidate) || candidate < 0 || candidate >= candidateCount) continue;
14183
- const count = (perCandidate.get(candidate) ?? 0) + 1;
14184
- perCandidate.set(candidate, count);
14185
- 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;
14186
14499
  const op = OPS.find((kind) => kind === o.op);
14187
14500
  if (op === void 0) {
14188
14501
  out.push({ candidate, invalid: true });
@@ -14595,9 +14908,14 @@ var CurationRuntime = class {
14595
14908
  #deps;
14596
14909
  #timer = null;
14597
14910
  #disposed = false;
14911
+ #draining = 0;
14598
14912
  constructor(deps) {
14599
14913
  this.#deps = deps;
14600
14914
  }
14915
+ /** Whether a drain is in flight right now. */
14916
+ get draining() {
14917
+ return this.#draining > 0;
14918
+ }
14601
14919
  #cancel() {
14602
14920
  if (this.#timer === null) return;
14603
14921
  this.#deps.clearTimer(this.#timer);
@@ -14651,6 +14969,7 @@ var CurationRuntime = class {
14651
14969
  this.#deps.report?.(reason, "skipped");
14652
14970
  return void 0;
14653
14971
  }
14972
+ this.#draining += 1;
14654
14973
  try {
14655
14974
  const lines = [];
14656
14975
  const result = await inbox.drain(async (entries) => {
@@ -14671,18 +14990,24 @@ var CurationRuntime = class {
14671
14990
  } catch {
14672
14991
  this.#deps.report?.(reason, "failed");
14673
14992
  return void 0;
14993
+ } finally {
14994
+ this.#draining -= 1;
14674
14995
  }
14675
14996
  }
14676
14997
  };
14677
14998
  function createCurationLog(file) {
14678
- let directory;
14679
- return (entry) => {
14680
- directory ??= mkdir5(dirname4(file), { recursive: true, mode: 448 }).catch(() => {
14681
- });
14682
- void directory.then(() => appendFile3(file, `${JSON.stringify(entry)}
14683
- `, { 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(() => {
14684
15008
  });
14685
- };
15009
+ }, "write");
15010
+ return Object.assign(write, { settled: /* @__PURE__ */ __name(() => tail2 ?? Promise.resolve(), "settled") });
14686
15011
  }
14687
15012
  __name(createCurationLog, "createCurationLog");
14688
15013
  function inboxPromotion(options) {
@@ -14726,7 +15051,7 @@ import {
14726
15051
  unlink as unlink3,
14727
15052
  writeFile as writeFile4
14728
15053
  } from "node:fs/promises";
14729
- 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";
14730
15055
  var INBOX_BATCH_SIZE = 8;
14731
15056
  var INBOX_MAX_BATCHES = 3;
14732
15057
  var INBOX_CLAIM_STALE_MS = 12e4;
@@ -14821,7 +15146,7 @@ var MemoryInbox = class {
14821
15146
  return dedupe(texts.flatMap((text2) => text2 === void 0 ? [] : parseLines(text2)));
14822
15147
  }
14823
15148
  #newClaimPath(now) {
14824
- return join18(
15149
+ return join19(
14825
15150
  dirname5(this.#file),
14826
15151
  `${basename3(this.#file, ".jsonl")}.claim-${now}-${this.#newId()}.jsonl`
14827
15152
  );
@@ -14840,7 +15165,7 @@ var MemoryInbox = class {
14840
15165
  if (!name.startsWith(prefix)) continue;
14841
15166
  const match = CLAIM_PATTERN.exec(name);
14842
15167
  if (!match) continue;
14843
- 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]) });
14844
15169
  }
14845
15170
  return out.sort((a, b) => a.at - b.at);
14846
15171
  }
@@ -14950,9 +15275,169 @@ async function atomicWrite(path, text2) {
14950
15275
  }
14951
15276
  __name(atomicWrite, "atomicWrite");
14952
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
+
14953
15438
  // src/memory/screen-archive.ts
14954
15439
  import { access as access2, writeFile as writeFile5 } from "node:fs/promises";
14955
- import { join as join19 } from "node:path";
15440
+ import { join as join20 } from "node:path";
14956
15441
  var SCREEN_MARKER_FILE = ".derived-screen-v1";
14957
15442
  var HEADINGS = {
14958
15443
  "What the user requires": "userRequirements",
@@ -15011,7 +15496,7 @@ ${body2}`) !== void 0) return true;
15011
15496
  __name(wouldNotBeWritten, "wouldNotBeWritten");
15012
15497
  async function archiveUnscreenedRecords(options) {
15013
15498
  const { store, directory, log } = options;
15014
- const marker = join19(directory, SCREEN_MARKER_FILE);
15499
+ const marker = join20(directory, SCREEN_MARKER_FILE);
15015
15500
  try {
15016
15501
  if (await access2(marker).then(
15017
15502
  () => true,
@@ -15191,6 +15676,250 @@ function memorySelectionOptions(setting, deps) {
15191
15676
  }
15192
15677
  __name(memorySelectionOptions, "memorySelectionOptions");
15193
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
+
15194
15923
  // src/permissions/auto-classifier.ts
15195
15924
  import { AsyncLocalStorage } from "node:async_hooks";
15196
15925
  var SMALL_MODEL_KEYWORD = "smallModel";
@@ -15405,10 +16134,10 @@ __name(cliGate, "cliGate");
15405
16134
  var WEB_FETCH_TOOL = "web_fetch";
15406
16135
  var MAX_LABEL_COMMAND = 60;
15407
16136
  var MAX_RULES_PER_ANSWER = 5;
15408
- function isRecord3(value) {
16137
+ function isRecord4(value) {
15409
16138
  return typeof value === "object" && value !== null && !Array.isArray(value);
15410
16139
  }
15411
- __name(isRecord3, "isRecord");
16140
+ __name(isRecord4, "isRecord");
15412
16141
  function alwaysAsked(call) {
15413
16142
  return mustAskPerson(call) || call.isDestructive === true;
15414
16143
  }
@@ -15493,7 +16222,7 @@ function plainCommands(line) {
15493
16222
  __name(plainCommands, "plainCommands");
15494
16223
  function allowsFor(call, commands) {
15495
16224
  if (alwaysAsked(call)) return void 0;
15496
- const input = isRecord3(call.input) ? call.input : void 0;
16225
+ const input = isRecord4(call.input) ? call.input : void 0;
15497
16226
  const commandArgument = commands.get(call.name);
15498
16227
  if (commandArgument !== void 0) {
15499
16228
  const line = input?.[commandArgument];
@@ -15611,7 +16340,7 @@ function createSessionAllows(_commands, options = {}) {
15611
16340
  );
15612
16341
  }, "rebuild");
15613
16342
  const allowed = /* @__PURE__ */ __name((call) => {
15614
- if (isRecord3(call.toolInput) && call.toolInput.dangerously_disable_sandbox === true)
16343
+ if (isRecord4(call.toolInput) && call.toolInput.dangerously_disable_sandbox === true)
15615
16344
  return false;
15616
16345
  const result = gate?.evaluate(call);
15617
16346
  return result !== void 0 && result.matchedRule !== null && result.decision === "allow";
@@ -15790,7 +16519,7 @@ function buildEnterPlanModeTool(host) {
15790
16519
  __name(buildEnterPlanModeTool, "buildEnterPlanModeTool");
15791
16520
 
15792
16521
  // src/plan/plan-file.ts
15793
- import { readFile as readFile8 } from "node:fs/promises";
16522
+ import { readFile as readFile9 } from "node:fs/promises";
15794
16523
  import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
15795
16524
  var WRITERS = /* @__PURE__ */ new Set(["write", "edit"]);
15796
16525
  function isPlanFileWrite(planPath, cwd) {
@@ -15807,7 +16536,7 @@ function isPlanFileWrite(planPath, cwd) {
15807
16536
  __name(isPlanFileWrite, "isPlanFileWrite");
15808
16537
  async function readPlan(planPath) {
15809
16538
  try {
15810
- const text2 = await readFile8(planPath, "utf8");
16539
+ const text2 = await readFile9(planPath, "utf8");
15811
16540
  return text2.trim().length > 0 ? text2 : void 0;
15812
16541
  } catch {
15813
16542
  return void 0;
@@ -15948,7 +16677,7 @@ function terminalProviderRetry(restartableOutput) {
15948
16677
  __name(terminalProviderRetry, "terminalProviderRetry");
15949
16678
 
15950
16679
  // src/reminders/index.ts
15951
- import { existsSync as existsSync4 } from "node:fs";
16680
+ import { existsSync as existsSync5 } from "node:fs";
15952
16681
 
15953
16682
  // src/reminders/changed-files.ts
15954
16683
  import { open as open4, stat as stat5 } from "node:fs/promises";
@@ -16577,7 +17306,7 @@ function createCliReminderSource(options) {
16577
17306
  messages,
16578
17307
  mode: options.mode(),
16579
17308
  planPath,
16580
- planExists: (options.planExists ?? existsSync4)(planPath),
17309
+ planExists: (options.planExists ?? existsSync5)(planPath),
16581
17310
  canAsk: options.canAsk === true
16582
17311
  })
16583
17312
  );
@@ -17486,11 +18215,11 @@ __name(clipRequestContext, "clipRequestContext");
17486
18215
  async function createAgentSession(prefs, detectedProviders, options = {}) {
17487
18216
  const modelEnvironment = readModelLaunchEnvironment();
17488
18217
  if (options.palEnvironment) {
17489
- const { createPalAgentSession } = await import("./agent-session-FZI6GVBH.js");
18218
+ const { createPalAgentSession } = await import("./agent-session-5ZG6WNTC.js");
17490
18219
  return createPalAgentSession(prefs, detectedProviders, options);
17491
18220
  }
17492
18221
  let detected = detectedProviders;
17493
- const { palAtWorkspace } = await import("./store-MNI5IJHC.js");
18222
+ const { palAtWorkspace } = await import("./store-3R5KTEP5.js");
17494
18223
  if (palAtWorkspace(options.cwd ?? process.cwd()))
17495
18224
  throw new Error("This Pal requires its owned virtual computer. Open it with namzu pal chat.");
17496
18225
  const commandArguments = builtinCommandArguments();
@@ -17546,7 +18275,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
17546
18275
  );
17547
18276
  }
17548
18277
  const sandboxWorkspace = options.sandbox?.workspace ?? "working-directory";
17549
- 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) {
17550
18279
  return emptySession(
17551
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.",
17552
18281
  "invocation"
@@ -18520,7 +19249,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18520
19249
  runsDirectory: /* @__PURE__ */ __name((turnId) => {
18521
19250
  if (options.ephemeral) return void 0;
18522
19251
  const owner = delegationScopes.get(turnId) ?? scope2;
18523
- return join20(paths.sessionDir({ sessionId: owner.sessionId }), "runs");
19252
+ return join21(paths.sessionDir({ sessionId: owner.sessionId }), "runs");
18524
19253
  }, "runsDirectory"),
18525
19254
  refusal: /* @__PURE__ */ __name((turnId) => {
18526
19255
  const auth = delegatedWorkflowAuth.get(turnId);
@@ -18756,7 +19485,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18756
19485
  );
18757
19486
  toolsets.push(options.toolLoading === "eager" ? monitorToolset : deferred(monitorToolset));
18758
19487
  }
18759
- const operatorPals = await import("./operator-tools-CZ2SXR3G.js");
19488
+ const operatorPals = await import("./operator-tools-O43OOXJJ.js");
18760
19489
  toolsets.push(
18761
19490
  readyWhen(
18762
19491
  toolset(
@@ -18811,7 +19540,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18811
19540
  );
18812
19541
  const curationListeners = /* @__PURE__ */ new Set();
18813
19542
  const memoryInbox = new MemoryInbox({
18814
- file: join20(paths.home, "memory-inbox", `${paths.slug}.jsonl`),
19543
+ file: join21(paths.home, "memory-inbox", `${paths.slug}.jsonl`),
18815
19544
  now: Date.now
18816
19545
  });
18817
19546
  const curation = options.memory?.curation === "off" || options.compaction?.consolidate ? void 0 : new CurationRuntime({
@@ -18820,7 +19549,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18820
19549
  store: memoryStore,
18821
19550
  sideModel: /* @__PURE__ */ __name(() => sideModel, "sideModel"),
18822
19551
  fallback: screenedPromoter,
18823
- log: createCurationLog(join20(paths.home, "memory", "curation.jsonl"))
19552
+ log: createCurationLog(join21(paths.home, "memory", "curation.jsonl"))
18824
19553
  }),
18825
19554
  setTimer: /* @__PURE__ */ __name((run2, ms) => {
18826
19555
  const handle = setTimeout(run2, ms);
@@ -18838,6 +19567,31 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18838
19567
  "namzu.memory.curation.result": typeof result === "string" ? result : `${result.applied}/${result.kept}/${result.dropped}`
18839
19568
  }), "report")
18840
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
+ });
18841
19595
  const promoteMemory = composeMemoryPromotion({
18842
19596
  curation,
18843
19597
  inbox: memoryInbox,
@@ -18967,12 +19721,14 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
18967
19721
  [EVENT_NAME_ATTRIBUTE]: BOOT_EVENT_NAMES.BOOT_READY
18968
19722
  });
18969
19723
  curation?.start();
19724
+ void memoryLifecycle.start();
18970
19725
  const reasoningLookup = new AbortController();
18971
19726
  const ephemeralLogs = /* @__PURE__ */ new Map();
18972
19727
  const ephemeralScopeKey = /* @__PURE__ */ __name((value) => JSON.stringify([value.tenantId, value.projectId, value.topicId, value.sessionId]), "ephemeralScopeKey");
18973
19728
  const operations = new SessionOperationOwner(async () => {
18974
19729
  reasoningLookup.abort();
18975
19730
  await curation?.dispose();
19731
+ await memoryLifecycle.dispose();
18976
19732
  workflowHost?.registry.close();
18977
19733
  const results = await Promise.allSettled([
18978
19734
  Promise.resolve().then(() => manager.dispose()),
@@ -19208,6 +19964,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19208
19964
  delegationScopes.set(entry2.turnId, turnScope);
19209
19965
  latestTurn = { sessionId: turnScope.sessionId, turnId: entry2.turnId };
19210
19966
  curation?.turnStarted();
19967
+ memoryLifecycle.turnStarted();
19211
19968
  delegationLimits.set(entry2.turnId, resumedLimits);
19212
19969
  if (route && pinned)
19213
19970
  delegationModels.set(entry2.turnId, {
@@ -19252,6 +20009,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19252
20009
  store: memoryStore,
19253
20010
  identifierGrounding: options.memory?.identifierGrounding,
19254
20011
  record: true,
20012
+ excluded: memoryLifecycle.excluded,
19255
20013
  ...memorySelection
19256
20014
  })
19257
20015
  ],
@@ -19454,6 +20212,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19454
20212
  },
19455
20213
  providerSummary: entry.id === "anthropic" ? withEndpointHost(entry.label) : entry.label,
19456
20214
  modelSummary: model,
20215
+ providerId: entry.id,
19457
20216
  get autoRoute() {
19458
20217
  return lastAutoRoute;
19459
20218
  },
@@ -19654,7 +20413,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19654
20413
  const live = host.registry.list();
19655
20414
  const known = new Set(live.map((view) => view.runId));
19656
20415
  const saved = options.ephemeral ? [] : await listWorkflowRuns(
19657
- join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs")
20416
+ join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs")
19658
20417
  ).catch(() => []);
19659
20418
  return [
19660
20419
  ...[...live].sort((a, b) => b.startedAt - a.startedAt),
@@ -19664,14 +20423,14 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19664
20423
  readScript: /* @__PURE__ */ __name((path) => {
19665
20424
  const saved = readSavedScript(
19666
20425
  path,
19667
- scriptsDirectory(join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"))
20426
+ scriptsDirectory(join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"))
19668
20427
  );
19669
20428
  if (!saved.ok) return void 0;
19670
20429
  reviewedScripts.record(saved.path, saved.text);
19671
20430
  return saved.text;
19672
20431
  }, "readScript"),
19673
20432
  describeResume: /* @__PURE__ */ __name((runId, script) => describeResume(
19674
- join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
20433
+ join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
19675
20434
  runId,
19676
20435
  script,
19677
20436
  options.ephemeral ? void 0 : workflowJournalKey(paths.home)
@@ -19679,13 +20438,13 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19679
20438
  recoverUnfinished: /* @__PURE__ */ __name(async () => {
19680
20439
  if (options.ephemeral) return [];
19681
20440
  return recoverUnfinishedWorkflows({
19682
- runsDirectory: join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
20441
+ runsDirectory: join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
19683
20442
  liveRunIds: new Set(host.registry.list().map((view) => view.runId)),
19684
20443
  ...workflowJournalKey(paths.home) !== void 0 ? { key: workflowJournalKey(paths.home) } : {}
19685
20444
  });
19686
20445
  }, "recoverUnfinished"),
19687
20446
  noticesDelivered: /* @__PURE__ */ __name((runIds) => markOrphanNoticesDelivered(
19688
- join20(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
20447
+ join21(paths.sessionDir({ sessionId: scope2.sessionId }), "runs"),
19689
20448
  runIds
19690
20449
  ), "noticesDelivered"),
19691
20450
  onEnd: /* @__PURE__ */ __name((listener) => {
@@ -19751,6 +20510,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19751
20510
  delegationScopes.set(turnId, turnScope);
19752
20511
  latestTurn = { sessionId: turnScope.sessionId, turnId };
19753
20512
  curation?.turnStarted();
20513
+ memoryLifecycle.turnStarted();
19754
20514
  delegationLimits.set(turnId, resolveTurnGuards(options.limits, opts?.limits));
19755
20515
  delegatedResumeHandlers.set(turnId, control.handler);
19756
20516
  delegatedReviewAllowedCalls.set(turnId, control.reviewAllowedCalls);
@@ -19942,7 +20702,15 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
19942
20702
  })
19943
20703
  }), "storedMemoryIndex"),
19944
20704
  storedMemories: {
19945
- 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"),
19946
20714
  read: /* @__PURE__ */ __name((item) => readMemoryBody(memoryStore, item.id), "read"),
19947
20715
  remove: /* @__PURE__ */ __name((item) => deleteManagedMemory(memoryStore, item), "remove"),
19948
20716
  removeRecorded: /* @__PURE__ */ __name((items) => deleteRecordedMemories(memoryStore, items), "removeRecorded"),
@@ -20042,6 +20810,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20042
20810
  delegationScopes.set(turnId2, turnScope);
20043
20811
  latestTurn = { sessionId: turnScope.sessionId, turnId: turnId2 };
20044
20812
  curation?.turnStarted();
20813
+ memoryLifecycle.turnStarted();
20045
20814
  delegationLimits.set(turnId2, turnLimits);
20046
20815
  const typedTarget = parseTokenTarget(opts?.typedInput ?? "");
20047
20816
  if (typedTarget !== void 0) workflowTokenTargets.set(turnId2, typedTarget);
@@ -20372,6 +21141,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20372
21141
  reviewAnswer: options.reviewAnswer,
20373
21142
  maxAnswerReviews: options.maxAnswerReviews,
20374
21143
  promoteMemory: options.compaction?.consolidate ? void 0 : promoteMemory,
21144
+ ...options.memory?.recall === false ? {} : { memoryLifecycle },
20375
21145
  prepareStep: [
20376
21146
  createTaskContextStep(turnTaskStore, turnScope.tenantId),
20377
21147
  outstandingWorkStep,
@@ -20383,6 +21153,7 @@ async function createAgentSession(prefs, detectedProviders, options = {}) {
20383
21153
  query: lastPromptText(messages),
20384
21154
  identifierGrounding: options.memory?.identifierGrounding,
20385
21155
  record: true,
21156
+ excluded: memoryLifecycle.excluded,
20386
21157
  ...memorySelection
20387
21158
  })
20388
21159
  ],
@@ -20985,6 +21756,7 @@ async function* runTurn({
20985
21756
  reviewAnswer,
20986
21757
  maxAnswerReviews,
20987
21758
  promoteMemory,
21759
+ memoryLifecycle,
20988
21760
  prepareStep,
20989
21761
  resumeHandler,
20990
21762
  approvalPolicyName,
@@ -21020,6 +21792,10 @@ async function* runTurn({
21020
21792
  const events = query({
21021
21793
  maxOutputContinuations: MAX_OUTPUT_CONTINUATIONS,
21022
21794
  ...opts?.refusalFallback ? { refusalFallback: opts.refusalFallback } : {},
21795
+ ...memoryLifecycle ? {
21796
+ withholdOnRefusal: memoryLifecycle.withholdOnRefusal,
21797
+ withheldKeys: memoryLifecycle.withheldKeys()
21798
+ } : {},
21023
21799
  ...retainedToolPreviewChars !== void 0 ? { retainedToolPreviewChars } : {},
21024
21800
  ...fileReadTracker ? { fileReadTracker } : {},
21025
21801
  ...structuredOutput ? { structuredOutput } : {},
@@ -21073,6 +21849,7 @@ async function* runTurn({
21073
21849
  model,
21074
21850
  ...sandboxProvider ? { sandbox: { workspace: sandboxWorkspace } } : {},
21075
21851
  ...opts?.effort !== void 0 ? { effort: opts.effort } : {},
21852
+ ...opts?.speed === "fast" ? { speed: opts.speed } : {},
21076
21853
  ...webSearch ? { webSearch } : {},
21077
21854
  ...turnConfigFields(resolveTurnGuards(limits), { completionAudit: true }),
21078
21855
  maxResponseTokens: limits?.maxResponseTokens ?? 8192,
@@ -21136,6 +21913,7 @@ async function* runTurn({
21136
21913
  claimTurn(event.turnId);
21137
21914
  }
21138
21915
  onSessionEvent?.(event);
21916
+ memoryLifecycle?.observe(event);
21139
21917
  if (signal?.aborted) {
21140
21918
  if (!abortReported) {
21141
21919
  abortReported = true;
@@ -21536,15 +22314,15 @@ function toAgentEvent(event, presenter, readsOnly, cwd) {
21536
22314
  };
21537
22315
  case "message_history_repaired": {
21538
22316
  if (event.source === "provider-rejected-image") {
21539
- const count = event.providerRejectedImagesSuppressed ?? 0;
22317
+ const count2 = event.providerRejectedImagesSuppressed ?? 0;
21540
22318
  return {
21541
22319
  kind: "history-repair",
21542
22320
  source: event.source,
21543
22321
  duplicateResults: event.duplicateToolResultsRemoved,
21544
22322
  orphanedResults: event.orphanedToolResultsRemoved,
21545
22323
  interruptedCalls: event.syntheticToolResultsInserted,
21546
- rejectedImages: count,
21547
- 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.`
21548
22326
  };
21549
22327
  }
21550
22328
  const changes = [
@@ -21923,6 +22701,7 @@ export {
21923
22701
  renderRestoreNote,
21924
22702
  PluginSettingsStore,
21925
22703
  validateComposerSendSettings,
22704
+ DecisionError,
21926
22705
  maybeCreateDecisionTool,
21927
22706
  maybeCreateDecisionModel,
21928
22707
  resolveAutoDefault,
@@ -21975,6 +22754,7 @@ export {
21975
22754
  PROGRESS_LOOK_MIN_GAP_MS,
21976
22755
  PHASE_NOTE_KEY_PREFIX,
21977
22756
  describePendingWorkflowNotices,
22757
+ thirdPartyHost,
21978
22758
  sessionLogCheckpointView,
21979
22759
  discoverAgentDefinitions2 as discoverAgentDefinitions,
21980
22760
  DEFAULT_AGENT_WORKFLOW,
@@ -21999,6 +22779,7 @@ export {
21999
22779
  matchMemories,
22000
22780
  listMatches,
22001
22781
  renderMemoryDetail,
22782
+ restoreOutcomeLine,
22002
22783
  RECALLED_MEMORY_KEY,
22003
22784
  historyHoldsAnyMemory,
22004
22785
  deleteOutcomeLine,
@@ -22048,4 +22829,4 @@ export {
22048
22829
  RESULT_SUMMARY_WHOLE_MAX,
22049
22830
  resultSummaryLine
22050
22831
  };
22051
- //# sourceMappingURL=chunk-RXUDOOPL.js.map
22832
+ //# sourceMappingURL=chunk-G5LUEMDI.js.map