@omnicross/core 0.1.5 → 0.1.7

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 (231) 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 +8 -6
  6. package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -4
  7. package/dist/{chunk-3Z5BQZFM.cjs → chunk-235MXAGX.cjs} +3 -1
  8. package/dist/{chunk-HRRYG2AX.js → chunk-23S5OPIO.js} +10 -1
  9. package/dist/chunk-25GXJCEZ.cjs +40 -0
  10. package/dist/chunk-2E42SAW3.cjs +323 -0
  11. package/dist/chunk-2JYRIADS.js +40 -0
  12. package/dist/chunk-2Z4XM3H5.cjs +44 -0
  13. package/dist/{chunk-BODMAL6G.js → chunk-32O35CIF.js} +271 -91
  14. package/dist/chunk-3SCOLIPT.cjs +63 -0
  15. package/dist/{chunk-SYQF7OIR.js → chunk-3WD4HTR2.js} +2 -0
  16. package/dist/{chunk-CGKLE6IW.cjs → chunk-4BB343BI.cjs} +1489 -520
  17. package/dist/{chunk-VACWOIRE.cjs → chunk-4VZX5F4T.cjs} +39 -15
  18. package/dist/{chunk-5ZQBEOMD.js → chunk-5NJLQ6T6.js} +46 -12
  19. package/dist/chunk-5RSZYQJH.cjs +62 -0
  20. package/dist/chunk-6QQG7YG3.cjs +153 -0
  21. package/dist/{chunk-IFXJ2BG7.js → chunk-7C7DET6S.js} +51 -6
  22. package/dist/{chunk-IK3KE3AU.js → chunk-DE2SRBFZ.js} +1 -1
  23. package/dist/{chunk-FH2P4OCD.js → chunk-E3COOKUP.js} +1240 -271
  24. package/dist/{chunk-UHGVBFU3.js → chunk-EBLFCNPY.js} +38 -14
  25. package/dist/chunk-FU7EAR73.js +62 -0
  26. package/dist/chunk-FXR6N3SR.js +323 -0
  27. package/dist/{chunk-SUEGJ75D.cjs → chunk-GDIXXKF2.cjs} +46 -12
  28. package/dist/chunk-GFIZ6LQI.js +170 -0
  29. package/dist/chunk-GL6XM527.js +61 -0
  30. package/dist/chunk-HVBBDBS3.cjs +350 -0
  31. package/dist/{chunk-46ZIFWYG.cjs → chunk-IIRPUVPH.cjs} +7 -1
  32. package/dist/chunk-J3QQ6JS5.cjs +170 -0
  33. package/dist/{chunk-JWVTXXPX.cjs → chunk-KBM2W6UY.cjs} +8 -4
  34. package/dist/chunk-LB6EBS6Y.js +69 -0
  35. package/dist/{chunk-IWQAX3CS.js → chunk-LVUCAWMK.js} +1 -1
  36. package/dist/chunk-MKF46GNZ.js +350 -0
  37. package/dist/{chunk-HYN75H6G.cjs → chunk-MUHWHQVM.cjs} +1 -1
  38. package/dist/chunk-MYYR3HZL.js +44 -0
  39. package/dist/{chunk-MFZ5437A.js → chunk-N5T4M4GU.js} +1 -1
  40. package/dist/{chunk-5ENKBSWO.js → chunk-N7OOJI5V.js} +88 -8
  41. package/dist/chunk-NKVZ6Z3Y.cjs +61 -0
  42. package/dist/chunk-OF3BECU2.cjs +69 -0
  43. package/dist/{chunk-SNYBEXLB.cjs → chunk-OJGQKHN5.cjs} +3 -1
  44. package/dist/{chunk-DDMRUL76.cjs → chunk-OKMJLEXX.cjs} +5 -5
  45. package/dist/chunk-OPRS4IQZ.js +153 -0
  46. package/dist/chunk-OTZC4TNH.cjs +79 -0
  47. package/dist/{chunk-3Q6Z6JTO.cjs → chunk-OVQBNVSV.cjs} +287 -107
  48. package/dist/{chunk-4XMYPW46.cjs → chunk-OXHNSZ53.cjs} +84 -44
  49. package/dist/{chunk-C6OV7GCC.js → chunk-PEGTIPB3.js} +52 -12
  50. package/dist/chunk-PO3XB56Z.js +79 -0
  51. package/dist/{chunk-D3TDKWRP.js → chunk-RJ5ZGNI3.js} +54 -5
  52. package/dist/{chunk-PG7PS2NN.cjs → chunk-RJUONLUQ.cjs} +59 -10
  53. package/dist/{chunk-BPKCU575.js → chunk-SOO562NM.js} +3 -1
  54. package/dist/{chunk-6QZGDLL4.js → chunk-TOVPMMHM.js} +5 -1
  55. package/dist/{chunk-K52THW2C.cjs → chunk-V4TXMEJS.cjs} +5 -5
  56. package/dist/{chunk-G2UTNSGU.js → chunk-WNKWAEUR.js} +7 -1
  57. package/dist/{chunk-UNWKG6EI.cjs → chunk-XPIOJQS2.cjs} +51 -6
  58. package/dist/chunk-XXFYLL7R.js +63 -0
  59. package/dist/{chunk-KFI44N2R.cjs → chunk-YNJNTCSQ.cjs} +10 -1
  60. package/dist/{chunk-VQY5W4YW.cjs → chunk-YWL7YZWS.cjs} +90 -10
  61. package/dist/completion/ApiKeyPoolService.cjs +12 -0
  62. package/dist/completion/ApiKeyPoolService.d.cts +6 -0
  63. package/dist/completion/ApiKeyPoolService.d.ts +6 -0
  64. package/dist/completion/ApiKeyPoolService.js +12 -0
  65. package/dist/completion/CompletionService.cjs +30 -24
  66. package/dist/completion/CompletionService.d.cts +3 -1
  67. package/dist/completion/CompletionService.d.ts +3 -1
  68. package/dist/completion/CompletionService.js +29 -23
  69. package/dist/completion.cjs +32 -26
  70. package/dist/completion.d.cts +3 -1
  71. package/dist/completion.d.ts +3 -1
  72. package/dist/completion.js +31 -25
  73. package/dist/index.cjs +56 -29
  74. package/dist/index.d.cts +8 -8
  75. package/dist/index.d.ts +8 -8
  76. package/dist/index.js +61 -34
  77. package/dist/{keyPolicy-Cp0FntZl.d.cts → keyPolicy-zdWTu3CQ.d.cts} +1 -1
  78. package/dist/{keyPolicy-Cp0FntZl.d.ts → keyPolicy-zdWTu3CQ.d.ts} +1 -1
  79. package/dist/outbound-api/auditCapture.cjs +2 -2
  80. package/dist/outbound-api/auditCapture.d.cts +3 -4
  81. package/dist/outbound-api/auditCapture.d.ts +3 -4
  82. package/dist/outbound-api/auditCapture.js +1 -1
  83. package/dist/outbound-api/quotaWarn.d.cts +1 -1
  84. package/dist/outbound-api/quotaWarn.d.ts +1 -1
  85. package/dist/outbound-api/routeResolver.cjs +2 -2
  86. package/dist/outbound-api/routeResolver.d.cts +5 -3
  87. package/dist/outbound-api/routeResolver.d.ts +5 -3
  88. package/dist/outbound-api/routeResolver.js +1 -1
  89. package/dist/outbound-api/subscriptionRegistryPort.d.cts +2 -0
  90. package/dist/outbound-api/subscriptionRegistryPort.d.ts +2 -0
  91. package/dist/outbound-api/types.d.cts +4 -2
  92. package/dist/outbound-api/types.d.ts +4 -2
  93. package/dist/outbound-api.cjs +52 -25
  94. package/dist/outbound-api.d.cts +131 -87
  95. package/dist/outbound-api.d.ts +131 -87
  96. package/dist/outbound-api.js +55 -28
  97. package/dist/pipeline/AccountAllowanceScheduling.cjs +15 -0
  98. package/dist/pipeline/AccountAllowanceScheduling.d.cts +91 -0
  99. package/dist/pipeline/AccountAllowanceScheduling.d.ts +91 -0
  100. package/dist/pipeline/AccountAllowanceScheduling.js +15 -0
  101. package/dist/pipeline/AccountAllowanceStore.cjs +20 -0
  102. package/dist/pipeline/AccountAllowanceStore.d.cts +77 -0
  103. package/dist/pipeline/AccountAllowanceStore.d.ts +77 -0
  104. package/dist/pipeline/AccountAllowanceStore.js +20 -0
  105. package/dist/pipeline/AccountRouteActivity.cjs +10 -0
  106. package/dist/pipeline/AccountRouteActivity.d.cts +61 -0
  107. package/dist/pipeline/AccountRouteActivity.d.ts +61 -0
  108. package/dist/pipeline/AccountRouteActivity.js +10 -0
  109. package/dist/pipeline/AuthSource.d.cts +11 -2
  110. package/dist/pipeline/AuthSource.d.ts +11 -2
  111. package/dist/pipeline/BoundAccountSelectionError.cjs +10 -0
  112. package/dist/pipeline/BoundAccountSelectionError.d.cts +28 -0
  113. package/dist/pipeline/BoundAccountSelectionError.d.ts +28 -0
  114. package/dist/pipeline/BoundAccountSelectionError.js +10 -0
  115. package/dist/pipeline/LlmConfigProviderAuth.d.cts +1 -0
  116. package/dist/pipeline/LlmConfigProviderAuth.d.ts +1 -0
  117. package/dist/pipeline/ServerOverloadCounter.cjs +16 -0
  118. package/dist/pipeline/ServerOverloadCounter.d.cts +77 -0
  119. package/dist/pipeline/ServerOverloadCounter.d.ts +77 -0
  120. package/dist/pipeline/ServerOverloadCounter.js +16 -0
  121. package/dist/pipeline/SubscriptionAccountHealth.cjs +6 -2
  122. package/dist/pipeline/SubscriptionAccountHealth.d.cts +65 -8
  123. package/dist/pipeline/SubscriptionAccountHealth.d.ts +65 -8
  124. package/dist/pipeline/SubscriptionAccountHealth.js +5 -1
  125. package/dist/pipeline/SubscriptionAuthSource.cjs +5 -2
  126. package/dist/pipeline/SubscriptionAuthSource.d.cts +1 -0
  127. package/dist/pipeline/SubscriptionAuthSource.d.ts +1 -0
  128. package/dist/pipeline/SubscriptionAuthSource.js +4 -1
  129. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +8 -3
  130. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +8 -3
  131. package/dist/pipeline/executeProviderCall.cjs +2 -2
  132. package/dist/pipeline/executeProviderCall.d.cts +8 -3
  133. package/dist/pipeline/executeProviderCall.d.ts +8 -3
  134. package/dist/pipeline/executeProviderCall.js +1 -1
  135. package/dist/pipeline/resolveProviderChain.d.cts +2 -3
  136. package/dist/pipeline/resolveProviderChain.d.ts +2 -3
  137. package/dist/pipeline/resolveSubscriptionChain.d.cts +1 -0
  138. package/dist/pipeline/resolveSubscriptionChain.d.ts +1 -0
  139. package/dist/pipeline/upstreamFetch.cjs +5 -3
  140. package/dist/pipeline/upstreamFetch.d.cts +35 -6
  141. package/dist/pipeline/upstreamFetch.d.ts +35 -6
  142. package/dist/pipeline/upstreamFetch.js +4 -2
  143. package/dist/pipeline/upstreamTrace.cjs +4 -2
  144. package/dist/pipeline/upstreamTrace.d.cts +22 -8
  145. package/dist/pipeline/upstreamTrace.d.ts +22 -8
  146. package/dist/pipeline/upstreamTrace.js +3 -1
  147. package/dist/ports/pricing-store.d.cts +4 -3
  148. package/dist/ports/pricing-store.d.ts +4 -3
  149. package/dist/ports.d.cts +4 -3
  150. package/dist/ports.d.ts +4 -3
  151. package/dist/provider-proxy/ProviderProxy.cjs +30 -24
  152. package/dist/provider-proxy/ProviderProxy.d.cts +2 -0
  153. package/dist/provider-proxy/ProviderProxy.d.ts +2 -0
  154. package/dist/provider-proxy/ProviderProxy.js +29 -23
  155. package/dist/provider-proxy/identity/codexCliHeaders.cjs +10 -0
  156. package/dist/provider-proxy/identity/codexCliHeaders.d.cts +45 -0
  157. package/dist/provider-proxy/identity/codexCliHeaders.d.ts +45 -0
  158. package/dist/provider-proxy/identity/codexCliHeaders.js +10 -0
  159. package/dist/provider-proxy/ingress/providerProxyShared.cjs +32 -24
  160. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +44 -5
  161. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +44 -5
  162. package/dist/provider-proxy/ingress/providerProxyShared.js +31 -23
  163. package/dist/provider-proxy/matchText.cjs +4 -2
  164. package/dist/provider-proxy/matchText.d.cts +39 -6
  165. package/dist/provider-proxy/matchText.d.ts +39 -6
  166. package/dist/provider-proxy/matchText.js +3 -1
  167. package/dist/provider-proxy/types.d.cts +35 -2
  168. package/dist/provider-proxy/types.d.ts +35 -2
  169. package/dist/provider-proxy.cjs +30 -24
  170. package/dist/provider-proxy.d.cts +2 -0
  171. package/dist/provider-proxy.d.ts +2 -0
  172. package/dist/provider-proxy.js +29 -23
  173. package/dist/{routeResolver-C4T7yClx.d.ts → routeResolver-BxOfunbm.d.ts} +1 -1
  174. package/dist/{routeResolver-CB3tvJKy.d.cts → routeResolver-D5OzD0iM.d.cts} +1 -1
  175. package/dist/transformer/TransformerChainExecutor.cjs +2 -2
  176. package/dist/transformer/TransformerChainExecutor.js +1 -1
  177. package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -2
  178. package/dist/transformer/transformers/AnthropicTransformer.js +2 -1
  179. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
  180. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
  181. package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
  182. package/dist/transformer/transformers/GeminiTransformer.js +2 -2
  183. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -2
  184. package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +1 -1
  185. package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +1 -1
  186. package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -1
  187. package/dist/transformer/transformers/OpenAITransformer.cjs +6 -0
  188. package/dist/transformer/transformers/OpenAITransformer.d.cts +68 -0
  189. package/dist/transformer/transformers/OpenAITransformer.d.ts +68 -0
  190. package/dist/transformer/transformers/OpenAITransformer.js +6 -0
  191. package/dist/transformer/transformers.cjs +9 -14
  192. package/dist/transformer/transformers.d.cts +12 -48
  193. package/dist/transformer/transformers.d.ts +12 -48
  194. package/dist/transformer/transformers.js +11 -16
  195. package/dist/transformer/types.d.cts +17 -0
  196. package/dist/transformer/types.d.ts +17 -0
  197. package/dist/transformer.cjs +12 -12
  198. package/dist/transformer.d.cts +1 -2
  199. package/dist/transformer.d.ts +1 -2
  200. package/dist/transformer.js +12 -12
  201. package/dist/{types-lgPYQuZS.d.ts → types-CqZD77rS.d.ts} +173 -7
  202. package/dist/{types-B8Arpxn0.d.cts → types-gjJ5lJ5n.d.cts} +173 -7
  203. package/dist/usage/pricing-engine.cjs +2 -2
  204. package/dist/usage/pricing-engine.d.cts +29 -1
  205. package/dist/usage/pricing-engine.d.ts +29 -1
  206. package/dist/usage/pricing-engine.js +1 -1
  207. package/dist/usage/usage-recorder.cjs +2 -2
  208. package/dist/usage/usage-recorder.d.cts +5 -1
  209. package/dist/usage/usage-recorder.d.ts +5 -1
  210. package/dist/usage/usage-recorder.js +1 -1
  211. package/dist/usage.cjs +3 -3
  212. package/dist/usage.js +2 -2
  213. package/package.json +1 -1
  214. package/dist/chunk-7FEBOPJO.cjs +0 -50
  215. package/dist/chunk-DWKQZ2SK.cjs +0 -254
  216. package/dist/chunk-IAXWICZU.js +0 -69
  217. package/dist/chunk-IB3FDI4O.js +0 -50
  218. package/dist/chunk-OQWKZCXP.js +0 -242
  219. package/dist/chunk-QWBWGODS.cjs +0 -69
  220. package/dist/chunk-YMFAJFQT.cjs +0 -173
  221. package/dist/chunk-ZCIQ3L3R.cjs +0 -242
  222. package/dist/chunk-ZJZAOKI7.js +0 -254
  223. package/dist/chunk-ZLX3KGXX.js +0 -173
  224. package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +0 -6
  225. package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +0 -51
  226. package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +0 -51
  227. package/dist/transformer/transformers/OpenCodeGoTransformer.js +0 -6
  228. package/dist/transformer/transformers/ReasoningTransformer.cjs +0 -6
  229. package/dist/transformer/transformers/ReasoningTransformer.d.cts +0 -47
  230. package/dist/transformer/transformers/ReasoningTransformer.d.ts +0 -47
  231. package/dist/transformer/transformers/ReasoningTransformer.js +0 -6
