@qwen-code/qwen-code 0.21.12-preview.5 → 0.21.13

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 (347) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +7 -5
  2. package/bundled/qc-helper/docs/features/channels/overview.md +1 -1
  3. package/bundled/qc-helper/docs/features/channels/plugins.md +11 -11
  4. package/bundled/qc-helper/docs/features/code-review.md +13 -12
  5. package/bundled/qc-helper/docs/qwen-serve.md +65 -0
  6. package/bundled/review/SKILL.md +96 -68
  7. package/chunks/{MaxSizedBox-6STELMXN.js → MaxSizedBox-UQALOVVT.js} +46 -46
  8. package/chunks/{StandaloneSessionPicker-LXMGCAIF.js → StandaloneSessionPicker-KEGXNUG6.js} +68 -69
  9. package/chunks/{acp-startup-profiler-TVI2OVUN.js → acp-startup-profiler-NMDXYGDN.js} +2 -2
  10. package/chunks/{acpAgent-NFRP4O5A.js → acpAgent-XPES32S7.js} +804 -380
  11. package/chunks/{agent-4AGYD6I6.js → agent-DPTOZFEM.js} +42 -42
  12. package/chunks/{agent-headless-GH4UIDXU.js → agent-headless-GJCQMURW.js} +42 -42
  13. package/chunks/{anthropicContentGenerator-ZBBX5VMY.js → anthropicContentGenerator-G7BVXTKN.js} +25 -25
  14. package/chunks/{artifact-tool-RWJAKYBZ.js → artifact-tool-GEXTOPVO.js} +5 -5
  15. package/chunks/{askUserQuestion-IQCA2SOX.js → askUserQuestion-B33XRSB7.js} +2 -2
  16. package/chunks/{bridge-3S4SKXSQ.js → bridge-YNQBAA4Z.js} +48 -48
  17. package/chunks/{build-RZS65IIX.js → build-GDBLPA24.js} +1 -1
  18. package/chunks/{channel-management-service-5ZYX4ROW.js → channel-management-service-GWY2GAIC.js} +4 -4
  19. package/chunks/{channel-settings-store-62E3TWVK.js → channel-settings-store-WNWYFHG7.js} +49 -49
  20. package/chunks/{channel-worker-group-QFJKXO7R.js → channel-worker-group-7LXCMZ77.js} +6 -6
  21. package/chunks/{channel-worker-manager-PWD2UURZ.js → channel-worker-manager-RYEME4ZZ.js} +6 -6
  22. package/chunks/{channel-worker-supervisor-XQJBGFCM.js → channel-worker-supervisor-OEVWBHGT.js} +4 -4
  23. package/chunks/{chunk-LHOG4E6Y.js → chunk-22C7BQ6D.js} +3 -3
  24. package/chunks/{chunk-KTWUFHS4.js → chunk-25EYDK42.js} +3 -3
  25. package/chunks/{chunk-QEWAHAW2.js → chunk-2B2BF7P7.js} +3 -3
  26. package/chunks/{chunk-2SB4SLKC.js → chunk-2IIJTXYF.js} +1 -3
  27. package/chunks/{chunk-6LDLDK6E.js → chunk-2M55OBEB.js} +1 -3
  28. package/chunks/{chunk-V3NMFQD2.js → chunk-3EZLLVDF.js} +2 -2
  29. package/chunks/{chunk-HUDUANHL.js → chunk-3U3VAL47.js} +1 -1
  30. package/chunks/{chunk-BKHCW2BI.js → chunk-3VUENPWF.js} +10 -0
  31. package/chunks/{chunk-XY7DGTIC.js → chunk-45NQKMYB.js} +1 -1
  32. package/chunks/{chunk-VGGNHRYZ.js → chunk-4PKCUT7F.js} +7 -7
  33. package/chunks/{chunk-T7YMWGFY.js → chunk-4S5337WV.js} +1491 -711
  34. package/chunks/{chunk-FVHLDSQS.js → chunk-4W5U2TUT.js} +3 -3
  35. package/chunks/{chunk-6SU6OW5Z.js → chunk-5CVO7YES.js} +1 -1
  36. package/chunks/{chunk-OZTGLK53.js → chunk-5EYKMUUY.js} +1 -1
  37. package/chunks/{chunk-ZRT36RSF.js → chunk-6HY6IF3Z.js} +1 -1
  38. package/chunks/{chunk-HRAFAUM7.js → chunk-6ORZ2EDC.js} +3 -3
  39. package/chunks/{chunk-JOVJCXN4.js → chunk-6QFDQMQX.js} +1 -1
  40. package/chunks/{chunk-CPTIJGUK.js → chunk-6YKYPVDV.js} +4 -4
  41. package/chunks/{chunk-62OKKUOX.js → chunk-76J3IJ3M.js} +9 -7
  42. package/chunks/{chunk-JVY7FHUZ.js → chunk-7U5G6JXI.js} +9 -0
  43. package/chunks/{chunk-TIM7NVEO.js → chunk-7UXUJ5T3.js} +1 -1
  44. package/chunks/{chunk-YCGXJ4Q3.js → chunk-A267JX7H.js} +6 -6
  45. package/chunks/{chunk-4JS2QK7P.js → chunk-A4MFR4C5.js} +1 -1
  46. package/chunks/{chunk-TN3REXN4.js → chunk-A4QRWUDE.js} +79 -36
  47. package/chunks/{chunk-JW5UEE3V.js → chunk-A6NRNRKE.js} +1 -1
  48. package/chunks/{chunk-T4G33L3W.js → chunk-AA2BEKV3.js} +3 -3
  49. package/chunks/{chunk-M3DWLXEO.js → chunk-AFSG32D5.js} +1 -1
  50. package/chunks/{chunk-R4YAQULI.js → chunk-AS5IN4GK.js} +5 -5
  51. package/chunks/{chunk-ADJDLEVO.js → chunk-AW27A43Y.js} +9 -11
  52. package/chunks/{chunk-RIDUB2GC.js → chunk-AW4TRXOC.js} +1 -1
  53. package/chunks/{chunk-XL6GYJL2.js → chunk-AXN7UPYQ.js} +2 -2
  54. package/chunks/{chunk-M4NWDIFU.js → chunk-AZQ3DT76.js} +1 -1
  55. package/chunks/{chunk-OSA2TFDI.js → chunk-BHILXOC3.js} +3 -3
  56. package/chunks/{chunk-YMIQ24FR.js → chunk-BKPPWD33.js} +2 -2
  57. package/chunks/{chunk-YMB77M76.js → chunk-BUQDLC2G.js} +59 -0
  58. package/chunks/{chunk-DXXYMK2U.js → chunk-BVJS5BSP.js} +1 -1
  59. package/chunks/{chunk-EGB2PIYM.js → chunk-BZ263IKX.js} +1 -1
  60. package/chunks/{chunk-6OJDN5ZT.js → chunk-CHHABXPE.js} +1 -1
  61. package/chunks/{chunk-ZPZANKVP.js → chunk-CKSJECTU.js} +4 -4
  62. package/chunks/{chunk-H6BFLALJ.js → chunk-CPHEPGAO.js} +1 -1
  63. package/chunks/{chunk-V6PERRH4.js → chunk-CU6GJD55.js} +1 -1
  64. package/chunks/{chunk-ZZ7RUTJ4.js → chunk-CZBYX5MY.js} +1 -1
  65. package/chunks/{chunk-2OFDCPMS.js → chunk-DGK6P3BQ.js} +13 -13
  66. package/chunks/{chunk-NM33GGOM.js → chunk-DGZEMW5R.js} +3 -3
  67. package/chunks/{chunk-UPUAGRKY.js → chunk-DXIBNLBZ.js} +2 -4
  68. package/chunks/{chunk-J5SUM3ZJ.js → chunk-E23IPNGS.js} +25 -2
  69. package/chunks/{chunk-TNETSI2A.js → chunk-E3DYKPYZ.js} +3 -3
  70. package/chunks/{chunk-3MJ44LNC.js → chunk-EL5SXY3T.js} +265 -138
  71. package/chunks/{chunk-AFKOAHC3.js → chunk-EZ5RP345.js} +13 -11
  72. package/chunks/{chunk-PSTHNTHF.js → chunk-FAAUPSY2.js} +1 -1
  73. package/chunks/{chunk-NW7SPXVG.js → chunk-FDGGZIYW.js} +1 -1
  74. package/chunks/{chunk-6YSSQFHQ.js → chunk-GGDBMYGZ.js} +5 -5
  75. package/chunks/{chunk-CDDLHCC2.js → chunk-GMIEIY3Y.js} +5 -5
  76. package/chunks/{chunk-6JFPUJ2O.js → chunk-GO7STP6N.js} +4 -4
  77. package/chunks/{chunk-7JL5YBSA.js → chunk-H4A72DE5.js} +1 -1
  78. package/chunks/{chunk-I3UEXUWJ.js → chunk-HUTNYWBG.js} +2 -2
  79. package/chunks/{chunk-UQPLUR4A.js → chunk-IA2K2HJE.js} +2 -2
  80. package/chunks/{chunk-Q7VJUIIB.js → chunk-IGGGG5CX.js} +4104 -1293
  81. package/chunks/{chunk-VE2UV7IN.js → chunk-IWPYVAO2.js} +4 -4
  82. package/chunks/{chunk-HAR4G5K2.js → chunk-JNDY2MDR.js} +2 -2
  83. package/chunks/{chunk-UALXTL5Y.js → chunk-JOOFMXGF.js} +6 -6
  84. package/chunks/{chunk-HOXEJHJQ.js → chunk-JUEPY766.js} +3 -3
  85. package/chunks/{chunk-Q7YDKOGY.js → chunk-JVEGA3MM.js} +1 -1
  86. package/chunks/{chunk-QBJYSIQ4.js → chunk-K3LPAED5.js} +53 -12
  87. package/chunks/{chunk-UHF5VBKO.js → chunk-KBXKR5R2.js} +1 -1
  88. package/chunks/{chunk-32SNBMNP.js → chunk-KD5BOPLP.js} +27 -27
  89. package/chunks/{chunk-67F2BEYW.js → chunk-KV27IEHM.js} +1 -1
  90. package/chunks/{chunk-DLDVO2NY.js → chunk-LJQAUZMR.js} +360 -174
  91. package/chunks/{chunk-BNRIQWXW.js → chunk-M732YJPW.js} +7 -7
  92. package/chunks/{chunk-JRTJEGSP.js → chunk-MA2HEDVP.js} +1 -1
  93. package/chunks/{chunk-5IW3FJGD.js → chunk-MC4TLKEI.js} +2 -2
  94. package/chunks/{chunk-2ASWIM4A.js → chunk-MIPFDQAF.js} +1 -1
  95. package/chunks/{chunk-6GTKI2YX.js → chunk-MLPXSYXR.js} +133 -28
  96. package/chunks/{chunk-KRXPRVGL.js → chunk-MLXTMF7H.js} +0 -1
  97. package/chunks/{chunk-NNGCKJAD.js → chunk-MRMJCLIY.js} +3 -3
  98. package/chunks/{chunk-E7XJWIWC.js → chunk-N5YPT6PH.js} +7 -7
  99. package/chunks/{chunk-72SKJ3E7.js → chunk-NEFOOD54.js} +3 -3
  100. package/chunks/{chunk-2U3UCXZ3.js → chunk-NHDR76JX.js} +45 -13
  101. package/chunks/{chunk-QLFTWYTO.js → chunk-NM5V5OVW.js} +3 -3
  102. package/chunks/{chunk-N4LVA3S6.js → chunk-NNHNLJ2X.js} +840 -60
  103. package/chunks/chunk-NYWWQ437.js +24 -0
  104. package/chunks/{chunk-DGNQ5AFX.js → chunk-O4D7SPJN.js} +2 -2
  105. package/chunks/{chunk-YY23TR4M.js → chunk-O565M6A4.js} +411 -10
  106. package/chunks/{chunk-VUTOV2HG.js → chunk-OD2WU5QY.js} +4 -3
  107. package/chunks/{chunk-B66LYK4B.js → chunk-OMLJNPBE.js} +42 -12
  108. package/chunks/{chunk-WAF6AR5Y.js → chunk-OOQUVWIG.js} +4 -4
  109. package/chunks/{chunk-A6GQUQ7I.js → chunk-OVZPVYZB.js} +2 -2
  110. package/chunks/{chunk-VPZMLGD3.js → chunk-OXCMMLED.js} +5 -5
  111. package/chunks/{chunk-646ZB2TS.js → chunk-OY5RNSV4.js} +3 -3
  112. package/chunks/{chunk-V7RNNPGC.js → chunk-P5Y23G2L.js} +18 -1
  113. package/chunks/{chunk-O6SLWH4X.js → chunk-P7MPQI75.js} +2 -2
  114. package/chunks/{chunk-3HXLH5QV.js → chunk-PP4FUZNV.js} +47 -4
  115. package/chunks/{chunk-4XX2LZ3E.js → chunk-PQ36L4F5.js} +1 -1
  116. package/chunks/{chunk-SKRHR6N2.js → chunk-PT4I7NBA.js} +1 -1
  117. package/chunks/{chunk-KQLW7LLV.js → chunk-QF2NHSPB.js} +603 -66
  118. package/chunks/{chunk-KK3FEHPJ.js → chunk-QFJ5JHQR.js} +1 -1
  119. package/chunks/{chunk-N2G4RA77.js → chunk-QIH2HAEN.js} +1 -1
  120. package/chunks/{chunk-QSWDGAIC.js → chunk-QILD6R27.js} +1 -1
  121. package/chunks/{chunk-NHZF4VCD.js → chunk-QNQAPSN2.js} +1 -1
  122. package/chunks/{chunk-6DH5YA3X.js → chunk-QRCNA3SR.js} +8 -8
  123. package/chunks/{chunk-3RC5Q66G.js → chunk-QV5YN5YD.js} +7 -5
  124. package/chunks/{chunk-7TKNMQ6L.js → chunk-RIAABG2K.js} +2 -2
  125. package/chunks/{chunk-LYRA6ZTI.js → chunk-RLKC46YT.js} +138 -11
  126. package/chunks/{chunk-YI5G32RU.js → chunk-ROIYNTHJ.js} +3 -3
  127. package/chunks/{chunk-UAAWNTOC.js → chunk-RVOJ2FBP.js} +12 -12
  128. package/chunks/{chunk-SNHBRO4C.js → chunk-RWDNJBWN.js} +2 -2
  129. package/chunks/{chunk-UFHPAMAV.js → chunk-S5DWMTHO.js} +11 -1
  130. package/chunks/{chunk-TROB4PZY.js → chunk-SG7ZP5PG.js} +4 -4
  131. package/chunks/{chunk-E74YSVIN.js → chunk-SXCOEJO4.js} +1 -1
  132. package/chunks/{chunk-U5C2GIN2.js → chunk-TIGA2IVL.js} +117 -3
  133. package/chunks/chunk-TS6625XH.js +488 -0
  134. package/chunks/{chunk-EHXS5MAC.js → chunk-TUGSVUJB.js} +7 -7
  135. package/chunks/{chunk-E3GLDLYB.js → chunk-TYAMGABM.js} +0 -6
  136. package/chunks/{chunk-ZLX7FTZQ.js → chunk-U3VNBPUO.js} +3 -3
  137. package/chunks/{chunk-F7PTQFTB.js → chunk-UKMR3CKV.js} +4 -4
  138. package/chunks/{chunk-7WUMS2UA.js → chunk-UPDOZBWO.js} +1 -1
  139. package/chunks/{chunk-YK4O72LT.js → chunk-UZPM4XHR.js} +4 -4
  140. package/chunks/{chunk-VKEA37IR.js → chunk-V26NVGAU.js} +1 -1
  141. package/chunks/{chunk-IJCZP2MA.js → chunk-V57QC6WW.js} +3 -3
  142. package/chunks/{chunk-LSMCI42W.js → chunk-WFSTRPRO.js} +3 -3
  143. package/chunks/{chunk-5KZNWF2M.js → chunk-WGHHA7ZH.js} +1 -1
  144. package/chunks/{chunk-A4BAHMJF.js → chunk-WSH6GRKG.js} +4 -4
  145. package/chunks/{chunk-OK727E5D.js → chunk-X26JYGTD.js} +1 -1
  146. package/chunks/{chunk-VAPNUDD5.js → chunk-XHRY7BXD.js} +4 -4
  147. package/chunks/{chunk-XNL23MGG.js → chunk-XIT3GURH.js} +3 -3
  148. package/chunks/{chunk-2RTRFLWH.js → chunk-XLLKYULU.js} +6 -6
  149. package/chunks/{chunk-C2DR57L6.js → chunk-XUJNK7Y6.js} +1 -1
  150. package/chunks/{chunk-AAZWJAPQ.js → chunk-Y3YCSWG5.js} +2 -2
  151. package/chunks/{chunk-ZTBFA7I6.js → chunk-YEYY7TEP.js} +7 -7
  152. package/chunks/{chunk-FTGU6G45.js → chunk-YZHRN3CF.js} +2 -2
  153. package/chunks/{chunk-2N6CV4PW.js → chunk-YZOSNW4R.js} +1 -1
  154. package/chunks/{chunk-U7ROFHSH.js → chunk-ZLCT4C5A.js} +1 -1
  155. package/chunks/{chunk-VBKTP7TH.js → chunk-ZYBBISBY.js} +15 -34
  156. package/chunks/{chunk-7ATQGA6V.js → chunk-ZYYTZUI2.js} +6 -6
  157. package/chunks/{chunk-RXX5T3IF.js → chunk-ZZO74WKW.js} +44 -8
  158. package/chunks/{computer-use-ZFBJYSR3.js → computer-use-77C5FHMW.js} +45 -45
  159. package/chunks/{config-utils-7JZQN6L2.js → config-utils-IVHRSXWI.js} +4 -4
  160. package/chunks/{contextCommand-G3TAIY7T.js → contextCommand-PJ77GBWL.js} +44 -44
  161. package/chunks/{core-runtime-K3MQVNSF.js → core-runtime-7VMIKUTG.js} +42 -42
  162. package/chunks/{create-sub-session-DMTLJPDG.js → create-sub-session-2L5MQRN4.js} +42 -42
  163. package/chunks/{create-sub-session-23ULO5PO.js → create-sub-session-KRQULJE6.js} +2 -2
  164. package/chunks/{cron-create-5WUTNKNF.js → cron-create-H7UEPDSN.js} +4 -4
  165. package/chunks/{cron-delete-JEQ27YPS.js → cron-delete-6SZK7YFM.js} +4 -4
  166. package/chunks/{cron-list-IXGCA7UR.js → cron-list-H25JIHEZ.js} +4 -4
  167. package/chunks/{daemon-UBVOQMWY.js → daemon-2KTG7ZBN.js} +108 -9
  168. package/chunks/daemon-git-worktree-guard-DXYIMWFT.js +2062 -0
  169. package/chunks/{daemon-status-provider-KFLEZGD7.js → daemon-status-provider-ZDOYJCU6.js} +52 -53
  170. package/chunks/{daemon-trust-policy-ZZ6DRDAC.js → daemon-trust-policy-E67OYUK2.js} +48 -48
  171. package/chunks/{daemon-trust-policy-monitor-CIKHNV2K.js → daemon-trust-policy-monitor-RYYGCQ3J.js} +48 -48
  172. package/chunks/{deferred-core-runtime-MM7X7UYR.js → deferred-core-runtime-3SGXFXEQ.js} +44 -44
  173. package/chunks/{devtools-X6ROTKHE.js → devtools-4QFYJT6U.js} +1 -1
  174. package/chunks/discovery-ORA5J7YP.js +27 -0
  175. package/chunks/{display-image-CAD7RAUM.js → display-image-ON3EYFRD.js} +4 -4
  176. package/chunks/{dist-B3ODKYEB.js → dist-4ZPG4BY6.js} +2 -2
  177. package/chunks/{dist-CCUH2Z4C.js → dist-BROOP2EG.js} +1 -1
  178. package/chunks/{dist-DANKRAB3.js → dist-IYYN3RUT.js} +2 -2
  179. package/chunks/{dist-5VDE7U3A.js → dist-JWMKPWT5.js} +3 -1
  180. package/chunks/{dist-6RK4U6VU.js → dist-K7IQB53U.js} +1 -1
  181. package/chunks/{dist-EZHCZSW6.js → dist-MAQXAQ2Y.js} +1 -1
  182. package/chunks/{dist-362MN6CP.js → dist-WJ4BHIEW.js} +2 -2
  183. package/chunks/{dist-M3XMEIP2.js → dist-YEPL4RAW.js} +1 -1
  184. package/chunks/{earlyInputCapture-O77TUBIF.js → earlyInputCapture-KJMLFVQV.js} +43 -43
  185. package/chunks/{edit-CZ23AVP6.js → edit-I4LQFAEC.js} +50 -49
  186. package/chunks/{enter-worktree-4EMS7IRL.js → enter-worktree-YNPOJSRH.js} +47 -47
  187. package/chunks/{enterPlanMode-TS6KO6DU.js → enterPlanMode-XCPK62ER.js} +47 -47
  188. package/chunks/{environment-7JAXEU6I.js → environment-S7CTIHMX.js} +44 -44
  189. package/chunks/{errors-NBABPF4S.js → errors-7HB2AIDS.js} +44 -44
  190. package/chunks/{exit-worktree-Q3NFHYUI.js → exit-worktree-AIIY7SR6.js} +47 -47
  191. package/chunks/{exitPlanMode-4JH6WLKL.js → exitPlanMode-R4JY7V2O.js} +42 -42
  192. package/chunks/{external-tool-guard-provider-5HTGOPGU.js → external-tool-guard-provider-TE4DRY36.js} +1 -1
  193. package/chunks/{fast-path-5LFDLPHJ.js → fast-path-NDJV3ZFJ.js} +3 -3
  194. package/chunks/{gemini-MB4S7YLN.js → gemini-RSUFP5OE.js} +108 -103
  195. package/chunks/{geminiContentGenerator-EQY2QU7K.js → geminiContentGenerator-SQ5XBPZ7.js} +11 -11
  196. package/chunks/{glob-LA5XO2H7.js → glob-J4RUJAHX.js} +49 -49
  197. package/chunks/{goal-tools-LQFO4BRY.js → goal-tools-VHTNVOKK.js} +56 -12
  198. package/chunks/{grep-KYBZMY36.js → grep-VJWPLFOT.js} +47 -47
  199. package/chunks/{handleAutoUpdate-HZJSAUNC.js → handleAutoUpdate-POCX2MNB.js} +46 -46
  200. package/chunks/{i18n-BSCIN4J4.js → i18n-RM5YOICI.js} +43 -43
  201. package/chunks/{image-gen-HGURQAHX.js → image-gen-EXECB5XM.js} +11 -11
  202. package/chunks/{initializer-WUHJXIB3.js → initializer-Z2AFGBNR.js} +49 -49
  203. package/chunks/{installationInfo-G3PDBWG2.js → installationInfo-4I5FXNMH.js} +43 -43
  204. package/chunks/{keychain-token-storage-GU75J2T2.js → keychain-token-storage-3XFJ5ZB2.js} +2 -2
  205. package/chunks/{list-IC7KDSZ6.js → list-ZMBFIGZA.js} +51 -51
  206. package/chunks/{list-agents-5PNMK2AM.js → list-agents-OSVDFI6S.js} +2 -2
  207. package/chunks/{loadedSettingsAdapter-Z3GOJRI7.js → loadedSettingsAdapter-T6TV4YJ7.js} +48 -48
  208. package/chunks/{loggingContentGenerator-E2QENFPH.js → loggingContentGenerator-WF4ZOJEZ.js} +99 -66
  209. package/chunks/{loop-wakeup-OV65FEGR.js → loop-wakeup-WQS6JYAG.js} +5 -5
  210. package/chunks/{ls-RPRSX26R.js → ls-D3HUFHDP.js} +6 -6
  211. package/chunks/{lsp-IWTJWFLT.js → lsp-3QDDJTCS.js} +2 -2
  212. package/chunks/{managed-npm-update-MX2OPCW4.js → managed-npm-update-E7IW6N7V.js} +43 -43
  213. package/chunks/{mcp-QQEWPNWV.js → mcp-6UNYX4HG.js} +48 -48
  214. package/chunks/{monitor-SV64FNV3.js → monitor-EE2UYMGE.js} +47 -47
  215. package/chunks/{node-YSOU44FX.js → node-UUDY34IG.js} +3 -3
  216. package/chunks/nonInteractiveCli-WAY237O4.js +163 -0
  217. package/chunks/{notebook-edit-QPYSWPRI.js → notebook-edit-NTDY4QDU.js} +47 -47
  218. package/chunks/{openaiContentGenerator-CMZXOSVA.js → openaiContentGenerator-YNFVJMRJ.js} +30 -30
  219. package/chunks/{pidfile-D5UXVVAI.js → pidfile-4XSFLYBZ.js} +43 -43
  220. package/chunks/{processUtils-ZEIMIVPX.js → processUtils-WDA2MJFD.js} +2 -2
  221. package/chunks/proper-lockfile-3LHWIM44.js +8 -0
  222. package/chunks/{qwenContentGenerator-JAXZKB7R.js → qwenContentGenerator-434M7QKY.js} +50 -50
  223. package/chunks/{qwenOAuth2-C2QWTD2G.js → qwenOAuth2-GMYZOO6A.js} +10 -10
  224. package/chunks/{read-file-2V5GE6ZW.js → read-file-TAFBKMNI.js} +11 -11
  225. package/chunks/{read-mcp-resource-THCSZHXO.js → read-mcp-resource-XD54ZQMC.js} +2 -2
  226. package/chunks/{record-artifact-76YYQA5F.js → record-artifact-SEYFJEJF.js} +3 -3
  227. package/chunks/{resumeHistoryUtils-UZ7GHPNY.js → resumeHistoryUtils-EVG3WYK2.js} +50 -50
  228. package/chunks/{ripGrep-MUTMPQSV.js → ripGrep-WOEK2PXS.js} +42 -42
  229. package/chunks/{run-qwen-serve-WU43JKEA.js → run-qwen-serve-3QSGRXAN.js} +417 -208
  230. package/chunks/{runtime-YLOFDP2P.js → runtime-5MLLZ7DC.js} +53 -53
  231. package/chunks/{scheduler-G44OPSZE.js → scheduler-RPBJ63CH.js} +44 -44
  232. package/chunks/{sdk-exporters-grpc-4QKV6MCX.js → sdk-exporters-grpc-54L4LS5L.js} +2 -2
  233. package/chunks/{sdk-exporters-http-A7XLKZO7.js → sdk-exporters-http-XUVP63H6.js} +12 -12
  234. package/chunks/{sdk-impl-XO4UF6PR.js → sdk-impl-YXUEN2Z2.js} +8 -8
  235. package/chunks/{send-message-P5SLP57G.js → send-message-VZENRWRH.js} +6 -6
  236. package/chunks/{serve-CZQDBDYV.js → serve-HS3XLPXU.js} +50 -50
  237. package/chunks/{server-HGI2KF3Y.js → server-TC4A7AAZ.js} +3850 -1630
  238. package/chunks/{session-OVMSHAO5.js → session-UBOFXVMN.js} +92 -95
  239. package/chunks/{settings-TWX6ROGP.js → settings-D5644OM5.js} +47 -47
  240. package/chunks/{shell-JDSWGVC7.js → shell-3PZULQQV.js} +42 -42
  241. package/chunks/{skill-QILHTMYJ.js → skill-PEVVXQ3L.js} +22 -22
  242. package/chunks/{skill-settings-RKRD34RZ.js → skill-settings-J65JKKES.js} +47 -47
  243. package/chunks/{spawnChannel-V5PYSDEI.js → spawnChannel-IYGXRHSQ.js} +45 -47
  244. package/chunks/{standalone-update-Y52CWCGG.js → standalone-update-IFM53PE7.js} +44 -44
  245. package/chunks/{startInteractiveUI-RVA62ZM6.js → startInteractiveUI-3AVH7L6H.js} +3340 -2460
  246. package/chunks/{syntheticOutput-SEW4NA47.js → syntheticOutput-7GWFIDXT.js} +3 -3
  247. package/chunks/{task-create-247EAVF7.js → task-create-FCBDX7UH.js} +12 -12
  248. package/chunks/{task-list-ZJN4QHLK.js → task-list-YIYIUFUA.js} +6 -6
  249. package/chunks/{task-stop-MAYQJ42I.js → task-stop-X37KYTKB.js} +2 -2
  250. package/chunks/{task-update-SU5TMZGG.js → task-update-MYPFVOVM.js} +12 -12
  251. package/chunks/{team-create-YMWUDIE3.js → team-create-ZAIA7KAV.js} +47 -47
  252. package/chunks/{team-delete-3XVRPQBP.js → team-delete-6UMU4XLS.js} +6 -6
  253. package/chunks/{team-plan-approval-3GPZAW46.js → team-plan-approval-UNIUS7OD.js} +47 -47
  254. package/chunks/{terminal-image-renderer-UGQKWDM3.js → terminal-image-renderer-G343P2RV.js} +44 -44
  255. package/chunks/{theme-manager-KRG4GGFY.js → theme-manager-Z3RIT7DB.js} +43 -43
  256. package/chunks/{todoWrite-IE2YTCK7.js → todoWrite-U2R4NVF4.js} +4 -4
  257. package/chunks/{tool-search-SZRO5G72.js → tool-search-5R2OE4C7.js} +17 -17
  258. package/chunks/{total-session-admission-JYHYOKWX.js → total-session-admission-4KBHMQQ2.js} +48 -48
  259. package/chunks/{trustedFolders-2BDCB5NJ.js → trustedFolders-LK6T4XC7.js} +43 -43
  260. package/chunks/{update-relaunch-XSYVPSDL.js → update-relaunch-UBKROIC6.js} +5 -5
  261. package/chunks/{updateCheck-SMMJ27GG.js → updateCheck-W4Y2GFSD.js} +45 -45
  262. package/chunks/{useAutoAcceptIndicator-HPG4UFIZ.js → useAutoAcceptIndicator-C7BEICBF.js} +51 -51
  263. package/chunks/{validateNonInterActiveAuth-IIL774NT.js → validateNonInterActiveAuth-LTEI2TB6.js} +84 -86
  264. package/chunks/{version-WSGAB2PA.js → version-G5A5DGVS.js} +1 -1
  265. package/chunks/{web-fetch-LKC2F5DM.js → web-fetch-RTEQTR5Z.js} +20 -20
  266. package/chunks/{web-search-BHMAMXEU.js → web-search-5OXHEZPV.js} +16 -16
  267. package/chunks/{workflow-A7AQ52HO.js → workflow-ISQJHPG2.js} +54 -53
  268. package/chunks/{workspace-providers-status-JRT57TLL.js → workspace-providers-status-2ZPZPUPZ.js} +51 -51
  269. package/chunks/{workspace-registration-store-EACJNCM5.js → workspace-registration-store-CYNY6IP6.js} +2 -2
  270. package/chunks/{workspace-registry-OV5SI4ES.js → workspace-registry-34GTUUHB.js} +50 -49
  271. package/chunks/{workspace-service-PUHU4EEK.js → workspace-service-XCDQLE2Y.js} +53 -53
  272. package/chunks/{workspace-skills-status-YAJE3UW3.js → workspace-skills-status-RS4O7AIJ.js} +49 -49
  273. package/chunks/{workspace-trust-reconciler-JP5UR2H6.js → workspace-trust-reconciler-AYGXC7A3.js} +57 -56
  274. package/chunks/{write-file-UBIHUP5M.js → write-file-EWXKVVXF.js} +42 -42
  275. package/chunks/{zoom-image-4QTKAMTP.js → zoom-image-4BFYJ3HG.js} +11 -11
  276. package/cli.js +18 -17
  277. package/package.json +3 -3
  278. package/web-shell/assets/{arc-lZ04kynw.js → arc-CgOpDKvm.js} +1 -1
  279. package/web-shell/assets/{architectureDiagram-3BPJPVTR-B1wZVhzD.js → architectureDiagram-3BPJPVTR-0Ag_m34F.js} +1 -1
  280. package/web-shell/assets/{blockDiagram-GPEHLZMM-CO0e0yJt.js → blockDiagram-GPEHLZMM-IwTwFau0.js} +1 -1
  281. package/web-shell/assets/{c4Diagram-AAUBKEIU-Dfpo6Qie.js → c4Diagram-AAUBKEIU-DLa5GUv8.js} +1 -1
  282. package/web-shell/assets/channel-BrGVBa2L.js +1 -0
  283. package/web-shell/assets/{chunk-2J33WTMH-BvxArftT.js → chunk-2J33WTMH-DcYP-WFG.js} +1 -1
  284. package/web-shell/assets/{chunk-4BX2VUAB-BS2XXjGY.js → chunk-4BX2VUAB-C8MVPMiQ.js} +1 -1
  285. package/web-shell/assets/{chunk-55IACEB6-CYL6h3Ph.js → chunk-55IACEB6-BUi4Yfv3.js} +1 -1
  286. package/web-shell/assets/{chunk-727SXJPM-C-cWPX30.js → chunk-727SXJPM-Cy3Su2YY.js} +1 -1
  287. package/web-shell/assets/{chunk-AQP2D5EJ-CJLxNbVV.js → chunk-AQP2D5EJ-Dp8Teqv6.js} +1 -1
  288. package/web-shell/assets/{chunk-FMBD7UC4-DwfzKywA.js → chunk-FMBD7UC4-BDTDM-4j.js} +1 -1
  289. package/web-shell/assets/{chunk-ND2GUHAM-BI5raYHQ.js → chunk-ND2GUHAM-7HfDt0r2.js} +1 -1
  290. package/web-shell/assets/{chunk-QZHKN3VN-_GkNI90J.js → chunk-QZHKN3VN-BIBU0uCF.js} +1 -1
  291. package/web-shell/assets/classDiagram-4FO5ZUOK-B5TUzJzI.js +1 -0
  292. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-B5TUzJzI.js +1 -0
  293. package/web-shell/assets/{cose-bilkent-S5V4N54A-BAVLNxh9.js → cose-bilkent-S5V4N54A-DRLdcg9p.js} +1 -1
  294. package/web-shell/assets/{dagre-BM42HDAG-BD4XNLqp.js → dagre-BM42HDAG-DCCgDwqW.js} +1 -1
  295. package/web-shell/assets/{diagram-2AECGRRQ-WO567p8w.js → diagram-2AECGRRQ-CsBTBmk3.js} +1 -1
  296. package/web-shell/assets/{diagram-5GNKFQAL-mAk23VWO.js → diagram-5GNKFQAL-C9qjH8Lt.js} +1 -1
  297. package/web-shell/assets/{diagram-KO2AKTUF-YQEeHKze.js → diagram-KO2AKTUF-Brjs_lj2.js} +1 -1
  298. package/web-shell/assets/{diagram-LMA3HP47-CMVjxAjv.js → diagram-LMA3HP47-DtiWCl_F.js} +1 -1
  299. package/web-shell/assets/{diagram-OG6HWLK6-42hPvbM-.js → diagram-OG6HWLK6-DmfKLkBT.js} +1 -1
  300. package/web-shell/assets/{erDiagram-TEJ5UH35-CXU_cPfu.js → erDiagram-TEJ5UH35-Bve_4deH.js} +1 -1
  301. package/web-shell/assets/{flowDiagram-I6XJVG4X-D-3TdhMT.js → flowDiagram-I6XJVG4X-C2_kXCcV.js} +1 -1
  302. package/web-shell/assets/{ganttDiagram-6RSMTGT7-CsgkXolz.js → ganttDiagram-6RSMTGT7-BSBIjiTF.js} +1 -1
  303. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-B6Q3PBLD.js → gitGraphDiagram-PVQCEYII-CyebwI55.js} +1 -1
  304. package/web-shell/assets/index-CIDsgxTe.js +1792 -0
  305. package/web-shell/assets/index-DiQnWi_E.css +5 -0
  306. package/web-shell/assets/{index-BFrkGj2B.js → index-d0yfnV1M.js} +1 -1
  307. package/web-shell/assets/{infoDiagram-5YYISTIA-jiAfSXp8.js → infoDiagram-5YYISTIA-CSDGnWxU.js} +1 -1
  308. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-BWif5KeJ.js → ishikawaDiagram-YF4QCWOH-BK4jU13p.js} +1 -1
  309. package/web-shell/assets/{journeyDiagram-JHISSGLW-B-GAZthS.js → journeyDiagram-JHISSGLW-D_W6j-oF.js} +1 -1
  310. package/web-shell/assets/{kanban-definition-UN3LZRKU-9TEuATdL.js → kanban-definition-UN3LZRKU-C7xf-SdC.js} +1 -1
  311. package/web-shell/assets/{linear-dy_QPfyE.js → linear-DQmzxpxd.js} +1 -1
  312. package/web-shell/assets/{mermaid.core-DB2uLAnq.js → mermaid.core-9P7AGOLG.js} +5 -5
  313. package/web-shell/assets/{mindmap-definition-RKZ34NQL-ey_dyxi-.js → mindmap-definition-RKZ34NQL-DgcgMyPk.js} +1 -1
  314. package/web-shell/assets/{pieDiagram-4H26LBE5-_6BuMdDj.js → pieDiagram-4H26LBE5-3wWGb9eG.js} +1 -1
  315. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-B2rM19W2.js → quadrantDiagram-W4KKPZXB-BeCXnQw9.js} +1 -1
  316. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DWj8b7vW.js → requirementDiagram-4Y6WPE33-Bi1UOHDz.js} +1 -1
  317. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-D5dtYh0N.js → sankeyDiagram-5OEKKPKP-lrLUjjbb.js} +1 -1
  318. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DVkdn_qW.js → sequenceDiagram-3UESZ5HK-BFuqKz6Q.js} +1 -1
  319. package/web-shell/assets/{stateDiagram-AJRCARHV-DgwD_fi6.js → stateDiagram-AJRCARHV-8DemQLhu.js} +1 -1
  320. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DhM5ixYd.js +1 -0
  321. package/web-shell/assets/{timeline-definition-PNZ67QCA-vNr_1UNX.js → timeline-definition-PNZ67QCA-uzEuVQXg.js} +1 -1
  322. package/web-shell/assets/{vennDiagram-CIIHVFJN-ChFcGAcu.js → vennDiagram-CIIHVFJN-BQTeZ_-o.js} +1 -1
  323. package/web-shell/assets/{wardley-L42UT6IY-C8PXoSWk.js → wardley-L42UT6IY-B6yM5Im7.js} +1 -1
  324. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-C2nqOV6i.js → wardleyDiagram-YWT4CUSO-ChM8bmgn.js} +1 -1
  325. package/web-shell/assets/{xychartDiagram-2RQKCTM6-BntaqhSB.js → xychartDiagram-2RQKCTM6-oNG6HyB1.js} +1 -1
  326. package/web-shell/index.html +2 -2
  327. package/chunks/chunk-5PLOQW7H.js +0 -830
  328. package/chunks/chunk-DMODRHNL.js +0 -649
  329. package/chunks/chunk-L34XSHIZ.js +0 -28
  330. package/chunks/chunk-N2TNM3QB.js +0 -9
  331. package/chunks/chunk-RECPKBBD.js +0 -622
  332. package/chunks/chunk-WLML6VIA.js +0 -18
  333. package/chunks/chunk-ZBBVBZBR.js +0 -137
  334. package/chunks/chunk-bdqvmfwv-OHYAFAAO.js +0 -17446
  335. package/chunks/discovery-XLHITE74.js +0 -220
  336. package/chunks/dispatch-FW7DX2CR.js +0 -43
  337. package/chunks/nonInteractiveCli-3XFIFXBR.js +0 -166
  338. package/chunks/opentui-entry-TEHHLGN7.js +0 -52419
  339. package/chunks/runtime-gate-T4ICWGQJ.js +0 -89
  340. package/chunks/wrapper-46Z24CTM.js +0 -35
  341. package/web-shell/assets/channel-BxvRq3pV.js +0 -1
  342. package/web-shell/assets/classDiagram-4FO5ZUOK-tL8nAxYf.js +0 -1
  343. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-tL8nAxYf.js +0 -1
  344. package/web-shell/assets/index-BgjULKyF.css +0 -5
  345. package/web-shell/assets/index-CxXlPYfl.js +0 -1789
  346. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BWGkVGVB.js +0 -1
  347. /package/chunks/{chunk-44CTCCLY.js → chunk-NWNEANAT.js} +0 -0
