@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
@@ -1,21 +1,21 @@
1
1
  import "./chunk-46RLHI7D.js";
2
+ import {
3
+ registerBuiltinTransformers
4
+ } from "./chunk-MYYR3HZL.js";
5
+ import "./chunk-PEGTIPB3.js";
6
+ import "./chunk-LVUCAWMK.js";
7
+ import "./chunk-32O35CIF.js";
8
+ import "./chunk-FU7EAR73.js";
9
+ import "./chunk-LB6EBS6Y.js";
2
10
  import {
3
11
  TransformerChainExecutor
4
- } from "./chunk-G2UTNSGU.js";
12
+ } from "./chunk-WNKWAEUR.js";
13
+ import "./chunk-MZNPGW5Q.js";
5
14
  import {
6
15
  TransformerService
7
16
  } from "./chunk-DK4A7DLE.js";
8
- import {
9
- registerBuiltinTransformers
10
- } from "./chunk-OQWKZCXP.js";
11
- import "./chunk-IB3FDI4O.js";
12
- import "./chunk-ZJZAOKI7.js";
13
- import "./chunk-C6OV7GCC.js";
14
- import "./chunk-IWQAX3CS.js";
15
- import "./chunk-BODMAL6G.js";
16
- import "./chunk-MZNPGW5Q.js";
17
- import "./chunk-MFZ5437A.js";
18
- import "./chunk-6QZGDLL4.js";
17
+ import "./chunk-N5T4M4GU.js";
18
+ import "./chunk-TOVPMMHM.js";
19
19
  export {
20
20
  TransformerChainExecutor,
21
21
  TransformerService,
@@ -8,7 +8,8 @@ import { L as Logger } from './logger-4GvQNzhE.js';
8
8
  import { ProviderConfigSource } from './ports/provider-config-source.js';
9
9
  import { P as ProviderProxy } from './ProviderProxy-C-xqrkKi.js';
10
10
  import { ProviderProxyDeps } from './provider-proxy/types.js';
11
- import { c as KeySpend } from './keyPolicy-Cp0FntZl.js';
11
+ import { BoundAccountFallbackPolicy } from './pipeline/BoundAccountSelectionError.js';
12
+ import { c as KeySpend } from './keyPolicy-zdWTu3CQ.js';
12
13
 
13
14
  /**
14
15
  * keySpendTracker — a cheap in-memory per-key accumulated-spend cache
@@ -313,15 +314,30 @@ interface EndpointRoutingConfig {
313
314
  /**
314
315
  * OPTIONAL subscription-mode binding to ONE specific subscription account id
315
316
  * (provider/subscription duality). Absent/blank ⇒ the provider's account pool
316
- * auto-schedules (priority/LRU/health). When set and the account is
317
- * schedulable it is used directly; otherwise the pool is the fallback.
317
+ * auto-schedules (priority/LRU/health). When set, strict mode requires this
318
+ * account to serve; the pool is a fallback only with the explicit policy below.
318
319
  */
319
320
  boundAccountId?: string;
321
+ /**
322
+ * What a bound account does when it cannot serve this request. Meaningful
323
+ * only with `boundAccountId`; normalization drops it otherwise. A legacy
324
+ * bound endpoint with no field migrates to `'strict'`. The pool is used only
325
+ * when this is explicitly set to `'pool'`.
326
+ */
327
+ boundAccountFallbackPolicy?: BoundAccountFallbackPolicy;
328
+ /**
329
+ * Runtime-only account-group selector used by a {@link GatewayBinding}.
330
+ * Legacy endpoint persistence does not synthesize this field; it is projected
331
+ * from an independent binding immediately before route resolution.
332
+ */
333
+ boundAccountGroup?: string;
320
334
  /**
321
335
  * OPTIONAL provider-mode binding to ONE specific BYO key id (from the
322
336
  * provider's key pool). Absent/blank ⇒ the provider's default key / key pool.
323
337
  */
324
338
  boundKeyId?: string;
339
+ /** Strict by default; `'pool'` permits the provider's normal key pool. */
340
+ boundKeyFallbackPolicy?: BoundAccountFallbackPolicy;
325
341
  /**
326
342
  * OPTIONAL "background model id" override list (role-based `gemini` only).
327
343
  * When set, an incoming requested model id appearing in this list is
@@ -364,7 +380,7 @@ interface ConcurrencyQueueConfig {
364
380
  * Persisted + strictly validated like the queue segments; applied to the shared
365
381
  * `SubscriptionAccountHealth` tracker at daemon boot.
366
382
  * - `overloadCooldownEnabled` default **true** — a 529 places the account in
367
- * overload cooldown (ON by default; CRS ships it off).
383
+ * overload cooldown (enabled by default).
368
384
  * - `overloadCooldownMs` default **600000** (10 min), valid `60000..3600000`.
369
385
  */
370
386
  interface AccountHealthConfig {
@@ -397,6 +413,89 @@ interface AccountProbeConfig {
397
413
  historySize: number;
398
414
  staggerMs: number;
399
415
  }
416
+ /** A resource selected by a client-to-upstream gateway binding. */
417
+ type GatewayBindingTarget = {
418
+ kind: 'account';
419
+ providerId: string;
420
+ accountId: string;
421
+ } | {
422
+ kind: 'account-group';
423
+ providerId: string;
424
+ group: string;
425
+ } | {
426
+ /**
427
+ * The provider's WHOLE subscription pool, with no account preference —
428
+ * plain priority/LRU/health scheduling. Distinct from `account-group`,
429
+ * which pins a preferred group, and from `provider`, which is BYO-key.
430
+ */
431
+ kind: 'account-pool';
432
+ providerId: string;
433
+ } | {
434
+ kind: 'provider';
435
+ providerId: string;
436
+ keyId?: string;
437
+ };
438
+ /**
439
+ * Behavior when a binding cannot serve the requested model or credential.
440
+ * `next` yields to the next matching route (and lets a bound account fall back
441
+ * to its provider pool); `fail` keeps the route strict and errors instead.
442
+ */
443
+ type GatewayBindingFallback = 'next' | 'fail';
444
+ /** Which named API keys may enter a downstream route. */
445
+ type GatewayBindingKeyScope = 'all' | 'selected';
446
+ /** Whether the downstream model id is forwarded or explicitly remapped. */
447
+ type GatewayBindingModelMode = 'passthrough' | 'mapped';
448
+ /** One exact or `*` wildcard model-name rewrite owned by a downstream route. */
449
+ interface GatewayModelMapping {
450
+ source: string;
451
+ target: ModelRef;
452
+ }
453
+ /**
454
+ * Independent client-to-upstream route aggregate.
455
+ *
456
+ * A binding belongs to exactly one endpoint and one upstream resource. Keeping
457
+ * it separate from account/provider DTOs lets the same resource participate in
458
+ * multiple client-key routes without changing its identity or secret shape.
459
+ */
460
+ interface GatewayBinding {
461
+ id: string;
462
+ name: string;
463
+ enabled: boolean;
464
+ /** Legacy entries without this field keep the former all-vs-list behavior. */
465
+ keyScope?: GatewayBindingKeyScope;
466
+ /** Used only when `keyScope` resolves to `selected`. */
467
+ apiKeyIds?: string[];
468
+ endpoint: OutboundEndpoint;
469
+ target: GatewayBindingTarget;
470
+ /** Lower values win. Key-scoped bindings win before this comparison. */
471
+ priority?: number;
472
+ /** Next yields to the following matching route; fail keeps the binding strict. */
473
+ fallback: GatewayBindingFallback;
474
+ /** Empty passthrough routes preserve the client's requested model id. */
475
+ modelMode?: GatewayBindingModelMode;
476
+ /** Preferred generic mapping shape; legacy endpoint-specific fields remain readable. */
477
+ modelMappings?: GatewayModelMapping[];
478
+ modelMap?: Record<string, ModelRef>;
479
+ models?: ModelRef[];
480
+ dispatchMode?: ChatDispatchMode;
481
+ prefixTargets?: ModelPrefixTargets;
482
+ defaultModel?: ModelRef;
483
+ backgroundModel?: ModelRef;
484
+ backgroundModelIds?: string[];
485
+ }
486
+ /**
487
+ * Optional allowance-aware account scheduling. Default-off keeps allowance
488
+ * telemetry display-only. When enabled, only fresh Claude/Codex snapshots are
489
+ * considered: accounts above `demoteAtPercent` receive a temporary priority
490
+ * penalty; accounts above `pauseAtPercent` are excluded until the provider's
491
+ * reset/freshness deadline. Missing or stale data never excludes an account.
492
+ */
493
+ interface AllowanceSchedulingConfig {
494
+ enabled: boolean;
495
+ demoteAtPercent: number;
496
+ pauseAtPercent: number;
497
+ priorityPenalty: number;
498
+ }
400
499
  /**
401
500
  * Client-fingerprint segment (subscription-client-fingerprint #7). Opt-in,
402
501
  * default OFF: when disabled the claude-subscription outbound headers are
@@ -435,8 +534,19 @@ interface OutboundApiServerConfig {
435
534
  enabled: boolean;
436
535
  /** When true the listener binds `0.0.0.0` (LAN) instead of `127.0.0.1`. */
437
536
  networkBinding: boolean;
438
- /** Per-endpoint routing config, one per endpoint (4 entries). */
537
+ /**
538
+ * LEGACY per-endpoint routing config, one per endpoint (4 entries). No longer
539
+ * a routing source: {@link normalizeServerConfig} projects any configured
540
+ * entry into {@link bindings} once and leaves these blank. Retained as the
541
+ * projection shape {@link EndpointRoutingConfig} and for embedders that build
542
+ * a config by hand.
543
+ */
439
544
  endpoints: EndpointRoutingConfig[];
545
+ /**
546
+ * Resource-centric routes — the SSOT for routing. Optional in the raw
547
+ * persisted shape; normalized Omnicross configs always carry an array.
548
+ */
549
+ bindings?: GatewayBinding[];
440
550
  /** Persisted port (fixed default; falls back to ephemeral on EADDRINUSE). */
441
551
  port?: number;
442
552
  /**
@@ -463,6 +573,8 @@ interface OutboundApiServerConfig {
463
573
  * boot; a change takes effect on restart. Default-off ⇒ no scheduler runs.
464
574
  */
465
575
  accountProbe?: AccountProbeConfig;
576
+ /** Default-off allowance-aware scheduling; hot-reloaded by the daemon. */
577
+ allowanceScheduling?: AllowanceSchedulingConfig;
466
578
  /**
467
579
  * Layered upstream-proxy segment (upstream-proxy). Optional; when absent no
468
580
  * global/provider proxy applies (direct egress). `normalizeServerConfig` drops
@@ -542,10 +654,23 @@ interface OutboundApiKeyInfo {
542
654
  id: string;
543
655
  name: string;
544
656
  keyPrefix: string;
657
+ /**
658
+ * Whether the operator "view key" affordance is available for this key — true
659
+ * only when a reversibly-encrypted `keySecret` was persisted at creation.
660
+ * Legacy hash-only rows (and any DB without a `SecretBox`) read as absent ⇒
661
+ * not revealable. Optional so a pre-upgrade daemon response type-checks.
662
+ */
663
+ revealable?: boolean;
545
664
  enabled: boolean;
546
665
  createdAt: number;
547
666
  lastUsedAt: number | null;
548
667
  revoked: boolean;
668
+ /** Intended consumer. Existing rows default to a general client key. */
669
+ kind?: 'client' | 'integration';
670
+ /** Optional endpoint allow-list. Absent means every outbound endpoint. */
671
+ allowedEndpoints?: OutboundEndpoint[];
672
+ /** When true the key is rejected unless the TCP peer is loopback. */
673
+ loopbackOnly?: boolean;
549
674
  /**
550
675
  * Per-key concurrency ceiling for the outbound concurrency gate. Absent or
551
676
  * `0` = unlimited (the gate is bypassed entirely for this key).
@@ -571,7 +696,7 @@ interface OutboundApiKeyInfo {
571
696
  rateLimitWindowMs?: number | null;
572
697
  /** Master switch: when false/unset the model list is inert (no restriction). */
573
698
  enableModelRestriction?: boolean;
574
- /** Restriction mode; absent ⇒ `'blacklist'` (CRS-parity). */
699
+ /** Restriction mode; absent ⇒ `'blacklist'`. */
575
700
  restrictionMode?: OutboundKeyModelRestrictionMode;
576
701
  /** The model-id list the mode acts on (bare modelIds; empty allowlist denies all). */
577
702
  restrictedModels?: string[];
@@ -633,10 +758,25 @@ interface OutboundKeyDbRow {
633
758
  name: string;
634
759
  keyHash: string;
635
760
  keyPrefix: string;
761
+ /**
762
+ * OPTIONAL reversibly-encrypted plaintext of the secret (an `enc:v1:…`
763
+ * envelope produced by the daemon's `SecretBox`). Absent on legacy rows
764
+ * (created before revealable storage) AND on any DB constructed without a
765
+ * `SecretBox` — in both cases the key is NOT revealable. The hash above
766
+ * remains the auth lookup index; this field only powers the operator
767
+ * "view key" affordance.
768
+ */
769
+ keySecret?: string;
636
770
  enabled: boolean;
637
771
  createdAt: number;
638
772
  lastUsedAt: number | null;
639
773
  revokedAt: number | null;
774
+ /** Intended consumer. Existing rows without this field remain client keys. */
775
+ kind?: 'client' | 'integration';
776
+ /** Optional endpoint allow-list for least-privilege integration keys. */
777
+ allowedEndpoints?: OutboundEndpoint[];
778
+ /** Restrict use to requests whose direct socket peer is loopback. */
779
+ loopbackOnly?: boolean;
640
780
  /**
641
781
  * Per-key concurrency ceiling. Absent/`0` = unlimited = the concurrency gate
642
782
  * is bypassed for this key. Persisted by the daemon (`omnicross-uqc-daemon`).
@@ -676,6 +816,17 @@ interface OutboundKeyDb {
676
816
  keyHash: string;
677
817
  keyPrefix: string;
678
818
  createdAt?: number;
819
+ kind?: 'client' | 'integration';
820
+ allowedEndpoints?: OutboundEndpoint[];
821
+ loopbackOnly?: boolean;
822
+ /**
823
+ * The generated plaintext secret. When the DB holds a `SecretBox` it
824
+ * persists a reversibly-encrypted copy as `keySecret` (enabling the
825
+ * "view key" affordance); when no box is wired the plaintext is dropped
826
+ * (byte-identical to the legacy hash-only storage). The hash above — NOT
827
+ * this field — remains the auth lookup index.
828
+ */
829
+ plaintext?: string;
679
830
  }): Promise<OutboundKeyDbRow>;
680
831
  outboundApiKeysRevoke(id: string): Promise<boolean>;
681
832
  outboundApiKeysTouchLastUsed(id: string): Promise<boolean>;
@@ -703,6 +854,21 @@ interface OutboundKeyDb {
703
854
  * idempotent).
704
855
  */
705
856
  outboundApiKeysMarkActivated(id: string, activatedAt: number): Promise<boolean>;
857
+ /**
858
+ * Reveal the stored plaintext for a key (the operator "view key" affordance),
859
+ * or `null` when the key is missing OR was persisted without a `keySecret`
860
+ * (legacy hash-only rows / a DB constructed without a `SecretBox`). The
861
+ * daemon-owned DB decrypts its stored envelope; core never handles the
862
+ * master key.
863
+ */
864
+ outboundApiKeysReveal(id: string): Promise<string | null>;
865
+ /**
866
+ * Permanently remove a key row (hard delete), returning whether a row was
867
+ * removed. Unlike {@link outboundApiKeysRevoke} (a soft revoke that keeps the
868
+ * row for history), this purges the row entirely — intended for cleaning up
869
+ * already-revoked keys. Irreversible; the caller confirms.
870
+ */
871
+ outboundApiKeysDelete(id: string): Promise<boolean>;
706
872
  }
