@iowarp/clio-coder 0.4.4 → 0.4.5

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 (555) hide show
  1. package/CHANGELOG.md +92 -2
  2. package/CONTRIBUTING.md +25 -15
  3. package/README.md +340 -27
  4. package/dist/{acp-WNAYYF4F.js → acp-H3CU2HBQ.js} +25 -24
  5. package/dist/{agents-3OKXHLOI.js → agents-IXQQZ7BD.js} +77 -77
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-VKNNMGPU.js → auth-R7KYF7N3.js} +38 -38
  8. package/dist/builtins-CRFDQUVP.js +22 -0
  9. package/dist/{chunk-TQAHXW6Y.js → chunk-22PQ4TX4.js} +4 -4
  10. package/dist/{chunk-NEDJ26B5.js → chunk-2GPGAE5W.js} +6 -51
  11. package/dist/{chunk-IKCO5N3L.js → chunk-2QPI3TR3.js} +3 -3
  12. package/dist/{chunk-HRQMFLJP.js → chunk-32KJPXAM.js} +6 -6
  13. package/dist/{chunk-65DEGPJ6.js → chunk-3A3CUMKA.js} +6 -4
  14. package/dist/{chunk-JCI2ROMZ.js → chunk-3T4DXWP6.js} +7 -7
  15. package/dist/{chunk-DR52UMZW.js → chunk-3UW3KU4A.js} +2 -2
  16. package/dist/{chunk-6Q3CYFD3.js → chunk-4SVIVOMC.js} +184 -33
  17. package/dist/{chunk-W54I7H25.js → chunk-5A6XR3RJ.js} +44 -19
  18. package/dist/{chunk-YPC6ZR5L.js → chunk-5CMARGPF.js} +119 -5
  19. package/dist/{chunk-KXDSS5WJ.js → chunk-5CY4Q6QI.js} +4 -4
  20. package/dist/{chunk-I2DWJ4GM.js → chunk-5DDOTTG4.js} +54 -42
  21. package/dist/{chunk-D4CJV46V.js → chunk-5GZICIYO.js} +3 -3
  22. package/dist/{chunk-4IUZQIJ3.js → chunk-5PHVPU4G.js} +2 -2
  23. package/dist/{chunk-3ODX73FK.js → chunk-5VTJP36Q.js} +4 -4
  24. package/dist/{chunk-54X7T7DK.js → chunk-5ZMXGW7P.js} +79 -7
  25. package/dist/chunk-5ZSZEYJK.js +119 -0
  26. package/dist/{chunk-IXIY2H4R.js → chunk-633EXGZA.js} +5 -5
  27. package/dist/{chunk-CUSRQKPU.js → chunk-6CDNRHWH.js} +299 -89
  28. package/dist/{chunk-EBY63B7G.js → chunk-6EXUUOSN.js} +2 -2
  29. package/dist/{chunk-SVNXH4L2.js → chunk-6ICZKDUC.js} +2 -2
  30. package/dist/{chunk-JEIYHLOR.js → chunk-6SYEGZI3.js} +12 -12
  31. package/dist/{chunk-DQOVN6KV.js → chunk-6YA46L5A.js} +4 -4
  32. package/dist/{chunk-NZMNUPZZ.js → chunk-77CZRFTE.js} +3 -3
  33. package/dist/{chunk-6PAZTBPA.js → chunk-7HBHHVCK.js} +15 -6
  34. package/dist/{chunk-25QBEXRS.js → chunk-7TKWWPD7.js} +5 -4
  35. package/dist/{chunk-2VTFPG5O.js → chunk-7WLRF2U5.js} +2 -2
  36. package/dist/chunk-7WUZEB2M.js +165 -0
  37. package/dist/{chunk-3UUXNFEX.js → chunk-7YJWEF2L.js} +61 -34
  38. package/dist/{chunk-3EBYEESD.js → chunk-A46ILRS2.js} +5 -5
  39. package/dist/{chunk-UOIZ7DA4.js → chunk-AP7HDJOP.js} +2 -2
  40. package/dist/{chunk-APJ265NV.js → chunk-B5GGDIHT.js} +146 -146
  41. package/dist/{chunk-PMZVFWSR.js → chunk-B5ZTR6KZ.js} +2 -2
  42. package/dist/{chunk-I5FWO7L5.js → chunk-B6UM3OZC.js} +2 -2
  43. package/dist/{chunk-2CU2H6KE.js → chunk-BBV5TKE6.js} +5 -5
  44. package/dist/{chunk-4O6MANBS.js → chunk-BS4GAMUB.js} +14 -10
  45. package/dist/{chunk-S66XZJOF.js → chunk-C27U2TYG.js} +2 -2
  46. package/dist/{chunk-QZWQA4DE.js → chunk-CBSKDFWL.js} +3 -3
  47. package/dist/{chunk-2LEAKD4C.js → chunk-CKK25WN3.js} +3 -3
  48. package/dist/{chunk-BYP5D4HI.js → chunk-CTTI7G3T.js} +2 -2
  49. package/dist/{chunk-XAKHZX5N.js → chunk-CVDAFGPW.js} +4 -4
  50. package/dist/{chunk-RKKLTLYB.js → chunk-CXQ37WJH.js} +3 -3
  51. package/dist/{chunk-GTUD2WMY.js → chunk-DBREN25X.js} +44 -9
  52. package/dist/{chunk-YNFKXPEC.js → chunk-DIMRLNIC.js} +35 -66
  53. package/dist/{chunk-NDDGJUXD.js → chunk-DNCE23JJ.js} +2 -2
  54. package/dist/{chunk-HVDIIIQW.js → chunk-DNHVRBH4.js} +3 -3
  55. package/dist/{chunk-XULDXHTN.js → chunk-DRD2A54W.js} +102 -50
  56. package/dist/{chunk-D7E7WCDF.js → chunk-DVNAPPXU.js} +2 -2
  57. package/dist/{chunk-YXLYO42X.js → chunk-DXVMLM3Z.js} +3 -2
  58. package/dist/{chunk-5MEZN6CB.js → chunk-DZK63TZJ.js} +6 -6
  59. package/dist/{chunk-IGLP3ODT.js → chunk-E3BQTQUP.js} +15 -15
  60. package/dist/{chunk-IWHMRKLL.js → chunk-E3LEPLQ2.js} +2 -2
  61. package/dist/{chunk-3R73A4XB.js → chunk-ECBHH7LU.js} +3 -3
  62. package/dist/chunk-ECOMVOHP.js +139 -0
  63. package/dist/chunk-EFSEIZE6.js +56 -0
  64. package/dist/{chunk-FEAXX7B6.js → chunk-EHCPSZJF.js} +4 -4
  65. package/dist/{chunk-4NSRCOYP.js → chunk-EHOSNVVM.js} +3 -2
  66. package/dist/{chunk-7UGL4MB5.js → chunk-EQEJJ53P.js} +10 -10
  67. package/dist/{chunk-GWZNEVM2.js → chunk-EWD5P3GK.js} +9 -9
  68. package/dist/{chunk-6UINWWS6.js → chunk-F34AR6O3.js} +14 -14
  69. package/dist/{chunk-GHS5EBTQ.js → chunk-FKIOX6DS.js} +29 -20
  70. package/dist/{chunk-HAXOFFRH.js → chunk-FQOOGXBH.js} +7 -7
  71. package/dist/{chunk-Y55JBDO5.js → chunk-FSTIBAGM.js} +38 -23
  72. package/dist/{chunk-ZTJUVLTU.js → chunk-FXFVDPWY.js} +2 -2
  73. package/dist/{chunk-XPLRXC72.js → chunk-GD55RTIW.js} +3 -3
  74. package/dist/{chunk-5B2AEOW5.js → chunk-GH5ZR6JP.js} +472 -472
  75. package/dist/{chunk-TOIVGRUX.js → chunk-GJ24ODAX.js} +5 -5
  76. package/dist/{chunk-QUFRYSWI.js → chunk-GNQRWTMY.js} +129 -48
  77. package/dist/{chunk-5ICU3EUH.js → chunk-GVYWZNRK.js} +5 -5
  78. package/dist/{chunk-GX5WYQO4.js → chunk-GXCCHKN6.js} +6 -6
  79. package/dist/{chunk-K6T2ZAMZ.js → chunk-HGSLRG33.js} +6 -6
  80. package/dist/{chunk-26QSH3EJ.js → chunk-HHVJNVUJ.js} +5 -5
  81. package/dist/{chunk-F4EKGO4N.js → chunk-HL26ADLH.js} +4 -2
  82. package/dist/{chunk-JT2RFCC5.js → chunk-HR3HPQ76.js} +5 -5
  83. package/dist/{chunk-ID64D7PE.js → chunk-HXHFDHB6.js} +24 -24
  84. package/dist/{chunk-ELWDPP3Y.js → chunk-I7VLWRK2.js} +8 -8
  85. package/dist/{chunk-6OSVSQL5.js → chunk-ICO4TQ2F.js} +7 -5
  86. package/dist/{chunk-SZAA6XDG.js → chunk-IFDRAD6F.js} +2 -2
  87. package/dist/{chunk-72YIHOZQ.js → chunk-ILJ7DWGE.js} +9 -9
  88. package/dist/{chunk-2JH2WHGE.js → chunk-J2FYEQ5L.js} +4 -4
  89. package/dist/{chunk-BMS5RKQY.js → chunk-JABWPKFY.js} +3 -3
  90. package/dist/{chunk-QDC3K2U3.js → chunk-K2BLQC5E.js} +3 -3
  91. package/dist/{chunk-AUPNRN7C.js → chunk-K2HL3GBL.js} +4 -4
  92. package/dist/{chunk-2ASED4PZ.js → chunk-K6RDB7IA.js} +26 -26
  93. package/dist/{chunk-FFUPXJC4.js → chunk-KDWLXVMN.js} +23 -24
  94. package/dist/{chunk-OZNBF4L3.js → chunk-KECNXMDE.js} +2 -2
  95. package/dist/{chunk-6QOTUPRG.js → chunk-KF6GFW6O.js} +66 -18
  96. package/dist/{chunk-BTK3SSSK.js → chunk-KMF54VH3.js} +2 -2
  97. package/dist/chunk-KPRLAMP4.js +32 -0
  98. package/dist/{chunk-ECH6PKUQ.js → chunk-KQ6IDQIB.js} +2 -2
  99. package/dist/{chunk-3UNOLWNZ.js → chunk-KTFSFCVN.js} +20 -9
  100. package/dist/{chunk-57XXR6DR.js → chunk-KYKNBD4Y.js} +24 -23
  101. package/dist/{chunk-IRXAATOX.js → chunk-L4N3DWNW.js} +3 -3
  102. package/dist/{chunk-LCGCVYZ4.js → chunk-LQTKDAUO.js} +2 -2
  103. package/dist/{chunk-U6TMQNSI.js → chunk-LTR5QCLS.js} +4 -4
  104. package/dist/chunk-LUL5Z66S.js +221 -0
  105. package/dist/{chunk-ELZVTCGV.js → chunk-LVFANMOH.js} +151 -327
  106. package/dist/{chunk-H7IXIC72.js → chunk-LY4N4TTL.js} +17 -3
  107. package/dist/{chunk-VKPAQYEB.js → chunk-LZBMXNLP.js} +5 -5
  108. package/dist/{chunk-UL3WSD3F.js → chunk-M4KFUXS7.js} +2 -2
  109. package/dist/{chunk-NXYCB2VD.js → chunk-M6TAYK66.js} +6 -6
  110. package/dist/{chunk-NEKRRTYW.js → chunk-MC3JSVR6.js} +2 -2
  111. package/dist/{chunk-CFGTUFWB.js → chunk-MCJKEGHO.js} +2 -2
  112. package/dist/{chunk-DXKJURES.js → chunk-MDU3C27C.js} +10 -7
  113. package/dist/{chunk-6XLNIQDB.js → chunk-MYI32N4R.js} +2 -2
  114. package/dist/{chunk-3GY4F45V.js → chunk-NC4KV7EL.js} +6 -6
  115. package/dist/{chunk-LLXSDWXS.js → chunk-NF3BK5WR.js} +5 -5
  116. package/dist/chunk-NTK3WTHM.js +141 -0
  117. package/dist/{chunk-GYV6VZOC.js → chunk-NTTS3O53.js} +2 -2
  118. package/dist/{chunk-RZDWV63N.js → chunk-NY6IWDVU.js} +6 -6
  119. package/dist/{chunk-XXYSBZIQ.js → chunk-O2RQ7LCK.js} +4 -4
  120. package/dist/{chunk-4BJ5BYCE.js → chunk-O3VV6IVK.js} +2 -2
  121. package/dist/{chunk-W6GROXXM.js → chunk-O5F25NIE.js} +2 -2
  122. package/dist/{chunk-NXIMQY5W.js → chunk-ODUTYZIU.js} +5 -5
  123. package/dist/{chunk-LTIKRKFL.js → chunk-ONRTXOZY.js} +4 -4
  124. package/dist/{chunk-KFV5L5SK.js → chunk-OQM5IVJY.js} +118 -232
  125. package/dist/{chunk-XRZT5WY5.js → chunk-P5SC4DLJ.js} +4 -4
  126. package/dist/{chunk-R6Q67RJH.js → chunk-PECBKCDK.js} +34 -6
  127. package/dist/{chunk-33YXPOE3.js → chunk-PPEZJWUG.js} +2 -2
  128. package/dist/{chunk-RXTN6AKH.js → chunk-PWWSIB2A.js} +5 -5
  129. package/dist/{chunk-2STGEDFV.js → chunk-QEQISF75.js} +2 -2
  130. package/dist/{chunk-3DPEIQKN.js → chunk-QH3ZTUOA.js} +2 -2
  131. package/dist/{chunk-YAKGTXEV.js → chunk-QRFXEO6Y.js} +2 -2
  132. package/dist/{chunk-35MSIRKH.js → chunk-QUIJZSDW.js} +2 -2
  133. package/dist/{chunk-HHV2GANA.js → chunk-R2P2U3ZS.js} +2 -2
  134. package/dist/{chunk-2DSOYNFC.js → chunk-R6MAYTMS.js} +7 -7
  135. package/dist/{chunk-JQLNNIKT.js → chunk-R6MICQYU.js} +6 -6
  136. package/dist/{chunk-NAI6ZFCY.js → chunk-RLTT5GVY.js} +122 -11
  137. package/dist/{chunk-DT3LWJOB.js → chunk-RXIOCVBZ.js} +24 -6
  138. package/dist/{chunk-N56KALIC.js → chunk-S32UQ5GL.js} +61 -34
  139. package/dist/{chunk-UEPWCCTY.js → chunk-SBZX6ARC.js} +12 -12
  140. package/dist/chunk-SD7SHNDW.js +15 -0
  141. package/dist/{chunk-NRO2BJRH.js → chunk-SDWNDICN.js} +10235 -4015
  142. package/dist/{chunk-UXCU4E3T.js → chunk-SE4ZKILO.js} +6 -6
  143. package/dist/chunk-SL2RDHKO.js +19 -0
  144. package/dist/{chunk-NUGM5KR6.js → chunk-SRCEQKQS.js} +2 -2
  145. package/dist/{chunk-OMQNJVKW.js → chunk-SRZOW5L2.js} +43 -13
  146. package/dist/{chunk-3M6DQK6S.js → chunk-T334FW2H.js} +7 -7
  147. package/dist/{chunk-V76WTFTW.js → chunk-T52TPHYC.js} +6 -6
  148. package/dist/{chunk-I7XBWTYH.js → chunk-T53XI6I7.js} +5 -5
  149. package/dist/{chunk-2ZSONWVL.js → chunk-T7FDXNRU.js} +13 -13
  150. package/dist/{chunk-JSD46VO2.js → chunk-TEG3RYVZ.js} +43 -36
  151. package/dist/{chunk-3I7MS7N2.js → chunk-TK2BMCBZ.js} +2 -2
  152. package/dist/{chunk-5OIVVPHF.js → chunk-TN5FW4XY.js} +13 -6
  153. package/dist/{chunk-75W7L2E2.js → chunk-TZ7MFRG4.js} +1041 -162
  154. package/dist/{chunk-36CT5VVL.js → chunk-U2JOLB7O.js} +126 -77
  155. package/dist/{chunk-LL4KHSZI.js → chunk-U2MSJ57E.js} +2 -2
  156. package/dist/{chunk-FTMGRKEF.js → chunk-U44YYLVV.js} +4 -4
  157. package/dist/{chunk-YECAMM3D.js → chunk-U7H5WRG5.js} +5 -5
  158. package/dist/{chunk-RQCKCSRL.js → chunk-U7VQ4NI4.js} +22 -22
  159. package/dist/{chunk-5TUB6SLS.js → chunk-UFYNOQK4.js} +7 -7
  160. package/dist/{chunk-R346GLFC.js → chunk-UHW5V7HC.js} +2 -2
  161. package/dist/{chunk-USR47QNF.js → chunk-UL36QJX6.js} +14 -14
  162. package/dist/{chunk-VIA6RFQZ.js → chunk-UQIVHSE4.js} +4 -4
  163. package/dist/{chunk-RAY4OVGZ.js → chunk-URBGEOH3.js} +5 -5
  164. package/dist/chunk-USZA7GWL.js +341 -0
  165. package/dist/{chunk-YD5GIKET.js → chunk-UTUNT5QL.js} +48 -579
  166. package/dist/{chunk-ZA4VCIGV.js → chunk-UUQ5G6EZ.js} +60 -41
  167. package/dist/{chunk-23L32XTI.js → chunk-UXAC2FX4.js} +68 -39
  168. package/dist/{chunk-VG7TBQIY.js → chunk-V552WL53.js} +68 -4
  169. package/dist/{chunk-BWH6N36D.js → chunk-VHKTOLEW.js} +272 -42
  170. package/dist/{chunk-EXLD33WO.js → chunk-VLPTKCKT.js} +24 -9
  171. package/dist/{chunk-336NSSKI.js → chunk-VNBICSS2.js} +2 -2
  172. package/dist/{chunk-VAVR4IJY.js → chunk-VQD7NH7Z.js} +3 -3
  173. package/dist/{chunk-LBMZMYH2.js → chunk-W2RJEH6Q.js} +3 -3
  174. package/dist/{chunk-7CR24IG7.js → chunk-WDV62RKY.js} +2 -2
  175. package/dist/{chunk-S6PYF2XF.js → chunk-WFKDPU7U.js} +4 -4
  176. package/dist/{chunk-BJVFZO5U.js → chunk-WJIMKGD6.js} +7 -7
  177. package/dist/{chunk-5636DCO5.js → chunk-WLMSOT73.js} +59 -12
  178. package/dist/{chunk-MXHC5QYU.js → chunk-WTQGRBHV.js} +5 -144
  179. package/dist/chunk-WXA2CFJO.js +23 -0
  180. package/dist/{chunk-QSNYB6ZV.js → chunk-XCUDZQLX.js} +3 -3
  181. package/dist/{chunk-4M6Z5QVF.js → chunk-XXBQKW32.js} +11 -11
  182. package/dist/{chunk-OEJSLEPW.js → chunk-YEJIG7LN.js} +332 -332
  183. package/dist/chunk-YGDMBK7O.js +567 -0
  184. package/dist/{chunk-4WR7VSYB.js → chunk-YYB3MC65.js} +23 -9
  185. package/dist/{chunk-2IR2NMPA.js → chunk-ZIDFQJRB.js} +2 -2
  186. package/dist/{chunk-Q4WO54TA.js → chunk-ZMZQEBKI.js} +14 -14
  187. package/dist/{chunk-6EJMN2Y3.js → chunk-ZTNFYMIO.js} +2 -2
  188. package/dist/{chunk-WEPFGWHJ.js → chunk-ZZFWWYLX.js} +2 -2
  189. package/dist/cli/index.js +44 -44
  190. package/dist/clio-5I2IBFYL.js +26 -0
  191. package/dist/{code-nav-IJR2DBPR.js → code-nav-YXIAEZVS.js} +48 -32
  192. package/dist/codewiki/build-worker.js +76 -29
  193. package/dist/{compile-cache-OQAVB7Y5.js → compile-cache-WJEPUZEJ.js} +4 -4
  194. package/dist/{components-2TGAI2RC.js → components-TNIKXCBH.js} +13 -13
  195. package/dist/{config-IUA6OYNS.js → config-Y2JDJ3JJ.js} +210 -124
  196. package/dist/configure-SML6UBZ5.js +55 -0
  197. package/dist/{context-4MPR7WKB.js → context-P5YSEO55.js} +125 -121
  198. package/dist/{context-2DKHWH2T.js → context-QQ53HSGJ.js} +91 -62
  199. package/dist/{context-BOYF5EJM.js → context-S2EEC3EJ.js} +62 -31
  200. package/dist/context-clear-TMEQCOTH.js +183 -0
  201. package/dist/{context-index-HNG3MOME.js → context-index-HP2JFUWA.js} +13 -11
  202. package/dist/{context-map-COB37XXN.js → context-map-INTXD54D.js} +71 -21
  203. package/dist/{context-working-set-3I3FYX6Y.js → context-working-set-CNLSQN5K.js} +31 -31
  204. package/dist/detail-5572VLBO.js +114 -0
  205. package/dist/{dispatch-runner-RJ5I2F2O.js → dispatch-runner-FRHD6P2O.js} +191 -116
  206. package/dist/{docs-SPOV3BAN.js → docs-BL7ROUFN.js} +4 -4
  207. package/dist/{doctor-DKICC2SN.js → doctor-N3LCM2LG.js} +58 -58
  208. package/dist/{eval-OQOQUDHK.js → eval-BUU3ZOUZ.js} +473 -168
  209. package/dist/{eval-inventory-Y6QRFOH5.js → eval-inventory-QOYZERXJ.js} +7 -7
  210. package/dist/evidence-DTGEN456.js +224 -0
  211. package/dist/{evidence-4DQ25GUQ.js → evidence-SQ5DNFEN.js} +110 -94
  212. package/dist/{evolve-GSS52E5J.js → evolve-IJNUFZDS.js} +107 -91
  213. package/dist/{extensions-G7MFLYHT.js → extensions-YVRHX6ZI.js} +16 -16
  214. package/dist/{fleet-Q37YHHAQ.js → fleet-ZNNVSYFO.js} +147 -147
  215. package/dist/{fleet-commands-G7E4N7SM.js → fleet-commands-5YE7NPJL.js} +27 -26
  216. package/dist/{fleet-decisions-O7M6QBA2.js → fleet-decisions-3SBSCTCW.js} +16 -15
  217. package/dist/{fleet-graph-TOUBW6OW.js → fleet-graph-6HHPWF5T.js} +39 -38
  218. package/dist/{fleet-inspect-SW33JJNI.js → fleet-inspect-JEYMGCGC.js} +107 -91
  219. package/dist/{fleet-new-RDVJLHHH.js → fleet-new-RCKGSRDV.js} +3 -3
  220. package/dist/{fleet-preflight-CV2655TW.js → fleet-preflight-QRSHIIDE.js} +10 -9
  221. package/dist/{fleet-validate-KESZX2YH.js → fleet-validate-4PM4GDDL.js} +46 -42
  222. package/dist/{fleet-verify-UQPMTVE3.js → fleet-verify-NJDTHTO3.js} +105 -89
  223. package/dist/fleet-view-UP2BWQQY.js +117 -0
  224. package/dist/{init-PXEXQSBF.js → init-S3GZQ5ZF.js} +123 -123
  225. package/dist/{install-NKNG7KD4.js → install-3RZDDP23.js} +5 -5
  226. package/dist/{interop-ZG5T62U3.js → interop-YOTGXFJM.js} +25 -25
  227. package/dist/inventory-K2OZ36YJ.js +117 -0
  228. package/dist/{library-B2W4N74O.js → library-GJI6W6OK.js} +45 -44
  229. package/dist/{memory-YCANYS5A.js → memory-OQOXQGYD.js} +107 -93
  230. package/dist/{models-GERTU3YI.js → models-3IK2Y5WE.js} +63 -62
  231. package/dist/{monitor-CPNIUULB.js → monitor-FTJLTKCQ.js} +136 -107
  232. package/dist/{orchestrator-J4BSH4WQ.js → orchestrator-N47O7SFD.js} +1159 -697
  233. package/dist/{panes-BOHAEGYC.js → panes-7BTYH3XQ.js} +8 -8
  234. package/dist/{panes-NXSLDQZ2.js → panes-WPOMEMRH.js} +22 -22
  235. package/dist/{paths-VSUWNC22.js → paths-J3KN7UAO.js} +12 -12
  236. package/dist/preload-65U34NG6.js +115 -0
  237. package/dist/{registry-LG64LTF4.js → registry-DESGAXWK.js} +3 -3
  238. package/dist/{reset-TNWTB5LU.js → reset-MUVQDLNL.js} +20 -20
  239. package/dist/{resources-4PXNMD5G.js → resources-LM76COAO.js} +41 -40
  240. package/dist/{run-D6XJ34CN.js → run-3VFZQ33N.js} +162 -156
  241. package/dist/{share-2NWMJJEE.js → share-4JUB4BL7.js} +43 -42
  242. package/dist/{skills-KR7WON5G.js → skills-S36AAJHU.js} +47 -46
  243. package/dist/{skills-eval-O2ZNOLDS.js → skills-eval-G6T57L7M.js} +127 -107
  244. package/dist/{skills-inventory-ZZOUBK7O.js → skills-inventory-WLM46PJH.js} +41 -40
  245. package/dist/slash-commands-GBARG3Y7.js +91 -0
  246. package/dist/{steer-XA25PSCS.js → steer-S7D7IKPU.js} +7 -7
  247. package/dist/{support-7EMVWYG2.js → support-5VAEC32W.js} +14 -14
  248. package/dist/{targets-OMH2XCSN.js → targets-N5REUETU.js} +145 -94
  249. package/dist/tasks-6BVY5YZF.js +36 -0
  250. package/dist/{terminal-lease-C2J3JYRE.js → terminal-lease-57UEOJKS.js} +12 -11
  251. package/dist/tools-6OCQ6SVB.js +28 -0
  252. package/dist/{trace-FXMXUZUF.js → trace-JHLXWUMN.js} +18 -17
  253. package/dist/{tree-sitter-HGKH6LG4.js → tree-sitter-AQUUOSYM.js} +6 -6
  254. package/dist/{tui-primitives-K5PASC3O.js → tui-primitives-RCY2HN7G.js} +3 -3
  255. package/dist/{uninstall-HALS6BLF.js → uninstall-FXYMFFRT.js} +17 -17
  256. package/dist/{upgrade-MS72RJEP.js → upgrade-4HD5HAIV.js} +40 -39
  257. package/dist/{usage-NHG6MCJM.js → usage-4GWM2WWP.js} +136 -105
  258. package/dist/{verifiers-7AUNVXDY.js → verifiers-GSKWKWVG.js} +28 -27
  259. package/dist/verify-3AS3ULCY.js +30 -0
  260. package/dist/{version-KGEG7EPO.js → version-RFPKO6T7.js} +4 -4
  261. package/dist/{web-fetch-V4FKSDAV.js → web-fetch-MQN4FH3X.js} +169 -18
  262. package/dist/wiki-generate-7BV7XWIY.js +614 -0
  263. package/dist/{with-panes-BDQEWBRT.js → with-panes-OFTNAR4Y.js} +34 -20
  264. package/dist/worker/entry.js +99 -88
  265. package/dist/{workspace-ZJ6BFM3Q.js → workspace-DZ7JADBG.js} +6 -6
  266. package/docs/README.md +7 -6
  267. package/docs/architecture/acp.md +10 -0
  268. package/docs/architecture/architecture.md +5 -5
  269. package/docs/architecture/context-engine.md +44 -59
  270. package/docs/architecture/context-working-set.md +7 -9
  271. package/docs/architecture/dispatch-architecture-rationale.md +1 -1
  272. package/docs/architecture/evidence-and-memory.md +10 -0
  273. package/docs/architecture/pi-boundary.md +37 -7
  274. package/docs/architecture/prompt-envelope-and-tools.md +7 -7
  275. package/docs/architecture/session-lifecycle.md +4 -4
  276. package/docs/architecture/worker-dispatch-mechanics.md +4 -0
  277. package/docs/guide/commands-and-modes.md +49 -36
  278. package/docs/guide/configuration-and-targets.md +7 -2
  279. package/docs/guide/configuration-reference.md +13 -3
  280. package/docs/guide/environment-variables.md +6 -2
  281. package/docs/guide/fleet-dispatch.md +12 -0
  282. package/docs/guide/installation-and-lifecycle.md +35 -9
  283. package/docs/guide/proactive-memory.md +1 -1
  284. package/docs/guide/skills-marketplace.md +11 -3
  285. package/docs/guide/tool-usage.md +9 -2
  286. package/docs/process/development-pipeline.md +10 -10
  287. package/docs/process/documentation-guide.md +2 -2
  288. package/docs/process/eval-runner.md +15 -0
  289. package/docs/process/evals-internal.md +1 -1
  290. package/docs/process/release-cut-checklist.md +6 -6
  291. package/evals/README.md +4 -0
  292. package/evals/behavioral-corpus-grader.mjs +147 -14
  293. package/evals/behavioral-model-negative-control.yaml +1 -0
  294. package/evals/behavioral-model.yaml +266 -1
  295. package/evals/fixtures/docs-retrieval.json +102 -0
  296. package/evals/fixtures/scalar-decision.json +17 -0
  297. package/evals/fixtures/scout-citation-pipeline.json +55 -0
  298. package/evals/fixtures/source-explanation.json +74 -0
  299. package/evals/fixtures/tool-arguments.json +18 -0
  300. package/evals/fixtures/tool-surface/read.txt +4 -0
  301. package/evals/fixtures/tool-surface/subdir/keep.txt +1 -0
  302. package/evals/no-edit-memory-grader.mjs +149 -0
  303. package/evals/scalar-decision-grader.py +41 -0
  304. package/evals/scalar-decision-machinery.ts +145 -0
  305. package/evals/source-explanation-grader.mjs +118 -0
  306. package/evals/tool-surface-grader.mjs +53 -0
  307. package/evals/tool-surface-model.yaml +274 -0
  308. package/package.json +14 -14
  309. package/skills/README.md +6 -6
  310. package/skills/registry.yaml +1 -1
  311. package/skills/skill-marketplace.json +1 -1
  312. package/src/cli/bootstrap-generate.ts +6 -0
  313. package/src/cli/config-inspect.ts +24 -7
  314. package/src/cli/config-trust.ts +62 -0
  315. package/src/cli/config.ts +8 -0
  316. package/src/cli/context-map.ts +75 -14
  317. package/src/cli/context.ts +46 -17
  318. package/src/cli/eval.ts +17 -3
  319. package/src/cli/modes/print.ts +32 -4
  320. package/src/cli/run.ts +16 -14
  321. package/src/cli/skills-eval.ts +10 -8
  322. package/src/cli/steer-channel.ts +31 -18
  323. package/src/cli/targets.ts +83 -31
  324. package/src/cli/tasks.ts +10 -1
  325. package/src/cli/upgrade.ts +9 -6
  326. package/src/cli/usage.ts +24 -0
  327. package/src/cli/wiki-generate.ts +239 -96
  328. package/src/core/bash-exec.ts +43 -15
  329. package/src/core/bus-events.ts +15 -0
  330. package/src/core/config.ts +33 -14
  331. package/src/core/defaults.ts +5 -4
  332. package/src/core/file-references.ts +11 -1
  333. package/src/core/incomplete-installation.ts +3 -1
  334. package/src/core/settings-layers.ts +21 -5
  335. package/src/core/termination.ts +26 -9
  336. package/src/core/untrusted-content.ts +16 -0
  337. package/src/core/workspace-trust.ts +179 -0
  338. package/src/domains/agents/builtins/coder.md +4 -2
  339. package/src/domains/agents/builtins/context-bootstrap.md +3 -1
  340. package/src/domains/agents/builtins/documenter.md +7 -4
  341. package/src/domains/agents/builtins/researcher.md +1 -0
  342. package/src/domains/agents/builtins/scout.md +7 -1
  343. package/src/domains/agents/result-contract.ts +199 -26
  344. package/src/domains/context/bootstrap-prompt.ts +11 -9
  345. package/src/domains/context/bootstrap.ts +74 -39
  346. package/src/domains/context/clio-md.ts +88 -26
  347. package/src/domains/context/codewiki/build-operation.ts +121 -0
  348. package/src/domains/context/codewiki/build-worker-protocol.ts +37 -3
  349. package/src/domains/context/codewiki/build-worker.ts +3 -35
  350. package/src/domains/context/codewiki/coordinator.ts +36 -6
  351. package/src/domains/context/codewiki/indexer.ts +59 -19
  352. package/src/domains/context/contract.ts +6 -2
  353. package/src/domains/context/extension.ts +72 -10
  354. package/src/domains/context/fingerprint.ts +39 -34
  355. package/src/domains/context/index.ts +7 -1
  356. package/src/domains/context/prompt-context.ts +55 -14
  357. package/src/domains/context/refresh.ts +9 -57
  358. package/src/domains/context/wiki/assemble.ts +14 -10
  359. package/src/domains/context/wiki/evidence.ts +209 -0
  360. package/src/domains/context/wiki/generate.ts +201 -67
  361. package/src/domains/context/wiki/meta.ts +10 -2
  362. package/src/domains/context/wiki/plan-store.ts +70 -14
  363. package/src/domains/context/wiki/plan.ts +71 -14
  364. package/src/domains/context/wiki/prompts.ts +42 -1
  365. package/src/domains/context/wiki/source-content.ts +106 -0
  366. package/src/domains/context/wiki/staleness.ts +33 -22
  367. package/src/domains/context/working-set/contract.ts +8 -2
  368. package/src/domains/context/working-set/engine.ts +17 -4
  369. package/src/domains/context/working-set/fold.ts +15 -2
  370. package/src/domains/context/working-set/marker.ts +2 -1
  371. package/src/domains/context/working-set/project.ts +18 -7
  372. package/src/domains/context/working-set/recall.ts +82 -56
  373. package/src/domains/dispatch/active-route-planner.ts +6 -3
  374. package/src/domains/dispatch/admission-queue.ts +19 -7
  375. package/src/domains/dispatch/admission.ts +3 -3
  376. package/src/domains/dispatch/budget-envelope.ts +47 -82
  377. package/src/domains/dispatch/capacity-lease.ts +57 -19
  378. package/src/domains/dispatch/contract.ts +10 -2
  379. package/src/domains/dispatch/event-pump.ts +28 -7
  380. package/src/domains/dispatch/execution-role.ts +49 -2
  381. package/src/domains/dispatch/execution-scheduler.ts +2 -0
  382. package/src/domains/dispatch/extension.ts +190 -105
  383. package/src/domains/dispatch/fleet-run.ts +20 -0
  384. package/src/domains/dispatch/gate-role-prompts.ts +4 -2
  385. package/src/domains/dispatch/parallel-writers.ts +34 -0
  386. package/src/domains/dispatch/reservation-store.ts +8 -34
  387. package/src/domains/dispatch/route-approval.ts +3 -3
  388. package/src/domains/dispatch/route-observer.ts +4 -2
  389. package/src/domains/dispatch/route-quality.ts +6 -1
  390. package/src/domains/dispatch/types.ts +4 -3
  391. package/src/domains/dispatch/worker-spawn.ts +58 -21
  392. package/src/domains/dispatch/workspace-checkpoint.ts +57 -0
  393. package/src/domains/eval/compare/behavioral.ts +81 -14
  394. package/src/domains/eval/compare/compare.ts +15 -5
  395. package/src/domains/eval/compare/envelope.ts +12 -5
  396. package/src/domains/eval/metrics/context.ts +24 -1
  397. package/src/domains/eval/metrics/tracked.ts +4 -28
  398. package/src/domains/eval/reports/comparison.ts +9 -9
  399. package/src/domains/eval/runners/clio-run.ts +5 -1
  400. package/src/domains/eval/schema/suite.ts +2 -0
  401. package/src/domains/eval/schema/validate.ts +1 -0
  402. package/src/domains/eval/suites/run.ts +189 -13
  403. package/src/domains/eval/verifiers/integrity.ts +39 -0
  404. package/src/domains/eval/verifiers/patch.ts +58 -2
  405. package/src/domains/eval/workspaces/temp-copy.ts +3 -0
  406. package/src/domains/evidence/build.ts +4 -2
  407. package/src/domains/interop/registry.ts +2 -2
  408. package/src/domains/middleware/hooks-io.ts +45 -26
  409. package/src/domains/middleware/hooks.ts +6 -0
  410. package/src/domains/middleware/injection-screen.ts +23 -0
  411. package/src/domains/middleware/rules.ts +5 -1
  412. package/src/domains/middleware/stalled-turn.ts +18 -3
  413. package/src/domains/middleware/task-board-reminder.ts +4 -2
  414. package/src/domains/middleware/task-nudge.ts +4 -1
  415. package/src/domains/mux/contract.ts +34 -1
  416. package/src/domains/mux/dock-controller.ts +8 -1
  417. package/src/domains/mux/index.ts +1 -0
  418. package/src/domains/mux/socket-client.ts +13 -3
  419. package/src/domains/observability/contract.ts +2 -2
  420. package/src/domains/observability/projection.ts +30 -9
  421. package/src/domains/prompts/compiler.ts +10 -2
  422. package/src/domains/prompts/contract.ts +7 -4
  423. package/src/domains/prompts/extension.ts +28 -64
  424. package/src/domains/prompts/fragments/identity/clio.md +23 -0
  425. package/src/domains/prompts/fragments/operating/contract.md +10 -0
  426. package/src/domains/prompts/fragments/operating/delegation.md +5 -0
  427. package/src/domains/prompts/fragments/wiki/page.md +28 -15
  428. package/src/domains/prompts/fragments/wiki/plan.md +4 -4
  429. package/src/domains/prompts/preload-prefix.ts +31 -0
  430. package/src/domains/prompts/preload.ts +135 -61
  431. package/src/domains/providers/auth/backend-file.ts +15 -11
  432. package/src/domains/providers/auth/storage.ts +3 -5
  433. package/src/domains/providers/catalog.ts +18 -3
  434. package/src/domains/providers/runtime-resolution.ts +11 -9
  435. package/src/domains/providers/runtimes/cloud/openrouter.ts +2 -0
  436. package/src/domains/resources/skills/promotion.ts +8 -1
  437. package/src/domains/safety/action-classifier.ts +9 -0
  438. package/src/domains/safety/autonomy.ts +10 -1
  439. package/src/domains/safety/contract.ts +5 -1
  440. package/src/domains/safety/default-path-policy.ts +11 -0
  441. package/src/domains/safety/extension.ts +11 -2
  442. package/src/domains/safety/policy-engine.ts +189 -32
  443. package/src/domains/safety/project-policy.ts +7 -2
  444. package/src/domains/safety/workspace-trust.ts +43 -0
  445. package/src/domains/session/compaction/compact.ts +384 -21
  446. package/src/domains/session/compaction/cut-point.ts +42 -5
  447. package/src/domains/session/compaction/tokens.ts +9 -1
  448. package/src/domains/session/decision-board.ts +43 -33
  449. package/src/domains/session/entries.ts +169 -4
  450. package/src/domains/session/prompt-manifest.ts +47 -8
  451. package/src/domains/session/task-board.ts +21 -3
  452. package/src/domains/user-tasks/handoff.ts +16 -0
  453. package/src/engine/acp/adapter.ts +44 -12
  454. package/src/engine/acp/server.ts +1 -0
  455. package/src/engine/acp/transport.ts +2 -1
  456. package/src/engine/acp/types.ts +6 -1
  457. package/src/engine/antigravity/subprocess-runtime.ts +20 -4
  458. package/src/engine/api-registry.ts +19 -2
  459. package/src/engine/apis/openai-completions.ts +13 -6
  460. package/src/engine/apis/output-budget.ts +26 -10
  461. package/src/engine/claude/sdk-runtime.ts +4 -3
  462. package/src/engine/env-api-keys.ts +2 -1
  463. package/src/engine/external-subprocess.ts +14 -3
  464. package/src/engine/loop-guard.ts +19 -2
  465. package/src/engine/provider-diagnostics.ts +129 -0
  466. package/src/engine/provider-payload.ts +3 -1
  467. package/src/engine/worker-runtime.ts +13 -2
  468. package/src/engine/worker-tools.ts +5 -1
  469. package/src/entry/extension-reload.ts +1 -0
  470. package/src/entry/orchestrator.ts +53 -15
  471. package/src/interactive/chat-loop-messages.ts +12 -4
  472. package/src/interactive/chat-loop.ts +115 -45
  473. package/src/interactive/chat-renderer.ts +60 -0
  474. package/src/interactive/context-recall-command.ts +2 -1
  475. package/src/interactive/dispatch-board.ts +17 -2
  476. package/src/interactive/editor-submit.ts +13 -0
  477. package/src/interactive/interactive-application.ts +8 -2
  478. package/src/interactive/interactive-event-projection.ts +7 -1
  479. package/src/interactive/interactive-presentation.ts +15 -7
  480. package/src/interactive/interactive-slash-runtime.ts +2 -0
  481. package/src/interactive/layout.ts +2 -1
  482. package/src/interactive/model-session-replay.ts +2 -2
  483. package/src/interactive/overlay-frame.ts +1 -0
  484. package/src/interactive/overlay-general-openers.ts +3 -1
  485. package/src/interactive/overlay-session-lifecycle.ts +6 -0
  486. package/src/interactive/overlays/ask-user.ts +1 -0
  487. package/src/interactive/overlays/message-picker.ts +1 -1
  488. package/src/interactive/renderers/tool-execution.ts +17 -1
  489. package/src/interactive/renderers/worker-entry.ts +25 -10
  490. package/src/interactive/slash-commands.ts +9 -7
  491. package/src/interactive/turn-context.ts +221 -53
  492. package/src/interactive/turn-middleware.ts +3 -1
  493. package/src/interactive/turn-persistence.ts +3 -0
  494. package/src/interactive/turn-runtime.ts +11 -2
  495. package/src/interactive/turn-state.ts +10 -9
  496. package/src/interactive/watch-pane.ts +18 -4
  497. package/src/interactive/worker-stream.ts +7 -7
  498. package/src/tools/agent-tools.ts +6 -3
  499. package/src/tools/bash.ts +1 -1
  500. package/src/tools/builtin-tool-catalog.ts +9 -2
  501. package/src/tools/codewiki/code-nav.ts +4 -10
  502. package/src/tools/compete-judge-task.ts +71 -0
  503. package/src/tools/compete-worktrees.ts +34 -0
  504. package/src/tools/context/index.ts +32 -7
  505. package/src/tools/context/surface.ts +15 -4
  506. package/src/tools/decide.ts +1 -1
  507. package/src/tools/dispatch-admission.ts +12 -1
  508. package/src/tools/dispatch-arguments.ts +38 -1
  509. package/src/tools/dispatch-plan.ts +7 -7
  510. package/src/tools/dispatch-runner.ts +48 -32
  511. package/src/tools/dispatch-schema.ts +30 -23
  512. package/src/tools/dispatch-scout-admission.ts +10 -44
  513. package/src/tools/dispatch-scout.ts +2 -3
  514. package/src/tools/find.ts +13 -4
  515. package/src/tools/grep.ts +13 -1
  516. package/src/tools/ls.ts +7 -1
  517. package/src/tools/monitor.ts +26 -11
  518. package/src/tools/network-policy.ts +11 -24
  519. package/src/tools/observation.ts +39 -2
  520. package/src/tools/read.ts +112 -15
  521. package/src/tools/registry.ts +54 -17
  522. package/src/tools/result-shaping.ts +110 -2
  523. package/src/tools/tasks.ts +33 -7
  524. package/src/tools/verify/frontend.ts +67 -30
  525. package/src/tools/verify/numeric.ts +6 -1
  526. package/src/tools/web-fetch-network.ts +179 -0
  527. package/src/tools/web-fetch-surface.ts +2 -1
  528. package/src/tools/web-fetch.ts +15 -13
  529. package/src/tools/worker-evidence.ts +27 -0
  530. package/src/worker/spec-contract.ts +12 -8
  531. package/dist/builtins-WGALA46I.js +0 -22
  532. package/dist/chunk-2WZ546HR.js +0 -792
  533. package/dist/chunk-5PSMVOLM.js +0 -56
  534. package/dist/chunk-EL24TAU4.js +0 -1560
  535. package/dist/chunk-IZXGRF7P.js +0 -4048
  536. package/dist/chunk-JVCV3ICN.js +0 -47
  537. package/dist/chunk-MNJGS2IN.js +0 -33
  538. package/dist/chunk-O5CVSAG5.js +0 -122
  539. package/dist/chunk-ODGTEFFI.js +0 -50
  540. package/dist/chunk-OQE5J4C6.js +0 -73
  541. package/dist/chunk-UUVG37B4.js +0 -244
  542. package/dist/chunk-V6HJFQZE.js +0 -228
  543. package/dist/clio-QLICPCF5.js +0 -25
  544. package/dist/configure-VEPX4NMX.js +0 -55
  545. package/dist/context-clear-S4ZJCQUX.js +0 -182
  546. package/dist/detail-A7JAVSIG.js +0 -98
  547. package/dist/evidence-4F5USFKH.js +0 -208
  548. package/dist/fleet-view-MN2VG4MR.js +0 -101
  549. package/dist/inventory-C26CFDRR.js +0 -101
  550. package/dist/preload-P6DGH2PZ.js +0 -13
  551. package/dist/slash-commands-ZXPJD64J.js +0 -92
  552. package/dist/tasks-IPAGMEIX.js +0 -36
  553. package/dist/tools-EFFEAIDP.js +0 -28
  554. package/dist/verify-FWYGPKMR.js +0 -29
  555. package/dist/wiki-generate-743CIGJW.js +0 -476
