@qwen-code/qwen-code 0.20.0-preview.0 → 0.20.0

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 (341) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +1 -1
  2. package/bundled/qc-helper/docs/features/auto-mode.md +16 -19
  3. package/bundled/qc-helper/docs/features/commands.md +0 -54
  4. package/bundled/qc-helper/docs/features/sub-agents.md +7 -16
  5. package/bundled/qc-helper/docs/integration-github-action.md +10 -10
  6. package/bundled/qc-helper/docs/qwen-serve.md +1 -2
  7. package/bundled/review/DESIGN.md +2 -2
  8. package/bundled/review/SKILL.md +4 -4
  9. package/chunks/{MaxSizedBox-53BTJ3JK.js → MaxSizedBox-B5YGZSYE.js} +34 -41
  10. package/chunks/{StandaloneSessionPicker-VMFIXQ44.js → StandaloneSessionPicker-CEGO2AZX.js} +50 -57
  11. package/chunks/{acpAgent-5WYAVSFG.js → acpAgent-YUR43TLG.js} +496 -1487
  12. package/chunks/{agent-44FM7PBX.js → agent-H4JIDL7S.js} +30 -37
  13. package/chunks/agent-headless-TTBEREQV.js +61 -0
  14. package/chunks/{anthropicContentGenerator-NMSS7IMV.js → anthropicContentGenerator-HVKLXOOU.js} +12 -13
  15. package/chunks/{artifact-tool-56T5IMBP.js → artifact-tool-WBCAMD3O.js} +3 -3
  16. package/chunks/{askUserQuestion-E25OBIC2.js → askUserQuestion-6DZC4UV5.js} +3 -3
  17. package/chunks/{bridge-IQZT3KU2.js → bridge-VL7ITBU5.js} +35 -42
  18. package/chunks/{build-GHIZ4MSZ.js → build-SSCNEHZZ.js} +1 -1
  19. package/chunks/{ca-N6VVUFVB.js → ca-2SL2BXTK.js} +201 -611
  20. package/chunks/{channel-worker-group-LFBT7K64.js → channel-worker-group-53CMOPFT.js} +5 -5
  21. package/chunks/{channel-worker-manager-3RUPERG2.js → channel-worker-manager-UTXILKC2.js} +5 -5
  22. package/chunks/{channel-worker-supervisor-A3KVATD3.js → channel-worker-supervisor-ZGO2W2MD.js} +4 -4
  23. package/chunks/{chunk-2LI23QA6.js → chunk-2HOVDT7W.js} +1 -1
  24. package/chunks/{chunk-JWJVZHT5.js → chunk-2LL7TXB4.js} +2 -2
  25. package/chunks/{chunk-22OH7L7I.js → chunk-333CXMNJ.js} +5 -5
  26. package/chunks/{chunk-J3VSRG5Y.js → chunk-33XUAINQ.js} +21 -61
  27. package/chunks/{chunk-S4BT3PX3.js → chunk-4EP2PYYL.js} +5 -5
  28. package/chunks/{chunk-CJTAUXKG.js → chunk-4ILMYHEI.js} +3 -3
  29. package/chunks/{chunk-JIHHXJFH.js → chunk-4N3KMAIL.js} +32 -128
  30. package/chunks/{chunk-6ZBPS62S.js → chunk-4ODB7WIB.js} +1 -1
  31. package/chunks/{chunk-YDLVKCZJ.js → chunk-4XNLIGVA.js} +298 -576
  32. package/chunks/{chunk-Q6DEGTYO.js → chunk-542SK7KV.js} +1608 -243
  33. package/chunks/{chunk-EPN5MKRH.js → chunk-5JBR5XIK.js} +2 -2
  34. package/chunks/{chunk-E4IMU4Y5.js → chunk-5SCI6E3E.js} +1 -1
  35. package/chunks/{chunk-IE7TPOXP.js → chunk-6AFUCL3D.js} +1 -1
  36. package/chunks/{chunk-5I5BM454.js → chunk-6EFTQYW7.js} +1 -1
  37. package/chunks/{chunk-45AIVIUL.js → chunk-7PZ2ATFZ.js} +29 -54
  38. package/chunks/{chunk-VI7UU7ZI.js → chunk-7RMOXZTC.js} +4 -4
  39. package/chunks/{chunk-C3YZ5CLY.js → chunk-7SXZC7ID.js} +6 -7
  40. package/chunks/{chunk-X6KLM4LZ.js → chunk-A5LYNIW7.js} +8 -8
  41. package/chunks/{chunk-GZBHRTNM.js → chunk-AJSJ5TTU.js} +1 -1
  42. package/chunks/{chunk-IT27F3ES.js → chunk-AKX4WPPP.js} +86 -307
  43. package/chunks/{chunk-EJFHUF3D.js → chunk-ANPINBOF.js} +5 -5
  44. package/chunks/{chunk-JJEFX6U5.js → chunk-AQIEINAY.js} +1766 -28
  45. package/chunks/{chunk-7Z6JQEL6.js → chunk-AYCDXHZB.js} +1 -1
  46. package/chunks/{chunk-BKZEHVPV.js → chunk-B3KGZCQN.js} +169 -177
  47. package/chunks/{chunk-6X4GWOPW.js → chunk-BDBMYST4.js} +1 -1
  48. package/chunks/{chunk-BEKZWVJJ.js → chunk-BMWMT5Y2.js} +373 -3
  49. package/chunks/{chunk-5MZSD2JX.js → chunk-BRRF37CO.js} +6 -6
  50. package/chunks/{chunk-QLJUC7TG.js → chunk-BVLROR2T.js} +1 -1
  51. package/chunks/{chunk-OQB4EXO4.js → chunk-C27BYUX6.js} +11 -14
  52. package/chunks/{chunk-VTKWURCJ.js → chunk-CB2HFGRV.js} +6 -31
  53. package/chunks/chunk-CPCVCKKF.js +358 -0
  54. package/chunks/{chunk-OAGG6CRR.js → chunk-CV63PP6U.js} +1 -1
  55. package/chunks/{chunk-XFWD3PCA.js → chunk-CZF3E5GF.js} +1 -1
  56. package/chunks/{chunk-QF4DPYPH.js → chunk-D22SX43D.js} +1 -1
  57. package/chunks/{chunk-X6N25LXS.js → chunk-D2VIDMVM.js} +2 -2
  58. package/chunks/{chunk-7KZ2KYAD.js → chunk-DBE4QFZS.js} +23 -27
  59. package/chunks/{chunk-VHYCUGOT.js → chunk-DP5GXXNZ.js} +1 -5
  60. package/chunks/{chunk-Q2YKNMLS.js → chunk-EAUYY7SS.js} +3 -3
  61. package/chunks/{chunk-KHOVYUHX.js → chunk-EIAK6Q2B.js} +2 -2
  62. package/chunks/{chunk-NPQDJGKU.js → chunk-EZVDJFZ7.js} +1 -1
  63. package/chunks/{chunk-FODK6UMO.js → chunk-FEOZBUMT.js} +27 -0
  64. package/chunks/{chunk-6NHK6HS7.js → chunk-FLSVD6BS.js} +3 -3
  65. package/chunks/{chunk-XP32LURS.js → chunk-FQD7GFSV.js} +3 -3
  66. package/chunks/{chunk-T2L47JJK.js → chunk-FSL5W5TI.js} +3 -3
  67. package/chunks/{chunk-JCW2R7WC.js → chunk-G45X5TRN.js} +72 -1
  68. package/chunks/{chunk-ZHERRXZJ.js → chunk-GKY2OJ7R.js} +1 -1
  69. package/chunks/{chunk-6IL7KRLE.js → chunk-GMGDLUC7.js} +1 -1
  70. package/chunks/{chunk-E5MVGARW.js → chunk-HZPN55E5.js} +1 -1
  71. package/chunks/{chunk-LMQNDPVP.js → chunk-I2PYAYFM.js} +3 -3
  72. package/chunks/{chunk-JD5FHQ3N.js → chunk-IR46U7RB.js} +3 -3
  73. package/chunks/{chunk-BXXWWCLA.js → chunk-IVPSS6EL.js} +4 -4
  74. package/chunks/{chunk-4K56OJFJ.js → chunk-JD3MKVKL.js} +1 -1
  75. package/chunks/{chunk-SP5WRGVG.js → chunk-JNWZQ27S.js} +3 -3
  76. package/chunks/{chunk-RUNR5DAE.js → chunk-KDC6GNQR.js} +4 -4
  77. package/chunks/{chunk-JT7HACMQ.js → chunk-KG3XV6FH.js} +2 -29
  78. package/chunks/{chunk-BRHHXGWL.js → chunk-KOR3XKCA.js} +4 -10
  79. package/chunks/{chunk-H4OWOFZL.js → chunk-KQNM4EO7.js} +5 -137
  80. package/chunks/{chunk-4K7VDKAD.js → chunk-KTUQMDEP.js} +1 -1
  81. package/chunks/{chunk-6RQ5IPUX.js → chunk-KX6UK4VJ.js} +19929 -22391
  82. package/chunks/{chunk-JYS55H6Z.js → chunk-MAQQGNQ5.js} +7 -66
  83. package/chunks/{chunk-GOWMC4CS.js → chunk-MJ6S23WZ.js} +4 -4
  84. package/chunks/{chunk-D7WXIW7H.js → chunk-NBMIC7DR.js} +4 -4
  85. package/chunks/{chunk-NYPUWHHC.js → chunk-NDMQLV4Y.js} +4 -4
  86. package/chunks/{chunk-FFFM6NJV.js → chunk-NEEB7UEN.js} +2 -1
  87. package/chunks/{chunk-6AWRQ4T2.js → chunk-NGFEPAE6.js} +6 -8
  88. package/chunks/{chunk-RVLZCXEE.js → chunk-NIJEXGV6.js} +10 -79
  89. package/chunks/{chunk-6OHCY3OB.js → chunk-O3OCNYY5.js} +2 -2
  90. package/chunks/{chunk-J63IP5ZT.js → chunk-O3Z73NBP.js} +7 -7
  91. package/chunks/{chunk-RWCQJC5W.js → chunk-OEO2ERWK.js} +33 -54
  92. package/chunks/{chunk-KQQ757OQ.js → chunk-OLMETXLX.js} +2 -2
  93. package/chunks/{chunk-LIZRAKPB.js → chunk-OOCI5VVU.js} +1 -1
  94. package/chunks/{chunk-GPSKDNEE.js → chunk-OONJNQ42.js} +3 -3
  95. package/chunks/{chunk-YM3SZTH4.js → chunk-OP4MOGXF.js} +1 -8
  96. package/chunks/{chunk-CHLNJN3C.js → chunk-OWCALFEG.js} +1 -1
  97. package/chunks/{chunk-5JX7FPHW.js → chunk-OYZWQNWG.js} +2 -2
  98. package/chunks/{chunk-QBUDF33N.js → chunk-PBATSWUQ.js} +1 -1
  99. package/chunks/{chunk-DKZISEDB.js → chunk-PBWEWI4N.js} +69 -76
  100. package/chunks/{chunk-DORJSBMF.js → chunk-PF4CHQOJ.js} +6 -6
  101. package/chunks/{chunk-SOMSZ6W3.js → chunk-PGEPSDJI.js} +8 -13
  102. package/chunks/{chunk-4LVZNIDO.js → chunk-QKYTTBYW.js} +1 -1
  103. package/chunks/{chunk-VYPFXUCB.js → chunk-R3VWUU2E.js} +1 -1
  104. package/chunks/{chunk-RV4C2ZFG.js → chunk-RFIAR4YL.js} +1 -1
  105. package/chunks/{chunk-66RKDODM.js → chunk-S2PD3EZD.js} +1 -1
  106. package/chunks/{chunk-RAUHV362.js → chunk-S2W2LVDU.js} +3 -3
  107. package/chunks/{chunk-VLBJ7ZUG.js → chunk-S2XVRHDN.js} +1 -1
  108. package/chunks/chunk-SEKHYHMS.js +45 -0
  109. package/chunks/{chunk-KNTYRZD4.js → chunk-SJMV7ZBK.js} +8 -8
  110. package/chunks/{chunk-THJNPLI4.js → chunk-TB6UDU4T.js} +16 -16
  111. package/chunks/{chunk-CMRYLH67.js → chunk-TIH2ZTOC.js} +2 -2
  112. package/chunks/{chunk-K4VB66QF.js → chunk-TKLLK6XQ.js} +11 -11
  113. package/chunks/{chunk-QTROYZUC.js → chunk-TMQ6XQCX.js} +53 -170
  114. package/chunks/{chunk-QNLNLENL.js → chunk-UEY4AYUL.js} +2 -2
  115. package/chunks/{chunk-FSXCGBXB.js → chunk-VDWBQ5AW.js} +1 -1
  116. package/chunks/{chunk-45DNGJKC.js → chunk-VEXFOTEO.js} +3 -3
  117. package/chunks/{chunk-A7CUSHP7.js → chunk-VZQUV7VK.js} +1 -1
  118. package/chunks/chunk-W7FJ3N32.js +49 -0
  119. package/chunks/{chunk-UGYMA4EI.js → chunk-W7H223ZZ.js} +1 -1
  120. package/chunks/{chunk-UH3WSE5L.js → chunk-X6YQWCIJ.js} +1 -13
  121. package/chunks/{chunk-H4AR2JQF.js → chunk-XVVH63JG.js} +3 -3
  122. package/chunks/{chunk-QKTHJXCS.js → chunk-Y2ENGUD6.js} +1 -1
  123. package/chunks/{chunk-QD6BRERJ.js → chunk-YWEW33JY.js} +7 -7
  124. package/chunks/{chunk-57FIIFJN.js → chunk-ZEOZL37W.js} +1 -1
  125. package/chunks/chunk-ZFKNWQGQ.js +74639 -0
  126. package/chunks/{computer-use-FMEBQMCB.js → computer-use-NIWQNUZF.js} +35 -42
  127. package/chunks/{config-utils-WYUQ7II4.js → config-utils-AHQ6YZ66.js} +3 -3
  128. package/chunks/contextCommand-L2COEUHS.js +66 -0
  129. package/chunks/{create-sub-session-MLELTOCW.js → create-sub-session-MGNX52P3.js} +30 -37
  130. package/chunks/{create-sub-session-AZ77LBL3.js → create-sub-session-P26FE5GG.js} +3 -3
  131. package/chunks/{cron-create-KTWJM7QT.js → cron-create-JWFHBDRQ.js} +5 -5
  132. package/chunks/{cron-delete-2P3I5ULL.js → cron-delete-GDX4E26G.js} +5 -5
  133. package/chunks/{cron-list-PXDPGEDQ.js → cron-list-USMAIWPT.js} +5 -5
  134. package/chunks/{daemon-KLPTQIE4.js → daemon-RG2MAI6T.js} +81 -138
  135. package/chunks/daemon-status-provider-NL4IAG7B.js +74 -0
  136. package/chunks/{de-4IBXM7CN.js → de-I7ZIYXZC.js} +1 -5
  137. package/chunks/{dist-HMU6CYS4.js → dist-2BHAYBKP.js} +2 -2
  138. package/chunks/{dist-PJLG2XYX.js → dist-2MIU4UUH.js} +1 -1
  139. package/chunks/{dist-UIFWIFRO.js → dist-53PZYC5B.js} +2 -2
  140. package/chunks/{dist-OAV7LJGJ.js → dist-AU7NQQRP.js} +1 -1
  141. package/chunks/{dist-OMW6WDEO.js → dist-FUTEXY6A.js} +1 -1
  142. package/chunks/{dist-XRYV6TJP.js → dist-WGTQO7F2.js} +25 -65
  143. package/chunks/{earlyInputCapture-N3J42S2G.js → earlyInputCapture-L6I2A22T.js} +31 -38
  144. package/chunks/{edit-T6GO7VPW.js → edit-3QV3JZJL.js} +37 -42
  145. package/chunks/{en-USMCCJAJ.js → en-XE34GKAA.js} +1 -5
  146. package/chunks/{enter-worktree-OL3FMR3A.js → enter-worktree-4GMMF7EG.js} +35 -42
  147. package/chunks/{enterPlanMode-LEP7BSBX.js → enterPlanMode-L5UWBAUC.js} +36 -48
  148. package/chunks/{environment-6LNBH2LJ.js → environment-3OV7UQOT.js} +32 -39
  149. package/chunks/{errors-IM3H4DNG.js → errors-LEOF5QG4.js} +32 -39
  150. package/chunks/{exit-worktree-6MOANJMY.js → exit-worktree-DDP57JLV.js} +35 -42
  151. package/chunks/{exitPlanMode-VLBSWDJK.js → exitPlanMode-CJBLGPIP.js} +35 -42
  152. package/chunks/{fast-path-3Z3JY4BL.js → fast-path-M6RP2ING.js} +3 -4
  153. package/chunks/{fast-path-settings-XB3CPUJT.js → fast-path-settings-DAOVFADC.js} +2 -2
  154. package/chunks/{fr-WVHEBDDB.js → fr-X7KDVZIY.js} +1 -5
  155. package/chunks/{gemini-VDE6O6CX.js → gemini-H4PHBJTL.js} +89 -97
  156. package/chunks/{geminiContentGenerator-NN4ZWALY.js → geminiContentGenerator-VURJYPWP.js} +5 -5
  157. package/chunks/{getMachineId-bsd-QFVLPUPT.js → getMachineId-bsd-EXV7SWPA.js} +1 -1
  158. package/chunks/{getMachineId-darwin-DGMQQE2E.js → getMachineId-darwin-IUOMFXU3.js} +1 -1
  159. package/chunks/{getMachineId-linux-R4Z6CSWC.js → getMachineId-linux-K7XJYFHL.js} +1 -1
  160. package/chunks/{getMachineId-unsupported-Z3SBVBUV.js → getMachineId-unsupported-EA5FDRJ6.js} +1 -1
  161. package/chunks/{getMachineId-win-SCK5UFDT.js → getMachineId-win-KBA6RAI5.js} +1 -1
  162. package/chunks/{glob-7AZHIY3Z.js → glob-2KUSRAVQ.js} +35 -42
  163. package/chunks/{grep-E2KEORSD.js → grep-B5RXVESV.js} +35 -42
  164. package/chunks/handleAutoUpdate-QQVIWXKT.js +67 -0
  165. package/chunks/{i18n-VP4NCTZN.js → i18n-N6OBDORT.js} +31 -38
  166. package/chunks/initializer-6WCFNDLL.js +72 -0
  167. package/chunks/installationInfo-6J3WPXNS.js +64 -0
  168. package/chunks/{ja-KY4ROZTE.js → ja-2ICT3KXF.js} +1 -5
  169. package/chunks/{keychain-token-storage-6ACJDYIB.js → keychain-token-storage-DWRJMNH3.js} +3 -3
  170. package/chunks/list-HOWQSWP6.js +75 -0
  171. package/chunks/loadedSettingsAdapter-AO4YBRXZ.js +69 -0
  172. package/chunks/{loop-wakeup-RNMRVA66.js → loop-wakeup-5GLTUBHA.js} +6 -6
  173. package/chunks/{ls-J2ZI5XYK.js → ls-FHBY3Y7I.js} +5 -5
  174. package/chunks/{lsp-UMS3NUB5.js → lsp-B6VMEW6Y.js} +3 -3
  175. package/chunks/mcp-QH7QNXOH.js +69 -0
  176. package/chunks/{monitor-NDYKU5VS.js → monitor-GLJZDNPS.js} +35 -42
  177. package/chunks/nonInteractiveCli-TI7EMPXD.js +126 -0
  178. package/chunks/{notebook-edit-GF3HSMXN.js → notebook-edit-AVCIWS4F.js} +38 -43
  179. package/chunks/{openaiContentGenerator-GE2I3C2T.js → openaiContentGenerator-B7W24G3D.js} +17 -22
  180. package/chunks/{pidfile-KS4IGGNX.js → pidfile-UEHAT6DH.js} +31 -38
  181. package/chunks/{processUtils-TEQQ47A2.js → processUtils-XZPY2PBB.js} +2 -2
  182. package/chunks/{pt-OK455PLH.js → pt-JJ4XPIBP.js} +1 -5
  183. package/chunks/{qwenContentGenerator-NDYOEIUY.js → qwenContentGenerator-6GUTWJIC.js} +35 -44
  184. package/chunks/{qwenOAuth2-CXDOBPSK.js → qwenOAuth2-GASEEWGU.js} +15 -18
  185. package/chunks/{read-file-QDVJX75S.js → read-file-SQJONF6A.js} +11 -13
  186. package/chunks/{read-mcp-resource-F6HYMDUY.js → read-mcp-resource-AKCL7I43.js} +3 -3
  187. package/chunks/{record-artifact-7GCFLDD7.js → record-artifact-PEUB7727.js} +3 -3
  188. package/chunks/{resumeHistoryUtils-5EAQ76W4.js → resumeHistoryUtils-PFQ2A23X.js} +36 -43
  189. package/chunks/ripGrep-QCK22GDU.js +59 -0
  190. package/chunks/{ru-7SPDGMGD.js → ru-STR4KTW7.js} +1 -5
  191. package/chunks/{run-qwen-serve-TC6M3WTJ.js → run-qwen-serve-OZGR3FQA.js} +82 -104
  192. package/chunks/{runtime-BB73E3Z3.js → runtime-SNVAP6EH.js} +40 -49
  193. package/chunks/{scheduler-NDU5OFSJ.js → scheduler-Z7QLMUWA.js} +30 -37
  194. package/chunks/{send-message-PYIJ2PZL.js → send-message-3RHE7HSM.js} +4 -6
  195. package/chunks/{serve-BTIRWZJ4.js → serve-BT7KS6SC.js} +36 -43
  196. package/chunks/{server-JKAQBE2E.js → server-SO64U3X5.js} +284 -988
  197. package/chunks/{session-66QFVVDS.js → session-2KL2WQAH.js} +173 -92
  198. package/chunks/{settings-NBN6GY7E.js → settings-KITVOUSV.js} +39 -46
  199. package/chunks/{shell-JDSLAQVH.js → shell-BITUVH2R.js} +30 -37
  200. package/chunks/{skill-TNMHTO3C.js → skill-SOQHY455.js} +20 -24
  201. package/chunks/{spawnChannel-TFLHHXOC.js → spawnChannel-2BU3AULL.js} +32 -39
  202. package/chunks/{src-YFXMPRBL.js → src-43LM7JLB.js} +209 -279
  203. package/chunks/{standalone-update-2CQVQRSC.js → standalone-update-YG5JUYCM.js} +32 -39
  204. package/chunks/{startInteractiveUI-6C6PENRW.js → startInteractiveUI-3RGTGEX5.js} +895 -1092
  205. package/chunks/{syntheticOutput-H7RTI5KL.js → syntheticOutput-FG5PQKIR.js} +4 -4
  206. package/chunks/{task-create-7474AJJD.js → task-create-HX32YXO7.js} +8 -10
  207. package/chunks/{task-list-633HGOIB.js → task-list-QWSY4ZIU.js} +6 -6
  208. package/chunks/{task-stop-MNUGHPIA.js → task-stop-GWC6UWAL.js} +3 -3
  209. package/chunks/{task-update-66GQB5LI.js → task-update-NCTAB73Q.js} +8 -10
  210. package/chunks/{team-create-IPBHD26Z.js → team-create-FXN3PEBP.js} +35 -42
  211. package/chunks/{team-delete-BB3CG3QF.js → team-delete-KK37HTOG.js} +6 -6
  212. package/chunks/{team-plan-approval-WIGEJXXM.js → team-plan-approval-GEIZ356Q.js} +35 -42
  213. package/chunks/theme-manager-IAETOI25.js +63 -0
  214. package/chunks/{todoWrite-KRAUN54W.js → todoWrite-ERCAMLFS.js} +5 -5
  215. package/chunks/{tool-search-J3CBYJRB.js → tool-search-XKK7DNOK.js} +17 -21
  216. package/chunks/total-session-admission-BJLDHKJN.js +69 -0
  217. package/chunks/{trustedFolders-5FJRCHGN.js → trustedFolders-5XCVNEUU.js} +31 -38
  218. package/chunks/{update-relaunch-S5APSFJS.js → update-relaunch-FMVZK6XF.js} +17 -17
  219. package/chunks/updateCheck-YZZB7YBU.js +70 -0
  220. package/chunks/{useAutoAcceptIndicator-WZVJ52U3.js → useAutoAcceptIndicator-ZSQX4I2H.js} +40 -47
  221. package/chunks/{validateNonInterActiveAuth-64SVMELJ.js → validateNonInterActiveAuth-PRVEB6GG.js} +72 -79
  222. package/chunks/{version-SQL27GUA.js → version-AZMG6KWL.js} +1 -1
  223. package/chunks/{web-fetch-K7QCHIOJ.js → web-fetch-EPGJ5OQQ.js} +41 -100
  224. package/chunks/{workflow-BFTW72A5.js → workflow-UTNVPW22.js} +39 -47
  225. package/chunks/workspace-providers-status-EADV364W.js +72 -0
  226. package/chunks/{workspace-registration-store-VAVPVIF3.js → workspace-registration-store-F3ZX3YHT.js} +2 -8
  227. package/chunks/workspace-registry-W6VMFYZU.js +73 -0
  228. package/chunks/workspace-service-F3KIN2UN.js +84 -0
  229. package/chunks/workspace-skills-status-YVICUR5Y.js +71 -0
  230. package/chunks/write-file-CVGF2OKV.js +596 -0
  231. package/chunks/{zh-WY5DWYZD.js → zh-6ANG2HTL.js} +1 -5
  232. package/chunks/{zh-TW-BM47YBFH.js → zh-TW-4RR3YHNN.js} +1 -5
  233. package/cli-entry.js +12 -164
  234. package/cli.js +11 -18
  235. package/locales/ca.js +203 -772
  236. package/locales/de.js +2 -8
  237. package/locales/en.js +2 -8
  238. package/locales/fr.js +2 -8
  239. package/locales/ja.js +2 -8
  240. package/locales/pt.js +2 -8
  241. package/locales/ru.js +2 -8
  242. package/locales/zh-TW.js +2 -8
  243. package/locales/zh.js +2 -8
  244. package/package.json +3 -3
  245. package/web-shell/assets/{arc-ByltRugA.js → arc-Buk1besA.js} +1 -1
  246. package/web-shell/assets/{architectureDiagram-3BPJPVTR-CCRTto5d.js → architectureDiagram-3BPJPVTR-B1aUKYDC.js} +1 -1
  247. package/web-shell/assets/{blockDiagram-GPEHLZMM-Jfy36u1L.js → blockDiagram-GPEHLZMM-CRTdg3Zx.js} +1 -1
  248. package/web-shell/assets/{c4Diagram-AAUBKEIU-4d5FfEZ0.js → c4Diagram-AAUBKEIU-DFdRMp5g.js} +1 -1
  249. package/web-shell/assets/channel-04R0vLbG.js +1 -0
  250. package/web-shell/assets/{chunk-2J33WTMH-BPwxCEro.js → chunk-2J33WTMH-4rYQdkEI.js} +1 -1
  251. package/web-shell/assets/{chunk-4BX2VUAB-jY7ZmJWY.js → chunk-4BX2VUAB-Coi-pQJy.js} +1 -1
  252. package/web-shell/assets/{chunk-55IACEB6-C98HgCsS.js → chunk-55IACEB6-BtBjz02t.js} +1 -1
  253. package/web-shell/assets/{chunk-727SXJPM-cDu-ge-q.js → chunk-727SXJPM-CGYOWorl.js} +1 -1
  254. package/web-shell/assets/{chunk-AQP2D5EJ-BKdJwxXK.js → chunk-AQP2D5EJ-CH5AKhqx.js} +1 -1
  255. package/web-shell/assets/{chunk-FMBD7UC4-DnuxqwMu.js → chunk-FMBD7UC4-Cd50-w85.js} +1 -1
  256. package/web-shell/assets/{chunk-ND2GUHAM-C4fZNPv0.js → chunk-ND2GUHAM-C2wF3KCK.js} +1 -1
  257. package/web-shell/assets/{chunk-QZHKN3VN-Cf4XWOmz.js → chunk-QZHKN3VN-pCeRTaWi.js} +1 -1
  258. package/web-shell/assets/classDiagram-4FO5ZUOK-Bw9SOwAV.js +1 -0
  259. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Bw9SOwAV.js +1 -0
  260. package/web-shell/assets/{cose-bilkent-S5V4N54A-C82mFiqj.js → cose-bilkent-S5V4N54A-B-_fAB6D.js} +1 -1
  261. package/web-shell/assets/{dagre-BM42HDAG-Df8KACER.js → dagre-BM42HDAG-ChSPNHpL.js} +1 -1
  262. package/web-shell/assets/{diagram-2AECGRRQ-EzNs7s_2.js → diagram-2AECGRRQ-BX7cFOF3.js} +1 -1
  263. package/web-shell/assets/{diagram-5GNKFQAL-BRLNvreg.js → diagram-5GNKFQAL-BQUTW92n.js} +1 -1
  264. package/web-shell/assets/{diagram-KO2AKTUF-2HLYHRjC.js → diagram-KO2AKTUF-BkYPh3e4.js} +1 -1
  265. package/web-shell/assets/{diagram-LMA3HP47-DeH0NzSp.js → diagram-LMA3HP47-Cl6jsNyx.js} +1 -1
  266. package/web-shell/assets/{diagram-OG6HWLK6-k5Gn47-G.js → diagram-OG6HWLK6-DRWoHz8n.js} +1 -1
  267. package/web-shell/assets/{erDiagram-TEJ5UH35-gPHFo79f.js → erDiagram-TEJ5UH35-CGvFcZco.js} +1 -1
  268. package/web-shell/assets/{flowDiagram-I6XJVG4X-DYBOiTRW.js → flowDiagram-I6XJVG4X-vms6oVdv.js} +1 -1
  269. package/web-shell/assets/{ganttDiagram-6RSMTGT7-cxjAuic9.js → ganttDiagram-6RSMTGT7-ukT_sfmi.js} +1 -1
  270. package/web-shell/assets/{gitGraphDiagram-PVQCEYII-3nPqpmCP.js → gitGraphDiagram-PVQCEYII-Bn2ZE2Ut.js} +1 -1
  271. package/web-shell/assets/index-DgkKrjw3.js +1187 -0
  272. package/web-shell/assets/index-Rv6mOAN9.css +5 -0
  273. package/web-shell/assets/{index-Cl8d-1bK.js → index-wFXp7W68.js} +1 -1
  274. package/web-shell/assets/{infoDiagram-5YYISTIA-Dph21pR5.js → infoDiagram-5YYISTIA-DHJdSi7x.js} +1 -1
  275. package/web-shell/assets/{ishikawaDiagram-YF4QCWOH-Cjg1hSaG.js → ishikawaDiagram-YF4QCWOH-DOvd2Wph.js} +1 -1
  276. package/web-shell/assets/{journeyDiagram-JHISSGLW-CR-IzvnU.js → journeyDiagram-JHISSGLW-CH_urMCT.js} +1 -1
  277. package/web-shell/assets/{kanban-definition-UN3LZRKU-BYmuybuC.js → kanban-definition-UN3LZRKU-FKiBdgbH.js} +1 -1
  278. package/web-shell/assets/{linear-CngEEoy8.js → linear-0ZVQFVKf.js} +1 -1
  279. package/web-shell/assets/{mermaid.core-G6fbZRPf.js → mermaid.core-DJ05ZZIK.js} +5 -5
  280. package/web-shell/assets/{mindmap-definition-RKZ34NQL-BtnqnUwJ.js → mindmap-definition-RKZ34NQL-BPuUhkUm.js} +1 -1
  281. package/web-shell/assets/{pieDiagram-4H26LBE5-XTq6UHIA.js → pieDiagram-4H26LBE5-yLFKcXyG.js} +1 -1
  282. package/web-shell/assets/{quadrantDiagram-W4KKPZXB-D1J5PrsS.js → quadrantDiagram-W4KKPZXB-irWqc1pE.js} +1 -1
  283. package/web-shell/assets/{requirementDiagram-4Y6WPE33-CLcBUy3t.js → requirementDiagram-4Y6WPE33-B_4uMoIV.js} +1 -1
  284. package/web-shell/assets/{sankeyDiagram-5OEKKPKP-iwKV02_6.js → sankeyDiagram-5OEKKPKP-ciA4GPwk.js} +1 -1
  285. package/web-shell/assets/{sequenceDiagram-3UESZ5HK-7NFYQcEX.js → sequenceDiagram-3UESZ5HK-CRdZvy0U.js} +1 -1
  286. package/web-shell/assets/{stateDiagram-AJRCARHV-Bvm4Wih6.js → stateDiagram-AJRCARHV-DaYIkCCn.js} +1 -1
  287. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-DWBoO4UY.js +1 -0
  288. package/web-shell/assets/{timeline-definition-PNZ67QCA-B4FZFE9O.js → timeline-definition-PNZ67QCA-oBUKv6iH.js} +1 -1
  289. package/web-shell/assets/{vennDiagram-CIIHVFJN-CvMBpmtL.js → vennDiagram-CIIHVFJN-CGW9Sdmb.js} +1 -1
  290. package/web-shell/assets/{wardley-L42UT6IY-E3ag2327.js → wardley-L42UT6IY-CvwKJOCm.js} +1 -1
  291. package/web-shell/assets/{wardleyDiagram-YWT4CUSO-BEXWlgxC.js → wardleyDiagram-YWT4CUSO-Ipc260sN.js} +1 -1
  292. package/web-shell/assets/{xychartDiagram-2RQKCTM6-CICK05gI.js → xychartDiagram-2RQKCTM6-D6-CM7pK.js} +1 -1
  293. package/web-shell/index.html +2 -2
  294. package/chunks/agent-headless-CDBMKM44.js +0 -68
  295. package/chunks/chunk-2RFKHEXL.js +0 -74
  296. package/chunks/chunk-43T5WDQ7.js +0 -127
  297. package/chunks/chunk-6PVPNMXU.js +0 -29
  298. package/chunks/chunk-7362QS5B.js +0 -2256
  299. package/chunks/chunk-FMXMKPI5.js +0 -1780
  300. package/chunks/chunk-GLNBDYUX.js +0 -38
  301. package/chunks/chunk-HTR4WV6U.js +0 -327
  302. package/chunks/chunk-KWK7UE6L.js +0 -6194
  303. package/chunks/chunk-M7WBGLYP.js +0 -151
  304. package/chunks/chunk-NABLFI57.js +0 -82
  305. package/chunks/chunk-OQ5SYCPE.js +0 -10017
  306. package/chunks/chunk-OZYV6F53.js +0 -391
  307. package/chunks/chunk-TJQXJJX7.js +0 -121
  308. package/chunks/chunk-U7ZFW55U.js +0 -2098
  309. package/chunks/chunk-WHGVTP7Q.js +0 -1049
  310. package/chunks/chunk-XHATNRQA.js +0 -1500
  311. package/chunks/chunk-ZJVVETCV.js +0 -20600
  312. package/chunks/contextCommand-5YK3QNNJ.js +0 -73
  313. package/chunks/daemon-status-provider-FXMOD242.js +0 -81
  314. package/chunks/handleAutoUpdate-BCNVTQWW.js +0 -74
  315. package/chunks/initializer-5UB4SRPK.js +0 -79
  316. package/chunks/installationInfo-LNYJCXN3.js +0 -73
  317. package/chunks/list-NIZ77KPE.js +0 -82
  318. package/chunks/loadedSettingsAdapter-IQPRO2SO.js +0 -76
  319. package/chunks/managed-npm-update-GFRDCD77.js +0 -333
  320. package/chunks/mcp-TCUL7LT2.js +0 -76
  321. package/chunks/nonInteractiveCli-UHSHJDFD.js +0 -133
  322. package/chunks/ripGrep-WANMXNVT.js +0 -66
  323. package/chunks/sdk-exporters-grpc-ETLH47EP.js +0 -23214
  324. package/chunks/sdk-exporters-http-T3POX73F.js +0 -563
  325. package/chunks/sdk-impl-NSLPDH6I.js +0 -9193
  326. package/chunks/theme-manager-OZYKJG3W.js +0 -70
  327. package/chunks/total-session-admission-CNBQRM44.js +0 -76
  328. package/chunks/updateCheck-BPSMOZXS.js +0 -89
  329. package/chunks/web-search-KQPQFM7A.js +0 -731
  330. package/chunks/workspace-providers-status-4PLI2VFC.js +0 -79
  331. package/chunks/workspace-registry-I4ZRHGBS.js +0 -80
  332. package/chunks/workspace-service-RXYBWBDJ.js +0 -91
  333. package/chunks/workspace-skills-status-35Z2FU4I.js +0 -78
  334. package/chunks/write-file-KCL5RI2I.js +0 -66
  335. package/web-shell/assets/channel-4N2UIFcG.js +0 -1
  336. package/web-shell/assets/classDiagram-4FO5ZUOK-Q4dYOtsh.js +0 -1
  337. package/web-shell/assets/classDiagram-v2-Q7XG4LA2-Q4dYOtsh.js +0 -1
  338. package/web-shell/assets/index-B7jzUZ_s.css +0 -5
  339. package/web-shell/assets/index-gE8OWwj_.js +0 -1197
  340. package/web-shell/assets/stateDiagram-v2-BHNVJYJU-xXU_zO2Z.js +0 -1
  341. package/chunks/{chunk-QZJY47IE.js → chunk-PEJWA3QQ.js} +5 -5
