@qwen-code/qwen-code 0.19.3 → 0.19.4

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 (305) hide show
  1. package/bundled/loop/SKILL.md +22 -3
  2. package/bundled/loop/SKILL.test.ts +20 -0
  3. package/bundled/loop/autonomous-loop.test.ts +59 -0
  4. package/bundled/loop/autonomous-loop.ts +102 -0
  5. package/bundled/loop/loop-task-file.test.ts +1064 -0
  6. package/bundled/loop/loop-task-file.ts +404 -0
  7. package/bundled/loop/loop-tick-resolver.test.ts +906 -0
  8. package/bundled/loop/loop-tick-resolver.ts +416 -0
  9. package/bundled/qc-helper/SKILL.md +12 -5
  10. package/bundled/qc-helper/docs/configuration/auth.md +1 -1
  11. package/bundled/qc-helper/docs/configuration/settings.md +40 -26
  12. package/bundled/qc-helper/docs/features/approval-mode.md +3 -0
  13. package/bundled/qc-helper/docs/features/auto-mode.md +40 -0
  14. package/bundled/qc-helper/docs/features/channels/overview.md +81 -18
  15. package/bundled/qc-helper/docs/features/channels/plugins.md +1 -1
  16. package/bundled/qc-helper/docs/features/code-review.md +17 -61
  17. package/bundled/qc-helper/docs/features/commands.md +6 -6
  18. package/bundled/qc-helper/docs/features/hooks.md +6 -1
  19. package/bundled/qc-helper/docs/features/mcp.md +3 -1
  20. package/bundled/qc-helper/docs/features/memory.md +1 -1
  21. package/bundled/qc-helper/docs/features/scheduled-tasks.md +10 -0
  22. package/bundled/qc-helper/docs/features/status-line.md +3 -3
  23. package/bundled/qc-helper/docs/ide-integration/ide-integration.md +4 -4
  24. package/bundled/qc-helper/docs/qwen-serve.md +19 -0
  25. package/bundled/qc-helper/docs/support/troubleshooting.md +6 -0
  26. package/bundled/review/DESIGN.md +21 -26
  27. package/bundled/review/SKILL.md +45 -129
  28. package/chunks/MaxSizedBox-ERTNFI22.js +68 -0
  29. package/chunks/{StandaloneSessionPicker-Z52JTYST.js → StandaloneSessionPicker-Y5NGRLRY.js} +48 -42
  30. package/chunks/{acpAgent-7RZUOWOM.js → acpAgent-UMN6OYTR.js} +1319 -361
  31. package/chunks/{agent-4FG7WTHJ.js → agent-56DZU4ZU.js} +30 -25
  32. package/chunks/agent-headless-SR7N2IJG.js +61 -0
  33. package/chunks/{anthropicContentGenerator-PFITVL7Y.js → anthropicContentGenerator-5OZFO6WQ.js} +11 -8
  34. package/chunks/{artifact-tool-D2X7G3C3.js → artifact-tool-JVZMHA4B.js} +3 -3
  35. package/chunks/{askUserQuestion-UGETICJQ.js → askUserQuestion-CMJZ2F3D.js} +2 -2
  36. package/chunks/bridge-AUHNFOUS.js +72 -0
  37. package/chunks/{ca-IUFWESZL.js → ca-RYOETBUW.js} +9 -9
  38. package/chunks/channel-worker-supervisor-A74FV522.js +308 -0
  39. package/chunks/{chunk-T4T2FNV4.js → chunk-2X2JUE47.js} +2 -2
  40. package/chunks/{chunk-BX5YO7UW.js → chunk-4VZH35PN.js} +540 -370
  41. package/chunks/{chunk-M2U5NM24.js → chunk-54YZOP7P.js} +309 -72
  42. package/chunks/chunk-5P5XGNYH.js +93 -0
  43. package/chunks/{chunk-QWFNTRH4.js → chunk-6AQR7732.js} +1 -1
  44. package/chunks/{chunk-HZT4UCFB.js → chunk-6CIIP6OE.js} +4 -4
  45. package/chunks/{chunk-ADCIHOQZ.js → chunk-6TLY5W3B.js} +16 -8
  46. package/chunks/{chunk-BXSHL2SF.js → chunk-73H73ASU.js} +1 -1
  47. package/chunks/{chunk-3TV3HUWZ.js → chunk-75X2VLSH.js} +60 -30
  48. package/chunks/{chunk-6V4NZFUS.js → chunk-7KPI4LAI.js} +5 -5
  49. package/chunks/{chunk-PDE7CSDS.js → chunk-7VPC7D7O.js} +2 -2
  50. package/chunks/chunk-AHNXYU4O.js +24 -0
  51. package/chunks/{chunk-UX4SGCGN.js → chunk-AVQDCKNF.js} +96 -22
  52. package/chunks/{chunk-HYCC3XM3.js → chunk-B236XPGF.js} +1 -1
  53. package/chunks/{chunk-N4EJFBN5.js → chunk-B7KGXIPZ.js} +419 -262
  54. package/chunks/{chunk-YAINVQ3Q.js → chunk-BFG6OZN7.js} +17392 -16335
  55. package/chunks/{chunk-5DWXLGOM.js → chunk-BJBWRCSK.js} +1 -1
  56. package/chunks/{chunk-BTLJ2MF5.js → chunk-BNJLLAQ7.js} +3 -3
  57. package/chunks/{chunk-UYT3MWEB.js → chunk-BQNJBEUA.js} +16 -2
  58. package/chunks/{chunk-SKQZZVAV.js → chunk-BZHLWC6T.js} +2 -2
  59. package/chunks/{chunk-HPZTOP4I.js → chunk-C2IHHGBZ.js} +131 -21
  60. package/chunks/chunk-CG7SVARK.js +367 -0
  61. package/chunks/{chunk-CNLEDYE3.js → chunk-CS5XYDBO.js} +5 -5
  62. package/chunks/{chunk-O75BHFQW.js → chunk-CUGEBAKG.js} +2 -2
  63. package/chunks/{chunk-U3KSMM7G.js → chunk-D5KISTLW.js} +339 -383
  64. package/chunks/{chunk-STUWFKGD.js → chunk-DQ74W65K.js} +431 -535
  65. package/chunks/{chunk-VVLOGDB6.js → chunk-DX3TKXNT.js} +2 -2
  66. package/chunks/chunk-E5A7LHNN.js +51 -0
  67. package/chunks/{chunk-3PJXIDKI.js → chunk-E6US47KI.js} +3 -27
  68. package/chunks/chunk-EDAGQADF.js +21 -0
  69. package/chunks/{chunk-QBZ22PQX.js → chunk-EWALXUAD.js} +3 -1
  70. package/chunks/{chunk-4QK3O43S.js → chunk-FNLXLI4I.js} +4 -4
  71. package/chunks/{chunk-I2LYBGNI.js → chunk-FYKX6XOT.js} +1 -1
  72. package/chunks/{chunk-QLDPRILK.js → chunk-G7OQ3RFJ.js} +3 -3
  73. package/chunks/{chunk-R2BXK7SX.js → chunk-GHOTR7HL.js} +6 -1
  74. package/chunks/{chunk-L7OKCI7T.js → chunk-GICCHL2Q.js} +15 -1
  75. package/chunks/{chunk-KMGMKW5Q.js → chunk-GLPV75ES.js} +9 -3
  76. package/chunks/{chunk-LD2XBG6Z.js → chunk-GO6LNQXT.js} +1 -39
  77. package/chunks/chunk-HI55Z6PR.js +3523 -0
  78. package/chunks/{chunk-QNKBEJO2.js → chunk-HJDF3ZVU.js} +2776 -1289
  79. package/chunks/{chunk-JJXWTVSK.js → chunk-HRZB5CSC.js} +34 -1
  80. package/chunks/{chunk-I4H7PRWQ.js → chunk-HTWHAN44.js} +1 -1
  81. package/chunks/{chunk-EJYJYJZ2.js → chunk-IRJWHZWU.js} +3 -70
  82. package/chunks/{chunk-CKQA6AWF.js → chunk-J3F7X3LW.js} +1 -1
  83. package/chunks/{chunk-QI7GOGJR.js → chunk-KKQWC6WS.js} +1 -1
  84. package/chunks/{chunk-VBZ452JT.js → chunk-KVPFPC4J.js} +494 -114
  85. package/chunks/{chunk-NDOC6M5S.js → chunk-L7QPM2YD.js} +2 -2
  86. package/chunks/{chunk-SLNKLLEO.js → chunk-L7VH7HQA.js} +12 -8
  87. package/chunks/{chunk-BVSVIN45.js → chunk-LKWAVAB5.js} +3 -3
  88. package/chunks/{chunk-ZP6UKOPB.js → chunk-LWGLBVWA.js} +1 -1
  89. package/chunks/{chunk-SBBN4BWR.js → chunk-MEQWZGK5.js} +1 -1
  90. package/chunks/{chunk-FKAVULLM.js → chunk-MKHC4BYZ.js} +58 -10
  91. package/chunks/{chunk-UFLGERMB.js → chunk-MNDTD5E5.js} +178 -124
  92. package/chunks/{chunk-RD6YJJJ6.js → chunk-MOUXUCXQ.js} +1 -1
  93. package/chunks/{chunk-EDMZZFDU.js → chunk-MVZXZWGT.js} +905 -795
  94. package/chunks/chunk-MX2YXRER.js +44 -0
  95. package/chunks/{chunk-JVHEVCAU.js → chunk-ND25GXEU.js} +23 -6
  96. package/chunks/chunk-NIOPRZNN.js +27 -0
  97. package/chunks/{chunk-DDMOU62Q.js → chunk-NPQWQYU6.js} +1 -1
  98. package/chunks/{chunk-PR32FRT6.js → chunk-OAFUMTWW.js} +3 -3
  99. package/chunks/chunk-OJCECIJA.js +238 -0
  100. package/chunks/{chunk-GGBIN5K7.js → chunk-PIYV6COW.js} +1 -1
  101. package/chunks/{chunk-CF6BB3LT.js → chunk-PPFWEV7G.js} +10 -1
  102. package/chunks/{chunk-4LUZAKMK.js → chunk-Q7VHIRDD.js} +1 -1
  103. package/chunks/{chunk-ODLIHNOY.js → chunk-QAFQLTXG.js} +1 -1
  104. package/chunks/{chunk-Y6YMRS3U.js → chunk-QMIND2AS.js} +3 -3
  105. package/chunks/{chunk-XJYUPHRC.js → chunk-QOMAHFYI.js} +3 -3
  106. package/chunks/{chunk-J37FGIOA.js → chunk-QXPI7FEC.js} +38 -4
  107. package/chunks/chunk-RM3PGSGL.js +66 -0
  108. package/chunks/chunk-RNBYOUGV.js +42 -0
  109. package/chunks/chunk-S5EQPDTM.js +91 -0
  110. package/chunks/chunk-SEZC2725.js +36 -0
  111. package/chunks/{chunk-FNJ7BDPH.js → chunk-SFN4TEHY.js} +10 -7
  112. package/chunks/{chunk-O2VBQ3Y2.js → chunk-SJBIFVD2.js} +2 -2
  113. package/chunks/chunk-SYCJMSIJ.js +82 -0
  114. package/chunks/{chunk-JE5FVRPC.js → chunk-T22H4V4R.js} +48 -23
  115. package/chunks/{chunk-3227DZO4.js → chunk-T42ACHFI.js} +1 -1
  116. package/chunks/{chunk-UO5GVXQE.js → chunk-TENOUWY2.js} +3 -3
  117. package/chunks/{chunk-JOLIREYR.js → chunk-TOAUDIS7.js} +1 -1
  118. package/chunks/{chunk-J7FA27RO.js → chunk-TTFNVEO5.js} +3 -3
  119. package/chunks/{chunk-S7AKE7HL.js → chunk-UANCYOOQ.js} +63 -9
  120. package/chunks/{chunk-BUUQ5HPX.js → chunk-UQFP2FEF.js} +1 -1
  121. package/chunks/{chunk-R5OP2ATH.js → chunk-UQYOMM6J.js} +11 -11
  122. package/chunks/{chunk-J33ZR6OJ.js → chunk-UT5JU5DJ.js} +16 -16
  123. package/chunks/{chunk-QE6KJYLT.js → chunk-VKGG724L.js} +122 -25
  124. package/chunks/{chunk-SMXULRAN.js → chunk-VXGPYF7U.js} +1 -1
  125. package/chunks/{chunk-MNF6S5PR.js → chunk-W2ZOAX7F.js} +4 -4
  126. package/chunks/{chunk-GT2FGICD.js → chunk-W6X4FGWX.js} +1 -1
  127. package/chunks/{chunk-SMYQZVZ3.js → chunk-XCUFHOAD.js} +1 -1
  128. package/chunks/{chunk-K5XU6E4T.js → chunk-XKSCTXPK.js} +2 -2
  129. package/chunks/{chunk-FXKVLFFY.js → chunk-YBDZ63KI.js} +3 -3
  130. package/chunks/{chunk-BKXBARJZ.js → chunk-YPCPZSZB.js} +1 -1
  131. package/chunks/chunk-YTFBURQD.js +313 -0
  132. package/chunks/{chunk-NL4C3H6C.js → chunk-YXK4GPYO.js} +1 -1
  133. package/chunks/{chunk-F3ZYSEY6.js → chunk-ZJP5T7IA.js} +3 -3
  134. package/chunks/{chunk-RYLJU2DY.js → chunk-ZN5T4BHI.js} +1 -1
  135. package/chunks/{chunk-RRFZXMYP.js → chunk-ZXCVPMIK.js} +553 -138
  136. package/chunks/{computer-use-JGB36FDW.js → computer-use-VWN5HH6A.js} +33 -28
  137. package/chunks/contextCommand-DFFG5KDJ.js +66 -0
  138. package/chunks/{cron-create-SKEY55RG.js → cron-create-CSSWJ67I.js} +4 -4
  139. package/chunks/{cron-delete-I3NAT32Z.js → cron-delete-E56CFQ7A.js} +4 -4
  140. package/chunks/{cron-list-6XRRL6TH.js → cron-list-BKSINY6Y.js} +4 -4
  141. package/chunks/daemon-5T6IHWJV.js +8430 -0
  142. package/chunks/daemon-status-provider-V5UY7O7J.js +70 -0
  143. package/chunks/{de-EOW5PVHF.js → de-HB5NJXGB.js} +9 -9
  144. package/chunks/{dist-NHEYYB2B.js → dist-2HDL5SHQ.js} +2 -2
  145. package/chunks/{dist-663NZ6MI.js → dist-B7SSDVWT.js} +116 -11
  146. package/chunks/{dist-PQPZ5Q4N.js → dist-BL3SL665.js} +20 -9
  147. package/chunks/{dist-J37VXPLD.js → dist-TAVAGZU6.js} +40 -15
  148. package/chunks/{dist-LB6OGPVM.js → dist-XBOVZ3R5.js} +26 -5
  149. package/chunks/{earlyInputCapture-44RISVVJ.js → earlyInputCapture-VVYU4FDO.js} +31 -26
  150. package/chunks/{edit-NN6GM5DT.js → edit-F35PTMBA.js} +35 -29
  151. package/chunks/{en-HPWEJBTR.js → en-FZREZFPO.js} +30 -10
  152. package/chunks/{enter-worktree-PB3O2C7D.js → enter-worktree-3DIW7EGJ.js} +30 -25
  153. package/chunks/{enterPlanMode-YQFNNSUA.js → enterPlanMode-QNXT77KP.js} +40 -25
  154. package/chunks/{errors-LS7XU5DZ.js → errors-M53YG76R.js} +32 -27
  155. package/chunks/{exit-worktree-E2FTNSBK.js → exit-worktree-BSDWNWHZ.js} +30 -25
  156. package/chunks/{exitPlanMode-GLYK2BUB.js → exitPlanMode-EL7AY327.js} +54 -33
  157. package/chunks/{fast-path-WQ6M7LI7.js → fast-path-DUCSMUFW.js} +30 -13
  158. package/chunks/{fast-path-settings-OAGU3X5H.js → fast-path-settings-UQLRFDQP.js} +2 -2
  159. package/chunks/{fr-BN5NKSAC.js → fr-XY3NQFCM.js} +9 -9
  160. package/chunks/{gemini-2YFLVA2M.js → gemini-F3IERB37.js} +80 -67
  161. package/chunks/{geminiContentGenerator-XV6SV6CD.js → geminiContentGenerator-6OULAKFQ.js} +4 -4
  162. package/chunks/{glob-2H6CDDMK.js → glob-ZMLFTD4T.js} +30 -25
  163. package/chunks/{grep-VXIUXM3C.js → grep-H5X66EI7.js} +30 -25
  164. package/chunks/initializer-LEOT2OLH.js +66 -0
  165. package/chunks/{ja-7DEUB2TS.js → ja-J7YAG7SA.js} +9 -9
  166. package/chunks/{keychain-token-storage-YLMDLKXT.js → keychain-token-storage-GPAKRDKQ.js} +2 -2
  167. package/chunks/list-M3DKXML6.js +70 -0
  168. package/chunks/loadedSettingsAdapter-OKMQFGGG.js +65 -0
  169. package/chunks/{loop-wakeup-CITGGQHA.js → loop-wakeup-FPBAVVPR.js} +5 -5
  170. package/chunks/{ls-R5WP4BGZ.js → ls-UGWQXPTY.js} +4 -4
  171. package/chunks/{lsp-GSICJMMW.js → lsp-24WV7NXB.js} +2 -2
  172. package/chunks/{monitor-HKLRS2HQ.js → monitor-ARL5P45R.js} +32 -26
  173. package/chunks/nonInteractiveCli-NUVLF3YR.js +108 -0
  174. package/chunks/{notebook-edit-Y6SKSGTT.js → notebook-edit-ANTZ2DDY.js} +31 -26
  175. package/chunks/{openaiContentGenerator-J7G2FYJT.js → openaiContentGenerator-TFGMKGHN.js} +15 -13
  176. package/chunks/pidfile-AWTL4C63.js +72 -0
  177. package/chunks/{pt-TNZRNLQB.js → pt-6RTAA6SS.js} +9 -9
  178. package/chunks/{qwenContentGenerator-5XIEM5GV.js → qwenContentGenerator-6QWAYTWS.js} +32 -27
  179. package/chunks/{qwenOAuth2-AG3PFFLZ.js → qwenOAuth2-LWLA6MQG.js} +5 -4
  180. package/chunks/{read-file-J7D552ZJ.js → read-file-EJY73XQ3.js} +11 -10
  181. package/chunks/{read-mcp-resource-DQQW7H7T.js → read-mcp-resource-NCBTPP7X.js} +2 -2
  182. package/chunks/ripGrep-HC4SA6CQ.js +59 -0
  183. package/chunks/{ru-NIAUBKCN.js → ru-AUBGJ2C4.js} +9 -9
  184. package/chunks/{run-qwen-serve-SGEEVMXD.js → run-qwen-serve-AGLZ642J.js} +454 -94
  185. package/chunks/{scheduler-7CQI3S4Q.js → scheduler-TURO7NGY.js} +30 -25
  186. package/chunks/{send-message-EE4TWKVU.js → send-message-3S2NYS3O.js} +6 -4
  187. package/chunks/serve-5DAMOIDW.js +70 -0
  188. package/chunks/{server-4QMUWXPW.js → server-4AGEK2HC.js} +4098 -1173
  189. package/chunks/{session-NRO7UFOY.js → session-7ZOQUC4Y.js} +204 -64
  190. package/chunks/{settings-SGWRDQSC.js → settings-DR4V6L5Y.js} +34 -29
  191. package/chunks/{shell-62ANGIHL.js → shell-H5WFKUXH.js} +30 -25
  192. package/chunks/{skill-VWAQAWW6.js → skill-ANHU5ZCR.js} +13 -12
  193. package/chunks/spawnChannel-VN5LJV7Z.js +68 -0
  194. package/chunks/{src-KUV5J5Q2.js → src-OVZLTVVM.js} +114 -30
  195. package/chunks/{startInteractiveUI-6EYJN3JV.js → startInteractiveUI-OA22V32P.js} +15970 -15430
  196. package/chunks/{syntheticOutput-T5YHQ6S2.js → syntheticOutput-SV7GBHZ5.js} +3 -3
  197. package/chunks/{task-create-BLY7RHXX.js → task-create-W2H2UJCH.js} +8 -7
  198. package/chunks/{task-list-3QUYNVYR.js → task-list-THBOPV4G.js} +7 -6
  199. package/chunks/{task-stop-U4RATK2V.js → task-stop-33FVCNCJ.js} +2 -2
  200. package/chunks/{task-update-U54O7KJX.js → task-update-LVFQLXEI.js} +8 -7
  201. package/chunks/{team-create-LPOGCPM7.js → team-create-OYL5CAQO.js} +30 -25
  202. package/chunks/{team-delete-LKBYPASD.js → team-delete-NTUQ25UY.js} +7 -6
  203. package/chunks/theme-manager-XCMPF2SI.js +63 -0
  204. package/chunks/{todoWrite-OYXKTVYN.js → todoWrite-SEPO2RI3.js} +4 -4
  205. package/chunks/{tool-search-YPUFJ3ZQ.js → tool-search-YXW55X6Z.js} +36 -11
  206. package/chunks/{trustedFolders-5B24TMEA.js → trustedFolders-TEPGM5YL.js} +31 -26
  207. package/chunks/{validateNonInterActiveAuth-BTDTYOVT.js → validateNonInterActiveAuth-OQIS7WUE.js} +65 -55
  208. package/chunks/{web-fetch-EEB5LZYU.js → web-fetch-OE7LHURA.js} +5 -4
  209. package/chunks/{workflow-LAWIW5LI.js → workflow-RTUWORAP.js} +67 -39
  210. package/chunks/workspace-providers-status-DM2XANVB.js +67 -0
  211. package/chunks/workspace-service-VKBI2KZD.js +77 -0
  212. package/chunks/{write-file-PCV226DJ.js → write-file-WGALQ53L.js} +35 -30
  213. package/chunks/{zh-TW-TR3XYGE5.js → zh-TW-6GIKXEAN.js} +30 -10
  214. package/chunks/{zh-5EUYXASN.js → zh-V3B4TFWL.js} +30 -10
  215. package/cli.js +6 -6
  216. package/locales/ca.js +13 -13
  217. package/locales/de.js +13 -13
  218. package/locales/en.js +49 -15
  219. package/locales/fr.js +13 -14
  220. package/locales/ja.js +13 -14
  221. package/locales/pt.js +13 -13
  222. package/locales/ru.js +13 -13
  223. package/locales/zh-TW.js +47 -14
  224. package/locales/zh.js +47 -14
  225. package/node_modules/@qwen-code/audio-capture/package.json +1 -1
  226. package/node_modules/@qwen-code/audio-capture/prebuilds/darwin-arm64/@qwen-code+audio-capture.node +0 -0
  227. package/node_modules/@qwen-code/audio-capture/prebuilds/darwin-x64/@qwen-code+audio-capture.node +0 -0
  228. package/node_modules/@qwen-code/audio-capture/prebuilds/win32-x64/@qwen-code+audio-capture.node +0 -0
  229. package/package.json +15 -6
  230. package/patches/chrome-devtools-mcp+1.4.0.patch +31 -0
  231. package/postinstall.js +50 -0
  232. package/web-shell/assets/{arc-DA7r8Ueo.js → arc-Det5Ccum.js} +1 -1
  233. package/web-shell/assets/{architectureDiagram-3BPJPVTR-ZDUxPtZ2.js → architectureDiagram-3BPJPVTR-DqNWVFpl.js} +1 -1
  234. package/web-shell/assets/{blockDiagram-GPEHLZMM-vrtOf1kJ.js → blockDiagram-GPEHLZMM-CYl7tYBi.js} +1 -1
  235. package/web-shell/assets/{c4Diagram-AAUBKEIU-BHFjzIi4.js → c4Diagram-AAUBKEIU-DaAEi0NQ.js} +1 -1
  236. package/web-shell/assets/channel-Bm0bFauD.js +1 -0
  237. package/web-shell/assets/{chunk-2J33WTMH-mdeQVz59.js → chunk-2J33WTMH-Df2CDEE2.js} +1 -1
  238. package/web-shell/assets/{chunk-4BX2VUAB-BkKMlwBX.js → chunk-4BX2VUAB-DNBFcyL2.js} +1 -1
  239. package/web-shell/assets/{chunk-55IACEB6-B7bnXNfu.js → chunk-55IACEB6-BKjF-0HI.js} +1 -1
  240. package/web-shell/assets/{chunk-727SXJPM-DGz8Mm6i.js → chunk-727SXJPM-DYwAwfIM.js} +1 -1
  241. package/web-shell/assets/{chunk-AQP2D5EJ-BQAydUNk.js → chunk-AQP2D5EJ-C6FswLqy.js} +1 -1
  242. package/web-shell/assets/{chunk-FMBD7UC4-GHr2LN_p.js → chunk-FMBD7UC4-DRWAcZSY.js} +1 -1
  243. package/web-shell/assets/{chunk-ND2GUHAM-7R91lnUx.js → chunk-ND2GUHAM-AoL16mNR.js} +1 -1
  244. package/web-shell/assets/{chunk-QZHKN3VN-aTJD3lSQ.js → chunk-QZHKN3VN-a8PtLMck.js} +1 -1
  245. package/web-shell/assets/classDiagram-4FO5ZUOK--NgUfb55.js +1 -0
  246. package/web-shell/assets/classDiagram-v2-Q7XG4LA2--NgUfb55.js +1 -0
  247. package/web-shell/assets/{cose-bilkent-S5V4N54A-BTf8t1RL.js → cose-bilkent-S5V4N54A-C4Aeu5qf.js} +1 -1
  248. package/web-shell/assets/{dagre-BM42HDAG-_sgp3WuA.js → dagre-BM42HDAG-BOulamjo.js} +1 -1
  249. package/web-shell/assets/{diagram-2AECGRRQ-CROtRy1w.js → diagram-2AECGRRQ-D1wt2ykO.js} +1 -1
  250. package/web-shell/assets/{diagram-5GNKFQAL-BqGRzwSc.js → diagram-5GNKFQAL-BRseus-O.js} +1 -1
  251. package/web-shell/assets/{diagram-KO2AKTUF-CMrcEtA7.js → diagram-KO2AKTUF-XSMkNzpZ.js} +1 -1
  252. package/web-shell/assets/{diagram-LMA3HP47-BRydGNW5.js → diagram-LMA3HP47-21KNLqoi.js} +1 -1
  253. package/web-shell/assets/{diagram-OG6HWLK6-D0ilgNjV.js → diagram-OG6HWLK6-DnUI8F5G.js} +1 -1
  254. package/web-shell/assets/{erDiagram-TEJ5UH35-2lnQeJUM.js → erDiagram-TEJ5UH35-BVSOMuM2.js} +1 -1
  255. package/web-shell/assets/{flowDiagram-I6XJVG4X-C_ZMdQiC.js → flowDiagram-I6XJVG4X-fYtDPJsW.js} +1 -1
  256. package/web-shell/assets/{ganttDiagram-6RSMTGT7-Dw9V_Ny0.js → ganttDiagram-6RSMTGT7-CmRXosW_.js} +1 -1
  257. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-HDXI-F1B.js → gitGraphDiagram-PVQCEYII-DPrmySxO.js} +1 -1
  258. package/web-shell/assets/index-BpKnmyFV.js +717 -0
  259. package/web-shell/assets/index-fLrtxpOG.css +5 -0
  260. package/web-shell/assets/{infoDiagram-5YYISTIA-CuB8Ebua.js → infoDiagram-5YYISTIA-x3VbEuCV.js} +1 -1
  261. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-D_tyhVwh.js → ishikawaDiagram-YF4QCWOH-SmitHRMC.js} +1 -1
  262. package/web-shell/assets/{journeyDiagram-JHISSGLW-CgCwJQNU.js → journeyDiagram-JHISSGLW-BxvA551S.js} +1 -1
  263. package/web-shell/assets/{kanban-definition-UN3LZRKU-PZUtcbPx.js → kanban-definition-UN3LZRKU-DNHC16jY.js} +1 -1
  264. package/web-shell/assets/{linear-CZqRdJIU.js → linear-CQ6irBL9.js} +1 -1
  265. package/web-shell/assets/{mermaid.core-CPW_4UEF.js → mermaid.core-DtB6NO1e.js} +72 -72
  266. package/web-shell/assets/{mindmap-definition-RKZ34NQL-D_Y75ID7.js → mindmap-definition-RKZ34NQL-QKMAgV2v.js} +1 -1
  267. package/web-shell/assets/{pieDiagram-4H26LBE5-Q4dTyLeF.js → pieDiagram-4H26LBE5-bvb6dGn6.js} +1 -1
  268. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-ckw329Ft.js → quadrantDiagram-W4KKPZXB-DLgdlG4D.js} +1 -1
  269. package/web-shell/assets/{requirementDiagram-4Y6WPE33-DbVDm4It.js → requirementDiagram-4Y6WPE33-2M9YH4GF.js} +1 -1
  270. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-CHuZ_ecH.js → sankeyDiagram-5OEKKPKP-DzwfclTH.js} +1 -1
  271. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-DU2YSpq-.js → sequenceDiagram-3UESZ5HK-BvPmTuy2.js} +1 -1
  272. package/web-shell/assets/{stateDiagram-AJRCARHV-CA9PEBUo.js → stateDiagram-AJRCARHV-BjwUmrJF.js} +1 -1
  273. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-C4L8zXeL.js +1 -0
  274. package/web-shell/assets/{timeline-definition-PNZ67QCA-Bhlo4WVc.js → timeline-definition-PNZ67QCA-CXzS6qqz.js} +1 -1
  275. package/web-shell/assets/{vennDiagram-CIIHVFJN-6xtPLsyl.js → vennDiagram-CIIHVFJN-yRSolF5B.js} +1 -1
  276. package/web-shell/assets/{wardley-L42UT6IY-3eozmXPf.js → wardley-L42UT6IY-ClLJjHPG.js} +1 -1
  277. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BOn6hKss.js → wardleyDiagram-YWT4CUSO-VIa6t2p2.js} +1 -1
  278. package/web-shell/assets/{xychartDiagram-2RQKCTM6-BsP4-I_y.js → xychartDiagram-2RQKCTM6-CtmrkezW.js} +1 -1
  279. package/web-shell/index.html +18 -2
  280. package/chunks/MaxSizedBox-QNF3EIGU.js +0 -63
  281. package/chunks/agent-headless-RQ5BTX3G.js +0 -56
  282. package/chunks/bridge-JL2PMCIW.js +0 -66
  283. package/chunks/chunk-5GOVVXEV.js +0 -73
  284. package/chunks/chunk-BC3C4F3Q.js +0 -40
  285. package/chunks/chunk-BW4KCQFD.js +0 -1103
  286. package/chunks/chunk-RKIZXJMB.js +0 -13
  287. package/chunks/contextCommand-WYU6OQ2F.js +0 -61
  288. package/chunks/daemon-status-provider-HH2EC5FI.js +0 -65
  289. package/chunks/headlessSafetyWarnings-TBE35GJ4.js +0 -55
  290. package/chunks/initializer-2Y7SLOKV.js +0 -61
  291. package/chunks/list-ZAFHZ7OS.js +0 -65
  292. package/chunks/loadedSettingsAdapter-6KJXD6M3.js +0 -60
  293. package/chunks/nonInteractiveCli-5W4GIZQM.js +0 -96
  294. package/chunks/ripGrep-IEIFIWP4.js +0 -54
  295. package/chunks/serve-V6GVZR6U.js +0 -65
  296. package/chunks/spawnChannel-3VHW5EPY.js +0 -63
  297. package/chunks/theme-manager-LYLGAERF.js +0 -58
  298. package/chunks/workspace-providers-status-PIAFVYHA.js +0 -62
  299. package/chunks/workspace-service-YAIOD4HG.js +0 -71
  300. package/web-shell/assets/channel-iRo68q4Q.js +0 -1
  301. package/web-shell/assets/classDiagram-4FO5ZUOK-iHF24a8X.js +0 -1
  302. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-iHF24a8X.js +0 -1
  303. package/web-shell/assets/index-CHmzAWys.css +0 -5
  304. package/web-shell/assets/index-w6GTOHh1.js +0 -713
  305. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-t1LRI0oY.js +0 -1
