@ai-sdk/google 3.0.59 → 3.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "3.0.59" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.61" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -825,6 +825,16 @@ var googleLanguageModelOptions = lazySchema4(
825
825
  longitude: z4.number()
826
826
  }).optional()
827
827
  }).optional(),
828
+ /**
829
+ * Optional. When set to true, function call arguments will be streamed
830
+ * incrementally via partialArgs in streaming responses. Only supported
831
+ * on the Vertex AI API (not the Gemini API).
832
+ *
833
+ * @default true
834
+ *
835
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
836
+ */
837
+ streamFunctionCallArguments: z4.boolean().optional(),
828
838
  /**
829
839
  * Optional. The service tier to use for the request.
830
840
  */
@@ -1085,6 +1095,229 @@ function prepareTools({
1085
1095
  }
1086
1096
  }
1087
1097
 
1098
+ // src/google-json-accumulator.ts
1099
+ var GoogleJSONAccumulator = class {
1100
+ constructor() {
1101
+ this.accumulatedArgs = {};
1102
+ this.jsonText = "";
1103
+ /**
1104
+ * Stack representing the currently "open" containers in the JSON output.
1105
+ * Entry 0 is always the root `{` object once the first value is written.
1106
+ */
1107
+ this.pathStack = [];
1108
+ /**
1109
+ * Whether a string value is currently "open" (willContinue was true),
1110
+ * meaning the closing quote has not yet been emitted.
1111
+ */
1112
+ this.stringOpen = false;
1113
+ }
1114
+ /**
1115
+ * Input: [{jsonPath:"$.brightness",numberValue:50}]
1116
+ * Output: { currentJSON:{brightness:50}, textDelta:'{"brightness":50' }
1117
+ */
1118
+ processPartialArgs(partialArgs) {
1119
+ let delta = "";
1120
+ for (const arg of partialArgs) {
1121
+ const rawPath = arg.jsonPath.replace(/^\$\./, "");
1122
+ if (!rawPath) continue;
1123
+ const segments = parsePath(rawPath);
1124
+ const existingValue = getNestedValue(this.accumulatedArgs, segments);
1125
+ const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
1126
+ if (isStringContinuation) {
1127
+ const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
1128
+ setNestedValue(
1129
+ this.accumulatedArgs,
1130
+ segments,
1131
+ existingValue + arg.stringValue
1132
+ );
1133
+ delta += escaped;
1134
+ continue;
1135
+ }
1136
+ const resolved = resolvePartialArgValue(arg);
1137
+ if (resolved == null) continue;
1138
+ setNestedValue(this.accumulatedArgs, segments, resolved.value);
1139
+ delta += this.emitNavigationTo(segments, arg, resolved.json);
1140
+ }
1141
+ this.jsonText += delta;
1142
+ return {
1143
+ currentJSON: this.accumulatedArgs,
1144
+ textDelta: delta
1145
+ };
1146
+ }
1147
+ /**
1148
+ * Input: jsonText='{"brightness":50', accumulatedArgs={brightness:50}
1149
+ * Output: { finalJSON:'{"brightness":50}', closingDelta:'}' }
1150
+ */
1151
+ finalize() {
1152
+ const finalArgs = JSON.stringify(this.accumulatedArgs);
1153
+ const closingDelta = finalArgs.slice(this.jsonText.length);
1154
+ return { finalJSON: finalArgs, closingDelta };
1155
+ }
1156
+ /**
1157
+ * Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
1158
+ * Output: '{' (first call) or '' (subsequent calls)
1159
+ */
1160
+ ensureRoot() {
1161
+ if (this.pathStack.length === 0) {
1162
+ this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
1163
+ return "{";
1164
+ }
1165
+ return "";
1166
+ }
1167
+ /**
1168
+ * Emits the JSON text fragment needed to navigate from the current open
1169
+ * path to the new leaf at `targetSegments`, then writes the value.
1170
+ *
1171
+ * Input: targetSegments=["recipe","name"], arg={jsonPath:"$.recipe.name",stringValue:"Lasagna"}, valueJson='"Lasagna"'
1172
+ * Output: '{"recipe":{"name":"Lasagna"'
1173
+ */
1174
+ emitNavigationTo(targetSegments, arg, valueJson) {
1175
+ let fragment = "";
1176
+ if (this.stringOpen) {
1177
+ fragment += '"';
1178
+ this.stringOpen = false;
1179
+ }
1180
+ fragment += this.ensureRoot();
1181
+ const targetContainerSegments = targetSegments.slice(0, -1);
1182
+ const leafSegment = targetSegments[targetSegments.length - 1];
1183
+ const commonDepth = this.findCommonStackDepth(targetContainerSegments);
1184
+ fragment += this.closeDownTo(commonDepth);
1185
+ fragment += this.openDownTo(targetContainerSegments, leafSegment);
1186
+ fragment += this.emitLeaf(leafSegment, arg, valueJson);
1187
+ return fragment;
1188
+ }
1189
+ /**
1190
+ * Returns the stack depth to preserve when navigating to a new target
1191
+ * container path. Always >= 1 (the root is never popped).
1192
+ *
1193
+ * Input: stack=[root,"recipe","ingredients",0], target=["recipe","ingredients",1]
1194
+ * Output: 3 (keep root+"recipe"+"ingredients")
1195
+ */
1196
+ findCommonStackDepth(targetContainer) {
1197
+ const maxDepth = Math.min(
1198
+ this.pathStack.length - 1,
1199
+ targetContainer.length
1200
+ );
1201
+ let common = 0;
1202
+ for (let i = 0; i < maxDepth; i++) {
1203
+ if (this.pathStack[i + 1].segment === targetContainer[i]) {
1204
+ common++;
1205
+ } else {
1206
+ break;
1207
+ }
1208
+ }
1209
+ return common + 1;
1210
+ }
1211
+ /**
1212
+ * Closes containers from the current stack depth back down to `targetDepth`.
1213
+ *
1214
+ * Input: this.pathStack=[root,"recipe","ingredients",0], targetDepth=3
1215
+ * Output: '}'
1216
+ */
1217
+ closeDownTo(targetDepth) {
1218
+ let fragment = "";
1219
+ while (this.pathStack.length > targetDepth) {
1220
+ const entry = this.pathStack.pop();
1221
+ fragment += entry.isArray ? "]" : "}";
1222
+ }
1223
+ return fragment;
1224
+ }
1225
+ /**
1226
+ * Opens containers from the current stack depth down to the full target
1227
+ * container path, emitting opening `{`, `[`, keys, and commas as needed.
1228
+ * `leafSegment` is used to determine if the innermost container is an array.
1229
+ *
1230
+ * Input: this.pathStack=[root], targetContainer=["recipe","ingredients"], leafSegment=0
1231
+ * Output: '"recipe":{"ingredients":['
1232
+ */
1233
+ openDownTo(targetContainer, leafSegment) {
1234
+ let fragment = "";
1235
+ const startIdx = this.pathStack.length - 1;
1236
+ for (let i = startIdx; i < targetContainer.length; i++) {
1237
+ const seg = targetContainer[i];
1238
+ const parentEntry = this.pathStack[this.pathStack.length - 1];
1239
+ if (parentEntry.childCount > 0) {
1240
+ fragment += ",";
1241
+ }
1242
+ parentEntry.childCount++;
1243
+ if (typeof seg === "string") {
1244
+ fragment += `${JSON.stringify(seg)}:`;
1245
+ }
1246
+ const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
1247
+ const isArray = typeof childSeg === "number";
1248
+ fragment += isArray ? "[" : "{";
1249
+ this.pathStack.push({ segment: seg, isArray, childCount: 0 });
1250
+ }
1251
+ return fragment;
1252
+ }
1253
+ /**
1254
+ * Emits the comma, key, and value for a leaf entry in the current container.
1255
+ *
1256
+ * Input: leafSegment="name", arg={stringValue:"Lasagna"}, valueJson='"Lasagna"'
1257
+ * Output: '"name":"Lasagna"' (or ',"name":"Lasagna"' if container.childCount > 0)
1258
+ */
1259
+ emitLeaf(leafSegment, arg, valueJson) {
1260
+ let fragment = "";
1261
+ const container = this.pathStack[this.pathStack.length - 1];
1262
+ if (container.childCount > 0) {
1263
+ fragment += ",";
1264
+ }
1265
+ container.childCount++;
1266
+ if (typeof leafSegment === "string") {
1267
+ fragment += `${JSON.stringify(leafSegment)}:`;
1268
+ }
1269
+ if (arg.stringValue != null && arg.willContinue) {
1270
+ fragment += valueJson.slice(0, -1);
1271
+ this.stringOpen = true;
1272
+ } else {
1273
+ fragment += valueJson;
1274
+ }
1275
+ return fragment;
1276
+ }
1277
+ };
1278
+ function parsePath(rawPath) {
1279
+ const segments = [];
1280
+ for (const part of rawPath.split(".")) {
1281
+ const bracketIdx = part.indexOf("[");
1282
+ if (bracketIdx === -1) {
1283
+ segments.push(part);
1284
+ } else {
1285
+ if (bracketIdx > 0) segments.push(part.slice(0, bracketIdx));
1286
+ for (const m of part.matchAll(/\[(\d+)\]/g)) {
1287
+ segments.push(parseInt(m[1], 10));
1288
+ }
1289
+ }
1290
+ }
1291
+ return segments;
1292
+ }
1293
+ function getNestedValue(obj, segments) {
1294
+ let current = obj;
1295
+ for (const seg of segments) {
1296
+ if (current == null || typeof current !== "object") return void 0;
1297
+ current = current[seg];
1298
+ }
1299
+ return current;
1300
+ }
1301
+ function setNestedValue(obj, segments, value) {
1302
+ let current = obj;
1303
+ for (let i = 0; i < segments.length - 1; i++) {
1304
+ const seg = segments[i];
1305
+ const nextSeg = segments[i + 1];
1306
+ if (current[seg] == null) {
1307
+ current[seg] = typeof nextSeg === "number" ? [] : {};
1308
+ }
1309
+ current = current[seg];
1310
+ }
1311
+ current[segments[segments.length - 1]] = value;
1312
+ }
1313
+ function resolvePartialArgValue(arg) {
1314
+ var _a, _b;
1315
+ const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
1316
+ if (value != null) return { value, json: JSON.stringify(value) };
1317
+ if ("nullValue" in arg) return { value: null, json: "null" };
1318
+ return void 0;
1319
+ }
1320
+
1088
1321
  // src/map-google-generative-ai-finish-reason.ts
