@qwen-code/qwen-code 0.21.1 → 0.21.2-nightly.20260801.bc382c3ff

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 (367) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +9 -7
  2. package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
  3. package/bundled/qc-helper/docs/features/channels/github.md +49 -10
  4. package/bundled/qc-helper/docs/features/channels/gitlab.md +177 -0
  5. package/bundled/qc-helper/docs/features/code-review.md +20 -0
  6. package/bundled/qc-helper/docs/features/commands.md +1 -0
  7. package/bundled/qc-helper/docs/features/hooks.md +135 -18
  8. package/bundled/qc-helper/docs/features/memory.md +27 -0
  9. package/bundled/qc-helper/docs/features/skills.md +14 -0
  10. package/bundled/qc-helper/docs/features/sub-agents.md +55 -8
  11. package/bundled/qc-helper/docs/features/tool-use-summaries.md +7 -7
  12. package/bundled/qc-helper/docs/qwen-serve.md +28 -6
  13. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +2 -2
  14. package/bundled/review/SKILL.md +1 -1
  15. package/chunks/{MaxSizedBox-VI3ROJJA.js → MaxSizedBox-CDHTDITS.js} +45 -40
  16. package/chunks/{StandaloneSessionPicker-LYXKD2EV.js → StandaloneSessionPicker-L63HUAHP.js} +65 -60
  17. package/chunks/{acp-startup-profiler-DFVPFQ6C.js → acp-startup-profiler-3RICG2YW.js} +2 -2
  18. package/chunks/{acpAgent-WN5SRDQO.js → acpAgent-6WVVT2P3.js} +962 -599
  19. package/chunks/{agent-K6ECSM64.js → agent-KDM4CBOU.js} +40 -35
  20. package/chunks/agent-headless-AS7K2K57.js +79 -0
  21. package/chunks/{anthropicContentGenerator-V2QOGVYD.js → anthropicContentGenerator-WCBYB6JG.js} +337 -27
  22. package/chunks/{artifact-tool-6K6U7XYJ.js → artifact-tool-ANV4CFCR.js} +2 -2
  23. package/chunks/{askUserQuestion-GD2IJJ7I.js → askUserQuestion-MALEB47H.js} +2 -2
  24. package/chunks/{bridge-3KJEWDNE.js → bridge-JNEW6FES.js} +46 -41
  25. package/chunks/{build-S6DO7LMM.js → build-GDBLPA24.js} +1 -1
  26. package/chunks/{ca-6W3SK7OQ.js → ca-4OJN75WT.js} +46 -5
  27. package/chunks/{channel-management-service-XR7GZSWF.js → channel-management-service-QOO7TD3T.js} +21 -6
  28. package/chunks/{channel-settings-store-HW4FXXUA.js → channel-settings-store-4CSMTR4L.js} +47 -42
  29. package/chunks/{channel-worker-group-XDPTDWTX.js → channel-worker-group-ERSUOPIR.js} +8 -8
  30. package/chunks/{channel-worker-manager-YYEHVRRE.js → channel-worker-manager-X247YDQ7.js} +8 -8
  31. package/chunks/{channel-worker-supervisor-74HTWA2G.js → channel-worker-supervisor-ORJIEEPP.js} +4 -4
  32. package/chunks/{chunk-VWOOBLTY.js → chunk-25QQVOCG.js} +5 -5
  33. package/chunks/{chunk-CAPPWD3X.js → chunk-2A6MHYIA.js} +3 -3
  34. package/chunks/{chunk-2XSLTRFZ.js → chunk-2CTKGIFR.js} +2 -2
  35. package/chunks/{chunk-DZLYR4U3.js → chunk-2DNKEBXY.js} +1 -1
  36. package/chunks/{chunk-UWMLWVCA.js → chunk-2IIJTXYF.js} +26 -10
  37. package/chunks/{chunk-JYBU6YUE.js → chunk-2M5N3DHY.js} +1 -1
  38. package/chunks/{chunk-AQIDMUGU.js → chunk-2PNQQ4UR.js} +2 -2
  39. package/chunks/{chunk-OKF7JF3R.js → chunk-2UISUFHQ.js} +3 -3
  40. package/chunks/{chunk-2LQTH543.js → chunk-33FNCQSY.js} +2 -2
  41. package/chunks/{chunk-M7OONWYU.js → chunk-3LGZEYOF.js} +4 -2
  42. package/chunks/{chunk-ZURDMIDR.js → chunk-3MHPWQ2M.js} +242 -76
  43. package/chunks/{chunk-UHUSJ6X7.js → chunk-3RXUYQJI.js} +25 -6
  44. package/chunks/{chunk-E5Z2AVNV.js → chunk-3SH53ANB.js} +0 -11
  45. package/chunks/{chunk-BNWB5CYE.js → chunk-3WXMXT7C.js} +22 -11
  46. package/chunks/{chunk-A2D5BAVP.js → chunk-42IKVPST.js} +1 -1
  47. package/chunks/{chunk-2DN4J57Y.js → chunk-432XCUHF.js} +1 -1
  48. package/chunks/{chunk-EVKE2FZL.js → chunk-433VD3HX.js} +4 -4
  49. package/chunks/{chunk-Q43KPN7X.js → chunk-434YCHSV.js} +6 -6
  50. package/chunks/{chunk-5TBMQLGG.js → chunk-4LKVQFHM.js} +2 -2
  51. package/chunks/{chunk-YDLJGZHL.js → chunk-4NFY2S7N.js} +0 -33
  52. package/chunks/{chunk-6PE7N3A4.js → chunk-5UJ6A3CH.js} +145 -10
  53. package/chunks/{chunk-GNR2RNMP.js → chunk-5UZITEHA.js} +3 -3
  54. package/chunks/chunk-6FMJLI5M.js +1591 -0
  55. package/chunks/{chunk-RPLGZJV2.js → chunk-6O5DVH27.js} +1 -1
  56. package/chunks/{chunk-2RFKHEXL.js → chunk-6PLDPT2C.js} +1 -1
  57. package/chunks/{chunk-7AEJDLRA.js → chunk-7IYLHTTM.js} +3 -3
  58. package/chunks/{chunk-65PQENQP.js → chunk-7K2WTPQO.js} +5 -5
  59. package/chunks/{chunk-P4WOAOJW.js → chunk-7MY2AR5A.js} +72 -26
  60. package/chunks/{chunk-GXIJHV66.js → chunk-A2A34TSB.js} +3 -3
  61. package/chunks/{chunk-XWWKIXVD.js → chunk-A5YZ3FA2.js} +2 -1
  62. package/chunks/{chunk-64LQLPL7.js → chunk-A6SX5TAH.js} +3 -3
  63. package/chunks/{chunk-SZ3KHTDR.js → chunk-AKA24BGO.js} +1 -1
  64. package/chunks/chunk-AQ37AY7B.js +93 -0
  65. package/chunks/{chunk-2N7CODY5.js → chunk-AQEWCKX4.js} +2 -2
  66. package/chunks/{chunk-KCO4FLFJ.js → chunk-AYB4HSBI.js} +3 -3
  67. package/chunks/{chunk-WZRWHXFE.js → chunk-BFHXDAR7.js} +1 -1
  68. package/chunks/{chunk-L55JWS76.js → chunk-BGXZBI5B.js} +1 -1
  69. package/chunks/{chunk-5MKRTI4T.js → chunk-BKUN5QHP.js} +7 -7
  70. package/chunks/{chunk-Y4IHBGBP.js → chunk-BV4QX43X.js} +1 -1
  71. package/chunks/{chunk-PB3MBFKG.js → chunk-C4L2MEIT.js} +4 -4
  72. package/chunks/{chunk-TCIFAA7K.js → chunk-CHCLO3M7.js} +14 -14
  73. package/chunks/{chunk-CVHIL5IG.js → chunk-CWEIMFFW.js} +13 -6
  74. package/chunks/{chunk-2FAK6PNM.js → chunk-DUIJ2IXG.js} +5 -13
  75. package/chunks/{chunk-T2QMKU3R.js → chunk-DVGTU5TC.js} +19 -7
  76. package/chunks/{chunk-LGAOC3ZS.js → chunk-DYA25Y7U.js} +1 -1
  77. package/chunks/{chunk-SGFT55XI.js → chunk-E4WHKETF.js} +32 -4
  78. package/chunks/{chunk-WBL3FJEU.js → chunk-FC4KQFCS.js} +1 -1
  79. package/chunks/{chunk-MHAIJPTD.js → chunk-FJHA23GM.js} +12 -12
  80. package/chunks/{chunk-S7W2GKIO.js → chunk-G7XXKQYS.js} +2 -0
  81. package/chunks/{chunk-MR5EAQ5M.js → chunk-GALUTA2C.js} +1 -1
  82. package/chunks/{chunk-7I5GTCT4.js → chunk-GB3AB7TR.js} +4008 -3648
  83. package/chunks/{chunk-QIZKCVM3.js → chunk-GHJM2C2T.js} +6 -8
  84. package/chunks/chunk-GOFAQQZA.js +132 -0
  85. package/chunks/{chunk-BCZFQXWK.js → chunk-GTM6IHBB.js} +2 -2
  86. package/chunks/{chunk-5ZF5XXTS.js → chunk-GVISB2OH.js} +2 -2
  87. package/chunks/{chunk-FNMZK765.js → chunk-H36SETQS.js} +1 -1
  88. package/chunks/{chunk-UBEPNVDI.js → chunk-H4346YW5.js} +28 -16
  89. package/chunks/{chunk-CQL64ESB.js → chunk-H4DSRWAS.js} +24 -13
  90. package/chunks/{chunk-YGF33UXG.js → chunk-H6MC6VQX.js} +222 -173
  91. package/chunks/{chunk-GZXCZHCT.js → chunk-I3G5JWBV.js} +1 -1
  92. package/chunks/{chunk-Y6AXW2OG.js → chunk-I5GNT6ZS.js} +7 -1
  93. package/chunks/{chunk-GEBV2JGB.js → chunk-I6FAHB4N.js} +1 -1
  94. package/chunks/{chunk-UPUG4GXM.js → chunk-I7JDGNG6.js} +3 -3
  95. package/chunks/{chunk-JHNRZMHI.js → chunk-II6WPWHY.js} +9 -9
  96. package/chunks/{chunk-B4AJNNOL.js → chunk-J26HHFI5.js} +1 -1
  97. package/chunks/{chunk-S3TWXGKA.js → chunk-JE7KQ2UP.js} +4 -2
  98. package/chunks/{chunk-ZHBO7WVX.js → chunk-JELIWHXD.js} +1 -1
  99. package/chunks/{chunk-3EFXSQCM.js → chunk-JRIDA5HF.js} +7 -7
  100. package/chunks/{chunk-TFRMVU6R.js → chunk-K4CGQN4Q.js} +1 -1
  101. package/chunks/{chunk-WUZ7H6DP.js → chunk-K5Q62CGR.js} +1 -1
  102. package/chunks/{chunk-JCW2R7WC.js → chunk-K623ENWT.js} +3 -79
  103. package/chunks/{chunk-T2NCM2ET.js → chunk-K6KS3LTN.js} +2 -749
  104. package/chunks/{chunk-TDL6LB4K.js → chunk-KG22G46Y.js} +22 -10
  105. package/chunks/{chunk-GATT5TKW.js → chunk-KKN2IE7Q.js} +1 -1
  106. package/chunks/{chunk-JMONIXMJ.js → chunk-KVUBYJDM.js} +2 -2
  107. package/chunks/{chunk-TBBV36Y4.js → chunk-KXSYDCP2.js} +4 -4
  108. package/chunks/{chunk-EIF3FXTB.js → chunk-LAPK3GLC.js} +121 -18
  109. package/chunks/chunk-LBOVL47Y.js +29 -0
  110. package/chunks/{chunk-U3E3UQAA.js → chunk-LBWNSLJK.js} +4 -4
  111. package/chunks/{chunk-S4WJVPZW.js → chunk-LL4U3BSH.js} +15 -7
  112. package/chunks/{chunk-657BH7VM.js → chunk-LRJWFR6L.js} +4 -4
  113. package/chunks/{chunk-PT722TDT.js → chunk-M2F5PLOW.js} +770 -125
  114. package/chunks/{chunk-3L2SPEBH.js → chunk-M744OFVE.js} +1 -1
  115. package/chunks/{chunk-VYOXCEPJ.js → chunk-MBKPUM5Y.js} +1 -1
  116. package/chunks/chunk-MISUEWB4.js +8749 -0
  117. package/chunks/{chunk-PONHVBRT.js → chunk-MOHAWIAW.js} +2 -2
  118. package/chunks/{chunk-HMRM2A3U.js → chunk-MSIVKDRC.js} +4 -4
  119. package/chunks/{record-artifact-XAMSFSW4.js → chunk-MYT7N6QH.js} +22 -7
  120. package/chunks/{chunk-X5WNMMIA.js → chunk-NGWYUZZO.js} +11510 -15137
  121. package/chunks/{chunk-PQNHRFJC.js → chunk-NYX53SV4.js} +0 -2
  122. package/chunks/{chunk-6RPMI2AB.js → chunk-NZB4NDJL.js} +10 -10
  123. package/chunks/{chunk-BGTQCTQW.js → chunk-O2ZYHG33.js} +6 -5
  124. package/chunks/chunk-O6GEWCJA.js +21 -0
  125. package/chunks/{chunk-JX27F6QS.js → chunk-OBAIHYFT.js} +1 -1
  126. package/chunks/{chunk-BPZKP57P.js → chunk-OCRM53TT.js} +3 -3
  127. package/chunks/{chunk-V7RNNPGC.js → chunk-P5Y23G2L.js} +18 -1
  128. package/chunks/{chunk-FTD6DP4T.js → chunk-PDDYAXL2.js} +5 -1
  129. package/chunks/{chunk-JSD33JG6.js → chunk-PGEGUNH5.js} +67 -10
  130. package/chunks/{chunk-A4COXFB3.js → chunk-PGP7Y3RQ.js} +5 -5
  131. package/chunks/{chunk-T3O2B4XO.js → chunk-PHODQP2V.js} +6 -6
  132. package/chunks/{chunk-BMFALVGQ.js → chunk-PXA5AWHY.js} +1 -1
  133. package/chunks/chunk-QL4TN4HS.js +59 -0
  134. package/chunks/{chunk-W4MIWP6M.js → chunk-QMBEW7EW.js} +2 -2
  135. package/chunks/{chunk-U4VTUMMK.js → chunk-QONSRAEV.js} +1 -1
  136. package/chunks/{chunk-LW3RFMG7.js → chunk-QYPT3QUD.js} +3 -3
  137. package/chunks/{chunk-TV64SXKD.js → chunk-RGJ4JWSU.js} +131 -48
  138. package/chunks/{chunk-75MIQ3LV.js → chunk-RPYYTL7E.js} +61 -13
  139. package/chunks/{chunk-52ZSWYEG.js → chunk-SK2UKB45.js} +1 -1
  140. package/chunks/{chunk-PLDQBIO6.js → chunk-SWEBEXPI.js} +1 -1
  141. package/chunks/chunk-T3CHYWJZ.js +758 -0
  142. package/chunks/{chunk-VCPIZRYH.js → chunk-TFFMATHX.js} +9 -7
  143. package/chunks/{chunk-J7OACQDE.js → chunk-TNVKFQXQ.js} +458 -97
  144. package/chunks/{chunk-A3NDJ5SB.js → chunk-TYERNYH4.js} +2 -2
  145. package/chunks/{chunk-GKX7E4CO.js → chunk-U25CMJYY.js} +1 -1
  146. package/chunks/{chunk-7XATOOE7.js → chunk-UH7Z7Y45.js} +1 -1
  147. package/chunks/{chunk-XFZYFU3I.js → chunk-UHQ3L6GC.js} +1 -1
  148. package/chunks/{chunk-GZ3RCT54.js → chunk-UHTJC7O3.js} +1 -1
  149. package/chunks/{chunk-XZC5VLBZ.js → chunk-UKZEXS6K.js} +6 -0
  150. package/chunks/{chunk-LO4ROVP4.js → chunk-UOFFZNXV.js} +111 -13
  151. package/chunks/{chunk-5YKDXHUY.js → chunk-URN76TKR.js} +2 -2
  152. package/chunks/{chunk-T4TXDL7G.js → chunk-UWLG4UCE.js} +132 -35
  153. package/chunks/{chunk-KAMYKP7E.js → chunk-UWSXFI6E.js} +1 -1
  154. package/chunks/{chunk-7BAU433D.js → chunk-VS3GXRNZ.js} +1198 -240
  155. package/chunks/{chunk-EJGJIBRS.js → chunk-VWF42XC6.js} +3 -3
  156. package/chunks/{chunk-RCUQIPTN.js → chunk-W7XZ3KP5.js} +1 -1
  157. package/chunks/{chunk-OCESJA77.js → chunk-WISQLM4Q.js} +1197 -1154
  158. package/chunks/{chunk-NOKIVHOL.js → chunk-WK4TJUEA.js} +1 -1
  159. package/chunks/{chunk-JFMA7Y5M.js → chunk-WP4HGHFG.js} +5 -5
  160. package/chunks/{chunk-4G2BISNC.js → chunk-XC2VAFVZ.js} +1 -1
  161. package/chunks/{chunk-2LKVPASC.js → chunk-XC656O42.js} +3 -3
  162. package/chunks/{chunk-5KTQXHPY.js → chunk-XCLLRKY5.js} +3 -3
  163. package/chunks/{chunk-HV26XH34.js → chunk-XFDPIC4P.js} +3 -3
  164. package/chunks/{chunk-JTV5K7NH.js → chunk-XSA5EKTJ.js} +1 -1
  165. package/chunks/{chunk-75GFAX4R.js → chunk-YAVY33G4.js} +1 -1
  166. package/chunks/{chunk-WBSMNTSV.js → chunk-YXEVDA66.js} +2 -2
  167. package/chunks/{chunk-7DXQIJID.js → chunk-ZRFJ75D7.js} +3 -3
  168. package/chunks/{chunk-XBYYDKAZ.js → chunk-ZTN6OA5J.js} +8 -7
  169. package/chunks/{computer-use-ZTIDHMMA.js → computer-use-Z4NCIIJN.js} +40 -35
  170. package/chunks/{config-utils-NYSXDMEQ.js → config-utils-64LM6OEQ.js} +4 -4
  171. package/chunks/{contextCommand-2PIEU37Z.js → contextCommand-HVM7XFCB.js} +43 -38
  172. package/chunks/{core-runtime-3XEYLQFK.js → core-runtime-NL3ZBHBU.js} +40 -35
  173. package/chunks/{create-sub-session-SBYUMSSS.js → create-sub-session-AM32K2HD.js} +2 -2
  174. package/chunks/{create-sub-session-R76FVXCI.js → create-sub-session-XHSCDYFU.js} +43 -38
  175. package/chunks/{cron-create-2QK6TCEC.js → cron-create-HPXYE6C5.js} +4 -4
  176. package/chunks/{cron-delete-FDCDFYMG.js → cron-delete-FPVNTKPK.js} +4 -4
  177. package/chunks/{cron-list-XN3WVBTP.js → cron-list-ZEI6PAAV.js} +4 -4
  178. package/chunks/{daemon-Q2AB5Z23.js → daemon-PCNCI5YU.js} +72 -3
  179. package/chunks/daemon-status-provider-XD23SNAM.js +94 -0
  180. package/chunks/{daemon-trust-policy-ILUDTLHD.js → daemon-trust-policy-NOHK7IW5.js} +46 -41
  181. package/chunks/{daemon-trust-policy-monitor-HS3PKKRO.js → daemon-trust-policy-monitor-ZBTSR333.js} +46 -41
  182. package/chunks/{de-SY6O76BF.js → de-A6TI4LBB.js} +46 -5
  183. package/chunks/{deferred-core-runtime-X4QV662U.js → deferred-core-runtime-JJBHKM2C.js} +40 -35
  184. package/chunks/{dist-HVRQ2CFL.js → dist-4LAMY2SK.js} +1180 -5
  185. package/chunks/{dist-DOLYHMXE.js → dist-4T4NCJFL.js} +2 -2
  186. package/chunks/dist-7KOL6OMD.js +13467 -0
  187. package/chunks/{dist-SSU66DM4.js → dist-BH76AT7N.js} +1 -1
  188. package/chunks/{dist-BSTVRPMT.js → dist-BXA3JXVQ.js} +541 -19
  189. package/chunks/{dist-SV7Q3AWJ.js → dist-OEEFI6UU.js} +12 -9
  190. package/chunks/{dist-YGBBMK3Z.js → dist-SMLVOWKV.js} +5 -4
  191. package/chunks/{dist-IXQEQWRG.js → dist-V2RK6S6Q.js} +1 -1
  192. package/chunks/{earlyInputCapture-XKLZT7ZD.js → earlyInputCapture-KLAZDAIP.js} +41 -36
  193. package/chunks/{edit-HHGIOTQ2.js → edit-YQZWCISX.js} +40 -35
  194. package/chunks/{en-NBK3JKCE.js → en-RESOFG55.js} +46 -5
  195. package/chunks/{enter-worktree-ZN7PUQ46.js → enter-worktree-WLVWI3FP.js} +40 -35
  196. package/chunks/{enterPlanMode-EIFIDSIV.js → enterPlanMode-6RYXFQUD.js} +40 -35
  197. package/chunks/{environment-XXQ75D2Q.js → environment-DXJTXSVT.js} +43 -38
  198. package/chunks/{errors-4GMVU7CK.js → errors-XGAGG2S2.js} +43 -38
  199. package/chunks/{exit-worktree-GXMI4ATY.js → exit-worktree-C4276VPP.js} +40 -35
  200. package/chunks/{exitPlanMode-34UVY7M6.js → exitPlanMode-MM5HIRUF.js} +40 -35
  201. package/chunks/{fast-path-VPIVA7L6.js → fast-path-PIXYOHCH.js} +6 -2
  202. package/chunks/{fr-4KG5V7UT.js → fr-QF7RI5ZE.js} +46 -5
  203. package/chunks/{gemini-4BWIK4WD.js → gemini-43RLVUNP.js} +158 -96
  204. package/chunks/{geminiContentGenerator-3XVV5MSS.js → geminiContentGenerator-PNQ4TSID.js} +6 -6
  205. package/chunks/{glob-TZ2ABCJG.js → glob-ZMBQKAU5.js} +40 -35
  206. package/chunks/goal-tools-Y767F7LZ.js +335 -0
  207. package/chunks/{grep-BEF463NA.js → grep-HSV37W2Q.js} +40 -35
  208. package/chunks/handleAutoUpdate-QDHZPBAY.js +85 -0
  209. package/chunks/{i18n-FMM5FDXR.js → i18n-ME22A6RN.js} +42 -37
  210. package/chunks/{image-gen-HHVLF7HS.js → image-gen-IFC7ZWSB.js} +9 -9
  211. package/chunks/{initializer-625TIAIO.js → initializer-J7H2CHVB.js} +47 -42
  212. package/chunks/{installationInfo-6AM4I2Y3.js → installationInfo-R7FXPQN5.js} +41 -36
  213. package/chunks/{ja-F3GSQXMF.js → ja-URQESVGW.js} +46 -5
  214. package/chunks/{keychain-token-storage-72IYCAZV.js → keychain-token-storage-7BT4TQ2A.js} +2 -2
  215. package/chunks/{kittyProtocolDetector-MBRTDRBK.js → kittyProtocolDetector-BFLAKYXH.js} +1 -1
  216. package/chunks/list-OYDIBA4N.js +93 -0
  217. package/chunks/{list-agents-R6KDXQR3.js → list-agents-GATIBBQQ.js} +2 -2
  218. package/chunks/{loadedSettingsAdapter-SPUTNKAV.js → loadedSettingsAdapter-OK6GK2GE.js} +46 -41
  219. package/chunks/{loggingContentGenerator-LKOF7XI7.js → loggingContentGenerator-U4ZEG4GL.js} +53 -38
  220. package/chunks/{loop-wakeup-3IQKCYAH.js → loop-wakeup-3DZMQQQQ.js} +13 -6
  221. package/chunks/{ls-DKZ37A7N.js → ls-7F4GHXIH.js} +4 -4
  222. package/chunks/{lsp-QNWN7KN3.js → lsp-6FEHVBWI.js} +2 -2
  223. package/chunks/{managed-npm-update-ACQGGIN5.js → managed-npm-update-PGKAJLLO.js} +43 -38
  224. package/chunks/mcp-S4DXJD2G.js +87 -0
  225. package/chunks/{monitor-DF52UVHI.js → monitor-E5ZFMT74.js} +40 -35
  226. package/chunks/nonInteractiveCli-HNOHKEPE.js +149 -0
  227. package/chunks/{notebook-edit-FCWS4XVN.js → notebook-edit-6QDN6VZJ.js} +40 -35
  228. package/chunks/{openaiContentGenerator-7LDK3DCJ.js → openaiContentGenerator-3NLB2C5O.js} +19 -19
  229. package/chunks/{pidfile-6ERW3DF4.js → pidfile-ZMOIUGG6.js} +41 -36
  230. package/chunks/{processUtils-COKZAMUP.js → processUtils-E4QGQVWW.js} +2 -2
  231. package/chunks/{pt-EQ33KWEN.js → pt-EEEQXRUI.js} +46 -5
  232. package/chunks/{qwenContentGenerator-TKWUMR7N.js → qwenContentGenerator-2LFRWJTM.js} +46 -41
  233. package/chunks/{qwenOAuth2-7HMU47SF.js → qwenOAuth2-N32BUQDC.js} +8 -8
  234. package/chunks/{read-file-X6DRC574.js → read-file-GLDCWZBG.js} +11 -11
  235. package/chunks/{read-mcp-resource-GFTWYXMK.js → read-mcp-resource-AFS3UKZO.js} +2 -2
  236. package/chunks/record-artifact-ECZSCEG5.js +21 -0
  237. package/chunks/{resumeHistoryUtils-PFPM2GWM.js → resumeHistoryUtils-F5BE5QDW.js} +48 -43
  238. package/chunks/ripGrep-T23Y4AGY.js +77 -0
  239. package/chunks/{ru-7OZAUKGG.js → ru-WGZDYQAB.js} +46 -5
  240. package/chunks/{run-qwen-serve-TSTCO4XE.js → run-qwen-serve-TI2HGLLU.js} +290 -75
  241. package/chunks/{runtime-DAUPSUKI.js → runtime-WCWM3DO7.js} +53 -46
  242. package/chunks/{scheduler-KMADMT26.js → scheduler-2QZO5AV5.js} +40 -35
  243. package/chunks/{sdk-exporters-http-WO556XNU.js → sdk-exporters-http-IKNWQJNV.js} +3 -3
  244. package/chunks/{sdk-impl-LPAVACSF.js → sdk-impl-7CUUMQDB.js} +3 -3
  245. package/chunks/{send-message-SAWK4DZX.js → send-message-X7G2JSII.js} +6 -11
  246. package/chunks/{serve-NNRWS6F4.js → serve-DZOMYUFU.js} +46 -41
  247. package/chunks/{server-WEH7DVCH.js → server-N4AJRKIQ.js} +2269 -1016
  248. package/chunks/{session-WXC56V2I.js → session-GS6AKMN7.js} +151 -86
  249. package/chunks/{settings-DJDXFDZ3.js → settings-CUN3SELH.js} +50 -45
  250. package/chunks/{shell-JN5VRQXD.js → shell-NGBFVXC5.js} +40 -35
  251. package/chunks/{skill-SGXPKJCS.js → skill-SC2BSO75.js} +30 -16
  252. package/chunks/{skill-settings-VJ5PDMZI.js → skill-settings-XVPCPW5K.js} +45 -40
  253. package/chunks/{spawnChannel-ETMJW7YX.js → spawnChannel-RILO4YY3.js} +42 -37
  254. package/chunks/{standalone-update-MK3Z7KBI.js → standalone-update-TMLT6LVJ.js} +43 -38
  255. package/chunks/{startInteractiveUI-ZCGIXPGT.js → startInteractiveUI-J45WOEOU.js} +883 -1112
  256. package/chunks/{syntheticOutput-355CB6CJ.js → syntheticOutput-FHRY3BPQ.js} +3 -3
  257. package/chunks/{task-create-INGWNUG4.js → task-create-LAQXBIHC.js} +11 -10
  258. package/chunks/{task-list-5XNNGTF4.js → task-list-V6K5DRDH.js} +6 -6
  259. package/chunks/{task-stop-4ROAOBXH.js → task-stop-LQXE52L6.js} +2 -2
  260. package/chunks/{task-update-CRK5VWWZ.js → task-update-NXRCXSPB.js} +11 -10
  261. package/chunks/{team-create-QQGAJG7P.js → team-create-W3EVWCTA.js} +40 -35
  262. package/chunks/{team-delete-S2RCXA4P.js → team-delete-Z4KGO7RC.js} +6 -6
  263. package/chunks/{team-plan-approval-RT7Q5R6O.js → team-plan-approval-URYVKJF4.js} +40 -35
  264. package/chunks/theme-manager-CUAMS2NI.js +81 -0
  265. package/chunks/{todoWrite-7WM3VDMY.js → todoWrite-OFIZDI7P.js} +32 -4
  266. package/chunks/{tool-search-Z3Z4AYKP.js → tool-search-DCICFL32.js} +15 -14
  267. package/chunks/total-session-admission-3ZTAXVUK.js +89 -0
  268. package/chunks/{trustedFolders-X2JEIO57.js → trustedFolders-EVCN36O5.js} +42 -37
  269. package/chunks/{update-relaunch-VWNPYDIP.js → update-relaunch-XLW46RHQ.js} +5 -5
  270. package/chunks/{updateCheck-KAQH67DV.js → updateCheck-ZHVXDAIH.js} +44 -39
  271. package/chunks/{useAutoAcceptIndicator-JH6BCF7S.js → useAutoAcceptIndicator-ZGD6BJSP.js} +50 -45
  272. package/chunks/{validateNonInterActiveAuth-GIUJ2UFS.js → validateNonInterActiveAuth-R3BAQFDY.js} +88 -83
  273. package/chunks/{version-BGLYIJUY.js → version-PMWREGCG.js} +1 -1
  274. package/chunks/{web-fetch-OTDU4VQF.js → web-fetch-PGN27SGF.js} +14 -14
  275. package/chunks/{web-search-FP6SIHPR.js → web-search-KW4UNMRE.js} +8 -8
  276. package/chunks/{workflow-YCIVBYSB.js → workflow-SN3TJBTJ.js} +363 -310
  277. package/chunks/workspace-providers-status-O3HUZGGR.js +90 -0
  278. package/chunks/{workspace-registration-store-OTMS3H4C.js → workspace-registration-store-M3FJ74RS.js} +2 -2
  279. package/chunks/{workspace-registry-O63R6IZ4.js → workspace-registry-U7ISW23N.js} +47 -42
  280. package/chunks/{workspace-service-M6LLHKJ5.js → workspace-service-VH6IWADT.js} +53 -48
  281. package/chunks/{workspace-skills-status-C2V7BAIS.js → workspace-skills-status-XANARSZS.js} +48 -43
  282. package/chunks/{workspace-trust-reconciler-IBUPOUJN.js → workspace-trust-reconciler-35EFR4GC.js} +53 -48
  283. package/chunks/write-file-NCRSGUDT.js +79 -0
  284. package/chunks/{zh-H3YDK5QW.js → zh-OHX23Q44.js} +43 -5
  285. package/chunks/{zh-TW-JYCP7XUA.js → zh-TW-4G7YKDAQ.js} +43 -5
  286. package/chunks/zoom-image-X7CIADYC.js +224 -0
  287. package/cli.js +55 -48
  288. package/locales/ca.js +60 -4
  289. package/locales/de.js +62 -4
  290. package/locales/en.js +59 -4
  291. package/locales/fr.js +64 -4
  292. package/locales/ja.js +61 -4
  293. package/locales/pt.js +60 -4
  294. package/locales/ru.js +63 -4
  295. package/locales/zh-TW.js +52 -4
  296. package/locales/zh.js +52 -4
  297. package/package.json +3 -3
  298. package/web-shell/assets/{arc-75-Wdeo3.js → arc-CaMTqKio.js} +1 -1
  299. package/web-shell/assets/{architectureDiagram-3BPJPVTR-FKeXQbyP.js → architectureDiagram-3BPJPVTR-Bjxztij2.js} +1 -1
  300. package/web-shell/assets/{blockDiagram-GPEHLZMM-CY0vc-A3.js → blockDiagram-GPEHLZMM-BYJzeHi9.js} +1 -1
  301. package/web-shell/assets/{c4Diagram-AAUBKEIU-CNP-A-8u.js → c4Diagram-AAUBKEIU-fYAa-Eil.js} +1 -1
  302. package/web-shell/assets/channel-LEZei0-5.js +1 -0
  303. package/web-shell/assets/{chunk-2J33WTMH-GybS4Gii.js → chunk-2J33WTMH-B1OTlTml.js} +1 -1
  304. package/web-shell/assets/{chunk-4BX2VUAB-02H91V8v.js → chunk-4BX2VUAB-DNj4uy6k.js} +1 -1
  305. package/web-shell/assets/{chunk-55IACEB6-D3M-2VT6.js → chunk-55IACEB6-DAqNmg3c.js} +1 -1
  306. package/web-shell/assets/{chunk-727SXJPM-CCu29u4H.js → chunk-727SXJPM-BwB4ddxE.js} +1 -1
  307. package/web-shell/assets/{chunk-AQP2D5EJ-CaFKWgrn.js → chunk-AQP2D5EJ-DmHR_UZs.js} +1 -1
  308. package/web-shell/assets/{chunk-FMBD7UC4-ZZpPqIwQ.js → chunk-FMBD7UC4-BlfOXumo.js} +1 -1
  309. package/web-shell/assets/{chunk-ND2GUHAM-D22DqGs8.js → chunk-ND2GUHAM-BKogiSy7.js} +1 -1
  310. package/web-shell/assets/{chunk-QZHKN3VN-Bu85S0fw.js → chunk-QZHKN3VN-DEclVrOF.js} +1 -1
  311. package/web-shell/assets/classDiagram-4FO5ZUOK-BiaRhfvf.js +1 -0
  312. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BiaRhfvf.js +1 -0
  313. package/web-shell/assets/{cose-bilkent-S5V4N54A-f1CK1Gwe.js → cose-bilkent-S5V4N54A-CwtS21WT.js} +1 -1
  314. package/web-shell/assets/{dagre-BM42HDAG-D0Ow8F_n.js → dagre-BM42HDAG-BAAIlB4p.js} +1 -1
  315. package/web-shell/assets/{diagram-2AECGRRQ-BPrmTWp8.js → diagram-2AECGRRQ-ChljtF_V.js} +1 -1
  316. package/web-shell/assets/{diagram-5GNKFQAL-HccuFAzy.js → diagram-5GNKFQAL-BIXVd31-.js} +1 -1
  317. package/web-shell/assets/{diagram-KO2AKTUF-BrS76mbA.js → diagram-KO2AKTUF-BEiBaS15.js} +1 -1
  318. package/web-shell/assets/{diagram-LMA3HP47-V7T9lU-5.js → diagram-LMA3HP47-C-g4tWKM.js} +1 -1
  319. package/web-shell/assets/{diagram-OG6HWLK6-DKidyJMR.js → diagram-OG6HWLK6-CNCCbNQG.js} +1 -1
  320. package/web-shell/assets/{erDiagram-TEJ5UH35-DBadZIkp.js → erDiagram-TEJ5UH35-v8ysnsdI.js} +1 -1
  321. package/web-shell/assets/{flowDiagram-I6XJVG4X-BymfqdNJ.js → flowDiagram-I6XJVG4X-LKVlLjwA.js} +1 -1
  322. package/web-shell/assets/{ganttDiagram-6RSMTGT7-DOw340jf.js → ganttDiagram-6RSMTGT7-DA5MrKYG.js} +1 -1
  323. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-_8EiD8sl.js → gitGraphDiagram-PVQCEYII-Cyg5fe6d.js} +1 -1
  324. package/web-shell/assets/index-BgOcEaVt.js +1756 -0
  325. package/web-shell/assets/index-C2GE3DAF.js +74 -0
  326. package/web-shell/assets/{index-CKIadvET.js → index-CKdUkVVS.js} +1 -1
  327. package/web-shell/assets/index-DA5Lvscv.css +5 -0
  328. package/web-shell/assets/{infoDiagram-5YYISTIA-D61KYQBu.js → infoDiagram-5YYISTIA-SLsfu3Qd.js} +1 -1
  329. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-CsiXSpNx.js → ishikawaDiagram-YF4QCWOH-CmHOmTNx.js} +1 -1
  330. package/web-shell/assets/{journeyDiagram-JHISSGLW-Sdfionyh.js → journeyDiagram-JHISSGLW-C3gM_HFQ.js} +1 -1
  331. package/web-shell/assets/{kanban-definition-UN3LZRKU-C3WI3Cnl.js → kanban-definition-UN3LZRKU-BbHD7duM.js} +1 -1
  332. package/web-shell/assets/{linear-Dpigcc62.js → linear-CSBvm435.js} +1 -1
  333. package/web-shell/assets/{mermaid.core-Ct97pqgW.js → mermaid.core-CPMw15lU.js} +5 -5
  334. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BzeaN0rB.js → mindmap-definition-RKZ34NQL-C_tNqXQW.js} +1 -1
  335. package/web-shell/assets/{pieDiagram-4H26LBE5-CvjgcbVD.js → pieDiagram-4H26LBE5-DH_N-8yY.js} +1 -1
  336. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-BUzgTNdH.js → quadrantDiagram-W4KKPZXB-CRbS8UkN.js} +1 -1
  337. package/web-shell/assets/{requirementDiagram-4Y6WPE33-B7zKlgUQ.js → requirementDiagram-4Y6WPE33-DJgdZPZn.js} +1 -1
  338. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-Bb9CQgrT.js → sankeyDiagram-5OEKKPKP-vhL1y5zx.js} +1 -1
  339. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DJ6V7itG.js → sequenceDiagram-3UESZ5HK-UQthhFwd.js} +1 -1
  340. package/web-shell/assets/{stateDiagram-AJRCARHV-IImflERY.js → stateDiagram-AJRCARHV-CAywEm20.js} +1 -1
  341. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-lfJQHw-7.js +1 -0
  342. package/web-shell/assets/{timeline-definition-PNZ67QCA-6Q_uWHKh.js → timeline-definition-PNZ67QCA-CLO8b3FD.js} +1 -1
  343. package/web-shell/assets/{vennDiagram-CIIHVFJN-TmyKyjwv.js → vennDiagram-CIIHVFJN-BNAAh0Mu.js} +1 -1
  344. package/web-shell/assets/{wardley-L42UT6IY-CRh9uiPv.js → wardley-L42UT6IY-CUY7bLpN.js} +1 -1
  345. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-59TKAW8w.js → wardleyDiagram-YWT4CUSO-CSg_ORdW.js} +1 -1
  346. package/web-shell/assets/{xychartDiagram-2RQKCTM6-GCSUIK2L.js → xychartDiagram-2RQKCTM6-BjffV208.js} +1 -1
  347. package/web-shell/index.html +2 -2
  348. package/chunks/agent-headless-NO4Y2HOE.js +0 -74
  349. package/chunks/chunk-6QIGFD5W.js +0 -82
  350. package/chunks/chunk-HGT6JR3U.js +0 -177
  351. package/chunks/daemon-status-provider-3XJI6CAL.js +0 -89
  352. package/chunks/handleAutoUpdate-L6ERF36Y.js +0 -80
  353. package/chunks/list-L2GA674Y.js +0 -88
  354. package/chunks/mcp-SZLHKFJW.js +0 -82
  355. package/chunks/nonInteractiveCli-5T7KYKLK.js +0 -144
  356. package/chunks/ripGrep-OWV2IVJC.js +0 -72
  357. package/chunks/theme-manager-EEWIQJ7J.js +0 -76
  358. package/chunks/total-session-admission-44JKRWQD.js +0 -84
  359. package/chunks/workspace-providers-status-S35YAIUS.js +0 -85
  360. package/chunks/write-file-3BZC3EAE.js +0 -72
  361. package/chunks/zoom-image-TZ6S2O57.js +0 -351
  362. package/web-shell/assets/channel-DPYMT76A.js +0 -1
  363. package/web-shell/assets/classDiagram-4FO5ZUOK--JstsIgL.js +0 -1
  364. package/web-shell/assets/classDiagram-v2-Q7XG4LA2--JstsIgL.js +0 -1
  365. package/web-shell/assets/index-D1eXNRHe.js +0 -1389
  366. package/web-shell/assets/index-DVLD4CQq.css +0 -5
  367. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CYI_YoNR.js +0 -1
