@qwen-code/qwen-code 0.21.1-simplify-system-prompt.0 → 0.21.2

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 (422) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +2 -0
  2. package/bundled/qc-helper/docs/configuration/settings.md +39 -28
  3. package/bundled/qc-helper/docs/features/channels/_meta.ts +2 -0
  4. package/bundled/qc-helper/docs/features/channels/github.md +139 -0
  5. package/bundled/qc-helper/docs/features/channels/gitlab.md +171 -0
  6. package/bundled/qc-helper/docs/features/channels/overview.md +61 -6
  7. package/bundled/qc-helper/docs/features/code-review.md +21 -1
  8. package/bundled/qc-helper/docs/features/hooks.md +72 -15
  9. package/bundled/qc-helper/docs/features/mcp.md +9 -1
  10. package/bundled/qc-helper/docs/features/scheduled-tasks.md +3 -1
  11. package/bundled/qc-helper/docs/features/sub-agents.md +42 -8
  12. package/bundled/qc-helper/docs/qwen-serve.md +11 -7
  13. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +2 -2
  14. package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
  15. package/bundled/review/DESIGN.md +19 -0
  16. package/bundled/review/SKILL.md +120 -61
  17. package/chunks/MaxSizedBox-TQBQ247P.js +88 -0
  18. package/chunks/{StandaloneSessionPicker-O6RKBPU4.js → StandaloneSessionPicker-2HPTKCLX.js} +71 -69
  19. package/chunks/{acp-startup-profiler-RV3IV562.js → acp-startup-profiler-2C4A5ZTJ.js} +2 -2
  20. package/chunks/{acpAgent-HYFVXVDR.js → acpAgent-PS6EDGH3.js} +1628 -590
  21. package/chunks/agent-VDOUB35F.js +84 -0
  22. package/chunks/agent-headless-EO53EFS2.js +78 -0
  23. package/chunks/{anthropicContentGenerator-LXUXMOE7.js → anthropicContentGenerator-OFHSZJBF.js} +61 -20
  24. package/chunks/{artifact-tool-Y5T7GG7F.js → artifact-tool-RDN2W7ND.js} +4 -4
  25. package/chunks/{askUserQuestion-2H6747FR.js → askUserQuestion-OZERWH5R.js} +4 -4
  26. package/chunks/bridge-W7AZSRZQ.js +94 -0
  27. package/chunks/{build-RV63TIRH.js → build-GDBLPA24.js} +1 -1
  28. package/chunks/{ca-25EDXPFZ.js → ca-6W3SK7OQ.js} +6 -1
  29. package/chunks/{channel-management-service-G74LFADV.js → channel-management-service-5S7YCWX5.js} +20 -5
  30. package/chunks/channel-settings-store-JFVRSNER.js +91 -0
  31. package/chunks/{channel-worker-group-PTJIJSKC.js → channel-worker-group-OVWGYMZS.js} +9 -5
  32. package/chunks/{channel-worker-manager-WIMGM2FD.js → channel-worker-manager-H55GKOQA.js} +9 -5
  33. package/chunks/{channel-worker-supervisor-KUFTR6P5.js → channel-worker-supervisor-CABBXYHK.js} +5 -4
  34. package/chunks/{chunk-6GMVPFB2.js → chunk-2IIJTXYF.js} +45 -16
  35. package/chunks/{chunk-BPJSQIJX.js → chunk-2J3OJGTL.js} +0 -2
  36. package/chunks/{chunk-I7XZ3RY5.js → chunk-2KKCCLPT.js} +1 -1
  37. package/chunks/{chunk-MSLKI6C2.js → chunk-2LEOZTBT.js} +49 -26
  38. package/chunks/{chunk-3QMGYBFN.js → chunk-3APUUXRF.js} +1 -80
  39. package/chunks/{chunk-VV6XU5L7.js → chunk-3F2WDAV6.js} +16 -11
  40. package/chunks/{chunk-MUP3T3AD.js → chunk-3I6DUGQD.js} +1 -35
  41. package/chunks/{chunk-66RMLJHC.js → chunk-44F4LBWZ.js} +577 -208
  42. package/chunks/{chunk-VAK25FTU.js → chunk-45IOTAUS.js} +1 -1
  43. package/chunks/{chunk-JZA3JUDJ.js → chunk-4KP2F2TE.js} +1 -1
  44. package/chunks/{chunk-DM4Q4JJH.js → chunk-54YCNSK5.js} +36562 -45062
  45. package/chunks/{chunk-2Q3OT4OV.js → chunk-56Z7QEAQ.js} +200 -77
  46. package/chunks/{chunk-ZOIFNCKL.js → chunk-5NNHICSA.js} +3 -23
  47. package/chunks/{chunk-A4UCTEB5.js → chunk-5WV5S2GT.js} +0 -1
  48. package/chunks/{chunk-RHLZR4E5.js → chunk-675H6PLP.js} +1 -1
  49. package/chunks/{chunk-YAF5VNU7.js → chunk-6CQWRWUC.js} +4 -5
  50. package/chunks/chunk-6FMJLI5M.js +1591 -0
  51. package/chunks/{chunk-HV3G62R6.js → chunk-6MPDY6ZG.js} +1 -1
  52. package/chunks/{chunk-32MVHM4T.js → chunk-6PQPKTXP.js} +1 -1
  53. package/chunks/{chunk-LG4GZIVV.js → chunk-6TAASXWL.js} +4 -4
  54. package/chunks/{chunk-OJGCZBB7.js → chunk-77V3VIKL.js} +41 -36
  55. package/chunks/{chunk-2OM7GEXO.js → chunk-7KAXXBER.js} +3 -3
  56. package/chunks/{chunk-2JM6GZ5D.js → chunk-7SJN2IWT.js} +8 -13
  57. package/chunks/{chunk-UUUTRMI2.js → chunk-7ULQIS27.js} +1 -1
  58. package/chunks/{chunk-2YZJCM5T.js → chunk-A7Y5H4TX.js} +4 -4
  59. package/chunks/{chunk-TOFQCPDC.js → chunk-AOHY3QJ3.js} +14 -8
  60. package/chunks/chunk-AQ37AY7B.js +93 -0
  61. package/chunks/{chunk-B6ZJ7SI6.js → chunk-AUOULH6Q.js} +383 -320
  62. package/chunks/{chunk-PJIZUQVC.js → chunk-AZQ3DT76.js} +2 -2
  63. package/chunks/{chunk-UH3WSE5L.js → chunk-B4AJNNOL.js} +1 -6
  64. package/chunks/{chunk-7FZEBPKS.js → chunk-BBIQAX4V.js} +23 -18
  65. package/chunks/{chunk-L26JL52R.js → chunk-CBBP4BMC.js} +64 -67
  66. package/chunks/{chunk-ZD6UTE4A.js → chunk-CNTR4GR6.js} +1 -1
  67. package/chunks/{chunk-4M377AZG.js → chunk-CO2U743O.js} +6 -6
  68. package/chunks/{chunk-3SJ43L4W.js → chunk-CPZAH673.js} +6 -0
  69. package/chunks/{chunk-VFSJ5VRH.js → chunk-CU47KXB5.js} +3 -3
  70. package/chunks/{chunk-EPDRMGT4.js → chunk-D4HTUMGX.js} +4 -28
  71. package/chunks/{chunk-XHRTVPG2.js → chunk-D6MDRSZ6.js} +7 -7
  72. package/chunks/{chunk-BYFNTGKI.js → chunk-DEEABGH2.js} +3111 -989
  73. package/chunks/{chunk-XVNQMZ2I.js → chunk-DGEIYUC3.js} +0 -1
  74. package/chunks/{chunk-BPZALHVR.js → chunk-DI35ZN7T.js} +1 -1
  75. package/chunks/{chunk-B4UMZKMU.js → chunk-DQ2O5QOJ.js} +1 -1
  76. package/chunks/{chunk-DLWL3Z7A.js → chunk-DSFHVTWD.js} +3 -3
  77. package/chunks/{chunk-RWS5VYWC.js → chunk-DUNI4EBW.js} +950 -446
  78. package/chunks/{chunk-NL7LTRLR.js → chunk-E2BHWIDT.js} +48 -72
  79. package/chunks/{chunk-3MSHSCSN.js → chunk-E2FN6SM7.js} +93 -3
  80. package/chunks/{chunk-USTWD7QV.js → chunk-E6CJ2SMM.js} +26 -16
  81. package/chunks/{chunk-TF2X2WCT.js → chunk-EQNUDTL6.js} +2 -2
  82. package/chunks/{chunk-PANH4R3B.js → chunk-EU5TBFJI.js} +18 -12
  83. package/chunks/{chunk-W4CQXHT6.js → chunk-FANRZEAJ.js} +1 -1
  84. package/chunks/{chunk-WBL3FJEU.js → chunk-FC4KQFCS.js} +1 -1
  85. package/chunks/{chunk-N3FAY5CM.js → chunk-FCYYAB4S.js} +157 -4
  86. package/chunks/{chunk-OKY7HXPG.js → chunk-FJ5WUMUQ.js} +2 -2
  87. package/chunks/{chunk-M4UKFCZ2.js → chunk-FNDXMN7I.js} +231 -171
  88. package/chunks/{chunk-FQK6JAFG.js → chunk-FS674JW4.js} +4 -4
  89. package/chunks/chunk-FYJ7W2PI.js +194 -0
  90. package/chunks/{chunk-INADJJGW.js → chunk-G7XXKQYS.js} +2 -2
  91. package/chunks/{chunk-LNARWLZQ.js → chunk-GJ2GBPBD.js} +2 -2
  92. package/chunks/{chunk-E5WH5O3C.js → chunk-GL4JOZXU.js} +4 -4
  93. package/chunks/{chunk-LS77BEZP.js → chunk-GLCZKT5V.js} +1 -5
  94. package/chunks/{chunk-KU5XMLDK.js → chunk-GURGAJTX.js} +4 -1
  95. package/chunks/{chunk-5THCYPLO.js → chunk-H6I4PGRV.js} +15 -8
  96. package/chunks/{chunk-A5L3JMUA.js → chunk-HC45LTEN.js} +18 -4
  97. package/chunks/{chunk-U7TXFVUN.js → chunk-HIVKI6O6.js} +118 -95
  98. package/chunks/{chunk-QY5MMZ6O.js → chunk-HX6RLYUO.js} +3 -3
  99. package/chunks/{chunk-GZXCZHCT.js → chunk-I3G5JWBV.js} +1 -1
  100. package/chunks/{chunk-ER5LWJR6.js → chunk-I5BT7ADR.js} +3 -3
  101. package/chunks/{chunk-L5UHQJTJ.js → chunk-IGTHU3T4.js} +1 -1
  102. package/chunks/{chunk-BIQWWWJN.js → chunk-IIUGIWWY.js} +1 -1
  103. package/chunks/{chunk-ML52PL6O.js → chunk-JCJ7LKNA.js} +5856 -5334
  104. package/chunks/{chunk-B7QDM6Z7.js → chunk-JE2CEOBO.js} +2 -2
  105. package/chunks/{chunk-S3TWXGKA.js → chunk-JE7KQ2UP.js} +4 -2
  106. package/chunks/{chunk-P5V4T7NK.js → chunk-JJPKFJBT.js} +11 -3
  107. package/chunks/{chunk-J6D3VXCC.js → chunk-JLZ3RBQG.js} +18 -5
  108. package/chunks/{chunk-PWTZEM3C.js → chunk-JXVC2PL3.js} +3 -37
  109. package/chunks/chunk-JYBU6YUE.js +378 -0
  110. package/chunks/{chunk-JCW2R7WC.js → chunk-K623ENWT.js} +3 -79
  111. package/chunks/{chunk-T2NCM2ET.js → chunk-K6KS3LTN.js} +2 -749
  112. package/chunks/{chunk-Z5BLYMZM.js → chunk-KR32NIAN.js} +6 -6
  113. package/chunks/{chunk-MK7VQDN3.js → chunk-KWHKHSIS.js} +8 -6
  114. package/chunks/{chunk-5U4IPFBR.js → chunk-KXDONCPU.js} +4 -4
  115. package/chunks/{chunk-DHHOYAPR.js → chunk-L2E5GFAG.js} +7 -7
  116. package/chunks/{chunk-V6VRAM7B.js → chunk-L32VV3ZJ.js} +12 -12
  117. package/chunks/{chunk-2W3OOD4W.js → chunk-L55JWS76.js} +6 -3
  118. package/chunks/{chunk-E5TUC6CA.js → chunk-LHKCY7DY.js} +3 -3
  119. package/chunks/{chunk-NH6KE4JX.js → chunk-LOY7RWQG.js} +3 -3
  120. package/chunks/{chunk-CC4N4M36.js → chunk-LYI2PZDK.js} +1 -1
  121. package/chunks/{chunk-3JAQDSXN.js → chunk-MB32MS4U.js} +80 -9
  122. package/chunks/{chunk-PR75REBZ.js → chunk-MM7TH7ZM.js} +12 -82
  123. package/chunks/{chunk-FODK6UMO.js → chunk-MPHPFVKK.js} +0 -2
  124. package/chunks/{chunk-M5JM7OSF.js → chunk-N4ACHWNH.js} +2 -3
  125. package/chunks/{chunk-JESCGQM3.js → chunk-NAVJD2PQ.js} +8 -7
  126. package/chunks/{chunk-J56UI34H.js → chunk-NBD76HUW.js} +4 -2
  127. package/chunks/{chunk-C3NS4F2Q.js → chunk-NHFEMWAZ.js} +1 -1
  128. package/chunks/{chunk-6PSLCFQ2.js → chunk-NTDH4IML.js} +18 -9
  129. package/chunks/{chunk-6OUGMXDC.js → chunk-NWNEANAT.js} +7 -7
  130. package/chunks/chunk-O6GEWCJA.js +21 -0
  131. package/chunks/chunk-OCPBI7J5.js +18 -0
  132. package/chunks/{chunk-ZE5WPL4I.js → chunk-OFZKFPYG.js} +3 -3
  133. package/chunks/{chunk-KIUFNBHR.js → chunk-P5VC5USY.js} +1 -1
  134. package/chunks/chunk-P755N4CS.js +2196 -0
  135. package/chunks/{chunk-BRRAJXPA.js → chunk-PCK4B6LR.js} +1 -1
  136. package/chunks/{chunk-TQCBGUHN.js → chunk-PJOHNFIY.js} +5 -5
  137. package/chunks/{chunk-G4WFQUYQ.js → chunk-PVNQRENX.js} +1 -1
  138. package/chunks/{chunk-DM22XS4K.js → chunk-PZEXDV3H.js} +357 -13
  139. package/chunks/{chunk-2JZBVYTU.js → chunk-Q3T5KA2V.js} +1 -8
  140. package/chunks/{chunk-SASBXAQL.js → chunk-Q5WZTTWE.js} +4 -4
  141. package/chunks/{chunk-SRZ6DXVG.js → chunk-QARJNL2V.js} +44 -136
  142. package/chunks/{chunk-YH6G52F2.js → chunk-QCXGC7QB.js} +4 -4
  143. package/chunks/{chunk-SQBYH7PX.js → chunk-QDK4F2N5.js} +1 -1
  144. package/chunks/{chunk-VDDGDZMA.js → chunk-QHWCP53L.js} +14 -7
  145. package/chunks/{chunk-H5FFA6TH.js → chunk-QTHQ6Z5X.js} +16 -3
  146. package/chunks/{chunk-5I2IWRSH.js → chunk-R2XWGR75.js} +2 -2
  147. package/chunks/{chunk-PHVR5UUY.js → chunk-RDJOB6S3.js} +1 -1
  148. package/chunks/{chunk-GDIPH4JY.js → chunk-RG64CDT2.js} +6 -6
  149. package/chunks/{chunk-3HBZKBMQ.js → chunk-RSVPYAGK.js} +5 -5
  150. package/chunks/{chunk-6AM5D4ME.js → chunk-S6LOFUVP.js} +0 -12
  151. package/chunks/{chunk-K4XWPEWB.js → chunk-SHN4KHDK.js} +4 -33
  152. package/chunks/{chunk-VYPFXUCB.js → chunk-SZ3KHTDR.js} +1 -1
  153. package/chunks/chunk-T26EAKDL.js +13 -0
  154. package/chunks/chunk-T3CHYWJZ.js +758 -0
  155. package/chunks/{chunk-FNQ6T3CV.js → chunk-TEGJSJDF.js} +10 -7
  156. package/chunks/{chunk-OHNBB4XR.js → chunk-THVU3RNH.js} +1 -1
  157. package/chunks/{record-artifact-RQKFYO5B.js → chunk-TIRRPCFS.js} +22 -7
  158. package/chunks/chunk-TTJZAIFP.js +319 -0
  159. package/chunks/{chunk-63P4EL5V.js → chunk-TZTAV5RH.js} +1 -1
  160. package/chunks/{chunk-52O2CIUL.js → chunk-UV6KF7T3.js} +130 -5
  161. package/chunks/{chunk-QPDRAXDJ.js → chunk-V25K5ID7.js} +1 -1
  162. package/chunks/{chunk-3IXOIAKE.js → chunk-V4XNUDPE.js} +18 -6
  163. package/chunks/{chunk-WDSWXQU3.js → chunk-VEMNQMHA.js} +2 -2
  164. package/chunks/{chunk-LNURQEMZ.js → chunk-VMX5RZQH.js} +12 -10
  165. package/chunks/{chunk-JALU3ZDU.js → chunk-W3UKBMSI.js} +154 -16
  166. package/chunks/{chunk-DN6ZX5AY.js → chunk-WWCMSZII.js} +61 -14
  167. package/chunks/{chunk-COH43MRJ.js → chunk-XCGIMOLN.js} +27 -1
  168. package/chunks/{chunk-FY3M44RD.js → chunk-XP4L6KS3.js} +3 -3
  169. package/chunks/{chunk-6FGBXPWM.js → chunk-XQK4XXTN.js} +38 -44
  170. package/chunks/{chunk-A6UO2C7C.js → chunk-XUGZYLDH.js} +167 -81
  171. package/chunks/{chunk-LZEMEFKY.js → chunk-YANIWTRZ.js} +1 -1
  172. package/chunks/{chunk-IPUUTYMV.js → chunk-YDLJGZHL.js} +1 -1
  173. package/chunks/{chunk-HIJQF5B5.js → chunk-YGE3IXJP.js} +1 -1
  174. package/chunks/{chunk-BJX6ZSUK.js → chunk-YUFIEIWC.js} +2 -2
  175. package/chunks/{chunk-BO4XCS7P.js → chunk-Z3S5EMOW.js} +20 -85
  176. package/chunks/chunk-Z4X5MTRT.js +133 -0
  177. package/chunks/{chunk-UW5EOVUN.js → chunk-ZBVS26BY.js} +4 -4
  178. package/chunks/{chunk-PSWQZHEA.js → chunk-ZMOJ7ISP.js} +1 -1
  179. package/chunks/{chunk-HTO4JFDZ.js → chunk-ZPJWUGCS.js} +0 -1
  180. package/chunks/{chunk-MVS3NS2N.js → chunk-ZPZ7ZJEE.js} +28 -5
  181. package/chunks/{computer-use-DOFAHZAB.js → computer-use-5QWCFNKD.js} +52 -50
  182. package/chunks/{config-utils-VFQXVGNR.js → config-utils-WADIDWGG.js} +4 -4
  183. package/chunks/contextCommand-4Z7T7TUM.js +83 -0
  184. package/chunks/core-runtime-6N4EFC2Q.js +137 -0
  185. package/chunks/{create-sub-session-IWW2IZ2T.js → create-sub-session-62YZWVAY.js} +3 -3
  186. package/chunks/{create-sub-session-7543K2QA.js → create-sub-session-AEREHZBQ.js} +49 -47
  187. package/chunks/{cron-create-YIID5XAW.js → cron-create-6E7GIQTG.js} +6 -6
  188. package/chunks/{cron-delete-ZVHYCEP2.js → cron-delete-JD26XY3W.js} +5 -5
  189. package/chunks/{cron-list-XEGS463Q.js → cron-list-CUWFB44G.js} +6 -6
  190. package/chunks/{daemon-VOMQW7KZ.js → daemon-PCNCI5YU.js} +239 -18
  191. package/chunks/daemon-status-provider-DDF7C5M7.js +93 -0
  192. package/chunks/daemon-trust-policy-Q4KSOJTR.js +88 -0
  193. package/chunks/daemon-trust-policy-monitor-V6FTE3IY.js +175 -0
  194. package/chunks/{de-HGRCYDEJ.js → de-SY6O76BF.js} +6 -1
  195. package/chunks/deferred-core-runtime-GHJ5GQHK.js +92 -0
  196. package/chunks/dist-26BIMQT6.js +4487 -0
  197. package/chunks/{dist-KTYYJ2C5.js → dist-2PERFI23.js} +12 -9
  198. package/chunks/{dist-NNVBBOGU.js → dist-OAOC5OV4.js} +2 -2
  199. package/chunks/{dist-K6Y4E7FX.js → dist-PVEAFLHY.js} +5 -4
  200. package/chunks/{dist-RTJFMNEZ.js → dist-SL2LUMML.js} +1449 -14
  201. package/chunks/dist-ULIG4M5H.js +13415 -0
  202. package/chunks/{dist-ANLAT3GS.js → dist-WGMNT3JQ.js} +2 -1
  203. package/chunks/{dist-BRB6EXK4.js → dist-ZHXOBXDN.js} +3 -3
  204. package/chunks/earlyInputCapture-TQXLLISD.js +85 -0
  205. package/chunks/{edit-RIEOJWKB.js → edit-FJEUV6KZ.js} +51 -49
  206. package/chunks/{en-MTWBNGDO.js → en-NBK3JKCE.js} +9 -1
  207. package/chunks/{enter-worktree-OGK5FQ3R.js → enter-worktree-7GE3TZ4P.js} +51 -49
  208. package/chunks/{enterPlanMode-IWZYALIB.js → enterPlanMode-KR5TMPCJ.js} +51 -49
  209. package/chunks/environment-SWL3CMB3.js +105 -0
  210. package/chunks/errors-XQE7BGZV.js +91 -0
  211. package/chunks/esm-K5FARBNI.js +5548 -0
  212. package/chunks/{exit-worktree-4TEYVIVP.js → exit-worktree-CHKTYNCV.js} +51 -49
  213. package/chunks/exitPlanMode-QYAG6LWX.js +76 -0
  214. package/chunks/{fast-path-HYE7IFEV.js → fast-path-Z2K7W6DC.js} +13 -3
  215. package/chunks/{fr-45RLL55O.js → fr-4KG5V7UT.js} +6 -1
  216. package/chunks/{gemini-NGRQX3YJ.js → gemini-YU4XKEDG.js} +107 -103
  217. package/chunks/{geminiContentGenerator-FQHPFZSR.js → geminiContentGenerator-ZZX6NBO4.js} +7 -7
  218. package/chunks/{getMachineId-bsd-V7W3GODC.js → getMachineId-bsd-FG7IUY6U.js} +1 -1
  219. package/chunks/{getMachineId-darwin-TDO75DQP.js → getMachineId-darwin-GLCJI2RA.js} +1 -1
  220. package/chunks/{getMachineId-linux-TF43WQT2.js → getMachineId-linux-O6OPPAKO.js} +1 -1
  221. package/chunks/{getMachineId-unsupported-ZGUO3TXT.js → getMachineId-unsupported-S6CKYVGC.js} +1 -1
  222. package/chunks/{getMachineId-win-ECFYZZFQ.js → getMachineId-win-X5SRNEH7.js} +1 -1
  223. package/chunks/{glob-FRTM3X2E.js → glob-VYF5CXSX.js} +51 -49
  224. package/chunks/goal-tools-HGO6VXPB.js +335 -0
  225. package/chunks/{grep-RKWVROCW.js → grep-5DP5ZUTW.js} +53 -50
  226. package/chunks/handleAutoUpdate-UVBJ56DL.js +84 -0
  227. package/chunks/i18n-UQNYHEUD.js +100 -0
  228. package/chunks/{image-gen-WIEM7KZA.js → image-gen-WHPIZNWF.js} +12 -12
  229. package/chunks/initializer-GMIICF4W.js +89 -0
  230. package/chunks/installationInfo-4MGG4WVI.js +83 -0
  231. package/chunks/{ja-B7DF7DFG.js → ja-F3GSQXMF.js} +6 -1
  232. package/chunks/{keychain-token-storage-MDTG3WRM.js → keychain-token-storage-IKO4G53C.js} +3 -3
  233. package/chunks/lib-RUF3WZA6.js +9 -0
  234. package/chunks/list-CPN2W334.js +92 -0
  235. package/chunks/{list-agents-5KJJHR6I.js → list-agents-PXJ7ZUFB.js} +3 -3
  236. package/chunks/loadedSettingsAdapter-ZQAV5NDO.js +86 -0
  237. package/chunks/{loggingContentGenerator-WGM27QAW.js → loggingContentGenerator-5E7W4IEP.js} +31 -30
  238. package/chunks/{loop-wakeup-FXKNNYSY.js → loop-wakeup-Y26NQZ5I.js} +15 -8
  239. package/chunks/{ls-NTK6VOQJ.js → ls-ONQTTMQR.js} +5 -5
  240. package/chunks/{lsp-2JI24STP.js → lsp-YGHHRGMD.js} +3 -3
  241. package/chunks/{managed-npm-update-JQ2CG3RH.js → managed-npm-update-MKKAXYXA.js} +50 -48
  242. package/chunks/mcp-V5NTJF6X.js +86 -0
  243. package/chunks/{monitor-7FEWXX5F.js → monitor-CO3ASY6E.js} +51 -49
  244. package/chunks/nonInteractiveCli-ZJYEOO7U.js +148 -0
  245. package/chunks/{notebook-edit-JGJV2K6J.js → notebook-edit-Z7AEE6FM.js} +51 -49
  246. package/chunks/{openaiContentGenerator-JPVXDTAO.js → openaiContentGenerator-CA3MQOP3.js} +25 -27
  247. package/chunks/pidfile-NL7MKDRU.js +89 -0
  248. package/chunks/process-registry-2CHQBXH5.js +157 -0
  249. package/chunks/{processUtils-V2LCK6T6.js → processUtils-PB5K2DYH.js} +2 -2
  250. package/chunks/{pt-22Q3FP73.js → pt-EQ33KWEN.js} +6 -1
  251. package/chunks/{qwenContentGenerator-TICV2W2Z.js → qwenContentGenerator-JYFNDCOS.js} +55 -53
  252. package/chunks/{qwenOAuth2-XGFI5XJG.js → qwenOAuth2-W2ALKQDD.js} +10 -10
  253. package/chunks/read-file-IEOR5H5W.js +29 -0
  254. package/chunks/{read-mcp-resource-4DKQWGHD.js → read-mcp-resource-U2IJN5HM.js} +4 -4
  255. package/chunks/record-artifact-MGPJ7EG4.js +21 -0
  256. package/chunks/resumeHistoryUtils-BNBTP5AS.js +94 -0
  257. package/chunks/ripGrep-UMQODKEB.js +76 -0
  258. package/chunks/{ru-FZCNZHDC.js → ru-7OZAUKGG.js} +6 -1
  259. package/chunks/{run-qwen-serve-3VCV4I7E.js → run-qwen-serve-RN2R6QQW.js} +982 -263
  260. package/chunks/runtime-QFJ2MJF5.js +122 -0
  261. package/chunks/{scheduler-RS2I6RU5.js → scheduler-AMYUFOZI.js} +49 -47
  262. package/chunks/{sdk-exporters-grpc-AK3LGHNO.js → sdk-exporters-grpc-54L4LS5L.js} +4 -4
  263. package/chunks/{sdk-exporters-http-FS6ZV7MF.js → sdk-exporters-http-4BQANSJ6.js} +7 -7
  264. package/chunks/{sdk-impl-7FZSCSXB.js → sdk-impl-Z4VXWVFX.js} +10 -10
  265. package/chunks/{send-message-Q6OOR6BR.js → send-message-PMP4ATVM.js} +8 -13
  266. package/chunks/serve-EIIYJVX3.js +92 -0
  267. package/chunks/{server-HRZ23U7M.js → server-EP2LLAPD.js} +4816 -1298
  268. package/chunks/{session-7XHZKTVV.js → session-GMPZBLOW.js} +101 -97
  269. package/chunks/{settings-7ZGZDXAS.js → settings-LN7RNKBS.js} +53 -51
  270. package/chunks/shell-EM2OWU5X.js +86 -0
  271. package/chunks/{skill-LIWXNLDW.js → skill-T5VPSK73.js} +22 -23
  272. package/chunks/skill-settings-GMR3GMNY.js +94 -0
  273. package/chunks/spawnChannel-YPCU62DI.js +85 -0
  274. package/chunks/standalone-update-JAKIM2NF.js +95 -0
  275. package/chunks/{startInteractiveUI-IW3CSKHA.js → startInteractiveUI-YETQWGYF.js} +1240 -903
  276. package/chunks/{syntheticOutput-I3757IWH.js → syntheticOutput-D7E6ZFKR.js} +4 -4
  277. package/chunks/task-create-NFCYD43L.js +26 -0
  278. package/chunks/{task-list-FOPULZEP.js → task-list-TAVMGEVD.js} +7 -7
  279. package/chunks/{task-stop-H6RHXFVQ.js → task-stop-ZDF2UJRM.js} +3 -3
  280. package/chunks/{task-update-M57TFZJT.js → task-update-6L7LHGEX.js} +12 -11
  281. package/chunks/{team-create-O2FROQ4R.js → team-create-LFJ6HGNY.js} +53 -51
  282. package/chunks/{team-delete-QE2UXJL7.js → team-delete-DPGGRQBU.js} +7 -7
  283. package/chunks/{team-plan-approval-Q6WDBXTQ.js → team-plan-approval-C2KLSDGO.js} +51 -49
  284. package/chunks/theme-manager-JQ3ZGBP5.js +80 -0
  285. package/chunks/{todoWrite-VQ7FKOHL.js → todoWrite-2UO5G6G6.js} +34 -6
  286. package/chunks/{tool-search-APECNQ3Z.js → tool-search-FAZBFRJZ.js} +21 -22
  287. package/chunks/total-session-admission-5CALIVYO.js +88 -0
  288. package/chunks/{tree-sitter-FS4VPMZA.js → tree-sitter-4D7QS7F6.js} +1 -1
  289. package/chunks/{tree-sitter-bash-6B46JJCV.js → tree-sitter-bash-VEJGF5XF.js} +1 -1
  290. package/chunks/trustedFolders-KOPSP44S.js +98 -0
  291. package/chunks/{update-relaunch-ON5MDJQG.js → update-relaunch-6QL2TICS.js} +5 -5
  292. package/chunks/updateCheck-4Q6RIKFW.js +95 -0
  293. package/chunks/useAutoAcceptIndicator-Q5BMKZV3.js +96 -0
  294. package/chunks/{validateNonInterActiveAuth-JBLKBKRD.js → validateNonInterActiveAuth-GKOC5F6Z.js} +95 -91
  295. package/chunks/{version-LTNUBQJY.js → version-VSATY2LD.js} +1 -1
  296. package/chunks/{web-fetch-L5UTI53V.js → web-fetch-JCLKL6NL.js} +19 -21
  297. package/chunks/{web-search-KM33JOS3.js → web-search-DSQTFUBX.js} +13 -13
  298. package/chunks/{workflow-K7FAWV77.js → workflow-M6QAVKVJ.js} +52 -50
  299. package/chunks/workspace-providers-status-YKLTLMJA.js +89 -0
  300. package/chunks/{workspace-registration-store-6TGVDJV5.js → workspace-registration-store-5DMGKU64.js} +1 -1
  301. package/chunks/workspace-registry-PTYUSYXX.js +96 -0
  302. package/chunks/workspace-service-25ML3T47.js +103 -0
  303. package/chunks/workspace-skills-status-YKZWOYRX.js +89 -0
  304. package/chunks/workspace-trust-reconciler-5FI2S3OS.js +349 -0
  305. package/chunks/write-file-AY7VLP5X.js +78 -0
  306. package/chunks/xterm-headless-NTYVIBT3.js +3475 -0
  307. package/chunks/{zh-LUIGBD55.js → zh-H3YDK5QW.js} +9 -1
  308. package/chunks/{zh-TW-F5KG2IYD.js → zh-TW-JYCP7XUA.js} +9 -1
  309. package/chunks/zoom-image-S4LJZMD5.js +224 -0
  310. package/cli.js +50 -16
  311. package/locales/ca.js +7 -2
  312. package/locales/de.js +7 -2
  313. package/locales/en.js +10 -2
  314. package/locales/fr.js +7 -2
  315. package/locales/ja.js +7 -2
  316. package/locales/pt.js +7 -2
  317. package/locales/ru.js +7 -2
  318. package/locales/zh-TW.js +10 -2
  319. package/locales/zh.js +10 -2
  320. package/package.json +5 -4
  321. package/web-shell/assets/{arc-BbHijhiN.js → arc-xjArKHU2.js} +1 -1
  322. package/web-shell/assets/{architectureDiagram-3BPJPVTR-Cb4B_JD0.js → architectureDiagram-3BPJPVTR-BgrQDNYG.js} +1 -1
  323. package/web-shell/assets/{blockDiagram-GPEHLZMM-Dsjlh3H-.js → blockDiagram-GPEHLZMM-CXxWC-1_.js} +1 -1
  324. package/web-shell/assets/{c4Diagram-AAUBKEIU-Cp5AeR4U.js → c4Diagram-AAUBKEIU-Dx1tLm3v.js} +1 -1
  325. package/web-shell/assets/channel-B1cyk94G.js +1 -0
  326. package/web-shell/assets/{chunk-2J33WTMH-CLcY7W2e.js → chunk-2J33WTMH-CBxjogVR.js} +1 -1
  327. package/web-shell/assets/{chunk-4BX2VUAB-BUhvY2LR.js → chunk-4BX2VUAB-izb-rY5W.js} +1 -1
  328. package/web-shell/assets/{chunk-55IACEB6-kDIFC_71.js → chunk-55IACEB6-NzLyvSb8.js} +1 -1
  329. package/web-shell/assets/{chunk-727SXJPM-CIBO15f2.js → chunk-727SXJPM-DVyKb0dl.js} +1 -1
  330. package/web-shell/assets/{chunk-AQP2D5EJ-BJ_T_slV.js → chunk-AQP2D5EJ-BtqL7NzB.js} +1 -1
  331. package/web-shell/assets/{chunk-FMBD7UC4-BEkW35J8.js → chunk-FMBD7UC4-iNpdKIO0.js} +1 -1
  332. package/web-shell/assets/{chunk-ND2GUHAM-GGPxofay.js → chunk-ND2GUHAM-DI7cbFmX.js} +1 -1
  333. package/web-shell/assets/{chunk-QZHKN3VN-Bifllrb6.js → chunk-QZHKN3VN-3Y_-xFYs.js} +1 -1
  334. package/web-shell/assets/classDiagram-4FO5ZUOK-BpBYZoRE.js +1 -0
  335. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BpBYZoRE.js +1 -0
  336. package/web-shell/assets/{cose-bilkent-S5V4N54A-C-Add_Dp.js → cose-bilkent-S5V4N54A--raRatZn.js} +1 -1
  337. package/web-shell/assets/{dagre-BM42HDAG-B7MfwNq2.js → dagre-BM42HDAG-B8SU70mO.js} +1 -1
  338. package/web-shell/assets/{diagram-2AECGRRQ-CY_0zuDz.js → diagram-2AECGRRQ-ewgoakXo.js} +1 -1
  339. package/web-shell/assets/{diagram-5GNKFQAL-VyYSbCgA.js → diagram-5GNKFQAL-Bm_JLTnS.js} +1 -1
  340. package/web-shell/assets/{diagram-KO2AKTUF-CBiIZ2PL.js → diagram-KO2AKTUF-DEIUjUy9.js} +1 -1
  341. package/web-shell/assets/{diagram-LMA3HP47-BL3CrVOx.js → diagram-LMA3HP47-C2Wmrpj-.js} +1 -1
  342. package/web-shell/assets/{diagram-OG6HWLK6-CZUPx96P.js → diagram-OG6HWLK6-CtYe6bFx.js} +1 -1
  343. package/web-shell/assets/{erDiagram-TEJ5UH35-B81xHr1-.js → erDiagram-TEJ5UH35-DfpHcWLV.js} +1 -1
  344. package/web-shell/assets/{flowDiagram-I6XJVG4X-EZWhir-J.js → flowDiagram-I6XJVG4X-CAiUhio5.js} +1 -1
  345. package/web-shell/assets/{ganttDiagram-6RSMTGT7-CVFSuIAg.js → ganttDiagram-6RSMTGT7-CYc7ezr4.js} +1 -1
  346. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-C1H2uQDv.js → gitGraphDiagram-PVQCEYII-70lbkcRS.js} +1 -1
  347. package/web-shell/assets/index-C1k3PDuU.css +5 -0
  348. package/web-shell/assets/index-C2GE3DAF.js +74 -0
  349. package/web-shell/assets/index-DZLIXILO.js +1750 -0
  350. package/web-shell/assets/{index-BYo99NBH.js → index-Ww86nT9f.js} +1 -1
  351. package/web-shell/assets/{infoDiagram-5YYISTIA-BwyFMlF8.js → infoDiagram-5YYISTIA-C7e8DWPa.js} +1 -1
  352. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-CQ7Yhn2Y.js → ishikawaDiagram-YF4QCWOH-BYLr2op-.js} +1 -1
  353. package/web-shell/assets/{journeyDiagram-JHISSGLW-CJn2sf0l.js → journeyDiagram-JHISSGLW-hEibAHKX.js} +1 -1
  354. package/web-shell/assets/{kanban-definition-UN3LZRKU-DaNRqwVN.js → kanban-definition-UN3LZRKU-F2rt8Uhp.js} +1 -1
  355. package/web-shell/assets/{linear-DCKODZe2.js → linear-DPhyNezd.js} +1 -1
  356. package/web-shell/assets/{mermaid.core-CTGJOk27.js → mermaid.core-ZUtnug0n.js} +5 -5
  357. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BKU3_3rg.js → mindmap-definition-RKZ34NQL-DDWcMoi8.js} +1 -1
  358. package/web-shell/assets/{pieDiagram-4H26LBE5-COcwBJ82.js → pieDiagram-4H26LBE5-CTRKzw1_.js} +1 -1
  359. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-CQnQ443x.js → quadrantDiagram-W4KKPZXB-CAEwYG_z.js} +1 -1
  360. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CZ2oj5cD.js → requirementDiagram-4Y6WPE33-CRjnH9D9.js} +1 -1
  361. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BxAv5mNu.js → sankeyDiagram-5OEKKPKP-LPQT_sOd.js} +1 -1
  362. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CztaySPs.js → sequenceDiagram-3UESZ5HK-Ht2Iqvb0.js} +1 -1
  363. package/web-shell/assets/{stateDiagram-AJRCARHV-CTQT1oGD.js → stateDiagram-AJRCARHV-CIUdqOXu.js} +1 -1
  364. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BmqqQZ6w.js +1 -0
  365. package/web-shell/assets/{timeline-definition-PNZ67QCA-K9Mkex5A.js → timeline-definition-PNZ67QCA-BcilneZF.js} +1 -1
  366. package/web-shell/assets/{vennDiagram-CIIHVFJN-B2rVIw76.js → vennDiagram-CIIHVFJN-BljwiiH1.js} +1 -1
  367. package/web-shell/assets/{wardley-L42UT6IY-Z1w2JR4M.js → wardley-L42UT6IY-DeKjkYjq.js} +1 -1
  368. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-CIX9aKXf.js → wardleyDiagram-YWT4CUSO-L3U1H7KG.js} +1 -1
  369. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CI9DLIKB.js → xychartDiagram-2RQKCTM6-IJnWsgMT.js} +1 -1
  370. package/web-shell/index.html +2 -2
  371. package/chunks/MaxSizedBox-INHRH72H.js +0 -86
  372. package/chunks/agent-VXDAN5JK.js +0 -82
  373. package/chunks/agent-headless-K4ZMMNBD.js +0 -76
  374. package/chunks/bridge-LGPZCFHO.js +0 -91
  375. package/chunks/channel-settings-store-CHCDRTPY.js +0 -89
  376. package/chunks/chunk-SZRN75WQ.js +0 -29
  377. package/chunks/chunk-UGYMA4EI.js +0 -219
  378. package/chunks/chunk-VCBZUOSI.js +0 -8575
  379. package/chunks/contextCommand-QIZYHDR5.js +0 -81
  380. package/chunks/daemon-status-provider-OS5UWBHV.js +0 -90
  381. package/chunks/earlyInputCapture-WQT24RWD.js +0 -83
  382. package/chunks/environment-VZ7BRI4Q.js +0 -103
  383. package/chunks/errors-PCX25DVP.js +0 -89
  384. package/chunks/exitPlanMode-GHPUHBZJ.js +0 -423
  385. package/chunks/handleAutoUpdate-2CZQRJ66.js +0 -82
  386. package/chunks/i18n-XEQVMRKN.js +0 -98
  387. package/chunks/initializer-OVGZ4FLY.js +0 -87
  388. package/chunks/installationInfo-5UUQJI6Y.js +0 -81
  389. package/chunks/list-HODU6RXD.js +0 -90
  390. package/chunks/loadedSettingsAdapter-TYNLBALY.js +0 -84
  391. package/chunks/mcp-J3DFWX4A.js +0 -84
  392. package/chunks/nonInteractiveCli-F4GYSMHT.js +0 -144
  393. package/chunks/pidfile-4VNAR3EP.js +0 -87
  394. package/chunks/read-file-LZXUR4TO.js +0 -31
  395. package/chunks/resumeHistoryUtils-65OX3SGJ.js +0 -92
  396. package/chunks/ripGrep-2U2FRGMV.js +0 -74
  397. package/chunks/runtime-AXJWIEDU.js +0 -120
  398. package/chunks/serve-W2GC47CM.js +0 -90
  399. package/chunks/shell-45IPBDP5.js +0 -84
  400. package/chunks/spawnChannel-PVXQ5AGV.js +0 -83
  401. package/chunks/src-AY65BYR7.js +0 -3166
  402. package/chunks/standalone-update-ZMFNKAEY.js +0 -93
  403. package/chunks/task-create-N7WQSGYA.js +0 -25
  404. package/chunks/theme-manager-YYPZFBAH.js +0 -78
  405. package/chunks/total-session-admission-JXES723M.js +0 -85
  406. package/chunks/trustedFolders-HVI7IXUH.js +0 -94
  407. package/chunks/updateCheck-WUJGHWZZ.js +0 -93
  408. package/chunks/useAutoAcceptIndicator-CHSTZLZD.js +0 -94
  409. package/chunks/workspace-providers-status-GAKSF4LL.js +0 -87
  410. package/chunks/workspace-registry-A7NQUONG.js +0 -89
  411. package/chunks/workspace-service-STGVSO4N.js +0 -99
  412. package/chunks/workspace-skills-status-66AK3DUA.js +0 -86
  413. package/chunks/write-file-HUUCEG4P.js +0 -74
  414. package/web-shell/assets/channel-Bzdx6E8P.js +0 -1
  415. package/web-shell/assets/classDiagram-4FO5ZUOK-Cd6wbiuK.js +0 -1
  416. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Cd6wbiuK.js +0 -1
  417. package/web-shell/assets/index-B2bXx96W.js +0 -1249
  418. package/web-shell/assets/index-_8mKjx8q.css +0 -5
  419. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BjMdT6E_.js +0 -1
  420. package/chunks/{chunk-TARRHLLG.js → chunk-QUGAUQGJ.js} +25 -25
  421. package/chunks/{chunk-U7ZFW55U.js → chunk-VOQXFAY5.js} +977 -977
  422. /package/chunks/{chunk-LXXMOYPL.js → chunk-VXZBKKQR.js} +0 -0