@@ -1,7 +1,14 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ import {
4
+ findCliEntryPath
5
+ } from "./chunk-AHNXYU4O.js";
6
+ import {
7
+ RUNTIME_STARTUP_CANCELLED_MESSAGE
8
+ } from "./chunk-GHOTR7HL.js";
3
9
  import {
4
10
  CAPABILITIES_SCHEMA_VERSION,
11
+ ClientMcpSenderRegistry,
5
12
  SERVE_CAPABILITY_REGISTRY,
6
13
  allowOriginCors,
7
14
  allowOriginMode,
@@ -13,90 +20,55 @@ import {
13
20
  getRateLimiter,
14
21
  getServeProtocolVersions,
15
22
  hostAllowlist,
16
- isLoopbackBind,
17
23
  listenerMaxConnections,
18
24
  parseAllowOriginPatterns,
19
25
  parseDaemonStatusDetail,
20
26
  positiveFiniteOrNull,
21
27
  require_express,
22
28
  resolveWebShellDir
23
- } from "./chunk-N4EJFBN5.js";
29
+ } from "./chunk-B7KGXIPZ.js";
30
+ import {
31
+ isLoopbackBind
32
+ } from "./chunk-RNBYOUGV.js";
24
33
  import "./chunk-3HX5LZ6R.js";
