@qwen-code/qwen-code 0.21.12-preview.3 → 0.21.12

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 (348) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +10 -0
  2. package/bundled/qc-helper/docs/features/channels/overview.md +1 -1
  3. package/bundled/qc-helper/docs/features/channels/plugins.md +11 -11
  4. package/bundled/qc-helper/docs/features/code-review.md +1 -1
  5. package/bundled/qc-helper/docs/qwen-serve.md +99 -34
  6. package/bundled/review/SKILL.md +55 -36
  7. package/chunks/{MaxSizedBox-EIK4BHBQ.js → MaxSizedBox-ZSJJ2D5S.js} +46 -46
  8. package/chunks/{StandaloneSessionPicker-NHVJDRYD.js → StandaloneSessionPicker-WHUHQXSA.js} +65 -66
  9. package/chunks/{acp-startup-profiler-JMJBZDVO.js → acp-startup-profiler-SVPUHLXV.js} +2 -2
  10. package/chunks/{acpAgent-37UDZP64.js → acpAgent-7JOAESF5.js} +960 -539
  11. package/chunks/{agent-FAWBG7PP.js → agent-E6V3VXQR.js} +42 -42
  12. package/chunks/{agent-headless-SHK4PCCH.js → agent-headless-OEQNFOMH.js} +42 -42
  13. package/chunks/{anthropicContentGenerator-4JSC3ZFL.js → anthropicContentGenerator-YDT4EOKO.js} +25 -25
  14. package/chunks/{artifact-tool-FRMBPDPB.js → artifact-tool-4GCQQDZI.js} +5 -5
  15. package/chunks/{askUserQuestion-7G3LI3IZ.js → askUserQuestion-HZJJLR3Z.js} +2 -2
  16. package/chunks/{bridge-DEAYNDCI.js → bridge-NPBV53UA.js} +49 -49
  17. package/chunks/{build-RZS65IIX.js → build-GDBLPA24.js} +1 -1
  18. package/chunks/{channel-management-service-SKAN6NOB.js → channel-management-service-OADNGQM3.js} +4 -4
  19. package/chunks/{channel-settings-store-UIGYER6R.js → channel-settings-store-4ODLJ4X2.js} +49 -49
  20. package/chunks/{channel-worker-group-YPTB5ASD.js → channel-worker-group-IHBIHQ45.js} +7 -7
  21. package/chunks/{channel-worker-manager-4EHJSPRH.js → channel-worker-manager-GEHYJ5AE.js} +7 -7
  22. package/chunks/{channel-worker-supervisor-DZKHYFHV.js → channel-worker-supervisor-ZJIIWM4I.js} +5 -5
  23. package/chunks/{chunk-LHOG4E6Y.js → chunk-22C7BQ6D.js} +3 -3
  24. package/chunks/{chunk-DP3IHZGG.js → chunk-2AUM35J5.js} +59 -7
  25. package/chunks/{chunk-2SB4SLKC.js → chunk-2IIJTXYF.js} +1 -3
  26. package/chunks/{chunk-DYVCDQW2.js → chunk-2IVYL3IF.js} +1 -1
  27. package/chunks/{chunk-EYW54TBD.js → chunk-2ZWH53I4.js} +3 -3
  28. package/chunks/{chunk-5I5NMQCU.js → chunk-36XKGB7E.js} +3 -3
  29. package/chunks/{chunk-AQHNAA7E.js → chunk-3AEKDXKT.js} +1 -1
  30. package/chunks/{chunk-M6SXIXBV.js → chunk-3GDBZJD6.js} +6 -6
  31. package/chunks/{chunk-6XZERB6P.js → chunk-3GM5DLBI.js} +5 -5
  32. package/chunks/{chunk-4M2F7OG7.js → chunk-3LDGOQXZ.js} +6 -6
  33. package/chunks/{chunk-BKHCW2BI.js → chunk-3VUENPWF.js} +10 -0
  34. package/chunks/{chunk-ENEEQMGM.js → chunk-45NQKMYB.js} +1 -1
  35. package/chunks/{chunk-MDFUBQAQ.js → chunk-47BGDLJG.js} +119 -27
  36. package/chunks/{chunk-EFIMD5VA.js → chunk-4AOVQPJU.js} +1 -1
  37. package/chunks/{chunk-HB6QW4LM.js → chunk-4KM2SYK5.js} +19 -16
  38. package/chunks/{chunk-UNCIELQJ.js → chunk-4XA4QIUA.js} +1 -1
  39. package/chunks/{chunk-2J53A6MV.js → chunk-56HVDG3M.js} +4 -4
  40. package/chunks/{chunk-N3FJOQX7.js → chunk-5AFGJNY6.js} +4 -4
  41. package/chunks/{chunk-2AZMF6G5.js → chunk-5RUCD4ED.js} +2 -2
  42. package/chunks/{chunk-32VOOMEF.js → chunk-62X3CM7Q.js} +7 -7
  43. package/chunks/{chunk-6LYDH7VT.js → chunk-63FNZTWG.js} +2 -2
  44. package/chunks/{chunk-P64FPV3G.js → chunk-6JEIRPLN.js} +47 -4
  45. package/chunks/{chunk-O5G7IQGM.js → chunk-6P5EXEBL.js} +499 -112
  46. package/chunks/{chunk-3ZYX7AUR.js → chunk-6SPD4Z7F.js} +1 -1
  47. package/chunks/{chunk-YZJVVQD3.js → chunk-6ZKSO6K7.js} +7 -7
  48. package/chunks/{chunk-N5ULBHP3.js → chunk-7KJPO7YH.js} +2 -2
  49. package/chunks/{chunk-MZSJ43WV.js → chunk-7U5G6JXI.js} +24 -2
  50. package/chunks/{chunk-K7JW6V5O.js → chunk-A6NRNRKE.js} +1 -1
  51. package/chunks/{chunk-XLQS3VI6.js → chunk-AKBFSOC5.js} +2 -2
  52. package/chunks/{chunk-LT532KF4.js → chunk-AW27A43Y.js} +10 -12
  53. package/chunks/{chunk-M4NWDIFU.js → chunk-AZQ3DT76.js} +1 -1
  54. package/chunks/{chunk-4GLFFNP3.js → chunk-B4VN3VDH.js} +5 -5
  55. package/chunks/{chunk-YTYPRVIZ.js → chunk-BSR5AXZR.js} +4 -3
  56. package/chunks/{chunk-AJX4ITUG.js → chunk-BSSLSQEW.js} +3 -3
  57. package/chunks/{chunk-EYY4IBPV.js → chunk-CGM3E75C.js} +3 -3
  58. package/chunks/{chunk-V4MJ56RS.js → chunk-CIDQISGM.js} +5 -5
  59. package/chunks/{chunk-T6W4KACQ.js → chunk-CPFFU46D.js} +1 -1
  60. package/chunks/{chunk-TYCXSMZU.js → chunk-CQ6IPDQW.js} +3 -3
  61. package/chunks/{chunk-KIFRFCCB.js → chunk-CZ4OWGQQ.js} +67 -22
  62. package/chunks/{chunk-N7NBMAMW.js → chunk-D2RNVVH6.js} +2 -2
  63. package/chunks/{chunk-KPVVWKF3.js → chunk-D7QGE3RT.js} +1 -1
  64. package/chunks/{chunk-TYGKUOEG.js → chunk-DAV4QFD5.js} +3 -11
  65. package/chunks/{chunk-QUESTNOP.js → chunk-DD6O3ZRD.js} +1 -1
  66. package/chunks/{chunk-NWPO6I7V.js → chunk-DEDESZDL.js} +1 -1
  67. package/chunks/{chunk-7LZ7DK4D.js → chunk-DFVXU5YM.js} +1 -1
  68. package/chunks/{chunk-TBVNYG5B.js → chunk-DG4IQ6JG.js} +5 -5
  69. package/chunks/{chunk-SAQHDAUJ.js → chunk-DPTMKFIH.js} +452 -57
  70. package/chunks/{chunk-M6HXP2SG.js → chunk-EBPLKY6U.js} +2192 -849
  71. package/chunks/{chunk-3XZYK76R.js → chunk-EJOGLSNJ.js} +2 -2
  72. package/chunks/{chunk-L7T742G2.js → chunk-FA5K6YI2.js} +47 -3
  73. package/chunks/{chunk-M2NMFAFR.js → chunk-FMIH5KMQ.js} +1 -1
  74. package/chunks/{chunk-HHGQGTJQ.js → chunk-FQDCO3CJ.js} +10 -1
  75. package/chunks/{chunk-V3LXMASR.js → chunk-FRHQQC2Z.js} +1 -1
  76. package/chunks/{chunk-732MOPEM.js → chunk-G6MUFRNI.js} +1 -1
  77. package/chunks/{chunk-KNXA5XXK.js → chunk-GXTMEATA.js} +15 -34
  78. package/chunks/{chunk-7SUQZ7QH.js → chunk-GZDWTBT3.js} +2 -2
  79. package/chunks/{chunk-IQFYO5BF.js → chunk-H7TMVHKE.js} +1 -1
  80. package/chunks/{chunk-KNQZXSLW.js → chunk-HG3UBTJ4.js} +23 -9
  81. package/chunks/{chunk-MPBRV3UU.js → chunk-HOSVOUDK.js} +71 -0
  82. package/chunks/{chunk-OPBATTFQ.js → chunk-HTYND72J.js} +1 -1
  83. package/chunks/{chunk-I4XSOFH2.js → chunk-I7BT2MME.js} +1 -1
  84. package/chunks/{chunk-LHY6HBRA.js → chunk-IH4Z54RJ.js} +7 -5
  85. package/chunks/{chunk-GYBDYWMV.js → chunk-IRSLAS4M.js} +2 -2
  86. package/chunks/{chunk-UZPWH6SP.js → chunk-IX4PWUDU.js} +401 -173
  87. package/chunks/{chunk-KT4OWAAZ.js → chunk-JRIVMPD2.js} +3 -3
  88. package/chunks/{chunk-Q7YDKOGY.js → chunk-JVEGA3MM.js} +1 -1
  89. package/chunks/{chunk-O5AZPHYZ.js → chunk-K34GJQOZ.js} +138 -16
  90. package/chunks/{chunk-L2GTEEEU.js → chunk-K5IDV3PC.js} +44 -1
  91. package/chunks/{chunk-5HBFERG5.js → chunk-KEC5FHLM.js} +3 -3
  92. package/chunks/{chunk-5PWLQ7SK.js → chunk-KLOMACIR.js} +15 -8
  93. package/chunks/{chunk-XWUQ4IH5.js → chunk-KWX56CHZ.js} +7 -7
  94. package/chunks/{chunk-VQZXRLEX.js → chunk-LCX5B364.js} +3 -3
  95. package/chunks/{chunk-CTQE2NB2.js → chunk-LSRI3ND3.js} +1 -1
  96. package/chunks/{chunk-5TXOGH4I.js → chunk-LUISTZXI.js} +3 -3
  97. package/chunks/{chunk-6AECVSVX.js → chunk-MAKIANMX.js} +3 -3
  98. package/chunks/{chunk-M4OYAR6J.js → chunk-MDNUCDKZ.js} +2 -2
  99. package/chunks/{chunk-CZXQ4UZA.js → chunk-MELQSJOU.js} +1 -1
  100. package/chunks/{chunk-6ZIIHBNV.js → chunk-MUNA4QDC.js} +4 -4
  101. package/chunks/{chunk-E5BWLU5J.js → chunk-N4SVADAV.js} +305 -143
  102. package/chunks/{chunk-URK542T4.js → chunk-NF5J2WFA.js} +15 -2
  103. package/chunks/{chunk-GJJQV4PY.js → chunk-NLFLYSS4.js} +1 -1
  104. package/chunks/{chunk-FRH4SSGX.js → chunk-NW2GIPG3.js} +2 -4
  105. package/chunks/{chunk-JS4Q5NG5.js → chunk-NX4A23LY.js} +3 -3
  106. package/chunks/{chunk-DEG7R6Z6.js → chunk-OK47XBYH.js} +79 -36
  107. package/chunks/{chunk-7D4KEFOT.js → chunk-OPVF453Q.js} +3 -3
  108. package/chunks/{chunk-J7DNMZFO.js → chunk-OR64CU46.js} +1 -1
  109. package/chunks/{chunk-DAX3G67A.js → chunk-OWGRUU7F.js} +1 -1
  110. package/chunks/{chunk-M2PY7CNK.js → chunk-OWXFBIB6.js} +2 -2
  111. package/chunks/{chunk-NELCY6JT.js → chunk-OYWVIXHT.js} +1 -3
  112. package/chunks/{chunk-V7RNNPGC.js → chunk-P5Y23G2L.js} +18 -1
  113. package/chunks/{chunk-QZ5G26ZE.js → chunk-PTSEETCO.js} +27 -27
  114. package/chunks/{chunk-IEP44U2R.js → chunk-PVXEJB66.js} +1 -1
  115. package/chunks/{chunk-NC4O6UE6.js → chunk-PZW46OTB.js} +2 -2
  116. package/chunks/{chunk-RQVVXDHS.js → chunk-Q4ZPYNIZ.js} +4 -4
  117. package/chunks/{chunk-QSWDGAIC.js → chunk-QILD6R27.js} +1 -1
  118. package/chunks/{chunk-GLWWPFTW.js → chunk-QLTATTPS.js} +1 -1
  119. package/chunks/{chunk-QTI7SRXI.js → chunk-QPBFRWCP.js} +3 -3
  120. package/chunks/{chunk-3TT6MZHJ.js → chunk-QSD4UH74.js} +842 -62
  121. package/chunks/{chunk-TEKFBSMY.js → chunk-RDVNSJQU.js} +3 -3
  122. package/chunks/{chunk-NPE3STIW.js → chunk-ROIJYS5K.js} +6 -6
  123. package/chunks/{chunk-JEMR2FTD.js → chunk-RQJA2YYO.js} +4 -4
  124. package/chunks/{chunk-YI6UGZF5.js → chunk-S6TCTH4Z.js} +13 -13
  125. package/chunks/{chunk-ZGWY4YUB.js → chunk-SYHXR6WM.js} +5 -5
  126. package/chunks/{chunk-O4BBDP2G.js → chunk-TB4YFWXG.js} +2 -2
  127. package/chunks/{chunk-ILVATFYJ.js → chunk-TDESMS7M.js} +22 -18
  128. package/chunks/{chunk-47FQVRCO.js → chunk-TMFWI4RC.js} +1 -1
  129. package/chunks/{chunk-T4FTABSW.js → chunk-TQDFSQQF.js} +1 -1
  130. package/chunks/{chunk-ZV4XVYL3.js → chunk-TTRH3RTQ.js} +4 -4
  131. package/chunks/{chunk-ZWPWQEF5.js → chunk-TXP5NGG3.js} +1 -1
  132. package/chunks/{chunk-E3GLDLYB.js → chunk-TYAMGABM.js} +0 -6
  133. package/chunks/{chunk-VWD7SNNN.js → chunk-UI5UGEF4.js} +1082 -926
  134. package/chunks/{chunk-MWZYNOCG.js → chunk-ULNWG62W.js} +3 -3
  135. package/chunks/{chunk-HGCQ5SE7.js → chunk-UXEO7E3V.js} +21 -0
  136. package/chunks/{chunk-U6PTKAOW.js → chunk-V6OBVAST.js} +1 -1
  137. package/chunks/{chunk-5UPJ774B.js → chunk-VIFA5VJD.js} +1 -1
  138. package/chunks/{chunk-Y66OOMKS.js → chunk-VLHR7F4E.js} +595 -58
  139. package/chunks/{chunk-EYS3GGM3.js → chunk-VPV7WBVT.js} +1 -1
  140. package/chunks/{chunk-XCGIMOLN.js → chunk-WCCLLK7X.js} +14 -1
  141. package/chunks/{chunk-JL3LC3CQ.js → chunk-WCEI6J56.js} +1 -1
  142. package/chunks/{chunk-JXK3WAP7.js → chunk-WDVDVWJ3.js} +6 -6
  143. package/chunks/{chunk-ZQSNP4TG.js → chunk-WI6GIM2M.js} +2 -2
  144. package/chunks/{chunk-TRYJ3BVE.js → chunk-WM3LUQLO.js} +7 -7
  145. package/chunks/{chunk-VJNBRRZG.js → chunk-WZMH7II3.js} +1 -1
  146. package/chunks/{chunk-HBZUU4AE.js → chunk-X5SLJOMF.js} +9 -7
  147. package/chunks/{chunk-FDWH6CBK.js → chunk-XAFIL4BD.js} +7 -7
  148. package/chunks/{chunk-P2UCMHDT.js → chunk-XDRXOSAD.js} +3 -3
  149. package/chunks/{chunk-RRQJPCRQ.js → chunk-XH3KAV2G.js} +2 -2
  150. package/chunks/{chunk-F6AOBFUN.js → chunk-YBHUXEC6.js} +1 -1
  151. package/chunks/{chunk-GZGDJ4E6.js → chunk-YBVVOSOH.js} +1 -1
  152. package/chunks/{chunk-EXG2R5UR.js → chunk-YCHNAKC5.js} +16 -14
  153. package/chunks/{chunk-XTH2OMDS.js → chunk-YIGGWOJE.js} +1 -1
  154. package/chunks/{chunk-IX7CFQGA.js → chunk-YILJKX2T.js} +3 -3
  155. package/chunks/{chunk-SSAOTDK7.js → chunk-YX2RDGAL.js} +1 -1
  156. package/chunks/{chunk-6S52N6PG.js → chunk-ZBB5EZZV.js} +2 -2
  157. package/chunks/{chunk-3GCU5O2E.js → chunk-ZLCT4C5A.js} +1 -1
  158. package/chunks/{chunk-4ETA3KRC.js → chunk-ZMY2P4L3.js} +3 -3
  159. package/chunks/{chunk-575MI5K3.js → chunk-ZQUY3ZJU.js} +4 -4
  160. package/chunks/{computer-use-S4JEU5P7.js → computer-use-F4URV4TU.js} +45 -45
  161. package/chunks/{config-utils-TXVKR27S.js → config-utils-Z3OW3IQG.js} +4 -4
  162. package/chunks/{contextCommand-2H5OH2HW.js → contextCommand-IGSS2U5J.js} +44 -44
  163. package/chunks/{core-runtime-IAQ4DD4Y.js → core-runtime-H5CZDN3A.js} +42 -42
  164. package/chunks/{create-sub-session-EKHKXJAA.js → create-sub-session-PA7MFTHK.js} +42 -42
  165. package/chunks/{create-sub-session-Y4WYDZGC.js → create-sub-session-XT6DLYOE.js} +2 -2
  166. package/chunks/{cron-create-ZOVA3CC2.js → cron-create-2JZ2TWTF.js} +4 -4
  167. package/chunks/{cron-delete-7Z3H4LJY.js → cron-delete-CTPD2P26.js} +4 -4
  168. package/chunks/{cron-list-UHGX3IQG.js → cron-list-V44KHAF6.js} +4 -4
  169. package/chunks/{daemon-PXIC4ZDK.js → daemon-GED37WOX.js} +30 -2
  170. package/chunks/daemon-git-worktree-guard-LZDCNJGV.js +2062 -0
  171. package/chunks/daemon-status-provider-QYM57Z44.js +102 -0
  172. package/chunks/{daemon-trust-policy-7JOBVFH3.js → daemon-trust-policy-TSRVEYZR.js} +48 -48
  173. package/chunks/{daemon-trust-policy-monitor-OU3NRHAR.js → daemon-trust-policy-monitor-2K2YETMT.js} +48 -48
  174. package/chunks/{deferred-core-runtime-SFT3KI2C.js → deferred-core-runtime-FKJ3OYE7.js} +44 -44
  175. package/chunks/{devtools-X6ROTKHE.js → devtools-4QFYJT6U.js} +1 -1
  176. package/chunks/{display-image-ZE3GZNIK.js → display-image-M2ELAVN4.js} +4 -4
  177. package/chunks/{dist-KTYDJNYM.js → dist-4ZPG4BY6.js} +2 -2
  178. package/chunks/{dist-NPS52B2V.js → dist-BROOP2EG.js} +1 -1
  179. package/chunks/{dist-BW2LDPV3.js → dist-IYYN3RUT.js} +2 -2
  180. package/chunks/{dist-EFJILGIS.js → dist-JWMKPWT5.js} +3 -1
  181. package/chunks/{dist-AVUYBK7L.js → dist-K7IQB53U.js} +1 -1
  182. package/chunks/{dist-PKSRQAR2.js → dist-MAQXAQ2Y.js} +1 -1
  183. package/chunks/{dist-BNWP6IZL.js → dist-WJ4BHIEW.js} +2 -2
  184. package/chunks/{dist-ZWDH5HLS.js → dist-YEPL4RAW.js} +1 -1
  185. package/chunks/{earlyInputCapture-27RPWE2D.js → earlyInputCapture-WJBSJQUF.js} +43 -43
  186. package/chunks/{edit-WXVZ7FHS.js → edit-X73LA4YO.js} +50 -49
  187. package/chunks/{enter-worktree-TYMVXFLA.js → enter-worktree-CLRQTIVN.js} +47 -47
  188. package/chunks/{enterPlanMode-FT4MRU5N.js → enterPlanMode-6BDYUQ5T.js} +48 -48
  189. package/chunks/{environment-Z6OMA34I.js → environment-WOAJXJDJ.js} +44 -44
  190. package/chunks/{errors-YMXK2GG3.js → errors-7OY5MXYY.js} +44 -44
  191. package/chunks/{exit-worktree-ODZUQLGJ.js → exit-worktree-TFFJXCRT.js} +47 -47
  192. package/chunks/{exitPlanMode-MBPAPBBV.js → exitPlanMode-WDURQMIU.js} +42 -42
  193. package/chunks/{external-tool-guard-provider-5HTGOPGU.js → external-tool-guard-provider-TE4DRY36.js} +1 -1
  194. package/chunks/{fast-path-ZU5T6XSN.js → fast-path-QQLGC37M.js} +5 -5
  195. package/chunks/{gemini-OZK6AIMC.js → gemini-VHE62IJL.js} +110 -105
  196. package/chunks/{geminiContentGenerator-MC6ZKWZG.js → geminiContentGenerator-VSHIEGAQ.js} +11 -11
  197. package/chunks/{glob-KJ4A4ZOM.js → glob-VMEEDDLO.js} +49 -49
  198. package/chunks/{goal-tools-JDK2SNMV.js → goal-tools-M4UDAZXP.js} +4 -4
  199. package/chunks/{grep-QWBLG564.js → grep-F4UAR7KX.js} +47 -47
  200. package/chunks/{handleAutoUpdate-M3ACKDKF.js → handleAutoUpdate-GN7Z6QAC.js} +46 -46
  201. package/chunks/{i18n-FPW7XZL5.js → i18n-ETW24DHW.js} +43 -43
  202. package/chunks/{image-gen-OTFC2S7L.js → image-gen-YPK2AZT4.js} +11 -11
  203. package/chunks/{initializer-5HKUXXBT.js → initializer-UA6KQ7MS.js} +49 -49
  204. package/chunks/{installationInfo-4OA6UW7V.js → installationInfo-P7OTIR4P.js} +43 -43
  205. package/chunks/{keychain-token-storage-JTWUYFU7.js → keychain-token-storage-NKKCUHI2.js} +2 -2
  206. package/chunks/{list-3TKZ264A.js → list-GRAMIQOT.js} +51 -51
  207. package/chunks/{list-agents-4GQ2XNEU.js → list-agents-O6WSY4CT.js} +2 -2
  208. package/chunks/{loadedSettingsAdapter-IRUANLS2.js → loadedSettingsAdapter-5O2TDS3I.js} +48 -48
  209. package/chunks/{loggingContentGenerator-D4URLH2A.js → loggingContentGenerator-J2J2AANS.js} +151 -120
  210. package/chunks/{loop-wakeup-HOQI3K5D.js → loop-wakeup-GVQRMUKS.js} +5 -5
  211. package/chunks/{ls-FSHISLLA.js → ls-6W2D7TKU.js} +6 -6
  212. package/chunks/{lsp-APQJ5ZEZ.js → lsp-NJ4KFBI2.js} +2 -2
  213. package/chunks/{managed-npm-update-2O7XSAWJ.js → managed-npm-update-WMV5ITKU.js} +45 -45
  214. package/chunks/{mcp-AFVHCHKT.js → mcp-XLP33CAI.js} +48 -48
  215. package/chunks/{monitor-PY4WDSX3.js → monitor-2MM23VDV.js} +47 -47
  216. package/chunks/{node-YSOU44FX.js → node-UUDY34IG.js} +3 -3
  217. package/chunks/nonInteractiveCli-KTA5K6FS.js +163 -0
  218. package/chunks/{notebook-edit-GEPL33NO.js → notebook-edit-QD4TRKLY.js} +47 -47
  219. package/chunks/{openaiContentGenerator-ACYSXQ6R.js → openaiContentGenerator-KLHSPVN2.js} +31 -31
  220. package/chunks/{pidfile-SUNYCAA4.js → pidfile-RQGZBNXT.js} +43 -43
  221. package/chunks/{processUtils-F7LP7YUV.js → processUtils-HZZDA2VV.js} +2 -2
  222. package/chunks/{qwenContentGenerator-BB6IPELF.js → qwenContentGenerator-T75M2Z3B.js} +50 -50
  223. package/chunks/{qwenOAuth2-OU3WGDOI.js → qwenOAuth2-5QZU444W.js} +10 -10
  224. package/chunks/{read-file-GORBXJTS.js → read-file-LOVUSBJC.js} +12 -12
  225. package/chunks/{read-mcp-resource-TJSJRH4F.js → read-mcp-resource-GWCP23WG.js} +2 -2
  226. package/chunks/{read-package-up-TCM6I7S2.js → read-package-up-K6RKTL5D.js} +1 -1
  227. package/chunks/{record-artifact-FXF5LHPE.js → record-artifact-IYQDEYMV.js} +3 -3
  228. package/chunks/{resumeHistoryUtils-FOAJJJWK.js → resumeHistoryUtils-LVKSSQII.js} +50 -50
  229. package/chunks/{ripGrep-RNLIZGCY.js → ripGrep-ZJSHKB6H.js} +42 -42
  230. package/chunks/{run-qwen-serve-GVMMX3IU.js → run-qwen-serve-GZW7B4WK.js} +186 -90
  231. package/chunks/{runtime-RNBZ5FDD.js → runtime-MYRXEO2E.js} +53 -53
  232. package/chunks/{scheduler-NTRFSPIP.js → scheduler-DPTPI6FW.js} +44 -44
  233. package/chunks/{sdk-exporters-grpc-4QKV6MCX.js → sdk-exporters-grpc-54L4LS5L.js} +2 -2
  234. package/chunks/{sdk-exporters-http-2VPMAPFI.js → sdk-exporters-http-NHBYB5FZ.js} +21 -17
  235. package/chunks/{sdk-impl-5W3JUCWF.js → sdk-impl-SK4P5WON.js} +17 -14
  236. package/chunks/{send-message-RBYLV5NY.js → send-message-O7FO63UK.js} +6 -6
  237. package/chunks/{serve-H3PGA26U.js → serve-XCG4XCDA.js} +52 -52
  238. package/chunks/{server-SUXD2F3C.js → server-AWQHKXLG.js} +310 -200
  239. package/chunks/{session-MTFVUWWM.js → session-P5FKNCNR.js} +94 -97
  240. package/chunks/{settings-GUJ3TN2J.js → settings-CSYVIP2R.js} +47 -47
  241. package/chunks/{shell-C2UP5FF2.js → shell-EGTSUO2P.js} +42 -42
  242. package/chunks/{skill-4XCNK55E.js → skill-IFUD72GF.js} +22 -22
  243. package/chunks/{skill-settings-Y2BU27XM.js → skill-settings-YOE7LBHE.js} +47 -47
  244. package/chunks/{spawnChannel-UUUUK734.js → spawnChannel-PQSZIOLY.js} +45 -47
  245. package/chunks/{standalone-update-MJ722XZ4.js → standalone-update-RB2EGUSF.js} +44 -44
  246. package/chunks/{startInteractiveUI-TCPIPNGN.js → startInteractiveUI-KMYUJ2MU.js} +3040 -2399
  247. package/chunks/{syntheticOutput-D3Z64LJC.js → syntheticOutput-DVHJMUGV.js} +3 -3
  248. package/chunks/{task-create-URFZ5EUX.js → task-create-4NC7PDI4.js} +11 -11
  249. package/chunks/{task-list-6JDFMPUW.js → task-list-LBSRMOC7.js} +5 -5
  250. package/chunks/{task-stop-HHUGCD25.js → task-stop-YFNATTIM.js} +2 -2
  251. package/chunks/{task-update-DVV6CUGI.js → task-update-BPLM52GD.js} +12 -12
  252. package/chunks/{team-create-WZWH2NJI.js → team-create-B6A6MJBT.js} +47 -47
  253. package/chunks/{team-delete-PZGGBQLM.js → team-delete-MKYMYBFM.js} +5 -5
  254. package/chunks/{team-plan-approval-SUZQJCWJ.js → team-plan-approval-5WO3CXXU.js} +48 -48
  255. package/chunks/{terminal-image-renderer-BCUN3Z3W.js → terminal-image-renderer-BTRE2GEU.js} +44 -44
  256. package/chunks/{theme-manager-UGMFDREN.js → theme-manager-XL2N5SBY.js} +43 -43
  257. package/chunks/{todoWrite-WINAZSZI.js → todoWrite-K5K7NRE5.js} +4 -4
  258. package/chunks/{tool-search-B6F3MPUZ.js → tool-search-QNBLXUGR.js} +18 -18
  259. package/chunks/{total-session-admission-MQLBJ5WL.js → total-session-admission-N4E5SFBO.js} +49 -49
  260. package/chunks/{trustedFolders-2XST7U5C.js → trustedFolders-MQS46LIU.js} +43 -43
  261. package/chunks/{update-relaunch-OVC7YNGD.js → update-relaunch-536KRL33.js} +5 -5
  262. package/chunks/{updateCheck-YAKM36WQ.js → updateCheck-QJI2SYWF.js} +48 -48
  263. package/chunks/{useAutoAcceptIndicator-RF6FVX3S.js → useAutoAcceptIndicator-7QASHD46.js} +51 -51
  264. package/chunks/{validateNonInterActiveAuth-IPPXFNQH.js → validateNonInterActiveAuth-ZNRGWBLV.js} +86 -88
  265. package/chunks/{version-4IDFEXOU.js → version-DBEQAFRW.js} +2 -2
  266. package/chunks/{web-fetch-NUOLHXPN.js → web-fetch-MBIVXKPE.js} +21 -21
  267. package/chunks/{web-search-LVOOV4XZ.js → web-search-4LBIN6VF.js} +16 -16
  268. package/chunks/{workflow-JSTYTG3K.js → workflow-LNMA55HY.js} +127 -61
  269. package/chunks/{workspace-providers-status-U4EYXA4K.js → workspace-providers-status-PDDMI6ST.js} +51 -51
  270. package/chunks/{workspace-registration-store-OG66U3CB.js → workspace-registration-store-BGRKKIYR.js} +1 -1
  271. package/chunks/{workspace-registry-WSHWQRQQ.js → workspace-registry-L4NCJ34K.js} +49 -49
  272. package/chunks/{workspace-service-QZXQHX2F.js → workspace-service-LOXYKYTR.js} +54 -54
  273. package/chunks/{workspace-skills-status-VRBHEX5O.js → workspace-skills-status-IJ5FOQI6.js} +49 -49
  274. package/chunks/{workspace-trust-reconciler-FCRIUIOF.js → workspace-trust-reconciler-H36TCR2S.js} +57 -57
  275. package/chunks/{write-file-PYL3JCCD.js → write-file-JJAY7JSP.js} +42 -42
  276. package/chunks/{zoom-image-RS6MU26F.js → zoom-image-4MVVVM7E.js} +12 -12
  277. package/cli.js +18 -17
  278. package/package.json +4 -4
  279. package/web-shell/assets/{arc-CgGUyHWd.js → arc-B-89zHN4.js} +1 -1
  280. package/web-shell/assets/{architectureDiagram-3BPJPVTR-BR0Qv-1Y.js → architectureDiagram-3BPJPVTR-BkcOncHk.js} +1 -1
  281. package/web-shell/assets/{blockDiagram-GPEHLZMM-DIoaceaI.js → blockDiagram-GPEHLZMM-DQ4yboaF.js} +1 -1
  282. package/web-shell/assets/{c4Diagram-AAUBKEIU-Bc5k6BbI.js → c4Diagram-AAUBKEIU-C_8ZjPDI.js} +1 -1
  283. package/web-shell/assets/channel-Du2WFns8.js +1 -0
  284. package/web-shell/assets/{chunk-2J33WTMH-DtPEz2WX.js → chunk-2J33WTMH-naKVe1Bm.js} +1 -1
  285. package/web-shell/assets/{chunk-4BX2VUAB-Dydo6ydE.js → chunk-4BX2VUAB-DdoViKT2.js} +1 -1
  286. package/web-shell/assets/{chunk-55IACEB6-DD9_VWXm.js → chunk-55IACEB6-DUDQZEwU.js} +1 -1
  287. package/web-shell/assets/{chunk-727SXJPM-DVI2m59k.js → chunk-727SXJPM-BqpDTR5s.js} +1 -1
  288. package/web-shell/assets/{chunk-AQP2D5EJ-luatmaTN.js → chunk-AQP2D5EJ-CdmEknkT.js} +1 -1
  289. package/web-shell/assets/{chunk-FMBD7UC4-Duy8NTIi.js → chunk-FMBD7UC4-CH7fFTLB.js} +1 -1
  290. package/web-shell/assets/{chunk-ND2GUHAM-CrL1yhms.js → chunk-ND2GUHAM-ObgSuFKF.js} +1 -1
  291. package/web-shell/assets/{chunk-QZHKN3VN-C7BX6bu1.js → chunk-QZHKN3VN-D9fKdv_s.js} +1 -1
  292. package/web-shell/assets/classDiagram-4FO5ZUOK-Zw0HafH6.js +1 -0
  293. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Zw0HafH6.js +1 -0
  294. package/web-shell/assets/{cose-bilkent-S5V4N54A-BTzs7mIi.js → cose-bilkent-S5V4N54A-CvzATMx9.js} +1 -1
  295. package/web-shell/assets/{dagre-BM42HDAG-3VTUmWts.js → dagre-BM42HDAG-M_xU21QW.js} +1 -1
  296. package/web-shell/assets/{diagram-2AECGRRQ-Ehdp75GN.js → diagram-2AECGRRQ-CNrl9sW1.js} +1 -1
  297. package/web-shell/assets/{diagram-5GNKFQAL-B3wu3teE.js → diagram-5GNKFQAL-CUweVT6T.js} +1 -1
  298. package/web-shell/assets/{diagram-KO2AKTUF-DjgTSf2S.js → diagram-KO2AKTUF-D3n6Lxjo.js} +1 -1
  299. package/web-shell/assets/{diagram-LMA3HP47-Br9mwjY3.js → diagram-LMA3HP47-0SeFPK4t.js} +1 -1
  300. package/web-shell/assets/{diagram-OG6HWLK6-D4xz5M-z.js → diagram-OG6HWLK6-DAgyEwge.js} +1 -1
  301. package/web-shell/assets/{erDiagram-TEJ5UH35-CXayWlG_.js → erDiagram-TEJ5UH35-CzxBBDIK.js} +1 -1
  302. package/web-shell/assets/{flowDiagram-I6XJVG4X-CLonjQTi.js → flowDiagram-I6XJVG4X-B0uj0jyo.js} +1 -1
  303. package/web-shell/assets/{ganttDiagram-6RSMTGT7-BTySFT-1.js → ganttDiagram-6RSMTGT7-DFzcj5km.js} +1 -1
  304. package/web-shell/assets/{gitGraphDiagram-PVQCEYII--2WcUjOe.js → gitGraphDiagram-PVQCEYII-DylJ_Fc9.js} +1 -1
  305. package/web-shell/assets/index-BIGQygTL.css +5 -0
  306. package/web-shell/assets/{index-DPJHkFOG.js → index-BKSAnXU9.js} +1 -1
  307. package/web-shell/assets/index-J7OMTqAN.js +1789 -0
  308. package/web-shell/assets/{infoDiagram-5YYISTIA-9vpgAf1m.js → infoDiagram-5YYISTIA-BYMcJVMI.js} +1 -1
  309. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-DcRpHnAW.js → ishikawaDiagram-YF4QCWOH-t1quI1S3.js} +1 -1
  310. package/web-shell/assets/{journeyDiagram-JHISSGLW-C2TKorRm.js → journeyDiagram-JHISSGLW-YM_QVUJm.js} +1 -1
  311. package/web-shell/assets/{kanban-definition-UN3LZRKU-DdsFwB8b.js → kanban-definition-UN3LZRKU-jw8OddK1.js} +1 -1
  312. package/web-shell/assets/{linear-7PjRvJrf.js → linear-Dlr3RVuP.js} +1 -1
  313. package/web-shell/assets/{mermaid.core-raDXa11C.js → mermaid.core-CqGKzNzd.js} +5 -5
  314. package/web-shell/assets/{mindmap-definition-RKZ34NQL-DLHc-PRN.js → mindmap-definition-RKZ34NQL-BqureoOS.js} +1 -1
  315. package/web-shell/assets/{pieDiagram-4H26LBE5-BftYpeTW.js → pieDiagram-4H26LBE5-Da20HkK1.js} +1 -1
  316. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-O-6ygOYn.js → quadrantDiagram-W4KKPZXB-BsNlMvJy.js} +1 -1
  317. package/web-shell/assets/{requirementDiagram-4Y6WPE33-BmZWVufJ.js → requirementDiagram-4Y6WPE33-DzVCQCse.js} +1 -1
  318. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-2x5beiWt.js → sankeyDiagram-5OEKKPKP-BMo16voT.js} +1 -1
  319. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-BH8uKokQ.js → sequenceDiagram-3UESZ5HK-Bgi-pdHk.js} +1 -1
  320. package/web-shell/assets/{stateDiagram-AJRCARHV-Dq1MFgX_.js → stateDiagram-AJRCARHV-xaPQXwGk.js} +1 -1
  321. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-D5RqimXD.js +1 -0
  322. package/web-shell/assets/{timeline-definition-PNZ67QCA-Cl2WKbv9.js → timeline-definition-PNZ67QCA-C_9RuvKG.js} +1 -1
  323. package/web-shell/assets/{vennDiagram-CIIHVFJN-BqoRo_Q-.js → vennDiagram-CIIHVFJN-Bgu6vdla.js} +1 -1
  324. package/web-shell/assets/{wardley-L42UT6IY-BTxp-Yot.js → wardley-L42UT6IY-CFTZ8IrX.js} +1 -1
  325. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-DFXVCSH2.js → wardleyDiagram-YWT4CUSO-BASW9Vmt.js} +1 -1
  326. package/web-shell/assets/{xychartDiagram-2RQKCTM6-qQhWx0aE.js → xychartDiagram-2RQKCTM6--Nh-CD3F.js} +1 -1
  327. package/web-shell/index.html +2 -2
  328. package/chunks/chunk-CG3OQDNY.js +0 -649
  329. package/chunks/chunk-L34XSHIZ.js +0 -28
  330. package/chunks/chunk-N2TNM3QB.js +0 -9
  331. package/chunks/chunk-UOMZKPI5.js +0 -830
  332. package/chunks/chunk-WFRHWDBT.js +0 -622
  333. package/chunks/chunk-WLML6VIA.js +0 -18
  334. package/chunks/chunk-ZBBVBZBR.js +0 -137
  335. package/chunks/chunk-bdqvmfwv-OHYAFAAO.js +0 -17446
  336. package/chunks/daemon-status-provider-LPYR2GXY.js +0 -103
  337. package/chunks/dispatch-B53LNEO4.js +0 -37
  338. package/chunks/nonInteractiveCli-ZHW6F76F.js +0 -166
  339. package/chunks/opentui-entry-SBAOWW7M.js +0 -52325
  340. package/chunks/runtime-gate-T4ICWGQJ.js +0 -89
  341. package/chunks/wrapper-46Z24CTM.js +0 -35
  342. package/web-shell/assets/channel-D2b9IYpS.js +0 -1
  343. package/web-shell/assets/classDiagram-4FO5ZUOK-DHatTCmD.js +0 -1
  344. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-DHatTCmD.js +0 -1
  345. package/web-shell/assets/index-CIFO52Wx.css +0 -5
  346. package/web-shell/assets/index-bhq3CUUF.js +0 -1789
  347. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-spuAYji6.js +0 -1
  348. /package/chunks/{chunk-44CTCCLY.js → chunk-NWNEANAT.js} +0 -0
