@qwen-code/qwen-code 0.21.12 → 0.21.14-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +13 -5
  2. package/bundled/qc-helper/docs/features/code-review.md +18 -13
  3. package/bundled/qc-helper/docs/features/commands.md +120 -8
  4. package/bundled/qc-helper/docs/features/sub-agents.md +2 -2
  5. package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +1 -1
  6. package/bundled/qc-helper/docs/qwen-serve.md +20 -3
  7. package/bundled/review/SKILL.md +130 -82
  8. package/chunks/{MaxSizedBox-ZSJJ2D5S.js → MaxSizedBox-3PZITE2Y.js} +46 -45
  9. package/chunks/{StandaloneSessionPicker-WHUHQXSA.js → StandaloneSessionPicker-2C34PNGO.js} +68 -67
  10. package/chunks/{acp-startup-profiler-SVPUHLXV.js → acp-startup-profiler-HUYGO57H.js} +2 -2
  11. package/chunks/{acpAgent-7JOAESF5.js → acpAgent-3J4NHAYT.js} +1098 -366
  12. package/chunks/{agent-E6V3VXQR.js → agent-VFX4RPP5.js} +42 -41
  13. package/chunks/agent-headless-6WCF4J6N.js +88 -0
  14. package/chunks/{anthropicContentGenerator-YDT4EOKO.js → anthropicContentGenerator-M7XRJMSK.js} +8 -8
  15. package/chunks/{artifact-tool-4GCQQDZI.js → artifact-tool-GEXTOPVO.js} +2 -2
  16. package/chunks/{askUserQuestion-HZJJLR3Z.js → askUserQuestion-B33XRSB7.js} +2 -2
  17. package/chunks/{bridge-NPBV53UA.js → bridge-XR5ZSR7U.js} +46 -45
  18. package/chunks/{ca-4CQ6MYNQ.js → ca-SLZJD6QH.js} +8 -0
  19. package/chunks/{channel-management-service-OADNGQM3.js → channel-management-service-X6LCQUAD.js} +1 -1
  20. package/chunks/{channel-settings-store-4ODLJ4X2.js → channel-settings-store-Z7BUEUJE.js} +50 -49
  21. package/chunks/{channel-worker-group-IHBIHQ45.js → channel-worker-group-TJ35JDPE.js} +4 -4
  22. package/chunks/{channel-worker-manager-GEHYJ5AE.js → channel-worker-manager-G5LKWGOG.js} +4 -4
  23. package/chunks/{channel-worker-supervisor-ZJIIWM4I.js → channel-worker-supervisor-OEVWBHGT.js} +2 -2
  24. package/chunks/{chunk-47BGDLJG.js → chunk-25GHLMQQ.js} +42 -20
  25. package/chunks/{chunk-2ZWH53I4.js → chunk-2B2BF7P7.js} +3 -3
  26. package/chunks/chunk-2C6HJMG3.js +757 -0
  27. package/chunks/{chunk-WM3LUQLO.js → chunk-2JXDFSVE.js} +6 -6
  28. package/chunks/{chunk-OYWVIXHT.js → chunk-2M55OBEB.js} +1 -1
  29. package/chunks/{chunk-B4VN3VDH.js → chunk-2OA3JMRD.js} +5 -5
  30. package/chunks/{chunk-GZDWTBT3.js → chunk-3EZLLVDF.js} +2 -2
  31. package/chunks/chunk-3PWCMXIR.js +9169 -0
  32. package/chunks/{chunk-XAFIL4BD.js → chunk-4KQ2TI2K.js} +5 -5
  33. package/chunks/{chunk-OPVF453Q.js → chunk-4V4DFJBS.js} +3 -3
  34. package/chunks/{chunk-DPTMKFIH.js → chunk-4ZMS3JCR.js} +43 -12
  35. package/chunks/{chunk-6JEIRPLN.js → chunk-55PIFSP2.js} +2 -2
  36. package/chunks/{chunk-V6OBVAST.js → chunk-57KOJ2KZ.js} +1 -1
  37. package/chunks/{chunk-QLTATTPS.js → chunk-5CVO7YES.js} +1 -1
  38. package/chunks/{chunk-OK47XBYH.js → chunk-5IYS4WWR.js} +1 -1
  39. package/chunks/chunk-5MK45KZ3.js +492 -0
  40. package/chunks/{chunk-OWXFBIB6.js → chunk-6DFPR7CS.js} +1 -1
  41. package/chunks/{chunk-YIGGWOJE.js → chunk-6HY6IF3Z.js} +1 -1
  42. package/chunks/{chunk-XDRXOSAD.js → chunk-6LAPGPVA.js} +7 -5
  43. package/chunks/{chunk-Q4ZPYNIZ.js → chunk-6PDOHRN6.js} +4 -4
  44. package/chunks/{chunk-OWGRUU7F.js → chunk-6QFDQMQX.js} +1 -1
  45. package/chunks/{chunk-MUNA4QDC.js → chunk-6VDPDHIP.js} +29 -8
  46. package/chunks/{chunk-MDNUCDKZ.js → chunk-73G3Z7QS.js} +3 -3
  47. package/chunks/{chunk-VIFA5VJD.js → chunk-7OCSX7FC.js} +1 -1
  48. package/chunks/{chunk-D2RNVVH6.js → chunk-AKBOLMUF.js} +96 -18
  49. package/chunks/{chunk-S6TCTH4Z.js → chunk-AQBHJ2IG.js} +12 -12
  50. package/chunks/{chunk-WCEI6J56.js → chunk-BOJNAPUE.js} +2 -2
  51. package/chunks/{chunk-DAV4QFD5.js → chunk-BQWNIPTE.js} +44 -3
  52. package/chunks/{chunk-HOSVOUDK.js → chunk-BUQDLC2G.js} +3 -0
  53. package/chunks/{chunk-LUISTZXI.js → chunk-CH5OFRV7.js} +2 -2
  54. package/chunks/{chunk-G6MUFRNI.js → chunk-CHHABXPE.js} +1 -1
  55. package/chunks/{chunk-4AOVQPJU.js → chunk-CPHEPGAO.js} +1 -1
  56. package/chunks/{chunk-MS7GNABG.js → chunk-CXJHQVEK.js} +8 -0
  57. package/chunks/{chunk-K5IDV3PC.js → chunk-D34RDOLP.js} +12 -2
  58. package/chunks/{chunk-3GM5DLBI.js → chunk-DGJ7O55J.js} +3 -3
  59. package/chunks/{chunk-7KJPO7YH.js → chunk-DRKYT2TR.js} +2 -2
  60. package/chunks/{chunk-PZW46OTB.js → chunk-DVR7XKO5.js} +2 -2
  61. package/chunks/{chunk-CQ6IPDQW.js → chunk-DZCV3ZYU.js} +3 -3
  62. package/chunks/{chunk-ULNWG62W.js → chunk-E3DYKPYZ.js} +3 -3
  63. package/chunks/{chunk-YCHNAKC5.js → chunk-E5RS7LF4.js} +44 -13
  64. package/chunks/{chunk-4NFY2S7N.js → chunk-E7REAOTN.js} +15 -0
  65. package/chunks/chunk-EOCQCNV4.js +3887 -0
  66. package/chunks/{chunk-D7QGE3RT.js → chunk-FAAUPSY2.js} +1 -1
  67. package/chunks/{chunk-2IVYL3IF.js → chunk-FCTLOVYW.js} +1 -1
  68. package/chunks/{chunk-QPBFRWCP.js → chunk-FS5NGKWC.js} +3 -3
  69. package/chunks/{chunk-RQJA2YYO.js → chunk-G6FFFICU.js} +4 -4
  70. package/chunks/{chunk-36XKGB7E.js → chunk-GV3OIADZ.js} +3 -3
  71. package/chunks/{chunk-3AEKDXKT.js → chunk-H4A72DE5.js} +1 -1
  72. package/chunks/{chunk-IH4Z54RJ.js → chunk-HGPMOXLZ.js} +5 -5
  73. package/chunks/{chunk-DG4IQ6JG.js → chunk-I3N2Z25H.js} +3 -3
  74. package/chunks/{chunk-WI6GIM2M.js → chunk-I7NTHW4C.js} +2 -2
  75. package/chunks/{chunk-ZBB5EZZV.js → chunk-IA2K2HJE.js} +2 -2
  76. package/chunks/{chunk-IRSLAS4M.js → chunk-IOTPI425.js} +19 -11
  77. package/chunks/{chunk-ROIJYS5K.js → chunk-ISRHAMNL.js} +3 -3
  78. package/chunks/{chunk-CGM3E75C.js → chunk-J63PKMYA.js} +3 -3
  79. package/chunks/{chunk-PTSEETCO.js → chunk-J6YS7Z25.js} +107 -13
  80. package/chunks/{chunk-ZQUY3ZJU.js → chunk-K3CECR5C.js} +4 -4
  81. package/chunks/{chunk-QBJYSIQ4.js → chunk-K3LPAED5.js} +53 -12
  82. package/chunks/{chunk-FRHQQC2Z.js → chunk-KBXKR5R2.js} +1 -1
  83. package/chunks/{chunk-4KM2SYK5.js → chunk-KC4WMLZO.js} +1491 -10579
  84. package/chunks/{chunk-IX4PWUDU.js → chunk-KSGWAYNE.js} +14350 -8679
  85. package/chunks/{chunk-CPFFU46D.js → chunk-KV27IEHM.js} +1 -1
  86. package/chunks/{chunk-OR64CU46.js → chunk-L6CCLB3G.js} +1 -1
  87. package/chunks/{chunk-M6NDLY2T.js → chunk-LD5VIJ7S.js} +1 -1
  88. package/chunks/{chunk-GXTMEATA.js → chunk-LLR424CQ.js} +18 -15
  89. package/chunks/{chunk-RDVNSJQU.js → chunk-LRDB2OLB.js} +3 -3
  90. package/chunks/{chunk-LSRI3ND3.js → chunk-MA2HEDVP.js} +1 -1
  91. package/chunks/{chunk-DFVXU5YM.js → chunk-MCG53LWC.js} +1 -1
  92. package/chunks/{chunk-YBVVOSOH.js → chunk-MIPFDQAF.js} +1 -1
  93. package/chunks/{chunk-KRXPRVGL.js → chunk-MLXTMF7H.js} +0 -1
  94. package/chunks/{chunk-BSR5AXZR.js → chunk-NRPXRNN4.js} +1 -1
  95. package/chunks/{chunk-X5SLJOMF.js → chunk-NV6LW6FT.js} +4 -4
  96. package/chunks/{chunk-YILJKX2T.js → chunk-NVRMCWTP.js} +10 -6
  97. package/chunks/chunk-NYWWQ437.js +24 -0
  98. package/chunks/{chunk-AKBFSOC5.js → chunk-OBJYN4MX.js} +2 -2
  99. package/chunks/{chunk-NX4A23LY.js → chunk-OJOP26ET.js} +3 -3
  100. package/chunks/{chunk-3GDBZJD6.js → chunk-OLZSWUZR.js} +7 -7
  101. package/chunks/{chunk-K34GJQOZ.js → chunk-OO4FKHLO.js} +4 -4
  102. package/chunks/{chunk-BSSLSQEW.js → chunk-OSAFWBNR.js} +3 -3
  103. package/chunks/{chunk-TMFWI4RC.js → chunk-OVY67CYC.js} +1 -1
  104. package/chunks/{chunk-6ZKSO6K7.js → chunk-P425IVUK.js} +7 -7
  105. package/chunks/{chunk-4XA4QIUA.js → chunk-PMS7O6SA.js} +1 -1
  106. package/chunks/{chunk-LCX5B364.js → chunk-PPTM4O4R.js} +3 -3
  107. package/chunks/{chunk-VPV7WBVT.js → chunk-PT4I7NBA.js} +1 -1
  108. package/chunks/{chunk-3LDGOQXZ.js → chunk-QECSDJET.js} +6 -6
  109. package/chunks/{chunk-FMIH5KMQ.js → chunk-QEJZUXSK.js} +1 -1
  110. package/chunks/{chunk-NLFLYSS4.js → chunk-QFJ5JHQR.js} +1 -1
  111. package/chunks/{chunk-KWX56CHZ.js → chunk-QIHHJKXT.js} +7 -7
  112. package/chunks/{chunk-TDESMS7M.js → chunk-RAQBBGS6.js} +50 -70
  113. package/chunks/{chunk-KEC5FHLM.js → chunk-ROIYNTHJ.js} +3 -3
  114. package/chunks/{chunk-63FNZTWG.js → chunk-RWDNJBWN.js} +2 -2
  115. package/chunks/{chunk-56HVDG3M.js → chunk-RXHBTKMG.js} +6 -6
  116. package/chunks/{chunk-MAKIANMX.js → chunk-S6CXQKDD.js} +3 -3
  117. package/chunks/{chunk-CIDQISGM.js → chunk-SA7GBPEA.js} +5 -5
  118. package/chunks/{chunk-YX2RDGAL.js → chunk-SBRIBTYN.js} +1 -1
  119. package/chunks/{chunk-TTRH3RTQ.js → chunk-SG7ZP5PG.js} +4 -4
  120. package/chunks/{chunk-XH3KAV2G.js → chunk-SGLPDKRT.js} +3 -3
  121. package/chunks/{chunk-JRIVMPD2.js → chunk-SLILKYV2.js} +4 -4
  122. package/chunks/{chunk-NW2GIPG3.js → chunk-SNQZZ765.js} +2 -2
  123. package/chunks/{chunk-I7BT2MME.js → chunk-SR2LYSMT.js} +1 -1
  124. package/chunks/{chunk-TXP5NGG3.js → chunk-SXCOEJO4.js} +1 -1
  125. package/chunks/{chunk-MELQSJOU.js → chunk-TNPWODIZ.js} +1 -1
  126. package/chunks/{chunk-VLHR7F4E.js → chunk-U6RZRKNM.js} +247 -198
  127. package/chunks/{chunk-HTYND72J.js → chunk-UC67T4SF.js} +3 -1
  128. package/chunks/{chunk-HG3UBTJ4.js → chunk-UYDGFWIJ.js} +609 -23
  129. package/chunks/{chunk-6P5EXEBL.js → chunk-VGAAAMRD.js} +1126 -232
  130. package/chunks/{chunk-WDVDVWJ3.js → chunk-VHPMDDPT.js} +6 -6
  131. package/chunks/{chunk-H7TMVHKE.js → chunk-WGHHA7ZH.js} +1 -1
  132. package/chunks/{chunk-FQDCO3CJ.js → chunk-WP4WIUOJ.js} +7 -0
  133. package/chunks/{chunk-5RUCD4ED.js → chunk-WPVUOVYX.js} +3 -3
  134. package/chunks/{chunk-EJOGLSNJ.js → chunk-WSSH2BNO.js} +2 -2
  135. package/chunks/{chunk-5AFGJNY6.js → chunk-WVIABDXV.js} +4 -4
  136. package/chunks/chunk-WZAD4ZNJ.js +59 -0
  137. package/chunks/{chunk-62X3CM7Q.js → chunk-X3YA3YGG.js} +8 -5
  138. package/chunks/{chunk-EBPLKY6U.js → chunk-XC377TLN.js} +5483 -3168
  139. package/chunks/{chunk-KLOMACIR.js → chunk-XLLKYULU.js} +2 -2
  140. package/chunks/{chunk-QSD4UH74.js → chunk-XO24LIZC.js} +254 -56
  141. package/chunks/{chunk-N4SVADAV.js → chunk-XT4RKHVE.js} +5 -4
  142. package/chunks/{chunk-PVXEJB66.js → chunk-XUJNK7Y6.js} +1 -1
  143. package/chunks/{chunk-YBHUXEC6.js → chunk-YECDICIO.js} +3 -3
  144. package/chunks/{chunk-FA5K6YI2.js → chunk-YFPZ3NNC.js} +36 -4
  145. package/chunks/{chunk-46UV252V.js → chunk-YHC2EYYG.js} +35 -38
  146. package/chunks/{chunk-6SPD4Z7F.js → chunk-YIWH3MKK.js} +8 -3
  147. package/chunks/{chunk-ZMY2P4L3.js → chunk-YXC7JYUI.js} +4 -4
  148. package/chunks/{chunk-TB4YFWXG.js → chunk-YZHRN3CF.js} +2 -2
  149. package/chunks/{chunk-TQDFSQQF.js → chunk-YZOSNW4R.js} +1 -1
  150. package/chunks/{chunk-DD6O3ZRD.js → chunk-ZIGC3MUS.js} +3 -5
  151. package/chunks/{chunk-CZ4OWGQQ.js → chunk-ZXEAEZFN.js} +63 -19
  152. package/chunks/{computer-use-F4URV4TU.js → computer-use-ABECHPS5.js} +42 -41
  153. package/chunks/{config-utils-Z3OW3IQG.js → config-utils-NJQA5YLJ.js} +2 -2
  154. package/chunks/{contextCommand-IGSS2U5J.js → contextCommand-4CD5HZQQ.js} +44 -43
  155. package/chunks/{core-runtime-H5CZDN3A.js → core-runtime-2MOVQ4VX.js} +42 -41
  156. package/chunks/{create-sub-session-XT6DLYOE.js → create-sub-session-KRQULJE6.js} +2 -2
  157. package/chunks/{create-sub-session-PA7MFTHK.js → create-sub-session-L6NNHG5N.js} +46 -44
  158. package/chunks/{cron-create-2JZ2TWTF.js → cron-create-NFRZEOQX.js} +4 -4
  159. package/chunks/{cron-delete-CTPD2P26.js → cron-delete-GFVSVO7C.js} +4 -4
  160. package/chunks/{cron-list-V44KHAF6.js → cron-list-NRW34CLU.js} +4 -4
  161. package/chunks/{daemon-GED37WOX.js → daemon-XH76IXOC.js} +436 -29
  162. package/chunks/{daemon-git-worktree-guard-LZDCNJGV.js → daemon-git-worktree-guard-BLXFEG4Q.js} +44 -43
  163. package/chunks/daemon-status-provider-XGD3TPTO.js +103 -0
  164. package/chunks/daemon-trust-policy-THEGCWPO.js +100 -0
  165. package/chunks/{daemon-trust-policy-monitor-2K2YETMT.js → daemon-trust-policy-monitor-L7L4ACWQ.js} +49 -48
  166. package/chunks/{de-UBEBKG6V.js → de-AH4LGCF5.js} +8 -0
  167. package/chunks/{deferred-core-runtime-FKJ3OYE7.js → deferred-core-runtime-YQLHDUGE.js} +42 -41
  168. package/chunks/discovery-X2NV535U.js +27 -0
  169. package/chunks/{display-image-M2ELAVN4.js → display-image-ON3EYFRD.js} +4 -4
  170. package/chunks/{dist-WJ4BHIEW.js → dist-ESS34DHC.js} +72 -0
  171. package/chunks/{earlyInputCapture-WJBSJQUF.js → earlyInputCapture-PCTXNW7N.js} +43 -42
  172. package/chunks/{edit-X73LA4YO.js → edit-QX2EGWYW.js} +45 -43
  173. package/chunks/{en-X6YV7GME.js → en-MD3GP5YL.js} +8 -0
  174. package/chunks/{enter-worktree-CLRQTIVN.js → enter-worktree-EM3ZZ2SB.js} +42 -41
  175. package/chunks/{enterPlanMode-6BDYUQ5T.js → enterPlanMode-ESCMVAKB.js} +42 -41
  176. package/chunks/{environment-WOAJXJDJ.js → environment-TOJI56YV.js} +45 -44
  177. package/chunks/{errors-7OY5MXYY.js → errors-DZ5FWWEM.js} +44 -43
  178. package/chunks/{exit-worktree-TFFJXCRT.js → exit-worktree-KUIJ36XA.js} +42 -41
  179. package/chunks/exitPlanMode-NFVY54FV.js +86 -0
  180. package/chunks/{fast-path-QQLGC37M.js → fast-path-JLQXJSH6.js} +3 -3
  181. package/chunks/{fast-path-settings-LNOFM2YP.js → fast-path-settings-WHX3J3ZI.js} +2 -2
  182. package/chunks/{fr-VENTC2BS.js → fr-ZEML2JWS.js} +8 -0
  183. package/chunks/{gemini-VHE62IJL.js → gemini-I7OT4FWL.js} +92 -91
  184. package/chunks/{geminiContentGenerator-VSHIEGAQ.js → geminiContentGenerator-GRIS77NJ.js} +6 -6
  185. package/chunks/{glob-VMEEDDLO.js → glob-7TBUUV6R.js} +42 -41
  186. package/chunks/{goal-tools-M4UDAZXP.js → goal-tools-K5OHOJ6B.js} +56 -12
  187. package/chunks/{grep-F4UAR7KX.js → grep-743SYWCZ.js} +42 -41
  188. package/chunks/handleAutoUpdate-GAOYUYOD.js +95 -0
  189. package/chunks/{i18n-ETW24DHW.js → i18n-2ITURYX6.js} +43 -42
  190. package/chunks/{image-gen-YPK2AZT4.js → image-gen-4OIWDZD6.js} +10 -10
  191. package/chunks/initializer-OC7LWA6X.js +101 -0
  192. package/chunks/{installationInfo-P7OTIR4P.js → installationInfo-CO47QX3Q.js} +43 -42
  193. package/chunks/{ja-QHT4EQTO.js → ja-UM5B2HMD.js} +8 -0
  194. package/chunks/{keychain-token-storage-NKKCUHI2.js → keychain-token-storage-3XFJ5ZB2.js} +2 -2
  195. package/chunks/list-ATR2SFWT.js +104 -0
  196. package/chunks/{list-agents-O6WSY4CT.js → list-agents-OSVDFI6S.js} +2 -2
  197. package/chunks/loadedSettingsAdapter-NK4B7AGK.js +98 -0
  198. package/chunks/{loggingContentGenerator-J2J2AANS.js → loggingContentGenerator-3WXBU5TQ.js} +67 -41
  199. package/chunks/{loop-wakeup-GVQRMUKS.js → loop-wakeup-HWVUU5CF.js} +5 -5
  200. package/chunks/{ls-6W2D7TKU.js → ls-D3HUFHDP.js} +4 -4
  201. package/chunks/{lsp-NJ4KFBI2.js → lsp-3QDDJTCS.js} +2 -2
  202. package/chunks/{managed-npm-update-WMV5ITKU.js → managed-npm-update-4SSBWI2D.js} +43 -42
  203. package/chunks/mcp-C62AE2QI.js +98 -0
  204. package/chunks/{monitor-2MM23VDV.js → monitor-FEYEGASA.js} +42 -41
  205. package/chunks/nonInteractiveCli-AJEV5ZWO.js +165 -0
  206. package/chunks/{notebook-edit-QD4TRKLY.js → notebook-edit-SLLTEY4O.js} +46 -44
  207. package/chunks/{openaiContentGenerator-KLHSPVN2.js → openaiContentGenerator-WLUGIAPX.js} +27 -26
  208. package/chunks/{pidfile-RQGZBNXT.js → pidfile-TV2VWUMB.js} +43 -42
  209. package/chunks/{processUtils-HZZDA2VV.js → processUtils-3IN2ZR55.js} +2 -2
  210. package/chunks/proper-lockfile-3LHWIM44.js +8 -0
  211. package/chunks/{pt-VL3I5RNY.js → pt-5BMJ3XYH.js} +8 -0
  212. package/chunks/{qwenContentGenerator-T75M2Z3B.js → qwenContentGenerator-GSGRFPJE.js} +47 -46
  213. package/chunks/{qwenOAuth2-5QZU444W.js → qwenOAuth2-JLSTIS4Z.js} +9 -9
  214. package/chunks/{read-file-LOVUSBJC.js → read-file-6PZZRGZZ.js} +15 -13
  215. package/chunks/{read-mcp-resource-GWCP23WG.js → read-mcp-resource-XD54ZQMC.js} +2 -2
  216. package/chunks/{record-artifact-IYQDEYMV.js → record-artifact-GLU3UWBV.js} +5 -3
  217. package/chunks/{resumeHistoryUtils-LVKSSQII.js → resumeHistoryUtils-5GEWKOOO.js} +49 -48
  218. package/chunks/ripGrep-FX7GBGFN.js +86 -0
  219. package/chunks/{ru-4RCKL4PY.js → ru-6GL66ORV.js} +8 -0
  220. package/chunks/{run-qwen-serve-GZW7B4WK.js → run-qwen-serve-7RHU3NSV.js} +423 -212
  221. package/chunks/{runtime-MYRXEO2E.js → runtime-EPOXAMLP.js} +52 -51
  222. package/chunks/{scheduler-DPTPI6FW.js → scheduler-F4Y7ENVV.js} +44 -43
  223. package/chunks/{sdk-exporters-http-NHBYB5FZ.js → sdk-exporters-http-NC746HLT.js} +3 -3
  224. package/chunks/{sdk-impl-SK4P5WON.js → sdk-impl-YVL7BP6Y.js} +3 -3
  225. package/chunks/{send-message-O7FO63UK.js → send-message-TNBG5EVA.js} +7 -7
  226. package/chunks/{serve-XCG4XCDA.js → serve-LQV4TN5A.js} +49 -50
  227. package/chunks/{server-AWQHKXLG.js → server-IZCKLIYQ.js} +5042 -1725
  228. package/chunks/{session-P5FKNCNR.js → session-52ZGTDVB.js} +87 -85
  229. package/chunks/{settings-CSYVIP2R.js → settings-WCVB34HW.js} +48 -47
  230. package/chunks/{shell-EGTSUO2P.js → shell-33BIUBLH.js} +42 -41
  231. package/chunks/{skill-IFUD72GF.js → skill-IYVQ2QNK.js} +20 -18
  232. package/chunks/{skill-settings-YOE7LBHE.js → skill-settings-YG4ZS4OZ.js} +48 -47
  233. package/chunks/{spawnChannel-PQSZIOLY.js → spawnChannel-BLA4YT4W.js} +44 -43
  234. package/chunks/{standalone-update-RB2EGUSF.js → standalone-update-ALRIPWSM.js} +44 -43
  235. package/chunks/{startInteractiveUI-KMYUJ2MU.js → startInteractiveUI-PISBXWKA.js} +614 -294
  236. package/chunks/{syntheticOutput-DVHJMUGV.js → syntheticOutput-7GWFIDXT.js} +3 -3
  237. package/chunks/{task-create-4NC7PDI4.js → task-create-EILHJJB7.js} +11 -11
  238. package/chunks/{task-list-LBSRMOC7.js → task-list-WGJR6YL5.js} +21 -7
  239. package/chunks/{task-stop-YFNATTIM.js → task-stop-X37KYTKB.js} +2 -2
  240. package/chunks/{task-update-BPLM52GD.js → task-update-XZAHVXJ5.js} +86 -15
  241. package/chunks/{team-create-B6A6MJBT.js → team-create-CIQDCC6A.js} +43 -43
  242. package/chunks/{team-delete-MKYMYBFM.js → team-delete-UEP4QOOT.js} +6 -6
  243. package/chunks/{team-plan-approval-5WO3CXXU.js → team-plan-approval-664XCRB4.js} +42 -41
  244. package/chunks/{terminal-image-renderer-BTRE2GEU.js → terminal-image-renderer-TEBO6ONY.js} +44 -43
  245. package/chunks/theme-manager-3CIFH2JV.js +90 -0
  246. package/chunks/{todoWrite-K5K7NRE5.js → todoWrite-ATS62CAP.js} +4 -4
  247. package/chunks/{tool-search-QNBLXUGR.js → tool-search-IJX5JHJB.js} +19 -17
  248. package/chunks/{total-session-admission-N4E5SFBO.js → total-session-admission-XBK2NVRV.js} +46 -45
  249. package/chunks/{trustedFolders-MQS46LIU.js → trustedFolders-OOFNLRWK.js} +43 -42
  250. package/chunks/{update-relaunch-536KRL33.js → update-relaunch-EIG7EYAQ.js} +5 -5
  251. package/chunks/{updateCheck-QJI2SYWF.js → updateCheck-KYDCBLSF.js} +46 -45
  252. package/chunks/{useAutoAcceptIndicator-7QASHD46.js → useAutoAcceptIndicator-RFX3KNBN.js} +52 -51
  253. package/chunks/{validateNonInterActiveAuth-ZNRGWBLV.js → validateNonInterActiveAuth-MZXSAITU.js} +83 -81
  254. package/chunks/{version-DBEQAFRW.js → version-PJC6ZNXV.js} +1 -1
  255. package/chunks/{web-fetch-MBIVXKPE.js → web-fetch-XXICVGKQ.js} +21 -18
  256. package/chunks/{web-search-4LBIN6VF.js → web-search-LHPM6QWC.js} +9 -9
  257. package/chunks/{workflow-LNMA55HY.js → workflow-4CUO2BV7.js} +159 -57
  258. package/chunks/workspace-providers-status-G4MUGH3X.js +101 -0
  259. package/chunks/{workspace-registration-store-BGRKKIYR.js → workspace-registration-store-QMDMFWBE.js} +2 -2
  260. package/chunks/{workspace-registry-L4NCJ34K.js → workspace-registry-FKBB4MZK.js} +48 -46
  261. package/chunks/{workspace-service-LOXYKYTR.js → workspace-service-TIDTTA65.js} +55 -54
  262. package/chunks/workspace-skills-status-LBC2TZKM.js +101 -0
  263. package/chunks/{workspace-trust-reconciler-H36TCR2S.js → workspace-trust-reconciler-4KJ567XP.js} +58 -56
  264. package/chunks/{write-file-JJAY7JSP.js → write-file-R6LAEER5.js} +42 -41
  265. package/chunks/{zh-TW-SQ4HTSCW.js → zh-TW-LVLBK4KF.js} +8 -0
  266. package/chunks/{zh-LMSTK4WD.js → zh-UBMWS2BJ.js} +8 -0
  267. package/chunks/{zoom-image-4MVVVM7E.js → zoom-image-XLCK6DDK.js} +20 -17
  268. package/cli.js +13 -13
  269. package/locales/ca.js +13 -0
  270. package/locales/de.js +12 -0
  271. package/locales/en.js +11 -0
  272. package/locales/fr.js +13 -0
  273. package/locales/ja.js +13 -0
  274. package/locales/pt.js +12 -0
  275. package/locales/ru.js +12 -0
  276. package/locales/zh-TW.js +11 -0
  277. package/locales/zh.js +11 -0
  278. package/package.json +3 -3
  279. package/web-shell/assets/{arc-B-89zHN4.js → arc-DItbX0DI.js} +1 -1
  280. package/web-shell/assets/{architectureDiagram-3BPJPVTR-BkcOncHk.js → architectureDiagram-3BPJPVTR-CmnIlH8y.js} +1 -1
  281. package/web-shell/assets/{blockDiagram-GPEHLZMM-DQ4yboaF.js → blockDiagram-GPEHLZMM-pObnB9kw.js} +1 -1
  282. package/web-shell/assets/{c4Diagram-AAUBKEIU-C_8ZjPDI.js → c4Diagram-AAUBKEIU-BNBmMS0Y.js} +1 -1
  283. package/web-shell/assets/channel-hZnMfWA9.js +1 -0
  284. package/web-shell/assets/{chunk-2J33WTMH-naKVe1Bm.js → chunk-2J33WTMH-Dz4JBOO6.js} +1 -1
  285. package/web-shell/assets/{chunk-4BX2VUAB-DdoViKT2.js → chunk-4BX2VUAB-Cz2GnvAR.js} +1 -1
  286. package/web-shell/assets/{chunk-55IACEB6-DUDQZEwU.js → chunk-55IACEB6-CC6kOQYx.js} +1 -1
  287. package/web-shell/assets/{chunk-727SXJPM-BqpDTR5s.js → chunk-727SXJPM-Z4lY4gbh.js} +1 -1
  288. package/web-shell/assets/{chunk-AQP2D5EJ-CdmEknkT.js → chunk-AQP2D5EJ-Yz0hZr3D.js} +1 -1
  289. package/web-shell/assets/{chunk-FMBD7UC4-CH7fFTLB.js → chunk-FMBD7UC4-nKmTWTv9.js} +1 -1
  290. package/web-shell/assets/{chunk-ND2GUHAM-ObgSuFKF.js → chunk-ND2GUHAM-CjZz0f6Y.js} +1 -1
  291. package/web-shell/assets/{chunk-QZHKN3VN-D9fKdv_s.js → chunk-QZHKN3VN-Bab3FpuS.js} +1 -1
  292. package/web-shell/assets/classDiagram-4FO5ZUOK-BRnxm8DX.js +1 -0
  293. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BRnxm8DX.js +1 -0
  294. package/web-shell/assets/{cose-bilkent-S5V4N54A-CvzATMx9.js → cose-bilkent-S5V4N54A-BuSAGFox.js} +1 -1
  295. package/web-shell/assets/{dagre-BM42HDAG-M_xU21QW.js → dagre-BM42HDAG-CRZXTg3g.js} +1 -1
  296. package/web-shell/assets/{diagram-2AECGRRQ-CNrl9sW1.js → diagram-2AECGRRQ-BFx1Ayrz.js} +1 -1
  297. package/web-shell/assets/{diagram-5GNKFQAL-CUweVT6T.js → diagram-5GNKFQAL-B2hMZ3gS.js} +1 -1
  298. package/web-shell/assets/{diagram-KO2AKTUF-D3n6Lxjo.js → diagram-KO2AKTUF-DKxAQLmc.js} +1 -1
  299. package/web-shell/assets/{diagram-LMA3HP47-0SeFPK4t.js → diagram-LMA3HP47-Bo1xGqVY.js} +1 -1
  300. package/web-shell/assets/{diagram-OG6HWLK6-DAgyEwge.js → diagram-OG6HWLK6-B9NG78d-.js} +1 -1
  301. package/web-shell/assets/{erDiagram-TEJ5UH35-CzxBBDIK.js → erDiagram-TEJ5UH35-DltQKiqQ.js} +1 -1
  302. package/web-shell/assets/{flowDiagram-I6XJVG4X-B0uj0jyo.js → flowDiagram-I6XJVG4X-5xXGmS4I.js} +1 -1
  303. package/web-shell/assets/{ganttDiagram-6RSMTGT7-DFzcj5km.js → ganttDiagram-6RSMTGT7-bhGL5n0l.js} +1 -1
  304. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-DylJ_Fc9.js → gitGraphDiagram-PVQCEYII-ZYnz9hgh.js} +1 -1
  305. package/web-shell/assets/{index-BKSAnXU9.js → index-CBBeUArD.js} +1 -1
  306. package/web-shell/assets/index-CbgU-jUo.css +5 -0
  307. package/web-shell/assets/index-_nhzXqab.js +1750 -0
  308. package/web-shell/assets/{infoDiagram-5YYISTIA-BYMcJVMI.js → infoDiagram-5YYISTIA-Cg-jamQf.js} +1 -1
  309. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-t1quI1S3.js → ishikawaDiagram-YF4QCWOH-CcmvKlyq.js} +1 -1
  310. package/web-shell/assets/{journeyDiagram-JHISSGLW-YM_QVUJm.js → journeyDiagram-JHISSGLW-BRsOQZp1.js} +1 -1
  311. package/web-shell/assets/{kanban-definition-UN3LZRKU-jw8OddK1.js → kanban-definition-UN3LZRKU-xW-dmEHK.js} +1 -1
  312. package/web-shell/assets/{linear-Dlr3RVuP.js → linear-ClBfEZH2.js} +1 -1
  313. package/web-shell/assets/{mermaid.core-CqGKzNzd.js → mermaid.core-D65NDkzc.js} +5 -5
  314. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BqureoOS.js → mindmap-definition-RKZ34NQL-CyvFslYa.js} +1 -1
  315. package/web-shell/assets/{pieDiagram-4H26LBE5-Da20HkK1.js → pieDiagram-4H26LBE5-BwSefMyG.js} +1 -1
  316. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-BsNlMvJy.js → quadrantDiagram-W4KKPZXB-GqBJspFS.js} +1 -1
  317. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DzVCQCse.js → requirementDiagram-4Y6WPE33-B137PlTJ.js} +1 -1
  318. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BMo16voT.js → sankeyDiagram-5OEKKPKP-maHkkt8i.js} +1 -1
  319. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-Bgi-pdHk.js → sequenceDiagram-3UESZ5HK-DJ1mRaG3.js} +1 -1
  320. package/web-shell/assets/{stateDiagram-AJRCARHV-xaPQXwGk.js → stateDiagram-AJRCARHV-aRmP7Q4i.js} +1 -1
  321. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-Db39gvZ_.js +1 -0
  322. package/web-shell/assets/{timeline-definition-PNZ67QCA-C_9RuvKG.js → timeline-definition-PNZ67QCA-CIQ3BRPA.js} +1 -1
  323. package/web-shell/assets/{vennDiagram-CIIHVFJN-Bgu6vdla.js → vennDiagram-CIIHVFJN-DR9VPd5h.js} +1 -1
  324. package/web-shell/assets/{wardley-L42UT6IY-CFTZ8IrX.js → wardley-L42UT6IY-ZcfIbT4D.js} +1 -1
  325. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BASW9Vmt.js → wardleyDiagram-YWT4CUSO-D0jgPi4T.js} +1 -1
  326. package/web-shell/assets/{xychartDiagram-2RQKCTM6--Nh-CD3F.js → xychartDiagram-2RQKCTM6-BGWU4s5o.js} +1 -1
  327. package/web-shell/index.html +2 -2
  328. package/chunks/agent-headless-OEQNFOMH.js +0 -87
  329. package/chunks/chunk-DEDESZDL.js +0 -358
  330. package/chunks/chunk-MPHPFVKK.js +0 -48
  331. package/chunks/chunk-UI5UGEF4.js +0 -3576
  332. package/chunks/daemon-status-provider-QYM57Z44.js +0 -102
  333. package/chunks/daemon-trust-policy-TSRVEYZR.js +0 -99
  334. package/chunks/discovery-XLHITE74.js +0 -220
  335. package/chunks/exitPlanMode-WDURQMIU.js +0 -85
  336. package/chunks/handleAutoUpdate-GN7Z6QAC.js +0 -94
  337. package/chunks/initializer-UA6KQ7MS.js +0 -100
  338. package/chunks/list-GRAMIQOT.js +0 -103
  339. package/chunks/loadedSettingsAdapter-5O2TDS3I.js +0 -97
  340. package/chunks/mcp-XLP33CAI.js +0 -97
  341. package/chunks/nonInteractiveCli-KTA5K6FS.js +0 -163
  342. package/chunks/ripGrep-ZJSHKB6H.js +0 -85
  343. package/chunks/theme-manager-XL2N5SBY.js +0 -89
  344. package/chunks/workspace-providers-status-PDDMI6ST.js +0 -100
  345. package/chunks/workspace-skills-status-IJ5FOQI6.js +0 -100
  346. package/web-shell/assets/channel-Du2WFns8.js +0 -1
  347. package/web-shell/assets/classDiagram-4FO5ZUOK-Zw0HafH6.js +0 -1
  348. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Zw0HafH6.js +0 -1
  349. package/web-shell/assets/index-BIGQygTL.css +0 -5
  350. package/web-shell/assets/index-J7OMTqAN.js +0 -1789
  351. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-D5RqimXD.js +0 -1
  352. package/chunks/{chunk-SYHXR6WM.js → chunk-4W5U2TUT.js} +3 -3
  353. /package/chunks/{chunk-NTTBXH7U.js → chunk-UGK4K2N2.js} +0 -0
