@omnicross/core 0.1.7 → 0.1.9
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/{ProviderProxy-C-xqrkKi.d.ts → ProviderProxy--ROec6VI.d.ts} +22 -3
- package/dist/{ProviderProxy-CnMQYN59.d.cts → ProviderProxy-QdwNV6l1.d.cts} +22 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +5 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -2
- package/dist/{chunk-N5T4M4GU.js → chunk-2UTGX6FM.js} +2 -2
- package/dist/{chunk-32O35CIF.js → chunk-45FHEOKW.js} +22 -7
- package/dist/{chunk-LVUCAWMK.js → chunk-55FMGZ3L.js} +13 -5
- package/dist/{chunk-OF3BECU2.cjs → chunk-56QD3YW6.cjs} +18 -5
- package/dist/{chunk-V4TXMEJS.cjs → chunk-5LNYGCIW.cjs} +15 -7
- package/dist/chunk-77USGNRW.cjs +37 -0
- package/dist/chunk-AOFWNWLT.cjs +203 -0
- package/dist/{chunk-LB6EBS6Y.js → chunk-CCVRRJOX.js} +17 -4
- package/dist/{chunk-OVQBNVSV.cjs → chunk-CMVXX7ON.cjs} +42 -27
- package/dist/{chunk-E3COOKUP.js → chunk-CQIJCPMF.js} +1108 -271
- package/dist/{chunk-OJGQKHN5.cjs → chunk-EPN67EGP.cjs} +3 -0
- package/dist/{chunk-PEGTIPB3.js → chunk-HKB656B4.js} +37 -43
- package/dist/chunk-N2EIM2XJ.js +203 -0
- package/dist/{chunk-MYYR3HZL.js → chunk-NGYOO5TO.js} +5 -5
- package/dist/{chunk-OKMJLEXX.cjs → chunk-OC6DOOFX.cjs} +5 -5
- package/dist/{chunk-2Z4XM3H5.cjs → chunk-P7EM6BND.cjs} +10 -10
- package/dist/{chunk-KBM2W6UY.cjs → chunk-RICPANBY.cjs} +41 -24
- package/dist/{chunk-TOVPMMHM.js → chunk-S3DYFEBE.js} +37 -20
- package/dist/{chunk-SOO562NM.js → chunk-UAPBLNN2.js} +3 -0
- package/dist/chunk-WYVGULTQ.js +37 -0
- package/dist/{chunk-4BB343BI.cjs → chunk-XELFM7KL.cjs} +1381 -544
- package/dist/{chunk-OXHNSZ53.cjs → chunk-ZQQUD66M.cjs} +54 -60
- package/dist/completion/ApiKeyPoolService.cjs +32 -1
- package/dist/completion/ApiKeyPoolService.d.cts +17 -1
- package/dist/completion/ApiKeyPoolService.d.ts +17 -1
- package/dist/completion/ApiKeyPoolService.js +31 -0
- package/dist/completion/CompletionService.cjs +13 -11
- package/dist/completion/CompletionService.js +12 -10
- package/dist/completion.cjs +13 -11
- package/dist/completion.js +12 -10
- package/dist/index.cjs +69 -11
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +68 -10
- package/dist/outbound-api/routeResolver.d.cts +4 -4
- package/dist/outbound-api/routeResolver.d.ts +4 -4
- package/dist/outbound-api/types.d.cts +3 -3
- package/dist/outbound-api/types.d.ts +3 -3
- package/dist/outbound-api.cjs +13 -11
- package/dist/outbound-api.d.cts +5 -5
- package/dist/outbound-api.d.ts +5 -5
- package/dist/outbound-api.js +12 -10
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +3 -3
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +3 -3
- package/dist/pipeline/executeProviderCall.d.cts +2 -0
- package/dist/pipeline/executeProviderCall.d.ts +2 -0
- package/dist/pipeline/resolveProviderChain.d.cts +1 -0
- package/dist/pipeline/resolveProviderChain.d.ts +1 -0
- package/dist/pipeline/resolveSubscriptionChain.d.cts +2 -0
- package/dist/pipeline/resolveSubscriptionChain.d.ts +2 -0
- package/dist/ports/provider-config-source.d.cts +1 -0
- package/dist/ports/provider-config-source.d.ts +1 -0
- package/dist/ports.d.cts +3 -3
- package/dist/ports.d.ts +3 -3
- package/dist/provider-proxy/ProviderProxy.cjs +13 -11
- package/dist/provider-proxy/ProviderProxy.d.cts +1 -1
- package/dist/provider-proxy/ProviderProxy.d.ts +1 -1
- package/dist/provider-proxy/ProviderProxy.js +12 -10
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +13 -11
- package/dist/provider-proxy/ingress/providerProxyShared.js +12 -10
- package/dist/provider-proxy/types.d.cts +15 -1
- package/dist/provider-proxy/types.d.ts +15 -1
- package/dist/provider-proxy.cjs +69 -11
- package/dist/provider-proxy.d.cts +254 -8
- package/dist/provider-proxy.d.ts +254 -8
- package/dist/provider-proxy.js +70 -12
- package/dist/{routeResolver-BxOfunbm.d.ts → routeResolver-C0mkkZaM.d.ts} +1 -1
- package/dist/{routeResolver-D5OzD0iM.d.cts → routeResolver-CVFE8KKe.d.cts} +1 -1
- package/dist/transformer/TransformerChainExecutor.d.cts +2 -0
- package/dist/transformer/TransformerChainExecutor.d.ts +2 -0
- package/dist/transformer/TransformerService.d.cts +2 -0
- package/dist/transformer/TransformerService.d.ts +2 -0
- package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -2
- package/dist/transformer/transformers/AnthropicTransformer.d.cts +7 -2
- package/dist/transformer/transformers/AnthropicTransformer.d.ts +7 -2
- package/dist/transformer/transformers/AnthropicTransformer.js +3 -1
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +5 -3
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.cts +2 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.ts +2 -0
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +4 -2
- package/dist/transformer/transformers/GeminiTransformer.cjs +5 -3
- package/dist/transformer/transformers/GeminiTransformer.d.cts +4 -2
- package/dist/transformer/transformers/GeminiTransformer.d.ts +4 -2
- package/dist/transformer/transformers/GeminiTransformer.js +4 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +4 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +4 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -1
- package/dist/transformer/transformers/OpenAITransformer.cjs +3 -2
- package/dist/transformer/transformers/OpenAITransformer.d.cts +3 -1
- package/dist/transformer/transformers/OpenAITransformer.d.ts +3 -1
- package/dist/transformer/transformers/OpenAITransformer.js +2 -1
- package/dist/transformer/transformers.cjs +10 -8
- package/dist/transformer/transformers.d.cts +2 -0
- package/dist/transformer/transformers.d.ts +2 -0
- package/dist/transformer/transformers.js +9 -7
- package/dist/transformer/types.d.cts +16 -5
- package/dist/transformer/types.d.ts +16 -5
- package/dist/transformer.cjs +28 -9
- package/dist/transformer.d.cts +76 -1
- package/dist/transformer.d.ts +76 -1
- package/dist/transformer.js +28 -9
- package/dist/{types-CqZD77rS.d.ts → types-BB8pxk_3.d.ts} +1 -1
- package/dist/{types-gjJ5lJ5n.d.cts → types-C2MwkLah.d.cts} +1 -1
- package/dist/usage/usage-recorder.cjs +2 -2
- package/dist/usage/usage-recorder.d.cts +6 -0
- package/dist/usage/usage-recorder.d.ts +6 -0
- package/dist/usage/usage-recorder.js +1 -1
- package/dist/usage.cjs +2 -2
- package/dist/usage.js +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-FZ46M34D.cjs → chunk-QVOB2DNX.cjs} +0 -0
- /package/dist/{chunk-46RLHI7D.js → chunk-WTQMX2Q6.js} +0 -0
|
@@ -78,6 +78,9 @@ var UsageRecorder = class {
|
|
|
78
78
|
costSavedByCacheUsd,
|
|
79
79
|
rawUsage: input.rawUsage != null ? safeStringify(input.rawUsage) : null,
|
|
80
80
|
runId: _nullishCoalesce(input.runId, () => ( null)),
|
|
81
|
+
routeLeaseId: _nullishCoalesce(input.routeLeaseId, () => ( null)),
|
|
82
|
+
routeLeaseConsumer: _nullishCoalesce(input.routeLeaseConsumer, () => ( null)),
|
|
83
|
+
routeLeaseStageId: _nullishCoalesce(input.routeLeaseStageId, () => ( null)),
|
|
81
84
|
eventId: _nullishCoalesce(input.eventId, () => ( null)),
|
|
82
85
|
...input.cacheKeySource !== void 0 ? { cacheKeySource: input.cacheKeySource } : {},
|
|
83
86
|
...input.cacheKeyInjected !== void 0 ? { cacheKeyInjected: input.cacheKeyInjected } : {}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
anthropicUsageToChatUsage
|
|
3
3
|
} from "./chunk-FU7EAR73.js";
|
|
4
|
+
import {
|
|
5
|
+
flattenToolResultContent,
|
|
6
|
+
formatBase64,
|
|
7
|
+
getThinkLevel
|
|
8
|
+
} from "./chunk-WYVGULTQ.js";
|
|
9
|
+
import {
|
|
10
|
+
extractReasoningIntent,
|
|
11
|
+
normalizeThinkLevel,
|
|
12
|
+
resolveReasoningPlan
|
|
13
|
+
} from "./chunk-N2EIM2XJ.js";
|
|
4
14
|
|
|
5
15
|
// src/transformer/transformers/AnthropicToolHandling.ts
|
|
6
16
|
function isServerSideTool(tool) {
|
|
@@ -18,38 +28,6 @@ function convertAnthropicToolsToOpenAI(tools) {
|
|
|
18
28
|
}));
|
|
19
29
|
}
|
|
20
30
|
|
|
21
|
-
// src/transformer/transformers/AnthropicTypes.ts
|
|
22
|
-
function getThinkLevel(budgetTokens) {
|
|
23
|
-
if (!budgetTokens || budgetTokens <= 0) return "none";
|
|
24
|
-
if (budgetTokens < 4096) return "low";
|
|
25
|
-
if (budgetTokens < 16384) return "medium";
|
|
26
|
-
return "high";
|
|
27
|
-
}
|
|
28
|
-
function formatBase64(data, mediaType) {
|
|
29
|
-
if (data.startsWith("data:")) return data;
|
|
30
|
-
return `data:${mediaType || "image/png"};base64,${data}`;
|
|
31
|
-
}
|
|
32
|
-
function flattenToolResultContent(content) {
|
|
33
|
-
if (typeof content === "string") return content;
|
|
34
|
-
if (content == null) return "";
|
|
35
|
-
if (!Array.isArray(content)) return JSON.stringify(content);
|
|
36
|
-
const parts = [];
|
|
37
|
-
for (const block of content) {
|
|
38
|
-
if (typeof block === "string") {
|
|
39
|
-
parts.push(block);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (!block || typeof block !== "object") continue;
|
|
43
|
-
const typed = block;
|
|
44
|
-
if (typed.type === "image" || typed.type === "image_url") {
|
|
45
|
-
parts.push("[image omitted]");
|
|
46
|
-
} else if (typeof typed.text === "string") {
|
|
47
|
-
parts.push(typed.text);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return parts.filter((text) => text !== "").join("\n");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
31
|
// src/anthropicMaxTokens.ts
|
|
54
32
|
import { lookupCanonicalCapabilities } from "@omnicross/contracts/canonical-models";
|
|
55
33
|
var ANTHROPIC_FALLBACK_MAX_TOKENS = 128e3;
|
|
@@ -65,7 +43,7 @@ function resolveAnthropicMaxTokens(model, requested) {
|
|
|
65
43
|
}
|
|
66
44
|
|
|
67
45
|
// src/transformer/transformers/AnthropicRequestBuilder.ts
|
|
68
|
-
function buildAnthropicRequestBody(request) {
|
|
46
|
+
function buildAnthropicRequestBody(request, provider) {
|
|
69
47
|
let systemContent;
|
|
70
48
|
const anthropicMessages = [];
|
|
71
49
|
for (let i = 0; i < request.messages.length; i++) {
|
|
@@ -202,10 +180,18 @@ function buildAnthropicRequestBody(request) {
|
|
|
202
180
|
body.tool_choice = { type: "tool", name: request.tool_choice.function.name };
|
|
203
181
|
}
|
|
204
182
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
183
|
+
const reasoningPlan = resolveReasoningPlan({
|
|
184
|
+
intent: extractReasoningIntent(request),
|
|
185
|
+
model: request.model,
|
|
186
|
+
provider,
|
|
187
|
+
target: "anthropic",
|
|
188
|
+
requestMaxTokens: request.max_tokens
|
|
189
|
+
});
|
|
190
|
+
if (reasoningPlan?.kind === "level" && reasoningPlan.enabled) {
|
|
191
|
+
body.thinking = { type: "adaptive" };
|
|
192
|
+
body.output_config = { effort: reasoningPlan.effort };
|
|
193
|
+
} else if (reasoningPlan?.kind === "budget" && reasoningPlan.enabled) {
|
|
194
|
+
body.thinking = { type: "enabled", budget_tokens: reasoningPlan.budgetTokens };
|
|
209
195
|
body.temperature = 1;
|
|
210
196
|
}
|
|
211
197
|
return body;
|
|
@@ -461,10 +447,18 @@ function transformAnthropicRequestToUnified(request) {
|
|
|
461
447
|
result._serverSideTools = serverSideTools;
|
|
462
448
|
}
|
|
463
449
|
if (anthropicRequest.thinking) {
|
|
464
|
-
|
|
465
|
-
effort:
|
|
466
|
-
|
|
467
|
-
|
|
450
|
+
if (anthropicRequest.thinking.type === "disabled") {
|
|
451
|
+
result.reasoning = { effort: "none", enabled: false };
|
|
452
|
+
} else if (anthropicRequest.thinking.type === "adaptive") {
|
|
453
|
+
const effort = normalizeThinkLevel(anthropicRequest.output_config?.effort);
|
|
454
|
+
if (effort) result.reasoning = { effort, enabled: effort !== "none" };
|
|
455
|
+
} else {
|
|
456
|
+
result.reasoning = {
|
|
457
|
+
effort: getThinkLevel(anthropicRequest.thinking.budget_tokens),
|
|
458
|
+
enabled: true,
|
|
459
|
+
...typeof anthropicRequest.thinking.budget_tokens === "number" ? { max_tokens: anthropicRequest.thinking.budget_tokens } : {}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
468
462
|
}
|
|
469
463
|
if (anthropicRequest.tool_choice) {
|
|
470
464
|
if (anthropicRequest.tool_choice.type === "tool" && anthropicRequest.tool_choice.name) {
|
|
@@ -994,8 +988,8 @@ var AnthropicTransformer = class {
|
|
|
994
988
|
* This is the reverse of transformRequestOut — converts OpenAI/unified format
|
|
995
989
|
* to Anthropic's expected request body structure.
|
|
996
990
|
*/
|
|
997
|
-
async transformRequestIn(request,
|
|
998
|
-
return buildAnthropicRequestBody(request);
|
|
991
|
+
async transformRequestIn(request, provider, _context) {
|
|
992
|
+
return buildAnthropicRequestBody(request, provider);
|
|
999
993
|
}
|
|
1000
994
|
/**
|
|
1001
995
|
* Transform Anthropic response to OpenAI/unified format
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// src/reasoning/reasoning-plan.ts
|
|
2
|
+
import {
|
|
3
|
+
applyAlias,
|
|
4
|
+
normalizeModelId,
|
|
5
|
+
resolveModelCapabilities
|
|
6
|
+
} from "@omnicross/contracts/canonical-models";
|
|
7
|
+
import {
|
|
8
|
+
EFFORT_RATIO,
|
|
9
|
+
findLegacyTokenLimit
|
|
10
|
+
} from "@omnicross/contracts/thinking-config";
|
|
11
|
+
var THINK_LEVELS = [
|
|
12
|
+
"none",
|
|
13
|
+
"minimal",
|
|
14
|
+
"low",
|
|
15
|
+
"medium",
|
|
16
|
+
"high",
|
|
17
|
+
"xhigh",
|
|
18
|
+
"max"
|
|
19
|
+
];
|
|
20
|
+
var THINK_LEVEL_SET = new Set(THINK_LEVELS);
|
|
21
|
+
var ANTHROPIC_FALLBACK_BUDGET = {
|
|
22
|
+
minimal: 1024,
|
|
23
|
+
low: 2048,
|
|
24
|
+
medium: 8192,
|
|
25
|
+
high: 32768,
|
|
26
|
+
xhigh: 32768,
|
|
27
|
+
max: 32768
|
|
28
|
+
};
|
|
29
|
+
function normalizeThinkLevel(value) {
|
|
30
|
+
if (typeof value !== "string") return void 0;
|
|
31
|
+
const normalized = value.toLowerCase();
|
|
32
|
+
return THINK_LEVEL_SET.has(normalized) ? normalized : void 0;
|
|
33
|
+
}
|
|
34
|
+
function extractReasoningIntent(request) {
|
|
35
|
+
const reasoning = request.reasoning;
|
|
36
|
+
if (reasoning) {
|
|
37
|
+
if (reasoning.enabled === false) {
|
|
38
|
+
return { ...reasoning, effort: "none", enabled: false };
|
|
39
|
+
}
|
|
40
|
+
const effort = normalizeThinkLevel(reasoning.effort);
|
|
41
|
+
if (effort) {
|
|
42
|
+
return { ...reasoning, effort, enabled: effort !== "none" };
|
|
43
|
+
}
|
|
44
|
+
if (reasoning.enabled === true || isPositiveFinite(reasoning.max_tokens)) {
|
|
45
|
+
return { ...reasoning, effort: "medium", enabled: true };
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
const nativeEffort = normalizeThinkLevel(request.reasoning_effort);
|
|
50
|
+
if (!nativeEffort) return void 0;
|
|
51
|
+
return { effort: nativeEffort, enabled: nativeEffort !== "none" };
|
|
52
|
+
}
|
|
53
|
+
function canonicalModelId(model) {
|
|
54
|
+
return applyAlias(normalizeModelId(model));
|
|
55
|
+
}
|
|
56
|
+
function findModelOverride(targetModel, modelConfigs) {
|
|
57
|
+
if (!modelConfigs) return void 0;
|
|
58
|
+
const targetId = canonicalModelId(targetModel);
|
|
59
|
+
return modelConfigs.find(
|
|
60
|
+
(config) => config.id === targetModel || canonicalModelId(config.id) === targetId
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function resolveTargetModelCapabilities(targetModel, provider) {
|
|
64
|
+
const rowOverride = findModelOverride(targetModel, provider?.modelConfigs);
|
|
65
|
+
return resolveModelCapabilities(targetModel, void 0, rowOverride);
|
|
66
|
+
}
|
|
67
|
+
function resolveReasoningEffort(requested, targetModel, provider) {
|
|
68
|
+
if (requested === "none") return "none";
|
|
69
|
+
const capabilities = resolveTargetModelCapabilities(targetModel, provider);
|
|
70
|
+
const candidates = capabilities.thinkingLevels?.map(normalizeThinkLevel).filter((level) => level !== void 0 && level !== "none") ?? [];
|
|
71
|
+
if (candidates.includes(requested)) return requested;
|
|
72
|
+
if (capabilities.thinkingLevels?.length && candidates.length === 0) return "none";
|
|
73
|
+
if (candidates.length === 0) return requested;
|
|
74
|
+
const requestedRatio = EFFORT_RATIO[requested];
|
|
75
|
+
return candidates.reduce((best, candidate) => {
|
|
76
|
+
const distance = Math.abs(EFFORT_RATIO[candidate] - requestedRatio);
|
|
77
|
+
const bestDistance = Math.abs(EFFORT_RATIO[best] - requestedRatio);
|
|
78
|
+
if (distance < bestDistance - Number.EPSILON) return candidate;
|
|
79
|
+
if (Math.abs(distance - bestDistance) <= Number.EPSILON && EFFORT_RATIO[candidate] < EFFORT_RATIO[best]) {
|
|
80
|
+
return candidate;
|
|
81
|
+
}
|
|
82
|
+
return best;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function protocolFallback(model, target) {
|
|
86
|
+
if (target === "anthropic") return { min: 1024, max: 128e3 };
|
|
87
|
+
if (target === "gemini") {
|
|
88
|
+
return model.toLowerCase().includes("pro") ? { min: 128, max: 32768 } : { min: 0, max: 24576 };
|
|
89
|
+
}
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
function resolveTokenLimit(model, provider, target) {
|
|
93
|
+
const capabilities = resolveTargetModelCapabilities(model, provider);
|
|
94
|
+
if (capabilities.thinkingTokenLimit) {
|
|
95
|
+
return { limits: capabilities.thinkingTokenLimit, source: "capability" };
|
|
96
|
+
}
|
|
97
|
+
const legacy = findLegacyTokenLimit(model);
|
|
98
|
+
if (legacy) return { limits: legacy, source: "legacy" };
|
|
99
|
+
const fallback = protocolFallback(model, target);
|
|
100
|
+
return fallback ? { limits: fallback, source: "protocol" } : void 0;
|
|
101
|
+
}
|
|
102
|
+
function resolveReasoningTokenLimit(model, provider, target) {
|
|
103
|
+
return resolveTokenLimit(model, provider, target)?.limits;
|
|
104
|
+
}
|
|
105
|
+
function isPositiveFinite(value) {
|
|
106
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
107
|
+
}
|
|
108
|
+
function isFiniteNumber(value) {
|
|
109
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
110
|
+
}
|
|
111
|
+
function clampBudget(rawBudget, limits, target, effort, requestMaxTokens, explicitBudget = false) {
|
|
112
|
+
const protocolMin = target === "anthropic" ? 1024 : 0;
|
|
113
|
+
const min = Math.max(protocolMin, Math.floor(limits.min));
|
|
114
|
+
let max = Math.max(min, Math.floor(limits.max));
|
|
115
|
+
if (isPositiveFinite(requestMaxTokens)) {
|
|
116
|
+
const requestCeiling = target === "anthropic" ? explicitBudget ? Math.floor(requestMaxTokens) - 1 : Math.max(
|
|
117
|
+
min,
|
|
118
|
+
Math.floor(requestMaxTokens * Math.min(EFFORT_RATIO[effort], 0.75))
|
|
119
|
+
) : Math.floor(requestMaxTokens);
|
|
120
|
+
if (requestCeiling < min) return void 0;
|
|
121
|
+
max = Math.min(max, requestCeiling);
|
|
122
|
+
}
|
|
123
|
+
return Math.max(min, Math.min(max, Math.floor(rawBudget)));
|
|
124
|
+
}
|
|
125
|
+
function resolveBudget(intent, effort, model, provider, target, requestMaxTokens) {
|
|
126
|
+
const resolved = resolveTokenLimit(model, provider, target);
|
|
127
|
+
if (!resolved) return void 0;
|
|
128
|
+
const { limits, source } = resolved;
|
|
129
|
+
const explicitBudget = isFiniteNumber(intent.max_tokens) ? Math.floor(intent.max_tokens) : void 0;
|
|
130
|
+
const interpolated = source === "protocol" && target === "anthropic" ? ANTHROPIC_FALLBACK_BUDGET[effort] : Math.floor((limits.max - limits.min) * EFFORT_RATIO[effort] + limits.min);
|
|
131
|
+
return clampBudget(
|
|
132
|
+
explicitBudget ?? interpolated,
|
|
133
|
+
limits,
|
|
134
|
+
target,
|
|
135
|
+
effort,
|
|
136
|
+
requestMaxTokens,
|
|
137
|
+
explicitBudget !== void 0
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function resolveReasoningPlan(input) {
|
|
141
|
+
const normalizedIntent = input.intent ? extractReasoningIntent({ model: input.model, reasoning: input.intent }) : void 0;
|
|
142
|
+
if (!normalizedIntent?.effort) return void 0;
|
|
143
|
+
const capabilities = resolveTargetModelCapabilities(input.model, input.provider);
|
|
144
|
+
const nativeEffort = normalizedIntent.effort;
|
|
145
|
+
if (nativeEffort === "none") {
|
|
146
|
+
if (input.target === "gemini" && capabilities.thinkingLevels?.length && capabilities.thinkingLevels.includes("none")) {
|
|
147
|
+
return { kind: "level", effort: "none", enabled: false };
|
|
148
|
+
}
|
|
149
|
+
if (input.target === "gemini" && !capabilities.thinkingLevels?.length) {
|
|
150
|
+
const limits = resolveTokenLimit(input.model, input.provider, input.target)?.limits;
|
|
151
|
+
if (limits?.min === 0) {
|
|
152
|
+
return { kind: "budget", effort: "none", enabled: false, budgetTokens: 0 };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { kind: "off" };
|
|
156
|
+
}
|
|
157
|
+
if (capabilities.thinkingLevels?.length && !capabilities.thinkingLevels.some((level) => level !== "none")) {
|
|
158
|
+
return { kind: "off" };
|
|
159
|
+
}
|
|
160
|
+
const effort = input.preserveNativeEffort ? nativeEffort : resolveReasoningEffort(nativeEffort, input.model, input.provider);
|
|
161
|
+
if (effort === "none") return { kind: "off" };
|
|
162
|
+
if (input.target === "openai-chat" || input.target === "openai-responses") {
|
|
163
|
+
return { kind: "level", effort, enabled: true };
|
|
164
|
+
}
|
|
165
|
+
if (capabilities.thinkingLevels?.length) {
|
|
166
|
+
return { kind: "level", effort, enabled: true };
|
|
167
|
+
}
|
|
168
|
+
const budgetTokens = resolveBudget(
|
|
169
|
+
normalizedIntent,
|
|
170
|
+
effort,
|
|
171
|
+
input.model,
|
|
172
|
+
input.provider,
|
|
173
|
+
input.target,
|
|
174
|
+
input.requestMaxTokens
|
|
175
|
+
);
|
|
176
|
+
if (budgetTokens === void 0) return { kind: "off" };
|
|
177
|
+
return { kind: "budget", effort, enabled: true, budgetTokens };
|
|
178
|
+
}
|
|
179
|
+
function resolveRequestReasoning(request, provider, options = {}) {
|
|
180
|
+
const intent = extractReasoningIntent(request);
|
|
181
|
+
if (!intent?.effort) return void 0;
|
|
182
|
+
const plan = resolveReasoningPlan({
|
|
183
|
+
intent,
|
|
184
|
+
model: request.model,
|
|
185
|
+
provider,
|
|
186
|
+
target: "openai-chat",
|
|
187
|
+
preserveNativeEffort: options.preserveNativeEffort
|
|
188
|
+
});
|
|
189
|
+
if (!plan) return void 0;
|
|
190
|
+
if (plan.kind === "off") return { ...intent, effort: "none", enabled: false };
|
|
191
|
+
return { ...intent, effort: plan.effort, enabled: plan.enabled };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export {
|
|
195
|
+
THINK_LEVELS,
|
|
196
|
+
normalizeThinkLevel,
|
|
197
|
+
extractReasoningIntent,
|
|
198
|
+
resolveTargetModelCapabilities,
|
|
199
|
+
resolveReasoningEffort,
|
|
200
|
+
resolveReasoningTokenLimit,
|
|
201
|
+
resolveReasoningPlan,
|
|
202
|
+
resolveRequestReasoning
|
|
203
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AnthropicTransformer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HKB656B4.js";
|
|
4
4
|
import {
|
|
5
5
|
GeminiTransformer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-55FMGZ3L.js";
|
|
7
7
|
import {
|
|
8
8
|
OpenAIResponseTransformer
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-45FHEOKW.js";
|
|
10
10
|
import {
|
|
11
11
|
OpenAITransformer
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CCVRRJOX.js";
|
|
13
13
|
import {
|
|
14
14
|
GeminiCodeAssistTransformer
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2UTGX6FM.js";
|
|
16
16
|
|
|
17
17
|
// src/transformer/transformers/index.ts
|
|
18
18
|
var BuiltinTransformers = {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkRICPANBYcjs = require('./chunk-RICPANBY.cjs');
|
|
7
7
|
|
|
8
8
|
// src/transformer/transformers/GeminiCodeAssistTransformer.ts
|
|
9
9
|
var DEFAULT_CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|
@@ -117,7 +117,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
117
117
|
* openaiResponsesIngress). `undefined` is the valid fresh free-tier value.
|
|
118
118
|
*/
|
|
119
119
|
async transformRequestIn(request, provider, _context) {
|
|
120
|
-
const inner =
|
|
120
|
+
const inner = _chunkRICPANBYcjs.buildRequestBody.call(void 0, request, provider);
|
|
121
121
|
const envelope = {
|
|
122
122
|
model: request.model,
|
|
123
123
|
project: provider.geminiProject,
|
|
@@ -147,7 +147,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
147
147
|
if (inner && typeof inner === "object" && !("model" in inner) && "model" in r) {
|
|
148
148
|
inner.model = r.model;
|
|
149
149
|
}
|
|
150
|
-
return
|
|
150
|
+
return _chunkRICPANBYcjs.transformRequestOut.call(void 0, inner);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* Code Assist response → OpenAI-compatible. PEEL the `.response` envelope from
|
|
@@ -155,7 +155,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
155
155
|
*/
|
|
156
156
|
async transformResponseOut(response, _context) {
|
|
157
157
|
const unwrapped = await unwrapCodeAssistResponse(response);
|
|
158
|
-
return
|
|
158
|
+
return _chunkRICPANBYcjs.transformResponseOut.call(void 0, unwrapped, this.name, this.logger);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* OpenAI-compatible response → Code Assist (endpoint-encode parity). Re-wraps
|
|
@@ -164,7 +164,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
164
164
|
* `transformResponseOut`'s peel.
|
|
165
165
|
*/
|
|
166
166
|
async transformResponseIn(response, _context) {
|
|
167
|
-
const geminiResponse = await
|
|
167
|
+
const geminiResponse = await _chunkRICPANBYcjs.transformResponseIn.call(void 0, response, this.logger);
|
|
168
168
|
const contentType = _nullishCoalesce(geminiResponse.headers.get("Content-Type"), () => ( ""));
|
|
169
169
|
if (contentType.includes("text/event-stream")) {
|
|
170
170
|
return geminiResponse;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZQQUD66Mcjs = require('./chunk-ZQQUD66M.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk5LNYGCIWcjs = require('./chunk-5LNYGCIW.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkCMVXX7ONcjs = require('./chunk-CMVXX7ON.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk56QD3YW6cjs = require('./chunk-56QD3YW6.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkOC6DOOFXcjs = require('./chunk-OC6DOOFX.cjs');
|
|
16
16
|
|
|
17
17
|
// src/transformer/transformers/index.ts
|
|
18
18
|
var BuiltinTransformers = {
|
|
19
|
-
OpenAITransformer:
|
|
20
|
-
GeminiTransformer:
|
|
21
|
-
GeminiCodeAssistTransformer:
|
|
22
|
-
AnthropicTransformer:
|
|
23
|
-
OpenAIResponseTransformer:
|
|
19
|
+
OpenAITransformer: _chunk56QD3YW6cjs.OpenAITransformer,
|
|
20
|
+
GeminiTransformer: _chunk5LNYGCIWcjs.GeminiTransformer,
|
|
21
|
+
GeminiCodeAssistTransformer: _chunkOC6DOOFXcjs.GeminiCodeAssistTransformer,
|
|
22
|
+
AnthropicTransformer: _chunkZQQUD66Mcjs.AnthropicTransformer,
|
|
23
|
+
OpenAIResponseTransformer: _chunkCMVXX7ONcjs.OpenAIResponseTransformer
|
|
24
24
|
};
|
|
25
25
|
function getBuiltinTransformers() {
|
|
26
26
|
return BuiltinTransformers;
|
|
@@ -1,4 +1,13 @@
|
|
|
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; }
|
|
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 _chunk77USGNRWcjs = require('./chunk-77USGNRW.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkAOFWNWLTcjs = require('./chunk-AOFWNWLT.cjs');
|
|
9
|
+
|
|
10
|
+
// src/transformer/transformers/utils/gemini.response-in.ts
|
|
2
11
|
var FINISH_REASON_TO_GEMINI = {
|
|
3
12
|
stop: "STOP",
|
|
4
13
|
length: "MAX_TOKENS",
|
|
@@ -685,7 +694,7 @@ function transformTool(tool) {
|
|
|
685
694
|
}
|
|
686
695
|
|
|
687
696
|
// src/transformer/transformers/utils/gemini.util.ts
|
|
688
|
-
function buildRequestBody(request) {
|
|
697
|
+
function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
689
698
|
const tools = [];
|
|
690
699
|
const functionDeclarations = _optionalChain([request, 'access', _99 => _99.tools, 'optionalAccess', _100 => _100.filter, 'call', _101 => _101((tool) => tool.function.name !== "web_search"), 'optionalAccess', _102 => _102.map, 'call', _103 => _103((tool) => ({
|
|
691
700
|
name: tool.function.name,
|
|
@@ -795,27 +804,24 @@ function buildRequestBody(request) {
|
|
|
795
804
|
if (request.max_tokens !== void 0) {
|
|
796
805
|
generationConfig.maxOutputTokens = request.max_tokens;
|
|
797
806
|
}
|
|
798
|
-
|
|
807
|
+
const reasoningPlan = _chunkAOFWNWLTcjs.resolveReasoningPlan.call(void 0, {
|
|
808
|
+
intent: _chunkAOFWNWLTcjs.extractReasoningIntent.call(void 0, request),
|
|
809
|
+
model: request.model,
|
|
810
|
+
provider,
|
|
811
|
+
target: "gemini",
|
|
812
|
+
requestMaxTokens: request.max_tokens,
|
|
813
|
+
preserveNativeEffort
|
|
814
|
+
});
|
|
815
|
+
if (_optionalChain([reasoningPlan, 'optionalAccess', _117 => _117.kind]) === "level") {
|
|
799
816
|
generationConfig.thinkingConfig = {
|
|
800
|
-
includeThoughts:
|
|
817
|
+
includeThoughts: reasoningPlan.enabled,
|
|
818
|
+
thinkingLevel: reasoningPlan.effort
|
|
819
|
+
};
|
|
820
|
+
} else if (_optionalChain([reasoningPlan, 'optionalAccess', _118 => _118.kind]) === "budget") {
|
|
821
|
+
generationConfig.thinkingConfig = {
|
|
822
|
+
includeThoughts: reasoningPlan.enabled,
|
|
823
|
+
thinkingBudget: reasoningPlan.budgetTokens
|
|
801
824
|
};
|
|
802
|
-
if (request.model.includes("gemini-3")) {
|
|
803
|
-
generationConfig.thinkingConfig.thinkingLevel = request.reasoning.effort;
|
|
804
|
-
} else {
|
|
805
|
-
const thinkingBudgets = request.model.includes("pro") ? [128, 32768] : [0, 24576];
|
|
806
|
-
const maxTokens = request.reasoning.max_tokens;
|
|
807
|
-
if (typeof maxTokens !== "undefined") {
|
|
808
|
-
let thinkingBudget;
|
|
809
|
-
if (maxTokens >= thinkingBudgets[0] && maxTokens <= thinkingBudgets[1]) {
|
|
810
|
-
thinkingBudget = maxTokens;
|
|
811
|
-
} else if (maxTokens < thinkingBudgets[0]) {
|
|
812
|
-
thinkingBudget = thinkingBudgets[0];
|
|
813
|
-
} else {
|
|
814
|
-
thinkingBudget = thinkingBudgets[1];
|
|
815
|
-
}
|
|
816
|
-
generationConfig.thinkingConfig.thinkingBudget = thinkingBudget;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
825
|
}
|
|
820
826
|
const body = {
|
|
821
827
|
contents,
|
|
@@ -859,6 +865,17 @@ function transformRequestOut(request) {
|
|
|
859
865
|
stream,
|
|
860
866
|
tool_choice: toolChoice
|
|
861
867
|
};
|
|
868
|
+
const thinkingConfig = _optionalChain([generationConfig, 'optionalAccess', _123 => _123.thinkingConfig]);
|
|
869
|
+
const discreteEffort = _chunkAOFWNWLTcjs.normalizeThinkLevel.call(void 0, _optionalChain([thinkingConfig, 'optionalAccess', _124 => _124.thinkingLevel]));
|
|
870
|
+
if (discreteEffort) {
|
|
871
|
+
unifiedRequest.reasoning = {
|
|
872
|
+
effort: discreteEffort,
|
|
873
|
+
enabled: discreteEffort !== "none"
|
|
874
|
+
};
|
|
875
|
+
} else if (typeof _optionalChain([thinkingConfig, 'optionalAccess', _125 => _125.thinkingBudget]) === "number" && Number.isFinite(thinkingConfig.thinkingBudget) && thinkingConfig.thinkingBudget >= 0) {
|
|
876
|
+
const budget = thinkingConfig.thinkingBudget;
|
|
877
|
+
unifiedRequest.reasoning = budget === 0 ? { effort: "none", enabled: false, max_tokens: 0 } : { effort: _chunk77USGNRWcjs.getThinkLevel.call(void 0, budget), enabled: true, max_tokens: budget };
|
|
878
|
+
}
|
|
862
879
|
if (Array.isArray(contents)) {
|
|
863
880
|
const toolCallIdsByName = /* @__PURE__ */ new Map();
|
|
864
881
|
for (const content of contents) {
|
|
@@ -897,14 +914,14 @@ function transformRequestOut(request) {
|
|
|
897
914
|
} else if ("inlineData" in part || "file_data" in part) {
|
|
898
915
|
const inline = part.inlineData;
|
|
899
916
|
const fileData = part.file_data;
|
|
900
|
-
if (_optionalChain([inline, 'optionalAccess',
|
|
917
|
+
if (_optionalChain([inline, 'optionalAccess', _126 => _126.data])) {
|
|
901
918
|
const mime = inline.mime_type || "image/png";
|
|
902
919
|
contentParts.push({
|
|
903
920
|
type: "image_url",
|
|
904
921
|
image_url: { url: `data:${mime};base64,${inline.data}` },
|
|
905
922
|
media_type: mime
|
|
906
923
|
});
|
|
907
|
-
} else if (_optionalChain([fileData, 'optionalAccess',
|
|
924
|
+
} else if (_optionalChain([fileData, 'optionalAccess', _127 => _127.file_uri])) {
|
|
908
925
|
contentParts.push({
|
|
909
926
|
type: "image_url",
|
|
910
927
|
image_url: { url: fileData.file_uri },
|
|
@@ -924,7 +941,7 @@ function transformRequestOut(request) {
|
|
|
924
941
|
const queue = toolCallIdsByName.get(fnName);
|
|
925
942
|
const id = queue && queue.length > 0 ? queue.shift() : `tool_${Math.random().toString(36).substring(2, 15)}`;
|
|
926
943
|
const response = fr.functionResponse.response;
|
|
927
|
-
const result = _optionalChain([response, 'optionalAccess',
|
|
944
|
+
const result = _optionalChain([response, 'optionalAccess', _128 => _128.result]);
|
|
928
945
|
const toolContent = typeof result === "string" ? result : result !== void 0 ? JSON.stringify(result) : response !== void 0 ? JSON.stringify(response) : "";
|
|
929
946
|
unifiedRequest.messages.push({
|
|
930
947
|
role: "tool",
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getThinkLevel
|
|
3
|
+
} from "./chunk-WYVGULTQ.js";
|
|
4
|
+
import {
|
|
5
|
+
extractReasoningIntent,
|
|
6
|
+
normalizeThinkLevel,
|
|
7
|
+
resolveReasoningPlan
|
|
8
|
+
} from "./chunk-N2EIM2XJ.js";
|
|
9
|
+
|
|
1
10
|
// src/transformer/transformers/utils/gemini.response-in.ts
|
|
2
11
|
var FINISH_REASON_TO_GEMINI = {
|
|
3
12
|
stop: "STOP",
|
|
@@ -685,7 +694,7 @@ function transformTool(tool) {
|
|
|
685
694
|
}
|
|
686
695
|
|
|
687
696
|
// src/transformer/transformers/utils/gemini.util.ts
|
|
688
|
-
function buildRequestBody(request) {
|
|
697
|
+
function buildRequestBody(request, provider, preserveNativeEffort = false) {
|
|
689
698
|
const tools = [];
|
|
690
699
|
const functionDeclarations = request.tools?.filter((tool) => tool.function.name !== "web_search")?.map((tool) => ({
|
|
691
700
|
name: tool.function.name,
|
|
@@ -795,27 +804,24 @@ function buildRequestBody(request) {
|
|
|
795
804
|
if (request.max_tokens !== void 0) {
|
|
796
805
|
generationConfig.maxOutputTokens = request.max_tokens;
|
|
797
806
|
}
|
|
798
|
-
|
|
807
|
+
const reasoningPlan = resolveReasoningPlan({
|
|
808
|
+
intent: extractReasoningIntent(request),
|
|
809
|
+
model: request.model,
|
|
810
|
+
provider,
|
|
811
|
+
target: "gemini",
|
|
812
|
+
requestMaxTokens: request.max_tokens,
|
|
813
|
+
preserveNativeEffort
|
|
814
|
+
});
|
|
815
|
+
if (reasoningPlan?.kind === "level") {
|
|
799
816
|
generationConfig.thinkingConfig = {
|
|
800
|
-
includeThoughts:
|
|
817
|
+
includeThoughts: reasoningPlan.enabled,
|
|
818
|
+
thinkingLevel: reasoningPlan.effort
|
|
819
|
+
};
|
|
820
|
+
} else if (reasoningPlan?.kind === "budget") {
|
|
821
|
+
generationConfig.thinkingConfig = {
|
|
822
|
+
includeThoughts: reasoningPlan.enabled,
|
|
823
|
+
thinkingBudget: reasoningPlan.budgetTokens
|
|
801
824
|
};
|
|
802
|
-
if (request.model.includes("gemini-3")) {
|
|
803
|
-
generationConfig.thinkingConfig.thinkingLevel = request.reasoning.effort;
|
|
804
|
-
} else {
|
|
805
|
-
const thinkingBudgets = request.model.includes("pro") ? [128, 32768] : [0, 24576];
|
|
806
|
-
const maxTokens = request.reasoning.max_tokens;
|
|
807
|
-
if (typeof maxTokens !== "undefined") {
|
|
808
|
-
let thinkingBudget;
|
|
809
|
-
if (maxTokens >= thinkingBudgets[0] && maxTokens <= thinkingBudgets[1]) {
|
|
810
|
-
thinkingBudget = maxTokens;
|
|
811
|
-
} else if (maxTokens < thinkingBudgets[0]) {
|
|
812
|
-
thinkingBudget = thinkingBudgets[0];
|
|
813
|
-
} else {
|
|
814
|
-
thinkingBudget = thinkingBudgets[1];
|
|
815
|
-
}
|
|
816
|
-
generationConfig.thinkingConfig.thinkingBudget = thinkingBudget;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
825
|
}
|
|
820
826
|
const body = {
|
|
821
827
|
contents,
|
|
@@ -859,6 +865,17 @@ function transformRequestOut(request) {
|
|
|
859
865
|
stream,
|
|
860
866
|
tool_choice: toolChoice
|
|
861
867
|
};
|
|
868
|
+
const thinkingConfig = generationConfig?.thinkingConfig;
|
|
869
|
+
const discreteEffort = normalizeThinkLevel(thinkingConfig?.thinkingLevel);
|
|
870
|
+
if (discreteEffort) {
|
|
871
|
+
unifiedRequest.reasoning = {
|
|
872
|
+
effort: discreteEffort,
|
|
873
|
+
enabled: discreteEffort !== "none"
|
|
874
|
+
};
|
|
875
|
+
} else if (typeof thinkingConfig?.thinkingBudget === "number" && Number.isFinite(thinkingConfig.thinkingBudget) && thinkingConfig.thinkingBudget >= 0) {
|
|
876
|
+
const budget = thinkingConfig.thinkingBudget;
|
|
877
|
+
unifiedRequest.reasoning = budget === 0 ? { effort: "none", enabled: false, max_tokens: 0 } : { effort: getThinkLevel(budget), enabled: true, max_tokens: budget };
|
|
878
|
+
}
|
|
862
879
|
if (Array.isArray(contents)) {
|
|
863
880
|
const toolCallIdsByName = /* @__PURE__ */ new Map();
|
|
864
881
|
for (const content of contents) {
|
|
@@ -78,6 +78,9 @@ var UsageRecorder = class {
|
|
|
78
78
|
costSavedByCacheUsd,
|
|
79
79
|
rawUsage: input.rawUsage != null ? safeStringify(input.rawUsage) : null,
|
|
80
80
|
runId: input.runId ?? null,
|
|
81
|
+
routeLeaseId: input.routeLeaseId ?? null,
|
|
82
|
+
routeLeaseConsumer: input.routeLeaseConsumer ?? null,
|
|
83
|
+
routeLeaseStageId: input.routeLeaseStageId ?? null,
|
|
81
84
|
eventId: input.eventId ?? null,
|
|
82
85
|
...input.cacheKeySource !== void 0 ? { cacheKeySource: input.cacheKeySource } : {},
|
|
83
86
|
...input.cacheKeyInjected !== void 0 ? { cacheKeyInjected: input.cacheKeyInjected } : {}
|