@qwen-code/qwen-code 0.19.10 → 0.19.11-nightly.20260718.767a32484

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 (307) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +11 -0
  2. package/bundled/qc-helper/docs/configuration/settings.md +15 -14
  3. package/bundled/qc-helper/docs/features/approval-mode.md +2 -2
  4. package/bundled/qc-helper/docs/features/channels/dingtalk.md +30 -0
  5. package/bundled/qc-helper/docs/features/channels/overview.md +66 -17
  6. package/bundled/qc-helper/docs/features/channels/wecom.md +8 -7
  7. package/bundled/qc-helper/docs/features/sandbox.md +2 -0
  8. package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +42 -7
  9. package/bundled/qc-helper/docs/qwen-serve.md +77 -46
  10. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +1 -1
  11. package/bundled/review/SKILL.md +163 -403
  12. package/chunks/{MaxSizedBox-67ODZ4SZ.js → MaxSizedBox-ZFHA4QEQ.js} +30 -30
  13. package/chunks/{StandaloneSessionPicker-SIPBQT5Z.js → StandaloneSessionPicker-YRWOQVQA.js} +44 -44
  14. package/chunks/{acpAgent-VPZJXLFX.js → acpAgent-U2P2IESZ.js} +1423 -487
  15. package/chunks/{agent-Z7NWL6XL.js → agent-GQXX6X5Y.js} +26 -26
  16. package/chunks/{agent-headless-73HZ6ROQ.js → agent-headless-3572NBCK.js} +26 -26
  17. package/chunks/{anthropicContentGenerator-56U3YCP2.js → anthropicContentGenerator-Y65DMM64.js} +103 -18
  18. package/chunks/{artifact-tool-BWZZJ42H.js → artifact-tool-WR7I2XON.js} +2 -2
  19. package/chunks/{askUserQuestion-WU3S5A5T.js → askUserQuestion-B4FUTPHD.js} +2 -44
  20. package/chunks/{bridge-XFKW6S7Q.js → bridge-N5RMGD7G.js} +31 -33
  21. package/chunks/{ca-C2JTT2N5.js → ca-M3GQQ26D.js} +7 -2
  22. package/chunks/channel-worker-group-HZVJKLGX.js +21 -0
  23. package/chunks/{channel-worker-manager-5RWKSGEU.js → channel-worker-manager-3WDK4HNS.js} +34 -10
  24. package/chunks/{channel-worker-supervisor-PCDAZN4D.js → channel-worker-supervisor-U2W6Q5F7.js} +6 -4
  25. package/chunks/{chunk-YYPXHMWO.js → chunk-2XRGFF5K.js} +6 -6
  26. package/chunks/{chunk-ZKMGAFYV.js → chunk-2YSZE74N.js} +2 -2
  27. package/chunks/{chunk-L5U3ELZX.js → chunk-335ECZTA.js} +1 -1
  28. package/chunks/{chunk-5EBKKSBX.js → chunk-336KPNNV.js} +2 -2
  29. package/chunks/{chunk-Q5GLXH5Q.js → chunk-3CL5SEDT.js} +6 -6
  30. package/chunks/{chunk-2FO5GFKZ.js → chunk-3DJY4IFO.js} +1 -1
  31. package/chunks/{chunk-CJFNEBYB.js → chunk-3NWYQ7FX.js} +2 -2
  32. package/chunks/{chunk-WIASPMLX.js → chunk-3X2CFOUM.js} +358 -298
  33. package/chunks/{chunk-K7CRWKOE.js → chunk-3YJZ6WNY.js} +5812 -4520
  34. package/chunks/{chunk-Y66VOBRP.js → chunk-4CA4WUMS.js} +2 -2
  35. package/chunks/{chunk-LQIDP6K5.js → chunk-4CHDYDG3.js} +1 -1
  36. package/chunks/{chunk-TISZXPAX.js → chunk-4HCYNDMG.js} +1 -1
  37. package/chunks/chunk-4JBTZBCW.js +140 -0
  38. package/chunks/{chunk-TV6K2FB4.js → chunk-4RPARQ5D.js} +2 -2
  39. package/chunks/{chunk-RCEEXIOO.js → chunk-4XCVGEEX.js} +3 -3
  40. package/chunks/{chunk-N6FXRR6P.js → chunk-57RWF6R7.js} +1 -1
  41. package/chunks/chunk-5O34IMY5.js +59 -0
  42. package/chunks/{chunk-5LROA5W4.js → chunk-5QRK2VZG.js} +8 -8
  43. package/chunks/{chunk-7L4XBYVW.js → chunk-632KROVU.js} +10 -3
  44. package/chunks/{chunk-65N2J6V2.js → chunk-64XGKNSI.js} +3 -3
  45. package/chunks/{chunk-P6LART6G.js → chunk-66IT3EY2.js} +1059 -129
  46. package/chunks/{chunk-FXMC7SL2.js → chunk-6ITLKEOZ.js} +3 -3
  47. package/chunks/{chunk-F7NXQH4Y.js → chunk-6YIRYY3P.js} +1 -1
  48. package/chunks/{chunk-GGJII3FM.js → chunk-6Z5NRZVU.js} +92 -3
  49. package/chunks/{chunk-DPFBNG72.js → chunk-AEKYFMYE.js} +1 -1
  50. package/chunks/{chunk-2UUAIFQO.js → chunk-ANRANWVE.js} +9 -1
  51. package/chunks/{chunk-SXU3KKNI.js → chunk-ATJ7H5AS.js} +419 -76
  52. package/chunks/{chunk-6GETGQWP.js → chunk-C5NSOSF4.js} +64 -18
  53. package/chunks/{chunk-TQBODCFD.js → chunk-CMVFTMRD.js} +251 -3
  54. package/chunks/{chunk-DK33QJ3V.js → chunk-CZSAIBUB.js} +733 -14
  55. package/chunks/{chunk-3MX7D6QN.js → chunk-DASWPKXR.js} +32 -4
  56. package/chunks/{chunk-JSJFKYWT.js → chunk-DPSHAB47.js} +2 -2
  57. package/chunks/{chunk-7MJAZMXK.js → chunk-ECZFTRTP.js} +29 -78
  58. package/chunks/{chunk-H3FQOPPS.js → chunk-EKG3BHQY.js} +4 -4
  59. package/chunks/{chunk-FSA7ERJ2.js → chunk-F2RR4HO2.js} +1 -1
  60. package/chunks/{chunk-EQY6POVO.js → chunk-F5XYN5VF.js} +2 -2
  61. package/chunks/chunk-FEOZBUMT.js +77 -0
  62. package/chunks/{chunk-L62SEJWY.js → chunk-FHUXCRAF.js} +4 -4
  63. package/chunks/{chunk-OFEVHGVU.js → chunk-FSJGBUQI.js} +818 -31
  64. package/chunks/{chunk-FBU7WRZI.js → chunk-FUTHTZVV.js} +1 -1
  65. package/chunks/{chunk-ZRKBI3DP.js → chunk-FZRES4GK.js} +1 -1
  66. package/chunks/{chunk-OKAIGAYW.js → chunk-G274ETR6.js} +3 -3
  67. package/chunks/{chunk-6GKMJPOC.js → chunk-GA3WUOO7.js} +5 -5
  68. package/chunks/{chunk-X362TMXZ.js → chunk-GAQOQMHY.js} +8 -6
  69. package/chunks/{chunk-WLXYAKV7.js → chunk-GG6RSNWS.js} +9 -4
  70. package/chunks/{chunk-CEW4HDPK.js → chunk-GUNTLALV.js} +2484 -362
  71. package/chunks/{chunk-LXLTBIDP.js → chunk-HCCR43AY.js} +1 -1
  72. package/chunks/{chunk-RDRVMDWV.js → chunk-HIMIG6PI.js} +11 -11
  73. package/chunks/{chunk-MO7O5722.js → chunk-HQXQCIT2.js} +45 -5
  74. package/chunks/{chunk-LTNI523B.js → chunk-HT7L5FCZ.js} +28 -5
  75. package/chunks/{chunk-7NAWTFVY.js → chunk-IENO2YAT.js} +3 -3
  76. package/chunks/{chunk-3XJFUTNM.js → chunk-IK5TYYVR.js} +59 -12
  77. package/chunks/{chunk-AAR5SGMD.js → chunk-IVKLDHU6.js} +7 -5
  78. package/chunks/{chunk-6W6DI34P.js → chunk-IX7O5WI3.js} +180 -8
  79. package/chunks/{chunk-SPJQO2CE.js → chunk-J2MKYJKZ.js} +2 -2
  80. package/chunks/{chunk-SPUYQB4T.js → chunk-JBAQ5BYX.js} +1 -1
  81. package/chunks/{chunk-TYLOFD2U.js → chunk-JCJPZMJV.js} +1 -1
  82. package/chunks/chunk-JDIUK2Y3.js +226 -0
  83. package/chunks/{chunk-L37RC7MQ.js → chunk-JUVTV4NF.js} +1 -1
  84. package/chunks/{chunk-WDWJ4OQJ.js → chunk-K2GBHL73.js} +4 -4
  85. package/chunks/{chunk-HHEFI4RP.js → chunk-KEVDWH3U.js} +857 -137
  86. package/chunks/{chunk-YU56QGXX.js → chunk-KTKETHMY.js} +1 -1
  87. package/chunks/{chunk-WDW64OW3.js → chunk-LGY7PG7Q.js} +5 -5
  88. package/chunks/{chunk-E67NFMF4.js → chunk-LKR7QQ63.js} +37 -3
  89. package/chunks/{chunk-4YWLED2A.js → chunk-LSFVUGXT.js} +9 -6
  90. package/chunks/{chunk-W34A5MJH.js → chunk-LTD3CHGS.js} +1 -1
  91. package/chunks/chunk-LXXMOYPL.js +22 -0
  92. package/chunks/{chunk-BBNVFRGD.js → chunk-MI2V6IWU.js} +1 -1
  93. package/chunks/{chunk-UFOKA4PR.js → chunk-O2K6BLPZ.js} +114 -4
  94. package/chunks/{chunk-B5I2IIWY.js → chunk-OBYAX5QZ.js} +6 -6
  95. package/chunks/{chunk-V7EQTZYR.js → chunk-OCQ2QTFJ.js} +203 -47
  96. package/chunks/{chunk-VBRRNQB7.js → chunk-OPVIKLKK.js} +112 -25
  97. package/chunks/{chunk-2Z5UX4KI.js → chunk-OSSDHJDU.js} +1 -1
  98. package/chunks/{chunk-TTUO4DNG.js → chunk-OXOEOOQU.js} +126 -734
  99. package/chunks/{chunk-4FMG7EDJ.js → chunk-PWYLF7SS.js} +79 -16
  100. package/chunks/chunk-QFEY6OXH.js +45 -0
  101. package/chunks/{chunk-YX4LLZ3D.js → chunk-QPRDXJIC.js} +115 -40
  102. package/chunks/{chunk-7R4DPSRA.js → chunk-R3VWUU2E.js} +1 -1
  103. package/chunks/{chunk-XLIRF7IK.js → chunk-S4N3G4BB.js} +1 -1
  104. package/chunks/{chunk-ARKANCNX.js → chunk-SGPFJMRP.js} +1 -1
  105. package/chunks/{chunk-WTSXKLG5.js → chunk-SUARMD4Q.js} +1 -1
  106. package/chunks/{chunk-PZL23GTM.js → chunk-T3W4SDRB.js} +2 -0
  107. package/chunks/chunk-T4TZQJ7W.js +48 -0
  108. package/chunks/{chunk-K4PZ5F5T.js → chunk-TVYM3Q3J.js} +101 -8
  109. package/chunks/{chunk-4LD5APFL.js → chunk-TYQMGACW.js} +1 -0
  110. package/chunks/{chunk-6OATMEYN.js → chunk-U2LNTX56.js} +12 -4
  111. package/chunks/{chunk-422XAKCK.js → chunk-U2XBPBO3.js} +4 -3
  112. package/chunks/{chunk-LNUXFLLJ.js → chunk-U4FJ26D2.js} +54 -6
  113. package/chunks/{chunk-ZQTZXVHP.js → chunk-U6OPT4H2.js} +4 -18
  114. package/chunks/{chunk-7NFB7LBQ.js → chunk-UE5TZ55T.js} +8 -0
  115. package/chunks/{chunk-CUUXANEQ.js → chunk-URP6O2PP.js} +6 -1
  116. package/chunks/{chunk-GDQQRV43.js → chunk-V2FRLYHN.js} +3 -3
  117. package/chunks/{chunk-WIEO4CWB.js → chunk-VAJS2E2D.js} +1 -1
  118. package/chunks/{chunk-TXY2C3D2.js → chunk-VNN3JNYT.js} +1 -1
  119. package/chunks/{chunk-YHN5SUIJ.js → chunk-W7H223ZZ.js} +1 -1
  120. package/chunks/{chunk-WX6SD4IQ.js → chunk-WEPXQKGP.js} +1 -1
  121. package/chunks/{chunk-KSO42X3Z.js → chunk-X6YQWCIJ.js} +21 -2
  122. package/chunks/{chunk-URU5UEK6.js → chunk-XA7OKDWM.js} +135 -68
  123. package/chunks/{chunk-Q6TUALBE.js → chunk-XAAEDML2.js} +1 -1
  124. package/chunks/{chunk-KKRTYONM.js → chunk-XSPFQQRE.js} +3 -3
  125. package/chunks/{chunk-OATTJGPJ.js → chunk-Y72B36CP.js} +7 -7
  126. package/chunks/{chunk-ZPAHLFZU.js → chunk-Z2LBNX3R.js} +2 -2
  127. package/chunks/{chunk-XXJKGHZV.js → chunk-ZTSDZQZO.js} +131 -4
  128. package/chunks/{computer-use-IYTX45WA.js → computer-use-UIFBH25Y.js} +26 -26
  129. package/chunks/{config-utils-CFT33LTP.js → config-utils-2LHI7JXU.js} +3 -3
  130. package/chunks/{contextCommand-272V77WU.js → contextCommand-VGZHKEH2.js} +28 -28
  131. package/chunks/{create-sub-session-WNX2OQVX.js → create-sub-session-DIJOV6HV.js} +2 -2
  132. package/chunks/{create-sub-session-CBJMQLYP.js → create-sub-session-OFVI4H6I.js} +26 -26
  133. package/chunks/{cron-create-36TIFKRT.js → cron-create-34GVLSW5.js} +4 -4
  134. package/chunks/{cron-delete-OQD3WULU.js → cron-delete-NMVKUL45.js} +4 -4
  135. package/chunks/{cron-list-4533T2FH.js → cron-list-277ZOR7L.js} +4 -4
  136. package/chunks/{daemon-RNGFPMAB.js → daemon-72MEV3TY.js} +361 -84
  137. package/chunks/daemon-status-provider-ZJJ6AOG2.js +75 -0
  138. package/chunks/{de-2VCDRDGU.js → de-56TMDIKS.js} +7 -2
  139. package/chunks/{dist-3V3ZV6ML.js → dist-4W3UGU2A.js} +1 -1
  140. package/chunks/{dist-HNN7DR2L.js → dist-G6QCGO2K.js} +58 -30
  141. package/chunks/{dist-ERCPDVA6.js → dist-ILVRL322.js} +4 -51
  142. package/chunks/{dist-PHEPJLXD.js → dist-KEZ5JWH4.js} +2 -2
  143. package/chunks/{dist-JZE7F6YR.js → dist-LQHDHBPP.js} +1 -1
  144. package/chunks/{dist-MOEC47TR.js → dist-SVHAGOLN.js} +1 -1
  145. package/chunks/{earlyInputCapture-EN4BRREQ.js → earlyInputCapture-NPF4PVUE.js} +27 -27
  146. package/chunks/{edit-OMAF2QDR.js → edit-F7CT6NZH.js} +27 -27
  147. package/chunks/{en-NJCA3TAA.js → en-AXS2N62H.js} +12 -3
  148. package/chunks/{enter-worktree-BBZX52HG.js → enter-worktree-Z4ET3MZL.js} +26 -26
  149. package/chunks/{enterPlanMode-5NNFMBUY.js → enterPlanMode-VYR7T5NX.js} +27 -29
  150. package/chunks/{environment-7TEWMJYN.js → environment-MBTXL57Q.js} +28 -28
  151. package/chunks/{errors-I4VKVX3F.js → errors-HN36J4FR.js} +28 -28
  152. package/chunks/{exit-worktree-FUWRJI33.js → exit-worktree-RU7JYFMF.js} +26 -26
  153. package/chunks/exitPlanMode-LUBAWMZQ.js +390 -0
  154. package/chunks/{fast-path-ZA57TOH4.js → fast-path-RFT3CDNZ.js} +2 -2
  155. package/chunks/{fr-5F3E7WKD.js → fr-ZJPE5OVN.js} +7 -2
  156. package/chunks/{gemini-UOAKVXBG.js → gemini-37NTNKZF.js} +215 -231
  157. package/chunks/{geminiContentGenerator-G6UCE6MW.js → geminiContentGenerator-76HNOYNQ.js} +5 -5
  158. package/chunks/{glob-4GJQ2UFF.js → glob-DWD7JCZE.js} +32 -27
  159. package/chunks/{grep-5QSYXF2E.js → grep-NJRXFV5C.js} +32 -27
  160. package/chunks/{handleAutoUpdate-ULHNWL6R.js → handleAutoUpdate-7GBDXW6U.js} +30 -30
  161. package/chunks/{i18n-CYDUTF6F.js → i18n-MYD5VGED.js} +27 -27
  162. package/chunks/{initializer-NRFKUGIO.js → initializer-4DHPNAZG.js} +32 -32
  163. package/chunks/{installationInfo-WELKRHHE.js → installationInfo-RWOW6BZO.js} +27 -27
  164. package/chunks/{ja-66J6B53L.js → ja-57GG4QSL.js} +7 -2
  165. package/chunks/{keychain-token-storage-AU22CQI6.js → keychain-token-storage-K23CFKGN.js} +2 -2
  166. package/chunks/{list-JVDXEG2E.js → list-MMCNNHE7.js} +34 -34
  167. package/chunks/{loadedSettingsAdapter-WAM4VUTG.js → loadedSettingsAdapter-UK4JWPYU.js} +31 -31
  168. package/chunks/{loop-wakeup-MVUKDVCP.js → loop-wakeup-KCLY4XQM.js} +5 -5
  169. package/chunks/{ls-RXNIAQDE.js → ls-UNI4LAJ3.js} +4 -4
  170. package/chunks/{lsp-HB5LM5IL.js → lsp-HPACPJAN.js} +2 -2
  171. package/chunks/{mcp-YHOZN3ZM.js → mcp-AFCVA4UV.js} +31 -31
  172. package/chunks/{monitor-R7XZPJHQ.js → monitor-RK637BNO.js} +28 -27
  173. package/chunks/nonInteractiveCli-OUGWLHNV.js +129 -0
  174. package/chunks/{notebook-edit-6RNKE2L2.js → notebook-edit-LY2X3CMF.js} +27 -27
  175. package/chunks/{openaiContentGenerator-XNS5S64I.js → openaiContentGenerator-MDYDW7IA.js} +14 -14
  176. package/chunks/{pidfile-XE4RRR2P.js → pidfile-2NUYRLKB.js} +27 -27
  177. package/chunks/processUtils-7QH3VBVN.js +29 -0
  178. package/chunks/{pt-TFZO5Y6T.js → pt-MCGZ3RZ4.js} +7 -2
  179. package/chunks/{qwenContentGenerator-APDPJ3VN.js → qwenContentGenerator-3HT4TVDL.js} +28 -28
  180. package/chunks/{qwenOAuth2-LEYOU7RU.js → qwenOAuth2-3A4TJVZT.js} +5 -5
  181. package/chunks/{read-file-XSUWXSR7.js → read-file-NE4FREFR.js} +10 -10
  182. package/chunks/{read-mcp-resource-6LRTZKXI.js → read-mcp-resource-C6NT52T6.js} +2 -2
  183. package/chunks/{record-artifact-PMDTY4OS.js → record-artifact-ENCU7QCL.js} +2 -2
  184. package/chunks/{ripGrep-APB3CDMU.js → ripGrep-DBLXWQCJ.js} +26 -26
  185. package/chunks/{ru-4L4LFHIT.js → ru-GA3NZW5Q.js} +7 -2
  186. package/chunks/{run-qwen-serve-NWTGPERT.js → run-qwen-serve-3NOCI6IL.js} +63 -39
  187. package/chunks/{runtime-EIO3NQKR.js → runtime-ZI7DSZSS.js} +35 -35
  188. package/chunks/{scheduler-JJDZBDRN.js → scheduler-SOVEP5K7.js} +26 -26
  189. package/chunks/{send-message-SR4WSXP2.js → send-message-5IFPZTPE.js} +3 -3
  190. package/chunks/{serve-WTIPB3EI.js → serve-DB6OCXIA.js} +31 -31
  191. package/chunks/{server-NJPHQHLH.js → server-LDY4YVU4.js} +2257 -648
  192. package/chunks/{session-O4AO7FTS.js → session-D6OG5SKX.js} +99 -72
  193. package/chunks/{settings-HQNDK7TG.js → settings-L52ZV5LO.js} +30 -30
  194. package/chunks/{shell-UIXM6PWG.js → shell-IU27OY3Q.js} +28 -26
  195. package/chunks/{skill-3XMB4ULV.js → skill-BSOJT7LE.js} +12 -12
  196. package/chunks/{spawnChannel-3R632QRM.js → spawnChannel-HQAM25DD.js} +28 -29
  197. package/chunks/{src-USZKPUOC.js → src-7ZBIMTJZ.js} +130 -51
  198. package/chunks/{standalone-update-L5XW3D7K.js → standalone-update-77457VVK.js} +28 -28
  199. package/chunks/{startInteractiveUI-CPZOL2WB.js → startInteractiveUI-S7WC6EZG.js} +2310 -1835
  200. package/chunks/{syntheticOutput-YKFNUQZD.js → syntheticOutput-ULOVVLY4.js} +3 -3
  201. package/chunks/{task-create-NUFOHU53.js → task-create-V2DCDSET.js} +7 -7
  202. package/chunks/{task-list-Z2IKQY3S.js → task-list-DPL5ZN55.js} +5 -5
  203. package/chunks/{task-stop-KQFIVQTJ.js → task-stop-CPEQWOT6.js} +2 -2
  204. package/chunks/{task-update-HKADXSTD.js → task-update-ZR45M5Q7.js} +7 -7
  205. package/chunks/{team-create-XXPRF3IQ.js → team-create-CO7HSUON.js} +26 -26
  206. package/chunks/{team-delete-SDNTGZLG.js → team-delete-HIWXCWJU.js} +5 -5
  207. package/chunks/{team-plan-approval-EOTTKHDW.js → team-plan-approval-QDZF5YZY.js} +26 -26
  208. package/chunks/{theme-manager-P6UITO2L.js → theme-manager-UTUT3I4P.js} +27 -27
  209. package/chunks/todoWrite-HK6B3RHJ.js +358 -0
  210. package/chunks/{tool-search-DDNGK2LR.js → tool-search-2UUORA35.js} +11 -11
  211. package/chunks/{total-session-admission-PL5N7DNY.js → total-session-admission-NTWG6G3F.js} +32 -34
  212. package/chunks/{trustedFolders-C5LMF3UR.js → trustedFolders-YF37ZCN5.js} +27 -27
  213. package/chunks/update-relaunch-QFNHPMZZ.js +87 -0
  214. package/chunks/{updateCheck-QTVVISH7.js → updateCheck-B6O42VMD.js} +30 -28
  215. package/chunks/{validateNonInterActiveAuth-RY4RKBQG.js → validateNonInterActiveAuth-SCIWJ4CX.js} +65 -65
  216. package/chunks/{version-U45RYOSD.js → version-7DA6LAI3.js} +1 -1
  217. package/chunks/{web-fetch-ZSPR3PRR.js → web-fetch-B62SJXM2.js} +5 -6
  218. package/chunks/{workflow-TCIAQYOA.js → workflow-Q5WG4THP.js} +27 -27
  219. package/chunks/{workspace-providers-status-I3G2HYLY.js → workspace-providers-status-WWLAGWQW.js} +34 -34
  220. package/chunks/{workspace-registration-store-IH5GLZ6Y.js → workspace-registration-store-BVYQVY2H.js} +1 -1
  221. package/chunks/{workspace-registry-QEKBELIX.js → workspace-registry-OD7ACADD.js} +32 -34
  222. package/chunks/{workspace-service-ORKHGLP3.js → workspace-service-4LYJWS63.js} +37 -38
  223. package/chunks/{workspace-skills-status-D7QCNDYY.js → workspace-skills-status-P2AQLZZS.js} +32 -32
  224. package/chunks/{write-file-JGRQR5VM.js → write-file-TEPGXNM3.js} +60 -27
  225. package/chunks/{zh-FSAH32JB.js → zh-E34DZ2S3.js} +12 -3
  226. package/chunks/{zh-TW-D2YIE2LO.js → zh-TW-PEI2ZWUR.js} +12 -3
  227. package/cli-entry.js +92 -8
  228. package/cli.js +11 -11
  229. package/locales/ca.js +12 -2
  230. package/locales/de.js +12 -2
  231. package/locales/en.js +20 -5
  232. package/locales/fr.js +12 -2
  233. package/locales/ja.js +12 -2
  234. package/locales/pt.js +12 -2
  235. package/locales/ru.js +12 -2
  236. package/locales/zh-TW.js +19 -3
  237. package/locales/zh.js +19 -3
  238. package/package.json +3 -3
  239. package/web-shell/assets/{arc-CUeDlxvE.js → arc-Dh-N5oEG.js} +1 -1
  240. package/web-shell/assets/{architectureDiagram-3BPJPVTR-PiUszkQA.js → architectureDiagram-3BPJPVTR-DBOQgtfF.js} +1 -1
  241. package/web-shell/assets/{blockDiagram-GPEHLZMM-s2wYSO7e.js → blockDiagram-GPEHLZMM-Dyxbuyju.js} +1 -1
  242. package/web-shell/assets/{c4Diagram-AAUBKEIU-DyLxZoz9.js → c4Diagram-AAUBKEIU-DCJR5HPT.js} +1 -1
  243. package/web-shell/assets/channel-DY0fkcKT.js +1 -0
  244. package/web-shell/assets/{chunk-2J33WTMH-Dsdai7Tk.js → chunk-2J33WTMH-BkMUcy3O.js} +1 -1
  245. package/web-shell/assets/{chunk-4BX2VUAB-DEosOjV7.js → chunk-4BX2VUAB-BSm4pLQk.js} +1 -1
  246. package/web-shell/assets/{chunk-55IACEB6-sNsRLTXf.js → chunk-55IACEB6-CuRr-XgW.js} +1 -1
  247. package/web-shell/assets/{chunk-727SXJPM-DkRNZzmh.js → chunk-727SXJPM-CLv7-w3t.js} +1 -1
  248. package/web-shell/assets/{chunk-AQP2D5EJ-BrsRNpzd.js → chunk-AQP2D5EJ-Cz_n3-JW.js} +1 -1
  249. package/web-shell/assets/{chunk-FMBD7UC4-CI039lpl.js → chunk-FMBD7UC4-CFT_62Hq.js} +1 -1
  250. package/web-shell/assets/{chunk-ND2GUHAM-M-pkeIfu.js → chunk-ND2GUHAM-DWz6DOZ6.js} +1 -1
  251. package/web-shell/assets/{chunk-QZHKN3VN-C4ckGNbH.js → chunk-QZHKN3VN-C-mRhUzw.js} +1 -1
  252. package/web-shell/assets/classDiagram-4FO5ZUOK-DBvJ6PZo.js +1 -0
  253. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-DBvJ6PZo.js +1 -0
  254. package/web-shell/assets/{cose-bilkent-S5V4N54A-BciKUAFq.js → cose-bilkent-S5V4N54A-BqCZS3i1.js} +1 -1
  255. package/web-shell/assets/{dagre-BM42HDAG-C1nTSgU6.js → dagre-BM42HDAG-BGasdP8i.js} +1 -1
  256. package/web-shell/assets/{diagram-2AECGRRQ-BDPNWr1m.js → diagram-2AECGRRQ-BSyLDkMy.js} +1 -1
  257. package/web-shell/assets/{diagram-5GNKFQAL-CNFhTszL.js → diagram-5GNKFQAL-CM-ZJxWC.js} +1 -1
  258. package/web-shell/assets/{diagram-KO2AKTUF-CjPa4p5a.js → diagram-KO2AKTUF-wJdzt_C5.js} +1 -1
  259. package/web-shell/assets/{diagram-LMA3HP47-ZzPykSyG.js → diagram-LMA3HP47-DiH2fhpL.js} +1 -1
  260. package/web-shell/assets/{diagram-OG6HWLK6-0UVtZ9A4.js → diagram-OG6HWLK6-BZ9z1ZBl.js} +1 -1
  261. package/web-shell/assets/{erDiagram-TEJ5UH35-CajDZCat.js → erDiagram-TEJ5UH35-BsyWDziR.js} +1 -1
  262. package/web-shell/assets/{flowDiagram-I6XJVG4X-BRuFBIvL.js → flowDiagram-I6XJVG4X-CzdkxIrq.js} +1 -1
  263. package/web-shell/assets/{ganttDiagram-6RSMTGT7-BevGmJqG.js → ganttDiagram-6RSMTGT7-javIv2r2.js} +1 -1
  264. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-DvPMpBMb.js → gitGraphDiagram-PVQCEYII-CjHstylC.js} +1 -1
  265. package/web-shell/assets/{index-DzHwQkQq.js → index-BnJGxpah.js} +1 -1
  266. package/web-shell/assets/index-DhXB9nTa.js +1161 -0
  267. package/web-shell/assets/index-vYHgZ7bL.css +5 -0
  268. package/web-shell/assets/{infoDiagram-5YYISTIA-Oixn7tA9.js → infoDiagram-5YYISTIA-yXuQsomo.js} +1 -1
  269. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-BgKpeg-j.js → ishikawaDiagram-YF4QCWOH-a85JhE6F.js} +1 -1
  270. package/web-shell/assets/{journeyDiagram-JHISSGLW-74mwxIaA.js → journeyDiagram-JHISSGLW-Dak_4BVj.js} +1 -1
  271. package/web-shell/assets/{kanban-definition-UN3LZRKU-D4D6cEqA.js → kanban-definition-UN3LZRKU-COA-LuCV.js} +1 -1
  272. package/web-shell/assets/{linear-atZRE_L2.js → linear-DNAAAQWq.js} +1 -1
  273. package/web-shell/assets/{mermaid.core-KKudX-JC.js → mermaid.core-7Ff3aIUD.js} +5 -5
  274. package/web-shell/assets/{mindmap-definition-RKZ34NQL-CMCej9yG.js → mindmap-definition-RKZ34NQL-_rCOIODU.js} +1 -1
  275. package/web-shell/assets/{pieDiagram-4H26LBE5-nhx40X7q.js → pieDiagram-4H26LBE5-C9QCQ8EW.js} +1 -1
  276. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-CUmVcN3M.js → quadrantDiagram-W4KKPZXB-CsaE4FA8.js} +1 -1
  277. package/web-shell/assets/{requirementDiagram-4Y6WPE33-C_vyEwyy.js → requirementDiagram-4Y6WPE33-tV78naTg.js} +1 -1
  278. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-DU6G4VWR.js → sankeyDiagram-5OEKKPKP-Dk3Rw7BZ.js} +1 -1
  279. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DdeRR_KJ.js → sequenceDiagram-3UESZ5HK-BGsAWcMX.js} +1 -1
  280. package/web-shell/assets/{stateDiagram-AJRCARHV-C6iCI8ps.js → stateDiagram-AJRCARHV-zSxdtdoB.js} +1 -1
  281. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-vLEEtDpO.js +1 -0
  282. package/web-shell/assets/{timeline-definition-PNZ67QCA-B_Ea8Cb7.js → timeline-definition-PNZ67QCA-j0BQh9Go.js} +1 -1
  283. package/web-shell/assets/{vennDiagram-CIIHVFJN-BPUVZEJA.js → vennDiagram-CIIHVFJN-CRaUFFIu.js} +1 -1
  284. package/web-shell/assets/{wardley-L42UT6IY-BWEj0lKY.js → wardley-L42UT6IY-D7Py_ofm.js} +1 -1
  285. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BvDsdIQw.js → wardleyDiagram-YWT4CUSO-BrDIAZcp.js} +1 -1
  286. package/web-shell/assets/{xychartDiagram-2RQKCTM6-crz0QhF_.js → xychartDiagram-2RQKCTM6-Cecdw-w2.js} +1 -1
  287. package/web-shell/index.html +2 -2
  288. package/chunks/channel-worker-group-K7QKH6IG.js +0 -13
  289. package/chunks/chunk-2HRYPZT5.js +0 -25
  290. package/chunks/chunk-B7NUUEXC.js +0 -311
  291. package/chunks/chunk-CARU2RR2.js +0 -24
  292. package/chunks/chunk-GYTKQYDB.js +0 -23
  293. package/chunks/chunk-LQU7EVFA.js +0 -30
  294. package/chunks/chunk-OCPBI7J5.js +0 -18
  295. package/chunks/chunk-OJAMDVF5.js +0 -66
  296. package/chunks/chunk-QAW7PIHT.js +0 -168
  297. package/chunks/chunk-TEGEBB2I.js +0 -122
  298. package/chunks/daemon-status-provider-L4STG5VO.js +0 -76
  299. package/chunks/exitPlanMode-IHCJ5EEI.js +0 -909
  300. package/chunks/nonInteractiveCli-NSOB6D74.js +0 -129
  301. package/chunks/todoWrite-YNXB27GB.js +0 -531
  302. package/web-shell/assets/channel-DkuJJ0qd.js +0 -1
  303. package/web-shell/assets/classDiagram-4FO5ZUOK-CwqHc0TB.js +0 -1
  304. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CwqHc0TB.js +0 -1
  305. package/web-shell/assets/index-Cnvv4VcI.css +0 -5
  306. package/web-shell/assets/index-D1Uyklxa.js +0 -1088
  307. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-C0_6nR6C.js +0 -1
