@namzu/cli 45.2.0 → 45.3.1

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 (321) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/bin-main.d.ts.map +1 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/chunks/{acp-TYPW7WFK.js → acp-DBPT6HLS.js} +47 -47
  5. package/dist/chunks/{activity-command-D744W6SC.js → activity-command-LRJ7GKKA.js} +13 -13
  6. package/dist/chunks/{add-QEKJGVR4.js → add-VVCOEETE.js} +19 -19
  7. package/dist/chunks/{agent-JWTNZ4PK.js → agent-73YAS5CP.js} +37 -37
  8. package/dist/chunks/agent-session-XZXWL5UK.js +71 -0
  9. package/dist/chunks/{archive-FLZUJDJZ.js → archive-XSGGT3WT.js} +11 -11
  10. package/dist/chunks/{bin-main-UI3NYIJE.js → bin-main-TY6GSRGN.js} +31 -8
  11. package/dist/chunks/bin-main-TY6GSRGN.js.map +6 -0
  12. package/dist/chunks/{binding-JQUI2CTZ.js → binding-2BLX6TOQ.js} +3 -3
  13. package/dist/chunks/{browser-YZCY2CI6.js → browser-IGSENUE2.js} +6 -6
  14. package/dist/chunks/{chat-F3WXVEDM.js → chat-GFB57MWD.js} +16 -16
  15. package/dist/chunks/{chunk-PAY5TGHV.js → chunk-2BPJNDCY.js} +3 -3
  16. package/dist/chunks/{chunk-KY2WSKNM.js → chunk-2RP7EQM6.js} +2 -2
  17. package/dist/chunks/{chunk-HB4LEJMU.js → chunk-32TNYMYN.js} +3 -3
  18. package/dist/chunks/{chunk-D7BXM6WW.js → chunk-3JK34H57.js} +2 -2
  19. package/dist/chunks/{chunk-EVRWBRUB.js → chunk-3LB7TNKU.js} +2 -2
  20. package/dist/chunks/{chunk-U4YXQWPW.js → chunk-3QPGNGMH.js} +6 -6
  21. package/dist/chunks/{chunk-W6E3PSFH.js → chunk-3UZA4I32.js} +2 -2
  22. package/dist/chunks/{chunk-7HNWFGWD.js → chunk-43MVJB6D.js} +2 -2
  23. package/dist/chunks/{chunk-HIJXUSOS.js → chunk-45IW5SXC.js} +3 -3
  24. package/dist/chunks/{chunk-EVZAGFTY.js → chunk-53VZAZAI.js} +16 -12
  25. package/dist/chunks/chunk-53VZAZAI.js.map +6 -0
  26. package/dist/chunks/{chunk-6F4PW7TF.js → chunk-5AWO2BZT.js} +5 -5
  27. package/dist/chunks/{chunk-L3XUPXPP.js → chunk-5PBABKOO.js} +12 -12
  28. package/dist/chunks/{chunk-X4TNXFUB.js → chunk-5TRCWV7J.js} +64 -34
  29. package/dist/chunks/chunk-5TRCWV7J.js.map +6 -0
  30. package/dist/chunks/{chunk-POKKY7MR.js → chunk-6ZOD3GVR.js} +5 -5
  31. package/dist/chunks/{chunk-UQJPNUDU.js → chunk-AJ6XXZJU.js} +7 -7
  32. package/dist/chunks/{chunk-GXQ4G3KA.js → chunk-ANUVBWLR.js} +3 -3
  33. package/dist/chunks/{chunk-7BRK6EHB.js → chunk-B36O2XYM.js} +2 -2
  34. package/dist/chunks/{chunk-V3R3MR7F.js → chunk-B5WR5IF6.js} +4 -4
  35. package/dist/chunks/{chunk-TCRGKEEX.js → chunk-BL4Z6XEM.js} +2 -2
  36. package/dist/chunks/{chunk-EPIIR5CJ.js → chunk-DKPQ65OR.js} +9 -9
  37. package/dist/chunks/{chunk-PFFQOCEI.js → chunk-DPFI3M5Q.js} +2 -2
  38. package/dist/chunks/{chunk-JU7JQ62S.js → chunk-DSA6KENI.js} +3 -3
  39. package/dist/chunks/{chunk-PQTS7XQB.js → chunk-DUAP22BO.js} +12 -12
  40. package/dist/chunks/{chunk-HYPNAC4H.js → chunk-DZFQNHOA.js} +3 -3
  41. package/dist/chunks/{chunk-U5BN3L3Y.js → chunk-DZUB65K6.js} +2 -2
  42. package/dist/chunks/{chunk-CAOGKKB5.js → chunk-EB74JXDV.js} +3 -3
  43. package/dist/chunks/{chunk-WNOB6C62.js → chunk-EGZVMR4Y.js} +2 -2
  44. package/dist/chunks/{chunk-Q7ELMF4C.js → chunk-EKHGCYGE.js} +6 -6
  45. package/dist/chunks/{chunk-I6W3KJR3.js → chunk-FOXR7YSF.js} +2 -2
  46. package/dist/chunks/{chunk-RPCJJZTI.js → chunk-FR4VCS37.js} +3 -3
  47. package/dist/chunks/{chunk-NZ6DX5CL.js → chunk-GDETDUEE.js} +4 -4
  48. package/dist/chunks/{chunk-B7QEQ7Y3.js → chunk-GITVXMPC.js} +2 -2
  49. package/dist/chunks/{chunk-5W7CSQXQ.js → chunk-GRG7ZV6K.js} +4 -4
  50. package/dist/chunks/{chunk-XK26JNIF.js → chunk-HG6MH3OH.js} +6 -6
  51. package/dist/chunks/{chunk-LOKFLXQL.js → chunk-I3J3IRIZ.js} +2 -2
  52. package/dist/chunks/{chunk-7XAUAIGO.js → chunk-I3YUF54N.js} +4 -4
  53. package/dist/chunks/{chunk-ADG5OPNS.js → chunk-IAS5PYS7.js} +3 -3
  54. package/dist/chunks/{chunk-4YBTLYYH.js → chunk-ICDONDMK.js} +2 -2
  55. package/dist/chunks/{chunk-V26FS5VG.js → chunk-JI35RB5K.js} +11 -2
  56. package/dist/chunks/{chunk-V26FS5VG.js.map → chunk-JI35RB5K.js.map} +1 -1
  57. package/dist/chunks/{chunk-QWVWGW6I.js → chunk-JNUMQDCX.js} +2 -2
  58. package/dist/chunks/{chunk-LMVXENEF.js → chunk-KGVHER2M.js} +3 -3
  59. package/dist/chunks/{chunk-Q6RZ64FS.js → chunk-KKCNOBMK.js} +5 -5
  60. package/dist/chunks/{chunk-BWI7L43E.js → chunk-KQ2PTOJI.js} +6 -6
  61. package/dist/chunks/{chunk-5DFBOMTX.js → chunk-LLPBMY2C.js} +3 -3
  62. package/dist/chunks/{chunk-4HL5LUP5.js → chunk-N4DSUOEW.js} +1105 -644
  63. package/dist/chunks/chunk-N4DSUOEW.js.map +6 -0
  64. package/dist/chunks/{chunk-TGPKTH2S.js → chunk-NJT24324.js} +2 -2
  65. package/dist/chunks/{chunk-E3OXUQQB.js → chunk-NLBRNFW3.js} +3 -3
  66. package/dist/chunks/{chunk-4E33SWZU.js → chunk-NUIGGV5J.js} +4 -4
  67. package/dist/chunks/{chunk-IFEBBQ2M.js → chunk-NUYI4C7E.js} +3 -3
  68. package/dist/chunks/{chunk-QXNROEIH.js → chunk-O6TU3NIP.js} +4 -4
  69. package/dist/chunks/{chunk-Q6DM2TVI.js → chunk-OMCSPAV2.js} +2 -2
  70. package/dist/chunks/{chunk-ZB45QDNU.js → chunk-OXLZ5NRW.js} +3 -3
  71. package/dist/chunks/{chunk-4WHMQBUC.js → chunk-PPKM44OM.js} +33 -33
  72. package/dist/chunks/{chunk-XHR3UCKT.js → chunk-PSBKJPMK.js} +4 -4
  73. package/dist/chunks/{chunk-H5H6HDRA.js → chunk-QUUN2RDP.js} +3 -3
  74. package/dist/chunks/{chunk-NFATUZMX.js → chunk-R3DTSLY2.js} +2 -2
  75. package/dist/chunks/{chunk-NGMXEU2B.js → chunk-R62TJLZW.js} +2 -2
  76. package/dist/chunks/{chunk-XN7C5GWO.js → chunk-RH7CN6ME.js} +2 -2
  77. package/dist/chunks/{chunk-6OWRRNLC.js → chunk-RY6BVTTU.js} +2 -2
  78. package/dist/chunks/{chunk-IPVDXTWF.js → chunk-T6ZPQGU4.js} +2 -2
  79. package/dist/chunks/{chunk-H2JLRNYH.js → chunk-T7STEYNM.js} +8 -8
  80. package/dist/chunks/{chunk-RISNSR62.js → chunk-TJ254FRV.js} +3 -3
  81. package/dist/chunks/{chunk-A72NRUYG.js → chunk-TMWWZT66.js} +13 -13
  82. package/dist/chunks/{chunk-JCLZ5HXI.js → chunk-TVT2HS3D.js} +2 -2
  83. package/dist/chunks/{chunk-T3NLKQO2.js → chunk-UBKOLSTM.js} +4 -4
  84. package/dist/chunks/{chunk-NS4PN3SI.js → chunk-URJIXJEB.js} +2 -2
  85. package/dist/chunks/{chunk-IZDYKTPN.js → chunk-UVOPFFK4.js} +6 -6
  86. package/dist/chunks/{chunk-VZC7FE4F.js → chunk-V2CEMLV5.js} +11 -11
  87. package/dist/chunks/{chunk-NI3LZ6UX.js → chunk-VBGOWIVL.js} +5 -5
  88. package/dist/chunks/{chunk-NI3LZ6UX.js.map → chunk-VBGOWIVL.js.map} +1 -1
  89. package/dist/chunks/{chunk-X2F5ZFBV.js → chunk-VGPWLUQF.js} +4 -4
  90. package/dist/chunks/{chunk-GSAYGBOR.js → chunk-VKK2JM4X.js} +2 -2
  91. package/dist/chunks/{chunk-TOJSNO4M.js → chunk-VNMY5YWE.js} +5 -5
  92. package/dist/chunks/{chunk-5OGY4CE7.js → chunk-WXB7INQA.js} +2 -2
  93. package/dist/chunks/{chunk-24NEAMG5.js → chunk-X2IOSW35.js} +3 -3
  94. package/dist/chunks/{chunk-XOIXLN2Y.js → chunk-XMXF2LN4.js} +3 -3
  95. package/dist/chunks/{chunk-6WPKPHE2.js → chunk-XU5B5C4Q.js} +10 -10
  96. package/dist/chunks/{chunk-H2RDYYTB.js → chunk-Y6F4ZP5P.js} +2 -2
  97. package/dist/chunks/{chunk-6XL5ZMAL.js → chunk-YD7Y5T7K.js} +3 -3
  98. package/dist/chunks/{chunk-6NDJLXKW.js → chunk-YHBEEH3I.js} +4 -4
  99. package/dist/chunks/{chunk-VPJG7NQL.js → chunk-Z5ESEAEC.js} +2 -2
  100. package/dist/chunks/{cli-runtime-QOMHGRZL.js → cli-runtime-RV4V7WDI.js} +10 -10
  101. package/dist/chunks/{commands-56WUDKVN.js → commands-VH34H2QY.js} +5 -5
  102. package/dist/chunks/{crash-report-KHJZ3AKU.js → crash-report-D3E72S5E.js} +6 -6
  103. package/dist/chunks/{dist-QZPA2XDK.js → dist-3QIN7RZN.js} +24 -2
  104. package/dist/chunks/{dist-BLCQRSQS.js → dist-6A2IF77H.js} +2 -2
  105. package/dist/chunks/{dist-7UW2VLWO.js → dist-6OYIJEC5.js} +4 -3
  106. package/dist/chunks/{dist-7UW2VLWO.js.map → dist-6OYIJEC5.js.map} +1 -1
  107. package/dist/chunks/{dist-L757TGUH.js → dist-7K2J7WN7.js} +5 -4
  108. package/dist/chunks/dist-7K2J7WN7.js.map +6 -0
  109. package/dist/chunks/{dist-SEXSU4PO.js → dist-FBAG65SB.js} +2 -2
  110. package/dist/chunks/{dist-GUHZ3EE6.js → dist-J7ABDC66.js} +2 -2
  111. package/dist/chunks/{dist-BLC5XSXL.js → dist-M3PVYLEP.js} +2 -2
  112. package/dist/chunks/{dist-Y6IO47UU.js → dist-NO3HG2UB.js} +5 -2
  113. package/dist/chunks/dist-NO3HG2UB.js.map +6 -0
  114. package/dist/chunks/{doctor-LCRG5FBA.js → doctor-NUXR6O3U.js} +16 -16
  115. package/dist/chunks/{drain-47IMDCI5.js → drain-PSU2Z3LK.js} +10 -10
  116. package/dist/chunks/{entry-P6YPWRQW.js → entry-K4X4GXZF.js} +6 -6
  117. package/dist/chunks/{eval-5ZIBALCB.js → eval-5UWONKX4.js} +2 -2
  118. package/dist/chunks/{exec-ELIM7XVY.js → exec-7NV7EEM3.js} +34 -34
  119. package/dist/chunks/{home-DXPCVXZK.js → home-4BZTCLM4.js} +3 -3
  120. package/dist/chunks/{host-QE4D3UXC.js → host-3W7ZPE6Q.js} +10 -10
  121. package/dist/chunks/{host-queries-5H765XNX.js → host-queries-2E47CZJG.js} +16 -16
  122. package/dist/chunks/{learn-Y5IBBZDY.js → learn-KKRGJ7OU.js} +13 -13
  123. package/dist/chunks/{learn-builtin-ND3T6U5L.js → learn-builtin-JUJQAJOT.js} +16 -16
  124. package/dist/chunks/{lifecycle-FJS7LD7B.js → lifecycle-MP6OBPVC.js} +29 -29
  125. package/dist/chunks/{list-6HQMG7TU.js → list-JE6255IG.js} +10 -10
  126. package/dist/chunks/{live-CSA2LX3R.js → live-XFKDZJMS.js} +15 -15
  127. package/dist/chunks/{login-42ZPPMYK.js → login-DY2DI7YX.js} +13 -13
  128. package/dist/chunks/{logs-7MAFXNFR.js → logs-XB6AUHPP.js} +4 -4
  129. package/dist/chunks/{mcp-5RQSD6QV.js → mcp-PKLR4XKA.js} +20 -20
  130. package/dist/chunks/{message-command-V3CL4DNT.js → message-command-4DKALLO7.js} +43 -43
  131. package/dist/chunks/{open-3I5NZTSX.js → open-PNJIWVN4.js} +8 -8
  132. package/dist/chunks/{operator-tools-PK2WYSF3.js → operator-tools-SE6DETX5.js} +14 -14
  133. package/dist/chunks/{output-schema-2UJ7LOOX.js → output-schema-HK4MQIO6.js} +3 -3
  134. package/dist/chunks/{pal-WXN4O3DD.js → pal-7T6ETMJK.js} +16 -16
  135. package/dist/chunks/{peers-JQOUU3CX.js → peers-IPIIDLUU.js} +6 -6
  136. package/dist/chunks/{plain-report-IOYN4O6N.js → plain-report-XVPBQDLE.js} +2 -2
  137. package/dist/chunks/{providers-SI467SWN.js → providers-3I6EVD4I.js} +11 -11
  138. package/dist/chunks/{pty-T5LBAATA.js → pty-DTQ5ZOE3.js} +3 -3
  139. package/dist/chunks/{resident-NGQORA2W.js → resident-CMZVKVY7.js} +24 -24
  140. package/dist/chunks/resume-YYBSE3OJ.js +24 -0
  141. package/dist/chunks/{resume-command-V6ZKY7J6.js → resume-command-5LEKVJFF.js} +4 -4
  142. package/dist/chunks/{schedule-4L4DTRC5.js → schedule-3Q67DYJR.js} +8 -8
  143. package/dist/chunks/{service-EV6VQYJD.js → service-YR5MVVB3.js} +28 -28
  144. package/dist/chunks/{session-step-ZCZNC52S.js → session-step-HBDCVIK3.js} +15 -15
  145. package/dist/chunks/{skills-QARQHL6M.js → skills-QX2MGKTB.js} +8 -8
  146. package/dist/chunks/{start-check-W72K6M5Q.js → start-check-GLZGWX5M.js} +2 -2
  147. package/dist/chunks/startup-failure-RLKFISWY.js +27 -0
  148. package/dist/chunks/startup-failure-RLKFISWY.js.map +6 -0
  149. package/dist/chunks/{state-ADQWQEYB.js → state-KWLWSCEF.js} +2 -2
  150. package/dist/chunks/{store-KOGQWG66.js → store-BXCQIMBR.js} +11 -11
  151. package/dist/chunks/{store-RF6D7U2T.js → store-R2GIDHFX.js} +6 -6
  152. package/dist/chunks/{store-IVVYIPV2.js → store-SRK5QXWM.js} +3 -3
  153. package/dist/chunks/{store-TFJ73ZAM.js → store-TWOMDD7Y.js} +4 -4
  154. package/dist/chunks/{tui-CCAGK7BG.js → tui-ZOZ7T2IJ.js} +77 -71
  155. package/dist/chunks/tui-ZOZ7T2IJ.js.map +6 -0
  156. package/dist/chunks/{upgrade-LN6TFWDW.js → upgrade-DPHHR3QO.js} +8 -9
  157. package/dist/chunks/upgrade-DPHHR3QO.js.map +6 -0
  158. package/dist/chunks/{workspaces-5ZKKOX4X.js → workspaces-7BI5D7PW.js} +16 -16
  159. package/dist/chunks/{worktree-5M2XFFJT.js → worktree-QXYA5BQF.js} +13 -13
  160. package/dist/commands/upgrade.d.ts.map +1 -1
  161. package/dist/context/environment.d.ts +9 -1
  162. package/dist/context/environment.d.ts.map +1 -1
  163. package/dist/doctor/checks/runtime.d.ts +1 -1
  164. package/dist/doctor/checks/runtime.d.ts.map +1 -1
  165. package/dist/index.js +19 -19
  166. package/dist/integrations/resident/runner-worker.js +21 -21
  167. package/dist/reminders/environment.d.ts +1 -1
  168. package/dist/reminders/environment.d.ts.map +1 -1
  169. package/dist/reminders/index.d.ts +1 -1
  170. package/dist/reminders/index.d.ts.map +1 -1
  171. package/dist/startup-failure.d.ts +12 -0
  172. package/dist/startup-failure.d.ts.map +1 -0
  173. package/dist/tui/App.d.ts.map +1 -1
  174. package/dist/tui/agent.d.ts +9 -0
  175. package/dist/tui/agent.d.ts.map +1 -1
  176. package/dist/tui/capability-notice.d.ts +7 -0
  177. package/dist/tui/capability-notice.d.ts.map +1 -1
  178. package/dist/tui/external-editor.d.ts.map +1 -1
  179. package/package.json +9 -9
  180. package/dist/chunks/agent-session-OGPKSSKG.js +0 -71
  181. package/dist/chunks/bin-main-UI3NYIJE.js.map +0 -6
  182. package/dist/chunks/chunk-4HL5LUP5.js.map +0 -6
  183. package/dist/chunks/chunk-EVZAGFTY.js.map +0 -6
  184. package/dist/chunks/chunk-X4TNXFUB.js.map +0 -6
  185. package/dist/chunks/dist-L757TGUH.js.map +0 -6
  186. package/dist/chunks/dist-Y6IO47UU.js.map +0 -6
  187. package/dist/chunks/resume-GPXJJXCK.js +0 -24
  188. package/dist/chunks/tui-CCAGK7BG.js.map +0 -6
  189. package/dist/chunks/upgrade-LN6TFWDW.js.map +0 -6
  190. /package/dist/chunks/{acp-TYPW7WFK.js.map → acp-DBPT6HLS.js.map} +0 -0
  191. /package/dist/chunks/{activity-command-D744W6SC.js.map → activity-command-LRJ7GKKA.js.map} +0 -0
  192. /package/dist/chunks/{add-QEKJGVR4.js.map → add-VVCOEETE.js.map} +0 -0
  193. /package/dist/chunks/{agent-JWTNZ4PK.js.map → agent-73YAS5CP.js.map} +0 -0
  194. /package/dist/chunks/{agent-session-OGPKSSKG.js.map → agent-session-XZXWL5UK.js.map} +0 -0
  195. /package/dist/chunks/{archive-FLZUJDJZ.js.map → archive-XSGGT3WT.js.map} +0 -0
  196. /package/dist/chunks/{binding-JQUI2CTZ.js.map → binding-2BLX6TOQ.js.map} +0 -0
  197. /package/dist/chunks/{browser-YZCY2CI6.js.map → browser-IGSENUE2.js.map} +0 -0
  198. /package/dist/chunks/{chat-F3WXVEDM.js.map → chat-GFB57MWD.js.map} +0 -0
  199. /package/dist/chunks/{chunk-PAY5TGHV.js.map → chunk-2BPJNDCY.js.map} +0 -0
  200. /package/dist/chunks/{chunk-KY2WSKNM.js.map → chunk-2RP7EQM6.js.map} +0 -0
  201. /package/dist/chunks/{chunk-HB4LEJMU.js.map → chunk-32TNYMYN.js.map} +0 -0
  202. /package/dist/chunks/{chunk-D7BXM6WW.js.map → chunk-3JK34H57.js.map} +0 -0
  203. /package/dist/chunks/{chunk-EVRWBRUB.js.map → chunk-3LB7TNKU.js.map} +0 -0
  204. /package/dist/chunks/{chunk-U4YXQWPW.js.map → chunk-3QPGNGMH.js.map} +0 -0
  205. /package/dist/chunks/{chunk-W6E3PSFH.js.map → chunk-3UZA4I32.js.map} +0 -0
  206. /package/dist/chunks/{chunk-7HNWFGWD.js.map → chunk-43MVJB6D.js.map} +0 -0
  207. /package/dist/chunks/{chunk-HIJXUSOS.js.map → chunk-45IW5SXC.js.map} +0 -0
  208. /package/dist/chunks/{chunk-6F4PW7TF.js.map → chunk-5AWO2BZT.js.map} +0 -0
  209. /package/dist/chunks/{chunk-L3XUPXPP.js.map → chunk-5PBABKOO.js.map} +0 -0
  210. /package/dist/chunks/{chunk-POKKY7MR.js.map → chunk-6ZOD3GVR.js.map} +0 -0
  211. /package/dist/chunks/{chunk-UQJPNUDU.js.map → chunk-AJ6XXZJU.js.map} +0 -0
  212. /package/dist/chunks/{chunk-GXQ4G3KA.js.map → chunk-ANUVBWLR.js.map} +0 -0
  213. /package/dist/chunks/{chunk-7BRK6EHB.js.map → chunk-B36O2XYM.js.map} +0 -0
  214. /package/dist/chunks/{chunk-V3R3MR7F.js.map → chunk-B5WR5IF6.js.map} +0 -0
  215. /package/dist/chunks/{chunk-TCRGKEEX.js.map → chunk-BL4Z6XEM.js.map} +0 -0
  216. /package/dist/chunks/{chunk-EPIIR5CJ.js.map → chunk-DKPQ65OR.js.map} +0 -0
  217. /package/dist/chunks/{chunk-PFFQOCEI.js.map → chunk-DPFI3M5Q.js.map} +0 -0
  218. /package/dist/chunks/{chunk-JU7JQ62S.js.map → chunk-DSA6KENI.js.map} +0 -0
  219. /package/dist/chunks/{chunk-PQTS7XQB.js.map → chunk-DUAP22BO.js.map} +0 -0
  220. /package/dist/chunks/{chunk-HYPNAC4H.js.map → chunk-DZFQNHOA.js.map} +0 -0
  221. /package/dist/chunks/{chunk-U5BN3L3Y.js.map → chunk-DZUB65K6.js.map} +0 -0
  222. /package/dist/chunks/{chunk-CAOGKKB5.js.map → chunk-EB74JXDV.js.map} +0 -0
  223. /package/dist/chunks/{chunk-WNOB6C62.js.map → chunk-EGZVMR4Y.js.map} +0 -0
  224. /package/dist/chunks/{chunk-Q7ELMF4C.js.map → chunk-EKHGCYGE.js.map} +0 -0
  225. /package/dist/chunks/{chunk-I6W3KJR3.js.map → chunk-FOXR7YSF.js.map} +0 -0
  226. /package/dist/chunks/{chunk-RPCJJZTI.js.map → chunk-FR4VCS37.js.map} +0 -0
  227. /package/dist/chunks/{chunk-NZ6DX5CL.js.map → chunk-GDETDUEE.js.map} +0 -0
  228. /package/dist/chunks/{chunk-B7QEQ7Y3.js.map → chunk-GITVXMPC.js.map} +0 -0
  229. /package/dist/chunks/{chunk-5W7CSQXQ.js.map → chunk-GRG7ZV6K.js.map} +0 -0
  230. /package/dist/chunks/{chunk-XK26JNIF.js.map → chunk-HG6MH3OH.js.map} +0 -0
  231. /package/dist/chunks/{chunk-LOKFLXQL.js.map → chunk-I3J3IRIZ.js.map} +0 -0
  232. /package/dist/chunks/{chunk-7XAUAIGO.js.map → chunk-I3YUF54N.js.map} +0 -0
  233. /package/dist/chunks/{chunk-ADG5OPNS.js.map → chunk-IAS5PYS7.js.map} +0 -0
  234. /package/dist/chunks/{chunk-4YBTLYYH.js.map → chunk-ICDONDMK.js.map} +0 -0
  235. /package/dist/chunks/{chunk-QWVWGW6I.js.map → chunk-JNUMQDCX.js.map} +0 -0
  236. /package/dist/chunks/{chunk-LMVXENEF.js.map → chunk-KGVHER2M.js.map} +0 -0
  237. /package/dist/chunks/{chunk-Q6RZ64FS.js.map → chunk-KKCNOBMK.js.map} +0 -0
  238. /package/dist/chunks/{chunk-BWI7L43E.js.map → chunk-KQ2PTOJI.js.map} +0 -0
  239. /package/dist/chunks/{chunk-5DFBOMTX.js.map → chunk-LLPBMY2C.js.map} +0 -0
  240. /package/dist/chunks/{chunk-TGPKTH2S.js.map → chunk-NJT24324.js.map} +0 -0
  241. /package/dist/chunks/{chunk-E3OXUQQB.js.map → chunk-NLBRNFW3.js.map} +0 -0
  242. /package/dist/chunks/{chunk-4E33SWZU.js.map → chunk-NUIGGV5J.js.map} +0 -0
  243. /package/dist/chunks/{chunk-IFEBBQ2M.js.map → chunk-NUYI4C7E.js.map} +0 -0
  244. /package/dist/chunks/{chunk-QXNROEIH.js.map → chunk-O6TU3NIP.js.map} +0 -0
  245. /package/dist/chunks/{chunk-Q6DM2TVI.js.map → chunk-OMCSPAV2.js.map} +0 -0
  246. /package/dist/chunks/{chunk-ZB45QDNU.js.map → chunk-OXLZ5NRW.js.map} +0 -0
  247. /package/dist/chunks/{chunk-4WHMQBUC.js.map → chunk-PPKM44OM.js.map} +0 -0
  248. /package/dist/chunks/{chunk-XHR3UCKT.js.map → chunk-PSBKJPMK.js.map} +0 -0
  249. /package/dist/chunks/{chunk-H5H6HDRA.js.map → chunk-QUUN2RDP.js.map} +0 -0
  250. /package/dist/chunks/{chunk-NFATUZMX.js.map → chunk-R3DTSLY2.js.map} +0 -0
  251. /package/dist/chunks/{chunk-NGMXEU2B.js.map → chunk-R62TJLZW.js.map} +0 -0
  252. /package/dist/chunks/{chunk-XN7C5GWO.js.map → chunk-RH7CN6ME.js.map} +0 -0
  253. /package/dist/chunks/{chunk-6OWRRNLC.js.map → chunk-RY6BVTTU.js.map} +0 -0
  254. /package/dist/chunks/{chunk-IPVDXTWF.js.map → chunk-T6ZPQGU4.js.map} +0 -0
  255. /package/dist/chunks/{chunk-H2JLRNYH.js.map → chunk-T7STEYNM.js.map} +0 -0
  256. /package/dist/chunks/{chunk-RISNSR62.js.map → chunk-TJ254FRV.js.map} +0 -0
  257. /package/dist/chunks/{chunk-A72NRUYG.js.map → chunk-TMWWZT66.js.map} +0 -0
  258. /package/dist/chunks/{chunk-JCLZ5HXI.js.map → chunk-TVT2HS3D.js.map} +0 -0
  259. /package/dist/chunks/{chunk-T3NLKQO2.js.map → chunk-UBKOLSTM.js.map} +0 -0
  260. /package/dist/chunks/{chunk-NS4PN3SI.js.map → chunk-URJIXJEB.js.map} +0 -0
  261. /package/dist/chunks/{chunk-IZDYKTPN.js.map → chunk-UVOPFFK4.js.map} +0 -0
  262. /package/dist/chunks/{chunk-VZC7FE4F.js.map → chunk-V2CEMLV5.js.map} +0 -0
  263. /package/dist/chunks/{chunk-X2F5ZFBV.js.map → chunk-VGPWLUQF.js.map} +0 -0
  264. /package/dist/chunks/{chunk-GSAYGBOR.js.map → chunk-VKK2JM4X.js.map} +0 -0
  265. /package/dist/chunks/{chunk-TOJSNO4M.js.map → chunk-VNMY5YWE.js.map} +0 -0
  266. /package/dist/chunks/{chunk-5OGY4CE7.js.map → chunk-WXB7INQA.js.map} +0 -0
  267. /package/dist/chunks/{chunk-24NEAMG5.js.map → chunk-X2IOSW35.js.map} +0 -0
  268. /package/dist/chunks/{chunk-XOIXLN2Y.js.map → chunk-XMXF2LN4.js.map} +0 -0
  269. /package/dist/chunks/{chunk-6WPKPHE2.js.map → chunk-XU5B5C4Q.js.map} +0 -0
  270. /package/dist/chunks/{chunk-H2RDYYTB.js.map → chunk-Y6F4ZP5P.js.map} +0 -0
  271. /package/dist/chunks/{chunk-6XL5ZMAL.js.map → chunk-YD7Y5T7K.js.map} +0 -0
  272. /package/dist/chunks/{chunk-6NDJLXKW.js.map → chunk-YHBEEH3I.js.map} +0 -0
  273. /package/dist/chunks/{chunk-VPJG7NQL.js.map → chunk-Z5ESEAEC.js.map} +0 -0
  274. /package/dist/chunks/{cli-runtime-QOMHGRZL.js.map → cli-runtime-RV4V7WDI.js.map} +0 -0
  275. /package/dist/chunks/{commands-56WUDKVN.js.map → commands-VH34H2QY.js.map} +0 -0
  276. /package/dist/chunks/{crash-report-KHJZ3AKU.js.map → crash-report-D3E72S5E.js.map} +0 -0
  277. /package/dist/chunks/{dist-QZPA2XDK.js.map → dist-3QIN7RZN.js.map} +0 -0
  278. /package/dist/chunks/{dist-BLCQRSQS.js.map → dist-6A2IF77H.js.map} +0 -0
  279. /package/dist/chunks/{dist-SEXSU4PO.js.map → dist-FBAG65SB.js.map} +0 -0
  280. /package/dist/chunks/{dist-GUHZ3EE6.js.map → dist-J7ABDC66.js.map} +0 -0
  281. /package/dist/chunks/{dist-BLC5XSXL.js.map → dist-M3PVYLEP.js.map} +0 -0
  282. /package/dist/chunks/{doctor-LCRG5FBA.js.map → doctor-NUXR6O3U.js.map} +0 -0
  283. /package/dist/chunks/{drain-47IMDCI5.js.map → drain-PSU2Z3LK.js.map} +0 -0
  284. /package/dist/chunks/{entry-P6YPWRQW.js.map → entry-K4X4GXZF.js.map} +0 -0
  285. /package/dist/chunks/{eval-5ZIBALCB.js.map → eval-5UWONKX4.js.map} +0 -0
  286. /package/dist/chunks/{exec-ELIM7XVY.js.map → exec-7NV7EEM3.js.map} +0 -0
  287. /package/dist/chunks/{home-DXPCVXZK.js.map → home-4BZTCLM4.js.map} +0 -0
  288. /package/dist/chunks/{host-QE4D3UXC.js.map → host-3W7ZPE6Q.js.map} +0 -0
  289. /package/dist/chunks/{host-queries-5H765XNX.js.map → host-queries-2E47CZJG.js.map} +0 -0
  290. /package/dist/chunks/{learn-Y5IBBZDY.js.map → learn-KKRGJ7OU.js.map} +0 -0
  291. /package/dist/chunks/{learn-builtin-ND3T6U5L.js.map → learn-builtin-JUJQAJOT.js.map} +0 -0
  292. /package/dist/chunks/{lifecycle-FJS7LD7B.js.map → lifecycle-MP6OBPVC.js.map} +0 -0
  293. /package/dist/chunks/{list-6HQMG7TU.js.map → list-JE6255IG.js.map} +0 -0
  294. /package/dist/chunks/{live-CSA2LX3R.js.map → live-XFKDZJMS.js.map} +0 -0
  295. /package/dist/chunks/{login-42ZPPMYK.js.map → login-DY2DI7YX.js.map} +0 -0
  296. /package/dist/chunks/{logs-7MAFXNFR.js.map → logs-XB6AUHPP.js.map} +0 -0
  297. /package/dist/chunks/{mcp-5RQSD6QV.js.map → mcp-PKLR4XKA.js.map} +0 -0
  298. /package/dist/chunks/{message-command-V3CL4DNT.js.map → message-command-4DKALLO7.js.map} +0 -0
  299. /package/dist/chunks/{open-3I5NZTSX.js.map → open-PNJIWVN4.js.map} +0 -0
  300. /package/dist/chunks/{operator-tools-PK2WYSF3.js.map → operator-tools-SE6DETX5.js.map} +0 -0
  301. /package/dist/chunks/{output-schema-2UJ7LOOX.js.map → output-schema-HK4MQIO6.js.map} +0 -0
  302. /package/dist/chunks/{pal-WXN4O3DD.js.map → pal-7T6ETMJK.js.map} +0 -0
  303. /package/dist/chunks/{peers-JQOUU3CX.js.map → peers-IPIIDLUU.js.map} +0 -0
  304. /package/dist/chunks/{plain-report-IOYN4O6N.js.map → plain-report-XVPBQDLE.js.map} +0 -0
  305. /package/dist/chunks/{providers-SI467SWN.js.map → providers-3I6EVD4I.js.map} +0 -0
  306. /package/dist/chunks/{pty-T5LBAATA.js.map → pty-DTQ5ZOE3.js.map} +0 -0
  307. /package/dist/chunks/{resident-NGQORA2W.js.map → resident-CMZVKVY7.js.map} +0 -0
  308. /package/dist/chunks/{resume-GPXJJXCK.js.map → resume-YYBSE3OJ.js.map} +0 -0
  309. /package/dist/chunks/{resume-command-V6ZKY7J6.js.map → resume-command-5LEKVJFF.js.map} +0 -0
  310. /package/dist/chunks/{schedule-4L4DTRC5.js.map → schedule-3Q67DYJR.js.map} +0 -0
  311. /package/dist/chunks/{service-EV6VQYJD.js.map → service-YR5MVVB3.js.map} +0 -0
  312. /package/dist/chunks/{session-step-ZCZNC52S.js.map → session-step-HBDCVIK3.js.map} +0 -0
  313. /package/dist/chunks/{skills-QARQHL6M.js.map → skills-QX2MGKTB.js.map} +0 -0
  314. /package/dist/chunks/{start-check-W72K6M5Q.js.map → start-check-GLZGWX5M.js.map} +0 -0
  315. /package/dist/chunks/{state-ADQWQEYB.js.map → state-KWLWSCEF.js.map} +0 -0
  316. /package/dist/chunks/{store-IVVYIPV2.js.map → store-BXCQIMBR.js.map} +0 -0
  317. /package/dist/chunks/{store-KOGQWG66.js.map → store-R2GIDHFX.js.map} +0 -0
  318. /package/dist/chunks/{store-RF6D7U2T.js.map → store-SRK5QXWM.js.map} +0 -0
  319. /package/dist/chunks/{store-TFJ73ZAM.js.map → store-TWOMDD7Y.js.map} +0 -0
  320. /package/dist/chunks/{workspaces-5ZKKOX4X.js.map → workspaces-7BI5D7PW.js.map} +0 -0
  321. /package/dist/chunks/{worktree-5M2XFFJT.js.map → worktree-QXYA5BQF.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 = "60.1.0";
307
+ var VERSION = "60.2.1";
308
308
 
309
309
  // ../sdk/dist/runtime/harness-session/index.js
310
310
  import { posix, win32 } from "node:path";
@@ -5597,7 +5597,9 @@ var EPHEMERAL_EVENT_TYPES = /* @__PURE__ */ new Set([
5597
5597
  "reasoning_delta",
5598
5598
  "tool_progress",
5599
5599
  "monitor_event",
5600
- "compaction_started"
5600
+ "compaction_started",
5601
+ "session_log_degraded",
5602
+ "session_log_recovered"
5601
5603
  ]);
5602
5604
  function isEphemeralEvent(event) {
5603
5605
  return EPHEMERAL_EVENT_TYPES.has(event.type);
@@ -6045,10 +6047,10 @@ var ExternalHarnessSession = class {
6045
6047
  }
6046
6048
  }
6047
6049
  makeActive(turnId6, operationId, startedAt) {
6048
- let resolve34;
6050
+ let resolve35;
6049
6051
  let reject2;
6050
6052
  const done = new Promise((yes, no) => {
6051
- resolve34 = yes;
6053
+ resolve35 = yes;
6052
6054
  reject2 = no;
6053
6055
  });
6054
6056
  void done.catch(() => void 0);
@@ -6058,7 +6060,7 @@ var ExternalHarnessSession = class {
6058
6060
  startedAt,
6059
6061
  items: /* @__PURE__ */ new Map(),
6060
6062
  reviews: /* @__PURE__ */ new Map(),
6061
- resolve: resolve34,
6063
+ resolve: resolve35,
6062
6064
  reject: reject2,
6063
6065
  done
6064
6066
  };
@@ -6896,8 +6898,8 @@ function windowsEnv(env, name2) {
6896
6898
  }
6897
6899
  __name(windowsEnv, "windowsEnv");
6898
6900
  function insideDirectory(path3, directory) {
6899
- const relative16 = win322.relative(directory, path3);
6900
- return relative16 === "" || !relative16.startsWith("..") && !win322.isAbsolute(relative16);
6901
+ const relative17 = win322.relative(directory, path3);
6902
+ return relative17 === "" || !relative17.startsWith("..") && !win322.isAbsolute(relative17);
6901
6903
  }
6902
6904
  __name(insideDirectory, "insideDirectory");
6903
6905
  function findGitBash(probe2) {
@@ -8230,13 +8232,13 @@ var GuardedFetchProvider = class {
8230
8232
  operation.throwIfStopped();
8231
8233
  return url;
8232
8234
  }
8233
- const resolve34 = this.config.resolve ?? (async (name2) => (await lookup(name2, { all: true })).map((r) => r.address));
8235
+ const resolve35 = this.config.resolve ?? (async (name2) => (await lookup(name2, { all: true })).map((r) => r.address));
8234
8236
  let addresses;
8235
8237
  if (isIP(hostname)) {
8236
8238
  addresses = [hostname];
8237
8239
  } else {
8238
8240
  try {
8239
- addresses = await operation.run(() => resolve34(hostname, operation.signal));
8241
+ addresses = await operation.run(() => resolve35(hostname, operation.signal));
8240
8242
  } catch (err) {
8241
8243
  operation.throwIfStopped();
8242
8244
  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" });
@@ -8582,9 +8584,9 @@ async function vetWebSocketTarget(raw, options = {}) {
8582
8584
  if (literal !== 0) {
8583
8585
  addresses = [hostname];
8584
8586
  } else {
8585
- const resolve34 = options.resolve ?? (async (name2) => (await dnsLookup(name2, { all: true })).map((r) => r.address));
8587
+ const resolve35 = options.resolve ?? (async (name2) => (await dnsLookup(name2, { all: true })).map((r) => r.address));
8586
8588
  try {
8587
- addresses = await resolve34(hostname);
8589
+ addresses = await resolve35(hostname);
8588
8590
  } catch (err) {
8589
8591
  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.`);
8590
8592
  }
@@ -9118,8 +9120,8 @@ var BackgroundJobRegistry = class {
9118
9120
  };
9119
9121
  let startError;
9120
9122
  let settleStarted;
9121
- const startedPromise = new Promise((resolve34) => {
9122
- settleStarted = /* @__PURE__ */ __name(() => resolve34(startError === void 0 ? {} : { error: startError }), "settleStarted");
9123
+ const startedPromise = new Promise((resolve35) => {
9124
+ settleStarted = /* @__PURE__ */ __name(() => resolve35(startError === void 0 ? {} : { error: startError }), "settleStarted");
9123
9125
  });
9124
9126
  if (params.spawn || child.pid !== void 0)
9125
9127
  settleStarted();
@@ -9165,7 +9167,7 @@ var BackgroundJobRegistry = class {
9165
9167
  outputChunks: [],
9166
9168
  outputObservers: /* @__PURE__ */ new Set(),
9167
9169
  started: startedPromise,
9168
- exit: new Promise((resolve34) => {
9170
+ exit: new Promise((resolve35) => {
9169
9171
  let spawned = child.pid !== void 0;
9170
9172
  let failedToSpawn = false;
9171
9173
  let finalized = false;
@@ -9184,7 +9186,7 @@ var BackgroundJobRegistry = class {
9184
9186
  ...code === null ? {} : { exitCode: code },
9185
9187
  ...signal ? { signal } : {}
9186
9188
  };
9187
- resolve34();
9189
+ resolve35();
9188
9190
  for (const observer of entry.outputObservers)
9189
9191
  observer();
9190
9192
  if (entry.monitor) {
@@ -9383,7 +9385,7 @@ var BackgroundJobRegistry = class {
9383
9385
  const signal = opts.signal;
9384
9386
  if (signal.aborted)
9385
9387
  return Promise.reject(signal.reason);
9386
- return new Promise((resolve34, reject2) => {
9388
+ return new Promise((resolve35, reject2) => {
9387
9389
  let disposeAbort = /* @__PURE__ */ __name(() => {
9388
9390
  }, "disposeAbort");
9389
9391
  const unsubscribe = this.onExit((job) => {
@@ -9391,7 +9393,7 @@ var BackgroundJobRegistry = class {
9391
9393
  return;
9392
9394
  unsubscribe();
9393
9395
  disposeAbort();
9394
- resolve34(job);
9396
+ resolve35(job);
9395
9397
  });
9396
9398
  disposeAbort = subscribeToAbort(signal, () => {
9397
9399
  unsubscribe();
@@ -9488,7 +9490,7 @@ var BackgroundJobRegistry = class {
9488
9490
  throw new BackgroundJobOutputWaitLimitError({ owner, limit: globalLimit, scope: "registry" });
9489
9491
  this.outputWaiters++;
9490
9492
  this.outputWaitersByOwner.set(owner, ownerCount + 1);
9491
- return new Promise((resolve34) => {
9493
+ return new Promise((resolve35) => {
9492
9494
  const startedAt = Date.now();
9493
9495
  let settled = false;
9494
9496
  let disposeAbort = /* @__PURE__ */ __name(() => {
@@ -9508,7 +9510,7 @@ var BackgroundJobRegistry = class {
9508
9510
  this.outputWaitersByOwner.delete(owner);
9509
9511
  else
9510
9512
  this.outputWaitersByOwner.set(owner, remaining);
9511
- resolve34(result);
9513
+ resolve35(result);
9512
9514
  }, "finish");
9513
9515
  const timeout = /* @__PURE__ */ __name((cause) => {
9514
9516
  read();
@@ -10287,7 +10289,7 @@ ${line}`;
10287
10289
  stdout: true,
10288
10290
  stderr: true
10289
10291
  });
10290
- return await new Promise((resolve34) => {
10292
+ return await new Promise((resolve35) => {
10291
10293
  let settled = false;
10292
10294
  let terminal;
10293
10295
  const inFlight = /* @__PURE__ */ new Set();
@@ -10302,7 +10304,7 @@ ${line}`;
10302
10304
  clearTimeout(deadline);
10303
10305
  options.signal?.removeEventListener("abort", onAbort);
10304
10306
  void worker.terminate();
10305
- resolve34({ ...result, calls: [...calls] });
10307
+ resolve35({ ...result, calls: [...calls] });
10306
10308
  }, "finish");
10307
10309
  const finishTerminalWhenHostCallsSettle = /* @__PURE__ */ __name(() => {
10308
10310
  if (terminal && inFlight.size === 0)
@@ -12189,8 +12191,8 @@ ${body}`,
12189
12191
  let timer;
12190
12192
  await Promise.race([
12191
12193
  Promise.allSettled([...inFlight]),
12192
- new Promise((resolve34) => {
12193
- timer = setTimeout(resolve34, grace);
12194
+ new Promise((resolve35) => {
12195
+ timer = setTimeout(resolve35, grace);
12194
12196
  })
12195
12197
  ]);
12196
12198
  clearTimeout(timer);
@@ -14587,14 +14589,14 @@ var MCPReconnectSupervisor = class {
14587
14589
  });
14588
14590
  }
14589
14591
  wait(ms) {
14590
- return new Promise((resolve34) => {
14592
+ return new Promise((resolve35) => {
14591
14593
  const finish2 = /* @__PURE__ */ __name(() => {
14592
14594
  if (this.timer)
14593
14595
  clearTimeout(this.timer);
14594
14596
  this.timer = void 0;
14595
14597
  if (this.finishWait === finish2)
14596
14598
  this.finishWait = void 0;
14597
- resolve34();
14599
+ resolve35();
14598
14600
  }, "finish");
14599
14601
  this.finishWait = finish2;
14600
14602
  this.timer = setTimeout(finish2, ms);
@@ -15619,7 +15621,7 @@ async function renameWithRetry(from, to) {
15619
15621
  const code = err.code ?? "";
15620
15622
  if (!CONTENDED.has(code) || attempt >= RENAME_ATTEMPTS)
15621
15623
  throw err;
15622
- await new Promise((resolve34) => setTimeout(resolve34, attempt));
15624
+ await new Promise((resolve35) => setTimeout(resolve35, attempt));
15623
15625
  }
15624
15626
  }
15625
15627
  }
@@ -17903,11 +17905,11 @@ async function teardownSandbox(sandbox, timeoutMs) {
17903
17905
  return await operation;
17904
17906
  let timer;
17905
17907
  let timedOut;
17906
- const deadline = new Promise((resolve34) => {
17908
+ const deadline = new Promise((resolve35) => {
17907
17909
  timer = setTimeout(() => {
17908
17910
  timedOut = teardownTimeoutError(timeoutMs);
17909
17911
  controller.abort(timedOut);
17910
- resolve34({ kind: "timed_out", error: timedOut });
17912
+ resolve35({ kind: "timed_out", error: timedOut });
17911
17913
  }, timeoutMs);
17912
17914
  });
17913
17915
  try {
@@ -17935,20 +17937,20 @@ async function acquireSandbox(options) {
17935
17937
  let timeoutError3;
17936
17938
  let timer;
17937
17939
  let onAbort;
17938
- const aborted = new Promise((resolve34) => {
17940
+ const aborted = new Promise((resolve35) => {
17939
17941
  onAbort = /* @__PURE__ */ __name(() => {
17940
17942
  operationController.abort(runSignal.reason);
17941
- resolve34({ kind: "cancelled" });
17943
+ resolve35({ kind: "cancelled" });
17942
17944
  }, "onAbort");
17943
17945
  runSignal.addEventListener("abort", onAbort, { once: true });
17944
17946
  });
17945
- const timedOut = new Promise((resolve34) => {
17947
+ const timedOut = new Promise((resolve35) => {
17946
17948
  if (options.timeoutMs === Number.POSITIVE_INFINITY)
17947
17949
  return;
17948
17950
  timer = setTimeout(() => {
17949
17951
  timeoutError3 = acquisitionTimeoutError(options.timeoutMs);
17950
17952
  operationController.abort(timeoutError3);
17951
- resolve34({ kind: "timed_out", error: timeoutError3 });
17953
+ resolve35({ kind: "timed_out", error: timeoutError3 });
17952
17954
  }, options.timeoutMs);
17953
17955
  });
17954
17956
  if (runSignal.aborted) {
@@ -18358,6 +18360,157 @@ function memoizeAsync(fn) {
18358
18360
  }
18359
18361
  __name(memoizeAsync, "memoizeAsync");
18360
18362
 
18363
+ // ../sdk/dist/utils/temp.js
18364
+ import { createHash as createHash5 } from "node:crypto";
18365
+ import { lstatSync, mkdirSync as mkdirSync2, mkdtempSync } from "node:fs";
18366
+ import { mkdtemp } from "node:fs/promises";
18367
+ import { tmpdir, userInfo } from "node:os";
18368
+ import { isAbsolute as isAbsolute2, join as join8, relative, resolve as resolve2, sep } from "node:path";
18369
+ var NAMZU_TMPDIR_ENV = "NAMZU_TMPDIR";
18370
+ var TempDirectoryError = class extends Error {
18371
+ static {
18372
+ __name(this, "TempDirectoryError");
18373
+ }
18374
+ reason;
18375
+ directory;
18376
+ name = "TempDirectoryError";
18377
+ constructor(message, reason2, directory) {
18378
+ super(message);
18379
+ this.reason = reason2;
18380
+ this.directory = directory;
18381
+ }
18382
+ };
18383
+ function resolveTempBase(env = process.env) {
18384
+ const configured = env[NAMZU_TMPDIR_ENV]?.trim();
18385
+ if (!configured)
18386
+ return tmpdir();
18387
+ if (!isAbsolute2(configured)) {
18388
+ throw new TempDirectoryError(`${NAMZU_TMPDIR_ENV} must be a full path, but it is "${configured}". Set it to a folder on a disk with free space.`, "not_absolute", configured);
18389
+ }
18390
+ return configured;
18391
+ }
18392
+ __name(resolveTempBase, "resolveTempBase");
18393
+ function explain(error, directory) {
18394
+ const code = error?.code;
18395
+ const elsewhere = `Free some space and start again, or set ${NAMZU_TMPDIR_ENV} to a folder on another disk.`;
18396
+ switch (code) {
18397
+ case "ENOSPC":
18398
+ return new TempDirectoryError(`The disk is full, so Namzu could not create ${directory}. ${elsewhere}`, "volume_full", directory);
18399
+ case "EDQUOT":
18400
+ return new TempDirectoryError(`Your disk quota is used up, so Namzu could not create ${directory}. ${elsewhere}`, "quota_exceeded", directory);
18401
+ case "EACCES":
18402
+ case "EPERM":
18403
+ case "EROFS":
18404
+ return new TempDirectoryError(`Namzu could not create ${directory} because the folder cannot be written to. Set ${NAMZU_TMPDIR_ENV} to a folder you can write to.`, "not_writable", directory);
18405
+ case "ENOENT":
18406
+ return new TempDirectoryError(`Namzu could not create ${directory} because its parent folder does not exist. Create that folder, or set ${NAMZU_TMPDIR_ENV} to one that does.`, "missing", directory);
18407
+ default:
18408
+ return void 0;
18409
+ }
18410
+ }
18411
+ __name(explain, "explain");
18412
+ function refuse(root, why) {
18413
+ return new TempDirectoryError(`Refusing temporary root ${root}: ${why} Set ${NAMZU_TMPDIR_ENV} to a folder only you can write to.`, "refused", root);
18414
+ }
18415
+ __name(refuse, "refuse");
18416
+ function sha256Hex2(value) {
18417
+ return createHash5("sha256").update(value).digest("hex");
18418
+ }
18419
+ __name(sha256Hex2, "sha256Hex");
18420
+ function privateTempRootPath(options = {}) {
18421
+ const getuid = "getuid" in options ? options.getuid : process.getuid?.bind(process);
18422
+ let user = "user";
18423
+ if (typeof getuid === "function") {
18424
+ user = String(getuid());
18425
+ } else {
18426
+ try {
18427
+ const name2 = (options.username ?? (() => userInfo().username))();
18428
+ if (name2.length > 0)
18429
+ user = sha256Hex2(name2).slice(0, 12);
18430
+ } catch {
18431
+ }
18432
+ }
18433
+ return join8(options.tmpdir ?? resolveTempBase(options.env), `namzu-${user}`);
18434
+ }
18435
+ __name(privateTempRootPath, "privateTempRootPath");
18436
+ function privateTempRoot(options = {}) {
18437
+ const platform2 = options.platform ?? process.platform;
18438
+ const getuid = "getuid" in options ? options.getuid : process.getuid?.bind(process);
18439
+ const root = privateTempRootPath(options);
18440
+ try {
18441
+ mkdirSync2(root, { mode: 448 });
18442
+ } catch (error) {
18443
+ if (error.code !== "EEXIST")
18444
+ throw explain(error, root) ?? error;
18445
+ }
18446
+ const entry = lstatSync(root);
18447
+ if (entry.isSymbolicLink())
18448
+ throw refuse(root, "it is a symbolic link.");
18449
+ if (!entry.isDirectory())
18450
+ throw refuse(root, "it is not a directory.");
18451
+ if (platform2 !== "win32" && typeof getuid === "function") {
18452
+ if (entry.uid !== getuid())
18453
+ throw refuse(root, `it belongs to uid ${entry.uid}.`);
18454
+ if ((entry.mode & 63) !== 0) {
18455
+ throw refuse(root, `mode ${(entry.mode & 511).toString(8)} lets other users in; it must be 700.`);
18456
+ }
18457
+ }
18458
+ return root;
18459
+ }
18460
+ __name(privateTempRoot, "privateTempRoot");
18461
+ function createTempDirSync(prefix, options = {}) {
18462
+ const root = privateTempRoot(options);
18463
+ try {
18464
+ return mkdtempSync(join8(root, prefix));
18465
+ } catch (error) {
18466
+ throw explain(error, join8(root, prefix)) ?? error;
18467
+ }
18468
+ }
18469
+ __name(createTempDirSync, "createTempDirSync");
18470
+ async function createTempDir(prefix, options = {}) {
18471
+ const root = privateTempRoot(options);
18472
+ try {
18473
+ return await mkdtemp(join8(root, prefix));
18474
+ } catch (error) {
18475
+ throw explain(error, join8(root, prefix)) ?? error;
18476
+ }
18477
+ }
18478
+ __name(createTempDir, "createTempDir");
18479
+ function tempFilePath(name2, options = {}) {
18480
+ return join8(privateTempRoot(options), name2);
18481
+ }
18482
+ __name(tempFilePath, "tempFilePath");
18483
+ function ensureScratchpadDirectory(directory, options = {}) {
18484
+ const root = privateTempRoot(options);
18485
+ const target = resolve2(directory);
18486
+ const inside2 = relative(root, target);
18487
+ if (inside2 === "" || inside2.startsWith("..") || isAbsolute2(inside2)) {
18488
+ throw refuse(target, "it is not inside the private temporary folder.");
18489
+ }
18490
+ const getuid = "getuid" in options ? options.getuid : process.getuid?.bind(process);
18491
+ const platform2 = options.platform ?? process.platform;
18492
+ let current = root;
18493
+ for (const part2 of inside2.split(sep)) {
18494
+ current = join8(current, part2);
18495
+ try {
18496
+ mkdirSync2(current, { mode: 448 });
18497
+ } catch (error) {
18498
+ if (error.code !== "EEXIST")
18499
+ throw explain(error, current) ?? error;
18500
+ }
18501
+ const entry = lstatSync(current);
18502
+ if (entry.isSymbolicLink())
18503
+ throw refuse(current, "it is a symbolic link.");
18504
+ if (!entry.isDirectory())
18505
+ throw refuse(current, "it is not a directory.");
18506
+ if (platform2 !== "win32" && typeof getuid === "function" && entry.uid !== getuid()) {
18507
+ throw refuse(current, `it belongs to uid ${entry.uid}.`);
18508
+ }
18509
+ }
18510
+ return target;
18511
+ }
18512
+ __name(ensureScratchpadDirectory, "ensureScratchpadDirectory");
18513
+
18361
18514
  // ../sdk/dist/utils/conversation.js
18362
18515
  function extractFinalResponse(messages) {
18363
18516
  for (let i = messages.length - 1; i >= 0; i--) {
@@ -26132,6 +26285,8 @@ var SESSION_EVENT_TYPE_TABLE = {
26132
26285
  request_envelope: true,
26133
26286
  iteration_completed: true,
26134
26287
  compaction_started: true,
26288
+ session_log_degraded: true,
26289
+ session_log_recovered: true,
26135
26290
  compaction_shed: true,
26136
26291
  compaction_completed: true,
26137
26292
  compaction_tool_results_cleared: true,
@@ -26488,7 +26643,7 @@ function childSessionLog(childSessionId) {
26488
26643
  __name(childSessionLog, "childSessionLog");
26489
26644
 
26490
26645
  // ../sdk/dist/session/log-hash.js
26491
- import { createHash as createHash5 } from "node:crypto";
26646
+ import { createHash as createHash6 } from "node:crypto";
26492
26647
  var NEWLINE = 10;
26493
26648
  var encoder = new TextEncoder();
26494
26649
  var decoder = new TextDecoder("utf-8", { fatal: true });
@@ -26497,7 +26652,7 @@ function bytesOf(line) {
26497
26652
  }
26498
26653
  __name(bytesOf, "bytesOf");
26499
26654
  function recordSha256(line) {
26500
- return createHash5("sha256").update(bytesOf(line)).digest("hex");
26655
+ return createHash6("sha256").update(bytesOf(line)).digest("hex");
26501
26656
  }
26502
26657
  __name(recordSha256, "recordSha256");
26503
26658
  function formatSessionLogLine(record3) {
@@ -26953,39 +27108,39 @@ var SessionTurnState = class {
26953
27108
  /** Throws {@link TurnRuleError} if `record` may not follow the records applied so far. */
26954
27109
  check(record3) {
26955
27110
  const active = this.#active;
26956
- const refuse4 = /* @__PURE__ */ __name((message) => {
27111
+ const refuse5 = /* @__PURE__ */ __name((message) => {
26957
27112
  throw new TurnRuleError(message);
26958
27113
  }, "refuse");
26959
27114
  if (record3.type === "session_started") {
26960
27115
  if (this.#started)
26961
- refuse4("session_started is the first record of a log, and only the first");
27116
+ refuse5("session_started is the first record of a log, and only the first");
26962
27117
  return;
26963
27118
  }
26964
27119
  if (!this.#started)
26965
- refuse4("the first record of a log is session_started");
27120
+ refuse5("the first record of a log is session_started");
26966
27121
  if (record3.type === "turn_started") {
26967
27122
  if (active !== void 0) {
26968
- refuse4(`turn ${active.turnId} is still active; a session has one active turn at a time`);
27123
+ refuse5(`turn ${active.turnId} is still active; a session has one active turn at a time`);
26969
27124
  }
26970
27125
  return;
26971
27126
  }
26972
27127
  if (record3.turnId === void 0)
26973
27128
  return;
26974
27129
  if (active === void 0) {
26975
- refuse4(`the record names turn ${record3.turnId}, and no turn is active`);
27130
+ refuse5(`the record names turn ${record3.turnId}, and no turn is active`);
26976
27131
  }
26977
27132
  const current = active;
26978
27133
  if (record3.turnId !== current.turnId) {
26979
- refuse4(`the record names turn ${record3.turnId}; the active turn is ${current.turnId}`);
27134
+ refuse5(`the record names turn ${record3.turnId}; the active turn is ${current.turnId}`);
26980
27135
  }
26981
27136
  if (record3.type === "turn_resuming" && !current.paused) {
26982
27137
  return;
26983
27138
  }
26984
27139
  if (current.paused && record3.type !== "turn_resuming" && !CLOSES_OR_DECIDES.has(record3.type)) {
26985
- refuse4(`turn ${current.turnId} is paused; only turn_resuming, a decision record or a terminal record may follow`);
27140
+ refuse5(`turn ${current.turnId} is paused; only turn_resuming, a decision record or a terminal record may follow`);
26986
27141
  }
26987
27142
  if (record3.type === "turn_paused" && current.paused) {
26988
- refuse4(`turn ${current.turnId} is already paused`);
27143
+ refuse5(`turn ${current.turnId} is already paused`);
26989
27144
  }
26990
27145
  }
26991
27146
  apply(record3, options = {}) {
@@ -27091,8 +27246,8 @@ async function releaseHeldSessionLeases(options = {}) {
27091
27246
  }, () => {
27092
27247
  })));
27093
27248
  let timer;
27094
- const deadline = new Promise((resolve34) => {
27095
- timer = setTimeout(resolve34, options.timeoutMs ?? 2e3);
27249
+ const deadline = new Promise((resolve35) => {
27250
+ timer = setTimeout(resolve35, options.timeoutMs ?? 2e3);
27096
27251
  });
27097
27252
  await Promise.race([all, deadline]);
27098
27253
  clearTimeout(timer);
@@ -27102,17 +27257,17 @@ __name(releaseHeldSessionLeases, "releaseHeldSessionLeases");
27102
27257
 
27103
27258
  // ../sdk/dist/store/session-log/lease.js
27104
27259
  import { link as link3, mkdir as mkdir5, readFile as readFile5, readdir as readdir2, stat as stat2, unlink as unlink4, writeFile as writeFile4 } from "node:fs/promises";
27105
- import { join as join10 } from "node:path";
27260
+ import { join as join11 } from "node:path";
27106
27261
 
27107
27262
  // ../sdk/dist/store/session-log/spill.js
27108
- import { createHash as createHash6, randomBytes as randomBytes5 } from "node:crypto";
27263
+ import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
27109
27264
  import { link as link2, mkdir as mkdir4, open as open4, readFile as readFile4, rename as rename2, unlink as unlink3 } from "node:fs/promises";
27110
- import { dirname as dirname5, isAbsolute as isAbsolute2, join as join9, normalize, sep as sep2 } from "node:path";
27265
+ import { dirname as dirname5, isAbsolute as isAbsolute3, join as join10, normalize, sep as sep3 } from "node:path";
27111
27266
 
27112
27267
  // ../sdk/dist/store/evidence/io.js
27113
27268
  import { constants as constants2 } from "node:fs";
27114
27269
  import { lstat, open as open3 } from "node:fs/promises";
27115
- import { join as join8, parse, resolve as resolve2, sep } from "node:path";
27270
+ import { join as join9, parse, resolve as resolve3, sep as sep2 } from "node:path";
27116
27271
  var PAGE_BYTES = 8 * 1024 * 1024;
27117
27272
  var RECORD_BYTES = 4 * 1024 * 1024;
27118
27273
  var EvidencePageLimit = class extends Error {
@@ -27125,10 +27280,10 @@ function stamp2(stat17) {
27125
27280
  }
27126
27281
  __name(stamp2, "stamp");
27127
27282
  async function noLinks(path3) {
27128
- const absolute = resolve2(path3);
27283
+ const absolute = resolve3(path3);
27129
27284
  let current = parse(absolute).root;
27130
- for (const part2 of absolute.slice(current.length).split(sep).filter(Boolean)) {
27131
- current = join8(current, part2);
27285
+ for (const part2 of absolute.slice(current.length).split(sep2).filter(Boolean)) {
27286
+ current = join9(current, part2);
27132
27287
  if ((await lstat(current)).isSymbolicLink())
27133
27288
  throw new Error("Evidence symlinks are refused.");
27134
27289
  }
@@ -27201,14 +27356,14 @@ var SpillIntegrityError = class extends Error {
27201
27356
  this.path = path3;
27202
27357
  }
27203
27358
  };
27204
- function sha256Hex2(value) {
27205
- return createHash6("sha256").update(value).digest("hex");
27359
+ function sha256Hex3(value) {
27360
+ return createHash7("sha256").update(value).digest("hex");
27206
27361
  }
27207
- __name(sha256Hex2, "sha256Hex");
27362
+ __name(sha256Hex3, "sha256Hex");
27208
27363
  function spillFileName(key6) {
27209
27364
  if (key6.length === 0)
27210
27365
  throw new Error("A spill key is required.");
27211
- return `${sha256Hex2(key6)}.txt`;
27366
+ return `${sha256Hex3(key6)}.txt`;
27212
27367
  }
27213
27368
  __name(spillFileName, "spillFileName");
27214
27369
  var counter2 = 0;
@@ -27239,7 +27394,7 @@ async function renameWithRetry2(from, to) {
27239
27394
  const code = err.code ?? "";
27240
27395
  if (!CONTENDED2.has(code) || attempt >= RENAME_ATTEMPTS2)
27241
27396
  throw err;
27242
- await new Promise((resolve34) => setTimeout(resolve34, attempt));
27397
+ await new Promise((resolve35) => setTimeout(resolve35, attempt));
27243
27398
  }
27244
27399
  }
27245
27400
  }
@@ -27314,7 +27469,7 @@ function checkActualReadSize(ref, bytes, maxBytes) {
27314
27469
  __name(checkActualReadSize, "checkActualReadSize");
27315
27470
  function checkRelative(path3) {
27316
27471
  const normal = normalize(path3);
27317
- if (isAbsolute2(normal) || normal.startsWith("..") || !normal.startsWith(`${SPILL_DIR}${sep2}`)) {
27472
+ if (isAbsolute3(normal) || normal.startsWith("..") || !normal.startsWith(`${SPILL_DIR}${sep3}`)) {
27318
27473
  throw new SpillIntegrityError(path3, `A spill path must stay inside ${SPILL_DIR}/: ${path3}`);
27319
27474
  }
27320
27475
  return normal;
@@ -27325,7 +27480,7 @@ function verify(ref, text10) {
27325
27480
  if (bytes !== ref.bytes) {
27326
27481
  throw new SpillIntegrityError(ref.path, `Spill ${ref.path} is ${bytes} bytes; its record says ${ref.bytes}. Refusing rather than reading content the log cannot vouch for.`);
27327
27482
  }
27328
- if (sha256Hex2(text10) !== ref.sha256) {
27483
+ if (sha256Hex3(text10) !== ref.sha256) {
27329
27484
  throw new SpillIntegrityError(ref.path, `Spill ${ref.path} does not match the SHA-256 its record carries. Refusing rather than reading content the log cannot vouch for.`);
27330
27485
  }
27331
27486
  return text10;
@@ -27342,19 +27497,19 @@ var DiskSpillStore = class {
27342
27497
  this.now = now;
27343
27498
  }
27344
27499
  async write(key6, content, text10) {
27345
- const dir = join9(this.sessionDir, SPILL_DIR);
27500
+ const dir = join10(this.sessionDir, SPILL_DIR);
27346
27501
  await mkdir4(dir, { recursive: true });
27347
27502
  const name2 = spillFileName(key6);
27348
27503
  const ref = {
27349
27504
  path: `${SPILL_DIR}/${name2}`,
27350
27505
  manifest: `${SPILL_DIR}/${name2}.manifest.json`,
27351
27506
  bytes: Buffer.byteLength(text10, "utf8"),
27352
- sha256: sha256Hex2(text10)
27507
+ sha256: sha256Hex3(text10)
27353
27508
  };
27354
- const body = join9(dir, name2);
27509
+ const body = join10(dir, name2);
27355
27510
  if (!await durableCreateFile(body, text10)) {
27356
27511
  const existing = await readFile4(body, "utf8");
27357
- if (sha256Hex2(existing) !== ref.sha256) {
27512
+ if (sha256Hex3(existing) !== ref.sha256) {
27358
27513
  throw new SpillIntegrityError(ref.path, `Spill ${ref.path} already exists with different content. Refusing to replace it: an earlier record's hash vouches for the bytes that are there.`);
27359
27514
  }
27360
27515
  }
@@ -27367,14 +27522,14 @@ var DiskSpillStore = class {
27367
27522
  sha256: ref.sha256,
27368
27523
  createdAt: new Date(this.now()).toISOString()
27369
27524
  };
27370
- await durableCreateFile(join9(dir, `${name2}.manifest.json`), `${JSON.stringify(manifest)}
27525
+ await durableCreateFile(join10(dir, `${name2}.manifest.json`), `${JSON.stringify(manifest)}
27371
27526
  `);
27372
27527
  await syncDirectory2(dir);
27373
27528
  return ref;
27374
27529
  }
27375
27530
  async read(ref, options) {
27376
27531
  const maxBytes = checkedReadLimit(ref, options);
27377
- const path3 = join9(this.sessionDir, checkRelative(ref.path));
27532
+ const path3 = join10(this.sessionDir, checkRelative(ref.path));
27378
27533
  let text10;
27379
27534
  try {
27380
27535
  options?.signal?.throwIfAborted();
@@ -27424,10 +27579,10 @@ var InMemorySpillStore = class {
27424
27579
  path: `${SPILL_DIR}/${name2}`,
27425
27580
  manifest: `${SPILL_DIR}/${name2}.manifest.json`,
27426
27581
  bytes: Buffer.byteLength(text10, "utf8"),
27427
- sha256: sha256Hex2(text10)
27582
+ sha256: sha256Hex3(text10)
27428
27583
  };
27429
27584
  const existing = this.#files.get(ref.path);
27430
- if (existing !== void 0 && sha256Hex2(existing) !== ref.sha256) {
27585
+ if (existing !== void 0 && sha256Hex3(existing) !== ref.sha256) {
27431
27586
  throw new SpillIntegrityError(ref.path, `Spill ${ref.path} already exists with different content. Refusing to replace it: an earlier record's hash vouches for the bytes that are there.`);
27432
27587
  }
27433
27588
  this.#files.set(ref.path, text10);
@@ -27435,7 +27590,7 @@ var InMemorySpillStore = class {
27435
27590
  }
27436
27591
  async read(ref, options) {
27437
27592
  const maxBytes = checkedReadLimit(ref, options);
27438
- const text10 = this.#files.get(checkRelative(ref.path).split(sep2).join("/"));
27593
+ const text10 = this.#files.get(checkRelative(ref.path).split(sep3).join("/"));
27439
27594
  if (text10 === void 0) {
27440
27595
  throw new SpillIntegrityError(ref.path, `Spill ${ref.path} does not exist.`);
27441
27596
  }
@@ -27524,7 +27679,7 @@ var DiskSessionLeaseStore = class {
27524
27679
  if (top === void 0)
27525
27680
  return null;
27526
27681
  try {
27527
- const body = JSON.parse(await readFile5(join10(this.sessionDir, top.name), "utf8"));
27682
+ const body = JSON.parse(await readFile5(join11(this.sessionDir, top.name), "utf8"));
27528
27683
  if (typeof body.holder === "string" && Number.isFinite(body.expiresAt)) {
27529
27684
  return { holder: body.holder, fence: top.fence, expiresAt: body.expiresAt };
27530
27685
  }
@@ -27534,10 +27689,10 @@ var DiskSessionLeaseStore = class {
27534
27689
  }
27535
27690
  /** Write `body` and make it visible at `fence`, whole or not at all. Throws `EEXIST` on a lost race. */
27536
27691
  async #publish(fence, body) {
27537
- const temporary = join10(this.sessionDir, tempName(fence));
27692
+ const temporary = join11(this.sessionDir, tempName(fence));
27538
27693
  await writeFile4(temporary, JSON.stringify(body), { flag: "wx" });
27539
27694
  try {
27540
- await link3(temporary, join10(this.sessionDir, `lease.${fence}.json`));
27695
+ await link3(temporary, join11(this.sessionDir, `lease.${fence}.json`));
27541
27696
  } finally {
27542
27697
  await unlink4(temporary).catch(() => void 0);
27543
27698
  }
@@ -27550,7 +27705,7 @@ var DiskSessionLeaseStore = class {
27550
27705
  fence: lease.fence,
27551
27706
  expiresAt: new Date(lease.expiresAt).toISOString()
27552
27707
  };
27553
- await durableReplaceFile(join10(this.sessionDir, "lease.json"), `${JSON.stringify(view)}
27708
+ await durableReplaceFile(join11(this.sessionDir, "lease.json"), `${JSON.stringify(view)}
27554
27709
  `);
27555
27710
  }
27556
27711
  async claim(options, context2 = {}) {
@@ -27563,7 +27718,7 @@ var DiskSessionLeaseStore = class {
27563
27718
  return null;
27564
27719
  const body = { holder: options.holder, expiresAt: now + options.ttlMs };
27565
27720
  if (decision2.kind === "renew") {
27566
- await durableReplaceFile(join10(this.sessionDir, `lease.${decision2.fence}.json`), JSON.stringify(body));
27721
+ await durableReplaceFile(join11(this.sessionDir, `lease.${decision2.fence}.json`), JSON.stringify(body));
27567
27722
  if (await this.fence() !== decision2.fence)
27568
27723
  return null;
27569
27724
  const renewed = { holder: options.holder, fence: decision2.fence, expiresAt: body.expiresAt };
@@ -27611,13 +27766,13 @@ var DiskSessionLeaseStore = class {
27611
27766
  const match2 = FENCE_NAME.exec(name2);
27612
27767
  if (match2) {
27613
27768
  if (Number(match2[1]) < max - KEEP_BELOW_MAX) {
27614
- await unlink4(join10(this.sessionDir, name2)).catch(() => void 0);
27769
+ await unlink4(join11(this.sessionDir, name2)).catch(() => void 0);
27615
27770
  }
27616
27771
  continue;
27617
27772
  }
27618
27773
  if (!TEMP_NAME.test(name2))
27619
27774
  continue;
27620
- const path3 = join10(this.sessionDir, name2);
27775
+ const path3 = join11(this.sessionDir, name2);
27621
27776
  try {
27622
27777
  if (wallClock - (await stat2(path3)).mtimeMs < TEMP_TTL_MS)
27623
27778
  continue;
@@ -27718,6 +27873,20 @@ async function restoreSpilledRequestInputs(request, read) {
27718
27873
  __name(restoreSpilledRequestInputs, "restoreSpilledRequestInputs");
27719
27874
 
27720
27875
  // ../sdk/dist/store/session-log/core.js
27876
+ function sessionLogDegradedCause(error) {
27877
+ switch (error?.code) {
27878
+ case "ENOSPC":
27879
+ return "disk_full";
27880
+ case "EDQUOT":
27881
+ return "quota_exceeded";
27882
+ case "EROFS":
27883
+ return "read_only";
27884
+ default:
27885
+ return void 0;
27886
+ }
27887
+ }
27888
+ __name(sessionLogDegradedCause, "sessionLogDegradedCause");
27889
+ var DEFAULT_DEGRADED_BUFFER_BYTES = 8 * 1024 * 1024;
27721
27890
  var InvalidSessionRecordError = class extends Error {
27722
27891
  static {
27723
27892
  __name(this, "InvalidSessionRecordError");
@@ -27744,6 +27913,7 @@ var BOUNDARY_TYPES = /* @__PURE__ */ new Set([
27744
27913
  "log_repaired"
27745
27914
  ]);
27746
27915
  var PREVIEW_CHARS = 2e3;
27916
+ var NOT_SAVED_NOTE = "[\u2026 the rest of this output could not be saved: the disk is full]";
27747
27917
  var COMPACTION_SPILL_ABOVE_BYTES = 256 * 1024;
27748
27918
  var ZERO_USAGE = {
27749
27919
  promptTokens: 0,
@@ -27787,6 +27957,17 @@ var SessionLogCore = class {
27787
27957
  /** Bytes of the log this instance has verified and applied. */
27788
27958
  #synced = 0;
27789
27959
  #torn = 0;
27960
+ #degradedBufferBytes;
27961
+ /** Records accepted into the chain that the medium has not taken yet, oldest first. */
27962
+ #pending = [];
27963
+ #pendingBytes = 0;
27964
+ /** Bytes the medium holds while records are pending. */
27965
+ #diskBytes = 0;
27966
+ #degradedCause;
27967
+ #droppedRecords = 0;
27968
+ #droppedNoticeSent = false;
27969
+ #flushedWhileDegraded = 0;
27970
+ #healthListeners = /* @__PURE__ */ new Set();
27790
27971
  constructor(options) {
27791
27972
  this.sessionId = options.sessionId;
27792
27973
  this.#medium = options.medium;
@@ -27800,10 +27981,31 @@ var SessionLogCore = class {
27800
27981
  this.#spillAbove = Math.min(options.spillAboveBytes ?? SESSION_RECORD_MAX_BYTES, SESSION_RECORD_MAX_BYTES);
27801
27982
  this.#compactionSpillAbove = Math.min(options.compactionSpillAboveBytes ?? COMPACTION_SPILL_ABOVE_BYTES, this.#spillAbove);
27802
27983
  this.#sync = options.sync ?? "boundaries";
27984
+ this.#degradedBufferBytes = Math.max(0, options.degradedBufferBytes ?? DEFAULT_DEGRADED_BUFFER_BYTES);
27985
+ }
27986
+ onWriteHealth(listener) {
27987
+ this.#healthListeners.add(listener);
27988
+ return () => {
27989
+ this.#healthListeners.delete(listener);
27990
+ };
27991
+ }
27992
+ #notify(change) {
27993
+ for (const listener of this.#healthListeners) {
27994
+ try {
27995
+ listener(change);
27996
+ } catch {
27997
+ }
27998
+ }
27999
+ }
28000
+ /** True while records wait in memory because the volume refuses writes. */
28001
+ get degraded() {
28002
+ return this.#degradedCause !== void 0;
27803
28003
  }
27804
28004
  // ── state ──
27805
28005
  /** Catch up with the medium: verify and apply whatever was appended since the last sync. */
27806
28006
  async #catchUp() {
28007
+ if (this.#pending.length > 0)
28008
+ return;
27807
28009
  const size = await this.#medium.size();
27808
28010
  if (size === this.#synced + this.#torn && size >= this.#synced)
27809
28011
  return;
@@ -27827,6 +28029,8 @@ var SessionLogCore = class {
27827
28029
  this.#turns = new SessionTurnState();
27828
28030
  this.#synced = 0;
27829
28031
  this.#torn = 0;
28032
+ this.#pending = [];
28033
+ this.#pendingBytes = 0;
27830
28034
  }
27831
28035
  async #requireCurrent(lease) {
27832
28036
  const fence = await this.#leases.fence();
@@ -27885,6 +28089,8 @@ var SessionLogCore = class {
27885
28089
  */
27886
28090
  release(lease) {
27887
28091
  return this.#mutex.run(async () => {
28092
+ if (this.#pending.length > 0)
28093
+ await this.#flushPending().catch(() => void 0);
27888
28094
  if (this.#held?.fence === lease.fence) {
27889
28095
  this.#held = void 0;
27890
28096
  untrackHeldSessionLease(this.#holding);
@@ -28027,12 +28233,117 @@ var SessionLogCore = class {
28027
28233
  }
28028
28234
  const bytes = Buffer.from(line, "utf8");
28029
28235
  const sync = this.#sync === "all" || this.#sync === "boundaries" && BOUNDARY_TYPES.has(type);
28030
- await this.#medium.append(bytes, this.#synced, sync);
28236
+ await this.#persist(bytes, sync);
28031
28237
  const entry = this.#chain.accept(bytes, this.#synced);
28032
28238
  this.#turns.apply(entry.record);
28033
28239
  this.#synced += bytes.byteLength;
28034
28240
  return entry;
28035
28241
  }
28242
+ /**
28243
+ * Hand a record's bytes to the medium. A volume that refuses writes (full,
28244
+ * over quota, read-only) does not fail the record: it waits in a bounded
28245
+ * buffer and goes out, in order, with the next record that can be written.
28246
+ * Any other error is thrown as before. Caller holds the mutex.
28247
+ */
28248
+ async #persist(bytes, sync) {
28249
+ if (this.#pending.length === 0) {
28250
+ try {
28251
+ await this.#medium.append(bytes, this.#synced, sync);
28252
+ return;
28253
+ } catch (error) {
28254
+ const cause = sessionLogDegradedCause(error);
28255
+ if (cause === void 0)
28256
+ throw error;
28257
+ this.#diskBytes = this.#synced;
28258
+ this.#degradedCause = cause;
28259
+ this.#bufferRecord(bytes, sync);
28260
+ this.#notify({
28261
+ state: "degraded",
28262
+ cause,
28263
+ bufferedRecords: this.#pending.length,
28264
+ bufferedBytes: this.#pendingBytes
28265
+ });
28266
+ return;
28267
+ }
28268
+ }
28269
+ const queued = this.#bufferRecord(bytes, sync);
28270
+ try {
28271
+ await this.#flushPending();
28272
+ } catch (error) {
28273
+ if (sessionLogDegradedCause(error) === void 0) {
28274
+ const at = this.#pending.indexOf(queued);
28275
+ if (at !== -1) {
28276
+ this.#pending.splice(at, 1);
28277
+ this.#pendingBytes -= queued.bytes.byteLength;
28278
+ }
28279
+ throw error;
28280
+ }
28281
+ }
28282
+ }
28283
+ #bufferRecord(bytes, sync) {
28284
+ const queued = { bytes, sync };
28285
+ this.#pending.push(queued);
28286
+ this.#pendingBytes += bytes.byteLength;
28287
+ let dropped = false;
28288
+ while (this.#pendingBytes > this.#degradedBufferBytes && this.#pending.length > 1) {
28289
+ const oldest = this.#pending.shift();
28290
+ if (oldest === void 0)
28291
+ break;
28292
+ this.#pendingBytes -= oldest.bytes.byteLength;
28293
+ this.#droppedRecords += 1;
28294
+ dropped = true;
28295
+ }
28296
+ if (dropped && !this.#droppedNoticeSent && this.#degradedCause !== void 0) {
28297
+ this.#droppedNoticeSent = true;
28298
+ this.#notify({
28299
+ state: "degraded",
28300
+ cause: this.#degradedCause,
28301
+ bufferedRecords: this.#pending.length,
28302
+ bufferedBytes: this.#pendingBytes,
28303
+ dropping: true
28304
+ });
28305
+ }
28306
+ return queued;
28307
+ }
28308
+ /** Write the buffer in order. Throws the error that stopped it; clears the degraded mark when it empties. */
28309
+ async #flushPending() {
28310
+ const size = await this.#medium.size();
28311
+ if (size > this.#diskBytes)
28312
+ await this.#medium.truncate(this.#diskBytes, size);
28313
+ while (this.#pending.length > 0) {
28314
+ const next2 = this.#pending[0];
28315
+ if (next2 === void 0)
28316
+ break;
28317
+ await this.#medium.append(next2.bytes, this.#diskBytes, next2.sync);
28318
+ this.#diskBytes += next2.bytes.byteLength;
28319
+ this.#pendingBytes -= next2.bytes.byteLength;
28320
+ this.#pending.shift();
28321
+ this.#flushedWhileDegraded += 1;
28322
+ }
28323
+ const flushed = this.#flushedWhileDegraded;
28324
+ this.#flushedWhileDegraded = 0;
28325
+ const dropped = this.#droppedRecords;
28326
+ this.#degradedCause = void 0;
28327
+ this.#droppedRecords = 0;
28328
+ this.#droppedNoticeSent = false;
28329
+ this.#pendingBytes = 0;
28330
+ this.#notify({ state: "recovered", flushedRecords: flushed, droppedRecords: dropped });
28331
+ }
28332
+ /**
28333
+ * Write a message body beside the log. When the volume refuses it the body
28334
+ * is given up (`undefined`) rather than the record,; the record's own write
28335
+ * then meets the same refusal and degrades the log.
28336
+ */
28337
+ async #spillOrLose(key6, content, text10) {
28338
+ try {
28339
+ return await this.#spills.write(key6, content, text10);
28340
+ } catch (error) {
28341
+ const cause = sessionLogDegradedCause(error);
28342
+ if (cause === void 0)
28343
+ throw error;
28344
+ return void 0;
28345
+ }
28346
+ }
28036
28347
  async #spillIfLarge(original) {
28037
28348
  const candidate = this.#structuredResultSpilling ? await this.#spillStructuredResults(original) : original;
28038
28349
  const type = candidate.type;
@@ -28049,7 +28360,14 @@ var SessionLogCore = class {
28049
28360
  if (type === "turn_completed") {
28050
28361
  if (typeof candidate.result !== "string")
28051
28362
  return candidate;
28052
- const ref2 = await this.#spills.write(`record:${String(candidate.id)}`, "message", candidate.result);
28363
+ const ref2 = await this.#spillOrLose(`record:${String(candidate.id)}`, "message", candidate.result);
28364
+ if (ref2 === void 0) {
28365
+ return {
28366
+ ...candidate,
28367
+ result: `${candidate.result.slice(0, PREVIEW_CHARS)}
28368
+ ${NOT_SAVED_NOTE}`
28369
+ };
28370
+ }
28053
28371
  const preview3 = `${candidate.result.slice(0, PREVIEW_CHARS)}
28054
28372
  [\u2026 ${ref2.bytes} bytes spilled to ${ref2.path}]`;
28055
28373
  return { ...candidate, result: preview3, resultSpill: ref2 };
@@ -28062,8 +28380,19 @@ var SessionLogCore = class {
28062
28380
  }
28063
28381
  const content = candidate.content;
28064
28382
  const key6 = content.role === "tool" && typeof content.toolCallId === "string" ? content.toolCallId : type === "message_replaced" ? `record:${String(candidate.id)}` : `message:${String(candidate.messageId)}`;
28065
- const ref = await this.#spills.write(key6, "message", JSON.stringify(content));
28383
+ const ref = await this.#spillOrLose(key6, "message", JSON.stringify(content));
28066
28384
  const text10 = typeof content.content === "string" ? content.content : JSON.stringify(content.content);
28385
+ if (ref === void 0) {
28386
+ return {
28387
+ ...candidate,
28388
+ content: {
28389
+ role: content.role,
28390
+ content: `${text10.slice(0, PREVIEW_CHARS)}
28391
+ ${NOT_SAVED_NOTE}`,
28392
+ ...typeof content.toolCallId === "string" ? { toolCallId: content.toolCallId } : {}
28393
+ }
28394
+ };
28395
+ }
28067
28396
  const preview2 = {
28068
28397
  role: content.role,
28069
28398
  content: `${text10.slice(0, PREVIEW_CHARS)}
@@ -28276,11 +28605,9 @@ import { mkdir as mkdir7, open as open6, stat as stat3 } from "node:fs/promises"
28276
28605
  import { dirname as dirname7 } from "node:path";
28277
28606
 
28278
28607
  // ../sdk/dist/session/paths.js
28279
- import { createHash as createHash7 } from "node:crypto";
28280
- import { lstatSync, mkdirSync as mkdirSync2 } from "node:fs";
28608
+ import { createHash as createHash8 } from "node:crypto";
28281
28609
  import { link as link4, mkdir as mkdir6, open as open5, readFile as readFile6, realpath, unlink as unlink5 } from "node:fs/promises";
28282
- import { tmpdir, userInfo } from "node:os";
28283
- import { basename as basename4, dirname as dirname6, join as join11 } from "node:path";
28610
+ import { basename as basename4, dirname as dirname6, join as join12 } from "node:path";
28284
28611
  function sessionLocatorFromLogFile(file, sessionId5) {
28285
28612
  if (basename4(file) !== `${sessionId5}.jsonl`)
28286
28613
  return void 0;
@@ -28305,10 +28632,10 @@ var SessionPathError = class extends Error {
28305
28632
  var SLUG = /^[A-Za-z0-9-]+$/;
28306
28633
  var NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
28307
28634
  var MAX_SLUG = 200;
28308
- function sha256Hex3(value) {
28309
- return createHash7("sha256").update(value).digest("hex");
28635
+ function sha256Hex4(value) {
28636
+ return createHash8("sha256").update(value).digest("hex");
28310
28637
  }
28311
- __name(sha256Hex3, "sha256Hex");
28638
+ __name(sha256Hex4, "sha256Hex");
28312
28639
  function checkId(value, kind) {
28313
28640
  if (!isEntityId(value, kind)) {
28314
28641
  throw new SessionPathError(`Invalid ${kind} id for a path: ${JSON.stringify(value)}`);
@@ -28327,11 +28654,11 @@ function slugForCwd(cwd) {
28327
28654
  const slug = cwd.replace(/[^A-Za-z0-9]/g, "-");
28328
28655
  if (slug.length <= MAX_SLUG)
28329
28656
  return slug;
28330
- return `${slug.slice(0, MAX_SLUG - 9)}-${sha256Hex3(cwd).slice(0, 8)}`;
28657
+ return `${slug.slice(0, MAX_SLUG - 9)}-${sha256Hex4(cwd).slice(0, 8)}`;
28331
28658
  }
28332
28659
  __name(slugForCwd, "slugForCwd");
28333
28660
  function hashedSlugForCwd(cwd) {
28334
- return `${slugForCwd(cwd)}-${sha256Hex3(cwd).slice(0, 8)}`;
28661
+ return `${slugForCwd(cwd)}-${sha256Hex4(cwd).slice(0, 8)}`;
28335
28662
  }
28336
28663
  __name(hashedSlugForCwd, "hashedSlugForCwd");
28337
28664
  var ProjectDocumentError = class extends Error {
@@ -28367,9 +28694,9 @@ async function ensureProject(options) {
28367
28694
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
28368
28695
  const candidates = [slugForCwd(cwd), hashedSlugForCwd(cwd)];
28369
28696
  for (const slug of candidates) {
28370
- const projectDir = join11(options.home, "projects", slug);
28697
+ const projectDir = join12(options.home, "projects", slug);
28371
28698
  await mkdir6(projectDir, { recursive: true });
28372
- const file = join11(projectDir, "project.json");
28699
+ const file = join12(projectDir, "project.json");
28373
28700
  let existing = await readProjectDocument(file);
28374
28701
  if (existing === null) {
28375
28702
  const document = {
@@ -28380,7 +28707,7 @@ async function ensureProject(options) {
28380
28707
  slug,
28381
28708
  createdAt: now().toISOString()
28382
28709
  };
28383
- const temporary = join11(projectDir, `.project.json.${process.pid}.${uuidv7()}.tmp`);
28710
+ const temporary = join12(projectDir, `.project.json.${process.pid}.${uuidv7()}.tmp`);
28384
28711
  const handle = await open5(temporary, "wx", 384);
28385
28712
  try {
28386
28713
  await handle.writeFile(`${JSON.stringify(document)}
@@ -28414,42 +28741,14 @@ async function ensureProject(options) {
28414
28741
  }
28415
28742
  __name(ensureProject, "ensureProject");
28416
28743
  function tempRoot(options = {}) {
28417
- const platform2 = options.platform ?? process.platform;
28418
- const getuid = "getuid" in options ? options.getuid : process.getuid?.bind(process);
28419
- let user = "user";
28420
- if (typeof getuid === "function") {
28421
- user = String(getuid());
28422
- } else {
28423
- try {
28424
- const name2 = (options.username ?? (() => userInfo().username))();
28425
- if (name2.length > 0)
28426
- user = sha256Hex3(name2).slice(0, 12);
28427
- } catch {
28428
- }
28429
- }
28430
- const root = join11(options.tmpdir ?? tmpdir(), `namzu-${user}`);
28431
28744
  try {
28432
- mkdirSync2(root, { mode: 448 });
28745
+ return privateTempRoot(options);
28433
28746
  } catch (error) {
28434
- if (error.code !== "EEXIST")
28435
- throw error;
28436
- }
28437
- const entry = lstatSync(root);
28438
- if (entry.isSymbolicLink()) {
28439
- throw new SessionPathError(`Refusing temporary root ${root}: it is a symbolic link.`);
28440
- }
28441
- if (!entry.isDirectory()) {
28442
- throw new SessionPathError(`Refusing temporary root ${root}: it is not a directory.`);
28443
- }
28444
- if (platform2 !== "win32" && typeof getuid === "function") {
28445
- if (entry.uid !== getuid()) {
28446
- throw new SessionPathError(`Refusing temporary root ${root}: it belongs to uid ${entry.uid}.`);
28447
- }
28448
- if ((entry.mode & 63) !== 0) {
28449
- throw new SessionPathError(`Refusing temporary root ${root}: mode ${(entry.mode & 511).toString(8)} lets other users in; it must be 700.`);
28747
+ if (error instanceof TempDirectoryError && error.reason === "refused") {
28748
+ throw new SessionPathError(error.message);
28450
28749
  }
28750
+ throw error;
28451
28751
  }
28452
- return root;
28453
28752
  }
28454
28753
  __name(tempRoot, "tempRoot");
28455
28754
  var SessionPaths = class {
@@ -28469,40 +28768,40 @@ var SessionPaths = class {
28469
28768
  }
28470
28769
  /** `$NAMZU_HOME/index.sqlite`. */
28471
28770
  indexFile() {
28472
- return join11(this.home, "index.sqlite");
28771
+ return join12(this.home, "index.sqlite");
28473
28772
  }
28474
28773
  projectDir() {
28475
- return join11(this.home, "projects", this.slug);
28774
+ return join12(this.home, "projects", this.slug);
28476
28775
  }
28477
28776
  projectFile() {
28478
- return join11(this.projectDir(), "project.json");
28777
+ return join12(this.projectDir(), "project.json");
28479
28778
  }
28480
28779
  memoryDir() {
28481
- return join11(this.projectDir(), "memory");
28780
+ return join12(this.projectDir(), "memory");
28482
28781
  }
28483
28782
  residentDir(agentKey) {
28484
- return join11(this.projectDir(), "residents", checkName(agentKey, "resident agent key"));
28783
+ return join12(this.projectDir(), "residents", checkName(agentKey, "resident agent key"));
28485
28784
  }
28486
28785
  /** The `GitWorktreeManager` default root, or one labelled worktree inside it. */
28487
28786
  worktrees(label6) {
28488
- const root = join11(this.projectDir(), "worktrees");
28489
- return label6 === void 0 ? root : join11(root, checkName(label6, "worktree label"));
28787
+ const root = join12(this.projectDir(), "worktrees");
28788
+ return label6 === void 0 ? root : join12(root, checkName(label6, "worktree label"));
28490
28789
  }
28491
28790
  /** The directory that holds `<session-id>.jsonl`: the project for a root session, `subagents/` of its parent otherwise. */
28492
28791
  #logParent(locator) {
28493
28792
  let parent = this.projectDir();
28494
28793
  for (const ancestor of locator.ancestors ?? []) {
28495
- parent = join11(parent, checkId(ancestor, "session"), "subagents");
28794
+ parent = join12(parent, checkId(ancestor, "session"), "subagents");
28496
28795
  }
28497
28796
  return parent;
28498
28797
  }
28499
28798
  /** `<session-id>.jsonl`, or `…/subagents/<child-id>.jsonl` for a child session. */
28500
28799
  sessionLog(locator) {
28501
- return join11(this.#logParent(locator), `${checkId(locator.sessionId, "session")}.jsonl`);
28800
+ return join12(this.#logParent(locator), `${checkId(locator.sessionId, "session")}.jsonl`);
28502
28801
  }
28503
28802
  /** The session's own directory, beside its log. */
28504
28803
  sessionDir(locator) {
28505
- return join11(this.#logParent(locator), checkId(locator.sessionId, "session"));
28804
+ return join12(this.#logParent(locator), checkId(locator.sessionId, "session"));
28506
28805
  }
28507
28806
  #child(parent, childId) {
28508
28807
  return { sessionId: childId, ancestors: [...parent.ancestors ?? [], parent.sessionId] };
@@ -28512,67 +28811,74 @@ var SessionPaths = class {
28512
28811
  }
28513
28812
  /** `<parent-dir>/subagents/<child-id>.meta.json`. */
28514
28813
  subagentMeta(parent, childId) {
28515
- return join11(this.sessionDir(parent), "subagents", `${checkId(childId, "session")}.meta.json`);
28814
+ return join12(this.sessionDir(parent), "subagents", `${checkId(childId, "session")}.meta.json`);
28516
28815
  }
28517
28816
  toolResults(locator) {
28518
- return join11(this.sessionDir(locator), "tool-results");
28817
+ return join12(this.sessionDir(locator), "tool-results");
28519
28818
  }
28520
28819
  /** A spilled tool result, named by the SHA-256 of its provider tool-use id; the manifest is `<file>.manifest.json`. */
28521
28820
  toolResultFile(locator, toolUseId3) {
28522
28821
  if (toolUseId3.length === 0)
28523
28822
  throw new SessionPathError("A tool-use id is required.");
28524
- return join11(this.toolResults(locator), `${sha256Hex3(toolUseId3)}.txt`);
28823
+ return join12(this.toolResults(locator), `${sha256Hex4(toolUseId3)}.txt`);
28525
28824
  }
28526
28825
  checkpoints(locator) {
28527
- return join11(this.sessionDir(locator), "checkpoints");
28826
+ return join12(this.sessionDir(locator), "checkpoints");
28528
28827
  }
28529
28828
  checkpointFile(locator, checkpointId4) {
28530
- return join11(this.checkpoints(locator), `${checkId(checkpointId4, "checkpoint")}.json`);
28829
+ return join12(this.checkpoints(locator), `${checkId(checkpointId4, "checkpoint")}.json`);
28531
28830
  }
28532
28831
  /** Token ledgers; written for root sessions only. */
28533
28832
  budgets(locator) {
28534
- return join11(this.sessionDir(locator), "budgets");
28833
+ return join12(this.sessionDir(locator), "budgets");
28535
28834
  }
28536
28835
  budgetFile(locator, rootTurnId) {
28537
- return join11(this.budgets(locator), `${checkId(rootTurnId, "turn")}.json`);
28836
+ return join12(this.budgets(locator), `${checkId(rootTurnId, "turn")}.json`);
28538
28837
  }
28539
28838
  tasks(locator) {
28540
- return join11(this.sessionDir(locator), "tasks");
28839
+ return join12(this.sessionDir(locator), "tasks");
28541
28840
  }
28542
28841
  /** The session's plan directory; a host that has a plan mode keeps its one plan file here. */
28543
28842
  plans(locator) {
28544
- return join11(this.sessionDir(locator), "plans");
28843
+ return join12(this.sessionDir(locator), "plans");
28545
28844
  }
28546
28845
  /** The one file a session's plan mode may write: `<session-id>/plans/plan.md`. */
28547
28846
  planFile(locator) {
28548
- return join11(this.plans(locator), "plan.md");
28847
+ return join12(this.plans(locator), "plan.md");
28549
28848
  }
28550
28849
  taskFile(locator, taskId) {
28551
- return join11(this.tasks(locator), `${checkId(taskId, "task")}.json`);
28850
+ return join12(this.tasks(locator), `${checkId(taskId, "task")}.json`);
28552
28851
  }
28553
28852
  feedback(locator) {
28554
- return join11(this.sessionDir(locator), "feedback");
28853
+ return join12(this.sessionDir(locator), "feedback");
28555
28854
  }
28556
28855
  feedbackFile(locator, messageId4) {
28557
- return join11(this.feedback(locator), `${checkId(messageId4, "message")}.json`);
28856
+ return join12(this.feedback(locator), `${checkId(messageId4, "message")}.json`);
28558
28857
  }
28559
28858
  goals(locator) {
28560
- return join11(this.sessionDir(locator), "goals");
28859
+ return join12(this.sessionDir(locator), "goals");
28561
28860
  }
28562
28861
  goalFile(locator, goalId) {
28563
- return join11(this.goals(locator), `${checkId(goalId, "goal")}.json`);
28862
+ return join12(this.goals(locator), `${checkId(goalId, "goal")}.json`);
28564
28863
  }
28565
28864
  /** File snapshots a CLI `/restore` rolls back to. */
28566
28865
  fileHistory(locator) {
28567
- return join11(this.sessionDir(locator), "file-history");
28866
+ return join12(this.sessionDir(locator), "file-history");
28568
28867
  }
28569
28868
  lease(locator) {
28570
- return join11(this.sessionDir(locator), "lease.json");
28869
+ return join12(this.sessionDir(locator), "lease.json");
28571
28870
  }
28572
- /** `$TMPDIR/namzu-<user>/<slug>/<session-id>/scratchpad`. Not created; the per-user root is. */
28871
+ /** `<temp base>/namzu-<user>/<slug>/<session-id>/scratchpad`. Not created; the per-user root is. */
28573
28872
  tempDir(sessionId5) {
28574
28873
  this.#tempRoot ??= tempRoot();
28575
- return join11(this.#tempRoot, this.slug, checkId(sessionId5, "session"), "scratchpad");
28874
+ return join12(this.#tempRoot, this.slug, checkId(sessionId5, "session"), "scratchpad");
28875
+ }
28876
+ /**
28877
+ * Where {@link tempDir} is, creating and checking nothing, not even the
28878
+ * per-user root: for a caller that makes the folder only when it is first used.
28879
+ */
28880
+ scratchpadPath(sessionId5) {
28881
+ return join12(this.#tempRoot ?? privateTempRootPath(), this.slug, checkId(sessionId5, "session"), "scratchpad");
28576
28882
  }
28577
28883
  };
28578
28884
 
@@ -28687,7 +28993,8 @@ var DiskSessionLog = class _DiskSessionLog extends SessionLogCore {
28687
28993
  spillAboveBytes: options.spillAboveBytes,
28688
28994
  compactionSpillAboveBytes: options.compactionSpillAboveBytes,
28689
28995
  structuredResultSpilling: options.structuredResultSpilling,
28690
- sync: options.sync
28996
+ sync: options.sync,
28997
+ degradedBufferBytes: options.degradedBufferBytes
28691
28998
  });
28692
28999
  this.file = options.file;
28693
29000
  this.sessionDir = options.sessionDir;
@@ -28824,7 +29131,7 @@ async function readStructuredResultSpill(log, ref, signal) {
28824
29131
  throw new SpillIntegrityError(ref.path, "Invalid or oversized structured result reference.");
28825
29132
  const json2 = await awaitWithAbort(log.readSpill(ref, { maxBytes: STRUCTURED_RESULT_MAX_BYTES, signal }), signal);
28826
29133
  signal?.throwIfAborted();
28827
- if (typeof json2 !== "string" || Buffer.byteLength(json2, "utf8") !== ref.bytes || sha256Hex2(json2) !== ref.sha256) {
29134
+ if (typeof json2 !== "string" || Buffer.byteLength(json2, "utf8") !== ref.bytes || sha256Hex3(json2) !== ref.sha256) {
28828
29135
  throw new SpillIntegrityError(ref.path, "Structured result bytes do not match their recorded length and SHA-256.");
28829
29136
  }
28830
29137
  let value;
@@ -29329,6 +29636,10 @@ var TurnRecorder = class {
29329
29636
  this.#leaseHeartbeat = setInterval(() => this.#queueLeaseRenewal(), this.#leaseTtlMs / 2);
29330
29637
  this.#leaseHeartbeat.unref();
29331
29638
  }
29639
+ this.#stopWatchingHealth ??= this.log.onWriteHealth?.((change) => {
29640
+ for (const listener of this.#healthListeners)
29641
+ listener(change);
29642
+ });
29332
29643
  const head2 = await this.log.head();
29333
29644
  if (head2 === null) {
29334
29645
  this.#lastEntry = await this.log.append(lease, {
@@ -29358,6 +29669,19 @@ var TurnRecorder = class {
29358
29669
  throw error;
29359
29670
  }
29360
29671
  }
29672
+ /**
29673
+ * Be told when the session log stops writing (the disk is full) and when
29674
+ * it writes again. Sent while the recorder holds the log, from `open` to
29675
+ * `release`.
29676
+ */
29677
+ onLogWriteHealth(listener) {
29678
+ this.#healthListeners.add(listener);
29679
+ return () => {
29680
+ this.#healthListeners.delete(listener);
29681
+ };
29682
+ }
29683
+ #healthListeners = /* @__PURE__ */ new Set();
29684
+ #stopWatchingHealth;
29361
29685
  /** Serialize timer and write-triggered renewals so release uses the latest token. */
29362
29686
  #queueLeaseRenewal() {
29363
29687
  this.#leaseRenewal = this.#leaseRenewal.then(async () => {
@@ -29404,6 +29728,8 @@ var TurnRecorder = class {
29404
29728
  }
29405
29729
  /** Give up a lease the recorder claimed. Never throws. */
29406
29730
  async release() {
29731
+ this.#stopWatchingHealth?.();
29732
+ this.#stopWatchingHealth = void 0;
29407
29733
  if (!this.#ownsLease || !this.#lease)
29408
29734
  return;
29409
29735
  this.#released = true;
@@ -32617,12 +32943,12 @@ var AwaitedJobs = class {
32617
32943
  return Promise.resolve();
32618
32944
  if (this.outstanding.size === 0 && this.monitors.size === 0)
32619
32945
  return Promise.resolve();
32620
- return new Promise((resolve34) => {
32946
+ return new Promise((resolve35) => {
32621
32947
  const finish2 = /* @__PURE__ */ __name(() => {
32622
32948
  clearTimeout(timer);
32623
32949
  this.arrivals.delete(finish2);
32624
32950
  signal?.removeEventListener("abort", finish2);
32625
- resolve34();
32951
+ resolve35();
32626
32952
  }, "finish");
32627
32953
  const timer = setTimeout(finish2, timeoutMs);
32628
32954
  timer.unref?.();
@@ -34122,7 +34448,7 @@ var DetachedCalls = class {
34122
34448
  return Promise.resolve();
34123
34449
  if (signal.aborted)
34124
34450
  return Promise.reject(signal.reason);
34125
- return new Promise((resolve34, reject2) => {
34451
+ return new Promise((resolve35, reject2) => {
34126
34452
  const done = /* @__PURE__ */ __name(() => {
34127
34453
  clearTimeout(timer);
34128
34454
  this.waiters.delete(wake);
@@ -34130,7 +34456,7 @@ var DetachedCalls = class {
34130
34456
  }, "done");
34131
34457
  const wake = /* @__PURE__ */ __name(() => {
34132
34458
  done();
34133
- resolve34();
34459
+ resolve35();
34134
34460
  }, "wake");
34135
34461
  const abort = /* @__PURE__ */ __name(() => {
34136
34462
  done();
@@ -34148,10 +34474,10 @@ var DetachedCalls = class {
34148
34474
  };
34149
34475
 
34150
34476
  // ../sdk/dist/store/memory/digest.js
34151
- import { createHash as createHash8 } from "node:crypto";
34477
+ import { createHash as createHash9 } from "node:crypto";
34152
34478
  var KNOWLEDGE_TAG_PREFIX = "knowledge:";
34153
34479
  function knowledgeDigest(value) {
34154
- return createHash8("sha256").update(JSON.stringify(value)).digest("hex");
34480
+ return createHash9("sha256").update(JSON.stringify(value)).digest("hex");
34155
34481
  }
34156
34482
  __name(knowledgeDigest, "knowledgeDigest");
34157
34483
  async function holdsKnowledgeDigest(store, tags, digest8, isWriter) {
@@ -34955,12 +35281,12 @@ var CompletionInbox = class {
34955
35281
  return Promise.resolve();
34956
35282
  if (!this.hasPendingWork)
34957
35283
  return Promise.resolve();
34958
- return new Promise((resolve34) => {
35284
+ return new Promise((resolve35) => {
34959
35285
  const finish2 = /* @__PURE__ */ __name(() => {
34960
35286
  clearTimeout(timer);
34961
35287
  this.arrivals.delete(finish2);
34962
35288
  signal?.removeEventListener("abort", finish2);
34963
- resolve34();
35289
+ resolve35();
34964
35290
  }, "finish");
34965
35291
  const timer = setTimeout(finish2, timeoutMs);
34966
35292
  timer.unref?.();
@@ -35128,11 +35454,11 @@ ${JSON.stringify({ tasks: tasks2 })}`;
35128
35454
  });
35129
35455
  if (settlements.length === 0)
35130
35456
  return this.drain();
35131
- await new Promise((resolve34) => {
35457
+ await new Promise((resolve35) => {
35132
35458
  const finish2 = /* @__PURE__ */ __name(() => {
35133
35459
  signal?.removeEventListener("abort", finish2);
35134
35460
  this.drains.delete(finish2);
35135
- resolve34();
35461
+ resolve35();
35136
35462
  }, "finish");
35137
35463
  this.drains.add(finish2);
35138
35464
  signal?.addEventListener("abort", finish2, { once: true });
@@ -35391,7 +35717,7 @@ async function deliverDurableInbound(recorder, source, signal) {
35391
35717
  __name(deliverDurableInbound, "deliverDurableInbound");
35392
35718
 
35393
35719
  // ../sdk/dist/runtime/query/observation-context.js
35394
- import { createHash as createHash11 } from "node:crypto";
35720
+ import { createHash as createHash12 } from "node:crypto";
35395
35721
 
35396
35722
  // ../sdk/dist/compaction/retention.js
35397
35723
  var isAssistantWithCalls = /* @__PURE__ */ __name((m) => m.role === "assistant" && Array.isArray(m.toolCalls), "isAssistantWithCalls");
@@ -35467,12 +35793,12 @@ function findRetainedIndices(messages) {
35467
35793
  __name(findRetainedIndices, "findRetainedIndices");
35468
35794
 
35469
35795
  // ../sdk/dist/runtime/query/tool-output-budget.js
35470
- import { createHash as createHash10 } from "node:crypto";
35796
+ import { createHash as createHash11 } from "node:crypto";
35471
35797
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
35472
- import { join as join12 } from "node:path";
35798
+ import { join as join13 } from "node:path";
35473
35799
 
35474
35800
  // ../sdk/dist/store/evidence/format.js
35475
- import { createHash as createHash9 } from "node:crypto";
35801
+ import { createHash as createHash10 } from "node:crypto";
35476
35802
 
35477
35803
  // ../sdk/dist/utils/evidence-tokens.js
35478
35804
  function evidenceTokens(text10) {
@@ -35511,7 +35837,7 @@ var SEARCH_OVERLAP_BYTES = 1024;
35511
35837
  var FILTER_BYTES = 1024;
35512
35838
  var TOKEN_FILTER_PREFIX = `tokens-v1:${digest2(`${process.version}:${process.versions.v8}:${process.versions.unicode}`).slice(0, 16)}:`;
35513
35839
  function digest2(value) {
35514
- return createHash9("sha256").update(value).digest("hex");
35840
+ return createHash10("sha256").update(value).digest("hex");
35515
35841
  }
35516
35842
  __name(digest2, "digest");
35517
35843
  function hashAt(text10, offset) {
@@ -35776,8 +36102,8 @@ __name(applyToolOutputBudget, "applyToolOutputBudget");
35776
36102
  function spill2(dir, toolUseId3, content, onError) {
35777
36103
  try {
35778
36104
  mkdirSync3(dir, { recursive: true, mode: 448 });
35779
- const name2 = createHash10("sha256").update(toolUseId3).digest("hex");
35780
- const path3 = join12(dir, `${name2}.txt`);
36105
+ const name2 = createHash11("sha256").update(toolUseId3).digest("hex");
36106
+ const path3 = join13(dir, `${name2}.txt`);
35781
36107
  const bytes = Buffer.from(content, "utf8");
35782
36108
  writeFileSync2(path3, bytes, { flag: "wx", mode: 384 });
35783
36109
  try {
@@ -35998,7 +36324,7 @@ function projectObservationContext(messages, tools, preserveToolResultsFrom = []
35998
36324
  }
35999
36325
  if (executionKey === void 0)
36000
36326
  continue;
36001
- const key6 = createHash11("sha256").update(JSON.stringify([
36327
+ const key6 = createHash12("sha256").update(JSON.stringify([
36002
36328
  call2.function.name,
36003
36329
  call2.function.arguments,
36004
36330
  message.content,
@@ -36025,7 +36351,7 @@ function projectObservationContext(messages, tools, preserveToolResultsFrom = []
36025
36351
  __name(projectObservationContext, "projectObservationContext");
36026
36352
 
36027
36353
  // ../sdk/dist/runtime/query/request-context.js
36028
- import { createHash as createHash12 } from "node:crypto";
36354
+ import { createHash as createHash13 } from "node:crypto";
36029
36355
  function canonicalJson2(value) {
36030
36356
  return JSON.stringify(value, (_key, item) => {
36031
36357
  if (!item || typeof item !== "object" || Array.isArray(item))
@@ -36044,7 +36370,7 @@ function snapshotRequestContext(messages) {
36044
36370
  partIndex: partIndex++,
36045
36371
  role: message.role,
36046
36372
  kind,
36047
- digest: createHash12("sha256").update(canonicalJson2(payload)).digest("hex"),
36373
+ digest: createHash13("sha256").update(canonicalJson2(payload)).digest("hex"),
36048
36374
  ...toolCallId !== void 0 ? { toolCallId } : {},
36049
36375
  ...message.role === "tool" ? { isError: message.isError === true } : {}
36050
36376
  }));
@@ -36096,6 +36422,13 @@ function diffRequestContext(previous, next2) {
36096
36422
  }
36097
36423
  __name(diffRequestContext, "diffRequestContext");
36098
36424
 
36425
+ // ../sdk/dist/runtime/query/request-void-turns.js
36426
+ function withoutVoidAssistantTurns(messages) {
36427
+ const isVoid = /* @__PURE__ */ __name((message) => message.role === "assistant" && !message.content && (message.toolCalls?.length ?? 0) === 0 && (message.reasoning?.length ?? 0) === 0 && (message.citations?.length ?? 0) === 0 && (message.textParts?.length ?? 0) === 0, "isVoid");
36428
+ return messages.some(isVoid) ? messages.filter((message) => !isVoid(message)) : messages;
36429
+ }
36430
+ __name(withoutVoidAssistantTurns, "withoutVoidAssistantTurns");
36431
+
36099
36432
  // ../sdk/dist/runtime/query/iteration/effort-clamp.js
36100
36433
  var EFFORT_ORDER = [
36101
36434
  "none",
@@ -36671,21 +37004,21 @@ async function waitForTaskWithBounds(gateway, taskId, bounds, now = Date.now) {
36671
37004
  throw err;
36672
37005
  }
36673
37006
  );
36674
- const expiry = new Promise((resolve34) => {
37007
+ const expiry = new Promise((resolve35) => {
36675
37008
  const tick = setInterval(() => {
36676
37009
  if (settled)
36677
37010
  return;
36678
37011
  const elapsed = now() - startedAt;
36679
37012
  if (elapsed >= bounds.wallMs) {
36680
37013
  clearInterval(tick);
36681
- resolve34({ kind: "timeout", cause: "wall", elapsedMs: elapsed, idleBoundArmed });
37014
+ resolve35({ kind: "timeout", cause: "wall", elapsedMs: elapsed, idleBoundArmed });
36682
37015
  return;
36683
37016
  }
36684
37017
  if (idleBoundArmed && bounds.idleMs !== void 0) {
36685
37018
  const quietFor = now() - lastProgressAt;
36686
37019
  if (quietFor >= bounds.idleMs) {
36687
37020
  clearInterval(tick);
36688
- resolve34({ kind: "timeout", cause: "idle", elapsedMs: elapsed, idleBoundArmed });
37021
+ resolve35({ kind: "timeout", cause: "idle", elapsedMs: elapsed, idleBoundArmed });
36689
37022
  }
36690
37023
  }
36691
37024
  }, POLL_INTERVAL_MS);
@@ -40165,14 +40498,14 @@ async function awaitDecisionDurably(ctx, checkpoint, request, scope) {
40165
40498
  }, "record");
40166
40499
  let parkTimer;
40167
40500
  let recording = false;
40168
- const recordIfSlow = new Promise((resolve34) => {
40501
+ const recordIfSlow = new Promise((resolve35) => {
40169
40502
  parkTimer = setTimeout(() => {
40170
40503
  if (settled) {
40171
- resolve34();
40504
+ resolve35();
40172
40505
  return;
40173
40506
  }
40174
40507
  recording = true;
40175
- record3().then(resolve34, resolve34);
40508
+ record3().then(resolve35, resolve35);
40176
40509
  }, delay2);
40177
40510
  });
40178
40511
  try {
@@ -40221,13 +40554,13 @@ async function awaitDecisionOrAbort(ctx, request, scope) {
40221
40554
  const abortedDecision = /* @__PURE__ */ __name(() => scope && !turnSignal?.aborted ? scope.closedAs() : { action: "abort", reason: "run aborted while parked for HITL" }, "abortedDecision");
40222
40555
  if (signal.aborted)
40223
40556
  return abortedDecision();
40224
- return new Promise((resolve34) => {
40557
+ return new Promise((resolve35) => {
40225
40558
  let settled = false;
40226
40559
  const onAbort = /* @__PURE__ */ __name(() => {
40227
40560
  if (settled)
40228
40561
  return;
40229
40562
  settled = true;
40230
- resolve34(abortedDecision());
40563
+ resolve35(abortedDecision());
40231
40564
  }, "onAbort");
40232
40565
  signal.addEventListener("abort", onAbort, { once: true });
40233
40566
  Promise.resolve(ctx.resumeHandler(request, resumeContext)).then((decision2) => {
@@ -40235,13 +40568,13 @@ async function awaitDecisionOrAbort(ctx, request, scope) {
40235
40568
  return;
40236
40569
  settled = true;
40237
40570
  signal.removeEventListener("abort", onAbort);
40238
- resolve34(decision2);
40571
+ resolve35(decision2);
40239
40572
  }, (err) => {
40240
40573
  if (settled)
40241
40574
  return;
40242
40575
  settled = true;
40243
40576
  signal.removeEventListener("abort", onAbort);
40244
- resolve34({
40577
+ resolve35({
40245
40578
  action: "abort",
40246
40579
  reason: err instanceof Error ? err.message : "resume handler failed"
40247
40580
  });
@@ -40447,7 +40780,7 @@ var DECLINED_TOOL_CALL_FEEDBACK = "The user declined this. Do not get the same c
40447
40780
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
40448
40781
  async function awaitProjectInstructionCallback(signal, start) {
40449
40782
  signal.throwIfAborted();
40450
- return new Promise((resolve34, reject2) => {
40783
+ return new Promise((resolve35, reject2) => {
40451
40784
  let settled = false;
40452
40785
  const cleanup = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "cleanup");
40453
40786
  const rejectOnce = /* @__PURE__ */ __name((reason2) => {
@@ -40462,7 +40795,7 @@ async function awaitProjectInstructionCallback(signal, start) {
40462
40795
  return;
40463
40796
  settled = true;
40464
40797
  cleanup();
40465
- resolve34(value);
40798
+ resolve35(value);
40466
40799
  }, "resolveOnce");
40467
40800
  const onAbort = /* @__PURE__ */ __name(() => rejectOnce(signal.reason), "onAbort");
40468
40801
  signal.addEventListener("abort", onAbort, { once: true });
@@ -40606,7 +40939,7 @@ function replaceProjectInstructionSnapshot(messages, snapshot, placement = "appe
40606
40939
  __name(replaceProjectInstructionSnapshot, "replaceProjectInstructionSnapshot");
40607
40940
 
40608
40941
  // ../sdk/dist/runtime/query/repeat-call.js
40609
- import { createHash as createHash13 } from "node:crypto";
40942
+ import { createHash as createHash14 } from "node:crypto";
40610
40943
 
40611
40944
  // ../sdk/dist/runtime/query/tool-grants.js
40612
40945
  function toolGrantKeys(call2) {
@@ -40715,7 +41048,7 @@ var RepeatCallTracker = class {
40715
41048
  this.failures.delete(key6);
40716
41049
  return;
40717
41050
  }
40718
- const fingerprint = createHash13("sha256").update(stableStringify(outcome.result ?? null)).digest("hex");
41051
+ const fingerprint = createHash14("sha256").update(stableStringify(outcome.result ?? null)).digest("hex");
40719
41052
  const previous = this.failures.get(key6);
40720
41053
  this.failures.set(key6, {
40721
41054
  fingerprint,
@@ -42105,19 +42438,17 @@ __name(pushRedirection, "pushRedirection");
42105
42438
  import { randomUUID as randomUUID3 } from "node:crypto";
42106
42439
  import { statSync } from "node:fs";
42107
42440
  import { rm } from "node:fs/promises";
42108
- import { tmpdir as tmpdir2 } from "node:os";
42109
- import { join as join14 } from "node:path";
42110
42441
 
42111
42442
  // ../sdk/dist/tools/paths.js
42112
42443
  import { realpath as realpath2 } from "node:fs/promises";
42113
- import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute3, join as join13, relative, resolve as resolve3 } from "node:path";
42444
+ import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute4, join as join14, relative as relative2, resolve as resolve4 } from "node:path";
42114
42445
  function resolveWithin(root, candidate) {
42115
42446
  if (candidate === void 0 || candidate === "")
42116
- return resolve3(root);
42117
- const resolvedRoot = resolve3(root);
42118
- const resolved2 = resolve3(resolvedRoot, candidate);
42119
- const rel = relative(resolvedRoot, resolved2);
42120
- if (rel.startsWith("..") || isAbsolute3(rel)) {
42447
+ return resolve4(root);
42448
+ const resolvedRoot = resolve4(root);
42449
+ const resolved2 = resolve4(resolvedRoot, candidate);
42450
+ const rel = relative2(resolvedRoot, resolved2);
42451
+ if (rel.startsWith("..") || isAbsolute4(rel)) {
42121
42452
  throw new Error(`Path escapes the working directory: ${candidate}. ${OUTSIDE_ROOTS_GUIDANCE(`inside ${resolvedRoot}`)}`);
42122
42453
  }
42123
42454
  return resolved2;
@@ -42142,12 +42473,12 @@ async function pathOutsideRoots(roots, candidate) {
42142
42473
  await resolveWithinAnyReal(roots, candidate);
42143
42474
  return void 0;
42144
42475
  } catch {
42145
- return resolve3(resolve3(first), candidate);
42476
+ return resolve4(resolve4(first), candidate);
42146
42477
  }
42147
42478
  }
42148
42479
  __name(pathOutsideRoots, "pathOutsideRoots");
42149
42480
  function describeRoots(roots) {
42150
- return roots.length === 1 ? `inside ${resolve3(roots[0])}` : `inside ${resolve3(roots[0])} or the added directories ${roots.slice(1).map((r) => resolve3(r)).join(", ")}`;
42481
+ return roots.length === 1 ? `inside ${resolve4(roots[0])}` : `inside ${resolve4(roots[0])} or the added directories ${roots.slice(1).map((r) => resolve4(r)).join(", ")}`;
42151
42482
  }
42152
42483
  __name(describeRoots, "describeRoots");
42153
42484
  function resolveWithinAny(roots, candidate) {
@@ -42156,7 +42487,7 @@ function resolveWithinAny(roots, candidate) {
42156
42487
  throw new Error("No root to resolve within.");
42157
42488
  if (rest.length === 0)
42158
42489
  return resolveWithin(first, candidate);
42159
- const resolved2 = candidate === void 0 || candidate === "" ? resolve3(first) : resolve3(resolve3(first), candidate);
42490
+ const resolved2 = candidate === void 0 || candidate === "" ? resolve4(first) : resolve4(resolve4(first), candidate);
42160
42491
  for (const root of roots) {
42161
42492
  if (isWithin(root, resolved2))
42162
42493
  return resolveWithin(root, resolved2);
@@ -42170,7 +42501,7 @@ async function resolveWithinAnyReal(roots, candidate) {
42170
42501
  throw new Error("No root to resolve within.");
42171
42502
  if (rest.length === 0)
42172
42503
  return resolveWithinReal(first, candidate);
42173
- const resolved2 = candidate === void 0 || candidate === "" ? resolve3(first) : resolve3(resolve3(first), candidate);
42504
+ const resolved2 = candidate === void 0 || candidate === "" ? resolve4(first) : resolve4(resolve4(first), candidate);
42174
42505
  let firstError;
42175
42506
  for (const root of roots) {
42176
42507
  try {
@@ -42193,10 +42524,10 @@ function isWithin(root, candidate) {
42193
42524
  __name(isWithin, "isWithin");
42194
42525
  async function resolveWithinReal(root, candidate) {
42195
42526
  const lexical = resolveWithin(root, candidate);
42196
- const realRoot = await canonicalize(resolve3(root));
42527
+ const realRoot = await canonicalize(resolve4(root));
42197
42528
  const canonical3 = await canonicalize(lexical);
42198
- const rel = relative(realRoot, canonical3);
42199
- if (rel.startsWith("..") || isAbsolute3(rel)) {
42529
+ const rel = relative2(realRoot, canonical3);
42530
+ if (rel.startsWith("..") || isAbsolute4(rel)) {
42200
42531
  throw new Error(`Path escapes the working directory: ${candidate}. It resolves through a link to ${canonical3}, outside ${realRoot}. ${OUTSIDE_ROOTS_GUIDANCE(`inside ${realRoot}`)}`);
42201
42532
  }
42202
42533
  return canonical3;
@@ -42208,11 +42539,11 @@ async function canonicalize(absolute) {
42208
42539
  for (; ; ) {
42209
42540
  const found = await realpath2(existing).then((value) => value, () => void 0);
42210
42541
  if (found !== void 0)
42211
- return remainder ? join13(found, remainder) : found;
42542
+ return remainder ? join14(found, remainder) : found;
42212
42543
  const parent = dirname8(existing);
42213
42544
  if (parent === existing)
42214
42545
  return absolute;
42215
- remainder = remainder ? join13(basename5(existing), remainder) : basename5(existing);
42546
+ remainder = remainder ? join14(basename5(existing), remainder) : basename5(existing);
42216
42547
  existing = parent;
42217
42548
  }
42218
42549
  }
@@ -42300,7 +42631,7 @@ exit $__namzu_status`;
42300
42631
  }
42301
42632
  __name(withCwdCapture, "withCwdCapture");
42302
42633
  function newCwdFile() {
42303
- return join14(tmpdir2(), `namzu-cwd-${randomUUID3()}`);
42634
+ return tempFilePath(`cwd-${randomUUID3()}`);
42304
42635
  }
42305
42636
  __name(newCwdFile, "newCwdFile");
42306
42637
  function startingDirectory(sessionId5, base3) {
@@ -43393,16 +43724,16 @@ function split(command) {
43393
43724
  continue;
43394
43725
  }
43395
43726
  if (ch === "|" || ch === "&" || ch === ";" || ch === "\n") {
43396
- let sep17 = ch;
43727
+ let sep18 = ch;
43397
43728
  if ((ch === "|" || ch === "&") && next2 === ch) {
43398
- sep17 = ch + ch;
43729
+ sep18 = ch + ch;
43399
43730
  i += 1;
43400
43731
  } else if (ch === "|" && next2 === "&") {
43401
- sep17 = "|&";
43732
+ sep18 = "|&";
43402
43733
  i += 1;
43403
43734
  }
43404
43735
  push();
43405
- pending2 = sep17 === "\n" ? ";" : sep17;
43736
+ pending2 = sep18 === "\n" ? ";" : sep18;
43406
43737
  continue;
43407
43738
  }
43408
43739
  current += ch;
@@ -43593,7 +43924,7 @@ function shellProgress(report) {
43593
43924
  __name(shellProgress, "shellProgress");
43594
43925
  function execHostShell(command, options) {
43595
43926
  options.signal?.throwIfAborted();
43596
- return new Promise((resolve34, reject2) => {
43927
+ return new Promise((resolve35, reject2) => {
43597
43928
  const child = spawnHostShell(command, {
43598
43929
  cwd: options.cwd,
43599
43930
  env: options.env,
@@ -43694,7 +44025,7 @@ function execHostShell(command, options) {
43694
44025
  const stdout = decodeCapture("stdout");
43695
44026
  const stderr = decodeCapture("stderr");
43696
44027
  if (!failure2 && cause === void 0 && code === 0 && signal === null) {
43697
- resolve34({
44028
+ resolve35({
43698
44029
  stdout,
43699
44030
  stderr,
43700
44031
  stdoutBytes: captures.stdout.bytes,
@@ -43745,7 +44076,7 @@ ${stderr}`));
43745
44076
  child.off("close", onClose);
43746
44077
  child.off("error", onError);
43747
44078
  child.off("spawn", onSpawn);
43748
- resolve34({
44079
+ resolve35({
43749
44080
  backgroundedJobId: jobId,
43750
44081
  backgroundedBy: reason2,
43751
44082
  stdout: decodeCapture("stdout"),
@@ -44151,14 +44482,14 @@ __name(backoffProportional, "backoffProportional");
44151
44482
  function sleep(ms, signal) {
44152
44483
  if (ms <= 0)
44153
44484
  return Promise.resolve();
44154
- return new Promise((resolve34, reject2) => {
44485
+ return new Promise((resolve35, reject2) => {
44155
44486
  if (signal?.aborted) {
44156
44487
  reject2(signal.reason);
44157
44488
  return;
44158
44489
  }
44159
44490
  const timer = setTimeout(() => {
44160
44491
  signal?.removeEventListener("abort", onAbort);
44161
- resolve34();
44492
+ resolve35();
44162
44493
  }, ms);
44163
44494
  const onAbort = /* @__PURE__ */ __name(() => {
44164
44495
  clearTimeout(timer);
@@ -44646,7 +44977,7 @@ __name(createAutoReviewClassifier, "createAutoReviewClassifier");
44646
44977
 
44647
44978
  // ../sdk/dist/runtime/query/path-escalation.js
44648
44979
  import { homedir as homedir2 } from "node:os";
44649
- import { isAbsolute as isAbsolute5, relative as relative2, resolve as resolve5, sep as sep4 } from "node:path";
44980
+ import { isAbsolute as isAbsolute6, relative as relative3, resolve as resolve6, sep as sep5 } from "node:path";
44650
44981
 
44651
44982
  // ../sdk/dist/authorization/protected-paths.js
44652
44983
  var PROTECTED_DIRECTORIES = [
@@ -44747,7 +45078,7 @@ __name(isProtectedPath, "isProtectedPath");
44747
45078
  // ../sdk/dist/authorization/removal.js
44748
45079
  import { existsSync as existsSync2, realpathSync } from "node:fs";
44749
45080
  import { homedir } from "node:os";
44750
- import { dirname as dirname9, isAbsolute as isAbsolute4, join as join15, normalize as normalize5, basename as pathBasename, resolve as resolve4, sep as sep3 } from "node:path";
45081
+ import { dirname as dirname9, isAbsolute as isAbsolute5, join as join15, normalize as normalize5, basename as pathBasename, resolve as resolve5, sep as sep4 } from "node:path";
44751
45082
  var TOP_LEVEL = "bin|boot|dev|etc|home|lib|lib32|lib64|libx32|media|mnt|opt|proc|root|run|sbin|srv|sys|tmp|usr|var|snap|nix|lost\\+found|private|cores|Applications|Library|System|Users|Volumes|Windows|ProgramData|cygdrive";
44752
45083
  var VAR = "(?:\\{([A-Za-z_][A-Za-z0-9_]*)(?::?-[^}]*)?\\}|([A-Za-z_][A-Za-z0-9_]*))";
44753
45084
  var EMPTY_VARIABLE_ROOT = new RegExp(`^\\$${VAR}/(?:[*?[{]|\\$|/|$)`);
@@ -44844,13 +45175,13 @@ function dangerousRemoval(reading, changesDirectory, context2) {
44844
45175
  return void 0;
44845
45176
  const home = context2.home ?? homedir();
44846
45177
  const env = context2.env ?? process.env;
44847
- const cwd = resolve4(context2.cwd);
45178
+ const cwd = resolve5(context2.cwd);
44848
45179
  const homes = [home, canonical2(home)];
44849
45180
  const workdirs = [cwd, canonical2(cwd)];
44850
45181
  const everyDirectory = [
44851
45182
  .../* @__PURE__ */ new Set([
44852
45183
  ...workdirs,
44853
- ...(context2.additionalDirectories ?? []).flatMap((d) => [resolve4(d), canonical2(resolve4(d))])
45184
+ ...(context2.additionalDirectories ?? []).flatMap((d) => [resolve5(d), canonical2(resolve5(d))])
44854
45185
  ])
44855
45186
  ];
44856
45187
  for (const removal of removals) {
@@ -44907,32 +45238,32 @@ __name(checkRemoval, "checkRemoval");
44907
45238
  var GLOB_TAIL = /[\\/]\.?\*$/;
44908
45239
  function checkTarget(program, args, spelled, word2, scope) {
44909
45240
  const expanded = expandTilde(spelled, scope.home);
44910
- const relative16 = !isAbsolute4(expanded);
45241
+ const relative17 = !isAbsolute5(expanded);
44911
45242
  if (expandsAtRuntime(word2) && /[$`]/.test(expanded)) {
44912
45243
  return void 0;
44913
45244
  }
44914
- const absolute = relative16 ? resolve4(scope.cwd, expanded) : resolve4(expanded);
45245
+ const absolute = relative17 ? resolve5(scope.cwd, expanded) : resolve5(expanded);
44915
45246
  let settled = absolute;
44916
45247
  for (let previous = ""; previous !== settled; ) {
44917
45248
  previous = settled;
44918
- const stripped = settled.replace(/([\\/]\.?\*+)+[\\/]*$/, "") || sep3;
45249
+ const stripped = settled.replace(/([\\/]\.?\*+)+[\\/]*$/, "") || sep4;
44919
45250
  if (stripped !== settled)
44920
45251
  settled = /[\\/]/.test(stripped) ? normalize5(stripped) : stripped;
44921
45252
  }
44922
45253
  const globbed = settled !== absolute;
44923
45254
  const original = expanded;
44924
- if (scope.changesDirectory && globbed && relative16 && GLOB_TAIL.test(absolute)) {
45255
+ if (scope.changesDirectory && globbed && relative17 && GLOB_TAIL.test(absolute)) {
44925
45256
  return `${program} ${spelled}: a relative glob after a cd cannot be resolved before the line runs`;
44926
45257
  }
44927
45258
  let below = settled;
44928
- if (relative16) {
44929
- const prefix = scope.cwd.endsWith(sep3) ? scope.cwd : scope.cwd + sep3;
45259
+ if (relative17) {
45260
+ const prefix = scope.cwd.endsWith(sep4) ? scope.cwd : scope.cwd + sep4;
44930
45261
  if (settled.startsWith(prefix))
44931
45262
  below = settled.slice(prefix.length);
44932
45263
  else if (settled === scope.cwd)
44933
45264
  below = "";
44934
45265
  }
44935
- if (globbed && (hasParentAfterName(original) || original.startsWith("~") || /^[\\/]{2}/.test(original) || relative16 && /(^|[\\/])\.\.([\\/]|$)/.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)) || relative16 && /\*[\\/]+$/.test(original) && GLOB_TAIL.test(absolute))) {
45266
+ if (globbed && (hasParentAfterName(original) || original.startsWith("~") || /^[\\/]{2}/.test(original) || relative17 && /(^|[\\/])\.\.([\\/]|$)/.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)) || relative17 && /\*[\\/]+$/.test(original) && GLOB_TAIL.test(absolute))) {
44936
45267
  return `${program} ${spelled}: the target cannot be resolved to a directory before the line runs`;
44937
45268
  }
44938
45269
  if (!globbed || !/[*?[]/.test(below)) {
@@ -44980,9 +45311,9 @@ __name(hasParentAfterName, "hasParentAfterName");
44980
45311
  function protectedScope(absolute, roots) {
44981
45312
  let best;
44982
45313
  for (const root of roots) {
44983
- const base3 = resolve5(root);
44984
- const below = relative2(base3, absolute);
44985
- if (below === "" || below.startsWith("..") || isAbsolute5(below))
45314
+ const base3 = resolve6(root);
45315
+ const below = relative3(base3, absolute);
45316
+ if (below === "" || below.startsWith("..") || isAbsolute6(below))
44986
45317
  continue;
44987
45318
  if (best === void 0 || below.length < best.length)
44988
45319
  best = below;
@@ -44991,12 +45322,12 @@ function protectedScope(absolute, roots) {
44991
45322
  }
44992
45323
  __name(protectedScope, "protectedScope");
44993
45324
  async function isProtectedWrite(spelled, absolute, roots) {
44994
- if (isProtectedPath(isAbsolute5(spelled) ? protectedScope(absolute, roots) : spelled))
45325
+ if (isProtectedPath(isAbsolute6(spelled) ? protectedScope(absolute, roots) : spelled))
44995
45326
  return true;
44996
45327
  if (isProtectedPath(protectedScope(absolute, roots)))
44997
45328
  return true;
44998
45329
  const real = await canonicalize(absolute);
44999
- const realRoots = await Promise.all(roots.map((root) => canonicalize(resolve5(root))));
45330
+ const realRoots = await Promise.all(roots.map((root) => canonicalize(resolve6(root))));
45000
45331
  return isProtectedPath(protectedScope(real, [...roots, ...realRoots]));
45001
45332
  }
45002
45333
  __name(isProtectedWrite, "isProtectedWrite");
@@ -45045,12 +45376,12 @@ function settle(value, home) {
45045
45376
  if (value === "~")
45046
45377
  return { path: home };
45047
45378
  if (value.startsWith("~/"))
45048
- return { path: resolve5(home, value.slice(2)) };
45379
+ return { path: resolve6(home, value.slice(2)) };
45049
45380
  if (value.startsWith("~"))
45050
45381
  return { unresolved: true };
45051
45382
  const variable = /^\$(?:\{HOME\}|HOME)(?=\/|$)/.exec(value);
45052
45383
  if (variable !== null)
45053
- return { path: resolve5(home, `.${value.slice(variable[0].length)}`) };
45384
+ return { path: resolve6(home, `.${value.slice(variable[0].length)}`) };
45054
45385
  if (/[$`]/.test(value))
45055
45386
  return { unresolved: true };
45056
45387
  return { path: value };
@@ -45068,7 +45399,7 @@ async function declaredWriteEscalation(roots, value) {
45068
45399
  const [first] = roots;
45069
45400
  if (first === void 0 || value === "")
45070
45401
  return void 0;
45071
- const absolute = resolve5(resolve5(first), value);
45402
+ const absolute = resolve6(resolve6(first), value);
45072
45403
  return await isProtectedWrite(value, absolute, roots) ? absolute : void 0;
45073
45404
  }
45074
45405
  __name(declaredWriteEscalation, "declaredWriteEscalation");
@@ -45080,17 +45411,17 @@ async function shellEscalations(line, dialect, context2) {
45080
45411
  const protectedPaths = /* @__PURE__ */ new Set();
45081
45412
  const home = homedir2();
45082
45413
  if (cwd !== void 0) {
45083
- const madeHere = reading.invocations.filter((invocation) => invocation.program === "ln").flatMap((invocation) => invocation.args.map((arg) => arg.value)).filter((value) => value !== "" && !value.startsWith("-")).map((value) => resolve5(cwd, value));
45414
+ const madeHere = reading.invocations.filter((invocation) => invocation.program === "ln").flatMap((invocation) => invocation.args.map((arg) => arg.value)).filter((value) => value !== "" && !value.startsWith("-")).map((value) => resolve6(cwd, value));
45084
45415
  for (const use of access.uses) {
45085
45416
  for (const spelled of expandBraces(use.path)) {
45086
45417
  const settled = settle(spelled, home);
45087
45418
  const unresolved = use.unresolved || "unresolved" in settled;
45088
45419
  const base3 = "path" in settled ? settled.path : spelled;
45089
45420
  const starts = [cwd];
45090
- const moved = use.directory !== void 0 && "relative" in use.directory ? resolve5(cwd, use.directory.relative) : void 0;
45421
+ const moved = use.directory !== void 0 && "relative" in use.directory ? resolve6(cwd, use.directory.relative) : void 0;
45091
45422
  if (moved !== void 0)
45092
45423
  starts.push(moved);
45093
- const absolutes = isAbsolute5(base3) ? [resolve5(base3)] : starts.map((from) => resolve5(from, base3));
45424
+ const absolutes = isAbsolute6(base3) ? [resolve6(base3)] : starts.map((from) => resolve6(from, base3));
45094
45425
  if (use.access === "write") {
45095
45426
  for (const candidate of absolutes) {
45096
45427
  if (await isProtectedWrite(spelled, candidate, context2.roots))
@@ -45104,12 +45435,12 @@ async function shellEscalations(line, dialect, context2) {
45104
45435
  outside.add(spelled);
45105
45436
  continue;
45106
45437
  }
45107
- if (use.directory !== void 0 && "unknown" in use.directory && use.access === "write" && !isAbsolute5(base3) && !spelled.startsWith("~")) {
45438
+ if (use.directory !== void 0 && "unknown" in use.directory && use.access === "write" && !isAbsolute6(base3) && !spelled.startsWith("~")) {
45108
45439
  outside.add(spelled);
45109
45440
  continue;
45110
45441
  }
45111
45442
  for (const candidate of absolutes) {
45112
- if (madeHere.some((link6) => candidate === link6 || candidate.startsWith(`${link6}${sep4}`))) {
45443
+ if (madeHere.some((link6) => candidate === link6 || candidate.startsWith(`${link6}${sep5}`))) {
45113
45444
  outside.add(candidate);
45114
45445
  continue;
45115
45446
  }
@@ -45563,7 +45894,8 @@ function createReviewHandler(options = {}) {
45563
45894
  answered = answer2;
45564
45895
  }
45565
45896
  const isPlanFileWrite = /* @__PURE__ */ __name((tc) => mode === "plan" && options.planModeWrite?.(tc) === true && tc.authorization?.decision !== "deny", "isPlanFileWrite");
45566
- const reviewable = request.toolCalls.filter((tc) => !(isPlanFileWrite(tc) && !tc.authorization?.explicitReview));
45897
+ const isScratchpadWrite = /* @__PURE__ */ __name((tc) => mode !== "strict" && tc.scratchpadWrite === true && tc.escalation === void 0 && tc.requiresApproval !== true && !tc.authorization?.explicitReview && tc.authorization?.decision !== "deny", "isScratchpadWrite");
45898
+ const reviewable = request.toolCalls.filter((tc) => !(isPlanFileWrite(tc) && !tc.authorization?.explicitReview) && !isScratchpadWrite(tc));
45567
45899
  if (!batchNeedsReview(reviewable, exempt)) {
45568
45900
  return { action: "approve_tools" };
45569
45901
  }
@@ -45574,7 +45906,7 @@ function createReviewHandler(options = {}) {
45574
45906
  )))).every(Boolean)) {
45575
45907
  return { action: "approve_tools" };
45576
45908
  }
45577
- if (mode === "plan" && !onlyReadsOutsideRoots(reviewable.filter((tc) => !isPlanFileWrite(tc)), exempt)) {
45909
+ if (mode === "plan" && !onlyReadsOutsideRoots(reviewable.filter((tc) => !isPlanFileWrite(tc) && !isScratchpadWrite(tc)), exempt)) {
45578
45910
  return { action: "reject_tools", feedback: PLAN_MODE_REFUSAL };
45579
45911
  }
45580
45912
  if (mode === "strict")
@@ -45795,8 +46127,8 @@ function createReviewPolicy(options = {}) {
45795
46127
  __name(createReviewPolicy, "createReviewPolicy");
45796
46128
 
45797
46129
  // ../sdk/dist/runtime/query/executor.js
45798
- import { createHash as createHash17 } from "node:crypto";
45799
- import { join as join18, resolve as resolve8 } from "node:path";
46130
+ import { createHash as createHash18 } from "node:crypto";
46131
+ import { isAbsolute as isAbsolute8, join as join18, resolve as resolve9 } from "node:path";
45800
46132
 
45801
46133
  // ../sdk/dist/probe/context.js
45802
46134
  function buildProbeContext(input = {}) {
@@ -46077,9 +46409,9 @@ function createProbeRegistry() {
46077
46409
  __name(createProbeRegistry, "createProbeRegistry");
46078
46410
 
46079
46411
  // ../sdk/dist/tools/builtins/content-fingerprint.js
46080
- import { createHash as createHash14 } from "node:crypto";
46412
+ import { createHash as createHash15 } from "node:crypto";
46081
46413
  function fingerprintContent(content) {
46082
- return createHash14("sha256").update(content, "utf-8").digest("hex").slice(0, 16);
46414
+ return createHash15("sha256").update(content, "utf-8").digest("hex").slice(0, 16);
46083
46415
  }
46084
46416
  __name(fingerprintContent, "fingerprintContent");
46085
46417
  function staleFileError(path3, operation = "edit") {
@@ -46220,21 +46552,21 @@ __name(createFileReadTracker, "createFileReadTracker");
46220
46552
 
46221
46553
  // ../sdk/dist/tools/retained-output.js
46222
46554
  import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
46223
- import { dirname as dirname10, extname, isAbsolute as isAbsolute6, relative as relative3, resolve as resolve6 } from "node:path";
46555
+ import { dirname as dirname10, extname, isAbsolute as isAbsolute7, relative as relative4, resolve as resolve7 } from "node:path";
46224
46556
  function inside(root, path3) {
46225
- const rel = relative3(root, path3);
46226
- return rel !== "" && !rel.startsWith("..") && !isAbsolute6(rel);
46557
+ const rel = relative4(root, path3);
46558
+ return rel !== "" && !rel.startsWith("..") && !isAbsolute7(rel);
46227
46559
  }
46228
46560
  __name(inside, "inside");
46229
46561
  async function resolveRetainedOutput(directory, candidate) {
46230
- if (!directory || !candidate || !isAbsolute6(candidate) || candidate.includes("\0"))
46562
+ if (!directory || !candidate || !isAbsolute7(candidate) || candidate.includes("\0"))
46231
46563
  return void 0;
46232
46564
  try {
46233
46565
  const base3 = await realpath3(directory);
46234
- const lexical = resolve6(candidate);
46566
+ const lexical = resolve7(candidate);
46235
46567
  if (extname(lexical).toLowerCase() !== ".txt")
46236
46568
  return void 0;
46237
- if (!inside(resolve6(directory), lexical) && !inside(base3, lexical))
46569
+ if (!inside(resolve7(directory), lexical) && !inside(base3, lexical))
46238
46570
  return void 0;
46239
46571
  const stat17 = await lstat2(lexical);
46240
46572
  if (stat17.isSymbolicLink() || !stat17.isFile() || stat17.nlink !== 1)
@@ -46773,8 +47105,7 @@ import { extname as extname2 } from "node:path";
46773
47105
 
46774
47106
  // ../sdk/dist/tools/builtins/read-media.js
46775
47107
  import { spawn } from "node:child_process";
46776
- import { mkdtemp, readdir as readdir3, rm as rm3 } from "node:fs/promises";
46777
- import { tmpdir as tmpdir3 } from "node:os";
47108
+ import { readdir as readdir3, rm as rm3 } from "node:fs/promises";
46778
47109
  import { join as join16 } from "node:path";
46779
47110
 
46780
47111
  // ../sdk/dist/tools/builtins/computer-use-image.js
@@ -46958,7 +47289,7 @@ async function cropAndFitPng(data, rect, limits) {
46958
47289
  __name(cropAndFitPng, "cropAndFitPng");
46959
47290
 
46960
47291
  // ../sdk/dist/tools/builtins/view-image.js
46961
- import { createHash as createHash15 } from "node:crypto";
47292
+ import { createHash as createHash16 } from "node:crypto";
46962
47293
  import { open as open8 } from "node:fs/promises";
46963
47294
  import { inflateSync } from "node:zlib";
46964
47295
 
@@ -47578,7 +47909,7 @@ ${validation === "container" ? "The complete container and dimensions were valid
47578
47909
  width: image.width,
47579
47910
  height: image.height,
47580
47911
  sourceBytes: artifact.bytes.length,
47581
- sha256: createHash15("sha256").update(artifact.bytes).digest("hex"),
47912
+ sha256: createHash16("sha256").update(artifact.bytes).digest("hex"),
47582
47913
  validation
47583
47914
  }
47584
47915
  };
@@ -47657,7 +47988,7 @@ function checkPageRange(value) {
47657
47988
  }
47658
47989
  __name(checkPageRange, "checkPageRange");
47659
47990
  function run(command, args, input, signal, timeoutMs) {
47660
- return new Promise((resolve34) => {
47991
+ return new Promise((resolve35) => {
47661
47992
  const child = spawn(command, [...args], { stdio: ["pipe", "pipe", "pipe"], signal });
47662
47993
  let stdout = "";
47663
47994
  let stderr = "";
@@ -47678,11 +48009,11 @@ function run(command, args, input, signal, timeoutMs) {
47678
48009
  child.on("error", (error) => {
47679
48010
  missing2 = error.code === "ENOENT";
47680
48011
  clearTimeout(timer);
47681
- resolve34({ code: null, stdout, stderr: stderr || error.message, missing: missing2, timedOut });
48012
+ resolve35({ code: null, stdout, stderr: stderr || error.message, missing: missing2, timedOut });
47682
48013
  });
47683
48014
  child.on("close", (code) => {
47684
48015
  clearTimeout(timer);
47685
- resolve34({ code, stdout, stderr, missing: missing2, timedOut });
48016
+ resolve35({ code, stdout, stderr, missing: missing2, timedOut });
47686
48017
  });
47687
48018
  child.stdin.on("error", () => {
47688
48019
  });
@@ -47785,7 +48116,7 @@ async function readPdfPages(bytes, pagesArgument, label6, signal) {
47785
48116
  }
47786
48117
  last = total === null ? PDF_WHOLE_READ_MAX_PAGES : total;
47787
48118
  }
47788
- const directory = await mkdtemp(join16(tmpdir3(), "namzu-pdf-"));
48119
+ const directory = await createTempDir("pdf-");
47789
48120
  try {
47790
48121
  const rendered = await renderPages(bytes, first, last, directory, signal);
47791
48122
  if (!rendered.ok)
@@ -48485,7 +48816,7 @@ function buildStructuredBinaryGuidance(path3, format, extractor) {
48485
48816
  __name(buildStructuredBinaryGuidance, "buildStructuredBinaryGuidance");
48486
48817
 
48487
48818
  // ../sdk/dist/runtime/query/file-evidence-replay.js
48488
- import { resolve as resolve7 } from "node:path";
48819
+ import { resolve as resolve8 } from "node:path";
48489
48820
 
48490
48821
  // ../sdk/dist/tools/builtins/edit-match.js
48491
48822
  var LEFT_SINGLE_QUOTE = "\u2018";
@@ -48963,8 +49294,8 @@ async function withFileMutationLock(key6, operation) {
48963
49294
  const previous = mutationTails.get(key6) ?? Promise.resolve();
48964
49295
  let release2 = /* @__PURE__ */ __name(() => {
48965
49296
  }, "release");
48966
- const current = new Promise((resolve34) => {
48967
- release2 = resolve34;
49297
+ const current = new Promise((resolve35) => {
49298
+ release2 = resolve35;
48968
49299
  });
48969
49300
  const tail = previous.then(() => current);
48970
49301
  mutationTails.set(key6, tail);
@@ -50145,7 +50476,7 @@ import { mkdir as mkdir9, readFile as readFile9 } from "node:fs/promises";
50145
50476
  import { dirname as dirname12 } from "node:path";
50146
50477
 
50147
50478
  // ../sdk/dist/tools/builtins/file-write-result.js
50148
- import { createHash as createHash16 } from "node:crypto";
50479
+ import { createHash as createHash17 } from "node:crypto";
50149
50480
  function previewSide(hunks2, changed) {
50150
50481
  return hunks2.flatMap((hunk) => hunk.lines).filter((row) => row.startsWith(" ") || row.startsWith(changed)).map((row) => `${row.slice(1)}
50151
50482
  `).join("");
@@ -50187,7 +50518,7 @@ function fileWriteResult(path3, before, after, sandboxed = false) {
50187
50518
  }
50188
50519
  },
50189
50520
  bytes,
50190
- sha256: createHash16("sha256").update(after, "utf8").digest("hex"),
50521
+ sha256: createHash17("sha256").update(after, "utf8").digest("hex"),
50191
50522
  ...before === null ? {} : { added: diff.added, removed: diff.removed, newlineChanged }
50192
50523
  }
50193
50524
  }
@@ -50392,7 +50723,7 @@ function parseArguments3(call2) {
50392
50723
  }
50393
50724
  __name(parseArguments3, "parseArguments");
50394
50725
  function lexicalFileKeys(workingDirectory, sandboxed) {
50395
- return (path3) => sandboxed ? path3 : resolve7(workingDirectory, path3);
50726
+ return (path3) => sandboxed ? path3 : resolve8(workingDirectory, path3);
50396
50727
  }
50397
50728
  __name(lexicalFileKeys, "lexicalFileKeys");
50398
50729
  function indexVisibleHistory(messages, keyOf) {
@@ -51113,8 +51444,8 @@ var ToolCallBudget = class {
51113
51444
  signal.throwIfAborted();
51114
51445
  const previous = this.chain;
51115
51446
  let release2;
51116
- this.chain = new Promise((resolve34) => {
51117
- release2 = resolve34;
51447
+ this.chain = new Promise((resolve35) => {
51448
+ release2 = resolve35;
51118
51449
  });
51119
51450
  try {
51120
51451
  await previous;
@@ -51355,6 +51686,67 @@ var ToolExecutor = class {
51355
51686
  await this.sandboxGate?.();
51356
51687
  }
51357
51688
  /** True once the turn has a sandbox, or is certain to get one before a tool runs. */
51689
+ /** The scratch folder, once a call has named it and it has been made and checked. */
51690
+ scratchpadReady;
51691
+ /** The tools' roots now: the turn's, plus the scratch folder once it is ready. */
51692
+ rootsNow() {
51693
+ return toolRoots({
51694
+ workingDirectory: this.config.workingDirectory,
51695
+ additionalDirectories: this.additionalDirectoriesNow()
51696
+ });
51697
+ }
51698
+ additionalDirectoriesNow() {
51699
+ if (this.scratchpadReady === void 0)
51700
+ return this.config.additionalDirectories;
51701
+ return [...this.config.additionalDirectories ?? [], this.scratchpadReady];
51702
+ }
51703
+ /**
51704
+ * Make the session's scratch folder a root when a call names it. Lazy: a
51705
+ * session that never uses it leaves nothing on disk. The folder must be
51706
+ * inside the private temporary root with no link on the way; otherwise it
51707
+ * stays outside the roots and a path in it is asked about like any other.
51708
+ */
51709
+ admitScratchpad(call2) {
51710
+ const directory = this.config.scratchpadDirectory;
51711
+ if (directory === void 0 || this.scratchpadReady !== void 0 || this.sandboxed)
51712
+ return;
51713
+ if (call2.kind === "synthetic")
51714
+ return;
51715
+ let named = false;
51716
+ try {
51717
+ named = JSON.stringify(call2.input)?.includes(JSON.stringify(directory).slice(1, -1)) === true;
51718
+ } catch {
51719
+ }
51720
+ if (!named)
51721
+ return;
51722
+ try {
51723
+ this.scratchpadReady = ensureScratchpadDirectory(directory);
51724
+ } catch (error) {
51725
+ this.log.warn("The session scratch folder could not be made, so it stays outside the roots", {
51726
+ "exception.message": error instanceof Error ? error.message : String(error)
51727
+ });
51728
+ }
51729
+ }
51730
+ /** Whether `call` writes a file inside the ready scratch folder and nothing else about it is notable. */
51731
+ async writesScratchpad(call2, escalation) {
51732
+ const root = this.scratchpadReady;
51733
+ if (root === void 0 || escalation !== void 0 || call2.kind === "synthetic")
51734
+ return false;
51735
+ if (call2.toolName !== "write" && call2.toolName !== "edit")
51736
+ return false;
51737
+ const tool = this.config.tools.get(call2.toolName);
51738
+ if (!tool?.pathArgument || call2.input === null || typeof call2.input !== "object")
51739
+ return false;
51740
+ const value = call2.input[tool.pathArgument];
51741
+ if (typeof value !== "string" || !isAbsolute8(value))
51742
+ return false;
51743
+ try {
51744
+ await resolveWithinAnyReal([root], value);
51745
+ return true;
51746
+ } catch {
51747
+ return false;
51748
+ }
51749
+ }
51358
51750
  get sandboxed() {
51359
51751
  return this.config.sandbox !== void 0 || this.sandboxGate !== void 0;
51360
51752
  }
@@ -51364,7 +51756,7 @@ var ToolExecutor = class {
51364
51756
  return recorded !== void 0 && message.toolCallId === call2.id && !message.isError && typeof message.content === "string" && this.config.tools.get(recorded.toolName) === recorded.definition && recorded.fingerprint === this.observationFingerprint(call2, message.content) ? recorded.inputFingerprint : void 0;
51365
51757
  }
51366
51758
  observationFingerprint(call2, content) {
51367
- return createHash17("sha256").update(JSON.stringify([call2.function.name, call2.function.arguments, content])).digest("hex");
51759
+ return createHash18("sha256").update(JSON.stringify([call2.function.name, call2.function.arguments, content])).digest("hex");
51368
51760
  }
51369
51761
  recordExecutedObservation(call2, toolName, definition, input, content) {
51370
51762
  if (typeof content !== "string" || this.config.tools.get(toolName) !== definition)
@@ -51376,7 +51768,7 @@ var ToolExecutor = class {
51376
51768
  toolName,
51377
51769
  definition,
51378
51770
  fingerprint: this.observationFingerprint(call2, content),
51379
- inputFingerprint: createHash17("sha256").update(JSON.stringify([toolName, input])).digest("hex")
51771
+ inputFingerprint: createHash18("sha256").update(JSON.stringify([toolName, input])).digest("hex")
51380
51772
  });
51381
51773
  } catch {
51382
51774
  }
@@ -51605,6 +51997,7 @@ var ToolExecutor = class {
51605
51997
  await this.awaitSandbox();
51606
51998
  const calls = /* @__PURE__ */ new Map();
51607
51999
  const escalations = /* @__PURE__ */ new Map();
52000
+ const scratchpadWrites = /* @__PURE__ */ new Set();
51608
52001
  const earlierPaths = [];
51609
52002
  for (const toolCall of response.message.toolCalls ?? []) {
51610
52003
  const prepared = await prepareDirectCall(this.admissionHost(), toolCall, !hostModifiedCallIds?.has(toolCall.id));
@@ -51613,12 +52006,15 @@ var ToolExecutor = class {
51613
52006
  if (path3 !== void 0)
51614
52007
  earlierPaths.push(path3);
51615
52008
  calls.set(toolCall.id, call2);
52009
+ this.admitScratchpad(call2);
51616
52010
  const escalation = await this.escalationOrUnfinished(call2);
51617
52011
  if (escalation)
51618
52012
  escalations.set(toolCall.id, escalation);
52013
+ if (await this.writesScratchpad(call2, escalation))
52014
+ scratchpadWrites.add(toolCall.id);
51619
52015
  }
51620
52016
  this.config.abortSignal.throwIfAborted();
51621
- return this.publishPreparedBatch(calls, escalations);
52017
+ return this.publishPreparedBatch(calls, escalations, scratchpadWrites);
51622
52018
  }
51623
52019
  /**
51624
52020
  * A ready call the tool already knows cannot run, answered now instead of
@@ -51636,8 +52032,8 @@ var ToolExecutor = class {
51636
52032
  return call2;
51637
52033
  const path3 = inputPathOf(call2);
51638
52034
  if (path3 !== void 0) {
51639
- const target = resolve8(this.config.workingDirectory, path3);
51640
- if (earlierPaths.some((p) => resolve8(this.config.workingDirectory, p) === target))
52035
+ const target = resolve9(this.config.workingDirectory, path3);
52036
+ if (earlierPaths.some((p) => resolve9(this.config.workingDirectory, p) === target))
51641
52037
  return call2;
51642
52038
  }
51643
52039
  try {
@@ -51705,7 +52101,7 @@ var ToolExecutor = class {
51705
52101
  const value = input[tool.pathArgument];
51706
52102
  if (typeof value === "string") {
51707
52103
  const retained = tool.name === "read" && await resolveRetainedOutput(this.outputDirectory(), value);
51708
- const outside = retained ? void 0 : await pathOutsideRoots(toolRoots(this.config), value);
52104
+ const outside = retained ? void 0 : await pathOutsideRoots(this.rootsNow(), value);
51709
52105
  if (outside !== void 0)
51710
52106
  outsidePaths = [outside];
51711
52107
  }
@@ -51740,7 +52136,7 @@ var ToolExecutor = class {
51740
52136
  * file tools' own does.
51741
52137
  */
51742
52138
  async pathEscalationsOf(tool, input, sandboxed, shellCwd) {
51743
- const roots = toolRoots(this.config);
52139
+ const roots = this.rootsNow();
51744
52140
  const protectedPaths = [];
51745
52141
  let outsidePaths = [];
51746
52142
  let removal;
@@ -51799,16 +52195,22 @@ var ToolExecutor = class {
51799
52195
  }
51800
52196
  const calls = new Map(previous.calls);
51801
52197
  const escalations = new Map(previous.escalations);
52198
+ const scratchpadWrites = new Set(previous.scratchpadWrites);
51802
52199
  const earlierPaths = [];
51803
52200
  for (const toolCall of response.message.toolCalls ?? []) {
51804
52201
  if (changedCallIds.has(toolCall.id)) {
51805
52202
  const call2 = await this.refusedBeforeReview(await prepareDirectCall(this.admissionHost(), toolCall, false), earlierPaths);
51806
52203
  calls.set(toolCall.id, call2);
52204
+ this.admitScratchpad(call2);
51807
52205
  const escalation = await this.escalationOrUnfinished(call2);
51808
52206
  if (escalation)
51809
52207
  escalations.set(toolCall.id, escalation);
51810
52208
  else
51811
52209
  escalations.delete(toolCall.id);
52210
+ if (await this.writesScratchpad(call2, escalation))
52211
+ scratchpadWrites.add(toolCall.id);
52212
+ else
52213
+ scratchpadWrites.delete(toolCall.id);
51812
52214
  }
51813
52215
  const prepared = calls.get(toolCall.id);
51814
52216
  const path3 = prepared ? inputPathOf(prepared) : void 0;
@@ -51816,9 +52218,9 @@ var ToolExecutor = class {
51816
52218
  earlierPaths.push(path3);
51817
52219
  }
51818
52220
  this.config.abortSignal.throwIfAborted();
51819
- return this.publishPreparedBatch(calls, escalations);
52221
+ return this.publishPreparedBatch(calls, escalations, scratchpadWrites);
51820
52222
  }
51821
- publishPreparedBatch(calls, escalations) {
52223
+ publishPreparedBatch(calls, escalations, scratchpadWrites) {
51822
52224
  const reviewCalls = [...calls.values()].filter((call2) => call2.kind !== "synthetic").map((call2) => {
51823
52225
  const escalation = escalations.get(call2.toolCall.id);
51824
52226
  const hookPermission = call2.hook?.permission;
@@ -51827,13 +52229,15 @@ var ToolExecutor = class {
51827
52229
  name: call2.toolName,
51828
52230
  input: call2.input,
51829
52231
  ...escalation ? { escalation } : {},
51830
- ...hookPermission ? { hookPermission } : {}
52232
+ ...hookPermission ? { hookPermission } : {},
52233
+ ...scratchpadWrites.has(call2.toolCall.id) ? { scratchpadWrite: true } : {}
51831
52234
  };
51832
52235
  });
51833
52236
  const batch = Object.freeze({
51834
52237
  reviewCalls: Object.freeze(reviewCalls),
51835
52238
  calls: new Map(calls),
51836
- escalations: new Map(escalations)
52239
+ escalations: new Map(escalations),
52240
+ scratchpadWrites: new Set(scratchpadWrites)
51837
52241
  });
51838
52242
  this.preparedBatches.add(batch);
51839
52243
  return batch;
@@ -52113,7 +52517,7 @@ var ToolExecutor = class {
52113
52517
  let failure2;
52114
52518
  const settledUnits = /* @__PURE__ */ new Map();
52115
52519
  const refusedAfterEnd = "An earlier call in this batch was refused and the turn was stopped, so this call was not run.";
52116
- await new Promise((resolve34) => {
52520
+ await new Promise((resolve35) => {
52117
52521
  const start = /* @__PURE__ */ __name((unit) => {
52118
52522
  inFlight.add(unit);
52119
52523
  let settledUnit;
@@ -52161,7 +52565,7 @@ var ToolExecutor = class {
52161
52565
  start(unit);
52162
52566
  }
52163
52567
  if (cursor >= units.length && inFlight.size === 0)
52164
- resolve34();
52568
+ resolve35();
52165
52569
  }, "pump");
52166
52570
  review.ended.addEventListener("abort", pump, { once: true });
52167
52571
  pump();
@@ -52293,6 +52697,7 @@ var ToolExecutor = class {
52293
52697
  } catch {
52294
52698
  needsApproval = true;
52295
52699
  }
52700
+ this.admitScratchpad(preparedCall);
52296
52701
  const nestedEscalation = await this.escalationOrUnfinished(preparedCall);
52297
52702
  if (nestedEscalation || needsApproval || gateResult && gateResult.decision !== "allow") {
52298
52703
  const reason2 = nestedEscalation ? "Blocked: this nested call reaches a protected path, removal floor, outside-root boundary or another safety escalation. Call it directly so it can be reviewed." : needsApproval ? `Blocked: "${name2}" requires the person's approval for every call, and an approval cannot be requested from inside another tool. Call it directly.` : gateResult?.decision === "deny" ? `Blocked by the authorization gate: ${gateResult.reason}` : `Blocked by the authorization gate: this nested call requires an explicit allow rule because an operator review cannot be opened from inside another tool. ${gateResult?.reason}`;
@@ -52476,7 +52881,7 @@ var ToolExecutor = class {
52476
52881
  sessionId: this.config.sessionId,
52477
52882
  turnId: this.config.turnId,
52478
52883
  workingDirectory: this.config.workingDirectory,
52479
- ...this.config.additionalDirectories?.length ? { additionalDirectories: this.config.additionalDirectories } : {},
52884
+ ...this.additionalDirectoriesNow()?.length ? { additionalDirectories: this.additionalDirectoriesNow() } : {},
52480
52885
  ...this.config.authorizationGate ? {
52481
52886
  readDenied: /* @__PURE__ */ __name((absolutePath) => this.evaluatePreparedAuthorization("read", { path: absolutePath })?.decision === "deny", "readDenied")
52482
52887
  } : {},
@@ -52927,21 +53332,21 @@ ${note}`;
52927
53332
  let invocationOpen = true;
52928
53333
  const nestedDispatches = /* @__PURE__ */ new Set();
52929
53334
  try {
52930
- const expired = Number.isFinite(timeoutMs) && timeoutMs > 0 ? new Promise((resolve34) => {
53335
+ const expired = Number.isFinite(timeoutMs) && timeoutMs > 0 ? new Promise((resolve35) => {
52931
53336
  timer = setTimeout(() => {
52932
53337
  timedOut = true;
52933
53338
  controller.abort(new Error(`Tool "${toolName}" exceeded ${timeoutMs}ms`));
52934
- resolve34("timeout");
53339
+ resolve35("timeout");
52935
53340
  }, timeoutMs);
52936
53341
  }) : void 0;
52937
- const aborted = new Promise((resolve34) => {
53342
+ const aborted = new Promise((resolve35) => {
52938
53343
  if (controller.signal.aborted && !timedOut) {
52939
- resolve34("aborted");
53344
+ resolve35("aborted");
52940
53345
  return;
52941
53346
  }
52942
53347
  controller.signal.addEventListener("abort", () => {
52943
53348
  if (!timedOut)
52944
- resolve34("aborted");
53349
+ resolve35("aborted");
52945
53350
  }, { once: true });
52946
53351
  });
52947
53352
  const inheritedDispatch = toolContext.dispatchTool;
@@ -53490,8 +53895,8 @@ var Semaphore = class {
53490
53895
  this.available--;
53491
53896
  return Promise.resolve();
53492
53897
  }
53493
- return new Promise((resolve34) => {
53494
- this.waiters.push(resolve34);
53898
+ return new Promise((resolve35) => {
53899
+ this.waiters.push(resolve35);
53495
53900
  });
53496
53901
  }
53497
53902
  release() {
@@ -54363,8 +54768,8 @@ var PerCallReview = class {
54363
54768
  async admit(call2) {
54364
54769
  const before = this.#line;
54365
54770
  let leave;
54366
- this.#line = new Promise((resolve34) => {
54367
- leave = resolve34;
54771
+ this.#line = new Promise((resolve35) => {
54772
+ leave = resolve35;
54368
54773
  });
54369
54774
  try {
54370
54775
  const verdict = await this.#decide(call2, before, leave);
@@ -54714,7 +55119,7 @@ function watchForOperator(ctx, startedAt) {
54714
55119
  return void 0;
54715
55120
  const watching = new AbortController();
54716
55121
  let timer;
54717
- const requested = new Promise((resolve34) => {
55122
+ const requested = new Promise((resolve35) => {
54718
55123
  const settled = Promise.race(wakes.map((wake) => {
54719
55124
  try {
54720
55125
  return wake(watching.signal);
@@ -54728,7 +55133,7 @@ function watchForOperator(ctx, startedAt) {
54728
55133
  if (watching.signal.aborted)
54729
55134
  return;
54730
55135
  const wait = Math.max(0, startedAt + DETACH_AFTER_MS - Date.now());
54731
- timer = setTimeout(resolve34, wait);
55136
+ timer = setTimeout(resolve35, wait);
54732
55137
  },
54733
55138
  // An aborted wait is the batch ending, which is not a message.
54734
55139
  () => {
@@ -54807,7 +55212,9 @@ async function* runToolReview(ctx, response, iterationNum) {
54807
55212
  } : { decision: "review" },
54808
55213
  ...requiresApproval2 ? { requiresApproval: true } : {},
54809
55214
  ...escalation ? { escalation } : {},
54810
- ...hookPermission ? { hookPermission } : {}
55215
+ ...hookPermission ? { hookPermission } : {},
55216
+ ..."scratchpadWrite" in tc && tc.scratchpadWrite ? { scratchpadWrite: true } : {},
55217
+ ..."scratchpadWrite" in tc && tc.scratchpadWrite ? { scratchpadWrite: true } : {}
54811
55218
  };
54812
55219
  });
54813
55220
  }, "summariesFor");
@@ -54984,8 +55391,8 @@ async function* runToolReview(ctx, response, iterationNum) {
54984
55391
  }
54985
55392
  const wakeup = /* @__PURE__ */ __name(() => {
54986
55393
  let notify;
54987
- const promise = new Promise((resolve34) => {
54988
- notify = resolve34;
55394
+ const promise = new Promise((resolve35) => {
55395
+ notify = resolve35;
54989
55396
  });
54990
55397
  return { promise, notify };
54991
55398
  }, "wakeup");
@@ -55737,7 +56144,7 @@ function appendRecordedContext(recorder, items, log, at = /* @__PURE__ */ new Da
55737
56144
  __name(appendRecordedContext, "appendRecordedContext");
55738
56145
 
55739
56146
  // ../sdk/dist/runtime/query/iteration/request-repair.js
55740
- import { createHash as createHash18 } from "node:crypto";
56147
+ import { createHash as createHash19 } from "node:crypto";
55741
56148
  var MAX_REPAIRS_PER_REQUEST = 5;
55742
56149
  var MAX_STRIPS_PER_INDEX = 3;
55743
56150
  var GENERIC_MEDIA_LIMITS = [510, 255, 127];
@@ -55850,7 +56257,7 @@ function isAccepted(chunk) {
55850
56257
  return Boolean(chunk.delta.content || chunk.delta.toolCalls?.length || chunk.delta.toolCallEnd || chunk.delta.reasoning || chunk.delta.citation || chunk.finishReason !== void 0 || chunk.usage !== void 0 || chunk.replayState !== void 0 || chunk.textParts !== void 0);
55851
56258
  }
55852
56259
  __name(isAccepted, "isAccepted");
55853
- var mediaFingerprint = /* @__PURE__ */ __name((data, mediaType) => createHash18("sha256").update(mediaType).update("\0").update(data).digest("hex"), "mediaFingerprint");
56260
+ var mediaFingerprint = /* @__PURE__ */ __name((data, mediaType) => createHash19("sha256").update(mediaType).update("\0").update(data).digest("hex"), "mediaFingerprint");
55854
56261
  var FAULT_NOTE = "the provider could not process it. The file may be unsupported or corrupt; do not retry reading it. If you need to inspect it, use a shell command instead.";
55855
56262
  var LIMIT_NOTE = "this conversation holds more files than the provider accepts at once, so the oldest are left out of the request. They are still in the conversation.";
55856
56263
  var removedNote = /* @__PURE__ */ __name((kind, limit) => `[${kind} removed: ${limit ? LIMIT_NOTE : FAULT_NOTE}]`, "removedNote");
@@ -57829,7 +58236,7 @@ var IterationOrchestrator = class {
57829
58236
  requestHistory.push(workingMemory.context);
57830
58237
  if (policyNotice)
57831
58238
  requestHistory.push(stepContextMessage(policyNotice));
57832
- const projected = projectRequestRichContent(this.projectObservations(requestHistory), this.ctx.turnConfig.maxRequestRichContentBytes ?? DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES, { imagesReadable: this.modelReadsImages(stepModel) });
58239
+ const projected = projectRequestRichContent(withoutVoidAssistantTurns(this.projectObservations(requestHistory)), this.ctx.turnConfig.maxRequestRichContentBytes ?? DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES, { imagesReadable: this.modelReadsImages(stepModel) });
57833
58240
  const messages = [...projected];
57834
58241
  const work = workContext(shaping, projected, iterationNum, step);
57835
58242
  const recordedNow = appendRecordedContext(recorder, work.recorded, this.ctx.log);
@@ -59255,7 +59662,7 @@ ${feedback}`, "hook-feedback"));
59255
59662
  ...workingMemory.history,
59256
59663
  ...workingMemory.context ? [workingMemory.context] : []
59257
59664
  ];
59258
- const finalMessages = projectRequestRichContent(this.projectObservations(finalHistory), this.ctx.turnConfig.maxRequestRichContentBytes ?? DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES, { imagesReadable: this.modelReadsImages(model) });
59665
+ const finalMessages = projectRequestRichContent(withoutVoidAssistantTurns(this.projectObservations(finalHistory)), this.ctx.turnConfig.maxRequestRichContentBytes ?? DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES, { imagesReadable: this.modelReadsImages(model) });
59259
59666
  finalMessages.push(createRuntimeContextMessage(`[SYSTEM] Turn is ending due to ${reason2}. ${CLOSING_RESPONSE_GUIDANCE}`, "limit-finalization"));
59260
59667
  await this.reportUnsupportedToolResults(finalMessages);
59261
59668
  const finalTools = this.ctx.tools.toLLMTools(this.ctx.allowedTools);
@@ -59914,7 +60321,7 @@ async function awaitStoreRead(signal, start) {
59914
60321
  if (!signal)
59915
60322
  return await start();
59916
60323
  signal.throwIfAborted();
59917
- return new Promise((resolve34, reject2) => {
60324
+ return new Promise((resolve35, reject2) => {
59918
60325
  let settled = false;
59919
60326
  const cleanup = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "cleanup");
59920
60327
  const rejectOnce = /* @__PURE__ */ __name((reason2) => {
@@ -59929,7 +60336,7 @@ async function awaitStoreRead(signal, start) {
59929
60336
  return;
59930
60337
  settled = true;
59931
60338
  cleanup();
59932
- resolve34(value);
60339
+ resolve35(value);
59933
60340
  }, "resolveOnce");
59934
60341
  const onAbort = /* @__PURE__ */ __name(() => rejectOnce(signal.reason), "onAbort");
59935
60342
  signal.addEventListener("abort", onAbort, { once: true });
@@ -60529,10 +60936,10 @@ var TurnContextFactory = class _TurnContextFactory {
60529
60936
 
60530
60937
  // ../sdk/dist/store/evidence/disk.js
60531
60938
  import { lstat as lstat4 } from "node:fs/promises";
60532
- import { resolve as resolve9 } from "node:path";
60939
+ import { resolve as resolve10 } from "node:path";
60533
60940
 
60534
60941
  // ../sdk/dist/store/evidence/index-page.js
60535
- import { createHash as createHash19, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
60942
+ import { createHash as createHash20, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
60536
60943
 
60537
60944
  // ../sdk/dist/store/evidence/compaction-provenance.js
60538
60945
  function record(value) {
@@ -60647,7 +61054,7 @@ var positionSchema = external_exports.object({
60647
61054
  textIndex: integer2.default(0)
60648
61055
  });
60649
61056
  function evidenceSeal(sessionStart, sourceKey) {
60650
- const key6 = createHash19("sha256").update("namzu-session-evidence-v1\n").update(sessionStart).digest();
61057
+ const key6 = createHash20("sha256").update("namzu-session-evidence-v1\n").update(sessionStart).digest();
60651
61058
  const mac = /* @__PURE__ */ __name((value) => createHmac2("sha256", key6).update(`${sourceKey}
60652
61059
  ${value}`).digest(), "mac");
60653
61060
  return {
@@ -61224,7 +61631,7 @@ function createSource(options, mode, anchor) {
61224
61631
  const consistency = external_exports.enum(["closed", "snapshot"]).parse(options.consistency ?? "closed");
61225
61632
  const maxReadBytes = external_exports.number().int().min(1024 * 1024).max(PAGE_BYTES).parse(options.maxReadBytes ?? PAGE_BYTES);
61226
61633
  const scope = Object.freeze(scopeSchema.parse(options.scope));
61227
- const logPath = resolve9(options.logPath);
61634
+ const logPath = resolve10(options.logPath);
61228
61635
  if (!logPath.endsWith(".jsonl"))
61229
61636
  throw new Error("A session log path ends in .jsonl.");
61230
61637
  const sessionDir = logPath.slice(0, -".jsonl".length);
@@ -61507,14 +61914,27 @@ var EventTranslator = class {
61507
61914
  this.recorder = recorder;
61508
61915
  this.probes = probeRegistry;
61509
61916
  this.log = resolveLogger(log).child({ [SCOPE_ATTRIBUTE]: "runtime/query/events" });
61917
+ recorder.onLogWriteHealth((change) => {
61918
+ void this.emitEvent(change.state === "degraded" ? {
61919
+ type: "session_log_degraded",
61920
+ cause: change.cause,
61921
+ bufferedRecords: change.bufferedRecords,
61922
+ bufferedBytes: change.bufferedBytes,
61923
+ ...change.dropping ? { dropping: true } : {}
61924
+ } : {
61925
+ type: "session_log_recovered",
61926
+ flushedRecords: change.flushedRecords,
61927
+ droppedRecords: change.droppedRecords
61928
+ });
61929
+ });
61510
61930
  }
61511
61931
  /** Serializes appends and reads against each other. */
61512
61932
  appendChain = Promise.resolve();
61513
61933
  async withLogLock(operation) {
61514
61934
  const previous = this.appendChain;
61515
61935
  let release2;
61516
- this.appendChain = new Promise((resolve34) => {
61517
- release2 = resolve34;
61936
+ this.appendChain = new Promise((resolve35) => {
61937
+ release2 = resolve35;
61518
61938
  });
61519
61939
  try {
61520
61940
  await previous;
@@ -61874,12 +62294,12 @@ var PreludeSessionLease = class _PreludeSessionLease {
61874
62294
 
61875
62295
  // ../sdk/dist/runtime/query/session-storage.js
61876
62296
  import { readdir as readdir5, realpath as realpath5 } from "node:fs/promises";
61877
- import { basename as basename7, dirname as dirname15, join as join21, resolve as resolve11 } from "node:path";
62297
+ import { basename as basename7, dirname as dirname15, join as join21, resolve as resolve12 } from "node:path";
61878
62298
 
61879
62299
  // ../sdk/dist/session/home.js
61880
62300
  import { lstatSync as lstatSync2, realpathSync as realpathSync2 } from "node:fs";
61881
62301
  import { homedir as homedir3 } from "node:os";
61882
- import { parse as parse2, resolve as resolve10 } from "node:path";
62302
+ import { parse as parse2, resolve as resolve11 } from "node:path";
61883
62303
  var NamzuHomeError = class extends Error {
61884
62304
  static {
61885
62305
  __name(this, "NamzuHomeError");
@@ -61890,7 +62310,7 @@ function resolveNamzuHome(options = {}) {
61890
62310
  const env = options.env ?? process.env;
61891
62311
  const configured = env.NAMZU_HOME;
61892
62312
  if (configured === void 0 || configured.length === 0) {
61893
- return resolve10(options.home ?? homedir3(), ".namzu");
62313
+ return resolve11(options.home ?? homedir3(), ".namzu");
61894
62314
  }
61895
62315
  if (configured.includes("\0")) {
61896
62316
  throw new NamzuHomeError("NAMZU_HOME contains a NUL byte and cannot name a directory.");
@@ -62778,7 +63198,7 @@ var InMemorySessionTokenBudgetStore = class {
62778
63198
  };
62779
63199
 
62780
63200
  // ../sdk/dist/store/checkpoint/contract.js
62781
- import { createHash as createHash20 } from "node:crypto";
63201
+ import { createHash as createHash21 } from "node:crypto";
62782
63202
  var CheckpointIntegrityError = class extends Error {
62783
63203
  static {
62784
63204
  __name(this, "CheckpointIntegrityError");
@@ -62812,10 +63232,10 @@ function serializeCheckpoint(checkpoint) {
62812
63232
  `;
62813
63233
  }
62814
63234
  __name(serializeCheckpoint, "serializeCheckpoint");
62815
- function sha256Hex4(text10) {
62816
- return createHash20("sha256").update(text10, "utf8").digest("hex");
63235
+ function sha256Hex5(text10) {
63236
+ return createHash21("sha256").update(text10, "utf8").digest("hex");
62817
63237
  }
62818
- __name(sha256Hex4, "sha256Hex");
63238
+ __name(sha256Hex5, "sha256Hex");
62819
63239
  function checkpointRecordPath(checkpointId4) {
62820
63240
  return `checkpoints/${asCheckpointId(checkpointId4)}.json`;
62821
63241
  }
@@ -62849,7 +63269,7 @@ function writeReceipt(checkpoint, text10) {
62849
63269
  throughSeq: checkpoint.throughSeq,
62850
63270
  throughSha256: checkpoint.throughSha256,
62851
63271
  path: checkpointRecordPath(checkpoint.checkpointId),
62852
- docSha256: sha256Hex4(text10)
63272
+ docSha256: sha256Hex5(text10)
62853
63273
  };
62854
63274
  }
62855
63275
  __name(writeReceipt, "writeReceipt");
@@ -62857,7 +63277,7 @@ async function verifyCheckpoint(log, scope, checkpoint, text10) {
62857
63277
  const recorded = await log.writtenDocSha256(scope, checkpoint.checkpointId);
62858
63278
  if (recorded === null)
62859
63279
  throw new CheckpointIntegrityError(checkpoint.checkpointId, "not-recorded");
62860
- if (recorded !== sha256Hex4(text10)) {
63280
+ if (recorded !== sha256Hex5(text10)) {
62861
63281
  throw new CheckpointIntegrityError(checkpoint.checkpointId, "document-mismatch");
62862
63282
  }
62863
63283
  if (!await log.verifyThrough(scope, checkpoint.throughSeq, checkpoint.throughSha256)) {
@@ -63141,7 +63561,7 @@ async function placeInLayout(paths2, log) {
63141
63561
  }
63142
63562
  __name(placeInLayout, "placeInLayout");
63143
63563
  async function canonicalPath(path3) {
63144
- let existing = resolve11(path3);
63564
+ let existing = resolve12(path3);
63145
63565
  let remainder = "";
63146
63566
  for (; ; ) {
63147
63567
  const found = await realpath5(existing).catch(() => void 0);
@@ -63149,7 +63569,7 @@ async function canonicalPath(path3) {
63149
63569
  return remainder ? join21(found, remainder) : found;
63150
63570
  const parent = dirname15(existing);
63151
63571
  if (parent === existing)
63152
- return resolve11(path3);
63572
+ return resolve12(path3);
63153
63573
  remainder = remainder ? join21(basename7(existing), remainder) : basename7(existing);
63154
63574
  existing = parent;
63155
63575
  }
@@ -63360,8 +63780,8 @@ async function resolveProviderContextWindow(provider, model, signal, timeoutMs,
63360
63780
  const resolverSignal = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
63361
63781
  const interrupted = /* @__PURE__ */ Symbol("provider-context-window-interrupted");
63362
63782
  let onAbort;
63363
- const interruption = new Promise((resolve34) => {
63364
- onAbort = /* @__PURE__ */ __name(() => resolve34(interrupted), "onAbort");
63783
+ const interruption = new Promise((resolve35) => {
63784
+ onAbort = /* @__PURE__ */ __name(() => resolve35(interrupted), "onAbort");
63365
63785
  resolverSignal.addEventListener("abort", onAbort, { once: true });
63366
63786
  });
63367
63787
  const deadlineMs = timeoutMs === 0 ? 5e3 : Math.min(Math.max(0, timeoutMs), 2147483647);
@@ -64212,6 +64632,7 @@ var ToolingBootstrap = class {
64212
64632
  turnId: config.turnId,
64213
64633
  workingDirectory: config.workingDirectory,
64214
64634
  ...config.additionalDirectories?.length ? { additionalDirectories: config.additionalDirectories } : {},
64635
+ ...config.scratchpadDirectory ? { scratchpadDirectory: config.scratchpadDirectory } : {},
64215
64636
  ...config.outsideRootAccess ? { outsideRootAccess: config.outsideRootAccess } : {},
64216
64637
  ...config.sandboxEscape ? { sandboxEscape: config.sandboxEscape } : {},
64217
64638
  permissionMode: config.permissionMode,
@@ -64519,6 +64940,14 @@ async function* query(params) {
64519
64940
  }
64520
64941
  }, "collectJob");
64521
64942
  const skillGrants = new SkillGrantSet();
64943
+ let scratchpadDirectory;
64944
+ if (!params.sandboxProvider) {
64945
+ try {
64946
+ scratchpadDirectory = ctx.storage.paths?.scratchpadPath(ctx.sessionId);
64947
+ } catch {
64948
+ scratchpadDirectory = void 0;
64949
+ }
64950
+ }
64522
64951
  const toolExecutor = ToolingBootstrap.init({
64523
64952
  skillGrants,
64524
64953
  tools: toolManager,
@@ -64527,6 +64956,7 @@ async function* query(params) {
64527
64956
  turnId: ctx.turnId,
64528
64957
  workingDirectory: ctx.cwd,
64529
64958
  ...params.additionalDirectories?.length ? { additionalDirectories: params.additionalDirectories } : {},
64959
+ ...scratchpadDirectory ? { scratchpadDirectory } : {},
64530
64960
  ...params.outsideRootAccess ? { outsideRootAccess: params.outsideRootAccess } : {},
64531
64961
  ...params.sandboxEscape ? { sandboxEscape: params.sandboxEscape } : {},
64532
64962
  permissionMode: /* @__PURE__ */ __name(() => ctx.permissionMode.current, "permissionMode"),
@@ -65544,8 +65974,8 @@ function createMockBidiProvider(script = {}) {
65544
65974
  }
65545
65975
  if (done)
65546
65976
  return;
65547
- await new Promise((resolve34) => {
65548
- wake = resolve34;
65977
+ await new Promise((resolve35) => {
65978
+ wake = resolve35;
65549
65979
  });
65550
65980
  wake = void 0;
65551
65981
  }
@@ -65813,8 +66243,8 @@ async function startBidiTurn(params) {
65813
66243
  }
65814
66244
  if (closed)
65815
66245
  return;
65816
- await new Promise((resolve34) => {
65817
- wake = resolve34;
66246
+ await new Promise((resolve35) => {
66247
+ wake = resolve35;
65818
66248
  });
65819
66249
  wake = void 0;
65820
66250
  }
@@ -65837,7 +66267,7 @@ async function startBidiTurn(params) {
65837
66267
  __name(startBidiTurn, "startBidiTurn");
65838
66268
 
65839
66269
  // ../sdk/dist/runtime/query/prompt-cache.js
65840
- import { createHash as createHash21 } from "node:crypto";
66270
+ import { createHash as createHash22 } from "node:crypto";
65841
66271
  var PromptCache = class {
65842
66272
  static {
65843
66273
  __name(this, "PromptCache");
@@ -65912,7 +66342,7 @@ var PromptCache = class {
65912
66342
  this.cachedStaticHash = void 0;
65913
66343
  }
65914
66344
  computeStaticHash(staticSegment) {
65915
- return createHash21("sha256").update(staticSegment).digest("hex").slice(0, 16);
66345
+ return createHash22("sha256").update(staticSegment).digest("hex").slice(0, 16);
65916
66346
  }
65917
66347
  computeConfigHash(input, prompt) {
65918
66348
  const parts = [
@@ -65922,7 +66352,7 @@ var PromptCache = class {
65922
66352
  // unsegmented text happens to be identical.
65923
66353
  input.contributions?.list().map((c) => [c.id, c.placement]) ?? []
65924
66354
  ];
65925
- return createHash21("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 16);
66355
+ return createHash22("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 16);
65926
66356
  }
65927
66357
  };
65928
66358
 
@@ -68815,6 +69245,8 @@ function createTurnReporter(parentLogger) {
68815
69245
  case "tool_calls_admitted":
68816
69246
  case "compaction_shed":
68817
69247
  case "compaction_started":
69248
+ case "session_log_degraded":
69249
+ case "session_log_recovered":
68818
69250
  break;
68819
69251
  default: {
68820
69252
  const _exhaustive = event;
@@ -68845,10 +69277,10 @@ __name(createTurnReporter, "createTurnReporter");
68845
69277
 
68846
69278
  // ../sdk/dist/turn/drain.js
68847
69279
  var DEFAULT_DRAIN_PAGE_SIZE = 100;
68848
- function refuse(code, message, details) {
69280
+ function refuse2(code, message, details) {
68849
69281
  throw new NamzuError({ code, message, details });
68850
69282
  }
68851
- __name(refuse, "refuse");
69283
+ __name(refuse2, "refuse");
68852
69284
  function toMessage(err) {
68853
69285
  return err instanceof Error ? err.message : String(err);
68854
69286
  }
@@ -68895,14 +69327,14 @@ __name(describeTurn, "describeTurn");
68895
69327
  async function drainParkedTurns(params) {
68896
69328
  const { index, tenantId: tenantId2, holder, ttlMs, onTurn, park, signal } = params;
68897
69329
  if (holder.trim().length === 0) {
68898
- refuse("invalid_config", "drainParkedTurns: `holder` is empty. Use something per-process \u2014 a worker id, a pod name plus a pid.", { holder });
69330
+ refuse2("invalid_config", "drainParkedTurns: `holder` is empty. Use something per-process \u2014 a worker id, a pod name plus a pid.", { holder });
68899
69331
  }
68900
69332
  if (!Number.isFinite(ttlMs) || ttlMs <= 0) {
68901
- refuse("invalid_config", `drainParkedTurns: ttlMs must be a positive number of milliseconds, got ${String(ttlMs)}. A lease that expires immediately is a lease every worker can take at once.`, { ttlMs });
69333
+ refuse2("invalid_config", `drainParkedTurns: ttlMs must be a positive number of milliseconds, got ${String(ttlMs)}. A lease that expires immediately is a lease every worker can take at once.`, { ttlMs });
68902
69334
  }
68903
69335
  const maxConcurrent = params.maxConcurrent ?? 1;
68904
69336
  if (!Number.isInteger(maxConcurrent) || maxConcurrent < 1) {
68905
- refuse("invalid_config", `drainParkedTurns: maxConcurrent must be a positive integer, got ${String(params.maxConcurrent)}.`, { maxConcurrent: params.maxConcurrent });
69337
+ refuse2("invalid_config", `drainParkedTurns: maxConcurrent must be a positive integer, got ${String(params.maxConcurrent)}.`, { maxConcurrent: params.maxConcurrent });
68906
69338
  }
68907
69339
  const pageSize = params.pageSize ?? DEFAULT_DRAIN_PAGE_SIZE;
68908
69340
  const openLog = params.openLog ?? ((sessionId5, logPath) => new DiskSessionLog({ sessionId: sessionId5, file: logPath, sessionDir: logPath.replace(/\.jsonl$/, "") }));
@@ -68987,7 +69419,7 @@ __name(drainParkedTurns, "drainParkedTurns");
68987
69419
  // ../sdk/dist/execution/local.js
68988
69420
  import { spawn as spawn2 } from "node:child_process";
68989
69421
  import { existsSync as existsSync4 } from "node:fs";
68990
- import { resolve as resolve12 } from "node:path";
69422
+ import { resolve as resolve13 } from "node:path";
68991
69423
 
68992
69424
  // ../sdk/dist/execution/base.js
68993
69425
  var InitializationSupersededError = class extends Error {
@@ -69278,7 +69710,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
69278
69710
  constructor(options) {
69279
69711
  super(options.log);
69280
69712
  this.id = options.id;
69281
- this.cwd = resolve12(options.cwd);
69713
+ this.cwd = resolve13(options.cwd);
69282
69714
  this.fsAccess = options.fsAccess ?? true;
69283
69715
  this.envVars = options.envVars ?? {};
69284
69716
  this.capabilities = options.capabilities ?? ["filesystem", "process", "shell"];
@@ -69314,7 +69746,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
69314
69746
  return this.cwd;
69315
69747
  }
69316
69748
  setCwd(newCwd) {
69317
- const resolved2 = resolve12(newCwd);
69749
+ const resolved2 = resolve13(newCwd);
69318
69750
  if (!existsSync4(resolved2)) {
69319
69751
  throw new Error(`Working directory does not exist: ${resolved2}`);
69320
69752
  }
@@ -69324,7 +69756,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
69324
69756
  return this.fsAccess;
69325
69757
  }
69326
69758
  resolvePath(relativePath) {
69327
- return resolve12(this.cwd, relativePath);
69759
+ return resolve13(this.cwd, relativePath);
69328
69760
  }
69329
69761
  getEnvVar(key6) {
69330
69762
  return this.envVars[key6] ?? process.env[key6];
@@ -69352,7 +69784,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
69352
69784
  durationMs: 0
69353
69785
  };
69354
69786
  }
69355
- const cwd = options?.cwd ? resolve12(this.cwd, options.cwd) : this.cwd;
69787
+ const cwd = options?.cwd ? resolve13(this.cwd, options.cwd) : this.cwd;
69356
69788
  const env = { ...process.env, ...this.envVars, ...options?.env };
69357
69789
  const timeoutMs = options?.timeoutMs ?? LOCAL_COMMAND_DEFAULT_TIMEOUT_MS;
69358
69790
  if (!Number.isInteger(timeoutMs) || timeoutMs < 0) {
@@ -69482,7 +69914,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
69482
69914
  };
69483
69915
 
69484
69916
  // ../sdk/dist/turn/workspace-fingerprint.js
69485
- import { createHash as createHash22 } from "node:crypto";
69917
+ import { createHash as createHash23 } from "node:crypto";
69486
69918
  import { lstat as lstat5, readFile as readFile12, readlink } from "node:fs/promises";
69487
69919
  import { join as join25 } from "node:path";
69488
69920
  var NODE_FS = { lstat: lstat5, readlink, readFile: readFile12 };
@@ -69498,7 +69930,7 @@ async function untrackedEntry(cwd, rel, fs) {
69498
69930
  if (!stats.isFile())
69499
69931
  return `? ${rel}`;
69500
69932
  const body = await fs.readFile(abs);
69501
- return `F ${rel}\0${createHash22("sha256").update(body).digest("hex")}`;
69933
+ return `F ${rel}\0${createHash23("sha256").update(body).digest("hex")}`;
69502
69934
  } catch {
69503
69935
  return null;
69504
69936
  }
@@ -69543,7 +69975,7 @@ async function fingerprintWorkspace(options) {
69543
69975
  return null;
69544
69976
  parts.push(entry);
69545
69977
  }
69546
- const hash2 = createHash22("sha256");
69978
+ const hash2 = createHash23("sha256");
69547
69979
  for (const part2 of parts)
69548
69980
  hash2.update(`${Buffer.byteLength(part2, "utf8")}:${part2}`);
69549
69981
  return hash2.digest("hex");
@@ -69873,7 +70305,7 @@ var InMemoryMemoryIndex = class {
69873
70305
  };
69874
70306
 
69875
70307
  // ../sdk/dist/store/memory/naming.js
69876
- import { sep as sep5 } from "node:path";
70308
+ import { sep as sep6 } from "node:path";
69877
70309
 
69878
70310
  // ../sdk/dist/types/memory/index.js
69879
70311
  function assertMemoryStatus(status) {
@@ -70040,7 +70472,7 @@ function withOptionalFields(entry, fields2) {
70040
70472
  }
70041
70473
  __name(withOptionalFields, "withOptionalFields");
70042
70474
  function entryPath(dir, stem, extension) {
70043
- return dir + sep5 + stem + extension;
70475
+ return dir + sep6 + stem + extension;
70044
70476
  }
70045
70477
  __name(entryPath, "entryPath");
70046
70478
 
@@ -70315,7 +70747,7 @@ function createMemoryRecallStep(options) {
70315
70747
  __name(createMemoryRecallStep, "createMemoryRecallStep");
70316
70748
 
70317
70749
  // ../sdk/dist/turn/json-claim-verifier.js
70318
- import { createHash as createHash23, randomUUID as randomUUID5 } from "node:crypto";
70750
+ import { createHash as createHash24, randomUUID as randomUUID5 } from "node:crypto";
70319
70751
  import { performance as performance2 } from "node:perf_hooks";
70320
70752
  function scalar(value) {
70321
70753
  return value === null || typeof value === "boolean" || typeof value === "string" && value.length <= 2e3 || typeof value === "number" && Number.isSafeInteger(value);
@@ -70448,7 +70880,7 @@ function createJsonClaimVerifier(options) {
70448
70880
  requestId: request.requestId,
70449
70881
  observedAt: observation.observedAt,
70450
70882
  bytes: bytes.byteLength,
70451
- sha256: createHash23("sha256").update(bytes).digest("hex")
70883
+ sha256: createHash24("sha256").update(bytes).digest("hex")
70452
70884
  });
70453
70885
  }
70454
70886
  ensureActive();
@@ -71898,7 +72330,7 @@ import { pathToFileURL } from "node:url";
71898
72330
 
71899
72331
  // ../sdk/dist/directory/scan.js
71900
72332
  import { lstat as lstat6, readdir as readdir9, realpath as realpath6 } from "node:fs/promises";
71901
- import { basename as basename10, extname as extname3, join as join28, relative as relative4, sep as sep6 } from "node:path";
72333
+ import { basename as basename10, extname as extname3, join as join28, relative as relative5, sep as sep7 } from "node:path";
71902
72334
  var CODE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"]);
71903
72335
  async function scanSlot(root, slot, dirName) {
71904
72336
  const dir = join28(root, dirName);
@@ -71963,7 +72395,7 @@ async function scanSlot(root, slot, dirName) {
71963
72395
  }
71964
72396
  let contained2;
71965
72397
  try {
71966
- contained2 = await resolveWithinReal(root, relative4(root, candidate));
72398
+ contained2 = await resolveWithinReal(root, relative5(root, candidate));
71967
72399
  } catch {
71968
72400
  diagnostics.push({
71969
72401
  code: "path_escapes_root",
@@ -72007,8 +72439,8 @@ var ALL_SLOTS = [
72007
72439
  var DEFAULT_MODULE_TIMEOUT_MS = 1e4;
72008
72440
  async function importWithDeadline(fileUrl, importModule, timeoutMs) {
72009
72441
  let timer;
72010
- const deadline = new Promise((resolve34) => {
72011
- timer = setTimeout(() => resolve34({ status: "abandoned" }), timeoutMs);
72442
+ const deadline = new Promise((resolve35) => {
72443
+ timer = setTimeout(() => resolve35({ status: "abandoned" }), timeoutMs);
72012
72444
  });
72013
72445
  try {
72014
72446
  const result = await Promise.race([
@@ -72462,7 +72894,7 @@ async function resolveForRun(entry, context2) {
72462
72894
  if (!context2.signal)
72463
72895
  return await entry.forRun(context2);
72464
72896
  const signal = context2.signal;
72465
- return await new Promise((resolve34, reject2) => {
72897
+ return await new Promise((resolve35, reject2) => {
72466
72898
  const onAbort = /* @__PURE__ */ __name(() => {
72467
72899
  signal.removeEventListener("abort", onAbort);
72468
72900
  reject2(signal.reason);
@@ -72472,7 +72904,7 @@ async function resolveForRun(entry, context2) {
72472
72904
  onAbort();
72473
72905
  return;
72474
72906
  }
72475
- Promise.resolve().then(() => entry.forRun(context2)).then(resolve34, reject2).finally(() => signal.removeEventListener("abort", onAbort));
72907
+ Promise.resolve().then(() => entry.forRun(context2)).then(resolve35, reject2).finally(() => signal.removeEventListener("abort", onAbort));
72476
72908
  });
72477
72909
  }
72478
72910
  __name(resolveForRun, "resolveForRun");
@@ -75086,15 +75518,15 @@ var DiskTaskStore = class {
75086
75518
  break;
75087
75519
  await existing.catch(() => void 0);
75088
75520
  }
75089
- let resolve34;
75521
+ let resolve35;
75090
75522
  const lock = new Promise((r) => {
75091
- resolve34 = r;
75523
+ resolve35 = r;
75092
75524
  });
75093
75525
  this.locks.set(taskId, lock);
75094
75526
  try {
75095
75527
  return await fn();
75096
75528
  } finally {
75097
- resolve34?.();
75529
+ resolve35?.();
75098
75530
  if (this.locks.get(taskId) === lock) {
75099
75531
  this.locks.delete(taskId);
75100
75532
  }
@@ -75413,7 +75845,7 @@ var DiskTaskStore = class {
75413
75845
  };
75414
75846
 
75415
75847
  // ../sdk/dist/store/memory/revision.js
75416
- import { createHash as createHash24 } from "node:crypto";
75848
+ import { createHash as createHash25 } from "node:crypto";
75417
75849
  var MemoryRevisionUnavailableError = class extends Error {
75418
75850
  static {
75419
75851
  __name(this, "MemoryRevisionUnavailableError");
@@ -75519,7 +75951,7 @@ function canonicalRecord(record3) {
75519
75951
  }
75520
75952
  __name(canonicalRecord, "canonicalRecord");
75521
75953
  function memoryRevision(record3) {
75522
- return `m2:${createHash24("sha256").update(canonicalRecord(record3)).digest("hex")}`;
75954
+ return `m2:${createHash25("sha256").update(canonicalRecord(record3)).digest("hex")}`;
75523
75955
  }
75524
75956
  __name(memoryRevision, "memoryRevision");
75525
75957
  var MemoryRevisionConflictError = class extends NamzuError {
@@ -75671,7 +76103,7 @@ var InMemoryMemoryStore = class {
75671
76103
 
75672
76104
  // ../sdk/dist/store/memory/disk.js
75673
76105
  import { mkdir as mkdir14, realpath as realpath7, unlink as unlink11 } from "node:fs/promises";
75674
- import { dirname as dirname17, join as join31, resolve as resolve13 } from "node:path";
76106
+ import { dirname as dirname17, join as join31, resolve as resolve14 } from "node:path";
75675
76107
 
75676
76108
  // ../sdk/dist/store/memory/operation-lock.js
75677
76109
  import { randomUUID as randomUUID6 } from "node:crypto";
@@ -75924,9 +76356,9 @@ function invalidContent(id3, reason2, details = {}) {
75924
76356
  });
75925
76357
  }
75926
76358
  __name(invalidContent, "invalidContent");
75927
- function assertStorageMemoryId(value, refuse4) {
76359
+ function assertStorageMemoryId(value, refuse5) {
75928
76360
  if (!isEntityId(value, "memory")) {
75929
- refuse4("id must be a UUID; prefixed memory IDs are not supported");
76361
+ refuse5("id must be a UUID; prefixed memory IDs are not supported");
75930
76362
  }
75931
76363
  }
75932
76364
  __name(assertStorageMemoryId, "assertStorageMemoryId");
@@ -76020,7 +76452,7 @@ var DiskMemoryStore = class {
76020
76452
  records = new DiskRecordStore(SCHEMA6);
76021
76453
  indexRecords = new DiskRecordStore(SCHEMA6);
76022
76454
  constructor(config) {
76023
- this.baseDir = config.directory === void 0 ? join31(config.baseDir, "memory") : resolve13(config.directory);
76455
+ this.baseDir = config.directory === void 0 ? join31(config.baseDir, "memory") : resolve14(config.directory);
76024
76456
  this.log = resolveLogger(config.logger).child({ [SCOPE_ATTRIBUTE]: "store/memory/disk" });
76025
76457
  this.lockTimeoutMs = config.lockTimeoutMs ?? DEFAULT_MEMORY_LOCK_TIMEOUT_MS;
76026
76458
  validateMemoryLockTimeout(this.lockTimeoutMs);
@@ -76047,7 +76479,7 @@ var DiskMemoryStore = class {
76047
76479
  }
76048
76480
  contentPath(location, id3) {
76049
76481
  assertStorageMemoryId(id3, (reason2) => invalidContent(id3, reason2, { field: "id" }));
76050
- const path3 = resolve13(entryPath(location.contentDir, id3, ".json"));
76482
+ const path3 = resolve14(entryPath(location.contentDir, id3, ".json"));
76051
76483
  if (dirname17(path3) !== location.contentDir) {
76052
76484
  invalidContent(id3, "resolved path escapes the content directory", { field: "id" });
76053
76485
  }
@@ -76279,9 +76711,9 @@ var DiskMemoryStore = class {
76279
76711
  };
76280
76712
 
76281
76713
  // ../sdk/dist/store/memory/markdown.js
76282
- import { createHash as createHash25 } from "node:crypto";
76714
+ import { createHash as createHash26 } from "node:crypto";
76283
76715
  import { lstat as lstat8, mkdir as mkdir15, readFile as readFile17, readdir as readdir11, realpath as realpath8, rename as rename6, unlink as unlink12 } from "node:fs/promises";
76284
- import { dirname as dirname18, join as join32, resolve as resolve14 } from "node:path";
76716
+ import { dirname as dirname18, join as join32, resolve as resolve15 } from "node:path";
76285
76717
 
76286
76718
  // ../sdk/dist/store/memory/index-file.js
76287
76719
  var MEMORY_INDEX_MAX_LINES = 200;
@@ -76519,7 +76951,7 @@ function invalidFile(file, reason2, cause) {
76519
76951
  }
76520
76952
  __name(invalidFile, "invalidFile");
76521
76953
  function derivedMemoryId(name2) {
76522
- const hex2 = createHash25("sha256").update(`namzu-memory-name:${name2}`).digest("hex");
76954
+ const hex2 = createHash26("sha256").update(`namzu-memory-name:${name2}`).digest("hex");
76523
76955
  const variant = (Number.parseInt(hex2[16] ?? "0", 16) & 3 | 8).toString(16);
76524
76956
  return `${hex2.slice(0, 8)}-${hex2.slice(8, 12)}-8${hex2.slice(13, 16)}-${variant}${hex2.slice(17, 20)}-${hex2.slice(20, 32)}`;
76525
76957
  }
@@ -76639,7 +77071,7 @@ var MarkdownMemoryStore = class {
76639
77071
  lockTimeoutMs;
76640
77072
  canonical;
76641
77073
  constructor(config) {
76642
- this.directory = resolve14(config.directory);
77074
+ this.directory = resolve15(config.directory);
76643
77075
  this.log = resolveLogger(config.logger).child({
76644
77076
  [SCOPE_ATTRIBUTE]: "store/memory/markdown"
76645
77077
  });
@@ -76660,7 +77092,7 @@ var MarkdownMemoryStore = class {
76660
77092
  memoryPath(dir, name2) {
76661
77093
  if (!isMemoryName(name2))
76662
77094
  invalidFile(join32(dir, `${name2}.md`), "name is not a memory name");
76663
- const path3 = resolve14(entryPath(dir, name2, ".md"));
77095
+ const path3 = resolve15(entryPath(dir, name2, ".md"));
76664
77096
  if (dirname18(path3) !== dir)
76665
77097
  invalidFile(path3, "resolved path escapes the memory directory");
76666
77098
  return path3;
@@ -77843,7 +78275,7 @@ var PluginRegistry = class extends ManagedRegistry {
77843
78275
  // ../sdk/dist/plugin/loader.js
77844
78276
  import { lstat as lstat9, readFile as readFile18, readdir as readdir12, realpath as realpath9 } from "node:fs/promises";
77845
78277
  import { homedir as homedir4, platform } from "node:os";
77846
- import { join as join34, resolve as resolve15 } from "node:path";
78278
+ import { join as join34, resolve as resolve16 } from "node:path";
77847
78279
 
77848
78280
  // ../sdk/dist/types/plugin/index.js
77849
78281
  function assertPluginScope(scope) {
@@ -78229,7 +78661,7 @@ async function samePhysicalDirectory(left, right) {
78229
78661
  try {
78230
78662
  value = await realpath9(path3);
78231
78663
  } catch {
78232
- value = resolve15(path3);
78664
+ value = resolve16(path3);
78233
78665
  }
78234
78666
  return platform() === "win32" ? value.toLocaleLowerCase("en-US") : value;
78235
78667
  }, "canonical");
@@ -78462,10 +78894,10 @@ function describeType(declared) {
78462
78894
  return `a \`${declared}\` parameter`;
78463
78895
  }
78464
78896
  __name(describeType, "describeType");
78465
- function refuse2(reason2) {
78897
+ function refuse3(reason2) {
78466
78898
  return { ok: false, reason: reason2 };
78467
78899
  }
78468
- __name(refuse2, "refuse");
78900
+ __name(refuse3, "refuse");
78469
78901
  function validateMcpHeaderAnnotations(inputSchema22) {
78470
78902
  if (!isPlainObject4(inputSchema22))
78471
78903
  return NO_BINDINGS;
@@ -78478,28 +78910,28 @@ function validateMcpHeaderAnnotations(inputSchema22) {
78478
78910
  const at = `at ${annotation.where}`;
78479
78911
  const name2 = annotation.value;
78480
78912
  if (typeof name2 !== "string") {
78481
- return refuse2(`\`x-mcp-header\` ${at} is ${quoted(name2)}, which is not a string`);
78913
+ return refuse3(`\`x-mcp-header\` ${at} is ${quoted(name2)}, which is not a string`);
78482
78914
  }
78483
78915
  if (name2.length === 0) {
78484
- return refuse2(`\`x-mcp-header\` ${at} is empty`);
78916
+ return refuse3(`\`x-mcp-header\` ${at} is empty`);
78485
78917
  }
78486
78918
  if (/[\r\n]/.test(name2)) {
78487
- return refuse2(`\`x-mcp-header\` ${quoted(name2)} ${at} contains a carriage return or line feed`);
78919
+ return refuse3(`\`x-mcp-header\` ${quoted(name2)} ${at} contains a carriage return or line feed`);
78488
78920
  }
78489
78921
  if (!FIELD_NAME_TOKEN.test(name2)) {
78490
- return refuse2(`\`x-mcp-header\` ${quoted(name2)} ${at} is not HTTP field-name token syntax (RFC 9110 1*tchar)`);
78922
+ return refuse3(`\`x-mcp-header\` ${quoted(name2)} ${at} is not HTTP field-name token syntax (RFC 9110 1*tchar)`);
78491
78923
  }
78492
78924
  const first = claimed.get(name2.toLowerCase());
78493
78925
  if (first !== void 0) {
78494
- return refuse2(`\`x-mcp-header\` ${quoted(name2)} ${at} repeats ${quoted(first)}; header names are compared without regard to case`);
78926
+ return refuse3(`\`x-mcp-header\` ${quoted(name2)} ${at} repeats ${quoted(first)}; header names are compared without regard to case`);
78495
78927
  }
78496
78928
  claimed.set(name2.toLowerCase(), name2);
78497
78929
  if (annotation.path === void 0) {
78498
- return refuse2(`\`x-mcp-header\` ${quoted(name2)} ${at} is not statically reachable: the chain from the schema root must consist solely of \`properties\` keys`);
78930
+ return refuse3(`\`x-mcp-header\` ${quoted(name2)} ${at} is not statically reachable: the chain from the schema root must consist solely of \`properties\` keys`);
78499
78931
  }
78500
78932
  const declared = annotation.declaredType;
78501
78933
  if (typeof declared !== "string" || !MIRRORABLE_TYPES.has(declared)) {
78502
- return refuse2(`\`x-mcp-header\` ${quoted(name2)} ${at} annotates ${describeType(declared)}; only \`string\`, \`boolean\` and \`integer\` may be mirrored, and \`number\` is excluded`);
78934
+ return refuse3(`\`x-mcp-header\` ${quoted(name2)} ${at} annotates ${describeType(declared)}; only \`string\`, \`boolean\` and \`integer\` may be mirrored, and \`number\` is excluded`);
78503
78935
  }
78504
78936
  bindings.push({
78505
78937
  header: `${MCP_PARAM_HEADER_PREFIX}${name2}`,
@@ -79219,7 +79651,7 @@ var StdioTransport = class {
79219
79651
  this.exitPending = false;
79220
79652
  return;
79221
79653
  }
79222
- await new Promise((resolve34) => {
79654
+ await new Promise((resolve35) => {
79223
79655
  let settled = false;
79224
79656
  const finish2 = /* @__PURE__ */ __name(() => {
79225
79657
  if (settled)
@@ -79227,7 +79659,7 @@ var StdioTransport = class {
79227
79659
  settled = true;
79228
79660
  clearTimeout(escalate);
79229
79661
  clearTimeout(giveUp);
79230
- resolve34();
79662
+ resolve35();
79231
79663
  }, "finish");
79232
79664
  child.once("close", finish2);
79233
79665
  child.once("error", finish2);
@@ -80183,7 +80615,7 @@ var MCPClient = class {
80183
80615
  capabilities: this.config.capabilities ?? {}
80184
80616
  });
80185
80617
  const controller = new AbortController();
80186
- return new Promise((resolve34) => {
80618
+ return new Promise((resolve35) => {
80187
80619
  let settled = false;
80188
80620
  const finish2 = /* @__PURE__ */ __name((answer) => {
80189
80621
  if (settled)
@@ -80192,7 +80624,7 @@ var MCPClient = class {
80192
80624
  clearTimeout(timer);
80193
80625
  if (this.pendingRequests.get(id3) === entry)
80194
80626
  this.pendingRequests.delete(id3);
80195
- resolve34(answer);
80627
+ resolve35(answer);
80196
80628
  }, "finish");
80197
80629
  const entry = {
80198
80630
  resolve: /* @__PURE__ */ __name((value) => finish2({ kind: "result", result: value }), "resolve"),
@@ -80766,8 +81198,8 @@ var MCPClient = class {
80766
81198
  let settled = false;
80767
81199
  let resolvePublic;
80768
81200
  let rejectPublic;
80769
- const result = new Promise((resolve34, reject2) => {
80770
- resolvePublic = resolve34;
81201
+ const result = new Promise((resolve35, reject2) => {
81202
+ resolvePublic = resolve35;
80771
81203
  rejectPublic = reject2;
80772
81204
  });
80773
81205
  const entry = {
@@ -81972,7 +82404,7 @@ function toolResultToMCPToolResult(result) {
81972
82404
  __name(toolResultToMCPToolResult, "toolResultToMCPToolResult");
81973
82405
 
81974
82406
  // ../sdk/dist/connector/mcp/policy.js
81975
- import { createHash as createHash26 } from "node:crypto";
82407
+ import { createHash as createHash27 } from "node:crypto";
81976
82408
  function applyToolPolicy(tools, policy) {
81977
82409
  return applyNamePolicy(tools, policy);
81978
82410
  }
@@ -82012,7 +82444,7 @@ function toolsHash(tools) {
82012
82444
  // fingerprint built to catch exactly that rug-pull saw nothing.
82013
82445
  annotations: stableStringify2(tool.annotations)
82014
82446
  }));
82015
- return createHash26("sha256").update(JSON.stringify(canonical3)).digest("hex");
82447
+ return createHash27("sha256").update(JSON.stringify(canonical3)).digest("hex");
82016
82448
  }
82017
82449
  __name(toolsHash, "toolsHash");
82018
82450
  function diffTools(before, after) {
@@ -82235,7 +82667,7 @@ var MCPToolDiscovery = class {
82235
82667
  };
82236
82668
 
82237
82669
  // ../sdk/dist/connector/mcp/mcp-toolset.js
82238
- import { createHash as createHash27 } from "node:crypto";
82670
+ import { createHash as createHash28 } from "node:crypto";
82239
82671
 
82240
82672
  // ../sdk/dist/connector/mcp/prompt-adapter.js
82241
82673
  function renderPromptMessages(serverName, promptName, messages, description) {
@@ -82306,7 +82738,7 @@ function mcpToolsetName(serverName, ...segments) {
82306
82738
  const full = ["mcp", serverName, ...segments].join("__");
82307
82739
  if (full.length <= MCP_TOOLSET_NAME_MAX_LENGTH)
82308
82740
  return full;
82309
- const hash2 = createHash27("sha256").update(full).digest("hex").slice(0, 8);
82741
+ const hash2 = createHash28("sha256").update(full).digest("hex").slice(0, 8);
82310
82742
  const suffix = `_${hash2}`;
82311
82743
  return `${full.slice(0, MCP_TOOLSET_NAME_MAX_LENGTH - suffix.length)}${suffix}`;
82312
82744
  }
@@ -83561,21 +83993,21 @@ function guardedLookup(hostname, options, callback) {
83561
83993
  }
83562
83994
  __name(guardedLookup, "guardedLookup");
83563
83995
  function postHookJson(input) {
83564
- return new Promise((resolve34) => {
83996
+ return new Promise((resolve35) => {
83565
83997
  let url;
83566
83998
  try {
83567
83999
  url = new URL(input.url);
83568
84000
  } catch {
83569
- resolve34({ status: null, body: "", timedOut: false, error: "the url is not valid" });
84001
+ resolve35({ status: null, body: "", timedOut: false, error: "the url is not valid" });
83570
84002
  return;
83571
84003
  }
83572
84004
  if (url.protocol !== "http:" && url.protocol !== "https:") {
83573
- resolve34({ status: null, body: "", timedOut: false, error: "the url must be http or https" });
84005
+ resolve35({ status: null, body: "", timedOut: false, error: "the url must be http or https" });
83574
84006
  return;
83575
84007
  }
83576
84008
  const literal = url.hostname.replace(/^\[|\]$/g, "");
83577
84009
  if (isIP3(literal) !== 0 && !isReachableHookAddress(literal)) {
83578
- resolve34({
84010
+ resolve35({
83579
84011
  status: null,
83580
84012
  body: "",
83581
84013
  timedOut: false,
@@ -83600,7 +84032,7 @@ function postHookJson(input) {
83600
84032
  settled = true;
83601
84033
  clearTimeout(timer);
83602
84034
  input.signal?.removeEventListener("abort", onAbort);
83603
- resolve34(response);
84035
+ resolve35(response);
83604
84036
  }, "finish");
83605
84037
  const onAbort = /* @__PURE__ */ __name(() => {
83606
84038
  req.destroy();
@@ -83747,7 +84179,7 @@ function runShellHook(entry, input, signal) {
83747
84179
  const payload = shellHookPayload(input);
83748
84180
  const toolPath = pathOf(input.toolInput);
83749
84181
  const { NAMZU_TURN_ID: _inheritedTurnId, ...inherited } = process.env;
83750
- return new Promise((resolve34) => {
84182
+ return new Promise((resolve35) => {
83751
84183
  let child;
83752
84184
  try {
83753
84185
  const env = {
@@ -83778,7 +84210,7 @@ function runShellHook(entry, input, signal) {
83778
84210
  ...process.platform === "win32" ? {} : { shell: { path: "sh", dialect: "sh", source: "sh" } }
83779
84211
  });
83780
84212
  } catch (error) {
83781
- resolve34({
84213
+ resolve35({
83782
84214
  exitCode: null,
83783
84215
  timedOut: false,
83784
84216
  stdout: "",
@@ -83804,7 +84236,7 @@ function runShellHook(entry, input, signal) {
83804
84236
  settled = true;
83805
84237
  clearTimeout(timer);
83806
84238
  signal?.removeEventListener("abort", onAbort);
83807
- resolve34(outcome);
84239
+ resolve35(outcome);
83808
84240
  }, "finish");
83809
84241
  const killTree2 = /* @__PURE__ */ __name(() => {
83810
84242
  if (child.pid !== void 0 && process.platform !== "win32") {
@@ -84200,8 +84632,8 @@ ${json2}`;
84200
84632
  const combined = signal ? AbortSignal.any([signal, deadline]) : deadline;
84201
84633
  let reply;
84202
84634
  try {
84203
- reply = await new Promise((resolve34, reject2) => {
84204
- const stop = /* @__PURE__ */ __name(() => resolve34(void 0), "stop");
84635
+ reply = await new Promise((resolve35, reject2) => {
84636
+ const stop = /* @__PURE__ */ __name(() => resolve35(void 0), "stop");
84205
84637
  combined.addEventListener("abort", stop, { once: true });
84206
84638
  judge({
84207
84639
  instruction: PROMPT_HOOK_INSTRUCTION,
@@ -84209,7 +84641,7 @@ ${json2}`;
84209
84641
  sessionId: input.sessionId,
84210
84642
  ...input.turnId !== void 0 ? { turnId: input.turnId } : {},
84211
84643
  signal: combined
84212
- }).then(resolve34, reject2);
84644
+ }).then(resolve35, reject2);
84213
84645
  });
84214
84646
  } catch (error) {
84215
84647
  log.warn("prompt hook failed", {
@@ -84431,8 +84863,8 @@ async function settleWithSignal(operation, signal, acceptAfterAbort) {
84431
84863
  return operation;
84432
84864
  const settled = operation.then((value) => ({ kind: "fulfilled", value }), (reason2) => ({ kind: "rejected", reason: reason2 }));
84433
84865
  let onAbort;
84434
- const aborted = new Promise((resolve34) => {
84435
- onAbort = /* @__PURE__ */ __name(() => resolve34({ kind: "aborted" }), "onAbort");
84866
+ const aborted = new Promise((resolve35) => {
84867
+ onAbort = /* @__PURE__ */ __name(() => resolve35({ kind: "aborted" }), "onAbort");
84436
84868
  if (signal.aborted) {
84437
84869
  onAbort();
84438
84870
  return;
@@ -84451,8 +84883,8 @@ async function settleWithSignal(operation, signal, acceptAfterAbort) {
84451
84883
  let timer;
84452
84884
  const grace = await Promise.race([
84453
84885
  settled,
84454
- new Promise((resolve34) => {
84455
- timer = setTimeout(() => resolve34({ kind: "grace_elapsed" }), 0);
84886
+ new Promise((resolve35) => {
84887
+ timer = setTimeout(() => resolve35({ kind: "grace_elapsed" }), 0);
84456
84888
  })
84457
84889
  ]).finally(() => {
84458
84890
  if (timer !== void 0)
@@ -85799,7 +86231,7 @@ __name(summarizeBlocking, "summarizeBlocking");
85799
86231
 
85800
86232
  // ../sdk/dist/manager/agent/lifecycle.js
85801
86233
  import { realpath as realpath10, rm as rm5, stat as stat11 } from "node:fs/promises";
85802
- import { isAbsolute as isAbsolute7, relative as relative5, resolve as resolve16, sep as sep7 } from "node:path";
86234
+ import { isAbsolute as isAbsolute9, relative as relative6, resolve as resolve17, sep as sep8 } from "node:path";
85803
86235
 
85804
86236
  // ../sdk/dist/session/handoff/capacity.js
85805
86237
  var DelegationCapacityExceeded = class extends Error {
@@ -85972,14 +86404,14 @@ function mergeEnv(base3, override) {
85972
86404
  __name(mergeEnv, "mergeEnv");
85973
86405
  async function requireIsolatedWorktreePath(ref, callerCwd, subdirectory) {
85974
86406
  const meta = ref?.meta;
85975
- if (typeof ref?.id !== "string" || ref.id.length === 0 || meta?.backend !== "git-worktree" || typeof meta.repoRoot !== "string" || !isAbsolute7(meta.repoRoot) || typeof meta.branch !== "string" || meta.branch.length === 0 || typeof meta.worktreePath !== "string" || !isAbsolute7(meta.worktreePath) || resolve16(meta.worktreePath) === resolve16(callerCwd ?? process.cwd())) {
86407
+ if (typeof ref?.id !== "string" || ref.id.length === 0 || meta?.backend !== "git-worktree" || typeof meta.repoRoot !== "string" || !isAbsolute9(meta.repoRoot) || typeof meta.branch !== "string" || meta.branch.length === 0 || typeof meta.worktreePath !== "string" || !isAbsolute9(meta.worktreePath) || resolve17(meta.worktreePath) === resolve17(callerCwd ?? process.cwd())) {
85976
86408
  throw new Error("Isolated git-worktree driver returned an invalid workspace ref or path");
85977
86409
  }
85978
86410
  let physicalPaths;
85979
86411
  try {
85980
86412
  physicalPaths = await Promise.all([
85981
86413
  realpath10(meta.worktreePath),
85982
- realpath10(resolve16(callerCwd ?? process.cwd()))
86414
+ realpath10(resolve17(callerCwd ?? process.cwd()))
85983
86415
  ]);
85984
86416
  if (!(await stat11(physicalPaths[0])).isDirectory()) {
85985
86417
  throw new Error("The worktree path is not a directory");
@@ -85994,12 +86426,12 @@ async function requireIsolatedWorktreePath(ref, callerCwd, subdirectory) {
85994
86426
  }
85995
86427
  if (subdirectory === void 0)
85996
86428
  return meta.worktreePath;
85997
- if (typeof subdirectory !== "string" || subdirectory.length === 0 || isAbsolute7(subdirectory)) {
86429
+ if (typeof subdirectory !== "string" || subdirectory.length === 0 || isAbsolute9(subdirectory)) {
85998
86430
  throw new Error("Isolated workspace subdirectory must be a nonempty relative path");
85999
86431
  }
86000
- const lexicalChild = resolve16(meta.worktreePath, subdirectory);
86001
- const lexicalRelative = relative5(resolve16(meta.worktreePath), lexicalChild);
86002
- if (isAbsolute7(lexicalRelative) || lexicalRelative === ".." || lexicalRelative.startsWith(`..${sep7}`)) {
86432
+ const lexicalChild = resolve17(meta.worktreePath, subdirectory);
86433
+ const lexicalRelative = relative6(resolve17(meta.worktreePath), lexicalChild);
86434
+ if (isAbsolute9(lexicalRelative) || lexicalRelative === ".." || lexicalRelative.startsWith(`..${sep8}`)) {
86003
86435
  throw new Error("Isolated workspace subdirectory escapes the worktree");
86004
86436
  }
86005
86437
  let physicalChild;
@@ -86011,8 +86443,8 @@ async function requireIsolatedWorktreePath(ref, callerCwd, subdirectory) {
86011
86443
  } catch (cause) {
86012
86444
  throw new Error("Isolated workspace subdirectory is missing or not a directory", { cause });
86013
86445
  }
86014
- const physicalRelative = relative5(physicalPaths[0], physicalChild);
86015
- if (physicalRelative === "" || isAbsolute7(physicalRelative) || physicalRelative === ".." || physicalRelative.startsWith(`..${sep7}`)) {
86446
+ const physicalRelative = relative6(physicalPaths[0], physicalChild);
86447
+ if (physicalRelative === "" || isAbsolute9(physicalRelative) || physicalRelative === ".." || physicalRelative.startsWith(`..${sep8}`)) {
86016
86448
  throw new Error("Isolated workspace subdirectory resolves outside its worktree");
86017
86449
  }
86018
86450
  return physicalChild;
@@ -86807,9 +87239,9 @@ var AgentManager = class {
86807
87239
  if (isTerminalAgentTaskState(agentTask.state)) {
86808
87240
  return Promise.resolve();
86809
87241
  }
86810
- return new Promise((resolve34) => {
87242
+ return new Promise((resolve35) => {
86811
87243
  const existing = this.completionCallbacks.get(taskId) ?? [];
86812
- existing.push(resolve34);
87244
+ existing.push(resolve35);
86813
87245
  this.completionCallbacks.set(taskId, existing);
86814
87246
  });
86815
87247
  }
@@ -87016,7 +87448,7 @@ var AgentManager = class {
87016
87448
  origin,
87017
87449
  topicId: context2.topicId,
87018
87450
  projectId: context2.projectId,
87019
- cwd: resolve16(options.input.workingDirectory ?? process.cwd()),
87451
+ cwd: resolve17(options.input.workingDirectory ?? process.cwd()),
87020
87452
  log,
87021
87453
  activeSubSessionId: origin.subSessionId
87022
87454
  });
@@ -87033,20 +87465,20 @@ var AgentManager = class {
87033
87465
  * channel apply exactly as for a child that finished in this process.
87034
87466
  */
87035
87467
  async restoreChildConversation(options, context2) {
87036
- const refuse4 = /* @__PURE__ */ __name((reason2) => ({
87468
+ const refuse5 = /* @__PURE__ */ __name((reason2) => ({
87037
87469
  status: "refused",
87038
87470
  reason: reason2
87039
87471
  }), "refuse");
87040
87472
  const id3 = options.childSessionId;
87041
87473
  const retained = this.childConversations.get(id3);
87042
87474
  if (retained?.activeSubSessionId)
87043
- return refuse4("running");
87475
+ return refuse5("running");
87044
87476
  const paths2 = context2.childStorage?.kind === "disk" ? context2.childStorage.paths : this.deps.paths;
87045
87477
  if (!paths2)
87046
- return refuse4("no-layout");
87478
+ return refuse5("no-layout");
87047
87479
  const store = this.deps.sessionStore;
87048
87480
  if (store.supportsInvocationSummaries !== true || store.supportsOwnerVersionCas !== true)
87049
- return refuse4("not-resumable");
87481
+ return refuse5("not-resumable");
87050
87482
  const ancestry = await store.getAncestry(context2.sessionId, context2.tenantId);
87051
87483
  const parentLocator = {
87052
87484
  sessionId: context2.sessionId,
@@ -87056,32 +87488,32 @@ var AgentManager = class {
87056
87488
  try {
87057
87489
  meta = await readChildSessionMeta(paths2.subagentMeta(parentLocator, id3));
87058
87490
  } catch {
87059
- return refuse4("not-saved");
87491
+ return refuse5("not-saved");
87060
87492
  }
87061
87493
  if (!meta)
87062
- return refuse4("not-saved");
87494
+ return refuse5("not-saved");
87063
87495
  if (meta.sessionId !== id3 || meta.parentSessionId !== context2.sessionId)
87064
- return refuse4("foreign");
87496
+ return refuse5("foreign");
87065
87497
  const continuation = meta.continuation;
87066
87498
  if (!continuation || continuation.workspace !== "shared")
87067
- return refuse4("not-resumable");
87499
+ return refuse5("not-resumable");
87068
87500
  const agentId = options.agentFor(continuation.profile);
87069
87501
  if (agentId === void 0 || !this.registry.has(agentId))
87070
- return refuse4("not-resumable");
87502
+ return refuse5("not-resumable");
87071
87503
  const log = retained?.log ?? DiskSessionLog.at(paths2, { sessionId: id3, ancestors: ancestry });
87072
87504
  const ended = await childSessionEnded(log);
87073
87505
  if (!ended)
87074
- return refuse4("unsettled");
87506
+ return refuse5("unsettled");
87075
87507
  if (ended.status === "cancelled" || meta.status === "cancelled")
87076
- return refuse4("stopped");
87508
+ return refuse5("stopped");
87077
87509
  const started = await log.head();
87078
87510
  if (started === null)
87079
- return refuse4("unsettled");
87511
+ return refuse5("unsettled");
87080
87512
  for await (const { record: record3 } of log.read({ mode: "tolerant" })) {
87081
87513
  if (record3.type !== "session_started")
87082
87514
  continue;
87083
87515
  if (record3.projectId !== context2.projectId || record3.topicId !== context2.topicId)
87084
- return refuse4("foreign");
87516
+ return refuse5("foreign");
87085
87517
  break;
87086
87518
  }
87087
87519
  const placement = {
@@ -87105,7 +87537,7 @@ var AgentManager = class {
87105
87537
  if (this.childConversations.size >= RETAINED_CHILD_CONVERSATION_CAP) {
87106
87538
  const oldest = [...this.childConversations].find(([, value]) => !value.activeSubSessionId);
87107
87539
  if (!oldest)
87108
- return refuse4("full");
87540
+ return refuse5("full");
87109
87541
  this.childConversations.delete(oldest[0]);
87110
87542
  }
87111
87543
  const childActor = {
@@ -87121,7 +87553,7 @@ var AgentManager = class {
87121
87553
  try {
87122
87554
  if (child) {
87123
87555
  if (child.status === "active" || child.status === "archived" || child.status === "locked" || child.projectId !== context2.projectId || child.topicId !== context2.topicId || child.currentActor?.kind !== "agent" || child.currentActor.agentId !== agentId)
87124
- return refuse4("running");
87556
+ return refuse5("running");
87125
87557
  } else {
87126
87558
  child = await store.createSession({ id: id3, topicId: context2.topicId, projectId: context2.projectId, currentActor: childActor }, context2.tenantId);
87127
87559
  createdChild = true;
@@ -87161,7 +87593,7 @@ var AgentManager = class {
87161
87593
  },
87162
87594
  topicId: context2.topicId,
87163
87595
  projectId: context2.projectId,
87164
- cwd: resolve16(options.workingDirectory),
87596
+ cwd: resolve17(options.workingDirectory),
87165
87597
  log
87166
87598
  });
87167
87599
  return restored;
@@ -87189,7 +87621,7 @@ var AgentManager = class {
87189
87621
  throw new Error("Child conversation is still running or settling");
87190
87622
  if (origin.workspaceRef || options.workspace?.mode === "isolated" || options.workspaceBackend)
87191
87623
  throw new Error("Child continuation requires a shared workspace; isolated leases cannot be resumed");
87192
- if (resolve16(options.input.workingDirectory ?? process.cwd()) !== conversation.cwd)
87624
+ if (resolve17(options.input.workingDirectory ?? process.cwd()) !== conversation.cwd)
87193
87625
  throw new Error("Child continuation cannot change its working directory");
87194
87626
  const store = this.deps.sessionStore;
87195
87627
  if (store.supportsInvocationSummaries !== true || store.supportsOwnerVersionCas !== true)
@@ -87542,8 +87974,8 @@ var AgentManager = class {
87542
87974
  resolveCompletionCallbacks(taskId) {
87543
87975
  const callbacks = this.completionCallbacks.get(taskId);
87544
87976
  if (callbacks) {
87545
- for (const resolve34 of callbacks)
87546
- resolve34();
87977
+ for (const resolve35 of callbacks)
87978
+ resolve35();
87547
87979
  this.completionCallbacks.delete(taskId);
87548
87980
  }
87549
87981
  }
@@ -89091,7 +89523,7 @@ var MockLLMProvider = class {
89091
89523
  async delay() {
89092
89524
  if (this.responseDelayMs <= 0)
89093
89525
  return;
89094
- await new Promise((resolve34) => setTimeout(resolve34, this.responseDelayMs));
89526
+ await new Promise((resolve35) => setTimeout(resolve35, this.responseDelayMs));
89095
89527
  }
89096
89528
  /**
89097
89529
  * The turn to play. A script shorter than the turn repeats its last
@@ -89205,8 +89637,8 @@ registerMock();
89205
89637
  import { spawn as spawn5, spawnSync } from "node:child_process";
89206
89638
  import { constants as constants4, accessSync as accessSync2, existsSync as existsSync5, realpathSync as realpathSync3 } from "node:fs";
89207
89639
  import { readFile as fsReadFile, writeFile as fsWriteFile, mkdir as mkdir16, open as open13, readdir as readdir13, rename as rename7, rm as rm6, stat as stat12 } from "node:fs/promises";
89208
- import { tmpdir as tmpdir4 } from "node:os";
89209
- import { dirname as dirname19, isAbsolute as isAbsolute9, join as join36, parse as parse3, resolve as resolve17 } from "node:path";
89640
+ import { tmpdir as tmpdir2 } from "node:os";
89641
+ import { dirname as dirname19, isAbsolute as isAbsolute11, join as join36, parse as parse3, resolve as resolve18 } from "node:path";
89210
89642
 
89211
89643
  // ../sdk/dist/sandbox/denial.js
89212
89644
  var RUNNER_PREFIX = {
@@ -89261,7 +89693,7 @@ __name(denial, "denial");
89261
89693
 
89262
89694
  // ../sdk/dist/sandbox/file-walk.js
89263
89695
  var import_brace_expansion2 = __toESM(require_brace_expansion(), 1);
89264
- import { isAbsolute as isAbsolute8, join as join35, posix as posix2 } from "node:path";
89696
+ import { isAbsolute as isAbsolute10, join as join35, posix as posix2 } from "node:path";
89265
89697
 
89266
89698
  // ../../node_modules/.pnpm/minimatch@9.0.9/node_modules/minimatch/dist/esm/index.js
89267
89699
  var import_brace_expansion = __toESM(require_brace_expansion(), 1);
@@ -90074,8 +90506,8 @@ var path = {
90074
90506
  win32: { sep: "\\" },
90075
90507
  posix: { sep: "/" }
90076
90508
  };
90077
- var sep8 = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
90078
- minimatch.sep = sep8;
90509
+ var sep9 = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
90510
+ minimatch.sep = sep9;
90079
90511
  var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
90080
90512
  minimatch.GLOBSTAR = GLOBSTAR;
90081
90513
  var qmark2 = "[^/]";
@@ -91144,7 +91576,7 @@ function positiveInteger(value, name2) {
91144
91576
  }
91145
91577
  __name(positiveInteger, "positiveInteger");
91146
91578
  function planWalk(root, options) {
91147
- if (!isAbsolute8(root) && !posix2.isAbsolute(root)) {
91579
+ if (!isAbsolute10(root) && !posix2.isAbsolute(root)) {
91148
91580
  throw new Error("File walk root must be an absolute path");
91149
91581
  }
91150
91582
  let pattern = options.pattern ?? "**/*";
@@ -91203,7 +91635,7 @@ function planWalk(root, options) {
91203
91635
  __name(planWalk, "planWalk");
91204
91636
  function directoryMatcher(plan) {
91205
91637
  const patterns = plan.patterns.map((set3) => set3.map((part2) => typeof part2 === "object" && part2 !== null ? new RegExp(part2.source, `${part2.flags}s`) : part2));
91206
- return (relative16) => patterns.some((pattern) => {
91638
+ return (relative17) => patterns.some((pattern) => {
91207
91639
  const closure = /* @__PURE__ */ __name((states2) => {
91208
91640
  for (const index of states2)
91209
91641
  if (pattern[index] === null)
@@ -91211,7 +91643,7 @@ function directoryMatcher(plan) {
91211
91643
  return states2;
91212
91644
  }, "closure");
91213
91645
  let states = closure(/* @__PURE__ */ new Set([0]));
91214
- for (const name2 of relative16.split("/")) {
91646
+ for (const name2 of relative17.split("/")) {
91215
91647
  const next2 = /* @__PURE__ */ new Set();
91216
91648
  for (const index of states) {
91217
91649
  const segment2 = pattern[index];
@@ -91343,7 +91775,7 @@ async function* executeWalk(plan, signal, onSummary) {
91343
91775
  }
91344
91776
  if (plan.prefix.length >= maxDepth)
91345
91777
  return;
91346
- const openDirectory = /* @__PURE__ */ __name(async (absolute, relative16, depth, layered) => {
91778
+ const openDirectory = /* @__PURE__ */ __name(async (absolute, relative17, depth, layered) => {
91347
91779
  check2();
91348
91780
  try {
91349
91781
  const dir = await wait(fs.opendir(absolute), (late2) => {
@@ -91352,7 +91784,7 @@ async function* executeWalk(plan, signal, onSummary) {
91352
91784
  });
91353
91785
  if (layered)
91354
91786
  await ignore?.enter(absolute);
91355
- open15.push({ dir, relative: relative16, depth, layered });
91787
+ open15.push({ dir, relative: relative17, depth, layered });
91356
91788
  } catch (error) {
91357
91789
  if (!missing2(error))
91358
91790
  throw error;
@@ -91375,20 +91807,20 @@ async function* executeWalk(plan, signal, onSummary) {
91375
91807
  return;
91376
91808
  if (VCS_NAMES.has(entry.name))
91377
91809
  continue;
91378
- const relative16 = frame.relative ? `${frame.relative}/${entry.name}` : entry.name;
91379
- const absolute = path3.join(plan.root, relative16);
91810
+ const relative17 = frame.relative ? `${frame.relative}/${entry.name}` : entry.name;
91811
+ const absolute = path3.join(plan.root, relative17);
91380
91812
  const depth = frame.depth + 1;
91381
91813
  if (entry.isDirectory()) {
91382
- if (depth >= maxDepth || !canDescend(relative16))
91814
+ if (depth >= maxDepth || !canDescend(relative17))
91383
91815
  continue;
91384
91816
  if (ignore?.isIgnored(absolute, true)) {
91385
91817
  ignoredDirectories += 1;
91386
91818
  continue;
91387
91819
  }
91388
- await openDirectory(absolute, relative16, depth, true);
91820
+ await openDirectory(absolute, relative17, depth, true);
91389
91821
  continue;
91390
91822
  }
91391
- if (!entry.isFile() || !matchers.some((matcher) => matcher.test(relative16)))
91823
+ if (!entry.isFile() || !matchers.some((matcher) => matcher.test(relative17)))
91392
91824
  continue;
91393
91825
  if (ignore?.isIgnored(absolute, false))
91394
91826
  continue;
@@ -91476,8 +91908,8 @@ async function* walkFilesViaExec(exec, rootPath, options) {
91476
91908
  if (record3.type !== "entry" || typeof record3.path !== "string" || typeof record3.size !== "number" || !Number.isSafeInteger(record3.size) || record3.size < 0) {
91477
91909
  throw new Error("Invalid file walk entry");
91478
91910
  }
91479
- const relative16 = posix2.relative(rootPath, record3.path);
91480
- if (!posix2.isAbsolute(record3.path) || relative16 === ".." || relative16.startsWith("../") || posix2.isAbsolute(relative16)) {
91911
+ const relative17 = posix2.relative(rootPath, record3.path);
91912
+ if (!posix2.isAbsolute(record3.path) || relative17 === ".." || relative17.startsWith("../") || posix2.isAbsolute(relative17)) {
91481
91913
  throw new Error("File walk entry escaped its requested root");
91482
91914
  }
91483
91915
  if (++received > plan.maxEntries)
@@ -91546,8 +91978,8 @@ async function* walkFilesViaExec(exec, rootPath, options) {
91546
91978
  throw failure2;
91547
91979
  if (settled)
91548
91980
  break;
91549
- await new Promise((resolve34) => {
91550
- wake = resolve34;
91981
+ await new Promise((resolve35) => {
91982
+ wake = resolve35;
91551
91983
  });
91552
91984
  wake = void 0;
91553
91985
  }
@@ -91661,7 +92093,7 @@ var CappedStream = class {
91661
92093
  }
91662
92094
  };
91663
92095
  function requiredWrapper(request) {
91664
- if (request.wrapperCommand === void 0 || !isAbsolute9(request.wrapperCommand)) {
92096
+ if (request.wrapperCommand === void 0 || !isAbsolute11(request.wrapperCommand)) {
91665
92097
  throw new Error(`Sandbox environment ${request.environment} requires the absolute wrapper path that was probed`);
91666
92098
  }
91667
92099
  return request.wrapperCommand;
@@ -91716,7 +92148,7 @@ function detectEnvironment() {
91716
92148
  const { platform: platform2 } = process;
91717
92149
  if (platform2 === "linux") {
91718
92150
  const bwrap = resolveTrustedWrapper("bwrap");
91719
- if (bwrap !== void 0 && probeBwrapSpawn(bwrap, buildBwrapArgs(tmpdir4()))) {
92151
+ if (bwrap !== void 0 && probeBwrapSpawn(bwrap, buildBwrapArgs(resolveTempBase()))) {
91720
92152
  return { environment: "linux-bwrap", wrapperCommand: bwrap };
91721
92153
  }
91722
92154
  const unshare = resolveTrustedWrapper("unshare");
@@ -91726,7 +92158,7 @@ function detectEnvironment() {
91726
92158
  }
91727
92159
  if (platform2 === "darwin") {
91728
92160
  const seatbelt = resolveTrustedWrapper("sandbox-exec");
91729
- if (seatbelt !== void 0 && probeSandboxSpawn(seatbelt, buildSeatbeltArgs(tmpdir4()))) {
92161
+ if (seatbelt !== void 0 && probeSandboxSpawn(seatbelt, buildSeatbeltArgs(resolveTempBase()))) {
91730
92162
  return { environment: "macos-seatbelt", wrapperCommand: seatbelt };
91731
92163
  }
91732
92164
  }
@@ -91930,7 +92362,7 @@ var LocalSandbox = class {
91930
92362
  this.rootDir = rootDir;
91931
92363
  this.environment = environment;
91932
92364
  this.config = config;
91933
- this.additionalDirectories = (config.additionalDirectories ?? []).map((dir) => canonicalizePath(resolve17(dir))).filter((dir) => dir !== rootDir);
92365
+ this.additionalDirectories = (config.additionalDirectories ?? []).map((dir) => canonicalizePath(resolve18(dir))).filter((dir) => dir !== rootDir);
91934
92366
  this._status = "ready";
91935
92367
  this.log = log.child({
91936
92368
  [SCOPE_ATTRIBUTE]: "sandbox/provider/local",
@@ -92266,7 +92698,7 @@ var LocalSandbox = class {
92266
92698
  exitCode,
92267
92699
  stderr: stderr.text,
92268
92700
  timedOut,
92269
- allowedRoots: [...this.roots, tmpdir4(), "/tmp", "/var/tmp", "/dev"]
92701
+ allowedRoots: [...this.roots, tmpdir2(), resolveTempBase(), "/tmp", "/var/tmp", "/dev"]
92270
92702
  });
92271
92703
  resolvePromise({
92272
92704
  exitCode,
@@ -92332,7 +92764,7 @@ var LocalSandboxProvider = class {
92332
92764
  let rootDir;
92333
92765
  let removeRootOnDestroy;
92334
92766
  if (config?.workingDirectory !== void 0) {
92335
- const requested = resolve17(config.workingDirectory);
92767
+ const requested = resolve18(config.workingDirectory);
92336
92768
  let entry;
92337
92769
  try {
92338
92770
  entry = await stat12(requested);
@@ -92355,14 +92787,13 @@ var LocalSandboxProvider = class {
92355
92787
  }
92356
92788
  removeRootOnDestroy = false;
92357
92789
  for (const dir of config.additionalDirectories ?? []) {
92358
- const entry2 = await stat12(resolve17(dir)).catch(() => null);
92790
+ const entry2 = await stat12(resolve18(dir)).catch(() => null);
92359
92791
  if (!entry2?.isDirectory()) {
92360
- throw new Error(`Sandbox additional directory is not a directory: ${resolve17(dir)}`);
92792
+ throw new Error(`Sandbox additional directory is not a directory: ${resolve18(dir)}`);
92361
92793
  }
92362
92794
  }
92363
92795
  } else {
92364
- const { mkdtemp: mkdtemp2 } = await import("node:fs/promises");
92365
- const rawDir = await mkdtemp2(join36(tmpdir4(), SANDBOX_TEMP_DIR_PREFIX));
92796
+ const rawDir = await createTempDir(SANDBOX_TEMP_DIR_PREFIX);
92366
92797
  rootDir = canonicalizePath(rawDir);
92367
92798
  removeRootOnDestroy = true;
92368
92799
  }
@@ -92614,11 +93045,11 @@ var TextChunker = class {
92614
93045
  const trimmed = text10.trim();
92615
93046
  return trimmed.length > 0 ? [{ content: trimmed, index: startIndex }] : [];
92616
93047
  }
92617
- for (const sep17 of separators) {
92618
- const parts = sep17 === "" ? [...text10] : splitKeepingSeparator(text10, sep17).filter((p) => p.trim().length > 0);
93048
+ for (const sep18 of separators) {
93049
+ const parts = sep18 === "" ? [...text10] : splitKeepingSeparator(text10, sep18).filter((p) => p.trim().length > 0);
92619
93050
  if (parts.length <= 1)
92620
93051
  continue;
92621
- const remaining = separators.slice(separators.indexOf(sep17) + 1);
93052
+ const remaining = separators.slice(separators.indexOf(sep18) + 1);
92622
93053
  const merged = this.mergeSmallParts(parts, config);
92623
93054
  if (merged.every((c) => c.content.length <= config.chunkSize)) {
92624
93055
  return merged;
@@ -92640,12 +93071,12 @@ var TextChunker = class {
92640
93071
  }
92641
93072
  splitBySeparators(text10, separators) {
92642
93073
  let parts = [text10];
92643
- for (const sep17 of separators) {
93074
+ for (const sep18 of separators) {
92644
93075
  const nextParts = [];
92645
93076
  for (const part2 of parts) {
92646
- const splits = part2.split(sep17);
93077
+ const splits = part2.split(sep18);
92647
93078
  for (const [i, segment2] of splits.entries()) {
92648
- const piece = i < splits.length - 1 ? segment2 + sep17 : segment2;
93079
+ const piece = i < splits.length - 1 ? segment2 + sep18 : segment2;
92649
93080
  if (piece.trim().length > 0) {
92650
93081
  nextParts.push(piece);
92651
93082
  }
@@ -92675,17 +93106,17 @@ var TextChunker = class {
92675
93106
  return chunks;
92676
93107
  }
92677
93108
  };
92678
- function splitKeepingSeparator(text10, sep17) {
92679
- if (sep17 === "")
93109
+ function splitKeepingSeparator(text10, sep18) {
93110
+ if (sep18 === "")
92680
93111
  return [text10];
92681
93112
  const parts = [];
92682
93113
  let start = 0;
92683
93114
  for (; ; ) {
92684
- const at = text10.indexOf(sep17, start);
93115
+ const at = text10.indexOf(sep18, start);
92685
93116
  if (at === -1)
92686
93117
  break;
92687
- parts.push(text10.slice(start, at + sep17.length));
92688
- start = at + sep17.length;
93118
+ parts.push(text10.slice(start, at + sep18.length));
93119
+ start = at + sep18.length;
92689
93120
  }
92690
93121
  if (start < text10.length)
92691
93122
  parts.push(text10.slice(start));
@@ -94754,6 +95185,9 @@ var MAPPING = {
94754
95185
  // a peer models a task lifecycle — shipping a session's deleted history over
94755
95186
  // an external wire by default is a disclosure nobody asked for.
94756
95187
  compaction_started: null,
95188
+ // Where this runtime keeps its own transcript is not a fact about a peer's task.
95189
+ session_log_degraded: null,
95190
+ session_log_recovered: null,
94757
95191
  compaction_shed: null,
94758
95192
  compaction_completed: null,
94759
95193
  // Same reason as the two below: which of this runtime's context-relief
@@ -94922,8 +95356,8 @@ function operationBoundary(options) {
94922
95356
  let cause;
94923
95357
  let transportAbortArmed = options.abortTransportInitially;
94924
95358
  let resolveStopped;
94925
- const stopped = new Promise((resolve34) => {
94926
- resolveStopped = resolve34;
95359
+ const stopped = new Promise((resolve35) => {
95360
+ resolveStopped = resolve35;
94927
95361
  });
94928
95362
  const stop = /* @__PURE__ */ __name((next2) => {
94929
95363
  if (cause !== void 0)
@@ -95161,8 +95595,8 @@ var A2ADelegate = class {
95161
95595
  */
95162
95596
  async recoverInitialTask(request) {
95163
95597
  let timer;
95164
- const expired = new Promise((resolve34) => {
95165
- timer = setTimeout(() => resolve34(void 0), PEER_CANCEL_GRACE_MS);
95598
+ const expired = new Promise((resolve35) => {
95599
+ timer = setTimeout(() => resolve35(void 0), PEER_CANCEL_GRACE_MS);
95166
95600
  });
95167
95601
  try {
95168
95602
  const recovered = await Promise.race([
@@ -95256,7 +95690,7 @@ var A2ADelegate = class {
95256
95690
  };
95257
95691
  function sleep2(ms, signal) {
95258
95692
  signal.throwIfAborted();
95259
- return new Promise((resolve34, reject2) => {
95693
+ return new Promise((resolve35, reject2) => {
95260
95694
  let settled = false;
95261
95695
  const cleanup = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "cleanup");
95262
95696
  const onAbort = /* @__PURE__ */ __name(() => {
@@ -95272,7 +95706,7 @@ function sleep2(ms, signal) {
95272
95706
  return;
95273
95707
  settled = true;
95274
95708
  cleanup();
95275
- resolve34();
95709
+ resolve35();
95276
95710
  }, ms);
95277
95711
  signal.addEventListener("abort", onAbort, { once: true });
95278
95712
  if (signal.aborted)
@@ -95415,6 +95849,22 @@ var MAPPING2 = {
95415
95849
  failures: e.failures
95416
95850
  }), "transform")
95417
95851
  },
95852
+ session_log_degraded: {
95853
+ wire: "session_log.degraded",
95854
+ transform: /* @__PURE__ */ __name((e) => ({
95855
+ cause: e.cause,
95856
+ buffered_records: e.bufferedRecords,
95857
+ buffered_bytes: e.bufferedBytes,
95858
+ ...e.dropping ? { dropping: true } : {}
95859
+ }), "transform")
95860
+ },
95861
+ session_log_recovered: {
95862
+ wire: "session_log.recovered",
95863
+ transform: /* @__PURE__ */ __name((e) => ({
95864
+ flushed_records: e.flushedRecords,
95865
+ dropped_records: e.droppedRecords
95866
+ }), "transform")
95867
+ },
95418
95868
  compaction_started: {
95419
95869
  wire: "compaction.started",
95420
95870
  transform: /* @__PURE__ */ __name((e) => ({
@@ -95836,7 +96286,7 @@ __name(mapSessionEventToStreamEvent, "mapSessionEventToStreamEvent");
95836
96286
  var mapSessionToStreamEvent = mapSessionEventToStreamEvent;
95837
96287
 
95838
96288
  // ../sdk/dist/bridge/acp/server.js
95839
- import { isAbsolute as isAbsolute10 } from "node:path";
96289
+ import { isAbsolute as isAbsolute12 } from "node:path";
95840
96290
 
95841
96291
  // ../sdk/dist/bridge/acp/tasks.js
95842
96292
  function toAcpTaskUpdate(event, sessionId5) {
@@ -96139,7 +96589,7 @@ var ACPServer = class {
96139
96589
  request(method, params, signal) {
96140
96590
  this.requestSeq += 1;
96141
96591
  const id3 = `agent_${this.requestSeq}`;
96142
- return new Promise((resolve34, reject2) => {
96592
+ return new Promise((resolve35, reject2) => {
96143
96593
  const finish2 = /* @__PURE__ */ __name(() => {
96144
96594
  if (this.pending.get(id3) !== entry)
96145
96595
  return false;
@@ -96154,7 +96604,7 @@ var ACPServer = class {
96154
96604
  const entry = {
96155
96605
  resolve: /* @__PURE__ */ __name((value) => {
96156
96606
  if (finish2())
96157
- resolve34(value);
96607
+ resolve35(value);
96158
96608
  }, "resolve"),
96159
96609
  reject: /* @__PURE__ */ __name((error) => {
96160
96610
  if (finish2())
@@ -96301,7 +96751,7 @@ var ACPServer = class {
96301
96751
  }
96302
96752
  requireAbsoluteCwd(cwd) {
96303
96753
  const resolved2 = cwd ?? process.cwd();
96304
- if (!isAbsolute10(resolved2)) {
96754
+ if (!isAbsolute12(resolved2)) {
96305
96755
  throw new AcpError(ACP_ERROR_CODES.INVALID_PARAMS, `ACP session cwd must be an absolute path; received ${JSON.stringify(resolved2)}.`);
96306
96756
  }
96307
96757
  return resolved2;
@@ -96844,7 +97294,7 @@ var FileLockManager = class {
96844
97294
  return immediate;
96845
97295
  const deadline = Date.now() + this.config.acquireTimeoutMs;
96846
97296
  while (Date.now() < deadline) {
96847
- await new Promise((resolve34) => setTimeout(resolve34, LOCK_ACQUIRE_POLL_INTERVAL_MS));
97297
+ await new Promise((resolve35) => setTimeout(resolve35, LOCK_ACQUIRE_POLL_INTERVAL_MS));
96848
97298
  this.expireStale();
96849
97299
  const retry = this.tryAcquire(filePath, owner);
96850
97300
  if (retry.acquired)
@@ -97461,7 +97911,7 @@ var WorkspaceBackendRegistry = class {
97461
97911
  import { execFile } from "node:child_process";
97462
97912
  import { readFileSync as readFileSync3, realpathSync as realpathSync4 } from "node:fs";
97463
97913
  import { realpath as realpath11 } from "node:fs/promises";
97464
- import { basename as basename11, dirname as dirname20, isAbsolute as isAbsolute11, join as join37, relative as relative6, resolve as resolve18, sep as sep9 } from "node:path";
97914
+ import { basename as basename11, dirname as dirname20, isAbsolute as isAbsolute13, join as join37, relative as relative7, resolve as resolve19, sep as sep10 } from "node:path";
97465
97915
  import { promisify } from "node:util";
97466
97916
  var execFileAsync = promisify(execFile);
97467
97917
  var defaultExecFile = /* @__PURE__ */ __name(async (file, args) => execFileAsync(file, [...args]), "defaultExecFile");
@@ -97475,8 +97925,8 @@ var GitWorktreeDriver = class {
97475
97925
  log;
97476
97926
  exec;
97477
97927
  constructor(config) {
97478
- this.repoRoot = resolve18(config.repoRoot);
97479
- this.worktreesDir = resolve18(config.worktreesDir ?? defaultWorktreesDir(config.repoRoot));
97928
+ this.repoRoot = resolve19(config.repoRoot);
97929
+ this.worktreesDir = resolve19(config.worktreesDir ?? defaultWorktreesDir(config.repoRoot));
97480
97930
  this.log = config.logger.child({ [SCOPE_ATTRIBUTE]: "session/workspace/git-worktree" });
97481
97931
  this.exec = config.execFile ?? defaultExecFile;
97482
97932
  }
@@ -97489,7 +97939,7 @@ var GitWorktreeDriver = class {
97489
97939
  try {
97490
97940
  repoRoot = await canonicalizeThroughExisting(this.repoRoot);
97491
97941
  worktreesDir = await canonicalizeThroughExisting(this.worktreesDir);
97492
- const lexicalPath = resolve18(worktreesDir, label6);
97942
+ const lexicalPath = resolve19(worktreesDir, label6);
97493
97943
  if (!isStrictDescendant(worktreesDir, lexicalPath)) {
97494
97944
  throw new Error(`Workspace label escapes the managed worktree directory: ${label6}`);
97495
97945
  }
@@ -97497,13 +97947,13 @@ var GitWorktreeDriver = class {
97497
97947
  if (!isStrictDescendant(worktreesDir, worktreePath)) {
97498
97948
  throw new Error(`Workspace label resolves through a link outside the managed worktree directory: ${label6}`);
97499
97949
  }
97500
- if (relative6(worktreesDir, lexicalPath) !== relative6(worktreesDir, worktreePath)) {
97950
+ if (relative7(worktreesDir, lexicalPath) !== relative7(worktreesDir, worktreePath)) {
97501
97951
  throw new Error(`Workspace label resolves through a link to a different managed path: ${label6}`);
97502
97952
  }
97503
97953
  } catch (cause) {
97504
97954
  throw new WorkspaceBackendError({ op: "create:ownership", kind: this.kind, cause });
97505
97955
  }
97506
- const relativePath = relative6(worktreesDir, worktreePath).split(sep9).join("/");
97956
+ const relativePath = relative7(worktreesDir, worktreePath).split(sep10).join("/");
97507
97957
  const branch = `namzu/${relativePath}`;
97508
97958
  const argv = ["-C", repoRoot, "worktree", "add", "-b", branch, "--", worktreePath];
97509
97959
  if (params.baseRef !== void 0) {
@@ -97677,7 +98127,7 @@ var GitWorktreeDriver = class {
97677
98127
  if (!isStrictDescendant(worktreesDir, worktreePath)) {
97678
98128
  throw new Error("Workspace reference escapes the managed worktree directory");
97679
98129
  }
97680
- const label6 = relative6(worktreesDir, worktreePath).split(sep9).join("/");
98130
+ const label6 = relative7(worktreesDir, worktreePath).split(sep10).join("/");
97681
98131
  const branch = `namzu/${label6}`;
97682
98132
  if (ref.meta.branch !== branch) {
97683
98133
  throw new Error("Workspace reference branch does not match its managed path");
@@ -97712,12 +98162,12 @@ var GitWorktreeDriver = class {
97712
98162
  }
97713
98163
  };
97714
98164
  async function canonicalizeThroughExisting(input) {
97715
- let existing = resolve18(input);
98165
+ let existing = resolve19(input);
97716
98166
  const remainder = [];
97717
98167
  for (; ; ) {
97718
98168
  try {
97719
98169
  const canonical3 = await realpath11(existing);
97720
- return resolve18(canonical3, ...remainder);
98170
+ return resolve19(canonical3, ...remainder);
97721
98171
  } catch (cause) {
97722
98172
  const code = cause.code;
97723
98173
  if (code !== "ENOENT" && code !== "ENOTDIR")
@@ -97725,15 +98175,15 @@ async function canonicalizeThroughExisting(input) {
97725
98175
  }
97726
98176
  const parent = dirname20(existing);
97727
98177
  if (parent === existing)
97728
- return resolve18(existing, ...remainder);
98178
+ return resolve19(existing, ...remainder);
97729
98179
  remainder.unshift(basename11(existing));
97730
98180
  existing = parent;
97731
98181
  }
97732
98182
  }
97733
98183
  __name(canonicalizeThroughExisting, "canonicalizeThroughExisting");
97734
98184
  function isStrictDescendant(root, candidate) {
97735
- const rel = relative6(root, candidate);
97736
- return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep9}`) && !isAbsolute11(rel);
98185
+ const rel = relative7(root, candidate);
98186
+ return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep10}`) && !isAbsolute13(rel);
97737
98187
  }
97738
98188
  __name(isStrictDescendant, "isStrictDescendant");
97739
98189
  function parseWorktreeList(stdout, worktreePath) {
@@ -97767,7 +98217,7 @@ function defaultWorktreesDir(repoRoot) {
97767
98217
  try {
97768
98218
  cwd = realpathSync4(repoRoot);
97769
98219
  } catch {
97770
- cwd = resolve18(repoRoot);
98220
+ cwd = resolve19(repoRoot);
97771
98221
  }
97772
98222
  const home = resolveNamzuHome();
97773
98223
  let slug = slugForCwd(cwd);
@@ -97783,7 +98233,7 @@ __name(defaultWorktreesDir, "defaultWorktreesDir");
97783
98233
 
97784
98234
  // ../sdk/dist/session/workspace/shared-session.js
97785
98235
  import { mkdir as mkdir17, readFile as readFile19, rename as rename8, writeFile as writeFile6 } from "node:fs/promises";
97786
- import { dirname as dirname21, join as join38, normalize as normalize6, relative as relative7, sep as sep10 } from "node:path";
98236
+ import { dirname as dirname21, join as join38, normalize as normalize6, relative as relative8, sep as sep11 } from "node:path";
97787
98237
  import { posix as posix3 } from "node:path";
97788
98238
  var SharedSessionWorkspace = class _SharedSessionWorkspace {
97789
98239
  static {
@@ -97825,7 +98275,7 @@ var SharedSessionWorkspace = class _SharedSessionWorkspace {
97825
98275
  runtimePath(...segments) {
97826
98276
  if (segments.length === 0)
97827
98277
  return this.runtimeRoot;
97828
- return posix3.join(this.runtimeRoot, ...segments.map((segment2) => segment2.split(sep10).join("/")));
98278
+ return posix3.join(this.runtimeRoot, ...segments.map((segment2) => segment2.split(sep11).join("/")));
97829
98279
  }
97830
98280
  async ensure() {
97831
98281
  await Promise.all([
@@ -97998,8 +98448,8 @@ ${ensureTrailingNewline(input.sectionText)}` : ensureTrailingNewline(input.secti
97998
98448
  };
97999
98449
  function safeJoin(root, segments) {
98000
98450
  const fullPath = normalize6(join38(root, ...segments));
98001
- const rel = relative7(root, fullPath);
98002
- if (rel === "" || !rel.startsWith("..") && !rel.includes(`..${sep10}`))
98451
+ const rel = relative8(root, fullPath);
98452
+ if (rel === "" || !rel.startsWith("..") && !rel.includes(`..${sep11}`))
98003
98453
  return fullPath;
98004
98454
  throw new Error(`SharedSessionWorkspace path escapes root: ${segments.join("/")}`);
98005
98455
  }
@@ -99015,13 +99465,13 @@ __name(readText, "readText");
99015
99465
 
99016
99466
  // ../sdk/dist/store/session/memory.js
99017
99467
  import { realpathSync as realpathSync5 } from "node:fs";
99018
- import { resolve as resolve20 } from "node:path";
99468
+ import { resolve as resolve21 } from "node:path";
99019
99469
 
99020
99470
  // ../sdk/dist/store/session/canonical-path.js
99021
99471
  import { realpath as realpath12 } from "node:fs/promises";
99022
- import { resolve as resolve19 } from "node:path";
99472
+ import { resolve as resolve20 } from "node:path";
99023
99473
  async function canonicalizePath2(input) {
99024
- const absolute = resolve19(input);
99474
+ const absolute = resolve20(input);
99025
99475
  try {
99026
99476
  return await realpath12(absolute);
99027
99477
  } catch (err) {
@@ -99115,7 +99565,7 @@ var InMemorySessionStore = class {
99115
99565
  } catch (error) {
99116
99566
  if (error.code !== "ENOENT")
99117
99567
  throw error;
99118
- rootPath = resolve20(project.rootPath);
99568
+ rootPath = resolve21(project.rootPath);
99119
99569
  }
99120
99570
  const key6 = `${project.tenantId}\0${rootPath}`;
99121
99571
  const existingProjectId = roots.get(key6);
@@ -99497,9 +99947,9 @@ var InMemorySessionStore = class {
99497
99947
  };
99498
99948
 
99499
99949
  // ../sdk/dist/store/session/disk.js
99500
- import { createHash as createHash28 } from "node:crypto";
99950
+ import { createHash as createHash29 } from "node:crypto";
99501
99951
  import { mkdir as mkdir19, rm as rm7 } from "node:fs/promises";
99502
- import { join as join40, resolve as resolve21 } from "node:path";
99952
+ import { join as join40, resolve as resolve22 } from "node:path";
99503
99953
  var SCHEMA9 = defineSchema({
99504
99954
  kind: "session-store",
99505
99955
  current: 4,
@@ -99548,7 +99998,7 @@ var DiskSessionStore = class {
99548
99998
  this.rootDir = config.rootDir;
99549
99999
  }
99550
100000
  async withSessionWrite(sessionId5, operation) {
99551
- const key6 = resolve21(this.rootDir, sessionId5);
100001
+ const key6 = resolve22(this.rootDir, sessionId5);
99552
100002
  const previous = sessionWriters.get(key6) ?? Promise.resolve();
99553
100003
  let release2 = /* @__PURE__ */ __name(() => {
99554
100004
  }, "release");
@@ -99666,7 +100116,7 @@ var DiskSessionStore = class {
99666
100116
  }
99667
100117
  rootPathBindingLocation(rootPath, tenantId2) {
99668
100118
  const key6 = rootPathIndexKey(rootPath, tenantId2);
99669
- const digest8 = createHash28("sha256").update(key6).digest("hex");
100119
+ const digest8 = createHash29("sha256").update(key6).digest("hex");
99670
100120
  const root = join40(this.rootDir, "projects", ".root-path-index", digest8.slice(0, 2));
99671
100121
  return {
99672
100122
  legacyPath: join40(root, `${digest8.slice(2)}.json`),
@@ -101467,7 +101917,7 @@ function codingAgentDoctrineContribution(options = {}) {
101467
101917
  __name(codingAgentDoctrineContribution, "codingAgentDoctrineContribution");
101468
101918
 
101469
101919
  // ../sdk/dist/learning/skill.js
101470
- import { createHash as createHash29 } from "node:crypto";
101920
+ import { createHash as createHash30 } from "node:crypto";
101471
101921
  var label = external_exports.string().trim().min(1).max(256);
101472
101922
  var name = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
101473
101923
  var digest3 = external_exports.string().regex(/^[a-f0-9]{64}$/);
@@ -101620,7 +102070,7 @@ function reviseLearningProfile(current, input) {
101620
102070
  __name(reviseLearningProfile, "reviseLearningProfile");
101621
102071
  function hashLearningSkill(input) {
101622
102072
  const candidate = candidateSchema.parse(input);
101623
- return createHash29("sha256").update(JSON.stringify([
102073
+ return createHash30("sha256").update(JSON.stringify([
101624
102074
  candidate.name,
101625
102075
  candidate.description,
101626
102076
  candidate.body,
@@ -101660,13 +102110,13 @@ function promoteLearningSkill(current, input, evaluation, inputEvidence) {
101660
102110
  verification: {
101661
102111
  baselineHash,
101662
102112
  candidateHash: hash2,
101663
- evidenceDigest: createHash29("sha256").update(JSON.stringify({ ...evaluation, protection })).digest("hex"),
102113
+ evidenceDigest: createHash30("sha256").update(JSON.stringify({ ...evaluation, protection })).digest("hex"),
101664
102114
  verificationTasks: review.verification.tasks.length,
101665
102115
  confirmationTasks: review.confirmation?.tasks.length ?? 0,
101666
102116
  protection: {
101667
102117
  verificationTasks: protection.verification.length,
101668
102118
  confirmationTasks: protection.confirmation.length,
101669
- planDigest: createHash29("sha256").update(JSON.stringify(protection)).digest("hex")
102119
+ planDigest: createHash30("sha256").update(JSON.stringify(protection)).digest("hex")
101670
102120
  }
101671
102121
  }
101672
102122
  };
@@ -102273,12 +102723,12 @@ function openTerminalWith(pty, options, defaults2) {
102273
102723
  for (const listener of listeners)
102274
102724
  listener(chunk);
102275
102725
  });
102276
- const exited = new Promise((resolve34) => {
102726
+ const exited = new Promise((resolve35) => {
102277
102727
  const exitSub = child.onExit((event) => {
102278
102728
  dataSub.dispose();
102279
102729
  exitSub.dispose();
102280
102730
  listeners.clear();
102281
- resolve34(event);
102731
+ resolve35(event);
102282
102732
  });
102283
102733
  });
102284
102734
  return {
@@ -102424,7 +102874,7 @@ function analyzeContextUsage(input) {
102424
102874
  __name(analyzeContextUsage, "analyzeContextUsage");
102425
102875
 
102426
102876
  // ../sdk/dist/manager/resident/store.js
102427
- import { createHash as createHash30, randomUUID as randomUUID9 } from "node:crypto";
102877
+ import { createHash as createHash31, randomUUID as randomUUID9 } from "node:crypto";
102428
102878
  import { join as join41 } from "node:path";
102429
102879
  var text7 = external_exports.string().trim().min(1).max(8e3);
102430
102880
  var time = external_exports.number().int().nonnegative().safe();
@@ -102472,7 +102922,7 @@ var residentStateSchema = external_exports.object({
102472
102922
  });
102473
102923
  function residentKeySegment(key6) {
102474
102924
  const encoded = revisionFileSegment(key6);
102475
- return encoded.length <= 255 ? encoded : `~sha256-${createHash30("sha256").update(encoded).digest("hex")}`;
102925
+ return encoded.length <= 255 ? encoded : `~sha256-${createHash31("sha256").update(encoded).digest("hex")}`;
102476
102926
  }
102477
102927
  __name(residentKeySegment, "residentKeySegment");
102478
102928
  var ResidentConflictError = class extends Error {
@@ -102666,13 +103116,13 @@ __name(runResident, "runResident");
102666
103116
 
102667
103117
  // ../sdk/dist/manager/resident/agenda.js
102668
103118
  import { randomUUID as randomUUID11 } from "node:crypto";
102669
- import { join as join43, resolve as resolve23 } from "node:path";
103119
+ import { join as join43, resolve as resolve24 } from "node:path";
102670
103120
  import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
102671
103121
 
102672
103122
  // ../sdk/dist/manager/resident/history-disk.js
102673
103123
  import { constants as constants5 } from "node:fs";
102674
103124
  import { lstat as lstat10, open as open14 } from "node:fs/promises";
102675
- import { join as join42, relative as relative8, resolve as resolve22, sep as sep11 } from "node:path";
103125
+ import { join as join42, relative as relative9, resolve as resolve23, sep as sep12 } from "node:path";
102676
103126
  var RECORD_BYTES2 = 4 * 1024 * 1024;
102677
103127
  var ResidentHistoryPageLimit = class extends Error {
102678
103128
  static {
@@ -102681,12 +103131,12 @@ var ResidentHistoryPageLimit = class extends Error {
102681
103131
  };
102682
103132
  async function readResidentHistoryRecord(root, path3, budget) {
102683
103133
  budget.signal?.throwIfAborted();
102684
- const base3 = resolve22(root);
102685
- const suffix = relative8(base3, resolve22(path3));
102686
- if (suffix === ".." || suffix.startsWith(`..${sep11}`))
103134
+ const base3 = resolve23(root);
103135
+ const suffix = relative9(base3, resolve23(path3));
103136
+ if (suffix === ".." || suffix.startsWith(`..${sep12}`))
102687
103137
  throw new Error("Invalid history path.");
102688
103138
  let current = base3;
102689
- for (const part2 of ["", ...suffix.split(sep11).filter(Boolean)]) {
103139
+ for (const part2 of ["", ...suffix.split(sep12).filter(Boolean)]) {
102690
103140
  current = join42(current, part2);
102691
103141
  if ((await lstat10(current)).isSymbolicLink())
102692
103142
  throw new Error("History symlinks are refused.");
@@ -103410,8 +103860,8 @@ var DiskResidentAgenda = class {
103410
103860
  revisionsDir: join43(directory, "revisions"),
103411
103861
  publishLegacyProjection: false
103412
103862
  };
103413
- this.historyRoot = resolve23(root);
103414
- this.historyRevisions = resolve23(this.location.revisionsDir);
103863
+ this.historyRoot = resolve24(root);
103864
+ this.historyRevisions = resolve24(this.location.revisionsDir);
103415
103865
  }
103416
103866
  checked(record3) {
103417
103867
  const agenda = agendaSchema.parse(record3);
@@ -104302,7 +104752,7 @@ function createResidentDeliveryWindow(config) {
104302
104752
  __name(createResidentDeliveryWindow, "createResidentDeliveryWindow");
104303
104753
 
104304
104754
  // ../sdk/dist/learning/cycle.js
104305
- import { createHash as createHash31, randomUUID as randomUUID12 } from "node:crypto";
104755
+ import { createHash as createHash32, randomUUID as randomUUID12 } from "node:crypto";
104306
104756
 
104307
104757
  // ../sdk/dist/learning/leak-tripwire.js
104308
104758
  import { randomBytes as randomBytes7 } from "node:crypto";
@@ -104690,7 +105140,7 @@ ${exploration.evidence.reason}`
104690
105140
  }, { subject: "exploration.trace", text: exploration.trace });
104691
105141
  await append("exploration", {
104692
105142
  observations: exploration,
104693
- digest: createHash31("sha256").update(JSON.stringify(exploration)).digest("hex")
105143
+ digest: createHash32("sha256").update(JSON.stringify(exploration)).digest("hex")
104694
105144
  }, "explore");
104695
105145
  const problem2 = resourceProblem(true);
104696
105146
  if (problem2)
@@ -104739,7 +105189,7 @@ ${s.revision}`).join("\n"),
104739
105189
  await append("evaluation", {
104740
105190
  baselineRevision,
104741
105191
  candidateRevision,
104742
- digest: createHash31("sha256").update(JSON.stringify(batch)).digest("hex"),
105192
+ digest: createHash32("sha256").update(JSON.stringify(batch)).digest("hex"),
104743
105193
  baselineTrajectories: batch.baseline.map((t) => t.trajectoryId),
104744
105194
  candidateTrajectories: batch.candidate.map((t) => t.trajectoryId)
104745
105195
  }, name2);
@@ -105151,7 +105601,7 @@ __name(selectLearningExperience, "selectLearningExperience");
105151
105601
  // ../sdk/dist/learning/experience-store.js
105152
105602
  import { mkdirSync as mkdirSync4 } from "node:fs";
105153
105603
  import { createRequire as createRequire3 } from "node:module";
105154
- import { dirname as dirname22, resolve as resolve24 } from "node:path";
105604
+ import { dirname as dirname22, resolve as resolve25 } from "node:path";
105155
105605
  var SCHEMA10 = `
105156
105606
  CREATE TABLE experience (
105157
105607
  ordinal INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -105173,7 +105623,7 @@ var SqliteLearningExperienceStore = class {
105173
105623
  scope;
105174
105624
  readOnly;
105175
105625
  constructor(options) {
105176
- this.databasePath = resolve24(options.databasePath);
105626
+ this.databasePath = resolve25(options.databasePath);
105177
105627
  this.scope = Object.freeze({
105178
105628
  tenantId: asTenantId(options.scope.tenantId.toLowerCase()),
105179
105629
  projectId: asProjectId(options.scope.projectId.toLowerCase()),
@@ -105731,10 +106181,10 @@ function createResidentEvidenceRecallStep(options) {
105731
106181
  __name(createResidentEvidenceRecallStep, "createResidentEvidenceRecallStep");
105732
106182
 
105733
106183
  // ../sdk/dist/learning/store.js
105734
- import { createHash as createHash32, randomUUID as randomUUID14 } from "node:crypto";
106184
+ import { createHash as createHash33, randomUUID as randomUUID14 } from "node:crypto";
105735
106185
  import { closeSync, existsSync as existsSync6, fsyncSync, linkSync, lstatSync as lstatSync3, mkdirSync as mkdirSync5, openSync, readFileSync as readFileSync4, unlinkSync, writeFileSync as writeFileSync3 } from "node:fs";
105736
106186
  import { createRequire as createRequire4 } from "node:module";
105737
- import { dirname as dirname23, join as join44, resolve as resolve25 } from "node:path";
106187
+ import { dirname as dirname23, join as join44, resolve as resolve26 } from "node:path";
105738
106188
 
105739
106189
  // ../sdk/dist/learning/observation.js
105740
106190
  var label4 = external_exports.string().trim().min(1).max(256);
@@ -105760,7 +106210,7 @@ var learningObservationSchema = learningTargetSchema.extend({
105760
106210
 
105761
106211
  // ../sdk/dist/learning/store.js
105762
106212
  var uuid2 = external_exports.string().uuid().transform((id3) => id3.toLowerCase());
105763
- var digest4 = /* @__PURE__ */ __name((text10) => createHash32("sha256").update(text10).digest("hex"), "digest");
106213
+ var digest4 = /* @__PURE__ */ __name((text10) => createHash33("sha256").update(text10).digest("hex"), "digest");
105764
106214
  var MAX_EVENT_BYTES = 256 * 1024;
105765
106215
  var MAX_ARTIFACT_BYTES = 8 * 1024 * 1024;
105766
106216
  var MAX_EVENTS = 4096;
@@ -105864,8 +106314,8 @@ var SqliteLearningStore = class {
105864
106314
  scope;
105865
106315
  readOnly;
105866
106316
  constructor(options) {
105867
- this.databasePath = resolve25(options.databasePath);
105868
- this.artifactsPath = resolve25(options.artifactsPath);
106317
+ this.databasePath = resolve26(options.databasePath);
106318
+ this.artifactsPath = resolve26(options.artifactsPath);
105869
106319
  this.scope = Object.freeze({
105870
106320
  tenantId: asTenantId(options.scope.tenantId.toLowerCase()),
105871
106321
  projectId: asProjectId(options.scope.projectId.toLowerCase()),
@@ -106368,7 +106818,7 @@ import { join as join46 } from "node:path";
106368
106818
 
106369
106819
  // ../sdk/dist/peers/dir.js
106370
106820
  import { chmodSync, lstatSync as lstatSync4, mkdirSync as mkdirSync6 } from "node:fs";
106371
- import { tmpdir as tmpdir5 } from "node:os";
106821
+ import { tmpdir as tmpdir3 } from "node:os";
106372
106822
  import { join as join45 } from "node:path";
106373
106823
  var PeerDirectoryError = class extends Error {
106374
106824
  static {
@@ -106420,7 +106870,7 @@ function peerRuntimeDirCandidates(options) {
106420
106870
  if (options.env.XDG_RUNTIME_DIR)
106421
106871
  candidates.push(join45(options.env.XDG_RUNTIME_DIR, "namzu"));
106422
106872
  candidates.push(join45(options.namzuHome, "run"));
106423
- candidates.push(join45(options.tmpDir ?? tmpdir5(), `namzu-${options.uid ?? "user"}`));
106873
+ candidates.push(join45(options.tmpDir ?? tmpdir3(), `namzu-${options.uid ?? "user"}`));
106424
106874
  return candidates;
106425
106875
  }
106426
106876
  __name(peerRuntimeDirCandidates, "peerRuntimeDirCandidates");
@@ -106487,7 +106937,7 @@ function parsePeerAddress(address2) {
106487
106937
  __name(parsePeerAddress, "parsePeerAddress");
106488
106938
 
106489
106939
  // ../sdk/dist/peers/record.js
106490
- import { createHash as createHash33 } from "node:crypto";
106940
+ import { createHash as createHash34 } from "node:crypto";
106491
106941
 
106492
106942
  // ../sdk/dist/peers/protocol.js
106493
106943
  var PEER_PROTOCOL_VERSION = "namzu-peer/1";
@@ -106617,7 +107067,7 @@ var PeerRecordSchema = external_exports.object({
106617
107067
  var PeerRecordReaderSchema = PeerRecordSchema.strip();
106618
107068
  var PEER_REF_HEX_LENGTH = 6;
106619
107069
  function derivePeerRef(sessionId5) {
106620
- return createHash33("sha256").update(sessionId5, "utf8").digest("hex").slice(0, PEER_REF_HEX_LENGTH);
107070
+ return createHash34("sha256").update(sessionId5, "utf8").digest("hex").slice(0, PEER_REF_HEX_LENGTH);
106621
107071
  }
106622
107072
  __name(derivePeerRef, "derivePeerRef");
106623
107073
 
@@ -106644,7 +107094,7 @@ function connectPath(address2) {
106644
107094
  }
106645
107095
  __name(connectPath, "connectPath");
106646
107096
  function sendPeerRequest(address2, request, parseResponse, timeoutMs) {
106647
- return new Promise((resolve34) => {
107097
+ return new Promise((resolve35) => {
106648
107098
  let settled = false;
106649
107099
  const finish2 = /* @__PURE__ */ __name((result) => {
106650
107100
  if (settled)
@@ -106652,7 +107102,7 @@ function sendPeerRequest(address2, request, parseResponse, timeoutMs) {
106652
107102
  settled = true;
106653
107103
  clearTimeout(timer);
106654
107104
  socket.destroy();
106655
- resolve34(result);
107105
+ resolve35(result);
106656
107106
  }, "finish");
106657
107107
  const unreachable = /* @__PURE__ */ __name((error) => finish2({
106658
107108
  kind: "unreachable",
@@ -106664,7 +107114,7 @@ function sendPeerRequest(address2, request, parseResponse, timeoutMs) {
106664
107114
  path3 = connectPath(address2);
106665
107115
  } catch (error) {
106666
107116
  clearTimeout(timer);
106667
- resolve34({
107117
+ resolve35({
106668
107118
  kind: "unreachable",
106669
107119
  reason: error instanceof Error ? error.message : String(error)
106670
107120
  });
@@ -107213,23 +107663,23 @@ async function createPeerEndpoint(options) {
107213
107663
  void handleLine(buffered.subarray(0, newline)).catch(() => socket.destroy());
107214
107664
  });
107215
107665
  });
107216
- await new Promise((resolve34, reject2) => {
107666
+ await new Promise((resolve35, reject2) => {
107217
107667
  const failed = /* @__PURE__ */ __name((error) => reject2(error), "failed");
107218
107668
  server.once("error", failed);
107219
107669
  server.listen({ path: listenPath }, () => {
107220
107670
  server.removeListener("error", failed);
107221
- resolve34();
107671
+ resolve35();
107222
107672
  });
107223
107673
  });
107224
107674
  server.on("error", () => {
107225
107675
  });
107226
107676
  if (parsed.scheme === "uds")
107227
107677
  chmodSync2(listenPath, 384);
107228
- const close = /* @__PURE__ */ __name(() => new Promise((resolve34) => {
107678
+ const close = /* @__PURE__ */ __name(() => new Promise((resolve35) => {
107229
107679
  closing = true;
107230
107680
  for (const socket of sockets)
107231
107681
  socket.destroy();
107232
- server.close(() => resolve34());
107682
+ server.close(() => resolve35());
107233
107683
  }), "close");
107234
107684
  return {
107235
107685
  address: options.address,
@@ -107322,7 +107772,7 @@ __name(formatPeerNotice, "formatPeerNotice");
107322
107772
  // ../sdk/dist/account/registry.js
107323
107773
  import { randomBytes as randomBytes11 } from "node:crypto";
107324
107774
  import { chmodSync as chmodSync3, closeSync as closeSync4, fsyncSync as fsyncSync3, mkdirSync as mkdirSync8, openSync as openSync4, readFileSync as readFileSync7, realpathSync as realpathSync6, renameSync as renameSync2, rmSync as rmSync2, unlinkSync as unlinkSync4, writeSync as writeSync3 } from "node:fs";
107325
- import { basename as basename14, dirname as dirname26, isAbsolute as isAbsolute12, join as join49, relative as relative9, resolve as resolve26 } from "node:path";
107775
+ import { basename as basename14, dirname as dirname26, isAbsolute as isAbsolute14, join as join49, relative as relative10, resolve as resolve27 } from "node:path";
107326
107776
 
107327
107777
  // ../sdk/dist/account/lock.js
107328
107778
  import { randomBytes as randomBytes10 } from "node:crypto";
@@ -107653,7 +108103,7 @@ function createAccountRegistry(options = {}) {
107653
108103
  }
107654
108104
  __name(checkEndpointAndModel, "checkEndpointAndModel");
107655
108105
  function realOrSelf(target) {
107656
- let existing = resolve26(target);
108106
+ let existing = resolve27(target);
107657
108107
  const rest = [];
107658
108108
  for (; ; ) {
107659
108109
  try {
@@ -107661,7 +108111,7 @@ function createAccountRegistry(options = {}) {
107661
108111
  } catch {
107662
108112
  const parent = dirname26(existing);
107663
108113
  if (parent === existing)
107664
- return resolve26(target);
108114
+ return resolve27(target);
107665
108115
  rest.push(basename14(existing));
107666
108116
  existing = parent;
107667
108117
  }
@@ -107669,13 +108119,13 @@ function createAccountRegistry(options = {}) {
107669
108119
  }
107670
108120
  __name(realOrSelf, "realOrSelf");
107671
108121
  function insideAccountsRoot(dir) {
107672
- const rel = relative9(realOrSelf(accountsRoot), realOrSelf(dir));
107673
- return rel !== "" && !rel.startsWith("..") && !isAbsolute12(rel);
108122
+ const rel = relative10(realOrSelf(accountsRoot), realOrSelf(dir));
108123
+ return rel !== "" && !rel.startsWith("..") && !isAbsolute14(rel);
107674
108124
  }
107675
108125
  __name(insideAccountsRoot, "insideAccountsRoot");
107676
108126
  function nests(outer, inner) {
107677
- const rel = relative9(realOrSelf(outer), realOrSelf(inner));
107678
- return rel === "" || !rel.startsWith("..") && !isAbsolute12(rel);
108127
+ const rel = relative10(realOrSelf(outer), realOrSelf(inner));
108128
+ return rel === "" || !rel.startsWith("..") && !isAbsolute14(rel);
107679
108129
  }
107680
108130
  __name(nests, "nests");
107681
108131
  const registry = {
@@ -107724,7 +108174,7 @@ function createAccountRegistry(options = {}) {
107724
108174
  if (input.provider !== CODEX_PROVIDER) {
107725
108175
  throw new AccountRegistryError("A Codex home account belongs to the codex provider only.");
107726
108176
  }
107727
- const dir = resolve26(input.dir ?? join49(accountsRoot, "codex", input.label));
108177
+ const dir = resolve27(input.dir ?? join49(accountsRoot, "codex", input.label));
107728
108178
  if (!insideAccountsRoot(dir)) {
107729
108179
  throw new AccountRegistryError("A Codex account directory must live under the Namzu accounts folder.");
107730
108180
  }
@@ -107845,7 +108295,7 @@ __name(resolveBoundAccount, "resolveBoundAccount");
107845
108295
  // ../sdk/dist/pals/store.js
107846
108296
  import { randomUUID as randomUUID15 } from "node:crypto";
107847
108297
  import { chmodSync as chmodSync4, closeSync as closeSync5, fsyncSync as fsyncSync4, linkSync as linkSync2, lstatSync as lstatSync7, mkdirSync as mkdirSync9, openSync as openSync5, readFileSync as readFileSync8, readdirSync as readdirSync3, realpathSync as realpathSync7, unlinkSync as unlinkSync5, writeSync as writeSync4 } from "node:fs";
107848
- import { dirname as dirname27, isAbsolute as isAbsolute13, join as join50, relative as relative10, resolve as resolve27, sep as sep12 } from "node:path";
108298
+ import { dirname as dirname27, isAbsolute as isAbsolute15, join as join50, relative as relative11, resolve as resolve28, sep as sep13 } from "node:path";
107849
108299
  var ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
107850
108300
  var REVISION_FILE = /^[1-9][0-9]*\.json$/u;
107851
108301
  var PalConflictError = class extends Error {
@@ -107866,7 +108316,7 @@ function palId(id3) {
107866
108316
  }
107867
108317
  __name(palId, "palId");
107868
108318
  function homePath(home) {
107869
- const path3 = resolve27(home);
108319
+ const path3 = resolve28(home);
107870
108320
  mkdirSync9(path3, { recursive: true, mode: 448 });
107871
108321
  const entry = lstatSync7(path3);
107872
108322
  if (!entry.isDirectory() || entry.isSymbolicLink())
@@ -107878,8 +108328,8 @@ function homePath(home) {
107878
108328
  }
107879
108329
  __name(homePath, "homePath");
107880
108330
  function contained(path3, root) {
107881
- const rel = relative10(root, path3);
107882
- return rel === "" || !isAbsolute13(rel) && rel !== ".." && !rel.startsWith(`..${sep12}`);
108331
+ const rel = relative11(root, path3);
108332
+ return rel === "" || !isAbsolute15(rel) && rel !== ".." && !rel.startsWith(`..${sep13}`);
107883
108333
  }
107884
108334
  __name(contained, "contained");
107885
108335
  function paths(home, workspaceRoot, id3) {
@@ -108113,7 +108563,7 @@ var DiskPalStore = class {
108113
108563
  }
108114
108564
  /** Exact validated host control directory; never an execution-computer claim. */
108115
108565
  atWorkspace(cwd) {
108116
- const lexical = resolve27(cwd);
108566
+ const lexical = resolve28(cwd);
108117
108567
  const canonical3 = realpathSync7(lexical);
108118
108568
  const lexicalReserved = contained(lexical, this.workspaceRoot);
108119
108569
  const canonicalReserved = contained(canonical3, this.workspaceRoot);
@@ -108121,7 +108571,7 @@ var DiskPalStore = class {
108121
108571
  return null;
108122
108572
  if (lexical !== canonical3)
108123
108573
  throw new Error("Pal workspace is a symlink alias.");
108124
- const rel = relative10(this.workspaceRoot, canonical3);
108574
+ const rel = relative11(this.workspaceRoot, canonical3);
108125
108575
  if (!ID.test(rel))
108126
108576
  throw new Error("Reserved Pal control directories cannot run ordinary host sessions. Open the exact Pal workspace.");
108127
108577
  const pal = this.get(rel);
@@ -108773,7 +109223,7 @@ var PAL_WORK_GUIDANCE = [
108773
109223
  ].join("\n\n");
108774
109224
 
108775
109225
  // ../sdk/dist/pals/reference-images.js
108776
- import { createHash as createHash34, randomUUID as randomUUID16 } from "node:crypto";
109226
+ import { createHash as createHash35, randomUUID as randomUUID16 } from "node:crypto";
108777
109227
  import { posix as posix4 } from "node:path";
108778
109228
  var MAX_IMAGES = 8;
108779
109229
  var MAX_IMAGE_BYTES = 3 * 1024 * 1024;
@@ -108817,7 +109267,7 @@ function preparePalReferenceImages(attachments) {
108817
109267
  attachmentIndex: index + 1,
108818
109268
  mediaType: attachment.mediaType,
108819
109269
  data: attachment.data,
108820
- sha256: createHash34("sha256").update(bytes).digest("hex"),
109270
+ sha256: createHash35("sha256").update(bytes).digest("hex"),
108821
109271
  bytes: bytes.length
108822
109272
  }));
108823
109273
  }
@@ -108997,14 +109447,14 @@ __name(createPalReferenceImageTool, "createPalReferenceImageTool");
108997
109447
  // ../sdk/dist/pals/communication/store.js
108998
109448
  import { randomUUID as randomUUID17 } from "node:crypto";
108999
109449
  import { chmodSync as chmodSync5, lstatSync as lstatSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync4, realpathSync as realpathSync8 } from "node:fs";
109000
- import { join as join51, resolve as resolve28 } from "node:path";
109450
+ import { join as join51, resolve as resolve29 } from "node:path";
109001
109451
  import { isDeepStrictEqual as isDeepStrictEqual9 } from "node:util";
109002
109452
 
109003
109453
  // ../sdk/dist/pals/communication/ingress-schema.js
109004
109454
  import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
109005
109455
 
109006
109456
  // ../sdk/dist/pals/communication/schema.js
109007
- import { createHash as createHash35 } from "node:crypto";
109457
+ import { createHash as createHash36 } from "node:crypto";
109008
109458
  var id2 = external_exports.string().uuid();
109009
109459
  var sessionId3 = external_exports.custom((s) => isEntityId(s, "session"));
109010
109460
  var turnId4 = external_exports.custom((s) => isEntityId(s, "turn"));
@@ -109099,7 +109549,7 @@ function freezeCommunicationValue(value) {
109099
109549
  }
109100
109550
  __name(freezeCommunicationValue, "freezeCommunicationValue");
109101
109551
  function hash(value) {
109102
- return createHash35("sha256").update(JSON.stringify(value)).digest("hex");
109552
+ return createHash36("sha256").update(JSON.stringify(value)).digest("hex");
109103
109553
  }
109104
109554
  __name(hash, "hash");
109105
109555
  function addressTuple(value) {
@@ -109807,7 +110257,7 @@ var DiskPalCommunicationStore = class {
109807
110257
  migrations: { 1: (value) => value }
109808
110258
  }), "Pal communication", (record3) => record3.revision);
109809
110259
  constructor(options) {
109810
- this.root = resolve28(options.root);
110260
+ this.root = resolve29(options.root);
109811
110261
  this.secure = options.secureDirectory ?? ((path3) => {
109812
110262
  if (process.platform !== "win32")
109813
110263
  chmodSync5(path3, 448);
@@ -110675,7 +111125,7 @@ __name(dispatchPalMessagesOnce, "dispatchPalMessagesOnce");
110675
111125
 
110676
111126
  // ../sdk/dist/pals/communication/policy.js
110677
111127
  import { chmodSync as chmodSync6, lstatSync as lstatSync9, mkdirSync as mkdirSync11, readdirSync as readdirSync5, realpathSync as realpathSync9 } from "node:fs";
110678
- import { join as join52, resolve as resolve29 } from "node:path";
111128
+ import { join as join52, resolve as resolve30 } from "node:path";
110679
111129
  var PalMessagePermissionConflictError = class extends Error {
110680
111130
  static {
110681
111131
  __name(this, "PalMessagePermissionConflictError");
@@ -110711,7 +111161,7 @@ var DiskPalMessagePolicy = class {
110711
111161
  secure;
110712
111162
  records = new DiskRevisionRecordStore(defineSchema({ kind: "pal-message-permission", current: 1, migrations: {} }), "Pal message permission", (value) => value.revision);
110713
111163
  constructor(options) {
110714
- this.root = resolve29(options.root);
111164
+ this.root = resolve30(options.root);
110715
111165
  this.secure = options.secureDirectory ?? ((path3) => {
110716
111166
  if (process.platform !== "win32")
110717
111167
  chmodSync6(path3, 448);
@@ -110807,10 +111257,10 @@ var DiskPalMessagePolicy = class {
110807
111257
  };
110808
111258
 
110809
111259
  // ../sdk/dist/pals/activity/source.js
110810
- import { createHash as createHash37 } from "node:crypto";
111260
+ import { createHash as createHash38 } from "node:crypto";
110811
111261
 
110812
111262
  // ../sdk/dist/pals/activity/projection.js
110813
- import { createHash as createHash36 } from "node:crypto";
111263
+ import { createHash as createHash37 } from "node:crypto";
110814
111264
  var activityId2 = external_exports.custom((value) => isEntityId(value, "activity"));
110815
111265
  var checkpointId3 = external_exports.custom((value) => isEntityId(value, "checkpoint"));
110816
111266
  var toolUseId2 = external_exports.string().min(1).max(512).regex(/^[A-Za-z0-9_.:-]+$/);
@@ -110869,7 +111319,7 @@ function projectPalActivity(entry, scopeHash) {
110869
111319
  return null;
110870
111320
  }
110871
111321
  return Object.freeze({
110872
- id: createHash36("sha256").update(JSON.stringify(["pal-activity/1", scopeHash, pointer2])).digest("hex"),
111322
+ id: createHash37("sha256").update(JSON.stringify(["pal-activity/1", scopeHash, pointer2])).digest("hex"),
110873
111323
  type: record3.type,
110874
111324
  sessionId: record3.sessionId,
110875
111325
  ..."turnId" in record3 ? { turnId: record3.turnId } : {},
@@ -110963,7 +111413,7 @@ function createPalActivitySource(options) {
110963
111413
  if (definition.id !== scope.palId || definition.revision !== scope.profileRevision)
110964
111414
  throw new PalActivityIntegrityError();
110965
111415
  const workspace = definition.workspace;
110966
- const scopeHash = createHash37("sha256").update(JSON.stringify([
111416
+ const scopeHash = createHash38("sha256").update(JSON.stringify([
110967
111417
  "pal-activity/1",
110968
111418
  scope.tenantId,
110969
111419
  scope.projectId,
@@ -111352,11 +111802,11 @@ __name(dispatchPalIngressOnce, "dispatchPalIngressOnce");
111352
111802
 
111353
111803
  // ../sdk/dist/pals/channels/routes.js
111354
111804
  import { chmodSync as chmodSync7, lstatSync as lstatSync10, mkdirSync as mkdirSync12, readdirSync as readdirSync6, realpathSync as realpathSync10 } from "node:fs";
111355
- import { join as join53, resolve as resolve30 } from "node:path";
111805
+ import { join as join53, resolve as resolve31 } from "node:path";
111356
111806
  import { isDeepStrictEqual as isDeepStrictEqual10 } from "node:util";
111357
111807
 
111358
111808
  // ../sdk/dist/pals/channels/schema.js
111359
- import { createHash as createHash38 } from "node:crypto";
111809
+ import { createHash as createHash39 } from "node:crypto";
111360
111810
  var connectionSchema = external_exports.object({
111361
111811
  tenantId: addressSchema2.shape.tenantId,
111362
111812
  provider: label5,
@@ -111387,7 +111837,7 @@ var verifiedActionSchema = external_exports.object({
111387
111837
  actionId: label5,
111388
111838
  payloadDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
111389
111839
  payload: external_exports.string().min(1).max(32e3).refine((value) => !value.includes("\0"))
111390
- }).strict().refine((value) => createHash38("sha256").update(value.payload).digest("hex") === value.payloadDigest, "Channel action payload does not match its authenticated digest.");
111840
+ }).strict().refine((value) => createHash39("sha256").update(value.payload).digest("hex") === value.payloadDigest, "Channel action payload does not match its authenticated digest.");
111391
111841
  var routeDecisionSchema = external_exports.object({
111392
111842
  v: external_exports.literal(1),
111393
111843
  revision: external_exports.literal(1),
@@ -111460,7 +111910,7 @@ var DiskPalChannelRoutes = class {
111460
111910
  secure;
111461
111911
  records = new DiskRevisionRecordStore(defineSchema({ kind: "pal-channel-route", current: 1, migrations: {} }), "Pal channel route", (record3) => record3.revision);
111462
111912
  constructor(options) {
111463
- this.root = resolve30(options.root);
111913
+ this.root = resolve31(options.root);
111464
111914
  this.secure = options.secureDirectory ?? ((path3) => {
111465
111915
  if (process.platform !== "win32")
111466
111916
  chmodSync7(path3, 448);
@@ -111782,7 +112232,7 @@ var PalChannelRouter = class {
111782
112232
 
111783
112233
  // ../sdk/dist/pals/activity/subscription-store.js
111784
112234
  import { chmodSync as chmodSync8, lstatSync as lstatSync11, mkdirSync as mkdirSync13, readdirSync as readdirSync7, realpathSync as realpathSync11 } from "node:fs";
111785
- import { join as join54, resolve as resolve31 } from "node:path";
112235
+ import { join as join54, resolve as resolve32 } from "node:path";
111786
112236
  import { isDeepStrictEqual as isDeepStrictEqual13 } from "node:util";
111787
112237
 
111788
112238
  // ../sdk/dist/pals/activity/subscription-schema.js
@@ -111821,7 +112271,7 @@ var DiskPalActivitySubscriptionStore = class {
111821
112271
  migrations: {}
111822
112272
  }), "Pal activity subscription", (value) => value.revision);
111823
112273
  constructor(options) {
111824
- this.root = resolve31(options.root);
112274
+ this.root = resolve32(options.root);
111825
112275
  this.secure = options.secureDirectory ?? ((path3) => {
111826
112276
  if (process.platform !== "win32")
111827
112277
  chmodSync8(path3, 448);
@@ -111943,7 +112393,7 @@ var DiskPalActivitySubscriptionStore = class {
111943
112393
 
111944
112394
  // ../sdk/dist/pals/activity/subscription-policy.js
111945
112395
  import { chmodSync as chmodSync9, lstatSync as lstatSync12, mkdirSync as mkdirSync14, readdirSync as readdirSync8, realpathSync as realpathSync12 } from "node:fs";
111946
- import { join as join55, resolve as resolve32 } from "node:path";
112396
+ import { join as join55, resolve as resolve33 } from "node:path";
111947
112397
  import { isDeepStrictEqual as isDeepStrictEqual14 } from "node:util";
111948
112398
  var PalActivitySubscriptionPermissionConflictError = class extends Error {
111949
112399
  static {
@@ -111978,7 +112428,7 @@ var DiskPalActivitySubscriptionPolicy = class {
111978
112428
  migrations: {}
111979
112429
  }), "Pal activity subscription permission", (value) => value.revision);
111980
112430
  constructor(options) {
111981
- this.root = resolve32(options.root);
112431
+ this.root = resolve33(options.root);
111982
112432
  this.subscriptions = options.subscriptions;
111983
112433
  this.secure = options.secureDirectory ?? ((path3) => {
111984
112434
  if (process.platform !== "win32")
@@ -112240,7 +112690,7 @@ async function publishPalActivityOnce(options, id3, input) {
112240
112690
  __name(publishPalActivityOnce, "publishPalActivityOnce");
112241
112691
 
112242
112692
  // ../sdk/dist/pals/activity/causality.js
112243
- import { createHash as createHash39 } from "node:crypto";
112693
+ import { createHash as createHash40 } from "node:crypto";
112244
112694
  import { isDeepStrictEqual as isDeepStrictEqual16 } from "node:util";
112245
112695
  var requestMarkerSchema = external_exports.object({
112246
112696
  type: external_exports.literal("request_envelope"),
@@ -112319,7 +112769,7 @@ function createPalActivityCausalityResolver(options) {
112319
112769
  const root = entries2[0]?.record;
112320
112770
  if (root?.type !== "session_started" || root.parent || root.forkedFrom || root.tenantId !== scope.tenantId || root.projectId !== scope.projectId || root.cwd !== workspace || root.origin?.protocol !== "desktop" || root.origin.externalSessionId !== JSON.stringify(["namzu-pal", scope.palId, scope.profileRevision, scope.sessionId]))
112321
112771
  unavailable3();
112322
- const scopeHash = createHash39("sha256").update(JSON.stringify([
112772
+ const scopeHash = createHash40("sha256").update(JSON.stringify([
112323
112773
  "pal-activity/1",
112324
112774
  scope.tenantId,
112325
112775
  scope.projectId,
@@ -112558,7 +113008,7 @@ function admitToolFacts(value) {
112558
113008
  __name(admitToolFacts, "admitToolFacts");
112559
113009
 
112560
113010
  // ../sdk/dist/tools/builtins/glob.js
112561
- import { isAbsolute as isAbsolute15, join as join56, relative as relative12, sep as sep14 } from "node:path";
113011
+ import { isAbsolute as isAbsolute17, join as join56, relative as relative13, sep as sep15 } from "node:path";
112562
113012
 
112563
113013
  // ../sdk/dist/tools/posix-path.js
112564
113014
  function normalizeSegments(path3) {
@@ -112608,7 +113058,7 @@ function resolveWithinPosix(root, candidate) {
112608
113058
  __name(resolveWithinPosix, "resolveWithinPosix");
112609
113059
 
112610
113060
  // ../sdk/dist/tools/builtins/search-support.js
112611
- import { isAbsolute as isAbsolute14, join as joinPath, posix as posix5, relative as relative11, sep as sep13 } from "node:path";
113061
+ import { isAbsolute as isAbsolute16, join as joinPath, posix as posix5, relative as relative12, sep as sep14 } from "node:path";
112612
113062
  var SEARCH_BUDGET_MS = 12e3;
112613
113063
  var MAX_FILES_SEARCHED = 5e4;
112614
113064
  function openSearchBudget(parent, budgetMs = SEARCH_BUDGET_MS) {
@@ -112630,12 +113080,12 @@ function openSearchBudget(parent, budgetMs = SEARCH_BUDGET_MS) {
112630
113080
  }
112631
113081
  __name(openSearchBudget, "openSearchBudget");
112632
113082
  function hostDisplayPath(workingDirectory, absolute) {
112633
- const rel = relative11(workingDirectory, absolute);
113083
+ const rel = relative12(workingDirectory, absolute);
112634
113084
  if (rel === "")
112635
113085
  return ".";
112636
- if (rel === ".." || rel.startsWith(`..${sep13}`) || isAbsolute14(rel))
113086
+ if (rel === ".." || rel.startsWith(`..${sep14}`) || isAbsolute16(rel))
112637
113087
  return absolute;
112638
- return sep13 === "/" ? rel : rel.split(sep13).join("/");
113088
+ return sep14 === "/" ? rel : rel.split(sep14).join("/");
112639
113089
  }
112640
113090
  __name(hostDisplayPath, "hostDisplayPath");
112641
113091
  function quoteControlPath(path3) {
@@ -112664,10 +113114,10 @@ function isReadDenied(context2, path3, sandboxRoot) {
112664
113114
  return false;
112665
113115
  if (sandboxRoot === void 0)
112666
113116
  return context2.readDenied(path3);
112667
- const relative16 = posix5.relative(sandboxRoot, path3);
112668
- if (relative16 === ".." || relative16.startsWith("../") || posix5.isAbsolute(relative16))
113117
+ const relative17 = posix5.relative(sandboxRoot, path3);
113118
+ if (relative17 === ".." || relative17.startsWith("../") || posix5.isAbsolute(relative17))
112669
113119
  return true;
112670
- return context2.readDenied(joinPath(context2.workingDirectory, relative16));
113120
+ return context2.readDenied(joinPath(context2.workingDirectory, relative17));
112671
113121
  }
112672
113122
  __name(isReadDenied, "isReadDenied");
112673
113123
 
@@ -112680,13 +113130,13 @@ var inputSchema9 = external_exports.object({
112680
113130
  include_ignored: external_exports.boolean().optional().describe("Also return files that .gitignore and .ignore rules exclude, such as build output and dependencies. Default: false.")
112681
113131
  });
112682
113132
  function relativePattern(pattern, root, sandboxed) {
112683
- let result = sandboxed ? pattern : pattern.split(sep14).join("/");
113133
+ let result = sandboxed ? pattern : pattern.split(sep15).join("/");
112684
113134
  if (result.split("/").includes("..")) {
112685
113135
  throw new Error('Glob pattern escapes the search directory through "..". Choose a contained path and a relative pattern.');
112686
113136
  }
112687
- if (sandboxed ? result.startsWith("/") : isAbsolute15(pattern)) {
113137
+ if (sandboxed ? result.startsWith("/") : isAbsolute17(pattern)) {
112688
113138
  const contained2 = sandboxed ? resolveWithinPosix(root, result) : resolveWithin(root, pattern);
112689
- result = sandboxed ? relativePosix(root, contained2) : relative12(root, contained2).split(sep14).join("/");
113139
+ result = sandboxed ? relativePosix(root, contained2) : relative13(root, contained2).split(sep15).join("/");
112690
113140
  }
112691
113141
  while (result.startsWith("./"))
112692
113142
  result = result.slice(2);
@@ -112763,7 +113213,7 @@ var GlobTool = defineTool({
112763
113213
  capped = true;
112764
113214
  break;
112765
113215
  }
112766
- files.push(sandbox ? relativePosix(sandbox.rootDir, absolute) : hostDisplayPath(context2.workingDirectory, join56(lexicalRoot, relative12(root, absolute))));
113216
+ files.push(sandbox ? relativePosix(sandbox.rootDir, absolute) : hostDisplayPath(context2.workingDirectory, join56(lexicalRoot, relative13(root, absolute))));
112767
113217
  }
112768
113218
  } catch (error) {
112769
113219
  if (context2.abortSignal?.aborted)
@@ -112823,7 +113273,7 @@ ${ignoredHint(ignored)}` : "";
112823
113273
 
112824
113274
  // ../sdk/dist/tools/builtins/code-analysis.js
112825
113275
  import { realpath as realpath13, stat as stat13 } from "node:fs/promises";
112826
- import { isAbsolute as isAbsolute16, relative as relative13, sep as sep15 } from "node:path";
113276
+ import { isAbsolute as isAbsolute18, relative as relative14, sep as sep16 } from "node:path";
112827
113277
  var DEFAULT_LIMIT = 50;
112828
113278
  var MAX_LIMIT = 200;
112829
113279
  var DEFAULT_MAX_CHARS = 2e4;
@@ -113103,10 +113553,10 @@ async function owningRoot(roots, target) {
113103
113553
  }
113104
113554
  __name(owningRoot, "owningRoot");
113105
113555
  function relativeTo(root, path3) {
113106
- const rel = relative13(root, path3);
113107
- if (rel === "" || rel === ".." || rel.startsWith(`..${sep15}`) || isAbsolute16(rel))
113556
+ const rel = relative14(root, path3);
113557
+ if (rel === "" || rel === ".." || rel.startsWith(`..${sep16}`) || isAbsolute18(rel))
113108
113558
  return path3;
113109
- return sep15 === "/" ? rel : rel.split(sep15).join("/");
113559
+ return sep16 === "/" ? rel : rel.split(sep16).join("/");
113110
113560
  }
113111
113561
  __name(relativeTo, "relativeTo");
113112
113562
  function shortFunction(fn) {
@@ -113325,7 +113775,7 @@ __name(getCodeNavigationTools, "getCodeNavigationTools");
113325
113775
 
113326
113776
  // ../sdk/dist/tools/builtins/grep.js
113327
113777
  import { stat as stat14 } from "node:fs/promises";
113328
- import { isAbsolute as isAbsolute17, join as join57, relative as relative14, sep as sep16 } from "node:path";
113778
+ import { isAbsolute as isAbsolute19, join as join57, relative as relative15, sep as sep17 } from "node:path";
113329
113779
  async function readWithSignal(read, signal) {
113330
113780
  signal?.throwIfAborted();
113331
113781
  if (!signal)
@@ -113348,12 +113798,12 @@ async function readWithSignal(read, signal) {
113348
113798
  }
113349
113799
  __name(readWithSignal, "readWithSignal");
113350
113800
  function relativeInclude(include, root, sandboxed) {
113351
- let pattern = sandboxed ? include : include.split(sep16).join("/");
113801
+ let pattern = sandboxed ? include : include.split(sep17).join("/");
113352
113802
  if (pattern.split("/").includes(".."))
113353
113803
  throw new Error("Include pattern escapes the search directory");
113354
- if (sandboxed ? pattern.startsWith("/") : isAbsolute17(include)) {
113804
+ if (sandboxed ? pattern.startsWith("/") : isAbsolute19(include)) {
113355
113805
  const absolute = sandboxed ? resolveWithinPosix(root, pattern) : resolveWithin(root, include);
113356
- pattern = sandboxed ? relativePosix(root, absolute) : relative14(root, absolute).split(sep16).join("/");
113806
+ pattern = sandboxed ? relativePosix(root, absolute) : relative15(root, absolute).split(sep17).join("/");
113357
113807
  }
113358
113808
  while (pattern.startsWith("./"))
113359
113809
  pattern = pattern.slice(2);
@@ -113558,7 +114008,7 @@ var GrepTool = defineTool({
113558
114008
  }
113559
114009
  const lines = content.split("\n");
113560
114010
  let fileMatches = 0;
113561
- const relPath = sandbox ? relativePosix(sandbox.rootDir, filePath) : hostDisplayPath(context2.workingDirectory, join57(lexicalRoot, relative14(root, filePath)));
114011
+ const relPath = sandbox ? relativePosix(sandbox.rootDir, filePath) : hostDisplayPath(context2.workingDirectory, join57(lexicalRoot, relative15(root, filePath)));
113562
114012
  if (mode === "content" && input.only_matching) {
113563
114013
  for (const fragment of matchingFragments(content, regex, multiline)) {
113564
114014
  signal?.throwIfAborted();
@@ -114242,7 +114692,7 @@ async function waitForJobWithBounds(jobs, id3, options, now = Date.now) {
114242
114692
  omittedOutputBytes
114243
114693
  };
114244
114694
  });
114245
- const expiry = new Promise((resolve34) => {
114695
+ const expiry = new Promise((resolve35) => {
114246
114696
  const tick = setInterval(() => {
114247
114697
  if (settled)
114248
114698
  return;
@@ -114250,7 +114700,7 @@ async function waitForJobWithBounds(jobs, id3, options, now = Date.now) {
114250
114700
  const elapsed = now() - startedAt;
114251
114701
  if (elapsed >= options.wallMs) {
114252
114702
  clearInterval(tick);
114253
- resolve34({
114703
+ resolve35({
114254
114704
  kind: "timeout",
114255
114705
  cause: "wall",
114256
114706
  elapsedMs: elapsed,
@@ -114266,7 +114716,7 @@ async function waitForJobWithBounds(jobs, id3, options, now = Date.now) {
114266
114716
  const quietFor = now() - lastProgressAt;
114267
114717
  if (quietFor >= options.idleMs) {
114268
114718
  clearInterval(tick);
114269
- resolve34({
114719
+ resolve35({
114270
114720
  kind: "timeout",
114271
114721
  cause: "idle",
114272
114722
  elapsedMs: elapsed,
@@ -114503,7 +114953,7 @@ ${observed}
114503
114953
  });
114504
114954
 
114505
114955
  // ../sdk/dist/tools/builtins/skill.js
114506
- import { createHash as createHash40 } from "node:crypto";
114956
+ import { createHash as createHash41 } from "node:crypto";
114507
114957
  var inputSchema16 = external_exports.object({
114508
114958
  name: external_exports.string().min(1).optional().describe("The skill to load, exactly as listed in the available-skills manifest. Omit it to list model-invocable skills."),
114509
114959
  args: external_exports.string().max(8e3).optional().describe("What to apply the skill to, in your own words. A skill that runs as a delegated agent sees only this and its own instructions, so say what it needs. Omit it on a continuation."),
@@ -114514,7 +114964,7 @@ var LIST_CURSOR_PATTERN = /^v1\.list\.(0|[1-9][0-9]*)\.([01])\.([A-Za-z0-9_-]{43
114514
114964
  var MAX_SKILLS_PER_PAGE = 20;
114515
114965
  var OVERSIZED_CATALOG_WARNING = "Some skills were omitted because their metadata is too large for this response budget.";
114516
114966
  function snapshotDigest(snapshot) {
114517
- return createHash40("sha256").update(JSON.stringify({
114967
+ return createHash41("sha256").update(JSON.stringify({
114518
114968
  version: 1,
114519
114969
  name: snapshot.name,
114520
114970
  body: snapshot.body,
@@ -114558,7 +115008,7 @@ function activeOutputCap(maxChars2) {
114558
115008
  }
114559
115009
  __name(activeOutputCap, "activeOutputCap");
114560
115010
  function listDigest(skills, maxChars2) {
114561
- return createHash40("sha256").update(JSON.stringify({ version: 1, kind: "list", maxChars: maxChars2 ?? null, skills })).digest("base64url");
115011
+ return createHash41("sha256").update(JSON.stringify({ version: 1, kind: "list", maxChars: maxChars2 ?? null, skills })).digest("base64url");
114562
115012
  }
114563
115013
  __name(listDigest, "listDigest");
114564
115014
  function serializeListPage(page) {
@@ -115309,7 +115759,7 @@ __name(buildRunCodeTool, "buildRunCodeTool");
115309
115759
 
115310
115760
  // ../sdk/dist/tools/builtins/ls.js
115311
115761
  import { readdir as readdir15, stat as stat15 } from "node:fs/promises";
115312
- import { join as join58, relative as relative15 } from "node:path";
115762
+ import { join as join58, relative as relative16 } from "node:path";
115313
115763
  var inputSchema18 = external_exports.object({
115314
115764
  path: external_exports.string().default(".").describe("Directory path to list. Defaults to working directory."),
115315
115765
  all: external_exports.boolean().default(false).describe("Include hidden files (dotfiles)"),
@@ -115366,7 +115816,7 @@ async function listRecursive(basePath, currentPath, showHidden, maxDepth, depth,
115366
115816
  for (const entry of entries2) {
115367
115817
  if (count7.value >= MAX_ENTRIES)
115368
115818
  break;
115369
- const relPath = `./${relative15(basePath, join58(currentPath, entry.name))}`;
115819
+ const relPath = `./${relative16(basePath, join58(currentPath, entry.name))}`;
115370
115820
  const suffix = entry.type === "dir" ? "/" : "";
115371
115821
  const sizeStr = entry.type === "file" ? ` (${formatSize2(entry.size)})` : "";
115372
115822
  output.push(`${relPath}${suffix}${sizeStr}`);
@@ -115487,7 +115937,7 @@ var LsTool = defineTool({
115487
115937
 
115488
115938
  // ../sdk/dist/tools/builtins/verify-outputs.js
115489
115939
  import { stat as stat16 } from "node:fs/promises";
115490
- import { resolve as resolve33 } from "node:path";
115940
+ import { resolve as resolve34 } from "node:path";
115491
115941
  var inputSchema19 = external_exports.object({
115492
115942
  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."),
115493
115943
  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).")
@@ -115543,7 +115993,7 @@ async function verifyOne(input) {
115543
115993
  };
115544
115994
  }
115545
115995
  }
115546
- const filePath = resolve33(context2.workingDirectory, path3);
115996
+ const filePath = resolve34(context2.workingDirectory, path3);
115547
115997
  try {
115548
115998
  const info = await stat16(filePath);
115549
115999
  if (!info.isFile()) {
@@ -119176,10 +119626,10 @@ var inputSchema20 = external_exports.object({
119176
119626
  job: external_exports.string().optional().describe("update/pause/resume/delete: job name"),
119177
119627
  allFolders: external_exports.boolean().optional().describe("list: include jobs of other folders (names only)")
119178
119628
  });
119179
- function refuse3(error) {
119629
+ function refuse4(error) {
119180
119630
  return { success: false, output: "", error };
119181
119631
  }
119182
- __name(refuse3, "refuse");
119632
+ __name(refuse4, "refuse");
119183
119633
  function effectsOf(rule) {
119184
119634
  if (typeof rule === "string")
119185
119635
  return [rule];
@@ -119268,27 +119718,27 @@ async function create(host, input, signal) {
119268
119718
  if (runKind !== "agent" && input.script === void 0)
119269
119719
  required.push("script");
119270
119720
  if (required.length > 0) {
119271
- return refuse3(`create needs ${required.join(", ")}. permissions is required: propose an explicit set (a preset and/or rules, plus unmatched).`);
119721
+ return refuse4(`create needs ${required.join(", ")}. permissions is required: propose an explicit set (a preset and/or rules, plus unmatched).`);
119272
119722
  }
119273
119723
  if (runKind === "agent" && input.script !== void 0) {
119274
- return refuse3("an agent job has no script; omit kind (or set it to agent) to use one");
119724
+ return refuse4("an agent job has no script; omit kind (or set it to agent) to use one");
119275
119725
  }
119276
119726
  if (input.workspace === "none" && runKind !== "script")
119277
- return refuse3("workspace: 'none' is only for a pure script job");
119727
+ return refuse4("workspace: 'none' is only for a pure script job");
119278
119728
  if (input.workspace === "none" && input.folder !== void 0)
119279
- return refuse3("workspace: 'none' cannot be combined with folder; omit folder");
119729
+ return refuse4("workspace: 'none' cannot be combined with folder; omit folder");
119280
119730
  if (input.script?.report !== void 0 && runKind !== "script")
119281
- return refuse3("script.report is only for a pure script job");
119731
+ return refuse4("script.report is only for a pure script job");
119282
119732
  if (runKind === "script" && input.prompt !== void 0)
119283
- return refuse3("a pure script job has no prompt; remove prompt");
119733
+ return refuse4("a pure script job has no prompt; remove prompt");
119284
119734
  if (runKind === "script" && input.budget !== void 0) {
119285
- return refuse3("a pure script job has no agent budget; remove budget and use script.timeoutMs for its timeout");
119735
+ return refuse4("a pure script job has no agent budget; remove budget and use script.timeoutMs for its timeout");
119286
119736
  }
119287
119737
  if (runKind === "script" && input.permissions?.browser !== void 0)
119288
- return refuse3("a pure script job cannot use a browser grant; remove permissions.browser");
119738
+ return refuse4("a pure script job cannot use a browser grant; remove permissions.browser");
119289
119739
  const checked2 = checkPermissions(host, input.permissions);
119290
119740
  if (!checked2.ok)
119291
- return refuse3(checked2.error);
119741
+ return refuse4(checked2.error);
119292
119742
  const permissions = checked2.permissions;
119293
119743
  const draft = {
119294
119744
  name: input.name,
@@ -119304,12 +119754,12 @@ async function create(host, input, signal) {
119304
119754
  ...input.budget ? { budget: input.budget } : {}
119305
119755
  };
119306
119756
  if (networkWithHostShell(draft))
119307
- return refuse3(NETWORK_WITH_HOST_SHELL);
119757
+ return refuse4(NETWORK_WITH_HOST_SHELL);
119308
119758
  let preview2;
119309
119759
  try {
119310
119760
  preview2 = await host.preview(draft);
119311
119761
  } catch (error) {
119312
- return refuse3(error instanceof Error ? error.message : String(error));
119762
+ return refuse4(error instanceof Error ? error.message : String(error));
119313
119763
  }
119314
119764
  let answer;
119315
119765
  try {
@@ -119345,7 +119795,7 @@ async function list(host, input) {
119345
119795
  try {
119346
119796
  jobs = await host.list({ allFolders: input.allFolders === true });
119347
119797
  } catch (error) {
119348
- return refuse3(error instanceof Error ? error.message : String(error));
119798
+ return refuse4(error instanceof Error ? error.message : String(error));
119349
119799
  }
119350
119800
  if (jobs.length === 0)
119351
119801
  return { success: true, output: "No scheduled jobs.", data: { jobs: [] } };
@@ -119367,31 +119817,31 @@ var CHANGEABLE = [
119367
119817
  ];
119368
119818
  async function update(host, input, signal) {
119369
119819
  if (!host.previewUpdate || !host.confirmUpdate || !host.update) {
119370
- return refuse3("This host cannot change a scheduled job. Ask the operator to change it themselves; do not delete and create it again, which loses its history.");
119820
+ return refuse4("This host cannot change a scheduled job. Ask the operator to change it themselves; do not delete and create it again, which loses its history.");
119371
119821
  }
119372
119822
  if (!input.job)
119373
- return refuse3("update needs job (the job's name) and the fields to change.");
119823
+ return refuse4("update needs job (the job's name) and the fields to change.");
119374
119824
  if (input.name !== void 0) {
119375
- return refuse3("update cannot rename a job: name the job to change with job, and leave name out.");
119825
+ return refuse4("update cannot rename a job: name the job to change with job, and leave name out.");
119376
119826
  }
119377
119827
  const given = CHANGEABLE.filter((k) => input[k] !== void 0);
119378
119828
  if (given.length === 0) {
119379
- return refuse3(`update needs at least one of ${CHANGEABLE.join(", ")} to change.`);
119829
+ return refuse4(`update needs at least one of ${CHANGEABLE.join(", ")} to change.`);
119380
119830
  }
119381
119831
  if (input.kind === "agent" && input.script !== void 0) {
119382
- return refuse3("update cannot set kind to agent while also giving a script; drop script to make it an agent job, or leave kind unset (or as script/script+agent) to keep one.");
119832
+ return refuse4("update cannot set kind to agent while also giving a script; drop script to make it an agent job, or leave kind unset (or as script/script+agent) to keep one.");
119383
119833
  }
119384
119834
  if (input.workspace === "none" && input.folder !== void 0)
119385
- return refuse3("workspace: 'none' cannot be combined with folder; omit folder");
119835
+ return refuse4("workspace: 'none' cannot be combined with folder; omit folder");
119386
119836
  if (input.workspace === "none" && input.kind !== void 0 && input.kind !== "script")
119387
- return refuse3("workspace: 'none' is only for a pure script job");
119837
+ return refuse4("workspace: 'none' is only for a pure script job");
119388
119838
  if (input.script?.report !== void 0 && input.kind !== void 0 && input.kind !== "script")
119389
- return refuse3("script.report is only for a pure script job");
119839
+ return refuse4("script.report is only for a pure script job");
119390
119840
  let permissions;
119391
119841
  if (input.permissions) {
119392
119842
  const checked2 = checkPermissions(host, input.permissions);
119393
119843
  if (!checked2.ok)
119394
- return refuse3(checked2.error);
119844
+ return refuse4(checked2.error);
119395
119845
  permissions = checked2.permissions;
119396
119846
  if (networkWithHostShell({
119397
119847
  name: "",
@@ -119400,7 +119850,7 @@ async function update(host, input, signal) {
119400
119850
  ...input.kind !== void 0 ? { runKind: input.kind } : {},
119401
119851
  permissions
119402
119852
  }))
119403
- return refuse3(NETWORK_WITH_HOST_SHELL);
119853
+ return refuse4(NETWORK_WITH_HOST_SHELL);
119404
119854
  }
119405
119855
  const changes = {
119406
119856
  ...input.prompt !== void 0 ? { prompt: input.prompt } : {},
@@ -119418,11 +119868,11 @@ async function update(host, input, signal) {
119418
119868
  try {
119419
119869
  proposal = await host.previewUpdate(input.job, changes);
119420
119870
  } catch (error) {
119421
- return refuse3(error instanceof Error ? error.message : String(error));
119871
+ return refuse4(error instanceof Error ? error.message : String(error));
119422
119872
  }
119423
119873
  const effectiveKind = input.kind ?? proposal.preview.runKind ?? "agent";
119424
119874
  if ((effectiveKind === "script" || effectiveKind === "script+agent") && proposal.preview.execution === "host" && (proposal.preview.networkGrantAccess ?? proposal.preview.networkAccess)) {
119425
- return refuse3(NETWORK_WITH_HOST_SHELL);
119875
+ return refuse4(NETWORK_WITH_HOST_SHELL);
119426
119876
  }
119427
119877
  let confirmed = false;
119428
119878
  try {
@@ -119438,7 +119888,7 @@ async function update(host, input, signal) {
119438
119888
  confirmed = false;
119439
119889
  if (!confirmed) {
119440
119890
  return {
119441
- ...refuse3(`The operator did not confirm the change; "${proposal.preview.name}" was not changed.`),
119891
+ ...refuse4(`The operator did not confirm the change; "${proposal.preview.name}" was not changed.`),
119442
119892
  data: { cancelled: true }
119443
119893
  };
119444
119894
  }
@@ -119446,7 +119896,7 @@ async function update(host, input, signal) {
119446
119896
  try {
119447
119897
  saved = await host.update(proposal.preview);
119448
119898
  } catch (error) {
119449
- return refuse3(error instanceof Error ? error.message : String(error));
119899
+ return refuse4(error instanceof Error ? error.message : String(error));
119450
119900
  }
119451
119901
  const said = `Job "${saved.name}" was updated in place and keeps its history. It runs ${proposal.preview.schedule}.`;
119452
119902
  return {
@@ -119458,10 +119908,10 @@ async function update(host, input, signal) {
119458
119908
  __name(update, "update");
119459
119909
  async function lifecycle(host, input, action, signal) {
119460
119910
  if (!input.job)
119461
- return refuse3(`${action} needs job (the job's name).`);
119911
+ return refuse4(`${action} needs job (the job's name).`);
119462
119912
  const job = await host.find(input.job);
119463
119913
  if (!job)
119464
- return refuse3(`No scheduled job is named "${input.job}".`);
119914
+ return refuse4(`No scheduled job is named "${input.job}".`);
119465
119915
  if (action !== "pause") {
119466
119916
  let confirmed = false;
119467
119917
  try {
@@ -119473,7 +119923,7 @@ async function lifecycle(host, input, action, signal) {
119473
119923
  confirmed = false;
119474
119924
  if (!confirmed)
119475
119925
  return {
119476
- ...refuse3(`The operator did not confirm; "${job.name}" was not changed.`),
119926
+ ...refuse4(`The operator did not confirm; "${job.name}" was not changed.`),
119477
119927
  data: { cancelled: true }
119478
119928
  };
119479
119929
  }
@@ -119485,7 +119935,7 @@ async function lifecycle(host, input, action, signal) {
119485
119935
  try {
119486
119936
  await host.delete(job.name);
119487
119937
  } catch (error) {
119488
- return refuse3(error instanceof Error ? error.message : String(error));
119938
+ return refuse4(error instanceof Error ? error.message : String(error));
119489
119939
  }
119490
119940
  }
119491
119941
  const verb = action === "pause" ? "paused" : action === "resume" ? "resumed" : "deleted";
@@ -120410,6 +120860,15 @@ export {
120410
120860
  compressShellOutputFull,
120411
120861
  compressShellOutput,
120412
120862
  memoizeAsync,
120863
+ NAMZU_TMPDIR_ENV,
120864
+ TempDirectoryError,
120865
+ resolveTempBase,
120866
+ privateTempRootPath,
120867
+ privateTempRoot,
120868
+ createTempDirSync,
120869
+ createTempDir,
120870
+ tempFilePath,
120871
+ ensureScratchpadDirectory,
120413
120872
  extractFinalResponse,
120414
120873
  resolveTaskModel,
120415
120874
  assertThinkingUnsupported,
@@ -120544,6 +121003,8 @@ export {
120544
121003
  DiskSessionLeaseStore,
120545
121004
  readSessionLease,
120546
121005
  InMemorySessionLeaseStore,
121006
+ sessionLogDegradedCause,
121007
+ DEFAULT_DEGRADED_BUFFER_BYTES,
120547
121008
  InvalidSessionRecordError,
120548
121009
  SessionLogConflictError,
120549
121010
  SessionLogCore,
@@ -121415,4 +121876,4 @@ export {
121415
121876
  WakeBudget,
121416
121877
  wakeBudgetFromEnv
121417
121878
  };
121418
- //# sourceMappingURL=chunk-4HL5LUP5.js.map
121879
+ //# sourceMappingURL=chunk-N4DSUOEW.js.map