@depup/ai-sdk__google 4.0.45-depup.0 → 4.0.48-depup.0

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.48
4
+
5
+ ### Patch Changes
6
+
7
+ - 6c5a1ed: Inline local JSON Schema references in Google tool and structured-output schemas.
8
+
9
+ ## 4.0.47
10
+
11
+ ### Patch Changes
12
+
13
+ - e6087c9: fix: handle empty string tool call IDs
14
+ - Updated dependencies [e6087c9]
15
+ - @ai-sdk/provider-utils@5.0.28
16
+
17
+ ## 4.0.46
18
+
19
+ ### Patch Changes
20
+
21
+ - f69920a: fix(google): use low as the minimum reasoning level for full Gemini Flash 3.7 and later
22
+
3
23
  ## 4.0.45
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/ai-sdk__google
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.45 |
17
- | Processed | 2026-08-19 |
16
+ | Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.48 |
17
+ | Processed | 2026-08-21 |
18
18
  | Smoke test | failed |
19
19
  | Deps updated | 0 |
20
20
 
package/changes.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "bumped": {},
3
- "timestamp": "2026-08-19T00:14:27.664Z",
3
+ "timestamp": "2026-08-21T00:15:47.264Z",
4
4
  "totalUpdated": 0
5
5
  }
package/dist/index.js 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.45" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.48" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -303,21 +303,37 @@ import {
303
303
  UnsupportedFunctionalityError
304
304
  } from "@ai-sdk/provider";
305
305
  function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
306
+ const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
307
+ return convertJSONSchemaDefinition(jsonSchema, isRoot, {
308
+ definitions: rootSchema == null ? void 0 : rootSchema.definitions,
309
+ dollarDefinitions: rootSchema == null ? void 0 : rootSchema.$defs,
310
+ resolvingReferences: /* @__PURE__ */ new Set()
311
+ });
312
+ }
313
+ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
306
314
  if (jsonSchema == null) {
307
315
  return void 0;
308
316
  }
