@omnicross/core 0.1.5 → 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 (190) 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 +6 -5
  6. package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -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-4XMYPW46.cjs → chunk-4VLRHHFE.cjs} +75 -33
  11. package/dist/{chunk-VACWOIRE.cjs → chunk-4VZX5F4T.cjs} +39 -15
  12. package/dist/{chunk-C6OV7GCC.js → chunk-6CL5HTPQ.js} +44 -2
  13. package/dist/chunk-6QQG7YG3.cjs +153 -0
  14. package/dist/{chunk-3Q6Z6JTO.cjs → chunk-6VUQPOV3.cjs} +277 -86
  15. package/dist/chunk-7AK7B36B.cjs +44 -0
  16. package/dist/{chunk-5ZQBEOMD.js → chunk-AT7B7SOZ.js} +25 -2
  17. package/dist/{chunk-IK3KE3AU.js → chunk-DE2SRBFZ.js} +1 -1
  18. package/dist/chunk-DLXZEZWO.cjs +285 -0
  19. package/dist/{chunk-UHGVBFU3.js → chunk-EBLFCNPY.js} +38 -14
  20. package/dist/chunk-EJLH6NFT.cjs +166 -0
  21. package/dist/chunk-HVBBDBS3.cjs +350 -0
  22. package/dist/{chunk-46ZIFWYG.cjs → chunk-IIRPUVPH.cjs} +7 -1
  23. package/dist/{chunk-JWVTXXPX.cjs → chunk-KBM2W6UY.cjs} +8 -4
  24. package/dist/{chunk-PG7PS2NN.cjs → chunk-KCVJWJST.cjs} +14 -2
  25. package/dist/chunk-LB6EBS6Y.js +69 -0
  26. package/dist/{chunk-IWQAX3CS.js → chunk-LVUCAWMK.js} +1 -1
  27. package/dist/chunk-MKF46GNZ.js +350 -0
  28. package/dist/{chunk-HYN75H6G.cjs → chunk-MUHWHQVM.cjs} +1 -1
  29. package/dist/{chunk-MFZ5437A.js → chunk-N5T4M4GU.js} +1 -1
  30. package/dist/{chunk-BODMAL6G.js → chunk-OEWZUX4G.js} +262 -71
  31. package/dist/chunk-OF3BECU2.cjs +69 -0
  32. package/dist/{chunk-DDMRUL76.cjs → chunk-OKMJLEXX.cjs} +5 -5
  33. package/dist/chunk-OPRS4IQZ.js +153 -0
  34. package/dist/{chunk-D3TDKWRP.js → chunk-SIZQQD6T.js} +14 -2
  35. package/dist/{chunk-CGKLE6IW.cjs → chunk-SQYVORNP.cjs} +1219 -510
  36. package/dist/{chunk-6QZGDLL4.js → chunk-TOVPMMHM.js} +5 -1
  37. package/dist/{chunk-FH2P4OCD.js → chunk-UDCC7EMR.js} +976 -267
  38. package/dist/{chunk-ZLX3KGXX.js → chunk-UX7VWA46.js} +135 -23
  39. package/dist/{chunk-K52THW2C.cjs → chunk-V4TXMEJS.cjs} +5 -5
  40. package/dist/chunk-VRFBB5DB.js +44 -0
  41. package/dist/chunk-WB6PH56J.js +166 -0
  42. package/dist/{chunk-G2UTNSGU.js → chunk-WNKWAEUR.js} +7 -1
  43. package/dist/{chunk-SUEGJ75D.cjs → chunk-WYTEQ4Q5.cjs} +25 -2
  44. package/dist/{chunk-5ENKBSWO.js → chunk-YJVHCHQX.js} +42 -6
  45. package/dist/{chunk-VQY5W4YW.cjs → chunk-YK57NMIF.cjs} +44 -8
  46. package/dist/{chunk-KFI44N2R.cjs → chunk-YNJNTCSQ.cjs} +10 -1
  47. package/dist/completion/ApiKeyPoolService.cjs +12 -0
  48. package/dist/completion/ApiKeyPoolService.d.cts +6 -0
  49. package/dist/completion/ApiKeyPoolService.d.ts +6 -0
  50. package/dist/completion/ApiKeyPoolService.js +12 -0
  51. package/dist/completion/CompletionService.cjs +25 -23
  52. package/dist/completion/CompletionService.d.cts +2 -1
  53. package/dist/completion/CompletionService.d.ts +2 -1
  54. package/dist/completion/CompletionService.js +24 -22
  55. package/dist/completion.cjs +25 -23
  56. package/dist/completion.d.cts +2 -1
  57. package/dist/completion.d.ts +2 -1
  58. package/dist/completion.js +24 -22
  59. package/dist/index.cjs +49 -26
  60. package/dist/index.d.cts +8 -8
  61. package/dist/index.d.ts +8 -8
  62. package/dist/index.js +52 -29
  63. package/dist/{keyPolicy-Cp0FntZl.d.ts → keyPolicy-zdWTu3CQ.d.cts} +1 -1
  64. package/dist/{keyPolicy-Cp0FntZl.d.cts → keyPolicy-zdWTu3CQ.d.ts} +1 -1
  65. package/dist/outbound-api/quotaWarn.d.cts +1 -1
  66. package/dist/outbound-api/quotaWarn.d.ts +1 -1
  67. package/dist/outbound-api/routeResolver.cjs +2 -2
  68. package/dist/outbound-api/routeResolver.d.cts +4 -3
  69. package/dist/outbound-api/routeResolver.d.ts +4 -3
  70. package/dist/outbound-api/routeResolver.js +1 -1
  71. package/dist/outbound-api/subscriptionRegistryPort.d.cts +1 -0
  72. package/dist/outbound-api/subscriptionRegistryPort.d.ts +1 -0
  73. package/dist/outbound-api/types.d.cts +3 -2
  74. package/dist/outbound-api/types.d.ts +3 -2
  75. package/dist/outbound-api.cjs +47 -24
  76. package/dist/outbound-api.d.cts +127 -85
  77. package/dist/outbound-api.d.ts +127 -85
  78. package/dist/outbound-api.js +50 -27
  79. package/dist/pipeline/AccountAllowanceScheduling.cjs +15 -0
  80. package/dist/pipeline/AccountAllowanceScheduling.d.cts +90 -0
  81. package/dist/pipeline/AccountAllowanceScheduling.d.ts +90 -0
  82. package/dist/pipeline/AccountAllowanceScheduling.js +15 -0
  83. package/dist/pipeline/AccountAllowanceStore.cjs +20 -0
  84. package/dist/pipeline/AccountAllowanceStore.d.cts +77 -0
  85. package/dist/pipeline/AccountAllowanceStore.d.ts +77 -0
  86. package/dist/pipeline/AccountAllowanceStore.js +20 -0
  87. package/dist/pipeline/AuthSource.d.cts +11 -2
  88. package/dist/pipeline/AuthSource.d.ts +11 -2
  89. package/dist/pipeline/BoundAccountSelectionError.cjs +10 -0
  90. package/dist/pipeline/BoundAccountSelectionError.d.cts +28 -0
  91. package/dist/pipeline/BoundAccountSelectionError.d.ts +28 -0
  92. package/dist/pipeline/BoundAccountSelectionError.js +10 -0
  93. package/dist/pipeline/LlmConfigProviderAuth.d.cts +1 -0
  94. package/dist/pipeline/LlmConfigProviderAuth.d.ts +1 -0
  95. package/dist/pipeline/SubscriptionAccountHealth.cjs +4 -2
  96. package/dist/pipeline/SubscriptionAccountHealth.d.cts +34 -6
  97. package/dist/pipeline/SubscriptionAccountHealth.d.ts +34 -6
  98. package/dist/pipeline/SubscriptionAccountHealth.js +3 -1
  99. package/dist/pipeline/SubscriptionAuthSource.cjs +5 -2
  100. package/dist/pipeline/SubscriptionAuthSource.d.cts +1 -0
  101. package/dist/pipeline/SubscriptionAuthSource.d.ts +1 -0
  102. package/dist/pipeline/SubscriptionAuthSource.js +4 -1
  103. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +8 -3
  104. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +8 -3
  105. package/dist/pipeline/executeProviderCall.cjs +2 -2
  106. package/dist/pipeline/executeProviderCall.d.cts +8 -3
  107. package/dist/pipeline/executeProviderCall.d.ts +8 -3
  108. package/dist/pipeline/executeProviderCall.js +1 -1
  109. package/dist/pipeline/resolveProviderChain.d.cts +2 -3
  110. package/dist/pipeline/resolveProviderChain.d.ts +2 -3
  111. package/dist/pipeline/resolveSubscriptionChain.d.cts +1 -0
  112. package/dist/pipeline/resolveSubscriptionChain.d.ts +1 -0
  113. package/dist/pipeline/upstreamFetch.cjs +3 -2
  114. package/dist/pipeline/upstreamFetch.js +2 -1
  115. package/dist/ports/pricing-store.d.cts +4 -3
  116. package/dist/ports/pricing-store.d.ts +4 -3
  117. package/dist/ports.d.cts +4 -3
  118. package/dist/ports.d.ts +4 -3
  119. package/dist/provider-proxy/ProviderProxy.cjs +25 -23
  120. package/dist/provider-proxy/ProviderProxy.d.cts +1 -0
  121. package/dist/provider-proxy/ProviderProxy.d.ts +1 -0
  122. package/dist/provider-proxy/ProviderProxy.js +24 -22
  123. package/dist/provider-proxy/ingress/providerProxyShared.cjs +27 -23
  124. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +34 -5
  125. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +34 -5
  126. package/dist/provider-proxy/ingress/providerProxyShared.js +26 -22
  127. package/dist/provider-proxy/matchText.cjs +4 -2
  128. package/dist/provider-proxy/matchText.d.cts +41 -6
  129. package/dist/provider-proxy/matchText.d.ts +41 -6
  130. package/dist/provider-proxy/matchText.js +3 -1
  131. package/dist/provider-proxy/types.d.cts +30 -2
  132. package/dist/provider-proxy/types.d.ts +30 -2
  133. package/dist/provider-proxy.cjs +25 -23
  134. package/dist/provider-proxy.d.cts +1 -0
  135. package/dist/provider-proxy.d.ts +1 -0
  136. package/dist/provider-proxy.js +24 -22
  137. package/dist/{routeResolver-C4T7yClx.d.ts → routeResolver-CHTv_Bs5.d.ts} +1 -1
  138. package/dist/{routeResolver-CB3tvJKy.d.cts → routeResolver-kepxnfcC.d.cts} +1 -1
  139. package/dist/transformer/TransformerChainExecutor.cjs +2 -2
  140. package/dist/transformer/TransformerChainExecutor.js +1 -1
  141. package/dist/transformer/transformers/AnthropicTransformer.cjs +2 -2
  142. package/dist/transformer/transformers/AnthropicTransformer.js +1 -1
  143. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
  144. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
  145. package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
  146. package/dist/transformer/transformers/GeminiTransformer.js +2 -2
  147. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
  148. package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +1 -1
  149. package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +1 -1
  150. package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
  151. package/dist/transformer/transformers/OpenAITransformer.cjs +6 -0
  152. package/dist/transformer/transformers/OpenAITransformer.d.cts +68 -0
  153. package/dist/transformer/transformers/OpenAITransformer.d.ts +68 -0
  154. package/dist/transformer/transformers/OpenAITransformer.js +6 -0
  155. package/dist/transformer/transformers.cjs +8 -14
  156. package/dist/transformer/transformers.d.cts +12 -48
  157. package/dist/transformer/transformers.d.ts +12 -48
  158. package/dist/transformer/transformers.js +12 -18
  159. package/dist/transformer/types.d.cts +17 -0
  160. package/dist/transformer/types.d.ts +17 -0
  161. package/dist/transformer.cjs +10 -11
  162. package/dist/transformer.d.cts +1 -2
  163. package/dist/transformer.d.ts +1 -2
  164. package/dist/transformer.js +9 -10
  165. package/dist/{types-B8Arpxn0.d.cts → types-H3wGZSOo.d.cts} +134 -7
  166. package/dist/{types-lgPYQuZS.d.ts → types-hsoKrVQS.d.ts} +134 -7
  167. package/dist/usage/pricing-engine.cjs +2 -2
  168. package/dist/usage/pricing-engine.d.cts +9 -1
  169. package/dist/usage/pricing-engine.d.ts +9 -1
  170. package/dist/usage/pricing-engine.js +1 -1
  171. package/dist/usage.cjs +2 -2
  172. package/dist/usage.js +1 -1
  173. package/package.json +1 -1
  174. package/dist/chunk-7FEBOPJO.cjs +0 -50
  175. package/dist/chunk-DWKQZ2SK.cjs +0 -254
  176. package/dist/chunk-IAXWICZU.js +0 -69
  177. package/dist/chunk-IB3FDI4O.js +0 -50
  178. package/dist/chunk-OQWKZCXP.js +0 -242
  179. package/dist/chunk-QWBWGODS.cjs +0 -69
  180. package/dist/chunk-YMFAJFQT.cjs +0 -173
  181. package/dist/chunk-ZCIQ3L3R.cjs +0 -242
  182. package/dist/chunk-ZJZAOKI7.js +0 -254
  183. package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +0 -6
  184. package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +0 -51
  185. package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +0 -51
  186. package/dist/transformer/transformers/OpenCodeGoTransformer.js +0 -6
  187. package/dist/transformer/transformers/ReasoningTransformer.cjs +0 -6
  188. package/dist/transformer/transformers/ReasoningTransformer.d.cts +0 -47
  189. package/dist/transformer/transformers/ReasoningTransformer.d.ts +0 -47
  190. 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,12 +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 _chunkDDMRUL76cjs = require('../chunk-DDMRUL76.cjs');
