@qwen-code/qwen-code 0.21.0 → 0.21.1-nightly.20260731.702932cc7

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 (423) hide show
  1. package/bundled/qc-helper/docs/configuration/model-providers.md +2 -0
  2. package/bundled/qc-helper/docs/configuration/settings.md +39 -28
  3. package/bundled/qc-helper/docs/features/channels/_meta.ts +2 -0
  4. package/bundled/qc-helper/docs/features/channels/github.md +139 -0
  5. package/bundled/qc-helper/docs/features/channels/gitlab.md +171 -0
  6. package/bundled/qc-helper/docs/features/channels/overview.md +61 -6
  7. package/bundled/qc-helper/docs/features/code-review.md +21 -1
  8. package/bundled/qc-helper/docs/features/hooks.md +72 -15
  9. package/bundled/qc-helper/docs/features/mcp.md +9 -1
  10. package/bundled/qc-helper/docs/features/scheduled-tasks.md +3 -1
  11. package/bundled/qc-helper/docs/features/sub-agents.md +42 -8
  12. package/bundled/qc-helper/docs/qwen-serve.md +11 -7
  13. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +2 -2
  14. package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
  15. package/bundled/review/DESIGN.md +19 -0
  16. package/bundled/review/SKILL.md +120 -61
  17. package/chunks/MaxSizedBox-LAFHK4VO.js +88 -0
  18. package/chunks/{StandaloneSessionPicker-BIRMPLRD.js → StandaloneSessionPicker-EMNOBN3S.js} +71 -68
  19. package/chunks/{acp-startup-profiler-RV3IV562.js → acp-startup-profiler-2C4A5ZTJ.js} +2 -2
  20. package/chunks/{acpAgent-6J2U72PQ.js → acpAgent-ERFA6HWV.js} +1674 -591
  21. package/chunks/agent-PLKF6JK4.js +84 -0
  22. package/chunks/agent-headless-JAORDQ63.js +78 -0
  23. package/chunks/{anthropicContentGenerator-75BKLTSP.js → anthropicContentGenerator-OFHSZJBF.js} +79 -27
  24. package/chunks/{artifact-tool-Y5T7GG7F.js → artifact-tool-RDN2W7ND.js} +4 -4
  25. package/chunks/{askUserQuestion-2H6747FR.js → askUserQuestion-OZERWH5R.js} +4 -4
  26. package/chunks/bridge-NYOBVRIT.js +94 -0
  27. package/chunks/{build-RV63TIRH.js → build-GDBLPA24.js} +1 -1
  28. package/chunks/{ca-25EDXPFZ.js → ca-6W3SK7OQ.js} +6 -1
  29. package/chunks/channel-management-service-5S7YCWX5.js +418 -0
  30. package/chunks/channel-settings-store-NLOKYO23.js +91 -0
  31. package/chunks/{channel-worker-group-2ZD7TVAT.js → channel-worker-group-OVWGYMZS.js} +11 -6
  32. package/chunks/{channel-worker-manager-4OA4BCGB.js → channel-worker-manager-H55GKOQA.js} +11 -6
  33. package/chunks/{channel-worker-supervisor-V7KCFJTS.js → channel-worker-supervisor-CABBXYHK.js} +7 -5
  34. package/chunks/{chunk-RIBKPMRP.js → chunk-23F4XGWO.js} +19 -6
  35. package/chunks/{chunk-ACY3A37B.js → chunk-25VHI5T7.js} +23 -18
  36. package/chunks/{chunk-MZAXJAUM.js → chunk-26JK4RPD.js} +1 -1
  37. package/chunks/{chunk-6GMVPFB2.js → chunk-2IIJTXYF.js} +45 -16
  38. package/chunks/{chunk-BPJSQIJX.js → chunk-2J3OJGTL.js} +0 -2
  39. package/chunks/{chunk-2X55UKQE.js → chunk-2JZR3B4A.js} +3 -3
  40. package/chunks/{chunk-7JURR4JT.js → chunk-2OQUICDM.js} +167 -81
  41. package/chunks/{chunk-ZJHVAS7M.js → chunk-2YCYFWYZ.js} +4 -5
  42. package/chunks/{chunk-3QMGYBFN.js → chunk-3APUUXRF.js} +1 -80
  43. package/chunks/{chunk-MUP3T3AD.js → chunk-3I6DUGQD.js} +1 -35
  44. package/chunks/{chunk-JVPM2ULZ.js → chunk-3XZ5SSNR.js} +6 -6
  45. package/chunks/chunk-42VPM33K.js +319 -0
  46. package/chunks/{chunk-VAK25FTU.js → chunk-45IOTAUS.js} +1 -1
  47. package/chunks/chunk-45UYUCJ6.js +363 -0
  48. package/chunks/{chunk-JZA3JUDJ.js → chunk-4KP2F2TE.js} +1 -1
  49. package/chunks/{chunk-IO3IX5Q4.js → chunk-4YJQD2IO.js} +1 -1
  50. package/chunks/{chunk-JXJFVC6E.js → chunk-5G6XUGXO.js} +61 -14
  51. package/chunks/{chunk-ZOIFNCKL.js → chunk-5NNHICSA.js} +3 -23
  52. package/chunks/{chunk-A4UCTEB5.js → chunk-5WV5S2GT.js} +0 -1
  53. package/chunks/{chunk-RHLZR4E5.js → chunk-675H6PLP.js} +1 -1
  54. package/chunks/chunk-6FMJLI5M.js +1591 -0
  55. package/chunks/chunk-6MPDY6ZG.js +76 -0
  56. package/chunks/{chunk-PSOO6YXD.js → chunk-6NUWQ3R7.js} +9 -7
  57. package/chunks/{chunk-7MVVZO4N.js → chunk-6ZRWX46I.js} +4 -4
  58. package/chunks/{chunk-TPRQ7RZH.js → chunk-76E5Y3UZ.js} +3117 -993
  59. package/chunks/{chunk-UUUTRMI2.js → chunk-7ULQIS27.js} +1 -1
  60. package/chunks/{chunk-BKHWX6I2.js → chunk-A5BZ722X.js} +11 -3
  61. package/chunks/{chunk-TEHGS6UP.js → chunk-A5T5W7PR.js} +154 -16
  62. package/chunks/{chunk-VIA5XA4U.js → chunk-A5UODYG3.js} +4 -1
  63. package/chunks/{chunk-JLU636DO.js → chunk-ALMR3E6Q.js} +1 -0
  64. package/chunks/{chunk-EBJQ6AXW.js → chunk-ANDVK2JN.js} +358 -14
  65. package/chunks/{chunk-TOFQCPDC.js → chunk-AOHY3QJ3.js} +14 -8
  66. package/chunks/chunk-AQ37AY7B.js +93 -0
  67. package/chunks/{chunk-PJIZUQVC.js → chunk-AZQ3DT76.js} +2 -2
  68. package/chunks/{chunk-LKEJ26GS.js → chunk-B3TA3IF5.js} +16 -11
  69. package/chunks/{chunk-Q4M4MDQ4.js → chunk-B43QHWY6.js} +1 -1
  70. package/chunks/{chunk-UH3WSE5L.js → chunk-B4AJNNOL.js} +1 -6
  71. package/chunks/{chunk-K36B6G2O.js → chunk-B6FOGNGH.js} +5 -5
  72. package/chunks/{chunk-PWVFN2LF.js → chunk-BP2H5K25.js} +1 -1
  73. package/chunks/{chunk-LB6DUZ26.js → chunk-BTWSGZCT.js} +264 -185
  74. package/chunks/{chunk-ZNAUOR2I.js → chunk-BZBPT52P.js} +2 -2
  75. package/chunks/{chunk-L26JL52R.js → chunk-CBBP4BMC.js} +64 -67
  76. package/chunks/{chunk-ZD6UTE4A.js → chunk-CNTR4GR6.js} +1 -1
  77. package/chunks/{chunk-3SJ43L4W.js → chunk-CPZAH673.js} +6 -0
  78. package/chunks/{chunk-EPDRMGT4.js → chunk-D4HTUMGX.js} +4 -28
  79. package/chunks/{chunk-QAF7NMK7.js → chunk-D7CQTWRS.js} +1 -1
  80. package/chunks/{chunk-XVNQMZ2I.js → chunk-DGEIYUC3.js} +0 -1
  81. package/chunks/{chunk-BPZALHVR.js → chunk-DI35ZN7T.js} +1 -1
  82. package/chunks/{chunk-IKCX4CCL.js → chunk-DKPJUF5F.js} +118 -95
  83. package/chunks/{chunk-DLWL3Z7A.js → chunk-DSFHVTWD.js} +3 -3
  84. package/chunks/{chunk-FSITMZJH.js → chunk-DYRYLJ3O.js} +18 -9
  85. package/chunks/{chunk-NL7LTRLR.js → chunk-E2BHWIDT.js} +48 -72
  86. package/chunks/{chunk-UDX5OBWR.js → chunk-E2FN6SM7.js} +94 -4
  87. package/chunks/{chunk-USTWD7QV.js → chunk-E6CJ2SMM.js} +26 -16
  88. package/chunks/{chunk-KMQ33DO4.js → chunk-EDB7A72S.js} +4 -4
  89. package/chunks/{chunk-7ZCNENPP.js → chunk-FANRZEAJ.js} +1 -1
  90. package/chunks/{chunk-WBL3FJEU.js → chunk-FC4KQFCS.js} +1 -1
  91. package/chunks/{chunk-5NBDS5S6.js → chunk-FCYYAB4S.js} +162 -7
  92. package/chunks/{chunk-OKY7HXPG.js → chunk-FJ5WUMUQ.js} +2 -2
  93. package/chunks/{chunk-PHOF65IG.js → chunk-FRXG4ARO.js} +36273 -44436
  94. package/chunks/{chunk-FQK6JAFG.js → chunk-FS674JW4.js} +4 -4
  95. package/chunks/chunk-FYJ7W2PI.js +194 -0
  96. package/chunks/{chunk-BULDBTYC.js → chunk-G7XXKQYS.js} +3 -28
  97. package/chunks/{chunk-LS77BEZP.js → chunk-GLCZKT5V.js} +1 -5
  98. package/chunks/{chunk-VRYUBFMC.js → chunk-GRUAVQQR.js} +1 -1
  99. package/chunks/{chunk-MVSUYZDT.js → chunk-GWV7DI3S.js} +4 -4
  100. package/chunks/{chunk-A5L3JMUA.js → chunk-HC45LTEN.js} +18 -4
  101. package/chunks/{chunk-PC6JANNU.js → chunk-HKRVXYDN.js} +4 -4
  102. package/chunks/{chunk-GZXCZHCT.js → chunk-I3G5JWBV.js} +1 -1
  103. package/chunks/{chunk-4WIZGAH3.js → chunk-I5BT7ADR.js} +6 -58
  104. package/chunks/{chunk-GSN55ZRI.js → chunk-ID3O7PRB.js} +19 -7
  105. package/chunks/{chunk-L5UHQJTJ.js → chunk-IGTHU3T4.js} +1 -1
  106. package/chunks/{chunk-BIQWWWJN.js → chunk-IIUGIWWY.js} +1 -1
  107. package/chunks/{chunk-RWTEFFPU.js → chunk-JCJ7LKNA.js} +6140 -5616
  108. package/chunks/{chunk-S3TWXGKA.js → chunk-JE7KQ2UP.js} +4 -2
  109. package/chunks/{chunk-PWTZEM3C.js → chunk-JXVC2PL3.js} +3 -37
  110. package/chunks/chunk-JYBU6YUE.js +378 -0
  111. package/chunks/{chunk-RF3EXIHJ.js → chunk-K3PFMM5U.js} +49 -26
  112. package/chunks/{chunk-JCW2R7WC.js → chunk-K623ENWT.js} +3 -79
  113. package/chunks/{chunk-T2NCM2ET.js → chunk-K6KS3LTN.js} +2 -749
  114. package/chunks/chunk-KWHKHSIS.js +81 -0
  115. package/chunks/{chunk-DHHOYAPR.js → chunk-L2E5GFAG.js} +7 -7
  116. package/chunks/{chunk-2W3OOD4W.js → chunk-L55JWS76.js} +6 -3
  117. package/chunks/{chunk-E5TUC6CA.js → chunk-LHKCY7DY.js} +3 -3
  118. package/chunks/{chunk-NH6KE4JX.js → chunk-LOY7RWQG.js} +3 -3
  119. package/chunks/{chunk-U7M2DMGW.js → chunk-M4MSAE7U.js} +130 -5
  120. package/chunks/{chunk-IJTOWOD7.js → chunk-MB32MS4U.js} +92 -9
  121. package/chunks/{chunk-PR75REBZ.js → chunk-MM7TH7ZM.js} +12 -82
  122. package/chunks/{chunk-FODK6UMO.js → chunk-MPHPFVKK.js} +0 -2
  123. package/chunks/{chunk-M5JM7OSF.js → chunk-N4ACHWNH.js} +2 -3
  124. package/chunks/{chunk-JESCGQM3.js → chunk-NAVJD2PQ.js} +8 -7
  125. package/chunks/{chunk-J56UI34H.js → chunk-NBD76HUW.js} +4 -2
  126. package/chunks/{chunk-2SCDWPXI.js → chunk-NC4U4I3Y.js} +5 -5
  127. package/chunks/{chunk-H4SBPHSA.js → chunk-NNL7WPPK.js} +3 -3
  128. package/chunks/{chunk-YBL3QUDD.js → chunk-NQCXWP5D.js} +1 -1
  129. package/chunks/{chunk-CIKQ7KKO.js → chunk-NVFSGPIF.js} +954 -444
  130. package/chunks/{chunk-6OUGMXDC.js → chunk-NWNEANAT.js} +7 -7
  131. package/chunks/chunk-O6GEWCJA.js +21 -0
  132. package/chunks/chunk-OCPBI7J5.js +18 -0
  133. package/chunks/{chunk-KIM5GUMA.js → chunk-OE6F6ZWQ.js} +589 -220
  134. package/chunks/{chunk-SQCQ4KO2.js → chunk-P5DEY3NF.js} +380 -317
  135. package/chunks/{chunk-2JZBVYTU.js → chunk-Q3T5KA2V.js} +1 -8
  136. package/chunks/{chunk-MB4MZHMJ.js → chunk-QARJNL2V.js} +211 -522
  137. package/chunks/{chunk-YH6G52F2.js → chunk-QCXGC7QB.js} +4 -4
  138. package/chunks/chunk-QDK4F2N5.js +1252 -0
  139. package/chunks/{chunk-VDDGDZMA.js → chunk-QHWCP53L.js} +14 -7
  140. package/chunks/{chunk-VULLI6WQ.js → chunk-QIERF2GQ.js} +6 -6
  141. package/chunks/{chunk-TGILQ3YH.js → chunk-QQTJK5GB.js} +200 -77
  142. package/chunks/{chunk-H5FFA6TH.js → chunk-QTHQ6Z5X.js} +16 -3
  143. package/chunks/{chunk-5I2IWRSH.js → chunk-R2XWGR75.js} +2 -2
  144. package/chunks/{chunk-YPE6A4GC.js → chunk-RT7FNC2O.js} +2 -2
  145. package/chunks/{chunk-OFDOK3VM.js → chunk-RX7NJOPE.js} +8 -13
  146. package/chunks/{chunk-6AM5D4ME.js → chunk-S6LOFUVP.js} +0 -12
  147. package/chunks/{chunk-K4XWPEWB.js → chunk-SHN4KHDK.js} +4 -33
  148. package/chunks/{chunk-VYPFXUCB.js → chunk-SZ3KHTDR.js} +1 -1
  149. package/chunks/chunk-T26EAKDL.js +13 -0
  150. package/chunks/chunk-T3CHYWJZ.js +758 -0
  151. package/chunks/{chunk-FNQ6T3CV.js → chunk-TEGJSJDF.js} +10 -7
  152. package/chunks/{chunk-RZIX2G32.js → chunk-THPORXSI.js} +1 -1
  153. package/chunks/{chunk-OHNBB4XR.js → chunk-THVU3RNH.js} +1 -1
  154. package/chunks/{record-artifact-RQKFYO5B.js → chunk-TIRRPCFS.js} +22 -7
  155. package/chunks/{chunk-ETSW4KLJ.js → chunk-TUCOXPHJ.js} +2 -2
  156. package/chunks/{chunk-63P4EL5V.js → chunk-TZTAV5RH.js} +1 -1
  157. package/chunks/{chunk-LK7CHLVP.js → chunk-U4VTUMMK.js} +0 -60
  158. package/chunks/{chunk-3RN6GBKS.js → chunk-U5CODIJW.js} +1 -1
  159. package/chunks/chunk-UU2B5YG6.js +2196 -0
  160. package/chunks/{chunk-R5AFZNQW.js → chunk-VAVHTGU4.js} +15 -8
  161. package/chunks/{chunk-2NH6DYI4.js → chunk-VHPFWR2O.js} +12 -12
  162. package/chunks/{chunk-IKYJHJNF.js → chunk-VOMQ2P6B.js} +3 -3
  163. package/chunks/{chunk-ZFDTEDCF.js → chunk-VX22DUW2.js} +6 -6
  164. package/chunks/{chunk-HTR4WV6U.js → chunk-W4RQUHY3.js} +31 -1
  165. package/chunks/{chunk-M4FMGVY4.js → chunk-WQP7BKWA.js} +3 -3
  166. package/chunks/{chunk-LH2BYDQ5.js → chunk-X2E5TFJ5.js} +18 -12
  167. package/chunks/{chunk-COH43MRJ.js → chunk-XCGIMOLN.js} +27 -1
  168. package/chunks/{chunk-YX324OPW.js → chunk-XDS22O52.js} +1 -1
  169. package/chunks/chunk-XP4L6KS3.js +463 -0
  170. package/chunks/{chunk-6FGBXPWM.js → chunk-XQK4XXTN.js} +38 -44
  171. package/chunks/{chunk-55DJUCI2.js → chunk-XWYPFDB5.js} +53 -43
  172. package/chunks/{chunk-Y34KJKDC.js → chunk-Y7BVNVVW.js} +1 -1
  173. package/chunks/{chunk-IPUUTYMV.js → chunk-YDLJGZHL.js} +1 -1
  174. package/chunks/{chunk-HIJQF5B5.js → chunk-YGE3IXJP.js} +1 -1
  175. package/chunks/{chunk-LQIW3YFY.js → chunk-YJFPRUWX.js} +9 -7
  176. package/chunks/{chunk-J24WCGIN.js → chunk-YQIIG4NA.js} +4 -4
  177. package/chunks/{chunk-BJX6ZSUK.js → chunk-YUFIEIWC.js} +2 -2
  178. package/chunks/{chunk-NIBLUX3Y.js → chunk-Z3S5EMOW.js} +148 -21
  179. package/chunks/{chunk-WCXCRJYB.js → chunk-Z3YLHKB7.js} +1 -1
  180. package/chunks/chunk-Z4X5MTRT.js +133 -0
  181. package/chunks/{chunk-UW5EOVUN.js → chunk-ZBVS26BY.js} +4 -4
  182. package/chunks/{chunk-HTO4JFDZ.js → chunk-ZPJWUGCS.js} +0 -1
  183. package/chunks/{chunk-X5XDDSSH.js → chunk-ZPZ7ZJEE.js} +28 -5
  184. package/chunks/{computer-use-SOQ4E3VX.js → computer-use-GOM42LNK.js} +53 -50
  185. package/chunks/{config-utils-7V7GGIW6.js → config-utils-WADIDWGG.js} +4 -3
  186. package/chunks/contextCommand-6LVPTIWD.js +83 -0
  187. package/chunks/core-runtime-253XV2DB.js +137 -0
  188. package/chunks/{create-sub-session-QRJLW5BV.js → create-sub-session-45POYEVP.js} +50 -47
  189. package/chunks/{create-sub-session-IWW2IZ2T.js → create-sub-session-62YZWVAY.js} +3 -3
  190. package/chunks/{cron-create-YIID5XAW.js → cron-create-6E7GIQTG.js} +6 -6
  191. package/chunks/{cron-delete-ZVHYCEP2.js → cron-delete-JD26XY3W.js} +5 -5
  192. package/chunks/{cron-list-XEGS463Q.js → cron-list-CUWFB44G.js} +6 -6
  193. package/chunks/{daemon-YO6433NF.js → daemon-PCNCI5YU.js} +428 -18
  194. package/chunks/daemon-status-provider-AKALDYJJ.js +93 -0
  195. package/chunks/daemon-trust-policy-XB7ZSQFQ.js +88 -0
  196. package/chunks/daemon-trust-policy-monitor-FUTKP42Q.js +175 -0
  197. package/chunks/{de-HGRCYDEJ.js → de-SY6O76BF.js} +6 -1
  198. package/chunks/deferred-core-runtime-RKLCO7V5.js +92 -0
  199. package/chunks/dist-26BIMQT6.js +4487 -0
  200. package/chunks/{dist-F6IBUDR4.js → dist-2PERFI23.js} +12 -9
  201. package/chunks/{dist-46NQKLTW.js → dist-OAOC5OV4.js} +2 -2
  202. package/chunks/{dist-YFNEUWSE.js → dist-PVEAFLHY.js} +5 -4
  203. package/chunks/{dist-AIKFMUKK.js → dist-SL2LUMML.js} +1449 -14
  204. package/chunks/dist-ULIG4M5H.js +13415 -0
  205. package/chunks/{dist-WEAHOXDM.js → dist-WGMNT3JQ.js} +2 -1
  206. package/chunks/{dist-BBLXMS3N.js → dist-ZHXOBXDN.js} +3 -3
  207. package/chunks/earlyInputCapture-FCWU47OB.js +85 -0
  208. package/chunks/{edit-OBDSQURM.js → edit-TTACM3LN.js} +51 -48
  209. package/chunks/{en-MTWBNGDO.js → en-NBK3JKCE.js} +9 -1
  210. package/chunks/{enter-worktree-U6MRPQ2P.js → enter-worktree-R34GFDX6.js} +51 -48
  211. package/chunks/{enterPlanMode-BC5QUZZ2.js → enterPlanMode-KJPBB6G5.js} +51 -48
  212. package/chunks/environment-IJG3N2PR.js +105 -0
  213. package/chunks/errors-MRON5OJD.js +91 -0
  214. package/chunks/esm-K5FARBNI.js +5548 -0
  215. package/chunks/{exit-worktree-DGNYMECB.js → exit-worktree-UBA66Y4I.js} +51 -48
  216. package/chunks/exitPlanMode-SMSPGNSK.js +76 -0
  217. package/chunks/{fast-path-JJZFJANL.js → fast-path-ZBAMZDCP.js} +16 -6
  218. package/chunks/{fr-45RLL55O.js → fr-4KG5V7UT.js} +6 -1
  219. package/chunks/{gemini-QS36EBZV.js → gemini-XFT7HRNL.js} +106 -99
  220. package/chunks/{geminiContentGenerator-AG4KB6CV.js → geminiContentGenerator-XD3MLYQX.js} +40 -11
  221. package/chunks/{getMachineId-bsd-V7W3GODC.js → getMachineId-bsd-FG7IUY6U.js} +1 -1
  222. package/chunks/{getMachineId-darwin-TDO75DQP.js → getMachineId-darwin-GLCJI2RA.js} +1 -1
  223. package/chunks/{getMachineId-linux-TF43WQT2.js → getMachineId-linux-O6OPPAKO.js} +1 -1
  224. package/chunks/{getMachineId-unsupported-ZGUO3TXT.js → getMachineId-unsupported-S6CKYVGC.js} +1 -1
  225. package/chunks/{getMachineId-win-ECFYZZFQ.js → getMachineId-win-X5SRNEH7.js} +1 -1
  226. package/chunks/{glob-V7R3PSK3.js → glob-HFKY7HXZ.js} +51 -48
  227. package/chunks/goal-tools-HGO6VXPB.js +335 -0
  228. package/chunks/{grep-QYPSK7OP.js → grep-EO5Z3PFV.js} +53 -49
  229. package/chunks/handleAutoUpdate-WRENFE6C.js +84 -0
  230. package/chunks/i18n-ZG5OTVSV.js +100 -0
  231. package/chunks/{image-gen-Z3VPGKRC.js → image-gen-CKWZ4MJI.js} +12 -12
  232. package/chunks/initializer-FYPLLRC7.js +89 -0
  233. package/chunks/installationInfo-5RV4HRMC.js +83 -0
  234. package/chunks/{ja-B7DF7DFG.js → ja-F3GSQXMF.js} +6 -1
  235. package/chunks/{keychain-token-storage-MDTG3WRM.js → keychain-token-storage-IKO4G53C.js} +3 -3
  236. package/chunks/lib-RUF3WZA6.js +9 -0
  237. package/chunks/list-ZNWVL3AT.js +92 -0
  238. package/chunks/{list-agents-5KJJHR6I.js → list-agents-PXJ7ZUFB.js} +3 -3
  239. package/chunks/loadedSettingsAdapter-GQGNHP5I.js +86 -0
  240. package/chunks/{loggingContentGenerator-HS3S5H3Q.js → loggingContentGenerator-MS5DFAWH.js} +78 -113
  241. package/chunks/{loop-wakeup-FXKNNYSY.js → loop-wakeup-Y26NQZ5I.js} +15 -8
  242. package/chunks/{ls-NTK6VOQJ.js → ls-ONQTTMQR.js} +5 -5
  243. package/chunks/{lsp-2JI24STP.js → lsp-YGHHRGMD.js} +3 -3
  244. package/chunks/{managed-npm-update-JYEMMXA3.js → managed-npm-update-67AK4GTL.js} +51 -48
  245. package/chunks/mcp-FVQ4VTLM.js +86 -0
  246. package/chunks/{monitor-R3ODH5U6.js → monitor-BXB33EOZ.js} +51 -48
  247. package/chunks/nonInteractiveCli-CN2GYSN3.js +148 -0
  248. package/chunks/{notebook-edit-BNOK452R.js → notebook-edit-FKYRBV4L.js} +51 -48
  249. package/chunks/{openaiContentGenerator-WMCU3O2H.js → openaiContentGenerator-UUXV5DGU.js} +26 -27
  250. package/chunks/pidfile-MV347TTZ.js +89 -0
  251. package/chunks/process-registry-2CHQBXH5.js +157 -0
  252. package/chunks/{processUtils-RT7UNCC2.js → processUtils-LKFG52RV.js} +2 -2
  253. package/chunks/{pt-22Q3FP73.js → pt-EQ33KWEN.js} +6 -1
  254. package/chunks/{qwenContentGenerator-HHCRK4SX.js → qwenContentGenerator-3WYI2HRW.js} +56 -53
  255. package/chunks/{qwenOAuth2-OWLB5AKH.js → qwenOAuth2-B46MW45O.js} +10 -10
  256. package/chunks/read-file-ACSHVWP3.js +29 -0
  257. package/chunks/{read-mcp-resource-4DKQWGHD.js → read-mcp-resource-U2IJN5HM.js} +4 -4
  258. package/chunks/record-artifact-MGPJ7EG4.js +21 -0
  259. package/chunks/resumeHistoryUtils-AMS4767B.js +94 -0
  260. package/chunks/ripGrep-BAPM2UKC.js +76 -0
  261. package/chunks/{ru-FZCNZHDC.js → ru-7OZAUKGG.js} +6 -1
  262. package/chunks/{run-qwen-serve-FU6HEM4J.js → run-qwen-serve-JEN6FO2A.js} +1018 -263
  263. package/chunks/runtime-WVP22ISH.js +122 -0
  264. package/chunks/{scheduler-G2ZS2Z7E.js → scheduler-HTX5ACVR.js} +50 -47
  265. package/chunks/{sdk-exporters-grpc-AK3LGHNO.js → sdk-exporters-grpc-54L4LS5L.js} +4 -4
  266. package/chunks/{sdk-exporters-http-FYBSUCPD.js → sdk-exporters-http-4BQANSJ6.js} +7 -7
  267. package/chunks/{sdk-impl-GMVPB7NB.js → sdk-impl-Z4VXWVFX.js} +14 -14
  268. package/chunks/{send-message-Q6OOR6BR.js → send-message-PMP4ATVM.js} +8 -13
  269. package/chunks/serve-ELQIVNWN.js +92 -0
  270. package/chunks/{server-4UMH7OIZ.js → server-JNW2NOSQ.js} +5288 -1364
  271. package/chunks/{session-K3O3Q2SV.js → session-NC356XNS.js} +102 -95
  272. package/chunks/{settings-CR2EWTBA.js → settings-73RMIOJ6.js} +54 -51
  273. package/chunks/shell-NMHF5TFG.js +86 -0
  274. package/chunks/{skill-I3SDA4MB.js → skill-XPGXHEKO.js} +22 -22
  275. package/chunks/skill-settings-5IGIJDGA.js +94 -0
  276. package/chunks/spawnChannel-T5THBHFN.js +85 -0
  277. package/chunks/standalone-update-ODXEPDLP.js +95 -0
  278. package/chunks/{startInteractiveUI-SLZGHRPH.js → startInteractiveUI-S27DXVAE.js} +1241 -905
  279. package/chunks/{syntheticOutput-I3757IWH.js → syntheticOutput-D7E6ZFKR.js} +4 -4
  280. package/chunks/task-create-NFCYD43L.js +26 -0
  281. package/chunks/{task-list-FOPULZEP.js → task-list-TAVMGEVD.js} +7 -7
  282. package/chunks/{task-stop-H6RHXFVQ.js → task-stop-ZDF2UJRM.js} +3 -3
  283. package/chunks/{task-update-M57TFZJT.js → task-update-6L7LHGEX.js} +12 -11
  284. package/chunks/{team-create-YJALH5D2.js → team-create-CTLQWTJ2.js} +53 -50
  285. package/chunks/{team-delete-QE2UXJL7.js → team-delete-DPGGRQBU.js} +7 -7
  286. package/chunks/{team-plan-approval-34QFYKGN.js → team-plan-approval-WKRUAPJ4.js} +51 -48
  287. package/chunks/theme-manager-XQHXQQX6.js +80 -0
  288. package/chunks/{todoWrite-VQ7FKOHL.js → todoWrite-2UO5G6G6.js} +34 -6
  289. package/chunks/{tool-search-NF7GB6LE.js → tool-search-45YINAJA.js} +21 -22
  290. package/chunks/total-session-admission-QPUKGHKO.js +88 -0
  291. package/chunks/trustedFolders-YMUTRHEQ.js +98 -0
  292. package/chunks/{update-relaunch-WBUZJC5O.js → update-relaunch-PZUXTVHC.js} +5 -5
  293. package/chunks/updateCheck-IZAN4XTB.js +95 -0
  294. package/chunks/useAutoAcceptIndicator-CGL2MAYE.js +96 -0
  295. package/chunks/{validateNonInterActiveAuth-3R223G3R.js → validateNonInterActiveAuth-GBGNJ65K.js} +97 -90
  296. package/chunks/{version-HS7YSFHV.js → version-Z7EX24NZ.js} +1 -1
  297. package/chunks/{web-fetch-NKCSG7ZE.js → web-fetch-ETTT2H3V.js} +19 -21
  298. package/chunks/{web-search-S62WAP4S.js → web-search-Y3ZSVRJ6.js} +13 -13
  299. package/chunks/{workflow-QAGU5RU4.js → workflow-ATRJSAO7.js} +52 -49
  300. package/chunks/workspace-providers-status-YM3WLW3N.js +89 -0
  301. package/chunks/{workspace-registration-store-24JMHDGF.js → workspace-registration-store-4EGNCIPG.js} +1 -1
  302. package/chunks/workspace-registry-NGZOZKQP.js +96 -0
  303. package/chunks/workspace-service-SVWOXX2B.js +103 -0
  304. package/chunks/workspace-skills-status-YZHZ3PT5.js +89 -0
  305. package/chunks/workspace-trust-reconciler-GGBQV2U5.js +349 -0
  306. package/chunks/write-file-HLGCEB72.js +78 -0
  307. package/chunks/xterm-headless-NTYVIBT3.js +3475 -0
  308. package/chunks/{zh-LUIGBD55.js → zh-H3YDK5QW.js} +9 -1
  309. package/chunks/{zh-TW-F5KG2IYD.js → zh-TW-JYCP7XUA.js} +9 -1
  310. package/chunks/zoom-image-LDECT475.js +224 -0
  311. package/cli.js +50 -16
  312. package/locales/ca.js +7 -2
  313. package/locales/de.js +7 -2
  314. package/locales/en.js +10 -2
  315. package/locales/fr.js +7 -2
  316. package/locales/ja.js +7 -2
  317. package/locales/pt.js +7 -2
  318. package/locales/ru.js +7 -2
  319. package/locales/zh-TW.js +10 -2
  320. package/locales/zh.js +10 -2
  321. package/package.json +5 -4
  322. package/web-shell/assets/{arc-DcbWnB9T.js → arc-Dpy_U6Bb.js} +1 -1
  323. package/web-shell/assets/{architectureDiagram-3BPJPVTR-kMMF5sud.js → architectureDiagram-3BPJPVTR-DgDOg-c5.js} +1 -1
  324. package/web-shell/assets/{blockDiagram-GPEHLZMM-Htl9vTJS.js → blockDiagram-GPEHLZMM-tADd9Ja3.js} +1 -1
  325. package/web-shell/assets/{c4Diagram-AAUBKEIU-BnZnm0mQ.js → c4Diagram-AAUBKEIU-68wj9MCU.js} +1 -1
  326. package/web-shell/assets/channel-Do7fFnFl.js +1 -0
  327. package/web-shell/assets/{chunk-2J33WTMH-DziB7kDG.js → chunk-2J33WTMH-DjJLOeVU.js} +1 -1
  328. package/web-shell/assets/{chunk-4BX2VUAB-CmkD8daw.js → chunk-4BX2VUAB-CMbzGeVC.js} +1 -1
  329. package/web-shell/assets/{chunk-55IACEB6-CHAd9A_U.js → chunk-55IACEB6-SlKgejv9.js} +1 -1
  330. package/web-shell/assets/{chunk-727SXJPM-Dqaam3fE.js → chunk-727SXJPM-CijXssHZ.js} +1 -1
  331. package/web-shell/assets/{chunk-AQP2D5EJ-D_-saBYM.js → chunk-AQP2D5EJ-D8w25nvR.js} +1 -1
  332. package/web-shell/assets/{chunk-FMBD7UC4-B9r_veWD.js → chunk-FMBD7UC4-Bv9dcx_e.js} +1 -1
  333. package/web-shell/assets/{chunk-ND2GUHAM-B3EaCSpL.js → chunk-ND2GUHAM-Bzf6sAOd.js} +1 -1
  334. package/web-shell/assets/{chunk-QZHKN3VN-CYq8x9mn.js → chunk-QZHKN3VN-whNoNeW5.js} +1 -1
  335. package/web-shell/assets/classDiagram-4FO5ZUOK-By_XOP3X.js +1 -0
  336. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-By_XOP3X.js +1 -0
  337. package/web-shell/assets/{cose-bilkent-S5V4N54A-D0ng4uiB.js → cose-bilkent-S5V4N54A-rpQS44Lz.js} +1 -1
  338. package/web-shell/assets/{dagre-BM42HDAG-DCZollQv.js → dagre-BM42HDAG-Ck7VE6nT.js} +1 -1
  339. package/web-shell/assets/{diagram-2AECGRRQ-Dfk2pWS0.js → diagram-2AECGRRQ-CgRrsodR.js} +1 -1
  340. package/web-shell/assets/{diagram-5GNKFQAL-kX38ltWR.js → diagram-5GNKFQAL-CsTZtE5A.js} +1 -1
  341. package/web-shell/assets/{diagram-KO2AKTUF-CJz2vsXh.js → diagram-KO2AKTUF-D5EAdVq4.js} +1 -1
  342. package/web-shell/assets/{diagram-LMA3HP47-BvMLZm_7.js → diagram-LMA3HP47-DNrjHC7Z.js} +1 -1
  343. package/web-shell/assets/{diagram-OG6HWLK6-l7kfStkO.js → diagram-OG6HWLK6-ClJSJGgC.js} +1 -1
  344. package/web-shell/assets/{erDiagram-TEJ5UH35-BSVa8GGT.js → erDiagram-TEJ5UH35-DuVnos_y.js} +1 -1
  345. package/web-shell/assets/{flowDiagram-I6XJVG4X-CoawKIXH.js → flowDiagram-I6XJVG4X-DEpIVl1s.js} +1 -1
  346. package/web-shell/assets/{ganttDiagram-6RSMTGT7-DFUDH0zF.js → ganttDiagram-6RSMTGT7-COnQM2-C.js} +1 -1
  347. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Y2pvpT4e.js → gitGraphDiagram-PVQCEYII-C-lX5H3_.js} +1 -1
  348. package/web-shell/assets/index-C2GE3DAF.js +74 -0
  349. package/web-shell/assets/{index-D0GX0zZf.js → index-DfcyS2E7.js} +1 -1
  350. package/web-shell/assets/index-Qxt6kN7i.js +1700 -0
  351. package/web-shell/assets/index-bo0Z8hfu.css +5 -0
  352. package/web-shell/assets/{infoDiagram-5YYISTIA-CU8_zLiX.js → infoDiagram-5YYISTIA-D0WP-wmU.js} +1 -1
  353. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-AVQiV0DU.js → ishikawaDiagram-YF4QCWOH-DgsI3Clu.js} +1 -1
  354. package/web-shell/assets/{journeyDiagram-JHISSGLW-DQ0VSKa3.js → journeyDiagram-JHISSGLW-4yCoMZO6.js} +1 -1
  355. package/web-shell/assets/{kanban-definition-UN3LZRKU-BqnWqsE_.js → kanban-definition-UN3LZRKU-D_05au1N.js} +1 -1
  356. package/web-shell/assets/{linear-BkoihsaA.js → linear-B38fDz0Q.js} +1 -1
  357. package/web-shell/assets/{mermaid.core-5RJs-31j.js → mermaid.core-aGNwTaHi.js} +5 -5
  358. package/web-shell/assets/{mindmap-definition-RKZ34NQL-D33Bxnpd.js → mindmap-definition-RKZ34NQL-C2yf_5WM.js} +1 -1
  359. package/web-shell/assets/{pieDiagram-4H26LBE5-BuEAw3BH.js → pieDiagram-4H26LBE5-DiHABBT-.js} +1 -1
  360. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-Kox_usEq.js → quadrantDiagram-W4KKPZXB-W9xkeAGe.js} +1 -1
  361. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CNjeUif0.js → requirementDiagram-4Y6WPE33-BGmRXl9k.js} +1 -1
  362. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-BCd2OL_U.js → sankeyDiagram-5OEKKPKP-CvOmT43_.js} +1 -1
  363. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-CF2ZTsz0.js → sequenceDiagram-3UESZ5HK-C8pdd0Z-.js} +1 -1
  364. package/web-shell/assets/{stateDiagram-AJRCARHV-qenSzHtm.js → stateDiagram-AJRCARHV-C-CYdFx2.js} +1 -1
  365. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-BieEHeN9.js +1 -0
  366. package/web-shell/assets/{timeline-definition-PNZ67QCA-B5DyWdgs.js → timeline-definition-PNZ67QCA-w2KQn1cI.js} +1 -1
  367. package/web-shell/assets/{vennDiagram-CIIHVFJN-DqP4I_o_.js → vennDiagram-CIIHVFJN-DuorhRku.js} +1 -1
  368. package/web-shell/assets/{wardley-L42UT6IY-CJe2e4mg.js → wardley-L42UT6IY-BAXm2cWy.js} +1 -1
  369. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BMDSw-Rr.js → wardleyDiagram-YWT4CUSO-8PHaOXn5.js} +1 -1
  370. package/web-shell/assets/{xychartDiagram-2RQKCTM6-BTVZYkxD.js → xychartDiagram-2RQKCTM6-Do84JFSc.js} +1 -1
  371. package/web-shell/index.html +2 -2
  372. package/chunks/MaxSizedBox-5DPPWPGT.js +0 -85
  373. package/chunks/agent-6ODUANDO.js +0 -81
  374. package/chunks/agent-headless-7BYQTMHW.js +0 -75
  375. package/chunks/bridge-ZUB64FAE.js +0 -90
  376. package/chunks/chunk-LEH5C7FV.js +0 -232
  377. package/chunks/chunk-SZRN75WQ.js +0 -29
  378. package/chunks/chunk-UGYMA4EI.js +0 -219
  379. package/chunks/chunk-Z2BC6UJ5.js +0 -8575
  380. package/chunks/contextCommand-JLHYA34Z.js +0 -80
  381. package/chunks/daemon-status-provider-2233Q37D.js +0 -89
  382. package/chunks/earlyInputCapture-A7NDU3PF.js +0 -82
  383. package/chunks/environment-W5UFC2CH.js +0 -102
  384. package/chunks/errors-M7CLORXH.js +0 -88
  385. package/chunks/exitPlanMode-GXTBWQAR.js +0 -403
  386. package/chunks/handleAutoUpdate-6DBEZYPV.js +0 -81
  387. package/chunks/i18n-VUJJZIMU.js +0 -97
  388. package/chunks/initializer-UWAK5U5O.js +0 -86
  389. package/chunks/installationInfo-6O2YAA52.js +0 -80
  390. package/chunks/list-GB4ESM3T.js +0 -89
  391. package/chunks/loadedSettingsAdapter-OT6JVQ7U.js +0 -83
  392. package/chunks/mcp-6DBDJPFU.js +0 -83
  393. package/chunks/nonInteractiveCli-MOYCYBBU.js +0 -141
  394. package/chunks/pidfile-TFRZZZIO.js +0 -86
  395. package/chunks/read-file-APMO3PSX.js +0 -31
  396. package/chunks/resumeHistoryUtils-6KRYEAWZ.js +0 -91
  397. package/chunks/ripGrep-BEJDEDXW.js +0 -73
  398. package/chunks/runtime-XXRRTNP6.js +0 -118
  399. package/chunks/serve-7BSTXJ4T.js +0 -89
  400. package/chunks/shell-HH3PF3A2.js +0 -83
  401. package/chunks/spawnChannel-RWNDBXGA.js +0 -82
  402. package/chunks/src-GE4TTTML.js +0 -3147
  403. package/chunks/standalone-update-Q6WFRZZQ.js +0 -92
  404. package/chunks/task-create-N7WQSGYA.js +0 -25
  405. package/chunks/theme-manager-SWRILQHI.js +0 -77
  406. package/chunks/total-session-admission-DLHHHLD3.js +0 -84
  407. package/chunks/trustedFolders-KHXHY6PY.js +0 -93
  408. package/chunks/updateCheck-RKL6M5XN.js +0 -92
  409. package/chunks/useAutoAcceptIndicator-CFQ5BUJL.js +0 -93
  410. package/chunks/workspace-providers-status-QSVZUETE.js +0 -86
  411. package/chunks/workspace-registry-UT4RBNBM.js +0 -88
  412. package/chunks/workspace-service-JFWRUS4V.js +0 -98
  413. package/chunks/workspace-skills-status-ZBBKJOI2.js +0 -85
  414. package/chunks/write-file-VHIXW5M7.js +0 -73
  415. package/web-shell/assets/channel-Cq7YKtfC.js +0 -1
  416. package/web-shell/assets/classDiagram-4FO5ZUOK-CQ9aC1Tg.js +0 -1
  417. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CQ9aC1Tg.js +0 -1
  418. package/web-shell/assets/index-D9haPt0X.css +0 -5
  419. package/web-shell/assets/index-ckX9Pq5k.js +0 -1230
  420. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-B7W4zlCr.js +0 -1
  421. package/chunks/{chunk-TARRHLLG.js → chunk-QUGAUQGJ.js} +25 -25
  422. package/chunks/{chunk-U7ZFW55U.js → chunk-VOQXFAY5.js} +977 -977
  423. /package/chunks/{chunk-LXXMOYPL.js → chunk-VXZBKKQR.js} +0 -0