317
+ if (typeof jsonSchema === "boolean") {
318
+ return { type: "boolean", properties: {} };
319
+ }
320
+ if (jsonSchema.$ref != null) {
321
+ return convertJSONSchemaReference({
322
+ jsonSchema,
323
+ reference: jsonSchema.$ref,
324
+ isRoot,
325
+ referenceContext
326
+ });
327
+ }
309
328
  if (isEmptyObjectSchema(jsonSchema)) {
310
329
  if (isRoot) {
311
330
  return void 0;
312
331
  }
313
- if (typeof jsonSchema === "object" && jsonSchema.description) {
332
+ if (jsonSchema.description) {
314
333
  return { type: "object", description: jsonSchema.description };
315
334
  }
316
335
  return { type: "object" };
317
336
  }
318
- if (typeof jsonSchema === "boolean") {
319
- return { type: "boolean", properties: {} };
320
- }
321
337
  const {
322
338
  type,
323
339
  description,
@@ -359,18 +375,20 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
359
375
  if (properties != null) {
360
376
  result.properties = Object.entries(properties).reduce(
361
377
  (acc, [key, value]) => {
362
- acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
378
+ acc[key] = convertJSONSchemaDefinition(value, false, referenceContext);
363
379
  return acc;
364
380
  },
365
381
  {}
366
382
  );
367
383
  }
368
384
  if (items) {
369
- result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
385
+ result.items = Array.isArray(items) ? items.map(
386
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
387
+ ) : convertJSONSchemaDefinition(items, false, referenceContext);
370
388
  }
371
389
  if (allOf) {
372
390
  result.allOf = allOf.map(
373
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
391
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
374
392
  );
375
393
  }
376
394
  if (anyOf) {
@@ -381,9 +399,10 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
381
399
  (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
382
400
  );
383
401
  if (nonNullSchemas.length === 1) {
384
- const converted = convertJSONSchemaToOpenAPISchema(
402
+ const converted = convertJSONSchemaDefinition(
385
403
  nonNullSchemas[0],
386
- false
404
+ false,
405
+ referenceContext
387
406
  );
388
407
  if (typeof converted === "object") {
389
408
  result.nullable = true;
@@ -391,19 +410,19 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
391
410
  }
392
411
  } else {
393
412
  result.anyOf = nonNullSchemas.map(
394
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
413
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
395
414
  );
396
415
  result.nullable = true;
397
416
  }
398
417
  } else {
399
418
  result.anyOf = anyOf.map(
400
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
419
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
401
420
  );
402
421
  }
403
422
  }
404
423
  if (oneOf) {
405
424
  result.oneOf = oneOf.map(
406
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
425
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
407
426
  );
408
427
  }
409
428
  if (minLength !== void 0) {
@@ -411,6 +430,76 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
411
430
  }
412
431
  return result;
413
432
  }
433
+ function convertJSONSchemaReference({
434
+ jsonSchema,
435
+ reference,
436
+ isRoot,
437
+ referenceContext
438
+ }) {
439
+ const { definition, referenceKey } = getReferencedDefinition(
440
+ reference,
441
+ referenceContext
442
+ );
443
+ if (referenceContext.resolvingReferences.has(referenceKey)) {
444
+ throw new UnsupportedFunctionalityError({
445
+ functionality: `recursive JSON Schema reference: ${reference}`,
446
+ message: "Google schema conversion does not support recursive JSON Schema references."
447
+ });
448
+ }
449
+ const resolvingReferences = new Set(referenceContext.resolvingReferences);
450
+ resolvingReferences.add(referenceKey);
451
+ const { $ref: _reference, ...siblingSchema } = jsonSchema;
452
+ const resolvedSchema = typeof definition === "boolean" ? definition ? siblingSchema : false : { ...definition, ...siblingSchema };
453
+ return convertJSONSchemaDefinition(resolvedSchema, isRoot, {
454
+ ...referenceContext,
455
+ resolvingReferences
456
+ });
457
+ }
458
+ function getReferencedDefinition(reference, referenceContext) {
459
+ const definitionSources = [
460
+ {
461
+ prefix: "#/$defs/",
462
+ definitions: referenceContext.dollarDefinitions
463
+ },
464
+ {
465
+ prefix: "#/definitions/",
466
+ definitions: referenceContext.definitions
467
+ }
468
+ ];
469
+ const source = definitionSources.find(
470
+ ({ prefix }) => reference.startsWith(prefix)
471
+ );
472
+ const encodedDefinitionName = source ? reference.slice(source.prefix.length) : void 0;
473
+ if (source == null || encodedDefinitionName == null || encodedDefinitionName.length === 0 || encodedDefinitionName.includes("/")) {
474
+ throwUnsupportedReference(reference);
475
+ }
476
+ let decodedDefinitionName;
477
+ try {
478
+ decodedDefinitionName = decodeURIComponent(encodedDefinitionName);
479
+ } catch (e) {
480
+ throwUnsupportedReference(reference);
481
+ }
482
+ if (decodedDefinitionName.includes("/") || /~(?![01])/u.test(decodedDefinitionName) || source.definitions == null) {
483
+ throwUnsupportedReference(reference);
484
+ }
485
+ const definitionName = decodedDefinitionName.replace(
486
+ /~[01]/g,
487
+ (match) => match === "~1" ? "/" : "~"
488
+ );
489
+ if (!Object.prototype.hasOwnProperty.call(source.definitions, definitionName)) {
490
+ throwUnsupportedReference(reference);
491
+ }
492
+ return {
493
+ definition: source.definitions[definitionName],
494
+ referenceKey: `${source.prefix}${definitionName}`
495
+ };
496
+ }
497
+ function throwUnsupportedReference(reference) {
498
+ throw new UnsupportedFunctionalityError({
499
+ functionality: `JSON Schema reference: ${reference}`,
500
+ message: "Google schema conversion only supports references to direct children of root-level $defs or definitions."
501
+ });
502
+ }
414
503
  function addEnumToSchema({
415
504
  values,
416
505
  type,
@@ -1881,7 +1970,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1881
1970
  };
1882
1971
  }
1883
1972
  async doGenerate(options) {
1884
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1973
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1885
1974
  const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
1886
1975
  const wrapProviderMetadata = (payload) => Object.fromEntries(
1887
1976
  providerOptionsNames.map((name) => [name, payload])
@@ -1953,9 +2042,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1953
2042
  } else if ("functionCall" in part && part.functionCall.name != null) {
1954
2043
  content.push({
1955
2044
  type: "tool-call",
1956
- toolCallId: (_e = part.functionCall.id) != null ? _e : this.config.generateId(),
2045
+ toolCallId: part.functionCall.id || this.config.generateId(),
1957
2046
  toolName: part.functionCall.name,
1958
- input: JSON.stringify((_f = part.functionCall.args) != null ? _f : {}),
2047
+ input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
1959
2048
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1960
2049
  thoughtSignature: part.thoughtSignature
1961
2050
  }) : void 0
@@ -1972,13 +2061,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1972
2061
  }) : void 0
1973
2062
  });
