@omnicross/core 0.1.10 → 0.2.1
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/README.md +7 -0
- package/dist/{BuiltinToolExecutor-CS2WpXhM.d.cts → BuiltinToolExecutor-BHgH-EaZ.d.cts} +25 -2
- package/dist/{BuiltinToolExecutor-BluWyeob.d.ts → BuiltinToolExecutor-Bi1LmiTP.d.ts} +25 -2
- package/dist/{CompletionService-kNA17cfI.d.cts → CompletionService-BniP7j88.d.cts} +2 -2
- package/dist/{CompletionService-C3BX0Ovy.d.ts → CompletionService-BqrKPwfA.d.ts} +2 -2
- package/dist/{ProviderProxy-QdwNV6l1.d.cts → ProviderProxy-Bz_nkOwq.d.cts} +1 -1
- package/dist/{ProviderProxy--ROec6VI.d.ts → ProviderProxy-Ckr6oTrE.d.ts} +1 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -6
- package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -4
- package/dist/{chunk-NGYOO5TO.js → chunk-2C3TTBS7.js} +7 -7
- package/dist/{chunk-QUSEZNYS.cjs → chunk-32SRZFFP.cjs} +4 -1
- package/dist/chunk-4JOU54M5.js +200 -0
- package/dist/{chunk-2UTGX6FM.js → chunk-4VVCXVB7.js} +1 -1
- package/dist/{chunk-RJUONLUQ.cjs → chunk-4Z3ZLLC2.cjs} +14 -8
- package/dist/chunk-6DDYNS2B.cjs +384 -0
- package/dist/{chunk-GXEZ2R3E.js → chunk-6OKXH2TW.js} +18 -7
- package/dist/{chunk-YWL7YZWS.cjs → chunk-7LRTPNFL.cjs} +5 -0
- package/dist/{chunk-CCVRRJOX.js → chunk-7PIUVCKK.js} +9 -2
- package/dist/chunk-7RJI3NDI.cjs +236 -0
- package/dist/{chunk-IIRPUVPH.cjs → chunk-7ZHBN75N.cjs} +3 -1
- package/dist/chunk-D4WNI6BR.cjs +386 -0
- package/dist/chunk-DBBR6RHF.js +236 -0
- package/dist/chunk-E4QHVXV5.cjs +118 -0
- package/dist/{chunk-HKB656B4.js → chunk-EUZRH544.js} +55 -287
- package/dist/{chunk-WNKWAEUR.js → chunk-EYGBM2VC.js} +3 -1
- package/dist/{chunk-UWDW6PN3.cjs → chunk-FX325I5Q.cjs} +20 -9
- package/dist/chunk-G4CZIUIB.cjs +200 -0
- package/dist/chunk-HCOQQAZE.cjs +123 -0
- package/dist/chunk-HL2YSPL7.cjs +673 -0
- package/dist/{chunk-55FMGZ3L.js → chunk-HN74IGEO.js} +1 -1
- package/dist/{chunk-ZY6KU6P3.js → chunk-HOMUGKHR.js} +8 -5
- package/dist/{chunk-AOFWNWLT.cjs → chunk-IUL4VWNU.cjs} +22 -1
- package/dist/{chunk-5LNYGCIW.cjs → chunk-KIQ2HA2A.cjs} +5 -5
- package/dist/{chunk-MUHWHQVM.cjs → chunk-KQBLZMP6.cjs} +4 -3
- package/dist/chunk-LFEH7CEO.js +384 -0
- package/dist/chunk-LFPQ2OVH.js +386 -0
- package/dist/{chunk-FEBAQI5A.js → chunk-LKDAN4D7.js} +6363 -1350
- package/dist/chunk-LQYS2N47.js +3923 -0
- package/dist/{chunk-NZYN7C3P.cjs → chunk-MPXOKQJP.cjs} +53 -53
- package/dist/chunk-MZEGQSKQ.js +118 -0
- package/dist/chunk-N76KU6F5.js +123 -0
- package/dist/chunk-NLUOTJWB.js +673 -0
- package/dist/{chunk-CMVXX7ON.cjs → chunk-NOITAVHA.cjs} +114 -58
- package/dist/{chunk-Q27JY5RG.cjs → chunk-OIKREZVQ.cjs} +7 -4
- package/dist/{chunk-ZQQUD66M.cjs → chunk-POUTD5AM.cjs} +63 -295
- package/dist/{chunk-6D4W22P4.js → chunk-QIIAMBTM.js} +4 -1
- package/dist/{chunk-56QD3YW6.cjs → chunk-QWNUOR7F.cjs} +11 -4
- package/dist/{chunk-S3DYFEBE.js → chunk-R4VCO2CB.js} +10 -1
- package/dist/{chunk-4VZX5F4T.cjs → chunk-T6NWPIYZ.cjs} +5 -2
- package/dist/{chunk-EBLFCNPY.js → chunk-U47LQXPB.js} +5 -2
- package/dist/chunk-UPQIWJIE.cjs +3923 -0
- package/dist/{chunk-N7OOJI5V.js → chunk-V2UKUTJ3.js} +5 -0
- package/dist/{chunk-45FHEOKW.js → chunk-V53ZEFXC.js} +92 -36
- package/dist/{chunk-RJ5ZGNI3.js → chunk-VL5TUDTM.js} +8 -2
- package/dist/{chunk-TIT74RIL.cjs → chunk-VSYQ6XYN.cjs} +6837 -1824
- package/dist/{chunk-OC6DOOFX.cjs → chunk-VXRTQZF2.cjs} +5 -5
- package/dist/{chunk-RICPANBY.cjs → chunk-WX2E2G7H.cjs} +13 -4
- package/dist/{chunk-DE2SRBFZ.js → chunk-X335TJNS.js} +4 -3
- package/dist/{chunk-CDHS2QDC.js → chunk-Y4CRNHJO.js} +53 -53
- package/dist/{chunk-P7EM6BND.cjs → chunk-ZAPN7XA6.cjs} +10 -10
- package/dist/{chunk-N2EIM2XJ.js → chunk-ZLNHPUFA.js} +22 -1
- package/dist/completion/BuiltinToolExecutor.cjs +2 -2
- package/dist/completion/BuiltinToolExecutor.d.cts +3 -1
- package/dist/completion/BuiltinToolExecutor.d.ts +3 -1
- package/dist/completion/BuiltinToolExecutor.js +1 -1
- package/dist/completion/CompletionService.cjs +32 -28
- package/dist/completion/CompletionService.d.cts +7 -3
- package/dist/completion/CompletionService.d.ts +7 -3
- package/dist/completion/CompletionService.js +31 -27
- package/dist/completion.cjs +40 -36
- package/dist/completion.d.cts +7 -3
- package/dist/completion.d.ts +7 -3
- package/dist/completion.js +39 -35
- package/dist/egress-I46O_p5L.d.cts +126 -0
- package/dist/egress-I46O_p5L.d.ts +126 -0
- package/dist/frontends-Doz0RaWu.d.cts +97 -0
- package/dist/frontends-Doz0RaWu.d.ts +97 -0
- package/dist/image-generation.cjs +52 -0
- package/dist/image-generation.d.cts +96 -0
- package/dist/image-generation.d.ts +96 -0
- package/dist/image-generation.js +52 -0
- package/dist/index.cjs +142 -32
- package/dist/index.d.cts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.js +159 -49
- package/dist/openai-operation.cjs +18 -0
- package/dist/openai-operation.d.cts +22 -0
- package/dist/openai-operation.d.ts +22 -0
- package/dist/openai-operation.js +18 -0
- package/dist/outbound-api/auditCapture.cjs +3 -3
- package/dist/outbound-api/auditCapture.d.cts +13 -2
- package/dist/outbound-api/auditCapture.d.ts +13 -2
- package/dist/outbound-api/auditCapture.js +2 -2
- package/dist/outbound-api/auditRedact.cjs +2 -2
- package/dist/outbound-api/auditRedact.js +1 -1
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.d.cts +11 -4
- package/dist/outbound-api/routeResolver.d.ts +11 -4
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +5 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +5 -1
- package/dist/outbound-api/types.d.cts +10 -3
- package/dist/outbound-api/types.d.ts +10 -3
- package/dist/outbound-api.cjs +65 -33
- package/dist/outbound-api.d.cts +205 -10
- package/dist/outbound-api.d.ts +205 -10
- package/dist/outbound-api.js +64 -32
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +22 -15
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +22 -15
- package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
- package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.cjs +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +7 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +7 -0
- package/dist/pipeline/SubscriptionAccountHealth.js +1 -1
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.d.cts +11 -6
- package/dist/pipeline/executeProviderCall.d.ts +11 -6
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/upstreamFetch.cjs +2 -2
- package/dist/pipeline/upstreamFetch.d.cts +5 -0
- package/dist/pipeline/upstreamFetch.d.ts +5 -0
- package/dist/pipeline/upstreamFetch.js +1 -1
- package/dist/ports.d.cts +10 -3
- package/dist/ports.d.ts +10 -3
- package/dist/provider-proxy/ProviderProxy.cjs +32 -28
- package/dist/provider-proxy/ProviderProxy.d.cts +6 -2
- package/dist/provider-proxy/ProviderProxy.d.ts +6 -2
- package/dist/provider-proxy/ProviderProxy.js +31 -27
- package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
- package/dist/provider-proxy/identity/codexCliHeaders.d.cts +26 -6
- package/dist/provider-proxy/identity/codexCliHeaders.d.ts +26 -6
- package/dist/provider-proxy/identity/codexCliHeaders.js +5 -3
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +36 -28
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +41 -9
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +41 -9
- package/dist/provider-proxy/ingress/providerProxyShared.js +35 -27
- package/dist/provider-proxy/types.d.cts +17 -483
- package/dist/provider-proxy/types.d.ts +17 -483
- package/dist/provider-proxy.cjs +46 -28
- package/dist/provider-proxy.d.cts +34 -8
- package/dist/provider-proxy.d.ts +34 -8
- package/dist/provider-proxy.js +45 -27
- package/dist/proxy-UZTtjPZx.d.cts +18 -0
- package/dist/proxy-UZTtjPZx.d.ts +18 -0
- package/dist/{routeResolver-CVFE8KKe.d.cts → routeResolver-Da0yvkL1.d.cts} +4 -2
- package/dist/{routeResolver-C0mkkZaM.d.ts → routeResolver-STwMz_G4.d.ts} +4 -2
- package/dist/runtime-6QXNU526.cjs +8 -0
- package/dist/runtime-M5WXLD2R.js +8 -0
- package/dist/runtime-t8AZacFF.d.cts +233 -0
- package/dist/runtime-t8AZacFF.d.ts +233 -0
- package/dist/search/api.cjs +761 -0
- package/dist/search/api.d.cts +370 -0
- package/dist/search/api.d.ts +370 -0
- package/dist/search/api.js +761 -0
- package/dist/search/http.cjs +37 -0
- package/dist/search/http.d.cts +269 -0
- package/dist/search/http.d.ts +269 -0
- package/dist/search/http.js +37 -0
- package/dist/search.cjs +57 -0
- package/dist/search.d.cts +113 -0
- package/dist/search.d.ts +113 -0
- package/dist/search.js +57 -0
- package/dist/transformer/TransformerChainExecutor.cjs +2 -2
- package/dist/transformer/TransformerChainExecutor.d.cts +2 -2
- package/dist/transformer/TransformerChainExecutor.d.ts +2 -2
- package/dist/transformer/TransformerChainExecutor.js +1 -1
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +16 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.cts +53 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.ts +53 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +16 -0
- package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -3
- package/dist/transformer/transformers/AnthropicTransformer.js +3 -2
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +4 -4
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +3 -3
- package/dist/transformer/transformers/GeminiTransformer.cjs +4 -4
- package/dist/transformer/transformers/GeminiTransformer.js +3 -3
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -3
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -2
- package/dist/transformer/transformers/OpenAITransformer.cjs +3 -3
- package/dist/transformer/transformers/OpenAITransformer.js +2 -2
- package/dist/transformer/transformers.cjs +11 -10
- package/dist/transformer/transformers.js +12 -11
- package/dist/transformer/types.d.cts +39 -4
- package/dist/transformer/types.d.ts +39 -4
- package/dist/transformer.cjs +14 -13
- package/dist/transformer.js +13 -12
- package/dist/types-BSIJdsyl.d.cts +1130 -0
- package/dist/types-Be-yt_6T.d.cts +196 -0
- package/dist/types-By9Tg6-I.d.ts +1130 -0
- package/dist/types-CbCZqLGg.d.cts +127 -0
- package/dist/types-CbCZqLGg.d.ts +127 -0
- package/dist/{types-C2MwkLah.d.cts → types-D-oHYusb.d.cts} +250 -21
- package/dist/types-Dm4_36V4.d.ts +196 -0
- package/dist/{types-BB8pxk_3.d.ts → types-Dvlpjn0d.d.ts} +250 -21
- package/dist/usage.cjs +2 -2
- package/dist/usage.d.cts +6 -1
- package/dist/usage.d.ts +6 -1
- package/dist/usage.js +1 -1
- package/package.json +71 -64
- package/dist/chunk-FCR77GYM.cjs +0 -33
- package/dist/chunk-K5NM7VAH.js +0 -33
- /package/dist/{chunk-XXFYLL7R.js → chunk-ECZ3ZE2C.js} +0 -0
- /package/dist/{chunk-3SCOLIPT.cjs → chunk-MXI2PWIC.cjs} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
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; } var _class;
|
|
2
2
|
|
|
3
|
+
var _chunk6DDYNS2Bcjs = require('./chunk-6DDYNS2B.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunk5RSZYQJHcjs = require('./chunk-5RSZYQJH.cjs');
|
|
4
7
|
|
|
5
8
|
|
|
@@ -10,7 +13,8 @@ var _chunk77USGNRWcjs = require('./chunk-77USGNRW.cjs');
|
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
|
|
17
|
+
var _chunkIUL4VWNUcjs = require('./chunk-IUL4VWNU.cjs');
|
|
14
18
|
|
|
15
19
|
// src/transformer/transformers/AnthropicToolHandling.ts
|
|
16
20
|
function isServerSideTool(tool) {
|
|
@@ -155,6 +159,14 @@ function buildAnthropicRequestBody(request, provider) {
|
|
|
155
159
|
if (request.temperature !== void 0) {
|
|
156
160
|
body.temperature = request.temperature;
|
|
157
161
|
}
|
|
162
|
+
if (request.stop !== void 0 && request.stop.length > 0) {
|
|
163
|
+
body.stop_sequences = request.stop;
|
|
164
|
+
}
|
|
165
|
+
if (request.top_p !== void 0) body.top_p = request.top_p;
|
|
166
|
+
if (request.top_k !== void 0) body.top_k = request.top_k;
|
|
167
|
+
if (request.metadata_user_id !== void 0) {
|
|
168
|
+
body.metadata = { user_id: request.metadata_user_id };
|
|
169
|
+
}
|
|
158
170
|
if (systemContent !== void 0) {
|
|
159
171
|
body.system = systemContent;
|
|
160
172
|
}
|
|
@@ -180,8 +192,8 @@ function buildAnthropicRequestBody(request, provider) {
|
|
|
180
192
|
body.tool_choice = { type: "tool", name: request.tool_choice.function.name };
|
|
181
193
|
}
|
|
182
194
|
}
|
|
183
|
-
const reasoningPlan =
|
|
184
|
-
intent:
|
|
195
|
+
const reasoningPlan = _chunkIUL4VWNUcjs.resolveReasoningPlan.call(void 0, {
|
|
196
|
+
intent: _chunkIUL4VWNUcjs.extractReasoningIntent.call(void 0, request),
|
|
185
197
|
model: request.model,
|
|
186
198
|
provider,
|
|
187
199
|
target: "anthropic",
|
|
@@ -325,6 +337,7 @@ function convertOpenAIResponseToAnthropic(openaiResponse) {
|
|
|
325
337
|
function transformAnthropicRequestToUnified(request) {
|
|
326
338
|
const anthropicRequest = request;
|
|
327
339
|
const messages = [];
|
|
340
|
+
let redactedSeen = false;
|
|
328
341
|
if (anthropicRequest.system) {
|
|
329
342
|
if (typeof anthropicRequest.system === "string") {
|
|
330
343
|
messages.push({
|
|
@@ -419,15 +432,40 @@ function transformAnthropicRequestToUnified(request) {
|
|
|
419
432
|
}
|
|
420
433
|
}));
|
|
421
434
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
435
|
+
let thinkingText = "";
|
|
436
|
+
let firstSignature;
|
|
437
|
+
let sawRedacted = false;
|
|
438
|
+
for (const block of msg.content) {
|
|
439
|
+
if (block.type === "thinking") {
|
|
440
|
+
const t = block.thinking;
|
|
441
|
+
if (typeof t === "string" && t.length > 0) {
|
|
442
|
+
if (thinkingText.length > 0) thinkingText += "\n";
|
|
443
|
+
thinkingText += t;
|
|
444
|
+
}
|
|
445
|
+
const signature = block.signature;
|
|
446
|
+
if (signature) {
|
|
447
|
+
if (firstSignature === void 0) {
|
|
448
|
+
firstSignature = signature;
|
|
449
|
+
} else if (typeof t === "string" && t.length > 0) {
|
|
450
|
+
thinkingText += `
|
|
451
|
+
[signature: ${signature}]`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
} else if (block.type === "redacted_thinking") {
|
|
455
|
+
sawRedacted = true;
|
|
456
|
+
if (thinkingText.length > 0) thinkingText += "\n";
|
|
457
|
+
thinkingText += "[redacted thinking omitted]";
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (thinkingText.length > 0) {
|
|
426
461
|
assistantMessage.thinking = {
|
|
427
|
-
content:
|
|
428
|
-
signature:
|
|
462
|
+
content: thinkingText,
|
|
463
|
+
signature: firstSignature
|
|
429
464
|
};
|
|
430
465
|
}
|
|
466
|
+
if (sawRedacted) {
|
|
467
|
+
redactedSeen = true;
|
|
468
|
+
}
|
|
431
469
|
messages.push(assistantMessage);
|
|
432
470
|
}
|
|
433
471
|
}
|
|
@@ -441,8 +479,18 @@ function transformAnthropicRequestToUnified(request) {
|
|
|
441
479
|
max_tokens: anthropicRequest.max_tokens,
|
|
442
480
|
temperature: anthropicRequest.temperature,
|
|
443
481
|
stream: anthropicRequest.stream,
|
|
444
|
-
tools: _optionalChain([functionTools, 'optionalAccess',
|
|
482
|
+
tools: _optionalChain([functionTools, 'optionalAccess', _21 => _21.length]) ? functionTools : void 0
|
|
445
483
|
};
|
|
484
|
+
const raw = anthropicRequest;
|
|
485
|
+
if (Array.isArray(raw.stop_sequences)) {
|
|
486
|
+
result.stop = raw.stop_sequences.filter((s) => typeof s === "string");
|
|
487
|
+
}
|
|
488
|
+
if (typeof raw.top_p === "number") result.top_p = raw.top_p;
|
|
489
|
+
if (typeof raw.top_k === "number") result.top_k = raw.top_k;
|
|
490
|
+
if (typeof _optionalChain([raw, 'access', _22 => _22.metadata, 'optionalAccess', _23 => _23.user_id]) === "string") result.metadata_user_id = raw.metadata.user_id;
|
|
491
|
+
if (redactedSeen) {
|
|
492
|
+
_chunkIUL4VWNUcjs.recordDroppedField.call(void 0, result, "redacted_thinking", "unified");
|
|
493
|
+
}
|
|
446
494
|
if (serverSideTools.length > 0) {
|
|
447
495
|
result._serverSideTools = serverSideTools;
|
|
448
496
|
}
|
|
@@ -450,7 +498,7 @@ function transformAnthropicRequestToUnified(request) {
|
|
|
450
498
|
if (anthropicRequest.thinking.type === "disabled") {
|
|
451
499
|
result.reasoning = { effort: "none", enabled: false };
|
|
452
500
|
} else if (anthropicRequest.thinking.type === "adaptive") {
|
|
453
|
-
const effort =
|
|
501
|
+
const effort = _chunkIUL4VWNUcjs.normalizeThinkLevel.call(void 0, _optionalChain([anthropicRequest, 'access', _24 => _24.output_config, 'optionalAccess', _25 => _25.effort]));
|
|
454
502
|
if (effort) result.reasoning = { effort, enabled: effort !== "none" };
|
|
455
503
|
} else {
|
|
456
504
|
result.reasoning = {
|
|
@@ -574,7 +622,7 @@ function convertAnthropicStreamToOpenAI(anthropicStream, logger) {
|
|
|
574
622
|
`);
|
|
575
623
|
} else if (event.content_block.type === "web_search_tool_result") {
|
|
576
624
|
const searches = event.content_block.content;
|
|
577
|
-
if (_optionalChain([searches, 'optionalAccess',
|
|
625
|
+
if (_optionalChain([searches, 'optionalAccess', _26 => _26.length])) {
|
|
578
626
|
const formatted = searches.map((s) => `[${s.title}](${s.url}): ${s.page_content || s.snippet || ""}`).join("\n");
|
|
579
627
|
const chunk = {
|
|
580
628
|
id: messageId,
|
|
@@ -622,7 +670,7 @@ ${formatted}` },
|
|
|
622
670
|
`);
|
|
623
671
|
}
|
|
624
672
|
} catch (e) {
|
|
625
|
-
_optionalChain([logger, 'optionalAccess',
|
|
673
|
+
_optionalChain([logger, 'optionalAccess', _27 => _27.error, 'call', _28 => _28("Error parsing Anthropic stream event:", e)]);
|
|
626
674
|
}
|
|
627
675
|
}
|
|
628
676
|
}
|
|
@@ -644,286 +692,6 @@ ${formatted}` },
|
|
|
644
692
|
});
|
|
645
693
|
}
|
|
646
694
|
|
|
647
|
-
// src/transformer/transformers/AnthropicOpenAIToAnthropicStream.ts
|
|
648
|
-
function convertOpenAIStreamToAnthropic(openaiStream, _context, logger) {
|
|
649
|
-
const decoder = new TextDecoder();
|
|
650
|
-
const encoder = new TextEncoder();
|
|
651
|
-
let hasStarted = false;
|
|
652
|
-
let hasTextContentStarted = false;
|
|
653
|
-
let isThinkingStarted = false;
|
|
654
|
-
let contentIndex = 0;
|
|
655
|
-
let currentContentBlockIndex = -1;
|
|
656
|
-
const toolCallIndexToContentBlockIndex = /* @__PURE__ */ new Map();
|
|
657
|
-
return new ReadableStream({
|
|
658
|
-
start: async (controller) => {
|
|
659
|
-
const reader = openaiStream.getReader();
|
|
660
|
-
let buffer = "";
|
|
661
|
-
const messageId = `msg_${Date.now()}`;
|
|
662
|
-
let model = "unknown";
|
|
663
|
-
let isClosed = false;
|
|
664
|
-
let stopReasonDelta = null;
|
|
665
|
-
const safeEnqueue = (data) => {
|
|
666
|
-
if (!isClosed) {
|
|
667
|
-
try {
|
|
668
|
-
controller.enqueue(encoder.encode(data));
|
|
669
|
-
} catch (_e) {
|
|
670
|
-
isClosed = true;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
const assignContentBlockIndex = () => {
|
|
675
|
-
return contentIndex++;
|
|
676
|
-
};
|
|
677
|
-
const safeClose = () => {
|
|
678
|
-
if (isClosed) return;
|
|
679
|
-
if (currentContentBlockIndex >= 0) {
|
|
680
|
-
safeEnqueue(`event: content_block_stop
|
|
681
|
-
data: ${JSON.stringify({
|
|
682
|
-
type: "content_block_stop",
|
|
683
|
-
index: currentContentBlockIndex
|
|
684
|
-
})}
|
|
685
|
-
|
|
686
|
-
`);
|
|
687
|
-
}
|
|
688
|
-
if (stopReasonDelta) {
|
|
689
|
-
safeEnqueue(`event: message_delta
|
|
690
|
-
data: ${JSON.stringify(stopReasonDelta)}
|
|
691
|
-
|
|
692
|
-
`);
|
|
693
|
-
} else {
|
|
694
|
-
safeEnqueue(`event: message_delta
|
|
695
|
-
data: ${JSON.stringify({
|
|
696
|
-
type: "message_delta",
|
|
697
|
-
delta: { stop_reason: "end_turn", stop_sequence: null },
|
|
698
|
-
usage: { input_tokens: 0, output_tokens: 0 }
|
|
699
|
-
})}
|
|
700
|
-
|
|
701
|
-
`);
|
|
702
|
-
}
|
|
703
|
-
safeEnqueue(`event: message_stop
|
|
704
|
-
data: ${JSON.stringify({ type: "message_stop" })}
|
|
705
|
-
|
|
706
|
-
`);
|
|
707
|
-
try {
|
|
708
|
-
controller.close();
|
|
709
|
-
} catch (_e) {
|
|
710
|
-
}
|
|
711
|
-
isClosed = true;
|
|
712
|
-
};
|
|
713
|
-
try {
|
|
714
|
-
while (true) {
|
|
715
|
-
const { done, value } = await reader.read();
|
|
716
|
-
if (done) break;
|
|
717
|
-
buffer += decoder.decode(value, { stream: true });
|
|
718
|
-
const lines = buffer.split("\n");
|
|
719
|
-
buffer = lines.pop() || "";
|
|
720
|
-
for (const line of lines) {
|
|
721
|
-
if (isClosed) break;
|
|
722
|
-
if (!line.startsWith("data:")) continue;
|
|
723
|
-
const data = line.slice(5).trim();
|
|
724
|
-
if (data === "[DONE]") continue;
|
|
725
|
-
try {
|
|
726
|
-
const chunk = JSON.parse(data);
|
|
727
|
-
if (chunk.error) {
|
|
728
|
-
safeEnqueue(`event: error
|
|
729
|
-
data: ${JSON.stringify({
|
|
730
|
-
type: "error",
|
|
731
|
-
message: { type: "api_error", message: JSON.stringify(chunk.error) }
|
|
732
|
-
})}
|
|
733
|
-
|
|
734
|
-
`);
|
|
735
|
-
continue;
|
|
736
|
-
}
|
|
737
|
-
model = chunk.model || model;
|
|
738
|
-
if (!hasStarted) {
|
|
739
|
-
hasStarted = true;
|
|
740
|
-
safeEnqueue(`event: message_start
|
|
741
|
-
data: ${JSON.stringify({
|
|
742
|
-
type: "message_start",
|
|
743
|
-
message: {
|
|
744
|
-
id: messageId,
|
|
745
|
-
type: "message",
|
|
746
|
-
role: "assistant",
|
|
747
|
-
content: [],
|
|
748
|
-
model,
|
|
749
|
-
stop_reason: null,
|
|
750
|
-
stop_sequence: null,
|
|
751
|
-
usage: { input_tokens: 0, output_tokens: 0 }
|
|
752
|
-
}
|
|
753
|
-
})}
|
|
754
|
-
|
|
755
|
-
`);
|
|
756
|
-
}
|
|
757
|
-
const choice = _optionalChain([chunk, 'access', _28 => _28.choices, 'optionalAccess', _29 => _29[0]]);
|
|
758
|
-
if (!choice) continue;
|
|
759
|
-
if (chunk.usage) {
|
|
760
|
-
stopReasonDelta = {
|
|
761
|
-
type: "message_delta",
|
|
762
|
-
delta: { stop_reason: "end_turn", stop_sequence: null },
|
|
763
|
-
usage: {
|
|
764
|
-
input_tokens: (chunk.usage.prompt_tokens || 0) - (_optionalChain([chunk, 'access', _30 => _30.usage, 'access', _31 => _31.prompt_tokens_details, 'optionalAccess', _32 => _32.cached_tokens]) || 0),
|
|
765
|
-
output_tokens: chunk.usage.completion_tokens || 0,
|
|
766
|
-
cache_read_input_tokens: _optionalChain([chunk, 'access', _33 => _33.usage, 'access', _34 => _34.prompt_tokens_details, 'optionalAccess', _35 => _35.cached_tokens]) || 0
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
if (_optionalChain([choice, 'access', _36 => _36.delta, 'optionalAccess', _37 => _37.thinking])) {
|
|
771
|
-
if (!isThinkingStarted) {
|
|
772
|
-
const thinkingBlockIndex = assignContentBlockIndex();
|
|
773
|
-
safeEnqueue(`event: content_block_start
|
|
774
|
-
data: ${JSON.stringify({
|
|
775
|
-
type: "content_block_start",
|
|
776
|
-
index: thinkingBlockIndex,
|
|
777
|
-
content_block: { type: "thinking", thinking: "" }
|
|
778
|
-
})}
|
|
779
|
-
|
|
780
|
-
`);
|
|
781
|
-
currentContentBlockIndex = thinkingBlockIndex;
|
|
782
|
-
isThinkingStarted = true;
|
|
783
|
-
}
|
|
784
|
-
if (choice.delta.thinking.signature) {
|
|
785
|
-
safeEnqueue(`event: content_block_delta
|
|
786
|
-
data: ${JSON.stringify({
|
|
787
|
-
type: "content_block_delta",
|
|
788
|
-
index: currentContentBlockIndex,
|
|
789
|
-
delta: { type: "signature_delta", signature: choice.delta.thinking.signature }
|
|
790
|
-
})}
|
|
791
|
-
|
|
792
|
-
`);
|
|
793
|
-
safeEnqueue(`event: content_block_stop
|
|
794
|
-
data: ${JSON.stringify({
|
|
795
|
-
type: "content_block_stop",
|
|
796
|
-
index: currentContentBlockIndex
|
|
797
|
-
})}
|
|
798
|
-
|
|
799
|
-
`);
|
|
800
|
-
currentContentBlockIndex = -1;
|
|
801
|
-
} else if (choice.delta.thinking.content) {
|
|
802
|
-
safeEnqueue(`event: content_block_delta
|
|
803
|
-
data: ${JSON.stringify({
|
|
804
|
-
type: "content_block_delta",
|
|
805
|
-
index: currentContentBlockIndex,
|
|
806
|
-
delta: { type: "thinking_delta", thinking: choice.delta.thinking.content }
|
|
807
|
-
})}
|
|
808
|
-
|
|
809
|
-
`);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
if (_optionalChain([choice, 'access', _38 => _38.delta, 'optionalAccess', _39 => _39.content])) {
|
|
813
|
-
if (!hasTextContentStarted) {
|
|
814
|
-
if (currentContentBlockIndex >= 0 && isThinkingStarted) {
|
|
815
|
-
safeEnqueue(`event: content_block_stop
|
|
816
|
-
data: ${JSON.stringify({
|
|
817
|
-
type: "content_block_stop",
|
|
818
|
-
index: currentContentBlockIndex
|
|
819
|
-
})}
|
|
820
|
-
|
|
821
|
-
`);
|
|
822
|
-
}
|
|
823
|
-
hasTextContentStarted = true;
|
|
824
|
-
const textBlockIndex = assignContentBlockIndex();
|
|
825
|
-
safeEnqueue(`event: content_block_start
|
|
826
|
-
data: ${JSON.stringify({
|
|
827
|
-
type: "content_block_start",
|
|
828
|
-
index: textBlockIndex,
|
|
829
|
-
content_block: { type: "text", text: "" }
|
|
830
|
-
})}
|
|
831
|
-
|
|
832
|
-
`);
|
|
833
|
-
currentContentBlockIndex = textBlockIndex;
|
|
834
|
-
}
|
|
835
|
-
safeEnqueue(`event: content_block_delta
|
|
836
|
-
data: ${JSON.stringify({
|
|
837
|
-
type: "content_block_delta",
|
|
838
|
-
index: currentContentBlockIndex,
|
|
839
|
-
delta: { type: "text_delta", text: choice.delta.content }
|
|
840
|
-
})}
|
|
841
|
-
|
|
842
|
-
`);
|
|
843
|
-
}
|
|
844
|
-
if (_optionalChain([choice, 'access', _40 => _40.delta, 'optionalAccess', _41 => _41.tool_calls])) {
|
|
845
|
-
for (const toolCall of choice.delta.tool_calls) {
|
|
846
|
-
const toolCallIndex = _nullishCoalesce(toolCall.index, () => ( 0));
|
|
847
|
-
if (!toolCallIndexToContentBlockIndex.has(toolCallIndex)) {
|
|
848
|
-
if (currentContentBlockIndex >= 0) {
|
|
849
|
-
safeEnqueue(`event: content_block_stop
|
|
850
|
-
data: ${JSON.stringify({
|
|
851
|
-
type: "content_block_stop",
|
|
852
|
-
index: currentContentBlockIndex
|
|
853
|
-
})}
|
|
854
|
-
|
|
855
|
-
`);
|
|
856
|
-
hasTextContentStarted = false;
|
|
857
|
-
}
|
|
858
|
-
const newBlockIndex = assignContentBlockIndex();
|
|
859
|
-
toolCallIndexToContentBlockIndex.set(toolCallIndex, newBlockIndex);
|
|
860
|
-
safeEnqueue(`event: content_block_start
|
|
861
|
-
data: ${JSON.stringify({
|
|
862
|
-
type: "content_block_start",
|
|
863
|
-
index: newBlockIndex,
|
|
864
|
-
content_block: {
|
|
865
|
-
type: "tool_use",
|
|
866
|
-
id: toolCall.id || `call_${Date.now()}_${toolCallIndex}`,
|
|
867
|
-
name: _optionalChain([toolCall, 'access', _42 => _42.function, 'optionalAccess', _43 => _43.name]) || `tool_${toolCallIndex}`,
|
|
868
|
-
input: {}
|
|
869
|
-
}
|
|
870
|
-
})}
|
|
871
|
-
|
|
872
|
-
`);
|
|
873
|
-
currentContentBlockIndex = newBlockIndex;
|
|
874
|
-
}
|
|
875
|
-
if (_optionalChain([toolCall, 'access', _44 => _44.function, 'optionalAccess', _45 => _45.arguments])) {
|
|
876
|
-
const blockIndex = toolCallIndexToContentBlockIndex.get(toolCallIndex);
|
|
877
|
-
if (blockIndex !== void 0) {
|
|
878
|
-
safeEnqueue(`event: content_block_delta
|
|
879
|
-
data: ${JSON.stringify({
|
|
880
|
-
type: "content_block_delta",
|
|
881
|
-
index: blockIndex,
|
|
882
|
-
delta: { type: "input_json_delta", partial_json: toolCall.function.arguments }
|
|
883
|
-
})}
|
|
884
|
-
|
|
885
|
-
`);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
if (choice.finish_reason) {
|
|
891
|
-
const stopReasonMapping = {
|
|
892
|
-
stop: "end_turn",
|
|
893
|
-
length: "max_tokens",
|
|
894
|
-
tool_calls: "tool_use",
|
|
895
|
-
content_filter: "stop_sequence"
|
|
896
|
-
};
|
|
897
|
-
stopReasonDelta = {
|
|
898
|
-
type: "message_delta",
|
|
899
|
-
delta: {
|
|
900
|
-
stop_reason: stopReasonMapping[choice.finish_reason] || "end_turn",
|
|
901
|
-
stop_sequence: null
|
|
902
|
-
},
|
|
903
|
-
usage: {
|
|
904
|
-
input_tokens: (_optionalChain([chunk, 'access', _46 => _46.usage, 'optionalAccess', _47 => _47.prompt_tokens]) || 0) - (_optionalChain([chunk, 'access', _48 => _48.usage, 'optionalAccess', _49 => _49.prompt_tokens_details, 'optionalAccess', _50 => _50.cached_tokens]) || 0),
|
|
905
|
-
output_tokens: _optionalChain([chunk, 'access', _51 => _51.usage, 'optionalAccess', _52 => _52.completion_tokens]) || 0,
|
|
906
|
-
cache_read_input_tokens: _optionalChain([chunk, 'access', _53 => _53.usage, 'optionalAccess', _54 => _54.prompt_tokens_details, 'optionalAccess', _55 => _55.cached_tokens]) || 0
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
} catch (e) {
|
|
911
|
-
_optionalChain([logger, 'optionalAccess', _56 => _56.error, 'call', _57 => _57("Error parsing stream chunk:", e)]);
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
} catch (e) {
|
|
916
|
-
if (!isClosed) {
|
|
917
|
-
controller.error(e);
|
|
918
|
-
}
|
|
919
|
-
} finally {
|
|
920
|
-
safeClose();
|
|
921
|
-
reader.releaseLock();
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
|
|
927
695
|
// src/transformer/transformers/AnthropicTransformer.ts
|
|
928
696
|
var AnthropicTransformer = (_class = class {
|
|
929
697
|
static __initStatic() {this.TransformerName = "anthropic"}
|
|
@@ -932,7 +700,7 @@ var AnthropicTransformer = (_class = class {
|
|
|
932
700
|
__init2() {this.endPoint = "/v1/messages"}
|
|
933
701
|
|
|
934
702
|
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
935
|
-
this.useBearer = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
703
|
+
this.useBearer = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.UseBearer]), () => ( false));
|
|
936
704
|
}
|
|
937
705
|
/**
|
|
938
706
|
* Handle authentication - Anthropic uses x-api-key header
|
|
@@ -967,7 +735,7 @@ var AnthropicTransformer = (_class = class {
|
|
|
967
735
|
if (!response.body) {
|
|
968
736
|
throw new Error("Stream response body is null");
|
|
969
737
|
}
|
|
970
|
-
const convertedStream = convertOpenAIStreamToAnthropic(response.body, context, this.logger);
|
|
738
|
+
const convertedStream = _chunk6DDYNS2Bcjs.convertOpenAIStreamToAnthropic.call(void 0, response.body, context, this.logger);
|
|
971
739
|
return new Response(convertedStream, {
|
|
972
740
|
headers: {
|
|
973
741
|
"Content-Type": "text/event-stream",
|
|
@@ -84,6 +84,7 @@ var UsageThroughputTracker = class {
|
|
|
84
84
|
tokensPerMinute: 0,
|
|
85
85
|
inputTokensPerMinute: 0,
|
|
86
86
|
outputTokensPerMinute: 0,
|
|
87
|
+
cacheTokensPerMinute: 0,
|
|
87
88
|
costUsdPerMinute: 0,
|
|
88
89
|
complete: this.evictedThroughTs === null || this.evictedThroughTs < startTs
|
|
89
90
|
};
|
|
@@ -104,6 +105,7 @@ var UsageThroughputTracker = class {
|
|
|
104
105
|
row.tokensPerMinute = row.totalTokens / minutes;
|
|
105
106
|
row.inputTokensPerMinute = row.inputTokens / minutes;
|
|
106
107
|
row.outputTokensPerMinute = row.outputTokens / minutes;
|
|
108
|
+
row.cacheTokensPerMinute = (row.cacheReadTokens + row.cacheCreationTokens) / minutes;
|
|
107
109
|
row.costUsdPerMinute = row.costUsd / minutes;
|
|
108
110
|
return row;
|
|
109
111
|
}
|
|
@@ -113,7 +115,7 @@ var UsageThroughputTracker = class {
|
|
|
113
115
|
const startTs = endTs - THROUGHPUT_RETENTION_MS;
|
|
114
116
|
const out = [];
|
|
115
117
|
for (let i = 0; i < THROUGHPUT_BUCKET_COUNT; i += 1) {
|
|
116
|
-
out.push({ startTs: startTs + i * bucketMs, requests: 0, tokens: 0 });
|
|
118
|
+
out.push({ startTs: startTs + i * bucketMs, requests: 0, tokens: 0, outputTokens: 0 });
|
|
117
119
|
}
|
|
118
120
|
for (let i = this.head; i < this.samples.length; i += 1) {
|
|
119
121
|
const sample = this.samples[i];
|
|
@@ -121,6 +123,7 @@ var UsageThroughputTracker = class {
|
|
|
121
123
|
const bucket = out[Math.floor((sample.ts - startTs) / bucketMs)];
|
|
122
124
|
if (!bucket) continue;
|
|
123
125
|
bucket.requests += 1;
|
|
126
|
+
bucket.outputTokens += sample.outputTokens;
|
|
124
127
|
bucket.tokens += sample.inputTokens + sample.outputTokens + sample.cacheReadTokens + sample.cacheCreationTokens;
|
|
125
128
|
}
|
|
126
129
|
return out;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
var _chunkIUL4VWNUcjs = require('./chunk-IUL4VWNU.cjs');
|
|
5
6
|
|
|
6
7
|
// src/transformer/transformers/OpenAITransformer.ts
|
|
7
8
|
var FOREIGN_MESSAGE_KEYS = ["cache_control", "thinking"];
|
|
8
|
-
var FOREIGN_BODY_KEYS = ["meta", "reasoning", "thinking"];
|
|
9
|
+
var FOREIGN_BODY_KEYS = ["meta", "reasoning", "thinking", "top_k", "metadata_user_id", "_transformWarnings"];
|
|
9
10
|
function normalizeContent(content) {
|
|
10
11
|
if (!Array.isArray(content)) return content;
|
|
11
12
|
const cleaned = content.map((block) => {
|
|
@@ -36,6 +37,12 @@ var OpenAITransformer = (_class = class {constructor() { _class.prototype.__init
|
|
|
36
37
|
if (FOREIGN_BODY_KEYS.includes(key)) continue;
|
|
37
38
|
out[key] = source[key];
|
|
38
39
|
}
|
|
40
|
+
if (request.metadata_user_id !== void 0) {
|
|
41
|
+
out.user = request.metadata_user_id;
|
|
42
|
+
}
|
|
43
|
+
if (request.top_k !== void 0) {
|
|
44
|
+
_chunkIUL4VWNUcjs.recordDroppedField.call(void 0, request, "top_k", "openai-chat");
|
|
45
|
+
}
|
|
39
46
|
if (Array.isArray(request.messages)) {
|
|
40
47
|
out.messages = request.messages.map((message) => {
|
|
41
48
|
const src = message;
|
|
@@ -54,8 +61,8 @@ var OpenAITransformer = (_class = class {constructor() { _class.prototype.__init
|
|
|
54
61
|
return encoded;
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
|
-
const reasoningPlan = request.reasoning ?
|
|
58
|
-
intent:
|
|
64
|
+
const reasoningPlan = request.reasoning ? _chunkIUL4VWNUcjs.resolveReasoningPlan.call(void 0, {
|
|
65
|
+
intent: _chunkIUL4VWNUcjs.extractReasoningIntent.call(void 0, request),
|
|
59
66
|
model: request.model,
|
|
60
67
|
provider,
|
|
61
68
|
target: "openai-chat",
|
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
extractReasoningIntent,
|
|
6
6
|
normalizeThinkLevel,
|
|
7
|
+
recordDroppedField,
|
|
7
8
|
resolveReasoningPlan
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZLNHPUFA.js";
|
|
9
10
|
|
|
10
11
|
// src/transformer/transformers/utils/gemini.response-in.ts
|
|
11
12
|
var FINISH_REASON_TO_GEMINI = {
|
|
@@ -804,6 +805,14 @@ function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
|
804
805
|
if (request.max_tokens !== void 0) {
|
|
805
806
|
generationConfig.maxOutputTokens = request.max_tokens;
|
|
806
807
|
}
|
|
808
|
+
if (request.stop !== void 0 && request.stop.length > 0) {
|
|
809
|
+
generationConfig.stopSequences = request.stop;
|
|
810
|
+
}
|
|
811
|
+
if (request.top_p !== void 0) generationConfig.topP = request.top_p;
|
|
812
|
+
if (request.top_k !== void 0) generationConfig.topK = request.top_k;
|
|
813
|
+
if (request.metadata_user_id !== void 0) {
|
|
814
|
+
recordDroppedField(request, "metadata_user_id", "gemini");
|
|
815
|
+
}
|
|
807
816
|
const reasoningPlan = resolveReasoningPlan({
|
|
808
817
|
intent: extractReasoningIntent(request),
|
|
809
818
|
model: request.model,
|
|
@@ -264,7 +264,8 @@ async function resolveRoute(args) {
|
|
|
264
264
|
sessionId,
|
|
265
265
|
effectiveRole,
|
|
266
266
|
requestedModel,
|
|
267
|
-
apiKeyId: args.apiKeyId
|
|
267
|
+
apiKeyId: args.apiKeyId,
|
|
268
|
+
hostedImageGenerationAllowed: args.hostedImageGenerationAllowed
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
return {
|
|
@@ -301,13 +302,14 @@ async function resolveRoute(args) {
|
|
|
301
302
|
requestedModel,
|
|
302
303
|
// Usage attribution: the verified named-key id (undefined for internal traffic).
|
|
303
304
|
apiKeyId: args.apiKeyId,
|
|
305
|
+
hostedImageGenerationAllowed: args.hostedImageGenerationAllowed,
|
|
304
306
|
anthropicSdkHints
|
|
305
307
|
};
|
|
306
308
|
return { ok: true, route, usedRole: effectiveRole };
|
|
307
309
|
}
|
|
308
310
|
async function resolveSubscriptionRoute(args) {
|
|
309
311
|
const { config, providerId, modelId, ingressFormat, sessionId, effectiveRole } = args;
|
|
310
|
-
const { requestedModel, apiKeyId } = args;
|
|
312
|
+
const { requestedModel, apiKeyId, hostedImageGenerationAllowed } = args;
|
|
311
313
|
if (!config.useSubscription) {
|
|
312
314
|
return {
|
|
313
315
|
ok: false,
|
|
@@ -359,6 +361,7 @@ async function resolveSubscriptionRoute(args) {
|
|
|
359
361
|
requestedModel,
|
|
360
362
|
// Usage attribution: the verified named-key id (undefined for internal traffic).
|
|
361
363
|
apiKeyId,
|
|
364
|
+
hostedImageGenerationAllowed,
|
|
362
365
|
// Anthropic delegation carries the dispatch profile inside
|
|
363
366
|
// `anthropicSdkHints.subscriptionProfile`. The Responses ingress reads the
|
|
364
367
|
// TOP-LEVEL `route.subscriptionProfile`, and so does the built-in
|
|
@@ -264,7 +264,8 @@ async function resolveRoute(args) {
|
|
|
264
264
|
sessionId,
|
|
265
265
|
effectiveRole,
|
|
266
266
|
requestedModel,
|
|
267
|
-
apiKeyId: args.apiKeyId
|
|
267
|
+
apiKeyId: args.apiKeyId,
|
|
268
|
+
hostedImageGenerationAllowed: args.hostedImageGenerationAllowed
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
return {
|
|
@@ -301,13 +302,14 @@ async function resolveRoute(args) {
|
|
|
301
302
|
requestedModel,
|
|
302
303
|
// Usage attribution: the verified named-key id (undefined for internal traffic).
|
|
303
304
|
apiKeyId: args.apiKeyId,
|
|
305
|
+
hostedImageGenerationAllowed: args.hostedImageGenerationAllowed,
|
|
304
306
|
anthropicSdkHints
|
|
305
307
|
};
|
|
306
308
|
return { ok: true, route, usedRole: effectiveRole };
|
|
307
309
|
}
|
|
308
310
|
async function resolveSubscriptionRoute(args) {
|
|
309
311
|
const { config, providerId, modelId, ingressFormat, sessionId, effectiveRole } = args;
|
|
310
|
-
const { requestedModel, apiKeyId } = args;
|
|
312
|
+
const { requestedModel, apiKeyId, hostedImageGenerationAllowed } = args;
|
|
311
313
|
if (!config.useSubscription) {
|
|
312
314
|
return {
|
|
313
315
|
ok: false,
|
|
@@ -359,6 +361,7 @@ async function resolveSubscriptionRoute(args) {
|
|
|
359
361
|
requestedModel,
|
|
360
362
|
// Usage attribution: the verified named-key id (undefined for internal traffic).
|
|
361
363
|
apiKeyId,
|
|
364
|
+
hostedImageGenerationAllowed,
|
|
362
365
|
// Anthropic delegation carries the dispatch profile inside
|
|
363
366
|
// `anthropicSdkHints.subscriptionProfile`. The Responses ingress reads the
|
|
364
367
|
// TOP-LEVEL `route.subscriptionProfile`, and so does the built-in
|