@ai-sdk/google 4.0.46 → 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 +8 -0
- package/dist/index.js +63 -59
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +62 -58
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/google-language-model.ts +10 -10
- 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
|
},
|
|
@@ -3367,7 +3367,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3367
3367
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3368
3368
|
},
|
|
3369
3369
|
transform(chunk, controller) {
|
|
3370
|
-
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;
|
|
3371
3371
|
if (includeRawChunks) {
|
|
3372
3372
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3373
3373
|
}
|
|
@@ -3458,8 +3458,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3458
3458
|
}
|
|
3459
3459
|
}
|
|
3460
3460
|
} else if (stepType === "function_call") {
|
|
3461
|
-
const toolCallId = (
|
|
3462
|
-
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";
|
|
3463
3463
|
hasFunctionCall = true;
|
|
3464
3464
|
const state = {
|
|
3465
3465
|
kind: "function_call",
|
|
@@ -3476,28 +3476,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3476
3476
|
toolName
|
|
3477
3477
|
});
|
|
3478
3478
|
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
3479
|
-
const toolName = stepType === "mcp_server_tool_call" ? (
|
|
3480
|
-
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;
|
|
3481
3481
|
const state = {
|
|
3482
3482
|
kind: "builtin_tool_call",
|
|
3483
3483
|
id: blockId,
|
|
3484
3484
|
blockType: stepType,
|
|
3485
3485
|
toolCallId,
|
|
3486
3486
|
toolName,
|
|
3487
|
-
arguments: (
|
|
3487
|
+
arguments: (_d = step == null ? void 0 : step.arguments) != null ? _d : {},
|
|
3488
3488
|
callEmitted: false
|
|
3489
3489
|
};
|
|
3490
3490
|
openBlocks.set(index, state);
|
|
3491
3491
|
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
3492
|
-
const toolName = stepType === "mcp_server_tool_result" ? (
|
|
3493
|
-
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;
|
|
3494
3494
|
const state = {
|
|
3495
3495
|
kind: "builtin_tool_result",
|
|
3496
3496
|
id: blockId,
|
|
3497
3497
|
blockType: stepType,
|
|
3498
3498
|
callId,
|
|
3499
3499
|
toolName,
|
|
3500
|
-
result: (
|
|
3500
|
+
result: (_f = step == null ? void 0 : step.result) != null ? _f : null,
|
|
3501
3501
|
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
3502
3502
|
resultEmitted: false
|
|
3503
3503
|
};
|
|
@@ -3511,7 +3511,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3511
3511
|
const event = value;
|
|
3512
3512
|
let open = openBlocks.get(event.index);
|
|
3513
3513
|
if (open == null) break;
|
|
3514
|
-
const dtype = (
|
|
3514
|
+
const dtype = (_g = event.delta) == null ? void 0 : _g.type;
|
|
3515
3515
|
if (open.kind === "pending_model_output") {
|
|
3516
3516
|
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
3517
3517
|
const promoted = {
|
|
@@ -3532,14 +3532,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3532
3532
|
if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
|
|
3533
3533
|
controller.enqueue({
|
|
3534
3534
|
type: "file",
|
|
3535
|
-
mediaType: (
|
|
3535
|
+
mediaType: (_h = imageDelta.mime_type) != null ? _h : "image/png",
|
|
3536
3536
|
data: { type: "data", data: imageDelta.data },
|
|
3537
3537
|
...providerMetadata ? { providerMetadata } : {}
|
|
3538
3538
|
});
|
|
3539
3539
|
} else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
|
|
3540
3540
|
controller.enqueue({
|
|
3541
3541
|
type: "file",
|
|
3542
|
-
mediaType: (
|
|
3542
|
+
mediaType: (_i = imageDelta.mime_type) != null ? _i : "image/png",
|
|
3543
3543
|
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
3544
3544
|
...providerMetadata ? { providerMetadata } : {}
|
|
3545
3545
|
});
|
|
@@ -3558,14 +3558,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3558
3558
|
if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
|
|
3559
3559
|
controller.enqueue({
|
|
3560
3560
|
type: "file",
|
|
3561
|
-
mediaType: (
|
|
3561
|
+
mediaType: (_j = videoDelta.mime_type) != null ? _j : "video/mp4",
|
|
3562
3562
|
data: { type: "data", data: videoDelta.data },
|
|
3563
3563
|
...providerMetadata ? { providerMetadata } : {}
|
|
3564
3564
|
});
|
|
3565
3565
|
} else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
|
|
3566
3566
|
controller.enqueue({
|
|
3567
3567
|
type: "file",
|
|
3568
|
-
mediaType: (
|
|
3568
|
+
mediaType: (_k = videoDelta.mime_type) != null ? _k : "video/mp4",
|
|
3569
3569
|
data: { type: "url", url: new URL(videoDelta.uri) },
|
|
3570
3570
|
...providerMetadata ? { providerMetadata } : {}
|
|
3571
3571
|
});
|
|
@@ -3574,7 +3574,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3574
3574
|
}
|
|
3575
3575
|
const delta = event.delta;
|
|
3576
3576
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3577
|
-
const text = (
|
|
3577
|
+
const text = (_l = delta.text) != null ? _l : "";
|
|
3578
3578
|
if (text.length > 0) {
|
|
3579
3579
|
controller.enqueue({
|
|
3580
3580
|
type: "text-delta",
|
|
@@ -3624,7 +3624,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3624
3624
|
delta: slice
|
|
3625
3625
|
});
|
|
3626
3626
|
}
|
|
3627
|
-
if (delta.id != null) {
|
|
3627
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
3628
3628
|
open.toolCallId = delta.id;
|
|
3629
3629
|
}
|
|
3630
3630
|
if (delta.signature != null) {
|
|
@@ -3632,7 +3632,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3632
3632
|
}
|
|
3633
3633
|
hasFunctionCall = true;
|
|
3634
3634
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3635
|
-
if (delta.id != null
|
|
3635
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
3636
|
+
open.toolCallId = delta.id;
|
|
3637
|
+
}
|
|
3636
3638
|
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
3637
3639
|
open.arguments = delta.arguments;
|
|
3638
3640
|
}
|
|
@@ -3640,7 +3642,9 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3640
3642
|
open.toolName = delta.name;
|
|
3641
3643
|
}
|
|
3642
3644
|
} else if (open.kind === "builtin_tool_result" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3643
|
-
if (delta.call_id != null
|
|
3645
|
+
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
3646
|
+
open.callId = delta.call_id;
|
|
3647
|
+
}
|
|
3644
3648
|
if (delta.result !== void 0) open.result = delta.result;
|
|
3645
3649
|
if (delta.is_error != null) open.isError = delta.is_error;
|
|
3646
3650
|
if (delta.name != null && open.blockType === "mcp_server_tool_result") {
|
|
@@ -3677,14 +3681,14 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3677
3681
|
if (open.data != null && open.data.length > 0) {
|
|
3678
3682
|
controller.enqueue({
|
|
3679
3683
|
type: "file",
|
|
3680
|
-
mediaType: (
|
|
3684
|
+
mediaType: (_m = open.mimeType) != null ? _m : "image/png",
|
|
3681
3685
|
data: { type: "data", data: open.data },
|
|
3682
3686
|
...providerMetadata ? { providerMetadata } : {}
|
|
3683
3687
|
});
|
|
3684
3688
|
} else if (open.uri != null && open.uri.length > 0) {
|
|
3685
3689
|
controller.enqueue({
|
|
3686
3690
|
type: "file",
|
|
3687
|
-
mediaType: (
|
|
3691
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
3688
3692
|
data: { type: "url", url: new URL(open.uri) },
|
|
3689
3693
|
...providerMetadata ? { providerMetadata } : {}
|
|
3690
3694
|
});
|
|
@@ -3711,7 +3715,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3711
3715
|
type: "tool-call",
|
|
3712
3716
|
toolCallId: open.toolCallId,
|
|
3713
3717
|
toolName: open.toolName,
|
|
3714
|
-
input: JSON.stringify((
|
|
3718
|
+
input: JSON.stringify((_o = open.arguments) != null ? _o : {}),
|
|
3715
3719
|
providerExecuted: true
|
|
3716
3720
|
});
|
|
3717
3721
|
open.callEmitted = true;
|
|
@@ -3720,7 +3724,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3720
3724
|
type: "tool-result",
|
|
3721
3725
|
toolCallId: open.callId,
|
|
3722
3726
|
toolName: open.toolName,
|
|
3723
|
-
result: (
|
|
3727
|
+
result: (_p = open.result) != null ? _p : null
|
|
3724
3728
|
});
|
|
3725
3729
|
open.resultEmitted = true;
|
|
3726
3730
|
const sources = builtinToolResultToSources({
|
|
@@ -3774,7 +3778,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3774
3778
|
case "error": {
|
|
3775
3779
|
const event = value;
|
|
3776
3780
|
finishStatus = "failed";
|
|
3777
|
-
const errorPayload = (
|
|
3781
|
+
const errorPayload = (_q = event.error) != null ? _q : {
|
|
3778
3782
|
message: "Unknown interaction error"
|
|
3779
3783
|
};
|
|
3780
3784
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -4762,7 +4766,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
4762
4766
|
generateId: generateId2,
|
|
4763
4767
|
interactionId
|
|
4764
4768
|
}) {
|
|
4765
|
-
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;
|
|
4766
4770
|
const content = [];
|
|
4767
4771
|
let hasFunctionCall = false;
|
|
4768
4772
|
if (steps == null) {
|
|
@@ -4869,19 +4873,19 @@ function parseGoogleInteractionsOutputs({
|
|
|
4869
4873
|
const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
|
|
4870
4874
|
content.push({
|
|
4871
4875
|
type: "tool-call",
|
|
4872
|
-
toolCallId:
|
|
4876
|
+
toolCallId: call.id || generateId2(),
|
|
4873
4877
|
toolName,
|
|
4874
4878
|
input,
|
|
4875
4879
|
providerExecuted: true
|
|
4876
4880
|
});
|
|
4877
4881
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
4878
4882
|
const result = step;
|
|
4879
|
-
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);
|
|
4880
4884
|
content.push({
|
|
4881
4885
|
type: "tool-result",
|
|
4882
|
-
toolCallId:
|
|
4886
|
+
toolCallId: result.call_id || generateId2(),
|
|
4883
4887
|
toolName,
|
|
4884
|
-
result: (
|
|
4888
|
+
result: (_k = result.result) != null ? _k : null
|
|
4885
4889
|
});
|
|
4886
4890
|
const sources = builtinToolResultToSources({
|
|
4887
4891
|
block: step,
|