@@ -1,14 +1,9 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
3
  import {
4
- recomputeMcpGating
5
- } from "./chunk-6YSSQFHQ.js";
6
- import {
7
- classifyApiError
8
- } from "./chunk-V7RNNPGC.js";
9
- import {
4
+ classifyApiError,
10
5
  fireSessionDeleteHook
11
- } from "./chunk-L34XSHIZ.js";
6
+ } from "./chunk-P5Y23G2L.js";
12
7
  import {
13
8
  EXTENSION_CONTEXT_BUDGET,
14
9
  buildExtensionMentionContext,
@@ -18,17 +13,21 @@ import {
18
13
  matchMcpServerByRef,
19
14
  parseExtensionRef,
20
15
  parseMcpServerRef
21
- } from "./chunk-62OKKUOX.js";
22
- import "./chunk-WLML6VIA.js";
16
+ } from "./chunk-76J3IJ3M.js";
23
17
  import {
24
18
  getAvailableCommands,
25
19
  handleSlashCommand,
26
20
  insertAfterFunctionResponses,
21
+ isSlashCommand,
27
22
  normalizePartList
28
- } from "./chunk-5PLOQW7H.js";
23
+ } from "./chunk-NNHNLJ2X.js";
24
+ import {
25
+ collectContextData,
26
+ formatContextUsageText
27
+ } from "./chunk-N5YPT6PH.js";
29
28
  import {
30
- isSlashCommand
31
- } from "./chunk-N4LVA3S6.js";
29
+ recomputeMcpGating
30
+ } from "./chunk-GGDBMYGZ.js";
32
31
  import {
33
32
  SessionIdConflictError,
34
33
  appEvents,
@@ -36,43 +35,40 @@ import {
36
35
  cleanupReviewWorktreeLeases,
37
36
  loadCliConfig,
38
37
  normalizeDisabledToolList
39
- } from "./chunk-Q7VJUIIB.js";
38
+ } from "./chunk-IGGGG5CX.js";
40
39
  import {
41
40
  getCommandSubcommandNames
42
- } from "./chunk-M3DWLXEO.js";
41
+ } from "./chunk-AFSG32D5.js";
43
42
  import {
44
43
  getEffectiveSupportedModes
45
- } from "./chunk-DGNQ5AFX.js";
46
- import "./chunk-NYX53SV4.js";
47
- import "./chunk-UPUAGRKY.js";
48
- import {
49
- collectContextData,
50
- formatContextUsageText
51
- } from "./chunk-E7XJWIWC.js";
44
+ } from "./chunk-O4D7SPJN.js";
52
45
  import "./chunk-4WGODMVR.js";
