@qwen-code/qwen-code 0.21.1-simplify-system-prompt.0 → 0.21.2-nightly.20260801.bc382c3ff

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 (437) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +2 -0
  2. package/bundled/qc-helper/docs/configuration/settings.md +42 -30
  3. package/bundled/qc-helper/docs/features/channels/_meta.ts +2 -0
  4. package/bundled/qc-helper/docs/features/channels/github.md +146 -0
  5. package/bundled/qc-helper/docs/features/channels/gitlab.md +177 -0
  6. package/bundled/qc-helper/docs/features/channels/overview.md +61 -6
  7. package/bundled/qc-helper/docs/features/code-review.md +21 -1
  8. package/bundled/qc-helper/docs/features/commands.md +1 -0
  9. package/bundled/qc-helper/docs/features/hooks.md +186 -32
  10. package/bundled/qc-helper/docs/features/mcp.md +9 -1
  11. package/bundled/qc-helper/docs/features/memory.md +27 -0
  12. package/bundled/qc-helper/docs/features/scheduled-tasks.md +3 -1
  13. package/bundled/qc-helper/docs/features/skills.md +14 -0
  14. package/bundled/qc-helper/docs/features/sub-agents.md +75 -8
  15. package/bundled/qc-helper/docs/features/tool-use-summaries.md +7 -7
  16. package/bundled/qc-helper/docs/qwen-serve.md +32 -8
  17. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +4 -4
  18. package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
  19. package/bundled/review/DESIGN.md +19 -0
  20. package/bundled/review/SKILL.md +120 -61
  21. package/chunks/MaxSizedBox-CDHTDITS.js +89 -0
  22. package/chunks/{StandaloneSessionPicker-O6RKBPU4.js → StandaloneSessionPicker-L63HUAHP.js} +76 -73
  23. package/chunks/{acp-startup-profiler-RV3IV562.js → acp-startup-profiler-3RICG2YW.js} +2 -2
  24. package/chunks/{acpAgent-HYFVXVDR.js → acpAgent-6WVVT2P3.js} +2147 -1009
  25. package/chunks/agent-KDM4CBOU.js +85 -0
  26. package/chunks/agent-headless-AS7K2K57.js +79 -0
  27. package/chunks/{anthropicContentGenerator-LXUXMOE7.js → anthropicContentGenerator-WCBYB6JG.js} +388 -37
  28. package/chunks/{artifact-tool-Y5T7GG7F.js → artifact-tool-ANV4CFCR.js} +4 -4
  29. package/chunks/{askUserQuestion-2H6747FR.js → askUserQuestion-MALEB47H.js} +4 -4
  30. package/chunks/bridge-JNEW6FES.js +95 -0
  31. package/chunks/{build-RV63TIRH.js → build-GDBLPA24.js} +1 -1
  32. package/chunks/{ca-25EDXPFZ.js → ca-4OJN75WT.js} +52 -6
  33. package/chunks/{channel-management-service-G74LFADV.js → channel-management-service-QOO7TD3T.js} +21 -6
  34. package/chunks/channel-settings-store-4CSMTR4L.js +92 -0
  35. package/chunks/{channel-worker-group-PTJIJSKC.js → channel-worker-group-ERSUOPIR.js} +10 -6
  36. package/chunks/{channel-worker-manager-WIMGM2FD.js → channel-worker-manager-X247YDQ7.js} +10 -6
  37. package/chunks/{channel-worker-supervisor-KUFTR6P5.js → channel-worker-supervisor-ORJIEEPP.js} +6 -5
  38. package/chunks/{chunk-LNARWLZQ.js → chunk-25QQVOCG.js} +5 -5
  39. package/chunks/{chunk-2OM7GEXO.js → chunk-2A6MHYIA.js} +3 -3
  40. package/chunks/{chunk-ER5LWJR6.js → chunk-2CTKGIFR.js} +3 -3
  41. package/chunks/{chunk-SQBYH7PX.js → chunk-2DNKEBXY.js} +1 -1
  42. package/chunks/{chunk-6GMVPFB2.js → chunk-2IIJTXYF.js} +45 -16
  43. package/chunks/{chunk-BPJSQIJX.js → chunk-2J3OJGTL.js} +0 -2
  44. package/chunks/chunk-2M5N3DHY.js +378 -0
  45. package/chunks/{chunk-CC4N4M36.js → chunk-2PNQQ4UR.js} +2 -2
  46. package/chunks/{chunk-E5TUC6CA.js → chunk-2UISUFHQ.js} +3 -3
  47. package/chunks/{chunk-PWTZEM3C.js → chunk-33FNCQSY.js} +3 -37
  48. package/chunks/{chunk-J56UI34H.js → chunk-3LGZEYOF.js} +4 -2
  49. package/chunks/{chunk-66RMLJHC.js → chunk-3MHPWQ2M.js} +590 -212
  50. package/chunks/{chunk-NL7LTRLR.js → chunk-3RXUYQJI.js} +54 -74
  51. package/chunks/{chunk-E5Z2AVNV.js → chunk-3SH53ANB.js} +0 -11
  52. package/chunks/{chunk-XHRTVPG2.js → chunk-3WXMXT7C.js} +22 -11
  53. package/chunks/{chunk-C3NS4F2Q.js → chunk-42IKVPST.js} +1 -1
  54. package/chunks/{chunk-M5JM7OSF.js → chunk-432XCUHF.js} +2 -3
  55. package/chunks/{chunk-5U4IPFBR.js → chunk-433VD3HX.js} +4 -4
  56. package/chunks/chunk-434YCHSV.js +2196 -0
  57. package/chunks/{chunk-DHHOYAPR.js → chunk-4LKVQFHM.js} +7 -7
  58. package/chunks/{chunk-IPUUTYMV.js → chunk-4NFY2S7N.js} +0 -33
  59. package/chunks/{chunk-J6D3VXCC.js → chunk-5UJ6A3CH.js} +158 -12
  60. package/chunks/{chunk-N3FAY5CM.js → chunk-5UZITEHA.js} +158 -5
  61. package/chunks/{chunk-A4UCTEB5.js → chunk-5WV5S2GT.js} +0 -1
  62. package/chunks/chunk-6FMJLI5M.js +1591 -0
  63. package/chunks/{chunk-6FGBXPWM.js → chunk-6O5DVH27.js} +38 -44
  64. package/chunks/{chunk-2RFKHEXL.js → chunk-6PLDPT2C.js} +1 -1
  65. package/chunks/{chunk-52O2CIUL.js → chunk-7IYLHTTM.js} +130 -5
  66. package/chunks/{chunk-5THCYPLO.js → chunk-7K2WTPQO.js} +15 -8
  67. package/chunks/{chunk-2Q3OT4OV.js → chunk-7MY2AR5A.js} +204 -81
  68. package/chunks/{chunk-YH6G52F2.js → chunk-A2A34TSB.js} +4 -4
  69. package/chunks/{chunk-3QMGYBFN.js → chunk-A5YZ3FA2.js} +2 -80
  70. package/chunks/{chunk-K4XWPEWB.js → chunk-A6SX5TAH.js} +4 -33
  71. package/chunks/{chunk-VYPFXUCB.js → chunk-AKA24BGO.js} +1 -1
  72. package/chunks/chunk-AQ37AY7B.js +93 -0
  73. package/chunks/{chunk-PANH4R3B.js → chunk-AQEWCKX4.js} +18 -12
  74. package/chunks/{chunk-LG4GZIVV.js → chunk-AYB4HSBI.js} +4 -4
  75. package/chunks/{chunk-PJIZUQVC.js → chunk-AZQ3DT76.js} +2 -2
  76. package/chunks/{chunk-2JZBVYTU.js → chunk-BFHXDAR7.js} +1 -8
  77. package/chunks/{chunk-2W3OOD4W.js → chunk-BGXZBI5B.js} +7 -4
  78. package/chunks/{chunk-2YZJCM5T.js → chunk-BKUN5QHP.js} +7 -7
  79. package/chunks/{chunk-UUUTRMI2.js → chunk-BV4QX43X.js} +1 -1
  80. package/chunks/{chunk-4M377AZG.js → chunk-C4L2MEIT.js} +6 -6
  81. package/chunks/{chunk-VV6XU5L7.js → chunk-CHCLO3M7.js} +19 -14
  82. package/chunks/{chunk-TOFQCPDC.js → chunk-CWEIMFFW.js} +14 -8
  83. package/chunks/{chunk-XVNQMZ2I.js → chunk-DGEIYUC3.js} +0 -1
  84. package/chunks/{chunk-BPZALHVR.js → chunk-DI35ZN7T.js} +1 -1
  85. package/chunks/{chunk-WDSWXQU3.js → chunk-DUIJ2IXG.js} +5 -13
  86. package/chunks/{chunk-3MSHSCSN.js → chunk-DVGTU5TC.js} +94 -4
  87. package/chunks/{chunk-RHLZR4E5.js → chunk-DYA25Y7U.js} +1 -1
  88. package/chunks/{chunk-MUP3T3AD.js → chunk-E4WHKETF.js} +32 -38
  89. package/chunks/{chunk-WBL3FJEU.js → chunk-FC4KQFCS.js} +1 -1
  90. package/chunks/{chunk-V6VRAM7B.js → chunk-FJHA23GM.js} +12 -12
  91. package/chunks/chunk-FYJ7W2PI.js +194 -0
  92. package/chunks/{chunk-INADJJGW.js → chunk-G7XXKQYS.js} +2 -2
  93. package/chunks/{chunk-LZEMEFKY.js → chunk-GALUTA2C.js} +1 -1
  94. package/chunks/{chunk-ML52PL6O.js → chunk-GB3AB7TR.js} +4374 -3779
  95. package/chunks/{chunk-SASBXAQL.js → chunk-GHJM2C2T.js} +6 -8
  96. package/chunks/{chunk-LS77BEZP.js → chunk-GLCZKT5V.js} +1 -5
  97. package/chunks/chunk-GOFAQQZA.js +132 -0
  98. package/chunks/{chunk-BJX6ZSUK.js → chunk-GTM6IHBB.js} +2 -2
  99. package/chunks/{chunk-TF2X2WCT.js → chunk-GVISB2OH.js} +2 -2
  100. package/chunks/{chunk-OKY7HXPG.js → chunk-H36SETQS.js} +2 -2
  101. package/chunks/{chunk-7FZEBPKS.js → chunk-H4346YW5.js} +39 -22
  102. package/chunks/{chunk-LNURQEMZ.js → chunk-H4DSRWAS.js} +24 -13
  103. package/chunks/{chunk-3JAQDSXN.js → chunk-H6MC6VQX.js} +290 -179
  104. package/chunks/{chunk-GZXCZHCT.js → chunk-I3G5JWBV.js} +1 -1
  105. package/chunks/{chunk-PR75REBZ.js → chunk-I5GNT6ZS.js} +18 -82
  106. package/chunks/{chunk-MVS3NS2N.js → chunk-I6FAHB4N.js} +28 -5
  107. package/chunks/{chunk-ZOIFNCKL.js → chunk-I7JDGNG6.js} +3 -23
  108. package/chunks/{chunk-OJGCZBB7.js → chunk-II6WPWHY.js} +41 -36
  109. package/chunks/{chunk-UH3WSE5L.js → chunk-J26HHFI5.js} +2 -7
  110. package/chunks/{chunk-S3TWXGKA.js → chunk-JE7KQ2UP.js} +4 -2
  111. package/chunks/{chunk-ZD6UTE4A.js → chunk-JELIWHXD.js} +1 -1
  112. package/chunks/{chunk-6PSLCFQ2.js → chunk-JRIDA5HF.js} +18 -9
  113. package/chunks/{chunk-W4CQXHT6.js → chunk-K4CGQN4Q.js} +1 -1
  114. package/chunks/{chunk-G4WFQUYQ.js → chunk-K5Q62CGR.js} +1 -1
  115. package/chunks/{chunk-JCW2R7WC.js → chunk-K623ENWT.js} +3 -79
  116. package/chunks/{chunk-T2NCM2ET.js → chunk-K6KS3LTN.js} +2 -749
  117. package/chunks/{chunk-DN6ZX5AY.js → chunk-KG22G46Y.js} +62 -15
  118. package/chunks/{chunk-L5UHQJTJ.js → chunk-KKN2IE7Q.js} +1 -1
  119. package/chunks/{chunk-63P4EL5V.js → chunk-KVUBYJDM.js} +2 -2
  120. package/chunks/{chunk-E5WH5O3C.js → chunk-KXSYDCP2.js} +4 -4
  121. package/chunks/{chunk-JALU3ZDU.js → chunk-LAPK3GLC.js} +212 -16
  122. package/chunks/chunk-LBOVL47Y.js +29 -0
  123. package/chunks/{chunk-FQK6JAFG.js → chunk-LBWNSLJK.js} +4 -4
  124. package/chunks/{chunk-3IXOIAKE.js → chunk-LL4U3BSH.js} +30 -10
  125. package/chunks/{chunk-B7QDM6Z7.js → chunk-LRJWFR6L.js} +4 -4
  126. package/chunks/{chunk-RWS5VYWC.js → chunk-M2F5PLOW.js} +1018 -484
  127. package/chunks/{chunk-HIJQF5B5.js → chunk-M744OFVE.js} +1 -1
  128. package/chunks/{chunk-I7XZ3RY5.js → chunk-MBKPUM5Y.js} +1 -1
  129. package/chunks/chunk-MISUEWB4.js +8749 -0
  130. package/chunks/{chunk-FNQ6T3CV.js → chunk-MOHAWIAW.js} +10 -7
  131. package/chunks/{chunk-FODK6UMO.js → chunk-MPHPFVKK.js} +0 -2
  132. package/chunks/{chunk-QY5MMZ6O.js → chunk-MSIVKDRC.js} +4 -4
  133. package/chunks/{record-artifact-RQKFYO5B.js → chunk-MYT7N6QH.js} +22 -7
  134. package/chunks/{chunk-JESCGQM3.js → chunk-NAVJD2PQ.js} +8 -7
  135. package/chunks/{chunk-DM4Q4JJH.js → chunk-NGWYUZZO.js} +68794 -83526
  136. package/chunks/{chunk-6OUGMXDC.js → chunk-NWNEANAT.js} +7 -7
  137. package/chunks/{chunk-PQNHRFJC.js → chunk-NYX53SV4.js} +0 -2
  138. package/chunks/{chunk-Z5BLYMZM.js → chunk-NZB4NDJL.js} +10 -10
  139. package/chunks/{chunk-SRZ6DXVG.js → chunk-O2ZYHG33.js} +47 -138
  140. package/chunks/chunk-O6GEWCJA.js +21 -0
  141. package/chunks/{chunk-PHVR5UUY.js → chunk-OBAIHYFT.js} +1 -1
  142. package/chunks/chunk-OCPBI7J5.js +18 -0
  143. package/chunks/{chunk-P5V4T7NK.js → chunk-OCRM53TT.js} +11 -3
  144. package/chunks/{chunk-V7RNNPGC.js → chunk-P5Y23G2L.js} +18 -1
  145. package/chunks/{chunk-KU5XMLDK.js → chunk-PDDYAXL2.js} +7 -1
  146. package/chunks/{chunk-L26JL52R.js → chunk-PGEGUNH5.js} +108 -68
  147. package/chunks/{chunk-2JM6GZ5D.js → chunk-PGP7Y3RQ.js} +8 -13
  148. package/chunks/{chunk-VFSJ5VRH.js → chunk-PHODQP2V.js} +6 -6
  149. package/chunks/{chunk-PSWQZHEA.js → chunk-PXA5AWHY.js} +1 -1
  150. package/chunks/{chunk-VDDGDZMA.js → chunk-QHWCP53L.js} +14 -7
  151. package/chunks/chunk-QL4TN4HS.js +59 -0
  152. package/chunks/{chunk-USTWD7QV.js → chunk-QMBEW7EW.js} +26 -16
  153. package/chunks/{chunk-U4VTUMMK.js → chunk-QONSRAEV.js} +1 -1
  154. package/chunks/{chunk-NH6KE4JX.js → chunk-QYPT3QUD.js} +3 -3
  155. package/chunks/{chunk-GDIPH4JY.js → chunk-RGJ4JWSU.js} +133 -50
  156. package/chunks/{chunk-BO4XCS7P.js → chunk-RPYYTL7E.js} +77 -94
  157. package/chunks/{chunk-6AM5D4ME.js → chunk-S6LOFUVP.js} +0 -12
  158. package/chunks/{chunk-B4UMZKMU.js → chunk-SK2UKB45.js} +1 -1
  159. package/chunks/{chunk-QPDRAXDJ.js → chunk-SWEBEXPI.js} +1 -1
  160. package/chunks/chunk-T26EAKDL.js +13 -0
  161. package/chunks/chunk-T3CHYWJZ.js +758 -0
  162. package/chunks/{chunk-U7TXFVUN.js → chunk-TFFMATHX.js} +120 -95
  163. package/chunks/{chunk-M4UKFCZ2.js → chunk-TNVKFQXQ.js} +616 -217
  164. package/chunks/{chunk-5I2IWRSH.js → chunk-TYERNYH4.js} +2 -2
  165. package/chunks/{chunk-VAK25FTU.js → chunk-U25CMJYY.js} +1 -1
  166. package/chunks/{chunk-A5L3JMUA.js → chunk-UH7Z7Y45.js} +18 -4
  167. package/chunks/{chunk-BRRAJXPA.js → chunk-UHQ3L6GC.js} +1 -1
  168. package/chunks/{chunk-HV3G62R6.js → chunk-UHTJC7O3.js} +1 -1
  169. package/chunks/{chunk-3SJ43L4W.js → chunk-UKZEXS6K.js} +8 -0
  170. package/chunks/{chunk-DM22XS4K.js → chunk-UOFFZNXV.js} +361 -17
  171. package/chunks/{chunk-FY3M44RD.js → chunk-URN76TKR.js} +3 -3
  172. package/chunks/{chunk-MSLKI6C2.js → chunk-UWLG4UCE.js} +139 -31
  173. package/chunks/{chunk-A6UO2C7C.js → chunk-UWSXFI6E.js} +167 -81
  174. package/chunks/{chunk-BYFNTGKI.js → chunk-VS3GXRNZ.js} +3703 -1399
  175. package/chunks/{chunk-TQCBGUHN.js → chunk-VWF42XC6.js} +5 -5
  176. package/chunks/{chunk-32MVHM4T.js → chunk-W7XZ3KP5.js} +1 -1
  177. package/chunks/{chunk-B6ZJ7SI6.js → chunk-WISQLM4Q.js} +1526 -1420
  178. package/chunks/{chunk-H5FFA6TH.js → chunk-WK4TJUEA.js} +16 -3
  179. package/chunks/{chunk-3HBZKBMQ.js → chunk-WP4HGHFG.js} +5 -5
  180. package/chunks/{chunk-BIQWWWJN.js → chunk-XC2VAFVZ.js} +1 -1
  181. package/chunks/{chunk-EPDRMGT4.js → chunk-XC656O42.js} +4 -28
  182. package/chunks/{chunk-COH43MRJ.js → chunk-XCGIMOLN.js} +27 -1
  183. package/chunks/{chunk-YAF5VNU7.js → chunk-XCLLRKY5.js} +4 -5
  184. package/chunks/chunk-XFDPIC4P.js +319 -0
  185. package/chunks/{chunk-KIUFNBHR.js → chunk-XSA5EKTJ.js} +1 -1
  186. package/chunks/{chunk-OHNBB4XR.js → chunk-YAVY33G4.js} +1 -1
  187. package/chunks/{chunk-DLWL3Z7A.js → chunk-YXEVDA66.js} +3 -3
  188. package/chunks/chunk-Z4X5MTRT.js +133 -0
  189. package/chunks/{chunk-UW5EOVUN.js → chunk-ZBVS26BY.js} +4 -4
  190. package/chunks/{chunk-HTO4JFDZ.js → chunk-ZPJWUGCS.js} +0 -1
  191. package/chunks/{chunk-ZE5WPL4I.js → chunk-ZRFJ75D7.js} +3 -3
  192. package/chunks/{chunk-MK7VQDN3.js → chunk-ZTN6OA5J.js} +8 -6
  193. package/chunks/{computer-use-DOFAHZAB.js → computer-use-Z4NCIIJN.js} +54 -51
  194. package/chunks/{config-utils-VFQXVGNR.js → config-utils-64LM6OEQ.js} +4 -4
  195. package/chunks/contextCommand-HVM7XFCB.js +84 -0
  196. package/chunks/core-runtime-NL3ZBHBU.js +138 -0
  197. package/chunks/{create-sub-session-IWW2IZ2T.js → create-sub-session-AM32K2HD.js} +3 -3
  198. package/chunks/{create-sub-session-7543K2QA.js → create-sub-session-XHSCDYFU.js} +54 -51
  199. package/chunks/{cron-create-YIID5XAW.js → cron-create-HPXYE6C5.js} +6 -6
  200. package/chunks/{cron-delete-ZVHYCEP2.js → cron-delete-FPVNTKPK.js} +5 -5
  201. package/chunks/{cron-list-XEGS463Q.js → cron-list-ZEI6PAAV.js} +6 -6
  202. package/chunks/{daemon-VOMQW7KZ.js → daemon-PCNCI5YU.js} +239 -18
  203. package/chunks/daemon-status-provider-XD23SNAM.js +94 -0
  204. package/chunks/daemon-trust-policy-NOHK7IW5.js +89 -0
  205. package/chunks/daemon-trust-policy-monitor-ZBTSR333.js +176 -0
  206. package/chunks/{de-HGRCYDEJ.js → de-A6TI4LBB.js} +52 -6
  207. package/chunks/deferred-core-runtime-JJBHKM2C.js +93 -0
  208. package/chunks/{dist-RTJFMNEZ.js → dist-4LAMY2SK.js} +1449 -14
  209. package/chunks/{dist-NNVBBOGU.js → dist-4T4NCJFL.js} +2 -2
  210. package/chunks/dist-7KOL6OMD.js +13467 -0
  211. package/chunks/{dist-BRB6EXK4.js → dist-BH76AT7N.js} +3 -3
  212. package/chunks/dist-BXA3JXVQ.js +4749 -0
  213. package/chunks/{dist-KTYYJ2C5.js → dist-OEEFI6UU.js} +12 -9
  214. package/chunks/{dist-K6Y4E7FX.js → dist-SMLVOWKV.js} +5 -4
  215. package/chunks/{dist-ANLAT3GS.js → dist-V2RK6S6Q.js} +2 -1
  216. package/chunks/earlyInputCapture-KLAZDAIP.js +86 -0
  217. package/chunks/{edit-RIEOJWKB.js → edit-YQZWCISX.js} +53 -50
  218. package/chunks/{en-MTWBNGDO.js → en-RESOFG55.js} +55 -6
  219. package/chunks/{enter-worktree-OGK5FQ3R.js → enter-worktree-WLVWI3FP.js} +53 -50
  220. package/chunks/{enterPlanMode-IWZYALIB.js → enterPlanMode-6RYXFQUD.js} +53 -50
  221. package/chunks/environment-DXJTXSVT.js +106 -0
  222. package/chunks/errors-XGAGG2S2.js +92 -0
  223. package/chunks/esm-K5FARBNI.js +5548 -0
  224. package/chunks/{exit-worktree-4TEYVIVP.js → exit-worktree-C4276VPP.js} +53 -50
  225. package/chunks/exitPlanMode-MM5HIRUF.js +77 -0
  226. package/chunks/{fast-path-HYE7IFEV.js → fast-path-PIXYOHCH.js} +17 -3
  227. package/chunks/{fr-45RLL55O.js → fr-QF7RI5ZE.js} +52 -6
  228. package/chunks/{gemini-NGRQX3YJ.js → gemini-43RLVUNP.js} +171 -109
  229. package/chunks/{geminiContentGenerator-FQHPFZSR.js → geminiContentGenerator-PNQ4TSID.js} +7 -7
  230. package/chunks/{getMachineId-bsd-V7W3GODC.js → getMachineId-bsd-FG7IUY6U.js} +1 -1
  231. package/chunks/{getMachineId-darwin-TDO75DQP.js → getMachineId-darwin-GLCJI2RA.js} +1 -1
  232. package/chunks/{getMachineId-linux-TF43WQT2.js → getMachineId-linux-O6OPPAKO.js} +1 -1
  233. package/chunks/{getMachineId-unsupported-ZGUO3TXT.js → getMachineId-unsupported-S6CKYVGC.js} +1 -1
  234. package/chunks/{getMachineId-win-ECFYZZFQ.js → getMachineId-win-X5SRNEH7.js} +1 -1
  235. package/chunks/{glob-FRTM3X2E.js → glob-ZMBQKAU5.js} +53 -50
  236. package/chunks/goal-tools-Y767F7LZ.js +335 -0
  237. package/chunks/{grep-RKWVROCW.js → grep-HSV37W2Q.js} +55 -51
  238. package/chunks/handleAutoUpdate-QDHZPBAY.js +85 -0
  239. package/chunks/i18n-ME22A6RN.js +101 -0
  240. package/chunks/{image-gen-WIEM7KZA.js → image-gen-IFC7ZWSB.js} +12 -12
  241. package/chunks/initializer-J7H2CHVB.js +90 -0
  242. package/chunks/installationInfo-R7FXPQN5.js +84 -0
  243. package/chunks/{ja-B7DF7DFG.js → ja-URQESVGW.js} +52 -6
  244. package/chunks/{keychain-token-storage-MDTG3WRM.js → keychain-token-storage-7BT4TQ2A.js} +3 -3
  245. package/chunks/{kittyProtocolDetector-MBRTDRBK.js → kittyProtocolDetector-BFLAKYXH.js} +1 -1
  246. package/chunks/lib-RUF3WZA6.js +9 -0
  247. package/chunks/list-OYDIBA4N.js +93 -0
  248. package/chunks/{list-agents-5KJJHR6I.js → list-agents-GATIBBQQ.js} +3 -3
  249. package/chunks/loadedSettingsAdapter-OK6GK2GE.js +87 -0
  250. package/chunks/{loggingContentGenerator-WGM27QAW.js → loggingContentGenerator-U4ZEG4GL.js} +66 -50
  251. package/chunks/{loop-wakeup-FXKNNYSY.js → loop-wakeup-3DZMQQQQ.js} +15 -8
  252. package/chunks/{ls-NTK6VOQJ.js → ls-7F4GHXIH.js} +5 -5
  253. package/chunks/{lsp-2JI24STP.js → lsp-6FEHVBWI.js} +3 -3
  254. package/chunks/{managed-npm-update-JQ2CG3RH.js → managed-npm-update-PGKAJLLO.js} +52 -49
  255. package/chunks/mcp-S4DXJD2G.js +87 -0
  256. package/chunks/{monitor-7FEWXX5F.js → monitor-E5ZFMT74.js} +53 -50
  257. package/chunks/nonInteractiveCli-HNOHKEPE.js +149 -0
  258. package/chunks/{notebook-edit-JGJV2K6J.js → notebook-edit-6QDN6VZJ.js} +53 -50
  259. package/chunks/{openaiContentGenerator-JPVXDTAO.js → openaiContentGenerator-3NLB2C5O.js} +25 -27
  260. package/chunks/pidfile-ZMOIUGG6.js +90 -0
  261. package/chunks/process-registry-2CHQBXH5.js +157 -0
  262. package/chunks/{processUtils-V2LCK6T6.js → processUtils-E4QGQVWW.js} +2 -2
  263. package/chunks/{pt-22Q3FP73.js → pt-EEEQXRUI.js} +52 -6
  264. package/chunks/{qwenContentGenerator-TICV2W2Z.js → qwenContentGenerator-2LFRWJTM.js} +57 -54
  265. package/chunks/{qwenOAuth2-XGFI5XJG.js → qwenOAuth2-N32BUQDC.js} +10 -10
  266. package/chunks/read-file-GLDCWZBG.js +29 -0
  267. package/chunks/{read-mcp-resource-4DKQWGHD.js → read-mcp-resource-AFS3UKZO.js} +4 -4
  268. package/chunks/record-artifact-ECZSCEG5.js +21 -0
  269. package/chunks/resumeHistoryUtils-F5BE5QDW.js +95 -0
  270. package/chunks/ripGrep-T23Y4AGY.js +77 -0
  271. package/chunks/{ru-FZCNZHDC.js → ru-WGZDYQAB.js} +52 -6
  272. package/chunks/{run-qwen-serve-3VCV4I7E.js → run-qwen-serve-TI2HGLLU.js} +1155 -272
  273. package/chunks/runtime-WCWM3DO7.js +125 -0
  274. package/chunks/{scheduler-RS2I6RU5.js → scheduler-2QZO5AV5.js} +51 -48
  275. package/chunks/{sdk-exporters-grpc-AK3LGHNO.js → sdk-exporters-grpc-54L4LS5L.js} +4 -4
  276. package/chunks/{sdk-exporters-http-FS6ZV7MF.js → sdk-exporters-http-IKNWQJNV.js} +7 -7
  277. package/chunks/{sdk-impl-7FZSCSXB.js → sdk-impl-7CUUMQDB.js} +10 -10
  278. package/chunks/{send-message-Q6OOR6BR.js → send-message-X7G2JSII.js} +8 -13
  279. package/chunks/serve-DZOMYUFU.js +93 -0
  280. package/chunks/{server-HRZ23U7M.js → server-N4AJRKIQ.js} +5299 -1584
  281. package/chunks/{session-7XHZKTVV.js → session-GS6AKMN7.js} +167 -102
  282. package/chunks/{settings-7ZGZDXAS.js → settings-CUN3SELH.js} +56 -53
  283. package/chunks/shell-NGBFVXC5.js +87 -0
  284. package/chunks/{skill-LIWXNLDW.js → skill-SC2BSO75.js} +35 -23
  285. package/chunks/skill-settings-XVPCPW5K.js +95 -0
  286. package/chunks/spawnChannel-RILO4YY3.js +86 -0
  287. package/chunks/standalone-update-TMLT6LVJ.js +96 -0
  288. package/chunks/{startInteractiveUI-IW3CSKHA.js → startInteractiveUI-J45WOEOU.js} +1343 -1230
  289. package/chunks/{syntheticOutput-I3757IWH.js → syntheticOutput-FHRY3BPQ.js} +4 -4
  290. package/chunks/task-create-LAQXBIHC.js +26 -0
  291. package/chunks/{task-list-FOPULZEP.js → task-list-V6K5DRDH.js} +8 -8
  292. package/chunks/{task-stop-H6RHXFVQ.js → task-stop-LQXE52L6.js} +3 -3
  293. package/chunks/{task-update-M57TFZJT.js → task-update-NXRCXSPB.js} +13 -12
  294. package/chunks/{team-create-O2FROQ4R.js → team-create-W3EVWCTA.js} +55 -52
  295. package/chunks/{team-delete-QE2UXJL7.js → team-delete-Z4KGO7RC.js} +8 -8
  296. package/chunks/{team-plan-approval-Q6WDBXTQ.js → team-plan-approval-URYVKJF4.js} +53 -50
  297. package/chunks/theme-manager-CUAMS2NI.js +81 -0
  298. package/chunks/{todoWrite-VQ7FKOHL.js → todoWrite-OFIZDI7P.js} +34 -6
  299. package/chunks/{tool-search-APECNQ3Z.js → tool-search-DCICFL32.js} +21 -22
  300. package/chunks/total-session-admission-3ZTAXVUK.js +89 -0
  301. package/chunks/{tree-sitter-FS4VPMZA.js → tree-sitter-4D7QS7F6.js} +1 -1
  302. package/chunks/{tree-sitter-bash-6B46JJCV.js → tree-sitter-bash-VEJGF5XF.js} +1 -1
  303. package/chunks/trustedFolders-EVCN36O5.js +99 -0
  304. package/chunks/{update-relaunch-ON5MDJQG.js → update-relaunch-XLW46RHQ.js} +5 -5
  305. package/chunks/updateCheck-ZHVXDAIH.js +96 -0
  306. package/chunks/useAutoAcceptIndicator-ZGD6BJSP.js +97 -0
  307. package/chunks/{validateNonInterActiveAuth-JBLKBKRD.js → validateNonInterActiveAuth-R3BAQFDY.js} +102 -97
  308. package/chunks/{version-LTNUBQJY.js → version-PMWREGCG.js} +1 -1
  309. package/chunks/{web-fetch-L5UTI53V.js → web-fetch-PGN27SGF.js} +19 -21
  310. package/chunks/{web-search-KM33JOS3.js → web-search-KW4UNMRE.js} +13 -13
  311. package/chunks/{workflow-K7FAWV77.js → workflow-SN3TJBTJ.js} +374 -323
  312. package/chunks/workspace-providers-status-O3HUZGGR.js +90 -0
  313. package/chunks/{workspace-registration-store-6TGVDJV5.js → workspace-registration-store-M3FJ74RS.js} +2 -2
  314. package/chunks/workspace-registry-U7ISW23N.js +97 -0
  315. package/chunks/workspace-service-VH6IWADT.js +104 -0
  316. package/chunks/workspace-skills-status-XANARSZS.js +90 -0
  317. package/chunks/workspace-trust-reconciler-35EFR4GC.js +350 -0
  318. package/chunks/write-file-NCRSGUDT.js +79 -0
  319. package/chunks/xterm-headless-NTYVIBT3.js +3475 -0
  320. package/chunks/{zh-LUIGBD55.js → zh-OHX23Q44.js} +52 -6
  321. package/chunks/{zh-TW-F5KG2IYD.js → zh-TW-4G7YKDAQ.js} +52 -6
  322. package/chunks/zoom-image-X7CIADYC.js +224 -0
  323. package/cli.js +55 -48
  324. package/locales/ca.js +67 -6
  325. package/locales/de.js +69 -6
  326. package/locales/en.js +69 -6
  327. package/locales/fr.js +71 -6
  328. package/locales/ja.js +68 -6
  329. package/locales/pt.js +67 -6
  330. package/locales/ru.js +70 -6
  331. package/locales/zh-TW.js +62 -6
  332. package/locales/zh.js +62 -6
  333. package/package.json +5 -4
  334. package/web-shell/assets/{arc-BbHijhiN.js → arc-CaMTqKio.js} +1 -1
  335. package/web-shell/assets/{architectureDiagram-3BPJPVTR-Cb4B_JD0.js → architectureDiagram-3BPJPVTR-Bjxztij2.js} +1 -1
  336. package/web-shell/assets/{blockDiagram-GPEHLZMM-Dsjlh3H-.js → blockDiagram-GPEHLZMM-BYJzeHi9.js} +1 -1
  337. package/web-shell/assets/{c4Diagram-AAUBKEIU-Cp5AeR4U.js → c4Diagram-AAUBKEIU-fYAa-Eil.js} +1 -1
  338. package/web-shell/assets/channel-LEZei0-5.js +1 -0
  339. package/web-shell/assets/{chunk-2J33WTMH-CLcY7W2e.js → chunk-2J33WTMH-B1OTlTml.js} +1 -1
  340. package/web-shell/assets/{chunk-4BX2VUAB-BUhvY2LR.js → chunk-4BX2VUAB-DNj4uy6k.js} +1 -1
  341. package/web-shell/assets/{chunk-55IACEB6-kDIFC_71.js → chunk-55IACEB6-DAqNmg3c.js} +1 -1
  342. package/web-shell/assets/{chunk-727SXJPM-CIBO15f2.js → chunk-727SXJPM-BwB4ddxE.js} +1 -1
  343. package/web-shell/assets/{chunk-AQP2D5EJ-BJ_T_slV.js → chunk-AQP2D5EJ-DmHR_UZs.js} +1 -1
  344. package/web-shell/assets/{chunk-FMBD7UC4-BEkW35J8.js → chunk-FMBD7UC4-BlfOXumo.js} +1 -1
  345. package/web-shell/assets/{chunk-ND2GUHAM-GGPxofay.js → chunk-ND2GUHAM-BKogiSy7.js} +1 -1
  346. package/web-shell/assets/{chunk-QZHKN3VN-Bifllrb6.js → chunk-QZHKN3VN-DEclVrOF.js} +1 -1
  347. package/web-shell/assets/classDiagram-4FO5ZUOK-BiaRhfvf.js +1 -0
  348. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-BiaRhfvf.js +1 -0
  349. package/web-shell/assets/{cose-bilkent-S5V4N54A-C-Add_Dp.js → cose-bilkent-S5V4N54A-CwtS21WT.js} +1 -1
  350. package/web-shell/assets/{dagre-BM42HDAG-B7MfwNq2.js → dagre-BM42HDAG-BAAIlB4p.js} +1 -1
  351. package/web-shell/assets/{diagram-2AECGRRQ-CY_0zuDz.js → diagram-2AECGRRQ-ChljtF_V.js} +1 -1
  352. package/web-shell/assets/{diagram-5GNKFQAL-VyYSbCgA.js → diagram-5GNKFQAL-BIXVd31-.js} +1 -1
  353. package/web-shell/assets/{diagram-KO2AKTUF-CBiIZ2PL.js → diagram-KO2AKTUF-BEiBaS15.js} +1 -1
  354. package/web-shell/assets/{diagram-LMA3HP47-BL3CrVOx.js → diagram-LMA3HP47-C-g4tWKM.js} +1 -1
  355. package/web-shell/assets/{diagram-OG6HWLK6-CZUPx96P.js → diagram-OG6HWLK6-CNCCbNQG.js} +1 -1
  356. package/web-shell/assets/{erDiagram-TEJ5UH35-B81xHr1-.js → erDiagram-TEJ5UH35-v8ysnsdI.js} +1 -1
  357. package/web-shell/assets/{flowDiagram-I6XJVG4X-EZWhir-J.js → flowDiagram-I6XJVG4X-LKVlLjwA.js} +1 -1
  358. package/web-shell/assets/{ganttDiagram-6RSMTGT7-CVFSuIAg.js → ganttDiagram-6RSMTGT7-DA5MrKYG.js} +1 -1
  359. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-C1H2uQDv.js → gitGraphDiagram-PVQCEYII-Cyg5fe6d.js} +1 -1
  360. package/web-shell/assets/index-BgOcEaVt.js +1756 -0
  361. package/web-shell/assets/index-C2GE3DAF.js +74 -0
  362. package/web-shell/assets/{index-BYo99NBH.js → index-CKdUkVVS.js} +1 -1
  363. package/web-shell/assets/index-DA5Lvscv.css +5 -0
  364. package/web-shell/assets/{infoDiagram-5YYISTIA-BwyFMlF8.js → infoDiagram-5YYISTIA-SLsfu3Qd.js} +1 -1
  365. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-CQ7Yhn2Y.js → ishikawaDiagram-YF4QCWOH-CmHOmTNx.js} +1 -1
  366. package/web-shell/assets/{journeyDiagram-JHISSGLW-CJn2sf0l.js → journeyDiagram-JHISSGLW-C3gM_HFQ.js} +1 -1
  367. package/web-shell/assets/{kanban-definition-UN3LZRKU-DaNRqwVN.js → kanban-definition-UN3LZRKU-BbHD7duM.js} +1 -1
  368. package/web-shell/assets/{linear-DCKODZe2.js → linear-CSBvm435.js} +1 -1
  369. package/web-shell/assets/{mermaid.core-CTGJOk27.js → mermaid.core-CPMw15lU.js} +5 -5
  370. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BKU3_3rg.js → mindmap-definition-RKZ34NQL-C_tNqXQW.js} +1 -1
  371. package/web-shell/assets/{pieDiagram-4H26LBE5-COcwBJ82.js → pieDiagram-4H26LBE5-DH_N-8yY.js} +1 -1
  372. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-CQnQ443x.js → quadrantDiagram-W4KKPZXB-CRbS8UkN.js} +1 -1
  373. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CZ2oj5cD.js → requirementDiagram-4Y6WPE33-DJgdZPZn.js} +1 -1
  374. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BxAv5mNu.js → sankeyDiagram-5OEKKPKP-vhL1y5zx.js} +1 -1
  375. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CztaySPs.js → sequenceDiagram-3UESZ5HK-UQthhFwd.js} +1 -1
  376. package/web-shell/assets/{stateDiagram-AJRCARHV-CTQT1oGD.js → stateDiagram-AJRCARHV-CAywEm20.js} +1 -1
  377. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-lfJQHw-7.js +1 -0
  378. package/web-shell/assets/{timeline-definition-PNZ67QCA-K9Mkex5A.js → timeline-definition-PNZ67QCA-CLO8b3FD.js} +1 -1
  379. package/web-shell/assets/{vennDiagram-CIIHVFJN-B2rVIw76.js → vennDiagram-CIIHVFJN-BNAAh0Mu.js} +1 -1
  380. package/web-shell/assets/{wardley-L42UT6IY-Z1w2JR4M.js → wardley-L42UT6IY-CUY7bLpN.js} +1 -1
  381. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-CIX9aKXf.js → wardleyDiagram-YWT4CUSO-CSg_ORdW.js} +1 -1
  382. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CI9DLIKB.js → xychartDiagram-2RQKCTM6-BjffV208.js} +1 -1
  383. package/web-shell/index.html +2 -2
  384. package/chunks/MaxSizedBox-INHRH72H.js +0 -86
  385. package/chunks/agent-VXDAN5JK.js +0 -82
  386. package/chunks/agent-headless-K4ZMMNBD.js +0 -76
  387. package/chunks/bridge-LGPZCFHO.js +0 -91
  388. package/chunks/channel-settings-store-CHCDRTPY.js +0 -89
  389. package/chunks/chunk-HGT6JR3U.js +0 -177
  390. package/chunks/chunk-JZA3JUDJ.js +0 -82
  391. package/chunks/chunk-SZRN75WQ.js +0 -29
  392. package/chunks/chunk-UGYMA4EI.js +0 -219
  393. package/chunks/chunk-VCBZUOSI.js +0 -8575
  394. package/chunks/contextCommand-QIZYHDR5.js +0 -81
  395. package/chunks/daemon-status-provider-OS5UWBHV.js +0 -90
  396. package/chunks/earlyInputCapture-WQT24RWD.js +0 -83
  397. package/chunks/environment-VZ7BRI4Q.js +0 -103
  398. package/chunks/errors-PCX25DVP.js +0 -89
  399. package/chunks/exitPlanMode-GHPUHBZJ.js +0 -423
  400. package/chunks/handleAutoUpdate-2CZQRJ66.js +0 -82
  401. package/chunks/i18n-XEQVMRKN.js +0 -98
  402. package/chunks/initializer-OVGZ4FLY.js +0 -87
  403. package/chunks/installationInfo-5UUQJI6Y.js +0 -81
  404. package/chunks/list-HODU6RXD.js +0 -90
  405. package/chunks/loadedSettingsAdapter-TYNLBALY.js +0 -84
  406. package/chunks/mcp-J3DFWX4A.js +0 -84
  407. package/chunks/nonInteractiveCli-F4GYSMHT.js +0 -144
  408. package/chunks/pidfile-4VNAR3EP.js +0 -87
  409. package/chunks/read-file-LZXUR4TO.js +0 -31
  410. package/chunks/resumeHistoryUtils-65OX3SGJ.js +0 -92
  411. package/chunks/ripGrep-2U2FRGMV.js +0 -74
  412. package/chunks/runtime-AXJWIEDU.js +0 -120
  413. package/chunks/serve-W2GC47CM.js +0 -90
  414. package/chunks/shell-45IPBDP5.js +0 -84
  415. package/chunks/spawnChannel-PVXQ5AGV.js +0 -83
  416. package/chunks/src-AY65BYR7.js +0 -3166
  417. package/chunks/standalone-update-ZMFNKAEY.js +0 -93
  418. package/chunks/task-create-N7WQSGYA.js +0 -25
  419. package/chunks/theme-manager-YYPZFBAH.js +0 -78
  420. package/chunks/total-session-admission-JXES723M.js +0 -85
  421. package/chunks/trustedFolders-HVI7IXUH.js +0 -94
  422. package/chunks/updateCheck-WUJGHWZZ.js +0 -93
  423. package/chunks/useAutoAcceptIndicator-CHSTZLZD.js +0 -94
  424. package/chunks/workspace-providers-status-GAKSF4LL.js +0 -87
  425. package/chunks/workspace-registry-A7NQUONG.js +0 -89
  426. package/chunks/workspace-service-STGVSO4N.js +0 -99
  427. package/chunks/workspace-skills-status-66AK3DUA.js +0 -86
  428. package/chunks/write-file-HUUCEG4P.js +0 -74
  429. package/web-shell/assets/channel-Bzdx6E8P.js +0 -1
  430. package/web-shell/assets/classDiagram-4FO5ZUOK-Cd6wbiuK.js +0 -1
  431. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Cd6wbiuK.js +0 -1
  432. package/web-shell/assets/index-B2bXx96W.js +0 -1249
  433. package/web-shell/assets/index-_8mKjx8q.css +0 -5
  434. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BjMdT6E_.js +0 -1
  435. package/chunks/{chunk-TARRHLLG.js → chunk-QUGAUQGJ.js} +25 -25
  436. package/chunks/{chunk-U7ZFW55U.js → chunk-VOQXFAY5.js} +977 -977
  437. /package/chunks/{chunk-LXXMOYPL.js → chunk-VXZBKKQR.js} +0 -0