707
873
  /**
708
874
  * App-session-scoped dependencies the outbound server needs. The resident
@@ -751,4 +917,4 @@ interface OutboundApiDeps {
751
917
  readonly logger?: Logger;
752
918
  }
753
919
 
754
- export { type AccountProbeConfig as A, toVoucherInfo as B, type ChatDispatchMode as C, voucherCodePrefix as D, ENDPOINT_MODEL_KINDS as E, type FingerprintConfig as F, type ModelRef as G, type AccountHealthConfig as H, type OutboundKeyModelRestrictionMode as I, type KeySpendReader as K, type MessagesModelKind as M, type OutboundKeyDb as O, type RequestRole as R, type UserMessageQueueConfig as U, type VoucherCreateInput as V, type ConcurrencyQueueConfig as a, type EndpointRoutingConfig as b, type KeySpendSeeder as c, KeySpendTracker as d, type KindMappedEndpoint as e, type ModelKind as f, type ModelPrefixTargets as g, type OutboundApiDeps as h, type OutboundApiKeyCreated as i, type OutboundApiKeyInfo as j, type OutboundApiServerConfig as k, type OutboundApiServerStatus as l, type OutboundEndpoint as m, type OutboundFormatUrls as n, type OutboundKeyActivationMode as o, type OutboundKeyDbRow as p, type OutboundKeyPolicy as q, type OutboundProxyConfig as r, type ResponsesModelKind as s, type VoucherDb as t, computeVoucherGrant as u, generateVoucherCode as v, hashVoucherCode as w, newVoucherId as x, startOfLocalDay as y, startOfLocalWeek as z };
920
+ export { type AccountProbeConfig as A, computeVoucherGrant as B, type ChatDispatchMode as C, generateVoucherCode as D, ENDPOINT_MODEL_KINDS as E, type FingerprintConfig as F, type GatewayBinding as G, hashVoucherCode as H, newVoucherId as I, startOfLocalDay as J, type KeySpendReader as K, startOfLocalWeek as L, type MessagesModelKind as M, toVoucherInfo as N, type OutboundKeyDb as O, voucherCodePrefix as P, type ModelRef as Q, type RequestRole as R, type AccountHealthConfig as S, type OutboundKeyModelRestrictionMode as T, type UserMessageQueueConfig as U, type VoucherCreateInput as V, type AllowanceSchedulingConfig as a, type ConcurrencyQueueConfig as b, type EndpointRoutingConfig as c, type GatewayBindingFallback as d, type GatewayBindingKeyScope as e, type GatewayBindingModelMode as f, type GatewayBindingTarget as g, type GatewayModelMapping as h, type KeySpendSeeder as i, KeySpendTracker as j, type KindMappedEndpoint as k, type ModelKind as l, type ModelPrefixTargets as m, type OutboundApiDeps as n, type OutboundApiKeyCreated as o, type OutboundApiKeyInfo as p, type OutboundApiServerConfig as q, type OutboundApiServerStatus as r, type OutboundEndpoint as s, type OutboundFormatUrls as t, type OutboundKeyActivationMode as u, type OutboundKeyDbRow as v, type OutboundKeyPolicy as w, type OutboundProxyConfig as x, type ResponsesModelKind as y, type VoucherDb as z };
@@ -8,7 +8,8 @@ import { L as Logger } from './logger-4GvQNzhE.cjs';
8
8
  import { ProviderConfigSource } from './ports/provider-config-source.cjs';
9
9
  import { P as ProviderProxy } from './ProviderProxy-CnMQYN59.cjs';
10
10
  import { ProviderProxyDeps } from './provider-proxy/types.cjs';
11
- import { c as KeySpend } from './keyPolicy-Cp0FntZl.cjs';
11
+ import { BoundAccountFallbackPolicy } from './pipeline/BoundAccountSelectionError.cjs';
12
+ import { c as KeySpend } from './keyPolicy-zdWTu3CQ.cjs';
12
13
 
13
14
  /**
14
15
  * keySpendTracker — a cheap in-memory per-key accumulated-spend cache
@@ -313,15 +314,30 @@ interface EndpointRoutingConfig {
313
314
  /**
314
315
  * OPTIONAL subscription-mode binding to ONE specific subscription account id
315
316
  * (provider/subscription duality). Absent/blank ⇒ the provider's account pool
316
- * auto-schedules (priority/LRU/health). When set and the account is
317
- * schedulable it is used directly; otherwise the pool is the fallback.
317
+ * auto-schedules (priority/LRU/health). When set, strict mode requires this
318
+ * account to serve; the pool is a fallback only with the explicit policy below.
318
319
  */