@@ -1,8 +1,9 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
3
  import {
4
- classifyApiError
5
- } from "./chunk-V7RNNPGC.js";
4
+ classifyApiError,
5
+ fireSessionDeleteHook
6
+ } from "./chunk-P5Y23G2L.js";
6
7
  import {
7
8
  EXTENSION_CONTEXT_BUDGET,
8
9
  buildExtensionMentionContext,
@@ -12,53 +13,49 @@ import {
12
13
  matchMcpServerByRef,
13
14
  parseExtensionRef,
14
15
  parseMcpServerRef
15
- } from "./chunk-TV64SXKD.js";
16
+ } from "./chunk-RGJ4JWSU.js";
16
17
  import {
17
18
  getAvailableCommands,
18
19
  handleSlashCommand,
19
20
  insertAfterFunctionResponses,
20
21
  isSlashCommand,
21
22
  normalizePartList
22
- } from "./chunk-J7OACQDE.js";
23
+ } from "./chunk-TNVKFQXQ.js";
24
+ import {
25
+ collectContextData,
26
+ formatContextUsageText
27
+ } from "./chunk-7K2WTPQO.js";
23
28
  import {
24
29
  recomputeMcpGating
25
- } from "./chunk-A4COXFB3.js";
30
+ } from "./chunk-PGP7Y3RQ.js";
26
31
  import {
32
+ SessionIdConflictError,
27
33
  appEvents,
28
34
  buildDisabledSkillNamesProvider,
29
35
  cleanupReviewWorktreeLeases,
30
36
  loadCliConfig,
31
37
  normalizeDisabledToolList
32
- } from "./chunk-7BAU433D.js";
38
+ } from "./chunk-VS3GXRNZ.js";
33
39
  import {
34
40
  getCommandSubcommandNames
35
- } from "./chunk-JX27F6QS.js";
41
+ } from "./chunk-OBAIHYFT.js";
36
42
  import {
37
43
  getEffectiveSupportedModes
38
- } from "./chunk-7AEJDLRA.js";
39
- import "./chunk-PQNHRFJC.js";
40
- import "./chunk-M7OONWYU.js";
41
- import {
42
- collectContextData,
43
- formatContextUsageText
44
- } from "./chunk-65PQENQP.js";
44
+ } from "./chunk-7IYLHTTM.js";
45
45
  import "./chunk-4WGODMVR.js";
46
- import "./chunk-GATT5TKW.js";
47
- import "./chunk-EVKE2FZL.js";
48
- import "./chunk-T3O2B4XO.js";
49
- import "./chunk-7DXQIJID.js";
50
- import "./chunk-YAF2MQZ6.js";
51
- import {
52
- computeCpuPercent
53
- } from "./chunk-HGT6JR3U.js";
54
- import "./chunk-S4WJVPZW.js";
55
- import "./chunk-6H67XLET.js";
46
+ import "./chunk-NYX53SV4.js";
47
+ import "./chunk-3LGZEYOF.js";
48
+ import "./chunk-KKN2IE7Q.js";
56
49
  import {
57
50
  beginAcpBootstrapConfigProfiling,
58
51
  buildAndFreezeAcpStartupProfile,
59
52
  endAcpBootstrapConfigProfiling,
60
53
  markAcpStartup
61
- } from "./chunk-3L2SPEBH.js";
54
+ } from "./chunk-M744OFVE.js";
55
+ import "./chunk-433VD3HX.js";
56
+ import "./chunk-PHODQP2V.js";
57
+ import "./chunk-ZRFJ75D7.js";
58
+ import "./chunk-YAF2MQZ6.js";
62
59
  import {
63
60
  GENERATION_MAX_PROMPT_BYTES,
64
61
  GENERATION_TIMEOUT_MS,
@@ -71,6 +68,7 @@ import {
71
68
  executeGeneration,
72
69
  formatWorkspaceMemoryForgetSummary,
73
70
  isValidServerName,
71
+ loadSettingsCached,
74
72
  normalizeChannelDeliveryText,
75
73
  redactMcpServerSecrets,
76
74
  replayTranscriptRecordPage,
@@ -78,7 +76,7 @@ import {
78
76
  shouldSuppressRememberErrorDetails,
79
77
  workspaceMemoryFailureCode,
80
78
  workspaceMemoryFailureDiagnostics
81
- } from "./chunk-6PE7N3A4.js";
79
+ } from "./chunk-5UJ6A3CH.js";
82
80
  import {
83
81
  HistoryReplayer,
84
82
  MessageEmitter,
@@ -88,48 +86,57 @@ import {
88
86
  goalTerminalEventToHistoryItem,
89
87
  recordGoalStatusItem,
90
88
  restoreGoalFromHistory
91
- } from "./chunk-LO4ROVP4.js";
92
- import "./chunk-LGAOC3ZS.js";
93
- import "./chunk-XFZYFU3I.js";
94
- import "./chunk-YDLJGZHL.js";
89
+ } from "./chunk-UOFFZNXV.js";
90
+ import "./chunk-DYA25Y7U.js";
91
+ import "./chunk-4NFY2S7N.js";
92
+ import "./chunk-UHQ3L6GC.js";
95
93
  import "./chunk-2MIN6GRR.js";
96
94
  import "./chunk-QHTIBUWB.js";
97
95
  import {
98
96
  isTerminalGoalStatusKind
99
97
  } from "./chunk-QTERJVPZ.js";
100
98
  import "./chunk-3Z43GZUQ.js";
99
+ import {
100
+ computeCpuPercent
101
+ } from "./chunk-LBOVL47Y.js";
101
102
  import "./chunk-RXFQM6FQ.js";
103
+ import "./chunk-LL4U3BSH.js";
104
+ import "./chunk-6H67XLET.js";
105
+ import {
106
+ mapSkillConfigToStatus
107
+ } from "./chunk-BGXZBI5B.js";
102
108
  import {
103
109
  PERMISSION_RULE_TYPES,
104
110
  PermissionRulesValidationError,
105
111
  buildPermissionSettings,
106
112
  normalizePermissionRules,
107
113
  readPermissionRuleSet
108
- } from "./chunk-MR5EAQ5M.js";
114
+ } from "./chunk-GALUTA2C.js";
109
115
  import {
110
116
  MAX_AUDIO_BYTES,
111
117
  sanitizeVoiceErrorMessage,
112
118
  transcribeVoiceAudio
113
- } from "./chunk-CAPPWD3X.js";
119
+ } from "./chunk-2A6MHYIA.js";
114
120
  import {
115
121
  readVoiceModel
116
- } from "./chunk-JTV5K7NH.js";
117
- import "./chunk-ZHBO7WVX.js";
122
+ } from "./chunk-XSA5EKTJ.js";
123
+ import "./chunk-JELIWHXD.js";
118
124
  import {
119
125
  createLoadedSettingsAdapter
120
- } from "./chunk-WUZ7H6DP.js";
126
+ } from "./chunk-K5Q62CGR.js";
121
127
  import "./chunk-VXZBKKQR.js";
122
- import "./chunk-QIZKCVM3.js";
123
- import "./chunk-E5Z2AVNV.js";
128
+ import "./chunk-GHJM2C2T.js";
129
+ import "./chunk-3SH53ANB.js";
124
130
  import {
131
+ SESSION_SOURCE_META_KEY,
125
132
  parseSessionSource
126
- } from "./chunk-ZURDMIDR.js";
133
+ } from "./chunk-3MHPWQ2M.js";
127
134
  import "./chunk-GLWP3FDB.js";
128
135
  import "./chunk-XCGIMOLN.js";
129
136
  import "./chunk-OCPBI7J5.js";
130
137
  import {
131
138
  ndJsonStream
132
- } from "./chunk-KAMYKP7E.js";
139
+ } from "./chunk-UWSXFI6E.js";
133
140
  import {
134
141
  ACP_ROUTE_ID_PREFIX,
135
142
  buildAcpModelOptions,
@@ -138,10 +145,7 @@ import {
138
145
  parseAcpModelOption,
139
146
  resolveAcpModelOption,
140
147
  sanitizeProviderBaseUrl
141
- } from "./chunk-KCO4FLFJ.js";
142
- import {
143
- mapSkillConfigToStatus
144
- } from "./chunk-L55JWS76.js";
148
+ } from "./chunk-AYB4HSBI.js";
145
149
  import {
146
150
  ACP_PREFLIGHT_KINDS,
147
151
  IDLE_HOOK_EVENTS,
@@ -149,16 +153,16 @@ import {
149
153
  SERVE_STATUS_EXT_METHODS,
150
154
  STATUS_SCHEMA_VERSION,
151
155
  mapDomainErrorToErrorKind
152
- } from "./chunk-FTD6DP4T.js";
156
+ } from "./chunk-PDDYAXL2.js";
153
157
  import {
154
158
  resolveSkillSettings
155
159
  } from "./chunk-Z4X5MTRT.js";
156
- import "./chunk-BNWB5CYE.js";
157
- import "./chunk-5MKRTI4T.js";
160
+ import "./chunk-3WXMXT7C.js";
161
+ import "./chunk-BKUN5QHP.js";
158
162
  import "./chunk-57OAHC2Y.js";
159
- import "./chunk-2XSLTRFZ.js";
160
- import "./chunk-TFRMVU6R.js";
161
- import "./chunk-XBYYDKAZ.js";
163
+ import "./chunk-2CTKGIFR.js";
164
+ import "./chunk-K4CGQN4Q.js";
165
+ import "./chunk-ZTN6OA5J.js";
162
166
  import "./chunk-V6WHFGST.js";
163
167
  import {
164
168
  CHANNEL_STARTUP_PROFILE_META_KEY,
@@ -166,29 +170,34 @@ import {
166
170
  CLIENT_MCP_OVER_WS_CONFIG_FLAG,
167
171
  DAEMON_CHANNEL_DELIVERY_META_KEY,
168
172
  LOAD_REPLAY_BULK_MODE,
173
+ LOAD_REPLAY_HIDE_INHERITED_META_KEY,
169
174
  LOAD_REPLAY_META_KEY,
170
175
  LOAD_REPLAY_MODE_META_KEY,
171
176
  LOAD_REPLAY_PAGE_SIZE_META_KEY,
172
177
  LOAD_REPLAY_VERSION,
173
178
  MID_TURN_QUEUE_DRAIN_METHOD,
174
179
  PROMPT_CANCEL_METHOD,
180
+ REQUESTED_SESSION_ID_META_KEY,
175
181
  TODO_STOP_GUARD_CONTINUATION_CLAIM_METHOD,
176
- TODO_STOP_GUARD_QUEUE_RELEASE_METHOD
177
- } from "./chunk-XZC5VLBZ.js";
182
+ TODO_STOP_GUARD_QUEUE_RELEASE_METHOD,
183
+ WORKTREE_MCP_DEFER_META_KEY
184
+ } from "./chunk-UKZEXS6K.js";
178
185
  import {
179
186
  NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE,
180
187
  isNotCurrentlyGeneratingCancelError
181
- } from "./chunk-B4AJNNOL.js";
182
- import "./chunk-2RFKHEXL.js";
188
+ } from "./chunk-J26HHFI5.js";
189
+ import "./chunk-6PLDPT2C.js";
183
190
  import "./chunk-FYJ7W2PI.js";
184
- import "./chunk-U4VTUMMK.js";
185
- import "./chunk-GZ3RCT54.js";
191
+ import "./chunk-QONSRAEV.js";
192
+ import "./chunk-UHTJC7O3.js";
186
193
  import "./chunk-ALMR3E6Q.js";
187
194
  import "./chunk-BK2UNYWD.js";
188
195
  import "./chunk-M5GB774H.js";
189
- import "./chunk-4G2BISNC.js";
190
- import "./chunk-GEBV2JGB.js";
191
- import "./chunk-7I5GTCT4.js";
196
+ import "./chunk-XC2VAFVZ.js";
197
+ import "./chunk-I6FAHB4N.js";
198
+ import {
199
+ ACP_EVENT_LOOP_STALL_RESTART_MS
200
+ } from "./chunk-GB3AB7TR.js";
192
201
  import {
193
202
  AgentSideConnection,
194
203
  PROTOCOL_VERSION,
@@ -197,48 +206,38 @@ import {
197
206
  import {
198
207
  assembleMcpServers,
199
208
  loadMcpApprovals
200
- } from "./chunk-6RPMI2AB.js";
209
+ } from "./chunk-NZB4NDJL.js";
201
210
  import {
202
211
  getOutputLanguageFilePath,
203
212
  getPersistScopeForModelSelection,
204
- getUserSettingsPath,
205
213
  loadSettings,
206
214
  resolveOutputLanguageOrPreserveAuto,
207
215
  updateOutputLanguageFile,
208
216
  writeOutputLanguageAndRegisterPath
209
- } from "./chunk-EIF3FXTB.js";
217
+ } from "./chunk-LAPK3GLC.js";
210
218
  import "./chunk-RKUWKYED.js";
219
+ import "./chunk-GOXKNSDZ.js";
220
+ import "./chunk-IDS7MSUP.js";
211
221
  import {
212
222
  SUPPORTED_LANGUAGES,
213
223
  getCurrentLanguage,
214
224
  setLanguageAsync
215
- } from "./chunk-TCIFAA7K.js";
225
+ } from "./chunk-CHCLO3M7.js";
216
226
  import {
217
- findEnvFiles,
218
- preResolveHomeEnvOverrides,
219
227
  reloadEnvironment
220
- } from "./chunk-2N7CODY5.js";
221
- import "./chunk-VWOOBLTY.js";
222
- import "./chunk-GOXKNSDZ.js";
223
- import {
224
- getSystemDefaultsPath,
225
- getSystemSettingsPath
226
- } from "./chunk-IDS7MSUP.js";
228
+ } from "./chunk-AQEWCKX4.js";
227
229
  import "./chunk-6PEXNQTX.js";
228
- import "./chunk-XFSFZCM5.js";
229
- import "./chunk-VYOXCEPJ.js";
230
- import "./chunk-VJNBRRZG.js";
230
+ import "./chunk-25QQVOCG.js";
231
231
  import {
232
232
  isFolderTrustEnabled,
233
233
  isWorkspaceTrusted,
234
234
  loadTrustedFolders
235
- } from "./chunk-Q43KPN7X.js";
235
+ } from "./chunk-434YCHSV.js";
236
236
  import "./chunk-ALGGS7UH.js";
237
237
  import "./chunk-MR3PXB6E.js";
238
- import {
239
- writeStderrLine,
240
- writeStderrLineSafe
241
- } from "./chunk-OWAK7LMW.js";
238
+ import "./chunk-XFSFZCM5.js";
239
+ import "./chunk-MBKPUM5Y.js";
240
+ import "./chunk-VJNBRRZG.js";
242
241
  import {
243
242
  ALL_PROVIDERS,
244
243
  APPROVAL_MODE_INFO,
@@ -300,6 +299,7 @@ import {
300
299
  evaluateAutoMode,
301
300
  evaluatePermissionFlow,
302
301
  evaluatePlanModeShellPolicy,
302
+ evaluateToolInvocationGuard,
303
303
  finalizeToolResponses,
304
304
  findExistingProviderModels,
305
305
  findPlanModeEntryBatchBoundaryIndex,
@@ -326,7 +326,6 @@ import {
326
326
  getProviderToolCallId,
327
327
  getScopedEnvContents,
328
328
  getStopHookContinuationReason,
329
- ideContextStore,
330
329
  injectPermissionRulesIfMissing,
331
330
  isApproveOutcome,
332
331
  isDenialFallbackReason,
@@ -339,7 +338,6 @@ import {
339
338
  normalizeEventPayload,
340
339
  normalizeSnapshotPayload,
341
340
  persistPermissionOutcome,
342
- promptIdContext,
343
341
  readManyFiles,
344
342
  recordAllow,
345
343
  recordFallbackApprove,
@@ -362,57 +360,66 @@ import {
362
360
  unregisterGoalHook,
363
361
  updateSetting,
364
362
  validatePlanModeShellApproval,
365
- validatePlanModeShellContext
366
- } from "./chunk-X5WNMMIA.js";
363
+ validatePlanModeShellContext,
364
+ wrapUserPromptSubmitContext
365
+ } from "./chunk-NGWYUZZO.js";
366
+ import "./chunk-GOFAQQZA.js";
367
+ import "./chunk-5M6IDOMF.js";
367
368
  import "./chunk-TWPJO254.js";
368
369
  import {
369
370
  external_exports
370
371
  } from "./chunk-H6XPXXMH.js";
371
- import "./chunk-5M6IDOMF.js";
372
- import "./chunk-UPUG4GXM.js";
373
- import "./chunk-64LQLPL7.js";
374
- import "./chunk-2LQTH543.js";
375
- import "./chunk-KRXPRVGL.js";
376
- import "./chunk-BMFALVGQ.js";
377
- import "./chunk-CVHIL5IG.js";
378
- import "./chunk-IRH27ZC2.js";
379
- import "./chunk-QHWCP53L.js";
380
- import "./chunk-PONHVBRT.js";
381
- import "./chunk-T26EAKDL.js";
372
+ import "./chunk-CWEIMFFW.js";
373
+ import "./chunk-I7JDGNG6.js";
374
+ import "./chunk-A6SX5TAH.js";
375
+ import "./chunk-33FNCQSY.js";
382
376
  import {
383
377
  parsePositiveIntegerEnv
384
378
  } from "./chunk-6PVPNMXU.js";
379
+ import "./chunk-PXA5AWHY.js";
380
+ import "./chunk-IRH27ZC2.js";
381
+ import "./chunk-QHWCP53L.js";
382
+ import "./chunk-MOHAWIAW.js";
383
+ import "./chunk-MYT7N6QH.js";
384
+ import {
385
+ promptIdContext,
386
+ todoWorkChainContext
387
+ } from "./chunk-O6GEWCJA.js";
388
+ import "./chunk-T26EAKDL.js";
385
389
  import "./chunk-CPBF7KYF.js";
386
- import "./chunk-6QIGFD5W.js";
390
+ import "./chunk-MISUEWB4.js";
391
+ import "./chunk-KRXPRVGL.js";
387
392
  import {
388
393
  HookEventName,
389
394
  createHookOutput
390
- } from "./chunk-XWWKIXVD.js";
391
- import "./chunk-75GFAX4R.js";
392
- import "./chunk-OKF7JF3R.js";
395
+ } from "./chunk-A5YZ3FA2.js";
396
+ import "./chunk-YAVY33G4.js";
397
+ import "./chunk-2UISUFHQ.js";
398
+ import "./chunk-6FMJLI5M.js";
393
399
  import {
394
400
  APPROVAL_MODES,
395
401
  FORK_SUBAGENT_TYPE,
396
402
  getStartupContextLength,
397
403
  isSystemReminderContent,
398
404
  runWithRuntimeContentGenerator
399
- } from "./chunk-JSD33JG6.js";
405
+ } from "./chunk-PGEGUNH5.js";
400
406
  import "./chunk-S6LOFUVP.js";
401
- import "./chunk-JCW2R7WC.js";
402
- import "./chunk-2DN4J57Y.js";
407
+ import "./chunk-K623ENWT.js";
408
+ import "./chunk-AQ37AY7B.js";
409
+ import "./chunk-432XCUHF.js";
403
410
  import "./chunk-ZPJWUGCS.js";
404
411
  import {
405
412
  clearCachedCredentialFile,
406
413
  qwenOAuth2Events
407
- } from "./chunk-2LKVPASC.js";
414
+ } from "./chunk-XC656O42.js";
408
415
  import "./chunk-NAVJD2PQ.js";
409
- import "./chunk-LW3RFMG7.js";
410
- import "./chunk-W4MIWP6M.js";
416
+ import "./chunk-QYPT3QUD.js";
417
+ import "./chunk-QMBEW7EW.js";
411
418
  import "./chunk-DGEIYUC3.js";
412
419
  import "./chunk-MPHPFVKK.js";
413
420
  import "./chunk-GLNBDYUX.js";
414
421
  import "./chunk-DJ2GSRLV.js";
415
- import "./chunk-5KTQXHPY.js";
422
+ import "./chunk-XCLLRKY5.js";
416
423
  import {
417
424
  addToolArgumentsAttributes,
418
425
  addToolCallResultAttributes,
@@ -420,14 +427,14 @@ import {
420
427
  registerAcpEventLoopLagGauge,
421
428
  startEventLoopLagMonitor,
422
429
  withDaemonSpan
423
- } from "./chunk-75MIQ3LV.js";
430
+ } from "./chunk-RPYYTL7E.js";
424
431
  import "./chunk-2J3OJGTL.js";
