@ai-sdk/google 4.0.0-canary.67 → 4.0.0-canary.68

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.0-canary.68
4
+
5
+ ### Patch Changes
6
+
7
+ - a2609df: fix(google): fix streaming tool call args
8
+ - 546cefe: feat(provider/google): add `gemini-3.5-flash`
9
+
3
10
  ## 4.0.0-canary.67
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
11
11
  }>;
12
12
  type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
13
13
 
14
- type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
14
+ type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
15
15
  declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
16
16
  responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
17
17
  thinkingConfig?: {
@@ -268,7 +268,7 @@ type GoogleFilesUploadOptions = {
268
268
  * the two surfaces (`:generateContent` vs `/interactions`) are independent and
269
269
  * may diverge over time.
270
270
  */
271
- type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
271
+ type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
272
272
  /**
273
273
  * Provider-options schema for `google.interactions(...)` calls. Read from the
274
274
  * shared `providerOptions.google.*` namespace (per PRD); per-call options that
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.67" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0-canary.68" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -1872,6 +1872,34 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
1872
1872
  let lastCodeExecutionToolCallId;
1873
1873
  let lastServerToolCallId;
1874
1874
  const activeStreamingToolCalls = [];
1875
+ const finishActiveStreamingToolCall = (controller) => {
1876
+ const active = activeStreamingToolCalls.pop();
1877
+ if (active == null) {
1878
+ return;
1879
+ }
1880
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
1881
+ if (closingDelta.length > 0) {
1882
+ controller.enqueue({
1883
+ type: "tool-input-delta",
1884
+ id: active.toolCallId,
1885
+ delta: closingDelta,
1886
+ providerMetadata: active.providerMetadata
1887
+ });
1888
+ }
1889
+ controller.enqueue({
1890
+ type: "tool-input-end",
1891
+ id: active.toolCallId,
1892
+ providerMetadata: active.providerMetadata
1893
+ });
1894
+ controller.enqueue({
1895
+ type: "tool-call",
1896
+ toolCallId: active.toolCallId,
1897
+ toolName: active.toolName,
1898
+ input: finalJSON,
1899
+ providerMetadata: active.providerMetadata
1900
+ });
1901
+ hasToolCalls = true;
1902
+ };
1875
1903
  return {
1876
1904
  stream: response.pipeThrough(
1877
1905
  new TransformStream({
@@ -2073,7 +2101,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2073
2101
  const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
2074
2102
  const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
2075
2103
  if (isStreamingChunk) {
2076
- if (part.functionCall.name != null && part.functionCall.willContinue === true) {
2104
+ if (part.functionCall.name != null) {
2077
2105
  const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
2078
2106
  const accumulator = new GoogleJSONAccumulator();
2079
2107
  activeStreamingToolCalls.push({
@@ -2089,9 +2117,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2089
2117
  providerMetadata: providerMeta
2090
2118
  });
2091
2119
  if (part.functionCall.partialArgs != null) {
2092
- const { textDelta } = accumulator.processPartialArgs(
2093
- part.functionCall.partialArgs
2094
- );
2120
+ const partialArgs = part.functionCall.partialArgs;
2121
+ const { textDelta } = accumulator.processPartialArgs(partialArgs);
2095
2122
  if (textDelta.length > 0) {
2096
2123
  controller.enqueue({
2097
2124
  type: "tool-input-delta",
@@ -2100,12 +2127,14 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2100
2127
  providerMetadata: providerMeta
2101
2128
  });
2102
2129
  }
2130
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
2131
+ finishActiveStreamingToolCall(controller);
2132
+ }
2103
2133
  }
2104
2134
  } else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
2105
2135
  const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
2106
- const { textDelta } = active.accumulator.processPartialArgs(
2107
- part.functionCall.partialArgs
2108
- );
2136
+ const partialArgs = part.functionCall.partialArgs;
2137
+ const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
2109
2138
  if (textDelta.length > 0) {
2110
2139
  controller.enqueue({
2111
2140
  type: "tool-input-delta",
@@ -2114,31 +2143,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
2114
2143
  providerMetadata: providerMeta
2115
2144
  });
2116
2145
  }
2146
+ if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
2147
+ finishActiveStreamingToolCall(controller);
2148
+ }
2117
2149
  }
2118
2150
  } else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
2119
- const active = activeStreamingToolCalls.pop();
2120
- const { finalJSON, closingDelta } = active.accumulator.finalize();
2121
- if (closingDelta.length > 0) {
2122
- controller.enqueue({
2123
- type: "tool-input-delta",
2124
- id: active.toolCallId,
2125
- delta: closingDelta,
2126
- providerMetadata: active.providerMetadata
2127
- });
2128
- }
2129
- controller.enqueue({
2130
- type: "tool-input-end",
2131
- id: active.toolCallId,
2132
- providerMetadata: active.providerMetadata
2133
- });
2134
- controller.enqueue({
2135
- type: "tool-call",
2136
- toolCallId: active.toolCallId,
2137
- toolName: active.toolName,
2138
- input: finalJSON,
2139
- providerMetadata: active.providerMetadata
2140
- });
2141
- hasToolCalls = true;
2151
+ finishActiveStreamingToolCall(controller);
2142
2152
  } else if (isCompleteCall) {
2143
2153
  const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
2144
2154
  const toolName = part.functionCall.name;