@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
@@ -1,6 +1,6 @@
1
1
  import { VoucherConfig } from '@omnicross/contracts/voucher-types';
2
- import { e as KindMappedEndpoint, f as ModelKind, m as OutboundEndpoint, b as EndpointRoutingConfig, k as OutboundApiServerConfig, U as UserMessageQueueConfig, a as ConcurrencyQueueConfig, h as OutboundApiDeps, l as OutboundApiServerStatus, n as OutboundFormatUrls, A as AccountProbeConfig, F as FingerprintConfig, g as ModelPrefixTargets, r as OutboundProxyConfig, G as ModelRef, O as OutboundKeyDb, i as OutboundApiKeyCreated, R as RequestRole } from './types-lgPYQuZS.js';
3
- export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS, K as KeySpendReader, c as KeySpendSeeder, d as KeySpendTracker, M as MessagesModelKind, j as OutboundApiKeyInfo, o as OutboundKeyActivationMode, p as OutboundKeyDbRow, q as OutboundKeyPolicy, s as ResponsesModelKind, V as VoucherCreateInput, t as VoucherDb, u as computeVoucherGrant, v as generateVoucherCode, w as hashVoucherCode, x as newVoucherId, y as startOfLocalDay, z as startOfLocalWeek, B as toVoucherInfo, D as voucherCodePrefix } from './types-lgPYQuZS.js';
2
+ import { c as EndpointRoutingConfig, G as GatewayBinding, U as UserMessageQueueConfig, b as ConcurrencyQueueConfig, n as OutboundApiDeps, r as OutboundApiServerStatus, t as OutboundFormatUrls, A as AccountProbeConfig, a as AllowanceSchedulingConfig, F as FingerprintConfig, q as OutboundApiServerConfig, m as ModelPrefixTargets, x as OutboundProxyConfig, s as OutboundEndpoint, R as RequestRole, Q as ModelRef, k as KindMappedEndpoint, l as ModelKind, O as OutboundKeyDb, o as OutboundApiKeyCreated } from './types-hsoKrVQS.js';
3
+ export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS, d as GatewayBindingFallback, e as GatewayBindingKeyScope, f as GatewayBindingModelMode, g as GatewayBindingTarget, h as GatewayModelMapping, K as KeySpendReader, i as KeySpendSeeder, j as KeySpendTracker, M as MessagesModelKind, p as OutboundApiKeyInfo, u as OutboundKeyActivationMode, v as OutboundKeyDbRow, w as OutboundKeyPolicy, y as ResponsesModelKind, V as VoucherCreateInput, z as VoucherDb, B as computeVoucherGrant, D as generateVoucherCode, H as hashVoucherCode, I as newVoucherId, J as startOfLocalDay, L as startOfLocalWeek, N as toVoucherInfo, P as voucherCodePrefix } from './types-hsoKrVQS.js';
4
4
  import { ProxyConfig } from '@omnicross/contracts/account-tokens-types';
5
5
  import { AuditConfig } from '@omnicross/contracts/audit-types';
6
6
  import { BillingConfig } from '@omnicross/contracts/billing-types';
@@ -8,11 +8,12 @@ import { WebhookDestination, WebhookConfig } from '@omnicross/contracts/webhook-
8
8
  export { AUDIT_REDACTED, redactAuditText } from './outbound-api/auditRedact.js';
9
9
  export { AuditCaptureContext, beginAuditCapture } from './outbound-api/auditCapture.js';
10
10
  export { BillingCaptureContext, beginBillingCapture } from './outbound-api/billingCapture.js';
11
- import { K as KeyCostLimits, M as ModelRestriction } from './keyPolicy-Cp0FntZl.js';
12
- export { a as KeyExpiryInput, b as KeyExpiryResult, c as KeySpend, Q as QuotaDecision, d as checkKeyQuota, e as computeKeyExpiry } from './keyPolicy-Cp0FntZl.js';
11
+ import { K as KeyCostLimits, M as ModelRestriction } from './keyPolicy-zdWTu3CQ.js';
12
+ export { a as KeyExpiryInput, b as KeyExpiryResult, c as KeySpend, Q as QuotaDecision, d as checkKeyQuota, e as computeKeyExpiry } from './keyPolicy-zdWTu3CQ.js';
13
13
  import http from 'node:http';
14
14
  import { IngressFormat } from './provider-proxy/types.js';
15
- export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-C4T7yClx.js';
15
+ export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-CHTv_Bs5.js';
16
+ export { BoundAccountFallbackPolicy, BoundAccountSelectionError, BoundAccountSelectionFailureReason, boundAccountSelectionMessage, isBoundAccountSelectionError } from './pipeline/BoundAccountSelectionError.js';
16
17
  import '@omnicross/contracts/health-logging-types';
17
18
  import './logger-4GvQNzhE.js';
18
19
  import './ports/provider-config-source.js';
@@ -30,70 +31,6 @@ import './pipeline/SubscriptionAuthStrategy.js';
30
31
  import './ports/web-search-backend.js';
31
32
  import '@omnicross/contracts/websearch-types';
32
33
 
