@ai-sdk/google 4.0.0-beta.30 → 4.0.0-beta.32

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 ? "4.0.0-beta.30" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0-beta.32" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -882,6 +882,16 @@ var googleLanguageModelOptions = lazySchema4(
882
882
  longitude: z4.number()
883
883
  }).optional()
884
884
  }).optional(),
885
+ /**
886
+ * Optional. When set to true, function call arguments will be streamed
887
+ * incrementally via partialArgs in streaming responses. Only supported
888
+ * on the Vertex AI API (not the Gemini API).
889
+ *
890
+ * @default true
891
+ *
892
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
893
+ */
894
+ streamFunctionCallArguments: z4.boolean().optional(),
885
895
  /**
886
896
  * Optional. The service tier to use for the request.
887
897
  */
@@ -1142,6 +1152,229 @@ function prepareTools({
1142
1152
  }
1143
1153
  }
1144
1154
 
1155
+ // src/google-json-accumulator.ts
1156
+ var GoogleJSONAccumulator = class {
1157
+ constructor() {
1158
+ this.accumulatedArgs = {};
1159
+ this.jsonText = "";
1160
+ /**
1161
+ * Stack representing the currently "open" containers in the JSON output.
1162
+ * Entry 0 is always the root `{` object once the first value is written.
1163
+ */
1164
+ this.pathStack = [];
1165
+ /**
1166
+ * Whether a string value is currently "open" (willContinue was true),
1167
+ * meaning the closing quote has not yet been emitted.
1168
+ */
1169
+ this.stringOpen = false;
1170
+ }
1171
+ /**
1172
+ * Input: [{jsonPath:"$.brightness",numberValue:50}]
1173
+ * Output: { currentJSON:{brightness:50}, textDelta:'{"brightness":50' }
1174
+ */
1175
+ processPartialArgs(partialArgs) {
1176
+ let delta = "";
1177
+ for (const arg of partialArgs) {
1178
+ const rawPath = arg.jsonPath.replace(/^\$\./, "");
1179
+ if (!rawPath) continue;
1180
+ const segments = parsePath(rawPath);
1181
+ const existingValue = getNestedValue(this.accumulatedArgs, segments);
1182
+ const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
1183
+ if (isStringContinuation) {
1184
+ const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
1185
+ setNestedValue(
1186
+ this.accumulatedArgs,
1187
+ segments,
1188
+ existingValue + arg.stringValue
1189
+ );
1190
+ delta += escaped;
1191
+ continue;
1192
+ }
1193
+ const resolved = resolvePartialArgValue(arg);
1194
+ if (resolved == null) continue;
1195
+ setNestedValue(this.accumulatedArgs, segments, resolved.value);
1196
+ delta += this.emitNavigationTo(segments, arg, resolved.json);
1197
+ }
1198
+ this.jsonText += delta;
1199
+ return {
1200
+ currentJSON: this.accumulatedArgs,
1201
+ textDelta: delta
1202
+ };
1203
+ }
1204
+ /**
1205
+ * Input: jsonText='{"brightness":50', accumulatedArgs={brightness:50}
1206
+ * Output: { finalJSON:'{"brightness":50}', closingDelta:'}' }
1207
+ */
1208
+ finalize() {
1209
+ const finalArgs = JSON.stringify(this.accumulatedArgs);
1210
+ const closingDelta = finalArgs.slice(this.jsonText.length);
1211
+ return { finalJSON: finalArgs, closingDelta };
1212
+ }
1213
+ /**
1214
+ * Input: pathStack=[] (first call) or pathStack=[root,...] (subsequent calls)
1215
+ * Output: '{' (first call) or '' (subsequent calls)
1216
+ */
1217
+ ensureRoot() {
1218
+ if (this.pathStack.length === 0) {
1219
+ this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
1220
+ return "{";
1221
+ }
1222
+ return "";
1223
+ }
1224
+ /**
1225
+ * Emits the JSON text fragment needed to navigate from the current open
1226
+ * path to the new leaf at `targetSegments`, then writes the value.
1227
+ *
1228
+ * Input: targetSegments=["recipe","name"], arg={jsonPath:"$.recipe.name",stringValue:"Lasagna"}, valueJson='"Lasagna"'
1229
+ * Output: '{"recipe":{"name":"Lasagna"'
1230
+ */
1231
+ emitNavigationTo(targetSegments, arg, valueJson) {
1232
+ let fragment = "";
1233
+ if (this.stringOpen) {
1234
+ fragment += '"';
1235
+ this.stringOpen = false;
1236
+ }
1237
+ fragment += this.ensureRoot();
1238
+ const targetContainerSegments = targetSegments.slice(0, -1);
1239
+ const leafSegment = targetSegments[targetSegments.length - 1];
1240
+ const commonDepth = this.findCommonStackDepth(targetContainerSegments);
1241
+ fragment += this.closeDownTo(commonDepth);
1242
+ fragment += this.openDownTo(targetContainerSegments, leafSegment);
1243
+ fragment += this.emitLeaf(leafSegment, arg, valueJson);
1244
+ return fragment;
1245
+ }
1246
+ /**
1247
+ * Returns the stack depth to preserve when navigating to a new target
1248
+ * container path. Always >= 1 (the root is never popped).
1249
+ *
1250
+ * Input: stack=[root,"recipe","ingredients",0], target=["recipe","ingredients",1]
1251
+ * Output: 3 (keep root+"recipe"+"ingredients")
1252
+ */
1253
+ findCommonStackDepth(targetContainer) {
1254
+ const maxDepth = Math.min(
1255
+ this.pathStack.length - 1,
1256
+ targetContainer.length
1257
+ );
1258
+ let common = 0;
1259
+ for (let i = 0; i < maxDepth; i++) {
1260
+ if (this.pathStack[i + 1].segment === targetContainer[i]) {
1261
+ common++;
1262
+ } else {
1263
+ break;
1264
+ }
1265
+ }
1266
+ return common + 1;
1267
+ }
1268
+ /**
1269
+ * Closes containers from the current stack depth back down to `targetDepth`.
1270
+ *
1271
+ * Input: this.pathStack=[root,"recipe","ingredients",0], targetDepth=3
1272
+ * Output: '}'
1273
+ */
1274
+ closeDownTo(targetDepth) {
1275
+ let fragment = "";
1276
+ while (this.pathStack.length > targetDepth) {
1277
+ const entry = this.pathStack.pop();
1278
+ fragment += entry.isArray ? "]" : "}";
1279
+ }
1280
+ return fragment;
1281
+ }
1282
+ /**
1283
+ * Opens containers from the current stack depth down to the full target
1284
+ * container path, emitting opening `{`, `[`, keys, and commas as needed.
1285
+ * `leafSegment` is used to determine if the innermost container is an array.
1286
+ *
1287
+ * Input: this.pathStack=[root], targetContainer=["recipe","ingredients"], leafSegment=0
1288
+ * Output: '"recipe":{"ingredients":['
1289
+ */
1290
+ openDownTo(targetContainer, leafSegment) {
1291
+ let fragment = "";
1292
+ const startIdx = this.pathStack.length - 1;
1293
+ for (let i = startIdx; i < targetContainer.length; i++) {
1294
+ const seg = targetContainer[i];
1295
+ const parentEntry = this.pathStack[this.pathStack.length - 1];
1296
+ if (parentEntry.childCount > 0) {
1297
+ fragment += ",";
1298
+ }
1299
+ parentEntry.childCount++;
1300
+ if (typeof seg === "string") {
1301
+ fragment += `${JSON.stringify(seg)}:`;
1302
+ }
1303
+ const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
1304
+ const isArray = typeof childSeg === "number";
1305
+ fragment += isArray ? "[" : "{";
1306
+ this.pathStack.push({ segment: seg, isArray, childCount: 0 });
1307
+ }
1308
+ return fragment;
1309
+ }
1310
+ /**
1311
+ * Emits the comma, key, and value for a leaf entry in the current container.
1312
+ *
1313
+ * Input: leafSegment="name", arg={stringValue:"Lasagna"}, valueJson='"Lasagna"'
1314
+ * Output: '"name":"Lasagna"' (or ',"name":"Lasagna"' if container.childCount > 0)
1315
+ */
1316
+ emitLeaf(leafSegment, arg, valueJson) {
1317
+ let fragment = "";
1318
+ const container = this.pathStack[this.pathStack.length - 1];
1319
+ if (container.childCount > 0) {
1320
+ fragment += ",";
1321
+ }
1322
+ container.childCount++;
1323
+ if (typeof leafSegment === "string") {
1324
+ fragment += `${JSON.stringify(leafSegment)}:`;
1325
+ }
1326
+ if (arg.stringValue != null && arg.willContinue) {
1327
+ fragment += valueJson.slice(0, -1);
1328
+ this.stringOpen = true;
1329
+ } else {
1330
+ fragment += valueJson;
1331
+ }
1332
+ return fragment;
1333
+ }
1334
+ };
1335
+ function parsePath(rawPath) {
1336
+ const segments = [];
1337
+ for (const part of rawPath.split(".")) {
1338
+ const bracketIdx = part.indexOf("[");
1339
+ if (bracketIdx === -1) {
1340
+ segments.push(part);
1341
+ } else {
1342
+ if (bracketIdx > 0) segments.push(part.slice(0, bracketIdx));
1343
+ for (const m of part.matchAll(/\[(\d+)\]/g)) {
1344
+ segments.push(parseInt(m[1], 10));
1345
+ }
1346
+ }
1347
+ }
1348
+ return segments;
1349
+ }
1350
+ function getNestedValue(obj, segments) {
1351
+ let current = obj;
1352
+ for (const seg of segments) {
1353
+ if (current == null || typeof current !== "object") return void 0;
1354
+ current = current[seg];
1355
+ }
1356
+ return current;
1357
+ }
1358
+ function setNestedValue(obj, segments, value) {
1359
+ let current = obj;
1360
+ for (let i = 0; i < segments.length - 1; i++) {
1361
+ const seg = segments[i];
1362
+ const nextSeg = segments[i + 1];
1363
+ if (current[seg] == null) {
1364
+ current[seg] = typeof nextSeg === "number" ? [] : {};
1365
+ }
1366
+ current = current[seg];
1367
+ }
1368
+ current[segments[segments.length - 1]] = value;
1369
+ }
1370
+ function resolvePartialArgValue(arg) {
1371
+ var _a, _b;
1372
+ const value = (_b = (_a = arg.stringValue) != null ? _a : arg.numberValue) != null ? _b : arg.boolValue;
1373
+ if (value != null) return { value, json: JSON.stringify(value) };
1374
+ if ("nullValue" in arg) return { value: null, json: "null" };
1375
+ return void 0;
1376
+ }
1377
+
1145
1378
  // src/map-google-generative-ai-finish-reason.ts
