@qwen-code/qwen-code 0.20.0 → 0.20.1-jobbench-claude-prompt.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 (171) hide show
  1. package/chunks/{MaxSizedBox-B5YGZSYE.js → MaxSizedBox-BGLP6FQT.js} +15 -12
  2. package/chunks/{StandaloneSessionPicker-CEGO2AZX.js → StandaloneSessionPicker-K6I4ZEHD.js} +33 -30
  3. package/chunks/{acpAgent-YUR43TLG.js → acpAgent-PKKBOEP4.js} +79 -71
  4. package/chunks/{agent-H4JIDL7S.js → agent-Y7XOSZY5.js} +15 -12
  5. package/chunks/{agent-headless-TTBEREQV.js → agent-headless-NXRPEYGF.js} +15 -12
  6. package/chunks/{anthropicContentGenerator-HVKLXOOU.js → anthropicContentGenerator-BWBAZGTW.js} +3 -2
  7. package/chunks/{artifact-tool-WBCAMD3O.js → artifact-tool-IUJ7QWCX.js} +1 -1
  8. package/chunks/{askUserQuestion-6DZC4UV5.js → askUserQuestion-IUMUUTDQ.js} +1 -1
  9. package/chunks/{bridge-VL7ITBU5.js → bridge-DCMYGFJ2.js} +18 -15
  10. package/chunks/{chunk-FLSVD6BS.js → chunk-26LLB6FM.js} +1 -1
  11. package/chunks/{chunk-NDMQLV4Y.js → chunk-2F7HITKF.js} +3 -3
  12. package/chunks/{chunk-4N3KMAIL.js → chunk-2R7OXGYM.js} +13 -13
  13. package/chunks/{chunk-7SXZC7ID.js → chunk-2RDNKVZ2.js} +4 -4
  14. package/chunks/{chunk-PBWEWI4N.js → chunk-2T2FG7OX.js} +29 -27
  15. package/chunks/{chunk-O3OCNYY5.js → chunk-3P4TUBON.js} +1 -1
  16. package/chunks/{chunk-MJ6S23WZ.js → chunk-3PG4G7SK.js} +4 -4
  17. package/chunks/{chunk-NGFEPAE6.js → chunk-3XZIXCJY.js} +6 -4
  18. package/chunks/{chunk-EZVDJFZ7.js → chunk-467G3SV5.js} +1 -1
  19. package/chunks/{chunk-CV63PP6U.js → chunk-4E33SVWA.js} +1 -1
  20. package/chunks/{chunk-S2W2LVDU.js → chunk-5244PA32.js} +2 -2
  21. package/chunks/{chunk-CB2HFGRV.js → chunk-6UTNZOZG.js} +4 -4
  22. package/chunks/{chunk-PGEPSDJI.js → chunk-6UTRTWUF.js} +7 -7
  23. package/chunks/{chunk-SEKHYHMS.js → chunk-6YS6TQB3.js} +1 -1
  24. package/chunks/{chunk-TMQ6XQCX.js → chunk-7AB5URLY.js} +36 -36
  25. package/chunks/chunk-7H2JMOPS.js +391 -0
  26. package/chunks/{chunk-SJMV7ZBK.js → chunk-7YK65ZFC.js} +6 -6
  27. package/chunks/{chunk-7PZ2ATFZ.js → chunk-A2F633L4.js} +13 -13
  28. package/chunks/{chunk-6AFUCL3D.js → chunk-AU2GX7QQ.js} +1 -1
  29. package/chunks/{chunk-DBE4QFZS.js → chunk-BL7EEZ4Y.js} +10 -10
  30. package/chunks/{chunk-HZPN55E5.js → chunk-C44MIZ2K.js} +1 -1
  31. package/chunks/{chunk-OWCALFEG.js → chunk-C5L66QPF.js} +1 -1
  32. package/chunks/chunk-C5Z652G4.js +121 -0
  33. package/chunks/{chunk-2LL7TXB4.js → chunk-CAKC64KX.js} +2 -2
  34. package/chunks/{chunk-4ILMYHEI.js → chunk-CMFMPPKV.js} +3 -3
  35. package/chunks/{chunk-KG3XV6FH.js → chunk-D742634K.js} +1 -1
  36. package/chunks/{chunk-AJSJ5TTU.js → chunk-DFQGFXMQ.js} +1 -1
  37. package/chunks/{chunk-S2PD3EZD.js → chunk-E6XTP5ZF.js} +1 -1
  38. package/chunks/{chunk-FQD7GFSV.js → chunk-EELSDL62.js} +3 -3
  39. package/chunks/{chunk-TIH2ZTOC.js → chunk-EKVLDUP4.js} +1 -1
  40. package/chunks/{chunk-CZF3E5GF.js → chunk-EMMNRTQX.js} +1 -1
  41. package/chunks/{chunk-CPCVCKKF.js → chunk-ETD6K42I.js} +1 -1
  42. package/chunks/{chunk-XVVH63JG.js → chunk-FNGK2Z5B.js} +2 -2
  43. package/chunks/{chunk-FEOZBUMT.js → chunk-FODK6UMO.js} +0 -27
  44. package/chunks/chunk-GLNBDYUX.js +38 -0
  45. package/chunks/{chunk-ZFKNWQGQ.js → chunk-HAL7YT4M.js} +7 -7
  46. package/chunks/{chunk-TKLLK6XQ.js → chunk-IMVIN5UC.js} +1 -1
  47. package/chunks/{chunk-KQNM4EO7.js → chunk-J5CK6QYL.js} +1 -1
  48. package/chunks/{chunk-EAUYY7SS.js → chunk-JDI67JFB.js} +1 -1
  49. package/chunks/{chunk-OYZWQNWG.js → chunk-JXWFXSLN.js} +1 -1
  50. package/chunks/{chunk-BRRF37CO.js → chunk-L4BZXQR3.js} +1 -1
  51. package/chunks/{chunk-4EP2PYYL.js → chunk-L4PEDXOX.js} +3 -3
  52. package/chunks/{chunk-VEXFOTEO.js → chunk-LB7ZIQ6C.js} +2 -2
  53. package/chunks/{chunk-VDWBQ5AW.js → chunk-M2DASLLB.js} +1 -1
  54. package/chunks/{chunk-A5LYNIW7.js → chunk-MEDHWB34.js} +4 -4
  55. package/chunks/{chunk-BMWMT5Y2.js → chunk-NL37SKPP.js} +2 -372
  56. package/chunks/{chunk-IR46U7RB.js → chunk-NNDKJNCC.js} +1 -1
  57. package/chunks/{chunk-7RMOXZTC.js → chunk-NRPP5TOB.js} +4 -4
  58. package/chunks/{chunk-5JBR5XIK.js → chunk-NYMHN4ZK.js} +2 -2
  59. package/chunks/{chunk-PF4CHQOJ.js → chunk-ORDXX5SE.js} +4 -4
  60. package/chunks/{chunk-DP5GXXNZ.js → chunk-P5OX37TK.js} +1 -1
  61. package/chunks/chunk-PC2QR5QO.js +1768 -0
  62. package/chunks/{chunk-D22SX43D.js → chunk-PXVAFBEI.js} +1 -1
  63. package/chunks/{chunk-33XUAINQ.js → chunk-QCCOKIGW.js} +46 -6
  64. package/chunks/{chunk-KX6UK4VJ.js → chunk-RTEHQUAD.js} +266 -840
  65. package/chunks/{chunk-OP4MOGXF.js → chunk-S35ZDXOS.js} +6 -0
  66. package/chunks/{chunk-O3Z73NBP.js → chunk-SKQD5RCT.js} +4 -4
  67. package/chunks/{chunk-OEO2ERWK.js → chunk-SMR34EQM.js} +3 -3
  68. package/chunks/{chunk-S2XVRHDN.js → chunk-SWRMKMVY.js} +1 -1
  69. package/chunks/{chunk-AQIEINAY.js → chunk-UJEZQ562.js} +25 -1763
  70. package/chunks/{chunk-ANPINBOF.js → chunk-UNIQ7KNW.js} +3 -3
  71. package/chunks/{chunk-KDC6GNQR.js → chunk-UTBTCPKF.js} +4 -4
  72. package/chunks/{chunk-VZQUV7VK.js → chunk-VT3KBCIU.js} +1 -1
  73. package/chunks/{chunk-4XNLIGVA.js → chunk-W2LKWG6I.js} +43 -26
  74. package/chunks/{chunk-542SK7KV.js → chunk-WCPQTUDI.js} +4 -4
  75. package/chunks/{chunk-KOR3XKCA.js → chunk-WJYCCJ3Q.js} +3 -3
  76. package/chunks/{chunk-I2PYAYFM.js → chunk-XBAYQWDL.js} +1 -1
  77. package/chunks/{chunk-333CXMNJ.js → chunk-XSSAJZXG.js} +4 -4
  78. package/chunks/{chunk-IVPSS6EL.js → chunk-YHRBVZ53.js} +3 -3
  79. package/chunks/{chunk-AKX4WPPP.js → chunk-YXBZOR3D.js} +4 -4
  80. package/chunks/{computer-use-NIWQNUZF.js → computer-use-KQVQD3IW.js} +15 -12
  81. package/chunks/{config-utils-AHQ6YZ66.js → config-utils-6FXFJUYB.js} +1 -1
  82. package/chunks/{contextCommand-L2COEUHS.js → contextCommand-IOC5HY6R.js} +17 -14
  83. package/chunks/{create-sub-session-MGNX52P3.js → create-sub-session-IOAGEN3O.js} +15 -12
  84. package/chunks/{create-sub-session-P26FE5GG.js → create-sub-session-X5RVIHCK.js} +1 -1
  85. package/chunks/{cron-create-JWFHBDRQ.js → cron-create-AC5FFLN7.js} +1 -1
  86. package/chunks/{cron-delete-GDX4E26G.js → cron-delete-JEB3FAHA.js} +1 -1
  87. package/chunks/{cron-list-USMAIWPT.js → cron-list-NBYPCNIB.js} +1 -1
  88. package/chunks/{daemon-status-provider-NL4IAG7B.js → daemon-status-provider-DYDVT4S5.js} +22 -19
  89. package/chunks/{earlyInputCapture-L6I2A22T.js → earlyInputCapture-7AA4D4RF.js} +15 -12
  90. package/chunks/{edit-3QV3JZJL.js → edit-RQXZUTEU.js} +16 -13
  91. package/chunks/{enter-worktree-4GMMF7EG.js → enter-worktree-BPYKHGTX.js} +15 -12
  92. package/chunks/{enterPlanMode-L5UWBAUC.js → enterPlanMode-VJ3KR5HM.js} +15 -12
  93. package/chunks/{environment-3OV7UQOT.js → environment-PZYHWWG5.js} +17 -14
  94. package/chunks/{errors-LEOF5QG4.js → errors-NZ6JOKJB.js} +17 -14
  95. package/chunks/{exit-worktree-DDP57JLV.js → exit-worktree-TZNABJPX.js} +15 -12
  96. package/chunks/{exitPlanMode-CJBLGPIP.js → exitPlanMode-RZMERKLI.js} +15 -12
  97. package/chunks/{fast-path-M6RP2ING.js → fast-path-F5UWH7GI.js} +2 -2
  98. package/chunks/{gemini-H4PHBJTL.js → gemini-2QJRGIKD.js} +56 -53
  99. package/chunks/{geminiContentGenerator-VURJYPWP.js → geminiContentGenerator-Q7IAYVM4.js} +1 -1
  100. package/chunks/{glob-2KUSRAVQ.js → glob-MP7IPPNS.js} +15 -12
  101. package/chunks/{grep-B5RXVESV.js → grep-OHN54Z7A.js} +15 -12
  102. package/chunks/{handleAutoUpdate-QQVIWXKT.js → handleAutoUpdate-EGCO46FV.js} +19 -16
  103. package/chunks/{i18n-N6OBDORT.js → i18n-4LK42EK5.js} +16 -13
  104. package/chunks/{initializer-6WCFNDLL.js → initializer-DAL5QAZU.js} +20 -17
  105. package/chunks/{installationInfo-6J3WPXNS.js → installationInfo-HOKGVMMQ.js} +16 -13
  106. package/chunks/{list-HOWQSWP6.js → list-M5NNXMQQ.js} +23 -20
  107. package/chunks/{loadedSettingsAdapter-AO4YBRXZ.js → loadedSettingsAdapter-I42UOUE7.js} +20 -17
  108. package/chunks/{loop-wakeup-5GLTUBHA.js → loop-wakeup-HMHCT5GU.js} +2 -2
  109. package/chunks/{ls-FHBY3Y7I.js → ls-IW5HYDG4.js} +1 -1
  110. package/chunks/{lsp-B6VMEW6Y.js → lsp-4RL52YIZ.js} +1 -1
  111. package/chunks/{mcp-QH7QNXOH.js → mcp-62XOYOXZ.js} +20 -17
  112. package/chunks/{monitor-GLJZDNPS.js → monitor-YIHFTVM7.js} +15 -12
  113. package/chunks/{nonInteractiveCli-TI7EMPXD.js → nonInteractiveCli-Z73R2B3B.js} +47 -44
  114. package/chunks/{notebook-edit-AVCIWS4F.js → notebook-edit-XK4J36D3.js} +16 -13
  115. package/chunks/{openaiContentGenerator-B7W24G3D.js → openaiContentGenerator-OEIKDARY.js} +10 -7
  116. package/chunks/{pidfile-UEHAT6DH.js → pidfile-2XVZMMKS.js} +15 -12
  117. package/chunks/{processUtils-XZPY2PBB.js → processUtils-SYFMMDPV.js} +2 -2
  118. package/chunks/{qwenContentGenerator-6GUTWJIC.js → qwenContentGenerator-LTTPUWV3.js} +20 -15
  119. package/chunks/{qwenOAuth2-GASEEWGU.js → qwenOAuth2-U3X6UBDP.js} +6 -5
  120. package/chunks/{read-file-SQJONF6A.js → read-file-P6IEAOBS.js} +3 -3
  121. package/chunks/{read-mcp-resource-AKCL7I43.js → read-mcp-resource-OIBCNIX7.js} +1 -1
  122. package/chunks/{record-artifact-PEUB7727.js → record-artifact-HDMK4LHG.js} +1 -1
  123. package/chunks/{resumeHistoryUtils-PFQ2A23X.js → resumeHistoryUtils-WMJ5TUPF.js} +19 -16
  124. package/chunks/{ripGrep-QCK22GDU.js → ripGrep-US5HKBSM.js} +15 -12
  125. package/chunks/{run-qwen-serve-OZGR3FQA.js → run-qwen-serve-MIFJODT4.js} +24 -24
  126. package/chunks/{runtime-SNVAP6EH.js → runtime-SK5QH53T.js} +22 -19
  127. package/chunks/{scheduler-Z7QLMUWA.js → scheduler-4TIUONHH.js} +15 -12
  128. package/chunks/{send-message-3RHE7HSM.js → send-message-WXVVK4DB.js} +2 -2
  129. package/chunks/{serve-BT7KS6SC.js → serve-F6VZULAL.js} +20 -17
  130. package/chunks/{server-SO64U3X5.js → server-UJEZDWGO.js} +70 -67
  131. package/chunks/{session-2KL2WQAH.js → session-PFCYZOZJ.js} +48 -45
  132. package/chunks/{settings-KITVOUSV.js → settings-7UHALRNO.js} +19 -16
  133. package/chunks/{shell-BITUVH2R.js → shell-DY7EASPT.js} +15 -12
  134. package/chunks/{skill-SOQHY455.js → skill-DOZBVXRT.js} +3 -3
  135. package/chunks/{spawnChannel-2BU3AULL.js → spawnChannel-HT7EQ4SL.js} +17 -14
  136. package/chunks/{src-43LM7JLB.js → src-VJO75DQQ.js} +50 -46
  137. package/chunks/{standalone-update-YG5JUYCM.js → standalone-update-5ERAJGLE.js} +17 -14
  138. package/chunks/{startInteractiveUI-3RGTGEX5.js → startInteractiveUI-HYMIOBH7.js} +144 -140
  139. package/chunks/{syntheticOutput-FG5PQKIR.js → syntheticOutput-HCUFXSIA.js} +2 -2
  140. package/chunks/{task-create-HX32YXO7.js → task-create-RIY5JTFC.js} +3 -3
  141. package/chunks/{task-list-QWSY4ZIU.js → task-list-XBUCV3CO.js} +1 -1
  142. package/chunks/{task-stop-GWC6UWAL.js → task-stop-QDFCCYR5.js} +1 -1
  143. package/chunks/{task-update-NCTAB73Q.js → task-update-7PXKJQOI.js} +3 -3
  144. package/chunks/{team-create-FXN3PEBP.js → team-create-NF3FCZE2.js} +18 -15
  145. package/chunks/{team-delete-KK37HTOG.js → team-delete-TNSSE2S5.js} +1 -1
  146. package/chunks/{team-plan-approval-GEIZ356Q.js → team-plan-approval-P5U7U4NW.js} +15 -12
  147. package/chunks/{theme-manager-IAETOI25.js → theme-manager-WD73RXOX.js} +15 -12
  148. package/chunks/{todoWrite-ERCAMLFS.js → todoWrite-OMAIGB6V.js} +1 -1
  149. package/chunks/{tool-search-XKK7DNOK.js → tool-search-TDMA733L.js} +4 -4
  150. package/chunks/{total-session-admission-BJLDHKJN.js → total-session-admission-H3XZPCNC.js} +18 -15
  151. package/chunks/{tree-sitter-4D7QS7F6.js → tree-sitter-VJEPTDMU.js} +1 -1
  152. package/chunks/{tree-sitter-bash-VEJGF5XF.js → tree-sitter-bash-WFKBO43W.js} +1 -1
  153. package/chunks/{trustedFolders-5XCVNEUU.js → trustedFolders-NEFWXHU2.js} +16 -13
  154. package/chunks/{update-relaunch-FMVZK6XF.js → update-relaunch-T2XQQC4W.js} +5 -5
  155. package/chunks/{updateCheck-YZZB7YBU.js → updateCheck-G5JYMVJZ.js} +18 -15
  156. package/chunks/{useAutoAcceptIndicator-ZSQX4I2H.js → useAutoAcceptIndicator-5FLFR3BY.js} +23 -20
  157. package/chunks/{validateNonInterActiveAuth-PRVEB6GG.js → validateNonInterActiveAuth-Z23SJ4D4.js} +44 -41
  158. package/chunks/{version-AZMG6KWL.js → version-PLKW23RX.js} +1 -1
  159. package/chunks/{web-fetch-EPGJ5OQQ.js → web-fetch-QNI3EEXN.js} +5 -4
  160. package/chunks/web-search-DLYTQBNN.js +680 -0
  161. package/chunks/{workflow-UTNVPW22.js → workflow-A3WFSQKU.js} +16 -13
  162. package/chunks/{workspace-providers-status-EADV364W.js → workspace-providers-status-6K34OJLQ.js} +23 -20
  163. package/chunks/{workspace-registration-store-F3ZX3YHT.js → workspace-registration-store-6FPLTQG3.js} +1 -1
  164. package/chunks/{workspace-registry-W6VMFYZU.js → workspace-registry-JZRIJXJS.js} +18 -15
  165. package/chunks/{workspace-service-F3KIN2UN.js → workspace-service-PQDLBZV3.js} +25 -22
  166. package/chunks/{workspace-skills-status-YVICUR5Y.js → workspace-skills-status-RKCPZVT2.js} +21 -18
  167. package/chunks/{write-file-CVGF2OKV.js → write-file-LHZENZ2A.js} +16 -13
  168. package/cli.js +11 -11
  169. package/package.json +3 -3
  170. package/chunks/{chunk-B3KGZCQN.js → chunk-7YBZGNEC.js} +3 -3
  171. /package/chunks/{chunk-YWEW33JY.js → chunk-OMH3276Y.js} +0 -0