46
+ import "./chunk-3SH53ANB.js";
47
+ import "./chunk-NYX53SV4.js";
48
+ import "./chunk-DXIBNLBZ.js";
53
49
  import {
54
50
  isGoalStatusKind
55
51
  } from "./chunk-EKTCKZV5.js";
56
- import "./chunk-6LDLDK6E.js";
52
+ import "./chunk-2M55OBEB.js";
57
53
  import {
58
54
  startNonInteractiveOpenAILogHousekeeping
59
- } from "./chunk-CPTIJGUK.js";
55
+ } from "./chunk-6YKYPVDV.js";
60
56
  import "./chunk-KW7NOTN6.js";
61
- import "./chunk-6JFPUJ2O.js";
62
- import "./chunk-HOXEJHJQ.js";
63
- import "./chunk-72SKJ3E7.js";
64
- import "./chunk-YAF2MQZ6.js";
65
- import {
66
- computeCpuPercent
67
- } from "./chunk-LBOVL47Y.js";
68
- import "./chunk-6DH5YA3X.js";
69
- import "./chunk-6H67XLET.js";
70
57
  import {
71
58
  beginAcpBootstrapConfigProfiling,
72
59
  buildAndFreezeAcpStartupProfile,
73
60
  endAcpBootstrapConfigProfiling,
74
61
  markAcpStartup
75
- } from "./chunk-ZZ7RUTJ4.js";
62
+ } from "./chunk-CZBYX5MY.js";
63
+ import "./chunk-GO7STP6N.js";
64
+ import "./chunk-JUEPY766.js";
65
+ import "./chunk-NEFOOD54.js";
66
+ import "./chunk-YAF2MQZ6.js";
67
+ import {
68
+ computeCpuPercent
69
+ } from "./chunk-LBOVL47Y.js";
70
+ import "./chunk-QRCNA3SR.js";
71
+ import "./chunk-6H67XLET.js";
76
72
  import {
77
73
  GENERATION_MAX_PROMPT_BYTES,
78
74
  GENERATION_TIMEOUT_MS,
@@ -95,8 +91,7 @@ import {
95
91
  shouldSuppressRememberErrorDetails,
96
92
  workspaceMemoryFailureCode,
97
93
  workspaceMemoryFailureDiagnostics
98
- } from "./chunk-RXX5T3IF.js";
99
- import "./chunk-ZBBVBZBR.js";
94
+ } from "./chunk-ZZO74WKW.js";
100
95
  import {
101
96
  BaseEmitter,
102
97
  HistoryReplayer,
@@ -105,10 +100,10 @@ import {
105
100
  createTranscriptMessageUpdate,
106
101
  createTranscriptUsageUpdate,
107
102
  hasFullSessionContext
108
- } from "./chunk-LYRA6ZTI.js";
109
- import "./chunk-EGB2PIYM.js";
103
+ } from "./chunk-RLKC46YT.js";
104
+ import "./chunk-BZ263IKX.js";
110
105
  import "./chunk-4NFY2S7N.js";
111
- import "./chunk-HUDUANHL.js";
106
+ import "./chunk-3U3VAL47.js";
112
107
  import "./chunk-2MIN6GRR.js";
113
108
  import "./chunk-QHTIBUWB.js";
114
109
  import "./chunk-3Z43GZUQ.js";
@@ -126,24 +121,23 @@ import {
126
121
  buildPermissionSettings,
127
122
  normalizePermissionRules,
128
123
  readPermissionRuleSet
129
- } from "./chunk-TIM7NVEO.js";
124
+ } from "./chunk-7UXUJ5T3.js";
130
125
  import {
131
126
  MAX_AUDIO_BYTES,
132
127
  sanitizeVoiceErrorMessage,
133
128
  transcribeVoiceAudio
134
- } from "./chunk-HRAFAUM7.js";
129
+ } from "./chunk-6ORZ2EDC.js";
135
130
  import {
136
131
  readVoiceModel
137
- } from "./chunk-N2G4RA77.js";
138
- import "./chunk-5KZNWF2M.js";
132
+ } from "./chunk-QIH2HAEN.js";
133
+ import "./chunk-WGHHA7ZH.js";
139
134
  import "./chunk-NTTBXH7U.js";
140
- import "./chunk-VAPNUDD5.js";
141
- import "./chunk-3SH53ANB.js";
135
+ import "./chunk-XHRY7BXD.js";
142
136
  import {
143
137
  SESSION_SOURCE_META_KEY,
144
138
  parseSessionSource
145
- } from "./chunk-DLDVO2NY.js";
146
- import "./chunk-JVY7FHUZ.js";
139
+ } from "./chunk-LJQAUZMR.js";
140
+ import "./chunk-7U5G6JXI.js";
147
141
  import "./chunk-WCCLLK7X.js";
148
142
  import "./chunk-OCPBI7J5.js";
149
143
  import {
@@ -154,26 +148,26 @@ import {
154
148
  parseAcpModelOption,
155
149
  resolveAcpModelOption,
156
150
  sanitizeProviderBaseUrl
157
- } from "./chunk-7ATQGA6V.js";
151
+ } from "./chunk-ZYYTZUI2.js";
158
152
  import {
159
153
  mapSkillConfigToStatus
160
154
  } from "./chunk-BGXZBI5B.js";
161
155
  import {
162
156
  resolveSkillSettings
163
157
  } from "./chunk-Z4X5MTRT.js";
164
- import "./chunk-EHXS5MAC.js";
165
- import "./chunk-3RC5Q66G.js";
158
+ import "./chunk-TUGSVUJB.js";
159
+ import "./chunk-QV5YN5YD.js";
166
160
  import "./chunk-57OAHC2Y.js";
167
- import "./chunk-VUTOV2HG.js";
168
- import "./chunk-XY7DGTIC.js";
169
- import "./chunk-TN3REXN4.js";
161
+ import "./chunk-OD2WU5QY.js";
162
+ import "./chunk-45NQKMYB.js";
163
+ import "./chunk-A4QRWUDE.js";
170
164
  import "./chunk-V6WHFGST.js";
171
165
  import {
172
166
  createLoadedSettingsAdapter
173
- } from "./chunk-DXXYMK2U.js";
167
+ } from "./chunk-BVJS5BSP.js";
174
168
  import {
175
169
  ndJsonStream
176
- } from "./chunk-2U3UCXZ3.js";
170
+ } from "./chunk-NHDR76JX.js";
177
171
  import {
178
172
  ACP_PREFLIGHT_KINDS,
179
173
  IDLE_HOOK_EVENTS,
@@ -181,14 +175,15 @@ import {
181
175
  SERVE_STATUS_EXT_METHODS,
182
176
  STATUS_SCHEMA_VERSION,
183
177
  mapDomainErrorToErrorKind
184
- } from "./chunk-NHZF4VCD.js";
185
- import "./chunk-U7ROFHSH.js";
186
- import "./chunk-YMIQ24FR.js";
178
+ } from "./chunk-QNQAPSN2.js";
179
+ import "./chunk-ZLCT4C5A.js";
180
+ import "./chunk-BKPPWD33.js";
187
181
  import {
188
182
  ACTIVE_WORK_CLOSE_IF_UNHELD_PARAM,
189
183
  ACTIVE_WORK_HEARTBEAT_META_KEY,
190
184
  ACTIVE_WORK_HEARTBEAT_VERSION,
191
185
  ACTIVE_WORK_HOLD_CATEGORIES,
186
+ ACTIVE_WORK_LEGACY_HOLD_CATEGORIES,
192
187
  ACTIVE_WORK_NOTIFICATION_METHOD,
193
188
  CHANNEL_STARTUP_PROFILE_META_KEY,
194
189
  CHANNEL_STARTUP_PROFILE_VERSION,
@@ -212,7 +207,7 @@ import {
212
207
  WORKTREE_MCP_DEFER_META_KEY,
213
208
  clampActiveWorkIntervalMs,
214
209
  isValidTrustedModelPrompt
215
- } from "./chunk-UFHPAMAV.js";
210
+ } from "./chunk-S5DWMTHO.js";
216
211
  import {
217
212
  NOT_CURRENTLY_GENERATING_CANCEL_MESSAGE,
218
213
  isNotCurrentlyGeneratingCancelError
@@ -220,7 +215,7 @@ import {
220
215
  import "./chunk-6PLDPT2C.js";
221
216
  import "./chunk-FYJ7W2PI.js";
222
217
  import "./chunk-YP5KH5Y7.js";
223
- import "./chunk-JW5UEE3V.js";
218
+ import "./chunk-A6NRNRKE.js";
224
219
  import "./chunk-ALMR3E6Q.js";
225
220
  import "./chunk-HIBNSEJE.js";
226
221
  import "./chunk-M5GB774H.js";
@@ -229,22 +224,24 @@ import {
229
224
  EXTERNAL_TOOL_GUARD_REQUIRED_VALUE,
230
225
  EXTERNAL_TOOL_GUARD_TOKEN_ENV,
231
226
  PRIVATE_EXTERNAL_TOOL_GUARD_ENV,
227
+ PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV,
228
+ SHELL_EXECUTING_TOOL_NAMES,
232
229
  isValidExternalToolGuardDenialReason
233
- } from "./chunk-BKHCW2BI.js";
230
+ } from "./chunk-3VUENPWF.js";
234
231
  import {
235
232
  ACP_EVENT_LOOP_STALL_RESTART_MS,
236
233
  CHANNEL_PROMPT_META_KEY
237
- } from "./chunk-ADJDLEVO.js";
234
+ } from "./chunk-AW27A43Y.js";
238
235
  import {
239
236
  AgentSideConnection,
240
237
  PROTOCOL_VERSION,
241
238
  RequestError
242
239
  } from "./chunk-IW6RQPQB.js";
243
- import "./chunk-7JL5YBSA.js";
240
+ import "./chunk-H4A72DE5.js";
244
241
  import {
245
242
  assembleMcpServers,
246
243
  loadMcpApprovals
247
- } from "./chunk-UALXTL5Y.js";
244
+ } from "./chunk-JOOFMXGF.js";
248
245
  import {
249
246
  getOutputLanguageFilePath,
250
247
  getPersistScopeForModelSelection,
@@ -253,9 +250,9 @@ import {
253
250
  resolveOutputLanguageOrPreserveAuto,
254
251
  updateOutputLanguageFile,
255
252
  writeOutputLanguageAndRegisterPath
256
- } from "./chunk-YCGXJ4Q3.js";
253
+ } from "./chunk-A267JX7H.js";
257
254
  import "./chunk-RKUWKYED.js";
258
- import "./chunk-J5SUM3ZJ.js";
255
+ import "./chunk-E23IPNGS.js";
259
256
  import "./chunk-GOXKNSDZ.js";
260
257
  import {
261
258
  getSystemDefaultsPath,
@@ -264,7 +261,7 @@ import {
264
261
  import {
265
262
  getCurrentLanguage,
266
263
  setLanguageAsync
267
- } from "./chunk-I3UEXUWJ.js";
264
+ } from "./chunk-HUTNYWBG.js";
268
265
  import {
269
266
  SUPPORTED_LANGUAGES
270
267
  } from "./chunk-5EJZE3FP.js";
@@ -272,17 +269,17 @@ import {
272
269
  findEnvFiles,
273
270
  preResolveHomeEnvOverrides,
274
271
  reloadEnvironment
275
- } from "./chunk-5IW3FJGD.js";
272
+ } from "./chunk-MC4TLKEI.js";
276
273
  import {
277
274
  ENV_ACP_REPEATED_TOOL_FAILURE_GUARD
278
275
  } from "./chunk-MS7GNABG.js";
279
- import "./chunk-V6PERRH4.js";
276
+ import "./chunk-CU6GJD55.js";
280
277
  import "./chunk-WZMH7II3.js";
281
278
  import {
282
279
  isFolderTrustEnabled,
283
280
  isWorkspaceTrusted,
284
281
  loadTrustedFolders
285
- } from "./chunk-VE2UV7IN.js";
282
+ } from "./chunk-IWPYVAO2.js";
286
283
  import "./chunk-NPQ5ZKRP.js";
287
284
  import "./chunk-MR3PXB6E.js";
288
285
  import "./chunk-XFSFZCM5.js";