1146
1379
  function mapGoogleGenerativeAIFinishReason({
1147
1380
  finishReason,
@@ -1200,7 +1433,7 @@ var GoogleGenerativeAILanguageModel = class {
1200
1433
  reasoning,
1201
1434
  providerOptions
1202
1435
  }) {
1203
- var _a;
1436
+ var _a, _b;
1204
1437
  const warnings = [];
1205
1438
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1206
1439
  let googleOptions = await parseProviderOptions2({
@@ -1215,14 +1448,21 @@ var GoogleGenerativeAILanguageModel = class {
1215
1448
  schema: googleLanguageModelOptions
1216
1449
  });
1217
1450
  }
1451
+ const isVertexProvider = this.config.provider.startsWith("google.vertex.");
1218
1452
  if ((tools == null ? void 0 : tools.some(
1219
1453
  (tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
1220
- )) && !this.config.provider.startsWith("google.vertex.")) {
1454
+ )) && !isVertexProvider) {
1221
1455
  warnings.push({
1222
1456
  type: "other",
1223
1457
  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}).`
1224
1458
  });
1225
1459
  }
1460
+ if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
1461
+ warnings.push({
1462
+ type: "other",
1463
+ 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`
1464
+ });
1465
+ }
1226
1466
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
1227
1467
  const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
