@ai-sdk/google 4.0.45 → 4.0.47
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/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 +2 -2
- 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/dist/internal/index.js
CHANGED
|
@@ -1652,7 +1652,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1652
1652
|
};
|
|
1653
1653
|
}
|
|
1654
1654
|
async doGenerate(options) {
|
|
1655
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
1655
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1656
1656
|
const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
|
|
1657
1657
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1658
1658
|
providerOptionsNames.map((name) => [name, payload])
|
|
@@ -1724,9 +1724,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1724
1724
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1725
1725
|
content.push({
|
|
1726
1726
|
type: "tool-call",
|
|
1727
|
-
toolCallId:
|
|
1727
|
+
toolCallId: part.functionCall.id || this.config.generateId(),
|
|
1728
1728
|
toolName: part.functionCall.name,
|
|
1729
|
-
input: JSON.stringify((
|
|
1729
|
+
input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
|
|
1730
1730
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1731
1731
|
thoughtSignature: part.thoughtSignature
|
|
1732
1732
|
}) : void 0
|
|
@@ -1743,13 +1743,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1743
1743
|
}) : void 0
|
|
1744
1744
|
});
|
|
1745
1745
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1746
|
-
const toolCallId =
|
|
1746
|
+
const toolCallId = part.toolCall.id || this.config.generateId();
|
|
1747
1747
|
lastServerToolCallId = toolCallId;
|
|
1748
1748
|
content.push({
|
|
1749
1749
|
type: "tool-call",
|
|
1750
1750
|
toolCallId,
|
|
1751
1751
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1752
|
-
input: JSON.stringify((
|
|
1752
|
+
input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
|
|
1753
1753
|
providerExecuted: true,
|
|
1754
1754
|
dynamic: true,
|
|
1755
1755
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -1762,12 +1762,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1762
1762
|
})
|
|
1763
1763
|
});
|
|
1764
1764
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1765
|
-
const responseToolCallId =
|
|
1765
|
+
const responseToolCallId = lastServerToolCallId || part.toolResponse.id || this.config.generateId();
|
|
1766
1766
|
content.push({
|
|
1767
1767
|
type: "tool-result",
|
|
1768
1768
|
toolCallId: responseToolCallId,
|
|
1769
1769
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1770
|
-
result: (
|
|
1770
|
+
result: (_g = part.toolResponse.response) != null ? _g : {},
|
|
1771
1771
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1772
1772
|
thoughtSignature: part.thoughtSignature,
|
|
1773
1773
|
serverToolCallId: responseToolCallId,
|
|
@@ -1780,10 +1780,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1780
1780
|
lastServerToolCallId = void 0;
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
|
-
const sources = (
|
|
1783
|
+
const sources = (_h = extractSources({
|
|
1784
1784
|
groundingMetadata: candidate.groundingMetadata,
|
|
1785
1785
|
generateId: this.config.generateId
|
|
1786
|
-
})) != null ?
|
|
1786
|
+
})) != null ? _h : [];
|
|
1787
1787
|
for (const source of sources) {
|
|
1788
1788
|
content.push(source);
|
|
1789
1789
|
}
|
|
@@ -1797,23 +1797,23 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1797
1797
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1798
1798
|
)
|
|
1799
1799
|
}),
|
|
1800
|
-
raw: (
|
|
1800
|
+
raw: (_i = candidate.finishReason) != null ? _i : void 0
|
|
1801
1801
|
},
|
|
1802
1802
|
usage: convertGoogleUsage(usageMetadata),
|
|
1803
1803
|
warnings,
|
|
1804
1804
|
providerMetadata: wrapProviderMetadata({
|
|
1805
|
-
promptFeedback: (
|
|
1806
|
-
groundingMetadata: (
|
|
1807
|
-
urlContextMetadata: (
|
|
1808
|
-
safetyRatings: (
|
|
1805
|
+
promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
|
|
1806
|
+
groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
|
|
1807
|
+
urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
|
|
1808
|
+
safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
|
|
1809
1809
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1810
|
-
finishMessage: (
|
|
1811
|
-
serviceTier: (
|
|
1810
|
+
finishMessage: (_n = candidate.finishMessage) != null ? _n : null,
|
|
1811
|
+
serviceTier: (_o = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _o : null
|
|
1812
1812
|
}),
|
|
1813
1813
|
request: { body: args },
|
|
1814
1814
|
response: {
|
|
1815
1815
|
// TODO timestamp, model id
|
|
1816
|
-
id: (
|
|
1816
|
+
id: (_p = response.responseId) != null ? _p : void 0,
|
|
1817
1817
|
headers: responseHeaders,
|
|
1818
1818
|
body: rawResponse
|
|
1819
1819
|
}
|
|
@@ -1893,7 +1893,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1893
1893
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1894
1894
|
},
|
|
1895
1895
|
transform(chunk, controller) {
|
|
1896
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
1896
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1897
1897
|
if (options.includeRawChunks) {
|
|
1898
1898
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1899
1899
|
}
|
|
@@ -2047,7 +2047,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2047
2047
|
providerMetadata: fileMeta
|
|
2048
2048
|
});
|
|
2049
2049
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2050
|
-
const toolCallId =
|
|
2050
|
+
const toolCallId = part.toolCall.id || generateId2();
|
|
2051
2051
|
lastServerToolCallId = toolCallId;
|
|
2052
2052
|
const serverMeta = wrapProviderMetadata({
|
|
2053
2053
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
@@ -2058,13 +2058,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2058
2058
|
type: "tool-call",
|
|
2059
2059
|
toolCallId,
|
|
2060
2060
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2061
|
-
input: JSON.stringify((
|
|
2061
|
+
input: JSON.stringify((_e = part.toolCall.args) != null ? _e : {}),
|
|
2062
2062
|
providerExecuted: true,
|
|
2063
2063
|
dynamic: true,
|
|
2064
2064
|
providerMetadata: serverMeta
|
|
2065
2065
|
});
|
|
2066
2066
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2067
|
-
const responseToolCallId =
|
|
2067
|
+
const responseToolCallId = lastServerToolCallId || part.toolResponse.id || generateId2();
|
|
2068
2068
|
const serverMeta = wrapProviderMetadata({
|
|
2069
2069
|
...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
|
|
2070
2070
|
serverToolCallId: responseToolCallId,
|
|
@@ -2074,7 +2074,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2074
2074
|
type: "tool-result",
|
|
2075
2075
|
toolCallId: responseToolCallId,
|
|
2076
2076
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2077
|
-
result: (
|
|
2077
|
+
result: (_f = part.toolResponse.response) != null ? _f : {},
|
|
2078
2078
|
providerMetadata: serverMeta
|
|
2079
2079
|
});
|
|
2080
2080
|
lastServerToolCallId = void 0;
|
|
@@ -2091,7 +2091,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2091
2091
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
2092
2092
|
if (isStreamingChunk) {
|
|
2093
2093
|
if (part.functionCall.name != null) {
|
|
2094
|
-
const toolCallId =
|
|
2094
|
+
const toolCallId = part.functionCall.id || generateId2();
|
|
2095
2095
|
const accumulator = new GoogleJSONAccumulator();
|
|
2096
2096
|
activeStreamingToolCalls.push({
|
|
2097
2097
|
toolCallId,
|
|
@@ -2139,9 +2139,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2139
2139
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
2140
2140
|
finishActiveStreamingToolCall(controller);
|
|
2141
2141
|
} else if (isCompleteCall) {
|
|
2142
|
-
const toolCallId =
|
|
2142
|
+
const toolCallId = part.functionCall.id || generateId2();
|
|
2143
2143
|
const toolName = part.functionCall.name;
|
|
2144
|
-
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((
|
|
2144
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_g = part.functionCall.args) != null ? _g : {});
|
|
2145
2145
|
controller.enqueue({
|
|
2146
2146
|
type: "tool-input-start",
|
|
2147
2147
|
id: toolCallId,
|
|
@@ -2168,7 +2168,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2168
2168
|
});
|
|
2169
2169
|
hasToolCalls = true;
|
|
2170
2170
|
} else if (isNoArgsCompleteCall) {
|
|
2171
|
-
const toolCallId =
|
|
2171
|
+
const toolCallId = part.functionCall.id || generateId2();
|
|
2172
2172
|
const toolName = part.functionCall.name;
|
|
2173
2173
|
controller.enqueue({
|
|
2174
2174
|
type: "tool-input-start",
|
|
@@ -2201,13 +2201,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2201
2201
|
raw: candidate.finishReason
|
|
2202
2202
|
};
|
|
2203
2203
|
providerMetadata = wrapProviderMetadata({
|
|
2204
|
-
promptFeedback: (
|
|
2204
|
+
promptFeedback: (_h = value.promptFeedback) != null ? _h : null,
|
|
2205
2205
|
groundingMetadata: lastGroundingMetadata,
|
|
2206
2206
|
urlContextMetadata: lastUrlContextMetadata,
|
|
2207
|
-
safetyRatings: (
|
|
2207
|
+
safetyRatings: (_i = candidate.safetyRatings) != null ? _i : null,
|
|
2208
2208
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2209
|
-
finishMessage: (
|
|
2210
|
-
serviceTier: (
|
|
2209
|
+
finishMessage: (_j = candidate.finishMessage) != null ? _j : null,
|
|
2210
|
+
serviceTier: (_k = usage == null ? void 0 : usage.serviceTier) != null ? _k : null
|
|
2211
2211
|
});
|
|
2212
2212
|
}
|
|
2213
2213
|
},
|
|
@@ -2266,7 +2266,7 @@ function resolveGemini3ThinkingConfig({
|
|
|
2266
2266
|
modelId,
|
|
2267
2267
|
warnings
|
|
2268
2268
|
}) {
|
|
2269
|
-
const minimumThinkingLevel =
|
|
2269
|
+
const minimumThinkingLevel = getMinimumThinkingLevelForGemini3Model(modelId);
|
|
2270
2270
|
if (reasoning === "none") {
|
|
2271
2271
|
return { thinkingLevel: minimumThinkingLevel };
|
|
2272
2272
|
}
|
|
@@ -2286,6 +2286,22 @@ function resolveGemini3ThinkingConfig({
|
|
|
2286
2286
|
}
|
|
2287
2287
|
return { thinkingLevel };
|
|
2288
2288
|
}
|
|
2289
|
+
function getMinimumThinkingLevelForGemini3Model(modelId) {
|
|
2290
|
+
var _a;
|
|
2291
|
+
const modelName = (_a = modelId.split("/").at(-1)) == null ? void 0 : _a.toLowerCase();
|
|
2292
|
+
if (modelName === "gemini-flash-latest") {
|
|
2293
|
+
return "low";
|
|
2294
|
+
}
|
|
2295
|
+
const versionMatch = /^gemini-(\d+)\.(\d+)-flash(?:$|-(?!lite(?:-|$)))/.exec(
|
|
2296
|
+
modelName != null ? modelName : ""
|
|
2297
|
+
);
|
|
2298
|
+
if (versionMatch == null) {
|
|
2299
|
+
return "minimal";
|
|
2300
|
+
}
|
|
2301
|
+
const majorVersion = Number(versionMatch[1]);
|
|
2302
|
+
const minorVersion = Number(versionMatch[2]);
|
|
2303
|
+
return majorVersion > 3 || majorVersion === 3 && minorVersion >= 7 ? "low" : "minimal";
|
|
2304
|
+
}
|
|
2289
2305
|
function resolveGemini25ThinkingConfig({
|
|
2290
2306
|
reasoning,
|
|
2291
2307
|
modelId,
|
|
@@ -3351,7 +3367,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3351
3367
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3352
3368
|
},
|
|
3353
3369
|
transform(chunk, controller) {
|
|
3354
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q
|
|
3370
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
3355
3371
|
if (includeRawChunks) {
|
|
3356
3372
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3357
3373
|
}
|
|
@@ -3442,8 +3458,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3442
3458
|
}
|
|
3443
3459
|
}
|
|
3444
3460
|
} else if (stepType === "function_call") {
|
|
3445
|
-
const toolCallId = (
|
|
3446
|
-
const toolName = (
|
|
3461
|
+
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
3462
|
+
const toolName = (_b = step == null ? void 0 : step.name) != null ? _b : "unknown";
|
|
3447
3463
|
hasFunctionCall = true;
|
|
3448
3464
|
const state = {
|
|
3449
3465
|
kind: "function_call",
|
|
@@ -3460,28 +3476,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3460
3476
|
toolName
|
|
3461
3477
|
});
|
|
3462
3478
|
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
3463
|
-
const toolName = stepType === "mcp_server_tool_call" ? (
|
|
3464
|
-
const toolCallId = (
|
|
3479
|
+
const toolName = stepType === "mcp_server_tool_call" ? (_c = step == null ? void 0 : step.name) != null ? _c : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
3480
|
+
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
3465
3481
|
const state = {
|
|
3466
3482
|
kind: "builtin_tool_call",
|
|
3467
3483
|
id: blockId,
|
|
3468
3484
|
blockType: stepType,
|
|
3469
3485
|
toolCallId,
|
|
3470
3486
|
toolName,
|
|
3471
|
-
arguments: (
|
|
3487
|
+
arguments: (_d = step == null ? void 0 : step.arguments) != null ? _d : {},
|
|
3472
3488
|
callEmitted: false
|
|
3473
3489
|
};
|
|
3474
3490
|
openBlocks.set(index, state);
|
|
3475
3491
|
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
3476
|
-
const toolName = stepType === "mcp_server_tool_result" ? (
|
|
3477
|
-
const callId = (
|
|
3492
|
+
const toolName = stepType === "mcp_server_tool_result" ? (_e = step == null ? void 0 : step.name) != null ? _e : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
3493
|
+
const callId = (step == null ? void 0 : step.call_id) || blockId;
|
|
3478
3494
|
const state = {
|
|
3479
3495
|
kind: "builtin_tool_result",
|
|
3480
3496
|
id: blockId,
|
|
3481
3497
|
blockType: stepType,
|
|
3482
3498
|
callId,
|
|
3483
3499
|
toolName,
|
|
3484
|
-
result: (
|
|
3500
|
+
result: (_f = step == null ? void 0 : step.result) != null ? _f : null,
|
|
3485
3501
|
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
3486
3502
|
resultEmitted: false
|
|
3487
3503
|
};
|
|
@@ -3495,7 +3511,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3495
3511
|
const event = value;
|
|
3496
3512
|
let open = openBlocks.get(event.index);
|
|
3497
3513
|
if (open == null) break;
|
|
3498
|
-
const dtype = (
|
|
3514
|
+
const dtype = (_g = event.delta) == null ? void 0 : _g.type;
|
|
3499
3515
|
if (open.kind === "pending_model_output") {
|
|
3500
3516
|
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
3501
3517
|
const promoted = {
|
|
@@ -3516,14 +3532,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3516
3532
|
if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
|
|
3517
3533
|
controller.enqueue({
|
|
3518
3534
|
type: "file",
|
|
3519
|
-
mediaType: (
|
|
3535
|
+
mediaType: (_h = imageDelta.mime_type) != null ? _h : "image/png",
|
|
3520
3536
|
data: { type: "data", data: imageDelta.data },
|
|
3521
3537
|
...providerMetadata ? { providerMetadata } : {}
|
|
3522
3538
|
});
|
|
3523
3539
|
} else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
|
|
3524
3540
|
controller.enqueue({
|
|
3525
3541
|
type: "file",
|
|
3526
|
-
mediaType: (
|
|
3542
|
+
mediaType: (_i = imageDelta.mime_type) != null ? _i : "image/png",
|
|
3527
3543
|
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
3528
3544
|
...providerMetadata ? { providerMetadata } : {}
|
|
3529
3545
|
});
|
|
@@ -3542,14 +3558,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3542
3558
|
if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
|
|
3543
3559
|
controller.enqueue({
|
|
3544
3560
|
type: "file",
|
|
3545
|
-
mediaType: (
|
|
3561
|
+
mediaType: (_j = videoDelta.mime_type) != null ? _j : "video/mp4",
|
|
3546
3562
|
data: { type: "data", data: videoDelta.data },
|
|
3547
3563
|
...providerMetadata ? { providerMetadata } : {}
|
|
3548
3564
|
});
|
|
3549
3565
|
} else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
|
|
3550
3566
|
controller.enqueue({
|
|
3551
3567
|
type: "file",
|
|
3552
|
-
mediaType: (
|
|
3568
|
+
mediaType: (_k = videoDelta.mime_type) != null ? _k : "video/mp4",
|
|
3553
3569
|
data: { type: "url", url: new URL(videoDelta.uri) },
|
|
3554
3570
|
...providerMetadata ? { providerMetadata } : {}
|
|
3555
3571
|
});
|
|
@@ -3558,7 +3574,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3558
3574
|
}
|
|
3559
3575
|
const delta = event.delta;
|
|
3560
3576
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3561
|
-
const text = (
|
|
3577
|
+
const text = (_l = delta.text) != null ? _l : "";
|
|
3562
3578
|
if (text.length > 0) {
|
|
3563
3579
|
controller.enqueue({
|
|
3564
3580
|
type: "text-delta",
|
|
@@ -3608,7 +3624,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3608
3624
|
delta: slice
|
|
3609
3625
|
});
|
|
3610
3626
|
}
|
|
3611
|
-
if (delta.id != null) {
|
|
3627
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
3612
3628
|
open.toolCallId = delta.id;
|
|
3613
3629
|
}
|
|
3614
3630
|
if (delta.signature != null) {
|
|
@@ -3616,7 +3632,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3616
3632
|
}
|
|
3617
3633
|
hasFunctionCall = true;
|
|
3618
3634
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3619
|
-
if (delta.id != null
|
|
3635
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
3636
|
+
open.toolCallId = delta.id;
|
|
3637
|
+
}
|
|
3620
3638
|
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
3621
3639
|
open.arguments = delta.arguments;
|
|
3622
3640
|
}
|
|
@@ -3624,7 +3642,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3624
3642
|
open.toolName = delta.name;
|
|
3625
3643
|
}
|
|
3626
3644
|
} else if (open.kind === "builtin_tool_result" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3627
|
-
if (delta.call_id != null
|
|
3645
|
+
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
3646
|
+
open.callId = delta.call_id;
|
|
3647
|
+
}
|
|
3628
3648
|
if (delta.result !== void 0) open.result = delta.result;
|
|
3629
3649
|
if (delta.is_error != null) open.isError = delta.is_error;
|
|
3630
3650
|
if (delta.name != null && open.blockType === "mcp_server_tool_result") {
|
|
@@ -3661,14 +3681,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3661
3681
|
if (open.data != null && open.data.length > 0) {
|
|
3662
3682
|
controller.enqueue({
|
|
3663
3683
|
type: "file",
|
|
3664
|
-
mediaType: (
|
|
3684
|
+
mediaType: (_m = open.mimeType) != null ? _m : "image/png",
|
|
3665
3685
|
data: { type: "data", data: open.data },
|
|
3666
3686
|
...providerMetadata ? { providerMetadata } : {}
|
|
3667
3687
|
});
|
|
3668
3688
|
} else if (open.uri != null && open.uri.length > 0) {
|
|
3669
3689
|
controller.enqueue({
|
|
3670
3690
|
type: "file",
|
|
3671
|
-
mediaType: (
|
|
3691
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
3672
3692
|
data: { type: "url", url: new URL(open.uri) },
|
|
3673
3693
|
...providerMetadata ? { providerMetadata } : {}
|
|
3674
3694
|
});
|
|
@@ -3695,7 +3715,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3695
3715
|
type: "tool-call",
|
|
3696
3716
|
toolCallId: open.toolCallId,
|
|
3697
3717
|
toolName: open.toolName,
|
|
3698
|
-
input: JSON.stringify((
|
|
3718
|
+
input: JSON.stringify((_o = open.arguments) != null ? _o : {}),
|
|
3699
3719
|
providerExecuted: true
|
|
3700
3720
|
});
|
|
3701
3721
|
open.callEmitted = true;
|
|
@@ -3704,7 +3724,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3704
3724
|
type: "tool-result",
|
|
3705
3725
|
toolCallId: open.callId,
|
|
3706
3726
|
toolName: open.toolName,
|
|
3707
|
-
result: (
|
|
3727
|
+
result: (_p = open.result) != null ? _p : null
|
|
3708
3728
|
});
|
|
3709
3729
|
open.resultEmitted = true;
|
|
3710
3730
|
const sources = builtinToolResultToSources({
|
|
@@ -3758,7 +3778,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3758
3778
|
case "error": {
|
|
3759
3779
|
const event = value;
|
|
3760
3780
|
finishStatus = "failed";
|
|
3761
|
-
const errorPayload = (
|
|
3781
|
+
const errorPayload = (_q = event.error) != null ? _q : {
|
|
3762
3782
|
message: "Unknown interaction error"
|
|
3763
3783
|
};
|
|
3764
3784
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -4746,7 +4766,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
4746
4766
|
generateId: generateId2,
|
|
4747
4767
|
interactionId
|
|
4748
4768
|
}) {
|
|
4749
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
4769
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4750
4770
|
const content = [];
|
|
4751
4771
|
let hasFunctionCall = false;
|
|
4752
4772
|
if (steps == null) {
|
|
@@ -4853,19 +4873,19 @@ function parseGoogleInteractionsOutputs({
|
|
|
4853
4873
|
const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
|
|
4854
4874
|
content.push({
|
|
4855
4875
|
type: "tool-call",
|
|
4856
|
-
toolCallId:
|
|
4876
|
+
toolCallId: call.id || generateId2(),
|
|
4857
4877
|
toolName,
|
|
4858
4878
|
input,
|
|
4859
4879
|
providerExecuted: true
|
|
4860
4880
|
});
|
|
4861
4881
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
4862
4882
|
const result = step;
|
|
4863
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
4883
|
+
const toolName = type === "mcp_server_tool_result" ? (_j = result.name) != null ? _j : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
4864
4884
|
content.push({
|
|
4865
4885
|
type: "tool-result",
|
|
4866
|
-
toolCallId:
|
|
4886
|
+
toolCallId: result.call_id || generateId2(),
|
|
4867
4887
|
toolName,
|
|
4868
|
-
result: (
|
|
4888
|
+
result: (_k = result.result) != null ? _k : null
|
|
4869
4889
|
});
|
|
4870
4890
|
const sources = builtinToolResultToSources({
|
|
4871
4891
|
block: step,
|