33
- /**
34
- * kindDetection — classify an outbound request's model KIND for the kind-mapped
35
- * endpoints (`messages`/`responses`) and validate their config completeness
36
- * (`outbound-api-server`, model-kind-mapping contract).
37
- *
38
- * The kind-mapped endpoints route by a version-INDEPENDENT model KIND rather
39
- * than by role: the user configures one upstream ref per kind
40
- * ({@link ENDPOINT_MODEL_KINDS}) and an incoming versioned client id
41
- * (`claude-opus-4-8-2026xxxx`) is classified to its kind (`opus`) so CLI
42
- * upgrades need no reconfig. `chat`/`gemini` stay on `roleDetection`.
43
- *
44
- * Pure module — no I/O. The router decides, per endpoint, whether to call
45
- * `detectModelKind` (messages/responses) or `detectRequestRole` (chat/gemini);
46
- * the routing RESOLUTION and the startup-gate ENFORCEMENT live downstream.
47
- *
48
- * @module outbound-api/kindDetection
49
- */
50
-
51
- /**
52
- * Narrow an endpoint to the kind-mapped set (`messages`/`responses`). `chat`
53
- * and `gemini` are role-based and return false.
54
- */
55
- declare function isKindMappedEndpoint(endpoint: OutboundEndpoint): endpoint is KindMappedEndpoint;
56
- /** The canonical kinds for a kind-mapped endpoint (in declaration order). */
57
- declare function modelKindsForEndpoint(endpoint: KindMappedEndpoint): readonly ModelKind[];
58
- /**
59
- * Extract the version-INDEPENDENT model KIND for a kind-mapped endpoint.
60
- * - `messages`: the FIRST id token that is one of {fable,opus,sonnet,haiku};
61
- * `undefined` when no token matches (the unmatched-kind fallback is SERVING's
62
- * decision, not core's).
63
- * - `responses`: `mini` when {@link isBackgroundTierModel}; else `codex`
64
- * (codex is the else-branch — a present id always resolves).
65
- * - Any empty/blank id ⇒ `undefined`.
66
- *
67
- * Reuses `normalizeModelId` + the shared `/[-._:/\s]+/` tokenizer
68
- * (`modelTokens`) + the small-tier token set (`isBackgroundTierModel`) so the
69
- * kind and role detectors stay token-boundary-consistent.
70
- */
71
- declare function detectModelKind(endpoint: KindMappedEndpoint, requestedModelId: string | undefined): ModelKind | undefined;
72
- /**
73
- * The kinds THIS endpoint declares but leaves unconfigured (blank/absent ref).
74
- * Role-based endpoints (`chat`/`gemini`) have no declared kinds → `[]`.
75
- * Absent and blank refs are treated identically; a malformed-but-non-blank ref
76
- * is a serving-time concern, not a startup-gate one.
77
- */
78
- declare function validateEndpointModelConfig(config: EndpointRoutingConfig): ModelKind[];
79
- /** One incomplete kind-mapped endpoint and the kinds it is missing. */
80
- interface EndpointModelConfigError {
81
- endpoint: KindMappedEndpoint;
82
- missingKinds: ModelKind[];
83
- }
84
- /**
85
- * Server-level completeness, PER-ENDPOINT: a kind-mapped endpoint whose
86
- * declared kinds are ALL blank/absent counts as UNCONFIGURED — the operator
87
- * simply doesn't use that endpoint, so it does NOT block startup (its requests
88
- * 503 per-request instead). Only a PARTIALLY configured endpoint (some kinds
89
- * set, some blank — a real config mistake that would silently misroute) is
90
- * returned as an error. Empty result ⇒ the config satisfies the startup gate.
91
- *
92
- * Serving consumes this for the gate ENFORCEMENT; it MAY tighten to an
93
- * all-endpoints-strict policy by composing {@link validateEndpointModelConfig}.
94
- */
95
- declare function validateServerModelConfig(config: OutboundApiServerConfig): EndpointModelConfigError[];
96
-
97
34
  /**
98
35
  * OutboundApiServer — the external-facing HTTP listener for the outbound API
99
36
  * server (`outbound-api-server`, design D1/D4/D5).
@@ -125,6 +62,8 @@ interface ApplyConfigInput {
125
62
  enabled: boolean;
126
63
  networkBinding: boolean;
127
64
  endpoints: EndpointRoutingConfig[];
65
+ /** Independent resource bindings; absent preserves legacy endpoint routing. */
66
+ bindings?: GatewayBinding[];
128
67
  port?: number;
129
68
  /** User-message serial-queue segment (normalized/defaulted by core). */
130
69
  userMessageQueue?: UserMessageQueueConfig;
@@ -134,17 +73,6 @@ interface ApplyConfigInput {
134
73
  * disabled ⇒ the `/redeem` endpoint is inert (zero regression). */
135
74
  voucher?: VoucherConfig;
136
75
  }
