@omnicross/core 0.4.1 → 0.4.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.
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +11 -184
- package/dist/auth/GeminiCodeAssistProjectResolver.d.cts +41 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.d.ts +41 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.js +12 -185
- package/dist/{chunk-POUTD5AM.cjs → chunk-47E3I5PF.cjs} +10 -3
- package/dist/{chunk-WX2E2G7H.cjs → chunk-4NAMH4UE.cjs} +79 -51
- package/dist/{chunk-LQYS2N47.js → chunk-4RM22ETG.js} +14 -2
- package/dist/{chunk-YEVWA4C7.cjs → chunk-57Y2EA2G.cjs} +6 -5
- package/dist/chunk-6I4SAWCN.js +24 -0
- package/dist/chunk-AFH5CEMF.cjs +38 -0
- package/dist/{chunk-KIQ2HA2A.cjs → chunk-BTSADEX4.cjs} +5 -5
- package/dist/chunk-CGEZQC2G.cjs +67 -0
- package/dist/chunk-E5RCCGE7.cjs +95 -0
- package/dist/chunk-EE7VP4O3.js +230 -0
- package/dist/chunk-F6P4DIBL.js +95 -0
- package/dist/{chunk-BKXC4XM6.cjs → chunk-FORICQ5U.cjs} +15 -11
- package/dist/{chunk-PF7YQBKX.js → chunk-FYPKKMB3.js} +6 -2
- package/dist/chunk-HRBXQ5AC.js +44 -0
- package/dist/{chunk-LFEH7CEO.js → chunk-IDPMD4B7.js} +22 -0
- package/dist/{chunk-UPQIWJIE.cjs → chunk-INY54AYX.cjs} +14 -2
- package/dist/{chunk-QEOV6Y4E.cjs → chunk-J5XMB5KY.cjs} +359 -170
- package/dist/{chunk-C3NPMQTK.js → chunk-JHJRZ75C.js} +14 -10
- package/dist/chunk-K6J2RIEX.js +67 -0
- package/dist/chunk-KSMK45RD.cjs +45 -0
- package/dist/chunk-LL3MZ7O5.cjs +24 -0
- package/dist/{chunk-ECZ3ZE2C.js → chunk-M6PKXP6T.js} +4 -29
- package/dist/{chunk-PAXJGABW.js → chunk-MPFOC7AT.js} +10 -5
- package/dist/{chunk-DKBXDV5U.cjs → chunk-N3MGNLCU.cjs} +49 -44
- package/dist/chunk-NDIBVTBZ.cjs +230 -0
- package/dist/{chunk-5DJSOFEP.js → chunk-NTF7TLT7.js} +1 -1
- package/dist/chunk-ONTTXSRL.js +32 -0
- package/dist/{chunk-HN74IGEO.js → chunk-OXBGNEYR.js} +1 -1
- package/dist/{chunk-5GXOYVLB.js → chunk-QSOHEDKO.js} +44 -39
- package/dist/{chunk-TX3AEV6H.cjs → chunk-RXMF7GNF.cjs} +4 -3
- package/dist/{chunk-5TEWZN5J.js → chunk-SWY2LTMR.js} +277 -88
- package/dist/{chunk-EUZRH544.js → chunk-TKZ3DZS5.js} +10 -3
- package/dist/{chunk-MXI2PWIC.cjs → chunk-UKQHBK4Q.cjs} +1 -32
- package/dist/{chunk-3XVDFRCQ.cjs → chunk-UOOLU64V.cjs} +13 -8
- package/dist/{chunk-ZSA44G7J.cjs → chunk-VFFCV4J6.cjs} +3 -3
- package/dist/{chunk-6DDYNS2B.cjs → chunk-VGBJPHHD.cjs} +36 -14
- package/dist/{chunk-2T6D7LWE.cjs → chunk-VYOBVPNB.cjs} +6 -2
- package/dist/chunk-WYECWQ3J.cjs +44 -0
- package/dist/chunk-X6GHTNDL.cjs +482 -0
- package/dist/chunk-XBQTVRMK.js +45 -0
- package/dist/{chunk-R4VCO2CB.js → chunk-YEHQ5FXZ.js} +28 -0
- package/dist/{chunk-HDXSPXIN.js → chunk-ZBDDPWVQ.js} +4 -3
- package/dist/chunk-ZJJBITUN.js +482 -0
- package/dist/{chunk-QRXOLINS.js → chunk-ZMERU7D3.js} +3 -2
- package/dist/completion/CompletionService.cjs +29 -22
- package/dist/completion/CompletionService.js +28 -21
- package/dist/completion.cjs +29 -22
- package/dist/completion.js +28 -21
- package/dist/image-generation.cjs +2 -2
- package/dist/image-generation.d.cts +2 -2
- package/dist/image-generation.d.ts +2 -2
- package/dist/image-generation.js +1 -1
- package/dist/index.cjs +40 -29
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +40 -29
- package/dist/outbound-api/routeResolver.cjs +3 -3
- package/dist/outbound-api/routeResolver.d.cts +3 -3
- package/dist/outbound-api/routeResolver.d.ts +3 -3
- package/dist/outbound-api/routeResolver.js +2 -2
- package/dist/outbound-api/types.cjs +6 -2
- package/dist/outbound-api/types.d.cts +2 -2
- package/dist/outbound-api/types.d.ts +2 -2
- package/dist/outbound-api/types.js +7 -3
- package/dist/outbound-api.cjs +33 -22
- package/dist/outbound-api.d.cts +4 -4
- package/dist/outbound-api.d.ts +4 -4
- package/dist/outbound-api.js +33 -22
- package/dist/pipeline/AccountAllowanceScheduling.cjs +4 -3
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +4 -4
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +4 -4
- package/dist/pipeline/AccountAllowanceScheduling.js +3 -2
- package/dist/pipeline/AccountAllowanceStore.cjs +2 -2
- package/dist/pipeline/AccountAllowanceStore.js +1 -1
- package/dist/pipeline/AuthSource.d.cts +6 -0
- package/dist/pipeline/AuthSource.d.ts +6 -0
- package/dist/pipeline/SubscriptionAuthSource.cjs +5 -4
- package/dist/pipeline/SubscriptionAuthSource.js +4 -3
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +7 -0
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +7 -0
- package/dist/pipeline/antigravityQuotaFamily.cjs +16 -0
- package/dist/pipeline/antigravityQuotaFamily.d.cts +52 -0
- package/dist/pipeline/antigravityQuotaFamily.d.ts +52 -0
- package/dist/pipeline/antigravityQuotaFamily.js +16 -0
- package/dist/pipeline/upstreamFetch.cjs +3 -3
- package/dist/pipeline/upstreamFetch.js +2 -2
- package/dist/ports.d.cts +2 -2
- package/dist/ports.d.ts +2 -2
- package/dist/provider-proxy/ProviderProxy.cjs +29 -22
- package/dist/provider-proxy/ProviderProxy.js +28 -21
- package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
- package/dist/provider-proxy/identity/codexCliHeaders.js +4 -2
- package/dist/provider-proxy/identity/openCodeGoHeaders.cjs +17 -0
- package/dist/provider-proxy/identity/openCodeGoHeaders.d.cts +71 -0
- package/dist/provider-proxy/identity/openCodeGoHeaders.d.ts +71 -0
- package/dist/provider-proxy/identity/openCodeGoHeaders.js +17 -0
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +29 -22
- package/dist/provider-proxy/ingress/providerProxyShared.js +28 -21
- package/dist/provider-proxy.cjs +29 -22
- package/dist/provider-proxy.d.cts +2 -2
- package/dist/provider-proxy.d.ts +2 -2
- package/dist/provider-proxy.js +28 -21
- package/dist/{routeResolver-STwMz_G4.d.ts → routeResolver-BLTleO4H.d.ts} +1 -1
- package/dist/{routeResolver-Da0yvkL1.d.cts → routeResolver-C2z0pp-q.d.cts} +1 -1
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +2 -2
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +1 -1
- package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -3
- package/dist/transformer/transformers/AnthropicTransformer.js +2 -2
- package/dist/transformer/transformers/AntigravityTransformer.cjs +31 -0
- package/dist/transformer/transformers/AntigravityTransformer.d.cts +104 -0
- package/dist/transformer/transformers/AntigravityTransformer.d.ts +104 -0
- package/dist/transformer/transformers/AntigravityTransformer.js +31 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.cts +2 -1
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.ts +2 -1
- 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/antigravityFailover.cjs +30 -0
- package/dist/transformer/transformers/antigravityFailover.d.cts +52 -0
- package/dist/transformer/transformers/antigravityFailover.d.ts +52 -0
- package/dist/transformer/transformers/antigravityFailover.js +30 -0
- package/dist/transformer/transformers/antigravityIdentity.cjs +24 -0
- package/dist/transformer/transformers/antigravityIdentity.d.cts +76 -0
- package/dist/transformer/transformers/antigravityIdentity.d.ts +76 -0
- package/dist/transformer/transformers/antigravityIdentity.js +24 -0
- package/dist/transformer/transformers.cjs +61 -9
- package/dist/transformer/transformers.d.cts +7 -2
- package/dist/transformer/transformers.d.ts +7 -2
- package/dist/transformer/transformers.js +61 -9
- package/dist/transformer/types.d.cts +11 -0
- package/dist/transformer/types.d.ts +11 -0
- package/dist/transformer.cjs +21 -12
- package/dist/transformer.d.cts +3 -0
- package/dist/transformer.d.ts +3 -0
- package/dist/transformer.js +20 -11
- package/dist/{types-Be-yt_6T.d.cts → types-BVwJQ9ZS.d.cts} +3 -0
- package/dist/{types-D-oHYusb.d.cts → types-C6m-Db26.d.cts} +25 -4
- package/dist/{types-Dvlpjn0d.d.ts → types-Da735j2d.d.ts} +25 -4
- package/dist/{types-Dm4_36V4.d.ts → types-VAHRysdP.d.ts} +3 -0
- package/package.json +2 -2
- package/dist/chunk-4IH4EL7M.cjs +0 -9
- package/dist/chunk-XEKD23J5.js +0 -9
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21;
|
|
2
2
|
|
|
3
|
+
var _chunkNOITAVHAcjs = require('./chunk-NOITAVHA.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
7
|
+
var _chunk47E3I5PFcjs = require('./chunk-47E3I5PF.cjs');
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var _chunkVGBJPHHDcjs = require('./chunk-VGBJPHHD.cjs');
|
|
9
11
|
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
var _chunkCGEZQC2Gcjs = require('./chunk-CGEZQC2G.cjs');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunkBTSADEX4cjs = require('./chunk-BTSADEX4.cjs');
|
|
12
18
|
|
|
13
19
|
|
|
14
20
|
var _chunk7ZHBN75Ncjs = require('./chunk-7ZHBN75N.cjs');
|
|
@@ -17,25 +23,27 @@ var _chunk7ZHBN75Ncjs = require('./chunk-7ZHBN75N.cjs');
|
|
|
17
23
|
var _chunkGBHYAGX3cjs = require('./chunk-GBHYAGX3.cjs');
|
|
18
24
|
|
|
19
25
|
|
|
20
|
-
var _chunkKIQ2HA2Acjs = require('./chunk-KIQ2HA2A.cjs');
|
|
21
26
|
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunkJ3QQ6JS5cjs = require('./chunk-J3QQ6JS5.cjs');
|
|
24
31
|
|
|
25
32
|
|
|
26
33
|
|
|
27
|
-
var _chunkPOUTD5AMcjs = require('./chunk-POUTD5AM.cjs');
|
|
28
34
|
|
|
29
35
|
|
|
30
|
-
var _chunk6DDYNS2Bcjs = require('./chunk-6DDYNS2B.cjs');
|
|
31
36
|
|
|
32
37
|
|
|
38
|
+
var _chunkE4QHVXV5cjs = require('./chunk-E4QHVXV5.cjs');
|
|
39
|
+
|
|
33
40
|
|
|
41
|
+
var _chunkHQP3K7PUcjs = require('./chunk-HQP3K7PU.cjs');
|
|
34
42
|
|
|
35
43
|
|
|
36
44
|
|
|
37
45
|
|
|
38
|
-
var
|
|
46
|
+
var _chunkAFH5CEMFcjs = require('./chunk-AFH5CEMF.cjs');
|
|
39
47
|
|
|
40
48
|
|
|
41
49
|
var _chunkRPII3E6Zcjs = require('./chunk-RPII3E6Z.cjs');
|
|
@@ -45,11 +53,12 @@ var _chunkRPII3E6Zcjs = require('./chunk-RPII3E6Z.cjs');
|
|
|
45
53
|
var _chunk6RPZADX3cjs = require('./chunk-6RPZADX3.cjs');
|
|
46
54
|
|
|
47
55
|
|
|
56
|
+
var _chunkWYECWQ3Jcjs = require('./chunk-WYECWQ3J.cjs');
|
|
48
57
|
|
|
49
58
|
|
|
50
59
|
|
|
51
60
|
|
|
52
|
-
var
|
|
61
|
+
var _chunkUKQHBK4Qcjs = require('./chunk-UKQHBK4Q.cjs');
|
|
53
62
|
|
|
54
63
|
|
|
55
64
|
var _chunkUIBD2YY5cjs = require('./chunk-UIBD2YY5.cjs');
|
|
@@ -78,17 +87,17 @@ var _chunkOTZC4TNHcjs = require('./chunk-OTZC4TNH.cjs');
|
|
|
78
87
|
var _chunk7LRTPNFLcjs = require('./chunk-7LRTPNFL.cjs');
|
|
79
88
|
|
|
80
89
|
|
|
81
|
-
var
|
|
90
|
+
var _chunkRXMF7GNFcjs = require('./chunk-RXMF7GNF.cjs');
|
|
82
91
|
|
|
83
92
|
|
|
84
93
|
var _chunkSVNDB62Dcjs = require('./chunk-SVNDB62D.cjs');
|
|
85
94
|
|
|
86
95
|
|
|
87
|
-
var _chunkBKXC4XM6cjs = require('./chunk-BKXC4XM6.cjs');
|
|
88
96
|
|
|
97
|
+
var _chunk25GXJCEZcjs = require('./chunk-25GXJCEZ.cjs');
|
|
89
98
|
|
|
90
99
|
|
|
91
|
-
var
|
|
100
|
+
var _chunkFORICQ5Ucjs = require('./chunk-FORICQ5U.cjs');
|
|
92
101
|
|
|
93
102
|
|
|
94
103
|
var _chunkFX325I5Qcjs = require('./chunk-FX325I5Q.cjs');
|
|
@@ -109,12 +118,16 @@ var _chunk4YINUUKQcjs = require('./chunk-4YINUUKQ.cjs');
|
|
|
109
118
|
|
|
110
119
|
|
|
111
120
|
|
|
112
|
-
var
|
|
121
|
+
var _chunk57Y2EA2Gcjs = require('./chunk-57Y2EA2G.cjs');
|
|
113
122
|
|
|
114
123
|
|
|
115
124
|
var _chunkQBZJ7P2Tcjs = require('./chunk-QBZJ7P2T.cjs');
|
|
116
125
|
|
|
117
126
|
|
|
127
|
+
|
|
128
|
+
var _chunkLL3MZ7O5cjs = require('./chunk-LL3MZ7O5.cjs');
|
|
129
|
+
|
|
130
|
+
|
|
118
131
|
var _chunkJMJBSACDcjs = require('./chunk-JMJBSACD.cjs');
|
|
119
132
|
|
|
120
133
|
|
|
@@ -134,13 +147,16 @@ var _chunkA2YMUCBTcjs = require('./chunk-A2YMUCBT.cjs');
|
|
|
134
147
|
var _chunkGDIXXKF2cjs = require('./chunk-GDIXXKF2.cjs');
|
|
135
148
|
|
|
136
149
|
|
|
150
|
+
var _chunkNDIBVTBZcjs = require('./chunk-NDIBVTBZ.cjs');
|
|
151
|
+
|
|
152
|
+
|
|
137
153
|
var _chunkIUL4VWNUcjs = require('./chunk-IUL4VWNU.cjs');
|
|
138
154
|
|
|
139
155
|
|
|
140
|
-
var
|
|
156
|
+
var _chunkVFFCV4J6cjs = require('./chunk-VFFCV4J6.cjs');
|
|
141
157
|
|
|
142
158
|
|
|
143
|
-
var
|
|
159
|
+
var _chunkVYOBVPNBcjs = require('./chunk-VYOBVPNB.cjs');
|
|
144
160
|
|
|
145
161
|
|
|
146
162
|
var _chunkNKVZ6Z3Ycjs = require('./chunk-NKVZ6Z3Y.cjs');
|
|
@@ -150,7 +166,7 @@ var _chunkNKVZ6Z3Ycjs = require('./chunk-NKVZ6Z3Y.cjs');
|
|
|
150
166
|
|
|
151
167
|
|
|
152
168
|
|
|
153
|
-
var
|
|
169
|
+
var _chunkINY54AYXcjs = require('./chunk-INY54AYX.cjs');
|
|
154
170
|
|
|
155
171
|
|
|
156
172
|
|
|
@@ -501,12 +517,12 @@ function getResponsesEndpointTransformer() {
|
|
|
501
517
|
}
|
|
502
518
|
var sharedAnthropic = null;
|
|
503
519
|
function getAnthropicEndpointTransformer() {
|
|
504
|
-
if (!sharedAnthropic) sharedAnthropic = new (0,
|
|
520
|
+
if (!sharedAnthropic) sharedAnthropic = new (0, _chunk47E3I5PFcjs.AnthropicTransformer)();
|
|
505
521
|
return sharedAnthropic;
|
|
506
522
|
}
|
|
507
523
|
var sharedGemini = null;
|
|
508
524
|
function getGeminiEndpointTransformer() {
|
|
509
|
-
if (!sharedGemini) sharedGemini = new (0,
|
|
525
|
+
if (!sharedGemini) sharedGemini = new (0, _chunkBTSADEX4cjs.GeminiTransformer)();
|
|
510
526
|
return sharedGemini;
|
|
511
527
|
}
|
|
512
528
|
function readBody(req, signal) {
|
|
@@ -1082,9 +1098,9 @@ function extractClaudeClientHeaders(reqHeaders) {
|
|
|
1082
1098
|
const out = {};
|
|
1083
1099
|
for (const [rawKey, rawVal] of Object.entries(reqHeaders)) {
|
|
1084
1100
|
const key = rawKey.toLowerCase();
|
|
1085
|
-
if (
|
|
1101
|
+
if (_chunkUKQHBK4Qcjs.NEVER_FORWARD_HEADERS.has(key)) continue;
|
|
1086
1102
|
if (!CLAUDE_FORWARD_ALLOWLIST.has(key) && !key.startsWith(STAINLESS_PREFIX)) continue;
|
|
1087
|
-
const value =
|
|
1103
|
+
const value = _chunkUKQHBK4Qcjs.flattenHeaderValue.call(void 0, rawVal);
|
|
1088
1104
|
if (value !== void 0) out[key] = value;
|
|
1089
1105
|
}
|
|
1090
1106
|
return out;
|
|
@@ -1535,17 +1551,17 @@ async function buildSubscriptionPlan(res, route, deps, anthropicBody, routeModel
|
|
|
1535
1551
|
scenario = mapped.scenario;
|
|
1536
1552
|
}
|
|
1537
1553
|
const sessionKey = _chunkJ3QQ6JS5cjs.deriveSubscriptionSessionKey.call(void 0, anthropicBody);
|
|
1538
|
-
const plan = buildSubscriptionIterationPlan(profile, route, deps, resolvedModel, isStream, scenario, sessionKey);
|
|
1554
|
+
const plan = await buildSubscriptionIterationPlan(profile, route, deps, resolvedModel, isStream, scenario, sessionKey);
|
|
1539
1555
|
if (!plan) {
|
|
1540
1556
|
writeError(res, 502, "Subscription profile is missing resolveUpstreamUrl");
|
|
1541
1557
|
return null;
|
|
1542
1558
|
}
|
|
1543
1559
|
return plan;
|
|
1544
1560
|
}
|
|
1545
|
-
function buildSubscriptionIterationPlan(profile, route, deps, resolvedModel, isStream, scenario, sessionKey) {
|
|
1561
|
+
async function buildSubscriptionIterationPlan(profile, route, deps, resolvedModel, isStream, scenario, sessionKey) {
|
|
1546
1562
|
const upstreamUrl = _optionalChain([profile, 'access', _103 => _103.resolveUpstreamUrl, 'optionalCall', _104 => _104(resolvedModel, route.subscriptionConfig)]);
|
|
1547
1563
|
if (!upstreamUrl) return null;
|
|
1548
|
-
const auth = _nullishCoalesce(route.auth, () => ( new (0,
|
|
1564
|
+
const auth = _nullishCoalesce(route.auth, () => ( new (0, _chunkRXMF7GNFcjs.SubscriptionAuthSource)(profile)));
|
|
1549
1565
|
const sameFormat = profile.mode === "pass-through" || upstreamUrl.endsWith("/v1/messages");
|
|
1550
1566
|
const overrideNames = _optionalChain([profile, 'access', _105 => _105.resolveProviderTransformerNames, 'optionalCall', _106 => _106(
|
|
1551
1567
|
resolvedModel,
|
|
@@ -1563,11 +1579,30 @@ function buildSubscriptionIterationPlan(profile, route, deps, resolvedModel, isS
|
|
|
1563
1579
|
apiKey: "",
|
|
1564
1580
|
models: [resolvedModel]
|
|
1565
1581
|
};
|
|
1582
|
+
let antigravityAccountId;
|
|
1583
|
+
if (profile.authStrategy.providerId === "antigravity") {
|
|
1584
|
+
const headers = {};
|
|
1585
|
+
await auth.applyHeaders(headers, {
|
|
1586
|
+
upstreamUrl,
|
|
1587
|
+
model: resolvedModel,
|
|
1588
|
+
sessionKey,
|
|
1589
|
+
preferredAccountId: route.preferredAccountId,
|
|
1590
|
+
preferredAccountGroup: route.preferredAccountGroup,
|
|
1591
|
+
boundAccountFallbackPolicy: route.boundAccountFallbackPolicy,
|
|
1592
|
+
reportSelection: (accountId) => {
|
|
1593
|
+
antigravityAccountId = accountId;
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
const bearer = (_nullishCoalesce(_nullishCoalesce(headers.Authorization, () => ( headers.authorization)), () => ( ""))).replace(/^Bearer\s+/i, "").trim();
|
|
1597
|
+
if (bearer) {
|
|
1598
|
+
transformerProvider.geminiProject = await _chunkNDIBVTBZcjs.getAntigravityProjectResolver.call(void 0, ).resolveProject(bearer);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1566
1601
|
return {
|
|
1567
1602
|
auth,
|
|
1568
|
-
preferredAccountId: route.preferredAccountId,
|
|
1569
|
-
preferredAccountGroup: route.preferredAccountGroup,
|
|
1570
|
-
boundAccountFallbackPolicy: route.boundAccountFallbackPolicy,
|
|
1603
|
+
preferredAccountId: _nullishCoalesce(antigravityAccountId, () => ( route.preferredAccountId)),
|
|
1604
|
+
preferredAccountGroup: antigravityAccountId ? void 0 : route.preferredAccountGroup,
|
|
1605
|
+
boundAccountFallbackPolicy: antigravityAccountId ? "strict" : route.boundAccountFallbackPolicy,
|
|
1571
1606
|
chain,
|
|
1572
1607
|
transformerProvider,
|
|
1573
1608
|
resolvedModel,
|
|
@@ -1631,7 +1666,7 @@ function collectText(value) {
|
|
|
1631
1666
|
function proxyProviderId(plan) {
|
|
1632
1667
|
return plan.isSubscription ? plan.transformerProvider.name : "byo";
|
|
1633
1668
|
}
|
|
1634
|
-
async function runPipeline(anthropicBody, plan, reportSelection, signal) {
|
|
1669
|
+
async function runPipeline(anthropicBody, plan, reportSelection, signal, callerOpenCodeSession) {
|
|
1635
1670
|
const executor = getSharedExecutor();
|
|
1636
1671
|
const endpointTransformer = getAnthropicEndpointTransformer();
|
|
1637
1672
|
const { auth, chain, transformerProvider, resolvedModel, isStream, resolveUrl, upstreamUrl } = plan;
|
|
@@ -1641,6 +1676,7 @@ async function runPipeline(anthropicBody, plan, reportSelection, signal) {
|
|
|
1641
1676
|
upstreamUrl,
|
|
1642
1677
|
model: resolvedModel,
|
|
1643
1678
|
sessionKey: plan.sessionKey,
|
|
1679
|
+
callerOpenCodeSession,
|
|
1644
1680
|
preferredAccountId: plan.preferredAccountId,
|
|
1645
1681
|
preferredAccountGroup: plan.preferredAccountGroup,
|
|
1646
1682
|
boundAccountFallbackPolicy: plan.boundAccountFallbackPolicy,
|
|
@@ -1649,6 +1685,10 @@ async function runPipeline(anthropicBody, plan, reportSelection, signal) {
|
|
|
1649
1685
|
_optionalChain([reportSelection, 'optionalCall', _107 => _107(accountId, isActive)]);
|
|
1650
1686
|
}
|
|
1651
1687
|
});
|
|
1688
|
+
if (plan.transformerProvider.name === "antigravity") {
|
|
1689
|
+
const bearer = (_nullishCoalesce(_nullishCoalesce(authHeaders.Authorization, () => ( authHeaders.authorization)), () => ( ""))).replace(/^Bearer\s+/i, "").trim();
|
|
1690
|
+
if (bearer) transformerProvider.geminiProject = await _chunkNDIBVTBZcjs.getAntigravityProjectResolver.call(void 0, ).resolveProject(bearer);
|
|
1691
|
+
}
|
|
1652
1692
|
let rawStatus = null;
|
|
1653
1693
|
let activityRecordId;
|
|
1654
1694
|
const { response } = await _chunkKQBLZMP6cjs.executeProviderCall.call(void 0, {
|
|
@@ -1669,7 +1709,7 @@ async function runPipeline(anthropicBody, plan, reportSelection, signal) {
|
|
|
1669
1709
|
},
|
|
1670
1710
|
fetchFn: (url, headers, body) => {
|
|
1671
1711
|
console.info(`[ProviderProxy:anthropic] -> ${url} model=${resolvedModel} stream=${isStream}`);
|
|
1672
|
-
return
|
|
1712
|
+
return _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
1673
1713
|
url,
|
|
1674
1714
|
{ method: "POST", headers, body: JSON.stringify(body), signal },
|
|
1675
1715
|
{
|
|
@@ -1702,6 +1742,7 @@ async function runSubscriptionSameFormatFetch(rawBody, plan, reportSelection, op
|
|
|
1702
1742
|
upstreamUrl: plan.upstreamUrl,
|
|
1703
1743
|
model: plan.resolvedModel,
|
|
1704
1744
|
sessionKey: plan.sessionKey,
|
|
1745
|
+
callerOpenCodeSession: _nullishCoalesce(options.callerOpenCodeSession, () => ( void 0)),
|
|
1705
1746
|
preferredAccountId: plan.preferredAccountId,
|
|
1706
1747
|
preferredAccountGroup: plan.preferredAccountGroup,
|
|
1707
1748
|
boundAccountFallbackPolicy: plan.boundAccountFallbackPolicy,
|
|
@@ -1722,10 +1763,10 @@ async function runSubscriptionSameFormatFetch(rawBody, plan, reportSelection, op
|
|
|
1722
1763
|
);
|
|
1723
1764
|
}
|
|
1724
1765
|
if (isClaudeSubscription) {
|
|
1725
|
-
|
|
1726
|
-
|
|
1766
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, _nullishCoalesce(options.callerClientHeaders, () => ( {})));
|
|
1767
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, DEFAULT_CLAUDE_CODE_HEADERS);
|
|
1727
1768
|
}
|
|
1728
|
-
|
|
1769
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, { "anthropic-version": DEFAULT_ANTHROPIC_VERSION });
|
|
1729
1770
|
headers["accept-encoding"] = FORCED_ACCEPT_ENCODING;
|
|
1730
1771
|
const applyRemap = remappedModel !== void 0 && outboundRemapApplies(plan);
|
|
1731
1772
|
const outboundBody = applyRemap ? rewriteBodyModel(rawBody, remappedModel) : rawBody;
|
|
@@ -1733,13 +1774,13 @@ async function runSubscriptionSameFormatFetch(rawBody, plan, reportSelection, op
|
|
|
1733
1774
|
if (isClaudeSubscription) {
|
|
1734
1775
|
headers["anthropic-beta"] = buildAnthropicBeta(outboundModel, options.callerAnthropicBeta);
|
|
1735
1776
|
} else if (options.callerAnthropicBeta) {
|
|
1736
|
-
|
|
1777
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, { "anthropic-beta": options.callerAnthropicBeta });
|
|
1737
1778
|
}
|
|
1738
1779
|
console.info(
|
|
1739
1780
|
`[ProviderProxy:anthropic] (subscription same-format) -> ${_nullishCoalesce(urlOverride, () => ( plan.upstreamUrl))} model=${outboundModel} stream=${plan.isStream}`
|
|
1740
1781
|
);
|
|
1741
1782
|
let activityRecordId;
|
|
1742
|
-
const response = await
|
|
1783
|
+
const response = await _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
1743
1784
|
_nullishCoalesce(urlOverride, () => ( plan.upstreamUrl)),
|
|
1744
1785
|
{ method: "POST", headers, body: outboundBody, signal: options.signal },
|
|
1745
1786
|
{
|
|
@@ -1782,7 +1823,13 @@ async function runSubscriptionAttemptWith401Retry(anthropicBody, relayBody, plan
|
|
|
1782
1823
|
const reportSelection = (accountId) => {
|
|
1783
1824
|
selectedAccountId = accountId;
|
|
1784
1825
|
};
|
|
1785
|
-
const runOnce = () => plan.sameFormat ? runSubscriptionSameFormatFetch(relayBody, plan, reportSelection, options) : runPipeline(
|
|
1826
|
+
const runOnce = () => plan.sameFormat ? runSubscriptionSameFormatFetch(relayBody, plan, reportSelection, options) : runPipeline(
|
|
1827
|
+
anthropicBody,
|
|
1828
|
+
plan,
|
|
1829
|
+
reportSelection,
|
|
1830
|
+
options.signal,
|
|
1831
|
+
_nullishCoalesce(options.callerOpenCodeSession, () => ( void 0))
|
|
1832
|
+
);
|
|
1786
1833
|
const first = await runOnce();
|
|
1787
1834
|
let result = first;
|
|
1788
1835
|
if (first.rawStatus === 401) {
|
|
@@ -1870,8 +1917,27 @@ async function runPipelineWithSubscriptionRetry(anthropicBody, rawBody, initialP
|
|
|
1870
1917
|
};
|
|
1871
1918
|
if (!_optionalChain([profile, 'optionalAccess', _118 => _118.nextFallback]) || scenario === void 0) {
|
|
1872
1919
|
const loneBody = initialPlan.sameFormat ? anthropicBody : await prepareTranslateAttempt(anthropicBody);
|
|
1873
|
-
|
|
1920
|
+
let loneOutcome = await runSubscriptionAttemptOutcome(loneBody, rawBody, initialPlan, options);
|
|
1874
1921
|
if (!clientGone()) recordBreakerOutcome(profile, initialPlan.resolvedModel, outcomeStatus(loneOutcome));
|
|
1922
|
+
if (initialPlan.transformerProvider.name === "antigravity" && !clientGone() && outcomeStatus(loneOutcome) !== null && !is2xxStatus(outcomeStatus(loneOutcome))) {
|
|
1923
|
+
const bodyText = loneOutcome.kind === "result" ? await readBoundedBody(loneOutcome.result.response) : void 0;
|
|
1924
|
+
const failoverUrl = _chunkCGEZQC2Gcjs.maybeAntigravityFailoverUrl.call(void 0,
|
|
1925
|
+
initialPlan.upstreamUrl,
|
|
1926
|
+
outcomeStatus(loneOutcome),
|
|
1927
|
+
bodyText
|
|
1928
|
+
);
|
|
1929
|
+
if (failoverUrl) {
|
|
1930
|
+
console.warn(
|
|
1931
|
+
`[ProviderProxy:anthropic] antigravity endpoint failover -> ${failoverUrl} after ${outcomeStatus(loneOutcome)}`
|
|
1932
|
+
);
|
|
1933
|
+
if (loneOutcome.kind === "result") await cancelDiscardedResponse(loneOutcome.result.response);
|
|
1934
|
+
const failoverPlan = withUpstreamUrl(initialPlan, failoverUrl);
|
|
1935
|
+
loneOutcome = await runSubscriptionAttemptOutcome(loneBody, rawBody, failoverPlan, options);
|
|
1936
|
+
if (!clientGone()) {
|
|
1937
|
+
recordBreakerOutcome(profile, failoverPlan.resolvedModel, outcomeStatus(loneOutcome));
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1875
1941
|
return settleOutcome(loneOutcome);
|
|
1876
1942
|
}
|
|
1877
1943
|
const attempted = [];
|
|
@@ -1881,7 +1947,7 @@ async function runPipelineWithSubscriptionRetry(anthropicBody, rawBody, initialP
|
|
|
1881
1947
|
if (profile.allowModel && !profile.allowModel(initialPlan.resolvedModel)) {
|
|
1882
1948
|
attempted.push(initialPlan.resolvedModel);
|
|
1883
1949
|
const firstAdmitting = profile.nextFallback(scenario, attempted, route.subscriptionConfig);
|
|
1884
|
-
const gatedPlan = firstAdmitting ? buildSubscriptionIterationPlan(profile, route, deps, firstAdmitting.modelId, initialPlan.isStream, scenario, initialPlan.sessionKey) : null;
|
|
1950
|
+
const gatedPlan = firstAdmitting ? await buildSubscriptionIterationPlan(profile, route, deps, firstAdmitting.modelId, initialPlan.isStream, scenario, initialPlan.sessionKey) : null;
|
|
1885
1951
|
if (firstAdmitting && gatedPlan) {
|
|
1886
1952
|
console.warn(
|
|
1887
1953
|
`[ProviderProxy:anthropic] subscription primary ${initialPlan.resolvedModel} circuit open -> first admitting fallback ${firstAdmitting.modelId}`
|
|
@@ -1907,7 +1973,7 @@ async function runPipelineWithSubscriptionRetry(anthropicBody, rawBody, initialP
|
|
|
1907
1973
|
if (!isFallbackEligibleStatus(outcomeStatus(outcome))) return settleOutcome(outcome);
|
|
1908
1974
|
const next = profile.nextFallback(scenario, attempted, route.subscriptionConfig);
|
|
1909
1975
|
if (!next) return settleOutcome(outcome);
|
|
1910
|
-
const nextPlan = buildSubscriptionIterationPlan(
|
|
1976
|
+
const nextPlan = await buildSubscriptionIterationPlan(
|
|
1911
1977
|
profile,
|
|
1912
1978
|
route,
|
|
1913
1979
|
deps,
|
|
@@ -1931,6 +1997,28 @@ async function runPipelineWithSubscriptionRetry(anthropicBody, rawBody, initialP
|
|
|
1931
1997
|
}
|
|
1932
1998
|
return settleOutcome(outcome);
|
|
1933
1999
|
}
|
|
2000
|
+
function is2xxStatus(status) {
|
|
2001
|
+
return status !== null && status >= 200 && status < 300;
|
|
2002
|
+
}
|
|
2003
|
+
function withUpstreamUrl(plan, url) {
|
|
2004
|
+
return {
|
|
2005
|
+
...plan,
|
|
2006
|
+
upstreamUrl: url,
|
|
2007
|
+
resolveUrl: (config) => {
|
|
2008
|
+
const resolved = plan.resolveUrl(config);
|
|
2009
|
+
if (typeof resolved === "string" && resolved.includes("googleapis.com")) {
|
|
2010
|
+
try {
|
|
2011
|
+
const original = new URL(resolved);
|
|
2012
|
+
const target = new URL(url);
|
|
2013
|
+
return `${target.origin}${original.pathname}${original.search}`;
|
|
2014
|
+
} catch (e18) {
|
|
2015
|
+
return url;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
return resolved || url;
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
1934
2022
|
var MAX_FALLBACK_ATTEMPTS = 3;
|
|
1935
2023
|
|
|
1936
2024
|
// src/provider-proxy/ingress/anthropicPdfText.ts
|
|
@@ -1943,7 +2031,7 @@ var MAX_CMAP_ENTRIES = 65536;
|
|
|
1943
2031
|
function extractPdfText(base64, budgetMs = DEFAULT_PDF_TEXT_BUDGET_MS) {
|
|
1944
2032
|
try {
|
|
1945
2033
|
return extract(Buffer.from(base64, "base64"), budgetMs);
|
|
1946
|
-
} catch (
|
|
2034
|
+
} catch (e19) {
|
|
1947
2035
|
return { reason: "no-text-layer" };
|
|
1948
2036
|
}
|
|
1949
2037
|
}
|
|
@@ -2287,13 +2375,13 @@ function recordResponsesNonStreamUsage(recorder, bodyText, attribution) {
|
|
|
2287
2375
|
parsed.usage,
|
|
2288
2376
|
attribution
|
|
2289
2377
|
);
|
|
2290
|
-
} catch (
|
|
2378
|
+
} catch (e20) {
|
|
2291
2379
|
}
|
|
2292
2380
|
}
|
|
2293
2381
|
function recordResponsesStreamUsage(recorder, rawUsage, attribution) {
|
|
2294
2382
|
try {
|
|
2295
2383
|
emitResponsesUsageRecord(recorder, rawUsage, attribution);
|
|
2296
|
-
} catch (
|
|
2384
|
+
} catch (e21) {
|
|
2297
2385
|
}
|
|
2298
2386
|
}
|
|
2299
2387
|
|
|
@@ -2333,12 +2421,12 @@ function parseCodexUsageLimitErrorPayload(bodyText) {
|
|
|
2333
2421
|
...resetsAtMs !== void 0 ? { resetsAtMs } : {},
|
|
2334
2422
|
...typeof planType === "string" && planType ? { planType } : {}
|
|
2335
2423
|
};
|
|
2336
|
-
} catch (
|
|
2424
|
+
} catch (e22) {
|
|
2337
2425
|
return null;
|
|
2338
2426
|
}
|
|
2339
2427
|
}
|
|
2340
2428
|
function deadlineFromAllowanceSnapshot(accountId, now) {
|
|
2341
|
-
const snapshot =
|
|
2429
|
+
const snapshot = _chunkVYOBVPNBcjs.getSharedAccountAllowanceStore.call(void 0, ).get(PROVIDER_ID, accountId, now);
|
|
2342
2430
|
if (!snapshot) return void 0;
|
|
2343
2431
|
const candidates = snapshot.windows.filter(
|
|
2344
2432
|
(w) => typeof w.usedPercent === "number" && w.usedPercent >= QUOTA_EXHAUSTED_PERCENT && typeof w.resetsAt === "string"
|
|
@@ -2399,7 +2487,7 @@ function normalizeHostedImageState(value) {
|
|
|
2399
2487
|
hasImageContext: value.hasImageContext,
|
|
2400
2488
|
pendingReceipts: Object.freeze(pendingReceipts)
|
|
2401
2489
|
});
|
|
2402
|
-
} catch (
|
|
2490
|
+
} catch (e23) {
|
|
2403
2491
|
throw new TypeError(INVALID_HOSTED_IMAGE_METADATA);
|
|
2404
2492
|
}
|
|
2405
2493
|
}
|
|
@@ -2498,7 +2586,7 @@ function isResponsesCreateUrl(value) {
|
|
|
2498
2586
|
if (!value) return false;
|
|
2499
2587
|
try {
|
|
2500
2588
|
return new URL(value).pathname.replace(/\/+$/, "").endsWith("/responses");
|
|
2501
|
-
} catch (
|
|
2589
|
+
} catch (e24) {
|
|
2502
2590
|
return false;
|
|
2503
2591
|
}
|
|
2504
2592
|
}
|
|
@@ -2668,7 +2756,7 @@ function deriveResponsesCompactUrl(createUrl) {
|
|
|
2668
2756
|
let url;
|
|
2669
2757
|
try {
|
|
2670
2758
|
url = new URL(createUrl);
|
|
2671
|
-
} catch (
|
|
2759
|
+
} catch (e25) {
|
|
2672
2760
|
throw new (0, _chunkG4CZIUIBcjs.OpenAIOperationError)({
|
|
2673
2761
|
status: 502,
|
|
2674
2762
|
code: "invalid_upstream_url",
|
|
@@ -2802,7 +2890,7 @@ async function buildSubscriptionPlan2(route, deps, resolved, resolvedModel, isSt
|
|
|
2802
2890
|
const profile = route.subscriptionProfile;
|
|
2803
2891
|
const upstreamUrl = resolved.upstreamUrl;
|
|
2804
2892
|
const affinityAccountId = _optionalChain([affinity, 'optionalAccess', _148 => _148.credential, 'access', _149 => _149.kind]) === "subscription-account" ? affinity.credential.id : void 0;
|
|
2805
|
-
const auth = _nullishCoalesce(route.auth, () => ( new (0,
|
|
2893
|
+
const auth = _nullishCoalesce(route.auth, () => ( new (0, _chunkRXMF7GNFcjs.SubscriptionAuthSource)(profile)));
|
|
2806
2894
|
const chain = resolved.profile === "native" ? { providerTransformers: [], modelTransformers: [] } : _chunkNYUNU75Acjs.resolveSubscriptionChain.call(void 0,
|
|
2807
2895
|
profile,
|
|
2808
2896
|
deps.llmConfig.getTransformerService(),
|
|
@@ -2822,14 +2910,27 @@ async function buildSubscriptionPlan2(route, deps, resolved, resolvedModel, isSt
|
|
|
2822
2910
|
boundAccountFallbackPolicy: affinity ? "strict" : route.boundAccountFallbackPolicy
|
|
2823
2911
|
});
|
|
2824
2912
|
}
|
|
2913
|
+
let antigravityAccountId;
|
|
2914
|
+
if (profile.authStrategy.providerId === "antigravity") {
|
|
2915
|
+
transformerProvider.geminiProject = await resolveAntigravityProjectThreaded(profile, {
|
|
2916
|
+
sessionKey,
|
|
2917
|
+
resolvedModel,
|
|
2918
|
+
reportSelection: (accountId) => {
|
|
2919
|
+
antigravityAccountId = accountId;
|
|
2920
|
+
},
|
|
2921
|
+
preferredAccountId: _nullishCoalesce(affinityAccountId, () => ( route.preferredAccountId)),
|
|
2922
|
+
preferredAccountGroup: affinity ? void 0 : route.preferredAccountGroup,
|
|
2923
|
+
boundAccountFallbackPolicy: affinity ? "strict" : route.boundAccountFallbackPolicy
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2825
2926
|
return {
|
|
2826
2927
|
profile: resolved.profile,
|
|
2827
2928
|
auth,
|
|
2828
2929
|
sessionKey,
|
|
2829
2930
|
sessionSource,
|
|
2830
|
-
preferredAccountId: _nullishCoalesce(affinityAccountId, () => ( route.preferredAccountId)),
|
|
2831
|
-
preferredAccountGroup: affinity ? void 0 : route.preferredAccountGroup,
|
|
2832
|
-
boundAccountFallbackPolicy: affinity ? "strict" : route.boundAccountFallbackPolicy,
|
|
2931
|
+
preferredAccountId: _nullishCoalesce(_nullishCoalesce(antigravityAccountId, () => ( affinityAccountId)), () => ( route.preferredAccountId)),
|
|
2932
|
+
preferredAccountGroup: antigravityAccountId || affinity ? void 0 : route.preferredAccountGroup,
|
|
2933
|
+
boundAccountFallbackPolicy: antigravityAccountId || affinity ? "strict" : route.boundAccountFallbackPolicy,
|
|
2833
2934
|
chain,
|
|
2834
2935
|
transformerProvider,
|
|
2835
2936
|
resolvedModel,
|
|
@@ -2838,7 +2939,10 @@ async function buildSubscriptionPlan2(route, deps, resolved, resolvedModel, isSt
|
|
|
2838
2939
|
upstreamUrl,
|
|
2839
2940
|
proxyProviderId: profile.authStrategy.providerId,
|
|
2840
2941
|
providerIdentity: resolved.providerIdentity,
|
|
2841
|
-
callerClientHeaders: profile.authStrategy.providerId === "codex" ?
|
|
2942
|
+
callerClientHeaders: profile.authStrategy.providerId === "codex" ? _chunkAFH5CEMFcjs.extractCodexClientHeaders.call(void 0, requestHeaders) : void 0,
|
|
2943
|
+
// opencodego-egress-identity: the caller's own session id, forwarded
|
|
2944
|
+
// verbatim to opencode.ai (the codex callerClientHeaders precedent).
|
|
2945
|
+
callerOpenCodeSession: profile.authStrategy.providerId === "opencodego" ? _chunkWYECWQ3Jcjs.extractOpenCodeSessionHeader.call(void 0, requestHeaders) : void 0,
|
|
2842
2946
|
statefulContinuation: !!affinity,
|
|
2843
2947
|
credential: affinityAccountId ? { kind: "subscription-account", id: affinityAccountId } : { kind: "subscription-account", id: "pending-selection" }
|
|
2844
2948
|
};
|
|
@@ -2850,6 +2954,13 @@ async function resolveGeminiProject(profile, hints) {
|
|
|
2850
2954
|
if (!accessToken) return void 0;
|
|
2851
2955
|
return _optionalChain([_chunkR3HK6R4Bcjs.getGeminiCodeAssistResolver.call(void 0, ), 'optionalAccess', _150 => _150.resolveProject, 'call', _151 => _151(accessToken)]);
|
|
2852
2956
|
}
|
|
2957
|
+
async function resolveAntigravityProjectThreaded(profile, hints) {
|
|
2958
|
+
const headers = {};
|
|
2959
|
+
await profile.authStrategy.applyHeaders(headers, hints);
|
|
2960
|
+
const accessToken = (_nullishCoalesce(_nullishCoalesce(headers.Authorization, () => ( headers.authorization)), () => ( ""))).replace(/^Bearer\s+/i, "").trim();
|
|
2961
|
+
if (!accessToken) return void 0;
|
|
2962
|
+
return _chunkNDIBVTBZcjs.getAntigravityProjectResolver.call(void 0, ).resolveProject(accessToken);
|
|
2963
|
+
}
|
|
2853
2964
|
async function executeResponsesUpstream(body, plan, operation, signal) {
|
|
2854
2965
|
const run = () => plan.profile === "native" ? runNative(body, plan, operation, signal) : runReduced(body, plan, signal);
|
|
2855
2966
|
let result = await run();
|
|
@@ -2882,6 +2993,7 @@ async function applyPlanAuth(body, plan) {
|
|
|
2882
2993
|
upstreamUrl: plan.upstreamUrl,
|
|
2883
2994
|
model: plan.resolvedModel,
|
|
2884
2995
|
sessionKey: plan.sessionKey,
|
|
2996
|
+
callerOpenCodeSession: plan.callerOpenCodeSession,
|
|
2885
2997
|
preferredAccountId: plan.preferredAccountId,
|
|
2886
2998
|
preferredAccountGroup: plan.preferredAccountGroup,
|
|
2887
2999
|
boundAccountFallbackPolicy: plan.boundAccountFallbackPolicy,
|
|
@@ -2896,18 +3008,18 @@ async function applyPlanAuth(body, plan) {
|
|
|
2896
3008
|
}
|
|
2897
3009
|
function decorateCodexHeaders(headers, plan) {
|
|
2898
3010
|
if (plan.proxyProviderId !== "codex") return;
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
3011
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, _nullishCoalesce(plan.callerClientHeaders, () => ( {})));
|
|
3012
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, _chunkAFH5CEMFcjs.DEFAULT_CODEX_CLI_HEADERS);
|
|
3013
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, { accept: _chunkAFH5CEMFcjs.codexAcceptHeader.call(void 0, plan.isStream) });
|
|
2902
3014
|
}
|
|
2903
3015
|
async function runNative(body, plan, operation, signal) {
|
|
2904
3016
|
throwIfResponsesAborted(signal);
|
|
2905
3017
|
const { headers, accountId, actualModel } = await applyPlanAuth(body, plan);
|
|
2906
|
-
|
|
3018
|
+
_chunkUKQHBK4Qcjs.fillMissingHeaders.call(void 0, headers, { "content-type": "application/json" });
|
|
2907
3019
|
decorateCodexHeaders(headers, plan);
|
|
2908
3020
|
const url = operation === "compact" ? deriveResponsesCompactUrl(plan.upstreamUrl) : plan.upstreamUrl;
|
|
2909
3021
|
let activityRecordId;
|
|
2910
|
-
const response = await
|
|
3022
|
+
const response = await _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
2911
3023
|
url,
|
|
2912
3024
|
{ method: "POST", headers, body: JSON.stringify(body), signal },
|
|
2913
3025
|
{
|
|
@@ -2936,6 +3048,10 @@ async function runNative(body, plan, operation, signal) {
|
|
|
2936
3048
|
async function runReduced(body, plan, signal) {
|
|
2937
3049
|
throwIfResponsesAborted(signal);
|
|
2938
3050
|
const { headers: authHeaders, accountId, actualModel } = await applyPlanAuth(body, plan);
|
|
3051
|
+
if (plan.proxyProviderId === "antigravity") {
|
|
3052
|
+
const bearer = (_nullishCoalesce(_nullishCoalesce(authHeaders.Authorization, () => ( authHeaders.authorization)), () => ( ""))).replace(/^Bearer\s+/i, "").trim();
|
|
3053
|
+
if (bearer) plan.transformerProvider.geminiProject = await _chunkNDIBVTBZcjs.getAntigravityProjectResolver.call(void 0, ).resolveProject(bearer);
|
|
3054
|
+
}
|
|
2939
3055
|
let rawStatus = null;
|
|
2940
3056
|
let activityRecordId;
|
|
2941
3057
|
const { response } = await _chunkKQBLZMP6cjs.executeProviderCall.call(void 0, {
|
|
@@ -2955,26 +3071,28 @@ async function runReduced(body, plan, signal) {
|
|
|
2955
3071
|
decorateCodexHeaders(headers, plan);
|
|
2956
3072
|
return headers;
|
|
2957
3073
|
},
|
|
2958
|
-
fetchFn: (url, headers, requestBody) =>
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3074
|
+
fetchFn: async (url, headers, requestBody) => {
|
|
3075
|
+
const send = (target) => _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
3076
|
+
target,
|
|
3077
|
+
{ method: "POST", headers, body: JSON.stringify(requestBody), signal },
|
|
3078
|
+
{
|
|
3079
|
+
providerId: plan.proxyProviderId,
|
|
3080
|
+
accountId,
|
|
3081
|
+
routeActivity: plan.proxyProviderId === "byo" ? void 0 : {
|
|
3082
|
+
endpoint: "responses",
|
|
3083
|
+
sessionKey: plan.sessionKey,
|
|
3084
|
+
sessionSource: _nullishCoalesce(plan.sessionSource, () => ( "none")),
|
|
3085
|
+
model: actualModel,
|
|
3086
|
+
onRecorded: (record5) => {
|
|
3087
|
+
activityRecordId = record5.id;
|
|
3088
|
+
}
|
|
2971
3089
|
}
|
|
2972
3090
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
3091
|
+
);
|
|
3092
|
+
const upstream = plan.proxyProviderId === "antigravity" ? await _chunkCGEZQC2Gcjs.fetchWithAntigravityFailover.call(void 0, url, send, signal) : await send(url);
|
|
2975
3093
|
rawStatus = upstream.status;
|
|
2976
3094
|
return upstream;
|
|
2977
|
-
}
|
|
3095
|
+
},
|
|
2978
3096
|
runResponseChain: true,
|
|
2979
3097
|
preserveEndpointRequestForResponseChain: true
|
|
2980
3098
|
});
|
|
@@ -3191,17 +3309,17 @@ function createNonCollidingSelectorName(tools, createName) {
|
|
|
3191
3309
|
let candidate;
|
|
3192
3310
|
try {
|
|
3193
3311
|
candidate = createName();
|
|
3194
|
-
} catch (
|
|
3195
|
-
throw new (0,
|
|
3312
|
+
} catch (e26) {
|
|
3313
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("image_generation_failed");
|
|
3196
3314
|
}
|
|
3197
3315
|
if (typeof candidate === "string" && SELECTOR_NAME_PATTERN.test(candidate) && !declaredNames.has(candidate)) {
|
|
3198
3316
|
return candidate;
|
|
3199
3317
|
}
|
|
3200
3318
|
}
|
|
3201
|
-
throw new (0,
|
|
3319
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("image_generation_failed");
|
|
3202
3320
|
}
|
|
3203
3321
|
function protocolFailure() {
|
|
3204
|
-
throw new (0,
|
|
3322
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("upstream_protocol_changed");
|
|
3205
3323
|
}
|
|
3206
3324
|
function parseSelectorPrompt(value) {
|
|
3207
3325
|
if (typeof value !== "string" || Buffer.byteLength(value, "utf8") > 64 * 1024) {
|
|
@@ -3210,7 +3328,7 @@ function parseSelectorPrompt(value) {
|
|
|
3210
3328
|
let parsed;
|
|
3211
3329
|
try {
|
|
3212
3330
|
parsed = JSON.parse(value);
|
|
3213
|
-
} catch (
|
|
3331
|
+
} catch (e27) {
|
|
3214
3332
|
protocolFailure();
|
|
3215
3333
|
}
|
|
3216
3334
|
if (!isRecord4(parsed) || Object.keys(parsed).some((key) => key !== "prompt") || typeof parsed.prompt !== "string" || !parsed.prompt.trim() || parsed.prompt.length > 32e3) {
|
|
@@ -3427,7 +3545,7 @@ function parseSelectorArguments(value) {
|
|
|
3427
3545
|
let parsed;
|
|
3428
3546
|
try {
|
|
3429
3547
|
parsed = JSON.parse(value);
|
|
3430
|
-
} catch (
|
|
3548
|
+
} catch (e28) {
|
|
3431
3549
|
return void 0;
|
|
3432
3550
|
}
|
|
3433
3551
|
if (!isRecord5(parsed) || typeof parsed.query !== "string") return void 0;
|
|
@@ -3555,7 +3673,7 @@ var NativeResponsesSearchLease = class {
|
|
|
3555
3673
|
let parsed;
|
|
3556
3674
|
try {
|
|
3557
3675
|
parsed = JSON.parse(text);
|
|
3558
|
-
} catch (
|
|
3676
|
+
} catch (e29) {
|
|
3559
3677
|
return responseWithBody(input.response, text, false);
|
|
3560
3678
|
}
|
|
3561
3679
|
if (!isRecord6(parsed)) return responseWithBody(input.response, text, false);
|
|
@@ -3701,7 +3819,7 @@ async function handleOpenAIResponsesRequest(res, rawBody, route, deps, requestHe
|
|
|
3701
3819
|
let parsedBody;
|
|
3702
3820
|
try {
|
|
3703
3821
|
parsedBody = JSON.parse(rawBody);
|
|
3704
|
-
} catch (
|
|
3822
|
+
} catch (e30) {
|
|
3705
3823
|
writeError(res, 400, "Invalid JSON in request body");
|
|
3706
3824
|
return;
|
|
3707
3825
|
}
|
|
@@ -3747,7 +3865,7 @@ async function handleOpenAIResponsesRequest(res, rawBody, route, deps, requestHe
|
|
|
3747
3865
|
}
|
|
3748
3866
|
const errMsg = _chunkSVNDB62Dcjs.serializeError.call(void 0, err);
|
|
3749
3867
|
console.error("[ProviderProxy:responses] Pipeline error:", errMsg);
|
|
3750
|
-
writeError(res,
|
|
3868
|
+
writeError(res, _chunkFORICQ5Ucjs.isAccountAllowanceExhaustedError.call(void 0, err) ? 429 : 502, errMsg);
|
|
3751
3869
|
}
|
|
3752
3870
|
return;
|
|
3753
3871
|
}
|
|
@@ -4000,7 +4118,7 @@ async function handleResponsesOperation(res, responsesBody, route, deps, request
|
|
|
4000
4118
|
try {
|
|
4001
4119
|
const body = JSON.parse(bodyText);
|
|
4002
4120
|
if (body.status !== "failed" && body.status !== "incomplete") recordAffinity(body.id);
|
|
4003
|
-
} catch (
|
|
4121
|
+
} catch (e31) {
|
|
4004
4122
|
}
|
|
4005
4123
|
}
|
|
4006
4124
|
|
|
@@ -4009,7 +4127,7 @@ async function handleAnthropicMessagesByo(res, rawBody, route, deps, options = {
|
|
|
4009
4127
|
let anthropicBody;
|
|
4010
4128
|
try {
|
|
4011
4129
|
anthropicBody = JSON.parse(rawBody);
|
|
4012
|
-
} catch (
|
|
4130
|
+
} catch (e32) {
|
|
4013
4131
|
writeError(res, 400, "Invalid JSON in request body");
|
|
4014
4132
|
return;
|
|
4015
4133
|
}
|
|
@@ -4156,7 +4274,7 @@ async function handleAnthropicMessagesByo(res, rawBody, route, deps, options = {
|
|
|
4156
4274
|
}
|
|
4157
4275
|
const errMsg = _chunkSVNDB62Dcjs.serializeError.call(void 0, err);
|
|
4158
4276
|
console.error("[ProviderProxy:anthropic] Pipeline error:", errMsg);
|
|
4159
|
-
writeError(res,
|
|
4277
|
+
writeError(res, _chunkFORICQ5Ucjs.isAccountAllowanceExhaustedError.call(void 0, err) ? 429 : 502, errMsg);
|
|
4160
4278
|
}
|
|
4161
4279
|
}
|
|
4162
4280
|
async function buildByoPlan2(res, route, deps, resolvedModel, isStream) {
|
|
@@ -4237,7 +4355,7 @@ async function runSameFormatFetch(bodyToSend, plan, options, keyOverride, urlOve
|
|
|
4237
4355
|
headers["anthropic-version"] = callerVersion || DEFAULT_ANTHROPIC_VERSION;
|
|
4238
4356
|
const url = _nullishCoalesce(urlOverride, () => ( _chunkA2YMUCBTcjs.buildProviderApiUrl.call(void 0, provider, { model: resolvedModel, stream: isStream })));
|
|
4239
4357
|
console.info(`[ProviderProxy:anthropic] (same-format) -> ${url} model=${resolvedModel} stream=${isStream}`);
|
|
4240
|
-
const response = await
|
|
4358
|
+
const response = await _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
4241
4359
|
url,
|
|
4242
4360
|
{ method: "POST", headers, body: bodyToSend, signal: options.signal },
|
|
4243
4361
|
{ providerId: "byo" }
|
|
@@ -4249,7 +4367,7 @@ function resolveSameFormatBody(anthropicBody, rawBody, plan) {
|
|
|
4249
4367
|
try {
|
|
4250
4368
|
const m = JSON.parse(rawBody).model;
|
|
4251
4369
|
originalModel = typeof m === "string" ? m : void 0;
|
|
4252
|
-
} catch (
|
|
4370
|
+
} catch (e33) {
|
|
4253
4371
|
originalModel = void 0;
|
|
4254
4372
|
}
|
|
4255
4373
|
return plan.resolvedModel !== originalModel ? JSON.stringify(anthropicBody) : rawBody;
|
|
@@ -4345,7 +4463,7 @@ function countTools(tools, budget) {
|
|
|
4345
4463
|
let serialized;
|
|
4346
4464
|
try {
|
|
4347
4465
|
serialized = _nullishCoalesce(JSON.stringify(tool), () => ( ""));
|
|
4348
|
-
} catch (
|
|
4466
|
+
} catch (e34) {
|
|
4349
4467
|
serialized = "";
|
|
4350
4468
|
}
|
|
4351
4469
|
if (!budget.addChars(serialized.length)) return;
|
|
@@ -4390,7 +4508,7 @@ async function handleAnthropicCountTokens(res, rawBody, route, deps, options = {
|
|
|
4390
4508
|
let body;
|
|
4391
4509
|
try {
|
|
4392
4510
|
body = JSON.parse(rawBody);
|
|
4393
|
-
} catch (
|
|
4511
|
+
} catch (e35) {
|
|
4394
4512
|
writeError(res, 400, "Invalid JSON in request body");
|
|
4395
4513
|
return;
|
|
4396
4514
|
}
|
|
@@ -4429,7 +4547,7 @@ async function handleAnthropicCountTokens(res, rawBody, route, deps, options = {
|
|
|
4429
4547
|
}
|
|
4430
4548
|
const errMsg = _chunkSVNDB62Dcjs.serializeError.call(void 0, err);
|
|
4431
4549
|
console.error("[ProviderProxy:anthropic] count_tokens error:", errMsg);
|
|
4432
|
-
writeError(res,
|
|
4550
|
+
writeError(res, _chunkFORICQ5Ucjs.isAccountAllowanceExhaustedError.call(void 0, err) ? 429 : 502, errMsg);
|
|
4433
4551
|
}
|
|
4434
4552
|
}
|
|
4435
4553
|
function writeCountTokensEstimate(res, body, budgetMs) {
|
|
@@ -4491,11 +4609,13 @@ async function handleAnthropicMessagesRequest(req, res, route, deps) {
|
|
|
4491
4609
|
const callerAnthropicVersion = Array.isArray(callerVersionRaw) ? callerVersionRaw.join(",") : callerVersionRaw;
|
|
4492
4610
|
const callerIdentity = _chunk6RPZADX3cjs.captureCallerIdentity.call(void 0, _chunkRPII3E6Zcjs.getSharedIdentityStore.call(void 0, ), request.headers);
|
|
4493
4611
|
const callerClientHeaders = extractClaudeClientHeaders(request.headers);
|
|
4612
|
+
const callerOpenCodeSession = _chunkWYECWQ3Jcjs.extractOpenCodeSessionHeader.call(void 0, request.headers);
|
|
4494
4613
|
await handleAnthropicCountTokens(res, rawBody, route, deps, {
|
|
4495
4614
|
callerAnthropicBeta,
|
|
4496
4615
|
callerAnthropicVersion,
|
|
4497
4616
|
callerIdentity,
|
|
4498
4617
|
callerClientHeaders,
|
|
4618
|
+
callerOpenCodeSession,
|
|
4499
4619
|
signal: scope.signal
|
|
4500
4620
|
});
|
|
4501
4621
|
} catch (error) {
|
|
@@ -4512,7 +4632,7 @@ async function handleAnthropicMessagesRequest(req, res, route, deps) {
|
|
|
4512
4632
|
let parsedForSearch;
|
|
4513
4633
|
try {
|
|
4514
4634
|
parsedForSearch = preReadBody ? JSON.parse(preReadBody) : {};
|
|
4515
|
-
} catch (
|
|
4635
|
+
} catch (e36) {
|
|
4516
4636
|
parsedForSearch = void 0;
|
|
4517
4637
|
}
|
|
4518
4638
|
const handled = await handleAnthropicManagedSearch(res, parsedForSearch, {
|
|
@@ -4534,11 +4654,13 @@ async function handleAnthropicMessagesRequest(req, res, route, deps) {
|
|
|
4534
4654
|
const callerAnthropicVersion = Array.isArray(callerVersionRaw) ? callerVersionRaw.join(",") : callerVersionRaw;
|
|
4535
4655
|
const callerIdentity = _chunk6RPZADX3cjs.captureCallerIdentity.call(void 0, _chunkRPII3E6Zcjs.getSharedIdentityStore.call(void 0, ), request.headers);
|
|
4536
4656
|
const callerClientHeaders = extractClaudeClientHeaders(request.headers);
|
|
4657
|
+
const callerOpenCodeSession = _chunkWYECWQ3Jcjs.extractOpenCodeSessionHeader.call(void 0, request.headers);
|
|
4537
4658
|
await handleAnthropicMessagesByo(res, rawBody, route, deps, {
|
|
4538
4659
|
callerAnthropicBeta,
|
|
4539
4660
|
callerAnthropicVersion,
|
|
4540
4661
|
callerIdentity,
|
|
4541
4662
|
callerClientHeaders,
|
|
4663
|
+
callerOpenCodeSession,
|
|
4542
4664
|
signal: scope.signal
|
|
4543
4665
|
});
|
|
4544
4666
|
} catch (error) {
|
|
@@ -4655,13 +4777,13 @@ function recordGeminiNonStreamUsage(recorder, bodyText, attribution) {
|
|
|
4655
4777
|
parsed.usageMetadata,
|
|
4656
4778
|
attribution
|
|
4657
4779
|
);
|
|
4658
|
-
} catch (
|
|
4780
|
+
} catch (e37) {
|
|
4659
4781
|
}
|
|
4660
4782
|
}
|
|
4661
4783
|
function recordGeminiStreamUsage(recorder, rawUsageMetadata, attribution) {
|
|
4662
4784
|
try {
|
|
4663
4785
|
emitGeminiUsageRecord(recorder, rawUsageMetadata, attribution);
|
|
4664
|
-
} catch (
|
|
4786
|
+
} catch (e38) {
|
|
4665
4787
|
}
|
|
4666
4788
|
}
|
|
4667
4789
|
|
|
@@ -4685,7 +4807,7 @@ async function handleGeminiGenerateContentRequest(res, rawBody, url, route, deps
|
|
|
4685
4807
|
let geminiBody;
|
|
4686
4808
|
try {
|
|
4687
4809
|
geminiBody = JSON.parse(rawBody);
|
|
4688
|
-
} catch (
|
|
4810
|
+
} catch (e39) {
|
|
4689
4811
|
writeError(res, 400, "Invalid JSON in request body");
|
|
4690
4812
|
return;
|
|
4691
4813
|
}
|
|
@@ -4809,7 +4931,7 @@ async function runPipeline2(geminiBody, plan) {
|
|
|
4809
4931
|
},
|
|
4810
4932
|
fetchFn: (url, headers, body) => {
|
|
4811
4933
|
console.log(`[ProviderProxy:gemini] -> ${url} model=${resolvedModel} stream=${isStream}`);
|
|
4812
|
-
return
|
|
4934
|
+
return _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
4813
4935
|
url,
|
|
4814
4936
|
{ method: "POST", headers, body: JSON.stringify(body) },
|
|
4815
4937
|
{ providerId: "byo" }
|
|
@@ -4882,13 +5004,13 @@ function recordChatCompletionsNonStreamUsage(recorder, bodyText, attribution) {
|
|
|
4882
5004
|
parsed.usage,
|
|
4883
5005
|
attribution
|
|
4884
5006
|
);
|
|
4885
|
-
} catch (
|
|
5007
|
+
} catch (e40) {
|
|
4886
5008
|
}
|
|
4887
5009
|
}
|
|
4888
5010
|
function recordChatCompletionsStreamUsage(recorder, rawUsage, attribution) {
|
|
4889
5011
|
try {
|
|
4890
5012
|
emitChatCompletionsUsageRecord(recorder, rawUsage, attribution);
|
|
4891
|
-
} catch (
|
|
5013
|
+
} catch (e41) {
|
|
4892
5014
|
}
|
|
4893
5015
|
}
|
|
4894
5016
|
|
|
@@ -4899,7 +5021,7 @@ async function handleOpenAIChatRequest(res, rawBody, route, deps) {
|
|
|
4899
5021
|
let chatBody;
|
|
4900
5022
|
try {
|
|
4901
5023
|
chatBody = JSON.parse(rawBody);
|
|
4902
|
-
} catch (
|
|
5024
|
+
} catch (e42) {
|
|
4903
5025
|
writeError(res, 400, "Invalid JSON in request body");
|
|
4904
5026
|
return;
|
|
4905
5027
|
}
|
|
@@ -4945,7 +5067,7 @@ async function handleOpenAIChatRequest(res, rawBody, route, deps) {
|
|
|
4945
5067
|
}
|
|
4946
5068
|
const errMsg = _chunkSVNDB62Dcjs.serializeError.call(void 0, err);
|
|
4947
5069
|
console.error("[ProviderProxy:chat] Pipeline error:", errMsg);
|
|
4948
|
-
writeError(res,
|
|
5070
|
+
writeError(res, _chunkFORICQ5Ucjs.isAccountAllowanceExhaustedError.call(void 0, err) ? 429 : 502, errMsg);
|
|
4949
5071
|
}
|
|
4950
5072
|
}
|
|
4951
5073
|
async function buildByoPlan4(res, route, deps, resolvedModel, isStream) {
|
|
@@ -5019,7 +5141,7 @@ async function buildSubscriptionPlan3(res, route, deps, resolvedModel, isStream)
|
|
|
5019
5141
|
writeError(res, 502, "Subscription profile is missing resolveUpstreamUrl");
|
|
5020
5142
|
return null;
|
|
5021
5143
|
}
|
|
5022
|
-
const auth = _nullishCoalesce(route.auth, () => ( new (0,
|
|
5144
|
+
const auth = _nullishCoalesce(route.auth, () => ( new (0, _chunkRXMF7GNFcjs.SubscriptionAuthSource)(profile)));
|
|
5023
5145
|
const chain = _chunkNYUNU75Acjs.resolveSubscriptionChain.call(void 0,
|
|
5024
5146
|
profile,
|
|
5025
5147
|
deps.llmConfig.getTransformerService(),
|
|
@@ -5079,7 +5201,7 @@ async function runPipeline3(chatBody, plan) {
|
|
|
5079
5201
|
},
|
|
5080
5202
|
fetchFn: (url, headers, body) => {
|
|
5081
5203
|
console.log(`[ProviderProxy:chat] -> ${url} model=${resolvedModel} stream=${isStream}`);
|
|
5082
|
-
return
|
|
5204
|
+
return _chunkVFFCV4J6cjs.fetchUpstream.call(void 0,
|
|
5083
5205
|
url,
|
|
5084
5206
|
{ method: "POST", headers, body: JSON.stringify(body) },
|
|
5085
5207
|
{ providerId: plan.proxyProviderId, accountId: proxyAccountId }
|
|
@@ -5269,7 +5391,7 @@ var ProviderProxy = (_class8 = class {
|
|
|
5269
5391
|
for (const cleanup of [...this.beforeStop]) {
|
|
5270
5392
|
try {
|
|
5271
5393
|
await cleanup();
|
|
5272
|
-
} catch (
|
|
5394
|
+
} catch (e43) {
|
|
5273
5395
|
}
|
|
5274
5396
|
}
|
|
5275
5397
|
this.routes.clear();
|
|
@@ -5878,9 +6000,9 @@ function routeCanServe(binding, requestedModel, role) {
|
|
|
5878
6000
|
if (_optionalChain([binding, 'access', _298 => _298.modelMappings, 'optionalAccess', _299 => _299.length])) {
|
|
5879
6001
|
return nonBlank(resolveGatewayModelMapping(binding.modelMappings, requestedModel));
|
|
5880
6002
|
}
|
|
5881
|
-
if (
|
|
6003
|
+
if (_chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, binding.endpoint)) {
|
|
5882
6004
|
const map = _nullishCoalesce(binding.modelMap, () => ( {}));
|
|
5883
|
-
const kind =
|
|
6005
|
+
const kind = _chunk57Y2EA2Gcjs.detectModelKind.call(void 0, binding.endpoint, requestedModel);
|
|
5884
6006
|
if (kind && nonBlank(map[kind])) return true;
|
|
5885
6007
|
if (binding.endpoint === "messages") {
|
|
5886
6008
|
return MESSAGE_FALLBACK_KINDS.some((candidate) => nonBlank(map[candidate]));
|
|
@@ -5888,7 +6010,7 @@ function routeCanServe(binding, requestedModel, role) {
|
|
|
5888
6010
|
return nonBlank(map.codex);
|
|
5889
6011
|
}
|
|
5890
6012
|
if (binding.endpoint === "chat" && binding.dispatchMode === "prefix") {
|
|
5891
|
-
return
|
|
6013
|
+
return _chunk57Y2EA2Gcjs.resolvePrefixTarget.call(void 0, binding.prefixTargets, requestedModel) !== null;
|
|
5892
6014
|
}
|
|
5893
6015
|
if (binding.endpoint === "chat") {
|
|
5894
6016
|
if (!requestedModel) return false;
|
|
@@ -5926,9 +6048,9 @@ function targetPrefixRefs(target, refs) {
|
|
|
5926
6048
|
function applySingleModel(config, binding, targetModel) {
|
|
5927
6049
|
const ref = targetRef(binding.target, targetModel);
|
|
5928
6050
|
if (!ref) return;
|
|
5929
|
-
if (
|
|
6051
|
+
if (_chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, binding.endpoint)) {
|
|
5930
6052
|
config.modelMap = Object.fromEntries(
|
|
5931
|
-
|
|
6053
|
+
_chunk57Y2EA2Gcjs.modelKindsForEndpoint.call(void 0, binding.endpoint).map((kind) => [kind, ref])
|
|
5932
6054
|
);
|
|
5933
6055
|
} else if (binding.endpoint === "chat") {
|
|
5934
6056
|
config.models = [ref];
|
|
@@ -5948,7 +6070,7 @@ function gatewayBindingToEndpointConfig(binding, requestedModel) {
|
|
|
5948
6070
|
const dynamicModel = binding.modelMode === "passthrough" ? requestedModel : resolveGatewayModelMapping(binding.modelMappings, requestedModel);
|
|
5949
6071
|
if (usesGenericModelHandling) {
|
|
5950
6072
|
if (nonBlank(dynamicModel)) applySingleModel(config, binding, dynamicModel);
|
|
5951
|
-
} else if (
|
|
6073
|
+
} else if (_chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, binding.endpoint)) {
|
|
5952
6074
|
config.modelMap = Object.fromEntries(
|
|
5953
6075
|
Object.entries(_nullishCoalesce(binding.modelMap, () => ( {}))).map(([kind, ref]) => [kind, targetRef(target, ref)])
|
|
5954
6076
|
);
|
|
@@ -6047,7 +6169,7 @@ var RouteLeaseTargetResolver = class {
|
|
|
6047
6169
|
await this.preflightTarget(request);
|
|
6048
6170
|
const binding = syntheticBinding(request);
|
|
6049
6171
|
const config = gatewayBindingToEndpointConfig(binding, request.model);
|
|
6050
|
-
const result = await
|
|
6172
|
+
const result = await _chunk57Y2EA2Gcjs.resolveRoute.call(void 0, {
|
|
6051
6173
|
config,
|
|
6052
6174
|
ingressFormat: runtime.ingressFormat,
|
|
6053
6175
|
llmConfig: this.llmConfig,
|
|
@@ -6143,7 +6265,7 @@ function createResponsesCompactHandler(options = {}) {
|
|
|
6143
6265
|
const parsed = JSON.parse(rawBody);
|
|
6144
6266
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error();
|
|
6145
6267
|
body = parsed;
|
|
6146
|
-
} catch (
|
|
6268
|
+
} catch (e44) {
|
|
6147
6269
|
throw new (0, _chunkG4CZIUIBcjs.OpenAIOperationError)({
|
|
6148
6270
|
status: 400,
|
|
6149
6271
|
code: "invalid_request_body",
|
|
@@ -6209,7 +6331,7 @@ function isRecord8(value) {
|
|
|
6209
6331
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6210
6332
|
}
|
|
6211
6333
|
function protocolFailure2() {
|
|
6212
|
-
throw new (0,
|
|
6334
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("upstream_protocol_changed");
|
|
6213
6335
|
}
|
|
6214
6336
|
function byteLength2(value) {
|
|
6215
6337
|
return Buffer.byteLength(value, "utf8");
|
|
@@ -6234,7 +6356,7 @@ var BoundedSseFrameDecoder = class {
|
|
|
6234
6356
|
let decoded;
|
|
6235
6357
|
try {
|
|
6236
6358
|
decoded = this.#decoder.decode(chunk, { stream: true });
|
|
6237
|
-
} catch (
|
|
6359
|
+
} catch (e45) {
|
|
6238
6360
|
protocolFailure2();
|
|
6239
6361
|
}
|
|
6240
6362
|
return this.#append(decoded, false);
|
|
@@ -6243,7 +6365,7 @@ var BoundedSseFrameDecoder = class {
|
|
|
6243
6365
|
let tail;
|
|
6244
6366
|
try {
|
|
6245
6367
|
tail = this.#decoder.decode();
|
|
6246
|
-
} catch (
|
|
6368
|
+
} catch (e46) {
|
|
6247
6369
|
protocolFailure2();
|
|
6248
6370
|
}
|
|
6249
6371
|
const frames = this.#append(tail, true);
|
|
@@ -6387,7 +6509,7 @@ var HostedImageSsePipeline = class {
|
|
|
6387
6509
|
let parsed;
|
|
6388
6510
|
try {
|
|
6389
6511
|
parsed = JSON.parse(frame2.data);
|
|
6390
|
-
} catch (
|
|
6512
|
+
} catch (e47) {
|
|
6391
6513
|
protocolFailure2();
|
|
6392
6514
|
}
|
|
6393
6515
|
if (!isRecord8(parsed) || typeof parsed.type !== "string" || parsed.type.length > 256) {
|
|
@@ -6646,7 +6768,7 @@ var HostedImageSsePipeline = class {
|
|
|
6646
6768
|
yield this.#encode(event);
|
|
6647
6769
|
continue;
|
|
6648
6770
|
}
|
|
6649
|
-
if (event.kind === "failed") throw
|
|
6771
|
+
if (event.kind === "failed") throw _chunkINY54AYXcjs.imageGenerationErrorFromPublic.call(void 0, event.error);
|
|
6650
6772
|
if (event.kind === "started") {
|
|
6651
6773
|
const item = event.item;
|
|
6652
6774
|
if (startedId || completed || event.outputIndex !== selected.presentationIndex || !isRecord8(item) || Object.keys(item).some((key) => key !== "id" && key !== "type" && key !== "status") || typeof item.id !== "string" || !PUBLIC_IMAGE_CALL_ID_PATTERN3.test(item.id) || item.type !== "image_generation_call" || item.status !== "in_progress") {
|
|
@@ -6724,7 +6846,7 @@ data: ${JSON.stringify(event)}
|
|
|
6724
6846
|
return forbidden.some((candidate) => value.includes(candidate));
|
|
6725
6847
|
}
|
|
6726
6848
|
#failureEvent(error) {
|
|
6727
|
-
const safe =
|
|
6849
|
+
const safe = _chunkINY54AYXcjs.normalizeImageGenerationError.call(void 0, error);
|
|
6728
6850
|
const model = this.#responseModel && !this.#containsPrivate(this.#responseModel) ? this.#responseModel : void 0;
|
|
6729
6851
|
const response = {
|
|
6730
6852
|
...this.#responseId ? { id: this.#responseId } : {},
|
|
@@ -6798,16 +6920,16 @@ function isRecord9(value) {
|
|
|
6798
6920
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6799
6921
|
}
|
|
6800
6922
|
function protocolFailure3() {
|
|
6801
|
-
throw new (0,
|
|
6923
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("upstream_protocol_changed");
|
|
6802
6924
|
}
|
|
6803
6925
|
function throwIfAborted(signal) {
|
|
6804
6926
|
if (signal.aborted) {
|
|
6805
|
-
throw new (0,
|
|
6927
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("request_cancelled", { cause: signal.reason });
|
|
6806
6928
|
}
|
|
6807
6929
|
}
|
|
6808
6930
|
function asOpenAIOperationError(error, signal) {
|
|
6809
6931
|
if (error instanceof _chunkG4CZIUIBcjs.OpenAIOperationError) return error;
|
|
6810
|
-
const safe = signal.aborted ? new (0,
|
|
6932
|
+
const safe = signal.aborted ? new (0, _chunkINY54AYXcjs.ImageGenerationError)("request_cancelled", { cause: signal.reason }) : _chunkINY54AYXcjs.normalizeImageGenerationError.call(void 0, error);
|
|
6811
6933
|
return new (0, _chunkG4CZIUIBcjs.OpenAIOperationError)({
|
|
6812
6934
|
status: safe.httpStatus,
|
|
6813
6935
|
code: safe.code,
|
|
@@ -6853,7 +6975,7 @@ function parseJsonObject(bytes) {
|
|
|
6853
6975
|
let text;
|
|
6854
6976
|
try {
|
|
6855
6977
|
text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
6856
|
-
} catch (
|
|
6978
|
+
} catch (e48) {
|
|
6857
6979
|
protocolFailure3();
|
|
6858
6980
|
}
|
|
6859
6981
|
try {
|
|
@@ -6861,7 +6983,7 @@ function parseJsonObject(bytes) {
|
|
|
6861
6983
|
if (!isRecord9(parsed)) protocolFailure3();
|
|
6862
6984
|
return parsed;
|
|
6863
6985
|
} catch (error) {
|
|
6864
|
-
if (
|
|
6986
|
+
if (_chunkINY54AYXcjs.isImageGenerationError.call(void 0, error)) throw error;
|
|
6865
6987
|
protocolFailure3();
|
|
6866
6988
|
}
|
|
6867
6989
|
}
|
|
@@ -6918,7 +7040,7 @@ async function executeSelectedImageCall(scope, selected) {
|
|
|
6918
7040
|
}
|
|
6919
7041
|
if (!("kind" in event)) protocolFailure3();
|
|
6920
7042
|
if (event.kind === "failed") {
|
|
6921
|
-
throw
|
|
7043
|
+
throw _chunkINY54AYXcjs.imageGenerationErrorFromPublic.call(void 0, event.error);
|
|
6922
7044
|
}
|
|
6923
7045
|
if (event.kind === "started") {
|
|
6924
7046
|
const item = event.item;
|
|
@@ -6977,7 +7099,7 @@ var NativeResponsesHostedImageRequestLease = class {
|
|
|
6977
7099
|
}
|
|
6978
7100
|
async wrapUpstreamResponse(input) {
|
|
6979
7101
|
if (this.#wrapStarted) throw asOpenAIOperationError(
|
|
6980
|
-
new (0,
|
|
7102
|
+
new (0, _chunkINY54AYXcjs.ImageGenerationError)("upstream_protocol_changed"),
|
|
6981
7103
|
this.#input.signal
|
|
6982
7104
|
);
|
|
6983
7105
|
this.#wrapStarted = true;
|
|
@@ -7041,7 +7163,7 @@ var NativeResponsesHostedImageRequestLease = class {
|
|
|
7041
7163
|
openScope: async () => {
|
|
7042
7164
|
const requestId = this.#createRequestId();
|
|
7043
7165
|
if (!validRequestId(requestId)) {
|
|
7044
|
-
throw new (0,
|
|
7166
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("image_generation_failed");
|
|
7045
7167
|
}
|
|
7046
7168
|
throwIfAborted(this.#input.signal);
|
|
7047
7169
|
return this.#runtime.openRequest({
|
|
@@ -7094,7 +7216,7 @@ var NativeResponsesHostedImageRequestLease = class {
|
|
|
7094
7216
|
if (requiresScope) {
|
|
7095
7217
|
const requestId = this.#createRequestId();
|
|
7096
7218
|
if (!validRequestId(requestId)) {
|
|
7097
|
-
throw new (0,
|
|
7219
|
+
throw new (0, _chunkINY54AYXcjs.ImageGenerationError)("image_generation_failed");
|
|
7098
7220
|
}
|
|
7099
7221
|
this.#scope = await this.#runtime.openRequest({
|
|
7100
7222
|
admission: this.#admission,
|
|
@@ -7264,6 +7386,8 @@ var _billingtypes = require('@omnicross/contracts/billing-types');
|
|
|
7264
7386
|
var _webhooktypes = require('@omnicross/contracts/webhook-types');
|
|
7265
7387
|
|
|
7266
7388
|
// src/outbound-api/imagesServerConfig.ts
|
|
7389
|
+
var DEFAULT_CODEX_IMAGE_MODEL = "gpt-image-2";
|
|
7390
|
+
var DEFAULT_CODEX_CARRIER_MODEL = "gpt-5.6-luna";
|
|
7267
7391
|
var MIB = 1024 * 1024;
|
|
7268
7392
|
var GIB = 1024 * MIB;
|
|
7269
7393
|
var IMAGE_SERVER_HARD_CEILINGS = Object.freeze({
|
|
@@ -7318,9 +7442,13 @@ var IMAGE_SERVER_HARD_CEILINGS = Object.freeze({
|
|
|
7318
7442
|
});
|
|
7319
7443
|
var DEFAULT_IMAGES_SERVER_CONFIG = Object.freeze({
|
|
7320
7444
|
enabled: false,
|
|
7321
|
-
|
|
7445
|
+
models: Object.freeze({ ..._chunkLL3MZ7O5cjs.DEFAULT_IMAGE_MODEL_ROUTES }),
|
|
7322
7446
|
defaultModel: "gpt-image-2",
|
|
7323
|
-
|
|
7447
|
+
aliases: Object.freeze({}),
|
|
7448
|
+
codex: Object.freeze({
|
|
7449
|
+
imageModel: DEFAULT_CODEX_IMAGE_MODEL,
|
|
7450
|
+
carrierModel: DEFAULT_CODEX_CARRIER_MODEL
|
|
7451
|
+
}),
|
|
7324
7452
|
account: Object.freeze({ fallback: "strict" }),
|
|
7325
7453
|
queue: Object.freeze({
|
|
7326
7454
|
maxConcurrentJobsPerAccount: 1,
|
|
@@ -7335,7 +7463,7 @@ var DEFAULT_IMAGES_SERVER_CONFIG = Object.freeze({
|
|
|
7335
7463
|
staleAfterMs: 60 * 6e4,
|
|
7336
7464
|
cleanupIntervalMs: 5 * 6e4
|
|
7337
7465
|
}),
|
|
7338
|
-
limits: Object.freeze({ ...
|
|
7466
|
+
limits: Object.freeze({ ..._chunkINY54AYXcjs.DEFAULT_IMAGE_API_LIMITS }),
|
|
7339
7467
|
references: Object.freeze({
|
|
7340
7468
|
ttlMs: 24 * 60 * 6e4,
|
|
7341
7469
|
maxArtifactBytes: 50 * MIB,
|
|
@@ -7351,7 +7479,7 @@ var DEFAULT_IMAGES_SERVER_CONFIG = Object.freeze({
|
|
|
7351
7479
|
remote: Object.freeze({ enabled: false }),
|
|
7352
7480
|
evidenceTtlMs: 24 * 60 * 6e4
|
|
7353
7481
|
});
|
|
7354
|
-
var LIMIT_KEYS = Object.keys(
|
|
7482
|
+
var LIMIT_KEYS = Object.keys(_chunkINY54AYXcjs.DEFAULT_IMAGE_API_LIMITS);
|
|
7355
7483
|
var MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
7356
7484
|
var SAFE_OBJECT_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
7357
7485
|
function record3(value) {
|
|
@@ -7365,17 +7493,48 @@ function safeIdentifier(value) {
|
|
|
7365
7493
|
const trimmed = value.trim();
|
|
7366
7494
|
return trimmed && trimmed.length <= 256 && !/[\u0000-\u001f\u007f]/u.test(trimmed) ? trimmed : void 0;
|
|
7367
7495
|
}
|
|
7368
|
-
function normalizedAliases(value) {
|
|
7496
|
+
function normalizedAliases(value, routedModels) {
|
|
7369
7497
|
const aliases = {};
|
|
7370
7498
|
const raw = record3(value);
|
|
7371
7499
|
if (!raw) return aliases;
|
|
7372
7500
|
for (const [alias, target] of Object.entries(raw)) {
|
|
7373
7501
|
if (SAFE_OBJECT_KEYS.has(alias) || !MODEL_ID.test(alias)) continue;
|
|
7374
7502
|
if (typeof target !== "string" || !MODEL_ID.test(target)) continue;
|
|
7503
|
+
if (!routedModels.has(target)) continue;
|
|
7375
7504
|
aliases[alias] = target;
|
|
7376
7505
|
}
|
|
7377
7506
|
return aliases;
|
|
7378
7507
|
}
|
|
7508
|
+
function normalizedRoutes(raw) {
|
|
7509
|
+
const registered = new Set(_chunkLL3MZ7O5cjs.IMAGE_PROVIDER_IDS);
|
|
7510
|
+
const routes = {};
|
|
7511
|
+
const modelsRaw = record3(raw["models"]);
|
|
7512
|
+
if (modelsRaw) {
|
|
7513
|
+
for (const [model, provider] of Object.entries(modelsRaw)) {
|
|
7514
|
+
if (SAFE_OBJECT_KEYS.has(model) || !MODEL_ID.test(model)) continue;
|
|
7515
|
+
if (typeof provider !== "string" || !registered.has(provider)) continue;
|
|
7516
|
+
routes[model] = provider;
|
|
7517
|
+
}
|
|
7518
|
+
}
|
|
7519
|
+
const legacyProvider = raw["provider"];
|
|
7520
|
+
const legacyValid = legacyProvider === "codex-subscription" || legacyProvider === void 0;
|
|
7521
|
+
if (!legacyValid) return { ..._chunkLL3MZ7O5cjs.DEFAULT_IMAGE_MODEL_ROUTES };
|
|
7522
|
+
if (Object.keys(routes).length > 0) return routes;
|
|
7523
|
+
const defaultModel = typeof raw["defaultModel"] === "string" && MODEL_ID.test(raw["defaultModel"]) ? raw["defaultModel"] : "gpt-image-2";
|
|
7524
|
+
const migrated = { [defaultModel]: "codex-subscription" };
|
|
7525
|
+
const legacyAliases = record3(raw["modelAliases"]);
|
|
7526
|
+
if (legacyAliases) {
|
|
7527
|
+
for (const [alias, target] of Object.entries(legacyAliases)) {
|
|
7528
|
+
if (typeof target === "string" && MODEL_ID.test(target) && !SAFE_OBJECT_KEYS.has(alias) && MODEL_ID.test(alias)) {
|
|
7529
|
+
migrated[target] = "codex-subscription";
|
|
7530
|
+
}
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7533
|
+
if (legacyProvider !== void 0 || raw["modelAliases"] !== void 0 || raw["defaultModel"] !== void 0) {
|
|
7534
|
+
return migrated;
|
|
7535
|
+
}
|
|
7536
|
+
return { ..._chunkLL3MZ7O5cjs.DEFAULT_IMAGE_MODEL_ROUTES };
|
|
7537
|
+
}
|
|
7379
7538
|
function normalizeImagesServerConfig(value) {
|
|
7380
7539
|
const raw = _nullishCoalesce(record3(value), () => ( {}));
|
|
7381
7540
|
const accountRaw = _nullishCoalesce(record3(raw["account"]), () => ( {}));
|
|
@@ -7528,16 +7687,20 @@ function normalizeImagesServerConfig(value) {
|
|
|
7528
7687
|
if (typeof referencesRaw["storageRoot"] === "string" && referencesRaw["storageRoot"].trim()) {
|
|
7529
7688
|
references.storageRoot = referencesRaw["storageRoot"].trim();
|
|
7530
7689
|
}
|
|
7531
|
-
const
|
|
7532
|
-
const
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7690
|
+
const models = normalizedRoutes(raw);
|
|
7691
|
+
const defaultModel = typeof raw["defaultModel"] === "string" && MODEL_ID.test(raw["defaultModel"]) && (raw["provider"] !== void 0 || Object.keys(models).includes(raw["defaultModel"])) ? raw["defaultModel"] : DEFAULT_IMAGES_SERVER_CONFIG.defaultModel;
|
|
7692
|
+
const aliases = normalizedAliases(_nullishCoalesce(raw["aliases"], () => ( raw["modelAliases"])), new Set(Object.keys(models)));
|
|
7693
|
+
const codexRaw = _nullishCoalesce(record3(raw["codex"]), () => ( {}));
|
|
7694
|
+
const codex = {
|
|
7695
|
+
imageModel: typeof codexRaw["imageModel"] === "string" && MODEL_ID.test(codexRaw["imageModel"]) ? codexRaw["imageModel"] : DEFAULT_IMAGES_SERVER_CONFIG.codex.imageModel,
|
|
7696
|
+
carrierModel: typeof codexRaw["carrierModel"] === "string" && MODEL_ID.test(codexRaw["carrierModel"]) ? codexRaw["carrierModel"] : DEFAULT_IMAGES_SERVER_CONFIG.codex.carrierModel
|
|
7697
|
+
};
|
|
7536
7698
|
return {
|
|
7537
7699
|
enabled: raw["enabled"] === true,
|
|
7538
|
-
|
|
7700
|
+
models,
|
|
7539
7701
|
defaultModel,
|
|
7540
|
-
|
|
7702
|
+
aliases,
|
|
7703
|
+
codex,
|
|
7541
7704
|
account,
|
|
7542
7705
|
queue,
|
|
7543
7706
|
temporary,
|
|
@@ -7553,9 +7716,10 @@ function normalizeImagesServerConfig(value) {
|
|
|
7553
7716
|
}
|
|
7554
7717
|
var TOP_LEVEL_KEYS = [
|
|
7555
7718
|
"enabled",
|
|
7556
|
-
"
|
|
7719
|
+
"models",
|
|
7557
7720
|
"defaultModel",
|
|
7558
|
-
"
|
|
7721
|
+
"aliases",
|
|
7722
|
+
"codex",
|
|
7559
7723
|
"account",
|
|
7560
7724
|
"queue",
|
|
7561
7725
|
"temporary",
|
|
@@ -7614,20 +7778,45 @@ function validateImagesServerConfig(value) {
|
|
|
7614
7778
|
if (!raw) return errors;
|
|
7615
7779
|
rejectUnknown(raw, TOP_LEVEL_KEYS, "images", errors);
|
|
7616
7780
|
if (typeof raw["enabled"] !== "boolean") errors.push("images.enabled must be a boolean");
|
|
7617
|
-
|
|
7618
|
-
|
|
7781
|
+
const models = requireRecord(raw["models"], "images.models", errors);
|
|
7782
|
+
let modelKeys = /* @__PURE__ */ new Set();
|
|
7783
|
+
if (models) {
|
|
7784
|
+
if (Object.keys(models).length === 0) {
|
|
7785
|
+
errors.push("images.models must route at least one model");
|
|
7786
|
+
}
|
|
7787
|
+
for (const [model, provider] of Object.entries(models)) {
|
|
7788
|
+
if (SAFE_OBJECT_KEYS.has(model) || !MODEL_ID.test(model)) {
|
|
7789
|
+
errors.push("images.models contains an invalid model id");
|
|
7790
|
+
continue;
|
|
7791
|
+
}
|
|
7792
|
+
modelKeys.add(model);
|
|
7793
|
+
if (!_chunkLL3MZ7O5cjs.IMAGE_PROVIDER_IDS.includes(provider)) {
|
|
7794
|
+
errors.push(`images.models.${model} must target one of: ${_chunkLL3MZ7O5cjs.IMAGE_PROVIDER_IDS.join(", ")}`);
|
|
7795
|
+
}
|
|
7796
|
+
}
|
|
7619
7797
|
}
|
|
7620
|
-
if (raw["defaultModel"] !== "
|
|
7621
|
-
errors.push("images.defaultModel must be
|
|
7798
|
+
if (typeof raw["defaultModel"] !== "string" || !MODEL_ID.test(raw["defaultModel"])) {
|
|
7799
|
+
errors.push("images.defaultModel must be a valid model id");
|
|
7800
|
+
} else if (models && !modelKeys.has(raw["defaultModel"])) {
|
|
7801
|
+
errors.push("images.defaultModel must be a key of images.models");
|
|
7622
7802
|
}
|
|
7623
|
-
const aliases = requireRecord(raw["
|
|
7803
|
+
const aliases = requireRecord(raw["aliases"], "images.aliases", errors);
|
|
7624
7804
|
if (aliases) {
|
|
7625
7805
|
for (const [alias, target] of Object.entries(aliases)) {
|
|
7626
7806
|
if (SAFE_OBJECT_KEYS.has(alias) || !MODEL_ID.test(alias)) {
|
|
7627
|
-
errors.push("images.
|
|
7807
|
+
errors.push("images.aliases contains an invalid alias");
|
|
7628
7808
|
}
|
|
7629
|
-
if (target !==
|
|
7630
|
-
errors.push(`images.
|
|
7809
|
+
if (typeof target !== "string" || !MODEL_ID.test(target) || models && !modelKeys.has(target)) {
|
|
7810
|
+
errors.push(`images.aliases.${alias} must target a key of images.models`);
|
|
7811
|
+
}
|
|
7812
|
+
}
|
|
7813
|
+
}
|
|
7814
|
+
const codex = requireRecord(raw["codex"], "images.codex", errors);
|
|
7815
|
+
if (codex) {
|
|
7816
|
+
rejectUnknown(codex, ["imageModel", "carrierModel"], "images.codex", errors);
|
|
7817
|
+
for (const key of ["imageModel", "carrierModel"]) {
|
|
7818
|
+
if (typeof codex[key] !== "string" || !MODEL_ID.test(codex[key])) {
|
|
7819
|
+
errors.push(`images.codex.${key} must be a valid model id`);
|
|
7631
7820
|
}
|
|
7632
7821
|
}
|
|
7633
7822
|
}
|
|
@@ -8217,11 +8406,11 @@ function normalizeQueueSegments(raw) {
|
|
|
8217
8406
|
var ALL_ENDPOINTS = ["chat", "responses", "messages", "gemini"];
|
|
8218
8407
|
function blankModelMap(endpoint) {
|
|
8219
8408
|
const modelMap = {};
|
|
8220
|
-
for (const kind of
|
|
8409
|
+
for (const kind of _chunk57Y2EA2Gcjs.modelKindsForEndpoint.call(void 0, endpoint)) modelMap[kind] = "";
|
|
8221
8410
|
return modelMap;
|
|
8222
8411
|
}
|
|
8223
8412
|
function defaultEndpointConfig(endpoint) {
|
|
8224
|
-
if (
|
|
8413
|
+
if (_chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, endpoint)) {
|
|
8225
8414
|
return { endpoint, modelMap: blankModelMap(endpoint), useSubscription: false };
|
|
8226
8415
|
}
|
|
8227
8416
|
if (endpoint === "chat") {
|
|
@@ -8251,10 +8440,10 @@ function normalizeEndpointConfig(e) {
|
|
|
8251
8440
|
const boundAccountFallbackPolicy = boundAccountId ? e.boundAccountFallbackPolicy === "pool" ? "pool" : "strict" : void 0;
|
|
8252
8441
|
const boundKeyId = typeof e.boundKeyId === "string" && e.boundKeyId.trim() !== "" ? e.boundKeyId : void 0;
|
|
8253
8442
|
let config;
|
|
8254
|
-
if (
|
|
8443
|
+
if (_chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, endpoint)) {
|
|
8255
8444
|
const rawMap = e.modelMap && typeof e.modelMap === "object" ? e.modelMap : {};
|
|
8256
8445
|
const modelMap = {};
|
|
8257
|
-
for (const kind of
|
|
8446
|
+
for (const kind of _chunk57Y2EA2Gcjs.modelKindsForEndpoint.call(void 0, endpoint)) {
|
|
8258
8447
|
const v = rawMap[kind];
|
|
8259
8448
|
modelMap[kind] = typeof v === "string" ? v : "";
|
|
8260
8449
|
}
|
|
@@ -8751,7 +8940,7 @@ function effectiveOutboundPermissions(value) {
|
|
|
8751
8940
|
if (value === void 0) return LEGACY_OUTBOUND_PERMISSIONS;
|
|
8752
8941
|
try {
|
|
8753
8942
|
return validateOutboundPermissions(value);
|
|
8754
|
-
} catch (
|
|
8943
|
+
} catch (e49) {
|
|
8755
8944
|
return [];
|
|
8756
8945
|
}
|
|
8757
8946
|
}
|
|
@@ -9189,7 +9378,7 @@ async function handleCodexSearchRequest(req, res, deps) {
|
|
|
9189
9378
|
let parseFailed = false;
|
|
9190
9379
|
try {
|
|
9191
9380
|
parsed = raw ? JSON.parse(raw) : {};
|
|
9192
|
-
} catch (
|
|
9381
|
+
} catch (e50) {
|
|
9193
9382
|
parseFailed = true;
|
|
9194
9383
|
}
|
|
9195
9384
|
_optionalChain([deps, 'access', _437 => _437.onRequestBody, 'optionalCall', _438 => _438(raw, isRecord10(parsed) ? parsed : {})]);
|
|
@@ -9547,7 +9736,7 @@ async function handleVoucherRedeem(req, res, deps, voucherEnabled, redeemLimiter
|
|
|
9547
9736
|
let code;
|
|
9548
9737
|
try {
|
|
9549
9738
|
code = raw ? JSON.parse(raw)["code"] : void 0;
|
|
9550
|
-
} catch (
|
|
9739
|
+
} catch (e51) {
|
|
9551
9740
|
writeErr(res, 400, "Invalid JSON in request body");
|
|
9552
9741
|
return;
|
|
9553
9742
|
}
|
|
@@ -9740,7 +9929,7 @@ async function writeModelsListAnthropic(res, llmConfig, config, apiKeyId, allowe
|
|
|
9740
9929
|
);
|
|
9741
9930
|
};
|
|
9742
9931
|
const viaLabel = (name, ref) => {
|
|
9743
|
-
const modelId = ref ? _optionalChain([
|
|
9932
|
+
const modelId = ref ? _optionalChain([_chunk57Y2EA2Gcjs.parseModelRef.call(void 0, ref), 'optionalAccess', _479 => _479.modelId]) : void 0;
|
|
9744
9933
|
return modelId ? `${name} (via ${modelId})` : void 0;
|
|
9745
9934
|
};
|
|
9746
9935
|
for (const binding of candidateGatewayBindings(config.bindings, apiKeyId, "messages")) {
|
|
@@ -9792,7 +9981,7 @@ function handleOauthUsageProxy(res, config, apiKeyId) {
|
|
|
9792
9981
|
writeJsonError(res, 404, "No Claude subscription route is bound to this key");
|
|
9793
9982
|
return;
|
|
9794
9983
|
}
|
|
9795
|
-
const snapshots =
|
|
9984
|
+
const snapshots = _chunkVYOBVPNBcjs.getSharedAccountAllowanceStore.call(void 0, ).list({ providerId: "claude" });
|
|
9796
9985
|
const preferredAccountId = claudeBinding.target.kind === "account" ? claudeBinding.target.accountId : void 0;
|
|
9797
9986
|
const snapshot = _nullishCoalesce(_nullishCoalesce((preferredAccountId !== void 0 ? snapshots.find((s) => s.accountId === preferredAccountId) : void 0), () => ( snapshots.find((s) => s.windows.some((w) => w.state === "fresh")))), () => ( snapshots[0]));
|
|
9798
9987
|
const body = {};
|
|
@@ -9842,11 +10031,11 @@ async function writeModelsList(res, llmConfig, config, apiKeyId, allowedEndpoint
|
|
|
9842
10031
|
if (endpointConfig.backgroundModel) refs.push(endpointConfig.backgroundModel);
|
|
9843
10032
|
}
|
|
9844
10033
|
modelIds.push(
|
|
9845
|
-
...refs.map((ref) => _optionalChain([
|
|
10034
|
+
...refs.map((ref) => _optionalChain([_chunk57Y2EA2Gcjs.parseModelRef.call(void 0, ref), 'optionalAccess', _494 => _494.modelId])).filter((modelId) => modelId !== void 0)
|
|
9846
10035
|
);
|
|
9847
10036
|
}
|
|
9848
10037
|
}
|
|
9849
|
-
modelIds.push(...imageModels
|
|
10038
|
+
modelIds.push(...imageModels);
|
|
9850
10039
|
const seen = /* @__PURE__ */ new Set();
|
|
9851
10040
|
const data = modelIds.filter((modelId) => {
|
|
9852
10041
|
if (seen.has(modelId)) return false;
|
|
@@ -10010,7 +10199,7 @@ async function handleOutboundRequest(req, res, deps, config, rateLimiter, serial
|
|
|
10010
10199
|
if (verified.allowedEndpoints.includes("images") && deps.imageModelCatalog) {
|
|
10011
10200
|
try {
|
|
10012
10201
|
imageModels = await deps.imageModelCatalog.listAvailableModels(verified.id);
|
|
10013
|
-
} catch (
|
|
10202
|
+
} catch (e52) {
|
|
10014
10203
|
}
|
|
10015
10204
|
}
|
|
10016
10205
|
await writeModelsList(
|
|
@@ -10093,12 +10282,12 @@ async function handleOutboundRequest(req, res, deps, config, rateLimiter, serial
|
|
|
10093
10282
|
res.once("close", release2);
|
|
10094
10283
|
}
|
|
10095
10284
|
try {
|
|
10096
|
-
const ingressFormat =
|
|
10285
|
+
const ingressFormat = _chunk57Y2EA2Gcjs.endpointToIngressFormat.call(void 0, endpoint);
|
|
10097
10286
|
const rawBody = await readBody3(req);
|
|
10098
10287
|
let parsedBody = {};
|
|
10099
10288
|
try {
|
|
10100
10289
|
parsedBody = rawBody ? JSON.parse(rawBody) : {};
|
|
10101
|
-
} catch (
|
|
10290
|
+
} catch (e53) {
|
|
10102
10291
|
writeJsonError(res, 400, "Invalid JSON in request body");
|
|
10103
10292
|
return;
|
|
10104
10293
|
}
|
|
@@ -10113,8 +10302,8 @@ async function handleOutboundRequest(req, res, deps, config, rateLimiter, serial
|
|
|
10113
10302
|
const urlModel = extractGeminiModelFromUrl(req.url);
|
|
10114
10303
|
if (urlModel) parsedBody["model"] = urlModel;
|
|
10115
10304
|
}
|
|
10116
|
-
const requestedModel =
|
|
10117
|
-
const role =
|
|
10305
|
+
const requestedModel = _chunk57Y2EA2Gcjs.extractRequestedModel.call(void 0, ingressFormat, parsedBody);
|
|
10306
|
+
const role = _chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, endpoint) || endpoint === "chat" ? void 0 : _chunk57Y2EA2Gcjs.detectRequestRole.call(void 0, ingressFormat, parsedBody, {
|
|
10118
10307
|
// Role detection precedes the route pick (the pick consumes the
|
|
10119
10308
|
// role), so the hint is the union across the candidate routes.
|
|
10120
10309
|
backgroundModelIds: candidateBackgroundModelIds(config.bindings, verified.id, endpoint)
|
|
@@ -10134,7 +10323,7 @@ async function handleOutboundRequest(req, res, deps, config, rateLimiter, serial
|
|
|
10134
10323
|
const bindingAffinitySuffix = `:${bindingResolution.binding.id}`;
|
|
10135
10324
|
const sessionId = deps.proxyDeps.apiKeyPool ? `outbound:${verified.id}${bindingAffinitySuffix}` : null;
|
|
10136
10325
|
const hostedImageGenerationAllowed = verified.allowedEndpoints.includes("images");
|
|
10137
|
-
const resolved =
|
|
10326
|
+
const resolved = _chunk57Y2EA2Gcjs.isKindMappedEndpoint.call(void 0, endpoint) || endpoint === "chat" ? await _chunk57Y2EA2Gcjs.resolveRoute.call(void 0, {
|
|
10138
10327
|
config: effectiveEndpointConfig,
|
|
10139
10328
|
ingressFormat,
|
|
10140
10329
|
llmConfig: deps.llmConfig,
|
|
@@ -10146,7 +10335,7 @@ async function handleOutboundRequest(req, res, deps, config, rateLimiter, serial
|
|
|
10146
10335
|
// Attribution: stamp the verified named-key id onto the route.
|
|
10147
10336
|
apiKeyId: verified.id,
|
|
10148
10337
|
hostedImageGenerationAllowed
|
|
10149
|
-
}) : await
|
|
10338
|
+
}) : await _chunk57Y2EA2Gcjs.resolveRoute.call(void 0, {
|
|
10150
10339
|
config: effectiveEndpointConfig,
|
|
10151
10340
|
role,
|
|
10152
10341
|
ingressFormat,
|
|
@@ -10243,7 +10432,7 @@ async function handleOutboundRequest(req, res, deps, config, rateLimiter, serial
|
|
|
10243
10432
|
else console.error("[OutboundApi] dispatch error:", message);
|
|
10244
10433
|
_chunkUIBD2YY5cjs.emitWebhookEvent.call(void 0, { kind: "server.error", at: Date.now(), message });
|
|
10245
10434
|
if (audit) audit.error = message;
|
|
10246
|
-
writeJsonError(res,
|
|
10435
|
+
writeJsonError(res, _chunkFORICQ5Ucjs.isAccountAllowanceExhaustedError.call(void 0, err) ? 429 : 502, message);
|
|
10247
10436
|
} finally {
|
|
10248
10437
|
routeMap.removeRoute(token);
|
|
10249
10438
|
if (releaseSerial) releaseSerial();
|
|
@@ -10441,7 +10630,7 @@ var OutboundApiServer = (_class19 = class {
|
|
|
10441
10630
|
this.searchConfig = input.search;
|
|
10442
10631
|
this.imagesEnabled = input.imagesEnabled === true;
|
|
10443
10632
|
this.apiHelloEnabled = _optionalChain([input, 'access', _523 => _523.anthropic, 'optionalAccess', _524 => _524.apiHello]) !== false;
|
|
10444
|
-
|
|
10633
|
+
_chunkVGBJPHHDcjs.setAnthropicPingHeartbeatMs.call(void 0, _optionalChain([input, 'access', _525 => _525.anthropic, 'optionalAccess', _526 => _526.heartbeatIntervalMs]));
|
|
10445
10634
|
}
|
|
10446
10635
|
captureRuntimeSnapshot() {
|
|
10447
10636
|
return {
|
|
@@ -10468,7 +10657,7 @@ var OutboundApiServer = (_class19 = class {
|
|
|
10468
10657
|
this.searchConfig = snapshot.search;
|
|
10469
10658
|
this.imagesEnabled = snapshot.imagesEnabled;
|
|
10470
10659
|
this.apiHelloEnabled = _optionalChain([snapshot, 'access', _527 => _527.anthropic, 'optionalAccess', _528 => _528.apiHello]) !== false;
|
|
10471
|
-
|
|
10660
|
+
_chunkVGBJPHHDcjs.setAnthropicPingHeartbeatMs.call(void 0, _optionalChain([snapshot, 'access', _529 => _529.anthropic, 'optionalAccess', _530 => _530.heartbeatIntervalMs]));
|
|
10472
10661
|
}
|
|
10473
10662
|
async restoreRuntimeSnapshot(snapshot) {
|
|
10474
10663
|
const current = this.server;
|
|
@@ -10502,22 +10691,22 @@ var OutboundApiServer = (_class19 = class {
|
|
|
10502
10691
|
server.close(() => {
|
|
10503
10692
|
try {
|
|
10504
10693
|
this.logInfo("[OutboundApiServer] Stopped");
|
|
10505
|
-
} catch (
|
|
10694
|
+
} catch (e54) {
|
|
10506
10695
|
}
|
|
10507
10696
|
});
|
|
10508
|
-
} catch (
|
|
10697
|
+
} catch (e55) {
|
|
10509
10698
|
}
|
|
10510
10699
|
}
|
|
10511
10700
|
announcePublishedListener(bindAddr, requestedPort, actualPort) {
|
|
10512
10701
|
if (actualPort !== requestedPort) {
|
|
10513
10702
|
try {
|
|
10514
10703
|
_optionalChain([this, 'access', _531 => _531.onPortChange, 'optionalCall', _532 => _532(actualPort)]);
|
|
10515
|
-
} catch (
|
|
10704
|
+
} catch (e56) {
|
|
10516
10705
|
}
|
|
10517
10706
|
}
|
|
10518
10707
|
try {
|
|
10519
10708
|
this.logInfo(`[OutboundApiServer] Listening on ${bindAddr}:${actualPort}`);
|
|
10520
|
-
} catch (
|
|
10709
|
+
} catch (e57) {
|
|
10521
10710
|
}
|
|
10522
10711
|
}
|
|
10523
10712
|
/** Per-request handler. Auth is enforced on EVERY request (incl. loopback). */
|
|
@@ -11576,7 +11765,7 @@ function buildToolRequest(apiFormat, conversationMessages, actualModel, options,
|
|
|
11576
11765
|
// Native Anthropic Messages requires this field. Resolve an absent
|
|
11577
11766
|
// caller cap to the model's real ceiling rather than a small constant —
|
|
11578
11767
|
// see `resolveAnthropicMaxTokens`.
|
|
11579
|
-
max_tokens:
|
|
11768
|
+
max_tokens: _chunk47E3I5PFcjs.resolveAnthropicMaxTokens.call(void 0, actualModel, options.maxTokens),
|
|
11580
11769
|
temperature: _nullishCoalesce(options.temperature, () => ( 0.7)),
|
|
11581
11770
|
stream: true,
|
|
11582
11771
|
tools: options.tools
|