@qwen-code/qwen-code 0.22.2 → 0.22.3-nightly.20260831.3a0c4c6108

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 (480) hide show
  1. package/bundled/computer-use/SKILL.md +3 -3
  2. package/bundled/qc-helper/docs/common-workflow.md +32 -0
  3. package/bundled/qc-helper/docs/configuration/auth.md +6 -6
  4. package/bundled/qc-helper/docs/configuration/model-providers.md +4 -2
  5. package/bundled/qc-helper/docs/configuration/settings.md +47 -44
  6. package/bundled/qc-helper/docs/extension/introduction.md +1 -1
  7. package/bundled/qc-helper/docs/features/approval-mode.md +3 -0
  8. package/bundled/qc-helper/docs/features/auto-mode.md +34 -17
  9. package/bundled/qc-helper/docs/features/channels/dws.md +2 -0
  10. package/bundled/qc-helper/docs/features/channels/overview.md +36 -3
  11. package/bundled/qc-helper/docs/features/code-review.md +5 -5
  12. package/bundled/qc-helper/docs/features/commands.md +41 -0
  13. package/bundled/qc-helper/docs/features/computer-use.md +2 -2
  14. package/bundled/qc-helper/docs/features/hooks.md +6 -2
  15. package/bundled/qc-helper/docs/features/memory.md +1 -0
  16. package/bundled/qc-helper/docs/features/tool-use-summaries.md +1 -1
  17. package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +17 -7
  18. package/bundled/qc-helper/docs/qwen-serve.md +59 -55
  19. package/bundled/review/SKILL.md +90 -31
  20. package/bundled/review/references/persistence.md +7 -3
  21. package/bundled/review/references/posting.md +11 -5
  22. package/chunks/MaxSizedBox-IHRTWGSY.js +115 -0
  23. package/chunks/{StandaloneSessionPicker-AVLI6VJP.js → StandaloneSessionPicker-TLVWVTJ7.js} +88 -85
  24. package/chunks/{acp-startup-profiler-GNYAL6LI.js → acp-startup-profiler-M4X5F3VK.js} +2 -2
  25. package/chunks/{acpAgent-MXEAN54C.js → acpAgent-7I5LLPP3.js} +1563 -407
  26. package/chunks/agent-4Z4NTJXD.js +99 -0
  27. package/chunks/agent-headless-TVUJXQWU.js +89 -0
  28. package/chunks/{anthropicContentGenerator-HGMBACVE.js → anthropicContentGenerator-VSSPG7XV.js} +84 -55
  29. package/chunks/{artifact-tool-5YT4QF7Y.js → artifact-tool-TEYW6I4A.js} +11 -3
  30. package/chunks/{askUserQuestion-4SWJY65V.js → askUserQuestion-PYNBWV63.js} +45 -7
  31. package/chunks/bridge-EVURP4NO.js +122 -0
  32. package/chunks/{ca-7HPYOYSZ.js → ca-BNU7YNDE.js} +3 -0
  33. package/chunks/{channel-management-service-X4AZ6IXX.js → channel-management-service-IDBNYSFW.js} +6 -6
  34. package/chunks/channel-settings-store-MZNXRKVI.js +125 -0
  35. package/chunks/{channel-worker-group-27HMGD5S.js → channel-worker-group-ZLP5SJHT.js} +7 -7
  36. package/chunks/{channel-worker-manager-QEGX646Z.js → channel-worker-manager-FG5377T2.js} +7 -7
  37. package/chunks/{channel-worker-supervisor-UEW2WWCC.js → channel-worker-supervisor-HDVE4ADS.js} +4 -4
  38. package/chunks/{chunk-PPKZ7JOE.js → chunk-22UH7VTP.js} +1 -1
  39. package/chunks/chunk-24FVUD5P.js +49 -0
  40. package/chunks/{chunk-CMHFCLBU.js → chunk-26SIKQIC.js} +1 -1
  41. package/chunks/{chunk-5PA6UEYA.js → chunk-3452WXOK.js} +4 -1
  42. package/chunks/{chunk-SFPGAQUL.js → chunk-373DQUVA.js} +72 -31
  43. package/chunks/{chunk-H2WDGQ6D.js → chunk-3AKCBZVW.js} +3 -3
  44. package/chunks/{chunk-LXIBMVRN.js → chunk-3CZGSTZX.js} +15 -9
  45. package/chunks/{chunk-JVPFTDBK.js → chunk-3EGEBDTW.js} +1 -1
  46. package/chunks/{chunk-K2NQPH5D.js → chunk-3NQCZMUB.js} +79 -5
  47. package/chunks/{chunk-E7REAOTN.js → chunk-47ECGEJC.js} +4 -0
  48. package/chunks/{chunk-WKK5BQNP.js → chunk-4P7PPAHN.js} +45 -421
  49. package/chunks/chunk-4VQBQLIZ.js +293 -0
  50. package/chunks/{chunk-4JWNNLPT.js → chunk-5FGWVPCM.js} +4 -4
  51. package/chunks/{chunk-ZFKOCECU.js → chunk-5ICKESC3.js} +2 -2
  52. package/chunks/{chunk-3I6UTTDX.js → chunk-67AY5D3M.js} +20 -20
  53. package/chunks/chunk-6HUXPLB5.js +110 -0
  54. package/chunks/{chunk-BRVWYMKV.js → chunk-6MBXY6WM.js} +1 -1
  55. package/chunks/{chunk-6LFTG244.js → chunk-6NWPR2EB.js} +19 -9
  56. package/chunks/chunk-6OO7QEWV.js +2581 -0
  57. package/chunks/{chunk-TWSKM647.js → chunk-6VHIWUJP.js} +1 -1
  58. package/chunks/{chunk-RJC5EIKY.js → chunk-6YXNJXQW.js} +7 -5
  59. package/chunks/{chunk-TPI7O7HR.js → chunk-7DDTI7Q3.js} +1 -1
  60. package/chunks/{chunk-KGJGEEVR.js → chunk-7FA2II6K.js} +10 -1
  61. package/chunks/chunk-7J6OTNGO.js +424 -0
  62. package/chunks/{chunk-NIFYWDYN.js → chunk-7TBU7PU2.js} +1 -1
  63. package/chunks/{chunk-3FDFA4MZ.js → chunk-7XICSE62.js} +3 -3
  64. package/chunks/{chunk-V2NDP3I4.js → chunk-7XL4WRXM.js} +2 -2
  65. package/chunks/{chunk-F7TNAPZ4.js → chunk-AAX236AR.js} +45 -11
  66. package/chunks/{chunk-T32W2JHI.js → chunk-ACZ4YRYK.js} +6 -6
  67. package/chunks/chunk-ADJD4LZF.js +210 -0
  68. package/chunks/{chunk-JWALNCLT.js → chunk-AF3QB6OL.js} +1 -1
  69. package/chunks/{chunk-P2SU6ZTI.js → chunk-AI35S34R.js} +3 -3
  70. package/chunks/{chunk-OIP7C4FE.js → chunk-AKNQMSL2.js} +5 -5
  71. package/chunks/{chunk-6CGL7E7G.js → chunk-AN3KFCNH.js} +2 -2
  72. package/chunks/{chunk-ABS25QER.js → chunk-ANVG3BVV.js} +1 -1
  73. package/chunks/chunk-AYYKUUKP.js +972 -0
  74. package/chunks/chunk-B2RIIK3K.js +346 -0
  75. package/chunks/{chunk-F5SZP77N.js → chunk-BBYTY46C.js} +153 -112
  76. package/chunks/{chunk-XRSOI3DL.js → chunk-BE5FGT5Z.js} +1 -1
  77. package/chunks/{chunk-BGXZBI5B.js → chunk-BHTYRHJF.js} +3 -2
  78. package/chunks/{chunk-CSMI4FP5.js → chunk-BSJOBW4U.js} +1 -1
  79. package/chunks/{chunk-Z7TGYN5F.js → chunk-BXNKREX7.js} +3 -3
  80. package/chunks/{chunk-4MQEPP3Y.js → chunk-BY24DZ4J.js} +5 -119
  81. package/chunks/{chunk-5XBFCMWD.js → chunk-CAZADEU7.js} +17 -9
  82. package/chunks/chunk-CHEIIBT3.js +40 -0
  83. package/chunks/{chunk-BBWV7ONL.js → chunk-CM4F4JBB.js} +6 -6
  84. package/chunks/{chunk-CAJTKR6W.js → chunk-D7D3HSYQ.js} +6 -5
  85. package/chunks/{chunk-3DXFGHAJ.js → chunk-DBTMP3P4.js} +213 -185
  86. package/chunks/chunk-DJBQCO2E.js +842 -0
  87. package/chunks/{chunk-RXFQM6FQ.js → chunk-DMEUXLSS.js} +16 -1
  88. package/chunks/{chunk-3AFMQUTI.js → chunk-E4JNFXNI.js} +3 -3
  89. package/chunks/{chunk-UHQFIS7N.js → chunk-EAHOJF6V.js} +28 -4
  90. package/chunks/{chunk-OIVXBW3W.js → chunk-ED7DD7MV.js} +3 -3
  91. package/chunks/{chunk-6DIGWMGT.js → chunk-EIJT2PQ6.js} +2 -2
  92. package/chunks/{chunk-XQFT3QUF.js → chunk-ENYUKMFK.js} +1 -1
  93. package/chunks/{chunk-CQH5KTKC.js → chunk-ERHAMGAA.js} +1 -1
  94. package/chunks/{chunk-IOPCFOTF.js → chunk-ERRJA23L.js} +3 -3
  95. package/chunks/{chunk-LDP5OD6N.js → chunk-EU2B4P3D.js} +12 -12
  96. package/chunks/{chunk-W5MJJ2V7.js → chunk-FHPYRXRH.js} +1 -1
  97. package/chunks/{chunk-IZIVM7LZ.js → chunk-FIWZOMBF.js} +3 -3
  98. package/chunks/{chunk-4HV6HH33.js → chunk-FPMQT2YY.js} +9 -9
  99. package/chunks/{chunk-Z7VOMGDC.js → chunk-FTJMWDND.js} +0 -24
  100. package/chunks/{chunk-L2M46FP5.js → chunk-FXUSWLBF.js} +225 -12
  101. package/chunks/{chunk-VVW4ZNFY.js → chunk-GB4UKWY5.js} +16 -8
  102. package/chunks/{chunk-PKAYJDB3.js → chunk-GCUR24KK.js} +22 -4
  103. package/chunks/{chunk-DIMEPKCW.js → chunk-GDXSXL3H.js} +11 -1
  104. package/chunks/{chunk-7JPW6IYH.js → chunk-GN422P4J.js} +1 -1
  105. package/chunks/{chunk-66KDY3LV.js → chunk-GS7XT345.js} +3 -3
  106. package/chunks/{chunk-PFCQ62V4.js → chunk-H2A2GJGL.js} +6 -6
  107. package/chunks/{chunk-Z7FLBQPR.js → chunk-H5GPPDGY.js} +8 -8
  108. package/chunks/{chunk-CPGJJJLU.js → chunk-HDMKCJHI.js} +1 -1
  109. package/chunks/{chunk-6PJOTWAN.js → chunk-HT5S5TRQ.js} +1 -1
  110. package/chunks/{chunk-Z4X5MTRT.js → chunk-HWVUSYSN.js} +5 -12
  111. package/chunks/{chunk-V4QXXQJ2.js → chunk-I75VKFCJ.js} +4 -4
  112. package/chunks/{chunk-NU7RKEZR.js → chunk-IBMUI5EV.js} +3 -3
  113. package/chunks/{chunk-4J657AJR.js → chunk-ID33ZRWH.js} +42 -42
  114. package/chunks/{chunk-R4PMVSR5.js → chunk-IIFL7QDN.js} +30 -192
  115. package/chunks/{chunk-MQM5PJML.js → chunk-IVUWTA2D.js} +1 -1
  116. package/chunks/{chunk-E55H6BZ7.js → chunk-IXEZHTDR.js} +1616 -151
  117. package/chunks/{chunk-XF63PKEN.js → chunk-IXHV5MIC.js} +1 -1
  118. package/chunks/{chunk-JHS74YAB.js → chunk-J4Y3QJHF.js} +3 -1
  119. package/chunks/{chunk-MIIVI25Q.js → chunk-JDIO45X7.js} +3 -3
  120. package/chunks/{chunk-QFCDF5PL.js → chunk-JHN7UIDW.js} +1 -1
  121. package/chunks/{chunk-FDY5RMGH.js → chunk-JLSZT354.js} +2 -2
  122. package/chunks/chunk-JMRE4WJQ.js +1849 -0
  123. package/chunks/{chunk-FY76G3G5.js → chunk-JOTYTYYW.js} +6 -6
  124. package/chunks/{chunk-TRZTNIQ6.js → chunk-JOWQD4LO.js} +3 -3
  125. package/chunks/{chunk-KEKZFOL6.js → chunk-JPKTAQS3.js} +1 -1
  126. package/chunks/chunk-JS73NNWF.js +30 -0
  127. package/chunks/chunk-JX6XHPTX.js +26 -0
  128. package/chunks/{chunk-5JTIYALA.js → chunk-JZWOCUZ3.js} +1 -1
  129. package/chunks/{chunk-3JGZSIDA.js → chunk-KFN2IZYR.js} +3 -3
  130. package/chunks/{chunk-23RFD54N.js → chunk-KHP66DFN.js} +1 -1
  131. package/chunks/{chunk-AGR5UROZ.js → chunk-KUDI54QQ.js} +23 -33
  132. package/chunks/{chunk-3SGB2UHX.js → chunk-L2OKAIUK.js} +28 -16
  133. package/chunks/{chunk-BXDAPVQU.js → chunk-L6CUJZDG.js} +28 -4
  134. package/chunks/chunk-LAUEEBDL.js +277 -0
  135. package/chunks/{chunk-BNMF3K5X.js → chunk-LFAR7CPW.js} +55 -39
  136. package/chunks/{chunk-Y3QL45LS.js → chunk-LKODFJRD.js} +9 -9
  137. package/chunks/{chunk-BWORX6FA.js → chunk-LMMHS3RS.js} +1 -1
  138. package/chunks/{chunk-UTLCH2FK.js → chunk-LYSZVCCD.js} +10 -7
  139. package/chunks/{chunk-F6FV3C5K.js → chunk-MBZ5ORJB.js} +264 -283
  140. package/chunks/{chunk-L6YT5H34.js → chunk-MJBHSZEJ.js} +5 -5
  141. package/chunks/{chunk-B7CDU2SL.js → chunk-MOF6VZN2.js} +18 -21
  142. package/chunks/{chunk-6LFJEACX.js → chunk-MZ5A5PQW.js} +7 -7
  143. package/chunks/chunk-MZYWNU66.js +149 -0
  144. package/chunks/{chunk-2TNL5KPM.js → chunk-N4QWUPDM.js} +7 -0
  145. package/chunks/{chunk-5O72BNDD.js → chunk-ND7TQQPE.js} +9 -9
  146. package/chunks/{chunk-QP4C6WCE.js → chunk-NGKLMNWN.js} +3 -3
  147. package/chunks/{chunk-JSC3H3TD.js → chunk-NT5XIL5H.js} +46 -18
  148. package/chunks/{chunk-KUX5D6DK.js → chunk-NT7LXVV5.js} +11010 -11138
  149. package/chunks/{chunk-PDQGMSZK.js → chunk-ODZF64DM.js} +1 -1
  150. package/chunks/{chunk-FBSSIAAQ.js → chunk-OE5AQVNB.js} +8 -8
  151. package/chunks/chunk-OHU2H5CS.js +130 -0
  152. package/chunks/{chunk-2K6ORIHJ.js → chunk-OKMDOATP.js} +13 -13
  153. package/chunks/{chunk-JB4JIVTJ.js → chunk-OKTNXDVO.js} +1 -1
  154. package/chunks/{chunk-XDLEZ5HX.js → chunk-OQYXJK2V.js} +1 -1
  155. package/chunks/{chunk-EFUM7RVY.js → chunk-OSTQZIOY.js} +944 -18
  156. package/chunks/{chunk-VQUGEVGR.js → chunk-OTTNXUT5.js} +1 -1
  157. package/chunks/{chunk-T3WXYEZ4.js → chunk-PB7JBAHF.js} +53 -54
  158. package/chunks/{chunk-WAOIHTJS.js → chunk-PDAKFU7M.js} +1 -1
  159. package/chunks/{chunk-43GGFFLY.js → chunk-PDXYZBBQ.js} +3 -3
  160. package/chunks/{chunk-4CMJKUND.js → chunk-PNIGAVY6.js} +67 -2
  161. package/chunks/{chunk-SAH4BD2J.js → chunk-PQEISIKS.js} +67 -0
  162. package/chunks/{chunk-4CDSK5AZ.js → chunk-PWR2NQBS.js} +6 -6
  163. package/chunks/{chunk-YTDVNSUQ.js → chunk-QAK5475D.js} +1 -1
  164. package/chunks/{chunk-IJKTMLBE.js → chunk-QE7DTCLX.js} +1 -1
  165. package/chunks/{chunk-SMPR7SPO.js → chunk-QJNDUTOL.js} +45 -239
  166. package/chunks/{chunk-C6K43ZDE.js → chunk-QTMPM6RC.js} +16 -10
  167. package/chunks/{chunk-P5GGM4KS.js → chunk-RAEEQEC5.js} +5 -5
  168. package/chunks/{chunk-XDFHY4R3.js → chunk-RGEV5AUD.js} +242 -14
  169. package/chunks/{chunk-M6FOJXW3.js → chunk-RKW36UWC.js} +1 -1
  170. package/chunks/{chunk-RIEFGNTP.js → chunk-RLSPPTWH.js} +5119 -683
  171. package/chunks/{chunk-PDMJ3KGS.js → chunk-RT4QNQ5P.js} +3 -3
  172. package/chunks/{chunk-SJ3ZUWFK.js → chunk-RVCGAHC7.js} +4 -26
  173. package/chunks/{chunk-77RG5SFQ.js → chunk-RY7DL5IF.js} +11 -6
  174. package/chunks/{chunk-4FTKQNWJ.js → chunk-S2T7H5MI.js} +182 -3
  175. package/chunks/{chunk-EOGELB3H.js → chunk-SDCHI64N.js} +4 -4
  176. package/chunks/{chunk-EKSCLBBF.js → chunk-SMJYTKTB.js} +23 -5
  177. package/chunks/{chunk-MZS7GEC7.js → chunk-SMRDCANI.js} +1 -1
  178. package/chunks/{chunk-43UYNAWX.js → chunk-T3TL6S3B.js} +4 -4
  179. package/chunks/{chunk-4K7NQDCG.js → chunk-T4EFG2P5.js} +18 -9
  180. package/chunks/{chunk-IK5BW3CS.js → chunk-T4RMUTTT.js} +16 -5
  181. package/chunks/{chunk-L6BZRIUL.js → chunk-TBJ3SNS3.js} +183 -5
  182. package/chunks/{chunk-CCBZDVUA.js → chunk-TNMOFNT4.js} +133 -122
  183. package/chunks/{chunk-Y6LSMB6J.js → chunk-TV7BJ7TX.js} +1 -1
  184. package/chunks/{chunk-G34IR3D6.js → chunk-U5RTYI7D.js} +102 -146
  185. package/chunks/{chunk-TTX2JUE6.js → chunk-U6D2PPMN.js} +1 -1
  186. package/chunks/{chunk-D5LUXLUH.js → chunk-UJ4DUYIH.js} +18 -4
  187. package/chunks/{chunk-A7YP63XN.js → chunk-UKB2TZAO.js} +5 -5
  188. package/chunks/{chunk-VTHREBQM.js → chunk-UKYXYWI2.js} +2 -2
  189. package/chunks/{chunk-2NYCN6F2.js → chunk-UVYKCRJZ.js} +46 -29
  190. package/chunks/{chunk-HVEYF6VT.js → chunk-UXEW7TQS.js} +2 -2
  191. package/chunks/{chunk-HVQ3B7FF.js → chunk-V4HN35IF.js} +44 -7
  192. package/chunks/chunk-VGHZT6JR.js +51 -0
  193. package/chunks/{chunk-V5J4J5TP.js → chunk-VYSZUQGU.js} +2 -20
  194. package/chunks/{chunk-6IUNAPLR.js → chunk-W4BDHLRT.js} +3 -3
  195. package/chunks/{chunk-Q26AYA62.js → chunk-W7KWB6AH.js} +7 -4
  196. package/chunks/chunk-WLEYH7CD.js +332 -0
  197. package/chunks/{chunk-RU7BK6B3.js → chunk-X7C7KFWA.js} +2 -2
  198. package/chunks/{chunk-YRLW2MSX.js → chunk-XBVNNDPK.js} +11 -4
  199. package/chunks/{chunk-BFPESSTR.js → chunk-XEAAO654.js} +1 -1
  200. package/chunks/{chunk-JU4EEXC7.js → chunk-XLENZQXH.js} +2 -2
  201. package/chunks/{chunk-JSHHYW6T.js → chunk-XPDKSOVW.js} +69 -64
  202. package/chunks/chunk-YDQ4OCDK.js +1222 -0
  203. package/chunks/{chunk-ZU4UDIWX.js → chunk-YKADANK6.js} +6 -7
  204. package/chunks/{chunk-JCQD3INC.js → chunk-YNG7XAJU.js} +3 -3
  205. package/chunks/{chunk-O2UN57NX.js → chunk-YOFULAHO.js} +19 -2
  206. package/chunks/{chunk-BAJKAAOY.js → chunk-YOMKOM7E.js} +4892 -1504
  207. package/chunks/{chunk-ERFDKH32.js → chunk-YPISTYEI.js} +8 -7
  208. package/chunks/{chunk-TGWAQ5RB.js → chunk-ZBDYI7VM.js} +6900 -6882
  209. package/chunks/{chunk-OZ6KS6KW.js → chunk-ZGCKTAL5.js} +6 -1
  210. package/chunks/chunk-ZHO2CW6D.js +205 -0
  211. package/chunks/{chunk-DZWPESIF.js → chunk-ZQ3FKEWA.js} +3 -3
  212. package/chunks/{chunk-7EQQR46F.js → chunk-ZVP4PWBU.js} +1 -1
  213. package/chunks/{chunk-7UYV53BC.js → chunk-ZYPJ7HVZ.js} +1 -1
  214. package/chunks/config-utils-NNUPVGEC.js +118 -0
  215. package/chunks/contextCommand-S3TPCDM5.js +111 -0
  216. package/chunks/{core-runtime-677KFX6Q.js → core-runtime-NASPCSQX.js} +66 -63
  217. package/chunks/{create-sub-session-23ITIELI.js → create-sub-session-36TNCHCP.js} +3 -3
  218. package/chunks/{create-sub-session-JKZAYZX7.js → create-sub-session-DS4BJLYZ.js} +97 -68
  219. package/chunks/{cron-create-KJ4IY6PP.js → cron-create-QXHTYUTO.js} +4 -4
  220. package/chunks/{cron-delete-MBLQCAYY.js → cron-delete-WV2BM42M.js} +4 -4
  221. package/chunks/{cron-list-DWH2PQ47.js → cron-list-7KVNBLZ7.js} +4 -4
  222. package/chunks/{daemon-MJQUO7RA.js → daemon-UCVUHPJD.js} +723 -90
  223. package/chunks/{daemon-git-worktree-guard-6MVAAZZZ.js → daemon-git-worktree-guard-ATXVQPS3.js} +63 -60
  224. package/chunks/daemon-status-provider-UI3GBTMO.js +121 -0
  225. package/chunks/daemon-trust-policy-SUCBJ2CA.js +117 -0
  226. package/chunks/{daemon-trust-policy-monitor-B5U6TQX5.js → daemon-trust-policy-monitor-3LM5RQNS.js} +71 -68
  227. package/chunks/{de-X6HLSIFE.js → de-T4BLOKEC.js} +3 -0
  228. package/chunks/deferred-core-runtime-SCOJLVYG.js +119 -0
  229. package/chunks/{display-image-BE7I6ZB6.js → display-image-Z4VBQDEJ.js} +5 -5
  230. package/chunks/{dist-TJUDJTCB.js → dist-5423MG3D.js} +411 -91
  231. package/chunks/{dist-ILDBUWDB.js → dist-7WDZYMWV.js} +43 -25
  232. package/chunks/{dist-ZBVOXSKF.js → dist-FLJLHASF.js} +219 -121
  233. package/chunks/{dist-QODVOVWI.js → dist-GPSRNVVP.js} +43 -35
  234. package/chunks/{dist-DJBNNPLN.js → dist-LY66XNUL.js} +10 -3
  235. package/chunks/{dist-7CKN54NL.js → dist-S3BKCTWF.js} +205 -89
  236. package/chunks/{dist-UQUFZDIY.js → dist-SDKHGH5O.js} +41 -20
  237. package/chunks/{dist-4Q7NTUNB.js → dist-WAUO5OMN.js} +46 -22
  238. package/chunks/{dist-SATKXKUR.js → dist-WIVVPE7M.js} +28 -14
  239. package/chunks/earlyInputCapture-INWJ2STR.js +112 -0
  240. package/chunks/{edit-BSV6YRVW.js → edit-B7ZRRGAE.js} +51 -49
  241. package/chunks/{en-YLXBXM4Z.js → en-E4AYTX6H.js} +3 -0
  242. package/chunks/{enter-worktree-MQXFFPKM.js → enter-worktree-SPZHEETQ.js} +7 -7
  243. package/chunks/{enterPlanMode-PKNF35FE.js → enterPlanMode-S554IKJ2.js} +55 -53
  244. package/chunks/environment-25ADH4Y6.js +134 -0
  245. package/chunks/errors-G2I6LFTW.js +118 -0
  246. package/chunks/{exit-worktree-L344UY7K.js → exit-worktree-AWUXAMAM.js} +7 -7
  247. package/chunks/exitPlanMode-ZFH4OYPM.js +87 -0
  248. package/chunks/{fast-path-773PV7PU.js → fast-path-WZHVZ2ER.js} +8 -7
  249. package/chunks/{fast-path-settings-XMFBYFUH.js → fast-path-settings-NILM6QZL.js} +3 -3
  250. package/chunks/{fr-FTZWF462.js → fr-BGHGYX6A.js} +3 -0
  251. package/chunks/{glob-CZHOWUEA.js → glob-UOVDMBUP.js} +50 -48
  252. package/chunks/{goal-tools-YZQJXTGH.js → goal-tools-7TNK5ZHC.js} +5 -4
  253. package/chunks/{grep-5GPICQBU.js → grep-LHYJ5V2N.js} +9 -7
  254. package/chunks/handleAutoUpdate-4MZ45DZY.js +114 -0
  255. package/chunks/i18n-KWUEI4DS.js +129 -0
  256. package/chunks/{image-gen-HAYOEQ4O.js → image-gen-YZDVO5YS.js} +8 -10
  257. package/chunks/initializer-2NBROGMG.js +118 -0
  258. package/chunks/installationInfo-YKUSY3ZB.js +112 -0
  259. package/chunks/{ja-2GL5FKYJ.js → ja-G3FTD5XE.js} +3 -0
  260. package/chunks/{keychain-token-storage-37XPR34V.js → keychain-token-storage-REZVMJA6.js} +2 -2
  261. package/chunks/list-W2WV3COM.js +121 -0
  262. package/chunks/list-agents-PMVMHNY7.js +128 -0
  263. package/chunks/{gemini-IP4FJAP5.js → llm-NPPHLIJI.js} +162 -133
  264. package/chunks/{geminiContentGenerator-PUNEBWJW.js → llm-content-generator-YK3WN6XW.js} +29 -29
  265. package/chunks/loadedSettingsAdapter-2P7DFWUR.js +115 -0
  266. package/chunks/{loggingContentGenerator-2GGZNGLG.js → loggingContentGenerator-QYYYGU6V.js} +318 -35
  267. package/chunks/{loop-wakeup-XJFONSQ7.js → loop-wakeup-EBM4F5MZ.js} +5 -5
  268. package/chunks/{ls-3VAT2J7A.js → ls-F6TRX3DD.js} +4 -4
  269. package/chunks/{lsp-5W7IRUBH.js → lsp-QYTOS2FI.js} +2 -2
  270. package/chunks/{managed-npm-update-5TEV2E3J.js → managed-npm-update-UMC4NBWW.js} +64 -61
  271. package/chunks/mcp-OFI6XDP2.js +115 -0
  272. package/chunks/{monitor-FI7PY36Z.js → monitor-QX3BM3JY.js} +50 -48
  273. package/chunks/nonInteractiveCli-NVRMD5MN.js +193 -0
  274. package/chunks/{notebook-edit-TPGMGBST.js → notebook-edit-AAILDPSV.js} +51 -49
  275. package/chunks/{open-with-auth-4UI3KHUR.js → open-with-auth-D6JD6LDS.js} +4 -4
  276. package/chunks/{openaiContentGenerator-SUCYANUZ.js → openaiContentGenerator-53PB3CMN.js} +27 -29
  277. package/chunks/pidfile-5ACKG2LI.js +116 -0
  278. package/chunks/process-registry-OAEG6WGC.js +662 -0
  279. package/chunks/{processUtils-IQZBYWSB.js → processUtils-2BCDO3DZ.js} +2 -2
  280. package/chunks/prompt-terminal-ledger-3RKW73A2.js +110 -0
  281. package/chunks/{pt-XN2YWJVM.js → pt-D73IFYT7.js} +3 -0
  282. package/chunks/{qwenContentGenerator-J4TXFGJT.js → qwenContentGenerator-N4LLWDPH.js} +56 -54
  283. package/chunks/{qwenOAuth2-RF33DNZW.js → qwenOAuth2-7AOCKSOQ.js} +7 -9
  284. package/chunks/{read-file-QE2B5FTX.js → read-file-DPAKXHYE.js} +13 -13
  285. package/chunks/{read-mcp-resource-XD257PGJ.js → read-mcp-resource-R4NO75DW.js} +2 -2
  286. package/chunks/{record-artifact-RZGZBENU.js → record-artifact-2EAYLAL5.js} +4 -4
  287. package/chunks/{report-findings-Q3SYKKW5.js → report-findings-Y4MSHDS3.js} +9 -5
  288. package/chunks/{request-shutdown-BCLA3JV2.js → request-shutdown-DWRMGTMB.js} +8 -7
  289. package/chunks/resumeHistoryUtils-3JQORXAK.js +123 -0
  290. package/chunks/ripGrep-AHF5QCI7.js +39 -0
  291. package/chunks/{ru-OLTMFJEW.js → ru-QMISLKRH.js} +3 -0
  292. package/chunks/{run-qwen-serve-TPHZMSXJ.js → run-qwen-serve-3LKV7KDC.js} +728 -256
  293. package/chunks/runtime-66F4W3IA.js +153 -0
  294. package/chunks/scheduled-tasks-2NVKS5Q2.js +132 -0
  295. package/chunks/scheduler-JNV7T3ZO.js +127 -0
  296. package/chunks/{sdk-exporters-http-KCJ4ZFG7.js → sdk-exporters-http-MFIWD23D.js} +2 -2
  297. package/chunks/{sdk-impl-HLSEDAEP.js → sdk-impl-2RXJ4Q6X.js} +11 -5
  298. package/chunks/send-message-WPZRCJOB.js +442 -0
  299. package/chunks/serve-GP2UNRP7.js +123 -0
  300. package/chunks/{server-DFUSSSHI.js → server-7W6C3SOW.js} +5233 -3623
  301. package/chunks/{session-3TEHNENZ.js → session-PZLBAQGG.js} +125 -118
  302. package/chunks/session-pr-refresh-OIVL3U3Z.js +367 -0
  303. package/chunks/{settings-VOZYKLTT.js → settings-ZOHIQWYK.js} +70 -67
  304. package/chunks/shell-FWZT6IUR.js +97 -0
  305. package/chunks/{skill-FEOKFX26.js → skill-RTQC2YGA.js} +121 -65
  306. package/chunks/skill-settings-AKMIXFSJ.js +123 -0
  307. package/chunks/spawnChannel-ZP23JL6O.js +116 -0
  308. package/chunks/standalone-update-P2Q5H4ZU.js +123 -0
  309. package/chunks/{startInteractiveUI-WHJPFOGH.js → startInteractiveUI-NSA6QPQZ.js} +2018 -1526
  310. package/chunks/{stdioHelpers-7A2EE64Z.js → stdioHelpers-AY6XCDY2.js} +3 -1
  311. package/chunks/{syntheticOutput-ML43GEFN.js → syntheticOutput-5URSQLIS.js} +3 -3
  312. package/chunks/{task-create-TMSV7RD5.js → task-create-3EXVDG3G.js} +12 -12
  313. package/chunks/{task-list-W55RBFRX.js → task-list-PIBYNSE7.js} +5 -6
  314. package/chunks/{task-stop-CXEH5L2D.js → task-stop-IV3BYWJC.js} +2 -2
  315. package/chunks/{task-update-N536I4GQ.js → task-update-H5BPDS5Y.js} +13 -14
  316. package/chunks/{team-create-QYSWCYCL.js → team-create-53T42W37.js} +56 -55
  317. package/chunks/{team-delete-FJRFX33M.js → team-delete-X3WPELS6.js} +25 -8
  318. package/chunks/{team-plan-approval-P7DAD644.js → team-plan-approval-D45ZC5OE.js} +50 -48
  319. package/chunks/terminal-image-renderer-FCRUWT6C.js +121 -0
  320. package/chunks/theme-manager-MHNPEDP7.js +107 -0
  321. package/chunks/{todoWrite-WDJNQEMW.js → todoWrite-A5IOZZ3P.js} +4 -4
  322. package/chunks/{tool-search-F2EMIAPV.js → tool-search-6RPBGGUX.js} +27 -23
  323. package/chunks/total-session-admission-MGV56XDK.js +117 -0
  324. package/chunks/trustedFolders-QJYEFMTU.js +127 -0
  325. package/chunks/{types-WYCFCEHR.js → types-HKLPXZB3.js} +1 -3
  326. package/chunks/{update-relaunch-4GF3OXMB.js → update-relaunch-ZDMQX63C.js} +6 -6
  327. package/chunks/updateCheck-4QZWCGP6.js +123 -0
  328. package/chunks/useAutoAcceptIndicator-DLIQN256.js +125 -0
  329. package/chunks/{validateNonInterActiveAuth-BPPA563H.js → validateNonInterActiveAuth-HGTG7AEK.js} +114 -107
  330. package/chunks/{version-ANP4TS6O.js → version-CPAZMC4B.js} +1 -1
  331. package/chunks/{web-fetch-QJADSAH3.js → web-fetch-N4K5M3M4.js} +16 -18
  332. package/chunks/{web-search-7TTQKEKM.js → web-search-4VZKM5SF.js} +9 -11
  333. package/chunks/{web-shell-static-A6QMUNNV.js → web-shell-static-PW7OEDQO.js} +3 -2
  334. package/chunks/{workflow-5XN6XSOT.js → workflow-2ALQKTHG.js} +229 -146
  335. package/chunks/workspace-providers-status-5JM4CB6R.js +119 -0
  336. package/chunks/{workspace-registration-store-XKVW2YVH.js → workspace-registration-store-RNMFVCH7.js} +2 -1
  337. package/chunks/workspace-registry-6EULAPZC.js +126 -0
  338. package/chunks/workspace-runtime-coordinator-IRI2DRCJ.js +127 -0
  339. package/chunks/workspace-service-SETHN4WE.js +131 -0
  340. package/chunks/workspace-skills-status-4D4EUEQU.js +118 -0
  341. package/chunks/{workspace-trust-reconciler-KLGOB53D.js → workspace-trust-reconciler-4LR3CDL4.js} +77 -76
  342. package/chunks/write-file-45GWPSOI.js +92 -0
  343. package/chunks/{zh-UNY63FR3.js → zh-2BQ7P6OD.js} +3 -0
  344. package/chunks/{zh-TW-RPTMRTHG.js → zh-TW-UFXRZTXX.js} +3 -0
  345. package/chunks/{zoom-image-6ASG6J4C.js → zoom-image-K6IQUKRC.js} +13 -13
  346. package/cli.js +129 -92
  347. package/locales/ca.js +6 -0
  348. package/locales/de.js +6 -0
  349. package/locales/en.js +6 -0
  350. package/locales/fr.js +6 -0
  351. package/locales/ja.js +6 -0
  352. package/locales/pt.js +6 -0
  353. package/locales/ru.js +6 -0
  354. package/locales/zh-TW.js +6 -0
  355. package/locales/zh.js +6 -0
  356. package/package.json +3 -3
  357. package/web-shell/assets/{abnfDiagram-VCTEODGH-uS-vtfs3.js → abnfDiagram-VCTEODGH-C80OZcPP.js} +1 -1
  358. package/web-shell/assets/{arc-BSTnk5pu.js → arc-AUqStYgf.js} +1 -1
  359. package/web-shell/assets/{architectureDiagram-5GKGNRK7-DCMyiqzy.js → architectureDiagram-5GKGNRK7-CQYOdYla.js} +1 -1
  360. package/web-shell/assets/{blockDiagram-NRAW4CY4-C7_gt0r1.js → blockDiagram-NRAW4CY4-lYKlFysy.js} +1 -1
  361. package/web-shell/assets/{c4Diagram-UCG6FXSJ-BeQg2L8B.js → c4Diagram-UCG6FXSJ-BoS23iIp.js} +1 -1
  362. package/web-shell/assets/channel-B0ovOJeK.js +1 -0
  363. package/web-shell/assets/{chunk-2Q5K7J3B-DnV9bKBe.js → chunk-2Q5K7J3B-DLLooL1E.js} +1 -1
  364. package/web-shell/assets/{chunk-5VM5RSS4-rT1GAcT7.js → chunk-5VM5RSS4-kPfJxScY.js} +1 -1
  365. package/web-shell/assets/{chunk-F27PBJKO-BcgSxqGA.js → chunk-F27PBJKO-CVGFBqkD.js} +1 -1
  366. package/web-shell/assets/{chunk-G27WJ6UU-Bw1ZhyZq.js → chunk-G27WJ6UU-CnM_kOVV.js} +1 -1
  367. package/web-shell/assets/{chunk-JWPE2WC7-D4iDw-96.js → chunk-JWPE2WC7-Cj-ajOkT.js} +1 -1
  368. package/web-shell/assets/{chunk-LCL6LL3I-D3MB3GTZ.js → chunk-LCL6LL3I-8L5c-wFo.js} +1 -1
  369. package/web-shell/assets/{chunk-POPQ4Y6H-Cep2ndrS.js → chunk-POPQ4Y6H-DsXTxpvL.js} +1 -1
  370. package/web-shell/assets/{chunk-SVP7TREG-BuahMHJc.js → chunk-SVP7TREG-DU5GE1_z.js} +1 -1
  371. package/web-shell/assets/{chunk-XXDRQBXY-BdujIvJY.js → chunk-XXDRQBXY-D2IIWZKt.js} +1 -1
  372. package/web-shell/assets/classDiagram-DTDB5LWJ-DMll2-6_.js +1 -0
  373. package/web-shell/assets/classDiagram-v2-JRS7N3AN-DMll2-6_.js +1 -0
  374. package/web-shell/assets/{cose-bilkent-JH36ORCC-CGLLUbF8.js → cose-bilkent-JH36ORCC-CF_txUJr.js} +1 -1
  375. package/web-shell/assets/{cynefin-OW5HDTMX-D6kDsRSh.js → cynefin-OW5HDTMX-DEZ-My-Z.js} +1 -1
  376. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-CCy78qZx.js → cynefinDiagram-5FMLGOSQ-BV7EKUS6.js} +1 -1
  377. package/web-shell/assets/{dagre-3AP2YEHR-D5gJuJsf.js → dagre-3AP2YEHR-JGIX0G4H.js} +1 -1
  378. package/web-shell/assets/{diagram-S7CK7UJ4-ZwEZ5W__.js → diagram-S7CK7UJ4-DdUY7q6A.js} +1 -1
  379. package/web-shell/assets/{diagram-UQ7AKVKN-B036APjv.js → diagram-UQ7AKVKN-fhzRZ19v.js} +1 -1
  380. package/web-shell/assets/{diagram-VSXAHHWV-BfDJ57Fq.js → diagram-VSXAHHWV-BOgOex6q.js} +1 -1
  381. package/web-shell/assets/{diagram-VX7I27RA-Wha0p5rT.js → diagram-VX7I27RA-C0NknIz6.js} +1 -1
  382. package/web-shell/assets/{diagram-Z3DM3KII-L20bz2K1.js → diagram-Z3DM3KII-C__3mUBX.js} +1 -1
  383. package/web-shell/assets/{ebnfDiagram-PWID7BFC-D1ZM0Cp7.js → ebnfDiagram-PWID7BFC-BvPhqycH.js} +1 -1
  384. package/web-shell/assets/{erDiagram-SSCWMZ5O-CMtA19v8.js → erDiagram-SSCWMZ5O-BqzoNoL9.js} +1 -1
  385. package/web-shell/assets/{flowDiagram-A5DVABFB-D96m326S.js → flowDiagram-A5DVABFB-CJKOre47.js} +1 -1
  386. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-BuHiYG2o.js → ganttDiagram-EL5Y4UJY-C5xZjrp0.js} +1 -1
  387. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-Ck3NmkSw.js → gitGraphDiagram-WWUBYQGX-C0EjwuPK.js} +1 -1
  388. package/web-shell/assets/index-B_IPzA0h.js +2020 -0
  389. package/web-shell/assets/{index-CBGz4Qjl.js → index-C5M93syE.js} +1 -1
  390. package/web-shell/assets/index-D1OKGQlM.css +36 -0
  391. package/web-shell/assets/{infoDiagram-RXCK75RN-B6DAOyXe.js → infoDiagram-RXCK75RN-BUwzsYOs.js} +1 -1
  392. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-Bpg-joFo.js → ishikawaDiagram-5VMMS53U-EDJ_DH3V.js} +1 -1
  393. package/web-shell/assets/{journeyDiagram-EYS64GPL-BclrHzGa.js → journeyDiagram-EYS64GPL-BnfcOsS0.js} +1 -1
  394. package/web-shell/assets/{kanban-definition-3QL26DDD-5gJzNTYG.js → kanban-definition-3QL26DDD-D_ofTVGu.js} +1 -1
  395. package/web-shell/assets/{layout-CEz_1L8z.js → layout-CBuQFdfZ.js} +1 -1
  396. package/web-shell/assets/{linear-CBjTq9Hc.js → linear-DRIHtmGv.js} +1 -1
  397. package/web-shell/assets/{mermaid.core-Dzhbxx_I.js → mermaid.core-CmR5wZH6.js} +6 -6
  398. package/web-shell/assets/{mindmap-definition-FBJOCRG2-DQdVqlBF.js → mindmap-definition-FBJOCRG2-BV374olC.js} +1 -1
  399. package/web-shell/assets/{pegDiagram-XKGWAZYB-D1JZlYXL.js → pegDiagram-XKGWAZYB-Bpy1SplK.js} +1 -1
  400. package/web-shell/assets/{pieDiagram-E7YTZNPT-BmkpYL0w.js → pieDiagram-E7YTZNPT-CeZx4hR2.js} +1 -1
  401. package/web-shell/assets/{quadrantDiagram-AXDQQJYC-DRvD6co5.js → quadrantDiagram-AXDQQJYC-COYKs14h.js} +1 -1
  402. package/web-shell/assets/{railroadDiagram-O6MQD6OU-CEdjDuoo.js → railroadDiagram-O6MQD6OU-5g2pOeTs.js} +1 -1
  403. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-BCHG-ie8.js → requirementDiagram-EFPCY7ZU-Yn8uPGtF.js} +1 -1
  404. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-C9cZMnye.js → sankeyDiagram-P5KCCOFB-CTayAGq6.js} +1 -1
  405. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-DYHRV4zL.js → sequenceDiagram-WJ2MYXX4-BFWDKzUU.js} +1 -1
  406. package/web-shell/assets/{sizeCapture-X5ZJPWSS-DlK21aye.js → sizeCapture-X5ZJPWSS-CtErUbj4.js} +1 -1
  407. package/web-shell/assets/{stateDiagram-HBIQ2CUA-BrmZssvk.js → stateDiagram-HBIQ2CUA-Co3HFzOd.js} +1 -1
  408. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-C3gdRjPm.js +1 -0
  409. package/web-shell/assets/{swimlanes-XN3QIQJK-D9xfcayR.js → swimlanes-XN3QIQJK-CDZuxzOj.js} +1 -1
  410. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-C34TGCPZ.js +8 -0
  411. package/web-shell/assets/{timeline-definition-24CTP7MA-D4gdDL_d.js → timeline-definition-24CTP7MA-UcNHj8At.js} +1 -1
  412. package/web-shell/assets/{vennDiagram-4TSXK5OY-DdhIExjI.js → vennDiagram-4TSXK5OY-JKR9pVFG.js} +1 -1
  413. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-C9RS_Zof.js → wardleyDiagram-VM6X3IG4-C4SU-yIW.js} +1 -1
  414. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-orRgmxWk.js → xychartDiagram-S5SC5T6Z-D_yoWGZ4.js} +1 -1
  415. package/web-shell/index.html +197 -3
  416. package/chunks/MaxSizedBox-X5FZSNAJ.js +0 -112
  417. package/chunks/agent-PJIPDWHB.js +0 -97
  418. package/chunks/agent-headless-B4JVD7UK.js +0 -87
  419. package/chunks/bridge-FKZTVIS3.js +0 -121
  420. package/chunks/channel-settings-store-4UFCLBBG.js +0 -117
  421. package/chunks/chunk-7DJCPZE3.js +0 -945
  422. package/chunks/chunk-CPBF7KYF.js +0 -51
  423. package/chunks/chunk-H72BQNM3.js +0 -645
  424. package/chunks/chunk-J2OSJFP3.js +0 -202
  425. package/chunks/chunk-K2OJUPOE.js +0 -78
  426. package/chunks/chunk-P3QQPMQA.js +0 -19
  427. package/chunks/chunk-RUGNCYNO.js +0 -699
  428. package/chunks/chunk-T26EAKDL.js +0 -13
  429. package/chunks/chunk-ZGXYO7DY.js +0 -3416
  430. package/chunks/chunk-ZYNTSXWK.js +0 -32
  431. package/chunks/config-utils-BBOCOGZW.js +0 -113
  432. package/chunks/contextCommand-EET67MQ2.js +0 -108
  433. package/chunks/daemon-status-provider-RFKZOK3S.js +0 -119
  434. package/chunks/daemon-trust-policy-DRZPFB4Q.js +0 -114
  435. package/chunks/deferred-core-runtime-BBVIOP24.js +0 -116
  436. package/chunks/earlyInputCapture-2JOMMNQ4.js +0 -109
  437. package/chunks/environment-MOZMPUHR.js +0 -131
  438. package/chunks/errors-DMPQVYJL.js +0 -115
  439. package/chunks/exitPlanMode-UE4FGCY4.js +0 -85
  440. package/chunks/handleAutoUpdate-SGXKTQM6.js +0 -111
  441. package/chunks/i18n-B42HKHKH.js +0 -126
  442. package/chunks/initializer-FB66WYR3.js +0 -115
  443. package/chunks/installationInfo-Y7AULNMX.js +0 -109
  444. package/chunks/list-2HWGSVRA.js +0 -118
  445. package/chunks/list-agents-DI3YFTDT.js +0 -80
  446. package/chunks/loadedSettingsAdapter-7Y7IEI6T.js +0 -112
  447. package/chunks/mcp-QGG5NMJJ.js +0 -112
  448. package/chunks/nonInteractiveCli-4LO2TL72.js +0 -186
  449. package/chunks/pidfile-JMF2CLMY.js +0 -113
  450. package/chunks/process-registry-PMJOA5CO.js +0 -172
  451. package/chunks/prompt-terminal-ledger-DCZO6S7C.js +0 -107
  452. package/chunks/resumeHistoryUtils-CZ4JRDVW.js +0 -120
  453. package/chunks/ripGrep-R6B6HWPX.js +0 -39
  454. package/chunks/runtime-TTIGSBM4.js +0 -150
  455. package/chunks/scheduled-tasks-QB4ZVUQS.js +0 -129
  456. package/chunks/scheduler-YRUG22M7.js +0 -124
  457. package/chunks/send-message-Y5I6NYAM.js +0 -295
  458. package/chunks/serve-MXXCDAQN.js +0 -120
  459. package/chunks/shell-6RTKZVMI.js +0 -95
  460. package/chunks/skill-settings-VA4XVYVL.js +0 -120
  461. package/chunks/spawnChannel-F6WVP723.js +0 -114
  462. package/chunks/standalone-update-RGILUQVK.js +0 -120
  463. package/chunks/terminal-image-renderer-SMQE46UJ.js +0 -116
  464. package/chunks/theme-manager-RFO5WWFF.js +0 -104
  465. package/chunks/total-session-admission-HTVTP4BS.js +0 -116
  466. package/chunks/trustedFolders-7OCNMUQE.js +0 -124
  467. package/chunks/updateCheck-7QBDXZRT.js +0 -120
  468. package/chunks/useAutoAcceptIndicator-UI4SNL2O.js +0 -122
  469. package/chunks/workspace-providers-status-PDFZWL5Q.js +0 -116
  470. package/chunks/workspace-registry-23R7XRB5.js +0 -125
  471. package/chunks/workspace-service-MUYO2QIC.js +0 -131
  472. package/chunks/workspace-skills-status-IKECTOOQ.js +0 -115
  473. package/chunks/write-file-GGRBB5TZ.js +0 -90
  474. package/web-shell/assets/channel-CENAhErJ.js +0 -1
  475. package/web-shell/assets/classDiagram-DTDB5LWJ-CM6FArGH.js +0 -1
  476. package/web-shell/assets/classDiagram-v2-JRS7N3AN-CM6FArGH.js +0 -1
  477. package/web-shell/assets/index-8hXIpvo4.js +0 -1865
  478. package/web-shell/assets/index-DclEv91i.css +0 -5
  479. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-B2Q7XDaE.js +0 -1
  480. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-DpZPOSbX.js +0 -8