@@ -1,52 +1,22 @@
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";
15
3
  import {
16
4
  DASHSCOPE_PROXY_BASE_URL,
17
5
  DEFAULT_DASHSCOPE_BASE_URL,
18
6
  DEFAULT_MAX_RETRIES,
19
- DEFAULT_STREAM_IDLE_TIMEOUT_MS,
20
- MAX_STREAM_IDLE_TIMEOUT_MS,
21
- QWEN_STREAM_IDLE_TIMEOUT_MS_ENV,
22
7
  resolveRequestTimeout
23
- } from "./chunk-FEOZBUMT.js";
8
+ } from "./chunk-GLNBDYUX.js";
24
9
  import {
25
- createChildAbortController
26
- } from "./chunk-DJ2GSRLV.js";
27
- import {
28
- buildRuntimeFetchOptions,
29
- redactProxyError
10
+ buildRuntimeFetchOptions
30
11
  } from "./chunk-6EFTQYW7.js";
31
12
  import {
32
13
  defaultOutputCeiling,
33
- getToolCallPreparations,
34
14
  hasExplicitOutputLimit,
35
15
  parsePositiveIntegerEnvValue,
36
- reconcileMaxTokens,
37
- runtimeDiagnostics,
38
- safeJsonParse,
39
16
  tokenLimit
40
17
  } from "./chunk-MAQQGNQ5.js";