@@ -290,6 +287,7 @@ import {
290
287
  ALL_PROVIDERS,
291
288
  APPROVAL_MODE_INFO,
292
289
  BTW_MAX_INPUT_LENGTH,
290
+ BranchPointInvalidError,
293
291
  ExtensionManager,
294
292
  GLOBAL_DUPLICATE_THRESHOLD,
295
293
  IMAGE_CAPABILITY,
@@ -395,7 +393,6 @@ import {
395
393
  readManyFiles,
396
394
  recordAllow,
397
395
  recordFallbackApprove,
398
- redactUrlCredentials,
399
396
  refreshMemoryAfterManagedWrite,
400
397
  refreshMemoryInstruction,
401
398
  resolveBaseUrl,
@@ -414,25 +411,25 @@ import {
414
411
  updateSetting,
415
412
  validatePlanModeShellApproval,
416
413
  validatePlanModeShellContext
417
- } from "./chunk-T7YMWGFY.js";
414
+ } from "./chunk-4S5337WV.js";
418
415
  import "./chunk-GOFAQQZA.js";
419
416
  import "./chunk-5M6IDOMF.js";
420
417
  import "./chunk-TWPJO254.js";
421
418
  import {
422
419
  external_exports
423
420
  } from "./chunk-CQ35AJ4Z.js";
424
- import "./chunk-NM33GGOM.js";
425
- import "./chunk-A4BAHMJF.js";
426
- import "./chunk-ZPZANKVP.js";
427
- import "./chunk-A6GQUQ7I.js";
421
+ import "./chunk-DGZEMW5R.js";
422
+ import "./chunk-WSH6GRKG.js";
423
+ import "./chunk-CKSJECTU.js";
424
+ import "./chunk-OVZPVYZB.js";
428
425
  import {
429
426
  parsePositiveIntegerEnv
430
427
  } from "./chunk-6PVPNMXU.js";
431
- import "./chunk-OZTGLK53.js";
428
+ import "./chunk-5EYKMUUY.js";
432
429
  import "./chunk-IRH27ZC2.js";
433
430
  import "./chunk-QHWCP53L.js";
434
- import "./chunk-AAZWJAPQ.js";
435
- import "./chunk-7WUMS2UA.js";
431
+ import "./chunk-Y3YCSWG5.js";
432
+ import "./chunk-UPDOZBWO.js";
436
433
  import {
437
434
  promptIdContext,
438
435
  todoWorkChainContext
@@ -442,15 +439,15 @@ import "./chunk-ZPJWUGCS.js";
442
439
  import "./chunk-CPBF7KYF.js";
443
440
  import {
444
441
  APPROVAL_MODES
445
- } from "./chunk-SNHBRO4C.js";
446
- import "./chunk-KTWUFHS4.js";
447
- import "./chunk-KRXPRVGL.js";
442
+ } from "./chunk-RWDNJBWN.js";
443
+ import "./chunk-25EYDK42.js";
448
444
  import {
449
445
  HookEventName,
450
446
  createHookOutput
451
- } from "./chunk-2ASWIM4A.js";
452
- import "./chunk-67F2BEYW.js";
453
- import "./chunk-TNETSI2A.js";
447
+ } from "./chunk-MIPFDQAF.js";
448
+ import "./chunk-MLXTMF7H.js";
449
+ import "./chunk-KV27IEHM.js";
450
+ import "./chunk-E3DYKPYZ.js";
454
451
  import {
455
452
  GoalPersistenceUnavailableError,
456
453
  emptyGoalSnapshot,
@@ -458,9 +455,11 @@ import {
458
455
  parseGoalSnapshotV2,
459
456
  parseGoalStateCause,
460
457
  wrapUserPromptSubmitContext
461
- } from "./chunk-B66LYK4B.js";
462
- import "./chunk-VPZMLGD3.js";
458
+ } from "./chunk-OMLJNPBE.js";
459
+ import "./chunk-OXCMMLED.js";
463
460
  import {
461
+ AgentOutputMessageCapture,
462
+ addAgentInputMessageAttributes,
464
463
  addDaemonRequestAttribute,
465
464
  addToolArgumentsAttributes,
466
465
  addToolCallResultAttributes,
@@ -468,14 +467,43 @@ import {
468
467
  registerAcpEventLoopLagGauge,
469
468
  startEventLoopLagMonitor,
470
469
  withDaemonSpan
471
- } from "./chunk-U5C2GIN2.js";
470
+ } from "./chunk-TIGA2IVL.js";
472
471
  import "./chunk-SAH4BD2J.js";
473
- import "./chunk-2RTRFLWH.js";
472
+ import "./chunk-XLLKYULU.js";
474
473
  import {
475
474
  runWithRuntimeContentGenerator
476
- } from "./chunk-SKRHR6N2.js";
475
+ } from "./chunk-PT4I7NBA.js";
477
476
  import "./chunk-S6LOFUVP.js";
478
477
  import "./chunk-2J3OJGTL.js";
478
+ import {
479
+ FORK_SUBAGENT_TYPE,
480
+ getStartupContextLength,
481
+ isSystemReminderContent
482
+ } from "./chunk-SG7ZP5PG.js";
483
+ import "./chunk-K623ENWT.js";
484
+ import "./chunk-AQ37AY7B.js";
485
+ import "./chunk-KBXKR5R2.js";
486
+ import {
487
+ clearCachedCredentialFile,
488
+ qwenOAuth2Events
489
+ } from "./chunk-GMIEIY3Y.js";
490
+ import "./chunk-NAVJD2PQ.js";
491
+ import "./chunk-ROIYNTHJ.js";
492
+ import "./chunk-2B2BF7P7.js";
493
+ import "./chunk-P3QQPMQA.js";
494
+ import "./chunk-YZHRN3CF.js";
495
+ import "./chunk-FAAUPSY2.js";
496
+ import {
497
+ REASONING_EFFORT_TIERS,
498
+ applyReasoningEffort
499
+ } from "./chunk-KM73TBQ4.js";
500
+ import "./chunk-MPHPFVKK.js";
501
+ import "./chunk-AXMWHKXA.js";
502
+ import {
503
+ getToolCallPreparations
504
+ } from "./chunk-GLCZKT5V.js";
505
+ import "./chunk-DJ2GSRLV.js";
506
+ import "./chunk-QFJ5JHQR.js";
479
507
  import {
480
508
  ConversationFinishedEvent,
481
509
  DiscoveredMCPTool,
@@ -508,26 +536,17 @@ import {
508
536
  shouldRunVisionBridge,
509
537
  splitImageParts,
510
538
  uiTelemetryService
511
- } from "./chunk-UAAWNTOC.js";
539
+ } from "./chunk-RVOJ2FBP.js";
512
540
  import "./chunk-YRLW2MSX.js";
513
541
  import "./chunk-VGC4I5JJ.js";
514
542
  import {
515
543
  getAutoMemoryRoot,
516
544
  getUserAutoMemoryRoot
517
- } from "./chunk-6OJDN5ZT.js";
545
+ } from "./chunk-CHHABXPE.js";
518
546
  import {
519
547
  runSideQuery
520
- } from "./chunk-JRTJEGSP.js";
521
- import "./chunk-O6SLWH4X.js";
522
- import "./chunk-C2DR57L6.js";
523
- import {
524
- FORK_SUBAGENT_TYPE,
525
- getStartupContextLength,
526
- isSystemReminderContent
527
- } from "./chunk-TROB4PZY.js";
528
- import "./chunk-K623ENWT.js";
529
- import "./chunk-AQ37AY7B.js";
530
- import "./chunk-UHF5VBKO.js";
548
+ } from "./chunk-MA2HEDVP.js";
549
+ import "./chunk-XUJNK7Y6.js";
531
550
  import {
532
551
  BaseDeclarativeTool,
533
552
  BaseToolInvocation,
@@ -535,49 +554,31 @@ import {
535
554
  ToolNames,
536
555
  canonicalToolName,
537
556
  isShellProgressData
538
- } from "./chunk-ZRT36RSF.js";
539
- import {
540
- clearCachedCredentialFile,
541
- qwenOAuth2Events
542
- } from "./chunk-CDDLHCC2.js";
543
- import "./chunk-NAVJD2PQ.js";
544
- import "./chunk-YI5G32RU.js";
545
- import "./chunk-QEWAHAW2.js";
546
- import "./chunk-P3QQPMQA.js";
547
- import "./chunk-FTGU6G45.js";
548
- import "./chunk-PSTHNTHF.js";
557
+ } from "./chunk-6HY6IF3Z.js";
549
558
  import {
550
559
  AuthType,
551
560
  preloadContentGenerator
552
- } from "./chunk-VGGNHRYZ.js";
561
+ } from "./chunk-4PKCUT7F.js";
553
562
  import "./chunk-F6WFNA7U.js";
554
- import "./chunk-NW7SPXVG.js";
555
- import {
556
- REASONING_EFFORT_TIERS,
557
- applyReasoningEffort
558
- } from "./chunk-KM73TBQ4.js";
559
- import "./chunk-MPHPFVKK.js";
560
- import "./chunk-AXMWHKXA.js";
561
- import {
562
- getToolCallPreparations
563
- } from "./chunk-GLCZKT5V.js";
564
- import "./chunk-KK3FEHPJ.js";
565
563
  import "./chunk-46UV252V.js";
566
564
  import {
567
565
  DEFAULT_TOKEN_LIMIT,
568
566
  tokenLimit
569
567
  } from "./chunk-FPGTNKCP.js";
570
- import "./chunk-DJ2GSRLV.js";
571
- import "./chunk-H6BFLALJ.js";
568
+ import "./chunk-CPHEPGAO.js";
569
+ import "./chunk-P7MPQI75.js";
570
+ import "./chunk-FDGGZIYW.js";
572
571
  import {
573
572
  endToolExecutionSpan,
574
573
  endToolSpan,
574
+ getActiveInteractionSpan,
575
575
  initializeTelemetry,
576
+ redactUrlCredentials,
576
577
  runInToolSpanContext,
577
578
  startToolExecutionSpan,
578
579
  startToolSpan,
579
580
  withInteractionSpan
580
- } from "./chunk-3MJ44LNC.js";
581
+ } from "./chunk-EL5SXY3T.js";
581
582
  import "./chunk-HHJLM3WQ.js";
582
583
  import {
583
584
  sessionIdContext
@@ -588,12 +589,12 @@ import {
588
589
  getErrorMessage,
589
590
  getErrorStatus,
590
591
  isSubpath
591
- } from "./chunk-YMB77M76.js";
592
+ } from "./chunk-BUQDLC2G.js";
592
593
  import "./chunk-VOQXFAY5.js";