425
432
  import "./chunk-P3QQPMQA.js";
426
- import "./chunk-RPLGZJV2.js";
433
+ import "./chunk-6O5DVH27.js";
427
434
  import {
428
435
  getToolCallPreparations
429
436
  } from "./chunk-GLCZKT5V.js";
430
- import "./chunk-DZLYR4U3.js";
437
+ import "./chunk-2DNKEBXY.js";
431
438
  import {
432
439
  ConversationFinishedEvent,
433
440
  DiscoveredMCPTool,
@@ -458,30 +465,30 @@ import {
458
465
  shouldRunVisionBridge,
459
466
  splitImageParts,
460
467
  uiTelemetryService
461
- } from "./chunk-PT722TDT.js";
468
+ } from "./chunk-M2F5PLOW.js";
462
469
  import "./chunk-VGC4I5JJ.js";
463
470
  import {
464
471
  getAutoMemoryRoot,
465
472
  getUserAutoMemoryRoot
466
- } from "./chunk-SGFT55XI.js";
467
- import "./chunk-Y4IHBGBP.js";
473
+ } from "./chunk-E4WHKETF.js";
474
+ import "./chunk-BV4QX43X.js";
468
475
  import {
469
476
  ToolConfirmationOutcome,
470
477
  ToolNames,
471
478
  isShellProgressData
472
- } from "./chunk-Y6AXW2OG.js";
479
+ } from "./chunk-I5GNT6ZS.js";
473
480
  import {
474
481
  AuthType,
475
482
  preloadContentGenerator
476
- } from "./chunk-VCPIZRYH.js";
483
+ } from "./chunk-TFFMATHX.js";
477
484
  import "./chunk-46UV252V.js";
478
485
  import {
479
486
  DEFAULT_TOKEN_LIMIT,
480
487
  tokenLimit
481
488
  } from "./chunk-ZBVS26BY.js";
482
- import "./chunk-WZRWHXFE.js";
483
- import "./chunk-A3NDJ5SB.js";
484
- import "./chunk-7XATOOE7.js";
489
+ import "./chunk-BFHXDAR7.js";
490
+ import "./chunk-TYERNYH4.js";
491
+ import "./chunk-UH7Z7Y45.js";
485
492
  import {
486
493
  endToolExecutionSpan,
487
494
  endToolSpan,
@@ -490,21 +497,25 @@ import {
490
497
  startToolExecutionSpan,
491
498
  startToolSpan,
492
499
  withInteractionSpan
493
- } from "./chunk-BGTQCTQW.js";
500
+ } from "./chunk-O2ZYHG33.js";
494
501
  import "./chunk-W4RQUHY3.js";
495
- import "./chunk-S7W2GKIO.js";
502
+ import "./chunk-G7XXKQYS.js";
496
503
  import {
497
504
  Storage,
498
505
  createDebugLogger,
499
506
  getErrorMessage,
500
507
  getErrorStatus,
501
508
  isSubpath
502
- } from "./chunk-UHUSJ6X7.js";
509
+ } from "./chunk-3RXUYQJI.js";
503
510
  import "./chunk-VOQXFAY5.js";
504
- import "./chunk-RCUQIPTN.js";
511
+ import "./chunk-W7XZ3KP5.js";
505
512
  import {
506
513
  runExitCleanup
507
- } from "./chunk-52ZSWYEG.js";
514
+ } from "./chunk-SK2UKB45.js";
515
+ import {
516
+ writeStderrLine,
517
+ writeStderrLineSafe
518
+ } from "./chunk-OWAK7LMW.js";
508
519
  import "./chunk-75DOP5OR.js";
509
520
  import "./chunk-DMTGGOSA.js";
510
521
  import "./chunk-YQ3U5MUC.js";