25
34
  import "./chunk-7RYW5LQV.js";
26
35
  import {
27
36
  getCliVersion
28
- } from "./chunk-GT2FGICD.js";
29
- import "./chunk-VBZ452JT.js";
30
- import "./chunk-QBZ22PQX.js";
31
- import "./chunk-ALX6BUYW.js";
32
- import "./chunk-P7M4GA57.js";
37
+ } from "./chunk-W6X4FGWX.js";
38
+ import "./chunk-EWALXUAD.js";
33
39
  import {
34
40
  canonicalizeWorkspace
35
- } from "./chunk-JE5FVRPC.js";
36
- import "./chunk-FXKVLFFY.js";
37
- import "./chunk-UFC57OYT.js";
38
- import "./chunk-L7OKCI7T.js";
41
+ } from "./chunk-SEZC2725.js";
42
+ import {
43
+ QWEN_SERVER_TOKEN_ENV
44
+ } from "./chunk-EDAGQADF.js";
45
+ import {
46
+ channelSelectionNames
47
+ } from "./chunk-MX2YXRER.js";
39
48
  import {
40
49
  loadServeFastPathSettings,
41
50
  preResolveServeFastPathHomeEnvOverrides
42
- } from "./chunk-QI7GOGJR.js";
51
+ } from "./chunk-KKQWC6WS.js";
43
52
  import {
44
53
  getGlobalQwenDirLite,
45
54
  resolveConfigPathLite
46
- } from "./chunk-CF6BB3LT.js";
55
+ } from "./chunk-PPFWEV7G.js";
47
56
  import {
48
57
  writeStderrLine,
49
58
  writeStdoutLine
50
59
  } from "./chunk-Y6Z2O3WR.js";
