@omnicross/core 0.1.2 → 0.1.3

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 (131) hide show
  1. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -1
  2. package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -1
  3. package/dist/{chunk-SN3YWBX7.cjs → chunk-2FMI2B6V.cjs} +2329 -533
  4. package/dist/{chunk-XBSYYZIY.cjs → chunk-3QOSDDNI.cjs} +39 -3
  5. package/dist/{chunk-2FEVTJWG.js → chunk-4DECIFU7.js} +2162 -366
  6. package/dist/chunk-4IH4EL7M.cjs +9 -0
  7. package/dist/chunk-5ENKBSWO.js +311 -0
  8. package/dist/chunk-6RPZADX3.cjs +92 -0
  9. package/dist/chunk-AEOZIDEB.cjs +32 -0
  10. package/dist/chunk-BO4RFWBR.js +89 -0
  11. package/dist/{chunk-MNYKI4CI.js → chunk-CWM2ZDU5.js} +36 -0
  12. package/dist/chunk-CZHZGRU7.js +383 -0
  13. package/dist/{chunk-4NBS6KPV.cjs → chunk-DQ5VAYZ6.cjs} +7 -8
  14. package/dist/chunk-HUZZZ3JL.js +32 -0
  15. package/dist/{chunk-QOCNX236.js → chunk-IAXWICZU.js} +24 -1
  16. package/dist/{chunk-V5KPWNYX.cjs → chunk-JMJBSACD.cjs} +3 -3
  17. package/dist/chunk-L74VDN4A.cjs +32 -0
  18. package/dist/{chunk-74TMJA7Z.js → chunk-N5QFKSDO.js} +7 -4
  19. package/dist/{chunk-LKZJEL6E.cjs → chunk-Q27JY5RG.cjs} +6 -4
  20. package/dist/{chunk-SPVWWUHX.cjs → chunk-QWBWGODS.cjs} +24 -1
  21. package/dist/chunk-RPII3E6Z.cjs +145 -0
  22. package/dist/chunk-S6JGLF3G.cjs +89 -0
  23. package/dist/chunk-SVXC36MU.cjs +383 -0
  24. package/dist/chunk-TKJMZBAH.js +32 -0
  25. package/dist/{chunk-ZSVQT3PW.js → chunk-UBWEBKRC.js} +5 -6
  26. package/dist/chunk-UNEFIWXI.cjs +32 -0
  27. package/dist/chunk-VQY5W4YW.cjs +311 -0
  28. package/dist/chunk-WNY4WMRF.js +32 -0
  29. package/dist/chunk-XEKD23J5.js +9 -0
  30. package/dist/chunk-XTEI64OU.js +145 -0
  31. package/dist/chunk-XX6NQJMA.js +92 -0
  32. package/dist/{chunk-N3V2J5ZO.cjs → chunk-Y6OM7EV7.cjs} +7 -4
  33. package/dist/{chunk-745DV5FL.js → chunk-Y7FO65VT.js} +3 -3
  34. package/dist/{chunk-PXUJF5HS.js → chunk-ZY6KU6P3.js} +4 -2
  35. package/dist/completion/CompletionService.cjs +22 -15
  36. package/dist/completion/CompletionService.js +21 -14
  37. package/dist/completion/NativeSearchInjector.cjs +3 -3
  38. package/dist/completion/NativeSearchInjector.js +2 -2
  39. package/dist/completion/openrouter-headers.cjs +3 -6
  40. package/dist/completion/openrouter-headers.d.cts +9 -12
  41. package/dist/completion/openrouter-headers.d.ts +9 -12
  42. package/dist/completion/openrouter-headers.js +2 -5
  43. package/dist/completion/openrouter-models.cjs +4 -3
  44. package/dist/completion/openrouter-models.js +2 -1
  45. package/dist/completion.cjs +22 -15
  46. package/dist/completion.js +21 -14
  47. package/dist/index.cjs +139 -17
  48. package/dist/index.d.cts +40 -10
  49. package/dist/index.d.ts +40 -10
  50. package/dist/index.js +146 -24
  51. package/dist/outbound-api/routeResolver.cjs +5 -2
  52. package/dist/outbound-api/routeResolver.d.cts +8 -2
  53. package/dist/outbound-api/routeResolver.d.ts +8 -2
  54. package/dist/outbound-api/routeResolver.js +4 -1
  55. package/dist/outbound-api/types.cjs +6 -1
  56. package/dist/outbound-api/types.d.cts +11 -144
  57. package/dist/outbound-api/types.d.ts +11 -144
  58. package/dist/outbound-api/types.js +6 -0
  59. package/dist/outbound-api.cjs +133 -15
  60. package/dist/outbound-api.d.cts +786 -25
  61. package/dist/outbound-api.d.ts +786 -25
  62. package/dist/outbound-api.js +137 -19
  63. package/dist/pipeline/AuthSource.d.cts +23 -1
  64. package/dist/pipeline/AuthSource.d.ts +23 -1
  65. package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
  66. package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
  67. package/dist/pipeline/SubscriptionAccountHealth.cjs +22 -0
  68. package/dist/pipeline/SubscriptionAccountHealth.d.cts +235 -0
  69. package/dist/pipeline/SubscriptionAccountHealth.d.ts +235 -0
  70. package/dist/pipeline/SubscriptionAccountHealth.js +22 -0
  71. package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
  72. package/dist/pipeline/SubscriptionAuthSource.d.cts +3 -2
  73. package/dist/pipeline/SubscriptionAuthSource.d.ts +3 -2
  74. package/dist/pipeline/SubscriptionAuthSource.js +1 -1
  75. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +24 -1
  76. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +24 -1
  77. package/dist/pipeline/auditSink.cjs +14 -0
  78. package/dist/pipeline/auditSink.d.cts +48 -0
  79. package/dist/pipeline/auditSink.d.ts +48 -0
  80. package/dist/pipeline/auditSink.js +14 -0
  81. package/dist/pipeline/billingEmit.cjs +14 -0
  82. package/dist/pipeline/billingEmit.d.cts +49 -0
  83. package/dist/pipeline/billingEmit.d.ts +49 -0
  84. package/dist/pipeline/billingEmit.js +14 -0
  85. package/dist/ports/usage-event-store.d.cts +26 -1
  86. package/dist/ports/usage-event-store.d.ts +26 -1
  87. package/dist/ports.d.cts +7 -1
  88. package/dist/ports.d.ts +7 -1
  89. package/dist/provider-proxy/ProviderProxy.cjs +22 -15
  90. package/dist/provider-proxy/ProviderProxy.js +21 -14
  91. package/dist/provider-proxy/identity/SubscriptionIdentityStore.cjs +15 -0
  92. package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.cts +121 -0
  93. package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.ts +121 -0
  94. package/dist/provider-proxy/identity/SubscriptionIdentityStore.js +15 -0
  95. package/dist/provider-proxy/identity/fingerprintHeaders.cjs +20 -0
  96. package/dist/provider-proxy/identity/fingerprintHeaders.d.cts +89 -0
  97. package/dist/provider-proxy/identity/fingerprintHeaders.d.ts +89 -0
  98. package/dist/provider-proxy/identity/fingerprintHeaders.js +20 -0
  99. package/dist/provider-proxy/ingress/providerProxyShared.cjs +22 -15
  100. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +11 -2
  101. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +11 -2
  102. package/dist/provider-proxy/ingress/providerProxyShared.js +21 -14
  103. package/dist/provider-proxy/matchText.cjs +4 -2
  104. package/dist/provider-proxy/matchText.d.cts +14 -1
  105. package/dist/provider-proxy/matchText.d.ts +14 -1
  106. package/dist/provider-proxy/matchText.js +3 -1
  107. package/dist/provider-proxy/types.d.cts +23 -0
  108. package/dist/provider-proxy/types.d.ts +23 -0
  109. package/dist/provider-proxy.cjs +22 -15
  110. package/dist/provider-proxy.js +21 -14
  111. package/dist/{routeResolver-HE-ZO0fO.d.ts → routeResolver-B1NglTfe.d.ts} +36 -10
  112. package/dist/{routeResolver-BrbK6ja9.d.cts → routeResolver-CbG5uBgm.d.cts} +36 -10
  113. package/dist/transformer/transformers.cjs +7 -7
  114. package/dist/transformer/transformers.js +7 -7
  115. package/dist/transformer.cjs +5 -5
  116. package/dist/transformer.js +4 -4
  117. package/dist/types-6OUY_xfA.d.ts +830 -0
  118. package/dist/types-aBFFXoBz.d.cts +830 -0
  119. package/dist/usage/usage-recorder.cjs +2 -2
  120. package/dist/usage/usage-recorder.d.cts +19 -1
  121. package/dist/usage/usage-recorder.d.ts +19 -1
  122. package/dist/usage/usage-recorder.js +1 -1
  123. package/dist/usage.cjs +2 -2
  124. package/dist/usage.js +1 -1
  125. package/package.json +4 -2
  126. package/dist/chunk-3MEACFK3.js +0 -193
  127. package/dist/chunk-6VIXXLMX.cjs +0 -14
  128. package/dist/chunk-E3WHL7CO.js +0 -14
  129. package/dist/chunk-G2FUJNA2.cjs +0 -193
  130. package/dist/{chunk-UYPEN5XE.cjs → chunk-FFALUUZZ.cjs} +5 -5
  131. package/dist/{chunk-O466Y272.js → chunk-MQNDWYPN.js} +6 -6
