@namzu/cli 50.1.0 → 50.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-PFKCDYRZ.js → acp-WZJUKMLZ.js} +73 -87
  4. package/dist/chunks/acp-WZJUKMLZ.js.map +6 -0
  5. package/dist/chunks/{activity-command-VZNRTS4Y.js → activity-command-WLHWANOB.js} +12 -12
  6. package/dist/chunks/{add-ILOY57M3.js → add-B55RR7FD.js} +19 -19
  7. package/dist/chunks/{agent-7XMB6YDL.js → agent-LG5LWVHS.js} +37 -35
  8. package/dist/chunks/agent-session-XZAD6VLV.js +69 -0
  9. package/dist/chunks/{archive-YUJITQ3K.js → archive-SJZ25KYL.js} +10 -10
  10. package/dist/chunks/{bin-main-QQCDUNOU.js → bin-main-2PGQSBXB.js} +7 -7
  11. package/dist/chunks/{binding-QXY72MYE.js → binding-L2VXM2X5.js} +3 -3
  12. package/dist/chunks/{browser-T5M3N46O.js → browser-5TFSC4LO.js} +6 -6
  13. package/dist/chunks/{chat-H6P7555R.js → chat-OFLDMKBR.js} +15 -15
  14. package/dist/chunks/{chunk-T4BQXXZS.js → chunk-24PL6U4S.js} +5 -5
  15. package/dist/chunks/{chunk-C2PBNQYT.js → chunk-2CSVXV4L.js} +10 -10
  16. package/dist/chunks/{chunk-4IP74K5V.js → chunk-2GYQWGJD.js} +2 -2
  17. package/dist/chunks/{chunk-IQPD7KYD.js → chunk-2IGQFWAB.js} +3 -3
  18. package/dist/chunks/{chunk-AKXUNA4X.js → chunk-3UXNHP3C.js} +6 -6
  19. package/dist/chunks/{chunk-FGEJOOL4.js → chunk-4H5G75XK.js} +3 -3
  20. package/dist/chunks/{chunk-CPWGSBBN.js → chunk-4LR6IOLQ.js} +3 -3
  21. package/dist/chunks/{chunk-GN424XZ3.js → chunk-4XN7DMZ6.js} +7 -7
  22. package/dist/chunks/{chunk-424T6RL4.js → chunk-5GVVNO7E.js} +2 -2
  23. package/dist/chunks/{chunk-UXXV6VCO.js → chunk-663XNTZ7.js} +3 -3
  24. package/dist/chunks/{chunk-GKPO6EGA.js → chunk-6BIE5DYM.js} +2 -2
  25. package/dist/chunks/{chunk-P2E6HFIP.js → chunk-6COBCXQV.js} +2 -2
  26. package/dist/chunks/{chunk-WTMP5H7T.js → chunk-6OVQ7YHB.js} +4 -4
  27. package/dist/chunks/{chunk-6X3NKVRL.js → chunk-7Q6ENTCV.js} +4 -4
  28. package/dist/chunks/{chunk-QPREGR6U.js → chunk-A75MGD3U.js} +4 -4
  29. package/dist/chunks/{chunk-UARXWUZO.js → chunk-AXXQTHGT.js} +4 -4
  30. package/dist/chunks/{chunk-T2DRSTJV.js → chunk-BCBTE5FC.js} +2 -2
  31. package/dist/chunks/{chunk-7VXBUWVA.js → chunk-BGJ77YZV.js} +2 -2
  32. package/dist/chunks/{chunk-SSPDO3JT.js → chunk-BH34ASBZ.js} +9 -9
  33. package/dist/chunks/{chunk-SB3GBZ65.js → chunk-CIIBX4PI.js} +3 -3
  34. package/dist/chunks/{chunk-JQUAYX3B.js → chunk-COF6PKWN.js} +5 -5
  35. package/dist/chunks/{chunk-RSAB3MPL.js → chunk-CTVEF75F.js} +11 -11
  36. package/dist/chunks/{chunk-URBIMXZN.js → chunk-DRTTUNNF.js} +6 -6
  37. package/dist/chunks/{chunk-HUKEVKWH.js → chunk-DSLM4DF6.js} +3 -3
  38. package/dist/chunks/{chunk-2FQ6QJIZ.js → chunk-DURIB5QE.js} +12 -12
  39. package/dist/chunks/{chunk-CFCULKSN.js → chunk-E3C3CMR6.js} +2 -2
  40. package/dist/chunks/{chunk-JGYCZO6C.js → chunk-EM4U3UY4.js} +2 -2
  41. package/dist/chunks/{chunk-QNIHTTLG.js → chunk-FP5BDOUA.js} +3 -3
  42. package/dist/chunks/{chunk-57EJUGDT.js → chunk-G6HVF7BU.js} +3 -3
  43. package/dist/chunks/{chunk-FXAHVRUE.js → chunk-GP4XESLU.js} +3 -3
  44. package/dist/chunks/{chunk-SFGTJCGU.js → chunk-GPMXLPTZ.js} +2 -2
  45. package/dist/chunks/{chunk-FIIZZRMV.js → chunk-HRA64D54.js} +3 -3
  46. package/dist/chunks/{chunk-XC6UYANY.js → chunk-I5JZS2ZI.js} +2 -2
  47. package/dist/chunks/{chunk-Z3DTGVZS.js → chunk-IX4YFVK5.js} +35 -33
  48. package/dist/chunks/{chunk-Z3DTGVZS.js.map → chunk-IX4YFVK5.js.map} +1 -1
  49. package/dist/chunks/{chunk-GL6KSVMS.js → chunk-IY5RBBRD.js} +9 -9
  50. package/dist/chunks/{chunk-CR23VYUE.js → chunk-J2Y2AOFX.js} +15 -14
  51. package/dist/chunks/{chunk-CR23VYUE.js.map → chunk-J2Y2AOFX.js.map} +1 -1
  52. package/dist/chunks/{chunk-IZHREIZK.js → chunk-J65LJILX.js} +192 -85
  53. package/dist/chunks/chunk-J65LJILX.js.map +6 -0
  54. package/dist/chunks/{chunk-IXNUPR24.js → chunk-JBMA7BRH.js} +33 -33
  55. package/dist/chunks/{chunk-K4PPNYXR.js → chunk-JMURF6AE.js} +2 -2
  56. package/dist/chunks/{chunk-SVB7IHBE.js → chunk-JREHAUBD.js} +3 -3
  57. package/dist/chunks/{chunk-HDOYZYBW.js → chunk-K7B7Z4OK.js} +3 -3
  58. package/dist/chunks/{chunk-EPDDCCV5.js → chunk-LD5TYFAP.js} +2 -2
  59. package/dist/chunks/{chunk-Y22AUU3X.js → chunk-LM37ASZT.js} +4 -4
  60. package/dist/chunks/{chunk-MAMV7MUG.js → chunk-LP4KMVFB.js} +9 -9
  61. package/dist/chunks/{chunk-ZJKISI2K.js → chunk-M62PUTES.js} +13 -5
  62. package/dist/chunks/chunk-M62PUTES.js.map +6 -0
  63. package/dist/chunks/{chunk-NXRUXNJ5.js → chunk-MAF7TNYC.js} +2 -2
  64. package/dist/chunks/{chunk-ZE6HLPD4.js → chunk-MJJAKWHU.js} +889 -319
  65. package/dist/chunks/chunk-MJJAKWHU.js.map +6 -0
  66. package/dist/chunks/{chunk-P7NXR4OV.js → chunk-NUYEA2GW.js} +4 -4
  67. package/dist/chunks/{chunk-WKW65PAC.js → chunk-OGGKA2PQ.js} +2 -2
  68. package/dist/chunks/{chunk-56WREK7X.js → chunk-OPQ2MCIJ.js} +2 -2
  69. package/dist/chunks/{chunk-PCW42R33.js → chunk-OV6445PV.js} +5 -5
  70. package/dist/chunks/{chunk-KKEWKJVL.js → chunk-PGMKME64.js} +3 -3
  71. package/dist/chunks/{chunk-G5OCRPZF.js → chunk-PUYFQ7HR.js} +2 -2
  72. package/dist/chunks/{chunk-RGUF5E22.js → chunk-PV6KTWLW.js} +4 -4
  73. package/dist/chunks/{chunk-RZ6PDAMQ.js → chunk-PVWX3NVL.js} +2 -2
  74. package/dist/chunks/{chunk-FM2QPMPK.js → chunk-PWGNLBJO.js} +2 -2
  75. package/dist/chunks/{chunk-S4Q4PC2L.js → chunk-QPG5YTSB.js} +5 -5
  76. package/dist/chunks/{chunk-S4Q4PC2L.js.map → chunk-QPG5YTSB.js.map} +1 -1
  77. package/dist/chunks/{chunk-ITNMS75R.js → chunk-QQ7MRKPH.js} +2 -2
  78. package/dist/chunks/{chunk-SECKALTU.js → chunk-QWVWNNP7.js} +2 -2
  79. package/dist/chunks/{chunk-SAJGEVVD.js → chunk-RHNZNUTG.js} +3 -3
  80. package/dist/chunks/{chunk-2BMVENUB.js → chunk-RLGZA2NG.js} +2 -2
  81. package/dist/chunks/{chunk-NVZRRJJS.js → chunk-RSP6O5OB.js} +2 -2
  82. package/dist/chunks/{chunk-XXHZE4KV.js → chunk-S2U2D4UF.js} +2 -2
  83. package/dist/chunks/{chunk-BIDU2JUB.js → chunk-SM2DUB7U.js} +2 -2
  84. package/dist/chunks/{chunk-E6BNHEYX.js → chunk-TZLJJJRB.js} +2 -2
  85. package/dist/chunks/{chunk-45PI33XV.js → chunk-VAOGSS7C.js} +3 -3
  86. package/dist/chunks/{chunk-D7W5LUXV.js → chunk-VCQOTSMI.js} +3 -3
  87. package/dist/chunks/{chunk-HNVUVSOI.js → chunk-VD6DYY42.js} +2 -2
  88. package/dist/chunks/{chunk-5WSDPQ3D.js → chunk-WLQ4EA3C.js} +4 -4
  89. package/dist/chunks/{chunk-HYUVSO4X.js → chunk-WWVFL5LP.js} +4 -4
  90. package/dist/chunks/{chunk-UBB7EIHC.js → chunk-XKX67QOT.js} +3 -3
  91. package/dist/chunks/{chunk-MIJGXF3Z.js → chunk-XLYTLAMO.js} +2 -2
  92. package/dist/chunks/{chunk-GWXAAFPJ.js → chunk-YFOTGPY7.js} +2 -2
  93. package/dist/chunks/{chunk-HYWVPQQD.js → chunk-YMQ7RDWK.js} +4 -4
  94. package/dist/chunks/{chunk-VQ7FOO7M.js → chunk-YYVKM3Z6.js} +2 -2
  95. package/dist/chunks/{chunk-IXDECEIX.js → chunk-ZS64S2KR.js} +4 -4
  96. package/dist/chunks/{cli-runtime-JXRGA4O7.js → cli-runtime-IRYWJ4X4.js} +11 -11
  97. package/dist/chunks/{commands-3K6WWRUN.js → commands-FXM7W42M.js} +5 -5
  98. package/dist/chunks/{crash-report-NTEADY4P.js → crash-report-ZOFOPOGE.js} +6 -6
  99. package/dist/chunks/{dist-CRT6EQAR.js → dist-2WXYB36H.js} +2 -2
  100. package/dist/chunks/{dist-EHAGNOTG.js → dist-ABFEAN2U.js} +2 -2
  101. package/dist/chunks/{dist-Z2QVC4OK.js → dist-QEI7QZKS.js} +2 -2
  102. package/dist/chunks/{dist-43NXQHZ2.js → dist-RVSYRVUG.js} +2 -2
  103. package/dist/chunks/{dist-G2QITXMW.js → dist-S3XEFHON.js} +2 -2
  104. package/dist/chunks/{dist-VEUKVTZP.js → dist-U2IASQF3.js} +2 -2
  105. package/dist/chunks/{dist-WDRMCFAU.js → dist-VG7K7T7Q.js} +6 -2
  106. package/dist/chunks/{dist-5ZAKSBZS.js → dist-ZMX2O2DP.js} +2 -2
  107. package/dist/chunks/{doctor-UVX6YR2I.js → doctor-KCCXSJVZ.js} +16 -16
  108. package/dist/chunks/{drain-URR6CUUH.js → drain-QLA4FGSV.js} +9 -9
  109. package/dist/chunks/{entry-WCWSORA2.js → entry-FHD4KBSM.js} +6 -6
  110. package/dist/chunks/{eval-Y6FUUDCX.js → eval-4O37Q6RK.js} +2 -2
  111. package/dist/chunks/{exec-5BUTAYMJ.js → exec-5YDDQJBB.js} +34 -34
  112. package/dist/chunks/{home-HDE3CFLB.js → home-33E6UFR7.js} +3 -3
  113. package/dist/chunks/{host-TZ6GSDWP.js → host-TBRXV7RU.js} +10 -10
  114. package/dist/chunks/{host-queries-Y7A4XJ64.js → host-queries-FKIZCZ4O.js} +15 -15
  115. package/dist/chunks/{learn-GYBZNIT3.js → learn-CXRBVPKA.js} +11 -11
  116. package/dist/chunks/{learn-builtin-EJXTHMX6.js → learn-builtin-OXXSTVYX.js} +14 -14
  117. package/dist/chunks/{lifecycle-5EM2QRFV.js → lifecycle-PTN5UDGT.js} +28 -28
  118. package/dist/chunks/{list-M34JU5AG.js → list-KUGDZNCZ.js} +11 -11
  119. package/dist/chunks/{live-XMBIOII4.js → live-PJUMYJWV.js} +15 -15
  120. package/dist/chunks/{login-NI3DFWOW.js → login-PI2CVLAL.js} +13 -13
  121. package/dist/chunks/{logs-OI6GZRRC.js → logs-YPFTNWHJ.js} +4 -4
  122. package/dist/chunks/{mcp-FK3OBBSJ.js → mcp-V7JIRXMM.js} +21 -21
  123. package/dist/chunks/{message-command-CIYB47HZ.js → message-command-GNTXQWWP.js} +41 -41
  124. package/dist/chunks/{open-XYGGZHXM.js → open-LQFYXJGO.js} +8 -8
  125. package/dist/chunks/{operator-tools-QSZS57PI.js → operator-tools-ODPPKZYO.js} +13 -13
  126. package/dist/chunks/{output-schema-BTNJ6DL5.js → output-schema-S5UX6KD4.js} +3 -3
  127. package/dist/chunks/{pal-EQAAJBWP.js → pal-PQP724JL.js} +16 -16
  128. package/dist/chunks/{peers-35H6CZOZ.js → peers-64WUYNO7.js} +7 -7
  129. package/dist/chunks/{peers-KN4BGJHU.js → peers-WF73HX4C.js} +6 -6
  130. package/dist/chunks/{providers-I2GONE3C.js → providers-SSGFWJ47.js} +11 -11
  131. package/dist/chunks/{pty-GZ4R2DCS.js → pty-CHKQPTIJ.js} +3 -3
  132. package/dist/chunks/resume-32TSOW5K.js +23 -0
  133. package/dist/chunks/{resume-command-TOAGIGZO.js → resume-command-PDAWC5OQ.js} +4 -4
  134. package/dist/chunks/{schedule-FU5WY3WV.js → schedule-DOUPTTHG.js} +8 -8
  135. package/dist/chunks/{service-3UYEV4JX.js → service-LQRXWFGJ.js} +28 -28
  136. package/dist/chunks/{skills-4V2SBEY3.js → skills-YVKSFMOJ.js} +8 -8
  137. package/dist/chunks/{start-check-RBYWVZT4.js → start-check-O4VN7KQQ.js} +2 -2
  138. package/dist/chunks/{startup-failure-SST73T7Q.js → startup-failure-MX3RDAVD.js} +2 -2
  139. package/dist/chunks/{state-N46ZI3LZ.js → state-SAFS7RR2.js} +2 -2
  140. package/dist/chunks/{store-M56FSIZT.js → store-5N2RJTS7.js} +6 -6
  141. package/dist/chunks/{store-KA6NETSP.js → store-DZQLPD24.js} +3 -3
  142. package/dist/chunks/{store-R662Y2YQ.js → store-QT2Z3BMR.js} +14 -10
  143. package/dist/chunks/{store-RHAHG45U.js → store-RNO4PTEJ.js} +4 -4
  144. package/dist/chunks/{tui-TJNH67YO.js → tui-SAH75DVX.js} +66 -66
  145. package/dist/chunks/{tui-TJNH67YO.js.map → tui-SAH75DVX.js.map} +1 -1
  146. package/dist/chunks/{upgrade-YNYPRYFI.js → upgrade-Z5LLWZN4.js} +7 -7
  147. package/dist/chunks/{workspaces-OITS2AZJ.js → workspaces-2BQK5RIW.js} +16 -16
  148. package/dist/chunks/{worktree-DJW4XCBG.js → worktree-4LIJQ2FK.js} +12 -12
  149. package/dist/commands/acp-harness.d.ts.map +1 -1
  150. package/dist/commands/acp-provider-retry.d.ts.map +1 -1
  151. package/dist/commands/acp.d.ts.map +1 -1
  152. package/dist/commands/desktop-host.d.ts.map +1 -1
  153. package/dist/config/load.d.ts.map +1 -1
  154. package/dist/config/schema.d.ts +10 -0
  155. package/dist/config/schema.d.ts.map +1 -1
  156. package/dist/config/settings-descriptors.d.ts.map +1 -1
  157. package/dist/index.js +19 -19
  158. package/dist/integrations/sessions/conversation-facts.d.ts +76 -0
  159. package/dist/integrations/sessions/conversation-facts.d.ts.map +1 -0
  160. package/dist/integrations/sessions/store.d.ts +22 -18
  161. package/dist/integrations/sessions/store.d.ts.map +1 -1
  162. package/dist/schedule/daemon/sessions.d.ts +3 -3
  163. package/dist/schedule/daemon/sessions.d.ts.map +1 -1
  164. package/dist/tui/agent.d.ts +3 -1
  165. package/dist/tui/agent.d.ts.map +1 -1
  166. package/package.json +4 -4
  167. package/dist/chunks/acp-PFKCDYRZ.js.map +0 -6
  168. package/dist/chunks/agent-session-EJPBND2I.js +0 -69
  169. package/dist/chunks/chunk-IZHREIZK.js.map +0 -6
  170. package/dist/chunks/chunk-ZE6HLPD4.js.map +0 -6
  171. package/dist/chunks/chunk-ZJKISI2K.js.map +0 -6
  172. package/dist/chunks/resume-4KW4GUYR.js +0 -23
  173. /package/dist/chunks/{activity-command-VZNRTS4Y.js.map → activity-command-WLHWANOB.js.map} +0 -0
  174. /package/dist/chunks/{add-ILOY57M3.js.map → add-B55RR7FD.js.map} +0 -0
  175. /package/dist/chunks/{agent-7XMB6YDL.js.map → agent-LG5LWVHS.js.map} +0 -0
  176. /package/dist/chunks/{agent-session-EJPBND2I.js.map → agent-session-XZAD6VLV.js.map} +0 -0
  177. /package/dist/chunks/{archive-YUJITQ3K.js.map → archive-SJZ25KYL.js.map} +0 -0
  178. /package/dist/chunks/{bin-main-QQCDUNOU.js.map → bin-main-2PGQSBXB.js.map} +0 -0
  179. /package/dist/chunks/{binding-QXY72MYE.js.map → binding-L2VXM2X5.js.map} +0 -0
  180. /package/dist/chunks/{browser-T5M3N46O.js.map → browser-5TFSC4LO.js.map} +0 -0
  181. /package/dist/chunks/{chat-H6P7555R.js.map → chat-OFLDMKBR.js.map} +0 -0
  182. /package/dist/chunks/{chunk-T4BQXXZS.js.map → chunk-24PL6U4S.js.map} +0 -0
  183. /package/dist/chunks/{chunk-C2PBNQYT.js.map → chunk-2CSVXV4L.js.map} +0 -0
  184. /package/dist/chunks/{chunk-4IP74K5V.js.map → chunk-2GYQWGJD.js.map} +0 -0
  185. /package/dist/chunks/{chunk-IQPD7KYD.js.map → chunk-2IGQFWAB.js.map} +0 -0
  186. /package/dist/chunks/{chunk-AKXUNA4X.js.map → chunk-3UXNHP3C.js.map} +0 -0
  187. /package/dist/chunks/{chunk-FGEJOOL4.js.map → chunk-4H5G75XK.js.map} +0 -0
  188. /package/dist/chunks/{chunk-CPWGSBBN.js.map → chunk-4LR6IOLQ.js.map} +0 -0
  189. /package/dist/chunks/{chunk-GN424XZ3.js.map → chunk-4XN7DMZ6.js.map} +0 -0
  190. /package/dist/chunks/{chunk-424T6RL4.js.map → chunk-5GVVNO7E.js.map} +0 -0
  191. /package/dist/chunks/{chunk-UXXV6VCO.js.map → chunk-663XNTZ7.js.map} +0 -0
  192. /package/dist/chunks/{chunk-GKPO6EGA.js.map → chunk-6BIE5DYM.js.map} +0 -0
  193. /package/dist/chunks/{chunk-P2E6HFIP.js.map → chunk-6COBCXQV.js.map} +0 -0
  194. /package/dist/chunks/{chunk-WTMP5H7T.js.map → chunk-6OVQ7YHB.js.map} +0 -0
  195. /package/dist/chunks/{chunk-6X3NKVRL.js.map → chunk-7Q6ENTCV.js.map} +0 -0
  196. /package/dist/chunks/{chunk-QPREGR6U.js.map → chunk-A75MGD3U.js.map} +0 -0
  197. /package/dist/chunks/{chunk-UARXWUZO.js.map → chunk-AXXQTHGT.js.map} +0 -0
  198. /package/dist/chunks/{chunk-T2DRSTJV.js.map → chunk-BCBTE5FC.js.map} +0 -0
  199. /package/dist/chunks/{chunk-7VXBUWVA.js.map → chunk-BGJ77YZV.js.map} +0 -0
  200. /package/dist/chunks/{chunk-SSPDO3JT.js.map → chunk-BH34ASBZ.js.map} +0 -0
  201. /package/dist/chunks/{chunk-SB3GBZ65.js.map → chunk-CIIBX4PI.js.map} +0 -0
  202. /package/dist/chunks/{chunk-JQUAYX3B.js.map → chunk-COF6PKWN.js.map} +0 -0
  203. /package/dist/chunks/{chunk-RSAB3MPL.js.map → chunk-CTVEF75F.js.map} +0 -0
  204. /package/dist/chunks/{chunk-URBIMXZN.js.map → chunk-DRTTUNNF.js.map} +0 -0
  205. /package/dist/chunks/{chunk-HUKEVKWH.js.map → chunk-DSLM4DF6.js.map} +0 -0
  206. /package/dist/chunks/{chunk-2FQ6QJIZ.js.map → chunk-DURIB5QE.js.map} +0 -0
  207. /package/dist/chunks/{chunk-CFCULKSN.js.map → chunk-E3C3CMR6.js.map} +0 -0
  208. /package/dist/chunks/{chunk-JGYCZO6C.js.map → chunk-EM4U3UY4.js.map} +0 -0
  209. /package/dist/chunks/{chunk-QNIHTTLG.js.map → chunk-FP5BDOUA.js.map} +0 -0
  210. /package/dist/chunks/{chunk-57EJUGDT.js.map → chunk-G6HVF7BU.js.map} +0 -0
  211. /package/dist/chunks/{chunk-FXAHVRUE.js.map → chunk-GP4XESLU.js.map} +0 -0
  212. /package/dist/chunks/{chunk-SFGTJCGU.js.map → chunk-GPMXLPTZ.js.map} +0 -0
  213. /package/dist/chunks/{chunk-FIIZZRMV.js.map → chunk-HRA64D54.js.map} +0 -0
  214. /package/dist/chunks/{chunk-XC6UYANY.js.map → chunk-I5JZS2ZI.js.map} +0 -0
  215. /package/dist/chunks/{chunk-GL6KSVMS.js.map → chunk-IY5RBBRD.js.map} +0 -0
  216. /package/dist/chunks/{chunk-IXNUPR24.js.map → chunk-JBMA7BRH.js.map} +0 -0
  217. /package/dist/chunks/{chunk-K4PPNYXR.js.map → chunk-JMURF6AE.js.map} +0 -0
  218. /package/dist/chunks/{chunk-SVB7IHBE.js.map → chunk-JREHAUBD.js.map} +0 -0
  219. /package/dist/chunks/{chunk-HDOYZYBW.js.map → chunk-K7B7Z4OK.js.map} +0 -0
  220. /package/dist/chunks/{chunk-EPDDCCV5.js.map → chunk-LD5TYFAP.js.map} +0 -0
  221. /package/dist/chunks/{chunk-Y22AUU3X.js.map → chunk-LM37ASZT.js.map} +0 -0
  222. /package/dist/chunks/{chunk-MAMV7MUG.js.map → chunk-LP4KMVFB.js.map} +0 -0
  223. /package/dist/chunks/{chunk-NXRUXNJ5.js.map → chunk-MAF7TNYC.js.map} +0 -0
  224. /package/dist/chunks/{chunk-P7NXR4OV.js.map → chunk-NUYEA2GW.js.map} +0 -0
  225. /package/dist/chunks/{chunk-WKW65PAC.js.map → chunk-OGGKA2PQ.js.map} +0 -0
  226. /package/dist/chunks/{chunk-56WREK7X.js.map → chunk-OPQ2MCIJ.js.map} +0 -0
  227. /package/dist/chunks/{chunk-PCW42R33.js.map → chunk-OV6445PV.js.map} +0 -0
  228. /package/dist/chunks/{chunk-KKEWKJVL.js.map → chunk-PGMKME64.js.map} +0 -0
  229. /package/dist/chunks/{chunk-G5OCRPZF.js.map → chunk-PUYFQ7HR.js.map} +0 -0
  230. /package/dist/chunks/{chunk-RGUF5E22.js.map → chunk-PV6KTWLW.js.map} +0 -0
  231. /package/dist/chunks/{chunk-RZ6PDAMQ.js.map → chunk-PVWX3NVL.js.map} +0 -0
  232. /package/dist/chunks/{chunk-FM2QPMPK.js.map → chunk-PWGNLBJO.js.map} +0 -0
  233. /package/dist/chunks/{chunk-ITNMS75R.js.map → chunk-QQ7MRKPH.js.map} +0 -0
  234. /package/dist/chunks/{chunk-SECKALTU.js.map → chunk-QWVWNNP7.js.map} +0 -0
  235. /package/dist/chunks/{chunk-SAJGEVVD.js.map → chunk-RHNZNUTG.js.map} +0 -0
  236. /package/dist/chunks/{chunk-2BMVENUB.js.map → chunk-RLGZA2NG.js.map} +0 -0
  237. /package/dist/chunks/{chunk-NVZRRJJS.js.map → chunk-RSP6O5OB.js.map} +0 -0
  238. /package/dist/chunks/{chunk-XXHZE4KV.js.map → chunk-S2U2D4UF.js.map} +0 -0
  239. /package/dist/chunks/{chunk-BIDU2JUB.js.map → chunk-SM2DUB7U.js.map} +0 -0
  240. /package/dist/chunks/{chunk-E6BNHEYX.js.map → chunk-TZLJJJRB.js.map} +0 -0
  241. /package/dist/chunks/{chunk-45PI33XV.js.map → chunk-VAOGSS7C.js.map} +0 -0
  242. /package/dist/chunks/{chunk-D7W5LUXV.js.map → chunk-VCQOTSMI.js.map} +0 -0
  243. /package/dist/chunks/{chunk-HNVUVSOI.js.map → chunk-VD6DYY42.js.map} +0 -0
  244. /package/dist/chunks/{chunk-5WSDPQ3D.js.map → chunk-WLQ4EA3C.js.map} +0 -0
  245. /package/dist/chunks/{chunk-HYUVSO4X.js.map → chunk-WWVFL5LP.js.map} +0 -0
  246. /package/dist/chunks/{chunk-UBB7EIHC.js.map → chunk-XKX67QOT.js.map} +0 -0
  247. /package/dist/chunks/{chunk-MIJGXF3Z.js.map → chunk-XLYTLAMO.js.map} +0 -0
  248. /package/dist/chunks/{chunk-GWXAAFPJ.js.map → chunk-YFOTGPY7.js.map} +0 -0
  249. /package/dist/chunks/{chunk-HYWVPQQD.js.map → chunk-YMQ7RDWK.js.map} +0 -0
  250. /package/dist/chunks/{chunk-VQ7FOO7M.js.map → chunk-YYVKM3Z6.js.map} +0 -0
  251. /package/dist/chunks/{chunk-IXDECEIX.js.map → chunk-ZS64S2KR.js.map} +0 -0
  252. /package/dist/chunks/{cli-runtime-JXRGA4O7.js.map → cli-runtime-IRYWJ4X4.js.map} +0 -0
  253. /package/dist/chunks/{commands-3K6WWRUN.js.map → commands-FXM7W42M.js.map} +0 -0
  254. /package/dist/chunks/{crash-report-NTEADY4P.js.map → crash-report-ZOFOPOGE.js.map} +0 -0
  255. /package/dist/chunks/{dist-CRT6EQAR.js.map → dist-2WXYB36H.js.map} +0 -0
  256. /package/dist/chunks/{dist-EHAGNOTG.js.map → dist-ABFEAN2U.js.map} +0 -0
  257. /package/dist/chunks/{dist-Z2QVC4OK.js.map → dist-QEI7QZKS.js.map} +0 -0
  258. /package/dist/chunks/{dist-43NXQHZ2.js.map → dist-RVSYRVUG.js.map} +0 -0
  259. /package/dist/chunks/{dist-G2QITXMW.js.map → dist-S3XEFHON.js.map} +0 -0
  260. /package/dist/chunks/{dist-VEUKVTZP.js.map → dist-U2IASQF3.js.map} +0 -0
  261. /package/dist/chunks/{dist-WDRMCFAU.js.map → dist-VG7K7T7Q.js.map} +0 -0
  262. /package/dist/chunks/{dist-5ZAKSBZS.js.map → dist-ZMX2O2DP.js.map} +0 -0
  263. /package/dist/chunks/{doctor-UVX6YR2I.js.map → doctor-KCCXSJVZ.js.map} +0 -0
  264. /package/dist/chunks/{drain-URR6CUUH.js.map → drain-QLA4FGSV.js.map} +0 -0
  265. /package/dist/chunks/{entry-WCWSORA2.js.map → entry-FHD4KBSM.js.map} +0 -0
  266. /package/dist/chunks/{eval-Y6FUUDCX.js.map → eval-4O37Q6RK.js.map} +0 -0
  267. /package/dist/chunks/{exec-5BUTAYMJ.js.map → exec-5YDDQJBB.js.map} +0 -0
  268. /package/dist/chunks/{home-HDE3CFLB.js.map → home-33E6UFR7.js.map} +0 -0
  269. /package/dist/chunks/{host-TZ6GSDWP.js.map → host-TBRXV7RU.js.map} +0 -0
  270. /package/dist/chunks/{host-queries-Y7A4XJ64.js.map → host-queries-FKIZCZ4O.js.map} +0 -0
  271. /package/dist/chunks/{learn-GYBZNIT3.js.map → learn-CXRBVPKA.js.map} +0 -0
  272. /package/dist/chunks/{learn-builtin-EJXTHMX6.js.map → learn-builtin-OXXSTVYX.js.map} +0 -0
  273. /package/dist/chunks/{lifecycle-5EM2QRFV.js.map → lifecycle-PTN5UDGT.js.map} +0 -0
  274. /package/dist/chunks/{list-M34JU5AG.js.map → list-KUGDZNCZ.js.map} +0 -0
  275. /package/dist/chunks/{live-XMBIOII4.js.map → live-PJUMYJWV.js.map} +0 -0
  276. /package/dist/chunks/{login-NI3DFWOW.js.map → login-PI2CVLAL.js.map} +0 -0
  277. /package/dist/chunks/{logs-OI6GZRRC.js.map → logs-YPFTNWHJ.js.map} +0 -0
  278. /package/dist/chunks/{mcp-FK3OBBSJ.js.map → mcp-V7JIRXMM.js.map} +0 -0
  279. /package/dist/chunks/{message-command-CIYB47HZ.js.map → message-command-GNTXQWWP.js.map} +0 -0
  280. /package/dist/chunks/{open-XYGGZHXM.js.map → open-LQFYXJGO.js.map} +0 -0
  281. /package/dist/chunks/{operator-tools-QSZS57PI.js.map → operator-tools-ODPPKZYO.js.map} +0 -0
  282. /package/dist/chunks/{output-schema-BTNJ6DL5.js.map → output-schema-S5UX6KD4.js.map} +0 -0
  283. /package/dist/chunks/{pal-EQAAJBWP.js.map → pal-PQP724JL.js.map} +0 -0
  284. /package/dist/chunks/{peers-35H6CZOZ.js.map → peers-64WUYNO7.js.map} +0 -0
  285. /package/dist/chunks/{peers-KN4BGJHU.js.map → peers-WF73HX4C.js.map} +0 -0
  286. /package/dist/chunks/{providers-I2GONE3C.js.map → providers-SSGFWJ47.js.map} +0 -0
  287. /package/dist/chunks/{pty-GZ4R2DCS.js.map → pty-CHKQPTIJ.js.map} +0 -0
  288. /package/dist/chunks/{resume-4KW4GUYR.js.map → resume-32TSOW5K.js.map} +0 -0
  289. /package/dist/chunks/{resume-command-TOAGIGZO.js.map → resume-command-PDAWC5OQ.js.map} +0 -0
  290. /package/dist/chunks/{schedule-FU5WY3WV.js.map → schedule-DOUPTTHG.js.map} +0 -0
  291. /package/dist/chunks/{service-3UYEV4JX.js.map → service-LQRXWFGJ.js.map} +0 -0
  292. /package/dist/chunks/{skills-4V2SBEY3.js.map → skills-YVKSFMOJ.js.map} +0 -0
  293. /package/dist/chunks/{start-check-RBYWVZT4.js.map → start-check-O4VN7KQQ.js.map} +0 -0
  294. /package/dist/chunks/{startup-failure-SST73T7Q.js.map → startup-failure-MX3RDAVD.js.map} +0 -0
  295. /package/dist/chunks/{state-N46ZI3LZ.js.map → state-SAFS7RR2.js.map} +0 -0
  296. /package/dist/chunks/{store-KA6NETSP.js.map → store-5N2RJTS7.js.map} +0 -0
  297. /package/dist/chunks/{store-M56FSIZT.js.map → store-DZQLPD24.js.map} +0 -0
  298. /package/dist/chunks/{store-R662Y2YQ.js.map → store-QT2Z3BMR.js.map} +0 -0
  299. /package/dist/chunks/{store-RHAHG45U.js.map → store-RNO4PTEJ.js.map} +0 -0
  300. /package/dist/chunks/{upgrade-YNYPRYFI.js.map → upgrade-Z5LLWZN4.js.map} +0 -0
  301. /package/dist/chunks/{workspaces-OITS2AZJ.js.map → workspaces-2BQK5RIW.js.map} +0 -0
  302. /package/dist/chunks/{worktree-DJW4XCBG.js.map → worktree-4LIJQ2FK.js.map} +0 -0