1974
2063
  } else if ("toolCall" in part && part.toolCall) {
1975
- const toolCallId = (_g = part.toolCall.id) != null ? _g : this.config.generateId();
2064
+ const toolCallId = part.toolCall.id || this.config.generateId();
1976
2065
  lastServerToolCallId = toolCallId;
1977
2066
  content.push({
1978
2067
  type: "tool-call",
1979
2068
  toolCallId,
1980
2069
  toolName: `server:${part.toolCall.toolType}`,
1981
- input: JSON.stringify((_h = part.toolCall.args) != null ? _h : {}),
2070
+ input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1982
2071
  providerExecuted: true,
1983
2072
  dynamic: true,
1984
2073
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
@@ -1991,12 +2080,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1991
2080
  })
1992
2081
  });
1993
2082
  } else if ("toolResponse" in part && part.toolResponse) {
1994
- const responseToolCallId = (_i = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _i : this.config.generateId();
2083
+ const responseToolCallId = lastServerToolCallId || part.toolResponse.id || this.config.generateId();
1995
2084
  content.push({
1996
2085
  type: "tool-result",
1997
2086
  toolCallId: responseToolCallId,
1998
2087
  toolName: `server:${part.toolResponse.toolType}`,
1999
- result: (_j = part.toolResponse.response) != null ? _j : {},
2088
+ result: (_g = part.toolResponse.response) != null ? _g : {},
2000
2089
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
2001
2090
  thoughtSignature: part.thoughtSignature,
2002
2091
  serverToolCallId: responseToolCallId,
@@ -2009,10 +2098,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2009
2098
  lastServerToolCallId = void 0;
2010
2099
  }
2011
2100
  }
2012
- const sources = (_k = extractSources({
2101
+ const sources = (_h = extractSources({
2013
2102
  groundingMetadata: candidate.groundingMetadata,
2014
2103
  generateId: this.config.generateId
2015
- })) != null ? _k : [];
2104
+ })) != null ? _h : [];
2016
2105
  for (const source of sources) {
2017
2106
  content.push(source);
2018
2107
  }
@@ -2026,23 +2115,23 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2026
2115
  (part) => part.type === "tool-call" && !part.providerExecuted
2027
2116
  )
2028
2117
  }),
2029
- raw: (_l = candidate.finishReason) != null ? _l : void 0
2118
+ raw: (_i = candidate.finishReason) != null ? _i : void 0
2030
2119
  },
2031
2120
  usage: convertGoogleUsage(usageMetadata),
2032
2121
  warnings,
