@openclaw/ai 2026.9.5 → 2026.9.7
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/{anthropic-COtDvgtt.mjs → anthropic-Cw2pgccz.mjs} +59 -88
- package/dist/{anthropic-payload-policy-5Erq1Nzy.d.mts → anthropic-payload-policy-NIPVYXPq.d.mts} +8 -6
- package/dist/{anthropic-stream-reducer-BvdYYWL8.mjs → anthropic-stream-reducer-D9MCkl8Z.mjs} +194 -247
- package/dist/{api-registry-Ba2Cv-ut.d.mts → api-registry-D-nbmSqr.d.mts} +2 -2
- package/dist/{azure-openai-responses-YrgnD583.mjs → azure-openai-responses-BwT3-X8P.mjs} +22 -33
- package/dist/{base64-BQOzsvUH.mjs → base64-C1PsYcRQ.mjs} +22 -16
- package/dist/{diagnostics-Dm4bisWG.mjs → diagnostics-CJaB6g8J.mjs} +55 -10
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -5
- package/dist/diagnostics.mjs +4 -4
- package/dist/{env-api-keys-bktO00EJ.mjs → env-api-keys-CyX4VKGO.mjs} +7 -5
- package/dist/event-stream-CMQfX_yr.d.mts +1 -0
- package/dist/{event-stream-CCoa-qSI.d.mts → event-stream-DOPFYVqs.d.mts} +2 -2
- package/dist/{event-stream-D8PARQfL.mjs → event-stream-vd9UnCAU.mjs} +10 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-BuhpRO9r.mjs → google-BfapkS_K.mjs} +8 -11
- package/dist/google-interactions-DW3iXzjc.mjs +574 -0
- package/dist/{google-messages-CyWnYlh0.mjs → google-messages-CtjVtVot.mjs} +35 -71
- package/dist/{google-shared-BT5ZeNer.mjs → google-shared-Y2YfotEu.mjs} +43 -47
- package/dist/{google-vertex-C7EplRvt.mjs → google-vertex-Dov4kBWu.mjs} +16 -30
- package/dist/{host-B4MeUNBc.mjs → host-CHi3X87F.mjs} +64 -189
- package/dist/{host-policy-DUnXSx0I.mjs → host-policy-BOAwRg_M.mjs} +2 -14
- package/dist/{host-FZ1RA_qD.d.mts → host-rxlNaBwm.d.mts} +9 -3
- package/dist/{index-DaF2QbwS.d.mts → index-D6KsSE74.d.mts} +57 -9
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +13 -8
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +46 -9
- package/dist/internal/openai.mjs +13 -12
- package/dist/internal/runtime.d.mts +31 -70
- package/dist/internal/runtime.mjs +11 -66
- package/dist/internal/shared.d.mts +16 -13
- package/dist/internal/shared.mjs +6 -5
- package/dist/internal/tool-schema.d.mts +2 -2
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral-moA-mbwl.mjs → mistral-RS6mboC-.mjs} +46 -93
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-DWID3EFO.mjs → openai-chatgpt-responses-CYbidtrn.mjs} +118 -99
- package/dist/{openai-completions-DJ1Vm-CD.mjs → openai-completions-D14ihPYk.mjs} +14 -12
- package/dist/{openai-completions-compat-CkwdxTZx.mjs → openai-completions-compat-BOVWBZDn.mjs} +3 -5
- package/dist/{openai-completions-compat-JE7gqxb9.d.mts → openai-completions-compat-qJjmqQ71.d.mts} +3 -3
- package/dist/{openai-completions-stream-Bu98b0Hv.mjs → openai-completions-stream-CDCuw3DP.mjs} +124 -183
- package/dist/{openai-prompt-cache-CJ_xEevu.d.mts → openai-prompt-cache-CouErLh7.d.mts} +2 -2
- package/dist/{openai-prompt-cache-1wfaIszn.mjs → openai-prompt-cache-D2V7MqR7.mjs} +1 -1
- package/dist/{openai-provider-client-DPo0Hmak.mjs → openai-provider-client-CwfsGBbA.mjs} +2 -2
- package/dist/{openai-reasoning-effort-NlFZmfEu.mjs → openai-reasoning-effort-ConhwkeX.mjs} +14 -5
- package/dist/{openai-responses-BejZzQCP.mjs → openai-responses-CKCBEc2W.mjs} +12 -11
- package/dist/openai-responses-compaction-replay-DiYn-gFM.d.mts +12 -0
- package/dist/{openai-responses-compaction-window-D6P5oZP5.mjs → openai-responses-compaction-window-UNK1GDpy.mjs} +5 -5
- package/dist/{openai-responses-contracts-DWrfMODE.mjs → openai-responses-contracts-CLxnqS9p.mjs} +1 -1
- package/dist/{openai-responses-contracts-Dflvrfa8.d.mts → openai-responses-contracts-D1iZ0njF.d.mts} +4 -4
- package/dist/{openai-responses-prompt-observer-internal-C15_-OwV.mjs → openai-responses-prompt-observer-internal-iAqLb4tk.mjs} +16 -13
- package/dist/openai-responses-request-lifecycle-Fsag-IGZ.mjs +36 -0
- package/dist/{openai-responses-shared-CwsziD_m.mjs → openai-responses-shared-DL4ulQn7.mjs} +838 -577
- package/dist/{openai-responses-terminal-usage-Dl3J6zrf.d.mts → openai-responses-terminal-usage-BE7lf7nW.d.mts} +2 -2
- package/dist/{openai-stop-reason-Drnn_6Qj.mjs → openai-stop-reason-8s70vDXj.mjs} +2 -12
- package/dist/{openai-tool-schema-ynZBgqW-.d.mts → openai-tool-schema-a5ysBBga.d.mts} +0 -6
- package/dist/{openai-tool-schema-BO8rwyAD.mjs → openai-tool-schema-vsl-cE-n.mjs} +365 -429
- package/dist/{openai-transport-params-DQeuAvBl.mjs → openai-transport-params-BwlpzX-2.mjs} +61 -106
- package/dist/{positive-integer-DtjCkbue.mjs → positive-integer-CjN5OJbH.mjs} +1 -1
- package/dist/{provider-error-DDqw9Qda.mjs → provider-error-CwT_j2v0.mjs} +82 -10
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-DprLsWh9.d.mts → provider-options-Df7ov0K1.d.mts} +6 -4
- package/dist/{provider-replay-context-CnUSOwhr.mjs → provider-replay-context-DsyI5jOP.mjs} +1 -1
- package/dist/{provider-transcript-transform-BsRAhuWJ.mjs → provider-transcript-transform-JbFbHV8h.mjs} +17 -2
- package/dist/{provider-transport-turn-state-CkGToCD2.mjs → provider-transport-turn-state-BheUi_hl.mjs} +1 -1
- package/dist/{provider-types-CAKRC7N5.d.mts → provider-types-d4XnoZMd.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +15 -11
- package/dist/{reasoning-tag-text-partitioner-Dy9IO8Dc.mjs → reasoning-tag-text-partitioner-B6FIIBt6.mjs} +193 -98
- package/dist/{record-coerce-DwRYMj3t.mjs → record-coerce-CNDovvft.mjs} +1 -1
- package/dist/simple-options-CGAkCwtM.mjs +349 -0
- package/dist/{src-DeKjbE8I.mjs → src-H4aXcFuX.mjs} +53 -26
- package/dist/{stream-CREqxHgU.mjs → stream-DDsCBgd-.mjs} +1 -7
- package/dist/{stream-first-event-timeout-C9ZadkJW.mjs → stream-first-event-timeout-B9o0S4SZ.mjs} +1 -1
- package/dist/{tool-schema-json-projection-CD9c_fK8.mjs → tool-schema-json-projection-Ct8SeBeJ.mjs} +63 -23
- package/dist/{transport-stream-shared-D-6FQSHm.mjs → transport-stream-shared-Dh5qKJ8e.mjs} +63 -37
- package/dist/{transport-stream-shared-BbUkFaHi.d.mts → transport-stream-shared-yYhXa4kX.d.mts} +13 -7
- package/dist/{transport-utils-1cyq5Y7x.mjs → transport-utils-C-4bf2Ok.mjs} +3 -4
- package/dist/transports.d.mts +37 -33
- package/dist/transports.mjs +208 -239
- package/dist/types-CB-_vNyI.d.mts +1 -0
- package/dist/{types-4_uVs5WH.d.mts → types-CLLR3eB4.d.mts} +5 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/{validation-Dw7cb6BV.mjs → validation-BFZc40Ig.mjs} +80 -54
- package/dist/{validation-Ctzu2DhF.d.mts → validation-Cat2wQsc.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +6 -6
- package/dist/assistant-output-BsEkB-vU.mjs +0 -16
- package/dist/event-stream-DmSCpi1T.d.mts +0 -1
- package/dist/simple-options-C6cFWj_f.mjs +0 -175
- package/dist/types-DkJfb4W3.d.mts +0 -1
- package/dist/utf16-slice-CvGodqok.mjs +0 -29
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as appendAssistantThinking } from "./event-stream-
|
|
2
|
-
import {
|
|
3
|
-
import { v as
|
|
4
|
-
import {
|
|
1
|
+
import { r as appendAssistantThinking } from "./event-stream-vd9UnCAU.mjs";
|
|
2
|
+
import { k as isImageWithMediaPayload, w as calculateCost } from "./host-CHi3X87F.mjs";
|
|
3
|
+
import { a as createEmptyTransportUsage, b as transportAbortError, j as sanitizeSurrogates, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
4
|
+
import { D as sortPromptCacheToolsByName, d as describeToolResultMediaPlaceholder, m as extractToolResultText } from "./simple-options-CGAkCwtM.mjs";
|
|
5
5
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
6
6
|
//#region packages/ai/src/transports/google-thinking-level.ts
|
|
7
7
|
/** Returns whether a Gemini Flash model accepts the MINIMAL thinking level. */
|
|
@@ -66,16 +66,10 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
66
66
|
const blockIndex = () => blocks.length - 1;
|
|
67
67
|
const endCurrentBlock = () => {
|
|
68
68
|
if (!currentBlock) return;
|
|
69
|
-
|
|
70
|
-
type: "text_end",
|
|
69
|
+
params.stream.push({
|
|
70
|
+
type: currentBlock.type === "text" ? "text_end" : "thinking_end",
|
|
71
71
|
contentIndex: blockIndex(),
|
|
72
|
-
content: currentBlock.text,
|
|
73
|
-
partial: params.output
|
|
74
|
-
});
|
|
75
|
-
else params.stream.push({
|
|
76
|
-
type: "thinking_end",
|
|
77
|
-
contentIndex: blockIndex(),
|
|
78
|
-
content: currentBlock.thinking,
|
|
72
|
+
content: currentBlock.type === "text" ? currentBlock.text : currentBlock.thinking,
|
|
79
73
|
partial: params.output
|
|
80
74
|
});
|
|
81
75
|
currentBlock = null;
|
|
@@ -101,18 +95,11 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
101
95
|
const toolUsePromptTokens = knownUsage.toolUsePromptTokenCount;
|
|
102
96
|
const outputTokens = knownUsage.candidatesTokenCount + knownUsage.thoughtsTokenCount;
|
|
103
97
|
params.output.usage = {
|
|
98
|
+
...createEmptyTransportUsage(),
|
|
104
99
|
input: Math.max(0, promptTokens - cacheRead) + toolUsePromptTokens,
|
|
105
100
|
output: outputTokens,
|
|
106
101
|
cacheRead,
|
|
107
|
-
|
|
108
|
-
totalTokens: chunk.usageMetadata.totalTokenCount ?? promptTokens + outputTokens + toolUsePromptTokens,
|
|
109
|
-
cost: {
|
|
110
|
-
input: 0,
|
|
111
|
-
output: 0,
|
|
112
|
-
cacheRead: 0,
|
|
113
|
-
cacheWrite: 0,
|
|
114
|
-
total: 0
|
|
115
|
-
}
|
|
102
|
+
totalTokens: chunk.usageMetadata.totalTokenCount ?? promptTokens + outputTokens + toolUsePromptTokens
|
|
116
103
|
};
|
|
117
104
|
calculateCost(params.model, params.output.usage);
|
|
118
105
|
}
|
|
@@ -153,51 +140,35 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
153
140
|
const isThinking = part.thought === true || !preserveParts && !hasText;
|
|
154
141
|
if (!currentBlock || isThinking && currentBlock.type !== "thinking" || !isThinking && currentBlock.type !== "text") {
|
|
155
142
|
endCurrentBlock();
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
type: "text",
|
|
171
|
-
text: ""
|
|
172
|
-
};
|
|
173
|
-
params.output.content.push(currentBlock);
|
|
174
|
-
params.stream.push({
|
|
175
|
-
type: "text_start",
|
|
176
|
-
contentIndex: blockIndex(),
|
|
177
|
-
partial: params.output
|
|
178
|
-
});
|
|
179
|
-
}
|
|
143
|
+
currentBlock = isThinking ? {
|
|
144
|
+
type: "thinking",
|
|
145
|
+
thinking: "",
|
|
146
|
+
...preserveParts ? { thinkingSignature: void 0 } : {}
|
|
147
|
+
} : {
|
|
148
|
+
type: "text",
|
|
149
|
+
text: ""
|
|
150
|
+
};
|
|
151
|
+
params.output.content.push(currentBlock);
|
|
152
|
+
params.stream.push({
|
|
153
|
+
type: isThinking ? "thinking_start" : "text_start",
|
|
154
|
+
contentIndex: blockIndex(),
|
|
155
|
+
partial: params.output
|
|
156
|
+
});
|
|
180
157
|
}
|
|
181
158
|
const delta = hasText ? text : "";
|
|
182
159
|
if (currentBlock.type === "thinking") {
|
|
183
160
|
appendAssistantThinking(currentBlock, delta);
|
|
184
161
|
currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);
|
|
185
|
-
params.stream.push({
|
|
186
|
-
type: "thinking_delta",
|
|
187
|
-
contentIndex: blockIndex(),
|
|
188
|
-
delta,
|
|
189
|
-
partial: params.output
|
|
190
|
-
});
|
|
191
162
|
} else {
|
|
192
163
|
currentBlock.text += delta;
|
|
193
164
|
currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);
|
|
194
|
-
params.stream.push({
|
|
195
|
-
type: "text_delta",
|
|
196
|
-
contentIndex: blockIndex(),
|
|
197
|
-
delta,
|
|
198
|
-
partial: params.output
|
|
199
|
-
});
|
|
200
165
|
}
|
|
166
|
+
params.stream.push({
|
|
167
|
+
type: currentBlock.type === "thinking" ? "thinking_delta" : "text_delta",
|
|
168
|
+
contentIndex: blockIndex(),
|
|
169
|
+
delta,
|
|
170
|
+
partial: params.output
|
|
171
|
+
});
|
|
201
172
|
if (signatureOnly) endCurrentBlock();
|
|
202
173
|
}
|
|
203
174
|
if (part.functionCall) {
|
|
@@ -352,22 +323,15 @@ function projectGoogleMessages(params) {
|
|
|
352
323
|
let sawFunctionCall = false;
|
|
353
324
|
const nextReplaySignatures = /* @__PURE__ */ new Map();
|
|
354
325
|
const isSameProviderAndModel = msg.provider === model.provider && msg.api === model.api && msg.model === model.id;
|
|
355
|
-
for (const block of msg.content) if (block.type === "text") {
|
|
356
|
-
const
|
|
357
|
-
|
|
326
|
+
for (const block of msg.content) if (block.type === "text" || block.type === "thinking") {
|
|
327
|
+
const text = block.type === "text" ? block.text : block.thinking;
|
|
328
|
+
const thoughtSignature = isSameProviderAndModel ? signature(block.type === "text" ? block.textSignature : block.thinkingSignature) : void 0;
|
|
329
|
+
if ((!text || text.trim() === "") && (managed || !thoughtSignature)) continue;
|
|
358
330
|
parts.push({
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
});
|
|
362
|
-
} else if (block.type === "thinking") {
|
|
363
|
-
const thoughtSignature = isSameProviderAndModel ? signature(block.thinkingSignature) : void 0;
|
|
364
|
-
if ((!block.thinking || block.thinking.trim() === "") && (managed || !thoughtSignature)) continue;
|
|
365
|
-
if (isSameProviderAndModel) parts.push({
|
|
366
|
-
thought: true,
|
|
367
|
-
text: sanitizeText(block.thinking),
|
|
331
|
+
...block.type === "thinking" && isSameProviderAndModel ? { thought: true } : {},
|
|
332
|
+
text: sanitizeText(text),
|
|
368
333
|
...thoughtSignature && { thoughtSignature }
|
|
369
334
|
});
|
|
370
|
-
else parts.push({ text: sanitizeText(block.thinking) });
|
|
371
335
|
} else if (block.type === "toolCall") {
|
|
372
336
|
if (isSameProviderAndModel && (managed || model.provider !== "google-gemini-cli")) sameRouteToolCallIds.add(block.id);
|
|
373
337
|
const args = coerceTransportToolCallArguments(block.arguments);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
1
|
+
import { T as clampThinkingLevel } from "./host-CHi3X87F.mjs";
|
|
2
|
+
import { b as transportAbortError, c as failTransportStream, h as notifyProviderStreamOpened, j as sanitizeSurrogates } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
3
|
+
import { C as stripSystemPromptCacheBoundary } from "./simple-options-CGAkCwtM.mjs";
|
|
4
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-JbFbHV8h.mjs";
|
|
5
|
+
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-CtjVtVot.mjs";
|
|
6
6
|
import { FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
|
|
7
7
|
//#region packages/ai/src/providers/google-shared.ts
|
|
8
|
-
/**
|
|
9
|
-
* Shared utilities for Google Generative AI and Google Vertex providers.
|
|
10
|
-
*/
|
|
11
8
|
function convertMessages(model, context) {
|
|
12
9
|
return projectGoogleMessages({
|
|
13
10
|
model,
|
|
@@ -53,23 +50,20 @@ async function runGoogleGenerateContentLifecycle(params) {
|
|
|
53
50
|
} catch (error) {
|
|
54
51
|
for (const block of output.content) if ("index" in block) delete block.index;
|
|
55
52
|
const failure = options?.signal?.aborted ? transportAbortError(options.signal) : error;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
failTransportStream({
|
|
54
|
+
stream,
|
|
55
|
+
output,
|
|
56
|
+
error: failure,
|
|
57
|
+
signal: options?.signal
|
|
61
58
|
});
|
|
62
|
-
stream.end();
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
function buildGoogleGenerateContentParams(model, context, options = {}) {
|
|
66
62
|
const contents = convertMessages(model, context);
|
|
67
|
-
const generationConfig = {};
|
|
68
|
-
if (options.temperature !== void 0) generationConfig.temperature = options.temperature;
|
|
69
|
-
if (options.maxTokens !== void 0) generationConfig.maxOutputTokens = options.maxTokens;
|
|
70
|
-
if (options.stop !== void 0 && options.stop.length > 0) generationConfig.stopSequences = options.stop;
|
|
71
63
|
const config = {
|
|
72
|
-
...
|
|
64
|
+
...options.temperature !== void 0 && { temperature: options.temperature },
|
|
65
|
+
...options.maxTokens !== void 0 && { maxOutputTokens: options.maxTokens },
|
|
66
|
+
...options.stop !== void 0 && options.stop.length > 0 && { stopSequences: options.stop },
|
|
73
67
|
...context.systemPrompt && { systemInstruction: sanitizeSurrogates(stripSystemPromptCacheBoundary(context.systemPrompt)) },
|
|
74
68
|
...context.tools && context.tools.length > 0 && { tools: convertGoogleTools(context.tools) }
|
|
75
69
|
};
|
|
@@ -122,6 +116,28 @@ function buildGoogleSimpleThinking(model, options) {
|
|
|
122
116
|
budgetTokens: getGoogleBudget(model, effort, options.thinkingBudgets)
|
|
123
117
|
};
|
|
124
118
|
}
|
|
119
|
+
function buildGoogleInteractionsSimpleThinking(model, options) {
|
|
120
|
+
const thinking = buildGoogleSimpleThinking(model, options);
|
|
121
|
+
if (!thinking.enabled) {
|
|
122
|
+
if (!model.reasoning) return thinking;
|
|
123
|
+
const disabled = getDisabledGoogleThinkingConfig(model);
|
|
124
|
+
return {
|
|
125
|
+
enabled: false,
|
|
126
|
+
...disabled.thinkingLevel ? { level: disabled.thinkingLevel } : {}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (thinking.level !== void 0 || !options?.reasoning || isAdaptiveGoogleReasoningLevel(options.reasoning)) return thinking;
|
|
130
|
+
const clampedReasoning = clampThinkingLevel(model, options.reasoning);
|
|
131
|
+
if (clampedReasoning === "off") return { enabled: false };
|
|
132
|
+
if (clampedReasoning === "xhigh" || clampedReasoning === "max") return {
|
|
133
|
+
enabled: true,
|
|
134
|
+
level: getGoogleThinkingLevel("high", model)
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
enabled: true,
|
|
138
|
+
level: getGoogleThinkingLevel(clampedReasoning, model)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
125
141
|
function getDisabledGoogleThinkingConfig(model) {
|
|
126
142
|
if (isGemini3ProModel(model)) return { thinkingLevel: ThinkingLevel.LOW };
|
|
127
143
|
if (isGemini3FlashModel(model)) return { thinkingLevel: googleFlashSupportsMinimalThinking(model.id) ? ThinkingLevel.MINIMAL : ThinkingLevel.LOW };
|
|
@@ -139,18 +155,9 @@ function isGemini3FlashModel(model) {
|
|
|
139
155
|
return /gemini-(?:3(?:\.\d+)?-flash|flash(?:-lite)?-latest)/.test(model.id.toLowerCase());
|
|
140
156
|
}
|
|
141
157
|
function getGoogleThinkingLevel(effort, model) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
case "medium":
|
|
146
|
-
case "high": return ThinkingLevel.HIGH;
|
|
147
|
-
}
|
|
148
|
-
if (isGemma4Model(model)) switch (effort) {
|
|
149
|
-
case "minimal":
|
|
150
|
-
case "low": return ThinkingLevel.MINIMAL;
|
|
151
|
-
case "medium":
|
|
152
|
-
case "high": return ThinkingLevel.HIGH;
|
|
153
|
-
}
|
|
158
|
+
const lowEffort = effort === "minimal" || effort === "low";
|
|
159
|
+
if (isGemini3ProModel(model)) return lowEffort ? ThinkingLevel.LOW : ThinkingLevel.HIGH;
|
|
160
|
+
if (isGemma4Model(model)) return lowEffort ? ThinkingLevel.MINIMAL : ThinkingLevel.HIGH;
|
|
154
161
|
switch (effort) {
|
|
155
162
|
case "minimal": return isGemini3FlashModel(model) && !googleFlashSupportsMinimalThinking(model.id) ? ThinkingLevel.LOW : ThinkingLevel.MINIMAL;
|
|
156
163
|
case "low": return ThinkingLevel.LOW;
|
|
@@ -161,25 +168,14 @@ function getGoogleThinkingLevel(effort, model) {
|
|
|
161
168
|
}
|
|
162
169
|
function getGoogleBudget(model, effort, customBudgets) {
|
|
163
170
|
if (customBudgets?.[effort] !== void 0) return customBudgets[effort];
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
medium: 8192,
|
|
168
|
-
high: 32768
|
|
169
|
-
}[effort];
|
|
170
|
-
if (model.id.includes("2.5-flash-lite")) return {
|
|
171
|
-
minimal: 512,
|
|
172
|
-
low: 2048,
|
|
173
|
-
medium: 8192,
|
|
174
|
-
high: 24576
|
|
175
|
-
}[effort];
|
|
176
|
-
if (model.id.includes("2.5-flash")) return {
|
|
177
|
-
minimal: 128,
|
|
171
|
+
const isPro = model.id.includes("2.5-pro");
|
|
172
|
+
if (isPro || model.id.includes("2.5-flash")) return {
|
|
173
|
+
minimal: !isPro && model.id.includes("2.5-flash-lite") ? 512 : 128,
|
|
178
174
|
low: 2048,
|
|
179
175
|
medium: 8192,
|
|
180
|
-
high: 24576
|
|
176
|
+
high: isPro ? 32768 : 24576
|
|
181
177
|
}[effort];
|
|
182
178
|
return -1;
|
|
183
179
|
}
|
|
184
180
|
//#endregion
|
|
185
|
-
export {
|
|
181
|
+
export { runGoogleGenerateContentLifecycle as i, buildGoogleInteractionsSimpleThinking as n, buildGoogleSimpleThinking as r, buildGoogleGenerateContentParams as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
1
|
+
import { t as AssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
2
|
+
import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-CHi3X87F.mjs";
|
|
2
3
|
import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
|
|
3
|
-
import { n as
|
|
4
|
-
import { n as
|
|
5
|
-
import { t as
|
|
6
|
-
import { n as buildGoogleSimpleThinking, r as runGoogleGenerateContentLifecycle, t as buildGoogleGenerateContentParams } from "./google-shared-BT5ZeNer.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-CGAkCwtM.mjs";
|
|
5
|
+
import { n as createAssistantOutput } from "./provider-transcript-transform-JbFbHV8h.mjs";
|
|
6
|
+
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-Y2YfotEu.mjs";
|
|
7
7
|
import { GoogleGenAI, ResourceScope } from "@google/genai";
|
|
8
8
|
//#region packages/ai/src/providers/google-vertex.ts
|
|
9
9
|
const API_VERSION = "v1";
|
|
@@ -17,11 +17,8 @@ const streamGoogleVertex = (model, context, options) => {
|
|
|
17
17
|
model,
|
|
18
18
|
output,
|
|
19
19
|
options,
|
|
20
|
-
createClient: () =>
|
|
21
|
-
|
|
22
|
-
return apiKey ? createClientWithApiKey(model, apiKey, options?.headers) : createClient(model, resolveProject(options), resolveLocation(options), options?.headers);
|
|
23
|
-
},
|
|
24
|
-
buildParams: () => buildParams(model, context, options),
|
|
20
|
+
createClient: () => createClient(model, options),
|
|
21
|
+
buildParams: () => buildGoogleGenerateContentParams(model, context, options),
|
|
25
22
|
nextToolCallId: (name) => `${name}_${Date.now()}_${++toolCallCounter}`
|
|
26
23
|
});
|
|
27
24
|
return stream;
|
|
@@ -33,22 +30,17 @@ const streamSimpleGoogleVertex = (model, context, options) => {
|
|
|
33
30
|
thinking: buildGoogleSimpleThinking(model, options)
|
|
34
31
|
});
|
|
35
32
|
};
|
|
36
|
-
function createClient(model,
|
|
33
|
+
function createClient(model, options) {
|
|
34
|
+
const apiKey = resolveApiKey(options);
|
|
35
|
+
const credentials = apiKey ? { apiKey: getAiTransportHost().resolveSecretSentinel(apiKey) } : {
|
|
36
|
+
project: resolveProject(options),
|
|
37
|
+
location: resolveLocation(options)
|
|
38
|
+
};
|
|
37
39
|
return new GoogleGenAI({
|
|
38
40
|
vertexai: true,
|
|
39
|
-
|
|
40
|
-
location,
|
|
41
|
+
...credentials,
|
|
41
42
|
apiVersion: API_VERSION,
|
|
42
|
-
httpOptions: buildHttpOptions(model,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function createClientWithApiKey(model, apiKey, optionsHeaders) {
|
|
46
|
-
const resolvedApiKey = getAiTransportHost().resolveSecretSentinel(apiKey);
|
|
47
|
-
return new GoogleGenAI({
|
|
48
|
-
vertexai: true,
|
|
49
|
-
apiKey: resolvedApiKey,
|
|
50
|
-
apiVersion: API_VERSION,
|
|
51
|
-
httpOptions: buildHttpOptions(model, optionsHeaders)
|
|
43
|
+
httpOptions: buildHttpOptions(model, options?.headers)
|
|
52
44
|
});
|
|
53
45
|
}
|
|
54
46
|
function buildHttpOptions(model, optionsHeaders) {
|
|
@@ -79,12 +71,9 @@ function baseUrlIncludesApiVersion(baseUrl) {
|
|
|
79
71
|
}
|
|
80
72
|
function resolveApiKey(options) {
|
|
81
73
|
const apiKey = options?.apiKey?.trim() || process.env.GOOGLE_CLOUD_API_KEY?.trim();
|
|
82
|
-
if (!apiKey || apiKey === GCP_VERTEX_CREDENTIALS_MARKER ||
|
|
74
|
+
if (!apiKey || apiKey === GCP_VERTEX_CREDENTIALS_MARKER || /^<[^>]+>$/.test(apiKey)) return;
|
|
83
75
|
return apiKey;
|
|
84
76
|
}
|
|
85
|
-
function isPlaceholderApiKey(apiKey) {
|
|
86
|
-
return /^<[^>]+>$/.test(apiKey);
|
|
87
|
-
}
|
|
88
77
|
function resolveProject(options) {
|
|
89
78
|
const project = normalizeOptionalString(options?.project) || normalizeOptionalString(process.env.GOOGLE_CLOUD_PROJECT) || normalizeOptionalString(process.env.GCLOUD_PROJECT);
|
|
90
79
|
if (!project) throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");
|
|
@@ -95,8 +84,5 @@ function resolveLocation(options) {
|
|
|
95
84
|
if (!location) throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");
|
|
96
85
|
return location;
|
|
97
86
|
}
|
|
98
|
-
function buildParams(model, context, options = {}) {
|
|
99
|
-
return buildGoogleGenerateContentParams(model, context, options);
|
|
100
|
-
}
|
|
101
87
|
//#endregion
|
|
102
88
|
export { streamGoogleVertex, streamSimpleGoogleVertex };
|