@@ -0,0 +1,89 @@
1
+ import { SubscriptionIdentityStore } from './SubscriptionIdentityStore.js';
2
+
3
+ /**
4
+ * fingerprintHeaders — the PURE half of subscription client-fingerprint replay
5
+ * (subscription-client-fingerprint #7, design D2/D3/D4/D7).
6
+ *
7
+ * Holds ONLY pure functions (no state, no store): the capture WHITELIST
8
+ * (`extractFingerprintHeaders`), the store-normalizer (`sanitizeFrozenHeaders`),
9
+ * the TTL refresh split (`refreshNonStainless`), the outbound merge
10
+ * (`mergeFrozenIdentity`), and the one composition entrypoint the relay calls
11
+ * (`applyFingerprint`, which takes the store INSTANCE as a parameter so this file
12
+ * never imports the store at runtime — no cycle).
13
+ *
14
+ * SAFETY CORE (non-negotiable):
15
+ * - The capture whitelist is POSITIVE (`x-stainless-*` + a small set of
16
+ * Claude-Code / Anthropic-SDK header names) AND has an explicit EXCLUSION of
17
+ * `authorization` / `x-api-key` / `cookie` (the token/secret) — belt AND
18
+ * suspenders, so widening the whitelist can never leak auth.
19
+ * - The outbound merge NEVER overwrites `authorization` / `content-type`
20
+ * (the auth strategy owns auth; content-type is fixed) and never overwrites a
21
+ * header the outbound build already set (case-insensitive).
22
+ * - Values are only ever REAL captured client headers — nothing here fabricates
23
+ * a `x-stainless-*` value. The only synthesizable piece is the operator-set UA
24
+ * baseline, applied in `applyFingerprint` ONLY when NOTHING was captured.
25
+ *
26
+ * @module provider-proxy/identity/fingerprintHeaders
27
+ */
28
+
29
+ /** Header-name prefix that marks a stainless (SDK-runtime) fingerprint header. */
30
+ declare const STAINLESS_PREFIX = "x-stainless-";
31
+ /** Whether a header name (any case) is a stainless fingerprint header. */
32
+ declare function isStainless(name: string): boolean;
33
+ /**
34
+ * Capture: extract the WHITELISTED fingerprint headers from an incoming client
35
+ * request's header bag (`http.IncomingHttpHeaders`-shaped). Array values (rare —
36
+ * duplicate headers) are joined with `, `. Keys are lowercased. The auth/secret
37
+ * exclusion is applied FIRST so it wins over any whitelist entry. Never throws.
38
+ */
39
+ declare function extractFingerprintHeaders(reqHeaders: Record<string, string | string[] | undefined>): Record<string, string>;
40
+ /**
41
+ * Ingress capture gate (subscription-client-fingerprint #7): extract the caller's
42
+ * fingerprint headers ONLY when replay is enabled — returns `undefined` when
43
+ * disabled so the ingress does NO extraction work on the default/BYO path (and
44
+ * threads nothing to the relay). Behavior when enabled is identical to calling
45
+ * `extractFingerprintHeaders` directly.
46
+ */
47
+ declare function captureCallerIdentity(store: SubscriptionIdentityStore, reqHeaders: Record<string, string | string[] | undefined>): Record<string, string> | undefined;
48
+ /**
49
+ * Store-normalize a header bag before freezing/seeding: lowercase keys, drop
50
+ * empty/non-string values, and HARD-EXCLUDE the auth/secret + protected-outbound
51
+ * sets. This is the second line of defense (after the capture whitelist) so a
52
+ * persisted/seeded identity can never carry a token even if a bad bag was handed
53
+ * in. Idempotent.
54
+ */
55
+ declare function sanitizeFrozenHeaders(headers: Record<string, string>): Record<string, string>;
56
+ /**
57
+ * TTL refresh split (P2, piece 2): produce the refreshed frozen set when a newer
58
+ * real capture is observed after the CC-header TTL. The STAINLESS set stays
59
+ * frozen-stable (only the original values survive — a real client keeps a stable
60
+ * stainless identity); the NON-stainless headers (user-agent / anthropic-beta /
61
+ * x-app / …) are refreshed from the newer observation, falling back to the frozen
62
+ * value when the new bag omits one. New stainless headers in the incoming bag are
63
+ * IGNORED (stainless never grows/changes after the first freeze).
64
+ */
65
+ declare function refreshNonStainless(frozen: Record<string, string>, incoming: Record<string, string>): Record<string, string>;
66
+ /**
67
+ * Merge a frozen identity into the outbound `headers` in place. NEVER overwrites
68
+ * `authorization` / `content-type`, and never overwrites a header already present
69
+ * (case-insensitive) — so a header the auth strategy or the relay already set
70
+ * always wins. The identity keys are already lowercased (`sanitizeFrozenHeaders`).
71
+ */
72
+ declare function mergeFrozenIdentity(headers: Record<string, string>, identity: Record<string, string>): void;
73
+ /**
74
+ * The ONE composition entrypoint the claude same-format relay calls, AFTER
75
+ * `applyHeaders` reported the selected account and BEFORE `fetchUpstream`.
76
+ *
77
+ * Disabled (default) OR no account id ⇒ a strict no-op — the `headers` object is
78
+ * left BYTE-IDENTICAL (the zero-regression guarantee). When enabled:
79
+ * 1. capture the caller's real fingerprint headers for this account (first-seen
80
+ * freeze; P2 TTL refresh) — per-account, keyed by the reported account id;
81
+ * 2. replay the frozen identity for the account into `headers` (never
82
+ * overwriting auth/content-type). On the FIRST request this is the client's
83
+ * own just-captured headers (honest); later requests replay the frozen set;
84
+ * 3. if NOTHING is captured for the account, apply ONLY the operator-configured
85
+ * UA baseline (never a fabricated stainless value).
86
+ */
87
+ declare function applyFingerprint(store: SubscriptionIdentityStore, headers: Record<string, string>, providerId: string, accountId: string | undefined, callerIdentity: Record<string, string> | undefined, now?: number): void;
88
+
89
+ export { STAINLESS_PREFIX, applyFingerprint, captureCallerIdentity, extractFingerprintHeaders, isStainless, mergeFrozenIdentity, refreshNonStainless, sanitizeFrozenHeaders };
@@ -0,0 +1,20 @@
1
+ import {
2
+ STAINLESS_PREFIX,
3
+ applyFingerprint,
4
+ captureCallerIdentity,
5
+ extractFingerprintHeaders,
6
+ isStainless,
7
+ mergeFrozenIdentity,
8
+ refreshNonStainless,
9
+ sanitizeFrozenHeaders
10
+ } from "../../chunk-XX6NQJMA.js";
11
+ export {
12
+ STAINLESS_PREFIX,
13
+ applyFingerprint,
14
+ captureCallerIdentity,
15
+ extractFingerprintHeaders,
16
+ isStainless,
17
+ mergeFrozenIdentity,
18
+ refreshNonStainless,
19
+ sanitizeFrozenHeaders
20
+ };
@@ -7,39 +7,46 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkSN3YWBX7cjs = require('../../chunk-SN3YWBX7.cjs');
11
- require('../../chunk-SPVWWUHX.cjs');
10
+ var _chunk2FMI2B6Vcjs = require('../../chunk-2FMI2B6V.cjs');
12
11
  require('../../chunk-HQP3K7PU.cjs');