@@ -1,8 +1,5 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import {
4
- recomputeMcpGating
5
- } from "./chunk-2JM6GZ5D.js";
6
3
  import {
7
4
  classifyApiError
8
5
  } from "./chunk-V7RNNPGC.js";
@@ -15,50 +12,48 @@ import {
15
12
  matchMcpServerByRef,
16
13
  parseExtensionRef,
17
14
  parseMcpServerRef
18
- } from "./chunk-GDIPH4JY.js";
15
+ } from "./chunk-RG64CDT2.js";
19
16
  import {
20
17
  getAvailableCommands,
21
18
  handleSlashCommand,
22
19
  insertAfterFunctionResponses,
23
20
  isSlashCommand,
24
21
  normalizePartList
25
- } from "./chunk-M4UKFCZ2.js";
22
+ } from "./chunk-FNDXMN7I.js";
23
+ import {
24
+ collectContextData,
25
+ formatContextUsageText
26
+ } from "./chunk-H6I4PGRV.js";
27
+ import {
28
+ recomputeMcpGating
29
+ } from "./chunk-7SJN2IWT.js";
26
30
  import {
27
31
  appEvents,
28
32
  buildDisabledSkillNamesProvider,
29
33
  cleanupReviewWorktreeLeases,
30
34
  loadCliConfig,
31
35
  normalizeDisabledToolList
32
- } from "./chunk-BYFNTGKI.js";
33
- import "./chunk-PQNHRFJC.js";
34
- import {
35
- collectContextData,
36
- formatContextUsageText
37
- } from "./chunk-5THCYPLO.js";
36
+ } from "./chunk-DEEABGH2.js";
38
37
  import {
39
38
  getCommandSubcommandNames
40
- } from "./chunk-PHVR5UUY.js";
39
+ } from "./chunk-RDJOB6S3.js";
41
40
  import {
42
41
  getEffectiveSupportedModes
43
- } from "./chunk-52O2CIUL.js";
44
- import "./chunk-J56UI34H.js";
42
+ } from "./chunk-UV6KF7T3.js";
45
43
  import "./chunk-4WGODMVR.js";
46
- import "./chunk-ZE5WPL4I.js";
47
- import "./chunk-YAF2MQZ6.js";
48
- import "./chunk-L5UHQJTJ.js";
49
- import {
50
- computeCpuPercent
51
- } from "./chunk-HGT6JR3U.js";
52
- import "./chunk-3IXOIAKE.js";
53
- import "./chunk-6H67XLET.js";
44
+ import "./chunk-PQNHRFJC.js";
45
+ import "./chunk-NBD76HUW.js";
46
+ import "./chunk-IGTHU3T4.js";
54
47
  import {
55
48
  beginAcpBootstrapConfigProfiling,
56
49
  buildAndFreezeAcpStartupProfile,
57
50
  endAcpBootstrapConfigProfiling,
58
51
  markAcpStartup
59
- } from "./chunk-HIJQF5B5.js";
60
- import "./chunk-5U4IPFBR.js";
61
- import "./chunk-VFSJ5VRH.js";
52
+ } from "./chunk-YGE3IXJP.js";
53
+ import "./chunk-KXDONCPU.js";
54
+ import "./chunk-CU47KXB5.js";
55
+ import "./chunk-OFZKFPYG.js";
56
+ import "./chunk-YAF2MQZ6.js";
62
57
  import {
63
58
  GENERATION_MAX_PROMPT_BYTES,
64
59
  GENERATION_TIMEOUT_MS,
@@ -78,7 +73,7 @@ import {
78
73
  shouldSuppressRememberErrorDetails,
79
74
  workspaceMemoryFailureCode,
80
75
  workspaceMemoryFailureDiagnostics
81
- } from "./chunk-J6D3VXCC.js";
76
+ } from "./chunk-JLZ3RBQG.js";
82
77
  import {
83
78
  HistoryReplayer,
84
79
  MessageEmitter,
@@ -88,68 +83,57 @@ import {
88
83
  goalTerminalEventToHistoryItem,
89
84
  recordGoalStatusItem,
90
85
  restoreGoalFromHistory
91
- } from "./chunk-DM22XS4K.js";
92
- import "./chunk-RHLZR4E5.js";
93
- import "./chunk-IPUUTYMV.js";
94
- import "./chunk-BRRAJXPA.js";
86
+ } from "./chunk-PZEXDV3H.js";
87
+ import "./chunk-675H6PLP.js";
88
+ import "./chunk-YDLJGZHL.js";
89
+ import "./chunk-PCK4B6LR.js";
95
90
  import "./chunk-2MIN6GRR.js";
96
91
  import "./chunk-QHTIBUWB.js";
97
92
  import {
98
93
  isTerminalGoalStatusKind
99
94
  } from "./chunk-QTERJVPZ.js";
100
95
  import "./chunk-3Z43GZUQ.js";
96
+ import {
97
+ computeCpuPercent
98
+ } from "./chunk-HGT6JR3U.js";
101
99
  import "./chunk-RXFQM6FQ.js";
100
+ import "./chunk-V4XNUDPE.js";
101
+ import "./chunk-6H67XLET.js";
102
+ import {
103
+ mapSkillConfigToStatus
104
+ } from "./chunk-L55JWS76.js";
102
105
  import {
103
106
  PERMISSION_RULE_TYPES,
104
107
  PermissionRulesValidationError,
105
108
  buildPermissionSettings,
106
109
  normalizePermissionRules,
107
110
  readPermissionRuleSet
108
- } from "./chunk-LZEMEFKY.js";
111
+ } from "./chunk-YANIWTRZ.js";
109
112
  import {
110
113
  MAX_AUDIO_BYTES,
111
114
  sanitizeVoiceErrorMessage,
112
115
  transcribeVoiceAudio
113
- } from "./chunk-2OM7GEXO.js";
116
+ } from "./chunk-7KAXXBER.js";
114
117
  import {
115
118
  readVoiceModel
116
- } from "./chunk-KIUFNBHR.js";
117
- import "./chunk-ZD6UTE4A.js";
118
- import "./chunk-XHRTVPG2.js";
119
- import "./chunk-2YZJCM5T.js";
120
- import "./chunk-57OAHC2Y.js";
119
+ } from "./chunk-P5VC5USY.js";
120
+ import "./chunk-CNTR4GR6.js";
121
121
  import {
122
122
  createLoadedSettingsAdapter
123
- } from "./chunk-G4WFQUYQ.js";
124
- import "./chunk-LXXMOYPL.js";
125
- import "./chunk-SASBXAQL.js";
123
+ } from "./chunk-PVNQRENX.js";
124
+ import "./chunk-VXZBKKQR.js";
125
+ import "./chunk-Q5WZTTWE.js";
126
126
  import "./chunk-E5Z2AVNV.js";
127
127
  import {
128
+ SESSION_SOURCE_META_KEY,
128
129
  parseSessionSource
129
- } from "./chunk-66RMLJHC.js";
130
+ } from "./chunk-44F4LBWZ.js";
130
131
  import "./chunk-GLWP3FDB.js";
131
- import "./chunk-COH43MRJ.js";
132
- import {
133
- CHANNEL_STARTUP_PROFILE_META_KEY,
134
- CHANNEL_STARTUP_PROFILE_VERSION,
135
- CLIENT_MCP_OVER_WS_CONFIG_FLAG,
136
- DAEMON_CHANNEL_DELIVERY_META_KEY,
137
- LOAD_REPLAY_BULK_MODE,
138
- LOAD_REPLAY_META_KEY,
139
- LOAD_REPLAY_MODE_META_KEY,
140
- LOAD_REPLAY_PAGE_SIZE_META_KEY,
141
- LOAD_REPLAY_VERSION,
142
- MID_TURN_QUEUE_DRAIN_METHOD,
143
- PROMPT_CANCEL_METHOD,
144
- TODO_STOP_GUARD_QUEUE_RELEASE_METHOD
145
- } from "./chunk-3SJ43L4W.js";
146
- import {
147
- NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE,
148
- isNotCurrentlyGeneratingCancelError
149
- } from "./chunk-UH3WSE5L.js";
132
+ import "./chunk-XCGIMOLN.js";
133
+ import "./chunk-OCPBI7J5.js";
150
134
  import {
151
135
  ndJsonStream
152
- } from "./chunk-A6UO2C7C.js";
136
+ } from "./chunk-XUGZYLDH.js";
153
137
  import {
154
138
  ACP_ROUTE_ID_PREFIX,
155
139
  buildAcpModelOptions,
@@ -158,10 +142,7 @@ import {
158
142
  parseAcpModelOption,
159
143
  resolveAcpModelOption,
160
144
  sanitizeProviderBaseUrl
161
- } from "./chunk-LG4GZIVV.js";
162
- import {
163
- mapSkillConfigToStatus
164
- } from "./chunk-2W3OOD4W.js";
145
+ } from "./chunk-6TAASXWL.js";
165
146
  import {
166
147
  ACP_PREFLIGHT_KINDS,
167
148
  IDLE_HOOK_EVENTS,
@@ -169,30 +150,57 @@ import {
169
150
  SERVE_STATUS_EXT_METHODS,
170
151
  STATUS_SCHEMA_VERSION,
171
152
  mapDomainErrorToErrorKind
172
- } from "./chunk-KU5XMLDK.js";
173
- import "./chunk-MVS3NS2N.js";
174
- import "./chunk-ER5LWJR6.js";
175
- import "./chunk-W4CQXHT6.js";
176
- import "./chunk-MK7VQDN3.js";
153
+ } from "./chunk-GURGAJTX.js";
154
+ import {
155
+ resolveSkillSettings
156
+ } from "./chunk-Z4X5MTRT.js";
157
+ import "./chunk-D6MDRSZ6.js";
158
+ import "./chunk-A7Y5H4TX.js";
159
+ import "./chunk-57OAHC2Y.js";
160
+ import "./chunk-I5BT7ADR.js";
161
+ import "./chunk-FANRZEAJ.js";
162
+ import "./chunk-KWHKHSIS.js";
177
163
  import "./chunk-V6WHFGST.js";
178
164
  import {
179
- assembleMcpServers,
180
- loadMcpApprovals
181
- } from "./chunk-Z5BLYMZM.js";
182
- import "./chunk-LNARWLZQ.js";
165
+ CHANNEL_STARTUP_PROFILE_META_KEY,
166
+ CHANNEL_STARTUP_PROFILE_VERSION,
167
+ CLIENT_MCP_OVER_WS_CONFIG_FLAG,
168
+ DAEMON_CHANNEL_DELIVERY_META_KEY,
169
+ LOAD_REPLAY_BULK_MODE,
170
+ LOAD_REPLAY_HIDE_INHERITED_META_KEY,
171
+ LOAD_REPLAY_META_KEY,
172
+ LOAD_REPLAY_MODE_META_KEY,
173
+ LOAD_REPLAY_PAGE_SIZE_META_KEY,
174
+ LOAD_REPLAY_VERSION,
175
+ MID_TURN_QUEUE_DRAIN_METHOD,
176
+ PROMPT_CANCEL_METHOD,
177
+ TODO_STOP_GUARD_CONTINUATION_CLAIM_METHOD,
178
+ TODO_STOP_GUARD_QUEUE_RELEASE_METHOD,
179
+ WORKTREE_MCP_DEFER_META_KEY
180
+ } from "./chunk-CPZAH673.js";
181
+ import {
182
+ NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE,
183
+ isNotCurrentlyGeneratingCancelError
184
+ } from "./chunk-B4AJNNOL.js";
183
185
  import "./chunk-2RFKHEXL.js";
