@qwen-code/qwen-code 0.21.1-simplify-system-prompt.0 → 0.21.1

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 (405) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +2 -0
  2. package/bundled/qc-helper/docs/configuration/settings.md +38 -28
  3. package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
  4. package/bundled/qc-helper/docs/features/channels/github.md +107 -0
  5. package/bundled/qc-helper/docs/features/channels/overview.md +61 -6
  6. package/bundled/qc-helper/docs/features/code-review.md +1 -1
  7. package/bundled/qc-helper/docs/features/hooks.md +52 -15
  8. package/bundled/qc-helper/docs/features/mcp.md +9 -1
  9. package/bundled/qc-helper/docs/features/scheduled-tasks.md +3 -1
  10. package/bundled/qc-helper/docs/features/sub-agents.md +20 -0
  11. package/bundled/qc-helper/docs/qwen-serve.md +4 -2
  12. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +2 -2
  13. package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
  14. package/bundled/review/DESIGN.md +19 -0
  15. package/bundled/review/SKILL.md +120 -61
  16. package/chunks/MaxSizedBox-VI3ROJJA.js +84 -0
  17. package/chunks/{StandaloneSessionPicker-O6RKBPU4.js → StandaloneSessionPicker-LYXKD2EV.js} +66 -68
  18. package/chunks/{acp-startup-profiler-RV3IV562.js → acp-startup-profiler-DFVPFQ6C.js} +2 -2
  19. package/chunks/{acpAgent-HYFVXVDR.js → acpAgent-WN5SRDQO.js} +1317 -542
  20. package/chunks/agent-K6ECSM64.js +80 -0
  21. package/chunks/agent-headless-NO4Y2HOE.js +74 -0
  22. package/chunks/{anthropicContentGenerator-LXUXMOE7.js → anthropicContentGenerator-V2QOGVYD.js} +61 -20
  23. package/chunks/{artifact-tool-Y5T7GG7F.js → artifact-tool-6K6U7XYJ.js} +4 -4
  24. package/chunks/{askUserQuestion-2H6747FR.js → askUserQuestion-GD2IJJ7I.js} +4 -4
  25. package/chunks/bridge-3KJEWDNE.js +90 -0
  26. package/chunks/{build-RV63TIRH.js → build-S6DO7LMM.js} +1 -1
  27. package/chunks/{ca-25EDXPFZ.js → ca-6W3SK7OQ.js} +6 -1
  28. package/chunks/{channel-management-service-G74LFADV.js → channel-management-service-XR7GZSWF.js} +4 -4
  29. package/chunks/channel-settings-store-HW4FXXUA.js +87 -0
  30. package/chunks/{channel-worker-group-PTJIJSKC.js → channel-worker-group-XDPTDWTX.js} +9 -5
  31. package/chunks/{channel-worker-manager-WIMGM2FD.js → channel-worker-manager-YYEHVRRE.js} +9 -5
  32. package/chunks/{channel-worker-supervisor-KUFTR6P5.js → channel-worker-supervisor-74HTWA2G.js} +5 -4
  33. package/chunks/{chunk-M5JM7OSF.js → chunk-2DN4J57Y.js} +2 -3
  34. package/chunks/{chunk-WDSWXQU3.js → chunk-2FAK6PNM.js} +2 -2
  35. package/chunks/{chunk-BPJSQIJX.js → chunk-2J3OJGTL.js} +0 -2
  36. package/chunks/{chunk-EPDRMGT4.js → chunk-2LKVPASC.js} +4 -28
  37. package/chunks/{chunk-PWTZEM3C.js → chunk-2LQTH543.js} +3 -37
  38. package/chunks/{chunk-PANH4R3B.js → chunk-2N7CODY5.js} +18 -12
  39. package/chunks/{chunk-ER5LWJR6.js → chunk-2XSLTRFZ.js} +3 -3
  40. package/chunks/{chunk-6PSLCFQ2.js → chunk-3EFXSQCM.js} +18 -9
  41. package/chunks/{chunk-HIJQF5B5.js → chunk-3L2SPEBH.js} +1 -1
  42. package/chunks/{chunk-BIQWWWJN.js → chunk-4G2BISNC.js} +1 -1
  43. package/chunks/{chunk-B4UMZKMU.js → chunk-52ZSWYEG.js} +1 -1
  44. package/chunks/{chunk-YAF5VNU7.js → chunk-5KTQXHPY.js} +4 -5
  45. package/chunks/{chunk-2YZJCM5T.js → chunk-5MKRTI4T.js} +4 -4
  46. package/chunks/{chunk-DHHOYAPR.js → chunk-5TBMQLGG.js} +7 -7
  47. package/chunks/{chunk-A4UCTEB5.js → chunk-5WV5S2GT.js} +0 -1
  48. package/chunks/{chunk-FY3M44RD.js → chunk-5YKDXHUY.js} +3 -3
  49. package/chunks/{chunk-TF2X2WCT.js → chunk-5ZF5XXTS.js} +2 -2
  50. package/chunks/{chunk-K4XWPEWB.js → chunk-64LQLPL7.js} +4 -33
  51. package/chunks/{chunk-B7QDM6Z7.js → chunk-657BH7VM.js} +2 -2
  52. package/chunks/{chunk-5THCYPLO.js → chunk-65PQENQP.js} +14 -7
  53. package/chunks/{chunk-J6D3VXCC.js → chunk-6PE7N3A4.js} +17 -6
  54. package/chunks/{chunk-JZA3JUDJ.js → chunk-6QIGFD5W.js} +1 -1
  55. package/chunks/{chunk-Z5BLYMZM.js → chunk-6RPMI2AB.js} +6 -6
  56. package/chunks/{chunk-OHNBB4XR.js → chunk-75GFAX4R.js} +1 -1
  57. package/chunks/{chunk-BO4XCS7P.js → chunk-75MIQ3LV.js} +20 -85
  58. package/chunks/{chunk-52O2CIUL.js → chunk-7AEJDLRA.js} +130 -5
  59. package/chunks/{chunk-BYFNTGKI.js → chunk-7BAU433D.js} +2287 -941
  60. package/chunks/{chunk-ZE5WPL4I.js → chunk-7DXQIJID.js} +3 -3
  61. package/chunks/{chunk-ML52PL6O.js → chunk-7I5GTCT4.js} +483 -248
  62. package/chunks/{chunk-A5L3JMUA.js → chunk-7XATOOE7.js} +18 -4
  63. package/chunks/{chunk-C3NS4F2Q.js → chunk-A2D5BAVP.js} +1 -1
  64. package/chunks/{chunk-5I2IWRSH.js → chunk-A3NDJ5SB.js} +2 -2
  65. package/chunks/{chunk-2JM6GZ5D.js → chunk-A4COXFB3.js} +8 -13
  66. package/chunks/{chunk-CC4N4M36.js → chunk-AQIDMUGU.js} +1 -1
  67. package/chunks/{chunk-PJIZUQVC.js → chunk-AZQ3DT76.js} +2 -2
  68. package/chunks/{chunk-UH3WSE5L.js → chunk-B4AJNNOL.js} +1 -6
  69. package/chunks/{chunk-BJX6ZSUK.js → chunk-BCZFQXWK.js} +2 -2
  70. package/chunks/{chunk-SRZ6DXVG.js → chunk-BGTQCTQW.js} +44 -136
  71. package/chunks/{chunk-PSWQZHEA.js → chunk-BMFALVGQ.js} +1 -1
  72. package/chunks/{chunk-XHRTVPG2.js → chunk-BNWB5CYE.js} +7 -7
  73. package/chunks/{chunk-P5V4T7NK.js → chunk-BPZKP57P.js} +11 -3
  74. package/chunks/{chunk-2OM7GEXO.js → chunk-CAPPWD3X.js} +3 -3
  75. package/chunks/{chunk-LNURQEMZ.js → chunk-CQL64ESB.js} +7 -7
  76. package/chunks/{chunk-TOFQCPDC.js → chunk-CVHIL5IG.js} +4 -5
  77. package/chunks/{chunk-XVNQMZ2I.js → chunk-DGEIYUC3.js} +0 -1
  78. package/chunks/{chunk-BPZALHVR.js → chunk-DI35ZN7T.js} +1 -1
  79. package/chunks/{chunk-SQBYH7PX.js → chunk-DZLYR4U3.js} +1 -1
  80. package/chunks/{chunk-JALU3ZDU.js → chunk-EIF3FXTB.js} +117 -24
  81. package/chunks/{chunk-TQCBGUHN.js → chunk-EJGJIBRS.js} +5 -5
  82. package/chunks/{chunk-5U4IPFBR.js → chunk-EVKE2FZL.js} +4 -4
  83. package/chunks/{chunk-OKY7HXPG.js → chunk-FNMZK765.js} +2 -2
  84. package/chunks/{chunk-KU5XMLDK.js → chunk-FTD6DP4T.js} +3 -1
  85. package/chunks/chunk-FYJ7W2PI.js +194 -0
  86. package/chunks/{chunk-L5UHQJTJ.js → chunk-GATT5TKW.js} +1 -1
  87. package/chunks/{chunk-MVS3NS2N.js → chunk-GEBV2JGB.js} +28 -5
  88. package/chunks/{chunk-VAK25FTU.js → chunk-GKX7E4CO.js} +1 -1
  89. package/chunks/{chunk-LS77BEZP.js → chunk-GLCZKT5V.js} +1 -5
  90. package/chunks/{chunk-N3FAY5CM.js → chunk-GNR2RNMP.js} +157 -4
  91. package/chunks/{chunk-YH6G52F2.js → chunk-GXIJHV66.js} +4 -4
  92. package/chunks/{chunk-HV3G62R6.js → chunk-GZ3RCT54.js} +1 -1
  93. package/chunks/{chunk-QY5MMZ6O.js → chunk-HMRM2A3U.js} +3 -3
  94. package/chunks/chunk-HV26XH34.js +319 -0
  95. package/chunks/{chunk-M4UKFCZ2.js → chunk-J7OACQDE.js} +193 -155
  96. package/chunks/{chunk-3HBZKBMQ.js → chunk-JFMA7Y5M.js} +5 -5
  97. package/chunks/{chunk-OJGCZBB7.js → chunk-JHNRZMHI.js} +41 -36
  98. package/chunks/{chunk-63P4EL5V.js → chunk-JMONIXMJ.js} +1 -1
  99. package/chunks/{chunk-L26JL52R.js → chunk-JSD33JG6.js} +47 -64
  100. package/chunks/{chunk-KIUFNBHR.js → chunk-JTV5K7NH.js} +1 -1
  101. package/chunks/{chunk-PHVR5UUY.js → chunk-JX27F6QS.js} +1 -1
  102. package/chunks/chunk-JYBU6YUE.js +378 -0
  103. package/chunks/{chunk-A6UO2C7C.js → chunk-KAMYKP7E.js} +167 -81
  104. package/chunks/{chunk-LG4GZIVV.js → chunk-KCO4FLFJ.js} +4 -4
  105. package/chunks/{chunk-2W3OOD4W.js → chunk-L55JWS76.js} +6 -3
  106. package/chunks/{chunk-RHLZR4E5.js → chunk-LGAOC3ZS.js} +1 -1
  107. package/chunks/{chunk-DM22XS4K.js → chunk-LO4ROVP4.js} +261 -15
  108. package/chunks/{chunk-NH6KE4JX.js → chunk-LW3RFMG7.js} +3 -3
  109. package/chunks/{chunk-J56UI34H.js → chunk-M7OONWYU.js} +2 -2
  110. package/chunks/{chunk-V6VRAM7B.js → chunk-MHAIJPTD.js} +12 -12
  111. package/chunks/{chunk-FODK6UMO.js → chunk-MPHPFVKK.js} +0 -2
  112. package/chunks/{chunk-LZEMEFKY.js → chunk-MR5EAQ5M.js} +1 -1
  113. package/chunks/{chunk-JESCGQM3.js → chunk-NAVJD2PQ.js} +8 -7
  114. package/chunks/{chunk-H5FFA6TH.js → chunk-NOKIVHOL.js} +16 -3
  115. package/chunks/{chunk-6OUGMXDC.js → chunk-NWNEANAT.js} +7 -7
  116. package/chunks/{chunk-B6ZJ7SI6.js → chunk-OCESJA77.js} +391 -328
  117. package/chunks/chunk-OCPBI7J5.js +18 -0
  118. package/chunks/{chunk-E5TUC6CA.js → chunk-OKF7JF3R.js} +3 -3
  119. package/chunks/{chunk-2Q3OT4OV.js → chunk-P4WOAOJW.js} +141 -64
  120. package/chunks/{chunk-4M377AZG.js → chunk-PB3MBFKG.js} +6 -6
  121. package/chunks/{chunk-QPDRAXDJ.js → chunk-PLDQBIO6.js} +1 -1
  122. package/chunks/{chunk-FNQ6T3CV.js → chunk-PONHVBRT.js} +10 -7
  123. package/chunks/{chunk-RWS5VYWC.js → chunk-PT722TDT.js} +267 -378
  124. package/chunks/chunk-Q43KPN7X.js +2196 -0
  125. package/chunks/{chunk-VDDGDZMA.js → chunk-QHWCP53L.js} +14 -7
  126. package/chunks/{chunk-SASBXAQL.js → chunk-QIZKCVM3.js} +4 -4
  127. package/chunks/{chunk-32MVHM4T.js → chunk-RCUQIPTN.js} +1 -1
  128. package/chunks/{chunk-6FGBXPWM.js → chunk-RPLGZJV2.js} +38 -44
  129. package/chunks/{chunk-3IXOIAKE.js → chunk-S4WJVPZW.js} +18 -6
  130. package/chunks/{chunk-6AM5D4ME.js → chunk-S6LOFUVP.js} +0 -12
  131. package/chunks/{chunk-INADJJGW.js → chunk-S7W2GKIO.js} +0 -2
  132. package/chunks/{chunk-MUP3T3AD.js → chunk-SGFT55XI.js} +1 -35
  133. package/chunks/{chunk-VYPFXUCB.js → chunk-SZ3KHTDR.js} +1 -1
  134. package/chunks/chunk-T26EAKDL.js +13 -0
  135. package/chunks/{chunk-3MSHSCSN.js → chunk-T2QMKU3R.js} +79 -1
  136. package/chunks/{chunk-VFSJ5VRH.js → chunk-T3O2B4XO.js} +3 -3
  137. package/chunks/{chunk-MSLKI6C2.js → chunk-T4TXDL7G.js} +32 -21
  138. package/chunks/{chunk-E5WH5O3C.js → chunk-TBBV36Y4.js} +4 -4
  139. package/chunks/{chunk-VV6XU5L7.js → chunk-TCIFAA7K.js} +16 -11
  140. package/chunks/{chunk-DN6ZX5AY.js → chunk-TDL6LB4K.js} +46 -11
  141. package/chunks/{chunk-W4CQXHT6.js → chunk-TFRMVU6R.js} +1 -1
  142. package/chunks/{chunk-GDIPH4JY.js → chunk-TV64SXKD.js} +6 -6
  143. package/chunks/{chunk-FQK6JAFG.js → chunk-U3E3UQAA.js} +4 -4
  144. package/chunks/{chunk-7FZEBPKS.js → chunk-UBEPNVDI.js} +23 -18
  145. package/chunks/{chunk-NL7LTRLR.js → chunk-UHUSJ6X7.js} +29 -68
  146. package/chunks/{chunk-ZOIFNCKL.js → chunk-UPUG4GXM.js} +3 -23
  147. package/chunks/{chunk-6GMVPFB2.js → chunk-UWMLWVCA.js} +19 -6
  148. package/chunks/{chunk-U7TXFVUN.js → chunk-VCPIZRYH.js} +118 -95
  149. package/chunks/{chunk-LNARWLZQ.js → chunk-VWOOBLTY.js} +2 -2
  150. package/chunks/{chunk-I7XZ3RY5.js → chunk-VYOXCEPJ.js} +1 -1
  151. package/chunks/{chunk-USTWD7QV.js → chunk-W4MIWP6M.js} +26 -16
  152. package/chunks/{chunk-DLWL3Z7A.js → chunk-WBSMNTSV.js} +3 -3
  153. package/chunks/{chunk-G4WFQUYQ.js → chunk-WUZ7H6DP.js} +1 -1
  154. package/chunks/{chunk-2JZBVYTU.js → chunk-WZRWHXFE.js} +1 -8
  155. package/chunks/{chunk-DM4Q4JJH.js → chunk-X5WNMMIA.js} +22506 -33611
  156. package/chunks/{chunk-MK7VQDN3.js → chunk-XBYYDKAZ.js} +7 -6
  157. package/chunks/{chunk-COH43MRJ.js → chunk-XCGIMOLN.js} +27 -1
  158. package/chunks/{chunk-BRRAJXPA.js → chunk-XFZYFU3I.js} +1 -1
  159. package/chunks/{chunk-3QMGYBFN.js → chunk-XWWKIXVD.js} +1 -80
  160. package/chunks/{chunk-3SJ43L4W.js → chunk-XZC5VLBZ.js} +2 -0
  161. package/chunks/{chunk-UUUTRMI2.js → chunk-Y4IHBGBP.js} +1 -1
  162. package/chunks/{chunk-PR75REBZ.js → chunk-Y6AXW2OG.js} +12 -82
  163. package/chunks/{chunk-IPUUTYMV.js → chunk-YDLJGZHL.js} +1 -1
  164. package/chunks/{chunk-3JAQDSXN.js → chunk-YGF33UXG.js} +70 -8
  165. package/chunks/chunk-Z4X5MTRT.js +133 -0
  166. package/chunks/{chunk-UW5EOVUN.js → chunk-ZBVS26BY.js} +4 -4
  167. package/chunks/{chunk-ZD6UTE4A.js → chunk-ZHBO7WVX.js} +1 -1
  168. package/chunks/{chunk-HTO4JFDZ.js → chunk-ZPJWUGCS.js} +0 -1
  169. package/chunks/{chunk-66RMLJHC.js → chunk-ZURDMIDR.js} +355 -143
  170. package/chunks/{computer-use-DOFAHZAB.js → computer-use-ZTIDHMMA.js} +48 -50
  171. package/chunks/{config-utils-VFQXVGNR.js → config-utils-NYSXDMEQ.js} +4 -4
  172. package/chunks/contextCommand-2PIEU37Z.js +79 -0
  173. package/chunks/core-runtime-3XEYLQFK.js +133 -0
  174. package/chunks/{create-sub-session-7543K2QA.js → create-sub-session-R76FVXCI.js} +45 -47
  175. package/chunks/{create-sub-session-IWW2IZ2T.js → create-sub-session-SBYUMSSS.js} +3 -3
  176. package/chunks/{cron-create-YIID5XAW.js → cron-create-2QK6TCEC.js} +6 -6
  177. package/chunks/{cron-delete-ZVHYCEP2.js → cron-delete-FDCDFYMG.js} +5 -5
  178. package/chunks/{cron-list-XEGS463Q.js → cron-list-XN3WVBTP.js} +6 -6
  179. package/chunks/{daemon-VOMQW7KZ.js → daemon-Q2AB5Z23.js} +167 -15
  180. package/chunks/daemon-status-provider-3XJI6CAL.js +89 -0
  181. package/chunks/daemon-trust-policy-ILUDTLHD.js +84 -0
  182. package/chunks/daemon-trust-policy-monitor-HS3PKKRO.js +171 -0
  183. package/chunks/{de-HGRCYDEJ.js → de-SY6O76BF.js} +6 -1
  184. package/chunks/deferred-core-runtime-X4QV662U.js +88 -0
  185. package/chunks/dist-BSTVRPMT.js +4227 -0
  186. package/chunks/{dist-NNVBBOGU.js → dist-DOLYHMXE.js} +2 -2
  187. package/chunks/{dist-RTJFMNEZ.js → dist-HVRQ2CFL.js} +271 -11
  188. package/chunks/{dist-ANLAT3GS.js → dist-IXQEQWRG.js} +2 -1
  189. package/chunks/{dist-BRB6EXK4.js → dist-SSU66DM4.js} +3 -3
  190. package/chunks/{dist-KTYYJ2C5.js → dist-SV7Q3AWJ.js} +1 -1
  191. package/chunks/{dist-K6Y4E7FX.js → dist-YGBBMK3Z.js} +1 -1
  192. package/chunks/earlyInputCapture-XKLZT7ZD.js +81 -0
  193. package/chunks/{edit-RIEOJWKB.js → edit-HHGIOTQ2.js} +47 -49
  194. package/chunks/{en-MTWBNGDO.js → en-NBK3JKCE.js} +9 -1
  195. package/chunks/{enter-worktree-OGK5FQ3R.js → enter-worktree-ZN7PUQ46.js} +47 -49
  196. package/chunks/{enterPlanMode-IWZYALIB.js → enterPlanMode-EIFIDSIV.js} +47 -49
  197. package/chunks/{environment-VZ7BRI4Q.js → environment-XXQ75D2Q.js} +47 -49
  198. package/chunks/errors-4GMVU7CK.js +87 -0
  199. package/chunks/esm-K5FARBNI.js +5548 -0
  200. package/chunks/{exit-worktree-4TEYVIVP.js → exit-worktree-GXMI4ATY.js} +47 -49
  201. package/chunks/exitPlanMode-34UVY7M6.js +72 -0
  202. package/chunks/{fast-path-HYE7IFEV.js → fast-path-VPIVA7L6.js} +13 -3
  203. package/chunks/{fr-45RLL55O.js → fr-4KG5V7UT.js} +6 -1
  204. package/chunks/{gemini-NGRQX3YJ.js → gemini-4BWIK4WD.js} +103 -103
  205. package/chunks/{geminiContentGenerator-FQHPFZSR.js → geminiContentGenerator-3XVV5MSS.js} +7 -7
  206. package/chunks/{getMachineId-bsd-V7W3GODC.js → getMachineId-bsd-FG7IUY6U.js} +1 -1
  207. package/chunks/{getMachineId-darwin-TDO75DQP.js → getMachineId-darwin-GLCJI2RA.js} +1 -1
  208. package/chunks/{getMachineId-linux-TF43WQT2.js → getMachineId-linux-O6OPPAKO.js} +1 -1
  209. package/chunks/{getMachineId-unsupported-ZGUO3TXT.js → getMachineId-unsupported-S6CKYVGC.js} +1 -1
  210. package/chunks/{getMachineId-win-ECFYZZFQ.js → getMachineId-win-X5SRNEH7.js} +1 -1
  211. package/chunks/{glob-FRTM3X2E.js → glob-TZ2ABCJG.js} +47 -49
  212. package/chunks/{grep-RKWVROCW.js → grep-BEF463NA.js} +49 -50
  213. package/chunks/handleAutoUpdate-L6ERF36Y.js +80 -0
  214. package/chunks/i18n-FMM5FDXR.js +96 -0
  215. package/chunks/{image-gen-WIEM7KZA.js → image-gen-HHVLF7HS.js} +12 -12
  216. package/chunks/initializer-625TIAIO.js +85 -0
  217. package/chunks/installationInfo-6AM4I2Y3.js +79 -0
  218. package/chunks/{ja-B7DF7DFG.js → ja-F3GSQXMF.js} +6 -1
  219. package/chunks/{keychain-token-storage-MDTG3WRM.js → keychain-token-storage-72IYCAZV.js} +3 -3
  220. package/chunks/lib-RUF3WZA6.js +9 -0
  221. package/chunks/list-L2GA674Y.js +88 -0
  222. package/chunks/{list-agents-5KJJHR6I.js → list-agents-R6KDXQR3.js} +3 -3
  223. package/chunks/loadedSettingsAdapter-SPUTNKAV.js +82 -0
  224. package/chunks/{loggingContentGenerator-WGM27QAW.js → loggingContentGenerator-LKOF7XI7.js} +31 -30
  225. package/chunks/{loop-wakeup-FXKNNYSY.js → loop-wakeup-3IQKCYAH.js} +7 -7
  226. package/chunks/{ls-NTK6VOQJ.js → ls-DKZ37A7N.js} +5 -5
  227. package/chunks/{lsp-2JI24STP.js → lsp-QNWN7KN3.js} +3 -3
  228. package/chunks/{managed-npm-update-JQ2CG3RH.js → managed-npm-update-ACQGGIN5.js} +46 -48
  229. package/chunks/mcp-SZLHKFJW.js +82 -0
  230. package/chunks/{monitor-7FEWXX5F.js → monitor-DF52UVHI.js} +47 -49
  231. package/chunks/nonInteractiveCli-5T7KYKLK.js +144 -0
  232. package/chunks/{notebook-edit-JGJV2K6J.js → notebook-edit-FCWS4XVN.js} +47 -49
  233. package/chunks/{openaiContentGenerator-JPVXDTAO.js → openaiContentGenerator-7LDK3DCJ.js} +25 -27
  234. package/chunks/pidfile-6ERW3DF4.js +85 -0
  235. package/chunks/process-registry-2CHQBXH5.js +157 -0
  236. package/chunks/{processUtils-V2LCK6T6.js → processUtils-COKZAMUP.js} +2 -2
  237. package/chunks/{pt-22Q3FP73.js → pt-EQ33KWEN.js} +6 -1
  238. package/chunks/{qwenContentGenerator-TICV2W2Z.js → qwenContentGenerator-TKWUMR7N.js} +51 -53
  239. package/chunks/{qwenOAuth2-XGFI5XJG.js → qwenOAuth2-7HMU47SF.js} +10 -10
  240. package/chunks/read-file-X6DRC574.js +29 -0
  241. package/chunks/{read-mcp-resource-4DKQWGHD.js → read-mcp-resource-GFTWYXMK.js} +4 -4
  242. package/chunks/{record-artifact-RQKFYO5B.js → record-artifact-XAMSFSW4.js} +3 -3
  243. package/chunks/resumeHistoryUtils-PFPM2GWM.js +90 -0
  244. package/chunks/ripGrep-OWV2IVJC.js +72 -0
  245. package/chunks/{ru-FZCNZHDC.js → ru-7OZAUKGG.js} +6 -1
  246. package/chunks/{run-qwen-serve-3VCV4I7E.js → run-qwen-serve-TSTCO4XE.js} +917 -249
  247. package/chunks/{runtime-AXJWIEDU.js → runtime-DAUPSUKI.js} +55 -57
  248. package/chunks/{scheduler-RS2I6RU5.js → scheduler-KMADMT26.js} +45 -47
  249. package/chunks/{sdk-exporters-grpc-AK3LGHNO.js → sdk-exporters-grpc-54L4LS5L.js} +4 -4
  250. package/chunks/{sdk-exporters-http-FS6ZV7MF.js → sdk-exporters-http-WO556XNU.js} +7 -7
  251. package/chunks/{sdk-impl-7FZSCSXB.js → sdk-impl-LPAVACSF.js} +10 -10
  252. package/chunks/{send-message-Q6OOR6BR.js → send-message-SAWK4DZX.js} +6 -6
  253. package/chunks/serve-NNRWS6F4.js +88 -0
  254. package/chunks/{server-HRZ23U7M.js → server-WEH7DVCH.js} +3304 -842
  255. package/chunks/{session-7XHZKTVV.js → session-WXC56V2I.js} +94 -94
  256. package/chunks/{settings-7ZGZDXAS.js → settings-DJDXFDZ3.js} +54 -56
  257. package/chunks/shell-JN5VRQXD.js +82 -0
  258. package/chunks/{skill-LIWXNLDW.js → skill-SGXPKJCS.js} +20 -22
  259. package/chunks/skill-settings-VJ5PDMZI.js +90 -0
  260. package/chunks/spawnChannel-ETMJW7YX.js +81 -0
  261. package/chunks/standalone-update-MK3Z7KBI.js +91 -0
  262. package/chunks/{startInteractiveUI-IW3CSKHA.js → startInteractiveUI-ZCGIXPGT.js} +715 -373
  263. package/chunks/{syntheticOutput-I3757IWH.js → syntheticOutput-355CB6CJ.js} +4 -4
  264. package/chunks/{task-create-N7WQSGYA.js → task-create-INGWNUG4.js} +10 -10
  265. package/chunks/{task-list-FOPULZEP.js → task-list-5XNNGTF4.js} +7 -7
  266. package/chunks/{task-stop-H6RHXFVQ.js → task-stop-4ROAOBXH.js} +3 -3
  267. package/chunks/{task-update-M57TFZJT.js → task-update-CRK5VWWZ.js} +10 -10
  268. package/chunks/{team-create-O2FROQ4R.js → team-create-QQGAJG7P.js} +49 -51
  269. package/chunks/{team-delete-QE2UXJL7.js → team-delete-S2RCXA4P.js} +7 -7
  270. package/chunks/{team-plan-approval-Q6WDBXTQ.js → team-plan-approval-RT7Q5R6O.js} +47 -49
  271. package/chunks/theme-manager-EEWIQJ7J.js +76 -0
  272. package/chunks/{todoWrite-VQ7FKOHL.js → todoWrite-7WM3VDMY.js} +7 -7
  273. package/chunks/{tool-search-APECNQ3Z.js → tool-search-Z3Z4AYKP.js} +19 -21
  274. package/chunks/total-session-admission-44JKRWQD.js +84 -0
  275. package/chunks/{tree-sitter-FS4VPMZA.js → tree-sitter-4D7QS7F6.js} +1 -1
  276. package/chunks/{tree-sitter-bash-6B46JJCV.js → tree-sitter-bash-VEJGF5XF.js} +1 -1
  277. package/chunks/trustedFolders-X2JEIO57.js +94 -0
  278. package/chunks/{update-relaunch-ON5MDJQG.js → update-relaunch-VWNPYDIP.js} +5 -5
  279. package/chunks/updateCheck-KAQH67DV.js +91 -0
  280. package/chunks/useAutoAcceptIndicator-JH6BCF7S.js +92 -0
  281. package/chunks/{validateNonInterActiveAuth-JBLKBKRD.js → validateNonInterActiveAuth-GIUJ2UFS.js} +88 -88
  282. package/chunks/{version-LTNUBQJY.js → version-BGLYIJUY.js} +1 -1
  283. package/chunks/{web-fetch-L5UTI53V.js → web-fetch-OTDU4VQF.js} +19 -21
  284. package/chunks/{web-search-KM33JOS3.js → web-search-FP6SIHPR.js} +13 -13
  285. package/chunks/{workflow-K7FAWV77.js → workflow-YCIVBYSB.js} +48 -50
  286. package/chunks/workspace-providers-status-S35YAIUS.js +85 -0
  287. package/chunks/{workspace-registration-store-6TGVDJV5.js → workspace-registration-store-OTMS3H4C.js} +1 -1
  288. package/chunks/workspace-registry-O63R6IZ4.js +92 -0
  289. package/chunks/workspace-service-M6LLHKJ5.js +99 -0
  290. package/chunks/workspace-skills-status-C2V7BAIS.js +85 -0
  291. package/chunks/workspace-trust-reconciler-IBUPOUJN.js +345 -0
  292. package/chunks/write-file-3BZC3EAE.js +72 -0
  293. package/chunks/xterm-headless-NTYVIBT3.js +3475 -0
  294. package/chunks/{zh-LUIGBD55.js → zh-H3YDK5QW.js} +9 -1
  295. package/chunks/{zh-TW-F5KG2IYD.js → zh-TW-JYCP7XUA.js} +9 -1
  296. package/chunks/zoom-image-TZ6S2O57.js +351 -0
  297. package/cli.js +13 -13
  298. package/locales/ca.js +7 -2
  299. package/locales/de.js +7 -2
  300. package/locales/en.js +10 -2
  301. package/locales/fr.js +7 -2
  302. package/locales/ja.js +7 -2
  303. package/locales/pt.js +7 -2
  304. package/locales/ru.js +7 -2
  305. package/locales/zh-TW.js +10 -2
  306. package/locales/zh.js +10 -2
  307. package/package.json +5 -4
  308. package/web-shell/assets/{arc-BbHijhiN.js → arc-75-Wdeo3.js} +1 -1
  309. package/web-shell/assets/{architectureDiagram-3BPJPVTR-Cb4B_JD0.js → architectureDiagram-3BPJPVTR-FKeXQbyP.js} +1 -1
  310. package/web-shell/assets/{blockDiagram-GPEHLZMM-Dsjlh3H-.js → blockDiagram-GPEHLZMM-CY0vc-A3.js} +1 -1
  311. package/web-shell/assets/{c4Diagram-AAUBKEIU-Cp5AeR4U.js → c4Diagram-AAUBKEIU-CNP-A-8u.js} +1 -1
  312. package/web-shell/assets/channel-DPYMT76A.js +1 -0
  313. package/web-shell/assets/{chunk-2J33WTMH-CLcY7W2e.js → chunk-2J33WTMH-GybS4Gii.js} +1 -1
  314. package/web-shell/assets/{chunk-4BX2VUAB-BUhvY2LR.js → chunk-4BX2VUAB-02H91V8v.js} +1 -1
  315. package/web-shell/assets/{chunk-55IACEB6-kDIFC_71.js → chunk-55IACEB6-D3M-2VT6.js} +1 -1
  316. package/web-shell/assets/{chunk-727SXJPM-CIBO15f2.js → chunk-727SXJPM-CCu29u4H.js} +1 -1
  317. package/web-shell/assets/{chunk-AQP2D5EJ-BJ_T_slV.js → chunk-AQP2D5EJ-CaFKWgrn.js} +1 -1
  318. package/web-shell/assets/{chunk-FMBD7UC4-BEkW35J8.js → chunk-FMBD7UC4-ZZpPqIwQ.js} +1 -1
  319. package/web-shell/assets/{chunk-ND2GUHAM-GGPxofay.js → chunk-ND2GUHAM-D22DqGs8.js} +1 -1
  320. package/web-shell/assets/{chunk-QZHKN3VN-Bifllrb6.js → chunk-QZHKN3VN-Bu85S0fw.js} +1 -1
  321. package/web-shell/assets/classDiagram-4FO5ZUOK--JstsIgL.js +1 -0
  322. package/web-shell/assets/classDiagram-v2-Q7XG4LA2--JstsIgL.js +1 -0
  323. package/web-shell/assets/{cose-bilkent-S5V4N54A-C-Add_Dp.js → cose-bilkent-S5V4N54A-f1CK1Gwe.js} +1 -1
  324. package/web-shell/assets/{dagre-BM42HDAG-B7MfwNq2.js → dagre-BM42HDAG-D0Ow8F_n.js} +1 -1
  325. package/web-shell/assets/{diagram-2AECGRRQ-CY_0zuDz.js → diagram-2AECGRRQ-BPrmTWp8.js} +1 -1
  326. package/web-shell/assets/{diagram-5GNKFQAL-VyYSbCgA.js → diagram-5GNKFQAL-HccuFAzy.js} +1 -1
  327. package/web-shell/assets/{diagram-KO2AKTUF-CBiIZ2PL.js → diagram-KO2AKTUF-BrS76mbA.js} +1 -1
  328. package/web-shell/assets/{diagram-LMA3HP47-BL3CrVOx.js → diagram-LMA3HP47-V7T9lU-5.js} +1 -1
  329. package/web-shell/assets/{diagram-OG6HWLK6-CZUPx96P.js → diagram-OG6HWLK6-DKidyJMR.js} +1 -1
  330. package/web-shell/assets/{erDiagram-TEJ5UH35-B81xHr1-.js → erDiagram-TEJ5UH35-DBadZIkp.js} +1 -1
  331. package/web-shell/assets/{flowDiagram-I6XJVG4X-EZWhir-J.js → flowDiagram-I6XJVG4X-BymfqdNJ.js} +1 -1
  332. package/web-shell/assets/{ganttDiagram-6RSMTGT7-CVFSuIAg.js → ganttDiagram-6RSMTGT7-DOw340jf.js} +1 -1
  333. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-C1H2uQDv.js → gitGraphDiagram-PVQCEYII-_8EiD8sl.js} +1 -1
  334. package/web-shell/assets/{index-BYo99NBH.js → index-CKIadvET.js} +1 -1
  335. package/web-shell/assets/index-D1eXNRHe.js +1389 -0
  336. package/web-shell/assets/index-DVLD4CQq.css +5 -0
  337. package/web-shell/assets/{infoDiagram-5YYISTIA-BwyFMlF8.js → infoDiagram-5YYISTIA-D61KYQBu.js} +1 -1
  338. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-CQ7Yhn2Y.js → ishikawaDiagram-YF4QCWOH-CsiXSpNx.js} +1 -1
  339. package/web-shell/assets/{journeyDiagram-JHISSGLW-CJn2sf0l.js → journeyDiagram-JHISSGLW-Sdfionyh.js} +1 -1
  340. package/web-shell/assets/{kanban-definition-UN3LZRKU-DaNRqwVN.js → kanban-definition-UN3LZRKU-C3WI3Cnl.js} +1 -1
  341. package/web-shell/assets/{linear-DCKODZe2.js → linear-Dpigcc62.js} +1 -1
  342. package/web-shell/assets/{mermaid.core-CTGJOk27.js → mermaid.core-Ct97pqgW.js} +5 -5
  343. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BKU3_3rg.js → mindmap-definition-RKZ34NQL-BzeaN0rB.js} +1 -1
  344. package/web-shell/assets/{pieDiagram-4H26LBE5-COcwBJ82.js → pieDiagram-4H26LBE5-CvjgcbVD.js} +1 -1
  345. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-CQnQ443x.js → quadrantDiagram-W4KKPZXB-BUzgTNdH.js} +1 -1
  346. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CZ2oj5cD.js → requirementDiagram-4Y6WPE33-B7zKlgUQ.js} +1 -1
  347. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BxAv5mNu.js → sankeyDiagram-5OEKKPKP-Bb9CQgrT.js} +1 -1
  348. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CztaySPs.js → sequenceDiagram-3UESZ5HK-DJ6V7itG.js} +1 -1
  349. package/web-shell/assets/{stateDiagram-AJRCARHV-CTQT1oGD.js → stateDiagram-AJRCARHV-IImflERY.js} +1 -1
  350. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-CYI_YoNR.js +1 -0
  351. package/web-shell/assets/{timeline-definition-PNZ67QCA-K9Mkex5A.js → timeline-definition-PNZ67QCA-6Q_uWHKh.js} +1 -1
  352. package/web-shell/assets/{vennDiagram-CIIHVFJN-B2rVIw76.js → vennDiagram-CIIHVFJN-TmyKyjwv.js} +1 -1
  353. package/web-shell/assets/{wardley-L42UT6IY-Z1w2JR4M.js → wardley-L42UT6IY-CRh9uiPv.js} +1 -1
  354. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-CIX9aKXf.js → wardleyDiagram-YWT4CUSO-59TKAW8w.js} +1 -1
  355. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CI9DLIKB.js → xychartDiagram-2RQKCTM6-GCSUIK2L.js} +1 -1
  356. package/web-shell/index.html +2 -2
  357. package/chunks/MaxSizedBox-INHRH72H.js +0 -86
  358. package/chunks/agent-VXDAN5JK.js +0 -82
  359. package/chunks/agent-headless-K4ZMMNBD.js +0 -76
  360. package/chunks/bridge-LGPZCFHO.js +0 -91
  361. package/chunks/channel-settings-store-CHCDRTPY.js +0 -89
  362. package/chunks/chunk-SZRN75WQ.js +0 -29
  363. package/chunks/chunk-UGYMA4EI.js +0 -219
  364. package/chunks/chunk-VCBZUOSI.js +0 -8575
  365. package/chunks/contextCommand-QIZYHDR5.js +0 -81
  366. package/chunks/daemon-status-provider-OS5UWBHV.js +0 -90
  367. package/chunks/earlyInputCapture-WQT24RWD.js +0 -83
  368. package/chunks/errors-PCX25DVP.js +0 -89
  369. package/chunks/exitPlanMode-GHPUHBZJ.js +0 -423
  370. package/chunks/handleAutoUpdate-2CZQRJ66.js +0 -82
  371. package/chunks/i18n-XEQVMRKN.js +0 -98
  372. package/chunks/initializer-OVGZ4FLY.js +0 -87
  373. package/chunks/installationInfo-5UUQJI6Y.js +0 -81
  374. package/chunks/list-HODU6RXD.js +0 -90
  375. package/chunks/loadedSettingsAdapter-TYNLBALY.js +0 -84
  376. package/chunks/mcp-J3DFWX4A.js +0 -84
  377. package/chunks/nonInteractiveCli-F4GYSMHT.js +0 -144
  378. package/chunks/pidfile-4VNAR3EP.js +0 -87
  379. package/chunks/read-file-LZXUR4TO.js +0 -31
  380. package/chunks/resumeHistoryUtils-65OX3SGJ.js +0 -92
  381. package/chunks/ripGrep-2U2FRGMV.js +0 -74
  382. package/chunks/serve-W2GC47CM.js +0 -90
  383. package/chunks/shell-45IPBDP5.js +0 -84
  384. package/chunks/spawnChannel-PVXQ5AGV.js +0 -83
  385. package/chunks/src-AY65BYR7.js +0 -3166
  386. package/chunks/standalone-update-ZMFNKAEY.js +0 -93
  387. package/chunks/theme-manager-YYPZFBAH.js +0 -78
  388. package/chunks/total-session-admission-JXES723M.js +0 -85
  389. package/chunks/trustedFolders-HVI7IXUH.js +0 -94
  390. package/chunks/updateCheck-WUJGHWZZ.js +0 -93
  391. package/chunks/useAutoAcceptIndicator-CHSTZLZD.js +0 -94
  392. package/chunks/workspace-providers-status-GAKSF4LL.js +0 -87
  393. package/chunks/workspace-registry-A7NQUONG.js +0 -89
  394. package/chunks/workspace-service-STGVSO4N.js +0 -99
  395. package/chunks/workspace-skills-status-66AK3DUA.js +0 -86
  396. package/chunks/write-file-HUUCEG4P.js +0 -74
  397. package/web-shell/assets/channel-Bzdx6E8P.js +0 -1
  398. package/web-shell/assets/classDiagram-4FO5ZUOK-Cd6wbiuK.js +0 -1
  399. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Cd6wbiuK.js +0 -1
  400. package/web-shell/assets/index-B2bXx96W.js +0 -1249
  401. package/web-shell/assets/index-_8mKjx8q.css +0 -5
  402. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BjMdT6E_.js +0 -1
  403. package/chunks/{chunk-TARRHLLG.js → chunk-QUGAUQGJ.js} +25 -25
  404. package/chunks/{chunk-U7ZFW55U.js → chunk-VOQXFAY5.js} +977 -977
  405. /package/chunks/{chunk-LXXMOYPL.js → chunk-VXZBKKQR.js} +0 -0