319
320
  boundAccountId?: string;
321
+ /**
322
+ * What a bound account does when it cannot serve this request. Meaningful
323
+ * only with `boundAccountId`; normalization drops it otherwise. A legacy
324
+ * bound endpoint with no field migrates to `'strict'`. The pool is used only
325
+ * when this is explicitly set to `'pool'`.
326
+ */
327
+ boundAccountFallbackPolicy?: BoundAccountFallbackPolicy;
328
+ /**
329
+ * Runtime-only account-group selector used by a {@link GatewayBinding}.
330
+ * Legacy endpoint persistence does not synthesize this field; it is projected
331
+ * from an independent binding immediately before route resolution.
332
+ */
333
+ boundAccountGroup?: string;
320
334
  /**
321
335
  * OPTIONAL provider-mode binding to ONE specific BYO key id (from the
322
336
  * provider's key pool). Absent/blank ⇒ the provider's default key / key pool.
323
337
  */
324
338
  boundKeyId?: string;
339
+ /** Strict by default; `'pool'` permits the provider's normal key pool. */
340
+ boundKeyFallbackPolicy?: BoundAccountFallbackPolicy;
325
341
  /**
326
342
  * OPTIONAL "background model id" override list (role-based `gemini` only).
327
343
  * When set, an incoming requested model id appearing in this list is
@@ -364,7 +380,7 @@ interface ConcurrencyQueueConfig {
364
380
  * Persisted + strictly validated like the queue segments; applied to the shared
365
381
  * `SubscriptionAccountHealth` tracker at daemon boot.
366
382
  * - `overloadCooldownEnabled` default **true** — a 529 places the account in
367
- * overload cooldown (ON by default; CRS ships it off).
383
+ * overload cooldown (enabled by default).
368
384
  * - `overloadCooldownMs` default **600000** (10 min), valid `60000..3600000`.
369
385
  */
