@ai-sdk/google 4.0.18 → 4.0.20

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.
@@ -208,6 +208,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
208
208
  }[] | null | undefined;
209
209
  } | null | undefined;
210
210
  }[];
211
+ responseId?: string | null | undefined;
211
212
  usageMetadata?: {
212
213
  cachedContentTokenCount?: number | null | undefined;
213
214
  thoughtsTokenCount?: number | null | undefined;
@@ -1571,7 +1571,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1571
1571
  };
1572
1572
  }
1573
1573
  async doGenerate(options) {
1574
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1574
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1575
1575
  const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
1576
1576
  const wrapProviderMetadata = (payload) => Object.fromEntries(
1577
1577
  providerOptionsNames.map((name) => [name, payload])
@@ -1616,7 +1616,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1616
1616
  } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1617
1617
  content.push({
1618
1618
  type: "tool-result",
1619
- // Assumes a result directly follows its corresponding call part.
1619
+ // Results correspond to the most recent executable code part.
1620
1620
  toolCallId: lastCodeExecutionToolCallId,
1621
1621
  toolName: "code_execution",
1622
1622
  result: {
@@ -1624,7 +1624,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1624
1624
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1625
1625
  }
1626
1626
  });
1627
- lastCodeExecutionToolCallId = void 0;
1628
1627
  } else if ("text" in part && part.text != null) {
1629
1628
  const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
1630
1629
  thoughtSignature: part.thoughtSignature
@@ -1732,7 +1731,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1732
1731
  }),
1733
1732
  request: { body: args },
1734
1733
  response: {
1735
- // TODO timestamp, model id, id
1734
+ // TODO timestamp, model id
1735
+ id: (_s = response.responseId) != null ? _s : void 0,
1736
1736
  headers: responseHeaders,
1737
1737
  body: rawResponse
1738
1738
  }
@@ -1769,6 +1769,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1769
1769
  let lastUrlContextMetadata = null;
1770
1770
  const generateId2 = this.config.generateId;
1771
1771
  let hasToolCalls = false;
1772
+ let hasEmittedResponseMetadata = false;
1772
1773
  let currentTextBlockId = null;
1773
1774
  let currentReasoningBlockId = null;
1774
1775
  let blockCounter = 0;
@@ -1820,6 +1821,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1820
1821
  return;
1821
1822
  }
1822
1823
  const value = chunk.value;
1824
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
1825
+ hasEmittedResponseMetadata = true;
1826
+ controller.enqueue({
1827
+ type: "response-metadata",
1828
+ id: value.responseId
1829
+ });
1830
+ }
1823
1831
  const usageMetadata = value.usageMetadata;
1824
1832
  if (usageMetadata != null) {
1825
1833
  usage = usageMetadata;
@@ -1872,7 +1880,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1872
1880
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1873
1881
  }
1874
1882
  });
1875
- lastCodeExecutionToolCallId = void 0;
1876
1883
  }
1877
1884
  } else if ("text" in part && part.text != null) {
1878
1885
  const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
@@ -2462,6 +2469,7 @@ var getUrlContextMetadataSchema = () => z3.object({
2462
2469
  var responseSchema = lazySchema3(
2463
2470
  () => zodSchema3(
2464
2471
  z3.object({
2472
+ responseId: z3.string().nullish(),
2465
2473
  candidates: z3.array(
2466
2474
  z3.object({
2467
2475
  content: getContentSchema().nullish().or(z3.object({}).strict()),
@@ -2483,6 +2491,7 @@ var responseSchema = lazySchema3(
2483
2491
  var chunkSchema = lazySchema3(
2484
2492
  () => zodSchema3(
2485
2493
  z3.object({
2494
+ responseId: z3.string().nullish(),
2486
2495
  candidates: z3.array(
2487
2496
  z3.object({
2488
2497
  content: getContentSchema().nullish(),