@qwen-code/qwen-code 0.21.10 → 0.21.11

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 (367) hide show
  1. package/bundled/coordinate/SKILL.md +52 -0
  2. package/bundled/qc-helper/docs/configuration/model-providers.md +10 -8
  3. package/bundled/qc-helper/docs/extension/_meta.ts +1 -0
  4. package/bundled/qc-helper/docs/extension/agent-plugins.md +50 -0
  5. package/bundled/qc-helper/docs/extension/extension-releasing.md +3 -3
  6. package/bundled/qc-helper/docs/extension/introduction.md +17 -3
  7. package/bundled/qc-helper/docs/features/_meta.ts +1 -0
  8. package/bundled/qc-helper/docs/features/arena.md +4 -3
  9. package/bundled/qc-helper/docs/features/commands.md +7 -6
  10. package/bundled/qc-helper/docs/features/dual-output.md +5 -0
  11. package/bundled/qc-helper/docs/features/headless.md +8 -0
  12. package/bundled/qc-helper/docs/features/multi-agent-coordination.md +30 -0
  13. package/bundled/qc-helper/docs/qwen-serve.md +7 -7
  14. package/bundled/review/SKILL.md +17 -7
  15. package/chunks/{MaxSizedBox-FKXYULMW.js → MaxSizedBox-G7QPSZTF.js} +45 -44
  16. package/chunks/{StandaloneSessionPicker-OQS3M7AY.js → StandaloneSessionPicker-3CTEPV7S.js} +65 -64
  17. package/chunks/{acp-startup-profiler-VNTFWYAC.js → acp-startup-profiler-JMJBZDVO.js} +2 -2
  18. package/chunks/{acpAgent-AGS6HLQQ.js → acpAgent-43JURWOW.js} +1107 -285
  19. package/chunks/{agent-4NCVO27U.js → agent-MIY4LJJJ.js} +42 -41
  20. package/chunks/agent-headless-LWVA6GR5.js +87 -0
  21. package/chunks/{anthropicContentGenerator-D3Y4RFT4.js → anthropicContentGenerator-7HEP7Q5D.js} +8 -8
  22. package/chunks/{artifact-tool-N652YE4L.js → artifact-tool-M7UAJ5NT.js} +2 -2
  23. package/chunks/{askUserQuestion-ONW74PKJ.js → askUserQuestion-7G3LI3IZ.js} +2 -2
  24. package/chunks/{bridge-FHINXZMN.js → bridge-PTTJEBNP.js} +47 -46
  25. package/chunks/{ca-ZLKAB4K3.js → ca-4CQ6MYNQ.js} +2 -1
  26. package/chunks/{channel-management-service-PHELKOW2.js → channel-management-service-PQ6SU56M.js} +6 -6
  27. package/chunks/channel-settings-store-IKK34GMH.js +102 -0
  28. package/chunks/{channel-worker-group-WQP4RCDO.js → channel-worker-group-WBRE33ZV.js} +8 -7
  29. package/chunks/{channel-worker-manager-MRDFAKIM.js → channel-worker-manager-V4LYVTPH.js} +8 -7
  30. package/chunks/{channel-worker-supervisor-IVSDIMI4.js → channel-worker-supervisor-YDAGW2RP.js} +6 -5
  31. package/chunks/{chunk-2PLNY5TN.js → chunk-23GFHEM3.js} +4 -4
  32. package/chunks/{chunk-IIJEYBNH.js → chunk-25OFRBH2.js} +188 -58
  33. package/chunks/{chunk-F24A2JBM.js → chunk-2AAFGCWP.js} +690 -151
  34. package/chunks/{chunk-J6SZID63.js → chunk-2AZMF6G5.js} +2 -2
  35. package/chunks/{chunk-6LP743KE.js → chunk-2R2HYSUQ.js} +21 -102
  36. package/chunks/{chunk-DZUO626D.js → chunk-2XZWO53E.js} +3 -3
  37. package/chunks/{chunk-VKJ4KTPJ.js → chunk-3GCU5O2E.js} +1 -1
  38. package/chunks/{chunk-AQAJJMRR.js → chunk-3LHYTQ2R.js} +1 -1
  39. package/chunks/{chunk-QJMOAMXT.js → chunk-3SOTXJNO.js} +8 -8
  40. package/chunks/{chunk-URKIBIFC.js → chunk-45HPDU3F.js} +3 -3
  41. package/chunks/{chunk-OWMAZHIX.js → chunk-47FQVRCO.js} +1 -1
  42. package/chunks/{chunk-Z4JX4NSH.js → chunk-4C4QSXE3.js} +23 -23
  43. package/chunks/{chunk-IRZ2ZH72.js → chunk-4EX3DBFH.js} +4 -4
  44. package/chunks/{chunk-MFDYOYZZ.js → chunk-4MHDNGAV.js} +25 -2
  45. package/chunks/{chunk-ABVRJU3D.js → chunk-4PFKN7CQ.js} +7 -7
  46. package/chunks/{chunk-HV76SFIA.js → chunk-5HBFERG5.js} +3 -3
  47. package/chunks/{chunk-WAUGQKUU.js → chunk-6LYDH7VT.js} +9 -5
  48. package/chunks/{chunk-S6HYI3MF.js → chunk-6S52N6PG.js} +2 -2
  49. package/chunks/{chunk-FVKHVJZQ.js → chunk-732MOPEM.js} +1 -1
  50. package/chunks/{chunk-OCSFNUU4.js → chunk-7QE3QFU3.js} +8 -8
  51. package/chunks/{chunk-WCG5O7IP.js → chunk-7SUQZ7QH.js} +2 -2
  52. package/chunks/{chunk-QG3FFJYU.js → chunk-AAOONL5N.js} +1 -1
  53. package/chunks/{chunk-VSFKIRRW.js → chunk-AKLY5M2C.js} +4 -4
  54. package/chunks/{chunk-UVX4Y6IN.js → chunk-AQHNAA7E.js} +1 -1
  55. package/chunks/{chunk-IBUGFUXC.js → chunk-BIXG46YI.js} +12 -12
  56. package/chunks/{chunk-4TRQPFDP.js → chunk-BJKREW56.js} +6 -8
  57. package/chunks/{chunk-D27I6YJT.js → chunk-BNRNVMOT.js} +27 -18
  58. package/chunks/{chunk-IWTMYQ32.js → chunk-BR6TUEKJ.js} +9 -8
  59. package/chunks/{chunk-Q3JQ7OSU.js → chunk-BTYS2JAY.js} +1 -1
  60. package/chunks/{chunk-H6XPXXMH.js → chunk-CQ35AJ4Z.js} +252 -254
  61. package/chunks/{chunk-COBO5EBO.js → chunk-CTQE2NB2.js} +1 -1
  62. package/chunks/{chunk-P3BJLFSZ.js → chunk-DEKY5Y7V.js} +3 -3
  63. package/chunks/{chunk-Y3OVRWRY.js → chunk-DM4C3OX5.js} +1 -1
  64. package/chunks/{chunk-YWPSGJFI.js → chunk-DSKLWQHC.js} +2 -2
  65. package/chunks/{chunk-KKBPOU75.js → chunk-EFIMD5VA.js} +1 -1
  66. package/chunks/{chunk-CTJLZLB5.js → chunk-EN2J77G7.js} +1 -1
  67. package/chunks/{chunk-67EWJE77.js → chunk-ENEEQMGM.js} +1 -1
  68. package/chunks/{chunk-AEL7KN2O.js → chunk-EOBM4T2Z.js} +1 -1
  69. package/chunks/{chunk-NDU63YLI.js → chunk-ESVSQKPY.js} +4 -4
  70. package/chunks/{chunk-CPG6P4GG.js → chunk-EYS3GGM3.js} +1 -1
  71. package/chunks/{chunk-4PYCZH2V.js → chunk-EYW54TBD.js} +3 -3
  72. package/chunks/{chunk-EBZ6BJTF.js → chunk-F4T5J34H.js} +1 -1
  73. package/chunks/{chunk-FOGU3LJX.js → chunk-F6AOBFUN.js} +1 -1
  74. package/chunks/{chunk-ZBVS26BY.js → chunk-FPGTNKCP.js} +7 -5
  75. package/chunks/{chunk-YF5MALI4.js → chunk-G64M7R2Y.js} +5 -5
  76. package/chunks/{chunk-EI3HZX6C.js → chunk-GJJQV4PY.js} +1 -1
  77. package/chunks/{chunk-CKASRHZI.js → chunk-GLWWPFTW.js} +1 -1
  78. package/chunks/{chunk-GM463R2B.js → chunk-GZGDJ4E6.js} +1 -1
  79. package/chunks/{chunk-W5UC37EE.js → chunk-HHGQGTJQ.js} +2 -0
  80. package/chunks/chunk-HHJLM3WQ.js +41 -0
  81. package/chunks/{chunk-ZRBMO3C7.js → chunk-HMCSRTDY.js} +1 -1
  82. package/chunks/{chunk-L2AFWWJE.js → chunk-HUE2M6VI.js} +50 -5
  83. package/chunks/{chunk-LLCWZQCU.js → chunk-HZV75ET2.js} +3 -3
  84. package/chunks/{chunk-6ZRFAKXK.js → chunk-IEP44U2R.js} +1 -1
  85. package/chunks/{chunk-AOHJKPKL.js → chunk-IQFYO5BF.js} +1 -1
  86. package/chunks/{chunk-UDXSXLER.js → chunk-IW6RQPQB.js} +14 -4
  87. package/chunks/{chunk-XCWO3SMQ.js → chunk-IX7CFQGA.js} +3 -3
  88. package/chunks/{chunk-O3EU6GMH.js → chunk-J4EVBAB3.js} +27 -4
  89. package/chunks/{chunk-ZZCWJWTF.js → chunk-JHMFKJEP.js} +1 -1
  90. package/chunks/{chunk-XVHYA33G.js → chunk-JKEO6OQY.js} +4 -4
  91. package/chunks/{chunk-6Q5ABMTU.js → chunk-JLYYGKRN.js} +23 -19
  92. package/chunks/{chunk-KID7K6H2.js → chunk-JOXXPM3X.js} +6 -6
  93. package/chunks/{chunk-E2FPSSKP.js → chunk-JPA7IDTE.js} +57 -13
  94. package/chunks/{chunk-OQTXYMKW.js → chunk-JS4Q5NG5.js} +3 -3
  95. package/chunks/{chunk-PBRVUF5B.js → chunk-K7JW6V5O.js} +1 -1
  96. package/chunks/{chunk-3P2LV43B.js → chunk-KCCODSAA.js} +3 -3
  97. package/chunks/{chunk-DREZZAZM.js → chunk-KCDQGIHS.js} +13 -5
  98. package/chunks/{chunk-UEOKWYGY.js → chunk-KFCTC5IJ.js} +11 -11
  99. package/chunks/{chunk-M6HMMKVG.js → chunk-KPVVWKF3.js} +1 -1
  100. package/chunks/{chunk-MVUQRLOH.js → chunk-KT4OWAAZ.js} +3 -3
  101. package/chunks/{chunk-W4RQUHY3.js → chunk-L2GTEEEU.js} +142 -23
  102. package/chunks/{chunk-Q3AL4JQ3.js → chunk-LA3FF7RO.js} +2 -2
  103. package/chunks/{chunk-DX3RGJMS.js → chunk-LT532KF4.js} +71 -12
  104. package/chunks/{chunk-JT7XS4YW.js → chunk-M2NMFAFR.js} +1 -1
  105. package/chunks/{chunk-YTFDX4PR.js → chunk-M6NDLY2T.js} +1 -1
  106. package/chunks/{chunk-MIKXJYZB.js → chunk-MCHGE3EC.js} +305 -291
  107. package/chunks/{chunk-Y4R47ZUH.js → chunk-MDQSCFAZ.js} +7 -7
  108. package/chunks/{chunk-EKPKKXY2.js → chunk-MLZCPGDX.js} +1 -1
  109. package/chunks/{chunk-OIVKILPI.js → chunk-MPBRV3UU.js} +3 -0
  110. package/chunks/{chunk-VFMASYQA.js → chunk-MS7GNABG.js} +3 -0
  111. package/chunks/{chunk-2FRY5CRX.js → chunk-MWZYNOCG.js} +3 -3
  112. package/chunks/{chunk-ONSZH6VM.js → chunk-MZQ4I4AP.js} +2 -2
  113. package/chunks/{chunk-UMD7WQTR.js → chunk-N3ZWGKXN.js} +10 -8
  114. package/chunks/{chunk-7MH4J33A.js → chunk-N7NBMAMW.js} +2 -2
  115. package/chunks/{chunk-EUNWC2VS.js → chunk-NC4O6UE6.js} +2 -2
  116. package/chunks/{chunk-A7XMDZRI.js → chunk-NFSSQDB5.js} +5 -5
  117. package/chunks/{chunk-DCZEPFB4.js → chunk-NM3E6GGL.js} +3 -3
  118. package/chunks/{chunk-26CXSA6V.js → chunk-NQPYPDOY.js} +2 -2
  119. package/chunks/{chunk-HUWENAHO.js → chunk-NWPO6I7V.js} +1 -1
  120. package/chunks/{chunk-SR7RZ4MS.js → chunk-O4BBDP2G.js} +2 -2
  121. package/chunks/{chunk-ECWR5LQR.js → chunk-OC5SKSNX.js} +3 -3
  122. package/chunks/{chunk-VWKER4ZH.js → chunk-OGQERNHD.js} +3 -3
  123. package/chunks/{chunk-DA4HRSBW.js → chunk-OPBATTFQ.js} +1 -1
  124. package/chunks/{chunk-OONWZLFK.js → chunk-P7KCJGBR.js} +4 -4
  125. package/chunks/{chunk-OJUQF2PL.js → chunk-PBYVS6QT.js} +3 -3
  126. package/chunks/{chunk-VNNWAZSI.js → chunk-QG2IEE2E.js} +3 -3
  127. package/chunks/{chunk-KZ22NXBY.js → chunk-QGZN4RYB.js} +4 -4
  128. package/chunks/{chunk-2UUMVNYT.js → chunk-QTI7SRXI.js} +3 -3
  129. package/chunks/{chunk-B2GJNDTV.js → chunk-QUESTNOP.js} +1 -1
  130. package/chunks/{chunk-AAE6SR4Q.js → chunk-RUKNJEJO.js} +1 -1
  131. package/chunks/{chunk-NV65ZUVM.js → chunk-RUVZZKDH.js} +1 -1
  132. package/chunks/{chunk-QUI267ZP.js → chunk-SAQHDAUJ.js} +42 -8
  133. package/chunks/{chunk-4MKXUHXY.js → chunk-SUTP6CZA.js} +5 -5
  134. package/chunks/{chunk-UBX6NL47.js → chunk-T4576UW4.js} +3 -3
  135. package/chunks/{chunk-TZEZYNYD.js → chunk-T4FTABSW.js} +1 -1
  136. package/chunks/{chunk-SEZ556DZ.js → chunk-T6W4KACQ.js} +1 -1
  137. package/chunks/chunk-TKAEODJR.js +1279 -0
  138. package/chunks/{chunk-NV3F44FL.js → chunk-TNQLAI6I.js} +2 -2
  139. package/chunks/{chunk-F6WDTQ3M.js → chunk-TNS2M7VL.js} +5 -5
  140. package/chunks/{chunk-7GTMV7UE.js → chunk-TTB6GBJ6.js} +8323 -2227
  141. package/chunks/{chunk-YGT2AUJ7.js → chunk-U2JLICUY.js} +33 -16
  142. package/chunks/{chunk-NEOXOWYH.js → chunk-U7QUDFPD.js} +7 -7
  143. package/chunks/{chunk-QGNOFE5E.js → chunk-UEUE6LJX.js} +1 -1
  144. package/chunks/{chunk-EI3NWELG.js → chunk-UIZGNLBP.js} +4427 -3806
  145. package/chunks/{chunk-ZJ4W6SUY.js → chunk-UM57UTTV.js} +3 -3
  146. package/chunks/{chunk-EQL65XGA.js → chunk-V3LXMASR.js} +47 -21
  147. package/chunks/{chunk-LHEC5V6G.js → chunk-VRWOMUZM.js} +2 -2
  148. package/chunks/{chunk-5MZCSWI4.js → chunk-W2ITCESM.js} +176 -477
  149. package/chunks/{chunk-KONVMRK7.js → chunk-W2PNY24B.js} +1 -1
  150. package/chunks/{chunk-4WL6SY4F.js → chunk-X5GLCWPX.js} +1 -1
  151. package/chunks/{chunk-BSI645OU.js → chunk-XBLYC4MI.js} +3 -3
  152. package/chunks/{chunk-GNPNYXJB.js → chunk-XLQS3VI6.js} +2 -2
  153. package/chunks/{chunk-TRRF5BSP.js → chunk-XT6TGJFD.js} +1 -1
  154. package/chunks/{chunk-PYQADEFD.js → chunk-XTH2OMDS.js} +1 -1
  155. package/chunks/{chunk-47PEPJO7.js → chunk-XUMBOJC2.js} +3 -3
  156. package/chunks/{chunk-GWVUR3QZ.js → chunk-YIKMBYMT.js} +3 -3
  157. package/chunks/{chunk-WOJZWRAZ.js → chunk-YRLW2MSX.js} +1 -1
  158. package/chunks/{chunk-NRLFZWCT.js → chunk-YVVIFFU4.js} +3 -3
  159. package/chunks/chunk-Z7B6SRPM.js +32 -0
  160. package/chunks/{chunk-IA7TGCN2.js → chunk-ZV4XVYL3.js} +4 -4
  161. package/chunks/{chunk-PJRW65JO.js → chunk-ZWPWQEF5.js} +1 -1
  162. package/chunks/{computer-use-WQFK33Z3.js → computer-use-7TIKEXBX.js} +42 -41
  163. package/chunks/{config-utils-ULCSRMWD.js → config-utils-6MVJ54TY.js} +6 -6
  164. package/chunks/{contextCommand-7EOZND7C.js → contextCommand-5QKI7MRY.js} +44 -43
  165. package/chunks/{core-runtime-FGMQRM6E.js → core-runtime-USS7ZF3H.js} +42 -41
  166. package/chunks/{create-sub-session-QIDZUOPU.js → create-sub-session-Y4WYDZGC.js} +2 -2
  167. package/chunks/{create-sub-session-QM2K5HLZ.js → create-sub-session-ZD2F3BH2.js} +42 -41
  168. package/chunks/{cron-create-VONA5JYY.js → cron-create-ZOVA3CC2.js} +4 -4
  169. package/chunks/{cron-delete-5JXSP2MI.js → cron-delete-7Z3H4LJY.js} +4 -4
  170. package/chunks/{cron-list-KE4F2CIR.js → cron-list-UHGX3IQG.js} +4 -4
  171. package/chunks/{daemon-GWD7BT6E.js → daemon-Y3NOHFKQ.js} +38 -7
  172. package/chunks/daemon-status-provider-PMP4J7BC.js +103 -0
  173. package/chunks/daemon-trust-policy-2252VKXI.js +99 -0
  174. package/chunks/{daemon-trust-policy-monitor-6UKEABN5.js → daemon-trust-policy-monitor-OSGGKJXT.js} +49 -48
  175. package/chunks/{de-LIW4XVLN.js → de-UBEBKG6V.js} +2 -1
  176. package/chunks/{deferred-core-runtime-67GJXHXS.js → deferred-core-runtime-3VD4V6YZ.js} +42 -41
  177. package/chunks/{display-image-NQRSIBXM.js → display-image-ZE3GZNIK.js} +4 -4
  178. package/chunks/{dist-Z3CS4OVP.js → dist-AVUYBK7L.js} +11 -5
  179. package/chunks/{dist-6BMOAE3Z.js → dist-BNWP6IZL.js} +4 -4
  180. package/chunks/{dist-3NTTUAHT.js → dist-EFJILGIS.js} +3 -3
  181. package/chunks/{dist-EZE3V3Q7.js → dist-MAIUUIWN.js} +3 -3
  182. package/chunks/{dist-B2CGTW6T.js → dist-NPS52B2V.js} +3 -3
  183. package/chunks/{dist-J47AXBZC.js → dist-PKSRQAR2.js} +3 -3
  184. package/chunks/{dist-OTUO3AS2.js → dist-Q2WJ2IZU.js} +13 -5
  185. package/chunks/{dist-EWW3J4HQ.js → dist-ZWDH5HLS.js} +3 -3
  186. package/chunks/{earlyInputCapture-IWMYR6OB.js → earlyInputCapture-ER4HGLJN.js} +43 -42
  187. package/chunks/{edit-ZFGROCAF.js → edit-B3MT7O53.js} +42 -41
  188. package/chunks/{en-SY5GTIGX.js → en-X6YV7GME.js} +2 -1
  189. package/chunks/{enter-worktree-TZZZCDM5.js → enter-worktree-WVIYVSDJ.js} +42 -41
  190. package/chunks/{enterPlanMode-U77BI3R6.js → enterPlanMode-DDCIM6HA.js} +42 -41
  191. package/chunks/{environment-HC37DS2I.js → environment-LITGMOUP.js} +45 -44
  192. package/chunks/{errors-6AG54JPD.js → errors-E5CIOR2I.js} +44 -43
  193. package/chunks/{exit-worktree-UYYWFPNK.js → exit-worktree-NQ2A6URE.js} +42 -41
  194. package/chunks/exitPlanMode-YXSWN4D3.js +85 -0
  195. package/chunks/{fast-path-F5FSZ3O7.js → fast-path-PH3DBS6X.js} +3 -3
  196. package/chunks/{fast-path-settings-RPAVBD7P.js → fast-path-settings-LNOFM2YP.js} +2 -2
  197. package/chunks/{fr-RQFO7U4P.js → fr-VENTC2BS.js} +2 -1
  198. package/chunks/{gemini-NKQHYM36.js → gemini-4YPO4ADY.js} +88 -87
  199. package/chunks/{geminiContentGenerator-HCWZOUX3.js → geminiContentGenerator-GMSVVXOU.js} +6 -6
  200. package/chunks/{glob-3PDXKBAO.js → glob-3Y3VHLM2.js} +42 -41
  201. package/chunks/{goal-tools-SWNB6GP4.js → goal-tools-JDK2SNMV.js} +4 -4
  202. package/chunks/{grep-5HZKZYVD.js → grep-VUHUDZYG.js} +42 -41
  203. package/chunks/handleAutoUpdate-OBFFPWSJ.js +94 -0
  204. package/chunks/{i18n-Q27KKNDL.js → i18n-4PJA5KKU.js} +43 -42
  205. package/chunks/{image-gen-2Z2RJ6W7.js → image-gen-4IFV4HES.js} +10 -10
  206. package/chunks/initializer-ZTY3VSWL.js +100 -0
  207. package/chunks/{installationInfo-XXB75T7O.js → installationInfo-6USRNCD2.js} +43 -42
  208. package/chunks/{ja-KOZKHJHZ.js → ja-QHT4EQTO.js} +2 -1
  209. package/chunks/{keychain-token-storage-TVAMTNP7.js → keychain-token-storage-JTWUYFU7.js} +2 -2
  210. package/chunks/list-U2ZDKYWN.js +103 -0
  211. package/chunks/{list-agents-Z4WABFDZ.js → list-agents-4GQ2XNEU.js} +2 -2
  212. package/chunks/loadedSettingsAdapter-WW4HIVLO.js +97 -0
  213. package/chunks/{loggingContentGenerator-6NTFBM7Q.js → loggingContentGenerator-XXG6YWUE.js} +46 -27
  214. package/chunks/{loop-wakeup-UZ5RL5Y2.js → loop-wakeup-HOQI3K5D.js} +5 -5
  215. package/chunks/{ls-TVHDGIES.js → ls-O4VBQRG7.js} +4 -4
  216. package/chunks/{lsp-CVN6OQPI.js → lsp-APQJ5ZEZ.js} +2 -2
  217. package/chunks/{managed-npm-update-SPHYQUWZ.js → managed-npm-update-7GM2LPLL.js} +43 -42
  218. package/chunks/mcp-7KZW2T5P.js +97 -0
  219. package/chunks/{monitor-ZBBPAA54.js → monitor-RQROQHLD.js} +42 -41
  220. package/chunks/nonInteractiveCli-U7JNJGS6.js +163 -0
  221. package/chunks/{notebook-edit-5W3FW7Z2.js → notebook-edit-XQA6YCH2.js} +42 -41
  222. package/chunks/{openaiContentGenerator-TQANPEVZ.js → openaiContentGenerator-BZW2IB42.js} +29 -29
  223. package/chunks/{pidfile-EQOBLH4E.js → pidfile-NX5VZ3IK.js} +43 -42
  224. package/chunks/{processUtils-7XQG7EHS.js → processUtils-M635AD23.js} +2 -2
  225. package/chunks/{pt-U6AOCTMF.js → pt-VL3I5RNY.js} +2 -1
  226. package/chunks/{qwenContentGenerator-BKCPHHXU.js → qwenContentGenerator-KHJ73E2C.js} +48 -48
  227. package/chunks/{qwenOAuth2-BJ6PQKE6.js → qwenOAuth2-QMK25XO7.js} +9 -9
  228. package/chunks/read-file-6LKIKKXD.js +32 -0
  229. package/chunks/{read-mcp-resource-PZ4ZF6YL.js → read-mcp-resource-TJSJRH4F.js} +2 -2
  230. package/chunks/{record-artifact-P4HFMS7X.js → record-artifact-FXF5LHPE.js} +3 -3
  231. package/chunks/{resumeHistoryUtils-6N6XGJJW.js → resumeHistoryUtils-RR2KEVH5.js} +49 -48
  232. package/chunks/ripGrep-CF2WRBYV.js +85 -0
  233. package/chunks/{ru-CMX4UMYP.js → ru-4RCKL4PY.js} +2 -1
  234. package/chunks/{run-qwen-serve-BCKBCAMX.js → run-qwen-serve-L5TF57J4.js} +61 -50
  235. package/chunks/{runtime-E2437YKL.js → runtime-3RE3BPR4.js} +55 -54
  236. package/chunks/{scheduler-K3D5Z655.js → scheduler-LXQZAMYT.js} +44 -43
  237. package/chunks/{sdk-exporters-http-XVTZQRCE.js → sdk-exporters-http-7SYSCGEO.js} +3 -3
  238. package/chunks/{sdk-impl-7W7AKCS4.js → sdk-impl-VZI6M6EH.js} +6 -6
  239. package/chunks/{send-message-CAMSLG2L.js → send-message-RBYLV5NY.js} +6 -6
  240. package/chunks/{serve-IH4XR5IL.js → serve-5D4S7GIA.js} +49 -48
  241. package/chunks/{server-UD6INW7J.js → server-ILZB6TTC.js} +403 -178
  242. package/chunks/{session-GR4ZEVW4.js → session-SXCZITZ4.js} +114 -94
  243. package/chunks/{settings-5O24D3OJ.js → settings-4RQB3OVF.js} +48 -47
  244. package/chunks/{shell-UTLWLG5G.js → shell-FCTR3OI2.js} +42 -41
  245. package/chunks/{skill-QQAZL4VO.js → skill-IAKHPD5H.js} +19 -19
  246. package/chunks/{skill-settings-P3YHJVBZ.js → skill-settings-SOR23NOP.js} +48 -47
  247. package/chunks/spawnChannel-I6VAWYQJ.js +98 -0
  248. package/chunks/{standalone-update-QP742MGP.js → standalone-update-5NN3MTYH.js} +44 -43
  249. package/chunks/{startInteractiveUI-YCS6AEPN.js → startInteractiveUI-OYGL3NZJ.js} +590 -329
  250. package/chunks/{syntheticOutput-PEBJQYJV.js → syntheticOutput-D3Z64LJC.js} +3 -3
  251. package/chunks/{task-create-5NWCQSJF.js → task-create-URFZ5EUX.js} +10 -10
  252. package/chunks/{task-list-53265TRZ.js → task-list-6JDFMPUW.js} +5 -5
  253. package/chunks/{task-stop-FPCOIRYX.js → task-stop-HHUGCD25.js} +2 -2
  254. package/chunks/{task-update-5HN577LS.js → task-update-LCJM3EYG.js} +10 -10
  255. package/chunks/{team-create-WFH7OCDQ.js → team-create-J4JP6AXN.js} +44 -43
  256. package/chunks/{team-delete-MMQB4OSC.js → team-delete-PZGGBQLM.js} +5 -5
  257. package/chunks/{team-plan-approval-EGTT53MV.js → team-plan-approval-7BEAIR2H.js} +42 -41
  258. package/chunks/{terminal-image-renderer-BWRESAQ7.js → terminal-image-renderer-SGGTG5LN.js} +44 -43
  259. package/chunks/theme-manager-67TSB7LH.js +89 -0
  260. package/chunks/{todoWrite-JGV6VLOX.js → todoWrite-WINAZSZI.js} +4 -4
  261. package/chunks/{tool-search-TI5PTIBF.js → tool-search-XPOFDWOX.js} +19 -19
  262. package/chunks/{total-session-admission-66UDSOHO.js → total-session-admission-SZJFAM25.js} +47 -46
  263. package/chunks/{trustedFolders-4KYHA4IG.js → trustedFolders-44NTYYV4.js} +43 -42
  264. package/chunks/{update-relaunch-WB6LGIF2.js → update-relaunch-K33Q3WEH.js} +5 -5
  265. package/chunks/{updateCheck-LOS5GYFC.js → updateCheck-VBRNPLS4.js} +45 -44
  266. package/chunks/{useAutoAcceptIndicator-MHAPY52L.js → useAutoAcceptIndicator-AUNRB5S7.js} +52 -51
  267. package/chunks/{validateNonInterActiveAuth-QV22HNQU.js → validateNonInterActiveAuth-WTO36MTA.js} +83 -82
  268. package/chunks/{version-DALWZHKQ.js → version-JZA6HYPI.js} +1 -1
  269. package/chunks/{web-fetch-JMJVMYFE.js → web-fetch-LLHPV2IR.js} +19 -19
  270. package/chunks/{web-search-DNDUIPU5.js → web-search-4HCHRZ3U.js} +11 -11
  271. package/chunks/{workflow-JGNN64PM.js → workflow-YI74QTWW.js} +43 -42
  272. package/chunks/workspace-providers-status-CI3AO2BH.js +100 -0
  273. package/chunks/{workspace-registration-store-LRJG7QA4.js → workspace-registration-store-KPIKXDHA.js} +1 -1
  274. package/chunks/{workspace-registry-KVXIFM36.js → workspace-registry-XE22QDE6.js} +47 -46
  275. package/chunks/{workspace-service-PO4AAKKT.js → workspace-service-WI2FD72A.js} +54 -53
  276. package/chunks/workspace-skills-status-FFZU6FXL.js +100 -0
  277. package/chunks/{workspace-trust-reconciler-DOZPCVHG.js → workspace-trust-reconciler-GJLNXR2U.js} +54 -53
  278. package/chunks/write-file-IEAC3XC3.js +87 -0
  279. package/chunks/{zh-AGL2FVBI.js → zh-LMSTK4WD.js} +2 -1
  280. package/chunks/{zh-TW-KI66MHQY.js → zh-TW-SQ4HTSCW.js} +2 -1
  281. package/chunks/{zoom-image-CNC77ZMA.js → zoom-image-GTVVT25J.js} +15 -15
  282. package/cli.js +13 -13
  283. package/locales/ca.js +1 -0
  284. package/locales/de.js +1 -0
  285. package/locales/en.js +1 -0
  286. package/locales/fr.js +1 -0
  287. package/locales/ja.js +1 -0
  288. package/locales/pt.js +1 -0
  289. package/locales/ru.js +1 -0
  290. package/locales/zh-TW.js +1 -0
  291. package/locales/zh.js +1 -0
  292. package/package.json +3 -3
  293. package/web-shell/assets/{arc-CDk0d60K.js → arc-B13-S0Yo.js} +1 -1
  294. package/web-shell/assets/{architectureDiagram-3BPJPVTR-h-W3I2lP.js → architectureDiagram-3BPJPVTR-CHvWNlVW.js} +1 -1
  295. package/web-shell/assets/{blockDiagram-GPEHLZMM-D1pvSmZg.js → blockDiagram-GPEHLZMM-CXebOlXF.js} +1 -1
  296. package/web-shell/assets/{c4Diagram-AAUBKEIU-ByAm5ZNf.js → c4Diagram-AAUBKEIU-BQpx4y3Q.js} +1 -1
  297. package/web-shell/assets/channel-BB_Hm8Rf.js +1 -0
  298. package/web-shell/assets/{chunk-2J33WTMH-VrGPPOGV.js → chunk-2J33WTMH-Cak1exSv.js} +1 -1
  299. package/web-shell/assets/{chunk-4BX2VUAB-B7hTowgG.js → chunk-4BX2VUAB-BIc8BV5_.js} +1 -1
  300. package/web-shell/assets/{chunk-55IACEB6-j1Fq8DpE.js → chunk-55IACEB6-DoeJ5BL1.js} +1 -1
  301. package/web-shell/assets/{chunk-727SXJPM-UjABYpF2.js → chunk-727SXJPM-BDR_wYSu.js} +1 -1
  302. package/web-shell/assets/{chunk-AQP2D5EJ-D4uBItrs.js → chunk-AQP2D5EJ-BhRRGRq1.js} +1 -1
  303. package/web-shell/assets/{chunk-FMBD7UC4-DeFbKlb8.js → chunk-FMBD7UC4-BJGAwVXr.js} +1 -1
  304. package/web-shell/assets/{chunk-ND2GUHAM-rQJ8TIgT.js → chunk-ND2GUHAM-vhE73bsD.js} +1 -1
  305. package/web-shell/assets/{chunk-QZHKN3VN-DAGcRxvq.js → chunk-QZHKN3VN-BuTBZsdR.js} +1 -1
  306. package/web-shell/assets/classDiagram-4FO5ZUOK-B_hFK54Y.js +1 -0
  307. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-B_hFK54Y.js +1 -0
  308. package/web-shell/assets/{cose-bilkent-S5V4N54A-MaE7MJSt.js → cose-bilkent-S5V4N54A-CVHKipHP.js} +1 -1
  309. package/web-shell/assets/{dagre-BM42HDAG-DzijYGSb.js → dagre-BM42HDAG-C1DPa8SV.js} +1 -1
  310. package/web-shell/assets/{diagram-2AECGRRQ-WdbG7WnX.js → diagram-2AECGRRQ-BYP_QxkT.js} +1 -1
  311. package/web-shell/assets/{diagram-5GNKFQAL-NYutsBnw.js → diagram-5GNKFQAL-Cray7ruQ.js} +1 -1
  312. package/web-shell/assets/{diagram-KO2AKTUF-Dqg0eBY0.js → diagram-KO2AKTUF-Ds4vJANi.js} +1 -1
  313. package/web-shell/assets/{diagram-LMA3HP47-C7vRP2Lb.js → diagram-LMA3HP47-DxFrDykH.js} +1 -1
  314. package/web-shell/assets/{diagram-OG6HWLK6-B2sEPpPt.js → diagram-OG6HWLK6-BdIO-pF_.js} +1 -1
  315. package/web-shell/assets/{erDiagram-TEJ5UH35-a4zIbzm8.js → erDiagram-TEJ5UH35-5JA8KDYV.js} +1 -1
  316. package/web-shell/assets/{flowDiagram-I6XJVG4X-BK9y89ya.js → flowDiagram-I6XJVG4X-DL4drKro.js} +1 -1
  317. package/web-shell/assets/{ganttDiagram-6RSMTGT7-wUQTSNvV.js → ganttDiagram-6RSMTGT7-ijX2DD6_.js} +1 -1
  318. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-Dnzt4SAi.js → gitGraphDiagram-PVQCEYII-_lPsFLFF.js} +1 -1
  319. package/web-shell/assets/index-BTwNYZkp.js +1785 -0
  320. package/web-shell/assets/{index-BA3wUcKL.js → index-C-YoqYbs.js} +1 -1
  321. package/web-shell/assets/index-dHAFxPHb.css +5 -0
  322. package/web-shell/assets/{infoDiagram-5YYISTIA-DcaoToij.js → infoDiagram-5YYISTIA-COFClLab.js} +1 -1
  323. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-DzduqhP2.js → ishikawaDiagram-YF4QCWOH-Div9KOgO.js} +1 -1
  324. package/web-shell/assets/{journeyDiagram-JHISSGLW-BvviZR_O.js → journeyDiagram-JHISSGLW-VAw5u0wc.js} +1 -1
  325. package/web-shell/assets/{kanban-definition-UN3LZRKU-Efm2JxY3.js → kanban-definition-UN3LZRKU-CncCn8Nl.js} +1 -1
  326. package/web-shell/assets/{linear-DtY3IbOs.js → linear-D6ad7e_k.js} +1 -1
  327. package/web-shell/assets/{mermaid.core-PzpFqoMe.js → mermaid.core-BV1IECGb.js} +5 -5
  328. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BLlTkHS0.js → mindmap-definition-RKZ34NQL-a3jeNgPr.js} +1 -1
  329. package/web-shell/assets/{pieDiagram-4H26LBE5-D-mKF-jE.js → pieDiagram-4H26LBE5-DsVRY5BW.js} +1 -1
  330. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-DYCzslGm.js → quadrantDiagram-W4KKPZXB-D6zgexJK.js} +1 -1
  331. package/web-shell/assets/{requirementDiagram-4Y6WPE33-Dfpxlk7R.js → requirementDiagram-4Y6WPE33-VEpSwJjn.js} +1 -1
  332. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-D5cRaaxh.js → sankeyDiagram-5OEKKPKP-CYEuOFne.js} +1 -1
  333. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-s04DReiS.js → sequenceDiagram-3UESZ5HK-CCg0lI-9.js} +1 -1
  334. package/web-shell/assets/{stateDiagram-AJRCARHV-01UNFgnb.js → stateDiagram-AJRCARHV-BHXPsL0B.js} +1 -1
  335. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-eTG8D0QT.js +1 -0
  336. package/web-shell/assets/{timeline-definition-PNZ67QCA-DX8_wZBC.js → timeline-definition-PNZ67QCA-gqTf9a0k.js} +1 -1
  337. package/web-shell/assets/{vennDiagram-CIIHVFJN-BK0FlBme.js → vennDiagram-CIIHVFJN-C4DXXkBh.js} +1 -1
  338. package/web-shell/assets/{wardley-L42UT6IY-DkPc9UlD.js → wardley-L42UT6IY-CMK46EiX.js} +1 -1
  339. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-DNKkpDAo.js → wardleyDiagram-YWT4CUSO-DTk1Gzt9.js} +1 -1
  340. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CiPwg8QG.js → xychartDiagram-2RQKCTM6-BcJsM1dH.js} +1 -1
  341. package/web-shell/index.html +2 -2
  342. package/chunks/agent-headless-HYEHZFH6.js +0 -86
  343. package/chunks/channel-settings-store-OXYG5S5X.js +0 -101
  344. package/chunks/chunk-I5VM3SKY.js +0 -451
  345. package/chunks/chunk-PDPFQ2FO.js +0 -156
  346. package/chunks/daemon-status-provider-L3J6GKCT.js +0 -102
  347. package/chunks/daemon-trust-policy-4PHPY23S.js +0 -98
  348. package/chunks/exitPlanMode-RWJR2KGB.js +0 -84
  349. package/chunks/handleAutoUpdate-NHFSGYTF.js +0 -93
  350. package/chunks/initializer-Y5DJLT43.js +0 -99
  351. package/chunks/list-YHNQ32CS.js +0 -102
  352. package/chunks/loadedSettingsAdapter-GHUQK7H4.js +0 -96
  353. package/chunks/mcp-EA3KO6FS.js +0 -96
  354. package/chunks/nonInteractiveCli-NNOR56HU.js +0 -162
  355. package/chunks/read-file-KKTXGIZD.js +0 -32
  356. package/chunks/ripGrep-SJVAAYDV.js +0 -84
  357. package/chunks/spawnChannel-UAQMH6Y6.js +0 -94
  358. package/chunks/theme-manager-ZNDGAHJN.js +0 -88
  359. package/chunks/workspace-providers-status-K22B3Z6B.js +0 -99
  360. package/chunks/workspace-skills-status-DDYCBVSH.js +0 -99
  361. package/chunks/write-file-TT6MWIKC.js +0 -86
  362. package/web-shell/assets/channel-DPFUV4oi.js +0 -1
  363. package/web-shell/assets/classDiagram-4FO5ZUOK-CLm0hVvw.js +0 -1
  364. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-CLm0hVvw.js +0 -1
  365. package/web-shell/assets/index-BjC3yjjL.css +0 -5
  366. package/web-shell/assets/index-QzFq6w7o.js +0 -1775
  367. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DXb5olqv.js +0 -1
