@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.
- package/dist/ApiConverter.cjs +2 -2
- package/dist/ApiConverter.js +1 -1
- package/dist/{CompletionService-DdWaAxq0.d.ts → CompletionService-C3BX0Ovy.d.ts} +4 -3
- package/dist/{CompletionService-D3a47vdU.d.cts → CompletionService-kNA17cfI.d.cts} +4 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +8 -6
- package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -4
- package/dist/{chunk-3Z5BQZFM.cjs → chunk-235MXAGX.cjs} +3 -1
- package/dist/{chunk-HRRYG2AX.js → chunk-23S5OPIO.js} +10 -1
- package/dist/chunk-25GXJCEZ.cjs +40 -0
- package/dist/chunk-2E42SAW3.cjs +323 -0
- package/dist/chunk-2JYRIADS.js +40 -0
- package/dist/chunk-2Z4XM3H5.cjs +44 -0
- package/dist/{chunk-BODMAL6G.js → chunk-32O35CIF.js} +271 -91
- package/dist/chunk-3SCOLIPT.cjs +63 -0
- package/dist/{chunk-SYQF7OIR.js → chunk-3WD4HTR2.js} +2 -0
- package/dist/{chunk-CGKLE6IW.cjs → chunk-4BB343BI.cjs} +1489 -520
- package/dist/{chunk-VACWOIRE.cjs → chunk-4VZX5F4T.cjs} +39 -15
- package/dist/{chunk-5ZQBEOMD.js → chunk-5NJLQ6T6.js} +46 -12
- package/dist/chunk-5RSZYQJH.cjs +62 -0
- package/dist/chunk-6QQG7YG3.cjs +153 -0
- package/dist/{chunk-IFXJ2BG7.js → chunk-7C7DET6S.js} +51 -6
- package/dist/{chunk-IK3KE3AU.js → chunk-DE2SRBFZ.js} +1 -1
- package/dist/{chunk-FH2P4OCD.js → chunk-E3COOKUP.js} +1240 -271
- package/dist/{chunk-UHGVBFU3.js → chunk-EBLFCNPY.js} +38 -14
- package/dist/chunk-FU7EAR73.js +62 -0
- package/dist/chunk-FXR6N3SR.js +323 -0
- package/dist/{chunk-SUEGJ75D.cjs → chunk-GDIXXKF2.cjs} +46 -12
- package/dist/chunk-GFIZ6LQI.js +170 -0
- package/dist/chunk-GL6XM527.js +61 -0
- package/dist/chunk-HVBBDBS3.cjs +350 -0
- package/dist/{chunk-46ZIFWYG.cjs → chunk-IIRPUVPH.cjs} +7 -1
- package/dist/chunk-J3QQ6JS5.cjs +170 -0
- package/dist/{chunk-JWVTXXPX.cjs → chunk-KBM2W6UY.cjs} +8 -4
- package/dist/chunk-LB6EBS6Y.js +69 -0
- package/dist/{chunk-IWQAX3CS.js → chunk-LVUCAWMK.js} +1 -1
- package/dist/chunk-MKF46GNZ.js +350 -0
- package/dist/{chunk-HYN75H6G.cjs → chunk-MUHWHQVM.cjs} +1 -1
- package/dist/chunk-MYYR3HZL.js +44 -0
- package/dist/{chunk-MFZ5437A.js → chunk-N5T4M4GU.js} +1 -1
- package/dist/{chunk-5ENKBSWO.js → chunk-N7OOJI5V.js} +88 -8
- package/dist/chunk-NKVZ6Z3Y.cjs +61 -0
- package/dist/chunk-OF3BECU2.cjs +69 -0
- package/dist/{chunk-SNYBEXLB.cjs → chunk-OJGQKHN5.cjs} +3 -1
- package/dist/{chunk-DDMRUL76.cjs → chunk-OKMJLEXX.cjs} +5 -5
- package/dist/chunk-OPRS4IQZ.js +153 -0
- package/dist/chunk-OTZC4TNH.cjs +79 -0
- package/dist/{chunk-3Q6Z6JTO.cjs → chunk-OVQBNVSV.cjs} +287 -107
- package/dist/{chunk-4XMYPW46.cjs → chunk-OXHNSZ53.cjs} +84 -44
- package/dist/{chunk-C6OV7GCC.js → chunk-PEGTIPB3.js} +52 -12
- package/dist/chunk-PO3XB56Z.js +79 -0
- package/dist/{chunk-D3TDKWRP.js → chunk-RJ5ZGNI3.js} +54 -5
- package/dist/{chunk-PG7PS2NN.cjs → chunk-RJUONLUQ.cjs} +59 -10
- package/dist/{chunk-BPKCU575.js → chunk-SOO562NM.js} +3 -1
- package/dist/{chunk-6QZGDLL4.js → chunk-TOVPMMHM.js} +5 -1
- package/dist/{chunk-K52THW2C.cjs → chunk-V4TXMEJS.cjs} +5 -5
- package/dist/{chunk-G2UTNSGU.js → chunk-WNKWAEUR.js} +7 -1
- package/dist/{chunk-UNWKG6EI.cjs → chunk-XPIOJQS2.cjs} +51 -6
- package/dist/chunk-XXFYLL7R.js +63 -0
- package/dist/{chunk-KFI44N2R.cjs → chunk-YNJNTCSQ.cjs} +10 -1
- package/dist/{chunk-VQY5W4YW.cjs → chunk-YWL7YZWS.cjs} +90 -10
- package/dist/completion/ApiKeyPoolService.cjs +12 -0
- package/dist/completion/ApiKeyPoolService.d.cts +6 -0
- package/dist/completion/ApiKeyPoolService.d.ts +6 -0
- package/dist/completion/ApiKeyPoolService.js +12 -0
- package/dist/completion/CompletionService.cjs +30 -24
- package/dist/completion/CompletionService.d.cts +3 -1
- package/dist/completion/CompletionService.d.ts +3 -1
- package/dist/completion/CompletionService.js +29 -23
- package/dist/completion.cjs +32 -26
- package/dist/completion.d.cts +3 -1
- package/dist/completion.d.ts +3 -1
- package/dist/completion.js +31 -25
- package/dist/index.cjs +56 -29
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +61 -34
- package/dist/{keyPolicy-Cp0FntZl.d.cts → keyPolicy-zdWTu3CQ.d.cts} +1 -1
- package/dist/{keyPolicy-Cp0FntZl.d.ts → keyPolicy-zdWTu3CQ.d.ts} +1 -1
- package/dist/outbound-api/auditCapture.cjs +2 -2
- package/dist/outbound-api/auditCapture.d.cts +3 -4
- package/dist/outbound-api/auditCapture.d.ts +3 -4
- package/dist/outbound-api/auditCapture.js +1 -1
- package/dist/outbound-api/quotaWarn.d.cts +1 -1
- package/dist/outbound-api/quotaWarn.d.ts +1 -1
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.d.cts +5 -3
- package/dist/outbound-api/routeResolver.d.ts +5 -3
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +2 -0
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +2 -0
- package/dist/outbound-api/types.d.cts +4 -2
- package/dist/outbound-api/types.d.ts +4 -2
- package/dist/outbound-api.cjs +52 -25
- package/dist/outbound-api.d.cts +131 -87
- package/dist/outbound-api.d.ts +131 -87
- package/dist/outbound-api.js +55 -28
- package/dist/pipeline/AccountAllowanceScheduling.cjs +15 -0
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +91 -0
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +91 -0
- package/dist/pipeline/AccountAllowanceScheduling.js +15 -0
- package/dist/pipeline/AccountAllowanceStore.cjs +20 -0
- package/dist/pipeline/AccountAllowanceStore.d.cts +77 -0
- package/dist/pipeline/AccountAllowanceStore.d.ts +77 -0
- package/dist/pipeline/AccountAllowanceStore.js +20 -0
- package/dist/pipeline/AccountRouteActivity.cjs +10 -0
- package/dist/pipeline/AccountRouteActivity.d.cts +61 -0
- package/dist/pipeline/AccountRouteActivity.d.ts +61 -0
- package/dist/pipeline/AccountRouteActivity.js +10 -0
- package/dist/pipeline/AuthSource.d.cts +11 -2
- package/dist/pipeline/AuthSource.d.ts +11 -2
- package/dist/pipeline/BoundAccountSelectionError.cjs +10 -0
- package/dist/pipeline/BoundAccountSelectionError.d.cts +28 -0
- package/dist/pipeline/BoundAccountSelectionError.d.ts +28 -0
- package/dist/pipeline/BoundAccountSelectionError.js +10 -0
- package/dist/pipeline/LlmConfigProviderAuth.d.cts +1 -0
- package/dist/pipeline/LlmConfigProviderAuth.d.ts +1 -0
- package/dist/pipeline/ServerOverloadCounter.cjs +16 -0
- package/dist/pipeline/ServerOverloadCounter.d.cts +77 -0
- package/dist/pipeline/ServerOverloadCounter.d.ts +77 -0
- package/dist/pipeline/ServerOverloadCounter.js +16 -0
- package/dist/pipeline/SubscriptionAccountHealth.cjs +6 -2
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +65 -8
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +65 -8
- package/dist/pipeline/SubscriptionAccountHealth.js +5 -1
- package/dist/pipeline/SubscriptionAuthSource.cjs +5 -2
- package/dist/pipeline/SubscriptionAuthSource.d.cts +1 -0
- package/dist/pipeline/SubscriptionAuthSource.d.ts +1 -0
- package/dist/pipeline/SubscriptionAuthSource.js +4 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +8 -3
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +8 -3
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.d.cts +8 -3
- package/dist/pipeline/executeProviderCall.d.ts +8 -3
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/resolveProviderChain.d.cts +2 -3
- package/dist/pipeline/resolveProviderChain.d.ts +2 -3
- package/dist/pipeline/resolveSubscriptionChain.d.cts +1 -0
- package/dist/pipeline/resolveSubscriptionChain.d.ts +1 -0
- package/dist/pipeline/upstreamFetch.cjs +5 -3
- package/dist/pipeline/upstreamFetch.d.cts +35 -6
- package/dist/pipeline/upstreamFetch.d.ts +35 -6
- package/dist/pipeline/upstreamFetch.js +4 -2
- package/dist/pipeline/upstreamTrace.cjs +4 -2
- package/dist/pipeline/upstreamTrace.d.cts +22 -8
- package/dist/pipeline/upstreamTrace.d.ts +22 -8
- package/dist/pipeline/upstreamTrace.js +3 -1
- package/dist/ports/pricing-store.d.cts +4 -3
- package/dist/ports/pricing-store.d.ts +4 -3
- package/dist/ports.d.cts +4 -3
- package/dist/ports.d.ts +4 -3
- package/dist/provider-proxy/ProviderProxy.cjs +30 -24
- package/dist/provider-proxy/ProviderProxy.d.cts +2 -0
- package/dist/provider-proxy/ProviderProxy.d.ts +2 -0
- package/dist/provider-proxy/ProviderProxy.js +29 -23
- package/dist/provider-proxy/identity/codexCliHeaders.cjs +10 -0
- package/dist/provider-proxy/identity/codexCliHeaders.d.cts +45 -0
- package/dist/provider-proxy/identity/codexCliHeaders.d.ts +45 -0
- package/dist/provider-proxy/identity/codexCliHeaders.js +10 -0
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +32 -24
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +44 -5
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +44 -5
- package/dist/provider-proxy/ingress/providerProxyShared.js +31 -23
- package/dist/provider-proxy/matchText.cjs +4 -2
- package/dist/provider-proxy/matchText.d.cts +39 -6
- package/dist/provider-proxy/matchText.d.ts +39 -6
- package/dist/provider-proxy/matchText.js +3 -1
- package/dist/provider-proxy/types.d.cts +35 -2
- package/dist/provider-proxy/types.d.ts +35 -2
- package/dist/provider-proxy.cjs +30 -24
- package/dist/provider-proxy.d.cts +2 -0
- package/dist/provider-proxy.d.ts +2 -0
- package/dist/provider-proxy.js +29 -23
- package/dist/{routeResolver-C4T7yClx.d.ts → routeResolver-BxOfunbm.d.ts} +1 -1
- package/dist/{routeResolver-CB3tvJKy.d.cts → routeResolver-D5OzD0iM.d.cts} +1 -1
- package/dist/transformer/TransformerChainExecutor.cjs +2 -2
- package/dist/transformer/TransformerChainExecutor.js +1 -1
- package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -2
- package/dist/transformer/transformers/AnthropicTransformer.js +2 -1
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
- package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
- package/dist/transformer/transformers/GeminiTransformer.js +2 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +1 -1
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +1 -1
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -1
- package/dist/transformer/transformers/OpenAITransformer.cjs +6 -0
- package/dist/transformer/transformers/OpenAITransformer.d.cts +68 -0
- package/dist/transformer/transformers/OpenAITransformer.d.ts +68 -0
- package/dist/transformer/transformers/OpenAITransformer.js +6 -0
- package/dist/transformer/transformers.cjs +9 -14
- package/dist/transformer/transformers.d.cts +12 -48
- package/dist/transformer/transformers.d.ts +12 -48
- package/dist/transformer/transformers.js +11 -16
- package/dist/transformer/types.d.cts +17 -0
- package/dist/transformer/types.d.ts +17 -0
- package/dist/transformer.cjs +12 -12
- package/dist/transformer.d.cts +1 -2
- package/dist/transformer.d.ts +1 -2
- package/dist/transformer.js +12 -12
- package/dist/{types-lgPYQuZS.d.ts → types-CqZD77rS.d.ts} +173 -7
- package/dist/{types-B8Arpxn0.d.cts → types-gjJ5lJ5n.d.cts} +173 -7
- package/dist/usage/pricing-engine.cjs +2 -2
- package/dist/usage/pricing-engine.d.cts +29 -1
- package/dist/usage/pricing-engine.d.ts +29 -1
- package/dist/usage/pricing-engine.js +1 -1
- package/dist/usage/usage-recorder.cjs +2 -2
- package/dist/usage/usage-recorder.d.cts +5 -1
- package/dist/usage/usage-recorder.d.ts +5 -1
- package/dist/usage/usage-recorder.js +1 -1
- package/dist/usage.cjs +3 -3
- package/dist/usage.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-7FEBOPJO.cjs +0 -50
- package/dist/chunk-DWKQZ2SK.cjs +0 -254
- package/dist/chunk-IAXWICZU.js +0 -69
- package/dist/chunk-IB3FDI4O.js +0 -50
- package/dist/chunk-OQWKZCXP.js +0 -242
- package/dist/chunk-QWBWGODS.cjs +0 -69
- package/dist/chunk-YMFAJFQT.cjs +0 -173
- package/dist/chunk-ZCIQ3L3R.cjs +0 -242
- package/dist/chunk-ZJZAOKI7.js +0 -254
- package/dist/chunk-ZLX3KGXX.js +0 -173
- package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +0 -6
- package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +0 -51
- package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +0 -51
- package/dist/transformer/transformers/OpenCodeGoTransformer.js +0 -6
- package/dist/transformer/transformers/ReasoningTransformer.cjs +0 -6
- package/dist/transformer/transformers/ReasoningTransformer.d.cts +0 -47
- package/dist/transformer/transformers/ReasoningTransformer.d.ts +0 -47
- package/dist/transformer/transformers/ReasoningTransformer.js +0 -6
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk4BB343BIcjs = require('../chunk-4BB343BI.cjs');
|
|
5
5
|
require('../chunk-HQP3K7PU.cjs');
|
|
6
6
|
require('../chunk-FZ46M34D.cjs');
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
11
|
-
require('../chunk-
|
|
12
|
-
require('../chunk-
|
|
13
|
-
require('../chunk-K52THW2C.cjs');
|
|
14
|
-
require('../chunk-3Q6Z6JTO.cjs');
|
|
7
|
+
require('../chunk-2Z4XM3H5.cjs');
|
|
8
|
+
require('../chunk-OXHNSZ53.cjs');
|
|
9
|
+
require('../chunk-V4TXMEJS.cjs');
|
|
10
|
+
require('../chunk-OVQBNVSV.cjs');
|
|
11
|
+
require('../chunk-5RSZYQJH.cjs');
|
|
12
|
+
require('../chunk-OF3BECU2.cjs');
|
|
15
13
|
require('../chunk-EYZYXJTJ.cjs');
|
|
16
|
-
require('../chunk-
|
|
17
|
-
require('../chunk-
|
|
14
|
+
require('../chunk-2E42SAW3.cjs');
|
|
15
|
+
require('../chunk-OJGQKHN5.cjs');
|
|
16
|
+
require('../chunk-IIRPUVPH.cjs');
|
|
18
17
|
require('../chunk-GBHYAGX3.cjs');
|
|
18
|
+
require('../chunk-3OPYJG76.cjs');
|
|
19
|
+
require('../chunk-3SCOLIPT.cjs');
|
|
19
20
|
require('../chunk-RPII3E6Z.cjs');
|
|
20
21
|
require('../chunk-6RPZADX3.cjs');
|
|
21
|
-
require('../chunk-
|
|
22
|
+
require('../chunk-J3QQ6JS5.cjs');
|
|
22
23
|
require('../chunk-UIBD2YY5.cjs');
|
|
23
24
|
require('../chunk-R3HK6R4B.cjs');
|
|
24
|
-
require('../chunk-HYN75H6G.cjs');
|
|
25
|
-
require('../chunk-Q27JY5RG.cjs');
|
|
26
25
|
require('../chunk-QXD4MV2X.cjs');
|
|
27
26
|
require('../chunk-NYUNU75A.cjs');
|
|
28
|
-
require('../chunk-
|
|
29
|
-
require('../chunk-
|
|
27
|
+
require('../chunk-OTZC4TNH.cjs');
|
|
28
|
+
require('../chunk-YWL7YZWS.cjs');
|
|
29
|
+
require('../chunk-YNJNTCSQ.cjs');
|
|
30
30
|
require('../chunk-SVNDB62D.cjs');
|
|
31
|
+
require('../chunk-6QQG7YG3.cjs');
|
|
32
|
+
require('../chunk-25GXJCEZ.cjs');
|
|
33
|
+
require('../chunk-MUHWHQVM.cjs');
|
|
34
|
+
require('../chunk-Q27JY5RG.cjs');
|
|
31
35
|
require('../chunk-APYG5QD7.cjs');
|
|
32
36
|
require('../chunk-L74VDN4A.cjs');
|
|
33
37
|
require('../chunk-4YINUUKQ.cjs');
|
|
34
|
-
require('../chunk-
|
|
38
|
+
require('../chunk-4VZX5F4T.cjs');
|
|
35
39
|
require('../chunk-QBZJ7P2T.cjs');
|
|
36
40
|
require('../chunk-4IH4EL7M.cjs');
|
|
37
41
|
require('../chunk-A2YMUCBT.cjs');
|
|
38
|
-
require('../chunk-
|
|
42
|
+
require('../chunk-XPIOJQS2.cjs');
|
|
39
43
|
require('../chunk-FCR77GYM.cjs');
|
|
40
44
|
require('../chunk-AEOZIDEB.cjs');
|
|
41
45
|
require('../chunk-XSVNC2UD.cjs');
|
|
42
|
-
require('../chunk-
|
|
43
|
-
require('../chunk-
|
|
44
|
-
require('../chunk-
|
|
45
|
-
require('../chunk-
|
|
46
|
-
require('../chunk-
|
|
46
|
+
require('../chunk-GDIXXKF2.cjs');
|
|
47
|
+
require('../chunk-OKMJLEXX.cjs');
|
|
48
|
+
require('../chunk-KBM2W6UY.cjs');
|
|
49
|
+
require('../chunk-RJUONLUQ.cjs');
|
|
50
|
+
require('../chunk-235MXAGX.cjs');
|
|
51
|
+
require('../chunk-HVBBDBS3.cjs');
|
|
52
|
+
require('../chunk-NKVZ6Z3Y.cjs');
|
|
47
53
|
require('../chunk-NZYN7C3P.cjs');
|
|
48
54
|
require('../chunk-JMJBSACD.cjs');
|
|
49
55
|
require('../chunk-GMMT7RVN.cjs');
|
|
@@ -51,4 +57,4 @@ require('../chunk-UNEFIWXI.cjs');
|
|
|
51
57
|
|
|
52
58
|
|
|
53
59
|
|
|
54
|
-
exports.ProviderProxy =
|
|
60
|
+
exports.ProviderProxy = _chunk4BB343BIcjs.ProviderProxy; exports.isLoopbackAddress = _chunk4BB343BIcjs.isLoopbackAddress;
|
|
@@ -2,12 +2,14 @@ export { P as ProviderProxy, i as isLoopbackAddress } from '../ProviderProxy-CnM
|
|
|
2
2
|
import './types.cjs';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
import '@omnicross/contracts/completion-types';
|
|
5
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
5
6
|
import '@omnicross/contracts/subscription-types';
|
|
6
7
|
import '@omnicross/contracts/usage-types';
|
|
7
8
|
import '../completion/ApiKeyPoolService.cjs';
|
|
8
9
|
import '@omnicross/contracts/llm-config';
|
|
9
10
|
import '../logger-4GvQNzhE.cjs';
|
|
10
11
|
import '../pipeline/AuthSource.cjs';
|
|
12
|
+
import '../pipeline/BoundAccountSelectionError.cjs';
|
|
11
13
|
import '../pipeline/SubscriptionAuthSource.cjs';
|
|
12
14
|
import '../pipeline/SubscriptionAuthStrategy.cjs';
|
|
13
15
|
import '../ports/provider-config-source.cjs';
|
|
@@ -2,12 +2,14 @@ export { P as ProviderProxy, i as isLoopbackAddress } from '../ProviderProxy-C-x
|
|
|
2
2
|
import './types.js';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
import '@omnicross/contracts/completion-types';
|
|
5
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
5
6
|
import '@omnicross/contracts/subscription-types';
|
|
6
7
|
import '@omnicross/contracts/usage-types';
|
|
7
8
|
import '../completion/ApiKeyPoolService.js';
|
|
8
9
|
import '@omnicross/contracts/llm-config';
|
|
9
10
|
import '../logger-4GvQNzhE.js';
|
|
10
11
|
import '../pipeline/AuthSource.js';
|
|
12
|
+
import '../pipeline/BoundAccountSelectionError.js';
|
|
11
13
|
import '../pipeline/SubscriptionAuthSource.js';
|
|
12
14
|
import '../pipeline/SubscriptionAuthStrategy.js';
|
|
13
15
|
import '../ports/provider-config-source.js';
|
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProviderProxy,
|
|
3
3
|
isLoopbackAddress
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-E3COOKUP.js";
|
|
5
5
|
import "../chunk-VVEHS2LI.js";
|
|
6
6
|
import "../chunk-46RLHI7D.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-IWQAX3CS.js";
|
|
14
|
-
import "../chunk-BODMAL6G.js";
|
|
7
|
+
import "../chunk-MYYR3HZL.js";
|
|
8
|
+
import "../chunk-PEGTIPB3.js";
|
|
9
|
+
import "../chunk-LVUCAWMK.js";
|
|
10
|
+
import "../chunk-32O35CIF.js";
|
|
11
|
+
import "../chunk-FU7EAR73.js";
|
|
12
|
+
import "../chunk-LB6EBS6Y.js";
|
|
15
13
|
import "../chunk-7VU7V2E4.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-FXR6N3SR.js";
|
|
15
|
+
import "../chunk-SOO562NM.js";
|
|
16
|
+
import "../chunk-WNKWAEUR.js";
|
|
18
17
|
import "../chunk-MZNPGW5Q.js";
|
|
18
|
+
import "../chunk-DK4A7DLE.js";
|
|
19
|
+
import "../chunk-XXFYLL7R.js";
|
|
19
20
|
import "../chunk-XTEI64OU.js";
|
|
20
21
|
import "../chunk-XX6NQJMA.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-GFIZ6LQI.js";
|
|
22
23
|
import "../chunk-OE6TDIWW.js";
|
|
23
24
|
import "../chunk-DRWHTIIZ.js";
|
|
24
|
-
import "../chunk-IK3KE3AU.js";
|
|
25
|
-
import "../chunk-ZY6KU6P3.js";
|
|
26
25
|
import "../chunk-JWC6APFQ.js";
|
|
27
26
|
import "../chunk-5ERIZW3D.js";
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
27
|
+
import "../chunk-PO3XB56Z.js";
|
|
28
|
+
import "../chunk-N7OOJI5V.js";
|
|
29
|
+
import "../chunk-23S5OPIO.js";
|
|
30
30
|
import "../chunk-AVYJ4YBN.js";
|
|
31
|
+
import "../chunk-OPRS4IQZ.js";
|
|
32
|
+
import "../chunk-2JYRIADS.js";
|
|
33
|
+
import "../chunk-DE2SRBFZ.js";
|
|
34
|
+
import "../chunk-ZY6KU6P3.js";
|
|
31
35
|
import "../chunk-WLYIIEAF.js";
|
|
32
36
|
import "../chunk-TKJMZBAH.js";
|
|
33
37
|
import "../chunk-3QFXFCHG.js";
|
|
34
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-EBLFCNPY.js";
|
|
35
39
|
import "../chunk-AQ5TNQB7.js";
|
|
36
40
|
import "../chunk-XEKD23J5.js";
|
|
37
41
|
import "../chunk-H5JUT3KV.js";
|
|
38
|
-
import "../chunk-
|
|
42
|
+
import "../chunk-7C7DET6S.js";
|
|
39
43
|
import "../chunk-K5NM7VAH.js";
|
|
40
44
|
import "../chunk-WNY4WMRF.js";
|
|
41
45
|
import "../chunk-OZFM4X3S.js";
|
|
42
|
-
import "../chunk-
|
|
43
|
-
import "../chunk-
|
|
44
|
-
import "../chunk-
|
|
45
|
-
import "../chunk-
|
|
46
|
-
import "../chunk-
|
|
46
|
+
import "../chunk-5NJLQ6T6.js";
|
|
47
|
+
import "../chunk-N5T4M4GU.js";
|
|
48
|
+
import "../chunk-TOVPMMHM.js";
|
|
49
|
+
import "../chunk-RJ5ZGNI3.js";
|
|
50
|
+
import "../chunk-3WD4HTR2.js";
|
|
51
|
+
import "../chunk-MKF46GNZ.js";
|
|
52
|
+
import "../chunk-GL6XM527.js";
|
|
47
53
|
import "../chunk-CDHS2QDC.js";
|
|
48
54
|
import "../chunk-Y7FO65VT.js";
|
|
49
55
|
import "../chunk-FMOBD2OQ.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk3SCOLIPTcjs = require('../../chunk-3SCOLIPT.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.DEFAULT_CODEX_CLI_HEADERS = _chunk3SCOLIPTcjs.DEFAULT_CODEX_CLI_HEADERS; exports.codexAcceptHeader = _chunk3SCOLIPTcjs.codexAcceptHeader; exports.extractCodexClientHeaders = _chunk3SCOLIPTcjs.extractCodexClientHeaders;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codexCliHeaders — the Codex CLI client headers the CODEX SUBSCRIPTION relay
|
|
3
|
+
* puts on every `chatgpt.com/backend-api/codex/responses` request.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS: like the claude relay, this path sent exactly `content-type`
|
|
6
|
+
* + `Authorization` (verified against a live `upstream-trace.jsonl`). Unlike the
|
|
7
|
+
* claude one it still got a 200 — ChatGPT's Codex backend does not currently
|
|
8
|
+
* reject a bare request — but the relayed call carried NONE of the markers a
|
|
9
|
+
* real `codex` CLI sends (`originator`, its UA, `version`, `openai-beta`,
|
|
10
|
+
* `session_id`), which is exactly the shape risk-control looks at.
|
|
11
|
+
*
|
|
12
|
+
* SCOPE: applied ONLY to the codex SUBSCRIPTION plan (`proxyProviderId ===
|
|
13
|
+
* 'codex'`, i.e. an OAuth ChatGPT account). A BYO OpenAI-compatible endpoint
|
|
14
|
+
* shares this relay and must stay byte-identical — sending it `originator:
|
|
15
|
+
* codex_cli_rs` would be wrong and could trip its own checks.
|
|
16
|
+
*
|
|
17
|
+
* Modeled on claude-relay-service (`routes/openaiRoutes.js`, the codex branch).
|
|
18
|
+
*
|
|
19
|
+
* NOT DONE HERE (deliberate, see the relay call site):
|
|
20
|
+
* - `chatgpt-account-id`: CRS sends the ChatGPT account id parsed out of the
|
|
21
|
+
* OAuth `id_token`. Guessing it wrong risks a 403 on a path that currently
|
|
22
|
+
* works, so it is left to a follow-up that can verify the value.
|
|
23
|
+
* - forcing `store: false` on the body: a body mutation with its own regression
|
|
24
|
+
* surface, tracked separately.
|
|
25
|
+
*
|
|
26
|
+
* @module provider-proxy/identity/codexCliHeaders
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Client markers a real `codex` CLI invocation carries. Used ONLY to fill a slot
|
|
30
|
+
* the caller left empty — a forwarded real value always wins, so a genuine Codex
|
|
31
|
+
* CLI keeps its own identity and only a caller that sent nothing gets these.
|
|
32
|
+
*
|
|
33
|
+
* `originator` is the load-bearing one: it is how the backend tells the Codex
|
|
34
|
+
* CLI apart from a generic Responses client, and CRS sends it unconditionally.
|
|
35
|
+
*/
|
|
36
|
+
declare const DEFAULT_CODEX_CLI_HEADERS: Readonly<Record<string, string>>;
|
|
37
|
+
/**
|
|
38
|
+
* Extract the caller's forwardable Codex CLI headers (lowercased keys). Ungated:
|
|
39
|
+
* passing along what the client actually sent is not fingerprint synthesis.
|
|
40
|
+
*/
|
|
41
|
+
declare function extractCodexClientHeaders(reqHeaders: Record<string, string | string[] | undefined>): Record<string, string>;
|
|
42
|
+
/** The `accept` a Codex CLI sends, which differs by streaming mode. */
|
|
43
|
+
declare function codexAcceptHeader(isStream: boolean): string;
|
|
44
|
+
|
|
45
|
+
export { DEFAULT_CODEX_CLI_HEADERS, codexAcceptHeader, extractCodexClientHeaders };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codexCliHeaders — the Codex CLI client headers the CODEX SUBSCRIPTION relay
|
|
3
|
+
* puts on every `chatgpt.com/backend-api/codex/responses` request.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS: like the claude relay, this path sent exactly `content-type`
|
|
6
|
+
* + `Authorization` (verified against a live `upstream-trace.jsonl`). Unlike the
|
|
7
|
+
* claude one it still got a 200 — ChatGPT's Codex backend does not currently
|
|
8
|
+
* reject a bare request — but the relayed call carried NONE of the markers a
|
|
9
|
+
* real `codex` CLI sends (`originator`, its UA, `version`, `openai-beta`,
|
|
10
|
+
* `session_id`), which is exactly the shape risk-control looks at.
|
|
11
|
+
*
|
|
12
|
+
* SCOPE: applied ONLY to the codex SUBSCRIPTION plan (`proxyProviderId ===
|
|
13
|
+
* 'codex'`, i.e. an OAuth ChatGPT account). A BYO OpenAI-compatible endpoint
|
|
14
|
+
* shares this relay and must stay byte-identical — sending it `originator:
|
|
15
|
+
* codex_cli_rs` would be wrong and could trip its own checks.
|
|
16
|
+
*
|
|
17
|
+
* Modeled on claude-relay-service (`routes/openaiRoutes.js`, the codex branch).
|
|
18
|
+
*
|
|
19
|
+
* NOT DONE HERE (deliberate, see the relay call site):
|
|
20
|
+
* - `chatgpt-account-id`: CRS sends the ChatGPT account id parsed out of the
|
|
21
|
+
* OAuth `id_token`. Guessing it wrong risks a 403 on a path that currently
|
|
22
|
+
* works, so it is left to a follow-up that can verify the value.
|
|
23
|
+
* - forcing `store: false` on the body: a body mutation with its own regression
|
|
24
|
+
* surface, tracked separately.
|
|
25
|
+
*
|
|
26
|
+
* @module provider-proxy/identity/codexCliHeaders
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Client markers a real `codex` CLI invocation carries. Used ONLY to fill a slot
|
|
30
|
+
* the caller left empty — a forwarded real value always wins, so a genuine Codex
|
|
31
|
+
* CLI keeps its own identity and only a caller that sent nothing gets these.
|
|
32
|
+
*
|
|
33
|
+
* `originator` is the load-bearing one: it is how the backend tells the Codex
|
|
34
|
+
* CLI apart from a generic Responses client, and CRS sends it unconditionally.
|
|
35
|
+
*/
|
|
36
|
+
declare const DEFAULT_CODEX_CLI_HEADERS: Readonly<Record<string, string>>;
|
|
37
|
+
/**
|
|
38
|
+
* Extract the caller's forwardable Codex CLI headers (lowercased keys). Ungated:
|
|
39
|
+
* passing along what the client actually sent is not fingerprint synthesis.
|
|
40
|
+
*/
|
|
41
|
+
declare function extractCodexClientHeaders(reqHeaders: Record<string, string | string[] | undefined>): Record<string, string>;
|
|
42
|
+
/** The `accept` a Codex CLI sends, which differs by streaming mode. */
|
|
43
|
+
declare function codexAcceptHeader(isStream: boolean): string;
|
|
44
|
+
|
|
45
|
+
export { DEFAULT_CODEX_CLI_HEADERS, codexAcceptHeader, extractCodexClientHeaders };
|
|
@@ -8,49 +8,56 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _chunk4BB343BIcjs = require('../../chunk-4BB343BI.cjs');
|
|
12
13
|
require('../../chunk-HQP3K7PU.cjs');
|
|
13
14
|
require('../../chunk-FZ46M34D.cjs');
|
|
14
|
-
require('../../chunk-
|
|
15
|
-
require('../../chunk-
|
|
16
|
-
require('../../chunk-
|
|
17
|
-
require('../../chunk-
|
|
18
|
-
require('../../chunk-
|
|
19
|
-
require('../../chunk-
|
|
20
|
-
require('../../chunk-K52THW2C.cjs');
|
|
21
|
-
require('../../chunk-3Q6Z6JTO.cjs');
|
|
15
|
+
require('../../chunk-2Z4XM3H5.cjs');
|
|
16
|
+
require('../../chunk-OXHNSZ53.cjs');
|
|
17
|
+
require('../../chunk-V4TXMEJS.cjs');
|
|
18
|
+
require('../../chunk-OVQBNVSV.cjs');
|
|
19
|
+
require('../../chunk-5RSZYQJH.cjs');
|
|
20
|
+
require('../../chunk-OF3BECU2.cjs');
|
|
22
21
|
require('../../chunk-EYZYXJTJ.cjs');
|
|
23
|
-
require('../../chunk-
|
|
24
|
-
require('../../chunk-
|
|
22
|
+
require('../../chunk-2E42SAW3.cjs');
|
|
23
|
+
require('../../chunk-OJGQKHN5.cjs');
|
|
24
|
+
require('../../chunk-IIRPUVPH.cjs');
|
|
25
25
|
require('../../chunk-GBHYAGX3.cjs');
|
|
26
|
+
require('../../chunk-3OPYJG76.cjs');
|
|
27
|
+
require('../../chunk-3SCOLIPT.cjs');
|
|
26
28
|
require('../../chunk-RPII3E6Z.cjs');
|
|
27
29
|
require('../../chunk-6RPZADX3.cjs');
|
|
28
|
-
require('../../chunk-
|
|
30
|
+
require('../../chunk-J3QQ6JS5.cjs');
|
|
29
31
|
require('../../chunk-UIBD2YY5.cjs');
|
|
30
32
|
require('../../chunk-R3HK6R4B.cjs');
|
|
31
|
-
require('../../chunk-HYN75H6G.cjs');
|
|
32
|
-
require('../../chunk-Q27JY5RG.cjs');
|
|
33
33
|
require('../../chunk-QXD4MV2X.cjs');
|
|
34
34
|
require('../../chunk-NYUNU75A.cjs');
|
|
35
|
-
require('../../chunk-
|
|
36
|
-
require('../../chunk-
|
|
35
|
+
require('../../chunk-OTZC4TNH.cjs');
|
|
36
|
+
require('../../chunk-YWL7YZWS.cjs');
|
|
37
|
+
require('../../chunk-YNJNTCSQ.cjs');
|
|
37
38
|
require('../../chunk-SVNDB62D.cjs');
|
|
39
|
+
require('../../chunk-6QQG7YG3.cjs');
|
|
40
|
+
require('../../chunk-25GXJCEZ.cjs');
|
|
41
|
+
require('../../chunk-MUHWHQVM.cjs');
|
|
42
|
+
require('../../chunk-Q27JY5RG.cjs');
|
|
38
43
|
require('../../chunk-APYG5QD7.cjs');
|
|
39
44
|
require('../../chunk-L74VDN4A.cjs');
|
|
40
45
|
require('../../chunk-4YINUUKQ.cjs');
|
|
41
|
-
require('../../chunk-
|
|
46
|
+
require('../../chunk-4VZX5F4T.cjs');
|
|
42
47
|
require('../../chunk-QBZJ7P2T.cjs');
|
|
43
48
|
require('../../chunk-4IH4EL7M.cjs');
|
|
44
49
|
require('../../chunk-A2YMUCBT.cjs');
|
|
45
|
-
require('../../chunk-
|
|
50
|
+
require('../../chunk-XPIOJQS2.cjs');
|
|
46
51
|
require('../../chunk-FCR77GYM.cjs');
|
|
47
52
|
require('../../chunk-AEOZIDEB.cjs');
|
|
48
53
|
require('../../chunk-XSVNC2UD.cjs');
|
|
49
|
-
require('../../chunk-
|
|
50
|
-
require('../../chunk-
|
|
51
|
-
require('../../chunk-
|
|
52
|
-
require('../../chunk-
|
|
53
|
-
require('../../chunk-
|
|
54
|
+
require('../../chunk-GDIXXKF2.cjs');
|
|
55
|
+
require('../../chunk-OKMJLEXX.cjs');
|
|
56
|
+
require('../../chunk-KBM2W6UY.cjs');
|
|
57
|
+
require('../../chunk-RJUONLUQ.cjs');
|
|
58
|
+
require('../../chunk-235MXAGX.cjs');
|
|
59
|
+
require('../../chunk-HVBBDBS3.cjs');
|
|
60
|
+
require('../../chunk-NKVZ6Z3Y.cjs');
|
|
54
61
|
require('../../chunk-NZYN7C3P.cjs');
|
|
55
62
|
require('../../chunk-JMJBSACD.cjs');
|
|
56
63
|
require('../../chunk-GMMT7RVN.cjs');
|
|
@@ -65,4 +72,5 @@ require('../../chunk-UNEFIWXI.cjs');
|
|
|
65
72
|
|
|
66
73
|
|
|
67
74
|
|
|
68
|
-
|
|
75
|
+
|
|
76
|
+
exports.aggregateAnthropicSseToJsonBody = _chunk4BB343BIcjs.aggregateAnthropicSseToJsonBody; exports.getAnthropicEndpointTransformer = _chunk4BB343BIcjs.getAnthropicEndpointTransformer; exports.getGeminiEndpointTransformer = _chunk4BB343BIcjs.getGeminiEndpointTransformer; exports.getResponsesEndpointTransformer = _chunk4BB343BIcjs.getResponsesEndpointTransformer; exports.getSharedExecutor = _chunk4BB343BIcjs.getSharedExecutor; exports.readBody = _chunk4BB343BIcjs.readBody; exports.relayResponse = _chunk4BB343BIcjs.relayResponse; exports.resolvePoolBoundKey = _chunk4BB343BIcjs.resolvePoolBoundKey; exports.writeBoundAccountError = _chunk4BB343BIcjs.writeBoundAccountError; exports.writeError = _chunk4BB343BIcjs.writeError;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import { LLMProvider } from '@omnicross/contracts/llm-config';
|
|
3
|
+
import { BoundAccountSelectionError } from '../../pipeline/BoundAccountSelectionError.cjs';
|
|
3
4
|
import { TransformerChainExecutor } from '../../transformer/TransformerChainExecutor.cjs';
|
|
4
5
|
import { Transformer } from '../../transformer/types.cjs';
|
|
5
6
|
import { ProviderProxyDeps } from '../types.cjs';
|
|
6
7
|
import '@omnicross/contracts/completion-types';
|
|
8
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
7
9
|
import '@omnicross/contracts/subscription-types';
|
|
8
10
|
import '@omnicross/contracts/usage-types';
|
|
9
11
|
import '../../completion/ApiKeyPoolService.cjs';
|
|
@@ -37,6 +39,28 @@ declare function getAnthropicEndpointTransformer(): Transformer;
|
|
|
37
39
|
declare function getGeminiEndpointTransformer(): Transformer;
|
|
38
40
|
/** Read the full request body from an IncomingMessage. */
|
|
39
41
|
declare function readBody(req: http.IncomingMessage): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* A usage tap for {@link relayResponse}'s stream branch. Streaming responses were
|
|
44
|
+
* previously not metered (only the non-stream branch recorded usage), so Codex
|
|
45
|
+
* — which always streams — produced zero usage/dashboard rows. The tap lets each
|
|
46
|
+
* ingress extract the RAW provider usage object from the SSE events it already
|
|
47
|
+
* knows, and {@link onUsage} fires once at stream end so the recorder charges
|
|
48
|
+
* exactly one event per request. Returning the raw object (not normalized)
|
|
49
|
+
* keeps this tap endpoint-agnostic; each recorder normalizes its own shape.
|
|
50
|
+
*/
|
|
51
|
+
interface StreamUsageTap {
|
|
52
|
+
/**
|
|
53
|
+
* Inspect one parsed SSE `data:` JSON event. Return the raw provider usage
|
|
54
|
+
* object it carries (else null/undefined). The LAST non-null return across
|
|
55
|
+
* the whole stream is what {@link onUsage} receives — so for endpoints whose
|
|
56
|
+
* usage arrives piecewise (e.g. Anthropic `message_start`+`message_delta`),
|
|
57
|
+
* merge inside this closure and return the combined value from the terminal
|
|
58
|
+
* event.
|
|
59
|
+
*/
|
|
60
|
+
extractUsage(event: Record<string, unknown>): Record<string, unknown> | null | undefined;
|
|
61
|
+
/** Called once at stream end with the last captured usage (only if any). */
|
|
62
|
+
onUsage(rawUsage: Record<string, unknown>): void;
|
|
63
|
+
}
|
|
40
64
|
/**
|
|
41
65
|
* Relay an already-wire-shaped `Response` to the http `res`.
|
|
42
66
|
* - `text/event-stream` (or `isStream`): pipe the ReadableStream chunk-by-chunk.
|
|
@@ -54,7 +78,16 @@ declare function readBody(req: http.IncomingMessage): Promise<string>;
|
|
|
54
78
|
*
|
|
55
79
|
* @returns the (upstream) JSON body text for non-stream responses, else `null`.
|
|
56
80
|
*/
|
|
57
|
-
declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean, rewriteModel?: string
|
|
81
|
+
declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean, rewriteModel?: string, usageTap?: StreamUsageTap,
|
|
82
|
+
/**
|
|
83
|
+
* Read-only observer invoked with every parsed SSE `data:` event during a
|
|
84
|
+
* streaming relay. Never affects the relayed bytes (it runs on the ORIGINAL
|
|
85
|
+
* line, independent of the model-rewrite / usage-tap paths). Used to detect
|
|
86
|
+
* in-band errors that arrive AFTER a `200` — e.g. a Codex `response.failed`
|
|
87
|
+
* server-overload event. When present, forces the line-based relay path so
|
|
88
|
+
* events are parsed even without a `rewriteModel`/`usageTap`.
|
|
89
|
+
*/
|
|
90
|
+
onSseEvent?: (event: Record<string, unknown>) => void): Promise<string | null>;
|
|
58
91
|
/**
|
|
59
92
|
* Aggregate a streaming Anthropic `text/event-stream` body into ONE buffered
|
|
60
93
|
* Anthropic `message` JSON object — the inverse of the SDK's SSE wire format.
|
|
@@ -73,13 +106,19 @@ declare function relayResponse(res: http.ServerResponse, providerResponse: Respo
|
|
|
73
106
|
declare function aggregateAnthropicSseToJsonBody(response: Response, rewriteModel?: string): Promise<string>;
|
|
74
107
|
/** Write a JSON error response if the headers have not been sent. */
|
|
75
108
|
declare function writeError(res: http.ServerResponse, status: number, message: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Map a strict bound-account failure to a stable structured response. The body
|
|
111
|
+
* carries only the fixed code/reason/message; account ids, tokens, and upstream
|
|
112
|
+
* error text never cross the wire.
|
|
113
|
+
*/
|
|
114
|
+
declare function writeBoundAccountError(res: http.ServerResponse, error: BoundAccountSelectionError): void;
|
|
76
115
|
/**
|
|
77
116
|
* Resolve the FIRST-CHOICE BYO request key for a `buildByoPlan`, threading the
|
|
78
117
|
* ApiKeyPool through TWO gates so 429/529/401/403 failover actually fires on the
|
|
79
118
|
* outbound serving path (omnicross-daemon-parity-poolseam, design D2(b)).
|
|
80
119
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
120
|
+
* Matches the host engine adapter's `resolveApiKeyForProvider` contract so pool
|
|
121
|
+
* failover remains inside the provider layer:
|
|
83
122
|
* - pool present AND a (synthesized outbound) sessionId present →
|
|
84
123
|
* `getKeyForSession(providerId, sessionId)`. This SEEDS `sessionBindings`
|
|
85
124
|
* with the chosen key AND returns that same key, so it becomes the first
|
|
@@ -101,6 +140,6 @@ declare function writeError(res: http.ServerResponse, status: number, message: s
|
|
|
101
140
|
* already-`resolveKey`-resolved string (its loader passes the host resolver),
|
|
102
141
|
* so the pool branch needs no further `$ENV` expansion.
|
|
103
142
|
*/
|
|
104
|
-
declare function resolvePoolBoundKey(deps: ProviderProxyDeps, providerId: string, provider: LLMProvider, sessionId: string | null): Promise<string>;
|
|
143
|
+
declare function resolvePoolBoundKey(deps: ProviderProxyDeps, providerId: string, provider: LLMProvider, sessionId: string | null, preferredKeyId?: string, boundKeyFallbackPolicy?: 'strict' | 'pool'): Promise<string>;
|
|
105
144
|
|
|
106
|
-
export { aggregateAnthropicSseToJsonBody, getAnthropicEndpointTransformer, getGeminiEndpointTransformer, getResponsesEndpointTransformer, getSharedExecutor, readBody, relayResponse, resolvePoolBoundKey, writeError };
|
|
145
|
+
export { type StreamUsageTap, aggregateAnthropicSseToJsonBody, getAnthropicEndpointTransformer, getGeminiEndpointTransformer, getResponsesEndpointTransformer, getSharedExecutor, readBody, relayResponse, resolvePoolBoundKey, writeBoundAccountError, writeError };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import { LLMProvider } from '@omnicross/contracts/llm-config';
|
|
3
|
+
import { BoundAccountSelectionError } from '../../pipeline/BoundAccountSelectionError.js';
|
|
3
4
|
import { TransformerChainExecutor } from '../../transformer/TransformerChainExecutor.js';
|
|
4
5
|
import { Transformer } from '../../transformer/types.js';
|
|
5
6
|
import { ProviderProxyDeps } from '../types.js';
|
|
6
7
|
import '@omnicross/contracts/completion-types';
|
|
8
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
7
9
|
import '@omnicross/contracts/subscription-types';
|
|
8
10
|
import '@omnicross/contracts/usage-types';
|
|
9
11
|
import '../../completion/ApiKeyPoolService.js';
|
|
@@ -37,6 +39,28 @@ declare function getAnthropicEndpointTransformer(): Transformer;
|
|
|
37
39
|
declare function getGeminiEndpointTransformer(): Transformer;
|
|
38
40
|
/** Read the full request body from an IncomingMessage. */
|
|
39
41
|
declare function readBody(req: http.IncomingMessage): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* A usage tap for {@link relayResponse}'s stream branch. Streaming responses were
|
|
44
|
+
* previously not metered (only the non-stream branch recorded usage), so Codex
|
|
45
|
+
* — which always streams — produced zero usage/dashboard rows. The tap lets each
|
|
46
|
+
* ingress extract the RAW provider usage object from the SSE events it already
|
|
47
|
+
* knows, and {@link onUsage} fires once at stream end so the recorder charges
|
|
48
|
+
* exactly one event per request. Returning the raw object (not normalized)
|
|
49
|
+
* keeps this tap endpoint-agnostic; each recorder normalizes its own shape.
|
|
50
|
+
*/
|
|
51
|
+
interface StreamUsageTap {
|
|
52
|
+
/**
|
|
53
|
+
* Inspect one parsed SSE `data:` JSON event. Return the raw provider usage
|
|
54
|
+
* object it carries (else null/undefined). The LAST non-null return across
|
|
55
|
+
* the whole stream is what {@link onUsage} receives — so for endpoints whose
|
|
56
|
+
* usage arrives piecewise (e.g. Anthropic `message_start`+`message_delta`),
|
|
57
|
+
* merge inside this closure and return the combined value from the terminal
|
|
58
|
+
* event.
|
|
59
|
+
*/
|
|
60
|
+
extractUsage(event: Record<string, unknown>): Record<string, unknown> | null | undefined;
|
|
61
|
+
/** Called once at stream end with the last captured usage (only if any). */
|
|
62
|
+
onUsage(rawUsage: Record<string, unknown>): void;
|
|
63
|
+
}
|
|
40
64
|
/**
|
|
41
65
|
* Relay an already-wire-shaped `Response` to the http `res`.
|
|
42
66
|
* - `text/event-stream` (or `isStream`): pipe the ReadableStream chunk-by-chunk.
|
|
@@ -54,7 +78,16 @@ declare function readBody(req: http.IncomingMessage): Promise<string>;
|
|
|
54
78
|
*
|
|
55
79
|
* @returns the (upstream) JSON body text for non-stream responses, else `null`.
|
|
56
80
|
*/
|
|
57
|
-
declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean, rewriteModel?: string
|
|
81
|
+
declare function relayResponse(res: http.ServerResponse, providerResponse: Response, isStream: boolean, rewriteModel?: string, usageTap?: StreamUsageTap,
|
|
82
|
+
/**
|
|
83
|
+
* Read-only observer invoked with every parsed SSE `data:` event during a
|
|
84
|
+
* streaming relay. Never affects the relayed bytes (it runs on the ORIGINAL
|
|
85
|
+
* line, independent of the model-rewrite / usage-tap paths). Used to detect
|
|
86
|
+
* in-band errors that arrive AFTER a `200` — e.g. a Codex `response.failed`
|
|
87
|
+
* server-overload event. When present, forces the line-based relay path so
|
|
88
|
+
* events are parsed even without a `rewriteModel`/`usageTap`.
|
|
89
|
+
*/
|
|
90
|
+
onSseEvent?: (event: Record<string, unknown>) => void): Promise<string | null>;
|
|
58
91
|
/**
|
|
59
92
|
* Aggregate a streaming Anthropic `text/event-stream` body into ONE buffered
|
|
60
93
|
* Anthropic `message` JSON object — the inverse of the SDK's SSE wire format.
|
|
@@ -73,13 +106,19 @@ declare function relayResponse(res: http.ServerResponse, providerResponse: Respo
|
|
|
73
106
|
declare function aggregateAnthropicSseToJsonBody(response: Response, rewriteModel?: string): Promise<string>;
|
|
74
107
|
/** Write a JSON error response if the headers have not been sent. */
|
|
75
108
|
declare function writeError(res: http.ServerResponse, status: number, message: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Map a strict bound-account failure to a stable structured response. The body
|
|
111
|
+
* carries only the fixed code/reason/message; account ids, tokens, and upstream
|
|
112
|
+
* error text never cross the wire.
|
|
113
|
+
*/
|
|
114
|
+
declare function writeBoundAccountError(res: http.ServerResponse, error: BoundAccountSelectionError): void;
|
|
76
115
|
/**
|
|
77
116
|
* Resolve the FIRST-CHOICE BYO request key for a `buildByoPlan`, threading the
|
|
78
117
|
* ApiKeyPool through TWO gates so 429/529/401/403 failover actually fires on the
|
|
79
118
|
* outbound serving path (omnicross-daemon-parity-poolseam, design D2(b)).
|
|
80
119
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
120
|
+
* Matches the host engine adapter's `resolveApiKeyForProvider` contract so pool
|
|
121
|
+
* failover remains inside the provider layer:
|
|
83
122
|
* - pool present AND a (synthesized outbound) sessionId present →
|
|
84
123
|
* `getKeyForSession(providerId, sessionId)`. This SEEDS `sessionBindings`
|
|
85
124
|
* with the chosen key AND returns that same key, so it becomes the first
|
|
@@ -101,6 +140,6 @@ declare function writeError(res: http.ServerResponse, status: number, message: s
|
|
|
101
140
|
* already-`resolveKey`-resolved string (its loader passes the host resolver),
|
|
102
141
|
* so the pool branch needs no further `$ENV` expansion.
|
|
103
142
|
*/
|
|
104
|
-
declare function resolvePoolBoundKey(deps: ProviderProxyDeps, providerId: string, provider: LLMProvider, sessionId: string | null): Promise<string>;
|
|
143
|
+
declare function resolvePoolBoundKey(deps: ProviderProxyDeps, providerId: string, provider: LLMProvider, sessionId: string | null, preferredKeyId?: string, boundKeyFallbackPolicy?: 'strict' | 'pool'): Promise<string>;
|
|
105
144
|
|
|
106
|
-
export { aggregateAnthropicSseToJsonBody, getAnthropicEndpointTransformer, getGeminiEndpointTransformer, getResponsesEndpointTransformer, getSharedExecutor, readBody, relayResponse, resolvePoolBoundKey, writeError };
|
|
145
|
+
export { type StreamUsageTap, aggregateAnthropicSseToJsonBody, getAnthropicEndpointTransformer, getGeminiEndpointTransformer, getResponsesEndpointTransformer, getSharedExecutor, readBody, relayResponse, resolvePoolBoundKey, writeBoundAccountError, writeError };
|