51
60
  import "./chunk-QYUE6W3T.js";
52
- import "./chunk-YAINVQ3Q.js";
53
- import "./chunk-K5PGHDBN.js";
61
+ import "./chunk-5P5XGNYH.js";
54
62
  import "./chunk-SKAZWEV5.js";
55
- import "./chunk-XJYUPHRC.js";
56
- import "./chunk-QLDPRILK.js";
57
- import "./chunk-BVSVIN45.js";
58
- import "./chunk-SBBN4BWR.js";
59
- import "./chunk-S7AKE7HL.js";
60
- import "./chunk-2MPVVENX.js";
61
- import "./chunk-ZTQ26VBE.js";
62
- import "./chunk-O2VBQ3Y2.js";
63
- import "./chunk-MLZQVCF3.js";
64
- import "./chunk-LQ7TMOCE.js";
65
- import "./chunk-LD2XBG6Z.js";
66
- import "./chunk-HYCC3XM3.js";
67
- import "./chunk-NL4C3H6C.js";
68
- import "./chunk-JOLIREYR.js";
69
- import "./chunk-DDMOU62Q.js";
70
- import "./chunk-QNKBEJO2.js";
71
- import "./chunk-3PJXIDKI.js";
72
63
  import "./chunk-UWCTAVOD.js";
73
- import "./chunk-OFEVLU4C.js";
74
- import "./chunk-OMX7CUOE.js";
75
- import "./chunk-RD6YJJJ6.js";
76
- import "./chunk-SKQZZVAV.js";
77
- import "./chunk-BUUQ5HPX.js";
78
- import "./chunk-BX5YO7UW.js";
79
- import "./chunk-UO5GVXQE.js";
80
- import "./chunk-KMGMKW5Q.js";
81
- import "./chunk-22IFUCVR.js";
82
- import "./chunk-3227DZO4.js";
83
- import "./chunk-U3KSMM7G.js";
84
- import "./chunk-BKXBARJZ.js";
85
- import "./chunk-EJYJYJZ2.js";
86
- import "./chunk-55ZMG67I.js";
87
- import "./chunk-H6BD2ELD.js";
88
- import "./chunk-5IFG2VC4.js";
89
- import "./chunk-64WXLC72.js";
90
- import "./chunk-UX4SGCGN.js";
64
+ import "./chunk-SYCJMSIJ.js";
91
65
  import {
92
66
  finalizeStartupProfile,
93
67
  profileCheckpoint
94
68
  } from "./chunk-ITOGNELQ.js";
95
69
  import "./chunk-FXGLL2HL.js";
96
- import "./chunk-ZERZSAZL.js";
97
70
  import "./chunk-QN5NZ3UQ.js";
98
71
  import "./chunk-BR4QREVK.js";
99
- import "./chunk-Z2Z3GUXZ.js";
100
72
  import {
101
73
  init_esbuild_shims
102
74
  } from "./chunk-A4BMJM77.js";