186
+ import "./chunk-FYJ7W2PI.js";
184
187
  import "./chunk-U4VTUMMK.js";
185
- import "./chunk-HV3G62R6.js";
188
+ import "./chunk-6MPDY6ZG.js";
186
189
  import "./chunk-ALMR3E6Q.js";
187
190
  import "./chunk-BK2UNYWD.js";
188
191
  import "./chunk-M5GB774H.js";
189
- import "./chunk-ML52PL6O.js";
192
+ import "./chunk-IIUGIWWY.js";
193
+ import "./chunk-ZPZ7ZJEE.js";
194
+ import "./chunk-JCJ7LKNA.js";
190
195
  import {
191
196
  AgentSideConnection,
192
197
  PROTOCOL_VERSION,
193
198
  RequestError
194
199
  } from "./chunk-UDXSXLER.js";
195
- import "./chunk-BIQWWWJN.js";
200
+ import {
201
+ assembleMcpServers,
202
+ loadMcpApprovals
203
+ } from "./chunk-KR32NIAN.js";
196
204
  import {
197
205
  getOutputLanguageFilePath,
198
206
  getPersistScopeForModelSelection,
@@ -201,7 +209,7 @@ import {
201
209
  resolveOutputLanguageOrPreserveAuto,
202
210
  updateOutputLanguageFile,
203
211
  writeOutputLanguageAndRegisterPath
204
- } from "./chunk-JALU3ZDU.js";
212
+ } from "./chunk-W3UKBMSI.js";
205
213
  import "./chunk-RKUWKYED.js";
206
214
  import "./chunk-GOXKNSDZ.js";
207
215
  import {
@@ -212,27 +220,28 @@ import {
212
220
  SUPPORTED_LANGUAGES,
213
221
  getCurrentLanguage,
214
222
  setLanguageAsync
215
- } from "./chunk-VV6XU5L7.js";
223
+ } from "./chunk-3F2WDAV6.js";
216
224
  import {
217
225
  findEnvFiles,
218
226
  preResolveHomeEnvOverrides,
219
227
  reloadEnvironment
220
- } from "./chunk-PANH4R3B.js";
228
+ } from "./chunk-EU5TBFJI.js";
221
229
  import "./chunk-6PEXNQTX.js";
222
- import "./chunk-I7XZ3RY5.js";
223
- import "./chunk-VJNBRRZG.js";
230
+ import "./chunk-GJ2GBPBD.js";
224
231
  import {
225
232
  isFolderTrustEnabled,
226
233
  isWorkspaceTrusted,
227
234
  loadTrustedFolders
228
- } from "./chunk-VCBZUOSI.js";
235
+ } from "./chunk-P755N4CS.js";
229
236
  import "./chunk-ALGGS7UH.js";
230
237
  import "./chunk-MR3PXB6E.js";
238
+ import "./chunk-XFSFZCM5.js";
239
+ import "./chunk-2KKCCLPT.js";
240
+ import "./chunk-VJNBRRZG.js";
231
241
  import {
232
242
  writeStderrLine,
233
243
  writeStderrLineSafe
234
244
  } from "./chunk-OWAK7LMW.js";
235
- import "./chunk-XFSFZCM5.js";
236
245
  import {
237
246
  ALL_PROVIDERS,
238
247
  APPROVAL_MODE_INFO,
@@ -272,6 +281,7 @@ import {
272
281
  applyAutoModeDecision,
273
282
  applyProviderInstallPlan,
274
283
  approxBase64Bytes,
284
+ bridgeToolResultImages,
275
285
  buildBackgroundEntryLabel,
276
286
  buildBtwCacheSafeParams,
277
287
  buildBtwPrompt,
@@ -332,7 +342,6 @@ import {
332
342
  normalizeEventPayload,
333
343
  normalizeSnapshotPayload,
334
344
  persistPermissionOutcome,
335
- promptIdContext,
336
345
  readManyFiles,
337
346
  recordAllow,
338
347
  recordFallbackApprove,
@@ -355,57 +364,65 @@ import {
355
364
  unregisterGoalHook,
356
365
  updateSetting,
357
366
  validatePlanModeShellApproval,
358
- validatePlanModeShellContext
359
- } from "./chunk-DM4Q4JJH.js";
367
+ validatePlanModeShellContext,
368
+ wrapUserPromptSubmitContext
369
+ } from "./chunk-54YCNSK5.js";
360
370
  import "./chunk-5M6IDOMF.js";
361
371
  import "./chunk-TWPJO254.js";
362
372
  import {
363
373
  external_exports
364
374
  } from "./chunk-H6XPXXMH.js";
365
- import "./chunk-K4XWPEWB.js";
366
- import "./chunk-TOFQCPDC.js";
367
- import "./chunk-IRH27ZC2.js";
368
- import "./chunk-VDDGDZMA.js";
369
- import "./chunk-FNQ6T3CV.js";
370
- import "./chunk-ZOIFNCKL.js";
371
- import "./chunk-PWTZEM3C.js";
375
+ import "./chunk-AOHY3QJ3.js";
376
+ import "./chunk-5NNHICSA.js";
377
+ import "./chunk-SHN4KHDK.js";
378
+ import "./chunk-JXVC2PL3.js";
372
379
  import "./chunk-KRXPRVGL.js";
373
380
  import {
374
381
  parsePositiveIntegerEnv
375
382
  } from "./chunk-6PVPNMXU.js";
376
- import "./chunk-PSWQZHEA.js";
377
- import "./chunk-SZRN75WQ.js";
378
- import "./chunk-HTO4JFDZ.js";
383
+ import "./chunk-ZMOJ7ISP.js";
384
+ import "./chunk-IRH27ZC2.js";
385
+ import "./chunk-QHWCP53L.js";
386
+ import "./chunk-TEGJSJDF.js";
387
+ import "./chunk-TIRRPCFS.js";
388
+ import {
389
+ promptIdContext,
390
+ todoWorkChainContext
391
+ } from "./chunk-O6GEWCJA.js";
392
+ import "./chunk-T26EAKDL.js";
379
393
  import "./chunk-CPBF7KYF.js";
394
+ import "./chunk-4KP2F2TE.js";
395
+ import {
396
+ HookEventName,
397
+ createHookOutput
398
+ } from "./chunk-3APUUXRF.js";
399
+ import "./chunk-THVU3RNH.js";
400
+ import "./chunk-LHKCY7DY.js";
401
+ import "./chunk-6FMJLI5M.js";
380
402
  import {
381
403
  APPROVAL_MODES,
382
404
  FORK_SUBAGENT_TYPE,
383
405
  getStartupContextLength,
384
406
  isSystemReminderContent,
385
407
  runWithRuntimeContentGenerator
386
- } from "./chunk-L26JL52R.js";
387
- import "./chunk-6AM5D4ME.js";
388
- import "./chunk-JZA3JUDJ.js";
389
- import {
390
- HookEventName,
391
- createHookOutput
392
- } from "./chunk-3QMGYBFN.js";
393
- import "./chunk-JCW2R7WC.js";
394
- import "./chunk-M5JM7OSF.js";
395
- import "./chunk-OHNBB4XR.js";
396
- import "./chunk-E5TUC6CA.js";
408
+ } from "./chunk-CBBP4BMC.js";
409
+ import "./chunk-S6LOFUVP.js";
410
+ import "./chunk-K623ENWT.js";
411
+ import "./chunk-AQ37AY7B.js";
412
+ import "./chunk-N4ACHWNH.js";
413
+ import "./chunk-ZPJWUGCS.js";
397
414
  import {
398
415
  clearCachedCredentialFile,
399
416
  qwenOAuth2Events
400
- } from "./chunk-EPDRMGT4.js";
401
- import "./chunk-JESCGQM3.js";
402
- import "./chunk-NH6KE4JX.js";
403
- import "./chunk-USTWD7QV.js";
404
- import "./chunk-XVNQMZ2I.js";
405
- import "./chunk-FODK6UMO.js";
417
+ } from "./chunk-D4HTUMGX.js";
418
+ import "./chunk-NAVJD2PQ.js";
419
+ import "./chunk-LOY7RWQG.js";
420
+ import "./chunk-E6CJ2SMM.js";
421
+ import "./chunk-DGEIYUC3.js";
422
+ import "./chunk-MPHPFVKK.js";
406
423
  import "./chunk-GLNBDYUX.js";
407
424
  import "./chunk-DJ2GSRLV.js";
408
- import "./chunk-YAF5VNU7.js";
425
+ import "./chunk-6CQWRWUC.js";
409
426
  import {
410
427
  addToolArgumentsAttributes,
411
428
  addToolCallResultAttributes,
@@ -413,14 +430,14 @@ import {
413
430
  registerAcpEventLoopLagGauge,
414
431
  startEventLoopLagMonitor,
415
432
  withDaemonSpan
416
- } from "./chunk-BO4XCS7P.js";
417
- import "./chunk-BPJSQIJX.js";
433
+ } from "./chunk-Z3S5EMOW.js";
434
+ import "./chunk-2J3OJGTL.js";
418
435
  import "./chunk-P3QQPMQA.js";
419
- import "./chunk-6FGBXPWM.js";
436
+ import "./chunk-XQK4XXTN.js";
420
437
  import {
421
438
  getToolCallPreparations
422
- } from "./chunk-LS77BEZP.js";
423
- import "./chunk-SQBYH7PX.js";
439
+ } from "./chunk-GLCZKT5V.js";
440
+ import "./chunk-QDK4F2N5.js";
424
441
  import {
425
442
  ConversationFinishedEvent,
426
443
  DiscoveredMCPTool,
@@ -434,6 +451,7 @@ import {
434
451
  formatVisionBridgeNotice,
435
452
  getAllGeminiMdFilenames,
436
453
  getFullTurnVisionModelSelector,
454
+ getInvocationContext,
437
455
  getMCPServerStatus,
438
456
  getSpecificMimeType,
439
457
  hasImageParts,
@@ -450,25 +468,30 @@ import {
450
468
  shouldRunVisionBridge,
451
469
  splitImageParts,
452
470
  uiTelemetryService
453
- } from "./chunk-RWS5VYWC.js";
471
+ } from "./chunk-DUNI4EBW.js";
454
472
  import "./chunk-VGC4I5JJ.js";
455
473
  import {
456
474
  getAutoMemoryRoot,
457
475
  getUserAutoMemoryRoot
458
- } from "./chunk-MUP3T3AD.js";
476
+ } from "./chunk-3I6DUGQD.js";
477
+ import "./chunk-7ULQIS27.js";
478
+ import {
479
+ ToolConfirmationOutcome,
480
+ ToolNames,
481
+ isShellProgressData
482
+ } from "./chunk-MM7TH7ZM.js";
459
483
  import {
460
- AuthType
461
- } from "./chunk-U7TXFVUN.js";
484
+ AuthType,
485
+ preloadContentGenerator
486
+ } from "./chunk-HIVKI6O6.js";
462
487
  import "./chunk-46UV252V.js";
463
- import "./chunk-A4UCTEB5.js";
464
- import "./chunk-XWRJCPHC.js";
465
488
  import {
466
489
  DEFAULT_TOKEN_LIMIT,
467
490
  tokenLimit
468
- } from "./chunk-UW5EOVUN.js";
469
- import "./chunk-2JZBVYTU.js";
470
- import "./chunk-5I2IWRSH.js";
471
- import "./chunk-A5L3JMUA.js";
491
+ } from "./chunk-ZBVS26BY.js";
492
+ import "./chunk-Q3T5KA2V.js";
493
+ import "./chunk-R2XWGR75.js";
494
+ import "./chunk-HC45LTEN.js";
472
495
  import {
473
496
  endToolExecutionSpan,
474
497
  endToolSpan,
@@ -477,32 +500,26 @@ import {
477
500
  startToolExecutionSpan,
478
501
  startToolSpan,
479
502
  withInteractionSpan
480
- } from "./chunk-SRZ6DXVG.js";
503
+ } from "./chunk-QARJNL2V.js";
481
504
  import "./chunk-W4RQUHY3.js";
482
- import "./chunk-INADJJGW.js";
483
- import "./chunk-U7ZFW55U.js";
484
- import "./chunk-UUUTRMI2.js";
485
- import {
486
- ToolConfirmationOutcome,
487
- ToolNames,
488
- isShellProgressData
489
- } from "./chunk-PR75REBZ.js";
505
+ import "./chunk-G7XXKQYS.js";
490
506
  import {
491
507
  Storage,
492
508
  createDebugLogger,
493
509
  getErrorMessage,
494
510
  getErrorStatus,
495
511
  isSubpath
496
- } from "./chunk-NL7LTRLR.js";
497
- import "./chunk-32MVHM4T.js";
512
+ } from "./chunk-E2BHWIDT.js";
513
+ import "./chunk-VOQXFAY5.js";
514
+ import "./chunk-6PQPKTXP.js";
498
515
  import {
499
516
  runExitCleanup
500
- } from "./chunk-B4UMZKMU.js";
517
+ } from "./chunk-DQ2O5QOJ.js";
501
518
  import "./chunk-75DOP5OR.js";
502
519
  import "./chunk-DMTGGOSA.js";
503
520
  import "./chunk-YQ3U5MUC.js";
504
521
  import "./chunk-AMDSOFFV.js";
505
- import "./chunk-TARRHLLG.js";
522
+ import "./chunk-QUGAUQGJ.js";
506
523
  import {
507
524
  init_esbuild_shims
508
525
  } from "./chunk-5O2XNYP6.js";
@@ -1956,6 +1973,7 @@ var DaemonTodoStopGuard = class {
1956
1973
  // packages/cli/src/acp-integration/session/Session.ts
1957
1974
  var debugLogger6 = createDebugLogger("SESSION");
1958
1975
  var USER_CANCEL_ABORT_REASON = "qwen:user-cancel";
1976
+ var SESSION_DISPOSE_ABORT_REASON = "qwen:session-dispose";
1959
1977
  var DAEMON_RETRY_META_KEY = "qwen.daemon.retry";
1960
1978
  var DAEMON_CONTINUE_META_KEY = "qwen.daemon.continueLastTurn";
1961
1979
  var TODO_STOP_GUARD_PROMPT_PREFIX = "[Todo Stop Guard] ";
@@ -2227,6 +2245,20 @@ function parseMidTurnDrainResponse(response) {
2227
2245
  ).map((message) => ({ kind: "text", message }));
2228
2246
  }
2229
2247
  __name(parseMidTurnDrainResponse, "parseMidTurnDrainResponse");
2248
+ function isValidMidTurnDrainResponse(response, requireQueuedPromptState) {
2249
+ if (!isRecord2(response) || requireQueuedPromptState && typeof response["hasQueuedPrompt"] !== "boolean") {
2250
+ return false;
2251
+ }
2252
+ if (Array.isArray(response["items"])) {
2253
+ return response["items"].every(
2254
+ (item) => isRecord2(item) && Array.isArray(item["content"]) && item["content"].length > 0 && item["content"].every(isContentBlock)
2255
+ );
2256
+ }
2257
+ return Array.isArray(response["messages"]) && response["messages"].every(
2258
+ (message) => typeof message === "string" && message.trim().length > 0
2259
+ );
2260
+ }
2261
+ __name(isValidMidTurnDrainResponse, "isValidMidTurnDrainResponse");
2230
2262
  var MidTurnDrainTimeoutError = class extends Error {
2231
2263
  static {
2232
2264
  __name(this, "MidTurnDrainTimeoutError");
@@ -2237,6 +2269,16 @@ var MidTurnDrainTimeoutError = class extends Error {
2237
2269
  );
2238
2270
  }
2239
2271
  };
2272
+ var TodoStopGuardClaimTimeoutError = class extends Error {
2273
+ static {
2274
+ __name(this, "TodoStopGuardClaimTimeoutError");
2275
+ }
2276
+ constructor() {
2277
+ super(
2278
+ `Todo Stop Guard continuation claim got no response within ${MID_TURN_QUEUE_DRAIN_TIMEOUT_MS}ms`
2279
+ );
2280
+ }
2281
+ };
2240
2282
  function beginChannelDeliveryResponseBlock(capture) {
2241
2283
  if (!capture) return void 0;
2242
2284
  capture.finalText = "";
@@ -2493,12 +2535,7 @@ var Session = class {
2493
2535
  this.runtimeBaseDir = config.storage.getRuntimeBaseDir();
2494
2536
  const todoStopGuardEnabled = this.settings.merged.experimental?.todoStopGuard === true && !this.config.getBareMode() && !this.config.isSafeMode();
2495
2537
  this.todoStopGuard = new DaemonTodoStopGuard(todoStopGuardEnabled);
2496
- this.todoStopGuardBackgroundBaseline = todoStopGuardEnabled ? this.#captureTodoStopGuardBackgroundBaseline() : {
2497
- agents: /* @__PURE__ */ new Set(),
2498
- shells: /* @__PURE__ */ new Set(),
2499
- monitors: /* @__PURE__ */ new Set(),
2500
- wakeups: /* @__PURE__ */ new Set()
2501
- };
2538
+ this.todoStopGuardBackgroundBaseline = this.#captureTodoStopGuardBackgroundBaseline();
2502
2539
  this.toolCallEmitter = new ToolCallEmitter(this);
2503
2540
  this.planEmitter = new PlanEmitter(this);
2504
2541
  this.historyReplayer = new HistoryReplayer(this, {
@@ -2530,6 +2567,7 @@ var Session = class {
2530
2567
  */
2531
2568
  followupAbort = null;
2532
2569
  turn = 0;
2570
+ activeTodoWorkChainPromptId;
2533
2571
  createdAt = Date.now();
2534
2572
  /**
2535
2573
  * Running cumulative usage for this session, snapshotted onto each todo/plan
@@ -2570,7 +2608,12 @@ var Session = class {
2570
2608
  midTurnRecoveredMessages = [];
2571
2609
  todoStopGuard;
2572
2610
  todoStopGuardBackgroundBaseline;
2611
+ relatedAgentIds = /* @__PURE__ */ new Set();
2612
+ provisionalRelatedAgentCounts = /* @__PURE__ */ new Map();
2573
2613
  todoStopGuardQueuedPromptPriority = false;
2614
+ todoStopGuardQueuedPromptOwnerPromptId;
2615
+ todoStopGuardClaimOwnerCounts = /* @__PURE__ */ new Map();
2616
+ todoStopGuardReleasedDuringClaim = /* @__PURE__ */ new Set();
2574
2617
  todoStopGuardDrainAutomaticQueuesWhenIdle = false;
2575
2618
  // Background notification drain state. ACP does not have the TUI's idle
2576
2619
  // hook, so the session serializes registry callbacks through this queue.
@@ -2622,7 +2665,7 @@ var Session = class {
2622
2665
  }
2623
2666
  const drainSupersededAutomaticQueues = this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuard.hasCommittedContinuation || this.todoStopGuardQueuedPromptPriority;
2624
2667
  if (this.config.getApprovalMode() === "plan" /* PLAN */) {
2625
- this.todoStopGuardQueuedPromptPriority = false;
2668
+ this.#clearTodoStopGuardQueuedPromptWait();
2626
2669
  this.todoStopGuard.blockUntilOrdinaryPromptStarts();
2627
2670
  return {
2628
2671
  startsWorkChain: false,
@@ -2633,7 +2676,7 @@ var Session = class {
2633
2676
  const isRetry = params.retry === true || metadata?.[DAEMON_RETRY_META_KEY] === true;
2634
2677
  const isContinue = metadata?.[DAEMON_CONTINUE_META_KEY] === true;
2635
2678
  if (isRetry || isContinue) {
2636
- this.todoStopGuardQueuedPromptPriority = false;
2679
+ this.#clearTodoStopGuardQueuedPromptWait();
2637
2680
  if (this.todoStopGuard.hasTrustedUnfinishedState) {
2638
2681
  this.todoStopGuard.resumeTrustedPrompt();
2639
2682
  return {
@@ -2647,7 +2690,7 @@ var Session = class {
2647
2690
  drainSupersededAutomaticQueues
2648
2691
  };
2649
2692
  }
2650
- this.todoStopGuardQueuedPromptPriority = false;
2693
+ this.#clearTodoStopGuardQueuedPromptWait();
2651
2694
  this.todoStopGuard.blockUntilOrdinaryPromptStarts();
2652
2695
  return {
2653
2696
  startsWorkChain: true,
@@ -2660,7 +2703,7 @@ var Session = class {
2660
2703
  this.todoStopGuard.blockUntilOrdinaryPromptStarts();
2661
2704
  return;
2662
2705
  }
2663
- if (continuesCurrentWorkChain && this.todoStopGuard.isHardSuspended) {
2706
+ if (this.todoStopGuard.isHardSuspended) {
2664
2707
  return;
2665
2708
  }
2666
2709
  if (continuesCurrentWorkChain && this.todoStopGuard.hasTrustedUnfinishedState) {
@@ -2668,7 +2711,7 @@ var Session = class {
2668
2711
  return;
2669
2712
  }
2670
2713
  this.todoStopGuard.clearTrust();
2671
- this.todoStopGuardBackgroundBaseline = this.#captureTodoStopGuardBackgroundBaseline();
2714
+ this.#resetTodoStopGuardBackgroundLineage();
2672
2715
  }
2673
2716
  #clearTodoStopGuardTrustAndDrainAutomaticQueues() {
2674
2717
  const preserveQueuedPromptPriority = this.todoStopGuardQueuedPromptPriority;
@@ -2682,35 +2725,116 @@ var Session = class {
2682
2725
  void this.#drainCronQueue();
2683
2726
  void this.#drainNotificationQueue();
2684
2727
  }
2685
- releaseTodoStopGuardQueuedPromptWait() {
2686
- if (!this.todoStopGuardQueuedPromptPriority) return false;
2687
- this.todoStopGuardQueuedPromptPriority = false;
2728
+ releaseTodoStopGuardQueuedPromptWait(promptId) {
2729
+ const matchesCurrentWait = this.todoStopGuardQueuedPromptPriority && this.todoStopGuardQueuedPromptOwnerPromptId === promptId;
2730
+ if (!matchesCurrentWait) {
2731
+ if ((this.todoStopGuardClaimOwnerCounts.get(promptId) ?? 0) === 0) {
2732
+ return false;
2733
+ }
2734
+ this.todoStopGuardReleasedDuringClaim.add(promptId);
2735
+ if (!this.todoStopGuardQueuedPromptPriority) {
2736
+ this.#finishTodoStopGuardQueuedPromptRelease();
2737
+ }
2738
+ return true;
2739
+ }
2740
+ this.#clearTodoStopGuardQueuedPromptWait(promptId);
2741
+ this.#finishTodoStopGuardQueuedPromptRelease();
2742
+ return true;
2743
+ }
2744
+ #finishTodoStopGuardQueuedPromptRelease() {
2688
2745
  this.todoStopGuard.blockUntilOrdinaryPromptStarts();
2689
2746
  if (this.pendingPrompt) {
2690
2747
  this.todoStopGuardDrainAutomaticQueuesWhenIdle = true;
2691
- return true;
2748
+ return;
2692
2749
  }
2693
2750
  void this.#drainCronQueue();
2694
2751
  void this.#drainNotificationQueue();
2695
- return true;
2696
2752
  }
2697
2753
  clearTodoStopGuardTrust() {
2698
2754
  this.#clearTodoStopGuardTrustAndDrainAutomaticQueues();
2699
2755
  }
2700
- #beginTodoStopGuardQueuedPromptCheck() {
2701
- this.todoStopGuardQueuedPromptPriority = this.todoStopGuard.awaitQueuedPrompt();
2756
+ hardSuspendTodoStopGuard() {
2757
+ this.#clearTodoStopGuardQueuedPromptWait();
2758
+ this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
2759
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
2702
2760
  }
2703
- #finishTodoStopGuardQueuedPromptCheck(hasQueuedPrompt) {
2704
- const shouldWait = hasQueuedPrompt && this.todoStopGuardQueuedPromptPriority;
2705
- this.todoStopGuardQueuedPromptPriority = shouldWait;
2706
- if (!shouldWait) this.todoStopGuard.resumeTrustedPrompt();
2707
- return shouldWait;
2761
+ #clearTodoStopGuardQueuedPromptWait(expectedOwner) {
2762
+ if (expectedOwner !== void 0 && this.todoStopGuardQueuedPromptOwnerPromptId !== expectedOwner) {
2763
+ return;
2764
+ }
2765
+ this.todoStopGuardQueuedPromptPriority = false;
2766
+ this.todoStopGuardQueuedPromptOwnerPromptId = void 0;
2767
+ }
2768
+ #awaitTodoStopGuardQueuedPrompt(promptId) {
2769
+ this.todoStopGuard.awaitQueuedPrompt();
2770
+ this.todoStopGuardQueuedPromptPriority = true;
2771
+ this.todoStopGuardQueuedPromptOwnerPromptId = promptId;
2772
+ }
2773
+ async #claimTodoStopGuardContinuation(abortSignal) {
2774
+ const context = getInvocationContext();
2775
+ const ownerPromptId = context?.sessionId === this.sessionId ? context.promptId : void 0;
2776
+ if (ownerPromptId) {
2777
+ this.todoStopGuardClaimOwnerCounts.set(
2778
+ ownerPromptId,
2779
+ (this.todoStopGuardClaimOwnerCounts.get(ownerPromptId) ?? 0) + 1
2780
+ );
2781
+ }
2782
+ let timeoutHandle;
2783
+ try {
2784
+ const claimPromise = this.client.extMethod(
2785
+ TODO_STOP_GUARD_CONTINUATION_CLAIM_METHOD,
2786
+ {
2787
+ sessionId: this.sessionId,
2788
+ ...ownerPromptId ? { promptId: ownerPromptId } : {}
2789
+ }
2790
+ );
2791
+ const timeoutPromise = new Promise((_, reject) => {
2792
+ timeoutHandle = setTimeout(
2793
+ () => reject(new TodoStopGuardClaimTimeoutError()),
2794
+ MID_TURN_QUEUE_DRAIN_TIMEOUT_MS
2795
+ );
2796
+ });
2797
+ const response = await Promise.race([claimPromise, timeoutPromise]);
2798
+ if (abortSignal.aborted || !isRecord2(response)) {
2799
+ return "unavailable";
2800
+ }
2801
+ if (ownerPromptId && response["claimed"] === false && response["hasQueuedPrompt"] === true) {
2802
+ if (this.closing || this.disposed) return "unavailable";
2803
+ if (this.todoStopGuardReleasedDuringClaim.has(ownerPromptId)) {
2804
+ return "unavailable";
2805
+ }
2806
+ this.#awaitTodoStopGuardQueuedPrompt(ownerPromptId);
2807
+ return "queued";
2808
+ }
2809
+ if (this.todoStopGuard.isHardSuspended) return "unavailable";
2810
+ if (response["claimed"] === true && response["hasQueuedPrompt"] === false) {
2811
+ if (ownerPromptId) {
2812
+ this.#clearTodoStopGuardQueuedPromptWait(ownerPromptId);
2813
+ }
2814
+ this.todoStopGuard.resumeTrustedPrompt();
2815
+ return "claimed";
2816
+ }
2817
+ return "unavailable";
2818
+ } catch (error) {
2819
+ debugLogger6.warn(
2820
+ `Todo Stop Guard continuation claim unavailable [session ${this.sessionId}]: ${this.#formatError(error)}`
2821
+ );
2822
+ return "unavailable";
2823
+ } finally {
2824
+ clearTimeout(timeoutHandle);
2825
+ if (ownerPromptId) {
2826
+ const remaining = (this.todoStopGuardClaimOwnerCounts.get(ownerPromptId) ?? 1) - 1;
2827
+ if (remaining > 0) {
2828
+ this.todoStopGuardClaimOwnerCounts.set(ownerPromptId, remaining);
2829
+ } else {
2830
+ this.todoStopGuardClaimOwnerCounts.delete(ownerPromptId);
2831
+ this.todoStopGuardReleasedDuringClaim.delete(ownerPromptId);
2832
+ }
2833
+ }
2834
+ }
2708
2835
  }
2709
2836
  #notificationContinuesTodoStopGuardWorkChain(item) {
2710
- const baseline = this.todoStopGuardBackgroundBaseline;
2711
- if (item.kind === "agent") return !baseline.agents.has(item.taskId);
2712
- if (item.kind === "shell") return !baseline.shells.has(item.taskId);
2713
- return !baseline.monitors.has(item.taskId);
2837
+ return item.continuesTodoStopGuardWorkChain;
2714
2838
  }
2715
2839
  #cronContinuesTodoStopGuardWorkChain(item) {
2716
2840
  return item.source === "loop" && item.taskId !== void 0 && !this.todoStopGuardBackgroundBaseline.wakeups.has(item.taskId);
@@ -2743,6 +2867,37 @@ var Session = class {
2743
2867
  ])
2744
2868
  };
2745
2869
  }
2870
+ #resetTodoStopGuardBackgroundLineage() {
2871
+ this.relatedAgentIds.clear();
2872
+ this.provisionalRelatedAgentCounts.clear();
2873
+ this.todoStopGuardBackgroundBaseline = this.#captureTodoStopGuardBackgroundBaseline();
2874
+ for (const item of this.notificationQueue) {
2875
+ item.continuesTodoStopGuardWorkChain = false;
2876
+ }
2877
+ }
2878
+ #agentContinuesTodoStopGuardWorkChain(taskId, visiting = /* @__PURE__ */ new Set()) {
2879
+ if (this.relatedAgentIds.has(taskId) || (this.provisionalRelatedAgentCounts.get(taskId) ?? 0) > 0) {
2880
+ return true;
2881
+ }
2882
+ if (this.todoStopGuardBackgroundBaseline.agents.has(taskId)) return false;
2883
+ if (visiting.has(taskId)) return false;
2884
+ const task = this.config.getBackgroundTaskRegistry?.()?.get?.(taskId);
2885
+ if (!task) return false;
2886
+ if (!task.parentAgentId) return true;
2887
+ visiting.add(taskId);
2888
+ const related = this.#agentContinuesTodoStopGuardWorkChain(
2889
+ task.parentAgentId,
2890
+ visiting
2891
+ );
2892
+ visiting.delete(taskId);
2893
+ return related;
2894
+ }
2895
+ #monitorContinuesTodoStopGuardWorkChain(monitorId, ownerAgentId) {
2896
+ if (ownerAgentId) {
2897
+ return this.#agentContinuesTodoStopGuardWorkChain(ownerAgentId);
2898
+ }
2899
+ return !this.todoStopGuardBackgroundBaseline.monitors.has(monitorId);
2900
+ }
2746
2901
  #hasRelevantTodoStopGuardBackgroundInput() {