@@ -13,17 +13,22 @@ import {
13
13
  matchMcpServerByRef,
14
14
  parseExtensionRef,
15
15
  parseMcpServerRef
16
- } from "./chunk-X5SLJOMF.js";
16
+ } from "./chunk-NV6LW6FT.js";
17
17
  import {
18
18
  getAvailableCommands,
19
+ getSlashCommandFirstToken,
19
20
  handleSlashCommand,
20
21
  insertAfterFunctionResponses,
21
22
  isSlashCommand,
22
23
  normalizePartList
23
- } from "./chunk-QSD4UH74.js";
24
+ } from "./chunk-XO24LIZC.js";
25
+ import {
26
+ collectContextData,
27
+ formatContextUsageText
28
+ } from "./chunk-X3YA3YGG.js";
24
29
  import {
25
30
  recomputeMcpGating
26
- } from "./chunk-CIDQISGM.js";
31
+ } from "./chunk-SA7GBPEA.js";
27
32
  import {
28
33
  SessionIdConflictError,
29
34
  appEvents,
@@ -31,44 +36,40 @@ import {
31
36
  cleanupReviewWorktreeLeases,
32
37
  loadCliConfig,
33
38
  normalizeDisabledToolList
34
- } from "./chunk-IX4PWUDU.js";
39
+ } from "./chunk-KSGWAYNE.js";
35
40
  import {
36
41
  getCommandSubcommandNames
37
- } from "./chunk-4XA4QIUA.js";
42
+ } from "./chunk-PMS7O6SA.js";
38
43
  import {
39
44
  getEffectiveSupportedModes
40
- } from "./chunk-MDNUCDKZ.js";
45
+ } from "./chunk-73G3Z7QS.js";
46
+ import "./chunk-4WGODMVR.js";
41
47
  import "./chunk-3SH53ANB.js";
