@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.
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 ? "3.0.95" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.97" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -1672,7 +1672,7 @@ var GoogleGenerativeAILanguageModel = class {
1672
1672
  };
1673
1673
  }
1674
1674
  async doGenerate(options) {
1675
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1675
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1676
1676
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1677
1677
  const mergedHeaders = combineHeaders2(
1678
1678
  await resolve2(this.config.headers),
@@ -1714,7 +1714,7 @@ var GoogleGenerativeAILanguageModel = class {
1714
1714
  } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1715
1715
  content.push({
1716
1716
  type: "tool-result",
1717
- // Assumes a result directly follows its corresponding call part.
1717
+ // Results correspond to the most recent executable code part.
1718
1718
  toolCallId: lastCodeExecutionToolCallId,
1719
1719
  toolName: "code_execution",
1720
1720
  result: {
@@ -1722,7 +1722,6 @@ var GoogleGenerativeAILanguageModel = class {
1722
1722
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1723
1723
  }
1724
1724
  });
1725
- lastCodeExecutionToolCallId = void 0;
1726
1725
  } else if ("text" in part && part.text != null) {
1727
1726
  const thoughtSignatureMetadata = part.thoughtSignature ? {
1728
1727
  [providerOptionsName]: {
@@ -1847,7 +1846,8 @@ var GoogleGenerativeAILanguageModel = class {
1847
1846
  },
1848
1847
  request: { body: args },
1849
1848
  response: {
1850
- // TODO timestamp, model id, id
1849
+ // TODO timestamp, model id
1850
+ id: (_s = response.responseId) != null ? _s : void 0,
1851
1851
  headers: responseHeaders,
1852
1852
  body: rawResponse
1853
1853
  }
@@ -1881,6 +1881,7 @@ var GoogleGenerativeAILanguageModel = class {
1881
1881
  let lastUrlContextMetadata = null;
1882
1882
  const generateId3 = this.config.generateId;
1883
1883
  let hasToolCalls = false;
1884
+ let hasEmittedResponseMetadata = false;
1884
1885
  let currentTextBlockId = null;
1885
1886
  let currentReasoningBlockId = null;
1886
1887
  let blockCounter = 0;
@@ -1932,6 +1933,13 @@ var GoogleGenerativeAILanguageModel = class {
1932
1933
  return;
1933
1934
  }
1934
1935
  const value = chunk.value;
1936
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
1937
+ hasEmittedResponseMetadata = true;
1938
+ controller.enqueue({
1939
+ type: "response-metadata",
1940
+ id: value.responseId
1941
+ });
1942
+ }
1935
1943
  const usageMetadata = value.usageMetadata;
1936
1944
  if (usageMetadata != null) {
1937
1945
  usage = usageMetadata;
@@ -1984,7 +1992,6 @@ var GoogleGenerativeAILanguageModel = class {
1984
1992
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1985
1993
  }
1986
1994
  });
1987
- lastCodeExecutionToolCallId = void 0;
1988
1995
  }
1989
1996
  } else if ("text" in part && part.text != null) {
1990
1997
  const thoughtSignatureMetadata = part.thoughtSignature ? {
@@ -2518,6 +2525,7 @@ var getUrlContextMetadataSchema = () => z5.object({
2518
2525
  var responseSchema = lazySchema5(
2519
2526
  () => zodSchema5(
2520
2527
  z5.object({
2528
+ responseId: z5.string().nullish(),
2521
2529
  candidates: z5.array(
2522
2530
  z5.object({
2523
2531
  content: getContentSchema().nullish().or(z5.object({}).strict()),
@@ -2539,6 +2547,7 @@ var responseSchema = lazySchema5(
2539
2547
  var chunkSchema = lazySchema5(
2540
2548
  () => zodSchema5(
2541
2549
  z5.object({
2550
+ responseId: z5.string().nullish(),
2542
2551
  candidates: z5.array(
2543
2552
  z5.object({
2544
2553
  content: getContentSchema().nullish(),