5
- require('../chunk-JWVTXXPX.cjs');
4
+ var _chunkOKMJLEXXcjs = require('../chunk-OKMJLEXX.cjs');
5
+ require('../chunk-KBM2W6UY.cjs');
6
6
 
7
7
 
8
- var _chunkPG7PS2NNcjs = require('../chunk-PG7PS2NN.cjs');
8
+ var _chunkKCVJWJSTcjs = require('../chunk-KCVJWJST.cjs');
9
9
  require('../chunk-3Z5BQZFM.cjs');
10
+ require('../chunk-HVBBDBS3.cjs');
10
11
 
11
12
  // src/auth/GeminiCodeAssistProjectResolver.ts
12
13
  var FREE_TIER_ID = "free-tier";
@@ -26,7 +27,7 @@ var GeminiCodeAssistHandshakeError = class extends Error {
26
27
  var GeminiCodeAssistProjectResolver = (_class = class {
27
28
  // upstream-proxy: the Code Assist handshake is upstream egress → honor the
28
29
  // gemini proxy by default (still injectable for tests).
29
- constructor(fetchImpl = (url, init) => _chunkPG7PS2NNcjs.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);
30
31
  this.fetchImpl = fetchImpl;
31
32
  }
32
33
 
@@ -60,7 +61,7 @@ var GeminiCodeAssistProjectResolver = (_class = class {
60
61
  return run;
61
62
  }
62
63
  codeAssistUrl(method) {
63
- return `${_chunkDDMRUL76cjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkDDMRUL76cjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
64
+ return `${_chunkOKMJLEXXcjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkOKMJLEXXcjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
64
65
  }
65
66
  /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
66
67
  seedProjectId() {
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  resolveCodeAssistApiVersion,
3
3
  resolveCodeAssistEndpoint
4
- } from "../chunk-MFZ5437A.js";
5
- import "../chunk-6QZGDLL4.js";
4
+ } from "../chunk-N5T4M4GU.js";
5
+ import "../chunk-TOVPMMHM.js";
6
6
  import {
7
7
  fetchUpstream
8
- } from "../chunk-D3TDKWRP.js";
8
+ } from "../chunk-SIZQQD6T.js";
9
9
  import "../chunk-SYQF7OIR.js";
10
+ import "../chunk-MKF46GNZ.js";
10
11
 
11
12
  // src/auth/GeminiCodeAssistProjectResolver.ts
12
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
+ };
@@ -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,14 +269,14 @@ ${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 = [];
240
278
  const thinking = message.thinking;
241
- if (_optionalChain([thinking, 'optionalAccess', _13 => _13.content])) {
279
+ if (_optionalChain([thinking, 'optionalAccess', _14 => _14.content])) {
242
280
  content.push({
243
281
  type: "thinking",
244
282
  thinking: thinking.content,
@@ -252,7 +290,7 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
252
290
  });
253
291
  }
254
292
  const toolCalls = message.tool_calls;
255
- if (_optionalChain([toolCalls, 'optionalAccess', _14 => _14.length])) {
293
+ if (_optionalChain([toolCalls, 'optionalAccess', _15 => _15.length])) {
256
294
  for (const toolCall of toolCalls) {
257
295
  const func = toolCall.function;
258
296
  let parsedInput = {};
@@ -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;
@@ -89,18 +89,6 @@ function validateEndpointModelConfig(config) {
89
89
  (kind) => !isNonBlankRef(map[kind])
90
90
  );
91
91
  }
92
- function validateServerModelConfig(config) {
93
- const errors = [];
94
- for (const endpoint of Object.keys(_chunk4IH4EL7Mcjs.ENDPOINT_MODEL_KINDS)) {
95
- const ep = config.endpoints.find((e) => e.endpoint === endpoint);
96
- const declared = modelKindsForEndpoint(endpoint);
97
- const missingKinds = ep ? validateEndpointModelConfig(ep) : [...declared];
98
- if (missingKinds.length > 0 && missingKinds.length < declared.length) {
99
- errors.push({ endpoint, missingKinds });
100
- }
101
- }
102
- return errors;
103
- }
104
92
 
105
93
  // src/outbound-api/modelPrefixDispatch.ts
106
94
  function classifyModelPrefix(model) {
@@ -149,6 +137,34 @@ function endpointSupportsSubscription(endpoint) {
149
137
  }
150
138
 
151
139
  // src/outbound-api/routeResolver.ts
140
+ function bindDelegatedSubscriptionProfile(profile, config) {
141
+ const preferredAccountId = config.boundAccountId;
142
+ const preferredAccountGroup = config.boundAccountGroup;
143
+ const boundAccountFallbackPolicy = config.boundAccountFallbackPolicy;
144
+ if (!preferredAccountId && !preferredAccountGroup) return profile;
145
+ const strategy = profile.authStrategy;
146
+ return {
147
+ ...profile,
148
+ authStrategy: {
149
+ kind: strategy.kind,
150
+ providerId: strategy.providerId,
151
+ applyHeaders(headers, hints) {
152
+ return strategy.applyHeaders(headers, {
153
+ ...hints,
154
+ preferredAccountId,
155
+ preferredAccountGroup,
156
+ boundAccountFallbackPolicy
157
+ });
158
+ },
159
+ onUnauthorized(sessionKey) {
160
+ return strategy.onUnauthorized(sessionKey);
161
+ },
162
+ describeStatus() {
163
+ return strategy.describeStatus();
164
+ }
165
+ }
166
+ };
167
+ }
152
168
  function parseModelRef(ref) {
153
169
  if (!ref) return null;
154
170
  const idx = ref.indexOf(",");
@@ -267,6 +283,8 @@ async function resolveRoute(args) {
267
283
  apiKey: resolveApiKey(provider.api_key),
268
284
  isOfficialProvider,
269
285
  passThrough: false,
286
+ preferredKeyId: config.boundKeyId,
287
+ boundKeyFallbackPolicy: config.boundKeyFallbackPolicy,
270
288
  attribution: { sessionId, apiKeyId: _nullishCoalesce(args.apiKeyId, () => ( null)) }
271
289
  };
272
290
  }
@@ -277,6 +295,8 @@ async function resolveRoute(args) {
277
295
  ingressFormat,
278
296
  authMode: "byo",
279
297
  providerId,
298
+ preferredKeyId: config.boundKeyId,
299
+ boundKeyFallbackPolicy: config.boundKeyFallbackPolicy,
280
300
  // Passthrough gate: the client's ORIGINAL requested id (kind-mapped only).
281
301
  requestedModel,
282
302
  // Usage attribution: the verified named-key id (undefined for internal traffic).
@@ -321,7 +341,10 @@ async function resolveSubscriptionRoute(args) {
321
341
  apiKey: "",
322
342
  isOfficialProvider: false,
323
343
  passThrough: false,
324
- subscriptionProfile: profile,
344
+ subscriptionProfile: bindDelegatedSubscriptionProfile(profile, config),
345
+ preferredAccountId: config.boundAccountId,
346
+ preferredAccountGroup: config.boundAccountGroup,
347
+ boundAccountFallbackPolicy: config.boundAccountFallbackPolicy,
325
348
  attribution: { sessionId, apiKeyId: _nullishCoalesce(apiKeyId, () => ( null)) }
326
349
  };
327
350
  const subscriptionConfig = providerId === "opencodego" ? await _optionalChain([registry, 'optionalAccess', _9 => _9.getOpenCodeGoConfig, 'optionalCall', _10 => _10()]) : void 0;
@@ -353,6 +376,8 @@ async function resolveSubscriptionRoute(args) {
353
376
  subscriptionConfig,
354
377
  // Per-request preferred account (provider/subscription duality); undefined ⇒ pool.
355
378
  preferredAccountId: config.boundAccountId,
379
+ preferredAccountGroup: config.boundAccountGroup,
380
+ boundAccountFallbackPolicy: config.boundAccountFallbackPolicy,
356
381
  anthropicSdkHints: hints
357
382
  };
358
383
  return { ok: true, route, usedRole: effectiveRole };
@@ -381,5 +406,4 @@ function resolveApiKey(apiKey) {
381
406
 
382
407
 
383
408
 
384
-
385
- exports.extractRequestedModel = extractRequestedModel; exports.detectRequestRole = detectRequestRole; exports.endpointToIngressFormat = endpointToIngressFormat; exports.isKindMappedEndpoint = isKindMappedEndpoint; exports.modelKindsForEndpoint = modelKindsForEndpoint; exports.detectModelKind = detectModelKind; exports.validateEndpointModelConfig = validateEndpointModelConfig; exports.validateServerModelConfig = validateServerModelConfig; exports.classifyModelPrefix = classifyModelPrefix; exports.resolvePrefixTarget = resolvePrefixTarget; exports.SUBSCRIPTION_PROVIDER_IDS = SUBSCRIPTION_PROVIDER_IDS; exports.isSubscriptionProviderId = isSubscriptionProviderId; exports.endpointSupportsSubscription = endpointSupportsSubscription; exports.parseModelRef = parseModelRef; exports.pickModelRefFromList = pickModelRefFromList; exports.resolveRoute = resolveRoute;
409
+ exports.extractRequestedModel = extractRequestedModel; exports.detectRequestRole = detectRequestRole; exports.endpointToIngressFormat = endpointToIngressFormat; exports.isKindMappedEndpoint = isKindMappedEndpoint; exports.modelKindsForEndpoint = modelKindsForEndpoint; exports.detectModelKind = detectModelKind; exports.validateEndpointModelConfig = validateEndpointModelConfig; exports.classifyModelPrefix = classifyModelPrefix; exports.resolvePrefixTarget = resolvePrefixTarget; exports.SUBSCRIPTION_PROVIDER_IDS = SUBSCRIPTION_PROVIDER_IDS; exports.isSubscriptionProviderId = isSubscriptionProviderId; exports.endpointSupportsSubscription = endpointSupportsSubscription; exports.parseModelRef = parseModelRef; exports.pickModelRefFromList = pickModelRefFromList; exports.resolveRoute = resolveRoute;