42
48
  import "./chunk-NYX53SV4.js";
43
- import "./chunk-NW2GIPG3.js";
44
- import {
45
- collectContextData,
46
- formatContextUsageText
47
- } from "./chunk-62X3CM7Q.js";
48
- import "./chunk-4WGODMVR.js";
49
+ import "./chunk-SNQZZ765.js";
49
50
  import {
50
51
  isGoalStatusKind
51
52
  } from "./chunk-EKTCKZV5.js";
52
- import "./chunk-OYWVIXHT.js";
53
+ import "./chunk-2M55OBEB.js";
53
54
  import {
54
55
  startNonInteractiveOpenAILogHousekeeping
55
- } from "./chunk-5AFGJNY6.js";
56
+ } from "./chunk-WVIABDXV.js";
56
57
  import "./chunk-KW7NOTN6.js";
57
- import "./chunk-ZQUY3ZJU.js";
58
- import "./chunk-RDVNSJQU.js";
59
- import "./chunk-OPVF453Q.js";
60
- import "./chunk-YAF2MQZ6.js";
61
- import {
62
- computeCpuPercent
63
- } from "./chunk-LBOVL47Y.js";
64
- import "./chunk-TDESMS7M.js";
65
- import "./chunk-6H67XLET.js";
66
58
  import {
67
59
  beginAcpBootstrapConfigProfiling,
68
60
  buildAndFreezeAcpStartupProfile,
69
61
  endAcpBootstrapConfigProfiling,
70
62
  markAcpStartup
71
- } from "./chunk-FMIH5KMQ.js";
63
+ } from "./chunk-QEJZUXSK.js";
64
+ import "./chunk-K3CECR5C.js";
65
+ import "./chunk-LRDB2OLB.js";
66
+ import "./chunk-4V4DFJBS.js";
67
+ import "./chunk-YAF2MQZ6.js";
68
+ import {
69
+ computeCpuPercent
70
+ } from "./chunk-LBOVL47Y.js";
71
+ import "./chunk-RAQBBGS6.js";
72
+ import "./chunk-6H67XLET.js";
72
73
  import {
73
74
  GENERATION_MAX_PROMPT_BYTES,
74
75
  GENERATION_TIMEOUT_MS,
@@ -91,7 +92,7 @@ import {
91
92
  shouldSuppressRememberErrorDetails,
92
93
  workspaceMemoryFailureCode,
93
94
  workspaceMemoryFailureDiagnostics
94
- } from "./chunk-CZ4OWGQQ.js";
95
+ } from "./chunk-ZXEAEZFN.js";
95
96
  import {
96
97
  BaseEmitter,
97
98
  HistoryReplayer,
@@ -99,11 +100,13 @@ import {
99
100
  ToolCallEmitter,
100
101
  createTranscriptMessageUpdate,
101
102
  createTranscriptUsageUpdate,
102
- hasFullSessionContext
103
- } from "./chunk-UI5UGEF4.js";
104
- import "./chunk-TMFWI4RC.js";
105
- import "./chunk-4NFY2S7N.js";
106
- import "./chunk-V6OBVAST.js";
103
+ hasFullSessionContext,
104
+ observeAcpToolResultProjection,
105
+ observeAcpToolResultWire
106
+ } from "./chunk-EOCQCNV4.js";
107
+ import "./chunk-OVY67CYC.js";
108
+ import "./chunk-E7REAOTN.js";
109
+ import "./chunk-57KOJ2KZ.js";
107
110
  import "./chunk-2MIN6GRR.js";
108
111
  import "./chunk-QHTIBUWB.js";
109
112
  import "./chunk-3Z43GZUQ.js";
@@ -121,18 +124,25 @@ import {
121
124
  buildPermissionSettings,
122
125
  normalizePermissionRules,
123
126
  readPermissionRuleSet
124
- } from "./chunk-YX2RDGAL.js";
127
+ } from "./chunk-SBRIBTYN.js";
125
128
  import {
126
129
  MAX_AUDIO_BYTES,
127
130
  sanitizeVoiceErrorMessage,
128
131
  transcribeVoiceAudio
129
- } from "./chunk-LCX5B364.js";
132
+ } from "./chunk-PPTM4O4R.js";
130
133
  import {
131
134
  readVoiceModel
132
- } from "./chunk-VIFA5VJD.js";
133
- import "./chunk-H7TMVHKE.js";
134
- import "./chunk-NTTBXH7U.js";
135
- import "./chunk-RQJA2YYO.js";
135
+ } from "./chunk-7OCSX7FC.js";
136
+ import "./chunk-WGHHA7ZH.js";
137
+ import "./chunk-UGK4K2N2.js";
138
+ import "./chunk-G6FFFICU.js";
139
+ import {
140
+ SESSION_SOURCE_META_KEY,
141
+ parseSessionSource
142
+ } from "./chunk-VGAAAMRD.js";
143
+ import "./chunk-7U5G6JXI.js";
144
+ import "./chunk-WCCLLK7X.js";
145
+ import "./chunk-OCPBI7J5.js";
136
146
  import {
137
147
  ACP_ROUTE_ID_PREFIX,
138
148
  buildAcpModelOptions,
@@ -141,32 +151,26 @@ import {
141
151
  parseAcpModelOption,
142
152
  resolveAcpModelOption,
143
153
  sanitizeProviderBaseUrl
144
- } from "./chunk-ROIJYS5K.js";
154
+ } from "./chunk-ISRHAMNL.js";
145
155
  import {
146
156
  mapSkillConfigToStatus
147
157
  } from "./chunk-BGXZBI5B.js";
148
158
  import {
149
159
  resolveSkillSettings
150
160
  } from "./chunk-Z4X5MTRT.js";
151
- import "./chunk-WM3LUQLO.js";
152
- import "./chunk-IH4Z54RJ.js";
161
+ import "./chunk-2JXDFSVE.js";
162
+ import "./chunk-HGPMOXLZ.js";
153
163
  import "./chunk-57OAHC2Y.js";
154
- import "./chunk-BSR5AXZR.js";
164
+ import "./chunk-NRPXRNN4.js";
155
165
  import "./chunk-45NQKMYB.js";
156
- import "./chunk-OK47XBYH.js";
166
+ import "./chunk-5IYS4WWR.js";
167
+ import "./chunk-V6WHFGST.js";
157
168
  import {
158
169
  createLoadedSettingsAdapter
159
- } from "./chunk-2IVYL3IF.js";
160
- import {
161
- SESSION_SOURCE_META_KEY,
162
- parseSessionSource
163
- } from "./chunk-6P5EXEBL.js";
164
- import "./chunk-7U5G6JXI.js";
165
- import "./chunk-WCCLLK7X.js";
166
- import "./chunk-OCPBI7J5.js";
170
+ } from "./chunk-FCTLOVYW.js";
167
171
  import {
168
172
  ndJsonStream
169
- } from "./chunk-DAV4QFD5.js";
173
+ } from "./chunk-BQWNIPTE.js";
170
174
  import {
171
175
  ACP_PREFLIGHT_KINDS,
172
176
  IDLE_HOOK_EVENTS,
@@ -174,9 +178,9 @@ import {
174
178
  SERVE_STATUS_EXT_METHODS,
175
179
  STATUS_SCHEMA_VERSION,
176
180
  mapDomainErrorToErrorKind
177
- } from "./chunk-HTYND72J.js";
181
+ } from "./chunk-UC67T4SF.js";
178
182
  import "./chunk-ZLCT4C5A.js";
179
- import "./chunk-V6WHFGST.js";
183
+ import "./chunk-DRKYT2TR.js";
180
184
  import {
181
185
  ACTIVE_WORK_CLOSE_IF_UNHELD_PARAM,
182
186
  ACTIVE_WORK_HEARTBEAT_META_KEY,
@@ -188,6 +192,7 @@ import {
188
192
  CHANNEL_STARTUP_PROFILE_VERSION,
189
193
  CLIENT_MCP_OVER_WS_CONFIG_FLAG,
190
194
  DAEMON_CHANNEL_DELIVERY_META_KEY,
195
+ DAEMON_MEDIA_REFERENCES_META_KEY,
191
196
  DAEMON_MODEL_PROMPT_META_KEY,
192
197
  DAEMON_PROMPT_DISPLAY_TEXT_META_KEY,
193
198
  LOAD_REPLAY_BULK_MODE,
@@ -206,7 +211,7 @@ import {
206
211
  WORKTREE_MCP_DEFER_META_KEY,
207
212
  clampActiveWorkIntervalMs,
208
213
  isValidTrustedModelPrompt
209
- } from "./chunk-FQDCO3CJ.js";
214
+ } from "./chunk-WP4WIUOJ.js";
210
215
  import {
211
216
  NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE,
212
217
  isNotCurrentlyGeneratingCancelError
@@ -227,7 +232,6 @@ import {
227
232
  SHELL_EXECUTING_TOOL_NAMES,
228
233
  isValidExternalToolGuardDenialReason
229
234
  } from "./chunk-3VUENPWF.js";
230
- import "./chunk-3AEKDXKT.js";
231
235
  import {
232
236
  ACP_EVENT_LOOP_STALL_RESTART_MS,
233
237
  CHANNEL_PROMPT_META_KEY
@@ -237,10 +241,11 @@ import {
237
241
  PROTOCOL_VERSION,
238
242
  RequestError
239
243
  } from "./chunk-IW6RQPQB.js";
244
+ import "./chunk-H4A72DE5.js";
240
245
  import {
241
246
  assembleMcpServers,
242
247
  loadMcpApprovals
243
- } from "./chunk-3LDGOQXZ.js";
248
+ } from "./chunk-QECSDJET.js";
244
249
  import {
245
250
  getOutputLanguageFilePath,
246
251
  getPersistScopeForModelSelection,
@@ -249,9 +254,9 @@ import {
249
254
  resolveOutputLanguageOrPreserveAuto,
250
255
  updateOutputLanguageFile,
251
256
  writeOutputLanguageAndRegisterPath
252
- } from "./chunk-3GDBZJD6.js";
257
+ } from "./chunk-OLZSWUZR.js";
253
258
  import "./chunk-RKUWKYED.js";
254
- import "./chunk-FA5K6YI2.js";
259
+ import "./chunk-YFPZ3NNC.js";
255
260
  import "./chunk-GOXKNSDZ.js";
256
261
  import {
257
262
  getSystemDefaultsPath,
@@ -260,7 +265,7 @@ import {
260
265
  import {
261
266
  getCurrentLanguage,
262
267
  setLanguageAsync
263
- } from "./chunk-IRSLAS4M.js";
268
+ } from "./chunk-IOTPI425.js";
264
269
  import {
265
270
  SUPPORTED_LANGUAGES
266
271
  } from "./chunk-5EJZE3FP.js";
@@ -268,18 +273,17 @@ import {
268
273
  findEnvFiles,
269
274
  preResolveHomeEnvOverrides,
270
275
  reloadEnvironment
271
- } from "./chunk-XH3KAV2G.js";
276
+ } from "./chunk-SGLPDKRT.js";
272
277
  import {
273
278
  ENV_ACP_REPEATED_TOOL_FAILURE_GUARD
274
- } from "./chunk-MS7GNABG.js";
275
- import "./chunk-7KJPO7YH.js";
276
- import "./chunk-OWXFBIB6.js";
279
+ } from "./chunk-CXJHQVEK.js";
280
+ import "./chunk-6DFPR7CS.js";
277
281
  import "./chunk-WZMH7II3.js";
278
282
  import {
279
283
  isFolderTrustEnabled,
280
284
  isWorkspaceTrusted,
281
285
  loadTrustedFolders
282
- } from "./chunk-ZMY2P4L3.js";
286
+ } from "./chunk-YXC7JYUI.js";
283
287
  import "./chunk-NPQ5ZKRP.js";
284
288
  import "./chunk-MR3PXB6E.js";
285
289
  import "./chunk-XFSFZCM5.js";
@@ -287,6 +291,7 @@ import {
287
291
  ALL_PROVIDERS,
288
292
  APPROVAL_MODE_INFO,
289
293
  BTW_MAX_INPUT_LENGTH,
294
+ BranchPointInvalidError,
290
295
  ExtensionManager,
291
296
  GLOBAL_DUPLICATE_THRESHOLD,
292
297
  IMAGE_CAPABILITY,
@@ -317,6 +322,8 @@ import {
317
322
  SessionWriterError,
318
323
  SessionWriterUnavailableError,
319
324
  TURN_INTERRUPTION_HISTORY_TAIL_COUNT,
325
+ TURN_RESULT_CODE_TEXT_TRUNCATED,
326
+ TURN_RESULT_TEXT_MAX_CHARS,
320
327
  WorkspaceMcpBudget,
321
328
  abortGoalForStopHookCap,
322
329
  acquireSleepInhibitor,
@@ -381,12 +388,15 @@ import {
381
388
  isDenialFallbackReason,
382
389
  isGatedMcpScope,
383
390
  isPlanModeBlocked,
391
+ isTurnResultRecordPayload,
384
392
  markDuplicateProviderToolCallResponseSent,
385
393
  matchesAnyServerPattern,
386
394
  mcpServerRequiresOAuth,
387
395
  needsConfirmation,
388
396
  normalizeEventPayload,
389
397
  normalizeSnapshotPayload,
398
+ normalizeTurnResultError,
399
+ observeToolResultBoundary,
390
400
  persistPermissionOutcome,
391
401
  projectGoalStateToLegacy,
392
402
  readManyFiles,
@@ -406,29 +416,31 @@ import {
406
416
  shouldHaltOnTurnToolCallCap,
407
417
  shouldRunAutoModeForCall,
408
418
  subagentGenerator,
419
+ toolResultBoundaryArtifact,
420
+ toolResultPartDiagnosticValues,
409
421
  truncateNotificationLabel,
410
422
  updateSetting,
411
423
  validatePlanModeShellApproval,
412
424
  validatePlanModeShellContext
413
- } from "./chunk-EBPLKY6U.js";
425
+ } from "./chunk-XC377TLN.js";
414
426
  import "./chunk-GOFAQQZA.js";
415
427
  import "./chunk-5M6IDOMF.js";
416
428
  import "./chunk-TWPJO254.js";
417
429
  import {
418
430
  external_exports
419
431
  } from "./chunk-CQ35AJ4Z.js";
420
- import "./chunk-QPBFRWCP.js";
421
- import "./chunk-JRIVMPD2.js";
422
- import "./chunk-YILJKX2T.js";
423
- import "./chunk-D2RNVVH6.js";
432
+ import "./chunk-FS5NGKWC.js";
433
+ import "./chunk-SLILKYV2.js";
434
+ import "./chunk-NVRMCWTP.js";
435
+ import "./chunk-AKBOLMUF.js";
424
436
  import {
425
437
  parsePositiveIntegerEnv
426
438
  } from "./chunk-6PVPNMXU.js";
427
- import "./chunk-I7BT2MME.js";
439
+ import "./chunk-SR2LYSMT.js";
428
440
  import "./chunk-IRH27ZC2.js";
429
441
  import "./chunk-QHWCP53L.js";
430
- import "./chunk-AKBFSOC5.js";
431
- import "./chunk-DEDESZDL.js";
442
+ import "./chunk-OBJYN4MX.js";
443
+ import "./chunk-2C6HJMG3.js";
432
444
  import {
433
445
  promptIdContext,
434
446
  todoWorkChainContext
@@ -436,14 +448,17 @@ import {
436
448
  import "./chunk-T26EAKDL.js";
437
449
  import "./chunk-ZPJWUGCS.js";
438
450
  import "./chunk-CPBF7KYF.js";
439
- import "./chunk-5RUCD4ED.js";
440
- import "./chunk-KRXPRVGL.js";
451
+ import {
452
+ APPROVAL_MODES
453
+ } from "./chunk-RWDNJBWN.js";
454
+ import "./chunk-WPVUOVYX.js";
441
455
  import {
442
456
  HookEventName,
443
457
  createHookOutput
444
- } from "./chunk-YBVVOSOH.js";
445
- import "./chunk-CPFFU46D.js";
446
- import "./chunk-ULNWG62W.js";
458
+ } from "./chunk-MIPFDQAF.js";
459
+ import "./chunk-MLXTMF7H.js";
460
+ import "./chunk-KV27IEHM.js";
461
+ import "./chunk-E3DYKPYZ.js";
447
462
  import {
448
463
  GoalPersistenceUnavailableError,
449
464
  emptyGoalSnapshot,
@@ -451,11 +466,8 @@ import {
451
466
  parseGoalSnapshotV2,
452
467
  parseGoalStateCause,
453
468
  wrapUserPromptSubmitContext
454
- } from "./chunk-DPTMKFIH.js";
455
- import {
456
- APPROVAL_MODES
457
- } from "./chunk-63FNZTWG.js";
458
- import "./chunk-3GM5DLBI.js";
469
+ } from "./chunk-4ZMS3JCR.js";
470
+ import "./chunk-DGJ7O55J.js";
459
471
  import {
460
472
  AgentOutputMessageCapture,
461
473
  addAgentInputMessageAttributes,
@@ -466,43 +478,42 @@ import {
466
478
  registerAcpEventLoopLagGauge,
467
479
  startEventLoopLagMonitor,
468
480
  withDaemonSpan
469
- } from "./chunk-K34GJQOZ.js";
481
+ } from "./chunk-OO4FKHLO.js";
470
482
  import "./chunk-SAH4BD2J.js";
471
- import "./chunk-KLOMACIR.js";
483
+ import "./chunk-XLLKYULU.js";
472
484
  import {
473
485
  runWithRuntimeContentGenerator
474
- } from "./chunk-VPV7WBVT.js";
486
+ } from "./chunk-PT4I7NBA.js";
475
487
  import "./chunk-S6LOFUVP.js";
476
488
  import "./chunk-2J3OJGTL.js";
477
489
  import {
478
490
  FORK_SUBAGENT_TYPE,
479
491
  getStartupContextLength,
480
492
  isSystemReminderContent
481
- } from "./chunk-TTRH3RTQ.js";
493
+ } from "./chunk-SG7ZP5PG.js";
482
494
  import "./chunk-K623ENWT.js";
483
495
  import "./chunk-AQ37AY7B.js";
484
- import "./chunk-FRHQQC2Z.js";
496
+ import "./chunk-KBXKR5R2.js";
485
497
  import {
486
498
  clearCachedCredentialFile,
487
499
  qwenOAuth2Events
488
- } from "./chunk-DG4IQ6JG.js";
500
+ } from "./chunk-I3N2Z25H.js";
489
501
  import "./chunk-NAVJD2PQ.js";