593
- import "./chunk-RIDUB2GC.js";
594
+ import "./chunk-AW4TRXOC.js";
594
595
  import {
595
596
  runExitCleanup
596
- } from "./chunk-OK727E5D.js";
597
+ } from "./chunk-X26JYGTD.js";
597
598
  import {
598
599
  writeStderrLine,
599
600
  writeStderrLineSafe
@@ -3136,6 +3137,7 @@ var DAEMON_INVALID_TOOL_PARAMS_THRESHOLD = 3;
3136
3137
  var PERMISSION_CANCEL_SKIP_MESSAGE = "Skipped because a permission request was cancelled before the user answered; user input is required before continuing.";
3137
3138
  var LOOP_DETECTED_SKIP_MESSAGE = "Skipped because loop detection stopped the current turn before this tool call could run.";
3138
3139
  var LOOP_DETECTED_CONTEXT_MESSAGE = "System: this turn was terminated because the model exceeded tool-call safety limits. Try a different approach on the next turn.";
3140
+ var LOOP_DETECTED_TURN_ERROR_MESSAGE = "Tool-call loop protection stopped this turn. The session is still available; send a more specific instruction to continue.";
3139
3141
  var TOOL_EXECUTION_CANCELLED_MESSAGE = "Tool execution was cancelled.";
3140
3142
  var TOOL_POST_EXECUTION_CANCELLED_MESSAGE = "The tool had already completed; its output was discarded.";
3141
3143
  function createDaemonToolLoopState(repeatedToolFailureMode) {
@@ -3204,6 +3206,7 @@ __name(recordRepeatedToolFailureDecision, "recordRepeatedToolFailureDecision");
3204
3206
  function recordDaemonLoopDetected(config, promptId, loopType, message, loopState, options = {}) {
3205
3207
  if (!loopState.loopDetected) {
3206
3208
  loopState.loopDetected = true;
3209
+ loopState.loopType = loopType;
3207
3210
  debugLogger6.warn(message);
3208
3211
  try {
3209
3212
  logLoopDetected(
@@ -3221,6 +3224,25 @@ function recordDaemonLoopDetected(config, promptId, loopType, message, loopState
3221
3224
  return true;
3222
3225
  }
3223
3226
  __name(recordDaemonLoopDetected, "recordDaemonLoopDetected");
3227
+ function createLoopDetectedTurnError(loopState) {
3228
+ return new RequestError(-32603, LOOP_DETECTED_TURN_ERROR_MESSAGE, {
3229
+ code: "LOOP_DETECTED",
3230
+ errorKind: "loop_detected",
3231
+ ...loopState.loopType ? { loopType: loopState.loopType } : {}
3232
+ });
3233
+ }
3234
+ __name(createLoopDetectedTurnError, "createLoopDetectedTurnError");
3235
+ function cancelledOrThrowLoopDetected(signal, loopState) {
3236
+ if (signal.aborted) return "cancelled";
3237
+ throw createLoopDetectedTurnError(loopState);
3238
+ }
3239
+ __name(cancelledOrThrowLoopDetected, "cancelledOrThrowLoopDetected");
3240
+ function isLoopDetectedTurnError(error) {
3241
+ if (!(error instanceof RequestError)) return false;
3242
+ const data = error.data;
3243
+ return typeof data === "object" && data !== null && data.code === "LOOP_DETECTED";
3244
+ }
3245
+ __name(isLoopDetectedTurnError, "isLoopDetectedTurnError");
3224
3246
  function recordDaemonToolCalls(config, promptId, loopState, calls) {
3225
3247
  if (!loopState || loopState.loopDetected)
3226
3248
  return loopState?.loopDetected ?? false;
@@ -3484,14 +3506,16 @@ var TodoStopGuardClaimTimeoutError = class extends Error {
3484
3506
  }
3485
3507
  };
3486
3508
  function beginChannelDeliveryResponseBlock(capture) {
3487
- if (!capture) return void 0;
3488
- capture.finalText = "";
3509
+ capture?.agentOutput.beginResponse();
3510
+ if (!capture?.channelDelivery) return void 0;
3511
+ capture.channelDelivery.finalText = "";
3489
3512
  return [];
3490
3513
  }
3491
3514
  __name(beginChannelDeliveryResponseBlock, "beginChannelDeliveryResponseBlock");
3492
3515
  function commitChannelDeliveryResponseBlock(capture, responseBlock, hasFunctionCalls) {
3493
- if (capture && responseBlock && !hasFunctionCalls) {
3494
- capture.finalText = responseBlock.join("");
3516
+ capture?.agentOutput.commitResponse(hasFunctionCalls);
3517
+ if (capture?.channelDelivery && responseBlock && !hasFunctionCalls) {
3518
+ capture.channelDelivery.finalText = responseBlock.join("");
3495
3519
  }
3496
3520
  }
3497
3521
  __name(commitChannelDeliveryResponseBlock, "commitChannelDeliveryResponseBlock");
@@ -3677,10 +3701,11 @@ async function buildAvailableCommandsSnapshot(config, abortSignal = AbortSignal.
3677
3701
  }
3678
3702
  __name(buildAvailableCommandsSnapshot, "buildAvailableCommandsSnapshot");
3679
3703
  var Session = class {
3680
- constructor(id, config, client, settings, onActiveWorkChanged) {
3704
+ constructor(id, config, client, settings, runExclusiveAutomaticHistoryMutation = (operation) => operation(), onActiveWorkChanged) {
3681
3705
  this.config = config;
3682
3706
  this.client = client;
3683
3707
  this.settings = settings;
3708
+ this.runExclusiveAutomaticHistoryMutation = runExclusiveAutomaticHistoryMutation;
3684
3709
  this.onActiveWorkChanged = onActiveWorkChanged;
3685
3710
  this.sessionId = id;
3686
3711
  this.runtimeBaseDir = config.storage.getRuntimeBaseDir();
@@ -3784,6 +3809,7 @@ var Session = class {
3784
3809
  notificationAbortController = null;
3785
3810
  notificationCompletion = null;
3786
3811
  currentAgentNotificationTaskId = null;
3812
+ currentShellNotificationActive = false;
3787
3813
  persistedBackgroundNotificationTaskIds = /* @__PURE__ */ new Set();
3788
3814
  backgroundNotificationAcceptances = /* @__PURE__ */ new Map();
3789
3815
  activeAgentNotificationAcceptances = /* @__PURE__ */ new Set();
@@ -3805,12 +3831,14 @@ var Session = class {
3805
3831
  // on a session whose registries are already unregistered.
3806
3832
  disposed = false;
3807
3833
  closing = false;
3834
+ historyMutationActive = false;
3808
3835
  closeGateCompletion = null;
3809
3836
  resolveCloseGate = null;
3810
3837
  unsubscribeChatRecordingFailure;
3811
3838
  /** The exact status-change callback this Session installed, so dispose can
3812
3839
  * retract its own and nobody else's. */
3813
3840
  #statusChangeCallback;
3841
+ #shellStatusChangeCallback;
3814
3842
  workflowApprovalAbortController = new AbortController();
3815
3843
  activeTodoPlanRevision;
3816
3844
  // Modular components
@@ -4025,6 +4053,12 @@ var Session = class {
4025
4053
  return publication;
4026
4054
  }
4027
4055
  async #drainGoalQueue() {
4056
+ if (this.goalQueue.length === 0) return;
4057
+ await this.runExclusiveAutomaticHistoryMutation(
4058
+ () => this.#drainGoalQueueExclusive()
4059
+ );
4060
+ }
4061
+ async #drainGoalQueueExclusive() {
4028
4062
  if (this.disposed || this.closing || this.goalProcessing || this.pendingPrompt || this.pendingPromptCompletion || this.cronProcessing || this.cronAbortController || this.notificationProcessing || this.notificationAbortController) {
4029
4063
  return;
4030
4064
  }
@@ -4723,6 +4757,12 @@ var Session = class {
4723
4757
  if (this.closing) {
4724
4758
  throw RequestError.invalidParams(void 0, "Session is closing");
4725
4759
  }
4760
+ if (this.historyMutationActive) {
4761
+ throw RequestError.invalidParams(
4762
+ void 0,
4763
+ "Session history mutation is in progress"
4764
+ );
4765
+ }
4726
4766
  try {
4727
4767
  await this.config.assertCanStartTurn();
4728
4768
  } catch (error) {
@@ -4736,9 +4776,18 @@ var Session = class {
4736
4776
  if (this.closing) {
4737
4777
  throw RequestError.invalidParams(void 0, "Session is closing");
4738
4778
  }
4779
+ if (this.historyMutationActive) {
4780
+ throw RequestError.invalidParams(
4781
+ void 0,
4782
+ "Session history mutation is in progress"
4783
+ );
4784
+ }
4785
+ }
4786
+ isTurnIdle() {
4787
+ return !this.closing && !this.#hasActiveTurn();
4739
4788
  }
4740
4789
  isIdle() {
4741
- return !this.closing && !this.#hasActiveTurn() && this.collectActiveWorkHolds().length === 0;
4790
+ return this.isTurnIdle() && this.collectActiveWorkHolds().length === 0;
4742
4791
  }
4743
4792
  /**
4744
4793
  * The Session's current active-work holds, derived on every call.
@@ -4779,6 +4828,10 @@ var Session = class {
4779
4828
  for (const taskId of notificationIds) {
4780
4829
  holds.push({ category: "notification", id: taskId });
4781
4830
  }
4831
+ const shellActive = this.config.getBackgroundShellRegistry().hasRunningEntries() || this.notificationQueue.some((item) => item.kind === "shell") || this.currentShellNotificationActive;
4832
+ if (shellActive) {
4833
+ holds.push({ category: "shell", id: "background-shells" });
4834
+ }
4782
4835
  return holds;
4783
4836
  }
4784
4837
  #activeWorkChanged() {
@@ -4786,9 +4839,29 @@ var Session = class {
4786
4839
  }
4787
4840
  #hasActiveTurn() {
4788
4841
  return Boolean(
4789
- this.pendingPrompt || this.pendingPromptCompletion || this.goalProcessing || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
4842
+ this.pendingPrompt || this.historyMutationActive || this.pendingPromptCompletion || this.goalProcessing || this.cronProcessing || this.cronAbortController || this.cronCompletion || this.notificationProcessing || this.notificationAbortController || this.notificationCompletion
4790
4843
  );
4791
4844
  }
4845
+ beginHistoryMutation() {
4846
+ if (this.closing) {
4847
+ throw RequestError.invalidParams(void 0, "Session is closing");
4848
+ }
4849
+ if (this.#hasActiveTurn()) {
4850
+ throw new RequestError(-32602, "Session is busy processing a turn", {
4851
+ errorKind: "session_busy"
4852
+ });
4853
+ }
4854
+ this.historyMutationActive = true;
4855
+ let released = false;
4856
+ return () => {
4857
+ if (released) return;
4858
+ released = true;
4859
+ this.historyMutationActive = false;
4860
+ if (this.disposed) return;
4861
+ void this.#drainCronQueue();
4862
+ void this.#drainNotificationQueue();
4863
+ };
4864
+ }
4792
4865
  beginClose() {
4793
4866
  if (this.closing) {
4794
4867
  throw RequestError.invalidParams(
@@ -4906,7 +4979,12 @@ var Session = class {
4906
4979
  this.#statusChangeCallback = void 0;
4907
4980
  }
4908
4981
  this.config.getMonitorRegistry().setNotificationCallback(void 0);
4909
- this.config.getBackgroundShellRegistry().setNotificationCallback(void 0);
4982
+ const shellRegistry = this.config.getBackgroundShellRegistry();
4983
+ shellRegistry.setNotificationCallback(void 0);
4984
+ if (this.#shellStatusChangeCallback) {
4985
+ shellRegistry.clearStatusChangeCallback(this.#shellStatusChangeCallback);
4986
+ this.#shellStatusChangeCallback = void 0;
4987
+ }
4910
4988
  this.config.getChatRecordingService()?.setTitleRecordedCallback(void 0);
4911
4989
  this.unsubscribeChatRecordingFailure?.();
4912
4990
  this.unsubscribeChatRecordingFailure = void 0;
@@ -5133,6 +5211,12 @@ var Session = class {
5133
5211
  if (this.closing) {
5134
5212
  throw RequestError.invalidParams(void 0, "Session is closing");
5135
5213
  }
5214
+ if (this.historyMutationActive) {
5215
+ throw RequestError.invalidParams(
5216
+ void 0,
5217
+ "Session history mutation is in progress"
5218
+ );
5219
+ }
5136
5220
  if (modelPrompt !== void 0 && invocationContext === void 0) {
5137
5221
  throw RequestError.invalidParams(
5138
5222
  void 0,
@@ -5152,6 +5236,12 @@ var Session = class {
5152
5236
  if (this.closing) {
5153
5237
  throw RequestError.invalidParams(void 0, "Session is closing");
5154
5238
  }
5239
+ if (this.historyMutationActive) {
5240
+ throw RequestError.invalidParams(
5241
+ void 0,
5242
+ "Session history mutation is in progress"
5243
+ );
5244
+ }
5155
5245
  if (admissionCancellation?.aborted) {
5156
5246
  return { stopReason: "cancelled" };
5157
5247
  }
@@ -5270,6 +5360,9 @@ var Session = class {
5270
5360
  this.todoStopGuard.suspend();
5271
5361
  return { stopReason: "cancelled" };
5272
5362
  }
5363
+ const channelPromptTurn = params._meta?.[CHANNEL_PROMPT_META_KEY] === true;
5364
+ const recording = this.config.getChatRecordingService();
5365
+ const branchCheckpointCursor = scheduledGoalTurn === void 0 && !channelPromptTurn ? recording?.getBranchCheckpointCursor() : void 0;
5273
5366
  if (todoStopGuardPreparation.startsWorkChain) {
5274
5367
  this.#clearTodoStopGuardQueuedPromptWait();
5275
5368
  this.todoStopGuard.startOrdinaryPrompt();
@@ -5277,40 +5370,79 @@ var Session = class {
5277
5370
  }
5278
5371
  this.duplicateProviderToolCallResponseIds.clear();
5279
5372
  const channelDelivery = parsePromptChannelDelivery(params);
5280
- const channelDeliveryCapture = channelDelivery ? { finalText: "" } : void 0;
5373
+ const responseCapture = {
5374
+ ...channelDelivery ? { channelDelivery: { finalText: "" } } : {},
5375
+ agentOutput: new AgentOutputMessageCapture(this.config)
5376
+ };
5281
5377
  let resolveCompletion;
5282
5378
  this.pendingPromptCompletion = new Promise((resolve6) => {
5283
5379
  resolveCompletion = resolve6;
5284
5380
  });
5381
+ let rejectedByLoopProtection = false;
5285
5382
  let promptResult;
5286
5383
  let promptFailed = false;
5287
5384
  try {
5288
5385
  const result = await this.#executePrompt(
5289
5386
  params,
5290
5387
  pendingSend,
5291
- channelDeliveryCapture,
5388
+ responseCapture,
5292
5389
  invocationContext,
5293
5390
  modelPrompt,
5294
- goalTurn
5391
+ // Channel turns are non-interactive deliveries: like cron,
5392
+ // background-notification, and goal turns they keep the graceful
5393
+ // end-turn handling so the collected response text is still
5394
+ // delivered. Only the authenticated CHANNEL_PROMPT_META_KEY turns
5395
+ // sent by the channel bridges qualify; the delivery meta alone
5396
+ // schedules the delivery but keeps the foreground rejection. Goal
5397
+ // turns bypass the bridge entirely, so a rejection there would
5398
+ // settle the turn as failed and pause the goal without any
5399
+ // turn_error ever being published.
5400
+ !channelPromptTurn && goalTurn === void 0,
5401
+ goalTurn,
5402
+ channelPromptTurn
5295
5403
  );
5296
- promptResult = result;
5404
+ let branchPoint;
5405
+ if (recording && branchCheckpointCursor) {
5406
+ try {
5407
+ branchPoint = await recording.recordBranchCheckpointTransaction({
5408
+ cursor: branchCheckpointCursor,
5409
+ stopReason: result.stopReason
5410
+ });
5411
+ } catch (error) {
5412
+ debugLogger6.warn(
5413
+ "Failed to record branch checkpoint; completing the turn without a branch point",
5414
+ error
5415
+ );
5416
+ }
5417
+ }
5418
+ const completedResult = branchPoint ? {
5419
+ ...result,
5420
+ _meta: {
5421
+ ...result._meta,
5422
+ "qwen.branchPoint": {
5423
+ assistantRecordUuid: branchPoint.assistantRecordUuid,
5424
+ checkpointUuid: branchPoint.checkpointUuid
5425
+ }
5426
+ }
5427
+ } : result;
5428
+ promptResult = completedResult;
5297
5429
  releasePendingSend();
5298
5430
  void this.#drainCronQueue();
5299
5431
  void this.#drainNotificationQueue();
5300
- this.#maybeEmitFollowupSuggestion(result);
5301
- if (channelDelivery && result.stopReason === "end_turn") {
5432
+ this.#maybeEmitFollowupSuggestion(completedResult);
5433
+ if (channelDelivery && completedResult.stopReason === "end_turn") {
5302
5434
  this.#scheduleChannelDelivery({
5303
5435
  sessionId: this.sessionId,
5304
5436
  deliveryId: channelDelivery.deliveryId,
5305
5437
  source: "prompt",
5306
5438
  target: channelDelivery.target,
5307
5439
  text: normalizeChannelDeliveryText(
5308
- channelDeliveryCapture?.finalText ?? ""
5440
+ responseCapture.channelDelivery?.finalText ?? ""
5309
5441
  ),
5310
5442
  promptId: channelDelivery.deliveryId
5311
5443
  });
5312
5444
  }
5313
- return result;
5445
+ return completedResult;
5314
5446
  } catch (error) {
5315
5447
  promptFailed = true;
5316
5448
  if (error instanceof SessionWriterError) {
@@ -5318,11 +5450,17 @@ var Session = class {
5318
5450
  errorKind: error.errorKind
5319
5451
  });
5320
5452
  }
5453
+ rejectedByLoopProtection = isLoopDetectedTurnError(error);
5321
5454
  throw error;
5322
5455
  } finally {
5323
5456
  const stillOwnsPendingPrompt = this.pendingPrompt === pendingSend;
5324
5457
  releasePendingSend();
5325
- const shouldDrainAutomaticQueues = todoStopGuardPreparation.drainSupersededAutomaticQueues || this.todoStopGuardDrainAutomaticQueuesWhenIdle || this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuard.hasCommittedContinuation || this.todoStopGuardQueuedPromptPriority;
5458
+ const shouldDrainAutomaticQueues = (
5459
+ // Loop-detected turns resolved end_turn (and drained) before loop
5460
+ // stops became rejections; keep that invariant on the new path so
5461
+ // queued cron/notification work is not stranded.
5462
+ rejectedByLoopProtection || todoStopGuardPreparation.drainSupersededAutomaticQueues || this.todoStopGuardDrainAutomaticQueuesWhenIdle || this.todoStopGuard.blocksUnrelatedAutomaticTurns || this.todoStopGuard.hasCommittedContinuation || this.todoStopGuardQueuedPromptPriority
5463
+ );
5326
5464
  if (stillOwnsPendingPrompt) {
5327
5465
  this.todoStopGuardDrainAutomaticQueuesWhenIdle = false;
5328
5466
  }
@@ -5460,7 +5598,7 @@ var Session = class {
5460
5598
  }
5461
5599
  })();
5462
5600
  }
5463
- async #executePrompt(params, pendingSend, channelDeliveryCapture, invocationContext, modelPrompt, goalTurn) {
5601
+ async #executePrompt(params, pendingSend, responseCapture, invocationContext, modelPrompt, rejectOnLoopDetected = false, goalTurn, channelTurn = false) {
5464
5602
  const sessionId = this.config.getSessionId();
5465
5603
  if (invocationContext !== void 0 && invocationContext.sessionId !== sessionId) {
5466
5604
  throw RequestError.invalidParams(
@@ -5475,15 +5613,17 @@ var Session = class {
5475
5613
  () => this.#executePromptInner(
5476
5614
  params,
5477
5615
  pendingSend,
5478
- channelDeliveryCapture,
5616
+ responseCapture,
5479
5617
  modelPrompt,
5480
- goalTurn
5618
+ rejectOnLoopDetected,
5619
+ goalTurn,
5620
+ channelTurn
5481
5621
  )
5482
5622
  )
5483
5623
  ), "execute");
5484
5624
  return goalTurn ? goalTurnContext.run(goalTurn.permit, execute) : goalTurnContext.exit(execute);
5485
5625
  }
5486
- async #executePromptInner(params, pendingSend, channelDeliveryCapture, modelPrompt, goalTurn) {
5626
+ async #executePromptInner(params, pendingSend, responseCapture, modelPrompt, rejectOnLoopDetected = false, goalTurn, channelTurn = false) {
5487
5627
  return Storage.runWithRuntimeBaseDir(
5488
5628
  this.runtimeBaseDir,
5489
5629
  this.config.getWorkingDir(),
@@ -5521,6 +5661,16 @@ var Session = class {
5521
5661
  );
5522
5662
  const isRetry = params.retry === true || params._meta?.[DAEMON_RETRY_META_KEY] === true;
5523
5663
  const isContinue = params._meta?.[DAEMON_CONTINUE_META_KEY] === true;
5664
+ if (!isRetry && !isContinue && goalTurn?.origin !== "runtime") {
5665
+ const interactionSpan = getActiveInteractionSpan();
5666
+ if (interactionSpan) {
5667
+ addAgentInputMessageAttributes(
5668
+ this.config,
5669
+ interactionSpan,
5670
+ promptDisplayText ?? promptText
5671
+ );
5672
+ }
5673
+ }
5524
5674
  let continuationParts = null;
5525
5675
  let strippedOrphanEntries = null;
5526
5676
  let orphanPushCountSnapshot = 0;
@@ -5719,7 +5869,7 @@ ${this.pendingRecoveredAgentsNotice}
5719
5869
  let nextMessage = { role: "user", parts };
5720
5870
  let turnCount = 0;
5721
5871
  const toolLoopState = createDaemonToolLoopState(
5722
- promptMetadata?.[CHANNEL_PROMPT_META_KEY] === true ? "off" : this.repeatedToolFailureGuardMode
5872
+ channelTurn ? "off" : this.repeatedToolFailureGuardMode
5723
5873
  );
5724
5874
  try {
5725
5875
  while (nextMessage !== null) {
@@ -5739,6 +5889,7 @@ ${this.pendingRecoveredAgentsNotice}
5739
5889
  pendingSend.signal
5740
5890
  );
5741
5891
  let channelDeliveryResponseBlock;
5892
+ let channelDeliveryCheckpoint = 0;
5742
5893
  try {
5743
5894
  if (goalTurn) goalTurn.modelStarted = true;
5744
5895
  const sendResult = await this.#sendMessageStreamWithAutoCompression(
@@ -5757,8 +5908,8 @@ ${this.pendingRecoveredAgentsNotice}
5757
5908
  }
5758
5909
  const responseStream = sendResult.responseStream;
5759
5910
  nextMessage = null;
5760
- channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(channelDeliveryCapture);
5761
- const channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
5911
+ channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(responseCapture);
5912
+ channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
5762
5913
  let streamFailed = false;
5763
5914
  try {
5764
5915
  for await (const resp of responseStream) {
@@ -5778,10 +5929,14 @@ ${this.pendingRecoveredAgentsNotice}
5778
5929
  part.thought
5779
5930
  );
5780
5931
  if (!part.thought) {
5932
+ responseCapture.agentOutput.appendText(part.text);
5781
5933
  channelDeliveryResponseBlock?.push(part.text);
5782
5934
  messageDisplay?.addChunk(part.text);
5783
5935
  }
5784
5936
  }
5937
+ responseCapture.agentOutput.observeFinishReason(
5938
+ candidate.finishReason
5939
+ );
5785
5940
  }
5786
5941
  if (resp.type === "chunk" /* CHUNK */ && resp.value.usageMetadata) {
5787
5942
  usageMetadata = resp.value.usageMetadata;
@@ -5794,6 +5949,9 @@ ${this.pendingRecoveredAgentsNotice}
5794
5949
  }
5795
5950
  }
5796
5951
  if (resp.type === "retry" /* RETRY */ || resp.type === "model_fallback" /* MODEL_FALLBACK */) {
5952
+ responseCapture.agentOutput.restartAttempt(
5953
+ resp.type === "retry" /* RETRY */ && resp.isContinuation === true
5954
+ );
5797
5955
  if (resp.type === "model_fallback" /* MODEL_FALLBACK */ || !resp.isContinuation) {
5798
5956
  if (channelDeliveryResponseBlock) {
5799
5957
  channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
@@ -5854,7 +6012,7 @@ ${this.pendingRecoveredAgentsNotice}
5854
6012
  await messageDisplay?.finish();
5855
6013
  }
5856
6014
  commitChannelDeliveryResponseBlock(
5857
- channelDeliveryCapture,
6015
+ responseCapture,
5858
6016
  channelDeliveryResponseBlock,
5859
6017
  functionCalls.length > 0
5860
6018
  );
@@ -5898,14 +6056,16 @@ ${this.pendingRecoveredAgentsNotice}
5898
6056
  pendingSend.signal,
5899
6057
  promptId,
5900
6058
  toolLoopState,
5901
- onFullTurnModel
6059
+ onFullTurnModel,
6060
+ rejectOnLoopDetected
5902
6061
  );
5903
6062
  nextMessage = nextAfterTools.message;
5904
6063
  if (nextAfterTools.stoppedByRepeatedToolFailure) {
5905
6064
  return {
5906
- stopReason: getAbortAwareEndTurnStopReason(
5907
- pendingSend.signal
5908
- )
6065
+ stopReason: rejectOnLoopDetected ? cancelledOrThrowLoopDetected(
6066
+ pendingSend.signal,
6067
+ toolLoopState
6068
+ ) : getAbortAwareEndTurnStopReason(pendingSend.signal)
5909
6069
  };
5910
6070
  }
5911
6071
  if (toolRun.loopDetected) {
@@ -5915,9 +6075,10 @@ ${this.pendingRecoveredAgentsNotice}
5915
6075
  pendingSend.signal
5916
6076
  );
5917
6077
  return {
5918
- stopReason: getAbortAwareEndTurnStopReason(
5919
- pendingSend.signal
5920
- )
6078
+ stopReason: rejectOnLoopDetected ? cancelledOrThrowLoopDetected(
6079
+ pendingSend.signal,
6080
+ toolLoopState
6081
+ ) : getAbortAwareEndTurnStopReason(pendingSend.signal)
5921
6082
  };
5922
6083
  }
5923
6084
  }
@@ -5925,15 +6086,22 @@ ${this.pendingRecoveredAgentsNotice}
5925
6086
  if (this.messageRewriter) {
5926
6087
  await this.messageRewriter.waitForPendingRewrites();
5927
6088
  }
5928
- return await this.#handleStopHookLoop(
6089
+ const result = await this.#handleStopHookLoop(
5929
6090
  pendingSend,
5930
6091
  promptId,
5931
6092
  hooksEnabled,
5932
6093
  messageBus,
5933
6094
  true,
5934
6095
  fullTurnModelOverride,
5935
- channelDeliveryCapture
6096
+ responseCapture,
6097
+ rejectOnLoopDetected
5936
6098
  );
6099
+ if (result.stopReason !== "cancelled") {
6100
+ responseCapture.agentOutput.writeToSpan(
6101
+ getActiveInteractionSpan()
6102
+ );
6103
+ }
6104
+ return result;
5937
6105
  } finally {
5938
6106
  logConversationFinishedEvent(
5939
6107
  this.config,
@@ -5954,7 +6122,7 @@ ${this.pendingRecoveredAgentsNotice}
5954
6122
  }
5955
6123
  );
5956
6124
  }
5957
- async #handleStopHookLoop(pendingSend, promptId, hooksEnabled, messageBus, allowExternalHooks = true, modelOverride, channelDeliveryCapture) {
6125
+ async #handleStopHookLoop(pendingSend, promptId, hooksEnabled, messageBus, allowExternalHooks = true, modelOverride, responseCapture, rejectOnLoopDetected = false) {
5958
6126
  const stopHookBlockingCap = this.config.getStopHookBlockingCap();
5959
6127
  let stopHookIterationCount = 0;
5960
6128
  let stopHookReasons = [];
@@ -6014,7 +6182,8 @@ ${this.pendingRecoveredAgentsNotice}
6014
6182
  {
6015
6183
  onFullTurnModel,
6016
6184
  getModelOverride: /* @__PURE__ */ __name(() => modelOverride, "getModelOverride"),
6017
- channelDeliveryCapture
6185
+ responseCapture,
6186
+ rejectOnLoopDetected
6018
6187
  }
6019
6188
  );
6020
6189
  if (continuation2.kind === "terminal") {
@@ -6098,7 +6267,8 @@ ${this.pendingRecoveredAgentsNotice}
6098
6267
  {
6099
6268
  onFullTurnModel,
6100
6269
  getModelOverride: /* @__PURE__ */ __name(() => modelOverride, "getModelOverride"),
6101
- channelDeliveryCapture
6270
+ responseCapture,
6271
+ rejectOnLoopDetected
6102
6272
  }
6103
6273
  );
6104
6274
  if (continuation2.kind === "terminal") {
@@ -6197,7 +6367,8 @@ ${this.pendingRecoveredAgentsNotice}
6197
6367
  } : {},
6198
6368
  onFullTurnModel,
6199
6369
  getModelOverride: /* @__PURE__ */ __name(() => modelOverride, "getModelOverride"),
6200
- channelDeliveryCapture
6370
+ responseCapture,
6371
+ rejectOnLoopDetected
6201
6372
  }
6202
6373
  );
6203
6374
  if (continuation.supersededAutomaticContinuation && externalReason) {
@@ -6264,6 +6435,7 @@ ${this.pendingRecoveredAgentsNotice}
6264
6435
  pendingSend.signal
6265
6436
  );
6266
6437
  let channelDeliveryResponseBlock;
6438
+ let channelDeliveryCheckpoint = 0;
6267
6439
  let providerSendChat;
6268
6440
  let userContentPushCountBeforeSend = 0;
6269
6441
  try {
@@ -6494,9 +6666,9 @@ ${this.pendingRecoveredAgentsNotice}
6494
6666
  const responseStream = sendResult.responseStream;
6495
6667
  nextMessage = null;
6496
6668
  channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(
6497
- options.channelDeliveryCapture
6669
+ options.responseCapture
6498
6670
  );
6499
- const channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
6671
+ channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
6500
6672
  initialSend = false;
6501
6673
  if (guardForThisSend) {
6502
6674
  const guardCommitted = this.todoStopGuard.commitContinuation(
@@ -6528,10 +6700,14 @@ ${this.pendingRecoveredAgentsNotice}
6528
6700
  part.thought
6529
6701
  );
6530
6702
  if (!part.thought) {
6703
+ options.responseCapture?.agentOutput.appendText(part.text);
6531
6704
  channelDeliveryResponseBlock?.push(part.text);
6532
6705
  messageDisplay?.addChunk(part.text);
6533
6706
  }
6534
6707
  }
6708
+ options.responseCapture?.agentOutput.observeFinishReason(
6709
+ candidate.finishReason
6710
+ );
6535
6711
  }
6536
6712
  if (response.type === "chunk" /* CHUNK */ && response.value.usageMetadata) {
6537
6713
  usageMetadata = response.value.usageMetadata;
@@ -6544,6 +6720,9 @@ ${this.pendingRecoveredAgentsNotice}
6544
6720
  }
6545
6721
  }
6546
6722
  if (response.type === "retry" /* RETRY */ || response.type === "model_fallback" /* MODEL_FALLBACK */) {
6723
+ options.responseCapture?.agentOutput.restartAttempt(
6724
+ response.type === "retry" /* RETRY */ && response.isContinuation === true
6725
+ );
6547
6726
  if (response.type === "model_fallback" /* MODEL_FALLBACK */ || !response.isContinuation) {
6548
6727
  if (channelDeliveryResponseBlock) {
6549
6728
  channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
@@ -6606,7 +6785,7 @@ ${this.pendingRecoveredAgentsNotice}
6606
6785
  }
6607
6786
  }
6608
6787
  commitChannelDeliveryResponseBlock(
6609
- options.channelDeliveryCapture,
6788
+ options.responseCapture,
6610
6789
  channelDeliveryResponseBlock,
6611
6790
  functionCalls.length > 0
6612
6791
  );
@@ -6630,7 +6809,7 @@ ${this.pendingRecoveredAgentsNotice}
6630
6809
  options.onFullTurnModel
6631
6810
  )
6632
6811
  );
6633
- if (toolRun.stopAfterPermissionCancel || toolRun.loopDetected || pendingSend.signal.aborted) {
6812
+ if (toolRun.stopAfterPermissionCancel || pendingSend.signal.aborted) {
6634
6813
  this.todoStopGuard.suspend();
6635
6814
  await this.#preserveStoppedToolRun(toolRun, pendingSend.signal);
6636
6815
  return {
@@ -6639,12 +6818,25 @@ ${this.pendingRecoveredAgentsNotice}
6639
6818
  ...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
6640
6819
  };
6641
6820
  }
6821
+ if (toolRun.loopDetected) {
6822
+ this.todoStopGuard.suspend();
6823
+ await this.#preserveStoppedToolRun(toolRun, pendingSend.signal);
6824
+ return {
6825
+ kind: "terminal",
6826
+ // Only the foreground chain rejects a loop-detected stop; cron
6827
+ // and background-notification turns keep the graceful end-turn
6828
+ // handling they had before loop stops became rejections.
6829
+ stopReason: options.rejectOnLoopDetected ? cancelledOrThrowLoopDetected(pendingSend.signal, toolLoopState) : getAbortAwareEndTurnStopReason(pendingSend.signal),
6830
+ ...supersededAutomaticContinuation ? { supersededAutomaticContinuation: true } : {}
6831
+ };
6832
+ }
6642
6833
  const nextAfterTools = await this.#buildNextMessageAfterToolRun(
6643
6834
  toolRun,
6644
6835
  pendingSend.signal,
6645
6836
  toolPromptId,
6646
6837
  toolLoopState,
6647
- options.onFullTurnModel
6838
+ options.onFullTurnModel,
6839
+ options.rejectOnLoopDetected ?? false
6648
6840
  );
6649
6841
  nextMessage = nextAfterTools.message;
6650
6842
  if (nextAfterTools.hadMidTurnUserInput) {
@@ -6949,7 +7141,7 @@ ${this.pendingRecoveredAgentsNotice}
6949
7141
  );
6950
7142
  await this.messageRewriter?.waitForPendingRewrites();
6951
7143
  }
6952
- async #buildNextMessageAfterToolRun(toolRun, abortSignal, promptId, toolLoopState, onFullTurnModel) {
7144
+ async #buildNextMessageAfterToolRun(toolRun, abortSignal, promptId, toolLoopState, onFullTurnModel, rejectOnLoopDetected = false) {
6953
7145
  if (toolRun.loopDetected) {
6954
7146
  debugLogger6.debug("Stopping ACP turn after daemon loop detection.");
6955
7147
  return { message: null, hadMidTurnUserInput: false };
@@ -7039,14 +7231,16 @@ ${this.pendingRecoveredAgentsNotice}
7039
7231
  toolLoopState,
7040
7232
  { recordToQwenLogger: false }
7041
7233
  );
7042
- try {
7043
- await this.messageEmitter.emitAgentMessage(
7044
- REPEATED_TOOL_FAILURE_STOP_MESSAGE
7045
- );
7046
- } catch (error) {
7047
- debugLogger6.warn(
7048
- `Failed to emit repeated tool failure stop message: ${this.#formatError(error)}`
7049
- );
7234
+ if (!rejectOnLoopDetected) {
7235
+ try {
7236
+ await this.messageEmitter.emitAgentMessage(
7237
+ REPEATED_TOOL_FAILURE_STOP_MESSAGE
7238
+ );
7239
+ } catch (error) {
7240
+ debugLogger6.warn(
7241
+ `Failed to emit repeated tool failure stop message: ${this.#formatError(error)}`
7242
+ );
7243
+ }
7050
7244
  }
7051
7245
  return {
7052
7246
  message: null,
@@ -7389,6 +7583,15 @@ ${this.pendingRecoveredAgentsNotice}
7389
7583
  if (this.notificationProcessing) return;
7390
7584
  if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
7391
7585
  if (this.#nextCronQueueIndex() < 0) return;
7586
+ await this.runExclusiveAutomaticHistoryMutation(
7587
+ () => this.#drainCronQueueExclusive()
7588
+ );
7589
+ }
7590
+ async #drainCronQueueExclusive() {
7591
+ if (this.disposed || this.closing || this.cronProcessing) return;
7592
+ if (this.pendingPrompt || this.notificationProcessing) return;
7593
+ if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
7594
+ if (this.#nextCronQueueIndex() < 0) return;
7392
7595
  try {
7393
7596
  await this.assertCanStartTurn();
7394
7597
  } catch (error) {
@@ -7483,7 +7686,10 @@ ${this.pendingRecoveredAgentsNotice}
7483
7686
  const promptId = this.config.getSessionId() + "########cron" + Date.now();
7484
7687
  let cronHadError = false;
7485
7688
  let cronCompleted = false;
7486
- const channelDeliveryCapture = item.delivery ? { finalText: "" } : void 0;
7689
+ const responseCapture = {
7690
+ ...item.delivery ? { channelDelivery: { finalText: "" } } : {},
7691
+ agentOutput: new AgentOutputMessageCapture(this.config)
7692
+ };
7487
7693
  await withInteractionSpan(
7488
7694
  this.config,
7489
7695
  {
@@ -7596,7 +7802,7 @@ ${this.pendingRecoveredAgentsNotice}
7596
7802
  return;
7597
7803
  }
7598
7804
  const responseStream = sendResult.responseStream;
7599
- const channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(channelDeliveryCapture);
7805
+ const channelDeliveryResponseBlock = beginChannelDeliveryResponseBlock(responseCapture);
7600
7806
  const channelDeliveryCheckpoint = channelDeliveryResponseBlock?.length ?? 0;
7601
7807
  if (loopTick && turnCount === 1) {
7602
7808
  this.loopTickResolver?.markDelivered();
@@ -7622,10 +7828,14 @@ ${this.pendingRecoveredAgentsNotice}
7622
7828
  part.thought
7623
7829
  );
7624
7830
  if (!part.thought) {
7831
+ responseCapture.agentOutput.appendText(part.text);
7625
7832
  channelDeliveryResponseBlock?.push(part.text);
7626
7833
  messageDisplay?.addChunk(part.text);
7627
7834
  }
7628
7835
  }
7836
+ responseCapture.agentOutput.observeFinishReason(
7837
+ candidate.finishReason
7838
+ );
7629
7839
  }
7630
7840
  if (resp.type === "chunk" /* CHUNK */ && resp.value.usageMetadata) {
7631
7841
  usageMetadata = resp.value.usageMetadata;
@@ -7638,6 +7848,9 @@ ${this.pendingRecoveredAgentsNotice}
7638
7848
  }
7639
7849
  }
7640
7850
  if (resp.type === "retry" /* RETRY */ || resp.type === "model_fallback" /* MODEL_FALLBACK */) {
7851
+ responseCapture.agentOutput.restartAttempt(
7852
+ resp.type === "retry" /* RETRY */ && resp.isContinuation === true
7853
+ );
7641
7854
  if (resp.type === "model_fallback" /* MODEL_FALLBACK */ || !resp.isContinuation) {
7642
7855
  if (channelDeliveryResponseBlock) {
7643
7856
  channelDeliveryResponseBlock.length = channelDeliveryCheckpoint;
@@ -7666,7 +7879,7 @@ ${this.pendingRecoveredAgentsNotice}
7666
7879
  }
7667
7880
  }
7668
7881
  commitChannelDeliveryResponseBlock(
7669
- channelDeliveryCapture,
7882
+ responseCapture,
7670
7883
  channelDeliveryResponseBlock,
7671
7884
  functionCalls.length > 0
7672
7885
  );
@@ -7717,7 +7930,7 @@ ${this.pendingRecoveredAgentsNotice}
7717
7930
  void 0,
7718
7931
  false,
7719
7932
  void 0,
7720
- channelDeliveryCapture
7933
+ responseCapture
7721
7934
  );
7722
7935
  stopReason = guardStop.stopReason;
7723
7936
  if (guardStop.stopReason === "max_tokens") {
@@ -7750,6 +7963,11 @@ ${this.pendingRecoveredAgentsNotice}
7750
7963
  )
7751
7964
  );
7752
7965
  }
7966
+ if (!ac.signal.aborted && !cronHadError) {
7967
+ responseCapture.agentOutput.writeToSpan(
7968
+ getActiveInteractionSpan()
7969
+ );
7970
+ }
7753
7971
  },
