@namzu/cli 44.1.1 → 44.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/acp-OUBJWH5B.js +7754 -0
  4. package/dist/chunks/acp-OUBJWH5B.js.map +6 -0
  5. package/dist/chunks/{activity-command-Y5ZLCQ63.js → activity-command-R7MUSZIY.js} +16 -15
  6. package/dist/chunks/activity-command-R7MUSZIY.js.map +6 -0
  7. package/dist/chunks/{add-F7M57FGR.js → add-PSEIDDRW.js} +21 -18
  8. package/dist/chunks/add-PSEIDDRW.js.map +6 -0
  9. package/dist/chunks/{agent-AFX2UZU5.js → agent-YPEXUYPH.js} +35 -30
  10. package/dist/chunks/agent-session-EZB2OYG3.js +65 -0
  11. package/dist/chunks/{archive-6NM6DYAT.js → archive-ET4PXE34.js} +11 -10
  12. package/dist/chunks/archive-ET4PXE34.js.map +6 -0
  13. package/dist/chunks/{bin-main-I6CHRYYQ.js → bin-main-PMB57AZJ.js} +9 -9
  14. package/dist/chunks/binding-K6RIQ5AP.js +17 -0
  15. package/dist/chunks/{browser-OPMOTWTV.js → browser-SKTIAVBF.js} +6 -6
  16. package/dist/chunks/{chat-KGVPXQS6.js → chat-AVIVXXMD.js} +20 -19
  17. package/dist/chunks/chat-AVIVXXMD.js.map +6 -0
  18. package/dist/chunks/chunk-26C37THH.js +867 -0
  19. package/dist/chunks/chunk-26C37THH.js.map +6 -0
  20. package/dist/chunks/{chunk-CTN4O42X.js → chunk-2EHPXO4E.js} +3 -3
  21. package/dist/chunks/{chunk-LS75R55C.js → chunk-2NI5NS5S.js} +3 -3
  22. package/dist/chunks/{chunk-RV5QY3IY.js → chunk-2U5M5IYH.js} +6 -6
  23. package/dist/chunks/{chunk-PWOG3OMH.js → chunk-2X6JZAKH.js} +9 -9
  24. package/dist/chunks/{chunk-W5QFVC74.js → chunk-2Y26DLOF.js} +27 -10
  25. package/dist/chunks/{chunk-W5QFVC74.js.map → chunk-2Y26DLOF.js.map} +1 -1
  26. package/dist/chunks/{chunk-BR6EWAKQ.js → chunk-3QGJXD7U.js} +5 -5
  27. package/dist/chunks/{chunk-XFNCCDJK.js → chunk-435DYOG4.js} +2 -2
  28. package/dist/chunks/{chunk-Y44FAVKA.js → chunk-4OXIJ2EF.js} +3 -3
  29. package/dist/chunks/{chunk-RSRJQB6Q.js → chunk-6EJFXJDO.js} +204 -68
  30. package/dist/chunks/chunk-6EJFXJDO.js.map +6 -0
  31. package/dist/chunks/{chunk-UC3ZACVN.js → chunk-6FWFSPUL.js} +2 -2
  32. package/dist/chunks/chunk-6HTC5TQ3.js +89 -0
  33. package/dist/chunks/chunk-6HTC5TQ3.js.map +6 -0
  34. package/dist/chunks/chunk-6IDFHPY3.js +413 -0
  35. package/dist/chunks/chunk-6IDFHPY3.js.map +6 -0
  36. package/dist/chunks/chunk-7FPKSX4M.js +61 -0
  37. package/dist/chunks/chunk-7FPKSX4M.js.map +6 -0
  38. package/dist/chunks/{chunk-EFEZWLZC.js → chunk-7QQOUCGI.js} +12 -10
  39. package/dist/chunks/chunk-7QQOUCGI.js.map +6 -0
  40. package/dist/chunks/{chunk-KHM2XON5.js → chunk-7TEXDZVO.js} +17 -3
  41. package/dist/chunks/chunk-7TEXDZVO.js.map +6 -0
  42. package/dist/chunks/{chunk-WPNT6IGU.js → chunk-A5GTZ7R2.js} +2 -2
  43. package/dist/chunks/{chunk-BIGRB2H4.js → chunk-ACSG5R5P.js} +3 -3
  44. package/dist/chunks/{chunk-QV43JSBP.js → chunk-AI6PBE5G.js} +2 -2
  45. package/dist/chunks/{chunk-HXZ2JXCO.js → chunk-AX5ESG6K.js} +2 -2
  46. package/dist/chunks/{chunk-DESOZLEL.js → chunk-B3XIVOLM.js} +2 -2
  47. package/dist/chunks/{chunk-ZXKN4TWP.js → chunk-BGKQCLLH.js} +242 -447
  48. package/dist/chunks/chunk-BGKQCLLH.js.map +6 -0
  49. package/dist/chunks/chunk-BT7ZELXJ.js +63 -0
  50. package/dist/chunks/chunk-BT7ZELXJ.js.map +6 -0
  51. package/dist/chunks/{chunk-ZUN2WRCB.js → chunk-DECJPLLA.js} +13 -13
  52. package/dist/chunks/{chunk-GSYPRZZU.js → chunk-DFCJYRT5.js} +2 -2
  53. package/dist/chunks/{chunk-QNTR7X7D.js → chunk-DQLSLXDF.js} +5 -5
  54. package/dist/chunks/chunk-EXFSMYH4.js +83 -0
  55. package/dist/chunks/chunk-EXFSMYH4.js.map +6 -0
  56. package/dist/chunks/{chunk-6Z2ZJ4BA.js → chunk-FHQTXWDA.js} +4 -4
  57. package/dist/chunks/chunk-G73G2WGR.js +242 -0
  58. package/dist/chunks/chunk-G73G2WGR.js.map +6 -0
  59. package/dist/chunks/{chunk-BLM6IQS4.js → chunk-GANFMGV7.js} +5 -5
  60. package/dist/chunks/{chunk-REDD2WY7.js → chunk-GBS6ATYF.js} +2 -2
  61. package/dist/chunks/{chunk-ORVWGSLG.js → chunk-GCCFTP47.js} +4 -4
  62. package/dist/chunks/{chunk-FKIO77IY.js → chunk-GNEDN6MU.js} +12 -12
  63. package/dist/chunks/{chunk-NS7EU37U.js → chunk-HB5ZN5KQ.js} +2 -2
  64. package/dist/chunks/{chunk-EFQ6FUFZ.js → chunk-HELINLSD.js} +2 -2
  65. package/dist/chunks/{chunk-AY7B43MK.js → chunk-HKCIZR5P.js} +13 -13
  66. package/dist/chunks/chunk-HRJPVPSU.js +164 -0
  67. package/dist/chunks/chunk-HRJPVPSU.js.map +6 -0
  68. package/dist/chunks/{chunk-NPZY5OJ5.js → chunk-HTBMDD6Y.js} +8 -8
  69. package/dist/chunks/{chunk-LN26A356.js → chunk-I5E4MT3C.js} +4 -4
  70. package/dist/chunks/{chunk-KK2L4FD2.js → chunk-IJZ7SLBV.js} +3 -3
  71. package/dist/chunks/{chunk-YAEHAYI4.js → chunk-ITA57VY5.js} +7 -5
  72. package/dist/chunks/chunk-ITA57VY5.js.map +6 -0
  73. package/dist/chunks/{chunk-W4E2N7TY.js → chunk-IZVN6K6U.js} +4 -4
  74. package/dist/chunks/{chunk-7U36A4WQ.js → chunk-JL64XHSL.js} +55 -5
  75. package/dist/chunks/chunk-JL64XHSL.js.map +6 -0
  76. package/dist/chunks/chunk-KLKAK2O5.js +5817 -0
  77. package/dist/chunks/chunk-KLKAK2O5.js.map +6 -0
  78. package/dist/chunks/{chunk-465CVUN4.js → chunk-L2NNJ4XL.js} +3 -3
  79. package/dist/chunks/{chunk-JCUPTKQY.js → chunk-LF76CVOZ.js} +4 -4
  80. package/dist/chunks/{chunk-ZATO2QOS.js → chunk-LFPTXRMM.js} +2 -2
  81. package/dist/chunks/chunk-LG27EJU6.js +189 -0
  82. package/dist/chunks/chunk-LG27EJU6.js.map +6 -0
  83. package/dist/chunks/{chunk-UHPRMPWX.js → chunk-LKJBDF7W.js} +15 -3
  84. package/dist/chunks/chunk-LKJBDF7W.js.map +6 -0
  85. package/dist/chunks/chunk-LKODRKMZ.js +575 -0
  86. package/dist/chunks/chunk-LKODRKMZ.js.map +6 -0
  87. package/dist/chunks/{chunk-WLUGKIYQ.js → chunk-LQRP2VRQ.js} +4 -4
  88. package/dist/chunks/{chunk-UGAT33T5.js → chunk-LYGD5P7O.js} +3 -3
  89. package/dist/chunks/{chunk-CRWNJ62V.js → chunk-M2OZ4SVS.js} +3 -3
  90. package/dist/chunks/{chunk-I32JTWDW.js → chunk-MGZSEPDY.js} +2 -2
  91. package/dist/chunks/{chunk-HYFX32Y3.js → chunk-MJBGVVI5.js} +3 -3
  92. package/dist/chunks/{chunk-YPRKTJ5P.js → chunk-MYL75RA4.js} +2 -2
  93. package/dist/chunks/chunk-PIVHVYCN.js +3925 -0
  94. package/dist/chunks/chunk-PIVHVYCN.js.map +6 -0
  95. package/dist/chunks/{chunk-AE4LOPZF.js → chunk-PMX2WTZL.js} +2 -2
  96. package/dist/chunks/{chunk-FPLDTTM2.js → chunk-QWSZ5P4C.js} +6 -6
  97. package/dist/chunks/{chunk-T5POXPXY.js → chunk-RSIWTHYS.js} +3 -3
  98. package/dist/chunks/{chunk-UP3SWACV.js → chunk-S4QOQGAT.js} +2 -2
  99. package/dist/chunks/chunk-S7WRWA25.js +33 -0
  100. package/dist/chunks/chunk-S7WRWA25.js.map +6 -0
  101. package/dist/chunks/{chunk-ZRBGY4SL.js → chunk-SGRO4RJP.js} +2 -2
  102. package/dist/chunks/{chunk-WKUTR7YW.js → chunk-SJFPZPOJ.js} +80 -17
  103. package/dist/chunks/chunk-SJFPZPOJ.js.map +6 -0
  104. package/dist/chunks/{chunk-JAYPFJGZ.js → chunk-TZZOQ62Z.js} +2 -2
  105. package/dist/chunks/chunk-U4SST7AD.js +219 -0
  106. package/dist/chunks/chunk-U4SST7AD.js.map +6 -0
  107. package/dist/chunks/{chunk-CMAZ3DYB.js → chunk-UGDZ7MLG.js} +4 -4
  108. package/dist/chunks/chunk-VDKDXDOH.js +290 -0
  109. package/dist/chunks/chunk-VDKDXDOH.js.map +6 -0
  110. package/dist/chunks/{chunk-2NFPIARP.js → chunk-VFVWHYHT.js} +4 -4
  111. package/dist/chunks/{chunk-5UB2LLPG.js → chunk-VZ4PKWLF.js} +2 -2
  112. package/dist/chunks/{chunk-WLAI3VCE.js → chunk-WKFHQQOU.js} +2 -2
  113. package/dist/chunks/{chunk-JSFF2HGX.js → chunk-WKPRYH24.js} +3 -3
  114. package/dist/chunks/{chunk-VR4MTSMH.js → chunk-WQFHJ4TO.js} +3 -3
  115. package/dist/chunks/{chunk-RFMODICJ.js → chunk-WYJ3CNXX.js} +80 -38
  116. package/dist/chunks/chunk-WYJ3CNXX.js.map +6 -0
  117. package/dist/chunks/{chunk-ZNYKZ3MI.js → chunk-XPLHAOGE.js} +2 -2
  118. package/dist/chunks/{chunk-2NGXQQPP.js → chunk-XX2SP5AM.js} +3 -3
  119. package/dist/chunks/{chunk-T2PF65KB.js → chunk-YDSWGJWF.js} +2 -2
  120. package/dist/chunks/{chunk-LUSUJZR2.js → chunk-YJ6NWB2B.js} +2 -2
  121. package/dist/chunks/{chunk-O4MFP726.js → chunk-YTE3QIH3.js} +998 -393
  122. package/dist/chunks/chunk-YTE3QIH3.js.map +6 -0
  123. package/dist/chunks/{chunk-JH3SDABI.js → chunk-YUYNIAJX.js} +6 -6
  124. package/dist/chunks/{chunk-TX2PUHTP.js → chunk-YXIG4OT2.js} +2 -2
  125. package/dist/chunks/{cli-runtime-HTTDQPEZ.js → cli-runtime-F4MEMBDL.js} +11 -10
  126. package/dist/chunks/cli-runtime-F4MEMBDL.js.map +6 -0
  127. package/dist/chunks/{commands-ZD2L5QMI.js → commands-ZCNZVYTG.js} +5 -5
  128. package/dist/chunks/{crash-report-2IRIZSBD.js → crash-report-K53VF4H5.js} +6 -6
  129. package/dist/chunks/{dist-GSYFGRQT.js → dist-6IPPA55L.js} +2 -2
  130. package/dist/chunks/{dist-45IFTDJW.js → dist-H53G25BE.js} +2 -2
  131. package/dist/chunks/{dist-RQJEJN3Z.js → dist-L5LBM77I.js} +2 -2
  132. package/dist/chunks/{dist-OJTB6QLR.js → dist-RIH2Q2ER.js} +2 -2
  133. package/dist/chunks/{dist-OCZJJFHF.js → dist-RTIKLSUV.js} +2 -2
  134. package/dist/chunks/{dist-TWYNAZDN.js → dist-T6KE7URX.js} +2 -2
  135. package/dist/chunks/{dist-FNGLTQIG.js → dist-VSJGDIXP.js} +32 -2
  136. package/dist/chunks/{dist-NL7WG7PX.js → dist-XNGK3C4G.js} +2 -2
  137. package/dist/chunks/{doctor-NKPCWPB4.js → doctor-DOCGTBME.js} +17 -15
  138. package/dist/chunks/{drain-YTSVAQP5.js → drain-LT3J2MEA.js} +13 -13
  139. package/dist/chunks/entry-UHKDLPDS.js +232 -0
  140. package/dist/chunks/entry-UHKDLPDS.js.map +6 -0
  141. package/dist/chunks/{eval-ILFXDQUQ.js → eval-DH26W2QK.js} +2 -2
  142. package/dist/chunks/{exec-3JDAB34N.js → exec-QGAHWUUQ.js} +57 -47
  143. package/dist/chunks/exec-QGAHWUUQ.js.map +6 -0
  144. package/dist/chunks/{github-FH7PPWVW.js → github-JTMZJAZL.js} +4 -4
  145. package/dist/chunks/{home-5OIZIDIT.js → home-GGVNSCCU.js} +3 -3
  146. package/dist/chunks/host-6CUYPX4T.js +23 -0
  147. package/dist/chunks/{host-queries-SO2NOQRR.js → host-queries-4EW7M54U.js} +16 -15
  148. package/dist/chunks/host-queries-4EW7M54U.js.map +6 -0
  149. package/dist/chunks/{learn-RHNMJ4BD.js → learn-PAO3IOYA.js} +13 -13
  150. package/dist/chunks/{learn-builtin-UQ3MWGK6.js → learn-builtin-DXZUXOGG.js} +19 -19
  151. package/dist/chunks/{lifecycle-RTDYXKBW.js → lifecycle-KDN4D7DP.js} +30 -26
  152. package/dist/chunks/{list-G6OA34RL.js → list-KSP6S57Z.js} +15 -14
  153. package/dist/chunks/list-KSP6S57Z.js.map +6 -0
  154. package/dist/chunks/{live-44HBQCQY.js → live-XWJ2JOFO.js} +15 -13
  155. package/dist/chunks/{login-J4PWR4FM.js → login-3Q2HKQUW.js} +10 -8
  156. package/dist/chunks/{logs-22QAEH2Q.js → logs-UYB55HOX.js} +4 -4
  157. package/dist/chunks/{mcp-EXFVIHPJ.js → mcp-JWSI4KA6.js} +25 -22
  158. package/dist/chunks/mcp-JWSI4KA6.js.map +6 -0
  159. package/dist/chunks/{message-command-B4L2W4YZ.js → message-command-YP6TGD3K.js} +47 -42
  160. package/dist/chunks/message-command-YP6TGD3K.js.map +6 -0
  161. package/dist/chunks/open-QUDHJK5H.js +19 -0
  162. package/dist/chunks/{operator-tools-TEP4UTI6.js → operator-tools-43NL7HKO.js} +15 -14
  163. package/dist/chunks/operator-tools-43NL7HKO.js.map +6 -0
  164. package/dist/chunks/{output-schema-FZXJ7V33.js → output-schema-TLW5FA37.js} +3 -3
  165. package/dist/chunks/{pal-BUDEBIBJ.js → pal-EZE2KLYZ.js} +16 -14
  166. package/dist/chunks/pal-EZE2KLYZ.js.map +6 -0
  167. package/dist/chunks/palette-WDPS7W6Q.js +15 -0
  168. package/dist/chunks/peers-OBENILN2.js +18 -0
  169. package/dist/chunks/prefix-MLAG4KTK.js +14 -0
  170. package/dist/chunks/{providers-EQ32NZAT.js → providers-PJIHLTXP.js} +22 -18
  171. package/dist/chunks/pty-HDEXCPR6.js +29 -0
  172. package/dist/chunks/{resident-FSUGNG56.js → resident-2GHB3BKR.js} +32 -30
  173. package/dist/chunks/resident-2GHB3BKR.js.map +6 -0
  174. package/dist/chunks/resume-FHPY2RU3.js +24 -0
  175. package/dist/chunks/resume-FHPY2RU3.js.map +6 -0
  176. package/dist/chunks/{resume-command-DHPXCZVL.js → resume-command-VB6VA64L.js} +4 -4
  177. package/dist/chunks/resume-command-VB6VA64L.js.map +6 -0
  178. package/dist/chunks/{schedule-OJMZEWJG.js → schedule-42N4JOQJ.js} +8 -8
  179. package/dist/chunks/{service-EP2QHCK7.js → service-6WGZKKI4.js} +33 -29
  180. package/dist/chunks/service-6WGZKKI4.js.map +6 -0
  181. package/dist/chunks/{session-step-44XBOUDV.js → session-step-SBWIM4MZ.js} +15 -15
  182. package/dist/chunks/session-step-SBWIM4MZ.js.map +6 -0
  183. package/dist/chunks/{skills-YHAQXVP2.js → skills-V3VDOL3D.js} +11 -11
  184. package/dist/chunks/spaces-6II4JYTZ.js +231 -0
  185. package/dist/chunks/spaces-6II4JYTZ.js.map +6 -0
  186. package/dist/chunks/{start-check-KVZFDBD3.js → start-check-MRSPS5JT.js} +2 -2
  187. package/dist/chunks/start-check-MRSPS5JT.js.map +6 -0
  188. package/dist/chunks/{state-NXFKMBOX.js → state-HX3XRNPC.js} +2 -2
  189. package/dist/chunks/store-7P462EUD.js +17 -0
  190. package/dist/chunks/store-7P462EUD.js.map +6 -0
  191. package/dist/chunks/{store-KFJWAELA.js → store-FUQE7EWU.js} +13 -10
  192. package/dist/chunks/store-FUQE7EWU.js.map +6 -0
  193. package/dist/chunks/{store-QNY242NN.js → store-IX6KNJA4.js} +6 -6
  194. package/dist/chunks/store-IX6KNJA4.js.map +6 -0
  195. package/dist/chunks/{store-JLTSSGKL.js → store-MQXI7G2H.js} +4 -4
  196. package/dist/chunks/store-MQXI7G2H.js.map +6 -0
  197. package/dist/chunks/{tui-L5GKR237.js → tui-PH5B6UCO.js} +1822 -816
  198. package/dist/chunks/tui-PH5B6UCO.js.map +6 -0
  199. package/dist/chunks/{upgrade-PROVWX55.js → upgrade-HDW5MWLE.js} +6 -6
  200. package/dist/chunks/{worktree-ELHDXX4X.js → worktree-MLFYZF56.js} +13 -12
  201. package/dist/chunks/worktree-MLFYZF56.js.map +6 -0
  202. package/dist/cli.d.ts.map +1 -1
  203. package/dist/commands/exec-json.d.ts.map +1 -1
  204. package/dist/commands/manifest.d.ts +1 -0
  205. package/dist/commands/manifest.d.ts.map +1 -1
  206. package/dist/commands/spaces.d.ts +42 -0
  207. package/dist/commands/spaces.d.ts.map +1 -0
  208. package/dist/config/load.d.ts.map +1 -1
  209. package/dist/config/schema.d.ts +7 -0
  210. package/dist/config/schema.d.ts.map +1 -1
  211. package/dist/doctor/checks/index.d.ts +2 -1
  212. package/dist/doctor/checks/index.d.ts.map +1 -1
  213. package/dist/doctor/checks/terminal.d.ts +12 -0
  214. package/dist/doctor/checks/terminal.d.ts.map +1 -0
  215. package/dist/index.js +22 -19
  216. package/dist/integrations/accounts/activity.d.ts +39 -0
  217. package/dist/integrations/accounts/activity.d.ts.map +1 -0
  218. package/dist/integrations/accounts/binding.d.ts +30 -0
  219. package/dist/integrations/accounts/binding.d.ts.map +1 -0
  220. package/dist/integrations/accounts/codex-login.d.ts +33 -0
  221. package/dist/integrations/accounts/codex-login.d.ts.map +1 -0
  222. package/dist/integrations/accounts/host-facts.d.ts +22 -0
  223. package/dist/integrations/accounts/host-facts.d.ts.map +1 -0
  224. package/dist/integrations/accounts/open.d.ts +23 -0
  225. package/dist/integrations/accounts/open.d.ts.map +1 -0
  226. package/dist/integrations/accounts/rows.d.ts +45 -0
  227. package/dist/integrations/accounts/rows.d.ts.map +1 -0
  228. package/dist/integrations/peers/runtime.d.ts +12 -0
  229. package/dist/integrations/peers/runtime.d.ts.map +1 -1
  230. package/dist/integrations/providers/codex-account.d.ts +30 -0
  231. package/dist/integrations/providers/codex-account.d.ts.map +1 -0
  232. package/dist/integrations/providers/codex-oauth.d.ts +12 -0
  233. package/dist/integrations/providers/codex-oauth.d.ts.map +1 -1
  234. package/dist/integrations/providers/preferences.d.ts +8 -0
  235. package/dist/integrations/providers/preferences.d.ts.map +1 -1
  236. package/dist/integrations/resident/runner-worker.js +24 -23
  237. package/dist/integrations/resident/runner-worker.js.map +1 -1
  238. package/dist/integrations/sessions/store.d.ts +13 -1
  239. package/dist/integrations/sessions/store.d.ts.map +1 -1
  240. package/dist/spaces/git.d.ts +27 -0
  241. package/dist/spaces/git.d.ts.map +1 -0
  242. package/dist/spaces/goto.d.ts +31 -0
  243. package/dist/spaces/goto.d.ts.map +1 -0
  244. package/dist/spaces/host.d.ts +380 -0
  245. package/dist/spaces/host.d.ts.map +1 -0
  246. package/dist/spaces/input.d.ts +87 -0
  247. package/dist/spaces/input.d.ts.map +1 -0
  248. package/dist/spaces/keymap.d.ts +30 -0
  249. package/dist/spaces/keymap.d.ts.map +1 -0
  250. package/dist/spaces/layout.d.ts +34 -0
  251. package/dist/spaces/layout.d.ts.map +1 -0
  252. package/dist/spaces/overlay.d.ts +105 -0
  253. package/dist/spaces/overlay.d.ts.map +1 -0
  254. package/dist/spaces/palette.d.ts +35 -0
  255. package/dist/spaces/palette.d.ts.map +1 -0
  256. package/dist/spaces/peers.d.ts +19 -0
  257. package/dist/spaces/peers.d.ts.map +1 -0
  258. package/dist/spaces/prefix.d.ts +19 -0
  259. package/dist/spaces/prefix.d.ts.map +1 -0
  260. package/dist/spaces/roster.d.ts +111 -0
  261. package/dist/spaces/roster.d.ts.map +1 -0
  262. package/dist/spaces/session.d.ts +83 -0
  263. package/dist/spaces/session.d.ts.map +1 -0
  264. package/dist/spaces/sidebar.d.ts +99 -0
  265. package/dist/spaces/sidebar.d.ts.map +1 -0
  266. package/dist/spaces/signal.d.ts +28 -0
  267. package/dist/spaces/signal.d.ts.map +1 -0
  268. package/dist/spaces/status.d.ts +20 -0
  269. package/dist/spaces/status.d.ts.map +1 -0
  270. package/dist/spaces/store.d.ts +69 -0
  271. package/dist/spaces/store.d.ts.map +1 -0
  272. package/dist/spaces/tabbar.d.ts +36 -0
  273. package/dist/spaces/tabbar.d.ts.map +1 -0
  274. package/dist/spaces/tiling.d.ts +90 -0
  275. package/dist/spaces/tiling.d.ts.map +1 -0
  276. package/dist/terminal/host/cell.d.ts +35 -0
  277. package/dist/terminal/host/cell.d.ts.map +1 -0
  278. package/dist/terminal/host/frame.d.ts +64 -0
  279. package/dist/terminal/host/frame.d.ts.map +1 -0
  280. package/dist/terminal/host/index.d.ts +5 -0
  281. package/dist/terminal/host/index.d.ts.map +1 -0
  282. package/dist/terminal/host/writer.d.ts +21 -0
  283. package/dist/terminal/host/writer.d.ts.map +1 -0
  284. package/dist/terminal/host/xterm-source.d.ts +18 -0
  285. package/dist/terminal/host/xterm-source.d.ts.map +1 -0
  286. package/dist/terminal/pty.d.ts.map +1 -1
  287. package/dist/terminal/screen.d.ts +12 -0
  288. package/dist/terminal/screen.d.ts.map +1 -1
  289. package/dist/tui/App.d.ts +106 -1
  290. package/dist/tui/App.d.ts.map +1 -1
  291. package/dist/tui/Composer.d.ts +7 -1
  292. package/dist/tui/Composer.d.ts.map +1 -1
  293. package/dist/tui/ResumePicker.d.ts.map +1 -1
  294. package/dist/tui/TextPrompt.d.ts +5 -1
  295. package/dist/tui/TextPrompt.d.ts.map +1 -1
  296. package/dist/tui/account-flow.d.ts +126 -0
  297. package/dist/tui/account-flow.d.ts.map +1 -0
  298. package/dist/tui/agent.d.ts +17 -1
  299. package/dist/tui/agent.d.ts.map +1 -1
  300. package/dist/tui/compaction-rows.d.ts.map +1 -1
  301. package/dist/tui/context-usage.d.ts +14 -0
  302. package/dist/tui/context-usage.d.ts.map +1 -1
  303. package/dist/tui/index.d.ts.map +1 -1
  304. package/dist/tui/launch-settings.d.ts +5 -2
  305. package/dist/tui/launch-settings.d.ts.map +1 -1
  306. package/dist/tui/plain-interruption.d.ts +3 -1
  307. package/dist/tui/plain-interruption.d.ts.map +1 -1
  308. package/dist/tui/resume-picker-state.d.ts +7 -0
  309. package/dist/tui/resume-picker-state.d.ts.map +1 -1
  310. package/dist/tui/slashCommands.d.ts +11 -0
  311. package/dist/tui/slashCommands.d.ts.map +1 -1
  312. package/dist/tui/tidy-tool-output.d.ts +3 -1
  313. package/dist/tui/tidy-tool-output.d.ts.map +1 -1
  314. package/dist/tui/tool-end-rows.d.ts +2 -0
  315. package/dist/tui/tool-end-rows.d.ts.map +1 -1
  316. package/dist/tui/zoom/entry.d.ts +34 -0
  317. package/dist/tui/zoom/entry.d.ts.map +1 -0
  318. package/dist/tui/zoom/gesture.d.ts +51 -0
  319. package/dist/tui/zoom/gesture.d.ts.map +1 -0
  320. package/dist/tui/zoom/leave.d.ts +11 -0
  321. package/dist/tui/zoom/leave.d.ts.map +1 -0
  322. package/dist/tui/zoom/local.d.ts +55 -0
  323. package/dist/tui/zoom/local.d.ts.map +1 -0
  324. package/dist/tui/zoom/proxy.d.ts +40 -0
  325. package/dist/tui/zoom/proxy.d.ts.map +1 -0
  326. package/package.json +9 -8
  327. package/dist/chunks/acp-P3S54TTC.js +0 -13601
  328. package/dist/chunks/acp-P3S54TTC.js.map +0 -6
  329. package/dist/chunks/activity-command-Y5ZLCQ63.js.map +0 -6
  330. package/dist/chunks/add-F7M57FGR.js.map +0 -6
  331. package/dist/chunks/agent-session-CFWQHSYT.js +0 -60
  332. package/dist/chunks/archive-6NM6DYAT.js.map +0 -6
  333. package/dist/chunks/chat-KGVPXQS6.js.map +0 -6
  334. package/dist/chunks/chunk-43PPWWYD.js +0 -1415
  335. package/dist/chunks/chunk-43PPWWYD.js.map +0 -6
  336. package/dist/chunks/chunk-7U36A4WQ.js.map +0 -6
  337. package/dist/chunks/chunk-EFEZWLZC.js.map +0 -6
  338. package/dist/chunks/chunk-KHM2XON5.js.map +0 -6
  339. package/dist/chunks/chunk-O4MFP726.js.map +0 -6
  340. package/dist/chunks/chunk-RFMODICJ.js.map +0 -6
  341. package/dist/chunks/chunk-RSRJQB6Q.js.map +0 -6
  342. package/dist/chunks/chunk-UHPRMPWX.js.map +0 -6
  343. package/dist/chunks/chunk-WKUTR7YW.js.map +0 -6
  344. package/dist/chunks/chunk-YAEHAYI4.js.map +0 -6
  345. package/dist/chunks/chunk-ZXKN4TWP.js.map +0 -6
  346. package/dist/chunks/cli-runtime-HTTDQPEZ.js.map +0 -6
  347. package/dist/chunks/exec-3JDAB34N.js.map +0 -6
  348. package/dist/chunks/host-queries-SO2NOQRR.js.map +0 -6
  349. package/dist/chunks/list-G6OA34RL.js.map +0 -6
  350. package/dist/chunks/mcp-EXFVIHPJ.js.map +0 -6
  351. package/dist/chunks/message-command-B4L2W4YZ.js.map +0 -6
  352. package/dist/chunks/operator-tools-TEP4UTI6.js.map +0 -6
  353. package/dist/chunks/pal-BUDEBIBJ.js.map +0 -6
  354. package/dist/chunks/resident-FSUGNG56.js.map +0 -6
  355. package/dist/chunks/resume-VXHGE5GC.js +0 -23
  356. package/dist/chunks/service-EP2QHCK7.js.map +0 -6
  357. package/dist/chunks/tui-L5GKR237.js.map +0 -6
  358. package/dist/chunks/worktree-ELHDXX4X.js.map +0 -6
  359. /package/dist/chunks/{agent-AFX2UZU5.js.map → agent-YPEXUYPH.js.map} +0 -0
  360. /package/dist/chunks/{agent-session-CFWQHSYT.js.map → agent-session-EZB2OYG3.js.map} +0 -0
  361. /package/dist/chunks/{bin-main-I6CHRYYQ.js.map → bin-main-PMB57AZJ.js.map} +0 -0
  362. /package/dist/chunks/{commands-ZD2L5QMI.js.map → binding-K6RIQ5AP.js.map} +0 -0
  363. /package/dist/chunks/{browser-OPMOTWTV.js.map → browser-SKTIAVBF.js.map} +0 -0
  364. /package/dist/chunks/{chunk-CTN4O42X.js.map → chunk-2EHPXO4E.js.map} +0 -0
  365. /package/dist/chunks/{chunk-LS75R55C.js.map → chunk-2NI5NS5S.js.map} +0 -0
  366. /package/dist/chunks/{chunk-RV5QY3IY.js.map → chunk-2U5M5IYH.js.map} +0 -0
  367. /package/dist/chunks/{chunk-PWOG3OMH.js.map → chunk-2X6JZAKH.js.map} +0 -0
  368. /package/dist/chunks/{chunk-BR6EWAKQ.js.map → chunk-3QGJXD7U.js.map} +0 -0
  369. /package/dist/chunks/{chunk-XFNCCDJK.js.map → chunk-435DYOG4.js.map} +0 -0
  370. /package/dist/chunks/{chunk-Y44FAVKA.js.map → chunk-4OXIJ2EF.js.map} +0 -0
  371. /package/dist/chunks/{chunk-UC3ZACVN.js.map → chunk-6FWFSPUL.js.map} +0 -0
  372. /package/dist/chunks/{chunk-WPNT6IGU.js.map → chunk-A5GTZ7R2.js.map} +0 -0
  373. /package/dist/chunks/{chunk-BIGRB2H4.js.map → chunk-ACSG5R5P.js.map} +0 -0
  374. /package/dist/chunks/{chunk-QV43JSBP.js.map → chunk-AI6PBE5G.js.map} +0 -0
  375. /package/dist/chunks/{chunk-HXZ2JXCO.js.map → chunk-AX5ESG6K.js.map} +0 -0
  376. /package/dist/chunks/{chunk-DESOZLEL.js.map → chunk-B3XIVOLM.js.map} +0 -0
  377. /package/dist/chunks/{chunk-ZUN2WRCB.js.map → chunk-DECJPLLA.js.map} +0 -0
  378. /package/dist/chunks/{chunk-GSYPRZZU.js.map → chunk-DFCJYRT5.js.map} +0 -0
  379. /package/dist/chunks/{chunk-QNTR7X7D.js.map → chunk-DQLSLXDF.js.map} +0 -0
  380. /package/dist/chunks/{chunk-6Z2ZJ4BA.js.map → chunk-FHQTXWDA.js.map} +0 -0
  381. /package/dist/chunks/{chunk-BLM6IQS4.js.map → chunk-GANFMGV7.js.map} +0 -0
  382. /package/dist/chunks/{chunk-REDD2WY7.js.map → chunk-GBS6ATYF.js.map} +0 -0
  383. /package/dist/chunks/{chunk-ORVWGSLG.js.map → chunk-GCCFTP47.js.map} +0 -0
  384. /package/dist/chunks/{chunk-FKIO77IY.js.map → chunk-GNEDN6MU.js.map} +0 -0
  385. /package/dist/chunks/{chunk-NS7EU37U.js.map → chunk-HB5ZN5KQ.js.map} +0 -0
  386. /package/dist/chunks/{chunk-EFQ6FUFZ.js.map → chunk-HELINLSD.js.map} +0 -0
  387. /package/dist/chunks/{chunk-AY7B43MK.js.map → chunk-HKCIZR5P.js.map} +0 -0
  388. /package/dist/chunks/{chunk-NPZY5OJ5.js.map → chunk-HTBMDD6Y.js.map} +0 -0
  389. /package/dist/chunks/{chunk-LN26A356.js.map → chunk-I5E4MT3C.js.map} +0 -0
  390. /package/dist/chunks/{chunk-KK2L4FD2.js.map → chunk-IJZ7SLBV.js.map} +0 -0
  391. /package/dist/chunks/{chunk-W4E2N7TY.js.map → chunk-IZVN6K6U.js.map} +0 -0
  392. /package/dist/chunks/{chunk-465CVUN4.js.map → chunk-L2NNJ4XL.js.map} +0 -0
  393. /package/dist/chunks/{chunk-JCUPTKQY.js.map → chunk-LF76CVOZ.js.map} +0 -0
  394. /package/dist/chunks/{chunk-ZATO2QOS.js.map → chunk-LFPTXRMM.js.map} +0 -0
  395. /package/dist/chunks/{chunk-WLUGKIYQ.js.map → chunk-LQRP2VRQ.js.map} +0 -0
  396. /package/dist/chunks/{chunk-UGAT33T5.js.map → chunk-LYGD5P7O.js.map} +0 -0
  397. /package/dist/chunks/{chunk-CRWNJ62V.js.map → chunk-M2OZ4SVS.js.map} +0 -0
  398. /package/dist/chunks/{chunk-I32JTWDW.js.map → chunk-MGZSEPDY.js.map} +0 -0
  399. /package/dist/chunks/{chunk-HYFX32Y3.js.map → chunk-MJBGVVI5.js.map} +0 -0
  400. /package/dist/chunks/{chunk-YPRKTJ5P.js.map → chunk-MYL75RA4.js.map} +0 -0
  401. /package/dist/chunks/{chunk-AE4LOPZF.js.map → chunk-PMX2WTZL.js.map} +0 -0
  402. /package/dist/chunks/{chunk-FPLDTTM2.js.map → chunk-QWSZ5P4C.js.map} +0 -0
  403. /package/dist/chunks/{chunk-T5POXPXY.js.map → chunk-RSIWTHYS.js.map} +0 -0
  404. /package/dist/chunks/{chunk-UP3SWACV.js.map → chunk-S4QOQGAT.js.map} +0 -0
  405. /package/dist/chunks/{chunk-ZRBGY4SL.js.map → chunk-SGRO4RJP.js.map} +0 -0
  406. /package/dist/chunks/{chunk-JAYPFJGZ.js.map → chunk-TZZOQ62Z.js.map} +0 -0
  407. /package/dist/chunks/{chunk-CMAZ3DYB.js.map → chunk-UGDZ7MLG.js.map} +0 -0
  408. /package/dist/chunks/{chunk-2NFPIARP.js.map → chunk-VFVWHYHT.js.map} +0 -0
  409. /package/dist/chunks/{chunk-5UB2LLPG.js.map → chunk-VZ4PKWLF.js.map} +0 -0
  410. /package/dist/chunks/{chunk-WLAI3VCE.js.map → chunk-WKFHQQOU.js.map} +0 -0
  411. /package/dist/chunks/{chunk-JSFF2HGX.js.map → chunk-WKPRYH24.js.map} +0 -0
  412. /package/dist/chunks/{chunk-VR4MTSMH.js.map → chunk-WQFHJ4TO.js.map} +0 -0
  413. /package/dist/chunks/{chunk-ZNYKZ3MI.js.map → chunk-XPLHAOGE.js.map} +0 -0
  414. /package/dist/chunks/{chunk-2NGXQQPP.js.map → chunk-XX2SP5AM.js.map} +0 -0
  415. /package/dist/chunks/{chunk-T2PF65KB.js.map → chunk-YDSWGJWF.js.map} +0 -0
  416. /package/dist/chunks/{chunk-LUSUJZR2.js.map → chunk-YJ6NWB2B.js.map} +0 -0
  417. /package/dist/chunks/{chunk-JH3SDABI.js.map → chunk-YUYNIAJX.js.map} +0 -0
  418. /package/dist/chunks/{chunk-TX2PUHTP.js.map → chunk-YXIG4OT2.js.map} +0 -0
  419. /package/dist/chunks/{crash-report-2IRIZSBD.js.map → commands-ZCNZVYTG.js.map} +0 -0
  420. /package/dist/chunks/{dist-FNGLTQIG.js.map → crash-report-K53VF4H5.js.map} +0 -0
  421. /package/dist/chunks/{dist-GSYFGRQT.js.map → dist-6IPPA55L.js.map} +0 -0
  422. /package/dist/chunks/{dist-45IFTDJW.js.map → dist-H53G25BE.js.map} +0 -0
  423. /package/dist/chunks/{dist-RQJEJN3Z.js.map → dist-L5LBM77I.js.map} +0 -0
  424. /package/dist/chunks/{dist-OJTB6QLR.js.map → dist-RIH2Q2ER.js.map} +0 -0
  425. /package/dist/chunks/{dist-OCZJJFHF.js.map → dist-RTIKLSUV.js.map} +0 -0
  426. /package/dist/chunks/{dist-TWYNAZDN.js.map → dist-T6KE7URX.js.map} +0 -0
  427. /package/dist/chunks/{doctor-NKPCWPB4.js.map → dist-VSJGDIXP.js.map} +0 -0
  428. /package/dist/chunks/{dist-NL7WG7PX.js.map → dist-XNGK3C4G.js.map} +0 -0
  429. /package/dist/chunks/{home-5OIZIDIT.js.map → doctor-DOCGTBME.js.map} +0 -0
  430. /package/dist/chunks/{drain-YTSVAQP5.js.map → drain-LT3J2MEA.js.map} +0 -0
  431. /package/dist/chunks/{eval-ILFXDQUQ.js.map → eval-DH26W2QK.js.map} +0 -0
  432. /package/dist/chunks/{github-FH7PPWVW.js.map → github-JTMZJAZL.js.map} +0 -0
  433. /package/dist/chunks/{lifecycle-RTDYXKBW.js.map → home-GGVNSCCU.js.map} +0 -0
  434. /package/dist/chunks/{live-44HBQCQY.js.map → host-6CUYPX4T.js.map} +0 -0
  435. /package/dist/chunks/{learn-RHNMJ4BD.js.map → learn-PAO3IOYA.js.map} +0 -0
  436. /package/dist/chunks/{learn-builtin-UQ3MWGK6.js.map → learn-builtin-DXZUXOGG.js.map} +0 -0
  437. /package/dist/chunks/{login-J4PWR4FM.js.map → lifecycle-KDN4D7DP.js.map} +0 -0
  438. /package/dist/chunks/{output-schema-FZXJ7V33.js.map → live-XWJ2JOFO.js.map} +0 -0
  439. /package/dist/chunks/{providers-EQ32NZAT.js.map → login-3Q2HKQUW.js.map} +0 -0
  440. /package/dist/chunks/{logs-22QAEH2Q.js.map → logs-UYB55HOX.js.map} +0 -0
  441. /package/dist/chunks/{resume-VXHGE5GC.js.map → open-QUDHJK5H.js.map} +0 -0
  442. /package/dist/chunks/{resume-command-DHPXCZVL.js.map → output-schema-TLW5FA37.js.map} +0 -0
  443. /package/dist/chunks/{session-step-44XBOUDV.js.map → palette-WDPS7W6Q.js.map} +0 -0
  444. /package/dist/chunks/{start-check-KVZFDBD3.js.map → peers-OBENILN2.js.map} +0 -0
  445. /package/dist/chunks/{store-JLTSSGKL.js.map → prefix-MLAG4KTK.js.map} +0 -0
  446. /package/dist/chunks/{store-KFJWAELA.js.map → providers-PJIHLTXP.js.map} +0 -0
  447. /package/dist/chunks/{store-QNY242NN.js.map → pty-HDEXCPR6.js.map} +0 -0
  448. /package/dist/chunks/{schedule-OJMZEWJG.js.map → schedule-42N4JOQJ.js.map} +0 -0
  449. /package/dist/chunks/{skills-YHAQXVP2.js.map → skills-V3VDOL3D.js.map} +0 -0
  450. /package/dist/chunks/{state-NXFKMBOX.js.map → state-HX3XRNPC.js.map} +0 -0
  451. /package/dist/chunks/{upgrade-PROVWX55.js.map → upgrade-HDW5MWLE.js.map} +0 -0