490
- import "./chunk-KEC5FHLM.js";
491
- import "./chunk-2ZWH53I4.js";
502
+ import "./chunk-ROIYNTHJ.js";
503
+ import "./chunk-2B2BF7P7.js";
492
504
  import "./chunk-P3QQPMQA.js";
493
- import "./chunk-TB4YFWXG.js";
494
- import "./chunk-D7QGE3RT.js";
505
+ import "./chunk-YZHRN3CF.js";
506
+ import "./chunk-FAAUPSY2.js";
495
507
  import {
496
508
  REASONING_EFFORT_TIERS,
497
509
  applyReasoningEffort
498
510
  } from "./chunk-KM73TBQ4.js";
499
- import "./chunk-MPHPFVKK.js";
500
511
  import "./chunk-AXMWHKXA.js";
501
512
  import {
502
513
  getToolCallPreparations
503
514
  } from "./chunk-GLCZKT5V.js";
504
515
  import "./chunk-DJ2GSRLV.js";
505
- import "./chunk-NLFLYSS4.js";
516
+ import "./chunk-QFJ5JHQR.js";
506
517
  import {
507
518
  ConversationFinishedEvent,
508
519
  DiscoveredMCPTool,
@@ -516,11 +527,9 @@ import {
516
527
  apiActivityTracker,
517
528
  formatFullTurnVisionNotice,
518
529
  formatVisionBridgeNotice,
519
- getAllGeminiMdFilenames,
520
530
  getFullTurnVisionModelSelector,
521
531
  getInvocationContext,
522
532
  getMCPServerStatus,
523
- getSpecificMimeType,
524
533
  hasImageParts,
525
534
  logConversationFinishedEvent,
526
535
  logLoopDetected,
@@ -535,17 +544,21 @@ import {
535
544
  shouldRunVisionBridge,
536
545
  splitImageParts,
537
546
  uiTelemetryService
538
- } from "./chunk-4KM2SYK5.js";
547
+ } from "./chunk-KC4WMLZO.js";
539
548
  import "./chunk-YRLW2MSX.js";
540
549
  import "./chunk-VGC4I5JJ.js";
550
+ import {
551
+ getAllGeminiMdFilenames,
552
+ getSpecificMimeType
553
+ } from "./chunk-3PWCMXIR.js";
541
554
  import {
542
555
  getAutoMemoryRoot,
543
556
  getUserAutoMemoryRoot
544
- } from "./chunk-G6MUFRNI.js";
557
+ } from "./chunk-CHHABXPE.js";
545
558
  import {
546
559
  runSideQuery
547
- } from "./chunk-LSRI3ND3.js";
548
- import "./chunk-PVXEJB66.js";
560
+ } from "./chunk-MA2HEDVP.js";
561
+ import "./chunk-XUJNK7Y6.js";
549
562
  import {
550
563
  BaseDeclarativeTool,
551
564
  BaseToolInvocation,
@@ -553,20 +566,21 @@ import {
553
566
  ToolNames,
554
567
  canonicalToolName,
555
568
  isShellProgressData
556
- } from "./chunk-YIGGWOJE.js";
569
+ } from "./chunk-6HY6IF3Z.js";
557
570
  import {
558
571
  AuthType,
559
572
  preloadContentGenerator
560
- } from "./chunk-KWX56CHZ.js";
573
+ } from "./chunk-QIHHJKXT.js";
561
574
  import "./chunk-F6WFNA7U.js";
562
- import "./chunk-46UV252V.js";
575
+ import "./chunk-WZAD4ZNJ.js";
563
576
  import {
564
577
  DEFAULT_TOKEN_LIMIT,
565
578
  tokenLimit
566
579
  } from "./chunk-FPGTNKCP.js";
567
- import "./chunk-4AOVQPJU.js";
568
- import "./chunk-PZW46OTB.js";
569
- import "./chunk-YBHUXEC6.js";
580
+ import "./chunk-YHC2EYYG.js";
581
+ import "./chunk-CPHEPGAO.js";
582
+ import "./chunk-DVR7XKO5.js";
583
+ import "./chunk-YECDICIO.js";
570
584
  import {
571
585
  endToolExecutionSpan,
572
586
  endToolSpan,
@@ -577,23 +591,23 @@ import {
577
591
  startToolExecutionSpan,
578
592
  startToolSpan,
579
593
  withInteractionSpan
580
- } from "./chunk-N4SVADAV.js";
594
+ } from "./chunk-XT4RKHVE.js";
581
595
  import "./chunk-HHJLM3WQ.js";
582
596
  import {
583
597
  sessionIdContext
584
- } from "./chunk-K5IDV3PC.js";
598
+ } from "./chunk-D34RDOLP.js";
585
599
  import {
586
600
  Storage,
587
601
  createDebugLogger,
588
602
  getErrorMessage,
589
603
  getErrorStatus,
590
604
  isSubpath
591
- } from "./chunk-HOSVOUDK.js";
605
+ } from "./chunk-BUQDLC2G.js";
592
606
  import "./chunk-VOQXFAY5.js";
