@ai-sdk/google 3.0.60 → 3.0.62

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.
@@ -614,6 +614,17 @@ var googleLanguageModelOptions = lazySchema2(
614
614
  longitude: z2.number()
615
615
  }).optional()
616
616
  }).optional(),
617
+ /**
618
+ * Optional. When set to true, function call arguments will be streamed
619
+ * incrementally via partialArgs in streaming responses. Only supported
620
+ * on the Vertex AI API (not the Gemini API) and only for Gemini 3+
621
+ * models.
622
+ *
623
+ * @default false
624
+ *
625
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
626
+ */
627
+ streamFunctionCallArguments: z2.boolean().optional(),
617
628
  /**
618
629
  * Optional. The service tier to use for the request.
619
630
  */
@@ -874,6 +885,229 @@ function prepareTools({
874
885
  }
875
886
  }
876
887
 
888
+ // src/google-json-accumulator.ts
889
+ var GoogleJSONAccumulator = class {
890
+ constructor() {
891
+ this.accumulatedArgs = {};
892
+ this.jsonText = "";
893
+ /**
894
+ * Stack representing the currently "open" containers in the JSON output.
895
+ * Entry 0 is always the root `{` object once the first value is written.
896
+ */
897
+ this.pathStack = [];
898
+ /**
899
+ * Whether a string value is currently "open" (willContinue was true),
900
+ * meaning the closing quote has not yet been emitted.
901
+ */
902
+ this.stringOpen = false;
903
+ }
904
+ /**
905
+ * Input: [{jsonPath:"$.brightness",numberValue:50}]
906
+ * Output: { currentJSON:{brightness:50}, textDelta:'{"brightness":50' }
907
+ */
908
+ processPartialArgs(partialArgs) {
909
+ let delta = "";
910
+ for (const arg of partialArgs) {
911
+ const rawPath = arg.jsonPath.replace(/^\$\./, "");
912
+ if (!rawPath) continue;
913
+ const segments = parsePath(rawPath);
914
+ const existingValue = getNestedValue(this.accumulatedArgs, segments);
915
+ const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
916
+ if (isStringContinuation) {
917
+ const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
918
+ setNestedValue(
919
+ this.accumulatedArgs,
920
+ segments,
921
+ existingValue + arg.stringValue
922
+ );
923
+ delta += escaped;
924
+ continue;
925
+ }
926
+ const resolved = resolvePartialArgValue(arg);
927
+ if (resolved == null) continue;
928
+ setNestedValue(this.accumulatedArgs, segments, resolved.value);
929
+ delta += this.emitNavigationTo(segments, arg, resolved.json);
930
+ }
931
+ this.jsonText += delta;
932
+ return {
933
+ currentJSON: this.accumulatedArgs,
934
+ textDelta: delta
935
+ };
936
+ }
937
+ /**
938
+ * Input: jsonText='{"brightness":50', accumulatedArgs={brightness:50}
939
+ * Output: { finalJSON:'{"brightness":50}', closingDelta:'}' }
940
+ */
941
+ finalize() {
942
+ const finalArgs = JSON.stringify(this.accumulatedArgs);
943
+ const closingDelta = finalArgs.slice(this.jsonText.length);
944
+ return { finalJSON: finalArgs, closingDelta };
945
+ }
946
+ /**
947
+ * Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
948
+ * Output: '{' (first call) or '' (subsequent calls)
949
+ */
950
+ ensureRoot() {
951
+ if (this.pathStack.length === 0) {
952
+ this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
953
+ return "{";
954
+ }
955
+ return "";
956
+ }
957
+ /**
958
+ * Emits the JSON text fragment needed to navigate from the current open
959
+ * path to the new leaf at `targetSegments`, then writes the value.
960
+ *
961
+ * Input: targetSegments=["recipe","name"], arg={jsonPath:"$.recipe.name",stringValue:"Lasagna"}, valueJson='"Lasagna"'
962
+ * Output: '{"recipe":{"name":"Lasagna"'
963
+ */
964
+ emitNavigationTo(targetSegments, arg, valueJson) {
965
+ let fragment = "";
966
+ if (this.stringOpen) {
967
+ fragment += '"';
968
+ this.stringOpen = false;
969
+ }
970
+ fragment += this.ensureRoot();
971
+ const targetContainerSegments = targetSegments.slice(0, -1);
972
+ const leafSegment = targetSegments[targetSegments.length - 1];
973
+ const commonDepth = this.findCommonStackDepth(targetContainerSegments);
974
+ fragment += this.closeDownTo(commonDepth);
975
+ fragment += this.openDownTo(targetContainerSegments, leafSegment);
976
+ fragment += this.emitLeaf(leafSegment, arg, valueJson);
977
+ return fragment;
978
+ }
979
+ /**
980
+ * Returns the stack depth to preserve when navigating to a new target
981
+ * container path. Always >= 1 (the root is never popped).
982
+ *
983
+ * Input: stack=[root,"recipe","ingredients",0], target=["recipe","ingredients",1]
984
+ * Output: 3 (keep root+"recipe"+"ingredients")
985
+ */
986
+ findCommonStackDepth(targetContainer) {
987
+ const maxDepth = Math.min(
988
+ this.pathStack.length - 1,
989
+ targetContainer.length
990
+ );
991
+ let common = 0;
992
+ for (let i = 0; i < maxDepth; i++) {
993
+ if (this.pathStack[i + 1].segment === targetContainer[i]) {
994
+ common++;
995
+ } else {
996
+ break;
997
+ }
998
+ }
999
+ return common + 1;
1000
+ }
1001
+ /**
1002
+ * Closes containers from the current stack depth back down to `targetDepth`.
1003
+ *
1004
+ * Input: this.pathStack=[root,"recipe","ingredients",0], targetDepth=3
1005
+ * Output: '}'
1006
+ */
1007
+ closeDownTo(targetDepth) {
1008
+ let fragment = "";
1009
+ while (this.pathStack.length > targetDepth) {
1010
+ const entry = this.pathStack.pop();
1011
+ fragment += entry.isArray ? "]" : "}";
1012
+ }
1013
+ return fragment;
1014
+ }
1015
+ /**
1016
+ * Opens containers from the current stack depth down to the full target
1017
+ * container path, emitting opening `{`, `[`, keys, and commas as needed.
1018
+ * `leafSegment` is used to determine if the innermost container is an array.
1019
+ *
1020
+ * Input: this.pathStack=[root], targetContainer=["recipe","ingredients"], leafSegment=0
1021
+ * Output: '"recipe":{"ingredients":['
1022
+ */
1023
+ openDownTo(targetContainer, leafSegment) {
1024
+ let fragment = "";
1025
+ const startIdx = this.pathStack.length - 1;
1026
+ for (let i = startIdx; i < targetContainer.length; i++) {
1027
+ const seg = targetContainer[i];
1028
+ const parentEntry = this.pathStack[this.pathStack.length - 1];
1029
+ if (parentEntry.childCount > 0) {
1030
+ fragment += ",";
1031
+ }
1032
+ parentEntry.childCount++;
1033
+ if (typeof seg === "string") {
1034
+ fragment += `${JSON.stringify(seg)}:`;
1035
+ }
1036
+ const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
1037
+ const isArray = typeof childSeg === "number";
1038
+ fragment += isArray ? "[" : "{";
1039
+ this.pathStack.push({ segment: seg, isArray, childCount: 0 });
1040
+ }
1041
+ return fragment;
1042
+ }
1043
+ /**
1044
+ * Emits the comma, key, and value for a leaf entry in the current container.
1045
+ *
1046
+ * Input: leafSegment="name", arg={stringValue:"Lasagna"}, valueJson='"Lasagna"'
1047
+ * Output: '"name":"Lasagna"' (or ',"name":"Lasagna"' if container.childCount > 0)
1048
+ */
1049
+ emitLeaf(leafSegment, arg, valueJson) {
1050
+ let fragment = "";
1051
+ const container = this.pathStack[this.pathStack.length - 1];
1052
+ if (container.childCount > 0) {
1053
+ fragment += ",";
1054
+ }
1055
+ container.childCount++;
1056
+ if (typeof leafSegment === "string") {
1057
+ fragment += `${JSON.stringify(leafSegment)}:`;
1058
+ }
1059
+ if (arg.stringValue != null && arg.willContinue) {
1060
+ fragment += valueJson.slice(0, -1);
1061
+ this.stringOpen = true;
1062
+ } else {
1063
+ fragment += valueJson;
1064
+ }
1065
+ return fragment;
1066
+ }
1067
+ };
1068
+ function parsePath(rawPath) {
1069
+ const segments = [];
1070
+ for (const part of rawPath.split(".")) {
1071
+ const bracketIdx = part.indexOf("[");
1072
+ if (bracketIdx === -1) {
1073
+ segments.push(part);
1074
+ } else {
1075
+ if (bracketIdx > 0) segments.push(part.slice(0, bracketIdx));
1076
+ for (const m of part.matchAll(/\[(\d+)\]/g)) {
1077
+ segments.push(parseInt(m[1], 10));
1078
+ }
1079
+ }
1080
+ }
1081
+ return segments;
1082
+ }
1083
+ function getNestedValue(obj, segments) {
1084
+ let current = obj;
1085
+ for (const seg of segments) {
1086
+ if (current == null || typeof current !== "object") return void 0;
1087
+ current = current[seg];
1088
+ }
1089
+ return current;
1090
+ }
1091
+ function setNestedValue(obj, segments, value) {
1092
+ let current = obj;
1093
+ for (let i = 0; i < segments.length - 1; i++) {
1094
+ const seg = segments[i];
1095
+ const nextSeg = segments[i + 1];
1096
+ if (current[seg] == null) {
1097
+ current[seg] = typeof nextSeg === "number" ? [] : {};
1098
+ }
1099
+ current = current[seg];
1100
+ }
1101
+ current[segments[segments.length - 1]] = value;
1102
+ }
1103
+ function resolvePartialArgValue(arg) {
1104
+ var _a, _b;
1105
+ const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
1106
+ if (value != null) return { value, json: JSON.stringify(value) };
1107
+ if ("nullValue" in arg) return { value: null, json: "null" };
1108
+ return void 0;
1109
+ }
1110
+
877
1111
  // src/map-google-generative-ai-finish-reason.ts