1228
1468
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
@@ -1248,6 +1488,19 @@ var GoogleGenerativeAILanguageModel = class {
1248
1488
  warnings
1249
1489
  });
1250
1490
  const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
1491
+ const streamFunctionCallArguments = isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : true : void 0;
1492
+ const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1493
+ ...googleToolConfig,
1494
+ ...streamFunctionCallArguments && {
1495
+ functionCallingConfig: {
1496
+ ...googleToolConfig == null ? void 0 : googleToolConfig.functionCallingConfig,
1497
+ streamFunctionCallArguments: true
1498
+ }
1499
+ },
1500
+ ...(googleOptions == null ? void 0 : googleOptions.retrievalConfig) && {
1501
+ retrievalConfig: googleOptions.retrievalConfig
1502
+ }
1503
+ } : void 0;
1251
1504
  return {
1252
1505
  args: {
1253
1506
  generationConfig: {
@@ -1265,7 +1518,7 @@ var GoogleGenerativeAILanguageModel = class {
1265
1518
  responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
1266
1519
  // so this is needed as an escape hatch:
1267
1520
  // TODO convert into provider option
1268
- ((_a = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _a : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1521
+ ((_b = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _b : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
1269
1522
  ...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
1270
1523
  audioTimestamp: googleOptions.audioTimestamp
1271
1524
  },
@@ -1283,10 +1536,7 @@ var GoogleGenerativeAILanguageModel = class {
1283
1536
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
1284
1537
  safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
1285
1538
  tools: googleTools2,
1286
- toolConfig: (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
1287
- ...googleToolConfig,
1288
- retrievalConfig: googleOptions.retrievalConfig
1289
- } : googleToolConfig,
1539
+ toolConfig,
1290
1540
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
1291
1541
  labels: googleOptions == null ? void 0 : googleOptions.labels,
1292
1542
  serviceTier: googleOptions == null ? void 0 : googleOptions.serviceTier
@@ -1364,7 +1614,7 @@ var GoogleGenerativeAILanguageModel = class {
1364
1614
  providerMetadata: thoughtSignatureMetadata
1365
1615
  });
1366
1616
  }
1367
- } else if ("functionCall" in part) {
1617
+ } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
1368
1618
  content.push({
1369
1619
  type: "tool-call",
1370
1620
  toolCallId: this.config.generateId(),
@@ -1509,6 +1759,7 @@ var GoogleGenerativeAILanguageModel = class {
1509
1759
  const emittedSourceUrls = /* @__PURE__ */ new Set();
1510
1760
  let lastCodeExecutionToolCallId;
1511
1761
  let lastServerToolCallId;
1762
+ const activeStreamingToolCalls = [];
1512
1763
  return {
1513
1764
  stream: response.pipeThrough(
1514
1765
  new TransformStream({
@@ -1516,7 +1767,7 @@ var GoogleGenerativeAILanguageModel = class {
1516
1767
  controller.enqueue({ type: "stream-start", warnings });
1517
1768
  },
1518
1769
  transform(chunk, controller) {
1519
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1770
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1520
1771
  if (options.includeRawChunks) {
1521
1772
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1522
1773
  }
@@ -1708,36 +1959,110 @@ var GoogleGenerativeAILanguageModel = class {
1708
1959
  lastServerToolCallId = void 0;
1709
1960
  }
1710
1961
  }
1711
- const toolCallDeltas = getToolCallsFromParts({
1712
- parts: content.parts,
1713
- generateId: generateId3,
1714
- providerOptionsName
1715
- });
1716
- if (toolCallDeltas != null) {
1717
- for (const toolCall of toolCallDeltas) {
1962
+ for (const part of parts) {
1963
+ if (!("functionCall" in part)) continue;
1964
+ const providerMeta = part.thoughtSignature ? {
1965
+ [providerOptionsName]: {
1966
+ thoughtSignature: part.thoughtSignature
1967
+ }
1968
+ } : void 0;
1969
+ const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
1970
+ const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
1971
+ const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
1972
+ if (isStreamingChunk) {
1973
+ if (part.functionCall.name != null && part.functionCall.willContinue === true) {
1974
+ const toolCallId = generateId3();
1975
+ const accumulator = new GoogleJSONAccumulator();
1976
+ activeStreamingToolCalls.push({
1977
+ toolCallId,
1978
+ toolName: part.functionCall.name,
1979
+ accumulator,
1980
+ providerMetadata: providerMeta
1981
+ });
1982
+ controller.enqueue({
1983
+ type: "tool-input-start",
1984
+ id: toolCallId,
1985
+ toolName: part.functionCall.name,
1986
+ providerMetadata: providerMeta
1987
+ });
1988
+ if (part.functionCall.partialArgs != null) {
1989
+ const { textDelta } = accumulator.processPartialArgs(
1990
+ part.functionCall.partialArgs
1991
+ );
1992
+ if (textDelta.length > 0) {
1993
+ controller.enqueue({
1994
+ type: "tool-input-delta",
1995
+ id: toolCallId,
1996
+ delta: textDelta,
1997
+ providerMetadata: providerMeta
1998
+ });
1999
+ }
2000
+ }
2001
+ } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
2002
+ const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
2003
+ const { textDelta } = active.accumulator.processPartialArgs(
2004
+ part.functionCall.partialArgs
2005
+ );
2006
+ if (textDelta.length > 0) {
2007
+ controller.enqueue({
2008
+ type: "tool-input-delta",
2009
+ id: active.toolCallId,
2010
+ delta: textDelta,
2011
+ providerMetadata: providerMeta
2012
+ });
2013
+ }
2014
+ }
2015
+ } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
2016
+ const active = activeStreamingToolCalls.pop();
2017
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
2018
+ if (closingDelta.length > 0) {
2019
+ controller.enqueue({
2020
+ type: "tool-input-delta",
2021
+ id: active.toolCallId,
2022
+ delta: closingDelta,
2023
+ providerMetadata: active.providerMetadata
2024
+ });
2025
+ }
2026
+ controller.enqueue({
2027
+ type: "tool-input-end",
2028
+ id: active.toolCallId,
2029
+ providerMetadata: active.providerMetadata
2030
+ });
2031
+ controller.enqueue({
2032
+ type: "tool-call",
2033
+ toolCallId: active.toolCallId,
2034
+ toolName: active.toolName,
2035
+ input: finalJSON,
2036
+ providerMetadata: active.providerMetadata
2037
+ });
2038
+ hasToolCalls = true;
2039
+ } else if (isCompleteCall) {
2040
+ const toolCallId = generateId3();
2041
+ const toolName = part.functionCall.name;
2042
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_i = part.functionCall.args) != null ? _i : {});
1718
2043
  controller.enqueue({
1719
2044
  type: "tool-input-start",
1720
- id: toolCall.toolCallId,
1721
- toolName: toolCall.toolName,
1722
- providerMetadata: toolCall.providerMetadata
2045
+ id: toolCallId,
2046
+ toolName,
2047
+ providerMetadata: providerMeta
1723
2048
  });
1724
2049
  controller.enqueue({
1725
2050
  type: "tool-input-delta",
1726
- id: toolCall.toolCallId,
1727
- delta: toolCall.args,
1728
- providerMetadata: toolCall.providerMetadata
2051
+ id: toolCallId,
2052
+ delta: args2,
2053
+ providerMetadata: providerMeta
1729
2054
  });
1730
2055
  controller.enqueue({
1731
2056
  type: "tool-input-end",
1732
- id: toolCall.toolCallId,
1733
- providerMetadata: toolCall.providerMetadata
2057
+ id: toolCallId,
2058
+ providerMetadata: providerMeta
1734
2059
  });
1735
2060
  controller.enqueue({
1736
2061
  type: "tool-call",
1737
- toolCallId: toolCall.toolCallId,
1738
- toolName: toolCall.toolName,
1739
- input: toolCall.args,
1740
- providerMetadata: toolCall.providerMetadata
2062
+ toolCallId,
2063
+ toolName,
2064
+ input: args2,
2065
+ providerMetadata: providerMeta
1741
2066
  });
1742
2067
  hasToolCalls = true;
1743
2068
  }
@@ -1753,12 +2078,12 @@ var GoogleGenerativeAILanguageModel = class {
1753
2078
  };
1754
2079
  providerMetadata = {
1755
2080
  [providerOptionsName]: {
1756
- promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
2081
+ promptFeedback: (_j = value.promptFeedback) != null ? _j : null,
1757
2082
  groundingMetadata: lastGroundingMetadata,
1758
2083
  urlContextMetadata: lastUrlContextMetadata,
1759
- safetyRatings: (_j = candidate.safetyRatings) != null ? _j : null,
2084
+ safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null,
1760
2085
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1761
- finishMessage: (_k = candidate.finishMessage) != null ? _k : null,
2086
+ finishMessage: (_l = candidate.finishMessage) != null ? _l : null,
1762
2087
  serviceTier
1763
2088
  }
1764
2089
  };
@@ -1860,26 +2185,6 @@ function resolveGemini25ThinkingConfig({
1860
2185
  }
1861
2186
  return { thinkingBudget };
1862
2187
  }
1863
- function getToolCallsFromParts({
1864
- parts,
1865
- generateId: generateId3,
1866
- providerOptionsName
1867
- }) {
1868
- const functionCallParts = parts == null ? void 0 : parts.filter(
1869
- (part) => "functionCall" in part
1870
- );
1871
- return functionCallParts == null || functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
1872
- type: "tool-call",
1873
- toolCallId: generateId3(),
1874
- toolName: part.functionCall.name,
1875
- args: JSON.stringify(part.functionCall.args),
1876
- providerMetadata: part.thoughtSignature ? {
1877
- [providerOptionsName]: {
1878
- thoughtSignature: part.thoughtSignature
1879
- }
1880
- } : void 0
1881
- }));
1882
- }
1883
2188
  function extractSources({
1884
2189
  groundingMetadata,
1885
2190
  generateId: generateId3
@@ -2023,14 +2328,24 @@ var getGroundingMetadataSchema = () => z5.object({
2023
2328
  z5.object({})
2024
2329
  ]).nullish()
2025
2330
  });
2331
+ var partialArgSchema = z5.object({
2332
+ jsonPath: z5.string(),
2333
+ stringValue: z5.string().nullish(),
2334
+ numberValue: z5.number().nullish(),
2335
+ boolValue: z5.boolean().nullish(),
2336
+ nullValue: z5.unknown().nullish(),
2337
+ willContinue: z5.boolean().nullish()
2338
+ });
2026
2339
  var getContentSchema = () => z5.object({
2027
2340
  parts: z5.array(
2028
2341
  z5.union([
2029
2342
  // note: order matters since text can be fully empty
2030
2343
  z5.object({
2031
2344
  functionCall: z5.object({
2032
- name: z5.string(),
2033
- args: z5.unknown()
2345
+ name: z5.string().nullish(),
2346
+ args: z5.unknown().nullish(),
2347
+ partialArgs: z5.array(partialArgSchema).nullish(),
2348
+ willContinue: z5.boolean().nullish()
2034
2349
  }),
2035
2350
  thoughtSignature: z5.string().nullish()
2036
2351
  }),