2747
2902
  if (this.notificationQueue.some(
2748
2903
  (item) => this.#notificationContinuesTodoStopGuardWorkChain(item)
@@ -2754,7 +2909,7 @@ var Session = class {
2754
2909
  const baseline = this.todoStopGuardBackgroundBaseline;
2755
2910
  const agents = this.config.getBackgroundTaskRegistry?.()?.getAll?.() ?? [];
2756
2911
  if (agents.some(
2757
- (task) => !baseline.agents.has(task.id) && task.isBackgrounded && (task.status === "running" || task.status === "paused" || task.status === "cancelled" && !task.notified)
2912
+ (task) => this.#agentContinuesTodoStopGuardWorkChain(task.id) && task.isBackgrounded && (task.status === "running" || task.status === "paused" || task.status === "cancelled" && !task.notified)
2758
2913
  )) {
2759
2914
  return true;
2760
2915
  }
@@ -2766,7 +2921,10 @@ var Session = class {
2766
2921
  }
2767
2922
  const monitors = this.config.getMonitorRegistry?.()?.getAll?.() ?? [];
2768
2923
  if (monitors.some(
2769
- (task) => !baseline.monitors.has(task.id) && task.status === "running"
2924
+ (task) => this.#monitorContinuesTodoStopGuardWorkChain(
2925
+ task.id,
2926
+ task.ownerAgentId
2927
+ ) && task.status === "running"
2770
2928
  )) {
2771
2929
  return true;
2772
2930
  }
@@ -2897,12 +3055,19 @@ var Session = class {
2897
3055
  return this.closeGateCompletion ?? Promise.resolve();
2898
3056
  }
2899
3057
  async waitForActiveTurnsToSettle() {
2900
- const pending = [
2901
- this.pendingPromptCompletion,
2902
- this.cronCompletion,
2903
- this.notificationCompletion
2904
- ].filter((completion) => completion !== null);
2905
- await Promise.allSettled(pending);
3058
+ while (this.#hasActiveTurn()) {
3059
+ const pending = [
3060
+ this.pendingPromptCompletion,
3061
+ this.cronCompletion,
3062
+ this.notificationCompletion
3063
+ ].filter(
3064
+ (completion) => completion !== null
3065
+ );
3066
+ if (pending.length > 0) {
3067
+ await Promise.allSettled(pending);
3068
+ }
3069
+ await new Promise((resolve5) => setImmediate(resolve5));
3070
+ }
2906
3071
  }
2907
3072
  #deferAutomaticQueueDrainUntilTurnsSettle() {
2908
3073
  const completions = [
@@ -2931,12 +3096,12 @@ var Session = class {
2931
3096
  dispose() {
2932
3097
  this.disposed = true;
2933
3098
  this.closing = true;
3099
+ this.pendingPrompt?.abort(SESSION_DISPOSE_ABORT_REASON);
3100
+ this.pendingPrompt = null;
2934
3101
  this.resolveCloseGate?.();
2935
3102
  this.resolveCloseGate = null;
2936
3103
  this.closeGateCompletion = null;
2937
- this.todoStopGuardQueuedPromptPriority = false;
2938
- this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
2939
- this.todoStopGuard.clearTrust();
3104
+ this.hardSuspendTodoStopGuard();
2940
3105
  this.notificationQueue = [];
2941
3106
  this.cronQueue = [];
2942
3107
  this.notificationAbortController?.abort();
@@ -3177,6 +3342,9 @@ var Session = class {
3177
3342
  throw RequestError.invalidParams(void 0, "Session is closing");
3178
3343
  }
3179
3344
  await this.assertCanStartTurn();
3345
+ if (this.closing) {
3346
+ throw RequestError.invalidParams(void 0, "Session is closing");
3347
+ }
3180
3348
  if (admissionCancellation?.aborted) {
3181
3349
  return { stopReason: "cancelled" };
3182
3350
  }
@@ -3238,9 +3406,9 @@ var Session = class {
3238
3406
  return { stopReason: "cancelled" };
3239
3407
  }
3240
3408
  if (todoStopGuardPreparation.startsWorkChain) {
3241
- this.todoStopGuardQueuedPromptPriority = false;
3409
+ this.#clearTodoStopGuardQueuedPromptWait();
3242
3410
  this.todoStopGuard.startOrdinaryPrompt();
3243
- this.todoStopGuardBackgroundBaseline = this.#captureTodoStopGuardBackgroundBaseline();
3411
+ this.#resetTodoStopGuardBackgroundLineage();
3244
3412
  }
3245
3413
  this.duplicateProviderToolCallResponseIds.clear();
3246
3414
  const channelDelivery = parsePromptChannelDelivery(params);
@@ -3281,9 +3449,12 @@ var Session = class {
3281
3449
  }
3282
3450
  throw error;
3283
3451
  } finally {
3452
+ const stillOwnsPendingPrompt = this.pendingPrompt === pendingSend;
3284
3453
  releasePendingSend();
3285
3454
  const shouldDrainAutomaticQueues = todoStopGuardPreparation.drainSupersededAutomaticQueues || this.todoStopGuardDrainAutomaticQueuesWhenIdle || this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuard.hasCommittedContinuation || this.todoStopGuardQueuedPromptPriority;
3286
- this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
3455
+ if (stillOwnsPendingPrompt) {
3456
+ this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
3457
+ }
3287
3458
  if (shouldDrainAutomaticQueues) {
3288
3459
  void this.#drainCronQueue();
3289
3460
  void this.#drainNotificationQueue();
@@ -3438,6 +3609,8 @@ var Session = class {
3438
3609
  }
3439
3610
  this.turn += 1;
3440
3611
  const promptId = this.config.getSessionId() + "########" + this.turn;
3612
+ const promptMetadata = params._meta;
3613
+ const continuesCurrentWorkChain = params.retry === true || promptMetadata?.[DAEMON_RETRY_META_KEY] === true || promptMetadata?.[DAEMON_CONTINUE_META_KEY] === true;
3441
3614
  promptIdContext.enterWith(promptId);
3442
3615
  const parentContext = extractDaemonTraceContext(params);
3443
3616
  return await withInteractionSpan(
@@ -3504,6 +3677,9 @@ var Session = class {
3504
3677
  let parts;
3505
3678
  let fullTurnModelOverride;
3506
3679
  const onFullTurnModel = /* @__PURE__ */ __name((model) => {
3680
+ if (fullTurnModelOverride === model) {
3681
+ return true;
3682
+ }
3507
3683
  if (fullTurnModelOverride) {
3508
3684
  return false;
3509
3685
  }
@@ -3559,9 +3735,20 @@ var Session = class {
3559
3735
  }
3560
3736
  const additionalContext = hookOutput?.getAdditionalContext();
3561
3737
  if (additionalContext) {
3562
- parts = [...parts, { text: additionalContext }];
3738
+ parts = [
3739
+ ...parts,
3740
+ { text: wrapUserPromptSubmitContext(additionalContext) }
3741
+ ];
3563
3742
  }
3564
3743
  }
3744
+ if (!continuesCurrentWorkChain && !this.todoStopGuard.enabled) {
3745
+ this.#resetTodoStopGuardBackgroundLineage();
3746
+ }
3747
+ this.config.startActiveTodoWorkChain(
3748
+ promptId,
3749
+ continuesCurrentWorkChain ? this.activeTodoWorkChainPromptId : void 0
3750
+ );
3751
+ this.activeTodoWorkChainPromptId = promptId;
3565
3752
  try {
3566
3753
  const fileHistoryService = this.config.getFileHistoryService();
3567
3754
  await fileHistoryService.makeSnapshot(promptId);
@@ -3607,6 +3794,15 @@ ${this.pendingRecoveredAgentsNotice}
3607
3794
  parts = insertAfterFunctionResponses(parts, [noticePart]);
3608
3795
  this.pendingRecoveredAgentsNotice = null;
3609
3796
  }
3797
+ const activeTodoReminder = this.config.takeActiveTodoReminder(
3798
+ promptId,
3799
+ true
3800
+ );
3801
+ if (activeTodoReminder && !parts.some((part) => part.text === activeTodoReminder)) {
3802
+ parts = insertAfterFunctionResponses(parts, [
3803
+ { text: activeTodoReminder }
3804
+ ]);
3805
+ }
3610
3806
  let nextMessage = { role: "user", parts };
3611
3807
  let turnCount = 0;
3612
3808
  const toolLoopState = createDaemonToolLoopState();
@@ -3712,7 +3908,8 @@ ${this.pendingRecoveredAgentsNotice}
3712
3908
  }
3713
3909
  strippedOrphanEntries = null;
3714
3910
  }
3715
- if (pendingSend.signal.aborted && pendingSend.signal.reason === USER_CANCEL_ABORT_REASON && this.#isAbortError(error)) {
3911
+ const isControlledCancellation = pendingSend.signal.aborted && (pendingSend.signal.reason === USER_CANCEL_ABORT_REASON || pendingSend.signal.reason === SESSION_DISPOSE_ABORT_REASON);
3912
+ if (isControlledCancellation) {
3716
3913
  this.todoStopGuard.suspend();
3717
3914
  return { stopReason: "cancelled" };
3718
3915
  }
@@ -3764,7 +3961,8 @@ ${this.pendingRecoveredAgentsNotice}
3764
3961
  pendingSend.signal,
3765
3962
  promptId,
3766
3963
  functionCalls,
3767
- toolLoopState
3964
+ toolLoopState,
3965
+ onFullTurnModel
3768
3966
  )
3769
3967
  );
3770
3968
  if (toolRun.stopAfterPermissionCancel) {
@@ -3782,6 +3980,7 @@ ${this.pendingRecoveredAgentsNotice}
3782
3980
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
3783
3981
  toolRun,
3784
3982
  pendingSend.signal,
3983
+ promptId,
3785
3984
  onFullTurnModel
3786
3985
  );
3787
3986
  nextMessage = nextAfterTools.message;
@@ -3836,6 +4035,9 @@ ${this.pendingRecoveredAgentsNotice}
3836
4035
  let stopHookIterationCount = 0;
3837
4036
  let stopHookReasons = [];
3838
4037
  const onFullTurnModel = /* @__PURE__ */ __name((model) => {
4038
+ if (modelOverride === model) {
4039
+ return true;
4040
+ }
3839
4041
  if (modelOverride) {
3840
4042
  return false;
3841
4043
  }
@@ -3844,6 +4046,9 @@ ${this.pendingRecoveredAgentsNotice}
3844
4046
  }, "onFullTurnModel");
3845
4047
  let midTurnContinuationCount = 0;
3846
4048
  while (true) {
4049
+ if (this.pendingPrompt && this.pendingPrompt !== pendingSend) {
4050
+ return { stopReason: "cancelled" };
4051
+ }
3847
4052
  if (pendingSend.signal.aborted) {
3848
4053
  this.todoStopGuard.suspend();
3849
4054
  return { stopReason: "cancelled" };
@@ -3855,15 +4060,26 @@ ${this.pendingRecoveredAgentsNotice}
3855
4060
  return { stopReason: "end_turn" };
3856
4061
  }
3857
4062
  if (this.todoStopGuard.needsStopInspection) {
3858
- this.#beginTodoStopGuardQueuedPromptCheck();
3859
4063
  const drained = await this.#drainMidTurnInput(pendingSend.signal, {
3860
4064
  watchQueuedPromptForTodoStopGuard: true,
3861
4065
  onFullTurnModel
3862
4066
  });
3863
- const waitsForQueuedPrompt = this.#finishTodoStopGuardQueuedPromptCheck(
3864
- drained.hasQueuedPrompt
3865
- );
3866
4067
  if (drained.parts.length > 0) {
4068
+ if (drained.hasQueuedPrompt) {
4069
+ const claim = await this.#claimTodoStopGuardContinuation(
4070
+ pendingSend.signal
4071
+ );
4072
+ if (claim === "queued") {
4073
+ this.#preserveUnsentMessageHistory(
4074
+ { role: "user", parts: drained.parts },
4075
+ true
4076
+ );
4077
+ return { stopReason: "end_turn" };
4078
+ }
4079
+ if (claim === "unavailable") {
4080
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4081
+ }
4082
+ }
3867
4083
  this.todoStopGuard.acceptMidTurnUserInput();
3868
4084
  const continuation2 = await this.#runStopContinuation(
3869
4085
  pendingSend,
@@ -3882,13 +4098,22 @@ ${this.pendingRecoveredAgentsNotice}
3882
4098
  }
3883
4099
  continue;
3884
4100
  }
3885
- if (waitsForQueuedPrompt) {
3886
- return { stopReason: "end_turn" };
4101
+ if (!drained.reliable) {
4102
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4103
+ } else if (drained.hasQueuedPrompt) {
4104
+ const claim = await this.#claimTodoStopGuardContinuation(
4105
+ pendingSend.signal
4106
+ );
4107
+ if (claim === "queued") {
4108
+ return { stopReason: "end_turn" };
4109
+ }
4110
+ if (claim === "unavailable") {
4111
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4112
+ }
3887
4113
  }
3888
4114
  }
3889
4115
  let externalReason = null;
3890
4116
  let stopHookCount = 1;
3891
- let queuedPromptArrivedDuringStopHook = false;
3892
4117
  if (allowExternalHooks && hooksEnabled && messageBus && stopHookIterationCount < stopHookBlockingCap && this.config.hasHooksForEvent?.("Stop")) {
3893
4118
  const responseText = this.#getCurrentChat().getLastModelMessageText?.() || "[no response text]";
3894
4119
  const contextUsage = buildContextUsage(
@@ -3919,14 +4144,26 @@ ${this.pendingRecoveredAgentsNotice}
3919
4144
  return { stopReason: "cancelled" };
3920
4145
  }
3921
4146
  if (this.todoStopGuard.needsStopInspection) {
3922
- this.#beginTodoStopGuardQueuedPromptCheck();
3923
4147
  const drained = await this.#drainMidTurnInput(pendingSend.signal, {
3924
4148
  watchQueuedPromptForTodoStopGuard: true,
3925
4149
  onFullTurnModel
3926
4150
  });
3927
- const waitsForQueuedPrompt = this.#finishTodoStopGuardQueuedPromptCheck(drained.hasQueuedPrompt);
3928
- queuedPromptArrivedDuringStopHook = waitsForQueuedPrompt;
3929
4151
  if (drained.parts.length > 0) {
4152
+ if (drained.hasQueuedPrompt) {
4153
+ const claim = await this.#claimTodoStopGuardContinuation(
4154
+ pendingSend.signal
4155
+ );
4156
+ if (claim === "queued") {
4157
+ this.#preserveUnsentMessageHistory(
4158
+ { role: "user", parts: drained.parts },
4159
+ true
4160
+ );
4161
+ return { stopReason: "end_turn" };
4162
+ }
4163
+ if (claim === "unavailable") {
4164
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4165
+ }
4166
+ }
3930
4167
  this.todoStopGuard.acceptMidTurnUserInput();
3931
4168
  const continuation2 = await this.#runStopContinuation(
3932
4169
  pendingSend,
@@ -3943,6 +4180,20 @@ ${this.pendingRecoveredAgentsNotice}
3943
4180
  if (continuation2.kind === "terminal") {
3944
4181
  return { stopReason: continuation2.stopReason };
3945
4182
  }
4183
+ continue;
4184
+ }
4185
+ if (!drained.reliable) {
4186
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4187
+ } else if (drained.hasQueuedPrompt) {
4188
+ const claim = await this.#claimTodoStopGuardContinuation(
4189
+ pendingSend.signal
4190
+ );
4191
+ if (claim === "queued") {
4192
+ return { stopReason: "end_turn" };
4193
+ }
4194
+ if (claim === "unavailable") {
4195
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4196
+ }
3946
4197
  }
3947
4198
  }
3948
4199
  const hookOutput = response.output ? createHookOutput("Stop", response.output) : void 0;
@@ -3955,9 +4206,13 @@ ${this.pendingRecoveredAgentsNotice}
3955
4206
  stopHookIterationCount++;
3956
4207
  stopHookReasons = [...stopHookReasons, externalReason];
3957
4208
  stopHookCount = response.stopHookCount ?? 1;
4209
+ } else {
4210
+ stopHookIterationCount = 0;
4211
+ stopHookReasons = [];
4212
+ stopHookCount = 1;
3958
4213
  }
3959
4214
  }
3960
- const guardDecision = queuedPromptArrivedDuringStopHook ? null : this.todoStopGuard.decide(
4215
+ const guardDecision = this.todoStopGuard.decide(
3961
4216
  this.todoStopGuard.needsStopInspection ? this.#hasRelevantTodoStopGuardBackgroundInput() : false
3962
4217
  );
3963
4218
  const guardContinuation = guardDecision?.kind === "continue" ? guardDecision : null;
@@ -3980,9 +4235,6 @@ ${this.pendingRecoveredAgentsNotice}
3980
4235
  debugLogger6.warn(warning);
3981
4236
  return { stopReason: "end_turn" };
3982
4237
  }
3983
- if (queuedPromptArrivedDuringStopHook) {
3984
- return { stopReason: "end_turn" };
3985
- }
3986
4238
  if (!externalReason && !guardContinuation) {
3987
4239
  return { stopReason: "end_turn" };
3988
4240
  }
@@ -4038,8 +4290,27 @@ ${this.pendingRecoveredAgentsNotice}
4038
4290
  let initialSend = true;
4039
4291
  let automaticContinuationValidated = false;
4040
4292
  let supersededAutomaticContinuation = false;