@@ -1,9 +1,8 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
3
  import {
4
- DaemonMetricsRing,
5
4
  computeCpuPercent
6
- } from "./chunk-HGT6JR3U.js";
5
+ } from "./chunk-LBOVL47Y.js";
7
6
  import {
8
7
  RUNTIME_STARTUP_CANCELLED_MESSAGE
9
8
  } from "./chunk-QUPXZXLV.js";
@@ -35,22 +34,22 @@ import {
35
34
  require_express,
36
35
  resolveWebShellDir,
37
36
  setDeferredRuntimeRequestTiming
38
- } from "./chunk-3JAQDSXN.js";
37
+ } from "./chunk-H6MC6VQX.js";
39
38
  import {
40
39
  isLoopbackBind
41
40
  } from "./chunk-RXFQM6FQ.js";
42
41
  import {
43
42
  DEFAULT_COMPACTED_REPLAY_MAX_BYTES,
44
- normalizeCompactedReplayMaxBytes
45
- } from "./chunk-COH43MRJ.js";
46
- import {
47
- LOAD_REPLAY_META_KEY
48
- } from "./chunk-3SJ43L4W.js";
49
- import "./chunk-WBL3FJEU.js";
50
- import "./chunk-T2NCM2ET.js";
43
+ DEFAULT_MAX_JOURNAL_BYTES,
44
+ DEFAULT_MAX_JOURNAL_EVENTS,
45
+ normalizeCompactedReplayMaxBytes,
46
+ normalizeMaxJournalBytes,
47
+ normalizeMaxJournalEvents
48
+ } from "./chunk-XCGIMOLN.js";
49
+ import "./chunk-FC4KQFCS.js";
51
50
  import {
52
51
  resolveChannelCwd
53
- } from "./chunk-W4CQXHT6.js";
52
+ } from "./chunk-K4CGQN4Q.js";
54
53
  import {
55
54
  loadServeFastPathSettings,
56
55
  preResolveServeFastPathHomeEnvOverrides
@@ -59,51 +58,55 @@ import {
59
58
  MAX_REGISTERED_WORKSPACES,
60
59
  resolveWorkspaceInputs,
61
60
  workspaceRegistrationId
62
- } from "./chunk-CC4N4M36.js";
61
+ } from "./chunk-2PNQQ4UR.js";
62
+ import "./chunk-DVGTU5TC.js";
63
+ import {
64
+ LOAD_REPLAY_META_KEY
65
+ } from "./chunk-UKZEXS6K.js";
66
+ import "./chunk-J26HHFI5.js";
63
67
  import {
64
68
  canonicalizeWorkspace,
65
69
  translateAndCheckAbsoluteWorkspacePath
66
- } from "./chunk-2RFKHEXL.js";
67
- import "./chunk-3MSHSCSN.js";
68
- import "./chunk-N3FAY5CM.js";
70
+ } from "./chunk-6PLDPT2C.js";
71
+ import "./chunk-5UZITEHA.js";
72
+ import "./chunk-FYJ7W2PI.js";
69
73
  import {
70
74
  ChannelDeliveryError,
71
75
  ChannelWebhookEnqueueError,
72
76
  QWEN_SERVER_TOKEN_ENV,
73
77
  isChannelDeliveryError
74
- } from "./chunk-U4VTUMMK.js";
78
+ } from "./chunk-QONSRAEV.js";
75
79
  import {
76
80
  normalizeWorkerDiagnostic,
77
81
  sanitizeWorkerDiagnostic
78
- } from "./chunk-HV3G62R6.js";
82
+ } from "./chunk-UHTJC7O3.js";
79
83
  import {
80
84
  channelSelectionNames
81
85
  } from "./chunk-ALMR3E6Q.js";