2033
2122
  providerMetadata: wrapProviderMetadata({
2034
- promptFeedback: (_m = response.promptFeedback) != null ? _m : null,
2035
- groundingMetadata: (_n = candidate.groundingMetadata) != null ? _n : null,
2036
- urlContextMetadata: (_o = candidate.urlContextMetadata) != null ? _o : null,
2037
- safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
2123
+ promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
2124
+ groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
2125
+ urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
2126
+ safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
2038
2127
  usageMetadata: usageMetadata != null ? usageMetadata : null,
2039
- finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
2040
- serviceTier: (_r = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _r : null
2128
+ finishMessage: (_n = candidate.finishMessage) != null ? _n : null,
2129
+ serviceTier: (_o = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _o : null
2041
2130
  }),
2042
2131
  request: { body: args },
2043
2132
  response: {
2044
2133
  // TODO timestamp, model id
2045
- id: (_s = response.responseId) != null ? _s : void 0,
2134
+ id: (_p = response.responseId) != null ? _p : void 0,
2046
2135
  headers: responseHeaders,
2047
2136
  body: rawResponse
2048
2137
  }
@@ -2122,7 +2211,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2122
2211
  controller.enqueue({ type: "stream-start", warnings });
2123
2212
  },
2124
2213
  transform(chunk, controller) {
2125
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2214
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2126
2215
  if (options.includeRawChunks) {
2127
2216
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2128
2217
  }
@@ -2276,7 +2365,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2276
2365
  providerMetadata: fileMeta
2277
2366
  });
2278
2367
  } else if ("toolCall" in part && part.toolCall) {
2279
- const toolCallId = (_e = part.toolCall.id) != null ? _e : generateId3();
2368
+ const toolCallId = part.toolCall.id || generateId3();
2280
2369
  lastServerToolCallId = toolCallId;
2281
2370
  const serverMeta = wrapProviderMetadata({
2282
2371
  ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
@@ -2287,13 +2376,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2287
2376
  type: "tool-call",
2288
2377
  toolCallId,
2289
2378
  toolName: `server:${part.toolCall.toolType}`,
2290
- input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
2379
+ input: JSON.stringify((_e = part.toolCall.args) != null ? _e : {}),
2291
2380
  providerExecuted: true,
2292
2381
  dynamic: true,
2293
2382
  providerMetadata: serverMeta
2294
2383
  });
2295
2384
  } else if ("toolResponse" in part && part.toolResponse) {
2296
- const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : generateId3();
2385
+ const responseToolCallId = lastServerToolCallId || part.toolResponse.id || generateId3();
2297
2386
  const serverMeta = wrapProviderMetadata({
2298
2387
  ...part.thoughtSignature ? { thoughtSignature: part.thoughtSignature } : {},
2299
2388
  serverToolCallId: responseToolCallId,
@@ -2303,7 +2392,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2303
2392
  type: "tool-result",
2304
2393
  toolCallId: responseToolCallId,
2305
2394
  toolName: `server:${part.toolResponse.toolType}`,
2306
- result: (_h = part.toolResponse.response) != null ? _h : {},
2395
+ result: (_f = part.toolResponse.response) != null ? _f : {},
2307
2396
  providerMetadata: serverMeta
2308
2397
  });
2309
2398
  lastServerToolCallId = void 0;
@@ -2320,7 +2409,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2320
2409
  const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
2321
2410
  if (isStreamingChunk) {
2322
2411
  if (part.functionCall.name != null) {
2323
- const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
2412
+ const toolCallId = part.functionCall.id || generateId3();
2324
2413
  const accumulator = new GoogleJSONAccumulator();
2325
2414
  activeStreamingToolCalls.push({
2326
2415
  toolCallId,
@@ -2368,9 +2457,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2368
2457
  } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
2369
2458
  finishActiveStreamingToolCall(controller);
2370
2459
  } else if (isCompleteCall) {
2371
- const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
2460
+ const toolCallId = part.functionCall.id || generateId3();
2372
2461
  const toolName = part.functionCall.name;
2373
- const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_k = part.functionCall.args) != null ? _k : {});
2462
+ const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_g = part.functionCall.args) != null ? _g : {});
2374
2463
  controller.enqueue({
2375
2464
  type: "tool-input-start",
2376
2465
  id: toolCallId,
@@ -2397,7 +2486,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2397
2486
  });