@@ -35,22 +35,22 @@ import {
35
35
  require_express,
36
36
  resolveWebShellDir,
37
37
  setDeferredRuntimeRequestTiming
38
- } from "./chunk-IJTOWOD7.js";
38
+ } from "./chunk-MB32MS4U.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";
49
- import "./chunk-WBL3FJEU.js";
50
- import "./chunk-T2NCM2ET.js";
44
+ DEFAULT_MAX_JOURNAL_BYTES,
45
+ DEFAULT_MAX_JOURNAL_EVENTS,
46
+ normalizeCompactedReplayMaxBytes,
47
+ normalizeMaxJournalBytes,
48
+ normalizeMaxJournalEvents
49
+ } from "./chunk-XCGIMOLN.js";
50
+ import "./chunk-FC4KQFCS.js";
51
51
  import {
52
52
  resolveChannelCwd
53
- } from "./chunk-7ZCNENPP.js";
53
+ } from "./chunk-FANRZEAJ.js";
54
54
  import {
55
55
  loadServeFastPathSettings,
56
56
  preResolveServeFastPathHomeEnvOverrides
@@ -59,45 +59,54 @@ import {
59
59
  MAX_REGISTERED_WORKSPACES,
60
60
  resolveWorkspaceInputs,
61
61
  workspaceRegistrationId
62
- } from "./chunk-Q4M4MDQ4.js";
62
+ } from "./chunk-B43QHWY6.js";
63
+ import "./chunk-E2FN6SM7.js";
64
+ import {
65
+ LOAD_REPLAY_META_KEY
66
+ } from "./chunk-CPZAH673.js";
67
+ import "./chunk-B4AJNNOL.js";
63
68
  import {
64
69
  canonicalizeWorkspace,
65
70
  translateAndCheckAbsoluteWorkspacePath
66
71
  } from "./chunk-2RFKHEXL.js";