@@ -8,7 +8,7 @@ import {
8
8
  detectOverflowFromState,
9
9
  detectTerminalFailureFromState,
10
10
  estimatedUsageForInterruptedTurn,
11
- expandInlineFileReferencesAsync,
11
+ explainInterruptedAssistant,
12
12
  extractText,
13
13
  extractThinking,
14
14
  extractUserText,
@@ -33,126 +33,98 @@ import {
33
33
  toolNamesFromAgentState,
34
34
  toolResultSummary,
35
35
  toolSignatureFromState
36
- } from "./chunk-YD5GIKET.js";
36
+ } from "./chunk-UTUNT5QL.js";
37
37
  import {
38
38
  ShareDomainModule
39
- } from "./chunk-USR47QNF.js";
39
+ } from "./chunk-UL36QJX6.js";
40
40
  import {
41
41
  bootstrapInputFromInitOptions,
42
42
  modelBootstrapGenerate,
43
43
  resolveBootstrapRoute
44
- } from "./chunk-N56KALIC.js";
45
- import "./chunk-MNJGS2IN.js";
44
+ } from "./chunk-S32UQ5GL.js";
46
45
  import {
47
46
  DEFAULT_KEEP_RECENT_TOKENS,
48
47
  DEFAULT_RESERVE_TOKENS,
49
48
  buildEvictionFields,
50
49
  calculateContextTokens,
51
- compactionCut,
52
50
  estimateTokens,
53
51
  findCutPoint,
54
52
  getLastAssistantUsage,
55
53
  planEviction,
56
54
  projectWorkingSet,
57
- resolveWorkingSetPolicy,
58
- selectVisibleEntries
59
- } from "./chunk-ZA4VCIGV.js";
55
+ resolveWorkingSetPolicy
56
+ } from "./chunk-UUQ5G6EZ.js";
60
57
  import {
61
58
  SchedulingDomainModule,
62
59
  createPromptsDomainModule,
63
60
  renderAgentCatalogSectionsFromSpecs
64
- } from "./chunk-YNFKXPEC.js";
61
+ } from "./chunk-DIMRLNIC.js";
62
+ import {
63
+ PROMPT_MANIFEST_VERSION,
64
+ appendPromptCompileRecord,
65
+ getPromptManifestFilePath,
66
+ readPromptCompileManifest,
67
+ readPromptCompileRecords
68
+ } from "./chunk-5ZSZEYJK.js";
65
69
  import {
66
70
  recordFailedCompactionCalls
67
- } from "./chunk-FEAXX7B6.js";
71
+ } from "./chunk-EHCPSZJF.js";
68
72
  import {
69
73
  describePanesLeftBehind,
70
74
  paneWatchDecision
71
- } from "./chunk-3EBYEESD.js";
75
+ } from "./chunk-A46ILRS2.js";
72
76
  import {
73
77
  flushRawStdout,
74
78
  writeRawStdout
75
- } from "./chunk-2VTFPG5O.js";
79
+ } from "./chunk-7WLRF2U5.js";
76
80
  import {
77
81
  capturedHookSourcesFor
78
- } from "./chunk-SZAA6XDG.js";
82
+ } from "./chunk-IFDRAD6F.js";
79
83
  import {
80
84
  LifecycleDomainModule,
81
85
  describeUpgradeNotice
82
- } from "./chunk-JQLNNIKT.js";
83
- import "./chunk-GWZNEVM2.js";
84
- import "./chunk-5ICU3EUH.js";
86
+ } from "./chunk-R6MICQYU.js";
87
+ import "./chunk-EWD5P3GK.js";
88
+ import "./chunk-GVYWZNRK.js";
85
89
  import {
86
90
  ConfigDomainModule,
87
91
  createConfigDomainModule,
88
92
  loadDomains
89
- } from "./chunk-72YIHOZQ.js";
90
- import "./chunk-4WR7VSYB.js";
93
+ } from "./chunk-ILJ7DWGE.js";
94
+ import "./chunk-YYB3MC65.js";
91
95
  import {
92
96
  buildRecallFields,
93
97
  recallErrorMessage,
94
98
  recallParentTurnId,
95
99
  recallableRefListing,
96
100
  resolveRecall
97
- } from "./chunk-O5CVSAG5.js";
101
+ } from "./chunk-ECOMVOHP.js";
98
102
  import {
103
+ compactionCut,
99
104
  foldWorkingSet,
100
- isTurnStart
101
- } from "./chunk-GTUD2WMY.js";
105
+ isTurnStart,
106
+ selectVisibleEntries
107
+ } from "./chunk-DBREN25X.js";
102
108
  import {
103
109
  compileScoutTransition
104
- } from "./chunk-S6PYF2XF.js";
110
+ } from "./chunk-WFKDPU7U.js";
105
111
  import {
106
112
  monitorToolSurface
107
- } from "./chunk-LLXSDWXS.js";
113
+ } from "./chunk-NF3BK5WR.js";
108
114
  import {
109
115
  ObservabilityDomainModule,
110
116
  recordBackgroundMemoryStep
111
- } from "./chunk-Y55JBDO5.js";
117
+ } from "./chunk-FSTIBAGM.js";
112
118
  import {
113
119
  appendOutOfTurnUsageRow,
114
120
  readAccountabilitySummary
115
- } from "./chunk-JT2RFCC5.js";
121
+ } from "./chunk-HR3HPQ76.js";
116
122
  import {
117
123
  steerToolSurface
118
- } from "./chunk-RAY4OVGZ.js";
124
+ } from "./chunk-URBGEOH3.js";
119
125
  import {
120
126
  panesToolSurface
121
- } from "./chunk-3GY4F45V.js";
122
- import {
123
- createContextDomainModule,
124
- loadProjectClioMd
125
- } from "./chunk-IZXGRF7P.js";
126
- import "./chunk-R6Q67RJH.js";
127
- import {
128
- SafetyDomainModule
129
- } from "./chunk-5636DCO5.js";
130
- import {
131
- renderCodewikiDigest
132
- } from "./chunk-V6HJFQZE.js";
133
- import {
134
- buildMemoryPromptSection,
135
- canonicalMemoryRepositoryIdentity,
136
- createTaskMemoryTrace,
137
- describeTaskMemoryActivity,
138
- formatTaskMemorySpend,
139
- loadMemoryRecordsSync,
140
- proposeInjectedTaskMemory,
141
- proposeMemoryPromotion,
142
- readTaskMemorySpendSummary,
143
- renderTaskMemoryHandoffSource,
144
- seedTaskMemoryFromNewestHandoff,
145
- taskMemoryBankSize,
146
- taskMemoryHandoffSeedOffer,
147
- taskMemoryTracePath
148
- } from "./chunk-EL24TAU4.js";
149
- import {
150
- listWikiPages,
151
- wikiCompleteness,
152
- wikiStaleness,
153
- wikiStalenessAsync
154
- } from "./chunk-ELZVTCGV.js";
155
- import "./chunk-MXHC5QYU.js";
127
+ } from "./chunk-NC4KV7EL.js";
156
128
  import {
157
129
  BUILTIN_SLASH_COMMANDS,
158
130
  COMPLETION_SLOT_NAMES,
@@ -164,18 +136,17 @@ import {
164
136
  completeArgs,
165
137
  createWorkerStream,
166
138
  dispatchSlashCommand,
167
- formatUserTaskHandoff,
168
139
  isWorkerShareNote,
169
140
  parseSlashCommand,
170
141
  renderArgsSpec,
171
142
  workerAskedByModel,
172
143
  workerReceiptSummary,
173
144
  workerTargetLabel
174
- } from "./chunk-FFUPXJC4.js";
145
+ } from "./chunk-KDWLXVMN.js";
175
146
  import {
176
147
  boundSettledText
177
- } from "./chunk-XXYSBZIQ.js";
178
- import "./chunk-35MSIRKH.js";
148
+ } from "./chunk-O2RQ7LCK.js";
149
+ import "./chunk-QUIJZSDW.js";
179
150
  import {
180
151
  classifyLibraryRequirements,
181
152
  createResourcesDomainModule,
@@ -186,16 +157,120 @@ import {
186
157
  libraryEntryRef,
187
158
  libraryInstallPath,
188
159
  planLibraryInstall
189
- } from "./chunk-RQCKCSRL.js";
160
+ } from "./chunk-U7VQ4NI4.js";
190
161
  import {
191
162
  AgentsDomainModule
192
- } from "./chunk-RZDWV63N.js";
193
- import "./chunk-7UGL4MB5.js";
194
- import "./chunk-DR52UMZW.js";
163
+ } from "./chunk-NY6IWDVU.js";
164
+ import "./chunk-EQEJJ53P.js";
165
+ import "./chunk-3UW3KU4A.js";
195
166
  import {
196
- createUserTasksStore
197
- } from "./chunk-EXLD33WO.js";
198
- import "./chunk-YAKGTXEV.js";
167
+ createUserTasksStore,
168
+ formatUserTaskHandoff
169
+ } from "./chunk-VLPTKCKT.js";
170
+ import "./chunk-QRFXEO6Y.js";
171
+ import {
172
+ ToolchainDomainModule
173
+ } from "./chunk-32KJPXAM.js";
174
+ import "./chunk-K6RDB7IA.js";
175
+ import {
176
+ ensureClioState,
177
+ takeUpgradeNotice
178
+ } from "./chunk-E3BQTQUP.js";
179
+ import "./chunk-T334FW2H.js";
180
+ import "./chunk-LZBMXNLP.js";
181
+ import {
182
+ MARKETPLACE_UNCONFIGURED,
183
+ discoverMarketplaceSkills,
184
+ installSkill,
185
+ modelVisibleSkills
186
+ } from "./chunk-T7FDXNRU.js";
187
+ import "./chunk-DNCE23JJ.js";
188
+ import "./chunk-U7H5WRG5.js";
189
+ import "./chunk-5GZICIYO.js";
190
+ import "./chunk-MC3JSVR6.js";
191
+ import {
192
+ INHERITED_PROJECT_CONTEXT,
193
+ InteropDomainModule,
194
+ delegationEntryForKind,
195
+ renderProposalEntry
196
+ } from "./chunk-6SYEGZI3.js";
197
+ import "./chunk-T53XI6I7.js";
198
+ import {
199
+ ClioEditor,
200
+ CombinedAutocompleteProvider,
201
+ Container,
202
+ DEFAULT_SELECT_THEME,
203
+ FILTER_HINT,
204
+ FocusBox,
205
+ GLYPH,
206
+ Input,
207
+ MUTATION_PREVIEW_KEY,
208
+ Markdown,
209
+ Marked,
210
+ SGR_DIM,
211
+ SGR_RESET,
212
+ ScrollView,
213
+ SelectList,
214
+ Text,
215
+ VStack,
216
+ abbreviateModelId,
217
+ barSep,
218
+ bashExecutionEntryInput,
219
+ brandMark,
220
+ buildHint,
221
+ buildResponsiveHint,
222
+ clioError,
223
+ clioTheme,
224
+ collapseHomePath,
225
+ createAgentProgress,
226
+ createKeybindingManager,
227
+ createProcessInteractiveShell,
228
+ detectPlatformKeybindingWarnings,
229
+ detectTerminalKeySupport,
230
+ diagnosticSeverityToken,
231
+ dotSep,
232
+ fgSequence,
233
+ fitHintEntries,
234
+ fitUnits,
235
+ formatCompactMs,
236
+ formatContextPercent,
237
+ formatInvalidKeybindingNotice,
238
+ formatPlatformKeybindingNotice,
239
+ formatRuntimeResolutionDiagnostic,
240
+ formatTargetLabel,
241
+ frame,
242
+ fuzzyFilter,
243
+ getActiveRenderTrace,
244
+ getKeybindings,
245
+ innerDivider,
246
+ isClioToken,
247
+ isKeyRelease,
248
+ joinChips,
249
+ joinSections,
250
+ listGroupHeader,
251
+ markdownTheme,
252
+ matchesKey,
253
+ padAnsi,
254
+ paintHex,
255
+ parseEditorBashCommand,
256
+ permissionHintEntries,
257
+ rule,
258
+ screenTitle,
259
+ sectionTag,
260
+ selectListTheme,
261
+ showClioOverlayFrame,
262
+ spinnerFrame,
263
+ stripTerminalSequences,
264
+ truncateToWidth,
265
+ unguardPastedEditorOperator,
266
+ validateKeybindings,
267
+ visibleWidth,
268
+ wrapTextWithAnsi,
269
+ writeInputWedgeDump
270
+ } from "./chunk-7TKWWPD7.js";
271
+ import {
272
+ getTerminationCoordinator
273
+ } from "./chunk-BS4GAMUB.js";
199
274
  import {
200
275
  ACP_AGENT_META_KEY,
201
276
  ACP_MAX_CHUNK_BYTES,
@@ -210,54 +285,74 @@ import {
210
285
  COST_NOT_MEASURED,
211
286
  acpErrorMessage,
212
287
  aggregateCostAmounts,
288
+ buildMemoryPromptSection,
289
+ canonicalMemoryRepositoryIdentity,
213
290
  capacityLeaseUsage,
214
291
  costAggregateForAmount,
292
+ createContextDomainModule,
215
293
  createDispatchDomainModule,
216
294
  createDispatchRunEventRegistry,
217
295
  createRunReceiptQuality,
218
296
  createStdioServerTransport,
297
+ createTaskMemoryTrace,
298
+ describeTaskMemoryActivity,
219
299
  endpointCapacityUsage,
220
300
  evidenceDirectory,
221
301
  executeFleetRun,
222
302
  formatCostAggregate,
303
+ formatTaskMemorySpend,
223
304
  inspectEvidence,
224
305
  listEvidenceOverviews,
306
+ loadMemoryRecordsSync,
307
+ loadProjectClioMd,
308
+ newRunId,
225
309
  openLedger,
310
+ proposeInjectedTaskMemory,
311
+ proposeMemoryPromotion,
226
312
  protectedResidencyModels,
313
+ readTaskMemorySpendSummary,
227
314
  renderCostAggregate,
228
- renderDispatchReviewerTask
229
- } from "./chunk-NRO2BJRH.js";
315
+ renderDispatchReviewerTask,
316
+ renderTaskMemoryHandoffSource,
317
+ seedTaskMemoryFromNewestHandoff,
318
+ taskMemoryBankSize,
319
+ taskMemoryHandoffSeedOffer,
320
+ taskMemoryTracePath
321
+ } from "./chunk-SDWNDICN.js";
322
+ import "./chunk-PECBKCDK.js";
230
323
  import {
231
324
  readGateDecisionArtifacts,
232
325
  readPendingGateDecisions
233
- } from "./chunk-NXIMQY5W.js";
234
- import "./chunk-XRZT5WY5.js";
326
+ } from "./chunk-ODUTYZIU.js";
327
+ import "./chunk-P5SC4DLJ.js";
235
328
  import {
236
329
  describeWriteBoundaryAttributionDowngrade,
237
330
  gitCheckoutRoot,
238
331
  isGitRepository,
239
332
  preflightWriteBoundaries,
240
333
  recoverCleanupReadyCompeteGroups
241
- } from "./chunk-QUFRYSWI.js";
334
+ } from "./chunk-GNQRWTMY.js";
242
335
  import {
243
336
  bindExecutionPlanEndpoints,
244
337
  compileFleetExecutionPlan,
245
338
  requireAgentSteps
246
- } from "./chunk-LTIKRKFL.js";
339
+ } from "./chunk-ONRTXOZY.js";
247
340
  import {
341
+ SafetyDomainModule,
248
342
  parseRigorOverride,
249
343
  resolveRigor
250
- } from "./chunk-ODGTEFFI.js";
344
+ } from "./chunk-WLMSOT73.js";
251
345
  import {
252
346
  TRUST_STATUS_AXES,
253
347
  formatTrustSummaryLine,
254
348
  inspectRunReceiptTrustStatus,
255
349
  isReceiptIntegrity,
350
+ renderCodewikiDigest,
256
351
  retiredReceiptIntegrity,
257
352
  retiredReceiptIntegrityReason,
258
353
  trustStateWord,
259
354
  verifyReceiptIntegrity
260
- } from "./chunk-CUSRQKPU.js";
355
+ } from "./chunk-6CDNRHWH.js";
261
356
  import {
262
357
  SessionDomainModule,
263
358
  addResponseModelIdObservationCount,
@@ -271,20 +366,30 @@ import {
271
366
  readAuditRows,
272
367
  responseModelIdObservationCountsLabel,
273
368
  responseModelIdObservationFromRecord
274
- } from "./chunk-6UINWWS6.js";
275
- import "./chunk-FTMGRKEF.js";
369
+ } from "./chunk-F34AR6O3.js";
370
+ import "./chunk-U44YYLVV.js";
276
371
  import {
277
372
  configureRunEventJournal
278
- } from "./chunk-VIA6RFQZ.js";
373
+ } from "./chunk-UQIVHSE4.js";
374
+ import {
375
+ wikiCompleteness,
376
+ wikiStaleness,
377
+ wikiStalenessAsync
378
+ } from "./chunk-USZA7GWL.js";
379
+ import {
380
+ listWikiPages
381
+ } from "./chunk-LVFANMOH.js";
382
+ import "./chunk-WTQGRBHV.js";
383
+ import "./chunk-7WUZEB2M.js";
279
384
  import {
280
385
  filterEntriesToActivePath
281
- } from "./chunk-W6GROXXM.js";
386
+ } from "./chunk-O5F25NIE.js";
282
387
  import {
283
388
  activeDecisionRefs,
284
389
  createDecisionBoardStore,
285
390
  decisionRationale,
286
391
  foldDecisionBoard
287
- } from "./chunk-I2DWJ4GM.js";
392
+ } from "./chunk-5DDOTTG4.js";
288
393
  import {
289
394
  FLEET_COMMANDS_REMEDY,
290
395
  FleetCommandRegistryMissingError,
@@ -294,142 +399,39 @@ import {
294
399
  renderFleetPrompt,
295
400
  validateFleetCommands,
296
401
  validateFleetGraph
297
- } from "./chunk-OEJSLEPW.js";
298
- import "./chunk-RKKLTLYB.js";
402
+ } from "./chunk-YEJIG7LN.js";
403
+ import "./chunk-CXQ37WJH.js";
299
404
  import {
300
405
  discoverDeclaredChecks
301
- } from "./chunk-K6T2ZAMZ.js";
406
+ } from "./chunk-HGSLRG33.js";
407
+ import "./chunk-7YJWEF2L.js";
302
408
  import {
303
409
  shellQuote
304
- } from "./chunk-3UUXNFEX.js";
305
- import {
306
- ToolchainDomainModule
307
- } from "./chunk-HRQMFLJP.js";
308
- import "./chunk-2ASED4PZ.js";
309
- import {
310
- ensureClioState,
311
- takeUpgradeNotice
312
- } from "./chunk-IGLP3ODT.js";
313
- import "./chunk-3M6DQK6S.js";
314
- import "./chunk-VKPAQYEB.js";
315
- import "./chunk-LCGCVYZ4.js";
316
- import {
317
- MARKETPLACE_UNCONFIGURED,
318
- discoverMarketplaceSkills,
319
- installSkill,
320
- modelVisibleSkills
321
- } from "./chunk-2ZSONWVL.js";
322
- import "./chunk-NDDGJUXD.js";
323
- import "./chunk-YECAMM3D.js";
324
- import "./chunk-V76WTFTW.js";
410
+ } from "./chunk-SD7SHNDW.js";
411
+ import "./chunk-T52TPHYC.js";
325
412
  import {
326
413
  foldPromptCacheTelemetry,
327
414
  hasPromptCacheTelemetry,
328
415
  uncachedPrefillTokens
329
- } from "./chunk-3DPEIQKN.js";
416
+ } from "./chunk-QH3ZTUOA.js";
417
+ import "./chunk-LQTKDAUO.js";
330
418
  import {
331
419
  EXTENSION_SNAPSHOT_DIAGNOSTIC_MESSAGE_CAP,
332
420
  ExtensionsDomainModule
333
- } from "./chunk-TQAHXW6Y.js";
334
- import "./chunk-5MEZN6CB.js";
335
- import "./chunk-D4CJV46V.js";
336
- import "./chunk-NEKRRTYW.js";
337
- import {
338
- INHERITED_PROJECT_CONTEXT,
339
- InteropDomainModule,
340
- delegationEntryForKind,
341
- renderProposalEntry
342
- } from "./chunk-JEIYHLOR.js";
343
- import "./chunk-I7XBWTYH.js";
344
- import {
345
- ClioEditor,
346
- CombinedAutocompleteProvider,
347
- Container,
348
- DEFAULT_SELECT_THEME,
349
- FILTER_HINT,
350
- FocusBox,
351
- GLYPH,
352
- Input,
353
- MUTATION_PREVIEW_KEY,
354
- Markdown,
355
- Marked,
356
- SGR_DIM,
357
- SGR_RESET,
358
- ScrollView,
359
- SelectList,
360
- Text,
361
- VStack,
362
- abbreviateModelId,
363
- barSep,
364
- bashExecutionEntryInput,
365
- brandMark,
366
- buildHint,
367
- buildResponsiveHint,
368
- clioError,
369
- clioTheme,
370
- collapseHomePath,
371
- createAgentProgress,
372
- createKeybindingManager,
373
- createProcessInteractiveShell,
374
- detectPlatformKeybindingWarnings,
375
- detectTerminalKeySupport,
376
- diagnosticSeverityToken,
377
- dotSep,
378
- fgSequence,
379
- fitHintEntries,
380
- fitUnits,
381
- formatCompactMs,
382
- formatContextPercent,
383
- formatInvalidKeybindingNotice,
384
- formatPlatformKeybindingNotice,
385
- formatRuntimeResolutionDiagnostic,
386
- formatTargetLabel,
387
- frame,
388
- fuzzyFilter,
389
- getActiveRenderTrace,
390
- getKeybindings,
391
- innerDivider,
392
- isClioToken,
393
- isKeyRelease,
394
- joinChips,
395
- joinSections,
396
- listGroupHeader,
397
- markdownTheme,
398
- matchesKey,
399
- padAnsi,
400
- paintHex,
401
- parseEditorBashCommand,
402
- permissionHintEntries,
403
- rule,
404
- screenTitle,
405
- sectionTag,
406
- selectListTheme,
407
- showClioOverlayFrame,
408
- spinnerFrame,
409
- stripTerminalSequences,
410
- truncateToWidth,
411
- unguardPastedEditorOperator,
412
- validateKeybindings,
413
- visibleWidth,
414
- wrapTextWithAnsi,
415
- writeInputWedgeDump
416
- } from "./chunk-25QBEXRS.js";
417
- import {
418
- getTerminationCoordinator
419
- } from "./chunk-4O6MANBS.js";
420
- import "./chunk-JVCV3ICN.js";
421
+ } from "./chunk-22PQ4TX4.js";
422
+ import "./chunk-DZK63TZJ.js";
421
423
  import {
422
424
  emptyWorkspaceSnapshot,
423
425
  probeGitStatusAsync,
424
426
  probeWorkspaceAsync
425
- } from "./chunk-HVDIIIQW.js";
427
+ } from "./chunk-DNHVRBH4.js";
426
428
  import {
427
429
  formatBootTrace,
428
430
  traceBoot
429
- } from "./chunk-ZTJUVLTU.js";
431
+ } from "./chunk-FXFVDPWY.js";
430
432
  import {
431
433
  source_default
432
- } from "./chunk-JCI2ROMZ.js";
434
+ } from "./chunk-3T4DXWP6.js";
433
435
  import {
434
436
  INTERACTIVE_LOOP_BLOCK_BUDGET,
435
437
  applyEditsToNormalizedContent,
@@ -450,10 +452,10 @@ import {
450
452
  resolveSessionTools,
451
453
  sanitizeLockedSynthesisMessage,
452
454
  stripBom
453
- } from "./chunk-36CT5VVL.js";
455
+ } from "./chunk-U2JOLB7O.js";
454
456
  import {
455
457
  resolveFdBinary
456
- } from "./chunk-BMS5RKQY.js";
458
+ } from "./chunk-JABWPKFY.js";
457
459
  import {
458
460
  MIDDLEWARE_HOOK_TEXT_MAX_CHARS,
459
461
  MiddlewareDomainModule,
@@ -475,20 +477,13 @@ import {
475
477
  openDetachedBatchViews,
476
478
  watchdogBriefing,
477
479
  writeMiddlewareDiagnosticToStderr
478
- } from "./chunk-XULDXHTN.js";
479
- import "./chunk-2CU2H6KE.js";
480
- import "./chunk-GX5WYQO4.js";
481
- import "./chunk-RXTN6AKH.js";
482
- import "./chunk-3UNOLWNZ.js";
483
- import "./chunk-5PSMVOLM.js";
484
- import {
485
- TaskMemoryBank,
486
- TaskMemoryEndpointBusyError,
487
- createTaskMemoryTelemetrySink
488
- } from "./chunk-2WZ546HR.js";
489
- import {
490
- escapeRegExp
491
- } from "./chunk-VG7TBQIY.js";
480
+ } from "./chunk-DRD2A54W.js";
481
+ import "./chunk-BBV5TKE6.js";
482
+ import "./chunk-GXCCHKN6.js";
483
+ import "./chunk-PWWSIB2A.js";
484
+ import "./chunk-KTFSFCVN.js";
485
+ import "./chunk-XCUDZQLX.js";
486
+ import "./chunk-K2BLQC5E.js";
492
487
  import {
493
488
  ASK_USER_OTHER_LABEL,
494
489
  COUNCIL_JUDGE_PROMPT,
@@ -500,6 +495,8 @@ import {
500
495
  JUDGE_GATE_PROMPT,
501
496
  RESOLVED_DISPATCH_PLAN_ARGUMENT,
502
497
  REVIEWER_GATE_PROMPT,
498
+ TaskMemoryBank,
499
+ TaskMemoryEndpointBusyError,
503
500
  approvedRouteCandidates,
504
501
  askAxis,
505
502
  askUserExposure,
@@ -508,10 +505,12 @@ import {
508
505
  classifyDecisionPresentation,
509
506
  classifyResourceRead,
510
507
  createRegistry,
508
+ createTaskMemoryTelemetrySink,
511
509
  decisionActionClass,
512
510
  decisionFactsForAnswer,
513
511
  decisionFactsForPermission,
514
512
  describeDispatchPlan,
513
+ dispatchPlanTopology,
515
514
  dispatchRequestsFromArgs,
516
515
  finalizeAskUserInterviewForHost,
517
516
  formatBudgetPolicy,
@@ -530,96 +529,110 @@ import {
530
529
  timeoutMsArg,
531
530
  toolPresentationPolicy,
532
531
  withResolvedDispatchPlan
533
- } from "./chunk-75W7L2E2.js";
532
+ } from "./chunk-TZ7MFRG4.js";
534
533
  import {
535
534
  DEFAULT_RECENT_ENTRY_LIMIT,
536
535
  assessFinishContract,
537
536
  recentEntries
538
- } from "./chunk-6QOTUPRG.js";
537
+ } from "./chunk-KF6GFW6O.js";
539
538
  import {
540
- defaultRoutingIntent,
541
- sameRouteIdentity
542
- } from "./chunk-AUPNRN7C.js";
539
+ defaultRoutingIntent
540
+ } from "./chunk-K2HL3GBL.js";
543
541
  import {
544
542
  createTaskBoardStore,
545
543
  foldSessionTaskHistory,
546
544
  foldTaskBoard,
547
545
  taskBoardCounts
548
- } from "./chunk-6PAZTBPA.js";
549
- import "./chunk-6Q3CYFD3.js";
546
+ } from "./chunk-7HBHHVCK.js";
550
547
  import {
551
548
  describeCallTarget,
552
- redactSecretString,
553
- redactToolArgs,
554
549
  sanitizeCallTargetText,
555
550
  sanitizeMultilineDisplayText
556
- } from "./chunk-NEDJ26B5.js";
551
+ } from "./chunk-2GPGAE5W.js";
552
+ import "./chunk-SL2RDHKO.js";
557
553
  import {
554
+ expandInlineFileReferencesAsync
555
+ } from "./chunk-YGDMBK7O.js";
556
+ import {
557
+ escapeRegExp,
558
558
  resolveToCwd
559
- } from "./chunk-OQE5J4C6.js";
559
+ } from "./chunk-V552WL53.js";
560
560
  import {
561
561
  sweepExpiredToolOffloads,
562
562
  toolResultPresentationPolicy,
563
563
  toolResultPresentationText
564
- } from "./chunk-NAI6ZFCY.js";
564
+ } from "./chunk-RLTT5GVY.js";
565
565
  import {
566
566
  formatSize
567
- } from "./chunk-OZNBF4L3.js";
567
+ } from "./chunk-KECNXMDE.js";
568
+ import "./chunk-4SVIVOMC.js";
569
+ import {
570
+ captureProjectSurface,
571
+ projectSurfaceTrustNotice
572
+ } from "./chunk-NTK3WTHM.js";
573
+ import "./chunk-WXA2CFJO.js";
568
574
  import {
569
575
  TOOL_PROFILE_NAMES
570
- } from "./chunk-QZWQA4DE.js";
576
+ } from "./chunk-CBSKDFWL.js";
571
577
  import {
572
578
  agentRoleFactsResolver,
573
579
  gateDeciderAgentId,
574
580
  requestExecutionRole,
575
581
  withAttemptRole
576
- } from "./chunk-H7IXIC72.js";
582
+ } from "./chunk-LY4N4TTL.js";
577
583
  import {
584
+ RESULT_SUMMARY_MAX_BYTES_CEILING,
578
585
  isUserVisibleAgent,
579
586
  parseJsonObjectPayload,
580
587
  parseScoutResult,
581
588
  parseVerifierResult,
582
589
  resultContractSourceId
583
- } from "./chunk-KFV5L5SK.js";
590
+ } from "./chunk-OQM5IVJY.js";
591
+ import "./chunk-LUL5Z66S.js";
584
592
  import {
585
593
  toolMutationPaths
586
- } from "./chunk-NXYCB2VD.js";
587
- import "./chunk-ECH6PKUQ.js";
594
+ } from "./chunk-M6TAYK66.js";
595
+ import {
596
+ canonicalizeExistingPath
597
+ } from "./chunk-KQ6IDQIB.js";
588
598
  import {
589
599
  narrowDispatchIntentToReadOnly,
590
600
  normalizeDispatchIntent
591
- } from "./chunk-IRXAATOX.js";
592
- import "./chunk-BJVFZO5U.js";
593
- import "./chunk-DXKJURES.js";
594
- import "./chunk-HHV2GANA.js";
595
- import "./chunk-GYV6VZOC.js";
601
+ } from "./chunk-L4N3DWNW.js";
602
+ import "./chunk-WJIMKGD6.js";
603
+ import "./chunk-MDU3C27C.js";
604
+ import "./chunk-R2P2U3ZS.js";
605
+ import "./chunk-NTTS3O53.js";
596
606
  import {
597
607
  VERIFICATION_SCRIPT_FAMILY_HINT
598
- } from "./chunk-UL3WSD3F.js";
608
+ } from "./chunk-M4KFUXS7.js";
599
609
  import {
600
610
  typebox_exports
601
- } from "./chunk-5B2AEOW5.js";
602
- import "./chunk-VAVR4IJY.js";
603
- import "./chunk-QSNYB6ZV.js";
604
- import "./chunk-4BJ5BYCE.js";
611
+ } from "./chunk-GH5ZR6JP.js";
612
+ import "./chunk-VQD7NH7Z.js";
613
+ import "./chunk-O3VV6IVK.js";
605
614
  import {
606
615
  DEFAULT_AUTONOMY_LEVEL,
616
+ SKILL_CONTEXT_STATE,
607
617
  SKILL_SUGGESTION_PREFIX,
608
618
  armedSkillSurface,
609
619
  isSessionEntry,
610
620
  isSkillActivation,
621
+ latestSkillContextState,
622
+ mainSkillContextState,
611
623
  modelMayActivateSkills,
612
624
  skillActivationFromToolDetails,
625
+ skillContextContentHash,
613
626
  skillSurfaceLabels,
614
627
  skillSurfaceNames,
628
+ verifiedSkillContextCheckpoint,
615
629
  withModelSkillActivation
616
- } from "./chunk-54X7T7DK.js";
617
- import "./chunk-I5FWO7L5.js";
618
- import "./chunk-6XLNIQDB.js";
630
+ } from "./chunk-5ZMXGW7P.js";
631
+ import "./chunk-B6UM3OZC.js";
632
+ import "./chunk-MYI32N4R.js";
619
633
  import {
620
634
  ToolNames
621
- } from "./chunk-4NSRCOYP.js";
622
- import "./chunk-QDC3K2U3.js";
635
+ } from "./chunk-EHOSNVVM.js";
623
636
  import {
624
637
  ProvidersDomainModule,
625
638
  applyModelCapabilityPatch,
@@ -653,8 +666,8 @@ import {
653
666
  thinkingLevelChoiceLabel,
654
667
  thinkingLevelFromChoiceLabel,
655
668
  withRunOverrides
656
- } from "./chunk-JSD46VO2.js";
657
- import "./chunk-CFGTUFWB.js";
669
+ } from "./chunk-TEG3RYVZ.js";
670
+ import "./chunk-MCJKEGHO.js";
658
671
  import {
659
672
  AutoCompactionTrigger,
660
673
  DEFAULT_COMPACTION_THRESHOLD,
@@ -674,11 +687,8 @@ import {
674
687
  reconcileSnapshot,
675
688
  shouldCompact,
676
689
  snapshotInputTokens
677
- } from "./chunk-NZMNUPZZ.js";
678
- import "./chunk-2JH2WHGE.js";
679
- import {
680
- interopAgentKind
681
- } from "./chunk-KXDSS5WJ.js";
690
+ } from "./chunk-77CZRFTE.js";
691
+ import "./chunk-J2FYEQ5L.js";
682
692
  import {
683
693
  SETTINGS_V1_PATH_MOVES,
684
694
  bindAgentProfileInSettings,
@@ -688,8 +698,11 @@ import {
688
698
  setFleetProfileInSettings,
689
699
  updateSettings,
690
700
  useTargetInSettings
691
- } from "./chunk-GHS5EBTQ.js";
692
- import "./chunk-D7E7WCDF.js";
701
+ } from "./chunk-FKIOX6DS.js";
702
+ import "./chunk-DVNAPPXU.js";
703
+ import {
704
+ interopAgentKind
705
+ } from "./chunk-5CY4Q6QI.js";
693
706
  import {
694
707
  atomicWrite,
695
708
  cwdHash,
@@ -697,88 +710,92 @@ import {
697
710
  readSessionTailTurns,
698
711
  sessionCurrentPath,
699
712
  sessionPaths
700
- } from "./chunk-HAXOFFRH.js";
701
- import "./chunk-R346GLFC.js";
702
- import "./chunk-BTK3SSSK.js";
713
+ } from "./chunk-FQOOGXBH.js";
714
+ import "./chunk-UHW5V7HC.js";
715
+ import "./chunk-KMF54VH3.js";
703
716
  import {
704
717
  combineBashOutput,
705
718
  runBashCommand
706
- } from "./chunk-W54I7H25.js";
719
+ } from "./chunk-5A6XR3RJ.js";
720
+ import {
721
+ redactSecretString,
722
+ redactToolArgs
723
+ } from "./chunk-EFSEIZE6.js";
707
724
  import {
708
725
  getSharedBus
709
- } from "./chunk-PMZVFWSR.js";
726
+ } from "./chunk-B5ZTR6KZ.js";
710
727
  import {
711
728
  BusChannels,
712
729
  isRunAbortedPayload
713
- } from "./chunk-F4EKGO4N.js";
730
+ } from "./chunk-HL26ADLH.js";
714
731
  import {
715
732
  incompleteInstallationAdvice
716
- } from "./chunk-65DEGPJ6.js";
717
- import "./chunk-BWH6N36D.js";
718
- import "./chunk-UUVG37B4.js";
733
+ } from "./chunk-3A3CUMKA.js";
734
+ import "./chunk-VHKTOLEW.js";
735
+ import "./chunk-KPRLAMP4.js";
719
736
  import {
720
737
  readCodewiki,
721
738
  readCodewikiAsync
722
- } from "./chunk-LBMZMYH2.js";
723
- import "./chunk-XAKHZX5N.js";
739
+ } from "./chunk-W2RJEH6Q.js";
740
+ import "./chunk-CVDAFGPW.js";
724
741
  import {
725
742
  enumerateWorkspaceFilesAsync
726
- } from "./chunk-33YXPOE3.js";
727
- import "./chunk-7CR24IG7.js";
743
+ } from "./chunk-PPEZJWUG.js";
744
+ import "./chunk-WDV62RKY.js";
728
745
  import {
729
746
  getVersionInfo
730
- } from "./chunk-XPLRXC72.js";
747
+ } from "./chunk-GD55RTIW.js";
731
748
  import {
732
749
  readClioVersion,
733
750
  readPiMonoVersion
734
- } from "./chunk-IWHMRKLL.js";
751
+ } from "./chunk-E3LEPLQ2.js";
735
752
  import {
736
753
  VALID_THINKING_LEVELS,
737
754
  formatContextWindowSlots,
738
755
  registerBuiltinRuntimes
739
- } from "./chunk-6OSVSQL5.js";
756
+ } from "./chunk-ICO4TQ2F.js";
740
757
  import {
741
758
  ACTIVE_ROUTING_POSTURES,
742
759
  ACTIVE_ROUTING_ROLES,
743
760
  DEFAULT_DELEGATION_PERMISSION_TIMEOUT_MS,
744
761
  DEFAULT_SETTINGS,
745
762
  THINKING_LEVELS
746
- } from "./chunk-UXCU4E3T.js";
747
- import "./chunk-LL4KHSZI.js";
763
+ } from "./chunk-SE4ZKILO.js";
764
+ import "./chunk-U2MSJ57E.js";
748
765
  import {
749
766
  configureGuardrails,
750
767
  guardrailValuesFromSettings
751
- } from "./chunk-S66XZJOF.js";
752
- import "./chunk-TOIVGRUX.js";
768
+ } from "./chunk-C27U2TYG.js";
769
+ import "./chunk-GJ24ODAX.js";
753
770
  import {
754
771
  setCommitDecisionRefsProvider,
755
772
  setGitCommitAttributionEnabled
756
- } from "./chunk-U6TMQNSI.js";
773
+ } from "./chunk-LTR5QCLS.js";
757
774
  import {
758
775
  MAX_TIMER_DELAY_MS,
759
776
  rawDurationMs
760
- } from "./chunk-EBY63B7G.js";
761
- import "./chunk-6EJMN2Y3.js";
777
+ } from "./chunk-6EXUUOSN.js";
778
+ import "./chunk-ZTNFYMIO.js";
762
779
  import {
763
780
  resolveProviderReference
764
- } from "./chunk-26QSH3EJ.js";
781
+ } from "./chunk-HHVJNVUJ.js";
765
782
  import {
766
783
  targetRequiresAuth
767
- } from "./chunk-ID64D7PE.js";
768
- import "./chunk-336NSSKI.js";
769
- import "./chunk-IKCO5N3L.js";
770
- import "./chunk-3I7MS7N2.js";
771
- import "./chunk-APJ265NV.js";
784
+ } from "./chunk-HXHFDHB6.js";
785
+ import "./chunk-VNBICSS2.js";
786
+ import "./chunk-2QPI3TR3.js";
787
+ import "./chunk-TK2BMCBZ.js";
788
+ import "./chunk-B5GGDIHT.js";
772
789
  import {
773
790
  safeResourceWrite
774
- } from "./chunk-WEPFGWHJ.js";
791
+ } from "./chunk-ZZFWWYLX.js";
775
792
  import {
776
793
  getRuntimeRegistry
777
- } from "./chunk-NUGM5KR6.js";
794
+ } from "./chunk-SRCEQKQS.js";
778
795
  import {
779
796
  AGENT_ROLE_TOOLS_REQUIRED_REASON,
780
797
  supportsAgentRoleTools
781
- } from "./chunk-5OIVVPHF.js";
798
+ } from "./chunk-TN5FW4XY.js";
782
799
  import {
783
800
  StringEnum,
784
801
  cleanupEngineSessionResources,
@@ -786,24 +803,24 @@ import {
786
803
  isEngineRetryableAssistantError,
787
804
  stream,
788
805
  streamSimple
789
- } from "./chunk-YPC6ZR5L.js";
790
- import "./chunk-YXLYO42X.js";
791
- import "./chunk-2LEAKD4C.js";
806
+ } from "./chunk-5CMARGPF.js";
807
+ import "./chunk-DXVMLM3Z.js";
808
+ import "./chunk-CKK25WN3.js";
792
809
  import {
793
810
  clioConfigDir,
794
811
  clioDataDir,
795
812
  clioStateDir,
796
813
  stateRootRemoved
797
- } from "./chunk-BYP5D4HI.js";
814
+ } from "./chunk-CTTI7G3T.js";
798
815
  import {
799
816
  init_esm_shims
800
- } from "./chunk-3R73A4XB.js";
817
+ } from "./chunk-ECBHH7LU.js";
801
818
 
