@ai-sdk/google 4.0.0-canary.51 → 4.0.0-canary.53

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,24 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.0-canary.53
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [2427d88]
8
+ - @ai-sdk/provider-utils@5.0.0-canary.33
9
+
10
+ ## 4.0.0-canary.52
11
+
12
+ ### Patch Changes
13
+
14
+ - cfca634: fix(google): emit Vertex no-args streaming tool calls and preserve thoughtSignature
15
+
16
+ Vertex emits a no-args function call as a single chunk shaped `{ functionCall: { name: 'X' } }` with no `args`, no `partialArgs`, and no `willContinue`. The streaming parser had no branch for this shape, so the call was dropped along with any `thoughtSignature` it carried. For Gemini 3 thinking models this caused the next multi-turn step to 400 with `missing thought_signature`. The unary (`doGenerate`) path had the same drop.
17
+
18
+ Both paths now emit the call as a complete tool call with `'{}'` input and propagate `thoughtSignature` provider metadata.
19
+
20
+ Fixes #14847.
21
+
3
22
  ## 4.0.0-canary.51
4
23
 
5
24
  ### Patch Changes
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.0-canary.51" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0-canary.53" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -1645,7 +1645,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1645
1645
  };
1646
1646
  }
1647
1647
  async doGenerate(options) {
1648
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1648
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1649
1649
  const { args, warnings, providerOptionsNames } = await this.getArgs(options);
1650
1650
  const wrapProviderMetadata = (payload) => Object.fromEntries(
1651
1651
  providerOptionsNames.map((name) => [name, payload])
@@ -1714,12 +1714,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1714
1714
  providerMetadata: thoughtSignatureMetadata
1715
1715
  });
1716
1716
  }
1717
- } else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
1717
+ } else if ("functionCall" in part && part.functionCall.name != null) {
1718
1718
  content.push({
1719
1719
  type: "tool-call",
1720
1720
  toolCallId: this.config.generateId(),
1721
1721
  toolName: part.functionCall.name,
1722
- input: JSON.stringify(part.functionCall.args),
1722
+ input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
1723
1723
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1724
1724
  thoughtSignature: part.thoughtSignature
1725
1725
  }) : void 0
@@ -1736,13 +1736,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1736
1736
  }) : void 0
1737
1737
  });
1738
1738
  } else if ("toolCall" in part && part.toolCall) {
1739
- const toolCallId = (_e = part.toolCall.id) != null ? _e : this.config.generateId();
1739
+ const toolCallId = (_f = part.toolCall.id) != null ? _f : this.config.generateId();
1740
1740
  lastServerToolCallId = toolCallId;
1741
1741
  content.push({
1742
1742
  type: "tool-call",
1743
1743
  toolCallId,
1744
1744
  toolName: `server:${part.toolCall.toolType}`,
1745
- input: JSON.stringify((_f = part.toolCall.args) != null ? _f : {}),
1745
+ input: JSON.stringify((_g = part.toolCall.args) != null ? _g : {}),
1746
1746
  providerExecuted: true,
1747
1747
  dynamic: true,
1748
1748
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
@@ -1755,12 +1755,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1755
1755
  })
1756
1756
  });
1757
1757
  } else if ("toolResponse" in part && part.toolResponse) {
1758
- const responseToolCallId = (_g = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _g : this.config.generateId();
1758
+ const responseToolCallId = (_h = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _h : this.config.generateId();
1759
1759
  content.push({
1760
1760
  type: "tool-result",
1761
1761
  toolCallId: responseToolCallId,
1762
1762
  toolName: `server:${part.toolResponse.toolType}`,
1763
- result: (_h = part.toolResponse.response) != null ? _h : {},
1763
+ result: (_i = part.toolResponse.response) != null ? _i : {},
1764
1764
  providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
1765
1765
  thoughtSignature: part.thoughtSignature,
1766
1766
  serverToolCallId: responseToolCallId,
@@ -1773,10 +1773,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1773
1773
  lastServerToolCallId = void 0;
1774
1774
  }
1775
1775
  }
1776
- const sources = (_i = extractSources({
1776
+ const sources = (_j = extractSources({
1777
1777
  groundingMetadata: candidate.groundingMetadata,
1778
1778
  generateId: this.config.generateId
1779
- })) != null ? _i : [];
1779
+ })) != null ? _j : [];
1780
1780
  for (const source of sources) {
1781
1781
  content.push(source);
1782
1782
  }
@@ -1790,18 +1790,18 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1790
1790
  (part) => part.type === "tool-call" && !part.providerExecuted
1791
1791
  )
1792
1792
  }),
1793
- raw: (_j = candidate.finishReason) != null ? _j : void 0
1793
+ raw: (_k = candidate.finishReason) != null ? _k : void 0
1794
1794
  },
1795
1795
  usage: convertGoogleUsage(usageMetadata),
1796
1796
  warnings,
1797
1797
  providerMetadata: wrapProviderMetadata({
1798
- promptFeedback: (_k = response.promptFeedback) != null ? _k : null,
1799
- groundingMetadata: (_l = candidate.groundingMetadata) != null ? _l : null,
1800
- urlContextMetadata: (_m = candidate.urlContextMetadata) != null ? _m : null,
1801
- safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
1798
+ promptFeedback: (_l = response.promptFeedback) != null ? _l : null,
1799
+ groundingMetadata: (_m = candidate.groundingMetadata) != null ? _m : null,
1800
+ urlContextMetadata: (_n = candidate.urlContextMetadata) != null ? _n : null,
1801
+ safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
1802
1802
  usageMetadata: usageMetadata != null ? usageMetadata : null,
1803
- finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
1804
- serviceTier: (_p = response.serviceTier) != null ? _p : null
1803
+ finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
1804
+ serviceTier: (_q = response.serviceTier) != null ? _q : null
1805
1805
  }),
1806
1806
  request: { body: args },
1807
1807
  response: {
@@ -2051,6 +2051,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2051
2051
  const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
2052
2052
  const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
2053
2053
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
2054
+ const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
2054
2055
  if (isStreamingChunk) {
2055
2056
  if (part.functionCall.name != null && part.functionCall.willContinue === true) {
2056
2057
  const toolCallId = generateId3();
@@ -2147,6 +2148,28 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2147
2148
  providerMetadata: providerMeta
2148
2149
  });
2149
2150
  hasToolCalls = true;
2151
+ } else if (isNoArgsCompleteCall) {
2152
+ const toolCallId = generateId3();
2153
+ const toolName = part.functionCall.name;
2154
+ controller.enqueue({
2155
+ type: "tool-input-start",
2156
+ id: toolCallId,
2157
+ toolName,
2158
+ providerMetadata: providerMeta
2159
+ });
2160
+ controller.enqueue({
2161
+ type: "tool-input-end",
2162
+ id: toolCallId,
2163
+ providerMetadata: providerMeta
2164
+ });
2165
+ controller.enqueue({
2166
+ type: "tool-call",
2167
+ toolCallId,
2168
+ toolName,
2169
+ input: "{}",
2170
+ providerMetadata: providerMeta
2171
+ });
2172
+ hasToolCalls = true;
2150
2173
  }
2151
2174
  }
2152
2175
  }