13
12
  require('../../chunk-FZ46M34D.cjs');
14
13
  require('../../chunk-46ZIFWYG.cjs');
15
- require('../../chunk-GBHYAGX3.cjs');
16
14
  require('../../chunk-3OPYJG76.cjs');
17
- require('../../chunk-UYPEN5XE.cjs');
18
- require('../../chunk-7YN22L2H.cjs');
19
- require('../../chunk-2DCNB7DF.cjs');
15
+ require('../../chunk-FFALUUZZ.cjs');
20
16
  require('../../chunk-C72S6TTV.cjs');
21
17
  require('../../chunk-DWKQZ2SK.cjs');
22
18
  require('../../chunk-4VAVYUZS.cjs');
19
+ require('../../chunk-7YN22L2H.cjs');
20
+ require('../../chunk-2DCNB7DF.cjs');
23
21
  require('../../chunk-EYZYXJTJ.cjs');
24
22
  require('../../chunk-YMFAJFQT.cjs');
25
- require('../../chunk-XBSYYZIY.cjs');
23
+ require('../../chunk-3QOSDDNI.cjs');
24
+ require('../../chunk-GBHYAGX3.cjs');
25
+ require('../../chunk-RPII3E6Z.cjs');
26
+ require('../../chunk-6RPZADX3.cjs');
27
+ require('../../chunk-QWBWGODS.cjs');
28
+ require('../../chunk-NYUNU75A.cjs');
29
+ require('../../chunk-VQY5W4YW.cjs');
30
+ require('../../chunk-Y6OM7EV7.cjs');
31
+ require('../../chunk-SVNDB62D.cjs');
26
32
  require('../../chunk-R3HK6R4B.cjs');
33
+ require('../../chunk-AEOZIDEB.cjs');
34
+ require('../../chunk-L74VDN4A.cjs');
27
35
  require('../../chunk-KUU2RNG6.cjs');
28
- require('../../chunk-LKZJEL6E.cjs');
36
+ require('../../chunk-Q27JY5RG.cjs');
29
37
  require('../../chunk-QXD4MV2X.cjs');
30
- require('../../chunk-NYUNU75A.cjs');
31
- require('../../chunk-N3V2J5ZO.cjs');
32
- require('../../chunk-SVNDB62D.cjs');
33
38
  require('../../chunk-A2YMUCBT.cjs');
34
- require('../../chunk-G2FUJNA2.cjs');
39
+ require('../../chunk-SVXC36MU.cjs');
35
40
  require('../../chunk-QBZJ7P2T.cjs');