137
- /**
138
- * Thrown by {@link OutboundApiServer.applyConfig} when an ENABLED server is asked
139
- * to bind with an INCOMPLETE model-kind map (the "未配置 → 无法启动接口服务" gate,
140
- * design D6). Carries the per-endpoint missing kinds so the daemon/UI can render
141
- * an actionable message; the server does NOT bind. Exported from the barrel so
142
- * the daemon (surface) can `instanceof`-narrow it.
143
- */
144
- declare class OutboundApiConfigError extends Error {
145
- readonly missing: EndpointModelConfigError[];
146
- constructor(missing: EndpointModelConfigError[]);
147
- }
148
76
  declare class OutboundApiServer {
149
77
  private readonly deps;
150
78
  /** Called when the actual bound port differs from the requested one. */
@@ -153,6 +81,7 @@ declare class OutboundApiServer {
153
81
  private boundPort;
154
82
  private boundAddr;
155
83
  private endpoints;
84
+ private bindings;
156
85
  private userMessageQueue;
157
86
  private concurrencyQueue;
158
87
  private voucherConfig;
@@ -256,6 +185,10 @@ declare const DEFAULT_CONCURRENCY_QUEUE: ConcurrencyQueueConfig;
256
185
  * a load-safety valve (see `AccountProbeConfig`).
257
186
  */
258
187
  declare const DEFAULT_ACCOUNT_PROBE: AccountProbeConfig;
188
+ /** Default-off thresholds for allowance-aware account scheduling. */
189
+ declare const DEFAULT_ALLOWANCE_SCHEDULING: AllowanceSchedulingConfig;
190
+ /** Fill and clamp the optional allowance scheduling segment. */
191
+ declare function normalizeAllowanceScheduling(raw: Partial<OutboundApiServerConfig> | undefined | null): AllowanceSchedulingConfig;
259
192
  /** Fill + range-CLAMP the account-probe segment to the frozen defaults. */
260
193
  declare function normalizeAccountProbe(raw: Partial<OutboundApiServerConfig> | undefined | null): AccountProbeConfig;
261
194
  /**
@@ -359,6 +292,17 @@ interface ApiServerSettingsStore {
359
292
  * targets simply routes nothing until configured). Never throws.
360
293
  */
361
294
  declare function normalizePrefixTargets(raw: unknown): ModelPrefixTargets | undefined;
295
+ /**
296
+ * One-time migration off the removed global endpoint fallback: every configured
297
+ * legacy endpoint block becomes an equivalent downstream route. Runs only when
298
+ * the config carries no routes yet, so a user who has since deleted their routes
299
+ * does not get the old ones resurrected. Idempotent by construction —
300
+ * {@link normalizeServerConfig} blanks the legacy blocks in the same pass, so a
301
+ * second run finds nothing to project.
302
+ */
303
+ declare function legacyEndpointsToBindings(endpoints: readonly EndpointRoutingConfig[]): GatewayBinding[];
304
+ /** Normalize independent gateway bindings while dropping malformed entries. */
305
+ declare function normalizeGatewayBindings(raw: unknown): GatewayBinding[];
362
306
  /** The default server config: disabled, loopback, four blank endpoints. */
363
307
  declare function defaultServerConfig(): OutboundApiServerConfig;
364
308
  /**
@@ -374,6 +318,51 @@ declare function saveServerConfig(store: ApiServerSettingsStore, config: Outboun
374
318
  /** Apply a partial patch to a config, returning the merged whole. */
375
319
  declare function mergeServerConfig(current: OutboundApiServerConfig, patch: Partial<OutboundApiServerConfig>): OutboundApiServerConfig;
376
320
 
321
+ /**
322
+ * Either the winning route projected to the resolver shape, or `none` — no
323
+ * enabled route for this key/endpoint could serve the request. There is no
324
+ * global fallback: `none` is terminal and the caller answers with a route error.
325
+ */
326
+ type GatewayBindingResolution = {
327
+ source: 'binding';
328
+ binding: GatewayBinding;
329
+ config: EndpointRoutingConfig;
330
+ } | {
331
+ source: 'none';
332
+ };
333
+ interface ResolveGatewayBindingInput {
334
+ bindings: readonly GatewayBinding[] | undefined;
335
+ apiKeyId: string;
336
+ endpoint: OutboundEndpoint;
337
+ requestedModel?: string;
338
+ role?: RequestRole;
339
+ }
340
+ /** Project one downstream route into the legacy route-resolver shape. */
341
+ declare function gatewayBindingToEndpointConfig(binding: GatewayBinding, requestedModel?: string): EndpointRoutingConfig;
342
+ /**
343
+ * The enabled routes one verified key may enter on one endpoint, in resolution
344
+ * order. Exact key-scoped routes outrank unscoped ones (and suppress them
345
+ * entirely); within a tier the lower priority value wins, id breaking ties.
346
+ */
347
+ declare function candidateGatewayBindings(bindings: readonly GatewayBinding[] | undefined, apiKeyId: string, endpoint: OutboundEndpoint): GatewayBinding[];
348
+ /**
349
+ * The background-tier model ids the role-based endpoint should recognize for
350
+ * this request. Role detection runs BEFORE a route is picked (the pick needs the
351
+ * role), so the hint is the union across every candidate route.
352
+ */
353
+ declare function candidateBackgroundModelIds(bindings: readonly GatewayBinding[] | undefined, apiKeyId: string, endpoint: OutboundEndpoint): string[] | undefined;
354
+ /**
355
+ * Resolve the resource route for one verified client key. A route with
356
+ * `fallback: next` that has no model for this request yields to the next
357
+ * candidate, while `fail` remains selected immediately.
358
+ *
359
+ * When no candidate can serve, the FIRST candidate is still selected so route
360
+ * resolution produces its specific, actionable error (e.g. 404 for a model
361
+ * outside a chat route's list) rather than a generic one. `none` is reserved
362
+ * for having no candidate route at all.
363
+ */
364
+ declare function resolveGatewayBinding(input: ResolveGatewayBindingInput): GatewayBindingResolution;
365
+
377
366
  /**
378
367
  * modelPrefixDispatch — pure model-name PREFIX classification for the `chat`
379
368
  * endpoint's opt-in `dispatchMode: 'prefix'` (openai-chat-bridge #11, design D2).
@@ -426,8 +415,7 @@ declare function resolvePrefixTarget(targets: ModelPrefixTargets | undefined, mo
426
415
  * waiter can be CANCELLED (the wire layer binds this to `res.close` so a client
427
416
  * that disconnects mid-queue frees its spot). Release + cancel are idempotent
428
417
  * (guarded by a per-acquisition `settled` flag) so the wire's `finally` +
429
- * `res.once('close')` double-fire is safe this directly avoids the CRS #1130
430
- * slot leak.
418
+ * `res.once('close')` double-fire is safe and cannot leak a concurrency slot.
431
419
  *
432
420
  * Memory-only, injected clock, resets on restart. `limit <= 0` means unlimited
433
421
  * (the wire layer bypasses the gate entirely for such keys; a defensive call
@@ -526,8 +514,7 @@ declare class OutboundConcurrencyGate {
526
514
  * concurrent humans. Only human-INITIATED turns should be serialized; a
527
515
  * tool-loop turn (the client feeding a tool result back) must NOT be throttled
528
516
  * or it stalls the agent. This module classifies the LAST turn per ingress
529
- * format, aligned to claude-relay-service's `isUserMessageRequest` semantics but
530
- * covering all four omnicross ingress formats.
517
+ * format and covers all four Omnicross ingress formats.
531
518
  *
532
519
  * SAFETY BIAS: default `false` (bypass) on any shape it cannot POSITIVELY
533
520
  * classify as a human turn. Under-serializing only costs the (opt-in, default-
@@ -623,6 +610,53 @@ declare class UserMessageSerialQueue {
623
610
  reset(): void;
624
611
  }
625
612
 
613
+ /**
614
+ * kindDetection — classify an outbound request's model KIND for the kind-mapped
615
+ * endpoints (`messages`/`responses`) and validate their config completeness
616
+ * (`outbound-api-server`, model-kind-mapping contract).
617
+ *
618
+ * The kind-mapped endpoints route by a version-INDEPENDENT model KIND rather
619
+ * than by role: the user configures one upstream ref per kind
620
+ * ({@link ENDPOINT_MODEL_KINDS}) and an incoming versioned client id
621
+ * (`claude-opus-4-8-2026xxxx`) is classified to its kind (`opus`) so CLI
622
+ * upgrades need no reconfig. `chat`/`gemini` stay on `roleDetection`.
623
+ *
624
+ * Pure module — no I/O. The router decides, per endpoint, whether to call
625
+ * `detectModelKind` (messages/responses) or `detectRequestRole` (chat/gemini);
626
+ * the routing RESOLUTION and the startup-gate ENFORCEMENT live downstream.
627
+ *
628
+ * @module outbound-api/kindDetection
629
+ */
630
+
631
+ /**
632
+ * Narrow an endpoint to the kind-mapped set (`messages`/`responses`). `chat`
633
+ * and `gemini` are role-based and return false.
634
+ */
635
+ declare function isKindMappedEndpoint(endpoint: OutboundEndpoint): endpoint is KindMappedEndpoint;
636
+ /** The canonical kinds for a kind-mapped endpoint (in declaration order). */
637
+ declare function modelKindsForEndpoint(endpoint: KindMappedEndpoint): readonly ModelKind[];
638
+ /**
639
+ * Extract the version-INDEPENDENT model KIND for a kind-mapped endpoint.
640
+ * - `messages`: the FIRST id token that is one of {fable,opus,sonnet,haiku};
641
+ * `undefined` when no token matches (the unmatched-kind fallback is SERVING's
642
+ * decision, not core's).
643
+ * - `responses`: `mini` when {@link isBackgroundTierModel}; else `codex`
644
+ * (codex is the else-branch — a present id always resolves).
645
+ * - Any empty/blank id ⇒ `undefined`.
646
+ *
647
+ * Reuses `normalizeModelId` + the shared `/[-._:/\s]+/` tokenizer
648
+ * (`modelTokens`) + the small-tier token set (`isBackgroundTierModel`) so the
649
+ * kind and role detectors stay token-boundary-consistent.
650
+ */
651
+ declare function detectModelKind(endpoint: KindMappedEndpoint, requestedModelId: string | undefined): ModelKind | undefined;
652
+ /**
653
+ * The kinds THIS endpoint declares but leaves unconfigured (blank/absent ref).
654
+ * Role-based endpoints (`chat`/`gemini`) have no declared kinds → `[]`.
655
+ * Absent and blank refs are treated identically; a malformed-but-non-blank ref
656
+ * is a serving-time concern, not a startup-gate one.
657
+ */
658
+ declare function validateEndpointModelConfig(config: EndpointRoutingConfig): ModelKind[];
659
+
626
660
  /**
627
661
  * outboundApiKeyAuth — named-key generation, hashing, and verification for the
628
662
  * outbound API server (`outbound-api-server`).
@@ -649,12 +683,20 @@ declare function hashKey(secret: string): string;
649
683
  * prefix are stored.
650
684
  */
651
685
  declare function createNamedKey(db: OutboundKeyDb, name: string): Promise<OutboundApiKeyCreated>;
686
+ /**
687
+ * Mint the local gateway key used by native CLI configuration adapters. Unlike
688
+ * a user-distributed key it is explicitly loopback-only and endpoint-scoped.
689
+ */
690
+ declare function createIntegrationKey(db: OutboundKeyDb, name: string, allowedEndpoints?: OutboundEndpoint[]): Promise<OutboundApiKeyCreated>;
652
691
  /**
653
692
  * A verified key + the enforcement inputs carried from the row so the wire layer
654
693
  * runs its policy checks WITHOUT a second DB read (mirrors `maxConcurrency`).
655
694
  */
656
695
  interface VerifiedKey {
657
696
  id: string;
697
+ kind?: 'client' | 'integration';
698
+ allowedEndpoints?: OutboundEndpoint[];
699
+ loopbackOnly?: boolean;
658
700
  /**
659
701
  * The key's per-key concurrency ceiling, carried from the row so the wire
660
702
  * layer keys the concurrency gate without a second DB read. Absent/`0` =
@@ -875,4 +917,4 @@ declare function getOutboundApiServer(deps?: OutboundApiDeps, onPortChange?: (po
875
917
  /** Reset the singleton (tests / teardown only). */
876
918
  declare function __resetOutboundApiServerForTests(): void;
877
919
 
878
- export { AccountProbeConfig, type ApiServerSettingsStore, type ApplyConfigInput, ConcurrencyQueueConfig, ConcurrencyQueueFullError, ConcurrencyWaitCancelledError, ConcurrencyWaitTimeoutError, DEFAULT_ACCOUNT_PROBE, DEFAULT_CONCURRENCY_QUEUE, DEFAULT_FINGERPRINT, DEFAULT_OUTBOUND_PORT, DEFAULT_USER_MESSAGE_QUEUE, type EndpointModelConfigError, EndpointRoutingConfig, FingerprintConfig, type GateAcquireOptions, type GateAcquisition, type GateSlot, type GateStatusEntry, KeyCostLimits, type KeyVerification, KeyedMutex, KindMappedEndpoint, ModelKind, type ModelPrefixKind, ModelPrefixTargets, OUTBOUND_API_SERVER_CONFIG_KEY, OutboundApiConfigError, OutboundApiDeps, OutboundApiKeyCreated, OutboundApiServer, OutboundApiServerConfig, OutboundApiServerStatus, OutboundConcurrencyGate, OutboundEndpoint, OutboundFormatUrls, OutboundKeyDb, OutboundProxyConfig, OutboundRateLimiter, RequestRole, type SerialAcquireOptions, type SerialQueueStatusEntry, SerialQueueTimeoutError, type SerialSlot, UserMessageQueueConfig, UserMessageSerialQueue, type VerifiedKey, __resetOutboundApiServerForTests, classifyModelPrefix, createNamedKey, defaultServerConfig, detectModelKind, detectRequestRole, endpointToIngressFormat, formatUrls, getOutboundApiServer, handleVoucherRedeem, hashKey, isConcurrencyRejection, isKindMappedEndpoint, isRedeemRequest, isSerialQueueTimeout, isUserMessageRequest, loadServerConfig, mergeServerConfig, modelKindsForEndpoint, normalizeAccountProbe, normalizeAudit, normalizeBilling, normalizeFingerprint, normalizePrefixTargets, normalizeProxyConfig, normalizeProxySegment, normalizeQueueSegments, normalizeServerConfig, normalizeVoucher, normalizeWebhookDestination, normalizeWebhookSegment, randomBase62, resolvePrefixTarget, saveServerConfig, validateEndpointModelConfig, validateServerModelConfig, verifyKey, verifyPresentedKey };
920
+ export { AccountProbeConfig, AllowanceSchedulingConfig, type ApiServerSettingsStore, type ApplyConfigInput, ConcurrencyQueueConfig, ConcurrencyQueueFullError, ConcurrencyWaitCancelledError, ConcurrencyWaitTimeoutError, DEFAULT_ACCOUNT_PROBE, DEFAULT_ALLOWANCE_SCHEDULING, DEFAULT_CONCURRENCY_QUEUE, DEFAULT_FINGERPRINT, DEFAULT_OUTBOUND_PORT, DEFAULT_USER_MESSAGE_QUEUE, EndpointRoutingConfig, FingerprintConfig, type GateAcquireOptions, type GateAcquisition, type GateSlot, type GateStatusEntry, GatewayBinding, type GatewayBindingResolution, KeyCostLimits, type KeyVerification, KeyedMutex, KindMappedEndpoint, ModelKind, type ModelPrefixKind, ModelPrefixTargets, OUTBOUND_API_SERVER_CONFIG_KEY, OutboundApiDeps, OutboundApiKeyCreated, OutboundApiServer, OutboundApiServerConfig, OutboundApiServerStatus, OutboundConcurrencyGate, OutboundEndpoint, OutboundFormatUrls, OutboundKeyDb, OutboundProxyConfig, OutboundRateLimiter, RequestRole, type ResolveGatewayBindingInput, type SerialAcquireOptions, type SerialQueueStatusEntry, SerialQueueTimeoutError, type SerialSlot, UserMessageQueueConfig, UserMessageSerialQueue, type VerifiedKey, __resetOutboundApiServerForTests, candidateBackgroundModelIds, candidateGatewayBindings, classifyModelPrefix, createIntegrationKey, createNamedKey, defaultServerConfig, detectModelKind, detectRequestRole, endpointToIngressFormat, formatUrls, gatewayBindingToEndpointConfig, getOutboundApiServer, handleVoucherRedeem, hashKey, isConcurrencyRejection, isKindMappedEndpoint, isRedeemRequest, isSerialQueueTimeout, isUserMessageRequest, legacyEndpointsToBindings, loadServerConfig, mergeServerConfig, modelKindsForEndpoint, normalizeAccountProbe, normalizeAllowanceScheduling, normalizeAudit, normalizeBilling, normalizeFingerprint, normalizeGatewayBindings, normalizePrefixTargets, normalizeProxyConfig, normalizeProxySegment, normalizeQueueSegments, normalizeServerConfig, normalizeVoucher, normalizeWebhookDestination, normalizeWebhookSegment, randomBase62, resolveGatewayBinding, resolvePrefixTarget, saveServerConfig, validateEndpointModelConfig, verifyKey, verifyPresentedKey };
@@ -3,6 +3,7 @@ import {
3
3
  ConcurrencyWaitCancelledError,
4
4
  ConcurrencyWaitTimeoutError,
5
5
  DEFAULT_ACCOUNT_PROBE,
6
+ DEFAULT_ALLOWANCE_SCHEDULING,
6
7
  DEFAULT_CONCURRENCY_QUEUE,
7
8
  DEFAULT_FINGERPRINT,
8
9
  DEFAULT_OUTBOUND_PORT,
@@ -10,19 +11,22 @@ import {
10
11
  KeySpendTracker,
11
12
  KeyedMutex,
12
13
  OUTBOUND_API_SERVER_CONFIG_KEY,
13
- OutboundApiConfigError,
14
14
  OutboundApiServer,
15
15
  OutboundConcurrencyGate,
16
16
  OutboundRateLimiter,
17
17
  SerialQueueTimeoutError,
18
18
  UserMessageSerialQueue,
19
19
  __resetOutboundApiServerForTests,
20
+ candidateBackgroundModelIds,
21
+ candidateGatewayBindings,
20
22
  checkKeyQuota,
21
23
  computeKeyExpiry,
22
24
  computeVoucherGrant,
25
+ createIntegrationKey,
23
26
  createNamedKey,
24
27
  defaultServerConfig,
25
28
  formatUrls,
29
+ gatewayBindingToEndpointConfig,
26
30
  generateVoucherCode,
27
31
  getOutboundApiServer,
28
32
  handleVoucherRedeem,
@@ -32,13 +36,16 @@ import {
32
36
  isRedeemRequest,
33
37
  isSerialQueueTimeout,
34
38
  isUserMessageRequest,
39
+ legacyEndpointsToBindings,
35
40
  loadServerConfig,
36
41
  mergeServerConfig,
37
42
  newVoucherId,
38
43
  normalizeAccountProbe,
44
+ normalizeAllowanceScheduling,
39
45
  normalizeAudit,
40
46
  normalizeBilling,
41
47
  normalizeFingerprint,
48
+ normalizeGatewayBindings,
42
49
  normalizePrefixTargets,
43
50
  normalizeProxyConfig,
44
51
  normalizeProxySegment,
@@ -48,6 +55,7 @@ import {
48
55
  normalizeWebhookDestination,
49
56
  normalizeWebhookSegment,
50
57
  randomBase62,
58
+ resolveGatewayBinding,
51
59
  saveServerConfig,
52
60
  startOfLocalDay,
53
61
  startOfLocalWeek,
@@ -55,33 +63,38 @@ import {
55
63
  verifyKey,
56
64
  verifyPresentedKey,
57
65
  voucherCodePrefix
58
- } from "./chunk-FH2P4OCD.js";
66
+ } from "./chunk-UDCC7EMR.js";
67
+ import "./chunk-WB6PH56J.js";
59
68
  import "./chunk-VVEHS2LI.js";
60
69
  import "./chunk-46RLHI7D.js";
61
- import "./chunk-G2UTNSGU.js";
70
+ import "./chunk-WNKWAEUR.js";
71
+ import "./chunk-MZNPGW5Q.js";
62
72
  import "./chunk-DK4A7DLE.js";
63
- import "./chunk-OQWKZCXP.js";
64
- import "./chunk-IB3FDI4O.js";
65
- import "./chunk-ZJZAOKI7.js";
66
- import "./chunk-C6OV7GCC.js";
67
- import "./chunk-IWQAX3CS.js";
68
- import "./chunk-BODMAL6G.js";
73
+ import "./chunk-VRFBB5DB.js";
74
+ import "./chunk-LVUCAWMK.js";
75
+ import "./chunk-OEWZUX4G.js";
76
+ import "./chunk-LB6EBS6Y.js";
77
+ import "./chunk-6CL5HTPQ.js";
69
78
  import "./chunk-7VU7V2E4.js";
70
- import "./chunk-ZLX3KGXX.js";
79
+ import "./chunk-UX7VWA46.js";
71
80
  import "./chunk-BPKCU575.js";
72
- import "./chunk-MZNPGW5Q.js";
81
+ import "./chunk-DRWHTIIZ.js";
73
82
  import "./chunk-XTEI64OU.js";
74
83
  import "./chunk-XX6NQJMA.js";
75
- import "./chunk-IAXWICZU.js";
84
+ import "./chunk-5ERIZW3D.js";
85
+ import "./chunk-YJVHCHQX.js";
86
+ import "./chunk-23S5OPIO.js";
87
+ import "./chunk-AVYJ4YBN.js";
76
88
  import "./chunk-OE6TDIWW.js";
77
- import "./chunk-DRWHTIIZ.js";
78
- import "./chunk-IK3KE3AU.js";
89
+ import "./chunk-OPRS4IQZ.js";
90
+ import {
91
+ BoundAccountSelectionError,
92
+ boundAccountSelectionMessage,
93
+ isBoundAccountSelectionError
94
+ } from "./chunk-2JYRIADS.js";
95
+ import "./chunk-DE2SRBFZ.js";
79
96
  import "./chunk-ZY6KU6P3.js";
80
97
  import "./chunk-JWC6APFQ.js";
81
- import "./chunk-5ERIZW3D.js";
82
- import "./chunk-5ENKBSWO.js";
83
- import "./chunk-HRRYG2AX.js";
84
- import "./chunk-AVYJ4YBN.js";
85
98
  import {
86
99
  beginBillingCapture
87
100
  } from "./chunk-WLYIIEAF.js";
@@ -101,9 +114,8 @@ import {
101
114
  pickModelRefFromList,
102
115
  resolvePrefixTarget,
103
116
  resolveRoute,
104
- validateEndpointModelConfig,
105
- validateServerModelConfig
106
- } from "./chunk-UHGVBFU3.js";
117
+ validateEndpointModelConfig
118
+ } from "./chunk-EBLFCNPY.js";
107
119
  import "./chunk-AQ5TNQB7.js";
108
120
  import {
109
121
  ENDPOINT_MODEL_KINDS
@@ -118,21 +130,24 @@ import {
118
130
  } from "./chunk-K5NM7VAH.js";
119
131
  import "./chunk-WNY4WMRF.js";
120
132
  import "./chunk-OZFM4X3S.js";
121
- import "./chunk-5ZQBEOMD.js";
122
- import "./chunk-MFZ5437A.js";
123
- import "./chunk-6QZGDLL4.js";
124
- import "./chunk-D3TDKWRP.js";
133
+ import "./chunk-AT7B7SOZ.js";
134
+ import "./chunk-N5T4M4GU.js";
135
+ import "./chunk-TOVPMMHM.js";
136
+ import "./chunk-SIZQQD6T.js";
125
137
  import "./chunk-SYQF7OIR.js";
138
+ import "./chunk-MKF46GNZ.js";
126
139
  import "./chunk-CDHS2QDC.js";
127
140
  import "./chunk-Y7FO65VT.js";
128
141
  import "./chunk-FMOBD2OQ.js";
129
142
  import "./chunk-HUZZZ3JL.js";
130
143
  export {
131
144
  AUDIT_REDACTED,
145
+ BoundAccountSelectionError,
132
146
  ConcurrencyQueueFullError,
133
147
  ConcurrencyWaitCancelledError,
134
148
  ConcurrencyWaitTimeoutError,
135
149
  DEFAULT_ACCOUNT_PROBE,
150
+ DEFAULT_ALLOWANCE_SCHEDULING,
136
151
  DEFAULT_CONCURRENCY_QUEUE,
137
152
  DEFAULT_FINGERPRINT,
138
153
  DEFAULT_OUTBOUND_PORT,
@@ -141,7 +156,6 @@ export {
141
156
  KeySpendTracker,
142
157
  KeyedMutex,
143
158
  OUTBOUND_API_SERVER_CONFIG_KEY,
144
- OutboundApiConfigError,
145
159
  OutboundApiServer,
146
160
  OutboundConcurrencyGate,
147
161
  OutboundRateLimiter,
@@ -151,10 +165,14 @@ export {
151
165
  __resetOutboundApiServerForTests,
152
166
  beginAuditCapture,
153
167
  beginBillingCapture,
168
+ boundAccountSelectionMessage,
169
+ candidateBackgroundModelIds,
170
+ candidateGatewayBindings,
154
171
  checkKeyQuota,
155
172
  classifyModelPrefix,
156
173
  computeKeyExpiry,
157
174
  computeVoucherGrant,
175
+ createIntegrationKey,
158
176
  createNamedKey,
159
177
  defaultServerConfig,
160
178
  detectModelKind,
@@ -162,25 +180,30 @@ export {
162
180
  endpointSupportsSubscription,
163
181
  endpointToIngressFormat,
164
182
  formatUrls,
183
+ gatewayBindingToEndpointConfig,
165
184
  generateVoucherCode,
166
185
  getOutboundApiServer,
167
186
  handleVoucherRedeem,
168
187
  hashKey,
169
188
  hashVoucherCode,
189
+ isBoundAccountSelectionError,
170
190
  isConcurrencyRejection,
171
191
  isKindMappedEndpoint,
172
192
  isRedeemRequest,
173
193
  isSerialQueueTimeout,
174
194
  isSubscriptionProviderId,
175
195
  isUserMessageRequest,
196
+ legacyEndpointsToBindings,
176
197
  loadServerConfig,
177
198
  mergeServerConfig,
178
199
  modelKindsForEndpoint,
179
200
  newVoucherId,
180
201
  normalizeAccountProbe,
202
+ normalizeAllowanceScheduling,
181
203
  normalizeAudit,
182
204
  normalizeBilling,
183
205
  normalizeFingerprint,
206
+ normalizeGatewayBindings,
184
207
  normalizePrefixTargets,
185
208
  normalizeProxyConfig,
186
209
  normalizeProxySegment,
@@ -193,6 +216,7 @@ export {
193
216
  pickModelRefFromList,
194
217
  randomBase62,
195
218
  redactAuditText,
219
+ resolveGatewayBinding,
196
220
  resolvePrefixTarget,
197
221
  resolveRoute,
198
222
  saveServerConfig,
@@ -200,7 +224,6 @@ export {
200
224
  startOfLocalWeek,
201
225
  toVoucherInfo,
202
226
  validateEndpointModelConfig,
203
- validateServerModelConfig,
204
227
  verifyKey,
205
228
  verifyPresentedKey,
206
229
  voucherCodePrefix
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunk6QQG7YG3cjs = require('../chunk-6QQG7YG3.cjs');
8
+ require('../chunk-HVBBDBS3.cjs');
9
+
10
+
11
+
12
+
13
+
14
+
15
+ exports.AccountAllowanceExhaustedError = _chunk6QQG7YG3cjs.AccountAllowanceExhaustedError; exports.AccountAllowanceScheduling = _chunk6QQG7YG3cjs.AccountAllowanceScheduling; exports.__resetSharedAccountAllowanceSchedulingForTests = _chunk6QQG7YG3cjs.__resetSharedAccountAllowanceSchedulingForTests; exports.getSharedAccountAllowanceScheduling = _chunk6QQG7YG3cjs.getSharedAccountAllowanceScheduling; exports.isAccountAllowanceExhaustedError = _chunk6QQG7YG3cjs.isAccountAllowanceExhaustedError;
@@ -0,0 +1,90 @@
1
+ import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
2
+ import { a as AllowanceSchedulingConfig } from '../types-H3wGZSOo.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-types';
20
+ import '../completion/ApiKeyPoolService.cjs';
21
+ import './AuthSource.cjs';
22
+ import './BoundAccountSelectionError.cjs';
23
+ import './SubscriptionAuthSource.cjs';
24
+ import './SubscriptionAuthStrategy.cjs';
25
+ import '../ports/web-search-backend.cjs';
26
+ import '@omnicross/contracts/websearch-types';
27
+ import '../keyPolicy-zdWTu3CQ.cjs';
28
+ import '@omnicross/contracts/account-allowance-types';
29
+
30
+ /**
31
+ * Default-off allowance-aware scheduling policy.
32
+ *
33
+ * This layer consumes only normalized, secret-free snapshots. Missing, stale,
34
+ * unsupported, or reset-expired data is deliberately ignored so telemetry can
35
+ * never strand an account by accident.
36
+ */
37
+
38
+ type AllowanceSchedulingAction = 'normal' | 'demote' | 'pause' | 'ignore';
39
+ interface AllowanceSchedulingDecision {
40
+ providerId: SubscriptionProviderId;
41
+ accountId: string;
42
+ action: AllowanceSchedulingAction;
43
+ reason: 'policy-disabled' | 'provider-unsupported' | 'snapshot-missing' | 'snapshot-not-fresh' | 'below-threshold' | 'demote-threshold' | 'pause-threshold';
44
+ basePriority: number;
45
+ effectivePriority: number;
46
+ schedulable: boolean;
47
+ usedPercent?: number;
48
+ observedAt?: string;
49
+ resumeAt?: string;
50
+ decidedAt: string;
51
+ }
52
+ /**
53
+ * Safe, structured signal emitted only when an enabled allowance policy paused
54
+ * every otherwise eligible account. Request ingress maps it to HTTP 429 instead
55
+ * of disguising a local scheduling decision as an upstream 5xx.
56
+ */
57
+ declare class AccountAllowanceExhaustedError extends Error {
58
+ readonly providerId: SubscriptionProviderId;
59
+ readonly resumeAt?: string | undefined;
60
+ readonly code = "account_allowance_exhausted";
61
+ readonly status = 429;
62
+ constructor(providerId: SubscriptionProviderId, resumeAt?: string | undefined);
63
+ }
64
+ /** Structural guard survives package/bundle boundaries and never inspects secrets. */
65
+ declare function isAccountAllowanceExhaustedError(error: unknown): error is AccountAllowanceExhaustedError;
66
+ declare class AccountAllowanceScheduling {
67
+ private readonly store;
68
+ private readonly now;
69
+ private config;
70
+ private readonly history;
71
+ private readonly lastRecorded;
72
+ constructor(store?: AccountAllowanceStore, now?: () => number);
73
+ configure(config: AllowanceSchedulingConfig | undefined): void;
74
+ getConfig(): AllowanceSchedulingConfig;
75
+ evaluate(providerId: SubscriptionProviderId, accountId: string, basePriority: number, now?: number): AllowanceSchedulingDecision;
76
+ /**
77
+ * Project the current policy result without recording an applied decision.
78
+ * Admin/read-model callers use this so polling an account list never creates
79
+ * synthetic demotion/pause history entries.
80
+ */
81
+ preview(providerId: SubscriptionProviderId, accountId: string, basePriority: number, now?: number): AllowanceSchedulingDecision;
82
+ private decide;
83
+ getHistory(): AllowanceSchedulingDecision[];
84
+ clearHistory(): void;
85
+ private recordApplied;
86
+ }
87
+ declare function getSharedAccountAllowanceScheduling(): AccountAllowanceScheduling;
88
+ declare function __resetSharedAccountAllowanceSchedulingForTests(): void;
89
+
90
+ export { AccountAllowanceExhaustedError, AccountAllowanceScheduling, type AllowanceSchedulingAction, type AllowanceSchedulingDecision, __resetSharedAccountAllowanceSchedulingForTests, getSharedAccountAllowanceScheduling, isAccountAllowanceExhaustedError };