@omnicross/core 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-4LSZ7NFM.js +50 -0
- 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-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-GWC7HCZI.cjs +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-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-PAXJGABW.js → chunk-MPFOC7AT.js} +10 -5
- package/dist/{chunk-DKBXDV5U.cjs → chunk-N3MGNLCU.cjs} +49 -44
- package/dist/chunk-NCZDUBC2.js +44 -0
- 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-QEOV6Y4E.cjs → chunk-RX3BCX53.cjs} +359 -170
- package/dist/{chunk-TX3AEV6H.cjs → chunk-RXMF7GNF.cjs} +4 -3
- package/dist/chunk-SQU2FGXI.cjs +50 -0
- 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-X6GHTNDL.cjs +482 -0
- package/dist/chunk-XBQTVRMK.js +45 -0
- package/dist/{chunk-R4VCO2CB.js → chunk-YEHQ5FXZ.js} +28 -0
- package/dist/{chunk-5TEWZN5J.js → chunk-YV4JSBPA.js} +278 -89
- 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 +8 -2
- package/dist/provider-proxy/identity/codexCliHeaders.d.cts +36 -7
- package/dist/provider-proxy/identity/codexCliHeaders.d.ts +36 -7
- package/dist/provider-proxy/identity/codexCliHeaders.js +7 -1
- 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-ECZ3ZE2C.js +0 -63
- package/dist/chunk-XEKD23J5.js +0 -9
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
normalizeSearchFrontendModes,
|
|
5
|
-
searchErrorHttpStatus,
|
|
6
|
-
searchRuntimeAsWebSearchBackend,
|
|
7
|
-
validateSearchFrontendModes
|
|
8
|
-
} from "./chunk-MZEGQSKQ.js";
|
|
2
|
+
OpenAIResponseTransformer
|
|
3
|
+
} from "./chunk-V53ZEFXC.js";
|
|
9
4
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
AnthropicTransformer,
|
|
6
|
+
resolveAnthropicMaxTokens
|
|
7
|
+
} from "./chunk-TKZ3DZS5.js";
|
|
8
|
+
import {
|
|
9
|
+
setAnthropicPingHeartbeatMs
|
|
10
|
+
} from "./chunk-IDPMD4B7.js";
|
|
11
|
+
import {
|
|
12
|
+
fetchWithAntigravityFailover,
|
|
13
|
+
maybeAntigravityFailoverUrl
|
|
14
|
+
} from "./chunk-K6J2RIEX.js";
|
|
15
|
+
import {
|
|
16
|
+
GeminiTransformer
|
|
17
|
+
} from "./chunk-OXBGNEYR.js";
|
|
12
18
|
import {
|
|
13
19
|
TransformerChainExecutor
|
|
14
20
|
} from "./chunk-EYGBM2VC.js";
|
|
@@ -16,26 +22,28 @@ import {
|
|
|
16
22
|
injectExtendedContextBeta
|
|
17
23
|
} from "./chunk-MZNPGW5Q.js";
|
|
18
24
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
MATCH_TEXT_PER_MESSAGE_CAP,
|
|
26
|
+
collectMatchText,
|
|
27
|
+
deriveGatewaySessionKey,
|
|
28
|
+
deriveSubscriptionSessionKey,
|
|
29
|
+
flattenMatchText
|
|
30
|
+
} from "./chunk-GFIZ6LQI.js";
|
|
24
31
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
DEFAULT_SEARCH_FRONTEND_MODES,
|
|
33
|
+
SEARCH_UNSUPPORTED_CAPABILITY_CODE,
|
|
34
|
+
normalizeSearchFrontendModes,
|
|
35
|
+
searchErrorHttpStatus,
|
|
36
|
+
searchRuntimeAsWebSearchBackend,
|
|
37
|
+
validateSearchFrontendModes
|
|
38
|
+
} from "./chunk-MZEGQSKQ.js";
|
|
28
39
|
import {
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
40
|
+
streamSSEResponse
|
|
41
|
+
} from "./chunk-VVEHS2LI.js";
|
|
31
42
|
import {
|
|
32
|
-
DEFAULT_CODEX_CLI_HEADERS,
|
|
33
|
-
NEVER_FORWARD_HEADERS,
|
|
34
43
|
codexAcceptHeader,
|
|
35
44
|
extractCodexClientHeaders,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} from "./chunk-ECZ3ZE2C.js";
|
|
45
|
+
fillMissingCodexCliIdentity
|
|
46
|
+
} from "./chunk-4LSZ7NFM.js";
|
|
39
47
|
import {
|
|
40
48
|
getSharedIdentityStore
|
|
41
49
|
} from "./chunk-XTEI64OU.js";
|
|
@@ -44,12 +52,13 @@ import {
|
|
|
44
52
|
captureCallerIdentity
|
|
45
53
|
} from "./chunk-XX6NQJMA.js";
|
|
46
54
|
import {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
extractOpenCodeSessionHeader
|
|
56
|
+
} from "./chunk-NCZDUBC2.js";
|
|
57
|
+
import {
|
|
58
|
+
NEVER_FORWARD_HEADERS,
|
|
59
|
+
fillMissingHeaders,
|
|
60
|
+
flattenHeaderValue
|
|
61
|
+
} from "./chunk-ONTTXSRL.js";
|
|
53
62
|
import {
|
|
54
63
|
emitWebhookEvent
|
|
55
64
|
} from "./chunk-OE6TDIWW.js";
|
|
@@ -78,17 +87,17 @@ import {
|
|
|
78
87
|
} from "./chunk-V2UKUTJ3.js";
|
|
79
88
|
import {
|
|
80
89
|
SubscriptionAuthSource
|
|
81
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-ZBDDPWVQ.js";
|
|
82
91
|
import {
|
|
83
92
|
serializeError
|
|
84
93
|
} from "./chunk-AVYJ4YBN.js";
|
|
85
|
-
import {
|
|
86
|
-
isAccountAllowanceExhaustedError
|
|
87
|
-
} from "./chunk-C3NPMQTK.js";
|
|
88
94
|
import {
|
|
89
95
|
boundAccountSelectionMessage,
|
|
90
96
|
isBoundAccountSelectionError
|
|
91
97
|
} from "./chunk-2JYRIADS.js";
|
|
98
|
+
import {
|
|
99
|
+
isAccountAllowanceExhaustedError
|
|
100
|
+
} from "./chunk-JHJRZ75C.js";
|
|
92
101
|
import {
|
|
93
102
|
beginAuditCapture
|
|
94
103
|
} from "./chunk-6OKXH2TW.js";
|
|
@@ -109,10 +118,14 @@ import {
|
|
|
109
118
|
parseModelRef,
|
|
110
119
|
resolvePrefixTarget,
|
|
111
120
|
resolveRoute
|
|
112
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-ZMERU7D3.js";
|
|
113
122
|
import {
|
|
114
123
|
getSubscriptionRegistryForOutbound
|
|
115
124
|
} from "./chunk-AQ5TNQB7.js";
|
|
125
|
+
import {
|
|
126
|
+
DEFAULT_IMAGE_MODEL_ROUTES,
|
|
127
|
+
IMAGE_PROVIDER_IDS
|
|
128
|
+
} from "./chunk-6I4SAWCN.js";
|
|
116
129
|
import {
|
|
117
130
|
applyAugmentation
|
|
118
131
|
} from "./chunk-Y7FO65VT.js";
|
|
@@ -132,15 +145,18 @@ import {
|
|
|
132
145
|
convertAnthropicToOpenAI,
|
|
133
146
|
convertOpenAIToAnthropic
|
|
134
147
|
} from "./chunk-5NJLQ6T6.js";
|
|
148
|
+
import {
|
|
149
|
+
getAntigravityProjectResolver
|
|
150
|
+
} from "./chunk-EE7VP4O3.js";
|
|
135
151
|
import {
|
|
136
152
|
resolveReasoningPlan
|
|
137
153
|
} from "./chunk-ZLNHPUFA.js";
|
|
138
154
|
import {
|
|
139
155
|
fetchUpstream
|
|
140
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-NTF7TLT7.js";
|
|
141
157
|
import {
|
|
142
158
|
getSharedAccountAllowanceStore
|
|
143
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-FYPKKMB3.js";
|
|
144
160
|
import {
|
|
145
161
|
getSharedAccountRouteActivity
|
|
146
162
|
} from "./chunk-GL6XM527.js";
|
|
@@ -150,7 +166,7 @@ import {
|
|
|
150
166
|
imageGenerationErrorFromPublic,
|
|
151
167
|
isImageGenerationError,
|
|
152
168
|
normalizeImageGenerationError
|
|
153
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-4RM22ETG.js";
|
|
154
170
|
import {
|
|
155
171
|
OpenAIOperationError,
|
|
156
172
|
classifyOpenAIOperation,
|
|
@@ -1535,14 +1551,14 @@ async function buildSubscriptionPlan(res, route, deps, anthropicBody, routeModel
|
|
|
1535
1551
|
scenario = mapped.scenario;
|
|
1536
1552
|
}
|
|
1537
1553
|
const sessionKey = deriveSubscriptionSessionKey(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 = profile.resolveUpstreamUrl?.(resolvedModel, route.subscriptionConfig);
|
|
1547
1563
|
if (!upstreamUrl) return null;
|
|
1548
1564
|
const auth = route.auth ?? new SubscriptionAuthSource(profile);
|
|
@@ -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 = (headers.Authorization ?? headers.authorization ?? "").replace(/^Bearer\s+/i, "").trim();
|
|
1597
|
+
if (bearer) {
|
|
1598
|
+
transformerProvider.geminiProject = await getAntigravityProjectResolver().resolveProject(bearer);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1566
1601
|
return {
|
|
1567
1602
|
auth,
|
|
1568
|
-
preferredAccountId: route.preferredAccountId,
|
|
1569
|
-
preferredAccountGroup: route.preferredAccountGroup,
|
|
1570
|
-
boundAccountFallbackPolicy: route.boundAccountFallbackPolicy,
|
|
1603
|
+
preferredAccountId: 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
|
reportSelection?.(accountId, isActive);
|
|
1650
1686
|
}
|
|
1651
1687
|
});
|
|
1688
|
+
if (plan.transformerProvider.name === "antigravity") {
|
|
1689
|
+
const bearer = (authHeaders.Authorization ?? authHeaders.authorization ?? "").replace(/^Bearer\s+/i, "").trim();
|
|
1690
|
+
if (bearer) transformerProvider.geminiProject = await getAntigravityProjectResolver().resolveProject(bearer);
|
|
1691
|
+
}
|
|
1652
1692
|
let rawStatus = null;
|
|
1653
1693
|
let activityRecordId;
|
|
1654
1694
|
const { response } = await executeProviderCall({
|
|
@@ -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: options.callerOpenCodeSession ?? void 0,
|
|
1705
1746
|
preferredAccountId: plan.preferredAccountId,
|
|
1706
1747
|
preferredAccountGroup: plan.preferredAccountGroup,
|
|
1707
1748
|
boundAccountFallbackPolicy: plan.boundAccountFallbackPolicy,
|
|
@@ -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
|
+
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 (!profile?.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 = maybeAntigravityFailoverUrl(
|
|
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 {
|
|
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
|
|
@@ -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: 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: affinityAccountId ?? route.preferredAccountId,
|
|
2831
|
-
preferredAccountGroup: affinity ? void 0 : route.preferredAccountGroup,
|
|
2832
|
-
boundAccountFallbackPolicy: affinity ? "strict" : route.boundAccountFallbackPolicy,
|
|
2931
|
+
preferredAccountId: 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,
|
|
@@ -2839,6 +2940,9 @@ async function buildSubscriptionPlan2(route, deps, resolved, resolvedModel, isSt
|
|
|
2839
2940
|
proxyProviderId: profile.authStrategy.providerId,
|
|
2840
2941
|
providerIdentity: resolved.providerIdentity,
|
|
2841
2942
|
callerClientHeaders: profile.authStrategy.providerId === "codex" ? extractCodexClientHeaders(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" ? extractOpenCodeSessionHeader(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 getGeminiCodeAssistResolver()?.resolveProject(accessToken);
|
|
2852
2956
|
}
|
|
2957
|
+
async function resolveAntigravityProjectThreaded(profile, hints) {
|
|
2958
|
+
const headers = {};
|
|
2959
|
+
await profile.authStrategy.applyHeaders(headers, hints);
|
|
2960
|
+
const accessToken = (headers.Authorization ?? headers.authorization ?? "").replace(/^Bearer\s+/i, "").trim();
|
|
2961
|
+
if (!accessToken) return void 0;
|
|
2962
|
+
return getAntigravityProjectResolver().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,
|
|
@@ -2897,8 +3009,8 @@ async function applyPlanAuth(body, plan) {
|
|
|
2897
3009
|
function decorateCodexHeaders(headers, plan) {
|
|
2898
3010
|
if (plan.proxyProviderId !== "codex") return;
|
|
2899
3011
|
fillMissingHeaders(headers, plan.callerClientHeaders ?? {});
|
|
2900
|
-
fillMissingHeaders(headers, DEFAULT_CODEX_CLI_HEADERS);
|
|
2901
3012
|
fillMissingHeaders(headers, { accept: codexAcceptHeader(plan.isStream) });
|
|
3013
|
+
fillMissingCodexCliIdentity(headers);
|
|
2902
3014
|
}
|
|
2903
3015
|
async function runNative(body, plan, operation, signal) {
|
|
2904
3016
|
throwIfResponsesAborted(signal);
|
|
@@ -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 = (authHeaders.Authorization ?? authHeaders.authorization ?? "").replace(/^Bearer\s+/i, "").trim();
|
|
3053
|
+
if (bearer) plan.transformerProvider.geminiProject = await getAntigravityProjectResolver().resolveProject(bearer);
|
|
3054
|
+
}
|
|
2939
3055
|
let rawStatus = null;
|
|
2940
3056
|
let activityRecordId;
|
|
2941
3057
|
const { response } = await executeProviderCall({
|
|
@@ -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) => fetchUpstream(
|
|
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: 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 fetchWithAntigravityFailover(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
|
});
|
|
@@ -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 = captureCallerIdentity(getSharedIdentityStore(), request.headers);
|
|
4493
4611
|
const callerClientHeaders = extractClaudeClientHeaders(request.headers);
|
|
4612
|
+
const callerOpenCodeSession = extractOpenCodeSessionHeader(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) {
|
|
@@ -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 = captureCallerIdentity(getSharedIdentityStore(), request.headers);
|
|
4536
4656
|
const callerClientHeaders = extractClaudeClientHeaders(request.headers);
|
|
4657
|
+
const callerOpenCodeSession = extractOpenCodeSessionHeader(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) {
|
|
@@ -7264,6 +7386,8 @@ import {
|
|
|
7264
7386
|
} from "@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({ ...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,
|
|
@@ -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(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 { ...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 { ...DEFAULT_IMAGE_MODEL_ROUTES };
|
|
7537
|
+
}
|
|
7379
7538
|
function normalizeImagesServerConfig(value) {
|
|
7380
7539
|
const raw = record3(value) ?? {};
|
|
7381
7540
|
const accountRaw = 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(raw["aliases"] ?? raw["modelAliases"], new Set(Object.keys(models)));
|
|
7693
|
+
const codexRaw = 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 (!IMAGE_PROVIDER_IDS.includes(provider)) {
|
|
7794
|
+
errors.push(`images.models.${model} must target one of: ${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
|
}
|
|
@@ -9846,7 +10035,7 @@ async function writeModelsList(res, llmConfig, config, apiKeyId, allowedEndpoint
|
|
|
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;
|