593
- import "./chunk-MELQSJOU.js";
607
+ import "./chunk-TNPWODIZ.js";
594
608
  import {
595
609
  runExitCleanup
596
- } from "./chunk-OR64CU46.js";
610
+ } from "./chunk-L6CCLB3G.js";
597
611
  import {
598
612
  writeStderrLine,
599
613
  writeStderrLineSafe
@@ -2212,6 +2226,7 @@ var SubAgentTracker = class {
2212
2226
  success: event.success,
2213
2227
  message: event.responseParts ?? [],
2214
2228
  resultDisplay: event.resultDisplay,
2229
+ boundaryArtifact: event.boundaryArtifact,
2215
2230
  args: state?.args,
2216
2231
  subagentMeta: this.subagentMeta
2217
2232
  }).catch((error) => {
@@ -3033,6 +3048,30 @@ var NEW_PROMPT_ABORT_REASON = "qwen:new-prompt";
3033
3048
  var SESSION_DISPOSE_ABORT_REASON = "qwen:session-dispose";
3034
3049
  var DAEMON_RETRY_META_KEY = "qwen.daemon.retry";
3035
3050
  var DAEMON_CONTINUE_META_KEY = "qwen.daemon.continueLastTurn";
3051
+ var MAX_DAEMON_MEDIA_REFERENCES = 256;
3052
+ function readDaemonMediaReferences(value) {
3053
+ if (!Array.isArray(value) || value.length === 0 || value.length > MAX_DAEMON_MEDIA_REFERENCES) {
3054
+ return void 0;
3055
+ }
3056
+ const references = [];
3057
+ for (const item of value) {
3058
+ if (!item || typeof item !== "object" || Array.isArray(item)) {
3059
+ return void 0;
3060
+ }
3061
+ const reference = item;
3062
+ if (reference["type"] !== "image" || typeof reference["mediaId"] !== "string" || reference["mediaId"].length === 0 || reference["mediaId"].length > 128 || typeof reference["mimeType"] !== "string" || reference["mimeType"].length === 0 || reference["mimeType"].length > 128 || typeof reference["size"] !== "number" || !Number.isSafeInteger(reference["size"]) || reference["size"] <= 0) {
3063
+ return void 0;
3064
+ }
3065
+ references.push({
3066
+ type: reference["type"],
3067
+ mediaId: reference["mediaId"],
3068
+ mimeType: reference["mimeType"],
3069
+ size: reference["size"]
3070
+ });
3071
+ }
3072
+ return references;
3073
+ }
3074
+ __name(readDaemonMediaReferences, "readDaemonMediaReferences");
3036
3075
  var TODO_STOP_GUARD_PROMPT_PREFIX = "[Todo Stop Guard] ";
3037
3076
  var TODO_STOP_GUARD_PROMPT_BODY_SUFFIX = " todo item(s) are still pending or in progress. Continue executing the current task now. Do not ask the user whether to continue. If progress requires user input, use the structured question or permission flow. If progress depends on external state, report the blocker explicitly.";
3038
3077
  var TODO_STOP_GUARD_FINAL_PROMPT_SUFFIX = " This is the final automatic continuation. Before ending, either complete/update the todos or report the completed progress and the exact blocker.";
@@ -3385,6 +3424,43 @@ function hasInlineMediaContentBlock(content) {
3385
3424
  return content.some((part) => part.type === "image" || part.type === "audio");
3386
3425
  }
3387
3426
  __name(hasInlineMediaContentBlock, "hasInlineMediaContentBlock");
3427
+ function extractTurnPromptText(content) {
3428
+ let hasImage = false;
3429
+ for (const block of content) {
3430
+ if (block.type === "image") hasImage = true;
3431
+ if (block.type === "text" && block.text.length > 0) return block.text;
3432
+ }
3433
+ return hasImage ? "[image]" : "";
3434
+ }
3435
+ __name(extractTurnPromptText, "extractTurnPromptText");
3436
+ function truncateTurnText(text) {
3437
+ if (text.length <= TURN_RESULT_TEXT_MAX_CHARS) {
3438
+ return { text, truncated: false };
3439
+ }
3440
+ return { text: text.slice(0, TURN_RESULT_TEXT_MAX_CHARS), truncated: true };
3441
+ }
3442
+ __name(truncateTurnText, "truncateTurnText");
3443
+ function stripReferencedInlineDataParts(parts, content) {
3444
+ const coveredByKey = /* @__PURE__ */ new Map();
3445
+ for (const block of content) {
3446
+ if (block.type !== "image") continue;
3447
+ const key = `${block.mimeType}\0${block.data}`;
3448
+ coveredByKey.set(key, (coveredByKey.get(key) ?? 0) + 1);
3449
+ }
3450
+ if (coveredByKey.size === 0) return parts;
3451
+ return parts.filter((part) => {
3452
+ const inlineData = part.inlineData;
3453
+ if (inlineData === void 0 || typeof inlineData.data !== "string") {
3454
+ return true;
3455
+ }
3456
+ const key = `${inlineData.mimeType ?? ""}\0${inlineData.data}`;
3457
+ const remaining = coveredByKey.get(key) ?? 0;
3458
+ if (remaining === 0) return true;
3459
+ coveredByKey.set(key, remaining - 1);
3460
+ return false;
3461
+ });
3462
+ }
3463
+ __name(stripReferencedInlineDataParts, "stripReferencedInlineDataParts");
3388
3464
  function capMidTurnDrainItems(items, fieldName) {
3389
3465
  if (items.length <= MAX_MID_TURN_DRAIN_ITEMS) return items;
3390
3466
  debugLogger6.warn(
@@ -3421,14 +3497,18 @@ function getValidMidTurnContentBlocks(content, displayText) {
3421
3497
  return validBlocks;
3422
3498
  }
3423
3499
  __name(getValidMidTurnContentBlocks, "getValidMidTurnContentBlocks");
3424
- function getStructuredMidTurnDisplayText(content, displayText) {
3500
+ function getStructuredMidTurnDisplayText(content, displayText, willPersistReferences) {
3425
3501
  if (typeof displayText === "string" && displayText.trim().length > 0) {
3426
3502
  return displayText.trim();
3427
3503
  }
3428
3504
  const text = content.filter(
3429
3505
  (part) => part.type === "text"
3430
3506
  ).map((part) => part.text).join("\n").trim();
3431
- return text || "[User message with attachments]";
3507
+ if (text) return text;
3508
+ if (!willPersistReferences && hasInlineMediaContentBlock(content)) {
3509
+ return "[User message with attachments]";
3510
+ }
3511
+ return text;
3432
3512
  }
3433
3513
  __name(getStructuredMidTurnDisplayText, "getStructuredMidTurnDisplayText");
3434
3514
  function parseMidTurnDrainResponse(response) {
@@ -3444,14 +3524,20 @@ function parseMidTurnDrainResponse(response) {
3444
3524
  item["displayText"]
3445
3525
  );
3446
3526
  if (content.length === 0) return [];
3527
+ const mediaReferences = readDaemonMediaReferences(
3528
+ item["mediaReferences"]
3529
+ );
3530
+ const willPersistReferences = mediaReferences !== void 0 && mediaReferences.length === content.filter((block) => block.type === "image").length;
3447
3531
  return [
3448
3532
  {
3449
3533
  kind: "structured",
3450
3534
  content,
3451
3535
  displayText: getStructuredMidTurnDisplayText(
3452
3536
  content,
3453
- item["displayText"]
3454
- )
3537
+ item["displayText"],
3538
+ willPersistReferences
3539
+ ),
3540
+ ...mediaReferences ? { mediaReferences } : {}
3455
3541
  }
3456
3542
  ];
3457
3543
  }
@@ -3476,7 +3562,7 @@ function isValidMidTurnDrainResponse(response, requireQueuedPromptState) {
3476
3562
  }
3477
3563
  if (Array.isArray(response["items"])) {
3478
3564
  return response["items"].every(
3479
- (item) => isRecord2(item) && Array.isArray(item["content"]) && item["content"].length > 0 && item["content"].every(isContentBlock)
3565
+ (item) => isRecord2(item) && Array.isArray(item["content"]) && item["content"].length > 0 && item["content"].every(isContentBlock) && (item["mediaReferences"] === void 0 || readDaemonMediaReferences(item["mediaReferences"]) !== void 0)
3480
3566
  );
3481
3567
  }
3482
3568
  return Array.isArray(response["messages"]) && response["messages"].every(
@@ -3506,15 +3592,37 @@ var TodoStopGuardClaimTimeoutError = class extends Error {
3506
3592
  };
3507
3593
  function beginChannelDeliveryResponseBlock(capture) {
3508
3594
  capture?.agentOutput.beginResponse();
3509
- if (!capture?.channelDelivery) return void 0;
3510
- capture.channelDelivery.finalText = "";
3511
- return [];
3595
+ if (capture?.channelDelivery) capture.channelDelivery.finalText = "";
3596
+ if (capture?.turnResult) capture.turnResult.finalText = "";
3597
+ if (!capture?.channelDelivery && !capture?.turnResult) return void 0;
3598
+ return {
3599
+ parts: [],
3600
+ chars: 0,
3601
+ ...capture?.channelDelivery ? {} : { capChars: TURN_RESULT_TEXT_MAX_CHARS + 1 }
3602
+ };
3512
3603
  }
3513
3604
  __name(beginChannelDeliveryResponseBlock, "beginChannelDeliveryResponseBlock");
3605
+ function appendChannelDeliveryResponseText(responseBlock, text) {
3606
+ if (!responseBlock) return;
3607
+ if (responseBlock.capChars !== void 0 && responseBlock.chars >= responseBlock.capChars) {
3608
+ return;
3609
+ }
3610
+ responseBlock.parts.push(text);
3611
+ responseBlock.chars += text.length;
3612
+ }
3613
+ __name(appendChannelDeliveryResponseText, "appendChannelDeliveryResponseText");
3614
+ function rewindChannelDeliveryResponseBlock(responseBlock, checkpoint) {
3615
+ if (!responseBlock) return;
3616
+ const removed = responseBlock.parts.splice(checkpoint);
3617
+ for (const part of removed) responseBlock.chars -= part.length;
3618
+ }
3619
+ __name(rewindChannelDeliveryResponseBlock, "rewindChannelDeliveryResponseBlock");
3514
3620
  function commitChannelDeliveryResponseBlock(capture, responseBlock, hasFunctionCalls) {
3515
3621
  capture?.agentOutput.commitResponse(hasFunctionCalls);
3516
- if (capture?.channelDelivery && responseBlock && !hasFunctionCalls) {
3517
- capture.channelDelivery.finalText = responseBlock.join("");
3622
+ if (responseBlock && !hasFunctionCalls) {
3623
+ const finalText = responseBlock.parts.join("");
3624
+ if (capture?.channelDelivery) capture.channelDelivery.finalText = finalText;
3625
+ if (capture?.turnResult) capture.turnResult.finalText = finalText;
3518
3626
  }
3519
3627
  }
3520
3628
  __name(commitChannelDeliveryResponseBlock, "commitChannelDeliveryResponseBlock");
@@ -3700,10 +3808,11 @@ async function buildAvailableCommandsSnapshot(config, abortSignal = AbortSignal.
3700
3808
  }
3701
3809
  __name(buildAvailableCommandsSnapshot, "buildAvailableCommandsSnapshot");
3702
3810
  var Session = class {
3703
- constructor(id, config, client, settings, onActiveWorkChanged) {
3811
+ constructor(id, config, client, settings, runExclusiveAutomaticHistoryMutation = (operation) => operation(), onActiveWorkChanged) {
3704
3812
  this.config = config;
3705
3813
  this.client = client;
3706
3814
  this.settings = settings;
3815
+ this.runExclusiveAutomaticHistoryMutation = runExclusiveAutomaticHistoryMutation;
3707
3816
  this.onActiveWorkChanged = onActiveWorkChanged;
3708
3817
  this.sessionId = id;
3709
3818
  this.runtimeBaseDir = config.storage.getRuntimeBaseDir();
@@ -3829,6 +3938,7 @@ var Session = class {
3829
3938
  // on a session whose registries are already unregistered.
3830
3939
  disposed = false;
3831
3940
  closing = false;
3941
+ historyMutationActive = false;
3832
3942
  closeGateCompletion = null;
3833
3943
  resolveCloseGate = null;
3834
3944
  unsubscribeChatRecordingFailure;
@@ -4050,6 +4160,12 @@ var Session = class {
4050
4160
  return publication;
4051
4161
  }
4052
4162
  async #drainGoalQueue() {
4163
+ if (this.goalQueue.length === 0) return;
4164
+ await this.runExclusiveAutomaticHistoryMutation(
4165
+ () => this.#drainGoalQueueExclusive()
4166
+ );
4167
+ }
4168
+ async #drainGoalQueueExclusive() {
4053
4169
  if (this.disposed || this.closing || this.goalProcessing || this.pendingPrompt || this.pendingPromptCompletion || this.cronProcessing || this.cronAbortController || this.notificationProcessing || this.notificationAbortController) {
4054
4170
  return;
4055
4171
  }
@@ -4748,6 +4864,12 @@ var Session = class {
4748
4864
  if (this.closing) {
4749
4865
  throw RequestError.invalidParams(void 0, "Session is closing");
4750
4866
  }
4867
+ if (this.historyMutationActive) {
4868
+ throw RequestError.invalidParams(
4869
+ void 0,
4870
+ "Session history mutation is in progress"
4871
+ );
4872
+ }
4751
4873
  try {
4752
4874
  await this.config.assertCanStartTurn();
4753
4875
  } catch (error) {
@@ -4761,9 +4883,18 @@ var Session = class {
4761
4883
  if (this.closing) {
4762
4884
  throw RequestError.invalidParams(void 0, "Session is closing");
4763
4885
  }
4886
+ if (this.historyMutationActive) {
4887
+ throw RequestError.invalidParams(
4888
+ void 0,
4889
+ "Session history mutation is in progress"
4890
+ );
4891
+ }
4892
+ }
4893
+ isTurnIdle() {
4894
+ return !this.closing && !this.#hasActiveTurn();
4764
4895
  }
4765
4896
  isIdle() {
4766
- return !this.closing && !this.#hasActiveTurn() && this.collectActiveWorkHolds().length === 0;
4897
+ return this.isTurnIdle() && this.collectActiveWorkHolds().length === 0;
4767
4898
  }
4768
4899
  /**
4769
4900
  * The Session's current active-work holds, derived on every call.
@@ -4815,9 +4946,29 @@ var Session = class {
4815
4946
  }
4816
4947
  #hasActiveTurn() {
4817
4948
  return Boolean(
4818
- this.pendingPrompt || this.pendingPromptCompletion || this.goalProcessing || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
4949
+ this.pendingPrompt || this.historyMutationActive || this.pendingPromptCompletion || this.goalProcessing || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
4819
4950
  );
4820
4951
  }
4952
+ beginHistoryMutation() {
4953
+ if (this.closing) {
4954
+ throw RequestError.invalidParams(void 0, "Session is closing");
4955
+ }
4956
+ if (this.#hasActiveTurn()) {
4957
+ throw new RequestError(-32602, "Session is busy processing a turn", {
4958
+ errorKind: "session_busy"
4959
+ });
4960
+ }
4961
+ this.historyMutationActive = true;
4962
+ let released = false;
4963
+ return () => {
4964
+ if (released) return;
4965
+ released = true;
4966
+ this.historyMutationActive = false;
4967
+ if (this.disposed) return;
4968
+ void this.#drainCronQueue();
4969
+ void this.#drainNotificationQueue();
4970
+ };
4971
+ }
4821
4972
  beginClose() {
4822
4973
  if (this.closing) {
4823
4974
  throw RequestError.invalidParams(
@@ -5164,9 +5315,51 @@ var Session = class {
5164
5315
  }
5165
5316
  }
5166
5317
  async prompt(params, invocationContext, admissionCancellation, modelPrompt, scheduledGoalTurn) {
5318
+ if (invocationContext !== void 0 && invocationContext.sessionId !== this.config.getSessionId()) {
5319
+ throw RequestError.invalidParams(
5320
+ void 0,
5321
+ "Invocation context session does not match the active session"
5322
+ );
5323
+ }
5324
+ const turnRecording = this.#beginTurnRecording(params, invocationContext);
5325
+ try {
5326
+ const result = await this.#promptWithTurnRecording(
5327
+ params,
5328
+ invocationContext,
5329
+ admissionCancellation,
5330
+ modelPrompt,
5331
+ scheduledGoalTurn,
5332
+ turnRecording
5333
+ );
5334
+ this.#settleTurnRecording(
5335
+ result.stopReason === "cancelled" ? "cancelled" : "completed",
5336
+ turnRecording,
5337
+ result
5338
+ );
5339
+ return result;
5340
+ } catch (error) {
5341
+ const pendingSend = turnRecording?.abortController;
5342
+ const abortReason = pendingSend?.signal.aborted === true ? pendingSend.signal.reason : void 0;
5343
+ const controlledAbort = abortReason === USER_CANCEL_ABORT_REASON || abortReason === SESSION_DISPOSE_ABORT_REASON || abortReason === NEW_PROMPT_ABORT_REASON && this.#isAbortError(error);
5344
+ if (controlledAbort) {
5345
+ const result = { stopReason: "cancelled" };
5346
+ this.#settleTurnRecording("cancelled", turnRecording, result);
5347
+ return result;
5348
+ }
5349
+ this.#settleTurnRecording("error", turnRecording, void 0, error);
5350
+ throw error;
5351
+ }
5352
+ }
5353
+ async #promptWithTurnRecording(params, invocationContext, admissionCancellation, modelPrompt, scheduledGoalTurn, turnRecording) {
5167
5354
  if (this.closing) {
5168
5355
  throw RequestError.invalidParams(void 0, "Session is closing");
5169
5356
  }
5357
+ if (this.historyMutationActive) {
5358
+ throw RequestError.invalidParams(
5359
+ void 0,
5360
+ "Session history mutation is in progress"
5361
+ );
5362
+ }
5170
5363
  if (modelPrompt !== void 0 && invocationContext === void 0) {
5171
5364
  throw RequestError.invalidParams(
5172
5365
  void 0,
@@ -5186,6 +5379,12 @@ var Session = class {
5186
5379
  if (this.closing) {
5187
5380
  throw RequestError.invalidParams(void 0, "Session is closing");
5188
5381
  }
5382
+ if (this.historyMutationActive) {
5383
+ throw RequestError.invalidParams(
5384
+ void 0,
5385
+ "Session history mutation is in progress"
5386
+ );
5387
+ }
5189
5388
  if (admissionCancellation?.aborted) {
5190
5389
  return { stopReason: "cancelled" };
5191
5390
  }
@@ -5211,6 +5410,7 @@ var Session = class {
5211
5410
  }
5212
5411
  this.pendingPrompt?.abort(NEW_PROMPT_ABORT_REASON);
5213
5412
  const pendingSend = goalTurn?.controller ?? new AbortController();
5413
+ if (turnRecording) turnRecording.abortController = pendingSend;
5214
5414
  const cancelPendingSend = /* @__PURE__ */ __name(() => pendingSend.abort(USER_CANCEL_ABORT_REASON), "cancelPendingSend");
5215
5415
  if (admissionCancellation) {
5216
5416
  admissionCancellation.addEventListener("abort", cancelPendingSend, {
@@ -5304,6 +5504,9 @@ var Session = class {
5304
5504
  this.todoStopGuard.suspend();
5305
5505
  return { stopReason: "cancelled" };
5306
5506
  }
5507
+ const channelPromptTurn = params._meta?.[CHANNEL_PROMPT_META_KEY] === true;
5508
+ const recording = this.config.getChatRecordingService();
5509
+ const branchCheckpointCursor = scheduledGoalTurn === void 0 && !channelPromptTurn ? recording?.getBranchCheckpointCursor() : void 0;
5307
5510
  if (todoStopGuardPreparation.startsWorkChain) {
5308
5511
  this.#clearTodoStopGuardQueuedPromptWait();
5309
5512
  this.todoStopGuard.startOrdinaryPrompt();
@@ -5313,9 +5516,9 @@ var Session = class {
5313
5516
  const channelDelivery = parsePromptChannelDelivery(params);
5314
5517
  const responseCapture = {
5315
5518
  ...channelDelivery ? { channelDelivery: { finalText: "" } } : {},
5519
+ ...turnRecording ? { turnResult: turnRecording.finalAnswer } : {},
5316
5520
  agentOutput: new AgentOutputMessageCapture(this.config)
5317
5521
  };
5318
- const channelPromptTurn = params._meta?.[CHANNEL_PROMPT_META_KEY] === true;
5319
5522
  let resolveCompletion;
5320
5523
  this.pendingPromptCompletion = new Promise((resolve6) => {
5321
5524
  resolveCompletion = resolve6;
@@ -5323,6 +5526,7 @@ var Session = class {
5323
5526
  let rejectedByLoopProtection = false;
5324
5527
  let promptResult;
5325
5528
  let promptFailed = false;
5529
+ if (turnRecording) turnRecording.startedAt = Date.now();
5326
5530
  try {
5327
5531
  const result = await this.#executePrompt(
5328
5532
  params,
@@ -5343,12 +5547,36 @@ var Session = class {
5343
5547
  goalTurn,
5344
5548
  channelPromptTurn
5345
5549
  );
5346
- promptResult = result;
5550
+ let branchPoint;
5551
+ if (recording && branchCheckpointCursor) {
5552
+ try {
5553
+ branchPoint = await recording.recordBranchCheckpointTransaction({
5554
+ cursor: branchCheckpointCursor,
5555
+ stopReason: result.stopReason
5556
+ });
5557
+ } catch (error) {
5558
+ debugLogger6.warn(
5559
+ "Failed to record branch checkpoint; completing the turn without a branch point",
5560
+ error
5561
+ );
5562
+ }
5563
+ }
5564
+ const completedResult = branchPoint ? {
5565
+ ...result,
5566
+ _meta: {
5567
+ ...result._meta,
5568
+ "qwen.branchPoint": {
5569
+ assistantRecordUuid: branchPoint.assistantRecordUuid,
5570
+ checkpointUuid: branchPoint.checkpointUuid
5571
+ }
5572
+ }
5573
+ } : result;
5574
+ promptResult = completedResult;
5347
5575
  releasePendingSend();
5348
5576
  void this.#drainCronQueue();
5349
5577
  void this.#drainNotificationQueue();
5350
- this.#maybeEmitFollowupSuggestion(result);
5351
- if (channelDelivery && result.stopReason === "end_turn") {
5578
+ this.#maybeEmitFollowupSuggestion(completedResult);
5579
+ if (channelDelivery && completedResult.stopReason === "end_turn") {
5352
5580
  this.#scheduleChannelDelivery({
5353
5581
  sessionId: this.sessionId,
5354
5582
  deliveryId: channelDelivery.deliveryId,
@@ -5360,7 +5588,7 @@ var Session = class {
5360
5588
  promptId: channelDelivery.deliveryId
5361
5589
  });
5362
5590
  }
5363
- return result;
5591
+ return completedResult;
5364
5592
  } catch (error) {
5365
5593
  promptFailed = true;
5366
5594
  if (error instanceof SessionWriterError) {
@@ -5436,7 +5664,7 @@ var Session = class {
5436
5664
  * `qwen/notify/session/prompt-suggestion` extNotification. Mirrors
5437
5665
  * the CLI's `AppContainer.tsx` integration: same `generatePromptSuggestion`
5438
5666
  * call, same `enableCacheSharing` flag forwarding, same curated
5439
- * history slice (`getHistory(true).slice(-40)`).
5667
+ * history tail (`getHistoryTail(40, true)`).
5440
5668
  *
5441
5669
  * Differences from the CLI:
5442
5670
  * - Triggers only on `stopReason === 'end_turn'` (the daemon
@@ -5466,21 +5694,25 @@ var Session = class {
5466
5694
  const promptId = this.config.getSessionId() + "########" + String(this.turn);
5467
5695
  void (async () => {
5468
5696
  try {
5469
- const fullHistory = chat.getHistory(true);
5470
- const lastEntry = fullHistory[fullHistory.length - 1];
5697
+ const conversationHistory = chat.getHistoryTail(40, true);
5698
+ const lastEntry = conversationHistory[conversationHistory.length - 1];
5471
5699
  if (!lastEntry || lastEntry.role !== "model") {
5472
5700
  debugLogger6.debug(
5473
5701
  "Skipping followup suggestion: last history entry is not model"
5474
5702
  );
5475
5703
  return;
5476
5704
  }
5477
- const conversationHistory = fullHistory.length > 40 ? fullHistory.slice(-40) : fullHistory;
5478
5705
  const r = await generatePromptSuggestion(
5479
5706
  this.config,
5480
5707
  conversationHistory,
5481
5708
  ac.signal,
5482
5709
  {
5483
- enableCacheSharing: this.settings.merged.ui?.enableCacheSharing === true
5710
+ // On by default: the schema declares `default: true`, but
5711
+ // `mergeSettings` doesn't apply schema defaults, so an unset value
5712
+ // is `undefined` and a `=== true` gate left the cache-aware fork
5713
+ // as dead code unless the flag was explicitly set (#9230). Mirrors
5714
+ // AppContainer — only an explicit `false` opts out.
5715
+ enableCacheSharing: this.settings.merged.ui?.enableCacheSharing !== false
5484
5716
  }
5485
5717
  );
5486
5718
  if (ac.signal.aborted) return;
@@ -5566,7 +5798,8 @@ var Session = class {
5566
5798
  },
5567
5799
  async () => {
5568
5800
  const promptText = params.prompt.filter((block) => block.type === "text").map((block) => block.type === "text" ? block.text : "").join(" ");
5569
- const promptDisplayText = typeof promptMetadata?.[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] === "string" ? promptMetadata[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] : void 0;
5801
+ const promptDisplayTextValue = promptMetadata?.[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
5802
+ const promptDisplayText = typeof promptDisplayTextValue === "string" ? promptDisplayTextValue : void 0;
5570
5803
  const modelPromptBlocks = modelPrompt === void 0 ? params.prompt : [{ type: "text", text: modelPrompt }];
5571
5804
  logUserPrompt(
5572
5805
  this.config,
@@ -5589,6 +5822,12 @@ var Session = class {
5589
5822
  );
5590
5823
  }
5591
5824
  }
5825
+ const firstTextBlock = modelPromptBlocks.find(
5826
+ (block) => block.type === "text"
5827
+ );
5828
+ const inputText = firstTextBlock?.text || "";
5829
+ const isSlashInput = !isContinue && isSlashCommand(inputText);
5830
+ const slashCommandName = getSlashCommandFirstToken(inputText);
5592
5831
  let continuationParts = null;
5593
5832
  let strippedOrphanEntries = null;
5594
5833
  let orphanPushCountSnapshot = 0;
@@ -5627,12 +5866,16 @@ var Session = class {
5627
5866
  } else if (isContinue) {
5628
5867
  } else if (isRetry) {
5629
5868
  this.#getCurrentChat().stripOrphanedUserEntriesFromHistory();
5630
- } else {
5869
+ } else if (!isSlashInput || slashCommandName !== "advisor") {
5870
+ const mediaReferences = readDaemonMediaReferences(
5871
+ promptMetadata?.[DAEMON_MEDIA_REFERENCES_META_KEY]
5872
+ );
5631
5873
  const recorder = this.config.getChatRecordingService();
5632
- if (promptDisplayText !== void 0) {
5874
+ if (promptDisplayText !== void 0 || mediaReferences) {
5633
5875
  recorder?.recordUserMessage(promptText, goalTurn?.permit, {
5634
- displayText: promptDisplayText,
5635
- hookContext: ""
5876
+ displayText: promptDisplayText ?? promptText,
5877
+ hookContext: "",
5878
+ ...mediaReferences ? { mediaReferences } : {}
5636
5879
  });
5637
5880
  } else if (goalTurn) {
5638
5881
  recorder?.recordUserMessage(promptText, goalTurn.permit);
@@ -5640,11 +5883,6 @@ var Session = class {
5640
5883
  recorder?.recordUserMessage(promptText);
5641
5884
  }
5642
5885
  }
5643
- const firstTextBlock = modelPromptBlocks.find(
5644
- (block) => block.type === "text"
5645
- );
5646
- const inputText = firstTextBlock?.text || "";
5647
- const isSlashInput = !isContinue && isSlashCommand(inputText);
5648
5886
  if (!isSlashInput && !isContinue && !isRetry) {
5649
5887
  this.refreshContextFilesOnWrite = false;
5650
5888
  }
@@ -5675,13 +5913,58 @@ var Session = class {
5675
5913
  startNewSession: /* @__PURE__ */ __name(() => this.rebindGoalRuntimeForNewSession(), "startNewSession")
5676
5914
  }
5677
5915
  );
5678
- parts = await this.#processSlashCommandResult(
5679
- slashCommandResult,
5680
- modelPromptBlocks,
5681
- pendingSend.signal,
5682
- onFullTurnModel
5683
- );
5916
+ if (slashCommandName === "advisor" && pendingSend.signal.aborted && slashCommandResult.type === "message") {
5917
+ this.todoStopGuard.suspend();
5918
+ logConversationFinishedEvent(
5919
+ this.config,
5920
+ new ConversationFinishedEvent(
5921
+ this.config.getApprovalMode(),
5922
+ 0
5923
+ )
5924
+ );
5925
+ return { stopReason: "cancelled" };
5926
+ }
5927
+ const resolvedCommandInfo = slashCommandResult.resolvedCommand;
5928
+ const shouldRecordSlashCommand = !(resolvedCommandInfo?.kind === "built-in" /* BUILT_IN */ && resolvedCommandInfo.name === "advisor");
5929
+ if (slashCommandName === "advisor" && shouldRecordSlashCommand && goalTurn?.origin !== "runtime" && !isRetry) {
5930
+ const recorder = this.config.getChatRecordingService();
5931
+ if (promptDisplayText !== void 0) {
5932
+ recorder?.recordUserMessage(promptText, goalTurn?.permit, {
5933
+ displayText: promptDisplayText,
5934
+ hookContext: ""
5935
+ });
5936
+ } else if (goalTurn) {
5937
+ recorder?.recordUserMessage(promptText, goalTurn.permit);
5938
+ } else {
5939
+ recorder?.recordUserMessage(promptText);
5940
+ }
5941
+ }
5942
+ try {
5943
+ parts = await this.#processSlashCommandResult(
5944
+ slashCommandResult,
5945
+ modelPromptBlocks,
5946
+ pendingSend.signal,
5947
+ onFullTurnModel,
5948
+ shouldRecordSlashCommand
5949
+ );
5950
+ } catch (error) {
5951
+ logConversationFinishedEvent(
5952
+ this.config,
5953
+ new ConversationFinishedEvent(
5954
+ this.config.getApprovalMode(),
5955
+ 0
5956
+ )
5957
+ );
5958
+ throw error;
5959
+ }
5684
5960
  if (parts === null) {
5961
+ logConversationFinishedEvent(
5962
+ this.config,
5963
+ new ConversationFinishedEvent(
5964
+ this.config.getApprovalMode(),
5965
+ 0
5966
+ )
5967
+ );
5685
5968
  return { stopReason: "end_turn" };
5686
5969
  }
5687
5970
  } else {
@@ -5827,7 +6110,7 @@ ${this.pendingRecoveredAgentsNotice}
5827
6110
  const responseStream = sendResult.responseStream;
5828
6111
  nextMessage = null;
5829
6112
  channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(responseCapture);
5830
- channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
6113
+ channelDeliveryCheckpoint = channelDeliveryResponseBlock?.parts.length ?? 0;
5831
6114
  let streamFailed = false;
5832
6115
  try {
5833
6116
  for await (const resp of responseStream) {
@@ -5848,7 +6131,10 @@ ${this.pendingRecoveredAgentsNotice}
5848
6131
  );
5849
6132
  if (!part.thought) {
5850
6133
  responseCapture.agentOutput.appendText(part.text);
5851
- channelDeliveryResponseBlock?.push(part.text);
6134
+ appendChannelDeliveryResponseText(
6135
+ channelDeliveryResponseBlock,
6136
+ part.text
6137
+ );
5852
6138
  messageDisplay?.addChunk(part.text);
5853
6139
  }
5854
6140
  }
@@ -5871,9 +6157,10 @@ ${this.pendingRecoveredAgentsNotice}
5871
6157
  resp.type === "retry" /* RETRY */ && resp.isContinuation === true
5872
6158
  );
5873
6159
  if (resp.type === "model_fallback" /* MODEL_FALLBACK */ || !resp.isContinuation) {
5874
- if (channelDeliveryResponseBlock) {
5875
- channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
5876
- }
6160
+ rewindChannelDeliveryResponseBlock(
6161
+ channelDeliveryResponseBlock,
6162
+ channelDeliveryCheckpoint
6163
+ );
5877
6164
  }
5878
6165
  await finalizeToolCallPreparations(
5879
6166
  preparationTracker,
@@ -6586,7 +6873,7 @@ ${this.pendingRecoveredAgentsNotice}
6586
6873
  channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(
6587
6874
  options.responseCapture
6588
6875
  );
6589
- channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
6876
+ channelDeliveryCheckpoint = channelDeliveryResponseBlock?.parts.length ?? 0;
6590
6877
  initialSend = false;
6591
6878
  if (guardForThisSend) {
6592
6879
  const guardCommitted = this.todoStopGuard.commitContinuation(
@@ -6619,7 +6906,10 @@ ${this.pendingRecoveredAgentsNotice}
6619
6906
  );
6620
6907
  if (!part.thought) {
6621
6908
  options.responseCapture?.agentOutput.appendText(part.text);
6622
- channelDeliveryResponseBlock?.push(part.text);
6909
+ appendChannelDeliveryResponseText(
6910
+ channelDeliveryResponseBlock,
6911
+ part.text
6912
+ );
6623
6913
  messageDisplay?.addChunk(part.text);
6624
6914
  }
6625
6915
  }
@@ -6642,9 +6932,10 @@ ${this.pendingRecoveredAgentsNotice}
6642
6932
  response.type === "retry" /* RETRY */ && response.isContinuation === true
6643
6933
  );
6644
6934
  if (response.type === "model_fallback" /* MODEL_FALLBACK */ || !response.isContinuation) {
6645
- if (channelDeliveryResponseBlock) {
6646
- channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
6647
- }
6935
+ rewindChannelDeliveryResponseBlock(
6936
+ channelDeliveryResponseBlock,
6937
+ channelDeliveryCheckpoint
6938
+ );
6648
6939
  }
6649
6940
  await finalizeToolCallPreparations(
6650
6941
  preparationTracker,
@@ -6836,9 +7127,11 @@ ${this.pendingRecoveredAgentsNotice}
6836
7127
  }
6837
7128
  }
6838
7129
  async sendUpdate(update) {
7130
+ const projectedUpdate = projectAcpToolResultUpdate(update);
7131
+ observeAcpToolResultProjection(update, projectedUpdate, this.sessionId);
6839
7132
  const params = {
6840
7133
  sessionId: this.sessionId,
6841
- update: projectAcpToolResultUpdate(update)
7134
+ update: projectedUpdate
6842
7135
  };
6843
7136
  if (update.sessionUpdate === "plan") {
6844
7137
  this.activeTodoPlanRevision = void 0;
@@ -6869,6 +7162,52 @@ ${this.pendingRecoveredAgentsNotice}
6869
7162
  }, 0);
6870
7163
  timer.unref();
6871
7164
  }
7165
+ #beginTurnRecording(params, invocationContext) {
7166
+ if (!invocationContext) return null;
7167
+ const promptMetadata = params._meta;
7168
+ const rawPromptDisplayText = promptMetadata?.[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
7169
+ const promptDisplayText = typeof rawPromptDisplayText === "string" && rawPromptDisplayText !== "" ? rawPromptDisplayText : void 0;
7170
+ const { text, truncated } = truncateTurnText(
7171
+ promptDisplayText ?? extractTurnPromptText(params.prompt)
7172
+ );
7173
+ const recordingService = this.config.getChatRecordingService();
7174
+ return {
7175
+ promptId: invocationContext.promptId,
7176
+ ...invocationContext.originatorClientId !== void 0 ? { originatorClientId: invocationContext.originatorClientId } : {},
7177
+ promptText: text,
7178
+ promptTextTruncated: truncated,
7179
+ finalAnswer: { finalText: "" },
7180
+ ...recordingService !== void 0 ? { recordingService } : {}
7181
+ };
7182
+ }
7183
+ #settleTurnRecording(state, recording, response, error) {
7184
+ if (recording === null) return;
7185
+ const finalAnswer = truncateTurnText(recording.finalAnswer.finalText);
7186
+ const stopReason = response?.stopReason ?? (state === "cancelled" ? "cancelled" : void 0);
7187
+ const payload = {
7188
+ promptId: recording.promptId,
7189
+ state,
7190
+ ...stopReason !== void 0 ? { stopReason } : {},
7191
+ ...state === "error" ? { error: normalizeTurnResultError(error) } : {},
7192
+ ...recording.startedAt !== void 0 ? { startedAt: recording.startedAt } : {},
7193
+ endedAt: Date.now(),
7194
+ promptText: recording.promptText,
7195
+ ...recording.promptTextTruncated ? { promptTextTruncated: true } : {},
7196
+ ...finalAnswer.text.length > 0 ? { resultText: finalAnswer.text } : {},
7197
+ ...finalAnswer.truncated ? {
7198
+ resultTruncated: true,
7199
+ resultCode: TURN_RESULT_CODE_TEXT_TRUNCATED
7200
+ } : {},
7201
+ ...recording.originatorClientId !== void 0 ? { originatorClientId: recording.originatorClientId } : {}
7202
+ };
7203
+ try {
7204
+ recording.recordingService?.recordTurnResult(payload);
7205
+ } catch (recordError) {
7206
+ debugLogger6.warn(
7207
+ `Failed to record turn result: ${this.#formatError(recordError)}`
7208
+ );
7209
+ }
7210
+ }
6872
7211
  #getCurrentChat() {
6873
7212
  return this.config.getGeminiClient().getChat();
6874
7213
  }
@@ -7399,7 +7738,22 @@ ${this.pendingRecoveredAgentsNotice}
7399
7738
  }
7400
7739
  }
7401
7740
  const built = prefixMidTurnUserMessageParts(rawParts, displayText);
7402
- this.config.getChatRecordingService()?.recordMidTurnUserMessage(built, displayText);
7741
+ const recorder = this.config.getChatRecordingService();
7742
+ if (message.kind === "structured" && message.mediaReferences) {
7743
+ const everyMediaBlockHasAReference = message.mediaReferences.length === message.content.filter((block) => block.type === "image").length;
7744
+ if (everyMediaBlockHasAReference) {
7745
+ recorder?.recordMidTurnUserMessage(
7746
+ stripReferencedInlineDataParts(built, message.content),
7747
+ displayText,
7748
+ void 0,
7749
+ message.mediaReferences
7750
+ );
7751
+ } else {
7752
+ recorder?.recordMidTurnUserMessage(built, displayText);
7753
+ }
7754
+ } else {
7755
+ recorder?.recordMidTurnUserMessage(built, displayText);
7756
+ }
7403
7757
  parts.push(...built);
7404
7758
  }
7405
7759
  return parts;
@@ -7501,6 +7855,15 @@ ${this.pendingRecoveredAgentsNotice}
7501
7855
  if (this.notificationProcessing) return;
7502
7856
  if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
7503
7857
  if (this.#nextCronQueueIndex() < 0) return;
7858
+ await this.runExclusiveAutomaticHistoryMutation(
7859
+ () => this.#drainCronQueueExclusive()
7860
+ );
7861
+ }
7862
+ async #drainCronQueueExclusive() {
7863
+ if (this.disposed || this.closing || this.cronProcessing) return;
7864
+ if (this.pendingPrompt || this.notificationProcessing) return;
7865
+ if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
7866
+ if (this.#nextCronQueueIndex() < 0) return;
7504
7867
  try {
7505
7868
  await this.assertCanStartTurn();
7506
7869
  } catch (error) {
@@ -7712,7 +8075,7 @@ ${this.pendingRecoveredAgentsNotice}
7712
8075
  }
7713
8076
  const responseStream = sendResult.responseStream;
7714
8077
  const channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(responseCapture);
7715
- const channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
8078
+ const channelDeliveryCheckpoint = channelDeliveryResponseBlock?.parts.length ?? 0;
7716
8079
  if (loopTick && turnCount === 1) {
7717
8080
  this.loopTickResolver?.markDelivered();
7718
8081
  }
@@ -7738,7 +8101,10 @@ ${this.pendingRecoveredAgentsNotice}
7738
8101
  );
7739
8102
  if (!part.thought) {
7740
8103
  responseCapture.agentOutput.appendText(part.text);
7741
- channelDeliveryResponseBlock?.push(part.text);
8104
+ appendChannelDeliveryResponseText(
8105
+ channelDeliveryResponseBlock,
8106
+ part.text
8107
+ );
7742
8108
  messageDisplay?.addChunk(part.text);
7743
8109
  }
7744
8110
  }
@@ -7761,9 +8127,10 @@ ${this.pendingRecoveredAgentsNotice}
7761
8127
  resp.type === "retry" /* RETRY */ && resp.isContinuation === true
7762
8128
  );
7763
8129
  if (resp.type === "model_fallback" /* MODEL_FALLBACK */ || !resp.isContinuation) {
7764
- if (channelDeliveryResponseBlock) {
7765
- channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
7766
- }
8130
+ rewindChannelDeliveryResponseBlock(
8131
+ channelDeliveryResponseBlock,
8132
+ channelDeliveryCheckpoint
8133
+ );
7767
8134
  }
7768
8135
  await finalizeToolCallPreparations(
7769
8136
  preparationTracker,
@@ -8094,6 +8461,18 @@ ${this.pendingRecoveredAgentsNotice}
8094
8461
  if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
8095
8462
  if (this.notificationQueue.length === 0) return;
8096
8463
  if (this.#nextNotificationQueueIndex() < 0) return;
8464
+ await this.runExclusiveAutomaticHistoryMutation(
8465
+ () => this.#drainNotificationQueueExclusive()
8466
+ );
8467
+ }
8468
+ async #drainNotificationQueueExclusive() {
8469
+ if (this.disposed || this.closing || this.notificationProcessing) return;
8470
+ if (this.pendingPrompt || this.cronProcessing || this.cronAbortController) {
8471
+ return;
8472
+ }
8473
+ if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
8474
+ if (this.notificationQueue.length === 0) return;
8475
+ if (this.#nextNotificationQueueIndex() < 0) return;
8097
8476
  try {
8098
8477
  await this.assertCanStartTurn();
8099
8478
  } catch (error) {
@@ -8731,11 +9110,17 @@ ${this.pendingRecoveredAgentsNotice}
8731
9110
  callId: record.callId,
8732
9111
  toolName: record.toolName,
8733
9112
  responseParts: record.responseParts,
8734
- persistedOutputFiles: record.persistedOutputFiles
8735
- }))
9113
+ persistedOutputFiles: record.persistedOutputFiles,
9114
+ artifacts: record.metadata.artifacts
9115
+ })),
9116
+ new Map(orderedRecords.map((record) => [record.callId, promptId]))
8736
9117
  );
8737
9118
  orderedRecords.forEach((record, index) => {
8738
- this.config.getChatRecordingService()?.recordToolResult(finalized[index].responseParts, record.metadata);
9119
+ this.config.getChatRecordingService()?.recordToolResult(finalized[index].responseParts, {
9120
+ ...record.metadata,
9121
+ persistedOutputFiles: finalized[index].persistedOutputFiles,
9122
+ artifacts: finalized[index].artifacts
9123
+ });
8739
9124
  });
8740
9125
  return {
8741
9126
  ...result,
@@ -8851,7 +9236,9 @@ ${this.pendingRecoveredAgentsNotice}
8851
9236
  message: response.responseParts,
8852
9237
  resultDisplay: response.resultDisplay,
8853
9238
  error: response.error,
8854
- success: false
9239
+ success: false,
9240
+ artifacts: response.artifacts,
9241
+ persistedOutputFiles: response.persistedOutputFiles
8855
9242
  });
8856
9243
  }
8857
9244
  } catch (emitError) {
@@ -8872,7 +9259,8 @@ ${this.pendingRecoveredAgentsNotice}
8872
9259
  executionStatus: response.executionStatus ?? "not_started",
8873
9260
  resultDisplay: response.resultDisplay,
8874
9261
  error: response.error,
8875
- errorType: response.errorType
9262
+ errorType: response.errorType,
9263
+ artifacts: response.artifacts
8876
9264
  }
8877
9265
  });
8878
9266
  }, "emitDuplicateBatch");
@@ -9219,6 +9607,8 @@ ${this.pendingRecoveredAgentsNotice}
9219
9607
  let executionStatus = "not_started";
9220
9608
  let executionErrorType;
9221
9609
  let executeReturned = false;
9610
+ let executeAttempted = false;
9611
+ let producerObserved = false;
9222
9612
  let terminalStatus;
9223
9613
  let toolType = "native";
9224
9614
  let mcpServerName = void 0;
@@ -9298,9 +9688,28 @@ ${this.pendingRecoveredAgentsNotice}
9298
9688
  terminalStatus = opts.status;
9299
9689
  spanError = opts.status === "error" ? error.message : void 0;
9300
9690
  cleanupAgentToolResources();
9691
+ const errorParts = errorResponse(
9692
+ error,
9693
+ toolName2,
9694
+ opts.status,
9695
+ opts.errorType
9696
+ );
9301
9697
  if (toolName2 !== ToolNames.TODO_WRITE) {
9302
9698
  try {
9303
- await this.toolCallEmitter.emitError(callId, toolName2, error);
9699
+ if (opts.settledMetadata) {
9700
+ await this.toolCallEmitter.emitResult({
9701
+ callId,
9702
+ toolName: toolName2,
9703
+ args,
9704
+ message: errorParts,
9705
+ error,
9706
+ success: false,
9707
+ artifacts: opts.settledMetadata.artifacts,
9708
+ persistedOutputFiles: opts.settledMetadata.persistedOutputFiles
9709
+ });
9710
+ } else {
9711
+ await this.toolCallEmitter.emitError(callId, toolName2, error);
9712
+ }
9304
9713
  } catch (emitError) {
9305
9714
  debugLogger6.debug(
9306
9715
  "[Session.runTool] Failed to emit terminal tool update",
@@ -9308,16 +9717,28 @@ ${this.pendingRecoveredAgentsNotice}
9308
9717
  );
9309
9718
  }
9310
9719
  }
9311
- const errorParts = errorResponse(
9312
- error,
9313
- toolName2,
9314
- opts.status,
9315
- opts.errorType
9316
- );
9720
+ if (executeAttempted && !producerObserved) {
9721
+ observeToolResultBoundary({
9722
+ stage: "producer",
9723
+ sessionId: this.sessionId,
9724
+ promptId,
9725
+ toolCallId: callId,
9726
+ toolName: toolName2,
9727
+ artifacts: [
9728
+ opts.settledMetadata ? toolResultBoundaryArtifact(
9729
+ opts.settledMetadata.persistedOutputFiles,
9730
+ opts.settledMetadata.artifacts
9731
+ ) : toolResultBoundaryArtifact([], [])
9732
+ ],
9733
+ values: /* @__PURE__ */ __name(() => toolResultPartDiagnosticValues(errorParts), "values")
9734
+ });
9735
+ producerObserved = true;
9736
+ }
9317
9737
  queueToolResultRecord?.(fc, {
9318
9738
  callId,
9319
9739
  toolName: toolName2,
9320
9740
  responseParts: errorParts,
9741
+ persistedOutputFiles: opts.settledMetadata?.persistedOutputFiles,
9321
9742
  policyToolName: guardContext.policyToolName,
9322
9743
  toolType,
9323
9744
  executionErrorType: executionStatus === "error" ? executionErrorType ?? opts.errorType : void 0,
@@ -9326,6 +9747,7 @@ ${this.pendingRecoveredAgentsNotice}
9326
9747
  status: opts.status,
9327
9748
  executionStatus,
9328
9749
  resultDisplay: void 0,
9750
+ artifacts: opts.settledMetadata?.artifacts,
9329
9751
  error: opts.status === "error" ? error : void 0,
9330
9752
  errorType: opts.status === "error" ? opts.errorType : void 0
9331
9753
  }
@@ -10245,6 +10667,8 @@ ${this.pendingRecoveredAgentsNotice}
10245
10667
  }
10246
10668
  }
10247
10669
  } : void 0, "heartbeatSpanAttributes");
10670
+ let settledArtifacts;
10671
+ let settledPersistedOutputFiles;
10248
10672
  const sleepInhibitorHandle = acquireSleepInhibitor(
10249
10673
  this.config,
10250
10674
  `Qwen Code is executing tool ${toolName}`
@@ -10266,12 +10690,21 @@ ${this.pendingRecoveredAgentsNotice}
10266
10690
  callId
10267
10691
  });
10268
10692
  executionStatus = "error";
10693
+ executeAttempted = true;
10269
10694
  try {
10270
10695
  toolResult = await invocation.execute(
10271
10696
  activeToolAbortSignal,
10272
10697
  onToolProgress
10273
10698
  );
10274
10699
  executeReturned = true;
10700
+ try {
10701
+ settledArtifacts = toolResult.artifacts;
10702
+ } catch {
10703
+ }
10704
+ try {
10705
+ settledPersistedOutputFiles = toolResult.persistedOutputFiles;
10706
+ } catch {
10707
+ }
10275
10708
  parentAbortedAtExecutionSettle = activeToolAbortSignal.aborted;
10276
10709
  isExecutionTimeout = toolResult.error?.type === "execution_timeout" /* EXECUTION_TIMEOUT */;
10277
10710
  aborted = parentAbortedAtExecutionSettle && !isExecutionTimeout;
@@ -10306,6 +10739,32 @@ ${this.pendingRecoveredAgentsNotice}
10306
10739
  toolSettled = true;
10307
10740
  sleepInhibitorHandle.release();
10308
10741
  }
10742
+ producerObserved = true;
10743
+ try {
10744
+ observeToolResultBoundary({
10745
+ stage: "producer",
10746
+ sessionId: this.sessionId,
10747
+ promptId,
10748
+ toolCallId: callId,
10749
+ toolName,
10750
+ artifacts: [
10751
+ toolResultBoundaryArtifact(
10752
+ settledPersistedOutputFiles,
10753
+ settledArtifacts
10754
+ )
10755
+ ],
10756
+ values: /* @__PURE__ */ __name(() => [
10757
+ ...toolResultPartDiagnosticValues(toolResult.llmContent),
10758
+ ...typeof toolResult.returnDisplay === "string" ? [
10759
+ {
10760
+ representation: "display",
10761
+ value: toolResult.returnDisplay
10762
+ }
10763
+ ] : []
10764
+ ], "values")
10765
+ });
10766
+ } catch {
10767
+ }
10309
10768
  cleanupAgentToolResources();
10310
10769
  if ((isEnterPlanModeTool || isExitPlanModeTool) && !toolResult.error && this.config.getApprovalMode() !== approvalMode) {
10311
10770
  await this.sendCurrentModeUpdateNotification();
@@ -10359,7 +10818,11 @@ ${this.pendingRecoveredAgentsNotice}
10359
10818
  {
10360
10819
  status: "cancelled",
10361
10820
  errorType: void 0,
10362
- executionStatus
10821
+ executionStatus,
10822
+ settledMetadata: {
10823
+ artifacts: settledArtifacts,
10824
+ persistedOutputFiles: settledPersistedOutputFiles
10825
+ }
10363
10826
  }
10364
10827
  );
10365
10828
  }
@@ -10372,7 +10835,11 @@ ${this.pendingRecoveredAgentsNotice}
10372
10835
  return earlyErrorResponse(new Error(stopMessage), toolName, {
10373
10836
  status: "error",
10374
10837
  errorType: "execution_denied" /* EXECUTION_DENIED */,
10375
- executionStatus
10838
+ executionStatus,
10839
+ settledMetadata: {
10840
+ artifacts: settledArtifacts,
10841
+ persistedOutputFiles: settledPersistedOutputFiles
10842
+ }
10376
10843
  });
10377
10844
  }