4293
+ const preservePendingMessage = /* @__PURE__ */ __name((message) => {
4294
+ if (initialSend) return;
4295
+ const preservedParts = (message.parts ?? []).filter(
4296
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4297
+ );
4298
+ this.#preserveUnsentMessageHistory(
4299
+ preservedParts.length > 0 ? { ...message, parts: preservedParts } : null,
4300
+ true
4301
+ );
4302
+ }, "preservePendingMessage");
4041
4303
  while (nextMessage !== null) {
4304
+ if (this.pendingPrompt && this.pendingPrompt !== pendingSend) {
4305
+ preservePendingMessage(nextMessage);
4306
+ return {
4307
+ kind: "terminal",
4308
+ stopReason: "cancelled",
4309
+ ...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
4310
+ };
4311
+ }
4042
4312
  if (pendingSend.signal.aborted) {
4313
+ preservePendingMessage(nextMessage);
4043
4314
  this.todoStopGuard.suspend();
4044
4315
  return {
4045
4316
  kind: "terminal",
@@ -4057,12 +4328,18 @@ ${this.pendingRecoveredAgentsNotice}
4057
4328
  let guardForThisSend = nextGuardContinuation;
4058
4329
  let preserveGuardOnSkippedSend = false;
4059
4330
  let messageForPreservation = nextMessage;
4331
+ let preparedMessage = nextMessage.parts ?? [];
4332
+ let preservePreparedMessageOnSkippedSend = !guardForThisSend && preparedMessage.some(
4333
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4334
+ );
4060
4335
  const externalParts = initialSend ? options.externalParts : void 0;
4061
4336
  const promptIdForSend = guardForThisSend && guardForThisSend.attempt !== options.guardContinuation?.attempt ? toolPromptId + "_todo_stop_guard_" + guardForThisSend.attempt : streamPromptId;
4062
4337
  const messageDisplay = this.#createMessageDisplayDispatcher(
4063
4338
  pendingSend.signal
4064
4339
  );
4065
4340
  let channelDeliveryResponseBlock;
4341
+ let providerSendChat;
4342
+ let userContentPushCountBeforeSend = 0;
4066
4343
  try {
4067
4344
  const sendResult = await this.#sendMessageStreamWithAutoCompression(
4068
4345
  promptIdForSend,
@@ -4071,44 +4348,134 @@ ${this.pendingRecoveredAgentsNotice}
4071
4348
  {
4072
4349
  skipCompression: skipCompression || (guardForThisSend?.attempt ?? 0) > 1,
4073
4350
  getModelOverride: options.getModelOverride,
4074
- beforeSend: guardForThisSend || !automaticContinuationValidated && options.onAutomaticContinuationValidated ? async ({ compressionFailed }) => {
4075
- const inspectGuardPriority = guardForThisSend !== void 0;
4076
- const guardCompressionFailed = inspectGuardPriority && compressionFailed;
4077
- if (inspectGuardPriority) {
4078
- this.#beginTodoStopGuardQueuedPromptCheck();
4079
- const drained = await this.#drainMidTurnInput(
4080
- pendingSend.signal,
4081
- {
4082
- watchQueuedPromptForTodoStopGuard: true,
4083
- onFullTurnModel: options.onFullTurnModel
4351
+ prepareBeforeCompression: guardForThisSend ? async () => {
4352
+ const drained = await this.#drainMidTurnInput(
4353
+ pendingSend.signal,
4354
+ {
4355
+ watchQueuedPromptForTodoStopGuard: true,
4356
+ onFullTurnModel: options.onFullTurnModel
4357
+ }
4358
+ );
4359
+ if (drained.parts.length > 0) {
4360
+ if (drained.hasQueuedPrompt) {
4361
+ const claim = await this.#claimTodoStopGuardContinuation(
4362
+ pendingSend.signal
4363
+ );
4364
+ if (claim === "queued") {
4365
+ guardForThisSend = void 0;
4366
+ nextGuardContinuation = void 0;
4367
+ preserveGuardOnSkippedSend = true;
4368
+ preservePreparedMessageOnSkippedSend = true;
4369
+ messageForPreservation = {
4370
+ role: "user",
4371
+ parts: drained.parts
4372
+ };
4373
+ if (initialSend) {
4374
+ supersededAutomaticContinuation = true;
4375
+ }
4376
+ return { kind: "stop", stopReason: "end_turn" };
4084
4377
  }
4378
+ if (claim === "unavailable") {
4379
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4380
+ }
4381
+ }
4382
+ preservePreparedMessageOnSkippedSend = true;
4383
+ this.todoStopGuard.acceptMidTurnUserInput();
4384
+ guardForThisSend = void 0;
4385
+ nextGuardContinuation = void 0;
4386
+ if (initialSend) {
4387
+ supersededAutomaticContinuation = true;
4388
+ }
4389
+ preparedMessage = initialSend ? drained.parts : [
4390
+ ...(nextMessage?.parts ?? []).filter(
4391
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4392
+ ),
4393
+ ...drained.parts
4394
+ ];
4395
+ messageForPreservation = {
4396
+ role: "user",
4397
+ parts: preparedMessage
4398
+ };
4399
+ return { kind: "send", message: preparedMessage };
4400
+ }
4401
+ if (!drained.reliable) {
4402
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4403
+ guardForThisSend = void 0;
4404
+ nextGuardContinuation = void 0;
4405
+ if (!options.externalParts) {
4406
+ preserveGuardOnSkippedSend = true;
4407
+ return { kind: "stop", stopReason: "end_turn" };
4408
+ }
4409
+ if (!initialSend && nextMessage) {
4410
+ nextMessage = {
4411
+ ...nextMessage,
4412
+ parts: (nextMessage.parts ?? []).filter(
4413
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4414
+ )
4415
+ };
4416
+ }
4417
+ } else if (drained.hasQueuedPrompt) {
4418
+ const probe = await this.#claimTodoStopGuardContinuation(
4419
+ pendingSend.signal
4085
4420
  );
4086
- const waitsForQueuedPrompt = this.#finishTodoStopGuardQueuedPromptCheck(
4087
- drained.hasQueuedPrompt
4088
- );
4089
- if (drained.parts.length > 0) {
4090
- this.todoStopGuard.acceptMidTurnUserInput();
4421
+ if (probe === "queued") {
4091
4422
  guardForThisSend = void 0;
4092
4423
  nextGuardContinuation = void 0;
4424
+ preserveGuardOnSkippedSend = true;
4093
4425
  if (initialSend) {
4094
4426
  supersededAutomaticContinuation = true;
4095
4427
  }
4096
- const replacementMessage = initialSend ? drained.parts : [
4097
- ...(nextMessage?.parts ?? []).filter(
4098
- (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4099
- ),
4100
- ...drained.parts
4101
- ];
4102
- messageForPreservation = {
4103
- role: "user",
4104
- parts: replacementMessage
4105
- };
4106
- return {
4107
- kind: "send",
4108
- message: replacementMessage
4109
- };
4428
+ return { kind: "stop", stopReason: "end_turn" };
4110
4429
  }
4111
- if (waitsForQueuedPrompt) {
4430
+ if (probe === "unavailable") {
4431
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4432
+ guardForThisSend = void 0;
4433
+ nextGuardContinuation = void 0;
4434
+ if (!options.externalParts) {
4435
+ preserveGuardOnSkippedSend = true;
4436
+ return { kind: "stop", stopReason: "end_turn" };
4437
+ }
4438
+ if (!initialSend && nextMessage) {
4439
+ nextMessage = {
4440
+ ...nextMessage,
4441
+ parts: (nextMessage.parts ?? []).filter(
4442
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4443
+ )
4444
+ };
4445
+ }
4446
+ }
4447
+ }
4448
+ if (guardForThisSend && this.config.getApprovalMode() === "plan" /* PLAN */) {
4449
+ this.#clearTodoStopGuardTrustAndDrainAutomaticQueues();
4450
+ }
4451
+ if (guardForThisSend) {
4452
+ const hasRelevantBackgroundInput = this.#hasRelevantTodoStopGuardBackgroundInput();
4453
+ const refreshedDecision = guardForThisSend.toolClosure ? this.todoStopGuard.decideToolClosure(
4454
+ guardForThisSend.attempt - 1,
4455
+ hasRelevantBackgroundInput
4456
+ ) : this.todoStopGuard.decide(hasRelevantBackgroundInput);
4457
+ if (refreshedDecision.kind !== "continue" || refreshedDecision.attempt !== guardForThisSend.attempt) {
4458
+ guardForThisSend = void 0;
4459
+ nextGuardContinuation = void 0;
4460
+ if (!options.externalParts) {
4461
+ preserveGuardOnSkippedSend = true;
4462
+ return { kind: "stop", stopReason: "end_turn" };
4463
+ }
4464
+ if (!initialSend && nextMessage) {
4465
+ nextMessage = {
4466
+ ...nextMessage,
4467
+ parts: (nextMessage.parts ?? []).filter(
4468
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4469
+ )
4470
+ };
4471
+ }
4472
+ }
4473
+ }
4474
+ if (guardForThisSend) {
4475
+ const claim = await this.#claimTodoStopGuardContinuation(
4476
+ pendingSend.signal
4477
+ );
4478
+ if (claim === "queued") {
4112
4479
  guardForThisSend = void 0;
4113
4480
  nextGuardContinuation = void 0;
4114
4481
  preserveGuardOnSkippedSend = true;
@@ -4117,41 +4484,21 @@ ${this.pendingRecoveredAgentsNotice}
4117
4484
  }
4118
4485
  return { kind: "stop", stopReason: "end_turn" };
4119
4486
  }
4120
- if (guardCompressionFailed) {
4121
- this.todoStopGuard.suspend();
4487
+ if (claim === "unavailable") {
4488
+ this.todoStopGuard.blockUntilOrdinaryPromptStarts();
4122
4489
  guardForThisSend = void 0;
4123
4490
  nextGuardContinuation = void 0;
4124
- if (!externalParts || externalParts.length === 0) {
4491
+ if (!options.externalParts) {
4125
4492
  preserveGuardOnSkippedSend = true;
4126
4493
  return { kind: "stop", stopReason: "end_turn" };
4127
4494
  }
4128
- }
4129
- if (guardForThisSend && this.config.getApprovalMode() === "plan" /* PLAN */) {
4130
- this.#clearTodoStopGuardTrustAndDrainAutomaticQueues();
4131
- }
4132
- if (guardForThisSend) {
4133
- const hasRelevantBackgroundInput = this.#hasRelevantTodoStopGuardBackgroundInput();
4134
- const refreshedDecision = guardForThisSend.toolClosure ? this.todoStopGuard.decideToolClosure(
4135
- guardForThisSend.attempt - 1,
4136
- hasRelevantBackgroundInput
4137
- ) : this.todoStopGuard.decide(
4138
- hasRelevantBackgroundInput
4139
- );
4140
- if (refreshedDecision.kind !== "continue" || refreshedDecision.attempt !== guardForThisSend.attempt) {
4141
- guardForThisSend = void 0;
4142
- nextGuardContinuation = void 0;
4143
- if (!options.externalParts) {
4144
- preserveGuardOnSkippedSend = true;
4145
- return { kind: "stop", stopReason: "end_turn" };
4146
- }
4147
- if (!initialSend && nextMessage) {
4148
- nextMessage = {
4149
- ...nextMessage,
4150
- parts: (nextMessage.parts ?? []).filter(
4151
- (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4152
- )
4153
- };
4154
- }
4495
+ if (!initialSend && nextMessage) {
4496
+ nextMessage = {
4497
+ ...nextMessage,
4498
+ parts: (nextMessage.parts ?? []).filter(
4499
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4500
+ )
4501
+ };
4155
4502
  }
4156
4503
  }
4157
4504
  }
@@ -4159,16 +4506,42 @@ ${this.pendingRecoveredAgentsNotice}
4159
4506
  await options.onAutomaticContinuationValidated();
4160
4507
  automaticContinuationValidated = true;
4161
4508
  }
4162
- const selectedMessage = guardForThisSend || !externalParts ? nextMessage?.parts ?? [] : externalParts;
4509
+ preparedMessage = guardForThisSend || !externalParts ? nextMessage?.parts ?? [] : externalParts;
4163
4510
  messageForPreservation = {
4164
4511
  role: "user",
4165
- parts: selectedMessage
4512
+ parts: preparedMessage
4166
4513
  };
4167
- return {
4168
- kind: "send",
4169
- message: selectedMessage
4514
+ preservePreparedMessageOnSkippedSend = preparedMessage.some(
4515
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4516
+ );
4517
+ return { kind: "send", message: preparedMessage };
4518
+ } : void 0,
4519
+ beforeSend: /* @__PURE__ */ __name(async ({ compressionFailed }) => {
4520
+ if (guardForThisSend && compressionFailed) {
4521
+ this.todoStopGuard.suspend();
4522
+ guardForThisSend = void 0;
4523
+ nextGuardContinuation = void 0;
4524
+ if (!options.externalParts) {
4525
+ preserveGuardOnSkippedSend = true;
4526
+ return { kind: "stop", stopReason: "end_turn" };
4527
+ }
4528
+ preparedMessage = initialSend && externalParts ? externalParts : preparedMessage.filter(
4529
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4530
+ );
4531
+ preservePreparedMessageOnSkippedSend = true;
4532
+ }
4533
+ if (!automaticContinuationValidated && options.onAutomaticContinuationValidated) {
4534
+ await options.onAutomaticContinuationValidated();
4535
+ automaticContinuationValidated = true;
4536
+ }
4537
+ messageForPreservation = {
4538
+ role: "user",
4539
+ parts: preparedMessage
4170
4540
  };
4171
- } : void 0
4541
+ providerSendChat = this.#getCurrentChat();
4542
+ userContentPushCountBeforeSend = providerSendChat.getUserContentPushCount?.() ?? 0;
4543
+ return { kind: "send", message: preparedMessage };
4544
+ }, "beforeSend")
4172
4545
  }
4173
4546
  );
4174
4547
  if (!sendResult.responseStream) {
@@ -4184,7 +4557,7 @@ ${this.pendingRecoveredAgentsNotice}
4184
4557
  );
4185
4558
  this.#preserveUnsentMessageHistory(
4186
4559
  preservedParts.length > 0 ? { ...messageForPreservation, parts: preservedParts } : null,
4187
- sendResult.stopReason === "cancelled"
4560
+ sendResult.stopReason === "cancelled" || preservePreparedMessageOnSkippedSend
4188
4561
  );
4189
4562
  return {
4190
4563
  kind: "terminal",
@@ -4206,7 +4579,7 @@ ${this.pendingRecoveredAgentsNotice}
4206
4579
  if (guardCommitted) {
4207
4580
  await this.#emitTodoStopGuardContinuation(guardForThisSend);
4208
4581
  }
4209
- if (!guardCommitted && externalParts) {
4582
+ if (!guardCommitted && options.externalParts) {
4210
4583
  guardForThisSend = void 0;
4211
4584
  }
4212
4585
  }
@@ -4260,6 +4633,24 @@ ${this.pendingRecoveredAgentsNotice}
4260
4633
  }
4261
4634
  } catch (error) {
4262
4635
  streamFailed = true;
4636
+ const preservedParts = (messageForPreservation.parts ?? []).filter(
4637
+ (part) => !("text" in part && isTodoStopGuardPromptText(part.text))
4638
+ );
4639
+ if (preservedParts.length > 0 && (!providerSendChat || (providerSendChat.getUserContentPushCount?.() ?? 0) <= userContentPushCountBeforeSend)) {
4640
+ this.#preserveUnsentMessageHistory(
4641
+ { ...messageForPreservation, parts: preservedParts },
4642
+ true
4643
+ );
4644
+ }
4645
+ const isControlledCancellation = pendingSend.signal.aborted && (pendingSend.signal.reason === USER_CANCEL_ABORT_REASON || pendingSend.signal.reason === SESSION_DISPOSE_ABORT_REASON);
4646
+ if (isControlledCancellation) {
4647
+ this.todoStopGuard.suspend();
4648
+ return {
4649
+ kind: "terminal",
4650
+ stopReason: "cancelled",
4651
+ ...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
4652
+ };
4653
+ }
4263
4654
  this.todoStopGuard.pauseForTrustedRetry();
4264
4655
  const errorStatus = getErrorStatus(error);
4265
4656
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -4309,7 +4700,8 @@ ${this.pendingRecoveredAgentsNotice}
4309
4700
  pendingSend.signal,
4310
4701
  toolPromptId,
4311
4702
  functionCalls,
4312
- toolLoopState
4703
+ toolLoopState,
4704
+ options.onFullTurnModel
4313
4705
  )
4314
4706
  );
4315
4707
  if (toolRun.stopAfterPermissionCancel || toolRun.loopDetected) {
@@ -4324,6 +4716,7 @@ ${this.pendingRecoveredAgentsNotice}
4324
4716
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
4325
4717
  toolRun,
4326
4718
  pendingSend.signal,
4719
+ toolPromptId,
4327
4720
  options.onFullTurnModel
4328
4721
  );
4329
4722
  nextMessage = nextAfterTools.message;
@@ -4467,6 +4860,19 @@ ${this.pendingRecoveredAgentsNotice}
4467
4860
  */
4468
4861
  async #sendMessageStreamWithAutoCompression(promptId, message, abortSignal, options = {}) {
4469
4862
  const geminiClient = this.config.getGeminiClient();
4863
+ if (options.prepareBeforeCompression) {
4864
+ const decision = await options.prepareBeforeCompression();
4865
+ if (decision.kind === "stop") {
4866
+ return { responseStream: null, stopReason: decision.stopReason };
4867
+ }
4868
+ message = decision.message;
4869
+ }
4870
+ if (abortSignal.aborted) {
4871
+ debugLogger6.debug(
4872
+ `Send aborted after pre-compression preparation for prompt ${promptId}`
4873
+ );
4874
+ return { responseStream: null, stopReason: "cancelled" };
4875
+ }
4470
4876
  let compressionDiagnostic = null;
4471
4877
  let compressionInfo = null;
4472
4878
  let compressionFailed = false;
@@ -4488,10 +4894,13 @@ ${this.pendingRecoveredAgentsNotice}
4488
4894
  compressionDiagnostic = `IMPORTANT: This conversation ${reasonClause}. A compressed context will be sent for future messages (compressed from: ${compressed.originalTokenCount ?? "unknown"} to ${compressed.newTokenCount ?? "unknown"} tokens).`;
4489
4895
  }
4490
4896
  } catch (compressionError) {
4491
- if (abortSignal.aborted || this.#isAbortError(compressionError)) {
4897
+ if (abortSignal.aborted) {
4492
4898
  debugLogger6.debug(`Auto-compression aborted for prompt ${promptId}`);
4493
4899
  return { responseStream: null, stopReason: "cancelled" };
4494
4900
  }
4901
+ if (this.#isAbortError(compressionError)) {
4902
+ throw compressionError;
4903
+ }
4495
4904
  debugLogger6.warn(
4496
4905
  `Auto-compression failed for prompt ${promptId}; proceeding without compression: ` + this.#formatError(compressionError)
4497
4906
  );
@@ -4597,7 +5006,7 @@ ${this.pendingRecoveredAgentsNotice}
4597
5006
  );
4598
5007
  await this.messageRewriter?.waitForPendingRewrites();
4599
5008
  }
4600
- async #buildNextMessageAfterToolRun(toolRun, abortSignal, onFullTurnModel) {
5009
+ async #buildNextMessageAfterToolRun(toolRun, abortSignal, promptId, onFullTurnModel) {
4601
5010
  if (toolRun.loopDetected) {
4602
5011
  debugLogger6.debug("Stopping ACP turn after daemon loop detection.");
4603
5012
  return { message: null, hadMidTurnUserInput: false };
@@ -4616,7 +5025,12 @@ ${this.pendingRecoveredAgentsNotice}
4616
5025
  if (hadMidTurnUserInput) {
4617
5026
  this.todoStopGuard.acceptMidTurnUserInput();
4618
5027
  }
4619
- const parts = [...toolRun.parts, ...drained.parts];
5028
+ const activeTodoReminder = this.config.takeActiveTodoReminder(promptId);
5029
+ const parts = [
5030
+ ...toolRun.parts,
5031
+ ...activeTodoReminder ? [{ text: activeTodoReminder }] : [],
5032
+ ...drained.parts
5033
+ ];
4620
5034
  return {
4621
5035
  message: { role: "user", parts },
4622
5036
  hadMidTurnUserInput
@@ -4706,7 +5120,8 @@ ${this.pendingRecoveredAgentsNotice}
4706
5120
  if (this.midTurnDrainUnavailable) {
4707
5121
  return {
4708
5122
  parts: await this.#buildMidTurnParts(recovered, abortSignal, options),
4709
- hasQueuedPrompt: false
5123
+ hasQueuedPrompt: false,
5124
+ reliable: false
4710
5125
  };
4711
5126
  }
4712
5127
  let drainPromise;
@@ -4729,13 +5144,18 @@ ${this.pendingRecoveredAgentsNotice}
4729
5144
  clearTimeout(timeoutHandle);
4730
5145
  }
4731
5146
  this.midTurnDrainTimeoutStrikes = 0;
5147
+ const reliable = isValidMidTurnDrainResponse(
5148
+ response,
5149
+ options.watchQueuedPromptForTodoStopGuard === true
5150
+ );
4732
5151
  return {
4733
5152
  parts: await this.#buildMidTurnParts(
4734
5153
  [...recovered, ...parseMidTurnDrainResponse(response)],
4735
5154
  abortSignal,
4736
5155
  options
4737
5156
  ),
4738
- hasQueuedPrompt: isRecord2(response) && response["hasQueuedPrompt"] === true
5157
+ hasQueuedPrompt: isRecord2(response) && response["hasQueuedPrompt"] === true,
5158
+ reliable
4739
5159
  };
4740
5160
  } catch (error) {
4741
5161
  const errorMessage = error instanceof Error ? error.message : error && typeof error === "object" && "message" in error ? String(error.message) : String(error);
@@ -4754,7 +5174,8 @@ ${this.pendingRecoveredAgentsNotice}
4754
5174
  );
4755
5175
  return {
4756
5176
  parts: await this.#buildMidTurnParts(recovered, abortSignal, options),
4757
- hasQueuedPrompt: false
5177
+ hasQueuedPrompt: false,
5178
+ reliable: false
4758
5179
  };
4759
5180
  }
4760
5181
  }
@@ -4874,7 +5295,8 @@ ${this.pendingRecoveredAgentsNotice}
4874
5295
  source: job.cronExpr === "@wakeup" ? "loop" : "cron",
4875
5296
  ...job.id ? { taskId: job.id } : {},
4876
5297
  ...job.lastFiredAt !== void 0 ? { firedAt: job.lastFiredAt } : {},
4877
- ...job.delivery ? { delivery: job.delivery } : {}
5298
+ ...job.delivery ? { delivery: job.delivery } : {},
5299
+ ...job.todoWorkChainId ? { todoWorkChainId: job.todoWorkChainId } : {}
4878
5300
  });
4879
5301
  void this.#drainCronQueue();
4880
5302
  });
@@ -4894,26 +5316,39 @@ ${this.pendingRecoveredAgentsNotice}
4894
5316
  );
4895
5317
  }
4896
5318
  #enqueueCronPrompt(item) {
4897
- if ((this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuardQueuedPromptPriority) && !this.#cronContinuesTodoStopGuardWorkChain(item)) {
4898
- if (item.taskId) {
5319
+ const automaticWorkDeferred = this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuardQueuedPromptPriority;
5320
+ if (automaticWorkDeferred) {
5321
+ const incomingIsRelated = this.#cronContinuesTodoStopGuardWorkChain(item);
5322
+ let shouldAppend = true;
5323
+ if (!incomingIsRelated && item.taskId) {
4899
5324
  const duplicateIndex = this.cronQueue.findIndex(
4900
5325
  (queued) => queued.taskId === item.taskId && !this.#cronContinuesTodoStopGuardWorkChain(queued)
4901
5326
  );
4902
5327
  if (duplicateIndex >= 0) {
4903
5328
  this.cronQueue[duplicateIndex] = item;
4904
- return;
5329
+ shouldAppend = false;
4905
5330
  }
4906
5331
  }
4907
- const unrelatedIndices = this.cronQueue.map(
4908
- (queued, index) => this.#cronContinuesTodoStopGuardWorkChain(queued) ? -1 : index
4909
- ).filter((index) => index >= 0);
4910
- if (unrelatedIndices.length >= MAX_DEFERRED_UNRELATED_CRON_QUEUE) {
4911
- const evictedIndex = unrelatedIndices[0];
5332
+ const maxBeforeAppend = MAX_DEFERRED_UNRELATED_CRON_QUEUE - (shouldAppend && !incomingIsRelated ? 1 : 0);
5333
+ let unrelatedCount = this.cronQueue.filter(
5334
+ (queued) => !this.#cronContinuesTodoStopGuardWorkChain(queued)
5335
+ ).length;
5336
+ const evictedTaskIds = [];
5337
+ while (unrelatedCount > maxBeforeAppend) {
5338
+ const evictedIndex = this.cronQueue.findIndex(
5339
+ (queued) => !this.#cronContinuesTodoStopGuardWorkChain(queued)
5340
+ );
5341
+ if (evictedIndex < 0) break;
4912
5342
  const [evicted] = this.cronQueue.splice(evictedIndex, 1);
5343
+ evictedTaskIds.push(evicted?.taskId ?? "unknown");
5344
+ unrelatedCount--;
5345
+ }
5346
+ if (evictedTaskIds.length > 0) {
4913
5347
  debugLogger6.warn(
4914
- `Cron queue overflow while automatic work is deferred: evicting task=${evicted?.taskId ?? "unknown"}`
5348
+ `Cron queue overflow while automatic work is deferred: evicted ${evictedTaskIds.length} unrelated task(s): ${evictedTaskIds.join(", ")}`
4915
5349
  );
4916
5350
  }
5351
+ if (!shouldAppend) return;
4917
5352
  }
4918
5353
  this.cronQueue.push(item);
4919
5354
  }
@@ -5017,9 +5452,8 @@ ${this.pendingRecoveredAgentsNotice}
5017
5452
  async () => {
5018
5453
  const ac = new AbortController();
5019
5454
  this.cronAbortController = ac;
5020
- this.#prepareTodoStopGuardForAutomaticTurn(
5021
- this.#cronContinuesTodoStopGuardWorkChain(item)
5022
- );
5455
+ const continuesCurrentWorkChain = this.#cronContinuesTodoStopGuardWorkChain(item);
5456
+ this.#prepareTodoStopGuardForAutomaticTurn(continuesCurrentWorkChain);
5023
5457
  const promptId = this.config.getSessionId() + "########cron" + Date.now();
5024
5458
  let cronHadError = false;
5025
5459
  let cronCompleted = false;
@@ -5036,6 +5470,10 @@ ${this.pendingRecoveredAgentsNotice}
5036
5470
  try {
5037
5471
  await this.assertCanStartTurn();
5038
5472
  if (ac.signal.aborted) return;
5473
+ this.config.startAutomaticActiveTodoWorkChain(
5474
+ promptId,
5475
+ item.todoWorkChainId
5476
+ );
5039
5477
  const loopMode = detectLoopSentinel(prompt);
5040
5478
  const autonomousMode = loopMode ? null : detectAutonomousSentinel(prompt);
5041
5479
  let loopTick = null;
@@ -5090,9 +5528,17 @@ ${this.pendingRecoveredAgentsNotice}
5090
5528
  _meta: { source: item.source }
5091
5529
  });
5092
5530
  const cronReminders = await this.#buildInitialSystemReminders();
5531
+ const activeTodoReminder = this.config.takeActiveTodoReminder(
5532
+ promptId,
5533
+ true
5534
+ );
5093
5535
  let nextMessage = {
5094
5536
  role: "user",
5095
- parts: [...cronReminders, { text: modelText }]
5537
+ parts: [
5538
+ ...cronReminders,
5539
+ ...activeTodoReminder ? [{ text: activeTodoReminder }] : [],
5540
+ { text: modelText }
5541
+ ]
5096
5542
  };
5097
5543
  const toolLoopState = createDaemonToolLoopState();
5098
5544
  while (nextMessage !== null) {
@@ -5224,7 +5670,8 @@ ${this.pendingRecoveredAgentsNotice}
5224
5670
  }
5225
5671
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
5226
5672
  toolRun,
5227
- ac.signal
5673
+ ac.signal,
5674
+ promptId
5228
5675
  );
5229
5676
  nextMessage = nextAfterTools.message;
5230
5677
  if (toolRun.loopDetected) {
@@ -5264,6 +5711,7 @@ ${this.pendingRecoveredAgentsNotice}
5264
5711
  `[${item.source} error] ${msg}`
5265
5712
  );
5266
5713
  } finally {
5714
+ this.config.endAutomaticActiveTodoWorkChain(promptId);
5267
5715
  if (this.cronAbortController === ac) {
5268
5716
  this.cronAbortController = null;
5269
5717
  }
@@ -5315,7 +5763,9 @@ ${this.pendingRecoveredAgentsNotice}
5315
5763
  taskId: meta.agentId,
5316
5764
  status: meta.status,
5317
5765
  kind: "agent",
5318
- toolUseId: meta.toolUseId
5766
+ continuesTodoStopGuardWorkChain: this.#agentContinuesTodoStopGuardWorkChain(meta.agentId),
5767
+ toolUseId: meta.toolUseId,
5768
+ todoWorkChainId: meta.todoWorkChainId
5319
5769
  });
5320
5770
  }
5321
5771
  );
@@ -5330,7 +5780,12 @@ ${this.pendingRecoveredAgentsNotice}
5330
5780
  taskId: meta.monitorId,
5331
5781
  status: meta.status,
5332
5782
  kind: "monitor",
5333
- toolUseId: meta.toolUseId
5783
+ continuesTodoStopGuardWorkChain: this.#monitorContinuesTodoStopGuardWorkChain(
5784
+ meta.monitorId,
5785
+ meta.ownerAgentId
5786
+ ),
5787
+ toolUseId: meta.toolUseId,
5788
+ todoWorkChainId: meta.todoWorkChainId
5334
5789
  });
5335
5790
  });
5336
5791
  const shellRegistry = this.config.getBackgroundShellRegistry();
@@ -5340,7 +5795,9 @@ ${this.pendingRecoveredAgentsNotice}
5340
5795
  modelText,
5341
5796
  taskId: meta.shellId,
5342
5797
  status: meta.status,
5343
- kind: "shell"
5798
+ kind: "shell",
5799
+ continuesTodoStopGuardWorkChain: !this.todoStopGuardBackgroundBaseline.shells.has(meta.shellId),
5800
+ todoWorkChainId: meta.todoWorkChainId
5344
5801
  });
5345
5802
  });
5346
5803
  this.config.getChatRecordingService()?.setTitleRecordedCallback((customTitle, titleSource, sessionId) => {
@@ -5463,20 +5920,36 @@ ${this.pendingRecoveredAgentsNotice}
5463
5920
  async () => {
5464
5921
  const ac = new AbortController();
5465
5922
  this.notificationAbortController = ac;
5466
- this.#prepareTodoStopGuardForAutomaticTurn(
5467
- this.#notificationContinuesTodoStopGuardWorkChain(item)
5468
- );
5923
+ const continuesCurrentWorkChain = this.#notificationContinuesTodoStopGuardWorkChain(item);
5924
+ this.#prepareTodoStopGuardForAutomaticTurn(continuesCurrentWorkChain);
5469
5925
  const promptId = this.config.getSessionId() + "########notification" + Date.now();
5470
5926
  try {
5471
5927
  await this.assertCanStartTurn();
5472
5928
  if (ac.signal.aborted) return;
5929
+ this.config.startAutomaticActiveTodoWorkChain(
5930
+ promptId,
5931
+ item.todoWorkChainId
5932
+ );
5473
5933
  await this.#emitBackgroundNotificationDisplay(item);
5474
5934
  const notificationParts = [{ text: item.modelText }];
5475
- this.config.getChatRecordingService()?.recordNotification(notificationParts, item.displayText);
5935
+ this.config.getChatRecordingService()?.recordNotification(notificationParts, item.displayText, {
5936
+ taskId: item.taskId,
5937
+ status: item.status,
5938
+ kind: item.kind,
5939
+ toolUseId: item.toolUseId
5940
+ });
5476
5941
  const notificationReminders = await this.#buildInitialSystemReminders();
5942
+ const activeTodoReminder = this.config.takeActiveTodoReminder(
5943
+ promptId,
5944
+ true
5945
+ );
5477
5946
  let nextMessage = {
5478
5947
  role: "user",
5479
- parts: [...notificationReminders, ...notificationParts]
5948
+ parts: [
5949
+ ...notificationReminders,
5950
+ ...activeTodoReminder ? [{ text: activeTodoReminder }] : [],
5951
+ ...notificationParts
5952
+ ]
5480
5953
  };
5481
5954
  const toolLoopState = createDaemonToolLoopState();
5482
5955
  while (nextMessage !== null) {
@@ -5606,7 +6079,8 @@ ${this.pendingRecoveredAgentsNotice}
5606
6079
  }
5607
6080
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
5608
6081
  toolRun,
5609
- ac.signal
6082
+ ac.signal,
6083
+ promptId
5610
6084
  );
5611
6085
  nextMessage = nextAfterTools.message;
5612
6086
  if (toolRun.loopDetected) {
@@ -5657,6 +6131,7 @@ ${this.pendingRecoveredAgentsNotice}
5657
6131
  await this.#emitBackgroundNotificationEndTurn("end_turn");
5658
6132
  }
5659
6133
  } finally {
6134
+ this.config.endAutomaticActiveTodoWorkChain(promptId);
5660
6135
  if (this.notificationAbortController === ac) {
5661
6136
  this.notificationAbortController = null;
5662
6137
  }
@@ -5721,8 +6196,10 @@ ${this.pendingRecoveredAgentsNotice}
5721
6196
  debugLogger6.error("Error sending available commands update:", error);
5722
6197
  }
5723
6198
  }