@@ -391,11 +363,14 @@ function initDaemonLogger(opts) {
391
363
  __name(initDaemonLogger, "initDaemonLogger");
392
364
 
393
365
  // packages/cli/src/serve/run-qwen-serve.ts
394
- var QWEN_SERVER_TOKEN_ENV = "QWEN_SERVER_TOKEN";
366
+ var QWEN_SERVE_CLIENT_MCP_OVER_WS_ENV = "QWEN_SERVE_CLIENT_MCP_OVER_WS";
367
+ var QWEN_SERVE_CDP_TUNNEL_OVER_WS_ENV = "QWEN_SERVE_CDP_TUNNEL_OVER_WS";
395
368
  var QWEN_SERVE_PROMPT_DEADLINE_MS_ENV = "QWEN_SERVE_PROMPT_DEADLINE_MS";
396
369
  var QWEN_SERVE_WRITER_IDLE_TIMEOUT_MS_ENV = "QWEN_SERVE_WRITER_IDLE_TIMEOUT_MS";
397
370
  var SHUTDOWN_FORCE_CLOSE_MS = 5e3;
398
371
  var DEFAULT_RUNTIME_STARTUP_TIMEOUT_MS = 12e4;
372
+ var FAST_PATH_RUNTIME_START_AFTER_HEALTH_MS = 50;
373
+ var FAST_PATH_RUNTIME_START_FALLBACK_MS = 1e3;
399
374
  var RUNTIME_STARTUP_TIMEOUT_ENV = "QWEN_SERVE_RUNTIME_STARTUP_TIMEOUT_MS";
400
375
  var MAX_EVENT_RING_SIZE = 1e6;
401
376
  var DEFAULT_MAX_SESSIONS = 20;
@@ -436,6 +411,18 @@ function parseDeadlineEnv(envName, raw) {
436
411
  return parsed;
437
412
  }
438
413
  __name(parseDeadlineEnv, "parseDeadlineEnv");
414
+ function envFlagDisabled(raw) {
415
+ if (raw === void 0) return false;
416
+ const normalized = raw.trim().toLowerCase();
417
+ return normalized === "0" || normalized === "false";
418
+ }
419
+ __name(envFlagDisabled, "envFlagDisabled");
420
+ function hasChromeExtensionOrigin(origins) {
421
+ return origins?.some(
422
+ (origin) => origin.trim().toLowerCase().startsWith("chrome-extension://")
423
+ ) === true;
424
+ }
425
+ __name(hasChromeExtensionOrigin, "hasChromeExtensionOrigin");
439
426
  function createDaemonTelemetryRuntimeConfig(telemetry, cliVersion, daemonSessionId, defaults) {
440
427
  return {
441
428
  getTelemetryEnabled: /* @__PURE__ */ __name(() => telemetry.enabled ?? false, "getTelemetryEnabled"),
@@ -506,6 +493,14 @@ function formatHostForUrl(host) {
506
493
  return host;
507
494
  }
508
495
  __name(formatHostForUrl, "formatHostForUrl");
496
+ function formatChannelWorkerDaemonUrl(host, port) {
497
+ const normalized = host.trim().toLowerCase();
498
+ if (normalized === "" || normalized === "0.0.0.0" || normalized === "::" || normalized === "[::]") {
499
+ return `http://127.0.0.1:${port}`;
500
+ }
501
+ return `http://${formatHostForUrl(host)}:${port}`;
502
+ }
503
+ __name(formatChannelWorkerDaemonUrl, "formatChannelWorkerDaemonUrl");
509
504
  function extractContextFilename(value) {
510
505
  if (typeof value === "string") {
511
506
  const trimmed = value.trim();
@@ -531,6 +526,52 @@ function withSettingsLock(workspace, fn) {
531
526
  return next;
532
527
  }
533
528
  __name(withSettingsLock, "withSettingsLock");
529
+ var channelWorkerRuntimePromise;
530
+ async function loadChannelWorkerRuntime() {
531
+ channelWorkerRuntimePromise ??= Promise.all([
532
+ import("./channel-worker-supervisor-A74FV522.js"),
533
+ import("./pidfile-AWTL4C63.js")
534
+ ]).then(([supervisor, pidfile]) => ({
535
+ createChannelWorkerSupervisor: supervisor.createChannelWorkerSupervisor,
536
+ channelServicePidfile: pidfile
537
+ })).catch((err) => {
538
+ channelWorkerRuntimePromise = void 0;
539
+ throw err;
540
+ });
541
+ return channelWorkerRuntimePromise;
542
+ }
543
+ __name(loadChannelWorkerRuntime, "loadChannelWorkerRuntime");
544
+ function createDisabledChannelWorkerSupervisor() {
545
+ const snapshot = {
546
+ enabled: false,
547
+ state: "disabled",
548
+ channels: []
549
+ };
550
+ return {
551
+ async start() {
552
+ },
553
+ async stop() {
554
+ },
555
+ killAllSync() {
556
+ },
557
+ snapshot: /* @__PURE__ */ __name(() => ({ ...snapshot, channels: [] }), "snapshot")
558
+ };
559
+ }
560
+ __name(createDisabledChannelWorkerSupervisor, "createDisabledChannelWorkerSupervisor");
561
+ function writeServeChannelReservation(channelServicePidfile, channels) {
562
+ channelServicePidfile.reserveServeServiceInfo({
563
+ channels,
564
+ servePid: process.pid
565
+ });
566
+ }
567
+ __name(writeServeChannelReservation, "writeServeChannelReservation");
568
+ function channelServicePidfileConflictError(info) {
569
+ const owner = info.owner === "serve" ? "qwen serve" : "qwen channel start";
570
+ return new Error(
571
+ `Channel service is already running under ${owner} (PID ${info.pid}). Stop it before starting qwen serve --channel.`
572
+ );
573
+ }
574
+ __name(channelServicePidfileConflictError, "channelServicePidfileConflictError");
534
575
  function normalizeInstallModelIds(req, provider, getDefaultModelIds) {
535
576
  const fromRequest = req.modelIds?.map((id) => id.trim()).filter((id) => id.length > 0);
536
577
  const modelIds = fromRequest && fromRequest.length > 0 ? fromRequest : getDefaultModelIds(provider);
@@ -560,7 +601,7 @@ function shouldPreheatBridge(deps) {
560
601
  __name(shouldPreheatBridge, "shouldPreheatBridge");
561
602
  var coreRuntimePromise;
562
603
  function loadCoreRuntime() {
563
- coreRuntimePromise ??= import("./src-KUV5J5Q2.js");
604
+ coreRuntimePromise ??= import("./src-OVZLTVVM.js");
564
605
  return coreRuntimePromise;
565
606
  }
566
607
  __name(loadCoreRuntime, "loadCoreRuntime");
@@ -590,9 +631,9 @@ __name(resolveDaemonLogBaseDirForRun, "resolveDaemonLogBaseDirForRun");
590
631
  var settingsRuntimePromise;
591
632
  function loadSettingsRuntimeModules() {
592
633
  settingsRuntimePromise ??= Promise.all([
593
- import("./settings-SGWRDQSC.js"),
594
- import("./loadedSettingsAdapter-6KJXD6M3.js"),
595
- import("./trustedFolders-5B24TMEA.js")
634
+ import("./settings-DR4V6L5Y.js"),
635
+ import("./loadedSettingsAdapter-OKMQFGGG.js"),
636
+ import("./trustedFolders-TEPGM5YL.js")
596
637
  ]).then(([settings, loadedSettingsAdapter, trustedFolders]) => ({
597
638
  settings,
598
639
  loadedSettingsAdapter,
@@ -611,13 +652,13 @@ async function loadServeRuntimeModules() {
611
652
  daemonStatusProviderModule,
612
653
  workspaceProvidersStatusModule
613
654
  ] = await Promise.all([
614
- import("./server-4QMUWXPW.js"),
615
- import("./bridge-JL2PMCIW.js"),
616
- import("./spawnChannel-3VHW5EPY.js"),
617
- import("./workspace-service-YAIOD4HG.js"),
655
+ import("./server-4AGEK2HC.js"),
656
+ import("./bridge-AUHNFOUS.js"),
657
+ import("./spawnChannel-VN5LJV7Z.js"),
658
+ import("./workspace-service-VKBI2KZD.js"),
618
659
  import("./types-QX5C3CHJ.js"),
619
- import("./daemon-status-provider-HH2EC5FI.js"),
620
- import("./workspace-providers-status-PIAFVYHA.js")
660
+ import("./daemon-status-provider-V5UY7O7J.js"),
661
+ import("./workspace-providers-status-DM2XANVB.js")
621
662
  ]);
622
663
  return {
623
664
  createServeApp: serverModule.createServeApp,
@@ -662,7 +703,11 @@ function currentServeFeaturesForRunQwenServe(opts, sessionShellCommandEnabled) {
662
703
  persistSettingAvailable: true,
663
704
  sessionShellCommandEnabled,
664
705
  rateLimit: opts.rateLimit === true,
665
- reloadAvailable: true
706
+ reloadAvailable: true,
707
+ // Advertise the same WS feature flags as the runtime path (serve-features.ts)
708
+ // so the bootstrap `/capabilities` window doesn't briefly under-report them.
709
+ clientMcpOverWsEnabled: opts.clientMcpOverWs === true,
710
+ cdpTunnelOverWsEnabled: opts.cdpTunnelOverWs === true
666
711
  });
667
712
  }
668
713
  __name(currentServeFeaturesForRunQwenServe, "currentServeFeaturesForRunQwenServe");
@@ -787,6 +832,14 @@ async function waitForRuntimeStartingForShutdown(runtimeStarting, daemonLog, tim
787
832
  });
788
833
  }
789
834
  __name(waitForRuntimeStartingForShutdown, "waitForRuntimeStartingForShutdown");
835
+ var BOOTSTRAP_HEALTH_PATH = "/health";
836
+ var BOOTSTRAP_CAPABILITIES_PATH = "/capabilities";
837
+ var BOOTSTRAP_DAEMON_STATUS_PATH = "/daemon/status";
838
+ var BOOTSTRAP_SERVE_PATHS = /* @__PURE__ */ new Set([
839
+ BOOTSTRAP_HEALTH_PATH,
840
+ BOOTSTRAP_CAPABILITIES_PATH,
841
+ BOOTSTRAP_DAEMON_STATUS_PATH
842
+ ]);
790
843
  function createBootstrapServeApp(input) {
791
844
  const {
792
845
  opts,
@@ -797,7 +850,9 @@ function createBootstrapServeApp(input) {
797
850
  qwenCodeVersion,
798
851
  sessionShellCommandEnabled,
799
852
  permissionPolicy,
800
- getRuntimeError
853
+ getRuntimeError,
854
+ getChannelWorkerSnapshot,
855
+ onHealthServed
801
856
  } = input;
802
857
  const app = (0, import_express.default)();
803
858
  installSameOriginOriginStrip(app, getPort);
@@ -816,18 +871,21 @@ function createBootstrapServeApp(input) {
816
871
  });
817
872
  return;
818
873
  }
874
+ if (onHealthServed) {
875
+ res.once("finish", onHealthServed);
876
+ }
819
877
  res.status(200).json({ status: "ok" });
820
878
  }, "healthHandler");
821
879
  const loopback = isLoopbackBind(opts.hostname);
822
880
  const exposeHealthPreAuth = loopback && !opts.requireAuth;
823
881
  if (exposeHealthPreAuth) {
824
- app.get("/health", healthHandler);
882
+ app.get(BOOTSTRAP_HEALTH_PATH, healthHandler);
825
883
  }
826
884
  app.use(bearerAuth(opts.token));
827
885
  if (!exposeHealthPreAuth) {
828
- app.get("/health", healthHandler);
886
+ app.get(BOOTSTRAP_HEALTH_PATH, healthHandler);
829
887
  }
830
- app.get("/capabilities", (_req, res) => {
888
+ app.get(BOOTSTRAP_CAPABILITIES_PATH, (_req, res) => {
831
889
  res.status(200).json(
832
890
  createBootstrapCapabilities({
833
891
  opts,
@@ -838,7 +896,7 @@ function createBootstrapServeApp(input) {
838
896
  })
839
897
  );
840
898
  });
841
- app.get("/daemon/status", (req, res) => {
899
+ app.get(BOOTSTRAP_DAEMON_STATUS_PATH, (req, res) => {
842
900
  const detail = parseDaemonStatusDetail(req.query["detail"]);
843
901
  if (!detail.ok || !detail.detail) {
844
902
  res.status(400).json({
@@ -848,6 +906,7 @@ function createBootstrapServeApp(input) {
848
906
  return;
849
907
  }
850
908
  const runtimeError = getRuntimeError();
909
+ const channelWorker = getChannelWorkerSnapshot();
851
910
  const runtimeFailed = runtimeError !== void 0;
852
911
  const issue = runtimeError ? {
853
912
  code: "daemon_runtime_failed",
@@ -914,6 +973,7 @@ function createBootstrapServeApp(input) {
914
973
  policy: permissionPolicy ?? "first-responder"
915
974
  },
916
975
  channel: { live: false },
976
+ channelWorker,
917
977
  transport: {
918
978
  restSseActive: 0,
919
979
  acp: {
@@ -960,16 +1020,58 @@ function createBootstrapServeApp(input) {
960
1020
  return app;
961
1021
  }
962
1022
  __name(createBootstrapServeApp, "createBootstrapServeApp");
963
- function createDelegatingServeApp(bootstrapApp, getRuntimeApp) {
1023
+ function createDelegatingServeApp(bootstrapApp, getRuntimeApp, options = {}) {
964
1024
  const app = (0, import_express.default)();
965
1025
  app.use((req, res, next) => {
966
- const target = getRuntimeApp() ?? bootstrapApp;
967
- const handler = target;
968
- handler(req, res, next);
1026
+ const dispatch = /* @__PURE__ */ __name(async () => {
1027
+ let target = getRuntimeApp();
1028
+ if (!target && options.waitForDeferredRuntimeRoutes === true && !isBootstrapServeRoute(req) && !isCorsPreflightRequest(req) && options.startRuntime && options.runtimeReady) {
1029
+ if (options.authenticateDeferredRuntimeRequest && !runSynchronousRequestGate(
1030
+ options.authenticateDeferredRuntimeRequest,
1031
+ req,
1032
+ res,
1033
+ next
1034
+ )) {
1035
+ return;
1036
+ }
1037
+ options.startRuntime();
1038
+ try {
1039
+ await options.runtimeReady;
1040
+ } catch {
1041
+ }
1042
+ target = getRuntimeApp();
1043
+ }
1044
+ const handler = target ?? bootstrapApp;
1045
+ handler(req, res, next);
1046
+ }, "dispatch");
1047
+ void dispatch().catch(next);
969
1048
  });
970
1049
  return app;
971
1050
  }
972
1051
  __name(createDelegatingServeApp, "createDelegatingServeApp");
1052
+ function isBootstrapServeRoute(req) {
1053
+ const path2 = req.path.length > 1 && req.path.endsWith("/") ? req.path.slice(0, -1) : req.path;
1054
+ return BOOTSTRAP_SERVE_PATHS.has(path2);
1055
+ }
1056
+ __name(isBootstrapServeRoute, "isBootstrapServeRoute");
1057
+ function isCorsPreflightRequest(req) {
1058
+ return req.method === "OPTIONS" && Boolean(req.headers.origin) && Boolean(
1059
+ req.headers["access-control-request-method"] || req.headers["access-control-request-headers"]
1060
+ );
1061
+ }
1062
+ __name(isCorsPreflightRequest, "isCorsPreflightRequest");
1063
+ function runSynchronousRequestGate(handler, req, res, next) {
1064
+ let passed = false;
1065
+ handler(req, res, (err) => {
1066
+ if (err) {
1067
+ next(err);
1068
+ return;
1069
+ }
1070
+ passed = true;
1071
+ });
1072
+ return passed;
1073
+ }
1074
+ __name(runSynchronousRequestGate, "runSynchronousRequestGate");
973
1075
  async function runQwenServe(optsIn, deps = {}) {
974
1076
  const runStartedAt = performance.now();
975
1077
  const shouldPreheat = !deps.bridge && shouldPreheatBridge(deps);
@@ -998,12 +1100,78 @@ async function runQwenServe(optsIn, deps = {}) {
998
1100
  QWEN_SERVE_WRITER_IDLE_TIMEOUT_MS_ENV,
999
1101
  process.env[QWEN_SERVE_WRITER_IDLE_TIMEOUT_MS_ENV]
1000
1102
  );
1103
+ const clientMcpOverWsEnv = process.env[QWEN_SERVE_CLIENT_MCP_OVER_WS_ENV];
1104
+ const cdpTunnelOverWsEnv = process.env[QWEN_SERVE_CDP_TUNNEL_OVER_WS_ENV];
1105
+ const chromeExtensionOriginAllowed = hasChromeExtensionOrigin(
1106
+ optsIn.allowOrigins
1107
+ );
1001
1108
  const opts = {
1002
1109
  ...optsIn,
1003
1110
  token,
1004
1111
  promptDeadlineMs,
1005
- writerIdleTimeoutMs
1112
+ writerIdleTimeoutMs,
1113
+ clientMcpOverWs: optsIn.clientMcpOverWs ?? (!envFlagDisabled(clientMcpOverWsEnv) && clientMcpOverWsEnv !== void 0),
1114
+ cdpTunnelOverWs: optsIn.cdpTunnelOverWs ?? (!envFlagDisabled(cdpTunnelOverWsEnv) && (cdpTunnelOverWsEnv !== void 0 || chromeExtensionOriginAllowed))
1006
1115
  };
1116
+ const channelRuntime = opts.channelSelection ? await loadChannelWorkerRuntime() : void 0;
1117
+ const channelServicePidfile = deps.channelServicePidfile ?? channelRuntime?.channelServicePidfile;
1118
+ let channelPidfileReserved = false;
1119
+ const removeCurrentServePidfile = /* @__PURE__ */ __name(() => {
1120
+ if (!opts.channelSelection || !channelServicePidfile) return;
1121
+ if (!channelPidfileReserved) return;
1122
+ if (channelServicePidfile.removeServeServiceInfo) {
1123
+ if (channelServicePidfile.removeServeServiceInfo(process.pid)) {
1124
+ channelPidfileReserved = false;
1125
+ }
1126
+ return;
1127
+ }
1128
+ const info = channelServicePidfile.readServiceInfo();
1129
+ if (info?.owner === "serve" && info.pid === process.pid && info.servePid === process.pid) {
1130
+ channelServicePidfile.removeServiceInfo();
1131
+ channelPidfileReserved = false;
1132
+ }
1133
+ }, "removeCurrentServePidfile");
1134
+ const reserveChannelServicePidfile = /* @__PURE__ */ __name(() => {
1135
+ if (!opts.channelSelection) return;
1136
+ if (!channelServicePidfile) {
1137
+ throw new Error("Channel service pidfile runtime is not available.");
1138
+ }
1139
+ const channelPidfileNames = channelSelectionNames(opts.channelSelection);
1140
+ const existingChannelService = channelServicePidfile.readServiceInfo();
1141
+ if (existingChannelService) {
1142
+ throw channelServicePidfileConflictError(existingChannelService);
1143
+ }
1144
+ try {
1145
+ writeServeChannelReservation(channelServicePidfile, channelPidfileNames);
1146
+ channelPidfileReserved = true;
1147
+ } catch (err) {
1148
+ if (err && typeof err === "object" && "code" in err) {
1149
+ const code = err.code;
1150
+ if (code === "EEXIST") {
1151
+ const info = channelServicePidfile.readServiceInfo();
1152
+ if (info) {
1153
+ throw channelServicePidfileConflictError(info);
1154
+ }
1155
+ try {
1156
+ writeServeChannelReservation(
1157
+ channelServicePidfile,
1158
+ channelPidfileNames
1159
+ );
1160
+ channelPidfileReserved = true;
1161
+ return;
1162
+ } catch (retryErr) {
1163
+ if (retryErr && typeof retryErr === "object" && "code" in retryErr && retryErr.code === "EEXIST") {
1164
+ throw new Error(
1165
+ "Channel service is already starting. Retry after the current startup finishes."
1166
+ );
1167
+ }
1168
+ throw retryErr;
1169
+ }
1170
+ }
1171
+ }
1172
+ throw err;
1173
+ }
1174
+ }, "reserveChannelServicePidfile");
1007
1175
  validateRateLimitOptions(opts);
1008
1176
  if (!opts.hostname.startsWith("[") && opts.hostname.split(":").length === 2) {
1009
1177
  const [host, port] = opts.hostname.split(":");
@@ -1182,7 +1350,8 @@ async function runQwenServe(optsIn, deps = {}) {
1182
1350
  }
1183
1351
  const childEnvOverrides = {
1184
1352
  QWEN_SERVE_MCP_CLIENT_BUDGET: opts.mcpClientBudget !== void 0 ? String(opts.mcpClientBudget) : void 0,
1185
- QWEN_SERVE_MCP_BUDGET_MODE: opts.mcpBudgetMode
1353
+ QWEN_SERVE_MCP_BUDGET_MODE: opts.mcpBudgetMode,
1354
+ QWEN_SERVE_CDP_TUNNEL_OVER_WS: opts.cdpTunnelOverWs ? "1" : void 0
1186
1355
  };
1187
1356
  const cliVersionPromise = getCliVersion();
1188
1357
  let cliVersion;
@@ -1217,12 +1386,32 @@ async function runQwenServe(optsIn, deps = {}) {
1217
1386
  let markRuntimeReady;
1218
1387
  let markRuntimeFailed;
1219
1388
  let runtimeStartupSettled = false;
1389
+ let startRuntimeAfterHealth;
1390
+ let startRuntimeForRequest;
1391
+ const deferRuntimeUntilFirstHealth = deps.resolveOnListen === true && deps.deferRuntimeUntilFirstHealth === true;
1220
1392
  const runtimeReady = new Promise((resolve, reject) => {
1221
1393
  markRuntimeReady = resolve;
1222
1394
  markRuntimeFailed = reject;
1223
1395
  });
1224
1396
  void runtimeReady.catch(() => {
1225
1397
  });
1398
+ let channelWorker = createDisabledChannelWorkerSupervisor();
1399
+ const getChannelWorkerSnapshot = /* @__PURE__ */ __name(() => channelWorker.snapshot(), "getChannelWorkerSnapshot");
1400
+ const writeChannelWorkerPidfile = /* @__PURE__ */ __name(() => {
1401
+ if (!opts.channelSelection || !channelServicePidfile) return;
1402
+ const snapshot = channelWorker.snapshot();
1403
+ try {
1404
+ channelServicePidfile.writeServeServiceInfo({
1405
+ channels: snapshot.channels,
1406
+ servePid: process.pid,
1407
+ workerPid: snapshot.pid
1408
+ });
1409
+ } catch (err) {
1410
+ daemonLog.warn(
1411
+ `failed to write channel worker pidfile metadata: ${err instanceof Error ? err.message : String(err)}`
1412
+ );
1413
+ }
1414
+ }, "writeChannelWorkerPidfile");
1226
1415
  const handleBridge = deps.bridge ?? createLazyBridgeProxy(
1227
1416
  () => bridgeRef,
1228
1417
  () => runtimeStartupError
@@ -1329,6 +1518,7 @@ async function runQwenServe(optsIn, deps = {}) {
1329
1518
  });
1330
1519
  const statusProvider = runtime.createDaemonStatusProvider();
1331
1520
  const workspaceProvidersStatusProvider = runtime.createWorkspaceProvidersStatusProvider();
1521
+ const clientMcpSenderRegistry = new ClientMcpSenderRegistry();
1332
1522
  const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled) => withSettingsLock(workspace, async () => {
1333
1523
  const fresh = settingsRuntime.settings.loadSettings(workspace);
1334
1524
  const wsScope = fresh.forScope(WORKSPACE_SETTING_SCOPE).settings;
@@ -1376,6 +1566,9 @@ async function runQwenServe(optsIn, deps = {}) {
1376
1566
  }
1377
1567
  }), "persistSettingsFn");
1378
1568
  const bridge = deps.bridge ?? runtime.createAcpSessionBridge({
1569
+ // Reverse tool channel: let `BridgeClient.extMethod` reach the WS
1570
+ // connection that hosts a named client MCP server (#5626).
1571
+ clientMcpSender: clientMcpSenderRegistry.lookup,
1379
1572
  maxSessions: opts.maxSessions,
1380
1573
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
1381
1574
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
@@ -1438,7 +1631,11 @@ async function runQwenServe(optsIn, deps = {}) {
1438
1631
  startup,
1439
1632
  fsFactory,
1440
1633
  daemonLog,
1634
+ getChannelWorkerSnapshot,
1441
1635
  workspace: workspaceService,
1636
+ // Reverse tool channel (#5626): the SAME registry wired into `bridge` above,
1637
+ // so the WS provider and the child-answering bridge share one sender map.
1638
+ clientMcpSenderRegistry,
1442
1639
  persistDisabledTools: persistDisabledToolsFn,
1443
1640
  persistSetting: persistSettingFn,
1444
1641
  persistSettings: persistSettingsFn,
@@ -1487,8 +1684,10 @@ async function runQwenServe(optsIn, deps = {}) {
1487
1684
  runtimeAppForCleanup = runtime.app;
1488
1685
  runtimeApp = runtime.app;
1489
1686
  bridgeRef = runtime.bridge;
1490
- runtimeStartupSettled = true;
1491
- markRuntimeReady();
1687
+ if (!opts.channelSelection) {
1688
+ runtimeStartupSettled = true;
1689
+ markRuntimeReady();
1690
+ }
1492
1691
  }
1493
1692
  cliVersion ??= await cliVersionPromise;
1494
1693
  const bootstrapApp = createBootstrapServeApp({
@@ -1500,9 +1699,16 @@ async function runQwenServe(optsIn, deps = {}) {
1500
1699
  qwenCodeVersion: cliVersion,
1501
1700
  sessionShellCommandEnabled,
1502
1701
  permissionPolicy,
1503
- getRuntimeError: /* @__PURE__ */ __name(() => runtimeStartupError, "getRuntimeError")
1702
+ getRuntimeError: /* @__PURE__ */ __name(() => runtimeStartupError, "getRuntimeError"),
1703
+ getChannelWorkerSnapshot,
1704
+ onHealthServed: deferRuntimeUntilFirstHealth ? () => startRuntimeAfterHealth?.() : void 0
1705
+ });
1706
+ const app = runtimeApp ?? createDelegatingServeApp(bootstrapApp, () => runtimeApp, {
1707
+ waitForDeferredRuntimeRoutes: deferRuntimeUntilFirstHealth,
1708
+ startRuntime: /* @__PURE__ */ __name(() => startRuntimeForRequest?.(), "startRuntime"),
1709
+ runtimeReady,
1710
+ authenticateDeferredRuntimeRequest: bearerAuth(opts.token)
1504
1711
  });
1505
- const app = runtimeApp ?? createDelegatingServeApp(bootstrapApp, () => runtimeApp);
1506
1712
  let listenHostname = opts.hostname;
1507
1713
  if (opts.hostname.startsWith("[")) {
1508
1714
  const inner = opts.hostname.slice(1, -1);
@@ -1518,6 +1724,7 @@ async function runQwenServe(optsIn, deps = {}) {
1518
1724
  `Invalid maxConnections: ${opts.maxConnections}. Must be >= 0 (0 / Infinity = unlimited).`
1519
1725
  );
1520
1726
  }
1727
+ reserveChannelServicePidfile();
1521
1728
  return await new Promise((resolve, reject) => {
1522
1729
  const server = app.listen(opts.port, listenHostname, () => {
1523
1730
  startup.listenerReadyAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -1534,6 +1741,42 @@ async function runQwenServe(optsIn, deps = {}) {
1534
1741
  const addr = server.address();
1535
1742
  actualPort = typeof addr === "object" && addr ? addr.port : opts.port;
1536
1743
  const url = `http://${formatHostForUrl(opts.hostname)}:${actualPort}`;
1744
+ try {
1745
+ if (opts.channelSelection) {
1746
+ const createSupervisor = deps.channelWorkerSupervisorFactory ?? channelRuntime?.createChannelWorkerSupervisor;
1747
+ if (!createSupervisor) {
1748
+ throw new Error(
1749
+ "Channel worker supervisor runtime is not available."
1750
+ );
1751
+ }
1752
+ channelWorker = createSupervisor({
1753
+ cliEntryPath: findCliEntryPath(),
1754
+ daemonUrl: formatChannelWorkerDaemonUrl(opts.hostname, actualPort),
1755
+ ...token ? { daemonToken: token } : {},
1756
+ workspace: boundWorkspace,
1757
+ selection: opts.channelSelection,
1758
+ onExit: /* @__PURE__ */ __name((snapshot) => {
1759
+ daemonLog.warn(
1760
+ `channel worker exited (state=${snapshot.state}, pid=${snapshot.pid ?? "unknown"}, code=${snapshot.exitCode ?? "null"}, signal=${snapshot.signal ?? "null"}, error=${snapshot.error ?? "none"})`
1761
+ );
1762
+ removeCurrentServePidfile();
1763
+ }, "onExit")
1764
+ });
1765
+ }
1766
+ } catch (err) {
1767
+ removeCurrentServePidfile();
1768
+ const error = err instanceof Error ? err : new Error(String(err));
1769
+ server.close((closeErr) => {
1770
+ if (closeErr) {
1771
+ daemonLog.error(
1772
+ "server close after channel worker setup error failed",
1773
+ closeErr
1774
+ );
1775
+ }
1776
+ reject(error);
1777
+ });
1778
+ return;
1779
+ }
1537
1780
  writeStdoutLine(
1538
1781
  `qwen serve listening on ${url} (mode=${opts.mode}, workspace=${boundWorkspace})`
1539
1782
  );
@@ -1547,6 +1790,11 @@ async function runQwenServe(optsIn, deps = {}) {
1547
1790
  writeStderrLine(
1548
1791
  `qwen serve: bearer auth disabled (loopback default). Set ${QWEN_SERVER_TOKEN_ENV} to enable.`
1549
1792
  );
1793
+ if (opts.clientMcpOverWs === true) {
1794
+ writeStderrLine(
1795
+ `qwen serve: client-hosted MCP tools are accepted over the WebSocket without auth. Set ${QWEN_SERVE_CLIENT_MCP_OVER_WS_ENV}=0 to disable.`
1796
+ );
1797
+ }
1550
1798
  } else if (opts.requireAuth) {
1551
1799
  writeStderrLine(
1552
1800
  "qwen serve: --require-auth enabled (bearer token mandatory on every route, including loopback /health)."
@@ -1555,6 +1803,8 @@ async function runQwenServe(optsIn, deps = {}) {
1555
1803
  let shuttingDown = false;
1556
1804
  let closePromise;
1557
1805
  let runtimeStartupTimer;
1806
+ let runtimeStartAfterHealthTimer;
1807
+ let runtimeStartFallbackTimer;
1558
1808
  const runtimeStartupTimeoutMs = resolveRuntimeStartupTimeoutMs(
1559
1809
  deps.runtimeStartupTimeoutMs
1560
1810
  );
@@ -1563,6 +1813,27 @@ async function runQwenServe(optsIn, deps = {}) {
1563
1813
  clearTimeout(runtimeStartupTimer);
1564
1814
  runtimeStartupTimer = void 0;
1565
1815
  }, "clearRuntimeStartupTimer");
1816
+ const clearRuntimeStartFallbackTimer = /* @__PURE__ */ __name(() => {
1817
+ if (!runtimeStartFallbackTimer) return;
1818
+ clearTimeout(runtimeStartFallbackTimer);
1819
+ runtimeStartFallbackTimer = void 0;
1820
+ }, "clearRuntimeStartFallbackTimer");
1821
+ const clearRuntimeStartAfterHealthTimer = /* @__PURE__ */ __name(() => {
1822
+ if (!runtimeStartAfterHealthTimer) return;
1823
+ clearTimeout(runtimeStartAfterHealthTimer);
1824
+ runtimeStartAfterHealthTimer = void 0;
1825
+ }, "clearRuntimeStartAfterHealthTimer");
1826
+ const cancelDeferredRuntimeStartup = /* @__PURE__ */ __name(() => {
1827
+ if (!deferRuntimeUntilFirstHealth || runtimeStarting || runtimeStartupSettled)
1828
+ return;
1829
+ daemonLog.info(
1830
+ "deferred runtime: cancelled, server closed before startup"
1831
+ );
1832
+ runtimeStartupSettled = true;
1833
+ const error = new Error(RUNTIME_STARTUP_CANCELLED_MESSAGE);
1834
+ runtimeStartupError = error.message;
1835
+ markRuntimeFailed(error);
1836
+ }, "cancelDeferredRuntimeStartup");
1566
1837
  const shutdownBridgeAfterFailedStartup = /* @__PURE__ */ __name(async (bridge) => {
1567
1838
  if (!bridge || deps.bridge) return;
1568
1839
  try {
@@ -1578,6 +1849,14 @@ async function runQwenServe(optsIn, deps = {}) {
1578
1849
  }
1579
1850
  }
1580
1851
  }, "shutdownBridgeAfterFailedStartup");
1852
+ const stopChannelWorkerAfterFailedStartup = /* @__PURE__ */ __name(async () => {
1853
+ await channelWorker.stop().catch((stopErr) => {
1854
+ daemonLog.error(
1855
+ "channel worker stop after runtime startup error failed",
1856
+ stopErr instanceof Error ? stopErr : null
1857
+ );
1858
+ });
1859
+ }, "stopChannelWorkerAfterFailedStartup");
1581
1860
  const failRuntimeStartup = /* @__PURE__ */ __name(async (err, bridgeForCleanup) => {
1582
1861
  const error = err instanceof Error ? err : new Error(String(err));
1583
1862
  if (runtimeStartupSettled) {
@@ -1594,9 +1873,34 @@ async function runQwenServe(optsIn, deps = {}) {
1594
1873
  }
1595
1874
  writeStderrLine(`qwen serve: runtime startup failed: ${message}`);
1596
1875
  daemonLog.error("runtime startup failed", error);
1597
- markRuntimeFailed(error);
1876
+ await stopChannelWorkerAfterFailedStartup();
1877
+ removeCurrentServePidfile();
1598
1878
  await shutdownBridgeAfterFailedStartup(bridgeForCleanup ?? bridgeRef);
1879
+ markRuntimeFailed(error);
1599
1880
  }, "failRuntimeStartup");
1881
+ const armRuntimeStartupTimer = /* @__PURE__ */ __name(() => {
1882
+ if (runtimeStartupTimeoutMs <= 0 || runtimeStartupTimer) return;
1883
+ runtimeStartupTimer = setTimeout(() => {
1884
+ void failRuntimeStartup(
1885
+ new Error(
1886
+ `Daemon runtime startup timed out after ${runtimeStartupTimeoutMs}ms.`
1887
+ )
1888
+ );
1889
+ }, runtimeStartupTimeoutMs);
1890
+ runtimeStartupTimer.unref();
1891
+ }, "armRuntimeStartupTimer");
1892
+ const completeRuntimeStartup = /* @__PURE__ */ __name(async () => {
1893
+ if (runtimeStartupSettled) return;
1894
+ if (opts.channelSelection) {
1895
+ await channelWorker.start();
1896
+ if (runtimeStartupSettled) return;
1897
+ writeChannelWorkerPidfile();
1898
+ }
1899
+ if (runtimeStartupSettled) return;
1900
+ runtimeStartupSettled = true;
1901
+ clearRuntimeStartupTimer();
1902
+ markRuntimeReady();
1903
+ }, "completeRuntimeStartup");
1600
1904
  const startBridgePreheat = /* @__PURE__ */ __name((bridge) => {
1601
1905
  startup.preheat.status = "running";
1602
1906
  const preheatStartedAt = performance.now();
@@ -1619,6 +1923,9 @@ async function runQwenServe(optsIn, deps = {}) {
1619
1923
  }, "startBridgePreheat");
1620
1924
  const startRuntime = /* @__PURE__ */ __name(() => {
1621
1925
  if (runtimeStarting) return;
1926
+ armRuntimeStartupTimer();
1927
+ clearRuntimeStartAfterHealthTimer();
1928
+ clearRuntimeStartFallbackTimer();
1622
1929
  runtimeStarting = buildRuntime().then(async (runtime) => {
1623
1930
  if (runtimeStartupSettled) {
1624
1931
  await shutdownBridgeAfterFailedStartup(runtime.bridge);
@@ -1639,26 +1946,47 @@ async function runQwenServe(optsIn, deps = {}) {
1639
1946
  if (shouldPreheat) {
1640
1947
  startBridgePreheat(runtime.bridge);
1641
1948
  }
1642
- runtimeStartupSettled = true;
1643
- clearRuntimeStartupTimer();
1644
- markRuntimeReady();
1949
+ await completeRuntimeStartup();
1645
1950
  }).catch((err) => failRuntimeStartup(err));
1646
- if (runtimeStartupTimeoutMs > 0) {
1647
- runtimeStartupTimer = setTimeout(() => {
1648
- void failRuntimeStartup(
1649
- new Error(
1650
- `Daemon runtime startup timed out after ${runtimeStartupTimeoutMs}ms.`
1651
- )
1652
- );
1653
- }, runtimeStartupTimeoutMs);
1654
- runtimeStartupTimer.unref();
1655
- }
1656
1951
  }, "startRuntime");
1952
+ startRuntimeForRequest = startRuntime;
1953
+ const scheduleRuntimeStartFallback = /* @__PURE__ */ __name(() => {
1954
+ if (shuttingDown || runtimeStarting || runtimeStartFallbackTimer)
1955
+ return;
1956
+ daemonLog.info(
1957
+ `deferred runtime: scheduling fallback start in ${FAST_PATH_RUNTIME_START_FALLBACK_MS}ms`
1958
+ );
1959
+ runtimeStartFallbackTimer = setTimeout(() => {
1960
+ runtimeStartFallbackTimer = void 0;
1961
+ if (shuttingDown) return;
1962
+ daemonLog.info("deferred runtime: fallback timer fired, starting");
1963
+ startRuntime();
1964
+ }, FAST_PATH_RUNTIME_START_FALLBACK_MS);
1965
+ runtimeStartFallbackTimer.unref();
1966
+ }, "scheduleRuntimeStartFallback");
1967
+ startRuntimeAfterHealth = /* @__PURE__ */ __name(() => {
1968
+ if (shuttingDown || runtimeStarting || runtimeStartAfterHealthTimer) {
1969
+ return;
1970
+ }
1971
+ clearRuntimeStartFallbackTimer();
1972
+ daemonLog.info(
1973
+ `deferred runtime: health served, scheduling start in ${FAST_PATH_RUNTIME_START_AFTER_HEALTH_MS}ms`
1974
+ );
1975
+ runtimeStartAfterHealthTimer = setTimeout(() => {
1976
+ runtimeStartAfterHealthTimer = void 0;
1977
+ if (shuttingDown) return;
1978
+ daemonLog.info("deferred runtime: health timer fired, starting");
1979
+ startRuntime();
1980
+ }, FAST_PATH_RUNTIME_START_AFTER_HEALTH_MS);
1981
+ runtimeStartAfterHealthTimer.unref();
1982
+ }, "startRuntimeAfterHealth");
1657
1983
  const onSignal = /* @__PURE__ */ __name(async (signal) => {
1658
1984
  if (shuttingDown) {
1659
1985
  daemonLog.warn(`received ${signal} during drain \u2014 forcing exit`);
1660
1986
  try {
1987
+ channelWorker.killAllSync();
1661
1988
  bridgeRef?.killAllSync();
1989
+ removeCurrentServePidfile();
1662
1990
  } catch (err) {
1663
1991
  daemonLog.error(
1664
1992
  "force-kill error",
@@ -1682,6 +2010,11 @@ async function runQwenServe(optsIn, deps = {}) {
1682
2010
  process.exit(1);
1683
2011
  }
1684
2012
  }, "onSignal");
2013
+ const onUncaughtExceptionMonitor = /* @__PURE__ */ __name(() => {
2014
+ if (process.listenerCount("uncaughtException") === 0) {
2015
+ removeCurrentServePidfile();
2016
+ }
2017
+ }, "onUncaughtExceptionMonitor");
1685
2018
  const handle = {
1686
2019
  server,
1687
2020
  url,
@@ -1693,6 +2026,9 @@ async function runQwenServe(optsIn, deps = {}) {
1693
2026
  if (closePromise) return closePromise;
1694
2027
  closePromise = new Promise((res, rej) => {
1695
2028
  shuttingDown = true;
2029
+ clearRuntimeStartAfterHealthTimer();
2030
+ clearRuntimeStartFallbackTimer();
2031
+ cancelDeferredRuntimeStartup();
1696
2032
  let settled = false;
1697
2033
  let bridgeShutdownError;
1698
2034
  const finish = /* @__PURE__ */ __name((err) => {
@@ -1700,6 +2036,10 @@ async function runQwenServe(optsIn, deps = {}) {
1700
2036
  settled = true;
1701
2037
  process.removeListener("SIGINT", onSignal);
1702
2038
  process.removeListener("SIGTERM", onSignal);
2039
+ process.removeListener(
2040
+ "uncaughtExceptionMonitor",
2041
+ onUncaughtExceptionMonitor
2042
+ );
1703
2043
  void (coreRuntimePromise ? coreRuntimePromise.then((core) => core.shutdownTelemetry()) : Promise.resolve()).catch((telemetryErr) => {
1704
2044
  writeStderrLine(
1705
2045
  `qwen serve: telemetry shutdown error: ${telemetryErr instanceof Error ? telemetryErr.message : String(telemetryErr)}`
@@ -1747,6 +2087,13 @@ async function runQwenServe(optsIn, deps = {}) {
1747
2087
  rl.setDraining(true);
1748
2088
  rl.dispose();
1749
2089
  }
2090
+ await channelWorker.stop().catch((err) => {
2091
+ daemonLog.error(
2092
+ "channel worker stop error",
2093
+ err instanceof Error ? err : null
2094
+ );
2095
+ });
2096
+ removeCurrentServePidfile();
1750
2097
  const bridgeForShutdown = bridgeRef;
1751
2098
  if (bridgeForShutdown) {
1752
2099
  await bridgeForShutdown.shutdown().catch((err) => {
@@ -1786,6 +2133,7 @@ async function runQwenServe(optsIn, deps = {}) {
1786
2133
  };
1787
2134
  process.on("SIGINT", onSignal);
1788
2135
  process.on("SIGTERM", onSignal);
2136
+ process.on("uncaughtExceptionMonitor", onUncaughtExceptionMonitor);
1789
2137
  server.removeAllListeners("error");
1790
2138
  server.on("error", (err) => {
1791
2139
  daemonLog.error("server error", err instanceof Error ? err : null);
@@ -1796,6 +2144,14 @@ async function runQwenServe(optsIn, deps = {}) {
1796
2144
  if (shouldPreheat) {
1797
2145
  startBridgePreheat(bridgeRef);
1798
2146
  }
2147
+ if (opts.channelSelection && !runtimeStartupSettled) {
2148
+ armRuntimeStartupTimer();
2149
+ runtimeStarting = completeRuntimeStartup().catch(
2150
+ (err) => failRuntimeStartup(err, bridgeRef)
2151
+ );
2152
+ }
2153
+ } else if (deferRuntimeUntilFirstHealth) {
2154
+ scheduleRuntimeStartFallback();
1799
2155
  } else {
1800
2156
  startRuntime();
1801
2157
  }
@@ -1817,7 +2173,10 @@ async function runQwenServe(optsIn, deps = {}) {
1817
2173
  );
1818
2174
  }
1819
2175
  });
1820
- server.once("error", reject);
2176
+ server.once("error", (err) => {
2177
+ removeCurrentServePidfile();
2178
+ reject(err);
2179
+ });
1821
2180
  });
1822
2181
  }
1823
2182
  __name(runQwenServe, "runQwenServe");
@@ -1825,6 +2184,7 @@ export {
1825
2184
  InvalidPolicyConfigError,
1826
2185
  createLazyBridgeProxy,
1827
2186
  extractContextFilename,
2187
+ formatChannelWorkerDaemonUrl,
1828
2188
  resolveRuntimeStartupTimeoutMs,
1829
2189
  runQwenServe,
1830
2190
  validatePolicyConfig,