@@ -35,37 +35,38 @@ import {
35
35
  require_express,
36
36
  resolveWebShellDir,
37
37
  setDeferredRuntimeRequestTiming
38
- } from "./chunk-3JAQDSXN.js";
38
+ } from "./chunk-YGF33UXG.js";
39
39
  import {
40
40
  isLoopbackBind
41
41
  } from "./chunk-RXFQM6FQ.js";
42
42
  import {
43
43
  DEFAULT_COMPACTED_REPLAY_MAX_BYTES,
44
- normalizeCompactedReplayMaxBytes
45
- } from "./chunk-COH43MRJ.js";
46
- import {
47
- LOAD_REPLAY_META_KEY
48
- } from "./chunk-3SJ43L4W.js";
44
+ DEFAULT_MAX_JOURNAL_BYTES,
45
+ DEFAULT_MAX_JOURNAL_EVENTS,
46
+ normalizeCompactedReplayMaxBytes,
47
+ normalizeMaxJournalBytes,
48
+ normalizeMaxJournalEvents
49
+ } from "./chunk-XCGIMOLN.js";
49
50
  import "./chunk-WBL3FJEU.js";
50
- import "./chunk-T2NCM2ET.js";
51
51
  import {
52
52
  resolveChannelCwd
53
- } from "./chunk-W4CQXHT6.js";
54
- import {
55
- loadServeFastPathSettings,
56
- preResolveServeFastPathHomeEnvOverrides
57
- } from "./chunk-D3UEZIQH.js";
53
+ } from "./chunk-TFRMVU6R.js";
58
54
  import {
59
55
  MAX_REGISTERED_WORKSPACES,
60
56
  resolveWorkspaceInputs,
61
57
  workspaceRegistrationId
62
- } from "./chunk-CC4N4M36.js";
58
+ } from "./chunk-AQIDMUGU.js";
59
+ import "./chunk-T2QMKU3R.js";
60
+ import {
61
+ LOAD_REPLAY_META_KEY
62
+ } from "./chunk-XZC5VLBZ.js";
63
+ import "./chunk-B4AJNNOL.js";
63
64
  import {
64
65
  canonicalizeWorkspace,
65
66
  translateAndCheckAbsoluteWorkspacePath
66
67
  } from "./chunk-2RFKHEXL.js";
