@omnicross/core 0.1.4 → 0.1.6

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 (204) hide show
  1. package/dist/ApiConverter.cjs +2 -2
  2. package/dist/ApiConverter.js +1 -1
  3. package/dist/{CompletionService-DdWaAxq0.d.ts → CompletionService-C3BX0Ovy.d.ts} +4 -3
  4. package/dist/{CompletionService-D3a47vdU.d.cts → CompletionService-kNA17cfI.d.cts} +4 -3
  5. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +7 -5
  6. package/dist/auth/GeminiCodeAssistProjectResolver.js +5 -3
  7. package/dist/{chunk-HRRYG2AX.js → chunk-23S5OPIO.js} +10 -1
  8. package/dist/chunk-25GXJCEZ.cjs +40 -0
  9. package/dist/chunk-2JYRIADS.js +40 -0
  10. package/dist/chunk-3Z5BQZFM.cjs +52 -0
  11. package/dist/{chunk-4VAVYUZS.cjs → chunk-4VLRHHFE.cjs} +82 -40
  12. package/dist/{chunk-VACWOIRE.cjs → chunk-4VZX5F4T.cjs} +39 -15
  13. package/dist/{chunk-FTQ7IQUC.js → chunk-6CL5HTPQ.js} +52 -10
  14. package/dist/chunk-6QQG7YG3.cjs +153 -0
  15. package/dist/{chunk-SU2GCLAC.cjs → chunk-6VUQPOV3.cjs} +359 -60
  16. package/dist/chunk-7AK7B36B.cjs +44 -0
  17. package/dist/{chunk-5ZQBEOMD.js → chunk-AT7B7SOZ.js} +25 -2
  18. package/dist/{chunk-IK3KE3AU.js → chunk-DE2SRBFZ.js} +1 -1
  19. package/dist/chunk-DLXZEZWO.cjs +285 -0
  20. package/dist/{chunk-UHGVBFU3.js → chunk-EBLFCNPY.js} +38 -14
  21. package/dist/chunk-EJLH6NFT.cjs +166 -0
  22. package/dist/chunk-HVBBDBS3.cjs +350 -0
  23. package/dist/{chunk-7Y47UCF2.js → chunk-IFXJ2BG7.js} +5 -38
  24. package/dist/{chunk-46ZIFWYG.cjs → chunk-IIRPUVPH.cjs} +7 -1
  25. package/dist/{chunk-YGXJGRFI.cjs → chunk-KBM2W6UY.cjs} +111 -24
  26. package/dist/{chunk-OCEUVQHW.cjs → chunk-KCVJWJST.cjs} +73 -3
  27. package/dist/chunk-LB6EBS6Y.js +69 -0
  28. package/dist/{chunk-C7PSERMH.js → chunk-LVUCAWMK.js} +1 -1
  29. package/dist/chunk-MKF46GNZ.js +350 -0
  30. package/dist/{chunk-HYN75H6G.cjs → chunk-MUHWHQVM.cjs} +1 -1
  31. package/dist/{chunk-Z7Y2NPHY.js → chunk-N5T4M4GU.js} +1 -1
  32. package/dist/{chunk-TIER4SUC.js → chunk-OEWZUX4G.js} +346 -47
  33. package/dist/chunk-OF3BECU2.cjs +69 -0
  34. package/dist/{chunk-RSJ3TWJQ.cjs → chunk-OKMJLEXX.cjs} +5 -5
  35. package/dist/chunk-OPRS4IQZ.js +153 -0
  36. package/dist/{chunk-XK5CIRMQ.js → chunk-SIZQQD6T.js} +72 -2
  37. package/dist/{chunk-DKPXN34V.cjs → chunk-SQYVORNP.cjs} +1334 -510
  38. package/dist/chunk-SYQF7OIR.js +52 -0
  39. package/dist/{chunk-S4WBV25P.js → chunk-TOVPMMHM.js} +111 -24
  40. package/dist/{chunk-QYTT6GE3.js → chunk-UDCC7EMR.js} +1093 -269
  41. package/dist/{chunk-E3UCVHLP.cjs → chunk-UNWKG6EI.cjs} +5 -38
  42. package/dist/{chunk-ZLX3KGXX.js → chunk-UX7VWA46.js} +135 -23
  43. package/dist/{chunk-7YN22L2H.cjs → chunk-V4TXMEJS.cjs} +5 -5
  44. package/dist/chunk-VRFBB5DB.js +44 -0
  45. package/dist/chunk-WB6PH56J.js +166 -0
  46. package/dist/{chunk-G2UTNSGU.js → chunk-WNKWAEUR.js} +7 -1
  47. package/dist/{chunk-SUEGJ75D.cjs → chunk-WYTEQ4Q5.cjs} +25 -2
  48. package/dist/{chunk-5ENKBSWO.js → chunk-YJVHCHQX.js} +42 -6
  49. package/dist/{chunk-VQY5W4YW.cjs → chunk-YK57NMIF.cjs} +44 -8
  50. package/dist/{chunk-KFI44N2R.cjs → chunk-YNJNTCSQ.cjs} +10 -1
  51. package/dist/completion/ApiKeyPoolService.cjs +12 -0
  52. package/dist/completion/ApiKeyPoolService.d.cts +6 -0
  53. package/dist/completion/ApiKeyPoolService.d.ts +6 -0
  54. package/dist/completion/ApiKeyPoolService.js +12 -0
  55. package/dist/completion/CompletionService.cjs +27 -24
  56. package/dist/completion/CompletionService.d.cts +2 -1
  57. package/dist/completion/CompletionService.d.ts +2 -1
  58. package/dist/completion/CompletionService.js +26 -23
  59. package/dist/completion.cjs +27 -24
  60. package/dist/completion.d.cts +2 -1
  61. package/dist/completion.d.ts +2 -1
  62. package/dist/completion.js +26 -23
  63. package/dist/index.cjs +53 -29
  64. package/dist/index.d.cts +8 -8
  65. package/dist/index.d.ts +8 -8
  66. package/dist/index.js +56 -32
  67. package/dist/{keyPolicy-Cp0FntZl.d.cts → keyPolicy-zdWTu3CQ.d.cts} +1 -1
  68. package/dist/{keyPolicy-Cp0FntZl.d.ts → keyPolicy-zdWTu3CQ.d.ts} +1 -1
  69. package/dist/outbound-api/auditCapture.cjs +2 -2
  70. package/dist/outbound-api/auditCapture.d.cts +5 -3
  71. package/dist/outbound-api/auditCapture.d.ts +5 -3
  72. package/dist/outbound-api/auditCapture.js +1 -1
  73. package/dist/outbound-api/quotaWarn.d.cts +1 -1
  74. package/dist/outbound-api/quotaWarn.d.ts +1 -1
  75. package/dist/outbound-api/routeResolver.cjs +2 -2
  76. package/dist/outbound-api/routeResolver.d.cts +4 -3
  77. package/dist/outbound-api/routeResolver.d.ts +4 -3
  78. package/dist/outbound-api/routeResolver.js +1 -1
  79. package/dist/outbound-api/subscriptionRegistryPort.d.cts +1 -0
  80. package/dist/outbound-api/subscriptionRegistryPort.d.ts +1 -0
  81. package/dist/outbound-api/types.d.cts +3 -2
  82. package/dist/outbound-api/types.d.ts +3 -2
  83. package/dist/outbound-api.cjs +49 -25
  84. package/dist/outbound-api.d.cts +127 -85
  85. package/dist/outbound-api.d.ts +127 -85
  86. package/dist/outbound-api.js +52 -28
  87. package/dist/pipeline/AccountAllowanceScheduling.cjs +15 -0
  88. package/dist/pipeline/AccountAllowanceScheduling.d.cts +90 -0
  89. package/dist/pipeline/AccountAllowanceScheduling.d.ts +90 -0
  90. package/dist/pipeline/AccountAllowanceScheduling.js +15 -0
  91. package/dist/pipeline/AccountAllowanceStore.cjs +20 -0
  92. package/dist/pipeline/AccountAllowanceStore.d.cts +77 -0
  93. package/dist/pipeline/AccountAllowanceStore.d.ts +77 -0
  94. package/dist/pipeline/AccountAllowanceStore.js +20 -0
  95. package/dist/pipeline/AuthSource.d.cts +11 -2
  96. package/dist/pipeline/AuthSource.d.ts +11 -2
  97. package/dist/pipeline/BoundAccountSelectionError.cjs +10 -0
  98. package/dist/pipeline/BoundAccountSelectionError.d.cts +28 -0
  99. package/dist/pipeline/BoundAccountSelectionError.d.ts +28 -0
  100. package/dist/pipeline/BoundAccountSelectionError.js +10 -0
  101. package/dist/pipeline/LlmConfigProviderAuth.d.cts +1 -0
  102. package/dist/pipeline/LlmConfigProviderAuth.d.ts +1 -0
  103. package/dist/pipeline/SubscriptionAccountHealth.cjs +4 -2
  104. package/dist/pipeline/SubscriptionAccountHealth.d.cts +34 -6
  105. package/dist/pipeline/SubscriptionAccountHealth.d.ts +34 -6
  106. package/dist/pipeline/SubscriptionAccountHealth.js +3 -1
  107. package/dist/pipeline/SubscriptionAuthSource.cjs +5 -2
  108. package/dist/pipeline/SubscriptionAuthSource.d.cts +1 -0
  109. package/dist/pipeline/SubscriptionAuthSource.d.ts +1 -0
  110. package/dist/pipeline/SubscriptionAuthSource.js +4 -1
  111. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +8 -3
  112. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +8 -3
  113. package/dist/pipeline/executeProviderCall.cjs +2 -2
  114. package/dist/pipeline/executeProviderCall.d.cts +8 -3
  115. package/dist/pipeline/executeProviderCall.d.ts +8 -3
  116. package/dist/pipeline/executeProviderCall.js +1 -1
  117. package/dist/pipeline/resolveProviderChain.d.cts +2 -3
  118. package/dist/pipeline/resolveProviderChain.d.ts +2 -3
  119. package/dist/pipeline/resolveSubscriptionChain.d.cts +1 -0
  120. package/dist/pipeline/resolveSubscriptionChain.d.ts +1 -0
  121. package/dist/pipeline/upstreamFetch.cjs +4 -2
  122. package/dist/pipeline/upstreamFetch.d.cts +6 -0
  123. package/dist/pipeline/upstreamFetch.d.ts +6 -0
  124. package/dist/pipeline/upstreamFetch.js +3 -1
  125. package/dist/pipeline/upstreamTrace.cjs +14 -0
  126. package/dist/pipeline/upstreamTrace.d.cts +85 -0
  127. package/dist/pipeline/upstreamTrace.d.ts +85 -0
  128. package/dist/pipeline/upstreamTrace.js +14 -0
  129. package/dist/ports/pricing-store.d.cts +4 -3
  130. package/dist/ports/pricing-store.d.ts +4 -3
  131. package/dist/ports.d.cts +4 -3
  132. package/dist/ports.d.ts +4 -3
  133. package/dist/provider-proxy/ProviderProxy.cjs +27 -24
  134. package/dist/provider-proxy/ProviderProxy.d.cts +1 -0
  135. package/dist/provider-proxy/ProviderProxy.d.ts +1 -0
  136. package/dist/provider-proxy/ProviderProxy.js +26 -23
  137. package/dist/provider-proxy/ingress/providerProxyShared.cjs +31 -24
  138. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +50 -5
  139. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +50 -5
  140. package/dist/provider-proxy/ingress/providerProxyShared.js +30 -23
  141. package/dist/provider-proxy/matchText.cjs +4 -2
  142. package/dist/provider-proxy/matchText.d.cts +41 -6
  143. package/dist/provider-proxy/matchText.d.ts +41 -6
  144. package/dist/provider-proxy/matchText.js +3 -1
  145. package/dist/provider-proxy/types.d.cts +30 -2
  146. package/dist/provider-proxy/types.d.ts +30 -2
  147. package/dist/provider-proxy.cjs +27 -24
  148. package/dist/provider-proxy.d.cts +1 -0
  149. package/dist/provider-proxy.d.ts +1 -0
  150. package/dist/provider-proxy.js +26 -23
  151. package/dist/{routeResolver-C4T7yClx.d.ts → routeResolver-CHTv_Bs5.d.ts} +1 -1
  152. package/dist/{routeResolver-CB3tvJKy.d.cts → routeResolver-kepxnfcC.d.cts} +1 -1
  153. package/dist/transformer/TransformerChainExecutor.cjs +2 -2
  154. package/dist/transformer/TransformerChainExecutor.js +1 -1
  155. package/dist/transformer/transformers/AnthropicTransformer.cjs +2 -2
  156. package/dist/transformer/transformers/AnthropicTransformer.js +1 -1
  157. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
  158. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
  159. package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
  160. package/dist/transformer/transformers/GeminiTransformer.js +2 -2
  161. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
  162. package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +1 -1
  163. package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +1 -1
  164. package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
  165. package/dist/transformer/transformers/OpenAITransformer.cjs +6 -0
  166. package/dist/transformer/transformers/OpenAITransformer.d.cts +68 -0
  167. package/dist/transformer/transformers/OpenAITransformer.d.ts +68 -0
  168. package/dist/transformer/transformers/OpenAITransformer.js +6 -0
  169. package/dist/transformer/transformers.cjs +8 -14
  170. package/dist/transformer/transformers.d.cts +12 -48
  171. package/dist/transformer/transformers.d.ts +12 -48
  172. package/dist/transformer/transformers.js +11 -17
  173. package/dist/transformer/types.d.cts +17 -0
  174. package/dist/transformer/types.d.ts +17 -0
  175. package/dist/transformer.cjs +11 -12
  176. package/dist/transformer.d.cts +1 -2
  177. package/dist/transformer.d.ts +1 -2
  178. package/dist/transformer.js +11 -12
  179. package/dist/{types-B8Arpxn0.d.cts → types-H3wGZSOo.d.cts} +134 -7
  180. package/dist/{types-lgPYQuZS.d.ts → types-hsoKrVQS.d.ts} +134 -7
  181. package/dist/usage/pricing-engine.cjs +2 -2
  182. package/dist/usage/pricing-engine.d.cts +9 -1
  183. package/dist/usage/pricing-engine.d.ts +9 -1
  184. package/dist/usage/pricing-engine.js +1 -1
  185. package/dist/usage.cjs +2 -2
  186. package/dist/usage.js +1 -1
  187. package/package.json +1 -1
  188. package/dist/chunk-C72S6TTV.cjs +0 -49
  189. package/dist/chunk-DWKQZ2SK.cjs +0 -254
  190. package/dist/chunk-IAXWICZU.js +0 -69
  191. package/dist/chunk-QWBWGODS.cjs +0 -69
  192. package/dist/chunk-RGTR7CIO.cjs +0 -235
  193. package/dist/chunk-VPBAUQ2M.js +0 -235
  194. package/dist/chunk-YMFAJFQT.cjs +0 -173
  195. package/dist/chunk-Z7LUNECE.js +0 -49
  196. package/dist/chunk-ZJZAOKI7.js +0 -254
  197. package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +0 -6
  198. package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +0 -51
  199. package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +0 -51
  200. package/dist/transformer/transformers/OpenCodeGoTransformer.js +0 -6
  201. package/dist/transformer/transformers/ReasoningTransformer.cjs +0 -6
  202. package/dist/transformer/transformers/ReasoningTransformer.d.cts +0 -47
  203. package/dist/transformer/transformers/ReasoningTransformer.d.ts +0 -47
  204. package/dist/transformer/transformers/ReasoningTransformer.js +0 -6
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkSUEGJ75Dcjs = require('./chunk-SUEGJ75D.cjs');
12
+ var _chunkWYTEQ4Q5cjs = require('./chunk-WYTEQ4Q5.cjs');
13
13
 
