@qwen-code/qwen-code 0.21.10 → 0.21.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/bundled/coordinate/SKILL.md +52 -0
  2. package/bundled/qc-helper/docs/configuration/model-providers.md +10 -8
  3. package/bundled/qc-helper/docs/extension/_meta.ts +1 -0
  4. package/bundled/qc-helper/docs/extension/agent-plugins.md +50 -0
  5. package/bundled/qc-helper/docs/extension/extension-releasing.md +3 -3
  6. package/bundled/qc-helper/docs/extension/introduction.md +17 -3
  7. package/bundled/qc-helper/docs/features/_meta.ts +1 -0
  8. package/bundled/qc-helper/docs/features/arena.md +4 -3
  9. package/bundled/qc-helper/docs/features/commands.md +7 -6
  10. package/bundled/qc-helper/docs/features/dual-output.md +5 -0
  11. package/bundled/qc-helper/docs/features/headless.md +8 -0
  12. package/bundled/qc-helper/docs/features/multi-agent-coordination.md +30 -0
  13. package/bundled/qc-helper/docs/qwen-serve.md +7 -7
  14. package/bundled/review/SKILL.md +17 -7
  15. package/chunks/{MaxSizedBox-FKXYULMW.js → MaxSizedBox-G7QPSZTF.js} +45 -44
  16. package/chunks/{StandaloneSessionPicker-OQS3M7AY.js → StandaloneSessionPicker-3CTEPV7S.js} +65 -64
  17. package/chunks/{acp-startup-profiler-VNTFWYAC.js → acp-startup-profiler-JMJBZDVO.js} +2 -2
  18. package/chunks/{acpAgent-AGS6HLQQ.js → acpAgent-43JURWOW.js} +1107 -285
  19. package/chunks/{agent-4NCVO27U.js → agent-MIY4LJJJ.js} +42 -41
  20. package/chunks/agent-headless-LWVA6GR5.js +87 -0
  21. package/chunks/{anthropicContentGenerator-D3Y4RFT4.js → anthropicContentGenerator-7HEP7Q5D.js} +8 -8
  22. package/chunks/{artifact-tool-N652YE4L.js → artifact-tool-M7UAJ5NT.js} +2 -2
  23. package/chunks/{askUserQuestion-ONW74PKJ.js → askUserQuestion-7G3LI3IZ.js} +2 -2
  24. package/chunks/{bridge-FHINXZMN.js → bridge-PTTJEBNP.js} +47 -46
  25. package/chunks/{ca-ZLKAB4K3.js → ca-4CQ6MYNQ.js} +2 -1
  26. package/chunks/{channel-management-service-PHELKOW2.js → channel-management-service-PQ6SU56M.js} +6 -6
  27. package/chunks/channel-settings-store-IKK34GMH.js +102 -0
  28. package/chunks/{channel-worker-group-WQP4RCDO.js → channel-worker-group-WBRE33ZV.js} +8 -7
  29. package/chunks/{channel-worker-manager-MRDFAKIM.js → channel-worker-manager-V4LYVTPH.js} +8 -7
  30. package/chunks/{channel-worker-supervisor-IVSDIMI4.js → channel-worker-supervisor-YDAGW2RP.js} +6 -5
  31. package/chunks/{chunk-2PLNY5TN.js → chunk-23GFHEM3.js} +4 -4
  32. package/chunks/{chunk-IIJEYBNH.js → chunk-25OFRBH2.js} +188 -58
  33. package/chunks/{chunk-F24A2JBM.js → chunk-2AAFGCWP.js} +690 -151
  34. package/chunks/{chunk-J6SZID63.js → chunk-2AZMF6G5.js} +2 -2
  35. package/chunks/{chunk-6LP743KE.js → chunk-2R2HYSUQ.js} +21 -102
  36. package/chunks/{chunk-DZUO626D.js → chunk-2XZWO53E.js} +3 -3
  37. package/chunks/{chunk-VKJ4KTPJ.js → chunk-3GCU5O2E.js} +1 -1
  38. package/chunks/{chunk-AQAJJMRR.js → chunk-3LHYTQ2R.js} +1 -1
  39. package/chunks/{chunk-QJMOAMXT.js → chunk-3SOTXJNO.js} +8 -8
  40. package/chunks/{chunk-URKIBIFC.js → chunk-45HPDU3F.js} +3 -3
  41. package/chunks/{chunk-OWMAZHIX.js → chunk-47FQVRCO.js} +1 -1
  42. package/chunks/{chunk-Z4JX4NSH.js → chunk-4C4QSXE3.js} +23 -23
  43. package/chunks/{chunk-IRZ2ZH72.js → chunk-4EX3DBFH.js} +4 -4
  44. package/chunks/{chunk-MFDYOYZZ.js → chunk-4MHDNGAV.js} +25 -2
  45. package/chunks/{chunk-ABVRJU3D.js → chunk-4PFKN7CQ.js} +7 -7
  46. package/chunks/{chunk-HV76SFIA.js → chunk-5HBFERG5.js} +3 -3
  47. package/chunks/{chunk-WAUGQKUU.js → chunk-6LYDH7VT.js} +9 -5
  48. package/chunks/{chunk-S6HYI3MF.js → chunk-6S52N6PG.js} +2 -2
  49. package/chunks/{chunk-FVKHVJZQ.js → chunk-732MOPEM.js} +1 -1
  50. package/chunks/{chunk-OCSFNUU4.js → chunk-7QE3QFU3.js} +8 -8
  51. package/chunks/{chunk-WCG5O7IP.js → chunk-7SUQZ7QH.js} +2 -2
  52. package/chunks/{chunk-QG3FFJYU.js → chunk-AAOONL5N.js} +1 -1
  53. package/chunks/{chunk-VSFKIRRW.js → chunk-AKLY5M2C.js} +4 -4
  54. package/chunks/{chunk-UVX4Y6IN.js → chunk-AQHNAA7E.js} +1 -1
  55. package/chunks/{chunk-IBUGFUXC.js → chunk-BIXG46YI.js} +12 -12
  56. package/chunks/{chunk-4TRQPFDP.js → chunk-BJKREW56.js} +6 -8
  57. package/chunks/{chunk-D27I6YJT.js → chunk-BNRNVMOT.js} +27 -18
  58. package/chunks/{chunk-IWTMYQ32.js → chunk-BR6TUEKJ.js} +9 -8
  59. package/chunks/{chunk-Q3JQ7OSU.js → chunk-BTYS2JAY.js} +1 -1
  60. package/chunks/{chunk-H6XPXXMH.js → chunk-CQ35AJ4Z.js} +252 -254
  61. package/chunks/{chunk-COBO5EBO.js → chunk-CTQE2NB2.js} +1 -1
  62. package/chunks/{chunk-P3BJLFSZ.js → chunk-DEKY5Y7V.js} +3 -3
  63. package/chunks/{chunk-Y3OVRWRY.js → chunk-DM4C3OX5.js} +1 -1
  64. package/chunks/{chunk-YWPSGJFI.js → chunk-DSKLWQHC.js} +2 -2
  65. package/chunks/{chunk-KKBPOU75.js → chunk-EFIMD5VA.js} +1 -1
  66. package/chunks/{chunk-CTJLZLB5.js → chunk-EN2J77G7.js} +1 -1
  67. package/chunks/{chunk-67EWJE77.js → chunk-ENEEQMGM.js} +1 -1
  68. package/chunks/{chunk-AEL7KN2O.js → chunk-EOBM4T2Z.js} +1 -1
  69. package/chunks/{chunk-NDU63YLI.js → chunk-ESVSQKPY.js} +4 -4
  70. package/chunks/{chunk-CPG6P4GG.js → chunk-EYS3GGM3.js} +1 -1
  71. package/chunks/{chunk-4PYCZH2V.js → chunk-EYW54TBD.js} +3 -3
  72. package/chunks/{chunk-EBZ6BJTF.js → chunk-F4T5J34H.js} +1 -1
  73. package/chunks/{chunk-FOGU3LJX.js → chunk-F6AOBFUN.js} +1 -1
  74. package/chunks/{chunk-ZBVS26BY.js → chunk-FPGTNKCP.js} +7 -5
  75. package/chunks/{chunk-YF5MALI4.js → chunk-G64M7R2Y.js} +5 -5
  76. package/chunks/{chunk-EI3HZX6C.js → chunk-GJJQV4PY.js} +1 -1
  77. package/chunks/{chunk-CKASRHZI.js → chunk-GLWWPFTW.js} +1 -1
  78. package/chunks/{chunk-GM463R2B.js → chunk-GZGDJ4E6.js} +1 -1
  79. package/chunks/{chunk-W5UC37EE.js → chunk-HHGQGTJQ.js} +2 -0
  80. package/chunks/chunk-HHJLM3WQ.js +41 -0
  81. package/chunks/{chunk-ZRBMO3C7.js → chunk-HMCSRTDY.js} +1 -1
  82. package/chunks/{chunk-L2AFWWJE.js → chunk-HUE2M6VI.js} +50 -5
  83. package/chunks/{chunk-LLCWZQCU.js → chunk-HZV75ET2.js} +3 -3
  84. package/chunks/{chunk-6ZRFAKXK.js → chunk-IEP44U2R.js} +1 -1
  85. package/chunks/{chunk-AOHJKPKL.js → chunk-IQFYO5BF.js} +1 -1
  86. package/chunks/{chunk-UDXSXLER.js → chunk-IW6RQPQB.js} +14 -4
  87. package/chunks/{chunk-XCWO3SMQ.js → chunk-IX7CFQGA.js} +3 -3
  88. package/chunks/{chunk-O3EU6GMH.js → chunk-J4EVBAB3.js} +27 -4
  89. package/chunks/{chunk-ZZCWJWTF.js → chunk-JHMFKJEP.js} +1 -1
  90. package/chunks/{chunk-XVHYA33G.js → chunk-JKEO6OQY.js} +4 -4
  91. package/chunks/{chunk-6Q5ABMTU.js → chunk-JLYYGKRN.js} +23 -19
  92. package/chunks/{chunk-KID7K6H2.js → chunk-JOXXPM3X.js} +6 -6
  93. package/chunks/{chunk-E2FPSSKP.js → chunk-JPA7IDTE.js} +57 -13
  94. package/chunks/{chunk-OQTXYMKW.js → chunk-JS4Q5NG5.js} +3 -3
  95. package/chunks/{chunk-PBRVUF5B.js → chunk-K7JW6V5O.js} +1 -1
  96. package/chunks/{chunk-3P2LV43B.js → chunk-KCCODSAA.js} +3 -3
  97. package/chunks/{chunk-DREZZAZM.js → chunk-KCDQGIHS.js} +13 -5
  98. package/chunks/{chunk-UEOKWYGY.js → chunk-KFCTC5IJ.js} +11 -11
  99. package/chunks/{chunk-M6HMMKVG.js → chunk-KPVVWKF3.js} +1 -1
  100. package/chunks/{chunk-MVUQRLOH.js → chunk-KT4OWAAZ.js} +3 -3
  101. package/chunks/{chunk-W4RQUHY3.js → chunk-L2GTEEEU.js} +142 -23
  102. package/chunks/{chunk-Q3AL4JQ3.js → chunk-LA3FF7RO.js} +2 -2
  103. package/chunks/{chunk-DX3RGJMS.js → chunk-LT532KF4.js} +71 -12
  104. package/chunks/{chunk-JT7XS4YW.js → chunk-M2NMFAFR.js} +1 -1
  105. package/chunks/{chunk-YTFDX4PR.js → chunk-M6NDLY2T.js} +1 -1
  106. package/chunks/{chunk-MIKXJYZB.js → chunk-MCHGE3EC.js} +305 -291
  107. package/chunks/{chunk-Y4R47ZUH.js → chunk-MDQSCFAZ.js} +7 -7
  108. package/chunks/{chunk-EKPKKXY2.js → chunk-MLZCPGDX.js} +1 -1
  109. package/chunks/{chunk-OIVKILPI.js → chunk-MPBRV3UU.js} +3 -0
  110. package/chunks/{chunk-VFMASYQA.js → chunk-MS7GNABG.js} +3 -0
  111. package/chunks/{chunk-2FRY5CRX.js → chunk-MWZYNOCG.js} +3 -3
  112. package/chunks/{chunk-ONSZH6VM.js → chunk-MZQ4I4AP.js} +2 -2
  113. package/chunks/{chunk-UMD7WQTR.js → chunk-N3ZWGKXN.js} +10 -8
  114. package/chunks/{chunk-7MH4J33A.js → chunk-N7NBMAMW.js} +2 -2
  115. package/chunks/{chunk-EUNWC2VS.js → chunk-NC4O6UE6.js} +2 -2
  116. package/chunks/{chunk-A7XMDZRI.js → chunk-NFSSQDB5.js} +5 -5
  117. package/chunks/{chunk-DCZEPFB4.js → chunk-NM3E6GGL.js} +3 -3
  118. package/chunks/{chunk-26CXSA6V.js → chunk-NQPYPDOY.js} +2 -2
  119. package/chunks/{chunk-HUWENAHO.js → chunk-NWPO6I7V.js} +1 -1
  120. package/chunks/{chunk-SR7RZ4MS.js → chunk-O4BBDP2G.js} +2 -2
  121. package/chunks/{chunk-ECWR5LQR.js → chunk-OC5SKSNX.js} +3 -3
  122. package/chunks/{chunk-VWKER4ZH.js → chunk-OGQERNHD.js} +3 -3
  123. package/chunks/{chunk-DA4HRSBW.js → chunk-OPBATTFQ.js} +1 -1
  124. package/chunks/{chunk-OONWZLFK.js → chunk-P7KCJGBR.js} +4 -4
  125. package/chunks/{chunk-OJUQF2PL.js → chunk-PBYVS6QT.js} +3 -3
  126. package/chunks/{chunk-VNNWAZSI.js → chunk-QG2IEE2E.js} +3 -3
  127. package/chunks/{chunk-KZ22NXBY.js → chunk-QGZN4RYB.js} +4 -4
  128. package/chunks/{chunk-2UUMVNYT.js → chunk-QTI7SRXI.js} +3 -3
  129. package/chunks/{chunk-B2GJNDTV.js → chunk-QUESTNOP.js} +1 -1
  130. package/chunks/{chunk-AAE6SR4Q.js → chunk-RUKNJEJO.js} +1 -1
  131. package/chunks/{chunk-NV65ZUVM.js → chunk-RUVZZKDH.js} +1 -1
  132. package/chunks/{chunk-QUI267ZP.js → chunk-SAQHDAUJ.js} +42 -8
  133. package/chunks/{chunk-4MKXUHXY.js → chunk-SUTP6CZA.js} +5 -5
  134. package/chunks/{chunk-UBX6NL47.js → chunk-T4576UW4.js} +3 -3
  135. package/chunks/{chunk-TZEZYNYD.js → chunk-T4FTABSW.js} +1 -1
  136. package/chunks/{chunk-SEZ556DZ.js → chunk-T6W4KACQ.js} +1 -1
  137. package/chunks/chunk-TKAEODJR.js +1279 -0
  138. package/chunks/{chunk-NV3F44FL.js → chunk-TNQLAI6I.js} +2 -2
  139. package/chunks/{chunk-F6WDTQ3M.js → chunk-TNS2M7VL.js} +5 -5
  140. package/chunks/{chunk-7GTMV7UE.js → chunk-TTB6GBJ6.js} +8323 -2227
  141. package/chunks/{chunk-YGT2AUJ7.js → chunk-U2JLICUY.js} +33 -16
  142. package/chunks/{chunk-NEOXOWYH.js → chunk-U7QUDFPD.js} +7 -7
  143. package/chunks/{chunk-QGNOFE5E.js → chunk-UEUE6LJX.js} +1 -1
  144. package/chunks/{chunk-EI3NWELG.js → chunk-UIZGNLBP.js} +4427 -3806
  145. package/chunks/{chunk-ZJ4W6SUY.js → chunk-UM57UTTV.js} +3 -3
  146. package/chunks/{chunk-EQL65XGA.js → chunk-V3LXMASR.js} +47 -21
  147. package/chunks/{chunk-LHEC5V6G.js → chunk-VRWOMUZM.js} +2 -2
  148. package/chunks/{chunk-5MZCSWI4.js → chunk-W2ITCESM.js} +176 -477
  149. package/chunks/{chunk-KONVMRK7.js → chunk-W2PNY24B.js} +1 -1
  150. package/chunks/{chunk-4WL6SY4F.js → chunk-X5GLCWPX.js} +1 -1
  151. package/chunks/{chunk-BSI645OU.js → chunk-XBLYC4MI.js} +3 -3
  152. package/chunks/{chunk-GNPNYXJB.js → chunk-XLQS3VI6.js} +2 -2
  153. package/chunks/{chunk-TRRF5BSP.js → chunk-XT6TGJFD.js} +1 -1
  154. package/chunks/{chunk-PYQADEFD.js → chunk-XTH2OMDS.js} +1 -1
  155. package/chunks/{chunk-47PEPJO7.js → chunk-XUMBOJC2.js} +3 -3
  156. package/chunks/{chunk-GWVUR3QZ.js → chunk-YIKMBYMT.js} +3 -3
  157. package/chunks/{chunk-WOJZWRAZ.js → chunk-YRLW2MSX.js} +1 -1
  158. package/chunks/{chunk-NRLFZWCT.js → chunk-YVVIFFU4.js} +3 -3
  159. package/chunks/chunk-Z7B6SRPM.js +32 -0
  160. package/chunks/{chunk-IA7TGCN2.js → chunk-ZV4XVYL3.js} +4 -4
  161. package/chunks/{chunk-PJRW65JO.js → chunk-ZWPWQEF5.js} +1 -1
  162. package/chunks/{computer-use-WQFK33Z3.js → computer-use-7TIKEXBX.js} +42 -41
  163. package/chunks/{config-utils-ULCSRMWD.js → config-utils-6MVJ54TY.js} +6 -6
  164. package/chunks/{contextCommand-7EOZND7C.js → contextCommand-5QKI7MRY.js} +44 -43
  165. package/chunks/{core-runtime-FGMQRM6E.js → core-runtime-USS7ZF3H.js} +42 -41
  166. package/chunks/{create-sub-session-QIDZUOPU.js → create-sub-session-Y4WYDZGC.js} +2 -2
  167. package/chunks/{create-sub-session-QM2K5HLZ.js → create-sub-session-ZD2F3BH2.js} +42 -41
  168. package/chunks/{cron-create-VONA5JYY.js → cron-create-ZOVA3CC2.js} +4 -4
  169. package/chunks/{cron-delete-5JXSP2MI.js → cron-delete-7Z3H4LJY.js} +4 -4
  170. package/chunks/{cron-list-KE4F2CIR.js → cron-list-UHGX3IQG.js} +4 -4
  171. package/chunks/{daemon-GWD7BT6E.js → daemon-Y3NOHFKQ.js} +38 -7
  172. package/chunks/daemon-status-provider-PMP4J7BC.js +103 -0
  173. package/chunks/daemon-trust-policy-2252VKXI.js +99 -0
  174. package/chunks/{daemon-trust-policy-monitor-6UKEABN5.js → daemon-trust-policy-monitor-OSGGKJXT.js} +49 -48
  175. package/chunks/{de-LIW4XVLN.js → de-UBEBKG6V.js} +2 -1
  176. package/chunks/{deferred-core-runtime-67GJXHXS.js → deferred-core-runtime-3VD4V6YZ.js} +42 -41
  177. package/chunks/{display-image-NQRSIBXM.js → display-image-ZE3GZNIK.js} +4 -4
  178. package/chunks/{dist-Z3CS4OVP.js → dist-AVUYBK7L.js} +11 -5
  179. package/chunks/{dist-6BMOAE3Z.js → dist-BNWP6IZL.js} +4 -4
  180. package/chunks/{dist-3NTTUAHT.js → dist-EFJILGIS.js} +3 -3
  181. package/chunks/{dist-EZE3V3Q7.js → dist-MAIUUIWN.js} +3 -3
  182. package/chunks/{dist-B2CGTW6T.js → dist-NPS52B2V.js} +3 -3
  183. package/chunks/{dist-J47AXBZC.js → dist-PKSRQAR2.js} +3 -3
  184. package/chunks/{dist-OTUO3AS2.js → dist-Q2WJ2IZU.js} +13 -5
  185. package/chunks/{dist-EWW3J4HQ.js → dist-ZWDH5HLS.js} +3 -3
  186. package/chunks/{earlyInputCapture-IWMYR6OB.js → earlyInputCapture-ER4HGLJN.js} +43 -42
  187. package/chunks/{edit-ZFGROCAF.js → edit-B3MT7O53.js} +42 -41
  188. package/chunks/{en-SY5GTIGX.js → en-X6YV7GME.js} +2 -1
  189. package/chunks/{enter-worktree-TZZZCDM5.js → enter-worktree-WVIYVSDJ.js} +42 -41
  190. package/chunks/{enterPlanMode-U77BI3R6.js → enterPlanMode-DDCIM6HA.js} +42 -41
  191. package/chunks/{environment-HC37DS2I.js → environment-LITGMOUP.js} +45 -44
  192. package/chunks/{errors-6AG54JPD.js → errors-E5CIOR2I.js} +44 -43
  193. package/chunks/{exit-worktree-UYYWFPNK.js → exit-worktree-NQ2A6URE.js} +42 -41
  194. package/chunks/exitPlanMode-YXSWN4D3.js +85 -0
  195. package/chunks/{fast-path-F5FSZ3O7.js → fast-path-PH3DBS6X.js} +3 -3
  196. package/chunks/{fast-path-settings-RPAVBD7P.js → fast-path-settings-LNOFM2YP.js} +2 -2
  197. package/chunks/{fr-RQFO7U4P.js → fr-VENTC2BS.js} +2 -1
  198. package/chunks/{gemini-NKQHYM36.js → gemini-4YPO4ADY.js} +88 -87
  199. package/chunks/{geminiContentGenerator-HCWZOUX3.js → geminiContentGenerator-GMSVVXOU.js} +6 -6
  200. package/chunks/{glob-3PDXKBAO.js → glob-3Y3VHLM2.js} +42 -41
  201. package/chunks/{goal-tools-SWNB6GP4.js → goal-tools-JDK2SNMV.js} +4 -4
  202. package/chunks/{grep-5HZKZYVD.js → grep-VUHUDZYG.js} +42 -41
  203. package/chunks/handleAutoUpdate-OBFFPWSJ.js +94 -0
  204. package/chunks/{i18n-Q27KKNDL.js → i18n-4PJA5KKU.js} +43 -42
  205. package/chunks/{image-gen-2Z2RJ6W7.js → image-gen-4IFV4HES.js} +10 -10
  206. package/chunks/initializer-ZTY3VSWL.js +100 -0
  207. package/chunks/{installationInfo-XXB75T7O.js → installationInfo-6USRNCD2.js} +43 -42
  208. package/chunks/{ja-KOZKHJHZ.js → ja-QHT4EQTO.js} +2 -1
  209. package/chunks/{keychain-token-storage-TVAMTNP7.js → keychain-token-storage-JTWUYFU7.js} +2 -2
  210. package/chunks/list-U2ZDKYWN.js +103 -0
  211. package/chunks/{list-agents-Z4WABFDZ.js → list-agents-4GQ2XNEU.js} +2 -2
  212. package/chunks/loadedSettingsAdapter-WW4HIVLO.js +97 -0
  213. package/chunks/{loggingContentGenerator-6NTFBM7Q.js → loggingContentGenerator-XXG6YWUE.js} +46 -27
  214. package/chunks/{loop-wakeup-UZ5RL5Y2.js → loop-wakeup-HOQI3K5D.js} +5 -5
  215. package/chunks/{ls-TVHDGIES.js → ls-O4VBQRG7.js} +4 -4
  216. package/chunks/{lsp-CVN6OQPI.js → lsp-APQJ5ZEZ.js} +2 -2
  217. package/chunks/{managed-npm-update-SPHYQUWZ.js → managed-npm-update-7GM2LPLL.js} +43 -42
  218. package/chunks/mcp-7KZW2T5P.js +97 -0
  219. package/chunks/{monitor-ZBBPAA54.js → monitor-RQROQHLD.js} +42 -41
  220. package/chunks/nonInteractiveCli-U7JNJGS6.js +163 -0
  221. package/chunks/{notebook-edit-5W3FW7Z2.js → notebook-edit-XQA6YCH2.js} +42 -41
  222. package/chunks/{openaiContentGenerator-TQANPEVZ.js → openaiContentGenerator-BZW2IB42.js} +29 -29
  223. package/chunks/{pidfile-EQOBLH4E.js → pidfile-NX5VZ3IK.js} +43 -42
  224. package/chunks/{processUtils-7XQG7EHS.js → processUtils-M635AD23.js} +2 -2
  225. package/chunks/{pt-U6AOCTMF.js → pt-VL3I5RNY.js} +2 -1
  226. package/chunks/{qwenContentGenerator-BKCPHHXU.js → qwenContentGenerator-KHJ73E2C.js} +48 -48
  227. package/chunks/{qwenOAuth2-BJ6PQKE6.js → qwenOAuth2-QMK25XO7.js} +9 -9
  228. package/chunks/read-file-6LKIKKXD.js +32 -0
  229. package/chunks/{read-mcp-resource-PZ4ZF6YL.js → read-mcp-resource-TJSJRH4F.js} +2 -2
  230. package/chunks/{record-artifact-P4HFMS7X.js → record-artifact-FXF5LHPE.js} +3 -3
  231. package/chunks/{resumeHistoryUtils-6N6XGJJW.js → resumeHistoryUtils-RR2KEVH5.js} +49 -48
  232. package/chunks/ripGrep-CF2WRBYV.js +85 -0
  233. package/chunks/{ru-CMX4UMYP.js → ru-4RCKL4PY.js} +2 -1
  234. package/chunks/{run-qwen-serve-BCKBCAMX.js → run-qwen-serve-L5TF57J4.js} +61 -50
  235. package/chunks/{runtime-E2437YKL.js → runtime-3RE3BPR4.js} +55 -54
  236. package/chunks/{scheduler-K3D5Z655.js → scheduler-LXQZAMYT.js} +44 -43
  237. package/chunks/{sdk-exporters-http-XVTZQRCE.js → sdk-exporters-http-7SYSCGEO.js} +3 -3
  238. package/chunks/{sdk-impl-7W7AKCS4.js → sdk-impl-VZI6M6EH.js} +6 -6
  239. package/chunks/{send-message-CAMSLG2L.js → send-message-RBYLV5NY.js} +6 -6
  240. package/chunks/{serve-IH4XR5IL.js → serve-5D4S7GIA.js} +49 -48
  241. package/chunks/{server-UD6INW7J.js → server-ILZB6TTC.js} +403 -178
  242. package/chunks/{session-GR4ZEVW4.js → session-SXCZITZ4.js} +114 -94
  243. package/chunks/{settings-5O24D3OJ.js → settings-4RQB3OVF.js} +48 -47
  244. package/chunks/{shell-UTLWLG5G.js → shell-FCTR3OI2.js} +42 -41
  245. package/chunks/{skill-QQAZL4VO.js → skill-IAKHPD5H.js} +19 -19
  246. package/chunks/{skill-settings-P3YHJVBZ.js → skill-settings-SOR23NOP.js} +48 -47
  247. package/chunks/spawnChannel-I6VAWYQJ.js +98 -0
  248. package/chunks/{standalone-update-QP742MGP.js → standalone-update-5NN3MTYH.js} +44 -43
  249. package/chunks/{startInteractiveUI-YCS6AEPN.js → startInteractiveUI-OYGL3NZJ.js} +590 -329
  250. package/chunks/{syntheticOutput-PEBJQYJV.js → syntheticOutput-D3Z64LJC.js} +3 -3
  251. package/chunks/{task-create-5NWCQSJF.js → task-create-URFZ5EUX.js} +10 -10
  252. package/chunks/{task-list-53265TRZ.js → task-list-6JDFMPUW.js} +5 -5
  253. package/chunks/{task-stop-FPCOIRYX.js → task-stop-HHUGCD25.js} +2 -2
  254. package/chunks/{task-update-5HN577LS.js → task-update-LCJM3EYG.js} +10 -10
  255. package/chunks/{team-create-WFH7OCDQ.js → team-create-J4JP6AXN.js} +44 -43
  256. package/chunks/{team-delete-MMQB4OSC.js → team-delete-PZGGBQLM.js} +5 -5
  257. package/chunks/{team-plan-approval-EGTT53MV.js → team-plan-approval-7BEAIR2H.js} +42 -41
  258. package/chunks/{terminal-image-renderer-BWRESAQ7.js → terminal-image-renderer-SGGTG5LN.js} +44 -43
  259. package/chunks/theme-manager-67TSB7LH.js +89 -0
  260. package/chunks/{todoWrite-JGV6VLOX.js → todoWrite-WINAZSZI.js} +4 -4
  261. package/chunks/{tool-search-TI5PTIBF.js → tool-search-XPOFDWOX.js} +19 -19
  262. package/chunks/{total-session-admission-66UDSOHO.js → total-session-admission-SZJFAM25.js} +47 -46
  263. package/chunks/{trustedFolders-4KYHA4IG.js → trustedFolders-44NTYYV4.js} +43 -42
  264. package/chunks/{update-relaunch-WB6LGIF2.js → update-relaunch-K33Q3WEH.js} +5 -5
  265. package/chunks/{updateCheck-LOS5GYFC.js → updateCheck-VBRNPLS4.js} +45 -44
  266. package/chunks/{useAutoAcceptIndicator-MHAPY52L.js → useAutoAcceptIndicator-AUNRB5S7.js} +52 -51
  267. package/chunks/{validateNonInterActiveAuth-QV22HNQU.js → validateNonInterActiveAuth-WTO36MTA.js} +83 -82
  268. package/chunks/{version-DALWZHKQ.js → version-JZA6HYPI.js} +1 -1
  269. package/chunks/{web-fetch-JMJVMYFE.js → web-fetch-LLHPV2IR.js} +19 -19
  270. package/chunks/{web-search-DNDUIPU5.js → web-search-4HCHRZ3U.js} +11 -11
  271. package/chunks/{workflow-JGNN64PM.js → workflow-YI74QTWW.js} +43 -42
  272. package/chunks/workspace-providers-status-CI3AO2BH.js +100 -0
  273. package/chunks/{workspace-registration-store-LRJG7QA4.js → workspace-registration-store-KPIKXDHA.js} +1 -1
  274. package/chunks/{workspace-registry-KVXIFM36.js → workspace-registry-XE22QDE6.js} +47 -46
  275. package/chunks/{workspace-service-PO4AAKKT.js → workspace-service-WI2FD72A.js} +54 -53
  276. package/chunks/workspace-skills-status-FFZU6FXL.js +100 -0
  277. package/chunks/{workspace-trust-reconciler-DOZPCVHG.js → workspace-trust-reconciler-GJLNXR2U.js} +54 -53
  278. package/chunks/write-file-IEAC3XC3.js +87 -0
  279. package/chunks/{zh-AGL2FVBI.js → zh-LMSTK4WD.js} +2 -1
  280. package/chunks/{zh-TW-KI66MHQY.js → zh-TW-SQ4HTSCW.js} +2 -1
  281. package/chunks/{zoom-image-CNC77ZMA.js → zoom-image-GTVVT25J.js} +15 -15
  282. package/cli.js +13 -13
  283. package/locales/ca.js +1 -0
  284. package/locales/de.js +1 -0
  285. package/locales/en.js +1 -0
  286. package/locales/fr.js +1 -0
  287. package/locales/ja.js +1 -0
  288. package/locales/pt.js +1 -0
  289. package/locales/ru.js +1 -0
  290. package/locales/zh-TW.js +1 -0
  291. package/locales/zh.js +1 -0
  292. package/package.json +3 -3
  293. package/web-shell/assets/{arc-CDk0d60K.js → arc-B13-S0Yo.js} +1 -1
  294. package/web-shell/assets/{architectureDiagram-3BPJPVTR-h-W3I2lP.js → architectureDiagram-3BPJPVTR-CHvWNlVW.js} +1 -1
  295. package/web-shell/assets/{blockDiagram-GPEHLZMM-D1pvSmZg.js → blockDiagram-GPEHLZMM-CXebOlXF.js} +1 -1
  296. package/web-shell/assets/{c4Diagram-AAUBKEIU-ByAm5ZNf.js → c4Diagram-AAUBKEIU-BQpx4y3Q.js} +1 -1
  297. package/web-shell/assets/channel-BB_Hm8Rf.js +1 -0
  298. package/web-shell/assets/{chunk-2J33WTMH-VrGPPOGV.js → chunk-2J33WTMH-Cak1exSv.js} +1 -1
  299. package/web-shell/assets/{chunk-4BX2VUAB-B7hTowgG.js → chunk-4BX2VUAB-BIc8BV5_.js} +1 -1
  300. package/web-shell/assets/{chunk-55IACEB6-j1Fq8DpE.js → chunk-55IACEB6-DoeJ5BL1.js} +1 -1
  301. package/web-shell/assets/{chunk-727SXJPM-UjABYpF2.js → chunk-727SXJPM-BDR_wYSu.js} +1 -1
  302. package/web-shell/assets/{chunk-AQP2D5EJ-D4uBItrs.js → chunk-AQP2D5EJ-BhRRGRq1.js} +1 -1
  303. package/web-shell/assets/{chunk-FMBD7UC4-DeFbKlb8.js → chunk-FMBD7UC4-BJGAwVXr.js} +1 -1
  304. package/web-shell/assets/{chunk-ND2GUHAM-rQJ8TIgT.js → chunk-ND2GUHAM-vhE73bsD.js} +1 -1
  305. package/web-shell/assets/{chunk-QZHKN3VN-DAGcRxvq.js → chunk-QZHKN3VN-BuTBZsdR.js} +1 -1
  306. package/web-shell/assets/classDiagram-4FO5ZUOK-B_hFK54Y.js +1 -0
  307. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-B_hFK54Y.js +1 -0
  308. package/web-shell/assets/{cose-bilkent-S5V4N54A-MaE7MJSt.js → cose-bilkent-S5V4N54A-CVHKipHP.js} +1 -1
  309. package/web-shell/assets/{dagre-BM42HDAG-DzijYGSb.js → dagre-BM42HDAG-C1DPa8SV.js} +1 -1
  310. package/web-shell/assets/{diagram-2AECGRRQ-WdbG7WnX.js → diagram-2AECGRRQ-BYP_QxkT.js} +1 -1
  311. package/web-shell/assets/{diagram-5GNKFQAL-NYutsBnw.js → diagram-5GNKFQAL-Cray7ruQ.js} +1 -1
  312. package/web-shell/assets/{diagram-KO2AKTUF-Dqg0eBY0.js → diagram-KO2AKTUF-Ds4vJANi.js} +1 -1
  313. package/web-shell/assets/{diagram-LMA3HP47-C7vRP2Lb.js → diagram-LMA3HP47-DxFrDykH.js} +1 -1
  314. package/web-shell/assets/{diagram-OG6HWLK6-B2sEPpPt.js → diagram-OG6HWLK6-BdIO-pF_.js} +1 -1
  315. package/web-shell/assets/{erDiagram-TEJ5UH35-a4zIbzm8.js → erDiagram-TEJ5UH35-5JA8KDYV.js} +1 -1
  316. package/web-shell/assets/{flowDiagram-I6XJVG4X-BK9y89ya.js → flowDiagram-I6XJVG4X-DL4drKro.js} +1 -1
  317. package/web-shell/assets/{ganttDiagram-6RSMTGT7-wUQTSNvV.js → ganttDiagram-6RSMTGT7-ijX2DD6_.js} +1 -1
  318. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Dnzt4SAi.js → gitGraphDiagram-PVQCEYII-_lPsFLFF.js} +1 -1
  319. package/web-shell/assets/index-BTwNYZkp.js +1785 -0
  320. package/web-shell/assets/{index-BA3wUcKL.js → index-C-YoqYbs.js} +1 -1
  321. package/web-shell/assets/index-dHAFxPHb.css +5 -0
  322. package/web-shell/assets/{infoDiagram-5YYISTIA-DcaoToij.js → infoDiagram-5YYISTIA-COFClLab.js} +1 -1
  323. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-DzduqhP2.js → ishikawaDiagram-YF4QCWOH-Div9KOgO.js} +1 -1
  324. package/web-shell/assets/{journeyDiagram-JHISSGLW-BvviZR_O.js → journeyDiagram-JHISSGLW-VAw5u0wc.js} +1 -1
  325. package/web-shell/assets/{kanban-definition-UN3LZRKU-Efm2JxY3.js → kanban-definition-UN3LZRKU-CncCn8Nl.js} +1 -1
  326. package/web-shell/assets/{linear-DtY3IbOs.js → linear-D6ad7e_k.js} +1 -1
  327. package/web-shell/assets/{mermaid.core-PzpFqoMe.js → mermaid.core-BV1IECGb.js} +5 -5
  328. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BLlTkHS0.js → mindmap-definition-RKZ34NQL-a3jeNgPr.js} +1 -1
  329. package/web-shell/assets/{pieDiagram-4H26LBE5-D-mKF-jE.js → pieDiagram-4H26LBE5-DsVRY5BW.js} +1 -1
  330. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-DYCzslGm.js → quadrantDiagram-W4KKPZXB-D6zgexJK.js} +1 -1
  331. package/web-shell/assets/{requirementDiagram-4Y6WPE33-Dfpxlk7R.js → requirementDiagram-4Y6WPE33-VEpSwJjn.js} +1 -1
  332. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-D5cRaaxh.js → sankeyDiagram-5OEKKPKP-CYEuOFne.js} +1 -1
  333. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-s04DReiS.js → sequenceDiagram-3UESZ5HK-CCg0lI-9.js} +1 -1
  334. package/web-shell/assets/{stateDiagram-AJRCARHV-01UNFgnb.js → stateDiagram-AJRCARHV-BHXPsL0B.js} +1 -1
  335. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-eTG8D0QT.js +1 -0
  336. package/web-shell/assets/{timeline-definition-PNZ67QCA-DX8_wZBC.js → timeline-definition-PNZ67QCA-gqTf9a0k.js} +1 -1
  337. package/web-shell/assets/{vennDiagram-CIIHVFJN-BK0FlBme.js → vennDiagram-CIIHVFJN-C4DXXkBh.js} +1 -1
  338. package/web-shell/assets/{wardley-L42UT6IY-DkPc9UlD.js → wardley-L42UT6IY-CMK46EiX.js} +1 -1
  339. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-DNKkpDAo.js → wardleyDiagram-YWT4CUSO-DTk1Gzt9.js} +1 -1
  340. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CiPwg8QG.js → xychartDiagram-2RQKCTM6-BcJsM1dH.js} +1 -1
  341. package/web-shell/index.html +2 -2
  342. package/chunks/agent-headless-HYEHZFH6.js +0 -86
  343. package/chunks/channel-settings-store-OXYG5S5X.js +0 -101
  344. package/chunks/chunk-I5VM3SKY.js +0 -451
  345. package/chunks/chunk-PDPFQ2FO.js +0 -156
  346. package/chunks/daemon-status-provider-L3J6GKCT.js +0 -102
  347. package/chunks/daemon-trust-policy-4PHPY23S.js +0 -98
  348. package/chunks/exitPlanMode-RWJR2KGB.js +0 -84
  349. package/chunks/handleAutoUpdate-NHFSGYTF.js +0 -93
  350. package/chunks/initializer-Y5DJLT43.js +0 -99
  351. package/chunks/list-YHNQ32CS.js +0 -102
  352. package/chunks/loadedSettingsAdapter-GHUQK7H4.js +0 -96
  353. package/chunks/mcp-EA3KO6FS.js +0 -96
  354. package/chunks/nonInteractiveCli-NNOR56HU.js +0 -162
  355. package/chunks/read-file-KKTXGIZD.js +0 -32
  356. package/chunks/ripGrep-SJVAAYDV.js +0 -84
  357. package/chunks/spawnChannel-UAQMH6Y6.js +0 -94
  358. package/chunks/theme-manager-ZNDGAHJN.js +0 -88
  359. package/chunks/workspace-providers-status-K22B3Z6B.js +0 -99
  360. package/chunks/workspace-skills-status-DDYCBVSH.js +0 -99
  361. package/chunks/write-file-TT6MWIKC.js +0 -86
  362. package/web-shell/assets/channel-DPFUV4oi.js +0 -1
  363. package/web-shell/assets/classDiagram-4FO5ZUOK-CLm0hVvw.js +0 -1
  364. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CLm0hVvw.js +0 -1
  365. package/web-shell/assets/index-BjC3yjjL.css +0 -5
  366. package/web-shell/assets/index-QzFq6w7o.js +0 -1775
  367. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DXb5olqv.js +0 -1
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-OCPBI7J5.js";
18
18
  import {
19
19
  defaultSpawnChannelFactory
20
- } from "./chunk-I5VM3SKY.js";
20
+ } from "./chunk-TKAEODJR.js";
21
21
  import {
22
22
  BridgeChannelClosedError,
23
23
  BridgeTimeoutError,
@@ -27,7 +27,7 @@ import {
27
27
  SessionRestoreTimeoutError,
28
28
  createIdleWorkspaceExtensionsStatus,
29
29
  createIdleWorkspaceHooksStatus
30
- } from "./chunk-DA4HRSBW.js";
30
+ } from "./chunk-OPBATTFQ.js";
31
31
  import {
32
32
  ACTIVE_WORK_CLOSE_IF_UNHELD_PARAM,
33
33
  ACTIVE_WORK_CLOSE_TIMEOUT_MS,
@@ -43,6 +43,7 @@ import {
43
43
  CHANNEL_STARTUP_PROFILE_VERSION,
44
44
  DAEMON_CHANNEL_DELIVERY_META_KEY,
45
45
  DAEMON_MODEL_PROMPT_META_KEY,
46
+ DAEMON_PROMPT_DISPLAY_TEXT_META_KEY,
46
47
  LOAD_REPLAY_BULK_MODE,
47
48
  LOAD_REPLAY_HIDE_INHERITED_META_KEY,
48
49
  LOAD_REPLAY_META_KEY,
@@ -58,7 +59,7 @@ import {
58
59
  WORKTREE_MCP_DEFER_META_KEY,
59
60
  clampActiveWorkIntervalMs,
60
61
  isValidTrustedModelPrompt
61
- } from "./chunk-W5UC37EE.js";
62
+ } from "./chunk-HHGQGTJQ.js";
62
63
  import {
63
64
  BranchWhilePromptActiveError,
64
65
  BridgeChannelQuarantinedError,
@@ -102,9 +103,10 @@ import {
102
103
  ClientSideConnection,
103
104
  PROTOCOL_VERSION,
104
105
  RequestError
105
- } from "./chunk-UDXSXLER.js";
106
+ } from "./chunk-IW6RQPQB.js";
106
107
  import {
107
108
  SESSION_ARTIFACT_PERSISTENCE_VERSION,
109
+ SESSION_TRANSCRIPT_MAX_LIMIT,
108
110
  ShellExecutionService,
109
111
  TrustGateError,
110
112
  WORKSPACE_CONTENT_MTIME_MS_METADATA_KEY,
@@ -114,16 +116,16 @@ import {
114
116
  metadataBudgetBytes,
115
117
  normalizeSnapshotPayload,
116
118
  stableSessionArtifactId
117
- } from "./chunk-EI3NWELG.js";
119
+ } from "./chunk-UIZGNLBP.js";
118
120
  import {
119
121
  DAEMON_TRACEPARENT_META_KEY,
120
122
  DAEMON_TRACESTATE_META_KEY
121
- } from "./chunk-4TRQPFDP.js";
123
+ } from "./chunk-BJKREW56.js";
122
124
  import {
123
125
  INVOCATION_CONTEXT_META_KEY,
124
126
  PRIVATE_ACP_CAPABILITY_ENV,
125
127
  PRIVATE_PARENT_CAPABILITY_META_KEY
126
- } from "./chunk-YGT2AUJ7.js";
128
+ } from "./chunk-U2JLICUY.js";
127
129
  import {
128
130
  init_esbuild_shims
129
131
  } from "./chunk-5O2XNYP6.js";