67
- import "./chunk-3MSHSCSN.js";
68
- import "./chunk-N3FAY5CM.js";
68
+ import "./chunk-GNR2RNMP.js";
69
+ import "./chunk-FYJ7W2PI.js";
69
70
  import {
70
71
  ChannelDeliveryError,
71
72
  ChannelWebhookEnqueueError,
@@ -75,17 +76,22 @@ import {
75
76
  import {
76
77
  normalizeWorkerDiagnostic,
77
78
  sanitizeWorkerDiagnostic
78
- } from "./chunk-HV3G62R6.js";
79
+ } from "./chunk-GZ3RCT54.js";
79
80
  import {
80
81
  channelSelectionNames
81
82
  } from "./chunk-ALMR3E6Q.js";
82
83
  import "./chunk-BK2UNYWD.js";
83
84
  import "./chunk-M5GB774H.js";
85
+ import "./chunk-5HBA2Z7V.js";
86
+ import "./chunk-T2NCM2ET.js";
84
87
  import {
85
88
  sanitizeLogText
86
- } from "./chunk-ML52PL6O.js";
89
+ } from "./chunk-7I5GTCT4.js";
87
90
  import "./chunk-UDXSXLER.js";
88
- import "./chunk-5HBA2Z7V.js";
91
+ import {
92
+ loadServeFastPathSettings,
93
+ preResolveServeFastPathHomeEnvOverrides
94
+ } from "./chunk-D3UEZIQH.js";
89
95
  import "./chunk-GOXKNSDZ.js";