2398
2487
  hasToolCalls = true;
2399
2488
  } else if (isNoArgsCompleteCall) {
2400
- const toolCallId = (_l = part.functionCall.id) != null ? _l : generateId3();
2489
+ const toolCallId = part.functionCall.id || generateId3();
2401
2490
  const toolName = part.functionCall.name;
2402
2491
  controller.enqueue({
2403
2492
  type: "tool-input-start",
@@ -2430,13 +2519,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2430
2519
  raw: candidate.finishReason
2431
2520
  };
2432
2521
  providerMetadata = wrapProviderMetadata({
2433
- promptFeedback: (_m = value.promptFeedback) != null ? _m : null,
2522
+ promptFeedback: (_h = value.promptFeedback) != null ? _h : null,
2434
2523
  groundingMetadata: lastGroundingMetadata,
2435
2524
  urlContextMetadata: lastUrlContextMetadata,
2436
- safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
2525
+ safetyRatings: (_i = candidate.safetyRatings) != null ? _i : null,
2437
2526
  usageMetadata: usageMetadata != null ? usageMetadata : null,
2438
- finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
2439
- serviceTier: (_p = usage == null ? void 0 : usage.serviceTier) != null ? _p : null
2527
+ finishMessage: (_j = candidate.finishMessage) != null ? _j : null,
2528
+ serviceTier: (_k = usage == null ? void 0 : usage.serviceTier) != null ? _k : null
2440
2529
  });
2441
2530
  }
2442
2531
  },
