@omnicross/core 0.1.2 → 0.1.4
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.
- package/LICENSE +21 -21
- package/NOTICE +57 -57
- package/README.md +15 -15
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -1
- package/dist/chunk-3QFXFCHG.js +33 -0
- package/dist/chunk-4IH4EL7M.cjs +9 -0
- package/dist/chunk-4YINUUKQ.cjs +33 -0
- package/dist/chunk-5ENKBSWO.js +311 -0
- package/dist/chunk-6RPZADX3.cjs +92 -0
- package/dist/chunk-7Y47UCF2.js +142 -0
- package/dist/chunk-AEOZIDEB.cjs +32 -0
- package/dist/chunk-APYG5QD7.cjs +50 -0
- package/dist/{chunk-MNYKI4CI.js → chunk-BPKCU575.js} +29 -0
- package/dist/{chunk-SN3YWBX7.cjs → chunk-DKPXN34V.cjs} +2108 -538
- package/dist/{chunk-4NBS6KPV.cjs → chunk-DQ5VAYZ6.cjs} +7 -8
- package/dist/chunk-E3UCVHLP.cjs +142 -0
- package/dist/chunk-FCR77GYM.cjs +33 -0
- package/dist/{chunk-74TMJA7Z.js → chunk-HRRYG2AX.js} +8 -4
- package/dist/chunk-HUZZZ3JL.js +32 -0
- package/dist/{chunk-KUU2RNG6.cjs → chunk-HYN75H6G.cjs} +3 -0
- package/dist/{chunk-QOCNX236.js → chunk-IAXWICZU.js} +24 -1
- package/dist/{chunk-JO5NLTLY.js → chunk-IK3KE3AU.js} +3 -0
- package/dist/{chunk-V5KPWNYX.cjs → chunk-JMJBSACD.cjs} +3 -3
- package/dist/chunk-K5NM7VAH.js +33 -0
- package/dist/{chunk-N3V2J5ZO.cjs → chunk-KFI44N2R.cjs} +8 -4
- package/dist/chunk-L74VDN4A.cjs +32 -0
- package/dist/chunk-OCEUVQHW.cjs +112 -0
- package/dist/chunk-OE6TDIWW.js +22 -0
- package/dist/chunk-OZFM4X3S.js +18 -0
- package/dist/{chunk-LKZJEL6E.cjs → chunk-Q27JY5RG.cjs} +6 -4
- package/dist/{chunk-SPVWWUHX.cjs → chunk-QWBWGODS.cjs} +24 -1
- package/dist/{chunk-2FEVTJWG.js → chunk-QYTT6GE3.js} +1929 -359
- package/dist/{chunk-UYPEN5XE.cjs → chunk-RGTR7CIO.cjs} +6 -6
- package/dist/chunk-RPII3E6Z.cjs +145 -0
- package/dist/{chunk-XBSYYZIY.cjs → chunk-SNYBEXLB.cjs} +31 -2
- package/dist/{chunk-2DCNB7DF.cjs → chunk-SU2GCLAC.cjs} +30 -10
- package/dist/{chunk-5HTVET6E.js → chunk-TIER4SUC.js} +24 -4
- package/dist/chunk-TKJMZBAH.js +32 -0
- package/dist/{chunk-ZSVQT3PW.js → chunk-UBWEBKRC.js} +5 -6
- package/dist/chunk-UHGVBFU3.js +385 -0
- package/dist/chunk-UIBD2YY5.cjs +22 -0
- package/dist/chunk-UNEFIWXI.cjs +32 -0
- package/dist/chunk-VACWOIRE.cjs +385 -0
- package/dist/{chunk-O466Y272.js → chunk-VPBAUQ2M.js} +7 -7
- package/dist/chunk-VQY5W4YW.cjs +311 -0
- package/dist/chunk-WLYIIEAF.js +50 -0
- package/dist/chunk-WNY4WMRF.js +32 -0
- package/dist/chunk-XEKD23J5.js +9 -0
- package/dist/chunk-XK5CIRMQ.js +112 -0
- package/dist/chunk-XSVNC2UD.cjs +18 -0
- package/dist/chunk-XTEI64OU.js +145 -0
- package/dist/chunk-XX6NQJMA.js +92 -0
- package/dist/{chunk-745DV5FL.js → chunk-Y7FO65VT.js} +3 -3
- package/dist/{chunk-PXUJF5HS.js → chunk-ZY6KU6P3.js} +4 -2
- package/dist/completion/CompletionService.cjs +30 -17
- package/dist/completion/CompletionService.js +29 -16
- package/dist/completion/NativeSearchInjector.cjs +3 -3
- package/dist/completion/NativeSearchInjector.js +2 -2
- package/dist/completion/openrouter-headers.cjs +3 -6
- package/dist/completion/openrouter-headers.d.cts +9 -12
- package/dist/completion/openrouter-headers.d.ts +9 -12
- package/dist/completion/openrouter-headers.js +2 -5
- package/dist/completion/openrouter-models.cjs +4 -3
- package/dist/completion/openrouter-models.js +2 -1
- package/dist/completion.cjs +30 -17
- package/dist/completion.js +29 -16
- package/dist/index.cjs +151 -20
- package/dist/index.d.cts +44 -10
- package/dist/index.d.ts +44 -10
- package/dist/index.js +160 -29
- package/dist/keyPolicy-Cp0FntZl.d.cts +90 -0
- package/dist/keyPolicy-Cp0FntZl.d.ts +90 -0
- package/dist/outbound-api/auditCapture.cjs +9 -0
- package/dist/outbound-api/auditCapture.d.cts +52 -0
- package/dist/outbound-api/auditCapture.d.ts +52 -0
- package/dist/outbound-api/auditCapture.js +9 -0
- package/dist/outbound-api/auditRedact.cjs +8 -0
- package/dist/outbound-api/auditRedact.d.cts +30 -0
- package/dist/outbound-api/auditRedact.d.ts +30 -0
- package/dist/outbound-api/auditRedact.js +8 -0
- package/dist/outbound-api/billingCapture.cjs +8 -0
- package/dist/outbound-api/billingCapture.d.cts +61 -0
- package/dist/outbound-api/billingCapture.d.ts +61 -0
- package/dist/outbound-api/billingCapture.js +8 -0
- package/dist/outbound-api/quotaWarn.cjs +12 -0
- package/dist/outbound-api/quotaWarn.d.cts +43 -0
- package/dist/outbound-api/quotaWarn.d.ts +43 -0
- package/dist/outbound-api/quotaWarn.js +12 -0
- package/dist/outbound-api/routeResolver.cjs +5 -2
- package/dist/outbound-api/routeResolver.d.cts +9 -2
- package/dist/outbound-api/routeResolver.d.ts +9 -2
- package/dist/outbound-api/routeResolver.js +4 -1
- package/dist/outbound-api/types.cjs +6 -1
- package/dist/outbound-api/types.d.cts +12 -144
- package/dist/outbound-api/types.d.ts +12 -144
- package/dist/outbound-api/types.js +6 -0
- package/dist/outbound-api.cjs +144 -17
- package/dist/outbound-api.d.cts +655 -25
- package/dist/outbound-api.d.ts +655 -25
- package/dist/outbound-api.js +148 -21
- package/dist/pipeline/AuthSource.d.cts +29 -1
- package/dist/pipeline/AuthSource.d.ts +29 -1
- package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
- package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.cjs +22 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +235 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +235 -0
- package/dist/pipeline/SubscriptionAccountHealth.js +22 -0
- package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
- package/dist/pipeline/SubscriptionAuthSource.d.cts +3 -2
- package/dist/pipeline/SubscriptionAuthSource.d.ts +3 -2
- package/dist/pipeline/SubscriptionAuthSource.js +1 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +30 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +30 -1
- package/dist/pipeline/auditSink.cjs +14 -0
- package/dist/pipeline/auditSink.d.cts +48 -0
- package/dist/pipeline/auditSink.d.ts +48 -0
- package/dist/pipeline/auditSink.js +14 -0
- package/dist/pipeline/auditUsageStash.cjs +10 -0
- package/dist/pipeline/auditUsageStash.d.cts +37 -0
- package/dist/pipeline/auditUsageStash.d.ts +37 -0
- package/dist/pipeline/auditUsageStash.js +10 -0
- package/dist/pipeline/billingEmit.cjs +14 -0
- package/dist/pipeline/billingEmit.d.cts +49 -0
- package/dist/pipeline/billingEmit.d.ts +49 -0
- package/dist/pipeline/billingEmit.js +14 -0
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/upstreamFetch.cjs +14 -0
- package/dist/pipeline/upstreamFetch.d.cts +83 -0
- package/dist/pipeline/upstreamFetch.d.ts +83 -0
- package/dist/pipeline/upstreamFetch.js +14 -0
- package/dist/pipeline/webhookEmit.cjs +10 -0
- package/dist/pipeline/webhookEmit.d.cts +36 -0
- package/dist/pipeline/webhookEmit.d.ts +36 -0
- package/dist/pipeline/webhookEmit.js +10 -0
- package/dist/ports/usage-event-store.d.cts +26 -1
- package/dist/ports/usage-event-store.d.ts +26 -1
- package/dist/ports.d.cts +8 -1
- package/dist/ports.d.ts +8 -1
- package/dist/provider-proxy/ProviderProxy.cjs +30 -17
- package/dist/provider-proxy/ProviderProxy.js +29 -16
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.cjs +15 -0
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.cts +121 -0
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.ts +121 -0
- package/dist/provider-proxy/identity/SubscriptionIdentityStore.js +15 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.cjs +20 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.d.cts +89 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.d.ts +89 -0
- package/dist/provider-proxy/identity/fingerprintHeaders.js +20 -0
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +30 -17
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +11 -2
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +11 -2
- package/dist/provider-proxy/ingress/providerProxyShared.js +29 -16
- package/dist/provider-proxy/matchText.cjs +4 -2
- package/dist/provider-proxy/matchText.d.cts +14 -1
- package/dist/provider-proxy/matchText.d.ts +14 -1
- package/dist/provider-proxy/matchText.js +3 -1
- package/dist/provider-proxy/types.d.cts +30 -0
- package/dist/provider-proxy/types.d.ts +30 -0
- package/dist/provider-proxy.cjs +30 -17
- package/dist/provider-proxy.js +29 -16
- package/dist/{routeResolver-HE-ZO0fO.d.ts → routeResolver-C4T7yClx.d.ts} +36 -10
- package/dist/{routeResolver-BrbK6ja9.d.cts → routeResolver-CB3tvJKy.d.cts} +36 -10
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
- package/dist/transformer/transformers.cjs +7 -7
- package/dist/transformer/transformers.js +8 -8
- package/dist/transformer.cjs +9 -9
- package/dist/transformer.js +8 -8
- package/dist/types-B8Arpxn0.d.cts +754 -0
- package/dist/types-lgPYQuZS.d.ts +754 -0
- package/dist/usage/usage-recorder.cjs +3 -2
- package/dist/usage/usage-recorder.d.cts +19 -1
- package/dist/usage/usage-recorder.d.ts +19 -1
- package/dist/usage/usage-recorder.js +2 -1
- package/dist/usage.cjs +3 -2
- package/dist/usage.js +2 -1
- package/package.json +64 -62
- package/dist/chunk-3MEACFK3.js +0 -193
- package/dist/chunk-6VIXXLMX.cjs +0 -14
- package/dist/chunk-E3WHL7CO.js +0 -14
- package/dist/chunk-G2FUJNA2.cjs +0 -193
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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,52 @@ import {
|
|
|
7
7
|
relayResponse,
|
|
8
8
|
resolvePoolBoundKey,
|
|
9
9
|
writeError
|
|
10
|
-
} from "../../chunk-
|
|
11
|
-
import "../../chunk-QOCNX236.js";
|
|
10
|
+
} from "../../chunk-QYTT6GE3.js";
|
|
12
11
|
import "../../chunk-VVEHS2LI.js";
|
|
13
12
|
import "../../chunk-46RLHI7D.js";
|
|
14
|
-
import "../../chunk-G2UTNSGU.js";
|
|
15
|
-
import "../../chunk-MZNPGW5Q.js";
|
|
16
13
|
import "../../chunk-DK4A7DLE.js";
|
|
17
|
-
import "../../chunk-
|
|
18
|
-
import "../../chunk-C7PSERMH.js";
|
|
19
|
-
import "../../chunk-5HTVET6E.js";
|
|
20
|
-
import "../../chunk-Z7LUNECE.js";
|
|
14
|
+
import "../../chunk-VPBAUQ2M.js";
|
|
21
15
|
import "../../chunk-ZJZAOKI7.js";
|
|
22
16
|
import "../../chunk-FTQ7IQUC.js";
|
|
17
|
+
import "../../chunk-C7PSERMH.js";
|
|
18
|
+
import "../../chunk-TIER4SUC.js";
|
|
19
|
+
import "../../chunk-Z7LUNECE.js";
|
|
23
20
|
import "../../chunk-7VU7V2E4.js";
|
|
24
21
|
import "../../chunk-ZLX3KGXX.js";
|
|
25
|
-
import "../../chunk-
|
|
22
|
+
import "../../chunk-BPKCU575.js";
|
|
23
|
+
import "../../chunk-G2UTNSGU.js";
|
|
24
|
+
import "../../chunk-MZNPGW5Q.js";
|
|
25
|
+
import "../../chunk-XTEI64OU.js";
|
|
26
|
+
import "../../chunk-XX6NQJMA.js";
|
|
27
|
+
import "../../chunk-IAXWICZU.js";
|
|
28
|
+
import "../../chunk-OE6TDIWW.js";
|
|
26
29
|
import "../../chunk-DRWHTIIZ.js";
|
|
27
|
-
import "../../chunk-
|
|
28
|
-
import "../../chunk-
|
|
30
|
+
import "../../chunk-IK3KE3AU.js";
|
|
31
|
+
import "../../chunk-ZY6KU6P3.js";
|
|
29
32
|
import "../../chunk-JWC6APFQ.js";
|
|
30
33
|
import "../../chunk-5ERIZW3D.js";
|
|
31
|
-
import "../../chunk-
|
|
34
|
+
import "../../chunk-5ENKBSWO.js";
|
|
35
|
+
import "../../chunk-HRRYG2AX.js";
|
|
32
36
|
import "../../chunk-AVYJ4YBN.js";
|
|
33
|
-
import "../../chunk-
|
|
34
|
-
import "../../chunk-
|
|
37
|
+
import "../../chunk-WLYIIEAF.js";
|
|
38
|
+
import "../../chunk-TKJMZBAH.js";
|
|
39
|
+
import "../../chunk-3QFXFCHG.js";
|
|
40
|
+
import "../../chunk-UHGVBFU3.js";
|
|
35
41
|
import "../../chunk-AQ5TNQB7.js";
|
|
42
|
+
import "../../chunk-XEKD23J5.js";
|
|
43
|
+
import "../../chunk-H5JUT3KV.js";
|
|
44
|
+
import "../../chunk-7Y47UCF2.js";
|
|
45
|
+
import "../../chunk-K5NM7VAH.js";
|
|
46
|
+
import "../../chunk-WNY4WMRF.js";
|
|
47
|
+
import "../../chunk-OZFM4X3S.js";
|
|
36
48
|
import "../../chunk-5ZQBEOMD.js";
|
|
37
49
|
import "../../chunk-Z7Y2NPHY.js";
|
|
38
50
|
import "../../chunk-S4WBV25P.js";
|
|
51
|
+
import "../../chunk-XK5CIRMQ.js";
|
|
39
52
|
import "../../chunk-CDHS2QDC.js";
|
|
40
|
-
import "../../chunk-
|
|
41
|
-
import "../../chunk-E3WHL7CO.js";
|
|
53
|
+
import "../../chunk-Y7FO65VT.js";
|
|
42
54
|
import "../../chunk-FMOBD2OQ.js";
|
|
55
|
+
import "../../chunk-HUZZZ3JL.js";
|
|
43
56
|
export {
|
|
44
57
|
getAnthropicEndpointTransformer,
|
|
45
58
|
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
|
-
|
|
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-
|
|
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). */
|
|
@@ -318,6 +335,13 @@ interface RouteContext {
|
|
|
318
335
|
* `anthropicSdkHints.subscriptionProfile` and ignores this field.
|
|
319
336
|
*/
|
|
320
337
|
readonly subscriptionProfile?: SubscriptionAuthProfile | null;
|
|
338
|
+
/**
|
|
339
|
+
* Per-request preferred subscription account id (provider/subscription
|
|
340
|
+
* duality). Stamped by the outbound `resolveRoute` from
|
|
341
|
+
* `EndpointRoutingConfig.boundAccountId`; the account picker prefers it when
|
|
342
|
+
* schedulable (else falls back to the pool). Undefined ⇒ pool auto-schedule.
|
|
343
|
+
*/
|
|
344
|
+
readonly preferredAccountId?: string;
|
|
321
345
|
/**
|
|
322
346
|
* OPAQUE per-account subscription config (opencodego-only). Populated by the
|
|
323
347
|
* route resolver from the subscription registry's `getOpenCodeGoConfig()`
|
|
@@ -406,6 +430,12 @@ interface UsageRecordImportInput {
|
|
|
406
430
|
rawUsage?: unknown;
|
|
407
431
|
runId?: string | null;
|
|
408
432
|
eventId?: string | null;
|
|
433
|
+
/**
|
|
434
|
+
* OPTIONAL per-request audit correlation key (request-audit-log) — the outbound
|
|
435
|
+
* relay taps set this to the request's `http.ServerResponse` so the recorder can
|
|
436
|
+
* stash this request's tokens/cost for the audit capture. Opaque; unset ⇒ no-op.
|
|
437
|
+
*/
|
|
438
|
+
auditResponse?: object;
|
|
409
439
|
}
|
|
410
440
|
|
|
411
441
|
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). */
|
|
@@ -318,6 +335,13 @@ interface RouteContext {
|
|
|
318
335
|
* `anthropicSdkHints.subscriptionProfile` and ignores this field.
|
|
319
336
|
*/
|
|
320
337
|
readonly subscriptionProfile?: SubscriptionAuthProfile | null;
|
|
338
|
+
/**
|
|
339
|
+
* Per-request preferred subscription account id (provider/subscription
|
|
340
|
+
* duality). Stamped by the outbound `resolveRoute` from
|
|
341
|
+
* `EndpointRoutingConfig.boundAccountId`; the account picker prefers it when
|
|
342
|
+
* schedulable (else falls back to the pool). Undefined ⇒ pool auto-schedule.
|
|
343
|
+
*/
|
|
344
|
+
readonly preferredAccountId?: string;
|
|
321
345
|
/**
|
|
322
346
|
* OPAQUE per-account subscription config (opencodego-only). Populated by the
|
|
323
347
|
* route resolver from the subscription registry's `getOpenCodeGoConfig()`
|
|
@@ -406,6 +430,12 @@ interface UsageRecordImportInput {
|
|
|
406
430
|
rawUsage?: unknown;
|
|
407
431
|
runId?: string | null;
|
|
408
432
|
eventId?: string | null;
|
|
433
|
+
/**
|
|
434
|
+
* OPTIONAL per-request audit correlation key (request-audit-log) — the outbound
|
|
435
|
+
* relay taps set this to the request's `http.ServerResponse` so the recorder can
|
|
436
|
+
* stash this request's tokens/cost for the audit capture. Opaque; unset ⇒ no-op.
|
|
437
|
+
*/
|
|
438
|
+
auditResponse?: object;
|
|
409
439
|
}
|
|
410
440
|
|
|
411
441
|
export type { AnthropicIngressHandler, AnthropicIngressHandlerFactory, AnthropicRouteHandlerParams, AnthropicSdkHints, ExtendedContextHint, IngressFormat, ProviderProxyDeps, ProxyAttribution, RetryCallback, RouteAuthMode, RouteContext, StreamEventCallback, SubscriptionDispatchProfile, SubscriptionRequestSummary, TargetProviderFormat, UsageRecordImportInput, UsageRecorderImport };
|
package/dist/provider-proxy.cjs
CHANGED
|
@@ -5,39 +5,52 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('./chunk-SPVWWUHX.cjs');
|
|
8
|
+
var _chunkDKPXN34Vcjs = require('./chunk-DKPXN34V.cjs');
|
|
10
9
|
require('./chunk-HQP3K7PU.cjs');
|
|
11
10
|
require('./chunk-FZ46M34D.cjs');
|
|
12
|
-
require('./chunk-46ZIFWYG.cjs');
|
|
13
|
-
require('./chunk-GBHYAGX3.cjs');
|
|
14
11
|
require('./chunk-3OPYJG76.cjs');
|
|
15
|
-
require('./chunk-
|
|
16
|
-
require('./chunk-7YN22L2H.cjs');
|
|
17
|
-
require('./chunk-2DCNB7DF.cjs');
|
|
18
|
-
require('./chunk-C72S6TTV.cjs');
|
|
12
|
+
require('./chunk-RGTR7CIO.cjs');
|
|
19
13
|
require('./chunk-DWKQZ2SK.cjs');
|
|
20
14
|
require('./chunk-4VAVYUZS.cjs');
|
|
15
|
+
require('./chunk-7YN22L2H.cjs');
|
|
16
|
+
require('./chunk-SU2GCLAC.cjs');
|
|
17
|
+
require('./chunk-C72S6TTV.cjs');
|
|
21
18
|
require('./chunk-EYZYXJTJ.cjs');
|
|
22
19
|
require('./chunk-YMFAJFQT.cjs');
|
|
23
|
-
require('./chunk-
|
|
20
|
+
require('./chunk-SNYBEXLB.cjs');
|
|
21
|
+
require('./chunk-46ZIFWYG.cjs');
|
|
22
|
+
require('./chunk-GBHYAGX3.cjs');
|
|
23
|
+
require('./chunk-RPII3E6Z.cjs');
|
|
24
|
+
require('./chunk-6RPZADX3.cjs');
|
|
25
|
+
require('./chunk-QWBWGODS.cjs');
|
|
26
|
+
require('./chunk-UIBD2YY5.cjs');
|
|
24
27
|
require('./chunk-R3HK6R4B.cjs');
|
|
25
|
-
require('./chunk-
|
|
26
|
-
require('./chunk-
|
|
28
|
+
require('./chunk-HYN75H6G.cjs');
|
|
29
|
+
require('./chunk-Q27JY5RG.cjs');
|
|
27
30
|
require('./chunk-QXD4MV2X.cjs');
|
|
28
31
|
require('./chunk-NYUNU75A.cjs');
|
|
29
|
-
require('./chunk-
|
|
32
|
+
require('./chunk-VQY5W4YW.cjs');
|
|
33
|
+
require('./chunk-KFI44N2R.cjs');
|
|
30
34
|
require('./chunk-SVNDB62D.cjs');
|
|
31
|
-
require('./chunk-
|
|
32
|
-
require('./chunk-
|
|
35
|
+
require('./chunk-APYG5QD7.cjs');
|
|
36
|
+
require('./chunk-L74VDN4A.cjs');
|
|
37
|
+
require('./chunk-4YINUUKQ.cjs');
|
|
38
|
+
require('./chunk-VACWOIRE.cjs');
|
|
33
39
|
require('./chunk-QBZJ7P2T.cjs');
|
|
40
|
+
require('./chunk-4IH4EL7M.cjs');
|
|
41
|
+
require('./chunk-A2YMUCBT.cjs');
|
|
42
|
+
require('./chunk-E3UCVHLP.cjs');
|
|
43
|
+
require('./chunk-FCR77GYM.cjs');
|
|
44
|
+
require('./chunk-AEOZIDEB.cjs');
|
|
45
|
+
require('./chunk-XSVNC2UD.cjs');
|
|
34
46
|
require('./chunk-SUEGJ75D.cjs');
|
|
35
47
|
require('./chunk-RSJ3TWJQ.cjs');
|
|
36
48
|
require('./chunk-YGXJGRFI.cjs');
|
|
49
|
+
require('./chunk-OCEUVQHW.cjs');
|
|
37
50
|
require('./chunk-NZYN7C3P.cjs');
|
|
38
|
-
require('./chunk-
|
|
39
|
-
require('./chunk-6VIXXLMX.cjs');
|
|
51
|
+
require('./chunk-JMJBSACD.cjs');
|
|
40
52
|
require('./chunk-GMMT7RVN.cjs');
|
|
53
|
+
require('./chunk-UNEFIWXI.cjs');
|
|
41
54
|
|
|
42
55
|
|
|
43
56
|
|
|
@@ -45,4 +58,4 @@ require('./chunk-GMMT7RVN.cjs');
|
|
|
45
58
|
|
|
46
59
|
|
|
47
60
|
|
|
48
|
-
exports.DEFAULT_ROUTE_IDLE_MS =
|
|
61
|
+
exports.DEFAULT_ROUTE_IDLE_MS = _chunkDKPXN34Vcjs.DEFAULT_ROUTE_IDLE_MS; exports.ProviderProxy = _chunkDKPXN34Vcjs.ProviderProxy; exports.ProviderProxyRouteMap = _chunkDKPXN34Vcjs.ProviderProxyRouteMap; exports.__resetProviderProxyForTests = _chunkDKPXN34Vcjs.__resetProviderProxyForTests; exports.extractRouteToken = _chunkDKPXN34Vcjs.extractRouteToken; exports.getProviderProxy = _chunkDKPXN34Vcjs.getProviderProxy;
|
package/dist/provider-proxy.js
CHANGED
|
@@ -5,39 +5,52 @@ import {
|
|
|
5
5
|
__resetProviderProxyForTests,
|
|
6
6
|
extractRouteToken,
|
|
7
7
|
getProviderProxy
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-QOCNX236.js";
|
|
8
|
+
} from "./chunk-QYTT6GE3.js";
|
|
10
9
|
import "./chunk-VVEHS2LI.js";
|
|
11
10
|
import "./chunk-46RLHI7D.js";
|
|
12
|
-
import "./chunk-G2UTNSGU.js";
|
|
13
|
-
import "./chunk-MZNPGW5Q.js";
|
|
14
11
|
import "./chunk-DK4A7DLE.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-C7PSERMH.js";
|
|
17
|
-
import "./chunk-5HTVET6E.js";
|
|
18
|
-
import "./chunk-Z7LUNECE.js";
|
|
12
|
+
import "./chunk-VPBAUQ2M.js";
|
|
19
13
|
import "./chunk-ZJZAOKI7.js";
|
|
20
14
|
import "./chunk-FTQ7IQUC.js";
|
|
15
|
+
import "./chunk-C7PSERMH.js";
|
|
16
|
+
import "./chunk-TIER4SUC.js";
|
|
17
|
+
import "./chunk-Z7LUNECE.js";
|
|
21
18
|
import "./chunk-7VU7V2E4.js";
|
|
22
19
|
import "./chunk-ZLX3KGXX.js";
|
|
23
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-BPKCU575.js";
|
|
21
|
+
import "./chunk-G2UTNSGU.js";
|
|
22
|
+
import "./chunk-MZNPGW5Q.js";
|
|
23
|
+
import "./chunk-XTEI64OU.js";
|
|
24
|
+
import "./chunk-XX6NQJMA.js";
|
|
25
|
+
import "./chunk-IAXWICZU.js";
|
|
26
|
+
import "./chunk-OE6TDIWW.js";
|
|
24
27
|
import "./chunk-DRWHTIIZ.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-IK3KE3AU.js";
|
|
29
|
+
import "./chunk-ZY6KU6P3.js";
|
|
27
30
|
import "./chunk-JWC6APFQ.js";
|
|
28
31
|
import "./chunk-5ERIZW3D.js";
|
|
29
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-5ENKBSWO.js";
|
|
33
|
+
import "./chunk-HRRYG2AX.js";
|
|
30
34
|
import "./chunk-AVYJ4YBN.js";
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-WLYIIEAF.js";
|
|
36
|
+
import "./chunk-TKJMZBAH.js";
|
|
37
|
+
import "./chunk-3QFXFCHG.js";
|
|
38
|
+
import "./chunk-UHGVBFU3.js";
|
|
33
39
|
import "./chunk-AQ5TNQB7.js";
|
|
40
|
+
import "./chunk-XEKD23J5.js";
|
|
41
|
+
import "./chunk-H5JUT3KV.js";
|
|
42
|
+
import "./chunk-7Y47UCF2.js";
|
|
43
|
+
import "./chunk-K5NM7VAH.js";
|
|
44
|
+
import "./chunk-WNY4WMRF.js";
|
|
45
|
+
import "./chunk-OZFM4X3S.js";
|
|
34
46
|
import "./chunk-5ZQBEOMD.js";
|
|
35
47
|
import "./chunk-Z7Y2NPHY.js";
|
|
36
48
|
import "./chunk-S4WBV25P.js";
|
|
49
|
+
import "./chunk-XK5CIRMQ.js";
|
|
37
50
|
import "./chunk-CDHS2QDC.js";
|
|
38
|
-
import "./chunk-
|
|
39
|
-
import "./chunk-E3WHL7CO.js";
|
|
51
|
+
import "./chunk-Y7FO65VT.js";
|
|
40
52
|
import "./chunk-FMOBD2OQ.js";
|
|
53
|
+
import "./chunk-HUZZZ3JL.js";
|
|
41
54
|
export {
|
|
42
55
|
DEFAULT_ROUTE_IDLE_MS,
|
|
43
56
|
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 './
|
|
3
|
+
import { m as OutboundEndpoint, G as ModelRef, b as EndpointRoutingConfig, R as RequestRole } from './types-lgPYQuZS.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
|
|
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
|
|
47
|
-
*
|
|
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
|
-
*
|
|
56
|
-
*
|
|
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
|
|
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
|
|
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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProviderConfigSource } from './ports/provider-config-source.cjs';
|
|
2
2
|
import { IngressFormat, RouteContext } from './provider-proxy/types.cjs';
|
|
3
|
-
import { OutboundEndpoint, EndpointRoutingConfig, RequestRole } from './
|
|
3
|
+
import { m as OutboundEndpoint, G as ModelRef, b as EndpointRoutingConfig, R as RequestRole } from './types-B8Arpxn0.cjs';
|
|
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
|
|
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
|
|
47
|
-
*
|
|
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
|
-
*
|
|
56
|
-
*
|
|
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
|
|
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
|
|
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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkSU2GCLACcjs = require('../../chunk-SU2GCLAC.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
exports.OpenAIResponseTransformer =
|
|
6
|
+
exports.OpenAIResponseTransformer = _chunkSU2GCLACcjs.OpenAIResponseTransformer;
|