802
819
  // src/entry/orchestrator.ts
803
820
  init_esm_shims();
804
821
  import { randomUUID as randomUUID3 } from "node:crypto";
805
- import { readFileSync as readFileSync9 } from "node:fs";
806
- import { join as join11 } from "node:path";
822
+ import { readFileSync as readFileSync8 } from "node:fs";
823
+ import { join as join10 } from "node:path";
807
824
 
808
825
  // src/cli/modes/print.ts
809
826
  init_esm_shims();
@@ -855,6 +872,7 @@ function resultFromEvent(event, current) {
855
872
  if (event.type !== "message_end") return current;
856
873
  const message = event.message;
857
874
  if (message?.role !== "assistant") return current;
875
+ current = { ...current, outputExhausted: message.stopReason === "length", sawTerminatingToolResult: false };
858
876
  const error = assistantError(message);
859
877
  if (error) return { ...current, text: "", error };
860
878
  const text = assistantText(message).trimEnd();
@@ -875,8 +893,14 @@ function recordToolEnd(stats, event) {
875
893
  stat3.count += 1;
876
894
  const durationMs = durationMsFromEvent(event);
877
895
  if (durationMs !== void 0) stat3.totalDurationMs += durationMs;
878
- if (event.isError) stat3.errors += 1;
879
- else stat3.ok += 1;
896
+ const outcome = event.outcome;
897
+ if (outcome === "blocked") stat3.blocked += 1;
898
+ else if (outcome === "error") stat3.errors += 1;
899
+ else if (outcome === "ok") stat3.ok += 1;
900
+ else if (outcome === void 0) {
901
+ if (event.isError) stat3.errors += 1;
902
+ else stat3.ok += 1;
903
+ }
880
904
  stats.toolStats.set(tool, stat3);
881
905
  if (tool === ToolNames.Context) {
882
906
  const rawTurnId = event.turnId;
@@ -943,6 +967,7 @@ async function recordHeadlessMainAgentReceipt(input) {
943
967
  const outcomeDetail = input.terminal.failureMessage;
944
968
  const ledger = openLedger();
945
969
  const envelope = ledger.create({
970
+ id: input.runId,
946
971
  agentId: "main-agent",
947
972
  executionRole: "builder",
948
973
  requestOrigin: "user",
@@ -1046,10 +1071,12 @@ function defaultShutdownHooks() {
1046
1071
  };
1047
1072
  }
1048
1073
  async function runHeadlessMainAgent(chat, options) {
1074
+ const runId = newRunId();
1049
1075
  const mode = options.mode ?? "text";
1050
1076
  const jsonEvents = options.jsonEvents ?? "full";
1051
1077
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
1052
1078
  let result = {
1079
+ outputExhausted: false,
1053
1080
  text: "",
1054
1081
  error: null,
1055
1082
  sawTerminatingToolResult: false,
@@ -1067,6 +1094,7 @@ async function runHeadlessMainAgent(chat, options) {
1067
1094
  if (sealed !== null) return sealed;
1068
1095
  const endedAt2 = (/* @__PURE__ */ new Date()).toISOString();
1069
1096
  sealed = recordHeadlessMainAgentReceipt({
1097
+ runId,
1070
1098
  chat,
1071
1099
  task: options.prompt,
1072
1100
  startedAt,
@@ -1155,6 +1183,7 @@ async function runHeadlessMainAgent(chat, options) {
1155
1183
  try {
1156
1184
  if (mode === "json" && jsonEvents === "terminal") writeTerminalTurnStart();
1157
1185
  const submitOptions = {
1186
+ hostRun: { runId, lineage: { parentRunId: null, rootRunId: runId, depth: 0, attempt: 0 } },
1158
1187
  ...options.images && options.images.length > 0 ? { images: options.images } : {},
1159
1188
  ...options.workingContextPaths && options.workingContextPaths.length > 0 ? { workingContextPaths: options.workingContextPaths } : {},
1160
1189
  ...options.pendingSkillRequests && options.pendingSkillRequests.length > 0 ? { pendingSkillRequests: options.pendingSkillRequests } : {}
@@ -1189,6 +1218,11 @@ async function runHeadlessMainAgent(chat, options) {
1189
1218
  } else if (result.error) {
1190
1219
  terminal = { exitCode: 1, outcome: "failed", status: "failed", failureMessage: result.error };
1191
1220
  stderrMessage = prefixHeadlessFailure(chat, result.error);
1221
+ } else if (result.outputExhausted && !result.sawTerminatingToolResult) {
1222
+ const failureMessage = "clio-coder run: output token limit reached (stopReason=length); generation incomplete. Consider resuming with a narrower task, lower reasoning effort, or a larger output budget.";
1223
+ terminal = { exitCode: 1, outcome: "failed", status: "failed", failureMessage };
1224
+ stderrMessage = failureMessage;
1225
+ if (mode === "text" && result.text.length > 0) stdoutMessage = result.text;
1192
1226
  } else if (result.text.length === 0 && !result.sawTerminatingToolResult) {
1193
1227
  const failureMessage = result.lastNotice !== null ? `clio-coder run: no assistant response (${result.lastNotice})` : "clio-coder run: no assistant response";
1194
1228
  terminal = { exitCode: 1, outcome: "failed", status: "failed", failureMessage };
@@ -1213,7 +1247,8 @@ async function runHeadlessMainAgent(chat, options) {
1213
1247
  if (stderrMessage !== null) {
1214
1248
  process.stderr.write(`${stderrMessage}
1215
1249
  `);
1216
- } else if (stdoutMessage !== null) {
1250
+ }
1251
+ if (stdoutMessage !== null) {
1217
1252
  writeRawStdout(`${stdoutMessage}
1218
1253
  `);
1219
1254
  }
@@ -1870,6 +1905,41 @@ In addition to that carried-forward context, summarize ONLY the active-turn deta
1870
1905
  - what should happen next
1871
1906
 
1872
1907
  Do NOT answer the user. Do NOT summarize unrelated older history.`;
1908
+ function validateHistorySummary(text) {
1909
+ const required = [
1910
+ "## Goal",
1911
+ "## Constraints & Preferences",
1912
+ "## Progress",
1913
+ "### Done",
1914
+ "### In Progress",
1915
+ "### Blocked",
1916
+ "## Key Decisions",
1917
+ "## Next Steps",
1918
+ "## Critical Context"
1919
+ ];
1920
+ const headings = [];
1921
+ let fence;
1922
+ for (const line of text.split(/\r?\n/)) {
1923
+ const fenceMatch = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
1924
+ if (fenceMatch) {
1925
+ const marker = fenceMatch[1] ?? "";
1926
+ if (!fence) fence = { character: marker[0] ?? "", length: marker.length };
1927
+ else if (marker[0] === fence.character && marker.length >= fence.length && !fenceMatch[2]?.trim()) fence = void 0;
1928
+ continue;
1929
+ }
1930
+ if (fence) continue;
1931
+ const heading = /^ {0,3}(#{2,3})[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$/.exec(line);
1932
+ if (heading) {
1933
+ const normalized = `${heading[1]} ${heading[2]}`;
1934
+ if (required.includes(normalized)) headings.push(normalized);
1935
+ }
1936
+ }
1937
+ if (fence || headings.length !== required.length || headings.some((heading, index) => heading !== required[index])) {
1938
+ throw new Error(
1939
+ "compaction returned an incomplete history checkpoint: required headings must appear in order outside code fences; checkpoint was not saved"
1940
+ );
1941
+ }
1942
+ }
1873
1943
  function buildUserMessage(text) {
1874
1944
  return {
1875
1945
  role: "user",
@@ -1901,6 +1971,90 @@ function findTurnStartForProtection(entries, entryIndex, startIndex) {
1901
1971
  }
1902
1972
  return -1;
1903
1973
  }
1974
+ function captureSkillContext(entries, selection) {
1975
+ if (!selection || selection.unknown) return void 0;
1976
+ const newestSelected = Math.max(
1977
+ -1,
1978
+ ...selection.activationRefs.map((ref) => entries.findIndex((entry) => entry.turnId === ref))
1979
+ );
1980
+ if (selection.activationRefs.length > 0 && entries.slice(newestSelected + 1).some((entry) => entry.kind === "skillActivation" && entry.activation.runId === void 0))
1981
+ return void 0;
1982
+ const skills = [];
1983
+ for (const ref of selection.activationRefs) {
1984
+ const matches = entries.filter((entry2) => entry2.turnId === ref);
1985
+ const entry = matches[0];
1986
+ if (matches.length !== 1 || entry?.kind !== "skillActivation") return void 0;
1987
+ const activation = entry.activation;
1988
+ if (activation.runId !== void 0 || activation.triggeredBy !== "tool" || !activation.turnId || activation.drift === "mismatch")
1989
+ return void 0;
1990
+ if (entries.slice(entries.indexOf(entry) + 1).some(
1991
+ (later) => later.kind === "skillActivation" && later.activation.runId === void 0 && later.activation.name === activation.name
1992
+ ))
1993
+ return void 0;
1994
+ const request = entries.find((candidate) => candidate.turnId === activation.turnId);
1995
+ if (request?.kind !== "message" || request.role !== "user") return void 0;
1996
+ const start = entries.indexOf(request);
1997
+ const next = entries.findIndex(
1998
+ (candidate, index) => index > start && candidate.kind === "message" && candidate.role === "user"
1999
+ );
2000
+ const turn = entries.slice(start, next < 0 ? void 0 : next);
2001
+ if (!turn.includes(entry)) return void 0;
2002
+ const calls = turn.filter((candidate) => {
2003
+ if (candidate.kind !== "message" || candidate.role !== "tool_call") return false;
2004
+ const payload2 = payloadObject2(candidate.payload);
2005
+ const args = payloadObject2(payload2?.args);
2006
+ return payload2?.name === "context" && args?.scope === "skills" && args.name === activation.name;
2007
+ });
2008
+ if (calls.length !== 1) return void 0;
2009
+ const call = calls[0];
2010
+ if (call?.kind !== "message") return void 0;
2011
+ const callId = payloadObject2(call.payload)?.toolCallId;
2012
+ if (typeof callId !== "string" || !callId) return void 0;
2013
+ const assistant = turn.find((candidate) => candidate.turnId === call.parentTurnId);
2014
+ if (assistant?.kind !== "message" || assistant.role !== "assistant" || !contentBlocks2(assistant.payload).some(
2015
+ (block) => block.type === "toolCall" && block.id === callId && block.name === "context" && JSON.stringify(block.arguments) === JSON.stringify(payloadObject2(call.payload)?.args)
2016
+ ))
2017
+ return void 0;
2018
+ const results = entries.filter(
2019
+ (candidate) => candidate.kind === "message" && candidate.role === "tool_result" && payloadObject2(candidate.payload)?.toolCallId === callId
2020
+ );
2021
+ const resultEntry = results[0];
2022
+ if (results.length !== 1 || resultEntry?.kind !== "message" || !turn.includes(resultEntry) || resultEntry.parentTurnId !== call.turnId || entry.parentTurnId !== request.turnId)
2023
+ return void 0;
2024
+ const payload = payloadObject2(resultEntry.payload);
2025
+ const result = payloadObject2(payload?.result);
2026
+ const details = payloadObject2(result?.details);
2027
+ const observation = payloadObject2(details?.observation);
2028
+ const resultSummary = payloadObject2(payload?.resultSummary);
2029
+ const summaryObservation = payloadObject2(resultSummary?.observation);
2030
+ const sourceInfo = payloadObject2(details?.sourceInfo);
2031
+ if (payload?.toolName !== "context" || payload.isError !== false || payload.outcome !== "ok" || details?.kind !== "ok" || observation?.truncated !== false || details.workingSet !== void 0 || details.contextCompaction !== void 0 || resultSummary?.truncated !== false || summaryObservation?.truncated === true || details.name !== activation.name || details.path !== activation.filePath || details.hash !== activation.hash || details.source !== activation.source || details.sourceOrigin !== activation.sourceOrigin || sourceInfo?.path !== activation.filePath || sourceInfo.scope !== details.scope || sourceInfo.source !== activation.sourceOrigin || details.drift !== void 0 && details.drift !== "match" || details.drift !== activation.drift || !Array.isArray(result?.content) || !result.content.every((block) => {
2032
+ const obj = payloadObject2(block);
2033
+ return obj?.type === "text" && typeof obj.text === "string";
2034
+ }))
2035
+ return void 0;
2036
+ const content = result.content;
2037
+ const text = content.map((block) => block.text).join("\n");
2038
+ if (observation.shownBytes !== Buffer.byteLength(text, "utf8") || observation.totalBytes !== observation.shownBytes || resultSummary?.bytes !== observation.shownBytes)
2039
+ return void 0;
2040
+ const requestPayload = payloadObject2(request.payload);
2041
+ const operatorText = requestPayload?.operatorText;
2042
+ const requestText = typeof operatorText === "string" && operatorText.trim().length > 0 ? operatorText : requestPayload?.text;
2043
+ if (typeof requestText !== "string") return void 0;
2044
+ skills.push({
2045
+ activationRef: ref,
2046
+ requestRef: request.turnId,
2047
+ callRef: call.turnId,
2048
+ resultRef: resultEntry.turnId,
2049
+ activation: structuredClone(activation),
2050
+ requestText,
2051
+ content: structuredClone(content),
2052
+ contentHash: skillContextContentHash(content)
2053
+ });
2054
+ }
2055
+ const checkpoint = { version: 1, skills };
2056
+ return verifiedSkillContextCheckpoint(checkpoint) ? checkpoint : void 0;
2057
+ }
1904
2058
  function buildPreviousContextPrefix(previousContextText) {
1905
2059
  const trimmed = previousContextText.trim();
1906
2060
  return trimmed.length > 0 ? `<previous-context>
@@ -2027,20 +2181,23 @@ ${modified.join("\n")}
2027
2181
 
2028
2182
  ${sections.join("\n\n")}` : "";
2029
2183
  }
2030
- function formatRecallableRefs(entries, firstKeptEntryIndex) {
2184
+ function formatRecallableRefs(entries, firstKeptEntryIndex, view) {
2031
2185
  const entryIndexes = /* @__PURE__ */ new Map();
2032
2186
  for (let index = 0; index < entries.length; index += 1) {
2033
2187
  const entry = entries[index];
2034
2188
  if (entry) entryIndexes.set(entry.turnId, index);
2035
2189
  }
2036
- const view = foldWorkingSet(entries);
2037
2190
  const evictedBeforeCut = new Map(
2038
2191
  [...view.evicted].filter(([ref]) => (entryIndexes.get(ref) ?? Number.POSITIVE_INFINITY) < firstKeptEntryIndex)
2039
2192
  );
2040
2193
  const listing = recallableRefListing(entries, { ...view, evicted: evictedBeforeCut });
2041
- if (listing.refs.length === 0) return "";
2194
+ if (listing.refs.length === 0 && !entries.slice(0, firstKeptEntryIndex).some((entry) => entry.kind === "message" && entry.role === "tool_result"))
2195
+ return "";
2042
2196
  const rows = [...listing.refs];
2043
2197
  if (listing.remaining > 0) rows.push(`and ${listing.remaining} more`);
2198
+ rows.push(
2199
+ 'Preview only. Persisted original tool results removed by this summary are also recallable. Discover all active-path results with context(scope="recall", limit=8, offset=0), omitting ref; query filters path/tool/ref terms. Follow nextOffset, then recall the selected ref.'
2200
+ );
2044
2201
  return `
2045
2202
 
2046
2203
  <recallable-refs>
@@ -2105,12 +2262,31 @@ async function runSummaryStream(input, userText, systemPrompt, maxTokens) {
2105
2262
  systemPrompt,
2106
2263
  messages: [buildUserMessage(userText)]
2107
2264
  };
2265
+ const estimatedInput = estimateAgentContextTokens(context);
2266
+ const contextWindow = input.model.contextWindow;
2267
+ if (!Number.isFinite(contextWindow) || contextWindow <= 0) {
2268
+ throw new Error("compaction requires a positive finite model context window");
2269
+ }
2270
+ if (estimatedInput + maxTokens > contextWindow) {
2271
+ throw new Error(
2272
+ `compaction estimated input ${estimatedInput} tokens plus output ${maxTokens} tokens exceeds model context window ${contextWindow}; use a larger compaction model or reduce the working set`
2273
+ );
2274
+ }
2275
+ input.signal?.throwIfAborted();
2108
2276
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2109
2277
  const started = performance.now();
2110
2278
  let usage;
2111
2279
  let reported = {};
2112
2280
  let outcome = "error";
2113
2281
  try {
2282
+ if (input.summarize) {
2283
+ const response = await input.summarize({ systemPrompt, userText, maxTokens });
2284
+ usage = response.usage;
2285
+ reported = retainReportedUsage(reported, usage);
2286
+ input.signal?.throwIfAborted();
2287
+ outcome = "success";
2288
+ return { text: response.text.trim(), usage };
2289
+ }
2114
2290
  const events = streamSimple(
2115
2291
  input.model,
2116
2292
  context,
@@ -2123,6 +2299,11 @@ async function runSummaryStream(input, userText, systemPrompt, maxTokens) {
2123
2299
  }
2124
2300
  if (event.type === "done") {
2125
2301
  usage = event.message.usage ?? usage;
2302
+ reported = retainReportedUsage(reported, usage);
2303
+ input.signal?.throwIfAborted();
2304
+ if (event.reason === "length" || event.message.stopReason === "length") {
2305
+ throw new Error("compaction summary reached the model output limit; incomplete checkpoint was not saved");
2306
+ }
2126
2307
  outcome = "success";
2127
2308
  return { text: textFromAssistant(event.message).trim(), usage };
2128
2309
  }
@@ -2146,23 +2327,57 @@ async function runSummaryStream(input, userText, systemPrompt, maxTokens) {
2146
2327
  async function compact(input) {
2147
2328
  const reserveTokens = input.reserveTokens ?? DEFAULT_RESERVE_TOKENS;
2148
2329
  const keepRecentTokens = input.keepRecentTokens ?? DEFAULT_KEEP_RECENT_TOKENS;
2149
- const prevCompactionIndex = findLatestCompactionIndex(input.entries);
2330
+ const workingSet = foldWorkingSet(input.entries);
2331
+ const entries = projectWorkingSet(input.entries, workingSet);
2332
+ const prevCompactionIndex = findLatestCompactionIndex(entries);
2150
2333
  const boundaryStart = prevCompactionIndex + 1;
2151
- const protectedStart = findLatestSkillActivationProtectionStart(input.entries, boundaryStart);
2334
+ const selection = input.skillContextState === null ? void 0 : input.skillContextState ?? latestSkillContextState(input.entries);
2335
+ let skillContext = captureSkillContext(input.entries, selection);
2336
+ const priorCheckpoint = entries[prevCompactionIndex];
2337
+ const priorSkillContext = priorCheckpoint?.kind === "compactionSummary" && priorCheckpoint.skillContext !== void 0 && priorCheckpoint.skillContext.skills.length > 0 ? priorCheckpoint.skillContext : void 0;
2338
+ if (priorSkillContext !== void 0 && !skillContext) {
2339
+ throw new Error("cannot verify preserved skill context; retaining the existing checkpoint");
2340
+ }
2341
+ if (priorSkillContext !== void 0) {
2342
+ if (!verifiedSkillContextCheckpoint(priorSkillContext)) throw new Error("invalid preserved skill checkpoint");
2343
+ for (const previous of priorSkillContext.skills) {
2344
+ const current = skillContext?.skills.find((skill) => skill.activationRef === previous.activationRef);
2345
+ if (current && JSON.stringify(current) !== JSON.stringify(previous)) {
2346
+ throw new Error("preserved skill context no longer matches its captured receipt");
2347
+ }
2348
+ }
2349
+ }
2350
+ if (skillContext && priorSkillContext !== void 0) {
2351
+ skillContext = {
2352
+ version: 1,
2353
+ skills: skillContext.skills.map(
2354
+ (skill) => structuredClone(
2355
+ priorSkillContext.skills.find((previous) => previous.activationRef === skill.activationRef) ?? skill
2356
+ )
2357
+ )
2358
+ };
2359
+ }
2360
+ const legacyPriorCheckpoint = priorCheckpoint?.kind === "compactionSummary" && priorCheckpoint.skillContext === void 0;
2361
+ const protectedStart = skillContext ? null : findLatestSkillActivationProtectionStart(entries, legacyPriorCheckpoint ? 0 : boundaryStart);
2152
2362
  const usageStart = prevCompactionIndex >= 0 ? prevCompactionIndex : 0;
2153
- const usageEntries = input.entries.slice(usageStart);
2363
+ const usageEntries = entries.slice(usageStart);
2154
2364
  const lastUsage = getLastAssistantUsage(usageEntries);
2155
2365
  const tokensBefore = calculateContextTokens(usageEntries, lastUsage);
2156
- const rawCut = findCutPoint(input.entries, keepRecentTokens, { startIndex: boundaryStart });
2366
+ const rawCut = findCutPoint(entries, keepRecentTokens, { startIndex: boundaryStart });
2157
2367
  const cut = protectedStart !== null && rawCut.firstKeptEntryIndex > protectedStart ? { firstKeptEntryIndex: protectedStart, turnStartIndex: -1, isSplitTurn: false } : rawCut;
2158
2368
  const historyEnd = cut.isSplitTurn ? cut.turnStartIndex : cut.firstKeptEntryIndex;
2159
- const pre = input.entries.slice(boundaryStart, Math.max(boundaryStart, historyEnd));
2160
- const turnPrefix = cut.isSplitTurn ? input.entries.slice(Math.max(boundaryStart, cut.turnStartIndex), cut.firstKeptEntryIndex) : [];
2161
- const previousContextEntries = priorCompactionContextEntries(input.entries, prevCompactionIndex);
2369
+ const pre = entries.slice(boundaryStart, Math.max(boundaryStart, historyEnd));
2370
+ const turnPrefix = cut.isSplitTurn ? entries.slice(Math.max(boundaryStart, cut.turnStartIndex), cut.firstKeptEntryIndex) : [];
2371
+ const previousContextEntries = priorCompactionContextEntries(entries, prevCompactionIndex);
2162
2372
  const previousContextText = serializeConversation(previousContextEntries);
2163
- const fileOps = extractFileOps([...previousContextEntries, ...pre, ...turnPrefix]);
2373
+ const fileOps = extractFileOps([
2374
+ ...priorCompactionContextEntries(input.entries, prevCompactionIndex),
2375
+ ...input.entries.slice(boundaryStart, cut.firstKeptEntryIndex)
2376
+ ]);
2164
2377
  const firstKept = input.entries[cut.firstKeptEntryIndex] ?? null;
2165
- if (pre.length === 0 && turnPrefix.length === 0) {
2378
+ const priorSuffix = previousContextEntries.slice(1);
2379
+ const summarizePriorSuffix = pre.length === 0 && turnPrefix.length === 0 && firstKept !== null && cut.firstKeptEntryIndex >= boundaryStart && priorSuffix.some((entry) => entry.kind === "message" || entry.kind === "bashExecution");
2380
+ if (pre.length === 0 && turnPrefix.length === 0 && !summarizePriorSuffix) {
2166
2381
  return {
2167
2382
  summary: "",
2168
2383
  firstKeptEntryIndex: cut.firstKeptEntryIndex,
@@ -2173,15 +2388,23 @@ async function compact(input) {
2173
2388
  };
2174
2389
  }
2175
2390
  const systemPrompt = input.systemPrompt ?? COMPACTION_SYSTEM_PROMPT;
2176
- const maxTokens = Math.max(1024, Math.floor(reserveTokens * 0.8));
2391
+ if (!Number.isFinite(reserveTokens) || reserveTokens <= 0) {
2392
+ throw new Error("compaction requires a positive finite reserve token budget");
2393
+ }
2394
+ if (!Number.isFinite(input.model.maxTokens) || input.model.maxTokens < 1) {
2395
+ throw new Error("compaction requires a positive finite model output token limit");
2396
+ }
2397
+ const maxTokens = Math.min(Math.floor(input.model.maxTokens), Math.max(1024, Math.floor(reserveTokens * 0.8)));
2177
2398
  const summaryParts = [];
2178
2399
  let usage;
2179
- if (pre.length > 0) {
2180
- const conversationText = serializeConversation(pre);
2181
- const userText = buildUserText(conversationText, input.instructions, previousContextText);
2400
+ if (pre.length > 0 || summarizePriorSuffix) {
2401
+ const conversationText = serializeConversation(summarizePriorSuffix ? priorSuffix : pre);
2402
+ const previousText = summarizePriorSuffix ? serializeConversation(previousContextEntries.slice(0, 1)) : previousContextText;
2403
+ const userText = buildUserText(conversationText, input.instructions, previousText);
2182
2404
  const historySummary = await runSummaryStream(input, userText, systemPrompt, maxTokens);
2183
2405
  usage = addCompactionUsage(usage, historySummary.usage);
2184
2406
  if (historySummary.text.length === 0) throw new Error("compaction returned an empty history summary");
2407
+ validateHistorySummary(historySummary.text);
2185
2408
  summaryParts.push(historySummary.text);
2186
2409
  }
2187
2410
  if (turnPrefix.length > 0) {
@@ -2194,18 +2417,37 @@ async function compact(input) {
2194
2417
 
2195
2418
  ${prefixSummary.text}`);
2196
2419
  }
2420
+ let userContext = priorCheckpoint?.kind === "compactionSummary" ? priorCheckpoint.userContext : void 0;
2421
+ let activeUserIndex = -1;
2422
+ for (let index = entries.length - 1; index >= 0; index--) {
2423
+ const entry = entries[index];
2424
+ if (entry?.kind === "message" && entry.role === "user" && (input.preserveUserTurnId === void 0 || entry.turnId === input.preserveUserTurnId)) {
2425
+ activeUserIndex = index;
2426
+ break;
2427
+ }
2428
+ }
2429
+ const activeUser = activeUserIndex >= 0 && activeUserIndex < cut.firstKeptEntryIndex ? entries[activeUserIndex] : void 0;
2430
+ if (activeUser?.kind === "message" && activeUser.payload && typeof activeUser.payload === "object") {
2431
+ const payload = activeUser.payload;
2432
+ const operatorText = "operatorText" in payload ? payload.operatorText : void 0;
2433
+ const text = typeof operatorText === "string" && operatorText.trim().length > 0 ? operatorText : "text" in payload && typeof payload.text === "string" ? payload.text : null;
2434
+ if (text !== null) userContext = { turnId: activeUser.turnId, text };
2435
+ }
2197
2436
  const summary = `${summaryParts.join("\n\n---\n\n").trim()}${formatFileOperations(fileOps)}${formatRecallableRefs(
2198
2437
  input.entries,
2199
- cut.firstKeptEntryIndex
2438
+ cut.firstKeptEntryIndex,
2439
+ workingSet
2200
2440
  )}`.trim();
2201
2441
  return {
2202
2442
  summary,
2203
2443
  firstKeptEntryIndex: cut.firstKeptEntryIndex,
2204
2444
  firstKeptTurnId: firstKept?.turnId ?? null,
2205
2445
  tokensBefore,
2206
- messagesSummarized: pre.length + turnPrefix.length,
2446
+ messagesSummarized: pre.length + turnPrefix.length + (summarizePriorSuffix ? priorSuffix.length : 0),
2207
2447
  isSplitTurn: cut.isSplitTurn,
2208
- ...usage !== void 0 ? { usage } : {}
2448
+ ...usage !== void 0 ? { usage } : {},
2449
+ ...skillContext !== void 0 ? { skillContext } : {},
2450
+ ...userContext !== void 0 ? { userContext } : {}
2209
2451
  };
2210
2452
  }
2211
2453
  function textFromAssistant(message) {
@@ -2445,6 +2687,7 @@ var ACP_ADMISSION_REASONS = /* @__PURE__ */ new Set([
2445
2687
  "model-not-configured",
2446
2688
  "chat-unsupported",
2447
2689
  "streaming-unsupported",
2690
+ "context-window-exceeded",
2448
2691
  "admission-failed"
2449
2692
  ]);
2450
2693
  var ACP_ADMISSION_FALLBACK_REASON = "admission-failed";
@@ -4192,7 +4435,7 @@ async function serveClioAcpAgent(options) {
4192
4435
  }
4193
4436
  return promptResponse(active.stopReason, active);
4194
4437
  });
4195
- return await new Promise((resolve9) => {
4438
+ return await new Promise((resolve10) => {
4196
4439
  options.transport.onClose(() => {
4197
4440
  permission.unregister();
4198
4441
  unsubscribeEventStream();
@@ -4200,14 +4443,14 @@ async function serveClioAcpAgent(options) {
4200
4443
  for (const session of sessions.values()) cancelSession(session, "ACP transport closed");
4201
4444
  const inFlight = promptSettled;
4202
4445
  if (inFlight === null) {
4203
- resolve9(0);
4446
+ resolve10(0);
4204
4447
  return;
4205
4448
  }
4206
- const timer = setTimeout(() => resolve9(0), ACP_PROMPT_SETTLE_BOUND_MS);
4449
+ const timer = setTimeout(() => resolve10(0), ACP_PROMPT_SETTLE_BOUND_MS);
4207
4450
  timer.unref?.();
4208
4451
  void inFlight.then(() => {
4209
4452
  clearTimeout(timer);
4210
- resolve9(0);
4453
+ resolve10(0);
4211
4454
  });
4212
4455
  });
4213
4456
  });
@@ -4231,6 +4474,7 @@ function promptResponse(stopReason, active) {
4231
4474
 
4232
4475
  // src/interactive/chat-loop.ts
4233
4476
  init_esm_shims();
4477
+ import { AsyncLocalStorage } from "node:async_hooks";
4234
4478
 
4235
4479
  // src/domains/session/retry.ts
4236
4480
  init_esm_shims();
@@ -4840,6 +5084,7 @@ Extract the handoff record for that goal now.`
4840
5084
 
4841
5085
  // src/interactive/turn-context.ts
4842
5086
  init_esm_shims();
5087
+ import { createHash as createHash3 } from "node:crypto";
4843
5088
 
4844
5089
  // src/domains/session/compaction/mask-observations.ts
4845
5090
  init_esm_shims();
@@ -5035,105 +5280,12 @@ function maskStaleObservations(entries, excludeLastTurns) {
5035
5280
  };
5036
5281
  }
5037
5282
 
5038
- // src/domains/session/prompt-manifest.ts
5039
- init_esm_shims();
5040
- import { appendFileSync, existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
5041
- import { dirname, join as join3 } from "node:path";
5042
- var PROMPT_MANIFEST_VERSION = 2;
5043
- var SHA256_HEX = /^[a-f0-9]{64}$/;
5044
- function isCanonicalUtcTimestamp(value) {
5045
- if (typeof value !== "string") return false;
5046
- const timestamp = Date.parse(value);
5047
- return Number.isFinite(timestamp) && new Date(timestamp).toISOString() === value;
5048
- }
5049
- function isRecord5(value) {
5050
- return value !== null && typeof value === "object" && !Array.isArray(value);
5051
- }
5052
- function isNonNegativeInteger(value) {
5053
- return typeof value === "number" && Number.isInteger(value) && value >= 0;
5054
- }
5055
- function isSha256(value) {
5056
- return typeof value === "string" && SHA256_HEX.test(value);
5057
- }
5058
- function isPromptManifestSection(value) {
5059
- return isRecord5(value) && typeof value.id === "string" && isNonNegativeInteger(value.tokenEstimate);
5060
- }
5061
- function isPromptManifestFragment(value) {
5062
- return isRecord5(value) && typeof value.id === "string" && typeof value.relPath === "string" && isSha256(value.contentHash) && typeof value.dynamic === "boolean";
5063
- }
5064
- function isProjectPreloadClass(value) {
5065
- if (!isRecord5(value)) return false;
5066
- return (value.mode === "full" || value.mode === "synopsis" || value.mode === "none") && isNonNegativeInteger(value.chars) && isNonNegativeInteger(value.lines) && (value.reason === null || value.reason === "size" || value.reason === "lines" || value.reason === "no-clio-md") && typeof value.nearLimit === "boolean" && typeof value.label === "string";
5067
- }
5068
- function isOptional(value, guard) {
5069
- return value === void 0 || guard(value);
5070
- }
5071
- function isSessionPromptCompileRecord(value) {
5072
- if (!isRecord5(value)) return false;
5073
- return isOptional(value.version, isNonNegativeInteger) && isOptional(
5074
- value.contextWindow,
5075
- (candidate) => candidate === null ? true : isNonNegativeInteger(candidate)
5076
- ) && isOptional(
5077
- value.contextWindowSource,
5078
- (candidate) => candidate === null ? true : typeof candidate === "string"
5079
- ) && isCanonicalUtcTimestamp(value.at) && (value.previousHash === null || isSha256(value.previousHash)) && isSha256(value.systemPromptHash) && isNonNegativeInteger(value.tokenEstimate) && (value.thinkingLevel === null || typeof value.thinkingLevel === "string") && (value.projectPreload === null || isProjectPreloadClass(value.projectPreload)) && Array.isArray(value.sections) && value.sections.every(isPromptManifestSection) && Array.isArray(value.fragments) && value.fragments.every(isPromptManifestFragment);
5080
- }
5081
- function getPromptManifestFilePath(meta, stateDir) {
5082
- const safeMeta = {
5083
- ...meta,
5084
- cwdHash: meta.cwdHash || cwdHash(meta.cwd || process.cwd())
5085
- };
5086
- if (stateDir !== void 0) {
5087
- return join3(stateDir, "sessions", safeMeta.cwdHash, safeMeta.id, "prompt-manifest.jsonl");
5088
- }
5089
- const paths = sessionPaths(safeMeta);
5090
- return join3(dirname(paths.current), "prompt-manifest.jsonl");
5091
- }
5092
- function appendPromptCompileRecord(meta, record2) {
5093
- try {
5094
- const file = getPromptManifestFilePath(meta);
5095
- appendFileSync(file, `${JSON.stringify(record2)}
5096
- `, "utf8");
5097
- } catch {
5098
- }
5099
- }
5100
- function readPromptCompileManifest(meta, stateDir) {
5101
- const file = getPromptManifestFilePath(meta, stateDir);
5102
- try {
5103
- if (!existsSync3(file)) return { records: [], errors: [] };
5104
- const records = [];
5105
- const errors = [];
5106
- for (const [index, line] of readFileSync3(file, "utf8").split("\n").entries()) {
5107
- if (line.trim().length === 0) continue;
5108
- try {
5109
- const parsed = JSON.parse(line);
5110
- if (isSessionPromptCompileRecord(parsed)) {
5111
- records.push(parsed);
5112
- } else {
5113
- errors.push({ line: index + 1, message: "invalid prompt manifest record" });
5114
- }
5115
- } catch {
5116
- errors.push({ line: index + 1, message: "invalid JSON" });
5117
- }
5118
- }
5119
- return { records, errors };
5120
- } catch (err) {
5121
- return {
5122
- records: [],
5123
- errors: [{ line: null, message: err instanceof Error ? err.message : String(err) }]
5124
- };
5125
- }
5126
- }
5127
- function readPromptCompileRecords(meta) {
5128
- return readPromptCompileManifest(meta).records;
5129
- }
5130
-
5131
5283
  // src/interactive/model-session-replay.ts
5132
5284
  init_esm_shims();
5133
5285
 
5134
5286
  // src/interactive/chat-renderer.ts
5135
5287
  init_esm_shims();
5136
- import { existsSync as existsSync5 } from "node:fs";
5288
+ import { existsSync as existsSync4 } from "node:fs";
5137
5289
 
5138
5290
  // src/engine/messages.ts
5139
5291
  init_esm_shims();
@@ -5258,7 +5410,7 @@ init_esm_shims();
5258
5410
  // src/interactive/mutation-preview.ts
5259
5411
  init_esm_shims();
5260
5412
  import { createHash as createHash2 } from "node:crypto";
5261
- import { readFileSync as readFileSync4 } from "node:fs";
5413
+ import { readFileSync as readFileSync3 } from "node:fs";
5262
5414
  var MUTATION_PREVIEW_VISIBLE_ROWS = 16;
5263
5415
  var MUTATION_PREVIEW_MAX_CHARS = 262144;
5264
5416
  function canonicalJson(value) {
@@ -5373,7 +5525,7 @@ function editPreview(facts, path2, edits, read) {
5373
5525
  }
5374
5526
  }
5375
5527
  function createMutationInspector(tool, args, facts, options = {}) {
5376
- const read = options.readFile ?? ((path2) => readFileSync4(path2, "utf8"));
5528
+ const read = options.readFile ?? ((path2) => readFileSync3(path2, "utf8"));
5377
5529
  return () => {
5378
5530
  const current = mutationFacts(tool, args);
5379
5531
  if (current === null || current.digest !== facts.digest) {
@@ -5761,7 +5913,22 @@ function outcomeSummary(finished) {
5761
5913
  if (finished.toolName === "dispatch") {
5762
5914
  const receipts = numberField(details, "receiptCount");
5763
5915
  const failed = numberField(details, "failedCount") ?? 0;
5764
- if (receipts !== null) return `${receipts} task${receipts === 1 ? "" : "s"} -> ${receipts - failed} ok`;
5916
+ if (receipts !== null) {
5917
+ const runs = Array.isArray(details?.runs) ? details.runs.slice(0, receipts) : [];
5918
+ const qualityCounts = /* @__PURE__ */ new Map();
5919
+ for (const run of runs) {
5920
+ const trust = isPlainObject(run) && isPlainObject(run.trust) ? run.trust : null;
5921
+ const axes = isPlainObject(trust?.axes) ? trust.axes : null;
5922
+ const word = trustStateWord("validationGrounding", stringField2(axes, "validationGrounding") ?? "unknown");
5923
+ qualityCounts.set(word, (qualityCounts.get(word) ?? 0) + 1);
5924
+ }
5925
+ if (runs.length < receipts) {
5926
+ const unknown = trustStateWord("validationGrounding", "unknown");
5927
+ qualityCounts.set(unknown, (qualityCounts.get(unknown) ?? 0) + receipts - runs.length);
5928
+ }
5929
+ const quality = [...qualityCounts].map(([word, count2]) => `${count2} ${word}`).join(", ");
5930
+ return `${receipts} task${receipts === 1 ? "" : "s"} -> ${receipts - failed} execution ok${failed > 0 ? `, ${failed} execution failed` : ""}${quality ? `; quality: ${quality}` : ""}`;
5931
+ }
5765
5932
  return null;
5766
5933
  }
5767
5934
  if (finished.toolName === "tasks") {
@@ -6922,19 +7089,19 @@ function toggledFold(effective) {
6922
7089
 
6923
7090
  // src/interactive/worker-receipts.ts
6924
7091
  init_esm_shims();
6925
- import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
6926
- import { join as join5 } from "node:path";
7092
+ import { existsSync as existsSync3, readFileSync as readFileSync5 } from "node:fs";
7093
+ import { join as join4 } from "node:path";
6927
7094
 
6928
7095
  // src/interactive/view/artifacts.ts
6929
7096
  init_esm_shims();
6930
- import { createReadStream, readFileSync as readFileSync5, statSync } from "node:fs";
7097
+ import { createReadStream, readFileSync as readFileSync4, statSync } from "node:fs";
6931
7098
  import { readFile, realpath, stat } from "node:fs/promises";
6932
- import { basename, isAbsolute as isAbsolute4, join as join4, relative as relative4, resolve as resolve3, sep } from "node:path";
7099
+ import { basename, isAbsolute as isAbsolute4, join as join3, relative as relative4, resolve as resolve3, sep } from "node:path";
6933
7100
 
6934
7101
  // src/domains/session/session-artifacts.ts
6935
7102
  init_esm_shims();
6936
7103
  import { isAbsolute as isAbsolute3, relative as relative2, resolve as resolve2 } from "node:path";
6937
- function isRecord6(value) {
7104
+ function isRecord5(value) {
6938
7105
  return !!value && typeof value === "object" && !Array.isArray(value);
6939
7106
  }
6940
7107
  function isSessionArtifactTool(value) {
@@ -6956,15 +7123,15 @@ function foldSessionArtifacts(entries, options = {}) {
6956
7123
  const writeCounts = /* @__PURE__ */ new Map();
6957
7124
  let writeIndex = 0;
6958
7125
  for (const raw of entries) {
6959
- if (!isRecord6(raw) || raw.kind !== "message" || raw.role !== "tool_result") continue;
7126
+ if (!isRecord5(raw) || raw.kind !== "message" || raw.role !== "tool_result") continue;
6960
7127
  if (typeof raw.turnId !== "string" || typeof raw.timestamp !== "string") continue;
6961
7128
  const payload = raw.payload;
6962
- if (!isRecord6(payload) || !isSessionArtifactTool(payload.toolName)) continue;
7129
+ if (!isRecord5(payload) || !isSessionArtifactTool(payload.toolName)) continue;
6963
7130
  if (payload.isError === true || payload.outcome === "error" || payload.outcome === "blocked" || payload.outcome === "aborted" || payload.outcome === "orphaned") {
6964
7131
  continue;
6965
7132
  }
6966
7133
  const result = payload.result;
6967
- if (!isRecord6(result) || !isRecord6(result.details) || !Array.isArray(result.details.paths)) continue;
7134
+ if (!isRecord5(result) || !isRecord5(result.details) || !Array.isArray(result.details.paths)) continue;
6968
7135
  const artifactKind = payload.toolName === "artifact" && isSessionArtifactKind(result.details.kind) ? result.details.kind : void 0;
6969
7136
  const pathsSeenInResult = /* @__PURE__ */ new Set();
6970
7137
  for (const recordedPath of result.details.paths) {
@@ -7783,7 +7950,16 @@ function renderTaskIslandRow(row2, width) {
7783
7950
  );
7784
7951
  const telemetry = row2.retry ? ` ${theme6.fg("warning", `attempt ${row2.retry.attempt}`)}${dot}${theme6.fg("muted", retryCountdown(row2.retry))}` : ` ${up}${dot}${down}${dot}${theme6.fg("muted", cost)}`;
7785
7952
  const task = row2.taskSummary ? ` ${theme6.fg("muted", truncateToWidth(row2.taskSummary, Math.max(1, width - 2), "\u2026", false))}` : null;
7786
- return [padAnsi(line1, width), ...task ? [padAnsi(task, width)] : [], padAnsi(telemetry, width)];
7953
+ const quality = isTerminalStatus(row2.status) ? wrapTextWithAnsi(
7954
+ ` quality: ${trustStateWord("validationGrounding", row2.trust?.axes.validationGrounding ?? "unknown")}`,
7955
+ width
7956
+ ) : [];
7957
+ return [
7958
+ padAnsi(line1, width),
7959
+ ...quality.map((line) => padAnsi(theme6.fg("muted", line), width)),
7960
+ ...task ? [padAnsi(task, width)] : [],
7961
+ padAnsi(telemetry, width)
7962
+ ];
7787
7963
  }
7788
7964
  function councilMemberView(row2, council) {
7789
7965
  const presentation = dispatchStatusPresentation(row2.status, {
@@ -9526,20 +9702,20 @@ function activityQuadrant(facts, options = {}) {
9526
9702
  rows.push(kv("tools", meaningfulToolTally(facts.toolTally)));
9527
9703
  return dashboardBlock(theme6, "Activity", rows);
9528
9704
  }
9529
- function zipColumns2(left, right, leftWidth, rightWidth, sep3) {
9705
+ function zipColumns2(left, right, leftWidth, rightWidth, sep4) {
9530
9706
  const rowCount = Math.max(left.length, right.length);
9531
9707
  const lines = [];
9532
9708
  for (let i = 0; i < rowCount; i += 1) {
9533
- lines.push(`${cell(left[i] ?? "", leftWidth)}${sep3}${cell(right[i] ?? "", rightWidth)}`);
9709
+ lines.push(`${cell(left[i] ?? "", leftWidth)}${sep4}${cell(right[i] ?? "", rightWidth)}`);
9534
9710
  }
9535
9711
  return lines;
9536
9712
  }
9537
- function zipColumnBlocks(blocks, widths, sep3) {
9713
+ function zipColumnBlocks(blocks, widths, sep4) {
9538
9714
  const rowCount = blocks.reduce((max, block) => Math.max(max, block.length), 0);
9539
9715
  const lines = [];
9540
9716
  for (let row2 = 0; row2 < rowCount; row2 += 1) {
9541
9717
  const cells = blocks.map((block, index) => cell(block[row2] ?? "", widths[index] ?? 0));
9542
- lines.push(cells.join(sep3));
9718
+ lines.push(cells.join(sep4));
9543
9719
  }
9544
9720
  return lines;
9545
9721
  }
@@ -9801,13 +9977,13 @@ var ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{
9801
9977
  function isIso8601(value) {
9802
9978
  return typeof value === "string" && ISO_8601_REGEX.test(value) && !Number.isNaN(Date.parse(value));
9803
9979
  }
9804
- function isRecord7(value) {
9980
+ function isRecord6(value) {
9805
9981
  return !!value && typeof value === "object" && !Array.isArray(value);
9806
9982
  }
9807
9983
  function isNonEmptyString(value) {
9808
9984
  return typeof value === "string" && value.length > 0;
9809
9985
  }
9810
- function isNonNegativeInteger2(value) {
9986
+ function isNonNegativeInteger(value) {
9811
9987
  return typeof value === "number" && Number.isInteger(value) && value >= 0;
9812
9988
  }
9813
9989
  function isNonNegativeFiniteNumber(value) {
@@ -9864,23 +10040,23 @@ function maybeSizeBytes(path2) {
9864
10040
  }
9865
10041
  function sessionCurrentPath2(stateDir, meta) {
9866
10042
  if (!meta) return void 0;
9867
- return join4(stateDir, "sessions", meta.cwdHash, meta.id, "current.jsonl");
10043
+ return join3(stateDir, "sessions", meta.cwdHash, meta.id, "current.jsonl");
9868
10044
  }
9869
10045
  function protectedArtifactPath(path2) {
9870
10046
  return isAbsolute4(path2) ? path2 : void 0;
9871
10047
  }
9872
10048
  function receiptFilePath(stateDir, runId) {
9873
- return join4(stateDir, "receipts", `${runId}.json`);
10049
+ return join3(stateDir, "receipts", `${runId}.json`);
9874
10050
  }
9875
10051
  function runLedgerPath(stateDir) {
9876
- return join4(stateDir, "runs.json");
10052
+ return join3(stateDir, "runs.json");
9877
10053
  }
9878
10054
  function readRunLedger(stateDir) {
9879
10055
  try {
9880
- const raw = readFileSync5(runLedgerPath(stateDir), "utf8").trim();
10056
+ const raw = readFileSync4(runLedgerPath(stateDir), "utf8").trim();
9881
10057
  if (raw.length === 0) return [];
9882
10058
  const parsed = JSON.parse(raw);
9883
- return Array.isArray(parsed) ? parsed.filter(isRecord7) : [];
10059
+ return Array.isArray(parsed) ? parsed.filter(isRecord6) : [];
9884
10060
  } catch {
9885
10061
  return [];
9886
10062
  }
@@ -9902,14 +10078,14 @@ function validateToolStats(value) {
9902
10078
  }
9903
10079
  for (let i = 0; i < value.length; i++) {
9904
10080
  const entry = value[i];
9905
- if (!isRecord7(entry)) {
10081
+ if (!isRecord6(entry)) {
9906
10082
  return { ok: false, reason: `toolStats[${i}] not an object` };
9907
10083
  }
9908
10084
  if (!isNonEmptyString(entry.tool)) {
9909
10085
  return { ok: false, reason: `toolStats[${i}].tool invalid: ${String(entry.tool)}` };
9910
10086
  }
9911
10087
  for (const key of ["count", "ok", "errors", "blocked"]) {
9912
- if (!isNonNegativeInteger2(entry[key])) {
10088
+ if (!isNonNegativeInteger(entry[key])) {
9913
10089
  return { ok: false, reason: `toolStats[${i}].${key} invalid: ${String(entry[key])}` };
9914
10090
  }
9915
10091
  }
@@ -9921,7 +10097,7 @@ function validateToolStats(value) {
9921
10097
  }
9922
10098
  function receiptTrustDetail(stateDir, runId) {
9923
10099
  try {
9924
- const receipt = JSON.parse(readFileSync5(receiptFilePath(stateDir, runId), "utf8"));
10100
+ const receipt = JSON.parse(readFileSync4(receiptFilePath(stateDir, runId), "utf8"));
9925
10101
  const ledger = readRunEnvelope(stateDir, runId);
9926
10102
  return formatTrustSummaryLine(inspectRunReceiptTrustStatus(receipt, ledger.ok ? ledger.envelope : null).status);
9927
10103
  } catch {
@@ -9939,7 +10115,7 @@ function verifyReceiptFile(stateDir, runId) {
9939
10115
  const target = receiptFilePath(stateDir, runId);
9940
10116
  let raw;
9941
10117
  try {
9942
- raw = readFileSync5(target, "utf8");
10118
+ raw = readFileSync4(target, "utf8");
9943
10119
  } catch (err) {
9944
10120
  const e = err;
9945
10121
  if (e.code === "ENOENT") return { ok: false, reason: "receipt file not found" };
@@ -9951,7 +10127,7 @@ function verifyReceiptFile(stateDir, runId) {
9951
10127
  } catch (err) {
9952
10128
  return { ok: false, reason: `invalid json: ${err.message}` };
9953
10129
  }
9954
- if (!isRecord7(parsed)) {
10130
+ if (!isRecord6(parsed)) {
9955
10131
  return { ok: false, reason: "receipt is not an object" };
9956
10132
  }
9957
10133
  const r = parsed;
@@ -10051,7 +10227,7 @@ var RECEIPT_FILE_FAILURE = /^(?:receipt file not found|read error:)/u;
10051
10227
  var RECEIPT_CONTRACT_FAILURE = /^(?:invalid json:|receipt is not an object|missing field:|runId invalid:|runId mismatch:|agentId invalid:|task invalid:|targetId invalid:|wireModelId invalid:|runtimeId invalid:|runtimeKind invalid:|exitCode out of range:|tokenCount out of range:|inputTokenCount out of range:|outputTokenCount out of range:|cacheReadTokenCount out of range:|cacheWriteTokenCount out of range:|costUsd out of range:|reasoningTokenCount out of range:|startedAt not ISO-8601:|endedAt not ISO-8601:|clioCoderVersion empty|piMonoVersion invalid:|platform invalid:|nodeVersion invalid:|toolCalls out of range:|toolStats\[|compiledPromptHash invalid:|staticCompositionHash invalid:|sessionId invalid:|integrity invalid|execution role invalid|routing intent invalid|route decision invalid)/u;
10052
10228
  var LEDGER_FAILURE = /^(?:run ledger not found|run not found in ledger|ledger mismatch:)/u;
10053
10229
  function receiptIntegrityDigest(value) {
10054
- if (!isRecord7(value) || value.algorithm !== "sha256" || !isNonEmptyString(value.digest)) return null;
10230
+ if (!isRecord6(value) || value.algorithm !== "sha256" || !isNonEmptyString(value.digest)) return null;
10055
10231
  return `sha256:${value.digest}`;
10056
10232
  }
10057
10233
  function trustCheckEvidence(status, axis) {
@@ -10077,7 +10253,7 @@ function verifyReceiptFileReport(stateDir, runId) {
10077
10253
  const result = verifyReceiptFile(stateDir, runId);
10078
10254
  let receipt = null;
10079
10255
  try {
10080
- receipt = JSON.parse(readFileSync5(receiptPath, "utf8"));
10256
+ receipt = JSON.parse(readFileSync4(receiptPath, "utf8"));
10081
10257
  } catch {
10082
10258
  }
10083
10259
  const sealedDigest = receiptIntegrityDigest(receipt?.integrity);
@@ -10386,17 +10562,17 @@ var ReceiptArtifactProvider = class {
10386
10562
  }
10387
10563
  };
10388
10564
  function resultText3(result) {
10389
- if (!isRecord7(result)) return "";
10565
+ if (!isRecord6(result)) return "";
10390
10566
  if (result.kind === "ok" && typeof result.output === "string") return result.output;
10391
10567
  if (result.kind === "error" && typeof result.message === "string") return result.message;
10392
10568
  return "";
10393
10569
  }
10394
10570
  function resultDetails(result) {
10395
- return isRecord7(result) && isRecord7(result.details) ? result.details : null;
10571
+ return isRecord6(result) && isRecord6(result.details) ? result.details : null;
10396
10572
  }
10397
10573
  function messagePayload(entry) {
10398
10574
  if (entry.kind !== "message") return null;
10399
- return isRecord7(entry.payload) ? entry.payload : null;
10575
+ return isRecord6(entry.payload) ? entry.payload : null;
10400
10576
  }
10401
10577
  function toolNameFor(entry) {
10402
10578
  const payload = messagePayload(entry);
@@ -10422,7 +10598,7 @@ function dispatchResultForRun(entries, runId) {
10422
10598
  const details = resultDetails(payload.result);
10423
10599
  const detailRunId = details?.runId;
10424
10600
  const runIds = details?.runIds;
10425
- const matches = detailRunId === runId || Array.isArray(runIds) && runIds.some((item) => item === runId) || Array.isArray(details?.runs) && details.runs.some((item) => isRecord7(item) && item.runId === runId);
10601
+ const matches = detailRunId === runId || Array.isArray(runIds) && runIds.some((item) => item === runId) || Array.isArray(details?.runs) && details.runs.some((item) => isRecord6(item) && item.runId === runId);
10426
10602
  if (!matches) continue;
10427
10603
  const text = resultText3(payload.result);
10428
10604
  if (text.length > 0) return text;
@@ -10989,7 +11165,7 @@ function auditRowPayload(row2) {
10989
11165
  }
10990
11166
  function auditReadErrorsArtifact(stateDir, errors) {
10991
11167
  if (errors.length === 0) return null;
10992
- const path2 = join4(stateDir, "audit");
11168
+ const path2 = join3(stateDir, "audit");
10993
11169
  return {
10994
11170
  id: "audit:read-errors",
10995
11171
  category: "audit",
@@ -11017,7 +11193,7 @@ var SafetyAuditArtifactProvider = class {
11017
11193
  }
11018
11194
  const selected = [...currentSessionAuditRows(read.rows, this.deps.sessionMeta?.id)].sort(compareAuditRowsNewestFirst).slice(0, SAFETY_AUDIT_ARTIFACT_LIMIT);
11019
11195
  const artifacts = selected.map((row2) => {
11020
- const path2 = join4(this.deps.stateDir, "audit", row2.file);
11196
+ const path2 = join3(this.deps.stateDir, "audit", row2.file);
11021
11197
  const runId = readStringField2(row2.row, "runId");
11022
11198
  const sessionId = readStringField2(row2.row, "sessionId");
11023
11199
  const correlationId = readStringField2(row2.row, "correlationId") ?? row2.correlationId;
@@ -11101,7 +11277,7 @@ async function listViewArtifacts(providers) {
11101
11277
  }
11102
11278
 
11103
11279
  // src/interactive/worker-receipts.ts
11104
- function isRecord8(value) {
11280
+ function isRecord7(value) {
11105
11281
  return typeof value === "object" && value !== null && !Array.isArray(value);
11106
11282
  }
11107
11283
  function optionalString(value) {
@@ -11117,12 +11293,12 @@ function elapsedMsFrom(receipt) {
11117
11293
  return Math.max(0, endedAt - startedAt);
11118
11294
  }
11119
11295
  function contractFrom(receipt) {
11120
- const quality = isRecord8(receipt.quality) ? receipt.quality : null;
11296
+ const quality = isRecord7(receipt.quality) ? receipt.quality : null;
11121
11297
  if (quality === null) return void 0;
11122
11298
  if (!Object.hasOwn(quality, "resultContract")) return void 0;
11123
11299
  const fact = quality.resultContract;
11124
11300
  if (fact === null) return "unmeasured";
11125
- if (!isRecord8(fact)) return void 0;
11301
+ if (!isRecord7(fact)) return void 0;
11126
11302
  const conformance = fact.conformance;
11127
11303
  return conformance === "pass" || conformance === "fail" || conformance === "not-reached" ? conformance : void 0;
11128
11304
  }
@@ -11134,8 +11310,8 @@ var PRESENTED_RESULT_CONTRACTS = [
11134
11310
  "scout-report"
11135
11311
  ];
11136
11312
  function contractKindFrom(receipt) {
11137
- const quality = isRecord8(receipt.quality) ? receipt.quality : null;
11138
- const fact = quality !== null && isRecord8(quality.resultContract) ? quality.resultContract : null;
11313
+ const quality = isRecord7(receipt.quality) ? receipt.quality : null;
11314
+ const fact = quality !== null && isRecord7(quality.resultContract) ? quality.resultContract : null;
11139
11315
  const sourceId = optionalString(fact?.sourceId);
11140
11316
  if (sourceId === void 0) return void 0;
11141
11317
  return PRESENTED_RESULT_CONTRACTS.find((kind) => sourceId.startsWith(`agent-result-contract:${kind}:`));
@@ -11143,7 +11319,7 @@ function contractKindFrom(receipt) {
11143
11319
  function workerReceiptFacts(receipt) {
11144
11320
  const outcome = optionalString(receipt.outcome);
11145
11321
  if (outcome === void 0) return null;
11146
- const output = isRecord8(receipt.output) ? receipt.output : null;
11322
+ const output = isRecord7(receipt.output) ? receipt.output : null;
11147
11323
  const contract = contractFrom(receipt);
11148
11324
  const contractKind = contractKindFrom(receipt);
11149
11325
  const text = optionalString(output?.text);
@@ -11169,11 +11345,11 @@ function workerReceiptFacts(receipt) {
11169
11345
  function readReceiptFileFacts(runId, stateDir) {
11170
11346
  let parsed;
11171
11347
  try {
11172
- parsed = JSON.parse(readFileSync6(receiptFilePath(stateDir, runId), "utf8"));
11348
+ parsed = JSON.parse(readFileSync5(receiptFilePath(stateDir, runId), "utf8"));
11173
11349
  } catch {
11174
11350
  return null;
11175
11351
  }
11176
- if (!isRecord8(parsed)) return null;
11352
+ if (!isRecord7(parsed)) return null;
11177
11353
  const facts = workerReceiptFacts(parsed);
11178
11354
  if (facts === null) return null;
11179
11355
  const row2 = findRunRow(runId, stateDir);
@@ -11185,13 +11361,13 @@ function readWorkerReceiptFacts(runId, stateDir = clioStateDir()) {
11185
11361
  return readReceiptFileFacts(runId, stateDir);
11186
11362
  }
11187
11363
  function findRunRow(runId, stateDir) {
11188
- const path2 = join5(stateDir, "runs.json");
11189
- if (!existsSync4(path2)) return null;
11364
+ const path2 = join4(stateDir, "runs.json");
11365
+ if (!existsSync3(path2)) return null;
11190
11366
  try {
11191
- const parsed = JSON.parse(readFileSync6(path2, "utf8"));
11367
+ const parsed = JSON.parse(readFileSync5(path2, "utf8"));
11192
11368
  if (!Array.isArray(parsed)) return null;
11193
11369
  for (const entry of parsed) {
11194
- if (isRecord8(entry) && entry.id === runId) return entry;
11370
+ if (isRecord7(entry) && entry.id === runId) return entry;
11195
11371
  }
11196
11372
  return null;
11197
11373
  } catch {
@@ -11534,6 +11710,7 @@ function richMessageFromEntry(entry, maxTextChars) {
11534
11710
  "responseModelIdObservation",
11535
11711
  "responseModel",
11536
11712
  "responseId",
11713
+ "providerThinkingLevel",
11537
11714
  "gatewayRouting",
11538
11715
  "diagnostics",
11539
11716
  "contextUsageInvalidated"
@@ -11727,7 +11904,7 @@ function replayResultSummary(result) {
11727
11904
  const summary = result.resultSummary ?? toolResultSummary(result.result);
11728
11905
  const offloadPath = typeof summary.offloadPath === "string" && summary.offloadPath.length > 0 ? summary.offloadPath : null;
11729
11906
  if (offloadPath === null) return result.resultSummary;
11730
- return { ...summary, offloadFileMissing: !existsSync5(offloadPath) };
11907
+ return { ...summary, offloadFileMissing: !existsSync4(offloadPath) };
11731
11908
  }
11732
11909
  function extractToolResult(entry) {
11733
11910
  const payload = entry.payload;
@@ -11948,6 +12125,11 @@ function appendContextMessage(out, role, text, timestamp) {
11948
12125
  if (trimmed.length === 0) return;
11949
12126
  out.push(makeTextMessage(role, truncateReplayText(trimmed), timestamp));
11950
12127
  }
12128
+ var UNVERIFIED_SKILL_CHECKPOINT_TEXT = "Preserved skill instructions on this checkpoint failed integrity verification and were not replayed. If a skill still applies, ask the operator to run /skill <name> again.";
12129
+ function unverifiedSkillContextText(skill) {
12130
+ const activation = skill.activation;
12131
+ return `Preserved skill instructions for ${activation.name} (source=${activation.source} hash=${activation.hash} path=${activation.filePath}) could not be re-verified against this session's ledger and were not replayed. If the skill still applies, recall the original load with context(scope="recall", ref="${skill.resultRef}") or ask the operator to run /skill ${activation.name} again.`;
12132
+ }
11951
12133
  function skillActivationContextText(entry) {
11952
12134
  const activation = entry.activation;
11953
12135
  const turn = activation.turnId ? ` turn=${activation.turnId}` : "";
@@ -11956,6 +12138,16 @@ function skillActivationContextText(entry) {
11956
12138
  function buildReplayAgentMessagesFromTurns(turns, options = {}) {
11957
12139
  const out = createOrderedReplaySink();
11958
12140
  const seenToolCalls = /* @__PURE__ */ new Set();
12141
+ const activeEntries = truncateAtTurn(
12142
+ filterEntriesToActivePath(turns, options.activeLeafTurnId ?? options.uptoTurnId),
12143
+ options.uptoTurnId
12144
+ );
12145
+ const skillState = latestSkillContextState(activeEntries);
12146
+ const evidence = truncateAtTurn(
12147
+ filterEntriesToActivePath(options.skillContextEntries ?? turns, options.activeLeafTurnId ?? options.uptoTurnId),
12148
+ options.uptoTurnId
12149
+ );
12150
+ const verified = captureSkillContext(evidence, skillState);
11959
12151
  for (const entry of selectReplayEntries(turns, options)) {
11960
12152
  switch (entry.kind) {
11961
12153
  case "message": {
@@ -11989,8 +12181,36 @@ function buildReplayAgentMessagesFromTurns(turns, options = {}) {
11989
12181
  break;
11990
12182
  case "compactionSummary":
11991
12183
  appendContextMessage(out, "user", compactionContextText(entry), entry.timestamp);
12184
+ if (entry.userContext)
12185
+ out.push(
12186
+ makeTextMessage("user", `Active user instructions (verbatim):
12187
+ ${entry.userContext.text}`, entry.timestamp)
12188
+ );
12189
+ if (entry.skillContext !== void 0) {
12190
+ const retainedSkills = entry.skillContext.skills.length;
12191
+ if (!verifiedSkillContextCheckpoint(entry.skillContext)) {
12192
+ if (retainedSkills > 0) {
12193
+ out.push(makeTextMessage("user", UNVERIFIED_SKILL_CHECKPOINT_TEXT, entry.timestamp));
12194
+ }
12195
+ break;
12196
+ }
12197
+ for (const skill of entry.skillContext.skills) {
12198
+ if (skillState && !skillState.unknown && !skillState.activationRefs.includes(skill.activationRef)) continue;
12199
+ const receipt = verified?.skills.find((candidate) => candidate.activationRef === skill.activationRef);
12200
+ if (!receipt || JSON.stringify(receipt) !== JSON.stringify(skill)) {
12201
+ out.push(makeTextMessage("user", unverifiedSkillContextText(skill), entry.timestamp));
12202
+ continue;
12203
+ }
12204
+ out.push(makeTextMessage("user", `Preserved skill request (verbatim):
12205
+ ${skill.requestText}`, entry.timestamp));
12206
+ out.push(makeTextMessage("user", `Verified loaded skill: ${JSON.stringify(skill.activation)}`, entry.timestamp));
12207
+ for (const block of skill.content) out.push(makeTextMessage("user", block.text, entry.timestamp));
12208
+ }
12209
+ }
11992
12210
  break;
11993
12211
  case "skillActivation":
12212
+ if (entry.activation.runId !== void 0 || skillState && !skillState.activationRefs.includes(entry.turnId))
12213
+ break;
11994
12214
  appendContextMessage(out, "user", skillActivationContextText(entry), entry.timestamp);
11995
12215
  break;
11996
12216
  // The one custom entry that becomes a model message. `/handoff` seeds a
@@ -12209,8 +12429,8 @@ function rehydrateChatPanelFromTurns(chatPanel, turns, options = {}) {
12209
12429
  // src/interactive/model-session-replay.ts
12210
12430
  function buildModelReplayAgentMessagesFromTurns(entries, options = {}) {
12211
12431
  const activeLeafTurnId = options.activeLeafTurnId ?? options.uptoTurnId;
12212
- const projected = projectWorkingSet(entries, foldWorkingSet(entries, activeLeafTurnId));
12213
- return buildReplayAgentMessagesFromTurns(projected, options);
12432
+ const projected = projectWorkingSet(entries, foldWorkingSet(entries, activeLeafTurnId), activeLeafTurnId);
12433
+ return buildReplayAgentMessagesFromTurns(projected, { ...options, skillContextEntries: entries });
12214
12434
  }
12215
12435
 
12216
12436
  // src/interactive/turn-context.ts
@@ -12226,6 +12446,7 @@ function evictionSkipMessage(visibleEntries, workingSet, policyId) {
12226
12446
  function createTurnContext(deps) {
12227
12447
  const { state, middleware } = deps;
12228
12448
  const compactionTrigger = new AutoCompactionTrigger();
12449
+ let compactionController = null;
12229
12450
  let currentContextSnapshot = null;
12230
12451
  let reconciledAnchor = null;
12231
12452
  let lastCompactionEvent = null;
@@ -12239,7 +12460,7 @@ function createTurnContext(deps) {
12239
12460
  let resumedPromptHash = null;
12240
12461
  const sessionWorkingContextPaths = /* @__PURE__ */ new Set();
12241
12462
  let pendingPromptLogEntry = null;
12242
- let emptyAutoCompactTurnId = null;
12463
+ let emptyAutoCompactContextKey = null;
12243
12464
  const pendingColdReasons = /* @__PURE__ */ new Set();
12244
12465
  let runExpectedColdReasons = [];
12245
12466
  let nextAssistantColdReasons = [];
@@ -12402,18 +12623,25 @@ function createTurnContext(deps) {
12402
12623
  }
12403
12624
  return { contextWindow: 0, contextWindowSource: null, contextWindowSlots: null };
12404
12625
  };
12405
- const reconciledAnchoredTokens = (agentRuntime, pendingUserTokens) => {
12626
+ const anchorModelKey = (agentRuntime) => {
12627
+ const model = agentRuntime.agent.state.model;
12628
+ return JSON.stringify([model?.id, model?.provider, model?.api, model?.baseUrl]);
12629
+ };
12630
+ const reconciledHistoryTokens = (agentRuntime) => {
12406
12631
  const anchor = reconciledAnchor;
12407
12632
  if (!anchor) return null;
12408
12633
  const messages = agentRuntime.agent.state.messages;
12409
- if (anchor.anchoredMessageCount > messages.length) return null;
12634
+ if (anchor.runtime !== agentRuntime || anchor.model !== agentRuntime.agent.state.model || anchor.modelKey !== anchorModelKey(agentRuntime) || anchor.targetId !== agentRuntime.targetId || anchor.runtimeId !== agentRuntime.runtimeId || anchor.wireModelId !== agentRuntime.wireModelId || anchor.anchoredMessages.length > messages.length || anchor.anchoredMessages.some((message, index) => message !== messages[index])) {
12635
+ reconciledAnchor = null;
12636
+ return null;
12637
+ }
12410
12638
  let tail = 0;
12411
- for (let i = anchor.anchoredMessageCount; i < messages.length; i += 1) {
12639
+ for (let i = anchor.anchoredMessages.length; i < messages.length; i += 1) {
12412
12640
  const message = messages[i];
12413
12641
  if (message === void 0) continue;
12414
12642
  tail += estimateAgentMessageTokens(message);
12415
12643
  }
12416
- return anchor.tokens + tail + pendingUserTokens;
12644
+ return anchor.tokens + tail;
12417
12645
  };
12418
12646
  const liveContextEstimate = (agentRuntime, pendingUserText) => {
12419
12647
  const contextWindow = agentRuntime.runtimeResolution.contextWindowDetails.effectiveContextWindow;
@@ -12424,8 +12652,10 @@ function createTurnContext(deps) {
12424
12652
  ...pendingUserText !== void 0 ? { pendingUserText } : {}
12425
12653
  };
12426
12654
  const breakdown = estimateAgentContextBreakdown(estimateInput);
12427
- const estimatedTokens = estimateAgentContextTokens(estimateInput);
12428
- const reconciledTokens = reconciledAnchoredTokens(agentRuntime, breakdown.pendingUserTokens);
12655
+ const historyTokens = reconciledHistoryTokens(agentRuntime);
12656
+ const anchor = reconciledAnchor;
12657
+ const reconciledTokens = historyTokens !== null && anchor ? historyTokens + breakdown.pendingUserTokens + Math.max(0, breakdown.systemPromptTokens - anchor.systemPromptTokens) + Math.max(0, breakdown.toolSchemaTokens - anchor.toolSchemaTokens) : null;
12658
+ const estimatedTokens = reconciledTokens === null ? estimateAgentContextTokens(estimateInput) : breakdown.systemPromptTokens + breakdown.messageTokens + breakdown.pendingUserTokens + breakdown.toolSchemaTokens;
12429
12659
  return {
12430
12660
  // The estimate is a floor, not a competing verdict: it prices material
12431
12661
  // the attested call never saw, so a provider count below it would be
@@ -12437,11 +12667,12 @@ function createTurnContext(deps) {
12437
12667
  breakdown
12438
12668
  };
12439
12669
  };
12440
- const carryReconciledAnchorThroughProjection = (agentRuntime, tokensRemoved) => {
12441
- if (!reconciledAnchor) return;
12670
+ const carryReconciledAnchorThroughProjection = (agentRuntime, historyTokens, tokensRemoved) => {
12671
+ if (!reconciledAnchor || historyTokens === null) return;
12442
12672
  reconciledAnchor = {
12443
- tokens: Math.max(0, reconciledAnchor.tokens - Math.max(0, tokensRemoved)),
12444
- anchoredMessageCount: agentRuntime.agent.state.messages.length
12673
+ ...reconciledAnchor,
12674
+ tokens: Math.max(0, historyTokens - Math.max(0, tokensRemoved)),
12675
+ anchoredMessages: [...agentRuntime.agent.state.messages]
12445
12676
  };
12446
12677
  };
12447
12678
  const refreshAgentMessagesFromSession = (agentRuntime) => {
@@ -12483,27 +12714,54 @@ function createTurnContext(deps) {
12483
12714
  usage.targetId === void 0 && usage.modelId === void 0 ? agentRuntime.runtimeResolution.costProvenance : usage.cost.total > 0 ? "estimated" : "unknown"
12484
12715
  );
12485
12716
  };
12486
- const runAutoCompact = async (agentRuntime, force, instructions, triggerOverride, pendingUserText) => {
12717
+ const runAutoCompact = async (agentRuntime, force, instructions, triggerOverride, pendingUserText, pendingSkillPolicy, signal) => {
12487
12718
  if (!deps.readSessionEntries) return false;
12488
- const activeAutoTurnId = force ? null : state.activeUserTurnId;
12489
- if (activeAutoTurnId && emptyAutoCompactTurnId === activeAutoTurnId) return false;
12719
+ const useRequestBudget = !force || triggerOverride === "overflow";
12720
+ const activeAutoTurnId = useRequestBudget ? state.activeUserTurnId : null;
12721
+ const skillContextState = mainSkillContextState(
12722
+ filterEntriesToActivePath(deps.readSessionEntries(), state.lastTurnId ?? void 0),
12723
+ pendingSkillPolicy ?? state.currentPendingSkillPolicy ?? state.activeSkillSurface
12724
+ );
12490
12725
  const settings = deps.getSettings();
12491
12726
  const cfg = settings.context.compaction;
12492
12727
  const autoEnabled = cfg?.auto !== false;
12493
12728
  if (!force && !autoEnabled) return false;
12729
+ const compactionThreshold = cfg?.threshold ?? DEFAULT_COMPACTION_THRESHOLD;
12730
+ const pressureEstimate = force ? null : liveContextEstimate(agentRuntime, pendingUserText);
12731
+ if (pressureEstimate && !shouldCompact(pressureEstimate.tokens, compactionThreshold, pressureEstimate.contextWindow).shouldCompact)
12732
+ return false;
12733
+ const attemptKey = !force && activeAutoTurnId ? createHash3("sha256").update(
12734
+ JSON.stringify({
12735
+ turn: activeAutoTurnId,
12736
+ leaf: state.lastTurnId,
12737
+ entries: deps.readSessionEntries(),
12738
+ context: {
12739
+ systemPrompt: agentRuntime.agent.state.systemPrompt,
12740
+ messages: agentRuntime.agent.state.messages,
12741
+ tools: agentRuntime.agent.state.tools,
12742
+ model: agentRuntime.agent.state.model,
12743
+ thinkingLevel: agentRuntime.agent.state.thinkingLevel
12744
+ },
12745
+ pendingUserText,
12746
+ skillContextState,
12747
+ estimate: pressureEstimate,
12748
+ compaction: cfg,
12749
+ workingSet: settings.context.workingSet,
12750
+ output: settings.chat.maxOutputTokens
12751
+ })
12752
+ ).digest("hex") : null;
12753
+ if (attemptKey && emptyAutoCompactContextKey === attemptKey) return false;
12494
12754
  let preSummaryStageActed = false;
12495
12755
  let evictionSkipNotice = null;
12496
12756
  const rememberEmptyAutomaticAttempt = () => {
12497
- if (!force && !preSummaryStageActed && activeAutoTurnId) emptyAutoCompactTurnId = activeAutoTurnId;
12757
+ if (!force && !preSummaryStageActed && attemptKey) emptyAutoCompactContextKey = attemptKey;
12498
12758
  };
12499
- const compactionThreshold = cfg?.threshold ?? DEFAULT_COMPACTION_THRESHOLD;
12500
12759
  const trigger = triggerOverride ?? (force ? "force" : "auto");
12501
- if (!force) {
12502
- const estimate = liveContextEstimate(agentRuntime, pendingUserText);
12760
+ if (pressureEstimate) {
12761
+ const estimate = pressureEstimate;
12503
12762
  const verdict = shouldCompact(estimate.tokens, compactionThreshold, estimate.contextWindow);
12504
- if (!verdict.shouldCompact) return false;
12505
12763
  if (deps.session?.current()) {
12506
- const beforeSnapshotId2 = currentContextSnapshot?.snapshotId ?? null;
12764
+ const beforeSnapshotId = currentContextSnapshot?.snapshotId ?? null;
12507
12765
  if (process.env.CLIO_CODER_LEGACY_MASK === "1") {
12508
12766
  let masked;
12509
12767
  try {
@@ -12548,7 +12806,7 @@ function createTurnContext(deps) {
12548
12806
  maskedThinkingBlocks: masked.maskedThinkingBlocks,
12549
12807
  maskedThinkingChars: masked.maskedThinkingChars,
12550
12808
  trigger,
12551
- snapshotIdBefore: beforeSnapshotId2,
12809
+ snapshotIdBefore: beforeSnapshotId,
12552
12810
  snapshotIdAfter: postMaskSnapshot.snapshotId,
12553
12811
  at: Date.now()
12554
12812
  });
@@ -12594,11 +12852,12 @@ function createTurnContext(deps) {
12594
12852
  middleware.fireCompactionHook("working_set_evict", "pressure", estimate.tokens);
12595
12853
  emitCompactionActivity("started", "compacting context (working-set eviction)");
12596
12854
  try {
12855
+ const historyTokens = reconciledHistoryTokens(agentRuntime);
12597
12856
  deps.session.appendEntry({
12598
12857
  ...buildEvictionFields(planned, {
12599
12858
  trigger: "pressure",
12600
12859
  pressureBefore: verdict.pressure,
12601
- snapshotIdBefore: beforeSnapshotId2
12860
+ snapshotIdBefore: beforeSnapshotId
12602
12861
  }),
12603
12862
  // appendEntry does not infer this anchor; the interactive
12604
12863
  // cursor is the leaf the next message will extend.
@@ -12606,7 +12865,7 @@ function createTurnContext(deps) {
12606
12865
  });
12607
12866
  noteColdReason("working_set_evict");
12608
12867
  refreshAgentMessagesFromSession(agentRuntime);
12609
- carryReconciledAnchorThroughProjection(agentRuntime, planned.tokensBefore - planned.tokensAfter);
12868
+ carryReconciledAnchorThroughProjection(agentRuntime, historyTokens, planned.tokensBefore - planned.tokensAfter);
12610
12869
  const postEvictionSnapshot = captureRuntimeContextSnapshot(
12611
12870
  agentRuntime,
12612
12871
  state.activeUserTurnId || "compaction",
@@ -12626,7 +12885,7 @@ function createTurnContext(deps) {
12626
12885
  tokensBefore: planned.tokensBefore,
12627
12886
  tokensAfter: planned.tokensAfter,
12628
12887
  trigger,
12629
- snapshotIdBefore: beforeSnapshotId2,
12888
+ snapshotIdBefore: beforeSnapshotId,
12630
12889
  snapshotIdAfter: postEvictionSnapshot.snapshotId,
12631
12890
  policyId: planned.policyId,
12632
12891
  evictedItems: planned.items.length,
@@ -12670,13 +12929,57 @@ function createTurnContext(deps) {
12670
12929
  if (force) startSummaryLifecycle();
12671
12930
  if (evictionSkipNotice) deps.emitNotice(evictionSkipNotice);
12672
12931
  let result = null;
12673
- const beforeSnapshotId = currentContextSnapshot?.snapshotId ?? null;
12932
+ const snapshotMetadata = currentContextSnapshot && currentContextSnapshot.systemPrompt === agentRuntime.agent.state.systemPrompt ? { promptSegments: currentContextSnapshot.promptSegments, promptHash: currentContextSnapshot.promptHash } : {};
12933
+ const preCompactSnapshot = captureRuntimeContextSnapshot(
12934
+ agentRuntime,
12935
+ state.activeUserTurnId || "compaction",
12936
+ compactionThreshold,
12937
+ snapshotMetadata
12938
+ );
12939
+ let budget = skillContextState !== void 0 ? { skillContextState } : void 0;
12940
+ if (useRequestBudget) {
12941
+ const estimate = liveContextEstimate(agentRuntime, pendingUserText);
12942
+ const output = Math.min(
12943
+ resolveReservedOutputTokens(agentRuntime.agent.state.model?.maxTokens, {
12944
+ api: agentRuntime.agent.state.model?.api ?? "",
12945
+ contextWindow: estimate.contextWindow,
12946
+ inputTokens: estimate.tokens
12947
+ }),
12948
+ settings.chat.maxOutputTokens > 0 ? settings.chat.maxOutputTokens : Number.POSITIVE_INFINITY
12949
+ );
12950
+ const inputTarget = Math.min(estimate.contextWindow * compactionThreshold, estimate.contextWindow - output);
12951
+ const staticTokens = estimate.breakdown.systemPromptTokens + estimate.breakdown.toolSchemaTokens;
12952
+ const calibration = Math.max(
12953
+ 0,
12954
+ estimate.tokens - staticTokens - estimate.breakdown.messageTokens - estimate.breakdown.pendingUserTokens
12955
+ );
12956
+ const historyBudget = inputTarget - staticTokens - estimate.breakdown.pendingUserTokens - calibration;
12957
+ budget = {
12958
+ ...budget,
12959
+ keepRecentTokens: Math.min(DEFAULT_KEEP_RECENT_TOKENS, Math.max(1, Math.floor(historyBudget / 2))),
12960
+ ...activeAutoTurnId ? { preserveUserTurnId: activeAutoTurnId } : {}
12961
+ };
12962
+ }
12963
+ let summarySignal = compactionController?.signal;
12674
12964
  try {
12675
- result = await compactionTrigger.fire(() => (deps.autoCompact ?? (async () => null))(instructions, trigger));
12965
+ result = await compactionTrigger.fire(async () => {
12966
+ const controller = new AbortController();
12967
+ compactionController = controller;
12968
+ summarySignal = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
12969
+ try {
12970
+ return await deps.autoCompact?.(instructions, trigger, {
12971
+ ...budget,
12972
+ signal: summarySignal
12973
+ }) ?? null;
12974
+ } finally {
12975
+ if (compactionController === controller) compactionController = null;
12976
+ }
12977
+ });
12676
12978
  } catch (error) {
12677
12979
  if (!summaryLifecycleStarted) startSummaryLifecycle();
12678
12980
  emitCompactionActivity("failed", compactionFailureMessage(error));
12679
12981
  deps.bus?.emit(BusChannels.CompactionEnd, { trigger, at: Date.now() });
12982
+ summarySignal?.throwIfAborted();
12680
12983
  throw error;
12681
12984
  }
12682
12985
  if (!result || result.summary.length === 0) {
@@ -12696,32 +12999,35 @@ function createTurnContext(deps) {
12696
12999
  const postCompactSnapshot = captureRuntimeContextSnapshot(
12697
13000
  agentRuntime,
12698
13001
  state.activeUserTurnId || "compaction",
12699
- compactionThreshold
13002
+ compactionThreshold,
13003
+ snapshotMetadata
12700
13004
  );
12701
13005
  currentContextSnapshot = postCompactSnapshot;
13006
+ persistContextSnapshot(preCompactSnapshot);
12702
13007
  persistContextSnapshot(postCompactSnapshot);
13008
+ const tokensBefore = snapshotInputTokens(preCompactSnapshot);
12703
13009
  const tokensAfter = snapshotInputTokens(postCompactSnapshot);
12704
13010
  lastCompactionEvent = {
12705
13011
  stage: "llm_summary",
12706
- tokensBefore: result.tokensBefore,
13012
+ tokensBefore,
12707
13013
  tokensAfter,
12708
13014
  trigger
12709
13015
  };
12710
13016
  deps.bus?.emit(BusChannels.ContextPruned, {
12711
13017
  stage: "llm_summary",
12712
- tokensBefore: result.tokensBefore,
13018
+ tokensBefore,
12713
13019
  tokensAfter,
12714
13020
  trigger,
12715
- snapshotIdBefore: beforeSnapshotId,
13021
+ snapshotIdBefore: preCompactSnapshot.snapshotId,
12716
13022
  snapshotIdAfter: postCompactSnapshot.snapshotId,
12717
13023
  at: Date.now()
12718
13024
  });
12719
- emitCompactionActivity("completed", `compacted ~${result.tokensBefore} -> ~${tokensAfter} tokens`);
13025
+ emitCompactionActivity("completed", `compacted ~${tokensBefore} -> ~${tokensAfter} tokens`);
12720
13026
  deps.emitNotice(
12721
13027
  renderCompactionSummaryLine({
12722
13028
  messagesSummarized: result.messagesSummarized,
12723
13029
  summaryChars: result.summary.length,
12724
- tokensBefore: result.tokensBefore,
13030
+ tokensBefore,
12725
13031
  isSplitTurn: result.isSplitTurn
12726
13032
  })
12727
13033
  );
@@ -12748,6 +13054,7 @@ function createTurnContext(deps) {
12748
13054
  rememberedLoadedContextWindow,
12749
13055
  refreshAgentMessagesFromSession,
12750
13056
  runAutoCompact,
13057
+ cancelCompaction: () => compactionController?.abort(),
12751
13058
  setCurrentSnapshot(snapshot) {
12752
13059
  currentContextSnapshot = snapshot;
12753
13060
  },
@@ -12757,11 +13064,20 @@ function createTurnContext(deps) {
12757
13064
  },
12758
13065
  reconcileUsage(usage) {
12759
13066
  const promptTokens = (usage.input || 0) + (usage.cacheRead || 0) + (usage.cacheWrite || 0);
12760
- const messages = state.runtime?.agent.state.messages;
12761
- if (promptTokens > 0 && messages) {
13067
+ const runtime = state.runtime;
13068
+ if (promptTokens > 0 && runtime) {
13069
+ const breakdown = estimateAgentContextBreakdown({ ...runtime.agent.state, messages: [] });
12762
13070
  reconciledAnchor = {
12763
13071
  tokens: promptTokens + (usage.output || 0),
12764
- anchoredMessageCount: messages.length
13072
+ anchoredMessages: [...runtime.agent.state.messages],
13073
+ runtime,
13074
+ model: runtime.agent.state.model,
13075
+ modelKey: anchorModelKey(runtime),
13076
+ targetId: runtime.targetId,
13077
+ runtimeId: runtime.runtimeId,
13078
+ wireModelId: runtime.wireModelId,
13079
+ systemPromptTokens: breakdown.systemPromptTokens,
13080
+ toolSchemaTokens: breakdown.toolSchemaTokens
12765
13081
  };
12766
13082
  }
12767
13083
  if (!currentContextSnapshot) return;
@@ -12921,7 +13237,7 @@ function createTurnContext(deps) {
12921
13237
  let compacted = false;
12922
13238
  if (verdict.shouldCompact) {
12923
13239
  try {
12924
- compacted = await runAutoCompact(agentRuntime, false, void 0, "auto");
13240
+ compacted = await runAutoCompact(agentRuntime, false, void 0, "auto", void 0, void 0, signal);
12925
13241
  } catch (err) {
12926
13242
  throw new Error(
12927
13243
  `[Clio Coder] post-tool context guard could not compact before continuation: ${err instanceof Error ? err.message : String(err)}`
@@ -13069,6 +13385,7 @@ function createTurnContext(deps) {
13069
13385
  }
13070
13386
  },
13071
13387
  resetForSession() {
13388
+ compactionController?.abort();
13072
13389
  if (sessionPromptHash !== null) noteColdReason("prompt_recompiled");
13073
13390
  lastPromptCache = null;
13074
13391
  lastPrewarm = null;
@@ -13079,12 +13396,13 @@ function createTurnContext(deps) {
13079
13396
  resumedPromptHash = null;
13080
13397
  sessionWorkingContextPaths.clear();
13081
13398
  pendingPromptLogEntry = null;
13082
- emptyAutoCompactTurnId = null;
13399
+ emptyAutoCompactContextKey = null;
13083
13400
  reconciledAnchor = null;
13084
13401
  const session = deps.session?.current();
13085
13402
  currentContextSnapshot = session ? getLatestContextSnapshot(session) : null;
13086
13403
  },
13087
13404
  dispose() {
13405
+ compactionController?.abort();
13088
13406
  for (const unsubscribe of unsubscribeColdReasonSources) unsubscribe?.();
13089
13407
  }
13090
13408
  };
@@ -13253,7 +13571,7 @@ function createTurnMiddleware(deps) {
13253
13571
  },
13254
13572
  flushPendingReminders() {
13255
13573
  if (pendingReminders.length === 0) return "";
13256
- const messages = pendingReminders.map((entry) => entry.message);
13574
+ const messages = [...new Set(pendingReminders.map((entry) => entry.message))];
13257
13575
  pendingReminders.length = 0;
13258
13576
  return `<system-reminder>
13259
13577
  ${messages.join("\n\n")}
@@ -13371,7 +13689,9 @@ function createTurnPersistence(deps) {
13371
13689
  };
13372
13690
  const appendAssistantTurn = (message, timing) => {
13373
13691
  if (message?.role !== "assistant") return;
13692
+ if (persistedAssistantMessages.has(message)) return;
13374
13693
  if (state.activeInterruptReason !== null && isEmptyAbortedAssistantMessage(message)) return;
13694
+ if (explainInterruptedAssistant(message, state.activeInterruptReason)) state.interruptedAssistantMessage = message;
13375
13695
  const failure2 = terminalFailureFromAssistantMessage(message);
13376
13696
  const payload = assistantSessionPayload(message, failure2);
13377
13697
  if (timing) payload.timing = timing;
@@ -13816,9 +14136,9 @@ function createTurnPrewarm(deps) {
13816
14136
  releaseActiveRound();
13817
14137
  },
13818
14138
  settled() {
13819
- return new Promise((resolve9) => {
14139
+ return new Promise((resolve10) => {
13820
14140
  setTimeout(() => {
13821
- resolve9(inFlight.catch(() => null));
14141
+ resolve10(inFlight.catch(() => null));
13822
14142
  }, 0);
13823
14143
  });
13824
14144
  },
@@ -13979,7 +14299,7 @@ function createTurnRecovery(deps) {
13979
14299
  deps.emitFailureMessage(message);
13980
14300
  };
13981
14301
  const waitForRetryCountdown = async (status) => {
13982
- return new Promise((resolve9) => {
14302
+ return new Promise((resolve10) => {
13983
14303
  let settled = false;
13984
14304
  let currentHandle = null;
13985
14305
  const handle = createRetryCountdown({
@@ -13996,12 +14316,12 @@ function createTurnRecovery(deps) {
13996
14316
  onDone: () => {
13997
14317
  settled = true;
13998
14318
  if (retryCountdown2 === currentHandle) retryCountdown2 = null;
13999
- resolve9("done");
14319
+ resolve10("done");
14000
14320
  },
14001
14321
  onCancel: () => {
14002
14322
  settled = true;
14003
14323
  if (retryCountdown2 === currentHandle) retryCountdown2 = null;
14004
- resolve9("cancelled");
14324
+ resolve10("cancelled");
14005
14325
  }
14006
14326
  });
14007
14327
  currentHandle = handle;
@@ -14240,7 +14560,10 @@ function createTurnRuntime(deps) {
14240
14560
  toolOutcomes.set(event.toolCallId, {
14241
14561
  outcome: event.outcome,
14242
14562
  ...event.reason === void 0 ? {} : { reason: event.reason },
14243
- durationMs: event.durationMs
14563
+ durationMs: event.durationMs,
14564
+ ...event.ruleId === void 0 ? {} : { ruleId: event.ruleId },
14565
+ ...event.reasonCode === void 0 ? {} : { reasonCode: event.reasonCode },
14566
+ ...event.policySource === void 0 ? {} : { policySource: event.policySource }
14244
14567
  });
14245
14568
  }
14246
14569
  };
@@ -14560,6 +14883,9 @@ function createTurnRuntime(deps) {
14560
14883
  resultSummary: toolResultSummary(event.result),
14561
14884
  ...admission === void 0 ? {} : {
14562
14885
  outcome: admission.outcome,
14886
+ ...admission.ruleId === void 0 ? {} : { ruleId: admission.ruleId },
14887
+ ...admission.reasonCode === void 0 ? {} : { reasonCode: admission.reasonCode },
14888
+ ...admission.policySource === void 0 ? {} : { policySource: admission.policySource },
14563
14889
  ...admission.reason === void 0 ? {} : { blockReason: admission.reason }
14564
14890
  }
14565
14891
  };
@@ -14771,6 +15097,7 @@ function createTurnState(initialThinkingLevel) {
14771
15097
  replayedContextMessages: [],
14772
15098
  activeUserTurnId: null,
14773
15099
  activeInterruptReason: null,
15100
+ interruptedAssistantMessage: null,
14774
15101
  interruptedUsage: null,
14775
15102
  synthesisToolLock: false,
14776
15103
  toolProseAbortReason: null,
@@ -14850,10 +15177,18 @@ function createChatLoop(deps) {
14850
15177
  const emitNotice = (text, level = "info", key) => {
14851
15178
  emit({ type: "notice", level, surface: "transcript", text, ...key === void 0 ? {} : { key } });
14852
15179
  };
14853
- const armSkillSurface = (policy, loadedBefore) => {
15180
+ const armSkillSurface = (policy, loadedBefore, explicitOff = false) => {
14854
15181
  const previous = skillSurfaceNames(state.activeSkillSurface).join(", ");
14855
15182
  const next = armedSkillSurface(policy);
14856
15183
  const current = skillSurfaceNames(next).join(", ");
15184
+ if (deps.session?.current() && (explicitOff || previous.length > 0 || (policy?.loadedSkillNames.size ?? 0) > 0 || (policy?.requests.length ?? 0) > 0)) {
15185
+ const entries = filterEntriesToActivePath(deps.readSessionEntries?.() ?? [], state.lastTurnId ?? void 0);
15186
+ const selection = next ? mainSkillContextState(entries, next) : (policy?.loadedSkillNames.size ?? 0) > 0 ? null : { version: 1, activationRefs: [] };
15187
+ const data = selection ?? { version: 1, activationRefs: [], unknown: true };
15188
+ if (JSON.stringify(data) !== JSON.stringify(latestSkillContextState(entries))) {
15189
+ deps.session.appendEntry({ kind: "custom", customType: SKILL_CONTEXT_STATE, parentTurnId: state.lastTurnId, data });
15190
+ }
15191
+ }
14857
15192
  state.activeSkillSurface = next;
14858
15193
  const activated = skillSurfaceLabels(policy).filter((label) => !loadedBefore?.has(label.split(" ")[0] ?? label));
14859
15194
  if (activated.length > 0) {
@@ -14875,10 +15210,13 @@ function createChatLoop(deps) {
14875
15210
  return target.length > 0 && model.length === 0 ? "model-not-configured" : "orchestrator-not-configured";
14876
15211
  };
14877
15212
  const retrySettings = () => normalizeRetrySettings(deps.getSettings().chat.retry);
15213
+ const hostRunContext = new AsyncLocalStorage();
14878
15214
  const currentToolInvokeOptions = () => {
14879
15215
  const options = {
14880
15216
  toolResultMaxBytes: deps.getSettings().context.toolResultMaxBytes
14881
15217
  };
15218
+ const hostRun = hostRunContext.getStore();
15219
+ if (hostRun !== void 0) options.hostRun = hostRun;
14882
15220
  const sessionId = deps.session?.current()?.id ?? null;
14883
15221
  if (sessionId) options.sessionId = sessionId;
14884
15222
  const turnId = state.activeUserTurnId ?? state.lastTurnId;
@@ -14947,7 +15285,10 @@ function createChatLoop(deps) {
14947
15285
  emitNotice
14948
15286
  });
14949
15287
  const emitRuntimeEvent = (event) => {
14950
- if (event.type === "message_end") rewriteStallAbortMessage(state, event.message);
15288
+ if (event.type === "message_end") {
15289
+ rewriteStallAbortMessage(state, event.message);
15290
+ explainInterruptedAssistant(event.message, state.activeInterruptReason);
15291
+ }
14951
15292
  emit(event);
14952
15293
  };
14953
15294
  const turnRuntime = createTurnRuntime({
@@ -15100,7 +15441,7 @@ function createChatLoop(deps) {
15100
15441
  interruptRefusal: () => state.streaming ? interruptRefusalReason() : null,
15101
15442
  clearSkillSurface: () => {
15102
15443
  const cleared = skillSurfaceNames(state.activeSkillSurface);
15103
- armSkillSurface(void 0);
15444
+ armSkillSurface(void 0, void 0, true);
15104
15445
  return cleared;
15105
15446
  },
15106
15447
  clearQueuedFollowUps: () => queues.clearQueuedMirror().map((entry) => entry.text),
@@ -15196,9 +15537,10 @@ function createChatLoop(deps) {
15196
15537
  const forceNow = process.env.CLIO_CODER_FORCE_COMPACT === "1";
15197
15538
  try {
15198
15539
  setTurnPreparation("compacting");
15199
- await context.runAutoCompact(agentRuntime, forceNow, void 0, void 0, submittedText);
15540
+ await context.runAutoCompact(agentRuntime, forceNow, void 0, void 0, submittedText, pendingSkillPolicy);
15200
15541
  } catch (err) {
15201
15542
  emitNotice(`[Clio Coder] auto-compaction failed: ${err instanceof Error ? err.message : String(err)}`);
15543
+ if (err instanceof Error && err.name === "AbortError") return;
15202
15544
  } finally {
15203
15545
  endPreparationCompaction();
15204
15546
  }
@@ -15211,33 +15553,46 @@ function createChatLoop(deps) {
15211
15553
  promptHash: compiledPrompt?.systemPromptHash,
15212
15554
  toolSignature
15213
15555
  });
15214
- const reservedOutput = resolveReservedOutputTokens(agentRuntime.runtimeResolution.capabilityDecisions.maxTokens);
15215
15556
  const effectiveWindow = agentRuntime.runtimeResolution.contextWindowDetails.effectiveContextWindow;
15557
+ const outputForInput = (inputTokens) => resolveReservedOutputTokens(agentRuntime.runtimeResolution.capabilityDecisions.maxTokens, {
15558
+ api: agentRuntime.agent.state.model?.api ?? "",
15559
+ contextWindow: effectiveWindow,
15560
+ inputTokens
15561
+ });
15216
15562
  const pendingInputTokens = ceilChars(submittedText.length);
15217
15563
  let turnSnapshot = captureTurnSnapshot("pending");
15218
15564
  const budgetedPromptTokens = (snapshot) => Math.max(
15219
15565
  snapshotInputTokens(snapshot) + pendingInputTokens,
15220
15566
  context.liveContextEstimate(agentRuntime, submittedText).tokens
15221
15567
  );
15222
- const totalEstimate = budgetedPromptTokens(turnSnapshot) + reservedOutput;
15568
+ const inputEstimate = budgetedPromptTokens(turnSnapshot);
15569
+ const reservedOutput = outputForInput(inputEstimate);
15570
+ const totalEstimate = inputEstimate + reservedOutput;
15223
15571
  if (effectiveWindow > 0 && totalEstimate > effectiveWindow) {
15224
15572
  emitNotice(
15225
15573
  `[Clio Coder] Estimated request size ${totalEstimate} tokens (input ${totalEstimate - reservedOutput} + output budget ${reservedOutput}) exceeds the effective context window of ${effectiveWindow} tokens. Running compaction before sending...`
15226
15574
  );
15227
15575
  setTurnPreparation("compacting");
15228
- const compacted = await context.runAutoCompact(agentRuntime, true, void 0, void 0, submittedText).finally(endPreparationCompaction);
15576
+ let compactionFailure;
15577
+ const compacted = await context.runAutoCompact(agentRuntime, true, void 0, "overflow", submittedText, pendingSkillPolicy).catch((error) => {
15578
+ compactionFailure = error instanceof Error ? error.message : String(error);
15579
+ return false;
15580
+ }).finally(endPreparationCompaction);
15229
15581
  if (!compacted) {
15230
- emitNotice(
15231
- "[Clio Coder] Compaction could not reclaim enough space. Request blocked; trim the prompt, reduce active tools, or start a fresh session."
15582
+ emitAdmissionNotice(
15583
+ `[Clio Coder] Request exceeds the context window and compaction could not reclaim enough space.${compactionFailure ? ` ${compactionFailure}.` : ""} Trim the prompt or reduce active tools.`,
15584
+ "context-window-exceeded"
15232
15585
  );
15233
15586
  return;
15234
15587
  }
15235
15588
  context.refreshAgentMessagesFromSession(agentRuntime);
15236
15589
  turnSnapshot = captureTurnSnapshot("pending");
15237
- const postTotalEstimate = budgetedPromptTokens(turnSnapshot) + reservedOutput;
15590
+ const postInputEstimate = budgetedPromptTokens(turnSnapshot);
15591
+ const postTotalEstimate = postInputEstimate + outputForInput(postInputEstimate);
15238
15592
  if (postTotalEstimate > effectiveWindow) {
15239
- emitNotice(
15240
- `[Clio Coder] Request still exceeds the effective window after compaction (${postTotalEstimate} > ${effectiveWindow}). Request blocked.`
15593
+ emitAdmissionNotice(
15594
+ `[Clio Coder] Request still exceeds the effective window after compaction (${postTotalEstimate} > ${effectiveWindow}). Request blocked.`,
15595
+ "context-window-exceeded"
15241
15596
  );
15242
15597
  return;
15243
15598
  }
@@ -15285,6 +15640,7 @@ function createChatLoop(deps) {
15285
15640
  state.toolProseAbortReason = null;
15286
15641
  state.toolProseAssessedChars = 0;
15287
15642
  state.activeInterruptReason = null;
15643
+ state.interruptedAssistantMessage = null;
15288
15644
  state.interruptedUsage = null;
15289
15645
  context.consumeExpectedColdReasons(agentRuntime.runtimeId);
15290
15646
  state.streaming = true;
@@ -15359,12 +15715,17 @@ function createChatLoop(deps) {
15359
15715
  }
15360
15716
  state.streaming = false;
15361
15717
  if (state.activeInterruptReason !== null) {
15362
- const closing = noticeMessage(state.activeInterruptReason);
15363
- if (state.interruptedUsage !== null) {
15364
- closing.usage = state.interruptedUsage;
15365
- }
15366
- persistence.appendAssistantTurn(closing);
15718
+ const reason = state.activeInterruptReason;
15367
15719
  state.activeInterruptReason = null;
15720
+ if (state.interruptedAssistantMessage === null) {
15721
+ const closing = noticeMessage(reason);
15722
+ if (state.interruptedUsage !== null) {
15723
+ closing.usage = state.interruptedUsage;
15724
+ }
15725
+ persistence.appendAssistantTurn(closing);
15726
+ emitNotice(reason, "warning", "turn.interrupted");
15727
+ }
15728
+ state.interruptedAssistantMessage = null;
15368
15729
  state.interruptedUsage = null;
15369
15730
  }
15370
15731
  state.currentPendingSkillPolicy = priorPendingSkillPolicy;
@@ -15377,12 +15738,13 @@ function createChatLoop(deps) {
15377
15738
  },
15378
15739
  cancel(options) {
15379
15740
  const wasStreaming = state.streaming;
15741
+ context.cancelCompaction();
15380
15742
  recovery.cancelRetryCountdown();
15381
15743
  queues.clearQueuedMirror();
15382
15744
  const requestedReason = options?.reason?.trim();
15383
15745
  if (wasStreaming) {
15384
15746
  state.activeInterruptReason = requestedReason && requestedReason.length > 0 ? requestedReason : "[Clio Coder] active response cancelled.";
15385
- emitNotice(state.activeInterruptReason, "warning", "turn.interrupted");
15747
+ emitFooterNotice("warning", state.activeInterruptReason, "turn.interrupted");
15386
15748
  }
15387
15749
  state.runtime?.agent.abort();
15388
15750
  if (wasStreaming && deps.bus) {
@@ -15546,11 +15908,16 @@ function createChatLoop(deps) {
15546
15908
  return;
15547
15909
  }
15548
15910
  let compacted = false;
15911
+ enterPreparation();
15912
+ setTurnPreparation("compacting");
15549
15913
  try {
15550
15914
  compacted = await context.runAutoCompact(agentRuntime, true, instructions, "force");
15551
15915
  } catch (err) {
15552
15916
  emitNotice(`[/context compact] ${err instanceof Error ? err.message : String(err)}`);
15553
15917
  return;
15918
+ } finally {
15919
+ leavePreparation();
15920
+ endPreparationCompaction();
15554
15921
  }
15555
15922
  if (!compacted) {
15556
15923
  emitNotice("[/context compact] nothing to compact; session is empty or no cut crossed");
@@ -15570,12 +15937,13 @@ function createChatLoop(deps) {
15570
15937
  };
15571
15938
  let admissionTail = null;
15572
15939
  api.submit = (text, options = {}) => {
15940
+ const hostRun = options.hostRun === void 0 ? void 0 : structuredClone(options.hostRun);
15573
15941
  prewarm.cancel();
15574
15942
  const previous = admissionTail;
15575
15943
  let release = () => {
15576
15944
  };
15577
- const ticket = new Promise((resolve9) => {
15578
- release = resolve9;
15945
+ const ticket = new Promise((resolve10) => {
15946
+ release = resolve10;
15579
15947
  });
15580
15948
  admissionTail = ticket;
15581
15949
  const releaseTicket = () => {
@@ -15595,14 +15963,17 @@ function createChatLoop(deps) {
15595
15963
  await onPreparationVisible?.();
15596
15964
  } catch {
15597
15965
  }
15598
- return submitTracked(text, {
15599
- ...submitOptions,
15600
- onAdmitted: () => {
15601
- releaseTicket();
15602
- leaveOnce();
15603
- options.onAdmitted?.();
15604
- }
15605
- }).finally(releaseTicket);
15966
+ return hostRunContext.run(
15967
+ hostRun,
15968
+ () => submitTracked(text, {
15969
+ ...submitOptions,
15970
+ onAdmitted: () => {
15971
+ releaseTicket();
15972
+ leaveOnce();
15973
+ options.onAdmitted?.();
15974
+ }
15975
+ })
15976
+ ).finally(releaseTicket);
15606
15977
  };
15607
15978
  const run = previous ? previous.then(start) : start();
15608
15979
  return run.finally(leaveOnce);
@@ -16434,8 +16805,8 @@ var AskUserOverlayView = class {
16434
16805
  this.setSurface(askUserSurface(this.questions, this.history.length));
16435
16806
  this.rebuildControl();
16436
16807
  this.deps.requestRender();
16437
- return new Promise((resolve9) => {
16438
- this.resolveCurrent = resolve9;
16808
+ return new Promise((resolve10) => {
16809
+ this.resolveCurrent = resolve10;
16439
16810
  });
16440
16811
  }
16441
16812
  cancel() {
@@ -16672,7 +17043,7 @@ var AskUserOverlayView = class {
16672
17043
  this.deps.onSurface(next);
16673
17044
  }
16674
17045
  finish(result) {
16675
- const resolve9 = this.resolveCurrent;
17046
+ const resolve10 = this.resolveCurrent;
16676
17047
  this.resolveCurrent = null;
16677
17048
  this.list = null;
16678
17049
  this.input = null;
@@ -16681,7 +17052,7 @@ var AskUserOverlayView = class {
16681
17052
  if (this.phase !== "closed") this.phase = "waiting";
16682
17053
  if (this.history.length > 0) this.setSurface("interview");
16683
17054
  this.deps.requestRender();
16684
- resolve9?.(result);
17055
+ resolve10?.(result);
16685
17056
  }
16686
17057
  renderWaiting(width, maxRows) {
16687
17058
  const theme6 = clioTheme();
@@ -17243,6 +17614,7 @@ function openAskUserOverlay(tui, deps) {
17243
17614
  focus: () => handle?.focus(),
17244
17615
  unfocus: (options) => options ? handle?.unfocus(options) : handle?.unfocus(),
17245
17616
  isFocused: () => handle?.isFocused() ?? false,
17617
+ getBounds: () => handle?.getBounds(),
17246
17618
  ask: (questions, presentation) => view.begin(questions, presentation),
17247
17619
  cancel: () => view.cancel(),
17248
17620
  close,
@@ -17416,14 +17788,14 @@ function createAuthDialogController(title, onCancel) {
17416
17788
  });
17417
17789
  input.onSubmit = () => {
17418
17790
  if (!resolver) return;
17419
- const resolve9 = resolver;
17791
+ const resolve10 = resolver;
17420
17792
  resolver = void 0;
17421
17793
  rejecter = void 0;
17422
17794
  const value = input.getValue();
17423
17795
  promptLabel = null;
17424
17796
  input.setValue("");
17425
17797
  rebuild();
17426
- resolve9(value);
17798
+ resolve10(value);
17427
17799
  };
17428
17800
  input.onEscape = () => {
17429
17801
  cancel();
@@ -17477,8 +17849,8 @@ function createAuthDialogController(title, onCancel) {
17477
17849
  promptLabel = label;
17478
17850
  input.setValue("");
17479
17851
  rebuild();
17480
- return new Promise((resolve9, reject) => {
17481
- resolver = resolve9;
17852
+ return new Promise((resolve10, reject) => {
17853
+ resolver = resolve10;
17482
17854
  rejecter = reject;
17483
17855
  });
17484
17856
  }
@@ -17702,10 +18074,10 @@ function createOverlayAuthLifecycle(deps) {
17702
18074
  },
17703
18075
  onPrompt: async (prompt) => (await dialog.controller.prompt(prompt.message)).trim(),
17704
18076
  onSelect: (prompt) => selectOAuthOption(prompt, [`Target: ${targetId}`, `Runtime: ${runtime.id}`]),
17705
- onManualCodeInput: async () => await new Promise((resolve9, reject) => {
18077
+ onManualCodeInput: async () => await new Promise((resolve10, reject) => {
17706
18078
  manualCodeTimer = setTimeout(() => {
17707
18079
  manualCodeTimer = null;
17708
- dialog.controller.prompt("Verification code").then((value) => resolve9(value.trim())).catch(reject);
18080
+ dialog.controller.prompt("Verification code").then((value) => resolve10(value.trim())).catch(reject);
17709
18081
  }, 1e4);
17710
18082
  manualCodeTimer.unref?.();
17711
18083
  }),
@@ -20549,6 +20921,7 @@ function createOverlayGeneralOpeners(deps) {
20549
20921
  fleetRootId,
20550
20922
  dispatch: deps.dispatch,
20551
20923
  agents: { getSpec: (agentId) => agents.getSpec(agentId) },
20924
+ ...deps.getDecisionBoard ? { getDecisionBoard: deps.getDecisionBoard } : {},
20552
20925
  attributionEnabled: deps.getSettings?.().integrations.git.commitAttribution ?? true,
20553
20926
  vars: preview.vars,
20554
20927
  onStepDispatched: (event) => {
@@ -22370,12 +22743,12 @@ function scopedModelsSubmenu(selectedRefs, providers) {
22370
22743
  "Target entries cycle by target, using its default model when switching targets. Model entries pin one exact target/model reference."
22371
22744
  );
22372
22745
  }
22373
- function chainSubmenus(first, second, join12) {
22746
+ function chainSubmenus(first, second, join11) {
22374
22747
  return (_currentValue, done) => {
22375
22748
  let active = first("", (head) => {
22376
22749
  const trimmed = head?.trim() ?? "";
22377
22750
  if (!trimmed) return done();
22378
- active = second(trimmed)("", (tail) => done(tail?.trim() ? join12(trimmed, tail.trim()) : void 0));
22751
+ active = second(trimmed)("", (tail) => done(tail?.trim() ? join11(trimmed, tail.trim()) : void 0));
22379
22752
  });
22380
22753
  return {
22381
22754
  render: (width) => active.render(width),
@@ -23686,11 +24059,11 @@ function applyEntrySettingChange(settings, id, value) {
23686
24059
  }
23687
24060
  function changedLeafPaths(before, after) {
23688
24061
  const out = [];
23689
- const isRecord10 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
24062
+ const isRecord9 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
23690
24063
  const visit = (a, b, path2) => {
23691
24064
  if (a === b) return;
23692
24065
  const profileLeaf = path2.startsWith("fleet.profiles.") && path2.split(".").length === 3;
23693
- if (!isRecord10(a) || !isRecord10(b) || profileLeaf) {
24066
+ if (!isRecord9(a) || !isRecord9(b) || profileLeaf) {
23694
24067
  if (JSON.stringify(a) !== JSON.stringify(b)) out.push(path2);
23695
24068
  return;
23696
24069
  }
@@ -26451,14 +26824,14 @@ function openSkillsHub(tui, deps) {
26451
26824
  let pendingWithRequirements = null;
26452
26825
  const columns = () => typeof process.stdout.columns === "number" ? process.stdout.columns : 100;
26453
26826
  let handle;
26454
- const confirmInstall = deps.confirmInstall ?? ((subject) => new Promise((resolve9) => {
26827
+ const confirmInstall = deps.confirmInstall ?? ((subject) => new Promise((resolve10) => {
26455
26828
  handle.setHidden(true);
26456
26829
  const settle = (accepted) => {
26457
26830
  if (!closed) {
26458
26831
  handle.setHidden(false);
26459
26832
  handle.focus();
26460
26833
  }
26461
- resolve9(accepted);
26834
+ resolve10(accepted);
26462
26835
  };
26463
26836
  const confirmation = openLibraryInstallConfirmOverlay(tui, {
26464
26837
  subject,
@@ -26660,9 +27033,9 @@ init_esm_shims();
26660
27033
 
26661
27034
  // src/domains/session/cwd-fallback.ts
26662
27035
  init_esm_shims();
26663
- import { existsSync as existsSync6, statSync as statSync2 } from "node:fs";
27036
+ import { existsSync as existsSync5, statSync as statSync2 } from "node:fs";
26664
27037
  var defaultFsProbe = {
26665
- exists: (p) => existsSync6(p),
27038
+ exists: (p) => existsSync5(p),
26666
27039
  isDirectory: (p) => {
26667
27040
  try {
26668
27041
  return statSync2(p).isDirectory();
@@ -26700,9 +27073,9 @@ function runCompactWithNotice(onCompact, notice, instructions) {
26700
27073
  init_esm_shims();
26701
27074
  import { spawnSync } from "node:child_process";
26702
27075
  import { randomUUID as randomUUID2 } from "node:crypto";
26703
- import { readFileSync as readFileSync7, unlinkSync, writeFileSync } from "node:fs";
27076
+ import { readFileSync as readFileSync6, unlinkSync, writeFileSync } from "node:fs";
26704
27077
  import { tmpdir } from "node:os";
26705
- import { join as join6 } from "node:path";
27078
+ import { join as join5 } from "node:path";
26706
27079
  function defaultProbe(candidates) {
26707
27080
  for (const candidate of candidates) {
26708
27081
  const result = spawnSync("sh", ["-lc", `command -v ${candidate}`], {
@@ -26734,13 +27107,13 @@ function resolveExternalEditor(env = process.env, probe = defaultProbe) {
26734
27107
  }
26735
27108
  function editTextExternally(initialText, command) {
26736
27109
  if (!command) return { ok: false, error: "no external editor configured; set VISUAL or EDITOR" };
26737
- const tmpFile = join6(tmpdir(), `clio-coder-editor-${process.pid}-${randomUUID2()}.md`);
27110
+ const tmpFile = join5(tmpdir(), `clio-coder-editor-${process.pid}-${randomUUID2()}.md`);
26738
27111
  try {
26739
27112
  writeFileSync(tmpFile, initialText, "utf8");
26740
27113
  const result = runEditor(command, tmpFile);
26741
27114
  if (result.error) return { ok: false, error: result.error.message };
26742
27115
  if (result.status !== 0) return { ok: false, error: `external editor exited with code ${result.status ?? "?"}` };
26743
- return { ok: true, text: readFileSync7(tmpFile, "utf8").replace(/\n$/, "") };
27116
+ return { ok: true, text: readFileSync6(tmpFile, "utf8").replace(/\n$/, "") };
26744
27117
  } finally {
26745
27118
  try {
26746
27119
  unlinkSync(tmpFile);
@@ -27065,7 +27438,7 @@ function openMessagePickerOverlay(tui, deps) {
27065
27438
  anchor: "center",
27066
27439
  width: MESSAGE_PICKER_OVERLAY_WIDTH,
27067
27440
  markerId: "message-picker",
27068
- title: "Fork",
27441
+ title: "Fork conversation; workspace files stay unchanged",
27069
27442
  footerHint: rows.length > 0 ? buildHint([{ key: "Enter", verb: "select" }]) : buildHint([])
27070
27443
  });
27071
27444
  }
@@ -27938,6 +28311,12 @@ function createOverlaySessionLifecycle(deps) {
27938
28311
  }
27939
28312
  deps.resetTranscript();
27940
28313
  replayFork(forkedSessionId, parentTurnId, session);
28314
+ emitCommandNotice(
28315
+ deps.getSlashNotice(),
28316
+ "info",
28317
+ "fork",
28318
+ "Conversation forked. Workspace files were not rewound; existing edits remain."
28319
+ );
27941
28320
  } catch (error) {
27942
28321
  deps.stderr(`[/fork] fork failed: ${error instanceof Error ? error.message : String(error)}
27943
28322
  `);
@@ -28088,9 +28467,9 @@ function createOverlaySessionLifecycle(deps) {
28088
28467
  openHandoffReview(session, fromSessionId, goal, document);
28089
28468
  }
28090
28469
  function editHandoffDocument(current) {
28091
- const resolve9 = deps.resolveEditor ?? resolveExternalEditor;
28470
+ const resolve10 = deps.resolveEditor ?? resolveExternalEditor;
28092
28471
  const edit = deps.editExternally ?? editTextExternally;
28093
- const command = resolve9();
28472
+ const command = resolve10();
28094
28473
  if (!command) {
28095
28474
  deps.notify("warning", "handoff: no external editor configured; set VISUAL or EDITOR", "handoff:no-editor");
28096
28475
  return null;
@@ -28785,8 +29164,8 @@ function resolveApplicationCtrlCAction(state) {
28785
29164
  function createApplicationController(deps) {
28786
29165
  let resolveRun = () => {
28787
29166
  };
28788
- const run = new Promise((resolve9) => {
28789
- resolveRun = resolve9;
29167
+ const run = new Promise((resolve10) => {
29168
+ resolveRun = resolve10;
28790
29169
  });
28791
29170
  const keepAlive = deps.intervals.setInterval(() => {
28792
29171
  }, 1 << 30);
@@ -29087,15 +29466,18 @@ function formatSteerCandidates(runs) {
29087
29466
 
29088
29467
  // src/interactive/editor-submit.ts
29089
29468
  var EDITOR_BASH_TIMEOUT_MS = 3e5;
29469
+ var EDITOR_BASH_SHUTDOWN_MS = 6e3;
29090
29470
  function isRejectedCommand(command) {
29091
29471
  return command.kind === "usage-error";
29092
29472
  }
29093
29473
  function createEditorSubmitController(deps) {
29474
+ let shuttingDown = false;
29094
29475
  let activeEditorBash = null;
29095
29476
  let activeEditorBashSettlement = null;
29096
29477
  const runEditorBash = (text) => {
29097
29478
  const parsed = parseEditorBashCommand(text);
29098
29479
  if (!parsed) return false;
29480
+ if (shuttingDown) return true;
29099
29481
  if (deps.chat.isStreaming()) {
29100
29482
  deps.io.stderr("[bash] response in progress. Press Esc to cancel the active run before running a local command.\n");
29101
29483
  return true;
@@ -29330,12 +29712,14 @@ function createEditorSubmitController(deps) {
29330
29712
  const literalText = unguardPastedEditorOperator(text);
29331
29713
  const trimmed = literalText.trim();
29332
29714
  if (trimmed.length === 0) return;
29715
+ if (shuttingDown) throw new Error("editor is shutting down");
29333
29716
  signal?.throwIfAborted();
29334
29717
  deps.collapseLaunchpadBeforeSubmit?.();
29335
29718
  if (parseEditorBashCommand(text)) {
29336
29719
  while (deps.chat.isStreaming()) await awaitWithAbort(deps.chat.whenSettled(), signal);
29337
29720
  while (activeEditorBashSettlement) await awaitWithAbort(activeEditorBashSettlement, signal);
29338
29721
  signal?.throwIfAborted();
29722
+ if (shuttingDown) throw new Error("editor is shutting down");
29339
29723
  deps.editor.addToHistory(literalText);
29340
29724
  runEditorBash(text);
29341
29725
  deps.ui.requestRender();
@@ -29455,6 +29839,11 @@ function createEditorSubmitController(deps) {
29455
29839
  interruptFromEditor,
29456
29840
  restoreQueuedFollowUpsToEditor,
29457
29841
  hasActiveEditorBash: () => activeEditorBash !== null,
29842
+ shutdownEditorBash: async () => {
29843
+ shuttingDown = true;
29844
+ activeEditorBash?.abort();
29845
+ await activeEditorBashSettlement;
29846
+ },
29458
29847
  cancelActiveEditorBash: () => {
29459
29848
  if (!activeEditorBash) return false;
29460
29849
  activeEditorBash.abort();
@@ -29920,9 +30309,10 @@ function createInteractiveEventProjection(deps) {
29920
30309
  deps.bus.on(BusChannels.ContextPruned, (payload) => {
29921
30310
  const event = payload;
29922
30311
  if (event && typeof event === "object" && typeof event.tokensBefore === "number" && typeof event.tokensAfter === "number") {
30312
+ const outcome = event.tokensAfter < event.tokensBefore ? "Reclaimed context" : "Context updated";
29923
30313
  deps.notify(
29924
30314
  "info",
29925
- `[Compaction] Reclaimed context: ${event.tokensBefore} -> ${event.tokensAfter} tokens (${event.stage})`,
30315
+ `[Compaction] ${outcome}: ${event.tokensBefore} -> ${event.tokensAfter} tokens (${event.stage})`,
29926
30316
  "compaction-notice"
29927
30317
  );
29928
30318
  }
@@ -30043,6 +30433,11 @@ function createInteractiveEventProjection(deps) {
30043
30433
  );
30044
30434
  const seenMiddlewareBudgetWarnings = /* @__PURE__ */ new Set();
30045
30435
  remainingUnsubscribers.push(
30436
+ deps.bus.on(BusChannels.ExtensionsLoadIssue, (payload) => {
30437
+ if (typeof payload?.message !== "string" || payload.message.trim().length === 0) return;
30438
+ deps.appendTranscriptNotice("warn", payload.message);
30439
+ deps.requestRender();
30440
+ }),
30046
30441
  deps.bus.on(BusChannels.MiddlewareHookFailed, (payload) => {
30047
30442
  const notice = middlewareHookFailedSessionNotice(payload, seenMiddlewareBudgetWarnings);
30048
30443
  if (notice === null) return;
@@ -30755,7 +31150,7 @@ function headerLine2(entry, width) {
30755
31150
  return fitUnits(theme5, `${originGlyph(entry)} `, identityUnits(entry), width);
30756
31151
  }
30757
31152
  function outcomeUnit(receipt, word) {
30758
- if (receipt.outcome === "succeeded") return theme5.fg("success", word ? `${GLYPH.ok} ok` : GLYPH.ok);
31153
+ if (receipt.outcome === "succeeded") return theme5.fg("success", `${GLYPH.ok} execution ok`);
30759
31154
  if (receipt.outcome === "canceled") return theme5.fg("dim", `${GLYPH.cancelled} canceled`);
30760
31155
  if (receipt.abandonedDetail !== void 0) return theme5.fg("error", word ? `${GLYPH.error} abandoned` : GLYPH.error);
30761
31156
  return theme5.fg("error", `${GLYPH.error} ${receipt.outcomeCode ?? receipt.outcome}`);
@@ -30976,12 +31371,19 @@ function foldedLine(entry, width, expandKey) {
30976
31371
  const elapsed = entry.receipt?.durationMs === void 0 ? "" : dim3(`${SEPARATOR2}${formatCompactMs(entry.receipt.durationMs)}`);
30977
31372
  const hint = expandKey === void 0 || expandKey.length === 0 ? "" : dim3(` (${expandKey})`);
30978
31373
  const full = ` ${status}${elapsed}${hint}`;
30979
- const tail = visibleWidth(identity) + visibleWidth(full) <= width ? full : ` ${status}${hint}`;
30980
- return `${truncateToWidth(identity, Math.max(1, width - visibleWidth(tail)), GLYPH.ellipsis, false)}${tail}`;
31374
+ let tail = visibleWidth(identity) + visibleWidth(full) <= width ? full : ` ${status}${hint}`;
31375
+ if (visibleWidth(tail) >= width) tail = ` ${status}`;
31376
+ const header = `${truncateToWidth(identity, Math.max(1, width - visibleWidth(tail)), GLYPH.ellipsis, false)}${tail}`;
31377
+ return truncateToWidth(header, width, GLYPH.ellipsis, false);
30981
31378
  }
30982
31379
  function renderWorkerEntryLines(entry, width, options) {
30983
31380
  const safeWidth = Math.max(1, Math.floor(width));
30984
- if (options.folded) return [foldedLine(entry, safeWidth, options.expandKey)];
31381
+ const quality = isPending(entry) ? [] : railLines(
31382
+ `quality: ${trustStateWord("validationGrounding", entry.receipt?.trust?.validationGrounding.state ?? "unknown")}`,
31383
+ "muted",
31384
+ safeWidth
31385
+ );
31386
+ if (options.folded) return [foldedLine(entry, safeWidth, options.expandKey), ...quality];
30985
31387
  const tools = toolLine(entry, safeWidth);
30986
31388
  return [
30987
31389
  headerLine2(entry, safeWidth),
@@ -30989,7 +31391,8 @@ function renderWorkerEntryLines(entry, width, options) {
30989
31391
  ...attemptLines(entry, safeWidth),
30990
31392
  ...tools === null ? [] : [tools],
30991
31393
  ...failureLines(entry, safeWidth),
30992
- footerLine(entry, safeWidth)
31394
+ footerLine(entry, safeWidth),
31395
+ ...quality
30993
31396
  ];
30994
31397
  }
30995
31398
 
@@ -32470,8 +32873,8 @@ function renderFooterStatusLines(state, width) {
32470
32873
  const safeWidth = Math.max(1, Math.floor(width));
32471
32874
  const header = headerLine3(state.session, safeWidth);
32472
32875
  if (safeWidth >= EXPANDED_ULTRAWIDE) {
32473
- const sep3 = barSep(theme6);
32474
- const widths = expandedWideColumnWidths(safeWidth, visibleWidth(sep3) * 3);
32876
+ const sep4 = barSep(theme6);
32877
+ const widths = expandedWideColumnWidths(safeWidth, visibleWidth(sep4) * 3);
32475
32878
  const blocks2 = [
32476
32879
  activityQuadrant(state.agent, {
32477
32880
  width: widths[0],
@@ -32489,14 +32892,14 @@ function renderFooterStatusLines(state, width) {
32489
32892
  sessionQuadrant(state.session, { width: widths[2] }),
32490
32893
  workspaceQuadrant(state.workspace, { width: widths[3] })
32491
32894
  ];
32492
- return [header, rule(theme6, safeWidth), ...zipColumnBlocks(blocks2, widths, sep3)].map(
32895
+ return [header, rule(theme6, safeWidth), ...zipColumnBlocks(blocks2, widths, sep4)].map(
32493
32896
  (line) => fitDashboardLine(line, safeWidth)
32494
32897
  );
32495
32898
  }
32496
32899
  if (safeWidth >= EXPANDED_WIDE) {
32497
- const sep3 = barSep(theme6);
32498
- const [topLeftWidth, topRightWidth] = expandedPairWidths(safeWidth, visibleWidth(sep3));
32499
- const [bottomLeftWidth, bottomRightWidth] = expandedPairWidths(safeWidth, visibleWidth(sep3));
32900
+ const sep4 = barSep(theme6);
32901
+ const [topLeftWidth, topRightWidth] = expandedPairWidths(safeWidth, visibleWidth(sep4));
32902
+ const [bottomLeftWidth, bottomRightWidth] = expandedPairWidths(safeWidth, visibleWidth(sep4));
32500
32903
  const top = zipColumns2(
32501
32904
  activityQuadrant(state.agent, {
32502
32905
  width: topLeftWidth,
@@ -32513,14 +32916,14 @@ function renderFooterStatusLines(state, width) {
32513
32916
  contextQuadrant(state.context, { width: topRightWidth }),
32514
32917
  topLeftWidth,
32515
32918
  topRightWidth,
32516
- sep3
32919
+ sep4
32517
32920
  );
32518
32921
  const bottom = zipColumns2(
32519
32922
  sessionQuadrant(state.session, { width: bottomLeftWidth }),
32520
32923
  workspaceQuadrant(state.workspace, { width: bottomRightWidth }),
32521
32924
  bottomLeftWidth,
32522
32925
  bottomRightWidth,
32523
- sep3
32926
+ sep4
32524
32927
  );
32525
32928
  return [header, rule(theme6, safeWidth), ...top, "", ...bottom].map((line) => fitDashboardLine(line, safeWidth));
32526
32929
  }
@@ -32764,7 +33167,8 @@ function buildFullscreenLayout(parts, options = {}) {
32764
33167
  primary: true,
32765
33168
  overscroll: "chain",
32766
33169
  scrollbar: options.fullscreenScrollbar ?? "auto",
32767
- scrollbarStyle: () => theme6.fg("frameStrong", GLYPH.barFull)
33170
+ scrollbarTrackStyle: (text) => theme6.fg("frame", text),
33171
+ scrollbarThumbStyle: () => theme6.fg("frameStrong", GLYPH.barFull)
32768
33172
  });
32769
33173
  const dock = new VStack();
32770
33174
  if (parts.pending) dock.addChild(parts.pending, { shrink: 1, minSize: 0 });
@@ -32794,7 +33198,7 @@ init_esm_shims();
32794
33198
  import { execFile as execFile2 } from "node:child_process";
32795
33199
  import { open, readdir, stat as stat2 } from "node:fs/promises";
32796
33200
  import { homedir as homedir2 } from "node:os";
32797
- import { basename as basename3, dirname as dirname2, join as join7, relative as relative7, resolve as resolve5, sep as sep2 } from "node:path";
33201
+ import { basename as basename3, dirname, join as join6, relative as relative7, resolve as resolve5, sep as sep2 } from "node:path";
32798
33202
  var MAX_COMPLETION_ROWS = 40;
32799
33203
  var PREVIEW_BYTES = 2048;
32800
33204
  var PREVIEW_CHARS = 120;
@@ -32842,7 +33246,7 @@ function buildWorkspaceSnapshot(basePath, visibleFiles, trackedFiles) {
32842
33246
  const tracked = trackedFiles.has(path2);
32843
33247
  files.push({
32844
33248
  path: path2,
32845
- absolutePath: join7(basePath, path2),
33249
+ absolutePath: join6(basePath, path2),
32846
33250
  isDirectory: false,
32847
33251
  tracked,
32848
33252
  descendantFiles: 0,
@@ -32860,7 +33264,7 @@ function buildWorkspaceSnapshot(basePath, visibleFiles, trackedFiles) {
32860
33264
  const directories = [...directoryFacts].map(
32861
33265
  ([path2, facts]) => ({
32862
33266
  path: path2,
32863
- absolutePath: join7(basePath, path2),
33267
+ absolutePath: join6(basePath, path2),
32864
33268
  isDirectory: true,
32865
33269
  tracked: facts.tracked,
32866
33270
  descendantFiles: facts.descendantFiles,
@@ -32874,7 +33278,7 @@ function buildWorkspaceSnapshot(basePath, visibleFiles, trackedFiles) {
32874
33278
  };
32875
33279
  }
32876
33280
  function candidateParent(path2) {
32877
- const parent = posixPath(dirname2(path2));
33281
+ const parent = posixPath(dirname(path2));
32878
33282
  return parent === "." ? "" : parent;
32879
33283
  }
32880
33284
  function fuzzyOrdered(candidates, query) {
@@ -32935,7 +33339,7 @@ async function explicitCandidates(basePath, query, trackedFiles) {
32935
33339
  const candidates = [];
32936
33340
  for (const entry of await readdir(directory, { withFileTypes: true })) {
32937
33341
  if (entry.name === ".git" || /[\r\n\0]/u.test(entry.name)) continue;
32938
- const absolutePath = join7(directory, entry.name);
33342
+ const absolutePath = join6(directory, entry.name);
32939
33343
  let isDirectory = entry.isDirectory();
32940
33344
  let isFile = entry.isFile();
32941
33345
  if (!isDirectory && !isFile && entry.isSymbolicLink()) {
@@ -33481,8 +33885,8 @@ function processAutoPacingAllowed(backpressureObserved, env = process.env) {
33481
33885
 
33482
33886
  // src/interactive/welcome-dashboard.ts
33483
33887
  init_esm_shims();
33484
- import { existsSync as existsSync7, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
33485
- import { basename as basename4, join as join8 } from "node:path";
33888
+ import { existsSync as existsSync6, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
33889
+ import { basename as basename4, join as join7 } from "node:path";
33486
33890
  function activeStatus(status) {
33487
33891
  return status.available && status.health.status !== "down";
33488
33892
  }
@@ -33548,14 +33952,14 @@ function wikiFactsFrom(cwd, staleness) {
33548
33952
  };
33549
33953
  }
33550
33954
  function handoffFacts(cwd) {
33551
- const handoffsDir = join8(cwd, ".clio-coder", "handoffs");
33552
- if (!existsSync7(handoffsDir)) return { handoffCount: 0, handoffFreshness: "none" };
33955
+ const handoffsDir = join7(cwd, ".clio-coder", "handoffs");
33956
+ if (!existsSync6(handoffsDir)) return { handoffCount: 0, handoffFreshness: "none" };
33553
33957
  try {
33554
33958
  const files = readdirSync2(handoffsDir).filter((f) => f.startsWith("handoff-") && f.endsWith(".md"));
33555
33959
  if (files.length === 0) return { handoffCount: 0, handoffFreshness: "none" };
33556
33960
  let newestMtime = 0;
33557
33961
  for (const file of files) {
33558
- const mtime = statSync3(join8(handoffsDir, file)).mtimeMs;
33962
+ const mtime = statSync3(join7(handoffsDir, file)).mtimeMs;
33559
33963
  if (mtime > newestMtime) newestMtime = mtime;
33560
33964
  }
33561
33965
  return {
@@ -33593,7 +33997,7 @@ async function readWelcomeRepositoryFactsAsync(cwd) {
33593
33997
  function placeholderRepositoryFacts(cwd) {
33594
33998
  return {
33595
33999
  clioMdStatus: clioMdStatusFor(cwd),
33596
- hasCodewiki: existsSync7(join8(cwd, ".clio-coder", "codewiki.json")),
34000
+ hasCodewiki: existsSync6(join7(cwd, ".clio-coder", "codewiki.json")),
33597
34001
  codewikiCount: 0,
33598
34002
  wikiPageCount: 0,
33599
34003
  wikiStatus: NO_WIKI_STATUS,
@@ -34077,7 +34481,9 @@ function createInteractivePresentation(deps) {
34077
34481
  label: skill.name,
34078
34482
  description: skill.description
34079
34483
  })),
34080
- tasks: async () => (deps.getTaskBoard?.()?.tasks ?? []).map((task) => ({
34484
+ tasks: async ({ subcommand }) => (deps.userTasks?.snapshot() ?? []).filter(
34485
+ (task) => subcommand === "hand" ? task.status === "open" : task.status === "open" || task.status === "handed" || task.status === "picked"
34486
+ ).map((task) => ({
34081
34487
  id: task.id,
34082
34488
  value: task.id,
34083
34489
  label: task.title,
@@ -34242,7 +34648,7 @@ function createInteractivePresentation(deps) {
34242
34648
  // src/interactive/interactive-slash-runtime.ts
34243
34649
  init_esm_shims();
34244
34650
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
34245
- import { join as join9, resolve as resolve6 } from "node:path";
34651
+ import { join as join8, resolve as resolve6 } from "node:path";
34246
34652
 
34247
34653
  // src/interactive/context-recall-command.ts
34248
34654
  init_esm_shims();
@@ -34254,6 +34660,7 @@ function headlineFor(ref, tokens, state, offloadPath) {
34254
34660
  if (state !== void 0) {
34255
34661
  parts.push(state.by === void 0 ? `evicted: ${state.reason}` : `evicted: ${state.reason} by ${state.by}`);
34256
34662
  }
34663
+ if (state === void 0) parts.push("summarized");
34257
34664
  parts.push(`${formatTokens3(tokens)} tokens`);
34258
34665
  if (offloadPath !== void 0) parts.push(`offload: ${offloadPath}`);
34259
34666
  return `[/context recall] ${parts.join(" \xB7 ")}`;
@@ -34271,7 +34678,7 @@ function runOperatorRecall(ref, deps) {
34271
34678
  const view = foldWorkingSet(entries, leaf);
34272
34679
  const resolved = resolveRecall(entries, view, trimmed, leaf);
34273
34680
  if (!resolved.ok)
34274
- return { ok: false, message: `[/context recall] ${recallErrorMessage(resolved.error, entries, view)}` };
34681
+ return { ok: false, message: `[/context recall] ${recallErrorMessage(resolved.error, entries, view, leaf)}` };
34275
34682
  const { result } = resolved;
34276
34683
  const fields = buildRecallFields(result, { trigger: "operator" });
34277
34684
  try {
@@ -34589,8 +34996,8 @@ function createInteractiveSlashRuntime(deps) {
34589
34996
  deps.requestRender();
34590
34997
  let acknowledgeAdmission = () => {
34591
34998
  };
34592
- const admitted = new Promise((resolve9) => {
34593
- acknowledgeAdmission = resolve9;
34999
+ const admitted = new Promise((resolve10) => {
35000
+ acknowledgeAdmission = resolve10;
34594
35001
  });
34595
35002
  const turn = deps.chat.submit(sub.text, {
34596
35003
  ...sub.images.length > 0 ? { images: sub.images } : {},
@@ -34703,6 +35110,7 @@ function createInteractiveSlashRuntime(deps) {
34703
35110
  });
34704
35111
  },
34705
35112
  dispatch: deps.dispatch,
35113
+ ...deps.getDecisionBoard ? { getDecisionBoard: deps.getDecisionBoard } : {},
34706
35114
  bus: deps.bus,
34707
35115
  ...deps.agents ? { getAgentRoleFacts: agentRoleFactsResolver((agentId) => deps.agents?.getSpec(agentId) ?? null) } : {},
34708
35116
  shutdown: () => {
@@ -34894,7 +35302,7 @@ function createInteractiveSlashRuntime(deps) {
34894
35302
  const requestedPath = pathArg?.trim() ?? "";
34895
35303
  const markdown = requestedPath.toLowerCase().endsWith(".md");
34896
35304
  const target = resolve6(
34897
- requestedPath.length > 0 ? requestedPath : join9(".clio-coder", "exports", `${sessionId}-${date}.html`)
35305
+ requestedPath.length > 0 ? requestedPath : join8(".clio-coder", "exports", `${sessionId}-${date}.html`)
34898
35306
  );
34899
35307
  mkdirSync2(resolve6(target, ".."), { recursive: true });
34900
35308
  if (markdown) {
@@ -35524,6 +35932,7 @@ async function createInteractiveApplication(deps) {
35524
35932
  ...deps.session ? { session: deps.session } : {},
35525
35933
  ...deps.getSessionId ? { getSessionId: deps.getSessionId } : {},
35526
35934
  ...deps.getTaskBoard ? { getTaskBoard: deps.getTaskBoard } : {},
35935
+ ...deps.userTasks ? { userTasks: deps.userTasks } : {},
35527
35936
  ...deps.getTaskMemoryStatus ? { getTaskMemoryStatus: deps.getTaskMemoryStatus } : {},
35528
35937
  ...deps.getTaskMemorySeedOffer ? { getTaskMemorySeedOffer: deps.getTaskMemorySeedOffer } : {},
35529
35938
  ...deps.getContextState ? { getContextState: deps.getContextState } : {}
@@ -35622,6 +36031,7 @@ async function createInteractiveApplication(deps) {
35622
36031
  io,
35623
36032
  bus: deps.bus,
35624
36033
  dispatch: deps.dispatch,
36034
+ ...deps.getDecisionBoard ? { getDecisionBoard: deps.getDecisionBoard } : {},
35625
36035
  ...deps.session ? { session: deps.session } : {},
35626
36036
  providers: deps.providers,
35627
36037
  chat: deps.chat,
@@ -35721,6 +36131,7 @@ async function createInteractiveApplication(deps) {
35721
36131
  expandSubmit: (text) => expandInteractiveSubmitAsync(text, deps.resources),
35722
36132
  notify
35723
36133
  });
36134
+ getTerminationCoordinator().onDrain(() => editorSubmit.shutdownEditorBash(), { timeoutMs: EDITOR_BASH_SHUTDOWN_MS });
35724
36135
  editor.onSubmit = editorSubmit.submitEditorText;
35725
36136
  const interactiveTickers = createInteractiveTickers({
35726
36137
  tui,
@@ -35975,7 +36386,7 @@ async function createInteractiveApplication(deps) {
35975
36386
  steerSelectedDispatch,
35976
36387
  cancelSelectedDispatch,
35977
36388
  cancelActiveEditorBash: () => editorSubmit.cancelActiveEditorBash(),
35978
- isStreaming: () => deps.chat.isStreaming(),
36389
+ isStreaming: () => deps.chat.isStreaming() || deps.chat.turnPreparation().phase === "compacting",
35979
36390
  cancelActiveRun,
35980
36391
  editor,
35981
36392
  editorSubmit,
@@ -36168,6 +36579,7 @@ function createExtensionReloadCoordinator(deps) {
36168
36579
  workspaceRoot: workspace,
36169
36580
  ...captured !== null ? { capturedSources: captured } : {},
36170
36581
  recordReceipt: deps.recordReceipt,
36582
+ report: deps.report,
36171
36583
  ...deps.runCommand !== void 0 ? { runCommand: deps.runCommand } : {},
36172
36584
  ...deps.now !== void 0 ? { now: deps.now } : {}
36173
36585
  });
@@ -36442,13 +36854,39 @@ init_esm_shims();
36442
36854
 
36443
36855
  // src/tools/dispatch-admission.ts
36444
36856
  init_esm_shims();
36445
- import { isAbsolute as isAbsolute6, relative as relative8, resolve as resolve8 } from "node:path";
36857
+ import { isAbsolute as isAbsolute7, relative as relative9, resolve as resolve9 } from "node:path";
36858
+
36859
+ // src/domains/dispatch/parallel-writers.ts
36860
+ init_esm_shims();
36861
+ import { isAbsolute as isAbsolute6, relative as relative8, resolve as resolve8, sep as sep3 } from "node:path";
36862
+ function parallelWriterConflict(requests, specs) {
36863
+ const classes = new Map(specs.map((spec) => [spec.id, spec.capabilityClass]));
36864
+ const writers = requests.filter(
36865
+ (request) => request.worktree !== true && request.autonomy !== "read-only" && classes.get(request.agentId) !== "read-only"
36866
+ );
36867
+ const roots = writers.map(
36868
+ (request) => (request.writeRoots ?? request.intent?.writeRoots ?? []).map(
36869
+ (root) => canonicalizeExistingPath(resolve8(request.cwd ?? process.cwd(), root))
36870
+ )
36871
+ );
36872
+ const contains = (parent, child) => {
36873
+ const rel = relative8(parent, child);
36874
+ return rel === "" || !isAbsolute6(rel) && rel !== ".." && !rel.startsWith(`..${sep3}`);
36875
+ };
36876
+ for (let i = 0; i < writers.length; i++)
36877
+ for (let j = i + 1; j < writers.length; j++) {
36878
+ const left = roots[i] ?? [], right = roots[j] ?? [];
36879
+ if (!left.length || !right.length || left.some((a) => right.some((b) => contains(a, b) || contains(b, a)))) {
36880
+ return `parallel_writer_conflict: ${writers[i]?.agentId} and ${writers[j]?.agentId} have overlapping or undeclared write roots. Use worktree: true, declare disjoint intent.write_roots, or serialize writers with writers: 1.`;
36881
+ }
36882
+ }
36883
+ return null;
36884
+ }
36446
36885
 
36447
36886
  // src/tools/dispatch-scout-admission.ts
36448
36887
  init_esm_shims();
36449
- import { existsSync as existsSync8, readFileSync as readFileSync8 } from "node:fs";
36450
- import { join as join10 } from "node:path";
36451
- var MAX_SCOUT_PLAN_DEADLINE_MS = 36e5;
36888
+ import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
36889
+ import { join as join9 } from "node:path";
36452
36890
  function record(value) {
36453
36891
  return typeof value === "object" && value !== null && !Array.isArray(value);
36454
36892
  }
@@ -36494,11 +36932,11 @@ function validateScoutSource(receipt, envelope, agentSpecs) {
36494
36932
  function loadVerifiedScoutSource(input) {
36495
36933
  const envelope = input.dispatch.getRun(input.ref.runId);
36496
36934
  if (envelope === null) throw new Error(`dispatch: Scout source run '${input.ref.runId}' is unavailable`);
36497
- const receiptPath = envelope.receiptPath ?? join10(clioStateDir(), "receipts", `${input.ref.runId}.json`);
36498
- if (!existsSync8(receiptPath)) throw new Error(`dispatch: Scout source receipt '${input.ref.runId}' is unavailable`);
36935
+ const receiptPath = envelope.receiptPath ?? join9(clioStateDir(), "receipts", `${input.ref.runId}.json`);
36936
+ if (!existsSync7(receiptPath)) throw new Error(`dispatch: Scout source receipt '${input.ref.runId}' is unavailable`);
36499
36937
  let receipt;
36500
36938
  try {
36501
- receipt = JSON.parse(readFileSync8(receiptPath, "utf8"));
36939
+ receipt = JSON.parse(readFileSync7(receiptPath, "utf8"));
36502
36940
  } catch (error) {
36503
36941
  throw new Error(
36504
36942
  `dispatch: Scout source receipt is unreadable: ${error instanceof Error ? error.message : String(error)}`
@@ -36519,8 +36957,8 @@ function prepareScoutContinuation(input) {
36519
36957
  const routingIntent = input.authorization === "full-auto-policy" ? { ...sourceIntent, requiredCapabilities: [...sourceIntent.requiredCapabilities], failover: "approved" } : {
36520
36958
  ...sourceIntent,
36521
36959
  posture: sourceIntent.posture === "manual" ? "balanced" : sourceIntent.posture,
36522
- maxCostUsd: input.costCeilingUsd,
36523
- deadlineMs: null,
36960
+ maxCostUsd: sourceIntent.maxCostUsd,
36961
+ deadlineMs: sourceIntent.deadlineMs,
36524
36962
  requiredCapabilities: [...sourceIntent.requiredCapabilities],
36525
36963
  failover: "approved"
36526
36964
  };
@@ -36549,8 +36987,7 @@ function prepareScoutContinuation(input) {
36549
36987
  routingIntent
36550
36988
  });
36551
36989
  }
36552
- const priorCostCeiling = input.source.receipt.routingIntent.maxCostUsd;
36553
- const effectiveCostCeiling = input.authorization === "full-auto-policy" && priorCostCeiling !== null ? Math.min(input.costCeilingUsd, priorCostCeiling) : input.costCeilingUsd;
36990
+ const explicitCostCeiling = input.source.receipt.routingIntent.maxCostUsd;
36554
36991
  const bindings = proposals.map(({ subtask, agentSpec }) => ({
36555
36992
  subtaskId: subtask.id,
36556
36993
  spec: agentSpec
@@ -36574,31 +37011,7 @@ function prepareScoutContinuation(input) {
36574
37011
  throw new Error("dispatch: full-auto policy does not grant every requested Scout authority");
36575
37012
  }
36576
37013
  const plan = transition.plan;
36577
- const p95ByStep = new Map(
36578
- proposals.map((proposal) => {
36579
- const selected = proposal.decision.candidateEvaluations.find(
36580
- (entry) => sameRouteIdentity(entry.candidate, proposal.decision.selected)
36581
- );
36582
- if (selected === void 0 || selected.rejection !== null) {
36583
- throw new Error(`dispatch: Scout step '${proposal.subtask.id}' has no admissible latency estimate`);
36584
- }
36585
- return [proposal.subtask.id, selected.estimate.p95EndToEndMs];
36586
- })
36587
- );
36588
- const predictedDeadlineMs = Math.ceil(
36589
- plan.waves.reduce(
36590
- (total, wave) => total + Math.max(...wave.map((stepId) => p95ByStep.get(stepId) ?? Number.POSITIVE_INFINITY)),
36591
- 0
36592
- )
36593
- );
36594
- if (!Number.isFinite(predictedDeadlineMs) || predictedDeadlineMs < 1 || predictedDeadlineMs > MAX_SCOUT_PLAN_DEADLINE_MS) {
36595
- throw new Error("dispatch: Scout continuation exceeds the finite whole-plan deadline ceiling");
36596
- }
36597
- const priorDeadlineMs = input.source.receipt.routingIntent.deadlineMs;
36598
- if (input.authorization === "full-auto-policy" && priorDeadlineMs !== null && predictedDeadlineMs > priorDeadlineMs) {
36599
- throw new Error("dispatch: full-auto Scout continuation exceeds the previously granted deadline");
36600
- }
36601
- const deadlineMs = Math.max(priorDeadlineMs ?? 0, predictedDeadlineMs);
37014
+ const deadlineMs = input.source.receipt.routingIntent.deadlineMs;
36602
37015
  const requests = [];
36603
37016
  const resolutions = [];
36604
37017
  const tasks = requireAgentSteps(plan.steps).map((step, index) => {
@@ -36619,7 +37032,7 @@ function prepareScoutContinuation(input) {
36619
37032
  cwd: input.source.envelope.cwd,
36620
37033
  requestOrigin: "user",
36621
37034
  agentSelection: selection,
36622
- routingIntent: { ...proposal.routingIntent, maxCostUsd: effectiveCostCeiling, deadlineMs, failover: "none" },
37035
+ routingIntent: { ...proposal.routingIntent, maxCostUsd: explicitCostCeiling, deadlineMs, failover: "none" },
36623
37036
  failover: "none"
36624
37037
  });
36625
37038
  resolutions.push(proposal.resolution);
@@ -36631,7 +37044,7 @@ function prepareScoutContinuation(input) {
36631
37044
  node: proposal.resolution.node.id,
36632
37045
  nodeKind: proposal.resolution.node.kind,
36633
37046
  ...proposal.resolution.node.host === void 0 ? {} : { nodeHost: proposal.resolution.node.host },
36634
- routingIntent: { ...proposal.routingIntent, maxCostUsd: effectiveCostCeiling, deadlineMs, failover: "none" },
37047
+ routingIntent: { ...proposal.routingIntent, maxCostUsd: explicitCostCeiling, deadlineMs, failover: "none" },
36635
37048
  failover: "none",
36636
37049
  routeApproval: null,
36637
37050
  agentSelection: selection,
@@ -36647,8 +37060,8 @@ function prepareScoutContinuation(input) {
36647
37060
  };
36648
37061
  });
36649
37062
  const aggregateCost = resolutions.reduce((sum, resolution) => sum + resolution.costUpperBoundUsd, 0);
36650
- if (!Number.isFinite(aggregateCost) || aggregateCost > effectiveCostCeiling) {
36651
- throw new Error("dispatch: Scout continuation exceeds the scheduling cost ceiling");
37063
+ if (!Number.isFinite(aggregateCost) || explicitCostCeiling !== null && aggregateCost > explicitCostCeiling) {
37064
+ throw new Error("dispatch: Scout continuation exceeds the explicit routing cost ceiling");
36652
37065
  }
36653
37066
  return {
36654
37067
  artifact: {
@@ -36663,7 +37076,7 @@ function prepareScoutContinuation(input) {
36663
37076
  maxWorkers: plan.maxWorkers,
36664
37077
  onFailure: plan.onFailure,
36665
37078
  tasks,
36666
- costCeilingUsd: effectiveCostCeiling,
37079
+ costCeilingUsd: input.costCeilingUsd,
36667
37080
  deadlineMs
36668
37081
  },
36669
37082
  requests,
@@ -36696,7 +37109,7 @@ function councilSettingsFromArgs(args, deps) {
36696
37109
  if (!Array.isArray(args.members)) return { ok: false, message: "council_members_out_of_range" };
36697
37110
  members = [];
36698
37111
  for (const raw of args.members) {
36699
- if (!isRecord9(raw)) return { ok: false, message: "council_members_out_of_range" };
37112
+ if (!isRecord8(raw)) return { ok: false, message: "council_members_out_of_range" };
36700
37113
  const label = stringArg(raw, "label");
36701
37114
  const target = stringArg(raw, "target");
36702
37115
  if (label === void 0 || target === void 0 || !COUNCIL_LABEL.test(label)) {
@@ -36726,7 +37139,7 @@ function councilSettingsFromArgs(args, deps) {
36726
37139
  if (!Number.isInteger(rounds) || Number(rounds) < 1 || Number(rounds) > 3) {
36727
37140
  return { ok: false, message: "dispatch: rounds must be an integer 1..3" };
36728
37141
  }
36729
- const judge = isRecord9(args.judge) ? Object.fromEntries(
37142
+ const judge = isRecord8(args.judge) ? Object.fromEntries(
36730
37143
  ["agent", "model", "target", "node"].flatMap((key) => {
36731
37144
  const value = stringArg(args.judge, key);
36732
37145
  return value === void 0 ? [] : [[key, value]];
@@ -36734,13 +37147,13 @@ function councilSettingsFromArgs(args, deps) {
36734
37147
  ) : void 0;
36735
37148
  return { ok: true, council: { members, synthesis, rounds: Number(rounds), ...judge ? { judge } : {} } };
36736
37149
  }
36737
- function isRecord9(value) {
37150
+ function isRecord8(value) {
36738
37151
  return typeof value === "object" && value !== null && !Array.isArray(value);
36739
37152
  }
36740
37153
  function reviewSettingsFromArgs(args) {
36741
37154
  const raw = args.review;
36742
37155
  if (raw === void 0 || raw === false) return { ok: true, review: void 0 };
36743
- const record2 = raw === true ? {} : isRecord9(raw) ? raw : null;
37156
+ const record2 = raw === true ? {} : isRecord8(raw) ? raw : null;
36744
37157
  if (record2 === null) return { ok: false, message: "dispatch: review must be true or an options object" };
36745
37158
  const review = { maxCycles: REVIEW_MAX_CYCLES_DEFAULT };
36746
37159
  const reviewer = stringArg(record2, "reviewer", "agent");
@@ -36771,10 +37184,10 @@ function competeSettingsFromArgs(args) {
36771
37184
  }
36772
37185
  candidates = args.candidates;
36773
37186
  }
36774
- if (args.judge !== void 0 && !isRecord9(args.judge)) {
37187
+ if (args.judge !== void 0 && !isRecord8(args.judge)) {
36775
37188
  return { ok: false, message: "dispatch: judge must be an options object" };
36776
37189
  }
36777
- if (!isRecord9(args.judge)) return { ok: true, compete: { candidates } };
37190
+ if (!isRecord8(args.judge)) return { ok: true, compete: { candidates } };
36778
37191
  const judge = {};
36779
37192
  for (const key of ["agent", "model", "target", "node"]) {
36780
37193
  const value = stringArg(args.judge, key);
@@ -36819,7 +37232,7 @@ function createDispatchAdmissionController(deps) {
36819
37232
  return {
36820
37233
  check: entry.check,
36821
37234
  argv: [...check.command],
36822
- cwd: resolve8(process.cwd(), check.cwd),
37235
+ cwd: resolve9(process.cwd(), check.cwd),
36823
37236
  timeoutMs: entry.timeoutMs,
36824
37237
  // A judged check seals its kind and absolute file paths here, so
36825
37238
  // host verification judges against what the catalog declared at
@@ -36827,14 +37240,14 @@ function createDispatchAdmissionController(deps) {
36827
37240
  ...check.kind !== "command" ? { kind: check.kind } : {},
36828
37241
  ...check.numeric !== void 0 ? {
36829
37242
  numeric: {
36830
- reference: resolve8(process.cwd(), check.numeric.reference),
37243
+ reference: resolve9(process.cwd(), check.numeric.reference),
36831
37244
  tolerance: { ...check.numeric.tolerance }
36832
37245
  }
36833
37246
  } : {},
36834
37247
  ...check.perf !== void 0 ? {
36835
37248
  perf: {
36836
37249
  ...check.perf.budget !== void 0 ? { budget: structuredClone(check.perf.budget) } : {},
36837
- ...check.perf.baseline !== void 0 ? { baseline: resolve8(process.cwd(), check.perf.baseline) } : {},
37250
+ ...check.perf.baseline !== void 0 ? { baseline: resolve9(process.cwd(), check.perf.baseline) } : {},
36838
37251
  ...check.perf.tolerance !== void 0 ? { tolerance: { ...check.perf.tolerance } } : {}
36839
37252
  }
36840
37253
  } : {}
@@ -36899,7 +37312,7 @@ function createDispatchAdmissionController(deps) {
36899
37312
  ...request.worktree === true ? {
36900
37313
  worktree: true,
36901
37314
  apply: request.apply ?? "merge",
36902
- ...gitCheckoutRoot(resolve8(request.cwd ?? process.cwd())) === null ? {} : { worktreeDestination: gitCheckoutRoot(resolve8(request.cwd ?? process.cwd())) }
37315
+ ...gitCheckoutRoot(resolve9(request.cwd ?? process.cwd())) === null ? {} : { worktreeDestination: gitCheckoutRoot(resolve9(request.cwd ?? process.cwd())) }
36903
37316
  } : {},
36904
37317
  target: resolution.targetId,
36905
37318
  model: resolution.wireModelId,
@@ -37016,7 +37429,7 @@ function createDispatchAdmissionController(deps) {
37016
37429
  }
37017
37430
  }
37018
37431
  if (args.apply_winner !== void 0) {
37019
- if (!isRecord9(args.apply_winner)) {
37432
+ if (!isRecord8(args.apply_winner)) {
37020
37433
  return shapeRejection(args, "dispatch: apply_winner must be an options object");
37021
37434
  }
37022
37435
  const branch = stringArg(args.apply_winner, "branch");
@@ -37026,7 +37439,7 @@ function createDispatchAdmissionController(deps) {
37026
37439
  return shapeRejection(args, "dispatch: apply_winner.branch must be a clio-coder/compete/<group>/<n> branch");
37027
37440
  }
37028
37441
  try {
37029
- const cwd = resolve8(stringArg(args.apply_winner, "cwd") ?? process.cwd());
37442
+ const cwd = resolve9(stringArg(args.apply_winner, "cwd") ?? process.cwd());
37030
37443
  return trustExecution(
37031
37444
  markPrepared(
37032
37445
  withResolvedDispatchPlan(args, {
@@ -37062,6 +37475,10 @@ function createDispatchAdmissionController(deps) {
37062
37475
  if (args.writers === 1 && mode !== "parallel") {
37063
37476
  return shapeRejection(args, "dispatch: writers is supported only for parallel dispatch");
37064
37477
  }
37478
+ if (mode === "parallel" && args.writers !== 1) {
37479
+ const conflict = parallelWriterConflict(parsed.requests, deps.getAgentSpecs());
37480
+ if (conflict !== null) return shapeRejection(args, conflict);
37481
+ }
37065
37482
  const parentCheckout = gitCheckoutRoot(process.cwd());
37066
37483
  for (const request of parsed.requests) {
37067
37484
  if (request.worktree !== true) continue;
@@ -37070,9 +37487,9 @@ function createDispatchAdmissionController(deps) {
37070
37487
  const spec = deps.getAgentSpecs().find((candidate) => candidate.id === request.agentId);
37071
37488
  if (spec?.capabilityClass === "read-only") return shapeRejection(args, "worktree_read_only_agent");
37072
37489
  if (request.cwd !== void 0) {
37073
- const requested = resolve8(request.cwd);
37074
- const rel = relative8(parentCheckout, requested);
37075
- if (rel === ".." || rel.startsWith("../") || isAbsolute6(rel)) {
37490
+ const requested = resolve9(request.cwd);
37491
+ const rel = relative9(parentCheckout, requested);
37492
+ if (rel === ".." || rel.startsWith("../") || isAbsolute7(rel)) {
37076
37493
  return shapeRejection(args, "worktree_cwd_outside_checkout");
37077
37494
  }
37078
37495
  }
@@ -37134,6 +37551,7 @@ function createDispatchAdmissionController(deps) {
37134
37551
  resolveTask(
37135
37552
  {
37136
37553
  agentId: gateDeciderAgentId(reviewResult.review.reviewer),
37554
+ ...base.budget === void 0 ? {} : { budget: base.budget },
37137
37555
  executionRole: "reviewer",
37138
37556
  task: renderDispatchReviewerTask(base.task, subject.runId, cycle, base.intent),
37139
37557
  systemPrompt: REVIEWER_GATE_PROMPT,
@@ -37169,6 +37587,7 @@ function createDispatchAdmissionController(deps) {
37169
37587
  resolveTask(
37170
37588
  {
37171
37589
  agentId: gateDeciderAgentId(compete.judge?.agent),
37590
+ ...base.budget === void 0 ? {} : { budget: base.budget },
37172
37591
  executionRole: "judge",
37173
37592
  task: `Plan-time capability check for the ${compete.candidates}-candidate judge.`,
37174
37593
  systemPrompt: JUDGE_GATE_PROMPT,
@@ -37239,6 +37658,7 @@ function createDispatchAdmissionController(deps) {
37239
37658
  if (council.synthesis === "judge") {
37240
37659
  const judgeRequest = {
37241
37660
  agentId: council.judge?.agent ?? base.agentId,
37661
+ ...base.budget === void 0 ? {} : { budget: base.budget },
37242
37662
  executionRole: "judge",
37243
37663
  task: "Plan-time capability check for council synthesis.",
37244
37664
  systemPrompt: COUNCIL_JUDGE_PROMPT,
@@ -37264,7 +37684,7 @@ function createDispatchAdmissionController(deps) {
37264
37684
  } else {
37265
37685
  for (const [index, request] of parsed.requests.entries()) tasks.push(resolveTask(request, "task", index + 1));
37266
37686
  }
37267
- const topology = describeDispatchPlan(args).topology;
37687
+ const topology = dispatchPlanTopology(args);
37268
37688
  const planScale = tasks.length > 1 || topology === "compete" || tasks.some((task) => task.node !== "local" || task.failover === "approved");
37269
37689
  if (!planScale) {
37270
37690
  const marked2 = parsed.requests.some((request) => request.intent !== void 0) ? markPrepared(
@@ -37319,24 +37739,13 @@ var FULL_DISPATCH_SCHEMA_COMPOSITION = Object.freeze({
37319
37739
  compete: true,
37320
37740
  adaptiveRouting: true
37321
37741
  });
37322
- function distinctFleetRoutes(fleet) {
37323
- const routes = /* @__PURE__ */ new Set();
37324
- const add = (target, model) => {
37325
- if (!target) return;
37326
- routes.add(`${target}${model ?? ""}`);
37327
- };
37328
- add(fleet.default.target, fleet.default.model);
37329
- for (const profile of Object.values(fleet.profiles)) add(profile.target, profile.model);
37330
- for (const roster of Object.values(fleet.rosters)) {
37331
- for (const member of roster.members) add(member.target, member.model);
37332
- }
37333
- return routes.size;
37334
- }
37335
37742
  function dispatchSchemaCompositionFor(fleet) {
37336
37743
  const routing = fleet.adaptiveRouting;
37337
37744
  return {
37338
37745
  council: Object.keys(fleet.rosters).length > 0,
37339
- compete: distinctFleetRoutes(fleet) > 1,
37746
+ // The runner isolates candidate executions and dispatches a separate judge;
37747
+ // route diversity is not required. Normal admission still validates routes.
37748
+ compete: true,
37340
37749
  adaptiveRouting: routing.roles.length > 0 || routing.postures.length > 0 || routing.agentRoles.length > 0
37341
37750
  };
37342
37751
  }
@@ -37365,7 +37774,7 @@ var DispatchBudgetSchema = typebox_exports.Object(
37365
37774
  },
37366
37775
  {
37367
37776
  additionalProperties: false,
37368
- description: "Tool-call budget within the recipe's range; retryRevision preauthorizes one ceiling for a retry or revision phase."
37777
+ description: "Advisory tool-call estimate; choose appropriate counts even above recipe recommendations. retryRevision sets a retry/revision estimate. Crossing estimates does not stop work."
37369
37778
  }
37370
37779
  );
37371
37780
  var DispatchVerificationSchema = typebox_exports.Array(
@@ -37395,7 +37804,7 @@ var DispatchIntentSchema = typebox_exports.Object(
37395
37804
  },
37396
37805
  {
37397
37806
  additionalProperties: false,
37398
- description: "Repository-relative paths and outputs. Declare it on every dispatch: it selects the project rules that apply and pins worker context, where omitting it falls back to path tokens scraped from the task text. verification entries are declared check ids from package scripts or .clio-coder/verifiers.yaml. Per-task intent must fit inside the top-level intent."
37807
+ description: "Repository-relative paths and outputs. Declare it on every dispatch: it selects the project rules that apply and pins worker context, where omitting it falls back to path tokens scraped from the task text. verification entries are declared check ids from package scripts or .clio-coder/verifiers.yaml. Per-task intent fields override inherited top-level fields within its scope. For disjoint parallel writes, set each task's write_roots to only its assigned outputs; expected_outputs alone does not narrow write access."
37399
37808
  }
37400
37809
  );
37401
37810
  var DISPATCH_DEFS = { intent: DispatchIntentSchema, budget: DispatchBudgetSchema };
@@ -37445,14 +37854,25 @@ function buildDispatchParameters(composition = FULL_DISPATCH_SCHEMA_COMPOSITION)
37445
37854
  briefing: typebox_exports.Optional(
37446
37855
  typebox_exports.String({ description: `Per-task parent context, max ${DISPATCH_BRIEFING_MAX_BYTES} UTF-8 bytes.` })
37447
37856
  ),
37448
- agent: typebox_exports.Optional(typebox_exports.String({ description: "Recipe id (default coder)." })),
37857
+ agent: typebox_exports.Optional(
37858
+ typebox_exports.String({
37859
+ description: "Recipe id for this task: set scout/documenter explicitly in a mixed pipeline; names in task text do not select recipes, and omission inherits the batch/default recipe."
37860
+ })
37861
+ ),
37449
37862
  budget: typebox_exports.Optional(BudgetRef),
37450
37863
  target: typebox_exports.Optional(typebox_exports.String()),
37451
37864
  model: typebox_exports.Optional(typebox_exports.String()),
37452
37865
  node: typebox_exports.Optional(typebox_exports.String({ description: "Fleet node pin: local or a fleet.nodes id." })),
37453
37866
  worktree: typebox_exports.Optional(typebox_exports.Literal(true, { description: "Run this writer in an isolated git worktree." })),
37454
37867
  intent: typebox_exports.Optional(IntentRef),
37455
- gate: typebox_exports.Optional(typebox_exports.String({ description: "One declared check id, shorthand for intent.verification." }))
37868
+ gate: typebox_exports.Optional(typebox_exports.String({ description: "One declared check id, shorthand for intent.verification." })),
37869
+ result_summary_max_bytes: typebox_exports.Optional(
37870
+ typebox_exports.Integer({
37871
+ minimum: 1,
37872
+ maximum: RESULT_SUMMARY_MAX_BYTES_CEILING,
37873
+ description: "This task's inline summary allowance; mutation-report workers (coder, documenter) only."
37874
+ })
37875
+ )
37456
37876
  })
37457
37877
  ]),
37458
37878
  { description: "Batch of assignments; one string or object is wrapped." }
@@ -37529,7 +37949,7 @@ function buildDispatchParameters(composition = FULL_DISPATCH_SCHEMA_COMPOSITION)
37529
37949
  } : {},
37530
37950
  agent: typebox_exports.Optional(
37531
37951
  typebox_exports.String({
37532
- description: composition.council ? "Default recipe id for string tasks, or auto (default coder; researcher for council)." : "Default recipe id for string tasks, or auto (default coder)."
37952
+ description: composition.council ? "Default recipe id for tasks without their own agent, or auto (default coder; researcher for council)." : "Default recipe id for tasks without their own agent, or auto (default coder)."
37533
37953
  })
37534
37954
  ),
37535
37955
  briefing: typebox_exports.Optional(
@@ -37567,7 +37987,14 @@ function buildDispatchParameters(composition = FULL_DISPATCH_SCHEMA_COMPOSITION)
37567
37987
  thinking_level: typebox_exports.Optional(StringEnum(THINKING_LEVELS2)),
37568
37988
  cwd: typebox_exports.Optional(typebox_exports.String({ description: "Default worker working directory." })),
37569
37989
  timeout_ms: typebox_exports.Optional(typebox_exports.Number({ description: "Abort the dispatch after this many ms." })),
37570
- max_output_bytes: typebox_exports.Optional(typebox_exports.Number({ description: "Max summary bytes returned." }))
37990
+ max_output_bytes: typebox_exports.Optional(typebox_exports.Number({ description: "Max summary bytes returned." })),
37991
+ result_summary_max_bytes: typebox_exports.Optional(
37992
+ typebox_exports.Integer({
37993
+ minimum: 1,
37994
+ maximum: RESULT_SUMMARY_MAX_BYTES_CEILING,
37995
+ description: `UTF-8 byte allowance for a mutation-report worker's inline summary (coder, documenter), default 16384. A batch default applies to mutation-report steps only; other steps ignore it. Storage bound, not the returned preview (max_output_bytes).`
37996
+ })
37997
+ )
37571
37998
  },
37572
37999
  { $defs: DISPATCH_DEFS }
37573
38000
  );
@@ -37588,7 +38015,7 @@ function createDispatchTool(inputDeps, surfaceOptions = {}) {
37588
38015
  const admission = createDispatchAdmissionController(deps);
37589
38016
  let runnerPromise = null;
37590
38017
  const loadRunner = () => {
37591
- runnerPromise ??= (surfaceOptions.loadRunner ?? (() => import("./dispatch-runner-RJ5I2F2O.js")))();
38018
+ runnerPromise ??= (surfaceOptions.loadRunner ?? (() => import("./dispatch-runner-FRHD6P2O.js")))();
37592
38019
  return runnerPromise;
37593
38020
  };
37594
38021
  return {
@@ -37656,7 +38083,7 @@ function registerAllTools(registry, deps = {}) {
37656
38083
  ...builtin(
37657
38084
  lazyTool(
37658
38085
  monitorToolSurface,
37659
- async () => (await import("./monitor-CPNIUULB.js")).createMonitorTool({ dispatch, runEvents: dispatchRunEvents })
38086
+ async () => (await import("./monitor-FTJLTKCQ.js")).createMonitorTool({ dispatch, runEvents: dispatchRunEvents })
37660
38087
  ),
37661
38088
  {
37662
38089
  path: "src/tools/monitor.ts",
@@ -37666,7 +38093,7 @@ function registerAllTools(registry, deps = {}) {
37666
38093
  });
37667
38094
  registry.register({
37668
38095
  ...builtin(
37669
- lazyTool(steerToolSurface, async () => (await import("./steer-XA25PSCS.js")).createSteerTool({ dispatch })),
38096
+ lazyTool(steerToolSurface, async () => (await import("./steer-S7D7IKPU.js")).createSteerTool({ dispatch })),
37670
38097
  {
37671
38098
  path: "src/tools/steer.ts",
37672
38099
  scope: "core"
@@ -37678,7 +38105,7 @@ function registerAllTools(registry, deps = {}) {
37678
38105
  const panes = deps.panes;
37679
38106
  registry.register({
37680
38107
  ...builtin(
37681
- lazyTool(panesToolSurface, async () => (await import("./panes-BOHAEGYC.js")).createPanesTool({ panes })),
38108
+ lazyTool(panesToolSurface, async () => (await import("./panes-7BTYH3XQ.js")).createPanesTool({ panes })),
37682
38109
  { path: "src/tools/panes.ts", scope: "core" }
37683
38110
  )
37684
38111
  });
@@ -38017,7 +38444,7 @@ function agentRoleToolWarnings(providers, settings) {
38017
38444
  }
38018
38445
  return warnings;
38019
38446
  }
38020
- async function resolveCompactionModel(settings, providers) {
38447
+ async function resolveCompactionModel(settings, providers, signal) {
38021
38448
  const override = settings.context.compaction.model;
38022
38449
  let targetId = settings.chat.target;
38023
38450
  let wireModelId = settings.chat.model;
@@ -38037,7 +38464,7 @@ async function resolveCompactionModel(settings, providers) {
38037
38464
  wireModelId = selected.ref.model;
38038
38465
  }
38039
38466
  if (!targetId || !wireModelId) return null;
38040
- await prepareBackgroundModelMetadata(providers, targetId);
38467
+ await prepareBackgroundModelMetadata(providers, targetId, signal);
38041
38468
  const status = providers.list().find((entry) => entry.target.id === targetId);
38042
38469
  if (!status?.available) {
38043
38470
  throw new Error("context.compaction.model target is unavailable; check the selected target with clio-coder targets");
@@ -38074,7 +38501,7 @@ async function resolveCompactionModel(settings, providers) {
38074
38501
  applyModelCapabilityPatch(model, refined.capabilities);
38075
38502
  let apiKey = LOCAL_API_KEY_FALLBACK2;
38076
38503
  if (targetRequiresAuth(route.target, route.runtime)) {
38077
- const auth = await providers.auth.resolveForTarget(route.target, route.runtime);
38504
+ const auth = await providers.auth.resolveForTarget(route.target, route.runtime, signal ? { signal } : void 0);
38078
38505
  if (!auth.available || !auth.apiKey) {
38079
38506
  throw new Error(
38080
38507
  "context.compaction.model authentication is unavailable; authenticate the selected target with clio-coder auth"
@@ -38147,7 +38574,7 @@ function appendSkillActivationRegistryEvent(session, activation) {
38147
38574
  } catch {
38148
38575
  }
38149
38576
  }
38150
- async function runCompactionFlow(session, settings, providers, instructions, trigger, observability) {
38577
+ async function runCompactionFlow(session, settings, providers, instructions, trigger, observability, budget, summarize) {
38151
38578
  const meta = session.current();
38152
38579
  if (!meta) {
38153
38580
  throw new Error("no current session to compact; start one with /new or /resume first");
@@ -38157,8 +38584,11 @@ async function runCompactionFlow(session, settings, providers, instructions, tri
38157
38584
  const isOriginCurrent = () => session.current()?.id === meta.id && (session.tree(meta.id).leafId ?? void 0) === activeLeafTurnId;
38158
38585
  const entries = filterEntriesToActivePath(readSessionEntriesForCompact(meta.id), activeLeafTurnId);
38159
38586
  if (entries.length === 0) return null;
38587
+ budget?.signal?.throwIfAborted();
38160
38588
  const systemPrompt = await readCompactionSystemPrompt(settings.context.compaction.systemPrompt, meta.cwd);
38161
- const resolved = await resolveCompactionModel(settings, providers);
38589
+ budget?.signal?.throwIfAborted();
38590
+ const resolved = await resolveCompactionModel(settings, providers, budget?.signal);
38591
+ budget?.signal?.throwIfAborted();
38162
38592
  if (!resolved) {
38163
38593
  throw new Error("no model configured; set chat.target + chat.model");
38164
38594
  }
@@ -38181,6 +38611,8 @@ async function runCompactionFlow(session, settings, providers, instructions, tri
38181
38611
  try {
38182
38612
  result = await compact({
38183
38613
  entries,
38614
+ ...budget,
38615
+ ...summarize ? { summarize } : {},
38184
38616
  onCall: (call) => calls.push(call),
38185
38617
  model: resolved.model,
38186
38618
  ...systemPrompt !== void 0 ? { systemPrompt } : {},
@@ -38198,6 +38630,10 @@ async function runCompactionFlow(session, settings, providers, instructions, tri
38198
38630
  } finally {
38199
38631
  releaseEndpointSlot();
38200
38632
  }
38633
+ if (budget?.signal?.aborted) {
38634
+ preserveCalls();
38635
+ budget.signal.throwIfAborted();
38636
+ }
38201
38637
  if (!isOriginCurrent()) {
38202
38638
  preserveCalls();
38203
38639
  throw new Error("compaction session or branch changed; summary discarded and originating usage retained");
@@ -38215,6 +38651,8 @@ async function runCompactionFlow(session, settings, providers, instructions, tri
38215
38651
  turnId: randomUUID3(),
38216
38652
  parentTurnId: result.firstKeptTurnId ?? null,
38217
38653
  summary: result.summary,
38654
+ ...result.skillContext ? { skillContext: result.skillContext } : {},
38655
+ ...result.userContext ? { userContext: result.userContext } : {},
38218
38656
  tokensBefore: result.tokensBefore,
38219
38657
  firstKeptTurnId: result.firstKeptTurnId ?? "",
38220
38658
  messagesSummarized: result.messagesSummarized,
@@ -38243,7 +38681,7 @@ async function runCompactionFlow(session, settings, providers, instructions, tri
38243
38681
  }
38244
38682
  function compactionCheckpointWasWritten(path2, turnId) {
38245
38683
  let malformed = false;
38246
- for (const line of readFileSync9(path2, "utf8").split("\n")) {
38684
+ for (const line of readFileSync8(path2, "utf8").split("\n")) {
38247
38685
  if (line.trim().length === 0) continue;
38248
38686
  try {
38249
38687
  const entry = JSON.parse(line);
@@ -38256,16 +38694,26 @@ function compactionCheckpointWasWritten(path2, turnId) {
38256
38694
  if (malformed) throw new Error("cannot prove checkpoint absence in a malformed session ledger");
38257
38695
  return false;
38258
38696
  }
38259
- function createProductionAutoCompact(session, getSettings, providers, observability) {
38260
- return (instructions, trigger) => runCompactionFlow(session, getSettings(), providers, instructions, trigger, observability);
38697
+ function createProductionAutoCompact(session, getSettings, providers, observability, summarize) {
38698
+ return (instructions, trigger, budget) => runCompactionFlow(session, getSettings(), providers, instructions, trigger, observability, budget, summarize);
38261
38699
  }
38262
- function estimateTokensFromSummary(summary) {
38263
- return Math.max(1, ceilChars(summary.length));
38700
+ function estimateTokensFromSummary(result) {
38701
+ return estimateTokens({
38702
+ kind: "compactionSummary",
38703
+ turnId: "estimate",
38704
+ parentTurnId: null,
38705
+ timestamp: "",
38706
+ summary: result.summary,
38707
+ firstKeptTurnId: result.firstKeptTurnId ?? "",
38708
+ tokensBefore: result.tokensBefore,
38709
+ ...result.skillContext ? { skillContext: result.skillContext } : {},
38710
+ ...result.userContext ? { userContext: result.userContext } : {}
38711
+ });
38264
38712
  }
38265
38713
  function estimateTokensAfterCompaction(entries, result) {
38266
38714
  let droppedTokens = 0;
38267
38715
  for (const entry of entries.slice(0, result.firstKeptEntryIndex)) droppedTokens += estimateTokens(entry);
38268
- const summaryTokens = estimateTokensFromSummary(result.summary);
38716
+ const summaryTokens = estimateTokensFromSummary(result);
38269
38717
  return Math.max(summaryTokens, result.tokensBefore - droppedTokens + summaryTokens);
38270
38718
  }
38271
38719
  function advanceScopedTarget(settings, direction) {
@@ -38319,6 +38767,16 @@ async function bootOrchestrator(options = {}) {
38319
38767
  installBusTracer();
38320
38768
  termination.installSignalHandlers();
38321
38769
  ensureClioState();
38770
+ for (const surface of ["safety", "settings"]) {
38771
+ const snapshot = captureProjectSurface(process.cwd(), surface);
38772
+ if (snapshot.verdict === "trusted") continue;
38773
+ for (const file of snapshot.files) {
38774
+ if (file.text !== null || file.error !== void 0) {
38775
+ bootStderr(`[clio-coder:trust] ${projectSurfaceTrustNotice(snapshot, file.path)}
38776
+ `);
38777
+ }
38778
+ }
38779
+ }
38322
38780
  sweepExpiredToolOffloads();
38323
38781
  timer.mark("install check");
38324
38782
  if (isGitRepository(process.cwd())) {
@@ -38360,7 +38818,7 @@ async function bootOrchestrator(options = {}) {
38360
38818
  let protectedArtifactStateForDispatch = null;
38361
38819
  const muxInteractive = !options.headless && options.acp === void 0 && process.env.CLIO_CODER_INTERACTIVE === "1";
38362
38820
  const muxEnablement = resolvePanesEnablement(options.panes, options.startupSettings?.interface.panes.enabled);
38363
- const withPanes = muxInteractive && muxEnablement !== "off" ? await import("./with-panes-BDQEWBRT.js") : null;
38821
+ const withPanes = muxInteractive && muxEnablement !== "off" ? await import("./with-panes-OFTNAR4Y.js") : null;
38364
38822
  const result = await loadDomains(
38365
38823
  [
38366
38824
  options.startupSettings ? createConfigDomainModule(options.startupSettings) : ConfigDomainModule,
@@ -38674,7 +39132,8 @@ async function bootOrchestrator(options = {}) {
38674
39132
  if (contextDomain) {
38675
39133
  middleware.registerHook(createFileMutationObserver(({ paths }) => contextDomain.noteFileChanges(paths)));
38676
39134
  }
38677
- const hookReceiptLog = createHookReceiptLog({ persistPath: join11(clioStateDir(), "hook-receipts.json") });
39135
+ const hookReceiptLog = createHookReceiptLog({ persistPath: join10(clioStateDir(), "hook-receipts.json") });
39136
+ let bootHookNotices = true;
38678
39137
  const extensionReload = createExtensionReloadCoordinator({
38679
39138
  extensions,
38680
39139
  middleware,
@@ -38683,10 +39142,13 @@ async function bootOrchestrator(options = {}) {
38683
39142
  report: (line) => {
38684
39143
  if (!interactive) process.stderr.write(`${line}
38685
39144
  `);
39145
+ else if (bootHookNotices) initialNotices.push(line);
39146
+ else bus.emit(BusChannels.ExtensionsLoadIssue, { message: line });
38686
39147
  },
38687
39148
  onCommitted: (event) => bus.emit(BusChannels.ExtensionsReloaded, event)
38688
39149
  });
38689
39150
  extensionReload.applyBoot();
39151
+ bootHookNotices = false;
38690
39152
  termination.onDrain(() => hookReceiptLog.flush());
38691
39153
  let activeAcpSessionAutonomy = null;
38692
39154
  const resolveBaselineAutonomy = () => effectiveSettingsForDispatch?.().safety.autonomy ?? options.headless?.autonomy ?? (config?.get() ?? readSettings()).safety.autonomy ?? "auto-edit";
@@ -39487,4 +39949,4 @@ export {
39487
39949
  createBackgroundMemoryRouting,
39488
39950
  createProductionAutoCompact
39489
39951
  };
39490
- //# sourceMappingURL=orchestrator-J4BSH4WQ.js.map
39952
+ //# sourceMappingURL=orchestrator-N47O7SFD.js.map