41
18
  import {
42
- GenerateContentResponse
43
- } from "./chunk-TYQMGACW.js";
44
- import {
45
- createDebugLogger,
46
- getErrorMessage,
47
- getErrorStatus,
48
- getErrorType,
49
- isAbortError
19
+ createDebugLogger
50
20
  } from "./chunk-C27BYUX6.js";
51
21
  import {
52
22
  init_esbuild_shims
@@ -55,24 +25,6 @@ import {
55
25
  __name
56
26
  } from "./chunk-J2S4EL5Y.js";
57
27
 
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
-
76
28
  // node_modules/openai/client.mjs
77
29
  init_esbuild_shims();
78
30
 
@@ -118,12 +70,12 @@ init_esbuild_shims();
118
70
 
119
71
  // node_modules/openai/internal/errors.mjs
120
72
  init_esbuild_shims();
121
- function isAbortError2(err) {
73
+ function isAbortError(err) {
122
74
  return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
123
75
  ("name" in err && err.name === "AbortError" || // Expo fetch
124
76
  "message" in err && String(err.message).includes("FetchRequestCanceledException"));
125
77
  }
126
- __name(isAbortError2, "isAbortError");
78
+ __name(isAbortError, "isAbortError");
127
79
  var castToError = /* @__PURE__ */ __name((err) => {
128
80
  if (err instanceof Error)
129
81
  return err;
@@ -1228,7 +1180,7 @@ var Stream = class _Stream {
1228
1180
  }
1229
1181
  done = true;
1230
1182
  } catch (e) {
1231
- if (isAbortError2(e))
1183
+ if (isAbortError(e))
1232
1184
  return;
1233
1185
  throw e;
1234
1186
  } finally {
@@ -1273,7 +1225,7 @@ var Stream = class _Stream {
1273
1225
  }
1274
1226
  done = true;
1275
1227
  } catch (e) {
1276
- if (isAbortError2(e))
1228
+ if (isAbortError(e))
1277
1229
  return;
1278
1230
  throw e;
1279
1231
  } finally {
@@ -6667,7 +6619,7 @@ var OpenAI = class {
6667
6619
  if (options.signal?.aborted) {
6668
6620
  throw new APIUserAbortError();
6669
6621
  }
6670
- const isTimeout = isAbortError2(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
6622
+ const isTimeout = isAbortError(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
6671
6623
  if (retriesRemaining) {
6672
6624
  loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
6673
6625
  loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails({
@@ -6917,10 +6869,14 @@ OpenAI.Responses = Responses;
6917
6869
  OpenAI.Evals = Evals;
6918
6870
  OpenAI.Containers = Containers;
6919
6871
 
6872
+ // node_modules/openai/index.mjs
6873
+ init_esbuild_shims();
6874
+
6920
6875
  // node_modules/openai/azure.mjs
6921
6876
  init_esbuild_shims();
6922
6877
 
6923
6878
  // packages/core/src/core/openaiContentGenerator/provider/default.ts
6879
+ init_esbuild_shims();
6924
6880
  function shouldMirrorReasoningContentForQwen3(model) {
6925
6881
  return model.toLowerCase().includes("qwen3");
6926
6882
  }
@@ -7056,40 +7012,14 @@ var DefaultOpenAICompatibleProvider = class {
7056
7012
  }
7057
7013
  };
7058
7014
 
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
-
7090
7015
  // packages/core/src/core/openaiContentGenerator/provider/dashscope.ts
7091
7016
  init_esbuild_shims();
7092
7017
  var debugLogger = createDebugLogger("DashScopeOpenAICompatibleProvider");
7018
+ var DASHSCOPE_REGIONAL_HOSTS = [
7019
+ "dashscope.aliyuncs.com",
7020
+ "dashscope-intl.aliyuncs.com",
7021
+ "dashscope-us.aliyuncs.com"
7022
+ ];
7093
7023
  var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider extends DefaultOpenAICompatibleProvider {
7094
7024
  static {
7095
7025
  __name(this, "DashScopeOpenAICompatibleProvider");
@@ -7102,7 +7032,7 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7102
7032
  }
7103
7033
  /**
7104
7034
  * Determines whether to use the DashScope-compatible provider.
7105
- * Covers dashscope.aliyuncs.com, dashscope-intl.aliyuncs.com,
7035
+ * Covers the official regional hosts (DASHSCOPE_REGIONAL_HOSTS),
7106
7036
  * Token Plan endpoints under token-plan.<region>.maas.aliyuncs.com,
7107
7037
  * internal Alibaba domains (*.alibaba-inc.com, *.aliyun-inc.com),
7108
7038
  * and proxy matches.
@@ -7122,7 +7052,9 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7122
7052
  } catch {
7123
7053
  hostname = null;
7124
7054
  }
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"));
7055
+ const isDashscopeOrigin = hostname !== null && DASHSCOPE_REGIONAL_HOSTS.some(
7056
+ (host) => hostname === host || hostname.endsWith("." + host)
7057
+ );
7126
7058
  const isTokenPlanOrigin = hostname !== null && hostname.startsWith("token-plan.") && hostname.endsWith(".maas.aliyuncs.com");
7127
7059
  const isInternalOrigin = hostname !== null && (hostname.endsWith(".alibaba-inc.com") || hostname.endsWith(".aliyun-inc.com"));
7128
7060
  const normalizedProxyUrl = DASHSCOPE_PROXY_BASE_URL?.endsWith("/") ? DASHSCOPE_PROXY_BASE_URL.slice(0, -1) : DASHSCOPE_PROXY_BASE_URL;
@@ -7450,1679 +7382,9 @@ var DashScopeOpenAICompatibleProvider = class _DashScopeOpenAICompatibleProvider
7450
7382
  }
7451
7383
  };
7452
7384
 
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
-
9112
7385
  export {
9113
- DashScopeOpenAICompatibleProvider,
9114
- DeepSeekOpenAICompatibleProvider,
9115
- MiniMaxOpenAICompatibleProvider,
9116
- MistralOpenAICompatibleProvider,
9117
- MiMoOpenAICompatibleProvider,
9118
- ContentGenerationPipeline,
9119
- EnhancedErrorHandler,
9120
- OpenAIContentGenerator,
9121
- createOpenAIContentGenerator,
9122
- determineProvider
7386
+ OpenAI,
7387
+ DefaultOpenAICompatibleProvider,
7388
+ DASHSCOPE_REGIONAL_HOSTS,
7389
+ DashScopeOpenAICompatibleProvider
9123
7390
  };
9124
- /**
9125
- * @license
9126
- * Copyright 2025 Qwen
9127
- * SPDX-License-Identifier: Apache-2.0
9128
- */