@ai-sdk/google 3.0.95 → 3.0.97

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.
@@ -1455,7 +1455,7 @@ var GoogleGenerativeAILanguageModel = class {
1455
1455
  };
1456
1456
  }
1457
1457
  async doGenerate(options) {
1458
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1458
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1459
1459
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1460
1460
  const mergedHeaders = combineHeaders(
1461
1461
  await resolve(this.config.headers),
@@ -1497,7 +1497,7 @@ var GoogleGenerativeAILanguageModel = class {
1497
1497
  } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1498
1498
  content.push({
1499
1499
  type: "tool-result",
1500
- // Assumes a result directly follows its corresponding call part.
1500
+ // Results correspond to the most recent executable code part.
1501
1501
  toolCallId: lastCodeExecutionToolCallId,
1502
1502
  toolName: "code_execution",
1503
1503
  result: {
@@ -1505,7 +1505,6 @@ var GoogleGenerativeAILanguageModel = class {
1505
1505
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1506
1506
  }
1507
1507
  });
1508
- lastCodeExecutionToolCallId = void 0;
1509
1508
  } else if ("text" in part && part.text != null) {
1510
1509
  const thoughtSignatureMetadata = part.thoughtSignature ? {
1511
1510
  [providerOptionsName]: {
@@ -1630,7 +1629,8 @@ var GoogleGenerativeAILanguageModel = class {
1630
1629
  },
1631
1630
  request: { body: args },
1632
1631
  response: {
1633
- // TODO timestamp, model id, id
1632
+ // TODO timestamp, model id
1633
+ id: (_s = response.responseId) != null ? _s : void 0,
1634
1634
  headers: responseHeaders,
1635
1635
  body: rawResponse
1636
1636
  }
@@ -1664,6 +1664,7 @@ var GoogleGenerativeAILanguageModel = class {
1664
1664
  let lastUrlContextMetadata = null;
1665
1665
  const generateId2 = this.config.generateId;
1666
1666
  let hasToolCalls = false;
1667
+ let hasEmittedResponseMetadata = false;
1667
1668
  let currentTextBlockId = null;
1668
1669
  let currentReasoningBlockId = null;
1669
1670
  let blockCounter = 0;
@@ -1715,6 +1716,13 @@ var GoogleGenerativeAILanguageModel = class {
1715
1716
  return;
1716
1717
  }
1717
1718
  const value = chunk.value;
1719
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
1720
+ hasEmittedResponseMetadata = true;
1721
+ controller.enqueue({
1722
+ type: "response-metadata",
1723
+ id: value.responseId
1724
+ });
1725
+ }
1718
1726
  const usageMetadata = value.usageMetadata;
1719
1727
  if (usageMetadata != null) {
1720
1728
  usage = usageMetadata;
@@ -1767,7 +1775,6 @@ var GoogleGenerativeAILanguageModel = class {
1767
1775
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1768
1776
  }
1769
1777
  });
1770
- lastCodeExecutionToolCallId = void 0;
1771
1778
  }
1772
1779
  } else if ("text" in part && part.text != null) {
1773
1780
  const thoughtSignatureMetadata = part.thoughtSignature ? {
@@ -2301,6 +2308,7 @@ var getUrlContextMetadataSchema = () => z3.object({
2301
2308
  var responseSchema = lazySchema3(
2302
2309
  () => zodSchema3(
2303
2310
  z3.object({
2311
+ responseId: z3.string().nullish(),
2304
2312
  candidates: z3.array(
2305
2313
  z3.object({
2306
2314
  content: getContentSchema().nullish().or(z3.object({}).strict()),
@@ -2322,6 +2330,7 @@ var responseSchema = lazySchema3(
2322
2330
  var chunkSchema = lazySchema3(
2323
2331
  () => zodSchema3(
2324
2332
  z3.object({
2333
+ responseId: z3.string().nullish(),
2325
2334
  candidates: z3.array(
2326
2335
  z3.object({
2327
2336
  content: getContentSchema().nullish(),