1089
1322
  function mapGoogleGenerativeAIFinishReason({
1090
1323
  finishReason,
@@ -1142,7 +1375,7 @@ var GoogleGenerativeAILanguageModel = class {
1142
1375
  toolChoice,
1143
1376
  providerOptions
1144
1377
  }) {
1145
- var _a;
1378
+ var _a, _b;
1146
1379
  const warnings = [];
1147
1380
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1148
1381
  let googleOptions = await parseProviderOptions2({
@@ -1157,14 +1390,21 @@ var GoogleGenerativeAILanguageModel = class {
1157
1390
  schema: googleLanguageModelOptions
1158
1391
  });
1159
1392
  }
1393
+ const isVertexProvider = this.config.provider.startsWith("google.vertex.");
1160
1394
  if ((tools == null ? void 0 : tools.some(
1161
1395
  (tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
1162
- )) && !this.config.provider.startsWith("google.vertex.")) {
1396
+ )) && !isVertexProvider) {
1163
1397
  warnings.push({
1164
1398
  type: "other",
1165
1399
  message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
1166
1400
  });
1167
1401
  }
1402
+ if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
1403
+ warnings.push({
1404
+ type: "other",
1405
+ message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
1406
+ });
1407
+ }
1168
1408
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1169
1409
  const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