67
- import "./chunk-UDX5OBWR.js";
68
- import "./chunk-5NBDS5S6.js";
72
+ import "./chunk-FCYYAB4S.js";
73
+ import "./chunk-FYJ7W2PI.js";
69
74
  import {
70
75
  ChannelDeliveryError,
71
76
  ChannelWebhookEnqueueError,
72
77
  QWEN_SERVER_TOKEN_ENV,
73
- isChannelDeliveryError,
78
+ isChannelDeliveryError
79
+ } from "./chunk-U4VTUMMK.js";
80
+ import {
74
81
  normalizeWorkerDiagnostic,
75
82
  sanitizeWorkerDiagnostic
76
- } from "./chunk-LK7CHLVP.js";
83
+ } from "./chunk-6MPDY6ZG.js";
77
84
  import {
78
85
  channelSelectionNames
79
- } from "./chunk-JLU636DO.js";
86
+ } from "./chunk-ALMR3E6Q.js";
80
87
  import "./chunk-BK2UNYWD.js";
81
88
  import "./chunk-M5GB774H.js";
89
+ import "./chunk-5HBA2Z7V.js";
90
+ import "./chunk-K6KS3LTN.js";
91
+ import "./chunk-T3CHYWJZ.js";
82
92
  import {
83
93
  sanitizeLogText
84
- } from "./chunk-RWTEFFPU.js";
94
+ } from "./chunk-JCJ7LKNA.js";
85
95
  import "./chunk-UDXSXLER.js";
86
- import "./chunk-5HBA2Z7V.js";
87
96
  import "./chunk-GOXKNSDZ.js";
88
97
  import {
89
98
  getGlobalQwenDirLite,
90
99
  resolveConfigPathLite
91
100
  } from "./chunk-IDS7MSUP.js";
92
101
  import "./chunk-6PEXNQTX.js";
93
- import {
94
- getCliVersion
95
- } from "./chunk-YX324OPW.js";
96
- import "./chunk-VJNBRRZG.js";
97
102
  import "./chunk-ALGGS7UH.js";
98
103
  import {
99
104
  isWithinRoot
100
105
  } from "./chunk-MR3PXB6E.js";
106
+ import {
107
+ getCliVersion
108
+ } from "./chunk-XDS22O52.js";
109
+ import "./chunk-VJNBRRZG.js";
101
110
  import {
102
111
  writeStderrLine,
103
112
  writeStdoutLine
@@ -1260,7 +1269,7 @@ function createConcreteLogger(input) {
1260
1269
  }
1261
1270
  });
1262
1271
  let timeout;