41
+ require('../../chunk-4IH4EL7M.cjs');
36
42
  require('../../chunk-SUEGJ75D.cjs');
43
+ require('../../chunk-S6JGLF3G.cjs');
37
44
  require('../../chunk-RSJ3TWJQ.cjs');
38
45
  require('../../chunk-YGXJGRFI.cjs');
39
46
  require('../../chunk-NZYN7C3P.cjs');
40
- require('../../chunk-V5KPWNYX.cjs');
41
- require('../../chunk-6VIXXLMX.cjs');
47
+ require('../../chunk-JMJBSACD.cjs');
42
48
  require('../../chunk-GMMT7RVN.cjs');
49
+ require('../../chunk-UNEFIWXI.cjs');
43
50
 
44
51
 
45
52
 
@@ -49,4 +56,4 @@ require('../../chunk-GMMT7RVN.cjs');
49
56
 
50
57
 
51
58
 
52
- exports.getAnthropicEndpointTransformer = _chunkSN3YWBX7cjs.getAnthropicEndpointTransformer; exports.getGeminiEndpointTransformer = _chunkSN3YWBX7cjs.getGeminiEndpointTransformer; exports.getResponsesEndpointTransformer = _chunkSN3YWBX7cjs.getResponsesEndpointTransformer; exports.getSharedExecutor = _chunkSN3YWBX7cjs.getSharedExecutor; exports.readBody = _chunkSN3YWBX7cjs.readBody; exports.relayResponse = _chunkSN3YWBX7cjs.relayResponse; exports.resolvePoolBoundKey = _chunkSN3YWBX7cjs.resolvePoolBoundKey; exports.writeError = _chunkSN3YWBX7cjs.writeError;
59
+ exports.getAnthropicEndpointTransformer = _chunk2FMI2B6Vcjs.getAnthropicEndpointTransformer; exports.getGeminiEndpointTransformer = _chunk2FMI2B6Vcjs.getGeminiEndpointTransformer; exports.getResponsesEndpointTransformer = _chunk2FMI2B6Vcjs.getResponsesEndpointTransformer; exports.getSharedExecutor = _chunk2FMI2B6Vcjs.getSharedExecutor; exports.readBody = _chunk2FMI2B6Vcjs.readBody; exports.relayResponse = _chunk2FMI2B6Vcjs.relayResponse; exports.resolvePoolBoundKey = _chunk2FMI2B6Vcjs.resolvePoolBoundKey; exports.writeError = _chunk2FMI2B6Vcjs.writeError;
@@ -43,9 +43,18 @@ declare function readBody(req: http.IncomingMessage): Promise<string>;
43
43
  * - else: read the JSON text and write it once, returning it so the caller can
44
44
  * tap usage. Mirrors the host's codex relay.
45
45
  *
46
- * @returns the JSON body text for non-stream responses, else `null`.
46
+ * `rewriteModel` (optional, design D4): when set, the response `model` is
47
+ * rewritten to this id — top-level + nested `response.model` for non-stream JSON,
48
+ * and EVERY model-bearing SSE event for streams — so a kind-mapped outbound
49
+ * caller (Claude Code / Codex) sees its ORIGINAL requested id, not the upstream
50
+ * provider name. When UNSET the relay is byte-identical to before (the resident
51
+ * proxy + `chat`/`gemini` ingresses never pass it → zero regression). The RETURN
52
+ * value stays the UPSTREAM body text (the usage tap must account on the real
53
+ * upstream model), even though the client receives the rewritten body.
54
+ *
55
+ * @returns the (upstream) JSON body text for non-stream responses, else `null`.
47
56
  */
48
- declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean): Promise<string | null>;
57
+ declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean, rewriteModel?: string): Promise<string | null>;
49
58
  /** Write a JSON error response if the headers have not been sent. */
50
59
  declare function writeError(res: http.ServerResponse, status: number, message: string): void;
51
60
  /**
@@ -43,9 +43,18 @@ declare function readBody(req: http.IncomingMessage): Promise<string>;
43
43
  * - else: read the JSON text and write it once, returning it so the caller can
44
44
  * tap usage. Mirrors the host's codex relay.
45
45
  *
46
- * @returns the JSON body text for non-stream responses, else `null`.
46
+ * `rewriteModel` (optional, design D4): when set, the response `model` is
47
+ * rewritten to this id — top-level + nested `response.model` for non-stream JSON,
48
+ * and EVERY model-bearing SSE event for streams — so a kind-mapped outbound
49
+ * caller (Claude Code / Codex) sees its ORIGINAL requested id, not the upstream
50
+ * provider name. When UNSET the relay is byte-identical to before (the resident
51
+ * proxy + `chat`/`gemini` ingresses never pass it → zero regression). The RETURN
52
+ * value stays the UPSTREAM body text (the usage tap must account on the real
53
+ * upstream model), even though the client receives the rewritten body.
54
+ *
55
+ * @returns the (upstream) JSON body text for non-stream responses, else `null`.
47
56
  */
48
- declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean): Promise<string | null>;
57
+ declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean, rewriteModel?: string): Promise<string | null>;
49
58
  /** Write a JSON error response if the headers have not been sent. */
50
59
  declare function writeError(res: http.ServerResponse, status: number, message: string): void;
