@depup/ai-sdk__google 4.0.45-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 +14 -0
- package/README.md +2 -2
- package/changes.json +1 -1
- package/dist/index.js +80 -60
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +79 -59
- package/dist/internal/index.js.map +1 -1
- package/package.json +4 -4
- package/src/google-language-model.ts +36 -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,19 @@
|
|
|
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
|
+
|
|
3
17
|
## 4.0.45
|
|
4
18
|
|
|
5
19
|
### 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
|
},
|
|
@@ -2495,7 +2495,7 @@ function resolveGemini3ThinkingConfig({
|
|
|
2495
2495
|
modelId,
|
|
2496
2496
|
warnings
|
|
2497
2497
|
}) {
|
|
2498
|
-
const minimumThinkingLevel =
|
|
2498
|
+
const minimumThinkingLevel = getMinimumThinkingLevelForGemini3Model(modelId);
|
|
2499
2499
|
if (reasoning === "none") {
|
|
2500
2500
|
return { thinkingLevel: minimumThinkingLevel };
|
|
2501
2501
|
}
|
|
@@ -2515,6 +2515,22 @@ function resolveGemini3ThinkingConfig({
|
|
|
2515
2515
|
}
|
|
2516
2516
|
return { thinkingLevel };
|
|
2517
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
|
+
}
|
|
2518
2534
|
function resolveGemini25ThinkingConfig({
|
|
2519
2535
|
reasoning,
|
|
2520
2536
|
modelId,
|
|
@@ -4401,7 +4417,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4401
4417
|
controller.enqueue({ type: "stream-start", warnings });
|
|
4402
4418
|
},
|
|
4403
4419
|
transform(chunk, controller) {
|
|
4404
|
-
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;
|
|
4405
4421
|
if (includeRawChunks) {
|
|
4406
4422
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
4407
4423
|
}
|
|
@@ -4492,8 +4508,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4492
4508
|
}
|
|
4493
4509
|
}
|
|
4494
4510
|
} else if (stepType === "function_call") {
|
|
4495
|
-
const toolCallId = (
|
|
4496
|
-
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";
|
|
4497
4513
|
hasFunctionCall = true;
|
|
4498
4514
|
const state = {
|
|
4499
4515
|
kind: "function_call",
|
|
@@ -4510,28 +4526,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4510
4526
|
toolName
|
|
4511
4527
|
});
|
|
4512
4528
|
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
4513
|
-
const toolName = stepType === "mcp_server_tool_call" ? (
|
|
4514
|
-
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;
|
|
4515
4531
|
const state = {
|
|
4516
4532
|
kind: "builtin_tool_call",
|
|
4517
4533
|
id: blockId,
|
|
4518
4534
|
blockType: stepType,
|
|
4519
4535
|
toolCallId,
|
|
4520
4536
|
toolName,
|
|
4521
|
-
arguments: (
|
|
4537
|
+
arguments: (_d = step == null ? void 0 : step.arguments) != null ? _d : {},
|
|
4522
4538
|
callEmitted: false
|
|
4523
4539
|
};
|
|
4524
4540
|
openBlocks.set(index, state);
|
|
4525
4541
|
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
4526
|
-
const toolName = stepType === "mcp_server_tool_result" ? (
|
|
4527
|
-
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;
|
|
4528
4544
|
const state = {
|
|
4529
4545
|
kind: "builtin_tool_result",
|
|
4530
4546
|
id: blockId,
|
|
4531
4547
|
blockType: stepType,
|
|
4532
4548
|
callId,
|
|
4533
4549
|
toolName,
|
|
4534
|
-
result: (
|
|
4550
|
+
result: (_f = step == null ? void 0 : step.result) != null ? _f : null,
|
|
4535
4551
|
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
4536
4552
|
resultEmitted: false
|
|
4537
4553
|
};
|
|
@@ -4545,7 +4561,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4545
4561
|
const event = value;
|
|
4546
4562
|
let open = openBlocks.get(event.index);
|
|
4547
4563
|
if (open == null) break;
|
|
4548
|
-
const dtype = (
|
|
4564
|
+
const dtype = (_g = event.delta) == null ? void 0 : _g.type;
|
|
4549
4565
|
if (open.kind === "pending_model_output") {
|
|
4550
4566
|
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
4551
4567
|
const promoted = {
|
|
@@ -4566,14 +4582,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4566
4582
|
if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
|
|
4567
4583
|
controller.enqueue({
|
|
4568
4584
|
type: "file",
|
|
4569
|
-
mediaType: (
|
|
4585
|
+
mediaType: (_h = imageDelta.mime_type) != null ? _h : "image/png",
|
|
4570
4586
|
data: { type: "data", data: imageDelta.data },
|
|
4571
4587
|
...providerMetadata ? { providerMetadata } : {}
|
|
4572
4588
|
});
|
|
4573
4589
|
} else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
|
|
4574
4590
|
controller.enqueue({
|
|
4575
4591
|
type: "file",
|
|
4576
|
-
mediaType: (
|
|
4592
|
+
mediaType: (_i = imageDelta.mime_type) != null ? _i : "image/png",
|
|
4577
4593
|
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
4578
4594
|
...providerMetadata ? { providerMetadata } : {}
|
|
4579
4595
|
});
|
|
@@ -4592,14 +4608,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4592
4608
|
if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
|
|
4593
4609
|
controller.enqueue({
|
|
4594
4610
|
type: "file",
|
|
4595
|
-
mediaType: (
|
|
4611
|
+
mediaType: (_j = videoDelta.mime_type) != null ? _j : "video/mp4",
|
|
4596
4612
|
data: { type: "data", data: videoDelta.data },
|
|
4597
4613
|
...providerMetadata ? { providerMetadata } : {}
|
|
4598
4614
|
});
|
|
4599
4615
|
} else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
|
|
4600
4616
|
controller.enqueue({
|
|
4601
4617
|
type: "file",
|
|
4602
|
-
mediaType: (
|
|
4618
|
+
mediaType: (_k = videoDelta.mime_type) != null ? _k : "video/mp4",
|
|
4603
4619
|
data: { type: "url", url: new URL(videoDelta.uri) },
|
|
4604
4620
|
...providerMetadata ? { providerMetadata } : {}
|
|
4605
4621
|
});
|
|
@@ -4608,7 +4624,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4608
4624
|
}
|
|
4609
4625
|
const delta = event.delta;
|
|
4610
4626
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
4611
|
-
const text = (
|
|
4627
|
+
const text = (_l = delta.text) != null ? _l : "";
|
|
4612
4628
|
if (text.length > 0) {
|
|
4613
4629
|
controller.enqueue({
|
|
4614
4630
|
type: "text-delta",
|
|
@@ -4658,7 +4674,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4658
4674
|
delta: slice
|
|
4659
4675
|
});
|
|
4660
4676
|
}
|
|
4661
|
-
if (delta.id != null) {
|
|
4677
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
4662
4678
|
open.toolCallId = delta.id;
|
|
4663
4679
|
}
|
|
4664
4680
|
if (delta.signature != null) {
|
|
@@ -4666,7 +4682,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4666
4682
|
}
|
|
4667
4683
|
hasFunctionCall = true;
|
|
4668
4684
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
4669
|
-
if (delta.id != null
|
|
4685
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
4686
|
+
open.toolCallId = delta.id;
|
|
4687
|
+
}
|
|
4670
4688
|
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
4671
4689
|
open.arguments = delta.arguments;
|
|
4672
4690
|
}
|
|
@@ -4674,7 +4692,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4674
4692
|
open.toolName = delta.name;
|
|
4675
4693
|
}
|
|
4676
4694
|
} else if (open.kind === "builtin_tool_result" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
4677
|
-
if (delta.call_id != null
|
|
4695
|
+
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
4696
|
+
open.callId = delta.call_id;
|
|
4697
|
+
}
|
|
4678
4698
|
if (delta.result !== void 0) open.result = delta.result;
|
|
4679
4699
|
if (delta.is_error != null) open.isError = delta.is_error;
|
|
4680
4700
|
if (delta.name != null && open.blockType === "mcp_server_tool_result") {
|
|
@@ -4711,14 +4731,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4711
4731
|
if (open.data != null && open.data.length > 0) {
|
|
4712
4732
|
controller.enqueue({
|
|
4713
4733
|
type: "file",
|
|
4714
|
-
mediaType: (
|
|
4734
|
+
mediaType: (_m = open.mimeType) != null ? _m : "image/png",
|
|
4715
4735
|
data: { type: "data", data: open.data },
|
|
4716
4736
|
...providerMetadata ? { providerMetadata } : {}
|
|
4717
4737
|
});
|
|
4718
4738
|
} else if (open.uri != null && open.uri.length > 0) {
|
|
4719
4739
|
controller.enqueue({
|
|
4720
4740
|
type: "file",
|
|
4721
|
-
mediaType: (
|
|
4741
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
4722
4742
|
data: { type: "url", url: new URL(open.uri) },
|
|
4723
4743
|
...providerMetadata ? { providerMetadata } : {}
|
|
4724
4744
|
});
|
|
@@ -4745,7 +4765,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4745
4765
|
type: "tool-call",
|
|
4746
4766
|
toolCallId: open.toolCallId,
|
|
4747
4767
|
toolName: open.toolName,
|
|
4748
|
-
input: JSON.stringify((
|
|
4768
|
+
input: JSON.stringify((_o = open.arguments) != null ? _o : {}),
|
|
4749
4769
|
providerExecuted: true
|
|
4750
4770
|
});
|
|
4751
4771
|
open.callEmitted = true;
|
|
@@ -4754,7 +4774,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4754
4774
|
type: "tool-result",
|
|
4755
4775
|
toolCallId: open.callId,
|
|
4756
4776
|
toolName: open.toolName,
|
|
4757
|
-
result: (
|
|
4777
|
+
result: (_p = open.result) != null ? _p : null
|
|
4758
4778
|
});
|
|
4759
4779
|
open.resultEmitted = true;
|
|
4760
4780
|
const sources = builtinToolResultToSources({
|
|
@@ -4808,7 +4828,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4808
4828
|
case "error": {
|
|
4809
4829
|
const event = value;
|
|
4810
4830
|
finishStatus = "failed";
|
|
4811
|
-
const errorPayload = (
|
|
4831
|
+
const errorPayload = (_q = event.error) != null ? _q : {
|
|
4812
4832
|
message: "Unknown interaction error"
|
|
4813
4833
|
};
|
|
4814
4834
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -5796,7 +5816,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5796
5816
|
generateId: generateId3,
|
|
5797
5817
|
interactionId
|
|
5798
5818
|
}) {
|
|
5799
|
-
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;
|
|
5800
5820
|
const content = [];
|
|
5801
5821
|
let hasFunctionCall = false;
|
|
5802
5822
|
if (steps == null) {
|
|
@@ -5903,19 +5923,19 @@ function parseGoogleInteractionsOutputs({
|
|
|
5903
5923
|
const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
|
|
5904
5924
|
content.push({
|
|
5905
5925
|
type: "tool-call",
|
|
5906
|
-
toolCallId:
|
|
5926
|
+
toolCallId: call.id || generateId3(),
|
|
5907
5927
|
toolName,
|
|
5908
5928
|
input,
|
|
5909
5929
|
providerExecuted: true
|
|
5910
5930
|
});
|
|
5911
5931
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
5912
5932
|
const result = step;
|
|
5913
|
-
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);
|
|
5914
5934
|
content.push({
|
|
5915
5935
|
type: "tool-result",
|
|
5916
|
-
toolCallId:
|
|
5936
|
+
toolCallId: result.call_id || generateId3(),
|
|
5917
5937
|
toolName,
|
|
5918
|
-
result: (
|
|
5938
|
+
result: (_k = result.result) != null ? _k : null
|
|
5919
5939
|
});
|
|
5920
5940
|
const sources = builtinToolResultToSources({
|
|
5921
5941
|
block: step,
|