90
96
  import {
91
97
  getGlobalQwenDirLite,
@@ -94,7 +100,7 @@ import {
94
100
  import "./chunk-6PEXNQTX.js";
95
101
  import {
96
102
  getCliVersion
97
- } from "./chunk-I7XZ3RY5.js";
103
+ } from "./chunk-VYOXCEPJ.js";
98
104
  import "./chunk-VJNBRRZG.js";
99
105
  import "./chunk-ALGGS7UH.js";
100
106
  import {
@@ -104,9 +110,9 @@ import {
104
110
  writeStderrLine,
105
111
  writeStdoutLine
106
112
  } from "./chunk-OWAK7LMW.js";
107
- import "./chunk-5M6IDOMF.js";
108
113
  import "./chunk-TWPJO254.js";
109
114
  import "./chunk-H6XPXXMH.js";
115
+ import "./chunk-5M6IDOMF.js";
110
116
  import {
111
117
  require_proper_lockfile
112
118
  } from "./chunk-KRXPRVGL.js";
@@ -2494,6 +2500,13 @@ function formatHostForUrl(host) {
2494
2500
  return host;
2495
2501
  }
2496
2502
  __name(formatHostForUrl, "formatHostForUrl");
2503
+ function workspaceRuntimeEffectiveEnv(runtime, daemonEnv) {
2504
+ if (runtime.env.mode === "runtime-overlay") {
2505
+ return runtime.env.effectiveEnv ?? {};
2506
+ }
2507
+ return runtime.env.effectiveEnv ?? daemonEnv;
2508
+ }
2509
+ __name(workspaceRuntimeEffectiveEnv, "workspaceRuntimeEffectiveEnv");
2497
2510
  function formatChannelWorkerDaemonUrl(host, port) {
2498
2511
  const normalized = host.trim().toLowerCase();
2499
2512
  if (normalized === "" || normalized === "0.0.0.0" || normalized === "::" || normalized === "[::]") {
@@ -2531,15 +2544,16 @@ function withSettingsLock(workspace, fn) {
2531
2544
  return next;
2532
2545
  }
2533
2546
  __name(withSettingsLock, "withSettingsLock");
2547
+ var retryableChannelWorkerShutdownErrors = /* @__PURE__ */ new WeakSet();
2534
2548
  var channelWorkerRuntimePromise;
2535
2549
  async function loadChannelWorkerRuntime() {
2536
2550
  channelWorkerRuntimePromise ??= Promise.all([
2537
- import("./channel-worker-supervisor-KUFTR6P5.js"),
2538
- import("./pidfile-4VNAR3EP.js"),
2539
- import("./runtime-AXJWIEDU.js"),
2551
+ import("./channel-worker-supervisor-74HTWA2G.js"),
2552
+ import("./pidfile-6ERW3DF4.js"),
2553
+ import("./runtime-DAUPSUKI.js"),
2540
2554
  import("./cli-entry-path-4VJ3Y6T2.js"),
2541
- import("./channel-worker-group-PTJIJSKC.js"),
2542
- import("./channel-worker-manager-WIMGM2FD.js")
2555
+ import("./channel-worker-group-XDPTDWTX.js"),
2556
+ import("./channel-worker-manager-YYEHVRRE.js")
2543
2557
  ]).then(
2544
2558
  ([
2545
2559
  supervisor,
@@ -2644,7 +2658,7 @@ function shouldPreheatBridge(deps) {
2644
2658
  __name(shouldPreheatBridge, "shouldPreheatBridge");
2645
2659
  var coreRuntimePromise;
2646
2660
  function loadCoreRuntime() {
2647
- coreRuntimePromise ??= import("./src-AY65BYR7.js");
2661
+ coreRuntimePromise ??= import("./core-runtime-3XEYLQFK.js");
2648
2662
  return coreRuntimePromise;
2649
2663
  }
2650
2664
  __name(loadCoreRuntime, "loadCoreRuntime");
@@ -2674,10 +2688,10 @@ __name(resolveDaemonLogBaseDirForRun, "resolveDaemonLogBaseDirForRun");
2674
2688
  var settingsRuntimePromise;
2675
2689
  function loadSettingsRuntimeModules() {
2676
2690
  settingsRuntimePromise ??= Promise.all([
2677
- import("./settings-7ZGZDXAS.js"),
2678
- import("./environment-VZ7BRI4Q.js"),
2679
- import("./loadedSettingsAdapter-TYNLBALY.js"),
2680
- import("./trustedFolders-HVI7IXUH.js")
2691
+ import("./settings-DJDXFDZ3.js"),
2692
+ import("./environment-XXQ75D2Q.js"),
2693
+ import("./loadedSettingsAdapter-SPUTNKAV.js"),
2694
+ import("./trustedFolders-X2JEIO57.js")
2681
2695
  ]).then(([settings, environment, loadedSettingsAdapter, trustedFolders]) => ({
2682
2696
  settings,
2683
2697
  environment,
@@ -2690,8 +2704,8 @@ __name(loadSettingsRuntimeModules, "loadSettingsRuntimeModules");
2690
2704
  var channelWebhookConfigRuntimePromise;
2691
2705
  function loadChannelWebhookConfigRuntime() {
2692
2706
  channelWebhookConfigRuntimePromise ??= Promise.all([
2693
- import("./runtime-AXJWIEDU.js"),
2694
- import("./config-utils-VFQXVGNR.js")
2707
+ import("./runtime-DAUPSUKI.js"),
2708
+ import("./config-utils-NYSXDMEQ.js")
2695
2709
  ]).then(([channelRuntime, configUtils]) => ({
2696
2710
  loadChannelsConfig: channelRuntime.loadChannelsConfig,
2697
2711
  parseChannelWebhookConfig: configUtils.parseChannelWebhookConfig
@@ -2707,6 +2721,7 @@ async function loadServeRuntimeModules() {
2707
2721
  serverModule,
2708
2722
  bridgeModule,
2709
2723
  spawnChannelModule,
2724
+ processRegistryModule,
2710
2725
  workspaceModule,
2711
2726
  workspaceTypesModule,
2712
2727
  daemonStatusProviderModule,
@@ -2715,16 +2730,17 @@ async function loadServeRuntimeModules() {
2715
2730
  totalSessionAdmissionModule,
2716
2731
  workspaceRegistryModule
2717
2732
  ] = await Promise.all([
2718
- import("./server-HRZ23U7M.js"),
2719
- import("./bridge-LGPZCFHO.js"),
2720
- import("./spawnChannel-PVXQ5AGV.js"),
2721
- import("./workspace-service-STGVSO4N.js"),
2733
+ import("./server-WEH7DVCH.js"),
2734
+ import("./bridge-3KJEWDNE.js"),
2735
+ import("./spawnChannel-ETMJW7YX.js"),
2736
+ import("./process-registry-2CHQBXH5.js"),
2737
+ import("./workspace-service-M6LLHKJ5.js"),
2722
2738
  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")
2739
+ import("./daemon-status-provider-3XJI6CAL.js"),
2740
+ import("./workspace-providers-status-S35YAIUS.js"),
2741
+ import("./workspace-skills-status-C2V7BAIS.js"),
2742
+ import("./total-session-admission-44JKRWQD.js"),
2743
+ import("./workspace-registry-O63R6IZ4.js")
2728
2744
  ]);
2729
2745
  return {
2730
2746
  createServeApp: serverModule.createServeApp,
@@ -2733,6 +2749,7 @@ async function loadServeRuntimeModules() {
2733
2749
  resolveBridgeFsFactory: serverModule.resolveBridgeFsFactory,
2734
2750
  createAcpSessionBridge: bridgeModule.createAcpSessionBridge,
2735
2751
  createSpawnChannelFactory: spawnChannelModule.createSpawnChannelFactory,
2752
+ ProcessRegistry: processRegistryModule.ProcessRegistry,
2736
2753
  createDaemonWorkspaceService: workspaceModule.createDaemonWorkspaceService,
2737
2754
  WorkspaceSettingsPartialPersistError: workspaceTypesModule.WorkspaceSettingsPartialPersistError,
2738
2755
  WorkspaceSkillNotToggleableError: workspaceTypesModule.WorkspaceSkillNotToggleableError,
@@ -2741,7 +2758,8 @@ async function loadServeRuntimeModules() {
2741
2758
  createWorkspaceSkillsStatusProvider: workspaceSkillsStatusModule.createWorkspaceSkillsStatusProvider,
2742
2759
  createTotalSessionAdmissionController: totalSessionAdmissionModule.createTotalSessionAdmissionController,
2743
2760
  createWorkspaceRegistry: workspaceRegistryModule.createWorkspaceRegistry,
2744
- createWorkspaceSessionOwnerIndex: workspaceRegistryModule.createWorkspaceSessionOwnerIndex
2761
+ createWorkspaceSessionOwnerIndex: workspaceRegistryModule.createWorkspaceSessionOwnerIndex,
2762
+ createWorkspaceGenerationGuard: workspaceRegistryModule.createWorkspaceGenerationGuard
2745
2763
  };
2746
2764
  }
2747
2765
  __name(loadServeRuntimeModules, "loadServeRuntimeModules");
@@ -3090,6 +3108,8 @@ function createBootstrapServeApp(input) {
3090
3108
  listenerMaxConnections: listenerMaxConnections(opts.maxConnections),
3091
3109
  eventRingSize: opts.eventRingSize ?? DEFAULT_EVENT_RING_SIZE,
3092
3110
  compactedReplayMaxBytes: opts.compactedReplayMaxBytes ?? DEFAULT_COMPACTED_REPLAY_MAX_BYTES,
3111
+ maxJournalEvents: opts.maxJournalEvents ?? DEFAULT_MAX_JOURNAL_EVENTS,
3112
+ maxJournalBytes: opts.maxJournalBytes ?? DEFAULT_MAX_JOURNAL_BYTES,
3093
3113
  promptDeadlineMs: positiveFiniteOrNull(opts.promptDeadlineMs),
3094
3114
  writerIdleTimeoutMs: positiveFiniteOrNull(opts.writerIdleTimeoutMs),
3095
3115
  channelIdleTimeoutMs: channelIdleTimeoutMs(opts.channelIdleTimeoutMs),
@@ -3613,7 +3633,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3613
3633
  }
3614
3634
  let workspaceRegistrationStore = deps.workspaceRegistrationStore;
3615
3635
  if (workspaceRegistrationStore === void 0 && process.env["QWEN_SERVE_NO_PERSISTENT_REGISTRATION"] !== "1") {
3616
- const { WorkspaceRegistrationStore } = await import("./workspace-registration-store-6TGVDJV5.js");
3636
+ const { WorkspaceRegistrationStore } = await import("./workspace-registration-store-OTMS3H4C.js");
3617
3637
  workspaceRegistrationStore = new WorkspaceRegistrationStore(boundWorkspace);
3618
3638
  }
3619
3639
  if (workspaceRegistrationStore) {
@@ -3768,6 +3788,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3768
3788
  if (opts.compactedReplayMaxBytes !== void 0) {
3769
3789
  normalizeCompactedReplayMaxBytes(opts.compactedReplayMaxBytes);
3770
3790
  }
3791
+ if (opts.maxJournalEvents !== void 0) {
3792
+ normalizeMaxJournalEvents(opts.maxJournalEvents);
3793
+ }
3794
+ if (opts.maxJournalBytes !== void 0) {
3795
+ normalizeMaxJournalBytes(opts.maxJournalBytes);
3796
+ }
3771
3797
  if (opts.writerIdleTimeoutMs !== void 0) {
3772
3798
  if (!isPositiveIntegerMs(opts.writerIdleTimeoutMs)) {
3773
3799
  throw new TypeError(
@@ -3852,6 +3878,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3852
3878
  let runtimeApp;
3853
3879
  let runtimeAppForCleanup;
3854
3880
  let bridgeRef = deps.bridge;
3881
+ let managedProcessRegistry;
3855
3882
  const internalRuntimeBridgesForCleanup = [];
3856
3883
  let daemonEventLoopMonitor;
3857
3884
  let daemonMetricsSampler;
@@ -4018,6 +4045,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4018
4045
  const disposedRuntimeApps = /* @__PURE__ */ new WeakSet();
4019
4046
  const stoppedRuntimeAppProducers = /* @__PURE__ */ new WeakSet();
4020
4047
  const stoppedExtensionReconcilers = /* @__PURE__ */ new WeakSet();
4048
+ const stoppedTrustPolicyMonitors = /* @__PURE__ */ new WeakSet();
4049
+ const stopTrustPolicyMonitor = /* @__PURE__ */ __name((app2) => {
4050
+ if (!app2 || stoppedTrustPolicyMonitors.has(app2)) return;
4051
+ stoppedTrustPolicyMonitors.add(app2);
4052
+ const stop = app2.locals?.["stopTrustPolicyMonitor"];
4053
+ try {
4054
+ stop?.();
4055
+ } catch (err) {
4056
+ daemonLog.warn(
4057
+ `trust policy monitor dispose error: ${err instanceof Error ? err.message : String(err)}`
4058
+ );
4059
+ }
4060
+ }, "stopTrustPolicyMonitor");
4021
4061
  const stopExtensionReconciler = /* @__PURE__ */ __name((app2) => {
4022
4062
  if (!app2 || stoppedExtensionReconcilers.has(app2)) return;
4023
4063
  stoppedExtensionReconcilers.add(app2);
@@ -4045,6 +4085,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4045
4085
  }, "stopSafely");
4046
4086
  stopSafely("scheduled-task keepalive", locals.stopScheduledTaskKeepalive);
4047
4087
  stopSafely("workspace git state", locals.stopWorkspaceGitState);
4088
+ stopTrustPolicyMonitor(app2);
4048
4089
  for (const stop of locals.subSessionStoppers ?? []) {
4049
4090
  stopSafely("sub-session launcher", stop);
4050
4091
  }
@@ -4098,13 +4139,23 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4098
4139
  return [...new Set(bridges)];
4099
4140
  }, "getRuntimeBridgesForCleanup");
4100
4141
  const buildRuntime = /* @__PURE__ */ __name(async () => {
4101
- const [runtime, core, settingsRuntime, resolvedCliVersion] = await Promise.all([
4142
+ const [runtime, core, settingsRuntime, resolvedCliVersion, trustPolicy] = await Promise.all([
4102
4143
  loadServeRuntimeModules(),
4103
4144
  loadCoreRuntime(),
4104
4145
  loadSettingsRuntimeModules(),
4105
- cliVersionPromise
4146
+ cliVersionPromise,
4147
+ import("./daemon-trust-policy-ILUDTLHD.js")
4106
4148
  ]);
4107
4149
  cliVersion = resolvedCliVersion;
4150
+ settingsRuntime.environment.preResolveHomeEnvOverrides();
4151
+ const bootTrustSnapshot = await trustPolicy.readDaemonTrustPolicySnapshot();
4152
+ let latestTrustPolicySnapshot = bootTrustSnapshot;
4153
+ const bootPrimaryTrustDecision = trustPolicy.evaluateDaemonWorkspaceTrust(
4154
+ bootTrustSnapshot,
4155
+ boundWorkspace
4156
+ );
4157
+ const trustedWorkspace = deps.trustedWorkspace ?? bootPrimaryTrustDecision.targetTrusted;
4158
+ const workspaceTrustHotReloadAvailable = deps.trustedWorkspace === void 0 && deps.bridge === void 0 && deps.fsFactory === void 0;
4108
4159
  let managedScratchRoot;
4109
4160
  try {
4110
4161
  managedScratchRoot = prepareManagedScratchRoot(
@@ -4118,16 +4169,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4118
4169
  }
4119
4170
  let runtimeBootSettings;
4120
4171
  try {
4121
- runtimeBootSettings = settingsRuntime.settings.loadSettings(boundWorkspace);
4172
+ runtimeBootSettings = settingsRuntime.settings.loadSettings(
4173
+ boundWorkspace,
4174
+ {
4175
+ skipLoadEnvironment: true,
4176
+ skipWorkspaceSettings: !trustedWorkspace,
4177
+ workspaceTrusted: trustedWorkspace
4178
+ }
4179
+ );
4122
4180
  } catch (err) {
4123
4181
  writeStderrLine(
4124
4182
  `qwen serve: could not read full settings for runtime startup (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4125
4183
  );
4126
4184
  }
4127
- const trustedWorkspace = deps.trustedWorkspace ?? (runtimeBootSettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4128
- runtimeBootSettings.merged,
4129
- boundWorkspace
4130
- ).effective.state === "trusted" : true);
4131
4185
  if (deps.trustedWorkspace === void 0 && runtimeBootSettings && !trustedWorkspace) {
4132
4186
  daemonLog.warn(
4133
4187
  "workspace file writes are disabled because the bound workspace is not trusted",
@@ -4137,7 +4191,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4137
4191
  const runtimeEnvSnapshot = runtimeBootSettings ? settingsRuntime.environment.buildRuntimeEnvironment(
4138
4192
  runtimeBootSettings.merged,
4139
4193
  boundWorkspace,
4140
- daemonRuntimeBaseEnv
4194
+ daemonRuntimeBaseEnv,
4195
+ trustedWorkspace
4141
4196
  ) : {
4142
4197
  effectiveEnv: { ...daemonRuntimeBaseEnv },
4143
4198
  overlayKeys: Object.freeze([]),
@@ -4308,17 +4363,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4308
4363
  void 0,
4309
4364
  (workspace, index) => {
4310
4365
  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,
4366
+ const trustedSecondary = trustPolicy.evaluateDaemonWorkspaceTrust(
4367
+ bootTrustSnapshot,
4320
4368
  workspace
4321
- ).effective.state === "trusted";
4369
+ ).targetTrusted;
4322
4370
  if (!trustedSecondary) {
4323
4371
  daemonLog.warn(
4324
4372
  "excluding untrusted secondary workspace root from file-system access",
@@ -4333,7 +4381,16 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4333
4381
  secondary: boundWorkspaces.slice(1),
4334
4382
  ideEnvPresent: !!process.env["QWEN_CODE_IDE_WORKSPACE_PATH"]
4335
4383
  });
4384
+ const primaryGenerationGuard = runtime.createWorkspaceGenerationGuard();
4385
+ const primaryTrustMaterialization = JSON.stringify({
4386
+ trusted: trustedWorkspace,
4387
+ boundWorkspaces: [...boundWorkspaces].sort()
4388
+ });
4336
4389
  const sharedPathLocks = new PathMutexRegistry();
4390
+ const workspaceTrustOperationGate = new PathMutexRegistry();
4391
+ const runWorkspaceTrustOperation = /* @__PURE__ */ __name((operation) => workspaceTrustOperationGate.runExclusive("runtime-topology", operation), "runWorkspaceTrustOperation");
4392
+ const processRegistry = new runtime.ProcessRegistry();
4393
+ managedProcessRegistry = processRegistry;
4337
4394
  const fsFactory = runtime.resolveBridgeFsFactory({
4338
4395
  // Secondary roots share a write-capable factory only after their own
4339
4396
  // folder trust check passes; untrusted secondary roots stay outside.
@@ -4342,6 +4399,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4342
4399
  trusted: trustedWorkspace,
4343
4400
  emit: deps.fsAuditEmit,
4344
4401
  pathLocks: sharedPathLocks,
4402
+ generationGuard: primaryGenerationGuard,
4345
4403
  ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4346
4404
  });
4347
4405
  const routeFsFactory = runtime.resolveBridgeFsFactory({
@@ -4351,9 +4409,11 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4351
4409
  trusted: trustedWorkspace,
4352
4410
  emit: deps.fsAuditEmit,
4353
4411
  pathLocks: sharedPathLocks,
4412
+ generationGuard: primaryGenerationGuard,
4354
4413
  ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4355
4414
  });
4356
4415
  const channelFactory = runtime.createSpawnChannelFactory({
4416
+ processRegistry,
4357
4417
  sourceEnv: runtimeEffectiveEnv,
4358
4418
  onDiagnosticLine: diagnosticSink,
4359
4419
  pipeHooks: {
@@ -4371,9 +4431,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4371
4431
  env: runtimeEffectiveEnv
4372
4432
  });
4373
4433
  const workspaceProvidersStatusProvider = runtime.createWorkspaceProvidersStatusProvider({
4374
- env: runtimeEffectiveEnv
4434
+ env: runtimeEffectiveEnv,
4435
+ workspaceTrusted: trustedWorkspace
4436
+ });
4437
+ const workspaceSkillsStatusProvider = runtime.createWorkspaceSkillsStatusProvider({
4438
+ workspaceTrusted: trustedWorkspace
4375
4439
  });
4376
- const workspaceSkillsStatusProvider = runtime.createWorkspaceSkillsStatusProvider();
4377
4440
  const clientMcpSenderRegistry = new ClientMcpSenderRegistry();
4378
4441
  const runtimeBridges = [];
4379
4442
  const totalSessionAdmission = runtime.createTotalSessionAdmissionController(
@@ -4383,84 +4446,108 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4383
4446
  }
4384
4447
  );
4385
4448
  const sessionOwnerIndex = runtime.createWorkspaceSessionOwnerIndex();
4386
- const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled) => withSettingsLock(workspace, async () => {
4387
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4449
+ const workspaceRegistryForPersistence = { current: void 0 };
4450
+ const isWorkspaceTrustedForPersistence = /* @__PURE__ */ __name((workspace) => workspaceRegistryForPersistence.current?.getByWorkspaceCwd(workspace)?.trusted ?? (workspaceRegistryForPersistence.current === void 0 && workspace === boundWorkspace && trustedWorkspace), "isWorkspaceTrustedForPersistence");
4451
+ const loadSettingsForPersistence = /* @__PURE__ */ __name((workspace) => {
4452
+ const trusted = isWorkspaceTrustedForPersistence(workspace);
4453
+ return settingsRuntime.settings.loadSettings(workspace, {
4454
+ skipLoadEnvironment: true,
4455
+ skipWorkspaceSettings: !trusted,
4456
+ workspaceTrusted: trusted
4457
+ });
4458
+ }, "loadSettingsForPersistence");
4459
+ const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4460
+ assertGenerationOpen?.();
4461
+ const fresh = loadSettingsForPersistence(workspace);
4388
4462
  const wsScope = fresh.forScope(WORKSPACE_SETTING_SCOPE).settings;
4389
4463
  const wsDisabled = wsScope.tools?.disabled;
4390
4464
  const current = Array.isArray(wsDisabled) ? wsDisabled.filter((v) => typeof v === "string") : [];
4391
4465
  const next = new Set(current);
4392
4466
  if (enabled) next.delete(toolName);
4393
4467
  else next.add(toolName);
4468
+ assertGenerationOpen?.();
4394
4469
  fresh.setValue(
4395
4470
  WORKSPACE_SETTING_SCOPE,
4396
4471
  "tools.disabled",
4397
- [...next].sort()
4472
+ [...next].sort(),
4473
+ assertGenerationOpen
4398
4474
  );
4399
4475
  }), "persistDisabledToolsFn");
4400
- const persistDisabledSkillsFn = /* @__PURE__ */ __name((workspace, skillName, enabled) => withSettingsLock(workspace, async () => {
4401
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4476
+ const persistDisabledSkillsFn = /* @__PURE__ */ __name((workspace, skillName, enabled, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4477
+ assertGenerationOpen?.();
4478
+ const {
4479
+ resolveSkillSettings,
4480
+ skillSettingStrings,
4481
+ updateWorkspaceSkillSettingLists
4482
+ } = await import("./skill-settings-VJ5PDMZI.js");
4483
+ const fresh = loadSettingsForPersistence(workspace);
4402
4484
  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
- }
4485
+ const resolved = resolveSkillSettings(fresh);
4486
+ const disablement = resolved.disablements.get(normalizedName);
4487
+ if (disablement?.reason === "hard" && disablement.lockedScope) {
4488
+ throw new runtime.WorkspaceSkillNotToggleableError(
4489
+ skillName,
4490
+ "locked",
4491
+ disablement.lockedScope
4492
+ );
4421
4493
  }
4422
- const workspaceDisabled = disabledNames(
4423
- fresh.workspace.settings.skills?.disabled
4494
+ const workspaceDisabled = skillSettingStrings(
4495
+ fresh,
4496
+ WORKSPACE_SETTING_SCOPE,
4497
+ "disabled"
4424
4498
  );
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
- }
4499
+ const workspaceEnabled = skillSettingStrings(
4500
+ fresh,
4501
+ WORKSPACE_SETTING_SCOPE,
4502
+ "enabled"
4503
+ );
4504
+ const next = updateWorkspaceSkillSettingLists(
4505
+ { disabled: workspaceDisabled, enabled: workspaceEnabled },
4506
+ skillName,
4507
+ enabled,
4508
+ resolved.defaultDisabledNames.has(normalizedName) && !resolved.enabledNames.has(normalizedName)
4509
+ );
4510
+ const settingsChanges = [];
4511
+ if (JSON.stringify(next.disabled) !== JSON.stringify(workspaceDisabled)) {
4512
+ settingsChanges.push({
4513
+ key: "skills.disabled",
4514
+ value: next.disabled.length > 0 ? next.disabled : void 0
4515
+ });
4444
4516
  }
4445
- if (!enabled && !found) {
4446
- next.push(skillName);
4447
- changed = true;
4517
+ if (JSON.stringify(next.enabled) !== JSON.stringify(workspaceEnabled)) {
4518
+ settingsChanges.push({
4519
+ key: "skills.enabled",
4520
+ value: next.enabled.length > 0 ? next.enabled : void 0
4521
+ });
4448
4522
  }
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
4523
+ if (settingsChanges.length === 0) {
4524
+ return { changed: false, disabled: workspaceDisabled };
4525
+ }
4526
+ assertGenerationOpen?.();
4527
+ fresh.setValues(
4528
+ settingsChanges.map((change) => ({
4529
+ scope: WORKSPACE_SETTING_SCOPE,
4530
+ ...change
4531
+ })),
4532
+ void 0,
4533
+ assertGenerationOpen
4454
4534
  );
4455
- return { changed: true, disabled: next };
4535
+ return {
4536
+ changed: true,
4537
+ disabled: next.disabled,
4538
+ settingsChanges
4539
+ };
4456
4540
  }), "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);
4541
+ const persistSettingFn = /* @__PURE__ */ __name((workspace, scope, key, value, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4542
+ assertGenerationOpen?.();
4543
+ const fresh = loadSettingsForPersistence(workspace);
4544
+ assertGenerationOpen?.();
4545
+ fresh.setValue(scope, key, value, assertGenerationOpen);
4460
4546
  return fresh;
4461
4547
  }), "persistSettingFn");
4462
- const persistSettingsFn = /* @__PURE__ */ __name((workspace, writes) => withSettingsLock(workspace, async () => {
4463
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4548
+ const persistSettingsFn = /* @__PURE__ */ __name((workspace, writes, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4549
+ assertGenerationOpen?.();
4550
+ const fresh = loadSettingsForPersistence(workspace);
4464
4551
  const writesByScope = /* @__PURE__ */ new Map();
4465
4552
  for (const write of writes) {
4466
4553
  writesByScope.set(
@@ -4471,10 +4558,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4471
4558
  const committedScopes = /* @__PURE__ */ new Set();
4472
4559
  let committed = 0;
4473
4560
  try {
4474
- fresh.setValues(writes, (scope) => {
4475
- committedScopes.add(scope);
4476
- committed += writesByScope.get(scope) ?? 0;
4477
- });
4561
+ assertGenerationOpen?.();
4562
+ fresh.setValues(
4563
+ writes,
4564
+ (scope) => {
4565
+ committedScopes.add(scope);
4566
+ committed += writesByScope.get(scope) ?? 0;
4567
+ },
4568
+ assertGenerationOpen
4569
+ );
4478
4570
  } catch (err) {
4479
4571
  const failedWrite = writes.find((write) => !committedScopes.has(write.scope)) ?? writes[committed];
4480
4572
  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 +4578,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4486
4578
  );
4487
4579
  }
4488
4580
  }), "persistSettingsFn");
4489
- const { createSubSessionLauncher } = await import("./create-sub-session-7543K2QA.js");
4581
+ const { createSubSessionLauncher } = await import("./create-sub-session-R76FVXCI.js");
4490
4582
  const subSessionLauncher = createSubSessionLauncher({
4491
4583
  getBridge: /* @__PURE__ */ __name(() => bridgeRef, "getBridge"),
4492
4584
  boundWorkspace
@@ -4505,10 +4597,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4505
4597
  ),
4506
4598
  maxSessions: opts.maxSessions,
4507
4599
  freshSessionAdmission: totalSessionAdmission.admit,
4508
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
4600
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
4601
+ if (event.type === "registered" && primaryGenerationGuard.closed) {
4602
+ return;
4603
+ }
4604
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
4605
+ }, "sessionLifecycle"),
4509
4606
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
4510
4607
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
4511
4608
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
4609
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
4610
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
4512
4611
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
4513
4612
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
4514
4613
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -4526,8 +4625,23 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4526
4625
  statusProvider,
4527
4626
  fileSystem: createBridgeFileSystemAdapter(fsFactory),
4528
4627
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
4529
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4530
- fresh.setValue(WORKSPACE_SETTING_SCOPE, "tools.approvalMode", mode);
4628
+ primaryGenerationGuard.assertOpen();
4629
+ if (!trustedWorkspace) {
4630
+ throw new Error(
4631
+ "Cannot persist approval mode for an untrusted workspace."
4632
+ );
4633
+ }
4634
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
4635
+ skipLoadEnvironment: true,
4636
+ workspaceTrusted: trustedWorkspace
4637
+ });
4638
+ primaryGenerationGuard.assertOpen();
4639
+ fresh.setValue(
4640
+ WORKSPACE_SETTING_SCOPE,
4641
+ "tools.approvalMode",
4642
+ mode,
4643
+ () => primaryGenerationGuard.assertOpen()
4644
+ );
4531
4645
  }), "persistApprovalMode")
4532
4646
  });
4533
4647
  if (!deps.bridge) {
@@ -4539,6 +4653,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4539
4653
  }, "invalidatePrimaryServeFeaturesCache");
4540
4654
  const workspaceService = runtime.createDaemonWorkspaceService({
4541
4655
  boundWorkspace,
4656
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => trustedWorkspace, "isWorkspaceTrusted"),
4657
+ assertGenerationOpen: /* @__PURE__ */ __name(() => primaryGenerationGuard.assertOpen(), "assertGenerationOpen"),
4542
4658
  contextFilename: contextFilenameForInit ?? "QWEN.md",
4543
4659
  statusProvider,
4544
4660
  workspaceProvidersStatusProvider,
@@ -4551,13 +4667,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4551
4667
  persistSetting: persistSettingFn,
4552
4668
  persistSettings: persistSettingsFn,
4553
4669
  preheatAcpChild: /* @__PURE__ */ __name(() => bridge.preheat(), "preheatAcpChild"),
4554
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
4670
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4671
+ assertGenerationOpen?.();
4555
4672
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
4556
- skipLoadEnvironment: true
4673
+ skipLoadEnvironment: true,
4674
+ skipWorkspaceSettings: !trustedWorkspace,
4675
+ workspaceTrusted: trustedWorkspace
4557
4676
  });
4677
+ assertGenerationOpen?.();
4558
4678
  const result = settingsRuntime.settings.reloadEnvironment(
4559
4679
  fresh.merged,
4560
- workspace
4680
+ workspace,
4681
+ trustedWorkspace
4561
4682
  );
4562
4683
  let refreshedRuntimeEnv;
4563
4684
  let fallbackReason;
@@ -4565,7 +4686,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4565
4686
  refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
4566
4687
  fresh.merged,
4567
4688
  workspace,
4568
- daemonRuntimeBaseEnv
4689
+ daemonRuntimeBaseEnv,
4690
+ trustedWorkspace
4569
4691
  );
4570
4692
  } catch (err) {
4571
4693
  fallbackReason = err instanceof Error ? err.message : String(err);
@@ -4633,14 +4755,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4633
4755
  bridge,
4634
4756
  workspaceService,
4635
4757
  routeFileSystemFactory: routeFsFactory,
4636
- clientMcpSenderRegistry
4758
+ clientMcpSenderRegistry,
4759
+ generationGuard: primaryGenerationGuard,
4760
+ trustMaterialization: primaryTrustMaterialization
4637
4761
  }
4638
4762
  ];
4639
- const createRuntimeEnvMetadata = /* @__PURE__ */ __name((workspace, settings) => {
4763
+ const createRuntimeEnvMetadata = /* @__PURE__ */ __name((workspace, settings, trusted) => {
4640
4764
  const snapshot = settings ? settingsRuntime.environment.buildRuntimeEnvironment(
4641
4765
  settings.merged,
4642
4766
  workspace,
4643
- daemonRuntimeBaseEnv
4767
+ daemonRuntimeBaseEnv,
4768
+ trusted
4644
4769
  ) : {
4645
4770
  effectiveEnv: { ...daemonRuntimeBaseEnv },
4646
4771
  overlayKeys: Object.freeze([]),
@@ -4670,27 +4795,33 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4670
4795
  };
4671
4796
  }, "createRuntimeEnvMetadata");
4672
4797
  const subSessionStoppers = [];
4673
- const subSessionStoppersByWorkspace = /* @__PURE__ */ new Map();
4798
+ const subSessionStoppersByRuntime = /* @__PURE__ */ new WeakMap();
4674
4799
  const runtimeCleanupPromises = /* @__PURE__ */ new WeakMap();
4675
4800
  const removeArrayValue = /* @__PURE__ */ __name((values, value) => {
4676
4801
  const index = values.indexOf(value);
4677
4802
  if (index >= 0) values.splice(index, 1);
4678
4803
  }, "removeArrayValue");
4679
4804
  for (const workspaceInput of workspaceInputs.slice(1)) {
4805
+ const secondaryDecision = trustPolicy.evaluateDaemonWorkspaceTrust(
4806
+ bootTrustSnapshot,
4807
+ workspaceInput.cwd
4808
+ );
4809
+ const secondaryTrusted = secondaryDecision.targetTrusted;
4680
4810
  let secondarySettings;
4681
4811
  try {
4682
4812
  secondarySettings = settingsRuntime.settings.loadSettings(
4683
- workspaceInput.cwd
4813
+ workspaceInput.cwd,
4814
+ {
4815
+ skipLoadEnvironment: true,
4816
+ skipWorkspaceSettings: !secondaryTrusted,
4817
+ workspaceTrusted: secondaryTrusted
4818
+ }
4684
4819
  );
4685
4820
  } catch (err) {
4686
4821
  writeStderrLine(
4687
4822
  `qwen serve: could not read full settings for secondary workspace ${workspaceInput.cwd} (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4688
4823
  );
4689
4824
  }
4690
- const secondaryTrusted = secondarySettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4691
- secondarySettings.merged,
4692
- workspaceInput.cwd
4693
- ).effective.state === "trusted" : false;
4694
4825
  if (!secondaryTrusted) {
4695
4826
  daemonLog.warn("secondary workspace is not trusted", {
4696
4827
  workspace: workspaceInput.cwd,
@@ -4699,11 +4830,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4699
4830
  }
4700
4831
  const secondaryEnv = createRuntimeEnvMetadata(
4701
4832
  workspaceInput.cwd,
4702
- secondarySettings
4833
+ secondarySettings,
4834
+ secondaryTrusted
4703
4835
  );
4836
+ const secondaryCustomIgnoreFiles = secondarySettings?.merged.context?.fileFiltering?.customIgnoreFiles;
4837
+ const secondaryContextFilename = extractContextFilename(secondarySettings?.merged.context?.fileName) ?? contextFilenameForInit ?? "QWEN.md";
4704
4838
  const secondaryWorkspaceHash = core.hashDaemonWorkspace(
4705
4839
  workspaceInput.cwd
4706
4840
  );
4841
+ const secondaryGenerationGuard = runtime.createWorkspaceGenerationGuard();
4707
4842
  const secondaryStatusProvider = runtime.createDaemonStatusProvider({
4708
4843
  env: secondaryEnv.effectiveEnv
4709
4844
  });
@@ -4712,9 +4847,11 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4712
4847
  trusted: secondaryTrusted,
4713
4848
  emit: deps.fsAuditEmit,
4714
4849
  pathLocks: sharedPathLocks,
4715
- ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4850
+ generationGuard: secondaryGenerationGuard,
4851
+ ...secondaryCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: secondaryCustomIgnoreFiles } : {}
4716
4852
  });
4717
4853
  const secondaryChannelFactory = runtime.createSpawnChannelFactory({
4854
+ processRegistry,
4718
4855
  sourceEnv: secondaryEnv.effectiveEnv,
4719
4856
  onDiagnosticLine: diagnosticSink,
4720
4857
  pipeHooks: {
@@ -4746,10 +4883,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4746
4883
  ),
4747
4884
  maxSessions: opts.maxSessions,
4748
4885
  freshSessionAdmission: totalSessionAdmission.admit,
4749
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
4886
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
4887
+ if (event.type === "registered" && secondaryGenerationGuard.closed) {
4888
+ return;
4889
+ }
4890
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
4891
+ }, "sessionLifecycle"),
4750
4892
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
4751
4893
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
4752
4894
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
4895
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
4896
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
4753
4897
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
4754
4898
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
4755
4899
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -4769,26 +4913,42 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4769
4913
  statusProvider: secondaryStatusProvider,
4770
4914
  fileSystem: createBridgeFileSystemAdapter(secondaryBridgeFsFactory),
4771
4915
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
4772
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4773
- fresh.setValue(WORKSPACE_SETTING_SCOPE, "tools.approvalMode", mode);
4916
+ secondaryGenerationGuard.assertOpen();
4917
+ if (!secondaryTrusted) {
4918
+ throw new Error(
4919
+ "Cannot persist approval mode for an untrusted workspace."
4920
+ );
4921
+ }
4922
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
4923
+ skipLoadEnvironment: true,
4924
+ workspaceTrusted: secondaryTrusted
4925
+ });
4926
+ secondaryGenerationGuard.assertOpen();
4927
+ fresh.setValue(
4928
+ WORKSPACE_SETTING_SCOPE,
4929
+ "tools.approvalMode",
4930
+ mode,
4931
+ () => secondaryGenerationGuard.assertOpen()
4932
+ );
4774
4933
  }), "persistApprovalMode")
4775
4934
  });
4776
4935
  secondaryBridgeRef = secondaryBridge;
4777
4936
  runtimeBridges.push(secondaryBridge);
4778
4937
  internalRuntimeBridgesForCleanup.push(secondaryBridge);
4779
4938
  subSessionStoppers.push(secondarySubSessionLauncher.stop);
4780
- subSessionStoppersByWorkspace.set(
4781
- workspaceInput.cwd,
4782
- secondarySubSessionLauncher.stop
4783
- );
4784
4939
  const secondaryWorkspaceService = runtime.createDaemonWorkspaceService({
4785
4940
  boundWorkspace: workspaceInput.cwd,
4786
- contextFilename: contextFilenameForInit ?? "QWEN.md",
4941
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => secondaryTrusted, "isWorkspaceTrusted"),
4942
+ assertGenerationOpen: /* @__PURE__ */ __name(() => secondaryGenerationGuard.assertOpen(), "assertGenerationOpen"),
4943
+ contextFilename: secondaryContextFilename,
4787
4944
  statusProvider: secondaryStatusProvider,
4788
4945
  workspaceProvidersStatusProvider: runtime.createWorkspaceProvidersStatusProvider({
4789
- env: secondaryEnv.effectiveEnv
4946
+ env: secondaryEnv.effectiveEnv,
4947
+ workspaceTrusted: secondaryTrusted
4948
+ }),
4949
+ workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider({
4950
+ workspaceTrusted: secondaryTrusted
4790
4951
  }),
4791
- workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider(),
4792
4952
  skillInstallEnv: secondaryEnv.effectiveEnv,
4793
4953
  voiceEnv: secondaryEnv.effectiveEnv,
4794
4954
  voiceSettingsScope: WORKSPACE_SETTING_SCOPE,
@@ -4798,19 +4958,25 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4798
4958
  persistDisabledSkills: persistDisabledSkillsFn,
4799
4959
  persistSetting: persistSettingFn,
4800
4960
  persistSettings: persistSettingsFn,
4801
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
4961
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4962
+ assertGenerationOpen?.();
4802
4963
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
4803
- skipLoadEnvironment: true
4964
+ skipLoadEnvironment: true,
4965
+ skipWorkspaceSettings: !secondaryTrusted,
4966
+ workspaceTrusted: secondaryTrusted
4804
4967
  });
4968
+ assertGenerationOpen?.();
4805
4969
  const result = settingsRuntime.settings.reloadEnvironment(
4806
4970
  fresh.merged,
4807
- workspace
4971
+ workspace,
4972
+ secondaryTrusted
4808
4973
  );
4809
4974
  try {
4810
4975
  const refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
4811
4976
  fresh.merged,
4812
4977
  workspace,
4813
- daemonRuntimeBaseEnv
4978
+ daemonRuntimeBaseEnv,
4979
+ secondaryTrusted
4814
4980
  );
4815
4981
  logRuntimeEnvFileReadFailures(workspace, refreshedRuntimeEnv);
4816
4982
  secondaryEnv.replace(refreshedRuntimeEnv.effectiveEnv);
@@ -4848,7 +5014,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4848
5014
  refreshExtensionsForAllSessions: /* @__PURE__ */ __name(() => secondaryBridge.refreshExtensionsForAllSessions(), "refreshExtensionsForAllSessions"),
4849
5015
  publishWorkspaceEvent: /* @__PURE__ */ __name((event) => secondaryBridge.publishWorkspaceEvent(event), "publishWorkspaceEvent")
4850
5016
  });
4851
- workspaceRuntimes.push({
5017
+ const secondaryRuntime = {
4852
5018
  workspaceId: secondaryWorkspaceHash,
4853
5019
  workspaceCwd: workspaceInput.cwd,
4854
5020
  ...workspaceInput.displayName ? { displayName: workspaceInput.displayName } : {},
@@ -4860,12 +5026,24 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4860
5026
  bridge: secondaryBridge,
4861
5027
  workspaceService: secondaryWorkspaceService,
4862
5028
  routeFileSystemFactory: secondaryBridgeFsFactory,
4863
- clientMcpSenderRegistry: secondaryClientMcpSenderRegistry
4864
- });
5029
+ clientMcpSenderRegistry: secondaryClientMcpSenderRegistry,
5030
+ generationGuard: secondaryGenerationGuard,
5031
+ trustMaterialization: JSON.stringify({
5032
+ trusted: secondaryTrusted,
5033
+ boundWorkspaces: [workspaceInput.cwd]
5034
+ })
5035
+ };
5036
+ subSessionStoppersByRuntime.set(
5037
+ secondaryRuntime,
5038
+ secondarySubSessionLauncher.stop
5039
+ );
5040
+ workspaceRuntimes.push(secondaryRuntime);
4865
5041
  }
4866
5042
  const workspaceRegistry = runtime.createWorkspaceRegistry(workspaceRuntimes, {
4867
- sessionOwnerIndex
5043
+ sessionOwnerIndex,
5044
+ scanUnindexedOwners: deps.bridge !== void 0
4868
5045
  });
5046
+ workspaceRegistryForPersistence.current = workspaceRegistry;
4869
5047
  const workspaceVoiceCoordinator = new WorkspaceVoiceCoordinator();
4870
5048
  core.registerDaemonGaugeCallbacks({
4871
5049
  sessionCount: /* @__PURE__ */ __name(() => workspaceRegistry.list().reduce((sum, item) => sum + item.bridge.sessionCount, 0), "sessionCount"),
@@ -4900,9 +5078,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4900
5078
  const rejectedTotal = hits ? hits.prompt + hits.mutation + hits.read : 0;
4901
5079
  const rateLimitRejected = prevRateRejected === void 0 ? 0 : Math.max(0, rejectedTotal - prevRateRejected);
4902
5080
  prevRateRejected = rejectedTotal;
4903
- const child = bridge.getChildResourceSnapshot?.();
5081
+ const primaryEntry = workspaceRegistry.primaryEntry;
5082
+ const primaryRuntimeBridge = primaryEntry.state === "active" ? primaryEntry.current?.runtime.bridge : void 0;
5083
+ const child = primaryRuntimeBridge?.getChildResourceSnapshot?.();
4904
5084
  if (runtime.getActiveSseCount() > 0 || (acp?.wsStreams ?? 0) > 0) {
4905
- void bridge.refreshChildResource?.();
5085
+ void primaryRuntimeBridge?.refreshChildResource?.().catch((err) => {
5086
+ daemonLog.warn(
5087
+ `ACP child resource refresh failed: ${err instanceof Error ? err.message : String(err)}`
5088
+ );
5089
+ });
4906
5090
  }
4907
5091
  metricsRing.sample(nowMs, {
4908
5092
  cpuPercent,
@@ -4958,34 +5142,52 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4958
5142
  metricsLoopDelay.disable();
4959
5143
  }
4960
5144
  };
4961
- const createDynamicWorkspaceRuntime = /* @__PURE__ */ __name(async (cwd, options) => {
4962
- if (options.provenance === "managed-scratch" && (!managedScratchRoot || !isManagedScratchChild(cwd, managedScratchRoot.canonicalRoot))) {
5145
+ const createDynamicWorkspaceRuntime = /* @__PURE__ */ __name(async (cwd, buildOptions) => {
5146
+ const provenance = buildOptions?.provenance ?? "existing";
5147
+ if (provenance === "managed-scratch" && (!managedScratchRoot || !isManagedScratchChild(cwd, managedScratchRoot.canonicalRoot))) {
4963
5148
  throw new Error(
4964
5149
  "Managed scratch runtime must use an accepted direct child directory"
4965
5150
  );
4966
5151
  }
5152
+ const snapshot = buildOptions?.snapshot ?? await trustPolicy.readDaemonTrustPolicySnapshot();
5153
+ const decision = buildOptions?.decision ?? trustPolicy.evaluateDaemonWorkspaceTrust(snapshot, cwd);
5154
+ const trusted = provenance === "managed-scratch" ? true : buildOptions?.trusted ?? decision.targetTrusted;
4967
5155
  let wsSettings;
4968
5156
  try {
4969
- wsSettings = settingsRuntime.settings.loadSettings(cwd);
5157
+ wsSettings = settingsRuntime.settings.loadSettings(cwd, {
5158
+ skipLoadEnvironment: true,
5159
+ skipWorkspaceSettings: !trusted,
5160
+ workspaceTrusted: trusted
5161
+ });
4970
5162
  } catch (err) {
4971
5163
  writeStderrLine(
4972
5164
  `qwen serve: could not read full settings for dynamic workspace ${cwd} (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4973
5165
  );
4974
5166
  }
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);
5167
+ const wsEnv = createRuntimeEnvMetadata(cwd, wsSettings, trusted);
5168
+ const wsCustomIgnoreFiles = wsSettings?.merged.context?.fileFiltering?.customIgnoreFiles;
5169
+ const wsContextFilename = extractContextFilename(wsSettings?.merged.context?.fileName) ?? contextFilenameForInit ?? "QWEN.md";
4980
5170
  const wsHash = core.hashDaemonWorkspace(cwd);
5171
+ const generationGuard = buildOptions?.generationGuard ?? runtime.createWorkspaceGenerationGuard();
5172
+ const runtimeBoundWorkspaces = buildOptions?.boundWorkspaces ?? [cwd];
4981
5173
  const wsFsFactory = runtime.resolveBridgeFsFactory({
4982
- boundWorkspaces: [cwd],
5174
+ boundWorkspaces: runtimeBoundWorkspaces,
4983
5175
  trusted,
4984
5176
  emit: deps.fsAuditEmit,
4985
5177
  pathLocks: sharedPathLocks,
4986
- ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
5178
+ generationGuard,
5179
+ ...wsCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: wsCustomIgnoreFiles } : {}
4987
5180
  });
5181
+ const wsRouteFsFactory = buildOptions?.primary === true && runtimeBoundWorkspaces.length > 1 ? runtime.resolveBridgeFsFactory({
5182
+ boundWorkspaces: [cwd],
5183
+ trusted,
5184
+ emit: deps.fsAuditEmit,
5185
+ pathLocks: sharedPathLocks,
5186
+ generationGuard,
5187
+ ...wsCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: wsCustomIgnoreFiles } : {}
5188
+ }) : wsFsFactory;
4988
5189
  const wsChannelFactory = runtime.createSpawnChannelFactory({
5190
+ processRegistry,
4989
5191
  sourceEnv: wsEnv.effectiveEnv,
4990
5192
  onDiagnosticLine: diagnosticSink,
4991
5193
  pipeHooks: {
@@ -5019,10 +5221,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5019
5221
  ),
5020
5222
  maxSessions: opts.maxSessions,
5021
5223
  freshSessionAdmission: totalSessionAdmission.admit,
5022
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
5224
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
5225
+ if (event.type === "registered" && generationGuard.closed) return;
5226
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
5227
+ }, "sessionLifecycle"),
5023
5228
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
5024
5229
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
5025
5230
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
5231
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
5232
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
5026
5233
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
5027
5234
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
5028
5235
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -5035,18 +5242,31 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5035
5242
  onDiagnosticLine: diagnosticSink,
5036
5243
  telemetry: createRuntimeBridgeTelemetry(wsHash),
5037
5244
  ...permissionPolicy !== void 0 ? { permissionPolicy } : {},
5038
- ...permissionConsensusQuorum !== void 0 ? { permissionConsensusQuorum } : {},
5245
+ ...permissionConsensusQuorum !== void 0 ? {
5246
+ permissionConsensusQuorum
5247
+ } : {},
5039
5248
  permissionAudit: permissionAuditPublisher,
5040
5249
  statusProvider: runtime.createDaemonStatusProvider({
5041
5250
  env: wsEnv.effectiveEnv
5042
5251
  }),
5043
5252
  fileSystem: createBridgeFileSystemAdapter(wsFsFactory),
5044
5253
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
5045
- const fresh = settingsRuntime.settings.loadSettings(workspace);
5254
+ generationGuard.assertOpen();
5255
+ if (!trusted) {
5256
+ throw new Error(
5257
+ "Cannot persist approval mode for an untrusted workspace."
5258
+ );
5259
+ }
5260
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
5261
+ skipLoadEnvironment: true,
5262
+ workspaceTrusted: trusted
5263
+ });
5264
+ generationGuard.assertOpen();
5046
5265
  fresh.setValue(
5047
5266
  WORKSPACE_SETTING_SCOPE,
5048
5267
  "tools.approvalMode",
5049
- mode
5268
+ mode,
5269
+ () => generationGuard.assertOpen()
5050
5270
  );
5051
5271
  }), "persistApprovalMode")
5052
5272
  });
@@ -5059,36 +5279,47 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5059
5279
  try {
5060
5280
  wsService = runtime.createDaemonWorkspaceService({
5061
5281
  boundWorkspace: cwd,
5062
- contextFilename: contextFilenameForInit ?? "QWEN.md",
5282
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => trusted, "isWorkspaceTrusted"),
5283
+ assertGenerationOpen: /* @__PURE__ */ __name(() => generationGuard.assertOpen(), "assertGenerationOpen"),
5284
+ contextFilename: wsContextFilename,
5063
5285
  statusProvider: runtime.createDaemonStatusProvider({
5064
5286
  env: wsEnv.effectiveEnv
5065
5287
  }),
5066
5288
  workspaceProvidersStatusProvider: runtime.createWorkspaceProvidersStatusProvider({
5067
- env: wsEnv.effectiveEnv
5289
+ env: wsEnv.effectiveEnv,
5290
+ workspaceTrusted: trusted
5291
+ }),
5292
+ workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider({
5293
+ workspaceTrusted: trusted
5068
5294
  }),
5069
- workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider(),
5070
5295
  skillInstallEnv: wsEnv.effectiveEnv,
5071
5296
  voiceEnv: wsEnv.effectiveEnv,
5072
- voiceSettingsScope: WORKSPACE_SETTING_SCOPE,
5297
+ ...buildOptions?.primary === true ? {} : { voiceSettingsScope: WORKSPACE_SETTING_SCOPE },
5073
5298
  isChannelLive: /* @__PURE__ */ __name(() => wsBridge.isChannelLive(), "isChannelLive"),
5074
5299
  preheatAcpChild: /* @__PURE__ */ __name(() => wsBridge.preheat(), "preheatAcpChild"),
5075
5300
  persistDisabledTools: persistDisabledToolsFn,
5076
5301
  persistDisabledSkills: persistDisabledSkillsFn,
5077
5302
  persistSetting: persistSettingFn,
5078
5303
  persistSettings: persistSettingsFn,
5079
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
5304
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
5305
+ assertGenerationOpen?.();
5080
5306
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
5081
- skipLoadEnvironment: true
5307
+ skipLoadEnvironment: true,
5308
+ skipWorkspaceSettings: !trusted,
5309
+ workspaceTrusted: trusted
5082
5310
  });
5311
+ assertGenerationOpen?.();
5083
5312
  const result = settingsRuntime.settings.reloadEnvironment(
5084
5313
  fresh.merged,
5085
- workspace
5314
+ workspace,
5315
+ trusted
5086
5316
  );
5087
5317
  try {
5088
5318
  const refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
5089
5319
  fresh.merged,
5090
5320
  workspace,
5091
- daemonRuntimeBaseEnv
5321
+ daemonRuntimeBaseEnv,
5322
+ trusted
5092
5323
  );
5093
5324
  logRuntimeEnvFileReadFailures(workspace, refreshedRuntimeEnv);
5094
5325
  wsEnv.replace(refreshedRuntimeEnv.effectiveEnv);
@@ -5124,7 +5355,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5124
5355
  queryWorkspaceStatus: /* @__PURE__ */ __name((method, idle) => wsBridge.queryWorkspaceStatus(method, idle), "queryWorkspaceStatus"),
5125
5356
  invokeWorkspaceCommand: /* @__PURE__ */ __name((method, params, invokeOpts) => wsBridge.invokeWorkspaceCommand(method, params, invokeOpts), "invokeWorkspaceCommand"),
5126
5357
  refreshExtensionsForAllSessions: /* @__PURE__ */ __name(() => wsBridge.refreshExtensionsForAllSessions(), "refreshExtensionsForAllSessions"),
5127
- publishWorkspaceEvent: /* @__PURE__ */ __name((event) => wsBridge.publishWorkspaceEvent(event), "publishWorkspaceEvent")
5358
+ publishWorkspaceEvent: /* @__PURE__ */ __name((event) => {
5359
+ if (buildOptions?.primary === true && (event.type === "settings_changed" || event.type === "settings_reloaded")) {
5360
+ invalidatePrimaryServeFeaturesCache();
5361
+ }
5362
+ wsBridge.publishWorkspaceEvent(event);
5363
+ }, "publishWorkspaceEvent")
5128
5364
  });
5129
5365
  } catch (err) {
5130
5366
  wsSubSessionLauncher.stop();
@@ -5139,31 +5375,75 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5139
5375
  runtimeBridges.push(wsBridge);
5140
5376
  internalRuntimeBridgesForCleanup.push(wsBridge);
5141
5377
  subSessionStoppers.push(wsSubSessionLauncher.stop);
5142
- subSessionStoppersByWorkspace.set(cwd, wsSubSessionLauncher.stop);
5143
- return {
5378
+ const wsRuntime = {
5144
5379
  workspaceId: wsHash,
5145
5380
  workspaceCwd: cwd,
5146
- primary: false,
5381
+ ...buildOptions?.displayName !== void 0 ? { displayName: buildOptions.displayName } : {},
5382
+ primary: buildOptions?.primary ?? false,
5147
5383
  trusted,
5148
- removable: true,
5149
- registrationIds: [],
5384
+ provenance,
5385
+ removable: buildOptions?.removable ?? true,
5386
+ registrationIds: [...buildOptions?.registrationIds ?? []],
5150
5387
  env: wsEnv.metadata,
5151
5388
  bridge: wsBridge,
5152
5389
  workspaceService: wsService,
5153
- routeFileSystemFactory: wsFsFactory,
5154
- clientMcpSenderRegistry: wsClientMcpRegistry
5390
+ routeFileSystemFactory: wsRouteFsFactory,
5391
+ clientMcpSenderRegistry: wsClientMcpRegistry,
5392
+ generationGuard,
5393
+ trustMaterialization: buildOptions?.trustMaterialization ?? JSON.stringify({
5394
+ trusted,
5395
+ boundWorkspaces: [...runtimeBoundWorkspaces].sort()
5396
+ })
5155
5397
  };
5398
+ subSessionStoppersByRuntime.set(wsRuntime, wsSubSessionLauncher.stop);
5399
+ if (provenance !== "managed-scratch" && !buildOptions?.snapshot) {
5400
+ const latest = await trustPolicy.readDaemonTrustPolicySnapshot();
5401
+ if (latest.revision !== snapshot.revision) {
5402
+ generationGuard.close();
5403
+ wsSubSessionLauncher.stop();
5404
+ await wsBridge.shutdown({ reason: "trust_reconfigured" }).catch(() => {
5405
+ try {
5406
+ wsBridge.killAllSync();
5407
+ } catch {
5408
+ }
5409
+ });
5410
+ subSessionStoppersByRuntime.delete(wsRuntime);
5411
+ removeArrayValue(subSessionStoppers, wsSubSessionLauncher.stop);
5412
+ removeArrayValue(runtimeBridges, wsBridge);
5413
+ removeArrayValue(internalRuntimeBridgesForCleanup, wsBridge);
5414
+ if ((buildOptions?.validationAttempt ?? 0) >= 2) {
5415
+ throw new Error(
5416
+ "Workspace trust policy kept changing during runtime creation."
5417
+ );
5418
+ }
5419
+ const { generationGuard: _staleGuard, ...retryOptions } = buildOptions ?? {};
5420
+ return createDynamicWorkspaceRuntime(cwd, {
5421
+ ...retryOptions,
5422
+ validationAttempt: (buildOptions?.validationAttempt ?? 0) + 1
5423
+ });
5424
+ }
5425
+ }
5426
+ return wsRuntime;
5156
5427
  }, "createDynamicWorkspaceRuntime");
5428
+ const serveAppForRuntimeLifecycle = { current: void 0 };
5157
5429
  const workspaceRuntimeRemoval = {
5158
5430
  async runtimeAdded(runtimeAdded) {
5159
- const app3 = runtimeApp ?? runtimeAppForCleanup;
5431
+ channelWebhookEnvByWorkspace.set(
5432
+ runtimeAdded.workspaceCwd,
5433
+ workspaceRuntimeEffectiveEnv(runtimeAdded, daemonRuntimeBaseEnv)
5434
+ );
5435
+ channelWebhookConfigVersion += 1;
5436
+ refreshChannelWebhookConfigs?.();
5437
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5160
5438
  const startScheduledTaskKeepaliveForWorkspace = app3?.locals?.["startScheduledTaskKeepaliveForWorkspace"];
5161
5439
  startScheduledTaskKeepaliveForWorkspace?.(runtimeAdded);
5162
5440
  if (!channelWorkerManager) return;
5163
5441
  try {
5164
- await channelWorkerManager.restoreWorkspace(
5165
- runtimeAdded.workspaceCwd
5166
- );
5442
+ if (runtimeAdded.trusted) {
5443
+ await channelWorkerManager.restoreWorkspace(
5444
+ runtimeAdded.workspaceCwd
5445
+ );
5446
+ }
5167
5447
  await channelWorkerManager.refreshWorkspaces();
5168
5448
  } catch (err) {
5169
5449
  daemonLog.error(
@@ -5175,14 +5455,51 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5175
5455
  }
5176
5456
  },
5177
5457
  beginDrain(runtimeToDrain) {
5458
+ if (runtimeToDrain.primary) {
5459
+ if (bridgeRef === runtimeToDrain.bridge) bridgeRef = void 0;
5460
+ invalidatePrimaryServeFeaturesCache();
5461
+ }
5178
5462
  totalSessionAdmission.beginWorkspaceDrain(runtimeToDrain.workspaceCwd);
5179
5463
  channelWorkerManager?.beginWorkspaceDrain(runtimeToDrain.workspaceCwd);
5180
5464
  workspaceVoiceCoordinator.beginWorkspaceDrain(runtimeToDrain);
5465
+ channelWebhookEnvByWorkspace.delete(runtimeToDrain.workspaceCwd);
5466
+ channelWebhookConfigVersion += 1;
5467
+ refreshChannelWebhookConfigs?.();
5468
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5469
+ const stopScheduledTaskKeepaliveForWorkspace = app3?.locals?.["stopScheduledTaskKeepaliveForWorkspace"];
5470
+ try {
5471
+ stopScheduledTaskKeepaliveForWorkspace?.(runtimeToDrain.workspaceCwd);
5472
+ } catch (err) {
5473
+ daemonLog.error(
5474
+ "workspace scheduled-task drain error",
5475
+ err instanceof Error ? err : null
5476
+ );
5477
+ }
5181
5478
  },
5182
5479
  cancelDrain(runtimeToDrain) {
5480
+ if (runtimeToDrain.primary && bridgeRef === void 0) {
5481
+ bridgeRef = runtimeToDrain.bridge;
5482
+ invalidatePrimaryServeFeaturesCache();
5483
+ }
5183
5484
  channelWorkerManager?.cancelWorkspaceDrain(runtimeToDrain.workspaceCwd);
5184
5485
  totalSessionAdmission.cancelWorkspaceDrain(runtimeToDrain.workspaceCwd);
5185
5486
  workspaceVoiceCoordinator.cancelWorkspaceDrain(runtimeToDrain);
5487
+ channelWebhookEnvByWorkspace.set(
5488
+ runtimeToDrain.workspaceCwd,
5489
+ workspaceRuntimeEffectiveEnv(runtimeToDrain, daemonRuntimeBaseEnv)
5490
+ );
5491
+ channelWebhookConfigVersion += 1;
5492
+ refreshChannelWebhookConfigs?.();
5493
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5494
+ const startScheduledTaskKeepaliveForWorkspace = app3?.locals?.["startScheduledTaskKeepaliveForWorkspace"];
5495
+ try {
5496
+ startScheduledTaskKeepaliveForWorkspace?.(runtimeToDrain);
5497
+ } catch (err) {
5498
+ daemonLog.error(
5499
+ "workspace scheduled-task drain rollback error",
5500
+ err instanceof Error ? err : null
5501
+ );
5502
+ }
5186
5503
  },
5187
5504
  completeDrain(runtimeToDrain) {
5188
5505
  totalSessionAdmission.completeWorkspaceDrain(
@@ -5205,18 +5522,29 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5205
5522
  const existing = runtimeCleanupPromises.get(runtimeToDrain);
5206
5523
  if (existing) return existing;
5207
5524
  const cleanup = (async () => {
5208
- await workspaceVoiceCoordinator.disposeRuntime(
5209
- runtimeToDrain,
5210
- reason
5211
- );
5212
- const stopSubSessions = subSessionStoppersByWorkspace.get(
5213
- runtimeToDrain.workspaceCwd
5214
- );
5525
+ const containmentErrors = [];
5526
+ try {
5527
+ await workspaceVoiceCoordinator.disposeRuntime(
5528
+ runtimeToDrain,
5529
+ reason
5530
+ );
5531
+ } catch (err) {
5532
+ daemonLog.error(
5533
+ "workspace voice cleanup error",
5534
+ err instanceof Error ? err : null
5535
+ );
5536
+ }
5537
+ if (reason === "trust_reconfigured" && workspaceVoiceCoordinator.getWorkspaceActivity(runtimeToDrain) > 0) {
5538
+ containmentErrors.push(
5539
+ new Error("Workspace voice sessions are still active.")
5540
+ );
5541
+ }
5542
+ const stopSubSessions = subSessionStoppersByRuntime.get(runtimeToDrain);
5215
5543
  try {
5216
5544
  stopSubSessions?.();
5217
5545
  } catch {
5218
5546
  }
5219
- if (reason === "workspace_removed" && channelWorkerManager) {
5547
+ if (reason !== "daemon_shutdown" && channelWorkerManager) {
5220
5548
  await channelWorkerManager.removeWorkspace(runtimeToDrain.workspaceCwd).catch((err) => {
5221
5549
  daemonLog.error(
5222
5550
  "workspace channel worker cleanup error",
@@ -5237,25 +5565,65 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5237
5565
  );
5238
5566
  }
5239
5567
  writeChannelWorkerPidfile();
5568
+ if (reason === "trust_reconfigured" && channelWorkerManager.workspaceActivity(
5569
+ runtimeToDrain.workspaceCwd
5570
+ ) > 0) {
5571
+ containmentErrors.push(
5572
+ new Error("Workspace channel workers are still active.")
5573
+ );
5574
+ }
5240
5575
  }
5241
- if (reason === "workspace_removed") {
5242
- const app3 = runtimeApp ?? runtimeAppForCleanup;
5576
+ if (reason !== "daemon_shutdown") {
5577
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5243
5578
  const stopWorkspaceGitStateForWorkspace = app3?.locals?.["stopWorkspaceGitStateForWorkspace"];
5244
5579
  const stopScheduledTaskKeepaliveForWorkspace = app3?.locals?.["stopScheduledTaskKeepaliveForWorkspace"];
5245
- stopWorkspaceGitStateForWorkspace?.(runtimeToDrain.workspaceCwd);
5246
- stopScheduledTaskKeepaliveForWorkspace?.(
5247
- runtimeToDrain.workspaceCwd
5248
- );
5580
+ try {
5581
+ stopWorkspaceGitStateForWorkspace?.(runtimeToDrain.workspaceCwd);
5582
+ } catch (err) {
5583
+ daemonLog.error(
5584
+ "workspace git-state cleanup error",
5585
+ err instanceof Error ? err : null
5586
+ );
5587
+ }
5588
+ try {
5589
+ stopScheduledTaskKeepaliveForWorkspace?.(
5590
+ runtimeToDrain.workspaceCwd
5591
+ );
5592
+ } catch (err) {
5593
+ daemonLog.error(
5594
+ "workspace scheduled-task cleanup error",
5595
+ err instanceof Error ? err : null
5596
+ );
5597
+ }
5249
5598
  }
5250
5599
  let bridgeStopped = false;
5251
5600
  try {
5252
5601
  if (!shutdownBridges.has(runtimeToDrain.bridge)) {
5253
- await runtimeToDrain.bridge.shutdown({ reason });
5602
+ try {
5603
+ await runtimeToDrain.bridge.shutdown({ reason });
5604
+ } catch (shutdownError) {
5605
+ try {
5606
+ runtimeToDrain.bridge.killAllSync();
5607
+ daemonLog.warn(
5608
+ "workspace bridge required forceful shutdown",
5609
+ {
5610
+ workspace: runtimeToDrain.workspaceCwd,
5611
+ reason,
5612
+ error: shutdownError instanceof Error ? shutdownError.message : String(shutdownError)
5613
+ }
5614
+ );
5615
+ } catch (killError) {
5616
+ throw new AggregateError(
5617
+ [shutdownError, killError],
5618
+ "Workspace bridge shutdown could not be confirmed."
5619
+ );
5620
+ }
5621
+ }
5254
5622
  }
5255
5623
  bridgeStopped = true;
5256
5624
  } finally {
5257
- if (bridgeStopped || reason === "workspace_removed") {
5258
- subSessionStoppersByWorkspace.delete(runtimeToDrain.workspaceCwd);
5625
+ if (bridgeStopped) {
5626
+ subSessionStoppersByRuntime.delete(runtimeToDrain);
5259
5627
  if (stopSubSessions) {
5260
5628
  removeArrayValue(subSessionStoppers, stopSubSessions);
5261
5629
  }
@@ -5267,10 +5635,16 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5267
5635
  shutdownBridges.add(runtimeToDrain.bridge);
5268
5636
  }
5269
5637
  }
5638
+ if (containmentErrors.length > 0) {
5639
+ throw new AggregateError(
5640
+ containmentErrors,
5641
+ "Workspace runtime containment could not be confirmed."
5642
+ );
5643
+ }
5270
5644
  })();
5271
5645
  runtimeCleanupPromises.set(runtimeToDrain, cleanup);
5272
5646
  void cleanup.catch(() => {
5273
- if (reason === "daemon_shutdown" && runtimeCleanupPromises.get(runtimeToDrain) === cleanup) {
5647
+ if (runtimeCleanupPromises.get(runtimeToDrain) === cleanup) {
5274
5648
  runtimeCleanupPromises.delete(runtimeToDrain);
5275
5649
  }
5276
5650
  });
@@ -5292,8 +5666,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5292
5666
  { createChannelManagementService },
5293
5667
  { WorkspaceChannelSettingsStore }
5294
5668
  ] = await Promise.all([
5295
- import("./channel-management-service-G74LFADV.js"),
5296
- import("./channel-settings-store-CHCDRTPY.js")
5669
+ import("./channel-management-service-XR7GZSWF.js"),
5670
+ import("./channel-settings-store-HW4FXXUA.js")
5297
5671
  ]);
5298
5672
  return createChannelManagementService({
5299
5673
  workspaceCwd: targetRuntime.workspaceCwd,
@@ -5309,12 +5683,55 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5309
5683
  });
5310
5684
  return pending;
5311
5685
  }, "channelManagementService");
5686
+ const validateWorkspaceRuntimeForPublication = /* @__PURE__ */ __name(async (runtimeForPublication) => {
5687
+ let candidate = runtimeForPublication;
5688
+ for (let attempt = 0; attempt < 3; attempt++) {
5689
+ const snapshot = await trustPolicy.readDaemonTrustPolicySnapshot();
5690
+ const decision = trustPolicy.evaluateDaemonWorkspaceTrust(
5691
+ snapshot,
5692
+ candidate.workspaceCwd
5693
+ );
5694
+ const materialization = JSON.stringify({
5695
+ trusted: decision.targetTrusted,
5696
+ boundWorkspaces: [candidate.workspaceCwd]
5697
+ });
5698
+ if (candidate.trustMaterialization === materialization) {
5699
+ return candidate;
5700
+ }
5701
+ candidate.generationGuard?.close();
5702
+ await workspaceRuntimeRemoval.disposeRuntime(
5703
+ candidate,
5704
+ "trust_reconfigured"
5705
+ );
5706
+ if (attempt === 2) {
5707
+ throw new Error(
5708
+ "Workspace trust policy kept changing before runtime publication."
5709
+ );
5710
+ }
5711
+ candidate = await createDynamicWorkspaceRuntime(
5712
+ runtimeForPublication.workspaceCwd,
5713
+ {
5714
+ primary: runtimeForPublication.primary,
5715
+ removable: runtimeForPublication.removable,
5716
+ displayName: runtimeForPublication.displayName,
5717
+ registrationIds: runtimeForPublication.registrationIds
5718
+ }
5719
+ );
5720
+ }
5721
+ throw new Error("Workspace runtime publication validation failed.");
5722
+ }, "validateWorkspaceRuntimeForPublication");
5312
5723
  const app2 = runtime.createServeApp(opts, () => actualPort, {
5313
5724
  workspaceRegistry,
5314
5725
  createWorkspaceRuntime: createDynamicWorkspaceRuntime,
5726
+ ...workspaceTrustHotReloadAvailable ? {
5727
+ validateWorkspaceRuntimeForPublication,
5728
+ runWorkspaceTrustOperation,
5729
+ getWorkspaceTrustPolicySnapshot: /* @__PURE__ */ __name(() => latestTrustPolicySnapshot, "getWorkspaceTrustPolicySnapshot")
5730
+ } : {},
5315
5731
  managedScratchRoot,
5316
5732
  workspaceRegistrationStore,
5317
5733
  workspaceRuntimeRemoval,
5734
+ workspaceTrustHotReloadAvailable,
5318
5735
  voiceCoordinator: workspaceVoiceCoordinator,
5319
5736
  bridge,
5320
5737
  webShellDir,
@@ -5393,9 +5810,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5393
5810
  sessionArtifactsPersistenceAvailable: sessionArtifactsPersistenceAvailableFromSettings(
5394
5811
  runtimeBootSettings?.merged
5395
5812
  ),
5396
- installAuthProvider: /* @__PURE__ */ __name((req) => withSettingsLock(
5813
+ installAuthProvider: /* @__PURE__ */ __name((req, assertGenerationOpen) => withSettingsLock(
5397
5814
  boundWorkspace,
5398
5815
  async () => {
5816
+ assertGenerationOpen?.();
5399
5817
  const provider = core.findProviderById(req.providerId);
5400
5818
  if (!provider) {
5401
5819
  throw new Error(`Unsupported auth provider: ${req.providerId}`);
@@ -5405,7 +5823,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5405
5823
  resolveBaseUrl: core.resolveBaseUrl
5406
5824
  });
5407
5825
  const plan = core.buildInstallPlan(provider, inputs);
5408
- const fresh = settingsRuntime.settings.loadSettings(boundWorkspace);
5826
+ const fresh = loadSettingsForPersistence(boundWorkspace);
5409
5827
  const adapter = settingsRuntime.loadedSettingsAdapter.createLoadedSettingsAdapter(
5410
5828
  fresh
5411
5829
  );
@@ -5413,6 +5831,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5413
5831
  settings: adapter,
5414
5832
  doRefreshAuth: false
5415
5833
  });
5834
+ assertGenerationOpen?.();
5416
5835
  core.emitDaemonLog("Auth provider installed.", {
5417
5836
  "qwen-code.daemon.auth.provider_id": provider.id,
5418
5837
  "qwen-code.daemon.auth.auth_type": plan.authType
@@ -5431,11 +5850,171 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5431
5850
  }
5432
5851
  ), "installAuthProvider")
5433
5852
  });
5853
+ serveAppForRuntimeLifecycle.current = app2;
5434
5854
  invalidatePrimaryServeFeaturesCache = app2.locals.invalidateServeFeaturesCache ?? invalidatePrimaryServeFeaturesCache;
5435
5855
  app2.locals.subSessionStoppers = subSessionStoppers;
5436
5856
  subSessionStoppers.push(subSessionLauncher.stop);
5437
- subSessionStoppersByWorkspace.set(boundWorkspace, subSessionLauncher.stop);
5438
- return { app: app2, bridge };
5857
+ subSessionStoppersByRuntime.set(
5858
+ workspaceRegistry.primary,
5859
+ subSessionLauncher.stop
5860
+ );
5861
+ if (workspaceTrustHotReloadAvailable) {
5862
+ const [
5863
+ { createWorkspaceTrustReconciler },
5864
+ { createDaemonTrustPolicyMonitor }
5865
+ ] = await Promise.all([
5866
+ import("./workspace-trust-reconciler-IBUPOUJN.js"),
5867
+ import("./daemon-trust-policy-monitor-HS3PKKRO.js")
5868
+ ]);
5869
+ const materializationFor = /* @__PURE__ */ __name((entry, snapshot, decision) => {
5870
+ const boundWorkspaces2 = entry.primary && decision.targetTrusted ? runtime.resolveBoundWorkspacesFromIdeEnv(
5871
+ entry.workspaceCwd,
5872
+ void 0,
5873
+ (workspace, index) => index === 0 || trustPolicy.evaluateDaemonWorkspaceTrust(snapshot, workspace).targetTrusted
5874
+ ) : [entry.workspaceCwd];
5875
+ return {
5876
+ key: JSON.stringify({
5877
+ trusted: decision.targetTrusted,
5878
+ boundWorkspaces: [...boundWorkspaces2].sort()
5879
+ }),
5880
+ boundWorkspaces: boundWorkspaces2
5881
+ };
5882
+ }, "materializationFor");
5883
+ const acpHandle = /* @__PURE__ */ __name(() => app2.locals?.["acpHandle"], "acpHandle");
5884
+ const trustReconciler = createWorkspaceTrustReconciler({
5885
+ registry: workspaceRegistry,
5886
+ readLatestSnapshot: trustPolicy.readDaemonTrustPolicySnapshot,
5887
+ materializationKey: /* @__PURE__ */ __name(({ entry, snapshot, decision }) => materializationFor(entry, snapshot, decision).key, "materializationKey"),
5888
+ isTrustDecrease: /* @__PURE__ */ __name(({
5889
+ runtime: current,
5890
+ nextMaterialization,
5891
+ decision
5892
+ }) => {
5893
+ if (current.trusted && !decision.targetTrusted) return true;
5894
+ if (!current.primary || !current.trusted) return false;
5895
+ try {
5896
+ const previous = JSON.parse(
5897
+ current.trustMaterialization ?? "{}"
5898
+ );
5899
+ const next = JSON.parse(nextMaterialization);
5900
+ if (!Array.isArray(previous.boundWorkspaces) || !Array.isArray(next.boundWorkspaces)) {
5901
+ return true;
5902
+ }
5903
+ const nextRoots = new Set(
5904
+ next.boundWorkspaces.filter(
5905
+ (value) => typeof value === "string"
5906
+ )
5907
+ );
5908
+ return previous.boundWorkspaces.some(
5909
+ (value) => typeof value !== "string" || !nextRoots.has(value)
5910
+ );
5911
+ } catch {
5912
+ return true;
5913
+ }
5914
+ }, "isTrustDecrease"),
5915
+ buildRuntime: /* @__PURE__ */ __name(async ({
5916
+ entry,
5917
+ trusted,
5918
+ snapshot,
5919
+ decision,
5920
+ generationGuard
5921
+ }) => {
5922
+ const materialized = materializationFor(
5923
+ entry,
5924
+ snapshot,
5925
+ trusted === decision.targetTrusted ? decision : { ...decision, targetTrusted: trusted }
5926
+ );
5927
+ return createDynamicWorkspaceRuntime(entry.workspaceCwd, {
5928
+ trusted,
5929
+ snapshot,
5930
+ decision,
5931
+ generationGuard,
5932
+ primary: entry.primary,
5933
+ removable: entry.removable,
5934
+ displayName: entry.displayName,
5935
+ registrationIds: entry.registrationIds,
5936
+ boundWorkspaces: materialized.boundWorkspaces,
5937
+ trustMaterialization: materialized.key
5938
+ });
5939
+ }, "buildRuntime"),
5940
+ drainRuntime: /* @__PURE__ */ __name(async (runtimeToDrain) => {
5941
+ workspaceRuntimeRemoval.beginDrain(runtimeToDrain);
5942
+ acpHandle()?.beginWorkspaceDrain(runtimeToDrain.workspaceId);
5943
+ }, "drainRuntime"),
5944
+ disposeRuntime: /* @__PURE__ */ __name(async (runtimeToDispose, reason) => {
5945
+ const errors = [];
5946
+ try {
5947
+ await workspaceRuntimeRemoval.disposeRuntime(
5948
+ runtimeToDispose,
5949
+ reason
5950
+ );
5951
+ } catch (error) {
5952
+ errors.push(error);
5953
+ }
5954
+ try {
5955
+ const handle = acpHandle();
5956
+ if (!runtimeToDispose.primary) {
5957
+ handle?.commitWorkspaceRemoval(runtimeToDispose.workspaceId);
5958
+ }
5959
+ handle?.disposeWorkspace(runtimeToDispose.workspaceId);
5960
+ const deadline = Date.now() + 1e3;
5961
+ while ((handle?.getWorkspaceActivity(runtimeToDispose.workspaceId).memoryTasks ?? 0) > 0 && Date.now() < deadline) {
5962
+ await new Promise((resolve) => setTimeout(resolve, 25));
5963
+ }
5964
+ if ((handle?.getWorkspaceActivity(runtimeToDispose.workspaceId).memoryTasks ?? 0) > 0) {
5965
+ throw new Error(
5966
+ "Workspace memory tasks did not stop after runtime disposal."
5967
+ );
5968
+ }
5969
+ } catch (error) {
5970
+ errors.push(error);
5971
+ }
5972
+ if (errors.length === 1) throw errors[0];
5973
+ if (errors.length > 1) {
5974
+ throw new AggregateError(
5975
+ errors,
5976
+ "Workspace runtime and ACP cleanup failed."
5977
+ );
5978
+ }
5979
+ }, "disposeRuntime"),
5980
+ runtimeActivated: /* @__PURE__ */ __name(async (runtimeAdded) => {
5981
+ workspaceRuntimeRemoval.cancelDrain(runtimeAdded);
5982
+ acpHandle()?.cancelWorkspaceDrain(runtimeAdded.workspaceId);
5983
+ if (runtimeAdded.primary) {
5984
+ bridgeRef = runtimeAdded.bridge;
5985
+ invalidatePrimaryServeFeaturesCache();
5986
+ }
5987
+ await workspaceRuntimeRemoval.runtimeAdded(runtimeAdded);
5988
+ }, "runtimeActivated"),
5989
+ onError: /* @__PURE__ */ __name((entry, error) => {
5990
+ daemonLog.error(
5991
+ `workspace trust reconciliation failed for ${entry.workspaceCwd}`,
5992
+ error instanceof Error ? error : null
5993
+ );
5994
+ }, "onError")
5995
+ });
5996
+ const trustMonitor = createDaemonTrustPolicyMonitor({
5997
+ onSnapshot: /* @__PURE__ */ __name((snapshot) => {
5998
+ latestTrustPolicySnapshot = snapshot;
5999
+ return runWorkspaceTrustOperation(
6000
+ () => trustReconciler.reconcile(snapshot)
6001
+ );
6002
+ }, "onSnapshot"),
6003
+ onError: /* @__PURE__ */ __name((error) => {
6004
+ daemonLog.error(
6005
+ "workspace trust policy monitor failed",
6006
+ error instanceof Error ? error : null
6007
+ );
6008
+ }, "onError")
6009
+ });
6010
+ app2.locals.stopTrustPolicyMonitor = () => trustMonitor.stop();
6011
+ app2.locals.requestTrustReconcile = () => trustMonitor.requestReconcile("manual");
6012
+ app2.locals.waitForTrustPolicyIdle = () => runWorkspaceTrustOperation(async () => void 0);
6013
+ await trustMonitor.start();
6014
+ }
6015
+ const activePrimaryBridge = workspaceRegistry.primaryEntry.current?.runtime.bridge;
6016
+ bridgeRef = activePrimaryBridge;
6017
+ return { app: app2, bridge: activePrimaryBridge };
5439
6018
  }, "buildRuntime");
5440
6019
  if (deps.bridge) {
5441
6020
  const runtime = await buildRuntime();
@@ -5492,46 +6071,89 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5492
6071
  );
5493
6072
  }
5494
6073
  const channelValidationSettingsRuntime = opts.channelSelection ? await loadSettingsRuntimeModules() : void 0;
6074
+ const channelValidationTrustPolicy = opts.channelSelection ? await import("./daemon-trust-policy-ILUDTLHD.js") : void 0;
6075
+ const channelValidationTrustSnapshot = channelValidationTrustPolicy ? await channelValidationTrustPolicy.readDaemonTrustPolicySnapshot() : void 0;
5495
6076
  const resolveChannelWorkspaceGroupsAtListen = /* @__PURE__ */ __name(() => {
5496
6077
  if (!opts.channelSelection || !channelValidationSettingsRuntime || !channelRuntime) {
5497
6078
  return void 0;
5498
6079
  }
6080
+ const registry = (runtimeApp ?? runtimeAppForCleanup)?.locals?.["workspaceRegistry"];
6081
+ const resolveRuntime = /* @__PURE__ */ __name((workspaceCwd) => {
6082
+ const runtime = registry?.getByWorkspaceCwd(workspaceCwd);
6083
+ if (registry && !runtime) {
6084
+ throw Object.assign(
6085
+ new Error(`Workspace "${workspaceCwd}" is unavailable.`),
6086
+ { code: "workspace_unavailable" }
6087
+ );
6088
+ }
6089
+ return runtime;
6090
+ }, "resolveRuntime");
6091
+ const resolveTrusted = /* @__PURE__ */ __name((workspaceCwd, primary, runtime) => {
6092
+ if (runtime) return runtime.trusted;
6093
+ if (primary && deps.trustedWorkspace !== void 0) {
6094
+ return deps.trustedWorkspace;
6095
+ }
6096
+ if (!channelValidationTrustPolicy || !channelValidationTrustSnapshot) {
6097
+ return false;
6098
+ }
6099
+ return channelValidationTrustPolicy.evaluateDaemonWorkspaceTrust(
6100
+ channelValidationTrustSnapshot,
6101
+ workspaceCwd
6102
+ ).targetTrusted;
6103
+ }, "resolveTrusted");
5499
6104
  const settingsByWorkspace = /* @__PURE__ */ new Map();
5500
6105
  if (workspaceInputs.length === 1) {
5501
6106
  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,
6107
+ const runtime = resolveRuntime(workspace.cwd);
6108
+ const trusted = resolveTrusted(workspace.cwd, true, runtime);
6109
+ if (!trusted) {
6110
+ throw Object.assign(
6111
+ new Error(
6112
+ `Primary workspace "${workspace.cwd}" is not trusted; cannot host channels.`
6113
+ ),
6114
+ { code: "untrusted_workspace" }
6115
+ );
6116
+ }
6117
+ const effectiveEnv = runtime ? workspaceRuntimeEffectiveEnv(runtime, daemonRuntimeBaseEnv) : channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
6118
+ channelValidationSettingsRuntime.settings.loadSettings(
5509
6119
  workspace.cwd,
5510
- daemonRuntimeBaseEnv
5511
- ).effectiveEnv
5512
- );
6120
+ {
6121
+ skipLoadEnvironment: true,
6122
+ skipWorkspaceSettings: false,
6123
+ workspaceTrusted: true
6124
+ }
6125
+ ).merged,
6126
+ workspace.cwd,
6127
+ daemonRuntimeBaseEnv,
6128
+ trusted
6129
+ ).effectiveEnv;
6130
+ channelWebhookEnvByWorkspace.set(workspace.cwd, effectiveEnv);
5513
6131
  return void 0;
5514
6132
  }
5515
6133
  const workspaces = workspaceInputs.map((workspace, index) => {
6134
+ const runtime = resolveRuntime(workspace.cwd);
6135
+ const trusted = resolveTrusted(workspace.cwd, index === 0, runtime);
5516
6136
  const settings = channelValidationSettingsRuntime.settings.loadSettings(
5517
- workspace.cwd
6137
+ workspace.cwd,
6138
+ {
6139
+ skipLoadEnvironment: true,
6140
+ skipWorkspaceSettings: !trusted,
6141
+ workspaceTrusted: trusted
6142
+ }
5518
6143
  );
5519
6144
  settingsByWorkspace.set(workspace.cwd, settings);
5520
6145
  channelWebhookEnvByWorkspace.set(
5521
6146
  workspace.cwd,
5522
- channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
6147
+ runtime ? workspaceRuntimeEffectiveEnv(runtime, daemonRuntimeBaseEnv) : channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
5523
6148
  settings.merged,
5524
6149
  workspace.cwd,
5525
- daemonRuntimeBaseEnv
6150
+ daemonRuntimeBaseEnv,
6151
+ trusted
5526
6152
  ).effectiveEnv
5527
6153
  );
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
6154
  return {
5533
6155
  workspaceCwd: workspace.cwd,
5534
- primary: index === 0,
6156
+ primary: runtime?.primary ?? index === 0,
5535
6157
  trusted
5536
6158
  };
5537
6159
  });
@@ -5751,9 +6373,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5751
6373
  }
5752
6374
  const runtimes = registry.list();
5753
6375
  if (runtimes.length <= 1 && operation === "initial") {
6376
+ const primary = registry.primary;
6377
+ if (!primary.trusted) {
6378
+ throw Object.assign(
6379
+ new Error(
6380
+ `Primary workspace "${primary.workspaceCwd}" is not trusted; cannot host channels.`
6381
+ ),
6382
+ { code: "untrusted_workspace" }
6383
+ );
6384
+ }
5754
6385
  return [
5755
6386
  {
5756
- workspaceCwd: registry.primary.workspaceCwd,
6387
+ workspaceCwd: primary.workspaceCwd,
5757
6388
  selection: channelSelection
5758
6389
  }
5759
6390
  ];
@@ -5764,7 +6395,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5764
6395
  const grouping = resolveChannelWorkspaceGroups({
5765
6396
  workspaces: runtimes.map((runtime) => {
5766
6397
  const settings = settingsRuntime.settings.loadSettings(
5767
- runtime.workspaceCwd
6398
+ runtime.workspaceCwd,
6399
+ {
6400
+ skipLoadEnvironment: true,
6401
+ skipWorkspaceSettings: !runtime.trusted,
6402
+ workspaceTrusted: runtime.trusted
6403
+ }
5768
6404
  );
5769
6405
  settingsByWorkspace.set(runtime.workspaceCwd, settings);
5770
6406
  return {
@@ -5935,7 +6571,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5935
6571
  );
5936
6572
  return;
5937
6573
  }
5938
- if (shouldPreheat) {
6574
+ if (shouldPreheat && runtime.bridge) {
5939
6575
  startBridgePreheat(runtime.bridge);
5940
6576
  }
5941
6577
  await completeRuntimeStartup(runtime.app);
@@ -5977,6 +6613,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5977
6613
  if (shuttingDown) {
5978
6614
  daemonLog.warn(`received ${signal} during drain \u2014 forcing exit`);
5979
6615
  try {
6616
+ managedProcessRegistry?.killAllSync();
5980
6617
  channelWorkerManager?.killAllSync();
5981
6618
  for (const runtimeBridge of getRuntimeBridgesForCleanup()) {
5982
6619
  runtimeBridge.killAllSync();
@@ -6004,7 +6641,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6004
6641
  process.exit(runtimeStartupError === void 0 ? 0 : 1);
6005
6642
  } catch (err) {
6006
6643
  daemonLog.error("shutdown error", err instanceof Error ? err : null);
6007
- if (channelWorkerManager?.state().enabled) {
6644
+ if (err instanceof Error && retryableChannelWorkerShutdownErrors.has(err)) {
6008
6645
  daemonLog.error(
6009
6646
  "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
6647
  );
@@ -6037,6 +6674,14 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6037
6674
  const initiallyMountedApp = runtimeApp ?? runtimeAppForCleanup;
6038
6675
  const initiallyMountedManagement = initiallyMountedApp?.locals?.["workspaceManagementHandle"];
6039
6676
  const initialManagementWait = initiallyMountedManagement?.sealAndWait?.();
6677
+ let processRegistryShutdown;
6678
+ const startProcessRegistryShutdown = /* @__PURE__ */ __name(() => {
6679
+ processRegistryShutdown ??= managedProcessRegistry?.shutdown().then(
6680
+ () => void 0,
6681
+ (error2) => error2 instanceof Error ? error2 : new Error(String(error2))
6682
+ );
6683
+ }, "startProcessRegistryShutdown");
6684
+ startProcessRegistryShutdown();
6040
6685
  clearRuntimeStartAfterHealthTimer();
6041
6686
  clearRuntimeStartFallbackTimer();
6042
6687
  cancelDeferredRuntimeStartup();
@@ -6065,6 +6710,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6065
6710
  const finalErr = err ?? bridgeShutdownError ?? channelWorkerShutdownError;
6066
6711
  const retryableChannelClose = channelWorkerShutdownError !== void 0 && channelWorkerManager?.state().enabled === true;
6067
6712
  if (retryableChannelClose) {
6713
+ const retryableError = channelWorkerShutdownError;
6068
6714
  await flushDaemonLogBounded(
6069
6715
  daemonLog,
6070
6716
  DAEMON_LOG_FORCED_FLUSH_BUDGET_MS
@@ -6072,13 +6718,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6072
6718
  closePromise = void 0;
6073
6719
  shuttingDown = false;
6074
6720
  channelControlDraining = false;
6075
- rej(finalErr);
6721
+ retryableChannelWorkerShutdownErrors.add(retryableError);
6722
+ rej(retryableError);
6076
6723
  return;
6077
6724
  }
6078
6725
  if (loggerPublished || loggerSignalOwned) {
6079
- writeDaemonLifecycleBestEffort(
6080
- () => daemonLog.info("daemon stopped")
6081
- );
6726
+ writeDaemonLifecycleBestEffort(() => {
6727
+ if (finalErr) {
6728
+ daemonLog.error("daemon shutdown incomplete", finalErr);
6729
+ } else {
6730
+ daemonLog.info("daemon stopped");
6731
+ }
6732
+ });
6082
6733
  await daemonLog.close();
6083
6734
  }
6084
6735
  if (finalErr) rej(finalErr);
@@ -6101,6 +6752,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6101
6752
  if (workspaceManagementHandle !== initiallyMountedManagement) {
6102
6753
  await workspaceManagementHandle?.sealAndWait?.();
6103
6754
  }
6755
+ stopTrustPolicyMonitor(appForCleanup);
6756
+ const waitForTrustPolicyIdle = appForCleanup?.locals?.["waitForTrustPolicyIdle"];
6757
+ await waitForTrustPolicyIdle?.().catch((err) => {
6758
+ daemonLog.error(
6759
+ "workspace trust reconciliation shutdown wait failed",
6760
+ err instanceof Error ? err : null
6761
+ );
6762
+ });
6763
+ startProcessRegistryShutdown();
6104
6764
  disposeRuntimeAppResources(appForCleanup);
6105
6765
  disposeDaemonEventLoopMonitor();
6106
6766
  if (channelWorkerManager) {
@@ -6151,6 +6811,14 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6151
6811
  bridgeShutdownError = err instanceof Error ? err : new Error(String(err));
6152
6812
  });
6153
6813
  }
6814
+ const processRegistryError = await processRegistryShutdown;
6815
+ if (processRegistryError) {
6816
+ daemonLog.error(
6817
+ "ACP process registry shutdown error",
6818
+ processRegistryError
6819
+ );
6820
+ bridgeShutdownError ??= processRegistryError;
6821
+ }
6154
6822
  }).finally(() => {
6155
6823
  if (!server.listening) {
6156
6824
  void (runtimeFailureListenerClose ?? Promise.resolve()).then(
@@ -6233,7 +6901,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6233
6901
  closeErr instanceof Error ? closeErr : null
6234
6902
  )
6235
6903
  );
6236
- if (channelWorkerManager?.state().enabled) {
6904
+ if (closeErr instanceof Error && retryableChannelWorkerShutdownErrors.has(closeErr)) {
6237
6905
  writeDaemonLifecycleBestEffort(
6238
6906
  () => daemonLog.error(
6239
6907
  "runtime startup failed, but qwen serve remains alive to retain the channel service lease until worker exit is confirmed"