@@ -1,23 +1,53 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ import {
4
+ InvalidStreamError,
5
+ OpenAIContentConverter,
6
+ ProtocolTagSanitizedEvent,
7
+ TaggedThinkingParser,
8
+ getRateLimitErrorDetails,
9
+ logProtocolTagSanitized,
10
+ openaiRequestCaptureContext
11
+ } from "./chunk-ZFKNWQGQ.js";
12
+ import {
13
+ RequestTokenizer
14
+ } from "./chunk-FLSVD6BS.js";
3
15
  import {
4
16
  DASHSCOPE_PROXY_BASE_URL,
5
17
  DEFAULT_DASHSCOPE_BASE_URL,
6
18
  DEFAULT_MAX_RETRIES,
19
+ DEFAULT_STREAM_IDLE_TIMEOUT_MS,
20
+ MAX_STREAM_IDLE_TIMEOUT_MS,
21
+ QWEN_STREAM_IDLE_TIMEOUT_MS_ENV,
7
22
  resolveRequestTimeout
8
- } from "./chunk-GLNBDYUX.js";
23
+ } from "./chunk-FEOZBUMT.js";
9
24
  import {
10
- buildRuntimeFetchOptions
11
- } from "./chunk-5I5BM454.js";
25
+ createChildAbortController
26
+ } from "./chunk-DJ2GSRLV.js";
27
+ import {
28
+ buildRuntimeFetchOptions,
29
+ redactProxyError
30
+ } from "./chunk-6EFTQYW7.js";
12
31
  import {
13
32
  defaultOutputCeiling,
33
+ getToolCallPreparations,
14
34
  hasExplicitOutputLimit,
15
35
  parsePositiveIntegerEnvValue,
36
+ reconcileMaxTokens,
37
+ runtimeDiagnostics,
38
+ safeJsonParse,
16
39
  tokenLimit
17
- } from "./chunk-JYS55H6Z.js";
40
+ } from "./chunk-MAQQGNQ5.js";
41
+ import {
42
+ GenerateContentResponse
43
+ } from "./chunk-TYQMGACW.js";
18
44
  import {
19
- createDebugLogger
20
- } from "./chunk-OQB4EXO4.js";
45
+ createDebugLogger,
46
+ getErrorMessage,
47
+ getErrorStatus,
48
+ getErrorType,
49
+ isAbortError
50
+ } from "./chunk-C27BYUX6.js";
21
51
  import {
22
52
  init_esbuild_shims
23
53
  } from "./chunk-5O2XNYP6.js";