@@ -0,0 +1,91 @@
1
+ import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
2
+ import { a as AllowanceSchedulingConfig } from '../types-gjJ5lJ5n.cjs';
3
+ import { AccountAllowanceStore } from './AccountAllowanceStore.cjs';
4
+ import '@omnicross/contracts/account-tokens-types';
5
+ import '@omnicross/contracts/audit-types';
6
+ import '@omnicross/contracts/billing-types';
7
+ import '@omnicross/contracts/health-logging-types';
8
+ import '@omnicross/contracts/voucher-types';
9
+ import '@omnicross/contracts/webhook-types';
10
+ import '../logger-4GvQNzhE.cjs';
11
+ import '../ports/provider-config-source.cjs';
12
+ import '@omnicross/contracts/llm-config';
13
+ import '../transformer/types.cjs';
14
+ import '../transformer/TransformerService.cjs';
15
+ import '../ProviderProxy-CnMQYN59.cjs';
16
+ import '../provider-proxy/types.cjs';
17
+ import 'node:http';
18
+ import '@omnicross/contracts/completion-types';
19
+ import '@omnicross/contracts/usage-stats-types';
20
+ import '@omnicross/contracts/usage-types';
21
+ import '../completion/ApiKeyPoolService.cjs';
22
+ import './AuthSource.cjs';
23
+ import './BoundAccountSelectionError.cjs';
24
+ import './SubscriptionAuthSource.cjs';
25
+ import './SubscriptionAuthStrategy.cjs';
26
+ import '../ports/web-search-backend.cjs';
27
+ import '@omnicross/contracts/websearch-types';
28
+ import '../keyPolicy-zdWTu3CQ.cjs';
29
+ import '@omnicross/contracts/account-allowance-types';
30
+
31
+ /**
32
+ * Default-off allowance-aware scheduling policy.
33
+ *
34
+ * This layer consumes only normalized, secret-free snapshots. Missing, stale,
35
+ * unsupported, or reset-expired data is deliberately ignored so telemetry can
36
+ * never strand an account by accident.
37
+ */
38
+
39
+ type AllowanceSchedulingAction = 'normal' | 'demote' | 'pause' | 'ignore';
40
+ interface AllowanceSchedulingDecision {
41
+ providerId: SubscriptionProviderId;
42
+ accountId: string;
43
+ action: AllowanceSchedulingAction;
44
+ reason: 'policy-disabled' | 'provider-unsupported' | 'snapshot-missing' | 'snapshot-not-fresh' | 'below-threshold' | 'demote-threshold' | 'pause-threshold';
45
+ basePriority: number;
46
+ effectivePriority: number;
47
+ schedulable: boolean;
48
+ usedPercent?: number;
49
+ observedAt?: string;
50
+ resumeAt?: string;
51
+ decidedAt: string;
52
+ }
53
+ /**
54
+ * Safe, structured signal emitted only when an enabled allowance policy paused
55
+ * every otherwise eligible account. Request ingress maps it to HTTP 429 instead
56
+ * of disguising a local scheduling decision as an upstream 5xx.
57
+ */
58
+ declare class AccountAllowanceExhaustedError extends Error {
59
+ readonly providerId: SubscriptionProviderId;
60
+ readonly resumeAt?: string | undefined;
61
+ readonly code = "account_allowance_exhausted";
62
+ readonly status = 429;
63
+ constructor(providerId: SubscriptionProviderId, resumeAt?: string | undefined);
64
+ }
65
+ /** Structural guard survives package/bundle boundaries and never inspects secrets. */
66
+ declare function isAccountAllowanceExhaustedError(error: unknown): error is AccountAllowanceExhaustedError;
67
+ declare class AccountAllowanceScheduling {
68
+ private readonly store;
69
+ private readonly now;
70
+ private config;
71
+ private readonly history;
72
+ private readonly lastRecorded;
73
+ constructor(store?: AccountAllowanceStore, now?: () => number);
74
+ configure(config: AllowanceSchedulingConfig | undefined): void;
75
+ getConfig(): AllowanceSchedulingConfig;
76
+ evaluate(providerId: SubscriptionProviderId, accountId: string, basePriority: number, now?: number): AllowanceSchedulingDecision;
77
+ /**
78
+ * Project the current policy result without recording an applied decision.
79
+ * Admin/read-model callers use this so polling an account list never creates
80
+ * synthetic demotion/pause history entries.
81
+ */
82
+ preview(providerId: SubscriptionProviderId, accountId: string, basePriority: number, now?: number): AllowanceSchedulingDecision;
83
+ private decide;
84
+ getHistory(): AllowanceSchedulingDecision[];
85
+ clearHistory(): void;
86
+ private recordApplied;
87
+ }
88
+ declare function getSharedAccountAllowanceScheduling(): AccountAllowanceScheduling;
89
+ declare function __resetSharedAccountAllowanceSchedulingForTests(): void;
90
+
91
+ export { AccountAllowanceExhaustedError, AccountAllowanceScheduling, type AllowanceSchedulingAction, type AllowanceSchedulingDecision, __resetSharedAccountAllowanceSchedulingForTests, getSharedAccountAllowanceScheduling, isAccountAllowanceExhaustedError };
@@ -0,0 +1,91 @@
1
+ import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
2
+ import { a as AllowanceSchedulingConfig } from '../types-CqZD77rS.js';
3
+ import { AccountAllowanceStore } from './AccountAllowanceStore.js';
4
+ import '@omnicross/contracts/account-tokens-types';
5
+ import '@omnicross/contracts/audit-types';
6
+ import '@omnicross/contracts/billing-types';
7
+ import '@omnicross/contracts/health-logging-types';
8
+ import '@omnicross/contracts/voucher-types';
9
+ import '@omnicross/contracts/webhook-types';
10
+ import '../logger-4GvQNzhE.js';
11
+ import '../ports/provider-config-source.js';
12
+ import '@omnicross/contracts/llm-config';
13
+ import '../transformer/types.js';
14
+ import '../transformer/TransformerService.js';
15
+ import '../ProviderProxy-C-xqrkKi.js';
16
+ import '../provider-proxy/types.js';
17
+ import 'node:http';
18
+ import '@omnicross/contracts/completion-types';
19
+ import '@omnicross/contracts/usage-stats-types';
20
+ import '@omnicross/contracts/usage-types';
21
+ import '../completion/ApiKeyPoolService.js';
22
+ import './AuthSource.js';
23
+ import './BoundAccountSelectionError.js';
24
+ import './SubscriptionAuthSource.js';
25
+ import './SubscriptionAuthStrategy.js';
26
+ import '../ports/web-search-backend.js';
27
+ import '@omnicross/contracts/websearch-types';
28
+ import '../keyPolicy-zdWTu3CQ.js';
29
+ import '@omnicross/contracts/account-allowance-types';
30
+
31
+ /**
32
+ * Default-off allowance-aware scheduling policy.
33
+ *
34
+ * This layer consumes only normalized, secret-free snapshots. Missing, stale,
35
+ * unsupported, or reset-expired data is deliberately ignored so telemetry can
36
+ * never strand an account by accident.
37
+ */
38
+
39
+ type AllowanceSchedulingAction = 'normal' | 'demote' | 'pause' | 'ignore';
40
+ interface AllowanceSchedulingDecision {
41
+ providerId: SubscriptionProviderId;
42
+ accountId: string;
43
+ action: AllowanceSchedulingAction;
44
+ reason: 'policy-disabled' | 'provider-unsupported' | 'snapshot-missing' | 'snapshot-not-fresh' | 'below-threshold' | 'demote-threshold' | 'pause-threshold';
45
+ basePriority: number;
46
+ effectivePriority: number;
47
+ schedulable: boolean;
48
+ usedPercent?: number;
49
+ observedAt?: string;
50
+ resumeAt?: string;
51
+ decidedAt: string;
52
+ }
53
+ /**
54
+ * Safe, structured signal emitted only when an enabled allowance policy paused
55
+ * every otherwise eligible account. Request ingress maps it to HTTP 429 instead
56
+ * of disguising a local scheduling decision as an upstream 5xx.
57
+ */
58
+ declare class AccountAllowanceExhaustedError extends Error {
59
+ readonly providerId: SubscriptionProviderId;
60
+ readonly resumeAt?: string | undefined;
61
+ readonly code = "account_allowance_exhausted";
62
+ readonly status = 429;
63
+ constructor(providerId: SubscriptionProviderId, resumeAt?: string | undefined);
64
+ }
65
+ /** Structural guard survives package/bundle boundaries and never inspects secrets. */
66
+ declare function isAccountAllowanceExhaustedError(error: unknown): error is AccountAllowanceExhaustedError;
67
+ declare class AccountAllowanceScheduling {
68
+ private readonly store;
69
+ private readonly now;
70
+ private config;
71
+ private readonly history;
72
+ private readonly lastRecorded;
73
+ constructor(store?: AccountAllowanceStore, now?: () => number);
74
+ configure(config: AllowanceSchedulingConfig | undefined): void;
75
+ getConfig(): AllowanceSchedulingConfig;
76
+ evaluate(providerId: SubscriptionProviderId, accountId: string, basePriority: number, now?: number): AllowanceSchedulingDecision;
77
+ /**
78
+ * Project the current policy result without recording an applied decision.
79
+ * Admin/read-model callers use this so polling an account list never creates
80
+ * synthetic demotion/pause history entries.
81
+ */
82
+ preview(providerId: SubscriptionProviderId, accountId: string, basePriority: number, now?: number): AllowanceSchedulingDecision;
83
+ private decide;
84
+ getHistory(): AllowanceSchedulingDecision[];
85
+ clearHistory(): void;
86
+ private recordApplied;
87
+ }
88
+ declare function getSharedAccountAllowanceScheduling(): AccountAllowanceScheduling;
89
+ declare function __resetSharedAccountAllowanceSchedulingForTests(): void;
90
+
91
+ export { AccountAllowanceExhaustedError, AccountAllowanceScheduling, type AllowanceSchedulingAction, type AllowanceSchedulingDecision, __resetSharedAccountAllowanceSchedulingForTests, getSharedAccountAllowanceScheduling, isAccountAllowanceExhaustedError };
@@ -0,0 +1,15 @@
1
+ import {
2
+ AccountAllowanceExhaustedError,
3
+ AccountAllowanceScheduling,
4
+ __resetSharedAccountAllowanceSchedulingForTests,
5
+ getSharedAccountAllowanceScheduling,
6
+ isAccountAllowanceExhaustedError
7
+ } from "../chunk-OPRS4IQZ.js";
8
+ import "../chunk-MKF46GNZ.js";
9
+ export {
10
+ AccountAllowanceExhaustedError,
11
+ AccountAllowanceScheduling,
12
+ __resetSharedAccountAllowanceSchedulingForTests,
13
+ getSharedAccountAllowanceScheduling,
14
+ isAccountAllowanceExhaustedError
15
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ var _chunkHVBBDBS3cjs = require('../chunk-HVBBDBS3.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ exports.AccountAllowanceStore = _chunkHVBBDBS3cjs.AccountAllowanceStore; exports.DEFAULT_ALLOWANCE_MAX_SNAPSHOTS = _chunkHVBBDBS3cjs.DEFAULT_ALLOWANCE_MAX_SNAPSHOTS; exports.DEFAULT_CODEX_ALLOWANCE_FRESH_MS = _chunkHVBBDBS3cjs.DEFAULT_CODEX_ALLOWANCE_FRESH_MS; exports.__resetSharedAccountAllowanceStoreForTests = _chunkHVBBDBS3cjs.__resetSharedAccountAllowanceStoreForTests; exports.getSharedAccountAllowanceStore = _chunkHVBBDBS3cjs.getSharedAccountAllowanceStore; exports.normalizeAccountAllowanceSnapshot = _chunkHVBBDBS3cjs.normalizeAccountAllowanceSnapshot; exports.parseCodexAllowanceHeaders = _chunkHVBBDBS3cjs.parseCodexAllowanceHeaders; exports.setSharedAccountAllowanceStore = _chunkHVBBDBS3cjs.setSharedAccountAllowanceStore;
@@ -0,0 +1,77 @@
1
+ import { AccountAllowanceSnapshot } from '@omnicross/contracts/account-allowance-types';
2
+ import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
3
+
4
+ /**
5
+ * Secret-free upstream account allowance snapshots.
6
+ *
7
+ * Claude actively populates this store from the daemon. Codex is observed at the
8
+ * core egress seam so the response headers are attributed to the exact account id
9
+ * selected for that request. Only normalized numbers are retained; raw headers
10
+ * and credentials never enter the store. A host may inject a small persistence
11
+ * port; core deliberately does not know where that host stores the snapshot.
12
+ */
13
+
14
+ declare const DEFAULT_CODEX_ALLOWANCE_FRESH_MS: number;
15
+ declare const DEFAULT_ALLOWANCE_MAX_SNAPSHOTS = 256;
16
+ type AllowanceHeadersLike = Headers | Record<string, string | string[] | number | null | undefined>;
17
+ interface CodexAllowanceWindowObservation {
18
+ usedPercent?: number;
19
+ resetAfterSeconds?: number;
20
+ windowMinutes?: number;
21
+ }
22
+ interface CodexAllowanceObservation {
23
+ primary?: CodexAllowanceWindowObservation;
24
+ secondary?: CodexAllowanceWindowObservation;
25
+ primaryOverSecondaryLimitPercent?: number;
26
+ }
27
+ /** Host-owned persistence seam for normalized allowance snapshots. */
28
+ interface AccountAllowancePersistence {
29
+ /** Return the decoded file payload, or any value for the store to validate. */
30
+ load(): unknown;
31
+ /** Replace the durable snapshot with this already-normalized bounded list. */
32
+ save(snapshots: readonly AccountAllowanceSnapshot[]): void;
33
+ }
34
+ /**
35
+ * Pick and normalize only the public DTO fields. This is used for both live
36
+ * writes and restart loads, so a structurally-cast object can never smuggle raw
37
+ * headers, response bodies, or token fields into the cache.
38
+ */
39
+ declare function normalizeAccountAllowanceSnapshot(value: unknown): AccountAllowanceSnapshot | null;
40
+ /** Parse only the documented numeric Codex allowance headers. */
41
+ declare function parseCodexAllowanceHeaders(headers: AllowanceHeadersLike): CodexAllowanceObservation | null;
42
+ /** In-memory allowance projection shared by serving/admin with optional host persistence. */
43
+ declare class AccountAllowanceStore {
44
+ private readonly now;
45
+ private readonly codexFreshMs;
46
+ private readonly persistence?;
47
+ private readonly snapshots;
48
+ private readonly maxSnapshots;
49
+ constructor(now?: () => number, codexFreshMs?: number, persistence?: AccountAllowancePersistence | undefined, maxSnapshots?: number);
50
+ set(snapshot: AccountAllowanceSnapshot): void;
51
+ delete(providerId: SubscriptionProviderId, accountId: string): void;
52
+ /** Remove rows that no longer correspond to a configured account. */
53
+ pruneToKnownAccounts(accounts: Iterable<{
54
+ providerId: SubscriptionProviderId;
55
+ accountId: string;
56
+ }>): number;
57
+ get(providerId: SubscriptionProviderId, accountId: string, now?: number): AccountAllowanceSnapshot | null;
58
+ list(filter?: {
59
+ providerId?: SubscriptionProviderId;
60
+ accountId?: string;
61
+ }, now?: number): AccountAllowanceSnapshot[];
62
+ /**
63
+ * Merge one real Codex upstream response into the selected account's snapshot.
64
+ * A response with no recognized headers is a strict no-op, and a partial header
65
+ * set preserves previous values while marking untouched windows stale.
66
+ */
67
+ recordCodexHeaders(accountId: string, headers: AllowanceHeadersLike, observedMs?: number): AccountAllowanceSnapshot | null;
68
+ clear(): void;
69
+ private loadPersisted;
70
+ private persist;
71
+ }
72
+ declare function getSharedAccountAllowanceStore(): AccountAllowanceStore;
73
+ declare function setSharedAccountAllowanceStore(store: AccountAllowanceStore): void;
74
+ /** Test/daemon teardown seam. */
75
+ declare function __resetSharedAccountAllowanceStoreForTests(): void;
76
+
77
+ export { type AccountAllowancePersistence, AccountAllowanceStore, type AllowanceHeadersLike, type CodexAllowanceObservation, type CodexAllowanceWindowObservation, DEFAULT_ALLOWANCE_MAX_SNAPSHOTS, DEFAULT_CODEX_ALLOWANCE_FRESH_MS, __resetSharedAccountAllowanceStoreForTests, getSharedAccountAllowanceStore, normalizeAccountAllowanceSnapshot, parseCodexAllowanceHeaders, setSharedAccountAllowanceStore };
@@ -0,0 +1,77 @@
1
+ import { AccountAllowanceSnapshot } from '@omnicross/contracts/account-allowance-types';
2
+ import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
3
+
4
+ /**
5
+ * Secret-free upstream account allowance snapshots.
6
+ *
7
+ * Claude actively populates this store from the daemon. Codex is observed at the
8
+ * core egress seam so the response headers are attributed to the exact account id
9
+ * selected for that request. Only normalized numbers are retained; raw headers
10
+ * and credentials never enter the store. A host may inject a small persistence
11
+ * port; core deliberately does not know where that host stores the snapshot.
12
+ */
13
+
14
+ declare const DEFAULT_CODEX_ALLOWANCE_FRESH_MS: number;
15
+ declare const DEFAULT_ALLOWANCE_MAX_SNAPSHOTS = 256;
16
+ type AllowanceHeadersLike = Headers | Record<string, string | string[] | number | null | undefined>;
17
+ interface CodexAllowanceWindowObservation {
18
+ usedPercent?: number;
19
+ resetAfterSeconds?: number;
20
+ windowMinutes?: number;
21
+ }
22
+ interface CodexAllowanceObservation {
23
+ primary?: CodexAllowanceWindowObservation;
24
+ secondary?: CodexAllowanceWindowObservation;
25
+ primaryOverSecondaryLimitPercent?: number;
26
+ }
27
+ /** Host-owned persistence seam for normalized allowance snapshots. */
28
+ interface AccountAllowancePersistence {
29
+ /** Return the decoded file payload, or any value for the store to validate. */
30
+ load(): unknown;
31
+ /** Replace the durable snapshot with this already-normalized bounded list. */
32
+ save(snapshots: readonly AccountAllowanceSnapshot[]): void;
33
+ }
34
+ /**
35
+ * Pick and normalize only the public DTO fields. This is used for both live
36
+ * writes and restart loads, so a structurally-cast object can never smuggle raw
37
+ * headers, response bodies, or token fields into the cache.
38
+ */
39
+ declare function normalizeAccountAllowanceSnapshot(value: unknown): AccountAllowanceSnapshot | null;
40
+ /** Parse only the documented numeric Codex allowance headers. */
41
+ declare function parseCodexAllowanceHeaders(headers: AllowanceHeadersLike): CodexAllowanceObservation | null;
42
+ /** In-memory allowance projection shared by serving/admin with optional host persistence. */
43
+ declare class AccountAllowanceStore {
44
+ private readonly now;
45
+ private readonly codexFreshMs;
46
+ private readonly persistence?;
47
+ private readonly snapshots;
48
+ private readonly maxSnapshots;
49
+ constructor(now?: () => number, codexFreshMs?: number, persistence?: AccountAllowancePersistence | undefined, maxSnapshots?: number);
50
+ set(snapshot: AccountAllowanceSnapshot): void;
51
+ delete(providerId: SubscriptionProviderId, accountId: string): void;
52
+ /** Remove rows that no longer correspond to a configured account. */
53
+ pruneToKnownAccounts(accounts: Iterable<{
54
+ providerId: SubscriptionProviderId;
55
+ accountId: string;
56
+ }>): number;
57
+ get(providerId: SubscriptionProviderId, accountId: string, now?: number): AccountAllowanceSnapshot | null;
58
+ list(filter?: {
59
+ providerId?: SubscriptionProviderId;
60
+ accountId?: string;
61
+ }, now?: number): AccountAllowanceSnapshot[];
62
+ /**
63
+ * Merge one real Codex upstream response into the selected account's snapshot.
64
+ * A response with no recognized headers is a strict no-op, and a partial header
65
+ * set preserves previous values while marking untouched windows stale.
66
+ */
67
+ recordCodexHeaders(accountId: string, headers: AllowanceHeadersLike, observedMs?: number): AccountAllowanceSnapshot | null;
68
+ clear(): void;
69
+ private loadPersisted;
70
+ private persist;
71
+ }
72
+ declare function getSharedAccountAllowanceStore(): AccountAllowanceStore;
73
+ declare function setSharedAccountAllowanceStore(store: AccountAllowanceStore): void;
74
+ /** Test/daemon teardown seam. */
75
+ declare function __resetSharedAccountAllowanceStoreForTests(): void;
76
+
77
+ export { type AccountAllowancePersistence, AccountAllowanceStore, type AllowanceHeadersLike, type CodexAllowanceObservation, type CodexAllowanceWindowObservation, DEFAULT_ALLOWANCE_MAX_SNAPSHOTS, DEFAULT_CODEX_ALLOWANCE_FRESH_MS, __resetSharedAccountAllowanceStoreForTests, getSharedAccountAllowanceStore, normalizeAccountAllowanceSnapshot, parseCodexAllowanceHeaders, setSharedAccountAllowanceStore };
@@ -0,0 +1,20 @@
1
+ import {
2
+ AccountAllowanceStore,
3
+ DEFAULT_ALLOWANCE_MAX_SNAPSHOTS,
4
+ DEFAULT_CODEX_ALLOWANCE_FRESH_MS,
5
+ __resetSharedAccountAllowanceStoreForTests,
6
+ getSharedAccountAllowanceStore,
7
+ normalizeAccountAllowanceSnapshot,
8
+ parseCodexAllowanceHeaders,
9
+ setSharedAccountAllowanceStore
10
+ } from "../chunk-MKF46GNZ.js";
11
+ export {
12
+ AccountAllowanceStore,
13
+ DEFAULT_ALLOWANCE_MAX_SNAPSHOTS,
14
+ DEFAULT_CODEX_ALLOWANCE_FRESH_MS,
15
+ __resetSharedAccountAllowanceStoreForTests,
16
+ getSharedAccountAllowanceStore,
17
+ normalizeAccountAllowanceSnapshot,
18
+ parseCodexAllowanceHeaders,
19
+ setSharedAccountAllowanceStore
20
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkNKVZ6Z3Ycjs = require('../chunk-NKVZ6Z3Y.cjs');
6
+
7
+
8
+
9
+
10
+ exports.ACCOUNT_ROUTE_ACTIVITY_LIMIT = _chunkNKVZ6Z3Ycjs.ACCOUNT_ROUTE_ACTIVITY_LIMIT; exports.AccountRouteActivityStore = _chunkNKVZ6Z3Ycjs.AccountRouteActivityStore; exports.getSharedAccountRouteActivity = _chunkNKVZ6Z3Ycjs.getSharedAccountRouteActivity;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Bounded, metadata-only history of subscription account routing decisions.
3
+ *
4
+ * Records are created at the shared upstream fetch seam, after authentication has
5
+ * reported the account that will actually serve the request. The store is
6
+ * intentionally process-local: it is useful for live operator diagnostics without
7
+ * turning session/account affinity into a durable tracking database.
8
+ */
9
+ declare const ACCOUNT_ROUTE_ACTIVITY_LIMIT = 300;
10
+ type AccountRouteEndpoint = 'responses' | 'messages';
11
+ type AccountRouteSessionSource = 'session-header' | 'thread-header' | 'body-session-id' | 'body-thread-id' | 'prompt-cache-key' | 'content-fingerprint' | 'api-key-fallback' | 'none';
12
+ type AccountRouteAffinity = 'new' | 'sticky' | 'switched' | 'untracked';
13
+ interface AccountRouteActivityInput {
14
+ providerId: string;
15
+ accountId: string;
16
+ endpoint: AccountRouteEndpoint;
17
+ sessionKey?: string;
18
+ sessionSource: AccountRouteSessionSource;
19
+ model: string;
20
+ status: number;
21
+ durationMs: number;
22
+ ts?: number;
23
+ /**
24
+ * Post-hoc error observed AFTER the upstream status was recorded — e.g. a
25
+ * `200` whose SSE body carries a `response.failed` server-overload event.
26
+ * Never known at `record()` time; set later via {@link amend}. Absent on
27
+ * healthy responses.
28
+ */
29
+ streamError?: string;
30
+ }
31
+ interface AccountRouteActivityRecord extends AccountRouteActivityInput {
32
+ id: string;
33
+ ts: number;
34
+ affinity: AccountRouteAffinity;
35
+ previousAccountId?: string;
36
+ }
37
+ interface AccountRouteActivityQuery {
38
+ providerId?: string;
39
+ accountId?: string;
40
+ sessionKey?: string;
41
+ limit?: number;
42
+ }
43
+ declare class AccountRouteActivityStore {
44
+ private readonly records;
45
+ private sequence;
46
+ record(input: AccountRouteActivityInput): AccountRouteActivityRecord;
47
+ list(query?: AccountRouteActivityQuery): AccountRouteActivityRecord[];
48
+ clear(): void;
49
+ /**
50
+ * Backfill a field on an already-recorded entry. Used to annotate a record
51
+ * AFTER the upstream body streams — e.g. a `200` whose SSE body carries a
52
+ * `response.failed` overload event is only detectable mid-relay, long after
53
+ * `record()` stamped the 200 status. `patch` is intentionally narrow: only
54
+ * post-hoc-observable fields belong here, never the routing-decision fields.
55
+ * No-op when the id has already aged out of the bounded ring.
56
+ */
57
+ amend(id: string, patch: Partial<Pick<AccountRouteActivityRecord, 'streamError'>>): void;
58
+ }
59
+ declare function getSharedAccountRouteActivity(): AccountRouteActivityStore;
60
+
61
+ export { ACCOUNT_ROUTE_ACTIVITY_LIMIT, type AccountRouteActivityInput, type AccountRouteActivityQuery, type AccountRouteActivityRecord, AccountRouteActivityStore, type AccountRouteAffinity, type AccountRouteEndpoint, type AccountRouteSessionSource, getSharedAccountRouteActivity };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Bounded, metadata-only history of subscription account routing decisions.
3
+ *
4
+ * Records are created at the shared upstream fetch seam, after authentication has
5
+ * reported the account that will actually serve the request. The store is
6
+ * intentionally process-local: it is useful for live operator diagnostics without
7
+ * turning session/account affinity into a durable tracking database.
8
+ */
9
+ declare const ACCOUNT_ROUTE_ACTIVITY_LIMIT = 300;
10
+ type AccountRouteEndpoint = 'responses' | 'messages';
11
+ type AccountRouteSessionSource = 'session-header' | 'thread-header' | 'body-session-id' | 'body-thread-id' | 'prompt-cache-key' | 'content-fingerprint' | 'api-key-fallback' | 'none';
12
+ type AccountRouteAffinity = 'new' | 'sticky' | 'switched' | 'untracked';
13
+ interface AccountRouteActivityInput {
14
+ providerId: string;
15
+ accountId: string;
16
+ endpoint: AccountRouteEndpoint;
17
+ sessionKey?: string;
18
+ sessionSource: AccountRouteSessionSource;
19
+ model: string;
20
+ status: number;
21
+ durationMs: number;
22
+ ts?: number;
23
+ /**
24
+ * Post-hoc error observed AFTER the upstream status was recorded — e.g. a
25
+ * `200` whose SSE body carries a `response.failed` server-overload event.
26
+ * Never known at `record()` time; set later via {@link amend}. Absent on
27
+ * healthy responses.
28
+ */
29
+ streamError?: string;
30
+ }
31
+ interface AccountRouteActivityRecord extends AccountRouteActivityInput {
32
+ id: string;
33
+ ts: number;
34
+ affinity: AccountRouteAffinity;
35
+ previousAccountId?: string;
36
+ }
37
+ interface AccountRouteActivityQuery {
38
+ providerId?: string;
39
+ accountId?: string;
40
+ sessionKey?: string;
41
+ limit?: number;
42
+ }
43
+ declare class AccountRouteActivityStore {
44
+ private readonly records;
45
+ private sequence;
46
+ record(input: AccountRouteActivityInput): AccountRouteActivityRecord;
47
+ list(query?: AccountRouteActivityQuery): AccountRouteActivityRecord[];
48
+ clear(): void;
49
+ /**
50
+ * Backfill a field on an already-recorded entry. Used to annotate a record
51
+ * AFTER the upstream body streams — e.g. a `200` whose SSE body carries a
52
+ * `response.failed` overload event is only detectable mid-relay, long after
53
+ * `record()` stamped the 200 status. `patch` is intentionally narrow: only
54
+ * post-hoc-observable fields belong here, never the routing-decision fields.
55
+ * No-op when the id has already aged out of the bounded ring.
56
+ */
57
+ amend(id: string, patch: Partial<Pick<AccountRouteActivityRecord, 'streamError'>>): void;
58
+ }
59
+ declare function getSharedAccountRouteActivity(): AccountRouteActivityStore;
60
+
61
+ export { ACCOUNT_ROUTE_ACTIVITY_LIMIT, type AccountRouteActivityInput, type AccountRouteActivityQuery, type AccountRouteActivityRecord, AccountRouteActivityStore, type AccountRouteAffinity, type AccountRouteEndpoint, type AccountRouteSessionSource, getSharedAccountRouteActivity };
@@ -0,0 +1,10 @@
1
+ import {
2
+ ACCOUNT_ROUTE_ACTIVITY_LIMIT,
3
+ AccountRouteActivityStore,
4
+ getSharedAccountRouteActivity
5
+ } from "../chunk-GL6XM527.js";
6
+ export {
7
+ ACCOUNT_ROUTE_ACTIVITY_LIMIT,
8
+ AccountRouteActivityStore,
9
+ getSharedAccountRouteActivity
10
+ };
@@ -1,3 +1,5 @@
1
+ import { BoundAccountFallbackPolicy } from './BoundAccountSelectionError.cjs';
2
+
1
3
  /**
2
4
  * AuthSource — unified outbound-authentication strategy for the provider
3
5
  * request pipeline.
@@ -54,10 +56,17 @@ interface AuthApplyHints {
54
56
  reportSelection?: (accountId: string, isActive: boolean, remappedModel?: string) => void;
55
57
  /**
56
58
  * OPTIONAL preferred subscription account id (provider/subscription duality).
57
- * When set and schedulable the account picker resolves it directly; absent or
58
- * unschedulable ⇒ pool auto-schedule. BYO auth sources ignore it.
59
+ * When set, strict is the default; only the explicit `'pool'` policy permits
60
+ * pool fallback. BYO auth sources ignore both binding hints.
59
61
  */
60
62
  preferredAccountId?: string;
63
+ /** Optional account group selected by a resource-level gateway binding. */
64
+ preferredAccountGroup?: string;
65
+ /**
66
+ * Binding behavior. `'pool'` is an explicit opt-in; any other value used
67
+ * with a preferred account is treated as strict by the selector.
68
+ */
69
+ boundAccountFallbackPolicy?: BoundAccountFallbackPolicy;
61
70
  }
62
71
  /**
63
72
  * Result of {@link AuthSource.onResult}.
@@ -1,3 +1,5 @@
1
+ import { BoundAccountFallbackPolicy } from './BoundAccountSelectionError.js';
2
+
1
3
  /**
2
4
  * AuthSource — unified outbound-authentication strategy for the provider
3
5
  * request pipeline.
@@ -54,10 +56,17 @@ interface AuthApplyHints {
54
56
  reportSelection?: (accountId: string, isActive: boolean, remappedModel?: string) => void;
55
57
  /**
56
58
  * OPTIONAL preferred subscription account id (provider/subscription duality).
57
- * When set and schedulable the account picker resolves it directly; absent or
58
- * unschedulable ⇒ pool auto-schedule. BYO auth sources ignore it.
59
+ * When set, strict is the default; only the explicit `'pool'` policy permits
60
+ * pool fallback. BYO auth sources ignore both binding hints.
59
61
  */
60
62
  preferredAccountId?: string;
63
+ /** Optional account group selected by a resource-level gateway binding. */
64
+ preferredAccountGroup?: string;
65
+ /**
66
+ * Binding behavior. `'pool'` is an explicit opt-in; any other value used
67
+ * with a preferred account is treated as strict by the selector.
68
+ */
69
+ boundAccountFallbackPolicy?: BoundAccountFallbackPolicy;
61
70
  }
62
71
  /**
63
72
  * Result of {@link AuthSource.onResult}.
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunk25GXJCEZcjs = require('../chunk-25GXJCEZ.cjs');
6
+
7
+
8
+
9
+
10
+ exports.BoundAccountSelectionError = _chunk25GXJCEZcjs.BoundAccountSelectionError; exports.boundAccountSelectionMessage = _chunk25GXJCEZcjs.boundAccountSelectionMessage; exports.isBoundAccountSelectionError = _chunk25GXJCEZcjs.isBoundAccountSelectionError;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Secret-free failure contract for a strict outbound subscription-account
3
+ * binding. The selector throws this value only when an endpoint explicitly (or
4
+ * by the migrated default) requires its bound account to serve the request.
5
+ */
6
+ /** Persisted policy for an endpoint that binds a subscription account. */
7
+ type BoundAccountFallbackPolicy = 'strict' | 'pool';
8
+ /** Bounded reasons a strict bound account can refuse a request. */
9
+ type BoundAccountSelectionFailureReason = 'unavailable' | 'not-found' | 'disabled' | 'unhealthy' | 'model-incompatible' | 'allowance-paused' | 'empty-token';
10
+ /** Return the fixed public message for a validated failure reason. */
11
+ declare function boundAccountSelectionMessage(reason: BoundAccountSelectionFailureReason): string;
12
+ /**
13
+ * Stable, non-secret error thrown by strict account selection. Account ids and
14
+ * token material are intentionally absent from both the message and the wire
15
+ * projection; the reason is a small fixed vocabulary.
16
+ */
17
+ declare class BoundAccountSelectionError extends Error {
18
+ readonly providerId: string;
19
+ readonly reason: BoundAccountSelectionFailureReason;
20
+ readonly resumeAt?: string | undefined;
21
+ readonly code: "bound_account_unavailable";
22
+ readonly status: 429 | 503;
23
+ constructor(providerId: string, reason: BoundAccountSelectionFailureReason, resumeAt?: string | undefined);
24
+ }
25
+ /** Structural guard that survives package/bundle boundaries. */
26
+ declare function isBoundAccountSelectionError(error: unknown): error is BoundAccountSelectionError;
27
+
28
+ export { type BoundAccountFallbackPolicy, BoundAccountSelectionError, type BoundAccountSelectionFailureReason, boundAccountSelectionMessage, isBoundAccountSelectionError };