878
1112
  function mapGoogleGenerativeAIFinishReason({
879
1113
  finishReason,
@@ -930,8 +1164,8 @@ var GoogleGenerativeAILanguageModel = class {
930
1164
  tools,
931
1165
  toolChoice,
932
1166
  providerOptions
933
- }) {
934
- var _a;
1167
+ }, { isStreaming = false } = {}) {
1168
+ var _a, _b;
935
1169
  const warnings = [];
936
1170
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
937
1171
  let googleOptions = await parseProviderOptions({
@@ -946,14 +1180,21 @@ var GoogleGenerativeAILanguageModel = class {
946
1180
  schema: googleLanguageModelOptions
947
1181
  });
948
1182
  }
1183
+ const isVertexProvider = this.config.provider.startsWith("google.vertex.");
949
1184
  if ((tools == null ? void 0 : tools.some(
950
1185
  (tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
951
- )) && !this.config.provider.startsWith("google.vertex.")) {
1186
+ )) && !isVertexProvider) {
952
1187
  warnings.push({
953
1188
  type: "other",
954
1189
  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}).`
955
1190
  });
956
1191
  }
1192
+ if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
1193
+ warnings.push({
1194
+ type: "other",
1195
+ 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`
1196
+ });
1197
+ }
957
1198
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
958
1199
  const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