@@ -5,23 +5,28 @@ import {
5
5
  } from "./chunk-4NFY2S7N.js";
6
6
  import {
7
7
  formatHistoryGapNotice
8
- } from "./chunk-U6PTKAOW.js";
8
+ } from "./chunk-V6OBVAST.js";
9
9
  import {
10
10
  loadUndici
11
11
  } from "./chunk-3Z43GZUQ.js";
12
12
  import {
13
+ projectGoalStateToLegacy
14
+ } from "./chunk-EBPLKY6U.js";
15
+ import {
16
+ parseGoalSnapshotV2,
17
+ parseGoalStateCause,
13
18
  projectUserTranscriptForDisplay
14
- } from "./chunk-SAQHDAUJ.js";
19
+ } from "./chunk-DPTMKFIH.js";
15
20
  import {
16
21
  formatVisionBridgeNoticeDisplay,
17
22
  isVisionBridgeNoticeDisplay
18
- } from "./chunk-HB6QW4LM.js";
23
+ } from "./chunk-4KM2SYK5.js";
19
24
  import {
20
25
  ToolNames
21
- } from "./chunk-XTH2OMDS.js";
26
+ } from "./chunk-YIGGWOJE.js";
22
27
  import {
23
28
  createDebugLogger
24
- } from "./chunk-MPBRV3UU.js";
29
+ } from "./chunk-HOSVOUDK.js";
25
30
  import {
26
31
  writeStderrLine,
27
32
  writeStderrLineSafe
@@ -33,599 +38,147 @@ import {
33
38
  __name
34
39
  } from "./chunk-J2S4EL5Y.js";
35
40
 
36
- // packages/cli/src/services/setup-github.ts
41
+ // packages/cli/src/acp-integration/session/history-replayer.ts
37
42
  init_esbuild_shims();
38
- import { promises as fsp } from "node:fs";
39
- import * as path from "node:path";
40
43
 
41
- // packages/cli/src/utils/gitUtils.ts
44
+ // packages/acp-bridge/src/transcript-replay.ts
42
45
  init_esbuild_shims();
43
- import * as childProcess from "node:child_process";
44
- var debugLogger = createDebugLogger("GIT");
45
- async function runGit(args, opts = {}) {
46
- return await new Promise((resolve2, reject) => {
47
- childProcess.execFile(
48
- "git",
49
- args,
50
- {
51
- encoding: "utf-8",
52
- ...opts.cwd ? { cwd: opts.cwd } : {}
53
- },
54
- (err, stdout) => {
55
- if (err) {
56
- reject(err);
57
- return;
58
- }
59
- resolve2(String(stdout ?? "").trim());
60
- }
61
- );
62
- });
46
+
47
+ // packages/core/dist/src/goals/goal-wire.js
48
+ init_esbuild_shims();
49
+
50
+ // packages/core/dist/src/goals/goal-protocol.js
51
+ init_esbuild_shims();
52
+ var GOAL_STATE_VERSION = 2;
53
+ var GOAL_CHECKPOINT_CLAIM_LIMIT = 32;
54
+ var GOAL_CHECKPOINT_CLAIM_MAX_CHARACTERS = 2e3;
55
+ var GOAL_CHECKPOINT_CLAIM_MAX_BYTES = 16e3;
56
+ var GOAL_CHECKPOINT_SOURCE_REFERENCE_LIMIT = 32;
57
+ function isGoalEvidenceProofKind(value) {
58
+ return value === "user_input" || value === "delivered_output" || value === "external_fact";
63
59
  }
64
- __name(runGit, "runGit");
65
- var isGitHubRepositoryAsync = /* @__PURE__ */ __name(async (opts = {}) => {
66
- try {
67
- const remotes = await runGit(["remote", "-v"], opts);
68
- return remotes.split("\n").some((line) => {
69
- const remoteUrl = line.trim().split(/\s+/)[1];
70
- return remoteUrl ? isGitHubRemoteUrl(remoteUrl) : false;
71
- });
72
- } catch (_error) {
73
- debugLogger.debug(`Failed to get git remote:`, _error);
74
- return false;
75
- }
76
- }, "isGitHubRepositoryAsync");
77
- function isGitHubRemoteUrl(remoteUrl) {
78
- if (remoteUrl.startsWith("git@github.com:")) {
79
- return true;
80
- }
81
- if (remoteUrl.startsWith("git@")) {
82
- return false;
60
+ __name(isGoalEvidenceProofKind, "isGoalEvidenceProofKind");
61
+
62
+ // packages/core/dist/src/goals/goal-reducer.js
63
+ init_esbuild_shims();
64
+ var MAX_BLOCKED_AUDIT_COUNT = 3;
65
+ function parseGoalStateRecordPayloadV2(value) {
66
+ if (!isRecord(value) || !hasOnlyKeys(value, [
67
+ "v",
68
+ "cause",
69
+ "snapshot",
70
+ "checkpointPending",
71
+ "blockedAudit"
72
+ ]) || value["v"] !== GOAL_STATE_VERSION || !isGoalStateCause(value["cause"]) || !isCheckpointPending(value["checkpointPending"]) || !isBlockedAudit(value["blockedAudit"])) {
73
+ return void 0;
83
74
  }
84
- try {
85
- return new URL(remoteUrl).hostname === "github.com";
86
- } catch {
87
- return false;
75
+ const parsedSnapshot = parseGoalSnapshotV22(value["snapshot"]);
76
+ if (parsedSnapshot?.activity !== "idle")
77
+ return void 0;
78
+ const checkpointPending = value["checkpointPending"];
79
+ if (checkpointPending && (parsedSnapshot.goal?.status !== "active" || checkpointPending.permit.goalId !== parsedSnapshot.goal.goalId || checkpointPending.permit.revision !== parsedSnapshot.goal.revision || checkpointPending.recordUuid === parsedSnapshot.goal.evidenceCursor.recordId || value["cause"] !== "turn_finished" && value["cause"] !== "verifier_reject")) {
80
+ return void 0;
88
81
  }
82
+ return {
83
+ v: GOAL_STATE_VERSION,
84
+ cause: value["cause"],
85
+ snapshot: parsedSnapshot,
86
+ ...checkpointPending ? { checkpointPending: structuredClone(checkpointPending) } : {},
87
+ ...value["blockedAudit"] ? { blockedAudit: structuredClone(value["blockedAudit"]) } : {}
88
+ };
89
89
  }
90
- __name(isGitHubRemoteUrl, "isGitHubRemoteUrl");
91
- var getGitRepoRootAsync = /* @__PURE__ */ __name(async (opts = {}) => {
92
- const gitRepoRoot = await runGit(["rev-parse", "--show-toplevel"], opts);
93
- if (!gitRepoRoot) {
94
- throw new Error(`Git repo returned empty value`);
90
+ __name(parseGoalStateRecordPayloadV2, "parseGoalStateRecordPayloadV2");
91
+ function parseGoalSnapshotV22(value) {
92
+ if (!isRecord(value) || !hasOnlyKeys(value, ["v", "goal", "activity"]) || value["v"] !== GOAL_STATE_VERSION || !isGoalActivity(value["activity"])) {
93
+ return void 0;
95
94
  }
96
- return gitRepoRoot;
97
- }, "getGitRepoRootAsync");
98
- var getLatestGitHubRelease = /* @__PURE__ */ __name(async (proxy) => {
99
- try {
100
- const controller = new AbortController();
101
- const endpoint = `https://api.github.com/repos/QwenLM/qwen-code-action/releases/latest`;
102
- const dispatcher = proxy ? new (await loadUndici()).ProxyAgent(proxy) : void 0;
103
- const response = await fetch(endpoint, {
104
- method: "GET",
105
- headers: {
106
- Accept: "application/vnd.github+json",
107
- "Content-Type": "application/json",
108
- "X-GitHub-Api-Version": "2022-11-28"
109
- },
110
- dispatcher,
111
- signal: AbortSignal.any([AbortSignal.timeout(3e4), controller.signal])
112
- });
113
- if (!response.ok) {
114
- throw new Error(
115
- `Invalid response code: ${response.status} - ${response.statusText}`
116
- );
117
- }
118
- const releaseTag = (await response.json()).tag_name;
119
- if (!releaseTag) {
120
- throw new Error(`Response did not include tag_name field`);
121
- }
122
- return releaseTag;
123
- } catch (_error) {
124
- debugLogger.debug(
125
- `Failed to determine latest qwen-code-action release:`,
126
- _error
127
- );
128
- throw new Error(
129
- `Unable to determine the latest qwen-code-action release on GitHub.`
130
- );
95
+ if (value["goal"] === null) {
96
+ return {
97
+ v: GOAL_STATE_VERSION,
98
+ goal: null,
99
+ activity: value["activity"]
100
+ };
131
101
  }
132
- }, "getLatestGitHubRelease");
133
- async function getGitHubRepoInfoAsync(opts = {}) {
134
- return parseGitHubRepoInfo(
135
- await runGit(["remote", "get-url", "origin"], opts)
136
- );
102
+ const goal = parseGoalRecord(value["goal"]);
103
+ return goal ? { v: GOAL_STATE_VERSION, goal, activity: value["activity"] } : void 0;
137
104
  }
138
- __name(getGitHubRepoInfoAsync, "getGitHubRepoInfoAsync");
139
- function parseGitHubRepoInfo(remoteUrl) {
140
- let urlToParse = remoteUrl;
141
- if (remoteUrl.startsWith("git@github.com:")) {
142
- urlToParse = remoteUrl.replace("git@github.com:", "");
143
- } else if (remoteUrl.startsWith("git@")) {
144
- throw new Error(
145
- `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
146
- );
105
+ __name(parseGoalSnapshotV22, "parseGoalSnapshotV2");
106
+ function parseGoalStateCause2(value) {
107
+ return isGoalStateCause(value) ? value : void 0;
108
+ }
109
+ __name(parseGoalStateCause2, "parseGoalStateCause");
110
+ function copyCursor(cursor) {
111
+ return { recordId: cursor.recordId };
112
+ }
113
+ __name(copyCursor, "copyCursor");
114
+ function parseGoalRecord(value) {
115
+ if (!isRecord(value) || !hasOnlyKeys(value, [
116
+ "goalId",
117
+ "revision",
118
+ "objective",
119
+ "status",
120
+ "evidenceCursor",
121
+ "turnCount",
122
+ "activeTimeMs",
123
+ "createdAt",
124
+ "updatedAt",
125
+ "evidenceCheckpoint",
126
+ "lastReason"
127
+ ]) || typeof value["goalId"] !== "string" || !value["goalId"] || !isNonNegativeInteger(value["revision"]) || value["revision"] === 0 || typeof value["objective"] !== "string" || !value["objective"].trim() || !isGoalStatus(value["status"]) || !isTranscriptCursor(value["evidenceCursor"]) || !isNonNegativeInteger(value["turnCount"]) || !isNonNegativeNumber(value["activeTimeMs"]) || !isFiniteNumber(value["createdAt"]) || !isFiniteNumber(value["updatedAt"]) || !isGoalEvidenceCheckpoint(value["evidenceCheckpoint"]) || value["lastReason"] !== void 0 && typeof value["lastReason"] !== "string") {
128
+ return void 0;
147
129
  }
148
- let parsedUrl;
149
- try {
150
- parsedUrl = new URL(urlToParse, "https://github.com");
151
- } catch {
152
- throw new Error(
153
- `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
154
- );
130
+ if (value["evidenceCheckpoint"] && value["evidenceCursor"].recordId !== value["evidenceCheckpoint"].checkpointId) {
131
+ return void 0;
155
132
  }
156
- if (parsedUrl.hostname !== "github.com") {
157
- throw new Error(
158
- `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
159
- );
133
+ return {
134
+ goalId: value["goalId"],
135
+ revision: value["revision"],
136
+ objective: value["objective"],
137
+ status: value["status"],
138
+ evidenceCursor: copyCursor(value["evidenceCursor"]),
139
+ turnCount: value["turnCount"],
140
+ activeTimeMs: value["activeTimeMs"],
141
+ createdAt: value["createdAt"],
142
+ updatedAt: value["updatedAt"],
143
+ ...value["evidenceCheckpoint"] === void 0 ? {} : {
144
+ evidenceCheckpoint: structuredClone(value["evidenceCheckpoint"])
145
+ },
146
+ ...value["lastReason"] === void 0 ? {} : { lastReason: value["lastReason"] }
147
+ };
148
+ }
149
+ __name(parseGoalRecord, "parseGoalRecord");
150
+ function isTranscriptCursor(value) {
151
+ return isRecord(value) && hasOnlyKeys(value, ["recordId"]) && (typeof value["recordId"] === "string" || value["recordId"] === null);
152
+ }
153
+ __name(isTranscriptCursor, "isTranscriptCursor");
154
+ function isGoalStatus(value) {
155
+ return value === "active" || value === "paused" || value === "blocked" || value === "usage_limited" || value === "complete";
156
+ }
157
+ __name(isGoalStatus, "isGoalStatus");
158
+ function isGoalActivity(value) {
159
+ return value === "idle" || value === "running" || value === "verifying";
160
+ }
161
+ __name(isGoalActivity, "isGoalActivity");
162
+ function isGoalStateCause(value) {
163
+ return value === "create" || value === "replace" || value === "edit" || value === "pause" || value === "resume" || value === "turn_finished" || value === "checkpoint" || value === "verifier_accept" || value === "verifier_reject" || value === "complete" || value === "blocked" || value === "usage_limited" || value === "clear" || value === "migrated";
164
+ }
165
+ __name(isGoalStateCause, "isGoalStateCause");
166
+ function isGoalEvidenceCheckpoint(value) {
167
+ if (value === void 0)
168
+ return true;
169
+ if (!isRecord(value) || !hasOnlyKeys(value, ["checkpointId", "createdAt", "claims"]) || typeof value["checkpointId"] !== "string" || value["checkpointId"].length === 0 || !isFiniteNumber(value["createdAt"]) || !Array.isArray(value["claims"]) || value["claims"].length === 0 || value["claims"].length > GOAL_CHECKPOINT_CLAIM_LIMIT) {
170
+ return false;
160
171
  }
161
- const parts = parsedUrl.pathname.split("/").filter((part) => part !== "");
162
- if (parts.length !== 2 || !parts[0] || !parts[1]) {
163
- throw new Error(
164
- `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
165
- );
172
+ let checkpointBytes = 0;
173
+ for (const [index, claim] of value["claims"].entries()) {
174
+ if (!isRecord(claim) || !hasOnlyKeys(claim, ["id", "proofKind", "claim", "sourceRefs"]) || claim["id"] !== `${value["checkpointId"]}:${index + 1}` || !isGoalEvidenceProofKind(claim["proofKind"]) || typeof claim["claim"] !== "string" || claim["claim"].trim().length === 0 || [...claim["claim"]].length > GOAL_CHECKPOINT_CLAIM_MAX_CHARACTERS || !Array.isArray(claim["sourceRefs"]) || claim["sourceRefs"].length === 0 || claim["sourceRefs"].length > GOAL_CHECKPOINT_SOURCE_REFERENCE_LIMIT || new Set(claim["sourceRefs"]).size !== claim["sourceRefs"].length || claim["sourceRefs"].some((reference) => typeof reference !== "string" || reference.length === 0)) {
175
+ return false;
176
+ }
177
+ checkpointBytes += new TextEncoder().encode(claim["claim"]).byteLength;
178
+ if (checkpointBytes > GOAL_CHECKPOINT_CLAIM_MAX_BYTES)
179
+ return false;
166
180
  }
167
- return { owner: parts[0], repo: parts[1].replace(/\.git$/, "") };
168
- }
169
- __name(parseGitHubRepoInfo, "parseGitHubRepoInfo");
170
-
171
- // packages/cli/src/services/setup-github.ts
172
- var debugLogger2 = createDebugLogger("SETUP_GITHUB");
173
- var GITHUB_WORKFLOW_PATHS = [
174
- "qwen-dispatch/qwen-dispatch.yml",
175
- "qwen-assistant/qwen-invoke.yml",
176
- "issue-triage/qwen-triage.yml",
177
- "issue-triage/qwen-scheduled-triage.yml",
178
- "pr-review/qwen-review.yml"
179
- ];
180
- var GITIGNORE_ENTRIES = [".qwen/", "gha-creds-*.json"];
181
- var MAX_WORKFLOW_DOWNLOAD_BYTES = 5 * 1024 * 1024;
182
- var SetupGithubError = class extends Error {
183
- static {
184
- __name(this, "SetupGithubError");
185
- }
186
- code;
187
- status;
188
- partial;
189
- partialResult;
190
- constructor(code, message, status, partialResult) {
191
- super(message);
192
- this.name = "SetupGithubError";
193
- this.code = code;
194
- this.status = status;
195
- this.partial = partialResult !== void 0;
196
- this.partialResult = partialResult;
197
- }
198
- };
199
- function isWorkspaceGenerationClosed(error) {
200
- return Boolean(
201
- error && typeof error === "object" && "code" in error && error.code === "workspace_generation_closed"
202
- );
203
- }
204
- __name(isWorkspaceGenerationClosed, "isWorkspaceGenerationClosed");
205
- var nodeFileOps = {
206
- assertCanWrite() {
207
- },
208
- async ensureWorkflowDirectory(gitRepoRoot) {
209
- await fsp.mkdir(path.join(gitRepoRoot, ".github", "workflows"), {
210
- recursive: true
211
- });
212
- },
213
- async writeTextFile(gitRepoRoot, relativePath, content) {
214
- const target = path.join(gitRepoRoot, relativePath);
215
- await fsp.writeFile(target, content, { mode: 420 });
216
- return { sizeBytes: Buffer.byteLength(content, "utf8") };
217
- },
218
- async readTextFile(gitRepoRoot, relativePath) {
219
- try {
220
- return await fsp.readFile(path.join(gitRepoRoot, relativePath), "utf8");
221
- } catch (error) {
222
- if (error.code === "ENOENT") {
223
- return void 0;
224
- }
225
- throw error;
226
- }
227
- }
228
- };
229
- async function setupGithub(options = {}) {
230
- const cwd = options.cwd ?? process.cwd();
231
- const fileOps = options.fileOps ?? nodeFileOps;
232
- if (!await isGitHubRepositoryAsync({ cwd })) {
233
- throw new SetupGithubError(
234
- "github_repository_not_found",
235
- "Unable to determine the GitHub repository. /setup-github must be run from a git repository.",
236
- 400
237
- );
238
- }
239
- let gitRepoRoot;
240
- try {
241
- gitRepoRoot = await getGitRepoRootAsync({ cwd });
242
- } catch (error) {
243
- debugLogger2.debug("Failed to get git repo root:", error);
244
- throw new SetupGithubError(
245
- "github_repository_not_found",
246
- "Unable to determine the GitHub repository. /setup-github must be run from a git repository.",
247
- 400
248
- );
249
- }
250
- if (options.workspaceRoot) {
251
- const [gitRootReal, workspaceReal] = await Promise.all([
252
- realpathOrResolve(gitRepoRoot),
253
- realpathOrResolve(options.workspaceRoot)
254
- ]);
255
- if (gitRootReal !== workspaceReal) {
256
- throw new SetupGithubError(
257
- "github_git_root_mismatch",
258
- "The Git repository root must match the daemon workspace root.",
259
- 400
260
- );
261
- }
262
- }
263
- fileOps.assertCanWrite?.();
264
- let releaseTag;
265
- try {
266
- releaseTag = await getLatestGitHubRelease(options.proxy);
267
- } catch (error) {
268
- writeStderrLine(
269
- `qwen setup-github: failed to determine latest qwen-code-action release: ${error instanceof Error ? error.message : String(error)}`
270
- );
271
- debugLogger2.debug(
272
- "Failed to determine latest qwen-code-action release:",
273
- error
274
- );
275
- throw new SetupGithubError(
276
- "github_release_lookup_failed",
277
- "Unable to determine the latest qwen-code-action release on GitHub.",
278
- 502
279
- );
280
- }
281
- const readmeUrl = `https://github.com/QwenLM/qwen-code-action/blob/${releaseTag}/README.md#quick-start`;
282
- const secretsUrl = await resolveSecretsUrl(cwd);
283
- const downloads = await downloadWorkflows({
284
- releaseTag,
285
- proxy: options.proxy,
286
- abortSignal: options.abortSignal,
287
- fetchImpl: options.fetchImpl ?? fetch
288
- });
289
- const result = {
290
- kind: "github_setup",
291
- workspaceCwd: options.workspaceRoot ?? gitRepoRoot,
292
- gitRepoRoot,
293
- releaseTag,
294
- readmeUrl,
295
- ...secretsUrl ? { secretsUrl } : {},
296
- workflows: [],
297
- gitignore: { path: ".gitignore", status: "skipped" },
298
- warnings: []
299
- };
300
- result.gitignore = await updateGitignore(gitRepoRoot, fileOps);
301
- if (result.gitignore.status === "failed") {
302
- result.warnings.push("Failed to update .gitignore.");
303
- }
304
- try {
305
- await fileOps.ensureWorkflowDirectory(gitRepoRoot);
306
- for (const workflow of downloads) {
307
- const relativePath = path.posix.join(
308
- ".github",
309
- "workflows",
310
- path.posix.basename(workflow.sourcePath)
311
- );
312
- try {
313
- const write = await fileOps.writeTextFile(
314
- gitRepoRoot,
315
- relativePath,
316
- workflow.content
317
- );
318
- result.workflows.push({
319
- sourcePath: workflow.sourcePath,
320
- path: relativePath,
321
- status: "written",
322
- sizeBytes: write.sizeBytes
323
- });
324
- } catch (error) {
325
- if (isWorkspaceGenerationClosed(error)) throw error;
326
- result.partial = true;
327
- result.workflows.push({
328
- sourcePath: workflow.sourcePath,
329
- path: relativePath,
330
- status: "failed",
331
- error: error instanceof Error ? error.message : String(error)
332
- });
333
- throw new SetupGithubError(
334
- "github_workflow_write_failed",
335
- `Unable to write ${relativePath}.`,
336
- 500,
337
- result
338
- );
339
- }
340
- }
341
- } catch (error) {
342
- if (isWorkspaceGenerationClosed(error)) throw error;
343
- if (error instanceof SetupGithubError) throw error;
344
- throw new SetupGithubError(
345
- "github_workflow_write_failed",
346
- "Unable to create .github/workflows.",
347
- 500,
348
- result
349
- );
350
- }
351
- return result;
352
- }
353
- __name(setupGithub, "setupGithub");
354
- async function updateGitignore(gitRepoRoot, fileOps = nodeFileOps) {
355
- try {
356
- const existingContent = await fileOps.readTextFile(
357
- gitRepoRoot,
358
- ".gitignore"
359
- );
360
- if (existingContent === void 0) {
361
- const content = GITIGNORE_ENTRIES.join("\n") + "\n";
362
- await fileOps.writeTextFile(gitRepoRoot, ".gitignore", content);
363
- return {
364
- path: ".gitignore",
365
- status: "created",
366
- added: [...GITIGNORE_ENTRIES]
367
- };
368
- }
369
- const missingEntries = GITIGNORE_ENTRIES.filter(
370
- (entry) => !existingContent.split(/\r?\n/).some((line) => line.split("#")[0].trim() === entry)
371
- );
372
- if (missingEntries.length === 0) {
373
- return { path: ".gitignore", status: "unchanged" };
374
- }
375
- const nextContent = existingContent + "\n" + missingEntries.join("\n") + "\n";
376
- await fileOps.writeTextFile(gitRepoRoot, ".gitignore", nextContent);
377
- return {
378
- path: ".gitignore",
379
- status: "updated",
380
- added: missingEntries
381
- };
382
- } catch (error) {
383
- if (isWorkspaceGenerationClosed(error)) throw error;
384
- debugLogger2.debug("Failed to update .gitignore:", error);
385
- return {
386
- path: ".gitignore",
387
- status: "failed",
388
- error: error instanceof Error ? error.message : String(error)
389
- };
390
- }
391
- }
392
- __name(updateGitignore, "updateGitignore");
393
- async function downloadWorkflows(options) {
394
- const internalAbort = new AbortController();
395
- try {
396
- const dispatcher = options.proxy ? new (await loadUndici()).ProxyAgent(options.proxy) : void 0;
397
- return await Promise.all(
398
- GITHUB_WORKFLOW_PATHS.map(async (workflow) => {
399
- const endpoint = `https://raw.githubusercontent.com/QwenLM/qwen-code-action/refs/tags/${options.releaseTag}/examples/workflows/${workflow}`;
400
- const response = await options.fetchImpl(endpoint, {
401
- method: "GET",
402
- dispatcher,
403
- signal: AbortSignal.any([
404
- AbortSignal.timeout(3e4),
405
- internalAbort.signal,
406
- ...options.abortSignal ? [options.abortSignal] : []
407
- ])
408
- });
409
- if (!response.ok) {
410
- throw new Error(
411
- `Invalid response code downloading ${endpoint}: ${response.status} - ${response.statusText}`
412
- );
413
- }
414
- return {
415
- sourcePath: workflow,
416
- content: await readResponseTextWithLimit(response, workflow)
417
- };
418
- })
419
- );
420
- } catch (error) {
421
- internalAbort.abort();
422
- const message = error instanceof Error ? error.message : String(error);
423
- debugLogger2.debug("Failed to download qwen-code-action workflows:", error);
424
- throw new SetupGithubError(
425
- "github_workflow_download_failed",
426
- `Unable to download qwen-code-action workflows from GitHub. ${message}`,
427
- 502
428
- );
429
- }
430
- }
431
- __name(downloadWorkflows, "downloadWorkflows");
432
- async function readResponseTextWithLimit(response, sourcePath) {
433
- const contentLength = response.headers.get("content-length");
434
- if (contentLength !== null) {
435
- const parsedLength = Number(contentLength);
436
- if (Number.isFinite(parsedLength) && parsedLength > MAX_WORKFLOW_DOWNLOAD_BYTES) {
437
- throw new Error(
438
- `${sourcePath} exceeds download limit of ${MAX_WORKFLOW_DOWNLOAD_BYTES} bytes`
439
- );
440
- }
441
- }
442
- if (!response.body) return "";
443
- const reader = response.body.getReader();
444
- const chunks = [];
445
- let totalBytes = 0;
446
- try {
447
- while (true) {
448
- const { done, value } = await reader.read();
449
- if (done) break;
450
- if (!value) continue;
451
- totalBytes += value.byteLength;
452
- if (totalBytes > MAX_WORKFLOW_DOWNLOAD_BYTES) {
453
- await reader.cancel().catch(() => {
454
- });
455
- throw new Error(
456
- `${sourcePath} exceeds download limit of ${MAX_WORKFLOW_DOWNLOAD_BYTES} bytes`
457
- );
458
- }
459
- chunks.push(value);
460
- }
461
- } finally {
462
- reader.releaseLock();
463
- }
464
- const body = new Uint8Array(totalBytes);
465
- let offset = 0;
466
- for (const chunk of chunks) {
467
- body.set(chunk, offset);
468
- offset += chunk.byteLength;
469
- }
470
- return new TextDecoder().decode(body);
471
- }
472
- __name(readResponseTextWithLimit, "readResponseTextWithLimit");
473
- async function resolveSecretsUrl(cwd) {
474
- try {
475
- const repoInfo = await getGitHubRepoInfoAsync({ cwd });
476
- return `https://github.com/${repoInfo.owner}/${repoInfo.repo}/settings/secrets/actions`;
477
- } catch {
478
- return void 0;
479
- }
480
- }
481
- __name(resolveSecretsUrl, "resolveSecretsUrl");
482
- async function realpathOrResolve(input) {
483
- try {
484
- return await fsp.realpath(input);
485
- } catch {
486
- return path.resolve(input);
487
- }
488
- }
489
- __name(realpathOrResolve, "realpathOrResolve");
490
-
491
- // packages/acp-bridge/src/transcript-replay.ts
492
- init_esbuild_shims();
493
-
494
- // packages/core/dist/src/goals/goal-wire.js
495
- init_esbuild_shims();
496
-
497
- // packages/core/dist/src/goals/goal-protocol.js
498
- init_esbuild_shims();
499
- var GOAL_STATE_VERSION = 2;
500
- var GOAL_CHECKPOINT_CLAIM_LIMIT = 32;
501
- var GOAL_CHECKPOINT_CLAIM_MAX_CHARACTERS = 2e3;
502
- var GOAL_CHECKPOINT_CLAIM_MAX_BYTES = 16e3;
503
- var GOAL_CHECKPOINT_SOURCE_REFERENCE_LIMIT = 32;
504
- function isGoalEvidenceProofKind(value) {
505
- return value === "user_input" || value === "delivered_output" || value === "external_fact";
506
- }
507
- __name(isGoalEvidenceProofKind, "isGoalEvidenceProofKind");
508
-
509
- // packages/core/dist/src/goals/goal-reducer.js
510
- init_esbuild_shims();
511
- var MAX_BLOCKED_AUDIT_COUNT = 3;
512
- function parseGoalStateRecordPayloadV2(value) {
513
- if (!isRecord(value) || !hasOnlyKeys(value, [
514
- "v",
515
- "cause",
516
- "snapshot",
517
- "checkpointPending",
518
- "blockedAudit"
519
- ]) || value["v"] !== GOAL_STATE_VERSION || !isGoalStateCause(value["cause"]) || !isCheckpointPending(value["checkpointPending"]) || !isBlockedAudit(value["blockedAudit"])) {
520
- return void 0;
521
- }
522
- const parsedSnapshot = parseGoalSnapshotV2(value["snapshot"]);
523
- if (parsedSnapshot?.activity !== "idle")
524
- return void 0;
525
- const checkpointPending = value["checkpointPending"];
526
- if (checkpointPending && (parsedSnapshot.goal?.status !== "active" || checkpointPending.permit.goalId !== parsedSnapshot.goal.goalId || checkpointPending.permit.revision !== parsedSnapshot.goal.revision || checkpointPending.recordUuid === parsedSnapshot.goal.evidenceCursor.recordId || value["cause"] !== "turn_finished" && value["cause"] !== "verifier_reject")) {
527
- return void 0;
528
- }
529
- return {
530
- v: GOAL_STATE_VERSION,
531
- cause: value["cause"],
532
- snapshot: parsedSnapshot,
533
- ...checkpointPending ? { checkpointPending: structuredClone(checkpointPending) } : {},
534
- ...value["blockedAudit"] ? { blockedAudit: structuredClone(value["blockedAudit"]) } : {}
535
- };
536
- }
537
- __name(parseGoalStateRecordPayloadV2, "parseGoalStateRecordPayloadV2");
538
- function parseGoalSnapshotV2(value) {
539
- if (!isRecord(value) || !hasOnlyKeys(value, ["v", "goal", "activity"]) || value["v"] !== GOAL_STATE_VERSION || !isGoalActivity(value["activity"])) {
540
- return void 0;
541
- }
542
- if (value["goal"] === null) {
543
- return {
544
- v: GOAL_STATE_VERSION,
545
- goal: null,
546
- activity: value["activity"]
547
- };
548
- }
549
- const goal = parseGoalRecord(value["goal"]);
550
- return goal ? { v: GOAL_STATE_VERSION, goal, activity: value["activity"] } : void 0;
551
- }
552
- __name(parseGoalSnapshotV2, "parseGoalSnapshotV2");
553
- function parseGoalStateCause(value) {
554
- return isGoalStateCause(value) ? value : void 0;
555
- }
556
- __name(parseGoalStateCause, "parseGoalStateCause");
557
- function copyCursor(cursor) {
558
- return { recordId: cursor.recordId };
559
- }
560
- __name(copyCursor, "copyCursor");
561
- function parseGoalRecord(value) {
562
- if (!isRecord(value) || !hasOnlyKeys(value, [
563
- "goalId",
564
- "revision",
565
- "objective",
566
- "status",
567
- "evidenceCursor",
568
- "turnCount",
569
- "activeTimeMs",
570
- "createdAt",
571
- "updatedAt",
572
- "evidenceCheckpoint",
573
- "lastReason"
574
- ]) || typeof value["goalId"] !== "string" || !value["goalId"] || !isNonNegativeInteger(value["revision"]) || value["revision"] === 0 || typeof value["objective"] !== "string" || !value["objective"].trim() || !isGoalStatus(value["status"]) || !isTranscriptCursor(value["evidenceCursor"]) || !isNonNegativeInteger(value["turnCount"]) || !isNonNegativeNumber(value["activeTimeMs"]) || !isFiniteNumber(value["createdAt"]) || !isFiniteNumber(value["updatedAt"]) || !isGoalEvidenceCheckpoint(value["evidenceCheckpoint"]) || value["lastReason"] !== void 0 && typeof value["lastReason"] !== "string") {
575
- return void 0;
576
- }
577
- if (value["evidenceCheckpoint"] && value["evidenceCursor"].recordId !== value["evidenceCheckpoint"].checkpointId) {
578
- return void 0;
579
- }
580
- return {
581
- goalId: value["goalId"],
582
- revision: value["revision"],
583
- objective: value["objective"],
584
- status: value["status"],
585
- evidenceCursor: copyCursor(value["evidenceCursor"]),
586
- turnCount: value["turnCount"],
587
- activeTimeMs: value["activeTimeMs"],
588
- createdAt: value["createdAt"],
589
- updatedAt: value["updatedAt"],
590
- ...value["evidenceCheckpoint"] === void 0 ? {} : {
591
- evidenceCheckpoint: structuredClone(value["evidenceCheckpoint"])
592
- },
593
- ...value["lastReason"] === void 0 ? {} : { lastReason: value["lastReason"] }
594
- };
595
- }
596
- __name(parseGoalRecord, "parseGoalRecord");
597
- function isTranscriptCursor(value) {
598
- return isRecord(value) && hasOnlyKeys(value, ["recordId"]) && (typeof value["recordId"] === "string" || value["recordId"] === null);
599
- }
600
- __name(isTranscriptCursor, "isTranscriptCursor");
601
- function isGoalStatus(value) {
602
- return value === "active" || value === "paused" || value === "blocked" || value === "usage_limited" || value === "complete";
603
- }
604
- __name(isGoalStatus, "isGoalStatus");
605
- function isGoalActivity(value) {
606
- return value === "idle" || value === "running" || value === "verifying";
607
- }
608
- __name(isGoalActivity, "isGoalActivity");
609
- function isGoalStateCause(value) {
610
- return value === "create" || value === "replace" || value === "edit" || value === "pause" || value === "resume" || value === "turn_finished" || value === "checkpoint" || value === "verifier_accept" || value === "verifier_reject" || value === "complete" || value === "blocked" || value === "usage_limited" || value === "clear" || value === "migrated";
611
- }
612
- __name(isGoalStateCause, "isGoalStateCause");
613
- function isGoalEvidenceCheckpoint(value) {
614
- if (value === void 0)
615
- return true;
616
- if (!isRecord(value) || !hasOnlyKeys(value, ["checkpointId", "createdAt", "claims"]) || typeof value["checkpointId"] !== "string" || value["checkpointId"].length === 0 || !isFiniteNumber(value["createdAt"]) || !Array.isArray(value["claims"]) || value["claims"].length === 0 || value["claims"].length > GOAL_CHECKPOINT_CLAIM_LIMIT) {
617
- return false;
618
- }
619
- let checkpointBytes = 0;
620
- for (const [index, claim] of value["claims"].entries()) {
621
- if (!isRecord(claim) || !hasOnlyKeys(claim, ["id", "proofKind", "claim", "sourceRefs"]) || claim["id"] !== `${value["checkpointId"]}:${index + 1}` || !isGoalEvidenceProofKind(claim["proofKind"]) || typeof claim["claim"] !== "string" || claim["claim"].trim().length === 0 || [...claim["claim"]].length > GOAL_CHECKPOINT_CLAIM_MAX_CHARACTERS || !Array.isArray(claim["sourceRefs"]) || claim["sourceRefs"].length === 0 || claim["sourceRefs"].length > GOAL_CHECKPOINT_SOURCE_REFERENCE_LIMIT || new Set(claim["sourceRefs"]).size !== claim["sourceRefs"].length || claim["sourceRefs"].some((reference) => typeof reference !== "string" || reference.length === 0)) {
622
- return false;
623
- }
624
- checkpointBytes += new TextEncoder().encode(claim["claim"]).byteLength;
625
- if (checkpointBytes > GOAL_CHECKPOINT_CLAIM_MAX_BYTES)
626
- return false;
627
- }
628
- return true;
181
+ return true;
629
182
  }
630
183
  __name(isGoalEvidenceCheckpoint, "isGoalEvidenceCheckpoint");
631
184
  function isCheckpointPending(value) {
@@ -663,7 +216,7 @@ __name(isFiniteNumber, "isFiniteNumber");
663
216
 
664
217
  // packages/core/dist/src/goals/goal-legacy-projection.js
665
218
  init_esbuild_shims();
666
- function projectGoalStateToLegacy(payload, previousGoal = null) {
219
+ function projectGoalStateToLegacy2(payload, previousGoal = null) {
667
220
  const snapshotGoal = payload.snapshot.goal;
668
221
  const displayGoal = snapshotGoal ?? previousGoal;
669
222
  const kind = legacyStatusKind(payload);
@@ -694,7 +247,7 @@ function projectGoalStateToLegacy(payload, previousGoal = null) {
694
247
  } : null
695
248
  };
696
249
  }
697
- __name(projectGoalStateToLegacy, "projectGoalStateToLegacy");
250
+ __name(projectGoalStateToLegacy2, "projectGoalStateToLegacy");
698
251
  function isGoalCheckpointBookkeepingTransition(previous, next) {
699
252
  const previousGoal = previous?.goal;
700
253
  const nextGoal = next.goal;
@@ -1289,7 +842,7 @@ var DefaultTranscriptReplayMachine = class {
1289
842
  previous: this.goalState,
1290
843
  next: payload2.snapshot
1291
844
  });
1292
- const projection = projectGoalStateToLegacy(
845
+ const projection = projectGoalStateToLegacy2(
1293
846
  payload2,
1294
847
  this.goalState?.goal ?? null
1295
848
  );
@@ -1524,7 +1077,7 @@ function parseInitialState(value, onDiagnostic) {
1524
1077
  });
1525
1078
  }
1526
1079
  const rawGoalState = value["goalState"];
1527
- const goalState = rawGoalState === void 0 ? void 0 : parseGoalSnapshotV2(rawGoalState);
1080
+ const goalState = rawGoalState === void 0 ? void 0 : parseGoalSnapshotV22(rawGoalState);
1528
1081
  if (rawGoalState !== void 0 && !goalState) {
1529
1082
  onDiagnostic?.({
1530
1083
  code: "invalid_replay_state",
@@ -1534,7 +1087,7 @@ function parseInitialState(value, onDiagnostic) {
1534
1087
  });
1535
1088
  }
1536
1089
  const rawGoalCause = value["goalCause"];
1537
- const goalCause = rawGoalCause === void 0 ? void 0 : parseGoalStateCause(rawGoalCause);
1090
+ const goalCause = rawGoalCause === void 0 ? void 0 : parseGoalStateCause2(rawGoalCause);
1538
1091
  if (rawGoalCause !== void 0 && !goalCause) {
1539
1092
  onDiagnostic?.({
1540
1093
  code: "invalid_replay_state",
@@ -1750,7 +1303,7 @@ function dedupeStrings(values) {
1750
1303
  }
1751
1304
  __name(dedupeStrings, "dedupeStrings");
1752
1305
 
1753
- // packages/cli/src/acp-integration/session/emitters/PlanEmitter.ts
1306
+ // packages/cli/src/acp-integration/session/emitters/tool-call-emitter.ts
1754
1307
  init_esbuild_shims();
1755
1308
 
1756
1309
  // packages/cli/src/acp-integration/session/emitters/base-emitter.ts
@@ -1796,6 +1349,7 @@ var BaseEmitter = class {
1796
1349
  };
1797
1350
 
1798
1351
  // packages/cli/src/acp-integration/session/emitters/PlanEmitter.ts
1352
+ init_esbuild_shims();
1799
1353
  var PlanEmitter = class extends BaseEmitter {
1800
1354
  static {
1801
1355
  __name(this, "PlanEmitter");
@@ -1840,9 +1394,6 @@ var PlanEmitter = class extends BaseEmitter {
1840
1394
  }
1841
1395
  };
1842
1396
 
1843
- // packages/cli/src/acp-integration/session/emitters/tool-call-emitter.ts
1844
- init_esbuild_shims();
1845
-
1846
1397
  // packages/cli/src/acp-integration/session/types.ts
1847
1398
  init_esbuild_shims();
1848
1399
  function hasFullSessionContext(context) {
@@ -1912,386 +1463,870 @@ var ToolCallEmitter = class _ToolCallEmitter extends BaseEmitter {
1912
1463
  timestamp: params.timestamp,
1913
1464
  asUpdate: updatesPreparedCall,
1914
1465
  extra: {
1915
- ...params.phase ? { phase: params.phase } : {},
1916
- ...params.subagentMeta,
1466
+ ...params.phase ? { phase: params.phase } : {},
1467
+ ...params.subagentMeta,
1468
+ provenance: provenance.provenance,
1469
+ ...provenance.serverId ? { serverId: provenance.serverId } : {}
1470
+ }
1471
+ })
1472
+ );
1473
+ if (params.phase === "preparing") {
1474
+ this.preparedCallIds.add(params.callId);
1475
+ }
1476
+ return true;
1477
+ }
1478
+ /**
1479
+ * Emits a terminal frame when a prepared tool call is discarded before
1480
+ * execution. TodoWrite remains represented exclusively by plan updates.
1481
+ *
1482
+ * @param callId - ID of the prepared tool call
1483
+ * @param toolName - Name of the prepared tool
1484
+ */
1485
+ async emitPreparationDiscarded(callId, toolName) {
1486
+ if (this.isTodoWriteTool(toolName)) return;
1487
+ this.preparedCallIds.delete(callId);
1488
+ const provenance = _ToolCallEmitter.resolveToolProvenance(toolName);
1489
+ await this.sendUpdate({
1490
+ sessionUpdate: "tool_call_update",
1491
+ toolCallId: callId,
1492
+ status: "failed",
1493
+ content: [],
1494
+ _meta: {
1495
+ toolName,
1496
+ phase: "preparing",
1497
+ preparationDiscarded: true,
1498
+ provenance: provenance.provenance,
1499
+ ...provenance.serverId ? { serverId: provenance.serverId } : {}
1500
+ }
1501
+ });
1502
+ }
1503
+ /**
1504
+ * Emits a tool call result event.
1505
+ * Handles TodoWriteTool specially by routing to plan updates.
1506
+ *
1507
+ * @param params - Tool call result parameters
1508
+ */
1509
+ async emitResult(params) {
1510
+ if (this.isTodoWriteTool(params.toolName)) {
1511
+ if (params.subagentMeta) return;
1512
+ if (!params.success) return;
1513
+ const plan = this.planEmitter.extractPlan(
1514
+ params.resultDisplay,
1515
+ params.args
1516
+ );
1517
+ if (plan && (plan.todos.length > 0 || params.args && Array.isArray(params.args["todos"]))) {
1518
+ await this.planEmitter.emitPlan(plan, params.callId);
1519
+ }
1520
+ return;
1521
+ }
1522
+ this.preparedCallIds.delete(params.callId);
1523
+ const provenance = _ToolCallEmitter.resolveToolProvenance(
1524
+ params.toolName,
1525
+ params.subagentMeta
1526
+ );
1527
+ await this.sendUpdate(
1528
+ createTranscriptToolCallResultUpdate({
1529
+ toolName: params.toolName,
1530
+ callId: params.callId,
1531
+ success: params.success,
1532
+ message: params.message,
1533
+ resultDisplay: params.resultDisplay,
1534
+ errorMessage: params.error?.message,
1535
+ artifacts: params.artifacts,
1536
+ contentPrefix: buildToolResultContentPrefix(params.resultDisplay),
1537
+ timestamp: params.timestamp,
1538
+ extra: {
1539
+ ...params.subagentMeta,
1540
+ provenance: provenance.provenance,
1541
+ ...provenance.serverId ? { serverId: provenance.serverId } : {}
1542
+ }
1543
+ })
1544
+ );
1545
+ }
1546
+ /**
1547
+ * Emits a tool call error event.
1548
+ * Use this for explicit error handling when not using emitResult.
1549
+ *
1550
+ * @param callId - The tool call ID
1551
+ * @param toolName - The tool name
1552
+ * @param error - The error that occurred
1553
+ * @param subagentMeta - Optional subagent metadata
1554
+ */
1555
+ async emitError(callId, toolName, error, subagentMeta) {
1556
+ this.preparedCallIds.delete(callId);
1557
+ const provenance = _ToolCallEmitter.resolveToolProvenance(
1558
+ toolName,
1559
+ subagentMeta
1560
+ );
1561
+ await this.sendUpdate(
1562
+ createTranscriptToolCallResultUpdate({
1563
+ toolName,
1564
+ callId,
1565
+ success: false,
1566
+ errorMessage: error.message,
1567
+ extra: {
1568
+ ...subagentMeta,
1917
1569
  provenance: provenance.provenance,
1918
1570
  ...provenance.serverId ? { serverId: provenance.serverId } : {}
1919
1571
  }
1920
1572
  })
1921
1573
  );
1922
- if (params.phase === "preparing") {
1923
- this.preparedCallIds.add(params.callId);
1574
+ }
1575
+ /**
1576
+ * Resolve a tool's provenance for UI dispatch on tool_call events.
1577
+ * The SDK reads `_meta.
1578
+ * provenance` + `_meta.serverId` to render builtin / MCP-server-badge /
1579
+ * subagent-block differently. Without this stamping, the SDK falls
1580
+ * back to string-matching the toolName which can't reliably
1581
+ * distinguish builtin from subagent.
1582
+ *
1583
+ * Resolution rules:
1584
+ * - `subagentMeta` present → `'subagent'` (a Task tool / Codex
1585
+ * subagent / etc. wrapping its own tool calls)
1586
+ * - toolName matches `mcp__<server>__<tool>` → `'mcp'` with
1587
+ * `serverId: <server>`. Naming convention from
1588
+ * `packages/core/src/tools/mcp-tool.ts` in the
1589
+ * `@qwen-code/qwen-code-core` package — mirrors the SDK's same
1590
+ * heuristic fallback so SDK consumers stay consistent with
1591
+ * daemon classification.
1592
+ * - everything else → `'builtin'`
1593
+ *
1594
+ * Static + pure so it can be unit-tested without an emitter
1595
+ * instance. Exported via `ToolCallEmitter.resolveToolProvenance`.
1596
+ */
1597
+ static resolveToolProvenance(toolName, subagentMeta) {
1598
+ if (subagentMeta !== void 0) {
1599
+ return { provenance: "subagent" };
1924
1600
  }
1925
- return true;
1601
+ if (toolName.startsWith("mcp__")) {
1602
+ const parts = toolName.split("__");
1603
+ if (parts.length >= 3 && parts[1] && parts[1].length > 0) {
1604
+ return { provenance: "mcp", serverId: parts[1] };
1605
+ }
1606
+ }
1607
+ return { provenance: "builtin" };
1926
1608
  }
1609
+ // ==================== Public Utilities ====================
1927
1610
  /**
1928
- * Emits a terminal frame when a prepared tool call is discarded before
1929
- * execution. TodoWrite remains represented exclusively by plan updates.
1611
+ * Checks if a tool name is the TodoWriteTool.
1612
+ * Exposed for external use in components that need to check this.
1613
+ */
1614
+ isTodoWriteTool(toolName) {
1615
+ return toolName === ToolNames.TODO_WRITE;
1616
+ }
1617
+ /**
1618
+ * Checks if a tool name is the ExitPlanModeTool.
1619
+ */
1620
+ isExitPlanModeTool(toolName) {
1621
+ return toolName === ToolNames.EXIT_PLAN_MODE;
1622
+ }
1623
+ /**
1624
+ * Checks if a tool name is the EnterPlanModeTool.
1625
+ */
1626
+ isEnterPlanModeTool(toolName) {
1627
+ return toolName === ToolNames.ENTER_PLAN_MODE;
1628
+ }
1629
+ /**
1630
+ * Resolves tool metadata from the registry.
1631
+ * Falls back to defaults if tool not found or build fails.
1930
1632
  *
1931
- * @param callId - ID of the prepared tool call
1932
- * @param toolName - Name of the prepared tool
1633
+ * @param toolName - Name of the tool
1634
+ * @param args - Tool call arguments (used to build invocation)
1933
1635
  */
1934
- async emitPreparationDiscarded(callId, toolName) {
1935
- if (this.isTodoWriteTool(toolName)) return;
1936
- this.preparedCallIds.delete(callId);
1937
- const provenance = _ToolCallEmitter.resolveToolProvenance(toolName);
1938
- await this.sendUpdate({
1939
- sessionUpdate: "tool_call_update",
1940
- toolCallId: callId,
1941
- status: "failed",
1942
- content: [],
1943
- _meta: {
1944
- toolName,
1945
- phase: "preparing",
1946
- preparationDiscarded: true,
1947
- provenance: provenance.provenance,
1948
- ...provenance.serverId ? { serverId: provenance.serverId } : {}
1636
+ resolveToolMetadata(toolName, args) {
1637
+ if (!hasFullSessionContext(this.ctx)) {
1638
+ const description = typeof args?.["description"] === "string" ? args["description"].trim() : "";
1639
+ return {
1640
+ title: description ? `${toolName}: ${description}` : toolName,
1641
+ locations: [],
1642
+ kind: "other"
1643
+ };
1644
+ }
1645
+ const toolRegistry = this.ctx.config.getToolRegistry();
1646
+ const tool = toolRegistry.getTool(toolName);
1647
+ let title = tool?.displayName ?? toolName;
1648
+ let locations = [];
1649
+ let kind = "other";
1650
+ if (tool && args) {
1651
+ try {
1652
+ const invocation = tool.build(args);
1653
+ title = `${title}: ${invocation.getDescription()}`;
1654
+ locations = invocation.toolLocations().map((loc) => ({
1655
+ path: loc.path,
1656
+ line: loc.line ?? null
1657
+ }));
1658
+ kind = this.mapToolKind(tool.kind, toolName);
1659
+ } catch {
1660
+ if (typeof args["description"] === "string") {
1661
+ title = `${title}: ${args["description"]}`;
1662
+ }
1663
+ if (tool.kind) {
1664
+ kind = this.mapToolKind(tool.kind, toolName);
1665
+ }
1949
1666
  }
1950
- });
1667
+ }
1668
+ return { title, locations, kind };
1951
1669
  }
1952
1670
  /**
1953
- * Emits a tool call result event.
1954
- * Handles TodoWriteTool specially by routing to plan updates.
1671
+ * Maps core Tool Kind enum to ACP ToolKind string literals.
1955
1672
  *
1956
- * @param params - Tool call result parameters
1673
+ * @param kind - The core Kind enum value
1674
+ * @param toolName - Optional tool name to handle special cases like exit_plan_mode
1957
1675
  */
1958
- async emitResult(params) {
1959
- if (this.isTodoWriteTool(params.toolName)) {
1960
- if (params.subagentMeta) return;
1961
- if (!params.success) return;
1962
- const plan = this.planEmitter.extractPlan(
1963
- params.resultDisplay,
1964
- params.args
1965
- );
1966
- if (plan && (plan.todos.length > 0 || params.args && Array.isArray(params.args["todos"]))) {
1967
- await this.planEmitter.emitPlan(plan, params.callId);
1676
+ mapToolKind(kind, toolName) {
1677
+ if (toolName && (this.isExitPlanModeTool(toolName) || this.isEnterPlanModeTool(toolName))) {
1678
+ return "switch_mode";
1679
+ }
1680
+ return KIND_MAP[kind] ?? "other";
1681
+ }
1682
+ };
1683
+ function buildToolResultContentPrefix(resultDisplay) {
1684
+ if (!isVisionBridgeNoticeDisplay(resultDisplay)) return [];
1685
+ return [
1686
+ {
1687
+ type: "content",
1688
+ content: {
1689
+ type: "text",
1690
+ text: sanitizeTerminalText(
1691
+ formatVisionBridgeNoticeDisplay(resultDisplay)
1692
+ )
1693
+ }
1694
+ }
1695
+ ];
1696
+ }
1697
+ __name(buildToolResultContentPrefix, "buildToolResultContentPrefix");
1698
+
1699
+ // packages/cli/src/acp-integration/session/history-replayer.ts
1700
+ var HistoryReplayer = class {
1701
+ constructor(ctx) {
1702
+ this.ctx = ctx;
1703
+ this.toolCallEmitter = new ToolCallEmitter(ctx);
1704
+ this.machine = this.createMachine();
1705
+ }
1706
+ static {
1707
+ __name(this, "HistoryReplayer");
1708
+ }
1709
+ toolCallEmitter;
1710
+ machine;
1711
+ async replay(records, gaps, options = {}) {
1712
+ try {
1713
+ if (options.goalBootstrap) {
1714
+ const update = {
1715
+ sessionUpdate: "agent_message_chunk",
1716
+ content: { type: "text", text: "" },
1717
+ _meta: {
1718
+ ...options.goalBootstrap.goalState ? { goalState: options.goalBootstrap.goalState } : {},
1719
+ goalStatus: options.goalBootstrap.goalStatus
1720
+ }
1721
+ };
1722
+ await this.sendUpdate(update);
1723
+ }
1724
+ await this.replayPage(records, {
1725
+ finalizeDangling: true,
1726
+ gaps,
1727
+ ...options.initialGoalState ? { goalState: options.initialGoalState } : {},
1728
+ ...options.initialGoalCause ? { goalCause: options.initialGoalCause } : {}
1729
+ });
1730
+ } finally {
1731
+ this.setActiveRecordId(null);
1732
+ }
1733
+ }
1734
+ static v2GoalBootstrap(rawGoalState, rawGoalCause) {
1735
+ const goalState = parseGoalSnapshotV2(rawGoalState);
1736
+ const goalCause = parseGoalStateCause(rawGoalCause);
1737
+ if (!goalState?.goal || goalState.goal.status !== "active" || !goalCause) {
1738
+ return void 0;
1739
+ }
1740
+ const projection = projectGoalStateToLegacy({
1741
+ v: 2,
1742
+ cause: goalCause,
1743
+ snapshot: goalState
1744
+ });
1745
+ const { type: _type, kind, ...goalStatus } = projection.goalStatus;
1746
+ if (kind !== "set" && kind !== "checking") {
1747
+ return void 0;
1748
+ }
1749
+ return { goalStatus: { ...goalStatus, kind }, goalState };
1750
+ }
1751
+ async replayPage(records, options = {}) {
1752
+ this.machine = this.createMachine(options);
1753
+ let replayError;
1754
+ try {
1755
+ for (const record of records) {
1756
+ for (const emission of this.machine.project(record)) {
1757
+ this.setActiveRecordId(
1758
+ emission.sourceRecordId,
1759
+ emission.sourceTimestamp
1760
+ );
1761
+ await this.sendUpdate(emission.update);
1762
+ }
1763
+ }
1764
+ } catch (error) {
1765
+ replayError = error;
1766
+ }
1767
+ let danglingError;
1768
+ if (options.finalizeDangling === true) {
1769
+ for (const emission of this.machine.finalize()) {
1770
+ this.setActiveRecordId(
1771
+ emission.sourceRecordId,
1772
+ emission.sourceTimestamp
1773
+ );
1774
+ try {
1775
+ await this.sendUpdate(emission.update);
1776
+ } catch (error) {
1777
+ danglingError ??= error;
1778
+ }
1968
1779
  }
1780
+ }
1781
+ const replay = this.machine.snapshot();
1782
+ this.copyCumulativeUsage(replay);
1783
+ const state = {
1784
+ pendingToolCalls: options.finalizeDangling === true ? [] : replay.pendingToolCalls.map(toLegacyPendingToolCall),
1785
+ replay
1786
+ };
1787
+ this.setActiveRecordId(null);
1788
+ if (replayError && danglingError) {
1789
+ throw new AggregateError(
1790
+ [replayError, danglingError],
1791
+ "Replay and dangling-cleanup both failed"
1792
+ );
1793
+ }
1794
+ if (replayError) throw replayError;
1795
+ if (danglingError) throw danglingError;
1796
+ return state;
1797
+ }
1798
+ getPendingToolCalls() {
1799
+ return this.machine.snapshot().pendingToolCalls.map(toLegacyPendingToolCall);
1800
+ }
1801
+ getReplayState() {
1802
+ return this.machine.snapshot();
1803
+ }
1804
+ createMachine(options = {}) {
1805
+ const cumulative = this.ctx.cumulativeUsage;
1806
+ const initialState = {
1807
+ v: 1,
1808
+ pendingToolCalls: (options.pendingToolCalls ?? []).map(
1809
+ toPendingTranscriptToolCall
1810
+ ),
1811
+ cumulativeUsage: cumulative ? { ...cumulative } : {
1812
+ promptTokens: 0,
1813
+ cachedTokens: 0,
1814
+ candidateTokens: 0,
1815
+ apiTimeMs: 0
1816
+ },
1817
+ ...options.goalState ? { goalState: options.goalState } : {},
1818
+ ...options.goalCause ? { goalCause: options.goalCause } : {}
1819
+ };
1820
+ return createTranscriptReplayMachine({
1821
+ initialState,
1822
+ gaps: options.gaps,
1823
+ presentation: this.presentationAdapter(),
1824
+ onDiagnostic: /* @__PURE__ */ __name((diagnostic) => {
1825
+ if (diagnostic.code === "malformed_part" && diagnostic.path === "systemPayload.outputHistoryItems.goalStatus.condition") {
1826
+ writeStderrLineSafe(`qwen: ${diagnostic.message}`);
1827
+ }
1828
+ }, "onDiagnostic")
1829
+ });
1830
+ }
1831
+ presentationAdapter() {
1832
+ return {
1833
+ resolveToolMetadata: /* @__PURE__ */ __name((toolName, args) => this.toolCallEmitter.resolveToolMetadata(toolName, { ...args }), "resolveToolMetadata"),
1834
+ formatHistoryGap: /* @__PURE__ */ __name((gap) => formatHistoryGapNotice(gap), "formatHistoryGap"),
1835
+ buildToolResultContentPrefix
1836
+ };
1837
+ }
1838
+ async sendUpdate(update) {
1839
+ if (this.ctx.messageRewriter) {
1840
+ await this.ctx.messageRewriter.interceptUpdate(update);
1969
1841
  return;
1970
1842
  }
1971
- this.preparedCallIds.delete(params.callId);
1972
- const provenance = _ToolCallEmitter.resolveToolProvenance(
1973
- params.toolName,
1974
- params.subagentMeta
1975
- );
1976
- await this.sendUpdate(
1977
- createTranscriptToolCallResultUpdate({
1978
- toolName: params.toolName,
1979
- callId: params.callId,
1980
- success: params.success,
1981
- message: params.message,
1982
- resultDisplay: params.resultDisplay,
1983
- errorMessage: params.error?.message,
1984
- artifacts: params.artifacts,
1985
- contentPrefix: buildToolResultContentPrefix(params.resultDisplay),
1986
- timestamp: params.timestamp,
1987
- extra: {
1988
- ...params.subagentMeta,
1989
- provenance: provenance.provenance,
1990
- ...provenance.serverId ? { serverId: provenance.serverId } : {}
1991
- }
1992
- })
1993
- );
1843
+ await this.ctx.sendUpdate(update);
1994
1844
  }
1995
- /**
1996
- * Emits a tool call error event.
1997
- * Use this for explicit error handling when not using emitResult.
1998
- *
1999
- * @param callId - The tool call ID
2000
- * @param toolName - The tool name
2001
- * @param error - The error that occurred
2002
- * @param subagentMeta - Optional subagent metadata
2003
- */
2004
- async emitError(callId, toolName, error, subagentMeta) {
2005
- this.preparedCallIds.delete(callId);
2006
- const provenance = _ToolCallEmitter.resolveToolProvenance(
2007
- toolName,
2008
- subagentMeta
2009
- );
2010
- await this.sendUpdate(
2011
- createTranscriptToolCallResultUpdate({
2012
- toolName,
2013
- callId,
2014
- success: false,
2015
- errorMessage: error.message,
2016
- extra: {
2017
- ...subagentMeta,
2018
- provenance: provenance.provenance,
2019
- ...provenance.serverId ? { serverId: provenance.serverId } : {}
1845
+ copyCumulativeUsage(state) {
1846
+ const cumulative = this.ctx.cumulativeUsage;
1847
+ if (!cumulative) return;
1848
+ cumulative.promptTokens = state.cumulativeUsage.promptTokens;
1849
+ cumulative.cachedTokens = state.cumulativeUsage.cachedTokens;
1850
+ cumulative.candidateTokens = state.cumulativeUsage.candidateTokens;
1851
+ cumulative.apiTimeMs = state.cumulativeUsage.apiTimeMs;
1852
+ }
1853
+ setActiveRecordId(recordId, timestamp) {
1854
+ this.ctx.setActiveRecordId?.(recordId, timestamp);
1855
+ }
1856
+ };
1857
+ function toPendingTranscriptToolCall(pending) {
1858
+ return {
1859
+ callId: pending.callId,
1860
+ toolName: pending.toolName,
1861
+ sourceRecordId: pending.recordId,
1862
+ ...pending.timestamp ? { sourceTimestamp: pending.timestamp } : {}
1863
+ };
1864
+ }
1865
+ __name(toPendingTranscriptToolCall, "toPendingTranscriptToolCall");
1866
+ function toLegacyPendingToolCall(pending) {
1867
+ return {
1868
+ callId: pending.callId,
1869
+ toolName: pending.toolName,
1870
+ recordId: pending.sourceRecordId,
1871
+ ...pending.sourceTimestamp ? { timestamp: pending.sourceTimestamp } : {}
1872
+ };
1873
+ }
1874
+ __name(toLegacyPendingToolCall, "toLegacyPendingToolCall");
1875
+
1876
+ // packages/cli/src/services/setup-github.ts
1877
+ init_esbuild_shims();
1878
+ import { promises as fsp } from "node:fs";
1879
+ import * as path from "node:path";
1880
+
1881
+ // packages/cli/src/utils/gitUtils.ts
1882
+ init_esbuild_shims();
1883
+ import * as childProcess from "node:child_process";
1884
+ var debugLogger = createDebugLogger("GIT");
1885
+ async function runGit(args, opts = {}) {
1886
+ return await new Promise((resolve2, reject) => {
1887
+ childProcess.execFile(
1888
+ "git",
1889
+ args,
1890
+ {
1891
+ encoding: "utf-8",
1892
+ ...opts.cwd ? { cwd: opts.cwd } : {}
1893
+ },
1894
+ (err, stdout) => {
1895
+ if (err) {
1896
+ reject(err);
1897
+ return;
2020
1898
  }
2021
- })
1899
+ resolve2(String(stdout ?? "").trim());
1900
+ }
2022
1901
  );
1902
+ });
1903
+ }
1904
+ __name(runGit, "runGit");
1905
+ var isGitHubRepositoryAsync = /* @__PURE__ */ __name(async (opts = {}) => {
1906
+ try {
1907
+ const remotes = await runGit(["remote", "-v"], opts);
1908
+ return remotes.split("\n").some((line) => {
1909
+ const remoteUrl = line.trim().split(/\s+/)[1];
1910
+ return remoteUrl ? isGitHubRemoteUrl(remoteUrl) : false;
1911
+ });
1912
+ } catch (_error) {
1913
+ debugLogger.debug(`Failed to get git remote:`, _error);
1914
+ return false;
2023
1915
  }
2024
- /**
2025
- * Resolve a tool's provenance for UI dispatch on tool_call events.
2026
- * The SDK reads `_meta.
2027
- * provenance` + `_meta.serverId` to render builtin / MCP-server-badge /
2028
- * subagent-block differently. Without this stamping, the SDK falls
2029
- * back to string-matching the toolName which can't reliably
2030
- * distinguish builtin from subagent.
2031
- *
2032
- * Resolution rules:
2033
- * - `subagentMeta` present → `'subagent'` (a Task tool / Codex
2034
- * subagent / etc. wrapping its own tool calls)
2035
- * - toolName matches `mcp__<server>__<tool>` → `'mcp'` with
2036
- * `serverId: <server>`. Naming convention from
2037
- * `packages/core/src/tools/mcp-tool.ts` in the
2038
- * `@qwen-code/qwen-code-core` package — mirrors the SDK's same
2039
- * heuristic fallback so SDK consumers stay consistent with
2040
- * daemon classification.
2041
- * - everything else → `'builtin'`
2042
- *
2043
- * Static + pure so it can be unit-tested without an emitter
2044
- * instance. Exported via `ToolCallEmitter.resolveToolProvenance`.
2045
- */
2046
- static resolveToolProvenance(toolName, subagentMeta) {
2047
- if (subagentMeta !== void 0) {
2048
- return { provenance: "subagent" };
2049
- }
2050
- if (toolName.startsWith("mcp__")) {
2051
- const parts = toolName.split("__");
2052
- if (parts.length >= 3 && parts[1] && parts[1].length > 0) {
2053
- return { provenance: "mcp", serverId: parts[1] };
2054
- }
2055
- }
2056
- return { provenance: "builtin" };
1916
+ }, "isGitHubRepositoryAsync");
1917
+ function isGitHubRemoteUrl(remoteUrl) {
1918
+ if (remoteUrl.startsWith("git@github.com:")) {
1919
+ return true;
2057
1920
  }
2058
- // ==================== Public Utilities ====================
2059
- /**
2060
- * Checks if a tool name is the TodoWriteTool.
2061
- * Exposed for external use in components that need to check this.
2062
- */
2063
- isTodoWriteTool(toolName) {
2064
- return toolName === ToolNames.TODO_WRITE;
1921
+ if (remoteUrl.startsWith("git@")) {
1922
+ return false;
2065
1923
  }
2066
- /**
2067
- * Checks if a tool name is the ExitPlanModeTool.
2068
- */
2069
- isExitPlanModeTool(toolName) {
2070
- return toolName === ToolNames.EXIT_PLAN_MODE;
1924
+ try {
1925
+ return new URL(remoteUrl).hostname === "github.com";
1926
+ } catch {
1927
+ return false;
2071
1928
  }
2072
- /**
2073
- * Checks if a tool name is the EnterPlanModeTool.
2074
- */
2075
- isEnterPlanModeTool(toolName) {
2076
- return toolName === ToolNames.ENTER_PLAN_MODE;
1929
+ }
1930
+ __name(isGitHubRemoteUrl, "isGitHubRemoteUrl");
1931
+ var getGitRepoRootAsync = /* @__PURE__ */ __name(async (opts = {}) => {
1932
+ const gitRepoRoot = await runGit(["rev-parse", "--show-toplevel"], opts);
1933
+ if (!gitRepoRoot) {
1934
+ throw new Error(`Git repo returned empty value`);
2077
1935
  }
2078
- /**
2079
- * Resolves tool metadata from the registry.
2080
- * Falls back to defaults if tool not found or build fails.
2081
- *
2082
- * @param toolName - Name of the tool
2083
- * @param args - Tool call arguments (used to build invocation)
2084
- */
2085
- resolveToolMetadata(toolName, args) {
2086
- if (!hasFullSessionContext(this.ctx)) {
2087
- const description = typeof args?.["description"] === "string" ? args["description"].trim() : "";
2088
- return {
2089
- title: description ? `${toolName}: ${description}` : toolName,
2090
- locations: [],
2091
- kind: "other"
2092
- };
1936
+ return gitRepoRoot;
1937
+ }, "getGitRepoRootAsync");
1938
+ var getLatestGitHubRelease = /* @__PURE__ */ __name(async (proxy) => {
1939
+ try {
1940
+ const controller = new AbortController();
1941
+ const endpoint = `https://api.github.com/repos/QwenLM/qwen-code-action/releases/latest`;
1942
+ const dispatcher = proxy ? new (await loadUndici()).ProxyAgent(proxy) : void 0;
1943
+ const response = await fetch(endpoint, {
1944
+ method: "GET",
1945
+ headers: {
1946
+ Accept: "application/vnd.github+json",
1947
+ "Content-Type": "application/json",
1948
+ "X-GitHub-Api-Version": "2022-11-28"
1949
+ },
1950
+ dispatcher,
1951
+ signal: AbortSignal.any([AbortSignal.timeout(3e4), controller.signal])
1952
+ });
1953
+ if (!response.ok) {
1954
+ throw new Error(
1955
+ `Invalid response code: ${response.status} - ${response.statusText}`
1956
+ );
2093
1957
  }
2094
- const toolRegistry = this.ctx.config.getToolRegistry();
2095
- const tool = toolRegistry.getTool(toolName);
2096
- let title = tool?.displayName ?? toolName;
2097
- let locations = [];
2098
- let kind = "other";
2099
- if (tool && args) {
2100
- try {
2101
- const invocation = tool.build(args);
2102
- title = `${title}: ${invocation.getDescription()}`;
2103
- locations = invocation.toolLocations().map((loc) => ({
2104
- path: loc.path,
2105
- line: loc.line ?? null
2106
- }));
2107
- kind = this.mapToolKind(tool.kind, toolName);
2108
- } catch {
2109
- if (typeof args["description"] === "string") {
2110
- title = `${title}: ${args["description"]}`;
2111
- }
2112
- if (tool.kind) {
2113
- kind = this.mapToolKind(tool.kind, toolName);
2114
- }
2115
- }
1958
+ const releaseTag = (await response.json()).tag_name;
1959
+ if (!releaseTag) {
1960
+ throw new Error(`Response did not include tag_name field`);
2116
1961
  }
2117
- return { title, locations, kind };
1962
+ return releaseTag;
1963
+ } catch (_error) {
1964
+ debugLogger.debug(
1965
+ `Failed to determine latest qwen-code-action release:`,
1966
+ _error
1967
+ );
1968
+ throw new Error(
1969
+ `Unable to determine the latest qwen-code-action release on GitHub.`
1970
+ );
2118
1971
  }
2119
- /**
2120
- * Maps core Tool Kind enum to ACP ToolKind string literals.
2121
- *
2122
- * @param kind - The core Kind enum value
2123
- * @param toolName - Optional tool name to handle special cases like exit_plan_mode
2124
- */
2125
- mapToolKind(kind, toolName) {
2126
- if (toolName && (this.isExitPlanModeTool(toolName) || this.isEnterPlanModeTool(toolName))) {
2127
- return "switch_mode";
2128
- }
2129
- return KIND_MAP[kind] ?? "other";
1972
+ }, "getLatestGitHubRelease");
1973
+ async function getGitHubRepoInfoAsync(opts = {}) {
1974
+ return parseGitHubRepoInfo(
1975
+ await runGit(["remote", "get-url", "origin"], opts)
1976
+ );
1977
+ }
1978
+ __name(getGitHubRepoInfoAsync, "getGitHubRepoInfoAsync");
1979
+ function parseGitHubRepoInfo(remoteUrl) {
1980
+ let urlToParse = remoteUrl;
1981
+ if (remoteUrl.startsWith("git@github.com:")) {
1982
+ urlToParse = remoteUrl.replace("git@github.com:", "");
1983
+ } else if (remoteUrl.startsWith("git@")) {
1984
+ throw new Error(
1985
+ `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
1986
+ );
2130
1987
  }
2131
- };
2132
- function buildToolResultContentPrefix(resultDisplay) {
2133
- if (!isVisionBridgeNoticeDisplay(resultDisplay)) return [];
2134
- return [
2135
- {
2136
- type: "content",
2137
- content: {
2138
- type: "text",
2139
- text: sanitizeTerminalText(
2140
- formatVisionBridgeNoticeDisplay(resultDisplay)
2141
- )
2142
- }
2143
- }
2144
- ];
1988
+ let parsedUrl;
1989
+ try {
1990
+ parsedUrl = new URL(urlToParse, "https://github.com");
1991
+ } catch {
1992
+ throw new Error(
1993
+ `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
1994
+ );
1995
+ }
1996
+ if (parsedUrl.hostname !== "github.com") {
1997
+ throw new Error(
1998
+ `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
1999
+ );
2000
+ }
2001
+ const parts = parsedUrl.pathname.split("/").filter((part) => part !== "");
2002
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
2003
+ throw new Error(
2004
+ `Owner & repo could not be extracted from remote URL: ${remoteUrl}`
2005
+ );
2006
+ }
2007
+ return { owner: parts[0], repo: parts[1].replace(/\.git$/, "") };
2145
2008
  }
2146
- __name(buildToolResultContentPrefix, "buildToolResultContentPrefix");
2009
+ __name(parseGitHubRepoInfo, "parseGitHubRepoInfo");
2147
2010
 
2148
- // packages/cli/src/acp-integration/session/history-replayer.ts
2149
- init_esbuild_shims();
2150
- var HistoryReplayer = class {
2151
- constructor(ctx) {
2152
- this.ctx = ctx;
2153
- this.toolCallEmitter = new ToolCallEmitter(ctx);
2154
- this.machine = this.createMachine();
2155
- }
2011
+ // packages/cli/src/services/setup-github.ts
2012
+ var debugLogger2 = createDebugLogger("SETUP_GITHUB");
2013
+ var GITHUB_WORKFLOW_PATHS = [
2014
+ "qwen-dispatch/qwen-dispatch.yml",
2015
+ "qwen-assistant/qwen-invoke.yml",
2016
+ "issue-triage/qwen-triage.yml",
2017
+ "issue-triage/qwen-scheduled-triage.yml",
2018
+ "pr-review/qwen-review.yml"
2019
+ ];
2020
+ var GITIGNORE_ENTRIES = [".qwen/", "gha-creds-*.json"];
2021
+ var MAX_WORKFLOW_DOWNLOAD_BYTES = 5 * 1024 * 1024;
2022
+ var SetupGithubError = class extends Error {
2156
2023
  static {
2157
- __name(this, "HistoryReplayer");
2024
+ __name(this, "SetupGithubError");
2158
2025
  }
2159
- toolCallEmitter;
2160
- machine;
2161
- async replay(records, gaps) {
2162
- try {
2163
- await this.replayPage(records, {
2164
- finalizeDangling: true,
2165
- gaps
2166
- });
2167
- } finally {
2168
- this.setActiveRecordId(null);
2169
- }
2026
+ code;
2027
+ status;
2028
+ partial;
2029
+ partialResult;
2030
+ constructor(code, message, status, partialResult) {
2031
+ super(message);
2032
+ this.name = "SetupGithubError";
2033
+ this.code = code;
2034
+ this.status = status;
2035
+ this.partial = partialResult !== void 0;
2036
+ this.partialResult = partialResult;
2170
2037
  }
2171
- async replayPage(records, options = {}) {
2172
- this.machine = this.createMachine(options);
2173
- let replayError;
2038
+ };
2039
+ function isWorkspaceGenerationClosed(error) {
2040
+ return Boolean(
2041
+ error && typeof error === "object" && "code" in error && error.code === "workspace_generation_closed"
2042
+ );
2043
+ }
2044
+ __name(isWorkspaceGenerationClosed, "isWorkspaceGenerationClosed");
2045
+ var nodeFileOps = {
2046
+ assertCanWrite() {
2047
+ },
2048
+ async ensureWorkflowDirectory(gitRepoRoot) {
2049
+ await fsp.mkdir(path.join(gitRepoRoot, ".github", "workflows"), {
2050
+ recursive: true
2051
+ });
2052
+ },
2053
+ async writeTextFile(gitRepoRoot, relativePath, content) {
2054
+ const target = path.join(gitRepoRoot, relativePath);
2055
+ await fsp.writeFile(target, content, { mode: 420 });
2056
+ return { sizeBytes: Buffer.byteLength(content, "utf8") };
2057
+ },
2058
+ async readTextFile(gitRepoRoot, relativePath) {
2174
2059
  try {
2175
- for (const record of records) {
2176
- for (const emission of this.machine.project(record)) {
2177
- this.setActiveRecordId(
2178
- emission.sourceRecordId,
2179
- emission.sourceTimestamp
2180
- );
2181
- await this.sendUpdate(emission.update);
2182
- }
2183
- }
2060
+ return await fsp.readFile(path.join(gitRepoRoot, relativePath), "utf8");
2184
2061
  } catch (error) {
2185
- replayError = error;
2062
+ if (error.code === "ENOENT") {
2063
+ return void 0;
2064
+ }
2065
+ throw error;
2186
2066
  }
2187
- let danglingError;
2188
- if (options.finalizeDangling === true) {
2189
- for (const emission of this.machine.finalize()) {
2190
- this.setActiveRecordId(
2191
- emission.sourceRecordId,
2192
- emission.sourceTimestamp
2067
+ }
2068
+ };
2069
+ async function setupGithub(options = {}) {
2070
+ const cwd = options.cwd ?? process.cwd();
2071
+ const fileOps = options.fileOps ?? nodeFileOps;
2072
+ if (!await isGitHubRepositoryAsync({ cwd })) {
2073
+ throw new SetupGithubError(
2074
+ "github_repository_not_found",
2075
+ "Unable to determine the GitHub repository. /setup-github must be run from a git repository.",
2076
+ 400
2077
+ );
2078
+ }
2079
+ let gitRepoRoot;
2080
+ try {
2081
+ gitRepoRoot = await getGitRepoRootAsync({ cwd });
2082
+ } catch (error) {
2083
+ debugLogger2.debug("Failed to get git repo root:", error);
2084
+ throw new SetupGithubError(
2085
+ "github_repository_not_found",
2086
+ "Unable to determine the GitHub repository. /setup-github must be run from a git repository.",
2087
+ 400
2088
+ );
2089
+ }
2090
+ if (options.workspaceRoot) {
2091
+ const [gitRootReal, workspaceReal] = await Promise.all([
2092
+ realpathOrResolve(gitRepoRoot),
2093
+ realpathOrResolve(options.workspaceRoot)
2094
+ ]);
2095
+ if (gitRootReal !== workspaceReal) {
2096
+ throw new SetupGithubError(
2097
+ "github_git_root_mismatch",
2098
+ "The Git repository root must match the daemon workspace root.",
2099
+ 400
2100
+ );
2101
+ }
2102
+ }
2103
+ fileOps.assertCanWrite?.();
2104
+ let releaseTag;
2105
+ try {
2106
+ releaseTag = await getLatestGitHubRelease(options.proxy);
2107
+ } catch (error) {
2108
+ writeStderrLine(
2109
+ `qwen setup-github: failed to determine latest qwen-code-action release: ${error instanceof Error ? error.message : String(error)}`
2110
+ );
2111
+ debugLogger2.debug(
2112
+ "Failed to determine latest qwen-code-action release:",
2113
+ error
2114
+ );
2115
+ throw new SetupGithubError(
2116
+ "github_release_lookup_failed",
2117
+ "Unable to determine the latest qwen-code-action release on GitHub.",
2118
+ 502
2119
+ );
2120
+ }
2121
+ const readmeUrl = `https://github.com/QwenLM/qwen-code-action/blob/${releaseTag}/README.md#quick-start`;
2122
+ const secretsUrl = await resolveSecretsUrl(cwd);
2123
+ const downloads = await downloadWorkflows({
2124
+ releaseTag,
2125
+ proxy: options.proxy,
2126
+ abortSignal: options.abortSignal,
2127
+ fetchImpl: options.fetchImpl ?? fetch
2128
+ });
2129
+ const result = {
2130
+ kind: "github_setup",
2131
+ workspaceCwd: options.workspaceRoot ?? gitRepoRoot,
2132
+ gitRepoRoot,
2133
+ releaseTag,
2134
+ readmeUrl,
2135
+ ...secretsUrl ? { secretsUrl } : {},
2136
+ workflows: [],
2137
+ gitignore: { path: ".gitignore", status: "skipped" },
2138
+ warnings: []
2139
+ };
2140
+ result.gitignore = await updateGitignore(gitRepoRoot, fileOps);
2141
+ if (result.gitignore.status === "failed") {
2142
+ result.warnings.push("Failed to update .gitignore.");
2143
+ }
2144
+ try {
2145
+ await fileOps.ensureWorkflowDirectory(gitRepoRoot);
2146
+ for (const workflow of downloads) {
2147
+ const relativePath = path.posix.join(
2148
+ ".github",
2149
+ "workflows",
2150
+ path.posix.basename(workflow.sourcePath)
2151
+ );
2152
+ try {
2153
+ const write = await fileOps.writeTextFile(
2154
+ gitRepoRoot,
2155
+ relativePath,
2156
+ workflow.content
2157
+ );
2158
+ result.workflows.push({
2159
+ sourcePath: workflow.sourcePath,
2160
+ path: relativePath,
2161
+ status: "written",
2162
+ sizeBytes: write.sizeBytes
2163
+ });
2164
+ } catch (error) {
2165
+ if (isWorkspaceGenerationClosed(error)) throw error;
2166
+ result.partial = true;
2167
+ result.workflows.push({
2168
+ sourcePath: workflow.sourcePath,
2169
+ path: relativePath,
2170
+ status: "failed",
2171
+ error: error instanceof Error ? error.message : String(error)
2172
+ });
2173
+ throw new SetupGithubError(
2174
+ "github_workflow_write_failed",
2175
+ `Unable to write ${relativePath}.`,
2176
+ 500,
2177
+ result
2193
2178
  );
2194
- try {
2195
- await this.sendUpdate(emission.update);
2196
- } catch (error) {
2197
- danglingError ??= error;
2198
- }
2199
2179
  }
2200
2180
  }
2201
- const replay = this.machine.snapshot();
2202
- this.copyCumulativeUsage(replay);
2203
- const state = {
2204
- pendingToolCalls: options.finalizeDangling === true ? [] : replay.pendingToolCalls.map(toLegacyPendingToolCall),
2205
- replay
2206
- };
2207
- this.setActiveRecordId(null);
2208
- if (replayError && danglingError) {
2209
- throw new AggregateError(
2210
- [replayError, danglingError],
2211
- "Replay and dangling-cleanup both failed"
2212
- );
2213
- }
2214
- if (replayError) throw replayError;
2215
- if (danglingError) throw danglingError;
2216
- return state;
2217
- }
2218
- getPendingToolCalls() {
2219
- return this.machine.snapshot().pendingToolCalls.map(toLegacyPendingToolCall);
2220
- }
2221
- getReplayState() {
2222
- return this.machine.snapshot();
2181
+ } catch (error) {
2182
+ if (isWorkspaceGenerationClosed(error)) throw error;
2183
+ if (error instanceof SetupGithubError) throw error;
2184
+ throw new SetupGithubError(
2185
+ "github_workflow_write_failed",
2186
+ "Unable to create .github/workflows.",
2187
+ 500,
2188
+ result
2189
+ );
2223
2190
  }
2224
- createMachine(options = {}) {
2225
- const cumulative = this.ctx.cumulativeUsage;
2226
- const initialState = {
2227
- v: 1,
2228
- pendingToolCalls: (options.pendingToolCalls ?? []).map(
2229
- toPendingTranscriptToolCall
2230
- ),
2231
- cumulativeUsage: cumulative ? { ...cumulative } : {
2232
- promptTokens: 0,
2233
- cachedTokens: 0,
2234
- candidateTokens: 0,
2235
- apiTimeMs: 0
2236
- },
2237
- ...options.goalState ? { goalState: options.goalState } : {},
2238
- ...options.goalCause ? { goalCause: options.goalCause } : {}
2191
+ return result;
2192
+ }
2193
+ __name(setupGithub, "setupGithub");
2194
+ async function updateGitignore(gitRepoRoot, fileOps = nodeFileOps) {
2195
+ try {
2196
+ const existingContent = await fileOps.readTextFile(
2197
+ gitRepoRoot,
2198
+ ".gitignore"
2199
+ );
2200
+ if (existingContent === void 0) {
2201
+ const content = GITIGNORE_ENTRIES.join("\n") + "\n";
2202
+ await fileOps.writeTextFile(gitRepoRoot, ".gitignore", content);
2203
+ return {
2204
+ path: ".gitignore",
2205
+ status: "created",
2206
+ added: [...GITIGNORE_ENTRIES]
2207
+ };
2208
+ }
2209
+ const missingEntries = GITIGNORE_ENTRIES.filter(
2210
+ (entry) => !existingContent.split(/\r?\n/).some((line) => line.split("#")[0].trim() === entry)
2211
+ );
2212
+ if (missingEntries.length === 0) {
2213
+ return { path: ".gitignore", status: "unchanged" };
2214
+ }
2215
+ const nextContent = existingContent + "\n" + missingEntries.join("\n") + "\n";
2216
+ await fileOps.writeTextFile(gitRepoRoot, ".gitignore", nextContent);
2217
+ return {
2218
+ path: ".gitignore",
2219
+ status: "updated",
2220
+ added: missingEntries
2239
2221
  };
2240
- return createTranscriptReplayMachine({
2241
- initialState,
2242
- gaps: options.gaps,
2243
- presentation: this.presentationAdapter(),
2244
- onDiagnostic: /* @__PURE__ */ __name((diagnostic) => {
2245
- if (diagnostic.code === "malformed_part" && diagnostic.path === "systemPayload.outputHistoryItems.goalStatus.condition") {
2246
- writeStderrLineSafe(`qwen: ${diagnostic.message}`);
2247
- }
2248
- }, "onDiagnostic")
2249
- });
2250
- }
2251
- presentationAdapter() {
2222
+ } catch (error) {
2223
+ if (isWorkspaceGenerationClosed(error)) throw error;
2224
+ debugLogger2.debug("Failed to update .gitignore:", error);
2252
2225
  return {
2253
- resolveToolMetadata: /* @__PURE__ */ __name((toolName, args) => this.toolCallEmitter.resolveToolMetadata(toolName, { ...args }), "resolveToolMetadata"),
2254
- formatHistoryGap: /* @__PURE__ */ __name((gap) => formatHistoryGapNotice(gap), "formatHistoryGap"),
2255
- buildToolResultContentPrefix
2226
+ path: ".gitignore",
2227
+ status: "failed",
2228
+ error: error instanceof Error ? error.message : String(error)
2256
2229
  };
2257
2230
  }
2258
- async sendUpdate(update) {
2259
- if (this.ctx.messageRewriter) {
2260
- await this.ctx.messageRewriter.interceptUpdate(update);
2261
- return;
2231
+ }
2232
+ __name(updateGitignore, "updateGitignore");
2233
+ async function downloadWorkflows(options) {
2234
+ const internalAbort = new AbortController();
2235
+ try {
2236
+ const dispatcher = options.proxy ? new (await loadUndici()).ProxyAgent(options.proxy) : void 0;
2237
+ return await Promise.all(
2238
+ GITHUB_WORKFLOW_PATHS.map(async (workflow) => {
2239
+ const endpoint = `https://raw.githubusercontent.com/QwenLM/qwen-code-action/refs/tags/${options.releaseTag}/examples/workflows/${workflow}`;
2240
+ const response = await options.fetchImpl(endpoint, {
2241
+ method: "GET",
2242
+ dispatcher,
2243
+ signal: AbortSignal.any([
2244
+ AbortSignal.timeout(3e4),
2245
+ internalAbort.signal,
2246
+ ...options.abortSignal ? [options.abortSignal] : []
2247
+ ])
2248
+ });
2249
+ if (!response.ok) {
2250
+ throw new Error(
2251
+ `Invalid response code downloading ${endpoint}: ${response.status} - ${response.statusText}`
2252
+ );
2253
+ }
2254
+ return {
2255
+ sourcePath: workflow,
2256
+ content: await readResponseTextWithLimit(response, workflow)
2257
+ };
2258
+ })
2259
+ );
2260
+ } catch (error) {
2261
+ internalAbort.abort();
2262
+ const message = error instanceof Error ? error.message : String(error);
2263
+ debugLogger2.debug("Failed to download qwen-code-action workflows:", error);
2264
+ throw new SetupGithubError(
2265
+ "github_workflow_download_failed",
2266
+ `Unable to download qwen-code-action workflows from GitHub. ${message}`,
2267
+ 502
2268
+ );
2269
+ }
2270
+ }
2271
+ __name(downloadWorkflows, "downloadWorkflows");
2272
+ async function readResponseTextWithLimit(response, sourcePath) {
2273
+ const contentLength = response.headers.get("content-length");
2274
+ if (contentLength !== null) {
2275
+ const parsedLength = Number(contentLength);
2276
+ if (Number.isFinite(parsedLength) && parsedLength > MAX_WORKFLOW_DOWNLOAD_BYTES) {
2277
+ throw new Error(
2278
+ `${sourcePath} exceeds download limit of ${MAX_WORKFLOW_DOWNLOAD_BYTES} bytes`
2279
+ );
2262
2280
  }
2263
- await this.ctx.sendUpdate(update);
2264
2281
  }
2265
- copyCumulativeUsage(state) {
2266
- const cumulative = this.ctx.cumulativeUsage;
2267
- if (!cumulative) return;
2268
- cumulative.promptTokens = state.cumulativeUsage.promptTokens;
2269
- cumulative.cachedTokens = state.cumulativeUsage.cachedTokens;
2270
- cumulative.candidateTokens = state.cumulativeUsage.candidateTokens;
2271
- cumulative.apiTimeMs = state.cumulativeUsage.apiTimeMs;
2282
+ if (!response.body) return "";
2283
+ const reader = response.body.getReader();
2284
+ const chunks = [];
2285
+ let totalBytes = 0;
2286
+ try {
2287
+ while (true) {
2288
+ const { done, value } = await reader.read();
2289
+ if (done) break;
2290
+ if (!value) continue;
2291
+ totalBytes += value.byteLength;
2292
+ if (totalBytes > MAX_WORKFLOW_DOWNLOAD_BYTES) {
2293
+ await reader.cancel().catch(() => {
2294
+ });
2295
+ throw new Error(
2296
+ `${sourcePath} exceeds download limit of ${MAX_WORKFLOW_DOWNLOAD_BYTES} bytes`
2297
+ );
2298
+ }
2299
+ chunks.push(value);
2300
+ }
2301
+ } finally {
2302
+ reader.releaseLock();
2272
2303
  }
2273
- setActiveRecordId(recordId, timestamp) {
2274
- this.ctx.setActiveRecordId?.(recordId, timestamp);
2304
+ const body = new Uint8Array(totalBytes);
2305
+ let offset = 0;
2306
+ for (const chunk of chunks) {
2307
+ body.set(chunk, offset);
2308
+ offset += chunk.byteLength;
2275
2309
  }
2276
- };
2277
- function toPendingTranscriptToolCall(pending) {
2278
- return {
2279
- callId: pending.callId,
2280
- toolName: pending.toolName,
2281
- sourceRecordId: pending.recordId,
2282
- ...pending.timestamp ? { sourceTimestamp: pending.timestamp } : {}
2283
- };
2310
+ return new TextDecoder().decode(body);
2284
2311
  }
2285
- __name(toPendingTranscriptToolCall, "toPendingTranscriptToolCall");
2286
- function toLegacyPendingToolCall(pending) {
2287
- return {
2288
- callId: pending.callId,
2289
- toolName: pending.toolName,
2290
- recordId: pending.sourceRecordId,
2291
- ...pending.sourceTimestamp ? { timestamp: pending.sourceTimestamp } : {}
2292
- };
2312
+ __name(readResponseTextWithLimit, "readResponseTextWithLimit");
2313
+ async function resolveSecretsUrl(cwd) {
2314
+ try {
2315
+ const repoInfo = await getGitHubRepoInfoAsync({ cwd });
2316
+ return `https://github.com/${repoInfo.owner}/${repoInfo.repo}/settings/secrets/actions`;
2317
+ } catch {
2318
+ return void 0;
2319
+ }
2293
2320
  }
2294
- __name(toLegacyPendingToolCall, "toLegacyPendingToolCall");
2321
+ __name(resolveSecretsUrl, "resolveSecretsUrl");
2322
+ async function realpathOrResolve(input) {
2323
+ try {
2324
+ return await fsp.realpath(input);
2325
+ } catch {
2326
+ return path.resolve(input);
2327
+ }
2328
+ }
2329
+ __name(realpathOrResolve, "realpathOrResolve");
2295
2330
 
2296
2331
  // packages/cli/src/ui/utils/export/collect.ts
2297
2332
  init_esbuild_shims();
@@ -2512,7 +2547,7 @@ async function extractMetadata(conversation, config) {
2512
2547
  const gitBranch = firstRecord?.gitBranch;
2513
2548
  let gitRepo;
2514
2549
  if (cwd) {
2515
- const { getGitRepoName } = await import("./deferred-core-runtime-SFT3KI2C.js");
2550
+ const { getGitRepoName } = await import("./deferred-core-runtime-FKJ3OYE7.js");
2516
2551
  gitRepo = getGitRepoName(cwd);
2517
2552
  }
2518
2553
  let model;
@@ -3363,6 +3398,122 @@ __name(generateExportFilename, "generateExportFilename");
3363
3398
  // packages/cli/src/ui/utils/export/index.ts
3364
3399
  init_esbuild_shims();
3365
3400
 
3401
+ // packages/cli/src/utils/json-string-byte-projection.ts
3402
+ init_esbuild_shims();
3403
+ import { Buffer as Buffer2 } from "node:buffer";
3404
+ var JSON_STRING_DELIMITER_BYTES = 2;
3405
+ function jsonPayloadBytesAt(value, index) {
3406
+ const code = value.charCodeAt(index);
3407
+ if (code === 34 || code === 92) return 2;
3408
+ if (code <= 31) {
3409
+ return code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
3410
+ }
3411
+ if (code <= 127) return 1;
3412
+ if (code <= 2047) return 2;
3413
+ if (code >= 55296 && code <= 56319) {
3414
+ const next = value.charCodeAt(index + 1);
3415
+ return next >= 56320 && next <= 57343 ? 4 : 6;
3416
+ }
3417
+ if (code >= 56320 && code <= 57343) return 6;
3418
+ return 3;
3419
+ }
3420
+ __name(jsonPayloadBytesAt, "jsonPayloadBytesAt");
3421
+ function jsonPayloadWidthAt(value, index) {
3422
+ const code = value.charCodeAt(index);
3423
+ if (code < 55296 || code > 56319) return 1;
3424
+ const next = value.charCodeAt(index + 1);
3425
+ return next >= 56320 && next <= 57343 ? 2 : 1;
3426
+ }
3427
+ __name(jsonPayloadWidthAt, "jsonPayloadWidthAt");
3428
+ function jsonStringPayloadByteLength(value, stopAfterBytes = Number.POSITIVE_INFINITY) {
3429
+ let bytes = 0;
3430
+ for (let index = 0; index < value.length; ) {
3431
+ bytes += jsonPayloadBytesAt(value, index);
3432
+ if (bytes > stopAfterBytes) return bytes;
3433
+ index += jsonPayloadWidthAt(value, index);
3434
+ }
3435
+ return bytes;
3436
+ }
3437
+ __name(jsonStringPayloadByteLength, "jsonStringPayloadByteLength");
3438
+ function jsonStringJsonByteLength(value) {
3439
+ return JSON_STRING_DELIMITER_BYTES + jsonStringPayloadByteLength(value);
3440
+ }
3441
+ __name(jsonStringJsonByteLength, "jsonStringJsonByteLength");
3442
+ function jsonPayloadWidthBefore(value, end) {
3443
+ const last = value.charCodeAt(end - 1);
3444
+ if (last >= 56320 && last <= 57343 && end >= 2) {
3445
+ const previous = value.charCodeAt(end - 2);
3446
+ if (previous >= 55296 && previous <= 56319) return 2;
3447
+ }
3448
+ return 1;
3449
+ }
3450
+ __name(jsonPayloadWidthBefore, "jsonPayloadWidthBefore");
3451
+ function selectPrefix(value, budget) {
3452
+ let end = 0;
3453
+ let bytes = 0;
3454
+ while (end < value.length) {
3455
+ const partBytes = jsonPayloadBytesAt(value, end);
3456
+ if (bytes + partBytes > budget) break;
3457
+ bytes += partBytes;
3458
+ end += jsonPayloadWidthAt(value, end);
3459
+ }
3460
+ return end;
3461
+ }
3462
+ __name(selectPrefix, "selectPrefix");
3463
+ function selectSuffix(value, budget) {
3464
+ let start = value.length;
3465
+ let bytes = 0;
3466
+ while (start > 0) {
3467
+ const partWidth = jsonPayloadWidthBefore(value, start);
3468
+ const partBytes = jsonPayloadBytesAt(value, start - partWidth);
3469
+ if (bytes + partBytes > budget) break;
3470
+ bytes += partBytes;
3471
+ start -= partWidth;
3472
+ }
3473
+ return start;
3474
+ }
3475
+ __name(selectSuffix, "selectSuffix");
3476
+ function copyString(value) {
3477
+ return value.split("").join("");
3478
+ }
3479
+ __name(copyString, "copyString");
3480
+ function truncateJsonStringPayload(value, originalPayloadBytes, payloadBudget, marker) {
3481
+ if (originalPayloadBytes <= payloadBudget) return value;
3482
+ const markerPayloadBytes = jsonStringPayloadByteLength(marker);
3483
+ if (payloadBudget < markerPayloadBytes) {
3484
+ return copyString(value.slice(0, selectPrefix(value, payloadBudget)));
3485
+ }
3486
+ const sourceBudget = payloadBudget - markerPayloadBytes;
3487
+ const headBudget = Math.floor(sourceBudget * 0.2);
3488
+ const tailBudget = sourceBudget - headBudget;
3489
+ const headEnd = selectPrefix(value, headBudget);
3490
+ const tailStart = selectSuffix(value, tailBudget);
3491
+ return copyString(value.slice(0, headEnd)) + marker + copyString(value.slice(tailStart));
3492
+ }
3493
+ __name(truncateJsonStringPayload, "truncateJsonStringPayload");
3494
+ function projectJsonStringToByteBudget(value, jsonByteBudget, marker) {
3495
+ const payloadBudget = Math.max(
3496
+ 0,
3497
+ jsonByteBudget - JSON_STRING_DELIMITER_BYTES
3498
+ );
3499
+ const payloadBytes = jsonStringPayloadByteLength(value, payloadBudget);
3500
+ if (payloadBytes <= payloadBudget) return value;
3501
+ const projected = truncateJsonStringPayload(
3502
+ value,
3503
+ payloadBytes,
3504
+ payloadBudget,
3505
+ marker
3506
+ );
3507
+ if (Buffer2.byteLength(JSON.stringify(projected), "utf8") <= jsonByteBudget) {
3508
+ return projected;
3509
+ }
3510
+ const fallback = copyString(
3511
+ marker.slice(0, selectPrefix(marker, payloadBudget))
3512
+ );
3513
+ return Buffer2.byteLength(JSON.stringify(fallback), "utf8") <= jsonByteBudget ? fallback : "";
3514
+ }
3515
+ __name(projectJsonStringToByteBudget, "projectJsonStringToByteBudget");
3516
+
3366
3517
  export {
3367
3518
  GITHUB_WORKFLOW_PATHS,
3368
3519
  SetupGithubError,
@@ -3382,11 +3533,16 @@ export {
3382
3533
  toHtml,
3383
3534
  toJson,
3384
3535
  toJsonl,
3385
- generateExportFilename
3536
+ generateExportFilename,
3537
+ JSON_STRING_DELIMITER_BYTES,
3538
+ jsonStringPayloadByteLength,
3539
+ jsonStringJsonByteLength,
3540
+ truncateJsonStringPayload,
3541
+ projectJsonStringToByteBudget
3386
3542
  };
3387
3543
  /**
3388
3544
  * @license
3389
- * Copyright 2025 Google LLC
3545
+ * Copyright 2026 Qwen Team
3390
3546
  * SPDX-License-Identifier: Apache-2.0
3391
3547
  */
3392
3548
  /**
@@ -3396,12 +3552,12 @@ export {
3396
3552
  */
3397
3553
  /**
3398
3554
  * @license
3399
- * Copyright 2026 Qwen Team
3555
+ * Copyright 2025 Qwen
3400
3556
  * SPDX-License-Identifier: Apache-2.0
3401
3557
  */
3402
3558
  /**
3403
3559
  * @license
3404
- * Copyright 2025 Qwen
3560
+ * Copyright 2025 Google LLC
3405
3561
  * SPDX-License-Identifier: Apache-2.0
3406
3562
  */
3407
3563
  /**