@@ -135,6 +137,7 @@ import {
135
137
  init_esbuild_shims();
136
138
  import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
137
139
  import * as path3 from "node:path";
140
+ import { inspect } from "node:util";
138
141
 
139
142
  // packages/acp-bridge/src/compactionEngine.ts
140
143
  init_esbuild_shims();
@@ -5913,6 +5916,12 @@ function isRecord3(value) {
5913
5916
  return typeof value === "object" && value !== null && !Array.isArray(value);
5914
5917
  }
5915
5918
  __name(isRecord3, "isRecord");
5919
+ function safeTransportFailureCode(error) {
5920
+ if (!isRecord3(error)) return void 0;
5921
+ const code = error["code"];
5922
+ return typeof code === "string" && /^[a-z0-9_.-]{1,64}$/iu.test(code) ? code : void 0;
5923
+ }
5924
+ __name(safeTransportFailureCode, "safeTransportFailureCode");
5916
5925
  function sessionSourceRequestMeta(sourceType, sourceId) {
5917
5926
  return sourceType ? {
5918
5927
  [SESSION_SOURCE_META_KEY]: {
@@ -5922,12 +5931,280 @@ function sessionSourceRequestMeta(sourceType, sourceId) {
5922
5931
  } : {};
5923
5932
  }
5924
5933
  __name(sessionSourceRequestMeta, "sessionSourceRequestMeta");
5934
+ function getChannelPromptDisplayText(entry, displayText) {
5935
+ return entry.sourceType === "channel" && typeof displayText === "string" ? displayText : void 0;
5936
+ }
5937
+ __name(getChannelPromptDisplayText, "getChannelPromptDisplayText");
5925
5938
  function isDefinitiveAcpRequestError(error) {
5926
5939
  if (error instanceof RequestError) return true;
5927
5940
  if (!isRecord3(error)) return false;
5928
5941
  return typeof error["code"] === "number" && Number.isInteger(error["code"]) && typeof error["message"] === "string";
5929
5942
  }
5930
5943
  __name(isDefinitiveAcpRequestError, "isDefinitiveAcpRequestError");
5944
+ var LogSafeAcpRequestError = class extends RequestError {
5945
+ constructor(code, message, data, reservePreparedResponse) {
5946
+ super(code, message, data);
5947
+ this.reservePreparedResponse = reservePreparedResponse;
5948
+ }
5949
+ static {
5950
+ __name(this, "LogSafeAcpRequestError");
5951
+ }
5952
+ toResult() {
5953
+ const result = super.toResult();
5954
+ if ("error" in result) {
5955
+ Object.defineProperty(result.error, inspect.custom, {
5956
+ configurable: true,
5957
+ value: /* @__PURE__ */ __name(() => ({ code: result.error.code, payloadOmitted: true }), "value")
5958
+ });
5959
+ try {
5960
+ this.reservePreparedResponse?.(result.error);
5961
+ } catch {
5962
+ }
5963
+ }
5964
+ return result;
5965
+ }
5966
+ };
5967
+ var MAX_LOG_SAFE_ACP_ERROR_DETAILS_CHARS = 1024;
5968
+ var MAX_LOG_SAFE_ACP_ERROR_KIND_CHARS = 128;
5969
+ var MAX_LOG_SAFE_ACP_ERROR_HINT_CHARS = 512;
5970
+ function logSafeAcpErrorDetails(error) {
5971
+ const details = error instanceof Error ? error.message : isRecord3(error) && typeof error["message"] === "string" ? error["message"] : void 0;
5972
+ if (!details) return void 0;
5973
+ return {
5974
+ details: details.length <= MAX_LOG_SAFE_ACP_ERROR_DETAILS_CHARS ? details : `${details.slice(0, MAX_LOG_SAFE_ACP_ERROR_DETAILS_CHARS)}\u2026`
5975
+ };
5976
+ }
5977
+ __name(logSafeAcpErrorDetails, "logSafeAcpErrorDetails");
5978
+ function boundedAcpErrorString(value, maxChars) {
5979
+ return value.length <= maxChars ? value : `${value.slice(0, maxChars)}\u2026`;
5980
+ }
5981
+ __name(boundedAcpErrorString, "boundedAcpErrorString");
5982
+ function logSafeRequestErrorMessage(code) {
5983
+ switch (code) {
5984
+ case -32700:
5985
+ return "Parse error";
5986
+ case -32600:
5987
+ return "Invalid request";
5988
+ case -32601:
5989
+ return "Method not found";
5990
+ case -32602:
5991
+ return "Invalid params";
5992
+ case -32603:
5993
+ return "Internal error";
5994
+ case -32e3:
5995
+ return "Authentication required";
5996
+ case -32002:
5997
+ return "Resource not found";
5998
+ default:
5999
+ return "ACP client request failed";
6000
+ }
6001
+ }
6002
+ __name(logSafeRequestErrorMessage, "logSafeRequestErrorMessage");
6003
+ function logSafeRequestErrorData(data) {
6004
+ if (!isRecord3(data) || typeof data["errorKind"] !== "string") {
6005
+ return void 0;
6006
+ }
6007
+ const status = data["status"];
6008
+ const hint = data["hint"];
6009
+ return {
6010
+ errorKind: boundedAcpErrorString(
6011
+ data["errorKind"],
6012
+ MAX_LOG_SAFE_ACP_ERROR_KIND_CHARS
6013
+ ),
6014
+ ...typeof status === "number" && Number.isFinite(status) ? { status } : {},
6015
+ ...typeof hint === "string" ? {
6016
+ hint: boundedAcpErrorString(hint, MAX_LOG_SAFE_ACP_ERROR_HINT_CHARS)
6017
+ } : {}
6018
+ };
6019
+ }
6020
+ __name(logSafeRequestErrorData, "logSafeRequestErrorData");
6021
+ var AcpInboundHandlerLimitError = class extends Error {
6022
+ constructor(maxActiveHandlers, maxActiveHandlerBytes, requiredBytes, availableBytes) {
6023
+ super("ACP inbound handler capacity exceeded");
6024
+ this.maxActiveHandlers = maxActiveHandlers;
6025
+ this.maxActiveHandlerBytes = maxActiveHandlerBytes;
6026
+ this.requiredBytes = requiredBytes;
6027
+ this.availableBytes = availableBytes;
6028
+ this.name = "AcpInboundHandlerLimitError";
6029
+ }
6030
+ static {
6031
+ __name(this, "AcpInboundHandlerLimitError");
6032
+ }
6033
+ code = "acp_handler_limit_exceeded";
6034
+ };
6035
+ function estimateAcpHandlerBytes(value, limitBytes) {
6036
+ let bytes = 0;
6037
+ const stack = [value];
6038
+ const seen = /* @__PURE__ */ new WeakSet();
6039
+ while (stack.length > 0) {
6040
+ const current = stack.pop();
6041
+ if (current === null) {
6042
+ bytes += 4;
6043
+ } else if (typeof current === "string") {
6044
+ bytes += Buffer.byteLength(current) + 2;
6045
+ } else if (typeof current === "number") {
6046
+ bytes += 24;
6047
+ } else if (typeof current === "boolean") {
6048
+ bytes += 5;
6049
+ } else if (Array.isArray(current)) {
6050
+ if (seen.has(current)) return limitBytes + 1;
6051
+ seen.add(current);
6052
+ bytes += 2 + Math.max(0, current.length - 1);
6053
+ if (bytes + current.length > limitBytes) return limitBytes + 1;
6054
+ for (let index = current.length - 1; index >= 0; index--) {
6055
+ stack.push(current[index]);
6056
+ }
6057
+ } else if (isRecord3(current)) {
6058
+ if (seen.has(current)) return limitBytes + 1;
6059
+ seen.add(current);
6060
+ const entries = Object.entries(current);
6061
+ bytes += 2 + Math.max(0, entries.length - 1);
6062
+ for (const [key, entryValue] of entries) {
6063
+ bytes += Buffer.byteLength(key) + 3;
6064
+ stack.push(entryValue);
6065
+ }
6066
+ } else {
6067
+ bytes += 4;
6068
+ }
6069
+ if (bytes > limitBytes) return limitBytes + 1;
6070
+ }
6071
+ return Math.max(1, bytes);
6072
+ }
6073
+ __name(estimateAcpHandlerBytes, "estimateAcpHandlerBytes");
6074
+ var AcpInboundHandlerAdmission = class {
6075
+ constructor(guard) {
6076
+ this.guard = guard;
6077
+ }
6078
+ static {
6079
+ __name(this, "AcpInboundHandlerAdmission");
6080
+ }
6081
+ activeHandlers = 0;
6082
+ activeBytes = 0;
6083
+ async run(params, operation) {
6084
+ const envelopeBytes = Math.min(2048, this.guard.maxActiveHandlerBytes);
6085
+ const requiredBytes = envelopeBytes + estimateAcpHandlerBytes(
6086
+ params,
6087
+ Math.max(0, this.guard.maxActiveHandlerBytes - envelopeBytes)
6088
+ );
6089
+ const availableBytes = Math.max(
6090
+ 0,
6091
+ this.guard.maxActiveHandlerBytes - this.activeBytes
6092
+ );
6093
+ if (this.activeHandlers >= this.guard.maxActiveHandlers || requiredBytes > availableBytes) {
6094
+ const error = new AcpInboundHandlerLimitError(
6095
+ this.guard.maxActiveHandlers,
6096
+ this.guard.maxActiveHandlerBytes,
6097
+ requiredBytes,
6098
+ availableBytes
6099
+ );
6100
+ this.guard.fail(error);
6101
+ throw error;
6102
+ }
6103
+ this.activeHandlers++;
6104
+ this.activeBytes += requiredBytes;
6105
+ try {
6106
+ return await operation();
6107
+ } finally {
6108
+ this.activeHandlers--;
6109
+ this.activeBytes -= requiredBytes;
6110
+ }
6111
+ }
6112
+ };
6113
+ async function withLogSafeAcpError(operation, reservePreparedResponse) {
6114
+ try {
6115
+ return await operation();
6116
+ } catch (error) {
6117
+ if (error instanceof RequestError) {
6118
+ const code = Number.isFinite(error.code) ? error.code : -32603;
6119
+ throw new LogSafeAcpRequestError(
6120
+ code,
6121
+ logSafeRequestErrorMessage(code),
6122
+ logSafeRequestErrorData(error.data),
6123
+ reservePreparedResponse
6124
+ );
6125
+ }
6126
+ throw new LogSafeAcpRequestError(
6127
+ -32603,
6128
+ "Internal error",
6129
+ logSafeAcpErrorDetails(error),
6130
+ reservePreparedResponse
6131
+ );
6132
+ }
6133
+ }
6134
+ __name(withLogSafeAcpError, "withLogSafeAcpError");
6135
+ function createLogSafeAcpClient(client, transportGuard) {
6136
+ const admission = new AcpInboundHandlerAdmission(transportGuard);
6137
+ const runNotification = /* @__PURE__ */ __name((params, operation) => withLogSafeAcpError(() => admission.run(params, operation)), "runNotification");
6138
+ const runRequest = /* @__PURE__ */ __name((params, operation) => withLogSafeAcpError(
6139
+ () => admission.run(params, async () => {
6140
+ const result = await operation();
6141
+ transportGuard.reservePreparedResponse(result ?? null);
6142
+ return result;
6143
+ }),
6144
+ transportGuard.reservePreparedResponse
6145
+ ), "runRequest");
6146
+ return {
6147
+ requestPermission: /* @__PURE__ */ __name((params) => runRequest(params, () => client.requestPermission(params)), "requestPermission"),
6148
+ sessionUpdate: /* @__PURE__ */ __name((params) => runNotification(params, () => client.sessionUpdate(params)), "sessionUpdate"),
6149
+ writeTextFile: client.writeTextFile ? (params) => runRequest(params, () => client.writeTextFile(params)) : void 0,
6150
+ readTextFile: client.readTextFile ? (params) => runRequest(params, () => client.readTextFile(params)) : void 0,
6151
+ createTerminal: client.createTerminal ? (params) => runRequest(params, () => client.createTerminal(params)) : void 0,
6152
+ terminalOutput: client.terminalOutput ? (params) => runRequest(params, () => client.terminalOutput(params)) : void 0,
6153
+ releaseTerminal: client.releaseTerminal ? (params) => runRequest(
6154
+ params,
6155
+ async () => await client.releaseTerminal(params) ?? {}
6156
+ ) : void 0,
6157
+ waitForTerminalExit: client.waitForTerminalExit ? (params) => runRequest(params, () => client.waitForTerminalExit(params)) : void 0,
6158
+ killTerminal: client.killTerminal ? (params) => runRequest(
6159
+ params,
6160
+ async () => await client.killTerminal(params) ?? {}
6161
+ ) : void 0,
6162
+ extMethod: client.extMethod ? (method, params) => runRequest(params, () => client.extMethod(method, params)) : void 0,
6163
+ extNotification: client.extNotification ? (method, params) => runNotification(params, () => client.extNotification(method, params)) : void 0
6164
+ };
6165
+ }
6166
+ __name(createLogSafeAcpClient, "createLogSafeAcpClient");
6167
+ var OUTBOUND_GUARDED_CONNECTION_METHODS = /* @__PURE__ */ new Set([
6168
+ "initialize",
6169
+ "newSession",
6170
+ "loadSession",
6171
+ "unstable_forkSession",
6172
+ "unstable_listSessions",
6173
+ "unstable_resumeSession",
6174
+ "setSessionMode",
6175
+ "unstable_setSessionModel",
6176
+ "setSessionConfigOption",
6177
+ "authenticate",
6178
+ "prompt",
6179
+ "cancel",
6180
+ "extMethod",
6181
+ "extNotification"
6182
+ ]);
6183
+ function createOutboundGuardedConnection(connection, transportGuard) {
6184
+ const wrappers = /* @__PURE__ */ new Map();
6185
+ return new Proxy(connection, {
6186
+ get(target, property) {
6187
+ const value = Reflect.get(target, property, target);
6188
+ if (typeof value !== "function" || !OUTBOUND_GUARDED_CONNECTION_METHODS.has(property)) {
6189
+ return value;
6190
+ }
6191
+ let wrapper = wrappers.get(property);
6192
+ if (!wrapper) {
6193
+ wrapper = /* @__PURE__ */ __name(async (...args) => {
6194
+ const release = transportGuard.reserveOutboundOperation(args);
6195
+ try {
6196
+ return await Reflect.apply(value, target, args);
6197
+ } finally {
6198
+ release();
6199
+ }
6200
+ }, "wrapper");
6201
+ wrappers.set(property, wrapper);
6202
+ }
6203
+ return wrapper;
6204
+ }
6205
+ });
6206
+ }
6207
+ __name(createOutboundGuardedConnection, "createOutboundGuardedConnection");
5931
6208
  function getCanonicalModelId(response, fallback) {
5932
6209
  if (!isRecord3(response) || !isRecord3(response["_meta"])) return fallback;
5933
6210
  const modelSwitch = response["_meta"]["qwenModelSwitch"];
@@ -6134,14 +6411,27 @@ function pickUserInputEchoMeta(meta) {
6134
6411
  return Array.isArray(inputAnnotations) ? { inputAnnotations } : {};
6135
6412
  }
6136
6413
  __name(pickUserInputEchoMeta, "pickUserInputEchoMeta");
6137
- function echoPromptToSessionBus(entry, req, promptId, originatorClientId) {
6414
+ function echoPromptToSessionBus(entry, req, promptId, originatorClientId, displayText) {
6138
6415
  const prompt = req.prompt;
6139
6416
  if (!Array.isArray(prompt) || prompt.length === 0) return;
6417
+ let displayTextPublished = false;
6140
6418
  const serverTimestamp = Date.now();
6141
- const blockCount = Math.min(prompt.length, MAX_ECHO_CONTENT_BLOCKS);
6419
+ const echoPrompt = prompt.slice(0, MAX_ECHO_CONTENT_BLOCKS);
6420
+ if (displayText && !echoPrompt.some((part) => isRecord3(part) && part["type"] === "text")) {
6421
+ const textPart = prompt.slice(MAX_ECHO_CONTENT_BLOCKS).find((part) => isRecord3(part) && part["type"] === "text");
6422
+ if (textPart) echoPrompt[echoPrompt.length - 1] = textPart;
6423
+ }
6424
+ const blockCount = echoPrompt.length;
6142
6425
  for (let i = 0; i < blockCount; i += 1) {
6143
- const part = prompt[i];
6426
+ const part = echoPrompt[i];
6144
6427
  if (!part || typeof part !== "object" || Array.isArray(part)) continue;
6428
+ let displayPart = part;
6429
+ if (displayText !== void 0 && part.type === "text") {
6430
+ if (displayTextPublished) continue;
6431
+ displayTextPublished = true;
6432
+ if (!displayText) continue;
6433
+ displayPart = { ...part, text: displayText };
6434
+ }
6145
6435
  try {
6146
6436
  entry.events.publish({
6147
6437
  type: "session_update",
@@ -6150,7 +6440,7 @@ function echoPromptToSessionBus(entry, req, promptId, originatorClientId) {
6150
6440
  sessionId: req.sessionId,
6151
6441
  update: {
6152
6442
  sessionUpdate: "user_message_chunk",
6153
- content: part,
6443
+ content: displayPart,
6154
6444
  // `_meta` lives inside the `update` object rather than at
6155
6445
  // envelope level. `_meta` is a standard JSON-RPC/MCP extension
6156
6446
  // field permitted alongside spec fields, the SDK normalizer
@@ -6717,6 +7007,14 @@ function createAcpSessionBridge(opts) {
6717
7007
  }
6718
7008
  }
6719
7009
  __name(cancelIdleTimer, "cancelIdleTimer");
7010
+ function channelUnavailableReject(channel, context) {
7011
+ const unavailable = channel.transportFailed ? Promise.race([channel.exited, channel.transportFailed]) : channel.exited;
7012
+ const reject = /* @__PURE__ */ __name(() => {
7013
+ throw new BridgeChannelClosedError(context);
7014
+ }, "reject");
7015
+ return unavailable.then(reject, reject);
7016
+ }
7017
+ __name(channelUnavailableReject, "channelUnavailableReject");
6720
7018
  async function killChannelWithLog(ci, context) {
6721
7019
  ci.isDying = true;
6722
7020
  await ci.channel.kill().catch((err) => {
@@ -6923,6 +7221,14 @@ function createAcpSessionBridge(opts) {
6923
7221
  const generationRequests = /* @__PURE__ */ new Map();
6924
7222
  const workspaceGenerationRequests = /* @__PURE__ */ new Map();
6925
7223
  const inFlightExtensionRefreshes = /* @__PURE__ */ new Map();
7224
+ const clearInFlightExtensionRefreshes = /* @__PURE__ */ __name((connection) => {
7225
+ for (const [sessionId, refresh] of inFlightExtensionRefreshes) {
7226
+ if (refresh.connection === connection) {
7227
+ refresh.rejectUnavailable();
7228
+ inFlightExtensionRefreshes.delete(sessionId);
7229
+ }
7230
+ }
7231
+ }, "clearInFlightExtensionRefreshes");
6926
7232
  const toSessionSummary = /* @__PURE__ */ __name((entry) => {
6927
7233
  let isWaitingForPermission = false;
6928
7234
  let isWaitingForUserQuestion = false;
@@ -7171,7 +7477,14 @@ function createAcpSessionBridge(opts) {
7171
7477
  applyActiveWorkSnapshot(currentInfo, snapshot);
7172
7478
  }
7173
7479
  );
7174
- connection = new ClientSideConnection(() => client, channel.stream);
7480
+ const rawConnection = new ClientSideConnection(
7481
+ () => channel.transportGuard ? createLogSafeAcpClient(client, channel.transportGuard) : client,
7482
+ channel.stream
7483
+ );
7484
+ connection = channel.transportGuard ? createOutboundGuardedConnection(
7485
+ rawConnection,
7486
+ channel.transportGuard
7487
+ ) : rawConnection;
7175
7488
  } catch (error) {
7176
7489
  try {
7177
7490
  channel.killSync();
@@ -7207,11 +7520,26 @@ function createAcpSessionBridge(opts) {
7207
7520
  unsettledAbandonedRestores: /* @__PURE__ */ new Set(),
7208
7521
  restoreSettlementOverdue: false,
7209
7522
  restoreSettlementTimers: /* @__PURE__ */ new Map(),
7523
+ transportFailed: false,
7524
+ transportFailureInitiatedTeardown: false,
7210
7525
  isDying: false,
7211
7526
  isQuarantined: false,
7212
7527
  handshakeComplete: false
7213
7528
  };
7214
7529
  infoRef.current = info;
7530
+ const markTransportFailed = /* @__PURE__ */ __name((error) => {
7531
+ if (!info.isDying) {
7532
+ info.transportFailureInitiatedTeardown = true;
7533
+ }
7534
+ info.transportFailed = true;
7535
+ info.transportFailureCode = safeTransportFailureCode(error);
7536
+ info.isDying = true;
7537
+ clearInFlightExtensionRefreshes(info.connection);
7538
+ }, "markTransportFailed");
7539
+ void channel.transportFailed?.then(
7540
+ markTransportFailed,
7541
+ markTransportFailed
7542
+ );
7215
7543
  aliveChannels.add(info);
7216
7544
  if (aliveChannels.size > 2) {
7217
7545
  writeStderrLine(
@@ -7219,6 +7547,7 @@ function createAcpSessionBridge(opts) {
7219
7547
  );
7220
7548
  }
7221
7549
  void channel.exited.then((exitInfo) => {
7550
+ clearInFlightExtensionRefreshes(info.connection);
7222
7551
  if (channelInfo === info) cancelIdleTimer();
7223
7552
  if (info.workspaceMcpDiscoveryTimer) {
7224
7553
  clearTimeout(info.workspaceMcpDiscoveryTimer);
@@ -7237,7 +7566,7 @@ function createAcpSessionBridge(opts) {
7237
7566
  if (channelInfo === info) channelInfo = void 0;
7238
7567
  const sessions = Array.from(info.sessionIds);
7239
7568
  info.sessionIds.clear();
7240
- const channelExitExpected = shuttingDown || info.isDying;
7569
+ const channelExitExpected = shuttingDown || info.isDying && !info.transportFailureInitiatedTeardown;
7241
7570
  if (info.handshakeComplete) {
7242
7571
  telemetry.metrics?.channelLifecycle("exit", channelExitExpected);
7243
7572
  }
@@ -7245,10 +7574,15 @@ function createAcpSessionBridge(opts) {
7245
7574
  telemetry.event("channel.exited", {
7246
7575
  "qwen-code.daemon.channel.exit_code": exitInfo?.exitCode ?? -1,
7247
7576
  "qwen-code.daemon.channel.session_count": sessions.length,
7577
+ "qwen-code.daemon.channel.transport_failed": info.transportFailed,
7578
+ "qwen-code.daemon.channel.transport_failure_initiated_teardown": info.transportFailureInitiatedTeardown,
7579
+ ...info.transportFailureCode ? {
7580
+ "qwen-code.daemon.channel.transport_error_code": info.transportFailureCode
7581
+ } : {},
7248
7582
  ...exitInfo?.signalCode ? { "qwen-code.daemon.channel.signal": exitInfo.signalCode } : {}
7249
7583
  });
7250
7584
  writeStderrLine(
7251
- `qwen serve: channel exited (code=${exitInfo?.exitCode ?? "none"}, signal=${exitInfo?.signalCode ?? "none"}, ${sessions.length} session(s) torn down)`
7585
+ `qwen serve: channel exited (code=${exitInfo?.exitCode ?? "none"}, signal=${exitInfo?.signalCode ?? "none"}, transport=${info.transportFailed ? info.transportFailureCode ?? "failed" : "ok"}, ${sessions.length} session(s) torn down)`
7252
7586
  );
7253
7587
  }
7254
7588
  for (const sid of sessions) {
@@ -7300,26 +7634,29 @@ function createAcpSessionBridge(opts) {
7300
7634
  },
7301
7635
  async () => {
7302
7636
  const response = await withTimeout(
7303
- connection.initialize({
7304
- protocolVersion: PROTOCOL_VERSION,
7305
- _meta: {
7306
- [ACTIVE_WORK_HEARTBEAT_META_KEY]: {
7307
- v: ACTIVE_WORK_HEARTBEAT_VERSION,
7308
- intervalMs: ACTIVE_WORK_HEARTBEAT_INTERVAL_MS
7637
+ Promise.race([
7638
+ connection.initialize({
7639
+ protocolVersion: PROTOCOL_VERSION,
7640
+ _meta: {
7641
+ [ACTIVE_WORK_HEARTBEAT_META_KEY]: {
7642
+ v: ACTIVE_WORK_HEARTBEAT_VERSION,
7643
+ intervalMs: ACTIVE_WORK_HEARTBEAT_INTERVAL_MS
7644
+ },
7645
+ [CHANNEL_STARTUP_PROFILE_META_KEY]: {
7646
+ v: CHANNEL_STARTUP_PROFILE_VERSION
7647
+ },
7648
+ [PRIVATE_PARENT_CAPABILITY_META_KEY]: privateParentCapability
7309
7649
  },
7310
- [CHANNEL_STARTUP_PROFILE_META_KEY]: {
7311
- v: CHANNEL_STARTUP_PROFILE_VERSION
7650
+ clientCapabilities: {
7651
+ fs: {
7652
+ readTextFile: delegateReadTextFileToClient,
7653
+ writeTextFile: true
7654
+ }
7312
7655
  },
7313
- [PRIVATE_PARENT_CAPABILITY_META_KEY]: privateParentCapability
7314
- },
7315
- clientCapabilities: {
7316
- fs: {
7317
- readTextFile: delegateReadTextFileToClient,
7318
- writeTextFile: true
7319
- }
7320
- },
7321
- clientInfo: { name: "qwen-serve-bridge", version: "0" }
7322
- }),
7656
+ clientInfo: { name: "qwen-serve-bridge", version: "0" }
7657
+ }),
7658
+ channelUnavailableReject(channel, "during initialize")
7659
+ ]),
7323
7660
  initTimeoutMs,
7324
7661
  "initialize"
7325
7662
  );
@@ -7364,6 +7701,11 @@ function createAcpSessionBridge(opts) {
7364
7701
  });
7365
7702
  throw err;
7366
7703
  }
7704
+ if (info.isDying) {
7705
+ await channel.kill().catch(() => {
7706
+ });
7707
+ throw new BridgeChannelClosedError("during initialize");
7708
+ }
7367
7709
  if (shuttingDown) {
7368
7710
  info.isDying = true;
7369
7711
  await channel.kill().catch(() => {
@@ -7393,6 +7735,9 @@ function createAcpSessionBridge(opts) {
7393
7735
  },
7394
7736
  ensureChannel
7395
7737
  );
7738
+ if (ci.isDying) {
7739
+ throw new BridgeChannelClosedError("before newSession");
7740
+ }
7396
7741
  ci.sessionSpawnsInFlight++;
7397
7742
  if (requestedSessionId !== void 0) {
7398
7743
  ci.client.markSessionRegistrationInFlight(requestedSessionId);
@@ -7425,15 +7770,18 @@ function createAcpSessionBridge(opts) {
7425
7770
  } : {}
7426
7771
  });
7427
7772
  const response = await withTimeout(
7428
- ci.connection.newSession(
7429
- worktree ? {
7430
- ...request,
7431
- _meta: {
7432
- ...isRecord3(request._meta) ? request._meta : {},
7433
- [WORKTREE_MCP_DEFER_META_KEY]: true
7434
- }
7435
- } : request
7436
- ),
7773
+ Promise.race([
7774
+ ci.connection.newSession(
7775
+ worktree ? {
7776
+ ...request,
7777
+ _meta: {
7778
+ ...isRecord3(request._meta) ? request._meta : {},
7779
+ [WORKTREE_MCP_DEFER_META_KEY]: true
7780
+ }
7781
+ } : request
7782
+ ),
7783
+ channelUnavailableReject(ci.channel, "during newSession")
7784
+ ]),
7437
7785
  initTimeoutMs,
7438
7786
  "newSession"
7439
7787
  );
@@ -7454,6 +7802,10 @@ function createAcpSessionBridge(opts) {
7454
7802
  }
7455
7803
  throw err;
7456
7804
  }
7805
+ await Promise.resolve();
7806
+ if (ci.isDying) {
7807
+ throw new BridgeChannelClosedError("after newSession");
7808
+ }
7457
7809
  if (shuttingDown) {
7458
7810
  throw new Error("AcpSessionBridge is shutting down");
7459
7811
  }
@@ -7772,13 +8124,25 @@ function createAcpSessionBridge(opts) {
7772
8124
  __name(applyApprovalMode, "applyApprovalMode");
7773
8125
  async function applyApprovalModeForAttach(entry, mode, clientId) {
7774
8126
  try {
7775
- await applyApprovalMode(entry, mode, false, clientId);
8127
+ const result = await applyApprovalMode(entry, mode, false, clientId);
8128
+ return result.previous;
7776
8129
  } catch (err) {
7777
8130
  await rollbackAttachRegistration(entry, clientId);
7778
8131
  throw err;
7779
8132
  }
7780
8133
  }
7781
8134
  __name(applyApprovalModeForAttach, "applyApprovalModeForAttach");
8135
+ async function rollbackApprovalModeForRejectedAttach(entry, previous, clientId) {
8136
+ if (byId.get(entry.sessionId) !== entry) return;
8137
+ try {
8138
+ await applyApprovalMode(entry, previous, false, clientId);
8139
+ } catch (err) {
8140
+ writeStderrLine(
8141
+ `attach: failed to restore approval mode for session ${entry.sessionId}: ${extractErrorMessage(err)}`
8142
+ );
8143
+ }
8144
+ }
8145
+ __name(rollbackApprovalModeForRejectedAttach, "rollbackApprovalModeForRejectedAttach");
7782
8146
  const cancelPendingForSession = /* @__PURE__ */ __name((sessionId) => {
7783
8147
  permissionMediator.forgetSession(sessionId);
7784
8148
  byId.get(sessionId)?.pendingPermissionIds.clear();
@@ -7786,11 +8150,10 @@ function createAcpSessionBridge(opts) {
7786
8150
  }, "cancelPendingForSession");
7787
8151
  const getTransportClosedReject = /* @__PURE__ */ __name((entry) => {
7788
8152
  if (!entry.transportClosedReject) {
7789
- entry.transportClosedReject = entry.channel.exited.then(() => {
7790
- throw new BridgeChannelClosedError(
7791
- `mid-request (session ${entry.sessionId})`
7792
- );
7793
- });
8153
+ entry.transportClosedReject = channelUnavailableReject(
8154
+ entry.channel,
8155
+ `mid-request (session ${entry.sessionId})`
8156
+ );
7794
8157
  }
7795
8158
  return entry.transportClosedReject;
7796
8159
  }, "getTransportClosedReject");
@@ -7818,6 +8181,28 @@ function createAcpSessionBridge(opts) {
7818
8181
  }
7819
8182
  return void 0;
7820
8183
  }, "channelInfoForEntry");
8184
+ const assertAttachableSessionEntry = /* @__PURE__ */ __name((sessionId, entry) => {
8185
+ if (byId.get(sessionId) !== entry) {
8186
+ throw new SessionNotFoundError(
8187
+ sessionId,
8188
+ "The session channel is unavailable; retry after teardown completes"
8189
+ );
8190
+ }
8191
+ if (isClosingOrAuthorizingClose(entry)) {
8192
+ throw new SessionNotFoundError(
8193
+ sessionId,
8194
+ "The session is closing; retry after close completes",
8195
+ "session_closing"
8196
+ );
8197
+ }
8198
+ const owner = channelInfoForEntry(entry);
8199
+ if (!owner || owner.isDying) {
8200
+ throw new SessionNotFoundError(
8201
+ sessionId,
8202
+ "The session channel is unavailable; retry after teardown completes"
8203
+ );
8204
+ }
8205
+ }, "assertAttachableSessionEntry");
7821
8206
  const assertLivePromptEntry = /* @__PURE__ */ __name((sessionId, entry) => {
7822
8207
  const info = channelInfoForEntry(entry);
7823
8208
  if (byId.get(sessionId) !== entry || !info || info.isDying) {
@@ -7826,9 +8211,10 @@ function createAcpSessionBridge(opts) {
7826
8211
  }, "assertLivePromptEntry");
7827
8212
  const getChannelClosedReject = /* @__PURE__ */ __name((info) => {
7828
8213
  if (!info.statusClosedReject) {
7829
- info.statusClosedReject = info.channel.exited.then(() => {
7830
- throw new BridgeChannelClosedError("mid-request (workspace status)");
7831
- });
8214
+ info.statusClosedReject = channelUnavailableReject(
8215
+ info.channel,
8216
+ "mid-request (workspace status)"
8217
+ );
7832
8218
  }
7833
8219
  return info.statusClosedReject;
7834
8220
  }, "getChannelClosedReject");
@@ -8039,7 +8425,7 @@ function createAcpSessionBridge(opts) {
8039
8425
  `ACP session close channel unavailable for ${entry.sessionId}`
8040
8426
  );
8041
8427
  }
8042
- return;
8428
+ return false;
8043
8429
  }
8044
8430
  try {
8045
8431
  const closeRequest = entry.connection.extMethod(
@@ -8051,7 +8437,7 @@ function createAcpSessionBridge(opts) {
8051
8437
  }
8052
8438
  );
8053
8439
  const observedCloseRequest = opts2?.timeoutMs ? withTimeout(closeRequest, opts2.timeoutMs, label) : closeRequest;
8054
- await Promise.race([
8440
+ const response = await Promise.race([
8055
8441
  opts2?.throwOnFailure === true ? observedCloseRequest : withTimeout(
8056
8442
  observedCloseRequest,
8057
8443
  initTimeoutMs,
@@ -8059,6 +8445,7 @@ function createAcpSessionBridge(opts) {
8059
8445
  ),
8060
8446
  getTransportClosedReject(entry)
8061
8447
  ]);
8448
+ return response["closed"] === true;
8062
8449
  } catch (err) {
8063
8450
  writeStderrLine(
8064
8451
  `qwen serve: ${label} ACP session close notification failed for session ${JSON.stringify(entry.sessionId)}: ${String(
@@ -8068,6 +8455,7 @@ function createAcpSessionBridge(opts) {
8068
8455
  if (opts2?.throwOnFailure === true) {
8069
8456
  throw err;
8070
8457
  }
8458
+ return false;
8071
8459
  }
8072
8460
  }, "notifyAgentSessionClose");
8073
8461
  const broadcastWorkspaceEvent = /* @__PURE__ */ __name((envelope, skipSessionId) => {
@@ -8492,6 +8880,7 @@ function createAcpSessionBridge(opts) {
8492
8880
  for (let attempt = 0; attempt < 2; attempt++) {
8493
8881
  try {
8494
8882
  const lastEventId = entry.events.lastEventId;
8883
+ const eventEpoch = entry.events.epoch;
8495
8884
  const seenCursors = /* @__PURE__ */ new Set();
8496
8885
  let emptyPageCount = 0;
8497
8886
  let cursor;
@@ -8512,11 +8901,12 @@ function createAcpSessionBridge(opts) {
8512
8901
  cursor = nextCursor;
8513
8902
  if (cursor !== void 0) seenCursors.add(cursor);
8514
8903
  } while (page.events.length === 0 && page.hasMore && cursor !== void 0 && page.partial !== true && page.replayError === void 0);
8515
- if (byId.get(entry.sessionId) === entry && !entry.promptActive && entry.events.lastEventId === lastEventId) {
8904
+ if (byId.get(entry.sessionId) === entry && !entry.promptActive && entry.events.epoch === eventEpoch && entry.events.lastEventId === lastEventId) {
8516
8905
  return {
8517
8906
  compactedReplay: page.events,
8518
8907
  liveJournal: [],
8519
8908
  lastEventId,
8909
+ eventEpoch,
8520
8910
  ...page.partial === true ? { partial: true } : {},
8521
8911
  ...page.replayError !== void 0 ? { replayError: page.replayError } : {},
8522
8912
  ...page.hasMore ? { historyHasMore: true } : {}
@@ -8580,33 +8970,39 @@ function createAcpSessionBridge(opts) {
8580
8970
  );
8581
8971
  }
8582
8972
  const historyReplay = action === "load" ? req.historyReplay ?? "stream" : "stream";
8973
+ const historyPageSize = action === "load" && historyReplay === "response" ? req.historyPageSize : void 0;
8974
+ if (historyPageSize !== void 0 && (!Number.isSafeInteger(historyPageSize) || historyPageSize < 1 || historyPageSize > SESSION_TRANSCRIPT_MAX_LIMIT)) {
8975
+ throw new Error(
8976
+ `Invalid historyPageSize; expected 1..${SESSION_TRANSCRIPT_MAX_LIMIT}`
8977
+ );
8978
+ }
8583
8979
  const hideInheritedHistory = action === "load" && req.hideInheritedHistory === true;
8584
8980
  const existing = byId.get(req.sessionId);
8585
8981
  if (existing) {
8586
- if (isClosingOrAuthorizingClose(existing)) {
8587
- throw new SessionNotFoundError(
8588
- req.sessionId,
8589
- "The session is closing; retry after close completes",
8590
- "session_closing"
8591
- );
8592
- }
8593
- const replayFields = action === "load" && req.historyPageSize !== void 0 ? await refreshedReplayFieldsFor(existing, req.historyPageSize) : replayFieldsFor(existing, action);
8982
+ assertAttachableSessionEntry(req.sessionId, existing);
8983
+ const replayFields = historyPageSize !== void 0 ? await refreshedReplayFieldsFor(existing, historyPageSize) : replayFieldsFor(existing, action);
8594
8984
  const historyAnchorRecordId = action === "load" ? await resolveHistoryAnchorRecordId(existing, replayFields) : void 0;
8595
- if (byId.get(req.sessionId) !== existing) {
8596
- throw new SessionNotFoundError(req.sessionId);
8597
- }
8598
- if (isClosingOrAuthorizingClose(existing)) {
8599
- throw new SessionNotFoundError(
8600
- req.sessionId,
8601
- "The session is closing; retry after close completes",
8602
- "session_closing"
8603
- );
8604
- }
8985
+ assertAttachableSessionEntry(req.sessionId, existing);
8605
8986
  existing.attachCount++;
8606
8987
  const clientId = registerClient(existing, req.clientId);
8607
8988
  recordAttachRef(existing, clientId);
8608
8989
  if (req.approvalMode) {
8609
- await applyApprovalModeForAttach(existing, req.approvalMode, clientId);
8990
+ const previousApprovalMode = await applyApprovalModeForAttach(
8991
+ existing,
8992
+ req.approvalMode,
8993
+ clientId
8994
+ );
8995
+ try {
8996
+ assertAttachableSessionEntry(req.sessionId, existing);
8997
+ } catch (error) {
8998
+ await rollbackApprovalModeForRejectedAttach(
8999
+ existing,
9000
+ previousApprovalMode,
9001
+ clientId
9002
+ );
9003
+ await rollbackAttachRegistration(existing, clientId);
9004
+ throw error;
9005
+ }
8610
9006
  }
8611
9007
  return {
8612
9008
  sessionId: existing.sessionId,
@@ -8630,7 +9026,7 @@ function createAcpSessionBridge(opts) {
8630
9026
  }
8631
9027
  const inFlight = inFlightRestores.get(req.sessionId);
8632
9028
  if (inFlight) {
8633
- if (inFlight.lifecycle.phase === "abandoned" || action !== inFlight.action || historyReplay !== inFlight.historyReplay || hideInheritedHistory !== inFlight.hideInheritedHistory) {
9029
+ if (inFlight.lifecycle.phase === "abandoned" || action !== inFlight.action || historyReplay !== inFlight.historyReplay || historyPageSize !== inFlight.historyPageSize || hideInheritedHistory !== inFlight.hideInheritedHistory) {
8634
9030
  const abandoned = inFlight.lifecycle.phase === "abandoned";
8635
9031
  throw new RestoreInProgressError(
8636
9032
  req.sessionId,
@@ -8658,10 +9054,32 @@ function createAcpSessionBridge(opts) {
8658
9054
  "the agent child likely crashed during session restore \u2014 retry to restore the session"
8659
9055
  );
8660
9056
  }
9057
+ try {
9058
+ assertAttachableSessionEntry(restored.sessionId, entry);
9059
+ } catch (error) {
9060
+ inFlight.coalesceState.count--;
9061
+ entry.attachCount = Math.max(0, entry.attachCount - 1);
9062
+ throw error;
9063
+ }
8661
9064
  const clientId = registerClient(entry, req.clientId);
8662
9065
  recordAttachRef(entry, clientId);
8663
9066
  if (req.approvalMode) {
8664
- await applyApprovalModeForAttach(entry, req.approvalMode, clientId);
9067
+ const previousApprovalMode = await applyApprovalModeForAttach(
9068
+ entry,
9069
+ req.approvalMode,
9070
+ clientId
9071
+ );
9072
+ try {
9073
+ assertAttachableSessionEntry(restored.sessionId, entry);
9074
+ } catch (error) {
9075
+ await rollbackApprovalModeForRejectedAttach(
9076
+ entry,
9077
+ previousApprovalMode,
9078
+ clientId
9079
+ );
9080
+ await rollbackAttachRegistration(entry, clientId);
9081
+ throw error;
9082
+ }
8665
9083
  }
8666
9084
  return {
8667
9085
  ...restored,
@@ -8825,12 +9243,16 @@ function createAcpSessionBridge(opts) {
8825
9243
  const promise = (async () => {
8826
9244
  pendingRestoreEvents.set(req.sessionId, restoreEvents);
8827
9245
  const restoreChannel = await ensureChannel();
9246
+ if (restoreChannel.isDying) {
9247
+ throw new BridgeChannelClosedError(`before session/${action}`);
9248
+ }
8828
9249
  ci = restoreChannel;
8829
9250
  restoreChannel.pendingRestoreIds.add(req.sessionId);
8830
9251
  restoreChannel.client.markRestoreInFlight(req.sessionId);
8831
- const transportClosed = restoreChannel.channel.exited.then(() => {
8832
- throw new BridgeChannelClosedError(`during session/${action}`);
8833
- });
9252
+ const transportClosed = channelUnavailableReject(
9253
+ restoreChannel.channel,
9254
+ `during session/${action}`
9255
+ );
8834
9256
  transportClosed.catch(() => {
8835
9257
  });
8836
9258
  let state;
@@ -8863,8 +9285,8 @@ function createAcpSessionBridge(opts) {
8863
9285
  ...sessionSourceRequestMeta(req.sourceType, req.sourceId),
8864
9286
  ...historyReplay === "response" ? {
8865
9287
  [LOAD_REPLAY_MODE_META_KEY]: LOAD_REPLAY_BULK_MODE,
8866
- ...req.historyPageSize !== void 0 ? {
8867
- [LOAD_REPLAY_PAGE_SIZE_META_KEY]: req.historyPageSize
9288
+ ...historyPageSize !== void 0 ? {
9289
+ [LOAD_REPLAY_PAGE_SIZE_META_KEY]: historyPageSize
8868
9290
  } : {}
8869
9291
  } : {},
8870
9292
  ...hideInheritedHistory ? { [LOAD_REPLAY_HIDE_INHERITED_META_KEY]: true } : {}
@@ -8976,24 +9398,20 @@ function createAcpSessionBridge(opts) {
8976
9398
  const racedEntry = byId.get(req.sessionId);
8977
9399
  if (racedEntry) {
8978
9400
  restoreEvents.close();
8979
- if (isClosingOrAuthorizingClose(racedEntry)) {
8980
- throw new SessionNotFoundError(
8981
- req.sessionId,
8982
- "The session is closing; retry after close completes",
8983
- "session_closing"
8984
- );
8985
- }
9401
+ assertAttachableSessionEntry(req.sessionId, racedEntry);
8986
9402
  racedEntry.attachCount += 1 + coalesceState.count;
8987
9403
  const clientId2 = registerClient(racedEntry, req.clientId);
8988
9404
  recordAttachRef(racedEntry, clientId2);
8989
9405
  if (req.approvalMode) {
9406
+ let previousApprovalMode;
8990
9407
  try {
8991
- await applyApprovalMode(
9408
+ const result = await applyApprovalMode(
8992
9409
  racedEntry,
8993
9410
  req.approvalMode,
8994
9411
  false,
8995
9412
  clientId2
8996
9413
  );
9414
+ previousApprovalMode = result.previous;
8997
9415
  } catch (err) {
8998
9416
  await rollbackAttachRegistration(
8999
9417
  racedEntry,
@@ -9002,6 +9420,21 @@ function createAcpSessionBridge(opts) {
9002
9420
  );
9003
9421
  throw err;
9004
9422
  }
9423
+ try {
9424
+ assertAttachableSessionEntry(req.sessionId, racedEntry);
9425
+ } catch (error) {
9426
+ await rollbackApprovalModeForRejectedAttach(
9427
+ racedEntry,
9428
+ previousApprovalMode,
9429
+ clientId2
9430
+ );
9431
+ await rollbackAttachRegistration(
9432
+ racedEntry,
9433
+ clientId2,
9434
+ 1 + coalesceState.count
9435
+ );
9436
+ throw error;
9437
+ }
9005
9438
  }
9006
9439
  return {
9007
9440
  sessionId: racedEntry.sessionId,
@@ -9063,14 +9496,16 @@ function createAcpSessionBridge(opts) {
9063
9496
  await ci.client.seedSessionUpdates(entry, replayUpdates, {
9064
9497
  ingestArtifacts: restoredArtifactSnapshot === void 0 || artifactRestoreFailed
9065
9498
  });
9066
- if (req.historyPageSize !== void 0 && entry.events.snapshotReplay()?.compactedTurns.some((event) => event.type === "history_truncated")) {
9499
+ if (historyPageSize !== void 0 && entry.events.snapshotReplay()?.compactedTurns.some((event) => event.type === "history_truncated")) {
9067
9500
  entry.restoreHistoryHasMore = true;
9068
9501
  }
9069
9502
  ci.client.drainEarlyEvents(entry.sessionId, entry);
9070
9503
  }
9504
+ assertAttachableSessionEntry(req.sessionId, entry);
9071
9505
  const clientId = registerClient(entry, req.clientId);
9072
9506
  if (req.approvalMode) {
9073
9507
  await applyApprovalModeForAttach(entry, req.approvalMode, clientId);
9508
+ assertAttachableSessionEntry(req.sessionId, entry);
9074
9509
  }
9075
9510
  entry.attachCount = coalesceState.count;
9076
9511
  registeredEntry = entry;
@@ -9147,6 +9582,7 @@ function createAcpSessionBridge(opts) {
9147
9582
  inFlightRestores.set(req.sessionId, {
9148
9583
  action,
9149
9584
  historyReplay,
9585
+ ...historyPageSize !== void 0 ? { historyPageSize } : {},
9150
9586
  hideInheritedHistory,
9151
9587
  publicPromise: promise,
9152
9588
  settlementPromise,
@@ -9192,15 +9628,21 @@ function createAcpSessionBridge(opts) {
9192
9628
  `qwen serve: closeSession channelInfoForEntry returned undefined for session ${JSON.stringify(sessionId)} \u2014 channel cleanup skipped (entry's channel already torn down)`
9193
9629
  );
9194
9630
  }
9631
+ let agentSessionClosed = false;
9195
9632
  try {
9196
9633
  permissionMediator.forgetSession(sessionId);
9197
9634
  entry.pendingPermissionIds.clear();
9198
9635
  entry.pendingInteractions.clear();
9199
- await notifyAgentSessionClose(entry, ci, "closeSession", {
9200
- throwOnFailure: true,
9201
- requireFlush: closeOpts?.requireAgentClose === true,
9202
- ...closeOpts?.agentCloseTimeoutMs !== void 0 ? { timeoutMs: closeOpts.agentCloseTimeoutMs } : {}
9203
- });
9636
+ agentSessionClosed = await notifyAgentSessionClose(
9637
+ entry,
9638
+ ci,
9639
+ "closeSession",
9640
+ {
9641
+ throwOnFailure: true,
9642
+ requireFlush: closeOpts?.requireAgentClose === true,
9643
+ ...closeOpts?.agentCloseTimeoutMs !== void 0 ? { timeoutMs: closeOpts.agentCloseTimeoutMs } : {}
9644
+ }
9645
+ );
9204
9646
  } catch (error) {
9205
9647
  if (isDefinitiveAcpRequestError(error)) {
9206
9648
  entry.closing = false;
@@ -9254,16 +9696,18 @@ function createAcpSessionBridge(opts) {
9254
9696
  } catch {
9255
9697
  }
9256
9698
  entry.events.close();
9257
- try {
9258
- await telemetry.withSpan(
9259
- "session.close.cancel_active_prompt",
9260
- {
9261
- "qwen-code.daemon.bridge.operation": "session.close.cancel_active_prompt",
9262
- "session.id": sessionId
9263
- },
9264
- async () => await entry.connection.cancel({ sessionId })
9265
- );
9266
- } catch {
9699
+ if (!agentSessionClosed) {
9700
+ try {
9701
+ await telemetry.withSpan(
9702
+ "session.close.cancel_active_prompt",
9703
+ {
9704
+ "qwen-code.daemon.bridge.operation": "session.close.cancel_active_prompt",
9705
+ "session.id": sessionId
9706
+ },
9707
+ async () => await entry.connection.cancel({ sessionId })
9708
+ );
9709
+ } catch {
9710
+ }
9267
9711
  }
9268
9712
  if (ci && hasNoChannelWork(ci)) {
9269
9713
  await reapPendingEmptyChannel(ci);
@@ -9447,13 +9891,7 @@ function createAcpSessionBridge(opts) {
9447
9891
  if (effectiveScope === "single") {
9448
9892
  const existing = defaultEntry;
9449
9893
  if (existing) {
9450
- if (isClosingOrAuthorizingClose(existing)) {
9451
- throw new SessionNotFoundError(
9452
- existing.sessionId,
9453
- "The session is closing; retry after close completes",
9454
- "session_closing"
9455
- );
9456
- }
9894
+ assertAttachableSessionEntry(existing.sessionId, existing);
9457
9895
  existing.attachCount++;
9458
9896
  const clientId = registerClient(existing, req.clientId);
9459
9897
  recordAttachRef(existing, clientId);
@@ -9466,13 +9904,27 @@ function createAcpSessionBridge(opts) {
9466
9904
  ).catch(() => {
9467
9905
  });
9468
9906
  }
9907
+ let previousApprovalMode;
9469
9908
  if (req.approvalMode) {
9470
- await applyApprovalModeForAttach(
9909
+ previousApprovalMode = await applyApprovalModeForAttach(
9471
9910
  existing,
9472
9911
  req.approvalMode,
9473
9912
  clientId
9474
9913
  );
9475
9914
  }
9915
+ try {
9916
+ assertAttachableSessionEntry(existing.sessionId, existing);
9917
+ } catch (error) {
9918
+ if (previousApprovalMode !== void 0) {
9919
+ await rollbackApprovalModeForRejectedAttach(
9920
+ existing,
9921
+ previousApprovalMode,
9922
+ clientId
9923
+ );
9924
+ }
9925
+ await rollbackAttachRegistration(existing, clientId);
9926
+ throw error;
9927
+ }
9476
9928
  return {
9477
9929
  sessionId: existing.sessionId,
9478
9930
  workspaceCwd: existing.workspaceCwd,
@@ -9489,13 +9941,14 @@ function createAcpSessionBridge(opts) {
9489
9941
  if (inFlight) {
9490
9942
  const session = await inFlight;
9491
9943
  const attachedEntry = byId.get(session.sessionId);
9492
- if (attachedEntry) attachedEntry.attachCount++;
9493
9944
  if (!attachedEntry) {
9494
9945
  throw new SessionNotFoundError(
9495
9946
  session.sessionId,
9496
9947
  "the agent child likely crashed during initialization \u2014 retry to spawn a new session"
9497
9948
  );
9498
9949
  }
9950
+ assertAttachableSessionEntry(session.sessionId, attachedEntry);
9951
+ attachedEntry.attachCount++;
9499
9952
  const clientId = registerClient(attachedEntry, req.clientId);
9500
9953
  recordAttachRef(attachedEntry, clientId);
9501
9954
  if (req.modelServiceId) {
@@ -9507,13 +9960,27 @@ function createAcpSessionBridge(opts) {
9507
9960
  ).catch(() => {
9508
9961
  });
9509
9962
  }
9963
+ let previousApprovalMode;
9510
9964
  if (req.approvalMode) {
9511
- await applyApprovalModeForAttach(
9965
+ previousApprovalMode = await applyApprovalModeForAttach(
9512
9966
  attachedEntry,
9513
9967
  req.approvalMode,
9514
9968
  clientId
9515
9969
  );
9516
9970
  }
9971
+ try {
9972
+ assertAttachableSessionEntry(session.sessionId, attachedEntry);
9973
+ } catch (error) {
9974
+ if (previousApprovalMode !== void 0) {
9975
+ await rollbackApprovalModeForRejectedAttach(
9976
+ attachedEntry,
9977
+ previousApprovalMode,
9978
+ clientId
9979
+ );
9980
+ }
9981
+ await rollbackAttachRegistration(attachedEntry, clientId);
9982
+ throw error;
9983
+ }
9517
9984
  return {
9518
9985
  ...session,
9519
9986
  attached: true,
@@ -9662,12 +10129,19 @@ function createAcpSessionBridge(opts) {
9662
10129
  );
9663
10130
  }
9664
10131
  }
10132
+ const channelDisplayText = getChannelPromptDisplayText(
10133
+ entry,
10134
+ context?.promptDisplayText
10135
+ );
10136
+ const pendingText = channelDisplayText === void 0 ? extractPromptText(req.prompt) : channelDisplayText || (req.prompt.some(
10137
+ (block) => isRecord3(block) && block["type"] === "image"
10138
+ ) ? "[image]" : "");
9665
10139
  const pendingEntry = {
9666
10140
  promptId,
9667
10141
  queuedAt,
9668
10142
  ...originatorClientId !== void 0 ? { originatorClientId } : {},
9669
10143
  ...isPromotedMidTurn ? { promotedMidTurn: true } : {},
9670
- text: extractPromptText(req.prompt),
10144
+ text: pendingText,
9671
10145
  abortController: pendingAbort,
9672
10146
  state: isQueued ? "queued" : "running"
9673
10147
  };
@@ -9805,11 +10279,13 @@ function createAcpSessionBridge(opts) {
9805
10279
  delete copy.retry;
9806
10280
  delete copy.delivery;
9807
10281
  const meta = copy._meta && typeof copy._meta === "object" ? { ...copy._meta } : {};
10282
+ const promptDisplayText = channelDisplayText;
9808
10283
  delete meta[DAEMON_RETRY_META_KEY];
9809
10284
  delete meta[INVOCATION_CONTEXT_META_KEY];
9810
10285
  delete meta[PRIVATE_PARENT_CAPABILITY_META_KEY];
9811
10286
  delete meta[DAEMON_CONTINUE_META_KEY];
9812
10287
  delete meta[DAEMON_CHANNEL_DELIVERY_META_KEY];
10288
+ delete meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY];
9813
10289
  delete meta[DAEMON_MODEL_PROMPT_META_KEY];
9814
10290
  if (isRetry) {
9815
10291
  meta[DAEMON_RETRY_META_KEY] = true;
@@ -9820,6 +10296,9 @@ function createAcpSessionBridge(opts) {
9820
10296
  if (context?.channelDelivery) {
9821
10297
  meta[DAEMON_CHANNEL_DELIVERY_META_KEY] = context.channelDelivery;
9822
10298
  }
10299
+ if (promptDisplayText !== void 0) {
10300
+ meta[DAEMON_PROMPT_DISPLAY_TEXT_META_KEY] = promptDisplayText;
10301
+ }
9823
10302
  if (modelPrompt !== void 0) {
9824
10303
  meta[DAEMON_MODEL_PROMPT_META_KEY] = modelPrompt;
9825
10304
  }
@@ -9849,7 +10328,8 @@ function createAcpSessionBridge(opts) {
9849
10328
  entry,
9850
10329
  promptRequest,
9851
10330
  pendingEntry.promptId,
9852
- originatorClientId
10331
+ originatorClientId,
10332
+ channelDisplayText
9853
10333
  );
9854
10334
  }
9855
10335
  } catch (echoErr) {
@@ -10208,16 +10688,20 @@ function createAcpSessionBridge(opts) {
10208
10688
  releaseFreshSessionReservation(admission);
10209
10689
  }, "releaseAdmissionOnce");
10210
10690
  try {
10211
- const ci = await ensureChannel();
10691
+ assertLivePromptEntry(sessionId, entry);
10692
+ const ci = channelInfoForEntry(entry);
10212
10693
  const result = await withTimeout(
10213
- ci.connection.extMethod(
10214
- isSideTask ? SERVE_CONTROL_EXT_METHODS.sessionSideTask : SERVE_CONTROL_EXT_METHODS.sessionBranch,
10215
- {
10216
- sessionId,
10217
- cwd: boundWorkspace,
10218
- name: req.name
10219
- }
10220
- ),
10694
+ Promise.race([
10695
+ ci.connection.extMethod(
10696
+ isSideTask ? SERVE_CONTROL_EXT_METHODS.sessionSideTask : SERVE_CONTROL_EXT_METHODS.sessionBranch,
10697
+ {
10698
+ sessionId,
10699
+ cwd: boundWorkspace,
10700
+ name: req.name
10701
+ }
10702
+ ),
10703
+ getTransportClosedReject(entry)
10704
+ ]),
10221
10705
  initTimeoutMs,
10222
10706
  isSideTask ? "createSideTaskSession" : "branchSession"
10223
10707
  );
@@ -10253,10 +10737,25 @@ function createAcpSessionBridge(opts) {
10253
10737
  `qwen serve: branchSession load failed for ${result.newSessionId}, attempting cleanup...`
10254
10738
  );
10255
10739
  try {
10256
- await ci.connection.extMethod(
10257
- SERVE_CONTROL_EXT_METHODS.sessionClose,
10258
- { sessionId: result.newSessionId, cwd: boundWorkspace }
10259
- );
10740
+ if (!ci.isDying) {
10741
+ await withTimeout(
10742
+ Promise.race([
10743
+ ci.connection.extMethod(
10744
+ SERVE_CONTROL_EXT_METHODS.sessionClose,
10745
+ {
10746
+ sessionId: result.newSessionId,
10747
+ cwd: boundWorkspace
10748
+ }
10749
+ ),
10750
+ channelUnavailableReject(
10751
+ ci.channel,
10752
+ "during branchSession cleanup"
10753
+ )
10754
+ ]),
10755
+ initTimeoutMs,
10756
+ "branchSession cleanup"
10757
+ );
10758
+ }
10260
10759
  } catch (cleanupErr) {
10261
10760
  writeStderrLine(
10262
10761
  `qwen serve: branchSession cleanup of ${result.newSessionId} failed: ${cleanupErr instanceof Error ? cleanupErr.message : cleanupErr}`
@@ -10352,16 +10851,16 @@ function createAcpSessionBridge(opts) {
10352
10851
  if (entry.promptActive) {
10353
10852
  throw new CdWhilePromptActiveError(sessionId);
10354
10853
  }
10355
- const ci = await ensureChannel();
10356
- const raw = await ci.connection.extMethod(
10357
- SERVE_CONTROL_EXT_METHODS.sessionCd,
10358
- {
10854
+ assertLivePromptEntry(sessionId, entry);
10855
+ const raw = await Promise.race([
10856
+ entry.connection.extMethod(SERVE_CONTROL_EXT_METHODS.sessionCd, {
10359
10857
  sessionId,
10360
10858
  path: req.path,
10361
10859
  ...req.allowedRoots ? { allowedRoots: req.allowedRoots } : {},
10362
10860
  ...req.managedRelocation ? { managedRelocation: req.managedRelocation } : {}
10363
- }
10364
- );
10861
+ }),
10862
+ getTransportClosedReject(entry)
10863
+ ]);
10365
10864
  const extResult = raw;
10366
10865
  if (typeof extResult?.previousCwd !== "string" || typeof extResult?.newCwd !== "string" || !Array.isArray(extResult?.warnings)) {
10367
10866
  throw new Error(
@@ -10894,6 +11393,7 @@ function createAcpSessionBridge(opts) {
10894
11393
  const bootstrapRefreshConnections = /* @__PURE__ */ new Set();
10895
11394
  const refreshSession = /* @__PURE__ */ __name(async (entry, refreshBootstrap) => {
10896
11395
  let inFlight = inFlightExtensionRefreshes.get(entry.sessionId);
11396
+ let created = false;
10897
11397
  if (!inFlight || inFlight.connection !== entry.connection || refreshBootstrap && !inFlight.refreshBootstrap) {
10898
11398
  const promise = (async () => {
10899
11399
  await entry.connection.extMethod(
@@ -10904,27 +11404,36 @@ function createAcpSessionBridge(opts) {
10904
11404
  }
10905
11405
  );
10906
11406
  })();
11407
+ let rejectUnavailable;
11408
+ const unavailable = new Promise((_resolve, reject) => {
11409
+ rejectUnavailable = /* @__PURE__ */ __name(() => reject(
11410
+ new BridgeChannelClosedError("refreshExtensionsForAllSessions")
11411
+ ), "rejectUnavailable");
11412
+ });
10907
11413
  inFlight = {
10908
11414
  connection: entry.connection,
10909
11415
  promise,
11416
+ wait: Promise.race([
11417
+ withTimeout(
11418
+ promise,
11419
+ 3e4,
11420
+ SERVE_CONTROL_EXT_METHODS.workspaceExtensionsRefresh
11421
+ ),
11422
+ unavailable
11423
+ ]),
11424
+ rejectUnavailable,
10910
11425
  refreshBootstrap
10911
11426
  };
10912
11427
  inFlightExtensionRefreshes.set(entry.sessionId, inFlight);
10913
- const clear = /* @__PURE__ */ __name(() => {
10914
- if (inFlightExtensionRefreshes.get(entry.sessionId) === inFlight) {
10915
- inFlightExtensionRefreshes.delete(entry.sessionId);
10916
- }
10917
- }, "clear");
10918
- void promise.then(clear, clear);
11428
+ created = true;
10919
11429
  }
10920
- await Promise.race([
10921
- withTimeout(
10922
- inFlight.promise,
10923
- 3e4,
10924
- SERVE_CONTROL_EXT_METHODS.workspaceExtensionsRefresh
10925
- ),
10926
- getTransportClosedReject(entry)
10927
- ]);
11430
+ const clear = /* @__PURE__ */ __name(() => {
11431
+ if (inFlightExtensionRefreshes.get(entry.sessionId) === inFlight) {
11432
+ inFlightExtensionRefreshes.delete(entry.sessionId);
11433
+ }
11434
+ }, "clear");
11435
+ if (created) void inFlight.promise.then(clear, clear);
11436
+ await inFlight.wait;
10928
11437
  }, "refreshSession");
10929
11438
  const results = await Promise.all(
10930
11439
  sessions.map(async (entry) => {
@@ -11051,6 +11560,29 @@ function createAcpSessionBridge(opts) {
11051
11560
  }
11052
11561
  return response;
11053
11562
  },
11563
+ async setSessionConfigOption(sessionId, req) {
11564
+ const entry = byId.get(sessionId);
11565
+ if (!entry) throw new SessionNotFoundError(sessionId);
11566
+ const info = channelInfoForEntry(entry);
11567
+ if (!info || info.isDying) throw new SessionNotFoundError(sessionId);
11568
+ const normalized = { ...req, sessionId };
11569
+ const transportClosed = getTransportClosedReject(entry);
11570
+ const work = entry.modelChangeQueue.then(
11571
+ () => Promise.race([
11572
+ withTimeout(
11573
+ entry.connection.setSessionConfigOption(normalized),
11574
+ initTimeoutMs,
11575
+ "setSessionConfigOption"
11576
+ ),
11577
+ transportClosed
11578
+ ])
11579
+ );
11580
+ entry.modelChangeQueue = work.then(
11581
+ () => void 0,
11582
+ () => void 0
11583
+ );
11584
+ return await work;
11585
+ },
11054
11586
  async setSessionLanguage(sessionId, params, context) {
11055
11587
  const entry = byId.get(sessionId);
11056
11588
  if (!entry) throw new SessionNotFoundError(sessionId);
@@ -11659,9 +12191,16 @@ function createAcpSessionBridge(opts) {
11659
12191
  });
11660
12192
  const historyOutput = output.length > MAX_SHELL_OUTPUT_FOR_HISTORY ? output.substring(0, MAX_SHELL_OUTPUT_FOR_HISTORY) + "\n... (truncated)" : output;
11661
12193
  try {
11662
- await entry.connection.extMethod(
11663
- SERVE_CONTROL_EXT_METHODS.sessionShellHistory,
11664
- { sessionId, command, output: historyOutput, exitCode }
12194
+ await withTimeout(
12195
+ Promise.race([
12196
+ entry.connection.extMethod(
12197
+ SERVE_CONTROL_EXT_METHODS.sessionShellHistory,
12198
+ { sessionId, command, output: historyOutput, exitCode }
12199
+ ),
12200
+ getTransportClosedReject(entry)
12201
+ ]),
12202
+ initTimeoutMs,
12203
+ "sessionShellHistory"
11665
12204
  );
11666
12205
  } catch (err) {
11667
12206
  writeServeDebugLine(