@@ -0,0 +1,1849 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ MissingCliEntryError
5
+ } from "./chunk-J4Y3QJHF.js";
6
+ import {
7
+ EXTERNAL_TOOL_GUARD_TOKEN_ENV
8
+ } from "./chunk-3VUENPWF.js";
9
+ import {
10
+ redactLogCredentials
11
+ } from "./chunk-M5GB774H.js";
12
+ import {
13
+ CLIENT_METHODS,
14
+ zCreateTerminalRequest,
15
+ zKillTerminalCommandRequest,
16
+ zReadTextFileRequest,
17
+ zReleaseTerminalRequest,
18
+ zRequestPermissionRequest,
19
+ zSessionNotification,
20
+ zTerminalOutputRequest,
21
+ zWaitForTerminalExitRequest,
22
+ zWriteTextFileRequest
23
+ } from "./chunk-IW6RQPQB.js";
24
+ import {
25
+ init_esbuild_shims
26
+ } from "./chunk-5O2XNYP6.js";
27
+ import {
28
+ __name
29
+ } from "./chunk-J2S4EL5Y.js";
30
+
31
+ // packages/acp-bridge/src/spawnChannel.ts
32
+ init_esbuild_shims();
33
+ import { spawn } from "node:child_process";
34
+ import * as os from "node:os";
35
+ import { Readable, Writable } from "node:stream";
36
+ import { getHeapStatistics } from "node:v8";
37
+
38
+ // packages/acp-bridge/src/ndJsonStream.ts
39
+ init_esbuild_shims();
40
+ import { createHash } from "node:crypto";
41
+ import { inspect } from "node:util";
42
+ var NdJsonFrameTooLargeError = class extends Error {
43
+ constructor(direction, limitBytes, observedBytes) {
44
+ super(
45
+ `NDJSON ${direction} frame exceeds ${limitBytes} bytes (observed ${observedBytes} bytes)`
46
+ );
47
+ this.direction = direction;
48
+ this.limitBytes = limitBytes;
49
+ this.observedBytes = observedBytes;
50
+ this.name = "NdJsonFrameTooLargeError";
51
+ }
52
+ static {
53
+ __name(this, "NdJsonFrameTooLargeError");
54
+ }
55
+ code = "ndjson_frame_too_large";
56
+ };
57
+ var NdJsonQueueLimitError = class extends Error {
58
+ constructor(maxQueuedMessages, maxQueuedBytes, requiredBytes, availableBytes) {
59
+ super(
60
+ `NDJSON decoded queue is full (required ${requiredBytes} bytes, available ${availableBytes} bytes)`
61
+ );
62
+ this.maxQueuedMessages = maxQueuedMessages;
63
+ this.maxQueuedBytes = maxQueuedBytes;
64
+ this.requiredBytes = requiredBytes;
65
+ this.availableBytes = availableBytes;
66
+ this.name = "NdJsonQueueLimitError";
67
+ }
68
+ static {
69
+ __name(this, "NdJsonQueueLimitError");
70
+ }
71
+ code = "ndjson_queue_limit_exceeded";
72
+ };
73
+ var NdJsonIncompleteFrameError = class extends Error {
74
+ constructor(observedBytes) {
75
+ super(`NDJSON input ended with an incomplete ${observedBytes}-byte frame`);
76
+ this.observedBytes = observedBytes;
77
+ this.name = "NdJsonIncompleteFrameError";
78
+ }
79
+ static {
80
+ __name(this, "NdJsonIncompleteFrameError");
81
+ }
82
+ code = "ndjson_incomplete_frame";
83
+ };
84
+ var NdJsonUnexpectedEofError = class extends Error {
85
+ static {
86
+ __name(this, "NdJsonUnexpectedEofError");
87
+ }
88
+ code = "ndjson_unexpected_eof";
89
+ constructor() {
90
+ super("NDJSON input ended while the bounded transport was active");
91
+ this.name = "NdJsonUnexpectedEofError";
92
+ }
93
+ };
94
+ var NdJsonInvalidMessageError = class extends Error {
95
+ constructor(code, observedBytes) {
96
+ super(`NDJSON input contains an invalid ${observedBytes}-byte message`);
97
+ this.code = code;
98
+ this.observedBytes = observedBytes;
99
+ this.name = "NdJsonInvalidMessageError";
100
+ }
101
+ static {
102
+ __name(this, "NdJsonInvalidMessageError");
103
+ }
104
+ };
105
+ var MAX_JSON_RPC_METHOD_BYTES = 1024;
106
+ var MAX_JSON_RPC_ID_BYTES = 256;
107
+ var MAX_JSON_RPC_ERROR_MESSAGE_BYTES = 1024;
108
+ var MAX_JSON_DEPTH = 64;
109
+ var MAX_JSON_NODES = 1e4;
110
+ var MAX_JSON_ARRAY_LENGTH = 4096;
111
+ function ndJsonStream(output, input, hooks, limits, validateInboundMessage, fatalCleanEof = false) {
112
+ const textEncoder = new TextEncoder();
113
+ const textDecoder = new TextDecoder();
114
+ if (limits) validateNdJsonStreamLimits(limits);
115
+ const outboundRequests = limits ? new BoundedOutstandingRequestLedger(limits) : void 0;
116
+ const inboundRequests = limits ? new BoundedInboundRequestLedger(limits) : void 0;
117
+ const readable = limits ? createBoundedReadable(
118
+ input,
119
+ textDecoder,
120
+ hooks,
121
+ limits,
122
+ outboundRequests,
123
+ inboundRequests,
124
+ validateInboundMessage,
125
+ fatalCleanEof
126
+ ) : createLegacyReadable(input, textDecoder, hooks);
127
+ const writable = new WritableStream({
128
+ async write(message) {
129
+ let writer;
130
+ let expectedResponseId;
131
+ try {
132
+ const content = JSON.stringify(message);
133
+ const payload = textEncoder.encode(content);
134
+ const frameBytes = payload.byteLength + 1;
135
+ if (limits && frameBytes > limits.maxFrameBytes) {
136
+ throw new NdJsonFrameTooLargeError(
137
+ "sent",
138
+ limits.maxFrameBytes,
139
+ frameBytes
140
+ );
141
+ }
142
+ const frame = new Uint8Array(frameBytes);
143
+ frame.set(payload);
144
+ frame[payload.byteLength] = 10;
145
+ if (outboundRequests && isJsonRpcRequestMessage(message)) {
146
+ outboundRequests.admit(message.id, frameBytes);
147
+ expectedResponseId = message.id;
148
+ }
149
+ writer = output.getWriter();
150
+ await writer.write(frame);
151
+ inboundRequests?.release(message);
152
+ callHook(hooks?.onMessageSent, payload.byteLength);
153
+ callHook(hooks?.onMessageObserved, {
154
+ direction: "sent",
155
+ bytes: payload.byteLength,
156
+ message
157
+ });
158
+ } catch (error) {
159
+ if (expectedResponseId !== void 0) {
160
+ outboundRequests?.discard(expectedResponseId);
161
+ }
162
+ if (limits) callHook(hooks?.onTransportError, error);
163
+ throw error;
164
+ } finally {
165
+ writer?.releaseLock();
166
+ }
167
+ }
168
+ });
169
+ return { readable, writable };
170
+ }
171
+ __name(ndJsonStream, "ndJsonStream");
172
+ function createLegacyReadable(input, textDecoder, hooks) {
173
+ return new ReadableStream({
174
+ async start(controller) {
175
+ const pending = [];
176
+ const reader = input.getReader();
177
+ try {
178
+ while (true) {
179
+ const { value, done } = await reader.read();
180
+ if (done) break;
181
+ if (!value) continue;
182
+ readLegacyChunk(value, pending, controller, textDecoder, hooks);
183
+ }
184
+ } finally {
185
+ reader.releaseLock();
186
+ controller.close();
187
+ }
188
+ }
189
+ });
190
+ }
191
+ __name(createLegacyReadable, "createLegacyReadable");
192
+ function createBoundedReadable(input, textDecoder, hooks, limits, outboundRequests, inboundRequests, validateInboundMessage, fatalCleanEof) {
193
+ const pending = new BoundedFrameBuffer(limits.maxFrameBytes);
194
+ const minimumQueueCharge = Math.ceil(
195
+ limits.maxQueuedBytes / limits.maxQueuedMessages
196
+ );
197
+ let nextQueueCharge = minimumQueueCharge;
198
+ let reader;
199
+ let canceled = false;
200
+ return new ReadableStream(
201
+ {
202
+ start(controller) {
203
+ reader = input.getReader();
204
+ void pumpBoundedInput(
205
+ reader,
206
+ pending,
207
+ controller,
208
+ textDecoder,
209
+ hooks,
210
+ limits,
211
+ outboundRequests,
212
+ inboundRequests,
213
+ validateInboundMessage,
214
+ fatalCleanEof,
215
+ minimumQueueCharge,
216
+ (charge) => {
217
+ nextQueueCharge = charge;
218
+ },
219
+ () => canceled
220
+ );
221
+ },
222
+ async cancel(reason) {
223
+ canceled = true;
224
+ pending.clear();
225
+ if (reader) await cancelReader(reader, reason);
226
+ }
227
+ },
228
+ {
229
+ highWaterMark: limits.maxQueuedBytes,
230
+ size: /* @__PURE__ */ __name(() => nextQueueCharge, "size")
231
+ }
232
+ );
233
+ }
234
+ __name(createBoundedReadable, "createBoundedReadable");
235
+ async function pumpBoundedInput(reader, pending, controller, textDecoder, hooks, limits, outboundRequests, inboundRequests, validateInboundMessage, fatalCleanEof, minimumQueueCharge, setNextQueueCharge, isCanceled) {
236
+ try {
237
+ while (true) {
238
+ const result = await reader.read();
239
+ if (result.done) {
240
+ if (isCanceled()) return;
241
+ if (pending.byteLength > 0) {
242
+ throw new NdJsonIncompleteFrameError(pending.byteLength);
243
+ }
244
+ if (fatalCleanEof) throw new NdJsonUnexpectedEofError();
245
+ controller.close();
246
+ return;
247
+ }
248
+ if (!result.value) continue;
249
+ readBoundedChunk(
250
+ result.value,
251
+ pending,
252
+ controller,
253
+ textDecoder,
254
+ hooks,
255
+ limits,
256
+ outboundRequests,
257
+ inboundRequests,
258
+ validateInboundMessage,
259
+ minimumQueueCharge,
260
+ setNextQueueCharge
261
+ );
262
+ }
263
+ } catch (error) {
264
+ if (isCanceled()) return;
265
+ pending.clear();
266
+ callHook(hooks?.onTransportError, error);
267
+ await cancelReader(reader, error);
268
+ if (!isCanceled()) controller.close();
269
+ } finally {
270
+ pending.clear();
271
+ outboundRequests.clear();
272
+ inboundRequests.clear();
273
+ reader.releaseLock();
274
+ }
275
+ }
276
+ __name(pumpBoundedInput, "pumpBoundedInput");
277
+ function readLegacyChunk(chunk, pending, controller, textDecoder, hooks) {
278
+ let start = 0;
279
+ let newline = chunk.indexOf(10, start);
280
+ while (newline !== -1) {
281
+ const lineBytes = takeLegacyLineBytes(
282
+ pending,
283
+ chunk.subarray(start, newline)
284
+ );
285
+ handleLegacyLine(lineBytes, controller, textDecoder, hooks);
286
+ start = newline + 1;
287
+ newline = chunk.indexOf(10, start);
288
+ }
289
+ if (start < chunk.length) {
290
+ pending.push(chunk.subarray(start));
291
+ }
292
+ }
293
+ __name(readLegacyChunk, "readLegacyChunk");
294
+ function readBoundedChunk(chunk, pending, controller, textDecoder, hooks, limits, outboundRequests, inboundRequests, validateInboundMessage, minimumQueueCharge, setNextQueueCharge) {
295
+ let start = 0;
296
+ let newline = chunk.indexOf(10, start);
297
+ while (newline !== -1) {
298
+ const current = chunk.subarray(start, newline);
299
+ const frameBytes = pending.byteLength + current.byteLength + 1;
300
+ assertFrameSize("received", limits.maxFrameBytes, frameBytes);
301
+ if (pending.isJsonWhitespaceLine(current)) {
302
+ pending.clear();
303
+ start = newline + 1;
304
+ newline = chunk.indexOf(10, start);
305
+ continue;
306
+ }
307
+ const queueCharge = Math.max(frameBytes, minimumQueueCharge);
308
+ const availableBytes = controller.desiredSize;
309
+ if (availableBytes === null || queueCharge > availableBytes) {
310
+ throw new NdJsonQueueLimitError(
311
+ limits.maxQueuedMessages,
312
+ limits.maxQueuedBytes,
313
+ queueCharge,
314
+ Math.max(0, availableBytes ?? 0)
315
+ );
316
+ }
317
+ setNextQueueCharge(queueCharge);
318
+ handleBoundedLine(
319
+ pending.take(current),
320
+ controller,
321
+ textDecoder,
322
+ hooks,
323
+ outboundRequests,
324
+ inboundRequests,
325
+ validateInboundMessage
326
+ );
327
+ start = newline + 1;
328
+ newline = chunk.indexOf(10, start);
329
+ }
330
+ if (start < chunk.length) pending.append(chunk.subarray(start));
331
+ }
332
+ __name(readBoundedChunk, "readBoundedChunk");
333
+ function takeLegacyLineBytes(pending, current) {
334
+ if (pending.length === 0) return current;
335
+ const totalLength = pending.reduce((sum, part) => sum + part.byteLength, 0) + current.byteLength;
336
+ const line = new Uint8Array(totalLength);
337
+ let offset = 0;
338
+ for (const part of pending) {
339
+ line.set(part, offset);
340
+ offset += part.byteLength;
341
+ }
342
+ line.set(current, offset);
343
+ pending.length = 0;
344
+ return line;
345
+ }
346
+ __name(takeLegacyLineBytes, "takeLegacyLineBytes");
347
+ function handleLegacyLine(lineBytes, controller, textDecoder, hooks) {
348
+ const line = textDecoder.decode(lineBytes);
349
+ const trimmedLine = line.trim();
350
+ if (!trimmedLine) return;
351
+ try {
352
+ const message = JSON.parse(trimmedLine);
353
+ controller.enqueue(message);
354
+ reportReceivedMessage(lineBytes, message, hooks);
355
+ } catch (err) {
356
+ console.error("Failed to parse JSON message:", trimmedLine, err);
357
+ }
358
+ }
359
+ __name(handleLegacyLine, "handleLegacyLine");
360
+ function handleBoundedLine(lineBytes, controller, textDecoder, hooks, outboundRequests, inboundRequests, validateInboundMessage) {
361
+ const line = textDecoder.decode(lineBytes);
362
+ const trimmedLine = line.trim();
363
+ if (!trimmedLine) return;
364
+ let parsed;
365
+ try {
366
+ parsed = JSON.parse(trimmedLine);
367
+ } catch {
368
+ throw logBoundedInvalidMessage("ndjson_parse_error", lineBytes);
369
+ }
370
+ if (!isJsonRpcMessage(parsed)) {
371
+ throw logBoundedInvalidMessage("ndjson_invalid_message", lineBytes);
372
+ }
373
+ const isResponse = isJsonRpcResponseMessage(parsed);
374
+ if (!isResponse && !hasBoundedJsonStructure(parsed) || validateInboundMessage && !validateInboundMessage(parsed)) {
375
+ throw logBoundedInvalidMessage("ndjson_invalid_message", lineBytes);
376
+ }
377
+ if (isJsonRpcResponseMessage(parsed) && !outboundRequests?.consumeResponse(parsed.id)) {
378
+ throw logBoundedInvalidMessage("ndjson_invalid_message", lineBytes);
379
+ }
380
+ inboundRequests?.admit(parsed, lineBytes.byteLength + 1);
381
+ const message = installBoundedLogRedaction(parsed);
382
+ controller.enqueue(message);
383
+ reportReceivedMessage(lineBytes, message, hooks);
384
+ }
385
+ __name(handleBoundedLine, "handleBoundedLine");
386
+ function installBoundedLogRedaction(message) {
387
+ Object.defineProperty(message, inspect.custom, {
388
+ configurable: false,
389
+ enumerable: false,
390
+ value: inspectBoundedJsonRpcMessage,
391
+ writable: false
392
+ });
393
+ return message;
394
+ }
395
+ __name(installBoundedLogRedaction, "installBoundedLogRedaction");
396
+ function inspectBoundedJsonRpcMessage() {
397
+ return {
398
+ jsonrpc: "2.0",
399
+ messageType: "method" in this ? "id" in this ? "request" : "notification" : "response",
400
+ payloadOmitted: true
401
+ };
402
+ }
403
+ __name(inspectBoundedJsonRpcMessage, "inspectBoundedJsonRpcMessage");
404
+ function isJsonRpcMessage(value) {
405
+ if (!isRecord(value) || value["jsonrpc"] !== "2.0") return false;
406
+ const hasMethod = Object.hasOwn(value, "method");
407
+ const hasId = Object.hasOwn(value, "id");
408
+ if (hasMethod) {
409
+ return typeof value["method"] === "string" && Buffer.byteLength(value["method"]) <= MAX_JSON_RPC_METHOD_BYTES && (!hasId || isJsonRpcId(value["id"]));
410
+ }
411
+ if (!hasId || !isJsonRpcId(value["id"])) return false;
412
+ const hasResult = Object.hasOwn(value, "result");
413
+ const hasError = Object.hasOwn(value, "error");
414
+ if (hasResult === hasError) return false;
415
+ if (!hasError) return true;
416
+ const error = value["error"];
417
+ return isRecord(error) && typeof error["code"] === "number" && Number.isFinite(error["code"]) && typeof error["message"] === "string" && Buffer.byteLength(error["message"]) <= MAX_JSON_RPC_ERROR_MESSAGE_BYTES;
418
+ }
419
+ __name(isJsonRpcMessage, "isJsonRpcMessage");
420
+ function isRecord(value) {
421
+ return typeof value === "object" && value !== null && !Array.isArray(value);
422
+ }
423
+ __name(isRecord, "isRecord");
424
+ function hasBoundedJsonStructure(value) {
425
+ const stack = [{ value, depth: 1 }];
426
+ let nodes = 0;
427
+ while (stack.length > 0) {
428
+ const current = stack.pop();
429
+ nodes++;
430
+ if (nodes > MAX_JSON_NODES || current.depth > MAX_JSON_DEPTH) return false;
431
+ if (Array.isArray(current.value)) {
432
+ if (current.value.length > MAX_JSON_ARRAY_LENGTH) return false;
433
+ for (let index = current.value.length - 1; index >= 0; index--) {
434
+ if (nodes + stack.length >= MAX_JSON_NODES || current.depth + 1 > MAX_JSON_DEPTH) {
435
+ return false;
436
+ }
437
+ stack.push({
438
+ value: current.value[index],
439
+ depth: current.depth + 1
440
+ });
441
+ }
442
+ } else if (isRecord(current.value)) {
443
+ for (const key in current.value) {
444
+ if (!Object.hasOwn(current.value, key)) continue;
445
+ if (nodes + stack.length >= MAX_JSON_NODES || current.depth + 1 > MAX_JSON_DEPTH) {
446
+ return false;
447
+ }
448
+ stack.push({
449
+ value: current.value[key],
450
+ depth: current.depth + 1
451
+ });
452
+ }
453
+ }
454
+ }
455
+ return true;
456
+ }
457
+ __name(hasBoundedJsonStructure, "hasBoundedJsonStructure");
458
+ function isJsonRpcId(value) {
459
+ return value === null || typeof value === "string" && Buffer.byteLength(value) <= MAX_JSON_RPC_ID_BYTES || typeof value === "number" && Number.isFinite(value);
460
+ }
461
+ __name(isJsonRpcId, "isJsonRpcId");
462
+ function isJsonRpcRequestMessage(value) {
463
+ return "method" in value && "id" in value && typeof value.method === "string" && isJsonRpcId(value.id);
464
+ }
465
+ __name(isJsonRpcRequestMessage, "isJsonRpcRequestMessage");
466
+ function isJsonRpcResponseMessage(value) {
467
+ return !("method" in value) && "id" in value;
468
+ }
469
+ __name(isJsonRpcResponseMessage, "isJsonRpcResponseMessage");
470
+ var BoundedInboundRequestLedger = class {
471
+ constructor(limits) {
472
+ this.limits = limits;
473
+ }
474
+ static {
475
+ __name(this, "BoundedInboundRequestLedger");
476
+ }
477
+ requests = /* @__PURE__ */ new Map();
478
+ retainedBytes = 0;
479
+ admit(message, frameBytes) {
480
+ if (!isJsonRpcRequestMessage(message)) return;
481
+ const availableBytes = Math.max(
482
+ 0,
483
+ this.limits.maxQueuedBytes - this.retainedBytes
484
+ );
485
+ if (this.requests.has(message.id) || this.requests.size >= this.limits.maxQueuedMessages || frameBytes > availableBytes) {
486
+ throw new NdJsonQueueLimitError(
487
+ this.limits.maxQueuedMessages,
488
+ this.limits.maxQueuedBytes,
489
+ frameBytes,
490
+ this.requests.has(message.id) ? 0 : availableBytes
491
+ );
492
+ }
493
+ this.requests.set(message.id, frameBytes);
494
+ this.retainedBytes += frameBytes;
495
+ }
496
+ release(message) {
497
+ if (!isJsonRpcResponseMessage(message)) return;
498
+ const frameBytes = this.requests.get(message.id);
499
+ if (frameBytes === void 0) return;
500
+ this.requests.delete(message.id);
501
+ this.retainedBytes -= frameBytes;
502
+ }
503
+ clear() {
504
+ this.requests.clear();
505
+ this.retainedBytes = 0;
506
+ }
507
+ };
508
+ var BoundedOutstandingRequestLedger = class {
509
+ constructor(limits) {
510
+ this.limits = limits;
511
+ }
512
+ static {
513
+ __name(this, "BoundedOutstandingRequestLedger");
514
+ }
515
+ requests = /* @__PURE__ */ new Map();
516
+ retainedBytes = 0;
517
+ admit(id, frameBytes) {
518
+ const availableBytes = Math.max(
519
+ 0,
520
+ this.limits.maxQueuedBytes - this.retainedBytes
521
+ );
522
+ if (this.requests.has(id) || this.requests.size >= this.limits.maxQueuedMessages || frameBytes > availableBytes) {
523
+ throw new NdJsonQueueLimitError(
524
+ this.limits.maxQueuedMessages,
525
+ this.limits.maxQueuedBytes,
526
+ frameBytes,
527
+ this.requests.has(id) ? 0 : availableBytes
528
+ );
529
+ }
530
+ this.requests.set(id, frameBytes);
531
+ this.retainedBytes += frameBytes;
532
+ }
533
+ consumeResponse(id) {
534
+ return this.discard(id);
535
+ }
536
+ discard(id) {
537
+ const frameBytes = this.requests.get(id);
538
+ if (frameBytes === void 0) return false;
539
+ this.requests.delete(id);
540
+ this.retainedBytes -= frameBytes;
541
+ return true;
542
+ }
543
+ clear() {
544
+ this.requests.clear();
545
+ this.retainedBytes = 0;
546
+ }
547
+ };
548
+ function logBoundedInvalidMessage(errorKind, lineBytes) {
549
+ const bytes = jsonPayloadByteLength(lineBytes);
550
+ const digest = createHash("sha256").update(lineBytes.subarray(0, bytes)).digest("hex");
551
+ console.error("Failed to parse JSON message:", {
552
+ errorKind,
553
+ bytes,
554
+ sha256: digest,
555
+ payloadOmitted: true
556
+ });
557
+ return new NdJsonInvalidMessageError(errorKind, bytes);
558
+ }
559
+ __name(logBoundedInvalidMessage, "logBoundedInvalidMessage");
560
+ function reportReceivedMessage(lineBytes, message, hooks) {
561
+ const bytes = jsonPayloadByteLength(lineBytes);
562
+ callHook(hooks?.onMessageReceived, bytes);
563
+ callHook(hooks?.onMessageObserved, {
564
+ direction: "received",
565
+ bytes,
566
+ message
567
+ });
568
+ }
569
+ __name(reportReceivedMessage, "reportReceivedMessage");
570
+ function jsonPayloadByteLength(lineBytes) {
571
+ return lineBytes[lineBytes.byteLength - 1] === 13 ? lineBytes.byteLength - 1 : lineBytes.byteLength;
572
+ }
573
+ __name(jsonPayloadByteLength, "jsonPayloadByteLength");
574
+ function validateNdJsonStreamLimits(limits) {
575
+ const values = [
576
+ ["maxFrameBytes", limits.maxFrameBytes],
577
+ ["maxQueuedMessages", limits.maxQueuedMessages],
578
+ ["maxQueuedBytes", limits.maxQueuedBytes]
579
+ ];
580
+ for (const [name, value] of values) {
581
+ if (!Number.isSafeInteger(value) || value <= 0) {
582
+ throw new RangeError(`${name} must be a positive safe integer`);
583
+ }
584
+ }
585
+ }
586
+ __name(validateNdJsonStreamLimits, "validateNdJsonStreamLimits");
587
+ function assertFrameSize(direction, limitBytes, observedBytes) {
588
+ if (observedBytes > limitBytes) {
589
+ throw new NdJsonFrameTooLargeError(direction, limitBytes, observedBytes);
590
+ }
591
+ }
592
+ __name(assertFrameSize, "assertFrameSize");
593
+ async function cancelReader(reader, reason) {
594
+ try {
595
+ await reader.cancel(reason);
596
+ } catch {
597
+ }
598
+ }
599
+ __name(cancelReader, "cancelReader");
600
+ function callHook(hook, value) {
601
+ try {
602
+ hook?.(value);
603
+ } catch {
604
+ }
605
+ }
606
+ __name(callHook, "callHook");
607
+ var BoundedFrameBuffer = class {
608
+ constructor(maxFrameBytes) {
609
+ this.maxFrameBytes = maxFrameBytes;
610
+ }
611
+ static {
612
+ __name(this, "BoundedFrameBuffer");
613
+ }
614
+ buffer;
615
+ length = 0;
616
+ get byteLength() {
617
+ return this.length;
618
+ }
619
+ append(bytes) {
620
+ const requiredBytes = this.length + bytes.byteLength;
621
+ assertFrameSize("received", this.maxFrameBytes, requiredBytes);
622
+ if (requiredBytes === 0) return;
623
+ if (!this.buffer || this.buffer.byteLength < requiredBytes) {
624
+ const doubledCapacity = Math.min(
625
+ this.maxFrameBytes,
626
+ Math.max(1024, (this.buffer?.byteLength ?? 0) * 2)
627
+ );
628
+ const next = new Uint8Array(Math.max(requiredBytes, doubledCapacity));
629
+ if (this.buffer) next.set(this.buffer.subarray(0, this.length));
630
+ this.buffer = next;
631
+ }
632
+ this.buffer.set(bytes, this.length);
633
+ this.length = requiredBytes;
634
+ }
635
+ take(current) {
636
+ if (this.length === 0) return current;
637
+ const line = new Uint8Array(this.length + current.byteLength);
638
+ line.set(this.buffer.subarray(0, this.length));
639
+ line.set(current, this.length);
640
+ this.clear();
641
+ return line;
642
+ }
643
+ isJsonWhitespaceLine(current) {
644
+ if (this.buffer) {
645
+ for (let index = 0; index < this.length; index++) {
646
+ if (!isJsonWhitespaceByte(this.buffer[index])) return false;
647
+ }
648
+ }
649
+ for (const byte of current) {
650
+ if (!isJsonWhitespaceByte(byte)) return false;
651
+ }
652
+ return true;
653
+ }
654
+ clear() {
655
+ this.buffer = void 0;
656
+ this.length = 0;
657
+ }
658
+ };
659
+ function isJsonWhitespaceByte(byte) {
660
+ return byte === 32 || byte === 9 || byte === 13;
661
+ }
662
+ __name(isJsonWhitespaceByte, "isJsonWhitespaceByte");
663
+
664
+ // packages/acp-bridge/src/process-registry.ts
665
+ init_esbuild_shims();
666
+ import {
667
+ execFile,
668
+ spawnSync
669
+ } from "node:child_process";
670
+ var TERM_GRACE_MS = 5e3;
671
+ var EXIT_DEADLINE_MS = 1e4;
672
+ var PROCESS_QUERY_TIMEOUT_MS = 2e3;
673
+ var PROCESS_QUERY_MAX_BUFFER = 8 * 1024 * 1024;
674
+ var PROCESS_POLL_MS = 50;
675
+ var PROCESS_STATE_POLL_MS = 250;
676
+ var MAX_OWNED_PROCESSES = 256;
677
+ var MAX_OWNERSHIP_DEPTH = 8;
678
+ var POSIX_PS = "/bin/ps";
679
+ var WINDOWS_TASKKILL = `${process.env["SystemRoot"] || "C:\\Windows"}\\System32\\taskkill.exe`;
680
+ var STRING_EXEC_OPTIONS = {
681
+ encoding: "utf8",
682
+ maxBuffer: PROCESS_QUERY_MAX_BUFFER,
683
+ timeout: PROCESS_QUERY_TIMEOUT_MS,
684
+ windowsHide: true
685
+ };
686
+ var ProcessRegistry = class {
687
+ static {
688
+ __name(this, "ProcessRegistry");
689
+ }
690
+ reservations = /* @__PURE__ */ new Set();
691
+ children = /* @__PURE__ */ new Set();
692
+ draining = false;
693
+ shutdownPromise;
694
+ reserve() {
695
+ if (this.draining) {
696
+ throw new Error("ACP process registry is draining");
697
+ }
698
+ const token = Symbol("acp-child");
699
+ this.reservations.add(token);
700
+ let settled = false;
701
+ return {
702
+ attach: /* @__PURE__ */ __name((child, options) => {
703
+ if (settled || !this.reservations.delete(token)) {
704
+ throw new Error("ACP process reservation is no longer active");
705
+ }
706
+ settled = true;
707
+ const tracked = new TrackedChild(
708
+ child,
709
+ options?.ownsProcessTree === true,
710
+ () => {
711
+ this.children.delete(tracked);
712
+ }
713
+ );
714
+ this.children.add(tracked);
715
+ if (this.draining) void tracked.terminate().catch(() => {
716
+ });
717
+ return tracked;
718
+ }, "attach"),
719
+ cancel: /* @__PURE__ */ __name(() => {
720
+ if (settled) return;
721
+ settled = true;
722
+ this.reservations.delete(token);
723
+ }, "cancel")
724
+ };
725
+ }
726
+ shutdown() {
727
+ if (this.shutdownPromise) return this.shutdownPromise;
728
+ this.draining = true;
729
+ this.shutdownPromise = Promise.allSettled(
730
+ [...this.children].map((child) => child.terminate())
731
+ ).then((results) => {
732
+ const failures = results.flatMap(
733
+ (result) => result.status === "rejected" ? [result.reason] : []
734
+ );
735
+ if (failures.length > 0) {
736
+ throw new AggregateError(failures, "ACP child process shutdown failed");
737
+ }
738
+ });
739
+ return this.shutdownPromise;
740
+ }
741
+ killAllSync() {
742
+ this.draining = true;
743
+ let processTable;
744
+ if (process.platform !== "win32" && [...this.children].some((child) => child.needsProcessTreeSnapshot)) {
745
+ try {
746
+ processTable = parseProcessTable(queryProcessTableSync());
747
+ } catch {
748
+ processTable = null;
749
+ }
750
+ }
751
+ for (const child of this.children) child.killSync(processTable);
752
+ }
753
+ get activeProcessCount() {
754
+ return this.children.size;
755
+ }
756
+ /**
757
+ * Children this registry has committed to: attached ones plus reservations
758
+ * that have not attached yet. Larger than {@link activeProcessCount}, and
759
+ * the right figure for admission — `reserve()` inserts its token
760
+ * synchronously before `spawn()`, so two racing spawns each see the other
761
+ * here, while neither is visible in `activeProcessCount` until its child is
762
+ * attached.
763
+ *
764
+ * A direct child leaves this count when its root exits. A tree-owned child
765
+ * under explicit teardown remains committed until its known tree is gone,
766
+ * so a channel swap includes memory still held by descendants.
767
+ */
768
+ get committedProcessCount() {
769
+ return this.children.size + this.reservations.size;
770
+ }
771
+ };
772
+ var TrackedChild = class {
773
+ constructor(child, ownsProcessTree, onRelease) {
774
+ this.child = child;
775
+ this.ownsProcessTree = ownsProcessTree;
776
+ this.onRelease = onRelease;
777
+ this.rememberRoot();
778
+ this.exited = new Promise((resolve) => {
779
+ const finish = /* @__PURE__ */ __name((info) => {
780
+ if (this.exitedSettled) return;
781
+ this.exitedSettled = true;
782
+ this.exitInfo = info;
783
+ resolve(info);
784
+ this.handleRootExit();
785
+ }, "finish");
786
+ child.once("exit", (exitCode, signalCode) => {
787
+ finish({ exitCode, signalCode });
788
+ });
789
+ child.once("spawn", () => {
790
+ this.spawnConfirmed = true;
791
+ this.rememberRoot();
792
+ });
793
+ child.once("error", () => {
794
+ if (!this.spawnConfirmed) finish(void 0);
795
+ });
796
+ });
797
+ }
798
+ static {
799
+ __name(this, "TrackedChild");
800
+ }
801
+ exited;
802
+ knownGroups = /* @__PURE__ */ new Set();
803
+ cleanupProofError;
804
+ exitInfo;
805
+ exitedSettled = false;
806
+ forceKillRequested = false;
807
+ released = false;
808
+ releasePollTimer;
809
+ releaseStateCheckInFlight = false;
810
+ spawnConfirmed = false;
811
+ terminatePromise;
812
+ terminating = false;
813
+ terminationSettled = false;
814
+ terminate() {
815
+ if (this.terminatePromise) return this.terminatePromise;
816
+ this.terminating = true;
817
+ if (this.releasePollTimer) {
818
+ clearTimeout(this.releasePollTimer);
819
+ this.releasePollTimer = void 0;
820
+ }
821
+ const termination = this.ownsProcessTree ? this.terminateTree() : this.terminateDirectChild();
822
+ this.terminatePromise = termination.finally(() => {
823
+ this.terminationSettled = true;
824
+ if (this.ownsProcessTree && this.exitedSettled && !this.released) {
825
+ this.releaseWhenGroupsExit();
826
+ }
827
+ });
828
+ return this.terminatePromise;
829
+ }
830
+ get needsProcessTreeSnapshot() {
831
+ return this.ownsProcessTree && !this.forceKillRequested && !this.rootHasExited && !this.released;
832
+ }
833
+ killSync(processTable) {
834
+ if (!this.ownsProcessTree) {
835
+ this.killDirectChildSync();
836
+ return;
837
+ }
838
+ if (this.released) return;
839
+ const firstForceKill = !this.forceKillRequested;
840
+ this.forceKillRequested = true;
841
+ const rootPid = this.rootPid;
842
+ if (!rootPid) {
843
+ this.killDirectChildSync();
844
+ return;
845
+ }
846
+ if (process.platform === "win32") {
847
+ if (!firstForceKill) return;
848
+ if (!taskkillSync(rootPid)) this.killDirectChildSync();
849
+ return;
850
+ }
851
+ if (firstForceKill && !this.rootHasExited) {
852
+ if (processTable === void 0) this.mergeSynchronousSnapshot();
853
+ else if (processTable !== null) {
854
+ this.mergeSnapshot(collectOwnership(processTable, rootPid));
855
+ }
856
+ }
857
+ const rootSignalled = this.signalKnownGroups("SIGKILL");
858
+ this.signalDirectRootIfNeeded("SIGKILL", rootSignalled);
859
+ if (this.exitedSettled && this.survivingGroups().length === 0) {
860
+ this.release();
861
+ }
862
+ }
863
+ get rootPid() {
864
+ const pid = this.child.pid;
865
+ return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 ? pid : void 0;
866
+ }
867
+ get rootHasExited() {
868
+ return this.exitedSettled || this.child.exitCode !== null || this.child.signalCode !== null;
869
+ }
870
+ rememberRoot() {
871
+ if (!this.ownsProcessTree) return;
872
+ const rootPid = this.rootPid;
873
+ if (!rootPid) return;
874
+ if (process.platform !== "win32") this.knownGroups.add(rootPid);
875
+ }
876
+ handleRootExit() {
877
+ if (!this.ownsProcessTree) {
878
+ this.release();
879
+ return;
880
+ }
881
+ if (this.terminating && !this.terminationSettled) return;
882
+ if (process.platform !== "win32") {
883
+ this.forceKillRequested = true;
884
+ this.signalKnownGroups("SIGKILL");
885
+ this.releaseWhenGroupsExit();
886
+ return;
887
+ }
888
+ this.release();
889
+ }
890
+ release() {
891
+ if (this.released) return;
892
+ this.released = true;
893
+ if (this.releasePollTimer) clearTimeout(this.releasePollTimer);
894
+ this.onRelease();
895
+ }
896
+ killDirectChildSync() {
897
+ if (this.exitedSettled) return;
898
+ try {
899
+ this.child.kill("SIGKILL");
900
+ } catch {
901
+ }
902
+ }
903
+ signalDirectRootIfNeeded(signal, rootGroupSignalled) {
904
+ const rootPid = this.rootPid;
905
+ if (!rootPid || this.exitedSettled || rootGroupSignalled) return;
906
+ try {
907
+ this.child.kill(signal);
908
+ } catch {
909
+ }
910
+ }
911
+ async terminateDirectChild() {
912
+ if (this.exitedSettled) return;
913
+ try {
914
+ this.child.kill("SIGTERM");
915
+ } catch {
916
+ if (this.exitedSettled) return;
917
+ }
918
+ let hardKillTimer;
919
+ let deadlineTimer;
920
+ const deadline = new Promise((_, reject) => {
921
+ hardKillTimer = setTimeout(
922
+ () => this.killDirectChildSync(),
923
+ TERM_GRACE_MS
924
+ );
925
+ hardKillTimer.unref();
926
+ deadlineTimer = setTimeout(() => {
927
+ reject(
928
+ new Error(
929
+ `ACP child pid=${this.child.pid ?? "unknown"} did not exit within ${EXIT_DEADLINE_MS}ms`
930
+ )
931
+ );
932
+ }, EXIT_DEADLINE_MS);
933
+ deadlineTimer.unref();
934
+ });
935
+ try {
936
+ const exitInfo = await Promise.race([this.exited, deadline]);
937
+ this.throwForUncleanExit(exitInfo);
938
+ } finally {
939
+ if (hardKillTimer) clearTimeout(hardKillTimer);
940
+ if (deadlineTimer) clearTimeout(deadlineTimer);
941
+ }
942
+ }
943
+ async terminateTree() {
944
+ if (this.exitedSettled && (process.platform === "win32" || this.released)) {
945
+ return;
946
+ }
947
+ const rootPid = this.rootPid;
948
+ if (!rootPid) {
949
+ await this.terminateDirectChild();
950
+ return;
951
+ }
952
+ if (process.platform === "win32") {
953
+ await this.terminateWindowsTree(rootPid);
954
+ return;
955
+ }
956
+ await this.terminatePosixTree(rootPid);
957
+ }
958
+ async terminatePosixTree(rootPid) {
959
+ const startedAt = Date.now();
960
+ if (!this.rootHasExited) {
961
+ await this.mergeAsynchronousSnapshot(rootPid, true);
962
+ }
963
+ let escalated = this.forceKillRequested;
964
+ let rootSignalled = this.signalKnownGroups(
965
+ escalated ? "SIGKILL" : "SIGTERM"
966
+ );
967
+ this.signalDirectRootIfNeeded(
968
+ escalated ? "SIGKILL" : "SIGTERM",
969
+ rootSignalled
970
+ );
971
+ const graceDeadline = Math.min(
972
+ startedAt + EXIT_DEADLINE_MS,
973
+ Date.now() + TERM_GRACE_MS
974
+ );
975
+ const exitDeadline = startedAt + EXIT_DEADLINE_MS;
976
+ let nextStateCheckAt = 0;
977
+ while (true) {
978
+ let survivingGroups = this.survivingGroups();
979
+ let now = Date.now();
980
+ if (this.exitedSettled && escalated && survivingGroups.length > 0 && now < exitDeadline && now >= nextStateCheckAt) {
981
+ await this.pruneTerminalGroups(survivingGroups, exitDeadline - now);
982
+ nextStateCheckAt = Date.now() + PROCESS_STATE_POLL_MS;
983
+ survivingGroups = this.survivingGroups();
984
+ now = Date.now();
985
+ }
986
+ if (this.exitedSettled && survivingGroups.length === 0) {
987
+ this.release();
988
+ if (this.cleanupProofError) throw this.cleanupProofError;
989
+ this.throwForUncleanExit(this.exitInfo);
990
+ return;
991
+ }
992
+ if (!escalated && (this.forceKillRequested || now >= graceDeadline)) {
993
+ if (!this.rootHasExited && this.knownGroups.has(rootPid)) {
994
+ await this.mergeAsynchronousSnapshot(rootPid, false);
995
+ }
996
+ escalated = true;
997
+ rootSignalled = this.signalKnownGroups("SIGKILL");
998
+ this.signalDirectRootIfNeeded("SIGKILL", rootSignalled);
999
+ continue;
1000
+ }
1001
+ if (now >= exitDeadline) {
1002
+ const groups = survivingGroups.join(",") || "none";
1003
+ const proof = this.cleanupProofError ? `; ${this.cleanupProofError.message}` : "";
1004
+ throw new Error(
1005
+ `ACP child pid=${rootPid} did not exit with its owned process groups within ${EXIT_DEADLINE_MS}ms (surviving pgids=${groups})${proof}`
1006
+ );
1007
+ }
1008
+ await delay(
1009
+ Math.min(
1010
+ PROCESS_POLL_MS,
1011
+ (escalated ? exitDeadline : graceDeadline) - now
1012
+ )
1013
+ );
1014
+ if (this.forceKillRequested) escalated = true;
1015
+ }
1016
+ }
1017
+ async terminateWindowsTree(rootPid) {
1018
+ const startedAt = Date.now();
1019
+ let treeKillError;
1020
+ try {
1021
+ await taskkill(rootPid);
1022
+ } catch (error) {
1023
+ treeKillError = toError(error);
1024
+ this.killDirectChildSync();
1025
+ }
1026
+ const remainingMs = Math.max(
1027
+ 1,
1028
+ EXIT_DEADLINE_MS - (Date.now() - startedAt)
1029
+ );
1030
+ const exitInfo = await waitForPromise(this.exited, remainingMs).catch(
1031
+ () => {
1032
+ throw new Error(
1033
+ `ACP child pid=${rootPid} did not exit within ${EXIT_DEADLINE_MS}ms` + (treeKillError ? `; ${treeKillError.message}` : "")
1034
+ );
1035
+ }
1036
+ );
1037
+ this.release();
1038
+ if (treeKillError) {
1039
+ throw new Error(
1040
+ `ACP child pid=${rootPid} process-tree cleanup failed: ${treeKillError.message}`
1041
+ );
1042
+ }
1043
+ this.throwForUncleanExit(exitInfo);
1044
+ }
1045
+ async mergeAsynchronousSnapshot(rootPid, initial) {
1046
+ try {
1047
+ const table = parseProcessTable(await queryProcessTable());
1048
+ if (this.rootHasExited) {
1049
+ if (initial && !this.forceKillRequested) {
1050
+ this.recordCleanupProofError(
1051
+ `ACP child pid=${rootPid} exited before its initial process-tree snapshot completed`
1052
+ );
1053
+ }
1054
+ return;
1055
+ }
1056
+ const snapshot = collectOwnership(table, rootPid);
1057
+ this.mergeSnapshot(snapshot);
1058
+ if (snapshot.truncated) {
1059
+ this.recordCleanupProofError(
1060
+ `ACP child pid=${rootPid} process-tree snapshot exceeded ${MAX_OWNED_PROCESSES} processes or depth ${MAX_OWNERSHIP_DEPTH}`
1061
+ );
1062
+ }
1063
+ if (initial && !snapshot.rootSeen) {
1064
+ this.recordCleanupProofError(
1065
+ `ACP child pid=${rootPid} was absent from the initial process-tree snapshot`
1066
+ );
1067
+ } else if (initial && !snapshot.rootIsGroupLeader) {
1068
+ this.recordCleanupProofError(
1069
+ `ACP child pid=${rootPid} was not an isolated process-group leader`
1070
+ );
1071
+ }
1072
+ } catch (error) {
1073
+ this.recordCleanupProofError(
1074
+ `ACP child pid=${rootPid} process-tree snapshot failed: ${toError(error).message}`
1075
+ );
1076
+ }
1077
+ }
1078
+ mergeSynchronousSnapshot() {
1079
+ const rootPid = this.rootPid;
1080
+ if (!rootPid || process.platform === "win32" || this.rootHasExited) return;
1081
+ try {
1082
+ const table = parseProcessTable(queryProcessTableSync());
1083
+ this.mergeSnapshot(collectOwnership(table, rootPid));
1084
+ } catch {
1085
+ }
1086
+ }
1087
+ mergeSnapshot(snapshot) {
1088
+ if (!snapshot.rootIsGroupLeader) {
1089
+ const rootPid = this.rootPid;
1090
+ if (snapshot.rootSeen && rootPid) this.knownGroups.delete(rootPid);
1091
+ return;
1092
+ }
1093
+ for (const group of snapshot.groups) this.knownGroups.add(group);
1094
+ }
1095
+ signalKnownGroups(signal) {
1096
+ const rootPid = this.rootPid;
1097
+ let rootSignalled = false;
1098
+ const groups = [...this.knownGroups].sort((left, right) => {
1099
+ if (left === rootPid) return 1;
1100
+ if (right === rootPid) return -1;
1101
+ return right - left;
1102
+ });
1103
+ for (const group of groups) {
1104
+ try {
1105
+ process.kill(-group, signal);
1106
+ if (group === rootPid) rootSignalled = true;
1107
+ } catch (error) {
1108
+ if (isErrno(error, "ESRCH")) {
1109
+ this.knownGroups.delete(group);
1110
+ continue;
1111
+ }
1112
+ this.recordCleanupProofError(
1113
+ `ACP child pid=${rootPid ?? "unknown"} could not send ${signal} to pgid=${group}: ${toError(error).message}`
1114
+ );
1115
+ }
1116
+ }
1117
+ return rootSignalled;
1118
+ }
1119
+ survivingGroups() {
1120
+ const surviving = [];
1121
+ for (const group of this.knownGroups) {
1122
+ try {
1123
+ process.kill(-group, 0);
1124
+ surviving.push(group);
1125
+ } catch (error) {
1126
+ if (isErrno(error, "ESRCH")) {
1127
+ this.knownGroups.delete(group);
1128
+ continue;
1129
+ }
1130
+ surviving.push(group);
1131
+ if (!isErrno(error, "EPERM")) {
1132
+ this.recordCleanupProofError(
1133
+ `ACP child pid=${this.rootPid ?? "unknown"} could not inspect pgid=${group}: ${toError(error).message}`
1134
+ );
1135
+ }
1136
+ }
1137
+ }
1138
+ return surviving;
1139
+ }
1140
+ recordCleanupProofError(message) {
1141
+ this.cleanupProofError ??= new Error(message);
1142
+ }
1143
+ async pruneTerminalGroups(groups, timeoutMs = PROCESS_QUERY_TIMEOUT_MS) {
1144
+ try {
1145
+ const table = parseProcessTable(await queryProcessTable(timeoutMs));
1146
+ const targets = new Set(groups);
1147
+ const terminalGroups = /* @__PURE__ */ new Set();
1148
+ const liveGroups = /* @__PURE__ */ new Set();
1149
+ for (const row of table.rowsByPid.values()) {
1150
+ if (!targets.has(row.pgid)) continue;
1151
+ if (row.terminal) terminalGroups.add(row.pgid);
1152
+ else liveGroups.add(row.pgid);
1153
+ }
1154
+ for (const group of terminalGroups) {
1155
+ if (!liveGroups.has(group)) this.knownGroups.delete(group);
1156
+ }
1157
+ } catch {
1158
+ }
1159
+ }
1160
+ releaseWhenGroupsExit() {
1161
+ if (this.released || this.releasePollTimer || this.releaseStateCheckInFlight || this.terminating && !this.terminationSettled) {
1162
+ return;
1163
+ }
1164
+ const survivingGroups = this.survivingGroups();
1165
+ if (survivingGroups.length === 0) {
1166
+ this.release();
1167
+ return;
1168
+ }
1169
+ this.releaseStateCheckInFlight = true;
1170
+ void this.pruneTerminalGroups(survivingGroups).finally(() => {
1171
+ this.releaseStateCheckInFlight = false;
1172
+ if (this.released) return;
1173
+ if (this.terminating && !this.terminationSettled) return;
1174
+ if (this.survivingGroups().length === 0) {
1175
+ this.release();
1176
+ return;
1177
+ }
1178
+ this.releasePollTimer = setTimeout(() => {
1179
+ this.releasePollTimer = void 0;
1180
+ this.releaseWhenGroupsExit();
1181
+ }, PROCESS_STATE_POLL_MS);
1182
+ this.releasePollTimer.unref();
1183
+ });
1184
+ }
1185
+ throwForUncleanExit(exitInfo) {
1186
+ if (exitInfo && (exitInfo.exitCode !== 0 || exitInfo.signalCode !== null)) {
1187
+ throw new Error(
1188
+ `ACP child pid=${this.child.pid ?? "unknown"} exited uncleanly during shutdown (code=${exitInfo.exitCode ?? "none"}, signal=${exitInfo.signalCode ?? "none"})`
1189
+ );
1190
+ }
1191
+ }
1192
+ };
1193
+ function parseProcessTable(stdout) {
1194
+ const rowsByPid = /* @__PURE__ */ new Map();
1195
+ const childrenByParent = /* @__PURE__ */ new Map();
1196
+ for (const line of stdout.split("\n")) {
1197
+ const match = line.trim().match(/^(\d+)\s+(\d+)\s+(\d+)(?:\s+(\S+)(?:\s+(\d+))?)?$/u);
1198
+ if (!match) continue;
1199
+ const pid = Number.parseInt(match[1], 10);
1200
+ const ppid = Number.parseInt(match[2], 10);
1201
+ const pgid = Number.parseInt(match[3], 10);
1202
+ const state = match[4];
1203
+ const threadCount = match[5] ? Number.parseInt(match[5], 10) : void 0;
1204
+ if (!Number.isSafeInteger(pid) || !Number.isSafeInteger(ppid) || !Number.isSafeInteger(pgid) || pid <= 0 || ppid < 0 || pgid <= 0) {
1205
+ continue;
1206
+ }
1207
+ const terminal = state?.startsWith("X") === true || state?.startsWith("Z") === true && (process.platform !== "linux" || threadCount === 1);
1208
+ rowsByPid.set(pid, { pgid, terminal });
1209
+ const children = childrenByParent.get(ppid);
1210
+ if (children) children.push(pid);
1211
+ else childrenByParent.set(ppid, [pid]);
1212
+ }
1213
+ if (rowsByPid.size === 0) {
1214
+ throw new Error("process-table query returned no parseable rows");
1215
+ }
1216
+ return { childrenByParent, rowsByPid };
1217
+ }
1218
+ __name(parseProcessTable, "parseProcessTable");
1219
+ function collectOwnership(table, rootPid) {
1220
+ const groups = /* @__PURE__ */ new Set();
1221
+ const visited = /* @__PURE__ */ new Set();
1222
+ const queue = [{ depth: 0, pid: rootPid }];
1223
+ let truncated = false;
1224
+ while (queue.length > 0) {
1225
+ const current = queue.shift();
1226
+ if (visited.has(current.pid)) continue;
1227
+ if (visited.size >= MAX_OWNED_PROCESSES) {
1228
+ truncated = true;
1229
+ break;
1230
+ }
1231
+ visited.add(current.pid);
1232
+ const row = table.rowsByPid.get(current.pid);
1233
+ if (row) groups.add(row.pgid);
1234
+ const children = table.childrenByParent.get(current.pid) ?? [];
1235
+ if (current.depth >= MAX_OWNERSHIP_DEPTH) {
1236
+ if (children.length > 0) truncated = true;
1237
+ continue;
1238
+ }
1239
+ for (const pid of children) {
1240
+ queue.push({ depth: current.depth + 1, pid });
1241
+ }
1242
+ }
1243
+ const root = table.rowsByPid.get(rootPid);
1244
+ return {
1245
+ groups,
1246
+ rootIsGroupLeader: root?.pgid === rootPid,
1247
+ rootSeen: root !== void 0,
1248
+ truncated
1249
+ };
1250
+ }
1251
+ __name(collectOwnership, "collectOwnership");
1252
+ function queryProcessTable(timeoutMs = PROCESS_QUERY_TIMEOUT_MS) {
1253
+ return runExecFile(POSIX_PS, posixPsArgs(), {
1254
+ ...STRING_EXEC_OPTIONS,
1255
+ timeout: Math.max(1, Math.min(PROCESS_QUERY_TIMEOUT_MS, timeoutMs))
1256
+ });
1257
+ }
1258
+ __name(queryProcessTable, "queryProcessTable");
1259
+ function queryProcessTableSync() {
1260
+ const result = spawnSync(POSIX_PS, posixPsArgs(), STRING_EXEC_OPTIONS);
1261
+ if (result.error) throw result.error;
1262
+ if (result.status !== 0) {
1263
+ throw new Error(`ps exited with status ${result.status ?? "unknown"}`);
1264
+ }
1265
+ return result.stdout;
1266
+ }
1267
+ __name(queryProcessTableSync, "queryProcessTableSync");
1268
+ function posixPsArgs() {
1269
+ const columns = process.platform === "linux" ? "pid=,ppid=,pgid=,state=,nlwp=" : "pid=,ppid=,pgid=,state=";
1270
+ return ["-A", "-o", columns];
1271
+ }
1272
+ __name(posixPsArgs, "posixPsArgs");
1273
+ function taskkill(rootPid) {
1274
+ return runExecFile(
1275
+ WINDOWS_TASKKILL,
1276
+ ["/f", "/t", "/pid", String(rootPid)],
1277
+ STRING_EXEC_OPTIONS
1278
+ );
1279
+ }
1280
+ __name(taskkill, "taskkill");
1281
+ function taskkillSync(rootPid) {
1282
+ try {
1283
+ const result = spawnSync(
1284
+ WINDOWS_TASKKILL,
1285
+ ["/f", "/t", "/pid", String(rootPid)],
1286
+ STRING_EXEC_OPTIONS
1287
+ );
1288
+ return !result.error && result.status === 0;
1289
+ } catch {
1290
+ return false;
1291
+ }
1292
+ }
1293
+ __name(taskkillSync, "taskkillSync");
1294
+ function runExecFile(file, args, options) {
1295
+ return new Promise((resolve, reject) => {
1296
+ execFile(file, args, options, (error, stdout) => {
1297
+ if (error) reject(error);
1298
+ else resolve(stdout);
1299
+ });
1300
+ });
1301
+ }
1302
+ __name(runExecFile, "runExecFile");
1303
+ function waitForPromise(promise, timeoutMs) {
1304
+ let timer;
1305
+ const timeout = new Promise((_, reject) => {
1306
+ timer = setTimeout(() => reject(new Error("deadline exceeded")), timeoutMs);
1307
+ });
1308
+ return Promise.race([promise, timeout]).finally(() => {
1309
+ if (timer) clearTimeout(timer);
1310
+ });
1311
+ }
1312
+ __name(waitForPromise, "waitForPromise");
1313
+ function delay(ms) {
1314
+ return new Promise((resolve) => setTimeout(resolve, Math.max(1, ms)));
1315
+ }
1316
+ __name(delay, "delay");
1317
+ function isErrno(error, code) {
1318
+ return error !== null && typeof error === "object" && "code" in error && error.code === code;
1319
+ }
1320
+ __name(isErrno, "isErrno");
1321
+ function toError(error) {
1322
+ return error instanceof Error ? error : new Error(String(error));
1323
+ }
1324
+ __name(toError, "toError");
1325
+
1326
+ // packages/acp-bridge/src/json-string-bytes.ts
1327
+ init_esbuild_shims();
1328
+ function estimateJsonStringBytes(value, limitBytes) {
1329
+ const unescapedBytes = Buffer.byteLength(value, "utf8") + 2;
1330
+ if (unescapedBytes > limitBytes) return limitBytes + 1;
1331
+ if (!/["\\]|[^ -\ud7ff\ue000-\uffff]/u.test(value)) {
1332
+ return unescapedBytes;
1333
+ }
1334
+ let bytes = 2;
1335
+ for (let index = 0; index < value.length; index++) {
1336
+ const code = value.charCodeAt(index);
1337
+ if (code === 34 || code === 92) {
1338
+ bytes += 2;
1339
+ } else if (code <= 31) {
1340
+ bytes += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
1341
+ } else if (code >= 55296 && code <= 56319) {
1342
+ const next = value.charCodeAt(index + 1);
1343
+ if (next >= 56320 && next <= 57343) {
1344
+ bytes += 4;
1345
+ index++;
1346
+ } else {
1347
+ bytes += 6;
1348
+ }
1349
+ } else if (code >= 56320 && code <= 57343) {
1350
+ bytes += 6;
1351
+ } else if (code <= 127) {
1352
+ bytes++;
1353
+ } else if (code <= 2047) {
1354
+ bytes += 2;
1355
+ } else {
1356
+ bytes += 3;
1357
+ }
1358
+ if (bytes > limitBytes) return limitBytes + 1;
1359
+ }
1360
+ return bytes;
1361
+ }
1362
+ __name(estimateJsonStringBytes, "estimateJsonStringBytes");
1363
+
1364
+ // packages/acp-bridge/src/spawnChannel.ts
1365
+ var cachedMemoryArgs;
1366
+ var DAEMON_ACP_NDJSON_LIMITS = Object.freeze({
1367
+ maxFrameBytes: 64 * 1024 * 1024,
1368
+ maxQueuedMessages: 256,
1369
+ maxQueuedBytes: 64 * 1024 * 1024
1370
+ });
1371
+ var daemonClientParamValidators = /* @__PURE__ */ new Map([
1372
+ [CLIENT_METHODS.fs_read_text_file, zReadTextFileRequest],
1373
+ [CLIENT_METHODS.fs_write_text_file, zWriteTextFileRequest],
1374
+ [CLIENT_METHODS.session_request_permission, zRequestPermissionRequest],
1375
+ [CLIENT_METHODS.session_update, zSessionNotification],
1376
+ [CLIENT_METHODS.terminal_create, zCreateTerminalRequest],
1377
+ [CLIENT_METHODS.terminal_kill, zKillTerminalCommandRequest],
1378
+ [CLIENT_METHODS.terminal_output, zTerminalOutputRequest],
1379
+ [CLIENT_METHODS.terminal_release, zReleaseTerminalRequest],
1380
+ [CLIENT_METHODS.terminal_wait_for_exit, zWaitForTerminalExitRequest]
1381
+ ]);
1382
+ function validateDaemonInboundMessage(message) {
1383
+ if (!("method" in message)) return true;
1384
+ const validator = daemonClientParamValidators.get(message.method);
1385
+ return !validator || validator.safeParse(message.params).success;
1386
+ }
1387
+ __name(validateDaemonInboundMessage, "validateDaemonInboundMessage");
1388
+ var PreparedResponseBudget = class {
1389
+ constructor(limits) {
1390
+ this.limits = limits;
1391
+ }
1392
+ static {
1393
+ __name(this, "PreparedResponseBudget");
1394
+ }
1395
+ objectCharges = /* @__PURE__ */ new WeakMap();
1396
+ primitiveCharges = /* @__PURE__ */ new Map();
1397
+ retainedCount = 0;
1398
+ retainedBytes = 0;
1399
+ closed = false;
1400
+ reserve(value) {
1401
+ if (this.closed) return;
1402
+ const availableBytes = Math.max(
1403
+ 0,
1404
+ this.limits.maxQueuedBytes - this.retainedBytes
1405
+ );
1406
+ const envelopeBytes = Math.min(2048, this.limits.maxQueuedBytes);
1407
+ const charge = envelopeBytes + estimatePreparedResponseBytes(
1408
+ value,
1409
+ Math.max(0, availableBytes - envelopeBytes)
1410
+ );
1411
+ if (this.retainedCount >= this.limits.maxQueuedMessages || charge > availableBytes) {
1412
+ throw new NdJsonQueueLimitError(
1413
+ this.limits.maxQueuedMessages,
1414
+ this.limits.maxQueuedBytes,
1415
+ charge,
1416
+ availableBytes
1417
+ );
1418
+ }
1419
+ const charges = this.getCharges(value, true);
1420
+ charges.push(charge);
1421
+ this.retainedCount++;
1422
+ this.retainedBytes += charge;
1423
+ }
1424
+ releaseMessage(message) {
1425
+ if (!isPlainRecord(message) || Object.hasOwn(message, "method") || !Object.hasOwn(message, "id")) {
1426
+ return;
1427
+ }
1428
+ const value = Object.hasOwn(message, "result") ? message["result"] : message["error"];
1429
+ const charges = this.getCharges(value, false);
1430
+ if (!charges) return;
1431
+ const charge = charges.shift();
1432
+ if (charge === void 0) return;
1433
+ if (charges.length === 0 && !isObjectValue(value)) {
1434
+ this.primitiveCharges.delete(value);
1435
+ }
1436
+ this.retainedCount--;
1437
+ this.retainedBytes -= charge;
1438
+ }
1439
+ close() {
1440
+ this.closed = true;
1441
+ this.objectCharges = /* @__PURE__ */ new WeakMap();
1442
+ this.primitiveCharges.clear();
1443
+ this.retainedCount = 0;
1444
+ this.retainedBytes = 0;
1445
+ }
1446
+ getCharges(value, create) {
1447
+ const charges = isObjectValue(value) ? this.objectCharges.get(value) : this.primitiveCharges.get(value);
1448
+ if (charges || !create) return charges;
1449
+ const created = [];
1450
+ if (isObjectValue(value)) {
1451
+ this.objectCharges.set(value, created);
1452
+ } else {
1453
+ this.primitiveCharges.set(value, created);
1454
+ }
1455
+ return created;
1456
+ }
1457
+ };
1458
+ var OutboundOperationBudget = class {
1459
+ constructor(limits) {
1460
+ this.limits = limits;
1461
+ }
1462
+ static {
1463
+ __name(this, "OutboundOperationBudget");
1464
+ }
1465
+ retainedCount = 0;
1466
+ retainedBytes = 0;
1467
+ generation = 0;
1468
+ closed = false;
1469
+ reserve(value) {
1470
+ if (this.closed) return () => {
1471
+ };
1472
+ const availableBytes = Math.max(
1473
+ 0,
1474
+ this.limits.maxQueuedBytes - this.retainedBytes
1475
+ );
1476
+ const envelopeBytes = Math.min(2048, this.limits.maxQueuedBytes);
1477
+ const charge = envelopeBytes + estimatePreparedResponseBytes(
1478
+ value,
1479
+ Math.max(0, availableBytes - envelopeBytes)
1480
+ );
1481
+ if (this.retainedCount >= this.limits.maxQueuedMessages || charge > availableBytes) {
1482
+ throw new NdJsonQueueLimitError(
1483
+ this.limits.maxQueuedMessages,
1484
+ this.limits.maxQueuedBytes,
1485
+ charge,
1486
+ availableBytes
1487
+ );
1488
+ }
1489
+ this.retainedCount++;
1490
+ this.retainedBytes += charge;
1491
+ const generation = this.generation;
1492
+ let active = true;
1493
+ return () => {
1494
+ if (!active) return;
1495
+ active = false;
1496
+ if (this.closed || this.generation !== generation) return;
1497
+ this.retainedCount--;
1498
+ this.retainedBytes -= charge;
1499
+ };
1500
+ }
1501
+ close() {
1502
+ this.closed = true;
1503
+ this.generation++;
1504
+ this.retainedCount = 0;
1505
+ this.retainedBytes = 0;
1506
+ }
1507
+ };
1508
+ function* enumerableOwnKeys(value) {
1509
+ for (const key in value) {
1510
+ if (Object.hasOwn(value, key)) yield key;
1511
+ }
1512
+ }
1513
+ __name(enumerableOwnKeys, "enumerableOwnKeys");
1514
+ function estimatePreparedResponseBytes(value, limitBytes) {
1515
+ let bytes = 0;
1516
+ const stack = [{ kind: "value", value }];
1517
+ const seen = /* @__PURE__ */ new WeakSet();
1518
+ while (stack.length > 0) {
1519
+ const frame = stack.pop();
1520
+ if (frame.kind === "array") {
1521
+ if (frame.index >= frame.value.length) continue;
1522
+ if (frame.index > 0) bytes++;
1523
+ if (bytes > limitBytes) return limitBytes + 1;
1524
+ const descriptor = Object.getOwnPropertyDescriptor(
1525
+ frame.value,
1526
+ String(frame.index)
1527
+ );
1528
+ if (descriptor?.get || descriptor?.set) return limitBytes + 1;
1529
+ stack.push({ ...frame, index: frame.index + 1 });
1530
+ stack.push({ kind: "value", value: descriptor?.value });
1531
+ continue;
1532
+ }
1533
+ if (frame.kind === "record") {
1534
+ const next = frame.keys.next();
1535
+ if (next.done) continue;
1536
+ const descriptor = Object.getOwnPropertyDescriptor(
1537
+ frame.value,
1538
+ next.value
1539
+ );
1540
+ if (!descriptor || descriptor.get || descriptor.set) {
1541
+ return limitBytes + 1;
1542
+ }
1543
+ bytes += (frame.first ? 0 : 1) + estimateJsonStringBytes(next.value, Math.max(0, limitBytes - bytes)) + 1;
1544
+ if (bytes > limitBytes) return limitBytes + 1;
1545
+ stack.push({ ...frame, first: false });
1546
+ stack.push({ kind: "value", value: descriptor.value });
1547
+ continue;
1548
+ }
1549
+ const current = frame.value;
1550
+ if (current === null) {
1551
+ bytes += 4;
1552
+ } else if (current === void 0) {
1553
+ bytes += 4;
1554
+ } else if (typeof current === "string") {
1555
+ bytes += estimateJsonStringBytes(
1556
+ current,
1557
+ Math.max(0, limitBytes - bytes)
1558
+ );
1559
+ } else if (typeof current === "number") {
1560
+ bytes += 24;
1561
+ } else if (typeof current === "boolean") {
1562
+ bytes += 5;
1563
+ } else if (Array.isArray(current)) {
1564
+ if (seen.has(current) || Object.hasOwn(current, "toJSON")) {
1565
+ return limitBytes + 1;
1566
+ }
1567
+ seen.add(current);
1568
+ bytes += 2;
1569
+ stack.push({ kind: "array", value: current, index: 0 });
1570
+ } else if (isPlainRecord(current)) {
1571
+ if (seen.has(current) || Object.hasOwn(current, "toJSON")) {
1572
+ return limitBytes + 1;
1573
+ }
1574
+ seen.add(current);
1575
+ bytes += 2;
1576
+ stack.push({
1577
+ kind: "record",
1578
+ value: current,
1579
+ keys: enumerableOwnKeys(current),
1580
+ first: true
1581
+ });
1582
+ } else {
1583
+ return limitBytes + 1;
1584
+ }
1585
+ if (bytes > limitBytes) return limitBytes + 1;
1586
+ }
1587
+ return Math.max(1, bytes);
1588
+ }
1589
+ __name(estimatePreparedResponseBytes, "estimatePreparedResponseBytes");
1590
+ function isObjectValue(value) {
1591
+ return typeof value === "object" && value !== null;
1592
+ }
1593
+ __name(isObjectValue, "isObjectValue");
1594
+ function isPlainRecord(value) {
1595
+ if (!isObjectValue(value) || Array.isArray(value)) return false;
1596
+ const prototype = Object.getPrototypeOf(value);
1597
+ return prototype === Object.prototype || prototype === null;
1598
+ }
1599
+ __name(isPlainRecord, "isPlainRecord");
1600
+ function getAcpMemoryArgs() {
1601
+ if (cachedMemoryArgs) return cachedMemoryArgs;
1602
+ const constrainedMemory = process.constrainedMemory;
1603
+ const constrained = typeof constrainedMemory === "function" ? constrainedMemory() : 0;
1604
+ const totalBytes = constrained && constrained > 0 ? constrained : os.totalmem();
1605
+ const totalMB = Math.floor(totalBytes / (1024 * 1024));
1606
+ const targetMB = Math.min(Math.floor(totalMB * 0.5), 16384);
1607
+ const currentLimitMB = Math.floor(
1608
+ getHeapStatistics().heap_size_limit / (1024 * 1024)
1609
+ );
1610
+ cachedMemoryArgs = [
1611
+ ...targetMB > currentLimitMB ? [`--max-old-space-size=${targetMB}`] : [],
1612
+ "--expose-gc"
1613
+ ];
1614
+ return cachedMemoryArgs;
1615
+ }
1616
+ __name(getAcpMemoryArgs, "getAcpMemoryArgs");
1617
+ function createStderrForwarder(opts) {
1618
+ const { prefix, onDiagnosticLine } = opts;
1619
+ const STDERR_LINE_CAP_CHARS = 64 * 1024;
1620
+ let buf = "";
1621
+ const flush = /* @__PURE__ */ __name((line) => {
1622
+ if (line.length > 0) {
1623
+ const safe = redactLogCredentials(line);
1624
+ process.stderr.write(prefix + safe + "\n");
1625
+ if (onDiagnosticLine) onDiagnosticLine(prefix + safe, "warn");
1626
+ }
1627
+ }, "flush");
1628
+ return {
1629
+ onData(chunk) {
1630
+ buf += chunk;
1631
+ let nl = buf.indexOf("\n");
1632
+ while (nl !== -1) {
1633
+ flush(buf.slice(0, nl));
1634
+ buf = buf.slice(nl + 1);
1635
+ nl = buf.indexOf("\n");
1636
+ }
1637
+ while (buf.length > STDERR_LINE_CAP_CHARS) {
1638
+ const truncated = redactLogCredentials(buf.slice(0, STDERR_LINE_CAP_CHARS)) + " [truncated]";
1639
+ process.stderr.write(prefix + truncated + "\n");
1640
+ if (onDiagnosticLine) onDiagnosticLine(prefix + truncated, "warn");
1641
+ buf = buf.slice(STDERR_LINE_CAP_CHARS);
1642
+ }
1643
+ },
1644
+ onEnd() {
1645
+ if (buf.length > 0) flush(buf);
1646
+ }
1647
+ };
1648
+ }
1649
+ __name(createStderrForwarder, "createStderrForwarder");
1650
+ function createSpawnChannelFactory(options = {}) {
1651
+ if (options.pipeLimits) validateNdJsonStreamLimits(options.pipeLimits);
1652
+ const processRegistry = options.processRegistry ?? new ProcessRegistry();
1653
+ return async (workspaceCwd, childEnvOverrides, signal) => {
1654
+ if (signal?.aborted) {
1655
+ throw signal.reason instanceof Error ? signal.reason : new Error("ACP channel spawn was aborted");
1656
+ }
1657
+ const sourceEnv = options.sourceEnv ?? process.env;
1658
+ const cliEntry = sourceEnv["QWEN_CLI_ENTRY"] || process.argv[1];
1659
+ if (!cliEntry) {
1660
+ throw new MissingCliEntryError();
1661
+ }
1662
+ const childEnv = scrubChildEnv(
1663
+ sourceEnv,
1664
+ SCRUBBED_CHILD_ENV_KEYS,
1665
+ childEnvOverrides
1666
+ );
1667
+ childEnv["QWEN_CODE_NO_RELAUNCH"] = "true";
1668
+ childEnv["QWEN_CODE_SERVE"] = "1";
1669
+ const execArgs = process.execArgv.filter(
1670
+ (a) => !/^--inspect(-brk)?($|=)/.test(a)
1671
+ );
1672
+ const reservation = processRegistry.reserve();
1673
+ let child;
1674
+ try {
1675
+ options.childHeapPolicy?.decide(processRegistry.committedProcessCount);
1676
+ const memoryArgs = getAcpMemoryArgs();
1677
+ child = spawn(
1678
+ process.execPath,
1679
+ [
1680
+ ...execArgs,
1681
+ ...memoryArgs,
1682
+ cliEntry,
1683
+ "--acp",
1684
+ ...options.extraArgs ?? []
1685
+ ],
1686
+ {
1687
+ cwd: workspaceCwd,
1688
+ stdio: ["pipe", "pipe", "pipe"],
1689
+ detached: process.platform !== "win32",
1690
+ windowsHide: true,
1691
+ env: childEnv
1692
+ }
1693
+ );
1694
+ } catch (error) {
1695
+ reservation.cancel();
1696
+ throw error;
1697
+ }
1698
+ const trackedChild = reservation.attach(child, { ownsProcessTree: true });
1699
+ const abortSpawn = /* @__PURE__ */ __name(() => {
1700
+ try {
1701
+ trackedChild.killSync();
1702
+ } catch {
1703
+ }
1704
+ }, "abortSpawn");
1705
+ signal?.addEventListener("abort", abortSpawn, { once: true });
1706
+ void trackedChild.exited.then(
1707
+ () => signal?.removeEventListener("abort", abortSpawn),
1708
+ () => signal?.removeEventListener("abort", abortSpawn)
1709
+ );
1710
+ if (signal?.aborted) {
1711
+ abortSpawn();
1712
+ throw signal.reason instanceof Error ? signal.reason : new Error("ACP channel spawn was aborted");
1713
+ }
1714
+ if (child.stderr) {
1715
+ const prefix = `[serve pid=${child.pid} cwd=${workspaceCwd}] `;
1716
+ const forwarder = createStderrForwarder({
1717
+ prefix,
1718
+ onDiagnosticLine: options.onDiagnosticLine
1719
+ });
1720
+ child.stderr.setEncoding("utf8");
1721
+ child.stderr.on("data", forwarder.onData);
1722
+ child.stderr.on("end", forwarder.onEnd);
1723
+ child.stderr.on("error", () => {
1724
+ });
1725
+ }
1726
+ if (!child.stdin || !child.stdout) {
1727
+ trackedChild.killSync();
1728
+ throw new Error(
1729
+ "Spawned ACP child has no stdin/stdout \u2014 cannot establish NDJSON channel."
1730
+ );
1731
+ }
1732
+ const writable = Writable.toWeb(child.stdin);
1733
+ const readable = Readable.toWeb(child.stdout);
1734
+ const preparedResponses = options.pipeLimits ? new PreparedResponseBudget(options.pipeLimits) : void 0;
1735
+ const outboundOperations = options.pipeLimits ? new OutboundOperationBudget(options.pipeLimits) : void 0;
1736
+ let reportTransportFailure;
1737
+ let transportFailureReported = false;
1738
+ const transportFailed = options.pipeLimits ? new Promise((resolve) => {
1739
+ reportTransportFailure = resolve;
1740
+ }) : void 0;
1741
+ const failTransport = options.pipeLimits ? (error) => {
1742
+ if (transportFailureReported) return;
1743
+ transportFailureReported = true;
1744
+ reportTransportFailure?.(error);
1745
+ reportTransportFailure = void 0;
1746
+ preparedResponses?.close();
1747
+ outboundOperations?.close();
1748
+ child.stdout?.destroy();
1749
+ child.stdin?.destroy();
1750
+ void trackedChild.terminate().catch(() => {
1751
+ });
1752
+ options.pipeHooks?.onTransportError?.(error);
1753
+ } : void 0;
1754
+ const pipeHooks = options.pipeLimits ? {
1755
+ ...options.pipeHooks,
1756
+ onMessageObserved: /* @__PURE__ */ __name((observation) => {
1757
+ if (observation.direction === "sent") {
1758
+ preparedResponses?.releaseMessage(observation.message);
1759
+ }
1760
+ options.pipeHooks?.onMessageObserved?.(observation);
1761
+ }, "onMessageObserved"),
1762
+ onTransportError: failTransport
1763
+ } : options.pipeHooks;
1764
+ const stream = ndJsonStream(
1765
+ writable,
1766
+ readable,
1767
+ pipeHooks,
1768
+ options.pipeLimits,
1769
+ options.pipeLimits ? validateDaemonInboundMessage : void 0,
1770
+ options.pipeLimits !== void 0
1771
+ );
1772
+ return {
1773
+ stream,
1774
+ ...transportFailed ? { transportFailed } : {},
1775
+ ...failTransport && options.pipeLimits ? {
1776
+ transportGuard: {
1777
+ maxActiveHandlers: options.pipeLimits.maxQueuedMessages,
1778
+ maxActiveHandlerBytes: options.pipeLimits.maxQueuedBytes,
1779
+ reserveOutboundOperation: /* @__PURE__ */ __name((value) => {
1780
+ try {
1781
+ return outboundOperations?.reserve(value) ?? (() => {
1782
+ });
1783
+ } catch (error) {
1784
+ failTransport(error);
1785
+ throw error;
1786
+ }
1787
+ }, "reserveOutboundOperation"),
1788
+ reservePreparedResponse: /* @__PURE__ */ __name((value) => {
1789
+ try {
1790
+ preparedResponses?.reserve(value);
1791
+ } catch (error) {
1792
+ failTransport(error);
1793
+ throw error;
1794
+ }
1795
+ }, "reservePreparedResponse"),
1796
+ fail: failTransport
1797
+ }
1798
+ } : {},
1799
+ kill: /* @__PURE__ */ __name(() => trackedChild.terminate(), "kill"),
1800
+ killSync: /* @__PURE__ */ __name(() => trackedChild.killSync(), "killSync"),
1801
+ exited: trackedChild.exited
1802
+ };
1803
+ };
1804
+ }
1805
+ __name(createSpawnChannelFactory, "createSpawnChannelFactory");
1806
+ var defaultSpawnChannelFactory = createSpawnChannelFactory();
1807
+ var SCRUBBED_CHILD_ENV_KEYS = /* @__PURE__ */ new Set([
1808
+ "QWEN_SERVER_TOKEN",
1809
+ "QWEN_CODE_SIMPLE",
1810
+ EXTERNAL_TOOL_GUARD_TOKEN_ENV
1811
+ ]);
1812
+ function scrubChildEnv(source, scrubbed, overrides) {
1813
+ const childEnv = { ...source };
1814
+ for (const key of scrubbed) {
1815
+ delete childEnv[key];
1816
+ }
1817
+ if (overrides) {
1818
+ for (const [key, value] of Object.entries(overrides)) {
1819
+ if (scrubbed.has(key)) continue;
1820
+ if (value === void 0) {
1821
+ delete childEnv[key];
1822
+ } else {
1823
+ childEnv[key] = value;
1824
+ }
1825
+ }
1826
+ }
1827
+ return childEnv;
1828
+ }
1829
+ __name(scrubChildEnv, "scrubChildEnv");
1830
+
1831
+ export {
1832
+ ndJsonStream,
1833
+ DAEMON_ACP_NDJSON_LIMITS,
1834
+ getAcpMemoryArgs,
1835
+ createStderrForwarder,
1836
+ createSpawnChannelFactory,
1837
+ defaultSpawnChannelFactory,
1838
+ scrubChildEnv
1839
+ };
1840
+ /**
1841
+ * @license
1842
+ * Copyright 2026 Qwen Team
1843
+ * SPDX-License-Identifier: Apache-2.0
1844
+ */
1845
+ /**
1846
+ * @license
1847
+ * Copyright 2025 Qwen Team
1848
+ * SPDX-License-Identifier: Apache-2.0
1849
+ */