7754
7972
  () => ac.signal.aborted ? "cancelled" : cronHadError ? "error" : "ok"
7755
7973
  );
@@ -7760,7 +7978,7 @@ ${this.pendingRecoveredAgentsNotice}
7760
7978
  source: "scheduled",
7761
7979
  target: item.delivery.target,
7762
7980
  text: normalizeChannelDeliveryText(
7763
- channelDeliveryCapture?.finalText ?? ""
7981
+ responseCapture.channelDelivery?.finalText ?? ""
7764
7982
  ),
7765
7983
  taskId: item.taskId,
7766
7984
  firedAt: item.firedAt
@@ -7832,6 +8050,10 @@ ${this.pendingRecoveredAgentsNotice}
7832
8050
  });
7833
8051
  });
7834
8052
  const shellRegistry = this.config.getBackgroundShellRegistry();
8053
+ this.#shellStatusChangeCallback = () => {
8054
+ this.#activeWorkChanged();
8055
+ };
8056
+ shellRegistry.setStatusChangeCallback(this.#shellStatusChangeCallback);
7835
8057
  shellRegistry.setNotificationCallback((displayText, modelText, meta) => {
7836
8058
  const entry = shellRegistry.get(meta.shellId);
7837
8059
  this.#enqueueBackgroundNotification({
@@ -7963,6 +8185,18 @@ ${this.pendingRecoveredAgentsNotice}
7963
8185
  if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
7964
8186
  if (this.notificationQueue.length === 0) return;
7965
8187
  if (this.#nextNotificationQueueIndex() < 0) return;
8188
+ await this.runExclusiveAutomaticHistoryMutation(
8189
+ () => this.#drainNotificationQueueExclusive()
8190
+ );
8191
+ }
8192
+ async #drainNotificationQueueExclusive() {
8193
+ if (this.disposed || this.closing || this.notificationProcessing) return;
8194
+ if (this.pendingPrompt || this.cronProcessing || this.cronAbortController) {
8195
+ return;
8196
+ }
8197
+ if (this.#deferAutomaticQueueDrainUntilTurnsSettle()) return;
8198
+ if (this.notificationQueue.length === 0) return;
8199
+ if (this.#nextNotificationQueueIndex() < 0) return;
7966
8200
  try {
7967
8201
  await this.assertCanStartTurn();
7968
8202
  } catch (error) {
@@ -7990,6 +8224,7 @@ ${this.pendingRecoveredAgentsNotice}
7990
8224
  const [item] = this.notificationQueue.splice(nextIndex, 1);
7991
8225
  if (!item) break;
7992
8226
  this.currentAgentNotificationTaskId = item.kind === "agent" ? item.taskId : null;
8227
+ this.currentShellNotificationActive = item.kind === "shell";
7993
8228
  this.#activeWorkChanged();
7994
8229
  try {
7995
8230
  await runWithInvocationContext(
@@ -8001,6 +8236,7 @@ ${this.pendingRecoveredAgentsNotice}
8001
8236
  );
8002
8237
  } finally {
8003
8238
  this.currentAgentNotificationTaskId = null;
8239
+ this.currentShellNotificationActive = false;
8004
8240
  this.#activeWorkChanged();
8005
8241
  }
8006
8242
  }
@@ -10016,6 +10252,13 @@ ${this.pendingRecoveredAgentsNotice}
10016
10252
  toolName: policyToolName,
10017
10253
  args: invocation.params,
10018
10254
  signal: activeToolAbortSignal,
10255
+ // Same identity and execution scope `CoreToolScheduler`
10256
+ // supplies. This is the path daemon ACP sessions actually
10257
+ // take, so without them a host policy that falls back to the
10258
+ // session — or reasons about where the tool runs — sees
10259
+ // neither on every call made here.
10260
+ sessionId: this.config.getSessionId(),
10261
+ cwd: this.config.getTargetDir(),
10019
10262
  ...invocationContext ? { invocationContext } : {}
10020
10263
  }
10021
10264
  );
@@ -11022,10 +11265,11 @@ ${contextPart.text}`
11022
11265
  init_esbuild_shims();
11023
11266
  var debugLogger7 = createDebugLogger("ACTIVE_WORK");
11024
11267
  var ActiveWorkReporter = class {
11025
- constructor(send, listSources, intervalMs) {
11268
+ constructor(send, listSources, intervalMs, enabledCategories) {
11026
11269
  this.send = send;
11027
11270
  this.listSources = listSources;
11028
11271
  this.intervalMs = intervalMs;
11272
+ this.#enabledCategories = new Set(enabledCategories);
11029
11273
  this.#timer = setInterval(() => {
11030
11274
  this.#publish();
11031
11275
  }, intervalMs);
@@ -11040,6 +11284,7 @@ var ActiveWorkReporter = class {
11040
11284
  #coalescing = false;
11041
11285
  #timer;
11042
11286
  #disposed = false;
11287
+ #enabledCategories;
11043
11288
  /**
11044
11289
  * Note that some Session's derived state may have changed. Coalesced to
11045
11290
  * one snapshot per microtask so a burst of transitions (an agent finishing
@@ -11087,7 +11332,7 @@ var ActiveWorkReporter = class {
11087
11332
  for (const source of this.listSources()) {
11088
11333
  sessions.push({
11089
11334
  sessionId: source.sessionId,
11090
- holds: source.collectActiveWorkHolds()
11335
+ holds: source.collectActiveWorkHolds().filter((hold) => this.#enabledCategories.has(hold.category))
11091
11336
  });
11092
11337
  }
11093
11338
  } catch (error) {
@@ -11381,11 +11626,15 @@ async function shutdownSessionConfig(config) {
11381
11626
  }
11382
11627
  }
11383
11628
  __name(shutdownSessionConfig, "shutdownSessionConfig");
11384
- async function waitForSessionDrain(operation, timeoutMs, kind) {
11629
+ async function waitForSessionDrain(operation, timeoutMs, kind, displayTimeoutMs) {
11385
11630
  let timer;
11386
11631
  const timeout = new Promise((_, reject) => {
11387
11632
  timer = setTimeout(
11388
- () => reject(new Error(`Session ${kind} timed out after ${timeoutMs}ms`)),
11633
+ () => reject(
11634
+ new Error(
11635
+ `Session ${kind} timed out after ${displayTimeoutMs ?? timeoutMs}ms`
11636
+ )
11637
+ ),
11389
11638
  timeoutMs
11390
11639
  );
11391
11640
  timer.unref();
@@ -11691,6 +11940,15 @@ function getLoadReplayPageSize(params) {
11691
11940
  return value;
11692
11941
  }
11693
11942
  __name(getLoadReplayPageSize, "getLoadReplayPageSize");
11943
+ function deriveForkBaseName(name, recording, sessionId) {
11944
+ if (typeof name === "string" && name.trim().length > 0) {
11945
+ return name.trim();
11946
+ }
11947
+ const existingTitle = recording?.getCurrentCustomTitle();
11948
+ const stripped = existingTitle?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, "").trim();
11949
+ return stripped && stripped.length > 0 ? stripped : sessionId.slice(0, 8);
11950
+ }
11951
+ __name(deriveForkBaseName, "deriveForkBaseName");
11694
11952
  function createHiddenWorkspaceMemoryConfig(config) {
11695
11953
  return new Proxy(config, {
11696
11954
  get(target, prop) {
@@ -13086,23 +13344,28 @@ async function deliverClientMcpMessage(connection, serverName, message, sessionI
13086
13344
  return payload;
13087
13345
  }
13088
13346
  __name(deliverClientMcpMessage, "deliverClientMcpMessage");
13089
- function createManagedExternalToolGuard(connection) {
13347
+ function createManagedExternalToolGuard(connection, options = {
13348
+ externalProviderAttached: false
13349
+ }) {
13090
13350
  return async (context) => {
13351
+ if (!options.externalProviderAttached && !SHELL_EXECUTING_TOOL_NAMES.has(context.toolName)) {
13352
+ return { allowed: true };
13353
+ }
13091
13354
  const invocation = context.invocationContext;
13092
- if (!invocation) {
13355
+ if (!invocation && options.externalProviderAttached) {
13093
13356
  throw new Error(
13094
13357
  "Managed external tool guard requires a runtime invocation context."
13095
13358
  );
13096
13359
  }
13360
+ const sessionId = invocation?.sessionId ?? context.sessionId;
13361
+ if (typeof sessionId !== "string" || sessionId.length === 0) {
13362
+ throw new Error(
13363
+ "Managed external tool guard requires a session identity."
13364
+ );
13365
+ }
13097
13366
  if (context.signal.aborted) {
13098
13367
  throw new DOMException("Tool invocation aborted", "AbortError");
13099
13368
  }
13100
- if (context.toolName === ToolNames.AGENT || context.toolName === ToolNames.WORKFLOW || context.toolName === ToolNames.CREATE_SUB_SESSION || context.toolName === ToolNames.SEND_MESSAGE) {
13101
- return {
13102
- allowed: false,
13103
- reason: "Managed external tool guard v1 does not support nested or delegated agent execution."
13104
- };
13105
- }
13106
13369
  let rejectOnAbort;
13107
13370
  const aborted = new Promise((_resolve, reject) => {
13108
13371
  rejectOnAbort = reject;
@@ -13117,11 +13380,14 @@ function createManagedExternalToolGuard(connection) {
13117
13380
  connection.extMethod(
13118
13381
  SERVE_CONTROL_EXT_METHODS.externalToolGuardPrepare,
13119
13382
  {
13120
- sessionId: invocation.sessionId,
13121
- promptId: invocation.promptId,
13383
+ sessionId,
13384
+ ...invocation ? { promptId: invocation.promptId } : {},
13122
13385
  toolCallId: context.callId,
13123
13386
  toolName: context.toolName,
13124
- arguments: context.args
13387
+ arguments: context.args,
13388
+ // A sub-agent pinned to a worktree executes here, not in the
13389
+ // session's own directory; the host validates this before use.
13390
+ ...typeof context.cwd === "string" && context.cwd.length > 0 ? { invocationCwd: context.cwd } : {}
13125
13391
  }
13126
13392
  ),
13127
13393
  aborted
@@ -13248,8 +13514,10 @@ async function runAcpAgent(config, settings, argv, options) {
13248
13514
  const privateParentCapability = options === void 0 ? process.env[PRIVATE_ACP_CAPABILITY_ENV] : options.privateParentCapability;
13249
13515
  delete process.env[PRIVATE_ACP_CAPABILITY_ENV];
13250
13516
  delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV];
13517
+ delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV];
13251
13518
  delete process.env[EXTERNAL_TOOL_GUARD_TOKEN_ENV];
13252
13519
  const externalToolGuardRequired = options?.externalToolGuardRequired === true;
13520
+ const externalToolGuardProviderAttached = options?.externalToolGuardProviderAttached === true;
13253
13521
  if (externalToolGuardRequired && privateParentCapability === void 0) {
13254
13522
  throw new Error(
13255
13523
  "Required external tool guard is available only to a private managed ACP parent."
@@ -13331,7 +13599,9 @@ async function runAcpAgent(config, settings, argv, options) {
13331
13599
  });
13332
13600
  connection = new AgentSideConnection((conn) => {
13333
13601
  acpConnection = conn;
13334
- const managedToolInvocationGuard = externalToolGuardRequired ? createManagedExternalToolGuard(conn) : void 0;
13602
+ const managedToolInvocationGuard = externalToolGuardRequired ? createManagedExternalToolGuard(conn, {
13603
+ externalProviderAttached: externalToolGuardProviderAttached
13604
+ }) : void 0;
13335
13605
  agentInstance = new QwenAgent(
13336
13606
  config,
13337
13607
  settings,
@@ -13339,7 +13609,8 @@ async function runAcpAgent(config, settings, argv, options) {
13339
13609
  conn,
13340
13610
  privateParentCapability,
13341
13611
  sessionWriterLeaseEnabledAtStartup,
13342
- managedToolInvocationGuard
13612
+ managedToolInvocationGuard,
13613
+ externalToolGuardProviderAttached
13343
13614
  );
13344
13615
  return agentInstance;
13345
13616
  }, stream);
@@ -13645,7 +13916,7 @@ function isOwnerOnlyDirectory(stats) {
13645
13916
  }
13646
13917
  __name(isOwnerOnlyDirectory, "isOwnerOnlyDirectory");
13647
13918
  var QwenAgent = class {
13648
- constructor(config, settings, argv, connection, expectedPrivateParentCapability, sessionWriterLeaseEnabledAtStartup = false, managedToolInvocationGuard) {
13919
+ constructor(config, settings, argv, connection, expectedPrivateParentCapability, sessionWriterLeaseEnabledAtStartup = false, managedToolInvocationGuard, externalToolGuardProviderAttached = false) {
13649
13920
  this.config = config;
13650
13921
  this.settings = settings;
13651
13922
  this.argv = argv;
@@ -13653,6 +13924,7 @@ var QwenAgent = class {
13653
13924
  this.expectedPrivateParentCapability = expectedPrivateParentCapability;
13654
13925
  this.sessionWriterLeaseEnabledAtStartup = sessionWriterLeaseEnabledAtStartup;
13655
13926
  this.managedToolInvocationGuard = managedToolInvocationGuard;
13927
+ this.externalToolGuardProviderAttached = externalToolGuardProviderAttached;
13656
13928
  if (process.env["QWEN_SERVE_NO_MCP_POOL"] === "1") {
13657
13929
  this.mcpPool = void 0;
13658
13930
  this.workspaceMcpBudget = void 0;
@@ -13683,6 +13955,7 @@ var QwenAgent = class {
13683
13955
  __name(this, "QwenAgent");
13684
13956
  }
13685
13957
  sessions = /* @__PURE__ */ new Map();
13958
+ historyMutationTails = /* @__PURE__ */ new Map();
13686
13959
  startingSessionIds = /* @__PURE__ */ new Set();
13687
13960
  activePromptCalls = /* @__PURE__ */ new Map();
13688
13961
  workspaceMcpDiscoveryConfig;
@@ -13746,8 +14019,45 @@ var QwenAgent = class {
13746
14019
  throw new SessionWriterUnavailableError();
13747
14020
  }
13748
14021
  }
14022
+ async runExclusiveHistoryMutation(sessionId, operation, waitTimeoutMs, waitDisplayTimeoutMs) {
14023
+ const previous = this.historyMutationTails.get(sessionId) ?? Promise.resolve();
14024
+ let release;
14025
+ const gate = new Promise((resolve6) => {
14026
+ release = resolve6;
14027
+ });
14028
+ const current = previous.then(() => gate);
14029
+ this.historyMutationTails.set(sessionId, current);
14030
+ try {
14031
+ if (waitTimeoutMs === void 0) {
14032
+ await previous;
14033
+ } else {
14034
+ await waitForSessionDrain(
14035
+ previous,
14036
+ waitTimeoutMs,
14037
+ "close",
14038
+ waitDisplayTimeoutMs
14039
+ );
14040
+ }
14041
+ } catch (error) {
14042
+ release();
14043
+ void current.then(() => {
14044
+ if (this.historyMutationTails.get(sessionId) === current) {
14045
+ this.historyMutationTails.delete(sessionId);
14046
+ }
14047
+ });
14048
+ throw error;
14049
+ }
14050
+ try {
14051
+ return await operation();
14052
+ } finally {
14053
+ release();
14054
+ if (this.historyMutationTails.get(sessionId) === current) {
14055
+ this.historyMutationTails.delete(sessionId);
14056
+ }
14057
+ }
14058
+ }
13749
14059
  rejectUnsupportedGuardedHiddenAgent(operation) {
13750
- if (this.managedToolInvocationGuard) {
14060
+ if (this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) {
13751
14061
  throw RequestError.invalidParams(
13752
14062
  void 0,
13753
14063
  `Managed external tool guard v1 does not support ${operation}.`
@@ -14245,11 +14555,10 @@ var QwenAgent = class {
14245
14555
  }
14246
14556
  const recorder = session.getConfig().getChatRecordingService();
14247
14557
  const requireFlush = opts?.requireFlush === true;
14248
- if (requireFlush) {
14249
- await recorder?.flush();
14250
- }
14558
+ if (requireFlush) await recorder?.flush();
14251
14559
  const drainTimeoutMs = opts?.drainTimeoutMs ?? SESSION_DRAIN_TIMEOUT_MS;
14252
14560
  const cancelClose = opts?.waitForCloseGate ? await beginSessionCloseAfterCurrentGate(session, drainTimeoutMs) : session.beginClose();
14561
+ const conditionalDrainDeadline = opts?.onlyIfUnheld ? Date.now() + drainTimeoutMs : void 0;
14253
14562
  if (opts?.onlyIfUnheld) {
14254
14563
  const holds = session.collectActiveWorkHolds();
14255
14564
  if (holds.length > 0) {
@@ -14257,13 +14566,24 @@ var QwenAgent = class {
14257
14566
  return { closed: false, holds };
14258
14567
  }
14259
14568
  }
14260
- for (const [requestId, generation] of this.generationControllers) {
14261
- if (generation.sessionId !== sessionId) continue;
14262
- generation.controller.abort();
14263
- this.generationControllers.delete(requestId);
14264
- }
14265
14569
  let removedFromStore = false;
14266
14570
  try {
14571
+ if (opts?.onlyIfUnheld) {
14572
+ await waitForSessionDrain(
14573
+ session.waitForActiveTurnsToSettle(),
14574
+ drainTimeoutMs,
14575
+ "close"
14576
+ );
14577
+ const holds = session.collectActiveWorkHolds();
14578
+ if (holds.length > 0) {
14579
+ return { closed: false, holds };
14580
+ }
14581
+ }
14582
+ for (const [requestId, generation] of this.generationControllers) {
14583
+ if (generation.sessionId !== sessionId) continue;
14584
+ generation.controller.abort();
14585
+ this.generationControllers.delete(requestId);
14586
+ }
14267
14587
  await waitForSessionDrain(
14268
14588
  (async () => {
14269
14589
  try {
@@ -14275,35 +14595,68 @@ var QwenAgent = class {
14275
14595
  }
14276
14596
  await session.waitForActiveTurnsToSettle();
14277
14597
  })(),
14278
- drainTimeoutMs,
14279
- "close"
14598
+ conditionalDrainDeadline === void 0 ? drainTimeoutMs : Math.max(1, conditionalDrainDeadline - Date.now()),
14599
+ "close",
14600
+ // Report the shared budget, not the phase-2 residue — a residue like
14601
+ // "1ms" hides that the settle phase consumed the budget and sends
14602
+ // oncall grepping for a timeout setting that does not exist.
14603
+ drainTimeoutMs
14280
14604
  );
14281
- recorder?.finalize();
14282
- let flushError;
14283
- try {
14284
- await recorder?.flush();
14285
- } catch (error) {
14286
- flushError = error;
14287
- }
14288
- if (flushError !== void 0 && requireFlush) {
14289
- throw flushError;
14290
- }
14291
- let closeError;
14292
- try {
14293
- await recorder?.close();
14294
- } catch (error) {
14295
- closeError = error;
14296
- }
14297
- if (recorder?.hasWriteOwnership()) {
14298
- throw closeError ?? new SessionWriterUnavailableError();
14299
- }
14300
- const cleanupErrors = [];
14301
- if (flushError !== void 0) cleanupErrors.push(flushError);
14302
- if (closeError !== void 0) cleanupErrors.push(closeError);
14303
- await this.removeStoredSessionEntry(sessionId, session, cleanupErrors, {
14304
- shutdownConfig: opts?.shutdownConfig
14305
- });
14306
- removedFromStore = true;
14605
+ const blockedByHolds = await this.runExclusiveHistoryMutation(
14606
+ sessionId,
14607
+ async () => {
14608
+ if (this.sessions.get(sessionId) !== session) {
14609
+ removedFromStore = true;
14610
+ return void 0;
14611
+ }
14612
+ if (opts?.onlyIfUnheld) {
14613
+ const holds = session.collectActiveWorkHolds();
14614
+ if (holds.length > 0) {
14615
+ return { closed: false, holds };
14616
+ }
14617
+ }
14618
+ recorder?.finalize();
14619
+ let flushError;
14620
+ try {
14621
+ await recorder?.flush();
14622
+ } catch (error) {
14623
+ flushError = error;
14624
+ }
14625
+ if (flushError !== void 0 && requireFlush) {
14626
+ throw flushError;
14627
+ }
14628
+ let closeError;
14629
+ try {
14630
+ await recorder?.close();
14631
+ } catch (error) {
14632
+ closeError = error;
14633
+ }
14634
+ if (recorder?.hasWriteOwnership()) {
14635
+ throw closeError ?? new SessionWriterUnavailableError();
14636
+ }
14637
+ const cleanupErrors = [];
14638
+ if (flushError !== void 0) cleanupErrors.push(flushError);
14639
+ if (closeError !== void 0) cleanupErrors.push(closeError);
14640
+ await this.removeStoredSessionEntry(
14641
+ sessionId,
14642
+ session,
14643
+ cleanupErrors,
14644
+ {
14645
+ shutdownConfig: opts?.shutdownConfig
14646
+ }
14647
+ );
14648
+ removedFromStore = true;
14649
+ return void 0;
14650
+ },
14651
+ // The mutation wait shares the conditional close's budget too, or
14652
+ // the whole round trip can outlast the daemon's outer wait — the
14653
+ // coupling the drain budget exists to keep. The mutation body
14654
+ // itself stays untimed, so the guarantee remains approximate. The
14655
+ // message reports the shared budget, not the residue.
14656
+ conditionalDrainDeadline === void 0 ? drainTimeoutMs : Math.max(1, conditionalDrainDeadline - Date.now()),
14657
+ drainTimeoutMs
14658
+ );
14659
+ if (blockedByHolds) return blockedByHolds;
14307
14660
  } finally {
14308
14661
  if (!removedFromStore) cancelClose();
14309
14662
  }
@@ -14411,7 +14764,7 @@ var QwenAgent = class {
14411
14764
  }
14412
14765
  this.clientCapabilities = args.clientCapabilities;
14413
14766
  const authMethods = buildAuthMethods();
14414
- const version = "0.21.12-preview.5";
14767
+ const version = "0.21.13";
14415
14768
  const response = {
14416
14769
  protocolVersion: PROTOCOL_VERSION,
14417
14770
  agentInfo: {
@@ -14455,12 +14808,17 @@ var QwenAgent = class {
14455
14808
  const activeWorkIntervalMs = activeWorkRequested ? clampActiveWorkIntervalMs(
14456
14809
  requestedActiveWork["intervalMs"]
14457
14810
  ) : void 0;
14811
+ const requestedActiveWorkCategories = activeWorkRequested ? requestedActiveWork["categories"] : void 0;
14812
+ const activeWorkCategories = activeWorkRequested ? Array.isArray(requestedActiveWorkCategories) ? ACTIVE_WORK_HOLD_CATEGORIES.filter(
14813
+ (category) => requestedActiveWorkCategories.includes(category)
14814
+ ) : ACTIVE_WORK_LEGACY_HOLD_CATEGORIES : void 0;
14458
14815
  if (activeWorkIntervalMs !== void 0) {
14459
14816
  this.activeWorkReporter?.dispose();
14460
14817
  this.activeWorkReporter = new ActiveWorkReporter(
14461
14818
  (method, params) => this.connection.extNotification(method, params),
14462
14819
  () => this.sessions.values(),
14463
- activeWorkIntervalMs
14820
+ activeWorkIntervalMs,
14821
+ activeWorkCategories ?? []
14464
14822
  );
14465
14823
  }
14466
14824
  const responseMeta = {
@@ -14472,7 +14830,7 @@ var QwenAgent = class {
14472
14830
  [ACTIVE_WORK_HEARTBEAT_META_KEY]: {
14473
14831
  v: ACTIVE_WORK_HEARTBEAT_VERSION,
14474
14832
  intervalMs: activeWorkIntervalMs,
14475
- categories: [...ACTIVE_WORK_HOLD_CATEGORIES]
14833
+ categories: [...activeWorkCategories ?? []]
14476
14834
  }
14477
14835
  } : {}
14478
14836
  };
@@ -15234,13 +15592,23 @@ var QwenAgent = class {
15234
15592
  const suppliedContext = meta[INVOCATION_CONTEXT_META_KEY];
15235
15593
  const suppliedModelPrompt = meta[DAEMON_MODEL_PROMPT_META_KEY];
15236
15594
  const suppliedPromptDisplayText = meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
15595
+ const suppliedChannelPrompt = meta[CHANNEL_PROMPT_META_KEY];
15596
+ const suppliedChannelDelivery = meta[DAEMON_CHANNEL_DELIVERY_META_KEY];
15237
15597
  delete meta[INVOCATION_CONTEXT_META_KEY];
15238
15598
  delete meta[DAEMON_MODEL_PROMPT_META_KEY];
15239
15599
  delete meta[PRIVATE_PARENT_CAPABILITY_META_KEY];
15240
15600
  delete meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
15601
+ delete meta[CHANNEL_PROMPT_META_KEY];
15602
+ delete meta[DAEMON_CHANNEL_DELIVERY_META_KEY];
15241
15603
  if (this.privateParentState === "trusted" && typeof suppliedPromptDisplayText === "string") {
15242
15604
  meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] = suppliedPromptDisplayText;
15243
15605
  }
15606
+ if (this.privateParentState === "trusted" && suppliedChannelPrompt === true) {
15607
+ meta[CHANNEL_PROMPT_META_KEY] = true;
15608
+ }
15609
+ if (this.privateParentState === "trusted" && suppliedChannelDelivery !== void 0) {
15610
+ meta[DAEMON_CHANNEL_DELIVERY_META_KEY] = suppliedChannelDelivery;
15611
+ }
15244
15612
  if (Object.keys(meta).length > 0) {
15245
15613
  sanitizedParams._meta = meta;
15246
15614
  } else {
@@ -15303,6 +15671,9 @@ var QwenAgent = class {
15303
15671
  throw error;
15304
15672
  }
15305
15673
  }
15674
+ for (const call of this.activePromptCalls.get(sessionId) ?? []) {
15675
+ call.controller.abort();
15676
+ }
15306
15677
  }
15307
15678
  loadPermissionSettings(cwd) {
15308
15679
  this.settings = loadSettings(cwd);
@@ -17597,7 +17968,7 @@ var QwenAgent = class {
17597
17968
  );
17598
17969
  case SERVE_CONTROL_EXT_METHODS.workspaceMemoryRememberAvailability:
17599
17970
  return {
17600
- available: !this.managedToolInvocationGuard && this.config.isManagedMemoryAvailable()
17971
+ available: !(this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) && this.config.isManagedMemoryAvailable()
17601
17972
  };
17602
17973
  case SERVE_CONTROL_EXT_METHODS.workspaceMemoryRemember: {
17603
17974
  this.rejectUnsupportedGuardedHiddenAgent(
@@ -19154,7 +19525,7 @@ var QwenAgent = class {
19154
19525
  return { sessionId, answer: result.text || null };
19155
19526
  }
19156
19527
  case SERVE_CONTROL_EXT_METHODS.sessionForkAgent: {
19157
- if (this.managedToolInvocationGuard) {
19528
+ if (this.managedToolInvocationGuard && this.externalToolGuardProviderAttached) {
19158
19529
  throw RequestError.invalidParams(
19159
19530
  void 0,
19160
19531
  "Managed external tool guard v1 does not support /fork."
@@ -19637,9 +20008,25 @@ ${outputText}
19637
20008
  `Session not found for id: ${sessionId}`
19638
20009
  );
19639
20010
  }
20011
+ if (!session.isTurnIdle()) {
20012
+ throw new RequestError(
20013
+ -32602,
20014
+ "Cannot rewind while a prompt is running",
20015
+ {
20016
+ errorKind: "session_busy"
20017
+ }
20018
+ );
20019
+ }
20020
+ const rawPromptId = params["promptId"];
20021
+ if (rawPromptId !== void 0 && typeof rawPromptId !== "string") {
20022
+ throw new RequestError(-32602, "Invalid promptId format", {
20023
+ errorKind: "invalid_rewind_target"
20024
+ });
20025
+ }
20026
+ const promptId = typeof rawPromptId === "string" ? rawPromptId : void 0;
19640
20027
  let turnIndex = params["targetTurnIndex"];
19641
- const promptId = params["promptId"];
19642
- if (promptId && (turnIndex === void 0 || turnIndex === null)) {
20028
+ const resolveFromPromptId = promptId !== void 0 && (turnIndex === void 0 || turnIndex === null);
20029
+ if (resolveFromPromptId) {
19643
20030
  const prefix = sessionId + "########";
19644
20031
  if (!promptId.startsWith(prefix)) {
19645
20032
  throw new RequestError(-32602, "Invalid promptId format", {
@@ -19654,104 +20041,113 @@ ${outputText}
19654
20041
  { errorKind: "invalid_rewind_target" }
19655
20042
  );
19656
20043
  }
19657
- const fhs = session.getConfig().getFileHistoryService();
19658
- const snapshots = fhs.getSnapshots();
19659
- const snapshotIdx = snapshots.findIndex(
19660
- (s) => s.promptId === promptId
19661
- );
19662
- if (snapshotIdx < 0) {
19663
- throw new RequestError(
19664
- -32602,
19665
- "Snapshot not found for the given promptId",
19666
- { errorKind: "invalid_rewind_target" }
19667
- );
19668
- }
19669
- turnIndex = snapshotIdx;
19670
- }
19671
- if (!Number.isInteger(turnIndex) || turnIndex < 0) {
20044
+ } else if (!Number.isInteger(turnIndex) || turnIndex < 0) {
19672
20045
  throw RequestError.invalidParams(
19673
20046
  void 0,
19674
20047
  "Invalid or missing targetTurnIndex"
19675
20048
  );
19676
20049
  }
19677
- const rewindFiles = params["rewindFiles"] !== false;
19678
- const historyBeforeRewind = session.captureHistorySnapshot();
19679
- let rewindResult;
19680
- try {
19681
- rewindResult = session.rewindToTurn(turnIndex, {
19682
- rewindFiles
19683
- });
19684
- } catch (err) {
19685
- if (err instanceof RequestError) {
19686
- const msg = err.message;
19687
- if (msg.includes("Cannot rewind while a prompt is running")) {
19688
- throw new RequestError(err.code, msg, {
19689
- errorKind: "session_busy"
19690
- });
19691
- }
19692
- if (msg.includes("compressed or does not exist")) {
19693
- throw new RequestError(err.code, msg, {
19694
- errorKind: "invalid_rewind_target"
19695
- });
20050
+ return await this.runExclusiveHistoryMutation(sessionId, async () => {
20051
+ if (resolveFromPromptId) {
20052
+ const fhs = session.getConfig().getFileHistoryService();
20053
+ const snapshots = fhs.getSnapshots();
20054
+ const snapshotIdx = snapshots.findIndex(
20055
+ (s) => s.promptId === promptId
20056
+ );
20057
+ if (snapshotIdx < 0) {
20058
+ throw new RequestError(
20059
+ -32602,
20060
+ "Snapshot not found for the given promptId",
20061
+ { errorKind: "invalid_rewind_target" }
20062
+ );
19696
20063
  }
20064
+ turnIndex = snapshotIdx;
19697
20065
  }
19698
- throw err;
19699
- }
19700
- let filesChanged = [];
19701
- let filesFailed = [];
19702
- if (rewindFiles && promptId) {
19703
- const fhs = session.getConfig().getFileHistoryService();
20066
+ const rewindFiles = params["rewindFiles"] !== false;
20067
+ const historyBeforeRewind = session.captureHistorySnapshot();
20068
+ let rewindResult;
20069
+ let releaseHistoryMutation;
19704
20070
  try {
19705
- const fileResult = await fhs.rewind(promptId, true);
19706
- filesChanged = fileResult.filesChanged;
19707
- filesFailed = fileResult.filesFailed;
20071
+ rewindResult = session.rewindToTurn(turnIndex, {
20072
+ rewindFiles
20073
+ });
20074
+ releaseHistoryMutation = session.beginHistoryMutation();
19708
20075
  } catch (err) {
19709
- const reason = err instanceof Error ? err.message : String(err);
19710
- debugLogger8.error(
19711
- `[ACP] File-history rewind failed for session=${sessionId} promptId=${promptId}: ${reason}`
19712
- );
19713
- filesFailed = [`file-history-rewind: ${reason}`];
20076
+ if (err instanceof RequestError) {
20077
+ const msg = err.message;
20078
+ if (msg.includes("Cannot rewind while a prompt is running") || msg.includes("Session is busy processing a turn")) {
20079
+ throw new RequestError(err.code, msg, {
20080
+ errorKind: "session_busy"
20081
+ });
20082
+ }
20083
+ if (msg.includes("compressed or does not exist")) {
20084
+ throw new RequestError(err.code, msg, {
20085
+ errorKind: "invalid_rewind_target"
20086
+ });
20087
+ }
20088
+ }
20089
+ throw err;
19714
20090
  }
19715
- }
19716
- let artifactSnapshot;
19717
- let artifactSnapshotUnavailable;
19718
- try {
19719
- const config = session.getConfig();
19720
- const recording = config.getChatRecordingService();
19721
- await recording?.flush();
19722
- const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
19723
- const sessionData = recording ? await recording.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
19724
- if (sessionData === void 0) {
19725
- artifactSnapshotUnavailable = "session data unavailable after rewind";
19726
- } else if (sessionData.artifactSnapshot) {
19727
- artifactSnapshot = sessionData.artifactSnapshot;
19728
- } else {
19729
- artifactSnapshot = {
19730
- v: SESSION_ARTIFACT_PERSISTENCE_VERSION,
19731
- sessionId,
19732
- sequence: 0,
19733
- artifacts: [],
19734
- tombstonedIds: [],
19735
- stickyEphemeralIds: [],
19736
- warnings: []
20091
+ try {
20092
+ let filesChanged = [];
20093
+ let filesFailed = [];
20094
+ if (rewindFiles && promptId) {
20095
+ const fhs = session.getConfig().getFileHistoryService();
20096
+ try {
20097
+ const fileResult = await fhs.rewind(promptId, true);
20098
+ filesChanged = fileResult.filesChanged;
20099
+ filesFailed = fileResult.filesFailed;
20100
+ } catch (err) {
20101
+ const reason = err instanceof Error ? err.message : String(err);
20102
+ debugLogger8.error(
20103
+ `[ACP] File-history rewind failed for session=${sessionId} promptId=${promptId}: ${reason}`
20104
+ );
20105
+ filesFailed = [`file-history-rewind: ${reason}`];
20106
+ }
20107
+ }
20108
+ let artifactSnapshot;
20109
+ let artifactSnapshotUnavailable;
20110
+ try {
20111
+ const config = session.getConfig();
20112
+ const recording = config.getChatRecordingService();
20113
+ await recording?.flush();
20114
+ const loadAuthoritative = /* @__PURE__ */ __name(() => config.getSessionService().loadSession(sessionId), "loadAuthoritative");
20115
+ const sessionData = recording ? await recording.runWithWriteBarrier(loadAuthoritative) : await loadAuthoritative();
20116
+ if (sessionData === void 0) {
20117
+ artifactSnapshotUnavailable = "session data unavailable after rewind";
20118
+ } else if (sessionData.artifactSnapshot) {
20119
+ artifactSnapshot = sessionData.artifactSnapshot;
20120
+ } else {
20121
+ artifactSnapshot = {
20122
+ v: SESSION_ARTIFACT_PERSISTENCE_VERSION,
20123
+ sessionId,
20124
+ sequence: 0,
20125
+ artifacts: [],
20126
+ tombstonedIds: [],
20127
+ stickyEphemeralIds: [],
20128
+ warnings: []
20129
+ };
20130
+ }
20131
+ } catch (err) {
20132
+ const reason = err instanceof Error ? err.message : String(err);
20133
+ artifactSnapshotUnavailable = "artifact snapshot unavailable after rewind";
20134
+ debugLogger8.warn(
20135
+ `[ACP] Failed to rebuild artifact snapshot after rewind for session=${sessionId}: ${reason}`
20136
+ );
20137
+ }
20138
+ return {
20139
+ success: true,
20140
+ historyBeforeRewind,
20141
+ ...rewindResult,
20142
+ filesChanged,
20143
+ filesFailed,
20144
+ ...artifactSnapshot ? { artifactSnapshot } : {},
20145
+ ...artifactSnapshotUnavailable ? { artifactSnapshotUnavailable } : {}
19737
20146
  };
20147
+ } finally {
20148
+ releaseHistoryMutation();
19738
20149
  }
19739
- } catch (err) {
19740
- const reason = err instanceof Error ? err.message : String(err);
19741
- artifactSnapshotUnavailable = "artifact snapshot unavailable after rewind";
19742
- debugLogger8.warn(
19743
- `[ACP] Failed to rebuild artifact snapshot after rewind for session=${sessionId}: ${reason}`
19744
- );
19745
- }
19746
- return {
19747
- success: true,
19748
- historyBeforeRewind,
19749
- ...rewindResult,
19750
- filesChanged,
19751
- filesFailed,
19752
- ...artifactSnapshot ? { artifactSnapshot } : {},
19753
- ...artifactSnapshotUnavailable ? { artifactSnapshotUnavailable } : {}
19754
- };
20150
+ });
19755
20151
  }
19756
20152
  case "qwen/session/loadUpdates": {
19757
20153
  const sessionId = params["sessionId"];
@@ -19854,6 +20250,16 @@ ${outputText}
19854
20250
  );
19855
20251
  }
19856
20252
  const name = params["name"];
20253
+ const atRecordId = params["atRecordId"];
20254
+ if (atRecordId !== void 0 && typeof atRecordId !== "string") {
20255
+ throw RequestError.invalidParams(void 0, "Invalid atRecordId");
20256
+ }
20257
+ if (isSideTask && atRecordId !== void 0) {
20258
+ throw RequestError.invalidParams(
20259
+ void 0,
20260
+ "atRecordId is not supported for side tasks"
20261
+ );
20262
+ }
19857
20263
  const sourceSession = this.sessions.get(sessionId);
19858
20264
  if (!sourceSession) {
19859
20265
  throw new RequestError(-32004, `Session not found: ${sessionId}`, {
@@ -19861,60 +20267,77 @@ ${outputText}
19861
20267
  sessionId
19862
20268
  });
19863
20269
  }
20270
+ if (!isSideTask) {
20271
+ if (!sourceSession.isTurnIdle()) {
20272
+ throw new RequestError(
20273
+ -32602,
20274
+ "Cannot branch while a prompt is running",
20275
+ { errorKind: "session_busy" }
20276
+ );
20277
+ }
20278
+ try {
20279
+ return await this.runExclusiveHistoryMutation(
20280
+ sessionId,
20281
+ async () => {
20282
+ await sourceSession.assertCanStartTurn();
20283
+ const releaseHistoryMutation = sourceSession.beginHistoryMutation();
20284
+ try {
20285
+ const sourceConfig2 = sourceSession.getConfig();
20286
+ const recording2 = sourceConfig2.getChatRecordingService();
20287
+ const sessionService2 = sourceConfig2.getSessionService();
20288
+ const baseName = deriveForkBaseName(
20289
+ name,
20290
+ recording2,
20291
+ sessionId
20292
+ );
20293
+ const title2 = await computeUniqueBranchTitle(
20294
+ baseName,
20295
+ sessionService2
20296
+ );
20297
+ const newSessionId2 = randomUUID2();
20298
+ const fork2 = /* @__PURE__ */ __name(() => sessionService2.forkSession(sessionId, newSessionId2, {
20299
+ title: title2,
20300
+ ...atRecordId !== void 0 ? { atRecordId } : {}
20301
+ }), "fork");
20302
+ if (recording2) {
20303
+ await recording2.runWithWriteBarrier(fork2);
20304
+ } else {
20305
+ await fork2();
20306
+ }
20307
+ return { newSessionId: newSessionId2, title: title2, displayName: title2 };
20308
+ } finally {
20309
+ releaseHistoryMutation();
20310
+ }
20311
+ }
20312
+ );
20313
+ } catch (error) {
20314
+ if (error instanceof BranchPointInvalidError) {
20315
+ throw new RequestError(-32009, error.message, {
20316
+ errorKind: "branch_point_invalid",
20317
+ recordId: error.recordId
20318
+ });
20319
+ }
20320
+ throw error;
20321
+ }
20322
+ }
19864
20323
  const sourceConfig = sourceSession.getConfig();
19865
20324
  const recording = sourceConfig.getChatRecordingService();
19866
- if (recording) {
19867
- await recording.flush();
19868
- }
19869
- const newSessionId = randomUUID2();
20325
+ if (recording) await recording.flush();
19870
20326
  const sessionService = sourceConfig.getSessionService();
19871
- const fork = /* @__PURE__ */ __name(() => isSideTask ? sessionService.forkSession(sessionId, newSessionId, {
20327
+ const title = deriveForkBaseName(name, recording, sessionId);
20328
+ const newSessionId = randomUUID2();
20329
+ const fork = /* @__PURE__ */ __name(() => sessionService.forkSession(sessionId, newSessionId, {
19872
20330
  source: {
19873
20331
  sourceType: "side_task",
19874
20332
  sourceId: sessionId
19875
- }
19876
- }) : sessionService.forkSession(sessionId, newSessionId), "fork");
19877
- if (isSideTask && recording) {
20333
+ },
20334
+ title
20335
+ }), "fork");
20336
+ if (recording) {
19878
20337
  await recording.runWithWriteBarrier(fork);
19879
20338
  } else {
19880
20339
  await fork();
19881
20340
  }
19882
- let title;
19883
- try {
19884
- let baseName;
19885
- if (typeof name === "string" && name.trim().length > 0) {
19886
- baseName = name.trim();
19887
- } else {
19888
- const existingTitle = recording?.getCurrentCustomTitle();
19889
- const stripped = existingTitle?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, "").trim();
19890
- if (stripped && stripped.length > 0) {
19891
- baseName = stripped;
19892
- } else {
19893
- baseName = sessionId.slice(0, 8);
19894
- }
19895
- }
19896
- title = isSideTask ? baseName : await computeUniqueBranchTitle(baseName, sessionService);
19897
- const renamed = await sessionService.renameSession(
19898
- newSessionId,
19899
- title,
19900
- "manual"
19901
- );
19902
- if (!renamed) {
19903
- throw new RequestError(
19904
- -32603,
19905
- `Failed to set title on forked session ${newSessionId}`,
19906
- { errorKind: "internal", sessionId: newSessionId }
19907
- );
19908
- }
19909
- } catch (err) {
19910
- sessionService.removeSession(newSessionId).catch((rmErr) => {
19911
- process.stderr.write(
19912
- `qwen serve: failed to clean up orphan session ${newSessionId}: ${rmErr instanceof Error ? rmErr.message : rmErr}
19913
- `
19914
- );
19915
- });
19916
- throw err;
19917
- }
19918
20341
  return { newSessionId, title, displayName: title };
19919
20342
  }
19920
20343
  case "qwen/settings/getCore": {
@@ -20699,6 +21122,7 @@ ${outputText}
20699
21122
  config,
20700
21123
  this.connection,
20701
21124
  settings,
21125
+ (operation) => this.runExclusiveHistoryMutation(sessionId, operation),
20702
21126
  () => this.activeWorkReporter?.notifyChanged()
20703
21127
  );
20704
21128
  let published = false;