14
14
 
15
15
 
@@ -21,4 +21,4 @@ var _chunkSUEGJ75Dcjs = require('./chunk-SUEGJ75D.cjs');
21
21
 
22
22
 
23
23
 
24
- exports.convertAnthropicRequestToOpenAI = _chunkSUEGJ75Dcjs.convertAnthropicRequestToOpenAI; exports.convertAnthropicStreamToOpenAI = _chunkSUEGJ75Dcjs.convertAnthropicStreamToOpenAI; exports.convertAnthropicToOpenAI = _chunkSUEGJ75Dcjs.convertAnthropicToOpenAI; exports.convertAnthropicToOpenAIWithThinking = _chunkSUEGJ75Dcjs.convertAnthropicToOpenAIWithThinking; exports.convertOpenAIResponseToAnthropic = _chunkSUEGJ75Dcjs.convertOpenAIResponseToAnthropic; exports.convertOpenAIStreamToAnthropic = _chunkSUEGJ75Dcjs.convertOpenAIStreamToAnthropic; exports.convertOpenAIToAnthropic = _chunkSUEGJ75Dcjs.convertOpenAIToAnthropic; exports.convertOpenAIToAnthropicWithThinking = _chunkSUEGJ75Dcjs.convertOpenAIToAnthropicWithThinking; exports.hasImageContent = _chunkSUEGJ75Dcjs.hasImageContent; exports.hasThinkingEnabled = _chunkSUEGJ75Dcjs.hasThinkingEnabled;
24
+ exports.convertAnthropicRequestToOpenAI = _chunkWYTEQ4Q5cjs.convertAnthropicRequestToOpenAI; exports.convertAnthropicStreamToOpenAI = _chunkWYTEQ4Q5cjs.convertAnthropicStreamToOpenAI; exports.convertAnthropicToOpenAI = _chunkWYTEQ4Q5cjs.convertAnthropicToOpenAI; exports.convertAnthropicToOpenAIWithThinking = _chunkWYTEQ4Q5cjs.convertAnthropicToOpenAIWithThinking; exports.convertOpenAIResponseToAnthropic = _chunkWYTEQ4Q5cjs.convertOpenAIResponseToAnthropic; exports.convertOpenAIStreamToAnthropic = _chunkWYTEQ4Q5cjs.convertOpenAIStreamToAnthropic; exports.convertOpenAIToAnthropic = _chunkWYTEQ4Q5cjs.convertOpenAIToAnthropic; exports.convertOpenAIToAnthropicWithThinking = _chunkWYTEQ4Q5cjs.convertOpenAIToAnthropicWithThinking; exports.hasImageContent = _chunkWYTEQ4Q5cjs.hasImageContent; exports.hasThinkingEnabled = _chunkWYTEQ4Q5cjs.hasThinkingEnabled;
@@ -9,7 +9,7 @@ import {
9
9
  convertOpenAIToAnthropicWithThinking,
10
10
  hasImageContent,
11
11
  hasThinkingEnabled
12
- } from "./chunk-5ZQBEOMD.js";
12
+ } from "./chunk-AT7B7SOZ.js";
13
13
  export {
14
14
  convertAnthropicRequestToOpenAI,
15
15
  convertAnthropicStreamToOpenAI,
@@ -174,9 +174,10 @@ declare class CompletionService {
174
174
  * Resolve effective max_tokens value with priority:
175
175
  * 1. Session settings (if provided)
176
176
  * 2. Global model parameters (if enabled)
177
- * 3. Model's maxTokens from provider config
178
- * 4. Discovered models cache (from API)
179
- * 5. undefined - let API use its default
177
+ * 3. undefined - let API use its default
178
+ *
179
+ * Provider and discovery maxTokens values are capability metadata, not
180
+ * implicit per-request output limits.
180
181
  */
181
182
  resolveEffectiveMaxTokens(providerId: string, modelId: string, sessionMaxTokens?: number): Promise<number | undefined>;
182
183
  /**
@@ -174,9 +174,10 @@ declare class CompletionService {
174
174
  * Resolve effective max_tokens value with priority:
175
175
  * 1. Session settings (if provided)
176
176
  * 2. Global model parameters (if enabled)
177
- * 3. Model's maxTokens from provider config
178
- * 4. Discovered models cache (from API)
179
- * 5. undefined - let API use its default
177
+ * 3. undefined - let API use its default
178
+ *
179
+ * Provider and discovery maxTokens values are capability metadata, not
180
+ * implicit per-request output limits.
180
181
  */
181
182
  resolveEffectiveMaxTokens(providerId: string, modelId: string, sessionMaxTokens?: number): Promise<number | undefined>;
182
183
  /**
@@ -1,11 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
3
 
4
- var _chunkRSJ3TWJQcjs = require('../chunk-RSJ3TWJQ.cjs');
5
- require('../chunk-YGXJGRFI.cjs');
4
+ var _chunkOKMJLEXXcjs = require('../chunk-OKMJLEXX.cjs');
5
+ require('../chunk-KBM2W6UY.cjs');
6
6
 
7
7
 
8
- var _chunkOCEUVQHWcjs = require('../chunk-OCEUVQHW.cjs');
8
+ var _chunkKCVJWJSTcjs = require('../chunk-KCVJWJST.cjs');
9
+ require('../chunk-3Z5BQZFM.cjs');
10
+ require('../chunk-HVBBDBS3.cjs');
9
11
 
10
12
  // src/auth/GeminiCodeAssistProjectResolver.ts
11
13
  var FREE_TIER_ID = "free-tier";
@@ -25,7 +27,7 @@ var GeminiCodeAssistHandshakeError = class extends Error {
25
27
  var GeminiCodeAssistProjectResolver = (_class = class {
26
28
  // upstream-proxy: the Code Assist handshake is upstream egress → honor the
27
29
  // gemini proxy by default (still injectable for tests).
28
- constructor(fetchImpl = (url, init) => _chunkOCEUVQHWcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
30
+ constructor(fetchImpl = (url, init) => _chunkKCVJWJSTcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
29
31
  this.fetchImpl = fetchImpl;
30
32
  }
31
33
 
@@ -59,7 +61,7 @@ var GeminiCodeAssistProjectResolver = (_class = class {
59
61
  return run;
60
62
  }
61
63
  codeAssistUrl(method) {
62
- return `${_chunkRSJ3TWJQcjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkRSJ3TWJQcjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
64
+ return `${_chunkOKMJLEXXcjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkOKMJLEXXcjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
63
65
  }
64
66
  /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
65
67
  seedProjectId() {
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  resolveCodeAssistApiVersion,
3
3
  resolveCodeAssistEndpoint
4
- } from "../chunk-Z7Y2NPHY.js";
5
- import "../chunk-S4WBV25P.js";
4
+ } from "../chunk-N5T4M4GU.js";
5
+ import "../chunk-TOVPMMHM.js";
6
6
  import {
7
7
  fetchUpstream
8
- } from "../chunk-XK5CIRMQ.js";
8
+ } from "../chunk-SIZQQD6T.js";
9
+ import "../chunk-SYQF7OIR.js";
10
+ import "../chunk-MKF46GNZ.js";
9
11
 
10
12
  // src/auth/GeminiCodeAssistProjectResolver.ts
11
13
  var FREE_TIER_ID = "free-tier";
@@ -1,6 +1,12 @@
1
1
  import {
2
2
  serializeError
3
3
  } from "./chunk-AVYJ4YBN.js";
4
+ import {
5
+ isAccountAllowanceExhaustedError
6
+ } from "./chunk-OPRS4IQZ.js";
7
+ import {
8
+ isBoundAccountSelectionError
9
+ } from "./chunk-2JYRIADS.js";
4
10
 
5
11
  // src/pipeline/SubscriptionAuthSource.ts
6
12
  function stripAuthHeaders(headers) {
@@ -34,9 +40,12 @@ var SubscriptionAuthSource = class {
34
40
  resolvedModel: hints.model,
35
41
  sessionKey: hints.sessionKey,
36
42
  reportSelection: hints.reportSelection,
37
- preferredAccountId: hints.preferredAccountId
43
+ preferredAccountId: hints.preferredAccountId,
44
+ preferredAccountGroup: hints.preferredAccountGroup,
45
+ boundAccountFallbackPolicy: hints.boundAccountFallbackPolicy
38
46
  });
39
47
  } catch (err) {
48
+ if (isAccountAllowanceExhaustedError(err) || isBoundAccountSelectionError(err)) throw err;
40
49
  console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", serializeError(err));
41
50
  }
42
51
  }
@@ -0,0 +1,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;// src/pipeline/BoundAccountSelectionError.ts
2
+ var FAILURE_MESSAGES = {
3
+ unavailable: "Bound subscription account is unavailable",
4
+ "not-found": "Bound subscription account was not found",
5
+ disabled: "Bound subscription account is disabled",
6
+ unhealthy: "Bound subscription account is unhealthy",
7
+ "model-incompatible": "Bound subscription account cannot serve the requested model",
8
+ "allowance-paused": "Bound subscription account is paused by the allowance policy",
9
+ "empty-token": "Bound subscription account has no usable token"
10
+ };
11
+ function boundAccountSelectionMessage(reason) {
12
+ return FAILURE_MESSAGES[reason];
13
+ }
14
+ var BoundAccountSelectionError = (_class = class extends Error {
15
+ constructor(providerId, reason, resumeAt) {
16
+ super(boundAccountSelectionMessage(reason));_class.prototype.__init.call(this);;
17
+ this.providerId = providerId;
18
+ this.reason = reason;
19
+ this.resumeAt = resumeAt;
20
+ this.name = "BoundAccountSelectionError";
21
+ this.status = reason === "allowance-paused" ? 429 : 503;
22
+ }
23
+
24
+
25
+
26
+ __init() {this.code = "bound_account_unavailable"}
27
+
28
+ }, _class);
29
+ function isBoundAccountSelectionError(error) {
30
+ if (error instanceof BoundAccountSelectionError) return true;
31
+ if (!error || typeof error !== "object") return false;
32
+ const value = error;
33
+ return value.code === "bound_account_unavailable" && (value.status === 429 || value.status === 503) && typeof value.reason === "string" && Object.prototype.hasOwnProperty.call(FAILURE_MESSAGES, value.reason);
34
+ }
35
+
36
+
37
+
38
+
39
+
40
+ exports.boundAccountSelectionMessage = boundAccountSelectionMessage; exports.BoundAccountSelectionError = BoundAccountSelectionError; exports.isBoundAccountSelectionError = isBoundAccountSelectionError;
@@ -0,0 +1,40 @@
1
+ // src/pipeline/BoundAccountSelectionError.ts
2
+ var FAILURE_MESSAGES = {
3
+ unavailable: "Bound subscription account is unavailable",
4
+ "not-found": "Bound subscription account was not found",
5
+ disabled: "Bound subscription account is disabled",
6
+ unhealthy: "Bound subscription account is unhealthy",
7
+ "model-incompatible": "Bound subscription account cannot serve the requested model",
8
+ "allowance-paused": "Bound subscription account is paused by the allowance policy",
9
+ "empty-token": "Bound subscription account has no usable token"
10
+ };
11
+ function boundAccountSelectionMessage(reason) {
12
+ return FAILURE_MESSAGES[reason];
13
+ }
14
+ var BoundAccountSelectionError = class extends Error {
15
+ constructor(providerId, reason, resumeAt) {
16
+ super(boundAccountSelectionMessage(reason));
17
+ this.providerId = providerId;
18
+ this.reason = reason;
19
+ this.resumeAt = resumeAt;
20
+ this.name = "BoundAccountSelectionError";
21
+ this.status = reason === "allowance-paused" ? 429 : 503;
22
+ }
23
+ providerId;
24
+ reason;
25
+ resumeAt;
26
+ code = "bound_account_unavailable";
27
+ status;
28
+ };
29
+ function isBoundAccountSelectionError(error) {
30
+ if (error instanceof BoundAccountSelectionError) return true;
31
+ if (!error || typeof error !== "object") return false;
32
+ const value = error;
33
+ return value.code === "bound_account_unavailable" && (value.status === 429 || value.status === 503) && typeof value.reason === "string" && Object.prototype.hasOwnProperty.call(FAILURE_MESSAGES, value.reason);
34
+ }
35
+
36
+ export {
37
+ boundAccountSelectionMessage,
38
+ BoundAccountSelectionError,
39
+ isBoundAccountSelectionError
40
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/pipeline/upstreamTrace.ts
2
+ var _promises = require('fs/promises');
3
+ var _path = require('path');
4
+ var tracePath = null;
5
+ var SECRET_HEADER_NAMES = /* @__PURE__ */ new Set([
6
+ "authorization",
7
+ "api-key",
8
+ "x-api-key",
9
+ "x-goog-api-key"
10
+ ]);
11
+ function setUpstreamTracePath(path) {
12
+ tracePath = typeof path === "string" && path.trim() ? path.trim() : null;
13
+ }
14
+ function getUpstreamTracePath() {
15
+ return tracePath;
16
+ }
17
+ function redactHeaders(headers) {
18
+ const out = {};
19
+ if (!headers) return out;
20
+ let entries;
21
+ if (Array.isArray(headers)) {
22
+ entries = headers;
23
+ } else if (typeof headers.entries === "function") {
24
+ entries = Array.from(headers.entries());
25
+ } else {
26
+ entries = Object.entries(headers);
27
+ }
28
+ for (const [key, value] of entries) {
29
+ out[key] = SECRET_HEADER_NAMES.has(key.toLowerCase()) ? "***REDACTED***" : String(value);
30
+ }
31
+ return out;
32
+ }
33
+ async function writeUpstreamTrace(record) {
34
+ const path = tracePath;
35
+ if (!path) return;
36
+ try {
37
+ await _promises.mkdir.call(void 0, _path.dirname.call(void 0, path), { recursive: true });
38
+ await _promises.appendFile.call(void 0, path, JSON.stringify(record) + "\n", "utf8");
39
+ } catch (e) {
40
+ }
41
+ }
42
+ function __resetUpstreamTraceForTests() {
43
+ tracePath = null;
44
+ }
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+ exports.setUpstreamTracePath = setUpstreamTracePath; exports.getUpstreamTracePath = getUpstreamTracePath; exports.redactHeaders = redactHeaders; exports.writeUpstreamTrace = writeUpstreamTrace; exports.__resetUpstreamTraceForTests = __resetUpstreamTraceForTests;
@@ -25,6 +25,40 @@ function formatBase64(data, mediaType) {
25
25
  if (data.startsWith("data:")) return data;
26
26
  return `data:${mediaType || "image/png"};base64,${data}`;
27
27
  }
28
+ function flattenToolResultContent(content) {
29
+ if (typeof content === "string") return content;
30
+ if (content == null) return "";
31
+ if (!Array.isArray(content)) return JSON.stringify(content);
32
+ const parts = [];
33
+ for (const block of content) {
34
+ if (typeof block === "string") {
35
+ parts.push(block);
36
+ continue;
37
+ }
38
+ if (!block || typeof block !== "object") continue;
39
+ const typed = block;
40
+ if (typed.type === "image" || typed.type === "image_url") {
41
+ parts.push("[image omitted]");
42
+ } else if (typeof typed.text === "string") {
43
+ parts.push(typed.text);
44
+ }
45
+ }
46
+ return parts.filter((text) => text !== "").join("\n");
47
+ }
48
+
49
+ // src/anthropicMaxTokens.ts
50
+ var _canonicalmodels = require('@omnicross/contracts/canonical-models');
51
+ var ANTHROPIC_FALLBACK_MAX_TOKENS = 128e3;
52
+ function resolveAnthropicMaxTokens(model, requested) {
53
+ if (typeof requested === "number" && Number.isFinite(requested) && requested > 0) {
54
+ return requested;
55
+ }
56
+ const canonical = model ? _optionalChain([_canonicalmodels.lookupCanonicalCapabilities.call(void 0, model), 'optionalAccess', _ => _.maxTokens]) : void 0;
57
+ if (typeof canonical === "number" && Number.isFinite(canonical) && canonical > 0) {
58
+ return canonical;
59
+ }
60
+ return ANTHROPIC_FALLBACK_MAX_TOKENS;
61
+ }
28
62
 
29
63
  // src/transformer/transformers/AnthropicRequestBuilder.ts
30
64
  function buildAnthropicRequestBody(request) {
@@ -46,7 +80,7 @@ function buildAnthropicRequestBody(request) {
46
80
  }
47
81
  if (msg.role === "assistant") {
48
82
  const content = [];
49
- if (_optionalChain([msg, 'access', _ => _.thinking, 'optionalAccess', _2 => _2.content])) {
83
+ if (_optionalChain([msg, 'access', _2 => _2.thinking, 'optionalAccess', _3 => _3.content])) {
50
84
  const block = {
51
85
  type: "thinking",
52
86
  thinking: msg.thinking.content
@@ -62,7 +96,7 @@ function buildAnthropicRequestBody(request) {
62
96
  content.push({ type: "text", text });
63
97
  }
64
98
  }
65
- if (_optionalChain([msg, 'access', _3 => _3.tool_calls, 'optionalAccess', _4 => _4.length])) {
99
+ if (_optionalChain([msg, 'access', _4 => _4.tool_calls, 'optionalAccess', _5 => _5.length])) {
66
100
  for (const tc of msg.tool_calls) {
67
101
  let input;
68
102
  try {
@@ -129,7 +163,11 @@ function buildAnthropicRequestBody(request) {
129
163
  const body = {
130
164
  model: request.model,
131
165
  messages: anthropicMessages,
132
- max_tokens: request.max_tokens || 4096,
166
+ // Anthropic requires this field, so an absent caller cap must resolve to
167
+ // the model's real ceiling — NOT a small constant, which would silently
168
+ // truncate long responses (and corrupt tool-call JSON mid-stream).
169
+ // See `resolveAnthropicMaxTokens`.
170
+ max_tokens: resolveAnthropicMaxTokens(request.model, request.max_tokens),
133
171
  stream: _nullishCoalesce(request.stream, () => ( false))
134
172
  };
135
173
  if (request.temperature !== void 0) {
@@ -138,7 +176,7 @@ function buildAnthropicRequestBody(request) {
138
176
  if (systemContent !== void 0) {
139
177
  body.system = systemContent;
140
178
  }
141
- if (_optionalChain([request, 'access', _5 => _5.tools, 'optionalAccess', _6 => _6.length])) {
179
+ if (_optionalChain([request, 'access', _6 => _6.tools, 'optionalAccess', _7 => _7.length])) {
142
180
  body.tools = request.tools.map((tool) => ({
143
181
  name: tool.function.name,
144
182
  description: tool.function.description || "",
@@ -146,7 +184,7 @@ function buildAnthropicRequestBody(request) {
146
184
  }));
147
185
  }
148
186
  const serverSideTools = request._serverSideTools;
149
- if (_optionalChain([serverSideTools, 'optionalAccess', _7 => _7.length])) {
187
+ if (_optionalChain([serverSideTools, 'optionalAccess', _8 => _8.length])) {
150
188
  body.tools = [...body.tools || [], ...serverSideTools];
151
189
  }
152
190
  if (request.tool_choice) {
@@ -160,7 +198,7 @@ function buildAnthropicRequestBody(request) {
160
198
  body.tool_choice = { type: "tool", name: request.tool_choice.function.name };
161
199
  }
162
200
  }
163
- if (_optionalChain([request, 'access', _8 => _8.reasoning, 'optionalAccess', _9 => _9.enabled])) {
201
+ if (_optionalChain([request, 'access', _9 => _9.reasoning, 'optionalAccess', _10 => _10.enabled])) {
164
202
  const budgetMap = { low: 2048, medium: 8192, high: 32768 };
165
203
  const budget = request.reasoning.max_tokens || budgetMap[request.reasoning.effort || "medium"] || 8192;
166
204
  body.thinking = { type: "enabled", budget_tokens: budget };
@@ -178,7 +216,7 @@ function convertAnthropicResponseToOpenAI(anthropicResponse) {
178
216
  const searchResults = content.filter((c) => c.type === "web_search_tool_result");
179
217
  for (const sr of searchResults) {
180
218
  const searches = sr.content;
181
- if (_optionalChain([searches, 'optionalAccess', _10 => _10.length])) {
219
+ if (_optionalChain([searches, 'optionalAccess', _11 => _11.length])) {
182
220
  const formatted = searches.map((s) => `[${s.title}](${s.url}): ${s.page_content || s.snippet || ""}`).join("\n");
183
221
  textParts.push(`
184
222
 
@@ -231,12 +269,20 @@ ${formatted}`);
231
269
  };
232
270
  }
233
271
  function convertOpenAIResponseToAnthropic(openaiResponse) {
234
- const choice = _optionalChain([openaiResponse, 'access', _11 => _11.choices, 'optionalAccess', _12 => _12[0]]);
272
+ const choice = _optionalChain([openaiResponse, 'access', _12 => _12.choices, 'optionalAccess', _13 => _13[0]]);
235
273
  if (!choice) {
236
274
  throw new Error("No choices found in OpenAI response");
237
275
  }
238
276
  const message = choice.message;
239
277
  const content = [];
278
+ const thinking = message.thinking;
279
+ if (_optionalChain([thinking, 'optionalAccess', _14 => _14.content])) {
280
+ content.push({
281
+ type: "thinking",
282
+ thinking: thinking.content,
283
+ signature: thinking.signature
284
+ });
285
+ }
240
286
  if (message.content) {
241
287
  content.push({
242
288
  type: "text",
@@ -244,7 +290,7 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
244
290
  });
245
291
  }
246
292
  const toolCalls = message.tool_calls;
247
- if (_optionalChain([toolCalls, 'optionalAccess', _13 => _13.length])) {
293
+ if (_optionalChain([toolCalls, 'optionalAccess', _15 => _15.length])) {
248
294
  for (const toolCall of toolCalls) {
249
295
  const func = toolCall.function;
250
296
  let parsedInput = {};
@@ -262,14 +308,6 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
262
308
  });
263
309
  }
264
310
  }
265
- const thinking = message.thinking;
266
- if (_optionalChain([thinking, 'optionalAccess', _14 => _14.content])) {
267
- content.push({
268
- type: "thinking",
269
- thinking: thinking.content,
270
- signature: thinking.signature
271
- });
272
- }
273
311
  const finishReason = choice.finish_reason;
274
312
  const stopReasonMapping = {
275
313
  stop: "end_turn",
@@ -278,7 +316,7 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
278
316
  content_filter: "stop_sequence"
279
317
  };
280
318
  const usage = openaiResponse.usage;
281
- const usageDetails = _optionalChain([usage, 'optionalAccess', _15 => _15.prompt_tokens_details]);
319
+ const usageDetails = _optionalChain([usage, 'optionalAccess', _16 => _16.prompt_tokens_details]);
282
320
  return {
283
321
  id: openaiResponse.id,
284
322
  type: "message",
@@ -288,9 +326,9 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
288
326
  stop_reason: stopReasonMapping[finishReason] || "end_turn",
289
327
  stop_sequence: null,
290
328
  usage: {
291
- input_tokens: (_optionalChain([usage, 'optionalAccess', _16 => _16.prompt_tokens]) || 0) - (_optionalChain([usageDetails, 'optionalAccess', _17 => _17.cached_tokens]) || 0),
292
- output_tokens: _optionalChain([usage, 'optionalAccess', _18 => _18.completion_tokens]) || 0,
293
- cache_read_input_tokens: _optionalChain([usageDetails, 'optionalAccess', _19 => _19.cached_tokens]) || 0
329
+ input_tokens: (_optionalChain([usage, 'optionalAccess', _17 => _17.prompt_tokens]) || 0) - (_optionalChain([usageDetails, 'optionalAccess', _18 => _18.cached_tokens]) || 0),
330
+ output_tokens: _optionalChain([usage, 'optionalAccess', _19 => _19.completion_tokens]) || 0,
331
+ cache_read_input_tokens: _optionalChain([usageDetails, 'optionalAccess', _20 => _20.cached_tokens]) || 0
294
332
  }
295
333
  };
296
334
  }
@@ -337,7 +375,10 @@ function transformAnthropicRequestToUnified(request) {
337
375
  for (const tool of toolParts) {
338
376
  messages.push({
339
377
  role: "tool",
340
- content: typeof tool.content === "string" ? tool.content : JSON.stringify(tool.content),
378
+ // Claude Code sends tool results as a block ARRAY; stringifying it
379
+ // fed the model the literal `[{"type":"text","text":"…"}]` envelope
380
+ // on every tool result.
381
+ content: flattenToolResultContent(tool.content),
341
382
  tool_call_id: tool.tool_use_id,
342
383
  cache_control: tool.cache_control
343
384
  });
@@ -393,7 +434,7 @@ function transformAnthropicRequestToUnified(request) {
393
434
  const thinkingPart = msg.content.find(
394
435
  (c) => c.type === "thinking"
395
436
  );
396
- if (_optionalChain([thinkingPart, 'optionalAccess', _20 => _20.thinking])) {
437
+ if (_optionalChain([thinkingPart, 'optionalAccess', _21 => _21.thinking])) {
397
438
  assistantMessage.thinking = {
398
439
  content: thinkingPart.thinking,
399
440
  signature: thinkingPart.signature
@@ -412,7 +453,7 @@ function transformAnthropicRequestToUnified(request) {
412
453
  max_tokens: anthropicRequest.max_tokens,
413
454
  temperature: anthropicRequest.temperature,
414
455
  stream: anthropicRequest.stream,
415
- tools: _optionalChain([functionTools, 'optionalAccess', _21 => _21.length]) ? functionTools : void 0
456
+ tools: _optionalChain([functionTools, 'optionalAccess', _22 => _22.length]) ? functionTools : void 0
416
457
  };
417
458
  if (serverSideTools.length > 0) {
418
459
  result._serverSideTools = serverSideTools;
@@ -537,7 +578,7 @@ function convertAnthropicStreamToOpenAI(anthropicStream, logger) {
537
578
  `);
538
579
  } else if (event.content_block.type === "web_search_tool_result") {
539
580
  const searches = event.content_block.content;
540
- if (_optionalChain([searches, 'optionalAccess', _22 => _22.length])) {
581
+ if (_optionalChain([searches, 'optionalAccess', _23 => _23.length])) {
541
582
  const formatted = searches.map((s) => `[${s.title}](${s.url}): ${s.page_content || s.snippet || ""}`).join("\n");
542
583
  const chunk = {
543
584
  id: messageId,
@@ -589,7 +630,7 @@ ${formatted}` },
589
630
  `);
590
631
  }
591
632
  } catch (e) {
592
- _optionalChain([logger, 'optionalAccess', _23 => _23.error, 'call', _24 => _24("Error parsing Anthropic stream event:", e)]);
633
+ _optionalChain([logger, 'optionalAccess', _24 => _24.error, 'call', _25 => _25("Error parsing Anthropic stream event:", e)]);
593
634
  }
594
635
  }
595
636
  }
@@ -721,20 +762,20 @@ data: ${JSON.stringify({
721
762
 
722
763
  `);
723
764
  }
724
- const choice = _optionalChain([chunk, 'access', _25 => _25.choices, 'optionalAccess', _26 => _26[0]]);
765
+ const choice = _optionalChain([chunk, 'access', _26 => _26.choices, 'optionalAccess', _27 => _27[0]]);
725
766
  if (!choice) continue;
726
767
  if (chunk.usage) {
727
768
  stopReasonDelta = {
728
769
  type: "message_delta",
729
770
  delta: { stop_reason: "end_turn", stop_sequence: null },
730
771
  usage: {
731
- input_tokens: (chunk.usage.prompt_tokens || 0) - (_optionalChain([chunk, 'access', _27 => _27.usage, 'access', _28 => _28.prompt_tokens_details, 'optionalAccess', _29 => _29.cached_tokens]) || 0),
772
+ input_tokens: (chunk.usage.prompt_tokens || 0) - (_optionalChain([chunk, 'access', _28 => _28.usage, 'access', _29 => _29.prompt_tokens_details, 'optionalAccess', _30 => _30.cached_tokens]) || 0),
732
773
  output_tokens: chunk.usage.completion_tokens || 0,
733
- cache_read_input_tokens: _optionalChain([chunk, 'access', _30 => _30.usage, 'access', _31 => _31.prompt_tokens_details, 'optionalAccess', _32 => _32.cached_tokens]) || 0
774
+ cache_read_input_tokens: _optionalChain([chunk, 'access', _31 => _31.usage, 'access', _32 => _32.prompt_tokens_details, 'optionalAccess', _33 => _33.cached_tokens]) || 0
734
775
  }
735
776
  };
736
777
  }
737
- if (_optionalChain([choice, 'access', _33 => _33.delta, 'optionalAccess', _34 => _34.thinking])) {
778
+ if (_optionalChain([choice, 'access', _34 => _34.delta, 'optionalAccess', _35 => _35.thinking])) {
738
779
  if (!isThinkingStarted) {
739
780
  const thinkingBlockIndex = assignContentBlockIndex();
740
781
  safeEnqueue(`event: content_block_start
@@ -776,7 +817,7 @@ data: ${JSON.stringify({
776
817
  `);
777
818
  }
778
819
  }
779
- if (_optionalChain([choice, 'access', _35 => _35.delta, 'optionalAccess', _36 => _36.content])) {
820
+ if (_optionalChain([choice, 'access', _36 => _36.delta, 'optionalAccess', _37 => _37.content])) {
780
821
  if (!hasTextContentStarted) {
781
822
  if (currentContentBlockIndex >= 0 && isThinkingStarted) {
782
823
  safeEnqueue(`event: content_block_stop
@@ -808,7 +849,7 @@ data: ${JSON.stringify({
808
849
 
809
850
  `);
810
851
  }
811
- if (_optionalChain([choice, 'access', _37 => _37.delta, 'optionalAccess', _38 => _38.tool_calls])) {
852
+ if (_optionalChain([choice, 'access', _38 => _38.delta, 'optionalAccess', _39 => _39.tool_calls])) {
812
853
  for (const toolCall of choice.delta.tool_calls) {
813
854
  const toolCallIndex = _nullishCoalesce(toolCall.index, () => ( 0));
814
855
  if (!toolCallIndexToContentBlockIndex.has(toolCallIndex)) {
@@ -831,7 +872,7 @@ data: ${JSON.stringify({
831
872
  content_block: {
832
873
  type: "tool_use",
833
874
  id: toolCall.id || `call_${Date.now()}_${toolCallIndex}`,
834
- name: _optionalChain([toolCall, 'access', _39 => _39.function, 'optionalAccess', _40 => _40.name]) || `tool_${toolCallIndex}`,
875
+ name: _optionalChain([toolCall, 'access', _40 => _40.function, 'optionalAccess', _41 => _41.name]) || `tool_${toolCallIndex}`,
835
876
  input: {}
836
877
  }
837
878
  })}
@@ -839,7 +880,7 @@ data: ${JSON.stringify({
839
880
  `);
840
881
  currentContentBlockIndex = newBlockIndex;
841
882
  }
842
- if (_optionalChain([toolCall, 'access', _41 => _41.function, 'optionalAccess', _42 => _42.arguments])) {
883
+ if (_optionalChain([toolCall, 'access', _42 => _42.function, 'optionalAccess', _43 => _43.arguments])) {
843
884
  const blockIndex = toolCallIndexToContentBlockIndex.get(toolCallIndex);
844
885
  if (blockIndex !== void 0) {
845
886
  safeEnqueue(`event: content_block_delta
@@ -868,14 +909,14 @@ data: ${JSON.stringify({
868
909
  stop_sequence: null
869
910
  },
870
911
  usage: {
871
- input_tokens: (_optionalChain([chunk, 'access', _43 => _43.usage, 'optionalAccess', _44 => _44.prompt_tokens]) || 0) - (_optionalChain([chunk, 'access', _45 => _45.usage, 'optionalAccess', _46 => _46.prompt_tokens_details, 'optionalAccess', _47 => _47.cached_tokens]) || 0),
872
- output_tokens: _optionalChain([chunk, 'access', _48 => _48.usage, 'optionalAccess', _49 => _49.completion_tokens]) || 0,
873
- cache_read_input_tokens: _optionalChain([chunk, 'access', _50 => _50.usage, 'optionalAccess', _51 => _51.prompt_tokens_details, 'optionalAccess', _52 => _52.cached_tokens]) || 0
912
+ input_tokens: (_optionalChain([chunk, 'access', _44 => _44.usage, 'optionalAccess', _45 => _45.prompt_tokens]) || 0) - (_optionalChain([chunk, 'access', _46 => _46.usage, 'optionalAccess', _47 => _47.prompt_tokens_details, 'optionalAccess', _48 => _48.cached_tokens]) || 0),
913
+ output_tokens: _optionalChain([chunk, 'access', _49 => _49.usage, 'optionalAccess', _50 => _50.completion_tokens]) || 0,
914
+ cache_read_input_tokens: _optionalChain([chunk, 'access', _51 => _51.usage, 'optionalAccess', _52 => _52.prompt_tokens_details, 'optionalAccess', _53 => _53.cached_tokens]) || 0
874
915
  }
875
916
  };
876
917
  }
877
918
  } catch (e) {
878
- _optionalChain([logger, 'optionalAccess', _53 => _53.error, 'call', _54 => _54("Error parsing stream chunk:", e)]);
919
+ _optionalChain([logger, 'optionalAccess', _54 => _54.error, 'call', _55 => _55("Error parsing stream chunk:", e)]);
879
920
  }
880
921
  }
881
922
  }
@@ -899,7 +940,7 @@ var AnthropicTransformer = (_class = class {
899
940
  __init2() {this.endPoint = "/v1/messages"}
900
941
 
901
942
  constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
902
- this.useBearer = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _55 => _55.UseBearer]), () => ( false));
943
+ this.useBearer = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _56 => _56.UseBearer]), () => ( false));
903
944
  }
904
945
  /**
905
946
  * Handle authentication - Anthropic uses x-api-key header
@@ -988,4 +1029,5 @@ var AnthropicTransformer = (_class = class {
988
1029
 
989
1030
 
990
1031
 
991
- exports.AnthropicTransformer = AnthropicTransformer;
1032
+
1033
+ exports.resolveAnthropicMaxTokens = resolveAnthropicMaxTokens; exports.AnthropicTransformer = AnthropicTransformer;