82
86
  import "./chunk-BK2UNYWD.js";
83
87
  import "./chunk-M5GB774H.js";
88
+ import "./chunk-5HBA2Z7V.js";
89
+ import "./chunk-K6KS3LTN.js";
90
+ import "./chunk-T3CHYWJZ.js";
84
91
  import {
85
92
  sanitizeLogText
86
- } from "./chunk-ML52PL6O.js";
93
+ } from "./chunk-GB3AB7TR.js";
87
94
  import "./chunk-UDXSXLER.js";
88
- import "./chunk-5HBA2Z7V.js";
89
95
  import "./chunk-GOXKNSDZ.js";
90
96
  import {
91
97
  getGlobalQwenDirLite,
92
98
  resolveConfigPathLite
93
99
  } from "./chunk-IDS7MSUP.js";
94
100
  import "./chunk-6PEXNQTX.js";
95
- import {
96
- getCliVersion
97
- } from "./chunk-I7XZ3RY5.js";
98
- import "./chunk-VJNBRRZG.js";
99
101
  import "./chunk-ALGGS7UH.js";
100
102
  import {
101
103
  isWithinRoot
102
104
  } from "./chunk-MR3PXB6E.js";
103
105
  import {
104
- writeStderrLine,
105
- writeStdoutLine
106
- } from "./chunk-OWAK7LMW.js";
106
+ getCliVersion
107
+ } from "./chunk-MBKPUM5Y.js";
108
+ import "./chunk-VJNBRRZG.js";
109
+ import "./chunk-GOFAQQZA.js";
107
110
  import "./chunk-5M6IDOMF.js";
108
111
  import "./chunk-TWPJO254.js";
109
112
  import "./chunk-H6XPXXMH.js";
@@ -117,6 +120,10 @@ import {
117
120
  profileCheckpoint
118
121
  } from "./chunk-QSWDGAIC.js";
119
122
  import "./chunk-Q7YDKOGY.js";
123
+ import {
124
+ writeStderrLine,
125
+ writeStdoutLine
126
+ } from "./chunk-OWAK7LMW.js";
120
127
  import "./chunk-DMTGGOSA.js";
121
128
  import "./chunk-YQ3U5MUC.js";
122
129
  import {
@@ -137,6 +144,10 @@ import * as path from "node:path";
137
144
  import * as os from "node:os";
138
145
  import { monitorEventLoopDelay, performance as performance2 } from "node:perf_hooks";
139
146
 
147
+ // packages/core/dist/src/memory/scopes.js
148
+ init_esbuild_shims();
149
+ var MEMORY_PROJECT_SCOPES = ["git-root", "workspace"];
150
+
140
151
  // packages/cli/src/serve/permission-audit.ts
141
152
  init_esbuild_shims();
142
153
  var DEFAULT_PERMISSION_AUDIT_RING_SIZE = 512;
@@ -1262,7 +1273,7 @@ function createConcreteLogger(input) {
1262
1273
  }
1263
1274
  });
1264
1275
  let timeout;