@@ -304,7 +304,7 @@ var require_brace_expansion = __commonJS({
304
304
  });
305
305
 
306
306
  // ../sdk/dist/version.js
307
- var VERSION = "58.1.1";
307
+ var VERSION = "59.0.0";
308
308
 
309
309
  // ../sdk/dist/runtime/harness-session/index.js
310
310
  import { posix, win32 } from "node:path";
@@ -5303,7 +5303,10 @@ var STRUCTURAL_CODES = {
5303
5303
  string_above_max_length: "context_length_exceeded",
5304
5304
  rate_limit_exceeded: "rate_limit",
5305
5305
  rate_limit_error: "rate_limit",
5306
- insufficient_quota: "rate_limit",
5306
+ insufficient_quota: "usage_limit",
5307
+ usage_limit_reached: "usage_limit",
5308
+ usage_limit_exceeded: "usage_limit",
5309
+ billing_error: "usage_limit",
5307
5310
  overloaded_error: "overloaded",
5308
5311
  content_filter: "content_filter",
5309
5312
  content_policy_violation: "content_filter",
@@ -5312,6 +5315,17 @@ var STRUCTURAL_CODES = {
5312
5315
  permission_error: "auth",
5313
5316
  model_not_found: "not_found"
5314
5317
  };
5318
+ var USAGE_LIMIT_DETAIL = [
5319
+ /credit balance is too low/i,
5320
+ /exceeded your current quota/i,
5321
+ /usage limit (?:has been )?(?:reached|exceeded)/i
5322
+ ];
5323
+ function isUsageLimitSignal(code, detail) {
5324
+ if (code !== void 0 && STRUCTURAL_CODES[code.toLowerCase()] === "usage_limit")
5325
+ return true;
5326
+ return detail !== void 0 && USAGE_LIMIT_DETAIL.some((re2) => re2.test(detail));
5327
+ }
5328
+ __name(isUsageLimitSignal, "isUsageLimitSignal");
5315
5329
  function codeFromStructure(err) {
5316
5330
  for (const link6 of causeChain(err)) {
5317
5331
  for (const field2 of [link6.code, link6.type, link6.error?.type]) {
@@ -5342,12 +5356,13 @@ function classifyFromProviderRequestError(err, providerId, now) {
5342
5356
  const mapped = KIND_TO_CODE[candidate.kind];
5343
5357
  if (!mapped)
5344
5358
  return void 0;
5359
+ const spent = (candidate.kind === "throttle" || candidate.kind === "bad_request") && isUsageLimitSignal(typeof candidate.providerCode === "string" ? candidate.providerCode : void 0, typeof candidate.detail === "string" ? candidate.detail : void 0);
5345
5360
  const retryAfterMs = typeof candidate.retryAfterMs === "number" ? candidate.retryAfterMs : readRetryAfterMs(err, now);
5346
5361
  return new ProviderError({
5347
- code: mapped.code,
5362
+ code: spent ? "usage_limit" : mapped.code,
5348
5363
  message: err.message,
5349
5364
  // The provider saying "do not resend" beats the kind's own verdict.
5350
- retryable: candidate.shouldRetry === false ? false : mapped.retryable,
5365
+ retryable: spent || candidate.shouldRetry === false ? false : mapped.retryable,
5351
5366
  cause: err,
5352
5367
  ...typeof candidate.providerId === "string" ? { providerId: candidate.providerId } : providerId !== void 0 ? { providerId } : {},
5353
5368
  ...typeof candidate.status === "number" ? { status: candidate.status } : {},
@@ -6030,10 +6045,10 @@ var ExternalHarnessSession = class {
6030
6045
  }
6031
6046
  }
6032
6047
  makeActive(turnId6, operationId, startedAt) {
6033
- let resolve32;
6048
+ let resolve33;
6034
6049
  let reject2;
6035
6050
  const done = new Promise((yes, no) => {
6036
- resolve32 = yes;
6051
+ resolve33 = yes;
6037
6052
  reject2 = no;
6038
6053
  });
6039
6054
  void done.catch(() => void 0);
@@ -6043,7 +6058,7 @@ var ExternalHarnessSession = class {
6043
6058
  startedAt,
6044
6059
  items: /* @__PURE__ */ new Map(),
6045
6060
  reviews: /* @__PURE__ */ new Map(),
6046
- resolve: resolve32,
6061
+ resolve: resolve33,
6047
6062
  reject: reject2,
6048
6063
  done
6049
6064
  };
@@ -6122,9 +6137,9 @@ var ExternalHarnessSession = class {
6122
6137
  permissionMode: input.permissionMode,
6123
6138
  ...input.effort ? { effort: input.effort } : {}
6124
6139
  });
6125
- const release = this.reserve();
6140
+ const release2 = this.reserve();
6126
6141
  if (!prompt.prompt || prompt.prompt.length > 1024 * 1024 || !prompt.model || prompt.model.length > 4096) {
6127
- release();
6142
+ release2();
6128
6143
  throw new HarnessSessionError("invalid-prompt", "A bounded prompt and explicit model are required.");
6129
6144
  }
6130
6145
  let active;
@@ -6194,7 +6209,7 @@ var ExternalHarnessSession = class {
6194
6209
  signal.addEventListener("abort", abort, { once: true });
6195
6210
  active.removeAbort = () => signal.removeEventListener("abort", abort);
6196
6211
  }
6197
- release();
6212
+ release2();
6198
6213
  dispatchInvoked = true;
6199
6214
  const nativeTurn2 = harnessSnapshot(HarnessNativeTurnSchema.parse(await connection.dispatch({ ...prompt, operationId, ...signal ? { signal } : {} })));
6200
6215
  await this.events;
@@ -6214,7 +6229,7 @@ var ExternalHarnessSession = class {
6214
6229
  }
6215
6230
  throw error;
6216
6231
  } finally {
6217
- release();
6232
+ release2();
6218
6233
  }
6219
6234
  }
6220
6235
  async failBeforeDispatch(active) {
@@ -6565,7 +6580,7 @@ var ExternalHarnessSession = class {
6565
6580
  async respond(input, value) {
6566
6581
  const request = harnessSnapshot(HarnessReviewRequestSchema.parse(input));
6567
6582
  const decision2 = harnessSnapshot(HarnessDecisionSchema.parse(value));
6568
- const release = this.reserve();
6583
+ const release2 = this.reserve();
6569
6584
  let reserved = false;
6570
6585
  try {
6571
6586
  const active = this.active;
@@ -6599,7 +6614,7 @@ var ExternalHarnessSession = class {
6599
6614
  await this.uncertain("decision-unconfirmed", error);
6600
6615
  throw error;
6601
6616
  } finally {
6602
- release();
6617
+ release2();
6603
6618
  }
6604
6619
  }
6605
6620
  async cancel(expectedTurnId) {
@@ -6635,7 +6650,7 @@ var ExternalHarnessSession = class {
6635
6650
  }
6636
6651
  }
6637
6652
  async reconnect(signal) {
6638
- const release = this.reserve();
6653
+ const release2 = this.reserve();
6639
6654
  try {
6640
6655
  if (this.active && this.phase !== "reconciliation-required")
6641
6656
  throw new HarnessSessionError("busy", "A native turn is still running.");
@@ -6656,7 +6671,7 @@ var ExternalHarnessSession = class {
6656
6671
  const snapshot = harnessSnapshot(await this.requireConnection().readHistory(signal));
6657
6672
  await this.reconcile(snapshot);
6658
6673
  } finally {
6659
- release();
6674
+ release2();
6660
6675
  }
6661
6676
  }
6662
6677
  async reconcile(snapshot) {
@@ -6704,7 +6719,7 @@ var ExternalHarnessSession = class {
6704
6719
  async close() {
6705
6720
  if (this.phase === "closed")
6706
6721
  return;
6707
- const release = this.reserve();
6722
+ const release2 = this.reserve();
6708
6723
  try {
6709
6724
  if (this.connection) {
6710
6725
  await this.connection.close();
@@ -6731,7 +6746,7 @@ var ExternalHarnessSession = class {
6731
6746
  await this.journal.release();
6732
6747
  this.phase = "closed";
6733
6748
  } finally {
6734
- release();
6749
+ release2();
6735
6750
  }
6736
6751
  }
6737
6752
  };
@@ -6822,8 +6837,8 @@ function windowsEnv(env, name2) {
6822
6837
  }
6823
6838
  __name(windowsEnv, "windowsEnv");
6824
6839
  function insideDirectory(path3, directory) {
6825
- const relative14 = win322.relative(directory, path3);
6826
- return relative14 === "" || !relative14.startsWith("..") && !win322.isAbsolute(relative14);
6840
+ const relative15 = win322.relative(directory, path3);
6841
+ return relative15 === "" || !relative15.startsWith("..") && !win322.isAbsolute(relative15);
6827
6842
  }
6828
6843
  __name(insideDirectory, "insideDirectory");
6829
6844
  function findGitBash(probe2) {
@@ -8112,13 +8127,13 @@ var GuardedFetchProvider = class {
8112
8127
  operation.throwIfStopped();
8113
8128
  return url;
8114
8129
  }
8115
- const resolve32 = this.config.resolve ?? (async (name2) => (await lookup(name2, { all: true })).map((r) => r.address));
8130
+ const resolve33 = this.config.resolve ?? (async (name2) => (await lookup(name2, { all: true })).map((r) => r.address));
8116
8131
  let addresses;
8117
8132
  if (isIP(hostname)) {
8118
8133
  addresses = [hostname];
8119
8134
  } else {
8120
8135
  try {
8121
- addresses = await operation.run(() => resolve32(hostname, operation.signal));
8136
+ addresses = await operation.run(() => resolve33(hostname, operation.signal));
8122
8137
  } catch (err) {
8123
8138
  operation.throwIfStopped();
8124
8139
  throw new WebFetchRefusedError(`Refused "${hostname}" \u2014 it could not be resolved (${err instanceof Error ? err.message : String(err)}), so nothing here can say where it points.`, { url: rawUrl, reason: "private-address" });
@@ -8464,9 +8479,9 @@ async function vetWebSocketTarget(raw, options = {}) {
8464
8479
  if (literal !== 0) {
8465
8480
  addresses = [hostname];
8466
8481
  } else {
8467
- const resolve32 = options.resolve ?? (async (name2) => (await dnsLookup(name2, { all: true })).map((r) => r.address));
8482
+ const resolve33 = options.resolve ?? (async (name2) => (await dnsLookup(name2, { all: true })).map((r) => r.address));
8468
8483
  try {
8469
- addresses = await resolve32(hostname);
8484
+ addresses = await resolve33(hostname);
8470
8485
  } catch (err) {
8471
8486
  throw new WebSocketRefusedError(`Refused "${hostname}": it could not be resolved (${err instanceof Error ? err.message : String(err)}), so nothing here can say where it points.`);
8472
8487
  }
@@ -8960,8 +8975,8 @@ var BackgroundJobRegistry = class {
8960
8975
  };
8961
8976
  let startError;
8962
8977
  let settleStarted;
8963
- const startedPromise = new Promise((resolve32) => {
8964
- settleStarted = /* @__PURE__ */ __name(() => resolve32(startError === void 0 ? {} : { error: startError }), "settleStarted");
8978
+ const startedPromise = new Promise((resolve33) => {
8979
+ settleStarted = /* @__PURE__ */ __name(() => resolve33(startError === void 0 ? {} : { error: startError }), "settleStarted");
8965
8980
  });
8966
8981
  if (params.spawn || child.pid !== void 0)
8967
8982
  settleStarted();
@@ -9007,7 +9022,7 @@ var BackgroundJobRegistry = class {
9007
9022
  outputChunks: [],
9008
9023
  outputObservers: /* @__PURE__ */ new Set(),
9009
9024
  started: startedPromise,
9010
- exit: new Promise((resolve32) => {
9025
+ exit: new Promise((resolve33) => {
9011
9026
  let spawned = child.pid !== void 0;
9012
9027
  let failedToSpawn = false;
9013
9028
  let finalized = false;
@@ -9025,7 +9040,7 @@ var BackgroundJobRegistry = class {
9025
9040
  ...code === null ? {} : { exitCode: code },
9026
9041
  ...signal ? { signal } : {}
9027
9042
  };
9028
- resolve32();
9043
+ resolve33();
9029
9044
  for (const observer of entry.outputObservers)
9030
9045
  observer();
9031
9046
  if (entry.monitor) {
@@ -9198,7 +9213,7 @@ var BackgroundJobRegistry = class {
9198
9213
  const signal = opts.signal;
9199
9214
  if (signal.aborted)
9200
9215
  return Promise.reject(signal.reason);
9201
- return new Promise((resolve32, reject2) => {
9216
+ return new Promise((resolve33, reject2) => {
9202
9217
  let disposeAbort = /* @__PURE__ */ __name(() => {
9203
9218
  }, "disposeAbort");
9204
9219
  const unsubscribe = this.onExit((job) => {
@@ -9206,7 +9221,7 @@ var BackgroundJobRegistry = class {
9206
9221
  return;
9207
9222
  unsubscribe();
9208
9223
  disposeAbort();
9209
- resolve32(job);
9224
+ resolve33(job);
9210
9225
  });
9211
9226
  disposeAbort = subscribeToAbort(signal, () => {
9212
9227
  unsubscribe();
@@ -9303,7 +9318,7 @@ var BackgroundJobRegistry = class {
9303
9318
  throw new BackgroundJobOutputWaitLimitError({ owner, limit: globalLimit, scope: "registry" });
9304
9319
  this.outputWaiters++;
9305
9320
  this.outputWaitersByOwner.set(owner, ownerCount + 1);
9306
- return new Promise((resolve32) => {
9321
+ return new Promise((resolve33) => {
9307
9322
  const startedAt = Date.now();
9308
9323
  let settled = false;
9309
9324
  let disposeAbort = /* @__PURE__ */ __name(() => {
@@ -9323,7 +9338,7 @@ var BackgroundJobRegistry = class {
9323
9338
  this.outputWaitersByOwner.delete(owner);
9324
9339
  else
9325
9340
  this.outputWaitersByOwner.set(owner, remaining);
9326
- resolve32(result);
9341
+ resolve33(result);
9327
9342
  }, "finish");
9328
9343
  const timeout = /* @__PURE__ */ __name((cause) => {
9329
9344
  read();
@@ -10092,7 +10107,7 @@ ${line}`;
10092
10107
  stdout: true,
10093
10108
  stderr: true
10094
10109
  });
10095
- return await new Promise((resolve32) => {
10110
+ return await new Promise((resolve33) => {
10096
10111
  let settled = false;
10097
10112
  let terminal;
10098
10113
  const inFlight = /* @__PURE__ */ new Set();
@@ -10107,7 +10122,7 @@ ${line}`;
10107
10122
  clearTimeout(deadline);
10108
10123
  options.signal?.removeEventListener("abort", onAbort);
10109
10124
  void worker.terminate();
10110
- resolve32({ ...result, calls: [...calls] });
10125
+ resolve33({ ...result, calls: [...calls] });
10111
10126
  }, "finish");
10112
10127
  const finishTerminalWhenHostCallsSettle = /* @__PURE__ */ __name(() => {
10113
10128
  if (terminal && inFlight.size === 0)
@@ -11207,7 +11222,7 @@ var WorkflowRuntime = class {
11207
11222
  ...agent.error !== void 0 ? { error: agent.error } : {},
11208
11223
  ...agent.skipped ? { skipped: true } : {}
11209
11224
  }), "agentEvent");
11210
- const acquire = /* @__PURE__ */ __name((agent) => {
11225
+ const acquire2 = /* @__PURE__ */ __name((agent) => {
11211
11226
  if (running < limits.maxConcurrency && waiters.length === 0) {
11212
11227
  running++;
11213
11228
  return Promise.resolve(true);
@@ -11216,7 +11231,7 @@ var WorkflowRuntime = class {
11216
11231
  waiters.push({ agent, admit });
11217
11232
  });
11218
11233
  }, "acquire");
11219
- const release = /* @__PURE__ */ __name(() => {
11234
+ const release2 = /* @__PURE__ */ __name(() => {
11220
11235
  running--;
11221
11236
  while (running < limits.maxConcurrency && waiters.length > 0) {
11222
11237
  const next2 = waiters.shift();
@@ -11378,7 +11393,7 @@ var WorkflowRuntime = class {
11378
11393
  schema: call2.schema !== void 0
11379
11394
  }
11380
11395
  });
11381
- const admitted = await acquire(agent);
11396
+ const admitted = await acquire2(agent);
11382
11397
  if (!admitted) {
11383
11398
  return agent.userSkipped ? settle2(agent, { state: "done", skipped: true }) : settle2(agent, {
11384
11399
  state: "error",
@@ -11439,7 +11454,7 @@ var WorkflowRuntime = class {
11439
11454
  }
11440
11455
  return interpret(agent, call2, outcome2);
11441
11456
  } finally {
11442
- release();
11457
+ release2();
11443
11458
  }
11444
11459
  }, "handleAgentCall");
11445
11460
  const onOutput = /* @__PURE__ */ __name((line) => {
@@ -11536,8 +11551,8 @@ ${body}`,
11536
11551
  let timer;
11537
11552
  await Promise.race([
11538
11553
  Promise.allSettled([...inFlight]),
11539
- new Promise((resolve32) => {
11540
- timer = setTimeout(resolve32, grace);
11554
+ new Promise((resolve33) => {
11555
+ timer = setTimeout(resolve33, grace);
11541
11556
  })
11542
11557
  ]);
11543
11558
  clearTimeout(timer);
@@ -13931,14 +13946,14 @@ var MCPReconnectSupervisor = class {
13931
13946
  });
13932
13947
  }
13933
13948
  wait(ms) {
13934
- return new Promise((resolve32) => {
13949
+ return new Promise((resolve33) => {
13935
13950
  const finish2 = /* @__PURE__ */ __name(() => {
13936
13951
  if (this.timer)
13937
13952
  clearTimeout(this.timer);
13938
13953
  this.timer = void 0;
13939
13954
  if (this.finishWait === finish2)
13940
13955
  this.finishWait = void 0;
13941
- resolve32();
13956
+ resolve33();
13942
13957
  }, "finish");
13943
13958
  this.finishWait = finish2;
13944
13959
  this.timer = setTimeout(finish2, ms);
@@ -14761,7 +14776,7 @@ async function renameWithRetry(from, to) {
14761
14776
  const code = err.code ?? "";
14762
14777
  if (!CONTENDED.has(code) || attempt >= RENAME_ATTEMPTS)
14763
14778
  throw err;
14764
- await new Promise((resolve32) => setTimeout(resolve32, attempt));
14779
+ await new Promise((resolve33) => setTimeout(resolve33, attempt));
14765
14780
  }
14766
14781
  }
14767
14782
  }
@@ -16250,6 +16265,20 @@ function providerCode(value) {
16250
16265
  return safeProviderCode(record3.code ?? nested);
16251
16266
  }
16252
16267
  __name(providerCode, "providerCode");
16268
+ function usageLimitTypeOf(error) {
16269
+ if (typeof error !== "object" || error === null)
16270
+ return void 0;
16271
+ const outer = error;
16272
+ const inner = typeof outer.error === "object" && outer.error !== null ? outer.error : void 0;
16273
+ const innermost = typeof inner?.error === "object" && inner.error !== null ? inner.error : void 0;
16274
+ for (const candidate of [outer.type, inner?.type, innermost?.type]) {
16275
+ if (typeof candidate === "string" && isUsageLimitSignal(candidate, void 0)) {
16276
+ return safeProviderCode(candidate);
16277
+ }
16278
+ }
16279
+ return void 0;
16280
+ }
16281
+ __name(usageLimitTypeOf, "usageLimitTypeOf");
16253
16282
  function vendorDetail(body) {
16254
16283
  if (body === void 0 || body === null)
16255
16284
  return void 0;
@@ -16491,7 +16520,7 @@ __name(structuredVendorDetail, "structuredVendorDetail");
16491
16520
  function providerVendorError(input) {
16492
16521
  const { error } = input;
16493
16522
  const status = vendorErrorStatus(error);
16494
- const exactProviderCode = providerCode(error);
16523
+ const exactProviderCode = providerCode(error) ?? usageLimitTypeOf(error);
16495
16524
  const name2 = error instanceof Error ? error.name : "";
16496
16525
  const message = error instanceof Error ? error.message : "";
16497
16526
  const transport = readTransportCause(error);
@@ -17028,11 +17057,11 @@ async function teardownSandbox(sandbox, timeoutMs) {
17028
17057
  return await operation;
17029
17058
  let timer;
17030
17059
  let timedOut;
17031
- const deadline = new Promise((resolve32) => {
17060
+ const deadline = new Promise((resolve33) => {
17032
17061
  timer = setTimeout(() => {
17033
17062
  timedOut = teardownTimeoutError(timeoutMs);
17034
17063
  controller.abort(timedOut);
17035
- resolve32({ kind: "timed_out", error: timedOut });
17064
+ resolve33({ kind: "timed_out", error: timedOut });
17036
17065
  }, timeoutMs);
17037
17066
  });
17038
17067
  try {
@@ -17060,20 +17089,20 @@ async function acquireSandbox(options) {
17060
17089
  let timeoutError3;
17061
17090
  let timer;
17062
17091
  let onAbort;
17063
- const aborted = new Promise((resolve32) => {
17092
+ const aborted = new Promise((resolve33) => {
17064
17093
  onAbort = /* @__PURE__ */ __name(() => {
17065
17094
  operationController.abort(runSignal.reason);
17066
- resolve32({ kind: "cancelled" });
17095
+ resolve33({ kind: "cancelled" });
17067
17096
  }, "onAbort");
17068
17097
  runSignal.addEventListener("abort", onAbort, { once: true });
17069
17098
  });
17070
- const timedOut = new Promise((resolve32) => {
17099
+ const timedOut = new Promise((resolve33) => {
17071
17100
  if (options.timeoutMs === Number.POSITIVE_INFINITY)
17072
17101
  return;
17073
17102
  timer = setTimeout(() => {
17074
17103
  timeoutError3 = acquisitionTimeoutError(options.timeoutMs);
17075
17104
  operationController.abort(timeoutError3);
17076
- resolve32({ kind: "timed_out", error: timeoutError3 });
17105
+ resolve33({ kind: "timed_out", error: timeoutError3 });
17077
17106
  }, options.timeoutMs);
17078
17107
  });
17079
17108
  if (runSignal.aborted) {
@@ -25205,6 +25234,11 @@ var BudgetBoundRecordSchema = inTurn("budget_bound", {
25205
25234
  rootTurnId: turnId2,
25206
25235
  accountId: text4.min(1)
25207
25236
  });
25237
+ var AccountBoundRecordSchema = recordSchema("account_bound", {
25238
+ accountId: text4.min(1),
25239
+ provider: text4.min(1),
25240
+ reason: external_exports.enum(["start", "user_switch", "limit_switch"])
25241
+ });
25208
25242
  var LogRepairedRecordSchema = recordSchema("log_repaired", {
25209
25243
  truncatedBytes: positive,
25210
25244
  lastGoodSeq: positive
@@ -25233,6 +25267,7 @@ var RECORD_ONLY_SCHEMAS = {
25233
25267
  child_session_ended: ChildSessionEndedRecordSchema,
25234
25268
  audit: AuditRecordSchema,
25235
25269
  budget_bound: BudgetBoundRecordSchema,
25270
+ account_bound: AccountBoundRecordSchema,
25236
25271
  log_repaired: LogRepairedRecordSchema
25237
25272
  };
25238
25273
  var SESSION_EVENT_TYPE_TABLE = {
@@ -26171,8 +26206,8 @@ async function releaseHeldSessionLeases(options = {}) {
26171
26206
  }, () => {
26172
26207
  })));
26173
26208
  let timer;
26174
- const deadline = new Promise((resolve32) => {
26175
- timer = setTimeout(resolve32, options.timeoutMs ?? 2e3);
26209
+ const deadline = new Promise((resolve33) => {
26210
+ timer = setTimeout(resolve33, options.timeoutMs ?? 2e3);
26176
26211
  });
26177
26212
  await Promise.race([all, deadline]);
26178
26213
  clearTimeout(timer);
@@ -26319,7 +26354,7 @@ async function renameWithRetry2(from, to) {
26319
26354
  const code = err.code ?? "";
26320
26355
  if (!CONTENDED2.has(code) || attempt >= RENAME_ATTEMPTS2)
26321
26356
  throw err;
26322
- await new Promise((resolve32) => setTimeout(resolve32, attempt));
26357
+ await new Promise((resolve33) => setTimeout(resolve33, attempt));
26323
26358
  }
26324
26359
  }
26325
26360
  }
@@ -29266,7 +29301,14 @@ function rejectedBeforeGeneration(error) {
29266
29301
  }
29267
29302
  const classified = classifyProviderError(error);
29268
29303
  const explicitRejection = error instanceof ProviderError || classified.status !== void 0 && [400, 401, 403, 404, 413, 422, 429].includes(classified.status);
29269
- return explicitRejection && ["auth", "rate_limit", "context_length_exceeded", "invalid_request", "not_found"].includes(classified.code);
29304
+ return explicitRejection && [
29305
+ "auth",
29306
+ "rate_limit",
29307
+ "usage_limit",
29308
+ "context_length_exceeded",
29309
+ "invalid_request",
29310
+ "not_found"
29311
+ ].includes(classified.code);
29270
29312
  }
29271
29313
  __name(rejectedBeforeGeneration, "rejectedBeforeGeneration");
29272
29314
  function withTokenBudget(provider, budget) {
@@ -29317,6 +29359,7 @@ function withTokenBudget(provider, budget) {
29317
29359
  if (recovery && ![
29318
29360
  "auth",
29319
29361
  "rate_limit",
29362
+ "usage_limit",
29320
29363
  "context_length_exceeded",
29321
29364
  "invalid_request",
29322
29365
  "not_found"
@@ -31688,12 +31731,12 @@ var AwaitedJobs = class {
31688
31731
  return Promise.resolve();
31689
31732
  if (this.outstanding.size === 0 && this.monitors.size === 0)
31690
31733
  return Promise.resolve();
31691
- return new Promise((resolve32) => {
31734
+ return new Promise((resolve33) => {
31692
31735
  const finish2 = /* @__PURE__ */ __name(() => {
31693
31736
  clearTimeout(timer);
31694
31737
  this.arrivals.delete(finish2);
31695
31738
  signal?.removeEventListener("abort", finish2);
31696
- resolve32();
31739
+ resolve33();
31697
31740
  }, "finish");
31698
31741
  const timer = setTimeout(finish2, timeoutMs);
31699
31742
  timer.unref?.();
@@ -31864,6 +31907,12 @@ var DEFAULT_ERROR_RULES = [
31864
31907
  message: "The provider rejected the credentials for this turn.",
31865
31908
  hint: "Check that the API key is set, is not expired, and belongs to the account the model is billed to. Retrying will not help until it changes."
31866
31909
  },
31910
+ {
31911
+ id: "provider.usage_limit",
31912
+ when: /* @__PURE__ */ __name((facts) => facts.code === "usage_limit", "when"),
31913
+ message: "The account has used up its allowance until the limit resets.",
31914
+ hint: "Waiting inside this turn cannot help. Continue on another account or provider, or resume after the reset time the provider reported."
31915
+ },
31867
31916
  {
31868
31917
  id: "provider.rate_limit",
31869
31918
  when: /* @__PURE__ */ __name((facts) => facts.code === "rate_limit" || facts.status === 429, "when"),
@@ -32726,7 +32775,7 @@ var CheckpointManager = class {
32726
32775
  }
32727
32776
  async write(recorder, iteration, state) {
32728
32777
  const binding = recorder.budget?.binding;
32729
- const accountId = recorder.budget?.accountId;
32778
+ const accountId2 = recorder.budget?.accountId;
32730
32779
  const document = {
32731
32780
  v: CHECKPOINT_DOCUMENT_VERSION,
32732
32781
  kind: "checkpoint",
@@ -32738,7 +32787,7 @@ var CheckpointManager = class {
32738
32787
  throughSha256: state.throughSha256,
32739
32788
  tokenUsage: state.tokenUsage,
32740
32789
  costInfo: state.costInfo,
32741
- ...accountId !== void 0 ? { budget: { ...binding ? { binding } : {}, accountId } } : {},
32790
+ ...accountId2 !== void 0 ? { budget: { ...binding ? { binding } : {}, accountId: accountId2 } } : {},
32742
32791
  guards: state.guards,
32743
32792
  review: state.review,
32744
32793
  ...state.latestUserMessageId ? { latestUserMessageId: state.latestUserMessageId } : {},
@@ -33868,12 +33917,12 @@ var CompletionInbox = class {
33868
33917
  return Promise.resolve();
33869
33918
  if (!this.hasPendingWork)
33870
33919
  return Promise.resolve();
33871
- return new Promise((resolve32) => {
33920
+ return new Promise((resolve33) => {
33872
33921
  const finish2 = /* @__PURE__ */ __name(() => {
33873
33922
  clearTimeout(timer);
33874
33923
  this.arrivals.delete(finish2);
33875
33924
  signal?.removeEventListener("abort", finish2);
33876
- resolve32();
33925
+ resolve33();
33877
33926
  }, "finish");
33878
33927
  const timer = setTimeout(finish2, timeoutMs);
33879
33928
  timer.unref?.();
@@ -34041,11 +34090,11 @@ ${JSON.stringify({ tasks: tasks2 })}`;
34041
34090
  });
34042
34091
  if (settlements.length === 0)
34043
34092
  return this.drain();
34044
- await new Promise((resolve32) => {
34093
+ await new Promise((resolve33) => {
34045
34094
  const finish2 = /* @__PURE__ */ __name(() => {
34046
34095
  signal?.removeEventListener("abort", finish2);
34047
34096
  this.drains.delete(finish2);
34048
- resolve32();
34097
+ resolve33();
34049
34098
  }, "finish");
34050
34099
  this.drains.add(finish2);
34051
34100
  signal?.addEventListener("abort", finish2, { once: true });
@@ -35553,21 +35602,21 @@ async function waitForTaskWithBounds(gateway, taskId, bounds, now = Date.now) {
35553
35602
  throw err;
35554
35603
  }
35555
35604
  );
35556
- const expiry = new Promise((resolve32) => {
35605
+ const expiry = new Promise((resolve33) => {
35557
35606
  const tick = setInterval(() => {
35558
35607
  if (settled)
35559
35608
  return;
35560
35609
  const elapsed = now() - startedAt;
35561
35610
  if (elapsed >= bounds.wallMs) {
35562
35611
  clearInterval(tick);
35563
- resolve32({ kind: "timeout", cause: "wall", elapsedMs: elapsed, idleBoundArmed });
35612
+ resolve33({ kind: "timeout", cause: "wall", elapsedMs: elapsed, idleBoundArmed });
35564
35613
  return;
35565
35614
  }
35566
35615
  if (idleBoundArmed && bounds.idleMs !== void 0) {
35567
35616
  const quietFor = now() - lastProgressAt;
35568
35617
  if (quietFor >= bounds.idleMs) {
35569
35618
  clearInterval(tick);
35570
- resolve32({ kind: "timeout", cause: "idle", elapsedMs: elapsed, idleBoundArmed });
35619
+ resolve33({ kind: "timeout", cause: "idle", elapsedMs: elapsed, idleBoundArmed });
35571
35620
  }
35572
35621
  }
35573
35622
  }, POLL_INTERVAL_MS);
@@ -38653,19 +38702,19 @@ async function runCompactionCheckInner(ctx, pass, options) {
38653
38702
  signal: ctx.abortController.signal
38654
38703
  }, ctx.emitEvent);
38655
38704
  applyLifecycleHookResults("pre_compact", results);
38656
- const refusal3 = results.find((result) => result.action === "skip");
38657
- if (refusal3?.action === "skip") {
38705
+ const refusal4 = results.find((result) => result.action === "skip");
38706
+ if (refusal4?.action === "skip") {
38658
38707
  if (!options?.force) {
38659
38708
  pass.attempted = false;
38660
38709
  ctx.log.info("A pre_compact hook cancelled the compaction pass", {
38661
38710
  [NAMZU.TURN_ID]: ctx.recorder.turnId,
38662
- "namzu.hook.reason": refusal3.reason
38711
+ "namzu.hook.reason": refusal4.reason
38663
38712
  });
38664
38713
  return;
38665
38714
  }
38666
38715
  ctx.log.warn("A pre_compact hook asked to cancel a compaction the provider forced; it ran", {
38667
38716
  [NAMZU.TURN_ID]: ctx.recorder.turnId,
38668
- "namzu.hook.reason": refusal3.reason
38717
+ "namzu.hook.reason": refusal4.reason
38669
38718
  });
38670
38719
  }
38671
38720
  }
@@ -39130,14 +39179,14 @@ async function awaitDecisionDurably(ctx, checkpoint, request, scope) {
39130
39179
  }, "record");
39131
39180
  let parkTimer;
39132
39181
  let recording = false;
39133
- const recordIfSlow = new Promise((resolve32) => {
39182
+ const recordIfSlow = new Promise((resolve33) => {
39134
39183
  parkTimer = setTimeout(() => {
39135
39184
  if (settled) {
39136
- resolve32();
39185
+ resolve33();
39137
39186
  return;
39138
39187
  }
39139
39188
  recording = true;
39140
- record3().then(resolve32, resolve32);
39189
+ record3().then(resolve33, resolve33);
39141
39190
  }, delay2);
39142
39191
  });
39143
39192
  try {
@@ -39186,13 +39235,13 @@ async function awaitDecisionOrAbort(ctx, request, scope) {
39186
39235
  const abortedDecision = /* @__PURE__ */ __name(() => scope && !turnSignal?.aborted ? scope.closedAs() : { action: "abort", reason: "run aborted while parked for HITL" }, "abortedDecision");
39187
39236
  if (signal.aborted)
39188
39237
  return abortedDecision();
39189
- return new Promise((resolve32) => {
39238
+ return new Promise((resolve33) => {
39190
39239
  let settled = false;
39191
39240
  const onAbort = /* @__PURE__ */ __name(() => {
39192
39241
  if (settled)
39193
39242
  return;
39194
39243
  settled = true;
39195
- resolve32(abortedDecision());
39244
+ resolve33(abortedDecision());
39196
39245
  }, "onAbort");
39197
39246
  signal.addEventListener("abort", onAbort, { once: true });
39198
39247
  Promise.resolve(ctx.resumeHandler(request, resumeContext)).then((decision2) => {
@@ -39200,13 +39249,13 @@ async function awaitDecisionOrAbort(ctx, request, scope) {
39200
39249
  return;
39201
39250
  settled = true;
39202
39251
  signal.removeEventListener("abort", onAbort);
39203
- resolve32(decision2);
39252
+ resolve33(decision2);
39204
39253
  }, (err) => {
39205
39254
  if (settled)
39206
39255
  return;
39207
39256
  settled = true;
39208
39257
  signal.removeEventListener("abort", onAbort);
39209
- resolve32({
39258
+ resolve33({
39210
39259
  action: "abort",
39211
39260
  reason: err instanceof Error ? err.message : "resume handler failed"
39212
39261
  });
@@ -39412,7 +39461,7 @@ var DECLINED_TOOL_CALL_FEEDBACK = "The user declined this. Do not get the same c
39412
39461
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
39413
39462
  async function awaitProjectInstructionCallback(signal, start) {
39414
39463
  signal.throwIfAborted();
39415
- return new Promise((resolve32, reject2) => {
39464
+ return new Promise((resolve33, reject2) => {
39416
39465
  let settled = false;
39417
39466
  const cleanup = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "cleanup");
39418
39467
  const rejectOnce = /* @__PURE__ */ __name((reason2) => {
@@ -39427,7 +39476,7 @@ async function awaitProjectInstructionCallback(signal, start) {
39427
39476
  return;
39428
39477
  settled = true;
39429
39478
  cleanup();
39430
- resolve32(value);
39479
+ resolve33(value);
39431
39480
  }, "resolveOnce");
39432
39481
  const onAbort = /* @__PURE__ */ __name(() => rejectOnce(signal.reason), "onAbort");
39433
39482
  signal.addEventListener("abort", onAbort, { once: true });
@@ -40710,10 +40759,10 @@ function gitOperands(args) {
40710
40759
  ]);
40711
40760
  let index = 0;
40712
40761
  let base3 = "";
40713
- const join56 = /* @__PURE__ */ __name((value) => base3 === "" ? value : `${base3.replace(/\/+$/, "")}/${value}`, "join");
40762
+ const join58 = /* @__PURE__ */ __name((value) => base3 === "" ? value : `${base3.replace(/\/+$/, "")}/${value}`, "join");
40714
40763
  const absolute = /* @__PURE__ */ __name((value) => value.startsWith("/") || value.startsWith("~"), "absolute");
40715
40764
  const setBase = /* @__PURE__ */ __name((value) => {
40716
- base3 = absolute(value) ? value : join56(value);
40765
+ base3 = absolute(value) ? value : join58(value);
40717
40766
  }, "setBase");
40718
40767
  while (index < args.length && args[index].value.startsWith("-")) {
40719
40768
  const flag2 = args[index].value;
@@ -40729,7 +40778,7 @@ function gitOperands(args) {
40729
40778
  }
40730
40779
  const sub = args[index]?.value;
40731
40780
  const rest = args.slice(index + 1);
40732
- const place = /* @__PURE__ */ __name((value) => base3 === "" || absolute(value) ? value : join56(value), "place");
40781
+ const place = /* @__PURE__ */ __name((value) => base3 === "" || absolute(value) ? value : join58(value), "place");
40733
40782
  if (sub === "grep") {
40734
40783
  const files = patternThenFiles(set2("-e", "--regexp", "-f", "--file", "-A", "--after-context", "-B", "--before-context", "-C", "--context", "-m", "--max-count", "--max-depth", "--threads"))(rest);
40735
40784
  return files.length > 0 ? files.map((f) => word(place(f.value))) : [word(base3 === "" ? "." : base3)];
@@ -42558,7 +42607,7 @@ function shellProgress(report) {
42558
42607
  __name(shellProgress, "shellProgress");
42559
42608
  function execHostShell(command, options) {
42560
42609
  options.signal?.throwIfAborted();
42561
- return new Promise((resolve32, reject2) => {
42610
+ return new Promise((resolve33, reject2) => {
42562
42611
  const child = spawnHostShell(command, {
42563
42612
  cwd: options.cwd,
42564
42613
  env: options.env,
@@ -42659,7 +42708,7 @@ function execHostShell(command, options) {
42659
42708
  const stdout = decodeCapture("stdout");
42660
42709
  const stderr = decodeCapture("stderr");
42661
42710
  if (!failure2 && cause === void 0 && code === 0 && signal === null) {
42662
- resolve32({
42711
+ resolve33({
42663
42712
  stdout,
42664
42713
  stderr,
42665
42714
  stdoutBytes: captures.stdout.bytes,
@@ -42710,7 +42759,7 @@ ${stderr}`));
42710
42759
  child.off("close", onClose);
42711
42760
  child.off("error", onError);
42712
42761
  child.off("spawn", onSpawn);
42713
- resolve32({
42762
+ resolve33({
42714
42763
  backgroundedJobId: jobId,
42715
42764
  backgroundedBy: reason2,
42716
42765
  stdout: decodeCapture("stdout"),
@@ -43114,14 +43163,14 @@ __name(backoffProportional, "backoffProportional");
43114
43163
  function sleep(ms, signal) {
43115
43164
  if (ms <= 0)
43116
43165
  return Promise.resolve();
43117
- return new Promise((resolve32, reject2) => {
43166
+ return new Promise((resolve33, reject2) => {
43118
43167
  if (signal?.aborted) {
43119
43168
  reject2(signal.reason);
43120
43169
  return;
43121
43170
  }
43122
43171
  const timer = setTimeout(() => {
43123
43172
  signal?.removeEventListener("abort", onAbort);
43124
- resolve32();
43173
+ resolve33();
43125
43174
  }, ms);
43126
43175
  const onAbort = /* @__PURE__ */ __name(() => {
43127
43176
  clearTimeout(timer);
@@ -43870,11 +43919,11 @@ __name(checkRemoval, "checkRemoval");
43870
43919
  var GLOB_TAIL = /[\\/]\.?\*$/;
43871
43920
  function checkTarget(program, args, spelled, word2, scope) {
43872
43921
  const expanded = expandTilde(spelled, scope.home);
43873
- const relative14 = !isAbsolute4(expanded);
43922
+ const relative15 = !isAbsolute4(expanded);
43874
43923
  if (expandsAtRuntime(word2) && /[$`]/.test(expanded)) {
43875
43924
  return void 0;
43876
43925
  }
43877
- const absolute = relative14 ? resolve3(scope.cwd, expanded) : resolve3(expanded);
43926
+ const absolute = relative15 ? resolve3(scope.cwd, expanded) : resolve3(expanded);
43878
43927
  let settled = absolute;
43879
43928
  for (let previous = ""; previous !== settled; ) {
43880
43929
  previous = settled;
@@ -43884,18 +43933,18 @@ function checkTarget(program, args, spelled, word2, scope) {
43884
43933
  }
43885
43934
  const globbed = settled !== absolute;
43886
43935
  const original = expanded;
43887
- if (scope.changesDirectory && globbed && relative14 && GLOB_TAIL.test(absolute)) {
43936
+ if (scope.changesDirectory && globbed && relative15 && GLOB_TAIL.test(absolute)) {
43888
43937
  return `${program} ${spelled}: a relative glob after a cd cannot be resolved before the line runs`;
43889
43938
  }
43890
43939
  let below = settled;
43891
- if (relative14) {
43940
+ if (relative15) {
43892
43941
  const prefix = scope.cwd.endsWith(sep3) ? scope.cwd : scope.cwd + sep3;
43893
43942
  if (settled.startsWith(prefix))
43894
43943
  below = settled.slice(prefix.length);
43895
43944
  else if (settled === scope.cwd)
43896
43945
  below = "";
43897
43946
  }
43898
- if (globbed && (hasParentAfterName(original) || original.startsWith("~") || /^[\\/]{2}/.test(original) || relative14 && /(^|[\\/])\.\.([\\/]|$)/.test(original) && GLOB_TAIL.test(absolute) || program === "rmdir" && GLOB_TAIL.test(absolute) && args.some((a) => /^--p/.test(a.value) || /^-[a-z]*p/.test(a.value)) || relative14 && /\*[\\/]+$/.test(original) && GLOB_TAIL.test(absolute))) {
43947
+ if (globbed && (hasParentAfterName(original) || original.startsWith("~") || /^[\\/]{2}/.test(original) || relative15 && /(^|[\\/])\.\.([\\/]|$)/.test(original) && GLOB_TAIL.test(absolute) || program === "rmdir" && GLOB_TAIL.test(absolute) && args.some((a) => /^--p/.test(a.value) || /^-[a-z]*p/.test(a.value)) || relative15 && /\*[\\/]+$/.test(original) && GLOB_TAIL.test(absolute))) {
43899
43948
  return `${program} ${spelled}: the target cannot be resolved to a directory before the line runs`;
43900
43949
  }
43901
43950
  if (!globbed || !/[*?[]/.test(below)) {
@@ -44612,9 +44661,9 @@ function createReviewHandler(options = {}) {
44612
44661
  if (!live.some(isBypassImmune))
44613
44662
  return { action: "approve_tools" };
44614
44663
  if (!prompt) {
44615
- const refusal3 = immuneRefusal(live, options.unattendedSandboxEscape === "allow");
44616
- if (refusal3 !== void 0)
44617
- return { action: "reject_tools", feedback: refusal3 };
44664
+ const refusal4 = immuneRefusal(live, options.unattendedSandboxEscape === "allow");
44665
+ if (refusal4 !== void 0)
44666
+ return { action: "reject_tools", feedback: refusal4 };
44618
44667
  return {
44619
44668
  action: "approve_tools",
44620
44669
  ...escapes2.length > 0 ? { confirmedEscalations: escapes2 } : {}
@@ -45456,7 +45505,7 @@ function interpretPreToolResults(toolName, initialInput, results, requestHalt) {
45456
45505
  const withContext = /* @__PURE__ */ __name((text10) => contexts.length === 0 ? text10 : `${text10}
45457
45506
 
45458
45507
  ${hookNote(contexts)}`, "withContext");
45459
- let refusal3;
45508
+ let refusal4;
45460
45509
  for (const result of results) {
45461
45510
  switch (result.action) {
45462
45511
  case "continue":
@@ -45480,10 +45529,10 @@ ${hookNote(contexts)}`, "withContext");
45480
45529
  contexts.push(result.context);
45481
45530
  if (result.halt)
45482
45531
  requestHalt?.(result.halt.reason);
45483
- refusal3 ??= { kind: "skip", text: skippedToolResultText(toolName, result.reason) };
45532
+ refusal4 ??= { kind: "skip", text: skippedToolResultText(toolName, result.reason) };
45484
45533
  continue;
45485
45534
  case "error":
45486
- refusal3 ??= { kind: "error", text: `Error: ${result.message}` };
45535
+ refusal4 ??= { kind: "error", text: `Error: ${result.message}` };
45487
45536
  continue;
45488
45537
  case "retry":
45489
45538
  case "annotate":
@@ -45499,11 +45548,11 @@ ${hookNote(contexts)}`, "withContext");
45499
45548
  }
45500
45549
  }
45501
45550
  }
45502
- if (refusal3) {
45551
+ if (refusal4) {
45503
45552
  return {
45504
- kind: refusal3.kind,
45553
+ kind: refusal4.kind,
45505
45554
  input: currentInput,
45506
- output: refusal3.kind === "skip" ? withContext(refusal3.text) : refusal3.text
45555
+ output: refusal4.kind === "skip" ? withContext(refusal4.text) : refusal4.text
45507
45556
  };
45508
45557
  }
45509
45558
  return {
@@ -46620,7 +46669,7 @@ function checkPageRange(value) {
46620
46669
  }
46621
46670
  __name(checkPageRange, "checkPageRange");
46622
46671
  function run(command, args, input, signal, timeoutMs) {
46623
- return new Promise((resolve32) => {
46672
+ return new Promise((resolve33) => {
46624
46673
  const child = spawn(command, [...args], { stdio: ["pipe", "pipe", "pipe"], signal });
46625
46674
  let stdout = "";
46626
46675
  let stderr = "";
@@ -46641,11 +46690,11 @@ function run(command, args, input, signal, timeoutMs) {
46641
46690
  child.on("error", (error) => {
46642
46691
  missing2 = error.code === "ENOENT";
46643
46692
  clearTimeout(timer);
46644
- resolve32({ code: null, stdout, stderr: stderr || error.message, missing: missing2, timedOut });
46693
+ resolve33({ code: null, stdout, stderr: stderr || error.message, missing: missing2, timedOut });
46645
46694
  });
46646
46695
  child.on("close", (code) => {
46647
46696
  clearTimeout(timer);
46648
- resolve32({ code, stdout, stderr, missing: missing2, timedOut });
46697
+ resolve33({ code, stdout, stderr, missing: missing2, timedOut });
46649
46698
  });
46650
46699
  child.stdin.on("error", () => {
46651
46700
  });
@@ -47924,10 +47973,10 @@ __name(describeChange, "describeChange");
47924
47973
  var mutationTails = /* @__PURE__ */ new Map();
47925
47974
  async function withFileMutationLock(key6, operation) {
47926
47975
  const previous = mutationTails.get(key6) ?? Promise.resolve();
47927
- let release = /* @__PURE__ */ __name(() => {
47976
+ let release2 = /* @__PURE__ */ __name(() => {
47928
47977
  }, "release");
47929
- const current = new Promise((resolve32) => {
47930
- release = resolve32;
47978
+ const current = new Promise((resolve33) => {
47979
+ release2 = resolve33;
47931
47980
  });
47932
47981
  const tail = previous.then(() => current);
47933
47982
  mutationTails.set(key6, tail);
@@ -47935,7 +47984,7 @@ async function withFileMutationLock(key6, operation) {
47935
47984
  try {
47936
47985
  return await operation();
47937
47986
  } finally {
47938
- release();
47987
+ release2();
47939
47988
  if (mutationTails.get(key6) === tail)
47940
47989
  mutationTails.delete(key6);
47941
47990
  }
@@ -50075,9 +50124,9 @@ var ToolCallBudget = class {
50075
50124
  async admit(count7, kind, signal) {
50076
50125
  signal.throwIfAborted();
50077
50126
  const previous = this.chain;
50078
- let release;
50079
- this.chain = new Promise((resolve32) => {
50080
- release = resolve32;
50127
+ let release2;
50128
+ this.chain = new Promise((resolve33) => {
50129
+ release2 = resolve33;
50081
50130
  });
50082
50131
  try {
50083
50132
  await previous;
@@ -50110,7 +50159,7 @@ var ToolCallBudget = class {
50110
50159
  signal.throwIfAborted();
50111
50160
  return void 0;
50112
50161
  } finally {
50113
- release();
50162
+ release2();
50114
50163
  }
50115
50164
  }
50116
50165
  };
@@ -50604,18 +50653,18 @@ var ToolExecutor = class {
50604
50653
  return call2;
50605
50654
  }
50606
50655
  try {
50607
- const refusal3 = await tool.refuseBeforeReview(call2.input, this.buildToolContext());
50656
+ const refusal4 = await tool.refuseBeforeReview(call2.input, this.buildToolContext());
50608
50657
  this.config.abortSignal.throwIfAborted();
50609
- if (!refusal3)
50658
+ if (!refusal4)
50610
50659
  return call2;
50611
50660
  return {
50612
50661
  kind: "synthetic",
50613
50662
  toolCall: call2.toolCall,
50614
50663
  toolName: call2.toolName,
50615
50664
  input: call2.input,
50616
- message: formatFailedToolOutput(void 0, refusal3.error),
50665
+ message: formatFailedToolOutput(void 0, refusal4.error),
50617
50666
  isError: true,
50618
- ...refusal3.facts ? { facts: refusal3.facts } : {}
50667
+ ...refusal4.facts ? { facts: refusal4.facts } : {}
50619
50668
  };
50620
50669
  } catch {
50621
50670
  this.config.abortSignal.throwIfAborted();
@@ -50815,12 +50864,12 @@ var ToolExecutor = class {
50815
50864
  if (owned && !this.preparedBatches.has(owned)) {
50816
50865
  throw new Error("Prepared tool batch is not owned by this executor.");
50817
50866
  }
50818
- const refusal3 = this.toolCallBudget ? await this.toolCallBudget.admit(toolCalls.filter((call2) => prior?.get(call2.id) === void 0).length, "batch", this.config.abortSignal) : void 0;
50819
- if (refusal3) {
50867
+ const refusal4 = this.toolCallBudget ? await this.toolCallBudget.admit(toolCalls.filter((call2) => prior?.get(call2.id) === void 0).length, "batch", this.config.abortSignal) : void 0;
50868
+ if (refusal4) {
50820
50869
  const refused = new Map(denials);
50821
50870
  for (const call2 of toolCalls)
50822
50871
  if (!refused.has(call2.id))
50823
- refused.set(call2.id, refusal3);
50872
+ refused.set(call2.id, refusal4);
50824
50873
  return await this.runBatch(toolCalls, refused, prior, owned, declines, review);
50825
50874
  }
50826
50875
  return await this.runBatch(toolCalls, denials, prior, owned, declines, review);
@@ -51011,7 +51060,7 @@ var ToolExecutor = class {
51011
51060
  let failure2;
51012
51061
  const settledUnits = /* @__PURE__ */ new Map();
51013
51062
  const refusedAfterEnd = "An earlier call in this batch was refused and the turn was stopped, so this call was not run.";
51014
- await new Promise((resolve32) => {
51063
+ await new Promise((resolve33) => {
51015
51064
  const start = /* @__PURE__ */ __name((unit) => {
51016
51065
  inFlight.add(unit);
51017
51066
  let settledUnit;
@@ -51032,11 +51081,11 @@ var ToolExecutor = class {
51032
51081
  if (admission2.run && !review.ended.aborted) {
51033
51082
  await unit.run();
51034
51083
  } else {
51035
- const refusal3 = admission2.run ? { reason: refusedAfterEnd } : { reason: admission2.reason, declined: admission2.declined };
51084
+ const refusal4 = admission2.run ? { reason: refusedAfterEnd } : { reason: admission2.reason, declined: admission2.declined };
51036
51085
  if (review.ended.aborted) {
51037
51086
  await Promise.all([...settledUnits].filter(([index]) => index < unit.index).map(([, done]) => done));
51038
51087
  }
51039
- results[unit.index] = await this.recordDenial(unit.toolCall, refusal3.reason, unit.preparedCall, "declined" in refusal3 ? refusal3.declined : void 0);
51088
+ results[unit.index] = await this.recordDenial(unit.toolCall, refusal4.reason, unit.preparedCall, "declined" in refusal4 ? refusal4.declined : void 0);
51040
51089
  }
51041
51090
  } catch (error) {
51042
51091
  failure2 ??= { error };
@@ -51059,7 +51108,7 @@ var ToolExecutor = class {
51059
51108
  start(unit);
51060
51109
  }
51061
51110
  if (cursor >= units.length && inFlight.size === 0)
51062
- resolve32();
51111
+ resolve33();
51063
51112
  }, "pump");
51064
51113
  review.ended.addEventListener("abort", pump, { once: true });
51065
51114
  pump();
@@ -51129,9 +51178,9 @@ var ToolExecutor = class {
51129
51178
  };
51130
51179
  signal.throwIfAborted();
51131
51180
  if (this.toolCallBudget) {
51132
- const refusal3 = await this.toolCallBudget.admit(1, "nested", signal);
51133
- if (refusal3)
51134
- return { success: false, output: "", error: refusal3 };
51181
+ const refusal4 = await this.toolCallBudget.admit(1, "nested", signal);
51182
+ if (refusal4)
51183
+ return { success: false, output: "", error: refusal4 };
51135
51184
  }
51136
51185
  const preparedInput = preparedCall.input;
51137
51186
  const parent = context2.toolUseId;
@@ -51597,17 +51646,17 @@ var ToolExecutor = class {
51597
51646
  } catch {
51598
51647
  break;
51599
51648
  }
51600
- let refusal3;
51649
+ let refusal4;
51601
51650
  try {
51602
51651
  if (this.toolCallBudget)
51603
- refusal3 = await this.toolCallBudget.admit(1, "retry", this.config.abortSignal);
51652
+ refusal4 = await this.toolCallBudget.admit(1, "retry", this.config.abortSignal);
51604
51653
  } catch (error) {
51605
51654
  if (this.config.abortSignal.aborted)
51606
51655
  break;
51607
51656
  throw error;
51608
51657
  }
51609
- if (refusal3) {
51610
- result = { success: false, output: "", error: refusal3 };
51658
+ if (refusal4) {
51659
+ result = { success: false, output: "", error: refusal4 };
51611
51660
  post = { override: null, retry: false };
51612
51661
  break;
51613
51662
  }
@@ -51821,21 +51870,21 @@ ${note}`;
51821
51870
  let invocationOpen = true;
51822
51871
  const nestedDispatches = /* @__PURE__ */ new Set();
51823
51872
  try {
51824
- const expired = Number.isFinite(timeoutMs) && timeoutMs > 0 ? new Promise((resolve32) => {
51873
+ const expired = Number.isFinite(timeoutMs) && timeoutMs > 0 ? new Promise((resolve33) => {
51825
51874
  timer = setTimeout(() => {
51826
51875
  timedOut = true;
51827
51876
  controller.abort(new Error(`Tool "${toolName}" exceeded ${timeoutMs}ms`));
51828
- resolve32("timeout");
51877
+ resolve33("timeout");
51829
51878
  }, timeoutMs);
51830
51879
  }) : void 0;
51831
- const aborted = new Promise((resolve32) => {
51880
+ const aborted = new Promise((resolve33) => {
51832
51881
  if (controller.signal.aborted && !timedOut) {
51833
- resolve32("aborted");
51882
+ resolve33("aborted");
51834
51883
  return;
51835
51884
  }
51836
51885
  controller.signal.addEventListener("abort", () => {
51837
51886
  if (!timedOut)
51838
- resolve32("aborted");
51887
+ resolve33("aborted");
51839
51888
  }, { once: true });
51840
51889
  });
51841
51890
  const inheritedDispatch = toolContext.dispatchTool;
@@ -52044,11 +52093,16 @@ ${note}`;
52044
52093
  };
52045
52094
  }
52046
52095
  /**
52047
- * One execution attempt, with a throw materialized as an error result.
52096
+ * One execution attempt, with a throw materialized as an error result —
52097
+ * except `ToolResultHalted`, which this deliberately lets through.
52048
52098
  *
52049
52099
  * an unhandled throw from `tools.execute(...)` used to
52050
52100
  * propagate up to `result.ts` as `turn_failed` without emitting a
52051
- * terminal `tool_completed`, leaving UI cards stuck in `executing`.
52101
+ * terminal `tool_completed`, leaving UI cards stuck in `executing`. That
52102
+ * is still right for a tool that merely broke. It is wrong for a screen
52103
+ * that said `halt`: `screen.ts` throws `ToolResultHalted` instead of
52104
+ * returning it so a catch this generic cannot flatten it into a failed
52105
+ * `ToolResult` the model reads and works around.
52052
52106
  *
52053
52107
  * The return is the full `ToolResult`, not a narrowed literal: the
52054
52108
  * narrow version silently DROPPED `content`, so a tool returning an
@@ -52059,6 +52113,8 @@ ${note}`;
52059
52113
  try {
52060
52114
  return await this.executeWithDeadline(toolName, input, toolContext, prepared);
52061
52115
  } catch (err) {
52116
+ if (err instanceof ToolResultHalted)
52117
+ throw err;
52062
52118
  const message = toErrorMessage(err);
52063
52119
  this.log.warn("Tool execution threw", {
52064
52120
  [NAMZU.TURN_ID]: this.config.turnId,
@@ -52377,8 +52433,8 @@ var Semaphore = class {
52377
52433
  this.available--;
52378
52434
  return Promise.resolve();
52379
52435
  }
52380
- return new Promise((resolve32) => {
52381
- this.waiters.push(resolve32);
52436
+ return new Promise((resolve33) => {
52437
+ this.waiters.push(resolve33);
52382
52438
  });
52383
52439
  }
52384
52440
  release() {
@@ -52956,23 +53012,23 @@ __name(applyPendingResume, "applyPendingResume");
52956
53012
  function escalationRefusal(escalation, reviewed, wasModified, confirmed, id3) {
52957
53013
  if (!escalation)
52958
53014
  return void 0;
52959
- const refusal3 = "Refused after resume: this call reaches past the turn's boundary, and the durable approval does not cover what it reaches now. Ask for the approval again.";
53015
+ const refusal4 = "Refused after resume: this call reaches past the turn's boundary, and the durable approval does not cover what it reaches now. Ask for the approval again.";
52960
53016
  if (!reviewed || wasModified)
52961
- return refusal3;
53017
+ return refusal4;
52962
53018
  const shown = reviewed.escalation;
52963
53019
  for (const path3 of escalation.outsidePaths ?? []) {
52964
53020
  if (!shown?.outsidePaths?.includes(path3))
52965
- return refusal3;
53021
+ return refusal4;
52966
53022
  }
52967
53023
  for (const path3 of escalation.protectedPaths ?? []) {
52968
53024
  if (!shown?.protectedPaths?.includes(path3))
52969
- return refusal3;
53025
+ return refusal4;
52970
53026
  }
52971
53027
  if (escalation.dangerousRemoval !== void 0 && shown?.dangerousRemoval !== escalation.dangerousRemoval) {
52972
- return refusal3;
53028
+ return refusal4;
52973
53029
  }
52974
53030
  if (escalation.unfinishedCheck !== void 0 && shown?.unfinishedCheck === void 0) {
52975
- return refusal3;
53031
+ return refusal4;
52976
53032
  }
52977
53033
  if (escalation.sandboxEscape && (!shown?.sandboxEscape || !confirmed?.includes(id3))) {
52978
53034
  return "Refused after resume: running this command outside the sandbox needs a person to confirm it for this call, and the durable approval did not.";
@@ -53250,8 +53306,8 @@ var PerCallReview = class {
53250
53306
  async admit(call2) {
53251
53307
  const before = this.#line;
53252
53308
  let leave;
53253
- this.#line = new Promise((resolve32) => {
53254
- leave = resolve32;
53309
+ this.#line = new Promise((resolve33) => {
53310
+ leave = resolve33;
53255
53311
  });
53256
53312
  try {
53257
53313
  const verdict = await this.#decide(call2, before, leave);
@@ -53664,11 +53720,11 @@ async function* runToolReview(ctx, response, iterationNum) {
53664
53720
  for (const summary2 of toolCallSummaries) {
53665
53721
  if (denials?.has(summary2.id))
53666
53722
  continue;
53667
- const refusal3 = tracker.refusal(summary2.name, summary2.input);
53668
- if (!refusal3)
53723
+ const refusal4 = tracker.refusal(summary2.name, summary2.input);
53724
+ if (!refusal4)
53669
53725
  continue;
53670
53726
  merged ??= new Map(denials ?? []);
53671
- merged.set(summary2.id, refusal3);
53727
+ merged.set(summary2.id, refusal4);
53672
53728
  }
53673
53729
  return merged ?? denials;
53674
53730
  }, "withRepeatRefusals");
@@ -53817,8 +53873,8 @@ async function* runToolReview(ctx, response, iterationNum) {
53817
53873
  }
53818
53874
  const wakeup = /* @__PURE__ */ __name(() => {
53819
53875
  let notify;
53820
- const promise = new Promise((resolve32) => {
53821
- notify = resolve32;
53876
+ const promise = new Promise((resolve33) => {
53877
+ notify = resolve33;
53822
53878
  });
53823
53879
  return { promise, notify };
53824
53880
  }, "wakeup");
@@ -54046,14 +54102,14 @@ async function* runToolReview(ctx, response, iterationNum) {
54046
54102
  toolInput: tc.input,
54047
54103
  signal: ctx.abortController.signal
54048
54104
  }, ctx.emitEvent);
54049
- const refusal3 = answers.find((answer) => answer.action === "skip");
54105
+ const refusal4 = answers.find((answer) => answer.action === "skip");
54050
54106
  for (const answer of answers) {
54051
54107
  if ((answer.action === "continue" || answer.action === "skip") && answer.halt) {
54052
54108
  ctx.toolExecutor.requestHalt?.(answer.halt.reason);
54053
54109
  }
54054
54110
  }
54055
- if (refusal3?.action === "skip") {
54056
- const reason2 = `Blocked by a permission_request hook: ${refusal3.reason}`;
54111
+ if (refusal4?.action === "skip") {
54112
+ const reason2 = `Blocked by a permission_request hook: ${refusal4.reason}`;
54057
54113
  gateDenied.set(tc.id, reason2);
54058
54114
  tc.authorization = { decision: "deny", reason: reason2 };
54059
54115
  await ctx.recorder.recordAudit({
@@ -58554,7 +58610,7 @@ async function awaitStoreRead(signal, start) {
58554
58610
  if (!signal)
58555
58611
  return await start();
58556
58612
  signal.throwIfAborted();
58557
- return new Promise((resolve32, reject2) => {
58613
+ return new Promise((resolve33, reject2) => {
58558
58614
  let settled = false;
58559
58615
  const cleanup = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "cleanup");
58560
58616
  const rejectOnce = /* @__PURE__ */ __name((reason2) => {
@@ -58569,7 +58625,7 @@ async function awaitStoreRead(signal, start) {
58569
58625
  return;
58570
58626
  settled = true;
58571
58627
  cleanup();
58572
- resolve32(value);
58628
+ resolve33(value);
58573
58629
  }, "resolveOnce");
58574
58630
  const onAbort = /* @__PURE__ */ __name(() => rejectOnce(signal.reason), "onAbort");
58575
58631
  signal.addEventListener("abort", onAbort, { once: true });
@@ -60152,15 +60208,15 @@ var EventTranslator = class {
60152
60208
  appendChain = Promise.resolve();
60153
60209
  async withLogLock(operation) {
60154
60210
  const previous = this.appendChain;
60155
- let release;
60156
- this.appendChain = new Promise((resolve32) => {
60157
- release = resolve32;
60211
+ let release2;
60212
+ this.appendChain = new Promise((resolve33) => {
60213
+ release2 = resolve33;
60158
60214
  });
60159
60215
  try {
60160
60216
  await previous;
60161
60217
  return await operation();
60162
60218
  } finally {
60163
- release();
60219
+ release2();
60164
60220
  }
60165
60221
  }
60166
60222
  /** The session log's records, read between whole appends. */
@@ -60656,7 +60712,7 @@ function validateSessionTokenBudgetSnapshot(value) {
60656
60712
  const turnOwners = /* @__PURE__ */ new Map();
60657
60713
  const accounts = source.accounts.map((raw) => {
60658
60714
  const account = object(raw, "account");
60659
- const accountId = uuid(account.id, "account id");
60715
+ const accountId2 = uuid(account.id, "account id");
60660
60716
  if (typeof account.settled !== "boolean")
60661
60717
  throw new Error("Invalid token budget settled flag");
60662
60718
  const accountLimit = count4(account.limit, "limit");
@@ -60665,7 +60721,7 @@ function validateSessionTokenBudgetSnapshot(value) {
60665
60721
  turnId3(owner, "usage turn id");
60666
60722
  if (turnOwners.has(owner))
60667
60723
  throw new Error("A turn belongs to more than one token budget");
60668
- turnOwners.set(owner, accountId);
60724
+ turnOwners.set(owner, accountId2);
60669
60725
  usage[owner] = usageValue(rawUsage);
60670
60726
  }
60671
60727
  let turn;
@@ -60682,7 +60738,7 @@ function validateSessionTokenBudgetSnapshot(value) {
60682
60738
  throw new Error("Unbound token budget cannot contain usage");
60683
60739
  }
60684
60740
  return {
60685
- id: accountId,
60741
+ id: accountId2,
60686
60742
  ...account.parentId === void 0 ? {} : { parentId: uuid(account.parentId, "parent id") },
60687
60743
  limit: accountLimit,
60688
60744
  settled: account.settled,
@@ -60715,19 +60771,19 @@ function validateSessionTokenBudgetSnapshot(value) {
60715
60771
  const parseRequest = /* @__PURE__ */ __name((raw) => {
60716
60772
  const request = object(raw, "request");
60717
60773
  const requestId = uuid(request.id, "request id");
60718
- const accountId = uuid(request.accountId, "request account id");
60774
+ const accountId2 = uuid(request.accountId, "request account id");
60719
60775
  if (request.unresolved !== void 0 && typeof request.unresolved !== "boolean")
60720
60776
  throw new Error("Invalid unresolved request marker");
60721
60777
  const owner = turnId3(request.turnId, "request turn id");
60722
60778
  if (requestIds.has(requestId))
60723
60779
  throw new Error("Duplicate token budget request");
60724
60780
  requestIds.add(requestId);
60725
- if (!byId.has(accountId) || turnOwners.get(owner) !== accountId) {
60781
+ if (!byId.has(accountId2) || turnOwners.get(owner) !== accountId2) {
60726
60782
  throw new Error("Token budget request has no owning turn");
60727
60783
  }
60728
60784
  return {
60729
60785
  id: requestId,
60730
- accountId,
60786
+ accountId: accountId2,
60731
60787
  turnId: owner,
60732
60788
  ...request.usage === void 0 ? {} : { usage: usageValue(request.usage) },
60733
60789
  ...request.unresolved === true ? { unresolved: true } : {}
@@ -60798,23 +60854,23 @@ var SessionTokenBudget = class _SessionTokenBudget {
60798
60854
  }
60799
60855
  ledger;
60800
60856
  accountId;
60801
- constructor(ledger, accountId) {
60857
+ constructor(ledger, accountId2) {
60802
60858
  this.ledger = ledger;
60803
- this.accountId = accountId;
60859
+ this.accountId = accountId2;
60804
60860
  }
60805
60861
  static create(limit, scope, persistence) {
60806
60862
  count4(limit, "limit");
60807
60863
  const rootSessionId = sessionId2(scope.rootSessionId, "root session id");
60808
60864
  const rootTurnId = turnId3(scope.rootTurnId, "root turn id");
60809
- const accountId = uuidv7();
60865
+ const accountId2 = uuidv7();
60810
60866
  const budget = new _SessionTokenBudget({
60811
- rootAccountId: accountId,
60867
+ rootAccountId: accountId2,
60812
60868
  scope: { rootSessionId, rootTurnId },
60813
60869
  accounts: /* @__PURE__ */ new Map([
60814
60870
  [
60815
- accountId,
60871
+ accountId2,
60816
60872
  {
60817
- id: accountId,
60873
+ id: accountId2,
60818
60874
  limit,
60819
60875
  settled: false,
60820
60876
  turn: { sessionId: rootSessionId, turnId: rootTurnId },
@@ -60827,7 +60883,7 @@ var SessionTokenBudget = class _SessionTokenBudget {
60827
60883
  poisoned: false,
60828
60884
  persistence,
60829
60885
  writes: Promise.resolve()
60830
- }, accountId);
60886
+ }, accountId2);
60831
60887
  budget.persist();
60832
60888
  return budget;
60833
60889
  }
@@ -60912,10 +60968,10 @@ var SessionTokenBudget = class _SessionTokenBudget {
60912
60968
  }
60913
60969
  return Math.max(0, available);
60914
60970
  }
60915
- account(accountId) {
60916
- if (!this.descendants(this.node).has(accountId))
60971
+ account(accountId2) {
60972
+ if (!this.descendants(this.node).has(accountId2))
60917
60973
  throw new Error("Token budget account is outside this subtree");
60918
- return new _SessionTokenBudget(this.ledger, accountId);
60974
+ return new _SessionTokenBudget(this.ledger, accountId2);
60919
60975
  }
60920
60976
  findTurn(turn) {
60921
60977
  const descendants = this.descendants(this.node);
@@ -60945,16 +61001,16 @@ var SessionTokenBudget = class _SessionTokenBudget {
60945
61001
  if (tokens === 0 && this.remaining !== Number.POSITIVE_INFINITY || tokens > this.remaining)
60946
61002
  throw new Error("Token budget cannot reserve the requested tokens");
60947
61003
  count4(this.totals(this.node).reserved + tokens, "reserved allowance");
60948
- const accountId = uuidv7();
60949
- this.ledger.accounts.set(accountId, {
60950
- id: accountId,
61004
+ const accountId2 = uuidv7();
61005
+ this.ledger.accounts.set(accountId2, {
61006
+ id: accountId2,
60951
61007
  parentId: this.accountId,
60952
61008
  limit: tokens,
60953
61009
  settled: false,
60954
61010
  usage: {}
60955
61011
  });
60956
61012
  this.persist();
60957
- return this.account(accountId);
61013
+ return this.account(accountId2);
60958
61014
  }
60959
61015
  /** Narrow the entire subtree; already measured spend and reservations remain. */
60960
61016
  narrow(limit) {
@@ -61153,8 +61209,8 @@ var SessionTokenBudget = class _SessionTokenBudget {
61153
61209
  get node() {
61154
61210
  return this.requireAccount(this.accountId);
61155
61211
  }
61156
- requireAccount(accountId) {
61157
- const account = this.ledger.accounts.get(accountId);
61212
+ requireAccount(accountId2) {
61213
+ const account = this.ledger.accounts.get(accountId2);
61158
61214
  if (!account)
61159
61215
  throw new Error("Unknown token budget account");
61160
61216
  return account;
@@ -61998,8 +62054,8 @@ async function resolveProviderContextWindow(provider, model, signal, timeoutMs,
61998
62054
  const resolverSignal = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
61999
62055
  const interrupted = /* @__PURE__ */ Symbol("provider-context-window-interrupted");
62000
62056
  let onAbort;
62001
- const interruption = new Promise((resolve32) => {
62002
- onAbort = /* @__PURE__ */ __name(() => resolve32(interrupted), "onAbort");
62057
+ const interruption = new Promise((resolve33) => {
62058
+ onAbort = /* @__PURE__ */ __name(() => resolve33(interrupted), "onAbort");
62003
62059
  resolverSignal.addEventListener("abort", onAbort, { once: true });
62004
62060
  });
62005
62061
  const deadlineMs = timeoutMs === 0 ? 5e3 : Math.min(Math.max(0, timeoutMs), 2147483647);
@@ -64161,8 +64217,8 @@ function createMockBidiProvider(script = {}) {
64161
64217
  }
64162
64218
  if (done)
64163
64219
  return;
64164
- await new Promise((resolve32) => {
64165
- wake = resolve32;
64220
+ await new Promise((resolve33) => {
64221
+ wake = resolve33;
64166
64222
  });
64167
64223
  wake = void 0;
64168
64224
  }
@@ -64430,8 +64486,8 @@ async function startBidiTurn(params) {
64430
64486
  }
64431
64487
  if (closed)
64432
64488
  return;
64433
- await new Promise((resolve32) => {
64434
- wake = resolve32;
64489
+ await new Promise((resolve33) => {
64490
+ wake = resolve33;
64435
64491
  });
64436
64492
  wake = void 0;
64437
64493
  }
@@ -68760,11 +68816,11 @@ function createMemoryRecallStep(options) {
68760
68816
  }, "recall");
68761
68817
  const pending2 = recall();
68762
68818
  pendingRecalls.set(options.store, pending2);
68763
- const release = /* @__PURE__ */ __name(() => {
68819
+ const release2 = /* @__PURE__ */ __name(() => {
68764
68820
  if (pendingRecalls.get(options.store) === pending2)
68765
68821
  pendingRecalls.delete(options.store);
68766
68822
  }, "release");
68767
- void pending2.then(release, release);
68823
+ void pending2.then(release2, release2);
68768
68824
  let timer;
68769
68825
  let onAbort;
68770
68826
  try {
@@ -70491,8 +70547,8 @@ var ALL_SLOTS = [
70491
70547
  var DEFAULT_MODULE_TIMEOUT_MS = 1e4;
70492
70548
  async function importWithDeadline(fileUrl, importModule, timeoutMs) {
70493
70549
  let timer;
70494
- const deadline = new Promise((resolve32) => {
70495
- timer = setTimeout(() => resolve32({ status: "abandoned" }), timeoutMs);
70550
+ const deadline = new Promise((resolve33) => {
70551
+ timer = setTimeout(() => resolve33({ status: "abandoned" }), timeoutMs);
70496
70552
  });
70497
70553
  try {
70498
70554
  const result = await Promise.race([
@@ -70946,7 +71002,7 @@ async function resolveForRun(entry, context2) {
70946
71002
  if (!context2.signal)
70947
71003
  return await entry.forRun(context2);
70948
71004
  const signal = context2.signal;
70949
- return await new Promise((resolve32, reject2) => {
71005
+ return await new Promise((resolve33, reject2) => {
70950
71006
  const onAbort = /* @__PURE__ */ __name(() => {
70951
71007
  signal.removeEventListener("abort", onAbort);
70952
71008
  reject2(signal.reason);
@@ -70956,7 +71012,7 @@ async function resolveForRun(entry, context2) {
70956
71012
  onAbort();
70957
71013
  return;
70958
71014
  }
70959
- Promise.resolve().then(() => entry.forRun(context2)).then(resolve32, reject2).finally(() => signal.removeEventListener("abort", onAbort));
71015
+ Promise.resolve().then(() => entry.forRun(context2)).then(resolve33, reject2).finally(() => signal.removeEventListener("abort", onAbort));
70960
71016
  });
70961
71017
  }
70962
71018
  __name(resolveForRun, "resolveForRun");
@@ -73569,15 +73625,15 @@ var DiskTaskStore = class {
73569
73625
  break;
73570
73626
  await existing.catch(() => void 0);
73571
73627
  }
73572
- let resolve32;
73628
+ let resolve33;
73573
73629
  const lock = new Promise((r) => {
73574
- resolve32 = r;
73630
+ resolve33 = r;
73575
73631
  });
73576
73632
  this.locks.set(taskId, lock);
73577
73633
  try {
73578
73634
  return await fn();
73579
73635
  } finally {
73580
- resolve32?.();
73636
+ resolve33?.();
73581
73637
  if (this.locks.get(taskId) === lock) {
73582
73638
  this.locks.delete(taskId);
73583
73639
  }
@@ -73590,15 +73646,15 @@ var DiskTaskStore = class {
73590
73646
  */
73591
73647
  async withLocks(taskIds, fn) {
73592
73648
  const unique = [...new Set(taskIds)].sort();
73593
- const acquire = /* @__PURE__ */ __name(async (i) => {
73649
+ const acquire2 = /* @__PURE__ */ __name(async (i) => {
73594
73650
  if (i >= unique.length)
73595
73651
  return fn();
73596
73652
  const nextId = unique[i];
73597
73653
  if (nextId === void 0)
73598
73654
  return fn();
73599
- return this.withLock(nextId, () => acquire(i + 1));
73655
+ return this.withLock(nextId, () => acquire2(i + 1));
73600
73656
  }, "acquire");
73601
- return acquire(0);
73657
+ return acquire2(0);
73602
73658
  }
73603
73659
  on(listener) {
73604
73660
  this.listeners.push(listener);
@@ -74407,12 +74463,12 @@ var DiskMemoryStore = class {
74407
74463
  }
74408
74464
  async withAuthoritativeIndex(operation) {
74409
74465
  const location = await this.storageLocation();
74410
- const release = await acquireMemoryOperationLock(join31(dirname16(location.indexPath), "operation.lock"), this.lockTimeoutMs);
74466
+ const release2 = await acquireMemoryOperationLock(join31(dirname16(location.indexPath), "operation.lock"), this.lockTimeoutMs);
74411
74467
  try {
74412
74468
  await this.reloadIndex(location);
74413
74469
  return await operation(location);
74414
74470
  } finally {
74415
- await release();
74471
+ await release2();
74416
74472
  }
74417
74473
  }
74418
74474
  async readContent(location, id3) {
@@ -75058,7 +75114,7 @@ var MarkdownMemoryStore = class {
75058
75114
  }
75059
75115
  async withLoaded(operation, mode = {}) {
75060
75116
  const dir = await this.location();
75061
- const release = await acquireMemoryOperationLock(join32(dir, "operation.lock"), this.lockTimeoutMs);
75117
+ const release2 = await acquireMemoryOperationLock(join32(dir, "operation.lock"), this.lockTimeoutMs);
75062
75118
  try {
75063
75119
  const { loaded, superseded } = await this.load(dir, mode.importing ?? false);
75064
75120
  if (mode.writes)
@@ -75066,7 +75122,7 @@ var MarkdownMemoryStore = class {
75066
75122
  await this.setAside(path3);
75067
75123
  return await operation(dir, loaded);
75068
75124
  } finally {
75069
- await release();
75125
+ await release2();
75070
75126
  }
75071
75127
  }
75072
75128
  /** {@link withLoaded} for an operation that writes. */
@@ -77442,7 +77498,7 @@ var StdioTransport = class {
77442
77498
  this.exitPending = false;
77443
77499
  return;
77444
77500
  }
77445
- await new Promise((resolve32) => {
77501
+ await new Promise((resolve33) => {
77446
77502
  let settled = false;
77447
77503
  const finish2 = /* @__PURE__ */ __name(() => {
77448
77504
  if (settled)
@@ -77450,7 +77506,7 @@ var StdioTransport = class {
77450
77506
  settled = true;
77451
77507
  clearTimeout(escalate);
77452
77508
  clearTimeout(giveUp);
77453
- resolve32();
77509
+ resolve33();
77454
77510
  }, "finish");
77455
77511
  child.once("close", finish2);
77456
77512
  child.once("error", finish2);
@@ -78406,7 +78462,7 @@ var MCPClient = class {
78406
78462
  capabilities: this.config.capabilities ?? {}
78407
78463
  });
78408
78464
  const controller = new AbortController();
78409
- return new Promise((resolve32) => {
78465
+ return new Promise((resolve33) => {
78410
78466
  let settled = false;
78411
78467
  const finish2 = /* @__PURE__ */ __name((answer) => {
78412
78468
  if (settled)
@@ -78415,7 +78471,7 @@ var MCPClient = class {
78415
78471
  clearTimeout(timer);
78416
78472
  if (this.pendingRequests.get(id3) === entry)
78417
78473
  this.pendingRequests.delete(id3);
78418
- resolve32(answer);
78474
+ resolve33(answer);
78419
78475
  }, "finish");
78420
78476
  const entry = {
78421
78477
  resolve: /* @__PURE__ */ __name((value) => finish2({ kind: "result", result: value }), "resolve"),
@@ -78989,8 +79045,8 @@ var MCPClient = class {
78989
79045
  let settled = false;
78990
79046
  let resolvePublic;
78991
79047
  let rejectPublic;
78992
- const result = new Promise((resolve32, reject2) => {
78993
- resolvePublic = resolve32;
79048
+ const result = new Promise((resolve33, reject2) => {
79049
+ resolvePublic = resolve33;
78994
79050
  rejectPublic = reject2;
78995
79051
  });
78996
79052
  const entry = {
@@ -81449,8 +81505,8 @@ var PluginLifecycleManager = class {
81449
81505
  this.removeContributedTool(name2);
81450
81506
  }
81451
81507
  } finally {
81452
- for (const release of contributions.configReleases)
81453
- release();
81508
+ for (const release2 of contributions.configReleases)
81509
+ release2();
81454
81510
  }
81455
81511
  }
81456
81512
  disable(pluginId) {
@@ -81784,21 +81840,21 @@ function guardedLookup(hostname, options, callback) {
81784
81840
  }
81785
81841
  __name(guardedLookup, "guardedLookup");
81786
81842
  function postHookJson(input) {
81787
- return new Promise((resolve32) => {
81843
+ return new Promise((resolve33) => {
81788
81844
  let url;
81789
81845
  try {
81790
81846
  url = new URL(input.url);
81791
81847
  } catch {
81792
- resolve32({ status: null, body: "", timedOut: false, error: "the url is not valid" });
81848
+ resolve33({ status: null, body: "", timedOut: false, error: "the url is not valid" });
81793
81849
  return;
81794
81850
  }
81795
81851
  if (url.protocol !== "http:" && url.protocol !== "https:") {
81796
- resolve32({ status: null, body: "", timedOut: false, error: "the url must be http or https" });
81852
+ resolve33({ status: null, body: "", timedOut: false, error: "the url must be http or https" });
81797
81853
  return;
81798
81854
  }
81799
81855
  const literal = url.hostname.replace(/^\[|\]$/g, "");
81800
81856
  if (isIP3(literal) !== 0 && !isReachableHookAddress(literal)) {
81801
- resolve32({
81857
+ resolve33({
81802
81858
  status: null,
81803
81859
  body: "",
81804
81860
  timedOut: false,
@@ -81823,7 +81879,7 @@ function postHookJson(input) {
81823
81879
  settled = true;
81824
81880
  clearTimeout(timer);
81825
81881
  input.signal?.removeEventListener("abort", onAbort);
81826
- resolve32(response);
81882
+ resolve33(response);
81827
81883
  }, "finish");
81828
81884
  const onAbort = /* @__PURE__ */ __name(() => {
81829
81885
  req.destroy();
@@ -81970,7 +82026,7 @@ function runShellHook(entry, input, signal) {
81970
82026
  const payload = shellHookPayload(input);
81971
82027
  const toolPath = pathOf(input.toolInput);
81972
82028
  const { NAMZU_TURN_ID: _inheritedTurnId, ...inherited } = process.env;
81973
- return new Promise((resolve32) => {
82029
+ return new Promise((resolve33) => {
81974
82030
  let child;
81975
82031
  try {
81976
82032
  const env = {
@@ -82001,7 +82057,7 @@ function runShellHook(entry, input, signal) {
82001
82057
  ...process.platform === "win32" ? {} : { shell: { path: "sh", dialect: "sh", source: "sh" } }
82002
82058
  });
82003
82059
  } catch (error) {
82004
- resolve32({
82060
+ resolve33({
82005
82061
  exitCode: null,
82006
82062
  timedOut: false,
82007
82063
  stdout: "",
@@ -82027,7 +82083,7 @@ function runShellHook(entry, input, signal) {
82027
82083
  settled = true;
82028
82084
  clearTimeout(timer);
82029
82085
  signal?.removeEventListener("abort", onAbort);
82030
- resolve32(outcome);
82086
+ resolve33(outcome);
82031
82087
  }, "finish");
82032
82088
  const killTree2 = /* @__PURE__ */ __name(() => {
82033
82089
  if (child.pid !== void 0 && process.platform !== "win32") {
@@ -82423,8 +82479,8 @@ ${json2}`;
82423
82479
  const combined = signal ? AbortSignal.any([signal, deadline]) : deadline;
82424
82480
  let reply;
82425
82481
  try {
82426
- reply = await new Promise((resolve32, reject2) => {
82427
- const stop = /* @__PURE__ */ __name(() => resolve32(void 0), "stop");
82482
+ reply = await new Promise((resolve33, reject2) => {
82483
+ const stop = /* @__PURE__ */ __name(() => resolve33(void 0), "stop");
82428
82484
  combined.addEventListener("abort", stop, { once: true });
82429
82485
  judge({
82430
82486
  instruction: PROMPT_HOOK_INSTRUCTION,
@@ -82432,7 +82488,7 @@ ${json2}`;
82432
82488
  sessionId: input.sessionId,
82433
82489
  ...input.turnId !== void 0 ? { turnId: input.turnId } : {},
82434
82490
  signal: combined
82435
- }).then(resolve32, reject2);
82491
+ }).then(resolve33, reject2);
82436
82492
  });
82437
82493
  } catch (error) {
82438
82494
  log.warn("prompt hook failed", {
@@ -82654,8 +82710,8 @@ async function settleWithSignal(operation, signal, acceptAfterAbort) {
82654
82710
  return operation;
82655
82711
  const settled = operation.then((value) => ({ kind: "fulfilled", value }), (reason2) => ({ kind: "rejected", reason: reason2 }));
82656
82712
  let onAbort;
82657
- const aborted = new Promise((resolve32) => {
82658
- onAbort = /* @__PURE__ */ __name(() => resolve32({ kind: "aborted" }), "onAbort");
82713
+ const aborted = new Promise((resolve33) => {
82714
+ onAbort = /* @__PURE__ */ __name(() => resolve33({ kind: "aborted" }), "onAbort");
82659
82715
  if (signal.aborted) {
82660
82716
  onAbort();
82661
82717
  return;
@@ -82674,8 +82730,8 @@ async function settleWithSignal(operation, signal, acceptAfterAbort) {
82674
82730
  let timer;
82675
82731
  const grace = await Promise.race([
82676
82732
  settled,
82677
- new Promise((resolve32) => {
82678
- timer = setTimeout(() => resolve32({ kind: "grace_elapsed" }), 0);
82733
+ new Promise((resolve33) => {
82734
+ timer = setTimeout(() => resolve33({ kind: "grace_elapsed" }), 0);
82679
82735
  })
82680
82736
  ]).finally(() => {
82681
82737
  if (timer !== void 0)
@@ -83451,21 +83507,21 @@ var RemoteExecutionContext = class extends BaseExecutionContext {
83451
83507
  trackCommand(invoke) {
83452
83508
  const ownership = /* @__PURE__ */ Symbol("remote-command");
83453
83509
  this.activeCommands.add(ownership);
83454
- const release = /* @__PURE__ */ __name(() => {
83510
+ const release2 = /* @__PURE__ */ __name(() => {
83455
83511
  this.activeCommands.delete(ownership);
83456
83512
  }, "release");
83457
83513
  let operation;
83458
83514
  try {
83459
83515
  operation = Promise.resolve(invoke());
83460
83516
  } catch (error) {
83461
- release();
83517
+ release2();
83462
83518
  return Promise.reject(error);
83463
83519
  }
83464
83520
  return operation.then((result) => {
83465
- release();
83521
+ release2();
83466
83522
  return result;
83467
83523
  }, (error) => {
83468
- release();
83524
+ release2();
83469
83525
  throw error;
83470
83526
  });
83471
83527
  }
@@ -85030,9 +85086,9 @@ var AgentManager = class {
85030
85086
  if (isTerminalAgentTaskState(agentTask.state)) {
85031
85087
  return Promise.resolve();
85032
85088
  }
85033
- return new Promise((resolve32) => {
85089
+ return new Promise((resolve33) => {
85034
85090
  const existing = this.completionCallbacks.get(taskId) ?? [];
85035
- existing.push(resolve32);
85091
+ existing.push(resolve33);
85036
85092
  this.completionCallbacks.set(taskId, existing);
85037
85093
  });
85038
85094
  }
@@ -85765,8 +85821,8 @@ var AgentManager = class {
85765
85821
  resolveCompletionCallbacks(taskId) {
85766
85822
  const callbacks = this.completionCallbacks.get(taskId);
85767
85823
  if (callbacks) {
85768
- for (const resolve32 of callbacks)
85769
- resolve32();
85824
+ for (const resolve33 of callbacks)
85825
+ resolve33();
85770
85826
  this.completionCallbacks.delete(taskId);
85771
85827
  }
85772
85828
  }
@@ -87308,7 +87364,7 @@ var MockLLMProvider = class {
87308
87364
  async delay() {
87309
87365
  if (this.responseDelayMs <= 0)
87310
87366
  return;
87311
- await new Promise((resolve32) => setTimeout(resolve32, this.responseDelayMs));
87367
+ await new Promise((resolve33) => setTimeout(resolve33, this.responseDelayMs));
87312
87368
  }
87313
87369
  /**
87314
87370
  * The turn to play. A script shorter than the turn repeats its last
@@ -89141,7 +89197,7 @@ function planWalk(root, options) {
89141
89197
  __name(planWalk, "planWalk");
89142
89198
  function directoryMatcher(plan) {
89143
89199
  const patterns = plan.patterns.map((set3) => set3.map((part2) => typeof part2 === "object" && part2 !== null ? new RegExp(part2.source, `${part2.flags}s`) : part2));
89144
- return (relative14) => patterns.some((pattern) => {
89200
+ return (relative15) => patterns.some((pattern) => {
89145
89201
  const closure = /* @__PURE__ */ __name((states2) => {
89146
89202
  for (const index of states2)
89147
89203
  if (pattern[index] === null)
@@ -89149,7 +89205,7 @@ function directoryMatcher(plan) {
89149
89205
  return states2;
89150
89206
  }, "closure");
89151
89207
  let states = closure(/* @__PURE__ */ new Set([0]));
89152
- for (const name2 of relative14.split("/")) {
89208
+ for (const name2 of relative15.split("/")) {
89153
89209
  const next2 = /* @__PURE__ */ new Set();
89154
89210
  for (const index of states) {
89155
89211
  const segment2 = pattern[index];
@@ -89269,14 +89325,14 @@ async function* executeWalk(plan, signal) {
89269
89325
  }
89270
89326
  if (plan.prefix.length >= maxDepth)
89271
89327
  return;
89272
- const openDirectory = /* @__PURE__ */ __name(async (absolute, relative14, depth) => {
89328
+ const openDirectory = /* @__PURE__ */ __name(async (absolute, relative15, depth) => {
89273
89329
  check2();
89274
89330
  try {
89275
89331
  const dir = await wait(fs.opendir(absolute), (late2) => {
89276
89332
  void close(late2).catch(() => {
89277
89333
  });
89278
89334
  });
89279
- open14.push({ dir, relative: relative14, depth });
89335
+ open14.push({ dir, relative: relative15, depth });
89280
89336
  } catch (error) {
89281
89337
  if (!missing2(error))
89282
89338
  throw error;
@@ -89294,15 +89350,15 @@ async function* executeWalk(plan, signal) {
89294
89350
  continue;
89295
89351
  }
89296
89352
  noteVisit();
89297
- const relative14 = frame.relative ? `${frame.relative}/${entry.name}` : entry.name;
89298
- const absolute = path3.join(plan.root, relative14);
89353
+ const relative15 = frame.relative ? `${frame.relative}/${entry.name}` : entry.name;
89354
+ const absolute = path3.join(plan.root, relative15);
89299
89355
  const depth = frame.depth + 1;
89300
89356
  if (entry.isDirectory()) {
89301
- if (depth < maxDepth && canDescend(relative14))
89302
- await openDirectory(absolute, relative14, depth);
89357
+ if (depth < maxDepth && canDescend(relative15))
89358
+ await openDirectory(absolute, relative15, depth);
89303
89359
  continue;
89304
89360
  }
89305
- if (!entry.isFile() || !matchers.some((matcher) => matcher.test(relative14)))
89361
+ if (!entry.isFile() || !matchers.some((matcher) => matcher.test(relative15)))
89306
89362
  continue;
89307
89363
  let info;
89308
89364
  try {
@@ -89374,8 +89430,8 @@ async function* walkFilesViaExec(exec, rootPath, options) {
89374
89430
  if (record3.type !== "entry" || typeof record3.path !== "string" || typeof record3.size !== "number" || !Number.isSafeInteger(record3.size) || record3.size < 0) {
89375
89431
  throw new Error("Invalid file walk entry");
89376
89432
  }
89377
- const relative14 = posix2.relative(rootPath, record3.path);
89378
- if (!posix2.isAbsolute(record3.path) || relative14 === ".." || relative14.startsWith("../") || posix2.isAbsolute(relative14)) {
89433
+ const relative15 = posix2.relative(rootPath, record3.path);
89434
+ if (!posix2.isAbsolute(record3.path) || relative15 === ".." || relative15.startsWith("../") || posix2.isAbsolute(relative15)) {
89379
89435
  throw new Error("File walk entry escaped its requested root");
89380
89436
  }
89381
89437
  if (++received > plan.maxEntries)
@@ -89444,8 +89500,8 @@ async function* walkFilesViaExec(exec, rootPath, options) {
89444
89500
  throw failure2;
89445
89501
  if (settled)
89446
89502
  break;
89447
- await new Promise((resolve32) => {
89448
- wake = resolve32;
89503
+ await new Promise((resolve33) => {
89504
+ wake = resolve33;
89449
89505
  });
89450
89506
  wake = void 0;
89451
89507
  }
@@ -92797,8 +92853,8 @@ function operationBoundary(options) {
92797
92853
  let cause;
92798
92854
  let transportAbortArmed = options.abortTransportInitially;
92799
92855
  let resolveStopped;
92800
- const stopped = new Promise((resolve32) => {
92801
- resolveStopped = resolve32;
92856
+ const stopped = new Promise((resolve33) => {
92857
+ resolveStopped = resolve33;
92802
92858
  });
92803
92859
  const stop = /* @__PURE__ */ __name((next2) => {
92804
92860
  if (cause !== void 0)
@@ -93036,8 +93092,8 @@ var A2ADelegate = class {
93036
93092
  */
93037
93093
  async recoverInitialTask(request) {
93038
93094
  let timer;
93039
- const expired = new Promise((resolve32) => {
93040
- timer = setTimeout(() => resolve32(void 0), PEER_CANCEL_GRACE_MS);
93095
+ const expired = new Promise((resolve33) => {
93096
+ timer = setTimeout(() => resolve33(void 0), PEER_CANCEL_GRACE_MS);
93041
93097
  });
93042
93098
  try {
93043
93099
  const recovered = await Promise.race([
@@ -93131,7 +93187,7 @@ var A2ADelegate = class {
93131
93187
  };
93132
93188
  function sleep2(ms, signal) {
93133
93189
  signal.throwIfAborted();
93134
- return new Promise((resolve32, reject2) => {
93190
+ return new Promise((resolve33, reject2) => {
93135
93191
  let settled = false;
93136
93192
  const cleanup = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "cleanup");
93137
93193
  const onAbort = /* @__PURE__ */ __name(() => {
@@ -93147,7 +93203,7 @@ function sleep2(ms, signal) {
93147
93203
  return;
93148
93204
  settled = true;
93149
93205
  cleanup();
93150
- resolve32();
93206
+ resolve33();
93151
93207
  }, ms);
93152
93208
  signal.addEventListener("abort", onAbort, { once: true });
93153
93209
  if (signal.aborted)
@@ -94001,7 +94057,7 @@ var ACPServer = class {
94001
94057
  request(method, params, signal) {
94002
94058
  this.requestSeq += 1;
94003
94059
  const id3 = `agent_${this.requestSeq}`;
94004
- return new Promise((resolve32, reject2) => {
94060
+ return new Promise((resolve33, reject2) => {
94005
94061
  const finish2 = /* @__PURE__ */ __name(() => {
94006
94062
  if (this.pending.get(id3) !== entry)
94007
94063
  return false;
@@ -94016,7 +94072,7 @@ var ACPServer = class {
94016
94072
  const entry = {
94017
94073
  resolve: /* @__PURE__ */ __name((value) => {
94018
94074
  if (finish2())
94019
- resolve32(value);
94075
+ resolve33(value);
94020
94076
  }, "resolve"),
94021
94077
  reject: /* @__PURE__ */ __name((error) => {
94022
94078
  if (finish2())
@@ -94706,7 +94762,7 @@ var FileLockManager = class {
94706
94762
  return immediate;
94707
94763
  const deadline = Date.now() + this.config.acquireTimeoutMs;
94708
94764
  while (Date.now() < deadline) {
94709
- await new Promise((resolve32) => setTimeout(resolve32, LOCK_ACQUIRE_POLL_INTERVAL_MS));
94765
+ await new Promise((resolve33) => setTimeout(resolve33, LOCK_ACQUIRE_POLL_INTERVAL_MS));
94710
94766
  this.expireStale();
94711
94767
  const retry = this.tryAcquire(filePath, owner);
94712
94768
  if (retry.acquired)
@@ -97347,10 +97403,10 @@ var DiskSessionStore = class {
97347
97403
  async withSessionWrite(sessionId5, operation) {
97348
97404
  const key6 = resolve20(this.rootDir, sessionId5);
97349
97405
  const previous = sessionWriters.get(key6) ?? Promise.resolve();
97350
- let release = /* @__PURE__ */ __name(() => {
97406
+ let release2 = /* @__PURE__ */ __name(() => {
97351
97407
  }, "release");
97352
97408
  const held3 = new Promise((resolveWrite) => {
97353
- release = resolveWrite;
97409
+ release2 = resolveWrite;
97354
97410
  });
97355
97411
  const tail = previous.then(() => held3);
97356
97412
  sessionWriters.set(key6, tail);
@@ -97358,7 +97414,7 @@ var DiskSessionStore = class {
97358
97414
  try {
97359
97415
  return await operation();
97360
97416
  } finally {
97361
- release();
97417
+ release2();
97362
97418
  if (sessionWriters.get(key6) === tail)
97363
97419
  sessionWriters.delete(key6);
97364
97420
  }
@@ -100062,12 +100118,12 @@ function openTerminalWith(pty, options, defaults2) {
100062
100118
  for (const listener of listeners)
100063
100119
  listener(chunk);
100064
100120
  });
100065
- const exited = new Promise((resolve32) => {
100121
+ const exited = new Promise((resolve33) => {
100066
100122
  const exitSub = child.onExit((event) => {
100067
100123
  dataSub.dispose();
100068
100124
  exitSub.dispose();
100069
100125
  listeners.clear();
100070
- resolve32(event);
100126
+ resolve33(event);
100071
100127
  });
100072
100128
  });
100073
100129
  return {
@@ -104391,8 +104447,19 @@ var PeerRecordSchema = external_exports.object({
104391
104447
  address: external_exports.string().min(1),
104392
104448
  token: external_exports.string().min(1),
104393
104449
  protocol: external_exports.literal(PEER_PROTOCOL_VERSION),
104394
- cliVersion: external_exports.string()
104450
+ cliVersion: external_exports.string(),
104451
+ /** The slot a spaces host gave this terminal at launch; how the host finds its own sessions. */
104452
+ hostSlot: external_exports.string().min(1).max(128).optional(),
104453
+ /** The conversation this terminal is on, once it has one. */
104454
+ conversationId: external_exports.string().min(1).optional(),
104455
+ /** The label of the non-default account the conversation is bound to; absent for the default. */
104456
+ account: external_exports.string().min(1).optional(),
104457
+ /** True while the bound account is out of allowance and the terminal is waiting for a choice. */
104458
+ limited: external_exports.boolean().optional(),
104459
+ /** When the allowance is expected back (epoch ms); absent when the provider did not say. */
104460
+ limitedUntil: external_exports.number().int().positive().optional()
104395
104461
  }).strict();
104462
+ var PeerRecordReaderSchema = PeerRecordSchema.strip();
104396
104463
  var PEER_REF_HEX_LENGTH = 6;
104397
104464
  function derivePeerRef(sessionId5) {
104398
104465
  return createHash32("sha256").update(sessionId5, "utf8").digest("hex").slice(0, PEER_REF_HEX_LENGTH);
@@ -104422,7 +104489,7 @@ function connectPath(address2) {
104422
104489
  }
104423
104490
  __name(connectPath, "connectPath");
104424
104491
  function sendPeerRequest(address2, request, parseResponse, timeoutMs) {
104425
- return new Promise((resolve32) => {
104492
+ return new Promise((resolve33) => {
104426
104493
  let settled = false;
104427
104494
  const finish2 = /* @__PURE__ */ __name((result) => {
104428
104495
  if (settled)
@@ -104430,7 +104497,7 @@ function sendPeerRequest(address2, request, parseResponse, timeoutMs) {
104430
104497
  settled = true;
104431
104498
  clearTimeout(timer);
104432
104499
  socket.destroy();
104433
- resolve32(result);
104500
+ resolve33(result);
104434
104501
  }, "finish");
104435
104502
  const unreachable = /* @__PURE__ */ __name((error) => finish2({
104436
104503
  kind: "unreachable",
@@ -104442,7 +104509,7 @@ function sendPeerRequest(address2, request, parseResponse, timeoutMs) {
104442
104509
  path3 = connectPath(address2);
104443
104510
  } catch (error) {
104444
104511
  clearTimeout(timer);
104445
- resolve32({
104512
+ resolve33({
104446
104513
  kind: "unreachable",
104447
104514
  reason: error instanceof Error ? error.message : String(error)
104448
104515
  });
@@ -104571,7 +104638,7 @@ function parseRecordText(text10) {
104571
104638
  } catch {
104572
104639
  return void 0;
104573
104640
  }
104574
- const result = PeerRecordSchema.safeParse(parsed);
104641
+ const result = PeerRecordReaderSchema.safeParse(parsed);
104575
104642
  return result.success ? result.data : void 0;
104576
104643
  }
104577
104644
  __name(parseRecordText, "parseRecordText");
@@ -104991,23 +105058,23 @@ async function createPeerEndpoint(options) {
104991
105058
  void handleLine(buffered.subarray(0, newline)).catch(() => socket.destroy());
104992
105059
  });
104993
105060
  });
104994
- await new Promise((resolve32, reject2) => {
105061
+ await new Promise((resolve33, reject2) => {
104995
105062
  const failed = /* @__PURE__ */ __name((error) => reject2(error), "failed");
104996
105063
  server.once("error", failed);
104997
105064
  server.listen({ path: listenPath }, () => {
104998
105065
  server.removeListener("error", failed);
104999
- resolve32();
105066
+ resolve33();
105000
105067
  });
105001
105068
  });
105002
105069
  server.on("error", () => {
105003
105070
  });
105004
105071
  if (parsed.scheme === "uds")
105005
105072
  chmodSync2(listenPath, 384);
105006
- const close = /* @__PURE__ */ __name(() => new Promise((resolve32) => {
105073
+ const close = /* @__PURE__ */ __name(() => new Promise((resolve33) => {
105007
105074
  closing = true;
105008
105075
  for (const socket of sockets)
105009
105076
  socket.destroy();
105010
- server.close(() => resolve32());
105077
+ server.close(() => resolve33());
105011
105078
  }), "close");
105012
105079
  return {
105013
105080
  address: options.address,
@@ -105097,10 +105164,533 @@ function formatPeerNotice(notice) {
105097
105164
  }
105098
105165
  __name(formatPeerNotice, "formatPeerNotice");
105099
105166
 
105167
+ // ../sdk/dist/account/registry.js
105168
+ import { randomBytes as randomBytes11 } from "node:crypto";
105169
+ import { chmodSync as chmodSync3, closeSync as closeSync4, fsyncSync as fsyncSync3, mkdirSync as mkdirSync8, openSync as openSync4, readFileSync as readFileSync6, realpathSync as realpathSync6, renameSync as renameSync2, rmSync as rmSync2, unlinkSync as unlinkSync4, writeSync as writeSync3 } from "node:fs";
105170
+ import { basename as basename13, dirname as dirname25, isAbsolute as isAbsolute12, join as join48, relative as relative9, resolve as resolve25 } from "node:path";
105171
+
105172
+ // ../sdk/dist/account/lock.js
105173
+ import { randomBytes as randomBytes10 } from "node:crypto";
105174
+ import { closeSync as closeSync3, mkdirSync as mkdirSync7, openSync as openSync3, readFileSync as readFileSync5, rmSync, writeSync as writeSync2 } from "node:fs";
105175
+ import { dirname as dirname24, join as join47 } from "node:path";
105176
+
105177
+ // ../sdk/dist/account/types.js
105178
+ var DEFAULT_ACCOUNT_LABEL = "default";
105179
+ var CredentialWithdrawnError = class extends Error {
105180
+ static {
105181
+ __name(this, "CredentialWithdrawnError");
105182
+ }
105183
+ accountId;
105184
+ name = "CredentialWithdrawnError";
105185
+ constructor(accountId2, message) {
105186
+ super(message);
105187
+ this.accountId = accountId2;
105188
+ }
105189
+ };
105190
+ var AccountRegistryError = class extends Error {
105191
+ static {
105192
+ __name(this, "AccountRegistryError");
105193
+ }
105194
+ name = "AccountRegistryError";
105195
+ };
105196
+ var AccountLockError = class extends Error {
105197
+ static {
105198
+ __name(this, "AccountLockError");
105199
+ }
105200
+ lockPath;
105201
+ name = "AccountLockError";
105202
+ constructor(lockPath, message) {
105203
+ super(message);
105204
+ this.lockPath = lockPath;
105205
+ }
105206
+ };
105207
+
105208
+ // ../sdk/dist/account/lock.js
105209
+ function codexRefreshLockPath(dir) {
105210
+ return join47(dir, "auth.json.namzu.lock");
105211
+ }
105212
+ __name(codexRefreshLockPath, "codexRefreshLockPath");
105213
+ function acquire(lockPath) {
105214
+ const token = `${process.pid}:${Date.now()}:${randomBytes10(12).toString("hex")}`;
105215
+ mkdirSync7(dirname24(lockPath), { recursive: true, mode: 448 });
105216
+ for (let pass = 0; pass < 2; pass++) {
105217
+ let fd;
105218
+ try {
105219
+ fd = openSync3(lockPath, "wx", 384);
105220
+ } catch (error) {
105221
+ if (error.code !== "EEXIST")
105222
+ throw error;
105223
+ if (pass === 0 && reclaimIfStale(lockPath))
105224
+ continue;
105225
+ return void 0;
105226
+ }
105227
+ try {
105228
+ writeSync2(fd, token);
105229
+ } finally {
105230
+ closeSync3(fd);
105231
+ }
105232
+ return token;
105233
+ }
105234
+ return void 0;
105235
+ }
105236
+ __name(acquire, "acquire");
105237
+ function pidOf(token) {
105238
+ const pid = Number.parseInt(token.split(":", 1)[0] ?? "", 10);
105239
+ return Number.isInteger(pid) && pid > 0 ? pid : void 0;
105240
+ }
105241
+ __name(pidOf, "pidOf");
105242
+ function processIsDead(pid) {
105243
+ try {
105244
+ process.kill(pid, 0);
105245
+ return false;
105246
+ } catch (error) {
105247
+ return error.code === "ESRCH";
105248
+ }
105249
+ }
105250
+ __name(processIsDead, "processIsDead");
105251
+ function reclaimIfStale(lockPath) {
105252
+ let observed;
105253
+ try {
105254
+ observed = readFileSync5(lockPath, "utf8");
105255
+ } catch {
105256
+ return true;
105257
+ }
105258
+ const pid = pidOf(observed);
105259
+ if (pid === void 0 || !processIsDead(pid))
105260
+ return false;
105261
+ const guard = `${lockPath}.reclaim`;
105262
+ let fd;
105263
+ try {
105264
+ fd = openSync3(guard, "wx", 384);
105265
+ } catch (error) {
105266
+ if (error.code !== "EEXIST")
105267
+ throw error;
105268
+ try {
105269
+ const holder = pidOf(readFileSync5(guard, "utf8"));
105270
+ if (holder !== void 0 && processIsDead(holder))
105271
+ rmSync(guard, { force: true });
105272
+ } catch {
105273
+ }
105274
+ return false;
105275
+ }
105276
+ try {
105277
+ writeSync2(fd, `${process.pid}`);
105278
+ closeSync3(fd);
105279
+ let again;
105280
+ try {
105281
+ again = readFileSync5(lockPath, "utf8");
105282
+ } catch {
105283
+ return true;
105284
+ }
105285
+ if (again !== observed)
105286
+ return false;
105287
+ rmSync(lockPath, { force: true });
105288
+ return true;
105289
+ } finally {
105290
+ rmSync(guard, { force: true });
105291
+ }
105292
+ }
105293
+ __name(reclaimIfStale, "reclaimIfStale");
105294
+ function release(lockPath, token) {
105295
+ try {
105296
+ if (readFileSync5(lockPath, "utf8") === token)
105297
+ rmSync(lockPath, { force: true });
105298
+ } catch {
105299
+ }
105300
+ }
105301
+ __name(release, "release");
105302
+ function refusal(lockPath) {
105303
+ return new AccountLockError(lockPath, `another owner holds the account lock ${lockPath}. The lock is reclaimed on its own when the process that recorded it has exited; if that process is still running, wait for it to finish.`);
105304
+ }
105305
+ __name(refusal, "refusal");
105306
+ async function withAccountLock(lockPath, operation, options = {}) {
105307
+ const attempts2 = Math.max(1, options.attempts ?? 1);
105308
+ let token;
105309
+ for (let attempt = 0; attempt < attempts2; attempt++) {
105310
+ token = acquire(lockPath);
105311
+ if (token !== void 0)
105312
+ break;
105313
+ if (attempt + 1 < attempts2 && options.wait)
105314
+ await options.wait(attempt);
105315
+ }
105316
+ if (token === void 0)
105317
+ throw refusal(lockPath);
105318
+ try {
105319
+ return await operation();
105320
+ } finally {
105321
+ release(lockPath, token);
105322
+ }
105323
+ }
105324
+ __name(withAccountLock, "withAccountLock");
105325
+ function withAccountLockSync(lockPath, operation, options = {}) {
105326
+ const attempts2 = Math.max(1, options.attempts ?? 1);
105327
+ let token;
105328
+ for (let attempt = 0; attempt < attempts2; attempt++) {
105329
+ token = acquire(lockPath);
105330
+ if (token !== void 0)
105331
+ break;
105332
+ if (attempt + 1 < attempts2 && options.wait)
105333
+ options.wait(attempt);
105334
+ }
105335
+ if (token === void 0)
105336
+ throw refusal(lockPath);
105337
+ try {
105338
+ return operation();
105339
+ } finally {
105340
+ release(lockPath, token);
105341
+ }
105342
+ }
105343
+ __name(withAccountLockSync, "withAccountLockSync");
105344
+ function withAccountRefreshLock(dir, operation, options = {}) {
105345
+ return withAccountLock(codexRefreshLockPath(dir), operation, options);
105346
+ }
105347
+ __name(withAccountRefreshLock, "withAccountRefreshLock");
105348
+
105349
+ // ../sdk/dist/account/registry.js
105350
+ var ACCOUNTS_FILE_NAME = "accounts.json";
105351
+ var ACCOUNTS_FILE_VERSION = 1;
105352
+ var LABEL = /^[a-z0-9-]{1,32}$/;
105353
+ var CODEX_PROVIDER = "codex";
105354
+ var PROVIDER = /^[a-z0-9][a-z0-9._-]{0,63}$/;
105355
+ var SourceSchema = external_exports.discriminatedUnion("kind", [
105356
+ external_exports.object({ kind: external_exports.literal("codex-home"), dir: external_exports.string().min(1) }).passthrough(),
105357
+ external_exports.object({ kind: external_exports.literal("api-key"), keyRef: external_exports.string().min(1) }).passthrough()
105358
+ ]);
105359
+ var AccountSchema = external_exports.object({
105360
+ id: external_exports.string().min(1),
105361
+ provider: external_exports.string().min(1),
105362
+ label: external_exports.string().min(1),
105363
+ source: SourceSchema,
105364
+ createdAt: external_exports.string(),
105365
+ display: external_exports.string().optional(),
105366
+ baseUrl: external_exports.string().optional(),
105367
+ defaultModel: external_exports.string().optional()
105368
+ }).passthrough();
105369
+ var FileSchema = external_exports.object({
105370
+ version: external_exports.literal(ACCOUNTS_FILE_VERSION),
105371
+ accounts: external_exports.array(AccountSchema),
105372
+ keys: external_exports.record(external_exports.string())
105373
+ }).passthrough();
105374
+ function sleepBlocking() {
105375
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25);
105376
+ }
105377
+ __name(sleepBlocking, "sleepBlocking");
105378
+ function accountId(provider, label6) {
105379
+ return `${provider}:${label6}`;
105380
+ }
105381
+ __name(accountId, "accountId");
105382
+ function parseAccountId(id3) {
105383
+ const at = id3.indexOf(":");
105384
+ if (at <= 0 || at === id3.length - 1)
105385
+ return void 0;
105386
+ return { provider: id3.slice(0, at), label: id3.slice(at + 1) };
105387
+ }
105388
+ __name(parseAccountId, "parseAccountId");
105389
+ function writeAtomic(path3, text10) {
105390
+ const temporary = join48(dirname25(path3), `.${randomBytes11(8).toString("hex")}.accounts.tmp`);
105391
+ const fd = openSync4(temporary, "wx", 384);
105392
+ try {
105393
+ writeSync3(fd, text10);
105394
+ fsyncSync3(fd);
105395
+ } finally {
105396
+ closeSync4(fd);
105397
+ }
105398
+ try {
105399
+ renameSync2(temporary, path3);
105400
+ } catch (error) {
105401
+ try {
105402
+ unlinkSync4(temporary);
105403
+ } catch {
105404
+ }
105405
+ throw error;
105406
+ }
105407
+ }
105408
+ __name(writeAtomic, "writeAtomic");
105409
+ function createAccountRegistry(options = {}) {
105410
+ const home = options.home ?? resolveNamzuHome();
105411
+ const path3 = join48(home, ACCOUNTS_FILE_NAME);
105412
+ const lockPath = `${path3}.lock`;
105413
+ const accountsRoot = join48(home, "accounts");
105414
+ const now = options.now ?? (() => /* @__PURE__ */ new Date());
105415
+ function defaultAccount(provider) {
105416
+ return {
105417
+ id: accountId(provider, DEFAULT_ACCOUNT_LABEL),
105418
+ provider,
105419
+ label: DEFAULT_ACCOUNT_LABEL,
105420
+ source: { kind: "existing-default" },
105421
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString()
105422
+ };
105423
+ }
105424
+ __name(defaultAccount, "defaultAccount");
105425
+ function read() {
105426
+ let text10;
105427
+ try {
105428
+ text10 = readFileSync6(path3, "utf8");
105429
+ } catch (error) {
105430
+ if (error.code === "ENOENT") {
105431
+ return { version: ACCOUNTS_FILE_VERSION, accounts: [], keys: {} };
105432
+ }
105433
+ throw error;
105434
+ }
105435
+ let json2;
105436
+ try {
105437
+ json2 = JSON.parse(text10);
105438
+ } catch {
105439
+ throw new AccountRegistryError(`${path3} is not valid JSON; no account was changed.`);
105440
+ }
105441
+ const parsed = FileSchema.safeParse(json2);
105442
+ if (!parsed.success) {
105443
+ throw new AccountRegistryError(`${path3} is not a version ${ACCOUNTS_FILE_VERSION} account store.`);
105444
+ }
105445
+ return parsed.data;
105446
+ }
105447
+ __name(read, "read");
105448
+ function mutate2(change) {
105449
+ mkdirSync8(home, { recursive: true, mode: 448 });
105450
+ return withAccountLockSync(lockPath, () => {
105451
+ const file = read();
105452
+ const result = change(file);
105453
+ writeAtomic(path3, `${JSON.stringify(file, null, 2)}
105454
+ `);
105455
+ try {
105456
+ chmodSync3(path3, 384);
105457
+ } catch {
105458
+ }
105459
+ return result;
105460
+ }, { attempts: 80, wait: options.lockWait ?? sleepBlocking });
105461
+ }
105462
+ __name(mutate2, "mutate");
105463
+ function ownDir(source) {
105464
+ return String(source.dir);
105465
+ }
105466
+ __name(ownDir, "ownDir");
105467
+ function toAccount(stored) {
105468
+ return stored;
105469
+ }
105470
+ __name(toAccount, "toAccount");
105471
+ function checkLabel(label6) {
105472
+ if (!LABEL.test(label6)) {
105473
+ throw new AccountRegistryError("An account label is 1 to 32 characters: lowercase letters, digits and hyphens.");
105474
+ }
105475
+ if (label6 === DEFAULT_ACCOUNT_LABEL) {
105476
+ throw new AccountRegistryError('The label "default" belongs to the existing sign-in.');
105477
+ }
105478
+ }
105479
+ __name(checkLabel, "checkLabel");
105480
+ function checkEndpointAndModel(input) {
105481
+ if (input.baseUrl !== void 0) {
105482
+ let url;
105483
+ try {
105484
+ url = new URL(input.baseUrl);
105485
+ } catch {
105486
+ throw new AccountRegistryError("The base URL is not a valid address.");
105487
+ }
105488
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
105489
+ throw new AccountRegistryError("The base URL must start with https:// or http://.");
105490
+ }
105491
+ if (url.username !== "" || url.password !== "") {
105492
+ throw new AccountRegistryError("The base URL must not contain a user name or password.");
105493
+ }
105494
+ }
105495
+ if (input.defaultModel !== void 0 && !/^\S{1,200}$/.test(input.defaultModel)) {
105496
+ throw new AccountRegistryError("The default model is one name of up to 200 characters.");
105497
+ }
105498
+ }
105499
+ __name(checkEndpointAndModel, "checkEndpointAndModel");
105500
+ function realOrSelf(target) {
105501
+ let existing = resolve25(target);
105502
+ const rest = [];
105503
+ for (; ; ) {
105504
+ try {
105505
+ return join48(realpathSync6(existing), ...rest.reverse());
105506
+ } catch {
105507
+ const parent = dirname25(existing);
105508
+ if (parent === existing)
105509
+ return resolve25(target);
105510
+ rest.push(basename13(existing));
105511
+ existing = parent;
105512
+ }
105513
+ }
105514
+ }
105515
+ __name(realOrSelf, "realOrSelf");
105516
+ function insideAccountsRoot(dir) {
105517
+ const rel = relative9(realOrSelf(accountsRoot), realOrSelf(dir));
105518
+ return rel !== "" && !rel.startsWith("..") && !isAbsolute12(rel);
105519
+ }
105520
+ __name(insideAccountsRoot, "insideAccountsRoot");
105521
+ function nests(outer, inner) {
105522
+ const rel = relative9(realOrSelf(outer), realOrSelf(inner));
105523
+ return rel === "" || !rel.startsWith("..") && !isAbsolute12(rel);
105524
+ }
105525
+ __name(nests, "nests");
105526
+ const registry = {
105527
+ list(provider) {
105528
+ const stored = read().accounts.map(toAccount);
105529
+ const providers2 = /* @__PURE__ */ new Set([
105530
+ ...options.defaultProviders ?? [],
105531
+ ...stored.map((a) => a.provider)
105532
+ ]);
105533
+ if (provider !== void 0)
105534
+ providers2.add(provider);
105535
+ const defaults2 = [...providers2].filter((p) => provider === void 0 || p === provider).map(defaultAccount);
105536
+ return [
105537
+ ...defaults2,
105538
+ ...stored.filter((a) => provider === void 0 || a.provider === provider)
105539
+ ];
105540
+ },
105541
+ get(id3) {
105542
+ const parsed = parseAccountId(id3);
105543
+ if (!parsed)
105544
+ return void 0;
105545
+ if (parsed.label === DEFAULT_ACCOUNT_LABEL)
105546
+ return defaultAccount(parsed.provider);
105547
+ const stored = read().accounts.find((a) => a.id === id3);
105548
+ return stored ? toAccount(stored) : void 0;
105549
+ },
105550
+ add(input) {
105551
+ if (!PROVIDER.test(input.provider)) {
105552
+ throw new AccountRegistryError("The provider name is not valid.");
105553
+ }
105554
+ checkLabel(input.label);
105555
+ const id3 = accountId(input.provider, input.label);
105556
+ return mutate2((file) => {
105557
+ if (file.accounts.some((a) => a.id === id3)) {
105558
+ throw new AccountRegistryError(`There is already an account labelled "${input.label}".`);
105559
+ }
105560
+ let source;
105561
+ if (input.kind === "api-key") {
105562
+ if (input.apiKey.length === 0)
105563
+ throw new AccountRegistryError("The API key is empty.");
105564
+ checkEndpointAndModel(input);
105565
+ const keyRef = `key-${randomBytes11(9).toString("hex")}`;
105566
+ file.keys[keyRef] = input.apiKey;
105567
+ source = { kind: "api-key", keyRef };
105568
+ } else {
105569
+ if (input.provider !== CODEX_PROVIDER) {
105570
+ throw new AccountRegistryError("A Codex home account belongs to the codex provider only.");
105571
+ }
105572
+ const dir = resolve25(input.dir ?? join48(accountsRoot, "codex", input.label));
105573
+ if (!insideAccountsRoot(dir)) {
105574
+ throw new AccountRegistryError("A Codex account directory must live under the Namzu accounts folder.");
105575
+ }
105576
+ if (file.accounts.some((a) => a.source.kind === "codex-home" && (nests(a.source.dir, dir) || nests(dir, a.source.dir)))) {
105577
+ throw new AccountRegistryError("Another account already uses that Codex directory, or one inside or around it.");
105578
+ }
105579
+ mkdirSync8(dir, { recursive: true, mode: 448 });
105580
+ source = { kind: "codex-home", dir };
105581
+ }
105582
+ const account = {
105583
+ id: id3,
105584
+ provider: input.provider,
105585
+ label: input.label,
105586
+ source,
105587
+ createdAt: now().toISOString(),
105588
+ ...input.display !== void 0 ? { display: input.display } : {},
105589
+ ...input.kind === "api-key" && input.baseUrl !== void 0 ? { baseUrl: input.baseUrl } : {},
105590
+ ...input.kind === "api-key" && input.defaultModel !== void 0 ? { defaultModel: input.defaultModel } : {}
105591
+ };
105592
+ file.accounts.push(account);
105593
+ return account;
105594
+ });
105595
+ },
105596
+ rename(id3, label6) {
105597
+ checkLabel(label6);
105598
+ return mutate2((file) => {
105599
+ const index = file.accounts.findIndex((a) => a.id === id3);
105600
+ const current = file.accounts[index];
105601
+ if (!current)
105602
+ throw new AccountRegistryError("No such account.");
105603
+ const nextId = accountId(current.provider, label6);
105604
+ if (file.accounts.some((a) => a.id === nextId)) {
105605
+ throw new AccountRegistryError(`There is already an account labelled "${label6}".`);
105606
+ }
105607
+ const renamed2 = { ...current, id: nextId, label: label6 };
105608
+ file.accounts[index] = renamed2;
105609
+ return toAccount(renamed2);
105610
+ });
105611
+ },
105612
+ remove(id3) {
105613
+ const parsed = parseAccountId(id3);
105614
+ if (parsed?.label === DEFAULT_ACCOUNT_LABEL) {
105615
+ throw new AccountRegistryError("The existing sign-in is not an account that can be removed.");
105616
+ }
105617
+ mutate2((file) => {
105618
+ const index = file.accounts.findIndex((a) => a.id === id3);
105619
+ const current = file.accounts[index];
105620
+ if (!current)
105621
+ throw new AccountRegistryError("No such account.");
105622
+ file.accounts.splice(index, 1);
105623
+ if (current.source.kind === "api-key") {
105624
+ delete file.keys[current.source.keyRef];
105625
+ } else if (insideAccountsRoot(ownDir(current.source)) && !file.accounts.some((a) => a.source.kind === "codex-home" && nests(ownDir(current.source), a.source.dir))) {
105626
+ rmSync2(ownDir(current.source), { recursive: true, force: true });
105627
+ }
105628
+ });
105629
+ },
105630
+ async resolve(id3, signal) {
105631
+ const account = registry.get(id3);
105632
+ if (!account)
105633
+ throw new CredentialWithdrawnError(id3, "That account no longer exists.");
105634
+ const { source } = account;
105635
+ if (source.kind === "existing-default") {
105636
+ if (!options.readers?.existingDefault) {
105637
+ throw new CredentialWithdrawnError(id3, "No reader is configured for the existing sign-in.");
105638
+ }
105639
+ return options.readers.existingDefault(account.provider, signal);
105640
+ }
105641
+ if (source.kind === "codex-home") {
105642
+ if (account.provider !== CODEX_PROVIDER) {
105643
+ throw new CredentialWithdrawnError(id3, "A Codex home is only valid for the codex provider.");
105644
+ }
105645
+ if (!options.readers?.codexHome) {
105646
+ throw new CredentialWithdrawnError(id3, "No reader is configured for Codex accounts.");
105647
+ }
105648
+ return options.readers.codexHome(account, signal);
105649
+ }
105650
+ const secret = read().keys[source.keyRef];
105651
+ if (secret === void 0) {
105652
+ throw new CredentialWithdrawnError(id3, "The saved key for this account is missing.");
105653
+ }
105654
+ return {
105655
+ kind: "api-key",
105656
+ accessToken: secret,
105657
+ ...account.baseUrl !== void 0 ? { baseUrl: account.baseUrl } : {},
105658
+ ...account.defaultModel !== void 0 ? { defaultModel: account.defaultModel } : {}
105659
+ };
105660
+ },
105661
+ next(provider, excluding) {
105662
+ return registry.list(provider).find((a) => !excluding.includes(a.id));
105663
+ }
105664
+ };
105665
+ return registry;
105666
+ }
105667
+ __name(createAccountRegistry, "createAccountRegistry");
105668
+
105669
+ // ../sdk/dist/account/binding.js
105670
+ function accountBoundPayload(id3, provider, reason2) {
105671
+ return { type: "account_bound", accountId: id3, provider, reason: reason2 };
105672
+ }
105673
+ __name(accountBoundPayload, "accountBoundPayload");
105674
+ function resolveBoundAccount(records4, provider, registry) {
105675
+ const fallback = accountId(provider, DEFAULT_ACCOUNT_LABEL);
105676
+ let last;
105677
+ for (const record3 of records4) {
105678
+ if (record3.type === "account_bound" && record3.provider === provider) {
105679
+ last = record3;
105680
+ }
105681
+ }
105682
+ if (!last)
105683
+ return { accountId: fallback, fellBack: false };
105684
+ if (registry.get(last.accountId))
105685
+ return { accountId: last.accountId, fellBack: false };
105686
+ return { accountId: fallback, fellBack: last.accountId !== fallback };
105687
+ }
105688
+ __name(resolveBoundAccount, "resolveBoundAccount");
105689
+
105100
105690
  // ../sdk/dist/pals/store.js
105101
105691
  import { randomUUID as randomUUID15 } from "node:crypto";
105102
- import { chmodSync as chmodSync3, closeSync as closeSync3, fsyncSync as fsyncSync3, linkSync as linkSync2, lstatSync as lstatSync7, mkdirSync as mkdirSync7, openSync as openSync3, readFileSync as readFileSync5, readdirSync as readdirSync2, realpathSync as realpathSync6, unlinkSync as unlinkSync4, writeSync as writeSync2 } from "node:fs";
105103
- import { dirname as dirname24, isAbsolute as isAbsolute12, join as join47, relative as relative9, resolve as resolve25, sep as sep12 } from "node:path";
105692
+ import { chmodSync as chmodSync4, closeSync as closeSync5, fsyncSync as fsyncSync4, linkSync as linkSync2, lstatSync as lstatSync7, mkdirSync as mkdirSync9, openSync as openSync5, readFileSync as readFileSync7, readdirSync as readdirSync2, realpathSync as realpathSync7, unlinkSync as unlinkSync5, writeSync as writeSync4 } from "node:fs";
105693
+ import { dirname as dirname26, isAbsolute as isAbsolute13, join as join49, relative as relative10, resolve as resolve26, sep as sep12 } from "node:path";
105104
105694
  var ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
105105
105695
  var REVISION_FILE = /^[1-9][0-9]*\.json$/u;
105106
105696
  var PalConflictError = class extends Error {
@@ -105121,20 +105711,20 @@ function palId(id3) {
105121
105711
  }
105122
105712
  __name(palId, "palId");
105123
105713
  function homePath(home) {
105124
- const path3 = resolve25(home);
105125
- mkdirSync7(path3, { recursive: true, mode: 448 });
105714
+ const path3 = resolve26(home);
105715
+ mkdirSync9(path3, { recursive: true, mode: 448 });
105126
105716
  const entry = lstatSync7(path3);
105127
105717
  if (!entry.isDirectory() || entry.isSymbolicLink())
105128
105718
  throw new Error("Pal home must be a real directory.");
105129
- const canonical3 = realpathSync6(path3);
105719
+ const canonical3 = realpathSync7(path3);
105130
105720
  if (canonical3 !== path3)
105131
105721
  throw new Error("Pal root may not contain symlink aliases.");
105132
105722
  return canonical3;
105133
105723
  }
105134
105724
  __name(homePath, "homePath");
105135
105725
  function contained(path3, root) {
105136
- const rel = relative9(root, path3);
105137
- return rel === "" || !isAbsolute12(rel) && rel !== ".." && !rel.startsWith(`..${sep12}`);
105726
+ const rel = relative10(root, path3);
105727
+ return rel === "" || !isAbsolute13(rel) && rel !== ".." && !rel.startsWith(`..${sep12}`);
105138
105728
  }
105139
105729
  __name(contained, "contained");
105140
105730
  function paths(home, workspaceRoot, id3) {
@@ -105143,11 +105733,11 @@ function paths(home, workspaceRoot, id3) {
105143
105733
  throw new Error("Pal workspaces must be outside the application home.");
105144
105734
  return {
105145
105735
  definitionsRoot,
105146
- palDir: join47(definitionsRoot, id3),
105147
- revisions: join47(definitionsRoot, id3, "revisions"),
105736
+ palDir: join49(definitionsRoot, id3),
105737
+ revisions: join49(definitionsRoot, id3, "revisions"),
105148
105738
  workspaceRoot,
105149
105739
  workspaces: workspaceRoot,
105150
- workspace: join47(workspaceRoot, id3)
105740
+ workspace: join49(workspaceRoot, id3)
105151
105741
  };
105152
105742
  }
105153
105743
  __name(paths, "paths");
@@ -105189,18 +105779,18 @@ function safeAppearance(value) {
105189
105779
  }
105190
105780
  __name(safeAppearance, "safeAppearance");
105191
105781
  function readStoredRevision(home, workspaceRoot, id3, revision2) {
105192
- const source = join47(paths(home, workspaceRoot, id3).revisions, `${revision2}.json`);
105782
+ const source = join49(paths(home, workspaceRoot, id3).revisions, `${revision2}.json`);
105193
105783
  assertDirectory(paths(home, workspaceRoot, id3).palDir);
105194
105784
  assertDirectory(paths(home, workspaceRoot, id3).revisions);
105195
105785
  const file = lstatSync7(source);
105196
105786
  if (!file.isFile() || file.isSymbolicLink())
105197
105787
  throw new Error("Pal revision must be a real file.");
105198
- const raw = JSON.parse(readFileSync5(source, "utf8"));
105788
+ const raw = JSON.parse(readFileSync7(source, "utf8"));
105199
105789
  if (raw.v !== 1 || raw.kind !== "pal" && raw.kind !== "pal-deleted" || raw.id !== id3 || raw.revision !== revision2 || !Number.isSafeInteger(revision2) || revision2 < 1 || typeof raw.createdAt !== "string" || typeof raw.updatedAt !== "string" || typeof raw.workspace !== "string" || typeof raw.paused !== "boolean")
105200
105790
  throw new Error(`Invalid Pal definition ${id3} revision ${revision2}.`);
105201
105791
  const expected = paths(home, workspaceRoot, id3).workspace;
105202
105792
  const entry = lstatSync7(expected);
105203
- if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync6(expected) !== expected || raw.workspace !== expected || contained(expected, home))
105793
+ if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync7(expected) !== expected || raw.workspace !== expected || contained(expected, home))
105204
105794
  throw new Error(`Pal ${id3} workspace identity changed.`);
105205
105795
  return {
105206
105796
  v: 1,
@@ -105247,7 +105837,7 @@ var DiskPalStore = class {
105247
105837
  throw new Error("Pal registry and workspace roots must not overlap.");
105248
105838
  this.secureDirectory = options.secureDirectory ?? ((path3) => {
105249
105839
  if (process.platform !== "win32")
105250
- chmodSync3(path3, 448);
105840
+ chmodSync4(path3, 448);
105251
105841
  });
105252
105842
  this.secureDirectory(this.root);
105253
105843
  this.secureDirectory(this.workspaceRoot);
@@ -105284,14 +105874,14 @@ var DiskPalStore = class {
105284
105874
  const p = paths(this.root, this.workspaceRoot, id3);
105285
105875
  assertDirectory(this.root);
105286
105876
  assertDirectory(this.workspaceRoot);
105287
- mkdirSync7(p.workspace, { mode: 448 });
105877
+ mkdirSync9(p.workspace, { mode: 448 });
105288
105878
  this.secureDirectory(p.workspace);
105289
105879
  assertDirectory(p.workspace);
105290
105880
  if (readdirSync2(p.workspace).length !== 0)
105291
105881
  throw new Error("New Pal workspace must be empty.");
105292
- mkdirSync7(p.palDir, { mode: 448 });
105882
+ mkdirSync9(p.palDir, { mode: 448 });
105293
105883
  this.secureDirectory(p.palDir);
105294
- mkdirSync7(p.revisions, { mode: 448 });
105884
+ mkdirSync9(p.revisions, { mode: 448 });
105295
105885
  this.secureDirectory(p.revisions);
105296
105886
  const definition = {
105297
105887
  v: 1,
@@ -105307,7 +105897,7 @@ var DiskPalStore = class {
105307
105897
  createdAt: at,
105308
105898
  updatedAt: at
105309
105899
  };
105310
- if (!publishExclusive(join47(p.revisions, "1.json"), definition))
105900
+ if (!publishExclusive(join49(p.revisions, "1.json"), definition))
105311
105901
  throw new PalConflictError(id3);
105312
105902
  return definition;
105313
105903
  }
@@ -105332,7 +105922,7 @@ var DiskPalStore = class {
105332
105922
  };
105333
105923
  if (typeof next2.paused !== "boolean" || !Number.isSafeInteger(next2.revision))
105334
105924
  throw new Error("Invalid Pal change.");
105335
- if (!publishExclusive(join47(paths(this.root, this.workspaceRoot, id3).revisions, `${next2.revision}.json`), next2))
105925
+ if (!publishExclusive(join49(paths(this.root, this.workspaceRoot, id3).revisions, `${next2.revision}.json`), next2))
105336
105926
  throw new PalConflictError(id3);
105337
105927
  return next2;
105338
105928
  }
@@ -105363,20 +105953,20 @@ var DiskPalStore = class {
105363
105953
  revision: expectedRevision + 1,
105364
105954
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
105365
105955
  };
105366
- if (!publishExclusive(join47(paths(this.root, this.workspaceRoot, id3).revisions, `${deleted.revision}.json`), deleted))
105956
+ if (!publishExclusive(join49(paths(this.root, this.workspaceRoot, id3).revisions, `${deleted.revision}.json`), deleted))
105367
105957
  throw new PalConflictError(id3);
105368
105958
  }
105369
105959
  /** Exact validated host control directory; never an execution-computer claim. */
105370
105960
  atWorkspace(cwd) {
105371
- const lexical = resolve25(cwd);
105372
- const canonical3 = realpathSync6(lexical);
105961
+ const lexical = resolve26(cwd);
105962
+ const canonical3 = realpathSync7(lexical);
105373
105963
  const lexicalReserved = contained(lexical, this.workspaceRoot);
105374
105964
  const canonicalReserved = contained(canonical3, this.workspaceRoot);
105375
105965
  if (!lexicalReserved && !canonicalReserved)
105376
105966
  return null;
105377
105967
  if (lexical !== canonical3)
105378
105968
  throw new Error("Pal workspace is a symlink alias.");
105379
- const rel = relative9(this.workspaceRoot, canonical3);
105969
+ const rel = relative10(this.workspaceRoot, canonical3);
105380
105970
  if (!ID.test(rel))
105381
105971
  throw new Error("Reserved Pal control directories cannot run ordinary host sessions. Open the exact Pal workspace.");
105382
105972
  const pal = this.get(rel);
@@ -105387,19 +105977,19 @@ var DiskPalStore = class {
105387
105977
  };
105388
105978
  function assertDirectory(path3) {
105389
105979
  const entry = lstatSync7(path3);
105390
- if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync6(path3) !== path3)
105980
+ if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync7(path3) !== path3)
105391
105981
  throw new Error(`Pal directory identity changed: ${path3}`);
105392
105982
  }
105393
105983
  __name(assertDirectory, "assertDirectory");
105394
105984
  function publishExclusive(path3, value) {
105395
- const temporary = join47(dirname24(path3), `.pal-${randomUUID15()}.tmp`);
105396
- const fd = openSync3(temporary, "wx", 384);
105985
+ const temporary = join49(dirname26(path3), `.pal-${randomUUID15()}.tmp`);
105986
+ const fd = openSync5(temporary, "wx", 384);
105397
105987
  try {
105398
- writeSync2(fd, `${JSON.stringify(value)}
105988
+ writeSync4(fd, `${JSON.stringify(value)}
105399
105989
  `);
105400
- fsyncSync3(fd);
105990
+ fsyncSync4(fd);
105401
105991
  } finally {
105402
- closeSync3(fd);
105992
+ closeSync5(fd);
105403
105993
  }
105404
105994
  try {
105405
105995
  linkSync2(temporary, path3);
@@ -105409,7 +105999,7 @@ function publishExclusive(path3, value) {
105409
105999
  return false;
105410
106000
  throw error;
105411
106001
  } finally {
105412
- unlinkSync4(temporary);
106002
+ unlinkSync5(temporary);
105413
106003
  }
105414
106004
  }
105415
106005
  __name(publishExclusive, "publishExclusive");
@@ -106251,8 +106841,8 @@ __name(createPalReferenceImageTool, "createPalReferenceImageTool");
106251
106841
 
106252
106842
  // ../sdk/dist/pals/communication/store.js
106253
106843
  import { randomUUID as randomUUID17 } from "node:crypto";
106254
- import { chmodSync as chmodSync4, lstatSync as lstatSync8, mkdirSync as mkdirSync8, readdirSync as readdirSync3, realpathSync as realpathSync7 } from "node:fs";
106255
- import { join as join48, resolve as resolve26 } from "node:path";
106844
+ import { chmodSync as chmodSync5, lstatSync as lstatSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync3, realpathSync as realpathSync8 } from "node:fs";
106845
+ import { join as join50, resolve as resolve27 } from "node:path";
106256
106846
  import { isDeepStrictEqual as isDeepStrictEqual9 } from "node:util";
106257
106847
 
106258
106848
  // ../sdk/dist/pals/communication/ingress-schema.js
@@ -107062,10 +107652,10 @@ var DiskPalCommunicationStore = class {
107062
107652
  migrations: { 1: (value) => value }
107063
107653
  }), "Pal communication", (record3) => record3.revision);
107064
107654
  constructor(options) {
107065
- this.root = resolve26(options.root);
107655
+ this.root = resolve27(options.root);
107066
107656
  this.secure = options.secureDirectory ?? ((path3) => {
107067
107657
  if (process.platform !== "win32")
107068
- chmodSync4(path3, 448);
107658
+ chmodSync5(path3, 448);
107069
107659
  });
107070
107660
  this.maxPending = options.maxPending ?? 256;
107071
107661
  if (!Number.isSafeInteger(this.maxPending) || this.maxPending < 1)
@@ -107073,31 +107663,31 @@ var DiskPalCommunicationStore = class {
107073
107663
  this.directory(this.root);
107074
107664
  }
107075
107665
  directory(path3) {
107076
- mkdirSync8(path3, { recursive: true, mode: 448 });
107666
+ mkdirSync10(path3, { recursive: true, mode: 448 });
107077
107667
  const stat16 = lstatSync8(path3);
107078
- if (!stat16.isDirectory() || stat16.isSymbolicLink() || realpathSync7(path3) !== path3)
107668
+ if (!stat16.isDirectory() || stat16.isSymbolicLink() || realpathSync8(path3) !== path3)
107079
107669
  throw new Error("Pal communication requires a real directory without aliases.");
107080
107670
  this.secure(path3);
107081
107671
  }
107082
107672
  location(recipient) {
107083
107673
  const address2 = addressSchema2.parse(recipient);
107084
107674
  this.directory(this.root);
107085
- const directory = join48(this.root, hash(addressTuple(address2)));
107675
+ const directory = join50(this.root, hash(addressTuple(address2)));
107086
107676
  return this.commitLocation(directory);
107087
107677
  }
107088
107678
  commitLocation(directory) {
107089
107679
  this.directory(directory);
107090
- const revisionsDir = join48(directory, "revisions");
107680
+ const revisionsDir = join50(directory, "revisions");
107091
107681
  this.directory(revisionsDir);
107092
107682
  for (const name2 of readdirSync3(revisionsDir)) {
107093
107683
  if (!/^[1-9][0-9]*\.json$/u.test(name2))
107094
107684
  continue;
107095
- const stat16 = lstatSync8(join48(revisionsDir, name2));
107685
+ const stat16 = lstatSync8(join50(revisionsDir, name2));
107096
107686
  if (!stat16.isFile() || stat16.isSymbolicLink())
107097
107687
  throw new Error("Pal communication commit must be a real file.");
107098
107688
  }
107099
107689
  return {
107100
- legacyPath: join48(directory, "state.json"),
107690
+ legacyPath: join50(directory, "state.json"),
107101
107691
  revisionsDir,
107102
107692
  publishLegacyProjection: false
107103
107693
  };
@@ -107109,9 +107699,9 @@ var DiskPalCommunicationStore = class {
107109
107699
  async reserveOperation(input, recipientRevision, conversationId) {
107110
107700
  const intent = this.checkedIntent(input);
107111
107701
  this.directory(this.root);
107112
- const operationsRoot = join48(this.root, "operations");
107702
+ const operationsRoot = join50(this.root, "operations");
107113
107703
  this.directory(operationsRoot);
107114
- const location = this.commitLocation(join48(operationsRoot, intent.id));
107704
+ const location = this.commitLocation(join50(operationsRoot, intent.id));
107115
107705
  const proposed = ingressOperationReservationSchema.parse({
107116
107706
  revision: 1,
107117
107707
  intent,
@@ -107929,8 +108519,8 @@ async function dispatchPalMessagesOnce(options, recipient, signal) {
107929
108519
  __name(dispatchPalMessagesOnce, "dispatchPalMessagesOnce");
107930
108520
 
107931
108521
  // ../sdk/dist/pals/communication/policy.js
107932
- import { chmodSync as chmodSync5, lstatSync as lstatSync9, mkdirSync as mkdirSync9, readdirSync as readdirSync4, realpathSync as realpathSync8 } from "node:fs";
107933
- import { join as join49, resolve as resolve27 } from "node:path";
108522
+ import { chmodSync as chmodSync6, lstatSync as lstatSync9, mkdirSync as mkdirSync11, readdirSync as readdirSync4, realpathSync as realpathSync9 } from "node:fs";
108523
+ import { join as join51, resolve as resolve28 } from "node:path";
107934
108524
  var PalMessagePermissionConflictError = class extends Error {
107935
108525
  static {
107936
108526
  __name(this, "PalMessagePermissionConflictError");
@@ -107966,17 +108556,17 @@ var DiskPalMessagePolicy = class {
107966
108556
  secure;
107967
108557
  records = new DiskRevisionRecordStore(defineSchema({ kind: "pal-message-permission", current: 1, migrations: {} }), "Pal message permission", (value) => value.revision);
107968
108558
  constructor(options) {
107969
- this.root = resolve27(options.root);
108559
+ this.root = resolve28(options.root);
107970
108560
  this.secure = options.secureDirectory ?? ((path3) => {
107971
108561
  if (process.platform !== "win32")
107972
- chmodSync5(path3, 448);
108562
+ chmodSync6(path3, 448);
107973
108563
  });
107974
108564
  this.directory(this.root);
107975
108565
  }
107976
108566
  directory(path3) {
107977
- mkdirSync9(path3, { recursive: true, mode: 448 });
108567
+ mkdirSync11(path3, { recursive: true, mode: 448 });
107978
108568
  const entry = lstatSync9(path3);
107979
- if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync8(path3) !== path3)
108569
+ if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync9(path3) !== path3)
107980
108570
  throw new Error("Pal communication policy requires real directories without aliases.");
107981
108571
  this.secure(path3);
107982
108572
  }
@@ -107986,11 +108576,11 @@ var DiskPalMessagePolicy = class {
107986
108576
  if (source.tenantId !== recipient.tenantId)
107987
108577
  throw new Error("Cross-tenant Pal grants are refused.");
107988
108578
  this.directory(this.root);
107989
- const directory = join49(this.root, key5(source, recipient));
108579
+ const directory = join51(this.root, key5(source, recipient));
107990
108580
  this.directory(directory);
107991
- const revisionsDir = join49(directory, "revisions");
108581
+ const revisionsDir = join51(directory, "revisions");
107992
108582
  this.directory(revisionsDir);
107993
- return { legacyPath: join49(directory, "permission.json"), revisionsDir };
108583
+ return { legacyPath: join51(directory, "permission.json"), revisionsDir };
107994
108584
  }
107995
108585
  async get(source, recipient) {
107996
108586
  const capturedSource = addressSchema2.parse(source);
@@ -108028,12 +108618,12 @@ var DiskPalMessagePolicy = class {
108028
108618
  for (const name2 of readdirSync4(this.root)) {
108029
108619
  if (!/^[a-f0-9]{64}$/.test(name2))
108030
108620
  continue;
108031
- const directory = join49(this.root, name2);
108621
+ const directory = join51(this.root, name2);
108032
108622
  this.directory(directory);
108033
- this.directory(join49(directory, "revisions"));
108623
+ this.directory(join51(directory, "revisions"));
108034
108624
  const stored = await this.records.read({
108035
- legacyPath: join49(directory, "permission.json"),
108036
- revisionsDir: join49(directory, "revisions")
108625
+ legacyPath: join51(directory, "permission.json"),
108626
+ revisionsDir: join51(directory, "revisions")
108037
108627
  });
108038
108628
  if (!stored)
108039
108629
  continue;
@@ -108606,8 +109196,8 @@ async function dispatchPalIngressOnce(options, recipient, signal) {
108606
109196
  __name(dispatchPalIngressOnce, "dispatchPalIngressOnce");
108607
109197
 
108608
109198
  // ../sdk/dist/pals/channels/routes.js
108609
- import { chmodSync as chmodSync6, lstatSync as lstatSync10, mkdirSync as mkdirSync10, readdirSync as readdirSync5, realpathSync as realpathSync9 } from "node:fs";
108610
- import { join as join50, resolve as resolve28 } from "node:path";
109199
+ import { chmodSync as chmodSync7, lstatSync as lstatSync10, mkdirSync as mkdirSync12, readdirSync as readdirSync5, realpathSync as realpathSync10 } from "node:fs";
109200
+ import { join as join52, resolve as resolve29 } from "node:path";
108611
109201
  import { isDeepStrictEqual as isDeepStrictEqual10 } from "node:util";
108612
109202
 
108613
109203
  // ../sdk/dist/pals/channels/schema.js
@@ -108715,34 +109305,34 @@ var DiskPalChannelRoutes = class {
108715
109305
  secure;
108716
109306
  records = new DiskRevisionRecordStore(defineSchema({ kind: "pal-channel-route", current: 1, migrations: {} }), "Pal channel route", (record3) => record3.revision);
108717
109307
  constructor(options) {
108718
- this.root = resolve28(options.root);
109308
+ this.root = resolve29(options.root);
108719
109309
  this.secure = options.secureDirectory ?? ((path3) => {
108720
109310
  if (process.platform !== "win32")
108721
- chmodSync6(path3, 448);
109311
+ chmodSync7(path3, 448);
108722
109312
  });
108723
109313
  this.directory(this.root);
108724
109314
  }
108725
109315
  directory(path3) {
108726
- mkdirSync10(path3, { recursive: true, mode: 448 });
109316
+ mkdirSync12(path3, { recursive: true, mode: 448 });
108727
109317
  const entry = lstatSync10(path3);
108728
- if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync9(path3) !== path3)
109318
+ if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync10(path3) !== path3)
108729
109319
  throw new Error("Channel routes require real directories without aliases.");
108730
109320
  this.secure(path3);
108731
109321
  }
108732
109322
  location(id3) {
108733
109323
  this.directory(this.root);
108734
- const directory = join50(this.root, id3);
109324
+ const directory = join52(this.root, id3);
108735
109325
  this.directory(directory);
108736
- const revisionsDir = join50(directory, "revisions");
109326
+ const revisionsDir = join52(directory, "revisions");
108737
109327
  this.directory(revisionsDir);
108738
109328
  for (const name2 of readdirSync5(revisionsDir)) {
108739
109329
  if (!/^[1-9][0-9]*\.json$/u.test(name2))
108740
109330
  continue;
108741
- const entry = lstatSync10(join50(revisionsDir, name2));
109331
+ const entry = lstatSync10(join52(revisionsDir, name2));
108742
109332
  if (!entry.isFile() || entry.isSymbolicLink())
108743
109333
  throw new Error("Channel route commits must be real files.");
108744
109334
  }
108745
- const legacyPath = join50(directory, "route.json");
109335
+ const legacyPath = join52(directory, "route.json");
108746
109336
  try {
108747
109337
  const legacy = lstatSync10(legacyPath);
108748
109338
  if (!legacy.isFile() || legacy.isSymbolicLink())
@@ -109036,8 +109626,8 @@ var PalChannelRouter = class {
109036
109626
  };
109037
109627
 
109038
109628
  // ../sdk/dist/pals/activity/subscription-store.js
109039
- import { chmodSync as chmodSync7, lstatSync as lstatSync11, mkdirSync as mkdirSync11, readdirSync as readdirSync6, realpathSync as realpathSync10 } from "node:fs";
109040
- import { join as join51, resolve as resolve29 } from "node:path";
109629
+ import { chmodSync as chmodSync8, lstatSync as lstatSync11, mkdirSync as mkdirSync13, readdirSync as readdirSync6, realpathSync as realpathSync11 } from "node:fs";
109630
+ import { join as join53, resolve as resolve30 } from "node:path";
109041
109631
  import { isDeepStrictEqual as isDeepStrictEqual13 } from "node:util";
109042
109632
 
109043
109633
  // ../sdk/dist/pals/activity/subscription-schema.js
@@ -109076,36 +109666,36 @@ var DiskPalActivitySubscriptionStore = class {
109076
109666
  migrations: {}
109077
109667
  }), "Pal activity subscription", (value) => value.revision);
109078
109668
  constructor(options) {
109079
- this.root = resolve29(options.root);
109669
+ this.root = resolve30(options.root);
109080
109670
  this.secure = options.secureDirectory ?? ((path3) => {
109081
109671
  if (process.platform !== "win32")
109082
- chmodSync7(path3, 448);
109672
+ chmodSync8(path3, 448);
109083
109673
  });
109084
109674
  this.directory(this.root);
109085
109675
  }
109086
109676
  directory(path3) {
109087
- mkdirSync11(path3, { recursive: true, mode: 448 });
109677
+ mkdirSync13(path3, { recursive: true, mode: 448 });
109088
109678
  const stat16 = lstatSync11(path3);
109089
- if (!stat16.isDirectory() || stat16.isSymbolicLink() || realpathSync10(path3) !== path3)
109679
+ if (!stat16.isDirectory() || stat16.isSymbolicLink() || realpathSync11(path3) !== path3)
109090
109680
  throw new Error("Pal subscriptions require real directories without aliases.");
109091
109681
  this.secure(path3);
109092
109682
  }
109093
109683
  location(input) {
109094
109684
  const id3 = external_exports.string().uuid().parse(input);
109095
109685
  this.directory(this.root);
109096
- const directory = join51(this.root, id3);
109686
+ const directory = join53(this.root, id3);
109097
109687
  this.directory(directory);
109098
- const revisionsDir = join51(directory, "revisions");
109688
+ const revisionsDir = join53(directory, "revisions");
109099
109689
  this.directory(revisionsDir);
109100
109690
  for (const name2 of readdirSync6(revisionsDir)) {
109101
109691
  if (!/^[1-9][0-9]*\.json$/u.test(name2))
109102
109692
  continue;
109103
- const stat16 = lstatSync11(join51(revisionsDir, name2));
109693
+ const stat16 = lstatSync11(join53(revisionsDir, name2));
109104
109694
  if (!stat16.isFile() || stat16.isSymbolicLink())
109105
109695
  throw new Error("Pal subscription commits must be real files.");
109106
109696
  }
109107
109697
  return {
109108
- legacyPath: join51(directory, "subscription.json"),
109698
+ legacyPath: join53(directory, "subscription.json"),
109109
109699
  revisionsDir,
109110
109700
  publishLegacyProjection: false
109111
109701
  };
@@ -109124,7 +109714,7 @@ var DiskPalActivitySubscriptionStore = class {
109124
109714
  async list() {
109125
109715
  try {
109126
109716
  const entry = lstatSync11(this.root);
109127
- if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync10(this.root) !== this.root)
109717
+ if (!entry.isDirectory() || entry.isSymbolicLink() || realpathSync11(this.root) !== this.root)
109128
109718
  throw new Error("Pal subscriptions require real directories without aliases.");
109129
109719
  } catch (error) {
109130
109720
  if (error.code === "ENOENT")
@@ -109197,8 +109787,8 @@ var DiskPalActivitySubscriptionStore = class {
109197
109787
  };
109198
109788
 
109199
109789
  // ../sdk/dist/pals/activity/subscription-policy.js
109200
- import { chmodSync as chmodSync8, lstatSync as lstatSync12, mkdirSync as mkdirSync12, readdirSync as readdirSync7, realpathSync as realpathSync11 } from "node:fs";
109201
- import { join as join52, resolve as resolve30 } from "node:path";
109790
+ import { chmodSync as chmodSync9, lstatSync as lstatSync12, mkdirSync as mkdirSync14, readdirSync as readdirSync7, realpathSync as realpathSync12 } from "node:fs";
109791
+ import { join as join54, resolve as resolve31 } from "node:path";
109202
109792
  import { isDeepStrictEqual as isDeepStrictEqual14 } from "node:util";
109203
109793
  var PalActivitySubscriptionPermissionConflictError = class extends Error {
109204
109794
  static {
@@ -109233,37 +109823,37 @@ var DiskPalActivitySubscriptionPolicy = class {
109233
109823
  migrations: {}
109234
109824
  }), "Pal activity subscription permission", (value) => value.revision);
109235
109825
  constructor(options) {
109236
- this.root = resolve30(options.root);
109826
+ this.root = resolve31(options.root);
109237
109827
  this.subscriptions = options.subscriptions;
109238
109828
  this.secure = options.secureDirectory ?? ((path3) => {
109239
109829
  if (process.platform !== "win32")
109240
- chmodSync8(path3, 448);
109830
+ chmodSync9(path3, 448);
109241
109831
  });
109242
109832
  this.directory(this.root);
109243
109833
  }
109244
109834
  directory(path3) {
109245
- mkdirSync12(path3, { recursive: true, mode: 448 });
109835
+ mkdirSync14(path3, { recursive: true, mode: 448 });
109246
109836
  const stat16 = lstatSync12(path3);
109247
- if (!stat16.isDirectory() || stat16.isSymbolicLink() || realpathSync11(path3) !== path3)
109837
+ if (!stat16.isDirectory() || stat16.isSymbolicLink() || realpathSync12(path3) !== path3)
109248
109838
  throw new Error("Pal activity permissions require real directories without aliases.");
109249
109839
  this.secure(path3);
109250
109840
  }
109251
109841
  location(id3) {
109252
109842
  const key6 = external_exports.string().uuid().parse(id3);
109253
109843
  this.directory(this.root);
109254
- const directory = join52(this.root, key6);
109844
+ const directory = join54(this.root, key6);
109255
109845
  this.directory(directory);
109256
- const revisionsDir = join52(directory, "revisions");
109846
+ const revisionsDir = join54(directory, "revisions");
109257
109847
  this.directory(revisionsDir);
109258
109848
  for (const name2 of readdirSync7(revisionsDir)) {
109259
109849
  if (!/^[1-9][0-9]*\.json$/u.test(name2))
109260
109850
  continue;
109261
- const stat16 = lstatSync12(join52(revisionsDir, name2));
109851
+ const stat16 = lstatSync12(join54(revisionsDir, name2));
109262
109852
  if (!stat16.isFile() || stat16.isSymbolicLink())
109263
109853
  throw new Error("Pal permission commits must be real files.");
109264
109854
  }
109265
109855
  return {
109266
- legacyPath: join52(directory, "permission.json"),
109856
+ legacyPath: join54(directory, "permission.json"),
109267
109857
  revisionsDir,
109268
109858
  publishLegacyProjection: false
109269
109859
  };
@@ -109813,7 +110403,7 @@ function admitToolFacts(value) {
109813
110403
  __name(admitToolFacts, "admitToolFacts");
109814
110404
 
109815
110405
  // ../sdk/dist/tools/builtins/glob.js
109816
- import { isAbsolute as isAbsolute13, join as join53, relative as relative10, sep as sep13 } from "node:path";
110406
+ import { isAbsolute as isAbsolute14, join as join55, relative as relative11, sep as sep13 } from "node:path";
109817
110407
 
109818
110408
  // ../sdk/dist/tools/posix-path.js
109819
110409
  function normalizeSegments(path3) {
@@ -109875,9 +110465,9 @@ function relativePattern(pattern, root, sandboxed) {
109875
110465
  if (result.split("/").includes("..")) {
109876
110466
  throw new Error('Glob pattern escapes the search directory through "..". Choose a contained path and a relative pattern.');
109877
110467
  }
109878
- if (sandboxed ? result.startsWith("/") : isAbsolute13(pattern)) {
110468
+ if (sandboxed ? result.startsWith("/") : isAbsolute14(pattern)) {
109879
110469
  const contained2 = sandboxed ? resolveWithinPosix(root, result) : resolveWithin(root, pattern);
109880
- result = sandboxed ? relativePosix(root, contained2) : relative10(root, contained2).split(sep13).join("/");
110470
+ result = sandboxed ? relativePosix(root, contained2) : relative11(root, contained2).split(sep13).join("/");
109881
110471
  }
109882
110472
  while (result.startsWith("./"))
109883
110473
  result = result.slice(2);
@@ -109949,7 +110539,7 @@ var GlobTool = defineTool({
109949
110539
  truncated = true;
109950
110540
  break;
109951
110541
  }
109952
- const file = sandbox ? relativePosix(sandbox.rootDir, absolute) : relative10(context2.workingDirectory, join53(lexicalRoot, relative10(root, absolute)));
110542
+ const file = sandbox ? relativePosix(sandbox.rootDir, absolute) : relative11(context2.workingDirectory, join55(lexicalRoot, relative11(root, absolute)));
109953
110543
  files.push(`./${sandbox ? file : file.split(sep13).join("/")}`);
109954
110544
  }
109955
110545
  } catch (error) {
@@ -109977,7 +110567,7 @@ var GlobTool = defineTool({
109977
110567
 
109978
110568
  // ../sdk/dist/tools/builtins/code-analysis.js
109979
110569
  import { realpath as realpath13, stat as stat12 } from "node:fs/promises";
109980
- import { isAbsolute as isAbsolute14, relative as relative11, sep as sep14 } from "node:path";
110570
+ import { isAbsolute as isAbsolute15, relative as relative12, sep as sep14 } from "node:path";
109981
110571
  var DEFAULT_LIMIT = 50;
109982
110572
  var MAX_LIMIT = 200;
109983
110573
  var DEFAULT_MAX_CHARS = 2e4;
@@ -110257,8 +110847,8 @@ async function owningRoot(roots, target) {
110257
110847
  }
110258
110848
  __name(owningRoot, "owningRoot");
110259
110849
  function relativeTo(root, path3) {
110260
- const rel = relative11(root, path3);
110261
- if (rel === "" || rel === ".." || rel.startsWith(`..${sep14}`) || isAbsolute14(rel))
110850
+ const rel = relative12(root, path3);
110851
+ if (rel === "" || rel === ".." || rel.startsWith(`..${sep14}`) || isAbsolute15(rel))
110262
110852
  return path3;
110263
110853
  return sep14 === "/" ? rel : rel.split(sep14).join("/");
110264
110854
  }
@@ -110479,7 +111069,7 @@ __name(getCodeNavigationTools, "getCodeNavigationTools");
110479
111069
 
110480
111070
  // ../sdk/dist/tools/builtins/grep.js
110481
111071
  import { stat as stat13 } from "node:fs/promises";
110482
- import { isAbsolute as isAbsolute15, join as join54, relative as relative12, sep as sep15 } from "node:path";
111072
+ import { isAbsolute as isAbsolute16, join as join56, relative as relative13, sep as sep15 } from "node:path";
110483
111073
  async function readWithSignal(read, signal) {
110484
111074
  signal?.throwIfAborted();
110485
111075
  if (!signal)
@@ -110505,9 +111095,9 @@ function relativeInclude(include, root, sandboxed) {
110505
111095
  let pattern = sandboxed ? include : include.split(sep15).join("/");
110506
111096
  if (pattern.split("/").includes(".."))
110507
111097
  throw new Error("Include pattern escapes the search directory");
110508
- if (sandboxed ? pattern.startsWith("/") : isAbsolute15(include)) {
111098
+ if (sandboxed ? pattern.startsWith("/") : isAbsolute16(include)) {
110509
111099
  const absolute = sandboxed ? resolveWithinPosix(root, pattern) : resolveWithin(root, include);
110510
- pattern = sandboxed ? relativePosix(root, absolute) : relative12(root, absolute).split(sep15).join("/");
111100
+ pattern = sandboxed ? relativePosix(root, absolute) : relative13(root, absolute).split(sep15).join("/");
110511
111101
  }
110512
111102
  while (pattern.startsWith("./"))
110513
111103
  pattern = pattern.slice(2);
@@ -110700,7 +111290,7 @@ var GrepTool = defineTool({
110700
111290
  }
110701
111291
  const lines = content.split("\n");
110702
111292
  let fileMatches = 0;
110703
- const relPath = sandbox ? `./${relativePosix(sandbox.rootDir, filePath)}` : `./${relative12(context2.workingDirectory, join54(lexicalRoot, relative12(root, filePath))).split(sep15).join("/")}`;
111293
+ const relPath = sandbox ? `./${relativePosix(sandbox.rootDir, filePath)}` : `./${relative13(context2.workingDirectory, join56(lexicalRoot, relative13(root, filePath))).split(sep15).join("/")}`;
110704
111294
  if (mode === "content" && input.only_matching) {
110705
111295
  for (const fragment of matchingFragments(content, regex, multiline)) {
110706
111296
  context2.abortSignal?.throwIfAborted();
@@ -111263,7 +111853,7 @@ async function waitForJobWithBounds(jobs, id3, options, now = Date.now) {
111263
111853
  omittedOutputBytes
111264
111854
  };
111265
111855
  });
111266
- const expiry = new Promise((resolve32) => {
111856
+ const expiry = new Promise((resolve33) => {
111267
111857
  const tick = setInterval(() => {
111268
111858
  if (settled)
111269
111859
  return;
@@ -111271,7 +111861,7 @@ async function waitForJobWithBounds(jobs, id3, options, now = Date.now) {
111271
111861
  const elapsed = now() - startedAt;
111272
111862
  if (elapsed >= options.wallMs) {
111273
111863
  clearInterval(tick);
111274
- resolve32({
111864
+ resolve33({
111275
111865
  kind: "timeout",
111276
111866
  cause: "wall",
111277
111867
  elapsedMs: elapsed,
@@ -111286,7 +111876,7 @@ async function waitForJobWithBounds(jobs, id3, options, now = Date.now) {
111286
111876
  const quietFor = now() - lastProgressAt;
111287
111877
  if (quietFor >= options.idleMs) {
111288
111878
  clearInterval(tick);
111289
- resolve32({
111879
+ resolve33({
111290
111880
  kind: "timeout",
111291
111881
  cause: "idle",
111292
111882
  elapsedMs: elapsed,
@@ -111960,7 +112550,7 @@ function cacheFor(provider) {
111960
112550
  return cache;
111961
112551
  }
111962
112552
  __name(cacheFor, "cacheFor");
111963
- function refusal(url) {
112553
+ function refusal2(url) {
111964
112554
  if (url.length > MAX_URL_CHARS)
111965
112555
  return "Invalid URL: it is longer than 2000 characters.";
111966
112556
  let parsed;
@@ -111979,7 +112569,7 @@ function refusal(url) {
111979
112569
  }
111980
112570
  return void 0;
111981
112571
  }
111982
- __name(refusal, "refusal");
112572
+ __name(refusal2, "refusal");
111983
112573
  function statusText(status) {
111984
112574
  return STATUS_CODES[status] ?? "Unknown Status";
111985
112575
  }
@@ -112030,7 +112620,7 @@ var WebFetchTool = defineTool({
112030
112620
  error: "This turn has no web fetch provider configured, so no URL can be fetched."
112031
112621
  };
112032
112622
  }
112033
- const invalid = refusal(input.url);
112623
+ const invalid = refusal2(input.url);
112034
112624
  if (invalid)
112035
112625
  return { success: false, output: "", error: invalid };
112036
112626
  const offset = input.offset ?? 0;
@@ -112322,7 +112912,7 @@ __name(buildRunCodeTool, "buildRunCodeTool");
112322
112912
 
112323
112913
  // ../sdk/dist/tools/builtins/ls.js
112324
112914
  import { readdir as readdir15, stat as stat14 } from "node:fs/promises";
112325
- import { join as join55, relative as relative13 } from "node:path";
112915
+ import { join as join57, relative as relative14 } from "node:path";
112326
112916
  var inputSchema18 = external_exports.object({
112327
112917
  path: external_exports.string().default(".").describe("Directory path to list. Defaults to working directory."),
112328
112918
  all: external_exports.boolean().default(false).describe("Include hidden files (dotfiles)"),
@@ -112355,7 +112945,7 @@ async function listDirectory2(dirPath, showHidden) {
112355
112945
  } else if (entry.isFile()) {
112356
112946
  type = "file";
112357
112947
  try {
112358
- const s = await stat14(join55(dirPath, entry.name));
112948
+ const s = await stat14(join57(dirPath, entry.name));
112359
112949
  size = s.size;
112360
112950
  } catch {
112361
112951
  }
@@ -112379,13 +112969,13 @@ async function listRecursive(basePath, currentPath, showHidden, maxDepth, depth,
112379
112969
  for (const entry of entries2) {
112380
112970
  if (count7.value >= MAX_ENTRIES)
112381
112971
  break;
112382
- const relPath = `./${relative13(basePath, join55(currentPath, entry.name))}`;
112972
+ const relPath = `./${relative14(basePath, join57(currentPath, entry.name))}`;
112383
112973
  const suffix = entry.type === "dir" ? "/" : "";
112384
112974
  const sizeStr = entry.type === "file" ? ` (${formatSize2(entry.size)})` : "";
112385
112975
  output.push(`${relPath}${suffix}${sizeStr}`);
112386
112976
  count7.value++;
112387
112977
  if (entry.type === "dir") {
112388
- await listRecursive(basePath, join55(currentPath, entry.name), showHidden, maxDepth, depth + 1, output, count7);
112978
+ await listRecursive(basePath, join57(currentPath, entry.name), showHidden, maxDepth, depth + 1, output, count7);
112389
112979
  }
112390
112980
  }
112391
112981
  }
@@ -112500,7 +113090,7 @@ var LsTool = defineTool({
112500
113090
 
112501
113091
  // ../sdk/dist/tools/builtins/verify-outputs.js
112502
113092
  import { stat as stat15 } from "node:fs/promises";
112503
- import { resolve as resolve31 } from "node:path";
113093
+ import { resolve as resolve32 } from "node:path";
112504
113094
  var inputSchema19 = external_exports.object({
112505
113095
  paths: external_exports.array(external_exports.string().min(1)).min(1).describe("Expected output file paths to verify. Each path is checked for existence and size."),
112506
113096
  min_bytes: external_exports.number().int().min(0).optional().describe("Minimum acceptable file size in bytes. A file under this size counts as missing. Default: 1 (any non-empty file passes).")
@@ -112556,7 +113146,7 @@ async function verifyOne(input) {
112556
113146
  };
112557
113147
  }
112558
113148
  }
112559
- const filePath = resolve31(context2.workingDirectory, path3);
113149
+ const filePath = resolve32(context2.workingDirectory, path3);
112560
113150
  try {
112561
113151
  const info = await stat15(filePath);
112562
113152
  if (!info.isFile()) {
@@ -113417,7 +114007,7 @@ function createComputerUseTool(host, options = {}) {
113417
114007
  return entry ? `${uiElementText(entry.element)} (${ref})` : void 0;
113418
114008
  }, "describeUiRef");
113419
114009
  const label6 = /* @__PURE__ */ __name((input) => itemLabel(input, describeUiRef), "label");
113420
- const refusal3 = /* @__PURE__ */ __name((type) => {
114010
+ const refusal4 = /* @__PURE__ */ __name((type) => {
113421
114011
  if (available.has(type))
113422
114012
  return null;
113423
114013
  const required = requiredCapability(type);
@@ -113498,7 +114088,7 @@ function createComputerUseTool(host, options = {}) {
113498
114088
  }
113499
114089
  }, "runHost");
113500
114090
  const plan = /* @__PURE__ */ __name((item, frameId) => {
113501
- const denied2 = refusal3(item.type);
114091
+ const denied2 = refusal4(item.type);
113502
114092
  if (denied2)
113503
114093
  throw new StepFailure(denied2);
113504
114094
  const mutating = !READ_ONLY_ACTIONS.has(item.type);
@@ -114030,7 +114620,7 @@ ${wrapUntrusted({
114030
114620
  // adds nothing to the call row; observations, batches and failures do.
114031
114621
  presentResult: /* @__PURE__ */ __name((_input, result) => result.success && ACKNOWLEDGEMENT.test(result.output) ? { kind: "generic", label: result.output, visibility: "hidden" } : void 0, "presentResult"),
114032
114622
  async execute(input, context2) {
114033
- const denied2 = refusal3(input.type);
114623
+ const denied2 = refusal4(input.type);
114034
114624
  if (denied2)
114035
114625
  return { success: false, output: "", error: denied2 };
114036
114626
  try {
@@ -114683,17 +115273,17 @@ function actionAvailable(caps, action) {
114683
115273
  return true;
114684
115274
  }
114685
115275
  __name(actionAvailable, "actionAvailable");
114686
- function refusal2(error, data) {
115276
+ function refusal3(error, data) {
114687
115277
  return { success: false, output: "", error, ...data ? { data } : {} };
114688
115278
  }
114689
- __name(refusal2, "refusal");
115279
+ __name(refusal3, "refusal");
114690
115280
  function unavailable2(host, tool, action) {
114691
115281
  const caps = host.capabilities;
114692
115282
  if (caps.unavailableReason !== void 0) {
114693
- return refusal2(`${tool}: the browser is unavailable here \u2014 ${caps.unavailableReason} Do not retry; tell the user.`, { code: "browser_unavailable" });
115283
+ return refusal3(`${tool}: the browser is unavailable here \u2014 ${caps.unavailableReason} Do not retry; tell the user.`, { code: "browser_unavailable" });
114694
115284
  }
114695
115285
  if (!actionAvailable(caps, action)) {
114696
- return refusal2(`${tool}: action "${action}" is not supported by this browser host.`, {
115286
+ return refusal3(`${tool}: action "${action}" is not supported by this browser host.`, {
114697
115287
  code: "browser_unsupported_action"
114698
115288
  });
114699
115289
  }
@@ -114825,9 +115415,9 @@ var HUMAN_REASON_WORDS = {
114825
115415
  function hostErrorToResult(tool, error) {
114826
115416
  switch (error.code) {
114827
115417
  case "browser_origin_mismatch":
114828
- return refusal2(`${tool}: refused \u2014 the page is at ${error.actual || "an unknown origin"}, not ${error.expected}. Nothing was done. Take a snapshot and act on the page it shows.`, { code: error.code, expected: error.expected, actual: error.actual });
115418
+ return refusal3(`${tool}: refused \u2014 the page is at ${error.actual || "an unknown origin"}, not ${error.expected}. Nothing was done. Take a snapshot and act on the page it shows.`, { code: error.code, expected: error.expected, actual: error.actual });
114829
115419
  case "browser_stale_ref":
114830
- return refusal2(`${tool}: element ${error.ref} is not on the page any more (it came from an older snapshot). Nothing was done. Take a new snapshot and use a ref from it.`, { code: error.code, ref: error.ref });
115420
+ return refusal3(`${tool}: element ${error.ref} is not on the page any more (it came from an older snapshot). Nothing was done. Take a new snapshot and use a ref from it.`, { code: error.code, ref: error.ref });
114831
115421
  case "browser_human_required": {
114832
115422
  const what = HUMAN_REASON_WORDS[error.reason] ?? "something only a person can do";
114833
115423
  const how = error.loginCommand ? ` The user can ${error.reason === "http-auth" ? "check access" : "sign in"} with: ${oneLine5(error.loginCommand, 300)}` : "";
@@ -114837,7 +115427,7 @@ function hostErrorToResult(tool, error) {
114837
115427
  ...error.loginCommand !== void 0 ? { loginCommand: error.loginCommand } : {}
114838
115428
  };
114839
115429
  return {
114840
- ...refusal2(`${tool}: ${error.origin || "the page"} is showing ${what}. Stop here and tell the user; do not sign in, solve it or type a password or code.${how}`, {
115430
+ ...refusal3(`${tool}: ${error.origin || "the page"} is showing ${what}. Stop here and tell the user; do not sign in, solve it or type a password or code.${how}`, {
114841
115431
  code: error.code,
114842
115432
  handoff: { kind: "human-required", reason: error.reason, detail }
114843
115433
  }),
@@ -114852,14 +115442,14 @@ function hostErrorToResult(tool, error) {
114852
115442
  };
114853
115443
  }
114854
115444
  case "browser_outcome_unknown":
114855
- return refusal2(`${tool}: ${oneLine5(error.message, 500)}`, {
115445
+ return refusal3(`${tool}: ${oneLine5(error.message, 500)}`, {
114856
115446
  code: error.code,
114857
115447
  action: error.action,
114858
115448
  outcome: error.outcome,
114859
115449
  retrySafety: error.retrySafety
114860
115450
  });
114861
115451
  case "browser_site_denied":
114862
- return refusal2(`${tool}: ${error.origin || "this site"} is not allowed by the operator's site rules. Do not retry; tell the user.`, { code: error.code, origin: error.origin });
115452
+ return refusal3(`${tool}: ${error.origin || "this site"} is not allowed by the operator's site rules. Do not retry; tell the user.`, { code: error.code, origin: error.origin });
114863
115453
  }
114864
115454
  }
114865
115455
  __name(hostErrorToResult, "hostErrorToResult");
@@ -117848,6 +118438,21 @@ export {
117848
118438
  createPeerEndpoint,
117849
118439
  formatPeerMessage,
117850
118440
  formatPeerNotice,
118441
+ DEFAULT_ACCOUNT_LABEL,
118442
+ CredentialWithdrawnError,
118443
+ AccountRegistryError,
118444
+ AccountLockError,
118445
+ codexRefreshLockPath,
118446
+ withAccountLock,
118447
+ withAccountLockSync,
118448
+ withAccountRefreshLock,
118449
+ ACCOUNTS_FILE_NAME,
118450
+ ACCOUNTS_FILE_VERSION,
118451
+ accountId,
118452
+ parseAccountId,
118453
+ createAccountRegistry,
118454
+ accountBoundPayload,
118455
+ resolveBoundAccount,
117851
118456
  PalConflictError,
117852
118457
  DiskPalStore,
117853
118458
  PalUnavailableError,
@@ -117967,4 +118572,4 @@ export {
117967
118572
  buildResidentToolEvidenceTools,
117968
118573
  createPalMessagingTools
117969
118574
  };
117970
- //# sourceMappingURL=chunk-O4MFP726.js.map
118575
+ //# sourceMappingURL=chunk-YTE3QIH3.js.map