@@ -2495,7 +2584,7 @@ function resolveGemini3ThinkingConfig({
2495
2584
  modelId,
2496
2585
  warnings
2497
2586
  }) {
2498
- const minimumThinkingLevel = /(^|\/)gemini-3\.7-flash$/i.test(modelId) ? "low" : "minimal";
2587
+ const minimumThinkingLevel = getMinimumThinkingLevelForGemini3Model(modelId);
2499
2588
  if (reasoning === "none") {
2500
2589
  return { thinkingLevel: minimumThinkingLevel };
2501
2590
  }
@@ -2515,6 +2604,22 @@ function resolveGemini3ThinkingConfig({
2515
2604
  }
2516
2605
  return { thinkingLevel };
2517
2606
  }
2607
+ function getMinimumThinkingLevelForGemini3Model(modelId) {
2608
+ var _a;
2609
+ const modelName = (_a = modelId.split("/").at(-1)) == null ? void 0 : _a.toLowerCase();
2610
+ if (modelName === "gemini-flash-latest") {
2611
+ return "low";
2612
+ }
2613
+ const versionMatch = /^gemini-(\d+)\.(\d+)-flash(?:$|-(?!lite(?:-|$)))/.exec(
2614
+ modelName != null ? modelName : ""
2615
+ );
2616
+ if (versionMatch == null) {
2617
+ return "minimal";
2618
+ }
2619
+ const majorVersion = Number(versionMatch[1]);
2620
+ const minorVersion = Number(versionMatch[2]);
2621
+ return majorVersion > 3 || majorVersion === 3 && minorVersion >= 7 ? "low" : "minimal";
2622
+ }
2518
2623
  function resolveGemini25ThinkingConfig({
2519
2624
  reasoning,
2520
2625
  modelId,
@@ -4401,7 +4506,7 @@ function buildGoogleInteractionsStreamTransform({
4401
4506
  controller.enqueue({ type: "stream-start", warnings });
4402
4507
  },
4403
4508
  transform(chunk, controller) {
4404
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
4509
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
4405
4510
  if (includeRawChunks) {
4406
4511
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
4407
4512
  }
@@ -4492,8 +4597,8 @@ function buildGoogleInteractionsStreamTransform({
4492
4597
  }
4493
4598
  }
4494
4599
  } else if (stepType === "function_call") {
4495
- const toolCallId = (_b = step == null ? void 0 : step.id) != null ? _b : blockId;
4496
- const toolName = (_c = step == null ? void 0 : step.name) != null ? _c : "unknown";
4600
+ const toolCallId = (step == null ? void 0 : step.id) || blockId;
4601
+ const toolName = (_b = step == null ? void 0 : step.name) != null ? _b : "unknown";
4497
4602
  hasFunctionCall = true;
4498
4603
  const state = {
4499
4604
  kind: "function_call",
@@ -4510,28 +4615,28 @@ function buildGoogleInteractionsStreamTransform({
4510
4615
  toolName
4511
4616
  });
4512
4617
  } else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
4513
- const toolName = stepType === "mcp_server_tool_call" ? (_d = step == null ? void 0 : step.name) != null ? _d : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
4514
- const toolCallId = (_e = step == null ? void 0 : step.id) != null ? _e : blockId;
4618
+ const toolName = stepType === "mcp_server_tool_call" ? (_c = step == null ? void 0 : step.name) != null ? _c : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
4619
+ const toolCallId = (step == null ? void 0 : step.id) || blockId;
4515
4620
  const state = {
4516
4621
  kind: "builtin_tool_call",
4517
4622
  id: blockId,
4518
4623
  blockType: stepType,
4519
4624
  toolCallId,
4520
4625
  toolName,
4521
- arguments: (_f = step == null ? void 0 : step.arguments) != null ? _f : {},
4626
+ arguments: (_d = step == null ? void 0 : step.arguments) != null ? _d : {},
4522
4627
  callEmitted: false
4523
4628
  };
4524
4629
  openBlocks.set(index, state);
4525
4630
  } else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
4526
- const toolName = stepType === "mcp_server_tool_result" ? (_g = step == null ? void 0 : step.name) != null ? _g : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
4527
- const callId = (_h = step == null ? void 0 : step.call_id) != null ? _h : blockId;
4631
+ const toolName = stepType === "mcp_server_tool_result" ? (_e = step == null ? void 0 : step.name) != null ? _e : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
4632
+ const callId = (step == null ? void 0 : step.call_id) || blockId;
4528
4633
  const state = {
4529
4634
  kind: "builtin_tool_result",
4530
4635
  id: blockId,
4531
4636
  blockType: stepType,
4532
4637
  callId,
4533
4638
  toolName,
4534
- result: (_i = step == null ? void 0 : step.result) != null ? _i : null,
4639
+ result: (_f = step == null ? void 0 : step.result) != null ? _f : null,
4535
4640
  ...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
4536
4641
  resultEmitted: false
4537
4642
  };
@@ -4545,7 +4650,7 @@ function buildGoogleInteractionsStreamTransform({
4545
4650
  const event = value;
4546
4651
  let open = openBlocks.get(event.index);
4547
4652
  if (open == null) break;
4548
- const dtype = (_j = event.delta) == null ? void 0 : _j.type;
4653
+ const dtype = (_g = event.delta) == null ? void 0 : _g.type;
4549
4654
  if (open.kind === "pending_model_output") {
4550
4655
  if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
4551
4656
  const promoted = {
@@ -4566,14 +4671,14 @@ function buildGoogleInteractionsStreamTransform({
4566
4671
  if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
4567
4672
  controller.enqueue({
4568
4673
  type: "file",
4569
- mediaType: (_k = imageDelta.mime_type) != null ? _k : "image/png",
4674
+ mediaType: (_h = imageDelta.mime_type) != null ? _h : "image/png",
4570
4675
  data: { type: "data", data: imageDelta.data },
4571
4676
  ...providerMetadata ? { providerMetadata } : {}
4572
4677
  });
4573
4678
  } else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
4574
4679
  controller.enqueue({
4575
4680
  type: "file",
4576
- mediaType: (_l = imageDelta.mime_type) != null ? _l : "image/png",
4681
+ mediaType: (_i = imageDelta.mime_type) != null ? _i : "image/png",
4577
4682
  data: { type: "url", url: new URL(imageDelta.uri) },
4578
4683
  ...providerMetadata ? { providerMetadata } : {}
4579
4684
  });
@@ -4592,14 +4697,14 @@ function buildGoogleInteractionsStreamTransform({
4592
4697
  if ((videoDelta == null ? void 0 : videoDelta.data) != null && videoDelta.data.length > 0) {
4593
4698
  controller.enqueue({
4594
4699
  type: "file",
4595
- mediaType: (_m = videoDelta.mime_type) != null ? _m : "video/mp4",
4700
+ mediaType: (_j = videoDelta.mime_type) != null ? _j : "video/mp4",
4596
4701
  data: { type: "data", data: videoDelta.data },
4597
4702
  ...providerMetadata ? { providerMetadata } : {}
4598
4703
  });
4599
4704
  } else if ((videoDelta == null ? void 0 : videoDelta.uri) != null && videoDelta.uri.length > 0) {
4600
4705
  controller.enqueue({
4601
4706
  type: "file",
4602
- mediaType: (_n = videoDelta.mime_type) != null ? _n : "video/mp4",
4707
+ mediaType: (_k = videoDelta.mime_type) != null ? _k : "video/mp4",
4603
4708
  data: { type: "url", url: new URL(videoDelta.uri) },
4604
4709
  ...providerMetadata ? { providerMetadata } : {}
4605
4710
  });
@@ -4608,7 +4713,7 @@ function buildGoogleInteractionsStreamTransform({
4608
4713
  }
4609
4714
  const delta = event.delta;
4610
4715
  if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
4611
- const text = (_o = delta.text) != null ? _o : "";
4716
+ const text = (_l = delta.text) != null ? _l : "";
4612
4717
  if (text.length > 0) {
4613
4718
  controller.enqueue({
4614
4719
  type: "text-delta",
@@ -4658,7 +4763,7 @@ function buildGoogleInteractionsStreamTransform({
4658
4763
  delta: slice
4659
4764
  });
4660
4765
  }
4661
- if (delta.id != null) {
4766
+ if (delta.id != null && delta.id.length > 0) {
4662
4767
  open.toolCallId = delta.id;
4663
4768
  }
4664
4769
  if (delta.signature != null) {
@@ -4666,7 +4771,9 @@ function buildGoogleInteractionsStreamTransform({
4666
4771
  }
4667
4772
  hasFunctionCall = true;
4668
4773
  } else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
4669
- if (delta.id != null) open.toolCallId = delta.id;
4774
+ if (delta.id != null && delta.id.length > 0) {
4775
+ open.toolCallId = delta.id;
4776
+ }
4670
4777
  if (delta.arguments != null && typeof delta.arguments === "object") {
4671
4778
  open.arguments = delta.arguments;
4672
4779
  }
@@ -4674,7 +4781,9 @@ function buildGoogleInteractionsStreamTransform({
4674
4781
  open.toolName = delta.name;
4675
4782
  }
4676
4783
  } else if (open.kind === "builtin_tool_result" && (delta == null ? void 0 : delta.type) === open.blockType) {
4677
- if (delta.call_id != null) open.callId = delta.call_id;
4784
+ if (delta.call_id != null && delta.call_id.length > 0) {
4785
+ open.callId = delta.call_id;
4786
+ }
4678
4787
  if (delta.result !== void 0) open.result = delta.result;
4679
4788
  if (delta.is_error != null) open.isError = delta.is_error;
4680
4789
  if (delta.name != null && open.blockType === "mcp_server_tool_result") {
@@ -4711,14 +4820,14 @@ function buildGoogleInteractionsStreamTransform({
4711
4820
  if (open.data != null && open.data.length > 0) {
4712
4821
  controller.enqueue({
4713
4822
  type: "file",
4714
- mediaType: (_p = open.mimeType) != null ? _p : "image/png",
4823
+ mediaType: (_m = open.mimeType) != null ? _m : "image/png",
4715
4824
  data: { type: "data", data: open.data },
4716
4825
  ...providerMetadata ? { providerMetadata } : {}
4717
4826
  });
4718
4827
  } else if (open.uri != null && open.uri.length > 0) {
4719
4828
  controller.enqueue({
4720
4829
  type: "file",
4721
- mediaType: (_q = open.mimeType) != null ? _q : "image/png",
4830
+ mediaType: (_n = open.mimeType) != null ? _n : "image/png",
4722
4831
  data: { type: "url", url: new URL(open.uri) },
4723
4832
  ...providerMetadata ? { providerMetadata } : {}
4724
4833
  });
@@ -4745,7 +4854,7 @@ function buildGoogleInteractionsStreamTransform({
4745
4854
  type: "tool-call",
4746
4855
  toolCallId: open.toolCallId,
4747
4856
  toolName: open.toolName,
4748
- input: JSON.stringify((_r = open.arguments) != null ? _r : {}),
4857
+ input: JSON.stringify((_o = open.arguments) != null ? _o : {}),
4749
4858
  providerExecuted: true
4750
4859
  });
4751
4860
  open.callEmitted = true;
@@ -4754,7 +4863,7 @@ function buildGoogleInteractionsStreamTransform({
4754
4863
  type: "tool-result",
4755
4864
  toolCallId: open.callId,
4756
4865
  toolName: open.toolName,
4757
- result: (_s = open.result) != null ? _s : null
4866
+ result: (_p = open.result) != null ? _p : null
4758
4867
  });
4759
4868
  open.resultEmitted = true;
4760
4869
  const sources = builtinToolResultToSources({
@@ -4808,7 +4917,7 @@ function buildGoogleInteractionsStreamTransform({
4808
4917
  case "error": {
4809
4918
  const event = value;
4810
4919
  finishStatus = "failed";
4811
- const errorPayload = (_t = event.error) != null ? _t : {
4920
+ const errorPayload = (_q = event.error) != null ? _q : {
4812
4921
  message: "Unknown interaction error"
4813
4922
  };
4814
4923
  controller.enqueue({ type: "error", error: errorPayload });
@@ -5796,7 +5905,7 @@ function parseGoogleInteractionsOutputs({
5796
5905
  generateId: generateId3,
5797
5906
  interactionId
5798
5907
  }) {
5799
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
5908
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5800
5909
  const content = [];
5801
5910
  let hasFunctionCall = false;
5802
5911
  if (steps == null) {
@@ -5903,19 +6012,19 @@ function parseGoogleInteractionsOutputs({
5903
6012
  const input = JSON.stringify((_i = call.arguments) != null ? _i : {});
5904
6013
  content.push({
5905
6014
  type: "tool-call",
5906
- toolCallId: (_j = call.id) != null ? _j : generateId3(),
6015
+ toolCallId: call.id || generateId3(),
5907
6016
  toolName,
5908
6017
  input,
5909
6018
  providerExecuted: true
5910
6019
  });
5911
6020
  } else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
5912
6021
  const result = step;
5913
- const toolName = type === "mcp_server_tool_result" ? (_k = result.name) != null ? _k : "mcp_server_tool" : builtinToolNameFromResultType2(type);
6022
+ const toolName = type === "mcp_server_tool_result" ? (_j = result.name) != null ? _j : "mcp_server_tool" : builtinToolNameFromResultType2(type);
5914
6023
  content.push({
5915
6024
  type: "tool-result",
5916
- toolCallId: (_l = result.call_id) != null ? _l : generateId3(),
6025
+ toolCallId: result.call_id || generateId3(),
5917
6026
  toolName,
5918
- result: (_m = result.result) != null ? _m : null
6027
+ result: (_k = result.result) != null ? _k : null
5919
6028
  });
5920
6029
  const sources = builtinToolResultToSources({
5921
6030
  block: step,