1265
- const deadline = new Promise((resolve) => {
1276
+ const deadline = new Promise((resolve2) => {
1266
1277
  timeout = setTimeout(() => {
1267
1278
  try {
1268
1279
  input.warnOnce(
@@ -1271,7 +1282,7 @@ function createConcreteLogger(input) {
1271
1282
  );
1272
1283
  } catch {
1273
1284
  } finally {
1274
- resolve();
1285
+ resolve2();
1275
1286
  }
1276
1287
  }, input.policy.closeDrainBudgetMs);
1277
1288
  timeout.unref();
@@ -1615,6 +1626,156 @@ ${capUtf8Record(
1615
1626
  }
1616
1627
  __name(initDaemonLogger, "initDaemonLogger");
1617
1628
 
1629
+ // packages/cli/src/serve/daemon-metrics-ring.ts
1630
+ init_esbuild_shims();
1631
+ var MAX_SAMPLES_PER_WINDOW = 4096;
1632
+ var DaemonMetricsRing = class {
1633
+ static {
1634
+ __name(this, "DaemonMetricsRing");
1635
+ }
1636
+ capacity;
1637
+ buckets = [];
1638
+ curRequests = 0;
1639
+ curErrors = 0;
1640
+ curDurations = [];
1641
+ curPromptsCompleted = 0;
1642
+ curQueueWaits = [];
1643
+ curPromptDurations = [];
1644
+ curLlmDurations = [];
1645
+ curLlmApiErrors = 0;
1646
+ curLlmApiRetries = 0;
1647
+ curPipeInBytes = 0;
1648
+ curPipeOutBytes = 0;
1649
+ curTokensIn = 0;
1650
+ curTokensOut = 0;
1651
+ constructor(options) {
1652
+ this.capacity = Math.max(1, Math.floor(options.capacity));
1653
+ }
1654
+ /** Fold one completed HTTP request into the open window. */
1655
+ recordRequest(durationMs, statusCode) {
1656
+ this.curRequests += 1;
1657
+ if (statusCode >= 400) this.curErrors += 1;
1658
+ pushCapped(this.curDurations, durationMs);
1659
+ }
1660
+ /** Fold one prompt's queue wait (dispatched from the per-session FIFO). */
1661
+ recordPromptQueueWait(durationMs) {
1662
+ pushCapped(this.curQueueWaits, durationMs);
1663
+ }
1664
+ /** Fold one finished prompt's end-to-end duration (also counts throughput). */
1665
+ recordPromptDuration(durationMs) {
1666
+ this.curPromptsCompleted += 1;
1667
+ pushCapped(this.curPromptDurations, durationMs);
1668
+ }
1669
+ /** Fold one model round's LLM API round-trip time (from the token frame). */
1670
+ recordLlmDuration(durationMs) {
1671
+ pushCapped(this.curLlmDurations, durationMs);
1672
+ }
1673
+ /**
1674
+ * Fold one model round's per-round model-API-error and automatic-retry
1675
+ * increments (from the same token frame) into the open window. Both are
1676
+ * plain counters — a burst in one window accrues exactly, past the sample
1677
+ * cap that only bounds the percentile arrays. Non-finite / negative inputs
1678
+ * are ignored so a malformed frame cannot poison the totals.
1679
+ */
1680
+ recordApiActivity(errors, retries) {
1681
+ if (Number.isFinite(errors) && errors > 0) this.curLlmApiErrors += errors;
1682
+ if (Number.isFinite(retries) && retries > 0) {
1683
+ this.curLlmApiRetries += retries;
1684
+ }
1685
+ }
1686
+ /** Fold one ACP-child pipe message's payload size into the open window. */
1687
+ recordPipe(direction, bytes) {
1688
+ if (!Number.isFinite(bytes) || bytes < 0) return;
1689
+ if (direction === "inbound") this.curPipeInBytes += bytes;
1690
+ else this.curPipeOutBytes += bytes;
1691
+ }
1692
+ /** Fold one model turn's token usage into the open window. */
1693
+ recordTokens(inputTokens, outputTokens) {
1694
+ if (Number.isFinite(inputTokens) && inputTokens > 0) {
1695
+ this.curTokensIn += inputTokens;
1696
+ }
1697
+ if (Number.isFinite(outputTokens) && outputTokens > 0) {
1698
+ this.curTokensOut += outputTokens;
1699
+ }
1700
+ }
1701
+ /**
1702
+ * Seal the open window into a bucket stamped at `now` (folding in the
1703
+ * gauges), append it, evict the oldest past capacity, then reset the
1704
+ * accumulators for the next window.
1705
+ */
1706
+ sample(now, gauges) {
1707
+ this.buckets.push({
1708
+ t: now,
1709
+ activeSessions: finiteGauge(gauges.activeSessions),
1710
+ activePrompts: finiteGauge(gauges.activePrompts),
1711
+ queuedPrompts: finiteGauge(gauges.queuedPrompts),
1712
+ requests: this.curRequests,
1713
+ errors: this.curErrors,
1714
+ latencyP50Ms: percentile(this.curDurations, 0.5),
1715
+ latencyP95Ms: percentile(this.curDurations, 0.95),
1716
+ promptsCompleted: this.curPromptsCompleted,
1717
+ promptQueueWaitP95Ms: percentile(this.curQueueWaits, 0.95),
1718
+ promptDurationP95Ms: percentile(this.curPromptDurations, 0.95),
1719
+ llmApiP50Ms: percentile(this.curLlmDurations, 0.5),
1720
+ llmApiP95Ms: percentile(this.curLlmDurations, 0.95),
1721
+ llmApiErrors: this.curLlmApiErrors,
1722
+ llmApiRetries: this.curLlmApiRetries,
1723
+ cpuPercent: finiteGauge(gauges.cpuPercent),
1724
+ rssBytes: finiteGauge(gauges.rssBytes),
1725
+ heapUsedBytes: finiteGauge(gauges.heapUsedBytes),
1726
+ eventLoopLagP99Ms: finiteGauge(gauges.eventLoopLagP99Ms),
1727
+ pipeInBytes: this.curPipeInBytes,
1728
+ pipeOutBytes: this.curPipeOutBytes,
1729
+ sseConnections: finiteGauge(gauges.sseConnections),
1730
+ wsConnections: finiteGauge(gauges.wsConnections),
1731
+ acpConnections: finiteGauge(gauges.acpConnections),
1732
+ rateLimitRejected: finiteGauge(gauges.rateLimitRejected),
1733
+ tokensIn: this.curTokensIn,
1734
+ tokensOut: this.curTokensOut,
1735
+ childCpuPercent: finiteGauge(gauges.childCpuPercent),
1736
+ childRssBytes: finiteGauge(gauges.childRssBytes)
1737
+ });
1738
+ if (this.buckets.length > this.capacity) {
1739
+ this.buckets.splice(0, this.buckets.length - this.capacity);
1740
+ }
1741
+ this.curRequests = 0;
1742
+ this.curErrors = 0;
1743
+ this.curDurations.length = 0;
1744
+ this.curPromptsCompleted = 0;
1745
+ this.curQueueWaits.length = 0;
1746
+ this.curPromptDurations.length = 0;
1747
+ this.curLlmDurations.length = 0;
1748
+ this.curLlmApiErrors = 0;
1749
+ this.curLlmApiRetries = 0;
1750
+ this.curPipeInBytes = 0;
1751
+ this.curPipeOutBytes = 0;
1752
+ this.curTokensIn = 0;
1753
+ this.curTokensOut = 0;
1754
+ }
1755
+ /** Oldest→newest copy of the retained buckets (safe to serialize). */
1756
+ snapshot() {
1757
+ return this.buckets.slice();
1758
+ }
1759
+ };
1760
+ function finiteGauge(value) {
1761
+ return Number.isFinite(value) ? value : 0;
1762
+ }
1763
+ __name(finiteGauge, "finiteGauge");
1764
+ function pushCapped(target, value) {
1765
+ if (Number.isFinite(value) && value >= 0 && target.length < MAX_SAMPLES_PER_WINDOW) {
1766
+ target.push(value);
1767
+ }
1768
+ }
1769
+ __name(pushCapped, "pushCapped");
1770
+ function percentile(samples, q) {
1771
+ if (samples.length === 0) return 0;
1772
+ const sorted = samples.slice().sort((a, b) => a - b);
1773
+ const rank = Math.ceil(q * sorted.length);
1774
+ const idx = Math.min(sorted.length - 1, Math.max(0, rank - 1));
1775
+ return sorted[idx];
1776
+ }
1777
+ __name(percentile, "percentile");
1778
+
1618
1779
  // packages/cli/src/serve/large-pipe-frame-observer.ts
1619
1780
  init_esbuild_shims();
1620
1781
  var LARGE_PIPE_FRAME_THRESHOLD_BYTES = 256 * 1024;
@@ -2319,8 +2480,8 @@ async function flushDaemonLogBounded(daemonLog, budgetMs) {
2319
2480
  await Promise.race([
2320
2481
  daemonLog.flush().catch(() => {
2321
2482
  }),
2322
- new Promise((resolve) => {
2323
- timer = setTimeout(resolve, budgetMs);
2483
+ new Promise((resolve2) => {
2484
+ timer = setTimeout(resolve2, budgetMs);
2324
2485
  timer.unref();
2325
2486
  })
2326
2487
  ]);
@@ -2364,7 +2525,7 @@ var FAST_PATH_RUNTIME_START_AFTER_HEALTH_MS = 50;
2364
2525
  var FAST_PATH_RUNTIME_START_FALLBACK_MS = 1e3;
2365
2526
  var RUNTIME_STARTUP_TIMEOUT_ENV = "QWEN_SERVE_RUNTIME_STARTUP_TIMEOUT_MS";
2366
2527
  var MAX_EVENT_RING_SIZE = 1e6;
2367
- var DEFAULT_MAX_SESSIONS = 20;
2528
+ var DEFAULT_MAX_SESSIONS = 32;
2368
2529
  var DEFAULT_MAX_PENDING_PROMPTS_PER_SESSION = 5;
2369
2530
  var DEFAULT_EVENT_RING_SIZE = 8e3;
2370
2531
  var DEFAULT_SESSION_IDLE_TIMEOUT_MS = 30 * 6e4;
@@ -2494,6 +2655,13 @@ function formatHostForUrl(host) {
2494
2655
  return host;
2495
2656
  }
2496
2657
  __name(formatHostForUrl, "formatHostForUrl");
2658
+ function workspaceRuntimeEffectiveEnv(runtime, daemonEnv) {
2659
+ if (runtime.env.mode === "runtime-overlay") {
2660
+ return runtime.env.effectiveEnv ?? {};
2661
+ }
2662
+ return runtime.env.effectiveEnv ?? daemonEnv;
2663
+ }
2664
+ __name(workspaceRuntimeEffectiveEnv, "workspaceRuntimeEffectiveEnv");
2497
2665
  function formatChannelWorkerDaemonUrl(host, port) {
2498
2666
  const normalized = host.trim().toLowerCase();
2499
2667
  if (normalized === "" || normalized === "0.0.0.0" || normalized === "::" || normalized === "[::]") {
@@ -2531,15 +2699,16 @@ function withSettingsLock(workspace, fn) {
2531
2699
  return next;
2532
2700
  }
2533
2701
  __name(withSettingsLock, "withSettingsLock");
2702
+ var retryableChannelWorkerShutdownErrors = /* @__PURE__ */ new WeakSet();
2534
2703
  var channelWorkerRuntimePromise;
2535
2704
  async function loadChannelWorkerRuntime() {
2536
2705
  channelWorkerRuntimePromise ??= Promise.all([
2537
- import("./channel-worker-supervisor-KUFTR6P5.js"),
2538
- import("./pidfile-4VNAR3EP.js"),
2539
- import("./runtime-AXJWIEDU.js"),
2706
+ import("./channel-worker-supervisor-ORJIEEPP.js"),
2707
+ import("./pidfile-ZMOIUGG6.js"),
2708
+ import("./runtime-WCWM3DO7.js"),
2540
2709
  import("./cli-entry-path-4VJ3Y6T2.js"),
2541
- import("./channel-worker-group-PTJIJSKC.js"),
2542
- import("./channel-worker-manager-WIMGM2FD.js")
2710
+ import("./channel-worker-group-ERSUOPIR.js"),
2711
+ import("./channel-worker-manager-X247YDQ7.js")
2543
2712
  ]).then(
2544
2713
  ([
2545
2714
  supervisor,
@@ -2644,7 +2813,7 @@ function shouldPreheatBridge(deps) {
2644
2813
  __name(shouldPreheatBridge, "shouldPreheatBridge");
2645
2814
  var coreRuntimePromise;
2646
2815
  function loadCoreRuntime() {
2647
- coreRuntimePromise ??= import("./src-AY65BYR7.js");
2816
+ coreRuntimePromise ??= import("./core-runtime-NL3ZBHBU.js");
2648
2817
  return coreRuntimePromise;
2649
2818
  }
2650
2819
  __name(loadCoreRuntime, "loadCoreRuntime");
@@ -2674,10 +2843,10 @@ __name(resolveDaemonLogBaseDirForRun, "resolveDaemonLogBaseDirForRun");
2674
2843
  var settingsRuntimePromise;
2675
2844
  function loadSettingsRuntimeModules() {
2676
2845
  settingsRuntimePromise ??= Promise.all([
2677
- import("./settings-7ZGZDXAS.js"),
2678
- import("./environment-VZ7BRI4Q.js"),
2679
- import("./loadedSettingsAdapter-TYNLBALY.js"),
2680
- import("./trustedFolders-HVI7IXUH.js")
2846
+ import("./settings-CUN3SELH.js"),
2847
+ import("./environment-DXJTXSVT.js"),
2848
+ import("./loadedSettingsAdapter-OK6GK2GE.js"),
2849
+ import("./trustedFolders-EVCN36O5.js")
2681
2850
  ]).then(([settings, environment, loadedSettingsAdapter, trustedFolders]) => ({
2682
2851
  settings,
2683
2852
  environment,
@@ -2690,8 +2859,8 @@ __name(loadSettingsRuntimeModules, "loadSettingsRuntimeModules");
2690
2859
  var channelWebhookConfigRuntimePromise;
2691
2860
  function loadChannelWebhookConfigRuntime() {
2692
2861
  channelWebhookConfigRuntimePromise ??= Promise.all([
2693
- import("./runtime-AXJWIEDU.js"),
2694
- import("./config-utils-VFQXVGNR.js")
2862
+ import("./runtime-WCWM3DO7.js"),
2863
+ import("./config-utils-64LM6OEQ.js")
2695
2864
  ]).then(([channelRuntime, configUtils]) => ({
2696
2865
  loadChannelsConfig: channelRuntime.loadChannelsConfig,
2697
2866
  parseChannelWebhookConfig: configUtils.parseChannelWebhookConfig
@@ -2707,6 +2876,7 @@ async function loadServeRuntimeModules() {
2707
2876
  serverModule,
2708
2877
  bridgeModule,
2709
2878
  spawnChannelModule,
2879
+ processRegistryModule,
2710
2880
  workspaceModule,
2711
2881
  workspaceTypesModule,
2712
2882
  daemonStatusProviderModule,
@@ -2715,16 +2885,17 @@ async function loadServeRuntimeModules() {
2715
2885
  totalSessionAdmissionModule,
2716
2886
  workspaceRegistryModule
2717
2887
  ] = await Promise.all([
2718
- import("./server-HRZ23U7M.js"),
2719
- import("./bridge-LGPZCFHO.js"),
2720
- import("./spawnChannel-PVXQ5AGV.js"),
2721
- import("./workspace-service-STGVSO4N.js"),
2888
+ import("./server-N4AJRKIQ.js"),
2889
+ import("./bridge-JNEW6FES.js"),
2890
+ import("./spawnChannel-RILO4YY3.js"),
2891
+ import("./process-registry-2CHQBXH5.js"),
2892
+ import("./workspace-service-VH6IWADT.js"),
2722
2893
  import("./types-ML3TRJQ5.js"),
2723
- import("./daemon-status-provider-OS5UWBHV.js"),
2724
- import("./workspace-providers-status-GAKSF4LL.js"),
2725
- import("./workspace-skills-status-66AK3DUA.js"),
2726
- import("./total-session-admission-JXES723M.js"),
2727
- import("./workspace-registry-A7NQUONG.js")
2894
+ import("./daemon-status-provider-XD23SNAM.js"),
2895
+ import("./workspace-providers-status-O3HUZGGR.js"),
2896
+ import("./workspace-skills-status-XANARSZS.js"),
2897
+ import("./total-session-admission-3ZTAXVUK.js"),
2898
+ import("./workspace-registry-U7ISW23N.js")
2728
2899
  ]);
2729
2900
  return {
2730
2901
  createServeApp: serverModule.createServeApp,
@@ -2733,6 +2904,7 @@ async function loadServeRuntimeModules() {
2733
2904
  resolveBridgeFsFactory: serverModule.resolveBridgeFsFactory,
2734
2905
  createAcpSessionBridge: bridgeModule.createAcpSessionBridge,
2735
2906
  createSpawnChannelFactory: spawnChannelModule.createSpawnChannelFactory,
2907
+ ProcessRegistry: processRegistryModule.ProcessRegistry,
2736
2908
  createDaemonWorkspaceService: workspaceModule.createDaemonWorkspaceService,
2737
2909
  WorkspaceSettingsPartialPersistError: workspaceTypesModule.WorkspaceSettingsPartialPersistError,
2738
2910
  WorkspaceSkillNotToggleableError: workspaceTypesModule.WorkspaceSkillNotToggleableError,
@@ -2741,7 +2913,8 @@ async function loadServeRuntimeModules() {
2741
2913
  createWorkspaceSkillsStatusProvider: workspaceSkillsStatusModule.createWorkspaceSkillsStatusProvider,
2742
2914
  createTotalSessionAdmissionController: totalSessionAdmissionModule.createTotalSessionAdmissionController,
2743
2915
  createWorkspaceRegistry: workspaceRegistryModule.createWorkspaceRegistry,
2744
- createWorkspaceSessionOwnerIndex: workspaceRegistryModule.createWorkspaceSessionOwnerIndex
2916
+ createWorkspaceSessionOwnerIndex: workspaceRegistryModule.createWorkspaceSessionOwnerIndex,
2917
+ createWorkspaceGenerationGuard: workspaceRegistryModule.createWorkspaceGenerationGuard
2745
2918
  };
2746
2919
  }
2747
2920
  __name(loadServeRuntimeModules, "loadServeRuntimeModules");
@@ -2916,12 +3089,12 @@ async function waitForRuntimeStartingForShutdown(runtimeStarting, daemonLog, tim
2916
3089
  let timer;
2917
3090
  await Promise.race([
2918
3091
  runtimeStarting,
2919
- new Promise((resolve) => {
3092
+ new Promise((resolve2) => {
2920
3093
  timer = setTimeout(() => {
2921
3094
  daemonLog.warn(
2922
3095
  `${timeoutMs}ms runtime-startup wait reached during shutdown; continuing listener close`
2923
3096
  );
2924
- resolve();
3097
+ resolve2();
2925
3098
  }, timeoutMs);
2926
3099
  timer.unref();
2927
3100
  })
@@ -3090,6 +3263,8 @@ function createBootstrapServeApp(input) {
3090
3263
  listenerMaxConnections: listenerMaxConnections(opts.maxConnections),
3091
3264
  eventRingSize: opts.eventRingSize ?? DEFAULT_EVENT_RING_SIZE,
3092
3265
  compactedReplayMaxBytes: opts.compactedReplayMaxBytes ?? DEFAULT_COMPACTED_REPLAY_MAX_BYTES,
3266
+ maxJournalEvents: opts.maxJournalEvents ?? DEFAULT_MAX_JOURNAL_EVENTS,
3267
+ maxJournalBytes: opts.maxJournalBytes ?? DEFAULT_MAX_JOURNAL_BYTES,
3093
3268
  promptDeadlineMs: positiveFiniteOrNull(opts.promptDeadlineMs),
3094
3269
  writerIdleTimeoutMs: positiveFiniteOrNull(opts.writerIdleTimeoutMs),
3095
3270
  channelIdleTimeoutMs: channelIdleTimeoutMs(opts.channelIdleTimeoutMs),
@@ -3382,9 +3557,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3382
3557
  status: deps.bridge ? "external_bridge" : shouldPreheat ? "scheduled" : "not_scheduled"
3383
3558
  }
3384
3559
  };
3560
+ if (optsIn.memoryProjectScope !== void 0 && !MEMORY_PROJECT_SCOPES.includes(
3561
+ optsIn.memoryProjectScope
3562
+ )) {
3563
+ throw new TypeError(
3564
+ `Invalid memoryProjectScope: ${String(optsIn.memoryProjectScope)}. Must be "git-root" or "workspace".`
3565
+ );
3566
+ }
3385
3567
  preResolveServeFastPathHomeEnvOverrides();
3386
3568
  const daemonRuntimeBaseEnv = Object.freeze({
3387
- ...process.env
3569
+ ...process.env,
3570
+ ...optsIn.memoryProjectScope !== void 0 ? {
3571
+ QWEN_CODE_MEMORY_PROJECT_SCOPE: optsIn.memoryProjectScope
3572
+ } : {}
3388
3573
  });
3389
3574
  const rawToken = optsIn.token ?? process.env[QWEN_SERVER_TOKEN_ENV];
3390
3575
  const token = typeof rawToken === "string" && rawToken.trim().length > 0 ? rawToken.trim() : void 0;
@@ -3613,7 +3798,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3613
3798
  }
3614
3799
  let workspaceRegistrationStore = deps.workspaceRegistrationStore;
3615
3800
  if (workspaceRegistrationStore === void 0 && process.env["QWEN_SERVE_NO_PERSISTENT_REGISTRATION"] !== "1") {
3616
- const { WorkspaceRegistrationStore } = await import("./workspace-registration-store-6TGVDJV5.js");
3801
+ const { WorkspaceRegistrationStore } = await import("./workspace-registration-store-M3FJ74RS.js");
3617
3802
  workspaceRegistrationStore = new WorkspaceRegistrationStore(boundWorkspace);
3618
3803
  }
3619
3804
  if (workspaceRegistrationStore) {
@@ -3768,6 +3953,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3768
3953
  if (opts.compactedReplayMaxBytes !== void 0) {
3769
3954
  normalizeCompactedReplayMaxBytes(opts.compactedReplayMaxBytes);
3770
3955
  }
3956
+ if (opts.maxJournalEvents !== void 0) {
3957
+ normalizeMaxJournalEvents(opts.maxJournalEvents);
3958
+ }
3959
+ if (opts.maxJournalBytes !== void 0) {
3960
+ normalizeMaxJournalBytes(opts.maxJournalBytes);
3961
+ }
3771
3962
  if (opts.writerIdleTimeoutMs !== void 0) {
3772
3963
  if (!isPositiveIntegerMs(opts.writerIdleTimeoutMs)) {
3773
3964
  throw new TypeError(
@@ -3852,6 +4043,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3852
4043
  let runtimeApp;
3853
4044
  let runtimeAppForCleanup;
3854
4045
  let bridgeRef = deps.bridge;
4046
+ let managedProcessRegistry;
3855
4047
  const internalRuntimeBridgesForCleanup = [];
3856
4048
  let daemonEventLoopMonitor;
3857
4049
  let daemonMetricsSampler;
@@ -3863,8 +4055,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3863
4055
  let startRuntimeAfterHealth;
3864
4056
  let startRuntimeForRequest;
3865
4057
  const deferRuntimeUntilFirstHealth = deps.resolveOnListen === true && deps.deferRuntimeUntilFirstHealth === true;
3866
- const runtimeReady = new Promise((resolve, reject) => {
3867
- markRuntimeReady = resolve;
4058
+ const runtimeReady = new Promise((resolve2, reject) => {
4059
+ markRuntimeReady = resolve2;
3868
4060
  markRuntimeFailed = reject;
3869
4061
  });
3870
4062
  void runtimeReady.catch(() => {
@@ -4018,6 +4210,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4018
4210
  const disposedRuntimeApps = /* @__PURE__ */ new WeakSet();
4019
4211
  const stoppedRuntimeAppProducers = /* @__PURE__ */ new WeakSet();
4020
4212
  const stoppedExtensionReconcilers = /* @__PURE__ */ new WeakSet();
4213
+ const stoppedTrustPolicyMonitors = /* @__PURE__ */ new WeakSet();
4214
+ const stopTrustPolicyMonitor = /* @__PURE__ */ __name((app2) => {
4215
+ if (!app2 || stoppedTrustPolicyMonitors.has(app2)) return;
4216
+ stoppedTrustPolicyMonitors.add(app2);
4217
+ const stop = app2.locals?.["stopTrustPolicyMonitor"];
4218
+ try {
4219
+ stop?.();
4220
+ } catch (err) {
4221
+ daemonLog.warn(
4222
+ `trust policy monitor dispose error: ${err instanceof Error ? err.message : String(err)}`
4223
+ );
4224
+ }
4225
+ }, "stopTrustPolicyMonitor");
4021
4226
  const stopExtensionReconciler = /* @__PURE__ */ __name((app2) => {
4022
4227
  if (!app2 || stoppedExtensionReconcilers.has(app2)) return;
4023
4228
  stoppedExtensionReconcilers.add(app2);
@@ -4045,6 +4250,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4045
4250
  }, "stopSafely");
4046
4251
  stopSafely("scheduled-task keepalive", locals.stopScheduledTaskKeepalive);
4047
4252
  stopSafely("workspace git state", locals.stopWorkspaceGitState);
4253
+ stopTrustPolicyMonitor(app2);
4048
4254
  for (const stop of locals.subSessionStoppers ?? []) {
4049
4255
  stopSafely("sub-session launcher", stop);
4050
4256
  }
@@ -4098,13 +4304,23 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4098
4304
  return [...new Set(bridges)];
4099
4305
  }, "getRuntimeBridgesForCleanup");
4100
4306
  const buildRuntime = /* @__PURE__ */ __name(async () => {
4101
- const [runtime, core, settingsRuntime, resolvedCliVersion] = await Promise.all([
4307
+ const [runtime, core, settingsRuntime, resolvedCliVersion, trustPolicy] = await Promise.all([
4102
4308
  loadServeRuntimeModules(),
4103
4309
  loadCoreRuntime(),
4104
4310
  loadSettingsRuntimeModules(),
4105
- cliVersionPromise
4311
+ cliVersionPromise,
4312
+ import("./daemon-trust-policy-NOHK7IW5.js")
4106
4313
  ]);
4107
4314
  cliVersion = resolvedCliVersion;
4315
+ settingsRuntime.environment.preResolveHomeEnvOverrides();
4316
+ const bootTrustSnapshot = await trustPolicy.readDaemonTrustPolicySnapshot();
4317
+ let latestTrustPolicySnapshot = bootTrustSnapshot;
4318
+ const bootPrimaryTrustDecision = trustPolicy.evaluateDaemonWorkspaceTrust(
4319
+ bootTrustSnapshot,
4320
+ boundWorkspace
4321
+ );
4322
+ const trustedWorkspace = deps.trustedWorkspace ?? bootPrimaryTrustDecision.targetTrusted;
4323
+ const workspaceTrustHotReloadAvailable = deps.trustedWorkspace === void 0 && deps.bridge === void 0 && deps.fsFactory === void 0;
4108
4324
  let managedScratchRoot;
4109
4325
  try {
4110
4326
  managedScratchRoot = prepareManagedScratchRoot(
@@ -4118,16 +4334,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4118
4334
  }
4119
4335
  let runtimeBootSettings;
4120
4336
  try {
4121
- runtimeBootSettings = settingsRuntime.settings.loadSettings(boundWorkspace);
4337
+ runtimeBootSettings = settingsRuntime.settings.loadSettings(
4338
+ boundWorkspace,
4339
+ {
4340
+ skipLoadEnvironment: true,
4341
+ skipWorkspaceSettings: !trustedWorkspace,
4342
+ workspaceTrusted: trustedWorkspace
4343
+ }
4344
+ );
4122
4345
  } catch (err) {
4123
4346
  writeStderrLine(
4124
4347
  `qwen serve: could not read full settings for runtime startup (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4125
4348
  );
4126
4349
  }
4127
- const trustedWorkspace = deps.trustedWorkspace ?? (runtimeBootSettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4128
- runtimeBootSettings.merged,
4129
- boundWorkspace
4130
- ).effective.state === "trusted" : true);
4131
4350
  if (deps.trustedWorkspace === void 0 && runtimeBootSettings && !trustedWorkspace) {
4132
4351
  daemonLog.warn(
4133
4352
  "workspace file writes are disabled because the bound workspace is not trusted",
@@ -4137,7 +4356,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4137
4356
  const runtimeEnvSnapshot = runtimeBootSettings ? settingsRuntime.environment.buildRuntimeEnvironment(
4138
4357
  runtimeBootSettings.merged,
4139
4358
  boundWorkspace,
4140
- daemonRuntimeBaseEnv
4359
+ daemonRuntimeBaseEnv,
4360
+ trustedWorkspace
4141
4361
  ) : {
4142
4362
  effectiveEnv: { ...daemonRuntimeBaseEnv },
4143
4363
  overlayKeys: Object.freeze([]),
@@ -4145,6 +4365,29 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4145
4365
  envFileReadFailed: false,
4146
4366
  envFileReadFailures: Object.freeze([])
4147
4367
  };
4368
+ const resolveSessionRuntimeBaseDir = /* @__PURE__ */ __name((workspace, settings, effectiveEnv) => {
4369
+ const resolveConfiguredPath = /* @__PURE__ */ __name((configuredPath, relativeTo) => {
4370
+ const expanded = configuredPath === "~" ? os.homedir() : configuredPath.startsWith("~/") || configuredPath.startsWith("~\\") ? path.join(
4371
+ os.homedir(),
4372
+ ...configuredPath.slice(2).split(/[/\\]+/).filter(Boolean)
4373
+ ) : configuredPath;
4374
+ return path.resolve(relativeTo, expanded);
4375
+ }, "resolveConfiguredPath");
4376
+ const runtimeDir = effectiveEnv["QWEN_RUNTIME_DIR"];
4377
+ if (runtimeDir) {
4378
+ return resolveConfiguredPath(runtimeDir, process.cwd());
4379
+ }
4380
+ const settingsDir = settings?.merged.advanced?.runtimeOutputDir;
4381
+ if (settingsDir) {
4382
+ return resolveConfiguredPath(settingsDir, workspace);
4383
+ }
4384
+ const qwenHome = effectiveEnv["QWEN_HOME"];
4385
+ if (qwenHome) {
4386
+ return resolveConfiguredPath(qwenHome, process.cwd());
4387
+ }
4388
+ const homeDir = os.homedir();
4389
+ return homeDir ? path.join(homeDir, ".qwen") : path.join(os.tmpdir(), ".qwen");
4390
+ }, "resolveSessionRuntimeBaseDir");
4148
4391
  const logRuntimeEnvFileReadFailures = /* @__PURE__ */ __name((workspace, snapshot) => {
4149
4392
  if (!snapshot.envFileReadFailed) return;
4150
4393
  const failedFiles = snapshot.envFileReadFailures ?? [];
@@ -4154,14 +4397,21 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4154
4397
  });
4155
4398
  }, "logRuntimeEnvFileReadFailures");
4156
4399
  logRuntimeEnvFileReadFailures(boundWorkspace, runtimeEnvSnapshot);
4400
+ const primarySessionRuntimeBaseDir = resolveSessionRuntimeBaseDir(
4401
+ boundWorkspace,
4402
+ runtimeBootSettings,
4403
+ runtimeEnvSnapshot.effectiveEnv
4404
+ );
4157
4405
  const runtimeEffectiveEnv = {
4158
- ...runtimeEnvSnapshot.effectiveEnv
4406
+ ...runtimeEnvSnapshot.effectiveEnv,
4407
+ QWEN_RUNTIME_DIR: primarySessionRuntimeBaseDir
4159
4408
  };
4160
4409
  const replaceRuntimeEffectiveEnv = /* @__PURE__ */ __name((nextEnv) => {
4161
4410
  for (const key of Object.keys(runtimeEffectiveEnv)) {
4162
4411
  delete runtimeEffectiveEnv[key];
4163
4412
  }
4164
4413
  Object.assign(runtimeEffectiveEnv, nextEnv);
4414
+ runtimeEffectiveEnv["QWEN_RUNTIME_DIR"] = primarySessionRuntimeBaseDir;
4165
4415
  }, "replaceRuntimeEffectiveEnv");
4166
4416
  const primaryRuntimeEnv = {
4167
4417
  mode: "runtime-overlay",
@@ -4308,17 +4558,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4308
4558
  void 0,
4309
4559
  (workspace, index) => {
4310
4560
  if (index === 0) return true;
4311
- if (!runtimeBootSettings) {
4312
- daemonLog.warn(
4313
- "excluding secondary workspace root because trust settings are unavailable",
4314
- { workspace }
4315
- );
4316
- return false;
4317
- }
4318
- const trustedSecondary = settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4319
- runtimeBootSettings.merged,
4561
+ const trustedSecondary = trustPolicy.evaluateDaemonWorkspaceTrust(
4562
+ bootTrustSnapshot,
4320
4563
  workspace
4321
- ).effective.state === "trusted";
4564
+ ).targetTrusted;
4322
4565
  if (!trustedSecondary) {
4323
4566
  daemonLog.warn(
4324
4567
  "excluding untrusted secondary workspace root from file-system access",
@@ -4333,7 +4576,16 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4333
4576
  secondary: boundWorkspaces.slice(1),
4334
4577
  ideEnvPresent: !!process.env["QWEN_CODE_IDE_WORKSPACE_PATH"]
4335
4578
  });
4579
+ const primaryGenerationGuard = runtime.createWorkspaceGenerationGuard();
4580
+ const primaryTrustMaterialization = JSON.stringify({
4581
+ trusted: trustedWorkspace,
4582
+ boundWorkspaces: [...boundWorkspaces].sort()
4583
+ });
4336
4584
  const sharedPathLocks = new PathMutexRegistry();
4585
+ const workspaceTrustOperationGate = new PathMutexRegistry();
4586
+ const runWorkspaceTrustOperation = /* @__PURE__ */ __name((operation) => workspaceTrustOperationGate.runExclusive("runtime-topology", operation), "runWorkspaceTrustOperation");
4587
+ const processRegistry = new runtime.ProcessRegistry();
4588
+ managedProcessRegistry = processRegistry;
4337
4589
  const fsFactory = runtime.resolveBridgeFsFactory({
4338
4590
  // Secondary roots share a write-capable factory only after their own
4339
4591
  // folder trust check passes; untrusted secondary roots stay outside.
@@ -4342,6 +4594,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4342
4594
  trusted: trustedWorkspace,
4343
4595
  emit: deps.fsAuditEmit,
4344
4596
  pathLocks: sharedPathLocks,
4597
+ generationGuard: primaryGenerationGuard,
4345
4598
  ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4346
4599
  });
4347
4600
  const routeFsFactory = runtime.resolveBridgeFsFactory({
@@ -4351,9 +4604,11 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4351
4604
  trusted: trustedWorkspace,
4352
4605
  emit: deps.fsAuditEmit,
4353
4606
  pathLocks: sharedPathLocks,
4607
+ generationGuard: primaryGenerationGuard,
4354
4608
  ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4355
4609
  });
4356
4610
  const channelFactory = runtime.createSpawnChannelFactory({
4611
+ processRegistry,
4357
4612
  sourceEnv: runtimeEffectiveEnv,
4358
4613
  onDiagnosticLine: diagnosticSink,
4359
4614
  pipeHooks: {
@@ -4371,9 +4626,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4371
4626
  env: runtimeEffectiveEnv
4372
4627
  });
4373
4628
  const workspaceProvidersStatusProvider = runtime.createWorkspaceProvidersStatusProvider({
4374
- env: runtimeEffectiveEnv
4629
+ env: runtimeEffectiveEnv,
4630
+ workspaceTrusted: trustedWorkspace
4631
+ });
4632
+ const workspaceSkillsStatusProvider = runtime.createWorkspaceSkillsStatusProvider({
4633
+ workspaceTrusted: trustedWorkspace
4375
4634
  });
4376
- const workspaceSkillsStatusProvider = runtime.createWorkspaceSkillsStatusProvider();
4377
4635
  const clientMcpSenderRegistry = new ClientMcpSenderRegistry();
4378
4636
  const runtimeBridges = [];
4379
4637
  const totalSessionAdmission = runtime.createTotalSessionAdmissionController(
@@ -4383,84 +4641,108 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4383
4641
  }
4384
4642
  );
4385
4643
  const sessionOwnerIndex = runtime.createWorkspaceSessionOwnerIndex();
4386
- const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled) => withSettingsLock(workspace, async () => {
4387
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4644
+ const workspaceRegistryForPersistence = { current: void 0 };
4645
+ const isWorkspaceTrustedForPersistence = /* @__PURE__ */ __name((workspace) => workspaceRegistryForPersistence.current?.getByWorkspaceCwd(workspace)?.trusted ?? (workspaceRegistryForPersistence.current === void 0 && workspace === boundWorkspace && trustedWorkspace), "isWorkspaceTrustedForPersistence");
4646
+ const loadSettingsForPersistence = /* @__PURE__ */ __name((workspace) => {
4647
+ const trusted = isWorkspaceTrustedForPersistence(workspace);
4648
+ return settingsRuntime.settings.loadSettings(workspace, {
4649
+ skipLoadEnvironment: true,
4650
+ skipWorkspaceSettings: !trusted,
4651
+ workspaceTrusted: trusted
4652
+ });
4653
+ }, "loadSettingsForPersistence");
4654
+ const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4655
+ assertGenerationOpen?.();
4656
+ const fresh = loadSettingsForPersistence(workspace);
4388
4657
  const wsScope = fresh.forScope(WORKSPACE_SETTING_SCOPE).settings;
4389
4658
  const wsDisabled = wsScope.tools?.disabled;
4390
4659
  const current = Array.isArray(wsDisabled) ? wsDisabled.filter((v) => typeof v === "string") : [];
4391
4660
  const next = new Set(current);
4392
4661
  if (enabled) next.delete(toolName);
4393
4662
  else next.add(toolName);
4663
+ assertGenerationOpen?.();
4394
4664
  fresh.setValue(
4395
4665
  WORKSPACE_SETTING_SCOPE,
4396
4666
  "tools.disabled",
4397
- [...next].sort()
4667
+ [...next].sort(),
4668
+ assertGenerationOpen
4398
4669
  );
4399
4670
  }), "persistDisabledToolsFn");
4400
- const persistDisabledSkillsFn = /* @__PURE__ */ __name((workspace, skillName, enabled) => withSettingsLock(workspace, async () => {
4401
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4671
+ const persistDisabledSkillsFn = /* @__PURE__ */ __name((workspace, skillName, enabled, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4672
+ assertGenerationOpen?.();
4673
+ const {
4674
+ resolveSkillSettings,
4675
+ skillSettingStrings,
4676
+ updateWorkspaceSkillSettingLists
4677
+ } = await import("./skill-settings-XVPCPW5K.js");
4678
+ const fresh = loadSettingsForPersistence(workspace);
4402
4679
  const normalizedName = skillName.trim().toLowerCase();
4403
- const disabledNames = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.filter(
4404
- (entry) => typeof entry === "string"
4405
- ) : [], "disabledNames");
4406
- const lockedScopes = [
4407
- ["system", fresh.system.settings.skills?.disabled],
4408
- ["user", fresh.user.settings.skills?.disabled],
4409
- ["systemDefaults", fresh.systemDefaults.settings.skills?.disabled]
4410
- ];
4411
- for (const [scope, names] of lockedScopes) {
4412
- if (disabledNames(names).some(
4413
- (name) => name.trim().toLowerCase() === normalizedName
4414
- )) {
4415
- throw new runtime.WorkspaceSkillNotToggleableError(
4416
- skillName,
4417
- "locked",
4418
- scope
4419
- );
4420
- }
4680
+ const resolved = resolveSkillSettings(fresh);
4681
+ const disablement = resolved.disablements.get(normalizedName);
4682
+ if (disablement?.reason === "hard" && disablement.lockedScope) {
4683
+ throw new runtime.WorkspaceSkillNotToggleableError(
4684
+ skillName,
4685
+ "locked",
4686
+ disablement.lockedScope
4687
+ );
4421
4688
  }
4422
- const workspaceDisabled = disabledNames(
4423
- fresh.workspace.settings.skills?.disabled
4689
+ const workspaceDisabled = skillSettingStrings(
4690
+ fresh,
4691
+ WORKSPACE_SETTING_SCOPE,
4692
+ "disabled"
4424
4693
  );
4425
- const next = [];
4426
- let found = false;
4427
- let changed = false;
4428
- for (const name of workspaceDisabled) {
4429
- if (name.trim().toLowerCase() !== normalizedName) {
4430
- next.push(name);
4431
- continue;
4432
- }
4433
- if (enabled) {
4434
- changed = true;
4435
- continue;
4436
- }
4437
- if (!found) {
4438
- next.push(skillName);
4439
- found = true;
4440
- if (name !== skillName) changed = true;
4441
- } else {
4442
- changed = true;
4443
- }
4694
+ const workspaceEnabled = skillSettingStrings(
4695
+ fresh,
4696
+ WORKSPACE_SETTING_SCOPE,
4697
+ "enabled"
4698
+ );
4699
+ const next = updateWorkspaceSkillSettingLists(
4700
+ { disabled: workspaceDisabled, enabled: workspaceEnabled },
4701
+ skillName,
4702
+ enabled,
4703
+ resolved.defaultDisabledNames.has(normalizedName) && !resolved.enabledNames.has(normalizedName)
4704
+ );
4705
+ const settingsChanges = [];
4706
+ if (JSON.stringify(next.disabled) !== JSON.stringify(workspaceDisabled)) {
4707
+ settingsChanges.push({
4708
+ key: "skills.disabled",
4709
+ value: next.disabled.length > 0 ? next.disabled : void 0
4710
+ });
4444
4711
  }
4445
- if (!enabled && !found) {
4446
- next.push(skillName);
4447
- changed = true;
4712
+ if (JSON.stringify(next.enabled) !== JSON.stringify(workspaceEnabled)) {
4713
+ settingsChanges.push({
4714
+ key: "skills.enabled",
4715
+ value: next.enabled.length > 0 ? next.enabled : void 0
4716
+ });
4448
4717
  }
4449
- if (!changed) return { changed: false, disabled: workspaceDisabled };
4450
- fresh.setValue(
4451
- WORKSPACE_SETTING_SCOPE,
4452
- "skills.disabled",
4453
- next.length > 0 ? next : void 0
4718
+ if (settingsChanges.length === 0) {
4719
+ return { changed: false, disabled: workspaceDisabled };
4720
+ }
4721
+ assertGenerationOpen?.();
4722
+ fresh.setValues(
4723
+ settingsChanges.map((change) => ({
4724
+ scope: WORKSPACE_SETTING_SCOPE,
4725
+ ...change
4726
+ })),
4727
+ void 0,
4728
+ assertGenerationOpen
4454
4729
  );
4455
- return { changed: true, disabled: next };
4730
+ return {
4731
+ changed: true,
4732
+ disabled: next.disabled,
4733
+ settingsChanges
4734
+ };
4456
4735
  }), "persistDisabledSkillsFn");
4457
- const persistSettingFn = /* @__PURE__ */ __name((workspace, scope, key, value) => withSettingsLock(workspace, async () => {
4458
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4459
- fresh.setValue(scope, key, value);
4736
+ const persistSettingFn = /* @__PURE__ */ __name((workspace, scope, key, value, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4737
+ assertGenerationOpen?.();
4738
+ const fresh = loadSettingsForPersistence(workspace);
4739
+ assertGenerationOpen?.();
4740
+ fresh.setValue(scope, key, value, assertGenerationOpen);
4460
4741
  return fresh;
4461
4742
  }), "persistSettingFn");
4462
- const persistSettingsFn = /* @__PURE__ */ __name((workspace, writes) => withSettingsLock(workspace, async () => {
4463
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4743
+ const persistSettingsFn = /* @__PURE__ */ __name((workspace, writes, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4744
+ assertGenerationOpen?.();
4745
+ const fresh = loadSettingsForPersistence(workspace);
4464
4746
  const writesByScope = /* @__PURE__ */ new Map();
4465
4747
  for (const write of writes) {
4466
4748
  writesByScope.set(
@@ -4471,10 +4753,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4471
4753
  const committedScopes = /* @__PURE__ */ new Set();
4472
4754
  let committed = 0;
4473
4755
  try {
4474
- fresh.setValues(writes, (scope) => {
4475
- committedScopes.add(scope);
4476
- committed += writesByScope.get(scope) ?? 0;
4477
- });
4756
+ assertGenerationOpen?.();
4757
+ fresh.setValues(
4758
+ writes,
4759
+ (scope) => {
4760
+ committedScopes.add(scope);
4761
+ committed += writesByScope.get(scope) ?? 0;
4762
+ },
4763
+ assertGenerationOpen
4764
+ );
4478
4765
  } catch (err) {
4479
4766
  const failedWrite = writes.find((write) => !committedScopes.has(write.scope)) ?? writes[committed];
4480
4767
  const message = `persistSettings partial failure (workspace=${workspace}, committed=${committed}/${writes.length}, failedKey=${failedWrite?.key ?? "<unknown>"}, failedScope=${failedWrite?.scope ?? "<unknown>"}): ${err instanceof Error ? err.message : String(err)}`;
@@ -4486,7 +4773,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4486
4773
  );
4487
4774
  }
4488
4775
  }), "persistSettingsFn");
4489
- const { createSubSessionLauncher } = await import("./create-sub-session-7543K2QA.js");
4776
+ const { createSubSessionLauncher } = await import("./create-sub-session-XHSCDYFU.js");
4490
4777
  const subSessionLauncher = createSubSessionLauncher({
4491
4778
  getBridge: /* @__PURE__ */ __name(() => bridgeRef, "getBridge"),
4492
4779
  boundWorkspace
@@ -4505,10 +4792,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4505
4792
  ),
4506
4793
  maxSessions: opts.maxSessions,
4507
4794
  freshSessionAdmission: totalSessionAdmission.admit,
4508
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
4795
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
4796
+ if (event.type === "registered" && primaryGenerationGuard.closed) {
4797
+ return;
4798
+ }
4799
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
4800
+ }, "sessionLifecycle"),
4509
4801
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
4510
4802
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
4511
4803
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
4804
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
4805
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
4512
4806
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
4513
4807
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
4514
4808
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -4526,8 +4820,23 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4526
4820
  statusProvider,
4527
4821
  fileSystem: createBridgeFileSystemAdapter(fsFactory),
4528
4822
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
4529
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4530
- fresh.setValue(WORKSPACE_SETTING_SCOPE, "tools.approvalMode", mode);
4823
+ primaryGenerationGuard.assertOpen();
4824
+ if (!trustedWorkspace) {
4825
+ throw new Error(
4826
+ "Cannot persist approval mode for an untrusted workspace."
4827
+ );
4828
+ }
4829
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
4830
+ skipLoadEnvironment: true,
4831
+ workspaceTrusted: trustedWorkspace
4832
+ });
4833
+ primaryGenerationGuard.assertOpen();
4834
+ fresh.setValue(
4835
+ WORKSPACE_SETTING_SCOPE,
4836
+ "tools.approvalMode",
4837
+ mode,
4838
+ () => primaryGenerationGuard.assertOpen()
4839
+ );
4531
4840
  }), "persistApprovalMode")
4532
4841
  });
4533
4842
  if (!deps.bridge) {
@@ -4539,6 +4848,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4539
4848
  }, "invalidatePrimaryServeFeaturesCache");
4540
4849
  const workspaceService = runtime.createDaemonWorkspaceService({
4541
4850
  boundWorkspace,
4851
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => trustedWorkspace, "isWorkspaceTrusted"),
4852
+ assertGenerationOpen: /* @__PURE__ */ __name(() => primaryGenerationGuard.assertOpen(), "assertGenerationOpen"),
4542
4853
  contextFilename: contextFilenameForInit ?? "QWEN.md",
4543
4854
  statusProvider,
4544
4855
  workspaceProvidersStatusProvider,
@@ -4551,13 +4862,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4551
4862
  persistSetting: persistSettingFn,
4552
4863
  persistSettings: persistSettingsFn,
4553
4864
  preheatAcpChild: /* @__PURE__ */ __name(() => bridge.preheat(), "preheatAcpChild"),
4554
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
4865
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4866
+ assertGenerationOpen?.();
4555
4867
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
4556
- skipLoadEnvironment: true
4868
+ skipLoadEnvironment: true,
4869
+ skipWorkspaceSettings: !trustedWorkspace,
4870
+ workspaceTrusted: trustedWorkspace
4557
4871
  });
4872
+ assertGenerationOpen?.();
4558
4873
  const result = settingsRuntime.settings.reloadEnvironment(
4559
4874
  fresh.merged,
4560
- workspace
4875
+ workspace,
4876
+ trustedWorkspace
4561
4877
  );
4562
4878
  let refreshedRuntimeEnv;
4563
4879
  let fallbackReason;
@@ -4565,7 +4881,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4565
4881
  refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
4566
4882
  fresh.merged,
4567
4883
  workspace,
4568
- daemonRuntimeBaseEnv
4884
+ daemonRuntimeBaseEnv,
4885
+ trustedWorkspace
4569
4886
  );
4570
4887
  } catch (err) {
4571
4888
  fallbackReason = err instanceof Error ? err.message : String(err);
@@ -4624,6 +4941,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4624
4941
  {
4625
4942
  workspaceId: daemonWorkspaceHash,
4626
4943
  workspaceCwd: boundWorkspace,
4944
+ sessionRuntimeBaseDir: primarySessionRuntimeBaseDir,
4627
4945
  ...workspaceInputs[0]?.displayName ? { displayName: workspaceInputs[0].displayName } : {},
4628
4946
  primary: true,
4629
4947
  trusted: trustedWorkspace,
@@ -4633,14 +4951,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4633
4951
  bridge,
4634
4952
  workspaceService,
4635
4953
  routeFileSystemFactory: routeFsFactory,
4636
- clientMcpSenderRegistry
4954
+ clientMcpSenderRegistry,
4955
+ generationGuard: primaryGenerationGuard,
4956
+ trustMaterialization: primaryTrustMaterialization
4637
4957
  }
4638
4958
  ];
4639
- const createRuntimeEnvMetadata = /* @__PURE__ */ __name((workspace, settings) => {
4959
+ const createRuntimeEnvMetadata = /* @__PURE__ */ __name((workspace, settings, trusted) => {
4640
4960
  const snapshot = settings ? settingsRuntime.environment.buildRuntimeEnvironment(
4641
4961
  settings.merged,
4642
4962
  workspace,
4643
- daemonRuntimeBaseEnv
4963
+ daemonRuntimeBaseEnv,
4964
+ trusted
4644
4965
  ) : {
4645
4966
  effectiveEnv: { ...daemonRuntimeBaseEnv },
4646
4967
  overlayKeys: Object.freeze([]),
@@ -4649,7 +4970,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4649
4970
  envFileReadFailures: Object.freeze([])
4650
4971
  };
4651
4972
  logRuntimeEnvFileReadFailures(workspace, snapshot);
4652
- const effectiveEnv = { ...snapshot.effectiveEnv };
4973
+ const sessionRuntimeBaseDir = resolveSessionRuntimeBaseDir(
4974
+ workspace,
4975
+ settings,
4976
+ snapshot.effectiveEnv
4977
+ );
4978
+ const effectiveEnv = {
4979
+ ...snapshot.effectiveEnv,
4980
+ QWEN_RUNTIME_DIR: sessionRuntimeBaseDir
4981
+ };
4653
4982
  const metadata = {
4654
4983
  mode: "runtime-overlay",
4655
4984
  overlayKeys: [...snapshot.overlayKeys],
@@ -4661,36 +4990,44 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4661
4990
  return {
4662
4991
  metadata,
4663
4992
  effectiveEnv,
4993
+ sessionRuntimeBaseDir,
4664
4994
  replace(nextEnv) {
4665
4995
  for (const key of Object.keys(effectiveEnv)) {
4666
4996
  delete effectiveEnv[key];
4667
4997
  }
4668
4998
  Object.assign(effectiveEnv, nextEnv);
4999
+ effectiveEnv["QWEN_RUNTIME_DIR"] = sessionRuntimeBaseDir;
4669
5000
  }
4670
5001
  };
4671
5002
  }, "createRuntimeEnvMetadata");
4672
5003
  const subSessionStoppers = [];
4673
- const subSessionStoppersByWorkspace = /* @__PURE__ */ new Map();
5004
+ const subSessionStoppersByRuntime = /* @__PURE__ */ new WeakMap();
4674
5005
  const runtimeCleanupPromises = /* @__PURE__ */ new WeakMap();
4675
5006
  const removeArrayValue = /* @__PURE__ */ __name((values, value) => {
4676
5007
  const index = values.indexOf(value);
4677
5008
  if (index >= 0) values.splice(index, 1);
4678
5009
  }, "removeArrayValue");
4679
5010
  for (const workspaceInput of workspaceInputs.slice(1)) {
5011
+ const secondaryDecision = trustPolicy.evaluateDaemonWorkspaceTrust(
5012
+ bootTrustSnapshot,
5013
+ workspaceInput.cwd
5014
+ );
5015
+ const secondaryTrusted = secondaryDecision.targetTrusted;
4680
5016
  let secondarySettings;
4681
5017
  try {
4682
5018
  secondarySettings = settingsRuntime.settings.loadSettings(
4683
- workspaceInput.cwd
5019
+ workspaceInput.cwd,
5020
+ {
5021
+ skipLoadEnvironment: true,
5022
+ skipWorkspaceSettings: !secondaryTrusted,
5023
+ workspaceTrusted: secondaryTrusted
5024
+ }
4684
5025
  );
4685
5026
  } catch (err) {
4686
5027
  writeStderrLine(
4687
5028
  `qwen serve: could not read full settings for secondary workspace ${workspaceInput.cwd} (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4688
5029
  );
4689
5030
  }
4690
- const secondaryTrusted = secondarySettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4691
- secondarySettings.merged,
4692
- workspaceInput.cwd
4693
- ).effective.state === "trusted" : false;
4694
5031
  if (!secondaryTrusted) {
4695
5032
  daemonLog.warn("secondary workspace is not trusted", {
4696
5033
  workspace: workspaceInput.cwd,
@@ -4699,11 +5036,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4699
5036
  }
4700
5037
  const secondaryEnv = createRuntimeEnvMetadata(
4701
5038
  workspaceInput.cwd,
4702
- secondarySettings
5039
+ secondarySettings,
5040
+ secondaryTrusted
4703
5041
  );
5042
+ const secondaryCustomIgnoreFiles = secondarySettings?.merged.context?.fileFiltering?.customIgnoreFiles;
5043
+ const secondaryContextFilename = extractContextFilename(secondarySettings?.merged.context?.fileName) ?? contextFilenameForInit ?? "QWEN.md";
4704
5044
  const secondaryWorkspaceHash = core.hashDaemonWorkspace(
4705
5045
  workspaceInput.cwd
4706
5046
  );
5047
+ const secondaryGenerationGuard = runtime.createWorkspaceGenerationGuard();
4707
5048
  const secondaryStatusProvider = runtime.createDaemonStatusProvider({
4708
5049
  env: secondaryEnv.effectiveEnv
4709
5050
  });
@@ -4712,9 +5053,11 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4712
5053
  trusted: secondaryTrusted,
4713
5054
  emit: deps.fsAuditEmit,
4714
5055
  pathLocks: sharedPathLocks,
4715
- ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
5056
+ generationGuard: secondaryGenerationGuard,
5057
+ ...secondaryCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: secondaryCustomIgnoreFiles } : {}
4716
5058
  });
4717
5059
  const secondaryChannelFactory = runtime.createSpawnChannelFactory({
5060
+ processRegistry,
4718
5061
  sourceEnv: secondaryEnv.effectiveEnv,
4719
5062
  onDiagnosticLine: diagnosticSink,
4720
5063
  pipeHooks: {
@@ -4746,10 +5089,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4746
5089
  ),
4747
5090
  maxSessions: opts.maxSessions,
4748
5091
  freshSessionAdmission: totalSessionAdmission.admit,
4749
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
5092
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
5093
+ if (event.type === "registered" && secondaryGenerationGuard.closed) {
5094
+ return;
5095
+ }
5096
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
5097
+ }, "sessionLifecycle"),
4750
5098
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
4751
5099
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
4752
5100
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
5101
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
5102
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
4753
5103
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
4754
5104
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
4755
5105
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -4769,26 +5119,42 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4769
5119
  statusProvider: secondaryStatusProvider,
4770
5120
  fileSystem: createBridgeFileSystemAdapter(secondaryBridgeFsFactory),
4771
5121
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
4772
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4773
- fresh.setValue(WORKSPACE_SETTING_SCOPE, "tools.approvalMode", mode);
5122
+ secondaryGenerationGuard.assertOpen();
5123
+ if (!secondaryTrusted) {
5124
+ throw new Error(
5125
+ "Cannot persist approval mode for an untrusted workspace."
5126
+ );
5127
+ }
5128
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
5129
+ skipLoadEnvironment: true,
5130
+ workspaceTrusted: secondaryTrusted
5131
+ });
5132
+ secondaryGenerationGuard.assertOpen();
5133
+ fresh.setValue(
5134
+ WORKSPACE_SETTING_SCOPE,
5135
+ "tools.approvalMode",
5136
+ mode,
5137
+ () => secondaryGenerationGuard.assertOpen()
5138
+ );
4774
5139
  }), "persistApprovalMode")
4775
5140
  });
4776
5141
  secondaryBridgeRef = secondaryBridge;
4777
5142
  runtimeBridges.push(secondaryBridge);
4778
5143
  internalRuntimeBridgesForCleanup.push(secondaryBridge);
4779
5144
  subSessionStoppers.push(secondarySubSessionLauncher.stop);
4780
- subSessionStoppersByWorkspace.set(
4781
- workspaceInput.cwd,
4782
- secondarySubSessionLauncher.stop
4783
- );
4784
5145
  const secondaryWorkspaceService = runtime.createDaemonWorkspaceService({
4785
5146
  boundWorkspace: workspaceInput.cwd,
4786
- contextFilename: contextFilenameForInit ?? "QWEN.md",
5147
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => secondaryTrusted, "isWorkspaceTrusted"),
5148
+ assertGenerationOpen: /* @__PURE__ */ __name(() => secondaryGenerationGuard.assertOpen(), "assertGenerationOpen"),
5149
+ contextFilename: secondaryContextFilename,
4787
5150
  statusProvider: secondaryStatusProvider,
4788
5151
  workspaceProvidersStatusProvider: runtime.createWorkspaceProvidersStatusProvider({
4789
- env: secondaryEnv.effectiveEnv
5152
+ env: secondaryEnv.effectiveEnv,
5153
+ workspaceTrusted: secondaryTrusted
5154
+ }),
5155
+ workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider({
5156
+ workspaceTrusted: secondaryTrusted
4790
5157
  }),
4791
- workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider(),
4792
5158
  skillInstallEnv: secondaryEnv.effectiveEnv,
4793
5159
  voiceEnv: secondaryEnv.effectiveEnv,
4794
5160
  voiceSettingsScope: WORKSPACE_SETTING_SCOPE,
@@ -4798,19 +5164,25 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4798
5164
  persistDisabledSkills: persistDisabledSkillsFn,
4799
5165
  persistSetting: persistSettingFn,
4800
5166
  persistSettings: persistSettingsFn,
4801
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
5167
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
5168
+ assertGenerationOpen?.();
4802
5169
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
4803
- skipLoadEnvironment: true
5170
+ skipLoadEnvironment: true,
5171
+ skipWorkspaceSettings: !secondaryTrusted,
5172
+ workspaceTrusted: secondaryTrusted
4804
5173
  });
5174
+ assertGenerationOpen?.();
4805
5175
  const result = settingsRuntime.settings.reloadEnvironment(
4806
5176
  fresh.merged,
4807
- workspace
5177
+ workspace,
5178
+ secondaryTrusted
4808
5179
  );
4809
5180
  try {
4810
5181
  const refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
4811
5182
  fresh.merged,
4812
5183
  workspace,
4813
- daemonRuntimeBaseEnv
5184
+ daemonRuntimeBaseEnv,
5185
+ secondaryTrusted
4814
5186
  );
4815
5187
  logRuntimeEnvFileReadFailures(workspace, refreshedRuntimeEnv);
4816
5188
  secondaryEnv.replace(refreshedRuntimeEnv.effectiveEnv);
@@ -4848,9 +5220,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4848
5220
  refreshExtensionsForAllSessions: /* @__PURE__ */ __name(() => secondaryBridge.refreshExtensionsForAllSessions(), "refreshExtensionsForAllSessions"),
4849
5221
  publishWorkspaceEvent: /* @__PURE__ */ __name((event) => secondaryBridge.publishWorkspaceEvent(event), "publishWorkspaceEvent")
4850
5222
  });
4851
- workspaceRuntimes.push({
5223
+ const secondaryRuntime = {
4852
5224
  workspaceId: secondaryWorkspaceHash,
4853
5225
  workspaceCwd: workspaceInput.cwd,
5226
+ sessionRuntimeBaseDir: secondaryEnv.sessionRuntimeBaseDir,
4854
5227
  ...workspaceInput.displayName ? { displayName: workspaceInput.displayName } : {},
4855
5228
  primary: false,
4856
5229
  trusted: secondaryTrusted,
@@ -4860,12 +5233,24 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4860
5233
  bridge: secondaryBridge,
4861
5234
  workspaceService: secondaryWorkspaceService,
4862
5235
  routeFileSystemFactory: secondaryBridgeFsFactory,
4863
- clientMcpSenderRegistry: secondaryClientMcpSenderRegistry
4864
- });
5236
+ clientMcpSenderRegistry: secondaryClientMcpSenderRegistry,
5237
+ generationGuard: secondaryGenerationGuard,
5238
+ trustMaterialization: JSON.stringify({
5239
+ trusted: secondaryTrusted,
5240
+ boundWorkspaces: [workspaceInput.cwd]
5241
+ })
5242
+ };
5243
+ subSessionStoppersByRuntime.set(
5244
+ secondaryRuntime,
5245
+ secondarySubSessionLauncher.stop
5246
+ );
5247
+ workspaceRuntimes.push(secondaryRuntime);
4865
5248
  }
4866
5249
  const workspaceRegistry = runtime.createWorkspaceRegistry(workspaceRuntimes, {
4867
- sessionOwnerIndex
5250
+ sessionOwnerIndex,
5251
+ scanUnindexedOwners: deps.bridge !== void 0
4868
5252
  });
5253
+ workspaceRegistryForPersistence.current = workspaceRegistry;
4869
5254
  const workspaceVoiceCoordinator = new WorkspaceVoiceCoordinator();
4870
5255
  core.registerDaemonGaugeCallbacks({
4871
5256
  sessionCount: /* @__PURE__ */ __name(() => workspaceRegistry.list().reduce((sum, item) => sum + item.bridge.sessionCount, 0), "sessionCount"),
@@ -4900,9 +5285,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4900
5285
  const rejectedTotal = hits ? hits.prompt + hits.mutation + hits.read : 0;
4901
5286
  const rateLimitRejected = prevRateRejected === void 0 ? 0 : Math.max(0, rejectedTotal - prevRateRejected);
4902
5287
  prevRateRejected = rejectedTotal;
4903
- const child = bridge.getChildResourceSnapshot?.();
5288
+ const primaryEntry = workspaceRegistry.primaryEntry;
5289
+ const primaryRuntimeBridge = primaryEntry.state === "active" ? primaryEntry.current?.runtime.bridge : void 0;
5290
+ const child = primaryRuntimeBridge?.getChildResourceSnapshot?.();
4904
5291
  if (runtime.getActiveSseCount() > 0 || (acp?.wsStreams ?? 0) > 0) {
4905
- void bridge.refreshChildResource?.();
5292
+ void primaryRuntimeBridge?.refreshChildResource?.().catch((err) => {
5293
+ daemonLog.warn(
5294
+ `ACP child resource refresh failed: ${err instanceof Error ? err.message : String(err)}`
5295
+ );
5296
+ });
4906
5297
  }
4907
5298
  metricsRing.sample(nowMs, {
4908
5299
  cpuPercent,
@@ -4958,34 +5349,52 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4958
5349
  metricsLoopDelay.disable();
4959
5350
  }
4960
5351
  };
4961
- const createDynamicWorkspaceRuntime = /* @__PURE__ */ __name(async (cwd, options) => {
4962
- if (options.provenance === "managed-scratch" && (!managedScratchRoot || !isManagedScratchChild(cwd, managedScratchRoot.canonicalRoot))) {
5352
+ const createDynamicWorkspaceRuntime = /* @__PURE__ */ __name(async (cwd, buildOptions) => {
5353
+ const provenance = buildOptions?.provenance ?? "existing";
5354
+ if (provenance === "managed-scratch" && (!managedScratchRoot || !isManagedScratchChild(cwd, managedScratchRoot.canonicalRoot))) {
4963
5355
  throw new Error(
4964
5356
  "Managed scratch runtime must use an accepted direct child directory"
4965
5357
  );
4966
5358
  }
5359
+ const snapshot = buildOptions?.snapshot ?? await trustPolicy.readDaemonTrustPolicySnapshot();
5360
+ const decision = buildOptions?.decision ?? trustPolicy.evaluateDaemonWorkspaceTrust(snapshot, cwd);
5361
+ const trusted = provenance === "managed-scratch" ? true : buildOptions?.trusted ?? decision.targetTrusted;
4967
5362
  let wsSettings;
4968
5363
  try {
4969
- wsSettings = settingsRuntime.settings.loadSettings(cwd);
5364
+ wsSettings = settingsRuntime.settings.loadSettings(cwd, {
5365
+ skipLoadEnvironment: true,
5366
+ skipWorkspaceSettings: !trusted,
5367
+ workspaceTrusted: trusted
5368
+ });
4970
5369
  } catch (err) {
4971
5370
  writeStderrLine(
4972
5371
  `qwen serve: could not read full settings for dynamic workspace ${cwd} (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4973
5372
  );
4974
5373
  }
4975
- const trusted = options.provenance === "managed-scratch" || (wsSettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4976
- wsSettings.merged,
4977
- cwd
4978
- ).effective.state === "trusted" : false);
4979
- const wsEnv = createRuntimeEnvMetadata(cwd, wsSettings);
5374
+ const wsEnv = createRuntimeEnvMetadata(cwd, wsSettings, trusted);
5375
+ const wsCustomIgnoreFiles = wsSettings?.merged.context?.fileFiltering?.customIgnoreFiles;
5376
+ const wsContextFilename = extractContextFilename(wsSettings?.merged.context?.fileName) ?? contextFilenameForInit ?? "QWEN.md";
4980
5377
  const wsHash = core.hashDaemonWorkspace(cwd);
5378
+ const generationGuard = buildOptions?.generationGuard ?? runtime.createWorkspaceGenerationGuard();
5379
+ const runtimeBoundWorkspaces = buildOptions?.boundWorkspaces ?? [cwd];
4981
5380
  const wsFsFactory = runtime.resolveBridgeFsFactory({
4982
- boundWorkspaces: [cwd],
5381
+ boundWorkspaces: runtimeBoundWorkspaces,
4983
5382
  trusted,
4984
5383
  emit: deps.fsAuditEmit,
4985
5384
  pathLocks: sharedPathLocks,
4986
- ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
5385
+ generationGuard,
5386
+ ...wsCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: wsCustomIgnoreFiles } : {}
4987
5387
  });
5388
+ const wsRouteFsFactory = buildOptions?.primary === true && runtimeBoundWorkspaces.length > 1 ? runtime.resolveBridgeFsFactory({
5389
+ boundWorkspaces: [cwd],
5390
+ trusted,
5391
+ emit: deps.fsAuditEmit,
5392
+ pathLocks: sharedPathLocks,
5393
+ generationGuard,
5394
+ ...wsCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: wsCustomIgnoreFiles } : {}
5395
+ }) : wsFsFactory;
4988
5396
  const wsChannelFactory = runtime.createSpawnChannelFactory({
5397
+ processRegistry,
4989
5398
  sourceEnv: wsEnv.effectiveEnv,
4990
5399
  onDiagnosticLine: diagnosticSink,
4991
5400
  pipeHooks: {
@@ -5019,10 +5428,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5019
5428
  ),
5020
5429
  maxSessions: opts.maxSessions,
5021
5430
  freshSessionAdmission: totalSessionAdmission.admit,
5022
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
5431
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
5432
+ if (event.type === "registered" && generationGuard.closed) return;
5433
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
5434
+ }, "sessionLifecycle"),
5023
5435
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
5024
5436
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
5025
5437
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
5438
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
5439
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
5026
5440
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
5027
5441
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
5028
5442
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -5035,18 +5449,31 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5035
5449
  onDiagnosticLine: diagnosticSink,
5036
5450
  telemetry: createRuntimeBridgeTelemetry(wsHash),
5037
5451
  ...permissionPolicy !== void 0 ? { permissionPolicy } : {},
5038
- ...permissionConsensusQuorum !== void 0 ? { permissionConsensusQuorum } : {},
5452
+ ...permissionConsensusQuorum !== void 0 ? {
5453
+ permissionConsensusQuorum
5454
+ } : {},
5039
5455
  permissionAudit: permissionAuditPublisher,
5040
5456
  statusProvider: runtime.createDaemonStatusProvider({
5041
5457
  env: wsEnv.effectiveEnv
5042
5458
  }),
5043
5459
  fileSystem: createBridgeFileSystemAdapter(wsFsFactory),
5044
5460
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
5045
- const fresh = settingsRuntime.settings.loadSettings(workspace);
5461
+ generationGuard.assertOpen();
5462
+ if (!trusted) {
5463
+ throw new Error(
5464
+ "Cannot persist approval mode for an untrusted workspace."
5465
+ );
5466
+ }
5467
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
5468
+ skipLoadEnvironment: true,
5469
+ workspaceTrusted: trusted
5470
+ });
5471
+ generationGuard.assertOpen();
5046
5472
  fresh.setValue(
5047
5473
  WORKSPACE_SETTING_SCOPE,
5048
5474
  "tools.approvalMode",
5049
- mode
5475
+ mode,
5476
+ () => generationGuard.assertOpen()
5050
5477
  );
5051
5478
  }), "persistApprovalMode")
5052
5479
  });
@@ -5059,36 +5486,47 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5059
5486
  try {
5060
5487
  wsService = runtime.createDaemonWorkspaceService({
5061
5488
  boundWorkspace: cwd,
5062
- contextFilename: contextFilenameForInit ?? "QWEN.md",
5489
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => trusted, "isWorkspaceTrusted"),
5490
+ assertGenerationOpen: /* @__PURE__ */ __name(() => generationGuard.assertOpen(), "assertGenerationOpen"),
5491
+ contextFilename: wsContextFilename,
5063
5492
  statusProvider: runtime.createDaemonStatusProvider({
5064
5493
  env: wsEnv.effectiveEnv
5065
5494
  }),
5066
5495
  workspaceProvidersStatusProvider: runtime.createWorkspaceProvidersStatusProvider({
5067
- env: wsEnv.effectiveEnv
5496
+ env: wsEnv.effectiveEnv,
5497
+ workspaceTrusted: trusted
5498
+ }),
5499
+ workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider({
5500
+ workspaceTrusted: trusted
5068
5501
  }),
5069
- workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider(),
5070
5502
  skillInstallEnv: wsEnv.effectiveEnv,
5071
5503
  voiceEnv: wsEnv.effectiveEnv,
5072
- voiceSettingsScope: WORKSPACE_SETTING_SCOPE,
5504
+ ...buildOptions?.primary === true ? {} : { voiceSettingsScope: WORKSPACE_SETTING_SCOPE },
5073
5505
  isChannelLive: /* @__PURE__ */ __name(() => wsBridge.isChannelLive(), "isChannelLive"),
5074
5506
  preheatAcpChild: /* @__PURE__ */ __name(() => wsBridge.preheat(), "preheatAcpChild"),
5075
5507
  persistDisabledTools: persistDisabledToolsFn,
5076
5508
  persistDisabledSkills: persistDisabledSkillsFn,
5077
5509
  persistSetting: persistSettingFn,
5078
5510
  persistSettings: persistSettingsFn,
5079
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
5511
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
5512
+ assertGenerationOpen?.();
5080
5513
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
5081
- skipLoadEnvironment: true
5514
+ skipLoadEnvironment: true,
5515
+ skipWorkspaceSettings: !trusted,
5516
+ workspaceTrusted: trusted
5082
5517
  });
5518
+ assertGenerationOpen?.();
5083
5519
  const result = settingsRuntime.settings.reloadEnvironment(
5084
5520
  fresh.merged,
5085
- workspace
5521
+ workspace,
5522
+ trusted
5086
5523
  );
5087
5524
  try {
5088
5525
  const refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
5089
5526
  fresh.merged,
5090
5527
  workspace,
5091
- daemonRuntimeBaseEnv
5528
+ daemonRuntimeBaseEnv,
5529
+ trusted
5092
5530
  );
5093
5531
  logRuntimeEnvFileReadFailures(workspace, refreshedRuntimeEnv);
5094
5532
  wsEnv.replace(refreshedRuntimeEnv.effectiveEnv);
@@ -5124,7 +5562,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5124
5562
  queryWorkspaceStatus: /* @__PURE__ */ __name((method, idle) => wsBridge.queryWorkspaceStatus(method, idle), "queryWorkspaceStatus"),
5125
5563
  invokeWorkspaceCommand: /* @__PURE__ */ __name((method, params, invokeOpts) => wsBridge.invokeWorkspaceCommand(method, params, invokeOpts), "invokeWorkspaceCommand"),
5126
5564
  refreshExtensionsForAllSessions: /* @__PURE__ */ __name(() => wsBridge.refreshExtensionsForAllSessions(), "refreshExtensionsForAllSessions"),
5127
- publishWorkspaceEvent: /* @__PURE__ */ __name((event) => wsBridge.publishWorkspaceEvent(event), "publishWorkspaceEvent")
5565
+ publishWorkspaceEvent: /* @__PURE__ */ __name((event) => {
5566
+ if (buildOptions?.primary === true && (event.type === "settings_changed" || event.type === "settings_reloaded")) {
5567
+ invalidatePrimaryServeFeaturesCache();
5568
+ }
5569
+ wsBridge.publishWorkspaceEvent(event);
5570
+ }, "publishWorkspaceEvent")
5128
5571
  });
5129
5572
  } catch (err) {
5130
5573
  wsSubSessionLauncher.stop();
@@ -5139,31 +5582,76 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5139
5582
  runtimeBridges.push(wsBridge);
5140
5583
  internalRuntimeBridgesForCleanup.push(wsBridge);
5141
5584
  subSessionStoppers.push(wsSubSessionLauncher.stop);
5142
- subSessionStoppersByWorkspace.set(cwd, wsSubSessionLauncher.stop);
5143
- return {
5585
+ const wsRuntime = {
5144
5586
  workspaceId: wsHash,
5145
5587
  workspaceCwd: cwd,
5146
- primary: false,
5588
+ sessionRuntimeBaseDir: wsEnv.sessionRuntimeBaseDir,
5589
+ ...buildOptions?.displayName !== void 0 ? { displayName: buildOptions.displayName } : {},
5590
+ primary: buildOptions?.primary ?? false,
5147
5591
  trusted,
5148
- removable: true,
5149
- registrationIds: [],
5592
+ provenance,
5593
+ removable: buildOptions?.removable ?? true,
5594
+ registrationIds: [...buildOptions?.registrationIds ?? []],
5150
5595
  env: wsEnv.metadata,
5151
5596
  bridge: wsBridge,
5152
5597
  workspaceService: wsService,
5153
- routeFileSystemFactory: wsFsFactory,
5154
- clientMcpSenderRegistry: wsClientMcpRegistry
5598
+ routeFileSystemFactory: wsRouteFsFactory,
5599
+ clientMcpSenderRegistry: wsClientMcpRegistry,
5600
+ generationGuard,
5601
+ trustMaterialization: buildOptions?.trustMaterialization ?? JSON.stringify({
5602
+ trusted,
5603
+ boundWorkspaces: [...runtimeBoundWorkspaces].sort()
5604
+ })
5155
5605
  };
5606
+ subSessionStoppersByRuntime.set(wsRuntime, wsSubSessionLauncher.stop);
5607
+ if (provenance !== "managed-scratch" && !buildOptions?.snapshot) {
5608
+ const latest = await trustPolicy.readDaemonTrustPolicySnapshot();
5609
+ if (latest.revision !== snapshot.revision) {
5610
+ generationGuard.close();
5611
+ wsSubSessionLauncher.stop();
5612
+ await wsBridge.shutdown({ reason: "trust_reconfigured" }).catch(() => {
5613
+ try {
5614
+ wsBridge.killAllSync();
5615
+ } catch {
5616
+ }
5617
+ });
5618
+ subSessionStoppersByRuntime.delete(wsRuntime);
5619
+ removeArrayValue(subSessionStoppers, wsSubSessionLauncher.stop);
5620
+ removeArrayValue(runtimeBridges, wsBridge);
5621
+ removeArrayValue(internalRuntimeBridgesForCleanup, wsBridge);
5622
+ if ((buildOptions?.validationAttempt ?? 0) >= 2) {
5623
+ throw new Error(
5624
+ "Workspace trust policy kept changing during runtime creation."
5625
+ );
5626
+ }
5627
+ const { generationGuard: _staleGuard, ...retryOptions } = buildOptions ?? {};
5628
+ return createDynamicWorkspaceRuntime(cwd, {
5629
+ ...retryOptions,
5630
+ validationAttempt: (buildOptions?.validationAttempt ?? 0) + 1
5631
+ });
5632
+ }
5633
+ }
5634
+ return wsRuntime;
5156
5635
  }, "createDynamicWorkspaceRuntime");
5636
+ const serveAppForRuntimeLifecycle = { current: void 0 };
5157
5637
  const workspaceRuntimeRemoval = {
5158
5638
  async runtimeAdded(runtimeAdded) {
5159
- const app3 = runtimeApp ?? runtimeAppForCleanup;
5639
+ channelWebhookEnvByWorkspace.set(
5640
+ runtimeAdded.workspaceCwd,
5641
+ workspaceRuntimeEffectiveEnv(runtimeAdded, daemonRuntimeBaseEnv)
5642
+ );
5643
+ channelWebhookConfigVersion += 1;
5644
+ refreshChannelWebhookConfigs?.();
5645
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5160
5646
  const startScheduledTaskKeepaliveForWorkspace = app3?.locals?.["startScheduledTaskKeepaliveForWorkspace"];
5161
5647
  startScheduledTaskKeepaliveForWorkspace?.(runtimeAdded);
5162
5648
  if (!channelWorkerManager) return;
5163
5649
  try {
5164
- await channelWorkerManager.restoreWorkspace(
5165
- runtimeAdded.workspaceCwd
5166
- );
5650
+ if (runtimeAdded.trusted) {
5651
+ await channelWorkerManager.restoreWorkspace(
5652
+ runtimeAdded.workspaceCwd
5653
+ );
5654
+ }
5167
5655
  await channelWorkerManager.refreshWorkspaces();
5168
5656
  } catch (err) {
5169
5657
  daemonLog.error(
@@ -5175,14 +5663,51 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5175
5663
  }
5176
5664
  },
5177
5665
  beginDrain(runtimeToDrain) {
5666
+ if (runtimeToDrain.primary) {
5667
+ if (bridgeRef === runtimeToDrain.bridge) bridgeRef = void 0;
5668
+ invalidatePrimaryServeFeaturesCache();
5669
+ }
5178
5670
  totalSessionAdmission.beginWorkspaceDrain(runtimeToDrain.workspaceCwd);
5179
5671
  channelWorkerManager?.beginWorkspaceDrain(runtimeToDrain.workspaceCwd);
5180
5672
  workspaceVoiceCoordinator.beginWorkspaceDrain(runtimeToDrain);
5673
+ channelWebhookEnvByWorkspace.delete(runtimeToDrain.workspaceCwd);
5674
+ channelWebhookConfigVersion += 1;
5675
+ refreshChannelWebhookConfigs?.();
5676
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5677
+ const stopScheduledTaskKeepaliveForWorkspace = app3?.locals?.["stopScheduledTaskKeepaliveForWorkspace"];
5678
+ try {
5679
+ stopScheduledTaskKeepaliveForWorkspace?.(runtimeToDrain.workspaceCwd);
5680
+ } catch (err) {
5681
+ daemonLog.error(
5682
+ "workspace scheduled-task drain error",
5683
+ err instanceof Error ? err : null
5684
+ );
5685
+ }
5181
5686
  },
5182
5687
  cancelDrain(runtimeToDrain) {
5688
+ if (runtimeToDrain.primary && bridgeRef === void 0) {
5689
+ bridgeRef = runtimeToDrain.bridge;
5690
+ invalidatePrimaryServeFeaturesCache();
5691
+ }
5183
5692
  channelWorkerManager?.cancelWorkspaceDrain(runtimeToDrain.workspaceCwd);
5184
5693
  totalSessionAdmission.cancelWorkspaceDrain(runtimeToDrain.workspaceCwd);
5185
5694
  workspaceVoiceCoordinator.cancelWorkspaceDrain(runtimeToDrain);
5695
+ channelWebhookEnvByWorkspace.set(
5696
+ runtimeToDrain.workspaceCwd,
5697
+ workspaceRuntimeEffectiveEnv(runtimeToDrain, daemonRuntimeBaseEnv)
5698
+ );
5699
+ channelWebhookConfigVersion += 1;
5700
+ refreshChannelWebhookConfigs?.();
5701
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5702
+ const startScheduledTaskKeepaliveForWorkspace = app3?.locals?.["startScheduledTaskKeepaliveForWorkspace"];
5703
+ try {
5704
+ startScheduledTaskKeepaliveForWorkspace?.(runtimeToDrain);
5705
+ } catch (err) {
5706
+ daemonLog.error(
5707
+ "workspace scheduled-task drain rollback error",
5708
+ err instanceof Error ? err : null
5709
+ );
5710
+ }
5186
5711
  },
5187
5712
  completeDrain(runtimeToDrain) {
5188
5713
  totalSessionAdmission.completeWorkspaceDrain(
@@ -5205,18 +5730,29 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5205
5730
  const existing = runtimeCleanupPromises.get(runtimeToDrain);
5206
5731
  if (existing) return existing;
5207
5732
  const cleanup = (async () => {
5208
- await workspaceVoiceCoordinator.disposeRuntime(
5209
- runtimeToDrain,
5210
- reason
5211
- );
5212
- const stopSubSessions = subSessionStoppersByWorkspace.get(
5213
- runtimeToDrain.workspaceCwd
5214
- );
5733
+ const containmentErrors = [];
5734
+ try {
5735
+ await workspaceVoiceCoordinator.disposeRuntime(
5736
+ runtimeToDrain,
5737
+ reason
5738
+ );
5739
+ } catch (err) {
5740
+ daemonLog.error(
5741
+ "workspace voice cleanup error",
5742
+ err instanceof Error ? err : null
5743
+ );
5744
+ }
5745
+ if (reason === "trust_reconfigured" && workspaceVoiceCoordinator.getWorkspaceActivity(runtimeToDrain) > 0) {
5746
+ containmentErrors.push(
5747
+ new Error("Workspace voice sessions are still active.")
5748
+ );
5749
+ }
5750
+ const stopSubSessions = subSessionStoppersByRuntime.get(runtimeToDrain);
5215
5751
  try {
5216
5752
  stopSubSessions?.();
5217
5753
  } catch {
5218
5754
  }
5219
- if (reason === "workspace_removed" && channelWorkerManager) {
5755
+ if (reason !== "daemon_shutdown" && channelWorkerManager) {
5220
5756
  await channelWorkerManager.removeWorkspace(runtimeToDrain.workspaceCwd).catch((err) => {
5221
5757
  daemonLog.error(
5222
5758
  "workspace channel worker cleanup error",
@@ -5237,25 +5773,65 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5237
5773
  );
5238
5774
  }
5239
5775
  writeChannelWorkerPidfile();
5776
+ if (reason === "trust_reconfigured" && channelWorkerManager.workspaceActivity(
5777
+ runtimeToDrain.workspaceCwd
5778
+ ) > 0) {
5779
+ containmentErrors.push(
5780
+ new Error("Workspace channel workers are still active.")
5781
+ );
5782
+ }
5240
5783
  }
5241
- if (reason === "workspace_removed") {
5242
- const app3 = runtimeApp ?? runtimeAppForCleanup;
5784
+ if (reason !== "daemon_shutdown") {
5785
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5243
5786
  const stopWorkspaceGitStateForWorkspace = app3?.locals?.["stopWorkspaceGitStateForWorkspace"];
5244
5787
  const stopScheduledTaskKeepaliveForWorkspace = app3?.locals?.["stopScheduledTaskKeepaliveForWorkspace"];
5245
- stopWorkspaceGitStateForWorkspace?.(runtimeToDrain.workspaceCwd);
5246
- stopScheduledTaskKeepaliveForWorkspace?.(
5247
- runtimeToDrain.workspaceCwd
5248
- );
5788
+ try {
5789
+ stopWorkspaceGitStateForWorkspace?.(runtimeToDrain.workspaceCwd);
5790
+ } catch (err) {
5791
+ daemonLog.error(
5792
+ "workspace git-state cleanup error",
5793
+ err instanceof Error ? err : null
5794
+ );
5795
+ }
5796
+ try {
5797
+ stopScheduledTaskKeepaliveForWorkspace?.(
5798
+ runtimeToDrain.workspaceCwd
5799
+ );
5800
+ } catch (err) {
5801
+ daemonLog.error(
5802
+ "workspace scheduled-task cleanup error",
5803
+ err instanceof Error ? err : null
5804
+ );
5805
+ }
5249
5806
  }
5250
5807
  let bridgeStopped = false;
5251
5808
  try {
5252
5809
  if (!shutdownBridges.has(runtimeToDrain.bridge)) {
5253
- await runtimeToDrain.bridge.shutdown({ reason });
5810
+ try {
5811
+ await runtimeToDrain.bridge.shutdown({ reason });
5812
+ } catch (shutdownError) {
5813
+ try {
5814
+ runtimeToDrain.bridge.killAllSync();
5815
+ daemonLog.warn(
5816
+ "workspace bridge required forceful shutdown",
5817
+ {
5818
+ workspace: runtimeToDrain.workspaceCwd,
5819
+ reason,
5820
+ error: shutdownError instanceof Error ? shutdownError.message : String(shutdownError)
5821
+ }
5822
+ );
5823
+ } catch (killError) {
5824
+ throw new AggregateError(
5825
+ [shutdownError, killError],
5826
+ "Workspace bridge shutdown could not be confirmed."
5827
+ );
5828
+ }
5829
+ }
5254
5830
  }
5255
5831
  bridgeStopped = true;
5256
5832
  } finally {
5257
- if (bridgeStopped || reason === "workspace_removed") {
5258
- subSessionStoppersByWorkspace.delete(runtimeToDrain.workspaceCwd);
5833
+ if (bridgeStopped) {
5834
+ subSessionStoppersByRuntime.delete(runtimeToDrain);
5259
5835
  if (stopSubSessions) {
5260
5836
  removeArrayValue(subSessionStoppers, stopSubSessions);
5261
5837
  }
@@ -5267,10 +5843,16 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5267
5843
  shutdownBridges.add(runtimeToDrain.bridge);
5268
5844
  }
5269
5845
  }
5846
+ if (containmentErrors.length > 0) {
5847
+ throw new AggregateError(
5848
+ containmentErrors,
5849
+ "Workspace runtime containment could not be confirmed."
5850
+ );
5851
+ }
5270
5852
  })();
5271
5853
  runtimeCleanupPromises.set(runtimeToDrain, cleanup);
5272
5854
  void cleanup.catch(() => {
5273
- if (reason === "daemon_shutdown" && runtimeCleanupPromises.get(runtimeToDrain) === cleanup) {
5855
+ if (runtimeCleanupPromises.get(runtimeToDrain) === cleanup) {
5274
5856
  runtimeCleanupPromises.delete(runtimeToDrain);
5275
5857
  }
5276
5858
  });
@@ -5292,8 +5874,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5292
5874
  { createChannelManagementService },
5293
5875
  { WorkspaceChannelSettingsStore }
5294
5876
  ] = await Promise.all([
5295
- import("./channel-management-service-G74LFADV.js"),
5296
- import("./channel-settings-store-CHCDRTPY.js")
5877
+ import("./channel-management-service-QOO7TD3T.js"),
5878
+ import("./channel-settings-store-4CSMTR4L.js")
5297
5879
  ]);
5298
5880
  return createChannelManagementService({
5299
5881
  workspaceCwd: targetRuntime.workspaceCwd,
@@ -5309,12 +5891,55 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5309
5891
  });
5310
5892
  return pending;
5311
5893
  }, "channelManagementService");
5894
+ const validateWorkspaceRuntimeForPublication = /* @__PURE__ */ __name(async (runtimeForPublication) => {
5895
+ let candidate = runtimeForPublication;
5896
+ for (let attempt = 0; attempt < 3; attempt++) {
5897
+ const snapshot = await trustPolicy.readDaemonTrustPolicySnapshot();
5898
+ const decision = trustPolicy.evaluateDaemonWorkspaceTrust(
5899
+ snapshot,
5900
+ candidate.workspaceCwd
5901
+ );
5902
+ const materialization = JSON.stringify({
5903
+ trusted: decision.targetTrusted,
5904
+ boundWorkspaces: [candidate.workspaceCwd]
5905
+ });
5906
+ if (candidate.trustMaterialization === materialization) {
5907
+ return candidate;
5908
+ }
5909
+ candidate.generationGuard?.close();
5910
+ await workspaceRuntimeRemoval.disposeRuntime(
5911
+ candidate,
5912
+ "trust_reconfigured"
5913
+ );
5914
+ if (attempt === 2) {
5915
+ throw new Error(
5916
+ "Workspace trust policy kept changing before runtime publication."
5917
+ );
5918
+ }
5919
+ candidate = await createDynamicWorkspaceRuntime(
5920
+ runtimeForPublication.workspaceCwd,
5921
+ {
5922
+ primary: runtimeForPublication.primary,
5923
+ removable: runtimeForPublication.removable,
5924
+ displayName: runtimeForPublication.displayName,
5925
+ registrationIds: runtimeForPublication.registrationIds
5926
+ }
5927
+ );
5928
+ }
5929
+ throw new Error("Workspace runtime publication validation failed.");
5930
+ }, "validateWorkspaceRuntimeForPublication");
5312
5931
  const app2 = runtime.createServeApp(opts, () => actualPort, {
5313
5932
  workspaceRegistry,
5314
5933
  createWorkspaceRuntime: createDynamicWorkspaceRuntime,
5934
+ ...workspaceTrustHotReloadAvailable ? {
5935
+ validateWorkspaceRuntimeForPublication,
5936
+ runWorkspaceTrustOperation,
5937
+ getWorkspaceTrustPolicySnapshot: /* @__PURE__ */ __name(() => latestTrustPolicySnapshot, "getWorkspaceTrustPolicySnapshot")
5938
+ } : {},
5315
5939
  managedScratchRoot,
5316
5940
  workspaceRegistrationStore,
5317
5941
  workspaceRuntimeRemoval,
5942
+ workspaceTrustHotReloadAvailable,
5318
5943
  voiceCoordinator: workspaceVoiceCoordinator,
5319
5944
  bridge,
5320
5945
  webShellDir,
@@ -5393,9 +6018,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5393
6018
  sessionArtifactsPersistenceAvailable: sessionArtifactsPersistenceAvailableFromSettings(
5394
6019
  runtimeBootSettings?.merged
5395
6020
  ),
5396
- installAuthProvider: /* @__PURE__ */ __name((req) => withSettingsLock(
6021
+ installAuthProvider: /* @__PURE__ */ __name((req, assertGenerationOpen) => withSettingsLock(
5397
6022
  boundWorkspace,
5398
6023
  async () => {
6024
+ assertGenerationOpen?.();
5399
6025
  const provider = core.findProviderById(req.providerId);
5400
6026
  if (!provider) {
5401
6027
  throw new Error(`Unsupported auth provider: ${req.providerId}`);
@@ -5405,7 +6031,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5405
6031
  resolveBaseUrl: core.resolveBaseUrl
5406
6032
  });
5407
6033
  const plan = core.buildInstallPlan(provider, inputs);
5408
- const fresh = settingsRuntime.settings.loadSettings(boundWorkspace);
6034
+ const fresh = loadSettingsForPersistence(boundWorkspace);
5409
6035
  const adapter = settingsRuntime.loadedSettingsAdapter.createLoadedSettingsAdapter(
5410
6036
  fresh
5411
6037
  );
@@ -5413,6 +6039,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5413
6039
  settings: adapter,
5414
6040
  doRefreshAuth: false
5415
6041
  });
6042
+ assertGenerationOpen?.();
5416
6043
  core.emitDaemonLog("Auth provider installed.", {
5417
6044
  "qwen-code.daemon.auth.provider_id": provider.id,
5418
6045
  "qwen-code.daemon.auth.auth_type": plan.authType
@@ -5431,11 +6058,171 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5431
6058
  }
5432
6059
  ), "installAuthProvider")
5433
6060
  });
6061
+ serveAppForRuntimeLifecycle.current = app2;
5434
6062
  invalidatePrimaryServeFeaturesCache = app2.locals.invalidateServeFeaturesCache ?? invalidatePrimaryServeFeaturesCache;
5435
6063
  app2.locals.subSessionStoppers = subSessionStoppers;
5436
6064
  subSessionStoppers.push(subSessionLauncher.stop);
5437
- subSessionStoppersByWorkspace.set(boundWorkspace, subSessionLauncher.stop);
5438
- return { app: app2, bridge };
6065
+ subSessionStoppersByRuntime.set(
6066
+ workspaceRegistry.primary,
6067
+ subSessionLauncher.stop
6068
+ );
6069
+ if (workspaceTrustHotReloadAvailable) {
6070
+ const [
6071
+ { createWorkspaceTrustReconciler },
6072
+ { createDaemonTrustPolicyMonitor }
6073
+ ] = await Promise.all([
6074
+ import("./workspace-trust-reconciler-35EFR4GC.js"),
6075
+ import("./daemon-trust-policy-monitor-ZBTSR333.js")
6076
+ ]);
6077
+ const materializationFor = /* @__PURE__ */ __name((entry, snapshot, decision) => {
6078
+ const boundWorkspaces2 = entry.primary && decision.targetTrusted ? runtime.resolveBoundWorkspacesFromIdeEnv(
6079
+ entry.workspaceCwd,
6080
+ void 0,
6081
+ (workspace, index) => index === 0 || trustPolicy.evaluateDaemonWorkspaceTrust(snapshot, workspace).targetTrusted
6082
+ ) : [entry.workspaceCwd];
6083
+ return {
6084
+ key: JSON.stringify({
6085
+ trusted: decision.targetTrusted,
6086
+ boundWorkspaces: [...boundWorkspaces2].sort()
6087
+ }),
6088
+ boundWorkspaces: boundWorkspaces2
6089
+ };
6090
+ }, "materializationFor");
6091
+ const acpHandle = /* @__PURE__ */ __name(() => app2.locals?.["acpHandle"], "acpHandle");
6092
+ const trustReconciler = createWorkspaceTrustReconciler({
6093
+ registry: workspaceRegistry,
6094
+ readLatestSnapshot: trustPolicy.readDaemonTrustPolicySnapshot,
6095
+ materializationKey: /* @__PURE__ */ __name(({ entry, snapshot, decision }) => materializationFor(entry, snapshot, decision).key, "materializationKey"),
6096
+ isTrustDecrease: /* @__PURE__ */ __name(({
6097
+ runtime: current,
6098
+ nextMaterialization,
6099
+ decision
6100
+ }) => {
6101
+ if (current.trusted && !decision.targetTrusted) return true;
6102
+ if (!current.primary || !current.trusted) return false;
6103
+ try {
6104
+ const previous = JSON.parse(
6105
+ current.trustMaterialization ?? "{}"
6106
+ );
6107
+ const next = JSON.parse(nextMaterialization);
6108
+ if (!Array.isArray(previous.boundWorkspaces) || !Array.isArray(next.boundWorkspaces)) {
6109
+ return true;
6110
+ }
6111
+ const nextRoots = new Set(
6112
+ next.boundWorkspaces.filter(
6113
+ (value) => typeof value === "string"
6114
+ )
6115
+ );
6116
+ return previous.boundWorkspaces.some(
6117
+ (value) => typeof value !== "string" || !nextRoots.has(value)
6118
+ );
6119
+ } catch {
6120
+ return true;
6121
+ }
6122
+ }, "isTrustDecrease"),
6123
+ buildRuntime: /* @__PURE__ */ __name(async ({
6124
+ entry,
6125
+ trusted,
6126
+ snapshot,
6127
+ decision,
6128
+ generationGuard
6129
+ }) => {
6130
+ const materialized = materializationFor(
6131
+ entry,
6132
+ snapshot,
6133
+ trusted === decision.targetTrusted ? decision : { ...decision, targetTrusted: trusted }
6134
+ );
6135
+ return createDynamicWorkspaceRuntime(entry.workspaceCwd, {
6136
+ trusted,
6137
+ snapshot,
6138
+ decision,
6139
+ generationGuard,
6140
+ primary: entry.primary,
6141
+ removable: entry.removable,
6142
+ displayName: entry.displayName,
6143
+ registrationIds: entry.registrationIds,
6144
+ boundWorkspaces: materialized.boundWorkspaces,
6145
+ trustMaterialization: materialized.key
6146
+ });
6147
+ }, "buildRuntime"),
6148
+ drainRuntime: /* @__PURE__ */ __name(async (runtimeToDrain) => {
6149
+ workspaceRuntimeRemoval.beginDrain(runtimeToDrain);
6150
+ acpHandle()?.beginWorkspaceDrain(runtimeToDrain.workspaceId);
6151
+ }, "drainRuntime"),
6152
+ disposeRuntime: /* @__PURE__ */ __name(async (runtimeToDispose, reason) => {
6153
+ const errors = [];
6154
+ try {
6155
+ await workspaceRuntimeRemoval.disposeRuntime(
6156
+ runtimeToDispose,
6157
+ reason
6158
+ );
6159
+ } catch (error) {
6160
+ errors.push(error);
6161
+ }
6162
+ try {
6163
+ const handle = acpHandle();
6164
+ if (!runtimeToDispose.primary) {
6165
+ handle?.commitWorkspaceRemoval(runtimeToDispose.workspaceId);
6166
+ }
6167
+ handle?.disposeWorkspace(runtimeToDispose.workspaceId);
6168
+ const deadline = Date.now() + 1e3;
6169
+ while ((handle?.getWorkspaceActivity(runtimeToDispose.workspaceId).memoryTasks ?? 0) > 0 && Date.now() < deadline) {
6170
+ await new Promise((resolve2) => setTimeout(resolve2, 25));
6171
+ }
6172
+ if ((handle?.getWorkspaceActivity(runtimeToDispose.workspaceId).memoryTasks ?? 0) > 0) {
6173
+ throw new Error(
6174
+ "Workspace memory tasks did not stop after runtime disposal."
6175
+ );
6176
+ }
6177
+ } catch (error) {
6178
+ errors.push(error);
6179
+ }
6180
+ if (errors.length === 1) throw errors[0];
6181
+ if (errors.length > 1) {
6182
+ throw new AggregateError(
6183
+ errors,
6184
+ "Workspace runtime and ACP cleanup failed."
6185
+ );
6186
+ }
6187
+ }, "disposeRuntime"),
6188
+ runtimeActivated: /* @__PURE__ */ __name(async (runtimeAdded) => {
6189
+ workspaceRuntimeRemoval.cancelDrain(runtimeAdded);
6190
+ acpHandle()?.cancelWorkspaceDrain(runtimeAdded.workspaceId);
6191
+ if (runtimeAdded.primary) {
6192
+ bridgeRef = runtimeAdded.bridge;
6193
+ invalidatePrimaryServeFeaturesCache();
6194
+ }
6195
+ await workspaceRuntimeRemoval.runtimeAdded(runtimeAdded);
6196
+ }, "runtimeActivated"),
6197
+ onError: /* @__PURE__ */ __name((entry, error) => {
6198
+ daemonLog.error(
6199
+ `workspace trust reconciliation failed for ${entry.workspaceCwd}`,
6200
+ error instanceof Error ? error : null
6201
+ );
6202
+ }, "onError")
6203
+ });
6204
+ const trustMonitor = createDaemonTrustPolicyMonitor({
6205
+ onSnapshot: /* @__PURE__ */ __name((snapshot) => {
6206
+ latestTrustPolicySnapshot = snapshot;
6207
+ return runWorkspaceTrustOperation(
6208
+ () => trustReconciler.reconcile(snapshot)
6209
+ );
6210
+ }, "onSnapshot"),
6211
+ onError: /* @__PURE__ */ __name((error) => {
6212
+ daemonLog.error(
6213
+ "workspace trust policy monitor failed",
6214
+ error instanceof Error ? error : null
6215
+ );
6216
+ }, "onError")
6217
+ });
6218
+ app2.locals.stopTrustPolicyMonitor = () => trustMonitor.stop();
6219
+ app2.locals.requestTrustReconcile = () => trustMonitor.requestReconcile("manual");
6220
+ app2.locals.waitForTrustPolicyIdle = () => runWorkspaceTrustOperation(async () => void 0);
6221
+ await trustMonitor.start();
6222
+ }
6223
+ const activePrimaryBridge = workspaceRegistry.primaryEntry.current?.runtime.bridge;
6224
+ bridgeRef = activePrimaryBridge;
6225
+ return { app: app2, bridge: activePrimaryBridge };
5439
6226
  }, "buildRuntime");
5440
6227
  if (deps.bridge) {
5441
6228
  const runtime = await buildRuntime();
@@ -5492,46 +6279,89 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5492
6279
  );
5493
6280
  }
5494
6281
  const channelValidationSettingsRuntime = opts.channelSelection ? await loadSettingsRuntimeModules() : void 0;
6282
+ const channelValidationTrustPolicy = opts.channelSelection ? await import("./daemon-trust-policy-NOHK7IW5.js") : void 0;
6283
+ const channelValidationTrustSnapshot = channelValidationTrustPolicy ? await channelValidationTrustPolicy.readDaemonTrustPolicySnapshot() : void 0;
5495
6284
  const resolveChannelWorkspaceGroupsAtListen = /* @__PURE__ */ __name(() => {
5496
6285
  if (!opts.channelSelection || !channelValidationSettingsRuntime || !channelRuntime) {
5497
6286
  return void 0;
5498
6287
  }
6288
+ const registry = (runtimeApp ?? runtimeAppForCleanup)?.locals?.["workspaceRegistry"];
6289
+ const resolveRuntime = /* @__PURE__ */ __name((workspaceCwd) => {
6290
+ const runtime = registry?.getByWorkspaceCwd(workspaceCwd);
6291
+ if (registry && !runtime) {
6292
+ throw Object.assign(
6293
+ new Error(`Workspace "${workspaceCwd}" is unavailable.`),
6294
+ { code: "workspace_unavailable" }
6295
+ );
6296
+ }
6297
+ return runtime;
6298
+ }, "resolveRuntime");
6299
+ const resolveTrusted = /* @__PURE__ */ __name((workspaceCwd, primary, runtime) => {
6300
+ if (runtime) return runtime.trusted;
6301
+ if (primary && deps.trustedWorkspace !== void 0) {
6302
+ return deps.trustedWorkspace;
6303
+ }
6304
+ if (!channelValidationTrustPolicy || !channelValidationTrustSnapshot) {
6305
+ return false;
6306
+ }
6307
+ return channelValidationTrustPolicy.evaluateDaemonWorkspaceTrust(
6308
+ channelValidationTrustSnapshot,
6309
+ workspaceCwd
6310
+ ).targetTrusted;
6311
+ }, "resolveTrusted");
5499
6312
  const settingsByWorkspace = /* @__PURE__ */ new Map();
5500
6313
  if (workspaceInputs.length === 1) {
5501
6314
  const workspace = workspaceInputs[0];
5502
- const settings = channelValidationSettingsRuntime.settings.loadSettings(
5503
- workspace.cwd
5504
- );
5505
- channelWebhookEnvByWorkspace.set(
5506
- workspace.cwd,
5507
- channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
5508
- settings.merged,
6315
+ const runtime = resolveRuntime(workspace.cwd);
6316
+ const trusted = resolveTrusted(workspace.cwd, true, runtime);
6317
+ if (!trusted) {
6318
+ throw Object.assign(
6319
+ new Error(
6320
+ `Primary workspace "${workspace.cwd}" is not trusted; cannot host channels.`
6321
+ ),
6322
+ { code: "untrusted_workspace" }
6323
+ );
6324
+ }
6325
+ const effectiveEnv = runtime ? workspaceRuntimeEffectiveEnv(runtime, daemonRuntimeBaseEnv) : channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
6326
+ channelValidationSettingsRuntime.settings.loadSettings(
5509
6327
  workspace.cwd,
5510
- daemonRuntimeBaseEnv
5511
- ).effectiveEnv
5512
- );
6328
+ {
6329
+ skipLoadEnvironment: true,
6330
+ skipWorkspaceSettings: false,
6331
+ workspaceTrusted: true
6332
+ }
6333
+ ).merged,
6334
+ workspace.cwd,
6335
+ daemonRuntimeBaseEnv,
6336
+ trusted
6337
+ ).effectiveEnv;
6338
+ channelWebhookEnvByWorkspace.set(workspace.cwd, effectiveEnv);
5513
6339
  return void 0;
5514
6340
  }
5515
6341
  const workspaces = workspaceInputs.map((workspace, index) => {
6342
+ const runtime = resolveRuntime(workspace.cwd);
6343
+ const trusted = resolveTrusted(workspace.cwd, index === 0, runtime);
5516
6344
  const settings = channelValidationSettingsRuntime.settings.loadSettings(
5517
- workspace.cwd
6345
+ workspace.cwd,
6346
+ {
6347
+ skipLoadEnvironment: true,
6348
+ skipWorkspaceSettings: !trusted,
6349
+ workspaceTrusted: trusted
6350
+ }
5518
6351
  );
5519
6352
  settingsByWorkspace.set(workspace.cwd, settings);
5520
6353
  channelWebhookEnvByWorkspace.set(
5521
6354
  workspace.cwd,
5522
- channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
6355
+ runtime ? workspaceRuntimeEffectiveEnv(runtime, daemonRuntimeBaseEnv) : channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
5523
6356
  settings.merged,
5524
6357
  workspace.cwd,
5525
- daemonRuntimeBaseEnv
6358
+ daemonRuntimeBaseEnv,
6359
+ trusted
5526
6360
  ).effectiveEnv
5527
6361
  );
5528
- const trusted = index === 0 && deps.trustedWorkspace !== void 0 ? deps.trustedWorkspace : channelValidationSettingsRuntime.trustedFolders.getWorkspaceTrustStatus(
5529
- settings.merged,
5530
- workspace.cwd
5531
- ).effective.state === "trusted";
5532
6362
  return {
5533
6363
  workspaceCwd: workspace.cwd,
5534
- primary: index === 0,
6364
+ primary: runtime?.primary ?? index === 0,
5535
6365
  trusted
5536
6366
  };
5537
6367
  });
@@ -5555,7 +6385,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5555
6385
  if (opts.channelSelection) {
5556
6386
  reserveChannelServicePidfile(opts.channelSelection);
5557
6387
  }
5558
- return await new Promise((resolve, reject) => {
6388
+ return await new Promise((resolve2, reject) => {
5559
6389
  const onListening = /* @__PURE__ */ __name((error) => {
5560
6390
  if (error) return;
5561
6391
  startup.listenerReadyAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -5710,7 +6540,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5710
6540
  daemonLog.error("runtime startup failed", error2);
5711
6541
  markRuntimeFailed(error2);
5712
6542
  if (closeServerAfterChannelWorkerStartupFailure && server.listening) {
5713
- runtimeFailureListenerClose = new Promise((resolve2) => {
6543
+ runtimeFailureListenerClose = new Promise((resolve3) => {
5714
6544
  server.close((closeErr) => {
5715
6545
  if (closeErr) {
5716
6546
  daemonLog.error(
@@ -5718,7 +6548,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5718
6548
  closeErr
5719
6549
  );
5720
6550
  }
5721
- resolve2();
6551
+ resolve3();
5722
6552
  });
5723
6553
  });
5724
6554
  server.closeAllConnections();
@@ -5751,9 +6581,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5751
6581
  }
5752
6582
  const runtimes = registry.list();
5753
6583
  if (runtimes.length <= 1 && operation === "initial") {
6584
+ const primary = registry.primary;
6585
+ if (!primary.trusted) {
6586
+ throw Object.assign(
6587
+ new Error(
6588
+ `Primary workspace "${primary.workspaceCwd}" is not trusted; cannot host channels.`
6589
+ ),
6590
+ { code: "untrusted_workspace" }
6591
+ );
6592
+ }
5754
6593
  return [
5755
6594
  {
5756
- workspaceCwd: registry.primary.workspaceCwd,
6595
+ workspaceCwd: primary.workspaceCwd,
5757
6596
  selection: channelSelection
5758
6597
  }
5759
6598
  ];
@@ -5764,7 +6603,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5764
6603
  const grouping = resolveChannelWorkspaceGroups({
5765
6604
  workspaces: runtimes.map((runtime) => {
5766
6605
  const settings = settingsRuntime.settings.loadSettings(
5767
- runtime.workspaceCwd
6606
+ runtime.workspaceCwd,
6607
+ {
6608
+ skipLoadEnvironment: true,
6609
+ skipWorkspaceSettings: !runtime.trusted,
6610
+ workspaceTrusted: runtime.trusted
6611
+ }
5768
6612
  );
5769
6613
  settingsByWorkspace.set(runtime.workspaceCwd, settings);
5770
6614
  return {
@@ -5935,7 +6779,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5935
6779
  );
5936
6780
  return;
5937
6781
  }
5938
- if (shouldPreheat) {
6782
+ if (shouldPreheat && runtime.bridge) {
5939
6783
  startBridgePreheat(runtime.bridge);
5940
6784
  }
5941
6785
  await completeRuntimeStartup(runtime.app);
@@ -5977,6 +6821,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5977
6821
  if (shuttingDown) {
5978
6822
  daemonLog.warn(`received ${signal} during drain \u2014 forcing exit`);
5979
6823
  try {
6824
+ managedProcessRegistry?.killAllSync();
5980
6825
  channelWorkerManager?.killAllSync();
5981
6826
  for (const runtimeBridge of getRuntimeBridgesForCleanup()) {
5982
6827
  runtimeBridge.killAllSync();
@@ -6004,7 +6849,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6004
6849
  process.exit(runtimeStartupError === void 0 ? 0 : 1);
6005
6850
  } catch (err) {
6006
6851
  daemonLog.error("shutdown error", err instanceof Error ? err : null);
6007
- if (channelWorkerManager?.state().enabled) {
6852
+ if (err instanceof Error && retryableChannelWorkerShutdownErrors.has(err)) {
6008
6853
  daemonLog.error(
6009
6854
  "refusing to exit while a channel worker or service lease remains; signal again to retry after the child exits (another signal during that retry forces exit)"
6010
6855
  );
@@ -6036,7 +6881,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6036
6881
  channelControlDraining = true;
6037
6882
  const initiallyMountedApp = runtimeApp ?? runtimeAppForCleanup;
6038
6883
  const initiallyMountedManagement = initiallyMountedApp?.locals?.["workspaceManagementHandle"];
6884
+ const initiallyMountedSessionMaintenance = initiallyMountedApp?.locals?.["sessionArchiveCoordinator"];
6039
6885
  const initialManagementWait = initiallyMountedManagement?.sealAndWait?.();
6886
+ const initialSessionMaintenanceWait = initiallyMountedSessionMaintenance?.sealMaintenanceAndWait?.();
6887
+ let processRegistryShutdown;
6888
+ const startProcessRegistryShutdown = /* @__PURE__ */ __name(() => {
6889
+ processRegistryShutdown ??= managedProcessRegistry?.shutdown().then(
6890
+ () => void 0,
6891
+ (error2) => error2 instanceof Error ? error2 : new Error(String(error2))
6892
+ );
6893
+ }, "startProcessRegistryShutdown");
6894
+ startProcessRegistryShutdown();
6040
6895
  clearRuntimeStartAfterHealthTimer();
6041
6896
  clearRuntimeStartFallbackTimer();
6042
6897
  cancelDeferredRuntimeStartup();
@@ -6065,6 +6920,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6065
6920
  const finalErr = err ?? bridgeShutdownError ?? channelWorkerShutdownError;
6066
6921
  const retryableChannelClose = channelWorkerShutdownError !== void 0 && channelWorkerManager?.state().enabled === true;
6067
6922
  if (retryableChannelClose) {
6923
+ const retryableError = channelWorkerShutdownError;
6068
6924
  await flushDaemonLogBounded(
6069
6925
  daemonLog,
6070
6926
  DAEMON_LOG_FORCED_FLUSH_BUDGET_MS
@@ -6072,13 +6928,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6072
6928
  closePromise = void 0;
6073
6929
  shuttingDown = false;
6074
6930
  channelControlDraining = false;
6075
- rej(finalErr);
6931
+ retryableChannelWorkerShutdownErrors.add(retryableError);
6932
+ rej(retryableError);
6076
6933
  return;
6077
6934
  }
6078
6935
  if (loggerPublished || loggerSignalOwned) {
6079
- writeDaemonLifecycleBestEffort(
6080
- () => daemonLog.info("daemon stopped")
6081
- );
6936
+ writeDaemonLifecycleBestEffort(() => {
6937
+ if (finalErr) {
6938
+ daemonLog.error("daemon shutdown incomplete", finalErr);
6939
+ } else {
6940
+ daemonLog.info("daemon stopped");
6941
+ }
6942
+ });
6082
6943
  await daemonLog.close();
6083
6944
  }
6084
6945
  if (finalErr) rej(finalErr);
@@ -6097,10 +6958,24 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6097
6958
  );
6098
6959
  const appForCleanup = runtimeApp ?? runtimeAppForCleanup;
6099
6960
  const workspaceManagementHandle = appForCleanup?.locals?.["workspaceManagementHandle"];
6961
+ const sessionMaintenance = appForCleanup?.locals?.["sessionArchiveCoordinator"];
6100
6962
  await initialManagementWait;
6101
6963
  if (workspaceManagementHandle !== initiallyMountedManagement) {
6102
6964
  await workspaceManagementHandle?.sealAndWait?.();
6103
6965
  }
6966
+ await initialSessionMaintenanceWait;
6967
+ if (sessionMaintenance !== initiallyMountedSessionMaintenance) {
6968
+ await sessionMaintenance?.sealMaintenanceAndWait?.();
6969
+ }
6970
+ stopTrustPolicyMonitor(appForCleanup);
6971
+ const waitForTrustPolicyIdle = appForCleanup?.locals?.["waitForTrustPolicyIdle"];
6972
+ await waitForTrustPolicyIdle?.().catch((err) => {
6973
+ daemonLog.error(
6974
+ "workspace trust reconciliation shutdown wait failed",
6975
+ err instanceof Error ? err : null
6976
+ );
6977
+ });
6978
+ startProcessRegistryShutdown();
6104
6979
  disposeRuntimeAppResources(appForCleanup);
6105
6980
  disposeDaemonEventLoopMonitor();
6106
6981
  if (channelWorkerManager) {
@@ -6151,6 +7026,14 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6151
7026
  bridgeShutdownError = err instanceof Error ? err : new Error(String(err));
6152
7027
  });
6153
7028
  }
7029
+ const processRegistryError = await processRegistryShutdown;
7030
+ if (processRegistryError) {
7031
+ daemonLog.error(
7032
+ "ACP process registry shutdown error",
7033
+ processRegistryError
7034
+ );
7035
+ bridgeShutdownError ??= processRegistryError;
7036
+ }
6154
7037
  }).finally(() => {
6155
7038
  if (!server.listening) {
6156
7039
  void (runtimeFailureListenerClose ?? Promise.resolve()).then(
@@ -6213,13 +7096,13 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6213
7096
  if (deps.resolveOnListen) {
6214
7097
  loggerPublished = true;
6215
7098
  loggerLifecycle.published();
6216
- resolve(handle);
7099
+ resolve2(handle);
6217
7100
  } else {
6218
7101
  void runtimeReady.then(
6219
7102
  () => {
6220
7103
  loggerPublished = true;
6221
7104
  loggerLifecycle.published();
6222
- resolve(handle);
7105
+ resolve2(handle);
6223
7106
  },
6224
7107
  (err) => {
6225
7108
  void handle.close().then(
@@ -6233,7 +7116,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6233
7116
  closeErr instanceof Error ? closeErr : null
6234
7117
  )
6235
7118
  );
6236
- if (channelWorkerManager?.state().enabled) {
7119
+ if (closeErr instanceof Error && retryableChannelWorkerShutdownErrors.has(closeErr)) {
6237
7120
  writeDaemonLifecycleBestEffort(
6238
7121
  () => daemonLog.error(
6239
7122
  "runtime startup failed, but qwen serve remains alive to retain the channel service lease until worker exit is confirmed"