370
386
  interface AccountHealthConfig {
@@ -397,6 +413,89 @@ interface AccountProbeConfig {
397
413
  historySize: number;
398
414
  staggerMs: number;
399
415
  }
416
+ /** A resource selected by a client-to-upstream gateway binding. */
417
+ type GatewayBindingTarget = {
418
+ kind: 'account';
419
+ providerId: string;
420
+ accountId: string;
421
+ } | {
422
+ kind: 'account-group';
423
+ providerId: string;
424
+ group: string;
425
+ } | {
426
+ /**
427
+ * The provider's WHOLE subscription pool, with no account preference —
428
+ * plain priority/LRU/health scheduling. Distinct from `account-group`,
429
+ * which pins a preferred group, and from `provider`, which is BYO-key.
430
+ */
431
+ kind: 'account-pool';
432
+ providerId: string;
433
+ } | {
434
+ kind: 'provider';
435
+ providerId: string;
436
+ keyId?: string;
437
+ };
438
+ /**
439
+ * Behavior when a binding cannot serve the requested model or credential.
440
+ * `next` yields to the next matching route (and lets a bound account fall back
441
+ * to its provider pool); `fail` keeps the route strict and errors instead.
442
+ */
443
+ type GatewayBindingFallback = 'next' | 'fail';
444
+ /** Which named API keys may enter a downstream route. */
445
+ type GatewayBindingKeyScope = 'all' | 'selected';
446
+ /** Whether the downstream model id is forwarded or explicitly remapped. */
447
+ type GatewayBindingModelMode = 'passthrough' | 'mapped';
448
+ /** One exact or `*` wildcard model-name rewrite owned by a downstream route. */
449
+ interface GatewayModelMapping {
450
+ source: string;
451
+ target: ModelRef;
452
+ }
453
+ /**
454
+ * Independent client-to-upstream route aggregate.
455
+ *
456
+ * A binding belongs to exactly one endpoint and one upstream resource. Keeping
457
+ * it separate from account/provider DTOs lets the same resource participate in
458
+ * multiple client-key routes without changing its identity or secret shape.
459
+ */
460
+ interface GatewayBinding {
461
+ id: string;
462
+ name: string;
463
+ enabled: boolean;
464
+ /** Legacy entries without this field keep the former all-vs-list behavior. */
465
+ keyScope?: GatewayBindingKeyScope;
466
+ /** Used only when `keyScope` resolves to `selected`. */
467
+ apiKeyIds?: string[];
468
+ endpoint: OutboundEndpoint;
469
+ target: GatewayBindingTarget;
470
+ /** Lower values win. Key-scoped bindings win before this comparison. */
471
+ priority?: number;
472
+ /** Next yields to the following matching route; fail keeps the binding strict. */
473
+ fallback: GatewayBindingFallback;
474
+ /** Empty passthrough routes preserve the client's requested model id. */
475
+ modelMode?: GatewayBindingModelMode;
476
+ /** Preferred generic mapping shape; legacy endpoint-specific fields remain readable. */
477
+ modelMappings?: GatewayModelMapping[];
478
+ modelMap?: Record<string, ModelRef>;
479
+ models?: ModelRef[];
480
+ dispatchMode?: ChatDispatchMode;
481
+ prefixTargets?: ModelPrefixTargets;
482
+ defaultModel?: ModelRef;
483
+ backgroundModel?: ModelRef;
484
+ backgroundModelIds?: string[];
485
+ }
486
+ /**
487
+ * Optional allowance-aware account scheduling. Default-off keeps allowance
488
+ * telemetry display-only. When enabled, only fresh Claude/Codex snapshots are
489
+ * considered: accounts above `demoteAtPercent` receive a temporary priority
490
+ * penalty; accounts above `pauseAtPercent` are excluded until the provider's
491
+ * reset/freshness deadline. Missing or stale data never excludes an account.
492
+ */
493
+ interface AllowanceSchedulingConfig {
494
+ enabled: boolean;
495
+ demoteAtPercent: number;
496
+ pauseAtPercent: number;
497
+ priorityPenalty: number;
498
+ }
400
499
  /**
401
500
  * Client-fingerprint segment (subscription-client-fingerprint #7). Opt-in,
402
501
  * default OFF: when disabled the claude-subscription outbound headers are
@@ -435,8 +534,19 @@ interface OutboundApiServerConfig {
435
534
  enabled: boolean;
436
535
  /** When true the listener binds `0.0.0.0` (LAN) instead of `127.0.0.1`. */
437
536
  networkBinding: boolean;
438
- /** Per-endpoint routing config, one per endpoint (4 entries). */
537
+ /**
538
+ * LEGACY per-endpoint routing config, one per endpoint (4 entries). No longer
539
+ * a routing source: {@link normalizeServerConfig} projects any configured
540
+ * entry into {@link bindings} once and leaves these blank. Retained as the
541
+ * projection shape {@link EndpointRoutingConfig} and for embedders that build
542
+ * a config by hand.
543
+ */
439
544
  endpoints: EndpointRoutingConfig[];
545
+ /**
546
+ * Resource-centric routes — the SSOT for routing. Optional in the raw
547
+ * persisted shape; normalized Omnicross configs always carry an array.
548
+ */
549
+ bindings?: GatewayBinding[];
440
550
  /** Persisted port (fixed default; falls back to ephemeral on EADDRINUSE). */
441
551
  port?: number;
442
552
  /**
@@ -463,6 +573,8 @@ interface OutboundApiServerConfig {
463
573
  * boot; a change takes effect on restart. Default-off ⇒ no scheduler runs.
464
574
  */
465
575
  accountProbe?: AccountProbeConfig;
576
+ /** Default-off allowance-aware scheduling; hot-reloaded by the daemon. */
577
+ allowanceScheduling?: AllowanceSchedulingConfig;
466
578
  /**
467
579
  * Layered upstream-proxy segment (upstream-proxy). Optional; when absent no
468
580
  * global/provider proxy applies (direct egress). `normalizeServerConfig` drops
@@ -542,10 +654,23 @@ interface OutboundApiKeyInfo {
542
654
  id: string;
543
655
  name: string;
544
656
  keyPrefix: string;
657
+ /**
658
+ * Whether the operator "view key" affordance is available for this key — true
659
+ * only when a reversibly-encrypted `keySecret` was persisted at creation.
660
+ * Legacy hash-only rows (and any DB without a `SecretBox`) read as absent ⇒
661
+ * not revealable. Optional so a pre-upgrade daemon response type-checks.
662
+ */
663
+ revealable?: boolean;
545
664
  enabled: boolean;
546
665
  createdAt: number;
547
666
  lastUsedAt: number | null;
548
667
  revoked: boolean;
668
+ /** Intended consumer. Existing rows default to a general client key. */
669
+ kind?: 'client' | 'integration';
670
+ /** Optional endpoint allow-list. Absent means every outbound endpoint. */
671
+ allowedEndpoints?: OutboundEndpoint[];
672
+ /** When true the key is rejected unless the TCP peer is loopback. */
673
+ loopbackOnly?: boolean;
549
674
  /**
550
675
  * Per-key concurrency ceiling for the outbound concurrency gate. Absent or
551
676
  * `0` = unlimited (the gate is bypassed entirely for this key).
@@ -571,7 +696,7 @@ interface OutboundApiKeyInfo {
571
696
  rateLimitWindowMs?: number | null;
572
697
  /** Master switch: when false/unset the model list is inert (no restriction). */
573
698
  enableModelRestriction?: boolean;
574
- /** Restriction mode; absent ⇒ `'blacklist'` (CRS-parity). */
699
+ /** Restriction mode; absent ⇒ `'blacklist'`. */
575
700
  restrictionMode?: OutboundKeyModelRestrictionMode;
576
701
  /** The model-id list the mode acts on (bare modelIds; empty allowlist denies all). */
577
702
  restrictedModels?: string[];
@@ -633,10 +758,25 @@ interface OutboundKeyDbRow {
633
758
  name: string;
634
759
  keyHash: string;
635
760
  keyPrefix: string;
761
+ /**
762
+ * OPTIONAL reversibly-encrypted plaintext of the secret (an `enc:v1:…`
763
+ * envelope produced by the daemon's `SecretBox`). Absent on legacy rows
764
+ * (created before revealable storage) AND on any DB constructed without a
765
+ * `SecretBox` — in both cases the key is NOT revealable. The hash above
766
+ * remains the auth lookup index; this field only powers the operator
767
+ * "view key" affordance.
768
+ */
769
+ keySecret?: string;
636
770
  enabled: boolean;
637
771
  createdAt: number;
638
772
  lastUsedAt: number | null;
639
773
  revokedAt: number | null;
774
+ /** Intended consumer. Existing rows without this field remain client keys. */
775
+ kind?: 'client' | 'integration';
776
+ /** Optional endpoint allow-list for least-privilege integration keys. */
777
+ allowedEndpoints?: OutboundEndpoint[];
778
+ /** Restrict use to requests whose direct socket peer is loopback. */
779
+ loopbackOnly?: boolean;
640
780
  /**
641
781
  * Per-key concurrency ceiling. Absent/`0` = unlimited = the concurrency gate
642
782
  * is bypassed for this key. Persisted by the daemon (`omnicross-uqc-daemon`).
@@ -676,6 +816,17 @@ interface OutboundKeyDb {
676
816
  keyHash: string;
677
817
  keyPrefix: string;
678
818
  createdAt?: number;
819
+ kind?: 'client' | 'integration';
820
+ allowedEndpoints?: OutboundEndpoint[];
821
+ loopbackOnly?: boolean;
822
+ /**
823
+ * The generated plaintext secret. When the DB holds a `SecretBox` it
824
+ * persists a reversibly-encrypted copy as `keySecret` (enabling the
825
+ * "view key" affordance); when no box is wired the plaintext is dropped
826
+ * (byte-identical to the legacy hash-only storage). The hash above — NOT
827
+ * this field — remains the auth lookup index.
828
+ */
829
+ plaintext?: string;
679
830
  }): Promise<OutboundKeyDbRow>;