@@ -25,6 +55,24 @@ import {
25
55
  __name
26
56
  } from "./chunk-J2S4EL5Y.js";
27
57
 
58
+ // packages/core/src/core/openaiContentGenerator/index.ts
59
+ init_esbuild_shims();
60
+
61
+ // packages/core/src/core/openaiContentGenerator/openaiContentGenerator.ts
62
+ init_esbuild_shims();
63
+
64
+ // packages/core/src/core/openaiContentGenerator/provider/index.ts
65
+ init_esbuild_shims();
66
+
67
+ // packages/core/src/core/openaiContentGenerator/provider/modelscope.ts
68
+ init_esbuild_shims();
69
+
70
+ // packages/core/src/core/openaiContentGenerator/provider/default.ts
71
+ init_esbuild_shims();
72
+
73
+ // node_modules/openai/index.mjs
74
+ init_esbuild_shims();
75
+
28
76
  // node_modules/openai/client.mjs
29
77
  init_esbuild_shims();
30
78
 
@@ -70,12 +118,12 @@ init_esbuild_shims();
70
118
 
71
119
  // node_modules/openai/internal/errors.mjs
72
120
  init_esbuild_shims();
73
- function isAbortError(err) {
121
+ function isAbortError2(err) {
74
122
  return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
75
123
  ("name" in err && err.name === "AbortError" || // Expo fetch
76
124
  "message" in err && String(err.message).includes("FetchRequestCanceledException"));
77
125
  }
78
- __name(isAbortError, "isAbortError");
126
+ __name(isAbortError2, "isAbortError");
79
127
  var castToError = /* @__PURE__ */ __name((err) => {
80
128
  if (err instanceof Error)
81
129
  return err;
@@ -1180,7 +1228,7 @@ var Stream = class _Stream {
1180
1228
  }
1181
1229
  done = true;
1182
1230
  } catch (e) {
1183
- if (isAbortError(e))
1231
+ if (isAbortError2(e))
1184
1232
  return;
1185
1233
  throw e;
1186
1234
  } finally {
@@ -1225,7 +1273,7 @@ var Stream = class _Stream {
1225
1273
  }
1226
1274
  done = true;
1227
1275
  } catch (e) {
1228
- if (isAbortError(e))
1276
+ if (isAbortError2(e))
1229
1277
  return;
1230
1278
  throw e;
1231
1279
  } finally {
@@ -6619,7 +6667,7 @@ var OpenAI = class {
6619
6667
  if (options.signal?.aborted) {
6620
6668
  throw new APIUserAbortError();
6621
6669
  }
6622
- const isTimeout = isAbortError(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
6670
+ const isTimeout = isAbortError2(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
6623
6671
  if (retriesRemaining) {
6624
6672
  loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
6625
6673
  loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails({
@@ -6869,14 +6917,10 @@ OpenAI.Responses = Responses;
6869
6917
  OpenAI.Evals = Evals;
6870
6918
  OpenAI.Containers = Containers;
6871
6919
 
6872
- // node_modules/openai/index.mjs
6873
- init_esbuild_shims();
6874
-
6875
6920
  // node_modules/openai/azure.mjs
6876
6921
  init_esbuild_shims();
6877
6922
 
6878
6923
  // packages/core/src/core/openaiContentGenerator/provider/default.ts
6879
- init_esbuild_shims();
6880
6924
  function shouldMirrorReasoningContentForQwen3(model) {
6881
6925
  return model.toLowerCase().includes("qwen3");
6882
6926
  }
@@ -7012,14 +7056,40 @@ var DefaultOpenAICompatibleProvider = class {
7012
7056
  }
7013
7057
  };
7014
7058
 
7059
+ // packages/core/src/core/openaiContentGenerator/provider/modelscope.ts
7060
+ var ModelScopeOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7061
+ static {
7062
+ __name(this, "ModelScopeOpenAICompatibleProvider");
7063
+ }
7064
+ /**
7065
+ * Checks if the configuration is for ModelScope.
7066
+ */
7067
+ static isModelScopeProvider(config) {
7068
+ const baseUrl = config.baseUrl ?? "";
7069
+ if (!baseUrl) return false;
7070
+ try {
7071
+ const hostname = new URL(baseUrl).hostname.toLowerCase();
7072
+ return hostname === "modelscope.cn" || hostname.endsWith(".modelscope.cn");
7073
+ } catch {
7074
+ return false;
7075
+ }
7076
+ }
7077
+ /**
7078
+ * ModelScope does not support `stream_options` when `stream` is false.
7079
+ * This method removes `stream_options` if `stream` is not true.
7080
+ */
7081
+ buildRequest(request, userPromptId) {
7082
+ const newRequest = super.buildRequest(request, userPromptId);
7083
+ if (!newRequest.stream) {
7084
+ delete newRequest.stream_options;
7085
+ }
7086
+ return newRequest;
7087
+ }
7088
+ };
7089
+
7015
7090
  // packages/core/src/core/openaiContentGenerator/provider/dashscope.ts
7016
7091
  init_esbuild_shims();
7017
7092
  var debugLogger = createDebugLogger("DashScopeOpenAICompatibleProvider");
7018
- var DASHSCOPE_REGIONAL_HOSTS = [
7019
- "dashscope.aliyuncs.com",
7020
- "dashscope-intl.aliyuncs.com",
7021
- "dashscope-us.aliyuncs.com"
7022
- ];
7023
7093
  var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider extends DefaultOpenAICompatibleProvider {
7024
7094
  static {
7025
7095
  __name(this, "DashScopeOpenAICompatibleProvider");
@@ -7032,7 +7102,7 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7032
7102
  }
7033
7103
  /**
7034
7104
  * Determines whether to use the DashScope-compatible provider.
7035
- * Covers the official regional hosts (DASHSCOPE_REGIONAL_HOSTS),
7105
+ * Covers dashscope.aliyuncs.com, dashscope-intl.aliyuncs.com,
7036
7106
  * Token Plan endpoints under token-plan.<region>.maas.aliyuncs.com,
7037
7107
  * internal Alibaba domains (*.alibaba-inc.com, *.aliyun-inc.com),
7038
7108
  * and proxy matches.
@@ -7052,9 +7122,7 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7052
7122
  } catch {
7053
7123
  hostname = null;
7054
7124
  }
7055
- const isDashscopeOrigin = hostname !== null && DASHSCOPE_REGIONAL_HOSTS.some(
7056
- (host) => hostname === host || hostname.endsWith("." + host)
7057
- );
7125
+ const isDashscopeOrigin = hostname !== null && (hostname === "dashscope.aliyuncs.com" || hostname === "dashscope-intl.aliyuncs.com" || hostname.endsWith(".dashscope.aliyuncs.com") || hostname.endsWith(".dashscope-intl.aliyuncs.com"));
7058
7126
  const isTokenPlanOrigin = hostname !== null && hostname.startsWith("token-plan.") && hostname.endsWith(".maas.aliyuncs.com");
7059
7127
  const isInternalOrigin = hostname !== null && (hostname.endsWith(".alibaba-inc.com") || hostname.endsWith(".aliyun-inc.com"));
7060
7128
  const normalizedProxyUrl = DASHSCOPE_PROXY_BASE_URL?.endsWith("/") ? DASHSCOPE_PROXY_BASE_URL.slice(0, -1) : DASHSCOPE_PROXY_BASE_URL;
@@ -7382,9 +7450,1679 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7382
7450
  }
7383
7451
  };
7384
7452
 
7453
+ // packages/core/src/core/openaiContentGenerator/provider/deepseek.ts
7454
+ init_esbuild_shims();
7455
+
7456
+ // packages/core/src/core/openaiContentGenerator/provider/utils.ts
7457
+ init_esbuild_shims();
7458
+ function ensureReasoningContentOnAssistantMessage(message) {
7459
+ if (message.role !== "assistant") {
7460
+ return message;
7461
+ }
7462
+ const assistant = message;
7463
+ if (typeof assistant.reasoning_content === "string") {
7464
+ return message;
7465
+ }
7466
+ return {
7467
+ ...assistant,
7468
+ reasoning_content: ""
7469
+ };
7470
+ }
7471
+ __name(ensureReasoningContentOnAssistantMessage, "ensureReasoningContentOnAssistantMessage");
7472
+
7473
+ // packages/core/src/core/openaiContentGenerator/provider/deepseek.ts
7474
+ function isDeepSeekHostname(contentGeneratorConfig) {
7475
+ const baseUrl = contentGeneratorConfig.baseUrl ?? "";
7476
+ if (!baseUrl) return false;
7477
+ try {
7478
+ const hostname = new URL(baseUrl).hostname.toLowerCase();
7479
+ return hostname === "api.deepseek.com" || hostname.endsWith(".api.deepseek.com");
7480
+ } catch {
7481
+ return false;
7482
+ }
7483
+ }
7484
+ __name(isDeepSeekHostname, "isDeepSeekHostname");
7485
+ function isDeepSeekProvider(contentGeneratorConfig) {
7486
+ if (isDeepSeekHostname(contentGeneratorConfig)) return true;
7487
+ const model = contentGeneratorConfig.model ?? "";
7488
+ return model.toLowerCase().includes("deepseek");
7489
+ }
7490
+ __name(isDeepSeekProvider, "isDeepSeekProvider");
7491
+ var DeepSeekOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7492
+ static {
7493
+ __name(this, "DeepSeekOpenAICompatibleProvider");
7494
+ }
7495
+ constructor(contentGeneratorConfig, cliConfig) {
7496
+ super(contentGeneratorConfig, cliConfig);
7497
+ }
7498
+ /**
7499
+ * Backward-compatible static delegates for the free `isDeepSeek*`
7500
+ * helpers. New call sites should import the free functions directly to
7501
+ * avoid coupling to this class.
7502
+ */
7503
+ static isDeepSeekProvider = isDeepSeekProvider;
7504
+ static isDeepSeekHostname = isDeepSeekHostname;
7505
+ /**
7506
+ * DeepSeek's API requires message content to be a plain string, not an
7507
+ * array of content parts. Flatten any text-part arrays into joined
7508
+ * strings; non-text parts (image_url, audio, …) are replaced with a
7509
+ * `[Unsupported content type: <type>]` placeholder so the request still
7510
+ * goes through with a textual breadcrumb rather than silently dropping
7511
+ * the part or raising mid-conversation. Also translate the standard
7512
+ * `reasoning.effort` config into DeepSeek's flat `reasoning_effort`
7513
+ * body parameter — but only on actual DeepSeek hostnames, since the
7514
+ * model-name fallback above can match self-hosted/strict OpenAI-compat
7515
+ * backends that don't accept the DeepSeek extension.
7516
+ */
7517
+ buildRequest(request, userPromptId) {
7518
+ const baseRequest = super.buildRequest(request, userPromptId);
7519
+ const reshaped = isDeepSeekHostname(this.contentGeneratorConfig) ? translateReasoningEffort(baseRequest) : baseRequest;
7520
+ if (!reshaped.messages?.length) {
7521
+ return reshaped;
7522
+ }
7523
+ const messages = reshaped.messages.map((message) => {
7524
+ const flattened = flattenContentParts(message);
7525
+ return ensureReasoningContentOnAssistantMessage(flattened);
7526
+ });
7527
+ return {
7528
+ ...reshaped,
7529
+ messages
7530
+ };
7531
+ }
7532
+ getDefaultGenerationConfig() {
7533
+ return {
7534
+ temperature: 0
7535
+ };
7536
+ }
7537
+ };
7538
+ function flattenContentParts(message) {
7539
+ if (!("content" in message)) {
7540
+ return message;
7541
+ }
7542
+ const { content } = message;
7543
+ if (typeof content === "string" || content === null || content === void 0) {
7544
+ return message;
7545
+ }
7546
+ if (!Array.isArray(content)) {
7547
+ return message;
7548
+ }
7549
+ const text = content.map((part) => {
7550
+ if (typeof part === "string") {
7551
+ return part;
7552
+ }
7553
+ if (part.type === "text") {
7554
+ return part.text ?? "";
7555
+ }
7556
+ return `[Unsupported content type: ${part.type}]`;
7557
+ }).join("\n\n");
7558
+ return {
7559
+ ...message,
7560
+ content: text
7561
+ };
7562
+ }
7563
+ __name(flattenContentParts, "flattenContentParts");
7564
+ function translateReasoningEffort(request) {
7565
+ const r = request;
7566
+ const nested = r["reasoning"];
7567
+ const nestedEffort = nested?.effort;
7568
+ if (typeof nestedEffort !== "string" || !nestedEffort) {
7569
+ return request;
7570
+ }
7571
+ const next = { ...r };
7572
+ if (typeof next["reasoning_effort"] !== "string" || !next["reasoning_effort"]) {
7573
+ let normalized = nestedEffort;
7574
+ if (normalized === "low" || normalized === "medium") normalized = "high";
7575
+ else if (normalized === "xhigh") normalized = "max";
7576
+ next["reasoning_effort"] = normalized;
7577
+ }
7578
+ if (nested && Object.keys(nested).length === 1) {
7579
+ delete next["reasoning"];
7580
+ } else if (nested) {
7581
+ const { effort: _drop, ...rest } = nested;
7582
+ next["reasoning"] = rest;
7583
+ }
7584
+ return next;
7585
+ }
7586
+ __name(translateReasoningEffort, "translateReasoningEffort");
7587
+
7588
+ // packages/core/src/core/openaiContentGenerator/provider/zai.ts
7589
+ init_esbuild_shims();
7590
+ var debugLogger2 = createDebugLogger("ZAI");
7591
+ function isZaiHostname(contentGeneratorConfig) {
7592
+ const baseUrl = contentGeneratorConfig.baseUrl;
7593
+ if (!baseUrl) {
7594
+ return false;
7595
+ }
7596
+ try {
7597
+ const hostname = new URL(baseUrl).hostname.toLowerCase();
7598
+ return hostname === "z.ai" || hostname.endsWith(".z.ai") || hostname === "bigmodel.cn" || hostname.endsWith(".bigmodel.cn");
7599
+ } catch {
7600
+ return false;
7601
+ }
7602
+ }
7603
+ __name(isZaiHostname, "isZaiHostname");
7604
+ function isZaiProvider(contentGeneratorConfig) {
7605
+ if (isZaiHostname(contentGeneratorConfig)) {
7606
+ return true;
7607
+ }
7608
+ const model = contentGeneratorConfig.model ?? "";
7609
+ return model.toLowerCase().startsWith("glm-");
7610
+ }
7611
+ __name(isZaiProvider, "isZaiProvider");
7612
+ var ZaiOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7613
+ static {
7614
+ __name(this, "ZaiOpenAICompatibleProvider");
7615
+ }
7616
+ static isZaiProvider = isZaiProvider;
7617
+ static isZaiHostname = isZaiHostname;
7618
+ // Latch so the skipped-flatten warning fires once per provider lifetime.
7619
+ nonZaiHostnameFlattenWarned = false;
7620
+ buildRequest(request, userPromptId) {
7621
+ const baseRequest = super.buildRequest(request, userPromptId);
7622
+ if (isZaiHostname(this.contentGeneratorConfig)) {
7623
+ return flattenReasoningEffort(baseRequest);
7624
+ }
7625
+ const reasoning = baseRequest["reasoning"];
7626
+ if (reasoning?.effort && !baseRequest["reasoning_effort"] && !this.nonZaiHostnameFlattenWarned) {
7627
+ debugLogger2.warn(
7628
+ `GLM model '${this.contentGeneratorConfig.model ?? "unknown"}' on a non-Z.ai hostname; leaving nested reasoning.effort='${String(
7629
+ reasoning.effort
7630
+ )}' unflattened (reasoning_effort reshape is hostname-gated).`
7631
+ );
7632
+ this.nonZaiHostnameFlattenWarned = true;
7633
+ }
7634
+ return baseRequest;
7635
+ }
7636
+ };
7637
+ function flattenReasoningEffort(request) {
7638
+ const r = request;
7639
+ const nested = r["reasoning"];
7640
+ const effort = nested?.effort;
7641
+ if (typeof effort !== "string" || !effort) {
7642
+ return request;
7643
+ }
7644
+ const next = { ...r };
7645
+ if (typeof next["reasoning_effort"] !== "string" || !next["reasoning_effort"]) {
7646
+ next["reasoning_effort"] = effort;
7647
+ }
7648
+ if (nested && Object.keys(nested).length === 1) {
7649
+ delete next["reasoning"];
7650
+ } else if (nested) {
7651
+ const { effort: _drop, ...rest } = nested;
7652
+ next["reasoning"] = rest;
7653
+ }
7654
+ return next;
7655
+ }
7656
+ __name(flattenReasoningEffort, "flattenReasoningEffort");
7657
+
7658
+ // packages/core/src/core/openaiContentGenerator/provider/minimax.ts
7659
+ init_esbuild_shims();
7660
+ var MINIMAX_KNOWN_HOSTS = ["api.minimaxi.com", "api.minimax.io"];
7661
+ var MINIMAX_HOST_SUFFIXES = [".minimaxi.com", ".minimax.io"];
7662
+ var MiniMaxOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7663
+ static {
7664
+ __name(this, "MiniMaxOpenAICompatibleProvider");
7665
+ }
7666
+ static isMiniMaxProvider(config) {
7667
+ if (!config.baseUrl) return false;
7668
+ try {
7669
+ const hostname = new URL(config.baseUrl).hostname.toLowerCase();
7670
+ if (MINIMAX_KNOWN_HOSTS.includes(hostname)) {
7671
+ return true;
7672
+ }
7673
+ return MINIMAX_HOST_SUFFIXES.some((suffix) => hostname.endsWith(suffix));
7674
+ } catch {
7675
+ return false;
7676
+ }
7677
+ }
7678
+ getResponseParsingOptions() {
7679
+ return { taggedThinkingTags: true };
7680
+ }
7681
+ };
7682
+
7683
+ // packages/core/src/core/openaiContentGenerator/provider/mistral.ts
7684
+ init_esbuild_shims();
7685
+ var MISTRAL_API_HOST = "api.mistral.ai";
7686
+ var MISTRAL_MODEL_MARKERS = [
7687
+ "mistral",
7688
+ "mixtral",
7689
+ "codestral",
7690
+ "ministral",
7691
+ "pixtral",
7692
+ "magistral",
7693
+ "devstral"
7694
+ ];
7695
+ function isMistralHostname(config) {
7696
+ const baseUrl = config.baseUrl ?? "";
7697
+ if (!baseUrl) return false;
7698
+ try {
7699
+ const hostname = new URL(baseUrl).hostname.toLowerCase();
7700
+ return hostname === MISTRAL_API_HOST || hostname.endsWith(`.${MISTRAL_API_HOST}`);
7701
+ } catch {
7702
+ return false;
7703
+ }
7704
+ }
7705
+ __name(isMistralHostname, "isMistralHostname");
7706
+ function isMistralProvider(config) {
7707
+ if (isMistralHostname(config)) return true;
7708
+ const model = config.model?.toLowerCase() ?? "";
7709
+ return MISTRAL_MODEL_MARKERS.some((marker) => model.includes(marker));
7710
+ }
7711
+ __name(isMistralProvider, "isMistralProvider");
7712
+ var MistralOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7713
+ static {
7714
+ __name(this, "MistralOpenAICompatibleProvider");
7715
+ }
7716
+ static isMistralProvider = isMistralProvider;
7717
+ buildRequest(request, userPromptId) {
7718
+ const baseRequest = super.buildRequest(request, userPromptId);
7719
+ return {
7720
+ ...baseRequest,
7721
+ messages: baseRequest.messages.map(stripReasoningContent)
7722
+ };
7723
+ }
7724
+ };
7725
+ function stripReasoningContent(message) {
7726
+ if (!("reasoning_content" in message)) {
7727
+ return message;
7728
+ }
7729
+ const next = { ...message };
7730
+ delete next["reasoning_content"];
7731
+ return next;
7732
+ }
7733
+ __name(stripReasoningContent, "stripReasoningContent");
7734
+
7735
+ // packages/core/src/core/openaiContentGenerator/provider/mimo.ts
7736
+ init_esbuild_shims();
7737
+ function isMiMoProvider(contentGeneratorConfig) {
7738
+ const baseUrl = contentGeneratorConfig.baseUrl ?? "";
7739
+ if (baseUrl) {
7740
+ try {
7741
+ const hostname = new URL(baseUrl).hostname.toLowerCase();
7742
+ if (hostname === "xiaomimimo.com" || hostname.endsWith(".xiaomimimo.com")) {
7743
+ return true;
7744
+ }
7745
+ } catch {
7746
+ }
7747
+ }
7748
+ const model = contentGeneratorConfig.model ?? "";
7749
+ return model.toLowerCase().startsWith("mimo-");
7750
+ }
7751
+ __name(isMiMoProvider, "isMiMoProvider");
7752
+ var MiMoOpenAICompatibleProvider = class extends DefaultOpenAICompatibleProvider {
7753
+ static {
7754
+ __name(this, "MiMoOpenAICompatibleProvider");
7755
+ }
7756
+ constructor(contentGeneratorConfig, cliConfig) {
7757
+ super(contentGeneratorConfig, cliConfig);
7758
+ }
7759
+ static isMiMoProvider = isMiMoProvider;
7760
+ buildRequest(request, userPromptId) {
7761
+ const baseRequest = super.buildRequest(request, userPromptId);
7762
+ if (!baseRequest.messages?.length) {
7763
+ return baseRequest;
7764
+ }
7765
+ return {
7766
+ ...baseRequest,
7767
+ messages: baseRequest.messages.map(
7768
+ ensureReasoningContentOnAssistantMessage
7769
+ )
7770
+ };
7771
+ }
7772
+ getRequestContextOverrides() {
7773
+ return {
7774
+ splitToolMedia: this.contentGeneratorConfig.splitToolMedia ?? true
7775
+ };
7776
+ }
7777
+ };
7778
+
7779
+ // packages/core/src/core/openaiContentGenerator/pipeline.ts
7780
+ init_esbuild_shims();
7781
+
7782
+ // packages/core/src/core/openaiContentGenerator/streamingToolCallParser.ts
7783
+ init_esbuild_shims();
7784
+ var debugLogger3 = createDebugLogger("STREAMING_TOOL_CALL_PARSER");
7785
+ var StreamingToolCallParser = class {
7786
+ static {
7787
+ __name(this, "StreamingToolCallParser");
7788
+ }
7789
+ /** Accumulated buffer containing all received chunks for each tool call index */
7790
+ buffers = /* @__PURE__ */ new Map();
7791
+ /** Current nesting depth in JSON structure for each tool call index */
7792
+ depths = /* @__PURE__ */ new Map();
7793
+ /** Whether we're currently inside a string literal for each tool call index */
7794
+ inStrings = /* @__PURE__ */ new Map();
7795
+ /** Whether the next character should be treated as escaped for each tool call index */
7796
+ escapes = /* @__PURE__ */ new Map();
7797
+ /** Metadata for each tool call index */
7798
+ toolCallMeta = /* @__PURE__ */ new Map();
7799
+ namelessToolCallIndices = /* @__PURE__ */ new Set();
7800
+ /** Map from tool call ID to actual index used for storage */
7801
+ idToIndexMap = /* @__PURE__ */ new Map();
7802
+ /** Remapped slots awaiting a stable ID from a later chunk. */
7803
+ pendingIndexRemaps = /* @__PURE__ */ new Map();
7804
+ /** Counter for generating new indices when collisions occur */
7805
+ nextAvailableIndex = 0;
7806
+ conflictingToolCallIdentity = false;
7807
+ invalidToolCallIndex = false;
7808
+ /**
7809
+ * Processes a new chunk of tool call data and attempts to parse complete JSON objects
7810
+ *
7811
+ * Handles the core problems of streaming tool call parsing:
7812
+ * - Resolves index collisions when the same index is reused for different tool calls
7813
+ * - Routes chunks without IDs to the correct incomplete tool call
7814
+ * - Tracks JSON parsing state (depth, string boundaries, escapes) per tool call
7815
+ * - Attempts parsing only when JSON structure is complete (depth = 0)
7816
+ * - Repairs common issues like unclosed strings
7817
+ *
7818
+ * @param index - Tool call index from streaming response (may collide with existing calls)
7819
+ * @param chunk - String chunk that may be empty, partial JSON, or complete data
7820
+ * @param id - Optional tool call ID for collision detection and chunk routing
7821
+ * @param name - Optional function name stored as metadata
7822
+ * @returns ToolCallParseResult with completion status, parsed value, and repair info
7823
+ */
7824
+ addChunk(index, chunk, id, name) {
7825
+ const validName = name?.trim() || void 0;
7826
+ if (!Number.isSafeInteger(index) || index < 0) {
7827
+ this.conflictingToolCallIdentity = true;
7828
+ this.invalidToolCallIndex = true;
7829
+ return {
7830
+ complete: false,
7831
+ error: new Error(`Invalid tool call index: ${index}`)
7832
+ };
7833
+ }
7834
+ if (!id && !validName && !chunk.trim()) {
7835
+ const depth2 = this.depths.get(index) ?? 0;
7836
+ const inString2 = this.inStrings.get(index) ?? false;
7837
+ if (!this.buffers.has(index) || depth2 === 0 && !inString2) {
7838
+ return { complete: false };
7839
+ }
7840
+ }
7841
+ let actualIndex = index;
7842
+ const isKnownId = Boolean(id && this.idToIndexMap.has(id));
7843
+ const existingName = this.toolCallMeta.get(index)?.name;
7844
+ const isNameOnlyDelta = Boolean(
7845
+ validName && chunk.length === 0 && (!existingName || existingName === validName)
7846
+ );
7847
+ if (id) {
7848
+ if (this.idToIndexMap.has(id)) {
7849
+ actualIndex = this.idToIndexMap.get(id);
7850
+ } else if (this.pendingIndexRemaps.has(index)) {
7851
+ actualIndex = this.pendingIndexRemaps.get(index);
7852
+ this.pendingIndexRemaps.delete(index);
7853
+ this.idToIndexMap.set(id, actualIndex);
7854
+ } else {
7855
+ if (this.buffers.has(index)) {
7856
+ const existingBuffer = this.buffers.get(index);
7857
+ const existingDepth = this.depths.get(index);
7858
+ const existingMeta = this.toolCallMeta.get(index);
7859
+ if (existingMeta?.id && existingMeta.id !== id) {
7860
+ let existingComplete = existingDepth === 0;
7861
+ if (existingComplete && existingBuffer.trim()) {
7862
+ try {
7863
+ JSON.parse(existingBuffer);
7864
+ } catch {
7865
+ existingComplete = false;
7866
+ }
7867
+ }
7868
+ if (existingComplete) {
7869
+ actualIndex = 0;
7870
+ while (this.buffers.has(actualIndex)) actualIndex += 1;
7871
+ if (!existingMeta.name) {
7872
+ this.conflictingToolCallIdentity = true;
7873
+ }
7874
+ } else {
7875
+ this.conflictingToolCallIdentity = true;
7876
+ }
7877
+ }
7878
+ }
7879
+ this.idToIndexMap.set(id, actualIndex);
7880
+ }
7881
+ } else if (!isNameOnlyDelta) {
7882
+ if (this.pendingIndexRemaps.has(index)) {
7883
+ actualIndex = this.pendingIndexRemaps.get(index);
7884
+ const existingBuffer = this.buffers.get(actualIndex);
7885
+ const existingDepth = this.depths.get(actualIndex);
7886
+ if (existingDepth === 0 && existingBuffer.trim()) {
7887
+ try {
7888
+ JSON.parse(existingBuffer);
7889
+ actualIndex = this.findMostRecentIncompleteIndex();
7890
+ } catch {
7891
+ }
7892
+ }
7893
+ } else if (this.buffers.has(index)) {
7894
+ const existingBuffer = this.buffers.get(index);
7895
+ const existingDepth = this.depths.get(index);
7896
+ if (existingDepth > 0 || !existingBuffer.trim()) {
7897
+ actualIndex = index;
7898
+ } else {
7899
+ try {
7900
+ JSON.parse(existingBuffer);
7901
+ actualIndex = this.findMostRecentIncompleteIndex();
7902
+ } catch {
7903
+ actualIndex = index;
7904
+ }
7905
+ }
7906
+ }
7907
+ }
7908
+ if (!this.buffers.has(actualIndex)) {
7909
+ this.buffers.set(actualIndex, "");
7910
+ this.depths.set(actualIndex, 0);
7911
+ this.inStrings.set(actualIndex, false);
7912
+ this.escapes.set(actualIndex, false);
7913
+ this.toolCallMeta.set(actualIndex, {});
7914
+ }
7915
+ const currentBuffer = this.buffers.get(actualIndex);
7916
+ const currentDepth = this.depths.get(actualIndex);
7917
+ const meta = this.toolCallMeta.get(actualIndex);
7918
+ if (chunk.length === 0 && (id || validName)) {
7919
+ if (id) meta.id = id;
7920
+ if (validName && !meta.name) meta.name = validName;
7921
+ if (!meta.name && meta.id) {
7922
+ this.namelessToolCallIndices.add(actualIndex);
7923
+ } else {
7924
+ this.namelessToolCallIndices.delete(actualIndex);
7925
+ }
7926
+ if (!meta.id && actualIndex !== index) {
7927
+ this.pendingIndexRemaps.set(index, actualIndex);
7928
+ }
7929
+ return { actualIndex, complete: false };
7930
+ }
7931
+ if (isKnownId && currentDepth === 0) {
7932
+ if (currentBuffer.trim()) {
7933
+ try {
7934
+ JSON.parse(currentBuffer);
7935
+ debugLogger3.debug(
7936
+ `Ignoring replay chunk for completed toolCall id=${id}`
7937
+ );
7938
+ return { actualIndex, complete: false };
7939
+ } catch {
7940
+ }
7941
+ }
7942
+ }
7943
+ const identityChanged = Boolean(id && meta.id && meta.id !== id);
7944
+ if (id) meta.id = id;
7945
+ if (validName) {
7946
+ if (!identityChanged && meta.name && meta.name !== validName) {
7947
+ this.conflictingToolCallIdentity = true;
7948
+ } else {
7949
+ meta.name = validName;
7950
+ }
7951
+ }
7952
+ if (!meta.id && actualIndex !== index) {
7953
+ this.pendingIndexRemaps.set(index, actualIndex);
7954
+ }
7955
+ const currentInString = this.inStrings.get(actualIndex);
7956
+ const currentEscape = this.escapes.get(actualIndex);
7957
+ const newBuffer = currentBuffer + chunk;
7958
+ this.buffers.set(actualIndex, newBuffer);
7959
+ if (!meta.name && (meta.id || /\S/.test(newBuffer))) {
7960
+ this.namelessToolCallIndices.add(actualIndex);
7961
+ } else {
7962
+ this.namelessToolCallIndices.delete(actualIndex);
7963
+ }
7964
+ let depth = currentDepth;
7965
+ let inString = currentInString;
7966
+ let escape2 = currentEscape;
7967
+ for (const char of chunk) {
7968
+ if (!inString) {
7969
+ if (char === "{" || char === "[") depth++;
7970
+ else if (char === "}" || char === "]") depth--;
7971
+ }
7972
+ if (char === '"' && !escape2) {
7973
+ inString = !inString;
7974
+ }
7975
+ escape2 = char === "\\" && !escape2;
7976
+ }
7977
+ this.depths.set(actualIndex, depth);
7978
+ this.inStrings.set(actualIndex, inString);
7979
+ this.escapes.set(actualIndex, escape2);
7980
+ if (depth === 0 && newBuffer.trim().length > 0) {
7981
+ try {
7982
+ const parsed = JSON.parse(newBuffer);
7983
+ return { actualIndex, complete: true, value: parsed };
7984
+ } catch (e) {
7985
+ if (inString) {
7986
+ try {
7987
+ const repaired = JSON.parse(newBuffer + '"');
7988
+ return {
7989
+ actualIndex,
7990
+ complete: true,
7991
+ value: repaired,
7992
+ repaired: true
7993
+ };
7994
+ } catch {
7995
+ }
7996
+ }
7997
+ return {
7998
+ actualIndex,
7999
+ complete: false,
8000
+ error: e instanceof Error ? e : new Error(String(e))
8001
+ };
8002
+ }
8003
+ }
8004
+ return { actualIndex, complete: false };
8005
+ }
8006
+ /**
8007
+ * Gets the current tool call metadata for a specific index
8008
+ *
8009
+ * @param index - The tool call index
8010
+ * @returns Object containing id and name if available
8011
+ */
8012
+ getToolCallMeta(index) {
8013
+ return this.toolCallMeta.get(index) || {};
8014
+ }
8015
+ hasNamelessToolCall() {
8016
+ return this.namelessToolCallIndices.size > 0;
8017
+ }
8018
+ hasConflictingToolCallIdentity() {
8019
+ return this.conflictingToolCallIdentity;
8020
+ }
8021
+ hasInvalidToolCallIndex() {
8022
+ return this.invalidToolCallIndex;
8023
+ }
8024
+ hasInvalidToolCallArguments() {
8025
+ for (const [index, buffer] of this.buffers.entries()) {
8026
+ if (!this.toolCallMeta.get(index)?.name || buffer.length === 0) continue;
8027
+ try {
8028
+ const args = JSON.parse(buffer);
8029
+ if (typeof args !== "object" || args === null || Array.isArray(args)) {
8030
+ return true;
8031
+ }
8032
+ } catch {
8033
+ return true;
8034
+ }
8035
+ }
8036
+ return false;
8037
+ }
8038
+ /**
8039
+ * Gets all completed tool calls that are ready to be emitted
8040
+ *
8041
+ * Attempts to parse accumulated buffers using multiple strategies:
8042
+ * 1. Standard JSON.parse()
8043
+ * 2. Auto-close unclosed strings and retry
8044
+ * 3. Fallback to safeJsonParse for malformed data
8045
+ *
8046
+ * Only returns tool calls with name metadata. An empty buffer yields
8047
+ * empty arguments ({}), matching the non-streaming path for no-argument
8048
+ * tools. Should be called when streaming is complete (finish_reason is
8049
+ * present).
8050
+ *
8051
+ * @returns Array of completed tool calls with their metadata and parsed arguments
8052
+ */
8053
+ getCompletedToolCalls() {
8054
+ const completed = [];
8055
+ const emittedIds = /* @__PURE__ */ new Set();
8056
+ for (const [index, buffer] of this.buffers.entries()) {
8057
+ const meta = this.toolCallMeta.get(index);
8058
+ if (meta?.name) {
8059
+ if (meta.id) {
8060
+ if (emittedIds.has(meta.id)) {
8061
+ continue;
8062
+ }
8063
+ emittedIds.add(meta.id);
8064
+ }
8065
+ let args = {};
8066
+ if (buffer.trim()) {
8067
+ try {
8068
+ args = JSON.parse(buffer);
8069
+ } catch {
8070
+ const inString = this.inStrings.get(index);
8071
+ if (inString) {
8072
+ try {
8073
+ args = JSON.parse(buffer + '"');
8074
+ } catch {
8075
+ args = safeJsonParse(buffer, {});
8076
+ }
8077
+ } else {
8078
+ args = safeJsonParse(buffer, {});
8079
+ }
8080
+ }
8081
+ if (typeof args !== "object" || args === null || Array.isArray(args)) {
8082
+ debugLogger3.debug(
8083
+ `Collapsing non-object arguments for tool call ${meta.name} (id=${meta.id}) at index ${index}; buffer likely polluted by a misrouted fragment`
8084
+ );
8085
+ args = {};
8086
+ }
8087
+ } else {
8088
+ debugLogger3.debug(
8089
+ `Emitting no-argument tool call ${meta.name} (id=${meta.id}) at index ${index} with empty buffer`
8090
+ );
8091
+ }
8092
+ completed.push({
8093
+ id: meta.id,
8094
+ name: meta.name,
8095
+ args,
8096
+ index
8097
+ });
8098
+ }
8099
+ }
8100
+ return completed;
8101
+ }
8102
+ /**
8103
+ * Finds the next available index for a new tool call
8104
+ *
8105
+ * Scans indices starting from nextAvailableIndex to find one that's safe to use.
8106
+ * Reuses indices never claimed by a named tool call or with incomplete
8107
+ * parsing states. Skips indices with complete tool call data — including
8108
+ * no-argument calls with empty buffers — to prevent overwriting.
8109
+ *
8110
+ * @returns The next available index safe for storing a new tool call
8111
+ */
8112
+ findNextAvailableIndex() {
8113
+ while (this.buffers.has(this.nextAvailableIndex)) {
8114
+ const buffer = this.buffers.get(this.nextAvailableIndex);
8115
+ const depth = this.depths.get(this.nextAvailableIndex);
8116
+ const meta = this.toolCallMeta.get(this.nextAvailableIndex);
8117
+ if (!meta?.name || depth > 0 || !meta?.id) {
8118
+ return this.nextAvailableIndex;
8119
+ }
8120
+ if (buffer.trim()) {
8121
+ try {
8122
+ JSON.parse(buffer);
8123
+ } catch {
8124
+ return this.nextAvailableIndex;
8125
+ }
8126
+ }
8127
+ this.nextAvailableIndex++;
8128
+ }
8129
+ return this.nextAvailableIndex++;
8130
+ }
8131
+ /**
8132
+ * Finds the most recent incomplete tool call index
8133
+ *
8134
+ * Used when continuation chunks arrive without IDs. Scans existing tool calls
8135
+ * to find the highest index with incomplete parsing state (depth > 0, empty
8136
+ * buffer with no name metadata yet, or unparseable JSON). Falls back to
8137
+ * creating a new index if none found.
8138
+ *
8139
+ * @returns The index of the most recent incomplete tool call, or a new available index
8140
+ */
8141
+ findMostRecentIncompleteIndex() {
8142
+ let maxIndex = -1;
8143
+ for (const [index, buffer] of this.buffers.entries()) {
8144
+ const depth = this.depths.get(index);
8145
+ const meta = this.toolCallMeta.get(index);
8146
+ if (meta?.id && (depth > 0 || !buffer.trim() && !meta?.name)) {
8147
+ maxIndex = Math.max(maxIndex, index);
8148
+ } else if (buffer.trim()) {
8149
+ try {
8150
+ JSON.parse(buffer);
8151
+ } catch {
8152
+ maxIndex = Math.max(maxIndex, index);
8153
+ }
8154
+ }
8155
+ }
8156
+ return maxIndex >= 0 ? maxIndex : this.findNextAvailableIndex();
8157
+ }
8158
+ /**
8159
+ * Resets the parser state for a specific tool call index
8160
+ *
8161
+ * @param index - The tool call index to reset
8162
+ */
8163
+ resetIndex(index) {
8164
+ this.buffers.set(index, "");
8165
+ this.depths.set(index, 0);
8166
+ this.inStrings.set(index, false);
8167
+ this.escapes.set(index, false);
8168
+ this.toolCallMeta.set(index, {});
8169
+ this.namelessToolCallIndices.delete(index);
8170
+ for (const [providerIndex, actualIndex] of this.pendingIndexRemaps) {
8171
+ if (providerIndex === index || actualIndex === index) {
8172
+ this.pendingIndexRemaps.delete(providerIndex);
8173
+ }
8174
+ }
8175
+ }
8176
+ /**
8177
+ * Resets the entire parser state for processing a new stream
8178
+ *
8179
+ * Clears all accumulated buffers, parsing states, metadata, and counters.
8180
+ * Allows the parser to be reused for multiple independent streams without
8181
+ * data leakage between sessions.
8182
+ */
8183
+ reset() {
8184
+ this.buffers.clear();
8185
+ this.depths.clear();
8186
+ this.inStrings.clear();
8187
+ this.escapes.clear();
8188
+ this.toolCallMeta.clear();
8189
+ this.namelessToolCallIndices.clear();
8190
+ this.idToIndexMap.clear();
8191
+ this.pendingIndexRemaps.clear();
8192
+ this.nextAvailableIndex = 0;
8193
+ this.conflictingToolCallIdentity = false;
8194
+ this.invalidToolCallIndex = false;
8195
+ }
8196
+ /**
8197
+ * Gets the current accumulated buffer content for a specific index
8198
+ *
8199
+ * @param index - The tool call index to retrieve buffer for
8200
+ * @returns The current buffer content for the specified index (empty string if not found)
8201
+ */
8202
+ getBuffer(index) {
8203
+ return this.buffers.get(index) || "";
8204
+ }
8205
+ /**
8206
+ * Gets the current parsing state information for a specific index
8207
+ *
8208
+ * @param index - The tool call index to get state information for
8209
+ * @returns Object containing current parsing state (depth, inString, escape)
8210
+ */
8211
+ getState(index) {
8212
+ return {
8213
+ depth: this.depths.get(index) || 0,
8214
+ inString: this.inStrings.get(index) || false,
8215
+ escape: this.escapes.get(index) || false
8216
+ };
8217
+ }
8218
+ /**
8219
+ * Checks whether any buffered tool call has incomplete JSON at stream end.
8220
+ *
8221
+ * A tool call is considered incomplete when its JSON parsing state indicates
8222
+ * the buffer was truncated mid-stream:
8223
+ * - depth > 0: unclosed braces/brackets remain
8224
+ * - inString === true: still inside a string literal
8225
+ *
8226
+ * This is critical for detecting output truncation that the LLM provider
8227
+ * may not report correctly via finish_reason (e.g. reporting "stop" or
8228
+ * "tool_calls" instead of "length" when output was actually cut off).
8229
+ *
8230
+ * @returns true if at least one tool call buffer has incomplete JSON
8231
+ */
8232
+ hasIncompleteToolCalls() {
8233
+ for (const [index] of this.buffers.entries()) {
8234
+ const meta = this.toolCallMeta.get(index);
8235
+ if (!meta?.name) continue;
8236
+ const depth = this.depths.get(index) || 0;
8237
+ const inString = this.inStrings.get(index) || false;
8238
+ if (depth > 0 || inString) {
8239
+ return true;
8240
+ }
8241
+ }
8242
+ return false;
8243
+ }
8244
+ };
8245
+
8246
+ // packages/core/src/core/openaiContentGenerator/pipeline.ts
8247
+ var debugLogger4 = createDebugLogger("OPENAI_PIPELINE");
8248
+ var StreamContentError = class extends Error {
8249
+ static {
8250
+ __name(this, "StreamContentError");
8251
+ }
8252
+ constructor(message) {
8253
+ super(message);
8254
+ this.name = "StreamContentError";
8255
+ }
8256
+ };
8257
+ var StreamInactivityTimeoutError = class extends Error {
8258
+ constructor(idleMs, chunksReceived, streamLifetimeMs) {
8259
+ super(
8260
+ `No stream activity for ${idleMs}ms after ${chunksReceived} chunks (stream lifetime: ${streamLifetimeMs}ms). Set ${QWEN_STREAM_IDLE_TIMEOUT_MS_ENV} to increase this window (or 0 to disable it).`
8261
+ );
8262
+ this.idleMs = idleMs;
8263
+ this.chunksReceived = chunksReceived;
8264
+ this.streamLifetimeMs = streamLifetimeMs;
8265
+ this.name = "StreamInactivityTimeoutError";
8266
+ }
8267
+ static {
8268
+ __name(this, "StreamInactivityTimeoutError");
8269
+ }
8270
+ code = "ETIMEDOUT";
8271
+ };
8272
+ var NON_SSE_BODY_PREFIX_LIMIT = 512;
8273
+ function isSSECompatibleContentType(contentType) {
8274
+ if (!contentType) return true;
8275
+ const mediaType = (contentType.split(";")[0] ?? "").trim().toLowerCase();
8276
+ return mediaType === "text/event-stream" || mediaType === "application/x-ndjson" || mediaType === "application/stream+json";
8277
+ }
8278
+ __name(isSSECompatibleContentType, "isSSECompatibleContentType");
8279
+ var NonSSEResponseError = class extends Error {
8280
+ constructor(contentType, httpStatus, bodyPrefix, requestId) {
8281
+ const preview = bodyPrefix.length > 0 ? ` Body prefix: ${bodyPrefix}` : "";
8282
+ super(
8283
+ `Streaming request received a non-SSE response (HTTP ${httpStatus}, Content-Type: ${contentType || "unknown"}).${preview}`
8284
+ );
8285
+ this.contentType = contentType;
8286
+ this.httpStatus = httpStatus;
8287
+ this.bodyPrefix = bodyPrefix;
8288
+ this.requestId = requestId;
8289
+ this.name = "NonSSEResponseError";
8290
+ this.status = httpStatus;
8291
+ this.request_id = requestId;
8292
+ }
8293
+ static {
8294
+ __name(this, "NonSSEResponseError");
8295
+ }
8296
+ status;
8297
+ request_id;
8298
+ };
8299
+ var PROVIDER_OUTPUT_BUDGET_KEYS = ["max_completion_tokens", "max_new_tokens"];
8300
+ function hasProviderOutputBudgetKey(samplingParams) {
8301
+ return PROVIDER_OUTPUT_BUDGET_KEYS.some(
8302
+ (key) => samplingParams[key] !== void 0
8303
+ );
8304
+ }
8305
+ __name(hasProviderOutputBudgetKey, "hasProviderOutputBudgetKey");
8306
+ function clampProviderOutputBudgetKeys(samplingParams, requestMaxTokens) {
8307
+ if (typeof requestMaxTokens !== "number") return samplingParams;
8308
+ for (const key of PROVIDER_OUTPUT_BUDGET_KEYS) {
8309
+ const value = samplingParams[key];
8310
+ if (typeof value === "number" && value > requestMaxTokens) {
8311
+ samplingParams[key] = requestMaxTokens;
8312
+ }
8313
+ }
8314
+ return samplingParams;
8315
+ }
8316
+ __name(clampProviderOutputBudgetKeys, "clampProviderOutputBudgetKeys");
8317
+ function resolveStreamIdleTimeoutMs(config) {
8318
+ const fromConfig = config.streamIdleTimeoutMs;
8319
+ if (typeof fromConfig === "number") {
8320
+ if (Number.isInteger(fromConfig) && fromConfig <= MAX_STREAM_IDLE_TIMEOUT_MS) {
8321
+ return fromConfig;
8322
+ }
8323
+ console.warn(
8324
+ `[qwen-code] Ignoring out-of-range streamIdleTimeoutMs=${fromConfig} (expected an integer in (-\u221E, ${MAX_STREAM_IDLE_TIMEOUT_MS}]); falling back to ${QWEN_STREAM_IDLE_TIMEOUT_MS_ENV}/default.`
8325
+ );
8326
+ }
8327
+ const raw = process.env[QWEN_STREAM_IDLE_TIMEOUT_MS_ENV];
8328
+ const trimmed = raw?.trim();
8329
+ if (trimmed) {
8330
+ if (/^\d+$/.test(trimmed)) {
8331
+ const parsed = Number(trimmed);
8332
+ if (parsed <= MAX_STREAM_IDLE_TIMEOUT_MS) {
8333
+ return parsed;
8334
+ }
8335
+ }
8336
+ console.warn(
8337
+ `[qwen-code] Ignoring invalid ${QWEN_STREAM_IDLE_TIMEOUT_MS_ENV}="${raw}" (expected an integer of milliseconds in [0, ${MAX_STREAM_IDLE_TIMEOUT_MS}]); using default ${DEFAULT_STREAM_IDLE_TIMEOUT_MS}ms.`
8338
+ );
8339
+ }
8340
+ return DEFAULT_STREAM_IDLE_TIMEOUT_MS;
8341
+ }
8342
+ __name(resolveStreamIdleTimeoutMs, "resolveStreamIdleTimeoutMs");
8343
+ async function* withStreamInactivityTimeout(source, idleMs, abortRequest, parentSignal) {
8344
+ const it = source[Symbol.asyncIterator]();
8345
+ const streamStartedAt = Date.now();
8346
+ let chunksReceived = 0;
8347
+ try {
8348
+ while (true) {
8349
+ const nextPromise = it.next();
8350
+ let timer;
8351
+ const timeout = new Promise((_resolve, reject) => {
8352
+ timer = setTimeout(() => {
8353
+ if (parentSignal?.aborted) {
8354
+ const abortErr = new Error("Aborted");
8355
+ abortErr.name = "AbortError";
8356
+ reject(abortErr);
8357
+ } else {
8358
+ abortRequest();
8359
+ reject(
8360
+ new StreamInactivityTimeoutError(
8361
+ idleMs,
8362
+ chunksReceived,
8363
+ Date.now() - streamStartedAt
8364
+ )
8365
+ );
8366
+ }
8367
+ }, idleMs);
8368
+ timer.unref?.();
8369
+ });
8370
+ let result;
8371
+ try {
8372
+ result = await Promise.race([nextPromise, timeout]);
8373
+ } catch (err) {
8374
+ void Promise.resolve(nextPromise).catch(() => {
8375
+ });
8376
+ throw err;
8377
+ } finally {
8378
+ if (timer !== void 0) clearTimeout(timer);
8379
+ }
8380
+ if (result.done) return;
8381
+ chunksReceived += 1;
8382
+ yield result.value;
8383
+ }
8384
+ } finally {
8385
+ abortRequest();
8386
+ try {
8387
+ await it.return?.();
8388
+ } catch {
8389
+ }
8390
+ }
8391
+ }
8392
+ __name(withStreamInactivityTimeout, "withStreamInactivityTimeout");
8393
+ var ContentGenerationPipeline = class {
8394
+ constructor(config) {
8395
+ this.config = config;
8396
+ this.contentGeneratorConfig = config.contentGeneratorConfig;
8397
+ this.client = this.config.provider.buildClient();
8398
+ this.streamIdleTimeoutMs = resolveStreamIdleTimeoutMs(
8399
+ this.contentGeneratorConfig
8400
+ );
8401
+ }
8402
+ static {
8403
+ __name(this, "ContentGenerationPipeline");
8404
+ }
8405
+ client;
8406
+ contentGeneratorConfig;
8407
+ // Resolved once (config field > env > default) so the env read + any
8408
+ // invalid-value warning happen per pipeline, not per streaming request.
8409
+ streamIdleTimeoutMs;
8410
+ async execute(request, userPromptId) {
8411
+ return this.executeWithErrorHandling(
8412
+ request,
8413
+ userPromptId,
8414
+ false,
8415
+ async (openaiRequest, context) => {
8416
+ const parentSignal = request.config?.abortSignal;
8417
+ const perRequestAc = parentSignal ? createChildAbortController(parentSignal) : void 0;
8418
+ try {
8419
+ const openaiResponse = await this.client.chat.completions.create(
8420
+ openaiRequest,
8421
+ {
8422
+ signal: perRequestAc?.signal
8423
+ }
8424
+ );
8425
+ const geminiResponse = OpenAIContentConverter.convertOpenAIResponseToGemini(
8426
+ openaiResponse,
8427
+ context
8428
+ );
8429
+ return geminiResponse;
8430
+ } finally {
8431
+ perRequestAc?.abort();
8432
+ }
8433
+ }
8434
+ );
8435
+ }
8436
+ async executeStream(request, userPromptId) {
8437
+ return this.executeWithErrorHandling(
8438
+ request,
8439
+ userPromptId,
8440
+ true,
8441
+ async (openaiRequest, context) => {
8442
+ const parentSignal = request.config?.abortSignal;
8443
+ const perRequestAc = createChildAbortController(parentSignal);
8444
+ let stream;
8445
+ try {
8446
+ const createPromise = this.client.chat.completions.create(
8447
+ openaiRequest,
8448
+ { signal: perRequestAc.signal }
8449
+ );
8450
+ if (typeof createPromise.withResponse === "function") {
8451
+ const {
8452
+ data,
8453
+ response: httpResponse,
8454
+ request_id
8455
+ } = await createPromise.withResponse();
8456
+ stream = data;
8457
+ const contentType = httpResponse.headers.get("content-type") ?? null;
8458
+ if (!isSSECompatibleContentType(contentType)) {
8459
+ let bodyPrefix = "";
8460
+ try {
8461
+ if (httpResponse.body) {
8462
+ const reader = httpResponse.body.getReader();
8463
+ const { value } = await reader.read();
8464
+ reader.releaseLock();
8465
+ if (value) {
8466
+ bodyPrefix = new TextDecoder().decode(value).slice(0, NON_SSE_BODY_PREFIX_LIMIT);
8467
+ }
8468
+ }
8469
+ } catch {
8470
+ }
8471
+ throw new NonSSEResponseError(
8472
+ contentType,
8473
+ httpResponse.status,
8474
+ bodyPrefix,
8475
+ request_id
8476
+ );
8477
+ }
8478
+ } else {
8479
+ stream = await createPromise;
8480
+ }
8481
+ } catch (e) {
8482
+ perRequestAc.abort();
8483
+ throw e;
8484
+ }
8485
+ const idleMs = this.streamIdleTimeoutMs;
8486
+ const guarded = idleMs > 0 ? withStreamInactivityTimeout(
8487
+ stream,
8488
+ idleMs,
8489
+ () => perRequestAc.abort(),
8490
+ parentSignal
8491
+ ) : stream;
8492
+ const innerStream = this.processStreamWithLogging(
8493
+ guarded,
8494
+ context,
8495
+ request,
8496
+ userPromptId
8497
+ );
8498
+ async function* drainThenCleanup() {
8499
+ try {
8500
+ yield* innerStream;
8501
+ } finally {
8502
+ perRequestAc.abort();
8503
+ }
8504
+ }
8505
+ __name(drainThenCleanup, "drainThenCleanup");
8506
+ return drainThenCleanup();
8507
+ }
8508
+ );
8509
+ }
8510
+ /**
8511
+ * Stage 2: Process OpenAI stream with conversion and logging
8512
+ * This method handles the complete stream processing pipeline:
8513
+ * 1. Convert OpenAI chunks to Gemini format while preserving original chunks
8514
+ * 2. Filter empty responses
8515
+ * 3. Handle chunk merging for providers that send finishReason and usageMetadata separately
8516
+ * 4. Handle success/error logging
8517
+ */
8518
+ async *processStreamWithLogging(stream, context, request, userPromptId) {
8519
+ let pendingFinishResponse = null;
8520
+ let finishYielded = false;
8521
+ let pendingFinishProtocolTagSanitized;
8522
+ const logPendingProtocolTagSanitized = /* @__PURE__ */ __name((response, sanitization) => {
8523
+ if (!sanitization) return;
8524
+ const event = new ProtocolTagSanitizedEvent({
8525
+ model: context.model,
8526
+ promptId: userPromptId,
8527
+ responseId: response.responseId,
8528
+ tagName: sanitization.tagName,
8529
+ toolCallCount: sanitization.toolCallCount
8530
+ });
8531
+ debugLogger4.warn("Sanitized a model protocol tag", {
8532
+ model: event.model,
8533
+ promptId: event.prompt_id,
8534
+ responseId: event.response_id,
8535
+ tagName: event.tag_name,
8536
+ toolCallCount: event.tool_call_count
8537
+ });
8538
+ logProtocolTagSanitized(this.config.cliConfig, event);
8539
+ }, "logPendingProtocolTagSanitized");
8540
+ try {
8541
+ for await (const chunk of stream) {
8542
+ if (chunk.choices?.[0]?.finish_reason === "error_finish") {
8543
+ const errorContent = chunk.choices?.[0]?.delta?.content?.trim() || "Unknown stream error";
8544
+ throw new StreamContentError(errorContent);
8545
+ }
8546
+ const response = OpenAIContentConverter.convertOpenAIChunkToGemini(
8547
+ chunk,
8548
+ context
8549
+ );
8550
+ const sanitization = context.protocolTagSanitized;
8551
+ if (sanitization) {
8552
+ context.protocolTagSanitized = void 0;
8553
+ }
8554
+ if (response.candidates?.[0]?.content?.parts?.length === 0 && !response.candidates?.[0]?.finishReason && !response.usageMetadata && // Preparation-only responses must reach ACP before arguments complete.
8555
+ getToolCallPreparations(response).length === 0) {
8556
+ continue;
8557
+ }
8558
+ if (pendingFinishProtocolTagSanitized && pendingFinishResponse && !response.candidates?.[0]?.finishReason && response.candidates?.some(
8559
+ (candidate) => (candidate.content?.parts?.length ?? 0) > 0
8560
+ )) {
8561
+ throw new InvalidStreamError(
8562
+ "Model response continued after a finish reason.",
8563
+ "PROTOCOL_TAG_LEAK"
8564
+ );
8565
+ }
8566
+ if (finishYielded) {
8567
+ if (response.usageMetadata) {
8568
+ const pending = pendingFinishResponse;
8569
+ if (pending) {
8570
+ pending.usageMetadata = response.usageMetadata;
8571
+ }
8572
+ }
8573
+ continue;
8574
+ }
8575
+ if (!pendingFinishResponse && response.candidates?.[0]?.finishReason && sanitization) {
8576
+ pendingFinishProtocolTagSanitized = sanitization;
8577
+ }
8578
+ const shouldYield = this.handleChunkMerging(
8579
+ response,
8580
+ pendingFinishResponse,
8581
+ (mergedResponse) => {
8582
+ pendingFinishResponse = mergedResponse;
8583
+ }
8584
+ );
8585
+ if (shouldYield) {
8586
+ if (pendingFinishResponse) {
8587
+ logPendingProtocolTagSanitized(
8588
+ pendingFinishResponse,
8589
+ pendingFinishProtocolTagSanitized
8590
+ );
8591
+ yield pendingFinishResponse;
8592
+ finishYielded = true;
8593
+ } else {
8594
+ logPendingProtocolTagSanitized(response, sanitization);
8595
+ yield response;
8596
+ }
8597
+ }
8598
+ }
8599
+ if (context.pendingThinkingTagCandidate && !context.pendingThinkingTagCandidate.closingTagName && !/\S/.test(context.pendingThinkingTagCandidate.text)) {
8600
+ const pendingParts = context.pendingUntrustedResponseParts;
8601
+ context.pendingThinkingTagCandidate = void 0;
8602
+ context.pendingUntrustedResponseParts = void 0;
8603
+ if (pendingParts?.length) {
8604
+ const response = new GenerateContentResponse();
8605
+ response.candidates = [
8606
+ {
8607
+ content: { parts: pendingParts, role: "model" },
8608
+ index: 0
8609
+ }
8610
+ ];
8611
+ yield response;
8612
+ }
8613
+ } else if (context.pendingThinkingTagCandidate) {
8614
+ throw new InvalidStreamError(
8615
+ "Model response leaked thinking tags.",
8616
+ "PROTOCOL_TAG_LEAK"
8617
+ );
8618
+ }
8619
+ if (pendingFinishResponse && !finishYielded) {
8620
+ logPendingProtocolTagSanitized(
8621
+ pendingFinishResponse,
8622
+ pendingFinishProtocolTagSanitized
8623
+ );
8624
+ yield pendingFinishResponse;
8625
+ }
8626
+ } catch (error) {
8627
+ if (error instanceof InvalidStreamError) {
8628
+ throw error;
8629
+ }
8630
+ if (error instanceof StreamContentError) {
8631
+ throw redactProxyError(error);
8632
+ }
8633
+ if (context.pendingThinkingTagCandidate?.closingTagName && request.config?.abortSignal?.aborted !== true) {
8634
+ context.pendingThinkingTagCandidate = void 0;
8635
+ context.pendingUntrustedResponseParts = void 0;
8636
+ throw new InvalidStreamError(
8637
+ "Model response leaked thinking tags.",
8638
+ "PROTOCOL_TAG_LEAK"
8639
+ );
8640
+ }
8641
+ if (error instanceof StreamInactivityTimeoutError) {
8642
+ debugLogger4.warn("OpenAI stream inactivity timeout", {
8643
+ idleMs: error.idleMs,
8644
+ chunksReceived: error.chunksReceived,
8645
+ streamLifetimeMs: error.streamLifetimeMs
8646
+ });
8647
+ throw redactProxyError(error);
8648
+ }
8649
+ await this.handleError(error, context, request);
8650
+ }
8651
+ }
8652
+ /**
8653
+ * Handle chunk merging for providers that send finishReason and usageMetadata separately.
8654
+ *
8655
+ * Strategy: When we encounter a finishReason chunk, we hold it and merge all subsequent
8656
+ * chunks into it until the stream ends. This ensures the final chunk contains both
8657
+ * finishReason and the most up-to-date usage information from any provider pattern.
8658
+ *
8659
+ * @param response Current Gemini response
8660
+ * @param pendingFinishResponse Finish response currently held for merging
8661
+ * @param setPendingFinish Callback to set pending finish response
8662
+ * @returns true if the response should be yielded, false if it should be held for merging
8663
+ */
8664
+ handleChunkMerging(response, pendingFinishResponse, setPendingFinish) {
8665
+ const isFinishChunk = response.candidates?.[0]?.finishReason;
8666
+ if (isFinishChunk) {
8667
+ if (pendingFinishResponse) {
8668
+ if (response.usageMetadata) {
8669
+ pendingFinishResponse.usageMetadata = response.usageMetadata;
8670
+ }
8671
+ setPendingFinish(pendingFinishResponse);
8672
+ } else {
8673
+ setPendingFinish(response);
8674
+ }
8675
+ return false;
8676
+ } else if (pendingFinishResponse) {
8677
+ const mergedResponse = new GenerateContentResponse();
8678
+ mergedResponse.candidates = pendingFinishResponse.candidates;
8679
+ if (response.usageMetadata) {
8680
+ mergedResponse.usageMetadata = response.usageMetadata;
8681
+ } else {
8682
+ mergedResponse.usageMetadata = pendingFinishResponse.usageMetadata;
8683
+ }
8684
+ mergedResponse.responseId = response.responseId;
8685
+ mergedResponse.createTime = response.createTime;
8686
+ mergedResponse.modelVersion = response.modelVersion;
8687
+ mergedResponse.promptFeedback = response.promptFeedback;
8688
+ setPendingFinish(mergedResponse);
8689
+ return true;
8690
+ }
8691
+ return true;
8692
+ }
8693
+ async buildRequest(request, userPromptId, context, isStreaming) {
8694
+ const messages = OpenAIContentConverter.convertGeminiRequestToOpenAI(
8695
+ request,
8696
+ context
8697
+ );
8698
+ const baseRequest = {
8699
+ model: context.model,
8700
+ messages,
8701
+ ...this.buildGenerateContentConfig(request)
8702
+ };
8703
+ if (isStreaming) {
8704
+ baseRequest.stream = true;
8705
+ baseRequest.stream_options = { include_usage: true };
8706
+ } else {
8707
+ baseRequest.stream = false;
8708
+ }
8709
+ if (request.config?.tools && request.config.tools.length > 0) {
8710
+ baseRequest.tools = await OpenAIContentConverter.convertGeminiToolsToOpenAI(
8711
+ request.config.tools,
8712
+ this.contentGeneratorConfig.schemaCompliance ?? "auto"
8713
+ );
8714
+ const fcMode = request.config?.toolConfig?.functionCallingConfig?.mode;
8715
+ if (fcMode === "ANY") {
8716
+ baseRequest["tool_choice"] = "required";
8717
+ } else if (fcMode === "NONE") {
8718
+ baseRequest["tool_choice"] = "none";
8719
+ }
8720
+ }
8721
+ const providerRequest = this.config.provider.buildRequest(
8722
+ baseRequest,
8723
+ userPromptId
8724
+ );
8725
+ const reasoningDisabled = request.config?.thinkingConfig?.includeThoughts === false || this.contentGeneratorConfig.reasoning === false;
8726
+ if (reasoningDisabled) {
8727
+ const typed = providerRequest;
8728
+ const model = (context.model ?? "").toLowerCase();
8729
+ if (model.startsWith("qwen") || model === "coder-model") {
8730
+ if (DashScopeOpenAICompatibleProvider.isDashScopeProvider(
8731
+ this.contentGeneratorConfig
8732
+ )) {
8733
+ typed["enable_thinking"] = false;
8734
+ } else {
8735
+ delete typed["enable_thinking"];
8736
+ const existing = typed["chat_template_kwargs"] ?? {};
8737
+ typed["chat_template_kwargs"] = {
8738
+ ...existing,
8739
+ enable_thinking: false
8740
+ };
8741
+ }
8742
+ }
8743
+ if ("reasoning" in typed) {
8744
+ delete typed["reasoning"];
8745
+ }
8746
+ if ("reasoning_effort" in typed) {
8747
+ delete typed["reasoning_effort"];
8748
+ }
8749
+ if (isDeepSeekHostname(this.contentGeneratorConfig)) {
8750
+ typed["thinking"] = { type: "disabled" };
8751
+ }
8752
+ }
8753
+ return providerRequest;
8754
+ }
8755
+ buildGenerateContentConfig(request) {
8756
+ const defaultSamplingParams = this.config.provider.getDefaultGenerationConfig();
8757
+ const configSamplingParams = this.contentGeneratorConfig.samplingParams;
8758
+ const getParameterValue = /* @__PURE__ */ __name((configKey, requestKey) => {
8759
+ const configValue = configSamplingParams?.[configKey];
8760
+ const requestValue = requestKey ? request.config?.[requestKey] : void 0;
8761
+ const defaultValue = requestKey ? defaultSamplingParams[requestKey] : void 0;
8762
+ if (configValue !== void 0) return configValue;
8763
+ if (requestValue !== void 0) return requestValue;
8764
+ return defaultValue;
8765
+ }, "getParameterValue");
8766
+ const addParameterIfDefined = /* @__PURE__ */ __name((key, configKey, requestKey) => {
8767
+ const value = getParameterValue(configKey, requestKey);
8768
+ return value !== void 0 ? { [key]: value } : {};
8769
+ }, "addParameterIfDefined");
8770
+ if (configSamplingParams !== void 0) {
8771
+ const requestMaxTokens = request.config?.maxOutputTokens;
8772
+ const maxTokens = reconcileMaxTokens(configSamplingParams.max_tokens, requestMaxTokens) ?? configSamplingParams.max_tokens ?? (hasProviderOutputBudgetKey(configSamplingParams) ? void 0 : requestMaxTokens);
8773
+ return clampProviderOutputBudgetKeys(
8774
+ maxTokens !== void 0 ? { ...configSamplingParams, max_tokens: maxTokens } : { ...configSamplingParams },
8775
+ requestMaxTokens
8776
+ );
8777
+ }
8778
+ const params = {
8779
+ // Parameters with request fallback but no defaults
8780
+ ...addParameterIfDefined("temperature", "temperature", "temperature"),
8781
+ ...addParameterIfDefined("top_p", "top_p", "topP"),
8782
+ // Max tokens (special case: different property names)
8783
+ ...addParameterIfDefined("max_tokens", "max_tokens", "maxOutputTokens"),
8784
+ // Config-only parameters (no request fallback)
8785
+ ...addParameterIfDefined("top_k", "top_k", "topK"),
8786
+ ...addParameterIfDefined("repetition_penalty", "repetition_penalty"),
8787
+ ...addParameterIfDefined(
8788
+ "presence_penalty",
8789
+ "presence_penalty",
8790
+ "presencePenalty"
8791
+ ),
8792
+ ...addParameterIfDefined(
8793
+ "frequency_penalty",
8794
+ "frequency_penalty",
8795
+ "frequencyPenalty"
8796
+ ),
8797
+ ...this.buildReasoningConfig(request)
8798
+ };
8799
+ return params;
8800
+ }
8801
+ buildReasoningConfig(request) {
8802
+ if (request.config?.thinkingConfig?.includeThoughts === false) {
8803
+ return {};
8804
+ }
8805
+ const reasoning = this.contentGeneratorConfig.reasoning;
8806
+ if (reasoning === false || reasoning === void 0) {
8807
+ return {};
8808
+ }
8809
+ return { reasoning };
8810
+ }
8811
+ /**
8812
+ * Common error handling wrapper for execute methods
8813
+ */
8814
+ async executeWithErrorHandling(request, userPromptId, isStreaming, executor) {
8815
+ const context = this.createRequestContext(request, isStreaming);
8816
+ try {
8817
+ const openaiRequest = await this.buildRequest(
8818
+ request,
8819
+ userPromptId,
8820
+ context,
8821
+ isStreaming
8822
+ );
8823
+ openaiRequestCaptureContext.getStore()?.(openaiRequest);
8824
+ runtimeDiagnostics.recordOpenAIWireRequest(openaiRequest);
8825
+ const result = await executor(openaiRequest, context);
8826
+ return result;
8827
+ } catch (error) {
8828
+ return await this.handleError(error, context, request);
8829
+ }
8830
+ }
8831
+ /**
8832
+ * Shared error handling logic for both executeWithErrorHandling and processStreamWithLogging
8833
+ * This centralizes the common error processing steps to avoid duplication
8834
+ */
8835
+ async handleError(error, context, request) {
8836
+ this.config.errorHandler.handle(redactProxyError(error), context, request);
8837
+ }
8838
+ /**
8839
+ * Create request context with common properties
8840
+ */
8841
+ createRequestContext(request, isStreaming) {
8842
+ const effectiveModel = request.model || this.contentGeneratorConfig.model;
8843
+ const providerOverrides = this.config.provider.getRequestContextOverrides?.() ?? {};
8844
+ const toolCallParser = isStreaming ? new StreamingToolCallParser() : void 0;
8845
+ const responseParsingOptions = this.config.provider.getResponseParsingOptions?.();
8846
+ const taggedThinkingParser = isStreaming && responseParsingOptions?.taggedThinkingTags ? new TaggedThinkingParser() : void 0;
8847
+ return {
8848
+ model: effectiveModel,
8849
+ modalities: this.contentGeneratorConfig.modalities ?? {},
8850
+ startTime: Date.now(),
8851
+ splitToolMedia: providerOverrides.splitToolMedia ?? this.contentGeneratorConfig.splitToolMedia ?? // Default true: the OpenAI Chat Completions spec only permits text on
8852
+ // `role: "tool"` messages, so tool-returned media (e.g. an image read
8853
+ // by read_file) embedded there is silently dropped or rejected by
8854
+ // strict providers (doubao / new-api / LM Studio) and the model never
8855
+ // sees it (QwenLM/qwen-code#4876). Splitting it into a follow-up user
8856
+ // message is spec-compliant and safe for permissive providers too.
8857
+ // Opt out via generationConfig.splitToolMedia = false.
8858
+ true,
8859
+ toolResultContentFormat: providerOverrides.toolResultContentFormat ?? this.contentGeneratorConfig.toolResultContentFormat ?? "parts",
8860
+ ...toolCallParser ? { toolCallParser } : {},
8861
+ ...responseParsingOptions ? { responseParsingOptions } : {},
8862
+ ...taggedThinkingParser ? { taggedThinkingParser } : {}
8863
+ };
8864
+ }
8865
+ };
8866
+
8867
+ // packages/core/src/core/openaiContentGenerator/errorHandler.ts
8868
+ init_esbuild_shims();
8869
+ var debugLogger5 = createDebugLogger("OPENAI_ERROR");
8870
+ var EnhancedErrorHandler = class {
8871
+ constructor(shouldSuppressLogging = () => false) {
8872
+ this.shouldSuppressLogging = shouldSuppressLogging;
8873
+ }
8874
+ static {
8875
+ __name(this, "EnhancedErrorHandler");
8876
+ }
8877
+ handle(error, context, request) {
8878
+ const redactedError = redactProxyError(error);
8879
+ const isTimeoutError = this.isTimeoutError(redactedError);
8880
+ const errorMessage = this.buildErrorMessage(
8881
+ redactedError,
8882
+ context,
8883
+ isTimeoutError
8884
+ );
8885
+ if (!this.shouldSuppressErrorLogging(redactedError, request)) {
8886
+ debugLogger5.error(
8887
+ "OpenAI API Error:",
8888
+ errorMessage,
8889
+ this.buildDiagnostics(redactedError, context)
8890
+ );
8891
+ }
8892
+ if (isTimeoutError) {
8893
+ throw new Error(
8894
+ `${errorMessage}
8895
+
8896
+ ${this.getTimeoutTroubleshootingTips()}`
8897
+ );
8898
+ }
8899
+ throw redactedError;
8900
+ }
8901
+ shouldSuppressErrorLogging(error, request) {
8902
+ return this.shouldSuppressLogging(error, request);
8903
+ }
8904
+ isTimeoutError(error) {
8905
+ if (!error) return false;
8906
+ const errorMessage = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
8907
+ const errorCode = error?.code;
8908
+ const errorType = error?.type;
8909
+ return errorMessage.includes("timeout") || errorMessage.includes("timed out") || errorMessage.includes("connection timeout") || errorMessage.includes("request timeout") || errorMessage.includes("read timeout") || errorMessage.includes("etimedout") || errorMessage.includes("esockettimedout") || errorCode === "ETIMEDOUT" || errorCode === "ESOCKETTIMEDOUT" || errorType === "timeout" || errorMessage.includes("request timed out") || errorMessage.includes("deadline exceeded");
8910
+ }
8911
+ buildErrorMessage(error, context, isTimeoutError) {
8912
+ const durationSeconds = Math.round((Date.now() - context.startTime) / 1e3);
8913
+ if (isTimeoutError) {
8914
+ return `Request timeout after ${durationSeconds}s. Try reducing input length or increasing timeout in config.`;
8915
+ }
8916
+ return error instanceof Error ? getErrorMessage(error) : String(error);
8917
+ }
8918
+ buildDiagnostics(error, context) {
8919
+ const details = getRateLimitErrorDetails(error);
8920
+ const requestId = this.getRequestId(error) ?? details.requestId;
8921
+ const statusCode = getErrorStatus(error);
8922
+ return {
8923
+ model: context.model,
8924
+ durationMs: Date.now() - context.startTime,
8925
+ errorType: getErrorType(error),
8926
+ ...statusCode !== void 0 ? { statusCode } : {},
8927
+ ...details.providerCode !== void 0 ? { providerCode: details.providerCode } : {},
8928
+ ...details.providerMessage !== void 0 ? { providerMessage: details.providerMessage } : {},
8929
+ ...requestId !== void 0 ? { requestId } : {},
8930
+ ...details.transport !== "unknown" ? { transport: details.transport } : {}
8931
+ };
8932
+ }
8933
+ getRequestId(error) {
8934
+ if (!error || typeof error !== "object") return void 0;
8935
+ const source = error;
8936
+ for (const value of [
8937
+ source.requestID,
8938
+ source.request_id,
8939
+ source.response_id
8940
+ ]) {
8941
+ if (typeof value === "string" && value) {
8942
+ return value;
8943
+ }
8944
+ }
8945
+ return void 0;
8946
+ }
8947
+ getTimeoutTroubleshootingTips() {
8948
+ const tips = [
8949
+ "- Reduce input length or complexity",
8950
+ "- Increase timeout in config: contentGenerator.timeout",
8951
+ "- Check network connectivity"
8952
+ ];
8953
+ return `Troubleshooting tips:
8954
+ ${tips.join("\n")}`;
8955
+ }
8956
+ };
8957
+
8958
+ // packages/core/src/core/openaiContentGenerator/openaiContentGenerator.ts
8959
+ var debugLogger6 = createDebugLogger("OPENAI");
8960
+ var OpenAIContentGenerator = class {
8961
+ static {
8962
+ __name(this, "OpenAIContentGenerator");
8963
+ }
8964
+ pipeline;
8965
+ constructor(contentGeneratorConfig, cliConfig, provider) {
8966
+ const pipelineConfig = {
8967
+ cliConfig,
8968
+ provider,
8969
+ contentGeneratorConfig,
8970
+ errorHandler: new EnhancedErrorHandler(
8971
+ (error, request) => this.shouldSuppressErrorLogging(error, request)
8972
+ )
8973
+ };
8974
+ this.pipeline = new ContentGenerationPipeline(pipelineConfig);
8975
+ }
8976
+ /**
8977
+ * Hook for subclasses to customize error handling behavior
8978
+ * @param error The error that occurred
8979
+ * @param request The original request
8980
+ * @returns true if error logging should be suppressed, false otherwise
8981
+ */
8982
+ shouldSuppressErrorLogging(error, request) {
8983
+ if (isAbortError(error) && request.config?.abortSignal?.aborted) {
8984
+ return true;
8985
+ }
8986
+ return false;
8987
+ }
8988
+ async generateContent(request, userPromptId) {
8989
+ return this.pipeline.execute(request, userPromptId);
8990
+ }
8991
+ async generateContentStream(request, userPromptId) {
8992
+ return this.pipeline.executeStream(request, userPromptId);
8993
+ }
8994
+ async countTokens(request) {
8995
+ try {
8996
+ const estimator = new RequestTokenizer();
8997
+ const result = await estimator.calculateTokens(request);
8998
+ return {
8999
+ totalTokens: result.totalTokens
9000
+ };
9001
+ } catch (error) {
9002
+ debugLogger6.warn(
9003
+ "Failed to calculate tokens with new tokenizer, falling back to simple method:",
9004
+ error
9005
+ );
9006
+ const content = JSON.stringify(request.contents);
9007
+ const totalTokens = Math.ceil(content.length / 4);
9008
+ return {
9009
+ totalTokens
9010
+ };
9011
+ }
9012
+ }
9013
+ async embedContent(request) {
9014
+ let text = "";
9015
+ if (Array.isArray(request.contents)) {
9016
+ text = request.contents.map((content) => {
9017
+ if (typeof content === "string") return content;
9018
+ if ("parts" in content && content.parts) {
9019
+ return content.parts.map(
9020
+ (part) => typeof part === "string" ? part : "text" in part ? part.text || "" : ""
9021
+ ).join(" ");
9022
+ }
9023
+ return "";
9024
+ }).join(" ");
9025
+ } else if (request.contents) {
9026
+ if (typeof request.contents === "string") {
9027
+ text = request.contents;
9028
+ } else if ("parts" in request.contents && request.contents.parts) {
9029
+ text = request.contents.parts.map(
9030
+ (part) => typeof part === "string" ? part : "text" in part ? part.text : ""
9031
+ ).join(" ");
9032
+ }
9033
+ }
9034
+ try {
9035
+ const embedding = await this.pipeline.client.embeddings.create({
9036
+ model: "text-embedding-ada-002",
9037
+ // Default embedding model
9038
+ input: text
9039
+ });
9040
+ return {
9041
+ embeddings: [
9042
+ {
9043
+ values: embedding.data[0].embedding
9044
+ }
9045
+ ]
9046
+ };
9047
+ } catch (error) {
9048
+ const redactedError = redactProxyError(error);
9049
+ debugLogger6.error("OpenAI API Embedding Error:", redactedError);
9050
+ throw new Error(
9051
+ `OpenAI API error: ${redactedError instanceof Error ? redactedError.message : String(redactedError)}`
9052
+ );
9053
+ }
9054
+ }
9055
+ useSummarizedThinking() {
9056
+ return false;
9057
+ }
9058
+ };
9059
+
9060
+ // packages/core/src/core/openaiContentGenerator/index.ts
9061
+ function createOpenAIContentGenerator(contentGeneratorConfig, cliConfig) {
9062
+ const provider = determineProvider(contentGeneratorConfig, cliConfig);
9063
+ return new OpenAIContentGenerator(
9064
+ contentGeneratorConfig,
9065
+ cliConfig,
9066
+ provider
9067
+ );
9068
+ }
9069
+ __name(createOpenAIContentGenerator, "createOpenAIContentGenerator");
9070
+ function determineProvider(contentGeneratorConfig, cliConfig) {
9071
+ const config = contentGeneratorConfig || cliConfig.getContentGeneratorConfig();
9072
+ if (DashScopeOpenAICompatibleProvider.isDashScopeProvider(config)) {
9073
+ return new DashScopeOpenAICompatibleProvider(
9074
+ contentGeneratorConfig,
9075
+ cliConfig
9076
+ );
9077
+ }
9078
+ if (DeepSeekOpenAICompatibleProvider.isDeepSeekProvider(config)) {
9079
+ return new DeepSeekOpenAICompatibleProvider(
9080
+ contentGeneratorConfig,
9081
+ cliConfig
9082
+ );
9083
+ }
9084
+ if (ZaiOpenAICompatibleProvider.isZaiProvider(config)) {
9085
+ return new ZaiOpenAICompatibleProvider(contentGeneratorConfig, cliConfig);
9086
+ }
9087
+ if (MiMoOpenAICompatibleProvider.isMiMoProvider(config)) {
9088
+ return new MiMoOpenAICompatibleProvider(contentGeneratorConfig, cliConfig);
9089
+ }
9090
+ if (ModelScopeOpenAICompatibleProvider.isModelScopeProvider(config)) {
9091
+ return new ModelScopeOpenAICompatibleProvider(
9092
+ contentGeneratorConfig,
9093
+ cliConfig
9094
+ );
9095
+ }
9096
+ if (MiniMaxOpenAICompatibleProvider.isMiniMaxProvider(config)) {
9097
+ return new MiniMaxOpenAICompatibleProvider(
9098
+ contentGeneratorConfig,
9099
+ cliConfig
9100
+ );
9101
+ }
9102
+ if (MistralOpenAICompatibleProvider.isMistralProvider(config)) {
9103
+ return new MistralOpenAICompatibleProvider(
9104
+ contentGeneratorConfig,
9105
+ cliConfig
9106
+ );
9107
+ }
9108
+ return new DefaultOpenAICompatibleProvider(contentGeneratorConfig, cliConfig);
9109
+ }
9110
+ __name(determineProvider, "determineProvider");
9111
+
7385
9112
  export {
7386
- OpenAI,
7387
- DefaultOpenAICompatibleProvider,
7388
- DASHSCOPE_REGIONAL_HOSTS,
7389
- DashScopeOpenAICompatibleProvider
9113
+ DashScopeOpenAICompatibleProvider,
9114
+ DeepSeekOpenAICompatibleProvider,
9115
+ MiniMaxOpenAICompatibleProvider,
9116
+ MistralOpenAICompatibleProvider,
9117
+ MiMoOpenAICompatibleProvider,
9118
+ ContentGenerationPipeline,
9119
+ EnhancedErrorHandler,
9120
+ OpenAIContentGenerator,
9121
+ createOpenAIContentGenerator,
9122
+ determineProvider
7390
9123
  };
9124
+ /**
9125
+ * @license
9126
+ * Copyright 2025 Qwen
9127
+ * SPDX-License-Identifier: Apache-2.0
9128
+ */