51
60
  /**
@@ -7,39 +7,46 @@ import {
7
7
  relayResponse,
8
8
  resolvePoolBoundKey,
9
9
  writeError
10
- } from "../../chunk-2FEVTJWG.js";
11
- import "../../chunk-QOCNX236.js";
10
+ } from "../../chunk-4DECIFU7.js";
12
11
  import "../../chunk-VVEHS2LI.js";
13
12
  import "../../chunk-46RLHI7D.js";
14
13
  import "../../chunk-G2UTNSGU.js";
15
- import "../../chunk-MZNPGW5Q.js";
16
14
  import "../../chunk-DK4A7DLE.js";
17
- import "../../chunk-O466Y272.js";
18
- import "../../chunk-C7PSERMH.js";
19
- import "../../chunk-5HTVET6E.js";
15
+ import "../../chunk-MQNDWYPN.js";
20
16
  import "../../chunk-Z7LUNECE.js";
21
17
  import "../../chunk-ZJZAOKI7.js";
22
18
  import "../../chunk-FTQ7IQUC.js";
19
+ import "../../chunk-C7PSERMH.js";
20
+ import "../../chunk-5HTVET6E.js";
23
21
  import "../../chunk-7VU7V2E4.js";
24
22
  import "../../chunk-ZLX3KGXX.js";
25
- import "../../chunk-MNYKI4CI.js";
23
+ import "../../chunk-CWM2ZDU5.js";
24
+ import "../../chunk-MZNPGW5Q.js";
25
+ import "../../chunk-XTEI64OU.js";
26
+ import "../../chunk-XX6NQJMA.js";
27
+ import "../../chunk-IAXWICZU.js";
28
+ import "../../chunk-5ERIZW3D.js";
29
+ import "../../chunk-5ENKBSWO.js";
30
+ import "../../chunk-N5QFKSDO.js";
31
+ import "../../chunk-AVYJ4YBN.js";
26
32
  import "../../chunk-DRWHTIIZ.js";
33
+ import "../../chunk-WNY4WMRF.js";
34
+ import "../../chunk-TKJMZBAH.js";
27
35
  import "../../chunk-JO5NLTLY.js";
28
- import "../../chunk-PXUJF5HS.js";
36
+ import "../../chunk-ZY6KU6P3.js";
29
37
  import "../../chunk-JWC6APFQ.js";
30
- import "../../chunk-5ERIZW3D.js";
31
- import "../../chunk-74TMJA7Z.js";
32
- import "../../chunk-AVYJ4YBN.js";
33
38
  import "../../chunk-H5JUT3KV.js";
34
- import "../../chunk-3MEACFK3.js";
39
+ import "../../chunk-CZHZGRU7.js";
35
40
  import "../../chunk-AQ5TNQB7.js";
41
+ import "../../chunk-XEKD23J5.js";
36
42
  import "../../chunk-5ZQBEOMD.js";
43
+ import "../../chunk-BO4RFWBR.js";
37
44
  import "../../chunk-Z7Y2NPHY.js";
38
45
  import "../../chunk-S4WBV25P.js";
39
46
  import "../../chunk-CDHS2QDC.js";
40
- import "../../chunk-745DV5FL.js";
41
- import "../../chunk-E3WHL7CO.js";
47
+ import "../../chunk-Y7FO65VT.js";
42
48
  import "../../chunk-FMOBD2OQ.js";
49
+ import "../../chunk-HUZZZ3JL.js";
43
50
  export {
44
51
  getAnthropicEndpointTransformer,
45
52
  getGeminiEndpointTransformer,
@@ -3,10 +3,12 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkSPVWWUHXcjs = require('../chunk-SPVWWUHX.cjs');
7
6
 
7
+ var _chunkQWBWGODScjs = require('../chunk-QWBWGODS.cjs');
8
8
 
9
9
 
10
10
 
11
11
 
12
- exports.MATCH_TEXT_PER_MESSAGE_CAP = _chunkSPVWWUHXcjs.MATCH_TEXT_PER_MESSAGE_CAP; exports.MATCH_TEXT_RECENT_MESSAGES = _chunkSPVWWUHXcjs.MATCH_TEXT_RECENT_MESSAGES; exports.collectMatchText = _chunkSPVWWUHXcjs.collectMatchText; exports.flattenMatchText = _chunkSPVWWUHXcjs.flattenMatchText;
12
+
13
+
14
+ exports.MATCH_TEXT_PER_MESSAGE_CAP = _chunkQWBWGODScjs.MATCH_TEXT_PER_MESSAGE_CAP; exports.MATCH_TEXT_RECENT_MESSAGES = _chunkQWBWGODScjs.MATCH_TEXT_RECENT_MESSAGES; exports.collectMatchText = _chunkQWBWGODScjs.collectMatchText; exports.deriveSubscriptionSessionKey = _chunkQWBWGODScjs.deriveSubscriptionSessionKey; exports.flattenMatchText = _chunkQWBWGODScjs.flattenMatchText;
@@ -43,5 +43,18 @@ declare function flattenMatchText(value: unknown): string;
43
43
  * @param anthropicBody the parsed Anthropic Messages request body.
44
44
  */
45
45
  declare function collectMatchText(anthropicBody: Record<string, unknown>): string[];
46
+ /**
47
+ * Derive a STABLE per-conversation session key for the account-pool's session
48
+ * affinity (subscription-account-scheduling, D5). Anchored on `system` + the
49
+ * FIRST `user` message — both survive a multi-turn conversation UNCHANGED (unlike
50
+ * the full transcript, which grows every turn), so one conversation keeps one
51
+ * session key and thus one sticky account. Returns `undefined` when there is no
52
+ * anchor text (⇒ the selector falls back to pure priority/LRU, still correct).
53
+ *
54
+ * Lives here (the shared match-text SSOT) so BOTH relay paths — the core
55
+ * `/v1/messages` ingress and the daemon `SubscriptionDispatcher` — derive the
56
+ * SAME key for the same body.
57
+ */
58
+ declare function deriveSubscriptionSessionKey(anthropicBody: Record<string, unknown>): string | undefined;
46
59
 
47
- export { MATCH_TEXT_PER_MESSAGE_CAP, MATCH_TEXT_RECENT_MESSAGES, collectMatchText, flattenMatchText };
60
+ export { MATCH_TEXT_PER_MESSAGE_CAP, MATCH_TEXT_RECENT_MESSAGES, collectMatchText, deriveSubscriptionSessionKey, flattenMatchText };
@@ -43,5 +43,18 @@ declare function flattenMatchText(value: unknown): string;
43
43
  * @param anthropicBody the parsed Anthropic Messages request body.
44
44
  */
45
45
  declare function collectMatchText(anthropicBody: Record<string, unknown>): string[];
46
+ /**
47
+ * Derive a STABLE per-conversation session key for the account-pool's session
48
+ * affinity (subscription-account-scheduling, D5). Anchored on `system` + the
49
+ * FIRST `user` message — both survive a multi-turn conversation UNCHANGED (unlike
50
+ * the full transcript, which grows every turn), so one conversation keeps one
51
+ * session key and thus one sticky account. Returns `undefined` when there is no
52
+ * anchor text (⇒ the selector falls back to pure priority/LRU, still correct).
53
+ *
54
+ * Lives here (the shared match-text SSOT) so BOTH relay paths — the core
55
+ * `/v1/messages` ingress and the daemon `SubscriptionDispatcher` — derive the
56
+ * SAME key for the same body.
57
+ */
58
+ declare function deriveSubscriptionSessionKey(anthropicBody: Record<string, unknown>): string | undefined;
46
59
 
