@ai-sdk/google 4.0.18 → 4.0.19

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,12 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.19
4
+
5
+ ### Patch Changes
6
+
7
+ - a70b027: fix(provider/google): associate multiple code execution results with their tool call
8
+ - a3ce307: fix(provider/google): surface Gemini `responseId` as `response-metadata` (stream) and `response.id` (generate)
9
+
3
10
  ## 4.0.18
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -170,6 +170,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
170
170
  }[] | null | undefined;
171
171
  } | null | undefined;
172
172
  }[];
173
+ responseId?: string | null | undefined;
173
174
  usageMetadata?: {
174
175
  cachedContentTokenCount?: number | null | undefined;
175
176
  thoughtsTokenCount?: number | null | undefined;
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.18" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.19" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -1800,7 +1800,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1800
1800
  };
1801
1801
  }
1802
1802
  async doGenerate(options) {
1803
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1803
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1804
1804
  const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
1805
1805
  const wrapProviderMetadata = (payload) => Object.fromEntries(
1806
1806
  providerOptionsNames.map((name) => [name, payload])
@@ -1845,7 +1845,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1845
1845
  } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1846
1846
  content.push({
1847
1847
  type: "tool-result",
1848
- // Assumes a result directly follows its corresponding call part.
1848
+ // Results correspond to the most recent executable code part.
1849
1849
  toolCallId: lastCodeExecutionToolCallId,
1850
1850
  toolName: "code_execution",
1851
1851
  result: {
@@ -1853,7 +1853,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1853
1853
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1854
1854
  }
1855
1855
  });
1856
- lastCodeExecutionToolCallId = void 0;
1857
1856
  } else if ("text" in part && part.text != null) {
1858
1857
  const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
1859
1858
  thoughtSignature: part.thoughtSignature
@@ -1961,7 +1960,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1961
1960
  }),
1962
1961
  request: { body: args },
1963
1962
  response: {
1964
- // TODO timestamp, model id, id
1963
+ // TODO timestamp, model id
1964
+ id: (_s = response.responseId) != null ? _s : void 0,
1965
1965
  headers: responseHeaders,
1966
1966
  body: rawResponse
1967
1967
  }
@@ -1998,6 +1998,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1998
1998
  let lastUrlContextMetadata = null;
1999
1999
  const generateId3 = this.config.generateId;
2000
2000
  let hasToolCalls = false;
2001
+ let hasEmittedResponseMetadata = false;
2001
2002
  let currentTextBlockId = null;
2002
2003
  let currentReasoningBlockId = null;
2003
2004
  let blockCounter = 0;
@@ -2049,6 +2050,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2049
2050
  return;
2050
2051
  }
2051
2052
  const value = chunk.value;
2053
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
2054
+ hasEmittedResponseMetadata = true;
2055
+ controller.enqueue({
2056
+ type: "response-metadata",
2057
+ id: value.responseId
2058
+ });
2059
+ }
2052
2060
  const usageMetadata = value.usageMetadata;
2053
2061
  if (usageMetadata != null) {
2054
2062
  usage = usageMetadata;
@@ -2101,7 +2109,6 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2101
2109
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
2102
2110
  }
2103
2111
  });
2104
- lastCodeExecutionToolCallId = void 0;
2105
2112
  }
2106
2113
  } else if ("text" in part && part.text != null) {
2107
2114
  const thoughtSignatureMetadata = part.thoughtSignature ? wrapProviderMetadata({
@@ -2691,6 +2698,7 @@ var getUrlContextMetadataSchema = () => z5.object({
2691
2698
  var responseSchema = lazySchema5(
2692
2699
  () => zodSchema5(
2693
2700
  z5.object({
2701
+ responseId: z5.string().nullish(),
2694
2702
  candidates: z5.array(
2695
2703
  z5.object({
2696
2704
  content: getContentSchema().nullish().or(z5.object({}).strict()),
@@ -2712,6 +2720,7 @@ var responseSchema = lazySchema5(
2712
2720
  var chunkSchema = lazySchema5(
2713
2721
  () => zodSchema5(
2714
2722
  z5.object({
2723
+ responseId: z5.string().nullish(),
2715
2724
  candidates: z5.array(
2716
2725
  z5.object({
2717
2726
  content: getContentSchema().nullish(),