5724
- async refreshSkillsFromSettings() {
5725
- this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
6199
+ async refreshSkillsFromSettings(options = {}) {
6200
+ if (options.reloadSettings ?? true) {
6201
+ this.reloadSkillSettings();
6202
+ }
5726
6203
  const skillManager = this.config.getSkillManager();
5727
6204
  let updateFailed = false;
5728
6205
  let updateError;
@@ -5732,7 +6209,7 @@ ${this.pendingRecoveredAgentsNotice}
5732
6209
  updateFailed = true;
5733
6210
  updateError = error;
5734
6211
  }
5735
- if (skillManager) {
6212
+ if (skillManager && (options.notifyConfigChanged ?? true)) {
5736
6213
  try {
5737
6214
  skillManager.suppressNextSlashReload();
5738
6215
  await skillManager.notifyConfigChanged();
@@ -5746,6 +6223,9 @@ ${this.pendingRecoveredAgentsNotice}
5746
6223
  }
5747
6224
  if (updateFailed) throw updateError;
5748
6225
  }
6226
+ reloadSkillSettings() {
6227
+ this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
6228
+ }
5749
6229
  async sendAvailableCommandsUpdateOrThrow() {
5750
6230
  const { availableCommands, availableSkills, availableSkillDetails } = await buildAvailableCommandsSnapshot(
5751
6231
  this.config,
@@ -5925,7 +6405,11 @@ ${this.pendingRecoveredAgentsNotice}
5925
6405
  * sequential batch to preserve the implicit ordering the model may rely
5926
6406
  * on. Response-part ordering matches the original `functionCalls` order.
5927
6407
  */
5928
- async runToolCalls(abortSignal, promptId, functionCalls, toolLoopState) {
6408
+ async runToolCalls(abortSignal, promptId, functionCalls, toolLoopState, onFullTurnModel) {
6409
+ promptIdContext.enterWith(promptId);
6410
+ todoWorkChainContext.enterWith(
6411
+ this.config.getActiveTodoWorkChainOwner(promptId)
6412
+ );
5929
6413
  const dedupedFunctionCalls = dedupeToolCallsById(functionCalls);
5930
6414
  const generatedCallIdBase = randomUUID();
5931
6415
  const executionCallIds = new Map(
@@ -6202,7 +6686,8 @@ ${this.pendingRecoveredAgentsNotice}
6202
6686
  toolLoopState,
6203
6687
  recordSkippedToolCall,
6204
6688
  queueToolResultRecord,
6205
- executionCallIds.get(calls[i])
6689
+ executionCallIds.get(calls[i]),
6690
+ onFullTurnModel
6206
6691
  );
6207
6692
  results[i] = r;
6208
6693
  if (r.loopDetected) {
@@ -6236,7 +6721,8 @@ ${this.pendingRecoveredAgentsNotice}
6236
6721
  toolLoopState,
6237
6722
  recordSkippedToolCall,
6238
6723
  queueToolResultRecord,
6239
- executionCallIds.get(calls[idx])
6724
+ executionCallIds.get(calls[idx]),
6725
+ onFullTurnModel
6240
6726
  ).then((r) => {
6241
6727
  results[idx] = r;
6242
6728
  }).finally(() => {
@@ -6360,7 +6846,8 @@ ${this.pendingRecoveredAgentsNotice}
6360
6846
  toolLoopState,
6361
6847
  recordSkippedToolCall,
6362
6848
  queueToolResultRecord,
6363
- executionCallIds.get(fc)
6849
+ executionCallIds.get(fc),
6850
+ onFullTurnModel
6364
6851
  );
6365
6852
  parts.push(...r.parts);
6366
6853
  collectMemoryWriteCandidates(r);
@@ -6425,7 +6912,7 @@ ${this.pendingRecoveredAgentsNotice}
6425
6912
  }
6426
6913
  return reminders;
6427
6914
  }
6428
- async runTool(abortSignal, promptId, fc, onStopAfterPermissionCancel, toolLoopState, recordSkippedToolCall, queueToolResultRecord, generatedCallId) {
6915
+ async runTool(abortSignal, promptId, fc, onStopAfterPermissionCancel, toolLoopState, recordSkippedToolCall, queueToolResultRecord, generatedCallId, onFullTurnModel) {
6429
6916
  const callId = fc.id ?? generatedCallId ?? `${fc.name}-${Date.now()}`;
6430
6917
  let args = fc.args ?? {};
6431
6918
  if (toolLoopState?.loopDetected) {
@@ -6541,7 +7028,8 @@ ${this.pendingRecoveredAgentsNotice}
6541
7028
  call_id: callId,
6542
7029
  tool_name: policyToolName
6543
7030
  },
6544
- tool.description
7031
+ tool.description,
7032
+ promptId
6545
7033
  );
6546
7034
  let spanSuccess = false;
6547
7035
  try {
@@ -6580,6 +7068,10 @@ ${this.pendingRecoveredAgentsNotice}
6580
7068
  let toolBuildSucceeded = false;
6581
7069
  try {
6582
7070
  const invocation = tool.build(args);
7071
+ if (policyToolName === ToolNames.MONITOR) {
7072
+ const callIdAware = invocation;
7073
+ callIdAware.setCallId?.(callId);
7074
+ }
6583
7075
  toolBuildSucceeded = true;
6584
7076
  const taskEventEmitter = invocation.eventEmitter;
6585
7077
  if (isAgentTool && taskEventEmitter) {
@@ -7095,6 +7587,33 @@ ${this.pendingRecoveredAgentsNotice}
7095
7587
  );
7096
7588
  }
7097
7589
  }
7590
+ const continuedAgentId = toolName === ToolNames.SEND_MESSAGE && typeof args["task_id"] === "string" && args["task_id"].length > 0 ? args["task_id"] : void 0;
7591
+ const provisionalRelatedAgent = continuedAgentId !== void 0 && !this.relatedAgentIds.has(continuedAgentId);
7592
+ if (provisionalRelatedAgent) {
7593
+ this.provisionalRelatedAgentCounts.set(
7594
+ continuedAgentId,
7595
+ (this.provisionalRelatedAgentCounts.get(continuedAgentId) ?? 0) + 1
7596
+ );
7597
+ }
7598
+ let relatedAgentSettled = false;
7599
+ const settleRelatedAgent = /* @__PURE__ */ __name((succeeded2) => {
7600
+ if (relatedAgentSettled || !provisionalRelatedAgent || !continuedAgentId) {
7601
+ return;
7602
+ }
7603
+ relatedAgentSettled = true;
7604
+ const remaining = (this.provisionalRelatedAgentCounts.get(continuedAgentId) ?? 1) - 1;
7605
+ if (remaining > 0) {
7606
+ this.provisionalRelatedAgentCounts.set(
7607
+ continuedAgentId,
7608
+ remaining
7609
+ );
7610
+ } else {
7611
+ this.provisionalRelatedAgentCounts.delete(continuedAgentId);
7612
+ }
7613
+ if (succeeded2) {
7614
+ this.relatedAgentIds.add(continuedAgentId);
7615
+ }
7616
+ }, "settleRelatedAgent");
7098
7617
  const execSpan = startToolExecutionSpan();
7099
7618
  let toolResult;
7100
7619
  let isExecutionTimeout = false;
@@ -7154,6 +7673,7 @@ ${this.pendingRecoveredAgentsNotice}
7154
7673
  }
7155
7674
  isExecutionTimeout = toolResult.error?.type === "execution_timeout" /* EXECUTION_TIMEOUT */;
7156
7675
  aborted = activeToolAbortSignal.aborted && !isExecutionTimeout;
7676
+ settleRelatedAgent(!toolResult.error && !aborted);
7157
7677
  endToolExecutionSpan(execSpan, {
7158
7678
  success: !toolResult.error && !aborted,
7159
7679
  error: aborted ? "tool_cancelled" : isExecutionTimeout ? "tool_timeout" : toolResult.error ? "tool_error" : void 0,
@@ -7161,6 +7681,7 @@ ${this.pendingRecoveredAgentsNotice}
7161
7681
  ...heartbeatSpanAttributes()
7162
7682
  });
7163
7683
  } catch (execError) {
7684
+ settleRelatedAgent(false);
7164
7685
  endToolExecutionSpan(execSpan, {
7165
7686
  success: false,
7166
7687
  error: activeToolAbortSignal.aborted ? "tool_cancelled" : "tool_exception",
@@ -7176,7 +7697,7 @@ ${this.pendingRecoveredAgentsNotice}
7176
7697
  this.#clearTodoStopGuardTrustAndDrainAutomaticQueues();
7177
7698
  }
7178
7699
  }
7179
- const responseParts = toolResult.error ? convertToFunctionErrorResponse(
7700
+ let responseParts = toolResult.error ? convertToFunctionErrorResponse(
7180
7701
  toolName,
7181
7702
  callId,
7182
7703
  toolResult.llmContent,
@@ -7254,6 +7775,18 @@ ${this.pendingRecoveredAgentsNotice}
7254
7775
  artifacts: failureHookResult.artifacts
7255
7776
  });
7256
7777
  }
7778
+ const visionBridgeNotices = [];
7779
+ responseParts = await bridgeToolResultImages({
7780
+ config: this.config,
7781
+ responseParts,
7782
+ signal: activeToolAbortSignal,
7783
+ onFullTurnModel,
7784
+ onVisionBridgeNotice: /* @__PURE__ */ __name((notice) => visionBridgeNotices.push(notice), "onVisionBridgeNotice")
7785
+ });
7786
+ const visionBridgeNotice = visionBridgeNotices.length > 0 ? visionBridgeNotices.join("\n") : void 0;
7787
+ if (visionBridgeNotice) {
7788
+ await this.messageEmitter.emitAgentMessage(visionBridgeNotice);
7789
+ }
7257
7790
  if (isTodoWriteTool) {
7258
7791
  const todos = this.planEmitter.extractTodos(
7259
7792
  toolResult.returnDisplay,
@@ -7297,6 +7830,7 @@ ${this.pendingRecoveredAgentsNotice}
7297
7830
  callId,
7298
7831
  status,
7299
7832
  resultDisplay: toolResult.returnDisplay,
7833
+ ...visionBridgeNotice !== void 0 ? { visionBridgeNotice } : {},
7300
7834
  error: toolResult.error ? new Error(toolResult.error.message) : void 0,
7301
7835
  errorType: toolResult.error?.type
7302
7836
  }
@@ -7985,7 +8519,8 @@ function serializeMonitorTask(entry, now) {
7985
8519
  ...optionalField("pid", entry.pid),
7986
8520
  ...optionalField("exitCode", entry.exitCode),
7987
8521
  ...optionalField("error", entry.error),
7988
- ...optionalField("ownerAgentId", entry.ownerAgentId)
8522
+ ...optionalField("ownerAgentId", entry.ownerAgentId),
8523
+ ...optionalField("toolUseId", entry.toolUseId)
7989
8524
  };
7990
8525
  }
7991
8526
  __name(serializeMonitorTask, "serializeMonitorTask");
@@ -8227,6 +8762,32 @@ function isBulkLoadReplayRequest(params) {
8227
8762
  return meta?.[LOAD_REPLAY_MODE_META_KEY] === LOAD_REPLAY_BULK_MODE;
8228
8763
  }
8229
8764
  __name(isBulkLoadReplayRequest, "isBulkLoadReplayRequest");
8765
+ function shouldHideInheritedHistory(params) {
8766
+ const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8767
+ return meta?.[LOAD_REPLAY_HIDE_INHERITED_META_KEY] === true;
8768
+ }
8769
+ __name(shouldHideInheritedHistory, "shouldHideInheritedHistory");
8770
+ function selectVisibleHistoryRecords(records, hideInheritedHistory) {
8771
+ const sourceBoundary = records.findIndex(
8772
+ (record) => record.type === "system" && record.subtype === "session_source" && isObjectRecord(record.systemPayload) && record.systemPayload["sourceType"] === "side_task"
8773
+ );
8774
+ if (sourceBoundary >= 0) {
8775
+ return records.slice(sourceBoundary).filter((record) => record.forkedFrom === void 0);
8776
+ }
8777
+ return hideInheritedHistory ? records.filter((record) => record.forkedFrom === void 0) : records;
8778
+ }
8779
+ __name(selectVisibleHistoryRecords, "selectVisibleHistoryRecords");
8780
+ function isChannelSessionRequest(params) {
8781
+ const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8782
+ const value = meta?.[SESSION_SOURCE_META_KEY];
8783
+ return isObjectRecord(value) && value["sourceType"] === "channel";
8784
+ }
8785
+ __name(isChannelSessionRequest, "isChannelSessionRequest");
8786
+ function shouldDeferMcpDiscovery(params) {
8787
+ const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8788
+ return meta?.[WORKTREE_MCP_DEFER_META_KEY] === true;
8789
+ }
8790
+ __name(shouldDeferMcpDiscovery, "shouldDeferMcpDiscovery");
8230
8791
  function getLoadReplayPageSize(params) {
8231
8792
  const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8232
8793
  const value = meta?.[LOAD_REPLAY_PAGE_SIZE_META_KEY];
@@ -9656,7 +10217,97 @@ async function deliverClientMcpMessage(connection, serverName, message, sessionI
9656
10217
  return payload;
9657
10218
  }
9658
10219
  __name(deliverClientMcpMessage, "deliverClientMcpMessage");
10220
+ function readRuntimeMcpRequest(params) {
10221
+ const name = params["name"];
10222
+ if (typeof name !== "string" || name.length === 0) {
10223
+ throw RequestError.invalidParams(void 0, "Invalid or missing name");
10224
+ }
10225
+ if (!isValidServerName(name)) {
10226
+ throw RequestError.invalidParams(
10227
+ void 0,
10228
+ "Server name must be \u2264256 chars, alphanumeric + underscore/hyphen, and not a reserved JS property name"
10229
+ );
10230
+ }
10231
+ const originatorClientId = params["originatorClientId"];
10232
+ return {
10233
+ name,
10234
+ runtimeClientId: typeof originatorClientId === "string" && originatorClientId.length > 0 ? originatorClientId : "daemon"
10235
+ };
10236
+ }
10237
+ __name(readRuntimeMcpRequest, "readRuntimeMcpRequest");
10238
+ function readRuntimeMcpAddRequest(params) {
10239
+ const request = readRuntimeMcpRequest(params);
10240
+ const config = params["config"];
10241
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
10242
+ throw RequestError.invalidParams(void 0, "Invalid or missing config");
10243
+ }
10244
+ const {
10245
+ trust: _trust,
10246
+ authProviderType: _auth,
10247
+ includeTools: _inc,
10248
+ excludeTools: _exc,
10249
+ cwd: _cwd,
10250
+ env: _env,
10251
+ oauth: _oauth,
10252
+ headers: _headers,
10253
+ type: _type,
10254
+ [CLIENT_MCP_OVER_WS_CONFIG_FLAG]: clientMcpOverWs,
10255
+ ...safeConfig
10256
+ } = config;
10257
+ if (clientMcpOverWs === true) {
10258
+ safeConfig["type"] = "sdk";
10259
+ }
10260
+ return {
10261
+ ...request,
10262
+ config: safeConfig
10263
+ };
10264
+ }
10265
+ __name(readRuntimeMcpAddRequest, "readRuntimeMcpAddRequest");
10266
+ function getRuntimeMcpManager(config) {
10267
+ const manager = config.getToolRegistry()?.getMcpClientManager();
10268
+ if (!manager) {
10269
+ throw RequestError.internalError(
10270
+ void 0,
10271
+ "McpClientManager unavailable on this Config"
10272
+ );
10273
+ }
10274
+ return manager;
10275
+ }
10276
+ __name(getRuntimeMcpManager, "getRuntimeMcpManager");
10277
+ async function addRuntimeMcpServer(manager, request) {
10278
+ try {
10279
+ return await manager.addRuntimeMcpServer(
10280
+ request.name,
10281
+ request.config,
10282
+ request.runtimeClientId
10283
+ );
10284
+ } catch (err) {
10285
+ if (err instanceof McpBudgetWouldExceedError) {
10286
+ throw new RequestError(-32099, err.message, {
10287
+ errorKind: err.code,
10288
+ serverName: err.serverName
10289
+ });
10290
+ }
10291
+ if (err instanceof McpServerSpawnFailedError) {
10292
+ throw new RequestError(-32099, err.message, {
10293
+ errorKind: err.code,
10294
+ serverName: err.serverName,
10295
+ ...err.details
10296
+ });
10297
+ }
10298
+ if (err instanceof InvalidMcpConfigError) {
10299
+ throw new RequestError(-32099, err.message, {
10300
+ errorKind: err.code,
10301
+ serverName: err.serverName,
10302
+ reason: err.reason
10303
+ });
10304
+ }
10305
+ throw err;
10306
+ }
10307
+ }
10308
+ __name(addRuntimeMcpServer, "addRuntimeMcpServer");
9659
10309
  async function runAcpAgent(config, settings, argv, options) {
10310
+ const sessionWriterLeaseEnabledAtStartup = typeof config.isSessionWriterLeaseEnabled === "function" ? config.isSessionWriterLeaseEnabled() : settings.merged.experimental?.sessionWriterLease === true;
9660
10311
  const privateParentCapability = options === void 0 ? process.env[PRIVATE_ACP_CAPABILITY_ENV] : options.privateParentCapability;
9661
10312
  delete process.env[PRIVATE_ACP_CAPABILITY_ENV];
9662
10313
  let acpConnection;
@@ -9696,12 +10347,31 @@ async function runAcpAgent(config, settings, argv, options) {
9696
10347
  console.info = console.error;
9697
10348
  console.debug = console.error;
9698
10349
  let initializeRequestId;
10350
+ const pendingNewSessionRequestIds = /* @__PURE__ */ new Set();
9699
10351
  const stream = ndJsonStream(stdout, stdin, {
9700
10352
  onMessageObserved: /* @__PURE__ */ __name(({ direction, message }) => {
9701
- if (direction === "received" && "id" in message && "method" in message && message.method === "initialize") {
9702
- initializeRequestId = message.id;
10353
+ if (direction === "received" && "id" in message && "method" in message) {
10354
+ if (message.method === "session/new") {
10355
+ pendingNewSessionRequestIds.add(message.id);
10356
+ } else if (message.method === "initialize") {
10357
+ initializeRequestId = message.id;
10358
+ }
9703
10359
  return;
9704
10360
  }
10361
+ if (direction === "sent" && "id" in message && !("method" in message) && pendingNewSessionRequestIds.delete(message.id) && "result" in message && typeof message.result === "object" && message.result !== null && "sessionId" in message.result && typeof message.result.sessionId === "string") {
10362
+ const sessionId = message.result.sessionId;
10363
+ setImmediate(() => {
10364
+ const session = agentInstance?.getActiveSessions().find((candidate) => candidate.getId() === sessionId);
10365
+ if (!session) return;
10366
+ void preloadContentGenerator(
10367
+ session.getConfig().getContentGenerator()
10368
+ ).catch((error) => {
10369
+ debugLogger7.debug(
10370
+ `[ACP] Session provider preload failed for ${sessionId}: ${error instanceof Error ? error.message : String(error)}`
10371
+ );
10372
+ });
10373
+ }).unref();
10374
+ }
9705
10375
  if (direction !== "sent" || initializeRequestId === void 0 || !("id" in message) || "method" in message || message.id !== initializeRequestId) {
9706
10376
  return;
9707
10377
  }
@@ -9720,7 +10390,8 @@ async function runAcpAgent(config, settings, argv, options) {
9720
10390
  settings,
9721
10391
  argv,
9722
10392
  conn,
9723
- privateParentCapability
10393
+ privateParentCapability,
10394
+ sessionWriterLeaseEnabledAtStartup
9724
10395
  );
9725
10396
  return agentInstance;
9726
10397
  }, stream);
@@ -9729,29 +10400,34 @@ async function runAcpAgent(config, settings, argv, options) {
9729
10400
  eventLoopMonitor.dispose();
9730
10401
  throw err;
9731
10402
  }
9732
- const drainPoolBeforeExit = /* @__PURE__ */ __name(async (label) => {
10403
+ const drainPoolBeforeExit = /* @__PURE__ */ __name(async (label, strict = false) => {
9733
10404
  if (!agentInstance) return;
9734
10405
  try {
9735
10406
  await agentInstance.shutdownMcpPool(8e3);
9736
10407
  } catch (err) {
9737
10408
  debugLogger7.error(`[ACP] MCP pool drain (${label}) error:`, err);
10409
+ if (strict) throw err;
9738
10410
  }
9739
10411
  }, "drainPoolBeforeExit");
9740
10412
  let shuttingDown = false;
10413
+ let managedShutdownPromise;
9741
10414
  let sessionEndFired = false;
9742
- const fireSessionEndOnce = /* @__PURE__ */ __name(async (reason) => {
10415
+ const fireSessionEndOnce = /* @__PURE__ */ __name(async (reason, managedConfigs) => {
9743
10416
  if (sessionEndFired) return;
9744
10417
  sessionEndFired = true;
9745
- const configs = /* @__PURE__ */ new Set([config]);
9746
- const sessions = agentInstance?.getActiveSessions();
9747
- if (sessions) {
9748
- for (const session of sessions) {
9749
- const sessionConfig = session.getConfig?.();
9750
- if (sessionConfig) {
9751
- configs.add(sessionConfig);
10418
+ const configs = new Set(managedConfigs ?? [config]);
10419
+ if (!managedConfigs) {
10420
+ const sessions = agentInstance?.getActiveSessions();
10421
+ if (sessions) {
10422
+ for (const session of sessions) {
10423
+ const sessionConfig = session.getConfig?.();
10424
+ if (sessionConfig) {
10425
+ configs.add(sessionConfig);
10426
+ }
9752
10427
  }
9753
10428
  }
9754
10429
  }
10430
+ const failures = [];
9755
10431
  for (const cfg of configs) {
9756
10432
  const hookSystem = cfg.getHookSystem?.();
9757
10433
  const hooksEnabled = !cfg.getDisableAllHooks?.();
@@ -9761,16 +10437,99 @@ async function runAcpAgent(config, settings, argv, options) {
9761
10437
  try {
9762
10438
  await hookSystem.fireSessionEndEvent(reason);
9763
10439
  } catch (err) {
10440
+ if (managedConfigs) failures.push(err);
9764
10441
  debugLogger7.warn(
9765
10442
  `SessionEnd hook failed: ${err instanceof Error ? err.message : String(err)}`
9766
10443
  );
9767
10444
  }
9768
10445
  }
10446
+ if (failures.length > 0) {
10447
+ throw new AggregateError(failures, "SessionEnd hook shutdown failed");
10448
+ }
9769
10449
  }, "fireSessionEndOnce");
10450
+ const shutdownManagedAgent = /* @__PURE__ */ __name((reason, label) => {
10451
+ if (managedShutdownPromise) return managedShutdownPromise;
10452
+ const agent = agentInstance;
10453
+ if (!agent?.isTrustedManagedParent()) {
10454
+ return Promise.reject(
10455
+ new Error("Managed shutdown requires a trusted private parent")
10456
+ );
10457
+ }
10458
+ const terminal = agent.beginManagedShutdown();
10459
+ managedShutdownPromise = (async () => {
10460
+ const failures = [];
10461
+ try {
10462
+ await terminal.writerShutdown;
10463
+ } catch (error) {
10464
+ failures.push(error);
10465
+ debugLogger7.error("[ACP] Managed writer shutdown error:", error);
10466
+ const retainedLockPaths = terminal.configs.flatMap((config2) => {
10467
+ if (typeof config2.getSessionRuntimeBaseDir !== "function" || typeof config2.getSessionId !== "function") {
10468
+ return [];
10469
+ }
10470
+ return [
10471
+ path4.join(
10472
+ config2.getSessionRuntimeBaseDir(),
10473
+ "tmp",
10474
+ "session-writer-locks",
10475
+ `${encodeURIComponent(config2.getSessionId())}.lock`
10476
+ )
10477
+ ];
10478
+ });
10479
+ writeStderrLineSafe(
10480
+ "qwen --acp: managed session writer shutdown failed; a writer lock may be retained for safety. Verify that no previous writer is running before manual cleanup." + (retainedLockPaths.length > 0 ? ` Candidate lock paths: ${retainedLockPaths.join(", ")}` : "")
10481
+ );
10482
+ }
10483
+ try {
10484
+ await fireSessionEndOnce(reason, terminal.configs);
10485
+ } catch (error) {
10486
+ failures.push(error);
10487
+ }
10488
+ try {
10489
+ await agent.finishManagedShutdown(terminal.configs);
10490
+ } catch (error) {
10491
+ failures.push(error);
10492
+ debugLogger7.error("[ACP] Managed resource shutdown error:", error);
10493
+ }
10494
+ try {
10495
+ await drainPoolBeforeExit(label, true);
10496
+ } catch (error) {
10497
+ failures.push(error);
10498
+ }
10499
+ try {
10500
+ await runExitCleanup();
10501
+ } catch (error) {
10502
+ failures.push(error);
10503
+ debugLogger7.error("[ACP] Cleanup error:", error);
10504
+ }
10505
+ if (failures.length > 0) {
10506
+ throw new AggregateError(failures, "Managed ACP shutdown failed");
10507
+ }
10508
+ })();
10509
+ return managedShutdownPromise;
10510
+ }, "shutdownManagedAgent");
9770
10511
  const shutdownHandler = /* @__PURE__ */ __name(async () => {
9771
10512
  if (shuttingDown) return;
9772
10513
  shuttingDown = true;
9773
10514
  debugLogger7.debug("[ACP] Shutdown signal received, closing streams");
10515
+ if (agentInstance?.isTrustedManagedParent()) {
10516
+ let exitCode = 0;
10517
+ try {
10518
+ await shutdownManagedAgent("other" /* Other */, "signal");
10519
+ } catch (err) {
10520
+ exitCode = 1;
10521
+ debugLogger7.error("[ACP] Managed shutdown error:", err);
10522
+ } finally {
10523
+ eventLoopMonitor.dispose();
10524
+ }
10525
+ try {
10526
+ process.stdin.destroy();
10527
+ process.stdout.destroy();
10528
+ } catch {
10529
+ }
10530
+ process.exit(exitCode);
10531
+ return;
10532
+ }
9774
10533
  try {
9775
10534
  await fireSessionEndOnce("other" /* Other */);
9776
10535
  await agentInstance?.disposeSessions();
@@ -9798,9 +10557,21 @@ async function runAcpAgent(config, settings, argv, options) {
9798
10557
  process.on("SIGINT", shutdownHandler);
9799
10558
  try {
9800
10559
  await connection.closed;
9801
- await fireSessionEndOnce("prompt_input_exit" /* PromptInputExit */);
9802
- await drainPoolBeforeExit("ide_close");
9803
- await agentInstance?.disposeSessions();
10560
+ if (agentInstance?.isTrustedManagedParent()) {
10561
+ try {
10562
+ await shutdownManagedAgent(
10563
+ "prompt_input_exit" /* PromptInputExit */,
10564
+ "ide_close"
10565
+ );
10566
+ } catch (error) {
10567
+ process.exitCode = 1;
10568
+ throw error;
10569
+ }
10570
+ } else {
10571
+ await fireSessionEndOnce("prompt_input_exit" /* PromptInputExit */);
10572
+ await drainPoolBeforeExit("ide_close");
10573
+ await agentInstance?.disposeSessions();
10574
+ }
9804
10575
  } finally {
9805
10576
  process.off("SIGTERM", shutdownHandler);
9806
10577
  process.off("SIGINT", shutdownHandler);
@@ -9917,12 +10688,13 @@ function parseAcpSessionListCursor(value) {
9917
10688
  }
9918
10689
  __name(parseAcpSessionListCursor, "parseAcpSessionListCursor");
9919
10690
  var QwenAgent = class {
9920
- constructor(config, settings, argv, connection, expectedPrivateParentCapability) {
10691
+ constructor(config, settings, argv, connection, expectedPrivateParentCapability, sessionWriterLeaseEnabledAtStartup = false) {
9921
10692
  this.config = config;
9922
10693
  this.settings = settings;
9923
10694
  this.argv = argv;
9924
10695
  this.connection = connection;
9925
10696
  this.expectedPrivateParentCapability = expectedPrivateParentCapability;
10697
+ this.sessionWriterLeaseEnabledAtStartup = sessionWriterLeaseEnabledAtStartup;
9926
10698
  if (process.env["QWEN_SERVE_NO_MCP_POOL"] === "1") {
9927
10699
  this.mcpPool = void 0;
9928
10700
  this.workspaceMcpBudget = void 0;
@@ -9957,12 +10729,15 @@ var QwenAgent = class {
9957
10729
  workspaceMcpDiscoveryConfig;
9958
10730
  workspaceMcpDiscoveryPromise;
9959
10731
  workspaceMcpDiscoveryError;
10732
+ workspaceExtensionStatusRefreshPromise;
9960
10733
  pendingMcpAuthentications = /* @__PURE__ */ new Map();
9961
10734
  mcpAuthenticationResults = /* @__PURE__ */ new Map();
9962
10735
  generationControllers = /* @__PURE__ */ new Map();
9963
10736
  workspaceGenerationControllers = /* @__PURE__ */ new Map();
9964
10737
  transcriptReplayConfigCache = /* @__PURE__ */ new Map();
9965
10738
  pendingConfigCleanup = /* @__PURE__ */ new Map();
10739
+ initializingConfigs = /* @__PURE__ */ new Set();
10740
+ managedShuttingDown = false;
9966
10741
  clientCapabilities;
9967
10742
  privateParentState = "uninitialized";
9968
10743
  // CPU-usage delta baseline for the daemon's `workspaceResource` extMethod
@@ -9996,12 +10771,141 @@ var QwenAgent = class {
9996
10771
  getActiveSessions() {
9997
10772
  return [...this.sessions.values()];
9998
10773
  }
10774
+ isTrustedManagedParent() {
10775
+ return this.privateParentState === "trusted";
10776
+ }
10777
+ assertManagedSessionAdmission() {
10778
+ if (this.expectedPrivateParentCapability !== void 0 && !this.isTrustedManagedParent()) {
10779
+ throw RequestError.invalidParams(
10780
+ void 0,
10781
+ "Private ACP parent is not initialized"
10782
+ );
10783
+ }
10784
+ if (this.managedShuttingDown) {
10785
+ throw new SessionWriterUnavailableError();
10786
+ }
10787
+ }
10788
+ beginManagedShutdown() {
10789
+ if (!this.isTrustedManagedParent()) {
10790
+ throw new Error("Managed shutdown requires a trusted private parent");
10791
+ }
10792
+ this.managedShuttingDown = true;
10793
+ for (const generation of this.generationControllers.values()) {
10794
+ generation.controller.abort();
10795
+ }
10796
+ this.generationControllers.clear();
10797
+ for (const controller of this.workspaceGenerationControllers.values()) {
10798
+ controller.abort();
10799
+ }
10800
+ this.workspaceGenerationControllers.clear();
10801
+ const configs = /* @__PURE__ */ new Set([this.config, ...this.initializingConfigs]);
10802
+ for (const session of this.sessions.values()) {
10803
+ try {
10804
+ session.beginCloseIfAvailable();
10805
+ } catch (error) {
10806
+ debugLogger7.debug(
10807
+ `Session ${session.getId()} admission close during managed shutdown failed: ${error instanceof Error ? error.message : String(error)}`
10808
+ );
10809
+ }
10810
+ void session.cancelPendingPrompt().catch((error) => {
10811
+ debugLogger7.debug(
10812
+ `Session ${session.getId()} cancel during managed shutdown failed: ${error instanceof Error ? error.message : String(error)}`
10813
+ );
10814
+ });
10815
+ configs.add(session.getConfig());
10816
+ }
10817
+ for (const pending of this.pendingConfigCleanup.values()) {
10818
+ for (const config of pending) configs.add(config);
10819
+ }
10820
+ const configList = [...configs];
10821
+ const writerTerminals = [];
10822
+ for (const config of configList) {
10823
+ try {
10824
+ writerTerminals.push(config.closeSessionWriter({ handoff: true }));
10825
+ } catch (error) {
10826
+ writerTerminals.push(Promise.reject(error));
10827
+ }
10828
+ }
10829
+ const writerShutdown = Promise.allSettled(writerTerminals).then(
10830
+ (results) => {
10831
+ const failures = results.flatMap(
10832
+ (result) => result.status === "rejected" ? [result.reason] : []
10833
+ );
10834
+ if (failures.length > 0) {
10835
+ throw new AggregateError(
10836
+ failures,
10837
+ "Managed session writer shutdown failed"
10838
+ );
10839
+ }
10840
+ }
10841
+ );
10842
+ return { configs: configList, writerShutdown };
10843
+ }
10844
+ async finishManagedShutdown(configs) {
10845
+ const failures = [];
10846
+ for (const [sessionId, session] of [...this.sessions]) {
10847
+ await this.removeStoredSessionEntry(sessionId, session, failures, {
10848
+ shutdownConfig: false
10849
+ });
10850
+ }
10851
+ const results = await Promise.allSettled(
10852
+ configs.map(
10853
+ (config) => config.shutdown({
10854
+ shutdownTelemetry: false,
10855
+ skipSessionWriter: true,
10856
+ strictResourceCleanup: true
10857
+ })
10858
+ )
10859
+ );
10860
+ for (const result of results) {
10861
+ if (result.status === "rejected") failures.push(result.reason);
10862
+ }
10863
+ this.initializingConfigs.clear();
10864
+ this.pendingConfigCleanup.clear();
10865
+ this.disposeTranscriptReplayConfigs();
10866
+ if (failures.length > 0) {
10867
+ throw new AggregateError(failures, "Managed session cleanup failed");
10868
+ }
10869
+ }
9999
10870
  getWorkspaceMcpConfig(serverName) {
10000
10871
  if (serverName && this.config.getRuntimeMcpServers?.()[serverName] !== void 0) {
10001
10872
  return this.config;
10002
10873
  }
10003
10874
  return this.workspaceMcpDiscoveryConfig ?? this.config;
10004
10875
  }
10876
+ refreshBootstrapExtensionStatus() {
10877
+ if (this.workspaceExtensionStatusRefreshPromise) {
10878
+ return this.workspaceExtensionStatusRefreshPromise;
10879
+ }
10880
+ const promise = (async () => {
10881
+ const errors = [];
10882
+ try {
10883
+ await this.config.getExtensionManager().refreshCache();
10884
+ } catch (error) {
10885
+ errors.push(error);
10886
+ }
10887
+ try {
10888
+ await this.config.getSkillManager()?.refreshCache();
10889
+ } catch (error) {
10890
+ errors.push(error);
10891
+ }
10892
+ if (errors.length === 1) throw errors[0];
10893
+ if (errors.length > 1) {
10894
+ throw new AggregateError(
10895
+ errors,
10896
+ "Bootstrap extension status refresh failed"
10897
+ );
10898
+ }
10899
+ })();
10900
+ this.workspaceExtensionStatusRefreshPromise = promise;
10901
+ const clear = /* @__PURE__ */ __name(() => {
10902
+ if (this.workspaceExtensionStatusRefreshPromise === promise) {
10903
+ this.workspaceExtensionStatusRefreshPromise = void 0;
10904
+ }
10905
+ }, "clear");
10906
+ void promise.then(clear, clear);
10907
+ return promise;
10908
+ }
10005
10909
  getLiveMcpConfigs(serverName) {
10006
10910
  return [
10007
10911
  .../* @__PURE__ */ new Set([
@@ -10138,16 +11042,18 @@ var QwenAgent = class {
10138
11042
  for (const config of liveConfigs) {
10139
11043
  try {
10140
11044
  const cwd = config.getTargetDir();
10141
- const mcpServers = assembleMcpServers(
11045
+ const isBareOrSafe = config.getBareMode() || config.isSafeMode();
11046
+ const mcpServers = isBareOrSafe ? { ...config.getTopTierMcpServers() } : assembleMcpServers(
10142
11047
  settings.merged.mcpServers,
10143
11048
  cwd,
10144
11049
  config.getTopTierMcpServers()
10145
11050
  );
10146
- const gating = recomputeMcpGating(
11051
+ const bootAllowed = config.getCliAllowedMcpServerNames();
11052
+ const gating = isBareOrSafe ? { allowed: bootAllowed ? [...bootAllowed] : void 0 } : recomputeMcpGating(
10147
11053
  settings,
10148
11054
  mcpServers,
10149
11055
  cwd,
10150
- config.getCliAllowedMcpServerNames(),
11056
+ bootAllowed,
10151
11057
  config.getApprovalMode() === "yolo" /* YOLO */
10152
11058
  );
10153
11059
  config.setExcludedMcpServers(gating.excluded ?? []);
@@ -10240,11 +11146,15 @@ var QwenAgent = class {
10240
11146
  debugLogger7.warn(
10241
11147
  `MCP pool drain: ${result.drained} clean, ${result.forced} timed out, ${result.errors.length} errors`
10242
11148
  );
11149
+ throw new Error(
11150
+ `MCP pool drain incomplete: ${result.forced} forced, ${result.errors.length} errors`
11151
+ );
10243
11152
  }
10244
11153
  } catch (err) {
10245
11154
  debugLogger7.error(
10246
11155
  `MCP pool drainAll failed: ${err instanceof Error ? err.message : String(err)}`
10247
11156
  );
11157
+ throw err;
10248
11158
  }
10249
11159
  }
10250
11160
  async removeStoredSessionEntry(sessionId, session, cleanupErrors = [], options = {}) {
@@ -10315,11 +11225,13 @@ var QwenAgent = class {
10315
11225
  try {
10316
11226
  await shutdownSessionConfig(config);
10317
11227
  } catch (error) {
11228
+ this.initializingConfigs.delete(config);
10318
11229
  const pending2 = this.pendingConfigCleanup.get(cleanupKey) ?? /* @__PURE__ */ new Set();
10319
11230
  pending2.add(config);
10320
11231
  this.pendingConfigCleanup.set(cleanupKey, pending2);
10321
11232
  throw mapSessionWriterRequestError(error);
10322
11233
  }
11234
+ this.initializingConfigs.delete(config);
10323
11235
  const pending = this.pendingConfigCleanup.get(cleanupKey);
10324
11236
  pending?.delete(config);
10325
11237
  if (pending?.size === 0) {
@@ -10334,7 +11246,7 @@ var QwenAgent = class {
10334
11246
  `Session cleanup failed while preserving the original request error: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`
10335
11247
  );
10336
11248
  }
10337
- throw error;
11249
+ throw mapSessionWriterRequestError(error);
10338
11250
  }
10339
11251
  pendingConfigCleanupKey(runtimeBaseDir, sessionId) {
10340
11252
  return `${path4.resolve(runtimeBaseDir)}\0${sessionId}`;
@@ -10524,7 +11436,7 @@ var QwenAgent = class {
10524
11436
  }
10525
11437
  this.clientCapabilities = args.clientCapabilities;
10526
11438
  const authMethods = buildAuthMethods();
10527
- const version = "0.21.1-simplify-system-prompt.0";
11439
+ const version = "0.21.2";
10528
11440
  const response = {
10529
11441
  protocolVersion: PROTOCOL_VERSION,
10530
11442
  agentInfo: {
@@ -10598,6 +11510,7 @@ var QwenAgent = class {
10598
11510
  }
10599
11511
  async newSession(params) {
10600
11512
  const { cwd, mcpServers } = params;
11513
+ const isChannelSession = isChannelSessionRequest(params);
10601
11514
  const parentContext = extractDaemonTraceContext(params);
10602
11515
  return await withDaemonSpan(
10603
11516
  "qwen-code.daemon.session_start",
@@ -10611,7 +11524,15 @@ var QwenAgent = class {
10611
11524
  this.settings = settings;
10612
11525
  const config = await profiler.time(
10613
11526
  "config_setup",
10614
- () => this.newSessionConfig(cwd, mcpServers, settings)
11527
+ () => this.newSessionConfig(
11528
+ cwd,
11529
+ mcpServers,
11530
+ settings,
11531
+ isChannelSession,
11532
+ void 0,
11533
+ void 0,
11534
+ shouldDeferMcpDiscovery(params) ? { skipMcpDiscovery: true } : void 0
11535
+ )
10615
11536
  );
10616
11537
  let session;
10617
11538
  try {
@@ -10643,6 +11564,7 @@ var QwenAgent = class {
10643
11564
  );
10644
11565
  }
10645
11566
  async loadSession(params) {
11567
+ const isChannelSession = isChannelSessionRequest(params);
10646
11568
  const settings = loadSettingsCached(params.cwd);
10647
11569
  const liveSession = this.sessions.get(params.sessionId);
10648
11570
  if (liveSession) {
@@ -10659,9 +11581,16 @@ var QwenAgent = class {
10659
11581
  ...sessionData2.artifactSnapshot ? { artifactSnapshot: sessionData2.artifactSnapshot } : {}
10660
11582
  };
10661
11583
  const records = sessionData2.conversation.messages;
10662
- if (records.length === 0) return response2;
11584
+ const visibleRecords = selectVisibleHistoryRecords(
11585
+ records,
11586
+ shouldHideInheritedHistory(params)
11587
+ );
11588
+ if (visibleRecords.length === 0) return response2;
10663
11589
  const bulkReplay2 = isBulkLoadReplayRequest(params);
10664
- const replayPage = bulkReplay2 ? selectRecentHistoryRecords(records, getLoadReplayPageSize(params)) : { records, hasMore: false };
11590
+ const replayPage = bulkReplay2 ? selectRecentHistoryRecords(
11591
+ visibleRecords,
11592
+ getLoadReplayPageSize(params)
11593
+ ) : { records: visibleRecords, hasMore: false };
10665
11594
  const replay = await collectHistoryReplayUpdates({
10666
11595
  sessionId: params.sessionId,
10667
11596
  config: config2,
@@ -10713,22 +11642,70 @@ var QwenAgent = class {
10713
11642
  // a `null`/`undefined` would otherwise throw `TypeError`.
10714
11643
  params.mcpServers ?? [],
10715
11644
  settings,
11645
+ isChannelSession,
10716
11646
  params.sessionId,
10717
11647
  true
10718
11648
  );
10719
11649
  const sessionData = config.getResumedSessionData();
10720
11650
  const bulkReplay = isBulkLoadReplayRequest(params);
10721
11651
  const replayPageSize = bulkReplay ? getLoadReplayPageSize(params) : void 0;
10722
- let session;
11652
+ let replayEnvelope;
10723
11653
  try {
10724
11654
  await this.ensureAuthenticated(config);
10725
11655
  this.setupFileSystem(config);
10726
- session = await this.createAndStoreSession(
10727
- config,
10728
- settings,
10729
- sessionData,
10730
- bulkReplay ? { replayHistory: false, startPostReplayServices: false } : {}
10731
- );
11656
+ await this.createAndStoreSession(config, settings, sessionData, {
11657
+ ...bulkReplay ? { replayHistory: false } : {},
11658
+ beforeStartPostReplayServices: /* @__PURE__ */ __name(async (createdSession) => {
11659
+ if (bulkReplay) {
11660
+ const records = sessionData?.conversation.messages;
11661
+ let replayUpdates = [];
11662
+ if (records) {
11663
+ createdSession.primeTurnFromHistory(records);
11664
+ const visibleRecords = selectVisibleHistoryRecords(
11665
+ records,
11666
+ shouldHideInheritedHistory(params)
11667
+ );
11668
+ const replayPage = selectRecentHistoryRecords(
11669
+ visibleRecords,
11670
+ replayPageSize
11671
+ );
11672
+ const replayUsage = createReplayCumulativeUsage();
11673
+ const replay = await collectHistoryReplayUpdates({
11674
+ sessionId: params.sessionId,
11675
+ config,
11676
+ records: replayPage.records,
11677
+ gaps: sessionData?.historyGaps,
11678
+ cumulativeUsage: replayUsage,
11679
+ supersedeUnrestorableGoal: true,
11680
+ logger: debugLogger7
11681
+ });
11682
+ replayUpdates = replay.updates;
11683
+ copyCumulativeUsage(createdSession.cumulativeUsage, replayUsage);
11684
+ if (replay.replayError !== void 0) {
11685
+ replayEnvelope = {
11686
+ v: LOAD_REPLAY_VERSION,
11687
+ updates: replayUpdates,
11688
+ partial: true,
11689
+ replayError: replay.replayError,
11690
+ ...replayPage.hasMore ? { hasMore: true } : {}
11691
+ };
11692
+ }
11693
+ replayEnvelope ??= {
11694
+ v: LOAD_REPLAY_VERSION,
11695
+ updates: replayUpdates,
11696
+ ...replayPage.hasMore ? { hasMore: true } : {}
11697
+ };
11698
+ }
11699
+ replayEnvelope ??= {
11700
+ v: LOAD_REPLAY_VERSION,
11701
+ updates: replayUpdates
11702
+ };
11703
+ }
11704
+ await this.#restoreWorktreeOnResume(config, createdSession);
11705
+ await this.#restoreBackgroundAgentsOnResume(config, createdSession);
11706
+ this.#restoreGoalOnResume(config, createdSession);
11707
+ }, "beforeStartPostReplayServices")
11708
+ });
10732
11709
  } catch (error) {
10733
11710
  return this.cleanupAfterRequestFailure(error, async () => {
10734
11711
  if (this.sessions.get(config.getSessionId())?.getConfig() !== config) {
@@ -10736,72 +11713,6 @@ var QwenAgent = class {
10736
11713
  }
10737
11714
  });
10738
11715
  }
10739
- let replayEnvelope;
10740
- if (bulkReplay) {
10741
- try {
10742
- const records = sessionData?.conversation.messages;
10743
- let replayUpdates = [];
10744
- if (records) {
10745
- session.primeTurnFromHistory(records);
10746
- const replayPage = selectRecentHistoryRecords(
10747
- records,
10748
- replayPageSize
10749
- );
10750
- const replayUsage = createReplayCumulativeUsage();
10751
- const replay = await collectHistoryReplayUpdates({
10752
- sessionId: params.sessionId,
10753
- config,
10754
- records: replayPage.records,
10755
- gaps: sessionData?.historyGaps,
10756
- cumulativeUsage: replayUsage,
10757
- // A resume: the goal restore runs right after this.
10758
- supersedeUnrestorableGoal: true,
10759
- logger: debugLogger7
10760
- });
10761
- replayUpdates = replay.updates;
10762
- copyCumulativeUsage(session.cumulativeUsage, replayUsage);
10763
- if (replay.replayError !== void 0) {
10764
- replayEnvelope = {
10765
- v: LOAD_REPLAY_VERSION,
10766
- updates: replayUpdates,
10767
- partial: true,
10768
- replayError: replay.replayError,
10769
- ...replayPage.hasMore ? { hasMore: true } : {}
10770
- };
10771
- }
10772
- replayEnvelope ??= {
10773
- v: LOAD_REPLAY_VERSION,
10774
- updates: replayUpdates,
10775
- ...replayPage.hasMore ? { hasMore: true } : {}
10776
- };
10777
- }
10778
- replayEnvelope ??= {
10779
- v: LOAD_REPLAY_VERSION,
10780
- updates: replayUpdates
10781
- };
10782
- session.installRewriter();
10783
- session.startCronScheduler();
10784
- } catch (err) {
10785
- return this.cleanupAfterRequestFailure(err, async () => {
10786
- try {
10787
- await this.discardStoredSessionIfCurrent(params.sessionId, session);
10788
- } catch (cleanupError) {
10789
- await this.removeStoredSessionEntry(
10790
- params.sessionId,
10791
- session,
10792
- [cleanupError],
10793
- {
10794
- shutdownConfig: false
10795
- }
10796
- );
10797
- await this.cleanupUnstoredConfig(config);
10798
- }
10799
- });
10800
- }
10801
- }
10802
- await this.#restoreWorktreeOnResume(config, session);
10803
- await this.#restoreBackgroundAgentsOnResume(config, session);
10804
- this.#restoreGoalOnResume(config, session);
10805
11716
  const modesData = this.buildModesData(config);
10806
11717
  const availableModels = this.buildAvailableModels(config);
10807
11718
  const configOptions = this.buildConfigOptions(config);
@@ -10822,6 +11733,7 @@ var QwenAgent = class {
10822
11733
  };
10823
11734
  }
10824
11735
  async unstable_resumeSession(params) {
11736
+ const isChannelSession = isChannelSessionRequest(params);
10825
11737
  const settings = loadSettingsCached(params.cwd);
10826
11738
  const liveSession = this.sessions.get(params.sessionId);
10827
11739
  if (liveSession) {
@@ -10854,18 +11766,25 @@ var QwenAgent = class {
10854
11766
  params.cwd,
10855
11767
  params.mcpServers ?? [],
10856
11768
  settings,
11769
+ isChannelSession,
10857
11770
  params.sessionId,
10858
11771
  true
10859
11772
  );
10860
- let session;
10861
11773
  try {
10862
11774
  await this.ensureAuthenticated(config);
10863
11775
  this.setupFileSystem(config);
10864
- session = await this.createAndStoreSession(
11776
+ await this.createAndStoreSession(
10865
11777
  config,
10866
11778
  settings,
10867
11779
  config.getResumedSessionData(),
10868
- { replayHistory: false }
11780
+ {
11781
+ replayHistory: false,
11782
+ beforeStartPostReplayServices: /* @__PURE__ */ __name(async (createdSession) => {
11783
+ await this.#restoreWorktreeOnResume(config, createdSession);
11784
+ await this.#restoreBackgroundAgentsOnResume(config, createdSession);
11785
+ this.#restoreGoalOnResume(config, createdSession);
11786
+ }, "beforeStartPostReplayServices")
11787
+ }
10869
11788
  );
10870
11789
  } catch (error) {
10871
11790
  return this.cleanupAfterRequestFailure(error, async () => {
@@ -10874,9 +11793,6 @@ var QwenAgent = class {
10874
11793
  }
10875
11794
  });
10876
11795
  }
10877
- await this.#restoreWorktreeOnResume(config, session);
10878
- await this.#restoreBackgroundAgentsOnResume(config, session);
10879
- this.#restoreGoalOnResume(config, session);
10880
11796
  const modesData = this.buildModesData(config);
10881
11797
  const availableModels = this.buildAvailableModels(config);
10882
11798
  const configOptions = this.buildConfigOptions(config);
@@ -11777,34 +12693,70 @@ var QwenAgent = class {
11777
12693
  ...inferred ? { errorKind: inferred } : {}
11778
12694
  };
11779
12695
  }
12696
+ /**
12697
+ * Keeps the extension-derived half of the skill snapshot self-healing.
12698
+ *
12699
+ * Skills have a watcher (`SkillManager.startWatching`); extensions do not, so
12700
+ * without this the child would never notice an extension installed, removed,
12701
+ * enabled, or disabled outside the daemon — and extension-level skills are
12702
+ * derived from that set, so a skill-watcher tick alone cannot recover it.
12703
+ *
12704
+ * The check is one `readdir` plus a bounded number of `stat`s, and refreshes
12705
+ * only when the sources actually moved, so a steady-state read still parses
12706
+ * no manifest and no `SKILL.md`. Failures are logged and swallowed: a status
12707
+ * read must not fail because revalidation could not run.
12708
+ *
12709
+ * Skipped in safe and bare mode. Those modes deliberately never populate the
12710
+ * extension cache (`Config.initialize` omits the refresh), and the snapshot
12711
+ * derives extension skills from `getExtensions()` — so revalidating here
12712
+ * would load the extensions those modes exist to exclude.
12713
+ */
12714
+ async revalidateExtensionSources(config) {
12715
+ try {
12716
+ if (config.isSafeMode() || config.getBareMode()) return;
12717
+ const changed = await config.getExtensionManager().refreshCacheIfSourcesChanged();
12718
+ if (!changed) return;
12719
+ await config.getSkillManager()?.refreshCache();
12720
+ } catch (error) {
12721
+ debugLogger7.warn("Extension source revalidation failed:", error);
12722
+ }
12723
+ }
11780
12724
  async buildWorkspaceSkillsStatus(config) {
11781
12725
  const skillManager = config.getSkillManager();
11782
12726
  if (!skillManager) {
11783
12727
  return {
11784
12728
  v: STATUS_SCHEMA_VERSION,
11785
12729
  workspaceCwd: this.workspaceCwd(config),
11786
- initialized: true,
12730
+ initialized: false,
11787
12731
  skills: []
11788
12732
  };
11789
12733
  }
12734
+ await this.revalidateExtensionSources(config);
11790
12735
  try {
11791
- const disabled = config.getDisabledSkillNames();
11792
- try {
11793
- await config.getExtensionManager().refreshCache();
11794
- } catch (error) {
11795
- debugLogger7.warn("Extension cache refresh failed:", error);
11796
- }
11797
- try {
11798
- await skillManager.refreshCache();
11799
- } catch (error) {
11800
- debugLogger7.warn("Skill cache refresh failed:", error);
12736
+ const skills = skillManager.getCachedSkills();
12737
+ if (skills === null) {
12738
+ return {
12739
+ v: STATUS_SCHEMA_VERSION,
12740
+ workspaceCwd: this.workspaceCwd(config),
12741
+ initialized: false,
12742
+ skills: []
12743
+ };
11801
12744
  }
11802
- const skills = await skillManager.listSkills();
12745
+ const resolved = resolveSkillSettings(this.settings);
12746
+ const disablements = new Map(
12747
+ Array.from(config.getDisabledSkillNames(), (name) => {
12748
+ const normalizedName = name.trim().toLowerCase();
12749
+ return [
12750
+ normalizedName,
12751
+ resolved.disablements.get(normalizedName) ?? { reason: "hard" }
12752
+ ];
12753
+ })
12754
+ );
11803
12755
  const inactiveSkillRefs = inactiveExtensionSkillRefs(config);
11804
12756
  const skillsByKey = new Map(
11805
12757
  skills.map((skill) => [
11806
12758
  `${skill.level}:${skill.extensionName ?? ""}:${skill.name}`,
11807
- mapSkillConfigToStatus(skill, disabled, {
12759
+ mapSkillConfigToStatus(skill, disablements, {
11808
12760
  disabled: isInactiveExtensionSkill(skill, inactiveSkillRefs)
11809
12761
  })
11810
12762
  ])
@@ -11825,7 +12777,7 @@ var QwenAgent = class {
11825
12777
  level: "extension",
11826
12778
  extensionName
11827
12779
  },
11828
- disabled,
12780
+ disablements,
11829
12781
  { disabled: true }
11830
12782
  )
11831
12783
  );
@@ -12885,12 +13837,19 @@ var QwenAgent = class {
12885
13837
  }
12886
13838
  case TODO_STOP_GUARD_QUEUE_RELEASE_METHOD: {
12887
13839
  const sessionId = params["sessionId"];
13840
+ const promptId = params["promptId"];
12888
13841
  if (typeof sessionId !== "string" || sessionId.length === 0) {
12889
13842
  throw RequestError.invalidParams(
12890
13843
  void 0,
12891
13844
  "Invalid or missing sessionId"
12892
13845
  );
12893
13846
  }
13847
+ if (typeof promptId !== "string" || promptId.length === 0) {
13848
+ throw RequestError.invalidParams(
13849
+ void 0,
13850
+ "Invalid or missing promptId"
13851
+ );
13852
+ }
12894
13853
  const session = this.sessions.get(sessionId);
12895
13854
  if (!session) {
12896
13855
  throw RequestError.invalidParams(
@@ -12899,7 +13858,7 @@ var QwenAgent = class {
12899
13858
  );
12900
13859
  }
12901
13860
  return {
12902
- released: session.releaseTodoStopGuardQueuedPromptWait()
13861
+ released: session.releaseTodoStopGuardQueuedPromptWait(promptId)
12903
13862
  };
12904
13863
  }
12905
13864
  case "qwen/providers/list": {
@@ -14320,10 +15279,12 @@ var QwenAgent = class {
14320
15279
  }
14321
15280
  }
14322
15281
  const previousCwd = config.getTargetDir();
14323
- if (canonicalPath === previousCwd) {
14324
- return { previousCwd, newCwd: canonicalPath, warnings: [] };
14325
- }
14326
- if (isFolderTrustEnabled(this.settings.merged)) {
15282
+ let trustValidated = false;
15283
+ const validateTrust = /* @__PURE__ */ __name(() => {
15284
+ if (!isFolderTrustEnabled(this.settings.merged)) {
15285
+ trustValidated = true;
15286
+ return;
15287
+ }
14327
15288
  const trustedFolders = loadTrustedFolders();
14328
15289
  if (trustedFolders.isPathTrusted(canonicalPath) !== true) {
14329
15290
  throw new RequestError(
@@ -14332,27 +15293,67 @@ var QwenAgent = class {
14332
15293
  { errorKind: "directory_not_trusted", path: canonicalPath }
14333
15294
  );
14334
15295
  }
15296
+ trustValidated = true;
15297
+ }, "validateTrust");
15298
+ if (canonicalPath !== previousCwd) {
15299
+ validateTrust();
14335
15300
  }
14336
- const warnings = [];
14337
- const relocation = await config.relocateWorkingDirectory(
14338
- canonicalPath,
14339
- canonicalPath,
14340
- { skipProcessChdir: true, skipArtifactMigration: true }
15301
+ const releaseGate = await beginSessionCloseAfterCurrentGate(
15302
+ session,
15303
+ SESSION_DRAIN_TIMEOUT_MS
14341
15304
  );
14342
- if (relocation.memoryRefreshError) {
14343
- warnings.push(
14344
- `Memory refresh failed: ${relocation.memoryRefreshError instanceof Error ? relocation.memoryRefreshError.message : String(relocation.memoryRefreshError)}`
14345
- );
14346
- }
14347
15305
  try {
14348
- await config.getGeminiClient()?.addWorkingDirectoryChangedContext(previousCwd, canonicalPath);
14349
- } catch (error) {
14350
- warnings.push(
14351
- `Model context refresh failed: ${error instanceof Error ? error.message : String(error)}`
15306
+ const settledPreviousCwd = config.getTargetDir();
15307
+ if (canonicalPath === settledPreviousCwd) {
15308
+ return {
15309
+ previousCwd: settledPreviousCwd,
15310
+ newCwd: canonicalPath,
15311
+ warnings: []
15312
+ };
15313
+ }
15314
+ if (!trustValidated) {
15315
+ validateTrust();
15316
+ }
15317
+ session.hardSuspendTodoStopGuard();
15318
+ await waitForSessionDrain(
15319
+ session.waitForActiveTurnsToSettle(),
15320
+ SESSION_DRAIN_TIMEOUT_MS,
15321
+ "close"
15322
+ );
15323
+ const warnings = [];
15324
+ const relocation = await config.relocateWorkingDirectory(
15325
+ canonicalPath,
15326
+ canonicalPath,
15327
+ { skipProcessChdir: true, skipArtifactMigration: true }
14352
15328
  );
15329
+ if (relocation.memoryRefreshError) {
15330
+ warnings.push(
15331
+ `Memory refresh failed: ${relocation.memoryRefreshError instanceof Error ? relocation.memoryRefreshError.message : String(relocation.memoryRefreshError)}`
15332
+ );
15333
+ }
15334
+ if (relocation.mcpRefreshError) {
15335
+ warnings.push(
15336
+ `MCP refresh failed: ${relocation.mcpRefreshError instanceof Error ? relocation.mcpRefreshError.message : String(relocation.mcpRefreshError)}`
15337
+ );
15338
+ }
15339
+ try {
15340
+ await config.getGeminiClient()?.addWorkingDirectoryChangedContext(
15341
+ settledPreviousCwd,
15342
+ canonicalPath
15343
+ );
15344
+ } catch (error) {
15345
+ warnings.push(
15346
+ `Model context refresh failed: ${error instanceof Error ? error.message : String(error)}`
15347
+ );
15348
+ }
15349
+ return {
15350
+ previousCwd: settledPreviousCwd,
15351
+ newCwd: canonicalPath,
15352
+ warnings
15353
+ };
15354
+ } finally {
15355
+ releaseGate();
14353
15356
  }
14354
- session.clearTodoStopGuardTrust();
14355
- return { previousCwd, newCwd: canonicalPath, warnings };
14356
15357
  }
14357
15358
  case SERVE_CONTROL_EXT_METHODS.sessionApprovalMode: {
14358
15359
  const sessionId = params["sessionId"];
@@ -14868,149 +15869,91 @@ ${outputText}
14868
15869
  return result;
14869
15870
  }
14870
15871
  case SERVE_CONTROL_EXT_METHODS.workspaceMcpRuntimeAdd: {
14871
- const name = params["name"];
14872
- const config = params["config"];
14873
- const originatorClientId = params["originatorClientId"];
14874
- if (typeof name !== "string" || name.length === 0) {
14875
- throw RequestError.invalidParams(
14876
- void 0,
14877
- "Invalid or missing name"
14878
- );
14879
- }
14880
- if (!isValidServerName(name)) {
14881
- throw RequestError.invalidParams(
14882
- void 0,
14883
- "Server name must be \u2264256 chars, alphanumeric + underscore/hyphen, and not a reserved JS property name"
14884
- );
14885
- }
14886
- if (!config || typeof config !== "object" || Array.isArray(config)) {
14887
- throw RequestError.invalidParams(
14888
- void 0,
14889
- "Invalid or missing config"
14890
- );
14891
- }
14892
- const runtimeClientId = typeof originatorClientId === "string" && originatorClientId.length > 0 ? originatorClientId : "daemon";
14893
- const manager = this.config.getToolRegistry()?.getMcpClientManager();
14894
- if (!manager) {
14895
- throw RequestError.internalError(
14896
- void 0,
14897
- "McpClientManager unavailable on this Config"
14898
- );
14899
- }
14900
- try {
14901
- const {
14902
- trust: _trust,
14903
- authProviderType: _auth,
14904
- includeTools: _inc,
14905
- excludeTools: _exc,
14906
- cwd: _cwd,
14907
- env: _env,
14908
- oauth: _oauth,
14909
- headers: _headers,
14910
- type: _type,
14911
- // Reverse tool channel marker (issue #5626, Phase 2). The parent
14912
- // serve process stamps this on a client-hosted (extension) MCP
14913
- // server's runtime config; it never reaches the transport itself.
14914
- [CLIENT_MCP_OVER_WS_CONFIG_FLAG]: clientMcpOverWs,
14915
- ...safeConfig
14916
- } = config;
14917
- if (clientMcpOverWs === true) {
14918
- safeConfig["type"] = "sdk";
14919
- }
14920
- const result = await manager.addRuntimeMcpServer(
14921
- name,
14922
- safeConfig,
14923
- runtimeClientId
14924
- );
14925
- await Promise.all(
14926
- this.getActiveSessions().map(async (session) => {
14927
- const sessionManager = session.getConfig().getToolRegistry()?.getMcpClientManager();
14928
- if (!sessionManager) return;
14929
- try {
14930
- await sessionManager.addRuntimeMcpServer(
14931
- name,
14932
- safeConfig,
14933
- runtimeClientId
14934
- );
14935
- } catch (sessionErr) {
14936
- debugLogger7.warn(
14937
- `workspaceMcpRuntimeAdd: failed to add runtime MCP server '${name}' to active session ${session.getConfig().getSessionId()}: ${sessionErr instanceof Error ? sessionErr.message : String(sessionErr)}`
14938
- );
14939
- }
14940
- })
14941
- );
14942
- return result;
14943
- } catch (err) {
14944
- if (err instanceof McpBudgetWouldExceedError) {
14945
- throw new RequestError(-32099, err.message, {
14946
- errorKind: err.code,
14947
- serverName: err.serverName
14948
- });
14949
- }
14950
- if (err instanceof McpServerSpawnFailedError) {
14951
- throw new RequestError(-32099, err.message, {
14952
- errorKind: err.code,
14953
- serverName: err.serverName,
14954
- ...err.details
14955
- });
14956
- }
14957
- if (err instanceof InvalidMcpConfigError) {
14958
- throw new RequestError(-32099, err.message, {
14959
- errorKind: err.code,
14960
- serverName: err.serverName,
14961
- reason: err.reason
14962
- });
14963
- }
14964
- throw err;
14965
- }
15872
+ const request = readRuntimeMcpAddRequest(params);
15873
+ const result = await addRuntimeMcpServer(
15874
+ getRuntimeMcpManager(this.config),
15875
+ request
15876
+ );
15877
+ await Promise.all(
15878
+ this.getActiveSessions().map(async (session) => {
15879
+ const sessionManager = session.getConfig().getToolRegistry()?.getMcpClientManager();
15880
+ if (!sessionManager) return;
15881
+ try {
15882
+ await sessionManager.addRuntimeMcpServer(
15883
+ request.name,
15884
+ request.config,
15885
+ request.runtimeClientId
15886
+ );
15887
+ } catch (sessionErr) {
15888
+ debugLogger7.warn(
15889
+ `workspaceMcpRuntimeAdd: failed to add runtime MCP server '${request.name}' to active session ${session.getConfig().getSessionId()}: ${sessionErr instanceof Error ? sessionErr.message : String(sessionErr)}`
15890
+ );
15891
+ }
15892
+ })
15893
+ );
15894
+ return result;
14966
15895
  }
14967
15896
  case SERVE_CONTROL_EXT_METHODS.workspaceMcpRuntimeRemove: {
14968
- const name = params["name"];
14969
- const originatorClientId = params["originatorClientId"];
14970
- if (typeof name !== "string" || name.length === 0) {
14971
- throw RequestError.invalidParams(
14972
- void 0,
14973
- "Invalid or missing name"
14974
- );
14975
- }
14976
- if (!isValidServerName(name)) {
14977
- throw RequestError.invalidParams(
14978
- void 0,
14979
- "Server name must be \u2264256 chars, alphanumeric + underscore/hyphen, and not a reserved JS property name"
14980
- );
14981
- }
14982
- const runtimeClientId = typeof originatorClientId === "string" && originatorClientId.length > 0 ? originatorClientId : "daemon";
14983
- const manager = this.config.getToolRegistry()?.getMcpClientManager();
14984
- if (!manager) {
14985
- throw RequestError.internalError(
14986
- void 0,
14987
- "McpClientManager unavailable on this Config"
14988
- );
14989
- }
14990
- const result = await manager.removeRuntimeMcpServer(
14991
- name,
14992
- runtimeClientId
14993
- );
15897
+ const request = readRuntimeMcpRequest(params);
15898
+ const result = await getRuntimeMcpManager(
15899
+ this.config
15900
+ ).removeRuntimeMcpServer(request.name, request.runtimeClientId);
14994
15901
  await Promise.all(
14995
15902
  this.getActiveSessions().map(async (session) => {
14996
15903
  const sessionManager = session.getConfig().getToolRegistry()?.getMcpClientManager();
14997
15904
  if (!sessionManager) return;
14998
15905
  try {
14999
15906
  await sessionManager.removeRuntimeMcpServer(
15000
- name,
15001
- runtimeClientId
15907
+ request.name,
15908
+ request.runtimeClientId
15002
15909
  );
15003
15910
  } catch (sessionErr) {
15004
15911
  debugLogger7.warn(
15005
- `workspaceMcpRuntimeRemove: failed to remove runtime MCP server '${name}' from active session ${session.getConfig().getSessionId()}: ${sessionErr instanceof Error ? sessionErr.message : String(sessionErr)}`
15912
+ `workspaceMcpRuntimeRemove: failed to remove runtime MCP server '${request.name}' from active session ${session.getConfig().getSessionId()}: ${sessionErr instanceof Error ? sessionErr.message : String(sessionErr)}`
15006
15913
  );
15007
15914
  }
15008
15915
  })
15009
15916
  );
15010
15917
  return result;
15011
15918
  }
15919
+ case SERVE_CONTROL_EXT_METHODS.sessionMcpRuntimeAdd: {
15920
+ const sessionId = params["sessionId"];
15921
+ if (typeof sessionId !== "string" || sessionId.length === 0) {
15922
+ throw RequestError.invalidParams(
15923
+ void 0,
15924
+ "Invalid or missing sessionId"
15925
+ );
15926
+ }
15927
+ const session = this.sessionOrThrow(sessionId);
15928
+ return addRuntimeMcpServer(
15929
+ getRuntimeMcpManager(session.getConfig()),
15930
+ readRuntimeMcpAddRequest(params)
15931
+ );
15932
+ }
15933
+ case SERVE_CONTROL_EXT_METHODS.sessionMcpRuntimeRemove: {
15934
+ const sessionId = params["sessionId"];
15935
+ if (typeof sessionId !== "string" || sessionId.length === 0) {
15936
+ throw RequestError.invalidParams(
15937
+ void 0,
15938
+ "Invalid or missing sessionId"
15939
+ );
15940
+ }
15941
+ const session = this.sessionOrThrow(sessionId);
15942
+ const request = readRuntimeMcpRequest(params);
15943
+ const result = await getRuntimeMcpManager(
15944
+ session.getConfig()
15945
+ ).removeRuntimeMcpServer(request.name, request.runtimeClientId);
15946
+ return result;
15947
+ }
15012
15948
  case SERVE_CONTROL_EXT_METHODS.workspaceExtensionsRefresh: {
15013
15949
  const sessionId = params["sessionId"];
15950
+ const rawRefreshBootstrap = params["refreshBootstrap"];
15951
+ if (rawRefreshBootstrap !== void 0 && typeof rawRefreshBootstrap !== "boolean") {
15952
+ throw RequestError.invalidParams(
15953
+ void 0,
15954
+ "refreshBootstrap must be a boolean"
15955
+ );
15956
+ }
15014
15957
  const session = this.sessionOrThrow(sessionId);
15015
15958
  const config = session.getConfig();
15016
15959
  const extensionManager = config.getExtensionManager();
@@ -15024,6 +15967,12 @@ ${outputText}
15024
15967
  }, "runRefresh");
15025
15968
  await runRefresh(async () => await extensionManager.refreshCache());
15026
15969
  await runRefresh(async () => await extensionManager.refreshTools());
15970
+ const bootstrapConfig = this.config;
15971
+ if (rawRefreshBootstrap !== false && bootstrapConfig !== config) {
15972
+ await runRefresh(
15973
+ async () => await this.refreshBootstrapExtensionStatus()
15974
+ );
15975
+ }
15027
15976
  const discoveryConfig = this.workspaceMcpDiscoveryConfig;
15028
15977
  if (discoveryConfig && discoveryConfig !== config) {
15029
15978
  const discoveryExtensionManager = discoveryConfig.getExtensionManager();
@@ -15327,7 +16276,9 @@ ${outputText}
15327
16276
  apiKeyEnvKey: cfg?.apiKeyEnvKey ?? null
15328
16277
  };
15329
16278
  }
15330
- case SERVE_CONTROL_EXT_METHODS.sessionBranch: {
16279
+ case SERVE_CONTROL_EXT_METHODS.sessionBranch:
16280
+ case SERVE_CONTROL_EXT_METHODS.sessionSideTask: {
16281
+ const isSideTask = method === SERVE_CONTROL_EXT_METHODS.sessionSideTask;
15331
16282
  const sessionId = params["sessionId"];
15332
16283
  if (typeof sessionId !== "string" || !SESSION_ID_RE.test(sessionId)) {
15333
16284
  throw RequestError.invalidParams(
@@ -15350,7 +16301,17 @@ ${outputText}
15350
16301
  }
15351
16302
  const newSessionId = randomUUID2();
15352
16303
  const sessionService = sourceConfig.getSessionService();
15353
- await sessionService.forkSession(sessionId, newSessionId);
16304
+ const fork = /* @__PURE__ */ __name(() => isSideTask ? sessionService.forkSession(sessionId, newSessionId, {
16305
+ source: {
16306
+ sourceType: "side_task",
16307
+ sourceId: sessionId
16308
+ }
16309
+ }) : sessionService.forkSession(sessionId, newSessionId), "fork");
16310
+ if (isSideTask && recording) {
16311
+ await recording.runWithWriteBarrier(fork);
16312
+ } else {
16313
+ await fork();
16314
+ }
15354
16315
  let title;
15355
16316
  try {
15356
16317
  let baseName;
@@ -15365,7 +16326,7 @@ ${outputText}
15365
16326
  baseName = sessionId.slice(0, 8);
15366
16327
  }
15367
16328
  }
15368
- title = await computeUniqueBranchTitle(baseName, sessionService);
16329
+ title = isSideTask ? baseName : await computeUniqueBranchTitle(baseName, sessionService);
15369
16330
  const renamed = await sessionService.renameSession(
15370
16331
  newSessionId,
15371
16332
  title,
@@ -15699,16 +16660,58 @@ ${outputText}
15699
16660
  };
15700
16661
  }
15701
16662
  case SERVE_CONTROL_EXT_METHODS.workspaceSkillsRefresh: {
15702
- this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
16663
+ const rawReason = params["reason"];
16664
+ if (rawReason !== void 0 && rawReason !== "settings" && rawReason !== "content" && rawReason !== "all") {
16665
+ throw RequestError.invalidParams(
16666
+ void 0,
16667
+ "reason must be settings, content, or all"
16668
+ );
16669
+ }
16670
+ const reason = rawReason ?? "all";
16671
+ const refreshSettings = reason !== "content";
16672
+ const refreshContent = reason !== "settings";
16673
+ if (refreshSettings) {
16674
+ this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
16675
+ }
15703
16676
  const sessions = this.getActiveSessions();
16677
+ const settingsReloadResults = refreshSettings ? await Promise.allSettled(
16678
+ sessions.map(
16679
+ (session) => Promise.resolve().then(() => session.reloadSkillSettings())
16680
+ )
16681
+ ) : void 0;
16682
+ let configResults = [];
16683
+ if (refreshContent) {
16684
+ const skillManagers = new Set(
16685
+ [this.config, ...sessions.map((session) => session.getConfig())].map((config) => config.getSkillManager()).filter(
16686
+ (manager) => manager !== void 0
16687
+ )
16688
+ );
16689
+ configResults = await Promise.allSettled(
16690
+ [...skillManagers].map((manager) => manager.refreshCache())
16691
+ );
16692
+ for (const result of configResults) {
16693
+ if (result.status === "rejected") {
16694
+ debugLogger7.warn(`Skill config refresh failed: ${result.reason}`);
16695
+ }
16696
+ }
16697
+ }
15704
16698
  const results = await Promise.allSettled(
15705
- sessions.map((session) => session.refreshSkillsFromSettings())
16699
+ sessions.map((session, index) => {
16700
+ const settingsReload = settingsReloadResults?.[index];
16701
+ if (settingsReload?.status === "rejected") {
16702
+ return Promise.reject(settingsReload.reason);
16703
+ }
16704
+ return session.refreshSkillsFromSettings({
16705
+ reloadSettings: false,
16706
+ notifyConfigChanged: !refreshContent
16707
+ });
16708
+ })
15706
16709
  );
15707
16710
  for (let i = 0; i < results.length; i++) {
15708
16711
  if (results[i].status === "rejected") {
15709
- const reason = results[i].reason;
16712
+ const reason2 = results[i].reason;
15710
16713
  debugLogger7.warn(
15711
- `Session ${sessions[i].getId()} skill refresh failed: ${reason}`
16714
+ `Session ${sessions[i].getId()} skill refresh failed: ${reason2}`
15712
16715
  );
15713
16716
  }
15714
16717
  }
@@ -15718,7 +16721,14 @@ ${outputText}
15718
16721
  ).length,
15719
16722
  sessionsFailed: results.filter(
15720
16723
  (result) => result.status === "rejected"
15721
- ).length
16724
+ ).length,
16725
+ configsRefreshed: configResults.filter(
16726
+ (result) => result.status === "fulfilled"
16727
+ ).length,
16728
+ configsFailed: configResults.filter(
16729
+ (result) => result.status === "rejected"
16730
+ ).length,
16731
+ reason
15722
16732
  };
15723
16733
  }
15724
16734
  default:
@@ -15781,6 +16791,7 @@ ${outputText}
15781
16791
  [],
15782
16792
  settings,
15783
16793
  void 0,
16794
+ void 0,
15784
16795
  false,
15785
16796
  {
15786
16797
  skipMcpDiscovery: true,
@@ -15822,8 +16833,9 @@ ${outputText}
15822
16833
  throw error;
15823
16834
  }
15824
16835
  }
15825
- async newSessionConfig(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}, chatRecording) {
16836
+ async newSessionConfig(cwd, mcpServers, settings, isChannelSession, sessionId, resume, initializeOptions = {}, chatRecording) {
15826
16837
  try {
16838
+ this.assertManagedSessionAdmission();
15827
16839
  return await this.runWithPinnedRuntimeBaseDir(settings, cwd, async () => {
15828
16840
  await this.retryPendingConfigCleanup(
15829
16841
  Storage.getRuntimeBaseDir(),
@@ -15833,6 +16845,7 @@ ${outputText}
15833
16845
  cwd,
15834
16846
  mcpServers,
15835
16847
  settings,
16848
+ isChannelSession,
15836
16849
  sessionId,
15837
16850
  resume,
15838
16851
  initializeOptions,
@@ -15849,7 +16862,7 @@ ${outputText}
15849
16862
  throw error;
15850
16863
  }
15851
16864
  }
15852
- async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}, chatRecording) {
16865
+ async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, isChannelSession, sessionId, resume, initializeOptions = {}, chatRecording) {
15853
16866
  const sessionMcpServers = {};
15854
16867
  for (const server of mcpServers) {
15855
16868
  const stdioServer = toStdioServer(server);
@@ -15861,8 +16874,7 @@ ${outputText}
15861
16874
  sessionMcpServers[stdioServer.name] = new MCPServerConfig(
15862
16875
  stdioServer.command,
15863
16876
  stdioServer.args,
15864
- env,
15865
- cwd
16877
+ env
15866
16878
  );
15867
16879
  continue;
15868
16880
  }
@@ -15901,7 +16913,14 @@ ${outputText}
15901
16913
  continue;
15902
16914
  }
15903
16915
  }
15904
- const mergedSettings = settings.merged;
16916
+ const mergedSettings = {
16917
+ ...settings.merged,
16918
+ experimental: {
16919
+ ...settings.merged.experimental,
16920
+ sessionWriterLease: this.sessionWriterLeaseEnabledAtStartup,
16921
+ ...isChannelSession ? { cron: false } : {}
16922
+ }
16923
+ };
15905
16924
  const sessionArg = resume === true ? { resume: sessionId, sessionId: void 0 } : { sessionId, resume: void 0 };
15906
16925
  const argvForSession = {
15907
16926
  ...this.argv,
@@ -15936,6 +16955,21 @@ ${outputText}
15936
16955
  buildDisabledSkillNamesProvider(settings),
15937
16956
  sessionMcpServers
15938
16957
  );
16958
+ if (chatRecording !== false) {
16959
+ this.initializingConfigs.add(config);
16960
+ }
16961
+ try {
16962
+ this.assertManagedSessionAdmission();
16963
+ if (this.isTrustedManagedParent()) {
16964
+ config.setSessionWriterReclaimPolicy("never");
16965
+ config.setSessionWriterTakeoverPolicy("certified");
16966
+ }
16967
+ } catch (error) {
16968
+ return this.cleanupAfterRequestFailure(
16969
+ error,
16970
+ () => this.cleanupUnstoredConfig(config)
16971
+ );
16972
+ }
15939
16973
  if (!initializeOptions.skipFileCheckpointing && typeof config.enableFileCheckpointing === "function") {
15940
16974
  config.enableFileCheckpointing();
15941
16975
  }
@@ -15976,6 +17010,7 @@ ${outputText}
15976
17010
  // (the daemon only adds SDK-type runtime servers for client MCP).
15977
17011
  sendSdkMcpMessage: this.buildClientMcpSender(wiredSessionId)
15978
17012
  });
17013
+ this.assertManagedSessionAdmission();
15979
17014
  } catch (error) {
15980
17015
  return this.cleanupAfterRequestFailure(
15981
17016
  error,
@@ -16036,17 +17071,20 @@ ${outputText}
16036
17071
  config.setFileSystemService(acpFileSystemService);
16037
17072
  }
16038
17073
  async createAndStoreSession(config, settings, sessionData, options = {}) {
17074
+ this.assertManagedSessionAdmission();
16039
17075
  const sessionId = config.getSessionId();
16040
17076
  const geminiClient = config.getGeminiClient();
16041
17077
  const needsInitialize = !geminiClient.isInitialized();
16042
17078
  if (needsInitialize) {
16043
17079
  await geminiClient.initialize();
16044
17080
  }
17081
+ this.assertManagedSessionAdmission();
16045
17082
  if (this.sessions.has(sessionId)) {
16046
17083
  throw new Error(`Session ${sessionId} is already active.`);
16047
17084
  }
16048
17085
  const session = new Session(sessionId, config, this.connection, settings);
16049
17086
  this.sessions.set(sessionId, session);
17087
+ this.initializingConfigs.delete(config);
16050
17088
  try {
16051
17089
  if (sessionData?.fileHistorySnapshots?.length) {
16052
17090
  config.getFileHistoryService().restoreFromSnapshots(sessionData.fileHistorySnapshots);
@@ -16060,10 +17098,9 @@ ${outputText}
16060
17098
  sessionData.historyGaps
16061
17099
  );
16062
17100
  }
16063
- if (options.startPostReplayServices !== false) {
16064
- session.installRewriter();
16065
- session.startCronScheduler();
16066
- }
17101
+ await options.beforeStartPostReplayServices?.(session);
17102
+ session.installRewriter();
17103
+ session.startCronScheduler();
16067
17104
  setTimeout(() => {
16068
17105
  void session.sendAvailableCommandsUpdate();
16069
17106
  }, 0);
@@ -16194,6 +17231,7 @@ export {
16194
17231
  fetchAllowedGitHub,
16195
17232
  normalizeCoreSettingValue,
16196
17233
  runAcpAgent,
17234
+ selectVisibleHistoryRecords,
16197
17235
  toHttpServer,
16198
17236
  toSseServer,
16199
17237
  toStdioServer