47
- export { MATCH_TEXT_PER_MESSAGE_CAP, MATCH_TEXT_RECENT_MESSAGES, collectMatchText, flattenMatchText };
60
+ export { MATCH_TEXT_PER_MESSAGE_CAP, MATCH_TEXT_RECENT_MESSAGES, collectMatchText, deriveSubscriptionSessionKey, flattenMatchText };
@@ -2,11 +2,13 @@ import {
2
2
  MATCH_TEXT_PER_MESSAGE_CAP,
3
3
  MATCH_TEXT_RECENT_MESSAGES,
4
4
  collectMatchText,
5
+ deriveSubscriptionSessionKey,
5
6
  flattenMatchText
6
- } from "../chunk-QOCNX236.js";
7
+ } from "../chunk-IAXWICZU.js";
7
8
  export {
8
9
  MATCH_TEXT_PER_MESSAGE_CAP,
9
10
  MATCH_TEXT_RECENT_MESSAGES,
10
11
  collectMatchText,
12
+ deriveSubscriptionSessionKey,
11
13
  flattenMatchText
12
14
  };
@@ -285,6 +285,23 @@ interface RouteContext {
285
285
  readonly targetProviderFormat: TargetProviderFormat;
286
286
  /** Resolved provider model the upstream request targets. */
287
287
  readonly model: string;
288
+ /**
289
+ * The client's ORIGINAL requested model id, for RESPONSE `model` passthrough
290
+ * on the kind-mapped outbound endpoints (`messages`/`responses`). Stamped ONLY
291
+ * by the outbound `resolveRoute` for those endpoints; the resident-proxy route
292
+ * minting path leaves it `undefined`, so internal completions are never
293
+ * rewritten (the two kind-mapped ingresses pass it as `relayResponse`'s
294
+ * `rewriteModel` — undefined ⇒ byte-identical passthrough).
295
+ */
296
+ readonly requestedModel?: string;
297
+ /**
298
+ * The outbound named-key id (`verified.id`) this request authenticated with,
299
+ * for usage attribution (the ByApiKey view). Stamped ONLY by the outbound
300
+ * `resolveRoute`; the resident-proxy route-minting path leaves it `undefined`,
301
+ * so internal completions record `apiKeyId: null` (the taps read
302
+ * `route.apiKeyId ?? null`), exactly as before.
303
+ */
304
+ readonly apiKeyId?: string;
288
305
  /** Wire format this route's ingress decodes. */
289
306
  readonly ingressFormat: IngressFormat;
290
307
  /** Re-auth mode (BYO key vs subscription OAuth). */
@@ -406,6 +423,12 @@ interface UsageRecordImportInput {
406
423
  rawUsage?: unknown;
407
424
  runId?: string | null;
408
425
  eventId?: string | null;
426
+ /**
427
+ * OPTIONAL per-request audit correlation key (request-audit-log) — the outbound
428
+ * relay taps set this to the request's `http.ServerResponse` so the recorder can
429
+ * stash this request's tokens/cost for the audit capture. Opaque; unset ⇒ no-op.
430
+ */
431
+ auditResponse?: object;
409
432
  }
410
433
 
411
434
  export type { AnthropicIngressHandler, AnthropicIngressHandlerFactory, AnthropicRouteHandlerParams, AnthropicSdkHints, ExtendedContextHint, IngressFormat, ProviderProxyDeps, ProxyAttribution, RetryCallback, RouteAuthMode, RouteContext, StreamEventCallback, SubscriptionDispatchProfile, SubscriptionRequestSummary, TargetProviderFormat, UsageRecordImportInput, UsageRecorderImport };
@@ -285,6 +285,23 @@ interface RouteContext {
285
285
  readonly targetProviderFormat: TargetProviderFormat;
286
286
  /** Resolved provider model the upstream request targets. */
287
287
  readonly model: string;
288
+ /**
289
+ * The client's ORIGINAL requested model id, for RESPONSE `model` passthrough
290
+ * on the kind-mapped outbound endpoints (`messages`/`responses`). Stamped ONLY
291
+ * by the outbound `resolveRoute` for those endpoints; the resident-proxy route
292
+ * minting path leaves it `undefined`, so internal completions are never
293
+ * rewritten (the two kind-mapped ingresses pass it as `relayResponse`'s
294
+ * `rewriteModel` — undefined ⇒ byte-identical passthrough).
295
+ */
296
+ readonly requestedModel?: string;
297
+ /**
298
+ * The outbound named-key id (`verified.id`) this request authenticated with,
299
+ * for usage attribution (the ByApiKey view). Stamped ONLY by the outbound
300
+ * `resolveRoute`; the resident-proxy route-minting path leaves it `undefined`,
301
+ * so internal completions record `apiKeyId: null` (the taps read
302
+ * `route.apiKeyId ?? null`), exactly as before.
303
+ */
304
+ readonly apiKeyId?: string;
288
305
  /** Wire format this route's ingress decodes. */
289
306
  readonly ingressFormat: IngressFormat;
290
307
  /** Re-auth mode (BYO key vs subscription OAuth). */
@@ -406,6 +423,12 @@ interface UsageRecordImportInput {
406
423
  rawUsage?: unknown;
407
424
  runId?: string | null;
408
425
  eventId?: string | null;
426
+ /**
427
+ * OPTIONAL per-request audit correlation key (request-audit-log) — the outbound
428
+ * relay taps set this to the request's `http.ServerResponse` so the recorder can
429
+ * stash this request's tokens/cost for the audit capture. Opaque; unset ⇒ no-op.
430
+ */
431
+ auditResponse?: object;
409
432
  }
410
433
 
411
434
  export type { AnthropicIngressHandler, AnthropicIngressHandlerFactory, AnthropicRouteHandlerParams, AnthropicSdkHints, ExtendedContextHint, IngressFormat, ProviderProxyDeps, ProxyAttribution, RetryCallback, RouteAuthMode, RouteContext, StreamEventCallback, SubscriptionDispatchProfile, SubscriptionRequestSummary, TargetProviderFormat, UsageRecordImportInput, UsageRecorderImport };
@@ -5,39 +5,46 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkSN3YWBX7cjs = require('./chunk-SN3YWBX7.cjs');
9
- require('./chunk-SPVWWUHX.cjs');
8
+ var _chunk2FMI2B6Vcjs = require('./chunk-2FMI2B6V.cjs');
10
9
  require('./chunk-HQP3K7PU.cjs');
11
10
  require('./chunk-FZ46M34D.cjs');
12
11
  require('./chunk-46ZIFWYG.cjs');
13
- require('./chunk-GBHYAGX3.cjs');
14
12
  require('./chunk-3OPYJG76.cjs');
15
- require('./chunk-UYPEN5XE.cjs');
16
- require('./chunk-7YN22L2H.cjs');
17
- require('./chunk-2DCNB7DF.cjs');
13
+ require('./chunk-FFALUUZZ.cjs');
18
14
  require('./chunk-C72S6TTV.cjs');
19
15
  require('./chunk-DWKQZ2SK.cjs');
20
16
  require('./chunk-4VAVYUZS.cjs');
17
+ require('./chunk-7YN22L2H.cjs');
18
+ require('./chunk-2DCNB7DF.cjs');
21
19
  require('./chunk-EYZYXJTJ.cjs');
22
20
  require('./chunk-YMFAJFQT.cjs');
23
- require('./chunk-XBSYYZIY.cjs');
21
+ require('./chunk-3QOSDDNI.cjs');
22
+ require('./chunk-GBHYAGX3.cjs');
23
+ require('./chunk-RPII3E6Z.cjs');
24
+ require('./chunk-6RPZADX3.cjs');
25
+ require('./chunk-QWBWGODS.cjs');
26
+ require('./chunk-NYUNU75A.cjs');
27
+ require('./chunk-VQY5W4YW.cjs');
28
+ require('./chunk-Y6OM7EV7.cjs');
29
+ require('./chunk-SVNDB62D.cjs');
24
30
  require('./chunk-R3HK6R4B.cjs');
31
+ require('./chunk-AEOZIDEB.cjs');
32
+ require('./chunk-L74VDN4A.cjs');
25
33
  require('./chunk-KUU2RNG6.cjs');
26
- require('./chunk-LKZJEL6E.cjs');
34
+ require('./chunk-Q27JY5RG.cjs');
27
35
  require('./chunk-QXD4MV2X.cjs');
28
- require('./chunk-NYUNU75A.cjs');
29
- require('./chunk-N3V2J5ZO.cjs');
30
- require('./chunk-SVNDB62D.cjs');
31
36
  require('./chunk-A2YMUCBT.cjs');
32
- require('./chunk-G2FUJNA2.cjs');
37
+ require('./chunk-SVXC36MU.cjs');
33
38
  require('./chunk-QBZJ7P2T.cjs');
39
+ require('./chunk-4IH4EL7M.cjs');
34
40
  require('./chunk-SUEGJ75D.cjs');
41
+ require('./chunk-S6JGLF3G.cjs');
35
42
  require('./chunk-RSJ3TWJQ.cjs');
36
43
  require('./chunk-YGXJGRFI.cjs');
37
44
  require('./chunk-NZYN7C3P.cjs');
38
- require('./chunk-V5KPWNYX.cjs');
39
- require('./chunk-6VIXXLMX.cjs');
45
+ require('./chunk-JMJBSACD.cjs');
40
46
  require('./chunk-GMMT7RVN.cjs');
47
+ require('./chunk-UNEFIWXI.cjs');
41
48
 
42
49
 
43
50
 
@@ -45,4 +52,4 @@ require('./chunk-GMMT7RVN.cjs');
45
52
 
46
53
 
47
54
 
48
- exports.DEFAULT_ROUTE_IDLE_MS = _chunkSN3YWBX7cjs.DEFAULT_ROUTE_IDLE_MS; exports.ProviderProxy = _chunkSN3YWBX7cjs.ProviderProxy; exports.ProviderProxyRouteMap = _chunkSN3YWBX7cjs.ProviderProxyRouteMap; exports.__resetProviderProxyForTests = _chunkSN3YWBX7cjs.__resetProviderProxyForTests; exports.extractRouteToken = _chunkSN3YWBX7cjs.extractRouteToken; exports.getProviderProxy = _chunkSN3YWBX7cjs.getProviderProxy;
55
+ exports.DEFAULT_ROUTE_IDLE_MS = _chunk2FMI2B6Vcjs.DEFAULT_ROUTE_IDLE_MS; exports.ProviderProxy = _chunk2FMI2B6Vcjs.ProviderProxy; exports.ProviderProxyRouteMap = _chunk2FMI2B6Vcjs.ProviderProxyRouteMap; exports.__resetProviderProxyForTests = _chunk2FMI2B6Vcjs.__resetProviderProxyForTests; exports.extractRouteToken = _chunk2FMI2B6Vcjs.extractRouteToken; exports.getProviderProxy = _chunk2FMI2B6Vcjs.getProviderProxy;
@@ -5,39 +5,46 @@ import {
5
5
  __resetProviderProxyForTests,
6
6
  extractRouteToken,
7
7
  getProviderProxy
8
- } from "./chunk-2FEVTJWG.js";
9
- import "./chunk-QOCNX236.js";
8
+ } from "./chunk-4DECIFU7.js";
10
9
  import "./chunk-VVEHS2LI.js";
11
10
  import "./chunk-46RLHI7D.js";
12
11
  import "./chunk-G2UTNSGU.js";
13
- import "./chunk-MZNPGW5Q.js";
14
12
  import "./chunk-DK4A7DLE.js";
15
- import "./chunk-O466Y272.js";
16
- import "./chunk-C7PSERMH.js";
17
- import "./chunk-5HTVET6E.js";
13
+ import "./chunk-MQNDWYPN.js";
18
14
  import "./chunk-Z7LUNECE.js";
19
15
  import "./chunk-ZJZAOKI7.js";
20
16
  import "./chunk-FTQ7IQUC.js";
17
+ import "./chunk-C7PSERMH.js";
18
+ import "./chunk-5HTVET6E.js";
21
19
  import "./chunk-7VU7V2E4.js";
22
20
  import "./chunk-ZLX3KGXX.js";
23
- import "./chunk-MNYKI4CI.js";
21
+ import "./chunk-CWM2ZDU5.js";
22
+ import "./chunk-MZNPGW5Q.js";
23
+ import "./chunk-XTEI64OU.js";
24
+ import "./chunk-XX6NQJMA.js";
25
+ import "./chunk-IAXWICZU.js";
26
+ import "./chunk-5ERIZW3D.js";
27
+ import "./chunk-5ENKBSWO.js";
28
+ import "./chunk-N5QFKSDO.js";
29
+ import "./chunk-AVYJ4YBN.js";
24
30
  import "./chunk-DRWHTIIZ.js";
31
+ import "./chunk-WNY4WMRF.js";
32
+ import "./chunk-TKJMZBAH.js";
25
33
  import "./chunk-JO5NLTLY.js";
26
- import "./chunk-PXUJF5HS.js";
34
+ import "./chunk-ZY6KU6P3.js";
27
35
  import "./chunk-JWC6APFQ.js";
28
- import "./chunk-5ERIZW3D.js";
29
- import "./chunk-74TMJA7Z.js";
30
- import "./chunk-AVYJ4YBN.js";
31
36
  import "./chunk-H5JUT3KV.js";
32
- import "./chunk-3MEACFK3.js";
37
+ import "./chunk-CZHZGRU7.js";
33
38
  import "./chunk-AQ5TNQB7.js";
39
+ import "./chunk-XEKD23J5.js";
34
40
  import "./chunk-5ZQBEOMD.js";
41
+ import "./chunk-BO4RFWBR.js";
35
42
  import "./chunk-Z7Y2NPHY.js";
36
43
  import "./chunk-S4WBV25P.js";
37
44
  import "./chunk-CDHS2QDC.js";
38
- import "./chunk-745DV5FL.js";
39
- import "./chunk-E3WHL7CO.js";
45
+ import "./chunk-Y7FO65VT.js";
40
46
  import "./chunk-FMOBD2OQ.js";
47
+ import "./chunk-HUZZZ3JL.js";
41
48
  export {
42
49
  DEFAULT_ROUTE_IDLE_MS,
43
50
  ProviderProxy,
@@ -1,6 +1,6 @@
1
1
  import { ProviderConfigSource } from './ports/provider-config-source.js';
2
2
  import { IngressFormat, RouteContext } from './provider-proxy/types.js';
3
- import { OutboundEndpoint, EndpointRoutingConfig, RequestRole } from './outbound-api/types.js';
3
+ import { q as OutboundEndpoint, P as ModelRef, b as EndpointRoutingConfig, R as RequestRole } from './types-6OUY_xfA.js';
4
4
  import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
5
5
 
6
6
  /**
@@ -39,21 +39,26 @@ declare function endpointSupportsSubscription(endpoint: OutboundEndpoint): boole
39
39
 
40
40
  /**
41
41
  * routeResolver — turn an endpoint's `EndpointRoutingConfig` + the detected
42
- * request role into a `RouteContext` for the shared `provider-proxy` dispatch
43
- * (`outbound-api-server`, design D2).
42
+ * request KIND (messages/responses) or ROLE (chat/gemini) into a `RouteContext`
43
+ * for the shared `provider-proxy` dispatch (`outbound-api-server`, design D1/D2).
44
44
  *
45
45
  * Steps:
46
- * 1. Pick the model for the role (vision default fallback when `visionModel`
47
- * is unset; vision is optional).
46
+ * 1. Pick the model ref: by model KIND for the kind-mapped endpoints
47
+ * (`messages`/`responses`) via `modelMap[detectModelKind(...)]` with a
48
+ * serving-owned fallback (messages: first configured of `sonnet → opus →
49
+ * haiku → fable`; responses: `codex`); by ROLE (default/background) for the
50
+ * role-based endpoints (`chat`/`gemini`). Vision was removed.
48
51
  * 2. Parse the chosen `"providerId,modelId"` ref.
49
52
  * 3. Gate by `useSubscription`: OFF → only BYO-key providers are eligible
50
53
  * (subscription-backed providers excluded); ON → subscription-backed
51
54
  * providers are eligible.
52
55
  * 4. Resolve the provider (BYO via the `ProviderConfigSource`; subscription via the
53
56
  * subscription registry) and build the `RouteContext` exactly as the
54
- * internal callers do.
55
- * 5. Return a clear `503`-style error when the role's required model is unset,
56
- * the provider is unavailable, or the subscription gate excludes it.
57
+ * internal callers do. For kind-mapped endpoints STAMP `route.requestedModel`
58
+ * with the client's ORIGINAL requested id so the response `model` can be
59
+ * passed through unchanged (the resident proxy leaves this unset).
60
+ * 5. Return a clear `503`-style error when the required model is unset, the
61
+ * provider is unavailable, or the subscription gate excludes it.
57
62
  *
58
63
  * @module outbound-api/routeResolver
59
64
  */
@@ -76,13 +81,34 @@ declare function parseModelRef(ref: string | undefined): {
76
81
  providerId: string;
77
82
  modelId: string;
78
83
  } | null;
84
+ /**
85
+ * Pick the model ref for the LIST-mapped `chat` endpoint: the client requests
86
+ * one of the configured refs' modelIds directly (the same names `GET /v1/models`
87
+ * advertises). Exact modelId match first, then case-insensitive. No requested
88
+ * model, or a model not in the list → `undefined` (per-request 404).
89
+ */
90
+ declare function pickModelRefFromList(models: ModelRef[] | undefined, requestedModel: string | undefined): ModelRef | undefined;
79
91
  /** Resolve a route for one authenticated outbound request. */
80
92
  declare function resolveRoute(args: {
81
93
  config: EndpointRoutingConfig;
82
- role: RequestRole;
94
+ /** Role for the role-based endpoints (`chat`/`gemini`); ignored (optional) for kind-mapped ones. */
95
+ role?: RequestRole;
83
96
  ingressFormat: IngressFormat;
84
97
  llmConfig: ProviderConfigSource;
85
98
  sessionId?: string | null;
99
+ /**
100
+ * The client's ORIGINAL requested model id. For kind-mapped endpoints it
101
+ * selects the model KIND AND is stamped onto `route.requestedModel` so the
102
+ * response `model` passes through unchanged. Ignored for role-based endpoints.
103
+ */
104
+ requestedModel?: string;
105
+ /**
106
+ * The verified named-key id (`verified.id`). Stamped onto EVERY outbound
107
+ * endpoint's route (not gated on kind — attribution is orthogonal to the
108
+ * passthrough-rewrite gate), BYO + subscription. Absent for the resident
109
+ * proxy's internal route minting, so internal usage records `apiKeyId: null`.
110
+ */
111
+ apiKeyId?: string;
86
112
  }): Promise<RouteResolveResult>;
87
113
 
88
- export { type RouteResolveError as R, SUBSCRIPTION_PROVIDER_IDS as S, type RouteResolveResult as a, endpointSupportsSubscription as e, isSubscriptionProviderId as i, parseModelRef as p, resolveRoute as r };
114
+ export { type RouteResolveError as R, SUBSCRIPTION_PROVIDER_IDS as S, pickModelRefFromList as a, type RouteResolveResult as b, endpointSupportsSubscription as e, isSubscriptionProviderId as i, parseModelRef as p, resolveRoute as r };