@@ -749,126 +760,11 @@ var AcpFileSystemService = class {
749
760
  // packages/cli/src/acp-integration/acpAgent.ts
750
761
  import { Readable, Writable } from "node:stream";
751
762
  import { pipeline } from "node:stream/promises";
752
- import * as fs2 from "node:fs/promises";
753
- import * as os3 from "node:os";
754
- import * as path4 from "node:path";
763
+ import * as fs from "node:fs/promises";
764
+ import * as os2 from "node:os";
765
+ import * as path3 from "node:path";
755
766
  import { createGunzip } from "node:zlib";
756
767
 
757
- // packages/cli/src/config/settings-cache.ts
758
- init_esbuild_shims();
759
- import * as fs from "node:fs";
760
- import * as os from "node:os";
761
- import * as path2 from "node:path";
762
- var MAX_CACHE_ENTRIES = 64;
763
- var debugLogger2 = createDebugLogger("SETTINGS_CACHE");
764
- var cache = /* @__PURE__ */ new Map();
765
- function statSig(filePath) {
766
- const st = fs.statSync(filePath, { throwIfNoEntry: false });
767
- return st ? `${st.mtimeMs}:${st.size}:${st.ino}` : "missing";
768
- }
769
- __name(statSig, "statSig");
770
- function realpathOr(p) {
771
- try {
772
- return fs.realpathSync(p);
773
- } catch {
774
- return path2.resolve(p);
775
- }
776
- }
777
- __name(realpathOr, "realpathOr");
778
- function settingsFileSigs(workspaceDir) {
779
- const filePaths = [
780
- getSystemSettingsPath(),
781
- getSystemDefaultsPath(),
782
- getUserSettingsPath(),
783
- new Storage(workspaceDir).getWorkspaceSettingsPath()
784
- ];
785
- return filePaths.map((filePath) => ({ filePath, sig: statSig(filePath) }));
786
- }
787
- __name(settingsFileSigs, "settingsFileSigs");
788
- function envFileSigs(settings, workspaceDir) {
789
- return findEnvFiles(settings.merged, workspaceDir).map((filePath) => ({
790
- filePath,
791
- sig: statSig(filePath)
792
- }));
793
- }
794
- __name(envFileSigs, "envFileSigs");
795
- function sameFileSigs(a, b) {
796
- if (a.length !== b.length) {
797
- return false;
798
- }
799
- return a.every(
800
- (sig, i) => sig.filePath === b[i].filePath && sig.sig === b[i].sig
801
- );
802
- }
803
- __name(sameFileSigs, "sameFileSigs");
804
- function isEntryFresh(key, entry) {
805
- const fp = entry.fingerprint;
806
- return ideContextStore.get()?.workspaceState?.isTrusted === fp.ideTrust && realpathOr(key) === fp.realCwd && // homeDir guards the corner where nothing else moves: QWEN_HOME set (so
807
- // settings paths don't follow HOME), no .env files anywhere, and the new
808
- // home equals the workspace dir — which flips workspaceSettingsActive.
809
- realpathOr(os.homedir()) === fp.homeDir && sameFileSigs(settingsFileSigs(key), fp.settingsFiles) && sameFileSigs(envFileSigs(entry.settings, key), fp.envFiles);
810
- }
811
- __name(isEntryFresh, "isEntryFresh");
812
- function loadSettingsCached(workspaceDir) {
813
- preResolveHomeEnvOverrides();
814
- const key = path2.resolve(workspaceDir);
815
- const entry = cache.get(key);
816
- if (entry) {
817
- let isFresh = false;
818
- try {
819
- isFresh = isEntryFresh(key, entry);
820
- } catch (error) {
821
- debugLogger2.warn(
822
- `fingerprint check failed for ${key}; reloading:`,
823
- error
824
- );
825
- }
826
- if (isFresh) {
827
- cache.delete(key);
828
- cache.set(key, entry);
829
- debugLogger2.debug(`hit ${key}`);
830
- return entry.settings;
831
- }
832
- cache.delete(key);
833
- }
834
- debugLogger2.debug(`miss ${key}`);
835
- let preLoadSigs;
836
- try {
837
- preLoadSigs = settingsFileSigs(key);
838
- } catch (error) {
839
- debugLogger2.warn(`pre-load signing failed for ${key}; not caching:`, error);
840
- }
841
- const settings = loadSettings(key);
842
- if (preLoadSigs) {
843
- try {
844
- cache.set(key, {
845
- settings,
846
- fingerprint: {
847
- settingsFiles: preLoadSigs,
848
- // .env discovery needs the merged settings (trust), so it can only
849
- // be signed after the load — see difference (2) in the module doc.
850
- envFiles: envFileSigs(settings, key),
851
- ideTrust: ideContextStore.get()?.workspaceState?.isTrusted,
852
- realCwd: realpathOr(key),
853
- homeDir: realpathOr(os.homedir())
854
- }
855
- });
856
- if (cache.size > MAX_CACHE_ENTRIES) {
857
- const oldest = cache.keys().next().value;
858
- if (oldest !== void 0) {
859
- cache.delete(oldest);
860
- debugLogger2.debug(`evicted LRU entry ${oldest}`);
861
- }
862
- }
863
- } catch (error) {
864
- cache.delete(key);
865
- debugLogger2.warn(`caching failed for ${key}; serving uncached:`, error);
866
- }
867
- }
868
- return settings;
869
- }
870
- __name(loadSettingsCached, "loadSettingsCached");
871
-
872
768
  // packages/cli/src/acp-integration/extension-skills.ts
873
769
  init_esbuild_shims();
874
770
  function extensionSkillRef(extensionName, skillName) {
@@ -898,9 +794,9 @@ __name(isInactiveExtensionSkill, "isInactiveExtensionSkill");
898
794
  init_esbuild_shims();
899
795
  import { Buffer as Buffer2 } from "node:buffer";
900
796
  import { randomUUID } from "node:crypto";
901
- import { existsSync as existsSync2, statSync as statSync2 } from "node:fs";
902
- import * as os2 from "node:os";
903
- import * as path3 from "node:path";
797
+ import { realpathSync, statSync } from "node:fs";
798
+ import * as os from "node:os";
799
+ import * as path2 from "node:path";
904
800
 
905
801
  // packages/cli/src/utils/midTurnUserMessage.ts
906
802
  init_esbuild_shims();
@@ -1110,7 +1006,7 @@ function requestPermissionWithAbort(client, params, signal) {
1110
1006
  if (signal.aborted) {
1111
1007
  return Promise.reject(permissionAbortError(signal));
1112
1008
  }
1113
- return new Promise((resolve5, reject) => {
1009
+ return new Promise((resolve4, reject) => {
1114
1010
  let settled = false;
1115
1011
  const finish = /* @__PURE__ */ __name((callback) => {
1116
1012
  if (settled) return;
@@ -1128,7 +1024,7 @@ function requestPermissionWithAbort(client, params, signal) {
1128
1024
  return;
1129
1025
  }
1130
1026
  request.then(
1131
- (response) => finish(() => resolve5(response)),
1027
+ (response) => finish(() => resolve4(response)),
1132
1028
  (error) => finish(() => reject(error))
1133
1029
  );
1134
1030
  });
@@ -1268,12 +1164,13 @@ function toPermissionOptions(confirmation, forceHideAlwaysAllow = false) {
1268
1164
  __name(toPermissionOptions, "toPermissionOptions");
1269
1165
 
1270
1166
  // packages/cli/src/acp-integration/session/SubAgentTracker.ts
1271
- var debugLogger3 = createDebugLogger("ACP_SUBAGENT_TRACKER");
1167
+ var debugLogger2 = createDebugLogger("ACP_SUBAGENT_TRACKER");
1272
1168
  var SubAgentTracker = class {
1273
- constructor(ctx, client, parentToolCallId, subagentType, onPermissionCancel) {
1169
+ constructor(ctx, client, parentToolCallId, subagentType, onPermissionCancel, permissionRequester = (params, signal) => requestPermissionWithAbort(this.client, params, signal)) {
1274
1170
  this.ctx = ctx;
1275
1171
  this.client = client;
1276
1172
  this.onPermissionCancel = onPermissionCancel;
1173
+ this.permissionRequester = permissionRequester;
1277
1174
  this.toolCallEmitter = new ToolCallEmitter(ctx);
1278
1175
  this.messageEmitter = new MessageEmitter(ctx);
1279
1176
  this.subagentMeta = { parentToolCallId, subagentType };
@@ -1328,7 +1225,7 @@ var SubAgentTracker = class {
1328
1225
  try {
1329
1226
  invocation = tool.build(event.args);
1330
1227
  } catch (e) {
1331
- debugLogger3.warn(`Failed to build subagent tool ${event.name}:`, e);
1228
+ debugLogger2.warn(`Failed to build subagent tool ${event.name}:`, e);
1332
1229
  }
1333
1230
  }
1334
1231
  this.toolStates.set(event.callId, {
@@ -1405,11 +1302,7 @@ var SubAgentTracker = class {
1405
1302
  }
1406
1303
  };
1407
1304
  try {
1408
- const output = await requestPermissionWithAbort(
1409
- this.client,
1410
- params,
1411
- abortSignal
1412
- );
1305
+ const output = await this.permissionRequester(params, abortSignal);
1413
1306
  const outcome = resolvePermissionOutcome(
1414
1307
  output,
1415
1308
  offeredPermissionOptions
@@ -1421,7 +1314,7 @@ var SubAgentTracker = class {
1421
1314
  this.onPermissionCancel?.();
1422
1315
  }
1423
1316
  } catch (error) {
1424
- debugLogger3.error(
1317
+ debugLogger2.error(
1425
1318
  `Permission request failed for subagent tool ${event.name}:`,
1426
1319
  error
1427
1320
  );
@@ -1429,7 +1322,7 @@ var SubAgentTracker = class {
1429
1322
  try {
1430
1323
  await event.respond("cancel" /* Cancel */);
1431
1324
  } catch (respondError) {
1432
- debugLogger3.error(
1325
+ debugLogger2.error(
1433
1326
  `Failed to cancel subagent tool ${event.name} after permission request failure:`,
1434
1327
  respondError
1435
1328
  );
@@ -1527,8 +1420,8 @@ var TurnBuffer = class {
1527
1420
  // packages/cli/src/acp-integration/session/rewrite/LlmRewriter.ts
1528
1421
  init_esbuild_shims();
1529
1422
  import { readFileSync, existsSync } from "node:fs";
1530
- import { resolve as resolve2 } from "node:path";
1531
- var debugLogger4 = createDebugLogger("MESSAGE_REWRITER");
1423
+ import { resolve } from "node:path";
1424
+ var debugLogger3 = createDebugLogger("MESSAGE_REWRITER");
1532
1425
  var DEFAULT_REWRITE_PROMPT = `You are an assistant that rewrites raw coding-agent output into concise, user-friendly progress updates.
1533
1426
 
1534
1427
  The agent is a software engineering assistant that reads files, writes code, runs commands, and uses tools. Its raw output mixes internal reasoning with user-facing information. Your job: extract what the user cares about, drop what they don't.
@@ -1554,14 +1447,14 @@ var LlmRewriter = class {
1554
1447
  this.rewriteModel = rewriteConfig.model || void 0;
1555
1448
  this.contextTurns = rewriteConfig.contextTurns === "all" ? Infinity : rewriteConfig.contextTurns ?? 1;
1556
1449
  if (rewriteConfig.promptFile) {
1557
- const filePath = resolve2(rewriteConfig.promptFile);
1450
+ const filePath = resolve(rewriteConfig.promptFile);
1558
1451
  if (existsSync(filePath)) {
1559
1452
  this.prompt = readFileSync(filePath, "utf-8").trim();
1560
- debugLogger4.info(
1453
+ debugLogger3.info(
1561
1454
  `Loaded rewrite prompt from file: ${filePath} (${this.prompt.length} chars)`
1562
1455
  );
1563
1456
  } else {
1564
- debugLogger4.warn(
1457
+ debugLogger3.warn(
1565
1458
  `Rewrite prompt file not found: ${filePath}, using default`
1566
1459
  );
1567
1460
  this.prompt = DEFAULT_REWRITE_PROMPT;
@@ -1598,7 +1491,7 @@ var LlmRewriter = class {
1598
1491
  const inputText = inputParts.join("\n\n");
1599
1492
  if (!inputText.trim()) return null;
1600
1493
  if (inputText.length < 10) return null;
1601
- debugLogger4.info(
1494
+ debugLogger3.info(
1602
1495
  `[REWRITE INPUT] system_prompt_len=${this.prompt.length} input_len=${inputText.length} context_turns=${this.outputHistory.length}
1603
1496
  --- INPUT TEXT ---
1604
1497
  ${inputText}
@@ -1627,10 +1520,10 @@ ${inputText}
1627
1520
  });
1628
1521
  const rewritten = result.text;
1629
1522
  if (!rewritten || rewritten.length < 5) {
1630
- debugLogger4.info(`[REWRITE OUTPUT] empty or too short, skipping`);
1523
+ debugLogger3.info(`[REWRITE OUTPUT] empty or too short, skipping`);
1631
1524
  return null;
1632
1525
  }
1633
- debugLogger4.info(
1526
+ debugLogger3.info(
1634
1527
  `[REWRITE OUTPUT] len=${rewritten.length}
1635
1528
  --- OUTPUT ---
1636
1529
  ${rewritten}
@@ -1644,7 +1537,7 @@ ${rewritten}
1644
1537
  }
1645
1538
  return rewritten;
1646
1539
  } catch (error) {
1647
- debugLogger4.warn(
1540
+ debugLogger3.warn(
1648
1541
  `LLM rewrite failed, skipping: ${error instanceof Error ? error.message : String(error)}`
1649
1542
  );
1650
1543
  return null;
@@ -1653,7 +1546,7 @@ ${rewritten}
1653
1546
  };
1654
1547
 
1655
1548
  // packages/cli/src/acp-integration/session/rewrite/MessageRewriteMiddleware.ts
1656
- var debugLogger5 = createDebugLogger("MESSAGE_REWRITE");
1549
+ var debugLogger4 = createDebugLogger("MESSAGE_REWRITE");
1657
1550
  var DEFAULT_REWRITE_TIMEOUT_MS = 3e4;
1658
1551
  var REWRITE_META_EXCLUDED_KEYS = /* @__PURE__ */ new Set([]);
1659
1552
  var MessageRewriteMiddleware = class {
@@ -1736,10 +1629,10 @@ var MessageRewriteMiddleware = class {
1736
1629
  try {
1737
1630
  const rewritten = await this.rewriter.rewrite(content, rewriteSignal);
1738
1631
  if (!rewritten) {
1739
- debugLogger5.info(`Turn ${turnIdx}: no rewrite output`);
1632
+ debugLogger4.info(`Turn ${turnIdx}: no rewrite output`);
1740
1633
  return;
1741
1634
  }
1742
- debugLogger5.info(
1635
+ debugLogger4.info(
1743
1636
  `Turn ${turnIdx}: rewritten ${rewritten.length} chars`
1744
1637
  );
1745
1638
  await this.sendUpdate({
@@ -1752,7 +1645,7 @@ var MessageRewriteMiddleware = class {
1752
1645
  }
1753
1646
  });
1754
1647
  } catch (error) {
1755
- debugLogger5.warn(
1648
+ debugLogger4.warn(
1756
1649
  `Turn ${turnIdx}: rewrite failed: ${error instanceof Error ? error.message : String(error)}`
1757
1650
  );
1758
1651
  }
@@ -1961,7 +1854,8 @@ var DaemonTodoStopGuard = class {
1961
1854
  };
1962
1855
 
1963
1856
  // packages/cli/src/acp-integration/session/Session.ts
1964
- var debugLogger6 = createDebugLogger("SESSION");
1857
+ var debugLogger5 = createDebugLogger("SESSION");
1858
+ var permissionRequestTails = /* @__PURE__ */ new WeakMap();
1965
1859
  var USER_CANCEL_ABORT_REASON = "qwen:user-cancel";
1966
1860
  var SESSION_DISPOSE_ABORT_REASON = "qwen:session-dispose";
1967
1861
  var DAEMON_RETRY_META_KEY = "qwen.daemon.retry";
@@ -1993,7 +1887,7 @@ async function finalizeToolCallPreparations(tracker, includeResolved, streamName
1993
1887
  await tracker.discard(includeResolved);
1994
1888
  } catch (error) {
1995
1889
  const message = error instanceof Error ? error.message : String(error);
1996
- debugLogger6.warn(
1890
+ debugLogger5.warn(
1997
1891
  `Failed to discard tool preparations for ${streamName}; continuing stream: ${message}`
1998
1892
  );
1999
1893
  }
@@ -2025,7 +1919,7 @@ __name(createDaemonToolLoopState, "createDaemonToolLoopState");
2025
1919
  function recordDaemonLoopDetected(config, promptId, loopType, message, loopState) {
2026
1920
  if (!loopState.loopDetected) {
2027
1921
  loopState.loopDetected = true;
2028
- debugLogger6.warn(message);
1922
+ debugLogger5.warn(message);
2029
1923
  logLoopDetected(config, new LoopDetectedEvent(loopType, promptId));
2030
1924
  }
2031
1925
  return true;
@@ -2094,7 +1988,7 @@ function isContentBlock(value) {
2094
1988
  case "resource":
2095
1989
  return isEmbeddedResourceResource(value["resource"]);
2096
1990
  default:
2097
- debugLogger6.warn(`Unknown ContentBlock type: ${value["type"]}`);
1991
+ debugLogger5.warn(`Unknown ContentBlock type: ${value["type"]}`);
2098
1992
  return false;
2099
1993
  }
2100
1994
  }
@@ -2152,7 +2046,7 @@ function hasInlineMediaContentBlock(content) {
2152
2046
  __name(hasInlineMediaContentBlock, "hasInlineMediaContentBlock");
2153
2047
  function capMidTurnDrainItems(items, fieldName) {
2154
2048
  if (items.length <= MAX_MID_TURN_DRAIN_ITEMS) return items;
2155
- debugLogger6.warn(
2049
+ debugLogger5.warn(
2156
2050
  `Mid-turn drain response had ${items.length} ${fieldName}; processing first ${MAX_MID_TURN_DRAIN_ITEMS}`
2157
2051
  );
2158
2052
  return items.slice(0, MAX_MID_TURN_DRAIN_ITEMS);
@@ -2167,7 +2061,7 @@ function getMidTurnItemDisplayTextForLog(displayText) {
2167
2061
  __name(getMidTurnItemDisplayTextForLog, "getMidTurnItemDisplayTextForLog");
2168
2062
  function getValidMidTurnContentBlocks(content, displayText) {
2169
2063
  if (!Array.isArray(content)) {
2170
- debugLogger6.warn(
2064
+ debugLogger5.warn(
2171
2065
  `Dropped invalid mid-turn item: ${getMidTurnItemDisplayTextForLog(
2172
2066
  displayText
2173
2067
  )}`
@@ -2177,7 +2071,7 @@ function getValidMidTurnContentBlocks(content, displayText) {
2177
2071
  const validBlocks = content.filter(isContentBlock);
2178
2072
  const invalidBlockCount = content.length - validBlocks.length;
2179
2073
  if (invalidBlockCount > 0) {
2180
- debugLogger6.warn(
2074
+ debugLogger5.warn(
2181
2075
  `Dropped ${invalidBlockCount} invalid mid-turn content block(s): ${getMidTurnItemDisplayTextForLog(
2182
2076
  displayText
2183
2077
  )}`
@@ -2223,7 +2117,7 @@ function parseMidTurnDrainResponse(response) {
2223
2117
  );
2224
2118
  }
2225
2119
  if (!Array.isArray(response["messages"])) {
2226
- debugLogger6.warn(
2120
+ debugLogger5.warn(
2227
2121
  `Mid-turn drain response had no recognized 'items' or 'messages' field; keys: ${Object.keys(
2228
2122
  response
2229
2123
  ).join(", ")}`
@@ -2308,21 +2202,23 @@ function parsePromptChannelDelivery(params) {
2308
2202
  __name(parsePromptChannelDelivery, "parsePromptChannelDelivery");
2309
2203
  var MAX_NOTIFICATION_QUEUE = 20;
2310
2204
  var MAX_DEFERRED_UNRELATED_CRON_QUEUE = 20;
2311
- function isExistingFile(resolved, fileExists = existsSync2, statFile = statSync2) {
2205
+ function resolveExistingFile(resolved, resolveRealPath2 = realpathSync, statFile = statSync) {
2312
2206
  try {
2313
- return fileExists(resolved) && statFile(resolved).isFile();
2207
+ const canonicalPath = resolveRealPath2(resolved);
2208
+ const stats = statFile(canonicalPath);
2209
+ return stats.isFile() || stats.isDirectory?.() ? canonicalPath : void 0;
2314
2210
  } catch {
2315
- return false;
2211
+ return void 0;
2316
2212
  }
2317
2213
  }
2318
- __name(isExistingFile, "isExistingFile");
2214
+ __name(resolveExistingFile, "resolveExistingFile");
2319
2215
  function resolveHomeLoopResolverRoots({
2320
2216
  homeQwenDir = Storage.getGlobalQwenDir(),
2321
- homeDir = os2.homedir(),
2217
+ homeDir = os.homedir(),
2322
2218
  qwenHome = process.env["QWEN_HOME"]
2323
2219
  } = {}) {
2324
2220
  return {
2325
- homeConfineRoot: (qwenHome ? homeQwenDir : homeDir) || path3.dirname(homeQwenDir),
2221
+ homeConfineRoot: (qwenHome ? homeQwenDir : homeDir) || path2.dirname(homeQwenDir),
2326
2222
  homeQwenDir
2327
2223
  };
2328
2224
  }
@@ -2361,7 +2257,7 @@ async function fireSessionPermissionDeniedForAutoMode(config, decision, outcome,
2361
2257
  callId
2362
2258
  );
2363
2259
  } catch (hookError) {
2364
- debugLogger6.warn(
2260
+ debugLogger5.warn(
2365
2261
  `PermissionDenied hook failed for tool ${callId}: ${hookError instanceof Error ? hookError.message : String(hookError)}`
2366
2262
  );
2367
2263
  }
@@ -2491,7 +2387,7 @@ async function buildAvailableCommandsSnapshot(config, abortSignal = AbortSignal.
2491
2387
  }
2492
2388
  }
2493
2389
  } catch (error) {
2494
- debugLogger6.error("Error loading available skills:", error);
2390
+ debugLogger5.error("Error loading available skills:", error);
2495
2391
  }
2496
2392
  for (const command of visibleSlashCommands) {
2497
2393
  if (command.kind !== "skill" /* SKILL */ || !command.skillDetail) {
@@ -2525,12 +2421,7 @@ var Session = class {
2525
2421
  this.runtimeBaseDir = config.storage.getRuntimeBaseDir();
2526
2422
  const todoStopGuardEnabled = this.settings.merged.experimental?.todoStopGuard === true && !this.config.getBareMode() && !this.config.isSafeMode();
2527
2423
  this.todoStopGuard = new DaemonTodoStopGuard(todoStopGuardEnabled);
2528
- this.todoStopGuardBackgroundBaseline = todoStopGuardEnabled ? this.#captureTodoStopGuardBackgroundBaseline() : {
2529
- agents: /* @__PURE__ */ new Set(),
2530
- shells: /* @__PURE__ */ new Set(),
2531
- monitors: /* @__PURE__ */ new Set(),
2532
- wakeups: /* @__PURE__ */ new Set()
2533
- };
2424
+ this.todoStopGuardBackgroundBaseline = this.#captureTodoStopGuardBackgroundBaseline();
2534
2425
  this.toolCallEmitter = new ToolCallEmitter(this);
2535
2426
  this.planEmitter = new PlanEmitter(this);
2536
2427
  this.historyReplayer = new HistoryReplayer(this, {
@@ -2540,6 +2431,9 @@ var Session = class {
2540
2431
  this.installGoalTerminalObserver();
2541
2432
  this.#registerBackgroundNotificationCallbacks();
2542
2433
  this.#registerSubSessionSpawner();
2434
+ this.config.getWorkflowRunRegistry?.().setApprovalRequestCallback(
2435
+ (entry, approval, rawArgs, signal) => this.#requestWorkflowApproval(entry.runId, approval, rawArgs, signal)
2436
+ );
2543
2437
  }
2544
2438
  static {
2545
2439
  __name(this, "Session");
@@ -2562,6 +2456,7 @@ var Session = class {
2562
2456
  */
2563
2457
  followupAbort = null;
2564
2458
  turn = 0;
2459
+ activeTodoWorkChainPromptId;
2565
2460
  createdAt = Date.now();
2566
2461
  /**
2567
2462
  * Running cumulative usage for this session, snapshotted onto each todo/plan
@@ -2625,6 +2520,7 @@ var Session = class {
2625
2520
  closeGateCompletion = null;
2626
2521
  resolveCloseGate = null;
2627
2522
  unsubscribeChatRecordingFailure;
2523
+ workflowApprovalAbortController = new AbortController();
2628
2524
  // Modular components
2629
2525
  historyReplayer;
2630
2526
  toolCallEmitter;
@@ -2650,6 +2546,106 @@ var Session = class {
2650
2546
  pendingRecoveredAgentsNotice = null;
2651
2547
  // Implement SessionContext interface
2652
2548
  sessionId;
2549
+ async #requestWorkflowApproval(runId, approval, rawArgs, approvalSignal) {
2550
+ const registry = this.config.getWorkflowRunRegistry();
2551
+ const externalToolCallId = `workflow:${this.sessionId}:${runId}:${approval.approvalId}`;
2552
+ const confirmationDetails = {
2553
+ ...approval.confirmationDetails,
2554
+ onConfirm: /* @__PURE__ */ __name(async () => {
2555
+ }, "onConfirm")
2556
+ };
2557
+ const permissionOptions = toPermissionOptions(confirmationDetails, true);
2558
+ const offeredPermissionOptions = permissionOptions.map((option) => ({
2559
+ ...option
2560
+ }));
2561
+ const content = confirmationDetails.type === "edit" ? [
2562
+ ...(confirmationDetails.warnings ?? []).map((warning) => ({
2563
+ type: "content",
2564
+ content: { type: "text", text: warning }
2565
+ })),
2566
+ ...confirmationDetails.fileDiff ? [
2567
+ {
2568
+ type: "content",
2569
+ content: {
2570
+ type: "text",
2571
+ text: confirmationDetails.fileDiff
2572
+ }
2573
+ }
2574
+ ] : []
2575
+ ] : buildPermissionRequestContent(confirmationDetails);
2576
+ const { title, locations, kind } = this.toolCallEmitter.resolveToolMetadata(
2577
+ approval.name,
2578
+ rawArgs
2579
+ );
2580
+ const params = {
2581
+ sessionId: this.sessionId,
2582
+ options: permissionOptions,
2583
+ toolCall: {
2584
+ toolCallId: externalToolCallId,
2585
+ status: "pending",
2586
+ title,
2587
+ content,
2588
+ locations,
2589
+ kind,
2590
+ rawInput: rawArgs,
2591
+ _meta: { toolName: approval.name, workflowApproval: true }
2592
+ }
2593
+ };
2594
+ const signal = AbortSignal.any([
2595
+ this.workflowApprovalAbortController.signal,
2596
+ approvalSignal
2597
+ ]);
2598
+ try {
2599
+ const response = await this.#requestPermissionQueued(params, signal);
2600
+ const outcome = resolvePermissionOutcome(
2601
+ response,
2602
+ offeredPermissionOptions
2603
+ );
2604
+ const resolved = await registry.resolvePendingApproval(
2605
+ runId,
2606
+ approval.approvalId,
2607
+ outcome === "proceed_once" /* ProceedOnce */ ? outcome : "cancel" /* Cancel */,
2608
+ void 0
2609
+ );
2610
+ await this.#finishWorkflowApprovalToolCall(
2611
+ approval,
2612
+ externalToolCallId,
2613
+ resolved && outcome === "proceed_once" /* ProceedOnce */
2614
+ );
2615
+ } catch (error) {
2616
+ debugLogger5.error("Workflow permission request failed:", error);
2617
+ await registry.resolvePendingApproval(
2618
+ runId,
2619
+ approval.approvalId,
2620
+ "cancel" /* Cancel */
2621
+ );
2622
+ await this.#finishWorkflowApprovalToolCall(
2623
+ approval,
2624
+ externalToolCallId,
2625
+ false
2626
+ );
2627
+ }
2628
+ }
2629
+ async #finishWorkflowApprovalToolCall(approval, externalToolCallId, success) {
2630
+ try {
2631
+ await this.sendUpdate({
2632
+ sessionUpdate: "tool_call_update",
2633
+ toolCallId: externalToolCallId,
2634
+ status: success ? "completed" : "failed",
2635
+ content: [],
2636
+ _meta: {
2637
+ toolName: approval.name,
2638
+ workflowApproval: true,
2639
+ approvalOutcome: success ? "approved" : "denied"
2640
+ }
2641
+ });
2642
+ } catch (error) {
2643
+ debugLogger5.warn(
2644
+ "Failed to finalize workflow approval tool call:",
2645
+ error
2646
+ );
2647
+ }
2648
+ }
2653
2649
  #prepareTodoStopGuardForPrompt(params) {
2654
2650
  if (!this.todoStopGuard.enabled) {
2655
2651
  return {
@@ -2810,7 +2806,7 @@ var Session = class {
2810
2806
  }
2811
2807
  return "unavailable";
2812
2808
  } catch (error) {
2813
- debugLogger6.warn(
2809
+ debugLogger5.warn(
2814
2810
  `Todo Stop Guard continuation claim unavailable [session ${this.sessionId}]: ${this.#formatError(error)}`
2815
2811
  );
2816
2812
  return "unavailable";
@@ -2976,7 +2972,7 @@ var Session = class {
2976
2972
  */
2977
2973
  startCronScheduler() {
2978
2974
  this.#startCronSchedulerInRuntime().catch((error) => {
2979
- debugLogger6.warn(
2975
+ debugLogger5.warn(
2980
2976
  `Cron scheduler startup failed [session ${this.sessionId}]: ${error}`
2981
2977
  );
2982
2978
  });
@@ -3019,8 +3015,8 @@ var Session = class {
3019
3015
  }
3020
3016
  this.closing = true;
3021
3017
  let resolveGate;
3022
- const completion = new Promise((resolve5) => {
3023
- resolveGate = resolve5;
3018
+ const completion = new Promise((resolve4) => {
3019
+ resolveGate = resolve4;
3024
3020
  });
3025
3021
  this.closeGateCompletion = completion;
3026
3022
  this.resolveCloseGate = resolveGate;
@@ -3060,7 +3056,7 @@ var Session = class {
3060
3056
  if (pending.length > 0) {
3061
3057
  await Promise.allSettled(pending);
3062
3058
  }
3063
- await new Promise((resolve5) => setImmediate(resolve5));
3059
+ await new Promise((resolve4) => setImmediate(resolve4));
3064
3060
  }
3065
3061
  }
3066
3062
  #deferAutomaticQueueDrainUntilTurnsSettle() {
@@ -3119,6 +3115,8 @@ var Session = class {
3119
3115
  this.unsubscribeChatRecordingFailure?.();
3120
3116
  this.unsubscribeChatRecordingFailure = void 0;
3121
3117
  this.config.setSubSessionSpawner(void 0);
3118
+ this.config.getWorkflowRunRegistry?.().setApprovalRequestCallback(void 0);
3119
+ this.workflowApprovalAbortController.abort(SESSION_DISPOSE_ABORT_REASON);
3122
3120
  clearGoalTerminalObserver(this.sessionId);
3123
3121
  }
3124
3122
  /**
@@ -3128,7 +3126,7 @@ var Session = class {
3128
3126
  installRewriter() {
3129
3127
  const rewriteConfig = loadRewriteConfig(this.settings);
3130
3128
  if (rewriteConfig?.enabled) {
3131
- debugLogger6.info("Message rewrite middleware enabled");
3129
+ debugLogger5.info("Message rewrite middleware enabled");
3132
3130
  this.messageRewriter = new MessageRewriteMiddleware(
3133
3131
  this.config,
3134
3132
  rewriteConfig,
@@ -3147,7 +3145,7 @@ var Session = class {
3147
3145
  installGoalTerminalObserver() {
3148
3146
  setGoalTerminalObserver(this.sessionId, (event) => {
3149
3147
  void this.messageEmitter.emitGoalTerminal(event).catch((error) => {
3150
- debugLogger6.warn(
3148
+ debugLogger5.warn(
3151
3149
  `Failed to emit goal terminal update: ${this.#formatError(error)}`
3152
3150
  );
3153
3151
  });
@@ -3164,7 +3162,7 @@ var Session = class {
3164
3162
  */
3165
3163
  emitGoalStatus(status) {
3166
3164
  void this.messageEmitter.emitGoalStatus(status).catch((error) => {
3167
- debugLogger6.warn(
3165
+ debugLogger5.warn(
3168
3166
  `Failed to emit goal status update: ${this.#formatError(error)}`
3169
3167
  );
3170
3168
  });
@@ -3408,8 +3406,8 @@ var Session = class {
3408
3406
  const channelDelivery = parsePromptChannelDelivery(params);
3409
3407
  const channelDeliveryCapture = channelDelivery ? { finalText: "" } : void 0;
3410
3408
  let resolveCompletion;
3411
- this.pendingPromptCompletion = new Promise((resolve5) => {
3412
- resolveCompletion = resolve5;
3409
+ this.pendingPromptCompletion = new Promise((resolve4) => {
3410
+ resolveCompletion = resolve4;
3413
3411
  });
3414
3412
  try {
3415
3413
  const result = await this.#executePrompt(
@@ -3529,7 +3527,7 @@ var Session = class {
3529
3527
  const fullHistory = chat.getHistory(true);
3530
3528
  const lastEntry = fullHistory[fullHistory.length - 1];
3531
3529
  if (!lastEntry || lastEntry.role !== "model") {
3532
- debugLogger6.debug(
3530
+ debugLogger5.debug(
3533
3531
  "Skipping followup suggestion: last history entry is not model"
3534
3532
  );
3535
3533
  return;
@@ -3565,9 +3563,9 @@ var Session = class {
3565
3563
  }
3566
3564
  } catch (error) {
3567
3565
  if (ac.signal.aborted) {
3568
- debugLogger6.debug("Follow-up suggestion generation aborted");
3566
+ debugLogger5.debug("Follow-up suggestion generation aborted");
3569
3567
  } else {
3570
- debugLogger6.warn("Follow-up suggestion generation failed", error);
3568
+ debugLogger5.warn("Follow-up suggestion generation failed", error);
3571
3569
  }
3572
3570
  } finally {
3573
3571
  if (this.followupAbort === ac) {
@@ -3603,6 +3601,8 @@ var Session = class {
3603
3601
  }
3604
3602
  this.turn += 1;
3605
3603
  const promptId = this.config.getSessionId() + "########" + this.turn;
3604
+ const promptMetadata = params._meta;
3605
+ const continuesCurrentWorkChain = params.retry === true || promptMetadata?.[DAEMON_RETRY_META_KEY] === true || promptMetadata?.[DAEMON_CONTINUE_META_KEY] === true;
3606
3606
  promptIdContext.enterWith(promptId);
3607
3607
  const parentContext = extractDaemonTraceContext(params);
3608
3608
  return await withInteractionSpan(
@@ -3635,7 +3635,7 @@ var Session = class {
3635
3635
  apiHistory: this.#getCurrentChat().getHistory()
3636
3636
  });
3637
3637
  if (!recoveryPlan.continuation) {
3638
- debugLogger6.warn(
3638
+ debugLogger5.warn(
3639
3639
  `[Session] continue ${promptId}: no interrupted turn on re-detection, nothing to continue`
3640
3640
  );
3641
3641
  logConversationFinishedEvent(
@@ -3727,9 +3727,20 @@ var Session = class {
3727
3727
  }
3728
3728
  const additionalContext = hookOutput?.getAdditionalContext();
3729
3729
  if (additionalContext) {
3730
- parts = [...parts, { text: additionalContext }];
3730
+ parts = [
3731
+ ...parts,
3732
+ { text: wrapUserPromptSubmitContext(additionalContext) }
3733
+ ];
3731
3734
  }
3732
3735
  }
3736
+ if (!continuesCurrentWorkChain && !this.todoStopGuard.enabled) {
3737
+ this.#resetTodoStopGuardBackgroundLineage();
3738
+ }
3739
+ this.config.startActiveTodoWorkChain(
3740
+ promptId,
3741
+ continuesCurrentWorkChain ? this.activeTodoWorkChainPromptId : void 0
3742
+ );
3743
+ this.activeTodoWorkChainPromptId = promptId;
3733
3744
  try {
3734
3745
  const fileHistoryService = this.config.getFileHistoryService();
3735
3746
  await fileHistoryService.makeSnapshot(promptId);
@@ -3739,10 +3750,10 @@ var Session = class {
3739
3750
  this.config.getChatRecordingService()?.recordFileHistorySnapshot(latestSnapshot);
3740
3751
  }
3741
3752
  } catch (e) {
3742
- debugLogger6.error(`FileHistory: recordSnapshot failed: ${e}`);
3753
+ debugLogger5.error(`FileHistory: recordSnapshot failed: ${e}`);
3743
3754
  }
3744
3755
  } catch (e) {
3745
- debugLogger6.error(`FileHistory: makeSnapshot failed: ${e}`);
3756
+ debugLogger5.error(`FileHistory: makeSnapshot failed: ${e}`);
3746
3757
  }
3747
3758
  const systemReminders = await this.#buildInitialSystemReminders();
3748
3759
  if (systemReminders.length > 0) {
@@ -3775,6 +3786,15 @@ ${this.pendingRecoveredAgentsNotice}
3775
3786
  parts = insertAfterFunctionResponses(parts, [noticePart]);
3776
3787
  this.pendingRecoveredAgentsNotice = null;
3777
3788
  }
3789
+ const activeTodoReminder = this.config.takeActiveTodoReminder(
3790
+ promptId,
3791
+ true
3792
+ );
3793
+ if (activeTodoReminder && !parts.some((part) => part.text === activeTodoReminder)) {
3794
+ parts = insertAfterFunctionResponses(parts, [
3795
+ { text: activeTodoReminder }
3796
+ ]);
3797
+ }
3778
3798
  let nextMessage = { role: "user", parts };
3779
3799
  let turnCount = 0;
3780
3800
  const toolLoopState = createDaemonToolLoopState();
@@ -3896,7 +3916,7 @@ ${this.pendingRecoveredAgentsNotice}
3896
3916
  const hooksEnabledForStopFailure = !this.config.getDisableAllHooks?.();
3897
3917
  if (hooksEnabledForStopFailure && hookSystem && this.config.hasHooksForEvent?.("StopFailure")) {
3898
3918
  hookSystem.fireStopFailureEvent(errorType, errorMessage).catch((err) => {
3899
- debugLogger6.warn(`StopFailure hook failed: ${err}`);
3919
+ debugLogger5.warn(`StopFailure hook failed: ${err}`);
3900
3920
  });
3901
3921
  }
3902
3922
  if (errorStatus === 429) {
@@ -3952,6 +3972,7 @@ ${this.pendingRecoveredAgentsNotice}
3952
3972
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
3953
3973
  toolRun,
3954
3974
  pendingSend.signal,
3975
+ promptId,
3955
3976
  onFullTurnModel
3956
3977
  );
3957
3978
  nextMessage = nextAfterTools.message;
@@ -4203,7 +4224,7 @@ ${this.pendingRecoveredAgentsNotice}
4203
4224
  );
4204
4225
  this.todoStopGuard.suspend();
4205
4226
  await this.messageEmitter.emitAgentMessage(warning);
4206
- debugLogger6.warn(warning);
4227
+ debugLogger5.warn(warning);
4207
4228
  return { stopReason: "end_turn" };
4208
4229
  }
4209
4230
  if (!externalReason && !guardContinuation) {
@@ -4632,7 +4653,7 @@ ${this.pendingRecoveredAgentsNotice}
4632
4653
  const hookSystem = this.config.getHookSystem?.();
4633
4654
  if (!this.config.getDisableAllHooks?.() && hookSystem && this.config.hasHooksForEvent?.("StopFailure")) {
4634
4655
  hookSystem.fireStopFailureEvent(errorType, errorMessage).catch((err) => {
4635
- debugLogger6.warn(`StopFailure hook failed: ${err}`);
4656
+ debugLogger5.warn(`StopFailure hook failed: ${err}`);
4636
4657
  });
4637
4658
  }
4638
4659
  if (errorStatus === 429) {
@@ -4687,6 +4708,7 @@ ${this.pendingRecoveredAgentsNotice}
4687
4708
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
4688
4709
  toolRun,
4689
4710
  pendingSend.signal,
4711
+ toolPromptId,
4690
4712
  options.onFullTurnModel
4691
4713
  );
4692
4714
  nextMessage = nextAfterTools.message;
@@ -4763,7 +4785,7 @@ ${this.pendingRecoveredAgentsNotice}
4763
4785
  }
4764
4786
  });
4765
4787
  } catch (error) {
4766
- debugLogger6.warn(
4788
+ debugLogger5.warn(
4767
4789
  `Failed to emit Todo Stop Guard status: ${this.#formatError(error)}`
4768
4790
  );
4769
4791
  }
@@ -4779,7 +4801,7 @@ ${this.pendingRecoveredAgentsNotice}
4779
4801
  const timer = setTimeout(() => {
4780
4802
  void this.client.extMethod(SERVE_CONTROL_EXT_METHODS.channelDelivery, params).catch((error) => {
4781
4803
  try {
4782
- debugLogger6.warn(
4804
+ debugLogger5.warn(
4783
4805
  `Channel delivery submission failed: ${error instanceof Error ? error.message : String(error)}`
4784
4806
  );
4785
4807
  } catch {
@@ -4817,7 +4839,7 @@ ${this.pendingRecoveredAgentsNotice}
4817
4839
  return new MessageDisplayDispatcher(
4818
4840
  messageBus,
4819
4841
  signal,
4820
- (message) => debugLogger6.warn(message)
4842
+ (message) => debugLogger5.warn(message)
4821
4843
  );
4822
4844
  }
4823
4845
  /**
@@ -4838,7 +4860,7 @@ ${this.pendingRecoveredAgentsNotice}
4838
4860
  message = decision.message;
4839
4861
  }
4840
4862
  if (abortSignal.aborted) {
4841
- debugLogger6.debug(
4863
+ debugLogger5.debug(
4842
4864
  `Send aborted after pre-compression preparation for prompt ${promptId}`
4843
4865
  );
4844
4866
  return { responseStream: null, stopReason: "cancelled" };
@@ -4865,20 +4887,20 @@ ${this.pendingRecoveredAgentsNotice}
4865
4887
  }
4866
4888
  } catch (compressionError) {
4867
4889
  if (abortSignal.aborted) {
4868
- debugLogger6.debug(`Auto-compression aborted for prompt ${promptId}`);
4890
+ debugLogger5.debug(`Auto-compression aborted for prompt ${promptId}`);
4869
4891
  return { responseStream: null, stopReason: "cancelled" };
4870
4892
  }
4871
4893
  if (this.#isAbortError(compressionError)) {
4872
4894
  throw compressionError;
4873
4895
  }
4874
- debugLogger6.warn(
4896
+ debugLogger5.warn(
4875
4897
  `Auto-compression failed for prompt ${promptId}; proceeding without compression: ` + this.#formatError(compressionError)
4876
4898
  );
4877
4899
  compressionFailed = true;
4878
4900
  }
4879
4901
  }
4880
4902
  if (abortSignal.aborted) {
4881
- debugLogger6.debug(`Auto-compression aborted for prompt ${promptId}`);
4903
+ debugLogger5.debug(`Auto-compression aborted for prompt ${promptId}`);
4882
4904
  return { responseStream: null, stopReason: "cancelled" };
4883
4905
  }
4884
4906
  if (!compressionInfo) {
@@ -4888,7 +4910,7 @@ ${this.pendingRecoveredAgentsNotice}
4888
4910
  if (sessionTokenLimit > 0) {
4889
4911
  const lastPromptTokenCount = this.#getPostCompressionTokenCount(compressionInfo);
4890
4912
  if (lastPromptTokenCount > sessionTokenLimit) {
4891
- debugLogger6.warn(
4913
+ debugLogger5.warn(
4892
4914
  `Session token limit exceeded for prompt ${promptId}: ${lastPromptTokenCount} > ${sessionTokenLimit}. Send dropped.`
4893
4915
  );
4894
4916
  await this.#emitAgentDiagnosticMessageSafely(
@@ -4905,7 +4927,7 @@ ${this.pendingRecoveredAgentsNotice}
4905
4927
  );
4906
4928
  }
4907
4929
  if (abortSignal.aborted) {
4908
- debugLogger6.debug(
4930
+ debugLogger5.debug(
4909
4931
  `Send aborted after compression diagnostic for prompt ${promptId}`
4910
4932
  );
4911
4933
  return { responseStream: null, stopReason: "cancelled" };
@@ -4918,7 +4940,7 @@ ${this.pendingRecoveredAgentsNotice}
4918
4940
  message = decision.message;
4919
4941
  }
4920
4942
  if (abortSignal.aborted) {
4921
- debugLogger6.debug(
4943
+ debugLogger5.debug(
4922
4944
  `Send aborted after pre-send validation for prompt ${promptId}`
4923
4945
  );
4924
4946
  return { responseStream: null, stopReason: "cancelled" };
@@ -4946,7 +4968,7 @@ ${this.pendingRecoveredAgentsNotice}
4946
4968
  ) ?? [];
4947
4969
  const droppedParts = (message.parts?.length ?? 0) - functionResponseParts.length;
4948
4970
  if (droppedParts > 0) {
4949
- debugLogger6.debug(
4971
+ debugLogger5.debug(
4950
4972
  `Dropping ${droppedParts} non-functionResponse part(s) from unsent ACP message after send was skipped.`
4951
4973
  );
4952
4974
  }
@@ -4976,14 +4998,14 @@ ${this.pendingRecoveredAgentsNotice}
4976
4998
  );
4977
4999
  await this.messageRewriter?.waitForPendingRewrites();
4978
5000
  }
4979
- async #buildNextMessageAfterToolRun(toolRun, abortSignal, onFullTurnModel) {
5001
+ async #buildNextMessageAfterToolRun(toolRun, abortSignal, promptId, onFullTurnModel) {
4980
5002
  if (toolRun.loopDetected) {
4981
- debugLogger6.debug("Stopping ACP turn after daemon loop detection.");
5003
+ debugLogger5.debug("Stopping ACP turn after daemon loop detection.");
4982
5004
  return { message: null, hadMidTurnUserInput: false };
4983
5005
  }
4984
5006
  if (toolRun.repeatedDuplicateProviderToolCall) {
4985
5007
  this.todoStopGuard.suspend();
4986
- debugLogger6.debug(
5008
+ debugLogger5.debug(
4987
5009
  "Stopping ACP turn after dropping repeated duplicate provider tool-call response."
4988
5010
  );
4989
5011
  return { message: null, hadMidTurnUserInput: false };
@@ -4995,7 +5017,12 @@ ${this.pendingRecoveredAgentsNotice}
4995
5017
  if (hadMidTurnUserInput) {
4996
5018
  this.todoStopGuard.acceptMidTurnUserInput();
4997
5019
  }
4998
- const parts = [...toolRun.parts, ...drained.parts];
5020
+ const activeTodoReminder = this.config.takeActiveTodoReminder(promptId);
5021
+ const parts = [
5022
+ ...toolRun.parts,
5023
+ ...activeTodoReminder ? [{ text: activeTodoReminder }] : [],
5024
+ ...drained.parts
5025
+ ];
4999
5026
  return {
5000
5027
  message: { role: "user", parts },
5001
5028
  hadMidTurnUserInput
@@ -5068,7 +5095,7 @@ ${this.pendingRecoveredAgentsNotice}
5068
5095
  try {
5069
5096
  await this.#emitAgentDiagnosticMessage(text);
5070
5097
  } catch (notifyError) {
5071
- debugLogger6.warn(`${failureContext}: ${this.#formatError(notifyError)}`);
5098
+ debugLogger5.warn(`${failureContext}: ${this.#formatError(notifyError)}`);
5072
5099
  }
5073
5100
  }
5074
5101
  async #emitAgentDiagnosticMessage(text) {
@@ -5134,7 +5161,7 @@ ${this.pendingRecoveredAgentsNotice}
5134
5161
  if (isPermanentError) {
5135
5162
  this.midTurnDrainUnavailable = true;
5136
5163
  }
5137
- debugLogger6.warn(
5164
+ debugLogger5.warn(
5138
5165
  `Mid-turn queue drain ${isPermanentError ? "permanently " : ""}unavailable [session ${this.sessionId}]: ${errorMessage}`
5139
5166
  );
5140
5167
  return {
@@ -5164,9 +5191,9 @@ ${this.pendingRecoveredAgentsNotice}
5164
5191
  });
5165
5192
  const expired = Symbol("mid-turn-recovery-expired");
5166
5193
  let timer;
5167
- const deadline = new Promise((resolve5) => {
5194
+ const deadline = new Promise((resolve4) => {
5168
5195
  timer = setTimeout(
5169
- () => resolve5(expired),
5196
+ () => resolve4(expired),
5170
5197
  MID_TURN_QUEUE_RECOVERY_TIMEOUT_MS
5171
5198
  );
5172
5199
  timer.unref?.();
@@ -5180,14 +5207,14 @@ ${this.pendingRecoveredAgentsNotice}
5180
5207
  clearTimeout(timer);
5181
5208
  }
5182
5209
  if (late === expired) {
5183
- debugLogger6.warn(
5210
+ debugLogger5.warn(
5184
5211
  `[mid-turn] dropped a drain response that arrived after the ${MID_TURN_QUEUE_RECOVERY_TIMEOUT_MS}ms recovery deadline [session ${this.sessionId}]`
5185
5212
  );
5186
5213
  return;
5187
5214
  }
5188
5215
  const lateMessages = parseMidTurnDrainResponse(late);
5189
5216
  if (lateMessages.length > 0) {
5190
- debugLogger6.debug(
5217
+ debugLogger5.debug(
5191
5218
  `[mid-turn] recovered ${lateMessages.length} message(s) from a timed-out drain [session ${this.sessionId}]`
5192
5219
  );
5193
5220
  this.midTurnRecoveredMessages.push(...lateMessages);
@@ -5218,7 +5245,7 @@ ${this.pendingRecoveredAgentsNotice}
5218
5245
  }
5219
5246
  if (!abortSignal.aborted) {
5220
5247
  const errorMessage = this.#formatError(messageError);
5221
- debugLogger6.warn(
5248
+ debugLogger5.warn(
5222
5249
  `Failed to resolve mid-turn message: ${errorMessage}`
5223
5250
  );
5224
5251
  }
@@ -5246,7 +5273,7 @@ ${this.pendingRecoveredAgentsNotice}
5246
5273
  try {
5247
5274
  await scheduler.enableDurable(this.sessionId);
5248
5275
  } catch (err) {
5249
- debugLogger6.warn(
5276
+ debugLogger5.warn(
5250
5277
  `Durable cron init failed \u2014 persistent tasks will not fire in this session: ${err}`
5251
5278
  );
5252
5279
  }
@@ -5260,7 +5287,8 @@ ${this.pendingRecoveredAgentsNotice}
5260
5287
  source: job.cronExpr === "@wakeup" ? "loop" : "cron",
5261
5288
  ...job.id ? { taskId: job.id } : {},
5262
5289
  ...job.lastFiredAt !== void 0 ? { firedAt: job.lastFiredAt } : {},
5263
- ...job.delivery ? { delivery: job.delivery } : {}
5290
+ ...job.delivery ? { delivery: job.delivery } : {},
5291
+ ...job.todoWorkChainId ? { todoWorkChainId: job.todoWorkChainId } : {}
5264
5292
  });
5265
5293
  void this.#drainCronQueue();
5266
5294
  });
@@ -5308,7 +5336,7 @@ ${this.pendingRecoveredAgentsNotice}
5308
5336
  unrelatedCount--;
5309
5337
  }
5310
5338
  if (evictedTaskIds.length > 0) {
5311
- debugLogger6.warn(
5339
+ debugLogger5.warn(
5312
5340
  `Cron queue overflow while automatic work is deferred: evicted ${evictedTaskIds.length} unrelated task(s): ${evictedTaskIds.join(", ")}`
5313
5341
  );
5314
5342
  }
@@ -5331,7 +5359,7 @@ ${this.pendingRecoveredAgentsNotice}
5331
5359
  try {
5332
5360
  await this.assertCanStartTurn();
5333
5361
  } catch (error) {
5334
- debugLogger6.warn(
5362
+ debugLogger5.warn(
5335
5363
  `Cron turn rejected [session ${this.sessionId}]: ${error instanceof Error ? error.message : String(error)}`
5336
5364
  );
5337
5365
  return;
@@ -5342,8 +5370,8 @@ ${this.pendingRecoveredAgentsNotice}
5342
5370
  if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
5343
5371
  this.cronProcessing = true;
5344
5372
  let resolveCompletion;
5345
- this.cronCompletion = new Promise((resolve5) => {
5346
- resolveCompletion = resolve5;
5373
+ this.cronCompletion = new Promise((resolve4) => {
5374
+ resolveCompletion = resolve4;
5347
5375
  });
5348
5376
  try {
5349
5377
  while (this.cronQueue.length > 0) {
@@ -5416,9 +5444,8 @@ ${this.pendingRecoveredAgentsNotice}
5416
5444
  async () => {
5417
5445
  const ac = new AbortController();
5418
5446
  this.cronAbortController = ac;
5419
- this.#prepareTodoStopGuardForAutomaticTurn(
5420
- this.#cronContinuesTodoStopGuardWorkChain(item)
5421
- );
5447
+ const continuesCurrentWorkChain = this.#cronContinuesTodoStopGuardWorkChain(item);
5448
+ this.#prepareTodoStopGuardForAutomaticTurn(continuesCurrentWorkChain);
5422
5449
  const promptId = this.config.getSessionId() + "########cron" + Date.now();
5423
5450
  let cronHadError = false;
5424
5451
  let cronCompleted = false;
@@ -5435,6 +5462,10 @@ ${this.pendingRecoveredAgentsNotice}
5435
5462
  try {
5436
5463
  await this.assertCanStartTurn();
5437
5464
  if (ac.signal.aborted) return;
5465
+ this.config.startAutomaticActiveTodoWorkChain(
5466
+ promptId,
5467
+ item.todoWorkChainId
5468
+ );
5438
5469
  const loopMode = detectLoopSentinel(prompt);
5439
5470
  const autonomousMode = loopMode ? null : detectAutonomousSentinel(prompt);
5440
5471
  let loopTick = null;
@@ -5445,7 +5476,7 @@ ${this.pendingRecoveredAgentsNotice}
5445
5476
  loopTick = await resolver.resolve(loopMode, trustedAtResolve);
5446
5477
  } catch (resolveErr) {
5447
5478
  const code = resolveErr.code ?? "unknown";
5448
- debugLogger6.warn(
5479
+ debugLogger5.warn(
5449
5480
  `loop.md sentinel resolution failed (mode=${loopMode}, code=${code}) \u2014 check .qwen/loop.md permissions/IO`,
5450
5481
  resolveErr
5451
5482
  );
@@ -5468,7 +5499,7 @@ ${this.pendingRecoveredAgentsNotice}
5468
5499
  }
5469
5500
  const modelText = loopTick ? loopTick.modelText : prompt;
5470
5501
  if (loopTick) {
5471
- debugLogger6.debug(
5502
+ debugLogger5.debug(
5472
5503
  `loop tick: mode=${loopMode ?? autonomousMode} delivery=${loopTick.full ? "full" : loopTick.transientError ? "transient-error" : loopTick.autonomous ? "autonomous-tick" : loopTick.sourceLabel ? "reminder" : "absent"} source=${loopTick.sourceLabel ?? "none"} autonomous=${loopTick.autonomous ?? false} transient=${loopTick.transientError ?? false}`
5473
5504
  );
5474
5505
  }
@@ -5489,9 +5520,17 @@ ${this.pendingRecoveredAgentsNotice}
5489
5520
  _meta: { source: item.source }
5490
5521
  });
5491
5522
  const cronReminders = await this.#buildInitialSystemReminders();
5523
+ const activeTodoReminder = this.config.takeActiveTodoReminder(
5524
+ promptId,
5525
+ true
5526
+ );
5492
5527
  let nextMessage = {
5493
5528
  role: "user",
5494
- parts: [...cronReminders, { text: modelText }]
5529
+ parts: [
5530
+ ...cronReminders,
5531
+ ...activeTodoReminder ? [{ text: activeTodoReminder }] : [],
5532
+ { text: modelText }
5533
+ ]
5495
5534
  };
5496
5535
  const toolLoopState = createDaemonToolLoopState();
5497
5536
  while (nextMessage !== null) {
@@ -5623,7 +5662,8 @@ ${this.pendingRecoveredAgentsNotice}
5623
5662
  }
5624
5663
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
5625
5664
  toolRun,
5626
- ac.signal
5665
+ ac.signal,
5666
+ promptId
5627
5667
  );
5628
5668
  nextMessage = nextAfterTools.message;
5629
5669
  if (toolRun.loopDetected) {
@@ -5657,12 +5697,13 @@ ${this.pendingRecoveredAgentsNotice}
5657
5697
  }
5658
5698
  this.todoStopGuard.pauseForTrustedRetry();
5659
5699
  cronHadError = true;
5660
- debugLogger6.error("Error processing cron prompt:", error);
5700
+ debugLogger5.error("Error processing cron prompt:", error);
5661
5701
  const msg = error instanceof Error ? error.message : String(error);
5662
5702
  await this.messageEmitter.emitAgentMessage(
5663
5703
  `[${item.source} error] ${msg}`
5664
5704
  );
5665
5705
  } finally {
5706
+ this.config.endAutomaticActiveTodoWorkChain(promptId);
5666
5707
  if (this.cronAbortController === ac) {
5667
5708
  this.cronAbortController = null;
5668
5709
  }
@@ -5715,7 +5756,8 @@ ${this.pendingRecoveredAgentsNotice}
5715
5756
  status: meta.status,
5716
5757
  kind: "agent",
5717
5758
  continuesTodoStopGuardWorkChain: this.#agentContinuesTodoStopGuardWorkChain(meta.agentId),
5718
- toolUseId: meta.toolUseId
5759
+ toolUseId: meta.toolUseId,
5760
+ todoWorkChainId: meta.todoWorkChainId
5719
5761
  });
5720
5762
  }
5721
5763
  );
@@ -5734,7 +5776,8 @@ ${this.pendingRecoveredAgentsNotice}
5734
5776
  meta.monitorId,
5735
5777
  meta.ownerAgentId
5736
5778
  ),
5737
- toolUseId: meta.toolUseId
5779
+ toolUseId: meta.toolUseId,
5780
+ todoWorkChainId: meta.todoWorkChainId
5738
5781
  });
5739
5782
  });
5740
5783
  const shellRegistry = this.config.getBackgroundShellRegistry();
@@ -5745,7 +5788,8 @@ ${this.pendingRecoveredAgentsNotice}
5745
5788
  taskId: meta.shellId,
5746
5789
  status: meta.status,
5747
5790
  kind: "shell",
5748
- continuesTodoStopGuardWorkChain: !this.todoStopGuardBackgroundBaseline.shells.has(meta.shellId)
5791
+ continuesTodoStopGuardWorkChain: !this.todoStopGuardBackgroundBaseline.shells.has(meta.shellId),
5792
+ todoWorkChainId: meta.todoWorkChainId
5749
5793
  });
5750
5794
  });
5751
5795
  this.config.getChatRecordingService()?.setTitleRecordedCallback((customTitle, titleSource, sessionId) => {
@@ -5779,20 +5823,20 @@ ${this.pendingRecoveredAgentsNotice}
5779
5823
  (queued) => !this.#notificationContinuesTodoStopGuardWorkChain(queued)
5780
5824
  );
5781
5825
  if (evictedIndex < 0 && !incomingIsRelated) {
5782
- debugLogger6.warn(
5826
+ debugLogger5.warn(
5783
5827
  `Notification queue overflow: dropping unrelated task=${item.taskId} kind=${item.kind} while automatic work is deferred`
5784
5828
  );
5785
5829
  return;
5786
5830
  }
5787
5831
  if (evictedIndex < 0) {
5788
- debugLogger6.warn(
5832
+ debugLogger5.warn(
5789
5833
  `Notification queue overflow: dropping related task=${item.taskId} kind=${item.kind} because all queued items are related`
5790
5834
  );
5791
5835
  return;
5792
5836
  }
5793
5837
  }
5794
5838
  const [evicted] = this.notificationQueue.splice(evictedIndex, 1);
5795
- debugLogger6.warn(
5839
+ debugLogger5.warn(
5796
5840
  `Notification queue overflow: evicting task=${evicted?.taskId ?? "unknown"} kind=${evicted?.kind ?? "unknown"}`
5797
5841
  );
5798
5842
  }
@@ -5812,7 +5856,7 @@ ${this.pendingRecoveredAgentsNotice}
5812
5856
  try {
5813
5857
  await this.assertCanStartTurn();
5814
5858
  } catch (error) {
5815
- debugLogger6.warn(
5859
+ debugLogger5.warn(
5816
5860
  `Notification turn rejected [session ${this.sessionId}]: ${error instanceof Error ? error.message : String(error)}`
5817
5861
  );
5818
5862
  return;
@@ -5823,8 +5867,8 @@ ${this.pendingRecoveredAgentsNotice}
5823
5867
  if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
5824
5868
  this.notificationProcessing = true;
5825
5869
  let resolveCompletion;
5826
- this.notificationCompletion = new Promise((resolve5) => {
5827
- resolveCompletion = resolve5;
5870
+ this.notificationCompletion = new Promise((resolve4) => {
5871
+ resolveCompletion = resolve4;
5828
5872
  });
5829
5873
  try {
5830
5874
  while (this.notificationQueue.length > 0) {
@@ -5868,13 +5912,16 @@ ${this.pendingRecoveredAgentsNotice}
5868
5912
  async () => {
5869
5913
  const ac = new AbortController();
5870
5914
  this.notificationAbortController = ac;
5871
- this.#prepareTodoStopGuardForAutomaticTurn(
5872
- this.#notificationContinuesTodoStopGuardWorkChain(item)
5873
- );
5915
+ const continuesCurrentWorkChain = this.#notificationContinuesTodoStopGuardWorkChain(item);
5916
+ this.#prepareTodoStopGuardForAutomaticTurn(continuesCurrentWorkChain);
5874
5917
  const promptId = this.config.getSessionId() + "########notification" + Date.now();
5875
5918
  try {
5876
5919
  await this.assertCanStartTurn();
5877
5920
  if (ac.signal.aborted) return;
5921
+ this.config.startAutomaticActiveTodoWorkChain(
5922
+ promptId,
5923
+ item.todoWorkChainId
5924
+ );
5878
5925
  await this.#emitBackgroundNotificationDisplay(item);
5879
5926
  const notificationParts = [{ text: item.modelText }];
5880
5927
  this.config.getChatRecordingService()?.recordNotification(notificationParts, item.displayText, {
@@ -5884,9 +5931,17 @@ ${this.pendingRecoveredAgentsNotice}
5884
5931
  toolUseId: item.toolUseId
5885
5932
  });
5886
5933
  const notificationReminders = await this.#buildInitialSystemReminders();
5934
+ const activeTodoReminder = this.config.takeActiveTodoReminder(
5935
+ promptId,
5936
+ true
5937
+ );
5887
5938
  let nextMessage = {
5888
5939
  role: "user",
5889
- parts: [...notificationReminders, ...notificationParts]
5940
+ parts: [
5941
+ ...notificationReminders,
5942
+ ...activeTodoReminder ? [{ text: activeTodoReminder }] : [],
5943
+ ...notificationParts
5944
+ ]
5890
5945
  };
5891
5946
  const toolLoopState = createDaemonToolLoopState();
5892
5947
  while (nextMessage !== null) {
@@ -6016,7 +6071,8 @@ ${this.pendingRecoveredAgentsNotice}
6016
6071
  }
6017
6072
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
6018
6073
  toolRun,
6019
- ac.signal
6074
+ ac.signal,
6075
+ promptId
6020
6076
  );
6021
6077
  nextMessage = nextAfterTools.message;
6022
6078
  if (toolRun.loopDetected) {
@@ -6052,14 +6108,14 @@ ${this.pendingRecoveredAgentsNotice}
6052
6108
  return;
6053
6109
  }
6054
6110
  this.todoStopGuard.pauseForTrustedRetry();
6055
- debugLogger6.error("Error processing background notification:", error);
6111
+ debugLogger5.error("Error processing background notification:", error);
6056
6112
  const msg = error instanceof Error ? error.message : String(error);
6057
6113
  try {
6058
6114
  await this.messageEmitter.emitAgentMessage(
6059
6115
  `[notification error] ${msg}`
6060
6116
  );
6061
6117
  } catch (emitError) {
6062
- debugLogger6.error(
6118
+ debugLogger5.error(
6063
6119
  "Failed to emit background notification error:",
6064
6120
  emitError
6065
6121
  );
@@ -6067,6 +6123,7 @@ ${this.pendingRecoveredAgentsNotice}
6067
6123
  await this.#emitBackgroundNotificationEndTurn("end_turn");
6068
6124
  }
6069
6125
  } finally {
6126
+ this.config.endAutomaticActiveTodoWorkChain(promptId);
6070
6127
  if (this.notificationAbortController === ac) {
6071
6128
  this.notificationAbortController = null;
6072
6129
  }
@@ -6119,7 +6176,7 @@ ${this.pendingRecoveredAgentsNotice}
6119
6176
  source: "background_notification"
6120
6177
  });
6121
6178
  } catch (error) {
6122
- debugLogger6.debug(
6179
+ debugLogger5.debug(
6123
6180
  `Background notification end-turn extNotification dropped: ${this.#formatError(error)}`
6124
6181
  );
6125
6182
  }
@@ -6128,11 +6185,13 @@ ${this.pendingRecoveredAgentsNotice}
6128
6185
  try {
6129
6186
  await this.sendAvailableCommandsUpdateOrThrow();
6130
6187
  } catch (error) {
6131
- debugLogger6.error("Error sending available commands update:", error);
6188
+ debugLogger5.error("Error sending available commands update:", error);
6132
6189
  }
6133
6190
  }
6134
- async refreshSkillsFromSettings() {
6135
- this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
6191
+ async refreshSkillsFromSettings(options = {}) {
6192
+ if (options.reloadSettings ?? true) {
6193
+ this.reloadSkillSettings();
6194
+ }
6136
6195
  const skillManager = this.config.getSkillManager();
6137
6196
  let updateFailed = false;
6138
6197
  let updateError;
@@ -6142,13 +6201,13 @@ ${this.pendingRecoveredAgentsNotice}
6142
6201
  updateFailed = true;
6143
6202
  updateError = error;
6144
6203
  }
6145
- if (skillManager) {
6204
+ if (skillManager && (options.notifyConfigChanged ?? true)) {
6146
6205
  try {
6147
6206
  skillManager.suppressNextSlashReload();
6148
6207
  await skillManager.notifyConfigChanged();
6149
6208
  } catch (error) {
6150
6209
  if (!updateFailed) throw error;
6151
- debugLogger6.error(
6210
+ debugLogger5.error(
6152
6211
  "SkillManager refresh failed after command update failure:",
6153
6212
  error
6154
6213
  );
@@ -6156,6 +6215,9 @@ ${this.pendingRecoveredAgentsNotice}
6156
6215
  }
6157
6216
  if (updateFailed) throw updateError;
6158
6217
  }
6218
+ reloadSkillSettings() {
6219
+ this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
6220
+ }
6159
6221
  async sendAvailableCommandsUpdateOrThrow() {
6160
6222
  const { availableCommands, availableSkills, availableSkillDetails } = await buildAvailableCommandsSnapshot(
6161
6223
  this.config,
@@ -6181,6 +6243,32 @@ ${this.pendingRecoveredAgentsNotice}
6181
6243
  async requestPermission(params) {
6182
6244
  return this.client.requestPermission(params);
6183
6245
  }
6246
+ #requestPermissionQueued(params, signal) {
6247
+ const prior = permissionRequestTails.get(this.client) ?? Promise.resolve();
6248
+ const transportRequest = prior.then(
6249
+ () => signal.aborted ? requestPermissionWithAbort(this.client, params, signal) : this.client.requestPermission(params)
6250
+ );
6251
+ let abortListener;
6252
+ const tail = Promise.race([
6253
+ transportRequest.then(
6254
+ () => void 0,
6255
+ () => void 0
6256
+ ),
6257
+ new Promise((resolve4) => {
6258
+ if (signal.aborted) return resolve4();
6259
+ abortListener = /* @__PURE__ */ __name(() => resolve4(), "abortListener");
6260
+ signal.addEventListener("abort", abortListener, { once: true });
6261
+ })
6262
+ ]).finally(() => {
6263
+ if (abortListener) signal.removeEventListener("abort", abortListener);
6264
+ });
6265
+ permissionRequestTails.set(this.client, tail);
6266
+ return requestPermissionWithAbort(
6267
+ { requestPermission: /* @__PURE__ */ __name(() => transportRequest, "requestPermission") },
6268
+ params,
6269
+ signal
6270
+ );
6271
+ }
6184
6272
  /**
6185
6273
  * Sets the approval mode for the current session.
6186
6274
  * Maps ACP approval mode values to core ApprovalMode enum.
@@ -6209,7 +6297,7 @@ ${this.pendingRecoveredAgentsNotice}
6209
6297
  sessionId: this.sessionId,
6210
6298
  currentModeId: params.modeId
6211
6299
  }).catch((error) => {
6212
- debugLogger6.debug("mode-update extNotification failed", error);
6300
+ debugLogger5.debug("mode-update extNotification failed", error);
6213
6301
  });
6214
6302
  }
6215
6303
  /**
@@ -6265,7 +6353,7 @@ ${this.pendingRecoveredAgentsNotice}
6265
6353
  sessionId: this.sessionId,
6266
6354
  currentModelId: currentAcpModelId
6267
6355
  }).catch((error) => {
6268
- debugLogger6.debug("model-update extNotification failed", error);
6356
+ debugLogger5.debug("model-update extNotification failed", error);
6269
6357
  });
6270
6358
  if (options.persistDefault ?? true) {
6271
6359
  const persistScope = getPersistScopeForModelSelection(this.settings);
@@ -6312,7 +6400,7 @@ ${this.pendingRecoveredAgentsNotice}
6312
6400
  await this.sendUpdate(update);
6313
6401
  legacyFrameSent = true;
6314
6402
  } catch (error) {
6315
- debugLogger6.debug("current_mode_update notification failed", error);
6403
+ debugLogger5.debug("current_mode_update notification failed", error);
6316
6404
  }
6317
6405
  try {
6318
6406
  await this.client.extNotification("qwen/notify/session/mode-update", {
@@ -6322,7 +6410,7 @@ ${this.pendingRecoveredAgentsNotice}
6322
6410
  legacyFrameSent
6323
6411
  });
6324
6412
  } catch (error) {
6325
- debugLogger6.debug("mode-update extNotification failed", error);
6413
+ debugLogger5.debug("mode-update extNotification failed", error);
6326
6414
  }
6327
6415
  }
6328
6416
  /**
@@ -6336,6 +6424,10 @@ ${this.pendingRecoveredAgentsNotice}
6336
6424
  * on. Response-part ordering matches the original `functionCalls` order.
6337
6425
  */
6338
6426
  async runToolCalls(abortSignal, promptId, functionCalls, toolLoopState, onFullTurnModel) {
6427
+ promptIdContext.enterWith(promptId);
6428
+ todoWorkChainContext.enterWith(
6429
+ this.config.getActiveTodoWorkChainOwner(promptId)
6430
+ );
6339
6431
  const dedupedFunctionCalls = dedupeToolCallsById(functionCalls);
6340
6432
  const generatedCallIdBase = randomUUID();
6341
6433
  const executionCallIds = new Map(
@@ -6410,7 +6502,7 @@ ${this.pendingRecoveredAgentsNotice}
6410
6502
  }
6411
6503
  await this.toolCallEmitter.emitError(callId, toolName, error);
6412
6504
  } catch (recordError) {
6413
- debugLogger6.error("Failed to record skipped tool call:", recordError);
6505
+ debugLogger5.error("Failed to record skipped tool call:", recordError);
6414
6506
  }
6415
6507
  return part;
6416
6508
  }, "recordSkippedToolCall");
@@ -6442,7 +6534,7 @@ ${this.pendingRecoveredAgentsNotice}
6442
6534
  );
6443
6535
  if (repeatedDuplicateCall) {
6444
6536
  const providerCallId = getProviderToolCallId(repeatedDuplicateCall) ?? repeatedDuplicateCall.id;
6445
- debugLogger6.debug(
6537
+ debugLogger5.debug(
6446
6538
  `[Session.runToolCalls] Dropping batch after repeated duplicate provider tool-call id: ${providerCallId} (tool: ${repeatedDuplicateCall.name ?? "unknown_tool"})`
6447
6539
  );
6448
6540
  return await finalizeRunToolResult({
@@ -6458,7 +6550,7 @@ ${this.pendingRecoveredAgentsNotice}
6458
6550
  this.duplicateProviderToolCallResponseIds
6459
6551
  );
6460
6552
  const response = createDuplicateProviderToolCallResponse(request);
6461
- debugLogger6.debug(
6553
+ debugLogger5.debug(
6462
6554
  `[Session.runToolCalls] Suppressing duplicate provider tool-call id: ${providerCallId} (tool: ${request.name})`
6463
6555
  );
6464
6556
  batches.push({ kind: "duplicate", fc, request, response });
@@ -6907,10 +6999,10 @@ ${this.pendingRecoveredAgentsNotice}
6907
6999
  responseParts: errorParts,
6908
7000
  metadata: {
6909
7001
  callId,
6910
- status: "error",
7002
+ status: opts?.status ?? "error",
6911
7003
  resultDisplay: void 0,
6912
7004
  error,
6913
- errorType: void 0
7005
+ errorType: opts?.errorType
6914
7006
  }
6915
7007
  });
6916
7008
  const loopDetected = opts?.recordInvalidToolParams === true && !activeToolAbortSignal.aborted && !opts?.stopAfterPermissionCancel && recordDaemonInvalidToolParams(
@@ -7012,7 +7104,8 @@ ${this.pendingRecoveredAgentsNotice}
7012
7104
  nestedPermissionCancelled = true;
7013
7105
  agentToolAbortController?.abort(USER_CANCEL_ABORT_REASON);
7014
7106
  onStopAfterPermissionCancel?.();
7015
- }
7107
+ },
7108
+ (params, signal) => this.#requestPermissionQueued(params, signal)
7016
7109
  );
7017
7110
  subAgentCleanupFunctions = subSubAgentTracker.setup(
7018
7111
  taskEventEmitter,
@@ -7090,7 +7183,7 @@ ${this.pendingRecoveredAgentsNotice}
7090
7183
  forceAutoReviewForAllow
7091
7184
  );
7092
7185
  if (finalPermission === "allow" && forceAutoReviewForAllow) {
7093
- debugLogger6.info(
7186
+ debugLogger5.info(
7094
7187
  `Auto mode: L4 allow overridden by protected-write guard for ${policyToolName}`
7095
7188
  );
7096
7189
  }
@@ -7134,7 +7227,7 @@ ${this.pendingRecoveredAgentsNotice}
7134
7227
  autoModeAllowed = true;
7135
7228
  break;
7136
7229
  case "blocked":
7137
- debugLogger6.warn(
7230
+ debugLogger5.warn(
7138
7231
  `Auto mode blocked (${outcome.reason}): tool=${policyToolName}, ` + formatDenialStateLog(denialState)
7139
7232
  );
7140
7233
  return earlyErrorResponse(
@@ -7145,7 +7238,7 @@ ${this.pendingRecoveredAgentsNotice}
7145
7238
  wasAutoModeManualFallback = isDenialFallbackReason(outcome.reason) || outcome.reason === "classifier_unavailable";
7146
7239
  autoModeFallbackMessage = outcome.message;
7147
7240
  if (wasAutoModeManualFallback) {
7148
- debugLogger6.warn(
7241
+ debugLogger5.warn(
7149
7242
  `Auto mode fallback to manual approval (${outcome.reason}): ` + formatDenialStateLog(denialState)
7150
7243
  );
7151
7244
  }
@@ -7163,12 +7256,12 @@ ${this.pendingRecoveredAgentsNotice}
7163
7256
  const before = this.config.getAutoModeDenialState();
7164
7257
  const after = recordFallbackApprove(before);
7165
7258
  if (after === before) {
7166
- debugLogger6.warn(
7259
+ debugLogger5.warn(
7167
7260
  `Auto mode denial counters already clear after fallback approval: ` + formatDenialStateLog(before)
7168
7261
  );
7169
7262
  return;
7170
7263
  }
7171
- debugLogger6.warn(
7264
+ debugLogger5.warn(
7172
7265
  `Auto mode denial counters reset after fallback approval: ${formatDenialStateLog(before)} -> ${formatDenialStateLog(after)}`
7173
7266
  );
7174
7267
  this.config.setAutoModeDenialState(after);
@@ -7365,8 +7458,7 @@ ${this.pendingRecoveredAgentsNotice}
7365
7458
  let output;
7366
7459
  let outcome;
7367
7460
  try {
7368
- output = await requestPermissionWithAbort(
7369
- this.client,
7461
+ output = await this.#requestPermissionQueued(
7370
7462
  params,
7371
7463
  activeToolAbortSignal
7372
7464
  );
@@ -7375,7 +7467,7 @@ ${this.pendingRecoveredAgentsNotice}
7375
7467
  offeredPermissionOptions
7376
7468
  );
7377
7469
  } catch (error) {
7378
- debugLogger6.error(
7470
+ debugLogger5.error(
7379
7471
  `Permission request failed for tool ${toolName}:`,
7380
7472
  error
7381
7473
  );
@@ -7384,7 +7476,7 @@ ${this.pendingRecoveredAgentsNotice}
7384
7476
  "cancel" /* Cancel */
7385
7477
  );
7386
7478
  } catch (confirmError) {
7387
- debugLogger6.error(
7479
+ debugLogger5.error(
7388
7480
  `Failed to cancel tool ${toolName} after permission request failure:`,
7389
7481
  confirmError
7390
7482
  );
@@ -7431,7 +7523,7 @@ ${this.pendingRecoveredAgentsNotice}
7431
7523
  if (outcome !== "cancel" /* Cancel */) {
7432
7524
  throw error;
7433
7525
  }
7434
- debugLogger6.error(
7526
+ debugLogger5.error(
7435
7527
  `Failed to confirm cancellation for tool ${toolName}:`,
7436
7528
  error
7437
7529
  );
@@ -7508,11 +7600,37 @@ ${this.pendingRecoveredAgentsNotice}
7508
7600
  return earlyErrorResponse(new Error(blockReason), toolName);
7509
7601
  }
7510
7602
  if (preHookResult.additionalContext) {
7511
- debugLogger6.debug(
7603
+ debugLogger5.debug(
7512
7604
  `PreToolUse hook additional context for ${toolName}: ${preHookResult.additionalContext}`
7513
7605
  );
7514
7606
  }
7515
7607
  }
7608
+ const toolInvocationGuard = this.config.getToolInvocationGuard?.();
7609
+ if (toolInvocationGuard) {
7610
+ const guardDecision = await evaluateToolInvocationGuard(
7611
+ toolInvocationGuard,
7612
+ {
7613
+ callId,
7614
+ toolName: policyToolName,
7615
+ args: invocation.params,
7616
+ signal: activeToolAbortSignal
7617
+ }
7618
+ );
7619
+ if (activeToolAbortSignal.aborted) {
7620
+ return earlyErrorResponse(
7621
+ new Error("Tool invocation was cancelled"),
7622
+ toolName,
7623
+ { status: "cancelled" }
7624
+ );
7625
+ }
7626
+ if (!guardDecision.allowed) {
7627
+ return earlyErrorResponse(
7628
+ new Error(guardDecision.reason),
7629
+ toolName,
7630
+ { errorType: "execution_denied" /* EXECUTION_DENIED */ }
7631
+ );
7632
+ }
7633
+ }
7516
7634
  const continuedAgentId = toolName === ToolNames.SEND_MESSAGE && typeof args["task_id"] === "string" && args["task_id"].length > 0 ? args["task_id"] : void 0;
7517
7635
  const provisionalRelatedAgent = continuedAgentId !== void 0 && !this.relatedAgentIds.has(continuedAgentId);
7518
7636
  if (provisionalRelatedAgent) {
@@ -7559,7 +7677,7 @@ ${this.pendingRecoveredAgentsNotice}
7559
7677
  status: "in_progress",
7560
7678
  _meta: { toolName, shellProgress: chunk }
7561
7679
  }).catch((err) => {
7562
- debugLogger6.debug(
7680
+ debugLogger5.debug(
7563
7681
  `[Session.runTool] heartbeat update failed for ${callId}: ${err}`
7564
7682
  );
7565
7683
  });
@@ -7585,7 +7703,7 @@ ${this.pendingRecoveredAgentsNotice}
7585
7703
  invocation.params
7586
7704
  );
7587
7705
  } catch {
7588
- debugLogger6.debug(
7706
+ debugLogger5.debug(
7589
7707
  "[Session.runTool] Failed to record tool arguments telemetry"
7590
7708
  );
7591
7709
  }
@@ -7660,7 +7778,7 @@ ${this.pendingRecoveredAgentsNotice}
7660
7778
  );
7661
7779
  if (postHookResult.shouldStop) {
7662
7780
  const stopMessage = postHookResult.stopReason || "Execution stopped by PostToolUse hook";
7663
- debugLogger6.info(
7781
+ debugLogger5.info(
7664
7782
  `PostToolUse hook requested stop for ${toolName}: ${stopMessage}`
7665
7783
  );
7666
7784
  this.todoStopGuard.suspend();
@@ -7690,7 +7808,7 @@ ${this.pendingRecoveredAgentsNotice}
7690
7808
  callId
7691
7809
  );
7692
7810
  if (failureHookResult.additionalContext) {
7693
- debugLogger6.debug(
7811
+ debugLogger5.debug(
7694
7812
  `PostToolUseFailure hook additional context for ${toolName}: ${failureHookResult.additionalContext}`
7695
7813
  );
7696
7814
  }
@@ -7770,7 +7888,7 @@ ${this.pendingRecoveredAgentsNotice}
7770
7888
  try {
7771
7889
  addToolCallResultAttributes(this.config, toolSpan, result);
7772
7890
  } catch {
7773
- debugLogger6.debug(
7891
+ debugLogger5.debug(
7774
7892
  "[Session.runTool] Failed to record tool result telemetry"
7775
7893
  );
7776
7894
  }
@@ -7812,7 +7930,7 @@ ${this.pendingRecoveredAgentsNotice}
7812
7930
  callId
7813
7931
  );
7814
7932
  if (failureHookResult.additionalContext) {
7815
- debugLogger6.debug(
7933
+ debugLogger5.debug(
7816
7934
  `PostToolUseFailure hook additional context for ${toolName}: ${failureHookResult.additionalContext}`
7817
7935
  );
7818
7936
  }
@@ -7962,7 +8080,7 @@ ${this.pendingRecoveredAgentsNotice}
7962
8080
  const embeddedContext = [];
7963
8081
  const extensionMentions = /* @__PURE__ */ new Map();
7964
8082
  const mcpServerMentions = /* @__PURE__ */ new Map();
7965
- const textPathSpecsToRead = /* @__PURE__ */ new Set();
8083
+ const textPathSpecsToRead = /* @__PURE__ */ new Map();
7966
8084
  const preserveUnsupportedImageForBridge = shouldRunVisionBridge(
7967
8085
  this.config
7968
8086
  );
@@ -7972,13 +8090,16 @@ ${this.pendingRecoveredAgentsNotice}
7972
8090
  collectExtensionMentionRefs(part.text, extensionMentions);
7973
8091
  collectMcpServerMentionRefs(part.text, mcpServerMentions);
7974
8092
  for (const pathSpec of extractAtPathCommands(part.text)) {
7975
- const resolved = path3.resolve(
8093
+ if (!path2.isAbsolute(pathSpec)) continue;
8094
+ const resolved = path2.resolve(
7976
8095
  this.config.getProjectRoot(),
7977
8096
  pathSpec
7978
8097
  );
7979
- const filteringOptions = this.config.getFileFilteringOptions();
7980
- if (path3.isAbsolute(pathSpec) && getSpecificMimeType(resolved)?.startsWith("image/") && isExistingFile(resolved) && this.config.getWorkspaceContext().isPathWithinWorkspace(pathSpec) && !this.config.getFileService().shouldIgnoreFile(pathSpec, filteringOptions)) {
7981
- textPathSpecsToRead.add(pathSpec);
8098
+ const canonicalPath = resolveExistingFile(resolved);
8099
+ if (!canonicalPath) continue;
8100
+ const filteringOptions2 = this.config.getFileFilteringOptions();
8101
+ if (getSpecificMimeType(canonicalPath)?.startsWith("image/") && this.config.getWorkspaceContext().isPathWithinWorkspace(canonicalPath) && !this.config.getFileService().shouldIgnoreFile(pathSpec, filteringOptions2) && !this.config.getFileService().shouldIgnoreFile(canonicalPath, filteringOptions2)) {
8102
+ textPathSpecsToRead.set(canonicalPath, pathSpec);
7982
8103
  }
7983
8104
  }
7984
8105
  return { text: part.text };
@@ -8028,34 +8149,62 @@ ${this.pendingRecoveredAgentsNotice}
8028
8149
  }
8029
8150
  });
8030
8151
  const atPathCommandParts = parts.filter((part) => "fileData" in part);
8031
- const pathSpecsToRead = [
8032
- .../* @__PURE__ */ new Set([
8033
- ...textPathSpecsToRead,
8034
- ...atPathCommandParts.map((part) => part.fileData.fileUri)
8035
- ])
8036
- ];
8037
8152
  const extensionParts = await this.#resolveExtensionMentionParts(
8038
8153
  extensionMentions,
8039
8154
  abortSignal
8040
8155
  );
8041
8156
  const mcpServerParts = this.#resolveMcpServerMentionParts(mcpServerMentions);
8157
+ const revalidatedTextPaths = [];
8158
+ const validatedPathIdentities = /* @__PURE__ */ new Map();
8159
+ const candidatePathsToRead = [
8160
+ ...textPathSpecsToRead.entries(),
8161
+ ...atPathCommandParts.flatMap((part) => {
8162
+ const fileUri = part.fileData.fileUri;
8163
+ const resolved = path2.resolve(this.config.getTargetDir(), fileUri);
8164
+ const canonicalPath = resolveExistingFile(resolved);
8165
+ return canonicalPath ? [[canonicalPath, fileUri]] : [];
8166
+ })
8167
+ ];
8168
+ const filteringOptions = candidatePathsToRead.length > 0 ? this.config.getFileFilteringOptions() : void 0;
8169
+ const displayPaths = /* @__PURE__ */ new Map();
8170
+ const acceptedFileUris = /* @__PURE__ */ new Set();
8171
+ for (const [textPath, displayPath] of candidatePathsToRead) {
8172
+ try {
8173
+ if (resolveExistingFile(textPath) !== textPath || !this.config.getWorkspaceContext().isPathWithinWorkspace(textPath) || textPathSpecsToRead.has(textPath) && !getSpecificMimeType(textPath)?.startsWith("image/") || this.config.getFileService().shouldIgnoreFile(displayPath, filteringOptions) || this.config.getFileService().shouldIgnoreFile(textPath, filteringOptions)) {
8174
+ continue;
8175
+ }
8176
+ const stats = statSync(textPath);
8177
+ revalidatedTextPaths.push(textPath);
8178
+ displayPaths.set(textPath, displayPath);
8179
+ acceptedFileUris.add(displayPath);
8180
+ validatedPathIdentities.set(textPath, {
8181
+ dev: stats.dev,
8182
+ ino: stats.ino
8183
+ });
8184
+ } catch {
8185
+ }
8186
+ }
8187
+ const pathSpecsToRead = [...new Set(revalidatedTextPaths)];
8188
+ const partsToSend = parts.filter(
8189
+ (part) => !("fileData" in part) || acceptedFileUris.has(part.fileData.fileUri)
8190
+ );
8042
8191
  if (pathSpecsToRead.length === 0 && embeddedContext.length === 0 && extensionParts.length === 0 && mcpServerParts.length === 0) {
8043
8192
  return this.#applyBridgeConversionsIfNeeded(
8044
- parts,
8193
+ partsToSend,
8045
8194
  abortSignal,
8046
8195
  options.onFullTurnModel
8047
8196
  );
8048
8197
  }
8049
8198
  if (pathSpecsToRead.length === 0 && embeddedContext.length === 0) {
8050
8199
  return this.#applyBridgeConversionsIfNeeded(
8051
- [...parts, ...extensionParts, ...mcpServerParts],
8200
+ [...partsToSend, ...extensionParts, ...mcpServerParts],
8052
8201
  abortSignal,
8053
8202
  options.onFullTurnModel
8054
8203
  );
8055
8204
  }
8056
8205
  let initialQueryText = "";
8057
- for (let i = 0; i < parts.length; i++) {
8058
- const chunk = parts[i];
8206
+ for (let i = 0; i < partsToSend.length; i++) {
8207
+ const chunk = partsToSend[i];
8059
8208
  if ("text" in chunk) {
8060
8209
  initialQueryText += chunk.text;
8061
8210
  } else if ("fileData" in chunk) {
@@ -8071,7 +8220,9 @@ ${this.pendingRecoveredAgentsNotice}
8071
8220
  const readResult = await readManyFiles(this.config, {
8072
8221
  paths: pathSpecsToRead,
8073
8222
  signal: abortSignal,
8074
- ...preserveUnsupportedImageForBridge ? { preserveUnsupportedImageForBridge } : {}
8223
+ ...preserveUnsupportedImageForBridge ? { preserveUnsupportedImageForBridge } : {},
8224
+ ...validatedPathIdentities.size > 0 ? { validatedPathIdentities } : {},
8225
+ ...displayPaths.size > 0 ? { displayPaths } : {}
8075
8226
  });
8076
8227
  const contentParts = Array.isArray(readResult.contentParts) ? readResult.contentParts : [readResult.contentParts];
8077
8228
  for (const part of contentParts) {
@@ -8135,7 +8286,7 @@ ${contextPart.text}`
8135
8286
  formatFullTurnVisionNotice(fullTurnModel)
8136
8287
  );
8137
8288
  } catch (error) {
8138
- debugLogger6.debug(
8289
+ debugLogger5.debug(
8139
8290
  `full-turn vision: failed to emit notice; continuing error=${error instanceof Error ? error.message : String(error)}`
8140
8291
  );
8141
8292
  }
@@ -8144,19 +8295,19 @@ ${contextPart.text}`
8144
8295
  }
8145
8296
  let bridgeResult;
8146
8297
  try {
8147
- debugLogger6.debug("vision bridge: gate matched, running conversion");
8298
+ debugLogger5.debug("vision bridge: gate matched, running conversion");
8148
8299
  bridgeResult = await runVisionBridge({
8149
8300
  config: this.config,
8150
8301
  parts,
8151
8302
  signal: abortSignal
8152
8303
  });
8153
8304
  } catch (error) {
8154
- debugLogger6.debug(
8305
+ debugLogger5.debug(
8155
8306
  `vision bridge: failed before replacement; falling back to text-only parts error=${String(error instanceof Error ? error.message : error)}`
8156
8307
  );
8157
8308
  return splitImageParts(parts).nonImageParts;
8158
8309
  }
8159
- debugLogger6.debug(
8310
+ debugLogger5.debug(
8160
8311
  `vision bridge: status=${bridgeResult.status} applied=${bridgeResult.applied} model=${bridgeResult.modelId ?? "(none)"}${bridgeResult.error ? ` error=${bridgeResult.error}` : ""}`
8161
8312
  );
8162
8313
  if (bridgeResult.status !== "skipped" || bridgeResult.egressOccurred) {
@@ -8165,13 +8316,13 @@ ${contextPart.text}`
8165
8316
  formatVisionBridgeNotice(bridgeResult)
8166
8317
  );
8167
8318
  } catch (error) {
8168
- debugLogger6.debug(
8319
+ debugLogger5.debug(
8169
8320
  `vision bridge: failed to emit notice; continuing with bridge result error=${String(error instanceof Error ? error.message : error)}`
8170
8321
  );
8171
8322
  }
8172
8323
  }
8173
8324
  if (abortSignal.aborted) {
8174
- debugLogger6.debug("vision bridge: turn aborted after bridge returned");
8325
+ debugLogger5.debug("vision bridge: turn aborted after bridge returned");
8175
8326
  return splitImageParts(parts).nonImageParts;
8176
8327
  }
8177
8328
  if (bridgeResult.applied && bridgeResult.parts != null) {
@@ -8185,7 +8336,7 @@ ${contextPart.text}`
8185
8336
  }
8186
8337
  const voiceModel = readVoiceModel(this.settings);
8187
8338
  if (!voiceModel) {
8188
- debugLogger6.debug(
8339
+ debugLogger5.debug(
8189
8340
  "voice bridge: no voice model configured; replacing audio with note"
8190
8341
  );
8191
8342
  return parts.map(
@@ -8204,14 +8355,14 @@ ${contextPart.text}`
8204
8355
  }
8205
8356
  const inlineData = part.inlineData;
8206
8357
  if (approxBase64Bytes(inlineData.data) > MAX_AUDIO_BYTES) {
8207
- debugLogger6.debug(
8358
+ debugLogger5.debug(
8208
8359
  "voice bridge: audio too large; replacing audio with note"
8209
8360
  );
8210
8361
  converted.push({ text: buildVoiceUnavailableBlock("audio too large") });
8211
8362
  continue;
8212
8363
  }
8213
8364
  try {
8214
- debugLogger6.debug(`voice bridge: transcribing audio via ${voiceModel}`);
8365
+ debugLogger5.debug(`voice bridge: transcribing audio via ${voiceModel}`);
8215
8366
  const transcript = (await transcribeVoiceAudio(
8216
8367
  {
8217
8368
  data: new Uint8Array(Buffer2.from(inlineData.data, "base64")),
@@ -8228,7 +8379,7 @@ ${contextPart.text}`
8228
8379
  }
8229
8380
  )).trim();
8230
8381
  if (abortSignal.aborted) {
8231
- debugLogger6.debug("voice bridge: turn aborted after transcription");
8382
+ debugLogger5.debug("voice bridge: turn aborted after transcription");
8232
8383
  return converted;
8233
8384
  }
8234
8385
  if (transcript.length > 0) {
@@ -8241,10 +8392,10 @@ ${contextPart.text}`
8241
8392
  });
8242
8393
  } catch (error) {
8243
8394
  if (abortSignal.aborted) {
8244
- debugLogger6.debug("voice bridge: transcription cancelled");
8395
+ debugLogger5.debug("voice bridge: transcription cancelled");
8245
8396
  return converted;
8246
8397
  }
8247
- debugLogger6.debug(
8398
+ debugLogger5.debug(
8248
8399
  `voice bridge: transcription failed; replacing audio with note error=${sanitizeVoiceErrorMessage(String(error instanceof Error ? error.message : error))}`
8249
8400
  );
8250
8401
  converted.push({
@@ -8258,7 +8409,7 @@ ${contextPart.text}`
8258
8409
  transcribedCount > 0 ? this.#formatVoiceBridgeNotice(voiceModel, transcribedCount) : this.#formatVoiceBridgeEgressNotice(voiceModel, egressCount)
8259
8410
  );
8260
8411
  } catch (error) {
8261
- debugLogger6.debug(
8412
+ debugLogger5.debug(
8262
8413
  `voice bridge: failed to emit notice; continuing with bridge result error=${String(error instanceof Error ? error.message : error)}`
8263
8414
  );
8264
8415
  }
@@ -8319,7 +8470,7 @@ ${contextPart.text}`
8319
8470
  }
8320
8471
  debug(msg) {
8321
8472
  if (this.config.getDebugMode()) {
8322
- debugLogger6.warn(msg);
8473
+ debugLogger5.warn(msg);
8323
8474
  }
8324
8475
  }
8325
8476
  async emitHookArtifactsNotification(args) {
@@ -8359,7 +8510,7 @@ ${contextPart.text}`
8359
8510
  }
8360
8511
  );
8361
8512
  }).catch((err) => {
8362
- debugLogger6.debug(
8513
+ debugLogger5.debug(
8363
8514
  `ACP terminalSequence notification dropped (session=${this.sessionId}): ${err instanceof Error ? err.message : String(err)}`
8364
8515
  );
8365
8516
  });
@@ -8477,7 +8628,7 @@ function runWithAcpRuntimeOutputDir(settings, cwd, fn) {
8477
8628
  __name(runWithAcpRuntimeOutputDir, "runWithAcpRuntimeOutputDir");
8478
8629
 
8479
8630
  // packages/cli/src/acp-integration/acpAgent.ts
8480
- var debugLogger7 = createDebugLogger("ACP_AGENT");
8631
+ var debugLogger6 = createDebugLogger("ACP_AGENT");
8481
8632
  var QWEN_ACP_LOCAL_READ_ROOTS_ENV = "QWEN_ACP_LOCAL_READ_ROOTS";
8482
8633
  var POSIX_TMP_LOCAL_READ_ROOT = "/tmp";
8483
8634
  var BTW_CHILD_TIMEOUT_MS = 55e3;
@@ -8612,10 +8763,10 @@ async function beginSessionCloseAfterCurrentGate(session, timeoutMs) {
8612
8763
  }
8613
8764
  }
8614
8765
  __name(beginSessionCloseAfterCurrentGate, "beginSessionCloseAfterCurrentGate");
8615
- var logWorkspaceMemoryExtractionError = createWorkspaceMemoryExtractionErrorLogger(debugLogger7);
8766
+ var logWorkspaceMemoryExtractionError = createWorkspaceMemoryExtractionErrorLogger(debugLogger6);
8616
8767
  function parseAcpLocalReadRootsEnv(raw = process.env[QWEN_ACP_LOCAL_READ_ROOTS_ENV]) {
8617
8768
  if (!raw) return [];
8618
- return raw.split(path4.delimiter).map((entry) => entry.trim()).filter((entry) => entry.length > 0 && path4.isAbsolute(entry));
8769
+ return raw.split(path3.delimiter).map((entry) => entry.trim()).filter((entry) => entry.length > 0 && path3.isAbsolute(entry));
8619
8770
  }
8620
8771
  __name(parseAcpLocalReadRootsEnv, "parseAcpLocalReadRootsEnv");
8621
8772
  function defaultAcpOnlyLocalReadRoots() {
@@ -8628,8 +8779,8 @@ function buildAcpLocalReadRoots(config) {
8628
8779
  // including auto-memory roots. The ACP-only additions below expand only
8629
8780
  // local read fallback, not read_file's default permission.
8630
8781
  config.storage.getProjectTempDir(),
8631
- path4.join(config.storage.getProjectDir(), "subagents"),
8632
- path4.join(config.getSessionRuntimeBaseDir(), "tmp"),
8782
+ path3.join(config.storage.getProjectDir(), "subagents"),
8783
+ path3.join(config.getSessionRuntimeBaseDir(), "tmp"),
8633
8784
  getAutoMemoryRoot(config.getTargetDir()),
8634
8785
  getUserAutoMemoryRoot(),
8635
8786
  ...config.storage.getUserSkillsDirs(),
@@ -8688,6 +8839,38 @@ function isBulkLoadReplayRequest(params) {
8688
8839
  return meta?.[LOAD_REPLAY_MODE_META_KEY] === LOAD_REPLAY_BULK_MODE;
8689
8840
  }
8690
8841
  __name(isBulkLoadReplayRequest, "isBulkLoadReplayRequest");
8842
+ function shouldHideInheritedHistory(params) {
8843
+ const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8844
+ return meta?.[LOAD_REPLAY_HIDE_INHERITED_META_KEY] === true;
8845
+ }
8846
+ __name(shouldHideInheritedHistory, "shouldHideInheritedHistory");
8847
+ function selectVisibleHistoryRecords(records, hideInheritedHistory) {
8848
+ const sourceBoundary = records.findIndex(
8849
+ (record) => record.type === "system" && record.subtype === "session_source" && isObjectRecord(record.systemPayload) && record.systemPayload["sourceType"] === "side_task"
8850
+ );
8851
+ if (sourceBoundary >= 0) {
8852
+ return records.slice(sourceBoundary).filter((record) => record.forkedFrom === void 0);
8853
+ }
8854
+ return hideInheritedHistory ? records.filter((record) => record.forkedFrom === void 0) : records;
8855
+ }
8856
+ __name(selectVisibleHistoryRecords, "selectVisibleHistoryRecords");
8857
+ function getSessionSource(params) {
8858
+ const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8859
+ const value = meta?.[SESSION_SOURCE_META_KEY];
8860
+ if (!isObjectRecord(value) || typeof value["sourceType"] !== "string") {
8861
+ return void 0;
8862
+ }
8863
+ return {
8864
+ sourceType: value["sourceType"],
8865
+ ...typeof value["sourceId"] === "string" ? { sourceId: value["sourceId"] } : {}
8866
+ };
8867
+ }
8868
+ __name(getSessionSource, "getSessionSource");
8869
+ function shouldDeferMcpDiscovery(params) {
8870
+ const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8871
+ return meta?.[WORKTREE_MCP_DEFER_META_KEY] === true;
8872
+ }
8873
+ __name(shouldDeferMcpDiscovery, "shouldDeferMcpDiscovery");
8691
8874
  function getLoadReplayPageSize(params) {
8692
8875
  const meta = isObjectRecord(params._meta) ? params._meta : void 0;
8693
8876
  const value = meta?.[LOAD_REPLAY_PAGE_SIZE_META_KEY];
@@ -8863,7 +9046,7 @@ function readRequiredString(value, fieldName) {
8863
9046
  }
8864
9047
  __name(readRequiredString, "readRequiredString");
8865
9048
  function validateSkillSlug(slug) {
8866
- if (!slug || slug === "." || slug === ".." || slug.includes("/") || slug.includes(path4.sep) || !/^[a-zA-Z0-9._-]+$/.test(slug)) {
9049
+ if (!slug || slug === "." || slug === ".." || slug.includes("/") || slug.includes(path3.sep) || !/^[a-zA-Z0-9._-]+$/.test(slug)) {
8867
9050
  throw RequestError.invalidParams(void 0, "Invalid skill.slug");
8868
9051
  }
8869
9052
  }
@@ -9332,7 +9515,7 @@ async function downloadGitHubSkillDirectoryFromApi(githubUrl, directoryPath, rel
9332
9515
  const name = readRequiredString(record["name"], "github.name");
9333
9516
  const itemPath = readRequiredString(record["path"], "github.path");
9334
9517
  const type = readRequiredString(record["type"], "github.type");
9335
- const relativePath = relativeRoot ? path4.posix.join(relativeRoot, name) : name;
9518
+ const relativePath = relativeRoot ? path3.posix.join(relativeRoot, name) : name;
9336
9519
  if (type === "dir") {
9337
9520
  files.push(
9338
9521
  ...await downloadGitHubSkillDirectoryFromApi(
@@ -9379,7 +9562,7 @@ async function downloadGitHubSkillDirectory(githubUrl, directoryPath) {
9379
9562
  githubUrl,
9380
9563
  directoryPath
9381
9564
  ).catch((error) => {
9382
- debugLogger7.warn(
9565
+ debugLogger6.warn(
9383
9566
  "GitHub API directory listing failed, falling back to archive download:",
9384
9567
  error
9385
9568
  );
@@ -9392,10 +9575,10 @@ __name(downloadGitHubSkillDirectory, "downloadGitHubSkillDirectory");
9392
9575
  async function downloadSkill(sourceUrl) {
9393
9576
  assertAllowedSkillSourceUrl(sourceUrl);
9394
9577
  const githubUrl = parseGitHubBlobSkillUrl(sourceUrl);
9395
- if (!githubUrl || path4.posix.basename(githubUrl.filePath) !== "SKILL.md") {
9578
+ if (!githubUrl || path3.posix.basename(githubUrl.filePath) !== "SKILL.md") {
9396
9579
  return downloadSingleSkillFile(sourceUrl);
9397
9580
  }
9398
- const skillDirectory = path4.posix.dirname(githubUrl.filePath);
9581
+ const skillDirectory = path3.posix.dirname(githubUrl.filePath);
9399
9582
  const files = await downloadGitHubSkillDirectory(githubUrl, skillDirectory);
9400
9583
  const skillFile = files.find((file) => file.relativePath === "SKILL.md");
9401
9584
  if (!skillFile) {
@@ -9411,9 +9594,9 @@ async function downloadSkill(sourceUrl) {
9411
9594
  }
9412
9595
  __name(downloadSkill, "downloadSkill");
9413
9596
  function resolveSkillInstallPath(skillDir, relativePath) {
9414
- const root = path4.resolve(skillDir);
9415
- const target = path4.resolve(skillDir, relativePath);
9416
- if (target !== root && !target.startsWith(root + path4.sep)) {
9597
+ const root = path3.resolve(skillDir);
9598
+ const target = path3.resolve(skillDir, relativePath);
9599
+ if (target !== root && !target.startsWith(root + path3.sep)) {
9417
9600
  throw RequestError.invalidParams(
9418
9601
  void 0,
9419
9602
  `Invalid skill file path: ${relativePath}`
@@ -9423,9 +9606,9 @@ function resolveSkillInstallPath(skillDir, relativePath) {
9423
9606
  }
9424
9607
  __name(resolveSkillInstallPath, "resolveSkillInstallPath");
9425
9608
  function resolveManagedSkillDir(skillsBaseDir, slug) {
9426
- const root = path4.resolve(skillsBaseDir);
9427
- const skillDir = path4.resolve(skillsBaseDir, slug);
9428
- if (!skillDir.startsWith(root + path4.sep)) {
9609
+ const root = path3.resolve(skillsBaseDir);
9610
+ const skillDir = path3.resolve(skillsBaseDir, slug);
9611
+ if (!skillDir.startsWith(root + path3.sep)) {
9429
9612
  throw RequestError.invalidParams(void 0, "Invalid skill.slug");
9430
9613
  }
9431
9614
  return skillDir;
@@ -9945,7 +10128,7 @@ function readMcpServers(source, scope) {
9945
10128
  const server = toMcpServerConfig(value);
9946
10129
  return server ? { name, scope, server: redactMcpServerSecrets(server) } : void 0;
9947
10130
  } catch (error) {
9948
- debugLogger7.warn(
10131
+ debugLogger6.warn(
9949
10132
  `Skipping malformed MCP server config [${scope}:${name}]:`,
9950
10133
  error
9951
10134
  );
@@ -10041,7 +10224,7 @@ function readHooks(source, scope, extensionName) {
10041
10224
  extensionName
10042
10225
  });
10043
10226
  } catch (error) {
10044
- debugLogger7.warn(
10227
+ debugLogger6.warn(
10045
10228
  `Skipping malformed hook entry [${scope}:${event}:${index}]:`,
10046
10229
  error
10047
10230
  );
@@ -10066,14 +10249,14 @@ function readScopeSettings(settings, scope) {
10066
10249
  __name(readScopeSettings, "readScopeSettings");
10067
10250
  async function resolvePreferredMemoryFile(dir, fallbackFilename) {
10068
10251
  for (const filename of getAllGeminiMdFilenames()) {
10069
- const filePath = path4.join(dir, filename);
10252
+ const filePath = path3.join(dir, filename);
10070
10253
  try {
10071
- await fs2.access(filePath);
10254
+ await fs.access(filePath);
10072
10255
  return filePath;
10073
10256
  } catch {
10074
10257
  }
10075
10258
  }
10076
- return path4.join(dir, fallbackFilename);
10259
+ return path3.join(dir, fallbackFilename);
10077
10260
  }
10078
10261
  __name(resolvePreferredMemoryFile, "resolvePreferredMemoryFile");
10079
10262
  async function resolveQwenMemoryPaths(params) {
@@ -10233,6 +10416,7 @@ async function runAcpAgent(config, settings, argv, options) {
10233
10416
  `);
10234
10417
  }
10235
10418
  const eventLoopMonitor = startEventLoopLagMonitor({
10419
+ suspendThresholdMs: ACP_EVENT_LOOP_STALL_RESTART_MS,
10236
10420
  onNewMaxStall: /* @__PURE__ */ __name((maxMs) => {
10237
10421
  console.error(`[perf] acp agent event loop stall: max=${maxMs}ms`);
10238
10422
  }, "onNewMaxStall")
@@ -10266,7 +10450,7 @@ async function runAcpAgent(config, settings, argv, options) {
10266
10450
  void preloadContentGenerator(
10267
10451
  session.getConfig().getContentGenerator()
10268
10452
  ).catch((error) => {
10269
- debugLogger7.debug(
10453
+ debugLogger6.debug(
10270
10454
  `[ACP] Session provider preload failed for ${sessionId}: ${error instanceof Error ? error.message : String(error)}`
10271
10455
  );
10272
10456
  });
@@ -10305,7 +10489,7 @@ async function runAcpAgent(config, settings, argv, options) {
10305
10489
  try {
10306
10490
  await agentInstance.shutdownMcpPool(8e3);
10307
10491
  } catch (err) {
10308
- debugLogger7.error(`[ACP] MCP pool drain (${label}) error:`, err);
10492
+ debugLogger6.error(`[ACP] MCP pool drain (${label}) error:`, err);
10309
10493
  if (strict) throw err;
10310
10494
  }
10311
10495
  }, "drainPoolBeforeExit");
@@ -10338,7 +10522,7 @@ async function runAcpAgent(config, settings, argv, options) {
10338
10522
  await hookSystem.fireSessionEndEvent(reason);
10339
10523
  } catch (err) {
10340
10524
  if (managedConfigs) failures.push(err);
10341
- debugLogger7.warn(
10525
+ debugLogger6.warn(
10342
10526
  `SessionEnd hook failed: ${err instanceof Error ? err.message : String(err)}`
10343
10527
  );
10344
10528
  }
@@ -10362,13 +10546,13 @@ async function runAcpAgent(config, settings, argv, options) {
10362
10546
  await terminal.writerShutdown;
10363
10547
  } catch (error) {
10364
10548
  failures.push(error);
10365
- debugLogger7.error("[ACP] Managed writer shutdown error:", error);
10549
+ debugLogger6.error("[ACP] Managed writer shutdown error:", error);
10366
10550
  const retainedLockPaths = terminal.configs.flatMap((config2) => {
10367
10551
  if (typeof config2.getSessionRuntimeBaseDir !== "function" || typeof config2.getSessionId !== "function") {
10368
10552
  return [];
10369
10553
  }
10370
10554
  return [
10371
- path4.join(
10555
+ path3.join(
10372
10556
  config2.getSessionRuntimeBaseDir(),
10373
10557
  "tmp",
10374
10558
  "session-writer-locks",
@@ -10389,7 +10573,7 @@ async function runAcpAgent(config, settings, argv, options) {
10389
10573
  await agent.finishManagedShutdown(terminal.configs);
10390
10574
  } catch (error) {
10391
10575
  failures.push(error);
10392
- debugLogger7.error("[ACP] Managed resource shutdown error:", error);
10576
+ debugLogger6.error("[ACP] Managed resource shutdown error:", error);
10393
10577
  }
10394
10578
  try {
10395
10579
  await drainPoolBeforeExit(label, true);
@@ -10400,7 +10584,7 @@ async function runAcpAgent(config, settings, argv, options) {
10400
10584
  await runExitCleanup();
10401
10585
  } catch (error) {
10402
10586
  failures.push(error);
10403
- debugLogger7.error("[ACP] Cleanup error:", error);
10587
+ debugLogger6.error("[ACP] Cleanup error:", error);
10404
10588
  }
10405
10589
  if (failures.length > 0) {
10406
10590
  throw new AggregateError(failures, "Managed ACP shutdown failed");
@@ -10411,14 +10595,14 @@ async function runAcpAgent(config, settings, argv, options) {
10411
10595
  const shutdownHandler = /* @__PURE__ */ __name(async () => {
10412
10596
  if (shuttingDown) return;
10413
10597
  shuttingDown = true;
10414
- debugLogger7.debug("[ACP] Shutdown signal received, closing streams");
10598
+ debugLogger6.debug("[ACP] Shutdown signal received, closing streams");
10415
10599
  if (agentInstance?.isTrustedManagedParent()) {
10416
10600
  let exitCode = 0;
10417
10601
  try {
10418
10602
  await shutdownManagedAgent("other" /* Other */, "signal");
10419
10603
  } catch (err) {
10420
10604
  exitCode = 1;
10421
- debugLogger7.error("[ACP] Managed shutdown error:", err);
10605
+ debugLogger6.error("[ACP] Managed shutdown error:", err);
10422
10606
  } finally {
10423
10607
  eventLoopMonitor.dispose();
10424
10608
  }
@@ -10443,12 +10627,12 @@ async function runAcpAgent(config, settings, argv, options) {
10443
10627
  }
10444
10628
  await drainPoolBeforeExit("signal");
10445
10629
  } catch (err) {
10446
- debugLogger7.error("[ACP] Shutdown error:", err);
10630
+ debugLogger6.error("[ACP] Shutdown error:", err);
10447
10631
  } finally {
10448
10632
  eventLoopMonitor.dispose();
10449
10633
  }
10450
10634
  runExitCleanup().catch((err) => {
10451
- debugLogger7.error("[ACP] Cleanup error:", err);
10635
+ debugLogger6.error("[ACP] Cleanup error:", err);
10452
10636
  }).finally(() => {
10453
10637
  process.exit(0);
10454
10638
  });
@@ -10629,6 +10813,7 @@ var QwenAgent = class {
10629
10813
  workspaceMcpDiscoveryConfig;
10630
10814
  workspaceMcpDiscoveryPromise;
10631
10815
  workspaceMcpDiscoveryError;
10816
+ workspaceExtensionStatusRefreshPromise;
10632
10817
  pendingMcpAuthentications = /* @__PURE__ */ new Map();
10633
10818
  mcpAuthenticationResults = /* @__PURE__ */ new Map();
10634
10819
  generationControllers = /* @__PURE__ */ new Map();
@@ -10644,7 +10829,7 @@ var QwenAgent = class {
10644
10829
  // cadence, so successive calls form a clean delta window independent of tool
10645
10830
  // activity. Init is guarded — `process.cpuUsage()` can throw in restricted
10646
10831
  // containers.
10647
- childCpuCoreCount = os3.availableParallelism?.() ?? os3.cpus().length ?? 1;
10832
+ childCpuCoreCount = os2.availableParallelism?.() ?? os2.cpus().length ?? 1;
10648
10833
  prevChildCpu = (() => {
10649
10834
  try {
10650
10835
  return process.cpuUsage();
@@ -10702,12 +10887,12 @@ var QwenAgent = class {
10702
10887
  try {
10703
10888
  session.beginCloseIfAvailable();
10704
10889
  } catch (error) {
10705
- debugLogger7.debug(
10890
+ debugLogger6.debug(
10706
10891
  `Session ${session.getId()} admission close during managed shutdown failed: ${error instanceof Error ? error.message : String(error)}`
10707
10892
  );
10708
10893
  }
10709
10894
  void session.cancelPendingPrompt().catch((error) => {
10710
- debugLogger7.debug(
10895
+ debugLogger6.debug(
10711
10896
  `Session ${session.getId()} cancel during managed shutdown failed: ${error instanceof Error ? error.message : String(error)}`
10712
10897
  );
10713
10898
  });
@@ -10720,7 +10905,7 @@ var QwenAgent = class {
10720
10905
  const writerTerminals = [];
10721
10906
  for (const config of configList) {
10722
10907
  try {
10723
- writerTerminals.push(config.closeSessionWriter());
10908
+ writerTerminals.push(config.closeSessionWriter({ handoff: true }));
10724
10909
  } catch (error) {
10725
10910
  writerTerminals.push(Promise.reject(error));
10726
10911
  }
@@ -10772,6 +10957,39 @@ var QwenAgent = class {
10772
10957
  }
10773
10958
  return this.workspaceMcpDiscoveryConfig ?? this.config;
10774
10959
  }
10960
+ refreshBootstrapExtensionStatus() {
10961
+ if (this.workspaceExtensionStatusRefreshPromise) {
10962
+ return this.workspaceExtensionStatusRefreshPromise;
10963
+ }
10964
+ const promise = (async () => {
10965
+ const errors = [];
10966
+ try {
10967
+ await this.config.getExtensionManager().refreshCache();
10968
+ } catch (error) {
10969
+ errors.push(error);
10970
+ }
10971
+ try {
10972
+ await this.config.getSkillManager()?.refreshCache();
10973
+ } catch (error) {
10974
+ errors.push(error);
10975
+ }
10976
+ if (errors.length === 1) throw errors[0];
10977
+ if (errors.length > 1) {
10978
+ throw new AggregateError(
10979
+ errors,
10980
+ "Bootstrap extension status refresh failed"
10981
+ );
10982
+ }
10983
+ })();
10984
+ this.workspaceExtensionStatusRefreshPromise = promise;
10985
+ const clear = /* @__PURE__ */ __name(() => {
10986
+ if (this.workspaceExtensionStatusRefreshPromise === promise) {
10987
+ this.workspaceExtensionStatusRefreshPromise = void 0;
10988
+ }
10989
+ }, "clear");
10990
+ void promise.then(clear, clear);
10991
+ return promise;
10992
+ }
10775
10993
  getLiveMcpConfigs(serverName) {
10776
10994
  return [
10777
10995
  .../* @__PURE__ */ new Set([
@@ -10822,7 +11040,7 @@ var QwenAgent = class {
10822
11040
  await run();
10823
11041
  }).catch((err) => {
10824
11042
  this.workspaceMcpDiscoveryError = err instanceof Error ? err.message : String(err);
10825
- debugLogger7.error(
11043
+ debugLogger6.error(
10826
11044
  `Workspace MCP ${label} failed: ${err instanceof Error ? err.message : String(err)}`
10827
11045
  );
10828
11046
  }).finally(() => {
@@ -11009,7 +11227,7 @@ var QwenAgent = class {
11009
11227
  try {
11010
11228
  const result = await this.mcpPool.drainAll({ force: true, timeoutMs });
11011
11229
  if (result.forced > 0 || result.errors.length > 0) {
11012
- debugLogger7.warn(
11230
+ debugLogger6.warn(
11013
11231
  `MCP pool drain: ${result.drained} clean, ${result.forced} timed out, ${result.errors.length} errors`
11014
11232
  );
11015
11233
  throw new Error(
@@ -11017,7 +11235,7 @@ var QwenAgent = class {
11017
11235
  );
11018
11236
  }
11019
11237
  } catch (err) {
11020
- debugLogger7.error(
11238
+ debugLogger6.error(
11021
11239
  `MCP pool drainAll failed: ${err instanceof Error ? err.message : String(err)}`
11022
11240
  );
11023
11241
  throw err;
@@ -11054,7 +11272,7 @@ var QwenAgent = class {
11054
11272
  }
11055
11273
  this.sessions.delete(sessionId);
11056
11274
  if (cleanupErrors.length > 0) {
11057
- debugLogger7.warn(
11275
+ debugLogger6.warn(
11058
11276
  `Session ${sessionId} closed after ${cleanupErrors.length} cleanup failure(s): ${cleanupErrors.map(
11059
11277
  (error) => error instanceof Error ? error.message : String(error)
11060
11278
  ).join("; ")}`
@@ -11108,21 +11326,21 @@ var QwenAgent = class {
11108
11326
  try {
11109
11327
  await cleanup();
11110
11328
  } catch (cleanupError) {
11111
- debugLogger7.warn(
11329
+ debugLogger6.warn(
11112
11330
  `Session cleanup failed while preserving the original request error: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`
11113
11331
  );
11114
11332
  }
11115
11333
  throw mapSessionWriterRequestError(error);
11116
11334
  }
11117
11335
  pendingConfigCleanupKey(runtimeBaseDir, sessionId) {
11118
- return `${path4.resolve(runtimeBaseDir)}\0${sessionId}`;
11336
+ return `${path3.resolve(runtimeBaseDir)}\0${sessionId}`;
11119
11337
  }
11120
11338
  async retryPendingConfigCleanup(runtimeBaseDir, requiredSessionId) {
11121
- const resolvedRuntimeBaseDir = path4.resolve(runtimeBaseDir);
11339
+ const resolvedRuntimeBaseDir = path3.resolve(runtimeBaseDir);
11122
11340
  const configs = /* @__PURE__ */ new Set();
11123
11341
  for (const pending of this.pendingConfigCleanup.values()) {
11124
11342
  for (const config of pending) {
11125
- if (path4.resolve(config.getSessionRuntimeBaseDir()) === resolvedRuntimeBaseDir) {
11343
+ if (path3.resolve(config.getSessionRuntimeBaseDir()) === resolvedRuntimeBaseDir) {
11126
11344
  configs.add(config);
11127
11345
  }
11128
11346
  }
@@ -11132,7 +11350,7 @@ var QwenAgent = class {
11132
11350
  await this.cleanupUnstoredConfig(config);
11133
11351
  } catch (error) {
11134
11352
  if (config.getSessionId() === requiredSessionId) throw error;
11135
- debugLogger7.warn(
11353
+ debugLogger6.warn(
11136
11354
  `Deferred Config cleanup retry failed for session ${config.getSessionId()}: ${error instanceof Error ? error.message : String(error)}`
11137
11355
  );
11138
11356
  }
@@ -11163,7 +11381,7 @@ var QwenAgent = class {
11163
11381
  try {
11164
11382
  await session.cancelPendingPrompt();
11165
11383
  } catch (err) {
11166
- debugLogger7.debug(
11384
+ debugLogger6.debug(
11167
11385
  `Session ${sessionId} cancel during close failed: ${err instanceof Error ? err.message : String(err)}`
11168
11386
  );
11169
11387
  }
@@ -11233,7 +11451,7 @@ var QwenAgent = class {
11233
11451
  return runWithAcpRuntimeOutputDir(settings, cwd, operation);
11234
11452
  }
11235
11453
  async assertLiveSessionScope(config, settings, cwd) {
11236
- if (path4.resolve(config.storage.getProjectRoot()) !== path4.resolve(cwd)) {
11454
+ if (path3.resolve(config.storage.getProjectRoot()) !== path3.resolve(cwd)) {
11237
11455
  throw RequestError.invalidParams(
11238
11456
  void 0,
11239
11457
  "The live session belongs to another workspace."
@@ -11244,7 +11462,7 @@ var QwenAgent = class {
11244
11462
  cwd,
11245
11463
  () => Storage.getRuntimeBaseDir()
11246
11464
  );
11247
- if (path4.resolve(config.getSessionRuntimeBaseDir()) !== path4.resolve(requestedRuntimeBaseDir)) {
11465
+ if (path3.resolve(config.getSessionRuntimeBaseDir()) !== path3.resolve(requestedRuntimeBaseDir)) {
11248
11466
  throw mapSessionWriterRequestError(new SessionWriterUnavailableError());
11249
11467
  }
11250
11468
  }
@@ -11267,7 +11485,7 @@ var QwenAgent = class {
11267
11485
  scope: "workspace",
11268
11486
  ...event
11269
11487
  }).catch((err) => {
11270
- debugLogger7.debug(
11488
+ debugLogger6.debug(
11271
11489
  `MCP workspace budget event delivery to session ${sid} failed (kind=${event.kind}): ${err instanceof Error ? err.message : String(err)}`
11272
11490
  );
11273
11491
  });
@@ -11302,7 +11520,7 @@ var QwenAgent = class {
11302
11520
  }
11303
11521
  this.clientCapabilities = args.clientCapabilities;
11304
11522
  const authMethods = buildAuthMethods();
11305
- const version = "0.21.1";
11523
+ const version = "0.21.2-nightly.20260801.bc382c3ff";
11306
11524
  const response = {
11307
11525
  protocolVersion: PROTOCOL_VERSION,
11308
11526
  agentInfo: {
@@ -11376,6 +11594,8 @@ var QwenAgent = class {
11376
11594
  }
11377
11595
  async newSession(params) {
11378
11596
  const { cwd, mcpServers } = params;
11597
+ const requestedSessionId = typeof params._meta?.[REQUESTED_SESSION_ID_META_KEY] === "string" ? params._meta[REQUESTED_SESSION_ID_META_KEY] : void 0;
11598
+ const sessionSource = getSessionSource(params);
11379
11599
  const parentContext = extractDaemonTraceContext(params);
11380
11600
  return await withDaemonSpan(
11381
11601
  "qwen-code.daemon.session_start",
@@ -11389,7 +11609,15 @@ var QwenAgent = class {
11389
11609
  this.settings = settings;
11390
11610
  const config = await profiler.time(
11391
11611
  "config_setup",
11392
- () => this.newSessionConfig(cwd, mcpServers, settings)
11612
+ () => this.newSessionConfig(
11613
+ cwd,
11614
+ mcpServers,
11615
+ settings,
11616
+ sessionSource,
11617
+ requestedSessionId,
11618
+ void 0,
11619
+ shouldDeferMcpDiscovery(params) ? { skipMcpDiscovery: true } : void 0
11620
+ )
11393
11621
  );
11394
11622
  let session;
11395
11623
  try {
@@ -11421,6 +11649,7 @@ var QwenAgent = class {
11421
11649
  );
11422
11650
  }
11423
11651
  async loadSession(params) {
11652
+ const sessionSource = getSessionSource(params);
11424
11653
  const settings = loadSettingsCached(params.cwd);
11425
11654
  const liveSession = this.sessions.get(params.sessionId);
11426
11655
  if (liveSession) {
@@ -11437,16 +11666,23 @@ var QwenAgent = class {
11437
11666
  ...sessionData2.artifactSnapshot ? { artifactSnapshot: sessionData2.artifactSnapshot } : {}
11438
11667
  };
11439
11668
  const records = sessionData2.conversation.messages;
11440
- if (records.length === 0) return response2;
11669
+ const visibleRecords = selectVisibleHistoryRecords(
11670
+ records,
11671
+ shouldHideInheritedHistory(params)
11672
+ );
11673
+ if (visibleRecords.length === 0) return response2;
11441
11674
  const bulkReplay2 = isBulkLoadReplayRequest(params);
11442
- const replayPage = bulkReplay2 ? selectRecentHistoryRecords(records, getLoadReplayPageSize(params)) : { records, hasMore: false };
11675
+ const replayPage = bulkReplay2 ? selectRecentHistoryRecords(
11676
+ visibleRecords,
11677
+ getLoadReplayPageSize(params)
11678
+ ) : { records: visibleRecords, hasMore: false };
11443
11679
  const replay = await collectHistoryReplayUpdates({
11444
11680
  sessionId: params.sessionId,
11445
11681
  config: config2,
11446
11682
  records: replayPage.records,
11447
11683
  gaps: sessionData2.historyGaps,
11448
11684
  cumulativeUsage: createReplayCumulativeUsage(),
11449
- logger: debugLogger7
11685
+ logger: debugLogger6
11450
11686
  });
11451
11687
  if (!bulkReplay2) {
11452
11688
  for (const update of replay.updates) {
@@ -11491,6 +11727,7 @@ var QwenAgent = class {
11491
11727
  // a `null`/`undefined` would otherwise throw `TypeError`.
11492
11728
  params.mcpServers ?? [],
11493
11729
  settings,
11730
+ sessionSource,
11494
11731
  params.sessionId,
11495
11732
  true
11496
11733
  );
@@ -11509,8 +11746,12 @@ var QwenAgent = class {
11509
11746
  let replayUpdates = [];
11510
11747
  if (records) {
11511
11748
  createdSession.primeTurnFromHistory(records);
11512
- const replayPage = selectRecentHistoryRecords(
11749
+ const visibleRecords = selectVisibleHistoryRecords(
11513
11750
  records,
11751
+ shouldHideInheritedHistory(params)
11752
+ );
11753
+ const replayPage = selectRecentHistoryRecords(
11754
+ visibleRecords,
11514
11755
  replayPageSize
11515
11756
  );
11516
11757
  const replayUsage = createReplayCumulativeUsage();
@@ -11521,7 +11762,7 @@ var QwenAgent = class {
11521
11762
  gaps: sessionData?.historyGaps,
11522
11763
  cumulativeUsage: replayUsage,
11523
11764
  supersedeUnrestorableGoal: true,
11524
- logger: debugLogger7
11765
+ logger: debugLogger6
11525
11766
  });
11526
11767
  replayUpdates = replay.updates;
11527
11768
  copyCumulativeUsage(createdSession.cumulativeUsage, replayUsage);
@@ -11577,6 +11818,7 @@ var QwenAgent = class {
11577
11818
  };
11578
11819
  }
11579
11820
  async unstable_resumeSession(params) {
11821
+ const sessionSource = getSessionSource(params);
11580
11822
  const settings = loadSettingsCached(params.cwd);
11581
11823
  const liveSession = this.sessions.get(params.sessionId);
11582
11824
  if (liveSession) {
@@ -11609,6 +11851,7 @@ var QwenAgent = class {
11609
11851
  params.cwd,
11610
11852
  params.mcpServers ?? [],
11611
11853
  settings,
11854
+ sessionSource,
11612
11855
  params.sessionId,
11613
11856
  true
11614
11857
  );
@@ -11660,7 +11903,7 @@ var QwenAgent = class {
11660
11903
  session.pendingWorktreeNotice = restored.contextMessage;
11661
11904
  }
11662
11905
  } catch (error) {
11663
- debugLogger7.warn(`ACP worktree restore failed: ${error}`);
11906
+ debugLogger6.warn(`ACP worktree restore failed: ${error}`);
11664
11907
  }
11665
11908
  }
11666
11909
  async #restoreBackgroundAgentsOnResume(config, session) {
@@ -11693,7 +11936,7 @@ var QwenAgent = class {
11693
11936
  config
11694
11937
  );
11695
11938
  if (restored.restored) {
11696
- debugLogger7.info(
11939
+ debugLogger6.info(
11697
11940
  `ACP goal restored sessionId=${config.getSessionId()} condition=${restored.condition}`
11698
11941
  );
11699
11942
  } else if (restored.blockedBy && restored.blockedBy !== "condition-invalid") {
@@ -11821,8 +12064,8 @@ var QwenAgent = class {
11821
12064
  }, "settleCall");
11822
12065
  const call = {
11823
12066
  controller: new AbortController(),
11824
- settled: new Promise((resolve5) => {
11825
- settleCall = resolve5;
12067
+ settled: new Promise((resolve4) => {
12068
+ settleCall = resolve4;
11826
12069
  })
11827
12070
  };
11828
12071
  let calls = this.activePromptCalls.get(params.sessionId);
@@ -11876,7 +12119,7 @@ var QwenAgent = class {
11876
12119
  await extensionManager.refreshCache();
11877
12120
  extensions = extensionManager.getLoadedExtensions();
11878
12121
  } catch (error) {
11879
- debugLogger7.warn(
12122
+ debugLogger6.warn(
11880
12123
  "Extension loading failed, continuing without extensions:",
11881
12124
  error
11882
12125
  );
@@ -12002,7 +12245,7 @@ var QwenAgent = class {
12002
12245
  pm.addPersistentRule(rule, ruleType);
12003
12246
  }
12004
12247
  } catch (error) {
12005
- debugLogger7.warn(
12248
+ debugLogger6.warn(
12006
12249
  `Failed to sync permission rules to a live session: ${error instanceof Error ? error.message : String(error)}`
12007
12250
  );
12008
12251
  }
@@ -12535,23 +12778,56 @@ var QwenAgent = class {
12535
12778
  ...inferred ? { errorKind: inferred } : {}
12536
12779
  };
12537
12780
  }
12781
+ /**
12782
+ * Keeps the extension-derived half of the skill snapshot self-healing.
12783
+ *
12784
+ * Skills have a watcher (`SkillManager.startWatching`); extensions do not, so
12785
+ * without this the child would never notice an extension installed, removed,
12786
+ * enabled, or disabled outside the daemon — and extension-level skills are
12787
+ * derived from that set, so a skill-watcher tick alone cannot recover it.
12788
+ *
12789
+ * The check is one `readdir` plus a bounded number of `stat`s, and refreshes
12790
+ * only when the sources actually moved, so a steady-state read still parses
12791
+ * no manifest and no `SKILL.md`. Failures are logged and swallowed: a status
12792
+ * read must not fail because revalidation could not run.
12793
+ *
12794
+ * Skipped in safe and bare mode. Those modes deliberately never populate the
12795
+ * extension cache (`Config.initialize` omits the refresh), and the snapshot
12796
+ * derives extension skills from `getExtensions()` — so revalidating here
12797
+ * would load the extensions those modes exist to exclude.
12798
+ */
12799
+ async revalidateExtensionSources(config) {
12800
+ try {
12801
+ if (config.isSafeMode() || config.getBareMode()) return;
12802
+ const changed = await config.getExtensionManager().refreshCacheIfSourcesChanged();
12803
+ if (!changed) return;
12804
+ await config.getSkillManager()?.refreshCache();
12805
+ } catch (error) {
12806
+ debugLogger6.warn("Extension source revalidation failed:", error);
12807
+ }
12808
+ }
12538
12809
  async buildWorkspaceSkillsStatus(config) {
12539
12810
  const skillManager = config.getSkillManager();
12540
12811
  if (!skillManager) {
12541
12812
  return {
12542
12813
  v: STATUS_SCHEMA_VERSION,
12543
12814
  workspaceCwd: this.workspaceCwd(config),
12544
- initialized: true,
12815
+ initialized: false,
12545
12816
  skills: []
12546
12817
  };
12547
12818
  }
12819
+ await this.revalidateExtensionSources(config);
12548
12820
  try {
12549
- const resolved = resolveSkillSettings(
12550
- loadSettings(this.workspaceCwd(config), {
12551
- consumeCorruptionEnvVars: false,
12552
- skipLoadEnvironment: true
12553
- })
12554
- );
12821
+ const skills = skillManager.getCachedSkills();
12822
+ if (skills === null) {
12823
+ return {
12824
+ v: STATUS_SCHEMA_VERSION,
12825
+ workspaceCwd: this.workspaceCwd(config),
12826
+ initialized: false,
12827
+ skills: []
12828
+ };
12829
+ }
12830
+ const resolved = resolveSkillSettings(this.settings);
12555
12831
  const disablements = new Map(
12556
12832
  Array.from(config.getDisabledSkillNames(), (name) => {
12557
12833
  const normalizedName = name.trim().toLowerCase();
@@ -12561,17 +12837,6 @@ var QwenAgent = class {
12561
12837
  ];
12562
12838
  })
12563
12839
  );
12564
- try {
12565
- await config.getExtensionManager().refreshCache();
12566
- } catch (error) {
12567
- debugLogger7.warn("Extension cache refresh failed:", error);
12568
- }
12569
- try {
12570
- await skillManager.refreshCache();
12571
- } catch (error) {
12572
- debugLogger7.warn("Skill cache refresh failed:", error);
12573
- }
12574
- const skills = await skillManager.listSkills();
12575
12840
  const inactiveSkillRefs = inactiveExtensionSkillRefs(config);
12576
12841
  const skillsByKey = new Map(
12577
12842
  skills.map((skill) => [
@@ -13427,9 +13692,9 @@ var QwenAgent = class {
13427
13692
  );
13428
13693
  }
13429
13694
  const download = await downloadSkill(request.sourceUrl);
13430
- const skillsBaseDir = path4.join(Storage.getGlobalQwenDir(), "skills");
13695
+ const skillsBaseDir = path3.join(Storage.getGlobalQwenDir(), "skills");
13431
13696
  const skillDir = resolveManagedSkillDir(skillsBaseDir, request.slug);
13432
- const skillFile = path4.join(skillDir, "SKILL.md");
13697
+ const skillFile = path3.join(skillDir, "SKILL.md");
13433
13698
  const parsed = skillManager.parseSkillContent(
13434
13699
  download.skillContent,
13435
13700
  skillFile,
@@ -13443,19 +13708,19 @@ var QwenAgent = class {
13443
13708
  }
13444
13709
  const stagingDir = `${skillDir}.installing-${process.pid}-${Date.now()}`;
13445
13710
  try {
13446
- await fs2.rm(stagingDir, { recursive: true, force: true });
13711
+ await fs.rm(stagingDir, { recursive: true, force: true });
13447
13712
  for (const file of download.files) {
13448
13713
  const targetPath = resolveSkillInstallPath(
13449
13714
  stagingDir,
13450
13715
  file.relativePath
13451
13716
  );
13452
- await fs2.mkdir(path4.dirname(targetPath), { recursive: true });
13453
- await fs2.writeFile(targetPath, file.content);
13717
+ await fs.mkdir(path3.dirname(targetPath), { recursive: true });
13718
+ await fs.writeFile(targetPath, file.content);
13454
13719
  }
13455
- await fs2.rm(skillDir, { recursive: true, force: true });
13456
- await fs2.rename(stagingDir, skillDir);
13720
+ await fs.rm(skillDir, { recursive: true, force: true });
13721
+ await fs.rename(stagingDir, skillDir);
13457
13722
  } catch (error) {
13458
- await fs2.rm(stagingDir, { recursive: true, force: true }).catch(() => {
13723
+ await fs.rm(stagingDir, { recursive: true, force: true }).catch(() => {
13459
13724
  });
13460
13725
  throw error;
13461
13726
  }
@@ -13488,17 +13753,17 @@ var QwenAgent = class {
13488
13753
  `Skill name "${parsed.name}" does not match requested slug "${request.slug}"`
13489
13754
  );
13490
13755
  }
13491
- const resolvedSkillDir = path4.resolve(skillDir);
13492
- const resolvedSkillFile = path4.resolve(skillFile);
13493
- const globalDir = path4.resolve(Storage.getGlobalQwenDir());
13494
- const isDedicatedSkillDir = resolvedSkillFile === path4.join(resolvedSkillDir, "SKILL.md");
13495
- if (!isDedicatedSkillDir || resolvedSkillDir === path4.parse(resolvedSkillDir).root || resolvedSkillDir === globalDir) {
13756
+ const resolvedSkillDir = path3.resolve(skillDir);
13757
+ const resolvedSkillFile = path3.resolve(skillFile);
13758
+ const globalDir = path3.resolve(Storage.getGlobalQwenDir());
13759
+ const isDedicatedSkillDir = resolvedSkillFile === path3.join(resolvedSkillDir, "SKILL.md");
13760
+ if (!isDedicatedSkillDir || resolvedSkillDir === path3.parse(resolvedSkillDir).root || resolvedSkillDir === globalDir) {
13496
13761
  throw RequestError.invalidParams(
13497
13762
  void 0,
13498
13763
  `Refusing to delete unexpected skill directory: ${skillDir}`
13499
13764
  );
13500
13765
  }
13501
- await fs2.rm(skillDir, { recursive: true, force: true });
13766
+ await fs.rm(skillDir, { recursive: true, force: true });
13502
13767
  await skillManager.refreshCache();
13503
13768
  return {
13504
13769
  slug: request.slug,
@@ -13508,11 +13773,11 @@ var QwenAgent = class {
13508
13773
  async readManagedSkillFile(slug, scope, skillManager, cwd) {
13509
13774
  if (scope === "global") {
13510
13775
  const qwenSkillDir = resolveManagedSkillDir(
13511
- path4.join(Storage.getGlobalQwenDir(), "skills"),
13776
+ path3.join(Storage.getGlobalQwenDir(), "skills"),
13512
13777
  slug
13513
13778
  );
13514
- const qwenSkillFile = path4.join(qwenSkillDir, "SKILL.md");
13515
- const qwenContent = await fs2.readFile(qwenSkillFile, "utf8").catch(() => void 0);
13779
+ const qwenSkillFile = path3.join(qwenSkillDir, "SKILL.md");
13780
+ const qwenContent = await fs.readFile(qwenSkillFile, "utf8").catch(() => void 0);
13516
13781
  if (qwenContent !== void 0) {
13517
13782
  return {
13518
13783
  skillDir: qwenSkillDir,
@@ -13540,34 +13805,34 @@ var QwenAgent = class {
13540
13805
  `${scope === "project" ? "Project" : "Global"} skill not found: ${slug}`
13541
13806
  );
13542
13807
  }
13543
- const content = await fs2.readFile(skillFile, "utf8").catch(() => {
13808
+ const content = await fs.readFile(skillFile, "utf8").catch(() => {
13544
13809
  throw RequestError.invalidParams(
13545
13810
  void 0,
13546
13811
  `${scope === "project" ? "Project" : "Global"} skill not found: ${slug}`
13547
13812
  );
13548
13813
  });
13549
13814
  return {
13550
- skillDir: path4.dirname(skillFile),
13815
+ skillDir: path3.dirname(skillFile),
13551
13816
  skillFile,
13552
13817
  content
13553
13818
  };
13554
13819
  }
13555
13820
  async findProjectSkillFileFromCwd(slug, cwd, skillManager) {
13556
- const projectRoot = path4.resolve(cwd);
13821
+ const projectRoot = path3.resolve(cwd);
13557
13822
  for (const configDir of PROJECT_SKILL_DIRS) {
13558
- const baseDir = path4.join(projectRoot, configDir, SKILLS_DIR);
13823
+ const baseDir = path3.join(projectRoot, configDir, SKILLS_DIR);
13559
13824
  const skills = await skillManager.loadSkillsFromDir(baseDir, "project");
13560
13825
  const skill = skills.find((candidate) => candidate.name === slug);
13561
13826
  const skillFile = skill?.filePath;
13562
13827
  if (!skillFile) continue;
13563
- const content = await fs2.readFile(skillFile, "utf8").catch(() => {
13828
+ const content = await fs.readFile(skillFile, "utf8").catch(() => {
13564
13829
  throw RequestError.invalidParams(
13565
13830
  void 0,
13566
13831
  `Project skill not found: ${slug}`
13567
13832
  );
13568
13833
  });
13569
13834
  return {
13570
- skillDir: path4.dirname(skillFile),
13835
+ skillDir: path3.dirname(skillFile),
13571
13836
  skillFile,
13572
13837
  content
13573
13838
  };
@@ -13598,13 +13863,13 @@ var QwenAgent = class {
13598
13863
  }
13599
13864
  const nextContent = setSkillFrontmatterEnabled(content, request.enabled);
13600
13865
  skillManager.parseSkillContent(nextContent, skillFile, level);
13601
- if (path4.basename(skillFile) !== "SKILL.md") {
13866
+ if (path3.basename(skillFile) !== "SKILL.md") {
13602
13867
  throw RequestError.invalidParams(
13603
13868
  void 0,
13604
13869
  `Refusing to write to unexpected skill file: ${skillFile}`
13605
13870
  );
13606
13871
  }
13607
- await fs2.writeFile(skillFile, nextContent, "utf8");
13872
+ await fs.writeFile(skillFile, nextContent, "utf8");
13608
13873
  await skillManager.refreshCache();
13609
13874
  return {
13610
13875
  slug: request.slug,
@@ -13977,7 +14242,7 @@ var QwenAgent = class {
13977
14242
  page,
13978
14243
  config,
13979
14244
  encodeCursor: /* @__PURE__ */ __name((state) => encodeSessionTranscriptCursor(state, cwd), "encodeCursor"),
13980
- logger: debugLogger7
14245
+ logger: debugLogger6
13981
14246
  });
13982
14247
  return {
13983
14248
  v: 1,
@@ -14170,7 +14435,7 @@ var QwenAgent = class {
14170
14435
  );
14171
14436
  if (childSignal.aborted) {
14172
14437
  const timeoutCode = "remember_timeout";
14173
- debugLogger7.error("Workspace memory remember timed out:", {
14438
+ debugLogger6.error("Workspace memory remember timed out:", {
14174
14439
  projectRoot,
14175
14440
  code: timeoutCode,
14176
14441
  details: diagnostics.debugDetails,
@@ -14182,7 +14447,7 @@ var QwenAgent = class {
14182
14447
  workspaceMemoryErrorData(timeoutCode, diagnostics)
14183
14448
  );
14184
14449
  }
14185
- debugLogger7.error("Workspace memory remember failed:", {
14450
+ debugLogger6.error("Workspace memory remember failed:", {
14186
14451
  projectRoot,
14187
14452
  code,
14188
14453
  details: diagnostics.debugDetails,
@@ -14256,7 +14521,7 @@ var QwenAgent = class {
14256
14521
  );
14257
14522
  if (childSignal.aborted) {
14258
14523
  const timeoutCode = "forget_timeout";
14259
- debugLogger7.error("Workspace memory forget timed out:", {
14524
+ debugLogger6.error("Workspace memory forget timed out:", {
14260
14525
  projectRoot,
14261
14526
  code: timeoutCode,
14262
14527
  details: diagnostics.debugDetails,
@@ -14268,7 +14533,7 @@ var QwenAgent = class {
14268
14533
  workspaceMemoryErrorData(timeoutCode, diagnostics)
14269
14534
  );
14270
14535
  }
14271
- debugLogger7.error("Workspace memory forget failed:", {
14536
+ debugLogger6.error("Workspace memory forget failed:", {
14272
14537
  projectRoot,
14273
14538
  code,
14274
14539
  details: diagnostics.debugDetails,
@@ -14333,7 +14598,7 @@ var QwenAgent = class {
14333
14598
  );
14334
14599
  if (childSignal.aborted) {
14335
14600
  const timeoutCode = "dream_timeout";
14336
- debugLogger7.error("Workspace memory dream timed out:", {
14601
+ debugLogger6.error("Workspace memory dream timed out:", {
14337
14602
  projectRoot,
14338
14603
  code: timeoutCode,
14339
14604
  details: diagnostics.debugDetails,
@@ -14345,7 +14610,7 @@ var QwenAgent = class {
14345
14610
  workspaceMemoryErrorData(timeoutCode, diagnostics)
14346
14611
  );
14347
14612
  }
14348
- debugLogger7.error("Workspace memory dream failed:", {
14613
+ debugLogger6.error("Workspace memory dream failed:", {
14349
14614
  projectRoot,
14350
14615
  code,
14351
14616
  details: diagnostics.debugDetails,
@@ -14696,10 +14961,10 @@ var QwenAgent = class {
14696
14961
  let resolveStarted;
14697
14962
  let rejectStarted;
14698
14963
  let startedTimer;
14699
- const started = new Promise((resolve5, reject) => {
14964
+ const started = new Promise((resolve4, reject) => {
14700
14965
  resolveStarted = /* @__PURE__ */ __name((value) => {
14701
14966
  clearTimeout(startedTimer);
14702
- resolve5(value);
14967
+ resolve4(value);
14703
14968
  }, "resolveStarted");
14704
14969
  rejectStarted = /* @__PURE__ */ __name((reason) => {
14705
14970
  clearTimeout(startedTimer);
@@ -14755,7 +15020,7 @@ var QwenAgent = class {
14755
15020
  error: error instanceof Error ? error.message : String(error)
14756
15021
  });
14757
15022
  rejectStarted(error);
14758
- debugLogger7.warn(
15023
+ debugLogger6.warn(
14759
15024
  `MCP OAuth authentication failed for ${serverName}:`,
14760
15025
  error
14761
15026
  );
@@ -14767,7 +15032,7 @@ var QwenAgent = class {
14767
15032
  "discover"
14768
15033
  );
14769
15034
  } catch (error) {
14770
- debugLogger7.warn(
15035
+ debugLogger6.warn(
14771
15036
  `MCP OAuth authenticated for ${serverName}, but tool synchronization failed:`,
14772
15037
  error
14773
15038
  );
@@ -15054,7 +15319,7 @@ var QwenAgent = class {
15054
15319
  "Invalid or missing sessionId"
15055
15320
  );
15056
15321
  }
15057
- if (typeof targetPath !== "string" || targetPath.length === 0 || !path4.isAbsolute(targetPath) || targetPath.includes("\0")) {
15322
+ if (typeof targetPath !== "string" || targetPath.length === 0 || !path3.isAbsolute(targetPath) || targetPath.includes("\0")) {
15058
15323
  throw RequestError.invalidParams(
15059
15324
  void 0,
15060
15325
  "Invalid or missing path (must be an absolute path)"
@@ -15069,7 +15334,7 @@ var QwenAgent = class {
15069
15334
  }
15070
15335
  let stats;
15071
15336
  try {
15072
- stats = await fs2.stat(targetPath);
15337
+ stats = await fs.stat(targetPath);
15073
15338
  } catch {
15074
15339
  throw new RequestError(-32002, `Directory not found: ${targetPath}`, {
15075
15340
  errorKind: "directory_not_found",
@@ -15082,13 +15347,13 @@ var QwenAgent = class {
15082
15347
  path: targetPath
15083
15348
  });
15084
15349
  }
15085
- const canonicalPath = await fs2.realpath(targetPath);
15350
+ const canonicalPath = await fs.realpath(targetPath);
15086
15351
  const allowedRoots = params["allowedRoots"];
15087
15352
  if (Array.isArray(allowedRoots) && allowedRoots.length > 0) {
15088
15353
  const contained = allowedRoots.some((root) => {
15089
15354
  if (typeof root !== "string") return false;
15090
- const rel = path4.relative(root, canonicalPath);
15091
- return !rel.startsWith("..") && !path4.isAbsolute(rel);
15355
+ const rel = path3.relative(root, canonicalPath);
15356
+ return !rel.startsWith("..") && !path3.isAbsolute(rel);
15092
15357
  });
15093
15358
  if (!contained) {
15094
15359
  throw new RequestError(
@@ -15151,6 +15416,11 @@ var QwenAgent = class {
15151
15416
  `Memory refresh failed: ${relocation.memoryRefreshError instanceof Error ? relocation.memoryRefreshError.message : String(relocation.memoryRefreshError)}`
15152
15417
  );
15153
15418
  }
15419
+ if (relocation.mcpRefreshError) {
15420
+ warnings.push(
15421
+ `MCP refresh failed: ${relocation.mcpRefreshError instanceof Error ? relocation.mcpRefreshError.message : String(relocation.mcpRefreshError)}`
15422
+ );
15423
+ }
15154
15424
  try {
15155
15425
  await config.getGeminiClient()?.addWorkingDirectoryChangedContext(
15156
15426
  settledPreviousCwd,
@@ -15228,7 +15498,7 @@ var QwenAgent = class {
15228
15498
  try {
15229
15499
  await setLanguageAsync(language);
15230
15500
  } catch (err) {
15231
- debugLogger7.warn("setLanguageAsync failed:", err);
15501
+ debugLogger6.warn("setLanguageAsync failed:", err);
15232
15502
  throw new RequestError(
15233
15503
  -32603,
15234
15504
  `Failed to switch UI language: ${err instanceof Error ? err.message : String(err)}`
@@ -15242,7 +15512,7 @@ var QwenAgent = class {
15242
15512
  language
15243
15513
  );
15244
15514
  } catch (err) {
15245
- debugLogger7.warn("Failed to persist UI language setting:", err);
15515
+ debugLogger6.warn("Failed to persist UI language setting:", err);
15246
15516
  }
15247
15517
  let outputLanguage = null;
15248
15518
  let refreshed = false;
@@ -15256,7 +15526,7 @@ var QwenAgent = class {
15256
15526
  );
15257
15527
  fileWriteOk = true;
15258
15528
  } catch (err) {
15259
- debugLogger7.warn("Failed to write output-language.md:", err);
15529
+ debugLogger6.warn("Failed to write output-language.md:", err);
15260
15530
  }
15261
15531
  if (fileWriteOk) {
15262
15532
  try {
@@ -15266,7 +15536,7 @@ var QwenAgent = class {
15266
15536
  settingValue
15267
15537
  );
15268
15538
  } catch (err) {
15269
- debugLogger7.warn(
15539
+ debugLogger6.warn(
15270
15540
  "Failed to persist output language setting:",
15271
15541
  err
15272
15542
  );
@@ -15286,7 +15556,7 @@ var QwenAgent = class {
15286
15556
  writeOutputLanguageAndRegisterPath(settingValue, cfg);
15287
15557
  }
15288
15558
  } catch (err) {
15289
- debugLogger7.warn(
15559
+ debugLogger6.warn(
15290
15560
  `Failed to write output-language.md for session ${s.getId()} (path=${sessionPath ?? "global-default"}):`,
15291
15561
  err
15292
15562
  );
@@ -15299,7 +15569,7 @@ var QwenAgent = class {
15299
15569
  (r) => r.status === "rejected"
15300
15570
  ).length;
15301
15571
  if (failedCount > 0) {
15302
- debugLogger7.warn(
15572
+ debugLogger6.warn(
15303
15573
  `Language refresh failed for ${failedCount}/${results.length} session(s)`
15304
15574
  );
15305
15575
  }
@@ -15317,14 +15587,14 @@ var QwenAgent = class {
15317
15587
  "Invalid or missing sessionId"
15318
15588
  );
15319
15589
  }
15320
- debugLogger7.debug(`recap ext-method received for session=${sessionId}`);
15590
+ debugLogger6.debug(`recap ext-method received for session=${sessionId}`);
15321
15591
  const session = this.sessionOrThrow(sessionId);
15322
15592
  const config = session.getConfig();
15323
15593
  const recap = await generateSessionRecap(
15324
15594
  config,
15325
15595
  new AbortController().signal
15326
15596
  );
15327
- debugLogger7.debug(
15597
+ debugLogger6.debug(
15328
15598
  `recap ext-method completed for session=${sessionId} result=${recap ? `len=${recap.length}` : "null"}`
15329
15599
  );
15330
15600
  return { sessionId, recap };
@@ -15406,7 +15676,7 @@ var QwenAgent = class {
15406
15676
  const config = session.getConfig();
15407
15677
  const cacheSafeParams = buildBtwCacheSafeParams(config);
15408
15678
  if (!cacheSafeParams) {
15409
- debugLogger7.debug(`btw: no cacheSafeParams for session=${sessionId}`);
15679
+ debugLogger6.debug(`btw: no cacheSafeParams for session=${sessionId}`);
15410
15680
  return { sessionId, answer: null };
15411
15681
  }
15412
15682
  const childSignal = AbortSignal.timeout(BTW_CHILD_TIMEOUT_MS);
@@ -15454,7 +15724,7 @@ var QwenAgent = class {
15454
15724
  try {
15455
15725
  hasHistory = (config.getGeminiClient().getHistoryShallow() ?? []).length > 0;
15456
15726
  } catch (error) {
15457
- debugLogger7.debug("Failed to read history before /fork:", error);
15727
+ debugLogger6.debug("Failed to read history before /fork:", error);
15458
15728
  }
15459
15729
  if (!hasHistory) {
15460
15730
  throw RequestError.invalidParams(
@@ -15496,7 +15766,7 @@ var QwenAgent = class {
15496
15766
  ]
15497
15767
  });
15498
15768
  } catch (error) {
15499
- debugLogger7.debug("Failed to record fork event in history:", error);
15769
+ debugLogger6.debug("Failed to record fork event in history:", error);
15500
15770
  }
15501
15771
  return { sessionId, description, launched: true };
15502
15772
  }
@@ -15559,7 +15829,7 @@ ${outputText}
15559
15829
  'taskKind must be "agent", "shell", or "monitor"'
15560
15830
  );
15561
15831
  }
15562
- debugLogger7.info(
15832
+ debugLogger6.info(
15563
15833
  `sessionTaskCancel requested sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind}`
15564
15834
  );
15565
15835
  const session = this.sessionOrThrow(sessionId);
@@ -15569,7 +15839,7 @@ ${outputText}
15569
15839
  const task = config.getBackgroundTaskRegistry().get(taskId);
15570
15840
  if (!task || task.status !== "running" && task.status !== "paused") {
15571
15841
  const reason = task ? "not_running" : "not_found";
15572
- debugLogger7.info(
15842
+ debugLogger6.info(
15573
15843
  `sessionTaskCancel skipped sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind} reason=${reason} status=${task?.status ?? "missing"}`
15574
15844
  );
15575
15845
  return { cancelled: false, reason, status: task?.status };
@@ -15579,7 +15849,7 @@ ${outputText}
15579
15849
  } else {
15580
15850
  config.getBackgroundTaskRegistry().cancel(taskId);
15581
15851
  }
15582
- debugLogger7.info(
15852
+ debugLogger6.info(
15583
15853
  `sessionTaskCancel completed sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind} status=${task.status}`
15584
15854
  );
15585
15855
  return { cancelled: true, status: task.status };
@@ -15588,13 +15858,13 @@ ${outputText}
15588
15858
  const task = config.getBackgroundShellRegistry().get(taskId);
15589
15859
  if (!task || task.status !== "running") {
15590
15860
  const reason = task ? "not_running" : "not_found";
15591
- debugLogger7.info(
15861
+ debugLogger6.info(
15592
15862
  `sessionTaskCancel skipped sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind} reason=${reason} status=${task?.status ?? "missing"}`
15593
15863
  );
15594
15864
  return { cancelled: false, reason, status: task?.status };
15595
15865
  }
15596
15866
  config.getBackgroundShellRegistry().requestCancel(taskId);
15597
- debugLogger7.info(
15867
+ debugLogger6.info(
15598
15868
  `sessionTaskCancel completed sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind} status=${task.status}`
15599
15869
  );
15600
15870
  return { cancelled: true, status: task.status };
@@ -15603,13 +15873,13 @@ ${outputText}
15603
15873
  const task = config.getMonitorRegistry().get(taskId);
15604
15874
  if (!task || task.status !== "running") {
15605
15875
  const reason = task ? "not_running" : "not_found";
15606
- debugLogger7.info(
15876
+ debugLogger6.info(
15607
15877
  `sessionTaskCancel skipped sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind} reason=${reason} status=${task?.status ?? "missing"}`
15608
15878
  );
15609
15879
  return { cancelled: false, reason, status: task?.status };
15610
15880
  }
15611
15881
  config.getMonitorRegistry().cancel(taskId);
15612
- debugLogger7.info(
15882
+ debugLogger6.info(
15613
15883
  `sessionTaskCancel completed sessionId=${sessionId} taskId=${taskId} taskKind=${taskKind} status=${task.status}`
15614
15884
  );
15615
15885
  return { cancelled: true, status: task.status };
@@ -15639,7 +15909,7 @@ ${outputText}
15639
15909
  durationMs: Date.now() - cleared.setAt
15640
15910
  });
15641
15911
  }
15642
- debugLogger7.info(
15912
+ debugLogger6.info(
15643
15913
  `sessionGoalClear sessionId=${sessionId} cleared=${!!cleared} condition=${cleared?.condition ?? "(none)"}`
15644
15914
  );
15645
15915
  return {
@@ -15678,7 +15948,7 @@ ${outputText}
15678
15948
  }
15679
15949
  const session = this.sessionOrThrow(sessionId);
15680
15950
  const result = await session.continueLastTurn();
15681
- debugLogger7.info(
15951
+ debugLogger6.info(
15682
15952
  `sessionContinue sessionId=${sessionId} accepted=${result.accepted} interruption=${result.interruption}`
15683
15953
  );
15684
15954
  return result;
@@ -15700,7 +15970,7 @@ ${outputText}
15700
15970
  request.runtimeClientId
15701
15971
  );
15702
15972
  } catch (sessionErr) {
15703
- debugLogger7.warn(
15973
+ debugLogger6.warn(
15704
15974
  `workspaceMcpRuntimeAdd: failed to add runtime MCP server '${request.name}' to active session ${session.getConfig().getSessionId()}: ${sessionErr instanceof Error ? sessionErr.message : String(sessionErr)}`
15705
15975
  );
15706
15976
  }
@@ -15723,7 +15993,7 @@ ${outputText}
15723
15993
  request.runtimeClientId
15724
15994
  );
15725
15995
  } catch (sessionErr) {
15726
- debugLogger7.warn(
15996
+ debugLogger6.warn(
15727
15997
  `workspaceMcpRuntimeRemove: failed to remove runtime MCP server '${request.name}' from active session ${session.getConfig().getSessionId()}: ${sessionErr instanceof Error ? sessionErr.message : String(sessionErr)}`
15728
15998
  );
15729
15999
  }
@@ -15762,6 +16032,13 @@ ${outputText}
15762
16032
  }
15763
16033
  case SERVE_CONTROL_EXT_METHODS.workspaceExtensionsRefresh: {
15764
16034
  const sessionId = params["sessionId"];
16035
+ const rawRefreshBootstrap = params["refreshBootstrap"];
16036
+ if (rawRefreshBootstrap !== void 0 && typeof rawRefreshBootstrap !== "boolean") {
16037
+ throw RequestError.invalidParams(
16038
+ void 0,
16039
+ "refreshBootstrap must be a boolean"
16040
+ );
16041
+ }
15765
16042
  const session = this.sessionOrThrow(sessionId);
15766
16043
  const config = session.getConfig();
15767
16044
  const extensionManager = config.getExtensionManager();
@@ -15775,6 +16052,12 @@ ${outputText}
15775
16052
  }, "runRefresh");
15776
16053
  await runRefresh(async () => await extensionManager.refreshCache());
15777
16054
  await runRefresh(async () => await extensionManager.refreshTools());
16055
+ const bootstrapConfig = this.config;
16056
+ if (rawRefreshBootstrap !== false && bootstrapConfig !== config) {
16057
+ await runRefresh(
16058
+ async () => await this.refreshBootstrapExtensionStatus()
16059
+ );
16060
+ }
15778
16061
  const discoveryConfig = this.workspaceMcpDiscoveryConfig;
15779
16062
  if (discoveryConfig && discoveryConfig !== config) {
15780
16063
  const discoveryExtensionManager = discoveryConfig.getExtensionManager();
@@ -15818,6 +16101,9 @@ ${outputText}
15818
16101
  return sessionService.removeSession(sessionId);
15819
16102
  }
15820
16103
  );
16104
+ if (success) {
16105
+ fireSessionDeleteHook(this.config, sessionId, debugLogger6);
16106
+ }
15821
16107
  return { success };
15822
16108
  }
15823
16109
  case "renameSession": {
@@ -15942,7 +16228,7 @@ ${outputText}
15942
16228
  filesFailed = fileResult.filesFailed;
15943
16229
  } catch (err) {
15944
16230
  const reason = err instanceof Error ? err.message : String(err);
15945
- debugLogger7.error(
16231
+ debugLogger6.error(
15946
16232
  `[ACP] File-history rewind failed for session=${sessionId} promptId=${promptId}: ${reason}`
15947
16233
  );
15948
16234
  filesFailed = [`file-history-rewind: ${reason}`];
@@ -15974,7 +16260,7 @@ ${outputText}
15974
16260
  } catch (err) {
15975
16261
  const reason = err instanceof Error ? err.message : String(err);
15976
16262
  artifactSnapshotUnavailable = "artifact snapshot unavailable after rewind";
15977
- debugLogger7.warn(
16263
+ debugLogger6.warn(
15978
16264
  `[ACP] Failed to rebuild artifact snapshot after rewind for session=${sessionId}: ${reason}`
15979
16265
  );
15980
16266
  }
@@ -16030,7 +16316,7 @@ ${outputText}
16030
16316
  records: sessionData.conversation.messages,
16031
16317
  gaps: sessionData.historyGaps,
16032
16318
  cumulativeUsage: createReplayCumulativeUsage(),
16033
- logger: debugLogger7
16319
+ logger: debugLogger6
16034
16320
  });
16035
16321
  return {
16036
16322
  updates: replay.updates,
@@ -16078,7 +16364,9 @@ ${outputText}
16078
16364
  apiKeyEnvKey: cfg?.apiKeyEnvKey ?? null
16079
16365
  };
16080
16366
  }
16081
- case SERVE_CONTROL_EXT_METHODS.sessionBranch: {
16367
+ case SERVE_CONTROL_EXT_METHODS.sessionBranch:
16368
+ case SERVE_CONTROL_EXT_METHODS.sessionSideTask: {
16369
+ const isSideTask = method === SERVE_CONTROL_EXT_METHODS.sessionSideTask;
16082
16370
  const sessionId = params["sessionId"];
16083
16371
  if (typeof sessionId !== "string" || !SESSION_ID_RE.test(sessionId)) {
16084
16372
  throw RequestError.invalidParams(
@@ -16101,7 +16389,17 @@ ${outputText}
16101
16389
  }
16102
16390
  const newSessionId = randomUUID2();
16103
16391
  const sessionService = sourceConfig.getSessionService();
16104
- await sessionService.forkSession(sessionId, newSessionId);
16392
+ const fork = /* @__PURE__ */ __name(() => isSideTask ? sessionService.forkSession(sessionId, newSessionId, {
16393
+ source: {
16394
+ sourceType: "side_task",
16395
+ sourceId: sessionId
16396
+ }
16397
+ }) : sessionService.forkSession(sessionId, newSessionId), "fork");
16398
+ if (isSideTask && recording) {
16399
+ await recording.runWithWriteBarrier(fork);
16400
+ } else {
16401
+ await fork();
16402
+ }
16105
16403
  let title;
16106
16404
  try {
16107
16405
  let baseName;
@@ -16116,7 +16414,7 @@ ${outputText}
16116
16414
  baseName = sessionId.slice(0, 8);
16117
16415
  }
16118
16416
  }
16119
- title = await computeUniqueBranchTitle(baseName, sessionService);
16417
+ title = isSideTask ? baseName : await computeUniqueBranchTitle(baseName, sessionService);
16120
16418
  const renamed = await sessionService.renameSession(
16121
16419
  newSessionId,
16122
16420
  title,
@@ -16374,7 +16672,7 @@ ${outputText}
16374
16672
  newMerged.providerProtocol ?? {}
16375
16673
  );
16376
16674
  } catch (err) {
16377
- debugLogger7.warn(
16675
+ debugLogger6.warn(
16378
16676
  `reload: reloadModelProvidersConfig failed for session ${id}: ${err}`
16379
16677
  );
16380
16678
  }
@@ -16384,7 +16682,7 @@ ${outputText}
16384
16682
  try {
16385
16683
  await config.switchModel(authType, newModelName);
16386
16684
  } catch (err) {
16387
- debugLogger7.warn(
16685
+ debugLogger6.warn(
16388
16686
  `reload: switchModel failed for session ${id}: ${err}`
16389
16687
  );
16390
16688
  }
@@ -16392,7 +16690,7 @@ ${outputText}
16392
16690
  try {
16393
16691
  await config.refreshAuth(authType);
16394
16692
  } catch (err) {
16395
- debugLogger7.warn(
16693
+ debugLogger6.warn(
16396
16694
  `reload: refreshAuth failed for session ${id}: ${err}`
16397
16695
  );
16398
16696
  }
@@ -16410,7 +16708,7 @@ ${outputText}
16410
16708
  session.clearTodoStopGuardTrust();
16411
16709
  }
16412
16710
  } catch (err) {
16413
- debugLogger7.warn(
16711
+ debugLogger6.warn(
16414
16712
  `reload: setApprovalMode failed for session ${id}: ${err}`
16415
16713
  );
16416
16714
  }
@@ -16419,14 +16717,14 @@ ${outputText}
16419
16717
  try {
16420
16718
  await config.refreshHierarchicalMemory();
16421
16719
  } catch (err) {
16422
- debugLogger7.warn(
16720
+ debugLogger6.warn(
16423
16721
  `reload: refreshHierarchicalMemory failed for session ${id}: ${err}`
16424
16722
  );
16425
16723
  }
16426
16724
  try {
16427
16725
  await config.getGeminiClient()?.refreshSystemInstruction();
16428
16726
  } catch (err) {
16429
- debugLogger7.warn(
16727
+ debugLogger6.warn(
16430
16728
  `reload: refreshSystemInstruction failed for session ${id}: ${err}`
16431
16729
  );
16432
16730
  }
@@ -16436,7 +16734,7 @@ ${outputText}
16436
16734
  for (let i = 0; i < results.length; i++) {
16437
16735
  if (results[i].status === "rejected") {
16438
16736
  const reason = results[i].reason;
16439
- debugLogger7.warn(
16737
+ debugLogger6.warn(
16440
16738
  `Session ${sessions[i][0]} reload failed: ${reason}`
16441
16739
  );
16442
16740
  skipped.push(sessions[i][0]);
@@ -16450,16 +16748,58 @@ ${outputText}
16450
16748
  };
16451
16749
  }
16452
16750
  case SERVE_CONTROL_EXT_METHODS.workspaceSkillsRefresh: {
16453
- this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
16751
+ const rawReason = params["reason"];
16752
+ if (rawReason !== void 0 && rawReason !== "settings" && rawReason !== "content" && rawReason !== "all") {
16753
+ throw RequestError.invalidParams(
16754
+ void 0,
16755
+ "reason must be settings, content, or all"
16756
+ );
16757
+ }
16758
+ const reason = rawReason ?? "all";
16759
+ const refreshSettings = reason !== "content";
16760
+ const refreshContent = reason !== "settings";
16761
+ if (refreshSettings) {
16762
+ this.settings.reloadScopeFromDisk("Workspace" /* Workspace */);
16763
+ }
16454
16764
  const sessions = this.getActiveSessions();
16765
+ const settingsReloadResults = refreshSettings ? await Promise.allSettled(
16766
+ sessions.map(
16767
+ (session) => Promise.resolve().then(() => session.reloadSkillSettings())
16768
+ )
16769
+ ) : void 0;
16770
+ let configResults = [];
16771
+ if (refreshContent) {
16772
+ const skillManagers = new Set(
16773
+ [this.config, ...sessions.map((session) => session.getConfig())].map((config) => config.getSkillManager()).filter(
16774
+ (manager) => manager !== void 0
16775
+ )
16776
+ );
16777
+ configResults = await Promise.allSettled(
16778
+ [...skillManagers].map((manager) => manager.refreshCache())
16779
+ );
16780
+ for (const result of configResults) {
16781
+ if (result.status === "rejected") {
16782
+ debugLogger6.warn(`Skill config refresh failed: ${result.reason}`);
16783
+ }
16784
+ }
16785
+ }
16455
16786
  const results = await Promise.allSettled(
16456
- sessions.map((session) => session.refreshSkillsFromSettings())
16787
+ sessions.map((session, index) => {
16788
+ const settingsReload = settingsReloadResults?.[index];
16789
+ if (settingsReload?.status === "rejected") {
16790
+ return Promise.reject(settingsReload.reason);
16791
+ }
16792
+ return session.refreshSkillsFromSettings({
16793
+ reloadSettings: false,
16794
+ notifyConfigChanged: !refreshContent
16795
+ });
16796
+ })
16457
16797
  );
16458
16798
  for (let i = 0; i < results.length; i++) {
16459
16799
  if (results[i].status === "rejected") {
16460
- const reason = results[i].reason;
16461
- debugLogger7.warn(
16462
- `Session ${sessions[i].getId()} skill refresh failed: ${reason}`
16800
+ const reason2 = results[i].reason;
16801
+ debugLogger6.warn(
16802
+ `Session ${sessions[i].getId()} skill refresh failed: ${reason2}`
16463
16803
  );
16464
16804
  }
16465
16805
  }
@@ -16469,7 +16809,14 @@ ${outputText}
16469
16809
  ).length,
16470
16810
  sessionsFailed: results.filter(
16471
16811
  (result) => result.status === "rejected"
16472
- ).length
16812
+ ).length,
16813
+ configsRefreshed: configResults.filter(
16814
+ (result) => result.status === "fulfilled"
16815
+ ).length,
16816
+ configsFailed: configResults.filter(
16817
+ (result) => result.status === "rejected"
16818
+ ).length,
16819
+ reason
16473
16820
  };
16474
16821
  }
16475
16822
  default:
@@ -16495,12 +16842,12 @@ ${outputText}
16495
16842
  disposeTranscriptReplayConfig(config) {
16496
16843
  try {
16497
16844
  void Promise.resolve(config.getToolRegistry()?.stop()).catch((err) => {
16498
- debugLogger7.debug(
16845
+ debugLogger6.debug(
16499
16846
  `Transcript replay config tool registry stop failed: ${err instanceof Error ? err.message : String(err)}`
16500
16847
  );
16501
16848
  });
16502
16849
  } catch (err) {
16503
- debugLogger7.debug(
16850
+ debugLogger6.debug(
16504
16851
  `Transcript replay config tool registry stop failed: ${err instanceof Error ? err.message : String(err)}`
16505
16852
  );
16506
16853
  }
@@ -16514,7 +16861,7 @@ ${outputText}
16514
16861
  this.transcriptReplayConfigCache.clear();
16515
16862
  }
16516
16863
  async getTranscriptReplayConfig(cwd, settings) {
16517
- const key = path4.resolve(cwd);
16864
+ const key = path3.resolve(cwd);
16518
16865
  const cached = this.transcriptReplayConfigCache.get(key);
16519
16866
  if (cached?.settings === settings) {
16520
16867
  if (cached.config) {
@@ -16532,6 +16879,7 @@ ${outputText}
16532
16879
  [],
16533
16880
  settings,
16534
16881
  void 0,
16882
+ void 0,
16535
16883
  false,
16536
16884
  {
16537
16885
  skipMcpDiscovery: true,
@@ -16573,7 +16921,7 @@ ${outputText}
16573
16921
  throw error;
16574
16922
  }
16575
16923
  }
16576
- async newSessionConfig(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}, chatRecording) {
16924
+ async newSessionConfig(cwd, mcpServers, settings, sessionSource, sessionId, resume, initializeOptions = {}, chatRecording) {
16577
16925
  try {
16578
16926
  this.assertManagedSessionAdmission();
16579
16927
  return await this.runWithPinnedRuntimeBaseDir(settings, cwd, async () => {
@@ -16585,6 +16933,7 @@ ${outputText}
16585
16933
  cwd,
16586
16934
  mcpServers,
16587
16935
  settings,
16936
+ sessionSource,
16588
16937
  sessionId,
16589
16938
  resume,
16590
16939
  initializeOptions,
@@ -16592,6 +16941,9 @@ ${outputText}
16592
16941
  );
16593
16942
  });
16594
16943
  } catch (error) {
16944
+ if (error instanceof SessionIdConflictError) {
16945
+ throw RequestError.invalidParams(void 0, error.message);
16946
+ }
16595
16947
  const writerError = getSessionWriterError(error);
16596
16948
  if (writerError) {
16597
16949
  throw new RequestError(writerError.rpcCode, writerError.message, {
@@ -16601,7 +16953,7 @@ ${outputText}
16601
16953
  throw error;
16602
16954
  }
16603
16955
  }
16604
- async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, sessionId, resume, initializeOptions = {}, chatRecording) {
16956
+ async newSessionConfigInRuntimeContext(cwd, mcpServers, settings, sessionSource, sessionId, resume, initializeOptions = {}, chatRecording) {
16605
16957
  const sessionMcpServers = {};
16606
16958
  for (const server of mcpServers) {
16607
16959
  const stdioServer = toStdioServer(server);
@@ -16613,8 +16965,7 @@ ${outputText}
16613
16965
  sessionMcpServers[stdioServer.name] = new MCPServerConfig(
16614
16966
  stdioServer.command,
16615
16967
  stdioServer.args,
16616
- env,
16617
- cwd
16968
+ env
16618
16969
  );
16619
16970
  continue;
16620
16971
  }
@@ -16657,7 +17008,8 @@ ${outputText}
16657
17008
  ...settings.merged,
16658
17009
  experimental: {
16659
17010
  ...settings.merged.experimental,
16660
- sessionWriterLease: this.sessionWriterLeaseEnabledAtStartup
17011
+ sessionWriterLease: this.sessionWriterLeaseEnabledAtStartup,
17012
+ ...sessionSource?.sourceType === "channel" ? { cron: false } : {}
16661
17013
  }
16662
17014
  };
16663
17015
  const sessionArg = resume === true ? { resume: sessionId, sessionId: void 0 } : { sessionId, resume: void 0 };
@@ -16692,8 +17044,17 @@ ${outputText}
16692
17044
  // session. ACP/Zed sessions otherwise leak persisted disabled skills
16693
17045
  // into the first <available_skills> at cold start.
16694
17046
  buildDisabledSkillNamesProvider(settings),
16695
- sessionMcpServers
17047
+ sessionMcpServers,
17048
+ // The daemon owns the settings watcher lifecycle.
17049
+ void 0,
17050
+ // A duplicate caller-supplied session id must fail this one request,
17051
+ // not process.exit(1) the shared ACP child and every session on its
17052
+ // channel. newSessionConfig maps the throw to a RequestError.
17053
+ true
16696
17054
  );
17055
+ if (sessionSource) {
17056
+ config.setSessionSource(sessionSource.sourceType, sessionSource.sourceId);
17057
+ }
16697
17058
  if (chatRecording !== false) {
16698
17059
  this.initializingConfigs.add(config);
16699
17060
  }
@@ -16701,6 +17062,7 @@ ${outputText}
16701
17062
  this.assertManagedSessionAdmission();
16702
17063
  if (this.isTrustedManagedParent()) {
16703
17064
  config.setSessionWriterReclaimPolicy("never");
17065
+ config.setSessionWriterTakeoverPolicy("certified");
16704
17066
  }
16705
17067
  } catch (error) {
16706
17068
  return this.cleanupAfterRequestFailure(
@@ -16732,7 +17094,7 @@ ${outputText}
16732
17094
  sessionId: sid,
16733
17095
  ...event
16734
17096
  }).catch((err) => {
16735
- debugLogger7.debug(
17097
+ debugLogger6.debug(
16736
17098
  `MCP budget extNotification dropped (session=${sid}, kind=${event.kind}): ${err instanceof Error ? err.message : String(err)}`
16737
17099
  );
16738
17100
  });
@@ -16762,7 +17124,7 @@ ${outputText}
16762
17124
  try {
16763
17125
  await config.waitForMcpReady();
16764
17126
  } catch (err) {
16765
- debugLogger7.error(
17127
+ debugLogger6.error(
16766
17128
  `MCP discovery readiness failed: ${err instanceof Error ? err.message : String(err)}`
16767
17129
  );
16768
17130
  return;
@@ -16786,7 +17148,7 @@ ${outputText}
16786
17148
  try {
16787
17149
  await config.refreshAuth(selectedType, true);
16788
17150
  } catch (e) {
16789
- debugLogger7.error(`Authentication failed: ${e}`);
17151
+ debugLogger6.error(`Authentication failed: ${e}`);
16790
17152
  throw RequestError.authRequired(
16791
17153
  {
16792
17154
  authMethods: pickAuthMethodsForAuthRequired(selectedType)
@@ -16969,6 +17331,7 @@ export {
16969
17331
  fetchAllowedGitHub,
16970
17332
  normalizeCoreSettingValue,
16971
17333
  runAcpAgent,
17334
+ selectVisibleHistoryRecords,
16972
17335
  toHttpServer,
16973
17336
  toSseServer,
16974
17337
  toStdioServer