@omnicross/core 0.4.2 → 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
|
@@ -246,6 +246,13 @@ async function transformResponseIn(response, logger) {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
// src/transformer/transformers/utils/gemini.stream.ts
|
|
249
|
+
function inlineDataToDataUrl(part) {
|
|
250
|
+
const inline = _nullishCoalesce(part.inlineData, () => ( part.inline_data));
|
|
251
|
+
const data = _optionalChain([inline, 'optionalAccess', _25 => _25.data]);
|
|
252
|
+
if (typeof data !== "string" || !data) return null;
|
|
253
|
+
const mime = _nullishCoalesce(_nullishCoalesce(_optionalChain([inline, 'optionalAccess', _26 => _26.mimeType]), () => ( _optionalChain([inline, 'optionalAccess', _27 => _27.mime_type]))), () => ( "image/png"));
|
|
254
|
+
return `data:${mime};base64,${data}`;
|
|
255
|
+
}
|
|
249
256
|
async function transformResponseOut(response, providerName, logger) {
|
|
250
257
|
const contentType = _nullishCoalesce(response.headers.get("Content-Type"), () => ( ""));
|
|
251
258
|
if (contentType.includes("application/json")) {
|
|
@@ -257,8 +264,8 @@ async function transformResponseOut(response, providerName, logger) {
|
|
|
257
264
|
}
|
|
258
265
|
async function handleJsonResponse(response, providerName, logger) {
|
|
259
266
|
const jsonResponse = await response.json();
|
|
260
|
-
_optionalChain([logger, 'optionalAccess',
|
|
261
|
-
const parts = _optionalChain([jsonResponse, 'access',
|
|
267
|
+
_optionalChain([logger, 'optionalAccess', _28 => _28.debug, 'call', _29 => _29(`${providerName} JSON response received`)]);
|
|
268
|
+
const parts = _optionalChain([jsonResponse, 'access', _30 => _30.candidates, 'optionalAccess', _31 => _31[0], 'optionalAccess', _32 => _32.content, 'optionalAccess', _33 => _33.parts]) || [];
|
|
262
269
|
let thinkingContent = "";
|
|
263
270
|
let thinkingSignature = "";
|
|
264
271
|
const nonThinkingParts = [];
|
|
@@ -269,25 +276,27 @@ async function handleJsonResponse(response, providerName, logger) {
|
|
|
269
276
|
nonThinkingParts.push(part);
|
|
270
277
|
}
|
|
271
278
|
}
|
|
272
|
-
thinkingSignature = _nullishCoalesce(_optionalChain([parts, 'access',
|
|
279
|
+
thinkingSignature = _nullishCoalesce(_optionalChain([parts, 'access', _34 => _34.find, 'call', _35 => _35((part) => part.thoughtSignature), 'optionalAccess', _36 => _36.thoughtSignature]), () => ( ""));
|
|
273
280
|
const toolCalls = nonThinkingParts.filter((part) => part.functionCall).map((part) => ({
|
|
274
|
-
id: _optionalChain([part, 'access',
|
|
281
|
+
id: _optionalChain([part, 'access', _37 => _37.functionCall, 'optionalAccess', _38 => _38.id]) || `tool_${Math.random().toString(36).substring(2, 15)}`,
|
|
275
282
|
type: "function",
|
|
276
283
|
function: {
|
|
277
|
-
name: _nullishCoalesce(_optionalChain([part, 'access',
|
|
278
|
-
arguments: JSON.stringify(_optionalChain([part, 'access',
|
|
284
|
+
name: _nullishCoalesce(_optionalChain([part, 'access', _39 => _39.functionCall, 'optionalAccess', _40 => _40.name]), () => ( "")),
|
|
285
|
+
arguments: JSON.stringify(_optionalChain([part, 'access', _41 => _41.functionCall, 'optionalAccess', _42 => _42.args]) || {})
|
|
279
286
|
}
|
|
280
287
|
}));
|
|
281
288
|
const textContent = nonThinkingParts.filter((part) => part.text).map((part) => part.text).join("\n");
|
|
289
|
+
const images = nonThinkingParts.map((part) => inlineDataToDataUrl(part)).filter((url) => url !== null);
|
|
282
290
|
const openAIResponse = {
|
|
283
291
|
id: _nullishCoalesce(jsonResponse.responseId, () => ( "")),
|
|
284
292
|
choices: [
|
|
285
293
|
{
|
|
286
|
-
finish_reason: (_nullishCoalesce(_optionalChain([jsonResponse, 'access',
|
|
294
|
+
finish_reason: (_nullishCoalesce(_optionalChain([jsonResponse, 'access', _43 => _43.candidates, 'optionalAccess', _44 => _44[0], 'optionalAccess', _45 => _45.finishReason]), () => ( ""))).toLowerCase() || null,
|
|
287
295
|
index: 0,
|
|
288
296
|
message: {
|
|
289
297
|
content: textContent,
|
|
290
298
|
role: "assistant",
|
|
299
|
+
images: images.length > 0 ? images : void 0,
|
|
291
300
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
292
301
|
...thinkingSignature && {
|
|
293
302
|
thinking: {
|
|
@@ -302,14 +311,14 @@ async function handleJsonResponse(response, providerName, logger) {
|
|
|
302
311
|
model: _nullishCoalesce(jsonResponse.modelVersion, () => ( "")),
|
|
303
312
|
object: "chat.completion",
|
|
304
313
|
usage: {
|
|
305
|
-
completion_tokens: _optionalChain([jsonResponse, 'access',
|
|
306
|
-
prompt_tokens: _optionalChain([jsonResponse, 'access',
|
|
314
|
+
completion_tokens: _optionalChain([jsonResponse, 'access', _46 => _46.usageMetadata, 'optionalAccess', _47 => _47.candidatesTokenCount]) || 0,
|
|
315
|
+
prompt_tokens: _optionalChain([jsonResponse, 'access', _48 => _48.usageMetadata, 'optionalAccess', _49 => _49.promptTokenCount]) || 0,
|
|
307
316
|
prompt_tokens_details: {
|
|
308
|
-
cached_tokens: _optionalChain([jsonResponse, 'access',
|
|
317
|
+
cached_tokens: _optionalChain([jsonResponse, 'access', _50 => _50.usageMetadata, 'optionalAccess', _51 => _51.cachedContentTokenCount]) || 0
|
|
309
318
|
},
|
|
310
|
-
total_tokens: _optionalChain([jsonResponse, 'access',
|
|
319
|
+
total_tokens: _optionalChain([jsonResponse, 'access', _52 => _52.usageMetadata, 'optionalAccess', _53 => _53.totalTokenCount]) || 0,
|
|
311
320
|
output_tokens_details: {
|
|
312
|
-
reasoning_tokens: _optionalChain([jsonResponse, 'access',
|
|
321
|
+
reasoning_tokens: _optionalChain([jsonResponse, 'access', _54 => _54.usageMetadata, 'optionalAccess', _55 => _55.thoughtsTokenCount]) || 0
|
|
313
322
|
}
|
|
314
323
|
}
|
|
315
324
|
};
|
|
@@ -340,15 +349,15 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
340
349
|
if (!line.startsWith("data: ")) return;
|
|
341
350
|
const chunkStr = line.slice(6).trim();
|
|
342
351
|
if (!chunkStr) return;
|
|
343
|
-
_optionalChain([logger, 'optionalAccess',
|
|
352
|
+
_optionalChain([logger, 'optionalAccess', _56 => _56.debug, 'call', _57 => _57(`${providerName} chunk: ${chunkStr.substring(0, 100)}...`)]);
|
|
344
353
|
try {
|
|
345
354
|
const chunk = JSON.parse(chunkStr);
|
|
346
|
-
if (!_optionalChain([chunk, 'access',
|
|
347
|
-
_optionalChain([logger, 'optionalAccess',
|
|
355
|
+
if (!_optionalChain([chunk, 'access', _58 => _58.candidates, 'optionalAccess', _59 => _59[0]])) {
|
|
356
|
+
_optionalChain([logger, 'optionalAccess', _60 => _60.debug, 'call', _61 => _61("Invalid chunk structure")]);
|
|
348
357
|
return;
|
|
349
358
|
}
|
|
350
359
|
const candidate = chunk.candidates[0];
|
|
351
|
-
const parts = _optionalChain([candidate, 'access',
|
|
360
|
+
const parts = _optionalChain([candidate, 'access', _62 => _62.content, 'optionalAccess', _63 => _63.parts]) || [];
|
|
352
361
|
textBuffered = false;
|
|
353
362
|
parts.filter((part) => part.text && part.thought === true).forEach((part) => {
|
|
354
363
|
hasThinkingContent = true;
|
|
@@ -366,7 +375,7 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
366
375
|
|
|
367
376
|
`));
|
|
368
377
|
});
|
|
369
|
-
const signature = _optionalChain([parts, 'access',
|
|
378
|
+
const signature = _optionalChain([parts, 'access', _64 => _64.find, 'call', _65 => _65((part) => part.thoughtSignature), 'optionalAccess', _66 => _66.thoughtSignature]);
|
|
370
379
|
if (signature && !signatureSent) {
|
|
371
380
|
if (!hasThinkingContent) {
|
|
372
381
|
const thinkingChunk = createChunk({
|
|
@@ -413,11 +422,11 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
413
422
|
}
|
|
414
423
|
}
|
|
415
424
|
const toolCalls = parts.filter((part) => part.functionCall).map((part) => ({
|
|
416
|
-
id: _optionalChain([part, 'access',
|
|
425
|
+
id: _optionalChain([part, 'access', _67 => _67.functionCall, 'optionalAccess', _68 => _68.id]) || `ccr_tool_${Math.random().toString(36).substring(2, 15)}`,
|
|
417
426
|
type: "function",
|
|
418
427
|
function: {
|
|
419
|
-
name: _nullishCoalesce(_optionalChain([part, 'access',
|
|
420
|
-
arguments: JSON.stringify(_optionalChain([part, 'access',
|
|
428
|
+
name: _nullishCoalesce(_optionalChain([part, 'access', _69 => _69.functionCall, 'optionalAccess', _70 => _70.name]), () => ( "")),
|
|
429
|
+
arguments: JSON.stringify(_optionalChain([part, 'access', _71 => _71.functionCall, 'optionalAccess', _72 => _72.args]) || {})
|
|
421
430
|
}
|
|
422
431
|
}));
|
|
423
432
|
const textContent = parts.filter((part) => part.text && part.thought !== true).map((part) => part.text).join("\n");
|
|
@@ -425,7 +434,7 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
425
434
|
contentSent = true;
|
|
426
435
|
}
|
|
427
436
|
if (hasThinkingContent && textContent && !signatureSent) {
|
|
428
|
-
if (_optionalChain([chunk, 'access',
|
|
437
|
+
if (_optionalChain([chunk, 'access', _73 => _73.modelVersion, 'optionalAccess', _74 => _74.includes, 'call', _75 => _75("3")])) {
|
|
429
438
|
pendingContent += textContent;
|
|
430
439
|
textBuffered = true;
|
|
431
440
|
} else {
|
|
@@ -445,6 +454,7 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
445
454
|
signatureSent = true;
|
|
446
455
|
}
|
|
447
456
|
}
|
|
457
|
+
const images = parts.map((part) => inlineDataToDataUrl(part)).filter((url) => url !== null);
|
|
448
458
|
if (textContent && !textBuffered) {
|
|
449
459
|
if (!pendingContent) contentIndex++;
|
|
450
460
|
const contentChunk = createChunk({
|
|
@@ -458,6 +468,21 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
458
468
|
});
|
|
459
469
|
controller.enqueue(encoder.encode(`data: ${JSON.stringify(contentChunk)}
|
|
460
470
|
|
|
471
|
+
`));
|
|
472
|
+
contentSent = true;
|
|
473
|
+
}
|
|
474
|
+
if (images.length > 0) {
|
|
475
|
+
const imageChunk = createChunk({
|
|
476
|
+
responseId: chunk.responseId,
|
|
477
|
+
modelVersion: chunk.modelVersion,
|
|
478
|
+
contentIndex,
|
|
479
|
+
delta: { role: "assistant", images },
|
|
480
|
+
finishReason: candidate.finishReason,
|
|
481
|
+
usageMetadata: chunk.usageMetadata,
|
|
482
|
+
groundingMetadata: candidate.groundingMetadata
|
|
483
|
+
});
|
|
484
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(imageChunk)}
|
|
485
|
+
|
|
461
486
|
`));
|
|
462
487
|
contentSent = true;
|
|
463
488
|
}
|
|
@@ -484,7 +509,7 @@ function handleStreamResponse(response, providerName, logger) {
|
|
|
484
509
|
contentSent = true;
|
|
485
510
|
}
|
|
486
511
|
} catch (_error) {
|
|
487
|
-
_optionalChain([logger, 'optionalAccess',
|
|
512
|
+
_optionalChain([logger, 'optionalAccess', _76 => _76.error, 'call', _77 => _77(`Error parsing ${providerName} stream chunk: ${chunkStr}`)]);
|
|
488
513
|
}
|
|
489
514
|
};
|
|
490
515
|
try {
|
|
@@ -528,7 +553,7 @@ function createChunk(options) {
|
|
|
528
553
|
choices: [
|
|
529
554
|
{
|
|
530
555
|
delta,
|
|
531
|
-
finish_reason: _optionalChain([finishReason, 'optionalAccess',
|
|
556
|
+
finish_reason: _optionalChain([finishReason, 'optionalAccess', _78 => _78.toLowerCase, 'call', _79 => _79()]) || null,
|
|
532
557
|
index: contentIndex,
|
|
533
558
|
logprobs: null
|
|
534
559
|
}
|
|
@@ -552,19 +577,19 @@ function createChunk(options) {
|
|
|
552
577
|
}
|
|
553
578
|
};
|
|
554
579
|
}
|
|
555
|
-
if (_optionalChain([groundingMetadata, 'optionalAccess',
|
|
580
|
+
if (_optionalChain([groundingMetadata, 'optionalAccess', _80 => _80.groundingChunks, 'optionalAccess', _81 => _81.length])) {
|
|
556
581
|
const annotations = groundingMetadata.groundingChunks.map((groundingChunk, index) => {
|
|
557
|
-
const support = _optionalChain([groundingMetadata, 'access',
|
|
558
|
-
(s) => _optionalChain([s, 'access',
|
|
582
|
+
const support = _optionalChain([groundingMetadata, 'access', _82 => _82.groundingSupports, 'optionalAccess', _83 => _83.find, 'call', _84 => _84(
|
|
583
|
+
(s) => _optionalChain([s, 'access', _85 => _85.groundingChunkIndices, 'optionalAccess', _86 => _86.includes, 'call', _87 => _87(index)])
|
|
559
584
|
)]);
|
|
560
585
|
return {
|
|
561
586
|
type: "url_citation",
|
|
562
587
|
url_citation: {
|
|
563
|
-
url: _optionalChain([groundingChunk, 'access',
|
|
564
|
-
title: _optionalChain([groundingChunk, 'access',
|
|
565
|
-
content: _optionalChain([support, 'optionalAccess',
|
|
566
|
-
start_index: _optionalChain([support, 'optionalAccess',
|
|
567
|
-
end_index: _optionalChain([support, 'optionalAccess',
|
|
588
|
+
url: _optionalChain([groundingChunk, 'access', _88 => _88.web, 'optionalAccess', _89 => _89.uri]) || "",
|
|
589
|
+
title: _optionalChain([groundingChunk, 'access', _90 => _90.web, 'optionalAccess', _91 => _91.title]) || "",
|
|
590
|
+
content: _optionalChain([support, 'optionalAccess', _92 => _92.segment, 'optionalAccess', _93 => _93.text]) || "",
|
|
591
|
+
start_index: _optionalChain([support, 'optionalAccess', _94 => _94.segment, 'optionalAccess', _95 => _95.startIndex]) || 0,
|
|
592
|
+
end_index: _optionalChain([support, 'optionalAccess', _96 => _96.segment, 'optionalAccess', _97 => _97.endIndex]) || 0
|
|
568
593
|
}
|
|
569
594
|
};
|
|
570
595
|
});
|
|
@@ -612,10 +637,10 @@ function processJsonSchema(jsonSchema) {
|
|
|
612
637
|
}
|
|
613
638
|
const incomingAnyOf = workingSchema.anyOf;
|
|
614
639
|
if (incomingAnyOf && Array.isArray(incomingAnyOf) && incomingAnyOf.length === 2) {
|
|
615
|
-
if (_optionalChain([incomingAnyOf, 'access',
|
|
640
|
+
if (_optionalChain([incomingAnyOf, 'access', _98 => _98[0], 'optionalAccess', _99 => _99.type]) === "null") {
|
|
616
641
|
genAISchema.nullable = true;
|
|
617
642
|
workingSchema = incomingAnyOf[1];
|
|
618
|
-
} else if (_optionalChain([incomingAnyOf, 'access',
|
|
643
|
+
} else if (_optionalChain([incomingAnyOf, 'access', _100 => _100[1], 'optionalAccess', _101 => _101.type]) === "null") {
|
|
619
644
|
genAISchema.nullable = true;
|
|
620
645
|
workingSchema = incomingAnyOf[0];
|
|
621
646
|
}
|
|
@@ -697,19 +722,19 @@ function transformTool(tool) {
|
|
|
697
722
|
// src/transformer/transformers/utils/gemini.util.ts
|
|
698
723
|
function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
699
724
|
const tools = [];
|
|
700
|
-
const functionDeclarations = _optionalChain([request, 'access',
|
|
725
|
+
const functionDeclarations = _optionalChain([request, 'access', _102 => _102.tools, 'optionalAccess', _103 => _103.filter, 'call', _104 => _104((tool) => tool.function.name !== "web_search"), 'optionalAccess', _105 => _105.map, 'call', _106 => _106((tool) => ({
|
|
701
726
|
name: tool.function.name,
|
|
702
727
|
description: tool.function.description,
|
|
703
728
|
parametersJsonSchema: tool.function.parameters
|
|
704
729
|
}))]);
|
|
705
|
-
if (_optionalChain([functionDeclarations, 'optionalAccess',
|
|
730
|
+
if (_optionalChain([functionDeclarations, 'optionalAccess', _107 => _107.length])) {
|
|
706
731
|
tools.push(
|
|
707
732
|
transformTool({
|
|
708
733
|
functionDeclarations
|
|
709
734
|
})
|
|
710
735
|
);
|
|
711
736
|
}
|
|
712
|
-
const webSearch = _optionalChain([request, 'access',
|
|
737
|
+
const webSearch = _optionalChain([request, 'access', _108 => _108.tools, 'optionalAccess', _109 => _109.find, 'call', _110 => _110((tool) => tool.function.name === "web_search")]);
|
|
713
738
|
if (webSearch) {
|
|
714
739
|
tools.push({ googleSearch: {} });
|
|
715
740
|
}
|
|
@@ -727,7 +752,7 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
727
752
|
const parts = [];
|
|
728
753
|
if (typeof message.content === "string") {
|
|
729
754
|
const part = { text: message.content };
|
|
730
|
-
if (_optionalChain([message, 'access',
|
|
755
|
+
if (_optionalChain([message, 'access', _111 => _111.thinking, 'optionalAccess', _112 => _112.signature])) {
|
|
731
756
|
part.thoughtSignature = message.thinking.signature;
|
|
732
757
|
}
|
|
733
758
|
parts.push(part);
|
|
@@ -736,7 +761,7 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
736
761
|
if (content.type === "text") {
|
|
737
762
|
parts.push({ text: content.text || "" });
|
|
738
763
|
} else if (content.type === "image_url") {
|
|
739
|
-
const imageUrl = _nullishCoalesce(_optionalChain([content, 'access',
|
|
764
|
+
const imageUrl = _nullishCoalesce(_optionalChain([content, 'access', _113 => _113.image_url, 'optionalAccess', _114 => _114.url]), () => ( ""));
|
|
740
765
|
if (imageUrl.startsWith("http")) {
|
|
741
766
|
parts.push({
|
|
742
767
|
file_data: {
|
|
@@ -773,7 +798,7 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
773
798
|
args: JSON.parse(toolCall.function.arguments || "{}")
|
|
774
799
|
}
|
|
775
800
|
};
|
|
776
|
-
if (index === 0 && _optionalChain([message, 'access',
|
|
801
|
+
if (index === 0 && _optionalChain([message, 'access', _115 => _115.thinking, 'optionalAccess', _116 => _116.signature])) {
|
|
777
802
|
functionCallPart.thoughtSignature = message.thinking.signature;
|
|
778
803
|
}
|
|
779
804
|
parts.push(functionCallPart);
|
|
@@ -789,8 +814,8 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
789
814
|
const response = toolResponses.find((item) => item.tool_call_id === tool.id);
|
|
790
815
|
return {
|
|
791
816
|
functionResponse: {
|
|
792
|
-
name: _nullishCoalesce(_optionalChain([tool, 'access',
|
|
793
|
-
response: { result: _optionalChain([response, 'optionalAccess',
|
|
817
|
+
name: _nullishCoalesce(_optionalChain([tool, 'access', _117 => _117.function, 'optionalAccess', _118 => _118.name]), () => ( "")),
|
|
818
|
+
response: { result: _optionalChain([response, 'optionalAccess', _119 => _119.content]) }
|
|
794
819
|
}
|
|
795
820
|
};
|
|
796
821
|
}
|
|
@@ -821,17 +846,20 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
821
846
|
requestMaxTokens: request.max_tokens,
|
|
822
847
|
preserveNativeEffort
|
|
823
848
|
});
|
|
824
|
-
if (_optionalChain([reasoningPlan, 'optionalAccess',
|
|
849
|
+
if (_optionalChain([reasoningPlan, 'optionalAccess', _120 => _120.kind]) === "level") {
|
|
825
850
|
generationConfig.thinkingConfig = {
|
|
826
851
|
includeThoughts: reasoningPlan.enabled,
|
|
827
852
|
thinkingLevel: reasoningPlan.effort
|
|
828
853
|
};
|
|
829
|
-
} else if (_optionalChain([reasoningPlan, 'optionalAccess',
|
|
854
|
+
} else if (_optionalChain([reasoningPlan, 'optionalAccess', _121 => _121.kind]) === "budget") {
|
|
830
855
|
generationConfig.thinkingConfig = {
|
|
831
856
|
includeThoughts: reasoningPlan.enabled,
|
|
832
857
|
thinkingBudget: reasoningPlan.budgetTokens
|
|
833
858
|
};
|
|
834
859
|
}
|
|
860
|
+
if (!generationConfig.responseModalities && typeof request.model === "string" && request.model.startsWith("gemini") && request.model.includes("-image")) {
|
|
861
|
+
generationConfig.responseModalities = ["TEXT", "IMAGE"];
|
|
862
|
+
}
|
|
835
863
|
const body = {
|
|
836
864
|
contents,
|
|
837
865
|
tools: tools.length > 0 ? tools : void 0,
|
|
@@ -847,7 +875,7 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
847
875
|
toolConfig.functionCallingConfig.mode = "none";
|
|
848
876
|
} else if (request.tool_choice === "required") {
|
|
849
877
|
toolConfig.functionCallingConfig.mode = "any";
|
|
850
|
-
} else if (typeof request.tool_choice === "object" && _optionalChain([request, 'access',
|
|
878
|
+
} else if (typeof request.tool_choice === "object" && _optionalChain([request, 'access', _122 => _122.tool_choice, 'access', _123 => _123.function, 'optionalAccess', _124 => _124.name])) {
|
|
851
879
|
toolConfig.functionCallingConfig.mode = "any";
|
|
852
880
|
toolConfig.functionCallingConfig.allowedFunctionNames = [
|
|
853
881
|
request.tool_choice.function.name
|
|
@@ -862,7 +890,7 @@ function transformRequestOut(request) {
|
|
|
862
890
|
const tools = request.tools;
|
|
863
891
|
const model = request.model;
|
|
864
892
|
const generationConfig = request.generationConfig;
|
|
865
|
-
const maxTokens = _nullishCoalesce(_optionalChain([generationConfig, 'optionalAccess',
|
|
893
|
+
const maxTokens = _nullishCoalesce(_optionalChain([generationConfig, 'optionalAccess', _125 => _125.maxOutputTokens]), () => ( request.max_tokens));
|
|
866
894
|
const temperature = request.temperature;
|
|
867
895
|
const stream = request.stream;
|
|
868
896
|
const toolChoice = request.tool_choice;
|
|
@@ -874,14 +902,14 @@ function transformRequestOut(request) {
|
|
|
874
902
|
stream,
|
|
875
903
|
tool_choice: toolChoice
|
|
876
904
|
};
|
|
877
|
-
const thinkingConfig = _optionalChain([generationConfig, 'optionalAccess',
|
|
878
|
-
const discreteEffort = _chunkIUL4VWNUcjs.normalizeThinkLevel.call(void 0, _optionalChain([thinkingConfig, 'optionalAccess',
|
|
905
|
+
const thinkingConfig = _optionalChain([generationConfig, 'optionalAccess', _126 => _126.thinkingConfig]);
|
|
906
|
+
const discreteEffort = _chunkIUL4VWNUcjs.normalizeThinkLevel.call(void 0, _optionalChain([thinkingConfig, 'optionalAccess', _127 => _127.thinkingLevel]));
|
|
879
907
|
if (discreteEffort) {
|
|
880
908
|
unifiedRequest.reasoning = {
|
|
881
909
|
effort: discreteEffort,
|
|
882
910
|
enabled: discreteEffort !== "none"
|
|
883
911
|
};
|
|
884
|
-
} else if (typeof _optionalChain([thinkingConfig, 'optionalAccess',
|
|
912
|
+
} else if (typeof _optionalChain([thinkingConfig, 'optionalAccess', _128 => _128.thinkingBudget]) === "number" && Number.isFinite(thinkingConfig.thinkingBudget) && thinkingConfig.thinkingBudget >= 0) {
|
|
885
913
|
const budget = thinkingConfig.thinkingBudget;
|
|
886
914
|
unifiedRequest.reasoning = budget === 0 ? { effort: "none", enabled: false, max_tokens: 0 } : { effort: _chunk77USGNRWcjs.getThinkLevel.call(void 0, budget), enabled: true, max_tokens: budget };
|
|
887
915
|
}
|
|
@@ -923,14 +951,14 @@ function transformRequestOut(request) {
|
|
|
923
951
|
} else if ("inlineData" in part || "file_data" in part) {
|
|
924
952
|
const inline = part.inlineData;
|
|
925
953
|
const fileData = part.file_data;
|
|
926
|
-
if (_optionalChain([inline, 'optionalAccess',
|
|
954
|
+
if (_optionalChain([inline, 'optionalAccess', _129 => _129.data])) {
|
|
927
955
|
const mime = inline.mime_type || "image/png";
|
|
928
956
|
contentParts.push({
|
|
929
957
|
type: "image_url",
|
|
930
958
|
image_url: { url: `data:${mime};base64,${inline.data}` },
|
|
931
959
|
media_type: mime
|
|
932
960
|
});
|
|
933
|
-
} else if (_optionalChain([fileData, 'optionalAccess',
|
|
961
|
+
} else if (_optionalChain([fileData, 'optionalAccess', _130 => _130.file_uri])) {
|
|
934
962
|
contentParts.push({
|
|
935
963
|
type: "image_url",
|
|
936
964
|
image_url: { url: fileData.file_uri },
|
|
@@ -950,7 +978,7 @@ function transformRequestOut(request) {
|
|
|
950
978
|
const queue = toolCallIdsByName.get(fnName);
|
|
951
979
|
const id = queue && queue.length > 0 ? queue.shift() : `tool_${Math.random().toString(36).substring(2, 15)}`;
|
|
952
980
|
const response = fr.functionResponse.response;
|
|
953
|
-
const result = _optionalChain([response, 'optionalAccess',
|
|
981
|
+
const result = _optionalChain([response, 'optionalAccess', _131 => _131.result]);
|
|
954
982
|
const toolContent = typeof result === "string" ? result : result !== void 0 ? JSON.stringify(result) : response !== void 0 ? JSON.stringify(response) : "";
|
|
955
983
|
unifiedRequest.messages.push({
|
|
956
984
|
role: "tool",
|
|
@@ -1811,6 +1811,11 @@ function assertFiniteImageApiLimits(limits) {
|
|
|
1811
1811
|
throw new TypeError("Image API aggregate output limit must cover one output.");
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
|
+
function resolveImageRequestProvider(runtime, model) {
|
|
1815
|
+
const providerId = runtime.modelRoutes.get(model);
|
|
1816
|
+
if (!providerId) throw new ImageGenerationError("unsupported_model", { param: "model" });
|
|
1817
|
+
return providerId;
|
|
1818
|
+
}
|
|
1814
1819
|
|
|
1815
1820
|
// src/image-generation/openai-images/generateHandler.ts
|
|
1816
1821
|
function validateRuntime(runtime) {
|
|
@@ -1863,7 +1868,10 @@ function createImageGenerateHandler(deps) {
|
|
|
1863
1868
|
...runtime.preferredAccountGroup ? { preferredAccountGroup: runtime.preferredAccountGroup } : {},
|
|
1864
1869
|
...runtime.boundAccountFallbackPolicy ? { boundAccountFallbackPolicy: runtime.boundAccountFallbackPolicy } : {}
|
|
1865
1870
|
},
|
|
1866
|
-
{
|
|
1871
|
+
{
|
|
1872
|
+
providerId: resolveImageRequestProvider(runtime, request2.model),
|
|
1873
|
+
...runtime.retention ? { retention: runtime.retention } : {}
|
|
1874
|
+
}
|
|
1867
1875
|
);
|
|
1868
1876
|
if (request2.stream) {
|
|
1869
1877
|
await writeImageApiSse({
|
|
@@ -2536,7 +2544,10 @@ function createImageEditHandler(deps) {
|
|
|
2536
2544
|
...runtime.preferredAccountGroup ? { preferredAccountGroup: runtime.preferredAccountGroup } : {},
|
|
2537
2545
|
...runtime.boundAccountFallbackPolicy ? { boundAccountFallbackPolicy: runtime.boundAccountFallbackPolicy } : {}
|
|
2538
2546
|
},
|
|
2539
|
-
{
|
|
2547
|
+
{
|
|
2548
|
+
providerId: resolveImageRequestProvider(runtime, request2.model),
|
|
2549
|
+
...runtime.retention ? { retention: runtime.retention } : {}
|
|
2550
|
+
}
|
|
2540
2551
|
);
|
|
2541
2552
|
if (request2.stream) {
|
|
2542
2553
|
await writeImageApiSse({
|
|
@@ -2883,6 +2894,7 @@ var NORMALIZATION_RUNTIME = {
|
|
|
2883
2894
|
providerId: "responses-image-inspection",
|
|
2884
2895
|
defaultModel: "responses-image-model",
|
|
2885
2896
|
modelAliases: /* @__PURE__ */ new Map(),
|
|
2897
|
+
modelRoutes: /* @__PURE__ */ new Map(),
|
|
2886
2898
|
limits: DEFAULT_IMAGE_API_LIMITS
|
|
2887
2899
|
};
|
|
2888
2900
|
function invalid5(param) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkQBZJ7P2Tcjs = require('./chunk-QBZJ7P2T.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkLL3MZ7O5cjs = require('./chunk-LL3MZ7O5.cjs');
|
|
7
7
|
|
|
8
8
|
// src/outbound-api/kindDetection.ts
|
|
9
9
|
var _canonicalmodels = require('@omnicross/contracts/canonical-models');
|
|
@@ -66,15 +66,15 @@ function isNonBlankRef(ref) {
|
|
|
66
66
|
return typeof ref === "string" && ref.trim() !== "";
|
|
67
67
|
}
|
|
68
68
|
function isKindMappedEndpoint(endpoint) {
|
|
69
|
-
return Object.prototype.hasOwnProperty.call(
|
|
69
|
+
return Object.prototype.hasOwnProperty.call(_chunkLL3MZ7O5cjs.ENDPOINT_MODEL_KINDS, endpoint);
|
|
70
70
|
}
|
|
71
71
|
function modelKindsForEndpoint(endpoint) {
|
|
72
|
-
return
|
|
72
|
+
return _chunkLL3MZ7O5cjs.ENDPOINT_MODEL_KINDS[endpoint];
|
|
73
73
|
}
|
|
74
74
|
function detectModelKind(endpoint, requestedModelId) {
|
|
75
75
|
if (!requestedModelId || requestedModelId.trim() === "") return void 0;
|
|
76
76
|
if (endpoint === "messages") {
|
|
77
|
-
const declared =
|
|
77
|
+
const declared = _chunkLL3MZ7O5cjs.ENDPOINT_MODEL_KINDS.messages;
|
|
78
78
|
for (const tok of modelTokens(_canonicalmodels.normalizeModelId.call(void 0, requestedModelId))) {
|
|
79
79
|
if (declared.includes(tok)) return tok;
|
|
80
80
|
}
|
|
@@ -122,7 +122,8 @@ var SUBSCRIPTION_PROVIDER_IDS = [
|
|
|
122
122
|
"opencodego",
|
|
123
123
|
"kimi",
|
|
124
124
|
"grok",
|
|
125
|
-
"copilot"
|
|
125
|
+
"copilot",
|
|
126
|
+
"antigravity"
|
|
126
127
|
];
|
|
127
128
|
var SUBSCRIPTION_ID_SET = new Set(SUBSCRIPTION_PROVIDER_IDS);
|
|
128
129
|
function isSubscriptionProviderId(providerId) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/outbound-api/types.ts
|
|
2
|
+
var IMAGE_PROVIDER_IDS = [
|
|
3
|
+
"codex-subscription",
|
|
4
|
+
"antigravity-subscription"
|
|
5
|
+
];
|
|
6
|
+
var DEFAULT_IMAGE_MODEL_ROUTES = Object.freeze({
|
|
7
|
+
"gpt-image-2": "codex-subscription",
|
|
8
|
+
"gpt-image-2-5": "codex-subscription",
|
|
9
|
+
"gemini-2.5-flash-image": "antigravity-subscription",
|
|
10
|
+
"gemini-2.5-flash-image-preview": "antigravity-subscription",
|
|
11
|
+
"gemini-3.1-flash-image": "antigravity-subscription",
|
|
12
|
+
"gemini-3.1-flash-image-preview": "antigravity-subscription",
|
|
13
|
+
"gemini-3-pro-image-preview": "antigravity-subscription"
|
|
14
|
+
});
|
|
15
|
+
var ENDPOINT_MODEL_KINDS = {
|
|
16
|
+
messages: ["fable", "opus", "sonnet", "haiku"],
|
|
17
|
+
responses: ["codex", "mini"]
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
IMAGE_PROVIDER_IDS,
|
|
22
|
+
DEFAULT_IMAGE_MODEL_ROUTES,
|
|
23
|
+
ENDPOINT_MODEL_KINDS
|
|
24
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkUKQHBK4Qcjs = require('./chunk-UKQHBK4Q.cjs');
|
|
5
|
+
|
|
6
|
+
// src/provider-proxy/identity/codexCliHeaders.ts
|
|
7
|
+
var DEFAULT_CODEX_CLI_HEADERS = Object.freeze({
|
|
8
|
+
originator: "codex_cli_rs",
|
|
9
|
+
"user-agent": "codex_cli_rs/0.144.5",
|
|
10
|
+
version: "0.144.5"
|
|
11
|
+
});
|
|
12
|
+
var CODEX_FORWARD_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
13
|
+
"version",
|
|
14
|
+
"openai-beta",
|
|
15
|
+
"session_id",
|
|
16
|
+
"originator",
|
|
17
|
+
"user-agent"
|
|
18
|
+
]);
|
|
19
|
+
function extractCodexClientHeaders(reqHeaders) {
|
|
20
|
+
const out = {};
|
|
21
|
+
for (const [rawKey, rawVal] of Object.entries(reqHeaders)) {
|
|
22
|
+
const key = rawKey.toLowerCase();
|
|
23
|
+
if (_chunkUKQHBK4Qcjs.NEVER_FORWARD_HEADERS.has(key)) continue;
|
|
24
|
+
if (!CODEX_FORWARD_ALLOWLIST.has(key)) continue;
|
|
25
|
+
const value = _chunkUKQHBK4Qcjs.flattenHeaderValue.call(void 0, rawVal);
|
|
26
|
+
if (value !== void 0) out[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
function codexAcceptHeader(isStream) {
|
|
31
|
+
return isStream ? "text/event-stream" : "application/json";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
exports.DEFAULT_CODEX_CLI_HEADERS = DEFAULT_CODEX_CLI_HEADERS; exports.extractCodexClientHeaders = extractCodexClientHeaders; exports.codexAcceptHeader = codexAcceptHeader;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk4NAMH4UEcjs = require('./chunk-4NAMH4UE.cjs');
|
|
7
7
|
|
|
8
8
|
// src/transformer/transformers/GeminiTransformer.ts
|
|
9
9
|
var GeminiTransformer = (_class = class {
|
|
@@ -44,7 +44,7 @@ var GeminiTransformer = (_class = class {
|
|
|
44
44
|
* Also builds the correct URL for the Gemini API
|
|
45
45
|
*/
|
|
46
46
|
async transformRequestIn(request, provider, context) {
|
|
47
|
-
const body =
|
|
47
|
+
const body = _chunk4NAMH4UEcjs.buildRequestBody.call(void 0,
|
|
48
48
|
request,
|
|
49
49
|
provider,
|
|
50
50
|
context.reasoningSourceFormat === this.name
|
|
@@ -69,7 +69,7 @@ var GeminiTransformer = (_class = class {
|
|
|
69
69
|
* (For requests coming into the Gemini endpoint)
|
|
70
70
|
*/
|
|
71
71
|
async transformRequestOut(request, context) {
|
|
72
|
-
const unifiedRequest =
|
|
72
|
+
const unifiedRequest = _chunk4NAMH4UEcjs.transformRequestOut.call(void 0, request);
|
|
73
73
|
if (_optionalChain([unifiedRequest, 'access', _2 => _2.reasoning, 'optionalAccess', _3 => _3.effort])) {
|
|
74
74
|
context.reasoningSourceFormat = this.name;
|
|
75
75
|
}
|
|
@@ -79,14 +79,14 @@ var GeminiTransformer = (_class = class {
|
|
|
79
79
|
* Transform Gemini response to OpenAI-compatible format
|
|
80
80
|
*/
|
|
81
81
|
async transformResponseOut(response, _context) {
|
|
82
|
-
return
|
|
82
|
+
return _chunk4NAMH4UEcjs.transformResponseOut.call(void 0, response, this.name, this.logger);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Transform OpenAI-compatible response back to Gemini format
|
|
86
86
|
* (For endpoint mode — returning Gemini-format responses to the client)
|
|
87
87
|
*/
|
|
88
88
|
async transformResponseIn(response, _context) {
|
|
89
|
-
return
|
|
89
|
+
return _chunk4NAMH4UEcjs.transformResponseIn.call(void 0, response, this.logger);
|
|
90
90
|
}
|
|
91
91
|
}, _class.__initStatic(), _class);
|
|
92
92
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
2
|
+
|
|
3
|
+
var _chunkX6GHTNDLcjs = require('./chunk-X6GHTNDL.cjs');
|
|
4
|
+
|
|
5
|
+
// src/transformer/transformers/antigravityFailover.ts
|
|
6
|
+
var ANTIGRAVITY_SANDBOX_ENDPOINT = "https://daily-cloudcode-pa.sandbox.googleapis.com";
|
|
7
|
+
var sandboxFailoverEnabled = false;
|
|
8
|
+
function setAntigravitySandboxFailover(enabled) {
|
|
9
|
+
sandboxFailoverEnabled = enabled;
|
|
10
|
+
}
|
|
11
|
+
function isAntigravitySandboxFailoverEnabled() {
|
|
12
|
+
return sandboxFailoverEnabled;
|
|
13
|
+
}
|
|
14
|
+
function __resetAntigravityFailoverState() {
|
|
15
|
+
sandboxFailoverEnabled = false;
|
|
16
|
+
}
|
|
17
|
+
function isAntigravityRetryableFailure(status, bodyText) {
|
|
18
|
+
if (status === null) return true;
|
|
19
|
+
if (status === 429 || status >= 500) return true;
|
|
20
|
+
if (status === 400 || status === 404) {
|
|
21
|
+
const message = (_nullishCoalesce(bodyText, () => ( ""))).toLowerCase();
|
|
22
|
+
return message.includes("requested model is currently unavailable") || message.includes("requested entity was not found") || message.includes("not found") || message.includes("tool_use") || message.includes("tool_result");
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function maybeAntigravityFailoverUrl(failedUrl, status, bodyText, methodPath) {
|
|
27
|
+
if (!sandboxFailoverEnabled) return null;
|
|
28
|
+
if (!isAntigravityRetryableFailure(status, bodyText)) return null;
|
|
29
|
+
let parsed;
|
|
30
|
+
try {
|
|
31
|
+
parsed = new URL(failedUrl);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (parsed.origin !== _chunkX6GHTNDLcjs.ANTIGRAVITY_ENDPOINT) return null;
|
|
36
|
+
const tail = _nullishCoalesce(methodPath, () => ( `${parsed.pathname}${parsed.search}`));
|
|
37
|
+
return `${ANTIGRAVITY_SANDBOX_ENDPOINT}${tail.startsWith("/") ? tail : `/${tail}`}`;
|
|
38
|
+
}
|
|
39
|
+
async function fetchWithAntigravityFailover(url, fetcher, signal) {
|
|
40
|
+
_optionalChain([signal, 'optionalAccess', _ => _.throwIfAborted, 'call', _2 => _2()]);
|
|
41
|
+
let response;
|
|
42
|
+
try {
|
|
43
|
+
response = await fetcher(url);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
_optionalChain([signal, 'optionalAccess', _3 => _3.throwIfAborted, 'call', _4 => _4()]);
|
|
46
|
+
const fallback2 = maybeAntigravityFailoverUrl(url, null);
|
|
47
|
+
if (!fallback2) throw error;
|
|
48
|
+
return fetcher(fallback2);
|
|
49
|
+
}
|
|
50
|
+
if (!sandboxFailoverEnabled || response.ok) return response;
|
|
51
|
+
const body = response.status === 400 || response.status === 404 ? await response.clone().text().catch(() => "") : void 0;
|
|
52
|
+
const fallback = maybeAntigravityFailoverUrl(url, response.status, body);
|
|
53
|
+
if (!fallback) return response;
|
|
54
|
+
await _optionalChain([response, 'access', _5 => _5.body, 'optionalAccess', _6 => _6.cancel, 'call', _7 => _7(), 'access', _8 => _8.catch, 'call', _9 => _9(() => void 0)]);
|
|
55
|
+
_optionalChain([signal, 'optionalAccess', _10 => _10.throwIfAborted, 'call', _11 => _11()]);
|
|
56
|
+
return fetcher(fallback);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
exports.ANTIGRAVITY_SANDBOX_ENDPOINT = ANTIGRAVITY_SANDBOX_ENDPOINT; exports.setAntigravitySandboxFailover = setAntigravitySandboxFailover; exports.isAntigravitySandboxFailoverEnabled = isAntigravitySandboxFailoverEnabled; exports.__resetAntigravityFailoverState = __resetAntigravityFailoverState; exports.isAntigravityRetryableFailure = isAntigravityRetryableFailure; exports.maybeAntigravityFailoverUrl = maybeAntigravityFailoverUrl; exports.fetchWithAntigravityFailover = fetchWithAntigravityFailover;
|