680
831
  outboundApiKeysRevoke(id: string): Promise<boolean>;
681
832
  outboundApiKeysTouchLastUsed(id: string): Promise<boolean>;
@@ -703,6 +854,21 @@ interface OutboundKeyDb {
703
854
  * idempotent).
704
855
  */
705
856
  outboundApiKeysMarkActivated(id: string, activatedAt: number): Promise<boolean>;
857
+ /**
858
+ * Reveal the stored plaintext for a key (the operator "view key" affordance),
859
+ * or `null` when the key is missing OR was persisted without a `keySecret`
860
+ * (legacy hash-only rows / a DB constructed without a `SecretBox`). The
861
+ * daemon-owned DB decrypts its stored envelope; core never handles the
862
+ * master key.
863
+ */
864
+ outboundApiKeysReveal(id: string): Promise<string | null>;
865
+ /**
866
+ * Permanently remove a key row (hard delete), returning whether a row was
867
+ * removed. Unlike {@link outboundApiKeysRevoke} (a soft revoke that keeps the
868
+ * row for history), this purges the row entirely — intended for cleaning up
869
+ * already-revoked keys. Irreversible; the caller confirms.
870
+ */
871
+ outboundApiKeysDelete(id: string): Promise<boolean>;
706
872
  }
707
873
  /**
708
874
  * App-session-scoped dependencies the outbound server needs. The resident
@@ -751,4 +917,4 @@ interface OutboundApiDeps {
751
917
  readonly logger?: Logger;
752
918
  }
753
919
 
754
- export { type AccountProbeConfig as A, toVoucherInfo as B, type ChatDispatchMode as C, voucherCodePrefix as D, ENDPOINT_MODEL_KINDS as E, type FingerprintConfig as F, type ModelRef as G, type AccountHealthConfig as H, type OutboundKeyModelRestrictionMode as I, type KeySpendReader as K, type MessagesModelKind as M, type OutboundKeyDb as O, type RequestRole as R, type UserMessageQueueConfig as U, type VoucherCreateInput as V, type ConcurrencyQueueConfig as a, type EndpointRoutingConfig as b, type KeySpendSeeder as c, KeySpendTracker as d, type KindMappedEndpoint as e, type ModelKind as f, type ModelPrefixTargets as g, type OutboundApiDeps as h, type OutboundApiKeyCreated as i, type OutboundApiKeyInfo as j, type OutboundApiServerConfig as k, type OutboundApiServerStatus as l, type OutboundEndpoint as m, type OutboundFormatUrls as n, type OutboundKeyActivationMode as o, type OutboundKeyDbRow as p, type OutboundKeyPolicy as q, type OutboundProxyConfig as r, type ResponsesModelKind as s, type VoucherDb as t, computeVoucherGrant as u, generateVoucherCode as v, hashVoucherCode as w, newVoucherId as x, startOfLocalDay as y, startOfLocalWeek as z };
920
+ export { type AccountProbeConfig as A, computeVoucherGrant as B, type ChatDispatchMode as C, generateVoucherCode as D, ENDPOINT_MODEL_KINDS as E, type FingerprintConfig as F, type GatewayBinding as G, hashVoucherCode as H, newVoucherId as I, startOfLocalDay as J, type KeySpendReader as K, startOfLocalWeek as L, type MessagesModelKind as M, toVoucherInfo as N, type OutboundKeyDb as O, voucherCodePrefix as P, type ModelRef as Q, type RequestRole as R, type AccountHealthConfig as S, type OutboundKeyModelRestrictionMode as T, type UserMessageQueueConfig as U, type VoucherCreateInput as V, type AllowanceSchedulingConfig as a, type ConcurrencyQueueConfig as b, type EndpointRoutingConfig as c, type GatewayBindingFallback as d, type GatewayBindingKeyScope as e, type GatewayBindingModelMode as f, type GatewayBindingTarget as g, type GatewayModelMapping as h, type KeySpendSeeder as i, KeySpendTracker as j, type KindMappedEndpoint as k, type ModelKind as l, type ModelPrefixTargets as m, type OutboundApiDeps as n, type OutboundApiKeyCreated as o, type OutboundApiKeyInfo as p, type OutboundApiServerConfig as q, type OutboundApiServerStatus as r, type OutboundEndpoint as s, type OutboundFormatUrls as t, type OutboundKeyActivationMode as u, type OutboundKeyDbRow as v, type OutboundKeyPolicy as w, type OutboundProxyConfig as x, type ResponsesModelKind as y, type VoucherDb as z };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkYMFAJFQTcjs = require('../chunk-YMFAJFQT.cjs');
3
+ var _chunk2E42SAW3cjs = require('../chunk-2E42SAW3.cjs');
4
4
 
5
5
 
6
- exports.PricingEngine = _chunkYMFAJFQTcjs.PricingEngine;
6
+ exports.PricingEngine = _chunk2E42SAW3cjs.PricingEngine;
@@ -9,7 +9,8 @@ import { PricingStore } from '../ports/pricing-store.cjs';
9
9
  * Persistence goes through the injected `PricingStore` port. Sources of
10
10
  * pricing rows:
11
11
  * - 'builtin' — bundled fallback prices, seeded by the host
12
- * - 'litellm' — refreshed on user demand from LiteLLM's public JSON
12
+ * - 'litellm' — primary catalog from LiteLLM's public JSON
13
+ * - 'openrouter' — supplemental OpenRouter route pricing
13
14
  * - 'user' — hand-edited; protected from auto-overwrite
14
15
  *
15
16
  * @module usage/pricing-engine
@@ -29,8 +30,12 @@ interface CostCalculation {
29
30
  interface PricingEngineOptions {
30
31
  /** Override the pricing-source JSON URL — useful for testing. */