@@ -4,9 +4,10 @@ import {
4
4
  LOAD_REPLAY_BULK_MODE,
5
5
  LOAD_REPLAY_META_KEY,
6
6
  LOAD_REPLAY_MODE_META_KEY,
7
+ LOAD_REPLAY_PAGE_SIZE_META_KEY,
7
8
  LOAD_REPLAY_VERSION,
8
9
  MID_TURN_QUEUE_DRAIN_METHOD
9
- } from "./chunk-PZL23GTM.js";
10
+ } from "./chunk-T3W4SDRB.js";
10
11
  import {
11
12
  DEFAULT_RING_SIZE,
12
13
  EVENT_SCHEMA_VERSION,
@@ -16,9 +17,6 @@ import {
16
17
  import {
17
18
  normalizeCompactedReplayMaxBytes
18
19
  } from "./chunk-COH43MRJ.js";
19
- import {
20
- MCP_RESTART_SERVER_DEADLINE_MS
21
- } from "./chunk-OCPBI7J5.js";
22
20
  import {
23
21
  BranchWhilePromptActiveError,
24
22
  CancelSentinelCollisionError,
@@ -28,6 +26,7 @@ import {
28
26
  InvalidRewindTargetError,
29
27
  InvalidSessionMetadataError,
30
28
  InvalidSessionScopeError,
29
+ MCP_RESTART_SERVER_DEADLINE_MS,
31
30
  PermissionForbiddenError,
32
31
  PromptQueueFullError,
33
32
  RestoreInProgressError,
@@ -38,10 +37,10 @@ import {
38
37
  SessionShellDisabledError,
39
38
  WorkspaceMismatchError,
40
39
  isNotCurrentlyGeneratingCancelError
41
- } from "./chunk-KSO42X3Z.js";
40
+ } from "./chunk-X6YQWCIJ.js";
42
41
  import {
43
42
  defaultSpawnChannelFactory
44
- } from "./chunk-UFOKA4PR.js";
43
+ } from "./chunk-O2K6BLPZ.js";
45
44
  import {
46
45
  BridgeChannelClosedError,
47
46
  BridgeTimeoutError,
@@ -50,7 +49,7 @@ import {
50
49
  STATUS_SCHEMA_VERSION,
51
50
  createIdleWorkspaceExtensionsStatus,
52
51
  createIdleWorkspaceHooksStatus
53
- } from "./chunk-CUUXANEQ.js";
52
+ } from "./chunk-URP6O2PP.js";
54
53
  import {
55
54
  canonicalizeWorkspace
56
55
  } from "./chunk-W7FJ3N32.js";
@@ -70,11 +69,11 @@ import {
70
69
  metadataBudgetBytes,
71
70
  normalizeSnapshotPayload,
72
71
  stableSessionArtifactId
73
- } from "./chunk-K7CRWKOE.js";
72
+ } from "./chunk-3YJZ6WNY.js";
74
73
  import {
75
74
  DAEMON_TRACEPARENT_META_KEY,
76
75
  DAEMON_TRACESTATE_META_KEY
77
- } from "./chunk-P6LART6G.js";
76
+ } from "./chunk-66IT3EY2.js";
78
77
  import {
79
78
  init_esbuild_shims
80
79
  } from "./chunk-5O2XNYP6.js";