@@ -0,0 +1,1279 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import {
4
+ MissingCliEntryError
5
+ } from "./chunk-OPBATTFQ.js";
6
+ import {
7
+ redactLogCredentials
8
+ } from "./chunk-M5GB774H.js";
9
+ import {
10
+ EXTERNAL_TOOL_GUARD_TOKEN_ENV
11
+ } from "./chunk-BKHCW2BI.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
+ var TERM_GRACE_MS = 5e3;
667
+ var EXIT_DEADLINE_MS = 1e4;
668
+ var ProcessRegistry = class {
669
+ static {
670
+ __name(this, "ProcessRegistry");
671
+ }
672
+ reservations = /* @__PURE__ */ new Set();
673
+ children = /* @__PURE__ */ new Set();
674
+ draining = false;
675
+ shutdownPromise;
676
+ reserve() {
677
+ if (this.draining) {
678
+ throw new Error("ACP process registry is draining");
679
+ }
680
+ const token = Symbol("acp-child");
681
+ this.reservations.add(token);
682
+ let settled = false;
683
+ return {
684
+ attach: /* @__PURE__ */ __name((child) => {
685
+ if (settled || !this.reservations.delete(token)) {
686
+ throw new Error("ACP process reservation is no longer active");
687
+ }
688
+ settled = true;
689
+ const tracked = new TrackedChild(child, () => {
690
+ this.children.delete(tracked);
691
+ });
692
+ this.children.add(tracked);
693
+ if (this.draining) void tracked.terminate().catch(() => {
694
+ });
695
+ return tracked;
696
+ }, "attach"),
697
+ cancel: /* @__PURE__ */ __name(() => {
698
+ if (settled) return;
699
+ settled = true;
700
+ this.reservations.delete(token);
701
+ }, "cancel")
702
+ };
703
+ }
704
+ shutdown() {
705
+ if (this.shutdownPromise) return this.shutdownPromise;
706
+ this.draining = true;
707
+ this.shutdownPromise = Promise.allSettled(
708
+ [...this.children].map((child) => child.terminate())
709
+ ).then((results) => {
710
+ const failures = results.flatMap(
711
+ (result) => result.status === "rejected" ? [result.reason] : []
712
+ );
713
+ if (failures.length > 0) {
714
+ throw new AggregateError(failures, "ACP child process shutdown failed");
715
+ }
716
+ });
717
+ return this.shutdownPromise;
718
+ }
719
+ killAllSync() {
720
+ this.draining = true;
721
+ for (const child of this.children) child.killSync();
722
+ }
723
+ get activeProcessCount() {
724
+ return this.children.size;
725
+ }
726
+ /**
727
+ * Children this registry has committed to: attached ones plus reservations
728
+ * that have not attached yet. Larger than {@link activeProcessCount}, and
729
+ * the right figure for admission — `reserve()` inserts its token
730
+ * synchronously before `spawn()`, so two racing spawns each see the other
731
+ * here, while neither is visible in `activeProcessCount` until its child is
732
+ * attached.
733
+ *
734
+ * A child leaves this count when it *exits*, not when `terminate()` starts,
735
+ * so a channel swap is counted twice while the old process is still winding
736
+ * down. That is deliberate: its memory is still resident.
737
+ */
738
+ get committedProcessCount() {
739
+ return this.children.size + this.reservations.size;
740
+ }
741
+ };
742
+ var TrackedChild = class {
743
+ constructor(child, onExit) {
744
+ this.child = child;
745
+ this.onExit = onExit;
746
+ this.exited = new Promise((resolve) => {
747
+ const finish = /* @__PURE__ */ __name((info) => {
748
+ if (this.exitedSettled) return;
749
+ this.exitedSettled = true;
750
+ this.onExit();
751
+ resolve(info);
752
+ }, "finish");
753
+ child.once("exit", (exitCode, signalCode) => {
754
+ finish({ exitCode, signalCode });
755
+ });
756
+ child.once("spawn", () => {
757
+ this.spawnConfirmed = true;
758
+ });
759
+ child.once("error", () => {
760
+ if (!this.spawnConfirmed) finish(void 0);
761
+ });
762
+ });
763
+ }
764
+ static {
765
+ __name(this, "TrackedChild");
766
+ }
767
+ exited;
768
+ exitedSettled = false;
769
+ spawnConfirmed = false;
770
+ terminatePromise;
771
+ terminate() {
772
+ this.terminatePromise ??= this.terminateOnce();
773
+ return this.terminatePromise;
774
+ }
775
+ killSync() {
776
+ if (this.exitedSettled) return;
777
+ try {
778
+ this.child.kill("SIGKILL");
779
+ } catch {
780
+ }
781
+ }
782
+ async terminateOnce() {
783
+ if (this.exitedSettled) return;
784
+ try {
785
+ this.child.kill("SIGTERM");
786
+ } catch {
787
+ if (this.exitedSettled) return;
788
+ }
789
+ let hardKillTimer;
790
+ let deadlineTimer;
791
+ const deadline = new Promise((_, reject) => {
792
+ hardKillTimer = setTimeout(() => this.killSync(), TERM_GRACE_MS);
793
+ hardKillTimer.unref();
794
+ deadlineTimer = setTimeout(() => {
795
+ reject(
796
+ new Error(
797
+ `ACP child pid=${this.child.pid ?? "unknown"} did not exit within ${EXIT_DEADLINE_MS}ms`
798
+ )
799
+ );
800
+ }, EXIT_DEADLINE_MS);
801
+ deadlineTimer.unref();
802
+ });
803
+ try {
804
+ const exitInfo = await Promise.race([this.exited, deadline]);
805
+ if (exitInfo && (exitInfo.exitCode !== 0 || exitInfo.signalCode !== null)) {
806
+ throw new Error(
807
+ `ACP child pid=${this.child.pid ?? "unknown"} exited uncleanly during shutdown (code=${exitInfo.exitCode ?? "none"}, signal=${exitInfo.signalCode ?? "none"})`
808
+ );
809
+ }
810
+ } finally {
811
+ if (hardKillTimer) clearTimeout(hardKillTimer);
812
+ if (deadlineTimer) clearTimeout(deadlineTimer);
813
+ }
814
+ }
815
+ };
816
+
817
+ // packages/acp-bridge/src/spawnChannel.ts
818
+ var cachedMemoryArgs;
819
+ var DAEMON_ACP_NDJSON_LIMITS = Object.freeze({
820
+ maxFrameBytes: 64 * 1024 * 1024,
821
+ maxQueuedMessages: 256,
822
+ maxQueuedBytes: 64 * 1024 * 1024
823
+ });
824
+ var daemonClientParamValidators = /* @__PURE__ */ new Map([
825
+ [CLIENT_METHODS.fs_read_text_file, zReadTextFileRequest],
826
+ [CLIENT_METHODS.fs_write_text_file, zWriteTextFileRequest],
827
+ [CLIENT_METHODS.session_request_permission, zRequestPermissionRequest],
828
+ [CLIENT_METHODS.session_update, zSessionNotification],
829
+ [CLIENT_METHODS.terminal_create, zCreateTerminalRequest],
830
+ [CLIENT_METHODS.terminal_kill, zKillTerminalCommandRequest],
831
+ [CLIENT_METHODS.terminal_output, zTerminalOutputRequest],
832
+ [CLIENT_METHODS.terminal_release, zReleaseTerminalRequest],
833
+ [CLIENT_METHODS.terminal_wait_for_exit, zWaitForTerminalExitRequest]
834
+ ]);
835
+ function validateDaemonInboundMessage(message) {
836
+ if (!("method" in message)) return true;
837
+ const validator = daemonClientParamValidators.get(message.method);
838
+ return !validator || validator.safeParse(message.params).success;
839
+ }
840
+ __name(validateDaemonInboundMessage, "validateDaemonInboundMessage");
841
+ var PreparedResponseBudget = class {
842
+ constructor(limits) {
843
+ this.limits = limits;
844
+ }
845
+ static {
846
+ __name(this, "PreparedResponseBudget");
847
+ }
848
+ objectCharges = /* @__PURE__ */ new WeakMap();
849
+ primitiveCharges = /* @__PURE__ */ new Map();
850
+ retainedCount = 0;
851
+ retainedBytes = 0;
852
+ closed = false;
853
+ reserve(value) {
854
+ if (this.closed) return;
855
+ const availableBytes = Math.max(
856
+ 0,
857
+ this.limits.maxQueuedBytes - this.retainedBytes
858
+ );
859
+ const envelopeBytes = Math.min(2048, this.limits.maxQueuedBytes);
860
+ const charge = envelopeBytes + estimatePreparedResponseBytes(
861
+ value,
862
+ Math.max(0, availableBytes - envelopeBytes)
863
+ );
864
+ if (this.retainedCount >= this.limits.maxQueuedMessages || charge > availableBytes) {
865
+ throw new NdJsonQueueLimitError(
866
+ this.limits.maxQueuedMessages,
867
+ this.limits.maxQueuedBytes,
868
+ charge,
869
+ availableBytes
870
+ );
871
+ }
872
+ const charges = this.getCharges(value, true);
873
+ charges.push(charge);
874
+ this.retainedCount++;
875
+ this.retainedBytes += charge;
876
+ }
877
+ releaseMessage(message) {
878
+ if (!isPlainRecord(message) || Object.hasOwn(message, "method") || !Object.hasOwn(message, "id")) {
879
+ return;
880
+ }
881
+ const value = Object.hasOwn(message, "result") ? message["result"] : message["error"];
882
+ const charges = this.getCharges(value, false);
883
+ if (!charges) return;
884
+ const charge = charges.shift();
885
+ if (charge === void 0) return;
886
+ if (charges.length === 0 && !isObjectValue(value)) {
887
+ this.primitiveCharges.delete(value);
888
+ }
889
+ this.retainedCount--;
890
+ this.retainedBytes -= charge;
891
+ }
892
+ close() {
893
+ this.closed = true;
894
+ this.objectCharges = /* @__PURE__ */ new WeakMap();
895
+ this.primitiveCharges.clear();
896
+ this.retainedCount = 0;
897
+ this.retainedBytes = 0;
898
+ }
899
+ getCharges(value, create) {
900
+ const charges = isObjectValue(value) ? this.objectCharges.get(value) : this.primitiveCharges.get(value);
901
+ if (charges || !create) return charges;
902
+ const created = [];
903
+ if (isObjectValue(value)) {
904
+ this.objectCharges.set(value, created);
905
+ } else {
906
+ this.primitiveCharges.set(value, created);
907
+ }
908
+ return created;
909
+ }
910
+ };
911
+ var OutboundOperationBudget = class {
912
+ constructor(limits) {
913
+ this.limits = limits;
914
+ }
915
+ static {
916
+ __name(this, "OutboundOperationBudget");
917
+ }
918
+ retainedCount = 0;
919
+ retainedBytes = 0;
920
+ generation = 0;
921
+ closed = false;
922
+ reserve(value) {
923
+ if (this.closed) return () => {
924
+ };
925
+ const availableBytes = Math.max(
926
+ 0,
927
+ this.limits.maxQueuedBytes - this.retainedBytes
928
+ );
929
+ const envelopeBytes = Math.min(2048, this.limits.maxQueuedBytes);
930
+ const charge = envelopeBytes + estimatePreparedResponseBytes(
931
+ value,
932
+ Math.max(0, availableBytes - envelopeBytes)
933
+ );
934
+ if (this.retainedCount >= this.limits.maxQueuedMessages || charge > availableBytes) {
935
+ throw new NdJsonQueueLimitError(
936
+ this.limits.maxQueuedMessages,
937
+ this.limits.maxQueuedBytes,
938
+ charge,
939
+ availableBytes
940
+ );
941
+ }
942
+ this.retainedCount++;
943
+ this.retainedBytes += charge;
944
+ const generation = this.generation;
945
+ let active = true;
946
+ return () => {
947
+ if (!active) return;
948
+ active = false;
949
+ if (this.closed || this.generation !== generation) return;
950
+ this.retainedCount--;
951
+ this.retainedBytes -= charge;
952
+ };
953
+ }
954
+ close() {
955
+ this.closed = true;
956
+ this.generation++;
957
+ this.retainedCount = 0;
958
+ this.retainedBytes = 0;
959
+ }
960
+ };
961
+ function* enumerableOwnKeys(value) {
962
+ for (const key in value) {
963
+ if (Object.hasOwn(value, key)) yield key;
964
+ }
965
+ }
966
+ __name(enumerableOwnKeys, "enumerableOwnKeys");
967
+ function estimatePreparedResponseBytes(value, limitBytes) {
968
+ let bytes = 0;
969
+ const stack = [{ kind: "value", value }];
970
+ const seen = /* @__PURE__ */ new WeakSet();
971
+ while (stack.length > 0) {
972
+ const frame = stack.pop();
973
+ if (frame.kind === "array") {
974
+ if (frame.index >= frame.value.length) continue;
975
+ if (frame.index > 0) bytes++;
976
+ if (bytes > limitBytes) return limitBytes + 1;
977
+ const descriptor = Object.getOwnPropertyDescriptor(
978
+ frame.value,
979
+ String(frame.index)
980
+ );
981
+ if (descriptor?.get || descriptor?.set) return limitBytes + 1;
982
+ stack.push({ ...frame, index: frame.index + 1 });
983
+ stack.push({ kind: "value", value: descriptor?.value });
984
+ continue;
985
+ }
986
+ if (frame.kind === "record") {
987
+ const next = frame.keys.next();
988
+ if (next.done) continue;
989
+ const descriptor = Object.getOwnPropertyDescriptor(
990
+ frame.value,
991
+ next.value
992
+ );
993
+ if (!descriptor || descriptor.get || descriptor.set) {
994
+ return limitBytes + 1;
995
+ }
996
+ bytes += (frame.first ? 0 : 1) + Buffer.byteLength(next.value) + 3;
997
+ if (bytes > limitBytes) return limitBytes + 1;
998
+ stack.push({ ...frame, first: false });
999
+ stack.push({ kind: "value", value: descriptor.value });
1000
+ continue;
1001
+ }
1002
+ const current = frame.value;
1003
+ if (current === null) {
1004
+ bytes += 4;
1005
+ } else if (current === void 0) {
1006
+ bytes += 4;
1007
+ } else if (typeof current === "string") {
1008
+ bytes += Buffer.byteLength(current) + 2;
1009
+ } else if (typeof current === "number") {
1010
+ bytes += 24;
1011
+ } else if (typeof current === "boolean") {
1012
+ bytes += 5;
1013
+ } else if (Array.isArray(current)) {
1014
+ if (seen.has(current) || Object.hasOwn(current, "toJSON")) {
1015
+ return limitBytes + 1;
1016
+ }
1017
+ seen.add(current);
1018
+ bytes += 2;
1019
+ stack.push({ kind: "array", value: current, index: 0 });
1020
+ } else if (isPlainRecord(current)) {
1021
+ if (seen.has(current) || Object.hasOwn(current, "toJSON")) {
1022
+ return limitBytes + 1;
1023
+ }
1024
+ seen.add(current);
1025
+ bytes += 2;
1026
+ stack.push({
1027
+ kind: "record",
1028
+ value: current,
1029
+ keys: enumerableOwnKeys(current),
1030
+ first: true
1031
+ });
1032
+ } else {
1033
+ return limitBytes + 1;
1034
+ }
1035
+ if (bytes > limitBytes) return limitBytes + 1;
1036
+ }
1037
+ return Math.max(1, bytes);
1038
+ }
1039
+ __name(estimatePreparedResponseBytes, "estimatePreparedResponseBytes");
1040
+ function isObjectValue(value) {
1041
+ return typeof value === "object" && value !== null;
1042
+ }
1043
+ __name(isObjectValue, "isObjectValue");
1044
+ function isPlainRecord(value) {
1045
+ if (!isObjectValue(value) || Array.isArray(value)) return false;
1046
+ const prototype = Object.getPrototypeOf(value);
1047
+ return prototype === Object.prototype || prototype === null;
1048
+ }
1049
+ __name(isPlainRecord, "isPlainRecord");
1050
+ function getAcpMemoryArgs() {
1051
+ if (cachedMemoryArgs) return cachedMemoryArgs;
1052
+ const constrainedMemory = process.constrainedMemory;
1053
+ const constrained = typeof constrainedMemory === "function" ? constrainedMemory() : 0;
1054
+ const totalBytes = constrained && constrained > 0 ? constrained : os.totalmem();
1055
+ const totalMB = Math.floor(totalBytes / (1024 * 1024));
1056
+ const targetMB = Math.min(Math.floor(totalMB * 0.5), 16384);
1057
+ const currentLimitMB = Math.floor(
1058
+ getHeapStatistics().heap_size_limit / (1024 * 1024)
1059
+ );
1060
+ cachedMemoryArgs = [
1061
+ ...targetMB > currentLimitMB ? [`--max-old-space-size=${targetMB}`] : [],
1062
+ "--expose-gc"
1063
+ ];
1064
+ return cachedMemoryArgs;
1065
+ }
1066
+ __name(getAcpMemoryArgs, "getAcpMemoryArgs");
1067
+ function createStderrForwarder(opts) {
1068
+ const { prefix, onDiagnosticLine } = opts;
1069
+ const STDERR_LINE_CAP_CHARS = 64 * 1024;
1070
+ let buf = "";
1071
+ const flush = /* @__PURE__ */ __name((line) => {
1072
+ if (line.length > 0) {
1073
+ const safe = redactLogCredentials(line);
1074
+ process.stderr.write(prefix + safe + "\n");
1075
+ if (onDiagnosticLine) onDiagnosticLine(prefix + safe, "warn");
1076
+ }
1077
+ }, "flush");
1078
+ return {
1079
+ onData(chunk) {
1080
+ buf += chunk;
1081
+ let nl = buf.indexOf("\n");
1082
+ while (nl !== -1) {
1083
+ flush(buf.slice(0, nl));
1084
+ buf = buf.slice(nl + 1);
1085
+ nl = buf.indexOf("\n");
1086
+ }
1087
+ while (buf.length > STDERR_LINE_CAP_CHARS) {
1088
+ const truncated = redactLogCredentials(buf.slice(0, STDERR_LINE_CAP_CHARS)) + " [truncated]";
1089
+ process.stderr.write(prefix + truncated + "\n");
1090
+ if (onDiagnosticLine) onDiagnosticLine(prefix + truncated, "warn");
1091
+ buf = buf.slice(STDERR_LINE_CAP_CHARS);
1092
+ }
1093
+ },
1094
+ onEnd() {
1095
+ if (buf.length > 0) flush(buf);
1096
+ }
1097
+ };
1098
+ }
1099
+ __name(createStderrForwarder, "createStderrForwarder");
1100
+ function createSpawnChannelFactory(options = {}) {
1101
+ if (options.pipeLimits) validateNdJsonStreamLimits(options.pipeLimits);
1102
+ const processRegistry = options.processRegistry ?? new ProcessRegistry();
1103
+ return async (workspaceCwd, childEnvOverrides) => {
1104
+ const sourceEnv = options.sourceEnv ?? process.env;
1105
+ const cliEntry = sourceEnv["QWEN_CLI_ENTRY"] || process.argv[1];
1106
+ if (!cliEntry) {
1107
+ throw new MissingCliEntryError();
1108
+ }
1109
+ const childEnv = scrubChildEnv(
1110
+ sourceEnv,
1111
+ SCRUBBED_CHILD_ENV_KEYS,
1112
+ childEnvOverrides
1113
+ );
1114
+ childEnv["QWEN_CODE_NO_RELAUNCH"] = "true";
1115
+ childEnv["QWEN_CODE_SERVE"] = "1";
1116
+ const execArgs = process.execArgv.filter(
1117
+ (a) => !/^--inspect(-brk)?($|=)/.test(a)
1118
+ );
1119
+ const reservation = processRegistry.reserve();
1120
+ let child;
1121
+ try {
1122
+ options.childHeapPolicy?.decide(processRegistry.committedProcessCount);
1123
+ const memoryArgs = getAcpMemoryArgs();
1124
+ child = spawn(
1125
+ process.execPath,
1126
+ [
1127
+ ...execArgs,
1128
+ ...memoryArgs,
1129
+ cliEntry,
1130
+ "--acp",
1131
+ ...options.extraArgs ?? []
1132
+ ],
1133
+ {
1134
+ cwd: workspaceCwd,
1135
+ stdio: ["pipe", "pipe", "pipe"],
1136
+ env: childEnv
1137
+ }
1138
+ );
1139
+ } catch (error) {
1140
+ reservation.cancel();
1141
+ throw error;
1142
+ }
1143
+ const trackedChild = reservation.attach(child);
1144
+ if (child.stderr) {
1145
+ const prefix = `[serve pid=${child.pid} cwd=${workspaceCwd}] `;
1146
+ const forwarder = createStderrForwarder({
1147
+ prefix,
1148
+ onDiagnosticLine: options.onDiagnosticLine
1149
+ });
1150
+ child.stderr.setEncoding("utf8");
1151
+ child.stderr.on("data", forwarder.onData);
1152
+ child.stderr.on("end", forwarder.onEnd);
1153
+ child.stderr.on("error", () => {
1154
+ });
1155
+ }
1156
+ if (!child.stdin || !child.stdout) {
1157
+ trackedChild.killSync();
1158
+ throw new Error(
1159
+ "Spawned ACP child has no stdin/stdout \u2014 cannot establish NDJSON channel."
1160
+ );
1161
+ }
1162
+ const writable = Writable.toWeb(child.stdin);
1163
+ const readable = Readable.toWeb(child.stdout);
1164
+ const preparedResponses = options.pipeLimits ? new PreparedResponseBudget(options.pipeLimits) : void 0;
1165
+ const outboundOperations = options.pipeLimits ? new OutboundOperationBudget(options.pipeLimits) : void 0;
1166
+ let reportTransportFailure;
1167
+ let transportFailureReported = false;
1168
+ const transportFailed = options.pipeLimits ? new Promise((resolve) => {
1169
+ reportTransportFailure = resolve;
1170
+ }) : void 0;
1171
+ const failTransport = options.pipeLimits ? (error) => {
1172
+ if (transportFailureReported) return;
1173
+ transportFailureReported = true;
1174
+ reportTransportFailure?.(error);
1175
+ reportTransportFailure = void 0;
1176
+ preparedResponses?.close();
1177
+ outboundOperations?.close();
1178
+ child.stdout?.destroy();
1179
+ child.stdin?.destroy();
1180
+ void trackedChild.terminate().catch(() => {
1181
+ });
1182
+ options.pipeHooks?.onTransportError?.(error);
1183
+ } : void 0;
1184
+ const pipeHooks = options.pipeLimits ? {
1185
+ ...options.pipeHooks,
1186
+ onMessageObserved: /* @__PURE__ */ __name((observation) => {
1187
+ if (observation.direction === "sent") {
1188
+ preparedResponses?.releaseMessage(observation.message);
1189
+ }
1190
+ options.pipeHooks?.onMessageObserved?.(observation);
1191
+ }, "onMessageObserved"),
1192
+ onTransportError: failTransport
1193
+ } : options.pipeHooks;
1194
+ const stream = ndJsonStream(
1195
+ writable,
1196
+ readable,
1197
+ pipeHooks,
1198
+ options.pipeLimits,
1199
+ options.pipeLimits ? validateDaemonInboundMessage : void 0,
1200
+ options.pipeLimits !== void 0
1201
+ );
1202
+ return {
1203
+ stream,
1204
+ ...transportFailed ? { transportFailed } : {},
1205
+ ...failTransport && options.pipeLimits ? {
1206
+ transportGuard: {
1207
+ maxActiveHandlers: options.pipeLimits.maxQueuedMessages,
1208
+ maxActiveHandlerBytes: options.pipeLimits.maxQueuedBytes,
1209
+ reserveOutboundOperation: /* @__PURE__ */ __name((value) => {
1210
+ try {
1211
+ return outboundOperations?.reserve(value) ?? (() => {
1212
+ });
1213
+ } catch (error) {
1214
+ failTransport(error);
1215
+ throw error;
1216
+ }
1217
+ }, "reserveOutboundOperation"),
1218
+ reservePreparedResponse: /* @__PURE__ */ __name((value) => {
1219
+ try {
1220
+ preparedResponses?.reserve(value);
1221
+ } catch (error) {
1222
+ failTransport(error);
1223
+ throw error;
1224
+ }
1225
+ }, "reservePreparedResponse"),
1226
+ fail: failTransport
1227
+ }
1228
+ } : {},
1229
+ kill: /* @__PURE__ */ __name(() => trackedChild.terminate(), "kill"),
1230
+ killSync: /* @__PURE__ */ __name(() => trackedChild.killSync(), "killSync"),
1231
+ exited: trackedChild.exited
1232
+ };
1233
+ };
1234
+ }
1235
+ __name(createSpawnChannelFactory, "createSpawnChannelFactory");
1236
+ var defaultSpawnChannelFactory = createSpawnChannelFactory();
1237
+ var SCRUBBED_CHILD_ENV_KEYS = /* @__PURE__ */ new Set([
1238
+ "QWEN_SERVER_TOKEN",
1239
+ "QWEN_CODE_SIMPLE",
1240
+ EXTERNAL_TOOL_GUARD_TOKEN_ENV
1241
+ ]);
1242
+ function scrubChildEnv(source, scrubbed, overrides) {
1243
+ const childEnv = { ...source };
1244
+ for (const key of scrubbed) {
1245
+ delete childEnv[key];
1246
+ }
1247
+ if (overrides) {
1248
+ for (const [key, value] of Object.entries(overrides)) {
1249
+ if (scrubbed.has(key)) continue;
1250
+ if (value === void 0) {
1251
+ delete childEnv[key];
1252
+ } else {
1253
+ childEnv[key] = value;
1254
+ }
1255
+ }
1256
+ }
1257
+ return childEnv;
1258
+ }
1259
+ __name(scrubChildEnv, "scrubChildEnv");
1260
+
1261
+ export {
1262
+ ndJsonStream,
1263
+ DAEMON_ACP_NDJSON_LIMITS,
1264
+ getAcpMemoryArgs,
1265
+ createStderrForwarder,
1266
+ createSpawnChannelFactory,
1267
+ defaultSpawnChannelFactory,
1268
+ scrubChildEnv
1269
+ };
1270
+ /**
1271
+ * @license
1272
+ * Copyright 2026 Qwen Team
1273
+ * SPDX-License-Identifier: Apache-2.0
1274
+ */
1275
+ /**
1276
+ * @license
1277
+ * Copyright 2025 Qwen Team
1278
+ * SPDX-License-Identifier: Apache-2.0
1279
+ */