@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.
@@ -199,6 +199,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
199
199
  }[] | null | undefined;
200
200
  } | null | undefined;
201
201
  }[];
202
+ responseId?: string | null | undefined;
202
203
  usageMetadata?: {
203
204
  cachedContentTokenCount?: number | null | undefined;
204
205
  thoughtsTokenCount?: number | null | undefined;
@@ -199,6 +199,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
199
199
  }[] | null | undefined;
200
200
  } | null | undefined;
201
201
  }[];
202
+ responseId?: string | null | undefined;
202
203
  usageMetadata?: {
203
204
  cachedContentTokenCount?: number | null | undefined;
204
205
  thoughtsTokenCount?: number | null | undefined;
@@ -1464,7 +1464,7 @@ var GoogleGenerativeAILanguageModel = class {
1464
1464
  };
1465
1465
  }
1466
1466
  async doGenerate(options) {
1467
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1467
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1468
1468
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1469
1469
  const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
1470
1470
  await (0, import_provider_utils4.resolve)(this.config.headers),
@@ -1506,7 +1506,7 @@ var GoogleGenerativeAILanguageModel = class {
1506
1506
  } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1507
1507
  content.push({
1508
1508
  type: "tool-result",
1509
- // Assumes a result directly follows its corresponding call part.
1509
+ // Results correspond to the most recent executable code part.
1510
1510
  toolCallId: lastCodeExecutionToolCallId,
1511
1511
  toolName: "code_execution",
1512
1512
  result: {
@@ -1514,7 +1514,6 @@ var GoogleGenerativeAILanguageModel = class {
1514
1514
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1515
1515
  }
1516
1516
  });
1517
- lastCodeExecutionToolCallId = void 0;
1518
1517
  } else if ("text" in part && part.text != null) {
1519
1518
  const thoughtSignatureMetadata = part.thoughtSignature ? {
1520
1519
  [providerOptionsName]: {
@@ -1639,7 +1638,8 @@ var GoogleGenerativeAILanguageModel = class {
1639
1638
  },
1640
1639
  request: { body: args },
1641
1640
  response: {
1642
- // TODO timestamp, model id, id
1641
+ // TODO timestamp, model id
1642
+ id: (_s = response.responseId) != null ? _s : void 0,
1643
1643
  headers: responseHeaders,
1644
1644
  body: rawResponse
1645
1645
  }
@@ -1673,6 +1673,7 @@ var GoogleGenerativeAILanguageModel = class {
1673
1673
  let lastUrlContextMetadata = null;
1674
1674
  const generateId2 = this.config.generateId;
1675
1675
  let hasToolCalls = false;
1676
+ let hasEmittedResponseMetadata = false;
1676
1677
  let currentTextBlockId = null;
1677
1678
  let currentReasoningBlockId = null;
1678
1679
  let blockCounter = 0;
@@ -1724,6 +1725,13 @@ var GoogleGenerativeAILanguageModel = class {
1724
1725
  return;
1725
1726
  }
1726
1727
  const value = chunk.value;
1728
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
1729
+ hasEmittedResponseMetadata = true;
1730
+ controller.enqueue({
1731
+ type: "response-metadata",
1732
+ id: value.responseId
1733
+ });
1734
+ }
1727
1735
  const usageMetadata = value.usageMetadata;
1728
1736
  if (usageMetadata != null) {
1729
1737
  usage = usageMetadata;
@@ -1776,7 +1784,6 @@ var GoogleGenerativeAILanguageModel = class {
1776
1784
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1777
1785
  }
1778
1786
  });
1779
- lastCodeExecutionToolCallId = void 0;
1780
1787
  }
1781
1788
  } else if ("text" in part && part.text != null) {
1782
1789
  const thoughtSignatureMetadata = part.thoughtSignature ? {
@@ -2310,6 +2317,7 @@ var getUrlContextMetadataSchema = () => import_v43.z.object({
2310
2317
  var responseSchema = (0, import_provider_utils4.lazySchema)(
2311
2318
  () => (0, import_provider_utils4.zodSchema)(
2312
2319
  import_v43.z.object({
2320
+ responseId: import_v43.z.string().nullish(),
2313
2321
  candidates: import_v43.z.array(
2314
2322
  import_v43.z.object({
2315
2323
  content: getContentSchema().nullish().or(import_v43.z.object({}).strict()),
@@ -2331,6 +2339,7 @@ var responseSchema = (0, import_provider_utils4.lazySchema)(
2331
2339
  var chunkSchema = (0, import_provider_utils4.lazySchema)(
2332
2340
  () => (0, import_provider_utils4.zodSchema)(
2333
2341
  import_v43.z.object({
2342
+ responseId: import_v43.z.string().nullish(),
2334
2343
  candidates: import_v43.z.array(
2335
2344
  import_v43.z.object({
2336
2345
  content: getContentSchema().nullish(),