1263
- const deadline = new Promise((resolve) => {
1272
+ const deadline = new Promise((resolve2) => {
1264
1273
  timeout = setTimeout(() => {
1265
1274
  try {
1266
1275
  input.warnOnce(
@@ -1269,7 +1278,7 @@ function createConcreteLogger(input) {
1269
1278
  );
1270
1279
  } catch {
1271
1280
  } finally {
1272
- resolve();
1281
+ resolve2();
1273
1282
  }
1274
1283
  }, input.policy.closeDrainBudgetMs);
1275
1284
  timeout.unref();
@@ -2317,8 +2326,8 @@ async function flushDaemonLogBounded(daemonLog, budgetMs) {
2317
2326
  await Promise.race([
2318
2327
  daemonLog.flush().catch(() => {
2319
2328
  }),
2320
- new Promise((resolve) => {
2321
- timer = setTimeout(resolve, budgetMs);
2329
+ new Promise((resolve2) => {
2330
+ timer = setTimeout(resolve2, budgetMs);
2322
2331
  timer.unref();
2323
2332
  })
2324
2333
  ]);
@@ -2492,6 +2501,13 @@ function formatHostForUrl(host) {
2492
2501
  return host;
2493
2502
  }
2494
2503
  __name(formatHostForUrl, "formatHostForUrl");
2504
+ function workspaceRuntimeEffectiveEnv(runtime, daemonEnv) {
2505
+ if (runtime.env.mode === "runtime-overlay") {
2506
+ return runtime.env.effectiveEnv ?? {};
2507
+ }
2508
+ return runtime.env.effectiveEnv ?? daemonEnv;
2509
+ }
2510
+ __name(workspaceRuntimeEffectiveEnv, "workspaceRuntimeEffectiveEnv");
2495
2511
  function formatChannelWorkerDaemonUrl(host, port) {
2496
2512
  const normalized = host.trim().toLowerCase();
2497
2513
  if (normalized === "" || normalized === "0.0.0.0" || normalized === "::" || normalized === "[::]") {
@@ -2529,15 +2545,16 @@ function withSettingsLock(workspace, fn) {
2529
2545
  return next;
2530
2546
  }
2531
2547
  __name(withSettingsLock, "withSettingsLock");
2548
+ var retryableChannelWorkerShutdownErrors = /* @__PURE__ */ new WeakSet();
2532
2549
  var channelWorkerRuntimePromise;
2533
2550
  async function loadChannelWorkerRuntime() {
2534
2551
  channelWorkerRuntimePromise ??= Promise.all([
2535
- import("./channel-worker-supervisor-V7KCFJTS.js"),
2536
- import("./pidfile-TFRZZZIO.js"),
2537
- import("./runtime-XXRRTNP6.js"),
2552
+ import("./channel-worker-supervisor-CABBXYHK.js"),
2553
+ import("./pidfile-MV347TTZ.js"),
2554
+ import("./runtime-WVP22ISH.js"),
2538
2555
  import("./cli-entry-path-4VJ3Y6T2.js"),
2539
- import("./channel-worker-group-2ZD7TVAT.js"),
2540
- import("./channel-worker-manager-4OA4BCGB.js")
2556
+ import("./channel-worker-group-OVWGYMZS.js"),
2557
+ import("./channel-worker-manager-H55GKOQA.js")
2541
2558
  ]).then(
2542
2559
  ([
2543
2560
  supervisor,
@@ -2642,7 +2659,7 @@ function shouldPreheatBridge(deps) {
2642
2659
  __name(shouldPreheatBridge, "shouldPreheatBridge");
2643
2660
  var coreRuntimePromise;
2644
2661
  function loadCoreRuntime() {
2645
- coreRuntimePromise ??= import("./src-GE4TTTML.js");
2662
+ coreRuntimePromise ??= import("./core-runtime-253XV2DB.js");
2646
2663
  return coreRuntimePromise;
2647
2664
  }
2648
2665
  __name(loadCoreRuntime, "loadCoreRuntime");
@@ -2672,10 +2689,10 @@ __name(resolveDaemonLogBaseDirForRun, "resolveDaemonLogBaseDirForRun");
2672
2689
  var settingsRuntimePromise;
2673
2690
  function loadSettingsRuntimeModules() {
2674
2691
  settingsRuntimePromise ??= Promise.all([
2675
- import("./settings-CR2EWTBA.js"),
2676
- import("./environment-W5UFC2CH.js"),
2677
- import("./loadedSettingsAdapter-OT6JVQ7U.js"),
2678
- import("./trustedFolders-KHXHY6PY.js")
2692
+ import("./settings-73RMIOJ6.js"),
2693
+ import("./environment-IJG3N2PR.js"),
2694
+ import("./loadedSettingsAdapter-GQGNHP5I.js"),
2695
+ import("./trustedFolders-YMUTRHEQ.js")
2679
2696
  ]).then(([settings, environment, loadedSettingsAdapter, trustedFolders]) => ({
2680
2697
  settings,
2681
2698
  environment,
@@ -2688,8 +2705,8 @@ __name(loadSettingsRuntimeModules, "loadSettingsRuntimeModules");
2688
2705
  var channelWebhookConfigRuntimePromise;
2689
2706
  function loadChannelWebhookConfigRuntime() {
2690
2707
  channelWebhookConfigRuntimePromise ??= Promise.all([
2691
- import("./runtime-XXRRTNP6.js"),
2692
- import("./config-utils-7V7GGIW6.js")
2708
+ import("./runtime-WVP22ISH.js"),
2709
+ import("./config-utils-WADIDWGG.js")
2693
2710
  ]).then(([channelRuntime, configUtils]) => ({
2694
2711
  loadChannelsConfig: channelRuntime.loadChannelsConfig,
2695
2712
  parseChannelWebhookConfig: configUtils.parseChannelWebhookConfig
@@ -2705,6 +2722,7 @@ async function loadServeRuntimeModules() {
2705
2722
  serverModule,
2706
2723
  bridgeModule,
2707
2724
  spawnChannelModule,
2725
+ processRegistryModule,
2708
2726
  workspaceModule,
2709
2727
  workspaceTypesModule,
2710
2728
  daemonStatusProviderModule,
@@ -2713,16 +2731,17 @@ async function loadServeRuntimeModules() {
2713
2731
  totalSessionAdmissionModule,
2714
2732
  workspaceRegistryModule
2715
2733
  ] = await Promise.all([
2716
- import("./server-4UMH7OIZ.js"),
2717
- import("./bridge-ZUB64FAE.js"),
2718
- import("./spawnChannel-RWNDBXGA.js"),
2719
- import("./workspace-service-JFWRUS4V.js"),
2734
+ import("./server-JNW2NOSQ.js"),
2735
+ import("./bridge-NYOBVRIT.js"),
2736
+ import("./spawnChannel-T5THBHFN.js"),
2737
+ import("./process-registry-2CHQBXH5.js"),
2738
+ import("./workspace-service-SVWOXX2B.js"),
2720
2739
  import("./types-ML3TRJQ5.js"),
2721
- import("./daemon-status-provider-2233Q37D.js"),
2722
- import("./workspace-providers-status-QSVZUETE.js"),
2723
- import("./workspace-skills-status-ZBBKJOI2.js"),
2724
- import("./total-session-admission-DLHHHLD3.js"),
2725
- import("./workspace-registry-UT4RBNBM.js")
2740
+ import("./daemon-status-provider-AKALDYJJ.js"),
2741
+ import("./workspace-providers-status-YM3WLW3N.js"),
2742
+ import("./workspace-skills-status-YZHZ3PT5.js"),
2743
+ import("./total-session-admission-QPUKGHKO.js"),
2744
+ import("./workspace-registry-NGZOZKQP.js")
2726
2745
  ]);
2727
2746
  return {
2728
2747
  createServeApp: serverModule.createServeApp,
@@ -2731,6 +2750,7 @@ async function loadServeRuntimeModules() {
2731
2750
  resolveBridgeFsFactory: serverModule.resolveBridgeFsFactory,
2732
2751
  createAcpSessionBridge: bridgeModule.createAcpSessionBridge,
2733
2752
  createSpawnChannelFactory: spawnChannelModule.createSpawnChannelFactory,
2753
+ ProcessRegistry: processRegistryModule.ProcessRegistry,
2734
2754
  createDaemonWorkspaceService: workspaceModule.createDaemonWorkspaceService,
2735
2755
  WorkspaceSettingsPartialPersistError: workspaceTypesModule.WorkspaceSettingsPartialPersistError,
2736
2756
  WorkspaceSkillNotToggleableError: workspaceTypesModule.WorkspaceSkillNotToggleableError,
@@ -2739,7 +2759,8 @@ async function loadServeRuntimeModules() {
2739
2759
  createWorkspaceSkillsStatusProvider: workspaceSkillsStatusModule.createWorkspaceSkillsStatusProvider,
2740
2760
  createTotalSessionAdmissionController: totalSessionAdmissionModule.createTotalSessionAdmissionController,
2741
2761
  createWorkspaceRegistry: workspaceRegistryModule.createWorkspaceRegistry,
2742
- createWorkspaceSessionOwnerIndex: workspaceRegistryModule.createWorkspaceSessionOwnerIndex
2762
+ createWorkspaceSessionOwnerIndex: workspaceRegistryModule.createWorkspaceSessionOwnerIndex,
2763
+ createWorkspaceGenerationGuard: workspaceRegistryModule.createWorkspaceGenerationGuard
2743
2764
  };
2744
2765
  }
2745
2766
  __name(loadServeRuntimeModules, "loadServeRuntimeModules");
@@ -2779,6 +2800,7 @@ function currentServeFeaturesForRunQwenServe(opts, sessionShellCommandEnabled, s
2779
2800
  reloadAvailable: true,
2780
2801
  channelReloadAvailable: opts.channelSelection !== void 0,
2781
2802
  channelControlAvailable: true,
2803
+ channelManagementAvailable: true,
2782
2804
  persistentWorkspaceRegistrationAvailable: true,
2783
2805
  workspaceRuntimeRemovalAvailable: true,
2784
2806
  // Advertise the same WS feature flags as the runtime path (serve-features.ts)
@@ -2913,12 +2935,12 @@ async function waitForRuntimeStartingForShutdown(runtimeStarting, daemonLog, tim
2913
2935
  let timer;
2914
2936
  await Promise.race([
2915
2937
  runtimeStarting,
2916
- new Promise((resolve) => {
2938
+ new Promise((resolve2) => {
2917
2939
  timer = setTimeout(() => {
2918
2940
  daemonLog.warn(
2919
2941
  `${timeoutMs}ms runtime-startup wait reached during shutdown; continuing listener close`
2920
2942
  );
2921
- resolve();
2943
+ resolve2();
2922
2944
  }, timeoutMs);
2923
2945
  timer.unref();
2924
2946
  })
@@ -3087,6 +3109,8 @@ function createBootstrapServeApp(input) {
3087
3109
  listenerMaxConnections: listenerMaxConnections(opts.maxConnections),
3088
3110
  eventRingSize: opts.eventRingSize ?? DEFAULT_EVENT_RING_SIZE,
3089
3111
  compactedReplayMaxBytes: opts.compactedReplayMaxBytes ?? DEFAULT_COMPACTED_REPLAY_MAX_BYTES,
3112
+ maxJournalEvents: opts.maxJournalEvents ?? DEFAULT_MAX_JOURNAL_EVENTS,
3113
+ maxJournalBytes: opts.maxJournalBytes ?? DEFAULT_MAX_JOURNAL_BYTES,
3090
3114
  promptDeadlineMs: positiveFiniteOrNull(opts.promptDeadlineMs),
3091
3115
  writerIdleTimeoutMs: positiveFiniteOrNull(opts.writerIdleTimeoutMs),
3092
3116
  channelIdleTimeoutMs: channelIdleTimeoutMs(opts.channelIdleTimeoutMs),
@@ -3610,7 +3634,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3610
3634
  }
3611
3635
  let workspaceRegistrationStore = deps.workspaceRegistrationStore;
3612
3636
  if (workspaceRegistrationStore === void 0 && process.env["QWEN_SERVE_NO_PERSISTENT_REGISTRATION"] !== "1") {
3613
- const { WorkspaceRegistrationStore } = await import("./workspace-registration-store-24JMHDGF.js");
3637
+ const { WorkspaceRegistrationStore } = await import("./workspace-registration-store-4EGNCIPG.js");
3614
3638
  workspaceRegistrationStore = new WorkspaceRegistrationStore(boundWorkspace);
3615
3639
  }
3616
3640
  if (workspaceRegistrationStore) {
@@ -3765,6 +3789,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3765
3789
  if (opts.compactedReplayMaxBytes !== void 0) {
3766
3790
  normalizeCompactedReplayMaxBytes(opts.compactedReplayMaxBytes);
3767
3791
  }
3792
+ if (opts.maxJournalEvents !== void 0) {
3793
+ normalizeMaxJournalEvents(opts.maxJournalEvents);
3794
+ }
3795
+ if (opts.maxJournalBytes !== void 0) {
3796
+ normalizeMaxJournalBytes(opts.maxJournalBytes);
3797
+ }
3768
3798
  if (opts.writerIdleTimeoutMs !== void 0) {
3769
3799
  if (!isPositiveIntegerMs(opts.writerIdleTimeoutMs)) {
3770
3800
  throw new TypeError(
@@ -3849,6 +3879,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3849
3879
  let runtimeApp;
3850
3880
  let runtimeAppForCleanup;
3851
3881
  let bridgeRef = deps.bridge;
3882
+ let managedProcessRegistry;
3852
3883
  const internalRuntimeBridgesForCleanup = [];
3853
3884
  let daemonEventLoopMonitor;
3854
3885
  let daemonMetricsSampler;
@@ -3860,8 +3891,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
3860
3891
  let startRuntimeAfterHealth;
3861
3892
  let startRuntimeForRequest;
3862
3893
  const deferRuntimeUntilFirstHealth = deps.resolveOnListen === true && deps.deferRuntimeUntilFirstHealth === true;
3863
- const runtimeReady = new Promise((resolve, reject) => {
3864
- markRuntimeReady = resolve;
3894
+ const runtimeReady = new Promise((resolve2, reject) => {
3895
+ markRuntimeReady = resolve2;
3865
3896
  markRuntimeFailed = reject;
3866
3897
  });
3867
3898
  void runtimeReady.catch(() => {
@@ -4015,6 +4046,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4015
4046
  const disposedRuntimeApps = /* @__PURE__ */ new WeakSet();
4016
4047
  const stoppedRuntimeAppProducers = /* @__PURE__ */ new WeakSet();
4017
4048
  const stoppedExtensionReconcilers = /* @__PURE__ */ new WeakSet();
4049
+ const stoppedTrustPolicyMonitors = /* @__PURE__ */ new WeakSet();
4050
+ const stopTrustPolicyMonitor = /* @__PURE__ */ __name((app2) => {
4051
+ if (!app2 || stoppedTrustPolicyMonitors.has(app2)) return;
4052
+ stoppedTrustPolicyMonitors.add(app2);
4053
+ const stop = app2.locals?.["stopTrustPolicyMonitor"];
4054
+ try {
4055
+ stop?.();
4056
+ } catch (err) {
4057
+ daemonLog.warn(
4058
+ `trust policy monitor dispose error: ${err instanceof Error ? err.message : String(err)}`
4059
+ );
4060
+ }
4061
+ }, "stopTrustPolicyMonitor");
4018
4062
  const stopExtensionReconciler = /* @__PURE__ */ __name((app2) => {
4019
4063
  if (!app2 || stoppedExtensionReconcilers.has(app2)) return;
4020
4064
  stoppedExtensionReconcilers.add(app2);
@@ -4042,6 +4086,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4042
4086
  }, "stopSafely");
4043
4087
  stopSafely("scheduled-task keepalive", locals.stopScheduledTaskKeepalive);
4044
4088
  stopSafely("workspace git state", locals.stopWorkspaceGitState);
4089
+ stopTrustPolicyMonitor(app2);
4045
4090
  for (const stop of locals.subSessionStoppers ?? []) {
4046
4091
  stopSafely("sub-session launcher", stop);
4047
4092
  }
@@ -4095,13 +4140,23 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4095
4140
  return [...new Set(bridges)];
4096
4141
  }, "getRuntimeBridgesForCleanup");
4097
4142
  const buildRuntime = /* @__PURE__ */ __name(async () => {
4098
- const [runtime, core, settingsRuntime, resolvedCliVersion] = await Promise.all([
4143
+ const [runtime, core, settingsRuntime, resolvedCliVersion, trustPolicy] = await Promise.all([
4099
4144
  loadServeRuntimeModules(),
4100
4145
  loadCoreRuntime(),
4101
4146
  loadSettingsRuntimeModules(),
4102
- cliVersionPromise
4147
+ cliVersionPromise,
4148
+ import("./daemon-trust-policy-XB7ZSQFQ.js")
4103
4149
  ]);
4104
4150
  cliVersion = resolvedCliVersion;
4151
+ settingsRuntime.environment.preResolveHomeEnvOverrides();
4152
+ const bootTrustSnapshot = await trustPolicy.readDaemonTrustPolicySnapshot();
4153
+ let latestTrustPolicySnapshot = bootTrustSnapshot;
4154
+ const bootPrimaryTrustDecision = trustPolicy.evaluateDaemonWorkspaceTrust(
4155
+ bootTrustSnapshot,
4156
+ boundWorkspace
4157
+ );
4158
+ const trustedWorkspace = deps.trustedWorkspace ?? bootPrimaryTrustDecision.targetTrusted;
4159
+ const workspaceTrustHotReloadAvailable = deps.trustedWorkspace === void 0 && deps.bridge === void 0 && deps.fsFactory === void 0;
4105
4160
  let managedScratchRoot;
4106
4161
  try {
4107
4162
  managedScratchRoot = prepareManagedScratchRoot(
@@ -4115,16 +4170,19 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4115
4170
  }
4116
4171
  let runtimeBootSettings;
4117
4172
  try {
4118
- runtimeBootSettings = settingsRuntime.settings.loadSettings(boundWorkspace);
4173
+ runtimeBootSettings = settingsRuntime.settings.loadSettings(
4174
+ boundWorkspace,
4175
+ {
4176
+ skipLoadEnvironment: true,
4177
+ skipWorkspaceSettings: !trustedWorkspace,
4178
+ workspaceTrusted: trustedWorkspace
4179
+ }
4180
+ );
4119
4181
  } catch (err) {
4120
4182
  writeStderrLine(
4121
4183
  `qwen serve: could not read full settings for runtime startup (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4122
4184
  );
4123
4185
  }
4124
- const trustedWorkspace = deps.trustedWorkspace ?? (runtimeBootSettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4125
- runtimeBootSettings.merged,
4126
- boundWorkspace
4127
- ).effective.state === "trusted" : true);
4128
4186
  if (deps.trustedWorkspace === void 0 && runtimeBootSettings && !trustedWorkspace) {
4129
4187
  daemonLog.warn(
4130
4188
  "workspace file writes are disabled because the bound workspace is not trusted",
@@ -4134,7 +4192,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4134
4192
  const runtimeEnvSnapshot = runtimeBootSettings ? settingsRuntime.environment.buildRuntimeEnvironment(
4135
4193
  runtimeBootSettings.merged,
4136
4194
  boundWorkspace,
4137
- daemonRuntimeBaseEnv
4195
+ daemonRuntimeBaseEnv,
4196
+ trustedWorkspace
4138
4197
  ) : {
4139
4198
  effectiveEnv: { ...daemonRuntimeBaseEnv },
4140
4199
  overlayKeys: Object.freeze([]),
@@ -4142,6 +4201,29 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4142
4201
  envFileReadFailed: false,
4143
4202
  envFileReadFailures: Object.freeze([])
4144
4203
  };
4204
+ const resolveSessionRuntimeBaseDir = /* @__PURE__ */ __name((workspace, settings, effectiveEnv) => {
4205
+ const resolveConfiguredPath = /* @__PURE__ */ __name((configuredPath, relativeTo) => {
4206
+ const expanded = configuredPath === "~" ? os.homedir() : configuredPath.startsWith("~/") || configuredPath.startsWith("~\\") ? path.join(
4207
+ os.homedir(),
4208
+ ...configuredPath.slice(2).split(/[/\\]+/).filter(Boolean)
4209
+ ) : configuredPath;
4210
+ return path.resolve(relativeTo, expanded);
4211
+ }, "resolveConfiguredPath");
4212
+ const runtimeDir = effectiveEnv["QWEN_RUNTIME_DIR"];
4213
+ if (runtimeDir) {
4214
+ return resolveConfiguredPath(runtimeDir, process.cwd());
4215
+ }
4216
+ const settingsDir = settings?.merged.advanced?.runtimeOutputDir;
4217
+ if (settingsDir) {
4218
+ return resolveConfiguredPath(settingsDir, workspace);
4219
+ }
4220
+ const qwenHome = effectiveEnv["QWEN_HOME"];
4221
+ if (qwenHome) {
4222
+ return resolveConfiguredPath(qwenHome, process.cwd());
4223
+ }
4224
+ const homeDir = os.homedir();
4225
+ return homeDir ? path.join(homeDir, ".qwen") : path.join(os.tmpdir(), ".qwen");
4226
+ }, "resolveSessionRuntimeBaseDir");
4145
4227
  const logRuntimeEnvFileReadFailures = /* @__PURE__ */ __name((workspace, snapshot) => {
4146
4228
  if (!snapshot.envFileReadFailed) return;
4147
4229
  const failedFiles = snapshot.envFileReadFailures ?? [];
@@ -4151,14 +4233,21 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4151
4233
  });
4152
4234
  }, "logRuntimeEnvFileReadFailures");
4153
4235
  logRuntimeEnvFileReadFailures(boundWorkspace, runtimeEnvSnapshot);
4236
+ const primarySessionRuntimeBaseDir = resolveSessionRuntimeBaseDir(
4237
+ boundWorkspace,
4238
+ runtimeBootSettings,
4239
+ runtimeEnvSnapshot.effectiveEnv
4240
+ );
4154
4241
  const runtimeEffectiveEnv = {
4155
- ...runtimeEnvSnapshot.effectiveEnv
4242
+ ...runtimeEnvSnapshot.effectiveEnv,
4243
+ QWEN_RUNTIME_DIR: primarySessionRuntimeBaseDir
4156
4244
  };
4157
4245
  const replaceRuntimeEffectiveEnv = /* @__PURE__ */ __name((nextEnv) => {
4158
4246
  for (const key of Object.keys(runtimeEffectiveEnv)) {
4159
4247
  delete runtimeEffectiveEnv[key];
4160
4248
  }
4161
4249
  Object.assign(runtimeEffectiveEnv, nextEnv);
4250
+ runtimeEffectiveEnv["QWEN_RUNTIME_DIR"] = primarySessionRuntimeBaseDir;
4162
4251
  }, "replaceRuntimeEffectiveEnv");
4163
4252
  const primaryRuntimeEnv = {
4164
4253
  mode: "runtime-overlay",
@@ -4305,17 +4394,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4305
4394
  void 0,
4306
4395
  (workspace, index) => {
4307
4396
  if (index === 0) return true;
4308
- if (!runtimeBootSettings) {
4309
- daemonLog.warn(
4310
- "excluding secondary workspace root because trust settings are unavailable",
4311
- { workspace }
4312
- );
4313
- return false;
4314
- }
4315
- const trustedSecondary = settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4316
- runtimeBootSettings.merged,
4397
+ const trustedSecondary = trustPolicy.evaluateDaemonWorkspaceTrust(
4398
+ bootTrustSnapshot,
4317
4399
  workspace
4318
- ).effective.state === "trusted";
4400
+ ).targetTrusted;
4319
4401
  if (!trustedSecondary) {
4320
4402
  daemonLog.warn(
4321
4403
  "excluding untrusted secondary workspace root from file-system access",
@@ -4330,7 +4412,16 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4330
4412
  secondary: boundWorkspaces.slice(1),
4331
4413
  ideEnvPresent: !!process.env["QWEN_CODE_IDE_WORKSPACE_PATH"]
4332
4414
  });
4415
+ const primaryGenerationGuard = runtime.createWorkspaceGenerationGuard();
4416
+ const primaryTrustMaterialization = JSON.stringify({
4417
+ trusted: trustedWorkspace,
4418
+ boundWorkspaces: [...boundWorkspaces].sort()
4419
+ });
4333
4420
  const sharedPathLocks = new PathMutexRegistry();
4421
+ const workspaceTrustOperationGate = new PathMutexRegistry();
4422
+ const runWorkspaceTrustOperation = /* @__PURE__ */ __name((operation) => workspaceTrustOperationGate.runExclusive("runtime-topology", operation), "runWorkspaceTrustOperation");
4423
+ const processRegistry = new runtime.ProcessRegistry();
4424
+ managedProcessRegistry = processRegistry;
4334
4425
  const fsFactory = runtime.resolveBridgeFsFactory({
4335
4426
  // Secondary roots share a write-capable factory only after their own
4336
4427
  // folder trust check passes; untrusted secondary roots stay outside.
@@ -4339,6 +4430,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4339
4430
  trusted: trustedWorkspace,
4340
4431
  emit: deps.fsAuditEmit,
4341
4432
  pathLocks: sharedPathLocks,
4433
+ generationGuard: primaryGenerationGuard,
4342
4434
  ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4343
4435
  });
4344
4436
  const routeFsFactory = runtime.resolveBridgeFsFactory({
@@ -4348,9 +4440,11 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4348
4440
  trusted: trustedWorkspace,
4349
4441
  emit: deps.fsAuditEmit,
4350
4442
  pathLocks: sharedPathLocks,
4443
+ generationGuard: primaryGenerationGuard,
4351
4444
  ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4352
4445
  });
4353
4446
  const channelFactory = runtime.createSpawnChannelFactory({
4447
+ processRegistry,
4354
4448
  sourceEnv: runtimeEffectiveEnv,
4355
4449
  onDiagnosticLine: diagnosticSink,
4356
4450
  pipeHooks: {
@@ -4368,9 +4462,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4368
4462
  env: runtimeEffectiveEnv
4369
4463
  });
4370
4464
  const workspaceProvidersStatusProvider = runtime.createWorkspaceProvidersStatusProvider({
4371
- env: runtimeEffectiveEnv
4465
+ env: runtimeEffectiveEnv,
4466
+ workspaceTrusted: trustedWorkspace
4467
+ });
4468
+ const workspaceSkillsStatusProvider = runtime.createWorkspaceSkillsStatusProvider({
4469
+ workspaceTrusted: trustedWorkspace
4372
4470
  });
4373
- const workspaceSkillsStatusProvider = runtime.createWorkspaceSkillsStatusProvider();
4374
4471
  const clientMcpSenderRegistry = new ClientMcpSenderRegistry();
4375
4472
  const runtimeBridges = [];
4376
4473
  const totalSessionAdmission = runtime.createTotalSessionAdmissionController(
@@ -4380,84 +4477,108 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4380
4477
  }
4381
4478
  );
4382
4479
  const sessionOwnerIndex = runtime.createWorkspaceSessionOwnerIndex();
4383
- const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled) => withSettingsLock(workspace, async () => {
4384
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4480
+ const workspaceRegistryForPersistence = { current: void 0 };
4481
+ const isWorkspaceTrustedForPersistence = /* @__PURE__ */ __name((workspace) => workspaceRegistryForPersistence.current?.getByWorkspaceCwd(workspace)?.trusted ?? (workspaceRegistryForPersistence.current === void 0 && workspace === boundWorkspace && trustedWorkspace), "isWorkspaceTrustedForPersistence");
4482
+ const loadSettingsForPersistence = /* @__PURE__ */ __name((workspace) => {
4483
+ const trusted = isWorkspaceTrustedForPersistence(workspace);
4484
+ return settingsRuntime.settings.loadSettings(workspace, {
4485
+ skipLoadEnvironment: true,
4486
+ skipWorkspaceSettings: !trusted,
4487
+ workspaceTrusted: trusted
4488
+ });
4489
+ }, "loadSettingsForPersistence");
4490
+ const persistDisabledToolsFn = /* @__PURE__ */ __name((workspace, toolName, enabled, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4491
+ assertGenerationOpen?.();
4492
+ const fresh = loadSettingsForPersistence(workspace);
4385
4493
  const wsScope = fresh.forScope(WORKSPACE_SETTING_SCOPE).settings;
4386
4494
  const wsDisabled = wsScope.tools?.disabled;
4387
4495
  const current = Array.isArray(wsDisabled) ? wsDisabled.filter((v) => typeof v === "string") : [];
4388
4496
  const next = new Set(current);
4389
4497
  if (enabled) next.delete(toolName);
4390
4498
  else next.add(toolName);
4499
+ assertGenerationOpen?.();
4391
4500
  fresh.setValue(
4392
4501
  WORKSPACE_SETTING_SCOPE,
4393
4502
  "tools.disabled",
4394
- [...next].sort()
4503
+ [...next].sort(),
4504
+ assertGenerationOpen
4395
4505
  );
4396
4506
  }), "persistDisabledToolsFn");
4397
- const persistDisabledSkillsFn = /* @__PURE__ */ __name((workspace, skillName, enabled) => withSettingsLock(workspace, async () => {
4398
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4507
+ const persistDisabledSkillsFn = /* @__PURE__ */ __name((workspace, skillName, enabled, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4508
+ assertGenerationOpen?.();
4509
+ const {
4510
+ resolveSkillSettings,
4511
+ skillSettingStrings,
4512
+ updateWorkspaceSkillSettingLists
4513
+ } = await import("./skill-settings-5IGIJDGA.js");
4514
+ const fresh = loadSettingsForPersistence(workspace);
4399
4515
  const normalizedName = skillName.trim().toLowerCase();
4400
- const disabledNames = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.filter(
4401
- (entry) => typeof entry === "string"
4402
- ) : [], "disabledNames");
4403
- const lockedScopes = [
4404
- ["system", fresh.system.settings.skills?.disabled],
4405
- ["user", fresh.user.settings.skills?.disabled],
4406
- ["systemDefaults", fresh.systemDefaults.settings.skills?.disabled]
4407
- ];
4408
- for (const [scope, names] of lockedScopes) {
4409
- if (disabledNames(names).some(
4410
- (name) => name.trim().toLowerCase() === normalizedName
4411
- )) {
4412
- throw new runtime.WorkspaceSkillNotToggleableError(
4413
- skillName,
4414
- "locked",
4415
- scope
4416
- );
4417
- }
4516
+ const resolved = resolveSkillSettings(fresh);
4517
+ const disablement = resolved.disablements.get(normalizedName);
4518
+ if (disablement?.reason === "hard" && disablement.lockedScope) {
4519
+ throw new runtime.WorkspaceSkillNotToggleableError(
4520
+ skillName,
4521
+ "locked",
4522
+ disablement.lockedScope
4523
+ );
4418
4524
  }
4419
- const workspaceDisabled = disabledNames(
4420
- fresh.workspace.settings.skills?.disabled
4525
+ const workspaceDisabled = skillSettingStrings(
4526
+ fresh,
4527
+ WORKSPACE_SETTING_SCOPE,
4528
+ "disabled"
4421
4529
  );
4422
- const next = [];
4423
- let found = false;
4424
- let changed = false;
4425
- for (const name of workspaceDisabled) {
4426
- if (name.trim().toLowerCase() !== normalizedName) {
4427
- next.push(name);
4428
- continue;
4429
- }
4430
- if (enabled) {
4431
- changed = true;
4432
- continue;
4433
- }
4434
- if (!found) {
4435
- next.push(skillName);
4436
- found = true;
4437
- if (name !== skillName) changed = true;
4438
- } else {
4439
- changed = true;
4440
- }
4530
+ const workspaceEnabled = skillSettingStrings(
4531
+ fresh,
4532
+ WORKSPACE_SETTING_SCOPE,
4533
+ "enabled"
4534
+ );
4535
+ const next = updateWorkspaceSkillSettingLists(
4536
+ { disabled: workspaceDisabled, enabled: workspaceEnabled },
4537
+ skillName,
4538
+ enabled,
4539
+ resolved.defaultDisabledNames.has(normalizedName) && !resolved.enabledNames.has(normalizedName)
4540
+ );
4541
+ const settingsChanges = [];
4542
+ if (JSON.stringify(next.disabled) !== JSON.stringify(workspaceDisabled)) {
4543
+ settingsChanges.push({
4544
+ key: "skills.disabled",
4545
+ value: next.disabled.length > 0 ? next.disabled : void 0
4546
+ });
4441
4547
  }
4442
- if (!enabled && !found) {
4443
- next.push(skillName);
4444
- changed = true;
4548
+ if (JSON.stringify(next.enabled) !== JSON.stringify(workspaceEnabled)) {
4549
+ settingsChanges.push({
4550
+ key: "skills.enabled",
4551
+ value: next.enabled.length > 0 ? next.enabled : void 0
4552
+ });
4445
4553
  }
4446
- if (!changed) return { changed: false, disabled: workspaceDisabled };
4447
- fresh.setValue(
4448
- WORKSPACE_SETTING_SCOPE,
4449
- "skills.disabled",
4450
- next.length > 0 ? next : void 0
4554
+ if (settingsChanges.length === 0) {
4555
+ return { changed: false, disabled: workspaceDisabled };
4556
+ }
4557
+ assertGenerationOpen?.();
4558
+ fresh.setValues(
4559
+ settingsChanges.map((change) => ({
4560
+ scope: WORKSPACE_SETTING_SCOPE,
4561
+ ...change
4562
+ })),
4563
+ void 0,
4564
+ assertGenerationOpen
4451
4565
  );
4452
- return { changed: true, disabled: next };
4566
+ return {
4567
+ changed: true,
4568
+ disabled: next.disabled,
4569
+ settingsChanges
4570
+ };
4453
4571
  }), "persistDisabledSkillsFn");
4454
- const persistSettingFn = /* @__PURE__ */ __name((workspace, scope, key, value) => withSettingsLock(workspace, async () => {
4455
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4456
- fresh.setValue(scope, key, value);
4572
+ const persistSettingFn = /* @__PURE__ */ __name((workspace, scope, key, value, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4573
+ assertGenerationOpen?.();
4574
+ const fresh = loadSettingsForPersistence(workspace);
4575
+ assertGenerationOpen?.();
4576
+ fresh.setValue(scope, key, value, assertGenerationOpen);
4457
4577
  return fresh;
4458
4578
  }), "persistSettingFn");
4459
- const persistSettingsFn = /* @__PURE__ */ __name((workspace, writes) => withSettingsLock(workspace, async () => {
4460
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4579
+ const persistSettingsFn = /* @__PURE__ */ __name((workspace, writes, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4580
+ assertGenerationOpen?.();
4581
+ const fresh = loadSettingsForPersistence(workspace);
4461
4582
  const writesByScope = /* @__PURE__ */ new Map();
4462
4583
  for (const write of writes) {
4463
4584
  writesByScope.set(
@@ -4468,10 +4589,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4468
4589
  const committedScopes = /* @__PURE__ */ new Set();
4469
4590
  let committed = 0;
4470
4591
  try {
4471
- fresh.setValues(writes, (scope) => {
4472
- committedScopes.add(scope);
4473
- committed += writesByScope.get(scope) ?? 0;
4474
- });
4592
+ assertGenerationOpen?.();
4593
+ fresh.setValues(
4594
+ writes,
4595
+ (scope) => {
4596
+ committedScopes.add(scope);
4597
+ committed += writesByScope.get(scope) ?? 0;
4598
+ },
4599
+ assertGenerationOpen
4600
+ );
4475
4601
  } catch (err) {
4476
4602
  const failedWrite = writes.find((write) => !committedScopes.has(write.scope)) ?? writes[committed];
4477
4603
  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)}`;
@@ -4483,7 +4609,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4483
4609
  );
4484
4610
  }
4485
4611
  }), "persistSettingsFn");
4486
- const { createSubSessionLauncher } = await import("./create-sub-session-QRJLW5BV.js");
4612
+ const { createSubSessionLauncher } = await import("./create-sub-session-45POYEVP.js");
4487
4613
  const subSessionLauncher = createSubSessionLauncher({
4488
4614
  getBridge: /* @__PURE__ */ __name(() => bridgeRef, "getBridge"),
4489
4615
  boundWorkspace
@@ -4502,10 +4628,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4502
4628
  ),
4503
4629
  maxSessions: opts.maxSessions,
4504
4630
  freshSessionAdmission: totalSessionAdmission.admit,
4505
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
4631
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
4632
+ if (event.type === "registered" && primaryGenerationGuard.closed) {
4633
+ return;
4634
+ }
4635
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
4636
+ }, "sessionLifecycle"),
4506
4637
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
4507
4638
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
4508
4639
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
4640
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
4641
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
4509
4642
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
4510
4643
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
4511
4644
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -4523,8 +4656,23 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4523
4656
  statusProvider,
4524
4657
  fileSystem: createBridgeFileSystemAdapter(fsFactory),
4525
4658
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
4526
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4527
- fresh.setValue(WORKSPACE_SETTING_SCOPE, "tools.approvalMode", mode);
4659
+ primaryGenerationGuard.assertOpen();
4660
+ if (!trustedWorkspace) {
4661
+ throw new Error(
4662
+ "Cannot persist approval mode for an untrusted workspace."
4663
+ );
4664
+ }
4665
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
4666
+ skipLoadEnvironment: true,
4667
+ workspaceTrusted: trustedWorkspace
4668
+ });
4669
+ primaryGenerationGuard.assertOpen();
4670
+ fresh.setValue(
4671
+ WORKSPACE_SETTING_SCOPE,
4672
+ "tools.approvalMode",
4673
+ mode,
4674
+ () => primaryGenerationGuard.assertOpen()
4675
+ );
4528
4676
  }), "persistApprovalMode")
4529
4677
  });
4530
4678
  if (!deps.bridge) {
@@ -4536,6 +4684,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4536
4684
  }, "invalidatePrimaryServeFeaturesCache");
4537
4685
  const workspaceService = runtime.createDaemonWorkspaceService({
4538
4686
  boundWorkspace,
4687
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => trustedWorkspace, "isWorkspaceTrusted"),
4688
+ assertGenerationOpen: /* @__PURE__ */ __name(() => primaryGenerationGuard.assertOpen(), "assertGenerationOpen"),
4539
4689
  contextFilename: contextFilenameForInit ?? "QWEN.md",
4540
4690
  statusProvider,
4541
4691
  workspaceProvidersStatusProvider,
@@ -4548,13 +4698,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4548
4698
  persistSetting: persistSettingFn,
4549
4699
  persistSettings: persistSettingsFn,
4550
4700
  preheatAcpChild: /* @__PURE__ */ __name(() => bridge.preheat(), "preheatAcpChild"),
4551
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
4701
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
4702
+ assertGenerationOpen?.();
4552
4703
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
4553
- skipLoadEnvironment: true
4704
+ skipLoadEnvironment: true,
4705
+ skipWorkspaceSettings: !trustedWorkspace,
4706
+ workspaceTrusted: trustedWorkspace
4554
4707
  });
4708
+ assertGenerationOpen?.();
4555
4709
  const result = settingsRuntime.settings.reloadEnvironment(
4556
4710
  fresh.merged,
4557
- workspace
4711
+ workspace,
4712
+ trustedWorkspace
4558
4713
  );
4559
4714
  let refreshedRuntimeEnv;
4560
4715
  let fallbackReason;
@@ -4562,7 +4717,8 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4562
4717
  refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
4563
4718
  fresh.merged,
4564
4719
  workspace,
4565
- daemonRuntimeBaseEnv
4720
+ daemonRuntimeBaseEnv,
4721
+ trustedWorkspace
4566
4722
  );
4567
4723
  } catch (err) {
4568
4724
  fallbackReason = err instanceof Error ? err.message : String(err);
@@ -4621,6 +4777,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4621
4777
  {
4622
4778
  workspaceId: daemonWorkspaceHash,
4623
4779
  workspaceCwd: boundWorkspace,
4780
+ sessionRuntimeBaseDir: primarySessionRuntimeBaseDir,
4624
4781
  ...workspaceInputs[0]?.displayName ? { displayName: workspaceInputs[0].displayName } : {},
4625
4782
  primary: true,
4626
4783
  trusted: trustedWorkspace,
@@ -4630,14 +4787,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4630
4787
  bridge,
4631
4788
  workspaceService,
4632
4789
  routeFileSystemFactory: routeFsFactory,
4633
- clientMcpSenderRegistry
4790
+ clientMcpSenderRegistry,
4791
+ generationGuard: primaryGenerationGuard,
4792
+ trustMaterialization: primaryTrustMaterialization
4634
4793
  }
4635
4794
  ];
4636
- const createRuntimeEnvMetadata = /* @__PURE__ */ __name((workspace, settings) => {
4795
+ const createRuntimeEnvMetadata = /* @__PURE__ */ __name((workspace, settings, trusted) => {
4637
4796
  const snapshot = settings ? settingsRuntime.environment.buildRuntimeEnvironment(
4638
4797
  settings.merged,
4639
4798
  workspace,
4640
- daemonRuntimeBaseEnv
4799
+ daemonRuntimeBaseEnv,
4800
+ trusted
4641
4801
  ) : {
4642
4802
  effectiveEnv: { ...daemonRuntimeBaseEnv },
4643
4803
  overlayKeys: Object.freeze([]),
@@ -4646,7 +4806,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4646
4806
  envFileReadFailures: Object.freeze([])
4647
4807
  };
4648
4808
  logRuntimeEnvFileReadFailures(workspace, snapshot);
4649
- const effectiveEnv = { ...snapshot.effectiveEnv };
4809
+ const sessionRuntimeBaseDir = resolveSessionRuntimeBaseDir(
4810
+ workspace,
4811
+ settings,
4812
+ snapshot.effectiveEnv
4813
+ );
4814
+ const effectiveEnv = {
4815
+ ...snapshot.effectiveEnv,
4816
+ QWEN_RUNTIME_DIR: sessionRuntimeBaseDir
4817
+ };
4650
4818
  const metadata = {
4651
4819
  mode: "runtime-overlay",
4652
4820
  overlayKeys: [...snapshot.overlayKeys],
@@ -4658,36 +4826,44 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4658
4826
  return {
4659
4827
  metadata,
4660
4828
  effectiveEnv,
4829
+ sessionRuntimeBaseDir,
4661
4830
  replace(nextEnv) {
4662
4831
  for (const key of Object.keys(effectiveEnv)) {
4663
4832
  delete effectiveEnv[key];
4664
4833
  }
4665
4834
  Object.assign(effectiveEnv, nextEnv);
4835
+ effectiveEnv["QWEN_RUNTIME_DIR"] = sessionRuntimeBaseDir;
4666
4836
  }
4667
4837
  };
4668
4838
  }, "createRuntimeEnvMetadata");
4669
4839
  const subSessionStoppers = [];
4670
- const subSessionStoppersByWorkspace = /* @__PURE__ */ new Map();
4840
+ const subSessionStoppersByRuntime = /* @__PURE__ */ new WeakMap();
4671
4841
  const runtimeCleanupPromises = /* @__PURE__ */ new WeakMap();
4672
4842
  const removeArrayValue = /* @__PURE__ */ __name((values, value) => {
4673
4843
  const index = values.indexOf(value);
4674
4844
  if (index >= 0) values.splice(index, 1);
4675
4845
  }, "removeArrayValue");
4676
4846
  for (const workspaceInput of workspaceInputs.slice(1)) {
4847
+ const secondaryDecision = trustPolicy.evaluateDaemonWorkspaceTrust(
4848
+ bootTrustSnapshot,
4849
+ workspaceInput.cwd
4850
+ );
4851
+ const secondaryTrusted = secondaryDecision.targetTrusted;
4677
4852
  let secondarySettings;
4678
4853
  try {
4679
4854
  secondarySettings = settingsRuntime.settings.loadSettings(
4680
- workspaceInput.cwd
4855
+ workspaceInput.cwd,
4856
+ {
4857
+ skipLoadEnvironment: true,
4858
+ skipWorkspaceSettings: !secondaryTrusted,
4859
+ workspaceTrusted: secondaryTrusted
4860
+ }
4681
4861
  );
4682
4862
  } catch (err) {
4683
4863
  writeStderrLine(
4684
4864
  `qwen serve: could not read full settings for secondary workspace ${workspaceInput.cwd} (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4685
4865
  );
4686
4866
  }
4687
- const secondaryTrusted = secondarySettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4688
- secondarySettings.merged,
4689
- workspaceInput.cwd
4690
- ).effective.state === "trusted" : false;
4691
4867
  if (!secondaryTrusted) {
4692
4868
  daemonLog.warn("secondary workspace is not trusted", {
4693
4869
  workspace: workspaceInput.cwd,
@@ -4696,11 +4872,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4696
4872
  }
4697
4873
  const secondaryEnv = createRuntimeEnvMetadata(
4698
4874
  workspaceInput.cwd,
4699
- secondarySettings
4875
+ secondarySettings,
4876
+ secondaryTrusted
4700
4877
  );
4878
+ const secondaryCustomIgnoreFiles = secondarySettings?.merged.context?.fileFiltering?.customIgnoreFiles;
4879
+ const secondaryContextFilename = extractContextFilename(secondarySettings?.merged.context?.fileName) ?? contextFilenameForInit ?? "QWEN.md";
4701
4880
  const secondaryWorkspaceHash = core.hashDaemonWorkspace(
4702
4881
  workspaceInput.cwd
4703
4882
  );
4883
+ const secondaryGenerationGuard = runtime.createWorkspaceGenerationGuard();
4704
4884
  const secondaryStatusProvider = runtime.createDaemonStatusProvider({
4705
4885
  env: secondaryEnv.effectiveEnv
4706
4886
  });
@@ -4709,9 +4889,11 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4709
4889
  trusted: secondaryTrusted,
4710
4890
  emit: deps.fsAuditEmit,
4711
4891
  pathLocks: sharedPathLocks,
4712
- ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
4892
+ generationGuard: secondaryGenerationGuard,
4893
+ ...secondaryCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: secondaryCustomIgnoreFiles } : {}
4713
4894
  });
4714
4895
  const secondaryChannelFactory = runtime.createSpawnChannelFactory({
4896
+ processRegistry,
4715
4897
  sourceEnv: secondaryEnv.effectiveEnv,
4716
4898
  onDiagnosticLine: diagnosticSink,
4717
4899
  pipeHooks: {
@@ -4743,10 +4925,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4743
4925
  ),
4744
4926
  maxSessions: opts.maxSessions,
4745
4927
  freshSessionAdmission: totalSessionAdmission.admit,
4746
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
4928
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
4929
+ if (event.type === "registered" && secondaryGenerationGuard.closed) {
4930
+ return;
4931
+ }
4932
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
4933
+ }, "sessionLifecycle"),
4747
4934
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
4748
4935
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
4749
4936
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
4937
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
4938
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
4750
4939
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
4751
4940
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
4752
4941
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -4766,26 +4955,42 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4766
4955
  statusProvider: secondaryStatusProvider,
4767
4956
  fileSystem: createBridgeFileSystemAdapter(secondaryBridgeFsFactory),
4768
4957
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
4769
- const fresh = settingsRuntime.settings.loadSettings(workspace);
4770
- fresh.setValue(WORKSPACE_SETTING_SCOPE, "tools.approvalMode", mode);
4958
+ secondaryGenerationGuard.assertOpen();
4959
+ if (!secondaryTrusted) {
4960
+ throw new Error(
4961
+ "Cannot persist approval mode for an untrusted workspace."
4962
+ );
4963
+ }
4964
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
4965
+ skipLoadEnvironment: true,
4966
+ workspaceTrusted: secondaryTrusted
4967
+ });
4968
+ secondaryGenerationGuard.assertOpen();
4969
+ fresh.setValue(
4970
+ WORKSPACE_SETTING_SCOPE,
4971
+ "tools.approvalMode",
4972
+ mode,
4973
+ () => secondaryGenerationGuard.assertOpen()
4974
+ );
4771
4975
  }), "persistApprovalMode")
4772
4976
  });
4773
4977
  secondaryBridgeRef = secondaryBridge;
4774
4978
  runtimeBridges.push(secondaryBridge);
4775
4979
  internalRuntimeBridgesForCleanup.push(secondaryBridge);
4776
4980
  subSessionStoppers.push(secondarySubSessionLauncher.stop);
4777
- subSessionStoppersByWorkspace.set(
4778
- workspaceInput.cwd,
4779
- secondarySubSessionLauncher.stop
4780
- );
4781
4981
  const secondaryWorkspaceService = runtime.createDaemonWorkspaceService({
4782
4982
  boundWorkspace: workspaceInput.cwd,
4783
- contextFilename: contextFilenameForInit ?? "QWEN.md",
4983
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => secondaryTrusted, "isWorkspaceTrusted"),
4984
+ assertGenerationOpen: /* @__PURE__ */ __name(() => secondaryGenerationGuard.assertOpen(), "assertGenerationOpen"),
4985
+ contextFilename: secondaryContextFilename,
4784
4986
  statusProvider: secondaryStatusProvider,
4785
4987
  workspaceProvidersStatusProvider: runtime.createWorkspaceProvidersStatusProvider({
4786
- env: secondaryEnv.effectiveEnv
4988
+ env: secondaryEnv.effectiveEnv,
4989
+ workspaceTrusted: secondaryTrusted
4990
+ }),
4991
+ workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider({
4992
+ workspaceTrusted: secondaryTrusted
4787
4993
  }),
4788
- workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider(),
4789
4994
  skillInstallEnv: secondaryEnv.effectiveEnv,
4790
4995
  voiceEnv: secondaryEnv.effectiveEnv,
4791
4996
  voiceSettingsScope: WORKSPACE_SETTING_SCOPE,
@@ -4795,19 +5000,25 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4795
5000
  persistDisabledSkills: persistDisabledSkillsFn,
4796
5001
  persistSetting: persistSettingFn,
4797
5002
  persistSettings: persistSettingsFn,
4798
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
5003
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
5004
+ assertGenerationOpen?.();
4799
5005
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
4800
- skipLoadEnvironment: true
5006
+ skipLoadEnvironment: true,
5007
+ skipWorkspaceSettings: !secondaryTrusted,
5008
+ workspaceTrusted: secondaryTrusted
4801
5009
  });
5010
+ assertGenerationOpen?.();
4802
5011
  const result = settingsRuntime.settings.reloadEnvironment(
4803
5012
  fresh.merged,
4804
- workspace
5013
+ workspace,
5014
+ secondaryTrusted
4805
5015
  );
4806
5016
  try {
4807
5017
  const refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
4808
5018
  fresh.merged,
4809
5019
  workspace,
4810
- daemonRuntimeBaseEnv
5020
+ daemonRuntimeBaseEnv,
5021
+ secondaryTrusted
4811
5022
  );
4812
5023
  logRuntimeEnvFileReadFailures(workspace, refreshedRuntimeEnv);
4813
5024
  secondaryEnv.replace(refreshedRuntimeEnv.effectiveEnv);
@@ -4845,9 +5056,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4845
5056
  refreshExtensionsForAllSessions: /* @__PURE__ */ __name(() => secondaryBridge.refreshExtensionsForAllSessions(), "refreshExtensionsForAllSessions"),
4846
5057
  publishWorkspaceEvent: /* @__PURE__ */ __name((event) => secondaryBridge.publishWorkspaceEvent(event), "publishWorkspaceEvent")
4847
5058
  });
4848
- workspaceRuntimes.push({
5059
+ const secondaryRuntime = {
4849
5060
  workspaceId: secondaryWorkspaceHash,
4850
5061
  workspaceCwd: workspaceInput.cwd,
5062
+ sessionRuntimeBaseDir: secondaryEnv.sessionRuntimeBaseDir,
4851
5063
  ...workspaceInput.displayName ? { displayName: workspaceInput.displayName } : {},
4852
5064
  primary: false,
4853
5065
  trusted: secondaryTrusted,
@@ -4857,12 +5069,24 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4857
5069
  bridge: secondaryBridge,
4858
5070
  workspaceService: secondaryWorkspaceService,
4859
5071
  routeFileSystemFactory: secondaryBridgeFsFactory,
4860
- clientMcpSenderRegistry: secondaryClientMcpSenderRegistry
4861
- });
5072
+ clientMcpSenderRegistry: secondaryClientMcpSenderRegistry,
5073
+ generationGuard: secondaryGenerationGuard,
5074
+ trustMaterialization: JSON.stringify({
5075
+ trusted: secondaryTrusted,
5076
+ boundWorkspaces: [workspaceInput.cwd]
5077
+ })
5078
+ };
5079
+ subSessionStoppersByRuntime.set(
5080
+ secondaryRuntime,
5081
+ secondarySubSessionLauncher.stop
5082
+ );
5083
+ workspaceRuntimes.push(secondaryRuntime);
4862
5084
  }
4863
5085
  const workspaceRegistry = runtime.createWorkspaceRegistry(workspaceRuntimes, {
4864
- sessionOwnerIndex
5086
+ sessionOwnerIndex,
5087
+ scanUnindexedOwners: deps.bridge !== void 0
4865
5088
  });
5089
+ workspaceRegistryForPersistence.current = workspaceRegistry;
4866
5090
  const workspaceVoiceCoordinator = new WorkspaceVoiceCoordinator();
4867
5091
  core.registerDaemonGaugeCallbacks({
4868
5092
  sessionCount: /* @__PURE__ */ __name(() => workspaceRegistry.list().reduce((sum, item) => sum + item.bridge.sessionCount, 0), "sessionCount"),
@@ -4897,9 +5121,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4897
5121
  const rejectedTotal = hits ? hits.prompt + hits.mutation + hits.read : 0;
4898
5122
  const rateLimitRejected = prevRateRejected === void 0 ? 0 : Math.max(0, rejectedTotal - prevRateRejected);
4899
5123
  prevRateRejected = rejectedTotal;
4900
- const child = bridge.getChildResourceSnapshot?.();
5124
+ const primaryEntry = workspaceRegistry.primaryEntry;
5125
+ const primaryRuntimeBridge = primaryEntry.state === "active" ? primaryEntry.current?.runtime.bridge : void 0;
5126
+ const child = primaryRuntimeBridge?.getChildResourceSnapshot?.();
4901
5127
  if (runtime.getActiveSseCount() > 0 || (acp?.wsStreams ?? 0) > 0) {
4902
- void bridge.refreshChildResource?.();
5128
+ void primaryRuntimeBridge?.refreshChildResource?.().catch((err) => {
5129
+ daemonLog.warn(
5130
+ `ACP child resource refresh failed: ${err instanceof Error ? err.message : String(err)}`
5131
+ );
5132
+ });
4903
5133
  }
4904
5134
  metricsRing.sample(nowMs, {
4905
5135
  cpuPercent,
@@ -4955,34 +5185,52 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
4955
5185
  metricsLoopDelay.disable();
4956
5186
  }
4957
5187
  };
4958
- const createDynamicWorkspaceRuntime = /* @__PURE__ */ __name(async (cwd, options) => {
4959
- if (options.provenance === "managed-scratch" && (!managedScratchRoot || !isManagedScratchChild(cwd, managedScratchRoot.canonicalRoot))) {
5188
+ const createDynamicWorkspaceRuntime = /* @__PURE__ */ __name(async (cwd, buildOptions) => {
5189
+ const provenance = buildOptions?.provenance ?? "existing";
5190
+ if (provenance === "managed-scratch" && (!managedScratchRoot || !isManagedScratchChild(cwd, managedScratchRoot.canonicalRoot))) {
4960
5191
  throw new Error(
4961
5192
  "Managed scratch runtime must use an accepted direct child directory"
4962
5193
  );
4963
5194
  }
5195
+ const snapshot = buildOptions?.snapshot ?? await trustPolicy.readDaemonTrustPolicySnapshot();
5196
+ const decision = buildOptions?.decision ?? trustPolicy.evaluateDaemonWorkspaceTrust(snapshot, cwd);
5197
+ const trusted = provenance === "managed-scratch" ? true : buildOptions?.trusted ?? decision.targetTrusted;
4964
5198
  let wsSettings;
4965
5199
  try {
4966
- wsSettings = settingsRuntime.settings.loadSettings(cwd);
5200
+ wsSettings = settingsRuntime.settings.loadSettings(cwd, {
5201
+ skipLoadEnvironment: true,
5202
+ skipWorkspaceSettings: !trusted,
5203
+ workspaceTrusted: trusted
5204
+ });
4967
5205
  } catch (err) {
4968
5206
  writeStderrLine(
4969
5207
  `qwen serve: could not read full settings for dynamic workspace ${cwd} (${err instanceof Error ? err.message : String(err)}); falling back to defaults.`
4970
5208
  );
4971
5209
  }
4972
- const trusted = options.provenance === "managed-scratch" || (wsSettings ? settingsRuntime.trustedFolders.getWorkspaceTrustStatus(
4973
- wsSettings.merged,
4974
- cwd
4975
- ).effective.state === "trusted" : false);
4976
- const wsEnv = createRuntimeEnvMetadata(cwd, wsSettings);
5210
+ const wsEnv = createRuntimeEnvMetadata(cwd, wsSettings, trusted);
5211
+ const wsCustomIgnoreFiles = wsSettings?.merged.context?.fileFiltering?.customIgnoreFiles;
5212
+ const wsContextFilename = extractContextFilename(wsSettings?.merged.context?.fileName) ?? contextFilenameForInit ?? "QWEN.md";
4977
5213
  const wsHash = core.hashDaemonWorkspace(cwd);
5214
+ const generationGuard = buildOptions?.generationGuard ?? runtime.createWorkspaceGenerationGuard();
5215
+ const runtimeBoundWorkspaces = buildOptions?.boundWorkspaces ?? [cwd];
4978
5216
  const wsFsFactory = runtime.resolveBridgeFsFactory({
4979
- boundWorkspaces: [cwd],
5217
+ boundWorkspaces: runtimeBoundWorkspaces,
4980
5218
  trusted,
4981
5219
  emit: deps.fsAuditEmit,
4982
5220
  pathLocks: sharedPathLocks,
4983
- ...customIgnoreFiles !== void 0 ? { customIgnoreFiles } : {}
5221
+ generationGuard,
5222
+ ...wsCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: wsCustomIgnoreFiles } : {}
4984
5223
  });
5224
+ const wsRouteFsFactory = buildOptions?.primary === true && runtimeBoundWorkspaces.length > 1 ? runtime.resolveBridgeFsFactory({
5225
+ boundWorkspaces: [cwd],
5226
+ trusted,
5227
+ emit: deps.fsAuditEmit,
5228
+ pathLocks: sharedPathLocks,
5229
+ generationGuard,
5230
+ ...wsCustomIgnoreFiles !== void 0 ? { customIgnoreFiles: wsCustomIgnoreFiles } : {}
5231
+ }) : wsFsFactory;
4985
5232
  const wsChannelFactory = runtime.createSpawnChannelFactory({
5233
+ processRegistry,
4986
5234
  sourceEnv: wsEnv.effectiveEnv,
4987
5235
  onDiagnosticLine: diagnosticSink,
4988
5236
  pipeHooks: {
@@ -5016,10 +5264,15 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5016
5264
  ),
5017
5265
  maxSessions: opts.maxSessions,
5018
5266
  freshSessionAdmission: totalSessionAdmission.admit,
5019
- sessionLifecycle: sessionOwnerIndex.handleBridgeSessionLifecycle,
5267
+ sessionLifecycle: /* @__PURE__ */ __name((event) => {
5268
+ if (event.type === "registered" && generationGuard.closed) return;
5269
+ sessionOwnerIndex.handleBridgeSessionLifecycle(event);
5270
+ }, "sessionLifecycle"),
5020
5271
  ...opts.maxPendingPromptsPerSession !== void 0 ? { maxPendingPromptsPerSession: opts.maxPendingPromptsPerSession } : {},
5021
5272
  ...opts.eventRingSize !== void 0 ? { eventRingSize: opts.eventRingSize } : {},
5022
5273
  ...opts.compactedReplayMaxBytes !== void 0 ? { compactedReplayMaxBytes: opts.compactedReplayMaxBytes } : {},
5274
+ ...opts.maxJournalEvents !== void 0 ? { maxJournalEvents: opts.maxJournalEvents } : {},
5275
+ ...opts.maxJournalBytes !== void 0 ? { maxJournalBytes: opts.maxJournalBytes } : {},
5023
5276
  ...opts.channelIdleTimeoutMs !== void 0 ? { channelIdleTimeoutMs: opts.channelIdleTimeoutMs } : {},
5024
5277
  ...opts.initializeTimeoutMs !== void 0 ? { initializeTimeoutMs: opts.initializeTimeoutMs } : {},
5025
5278
  ...opts.sessionReapIntervalMs !== void 0 ? { sessionReapIntervalMs: opts.sessionReapIntervalMs } : {},
@@ -5032,18 +5285,31 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5032
5285
  onDiagnosticLine: diagnosticSink,
5033
5286
  telemetry: createRuntimeBridgeTelemetry(wsHash),
5034
5287
  ...permissionPolicy !== void 0 ? { permissionPolicy } : {},
5035
- ...permissionConsensusQuorum !== void 0 ? { permissionConsensusQuorum } : {},
5288
+ ...permissionConsensusQuorum !== void 0 ? {
5289
+ permissionConsensusQuorum
5290
+ } : {},
5036
5291
  permissionAudit: permissionAuditPublisher,
5037
5292
  statusProvider: runtime.createDaemonStatusProvider({
5038
5293
  env: wsEnv.effectiveEnv
5039
5294
  }),
5040
5295
  fileSystem: createBridgeFileSystemAdapter(wsFsFactory),
5041
5296
  persistApprovalMode: /* @__PURE__ */ __name((workspace, mode) => withSettingsLock(workspace, async () => {
5042
- const fresh = settingsRuntime.settings.loadSettings(workspace);
5297
+ generationGuard.assertOpen();
5298
+ if (!trusted) {
5299
+ throw new Error(
5300
+ "Cannot persist approval mode for an untrusted workspace."
5301
+ );
5302
+ }
5303
+ const fresh = settingsRuntime.settings.loadSettings(workspace, {
5304
+ skipLoadEnvironment: true,
5305
+ workspaceTrusted: trusted
5306
+ });
5307
+ generationGuard.assertOpen();
5043
5308
  fresh.setValue(
5044
5309
  WORKSPACE_SETTING_SCOPE,
5045
5310
  "tools.approvalMode",
5046
- mode
5311
+ mode,
5312
+ () => generationGuard.assertOpen()
5047
5313
  );
5048
5314
  }), "persistApprovalMode")
5049
5315
  });
@@ -5056,36 +5322,47 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5056
5322
  try {
5057
5323
  wsService = runtime.createDaemonWorkspaceService({
5058
5324
  boundWorkspace: cwd,
5059
- contextFilename: contextFilenameForInit ?? "QWEN.md",
5325
+ isWorkspaceTrusted: /* @__PURE__ */ __name(() => trusted, "isWorkspaceTrusted"),
5326
+ assertGenerationOpen: /* @__PURE__ */ __name(() => generationGuard.assertOpen(), "assertGenerationOpen"),
5327
+ contextFilename: wsContextFilename,
5060
5328
  statusProvider: runtime.createDaemonStatusProvider({
5061
5329
  env: wsEnv.effectiveEnv
5062
5330
  }),
5063
5331
  workspaceProvidersStatusProvider: runtime.createWorkspaceProvidersStatusProvider({
5064
- env: wsEnv.effectiveEnv
5332
+ env: wsEnv.effectiveEnv,
5333
+ workspaceTrusted: trusted
5334
+ }),
5335
+ workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider({
5336
+ workspaceTrusted: trusted
5065
5337
  }),
5066
- workspaceSkillsStatusProvider: runtime.createWorkspaceSkillsStatusProvider(),
5067
5338
  skillInstallEnv: wsEnv.effectiveEnv,
5068
5339
  voiceEnv: wsEnv.effectiveEnv,
5069
- voiceSettingsScope: WORKSPACE_SETTING_SCOPE,
5340
+ ...buildOptions?.primary === true ? {} : { voiceSettingsScope: WORKSPACE_SETTING_SCOPE },
5070
5341
  isChannelLive: /* @__PURE__ */ __name(() => wsBridge.isChannelLive(), "isChannelLive"),
5071
5342
  preheatAcpChild: /* @__PURE__ */ __name(() => wsBridge.preheat(), "preheatAcpChild"),
5072
5343
  persistDisabledTools: persistDisabledToolsFn,
5073
5344
  persistDisabledSkills: persistDisabledSkillsFn,
5074
5345
  persistSetting: persistSettingFn,
5075
5346
  persistSettings: persistSettingsFn,
5076
- reloadDaemonEnv: /* @__PURE__ */ __name((workspace) => withSettingsLock(workspace, async () => {
5347
+ reloadDaemonEnv: /* @__PURE__ */ __name((workspace, assertGenerationOpen) => withSettingsLock(workspace, async () => {
5348
+ assertGenerationOpen?.();
5077
5349
  const fresh = settingsRuntime.settings.loadSettings(workspace, {
5078
- skipLoadEnvironment: true
5350
+ skipLoadEnvironment: true,
5351
+ skipWorkspaceSettings: !trusted,
5352
+ workspaceTrusted: trusted
5079
5353
  });
5354
+ assertGenerationOpen?.();
5080
5355
  const result = settingsRuntime.settings.reloadEnvironment(
5081
5356
  fresh.merged,
5082
- workspace
5357
+ workspace,
5358
+ trusted
5083
5359
  );
5084
5360
  try {
5085
5361
  const refreshedRuntimeEnv = settingsRuntime.environment.buildRuntimeEnvironment(
5086
5362
  fresh.merged,
5087
5363
  workspace,
5088
- daemonRuntimeBaseEnv
5364
+ daemonRuntimeBaseEnv,
5365
+ trusted
5089
5366
  );
5090
5367
  logRuntimeEnvFileReadFailures(workspace, refreshedRuntimeEnv);
5091
5368
  wsEnv.replace(refreshedRuntimeEnv.effectiveEnv);
@@ -5121,7 +5398,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5121
5398
  queryWorkspaceStatus: /* @__PURE__ */ __name((method, idle) => wsBridge.queryWorkspaceStatus(method, idle), "queryWorkspaceStatus"),
5122
5399
  invokeWorkspaceCommand: /* @__PURE__ */ __name((method, params, invokeOpts) => wsBridge.invokeWorkspaceCommand(method, params, invokeOpts), "invokeWorkspaceCommand"),
5123
5400
  refreshExtensionsForAllSessions: /* @__PURE__ */ __name(() => wsBridge.refreshExtensionsForAllSessions(), "refreshExtensionsForAllSessions"),
5124
- publishWorkspaceEvent: /* @__PURE__ */ __name((event) => wsBridge.publishWorkspaceEvent(event), "publishWorkspaceEvent")
5401
+ publishWorkspaceEvent: /* @__PURE__ */ __name((event) => {
5402
+ if (buildOptions?.primary === true && (event.type === "settings_changed" || event.type === "settings_reloaded")) {
5403
+ invalidatePrimaryServeFeaturesCache();
5404
+ }
5405
+ wsBridge.publishWorkspaceEvent(event);
5406
+ }, "publishWorkspaceEvent")
5125
5407
  });
5126
5408
  } catch (err) {
5127
5409
  wsSubSessionLauncher.stop();
@@ -5136,31 +5418,76 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5136
5418
  runtimeBridges.push(wsBridge);
5137
5419
  internalRuntimeBridgesForCleanup.push(wsBridge);
5138
5420
  subSessionStoppers.push(wsSubSessionLauncher.stop);
5139
- subSessionStoppersByWorkspace.set(cwd, wsSubSessionLauncher.stop);
5140
- return {
5421
+ const wsRuntime = {
5141
5422
  workspaceId: wsHash,
5142
5423
  workspaceCwd: cwd,
5143
- primary: false,
5424
+ sessionRuntimeBaseDir: wsEnv.sessionRuntimeBaseDir,
5425
+ ...buildOptions?.displayName !== void 0 ? { displayName: buildOptions.displayName } : {},
5426
+ primary: buildOptions?.primary ?? false,
5144
5427
  trusted,
5145
- removable: true,
5146
- registrationIds: [],
5428
+ provenance,
5429
+ removable: buildOptions?.removable ?? true,
5430
+ registrationIds: [...buildOptions?.registrationIds ?? []],
5147
5431
  env: wsEnv.metadata,
5148
5432
  bridge: wsBridge,
5149
5433
  workspaceService: wsService,
5150
- routeFileSystemFactory: wsFsFactory,
5151
- clientMcpSenderRegistry: wsClientMcpRegistry
5434
+ routeFileSystemFactory: wsRouteFsFactory,
5435
+ clientMcpSenderRegistry: wsClientMcpRegistry,
5436
+ generationGuard,
5437
+ trustMaterialization: buildOptions?.trustMaterialization ?? JSON.stringify({
5438
+ trusted,
5439
+ boundWorkspaces: [...runtimeBoundWorkspaces].sort()
5440
+ })
5152
5441
  };
5442
+ subSessionStoppersByRuntime.set(wsRuntime, wsSubSessionLauncher.stop);
5443
+ if (provenance !== "managed-scratch" && !buildOptions?.snapshot) {
5444
+ const latest = await trustPolicy.readDaemonTrustPolicySnapshot();
5445
+ if (latest.revision !== snapshot.revision) {
5446
+ generationGuard.close();
5447
+ wsSubSessionLauncher.stop();
5448
+ await wsBridge.shutdown({ reason: "trust_reconfigured" }).catch(() => {
5449
+ try {
5450
+ wsBridge.killAllSync();
5451
+ } catch {
5452
+ }
5453
+ });
5454
+ subSessionStoppersByRuntime.delete(wsRuntime);
5455
+ removeArrayValue(subSessionStoppers, wsSubSessionLauncher.stop);
5456
+ removeArrayValue(runtimeBridges, wsBridge);
5457
+ removeArrayValue(internalRuntimeBridgesForCleanup, wsBridge);
5458
+ if ((buildOptions?.validationAttempt ?? 0) >= 2) {
5459
+ throw new Error(
5460
+ "Workspace trust policy kept changing during runtime creation."
5461
+ );
5462
+ }
5463
+ const { generationGuard: _staleGuard, ...retryOptions } = buildOptions ?? {};
5464
+ return createDynamicWorkspaceRuntime(cwd, {
5465
+ ...retryOptions,
5466
+ validationAttempt: (buildOptions?.validationAttempt ?? 0) + 1
5467
+ });
5468
+ }
5469
+ }
5470
+ return wsRuntime;
5153
5471
  }, "createDynamicWorkspaceRuntime");
5472
+ const serveAppForRuntimeLifecycle = { current: void 0 };
5154
5473
  const workspaceRuntimeRemoval = {
5155
5474
  async runtimeAdded(runtimeAdded) {
5156
- const app3 = runtimeApp ?? runtimeAppForCleanup;
5475
+ channelWebhookEnvByWorkspace.set(
5476
+ runtimeAdded.workspaceCwd,
5477
+ workspaceRuntimeEffectiveEnv(runtimeAdded, daemonRuntimeBaseEnv)
5478
+ );
5479
+ channelWebhookConfigVersion += 1;
5480
+ refreshChannelWebhookConfigs?.();
5481
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5157
5482
  const startScheduledTaskKeepaliveForWorkspace = app3?.locals?.["startScheduledTaskKeepaliveForWorkspace"];
5158
5483
  startScheduledTaskKeepaliveForWorkspace?.(runtimeAdded);
5159
5484
  if (!channelWorkerManager) return;
5160
5485
  try {
5161
- await channelWorkerManager.restoreWorkspace(
5162
- runtimeAdded.workspaceCwd
5163
- );
5486
+ if (runtimeAdded.trusted) {
5487
+ await channelWorkerManager.restoreWorkspace(
5488
+ runtimeAdded.workspaceCwd
5489
+ );
5490
+ }
5164
5491
  await channelWorkerManager.refreshWorkspaces();
5165
5492
  } catch (err) {
5166
5493
  daemonLog.error(
@@ -5172,14 +5499,51 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5172
5499
  }
5173
5500
  },
5174
5501
  beginDrain(runtimeToDrain) {
5502
+ if (runtimeToDrain.primary) {
5503
+ if (bridgeRef === runtimeToDrain.bridge) bridgeRef = void 0;
5504
+ invalidatePrimaryServeFeaturesCache();
5505
+ }
5175
5506
  totalSessionAdmission.beginWorkspaceDrain(runtimeToDrain.workspaceCwd);
5176
5507
  channelWorkerManager?.beginWorkspaceDrain(runtimeToDrain.workspaceCwd);
5177
5508
  workspaceVoiceCoordinator.beginWorkspaceDrain(runtimeToDrain);
5509
+ channelWebhookEnvByWorkspace.delete(runtimeToDrain.workspaceCwd);
5510
+ channelWebhookConfigVersion += 1;
5511
+ refreshChannelWebhookConfigs?.();
5512
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5513
+ const stopScheduledTaskKeepaliveForWorkspace = app3?.locals?.["stopScheduledTaskKeepaliveForWorkspace"];
5514
+ try {
5515
+ stopScheduledTaskKeepaliveForWorkspace?.(runtimeToDrain.workspaceCwd);
5516
+ } catch (err) {
5517
+ daemonLog.error(
5518
+ "workspace scheduled-task drain error",
5519
+ err instanceof Error ? err : null
5520
+ );
5521
+ }
5178
5522
  },
5179
5523
  cancelDrain(runtimeToDrain) {
5524
+ if (runtimeToDrain.primary && bridgeRef === void 0) {
5525
+ bridgeRef = runtimeToDrain.bridge;
5526
+ invalidatePrimaryServeFeaturesCache();
5527
+ }
5180
5528
  channelWorkerManager?.cancelWorkspaceDrain(runtimeToDrain.workspaceCwd);
5181
5529
  totalSessionAdmission.cancelWorkspaceDrain(runtimeToDrain.workspaceCwd);
5182
5530
  workspaceVoiceCoordinator.cancelWorkspaceDrain(runtimeToDrain);
5531
+ channelWebhookEnvByWorkspace.set(
5532
+ runtimeToDrain.workspaceCwd,
5533
+ workspaceRuntimeEffectiveEnv(runtimeToDrain, daemonRuntimeBaseEnv)
5534
+ );
5535
+ channelWebhookConfigVersion += 1;
5536
+ refreshChannelWebhookConfigs?.();
5537
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5538
+ const startScheduledTaskKeepaliveForWorkspace = app3?.locals?.["startScheduledTaskKeepaliveForWorkspace"];
5539
+ try {
5540
+ startScheduledTaskKeepaliveForWorkspace?.(runtimeToDrain);
5541
+ } catch (err) {
5542
+ daemonLog.error(
5543
+ "workspace scheduled-task drain rollback error",
5544
+ err instanceof Error ? err : null
5545
+ );
5546
+ }
5183
5547
  },
5184
5548
  completeDrain(runtimeToDrain) {
5185
5549
  totalSessionAdmission.completeWorkspaceDrain(
@@ -5202,18 +5566,29 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5202
5566
  const existing = runtimeCleanupPromises.get(runtimeToDrain);
5203
5567
  if (existing) return existing;
5204
5568
  const cleanup = (async () => {
5205
- await workspaceVoiceCoordinator.disposeRuntime(
5206
- runtimeToDrain,
5207
- reason
5208
- );
5209
- const stopSubSessions = subSessionStoppersByWorkspace.get(
5210
- runtimeToDrain.workspaceCwd
5211
- );
5569
+ const containmentErrors = [];
5570
+ try {
5571
+ await workspaceVoiceCoordinator.disposeRuntime(
5572
+ runtimeToDrain,
5573
+ reason
5574
+ );
5575
+ } catch (err) {
5576
+ daemonLog.error(
5577
+ "workspace voice cleanup error",
5578
+ err instanceof Error ? err : null
5579
+ );
5580
+ }
5581
+ if (reason === "trust_reconfigured" && workspaceVoiceCoordinator.getWorkspaceActivity(runtimeToDrain) > 0) {
5582
+ containmentErrors.push(
5583
+ new Error("Workspace voice sessions are still active.")
5584
+ );
5585
+ }
5586
+ const stopSubSessions = subSessionStoppersByRuntime.get(runtimeToDrain);
5212
5587
  try {
5213
5588
  stopSubSessions?.();
5214
5589
  } catch {
5215
5590
  }
5216
- if (reason === "workspace_removed" && channelWorkerManager) {
5591
+ if (reason !== "daemon_shutdown" && channelWorkerManager) {
5217
5592
  await channelWorkerManager.removeWorkspace(runtimeToDrain.workspaceCwd).catch((err) => {
5218
5593
  daemonLog.error(
5219
5594
  "workspace channel worker cleanup error",
@@ -5234,25 +5609,65 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5234
5609
  );
5235
5610
  }
5236
5611
  writeChannelWorkerPidfile();
5612
+ if (reason === "trust_reconfigured" && channelWorkerManager.workspaceActivity(
5613
+ runtimeToDrain.workspaceCwd
5614
+ ) > 0) {
5615
+ containmentErrors.push(
5616
+ new Error("Workspace channel workers are still active.")
5617
+ );
5618
+ }
5237
5619
  }
5238
- if (reason === "workspace_removed") {
5239
- const app3 = runtimeApp ?? runtimeAppForCleanup;
5620
+ if (reason !== "daemon_shutdown") {
5621
+ const app3 = serveAppForRuntimeLifecycle.current ?? runtimeApp ?? runtimeAppForCleanup;
5240
5622
  const stopWorkspaceGitStateForWorkspace = app3?.locals?.["stopWorkspaceGitStateForWorkspace"];
5241
5623
  const stopScheduledTaskKeepaliveForWorkspace = app3?.locals?.["stopScheduledTaskKeepaliveForWorkspace"];
5242
- stopWorkspaceGitStateForWorkspace?.(runtimeToDrain.workspaceCwd);
5243
- stopScheduledTaskKeepaliveForWorkspace?.(
5244
- runtimeToDrain.workspaceCwd
5245
- );
5624
+ try {
5625
+ stopWorkspaceGitStateForWorkspace?.(runtimeToDrain.workspaceCwd);
5626
+ } catch (err) {
5627
+ daemonLog.error(
5628
+ "workspace git-state cleanup error",
5629
+ err instanceof Error ? err : null
5630
+ );
5631
+ }
5632
+ try {
5633
+ stopScheduledTaskKeepaliveForWorkspace?.(
5634
+ runtimeToDrain.workspaceCwd
5635
+ );
5636
+ } catch (err) {
5637
+ daemonLog.error(
5638
+ "workspace scheduled-task cleanup error",
5639
+ err instanceof Error ? err : null
5640
+ );
5641
+ }
5246
5642
  }
5247
5643
  let bridgeStopped = false;
5248
5644
  try {
5249
5645
  if (!shutdownBridges.has(runtimeToDrain.bridge)) {
5250
- await runtimeToDrain.bridge.shutdown({ reason });
5646
+ try {
5647
+ await runtimeToDrain.bridge.shutdown({ reason });
5648
+ } catch (shutdownError) {
5649
+ try {
5650
+ runtimeToDrain.bridge.killAllSync();
5651
+ daemonLog.warn(
5652
+ "workspace bridge required forceful shutdown",
5653
+ {
5654
+ workspace: runtimeToDrain.workspaceCwd,
5655
+ reason,
5656
+ error: shutdownError instanceof Error ? shutdownError.message : String(shutdownError)
5657
+ }
5658
+ );
5659
+ } catch (killError) {
5660
+ throw new AggregateError(
5661
+ [shutdownError, killError],
5662
+ "Workspace bridge shutdown could not be confirmed."
5663
+ );
5664
+ }
5665
+ }
5251
5666
  }
5252
5667
  bridgeStopped = true;
5253
5668
  } finally {
5254
- if (bridgeStopped || reason === "workspace_removed") {
5255
- subSessionStoppersByWorkspace.delete(runtimeToDrain.workspaceCwd);
5669
+ if (bridgeStopped) {
5670
+ subSessionStoppersByRuntime.delete(runtimeToDrain);
5256
5671
  if (stopSubSessions) {
5257
5672
  removeArrayValue(subSessionStoppers, stopSubSessions);
5258
5673
  }
@@ -5264,22 +5679,103 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5264
5679
  shutdownBridges.add(runtimeToDrain.bridge);
5265
5680
  }
5266
5681
  }
5682
+ if (containmentErrors.length > 0) {
5683
+ throw new AggregateError(
5684
+ containmentErrors,
5685
+ "Workspace runtime containment could not be confirmed."
5686
+ );
5687
+ }
5267
5688
  })();
5268
5689
  runtimeCleanupPromises.set(runtimeToDrain, cleanup);
5269
5690
  void cleanup.catch(() => {
5270
- if (reason === "daemon_shutdown" && runtimeCleanupPromises.get(runtimeToDrain) === cleanup) {
5691
+ if (runtimeCleanupPromises.get(runtimeToDrain) === cleanup) {
5271
5692
  runtimeCleanupPromises.delete(runtimeToDrain);
5272
5693
  }
5273
5694
  });
5274
5695
  return cleanup;
5275
5696
  }
5276
5697
  };
5698
+ const channelManagementServices = /* @__PURE__ */ new WeakMap();
5699
+ const channelManagementService = /* @__PURE__ */ __name((targetRuntime) => {
5700
+ const existing = channelManagementServices.get(targetRuntime);
5701
+ if (existing) return existing;
5702
+ const pending = (async () => {
5703
+ if (!ensureChannelWorkerManager) {
5704
+ throw Object.assign(
5705
+ new Error("Channel worker manager is unavailable."),
5706
+ { code: "channel_worker_unavailable" }
5707
+ );
5708
+ }
5709
+ const [
5710
+ { createChannelManagementService },
5711
+ { WorkspaceChannelSettingsStore }
5712
+ ] = await Promise.all([
5713
+ import("./channel-management-service-5S7YCWX5.js"),
5714
+ import("./channel-settings-store-NLOKYO23.js")
5715
+ ]);
5716
+ return createChannelManagementService({
5717
+ workspaceCwd: targetRuntime.workspaceCwd,
5718
+ store: new WorkspaceChannelSettingsStore(targetRuntime.workspaceCwd),
5719
+ manager: await ensureChannelWorkerManager()
5720
+ });
5721
+ })();
5722
+ channelManagementServices.set(targetRuntime, pending);
5723
+ void pending.catch(() => {
5724
+ if (channelManagementServices.get(targetRuntime) === pending) {
5725
+ channelManagementServices.delete(targetRuntime);
5726
+ }
5727
+ });
5728
+ return pending;
5729
+ }, "channelManagementService");
5730
+ const validateWorkspaceRuntimeForPublication = /* @__PURE__ */ __name(async (runtimeForPublication) => {
5731
+ let candidate = runtimeForPublication;
5732
+ for (let attempt = 0; attempt < 3; attempt++) {
5733
+ const snapshot = await trustPolicy.readDaemonTrustPolicySnapshot();
5734
+ const decision = trustPolicy.evaluateDaemonWorkspaceTrust(
5735
+ snapshot,
5736
+ candidate.workspaceCwd
5737
+ );
5738
+ const materialization = JSON.stringify({
5739
+ trusted: decision.targetTrusted,
5740
+ boundWorkspaces: [candidate.workspaceCwd]
5741
+ });
5742
+ if (candidate.trustMaterialization === materialization) {
5743
+ return candidate;
5744
+ }
5745
+ candidate.generationGuard?.close();
5746
+ await workspaceRuntimeRemoval.disposeRuntime(
5747
+ candidate,
5748
+ "trust_reconfigured"
5749
+ );
5750
+ if (attempt === 2) {
5751
+ throw new Error(
5752
+ "Workspace trust policy kept changing before runtime publication."
5753
+ );
5754
+ }
5755
+ candidate = await createDynamicWorkspaceRuntime(
5756
+ runtimeForPublication.workspaceCwd,
5757
+ {
5758
+ primary: runtimeForPublication.primary,
5759
+ removable: runtimeForPublication.removable,
5760
+ displayName: runtimeForPublication.displayName,
5761
+ registrationIds: runtimeForPublication.registrationIds
5762
+ }
5763
+ );
5764
+ }
5765
+ throw new Error("Workspace runtime publication validation failed.");
5766
+ }, "validateWorkspaceRuntimeForPublication");
5277
5767
  const app2 = runtime.createServeApp(opts, () => actualPort, {
5278
5768
  workspaceRegistry,
5279
5769
  createWorkspaceRuntime: createDynamicWorkspaceRuntime,
5770
+ ...workspaceTrustHotReloadAvailable ? {
5771
+ validateWorkspaceRuntimeForPublication,
5772
+ runWorkspaceTrustOperation,
5773
+ getWorkspaceTrustPolicySnapshot: /* @__PURE__ */ __name(() => latestTrustPolicySnapshot, "getWorkspaceTrustPolicySnapshot")
5774
+ } : {},
5280
5775
  managedScratchRoot,
5281
5776
  workspaceRegistrationStore,
5282
5777
  workspaceRuntimeRemoval,
5778
+ workspaceTrustHotReloadAvailable,
5283
5779
  voiceCoordinator: workspaceVoiceCoordinator,
5284
5780
  bridge,
5285
5781
  webShellDir,
@@ -5330,6 +5826,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5330
5826
  }, "deliverChannelMessage"),
5331
5827
  channelDeliveryAuthorizations,
5332
5828
  reloadChannelWorker,
5829
+ channelManagementService,
5333
5830
  getPerfSnapshot: /* @__PURE__ */ __name(() => ({
5334
5831
  eventLoop: currentDaemonEventLoopMonitor.snapshot(),
5335
5832
  promptQueueWait: {
@@ -5357,9 +5854,10 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5357
5854
  sessionArtifactsPersistenceAvailable: sessionArtifactsPersistenceAvailableFromSettings(
5358
5855
  runtimeBootSettings?.merged
5359
5856
  ),
5360
- installAuthProvider: /* @__PURE__ */ __name((req) => withSettingsLock(
5857
+ installAuthProvider: /* @__PURE__ */ __name((req, assertGenerationOpen) => withSettingsLock(
5361
5858
  boundWorkspace,
5362
5859
  async () => {
5860
+ assertGenerationOpen?.();
5363
5861
  const provider = core.findProviderById(req.providerId);
5364
5862
  if (!provider) {
5365
5863
  throw new Error(`Unsupported auth provider: ${req.providerId}`);
@@ -5369,7 +5867,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5369
5867
  resolveBaseUrl: core.resolveBaseUrl
5370
5868
  });
5371
5869
  const plan = core.buildInstallPlan(provider, inputs);
5372
- const fresh = settingsRuntime.settings.loadSettings(boundWorkspace);
5870
+ const fresh = loadSettingsForPersistence(boundWorkspace);
5373
5871
  const adapter = settingsRuntime.loadedSettingsAdapter.createLoadedSettingsAdapter(
5374
5872
  fresh
5375
5873
  );
@@ -5377,6 +5875,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5377
5875
  settings: adapter,
5378
5876
  doRefreshAuth: false
5379
5877
  });
5878
+ assertGenerationOpen?.();
5380
5879
  core.emitDaemonLog("Auth provider installed.", {
5381
5880
  "qwen-code.daemon.auth.provider_id": provider.id,
5382
5881
  "qwen-code.daemon.auth.auth_type": plan.authType
@@ -5395,11 +5894,171 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5395
5894
  }
5396
5895
  ), "installAuthProvider")
5397
5896
  });
5897
+ serveAppForRuntimeLifecycle.current = app2;
5398
5898
  invalidatePrimaryServeFeaturesCache = app2.locals.invalidateServeFeaturesCache ?? invalidatePrimaryServeFeaturesCache;
5399
5899
  app2.locals.subSessionStoppers = subSessionStoppers;
5400
5900
  subSessionStoppers.push(subSessionLauncher.stop);
5401
- subSessionStoppersByWorkspace.set(boundWorkspace, subSessionLauncher.stop);
5402
- return { app: app2, bridge };
5901
+ subSessionStoppersByRuntime.set(
5902
+ workspaceRegistry.primary,
5903
+ subSessionLauncher.stop
5904
+ );
5905
+ if (workspaceTrustHotReloadAvailable) {
5906
+ const [
5907
+ { createWorkspaceTrustReconciler },
5908
+ { createDaemonTrustPolicyMonitor }
5909
+ ] = await Promise.all([
5910
+ import("./workspace-trust-reconciler-GGBQV2U5.js"),
5911
+ import("./daemon-trust-policy-monitor-FUTKP42Q.js")
5912
+ ]);
5913
+ const materializationFor = /* @__PURE__ */ __name((entry, snapshot, decision) => {
5914
+ const boundWorkspaces2 = entry.primary && decision.targetTrusted ? runtime.resolveBoundWorkspacesFromIdeEnv(
5915
+ entry.workspaceCwd,
5916
+ void 0,
5917
+ (workspace, index) => index === 0 || trustPolicy.evaluateDaemonWorkspaceTrust(snapshot, workspace).targetTrusted
5918
+ ) : [entry.workspaceCwd];
5919
+ return {
5920
+ key: JSON.stringify({
5921
+ trusted: decision.targetTrusted,
5922
+ boundWorkspaces: [...boundWorkspaces2].sort()
5923
+ }),
5924
+ boundWorkspaces: boundWorkspaces2
5925
+ };
5926
+ }, "materializationFor");
5927
+ const acpHandle = /* @__PURE__ */ __name(() => app2.locals?.["acpHandle"], "acpHandle");
5928
+ const trustReconciler = createWorkspaceTrustReconciler({
5929
+ registry: workspaceRegistry,
5930
+ readLatestSnapshot: trustPolicy.readDaemonTrustPolicySnapshot,
5931
+ materializationKey: /* @__PURE__ */ __name(({ entry, snapshot, decision }) => materializationFor(entry, snapshot, decision).key, "materializationKey"),
5932
+ isTrustDecrease: /* @__PURE__ */ __name(({
5933
+ runtime: current,
5934
+ nextMaterialization,
5935
+ decision
5936
+ }) => {
5937
+ if (current.trusted && !decision.targetTrusted) return true;
5938
+ if (!current.primary || !current.trusted) return false;
5939
+ try {
5940
+ const previous = JSON.parse(
5941
+ current.trustMaterialization ?? "{}"
5942
+ );
5943
+ const next = JSON.parse(nextMaterialization);
5944
+ if (!Array.isArray(previous.boundWorkspaces) || !Array.isArray(next.boundWorkspaces)) {
5945
+ return true;
5946
+ }
5947
+ const nextRoots = new Set(
5948
+ next.boundWorkspaces.filter(
5949
+ (value) => typeof value === "string"
5950
+ )
5951
+ );
5952
+ return previous.boundWorkspaces.some(
5953
+ (value) => typeof value !== "string" || !nextRoots.has(value)
5954
+ );
5955
+ } catch {
5956
+ return true;
5957
+ }
5958
+ }, "isTrustDecrease"),
5959
+ buildRuntime: /* @__PURE__ */ __name(async ({
5960
+ entry,
5961
+ trusted,
5962
+ snapshot,
5963
+ decision,
5964
+ generationGuard
5965
+ }) => {
5966
+ const materialized = materializationFor(
5967
+ entry,
5968
+ snapshot,
5969
+ trusted === decision.targetTrusted ? decision : { ...decision, targetTrusted: trusted }
5970
+ );
5971
+ return createDynamicWorkspaceRuntime(entry.workspaceCwd, {
5972
+ trusted,
5973
+ snapshot,
5974
+ decision,
5975
+ generationGuard,
5976
+ primary: entry.primary,
5977
+ removable: entry.removable,
5978
+ displayName: entry.displayName,
5979
+ registrationIds: entry.registrationIds,
5980
+ boundWorkspaces: materialized.boundWorkspaces,
5981
+ trustMaterialization: materialized.key
5982
+ });
5983
+ }, "buildRuntime"),
5984
+ drainRuntime: /* @__PURE__ */ __name(async (runtimeToDrain) => {
5985
+ workspaceRuntimeRemoval.beginDrain(runtimeToDrain);
5986
+ acpHandle()?.beginWorkspaceDrain(runtimeToDrain.workspaceId);
5987
+ }, "drainRuntime"),
5988
+ disposeRuntime: /* @__PURE__ */ __name(async (runtimeToDispose, reason) => {
5989
+ const errors = [];
5990
+ try {
5991
+ await workspaceRuntimeRemoval.disposeRuntime(
5992
+ runtimeToDispose,
5993
+ reason
5994
+ );
5995
+ } catch (error) {
5996
+ errors.push(error);
5997
+ }
5998
+ try {
5999
+ const handle = acpHandle();
6000
+ if (!runtimeToDispose.primary) {
6001
+ handle?.commitWorkspaceRemoval(runtimeToDispose.workspaceId);
6002
+ }
6003
+ handle?.disposeWorkspace(runtimeToDispose.workspaceId);
6004
+ const deadline = Date.now() + 1e3;
6005
+ while ((handle?.getWorkspaceActivity(runtimeToDispose.workspaceId).memoryTasks ?? 0) > 0 && Date.now() < deadline) {
6006
+ await new Promise((resolve2) => setTimeout(resolve2, 25));
6007
+ }
6008
+ if ((handle?.getWorkspaceActivity(runtimeToDispose.workspaceId).memoryTasks ?? 0) > 0) {
6009
+ throw new Error(
6010
+ "Workspace memory tasks did not stop after runtime disposal."
6011
+ );
6012
+ }
6013
+ } catch (error) {
6014
+ errors.push(error);
6015
+ }
6016
+ if (errors.length === 1) throw errors[0];
6017
+ if (errors.length > 1) {
6018
+ throw new AggregateError(
6019
+ errors,
6020
+ "Workspace runtime and ACP cleanup failed."
6021
+ );
6022
+ }
6023
+ }, "disposeRuntime"),
6024
+ runtimeActivated: /* @__PURE__ */ __name(async (runtimeAdded) => {
6025
+ workspaceRuntimeRemoval.cancelDrain(runtimeAdded);
6026
+ acpHandle()?.cancelWorkspaceDrain(runtimeAdded.workspaceId);
6027
+ if (runtimeAdded.primary) {
6028
+ bridgeRef = runtimeAdded.bridge;
6029
+ invalidatePrimaryServeFeaturesCache();
6030
+ }
6031
+ await workspaceRuntimeRemoval.runtimeAdded(runtimeAdded);
6032
+ }, "runtimeActivated"),
6033
+ onError: /* @__PURE__ */ __name((entry, error) => {
6034
+ daemonLog.error(
6035
+ `workspace trust reconciliation failed for ${entry.workspaceCwd}`,
6036
+ error instanceof Error ? error : null
6037
+ );
6038
+ }, "onError")
6039
+ });
6040
+ const trustMonitor = createDaemonTrustPolicyMonitor({
6041
+ onSnapshot: /* @__PURE__ */ __name((snapshot) => {
6042
+ latestTrustPolicySnapshot = snapshot;
6043
+ return runWorkspaceTrustOperation(
6044
+ () => trustReconciler.reconcile(snapshot)
6045
+ );
6046
+ }, "onSnapshot"),
6047
+ onError: /* @__PURE__ */ __name((error) => {
6048
+ daemonLog.error(
6049
+ "workspace trust policy monitor failed",
6050
+ error instanceof Error ? error : null
6051
+ );
6052
+ }, "onError")
6053
+ });
6054
+ app2.locals.stopTrustPolicyMonitor = () => trustMonitor.stop();
6055
+ app2.locals.requestTrustReconcile = () => trustMonitor.requestReconcile("manual");
6056
+ app2.locals.waitForTrustPolicyIdle = () => runWorkspaceTrustOperation(async () => void 0);
6057
+ await trustMonitor.start();
6058
+ }
6059
+ const activePrimaryBridge = workspaceRegistry.primaryEntry.current?.runtime.bridge;
6060
+ bridgeRef = activePrimaryBridge;
6061
+ return { app: app2, bridge: activePrimaryBridge };
5403
6062
  }, "buildRuntime");
5404
6063
  if (deps.bridge) {
5405
6064
  const runtime = await buildRuntime();
@@ -5456,46 +6115,89 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5456
6115
  );
5457
6116
  }
5458
6117
  const channelValidationSettingsRuntime = opts.channelSelection ? await loadSettingsRuntimeModules() : void 0;
6118
+ const channelValidationTrustPolicy = opts.channelSelection ? await import("./daemon-trust-policy-XB7ZSQFQ.js") : void 0;
6119
+ const channelValidationTrustSnapshot = channelValidationTrustPolicy ? await channelValidationTrustPolicy.readDaemonTrustPolicySnapshot() : void 0;
5459
6120
  const resolveChannelWorkspaceGroupsAtListen = /* @__PURE__ */ __name(() => {
5460
6121
  if (!opts.channelSelection || !channelValidationSettingsRuntime || !channelRuntime) {
5461
6122
  return void 0;
5462
6123
  }
6124
+ const registry = (runtimeApp ?? runtimeAppForCleanup)?.locals?.["workspaceRegistry"];
6125
+ const resolveRuntime = /* @__PURE__ */ __name((workspaceCwd) => {
6126
+ const runtime = registry?.getByWorkspaceCwd(workspaceCwd);
6127
+ if (registry && !runtime) {
6128
+ throw Object.assign(
6129
+ new Error(`Workspace "${workspaceCwd}" is unavailable.`),
6130
+ { code: "workspace_unavailable" }
6131
+ );
6132
+ }
6133
+ return runtime;
6134
+ }, "resolveRuntime");
6135
+ const resolveTrusted = /* @__PURE__ */ __name((workspaceCwd, primary, runtime) => {
6136
+ if (runtime) return runtime.trusted;
6137
+ if (primary && deps.trustedWorkspace !== void 0) {
6138
+ return deps.trustedWorkspace;
6139
+ }
6140
+ if (!channelValidationTrustPolicy || !channelValidationTrustSnapshot) {
6141
+ return false;
6142
+ }
6143
+ return channelValidationTrustPolicy.evaluateDaemonWorkspaceTrust(
6144
+ channelValidationTrustSnapshot,
6145
+ workspaceCwd
6146
+ ).targetTrusted;
6147
+ }, "resolveTrusted");
5463
6148
  const settingsByWorkspace = /* @__PURE__ */ new Map();
5464
6149
  if (workspaceInputs.length === 1) {
5465
6150
  const workspace = workspaceInputs[0];
5466
- const settings = channelValidationSettingsRuntime.settings.loadSettings(
5467
- workspace.cwd
5468
- );
5469
- channelWebhookEnvByWorkspace.set(
5470
- workspace.cwd,
5471
- channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
5472
- settings.merged,
6151
+ const runtime = resolveRuntime(workspace.cwd);
6152
+ const trusted = resolveTrusted(workspace.cwd, true, runtime);
6153
+ if (!trusted) {
6154
+ throw Object.assign(
6155
+ new Error(
6156
+ `Primary workspace "${workspace.cwd}" is not trusted; cannot host channels.`
6157
+ ),
6158
+ { code: "untrusted_workspace" }
6159
+ );
6160
+ }
6161
+ const effectiveEnv = runtime ? workspaceRuntimeEffectiveEnv(runtime, daemonRuntimeBaseEnv) : channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
6162
+ channelValidationSettingsRuntime.settings.loadSettings(
5473
6163
  workspace.cwd,
5474
- daemonRuntimeBaseEnv
5475
- ).effectiveEnv
5476
- );
6164
+ {
6165
+ skipLoadEnvironment: true,
6166
+ skipWorkspaceSettings: false,
6167
+ workspaceTrusted: true
6168
+ }
6169
+ ).merged,
6170
+ workspace.cwd,
6171
+ daemonRuntimeBaseEnv,
6172
+ trusted
6173
+ ).effectiveEnv;
6174
+ channelWebhookEnvByWorkspace.set(workspace.cwd, effectiveEnv);
5477
6175
  return void 0;
5478
6176
  }
5479
6177
  const workspaces = workspaceInputs.map((workspace, index) => {
6178
+ const runtime = resolveRuntime(workspace.cwd);
6179
+ const trusted = resolveTrusted(workspace.cwd, index === 0, runtime);
5480
6180
  const settings = channelValidationSettingsRuntime.settings.loadSettings(
5481
- workspace.cwd
6181
+ workspace.cwd,
6182
+ {
6183
+ skipLoadEnvironment: true,
6184
+ skipWorkspaceSettings: !trusted,
6185
+ workspaceTrusted: trusted
6186
+ }
5482
6187
  );
5483
6188
  settingsByWorkspace.set(workspace.cwd, settings);
5484
6189
  channelWebhookEnvByWorkspace.set(
5485
6190
  workspace.cwd,
5486
- channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
6191
+ runtime ? workspaceRuntimeEffectiveEnv(runtime, daemonRuntimeBaseEnv) : channelValidationSettingsRuntime.environment.buildRuntimeEnvironment(
5487
6192
  settings.merged,
5488
6193
  workspace.cwd,
5489
- daemonRuntimeBaseEnv
6194
+ daemonRuntimeBaseEnv,
6195
+ trusted
5490
6196
  ).effectiveEnv
5491
6197
  );
5492
- const trusted = index === 0 && deps.trustedWorkspace !== void 0 ? deps.trustedWorkspace : channelValidationSettingsRuntime.trustedFolders.getWorkspaceTrustStatus(
5493
- settings.merged,
5494
- workspace.cwd
5495
- ).effective.state === "trusted";
5496
6198
  return {
5497
6199
  workspaceCwd: workspace.cwd,
5498
- primary: index === 0,
6200
+ primary: runtime?.primary ?? index === 0,
5499
6201
  trusted
5500
6202
  };
5501
6203
  });
@@ -5519,7 +6221,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5519
6221
  if (opts.channelSelection) {
5520
6222
  reserveChannelServicePidfile(opts.channelSelection);
5521
6223
  }
5522
- return await new Promise((resolve, reject) => {
6224
+ return await new Promise((resolve2, reject) => {
5523
6225
  const onListening = /* @__PURE__ */ __name((error) => {
5524
6226
  if (error) return;
5525
6227
  startup.listenerReadyAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -5674,7 +6376,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5674
6376
  daemonLog.error("runtime startup failed", error2);
5675
6377
  markRuntimeFailed(error2);
5676
6378
  if (closeServerAfterChannelWorkerStartupFailure && server.listening) {
5677
- runtimeFailureListenerClose = new Promise((resolve2) => {
6379
+ runtimeFailureListenerClose = new Promise((resolve3) => {
5678
6380
  server.close((closeErr) => {
5679
6381
  if (closeErr) {
5680
6382
  daemonLog.error(
@@ -5682,7 +6384,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5682
6384
  closeErr
5683
6385
  );
5684
6386
  }
5685
- resolve2();
6387
+ resolve3();
5686
6388
  });
5687
6389
  });
5688
6390
  server.closeAllConnections();
@@ -5715,9 +6417,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5715
6417
  }
5716
6418
  const runtimes = registry.list();
5717
6419
  if (runtimes.length <= 1 && operation === "initial") {
6420
+ const primary = registry.primary;
6421
+ if (!primary.trusted) {
6422
+ throw Object.assign(
6423
+ new Error(
6424
+ `Primary workspace "${primary.workspaceCwd}" is not trusted; cannot host channels.`
6425
+ ),
6426
+ { code: "untrusted_workspace" }
6427
+ );
6428
+ }
5718
6429
  return [
5719
6430
  {
5720
- workspaceCwd: registry.primary.workspaceCwd,
6431
+ workspaceCwd: primary.workspaceCwd,
5721
6432
  selection: channelSelection
5722
6433
  }
5723
6434
  ];
@@ -5728,7 +6439,12 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5728
6439
  const grouping = resolveChannelWorkspaceGroups({
5729
6440
  workspaces: runtimes.map((runtime) => {
5730
6441
  const settings = settingsRuntime.settings.loadSettings(
5731
- runtime.workspaceCwd
6442
+ runtime.workspaceCwd,
6443
+ {
6444
+ skipLoadEnvironment: true,
6445
+ skipWorkspaceSettings: !runtime.trusted,
6446
+ workspaceTrusted: runtime.trusted
6447
+ }
5732
6448
  );
5733
6449
  settingsByWorkspace.set(runtime.workspaceCwd, settings);
5734
6450
  return {
@@ -5899,7 +6615,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5899
6615
  );
5900
6616
  return;
5901
6617
  }
5902
- if (shouldPreheat) {
6618
+ if (shouldPreheat && runtime.bridge) {
5903
6619
  startBridgePreheat(runtime.bridge);
5904
6620
  }
5905
6621
  await completeRuntimeStartup(runtime.app);
@@ -5941,6 +6657,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5941
6657
  if (shuttingDown) {
5942
6658
  daemonLog.warn(`received ${signal} during drain \u2014 forcing exit`);
5943
6659
  try {
6660
+ managedProcessRegistry?.killAllSync();
5944
6661
  channelWorkerManager?.killAllSync();
5945
6662
  for (const runtimeBridge of getRuntimeBridgesForCleanup()) {
5946
6663
  runtimeBridge.killAllSync();
@@ -5968,7 +6685,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
5968
6685
  process.exit(runtimeStartupError === void 0 ? 0 : 1);
5969
6686
  } catch (err) {
5970
6687
  daemonLog.error("shutdown error", err instanceof Error ? err : null);
5971
- if (channelWorkerManager?.state().enabled) {
6688
+ if (err instanceof Error && retryableChannelWorkerShutdownErrors.has(err)) {
5972
6689
  daemonLog.error(
5973
6690
  "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)"
5974
6691
  );
@@ -6000,7 +6717,17 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6000
6717
  channelControlDraining = true;
6001
6718
  const initiallyMountedApp = runtimeApp ?? runtimeAppForCleanup;
6002
6719
  const initiallyMountedManagement = initiallyMountedApp?.locals?.["workspaceManagementHandle"];
6720
+ const initiallyMountedSessionMaintenance = initiallyMountedApp?.locals?.["sessionArchiveCoordinator"];
6003
6721
  const initialManagementWait = initiallyMountedManagement?.sealAndWait?.();
6722
+ const initialSessionMaintenanceWait = initiallyMountedSessionMaintenance?.sealMaintenanceAndWait?.();
6723
+ let processRegistryShutdown;
6724
+ const startProcessRegistryShutdown = /* @__PURE__ */ __name(() => {
6725
+ processRegistryShutdown ??= managedProcessRegistry?.shutdown().then(
6726
+ () => void 0,
6727
+ (error2) => error2 instanceof Error ? error2 : new Error(String(error2))
6728
+ );
6729
+ }, "startProcessRegistryShutdown");
6730
+ startProcessRegistryShutdown();
6004
6731
  clearRuntimeStartAfterHealthTimer();
6005
6732
  clearRuntimeStartFallbackTimer();
6006
6733
  cancelDeferredRuntimeStartup();
@@ -6029,6 +6756,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6029
6756
  const finalErr = err ?? bridgeShutdownError ?? channelWorkerShutdownError;
6030
6757
  const retryableChannelClose = channelWorkerShutdownError !== void 0 && channelWorkerManager?.state().enabled === true;
6031
6758
  if (retryableChannelClose) {
6759
+ const retryableError = channelWorkerShutdownError;
6032
6760
  await flushDaemonLogBounded(
6033
6761
  daemonLog,
6034
6762
  DAEMON_LOG_FORCED_FLUSH_BUDGET_MS
@@ -6036,13 +6764,18 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6036
6764
  closePromise = void 0;
6037
6765
  shuttingDown = false;
6038
6766
  channelControlDraining = false;
6039
- rej(finalErr);
6767
+ retryableChannelWorkerShutdownErrors.add(retryableError);
6768
+ rej(retryableError);
6040
6769
  return;
6041
6770
  }
6042
6771
  if (loggerPublished || loggerSignalOwned) {
6043
- writeDaemonLifecycleBestEffort(
6044
- () => daemonLog.info("daemon stopped")
6045
- );
6772
+ writeDaemonLifecycleBestEffort(() => {
6773
+ if (finalErr) {
6774
+ daemonLog.error("daemon shutdown incomplete", finalErr);
6775
+ } else {
6776
+ daemonLog.info("daemon stopped");
6777
+ }
6778
+ });
6046
6779
  await daemonLog.close();
6047
6780
  }
6048
6781
  if (finalErr) rej(finalErr);
@@ -6061,10 +6794,24 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6061
6794
  );
6062
6795
  const appForCleanup = runtimeApp ?? runtimeAppForCleanup;
6063
6796
  const workspaceManagementHandle = appForCleanup?.locals?.["workspaceManagementHandle"];
6797
+ const sessionMaintenance = appForCleanup?.locals?.["sessionArchiveCoordinator"];
6064
6798
  await initialManagementWait;
6065
6799
  if (workspaceManagementHandle !== initiallyMountedManagement) {
6066
6800
  await workspaceManagementHandle?.sealAndWait?.();
6067
6801
  }
6802
+ await initialSessionMaintenanceWait;
6803
+ if (sessionMaintenance !== initiallyMountedSessionMaintenance) {
6804
+ await sessionMaintenance?.sealMaintenanceAndWait?.();
6805
+ }
6806
+ stopTrustPolicyMonitor(appForCleanup);
6807
+ const waitForTrustPolicyIdle = appForCleanup?.locals?.["waitForTrustPolicyIdle"];
6808
+ await waitForTrustPolicyIdle?.().catch((err) => {
6809
+ daemonLog.error(
6810
+ "workspace trust reconciliation shutdown wait failed",
6811
+ err instanceof Error ? err : null
6812
+ );
6813
+ });
6814
+ startProcessRegistryShutdown();
6068
6815
  disposeRuntimeAppResources(appForCleanup);
6069
6816
  disposeDaemonEventLoopMonitor();
6070
6817
  if (channelWorkerManager) {
@@ -6115,6 +6862,14 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6115
6862
  bridgeShutdownError = err instanceof Error ? err : new Error(String(err));
6116
6863
  });
6117
6864
  }
6865
+ const processRegistryError = await processRegistryShutdown;
6866
+ if (processRegistryError) {
6867
+ daemonLog.error(
6868
+ "ACP process registry shutdown error",
6869
+ processRegistryError
6870
+ );
6871
+ bridgeShutdownError ??= processRegistryError;
6872
+ }
6118
6873
  }).finally(() => {
6119
6874
  if (!server.listening) {
6120
6875
  void (runtimeFailureListenerClose ?? Promise.resolve()).then(
@@ -6177,13 +6932,13 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6177
6932
  if (deps.resolveOnListen) {
6178
6933
  loggerPublished = true;
6179
6934
  loggerLifecycle.published();
6180
- resolve(handle);
6935
+ resolve2(handle);
6181
6936
  } else {
6182
6937
  void runtimeReady.then(
6183
6938
  () => {
6184
6939
  loggerPublished = true;
6185
6940
  loggerLifecycle.published();
6186
- resolve(handle);
6941
+ resolve2(handle);
6187
6942
  },
6188
6943
  (err) => {
6189
6944
  void handle.close().then(
@@ -6197,7 +6952,7 @@ async function runQwenServeImpl(optsIn, deps, loggerLifecycle) {
6197
6952
  closeErr instanceof Error ? closeErr : null
6198
6953
  )
6199
6954
  );
6200
- if (channelWorkerManager?.state().enabled) {
6955
+ if (closeErr instanceof Error && retryableChannelWorkerShutdownErrors.has(closeErr)) {
6201
6956
  writeDaemonLifecycleBestEffort(
6202
6957
  () => daemonLog.error(
6203
6958
  "runtime startup failed, but qwen serve remains alive to retain the channel service lease until worker exit is confirmed"