@@ -102,6 +101,23 @@ var LATEST_WINS_UPDATES = /* @__PURE__ */ new Set([
102
101
  "current_mode_update"
103
102
  ]);
104
103
  var REPLAY_SEGMENT_COMPACT_THRESHOLD = 64;
104
+ function replayRecordId(event) {
105
+ if (event.type !== "session_update") return void 0;
106
+ const data = event.data;
107
+ if (!data || typeof data !== "object" || Array.isArray(data))
108
+ return void 0;
109
+ const update = data["update"];
110
+ if (!update || typeof update !== "object" || Array.isArray(update)) {
111
+ return void 0;
112
+ }
113
+ const meta = update["_meta"];
114
+ if (!meta || typeof meta !== "object" || Array.isArray(meta)) {
115
+ return void 0;
116
+ }
117
+ const recordId = meta["qwen.session.recordId"];
118
+ return typeof recordId === "string" ? recordId : void 0;
119
+ }
120
+ __name(replayRecordId, "replayRecordId");
105
121
  var TurnBoundaryCompactionEngine = class {
106
122
  static {
107
123
  __name(this, "TurnBoundaryCompactionEngine");
@@ -169,11 +185,29 @@ var TurnBoundaryCompactionEngine = class {
169
185
  seedReplayEvents(events) {
170
186
  if (this.closed) return;
171
187
  this.resetReplayWindow();
188
+ let recordEvents = [];
189
+ let recordId;
190
+ const flushRecord = /* @__PURE__ */ __name(() => {
191
+ this.addReplaySegment(recordEvents, 0);
192
+ recordEvents = [];
193
+ recordId = void 0;
194
+ }, "flushRecord");
172
195
  for (const event of events) {
173
196
  this.recordLastEventId(event);
174
197
  if (TRANSIENT_TYPES.has(event.type)) continue;
175
- this.addReplaySegment([event], 0);
198
+ const nextRecordId = replayRecordId(event);
199
+ if (nextRecordId === void 0) {
200
+ flushRecord();
201
+ this.addReplaySegment([event], 0);
202
+ continue;
203
+ }
204
+ if (recordId !== void 0 && recordId !== nextRecordId) {
205
+ flushRecord();
206
+ }
207
+ recordId = nextRecordId;
208
+ recordEvents.push(event);
176
209
  }
210
+ flushRecord();
177
211
  this.liveJournal = [];
178
212
  this.slots = [];
179
213
  this.toolSlotIndex.clear();
@@ -473,6 +507,30 @@ function mergeToolCallEvent(existing, incoming) {
473
507
  }
474
508
  __name(mergeToolCallEvent, "mergeToolCallEvent");
475
509
 
510
+ // packages/acp-bridge/src/session-source.ts
511
+ init_esbuild_shims();
512
+ var SESSION_SOURCE_TYPE_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
513
+ var MAX_SESSION_SOURCE_ID_LENGTH = 256;
514
+ function parseSessionSource(sourceType, sourceId) {
515
+ if (sourceType === void 0 && sourceId === void 0) return {};
516
+ if (typeof sourceType !== "string" || !SESSION_SOURCE_TYPE_PATTERN.test(sourceType)) {
517
+ return {
518
+ error: "`sourceType` must match [a-z][a-z0-9_-]{0,63} when provided"
519
+ };
520
+ }
521
+ if (sourceId === void 0) return { sourceType };
522
+ if (typeof sourceId !== "string" || sourceId.length === 0 || sourceId.length > MAX_SESSION_SOURCE_ID_LENGTH || [...sourceId].some((character) => {
523
+ const code = character.charCodeAt(0);
524
+ return code <= 31 || code === 127;
525
+ })) {
526
+ return {
527
+ error: `\`sourceId\` must be a non-empty string of at most ${MAX_SESSION_SOURCE_ID_LENGTH} characters without control characters`
528
+ };
529
+ }
530
+ return { sourceType, sourceId };
531
+ }
532
+ __name(parseSessionSource, "parseSessionSource");
533
+
476
534
  // packages/acp-bridge/src/internal/stderrLine.ts
477
535
  init_esbuild_shims();
478
536
  function writeStderrLine(message) {
@@ -545,8 +603,8 @@ var MultiClientPermissionMediator = class {
545
603
  * an identical line (the unanimity condition is the NORMAL
546
604
  * operating mode for M=2, not a rare edge); a busy session with
547
605
  * many tool calls would produce dozens of duplicate stderr lines
548
- * within seconds. One emit per mediator (= per daemon lifetime
549
- * since the bridge constructs one) is enough to make the
606
+ * within seconds. One emit per mediator (= per bridge/runtime lifetime
607
+ * since each bridge constructs one) is enough to make the
550
608
  * configuration visible without spam.
551
609
  */
552
610
  unanimityBreadcrumbEmitted = false;
@@ -605,6 +663,7 @@ var MultiClientPermissionMediator = class {
605
663
  const pending = {
606
664
  requestId: record.requestId,
607
665
  sessionId: record.sessionId,
666
+ promptId: record.promptId,
608
667
  policy,
609
668
  originatorClientId: record.originatorClientId,
610
669
  allowedOptionIds: record.allowedOptionIds,
@@ -678,6 +737,7 @@ var MultiClientPermissionMediator = class {
678
737
  const optionId = prior.resolution.kind === "option" ? prior.resolution.optionId : CANCEL_VOTE_SENTINEL;
679
738
  this.safeEmit(prior.sessionId, {
680
739
  type: "permission_already_resolved",
740
+ ...prior.promptId ? { promptId: prior.promptId } : {},
681
741
  data: {
682
742
  requestId: prior.requestId,
683
743
  sessionId: prior.sessionId,
@@ -843,6 +903,7 @@ var MultiClientPermissionMediator = class {
843
903
  );
844
904
  this.safeEmit(pending.sessionId, {
845
905
  type: "permission_partial_vote",
906
+ ...pending.promptId ? { promptId: pending.promptId } : {},
846
907
  data: {
847
908
  requestId: pending.requestId,
848
909
  sessionId: pending.sessionId,
@@ -916,6 +977,7 @@ var MultiClientPermissionMediator = class {
916
977
  );
917
978
  this.safeEmit(pending.sessionId, {
918
979
  type: "permission_forbidden",
980
+ ...pending.promptId ? { promptId: pending.promptId } : {},
919
981
  data: {
920
982
  requestId: pending.requestId,
921
983
  sessionId: pending.sessionId,
@@ -1038,6 +1100,7 @@ var MultiClientPermissionMediator = class {
1038
1100
  this.pending.delete(pending.requestId);
1039
1101
  this.safeEmit(pending.sessionId, {
1040
1102
  type: "permission_resolved",
1103
+ ...pending.promptId ? { promptId: pending.promptId } : {},
1041
1104
  data: {
1042
1105
  requestId: pending.requestId,
1043
1106
  outcome: this.toAcpOutcome(resolution),
@@ -1061,6 +1124,7 @@ var MultiClientPermissionMediator = class {
1061
1124
  this.rememberResolved({
1062
1125
  requestId: pending.requestId,
1063
1126
  sessionId: pending.sessionId,
1127
+ promptId: pending.promptId,
1064
1128
  resolution,
1065
1129
  resolverClientId
1066
1130
  });
@@ -1159,6 +1223,7 @@ var MultiClientPermissionMediator = class {
1159
1223
  return {
1160
1224
  requestId: pending.requestId,
1161
1225
  sessionId: pending.sessionId,
1226
+ ...pending.promptId ? { promptId: pending.promptId } : {},
1162
1227
  originatorClientId: pending.originatorClientId,
1163
1228
  allowedOptionIds: pending.allowedOptionIds,
1164
1229
  issuedAtMs: pending.issuedAtMs
@@ -1392,7 +1457,7 @@ function sliceLineRange(content, startLine, endLine) {
1392
1457
  }
1393
1458
  __name(sliceLineRange, "sliceLineRange");
1394
1459
  var BridgeClient = class {
1395
- constructor(resolveEntry, resolvePendingRestoreEvents, mediator, permissionTimeoutMs, maxPendingPerSession, fileSystem, onModelPromoted, onModePromoted, clientMcpSender, ownsSession = () => true, onTokenUsage, onCreateSubSession) {
1460
+ constructor(resolveEntry, resolvePendingRestoreEvents, mediator, permissionTimeoutMs, maxPendingPerSession, fileSystem, onModelPromoted, onModePromoted, clientMcpSender, ownsSession = () => true, onTokenUsage, onCreateSubSession, onGenerationEvent) {
1396
1461
  this.resolveEntry = resolveEntry;
1397
1462
  this.resolvePendingRestoreEvents = resolvePendingRestoreEvents;
1398
1463
  this.mediator = mediator;
@@ -1405,6 +1470,7 @@ var BridgeClient = class {
1405
1470
  this.ownsSession = ownsSession;
1406
1471
  this.onTokenUsage = onTokenUsage;
1407
1472
  this.onCreateSubSession = onCreateSubSession;
1473
+ this.onGenerationEvent = onGenerationEvent;
1408
1474
  }
1409
1475
  static {
1410
1476
  __name(this, "BridgeClient");
@@ -1429,6 +1495,7 @@ var BridgeClient = class {
1429
1495
  }
1430
1496
  const published = entry.events.publish({
1431
1497
  type: "permission_request",
1498
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
1432
1499
  data: {
1433
1500
  requestId,
1434
1501
  sessionId: entry.sessionId,
@@ -1456,6 +1523,7 @@ var BridgeClient = class {
1456
1523
  const record = {
1457
1524
  requestId,
1458
1525
  sessionId: entry.sessionId,
1526
+ promptId: entry.activePromptId,
1459
1527
  originatorClientId: entry.activePromptOriginatorClientId,
1460
1528
  allowedOptionIds,
1461
1529
  issuedAtMs: Date.now()
@@ -1489,13 +1557,21 @@ var BridgeClient = class {
1489
1557
  } catch {
1490
1558
  }
1491
1559
  if (entry && prepared.artifacts.length > 0) {
1492
- await this.upsertAndPublishArtifacts(entry, prepared.artifacts, {
1493
- trustedPublisher: prepared.trustedPublisher
1494
- });
1560
+ await this.upsertAndPublishArtifacts(
1561
+ entry,
1562
+ prepared.artifacts,
1563
+ {
1564
+ trustedPublisher: prepared.trustedPublisher
1565
+ },
1566
+ prepared.turn
1567
+ );
1495
1568
  }
1496
1569
  }
1497
1570
  prepareSessionUpdateFrames(params, entry) {
1498
- const originator = entry?.activePromptOriginatorClientId ? { originatorClientId: entry.activePromptOriginatorClientId } : {};
1571
+ const turn = {
1572
+ ...entry?.activePromptId ? { promptId: entry.activePromptId } : {},
1573
+ ...entry?.activePromptOriginatorClientId ? { originatorClientId: entry.activePromptOriginatorClientId } : {}
1574
+ };
1499
1575
  const frames = [];
1500
1576
  const a2ui = extractA2uiToolUpdate(params);
1501
1577
  if (a2ui) {
@@ -1514,7 +1590,7 @@ var BridgeClient = class {
1514
1590
  _meta: { serverTimestamp: Date.now(), source: "a2ui-bridge" }
1515
1591
  }
1516
1592
  },
1517
- ...originator
1593
+ ...turn
1518
1594
  });
1519
1595
  }
1520
1596
  params = a2ui.sanitizedParams;
@@ -1532,13 +1608,14 @@ var BridgeClient = class {
1532
1608
  frames.push({
1533
1609
  type: "session_update",
1534
1610
  data: publishParams,
1535
- ...originator,
1611
+ ...turn,
1536
1612
  ...serverTimestamp !== void 0 ? { _meta: { serverTimestamp } } : {}
1537
1613
  });
1538
1614
  return {
1539
1615
  frames,
1540
1616
  artifacts,
1541
- trustedPublisher: isTrustedArtifactToolUpdate(params, updateMeta)
1617
+ trustedPublisher: isTrustedArtifactToolUpdate(params, updateMeta),
1618
+ turn
1542
1619
  };
1543
1620
  }
1544
1621
  async seedSessionUpdates(entry, updates, options = {}) {
@@ -1553,15 +1630,21 @@ var BridgeClient = class {
1553
1630
  if (options.ingestArtifacts !== false && prepared.artifacts.length > 0) {
1554
1631
  artifactBatches.push({
1555
1632
  artifacts: prepared.artifacts,
1556
- trustedPublisher: prepared.trustedPublisher
1633
+ trustedPublisher: prepared.trustedPublisher,
1634
+ turn: prepared.turn
1557
1635
  });
1558
1636
  }
1559
1637
  }
1560
1638
  entry.events.seedReplayEvents(frames);
1561
1639
  for (const batch of artifactBatches) {
1562
- await this.upsertAndPublishArtifacts(entry, batch.artifacts, {
1563
- trustedPublisher: batch.trustedPublisher
1564
- });
1640
+ await this.upsertAndPublishArtifacts(
1641
+ entry,
1642
+ batch.artifacts,
1643
+ {
1644
+ trustedPublisher: batch.trustedPublisher
1645
+ },
1646
+ batch.turn
1647
+ );
1565
1648
  }
1566
1649
  }
1567
1650
  /**
@@ -1684,6 +1767,7 @@ var BridgeClient = class {
1684
1767
  for (const [originatorClientId, texts] of byOriginator) {
1685
1768
  const published = entry.events.publish({
1686
1769
  type: MID_TURN_MESSAGE_INJECTED_EVENT,
1770
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
1687
1771
  data: { sessionId: entry.sessionId, messages: texts },
1688
1772
  ...originatorClientId ? { originatorClientId } : {}
1689
1773
  });
@@ -1816,6 +1900,51 @@ var BridgeClient = class {
1816
1900
  * forward-compat.
1817
1901
  */
1818
1902
  async extNotification(method, params) {
1903
+ if (method === "qwen/notify/session/generation/event") {
1904
+ const sessionId2 = params["sessionId"];
1905
+ const requestId = params["requestId"];
1906
+ const event = params["event"];
1907
+ if (params["v"] !== 1 || typeof sessionId2 !== "string" || typeof requestId !== "string" || !event || typeof event !== "object" || Array.isArray(event)) {
1908
+ return;
1909
+ }
1910
+ const record = event;
1911
+ if (record["type"] === "started") {
1912
+ const model = record["model"];
1913
+ const modelSource = record["modelSource"];
1914
+ if (typeof model !== "string" || modelSource !== "fast" && modelSource !== "main") {
1915
+ return;
1916
+ }
1917
+ this.onGenerationEvent?.(sessionId2, {
1918
+ type: "started",
1919
+ requestId,
1920
+ model,
1921
+ modelSource
1922
+ });
1923
+ return;
1924
+ }
1925
+ if (record["type"] === "thinking") {
1926
+ this.onGenerationEvent?.(sessionId2, {
1927
+ type: "thinking",
1928
+ requestId
1929
+ });
1930
+ return;
1931
+ }
1932
+ if (record["type"] === "delta") {
1933
+ const seq = record["seq"];
1934
+ const text = record["text"];
1935
+ if (typeof seq !== "number" || !Number.isSafeInteger(seq) || seq < 0 || typeof text !== "string" || text.length === 0) {
1936
+ return;
1937
+ }
1938
+ this.onGenerationEvent?.(sessionId2, {
1939
+ type: "delta",
1940
+ requestId,
1941
+ seq,
1942
+ text
1943
+ });
1944
+ return;
1945
+ }
1946
+ return;
1947
+ }
1819
1948
  if (method === "qwen/notify/session/model-update") {
1820
1949
  this.handleInSessionModelUpdate(params);
1821
1950
  return;
@@ -1890,7 +2019,7 @@ var BridgeClient = class {
1890
2019
  const { v: _v2, sessionId: _sid2, ...rest2 } = params;
1891
2020
  void _v2;
1892
2021
  void _sid2;
1893
- this.publishExtNotification(sessionId2, "terminal_sequence", rest2);
2022
+ this.publishExtNotification(sessionId2, "terminal_sequence", rest2, true);
1894
2023
  return;
1895
2024
  }
1896
2025
  if (method === "qwen/notify/session/artifact-event") {
@@ -1953,12 +2082,16 @@ var BridgeClient = class {
1953
2082
  toolCallId
1954
2083
  })
1955
2084
  );
1956
- await this.upsertAndPublishArtifacts(entry, artifacts);
2085
+ const turn = {
2086
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
2087
+ ...entry.activePromptOriginatorClientId ? { originatorClientId: entry.activePromptOriginatorClientId } : {}
2088
+ };
2089
+ await this.upsertAndPublishArtifacts(entry, artifacts, void 0, turn);
1957
2090
  }
1958
- async upsertAndPublishArtifacts(entry, artifacts, options) {
2091
+ async upsertAndPublishArtifacts(entry, artifacts, options, turn = {}) {
1959
2092
  try {
1960
2093
  const result = await entry.artifacts.upsertMany(artifacts, options);
1961
- this.publishArtifactChanges(entry, result.changes);
2094
+ this.publishArtifactChanges(entry, result.changes, turn);
1962
2095
  } catch (error) {
1963
2096
  writeStderrLine(
1964
2097
  `[artifacts] session=${entry.sessionId} action=dropped reason=${JSON.stringify(
@@ -1967,20 +2100,21 @@ var BridgeClient = class {
1967
2100
  );
1968
2101
  }
1969
2102
  }
1970
- publishArtifactChanges(entry, changes) {
2103
+ publishArtifactChanges(entry, changes, turn) {
1971
2104
  for (const change of changes) {
1972
2105
  entry.events.publish({
1973
2106
  type: "artifact_changed",
1974
2107
  data: { sessionId: entry.sessionId, change },
1975
- ...entry.activePromptOriginatorClientId ? { originatorClientId: entry.activePromptOriginatorClientId } : {}
2108
+ ...turn
1976
2109
  });
1977
2110
  }
1978
2111
  }
1979
- publishExtNotification(sessionId, type, data) {
2112
+ publishExtNotification(sessionId, type, data, turnScoped = false) {
1980
2113
  const entry = this.resolveEntry(sessionId);
1981
2114
  const frame = {
1982
2115
  type,
1983
2116
  data,
2117
+ ...turnScoped && entry?.activePromptId ? { promptId: entry.activePromptId } : {},
1984
2118
  ...entry?.activePromptOriginatorClientId ? { originatorClientId: entry.activePromptOriginatorClientId } : {}
1985
2119
  };
1986
2120
  if (entry) {
@@ -2025,6 +2159,7 @@ var BridgeClient = class {
2025
2159
  } else {
2026
2160
  entry.events.publish({
2027
2161
  type: "model_switched",
2162
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
2028
2163
  data: { sessionId, modelId: currentModelId },
2029
2164
  ...entry.activePromptOriginatorClientId ? { originatorClientId: entry.activePromptOriginatorClientId } : {}
2030
2165
  });
@@ -2078,6 +2213,7 @@ var BridgeClient = class {
2078
2213
  } else {
2079
2214
  entry.events.publish({
2080
2215
  type: "approval_mode_changed",
2216
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
2081
2217
  data: {
2082
2218
  sessionId,
2083
2219
  previous: "default",
@@ -2095,6 +2231,7 @@ var BridgeClient = class {
2095
2231
  }
2096
2232
  entry.events.publish({
2097
2233
  type: "session_update",
2234
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
2098
2235
  data: {
2099
2236
  sessionId,
2100
2237
  update: {
@@ -2432,6 +2569,77 @@ function extractA2uiToolUpdate(params) {
2432
2569
  }
2433
2570
  __name(extractA2uiToolUpdate, "extractA2uiToolUpdate");
2434
2571
 
2572
+ // packages/acp-bridge/src/generation-stream.ts
2573
+ init_esbuild_shims();
2574
+ var GenerationStreamQueue = class {
2575
+ constructor(capacity) {
2576
+ this.capacity = capacity;
2577
+ }
2578
+ static {
2579
+ __name(this, "GenerationStreamQueue");
2580
+ }
2581
+ values = [];
2582
+ waiter;
2583
+ closed = false;
2584
+ failure;
2585
+ push(value) {
2586
+ if (this.closed) return false;
2587
+ if (this.waiter) {
2588
+ const waiter = this.waiter;
2589
+ this.waiter = void 0;
2590
+ waiter.resolve({ value, done: false });
2591
+ return true;
2592
+ }
2593
+ if (this.values.length >= this.capacity) return false;
2594
+ this.values.push(value);
2595
+ return true;
2596
+ }
2597
+ close() {
2598
+ if (this.closed) return;
2599
+ this.closed = true;
2600
+ this.settleWaiter();
2601
+ }
2602
+ fail(error) {
2603
+ if (this.closed) return;
2604
+ this.failure = error;
2605
+ this.closed = true;
2606
+ this.settleWaiter();
2607
+ }
2608
+ settleWaiter() {
2609
+ if (!this.waiter) return;
2610
+ const waiter = this.waiter;
2611
+ this.waiter = void 0;
2612
+ if (this.failure !== void 0) waiter.reject(this.failure);
2613
+ else waiter.resolve({ value: void 0, done: true });
2614
+ }
2615
+ next() {
2616
+ if (this.values.length > 0) {
2617
+ return Promise.resolve({ value: this.values.shift(), done: false });
2618
+ }
2619
+ if (this.failure !== void 0) return Promise.reject(this.failure);
2620
+ if (this.closed) {
2621
+ return Promise.resolve({ value: void 0, done: true });
2622
+ }
2623
+ if (this.waiter) {
2624
+ return Promise.reject(
2625
+ new Error("GenerationStreamQueue supports only one pending reader")
2626
+ );
2627
+ }
2628
+ return new Promise((resolve2, reject) => {
2629
+ this.waiter = { resolve: resolve2, reject };
2630
+ });
2631
+ }
2632
+ [Symbol.asyncIterator]() {
2633
+ return {
2634
+ next: /* @__PURE__ */ __name(() => this.next(), "next"),
2635
+ return: /* @__PURE__ */ __name(async () => {
2636
+ this.close();
2637
+ return { value: void 0, done: true };
2638
+ }, "return")
2639
+ };
2640
+ }
2641
+ };
2642
+
2435
2643
  // packages/acp-bridge/src/sessionArtifacts.ts
2436
2644
  init_esbuild_shims();
2437
2645
  import { createHash } from "node:crypto";
@@ -4660,6 +4868,14 @@ function isRecord2(value) {
4660
4868
  return typeof value === "object" && value !== null && !Array.isArray(value);
4661
4869
  }
4662
4870
  __name(isRecord2, "isRecord");
4871
+ function getCanonicalModelId(response, fallback) {
4872
+ if (!isRecord2(response) || !isRecord2(response["_meta"])) return fallback;
4873
+ const modelSwitch = response["_meta"]["qwenModelSwitch"];
4874
+ if (!isRecord2(modelSwitch)) return fallback;
4875
+ const modelId = modelSwitch["modelId"];
4876
+ return typeof modelId === "string" ? modelId : fallback;
4877
+ }
4878
+ __name(getCanonicalModelId, "getCanonicalModelId");
4663
4879
  function isBulkReplayUpdate(value) {
4664
4880
  if (!isRecord2(value)) return false;
4665
4881
  const updateType = value["sessionUpdate"];
@@ -4705,6 +4921,12 @@ function extractLoadReplayResponse(state) {
4705
4921
  `Invalid qwen.session.loadReplay replayError (version=${LOAD_REPLAY_VERSION}, replayError=${describeLoadReplayValue(replayError)})`
4706
4922
  );
4707
4923
  }
4924
+ const hasMore = replay["hasMore"];
4925
+ if (hasMore !== void 0 && typeof hasMore !== "boolean") {
4926
+ throw new Error(
4927
+ `Invalid qwen.session.loadReplay hasMore (version=${LOAD_REPLAY_VERSION}, hasMore=${describeLoadReplayValue(hasMore)})`
4928
+ );
4929
+ }
4708
4930
  const invalidUpdateIndex = rawUpdates.findIndex(
4709
4931
  (update) => !isBulkReplayUpdate(update)
4710
4932
  );
@@ -4727,7 +4949,8 @@ function extractLoadReplayResponse(state) {
4727
4949
  state: cleanState,
4728
4950
  updates: rawUpdates,
4729
4951
  ...partial === true ? { partial: true } : {},
4730
- ...typeof replayError === "string" ? { replayError } : {}
4952
+ ...typeof replayError === "string" ? { replayError } : {},
4953
+ ...hasMore === true ? { hasMore: true } : {}
4731
4954
  };
4732
4955
  }
4733
4956
  __name(extractLoadReplayResponse, "extractLoadReplayResponse");
@@ -4851,7 +5074,7 @@ function pickUserInputEchoMeta(meta) {
4851
5074
  return Array.isArray(inputAnnotations) ? { inputAnnotations } : {};
4852
5075
  }
4853
5076
  __name(pickUserInputEchoMeta, "pickUserInputEchoMeta");
4854
- function echoPromptToSessionBus(entry, req, originatorClientId) {
5077
+ function echoPromptToSessionBus(entry, req, promptId, originatorClientId) {
4855
5078
  const prompt = req.prompt;
4856
5079
  if (!Array.isArray(prompt) || prompt.length === 0) return;
4857
5080
  const serverTimestamp = Date.now();
@@ -4862,6 +5085,7 @@ function echoPromptToSessionBus(entry, req, originatorClientId) {
4862
5085
  try {
4863
5086
  entry.events.publish({
4864
5087
  type: "session_update",
5088
+ promptId,
4865
5089
  data: {
4866
5090
  sessionId: req.sessionId,
4867
5091
  update: {
@@ -4886,10 +5110,11 @@ function echoPromptToSessionBus(entry, req, originatorClientId) {
4886
5110
  }
4887
5111
  }
4888
5112
  __name(echoPromptToSessionBus, "echoPromptToSessionBus");
4889
- function broadcastPromptCancelled(entry, sessionId, originatorClientId, reason) {
5113
+ function broadcastPromptCancelled(entry, sessionId, promptId, originatorClientId, reason) {
4890
5114
  try {
4891
5115
  entry.events.publish({
4892
5116
  type: "prompt_cancelled",
5117
+ ...promptId ? { promptId } : {},
4893
5118
  data: { sessionId, ...reason ? { reason } : {} },
4894
5119
  ...originatorClientId ? { originatorClientId } : {}
4895
5120
  });
@@ -4897,7 +5122,7 @@ function broadcastPromptCancelled(entry, sessionId, originatorClientId, reason)
4897
5122
  }
4898
5123
  }
4899
5124
  __name(broadcastPromptCancelled, "broadcastPromptCancelled");
4900
- function broadcastPromptCancelledOnce(entry, sessionId, originatorClientId, reason) {
5125
+ function broadcastPromptCancelledOnce(entry, sessionId, promptId, originatorClientId, reason) {
4901
5126
  if (entry.cancelBroadcast) {
4902
5127
  writeStderrLine(
4903
5128
  `broadcastPromptCancelledOnce: suppressed duplicate cancel for session ${sessionId} (latch already set)`
@@ -4905,13 +5130,20 @@ function broadcastPromptCancelledOnce(entry, sessionId, originatorClientId, reas
4905
5130
  return;
4906
5131
  }
4907
5132
  entry.cancelBroadcast = true;
4908
- broadcastPromptCancelled(entry, sessionId, originatorClientId, reason);
5133
+ broadcastPromptCancelled(
5134
+ entry,
5135
+ sessionId,
5136
+ promptId,
5137
+ originatorClientId,
5138
+ reason
5139
+ );
4909
5140
  }
4910
5141
  __name(broadcastPromptCancelledOnce, "broadcastPromptCancelledOnce");
4911
5142
  function broadcastTurnComplete(entry, sessionId, promptResult, promptId, originatorClientId) {
4912
5143
  try {
4913
5144
  entry.events.publish({
4914
5145
  type: "turn_complete",
5146
+ ...promptId ? { promptId } : {},
4915
5147
  data: {
4916
5148
  sessionId,
4917
5149
  stopReason: promptResult.stopReason ?? "end_turn",
@@ -4981,6 +5213,7 @@ function broadcastTurnError(entry, sessionId, err, promptId, originatorClientId)
4981
5213
  try {
4982
5214
  entry.events.publish({
4983
5215
  type: "turn_error",
5216
+ ...promptId ? { promptId } : {},
4984
5217
  data: {
4985
5218
  sessionId,
4986
5219
  message,
@@ -5027,6 +5260,8 @@ var MCP_OAUTH_TIMEOUT_MS = 6e5;
5027
5260
  var DAEMON_RETRY_META_KEY = "qwen.daemon.retry";
5028
5261
  var DAEMON_CONTINUE_META_KEY = "qwen.daemon.continueLastTurn";
5029
5262
  var SESSION_RECAP_TIMEOUT_MS = 6e4;
5263
+ var SESSION_GENERATION_TIMEOUT_MS = 65e3;
5264
+ var GENERATION_STREAM_QUEUE_CAPACITY = 128;
5030
5265
  var SESSION_BTW_TIMEOUT_MS = 6e4;
5031
5266
  var SESSION_TRANSCRIPT_TIMEOUT_MS = 6e4;
5032
5267
  var SHELL_COMMAND_TIMEOUT_MS = 12e4;
@@ -5132,6 +5367,9 @@ function createAcpSessionBridge(opts) {
5132
5367
  const telemetry = opts.telemetry ?? NOOP_BRIDGE_TELEMETRY;
5133
5368
  let defaultEntry;
5134
5369
  let channelInfo;
5370
+ let workspaceMcpStatusCache;
5371
+ const workspaceMcpToolsCache = /* @__PURE__ */ new Map();
5372
+ const workspaceMcpResourcesCache = /* @__PURE__ */ new Map();
5135
5373
  let idleTimer;
5136
5374
  const sessionReapIntervalMs = resolvePositiveFiniteMs(
5137
5375
  opts.sessionReapIntervalMs,
@@ -5196,9 +5434,41 @@ function createAcpSessionBridge(opts) {
5196
5434
  function hasNoChannelWork(ci, opts2) {
5197
5435
  const inFlightSpawnCount = ci.sessionSpawnsInFlight - (opts2?.ignoreCurrentSessionSpawn === true ? 1 : 0);
5198
5436
  const pendingRestoreCount = ci.pendingRestoreIds.size - (opts2?.ignoreRestoreId !== void 0 && ci.pendingRestoreIds.has(opts2.ignoreRestoreId) ? 1 : 0);
5199
- return ci.sessionIds.size === 0 && pendingRestoreCount === 0 && ci.workspaceControlInFlight === 0 && inFlightSpawnCount === 0;
5437
+ return ci.sessionIds.size === 0 && pendingRestoreCount === 0 && ci.workspaceControlInFlight === 0 && !ci.workspaceMcpDiscoveryInFlight && ci.workspaceMcpAuthenticationServerNames.size === 0 && inFlightSpawnCount === 0;
5200
5438
  }
5201
5439
  __name(hasNoChannelWork, "hasNoChannelWork");
5440
+ function beginWorkspaceMcpDiscovery(ci) {
5441
+ workspaceMcpStatusCache = void 0;
5442
+ workspaceMcpToolsCache.clear();
5443
+ workspaceMcpResourcesCache.clear();
5444
+ ci.workspaceMcpDiscoveryInFlight = true;
5445
+ if (ci.workspaceMcpDiscoveryTimer) {
5446
+ clearTimeout(ci.workspaceMcpDiscoveryTimer);
5447
+ }
5448
+ ci.workspaceMcpDiscoveryTimer = setTimeout(() => {
5449
+ ci.workspaceMcpDiscoveryTimer = void 0;
5450
+ ci.workspaceMcpDiscoveryInFlight = false;
5451
+ ci.workspaceMcpDiscoveryRequested = false;
5452
+ if (hasNoChannelWork(ci)) {
5453
+ void startIdleTimer(ci, "workspace MCP discovery timeout");
5454
+ }
5455
+ }, MCP_RESTART_TIMEOUT_MS);
5456
+ ci.workspaceMcpDiscoveryTimer.unref();
5457
+ }
5458
+ __name(beginWorkspaceMcpDiscovery, "beginWorkspaceMcpDiscovery");
5459
+ function finishWorkspaceMcpDiscovery(ci) {
5460
+ ci.workspaceMcpDiscoveryInFlight = false;
5461
+ if (ci.workspaceMcpDiscoveryTimer) {
5462
+ clearTimeout(ci.workspaceMcpDiscoveryTimer);
5463
+ ci.workspaceMcpDiscoveryTimer = void 0;
5464
+ }
5465
+ }
5466
+ __name(finishWorkspaceMcpDiscovery, "finishWorkspaceMcpDiscovery");
5467
+ function invalidateWorkspaceMcpDetailCache(serverName) {
5468
+ workspaceMcpToolsCache.delete(serverName);
5469
+ workspaceMcpResourcesCache.delete(serverName);
5470
+ }
5471
+ __name(invalidateWorkspaceMcpDetailCache, "invalidateWorkspaceMcpDetailCache");
5202
5472
  async function reapPendingEmptyChannel(ci) {
5203
5473
  if (!ci.emptyReapPending || !hasNoChannelWork(ci)) return;
5204
5474
  ci.emptyReapPending = false;
@@ -5262,6 +5532,7 @@ function createAcpSessionBridge(opts) {
5262
5532
  const aliveChannels = /* @__PURE__ */ new Set();
5263
5533
  let inFlightChannelSpawn;
5264
5534
  const byId = /* @__PURE__ */ new Map();
5535
+ const generationRequests = /* @__PURE__ */ new Map();
5265
5536
  const inFlightExtensionRefreshes = /* @__PURE__ */ new Map();
5266
5537
  const toSessionSummary = /* @__PURE__ */ __name((entry) => {
5267
5538
  let isWaitingForPermission = false;
@@ -5279,6 +5550,8 @@ function createAcpSessionBridge(opts) {
5279
5550
  createdAt: entry.createdAt,
5280
5551
  displayName: entry.displayName,
5281
5552
  ...entry.parentSessionId ? { parentSessionId: entry.parentSessionId } : {},
5553
+ ...entry.sourceType ? { sourceType: entry.sourceType } : {},
5554
+ ...entry.sourceId !== void 0 ? { sourceId: entry.sourceId } : {},
5282
5555
  clientCount: entry.clientIds.size,
5283
5556
  hasActivePrompt: entry.promptActive,
5284
5557
  isWaitingForPermission,
@@ -5376,11 +5649,13 @@ function createAcpSessionBridge(opts) {
5376
5649
  if (channelInfo && !channelInfo.isDying) return channelInfo;
5377
5650
  if (inFlightChannelSpawn) return await inFlightChannelSpawn;
5378
5651
  const promise = (async () => {
5652
+ const acpChannelId = randomUUID2();
5379
5653
  const channel = await telemetry.withSpan(
5380
5654
  "channel.spawn",
5381
5655
  {
5382
5656
  "qwen-code.daemon.bridge.operation": "channel.spawn",
5383
- "qwen-code.daemon.channel.reused": false
5657
+ "qwen-code.daemon.channel.reused": false,
5658
+ "qwen-code.daemon.acp_channel.id": acpChannelId
5384
5659
  },
5385
5660
  async () => await channelFactory(boundWorkspace, childEnvOverrides)
5386
5661
  );
@@ -5450,10 +5725,23 @@ function createAcpSessionBridge(opts) {
5450
5725
  // `create_sub_session` tool: forward the request/response hook so a child
5451
5726
  // tool can ask the daemon to spawn a sub-session and (for 'first-turn')
5452
5727
  // return its result. Omitted → the method reports daemon-only.
5453
- opts.onCreateSubSession
5728
+ opts.onCreateSubSession,
5729
+ (sessionId, event) => {
5730
+ const request = generationRequests.get(event.requestId);
5731
+ if (!request || request.sessionId !== sessionId) return;
5732
+ if (request.queue.push(event)) return;
5733
+ request.settled = true;
5734
+ generationRequests.delete(event.requestId);
5735
+ request.queue.fail(new Error("Generation stream consumer too slow"));
5736
+ void request.connection.extMethod(SERVE_CONTROL_EXT_METHODS.sessionGenerationCancel, {
5737
+ sessionId,
5738
+ requestId: event.requestId
5739
+ }).catch(() => void 0);
5740
+ }
5454
5741
  );
5455
5742
  const connection = new ClientSideConnection(() => client, channel.stream);
5456
5743
  const info = {
5744
+ id: acpChannelId,
5457
5745
  channel,
5458
5746
  connection,
5459
5747
  client,
@@ -5461,6 +5749,10 @@ function createAcpSessionBridge(opts) {
5461
5749
  pendingRestoreIds: /* @__PURE__ */ new Set(),
5462
5750
  sessionSpawnsInFlight: 0,
5463
5751
  workspaceControlInFlight: 0,
5752
+ workspaceMcpDiscoveryInFlight: false,
5753
+ workspaceMcpDiscoveryRequested: false,
5754
+ workspaceMcpAuthenticationServerNames: /* @__PURE__ */ new Set(),
5755
+ workspaceMcpAuthenticationTimers: /* @__PURE__ */ new Map(),
5464
5756
  emptyReapPending: false,
5465
5757
  isDying: false,
5466
5758
  handshakeComplete: false
@@ -5473,6 +5765,15 @@ function createAcpSessionBridge(opts) {
5473
5765
  }
5474
5766
  void channel.exited.then((exitInfo) => {
5475
5767
  if (channelInfo === info) cancelIdleTimer();
5768
+ if (info.workspaceMcpDiscoveryTimer) {
5769
+ clearTimeout(info.workspaceMcpDiscoveryTimer);
5770
+ info.workspaceMcpDiscoveryTimer = void 0;
5771
+ }
5772
+ for (const timer of info.workspaceMcpAuthenticationTimers.values()) {
5773
+ clearTimeout(timer);
5774
+ }
5775
+ info.workspaceMcpAuthenticationTimers.clear();
5776
+ info.workspaceMcpAuthenticationServerNames.clear();
5476
5777
  aliveChannels.delete(info);
5477
5778
  if (channelInfo === info) channelInfo = void 0;
5478
5779
  const sessions = Array.from(info.sessionIds);
@@ -5530,7 +5831,8 @@ function createAcpSessionBridge(opts) {
5530
5831
  await telemetry.withSpan(
5531
5832
  "channel.initialize",
5532
5833
  {
5533
- "qwen-code.daemon.bridge.operation": "channel.initialize"
5834
+ "qwen-code.daemon.bridge.operation": "channel.initialize",
5835
+ "qwen-code.daemon.acp_channel.id": acpChannelId
5534
5836
  },
5535
5837
  async () => await withTimeout(
5536
5838
  connection.initialize({
@@ -5569,8 +5871,16 @@ function createAcpSessionBridge(opts) {
5569
5871
  }
5570
5872
  }
5571
5873
  __name(ensureChannel, "ensureChannel");
5572
- async function doSpawn(modelServiceId, effectiveScope, approvalMode, requestedClientId, onSessionRegistered, parentSessionId) {
5573
- const ci = await ensureChannel();
5874
+ async function doSpawn(modelServiceId, effectiveScope, approvalMode, requestedClientId, onSessionRegistered, parentSessionId, sourceType, sourceId) {
5875
+ const channelPath = channelInfo && !channelInfo.isDying ? "reused" : inFlightChannelSpawn ? "joined" : "spawned_on_request";
5876
+ const ci = await telemetry.withSpan(
5877
+ "channel.wait",
5878
+ {
5879
+ "qwen-code.daemon.bridge.operation": "channel.wait",
5880
+ "qwen-code.daemon.channel.path": channelPath
5881
+ },
5882
+ ensureChannel
5883
+ );
5574
5884
  ci.sessionSpawnsInFlight++;
5575
5885
  let sessionRegistered = false;
5576
5886
  let sessionRemovedDuringInitialization = false;
@@ -5582,16 +5892,27 @@ function createAcpSessionBridge(opts) {
5582
5892
  "session.new",
5583
5893
  {
5584
5894
  "qwen-code.daemon.bridge.operation": "session.new",
5585
- "qwen-code.daemon.session_scope": effectiveScope
5895
+ "qwen-code.daemon.session_scope": effectiveScope,
5896
+ "qwen-code.daemon.channel.path": channelPath,
5897
+ "qwen-code.daemon.acp_channel.id": ci.id
5586
5898
  },
5587
- async () => await withTimeout(
5588
- ci.connection.newSession({
5589
- cwd: boundWorkspace,
5590
- mcpServers: []
5591
- }),
5592
- initTimeoutMs,
5593
- "newSession"
5594
- )
5899
+ async () => {
5900
+ const response = await withTimeout(
5901
+ ci.connection.newSession(
5902
+ telemetry.injectPromptContext({
5903
+ cwd: boundWorkspace,
5904
+ mcpServers: []
5905
+ })
5906
+ ),
5907
+ initTimeoutMs,
5908
+ "newSession"
5909
+ );
5910
+ telemetry.event("session.new.completed", {
5911
+ "session.id": response.sessionId,
5912
+ "qwen-code.daemon.acp_channel.id": ci.id
5913
+ });
5914
+ return response;
5915
+ }
5595
5916
  );
5596
5917
  } catch (err) {
5597
5918
  if (hasNoChannelWork(ci, { ignoreCurrentSessionSpawn: true })) {
@@ -5611,7 +5932,7 @@ function createAcpSessionBridge(opts) {
5611
5932
  newSessionResp.sessionId,
5612
5933
  boundWorkspace,
5613
5934
  void 0,
5614
- { parentSessionId }
5935
+ { parentSessionId, sourceType, sourceId }
5615
5936
  );
5616
5937
  initializedSessionId = entry.sessionId;
5617
5938
  sessionRegistered = true;
@@ -5661,6 +5982,32 @@ function createAcpSessionBridge(opts) {
5661
5982
  );
5662
5983
  }
5663
5984
  }
5985
+ let sourcePersisted;
5986
+ if (entry.sourceType) {
5987
+ try {
5988
+ const sourceResult = await Promise.race([
5989
+ withTimeout(
5990
+ entry.connection.extMethod(
5991
+ SERVE_CONTROL_EXT_METHODS.sessionSource,
5992
+ {
5993
+ sessionId: entry.sessionId,
5994
+ sourceType: entry.sourceType,
5995
+ ...entry.sourceId !== void 0 ? { sourceId: entry.sourceId } : {}
5996
+ }
5997
+ ),
5998
+ initTimeoutMs,
5999
+ "sessionSource"
6000
+ ),
6001
+ getTransportClosedReject(entry)
6002
+ ]);
6003
+ sourcePersisted = sourceResult?.persisted === true;
6004
+ } catch (err) {
6005
+ sourcePersisted = false;
6006
+ writeStderrLine(
6007
+ `qwen serve: source metadata for ${entry.sessionId} was not persisted (${err instanceof Error ? err.message : String(err)}) \u2014 the source is live-only until restart (reported to the caller via sourcePersisted=false)`
6008
+ );
6009
+ }
6010
+ }
5664
6011
  if (modelServiceId) {
5665
6012
  await applyModelServiceId(
5666
6013
  entry,
@@ -5696,6 +6043,9 @@ function createAcpSessionBridge(opts) {
5696
6043
  attached: false,
5697
6044
  clientId,
5698
6045
  createdAt: entry.createdAt,
6046
+ ...entry.sourceType ? { sourceType: entry.sourceType } : {},
6047
+ ...entry.sourceId !== void 0 ? { sourceId: entry.sourceId } : {},
6048
+ ...entry.sourceType ? { sourcePersisted: sourcePersisted === true } : {},
5699
6049
  ...entry.parentSessionId ? { parentSessionPersisted: parentSessionPersisted === true } : {}
5700
6050
  };
5701
6051
  } finally {
@@ -5726,7 +6076,7 @@ function createAcpSessionBridge(opts) {
5726
6076
  entry.modelRoundtripInFlight = true;
5727
6077
  let succeeded = false;
5728
6078
  try {
5729
- await Promise.race([
6079
+ const result = await Promise.race([
5730
6080
  withTimeout(
5731
6081
  conn.unstable_setSessionModel({
5732
6082
  sessionId: entry.sessionId,
@@ -5742,7 +6092,7 @@ function createAcpSessionBridge(opts) {
5742
6092
  type: "settings_changed",
5743
6093
  data: {
5744
6094
  key: "model.name",
5745
- value: modelId
6095
+ value: getCanonicalModelId(result, modelId)
5746
6096
  },
5747
6097
  ...originatorClientId ? { originatorClientId } : {}
5748
6098
  });
@@ -5943,10 +6293,77 @@ function createAcpSessionBridge(opts) {
5943
6293
  }
5944
6294
  return info.statusClosedReject;
5945
6295
  }, "getChannelClosedReject");
5946
- const requestWorkspaceStatus = /* @__PURE__ */ __name(async (method, idle, params = {}) => {
6296
+ const cacheWorkspaceMcpDetails = /* @__PURE__ */ __name(async (info, status) => {
6297
+ if (!Array.isArray(status.servers)) return;
6298
+ const serverNames = status.servers.flatMap(
6299
+ (server) => isRecord2(server) && typeof server["name"] === "string" && server["mcpStatus"] === "connected" ? [server["name"]] : []
6300
+ );
6301
+ const cacheDetail = /* @__PURE__ */ __name(async (serverName, method, cache) => {
6302
+ try {
6303
+ const result = await withTimeout(
6304
+ Promise.race([
6305
+ info.connection.extMethod(method, {
6306
+ serverName,
6307
+ cwd: boundWorkspace
6308
+ }),
6309
+ getChannelClosedReject(info)
6310
+ ]),
6311
+ initTimeoutMs,
6312
+ method
6313
+ );
6314
+ cache.set(serverName, result);
6315
+ } catch {
6316
+ }
6317
+ }, "cacheDetail");
6318
+ await Promise.all(
6319
+ serverNames.flatMap((serverName) => [
6320
+ cacheDetail(
6321
+ serverName,
6322
+ SERVE_STATUS_EXT_METHODS.workspaceMcpTools,
6323
+ workspaceMcpToolsCache
6324
+ ),
6325
+ cacheDetail(
6326
+ serverName,
6327
+ SERVE_STATUS_EXT_METHODS.workspaceMcpResources,
6328
+ workspaceMcpResourcesCache
6329
+ )
6330
+ ])
6331
+ );
6332
+ }, "cacheWorkspaceMcpDetails");
6333
+ const mergeManagedWorkspaceMcpStatus = /* @__PURE__ */ __name((serverNames, previous, current) => {
6334
+ if (Array.isArray(current.servers) && previous?.discoveryState === "completed" && current.discoveryState === "not_started") {
6335
+ if (current.servers.length === 0) return previous;
6336
+ const currentServers = new Map(
6337
+ current.servers.map((server) => [server.name, server])
6338
+ );
6339
+ const previousNames = new Set(
6340
+ previous.servers.map((server) => server.name)
6341
+ );
6342
+ const servers = previous.servers.map(
6343
+ (server) => serverNames.has(server.name) ? currentServers.get(server.name) ?? server : server
6344
+ );
6345
+ for (const server of current.servers) {
6346
+ if (serverNames.has(server.name) && !previousNames.has(server.name)) {
6347
+ servers.push(server);
6348
+ }
6349
+ }
6350
+ return {
6351
+ ...previous,
6352
+ discoveryState: "completed",
6353
+ servers
6354
+ };
6355
+ }
6356
+ return current;
6357
+ }, "mergeManagedWorkspaceMcpStatus");
6358
+ const requestWorkspaceStatus = /* @__PURE__ */ __name(async (method, idle, params = {}, managedServerNames) => {
5947
6359
  const info = liveChannelInfo();
5948
- if (!info) return idle();
5949
- const response = await withTimeout(
6360
+ if (!info) {
6361
+ if (method === SERVE_STATUS_EXT_METHODS.workspaceMcp && workspaceMcpStatusCache) {
6362
+ return workspaceMcpStatusCache;
6363
+ }
6364
+ return idle();
6365
+ }
6366
+ let response = await withTimeout(
5950
6367
  Promise.race([
5951
6368
  info.connection.extMethod(method, { ...params, cwd: boundWorkspace }),
5952
6369
  getChannelClosedReject(info)
@@ -5954,6 +6371,67 @@ function createAcpSessionBridge(opts) {
5954
6371
  initTimeoutMs,
5955
6372
  method
5956
6373
  );
6374
+ if (method === SERVE_STATUS_EXT_METHODS.workspaceMcp) {
6375
+ const rawStatus = response;
6376
+ if (!Array.isArray(rawStatus.servers)) {
6377
+ return response;
6378
+ }
6379
+ const rawServers = rawStatus.servers;
6380
+ const effectiveManagedServerNames = /* @__PURE__ */ new Set([
6381
+ ...info.workspaceMcpAuthenticationServerNames,
6382
+ ...managedServerNames ?? []
6383
+ ]);
6384
+ if (effectiveManagedServerNames.size > 0 || workspaceMcpStatusCache?.discoveryState === "completed" && rawStatus.discoveryState === "not_started" && rawServers.length === 0) {
6385
+ response = mergeManagedWorkspaceMcpStatus(
6386
+ effectiveManagedServerNames,
6387
+ workspaceMcpStatusCache,
6388
+ rawStatus
6389
+ );
6390
+ }
6391
+ const status = response;
6392
+ if (status.discoveryState === "completed") {
6393
+ await cacheWorkspaceMcpDetails(
6394
+ info,
6395
+ effectiveManagedServerNames.size > 0 ? {
6396
+ servers: rawServers.filter(
6397
+ (server) => effectiveManagedServerNames.has(server.name)
6398
+ )
6399
+ } : status
6400
+ );
6401
+ }
6402
+ if (info.workspaceMcpDiscoveryInFlight && (status.discoveryState === "completed" || Array.isArray(status.errors) && status.errors.length > 0)) {
6403
+ finishWorkspaceMcpDiscovery(info);
6404
+ if (hasNoChannelWork(info)) {
6405
+ await startIdleTimer(info, "workspace MCP discovery complete");
6406
+ }
6407
+ }
6408
+ if (status.discoveryState === "completed") {
6409
+ info.workspaceMcpDiscoveryRequested = true;
6410
+ } else if (status.discoveryState === "in_progress") {
6411
+ info.workspaceMcpDiscoveryRequested = true;
6412
+ } else if (Array.isArray(status.errors) && status.errors.length > 0) {
6413
+ info.workspaceMcpDiscoveryRequested = false;
6414
+ }
6415
+ let authenticationCompleted = false;
6416
+ for (const serverName of info.workspaceMcpAuthenticationServerNames) {
6417
+ const server = rawServers.find(
6418
+ (candidate) => candidate.name === serverName
6419
+ );
6420
+ if (server?.authenticationState !== "pending" && (server !== void 0 || rawStatus.discoveryState === "completed")) {
6421
+ info.workspaceMcpAuthenticationServerNames.delete(serverName);
6422
+ const timer = info.workspaceMcpAuthenticationTimers.get(serverName);
6423
+ if (timer) clearTimeout(timer);
6424
+ info.workspaceMcpAuthenticationTimers.delete(serverName);
6425
+ authenticationCompleted = true;
6426
+ }
6427
+ }
6428
+ if (authenticationCompleted) {
6429
+ if (hasNoChannelWork(info)) {
6430
+ await startIdleTimer(info, "workspace MCP authentication complete");
6431
+ }
6432
+ }
6433
+ workspaceMcpStatusCache = response;
6434
+ }
5957
6435
  return response;
5958
6436
  }, "requestWorkspaceStatus");
5959
6437
  const STALE_CHILD_RESOURCE_MS = 3e4;
@@ -6096,6 +6574,7 @@ function createAcpSessionBridge(opts) {
6096
6574
  entry.modelPublishGeneration++;
6097
6575
  entry.events.publish({
6098
6576
  type: "model_switched",
6577
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
6099
6578
  data: { sessionId: entry.sessionId, modelId },
6100
6579
  ...originatorClientId ? { originatorClientId } : {}
6101
6580
  });
@@ -6105,6 +6584,7 @@ function createAcpSessionBridge(opts) {
6105
6584
  entry.approvalModePublishGeneration++;
6106
6585
  entry.events.publish({
6107
6586
  type: "approval_mode_changed",
6587
+ ...entry.activePromptId ? { promptId: entry.activePromptId } : {},
6108
6588
  data: {
6109
6589
  sessionId: entry.sessionId,
6110
6590
  previous: payload.previous,
@@ -6177,6 +6657,8 @@ function createAcpSessionBridge(opts) {
6177
6657
  workspaceCwd,
6178
6658
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6179
6659
  ...options.parentSessionId ? { parentSessionId: options.parentSessionId } : {},
6660
+ ...options.sourceType ? { sourceType: options.sourceType } : {},
6661
+ ...options.sourceId !== void 0 ? { sourceId: options.sourceId } : {},
6180
6662
  channel: ci.channel,
6181
6663
  connection: ci.connection,
6182
6664
  events,
@@ -6351,7 +6833,8 @@ function createAcpSessionBridge(opts) {
6351
6833
  compactedReplay: snapshot.compactedTurns,
6352
6834
  liveJournal: snapshot.liveJournal,
6353
6835
  lastEventId: snapshot.lastEventId,
6354
- ...replayStatus
6836
+ ...replayStatus,
6837
+ ...entry.restoreHistoryHasMore === true ? { historyHasMore: true } : {}
6355
6838
  };
6356
6839
  }
6357
6840
  return { lastEventId: snapshot.lastEventId, ...replayStatus };
@@ -6411,6 +6894,8 @@ function createAcpSessionBridge(opts) {
6411
6894
  attached: true,
6412
6895
  clientId,
6413
6896
  createdAt: existing.createdAt,
6897
+ ...existing.sourceType ? { sourceType: existing.sourceType } : {},
6898
+ ...existing.sourceId !== void 0 ? { sourceId: existing.sourceId } : {},
6414
6899
  // Late attachers get the same ACP state the original restore
6415
6900
  // caller saw; spawn-only sessions don't carry a state payload.
6416
6901
  state: existing.restoreState ?? {},
@@ -6487,6 +6972,7 @@ function createAcpSessionBridge(opts) {
6487
6972
  let replayUpdates = [];
6488
6973
  let replayPartial;
6489
6974
  let replayError;
6975
+ let replayHasMore;
6490
6976
  try {
6491
6977
  if (action === "load") {
6492
6978
  state = await Promise.race([
@@ -6502,7 +6988,10 @@ function createAcpSessionBridge(opts) {
6502
6988
  mcpServers: [],
6503
6989
  ...historyReplay === "response" ? {
6504
6990
  _meta: {
6505
- [LOAD_REPLAY_MODE_META_KEY]: LOAD_REPLAY_BULK_MODE
6991
+ [LOAD_REPLAY_MODE_META_KEY]: LOAD_REPLAY_BULK_MODE,
6992
+ ...req.historyPageSize !== void 0 ? {
6993
+ [LOAD_REPLAY_PAGE_SIZE_META_KEY]: req.historyPageSize
6994
+ } : {}
6506
6995
  }
6507
6996
  } : {}
6508
6997
  }),
@@ -6531,6 +7020,7 @@ function createAcpSessionBridge(opts) {
6531
7020
  replayUpdates = extracted.updates;
6532
7021
  replayPartial = extracted.partial;
6533
7022
  replayError = extracted.replayError;
7023
+ replayHasMore = extracted.hasMore === true ? true : void 0;
6534
7024
  }
6535
7025
  } catch (err) {
6536
7026
  restoreEvents.close();
@@ -6583,6 +7073,8 @@ function createAcpSessionBridge(opts) {
6583
7073
  attached: true,
6584
7074
  clientId: clientId2,
6585
7075
  createdAt: racedEntry.createdAt,
7076
+ ...racedEntry.sourceType ? { sourceType: racedEntry.sourceType } : {},
7077
+ ...racedEntry.sourceId !== void 0 ? { sourceId: racedEntry.sourceId } : {},
6586
7078
  state: racedEntry.restoreState ?? {},
6587
7079
  hasActivePrompt: racedEntry.promptActive,
6588
7080
  ...replayFieldsFor(racedEntry, action)
@@ -6598,7 +7090,9 @@ function createAcpSessionBridge(opts) {
6598
7090
  lifecycleReason: action,
6599
7091
  // Re-seed the persisted parent lineage the caller recovered from the
6600
7092
  // transcript, so a restored sub-session's status reports its parent.
6601
- ...req.parentSessionId ? { parentSessionId: req.parentSessionId } : {}
7093
+ ...req.parentSessionId ? { parentSessionId: req.parentSessionId } : {},
7094
+ ...req.sourceType ? { sourceType: req.sourceType } : {},
7095
+ ...req.sourceId !== void 0 ? { sourceId: req.sourceId } : {}
6602
7096
  }
6603
7097
  );
6604
7098
  releaseAdmissionOnce();
@@ -6611,6 +7105,9 @@ function createAcpSessionBridge(opts) {
6611
7105
  if (replayError !== void 0) {
6612
7106
  entry.restoreReplayError = replayError;
6613
7107
  }
7108
+ if (replayHasMore === true) {
7109
+ entry.restoreHistoryHasMore = true;
7110
+ }
6614
7111
  seedSnapshotCaches(entry, publicState);
6615
7112
  const artifactRestoreWarnings = await entry.artifacts.restore(
6616
7113
  restoredArtifactSnapshot
@@ -6629,6 +7126,9 @@ function createAcpSessionBridge(opts) {
6629
7126
  await ci.client.seedSessionUpdates(entry, replayUpdates, {
6630
7127
  ingestArtifacts: restoredArtifactSnapshot === void 0 || artifactRestoreFailed
6631
7128
  });
7129
+ if (req.historyPageSize !== void 0 && entry.events.snapshotReplay()?.compactedTurns.some((event) => event.type === "history_truncated")) {
7130
+ entry.restoreHistoryHasMore = true;
7131
+ }
6632
7132
  ci.client.drainEarlyEvents(entry.sessionId, entry);
6633
7133
  }
6634
7134
  const clientId = registerClient(entry, req.clientId);
@@ -6643,6 +7143,8 @@ function createAcpSessionBridge(opts) {
6643
7143
  attached: false,
6644
7144
  clientId,
6645
7145
  createdAt: entry.createdAt,
7146
+ ...entry.sourceType ? { sourceType: entry.sourceType } : {},
7147
+ ...entry.sourceId !== void 0 ? { sourceId: entry.sourceId } : {},
6646
7148
  state: publicState,
6647
7149
  ...artifactRestoreWarnings.length > 0 ? { artifactWarnings: artifactRestoreWarnings } : {},
6648
7150
  hasActivePrompt: entry.promptActive,
@@ -6863,6 +7365,10 @@ function createAcpSessionBridge(opts) {
6863
7365
  throw new InvalidSessionScopeError(req.sessionScope);
6864
7366
  }
6865
7367
  const effectiveScope = req.sessionScope ?? defaultSessionScope;
7368
+ const source = parseSessionSource(req.sourceType, req.sourceId);
7369
+ if ("error" in source) {
7370
+ throw new InvalidSessionMetadataError("sourceType", source.error);
7371
+ }
6866
7372
  if (req.approvalMode !== void 0 && !KNOWN_APPROVAL_MODES.has(req.approvalMode)) {
6867
7373
  throw new Error(
6868
7374
  `Invalid approvalMode: ${JSON.stringify(req.approvalMode)}`
@@ -6895,6 +7401,8 @@ function createAcpSessionBridge(opts) {
6895
7401
  attached: true,
6896
7402
  clientId,
6897
7403
  createdAt: existing.createdAt,
7404
+ ...existing.sourceType ? { sourceType: existing.sourceType } : {},
7405
+ ...existing.sourceId !== void 0 ? { sourceId: existing.sourceId } : {},
6898
7406
  hasActivePrompt: existing.promptActive
6899
7407
  };
6900
7408
  }
@@ -6953,7 +7461,9 @@ function createAcpSessionBridge(opts) {
6953
7461
  req.approvalMode,
6954
7462
  req.clientId,
6955
7463
  releaseAdmissionOnce,
6956
- req.parentSessionId
7464
+ req.parentSessionId,
7465
+ source.sourceType,
7466
+ source.sourceId
6957
7467
  );
6958
7468
  const tracker = effectiveScope === "single" ? workspaceKey : `${workspaceKey}#${randomUUID2()}`;
6959
7469
  inFlightSpawns.set(tracker, promise);
@@ -7022,6 +7532,7 @@ function createAcpSessionBridge(opts) {
7022
7532
  if (isQueued) {
7023
7533
  entry.events.publish({
7024
7534
  type: "pending_prompt_added",
7535
+ promptId: pendingEntry.promptId,
7025
7536
  data: {
7026
7537
  sessionId,
7027
7538
  promptId: pendingEntry.promptId,
@@ -7042,6 +7553,7 @@ function createAcpSessionBridge(opts) {
7042
7553
  pendingEntry.state = "running";
7043
7554
  entry.events.publish({
7044
7555
  type: "pending_prompt_started",
7556
+ promptId: pendingEntry.promptId,
7045
7557
  data: {
7046
7558
  sessionId,
7047
7559
  promptId: pendingEntry.promptId,
@@ -7094,6 +7606,7 @@ function createAcpSessionBridge(opts) {
7094
7606
  return copy;
7095
7607
  })();
7096
7608
  entry.promptActive = true;
7609
+ entry.activePromptId = pendingEntry.promptId;
7097
7610
  delete entry.turnError;
7098
7611
  activePromptCounter++;
7099
7612
  entry.sessionLastSeenAt = Date.now();
@@ -7109,10 +7622,12 @@ function createAcpSessionBridge(opts) {
7109
7622
  echoPromptToSessionBus(
7110
7623
  entry,
7111
7624
  promptRequest,
7625
+ pendingEntry.promptId,
7112
7626
  originatorClientId
7113
7627
  );
7114
7628
  }
7115
7629
  } catch (echoErr) {
7630
+ delete entry.activePromptId;
7116
7631
  delete entry.activePromptOriginatorClientId;
7117
7632
  if (entry.promptActive) {
7118
7633
  entry.promptActive = false;
@@ -7128,6 +7643,7 @@ function createAcpSessionBridge(opts) {
7128
7643
  entry.sessionLastSeenAt = Date.now();
7129
7644
  touchActivity();
7130
7645
  }
7646
+ delete entry.activePromptId;
7131
7647
  delete entry.activePromptOriginatorClientId;
7132
7648
  if (entry.clientIds.size === 0 && entry.events.subscriberCount === 0 && byId.has(sessionId)) {
7133
7649
  void closeSessionImpl(sessionId, void 0, {
@@ -7159,6 +7675,7 @@ function createAcpSessionBridge(opts) {
7159
7675
  broadcastPromptCancelledOnce(
7160
7676
  entry,
7161
7677
  sessionId,
7678
+ pendingEntry.promptId,
7162
7679
  originatorClientId,
7163
7680
  "forward_failed"
7164
7681
  );
@@ -7176,6 +7693,7 @@ function createAcpSessionBridge(opts) {
7176
7693
  broadcastPromptCancelledOnce(
7177
7694
  entry,
7178
7695
  sessionId,
7696
+ pendingEntry.promptId,
7179
7697
  originatorClientId
7180
7698
  );
7181
7699
  cancelPendingForSession(sessionId);
@@ -7238,6 +7756,7 @@ function createAcpSessionBridge(opts) {
7238
7756
  try {
7239
7757
  entry.events.publish({
7240
7758
  type: "pending_prompt_completed",
7759
+ promptId: pendingEntry.promptId,
7241
7760
  data: {
7242
7761
  sessionId,
7243
7762
  promptId: pendingEntry.promptId,
@@ -7271,7 +7790,12 @@ function createAcpSessionBridge(opts) {
7271
7790
  entry,
7272
7791
  context?.clientId
7273
7792
  );
7274
- broadcastPromptCancelledOnce(entry, sessionId, cancelOriginatorClientId);
7793
+ broadcastPromptCancelledOnce(
7794
+ entry,
7795
+ sessionId,
7796
+ entry.activePromptId,
7797
+ cancelOriginatorClientId
7798
+ );
7275
7799
  cancelPendingForSession(sessionId);
7276
7800
  const notif = req ? { ...req, sessionId } : { sessionId };
7277
7801
  telemetry.metrics?.cancelled();
@@ -7728,18 +8252,39 @@ function createAcpSessionBridge(opts) {
7728
8252
  return requestWorkspaceStatus(method, idle);
7729
8253
  },
7730
8254
  async invokeWorkspaceCommand(method, params, invokeOpts) {
7731
- const info = liveChannelInfo();
8255
+ const startsWorkspaceChannel = method === SERVE_CONTROL_EXT_METHODS.workspaceMcpRestart;
8256
+ const info = startsWorkspaceChannel ? await ensureChannel() : liveChannelInfo();
7732
8257
  if (!info) throw new SessionNotFoundError(`workspace-command:${method}`);
7733
- const timeout = invokeOpts?.timeoutMs ?? initTimeoutMs;
7734
- const response = await withTimeout(
7735
- Promise.race([
7736
- info.connection.extMethod(method, params ?? {}),
7737
- getChannelClosedReject(info)
7738
- ]),
7739
- timeout,
7740
- method
7741
- );
7742
- return response;
8258
+ try {
8259
+ const timeout = invokeOpts?.timeoutMs ?? initTimeoutMs;
8260
+ const invoke = /* @__PURE__ */ __name(() => withTimeout(
8261
+ Promise.race([
8262
+ info.connection.extMethod(method, params ?? {}),
8263
+ getChannelClosedReject(info)
8264
+ ]),
8265
+ timeout,
8266
+ method
8267
+ ), "invoke");
8268
+ const response = startsWorkspaceChannel ? await withWorkspaceControl(info, invoke) : await invoke();
8269
+ if (method === SERVE_CONTROL_EXT_METHODS.workspaceMcpRestart && typeof params?.["serverName"] === "string") {
8270
+ invalidateWorkspaceMcpDetailCache(params["serverName"]);
8271
+ await requestWorkspaceStatus(
8272
+ SERVE_STATUS_EXT_METHODS.workspaceMcp,
8273
+ () => {
8274
+ throw new BridgeChannelClosedError(
8275
+ "workspace MCP restart status refresh"
8276
+ );
8277
+ },
8278
+ {},
8279
+ /* @__PURE__ */ new Set([params["serverName"]])
8280
+ );
8281
+ }
8282
+ return response;
8283
+ } finally {
8284
+ if (startsWorkspaceChannel && hasNoChannelWork(info)) {
8285
+ await startIdleTimer(info, "workspace MCP restart");
8286
+ }
8287
+ }
7743
8288
  },
7744
8289
  async isWorkspaceMemoryRememberAvailable() {
7745
8290
  const info = await ensureChannel();
@@ -7838,46 +8383,60 @@ function createAcpSessionBridge(opts) {
7838
8383
  }
7839
8384
  },
7840
8385
  async getWorkspaceMcpToolsStatus(serverName) {
7841
- return requestWorkspaceStatus(
8386
+ const result = await requestWorkspaceStatus(
7842
8387
  SERVE_STATUS_EXT_METHODS.workspaceMcpTools,
7843
- () => ({
7844
- v: STATUS_SCHEMA_VERSION,
7845
- workspaceCwd: boundWorkspace,
7846
- serverName,
7847
- initialized: false,
7848
- acpChannelLive: false,
7849
- tools: [],
7850
- errors: [
7851
- {
7852
- kind: "mcp_tools",
7853
- status: "not_started",
7854
- hint: "spawn a session to populate"
7855
- }
7856
- ]
7857
- }),
8388
+ () => {
8389
+ const cached = workspaceMcpToolsCache.get(serverName);
8390
+ return cached ? { ...cached, acpChannelLive: false } : {
8391
+ v: STATUS_SCHEMA_VERSION,
8392
+ workspaceCwd: boundWorkspace,
8393
+ serverName,
8394
+ initialized: false,
8395
+ acpChannelLive: false,
8396
+ tools: [],
8397
+ errors: [
8398
+ {
8399
+ kind: "mcp_tools",
8400
+ status: "not_started",
8401
+ hint: "initialize MCP discovery to populate"
8402
+ }
8403
+ ]
8404
+ };
8405
+ },
7858
8406
  { serverName }
7859
8407
  );
8408
+ if (result.acpChannelLive) {
8409
+ workspaceMcpToolsCache.set(serverName, result);
8410
+ }
8411
+ return result;
7860
8412
  },
7861
8413
  async getWorkspaceMcpResourcesStatus(serverName) {
7862
- return requestWorkspaceStatus(
8414
+ const result = await requestWorkspaceStatus(
7863
8415
  SERVE_STATUS_EXT_METHODS.workspaceMcpResources,
7864
- () => ({
7865
- v: STATUS_SCHEMA_VERSION,
7866
- workspaceCwd: boundWorkspace,
7867
- serverName,
7868
- initialized: false,
7869
- acpChannelLive: false,
7870
- resources: [],
7871
- errors: [
7872
- {
7873
- kind: "mcp_resources",
7874
- status: "not_started",
7875
- hint: "spawn a session to populate"
7876
- }
7877
- ]
7878
- }),
8416
+ () => {
8417
+ const cached = workspaceMcpResourcesCache.get(serverName);
8418
+ return cached ? { ...cached, acpChannelLive: false } : {
8419
+ v: STATUS_SCHEMA_VERSION,
8420
+ workspaceCwd: boundWorkspace,
8421
+ serverName,
8422
+ initialized: false,
8423
+ acpChannelLive: false,
8424
+ resources: [],
8425
+ errors: [
8426
+ {
8427
+ kind: "mcp_resources",
8428
+ status: "not_started",
8429
+ hint: "initialize MCP discovery to populate"
8430
+ }
8431
+ ]
8432
+ };
8433
+ },
7879
8434
  { serverName }
7880
8435
  );
8436
+ if (result.acpChannelLive) {
8437
+ workspaceMcpResourcesCache.set(serverName, result);
8438
+ }
8439
+ return result;
7881
8440
  },
7882
8441
  async getWorkspaceToolsStatus() {
7883
8442
  return requestWorkspaceStatus(
@@ -8117,7 +8676,7 @@ function createAcpSessionBridge(opts) {
8117
8676
  type: "settings_changed",
8118
8677
  data: {
8119
8678
  key: "model.name",
8120
- value: req.modelId
8679
+ value: getCanonicalModelId(result, req.modelId)
8121
8680
  },
8122
8681
  ...originatorClientId ? { originatorClientId } : {}
8123
8682
  });
@@ -8245,6 +8804,75 @@ function createAcpSessionBridge(opts) {
8245
8804
  recap: response.recap ?? null
8246
8805
  };
8247
8806
  },
8807
+ generateSessionContent(sessionId, prompt, signal, context) {
8808
+ const entry = byId.get(sessionId);
8809
+ if (!entry) throw new SessionNotFoundError(sessionId);
8810
+ const info = channelInfoForEntry(entry);
8811
+ if (!info || info.isDying) throw new SessionNotFoundError(sessionId);
8812
+ resolveTrustedClientId(entry, context?.clientId);
8813
+ const requestId = randomUUID2();
8814
+ const queue = new GenerationStreamQueue(
8815
+ GENERATION_STREAM_QUEUE_CAPACITY
8816
+ );
8817
+ const request = {
8818
+ sessionId,
8819
+ connection: entry.connection,
8820
+ queue,
8821
+ settled: false
8822
+ };
8823
+ generationRequests.set(requestId, request);
8824
+ const cancel = /* @__PURE__ */ __name(() => {
8825
+ if (request.settled) return;
8826
+ request.settled = true;
8827
+ generationRequests.delete(requestId);
8828
+ queue.close();
8829
+ void entry.connection.extMethod(SERVE_CONTROL_EXT_METHODS.sessionGenerationCancel, {
8830
+ sessionId,
8831
+ requestId
8832
+ }).catch(() => void 0);
8833
+ }, "cancel");
8834
+ signal.addEventListener("abort", cancel, { once: true });
8835
+ if (signal.aborted) {
8836
+ cancel();
8837
+ return queue;
8838
+ }
8839
+ void Promise.race([
8840
+ withTimeout(
8841
+ entry.connection.extMethod(
8842
+ SERVE_CONTROL_EXT_METHODS.sessionGenerationStart,
8843
+ { sessionId, requestId, prompt }
8844
+ ),
8845
+ SESSION_GENERATION_TIMEOUT_MS,
8846
+ SERVE_CONTROL_EXT_METHODS.sessionGenerationStart
8847
+ ),
8848
+ getTransportClosedReject(entry)
8849
+ ]).then((raw) => {
8850
+ if (request.settled) return;
8851
+ const response = raw;
8852
+ const model = response["model"];
8853
+ const modelSource = response["modelSource"];
8854
+ if (typeof model !== "string" || modelSource !== "fast" && modelSource !== "main") {
8855
+ throw new Error("Malformed generation completion");
8856
+ }
8857
+ const accepted = queue.push({
8858
+ type: "done",
8859
+ requestId,
8860
+ model,
8861
+ modelSource,
8862
+ ...typeof response["inputTokens"] === "number" ? { inputTokens: response["inputTokens"] } : {},
8863
+ ...typeof response["outputTokens"] === "number" ? { outputTokens: response["outputTokens"] } : {}
8864
+ });
8865
+ if (accepted) queue.close();
8866
+ else queue.fail(new Error("Generation stream consumer too slow"));
8867
+ }).catch((error) => {
8868
+ if (!request.settled) queue.fail(error);
8869
+ }).finally(() => {
8870
+ request.settled = true;
8871
+ signal.removeEventListener("abort", cancel);
8872
+ generationRequests.delete(requestId);
8873
+ });
8874
+ return queue;
8875
+ },
8248
8876
  getPendingPrompts(sessionId, context) {
8249
8877
  const entry = byId.get(sessionId);
8250
8878
  if (!entry) throw new SessionNotFoundError(sessionId);
@@ -8276,6 +8904,7 @@ function createAcpSessionBridge(opts) {
8276
8904
  try {
8277
8905
  entry.events.publish({
8278
8906
  type: "pending_prompt_completed",
8907
+ promptId,
8279
8908
  data: { sessionId, promptId, state: "removed" },
8280
8909
  ...target.originatorClientId ? { originatorClientId: target.originatorClientId } : {}
8281
8910
  });
@@ -8634,32 +9263,115 @@ function createAcpSessionBridge(opts) {
8634
9263
  };
8635
9264
  },
8636
9265
  async manageMcpServer(serverName, action, originatorClientId) {
8637
- const info = liveChannelInfo();
8638
- if (!info) {
8639
- throw new SessionNotFoundError(`mcp:${serverName}`);
9266
+ const info = await ensureChannel();
9267
+ try {
9268
+ return await withWorkspaceControl(info, async () => {
9269
+ const timeout = action === "authenticate" ? MCP_OAUTH_TIMEOUT_MS : MCP_RESTART_TIMEOUT_MS;
9270
+ const response = await Promise.race([
9271
+ withTimeout(
9272
+ info.connection.extMethod(
9273
+ SERVE_CONTROL_EXT_METHODS.workspaceMcpManage,
9274
+ { serverName, action, originatorClientId }
9275
+ ),
9276
+ timeout,
9277
+ SERVE_CONTROL_EXT_METHODS.workspaceMcpManage
9278
+ ),
9279
+ getChannelClosedReject(info)
9280
+ ]);
9281
+ if (action === "authenticate" && response.pending) {
9282
+ info.workspaceMcpAuthenticationServerNames.add(serverName);
9283
+ const previousTimer = info.workspaceMcpAuthenticationTimers.get(serverName);
9284
+ if (previousTimer) clearTimeout(previousTimer);
9285
+ const timer = setTimeout(() => {
9286
+ info.workspaceMcpAuthenticationServerNames.delete(serverName);
9287
+ info.workspaceMcpAuthenticationTimers.delete(serverName);
9288
+ if (hasNoChannelWork(info)) {
9289
+ void startIdleTimer(
9290
+ info,
9291
+ "workspace MCP authentication timeout"
9292
+ );
9293
+ }
9294
+ }, MCP_OAUTH_TIMEOUT_MS);
9295
+ timer.unref();
9296
+ info.workspaceMcpAuthenticationTimers.set(serverName, timer);
9297
+ }
9298
+ invalidateWorkspaceMcpDetailCache(serverName);
9299
+ await requestWorkspaceStatus(
9300
+ SERVE_STATUS_EXT_METHODS.workspaceMcp,
9301
+ () => {
9302
+ throw new BridgeChannelClosedError(
9303
+ "workspace MCP management status refresh"
9304
+ );
9305
+ },
9306
+ {},
9307
+ /* @__PURE__ */ new Set([serverName])
9308
+ );
9309
+ broadcastWorkspaceEvent({
9310
+ type: "mcp_server_changed",
9311
+ data: {
9312
+ serverName: response.serverName,
9313
+ action: response.action,
9314
+ originatorClientId
9315
+ },
9316
+ ...originatorClientId ? { originatorClientId } : {}
9317
+ });
9318
+ return response;
9319
+ });
9320
+ } finally {
9321
+ if (hasNoChannelWork(info)) {
9322
+ await startIdleTimer(info, "workspace MCP management");
9323
+ }
8640
9324
  }
8641
- const timeout = action === "authenticate" ? MCP_OAUTH_TIMEOUT_MS : MCP_RESTART_TIMEOUT_MS;
8642
- const response = await Promise.race([
8643
- withTimeout(
8644
- info.connection.extMethod(
8645
- SERVE_CONTROL_EXT_METHODS.workspaceMcpManage,
8646
- { serverName, action, originatorClientId }
9325
+ },
9326
+ async initializeWorkspaceMcp() {
9327
+ const info = await ensureChannel();
9328
+ info.workspaceMcpDiscoveryRequested = true;
9329
+ try {
9330
+ const result = await Promise.race([
9331
+ withTimeout(
9332
+ info.connection.extMethod(
9333
+ SERVE_CONTROL_EXT_METHODS.workspaceMcpInitialize,
9334
+ { cwd: boundWorkspace }
9335
+ ),
9336
+ initTimeoutMs,
9337
+ SERVE_CONTROL_EXT_METHODS.workspaceMcpInitialize
8647
9338
  ),
8648
- timeout,
8649
- SERVE_CONTROL_EXT_METHODS.workspaceMcpManage
8650
- ),
8651
- getChannelClosedReject(info)
8652
- ]);
8653
- broadcastWorkspaceEvent({
8654
- type: "mcp_server_changed",
8655
- data: {
8656
- serverName: response.serverName,
8657
- action: response.action,
8658
- originatorClientId
8659
- },
8660
- ...originatorClientId ? { originatorClientId } : {}
8661
- });
8662
- return response;
9339
+ getChannelClosedReject(info)
9340
+ ]);
9341
+ if (result.accepted) {
9342
+ beginWorkspaceMcpDiscovery(info);
9343
+ }
9344
+ return result;
9345
+ } finally {
9346
+ if (hasNoChannelWork(info)) {
9347
+ await startIdleTimer(info, "workspace MCP initialization");
9348
+ }
9349
+ }
9350
+ },
9351
+ async reloadWorkspaceMcp() {
9352
+ const info = await ensureChannel();
9353
+ info.workspaceMcpDiscoveryRequested = true;
9354
+ try {
9355
+ const result = await Promise.race([
9356
+ withTimeout(
9357
+ info.connection.extMethod(
9358
+ SERVE_CONTROL_EXT_METHODS.workspaceMcpReload,
9359
+ { cwd: boundWorkspace }
9360
+ ),
9361
+ initTimeoutMs,
9362
+ SERVE_CONTROL_EXT_METHODS.workspaceMcpReload
9363
+ ),
9364
+ getChannelClosedReject(info)
9365
+ ]);
9366
+ if (result.accepted) {
9367
+ beginWorkspaceMcpDiscovery(info);
9368
+ }
9369
+ return result;
9370
+ } finally {
9371
+ if (hasNoChannelWork(info)) {
9372
+ await startIdleTimer(info, "workspace MCP reload");
9373
+ }
9374
+ }
8663
9375
  },
8664
9376
  async generateWorkspaceAgent(description, _originatorClientId) {
8665
9377
  const info = liveChannelInfo();
@@ -8751,10 +9463,10 @@ function createAcpSessionBridge(opts) {
8751
9463
  },
8752
9464
  async killSession(sessionId, opts2) {
8753
9465
  const entry = byId.get(sessionId);
8754
- if (!entry) return;
9466
+ if (!entry) return false;
8755
9467
  if (opts2?.requireZeroAttaches && entry.attachCount > 0) {
8756
9468
  entry.spawnOwnerWantedKill = true;
8757
- return;
9469
+ return false;
8758
9470
  }
8759
9471
  permissionMediator.forgetSession(sessionId);
8760
9472
  entry.pendingPermissionIds.clear();
@@ -8798,6 +9510,7 @@ function createAcpSessionBridge(opts) {
8798
9510
  await startIdleTimer(ci, `killSession "${sessionId}"`);
8799
9511
  }
8800
9512
  }
9513
+ return true;
8801
9514
  },
8802
9515
  async detachClient(sessionId, clientId) {
8803
9516
  const entry = byId.get(sessionId);
@@ -8908,11 +9621,17 @@ function createAcpSessionBridge(opts) {
8908
9621
  },
8909
9622
  async preheat() {
8910
9623
  if (shuttingDown) return;
8911
- const ci = await ensureChannel();
8912
- const idleMs = resolvedChannelIdleTimeoutMs();
8913
- if (idleMs > 0 && hasNoChannelWork(ci)) {
8914
- await startIdleTimer(ci);
8915
- }
9624
+ await telemetry.withSpan(
9625
+ "channel.preheat",
9626
+ { "qwen-code.daemon.bridge.operation": "channel.preheat" },
9627
+ async () => {
9628
+ const ci = await ensureChannel();
9629
+ const idleMs = resolvedChannelIdleTimeoutMs();
9630
+ if (idleMs > 0 && hasNoChannelWork(ci)) {
9631
+ await startIdleTimer(ci);
9632
+ }
9633
+ }
9634
+ );
8916
9635
  }
8917
9636
  };
8918
9637
  return bridgeApi;
@@ -8935,6 +9654,7 @@ var createHttpAcpBridge = createAcpSessionBridge;
8935
9654
  export {
8936
9655
  SessionArtifactValidationError,
8937
9656
  SessionArtifactAuthorizationError,
9657
+ parseSessionSource,
8938
9658
  extractErrorMessage,
8939
9659
  extractErrorCode,
8940
9660
  classifyTurnErrorKind,