10378
10845
  if (postHookResult.additionalContext) {
@@ -10476,7 +10943,8 @@ ${this.pendingRecoveredAgentsNotice}
10476
10943
  resultDisplay: toolResult.returnDisplay,
10477
10944
  error: responseError,
10478
10945
  success: succeeded,
10479
- artifacts: toolResult.artifacts
10946
+ artifacts: settledArtifacts,
10947
+ persistedOutputFiles: settledPersistedOutputFiles
10480
10948
  });
10481
10949
  } catch (emitError) {
10482
10950
  debugLogger6.debug(
@@ -10515,7 +10983,7 @@ ${this.pendingRecoveredAgentsNotice}
10515
10983
  callId,
10516
10984
  toolName,
10517
10985
  responseParts,
10518
- persistedOutputFiles: toolResult.persistedOutputFiles,
10986
+ persistedOutputFiles: settledPersistedOutputFiles,
10519
10987
  policyToolName,
10520
10988
  toolType,
10521
10989
  executionErrorType: executionStatus === "error" ? executionErrorType : void 0,
@@ -10525,6 +10993,7 @@ ${this.pendingRecoveredAgentsNotice}
10525
10993
  executionStatus,
10526
10994
  resultDisplay: toolResult.returnDisplay,
10527
10995
  ...visionBridgeNotice !== void 0 ? { visionBridgeNotice } : {},
10996
+ artifacts: settledArtifacts,
10528
10997
  error: status === "error" && toolResult.error ? new Error(toolResult.error.message) : void 0,
10529
10998
  errorType: status === "error" ? executionErrorType : void 0
10530
10999
  }
@@ -10633,19 +11102,18 @@ ${this.pendingRecoveredAgentsNotice}
10633
11102
  *
10634
11103
  * Supported result types in ACP mode:
10635
11104
  * - submit_prompt: Submits content to the model
11105
+ * - message: Emits a single message to the client
10636
11106
  * - stream_messages: Streams multiple messages to the client (ACP-specific)
10637
11107
  * - unsupported: Command cannot be executed in ACP mode
10638
11108
  * - no_command: No command was found, use original prompt
10639
11109
  *
10640
- * Note: 'message' type is not supported in ACP mode - commands should use
10641
- * 'stream_messages' instead for consistent async handling.
10642
- *
10643
11110
  * @param result The result from handleSlashCommand
10644
11111
  * @param originalPrompt The original prompt blocks
10645
11112
  * @returns Parts to use for the prompt, or null if command was handled without needing model interaction
10646
11113
  */
10647
- async #processSlashCommandResult(result, originalPrompt, abortSignal, onFullTurnModel) {
11114
+ async #processSlashCommandResult(result, originalPrompt, abortSignal, onFullTurnModel, shouldRecordResult) {
10648
11115
  this.refreshContextFilesOnWrite = result.type === "submit_prompt" && Boolean(result.refreshContextFilesOnWrite);
11116
+ const recorder = shouldRecordResult ? this.config.getChatRecordingService() : void 0;
10649
11117
  switch (result.type) {
10650
11118
  case "submit_prompt":
10651
11119
  return this.#applyBridgeConversionsIfNeeded(
@@ -10659,7 +11127,7 @@ ${this.pendingRecoveredAgentsNotice}
10659
11127
  }
10660
11128
  const rendered = (result.content || "").replace(/\n/g, " \n");
10661
11129
  await this.messageEmitter.emitSlashCommandOutput(rendered);
10662
- this.config.getChatRecordingService()?.recordSlashCommand({
11130
+ recorder?.recordSlashCommand({
10663
11131
  phase: "result",
10664
11132
  rawCommand: originalPrompt.filter((b) => b.type === "text").map((b) => b.type === "text" ? b.text : "").join(" "),
10665
11133
  outputHistoryItems: [
@@ -10680,7 +11148,7 @@ ${this.pendingRecoveredAgentsNotice}
10680
11148
  chunks.push(msg.content || "");
10681
11149
  }
10682
11150
  if (chunks.length > 0) {
10683
- this.config.getChatRecordingService()?.recordSlashCommand({
11151
+ recorder?.recordSlashCommand({
10684
11152
  phase: "result",
10685
11153
  rawCommand: originalPrompt.filter((b) => b.type === "text").map((b) => b.type === "text" ? b.text : "").join(" "),
10686
11154
  outputHistoryItems: [
@@ -11414,6 +11882,38 @@ var ACP_REASONING_EFFORT_NAMES = {
11414
11882
  max: "Max"
11415
11883
  };
11416
11884
  var WORKSPACE_MEMORY_REMEMBER_CHILD_TIMEOUT_MS = 295e3;
11885
+ var TURN_STATUS_SCAN_PAGE_LIMIT = 500;
11886
+ var TURN_STATUS_SCAN_MAX_PAGES = 10;
11887
+ async function findSettledTurnResult(reader, sessionId, promptId, workspaceCwd) {
11888
+ let cursor;
11889
+ for (let page = 0; page < TURN_STATUS_SCAN_MAX_PAGES; page++) {
11890
+ const result = await reader.readPage(sessionId, {
11891
+ ...cursor !== void 0 ? { cursor } : { direction: "backward" },
11892
+ limit: TURN_STATUS_SCAN_PAGE_LIMIT,
11893
+ maxBytes: SESSION_TRANSCRIPT_MAX_PAGE_BYTES
11894
+ });
11895
+ for (let i = result.records.length - 1; i >= 0; i--) {
11896
+ const record = result.records[i];
11897
+ if (record.type !== "system" || record.subtype !== "turn_result") {
11898
+ continue;
11899
+ }
11900
+ const payload = record.systemPayload;
11901
+ if (!isTurnResultRecordPayload(payload)) continue;
11902
+ if (promptId === void 0 || payload.promptId === promptId) {
11903
+ return payload;
11904
+ }
11905
+ }
11906
+ if (!result.hasMore || result.nextCursorState === void 0) {
11907
+ return void 0;
11908
+ }
11909
+ cursor = encodeSessionTranscriptCursor(
11910
+ result.nextCursorState,
11911
+ workspaceCwd
11912
+ );
11913
+ }
11914
+ return void 0;
11915
+ }
11916
+ __name(findSettledTurnResult, "findSettledTurnResult");
11417
11917
  function createAcpSessionProfiler(span, attributePrefix) {
11418
11918
  let failedStage;
11419
11919
  const setAttribute = /* @__PURE__ */ __name((name, value) => {
@@ -11523,11 +12023,15 @@ async function shutdownSessionConfig(config) {
11523
12023
  }
11524
12024
  }
11525
12025
  __name(shutdownSessionConfig, "shutdownSessionConfig");
11526
- async function waitForSessionDrain(operation, timeoutMs, kind) {
12026
+ async function waitForSessionDrain(operation, timeoutMs, kind, displayTimeoutMs) {
11527
12027
  let timer;
11528
12028
  const timeout = new Promise((_, reject) => {
11529
12029
  timer = setTimeout(
11530
- () => reject(new Error(`Session ${kind} timed out after ${timeoutMs}ms`)),
12030
+ () => reject(
12031
+ new Error(
12032
+ `Session ${kind} timed out after ${displayTimeoutMs ?? timeoutMs}ms`
12033
+ )
12034
+ ),
11531
12035
  timeoutMs
11532
12036
  );
11533
12037
  timer.unref();
@@ -11833,6 +12337,15 @@ function getLoadReplayPageSize(params) {
11833
12337
  return value;
11834
12338
  }
11835
12339
  __name(getLoadReplayPageSize, "getLoadReplayPageSize");
12340
+ function deriveForkBaseName(name, recording, sessionId) {
12341
+ if (typeof name === "string" && name.trim().length > 0) {
12342
+ return name.trim();
12343
+ }
12344
+ const existingTitle = recording?.getCurrentCustomTitle();
12345
+ const stripped = existingTitle?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, "").trim();
12346
+ return stripped && stripped.length > 0 ? stripped : sessionId.slice(0, 8);
12347
+ }
12348
+ __name(deriveForkBaseName, "deriveForkBaseName");
11836
12349
  function createHiddenWorkspaceMemoryConfig(config) {
11837
12350
  return new Proxy(config, {
11838
12351
  get(target, prop) {
@@ -13447,7 +13960,10 @@ async function runAcpAgent(config, settings, argv, options) {
13447
13960
  let initializeRequestId;
13448
13961
  const pendingNewSessionRequestIds = /* @__PURE__ */ new Set();
13449
13962
  const stream = ndJsonStream(stdout, stdin, {
13450
- onMessageObserved: /* @__PURE__ */ __name(({ direction, message }) => {
13963
+ onMessageObserved: /* @__PURE__ */ __name(({ direction, bytes, message }) => {
13964
+ if (direction === "sent") {
13965
+ observeAcpToolResultWire(message, bytes);
13966
+ }
13451
13967
  if (direction === "received" && "id" in message && "method" in message) {
13452
13968
  if (message.method === "session/new") {
13453
13969
  pendingNewSessionRequestIds.add(message.id);
@@ -13839,6 +14355,7 @@ var QwenAgent = class {
13839
14355
  __name(this, "QwenAgent");
13840
14356
  }
13841
14357
  sessions = /* @__PURE__ */ new Map();
14358
+ historyMutationTails = /* @__PURE__ */ new Map();
13842
14359
  startingSessionIds = /* @__PURE__ */ new Set();
13843
14360
  activePromptCalls = /* @__PURE__ */ new Map();
13844
14361
  workspaceMcpDiscoveryConfig;
@@ -13902,6 +14419,43 @@ var QwenAgent = class {
13902
14419
  throw new SessionWriterUnavailableError();
13903
14420
  }
13904
14421
  }
14422
+ async runExclusiveHistoryMutation(sessionId, operation, waitTimeoutMs, waitDisplayTimeoutMs) {
14423
+ const previous = this.historyMutationTails.get(sessionId) ?? Promise.resolve();
14424
+ let release;
14425
+ const gate = new Promise((resolve6) => {
14426
+ release = resolve6;
14427
+ });
14428
+ const current = previous.then(() => gate);
14429
+ this.historyMutationTails.set(sessionId, current);
14430
+ try {
14431
+ if (waitTimeoutMs === void 0) {
14432
+ await previous;
14433
+ } else {
14434
+ await waitForSessionDrain(
14435
+ previous,
14436
+ waitTimeoutMs,
14437
+ "close",
14438
+ waitDisplayTimeoutMs
14439
+ );
14440
+ }
14441
+ } catch (error) {
14442
+ release();
14443
+ void current.then(() => {
14444
+ if (this.historyMutationTails.get(sessionId) === current) {
14445
+ this.historyMutationTails.delete(sessionId);
14446
+ }
14447
+ });
14448
+ throw error;
14449
+ }
14450
+ try {
14451
+ return await operation();
14452
+ } finally {
14453
+ release();
14454
+ if (this.historyMutationTails.get(sessionId) === current) {
14455
+ this.historyMutationTails.delete(sessionId);
14456
+ }
14457
+ }
14458
+ }
13905
14459
  rejectUnsupportedGuardedHiddenAgent(operation) {
13906
14460
  if (this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) {
13907
14461
  throw RequestError.invalidParams(
@@ -14401,11 +14955,10 @@ var QwenAgent = class {
14401
14955
  }
14402
14956
  const recorder = session.getConfig().getChatRecordingService();
14403
14957
  const requireFlush = opts?.requireFlush === true;
14404
- if (requireFlush) {
14405
- await recorder?.flush();
14406
- }
14958
+ if (requireFlush) await recorder?.flush();
14407
14959
  const drainTimeoutMs = opts?.drainTimeoutMs ?? SESSION_DRAIN_TIMEOUT_MS;
14408
14960
  const cancelClose = opts?.waitForCloseGate ? await beginSessionCloseAfterCurrentGate(session, drainTimeoutMs) : session.beginClose();
14961
+ const conditionalDrainDeadline = opts?.onlyIfUnheld ? Date.now() + drainTimeoutMs : void 0;
14409
14962
  if (opts?.onlyIfUnheld) {
14410
14963
  const holds = session.collectActiveWorkHolds();
14411
14964
  if (holds.length > 0) {
@@ -14413,13 +14966,24 @@ var QwenAgent = class {
14413
14966
  return { closed: false, holds };
14414
14967
  }
14415
14968
  }
14416
- for (const [requestId, generation] of this.generationControllers) {
14417
- if (generation.sessionId !== sessionId) continue;
14418
- generation.controller.abort();
14419
- this.generationControllers.delete(requestId);
14420
- }
14421
14969
  let removedFromStore = false;
14422
14970
  try {
14971
+ if (opts?.onlyIfUnheld) {
14972
+ await waitForSessionDrain(
14973
+ session.waitForActiveTurnsToSettle(),
14974
+ drainTimeoutMs,
14975
+ "close"
14976
+ );
14977
+ const holds = session.collectActiveWorkHolds();
14978
+ if (holds.length > 0) {
14979
+ return { closed: false, holds };
14980
+ }
14981
+ }
14982
+ for (const [requestId, generation] of this.generationControllers) {
14983
+ if (generation.sessionId !== sessionId) continue;
14984
+ generation.controller.abort();
14985
+ this.generationControllers.delete(requestId);
14986
+ }
14423
14987
  await waitForSessionDrain(
14424
14988
  (async () => {
14425
14989
  try {
@@ -14431,41 +14995,68 @@ var QwenAgent = class {
14431
14995
  }
14432
14996
  await session.waitForActiveTurnsToSettle();
14433
14997
  })(),
14434
- drainTimeoutMs,
14435
- "close"
14998
+ conditionalDrainDeadline === void 0 ? drainTimeoutMs : Math.max(1, conditionalDrainDeadline - Date.now()),
14999
+ "close",
15000
+ // Report the shared budget, not the phase-2 residue — a residue like
15001
+ // "1ms" hides that the settle phase consumed the budget and sends
15002
+ // oncall grepping for a timeout setting that does not exist.
15003
+ drainTimeoutMs
14436
15004
  );
14437
- if (opts?.onlyIfUnheld) {
14438
- const holds = session.collectActiveWorkHolds();
14439
- if (holds.length > 0) {
14440
- return { closed: false, holds };
14441
- }
14442
- }
14443
- recorder?.finalize();
14444
- let flushError;
14445
- try {
14446
- await recorder?.flush();
14447
- } catch (error) {
14448
- flushError = error;
14449
- }
14450
- if (flushError !== void 0 && requireFlush) {
14451
- throw flushError;
14452
- }
14453
- let closeError;
14454
- try {
14455
- await recorder?.close();
14456
- } catch (error) {
14457
- closeError = error;
14458
- }
14459
- if (recorder?.hasWriteOwnership()) {
14460
- throw closeError ?? new SessionWriterUnavailableError();
14461
- }
14462
- const cleanupErrors = [];
14463
- if (flushError !== void 0) cleanupErrors.push(flushError);
14464
- if (closeError !== void 0) cleanupErrors.push(closeError);
14465
- await this.removeStoredSessionEntry(sessionId, session, cleanupErrors, {
14466
- shutdownConfig: opts?.shutdownConfig
14467
- });
14468
- removedFromStore = true;
15005
+ const blockedByHolds = await this.runExclusiveHistoryMutation(
15006
+ sessionId,
15007
+ async () => {
15008
+ if (this.sessions.get(sessionId) !== session) {
15009
+ removedFromStore = true;
15010
+ return void 0;
15011
+ }
15012
+ if (opts?.onlyIfUnheld) {
15013
+ const holds = session.collectActiveWorkHolds();
15014
+ if (holds.length > 0) {
15015
+ return { closed: false, holds };
15016
+ }
15017
+ }
15018
+ recorder?.finalize();
15019
+ let flushError;
15020
+ try {
15021
+ await recorder?.flush();
15022
+ } catch (error) {
15023
+ flushError = error;
15024
+ }
15025
+ if (flushError !== void 0 && requireFlush) {
15026
+ throw flushError;
15027
+ }
15028
+ let closeError;
15029
+ try {
15030
+ await recorder?.close();
15031
+ } catch (error) {
15032
+ closeError = error;
15033
+ }
15034
+ if (recorder?.hasWriteOwnership()) {
15035
+ throw closeError ?? new SessionWriterUnavailableError();
15036
+ }
15037
+ const cleanupErrors = [];
15038
+ if (flushError !== void 0) cleanupErrors.push(flushError);
15039
+ if (closeError !== void 0) cleanupErrors.push(closeError);
15040
+ await this.removeStoredSessionEntry(
15041
+ sessionId,
15042
+ session,
15043
+ cleanupErrors,
15044
+ {
15045
+ shutdownConfig: opts?.shutdownConfig
15046
+ }
15047
+ );
15048
+ removedFromStore = true;
15049
+ return void 0;
15050
+ },
15051
+ // The mutation wait shares the conditional close's budget too, or
15052
+ // the whole round trip can outlast the daemon's outer wait — the
15053
+ // coupling the drain budget exists to keep. The mutation body
15054
+ // itself stays untimed, so the guarantee remains approximate. The
15055
+ // message reports the shared budget, not the residue.
15056
+ conditionalDrainDeadline === void 0 ? drainTimeoutMs : Math.max(1, conditionalDrainDeadline - Date.now()),
15057
+ drainTimeoutMs
15058
+ );
15059
+ if (blockedByHolds) return blockedByHolds;
14469
15060
  } finally {
14470
15061
  if (!removedFromStore) cancelClose();
14471
15062
  }
@@ -14573,7 +15164,7 @@ var QwenAgent = class {
14573
15164
  }
14574
15165
  this.clientCapabilities = args.clientCapabilities;
14575
15166
  const authMethods = buildAuthMethods();
14576
- const version = "0.21.12";
15167
+ const version = "0.21.14-preview.0";
14577
15168
  const response = {
14578
15169
  protocolVersion: PROTOCOL_VERSION,
14579
15170
  agentInfo: {
@@ -15480,6 +16071,9 @@ var QwenAgent = class {
15480
16071
  throw error;
15481
16072
  }
15482
16073
  }
16074
+ for (const call of this.activePromptCalls.get(sessionId) ?? []) {
16075
+ call.controller.abort();
16076
+ }
15483
16077
  }
15484
16078
  loadPermissionSettings(cwd) {
15485
16079
  this.settings = loadSettings(cwd);
@@ -19594,6 +20188,91 @@ ${outputText}
19594
20188
  } : null
19595
20189
  };
19596
20190
  }
20191
+ case SERVE_CONTROL_EXT_METHODS.sessionTurnStatus: {
20192
+ const sessionId = params["sessionId"];
20193
+ if (typeof sessionId !== "string" || !SESSION_ID_RE.test(sessionId)) {
20194
+ throw RequestError.invalidParams(
20195
+ void 0,
20196
+ "Invalid or missing sessionId"
20197
+ );
20198
+ }
20199
+ const rawPromptId = params["promptId"];
20200
+ if (rawPromptId !== void 0 && (typeof rawPromptId !== "string" || rawPromptId.length === 0)) {
20201
+ throw RequestError.invalidParams(
20202
+ void 0,
20203
+ "Invalid or missing promptId"
20204
+ );
20205
+ }
20206
+ const session = this.sessionOrThrow(sessionId);
20207
+ const settings = loadSettingsCached(cwd);
20208
+ return await runWithAcpRuntimeOutputDir(settings, cwd, async () => {
20209
+ try {
20210
+ await session.getConfig().getChatRecordingService()?.flush();
20211
+ } catch {
20212
+ }
20213
+ let reader;
20214
+ try {
20215
+ reader = new SessionTranscriptReader(cwd);
20216
+ const turnResult = await findSettledTurnResult(
20217
+ reader,
20218
+ sessionId,
20219
+ typeof rawPromptId === "string" ? rawPromptId : void 0,
20220
+ cwd
20221
+ );
20222
+ return {
20223
+ v: 1,
20224
+ sessionId,
20225
+ turnResult: turnResult ?? null
20226
+ };
20227
+ } catch (error) {
20228
+ if (error.code === "ENOENT") {
20229
+ return { v: 1, sessionId, turnResult: null };
20230
+ }
20231
+ if (error instanceof SessionTranscriptSnapshotUnavailableError && reader) {
20232
+ try {
20233
+ const transcript = await fs2.stat(
20234
+ reader.getSessionFilePath(sessionId)
20235
+ );
20236
+ if (transcript.size === 0) {
20237
+ return { v: 1, sessionId, turnResult: null };
20238
+ }
20239
+ } catch (statError) {
20240
+ if (statError.code === "ENOENT") {
20241
+ return { v: 1, sessionId, turnResult: null };
20242
+ }
20243
+ }
20244
+ }
20245
+ if (error instanceof InvalidSessionTranscriptCursorError) {
20246
+ throw new RequestError(-32602, error.message, {
20247
+ errorKind: "invalid_transcript_cursor"
20248
+ });
20249
+ }
20250
+ if (error instanceof SessionTranscriptSnapshotUnavailableError) {
20251
+ throw new RequestError(-32010, error.message, {
20252
+ errorKind: "transcript_snapshot_unavailable",
20253
+ sessionId
20254
+ });
20255
+ }
20256
+ if (error instanceof SessionTranscriptTooLargeError) {
20257
+ throw new RequestError(-32011, error.message, {
20258
+ errorKind: "transcript_too_large",
20259
+ sessionId,
20260
+ snapshotSize: error.snapshotSize,
20261
+ maxBytes: error.maxBytes
20262
+ });
20263
+ }
20264
+ if (error instanceof SessionTranscriptPageTooLargeError) {
20265
+ throw new RequestError(-32012, error.message, {
20266
+ errorKind: "transcript_page_too_large",
20267
+ sessionId,
20268
+ pageBytes: error.pageBytes,
20269
+ maxBytes: error.maxBytes
20270
+ });
20271
+ }
20272
+ throw error;
20273
+ }
20274
+ });
20275
+ }
19597
20276
  case SERVE_CONTROL_EXT_METHODS.sessionContinue: {
19598
20277
  const sessionId = params["sessionId"];
19599
20278
  if (typeof sessionId !== "string" || sessionId.length === 0) {
@@ -19814,9 +20493,25 @@ ${outputText}
19814
20493
  `Session not found for id: ${sessionId}`
19815
20494
  );
19816
20495
  }
20496
+ if (!session.isTurnIdle()) {
20497
+ throw new RequestError(
20498
+ -32602,
20499
+ "Cannot rewind while a prompt is running",
20500
+ {
20501
+ errorKind: "session_busy"
20502
+ }
20503
+ );
20504
+ }
20505
+ const rawPromptId = params["promptId"];
20506
+ if (rawPromptId !== void 0 && typeof rawPromptId !== "string") {
20507
+ throw new RequestError(-32602, "Invalid promptId format", {
20508
+ errorKind: "invalid_rewind_target"
20509
+ });
20510
+ }
20511
+ const promptId = typeof rawPromptId === "string" ? rawPromptId : void 0;
19817
20512
  let turnIndex = params["targetTurnIndex"];
19818
- const promptId = params["promptId"];
19819
- if (promptId && (turnIndex === void 0 || turnIndex === null)) {
20513
+ const resolveFromPromptId = promptId !== void 0 && (turnIndex === void 0 || turnIndex === null);
20514
+ if (resolveFromPromptId) {
19820
20515
  const prefix = sessionId + "########";
19821
20516
  if (!promptId.startsWith(prefix)) {
19822
20517
  throw new RequestError(-32602, "Invalid promptId format", {
@@ -19831,104 +20526,113 @@ ${outputText}
19831
20526
  { errorKind: "invalid_rewind_target" }
19832
20527
  );
19833
20528
  }
19834
- const fhs = session.getConfig().getFileHistoryService();
19835
- const snapshots = fhs.getSnapshots();
19836
- const snapshotIdx = snapshots.findIndex(
19837
- (s) => s.promptId === promptId
19838
- );
19839
- if (snapshotIdx < 0) {
19840
- throw new RequestError(
19841
- -32602,
19842
- "Snapshot not found for the given promptId",
19843
- { errorKind: "invalid_rewind_target" }
19844
- );
19845
- }
19846
- turnIndex = snapshotIdx;
19847
- }
19848
- if (!Number.isInteger(turnIndex) || turnIndex < 0) {
20529
+ } else if (!Number.isInteger(turnIndex) || turnIndex < 0) {
19849
20530
  throw RequestError.invalidParams(
19850
20531
  void 0,
19851
20532
  "Invalid or missing targetTurnIndex"
19852
20533
  );
19853
20534
  }
19854
- const rewindFiles = params["rewindFiles"] !== false;
19855
- const historyBeforeRewind = session.captureHistorySnapshot();
19856
- let rewindResult;
19857
- try {
19858
- rewindResult = session.rewindToTurn(turnIndex, {
19859
- rewindFiles
19860
- });
19861
- } catch (err) {
19862
- if (err instanceof RequestError) {
19863
- const msg = err.message;
19864
- if (msg.includes("Cannot rewind while a prompt is running")) {
19865
- throw new RequestError(err.code, msg, {
19866
- errorKind: "session_busy"
19867
- });
19868
- }
19869
- if (msg.includes("compressed or does not exist")) {
19870
- throw new RequestError(err.code, msg, {
19871
- errorKind: "invalid_rewind_target"
19872
- });
20535
+ return await this.runExclusiveHistoryMutation(sessionId, async () => {
20536
+ if (resolveFromPromptId) {
20537
+ const fhs = session.getConfig().getFileHistoryService();
20538
+ const snapshots = fhs.getSnapshots();
20539
+ const snapshotIdx = snapshots.findIndex(
20540
+ (s) => s.promptId === promptId
20541
+ );
20542
+ if (snapshotIdx < 0) {
20543
+ throw new RequestError(
20544
+ -32602,
20545
+ "Snapshot not found for the given promptId",
20546
+ { errorKind: "invalid_rewind_target" }
20547
+ );
19873
20548
  }
20549
+ turnIndex = snapshotIdx;
19874
20550
  }
19875
- throw err;
19876
- }
19877
- let filesChanged = [];
19878
- let filesFailed = [];
19879
- if (rewindFiles && promptId) {
19880
- const fhs = session.getConfig().getFileHistoryService();
20551
+ const rewindFiles = params["rewindFiles"] !== false;
20552
+ const historyBeforeRewind = session.captureHistorySnapshot();
20553
+ let rewindResult;
20554
+ let releaseHistoryMutation;
19881
20555
  try {
19882
- const fileResult = await fhs.rewind(promptId, true);
19883
- filesChanged = fileResult.filesChanged;
19884
- filesFailed = fileResult.filesFailed;
20556
+ rewindResult = session.rewindToTurn(turnIndex, {
20557
+ rewindFiles
20558
+ });
20559
+ releaseHistoryMutation = session.beginHistoryMutation();
19885
20560
  } catch (err) {
19886
- const reason = err instanceof Error ? err.message : String(err);
19887
- debugLogger8.error(
19888
- `[ACP] File-history rewind failed for session=${sessionId} promptId=${promptId}: ${reason}`
19889
- );
19890
- filesFailed = [`file-history-rewind: ${reason}`];
20561
+ if (err instanceof RequestError) {
20562
+ const msg = err.message;
20563
+ if (msg.includes("Cannot rewind while a prompt is running") || msg.includes("Session is busy processing a turn")) {
20564
+ throw new RequestError(err.code, msg, {
20565
+ errorKind: "session_busy"
20566
+ });
20567
+ }
20568
+ if (msg.includes("compressed or does not exist")) {
20569
+ throw new RequestError(err.code, msg, {
20570
+ errorKind: "invalid_rewind_target"
20571
+ });
20572
+ }
20573
+ }
20574
+ throw err;
19891
20575
  }
19892
- }
19893
- let artifactSnapshot;
19894
- let artifactSnapshotUnavailable;
19895
- try {
19896
- const config = session.getConfig();
19897
- const recording = config.getChatRecordingService();
19898
- await recording?.flush();
19899
- const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
19900
- const sessionData = recording ? await recording.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
19901
- if (sessionData === void 0) {
19902
- artifactSnapshotUnavailable = "session data unavailable after rewind";
19903
- } else if (sessionData.artifactSnapshot) {
19904
- artifactSnapshot = sessionData.artifactSnapshot;
19905
- } else {
19906
- artifactSnapshot = {
19907
- v: SESSION_ARTIFACT_PERSISTENCE_VERSION,
19908
- sessionId,
19909
- sequence: 0,
19910
- artifacts: [],
19911
- tombstonedIds: [],
19912
- stickyEphemeralIds: [],
19913
- warnings: []
20576
+ try {
20577
+ let filesChanged = [];
20578
+ let filesFailed = [];
20579
+ if (rewindFiles && promptId) {
20580
+ const fhs = session.getConfig().getFileHistoryService();
20581
+ try {
20582
+ const fileResult = await fhs.rewind(promptId, true);
20583
+ filesChanged = fileResult.filesChanged;
20584
+ filesFailed = fileResult.filesFailed;
20585
+ } catch (err) {
20586
+ const reason = err instanceof Error ? err.message : String(err);
20587
+ debugLogger8.error(
20588
+ `[ACP] File-history rewind failed for session=${sessionId} promptId=${promptId}: ${reason}`
20589
+ );
20590
+ filesFailed = [`file-history-rewind: ${reason}`];
20591
+ }
20592
+ }
20593
+ let artifactSnapshot;
20594
+ let artifactSnapshotUnavailable;
20595
+ try {
20596
+ const config = session.getConfig();
20597
+ const recording = config.getChatRecordingService();
20598
+ await recording?.flush();
20599
+ const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
20600
+ const sessionData = recording ? await recording.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
20601
+ if (sessionData === void 0) {
20602
+ artifactSnapshotUnavailable = "session data unavailable after rewind";
20603
+ } else if (sessionData.artifactSnapshot) {
20604
+ artifactSnapshot = sessionData.artifactSnapshot;
20605
+ } else {
20606
+ artifactSnapshot = {
20607
+ v: SESSION_ARTIFACT_PERSISTENCE_VERSION,
20608
+ sessionId,
20609
+ sequence: 0,
20610
+ artifacts: [],
20611
+ tombstonedIds: [],
20612
+ stickyEphemeralIds: [],
20613
+ warnings: []
20614
+ };
20615
+ }
20616
+ } catch (err) {
20617
+ const reason = err instanceof Error ? err.message : String(err);
20618
+ artifactSnapshotUnavailable = "artifact snapshot unavailable after rewind";
20619
+ debugLogger8.warn(
20620
+ `[ACP] Failed to rebuild artifact snapshot after rewind for session=${sessionId}: ${reason}`
20621
+ );
20622
+ }
20623
+ return {
20624
+ success: true,
20625
+ historyBeforeRewind,
20626
+ ...rewindResult,
20627
+ filesChanged,
20628
+ filesFailed,
20629
+ ...artifactSnapshot ? { artifactSnapshot } : {},
20630
+ ...artifactSnapshotUnavailable ? { artifactSnapshotUnavailable } : {}
19914
20631
  };
20632
+ } finally {
20633
+ releaseHistoryMutation();
19915
20634
  }
19916
- } catch (err) {
19917
- const reason = err instanceof Error ? err.message : String(err);
19918
- artifactSnapshotUnavailable = "artifact snapshot unavailable after rewind";
19919
- debugLogger8.warn(
19920
- `[ACP] Failed to rebuild artifact snapshot after rewind for session=${sessionId}: ${reason}`
19921
- );
19922
- }
19923
- return {
19924
- success: true,
19925
- historyBeforeRewind,
19926
- ...rewindResult,
19927
- filesChanged,
19928
- filesFailed,
19929
- ...artifactSnapshot ? { artifactSnapshot } : {},
19930
- ...artifactSnapshotUnavailable ? { artifactSnapshotUnavailable } : {}
19931
- };
20635
+ });
19932
20636
  }
19933
20637
  case "qwen/session/loadUpdates": {
19934
20638
  const sessionId = params["sessionId"];
@@ -20031,6 +20735,16 @@ ${outputText}
20031
20735
  );
20032
20736
  }
20033
20737
  const name = params["name"];
20738
+ const atRecordId = params["atRecordId"];
20739
+ if (atRecordId !== void 0 && typeof atRecordId !== "string") {
20740
+ throw RequestError.invalidParams(void 0, "Invalid atRecordId");
20741
+ }
20742
+ if (isSideTask && atRecordId !== void 0) {
20743
+ throw RequestError.invalidParams(
20744
+ void 0,
20745
+ "atRecordId is not supported for side tasks"
20746
+ );
20747
+ }
20034
20748
  const sourceSession = this.sessions.get(sessionId);
20035
20749
  if (!sourceSession) {
20036
20750
  throw new RequestError(-32004, `Session not found: ${sessionId}`, {
@@ -20038,60 +20752,77 @@ ${outputText}
20038
20752
  sessionId
20039
20753
  });
20040
20754
  }
20755
+ if (!isSideTask) {
20756
+ if (!sourceSession.isTurnIdle()) {
20757
+ throw new RequestError(
20758
+ -32602,
20759
+ "Cannot branch while a prompt is running",
20760
+ { errorKind: "session_busy" }
20761
+ );
20762
+ }
20763
+ try {
20764
+ return await this.runExclusiveHistoryMutation(
20765
+ sessionId,
20766
+ async () => {
20767
+ await sourceSession.assertCanStartTurn();
20768
+ const releaseHistoryMutation = sourceSession.beginHistoryMutation();
20769
+ try {
20770
+ const sourceConfig2 = sourceSession.getConfig();
20771
+ const recording2 = sourceConfig2.getChatRecordingService();
20772
+ const sessionService2 = sourceConfig2.getSessionService();
20773
+ const baseName = deriveForkBaseName(
20774
+ name,
20775
+ recording2,
20776
+ sessionId
20777
+ );
20778
+ const title2 = await computeUniqueBranchTitle(
20779
+ baseName,
20780
+ sessionService2
20781
+ );
20782
+ const newSessionId2 = randomUUID2();
20783
+ const fork2 = /* @__PURE__ */ __name(() => sessionService2.forkSession(sessionId, newSessionId2, {
20784
+ title: title2,
20785
+ ...atRecordId !== void 0 ? { atRecordId } : {}
20786
+ }), "fork");
20787
+ if (recording2) {
20788
+ await recording2.runWithWriteBarrier(fork2);
20789
+ } else {
20790
+ await fork2();
20791
+ }
20792
+ return { newSessionId: newSessionId2, title: title2, displayName: title2 };
20793
+ } finally {
20794
+ releaseHistoryMutation();
20795
+ }
20796
+ }
20797
+ );
20798
+ } catch (error) {
20799
+ if (error instanceof BranchPointInvalidError) {
20800
+ throw new RequestError(-32009, error.message, {
20801
+ errorKind: "branch_point_invalid",
20802
+ recordId: error.recordId
20803
+ });
20804
+ }
20805
+ throw error;
20806
+ }
20807
+ }
20041
20808
  const sourceConfig = sourceSession.getConfig();
20042
20809
  const recording = sourceConfig.getChatRecordingService();
20043
- if (recording) {
20044
- await recording.flush();
20045
- }
20046
- const newSessionId = randomUUID2();
20810
+ if (recording) await recording.flush();
20047
20811
  const sessionService = sourceConfig.getSessionService();
20048
- const fork = /* @__PURE__ */ __name(() => isSideTask ? sessionService.forkSession(sessionId, newSessionId, {
20812
+ const title = deriveForkBaseName(name, recording, sessionId);
20813
+ const newSessionId = randomUUID2();
20814
+ const fork = /* @__PURE__ */ __name(() => sessionService.forkSession(sessionId, newSessionId, {
20049
20815
  source: {
20050
20816
  sourceType: "side_task",
20051
20817
  sourceId: sessionId
20052
- }
20053
- }) : sessionService.forkSession(sessionId, newSessionId), "fork");
20054
- if (isSideTask && recording) {
20818
+ },
20819
+ title
20820
+ }), "fork");
20821
+ if (recording) {
20055
20822
  await recording.runWithWriteBarrier(fork);
20056
20823
  } else {
20057
20824
  await fork();
20058
20825
  }
20059
- let title;
20060
- try {
20061
- let baseName;
20062
- if (typeof name === "string" && name.trim().length > 0) {
20063
- baseName = name.trim();
20064
- } else {
20065
- const existingTitle = recording?.getCurrentCustomTitle();
20066
- const stripped = existingTitle?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, "").trim();
20067
- if (stripped && stripped.length > 0) {
20068
- baseName = stripped;
20069
- } else {
20070
- baseName = sessionId.slice(0, 8);
20071
- }
20072
- }
20073
- title = isSideTask ? baseName : await computeUniqueBranchTitle(baseName, sessionService);
20074
- const renamed = await sessionService.renameSession(
20075
- newSessionId,
20076
- title,
20077
- "manual"
20078
- );
20079
- if (!renamed) {
20080
- throw new RequestError(
20081
- -32603,
20082
- `Failed to set title on forked session ${newSessionId}`,
20083
- { errorKind: "internal", sessionId: newSessionId }
20084
- );
20085
- }
20086
- } catch (err) {
20087
- sessionService.removeSession(newSessionId).catch((rmErr) => {
20088
- process.stderr.write(
20089
- `qwen serve: failed to clean up orphan session ${newSessionId}: ${rmErr instanceof Error ? rmErr.message : rmErr}
20090
- `
20091
- );
20092
- });
20093
- throw err;
20094
- }
20095
20826
  return { newSessionId, title, displayName: title };
20096
20827
  }
20097
20828
  case "qwen/settings/getCore": {
@@ -20876,6 +21607,7 @@ ${outputText}
20876
21607
  config,
20877
21608
  this.connection,
20878
21609
  settings,
21610
+ (operation) => this.runExclusiveHistoryMutation(sessionId, operation),
20879
21611
  () => this.activeWorkReporter?.notifyChanged()
20880
21612
  );
20881
21613
  let published = false;