@@ -325,7 +325,7 @@ var require_brace_expansion = __commonJS({
325
325
  });
326
326
 
327
327
  // ../sdk/dist/version.js
328
- var VERSION = "62.8.0";
328
+ var VERSION = "62.9.0";
329
329
 
330
330
  // ../sdk/dist/runtime/harness-session/index.js
331
331
  import { posix, win32 } from "node:path";
@@ -28543,6 +28543,20 @@ var CompactionConfigSchema = external_exports.object({
28543
28543
  * `triggerThreshold` summarises. The context is held around here.
28544
28544
  */
28545
28545
  softTarget: external_exports.number().min(0).max(1).optional(),
28546
+ /**
28547
+ * `salience` only: how far below `softTarget`, as a fraction of the
28548
+ * window, a pass sheds. A pass still starts when the context reaches the
28549
+ * soft target, but it then keeps shedding until the context is
28550
+ * `softTargetHeadroom` of the window under it, so the next pass is needed
28551
+ * only after that headroom has been used instead of on the next turn.
28552
+ * Fewer passes, and the request is rewritten (a prompt cache's prefix
28553
+ * broken) once per headroom instead of once per turn; the cost is that
28554
+ * the context is held that much lower, so that much less history stays
28555
+ * whole. The messages shed are the same ones in the same order, only
28556
+ * earlier. Absent or `0`, the default, a pass sheds to the soft target
28557
+ * and no further, exactly as before.
28558
+ */
28559
+ softTargetHeadroom: external_exports.number().min(0).max(1).optional(),
28546
28560
  /**
28547
28561
  * Optional model context-window size (tokens) the compaction trigger
28548
28562
  * measures the CURRENT window against. NO default: when omitted the
@@ -30437,12 +30451,12 @@ function applyTemplate(record4) {
30437
30451
  __name(applyTemplate, "applyTemplate");
30438
30452
  var PALETTE = [31, 32, 33, 34, 35, 36, 91, 92];
30439
30453
  function scopeColour(scope) {
30440
- let hash3 = 2166136261;
30454
+ let hash4 = 2166136261;
30441
30455
  for (let i = 0; i < scope.length; i++) {
30442
- hash3 ^= scope.charCodeAt(i);
30443
- hash3 = Math.imul(hash3, 16777619);
30456
+ hash4 ^= scope.charCodeAt(i);
30457
+ hash4 = Math.imul(hash4, 16777619);
30444
30458
  }
30445
- return PALETTE[Math.abs(hash3) % PALETTE.length];
30459
+ return PALETTE[Math.abs(hash4) % PALETTE.length];
30446
30460
  }
30447
30461
  __name(scopeColour, "scopeColour");
30448
30462
 
@@ -41337,6 +41351,13 @@ var MessageReplacedRecordSchema = recordSchema("message_replaced", {
41337
41351
  "history-repair"
41338
41352
  ])
41339
41353
  });
41354
+ var MessageEditedRecordSchema = inTurn("message_edited", {
41355
+ ignorable: external_exports.literal(true),
41356
+ targetMessageId: messageId2,
41357
+ content: messageBody,
41358
+ spill: spill.optional(),
41359
+ reason: text4.min(1)
41360
+ });
41340
41361
  var CheckpointWrittenRecordSchema = inTurn("checkpoint_written", {
41341
41362
  checkpointId,
41342
41363
  iteration: count4,
@@ -41462,6 +41483,7 @@ var RECORD_ONLY_SCHEMAS = {
41462
41483
  session_updated: SessionUpdatedRecordSchema,
41463
41484
  message: MessageRecordSchema,
41464
41485
  message_replaced: MessageReplacedRecordSchema,
41486
+ message_edited: MessageEditedRecordSchema,
41465
41487
  checkpoint_written: CheckpointWrittenRecordSchema,
41466
41488
  checkpoint_pruned: CheckpointPrunedRecordSchema,
41467
41489
  decision_requested: DecisionRequestedRecordSchema,
@@ -41863,6 +41885,9 @@ function childSessionLog(childSessionId) {
41863
41885
  }
41864
41886
  __name(childSessionLog, "childSessionLog");
41865
41887
 
41888
+ // ../sdk/dist/manager/session/turn-recorder.js
41889
+ import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
41890
+
41866
41891
  // ../sdk/dist/session/log-hash.js
41867
41892
  import { createHash as createHash6 } from "node:crypto";
41868
41893
  var NEWLINE = 10;
@@ -42164,7 +42189,11 @@ async function foldSessionLog(log, fold4) {
42164
42189
  }
42165
42190
  let moved = false;
42166
42191
  try {
42167
- const walk2 = log.read({ mode: fold4.mode, ...anchor2 ? { after: anchor2 } : {} });
42192
+ const walk2 = log.read({
42193
+ mode: fold4.mode,
42194
+ ...anchor2 ? { after: anchor2 } : {},
42195
+ ...fold4.reverify && fold4.mode === "strict" ? { reverify: true } : {}
42196
+ });
42168
42197
  let summary2;
42169
42198
  for (; ; ) {
42170
42199
  summary2 = await walk2.next();
@@ -42269,7 +42298,8 @@ var SessionMessageFold = class {
42269
42298
  case "message":
42270
42299
  this.#message(record4);
42271
42300
  return;
42272
- case "message_replaced": {
42301
+ case "message_replaced":
42302
+ case "message_edited": {
42273
42303
  const spill3 = record4.spill;
42274
42304
  this.#replacements.set(record4.targetMessageId, {
42275
42305
  message: record4.content,
@@ -42384,7 +42414,7 @@ var TurnRuleError = class extends Error {
42384
42414
  }
42385
42415
  name = "TurnRuleError";
42386
42416
  };
42387
- var SessionTurnState = class {
42417
+ var SessionTurnState = class _SessionTurnState {
42388
42418
  static {
42389
42419
  __name(this, "SessionTurnState");
42390
42420
  }
@@ -42394,6 +42424,17 @@ var SessionTurnState = class {
42394
42424
  get active() {
42395
42425
  return this.#active;
42396
42426
  }
42427
+ /**
42428
+ * An independent copy at the records applied so far. `apply` replaces the
42429
+ * active turn's object rather than editing it, so the copy may share it.
42430
+ */
42431
+ clone() {
42432
+ const copy = new _SessionTurnState();
42433
+ copy.#active = this.#active;
42434
+ copy.#lastTurnId = this.#lastTurnId;
42435
+ copy.#started = this.#started;
42436
+ return copy;
42437
+ }
42397
42438
  /** The last turn that started, active or not. */
42398
42439
  get lastTurnId() {
42399
42440
  return this.#lastTurnId;
@@ -42492,6 +42533,7 @@ var CLOSES_OR_DECIDES = /* @__PURE__ */ new Set([
42492
42533
  "audit",
42493
42534
  "log_repaired",
42494
42535
  "message_replaced",
42536
+ "message_edited",
42495
42537
  "session_updated"
42496
42538
  ]);
42497
42539
 
@@ -43169,6 +43211,188 @@ async function restoreSpilledRequestInputs(request, read) {
43169
43211
  }
43170
43212
  __name(restoreSpilledRequestInputs, "restoreSpilledRequestInputs");
43171
43213
 
43214
+ // ../sdk/dist/store/session-log/verified-prefix.js
43215
+ import * as crypto from "node:crypto";
43216
+ var DIGEST_BYTES = 32;
43217
+ var LEDGERS_KEPT = 16;
43218
+ var MAX_RECORDS = 1 << 21;
43219
+ var hexDigestOf = typeof crypto.hash === "function" ? (line) => crypto.hash("sha256", line, "hex") : (line) => crypto.createHash("sha256").update(line).digest("hex");
43220
+ function hexEqualsBytes(hex4, bytes, at) {
43221
+ if (hex4.length !== DIGEST_BYTES * 2)
43222
+ return false;
43223
+ for (let i = 0; i < DIGEST_BYTES; i++) {
43224
+ const high = hex4.charCodeAt(i * 2);
43225
+ const low = hex4.charCodeAt(i * 2 + 1);
43226
+ const value = (high <= 57 ? high - 48 : high - 87) << 4 | (low <= 57 ? low - 48 : low - 87);
43227
+ if (value !== bytes[at + i])
43228
+ return false;
43229
+ }
43230
+ return true;
43231
+ }
43232
+ __name(hexEqualsBytes, "hexEqualsBytes");
43233
+ var VerifiedPrefix = class {
43234
+ static {
43235
+ __name(this, "VerifiedPrefix");
43236
+ }
43237
+ #count = 0;
43238
+ #lengths = new Uint32Array(1024);
43239
+ #digests = Buffer.allocUnsafe(1024 * DIGEST_BYTES);
43240
+ #head = null;
43241
+ #gen = 0;
43242
+ #sessionId;
43243
+ #end = 0;
43244
+ #dead = false;
43245
+ #turns = new SessionTurnState();
43246
+ /** Records remembered. */
43247
+ get count() {
43248
+ return this.#count;
43249
+ }
43250
+ get head() {
43251
+ return this.#head;
43252
+ }
43253
+ get gen() {
43254
+ return this.#gen;
43255
+ }
43256
+ get sessionId() {
43257
+ return this.#sessionId;
43258
+ }
43259
+ /** Byte offset just after the last remembered record. */
43260
+ get end() {
43261
+ return this.#end;
43262
+ }
43263
+ /** The turn state at the head, as its own copy. */
43264
+ turns() {
43265
+ return this.#turns.clone();
43266
+ }
43267
+ /** Lengths and digests as they stand now; entries below `count` never change. */
43268
+ get lengths() {
43269
+ return this.#lengths;
43270
+ }
43271
+ get digests() {
43272
+ return this.#digests;
43273
+ }
43274
+ /** Whether the remembered record `seq` is exactly `pointer` (length and digest). */
43275
+ holds(pointer2) {
43276
+ const at = pointer2.seq - 1;
43277
+ if (at < 0 || at >= this.#count)
43278
+ return false;
43279
+ if (this.#lengths[at] !== pointer2.length)
43280
+ return false;
43281
+ return this.#digests.toString("hex", at * DIGEST_BYTES, (at + 1) * DIGEST_BYTES) === pointer2.sha256;
43282
+ }
43283
+ /**
43284
+ * Remember a record that was verified in full. Ignored unless it continues
43285
+ * what is held: the next seq, naming the head by its pointer.
43286
+ */
43287
+ append(entry) {
43288
+ if (this.#dead)
43289
+ return;
43290
+ const { record: record4, pointer: pointer2 } = entry;
43291
+ if (pointer2.seq !== this.#count + 1 || pointer2.offset !== this.#end)
43292
+ return;
43293
+ const prev = record4.prev;
43294
+ if (this.#head === null ? prev !== null : !samePointer2(prev, this.#head))
43295
+ return;
43296
+ if (this.#sessionId !== void 0 && record4.sessionId !== this.#sessionId)
43297
+ return;
43298
+ if (this.#count >= MAX_RECORDS) {
43299
+ this.#dead = true;
43300
+ return;
43301
+ }
43302
+ if (this.#count === this.#lengths.length) {
43303
+ const lengths = new Uint32Array(this.#lengths.length * 2);
43304
+ lengths.set(this.#lengths);
43305
+ this.#lengths = lengths;
43306
+ const digests = Buffer.allocUnsafe(this.#digests.length * 2);
43307
+ this.#digests.copy(digests);
43308
+ this.#digests = digests;
43309
+ }
43310
+ this.#lengths[this.#count] = pointer2.length;
43311
+ this.#digests.write(pointer2.sha256, this.#count * DIGEST_BYTES, DIGEST_BYTES, "hex");
43312
+ this.#count += 1;
43313
+ this.#head = pointer2;
43314
+ this.#gen = record4.gen;
43315
+ this.#end = pointer2.offset + pointer2.length;
43316
+ this.#sessionId ??= record4.sessionId;
43317
+ this.#turns.apply(record4);
43318
+ }
43319
+ };
43320
+ function samePointer2(a, b) {
43321
+ return a !== null && a !== void 0 && a.seq === b.seq && a.offset === b.offset && a.length === b.length && a.sha256 === b.sha256;
43322
+ }
43323
+ __name(samePointer2, "samePointer");
43324
+ var ledgers = /* @__PURE__ */ new Map();
43325
+ function verifiedPrefixOf(key6) {
43326
+ const found = ledgers.get(key6);
43327
+ if (found !== void 0) {
43328
+ ledgers.delete(key6);
43329
+ ledgers.set(key6, found);
43330
+ }
43331
+ return found;
43332
+ }
43333
+ __name(verifiedPrefixOf, "verifiedPrefixOf");
43334
+ function startVerifiedPrefix(key6) {
43335
+ ledgers.delete(key6);
43336
+ if (ledgers.size >= LEDGERS_KEPT) {
43337
+ const oldest = ledgers.keys().next().value;
43338
+ if (oldest !== void 0)
43339
+ ledgers.delete(oldest);
43340
+ }
43341
+ const fresh = new VerifiedPrefix();
43342
+ ledgers.set(key6, fresh);
43343
+ return fresh;
43344
+ }
43345
+ __name(startVerifiedPrefix, "startVerifiedPrefix");
43346
+ async function rehashPrefix(bytes, ledger, count7) {
43347
+ if (count7 === 0)
43348
+ return true;
43349
+ if (count7 > ledger.count)
43350
+ return false;
43351
+ const lengths = ledger.lengths;
43352
+ const digests = ledger.digests;
43353
+ if (await bytes.size() < endOfLine(lengths, count7))
43354
+ return false;
43355
+ const splitter = new LineSplitter(0);
43356
+ let index = 0;
43357
+ let matched = false;
43358
+ const visit2 = /* @__PURE__ */ __name((chunk) => {
43359
+ for (const { line } of splitter.push(chunk)) {
43360
+ if (line.byteLength !== lengths[index])
43361
+ return true;
43362
+ if (!hexEqualsBytes(hexDigestOf(line), digests, index * DIGEST_BYTES))
43363
+ return true;
43364
+ index += 1;
43365
+ if (index === count7) {
43366
+ matched = true;
43367
+ return true;
43368
+ }
43369
+ }
43370
+ return false;
43371
+ }, "visit");
43372
+ try {
43373
+ if (bytes.scan !== void 0) {
43374
+ await bytes.scan(0, visit2);
43375
+ } else {
43376
+ for await (const chunk of bytes.stream(0))
43377
+ if (visit2(chunk))
43378
+ break;
43379
+ }
43380
+ } catch (error62) {
43381
+ if (error62.name === "SessionLogIntegrityError")
43382
+ return false;
43383
+ throw error62;
43384
+ }
43385
+ return matched;
43386
+ }
43387
+ __name(rehashPrefix, "rehashPrefix");
43388
+ function endOfLine(lengths, count7) {
43389
+ let total2 = 0;
43390
+ for (let i = 0; i < count7; i++)
43391
+ total2 += lengths[i];
43392
+ return total2;
43393
+ }
43394
+ __name(endOfLine, "endOfLine");
43395
+
43172
43396
  // ../sdk/dist/store/session-log/core.js
43173
43397
  function sessionLogDegradedCause(error62) {
43174
43398
  switch (error62?.code) {
@@ -43253,6 +43477,8 @@ var SessionLogCore = class {
43253
43477
  #holding = { release: /* @__PURE__ */ __name(() => this.#releaseHeld(), "release") };
43254
43478
  /** Bytes of the log this instance has verified and applied. */
43255
43479
  #synced = 0;
43480
+ /** What this process remembers of the log's verified prefix (see `verified-prefix.ts`). */
43481
+ #ledgerKey;
43256
43482
  #torn = 0;
43257
43483
  #degradedBufferBytes;
43258
43484
  /** Records accepted into the chain that the medium has not taken yet, oldest first. */
@@ -43299,7 +43525,16 @@ var SessionLogCore = class {
43299
43525
  return this.#degradedCause !== void 0;
43300
43526
  }
43301
43527
  // ── state ──
43302
- /** Catch up with the medium: verify and apply whatever was appended since the last sync. */
43528
+ /**
43529
+ * Catch up with the medium: verify and apply whatever was appended since the last sync.
43530
+ *
43531
+ * An instance that has nothing yet (a fresh one) first asks whether this
43532
+ * process already verified a prefix of this very log: it then re-reads and
43533
+ * hashes every byte of that prefix, and takes it as verified only when
43534
+ * every line's length and SHA-256 equal what was verified (no parsing, no
43535
+ * schema check). The bytes after it, and every byte when nothing matches,
43536
+ * are verified in full.
43537
+ */
43303
43538
  async #catchUp() {
43304
43539
  if (this.#pending.length > 0)
43305
43540
  return;
@@ -43308,6 +43543,26 @@ var SessionLogCore = class {
43308
43543
  return;
43309
43544
  if (size < this.#synced)
43310
43545
  this.#reset();
43546
+ let ledger;
43547
+ const key6 = await this.#medium.identity?.();
43548
+ this.#ledgerKey = key6;
43549
+ if (key6 !== void 0) {
43550
+ ledger = verifiedPrefixOf(key6);
43551
+ if (this.#synced === 0 && this.#chain.head === null) {
43552
+ const remembered = ledger;
43553
+ if (remembered !== void 0 && remembered.count > 0 && remembered.sessionId === this.sessionId && remembered.end <= size && await rehashPrefix(this.#medium, remembered, remembered.count)) {
43554
+ this.#chain = new SessionLogChain({
43555
+ head: remembered.head,
43556
+ sessionId: remembered.sessionId,
43557
+ gen: remembered.gen
43558
+ });
43559
+ this.#turns = remembered.turns();
43560
+ this.#synced = remembered.end;
43561
+ } else {
43562
+ ledger = startVerifiedPrefix(key6);
43563
+ }
43564
+ }
43565
+ }
43311
43566
  const splitter = new LineSplitter(this.#synced);
43312
43567
  for await (const chunk of this.#medium.stream(this.#synced)) {
43313
43568
  for (const { line, offset } of splitter.push(chunk)) {
@@ -43317,6 +43572,7 @@ var SessionLogCore = class {
43317
43572
  }
43318
43573
  this.#turns.apply(entry.record);
43319
43574
  this.#synced = offset + line.byteLength;
43575
+ ledger?.append(entry);
43320
43576
  }
43321
43577
  }
43322
43578
  this.#torn = splitter.pendingBytes;
@@ -43534,8 +43790,19 @@ var SessionLogCore = class {
43534
43790
  const entry = this.#chain.accept(bytes, this.#synced);
43535
43791
  this.#turns.apply(entry.record);
43536
43792
  this.#synced += bytes.byteLength;
43793
+ if (this.#pending.length === 0)
43794
+ await this.#rememberWritten(entry);
43537
43795
  return entry;
43538
43796
  }
43797
+ /** Let this process remember a record this instance just wrote and verified. */
43798
+ async #rememberWritten(entry) {
43799
+ if (this.#ledgerKey === void 0)
43800
+ this.#ledgerKey = await this.#medium.identity?.();
43801
+ if (this.#ledgerKey === void 0)
43802
+ return;
43803
+ const ledger = verifiedPrefixOf(this.#ledgerKey) ?? (entry.pointer.seq === 1 ? startVerifiedPrefix(this.#ledgerKey) : void 0);
43804
+ ledger?.append(entry);
43805
+ }
43539
43806
  /**
43540
43807
  * Hand a record's bytes to the medium. A volume that refuses writes (full,
43541
43808
  * over quota, read-only) does not fail the record: it waits in a bounded
@@ -43647,7 +43914,7 @@ var SessionLogCore = class {
43647
43914
  if (typeof type === "string" && TOOL_INPUT_RECORD_TYPES.has(type)) {
43648
43915
  return this.#spillToolInputs(candidate);
43649
43916
  }
43650
- if (type !== "message" && type !== "message_replaced" && type !== "compaction" && type !== "turn_completed")
43917
+ if (type !== "message" && type !== "message_replaced" && type !== "message_edited" && type !== "compaction" && type !== "turn_completed")
43651
43918
  return candidate;
43652
43919
  const size = Buffer.byteLength(`${JSON.stringify(candidate)}
43653
43920
  `, "utf8");
@@ -43676,7 +43943,7 @@ ${NOT_SAVED_NOTE}`
43676
43943
  return { ...candidate, summary: ref2 };
43677
43944
  }
43678
43945
  const content = candidate.content;
43679
- const key6 = content.role === "tool" && typeof content.toolCallId === "string" ? content.toolCallId : type === "message_replaced" ? `record:${String(candidate.id)}` : `message:${String(candidate.messageId)}`;
43946
+ const key6 = content.role === "tool" && typeof content.toolCallId === "string" ? content.toolCallId : type === "message_replaced" || type === "message_edited" ? `record:${String(candidate.id)}` : `message:${String(candidate.messageId)}`;
43680
43947
  const ref = await this.#spillOrLose(key6, "message", JSON.stringify(content));
43681
43948
  const text9 = typeof content.content === "string" ? content.content : JSON.stringify(content.content);
43682
43949
  if (ref === void 0) {
@@ -43823,6 +44090,8 @@ async function* walkSessionLog(medium, options) {
43823
44090
  throw error62;
43824
44091
  brokeAt = error62;
43825
44092
  }, "fail");
44093
+ let covered = 0;
44094
+ let ledger;
43826
44095
  if (options.after !== void 0) {
43827
44096
  const after = options.after;
43828
44097
  if (!await verifyPointer(medium, after)) {
@@ -43830,15 +44099,34 @@ async function* walkSessionLog(medium, options) {
43830
44099
  fail2(error62);
43831
44100
  return { intact: false, throughSeq: 0, head: null, tornBytes: 0, break: error62 };
43832
44101
  }
43833
- const parsed = parseSessionLogLine(await medium.read(after.offset, after.length));
43834
- chain = new SessionLogChain({
43835
- head: after,
43836
- sessionId: options.sessionId ?? parsed.record.sessionId,
43837
- gen: parsed.record.gen
43838
- });
43839
- start = after.offset + after.length;
44102
+ const key6 = options.reverify && strict ? await medium.identity?.() : void 0;
44103
+ if (key6 !== void 0) {
44104
+ const remembered = verifiedPrefixOf(key6);
44105
+ if (remembered !== void 0 && remembered.sessionId === options.sessionId && remembered.holds(after) && await rehashPrefix(medium, remembered, after.seq)) {
44106
+ ledger = remembered;
44107
+ } else {
44108
+ ledger = startVerifiedPrefix(key6);
44109
+ covered = after.seq;
44110
+ }
44111
+ }
44112
+ if (covered > 0) {
44113
+ chain = new SessionLogChain({ head: null, sessionId: options.sessionId });
44114
+ } else {
44115
+ const parsed = parseSessionLogLine(await medium.read(after.offset, after.length));
44116
+ chain = new SessionLogChain({
44117
+ head: after,
44118
+ sessionId: options.sessionId ?? parsed.record.sessionId,
44119
+ gen: parsed.record.gen
44120
+ });
44121
+ start = after.offset + after.length;
44122
+ }
43840
44123
  } else {
43841
44124
  chain = new SessionLogChain({ head: null, sessionId: options.sessionId });
44125
+ if (options.reverify && strict) {
44126
+ const key6 = await medium.identity?.();
44127
+ if (key6 !== void 0)
44128
+ ledger = verifiedPrefixOf(key6) ?? startVerifiedPrefix(key6);
44129
+ }
43842
44130
  }
43843
44131
  const splitter = new LineSplitter(start);
43844
44132
  let anchorSeen = false;
@@ -43867,6 +44155,9 @@ async function* walkSessionLog(medium, options) {
43867
44155
  break outer;
43868
44156
  }
43869
44157
  }
44158
+ ledger?.append(entry);
44159
+ if (entry.pointer.seq <= covered)
44160
+ continue;
43870
44161
  yield entry;
43871
44162
  if (options.throughSeq !== void 0 && entry.pointer.seq >= options.throughSeq) {
43872
44163
  stopped = true;
@@ -43902,7 +44193,7 @@ import { mkdir as mkdir7, open as open7, stat as stat3 } from "node:fs/promises"
43902
44193
  import { dirname as dirname7 } from "node:path";
43903
44194
 
43904
44195
  // ../sdk/dist/session/paths.js
43905
- import { createHash as createHash8 } from "node:crypto";
44196
+ import { createHash as createHash9 } from "node:crypto";
43906
44197
  import { link as link4, mkdir as mkdir6, open as open6, readFile as readFile6, realpath, unlink as unlink5 } from "node:fs/promises";
43907
44198
  import { basename as basename4, dirname as dirname6, join as join12 } from "node:path";
43908
44199
  function sessionLocatorFromLogFile(file2, sessionId5) {
@@ -43930,7 +44221,7 @@ var SLUG = /^[A-Za-z0-9-]+$/;
43930
44221
  var NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
43931
44222
  var MAX_SLUG = 200;
43932
44223
  function sha256Hex4(value) {
43933
- return createHash8("sha256").update(value).digest("hex");
44224
+ return createHash9("sha256").update(value).digest("hex");
43934
44225
  }
43935
44226
  __name(sha256Hex4, "sha256Hex");
43936
44227
  function checkId(value, kind) {
@@ -44198,6 +44489,16 @@ var DiskLogMedium = class {
44198
44489
  throw error62;
44199
44490
  }
44200
44491
  }
44492
+ async identity() {
44493
+ try {
44494
+ const stats = await stat3(this.file);
44495
+ return `${stats.dev}:${stats.ino}:${this.file}`;
44496
+ } catch (error62) {
44497
+ if (isErrno3(error62, "ENOENT"))
44498
+ return void 0;
44499
+ throw error62;
44500
+ }
44501
+ }
44201
44502
  async read(offset, length) {
44202
44503
  let handle;
44203
44504
  try {
@@ -44215,6 +44516,30 @@ var DiskLogMedium = class {
44215
44516
  await handle.close();
44216
44517
  }
44217
44518
  }
44519
+ async scan(offset, visit2) {
44520
+ let handle;
44521
+ try {
44522
+ handle = await open7(this.file, "r");
44523
+ } catch (error62) {
44524
+ if (isErrno3(error62, "ENOENT"))
44525
+ return;
44526
+ throw error62;
44527
+ }
44528
+ try {
44529
+ const buffer = Buffer.allocUnsafe(1 << 20);
44530
+ let position = offset;
44531
+ for (; ; ) {
44532
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, position);
44533
+ if (bytesRead === 0)
44534
+ return;
44535
+ position += bytesRead;
44536
+ if (visit2(buffer.subarray(0, bytesRead)))
44537
+ return;
44538
+ }
44539
+ } finally {
44540
+ await handle.close();
44541
+ }
44542
+ }
44218
44543
  async *stream(offset) {
44219
44544
  if (await this.size() <= offset)
44220
44545
  return;
@@ -44487,6 +44812,12 @@ function stampMessageId(message, id3) {
44487
44812
  message.id = id3;
44488
44813
  }
44489
44814
  __name(stampMessageId, "stampMessageId");
44815
+ function sameStoredContent(a, b) {
44816
+ const { id: _a4, timestamp: _ta, ...restA } = a;
44817
+ const { id: _b, timestamp: _tb, ...restB } = b;
44818
+ return isDeepStrictEqual2(JSON.parse(JSON.stringify(restA)), JSON.parse(JSON.stringify(restB)));
44819
+ }
44820
+ __name(sameStoredContent, "sameStoredContent");
44490
44821
  var DEFAULT_TURN_LEASE_TTL_MS = 5 * 6e4;
44491
44822
  var TURN_BOUND_EVENT_TYPES = /* @__PURE__ */ new Set([
44492
44823
  "tool_calls_admitted",
@@ -44583,6 +44914,8 @@ var TurnRecorder = class {
44583
44914
  * these needs no re-basing, so no `compaction` record is written for it.
44584
44915
  */
44585
44916
  #foldIdsAtResume;
44917
+ /** What the log folds to for a message a replacement or an edit changed, as of the resume. */
44918
+ #foldEditedAtResume = /* @__PURE__ */ new Map();
44586
44919
  /** When a resumed turn began: its `turn_started` record, not this process's start. */
44587
44920
  #resumedTurnStartedAt;
44588
44921
  constructor(config2) {
@@ -45127,6 +45460,7 @@ var TurnRecorder = class {
45127
45460
  async #readResumedLog() {
45128
45461
  await this.flush();
45129
45462
  const fold4 = new SessionMessageFold();
45463
+ const latestChange = /* @__PURE__ */ new Map();
45130
45464
  for await (const entry of this.log.read()) {
45131
45465
  const record4 = entry.record;
45132
45466
  if (record4.type === "turn_started" && record4.turnId === this.turnId) {
@@ -45134,17 +45468,25 @@ var TurnRecorder = class {
45134
45468
  if (Number.isFinite(at))
45135
45469
  this.#resumedTurnStartedAt = at;
45136
45470
  }
45471
+ if (record4.type === "message_edited")
45472
+ latestChange.set(record4.targetMessageId, "edited");
45473
+ else if (record4.type === "message_replaced")
45474
+ latestChange.set(record4.targetMessageId, "replaced");
45137
45475
  fold4.apply(record4);
45138
45476
  }
45139
- if (fold4.spilledSummary)
45140
- return void 0;
45141
45477
  const ids = [];
45478
+ let allRecorded = !fold4.spilledSummary;
45479
+ this.#foldEditedAtResume.clear();
45142
45480
  for (const entry of fold4.entries()) {
45143
- if (!entry.messageId)
45144
- return void 0;
45481
+ if (!entry.messageId) {
45482
+ allRecorded = false;
45483
+ continue;
45484
+ }
45145
45485
  ids.push(entry.messageId);
45486
+ if (latestChange.get(entry.messageId) === "edited" && entry.spill === void 0)
45487
+ this.#foldEditedAtResume.set(entry.messageId, entry.message);
45146
45488
  }
45147
- return ids;
45489
+ return allRecorded ? ids : void 0;
45148
45490
  }
45149
45491
  /** The recorded context is exactly what the log folds to: a resume changed nothing. */
45150
45492
  #viewMatchesFold() {
@@ -45348,6 +45690,10 @@ var TurnRecorder = class {
45348
45690
  });
45349
45691
  return;
45350
45692
  }
45693
+ if (options.restored && this.#rebasePending && this.#phase === "active") {
45694
+ this.#view.push({ message });
45695
+ return;
45696
+ }
45351
45697
  this.#syncMessages();
45352
45698
  }
45353
45699
  /** Replace the context without replacing the turn; recorded as one `compaction`. */
@@ -45382,6 +45728,101 @@ var TurnRecorder = class {
45382
45728
  stampMessageId(message, id3);
45383
45729
  return id3;
45384
45730
  }
45731
+ /**
45732
+ * A compaction pass edits one message by replacing its object with a copy
45733
+ * that has other content (`{ ...message, content }`). The copy still carries
45734
+ * the id the original was stamped with, but the recorder's own indexes are
45735
+ * keyed by object identity, so without this it would see an unknown message
45736
+ * and record every message after it again. A live object that is not in the
45737
+ * view, whose `id` is that of a recorded view entry whose own object has left
45738
+ * the context, is that same message edited: one `message_edited` record
45739
+ * carries its new content and the view entry follows the new object.
45740
+ *
45741
+ * Only an id claimed by exactly one live object is taken, so two copies of
45742
+ * one message are never both treated as its edit. Anything else is left to
45743
+ * the callers, which record it as a new message.
45744
+ */
45745
+ #absorbEdits() {
45746
+ if (this.#phase !== "active")
45747
+ return;
45748
+ const live2 = this.#turn.messages;
45749
+ const inContext = new Set(live2);
45750
+ let orphans;
45751
+ for (const entry of this.#view) {
45752
+ if (entry.id === void 0 || entry.transient || inContext.has(entry.message))
45753
+ continue;
45754
+ orphans ??= /* @__PURE__ */ new Map();
45755
+ orphans.set(entry.id, entry);
45756
+ }
45757
+ if (orphans === void 0)
45758
+ return;
45759
+ const known = new Set(this.#view.map((entry) => entry.message));
45760
+ const claimed = /* @__PURE__ */ new Map();
45761
+ for (const message of live2) {
45762
+ if (known.has(message) || this.#transient.has(message))
45763
+ continue;
45764
+ const id3 = message.id;
45765
+ if (id3 === void 0 || !orphans.has(id3))
45766
+ continue;
45767
+ const list2 = claimed.get(id3);
45768
+ if (list2)
45769
+ list2.push(message);
45770
+ else
45771
+ claimed.set(id3, [message]);
45772
+ }
45773
+ const turnId6 = this.turnId;
45774
+ for (const [id3, messages] of claimed) {
45775
+ const message = messages[0];
45776
+ const entry = orphans.get(id3);
45777
+ if (messages.length !== 1 || message.role !== entry.message.role)
45778
+ continue;
45779
+ const previous = entry.message;
45780
+ entry.message = message;
45781
+ this.#ids.set(message, id3);
45782
+ this.#recorded.set(message, id3);
45783
+ if (sameStoredContent(previous, message))
45784
+ continue;
45785
+ void this.#enqueue(() => this.#append({
45786
+ type: "message_edited",
45787
+ turnId: turnId6,
45788
+ targetMessageId: id3,
45789
+ content: message,
45790
+ ignorable: true,
45791
+ reason: "compaction"
45792
+ })).catch(() => void 0);
45793
+ }
45794
+ }
45795
+ /**
45796
+ * A resume restores the context a checkpoint holds, which can predate a
45797
+ * compaction edit written after it. The ids still match, so the log is not
45798
+ * re-based; but the fold then shows the edited text of a message the context
45799
+ * holds as it was. One `message_edited` per such message makes the fold show
45800
+ * the context the resume actually runs with.
45801
+ */
45802
+ #recordDriftFromFold() {
45803
+ const edited = this.#foldEditedAtResume;
45804
+ if (edited.size === 0)
45805
+ return;
45806
+ const turnId6 = this.turnId;
45807
+ for (const entry of this.#view) {
45808
+ if (entry.id === void 0 || entry.transient)
45809
+ continue;
45810
+ const folded = edited.get(entry.id);
45811
+ if (folded === void 0 || sameStoredContent(folded, entry.message))
45812
+ continue;
45813
+ const message = entry.message;
45814
+ const id3 = entry.id;
45815
+ void this.#enqueue(() => this.#append({
45816
+ type: "message_edited",
45817
+ turnId: turnId6,
45818
+ targetMessageId: id3,
45819
+ content: message,
45820
+ ignorable: true,
45821
+ reason: "resume"
45822
+ })).catch(() => void 0);
45823
+ }
45824
+ edited.clear();
45825
+ }
45385
45826
  /**
45386
45827
  * Reconcile the context with the log. Nothing is written before the turn
45387
45828
  * begins or after it pauses or settles.
@@ -45395,9 +45836,12 @@ var TurnRecorder = class {
45395
45836
  this.#foldIdsAtResume = void 0;
45396
45837
  if (!unchanged) {
45397
45838
  this.#recordCompaction();
45839
+ this.#recordDriftFromFold();
45398
45840
  return;
45399
45841
  }
45842
+ this.#recordDriftFromFold();
45400
45843
  }
45844
+ this.#absorbEdits();
45401
45845
  const live2 = this.#turn.messages;
45402
45846
  const view = this.#view;
45403
45847
  let prefix = 0;
@@ -45433,6 +45877,7 @@ var TurnRecorder = class {
45433
45877
  * log order, the whole context becomes the summary.
45434
45878
  */
45435
45879
  #recordCompaction() {
45880
+ this.#absorbEdits();
45436
45881
  const live2 = this.#turn.messages;
45437
45882
  const byMessage = new Map(this.#view.map((entry) => [entry.message, entry]));
45438
45883
  const next2 = live2.map((message) => {
@@ -45653,36 +46098,58 @@ async function recordedMessages(log, fold4) {
45653
46098
  return out;
45654
46099
  }
45655
46100
  __name(recordedMessages, "recordedMessages");
45656
- async function readEverRecordedMessages(log) {
46101
+ function recordedContent(record4) {
46102
+ return { content: record4.content, ...record4.spill ? { spill: record4.spill } : {} };
46103
+ }
46104
+ __name(recordedContent, "recordedContent");
46105
+ async function readEverRecordedMessageIndex(log) {
45657
46106
  return foldSessionLog(log, {
45658
46107
  name: "ever-recorded-messages",
45659
46108
  mode: "strict",
45660
- create: /* @__PURE__ */ __name(() => /* @__PURE__ */ new Map(), "create"),
45661
- apply: /* @__PURE__ */ __name((latest, entry) => {
46109
+ create: /* @__PURE__ */ __name(() => ({ latest: /* @__PURE__ */ new Map(), earlier: /* @__PURE__ */ new Map() }), "create"),
46110
+ apply: /* @__PURE__ */ __name(({ latest, earlier }, entry) => {
45662
46111
  const record4 = entry.record;
45663
46112
  if (record4.type === "message") {
45664
- latest.set(record4.messageId, {
45665
- content: record4.content,
45666
- ...record4.spill ? { spill: record4.spill } : {}
45667
- });
46113
+ latest.set(record4.messageId, recordedContent(record4));
45668
46114
  } else if (record4.type === "message_replaced") {
45669
- latest.set(record4.targetMessageId, {
45670
- content: record4.content,
45671
- ...record4.spill ? { spill: record4.spill } : {}
45672
- });
46115
+ earlier.delete(record4.targetMessageId);
46116
+ latest.set(record4.targetMessageId, recordedContent(record4));
46117
+ } else if (record4.type === "message_edited") {
46118
+ const before = latest.get(record4.targetMessageId);
46119
+ if (before !== void 0) {
46120
+ const held3 = earlier.get(record4.targetMessageId);
46121
+ if (held3)
46122
+ held3.push(before);
46123
+ else
46124
+ earlier.set(record4.targetMessageId, [before]);
46125
+ }
46126
+ latest.set(record4.targetMessageId, recordedContent(record4));
45673
46127
  }
45674
46128
  }, "apply"),
45675
- result: /* @__PURE__ */ __name(async (latest) => {
46129
+ result: /* @__PURE__ */ __name(async ({ latest, earlier }) => {
45676
46130
  const resolved2 = /* @__PURE__ */ new Map();
45677
46131
  for (const [id3, entry] of latest) {
45678
46132
  const content = entry.spill ? JSON.parse(await log.readSpill(entry.spill)) : structuredClone(entry.content);
45679
46133
  resolved2.set(id3, withMessageId(content, id3));
45680
46134
  }
45681
- return resolved2;
46135
+ const held3 = /* @__PURE__ */ new Map();
46136
+ for (const [id3, list2] of earlier)
46137
+ held3.set(id3, [...list2]);
46138
+ return {
46139
+ latest: resolved2,
46140
+ async heldBeforeAnEdit(id3, message) {
46141
+ for (const entry of held3.get(id3) ?? []) {
46142
+ const content = entry.spill ? JSON.parse(await log.readSpill(entry.spill)) : entry.content;
46143
+ if (sameStoredContent(content, message))
46144
+ return true;
46145
+ }
46146
+ return false;
46147
+ }
46148
+ };
45682
46149
  }, "result")
45683
46150
  });
45684
46151
  }
45685
- __name(readEverRecordedMessages, "readEverRecordedMessages");
46152
+ __name(readEverRecordedMessageIndex, "readEverRecordedMessageIndex");
45686
46153
 
45687
46154
  // ../sdk/dist/prompt/contributions.js
45688
46155
  var PromptContributionCollisionError = class extends RegistryCollisionError {
@@ -48866,7 +49333,7 @@ async function* settlePreStartCancellation(params, prepared) {
48866
49333
  });
48867
49334
  const push = /* @__PURE__ */ __name((message, ids) => {
48868
49335
  const messageId4 = ids.get(message);
48869
- ctx.recorder.pushMessage(message, messageId4 ? { messageId: messageId4 } : {});
49336
+ ctx.recorder.pushMessage(message, { ...messageId4 ? { messageId: messageId4 } : {}, restored: true });
48870
49337
  }, "push");
48871
49338
  try {
48872
49339
  if (selectedResumeState) {
@@ -49789,7 +50256,7 @@ async function readRecordedMessage(log, messageId4, throughSeq) {
49789
50256
  let found;
49790
50257
  for await (const { record: record4 } of log.read({ throughSeq })) {
49791
50258
  const entry = record4;
49792
- if (entry.type === "message" && entry.messageId === messageId4 || entry.type === "message_replaced" && entry.targetMessageId === messageId4) {
50259
+ if (entry.type === "message" && entry.messageId === messageId4 || (entry.type === "message_replaced" || entry.type === "message_edited") && entry.targetMessageId === messageId4) {
49793
50260
  found = { content: entry.content, ...entry.spill ? { spill: entry.spill } : {} };
49794
50261
  }
49795
50262
  }
@@ -49970,10 +50437,10 @@ var DetachedCalls = class {
49970
50437
  };
49971
50438
 
49972
50439
  // ../sdk/dist/store/memory/digest.js
49973
- import { createHash as createHash9 } from "node:crypto";
50440
+ import { createHash as createHash10 } from "node:crypto";
49974
50441
  var KNOWLEDGE_TAG_PREFIX = "knowledge:";
49975
50442
  function knowledgeDigest(value) {
49976
- return createHash9("sha256").update(JSON.stringify(value)).digest("hex");
50443
+ return createHash10("sha256").update(JSON.stringify(value)).digest("hex");
49977
50444
  }
49978
50445
  __name(knowledgeDigest, "knowledgeDigest");
49979
50446
  async function holdsKnowledgeDigest(store, tags, digest8, isWriter) {
@@ -52078,7 +52545,7 @@ async function deliverDurableInbound(recorder, source, signal) {
52078
52545
  __name(deliverDurableInbound, "deliverDurableInbound");
52079
52546
 
52080
52547
  // ../sdk/dist/runtime/query/observation-context.js
52081
- import { createHash as createHash12 } from "node:crypto";
52548
+ import { createHash as createHash13 } from "node:crypto";
52082
52549
 
52083
52550
  // ../sdk/dist/compaction/retention.js
52084
52551
  var isAssistantWithCalls = /* @__PURE__ */ __name((m) => m.role === "assistant" && Array.isArray(m.toolCalls), "isAssistantWithCalls");
@@ -52154,12 +52621,12 @@ function findRetainedIndices(messages) {
52154
52621
  __name(findRetainedIndices, "findRetainedIndices");
52155
52622
 
52156
52623
  // ../sdk/dist/runtime/query/tool-output-budget.js
52157
- import { createHash as createHash11 } from "node:crypto";
52624
+ import { createHash as createHash12 } from "node:crypto";
52158
52625
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
52159
52626
  import { join as join13 } from "node:path";
52160
52627
 
52161
52628
  // ../sdk/dist/store/evidence/format.js
52162
- import { createHash as createHash10 } from "node:crypto";
52629
+ import { createHash as createHash11 } from "node:crypto";
52163
52630
 
52164
52631
  // ../sdk/dist/utils/evidence-tokens.js
52165
52632
  function evidenceTokens(text9) {
@@ -52198,36 +52665,36 @@ var SEARCH_OVERLAP_BYTES = 1024;
52198
52665
  var FILTER_BYTES = 1024;
52199
52666
  var TOKEN_FILTER_PREFIX = `tokens-v1:${digest2(`${process.version}:${process.versions.v8}:${process.versions.unicode}`).slice(0, 16)}:`;
52200
52667
  function digest2(value) {
52201
- return createHash10("sha256").update(value).digest("hex");
52668
+ return createHash11("sha256").update(value).digest("hex");
52202
52669
  }
52203
52670
  __name(digest2, "digest");
52204
52671
  function hashAt(text9, offset) {
52205
- let hash3 = 2166136261;
52672
+ let hash4 = 2166136261;
52206
52673
  for (let i = 0; i < 3; i++)
52207
- hash3 = Math.imul(hash3 ^ text9.charCodeAt(offset + i), 16777619);
52208
- return hash3 >>> 0;
52674
+ hash4 = Math.imul(hash4 ^ text9.charCodeAt(offset + i), 16777619);
52675
+ return hash4 >>> 0;
52209
52676
  }
52210
52677
  __name(hashAt, "hashAt");
52211
- function second(hash3) {
52212
- return Math.imul(hash3 ^ hash3 >>> 16, 73244475) >>> 0;
52678
+ function second(hash4) {
52679
+ return Math.imul(hash4 ^ hash4 >>> 16, 73244475) >>> 0;
52213
52680
  }
52214
52681
  __name(second, "second");
52215
- function contains(bits, hash3) {
52216
- const bit = hash3 % (bits.length * 8);
52682
+ function contains(bits, hash4) {
52683
+ const bit = hash4 % (bits.length * 8);
52217
52684
  return ((bits[bit >>> 3] ?? 0) & 1 << (bit & 7)) !== 0;
52218
52685
  }
52219
52686
  __name(contains, "contains");
52220
- function set2(bits, hash3) {
52221
- const bit = hash3 % (bits.length * 8);
52687
+ function set2(bits, hash4) {
52688
+ const bit = hash4 % (bits.length * 8);
52222
52689
  bits[bit >>> 3] = (bits[bit >>> 3] ?? 0) | 1 << (bit & 7);
52223
52690
  }
52224
52691
  __name(set2, "set");
52225
52692
  function textFilter(text9) {
52226
52693
  const bits = Buffer.alloc(FILTER_BYTES);
52227
52694
  for (let i = 0; i + 2 < text9.length; i++) {
52228
- const hash3 = hashAt(text9, i);
52229
- set2(bits, hash3);
52230
- set2(bits, second(hash3));
52695
+ const hash4 = hashAt(text9, i);
52696
+ set2(bits, hash4);
52697
+ set2(bits, second(hash4));
52231
52698
  }
52232
52699
  return bits.toString("base64");
52233
52700
  }
@@ -52237,26 +52704,26 @@ function mayContain(filter, query2) {
52237
52704
  if (bits.length !== FILTER_BYTES)
52238
52705
  throw new Error("Invalid evidence filter.");
52239
52706
  for (let i = 0; i + 2 < query2.length; i++) {
52240
- const hash3 = hashAt(query2, i);
52241
- if (!contains(bits, hash3) || !contains(bits, second(hash3)))
52707
+ const hash4 = hashAt(query2, i);
52708
+ if (!contains(bits, hash4) || !contains(bits, second(hash4)))
52242
52709
  return false;
52243
52710
  }
52244
52711
  return true;
52245
52712
  }
52246
52713
  __name(mayContain, "mayContain");
52247
52714
  function tokenHash(token) {
52248
- let hash3 = 2166136261;
52715
+ let hash4 = 2166136261;
52249
52716
  for (let i = 0; i < token.length; i++)
52250
- hash3 = Math.imul(hash3 ^ token.charCodeAt(i), 16777619);
52251
- return hash3 >>> 0;
52717
+ hash4 = Math.imul(hash4 ^ token.charCodeAt(i), 16777619);
52718
+ return hash4 >>> 0;
52252
52719
  }
52253
52720
  __name(tokenHash, "tokenHash");
52254
52721
  function tokenFilter(text9) {
52255
52722
  const bits = Buffer.alloc(text9.length <= 1024 ? 128 : text9.length <= 8192 ? 512 : FILTER_BYTES);
52256
52723
  for (const match of evidenceTokenEntries(text9)) {
52257
- const hash3 = tokenHash(evidenceTokenKey(match[0]));
52258
- set2(bits, hash3);
52259
- set2(bits, second(hash3));
52724
+ const hash4 = tokenHash(evidenceTokenKey(match[0]));
52725
+ set2(bits, hash4);
52726
+ set2(bits, second(hash4));
52260
52727
  }
52261
52728
  return TOKEN_FILTER_PREFIX + bits.toString("base64");
52262
52729
  }
@@ -52267,8 +52734,8 @@ function mayContainToken(filter, query2) {
52267
52734
  const bits = Buffer.from(filter.slice(TOKEN_FILTER_PREFIX.length), "base64");
52268
52735
  if (![128, 512, FILTER_BYTES].includes(bits.length))
52269
52736
  throw new Error("Invalid evidence token filter.");
52270
- const hash3 = tokenHash(evidenceTokenKey(query2));
52271
- return contains(bits, hash3) && contains(bits, second(hash3));
52737
+ const hash4 = tokenHash(evidenceTokenKey(query2));
52738
+ return contains(bits, hash4) && contains(bits, second(hash4));
52272
52739
  }
52273
52740
  __name(mayContainToken, "mayContainToken");
52274
52741
  function encodeSpillManifest(manifest) {
@@ -52463,7 +52930,7 @@ __name(applyToolOutputBudget, "applyToolOutputBudget");
52463
52930
  function spill2(dir, toolUseId3, content, onError) {
52464
52931
  try {
52465
52932
  mkdirSync3(dir, { recursive: true, mode: 448 });
52466
- const name2 = createHash11("sha256").update(toolUseId3).digest("hex");
52933
+ const name2 = createHash12("sha256").update(toolUseId3).digest("hex");
52467
52934
  const path2 = join13(dir, `${name2}.txt`);
52468
52935
  const bytes = Buffer.from(content, "utf8");
52469
52936
  writeFileSync2(path2, bytes, { flag: "wx", mode: 384 });
@@ -52685,7 +53152,7 @@ function projectObservationContext(messages, tools, preserveToolResultsFrom = []
52685
53152
  }
52686
53153
  if (executionKey === void 0)
52687
53154
  continue;
52688
- const key6 = createHash12("sha256").update(JSON.stringify([
53155
+ const key6 = createHash13("sha256").update(JSON.stringify([
52689
53156
  call2.function.name,
52690
53157
  call2.function.arguments,
52691
53158
  message.content,
@@ -52712,7 +53179,7 @@ function projectObservationContext(messages, tools, preserveToolResultsFrom = []
52712
53179
  __name(projectObservationContext, "projectObservationContext");
52713
53180
 
52714
53181
  // ../sdk/dist/runtime/query/request-context.js
52715
- import { createHash as createHash13 } from "node:crypto";
53182
+ import { createHash as createHash14 } from "node:crypto";
52716
53183
  function canonicalJson2(value) {
52717
53184
  return JSON.stringify(value, (_key, item) => {
52718
53185
  if (!item || typeof item !== "object" || Array.isArray(item))
@@ -52731,7 +53198,7 @@ function snapshotRequestContext(messages) {
52731
53198
  partIndex: partIndex++,
52732
53199
  role: message.role,
52733
53200
  kind,
52734
- digest: createHash13("sha256").update(canonicalJson2(payload)).digest("hex"),
53201
+ digest: createHash14("sha256").update(canonicalJson2(payload)).digest("hex"),
52735
53202
  ...toolCallId !== void 0 ? { toolCallId } : {},
52736
53203
  ...message.role === "tool" ? { isError: message.isError === true } : {}
52737
53204
  }));
@@ -55933,7 +56400,7 @@ function deliverArrivedMonitorNotices(ctx) {
55933
56400
  __name(deliverArrivedMonitorNotices, "deliverArrivedMonitorNotices");
55934
56401
 
55935
56402
  // ../sdk/dist/runtime/query/iteration/request-repair.js
55936
- import { createHash as createHash14 } from "node:crypto";
56403
+ import { createHash as createHash15 } from "node:crypto";
55937
56404
 
55938
56405
  // ../sdk/dist/provider/image-input-refusal.js
55939
56406
  var IMAGE_INPUT_REFUSAL_PATTERNS = [
@@ -56210,7 +56677,7 @@ function isAccepted(chunk) {
56210
56677
  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);
56211
56678
  }
56212
56679
  __name(isAccepted, "isAccepted");
56213
- var mediaFingerprint = /* @__PURE__ */ __name((data, mediaType) => createHash14("sha256").update(mediaType).update("\0").update(data).digest("hex"), "mediaFingerprint");
56680
+ var mediaFingerprint = /* @__PURE__ */ __name((data, mediaType) => createHash15("sha256").update(mediaType).update("\0").update(data).digest("hex"), "mediaFingerprint");
56214
56681
  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.";
56215
56682
  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.";
56216
56683
  var removedNote = /* @__PURE__ */ __name((kind, limit) => `[${kind} removed: ${limit ? LIMIT_NOTE : FAULT_NOTE}]`, "removedNote");
@@ -57268,12 +57735,12 @@ __name(bm25Score, "bm25Score");
57268
57735
  var HASHES = 64;
57269
57736
  var SHINGLE = 3;
57270
57737
  function fnv1a(text9, seed) {
57271
- let hash3 = (2166136261 ^ seed) >>> 0;
57738
+ let hash4 = (2166136261 ^ seed) >>> 0;
57272
57739
  for (let i = 0; i < text9.length; i += 1) {
57273
- hash3 ^= text9.charCodeAt(i);
57274
- hash3 = Math.imul(hash3, 16777619) >>> 0;
57740
+ hash4 ^= text9.charCodeAt(i);
57741
+ hash4 = Math.imul(hash4, 16777619) >>> 0;
57275
57742
  }
57276
- return hash3;
57743
+ return hash4;
57277
57744
  }
57278
57745
  __name(fnv1a, "fnv1a");
57279
57746
  function minhash(tokens) {
@@ -57297,14 +57764,19 @@ function minhash(tokens) {
57297
57764
  return signature;
57298
57765
  }
57299
57766
  __name(minhash, "minhash");
57300
- function similarity(a, b) {
57301
- let same2 = 0;
57302
- for (let slot = 0; slot < HASHES; slot += 1)
57303
- if (a[slot] === b[slot])
57304
- same2 += 1;
57305
- return same2 / HASHES;
57306
- }
57307
- __name(similarity, "similarity");
57767
+ function similarityAtLeast(a, b, floor) {
57768
+ const allowedMisses = HASHES - Math.ceil(floor * HASHES);
57769
+ let misses = 0;
57770
+ for (let slot = 0; slot < HASHES; slot += 1) {
57771
+ if (a[slot] !== b[slot]) {
57772
+ misses += 1;
57773
+ if (misses > allowedMisses)
57774
+ return 0;
57775
+ }
57776
+ }
57777
+ return (HASHES - misses) / HASHES;
57778
+ }
57779
+ __name(similarityAtLeast, "similarityAtLeast");
57308
57780
  function isEmptySignature(signature) {
57309
57781
  return signature.every((h) => h === 4294967295);
57310
57782
  }
@@ -57351,6 +57823,25 @@ function citable(tokens) {
57351
57823
  return out;
57352
57824
  }
57353
57825
  __name(citable, "citable");
57826
+ var FEATURES = /* @__PURE__ */ new WeakMap();
57827
+ function featuresOf(message, text9) {
57828
+ const cached4 = FEATURES.get(message);
57829
+ if (cached4 !== void 0 && cached4.text === text9)
57830
+ return cached4;
57831
+ const tokens = tokenize(text9);
57832
+ const signature = minhash(tokens);
57833
+ const features = {
57834
+ text: text9,
57835
+ tokenCount: tokens.length,
57836
+ document: indexDocument(text9, tokens),
57837
+ citable: citable(tokens),
57838
+ signature,
57839
+ signatureKey: String.fromCharCode(...new Uint16Array(signature.buffer))
57840
+ };
57841
+ FEATURES.set(message, features);
57842
+ return features;
57843
+ }
57844
+ __name(featuresOf, "featuresOf");
57354
57845
  function scoreMessages(messages, options) {
57355
57846
  const config2 = {
57356
57847
  ...DEFAULT_SALIENCE_CONFIG,
@@ -57358,10 +57849,9 @@ function scoreMessages(messages, options) {
57358
57849
  weights: { ...DEFAULT_SALIENCE_WEIGHTS, ...options.config?.weights }
57359
57850
  };
57360
57851
  const n = messages.length;
57361
- const texts = messages.map(messageText);
57852
+ const features = messages.map((message) => featuresOf(message, messageText(message)));
57362
57853
  const richContent = messages.map(hasRichContent);
57363
- const tokenLists = texts.map(tokenize);
57364
- const documents = texts.map((text9, i) => indexDocument(text9, tokenLists[i]));
57854
+ const documents = features.map((f) => f.document);
57365
57855
  const index = buildIndex(documents);
57366
57856
  const goalTokens = tokenize(options.goal);
57367
57857
  const rawRelevance = documents.map((doc) => bm25Score(index, doc, goalTokens));
@@ -57369,23 +57859,48 @@ function scoreMessages(messages, options) {
57369
57859
  const m = messages[i];
57370
57860
  return m.role === "tool" || m.role === "assistant" && !isAssistantWithCalls2(m);
57371
57861
  }));
57372
- const citedAfter = new Array(n);
57373
- let running = /* @__PURE__ */ new Set();
57374
- for (let i = n - 1; i >= 0; i -= 1) {
57375
- citedAfter[i] = running;
57862
+ const lastCited = /* @__PURE__ */ new Map();
57863
+ for (let i = 0; i < n; i += 1) {
57376
57864
  const message = messages[i];
57377
- if (message.role === "assistant" || message.role === "user") {
57378
- running = /* @__PURE__ */ new Set([...running, ...citable(tokenLists[i])]);
57379
- }
57865
+ if (message.role !== "assistant" && message.role !== "user")
57866
+ continue;
57867
+ for (const token of features[i].citable)
57868
+ lastCited.set(token, i);
57380
57869
  }
57381
- const signatures = tokenLists.map(minhash);
57382
57870
  const callKeys = messages.map((m) => isAssistantWithCalls2(m) ? (m.toolCalls ?? []).map((c) => `${c.function.name}:${c.function.arguments}`) : []);
57383
- const laterCallKeys = new Array(n);
57384
- let calls = /* @__PURE__ */ new Set();
57871
+ const lastCalled = /* @__PURE__ */ new Map();
57872
+ for (let i = 0; i < n; i += 1) {
57873
+ for (const key6 of callKeys[i])
57874
+ lastCalled.set(key6, i);
57875
+ }
57876
+ const floor = Math.min(0.5, config2.duplicateThreshold);
57877
+ const redundancyOf = new Array(n).fill(0);
57878
+ const laterSignatures = /* @__PURE__ */ new Map();
57879
+ const laterKeys = /* @__PURE__ */ new Map();
57385
57880
  for (let i = n - 1; i >= 0; i -= 1) {
57386
- laterCallKeys[i] = calls;
57387
- if (callKeys[i].length > 0)
57388
- calls = /* @__PURE__ */ new Set([...calls, ...callKeys[i]]);
57881
+ const message = messages[i];
57882
+ if (richContent[i])
57883
+ continue;
57884
+ const own2 = features[i];
57885
+ const sameRole = laterSignatures.get(message.role) ?? [];
57886
+ const sameRoleKeys = laterKeys.get(message.role) ?? /* @__PURE__ */ new Set();
57887
+ let redundancy = 0;
57888
+ if (!isEmptySignature(own2.signature)) {
57889
+ if (sameRoleKeys.has(own2.signatureKey))
57890
+ redundancy = 1;
57891
+ else {
57892
+ for (const other of sameRole) {
57893
+ const sim = similarityAtLeast(own2.signature, other, floor);
57894
+ if (sim > redundancy)
57895
+ redundancy = sim;
57896
+ }
57897
+ }
57898
+ }
57899
+ redundancyOf[i] = redundancy;
57900
+ sameRole.push(own2.signature);
57901
+ sameRoleKeys.add(own2.signatureKey);
57902
+ laterSignatures.set(message.role, sameRole);
57903
+ laterKeys.set(message.role, sameRoleKeys);
57389
57904
  }
57390
57905
  const protectedBy = new Array(n).fill(null);
57391
57906
  let floorEnd = 0;
@@ -57441,28 +57956,20 @@ function scoreMessages(messages, options) {
57441
57956
  const relevance = maxRelevance > 0 ? rawRelevance[i] / maxRelevance : 0;
57442
57957
  let utility = 0;
57443
57958
  if (message.role === "user") {
57444
- const tokens = tokenLists[i];
57445
- utility = citable(tokens).size > 0 || tokens.length >= 6 ? 1 : 0.2;
57959
+ const own2 = features[i];
57960
+ utility = own2.citable.size > 0 || own2.tokenCount >= 6 ? 1 : 0.2;
57446
57961
  } else if (message.role === "tool") {
57447
- const mine = citable(tokenLists[i]);
57448
- let hits = 0;
57449
- for (const token of mine)
57450
- if (citedAfter[i].has(token))
57451
- hits += 1;
57452
- utility = hits > 0 ? 1 : 0;
57962
+ let cited = false;
57963
+ for (const token of features[i].citable) {
57964
+ if ((lastCited.get(token) ?? -1) > i) {
57965
+ cited = true;
57966
+ break;
57967
+ }
57968
+ }
57969
+ utility = cited ? 1 : 0;
57453
57970
  } else if (isAssistantWithCalls2(message))
57454
57971
  utility = 0.5;
57455
- let redundancy = 0;
57456
- const signature = signatures[i];
57457
- if (!richContent[i] && !isEmptySignature(signature)) {
57458
- for (let j = i + 1; j < n; j += 1) {
57459
- if (richContent[j] || messages[j].role !== message.role)
57460
- continue;
57461
- const sim = similarity(signature, signatures[j]);
57462
- if (sim > redundancy)
57463
- redundancy = sim;
57464
- }
57465
- }
57972
+ let redundancy = redundancyOf[i];
57466
57973
  if (redundancy < config2.duplicateThreshold)
57467
57974
  redundancy = redundancy >= 0.5 ? redundancy : 0;
57468
57975
  else
@@ -57475,7 +57982,7 @@ function scoreMessages(messages, options) {
57475
57982
  const call2 = (producer.toolCalls ?? []).find((c) => c.id === message.toolCallId);
57476
57983
  if (call2) {
57477
57984
  const key6 = `${call2.function.name}:${call2.function.arguments}`;
57478
- if (laterCallKeys[i].has(key6))
57985
+ if ((lastCalled.get(key6) ?? -1) > i)
57479
57986
  redundancy = 1;
57480
57987
  break;
57481
57988
  }
@@ -57510,10 +58017,7 @@ function isStubbedNarration(content) {
57510
58017
  return typeof content === "string" && content.includes(STUB_MARK);
57511
58018
  }
57512
58019
  __name(isStubbedNarration, "isStubbedNarration");
57513
- function planWorkingSet(messages, scored, options) {
57514
- const minTool = options.minToolResultChars ?? 1e3;
57515
- const minNarration = options.minNarrationChars ?? 240;
57516
- const preserve = new Set(options.preserveTools ?? []);
58020
+ function evictionRules(messages, options) {
57517
58021
  const toolNameByCallId = /* @__PURE__ */ new Map();
57518
58022
  for (const m of messages) {
57519
58023
  if (m.role !== "assistant")
@@ -57522,38 +58026,80 @@ function planWorkingSet(messages, scored, options) {
57522
58026
  toolNameByCallId.set(call2.id, call2.function.name);
57523
58027
  }
57524
58028
  }
58029
+ return {
58030
+ minTool: options.minToolResultChars ?? 1e3,
58031
+ minNarration: options.minNarrationChars ?? 240,
58032
+ preserve: new Set(options.preserveTools ?? []),
58033
+ toolNameByCallId
58034
+ };
58035
+ }
58036
+ __name(evictionRules, "evictionRules");
58037
+ function evictionKind(m, tokens, rules) {
58038
+ if (tokens === 0)
58039
+ return null;
58040
+ if (m.role === "tool") {
58041
+ const tool = m;
58042
+ if (tool.isError || isClearedToolResult(tool.content))
58043
+ return null;
58044
+ if (rules.preserve.has(rules.toolNameByCallId.get(tool.toolCallId) ?? ""))
58045
+ return null;
58046
+ if (tokens * CHARS_PER_TOKEN < rules.minTool)
58047
+ return null;
58048
+ return "clear";
58049
+ }
58050
+ if (m.role === "assistant" && !Array.isArray(m.toolCalls)) {
58051
+ const text9 = typeof m.content === "string" ? m.content : "";
58052
+ if (text9.length < rules.minNarration || isStubbedNarration(text9))
58053
+ return null;
58054
+ return "stub";
58055
+ }
58056
+ return null;
58057
+ }
58058
+ __name(evictionKind, "evictionKind");
58059
+ function hasEvictableMessage(messages, options) {
58060
+ const rules = evictionRules(messages, options);
58061
+ let floorEnd = 0;
58062
+ while (floorEnd < messages.length && messages[floorEnd]?.role === "system")
58063
+ floorEnd += 1;
58064
+ const end = Math.max(floorEnd, messages.length - options.keepRecentMessages);
58065
+ for (let i = floorEnd; i < end; i += 1) {
58066
+ const m = messages[i];
58067
+ if (evictionKind(m, estimateMessageTokens(m), rules) !== null)
58068
+ return true;
58069
+ }
58070
+ return false;
58071
+ }
58072
+ __name(hasEvictableMessage, "hasEvictableMessage");
58073
+ function planNothingToShed(messages, options) {
58074
+ return {
58075
+ messages: [...messages],
58076
+ actions: [],
58077
+ clearedCount: 0,
58078
+ stubbedCount: 0,
58079
+ charsReclaimed: 0,
58080
+ reclaimedTokens: 0,
58081
+ reachedTarget: options.estimatedTokens - options.targetTokens <= 0
58082
+ };
58083
+ }
58084
+ __name(planNothingToShed, "planNothingToShed");
58085
+ function planWorkingSet(messages, scored, options) {
58086
+ const rules = evictionRules(messages, options);
58087
+ const { toolNameByCallId } = rules;
57525
58088
  const candidates = [];
57526
58089
  for (const s of scored) {
57527
- if (s.protected !== null || s.tokens === 0)
58090
+ if (s.protected !== null)
57528
58091
  continue;
57529
58092
  const m = messages[s.index];
57530
- if (m.role === "tool") {
57531
- const tool = m;
57532
- if (tool.isError || isClearedToolResult(tool.content))
57533
- continue;
57534
- if (preserve.has(toolNameByCallId.get(tool.toolCallId) ?? ""))
57535
- continue;
57536
- if (s.tokens * CHARS_PER_TOKEN < minTool)
57537
- continue;
57538
- candidates.push({
57539
- index: s.index,
57540
- kind: "clear",
57541
- salience: s.salience,
57542
- tokens: s.tokens,
57543
- goalBound: s.relevance >= 0.5 || s.utility >= 1
57544
- });
57545
- } else if (m.role === "assistant" && !Array.isArray(m.toolCalls)) {
57546
- const text9 = typeof m.content === "string" ? m.content : "";
57547
- if (text9.length < minNarration || isStubbedNarration(text9))
57548
- continue;
57549
- candidates.push({
57550
- index: s.index,
57551
- kind: "stub",
57552
- salience: s.salience,
57553
- tokens: s.tokens,
57554
- goalBound: s.relevance >= 0.5 || s.utility >= 1
57555
- });
57556
- }
58093
+ const kind = evictionKind(m, s.tokens, rules);
58094
+ if (kind === null)
58095
+ continue;
58096
+ candidates.push({
58097
+ index: s.index,
58098
+ kind,
58099
+ salience: s.salience,
58100
+ tokens: s.tokens,
58101
+ goalBound: s.relevance >= 0.5 || s.utility >= 1
58102
+ });
57557
58103
  }
57558
58104
  candidates.sort((a, b) => a.salience - b.salience || b.tokens - a.tokens || a.index - b.index);
57559
58105
  const maxSalience = candidates.reduce((m, c) => Math.max(m, c.salience), Number.NEGATIVE_INFINITY);
@@ -57627,21 +58173,34 @@ function naiveKeepStartByTokens(messages, budgetTokens) {
57627
58173
  }
57628
58174
  __name(naiveKeepStartByTokens, "naiveKeepStartByTokens");
57629
58175
  var DEFAULT_SOFT_TARGET = 0.5;
57630
- function planSalienceWorkingSet(input2) {
57631
- const { config: config2, estimatedTokens, contextWindowTokens: budget } = input2;
57632
- const goal = buildGoal(input2.messages, {
57633
- ...input2.openTasks ? { openTasks: input2.openTasks } : {}
57634
- });
57635
- const scored = scoreMessages(input2.messages, {
57636
- goal,
58176
+ function salienceTargetTokens(config2, windowTokens) {
58177
+ const soft = config2.softTarget ?? DEFAULT_SOFT_TARGET;
58178
+ const headroom = config2.softTargetHeadroom ?? 0;
58179
+ return Math.floor(windowTokens * (headroom > 0 ? Math.max(0, soft - headroom) : soft));
58180
+ }
58181
+ __name(salienceTargetTokens, "salienceTargetTokens");
58182
+ function canShedSalienceWorkingSet(messages, config2) {
58183
+ return hasEvictableMessage(messages, {
58184
+ minToolResultChars: config2.minToolResultCharsToClear,
58185
+ ...config2.preserveToolResultsFrom ? { preserveTools: config2.preserveToolResultsFrom } : {},
57637
58186
  keepRecentMessages: config2.keepRecentMessages
57638
58187
  });
57639
- const working = planWorkingSet(input2.messages, scored, {
58188
+ }
58189
+ __name(canShedSalienceWorkingSet, "canShedSalienceWorkingSet");
58190
+ function planSalienceWorkingSet(input2) {
58191
+ const { config: config2, estimatedTokens, contextWindowTokens: budget } = input2;
58192
+ const workingOptions = {
57640
58193
  estimatedTokens,
57641
- targetTokens: Math.floor(budget * (config2.softTarget ?? DEFAULT_SOFT_TARGET)),
58194
+ targetTokens: salienceTargetTokens(config2, budget),
57642
58195
  minToolResultChars: config2.minToolResultCharsToClear,
57643
58196
  ...config2.preserveToolResultsFrom ? { preserveTools: config2.preserveToolResultsFrom } : {}
57644
- });
58197
+ };
58198
+ const working = canShedSalienceWorkingSet(input2.messages, config2) ? planWorkingSet(input2.messages, scoreMessages(input2.messages, {
58199
+ goal: buildGoal(input2.messages, {
58200
+ ...input2.openTasks ? { openTasks: input2.openTasks } : {}
58201
+ }),
58202
+ keepRecentMessages: config2.keepRecentMessages
58203
+ }), workingOptions) : planNothingToShed(input2.messages, workingOptions);
57645
58204
  return {
57646
58205
  kind: "cleared",
57647
58206
  messages: working.messages,
@@ -58633,6 +59192,9 @@ async function runCompactionCheckInner(ctx, pass, options) {
58633
59192
  const startAt = salience ? Math.min(config2.softTarget ?? DEFAULT_SOFT_TARGET, trigger) : trigger;
58634
59193
  if (!options?.force && usage < startAt)
58635
59194
  return;
59195
+ if (salience && !options?.force && !ctx.contextReducer && usage < trigger && !canShedSalienceWorkingSet(ctx.recorder.messages, config2)) {
59196
+ return;
59197
+ }
58636
59198
  const breaker2 = compactionBreaker(ctx);
58637
59199
  if (breaker2?.failuresOpen && !options?.force) {
58638
59200
  if (breaker2.takeFailureNotice()) {
@@ -59424,7 +59986,7 @@ __name(runPlanGate, "runPlanGate");
59424
59986
  var DECLINED_TOOL_CALL_FEEDBACK = "The user declined this. Do not get the same content or result another way (another tool, another site or address, or a web search) unless you ask the user first and they agree. Say what you wanted to do, or carry on without it.";
59425
59987
 
59426
59988
  // ../sdk/dist/runtime/query/project-instructions.js
59427
- import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
59989
+ import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
59428
59990
  async function awaitProjectInstructionCallback(signal, start) {
59429
59991
  signal.throwIfAborted();
59430
59992
  return new Promise((resolve37, reject2) => {
@@ -59517,7 +60079,7 @@ function canonical(message) {
59517
60079
  }
59518
60080
  __name(canonical, "canonical");
59519
60081
  function sameProjectInstructionSnapshot(a, b) {
59520
- return isDeepStrictEqual2(canonical(a), canonical(b));
60082
+ return isDeepStrictEqual3(canonical(a), canonical(b));
59521
60083
  }
59522
60084
  __name(sameProjectInstructionSnapshot, "sameProjectInstructionSnapshot");
59523
60085
  function latestProjectInstructionSnapshot(messages) {
@@ -59586,7 +60148,7 @@ function replaceProjectInstructionSnapshot(messages, snapshot, placement = "appe
59586
60148
  __name(replaceProjectInstructionSnapshot, "replaceProjectInstructionSnapshot");
59587
60149
 
59588
60150
  // ../sdk/dist/runtime/query/repeat-call.js
59589
- import { createHash as createHash15 } from "node:crypto";
60151
+ import { createHash as createHash16 } from "node:crypto";
59590
60152
 
59591
60153
  // ../sdk/dist/runtime/query/tool-grants.js
59592
60154
  function toolGrantKeys(call2) {
@@ -59695,7 +60257,7 @@ var RepeatCallTracker = class {
59695
60257
  this.failures.delete(key6);
59696
60258
  return;
59697
60259
  }
59698
- const fingerprint = createHash15("sha256").update(stableStringify(outcome.result ?? null)).digest("hex");
60260
+ const fingerprint = createHash16("sha256").update(stableStringify(outcome.result ?? null)).digest("hex");
59699
60261
  const previous = this.failures.get(key6);
59700
60262
  this.failures.set(key6, {
59701
60263
  fingerprint,
@@ -62598,9 +63160,9 @@ import { homedir } from "node:os";
62598
63160
  import { basename as basename6, isAbsolute as isAbsolute6, join as join15, resolve as resolve6 } from "node:path";
62599
63161
 
62600
63162
  // ../sdk/dist/tools/builtins/content-fingerprint.js
62601
- import { createHash as createHash16 } from "node:crypto";
63163
+ import { createHash as createHash17 } from "node:crypto";
62602
63164
  function fingerprintContent(content) {
62603
- return createHash16("sha256").update(content, "utf-8").digest("hex").slice(0, 16);
63165
+ return createHash17("sha256").update(content, "utf-8").digest("hex").slice(0, 16);
62604
63166
  }
62605
63167
  __name(fingerprintContent, "fingerprintContent");
62606
63168
  function staleFileError(path2, operation = "edit") {
@@ -64884,7 +65446,7 @@ function createReviewPolicy(options = {}) {
64884
65446
  __name(createReviewPolicy, "createReviewPolicy");
64885
65447
 
64886
65448
  // ../sdk/dist/runtime/query/executor.js
64887
- import { createHash as createHash19 } from "node:crypto";
65449
+ import { createHash as createHash20 } from "node:crypto";
64888
65450
  import { isAbsolute as isAbsolute11, join as join20, resolve as resolve12 } from "node:path";
64889
65451
 
64890
65452
  // ../sdk/dist/probe/context.js
@@ -66051,7 +66613,7 @@ async function cropAndFitPng(data, rect, limits) {
66051
66613
  __name(cropAndFitPng, "cropAndFitPng");
66052
66614
 
66053
66615
  // ../sdk/dist/tools/builtins/view-image.js
66054
- import { createHash as createHash17 } from "node:crypto";
66616
+ import { createHash as createHash18 } from "node:crypto";
66055
66617
  import { open as open10 } from "node:fs/promises";
66056
66618
  import { inflateSync } from "node:zlib";
66057
66619
 
@@ -66671,7 +67233,7 @@ ${validation === "container" ? "The complete container and dimensions were valid
66671
67233
  width: image.width,
66672
67234
  height: image.height,
66673
67235
  sourceBytes: artifact.bytes.length,
66674
- sha256: createHash17("sha256").update(artifact.bytes).digest("hex"),
67236
+ sha256: createHash18("sha256").update(artifact.bytes).digest("hex"),
66675
67237
  validation
66676
67238
  }
66677
67239
  };
@@ -69377,7 +69939,7 @@ import { mkdir as mkdir9, readFile as readFile10 } from "node:fs/promises";
69377
69939
  import { dirname as dirname13 } from "node:path";
69378
69940
 
69379
69941
  // ../sdk/dist/tools/builtins/file-write-result.js
69380
- import { createHash as createHash18 } from "node:crypto";
69942
+ import { createHash as createHash19 } from "node:crypto";
69381
69943
  function previewSide(hunks2, changed) {
69382
69944
  return hunks2.flatMap((hunk) => hunk.lines).filter((row) => row.startsWith(" ") || row.startsWith(changed)).map((row) => `${row.slice(1)}
69383
69945
  `).join("");
@@ -69419,7 +69981,7 @@ function fileWriteResult(path2, before, after, sandboxed = false) {
69419
69981
  }
69420
69982
  },
69421
69983
  bytes,
69422
- sha256: createHash18("sha256").update(after, "utf8").digest("hex"),
69984
+ sha256: createHash19("sha256").update(after, "utf8").digest("hex"),
69423
69985
  ...before === null ? {} : { added: diff.added, removed: diff.removed, newlineChanged }
69424
69986
  }
69425
69987
  }
@@ -70683,7 +71245,7 @@ var ToolExecutor = class {
70683
71245
  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;
70684
71246
  }
70685
71247
  observationFingerprint(call2, content) {
70686
- return createHash19("sha256").update(JSON.stringify([call2.function.name, call2.function.arguments, content])).digest("hex");
71248
+ return createHash20("sha256").update(JSON.stringify([call2.function.name, call2.function.arguments, content])).digest("hex");
70687
71249
  }
70688
71250
  recordExecutedObservation(call2, toolName, definition, input2, content) {
70689
71251
  if (typeof content !== "string" || this.config.tools.get(toolName) !== definition)
@@ -70695,7 +71257,7 @@ var ToolExecutor = class {
70695
71257
  toolName,
70696
71258
  definition,
70697
71259
  fingerprint: this.observationFingerprint(call2, content),
70698
- inputFingerprint: createHash19("sha256").update(JSON.stringify([toolName, input2])).digest("hex")
71260
+ inputFingerprint: createHash20("sha256").update(JSON.stringify([toolName, input2])).digest("hex")
70699
71261
  });
70700
71262
  } catch {
70701
71263
  }
@@ -72946,7 +73508,7 @@ function inputPathOf(call2) {
72946
73508
  __name(inputPathOf, "inputPathOf");
72947
73509
 
72948
73510
  // ../sdk/dist/runtime/query/resume-pending.js
72949
- import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
73511
+ import { isDeepStrictEqual as isDeepStrictEqual4 } from "node:util";
72950
73512
 
72951
73513
  // ../sdk/dist/runtime/query/question-park.js
72952
73514
  var QuestionParkBinding = class {
@@ -73420,7 +73982,7 @@ async function applyPendingResume(plan, recorder, executor, prior, assistantMess
73420
73982
  const reviewed = reviewedById.get(call2.id);
73421
73983
  const wasModified = plan.modifiedCallIds?.has(call2.id) === true;
73422
73984
  if (reviewed && !wasModified) {
73423
- const unchanged = reviewed.name === call2.name && isDeepStrictEqual3(reviewed.input, call2.input);
73985
+ const unchanged = reviewed.name === call2.name && isDeepStrictEqual4(reviewed.input, call2.input);
73424
73986
  if (!unchanged) {
73425
73987
  const reason2 = "The tool input changed after its durable review; the earlier approval cannot be reused.";
73426
73988
  denials.set(call2.id, reason2);
@@ -78494,7 +79056,7 @@ function enforcedModelInputToolNames(registry2, tools) {
78494
79056
  __name(enforcedModelInputToolNames, "enforcedModelInputToolNames");
78495
79057
 
78496
79058
  // ../sdk/dist/runtime/query/prepare-turn.js
78497
- import { isDeepStrictEqual as isDeepStrictEqual4 } from "node:util";
79059
+ import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
78498
79060
 
78499
79061
  // ../sdk/dist/provider/retry.js
78500
79062
  var gaveUpEarly = /* @__PURE__ */ new WeakMap();
@@ -79690,7 +80252,7 @@ import { lstat as lstat4 } from "node:fs/promises";
79690
80252
  import { resolve as resolve13 } from "node:path";
79691
80253
 
79692
80254
  // ../sdk/dist/store/evidence/index-page.js
79693
- import { createHash as createHash20, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
80255
+ import { createHash as createHash21, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
79694
80256
 
79695
80257
  // ../sdk/dist/store/evidence/compaction-provenance.js
79696
80258
  function record2(value) {
@@ -79805,7 +80367,7 @@ var positionSchema = external_exports.object({
79805
80367
  textIndex: integer3.default(0)
79806
80368
  });
79807
80369
  function evidenceSeal(sessionStart, sourceKey) {
79808
- const key6 = createHash20("sha256").update("namzu-session-evidence-v1\n").update(sessionStart).digest();
80370
+ const key6 = createHash21("sha256").update("namzu-session-evidence-v1\n").update(sessionStart).digest();
79809
80371
  const mac3 = /* @__PURE__ */ __name((value) => createHmac2("sha256", key6).update(`${sourceKey}
79810
80372
  ${value}`).digest(), "mac");
79811
80373
  return {
@@ -79899,7 +80461,7 @@ async function indexPage(handle, size, sessionId5, start, budget) {
79899
80461
  const parts = recordTexts(record4);
79900
80462
  if (textIndex > parts.length)
79901
80463
  throw new Error("Invalid textual part position.");
79902
- const hash3 = digest2(raw);
80464
+ const hash4 = digest2(raw);
79903
80465
  const tool = toolEntry(record4, offset, raw);
79904
80466
  records4++;
79905
80467
  while (textIndex < parts.length && entries2.length < 64) {
@@ -79909,7 +80471,7 @@ async function indexPage(handle, size, sessionId5, start, budget) {
79909
80471
  entries2.push(tool ?? entrySchema.parse({
79910
80472
  offset,
79911
80473
  length: raw.length,
79912
- sha256: hash3,
80474
+ sha256: hash4,
79913
80475
  seq: record4.seq,
79914
80476
  ...typeof record4.turnId === "string" ? { turnId: record4.turnId } : {},
79915
80477
  source: part2.source,
@@ -81990,7 +82552,7 @@ var InMemorySessionTokenBudgetStore = class {
81990
82552
  };
81991
82553
 
81992
82554
  // ../sdk/dist/store/checkpoint/contract.js
81993
- import { createHash as createHash21 } from "node:crypto";
82555
+ import { createHash as createHash22 } from "node:crypto";
81994
82556
  var CheckpointIntegrityError = class extends Error {
81995
82557
  static {
81996
82558
  __name(this, "CheckpointIntegrityError");
@@ -82025,7 +82587,7 @@ function serializeCheckpoint(checkpoint) {
82025
82587
  }
82026
82588
  __name(serializeCheckpoint, "serializeCheckpoint");
82027
82589
  function sha256Hex5(text9) {
82028
- return createHash21("sha256").update(text9, "utf8").digest("hex");
82590
+ return createHash22("sha256").update(text9, "utf8").digest("hex");
82029
82591
  }
82030
82592
  __name(sha256Hex5, "sha256Hex");
82031
82593
  function checkpointRecordPath(checkpointId4) {
@@ -83068,7 +83630,7 @@ __name(projectRecordedHistory, "projectRecordedHistory");
83068
83630
  function sameMessageContent(a, b) {
83069
83631
  const { id: _a4, timestamp: _ta, ...restA } = a;
83070
83632
  const { id: _b, timestamp: _tb, ...restB } = b;
83071
- return isDeepStrictEqual4(JSON.parse(JSON.stringify(restA)), JSON.parse(JSON.stringify(restB)));
83633
+ return isDeepStrictEqual5(JSON.parse(JSON.stringify(restA)), JSON.parse(JSON.stringify(restB)));
83072
83634
  }
83073
83635
  __name(sameMessageContent, "sameMessageContent");
83074
83636
  function staleCachedHistoryError(kind, message) {
@@ -83115,7 +83677,8 @@ function reconcileNoIdAgainstFold(caller, pool, hasId) {
83115
83677
  __name(reconcileNoIdAgainstFold, "reconcileNoIdAgainstFold");
83116
83678
  async function reconcileCallerMessages(messages, history, log, continuationMode) {
83117
83679
  const hasId = messages.some((message) => message.id !== void 0);
83118
- const recordedById = hasId ? await readEverRecordedMessages(log) : void 0;
83680
+ const everRecorded = hasId ? await readEverRecordedMessageIndex(log) : void 0;
83681
+ const recordedById = everRecorded?.latest;
83119
83682
  const claimedIds = /* @__PURE__ */ new Set();
83120
83683
  const noIdIndices = [];
83121
83684
  const noIdMessages = [];
@@ -83126,8 +83689,10 @@ async function reconcileCallerMessages(messages, history, log, continuationMode)
83126
83689
  const recorded = recordedById?.get(id3);
83127
83690
  if (recorded === void 0)
83128
83691
  throw staleCachedHistoryError("foreign", message);
83129
- if (!sameMessageContent(recorded, message))
83130
- throw staleCachedHistoryError("edited", message);
83692
+ if (!sameMessageContent(recorded, message)) {
83693
+ if (!await everRecorded?.heldBeforeAnEdit(id3, message))
83694
+ throw staleCachedHistoryError("edited", message);
83695
+ }
83131
83696
  claimedIds.add(id3);
83132
83697
  continue;
83133
83698
  }
@@ -84260,7 +84825,10 @@ ${annotations.join("\n\n")}`, "render")
84260
84825
  }, "pushSystemMessages");
84261
84826
  const pushRestored = /* @__PURE__ */ __name((message, ids) => {
84262
84827
  const messageId4 = ids.get(message);
84263
- ctx.recorder.pushMessage(message, messageId4 ? { messageId: messageId4 } : {});
84828
+ ctx.recorder.pushMessage(message, {
84829
+ ...messageId4 ? { messageId: messageId4 } : {},
84830
+ restored: true
84831
+ });
84264
84832
  }, "pushRestored");
84265
84833
  if (params.resumeFromCheckpoint) {
84266
84834
  const checkpoint = await checkpointMgr.restore(params.resumeFromCheckpoint);
@@ -85139,7 +85707,7 @@ async function startBidiTurn(params) {
85139
85707
  __name(startBidiTurn, "startBidiTurn");
85140
85708
 
85141
85709
  // ../sdk/dist/runtime/query/prompt-cache.js
85142
- import { createHash as createHash22 } from "node:crypto";
85710
+ import { createHash as createHash23 } from "node:crypto";
85143
85711
  var PromptCache = class {
85144
85712
  static {
85145
85713
  __name(this, "PromptCache");
@@ -85167,12 +85735,12 @@ var PromptCache = class {
85167
85735
  ...input2.contributions ? { contributions: input2.contributions } : {}
85168
85736
  });
85169
85737
  const prompt = builder.build();
85170
- const hash3 = this.computeConfigHash(input2, prompt);
85171
- if (this.cachedPrompt !== void 0 && this.cachedConfigHash === hash3) {
85738
+ const hash4 = this.computeConfigHash(input2, prompt);
85739
+ if (this.cachedPrompt !== void 0 && this.cachedConfigHash === hash4) {
85172
85740
  return this.cachedPrompt;
85173
85741
  }
85174
85742
  this.cachedPrompt = prompt;
85175
- this.cachedConfigHash = hash3;
85743
+ this.cachedConfigHash = hash4;
85176
85744
  return this.cachedPrompt;
85177
85745
  }
85178
85746
  get configHash() {
@@ -85214,7 +85782,7 @@ var PromptCache = class {
85214
85782
  this.cachedStaticHash = void 0;
85215
85783
  }
85216
85784
  computeStaticHash(staticSegment) {
85217
- return createHash22("sha256").update(staticSegment).digest("hex").slice(0, 16);
85785
+ return createHash23("sha256").update(staticSegment).digest("hex").slice(0, 16);
85218
85786
  }
85219
85787
  computeConfigHash(input2, prompt) {
85220
85788
  const parts = [
@@ -85224,7 +85792,7 @@ var PromptCache = class {
85224
85792
  // unsegmented text happens to be identical.
85225
85793
  input2.contributions?.list().map((c) => [c.id, c.placement]) ?? []
85226
85794
  ];
85227
- return createHash22("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 16);
85795
+ return createHash23("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 16);
85228
85796
  }
85229
85797
  };
85230
85798
 
@@ -88791,7 +89359,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
88791
89359
  };
88792
89360
 
88793
89361
  // ../sdk/dist/turn/workspace-fingerprint.js
88794
- import { createHash as createHash23 } from "node:crypto";
89362
+ import { createHash as createHash24 } from "node:crypto";
88795
89363
  import { lstat as lstat5, readFile as readFile13, readlink } from "node:fs/promises";
88796
89364
  import { join as join27 } from "node:path";
88797
89365
  var NODE_FS = { lstat: lstat5, readlink, readFile: readFile13 };
@@ -88807,7 +89375,7 @@ async function untrackedEntry(cwd, rel, fs) {
88807
89375
  if (!stats.isFile())
88808
89376
  return `? ${rel}`;
88809
89377
  const body = await fs.readFile(abs);
88810
- return `F ${rel}\0${createHash23("sha256").update(body).digest("hex")}`;
89378
+ return `F ${rel}\0${createHash24("sha256").update(body).digest("hex")}`;
88811
89379
  } catch {
88812
89380
  return null;
88813
89381
  }
@@ -88852,10 +89420,10 @@ async function fingerprintWorkspace(options) {
88852
89420
  return null;
88853
89421
  parts.push(entry);
88854
89422
  }
88855
- const hash3 = createHash23("sha256");
89423
+ const hash4 = createHash24("sha256");
88856
89424
  for (const part2 of parts)
88857
- hash3.update(`${Buffer.byteLength(part2, "utf8")}:${part2}`);
88858
- return hash3.digest("hex");
89425
+ hash4.update(`${Buffer.byteLength(part2, "utf8")}:${part2}`);
89426
+ return hash4.digest("hex");
88859
89427
  }
88860
89428
  __name(fingerprintWorkspace, "fingerprintWorkspace");
88861
89429
 
@@ -89082,7 +89650,7 @@ function createMemoryPromoter(options) {
89082
89650
  __name(createMemoryPromoter, "createMemoryPromoter");
89083
89651
 
89084
89652
  // ../sdk/dist/turn/json-claim-verifier.js
89085
- import { createHash as createHash24, randomUUID as randomUUID5 } from "node:crypto";
89653
+ import { createHash as createHash25, randomUUID as randomUUID5 } from "node:crypto";
89086
89654
  import { performance as performance2 } from "node:perf_hooks";
89087
89655
  function scalar(value) {
89088
89656
  return value === null || typeof value === "boolean" || typeof value === "string" && value.length <= 2e3 || typeof value === "number" && Number.isSafeInteger(value);
@@ -89215,7 +89783,7 @@ function createJsonClaimVerifier(options) {
89215
89783
  requestId: request.requestId,
89216
89784
  observedAt: observation.observedAt,
89217
89785
  bytes: bytes.byteLength,
89218
- sha256: createHash24("sha256").update(bytes).digest("hex")
89786
+ sha256: createHash25("sha256").update(bytes).digest("hex")
89219
89787
  });
89220
89788
  }
89221
89789
  ensureActive();
@@ -91196,7 +91764,7 @@ function deriveTurnOptions(manifest, input2) {
91196
91764
  __name(deriveTurnOptions, "deriveTurnOptions");
91197
91765
 
91198
91766
  // ../sdk/dist/agents/runAgent.js
91199
- import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
91767
+ import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
91200
91768
 
91201
91769
  // ../sdk/dist/capabilities/index.js
91202
91770
  function assertCapabilityId(id3) {
@@ -91343,7 +91911,7 @@ var DEFAULT_MAX_ITERATIONS = 16;
91343
91911
  var DEFAULT_TOKEN_BUDGET = 2e5;
91344
91912
  var DEFAULT_TIMEOUT_MS = 3e5;
91345
91913
  async function runAgent(options) {
91346
- if (options.verificationGate && options.authorizationGate && !isDeepStrictEqual5(options.verificationGate, options.authorizationGate)) {
91914
+ if (options.verificationGate && options.authorizationGate && !isDeepStrictEqual6(options.verificationGate, options.authorizationGate)) {
91347
91915
  throw new Error("runAgent: verificationGate and authorizationGate must name the same policy.");
91348
91916
  }
91349
91917
  const authorizationGate = options.authorizationGate ?? options.verificationGate;
@@ -94190,7 +94758,7 @@ var DiskTaskStore = class {
94190
94758
  };
94191
94759
 
94192
94760
  // ../sdk/dist/store/memory/revision.js
94193
- import { createHash as createHash25 } from "node:crypto";
94761
+ import { createHash as createHash26 } from "node:crypto";
94194
94762
  var MemoryRevisionUnavailableError = class extends Error {
94195
94763
  static {
94196
94764
  __name(this, "MemoryRevisionUnavailableError");
@@ -94296,7 +94864,7 @@ function canonicalRecord(record4) {
94296
94864
  }
94297
94865
  __name(canonicalRecord, "canonicalRecord");
94298
94866
  function memoryRevision(record4) {
94299
- return `m2:${createHash25("sha256").update(canonicalRecord(record4)).digest("hex")}`;
94867
+ return `m2:${createHash26("sha256").update(canonicalRecord(record4)).digest("hex")}`;
94300
94868
  }
94301
94869
  __name(memoryRevision, "memoryRevision");
94302
94870
  var MemoryRevisionConflictError = class extends NamzuError {
@@ -95056,7 +95624,7 @@ var DiskMemoryStore = class {
95056
95624
  };
95057
95625
 
95058
95626
  // ../sdk/dist/store/memory/markdown.js
95059
- import { createHash as createHash26 } from "node:crypto";
95627
+ import { createHash as createHash27 } from "node:crypto";
95060
95628
  import { lstat as lstat8, mkdir as mkdir15, readFile as readFile18, readdir as readdir11, realpath as realpath9, rename as rename6, unlink as unlink12 } from "node:fs/promises";
95061
95629
  import { dirname as dirname19, join as join34, resolve as resolve18 } from "node:path";
95062
95630
 
@@ -95296,7 +95864,7 @@ function invalidFile(file2, reason, cause) {
95296
95864
  }
95297
95865
  __name(invalidFile, "invalidFile");
95298
95866
  function derivedMemoryId(name2) {
95299
- const hex4 = createHash26("sha256").update(`namzu-memory-name:${name2}`).digest("hex");
95867
+ const hex4 = createHash27("sha256").update(`namzu-memory-name:${name2}`).digest("hex");
95300
95868
  const variant = (Number.parseInt(hex4[16] ?? "0", 16) & 3 | 8).toString(16);
95301
95869
  return `${hex4.slice(0, 8)}-${hex4.slice(8, 12)}-8${hex4.slice(13, 16)}-${variant}${hex4.slice(17, 20)}-${hex4.slice(20, 32)}`;
95302
95870
  }
@@ -100817,7 +101385,7 @@ function toolResultToMCPToolResult(result) {
100817
101385
  __name(toolResultToMCPToolResult, "toolResultToMCPToolResult");
100818
101386
 
100819
101387
  // ../sdk/dist/connector/mcp/policy.js
100820
- import { createHash as createHash27 } from "node:crypto";
101388
+ import { createHash as createHash28 } from "node:crypto";
100821
101389
  function applyToolPolicy(tools, policy) {
100822
101390
  return applyNamePolicy(tools, policy);
100823
101391
  }
@@ -100857,7 +101425,7 @@ function toolsHash(tools) {
100857
101425
  // fingerprint built to catch exactly that rug-pull saw nothing.
100858
101426
  annotations: stableStringify2(tool.annotations)
100859
101427
  }));
100860
- return createHash27("sha256").update(JSON.stringify(canonical3)).digest("hex");
101428
+ return createHash28("sha256").update(JSON.stringify(canonical3)).digest("hex");
100861
101429
  }
100862
101430
  __name(toolsHash, "toolsHash");
100863
101431
  function diffTools(before, after) {
@@ -101080,7 +101648,7 @@ var MCPToolDiscovery = class {
101080
101648
  };
101081
101649
 
101082
101650
  // ../sdk/dist/connector/mcp/mcp-toolset.js
101083
- import { createHash as createHash28 } from "node:crypto";
101651
+ import { createHash as createHash29 } from "node:crypto";
101084
101652
 
101085
101653
  // ../sdk/dist/connector/mcp/prompt-adapter.js
101086
101654
  function renderPromptMessages(serverName, promptName, messages, description) {
@@ -101151,8 +101719,8 @@ function mcpToolsetName(serverName, ...segments) {
101151
101719
  const full = ["mcp", serverName, ...segments].join("__");
101152
101720
  if (full.length <= MCP_TOOLSET_NAME_MAX_LENGTH)
101153
101721
  return full;
101154
- const hash3 = createHash28("sha256").update(full).digest("hex").slice(0, 8);
101155
- const suffix = `_${hash3}`;
101722
+ const hash4 = createHash29("sha256").update(full).digest("hex").slice(0, 8);
101723
+ const suffix = `_${hash4}`;
101156
101724
  return `${full.slice(0, MCP_TOOLSET_NAME_MAX_LENGTH - suffix.length)}${suffix}`;
101157
101725
  }
101158
101726
  __name(mcpToolsetName, "mcpToolsetName");
@@ -117122,7 +117690,7 @@ var InMemorySessionStore = class {
117122
117690
  };
117123
117691
 
117124
117692
  // ../sdk/dist/store/session/disk.js
117125
- import { createHash as createHash29 } from "node:crypto";
117693
+ import { createHash as createHash30 } from "node:crypto";
117126
117694
  import { mkdir as mkdir19, rm as rm7 } from "node:fs/promises";
117127
117695
  import { join as join42, resolve as resolve25 } from "node:path";
117128
117696
  var SCHEMA9 = defineSchema({
@@ -117291,7 +117859,7 @@ var DiskSessionStore = class {
117291
117859
  }
117292
117860
  rootPathBindingLocation(rootPath, tenantId2) {
117293
117861
  const key6 = rootPathIndexKey(rootPath, tenantId2);
117294
- const digest8 = createHash29("sha256").update(key6).digest("hex");
117862
+ const digest8 = createHash30("sha256").update(key6).digest("hex");
117295
117863
  const root = join42(this.rootDir, "projects", ".root-path-index", digest8.slice(0, 2));
117296
117864
  return {
117297
117865
  legacyPath: join42(root, `${digest8.slice(2)}.json`),
@@ -119541,7 +120109,7 @@ function analyzeContextUsage(input2) {
119541
120109
  __name(analyzeContextUsage, "analyzeContextUsage");
119542
120110
 
119543
120111
  // ../sdk/dist/learning/skill.js
119544
- import { createHash as createHash30 } from "node:crypto";
120112
+ import { createHash as createHash31 } from "node:crypto";
119545
120113
  var label = external_exports.string().trim().min(1).max(256);
119546
120114
  var name = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
119547
120115
  var digest3 = external_exports.string().regex(/^[a-f0-9]{64}$/);
@@ -119694,7 +120262,7 @@ function reviseLearningProfile(current, input2) {
119694
120262
  __name(reviseLearningProfile, "reviseLearningProfile");
119695
120263
  function hashLearningSkill(input2) {
119696
120264
  const candidate = candidateSchema.parse(input2);
119697
- return createHash30("sha256").update(JSON.stringify([
120265
+ return createHash31("sha256").update(JSON.stringify([
119698
120266
  candidate.name,
119699
120267
  candidate.description,
119700
120268
  candidate.body,
@@ -119706,7 +120274,7 @@ __name(hashLearningSkill, "hashLearningSkill");
119706
120274
  function promoteLearningSkill(current, input2, evaluation, inputEvidence) {
119707
120275
  const protection = normalizeHarnessProtection(evaluation.protection);
119708
120276
  const candidate = candidateSchema.parse(input2);
119709
- const hash3 = hashLearningSkill(candidate);
120277
+ const hash4 = hashLearningSkill(candidate);
119710
120278
  const baseline = current?.skills.find((s) => s.name === candidate.name);
119711
120279
  if (baseline && (baseline.purpose ?? "task") !== (candidate.purpose ?? "task"))
119712
120280
  throw new Error("A skill cannot change learning purpose; use a distinct skill name.");
@@ -119715,7 +120283,7 @@ function promoteLearningSkill(current, input2, evaluation, inputEvidence) {
119715
120283
  for (const batch of [evaluation.verification, evaluation.confirmation]) {
119716
120284
  if (!batch)
119717
120285
  continue;
119718
- if (batch.baselineRevision !== baselineHash || batch.candidateRevision !== hash3)
120286
+ if (batch.baselineRevision !== baselineHash || batch.candidateRevision !== hash4)
119719
120287
  throw new Error("Skill evaluation does not match the active baseline and candidate digests.");
119720
120288
  if (batch.baseline.length > 128 || batch.candidate.length > 128 || batch.attributions.length > 128)
119721
120289
  throw new Error("Skill evaluation is bounded to 64 tasks per round.");
@@ -119729,18 +120297,18 @@ function promoteLearningSkill(current, input2, evaluation, inputEvidence) {
119729
120297
  throw new Error(`Skill promotion ${review.decision}: ${review.reason}`);
119730
120298
  const skill = {
119731
120299
  ...candidate,
119732
- hash: hash3,
120300
+ hash: hash4,
119733
120301
  evidence,
119734
120302
  verification: {
119735
120303
  baselineHash,
119736
- candidateHash: hash3,
119737
- evidenceDigest: createHash30("sha256").update(JSON.stringify({ ...evaluation, protection })).digest("hex"),
120304
+ candidateHash: hash4,
120305
+ evidenceDigest: createHash31("sha256").update(JSON.stringify({ ...evaluation, protection })).digest("hex"),
119738
120306
  verificationTasks: review.verification.tasks.length,
119739
120307
  confirmationTasks: review.confirmation?.tasks.length ?? 0,
119740
120308
  protection: {
119741
120309
  verificationTasks: protection.verification.length,
119742
120310
  confirmationTasks: protection.confirmation.length,
119743
- planDigest: createHash30("sha256").update(JSON.stringify(protection)).digest("hex")
120311
+ planDigest: createHash31("sha256").update(JSON.stringify(protection)).digest("hex")
119744
120312
  }
119745
120313
  }
119746
120314
  };
@@ -119849,13 +120417,13 @@ function projectLearning(current, options) {
119849
120417
  __name(projectLearning, "projectLearning");
119850
120418
 
119851
120419
  // ../sdk/dist/learning/cycle.js
119852
- import { createHash as createHash32, randomUUID as randomUUID9 } from "node:crypto";
120420
+ import { createHash as createHash33, randomUUID as randomUUID9 } from "node:crypto";
119853
120421
 
119854
120422
  // ../sdk/dist/learning/guidance.js
119855
- import { createHash as createHash31 } from "node:crypto";
120423
+ import { createHash as createHash32 } from "node:crypto";
119856
120424
  import { readdir as readdir15 } from "node:fs/promises";
119857
120425
  import { join as join43 } from "node:path";
119858
- import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
120426
+ import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
119859
120427
  var LearningGuidanceConflictError = class extends Error {
119860
120428
  static {
119861
120429
  __name(this, "LearningGuidanceConflictError");
@@ -119897,7 +120465,7 @@ var ADOPTED_MARKER = "adopted.json";
119897
120465
  var REVISION_FILE = /^([1-9][0-9]{0,15})\.json$/;
119898
120466
  function keySegment(key6) {
119899
120467
  const encoded = revisionFileSegment(key6);
119900
- return encoded.length <= 255 ? encoded : `~sha256-${createHash31("sha256").update(encoded).digest("hex")}`;
120468
+ return encoded.length <= 255 ? encoded : `~sha256-${createHash32("sha256").update(encoded).digest("hex")}`;
119901
120469
  }
119902
120470
  __name(keySegment, "keySegment");
119903
120471
  function earlierGuidanceDirectory(root, scope) {
@@ -120054,7 +120622,7 @@ var DiskLearningGuidance = class {
120054
120622
  const current = this.checked(record4);
120055
120623
  if (current.revision !== snapshot.revision)
120056
120624
  throw new LearningGuidanceConflictError();
120057
- if (!isDeepStrictEqual6(current.learning, snapshot.learning))
120625
+ if (!isDeepStrictEqual7(current.learning, snapshot.learning))
120058
120626
  throw new LearningGuidanceConflictError();
120059
120627
  const next2 = this.checked({ ...current, learning, revision: current.revision + 1 });
120060
120628
  return { record: next2, result: next2 };
@@ -120467,7 +121035,7 @@ ${exploration.evidence.reason}`
120467
121035
  }, { subject: "exploration.trace", text: exploration.trace });
120468
121036
  await append("exploration", {
120469
121037
  observations: exploration,
120470
- digest: createHash32("sha256").update(JSON.stringify(exploration)).digest("hex")
121038
+ digest: createHash33("sha256").update(JSON.stringify(exploration)).digest("hex")
120471
121039
  }, "explore");
120472
121040
  const problem2 = resourceProblem(true);
120473
121041
  if (problem2)
@@ -120516,7 +121084,7 @@ ${s.revision}`).join("\n"),
120516
121084
  await append("evaluation", {
120517
121085
  baselineRevision,
120518
121086
  candidateRevision,
120519
- digest: createHash32("sha256").update(JSON.stringify(batch)).digest("hex"),
121087
+ digest: createHash33("sha256").update(JSON.stringify(batch)).digest("hex"),
120520
121088
  baselineTrajectories: batch.baseline.map((t) => t.trajectoryId),
120521
121089
  candidateTrajectories: batch.candidate.map((t) => t.trajectoryId)
120522
121090
  }, name2);
@@ -121047,7 +121615,7 @@ var SqliteLearningExperienceStore = class {
121047
121615
  };
121048
121616
 
121049
121617
  // ../sdk/dist/learning/store.js
121050
- import { createHash as createHash33, randomUUID as randomUUID11 } from "node:crypto";
121618
+ import { createHash as createHash34, randomUUID as randomUUID11 } from "node:crypto";
121051
121619
  import { closeSync as closeSync2, existsSync as existsSync6, fsyncSync, linkSync, lstatSync as lstatSync4, mkdirSync as mkdirSync5, openSync as openSync2, readFileSync as readFileSync4, unlinkSync, writeFileSync as writeFileSync3 } from "node:fs";
121052
121620
  import { createRequire as createRequire4 } from "node:module";
121053
121621
  import { dirname as dirname24, join as join44, resolve as resolve27 } from "node:path";
@@ -121076,7 +121644,7 @@ var learningObservationSchema = learningTargetSchema.extend({
121076
121644
 
121077
121645
  // ../sdk/dist/learning/store.js
121078
121646
  var uuid5 = external_exports.string().uuid().transform((id3) => id3.toLowerCase());
121079
- var digest4 = /* @__PURE__ */ __name((text9) => createHash33("sha256").update(text9).digest("hex"), "digest");
121647
+ var digest4 = /* @__PURE__ */ __name((text9) => createHash34("sha256").update(text9).digest("hex"), "digest");
121080
121648
  var MAX_EVENT_BYTES = 256 * 1024;
121081
121649
  var MAX_ARTIFACT_BYTES = 8 * 1024 * 1024;
121082
121650
  var MAX_EVENTS = 4096;
@@ -121399,7 +121967,7 @@ var SqliteLearningStore = class {
121399
121967
  this.claimObservation(db, event);
121400
121968
  let status = row.status;
121401
121969
  let result = null;
121402
- let hash3 = row.candidate_hash;
121970
+ let hash4 = row.candidate_hash;
121403
121971
  if (event.kind === "usage") {
121404
121972
  const receipt2 = external_exports.object({
121405
121973
  sessionId: uuid5,
@@ -121415,7 +121983,7 @@ var SqliteLearningStore = class {
121415
121983
  db.prepare("UPDATE cycles SET tokens = tokens + ?, cost_usd = cost_usd + ?, receipts = receipts + 1, unknown_tokens = unknown_tokens + ?, unknown_costs = unknown_costs + ? WHERE id = ?").run(receipt2.tokens ?? 0, receipt2.costUsd ?? 0, Number(receipt2.tokens === null), Number(receipt2.costUsd === null), event.cycleId);
121416
121984
  }
121417
121985
  if (event.kind === "candidate")
121418
- hash3 = external_exports.string().regex(/^[0-9a-f]{64}$/).parse(event.data.candidateRevision);
121986
+ hash4 = external_exports.string().regex(/^[0-9a-f]{64}$/).parse(event.data.candidateRevision);
121419
121987
  if (event.kind === "activation-requested")
121420
121988
  status = "activation-pending";
121421
121989
  if (event.kind === "finished") {
@@ -121447,7 +122015,7 @@ var SqliteLearningStore = class {
121447
122015
  result = JSON.stringify(value);
121448
122016
  }
121449
122017
  db.prepare("INSERT INTO events VALUES (?, ?, ?)").run(event.cycleId, event.sequence, body);
121450
- db.prepare("UPDATE cycles SET sequence = ?, status = ?, updated_at = ?, candidate_hash = ?, result = ? WHERE id = ?").run(event.sequence, status, Date.now(), hash3, result, event.cycleId);
122018
+ db.prepare("UPDATE cycles SET sequence = ?, status = ?, updated_at = ?, candidate_hash = ?, result = ? WHERE id = ?").run(event.sequence, status, Date.now(), hash4, result, event.cycleId);
121451
122019
  });
121452
122020
  }
121453
122021
  async get(cycleId) {
@@ -121795,7 +122363,7 @@ function parsePeerAddress(address2) {
121795
122363
  __name(parsePeerAddress, "parsePeerAddress");
121796
122364
 
121797
122365
  // ../sdk/dist/peers/record.js
121798
- import { createHash as createHash34 } from "node:crypto";
122366
+ import { createHash as createHash35 } from "node:crypto";
121799
122367
 
121800
122368
  // ../sdk/dist/peers/protocol.js
121801
122369
  var PEER_PROTOCOL_VERSION = "namzu-peer/1";
@@ -121933,7 +122501,7 @@ var PeerRecordSchema = external_exports.object({
121933
122501
  var PeerRecordReaderSchema = PeerRecordSchema.strip();
121934
122502
  var PEER_REF_HEX_LENGTH = 6;
121935
122503
  function derivePeerRef(sessionId5) {
121936
- return createHash34("sha256").update(sessionId5, "utf8").digest("hex").slice(0, PEER_REF_HEX_LENGTH);
122504
+ return createHash35("sha256").update(sessionId5, "utf8").digest("hex").slice(0, PEER_REF_HEX_LENGTH);
121937
122505
  }
121938
122506
  __name(derivePeerRef, "derivePeerRef");
121939
122507
 
@@ -124089,7 +124657,7 @@ var PAL_WORK_GUIDANCE = [
124089
124657
  ].join("\n\n");
124090
124658
 
124091
124659
  // ../sdk/dist/pals/reference-images.js
124092
- import { createHash as createHash35, randomUUID as randomUUID13 } from "node:crypto";
124660
+ import { createHash as createHash36, randomUUID as randomUUID13 } from "node:crypto";
124093
124661
  import { posix as posix4 } from "node:path";
124094
124662
  var MAX_IMAGES = 8;
124095
124663
  var MAX_IMAGE_BYTES = 3 * 1024 * 1024;
@@ -124133,7 +124701,7 @@ function preparePalReferenceImages(attachments) {
124133
124701
  attachmentIndex: index + 1,
124134
124702
  mediaType: attachment.mediaType,
124135
124703
  data: attachment.data,
124136
- sha256: createHash35("sha256").update(bytes).digest("hex"),
124704
+ sha256: createHash36("sha256").update(bytes).digest("hex"),
124137
124705
  bytes: bytes.length
124138
124706
  }));
124139
124707
  }
@@ -124314,13 +124882,13 @@ __name(createPalReferenceImageTool, "createPalReferenceImageTool");
124314
124882
  import { randomUUID as randomUUID14 } from "node:crypto";
124315
124883
  import { chmodSync as chmodSync5, lstatSync as lstatSync9, mkdirSync as mkdirSync10, readdirSync as readdirSync4, realpathSync as realpathSync8 } from "node:fs";
124316
124884
  import { join as join51, resolve as resolve30 } from "node:path";
124317
- import { isDeepStrictEqual as isDeepStrictEqual9 } from "node:util";
124885
+ import { isDeepStrictEqual as isDeepStrictEqual10 } from "node:util";
124318
124886
 
124319
124887
  // ../sdk/dist/pals/communication/ingress-schema.js
124320
- import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
124888
+ import { isDeepStrictEqual as isDeepStrictEqual8 } from "node:util";
124321
124889
 
124322
124890
  // ../sdk/dist/pals/communication/schema.js
124323
- import { createHash as createHash36 } from "node:crypto";
124891
+ import { createHash as createHash37 } from "node:crypto";
124324
124892
  var id2 = external_exports.string().uuid();
124325
124893
  var sessionId3 = external_exports.custom((s) => isEntityId(s, "session"));
124326
124894
  var turnId4 = external_exports.custom((s) => isEntityId(s, "turn"));
@@ -124414,10 +124982,10 @@ function freezeCommunicationValue(value) {
124414
124982
  return value;
124415
124983
  }
124416
124984
  __name(freezeCommunicationValue, "freezeCommunicationValue");
124417
- function hash2(value) {
124418
- return createHash36("sha256").update(JSON.stringify(value)).digest("hex");
124985
+ function hash3(value) {
124986
+ return createHash37("sha256").update(JSON.stringify(value)).digest("hex");
124419
124987
  }
124420
- __name(hash2, "hash");
124988
+ __name(hash3, "hash");
124421
124989
  function addressTuple(value) {
124422
124990
  return [value.tenantId, value.palId];
124423
124991
  }
@@ -124434,11 +125002,11 @@ function routeTuple(value) {
124434
125002
  }
124435
125003
  __name(routeTuple, "routeTuple");
124436
125004
  function routeId(value) {
124437
- return hash2(routeTuple(routeKeySchema.parse(value)));
125005
+ return hash3(routeTuple(routeKeySchema.parse(value)));
124438
125006
  }
124439
125007
  __name(routeId, "routeId");
124440
125008
  function messageId3(source, operationId) {
124441
- return hash2([
125009
+ return hash3([
124442
125010
  1,
124443
125011
  "pal-message",
124444
125012
  addressTuple(source.address),
@@ -124448,7 +125016,7 @@ function messageId3(source, operationId) {
124448
125016
  }
124449
125017
  __name(messageId3, "messageId");
124450
125018
  function intentDigest(intent) {
124451
- return hash2([
125019
+ return hash3([
124452
125020
  1,
124453
125021
  addressTuple(intent.source.address),
124454
125022
  intent.source.conversationId,
@@ -124783,14 +125351,14 @@ function ingressRouteTuple(key6) {
124783
125351
  __name(ingressRouteTuple, "ingressRouteTuple");
124784
125352
  function ingressRouteId(key6) {
124785
125353
  const parsed = ingressRouteKeySchema.parse(key6);
124786
- return parsed.kind === "pal" ? routeId(parsed) : hash2(ingressRouteTuple(parsed));
125354
+ return parsed.kind === "pal" ? routeId(parsed) : hash3(ingressRouteTuple(parsed));
124787
125355
  }
124788
125356
  __name(ingressRouteId, "ingressRouteId");
124789
125357
  function ingressIntentId(intent) {
124790
125358
  if (!("kind" in intent))
124791
125359
  return messageId3(intent.source, intent.operationId);
124792
125360
  if (intent.kind === "observation")
124793
- return hash2([
125361
+ return hash3([
124794
125362
  1,
124795
125363
  "pal-observation",
124796
125364
  intent.source.subscriptionId,
@@ -124798,14 +125366,14 @@ function ingressIntentId(intent) {
124798
125366
  intent.fact.id
124799
125367
  ]);
124800
125368
  if (intent.kind === "operator")
124801
- return hash2([
125369
+ return hash3([
124802
125370
  1,
124803
125371
  "pal-operator",
124804
125372
  intent.source.tenantId,
124805
125373
  intent.source.sessionId,
124806
125374
  intent.operationId
124807
125375
  ]);
124808
- return hash2([
125376
+ return hash3([
124809
125377
  1,
124810
125378
  "pal-channel",
124811
125379
  intent.source.tenantId,
@@ -124818,7 +125386,7 @@ function ingressIntentDigest(intent) {
124818
125386
  if (!("kind" in intent))
124819
125387
  return intentDigest(intent);
124820
125388
  if (intent.kind === "observation")
124821
- return hash2([
125389
+ return hash3([
124822
125390
  1,
124823
125391
  "observation",
124824
125392
  intent.source.subscriptionId,
@@ -124844,7 +125412,7 @@ function ingressIntentDigest(intent) {
124844
125412
  intent.subscriptionTrail
124845
125413
  ]);
124846
125414
  if (intent.kind === "operator")
124847
- return hash2([
125415
+ return hash3([
124848
125416
  1,
124849
125417
  "operator",
124850
125418
  intent.source.tenantId,
@@ -124854,7 +125422,7 @@ function ingressIntentDigest(intent) {
124854
125422
  ingressRouteTuple(intent.routeKey),
124855
125423
  intent.body
124856
125424
  ]);
124857
- return hash2([
125425
+ return hash3([
124858
125426
  1,
124859
125427
  "channel",
124860
125428
  intent.source.tenantId,
@@ -124877,12 +125445,12 @@ function checkedIngressIntent(value) {
124877
125445
  if (!sameAddress(intent.source.address, intent.routeKey.sender) || intent.source.conversationId !== intent.routeKey.senderConversationId)
124878
125446
  throw new Error("Invalid immutable Pal source operation.");
124879
125447
  } else if (intent.kind === "observation") {
124880
- if (intent.recipient.tenantId !== intent.source.scope.tenantId || intent.source.subscriptionId !== intent.routeKey.subscriptionId || !isDeepStrictEqual7(intent.source.scope, intent.routeKey.scope))
125448
+ if (intent.recipient.tenantId !== intent.source.scope.tenantId || intent.source.subscriptionId !== intent.routeKey.subscriptionId || !isDeepStrictEqual8(intent.source.scope, intent.routeKey.scope))
124881
125449
  throw new Error("Foreign observation source or route.");
124882
125450
  } else if (intent.kind === "operator") {
124883
125451
  if (intent.source.tenantId !== intent.recipient.tenantId || intent.source.sessionId !== intent.routeKey.conversationId)
124884
125452
  throw new Error("Foreign operator conversation source or route.");
124885
- } else if (intent.source.tenantId !== intent.recipient.tenantId || !isDeepStrictEqual7(nativeChannelTuple(intent.source), nativeChannelTuple(intent.routeKey)))
125453
+ } else if (intent.source.tenantId !== intent.recipient.tenantId || !isDeepStrictEqual8(nativeChannelTuple(intent.source), nativeChannelTuple(intent.routeKey)))
124886
125454
  throw new Error("Foreign channel source or route.");
124887
125455
  return freezeCommunicationValue(intent);
124888
125456
  }
@@ -124954,7 +125522,7 @@ function currentIngressRecipient(pals, binding) {
124954
125522
  __name(currentIngressRecipient, "currentIngressRecipient");
124955
125523
 
124956
125524
  // ../sdk/dist/pals/communication/verify.js
124957
- import { isDeepStrictEqual as isDeepStrictEqual8 } from "node:util";
125525
+ import { isDeepStrictEqual as isDeepStrictEqual9 } from "node:util";
124958
125526
  function capturedContext(input2) {
124959
125527
  return {
124960
125528
  binding: freezeCommunicationValue(ingressBindingSchema.parse(input2.binding)),
@@ -124991,7 +125559,7 @@ function checkedDelivery(input2, context2) {
124991
125559
  for (const key6 of ["ordinal", "routeId", "phase", "claim", "receipt"])
124992
125560
  delete raw[key6];
124993
125561
  checkedIngressIntent(raw);
124994
- if (message.routeId !== ingressRouteId(message.routeKey) || context2.binding.id !== ingressRouteId(context2.binding.key) || context2.binding.id !== message.routeId || !isDeepStrictEqual8(context2.binding.key, message.routeKey) || !message.claim || message.claim.sessionId !== context2.binding.sessionId)
125562
+ if (message.routeId !== ingressRouteId(message.routeKey) || context2.binding.id !== ingressRouteId(context2.binding.key) || context2.binding.id !== message.routeId || !isDeepStrictEqual9(context2.binding.key, message.routeKey) || !message.claim || message.claim.sessionId !== context2.binding.sessionId)
124995
125563
  throw new Error("Foreign delivery route or claim.");
124996
125564
  return message;
124997
125565
  }
@@ -125004,7 +125572,7 @@ async function matches(entry, message, context2) {
125004
125572
  if (!content || content.role !== "user" || content.content !== message.claim.content || !content.source || typeof content.source !== "object")
125005
125573
  return false;
125006
125574
  const source = content.source;
125007
- return source.type === "runtime-context" && source.kind === ingressRuntimeContextKind(message) && isDeepStrictEqual8(source.deliveryRef, ingressMessageRef(message));
125575
+ return source.type === "runtime-context" && source.kind === ingressRuntimeContextKind(message) && isDeepStrictEqual9(source.deliveryRef, ingressMessageRef(message));
125008
125576
  }
125009
125577
  __name(matches, "matches");
125010
125578
  async function findRecordedIngressMessage(inputMessage, inputContext, through) {
@@ -125026,7 +125594,7 @@ async function verifyIngressRecorded(inputMessage, inputReceipt, inputContext) {
125026
125594
  const context2 = capturedContext(inputContext);
125027
125595
  const message = checkedDelivery(inputMessage, context2);
125028
125596
  const receipt2 = ingressReceiptSchema.parse(inputReceipt);
125029
- if (!message.claim || context2.binding.id !== message.routeId || !isDeepStrictEqual8(context2.binding.key, message.routeKey) || !isDeepStrictEqual8(receipt2.ref, ingressMessageRef(message)) || receipt2.claimId !== message.claim.id || receipt2.sessionId !== message.claim.sessionId || receipt2.turnId !== message.claim.turnId || receipt2.through.gen < message.claim.generation)
125597
+ if (!message.claim || context2.binding.id !== message.routeId || !isDeepStrictEqual9(context2.binding.key, message.routeKey) || !isDeepStrictEqual9(receipt2.ref, ingressMessageRef(message)) || receipt2.claimId !== message.claim.id || receipt2.sessionId !== message.claim.sessionId || receipt2.turnId !== message.claim.turnId || receipt2.through.gen < message.claim.generation)
125030
125598
  throw new Error("Foreign delivery route or receipt.");
125031
125599
  const { entry } = await findRecordedIngressMessage(message, context2, receipt2.through);
125032
125600
  if (!entry || entry.record.type !== "message" || entry.record.messageId !== receipt2.messageId || entry.record.seq > receipt2.through.pointer.seq)
@@ -125143,7 +125711,7 @@ var DiskPalCommunicationStore = class {
125143
125711
  location(recipient) {
125144
125712
  const address2 = addressSchema2.parse(recipient);
125145
125713
  this.directory(this.root);
125146
- const directory = join51(this.root, hash2(addressTuple(address2)));
125714
+ const directory = join51(this.root, hash3(addressTuple(address2)));
125147
125715
  return this.commitLocation(directory);
125148
125716
  }
125149
125717
  commitLocation(directory) {
@@ -125223,7 +125791,7 @@ var DiskPalCommunicationStore = class {
125223
125791
  delete raw[key6];
125224
125792
  this.checkedIntent(raw);
125225
125793
  const binding = routes.get(message.routeId);
125226
- if (!binding || !isDeepStrictEqual9(binding.key, message.routeKey) || !sameAddress(message.recipient, recipient) || ids.has(message.id) || message.ordinal <= ordinal)
125794
+ if (!binding || !isDeepStrictEqual10(binding.key, message.routeKey) || !sameAddress(message.recipient, recipient) || ids.has(message.id) || message.ordinal <= ordinal)
125227
125795
  throw new Error("Invalid immutable Pal incoming intent.");
125228
125796
  ids.add(message.id);
125229
125797
  ordinal = message.ordinal;
@@ -125280,7 +125848,7 @@ var DiskPalCommunicationStore = class {
125280
125848
  return this.changeRaw(intent.recipient, (current) => {
125281
125849
  const routes = current?.routes ?? [];
125282
125850
  let binding = routes.find((r) => r.id === id3);
125283
- if (binding && (!isDeepStrictEqual9(binding.key, intent.routeKey) || pinnedConversationId !== null && binding.sessionId !== pinnedConversationId))
125851
+ if (binding && (!isDeepStrictEqual10(binding.key, intent.routeKey) || pinnedConversationId !== null && binding.sessionId !== pinnedConversationId))
125284
125852
  conflict("Route identity names another immutable conversation.");
125285
125853
  const existing = current?.messages.find((m) => m.id === intent.id);
125286
125854
  if (existing) {
@@ -125322,12 +125890,12 @@ var DiskPalCommunicationStore = class {
125322
125890
  return (await this.readRaw(parsed.recipient))?.routes.find((r) => r.id === ingressRouteId(parsed)) ?? null;
125323
125891
  }
125324
125892
  async activateIngress(binding, context2) {
125325
- if (!isDeepStrictEqual9(context2.binding, binding))
125893
+ if (!isDeepStrictEqual10(context2.binding, binding))
125326
125894
  throw new Error("Foreign route activation context.");
125327
125895
  await verifyIngressConversation(context2);
125328
125896
  return this.changeRaw(binding.key.recipient, (state) => {
125329
125897
  const current = state?.routes.find((r) => r.id === binding.id);
125330
- if (!state || !current || !isDeepStrictEqual9(current, binding))
125898
+ if (!state || !current || !isDeepStrictEqual10(current, binding))
125331
125899
  conflict("Route claim changed.");
125332
125900
  if (current.phase === "active")
125333
125901
  return { state: null, result: current };
@@ -125357,7 +125925,7 @@ var DiskPalCommunicationStore = class {
125357
125925
  if (!state || unresolved)
125358
125926
  return { state: null, result: null };
125359
125927
  const current = state.routes.find((r) => r.id === binding.id);
125360
- if (!current || current.phase !== "active" || !isDeepStrictEqual9(current, binding))
125928
+ if (!current || current.phase !== "active" || !isDeepStrictEqual10(current, binding))
125361
125929
  conflict("Route is not active.");
125362
125930
  const message = state.messages.find((m) => m.routeId === binding.id && m.phase === "pending");
125363
125931
  if (!message)
@@ -125433,7 +126001,7 @@ var DiskPalCommunicationStore = class {
125433
126001
  }
125434
126002
  checkedReceipt(message, input2) {
125435
126003
  const value = ingressReceiptSchema.parse(input2);
125436
- if (!message.claim || !isDeepStrictEqual9(value.ref, ingressMessageRef(message)) || value.claimId !== message.claim.id || value.sessionId !== message.claim.sessionId || value.turnId !== message.claim.turnId || value.through.gen < message.claim.generation || value.through.bytes < value.through.pointer.offset + value.through.pointer.length)
126004
+ if (!message.claim || !isDeepStrictEqual10(value.ref, ingressMessageRef(message)) || value.claimId !== message.claim.id || value.sessionId !== message.claim.sessionId || value.turnId !== message.claim.turnId || value.through.gen < message.claim.generation || value.through.bytes < value.through.pointer.offset + value.through.pointer.length)
125437
126005
  throw new Error("Receipt does not match the exact Pal delivery claim.");
125438
126006
  return value;
125439
126007
  }
@@ -125442,7 +126010,7 @@ var DiskPalCommunicationStore = class {
125442
126010
  await verifyIngressRecorded(message, value, context2);
125443
126011
  return this.changeMessage(message, (current) => {
125444
126012
  if (current.phase === "recorded") {
125445
- if (!isDeepStrictEqual9(current.receipt, value))
126013
+ if (!isDeepStrictEqual10(current.receipt, value))
125446
126014
  conflict("Recorded delivery has another receipt.");
125447
126015
  return current;
125448
126016
  }
@@ -125461,7 +126029,7 @@ var DiskPalCommunicationStore = class {
125461
126029
  async changeMessage(message, mutate2) {
125462
126030
  return this.changeRaw(message.recipient, (state) => {
125463
126031
  const current = state?.messages.find((m) => m.id === message.id);
125464
- if (!state || !current || !message.claim || !isDeepStrictEqual9(current.claim, message.claim) || current.digest !== message.digest || current.phase !== "claimed" && current.phase !== "recorded")
126032
+ if (!state || !current || !message.claim || !isDeepStrictEqual10(current.claim, message.claim) || current.digest !== message.digest || current.phase !== "claimed" && current.phase !== "recorded")
125465
126033
  conflict("Delivery claim changed; a stale claimant cannot settle it.");
125466
126034
  const next2 = frozen(mutate2(current));
125467
126035
  if (next2 === current)
@@ -125731,7 +126299,7 @@ function createPalOperatorMessagingTools(options) {
125731
126299
  if (typeof context2.toolBatchId !== "string" || !context2.toolBatchId || typeof context2.toolUseId !== "string" || !context2.toolUseId)
125732
126300
  throw new Error("Pal messaging requires executor toolBatchId and toolUseId.");
125733
126301
  const receipt2 = await options.sender.send(conversation, {
125734
- operationId: hash2([
126302
+ operationId: hash3([
125735
126303
  1,
125736
126304
  "operator-message-tool",
125737
126305
  conversation.sessionId,
@@ -126007,7 +126575,7 @@ var permissionSchema = external_exports.object({
126007
126575
  allowWake: external_exports.boolean()
126008
126576
  });
126009
126577
  function key5(source, recipient) {
126010
- return hash2([addressTuple(source), addressTuple(recipient)]);
126578
+ return hash3([addressTuple(source), addressTuple(recipient)]);
126011
126579
  }
126012
126580
  __name(key5, "key");
126013
126581
  function checked(input2, source, recipient) {
@@ -126123,10 +126691,10 @@ var DiskPalMessagePolicy = class {
126123
126691
  };
126124
126692
 
126125
126693
  // ../sdk/dist/pals/activity/source.js
126126
- import { createHash as createHash38 } from "node:crypto";
126694
+ import { createHash as createHash39 } from "node:crypto";
126127
126695
 
126128
126696
  // ../sdk/dist/pals/activity/projection.js
126129
- import { createHash as createHash37 } from "node:crypto";
126697
+ import { createHash as createHash38 } from "node:crypto";
126130
126698
  var activityId2 = external_exports.custom((value) => isEntityId(value, "activity"));
126131
126699
  var checkpointId3 = external_exports.custom((value) => isEntityId(value, "checkpoint"));
126132
126700
  var toolUseId2 = external_exports.string().min(1).max(512).regex(/^[A-Za-z0-9_.:-]+$/);
@@ -126185,7 +126753,7 @@ function projectPalActivity(entry, scopeHash) {
126185
126753
  return null;
126186
126754
  }
126187
126755
  return Object.freeze({
126188
- id: createHash37("sha256").update(JSON.stringify(["pal-activity/1", scopeHash, pointer2])).digest("hex"),
126756
+ id: createHash38("sha256").update(JSON.stringify(["pal-activity/1", scopeHash, pointer2])).digest("hex"),
126189
126757
  type: record4.type,
126190
126758
  sessionId: record4.sessionId,
126191
126759
  ..."turnId" in record4 ? { turnId: record4.turnId } : {},
@@ -126247,10 +126815,10 @@ var cursorSchema2 = external_exports.object({
126247
126815
  after: pointer,
126248
126816
  generation: external_exports.number().int().nonnegative().safe()
126249
126817
  }).strict();
126250
- function samePointer2(one, two) {
126818
+ function samePointer3(one, two) {
126251
126819
  return one.seq === two.seq && one.offset === two.offset && one.length === two.length && one.sha256 === two.sha256;
126252
126820
  }
126253
- __name(samePointer2, "samePointer");
126821
+ __name(samePointer3, "samePointer");
126254
126822
  function immutableCursor(value) {
126255
126823
  return Object.freeze({
126256
126824
  ...value,
@@ -126279,7 +126847,7 @@ function createPalActivitySource(options) {
126279
126847
  if (definition.id !== scope.palId || definition.revision !== scope.profileRevision)
126280
126848
  throw new PalActivityIntegrityError();
126281
126849
  const workspace = definition.workspace;
126282
- const scopeHash = createHash38("sha256").update(JSON.stringify([
126850
+ const scopeHash = createHash39("sha256").update(JSON.stringify([
126283
126851
  "pal-activity/1",
126284
126852
  scope.tenantId,
126285
126853
  scope.projectId,
@@ -126349,7 +126917,7 @@ function createPalActivitySource(options) {
126349
126917
  let generation = root.record.gen;
126350
126918
  if (supplied) {
126351
126919
  const anchorEnd = supplied.after.offset + supplied.after.length;
126352
- if (!samePointer2(root.pointer, supplied.root) || !Number.isSafeInteger(anchorEnd) || anchorEnd > size || supplied.after.seq < 1 || supplied.after.seq > 1 && supplied.after.offset < root.pointer.length)
126920
+ if (!samePointer3(root.pointer, supplied.root) || !Number.isSafeInteger(anchorEnd) || anchorEnd > size || supplied.after.seq < 1 || supplied.after.seq > 1 && supplied.after.offset < root.pointer.length)
126353
126921
  throw new PalActivityIntegrityError();
126354
126922
  let anchor2;
126355
126923
  try {
@@ -126360,7 +126928,7 @@ function createPalActivitySource(options) {
126360
126928
  throw error62;
126361
126929
  throw new PalActivityIntegrityError();
126362
126930
  }
126363
- if (anchor2.sha256 !== supplied.after.sha256 || anchor2.record.sessionId !== scope.sessionId || anchor2.record.seq !== supplied.after.seq || anchor2.record.gen !== supplied.generation || supplied.after.seq === 1 && !samePointer2(supplied.after, root.pointer))
126931
+ if (anchor2.sha256 !== supplied.after.sha256 || anchor2.record.sessionId !== scope.sessionId || anchor2.record.seq !== supplied.after.seq || anchor2.record.gen !== supplied.generation || supplied.after.seq === 1 && !samePointer3(supplied.after, root.pointer))
126364
126932
  throw new PalActivityIntegrityError();
126365
126933
  after = supplied.after;
126366
126934
  generation = anchor2.record.gen;
@@ -126669,10 +127237,10 @@ __name(dispatchPalIngressOnce, "dispatchPalIngressOnce");
126669
127237
  // ../sdk/dist/pals/channels/routes.js
126670
127238
  import { chmodSync as chmodSync7, lstatSync as lstatSync11, mkdirSync as mkdirSync12, readdirSync as readdirSync6, realpathSync as realpathSync10 } from "node:fs";
126671
127239
  import { join as join53, resolve as resolve32 } from "node:path";
126672
- import { isDeepStrictEqual as isDeepStrictEqual10 } from "node:util";
127240
+ import { isDeepStrictEqual as isDeepStrictEqual11 } from "node:util";
126673
127241
 
126674
127242
  // ../sdk/dist/pals/channels/schema.js
126675
- import { createHash as createHash39 } from "node:crypto";
127243
+ import { createHash as createHash40 } from "node:crypto";
126676
127244
  var connectionSchema = external_exports.object({
126677
127245
  tenantId: addressSchema2.shape.tenantId,
126678
127246
  provider: label4,
@@ -126703,7 +127271,7 @@ var verifiedActionSchema = external_exports.object({
126703
127271
  actionId: label4,
126704
127272
  payloadDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
126705
127273
  payload: external_exports.string().min(1).max(32e3).refine((value) => !value.includes("\0"))
126706
- }).strict().refine((value) => createHash39("sha256").update(value.payload).digest("hex") === value.payloadDigest, "Channel action payload does not match its authenticated digest.");
127274
+ }).strict().refine((value) => createHash40("sha256").update(value.payload).digest("hex") === value.payloadDigest, "Channel action payload does not match its authenticated digest.");
126707
127275
  var routeDecisionSchema = external_exports.object({
126708
127276
  v: external_exports.literal(1),
126709
127277
  revision: external_exports.literal(1),
@@ -126738,7 +127306,7 @@ function nativeTuple(identity) {
126738
127306
  }
126739
127307
  __name(nativeTuple, "nativeTuple");
126740
127308
  function decisionId(decision2) {
126741
- return hash2([1, decision2.recipient.tenantId, nativeTuple(decision2.identity)]);
127309
+ return hash3([1, decision2.recipient.tenantId, nativeTuple(decision2.identity)]);
126742
127310
  }
126743
127311
  __name(decisionId, "decisionId");
126744
127312
  function checkedDecision(input2) {
@@ -126827,7 +127395,7 @@ var DiskPalChannelRoutes = class {
126827
127395
  if (!stored)
126828
127396
  return null;
126829
127397
  const decision2 = storedDecision(stored);
126830
- if (decisionId(decision2) !== id3 || !isDeepStrictEqual10(decision2.identity, identity))
127398
+ if (decisionId(decision2) !== id3 || !isDeepStrictEqual11(decision2.identity, identity))
126831
127399
  throw new Error("Channel route identity changed.");
126832
127400
  return decision2;
126833
127401
  }
@@ -126837,7 +127405,7 @@ var DiskPalChannelRoutes = class {
126837
127405
  return await this.records.transact(this.location(decisionId(decision2)), (stored) => {
126838
127406
  if (stored) {
126839
127407
  const current = storedDecision(stored);
126840
- if (!isDeepStrictEqual10(current, decision2))
127408
+ if (!isDeepStrictEqual11(current, decision2))
126841
127409
  throw new PalChannelRouteConflictError("This native conversation already has an immutable Pal target.");
126842
127410
  throw new ExistingDecision(current);
126843
127411
  }
@@ -126852,7 +127420,7 @@ var DiskPalChannelRoutes = class {
126852
127420
  };
126853
127421
 
126854
127422
  // ../sdk/dist/pals/channels/ingress.js
126855
- import { isDeepStrictEqual as isDeepStrictEqual11 } from "node:util";
127423
+ import { isDeepStrictEqual as isDeepStrictEqual12 } from "node:util";
126856
127424
  var PalChannelIngress = class {
126857
127425
  static {
126858
127426
  __name(this, "PalChannelIngress");
@@ -126926,7 +127494,7 @@ var PalChannelIngress = class {
126926
127494
  if (allowed.allow !== true)
126927
127495
  throw new Error(`Channel ingress refused: ${allowed.reason}`);
126928
127496
  const reserved = checkedDecision(await routes.reserve(decision2));
126929
- if (!isDeepStrictEqual11(reserved, decision2))
127497
+ if (!isDeepStrictEqual12(reserved, decision2))
126930
127498
  throw new Error("Channel routing decision changed during acceptance.");
126931
127499
  decision2 = reserved;
126932
127500
  pals.getRevision(decision2.recipient.palId, decision2.profileRevision);
@@ -126973,7 +127541,7 @@ var PalChannelIngress = class {
126973
127541
  };
126974
127542
 
126975
127543
  // ../sdk/dist/pals/channels/routing.js
126976
- import { isDeepStrictEqual as isDeepStrictEqual12 } from "node:util";
127544
+ import { isDeepStrictEqual as isDeepStrictEqual13 } from "node:util";
126977
127545
  var contextSchema = external_exports.object({
126978
127546
  recipient: addressSchema2,
126979
127547
  sessionId: external_exports.custom((value) => isEntityId(value, "session")),
@@ -127012,11 +127580,11 @@ var PalChannelRouter = class {
127012
127580
  if (!found)
127013
127581
  throw new Error("Channel response does not name an accepted delivery.");
127014
127582
  const message = freezeCommunicationValue(ingressInboxSchema.parse(found));
127015
- if (!("kind" in message) || message.kind !== "channel" || message.phase !== "recorded" || !message.receipt || !isDeepStrictEqual12(ingressMessageRef(message), ref))
127583
+ if (!("kind" in message) || message.kind !== "channel" || message.phase !== "recorded" || !message.receipt || !isDeepStrictEqual13(ingressMessageRef(message), ref))
127016
127584
  throw new Error("Channel response requires the exact recorded channel delivery.");
127017
127585
  if (message.source.tenantId !== this.connection.tenantId || message.source.provider !== this.connection.provider || message.source.connectionId !== this.connection.connectionId || message.source.externalTenantId !== this.connection.externalTenantId)
127018
127586
  throw new Error("Channel response belongs to another connection.");
127019
- if (!isDeepStrictEqual12(nativeTuple(message.source), nativeTuple(message.routeKey)))
127587
+ if (!isDeepStrictEqual13(nativeTuple(message.source), nativeTuple(message.routeKey)))
127020
127588
  throw new Error("Channel message source does not match its original native route.");
127021
127589
  const binding = await this.options.store.routeIngress(message.routeKey);
127022
127590
  if (!binding || binding.id !== message.routeId || binding.phase !== "active" || binding.sessionId !== context2.sessionId || binding.profileRevision !== context2.profileRevision || binding.key.recipient.palId !== context2.recipient.palId || binding.key.recipient.tenantId !== context2.recipient.tenantId)
@@ -127033,7 +127601,7 @@ var PalChannelRouter = class {
127033
127601
  }
127034
127602
  async resolve(input2, context2, signal, action) {
127035
127603
  const message = await this.recorded(input2, context2, signal);
127036
- if (action && (action.externalTenantId !== message.source.externalTenantId || !isDeepStrictEqual12(nativeTuple({
127604
+ if (action && (action.externalTenantId !== message.source.externalTenantId || !isDeepStrictEqual13(nativeTuple({
127037
127605
  ...action,
127038
127606
  provider: this.connection.provider,
127039
127607
  connectionId: this.connection.connectionId
@@ -127099,7 +127667,7 @@ var PalChannelRouter = class {
127099
127667
  // ../sdk/dist/pals/activity/subscription-store.js
127100
127668
  import { chmodSync as chmodSync8, lstatSync as lstatSync12, mkdirSync as mkdirSync13, readdirSync as readdirSync7, realpathSync as realpathSync11 } from "node:fs";
127101
127669
  import { join as join54, resolve as resolve33 } from "node:path";
127102
- import { isDeepStrictEqual as isDeepStrictEqual13 } from "node:util";
127670
+ import { isDeepStrictEqual as isDeepStrictEqual14 } from "node:util";
127103
127671
 
127104
127672
  // ../sdk/dist/pals/activity/subscription-schema.js
127105
127673
  var positive6 = external_exports.number().int().positive().safe();
@@ -127244,12 +127812,12 @@ var DiskPalActivitySubscriptionStore = class {
127244
127812
  throw new Error("Subscription cursor cannot precede its root.");
127245
127813
  if (captured.cursor) {
127246
127814
  const previous = captured.cursor;
127247
- if (cursor.scopeHash !== previous.scopeHash || !isDeepStrictEqual13(cursor.root, previous.root) || cursor.after.seq < previous.after.seq || cursor.after.offset < previous.after.offset || cursor.generation < previous.generation || cursor.after.seq === previous.after.seq && !isDeepStrictEqual13(cursor, previous))
127815
+ if (cursor.scopeHash !== previous.scopeHash || !isDeepStrictEqual14(cursor.root, previous.root) || cursor.after.seq < previous.after.seq || cursor.after.offset < previous.after.offset || cursor.generation < previous.generation || cursor.after.seq === previous.after.seq && !isDeepStrictEqual14(cursor, previous))
127248
127816
  throw new Error("Subscription cursor identity changed or moved backwards.");
127249
127817
  }
127250
127818
  return this.records.transact(this.location(captured.id), (stored) => {
127251
127819
  const current = stored === null ? null : this.checked(stored, captured.id);
127252
- if (!current || !current.enabled || !isDeepStrictEqual13(current, captured))
127820
+ if (!current || !current.enabled || !isDeepStrictEqual14(current, captured))
127253
127821
  throw new PalActivitySubscriptionConflictError("Subscription changed before accepted progress could commit.");
127254
127822
  const record4 = this.checked({ ...current, revision: current.revision + 1, cursor }, current.id);
127255
127823
  return { record: record4, result: record4 };
@@ -127260,7 +127828,7 @@ var DiskPalActivitySubscriptionStore = class {
127260
127828
  // ../sdk/dist/pals/activity/subscription-policy.js
127261
127829
  import { chmodSync as chmodSync9, lstatSync as lstatSync13, mkdirSync as mkdirSync14, readdirSync as readdirSync8, realpathSync as realpathSync12 } from "node:fs";
127262
127830
  import { join as join55, resolve as resolve34 } from "node:path";
127263
- import { isDeepStrictEqual as isDeepStrictEqual14 } from "node:util";
127831
+ import { isDeepStrictEqual as isDeepStrictEqual15 } from "node:util";
127264
127832
  var PalActivitySubscriptionPermissionConflictError = class extends Error {
127265
127833
  static {
127266
127834
  __name(this, "PalActivitySubscriptionPermissionConflictError");
@@ -127358,13 +127926,13 @@ var DiskPalActivitySubscriptionPolicy = class {
127358
127926
  const captured = freezeCommunicationValue(subscriptionSchema.parse(request.subscription));
127359
127927
  const stored = await this.subscriptions.get(captured.id);
127360
127928
  const subscription = stored ? freezeCommunicationValue(subscriptionSchema.parse(stored)) : null;
127361
- if (!subscription?.enabled || subscription.configurationRevision !== captured.configurationRevision || !isDeepStrictEqual14(subscription.scope, captured.scope) || !isDeepStrictEqual14(subscription.recipient, captured.recipient))
127929
+ if (!subscription?.enabled || subscription.configurationRevision !== captured.configurationRevision || !isDeepStrictEqual15(subscription.scope, captured.scope) || !isDeepStrictEqual15(subscription.recipient, captured.recipient))
127362
127930
  return denied();
127363
127931
  const observed = await this.get(subscription.id);
127364
127932
  if (!permitted(observed))
127365
127933
  return denied();
127366
127934
  const current = await this.subscriptions.get(subscription.id);
127367
- if (!current?.enabled || current.configurationRevision !== captured.configurationRevision || !isDeepStrictEqual14(current.scope, captured.scope) || !isDeepStrictEqual14(current.recipient, captured.recipient))
127935
+ if (!current?.enabled || current.configurationRevision !== captured.configurationRevision || !isDeepStrictEqual15(current.scope, captured.scope) || !isDeepStrictEqual15(current.recipient, captured.recipient))
127368
127936
  return denied();
127369
127937
  const rule = await this.get(subscription.id);
127370
127938
  if (!rule || !permitted(rule))
@@ -127391,13 +127959,13 @@ var DiskPalActivitySubscriptionPolicy = class {
127391
127959
  const phase = external_exports.enum(["accept", "deliver", "wake"]).parse(request.phase);
127392
127960
  const stored = await this.subscriptions.get(id3);
127393
127961
  const subscription = stored ? freezeCommunicationValue(subscriptionSchema.parse(stored)) : null;
127394
- if (!subscription?.enabled || request.routeKey.kind !== "observation" || request.routeKey.subscriptionId !== id3 || !isDeepStrictEqual14(request.source.scope, subscription.scope) || !isDeepStrictEqual14(request.routeKey.scope, subscription.scope) || !isDeepStrictEqual14(request.recipient, subscription.recipient) || !isDeepStrictEqual14(request.routeKey.recipient, subscription.recipient))
127962
+ if (!subscription?.enabled || request.routeKey.kind !== "observation" || request.routeKey.subscriptionId !== id3 || !isDeepStrictEqual15(request.source.scope, subscription.scope) || !isDeepStrictEqual15(request.routeKey.scope, subscription.scope) || !isDeepStrictEqual15(request.recipient, subscription.recipient) || !isDeepStrictEqual15(request.routeKey.recipient, subscription.recipient))
127395
127963
  return denied();
127396
127964
  const observed = await this.get(id3);
127397
127965
  if (!observed?.observe || !observed.disclose || !observed.receive || phase === "wake" && !observed.wake)
127398
127966
  return denied();
127399
127967
  const current = await this.subscriptions.get(id3);
127400
- if (!current?.enabled || current.configurationRevision !== subscription.configurationRevision || !isDeepStrictEqual14(current.scope, subscription.scope) || !isDeepStrictEqual14(current.recipient, subscription.recipient))
127968
+ if (!current?.enabled || current.configurationRevision !== subscription.configurationRevision || !isDeepStrictEqual15(current.scope, subscription.scope) || !isDeepStrictEqual15(current.recipient, subscription.recipient))
127401
127969
  return denied();
127402
127970
  const rule = await this.get(id3);
127403
127971
  if (!rule?.observe || !rule.disclose || !rule.receive || phase === "wake" && !rule.wake)
@@ -127413,7 +127981,7 @@ var DiskPalActivitySubscriptionPolicy = class {
127413
127981
  };
127414
127982
 
127415
127983
  // ../sdk/dist/pals/activity/subscriptions.js
127416
- import { isDeepStrictEqual as isDeepStrictEqual15 } from "node:util";
127984
+ import { isDeepStrictEqual as isDeepStrictEqual16 } from "node:util";
127417
127985
  var PalActivitySubscriptionDeniedError = class extends Error {
127418
127986
  static {
127419
127987
  __name(this, "PalActivitySubscriptionDeniedError");
@@ -127439,7 +128007,7 @@ async function publishPalActivityOnce(options, id3, input2) {
127439
128007
  signal.throwIfAborted();
127440
128008
  const value = await subscriptions.get(subscriptionId);
127441
128009
  signal.throwIfAborted();
127442
- if (!value?.enabled || value.configurationRevision !== subscription.configurationRevision || !isDeepStrictEqual15(value.scope, subscription.scope) || !isDeepStrictEqual15(value.recipient, subscription.recipient))
128010
+ if (!value?.enabled || value.configurationRevision !== subscription.configurationRevision || !isDeepStrictEqual16(value.scope, subscription.scope) || !isDeepStrictEqual16(value.recipient, subscription.recipient))
127443
128011
  throw new PalActivitySubscriptionDeniedError();
127444
128012
  }
127445
128013
  __name(current, "current");
@@ -127510,7 +128078,7 @@ async function publishPalActivityOnce(options, id3, input2) {
127510
128078
  subscriptionTrail: [...lineage, subscription.id],
127511
128079
  replyTo: null,
127512
128080
  grant: {
127513
- id: hash2([
128081
+ id: hash3([
127514
128082
  "pal-observation-grants/1",
127515
128083
  subscription.id,
127516
128084
  observed.id,
@@ -127518,7 +128086,7 @@ async function publishPalActivityOnce(options, id3, input2) {
127518
128086
  received2.id,
127519
128087
  acceptedGrant.id
127520
128088
  ]),
127521
- revision: hash2([
128089
+ revision: hash3([
127522
128090
  subscription.configurationRevision,
127523
128091
  observed.revision,
127524
128092
  disclosed.revision,
@@ -127545,7 +128113,7 @@ async function publishPalActivityOnce(options, id3, input2) {
127545
128113
  }
127546
128114
  }
127547
128115
  await permitted("observe");
127548
- const next2 = subscription.cursor && isDeepStrictEqual15(subscription.cursor, page.cursor) ? subscription : await subscriptions.advance(subscription, page.cursor);
128116
+ const next2 = subscription.cursor && isDeepStrictEqual16(subscription.cursor, page.cursor) ? subscription : await subscriptions.advance(subscription, page.cursor);
127549
128117
  return freezeCommunicationValue({
127550
128118
  subscription: next2,
127551
128119
  accepted,
@@ -127556,8 +128124,8 @@ async function publishPalActivityOnce(options, id3, input2) {
127556
128124
  __name(publishPalActivityOnce, "publishPalActivityOnce");
127557
128125
 
127558
128126
  // ../sdk/dist/pals/activity/causality.js
127559
- import { createHash as createHash40 } from "node:crypto";
127560
- import { isDeepStrictEqual as isDeepStrictEqual16 } from "node:util";
128127
+ import { createHash as createHash41 } from "node:crypto";
128128
+ import { isDeepStrictEqual as isDeepStrictEqual17 } from "node:util";
127561
128129
  var requestMarkerSchema = external_exports.object({
127562
128130
  type: external_exports.literal("request_envelope"),
127563
128131
  iteration: external_exports.literal(1),
@@ -127635,7 +128203,7 @@ function createPalActivityCausalityResolver(options) {
127635
128203
  const root = entries2[0]?.record;
127636
128204
  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]))
127637
128205
  unavailable3();
127638
- const scopeHash = createHash40("sha256").update(JSON.stringify([
128206
+ const scopeHash = createHash41("sha256").update(JSON.stringify([
127639
128207
  "pal-activity/1",
127640
128208
  scope.tenantId,
127641
128209
  scope.projectId,
@@ -127645,7 +128213,7 @@ function createPalActivityCausalityResolver(options) {
127645
128213
  workspace
127646
128214
  ])).digest("hex");
127647
128215
  const original = entries2.find((e) => e.record.seq === fact.seq);
127648
- if (!original || !isDeepStrictEqual16(projectPalActivity(original, scopeHash), fact) || !fact.turnId)
128216
+ if (!original || !isDeepStrictEqual17(projectPalActivity(original, scopeHash), fact) || !fact.turnId)
127649
128217
  unavailable3();
127650
128218
  const turnId6 = fact.turnId;
127651
128219
  const firstRequest = entries2.find((e) => e.record.type === "request_envelope" && e.record.turnId === turnId6);
@@ -127682,13 +128250,13 @@ function createPalActivityCausalityResolver(options) {
127682
128250
  return unavailable3();
127683
128251
  const receipt2 = ingressReceiptSchema.parse(message.receipt);
127684
128252
  const covered = entries2.find((candidate) => candidate.record.seq === receipt2.through.pointer.seq);
127685
- if (!covered || !isDeepStrictEqual16(covered.pointer, receipt2.through.pointer) || covered.record.gen !== receipt2.through.gen || receipt2.through.bytes !== covered.pointer.offset + covered.pointer.length)
128253
+ if (!covered || !isDeepStrictEqual17(covered.pointer, receipt2.through.pointer) || covered.record.gen !== receipt2.through.gen || receipt2.through.bytes !== covered.pointer.offset + covered.pointer.length)
127686
128254
  return unavailable3();
127687
128255
  const parsedRoute = ingressBindingSchema.safeParse(state?.routes.find((r) => r.id === message.routeId));
127688
128256
  if (!parsedRoute.success)
127689
128257
  return unavailable3();
127690
128258
  const route = parsedRoute.data;
127691
- if (!route || route.phase !== "active" || !isDeepStrictEqual16(route.key, message.routeKey) || route.sessionId !== scope.sessionId || route.profileRevision !== scope.profileRevision || route.key.recipient.palId !== scope.palId || route.key.recipient.tenantId !== scope.tenantId)
128259
+ if (!route || route.phase !== "active" || !isDeepStrictEqual17(route.key, message.routeKey) || route.sessionId !== scope.sessionId || route.profileRevision !== scope.profileRevision || route.key.recipient.palId !== scope.palId || route.key.recipient.tenantId !== scope.tenantId)
127692
128260
  unavailable3();
127693
128261
  if (message && "kind" in message && message.kind === "observation")
127694
128262
  for (const id3 of message.subscriptionTrail)
@@ -130041,7 +130609,7 @@ ${observed}
130041
130609
  });
130042
130610
 
130043
130611
  // ../sdk/dist/tools/builtins/skill.js
130044
- import { createHash as createHash41 } from "node:crypto";
130612
+ import { createHash as createHash42 } from "node:crypto";
130045
130613
  var inputSchema16 = external_exports.object({
130046
130614
  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."),
130047
130615
  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."),
@@ -130052,7 +130620,7 @@ var LIST_CURSOR_PATTERN = /^v1\.list\.(0|[1-9][0-9]*)\.([01])\.([A-Za-z0-9_-]{43
130052
130620
  var MAX_SKILLS_PER_PAGE = 20;
130053
130621
  var OVERSIZED_CATALOG_WARNING = "Some skills were omitted because their metadata is too large for this response budget.";
130054
130622
  function snapshotDigest(snapshot) {
130055
- return createHash41("sha256").update(JSON.stringify({
130623
+ return createHash42("sha256").update(JSON.stringify({
130056
130624
  version: 1,
130057
130625
  name: snapshot.name,
130058
130626
  body: snapshot.body,
@@ -130096,7 +130664,7 @@ function activeOutputCap(maxChars2) {
130096
130664
  }
130097
130665
  __name(activeOutputCap, "activeOutputCap");
130098
130666
  function listDigest(skills, maxChars2) {
130099
- return createHash41("sha256").update(JSON.stringify({ version: 1, kind: "list", maxChars: maxChars2 ?? null, skills })).digest("base64url");
130667
+ return createHash42("sha256").update(JSON.stringify({ version: 1, kind: "list", maxChars: maxChars2 ?? null, skills })).digest("base64url");
130100
130668
  }
130101
130669
  __name(listDigest, "listDigest");
130102
130670
  function serializeListPage(page) {
@@ -135577,7 +136145,7 @@ function createPalMessagingTools(options) {
135577
136145
  await assertCurrent(context2);
135578
136146
  if (typeof context2.toolBatchId !== "string" || !context2.toolBatchId || typeof context2.toolUseId !== "string" || !context2.toolUseId)
135579
136147
  throw new Error("Pal messaging requires executor toolBatchId and toolUseId.");
135580
- const operationId = hash2([
136148
+ const operationId = hash3([
135581
136149
  1,
135582
136150
  "pal-message-tool",
135583
136151
  source.conversationId,
@@ -136194,6 +136762,7 @@ export {
136194
136762
  TurnFailedRecordSchema,
136195
136763
  MessageRecordSchema,
136196
136764
  MessageReplacedRecordSchema,
136765
+ MessageEditedRecordSchema,
136197
136766
  CompactionRecordSchema,
136198
136767
  TurnOutcomeRecordedRecordSchema,
136199
136768
  ChildOutcomeRecordedRecordSchema,
@@ -136216,6 +136785,7 @@ export {
136216
136785
  LineSplitter,
136217
136786
  readSessionLogTail,
136218
136787
  verifyPointer,
136788
+ foldSessionLog,
136219
136789
  TurnInProgressError,
136220
136790
  isTurnInProgressError,
136221
136791
  withMessageId,
@@ -137099,4 +137669,4 @@ export {
137099
137669
  WakeBudget,
137100
137670
  wakeBudgetFromEnv
137101
137671
  };
137102
- //# sourceMappingURL=chunk-ZE6HLPD4.js.map
137672
+ //# sourceMappingURL=chunk-MJJAKWHU.js.map