959
1200
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
@@ -973,6 +1214,19 @@ var GoogleGenerativeAILanguageModel = class {
973
1214
  toolChoice,
974
1215
  modelId: this.modelId
975
1216
  });
1217
+ const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
1218
+ const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1219
+ ...googleToolConfig,
1220
+ ...streamFunctionCallArguments && {
1221
+ functionCallingConfig: {
1222
+ ...googleToolConfig == null ? void 0 : googleToolConfig.functionCallingConfig,
1223
+ streamFunctionCallArguments: true
1224
+ }
1225
+ },
1226
+ ...(googleOptions == null ? void 0 : googleOptions.retrievalConfig) && {
1227
+ retrievalConfig: googleOptions.retrievalConfig
1228
+ }
1229
+ } : void 0;
976
1230
  return {
977
1231
  args: {
978
1232
  generationConfig: {
@@ -990,7 +1244,7 @@ var GoogleGenerativeAILanguageModel = class {
990
1244
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
991
1245
  // so this is needed as an escape hatch:
992
1246
  // TODO convert into provider option
993
- ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1247
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
994
1248
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
995
1249
  audioTimestamp: googleOptions.audioTimestamp
996
1250
  },
@@ -1008,10 +1262,7 @@ var GoogleGenerativeAILanguageModel = class {
1008
1262
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1009
1263
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1010
1264
  tools: googleTools2,
1011
- toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1012
- ...googleToolConfig,
1013
- retrievalConfig: googleOptions.retrievalConfig
1014
- } : googleToolConfig,
1265
+ toolConfig,
1015
1266
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
1016
1267
  labels: googleOptions == null ? void 0 : googleOptions.labels,
1017
1268
  serviceTier: googleOptions == null ? void 0 : googleOptions.serviceTier
@@ -1089,7 +1340,7 @@ var GoogleGenerativeAILanguageModel = class {
1089
1340
  providerMetadata: thoughtSignatureMetadata
1090
1341
  });
1091
1342
  }
1092
- } else if ("functionCall" in part) {
1343
+ } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
1093
1344
  content.push({
1094
1345
  type: "tool-call",
1095
1346
  toolCallId: this.config.generateId(),
@@ -1202,7 +1453,10 @@ var GoogleGenerativeAILanguageModel = class {
1202
1453
  };
1203
1454
  }
1204
1455
  async doStream(options) {
1205
- const { args, warnings, providerOptionsName } = await this.getArgs(options);
1456
+ const { args, warnings, providerOptionsName } = await this.getArgs(
1457
+ options,
1458
+ { isStreaming: true }
1459
+ );
1206
1460
  const headers = combineHeaders(
1207
1461
  await resolve(this.config.headers),
1208
1462
  options.headers
@@ -1235,6 +1489,7 @@ var GoogleGenerativeAILanguageModel = class {
1235
1489
  const emittedSourceUrls = /* @__PURE__ */ new Set();
1236
1490
  let lastCodeExecutionToolCallId;
1237
1491
  let lastServerToolCallId;
1492
+ const activeStreamingToolCalls = [];
1238
1493
  return {
1239
1494
  stream: response.pipeThrough(
1240
1495
  new TransformStream({
@@ -1242,7 +1497,7 @@ var GoogleGenerativeAILanguageModel = class {
1242
1497
  controller.enqueue({ type: "stream-start", warnings });
1243
1498
  },
1244
1499
  transform(chunk, controller) {
1245
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1500
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1246
1501
  if (options.includeRawChunks) {
1247
1502
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1248
1503
  }
@@ -1435,36 +1690,110 @@ var GoogleGenerativeAILanguageModel = class {
1435
1690
  lastServerToolCallId = void 0;
1436
1691
  }
1437
1692
  }
1438
- const toolCallDeltas = getToolCallsFromParts({
1439
- parts: content.parts,
1440
- generateId: generateId2,
1441
- providerOptionsName
1442
- });
1443
- if (toolCallDeltas != null) {
1444
- for (const toolCall of toolCallDeltas) {
1693
+ for (const part of parts) {
1694
+ if (!("functionCall" in part)) continue;
1695
+ const providerMeta = part.thoughtSignature ? {
1696
+ [providerOptionsName]: {
1697
+ thoughtSignature: part.thoughtSignature
1698
+ }
1699
+ } : void 0;
1700
+ const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1701
+ const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1702
+ const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1703
+ if (isStreamingChunk) {
1704
+ if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1705
+ const toolCallId = generateId2();
1706
+ const accumulator = new GoogleJSONAccumulator();
1707
+ activeStreamingToolCalls.push({
1708
+ toolCallId,
1709
+ toolName: part.functionCall.name,
1710
+ accumulator,
1711
+ providerMetadata: providerMeta
1712
+ });
1713
+ controller.enqueue({
1714
+ type: "tool-input-start",
1715
+ id: toolCallId,
1716
+ toolName: part.functionCall.name,
1717
+ providerMetadata: providerMeta
1718
+ });
1719
+ if (part.functionCall.partialArgs != null) {
1720
+ const { textDelta } = accumulator.processPartialArgs(
1721
+ part.functionCall.partialArgs
1722
+ );
1723
+ if (textDelta.length > 0) {
1724
+ controller.enqueue({
1725
+ type: "tool-input-delta",
1726
+ id: toolCallId,
1727
+ delta: textDelta,
1728
+ providerMetadata: providerMeta
1729
+ });
1730
+ }
1731
+ }
1732
+ } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
1733
+ const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
1734
+ const { textDelta } = active.accumulator.processPartialArgs(
1735
+ part.functionCall.partialArgs
1736
+ );
1737
+ if (textDelta.length > 0) {
1738
+ controller.enqueue({
1739
+ type: "tool-input-delta",
1740
+ id: active.toolCallId,
1741
+ delta: textDelta,
1742
+ providerMetadata: providerMeta
1743
+ });
1744
+ }
1745
+ }
1746
+ } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
1747
+ const active = activeStreamingToolCalls.pop();
1748
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1749
+ if (closingDelta.length > 0) {
1750
+ controller.enqueue({
1751
+ type: "tool-input-delta",
1752
+ id: active.toolCallId,
1753
+ delta: closingDelta,
1754
+ providerMetadata: active.providerMetadata
1755
+ });
1756
+ }
1757
+ controller.enqueue({
1758
+ type: "tool-input-end",
1759
+ id: active.toolCallId,
1760
+ providerMetadata: active.providerMetadata
1761
+ });
1762
+ controller.enqueue({
1763
+ type: "tool-call",
1764
+ toolCallId: active.toolCallId,
1765
+ toolName: active.toolName,
1766
+ input: finalJSON,
1767
+ providerMetadata: active.providerMetadata
1768
+ });
1769
+ hasToolCalls = true;
1770
+ } else if (isCompleteCall) {
1771
+ const toolCallId = generateId2();
1772
+ const toolName = part.functionCall.name;
1773
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_i = part.functionCall.args) != null ? _i : {});
1445
1774
  controller.enqueue({
1446
1775
  type: "tool-input-start",
1447
- id: toolCall.toolCallId,
1448
- toolName: toolCall.toolName,
1449
- providerMetadata: toolCall.providerMetadata
1776
+ id: toolCallId,
1777
+ toolName,
1778
+ providerMetadata: providerMeta
1450
1779
  });
1451
1780
  controller.enqueue({
1452
1781
  type: "tool-input-delta",
1453
- id: toolCall.toolCallId,
1454
- delta: toolCall.args,
1455
- providerMetadata: toolCall.providerMetadata
1782
+ id: toolCallId,
1783
+ delta: args2,
1784
+ providerMetadata: providerMeta
1456
1785
  });
1457
1786
  controller.enqueue({
1458
1787
  type: "tool-input-end",
1459
- id: toolCall.toolCallId,
1460
- providerMetadata: toolCall.providerMetadata
1788
+ id: toolCallId,
1789
+ providerMetadata: providerMeta
1461
1790
  });
1462
1791
  controller.enqueue({
1463
1792
  type: "tool-call",
1464
- toolCallId: toolCall.toolCallId,
1465
- toolName: toolCall.toolName,
1466
- input: toolCall.args,
1467
- providerMetadata: toolCall.providerMetadata
1793
+ toolCallId,
1794
+ toolName,
1795
+ input: args2,
1796
+ providerMetadata: providerMeta
1468
1797
  });
1469
1798
  hasToolCalls = true;
1470
1799
  }
@@ -1480,12 +1809,12 @@ var GoogleGenerativeAILanguageModel = class {
1480
1809
  };
1481
1810
  providerMetadata = {
1482
1811
  [providerOptionsName]: {
1483
- promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
1812
+ promptFeedback: (_j = value.promptFeedback) != null ? _j : null,
1484
1813
  groundingMetadata: lastGroundingMetadata,
1485
1814
  urlContextMetadata: lastUrlContextMetadata,
1486
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
1815
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null,
1487
1816
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1488
- finishMessage: (_k = candidate.finishMessage) != null ? _k : null,
1817
+ finishMessage: (_l = candidate.finishMessage) != null ? _l : null,
1489
1818
  serviceTier
1490
1819
  }
1491
1820
  };
@@ -1518,26 +1847,6 @@ var GoogleGenerativeAILanguageModel = class {
1518
1847
  };
1519
1848
  }
1520
1849
  };
1521
- function getToolCallsFromParts({
1522
- parts,
1523
- generateId: generateId2,
1524
- providerOptionsName
1525
- }) {
1526
- const functionCallParts = parts == null ? void 0 : parts.filter(
1527
- (part) => "functionCall" in part
1528
- );
1529
- return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1530
- type: "tool-call",
1531
- toolCallId: generateId2(),
1532
- toolName: part.functionCall.name,
1533
- args: JSON.stringify(part.functionCall.args),
1534
- providerMetadata: part.thoughtSignature ? {
1535
- [providerOptionsName]: {
1536
- thoughtSignature: part.thoughtSignature
1537
- }
1538
- } : void 0
1539
- }));
1540
- }
1541
1850
  function extractSources({
1542
1851
  groundingMetadata,
1543
1852
  generateId: generateId2
@@ -1681,14 +1990,24 @@ var getGroundingMetadataSchema = () => z3.object({
1681
1990
  z3.object({})
1682
1991
  ]).nullish()
1683
1992
  });
1993
+ var partialArgSchema = z3.object({
1994
+ jsonPath: z3.string(),
1995
+ stringValue: z3.string().nullish(),
1996
+ numberValue: z3.number().nullish(),
1997
+ boolValue: z3.boolean().nullish(),
1998
+ nullValue: z3.unknown().nullish(),
1999
+ willContinue: z3.boolean().nullish()
2000
+ });
1684
2001
  var getContentSchema = () => z3.object({
1685
2002
  parts: z3.array(
1686
2003
  z3.union([
1687
2004
  // note: order matters since text can be fully empty
1688
2005
  z3.object({
1689
2006
  functionCall: z3.object({
1690
- name: z3.string(),
1691
- args: z3.unknown()
2007
+ name: z3.string().nullish(),
2008
+ args: z3.unknown().nullish(),
2009
+ partialArgs: z3.array(partialArgSchema).nullish(),
2010
+ willContinue: z3.boolean().nullish()
1692
2011
  }),
1693
2012
  thoughtSignature: z3.string().nullish()
1694
2013
  }),