@depup/ai-sdk__google 4.0.44-depup.0 → 4.0.47-depup.0
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/CHANGELOG.md +20 -0
- package/README.md +2 -2
- package/changes.json +1 -1
- package/dist/index.js +84 -62
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +83 -61
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +36 -36
- package/package.json +4 -4
- package/src/google-language-model.ts +42 -13
- package/src/interactions/build-google-interactions-stream-transform.ts +10 -6
- package/src/interactions/parse-google-interactions-outputs.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.47
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e6087c9: fix: handle empty string tool call IDs
|
|
8
|
+
- Updated dependencies [e6087c9]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.28
|
|
10
|
+
|
|
11
|
+
## 4.0.46
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- f69920a: fix(google): use low as the minimum reasoning level for full Gemini Flash 3.7 and later
|
|
16
|
+
|
|
17
|
+
## 4.0.45
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- bb0cf2e: fix(google): coerce minimal reasoning to low for Gemini 3.7 Flash
|
|
22
|
+
|
|
3
23
|
## 4.0.44
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/ai-sdk__google
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.
|
|
17
|
-
| Processed | 2026-08-
|
|
16
|
+
| Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.47 |
|
|
17
|
+
| Processed | 2026-08-20 |
|
|
18
18
|
| Smoke test | failed |
|
|
19
19
|
| Deps updated | 0 |
|
|
20
20
|
|
package/changes.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.47" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -1881,7 +1881,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1881
1881
|
};
|
|
1882
1882
|
}
|
|
1883
1883
|
async doGenerate(options) {
|
|
1884
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
1884
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1885
1885
|
const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
|
|
1886
1886
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1887
1887
|
providerOptionsNames.map((name) => [name, payload])
|
|
@@ -1953,9 +1953,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1953
1953
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1954
1954
|
content.push({
|
|
1955
1955
|
type: "tool-call",
|
|
1956
|
-
toolCallId:
|
|
1956
|
+
toolCallId: part.functionCall.id || this.config.generateId(),
|
|
1957
1957
|
toolName: part.functionCall.name,
|
|
1958
|
-
input: JSON.stringify((
|
|
1958
|
+
input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
|
|
1959
1959
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1960
1960
|
thoughtSignature: part.thoughtSignature
|
|
1961
1961
|
}) : void 0
|
|
@@ -1972,13 +1972,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1972
1972
|
}) : void 0
|
|
1973
1973
|
});
|
|
1974
1974
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1975
|
-
const toolCallId =
|
|
1975
|
+
const toolCallId = part.toolCall.id || this.config.generateId();
|
|
1976
1976
|
lastServerToolCallId = toolCallId;
|
|
1977
1977
|
content.push({
|
|
1978
1978
|
type: "tool-call",
|
|
1979
1979
|
toolCallId,
|
|
1980
1980
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1981
|
-
input: JSON.stringify((
|
|
1981
|
+
input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
|
|
1982
1982
|
providerExecuted: true,
|
|
1983
1983
|
dynamic: true,
|
|
1984
1984
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -1991,12 +1991,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1991
1991
|
})
|
|
1992
1992
|
});
|
|
1993
1993
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1994
|
-
const responseToolCallId =
|
|
1994
|
+
const responseToolCallId = lastServerToolCallId || part.toolResponse.id || this.config.generateId();
|
|
1995
1995
|
content.push({
|
|
1996
1996
|
type: "tool-result",
|
|
1997
1997
|
toolCallId: responseToolCallId,
|
|
1998
1998
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1999
|
-
result: (
|
|
1999
|
+
result: (_g = part.toolResponse.response) != null ? _g : {},
|
|
2000
2000
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
2001
2001
|
thoughtSignature: part.thoughtSignature,
|
|
2002
2002
|
serverToolCallId: responseToolCallId,
|
|
@@ -2009,10 +2009,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2009
2009
|
lastServerToolCallId = void 0;
|
|
2010
2010
|
}
|
|
2011
2011
|
}
|
|
2012
|
-
const sources = (
|
|
2012
|
+
const sources = (_h = extractSources({
|
|
2013
2013
|
groundingMetadata: candidate.groundingMetadata,
|
|
2014
2014
|
generateId: this.config.generateId
|
|
2015
|
-
})) != null ?
|
|
2015
|
+
})) != null ? _h : [];
|
|
2016
2016
|
for (const source of sources) {
|
|
2017
2017
|
content.push(source);
|
|
2018
2018
|
}
|
|
@@ -2026,23 +2026,23 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2026
2026
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
2027
2027
|
)
|
|
2028
2028
|
}),
|
|
2029
|
-
raw: (
|
|
2029
|
+
raw: (_i = candidate.finishReason) != null ? _i : void 0
|
|
2030
2030
|
},
|
|
2031
2031
|
usage: convertGoogleUsage(usageMetadata),
|
|
2032
2032
|
warnings,
|
|
2033
2033
|
providerMetadata: wrapProviderMetadata({
|
|
2034
|
-
promptFeedback: (
|
|
2035
|
-
groundingMetadata: (
|
|
2036
|
-
urlContextMetadata: (
|
|
2037
|
-
safetyRatings: (
|
|
2034
|
+
promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
|
|
2035
|
+
groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
|
|
2036
|
+
urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
|
|
2037
|
+
safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
|
|
2038
2038
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2039
|
-
finishMessage: (
|
|
2040
|
-
serviceTier: (
|
|
2039
|
+
finishMessage: (_n = candidate.finishMessage) != null ? _n : null,
|
|
2040
|
+
serviceTier: (_o = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _o : null
|
|
2041
2041
|
}),
|
|
2042
2042
|
request: { body: args },
|
|
2043
2043
|
response: {
|
|
2044
2044
|
// TODO timestamp, model id
|
|
2045
|
-
id: (
|
|
2045
|
+
id: (_p = response.responseId) != null ? _p : void 0,
|
|
2046
2046
|
headers: responseHeaders,
|
|
2047
2047
|
body: rawResponse
|
|
2048
2048
|
}
|
|
@@ -2122,7 +2122,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2122
2122
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2123
2123
|
},
|
|
2124
2124
|
transform(chunk, controller) {
|
|
2125
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
2125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2126
2126
|
if (options.includeRawChunks) {
|
|
2127
2127
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2128
2128
|
}
|
|
@@ -2276,7 +2276,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2276
2276
|
providerMetadata: fileMeta
|
|
2277
2277
|
});
|
|
2278
2278
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2279
|
-
const toolCallId =
|
|
2279
|
+
const toolCallId = part.toolCall.id || generateId3();
|
|
2280
2280
|
lastServerToolCallId = toolCallId;
|
|
2281
2281
|
const serverMeta = wrapProviderMetadata({
|
|
2282
2282
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
@@ -2287,13 +2287,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2287
2287
|
type: "tool-call",
|
|
2288
2288
|
toolCallId,
|
|
2289
2289
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2290
|
-
input: JSON.stringify((
|
|
2290
|
+
input: JSON.stringify((_e = part.toolCall.args) != null ? _e : {}),
|
|
2291
2291
|
providerExecuted: true,
|
|
2292
2292
|
dynamic: true,
|
|
2293
2293
|
providerMetadata: serverMeta
|
|
2294
2294
|
});
|
|
2295
2295
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2296
|
-
const responseToolCallId =
|
|
2296
|
+
const responseToolCallId = lastServerToolCallId || part.toolResponse.id || generateId3();
|
|
2297
2297
|
const serverMeta = wrapProviderMetadata({
|
|
2298
2298
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
2299
2299
|
serverToolCallId: responseToolCallId,
|
|
@@ -2303,7 +2303,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2303
2303
|
type: "tool-result",
|
|
2304
2304
|
toolCallId: responseToolCallId,
|
|
2305
2305
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2306
|
-
result: (
|
|
2306
|
+
result: (_f = part.toolResponse.response) != null ? _f : {},
|
|
2307
2307
|
providerMetadata: serverMeta
|
|
2308
2308
|
});
|
|
2309
2309
|
lastServerToolCallId = void 0;
|
|
@@ -2320,7 +2320,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2320
2320
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
2321
2321
|
if (isStreamingChunk) {
|
|
2322
2322
|
if (part.functionCall.name != null) {
|
|
2323
|
-
const toolCallId =
|
|
2323
|
+
const toolCallId = part.functionCall.id || generateId3();
|
|
2324
2324
|
const accumulator = new GoogleJSONAccumulator();
|
|
2325
2325
|
activeStreamingToolCalls.push({
|
|
2326
2326
|
toolCallId,
|
|
@@ -2368,9 +2368,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2368
2368
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
2369
2369
|
finishActiveStreamingToolCall(controller);
|
|
2370
2370
|
} else if (isCompleteCall) {
|
|
2371
|
-
const toolCallId =
|
|
2371
|
+
const toolCallId = part.functionCall.id || generateId3();
|
|
2372
2372
|
const toolName = part.functionCall.name;
|
|
2373
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((
|
|
2373
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_g = part.functionCall.args) != null ? _g : {});
|
|
2374
2374
|
controller.enqueue({
|
|
2375
2375
|
type: "tool-input-start",
|
|
2376
2376
|
id: toolCallId,
|
|
@@ -2397,7 +2397,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2397
2397
|
});
|
|
2398
2398
|
hasToolCalls = true;
|
|
2399
2399
|
} else if (isNoArgsCompleteCall) {
|
|
2400
|
-
const toolCallId =
|
|
2400
|
+
const toolCallId = part.functionCall.id || generateId3();
|
|
2401
2401
|
const toolName = part.functionCall.name;
|
|
2402
2402
|
controller.enqueue({
|
|
2403
2403
|
type: "tool-input-start",
|
|
@@ -2430,13 +2430,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2430
2430
|
raw: candidate.finishReason
|
|
2431
2431
|
};
|
|
2432
2432
|
providerMetadata = wrapProviderMetadata({
|
|
2433
|
-
promptFeedback: (
|
|
2433
|
+
promptFeedback: (_h = value.promptFeedback) != null ? _h : null,
|
|
2434
2434
|
groundingMetadata: lastGroundingMetadata,
|
|
2435
2435
|
urlContextMetadata: lastUrlContextMetadata,
|
|
2436
|
-
safetyRatings: (
|
|
2436
|
+
safetyRatings: (_i = candidate.safetyRatings) != null ? _i : null,
|
|
2437
2437
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2438
|
-
finishMessage: (
|
|
2439
|
-
serviceTier: (
|
|
2438
|
+
finishMessage: (_j = candidate.finishMessage) != null ? _j : null,
|
|
2439
|
+
serviceTier: (_k = usage == null ? void 0 : usage.serviceTier) != null ? _k : null
|
|
2440
2440
|
});
|
|
2441
2441
|
}
|
|
2442
2442
|
},
|
|
@@ -2486,21 +2486,23 @@ function resolveThinkingConfig({
|
|
|
2486
2486
|
return void 0;
|
|
2487
2487
|
}
|
|
2488
2488
|
if (getGoogleModelCapabilities(modelId).usesGemini3Features && !modelId.includes("gemini-3-pro-image")) {
|
|
2489
|
-
return resolveGemini3ThinkingConfig({ reasoning, warnings });
|
|
2489
|
+
return resolveGemini3ThinkingConfig({ reasoning, modelId, warnings });
|
|
2490
2490
|
}
|
|
2491
2491
|
return resolveGemini25ThinkingConfig({ reasoning, modelId, warnings });
|
|
2492
2492
|
}
|
|
2493
2493
|
function resolveGemini3ThinkingConfig({
|
|
2494
2494
|
reasoning,
|
|
2495
|
+
modelId,
|
|
2495
2496
|
warnings
|
|
2496
2497
|
}) {
|
|
2498
|
+
const minimumThinkingLevel = getMinimumThinkingLevelForGemini3Model(modelId);
|
|
2497
2499
|
if (reasoning === "none") {
|
|
2498
|
-
return { thinkingLevel:
|
|
2500
|
+
return { thinkingLevel: minimumThinkingLevel };
|
|
2499
2501
|
}
|
|
2500
2502
|
const thinkingLevel = mapReasoningToProviderEffort({
|
|
2501
2503
|
reasoning,
|
|
2502
2504
|
effortMap: {
|
|
2503
|
-
minimal:
|
|
2505
|
+
minimal: minimumThinkingLevel,
|
|
2504
2506
|
low: "low",
|
|
2505
2507
|
medium: "medium",
|
|
2506
2508
|
high: "high",
|
|
@@ -2513,6 +2515,22 @@ function resolveGemini3ThinkingConfig({
|
|
|
2513
2515
|
}
|
|
2514
2516
|
return { thinkingLevel };
|
|
2515
2517
|
}
|
|
2518
|
+
function getMinimumThinkingLevelForGemini3Model(modelId) {
|
|
2519
|
+
var _a;
|
|
2520
|
+
const modelName = (_a = modelId.split("/").at(-1)) == null ? void 0 : _a.toLowerCase();
|
|
2521
|
+
if (modelName === "gemini-flash-latest") {
|
|
2522
|
+
return "low";
|
|
2523
|
+
}
|
|
2524
|
+
const versionMatch = /^gemini-(\d+)\.(\d+)-flash(?:$|-(?!lite(?:-|$)))/.exec(
|
|
2525
|
+
modelName != null ? modelName : ""
|
|
2526
|
+
);
|
|
2527
|
+
if (versionMatch == null) {
|
|
2528
|
+
return "minimal";
|
|
2529
|
+
}
|
|
2530
|
+
const majorVersion = Number(versionMatch[1]);
|
|
2531
|
+
const minorVersion = Number(versionMatch[2]);
|
|
2532
|
+
return majorVersion > 3 || majorVersion === 3 && minorVersion >= 7 ? "low" : "minimal";
|
|
2533
|
+
}
|
|
2516
2534
|
function resolveGemini25ThinkingConfig({
|
|
2517
2535
|
reasoning,
|
|
2518
2536
|
modelId,
|
|
@@ -4399,7 +4417,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4399
4417
|
controller.enqueue({ type: "stream-start", warnings });
|
|
4400
4418
|
},
|
|
4401
4419
|
transform(chunk, controller) {
|
|
4402
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
4420
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
4403
4421
|
if (includeRawChunks) {
|
|
4404
4422
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
4405
4423
|
}
|
|
@@ -4490,8 +4508,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4490
4508
|
}
|
|
4491
4509
|
}
|
|
4492
4510
|
} else if (stepType === "function_call") {
|
|
4493
|
-
const toolCallId = (
|
|
4494
|
-
const toolName = (
|
|
4511
|
+
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
4512
|
+
const toolName = (_b = step == null ? void 0 : step.name) != null ? _b : "unknown";
|
|
4495
4513
|
hasFunctionCall = true;
|
|
4496
4514
|
const state = {
|
|
4497
4515
|
kind: "function_call",
|
|
@@ -4508,28 +4526,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4508
4526
|
toolName
|
|
4509
4527
|
});
|
|
4510
4528
|
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
4511
|
-
const toolName = stepType === "mcp_server_tool_call" ? (
|
|
4512
|
-
const toolCallId = (
|
|
4529
|
+
const toolName = stepType === "mcp_server_tool_call" ? (_c = step == null ? void 0 : step.name) != null ? _c : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
4530
|
+
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
4513
4531
|
const state = {
|
|
4514
4532
|
kind: "builtin_tool_call",
|
|
4515
4533
|
id: blockId,
|
|
4516
4534
|
blockType: stepType,
|
|
4517
4535
|
toolCallId,
|
|
4518
4536
|
toolName,
|
|
4519
|
-
arguments: (
|
|
4537
|
+
arguments: (_d = step == null ? void 0 : step.arguments) != null ? _d : {},
|
|
4520
4538
|
callEmitted: false
|
|
4521
4539
|
};
|
|
4522
4540
|
openBlocks.set(index, state);
|
|
4523
4541
|
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
4524
|
-
const toolName = stepType === "mcp_server_tool_result" ? (
|
|
4525
|
-
const callId = (
|
|
4542
|
+
const toolName = stepType === "mcp_server_tool_result" ? (_e = step == null ? void 0 : step.name) != null ? _e : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
4543
|
+
const callId = (step == null ? void 0 : step.call_id) || blockId;
|
|
4526
4544
|
const state = {
|
|
4527
4545
|
kind: "builtin_tool_result",
|
|
4528
4546
|
id: blockId,
|
|
4529
4547
|
blockType: stepType,
|
|
4530
4548
|
callId,
|
|
4531
4549
|
toolName,
|
|
4532
|
-
result: (
|
|
4550
|
+
result: (_f = step == null ? void 0 : step.result) != null ? _f : null,
|
|
4533
4551
|
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
4534
4552
|
resultEmitted: false
|
|
4535
4553
|
};
|
|
@@ -4543,7 +4561,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4543
4561
|
const event = value;
|
|
4544
4562
|
let open = openBlocks.get(event.index);
|
|
4545
4563
|
if (open == null) break;
|
|
4546
|
-
const dtype = (
|
|
4564
|
+
const dtype = (_g = event.delta) == null ? void 0 : _g.type;
|
|
4547
4565
|
if (open.kind === "pending_model_output") {
|
|
4548
4566
|
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
4549
4567
|
const promoted = {
|
|
@@ -4564,14 +4582,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4564
4582
|
if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
|
|
4565
4583
|
controller.enqueue({
|
|
4566
4584
|
type: "file",
|
|
4567
|
-
mediaType: (
|
|
4585
|
+
mediaType: (_h = imageDelta.mime_type) != null ? _h : "image/png",
|
|
4568
4586
|
data: { type: "data", data: imageDelta.data },
|
|
4569
4587
|
...providerMetadata ? { providerMetadata } : {}
|
|
4570
4588
|
});
|
|
4571
4589
|
} else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
|
|
4572
4590
|
controller.enqueue({
|
|
4573
4591
|
type: "file",
|
|
4574
|
-
mediaType: (
|
|
4592
|
+
mediaType: (_i = imageDelta.mime_type) != null ? _i : "image/png",
|
|
4575
4593
|
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
4576
4594
|
...providerMetadata ? { providerMetadata } : {}
|
|
4577
4595
|
});
|
|
@@ -4590,14 +4608,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4590
4608
|
if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
|
|
4591
4609
|
controller.enqueue({
|
|
4592
4610
|
type: "file",
|
|
4593
|
-
mediaType: (
|
|
4611
|
+
mediaType: (_j = videoDelta.mime_type) != null ? _j : "video/mp4",
|
|
4594
4612
|
data: { type: "data", data: videoDelta.data },
|
|
4595
4613
|
...providerMetadata ? { providerMetadata } : {}
|
|
4596
4614
|
});
|
|
4597
4615
|
} else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
|
|
4598
4616
|
controller.enqueue({
|
|
4599
4617
|
type: "file",
|
|
4600
|
-
mediaType: (
|
|
4618
|
+
mediaType: (_k = videoDelta.mime_type) != null ? _k : "video/mp4",
|
|
4601
4619
|
data: { type: "url", url: new URL(videoDelta.uri) },
|
|
4602
4620
|
...providerMetadata ? { providerMetadata } : {}
|
|
4603
4621
|
});
|
|
@@ -4606,7 +4624,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4606
4624
|
}
|
|
4607
4625
|
const delta = event.delta;
|
|
4608
4626
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
4609
|
-
const text = (
|
|
4627
|
+
const text = (_l = delta.text) != null ? _l : "";
|
|
4610
4628
|
if (text.length > 0) {
|
|
4611
4629
|
controller.enqueue({
|
|
4612
4630
|
type: "text-delta",
|
|
@@ -4656,7 +4674,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4656
4674
|
delta: slice
|
|
4657
4675
|
});
|
|
4658
4676
|
}
|
|
4659
|
-
if (delta.id != null) {
|
|
4677
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
4660
4678
|
open.toolCallId = delta.id;
|
|
4661
4679
|
}
|
|
4662
4680
|
if (delta.signature != null) {
|
|
@@ -4664,7 +4682,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4664
4682
|
}
|
|
4665
4683
|
hasFunctionCall = true;
|
|
4666
4684
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
4667
|
-
if (delta.id != null
|
|
4685
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
4686
|
+
open.toolCallId = delta.id;
|
|
4687
|
+
}
|
|
4668
4688
|
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
4669
4689
|
open.arguments = delta.arguments;
|
|
4670
4690
|
}
|
|
@@ -4672,7 +4692,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4672
4692
|
open.toolName = delta.name;
|
|
4673
4693
|
}
|
|
4674
4694
|
} else if (open.kind === "builtin_tool_result" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
4675
|
-
if (delta.call_id != null
|
|
4695
|
+
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
4696
|
+
open.callId = delta.call_id;
|
|
4697
|
+
}
|
|
4676
4698
|
if (delta.result !== void 0) open.result = delta.result;
|
|
4677
4699
|
if (delta.is_error != null) open.isError = delta.is_error;
|
|
4678
4700
|
if (delta.name != null && open.blockType === "mcp_server_tool_result") {
|
|
@@ -4709,14 +4731,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4709
4731
|
if (open.data != null && open.data.length > 0) {
|
|
4710
4732
|
controller.enqueue({
|
|
4711
4733
|
type: "file",
|
|
4712
|
-
mediaType: (
|
|
4734
|
+
mediaType: (_m = open.mimeType) != null ? _m : "image/png",
|
|
4713
4735
|
data: { type: "data", data: open.data },
|
|
4714
4736
|
...providerMetadata ? { providerMetadata } : {}
|
|
4715
4737
|
});
|
|
4716
4738
|
} else if (open.uri != null && open.uri.length > 0) {
|
|
4717
4739
|
controller.enqueue({
|
|
4718
4740
|
type: "file",
|
|
4719
|
-
mediaType: (
|
|
4741
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
4720
4742
|
data: { type: "url", url: new URL(open.uri) },
|
|
4721
4743
|
...providerMetadata ? { providerMetadata } : {}
|
|
4722
4744
|
});
|
|
@@ -4743,7 +4765,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4743
4765
|
type: "tool-call",
|
|
4744
4766
|
toolCallId: open.toolCallId,
|
|
4745
4767
|
toolName: open.toolName,
|
|
4746
|
-
input: JSON.stringify((
|
|
4768
|
+
input: JSON.stringify((_o = open.arguments) != null ? _o : {}),
|
|
4747
4769
|
providerExecuted: true
|
|
4748
4770
|
});
|
|
4749
4771
|
open.callEmitted = true;
|
|
@@ -4752,7 +4774,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4752
4774
|
type: "tool-result",
|
|
4753
4775
|
toolCallId: open.callId,
|
|
4754
4776
|
toolName: open.toolName,
|
|
4755
|
-
result: (
|
|
4777
|
+
result: (_p = open.result) != null ? _p : null
|
|
4756
4778
|
});
|
|
4757
4779
|
open.resultEmitted = true;
|
|
4758
4780
|
const sources = builtinToolResultToSources({
|
|
@@ -4806,7 +4828,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4806
4828
|
case "error": {
|
|
4807
4829
|
const event = value;
|
|
4808
4830
|
finishStatus = "failed";
|
|
4809
|
-
const errorPayload = (
|
|
4831
|
+
const errorPayload = (_q = event.error) != null ? _q : {
|
|
4810
4832
|
message: "Unknown interaction error"
|
|
4811
4833
|
};
|
|
4812
4834
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -5794,7 +5816,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5794
5816
|
generateId: generateId3,
|
|
5795
5817
|
interactionId
|
|
5796
5818
|
}) {
|
|
5797
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
5819
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5798
5820
|
const content = [];
|
|
5799
5821
|
let hasFunctionCall = false;
|
|
5800
5822
|
if (steps == null) {
|
|
@@ -5901,19 +5923,19 @@ function parseGoogleInteractionsOutputs({
|
|
|
5901
5923
|
const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
|
|
5902
5924
|
content.push({
|
|
5903
5925
|
type: "tool-call",
|
|
5904
|
-
toolCallId:
|
|
5926
|
+
toolCallId: call.id || generateId3(),
|
|
5905
5927
|
toolName,
|
|
5906
5928
|
input,
|
|
5907
5929
|
providerExecuted: true
|
|
5908
5930
|
});
|
|
5909
5931
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
5910
5932
|
const result = step;
|
|
5911
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
5933
|
+
const toolName = type === "mcp_server_tool_result" ? (_j = result.name) != null ? _j : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
5912
5934
|
content.push({
|
|
5913
5935
|
type: "tool-result",
|
|
5914
|
-
toolCallId:
|
|
5936
|
+
toolCallId: result.call_id || generateId3(),
|
|
5915
5937
|
toolName,
|
|
5916
|
-
result: (
|
|
5938
|
+
result: (_k = result.result) != null ? _k : null
|
|
5917
5939
|
});
|
|
5918
5940
|
const sources = builtinToolResultToSources({
|
|
5919
5941
|
block: step,
|