1170
1410
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
@@ -1184,6 +1424,19 @@ var GoogleGenerativeAILanguageModel = class {
1184
1424
  toolChoice,
1185
1425
  modelId: this.modelId
1186
1426
  });
1427
+ const streamFunctionCallArguments = isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : true : void 0;
1428
+ const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1429
+ ...googleToolConfig,
1430
+ ...streamFunctionCallArguments && {
1431
+ functionCallingConfig: {
1432
+ ...googleToolConfig == null ? void 0 : googleToolConfig.functionCallingConfig,
1433
+ streamFunctionCallArguments: true
1434
+ }
1435
+ },
1436
+ ...(googleOptions == null ? void 0 : googleOptions.retrievalConfig) && {
1437
+ retrievalConfig: googleOptions.retrievalConfig
1438
+ }
1439
+ } : void 0;
1187
1440
  return {
1188
1441
  args: {
1189
1442
  generationConfig: {
@@ -1201,7 +1454,7 @@ var GoogleGenerativeAILanguageModel = class {
1201
1454
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
1202
1455
  // so this is needed as an escape hatch:
1203
1456
  // TODO convert into provider option
1204
- ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1457
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1205
1458
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
1206
1459
  audioTimestamp: googleOptions.audioTimestamp
1207
1460
  },
@@ -1219,10 +1472,7 @@ var GoogleGenerativeAILanguageModel = class {
1219
1472
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1220
1473
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1221
1474
  tools: googleTools2,
1222
- toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1223
- ...googleToolConfig,
1224
- retrievalConfig: googleOptions.retrievalConfig
1225
- } : googleToolConfig,
1475
+ toolConfig,
1226
1476
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
1227
1477
  labels: googleOptions == null ? void 0 : googleOptions.labels,
1228
1478
  serviceTier: googleOptions == null ? void 0 : googleOptions.serviceTier
@@ -1300,7 +1550,7 @@ var GoogleGenerativeAILanguageModel = class {
1300
1550
  providerMetadata: thoughtSignatureMetadata
1301
1551
  });
1302
1552
  }
1303
- } else if ("functionCall" in part) {
1553
+ } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
1304
1554
  content.push({
1305
1555
  type: "tool-call",
1306
1556
  toolCallId: this.config.generateId(),
@@ -1446,6 +1696,7 @@ var GoogleGenerativeAILanguageModel = class {
1446
1696
  const emittedSourceUrls = /* @__PURE__ */ new Set();
1447
1697
  let lastCodeExecutionToolCallId;
1448
1698
  let lastServerToolCallId;
1699
+ const activeStreamingToolCalls = [];
1449
1700
  return {
1450
1701
  stream: response.pipeThrough(
1451
1702
  new TransformStream({
@@ -1453,7 +1704,7 @@ var GoogleGenerativeAILanguageModel = class {
1453
1704
  controller.enqueue({ type: "stream-start", warnings });
1454
1705
  },
1455
1706
  transform(chunk, controller) {
1456
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1707
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1457
1708
  if (options.includeRawChunks) {
1458
1709
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1459
1710
  }
@@ -1646,36 +1897,110 @@ var GoogleGenerativeAILanguageModel = class {
1646
1897
  lastServerToolCallId = void 0;
1647
1898
  }
1648
1899
  }
1649
- const toolCallDeltas = getToolCallsFromParts({
1650
- parts: content.parts,
1651
- generateId: generateId3,
1652
- providerOptionsName
1653
- });
1654
- if (toolCallDeltas != null) {
1655
- for (const toolCall of toolCallDeltas) {
1900
+ for (const part of parts) {
1901
+ if (!("functionCall" in part)) continue;
1902
+ const providerMeta = part.thoughtSignature ? {
1903
+ [providerOptionsName]: {
1904
+ thoughtSignature: part.thoughtSignature
1905
+ }
1906
+ } : void 0;
1907
+ const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1908
+ const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1909
+ const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1910
+ if (isStreamingChunk) {
1911
+ if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1912
+ const toolCallId = generateId3();
1913
+ const accumulator = new GoogleJSONAccumulator();
1914
+ activeStreamingToolCalls.push({
1915
+ toolCallId,
1916
+ toolName: part.functionCall.name,
1917
+ accumulator,
1918
+ providerMetadata: providerMeta
1919
+ });
1920
+ controller.enqueue({
1921
+ type: "tool-input-start",
1922
+ id: toolCallId,
1923
+ toolName: part.functionCall.name,
1924
+ providerMetadata: providerMeta
1925
+ });
1926
+ if (part.functionCall.partialArgs != null) {
1927
+ const { textDelta } = accumulator.processPartialArgs(
1928
+ part.functionCall.partialArgs
1929
+ );
1930
+ if (textDelta.length > 0) {
1931
+ controller.enqueue({
1932
+ type: "tool-input-delta",
1933
+ id: toolCallId,
1934
+ delta: textDelta,
1935
+ providerMetadata: providerMeta
1936
+ });
1937
+ }
1938
+ }
1939
+ } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
1940
+ const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
1941
+ const { textDelta } = active.accumulator.processPartialArgs(
1942
+ part.functionCall.partialArgs
1943
+ );
1944
+ if (textDelta.length > 0) {
1945
+ controller.enqueue({
1946
+ type: "tool-input-delta",
1947
+ id: active.toolCallId,
1948
+ delta: textDelta,
1949
+ providerMetadata: providerMeta
1950
+ });
1951
+ }
1952
+ }
1953
+ } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
1954
+ const active = activeStreamingToolCalls.pop();
1955
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1956
+ if (closingDelta.length > 0) {
1957
+ controller.enqueue({
1958
+ type: "tool-input-delta",
1959
+ id: active.toolCallId,
1960
+ delta: closingDelta,
1961
+ providerMetadata: active.providerMetadata
1962
+ });
1963
+ }
1964
+ controller.enqueue({
1965
+ type: "tool-input-end",
1966
+ id: active.toolCallId,
1967
+ providerMetadata: active.providerMetadata
1968
+ });
1969
+ controller.enqueue({
1970
+ type: "tool-call",
1971
+ toolCallId: active.toolCallId,
1972
+ toolName: active.toolName,
1973
+ input: finalJSON,
1974
+ providerMetadata: active.providerMetadata
1975
+ });
1976
+ hasToolCalls = true;
1977
+ } else if (isCompleteCall) {
1978
+ const toolCallId = generateId3();
1979
+ const toolName = part.functionCall.name;
1980
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_i = part.functionCall.args) != null ? _i : {});
1656
1981
  controller.enqueue({
1657
1982
  type: "tool-input-start",
1658
- id: toolCall.toolCallId,
1659
- toolName: toolCall.toolName,
1660
- providerMetadata: toolCall.providerMetadata
1983
+ id: toolCallId,
1984
+ toolName,
1985
+ providerMetadata: providerMeta
1661
1986
  });
1662
1987
  controller.enqueue({
1663
1988
  type: "tool-input-delta",
1664
- id: toolCall.toolCallId,
1665
- delta: toolCall.args,
1666
- providerMetadata: toolCall.providerMetadata
1989
+ id: toolCallId,
1990
+ delta: args2,
1991
+ providerMetadata: providerMeta
1667
1992
  });
1668
1993
  controller.enqueue({
1669
1994
  type: "tool-input-end",
1670
- id: toolCall.toolCallId,
1671
- providerMetadata: toolCall.providerMetadata
1995
+ id: toolCallId,
1996
+ providerMetadata: providerMeta
1672
1997
  });
1673
1998
  controller.enqueue({
1674
1999
  type: "tool-call",
1675
- toolCallId: toolCall.toolCallId,
1676
- toolName: toolCall.toolName,
1677
- input: toolCall.args,
1678
- providerMetadata: toolCall.providerMetadata
2000
+ toolCallId,
2001
+ toolName,
2002
+ input: args2,
2003
+ providerMetadata: providerMeta
1679
2004
  });
1680
2005
  hasToolCalls = true;
1681
2006
  }
@@ -1691,12 +2016,12 @@ var GoogleGenerativeAILanguageModel = class {
1691
2016
  };
1692
2017
  providerMetadata = {
1693
2018
  [providerOptionsName]: {
1694
- promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
2019
+ promptFeedback: (_j = value.promptFeedback) != null ? _j : null,
1695
2020
  groundingMetadata: lastGroundingMetadata,
1696
2021
  urlContextMetadata: lastUrlContextMetadata,
1697
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
2022
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null,
1698
2023
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1699
- finishMessage: (_k = candidate.finishMessage) != null ? _k : null,
2024
+ finishMessage: (_l = candidate.finishMessage) != null ? _l : null,
1700
2025
  serviceTier
1701
2026
  }
1702
2027
  };
@@ -1729,26 +2054,6 @@ var GoogleGenerativeAILanguageModel = class {
1729
2054
  };
1730
2055
  }
1731
2056
  };
1732
- function getToolCallsFromParts({
1733
- parts,
1734
- generateId: generateId3,
1735
- providerOptionsName
1736
- }) {
1737
- const functionCallParts = parts == null ? void 0 : parts.filter(
1738
- (part) => "functionCall" in part
1739
- );
1740
- return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1741
- type: "tool-call",
1742
- toolCallId: generateId3(),
1743
- toolName: part.functionCall.name,
1744
- args: JSON.stringify(part.functionCall.args),
1745
- providerMetadata: part.thoughtSignature ? {
1746
- [providerOptionsName]: {
1747
- thoughtSignature: part.thoughtSignature
1748
- }
1749
- } : void 0
1750
- }));
1751
- }
1752
2057
  function extractSources({
1753
2058
  groundingMetadata,
1754
2059
  generateId: generateId3
@@ -1892,14 +2197,24 @@ var getGroundingMetadataSchema = () => z5.object({
1892
2197
  z5.object({})
1893
2198
  ]).nullish()
1894
2199
  });
2200
+ var partialArgSchema = z5.object({
2201
+ jsonPath: z5.string(),
2202
+ stringValue: z5.string().nullish(),
2203
+ numberValue: z5.number().nullish(),
2204
+ boolValue: z5.boolean().nullish(),
2205
+ nullValue: z5.unknown().nullish(),
2206
+ willContinue: z5.boolean().nullish()
2207
+ });
1895
2208
  var getContentSchema = () => z5.object({
1896
2209
  parts: z5.array(
1897
2210
  z5.union([
1898
2211
  // note: order matters since text can be fully empty
1899
2212
  z5.object({
1900
2213
  functionCall: z5.object({
1901
- name: z5.string(),
1902
- args: z5.unknown()
2214
+ name: z5.string().nullish(),
2215
+ args: z5.unknown().nullish(),
2216
+ partialArgs: z5.array(partialArgSchema).nullish(),
2217
+ willContinue: z5.boolean().nullish()
1903
2218
  }),
1904
2219
  thoughtSignature: z5.string().nullish()
1905
2220
  }),