31
32
  sourceUrl?: string;
33
+ /** Override the supplemental OpenRouter catalog URL. */
34
+ openRouterSourceUrl?: string;
32
35
  /** Override `fetch` — useful for testing. */
33
36
  fetchImpl?: typeof fetch;
37
+ /** Bound each remote source independently; both sources are fetched in parallel. */
38
+ fetchTimeoutMs?: number;
34
39
  }
35
40
  declare class PricingEngine {
36
41
  private store;
@@ -45,7 +50,18 @@ declare class PricingEngine {
45
50
  * non-wildcard entry per model wins.
46
51
  */
47
52
  private cacheByModel;
53
+ /**
54
+ * Last-resort fuzzy index: `[normalizedModelId, entry]` pairs over the same
55
+ * non-wildcard, non-openrouter rows as `cacheByModel`. Used when even the
56
+ * model-name fallback misses — e.g. usage recorded under a bare model id
57
+ * (`glm-5.2`) while the catalog only knows prefixed slugs
58
+ * (`cloudflare/@cf/zai-org/glm-5.2`). This is an ESTIMATE: the matched row
59
+ * may be an aggregate-route price rather than the direct-vendor rate.
60
+ */
61
+ private fuzzyEntries;
48
62
  private cacheLoaded;
63
+ /** Coalesce manual and background refreshes to prevent a catalog stampede. */
64
+ private refreshInFlight;
49
65
  constructor(store: PricingStore, logger: Logger, options?: PricingEngineOptions);
50
66
  /** Lazy-load and cache the full pricing table. */
51
67
  private ensureCache;
@@ -58,8 +74,19 @@ declare class PricingEngine {
58
74
  * 2. wildcard provider ('*', modelId)
59
75
  * 3. model name alone (any provider) — tolerates a runtime-alias vs
60
76
  * canonical provider-id mismatch for the same model.
77
+ * 4. normalized fuzzy match (last resort) — matches a bare id like
78
+ * `glm-5.2` against prefixed catalog slugs like
79
+ * `cloudflare/@cf/zai-org/glm-5.2`. ESTIMATE only: the matched row may
80
+ * be an aggregate-route price, not the direct-vendor rate.
61
81
  */
62
82
  getEntry(providerId: string, modelId: string): Promise<PricingEntry | null>;
83
+ /**
84
+ * Normalized substring match over the catalog's non-openrouter rows. Lowercases
85
+ * and strips all non-alphanumerics, then matches bidirectionally, preferring
86
+ * the shortest catalog key (tightest match) to reduce over-matching version
87
+ * variants. Returns null when nothing matches.
88
+ */
89
+ private fuzzyMatch;
63
90
  /**
64
91
  * Compute the cost (and cache savings) for a single response.
65
92
  *
@@ -77,6 +104,7 @@ declare class PricingEngine {
77
104
  calculateCost(providerId: string, modelId: string, usage: UsageTokens): Promise<CostCalculation>;
78
105
  upsertManual(input: PricingEntryInput): Promise<PricingEntry>;
79
106
  fetchLatestFromSource(): Promise<PricingFetchResult>;
107
+ private refreshSources;
80
108
  resolveConflicts(decisions: PricingConflictDecision[], pendingIncoming: Map<string, PricingEntryInput>): Promise<PricingResolution>;
81
109
  }
82
110