@ai-sdk/google 4.0.101 → 4.0.103

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,31 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.103
4
+
5
+ ### Patch Changes
6
+
7
+ - 43ad966: Report `interrupted` when a stream ends cleanly without its provider completion signal, preserving partial output without emitting an error solely for the interruption.
8
+
9
+ This applies to OpenAI (Chat, Responses, and Completions), Anthropic, Google (Generate Content and Interactions), Alibaba, Amazon Bedrock Converse, Cohere, DeepSeek, Groq, Hugging Face Responses, Mistral Chat, Moonshot AI, Open Responses, Perplexity, and xAI Responses. It also covers cutoffs in later Anthropic messages and Google automatic continuations.
10
+
11
+ **Compatibility notice:** These streams previously fell back to `other` or omitted the finish part. Applications must now handle `interrupted` in finish-reason switches, mappings, and custom validation. Check `finishReason === 'interrupted'` to detect incomplete responses; interruption alone does not trigger error handling.
12
+
13
+ Explicit unknown completion reasons still map to `other`. Actual provider, parsing, and transport errors retain their error paths; affected error paths that previously left the finish reason as `other` now report `error`. OpenAI-compatible remains unchanged.
14
+
15
+ - Updated dependencies [10026d1]
16
+ - @ai-sdk/provider@4.0.32
17
+ - @ai-sdk/provider-utils@5.0.66
18
+
19
+ ## 4.0.102
20
+
21
+ ### Patch Changes
22
+
23
+ - 39a776b: Add a shared encodePathSegment helper and use it to encode provider-returned identifiers in credentialed follow-up request paths.
24
+ - 754407e: Defer construction of provider validation schemas until first use to reduce package import time.
25
+ - Updated dependencies [b089ce8]
26
+ - Updated dependencies [39a776b]
27
+ - @ai-sdk/provider-utils@5.0.65
28
+
3
29
  ## 4.0.101
4
30
 
5
31
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -270,7 +270,7 @@ interface GoogleProviderMetadata {
270
270
  }
271
271
  //#endregion
272
272
  //#region src/tool/google-search.d.ts
273
- declare const googleSearchToolArgsBaseSchema: z.ZodObject<{
273
+ declare const googleSearchToolArgsBaseSchema: () => z.ZodObject<{
274
274
  searchTypes: z.ZodOptional<z.ZodObject<{
275
275
  webSearch: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
276
276
  imageSearch: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
@@ -280,7 +280,7 @@ declare const googleSearchToolArgsBaseSchema: z.ZodObject<{
280
280
  endTime: z.ZodString;
281
281
  }, z.core.$strip>>;
282
282
  }, z.core.$loose>;
283
- type GoogleSearchToolArgs = z.infer<typeof googleSearchToolArgsBaseSchema>;
283
+ type GoogleSearchToolArgs = z.infer<ReturnType<typeof googleSearchToolArgsBaseSchema>>;
284
284
  //#endregion
285
285
  //#region src/google-image-model-options.d.ts
286
286
  type GoogleImageModelOptions = Omit<GoogleLanguageModelOptions, 'responseModalities'> & {
@@ -625,17 +625,14 @@ type GoogleTranscriptionModelId = 'gemini-3.5-transcribe' | 'gemini-3.5-transcri
625
625
  * live (`gemini-3.5-transcribe-live`) transcription. Maps onto Google's
626
626
  * `AudioTranscriptionConfig`.
627
627
  */
628
- declare const googleTranscriptionModelOptions: z.ZodObject<{
629
- languageCodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
630
- customVocabulary: z.ZodOptional<z.ZodArray<z.ZodString>>;
631
- wordTimestamp: z.ZodOptional<z.ZodBoolean>;
632
- diarization: z.ZodOptional<z.ZodBoolean>;
633
- mode: z.ZodOptional<z.ZodEnum<{
634
- SMART: "SMART";
635
- VERBATIM: "VERBATIM";
636
- }>>;
637
- }, z.core.$strip>;
638
- type GoogleTranscriptionModelOptions = z.infer<typeof googleTranscriptionModelOptions>;
628
+ declare const googleTranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
629
+ languageCodes?: string[] | undefined;
630
+ customVocabulary?: string[] | undefined;
631
+ wordTimestamp?: boolean | undefined;
632
+ diarization?: boolean | undefined;
633
+ mode?: "SMART" | "VERBATIM" | undefined;
634
+ }>;
635
+ type GoogleTranscriptionModelOptions = InferSchema<typeof googleTranscriptionModelOptions>;
639
636
  //#endregion
640
637
  //#region src/speech-translation/google-speech-translation-model-options.d.ts
641
638
  type GoogleSpeechTranslationModelId = 'gemini-3.5-live-translate-preview' | (string & {});
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["DecisionModelV4","BatchV4","SpeechTranslationModelV4","RealtimeFactoryV4","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4SessionConfig","TranscriptionModelV4StreamOptions","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/google-error.ts","../src/google-language-model-options.ts","../src/google-language-model.ts","../src/google-prompt.ts","../src/tool/google-search.ts","../src/google-image-model-options.ts","../src/google-embedding-model-options.ts","../src/google-video-model-options.ts","../src/google-video-settings.ts","../src/google-speech-model-options.ts","../src/google-files.ts","../src/interactions/google-interactions-language-model-options.ts","../src/interactions/google-interactions-provider-metadata.ts","../src/interactions/google-interactions-agent.ts","../src/google-tools.ts","../src/google-image-settings.ts","../src/transcription/google-transcription-model-options.ts","../src/speech-translation/google-speech-translation-model-options.ts","../src/google-provider.ts","../src/realtime/google-realtime-model.ts","../src/realtime/google-realtime-model-options.ts","../src/transcription/google-transcription-model.ts","../src/speech-translation/google-speech-translation-model.ts","../src/version.ts"],"mappings":";;;;cAgBM,wDAAqB;;;;;;;;KAQf,kBAAkB,mBAAmB;;;KCjBrC;cAqDC,6DAA0B;;;;;;;;;;;;;;;WAA1B;;;;;;;;;;;;;;;;;;;;;;;;KA+OD,6BAA6B,mBAChC;;;cCorDI,iDAAc;;;cAAd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;IACA;;EAOF,iBACE,eACCC,0CAA6BA;EAIhC,qBACE,OAAOC,0CACN,WAAWC;EAId,mBACE,QAAQC,4CACP;;;;KChJO;KAEA;;;;;;;EAOV;;;;;IAKE;;;;;IAMA;;;;;;;;;;EAWF;;;;;;IAME;;;;;IAMA;;;;IAKA;;;;;;;;;;;EAYF;;;;UC2BQ;EACR;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;EACR,YAAY;EACZ;IACE,oBAAoB;IACpB;;;qBAIS,oCAAoC;WAsBpC,SAAS;mBACD;WAtBV;UAED,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKO,YAAA,SAAS,4BACD,QAAQ;UAGb;EAUR,WACJ,SAAS,WAAW,yCACnB,QAAQ,QAAQ,WAAW;EAmGxB,SACJ,SAASC,iDACR,QACD,QAAQ,WAAW,YAAY;;;;KCtKvB;EACV;EACA;EACA,eAAe;EACf,YAAY;EACZ;IACE,oBAAoB;IACpB;;;cAIS,wCAAwCE;WAC1C;WACA,SAAS;mBAED;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKF,YAAA,SAAS,gCACT,QAAQ;EAMJ,SACJ,SAASD,qDACR,QAAQ,QAAQ,WAAWC;;;;qBCpHnB"}
1
+ {"version":3,"file":"index.d.ts","names":["DecisionModelV4","BatchV4","SpeechTranslationModelV4","RealtimeFactoryV4","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4SessionConfig","TranscriptionModelV4StreamOptions","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/google-error.ts","../src/google-language-model-options.ts","../src/google-language-model.ts","../src/google-prompt.ts","../src/tool/google-search.ts","../src/google-image-model-options.ts","../src/google-embedding-model-options.ts","../src/google-video-model-options.ts","../src/google-video-settings.ts","../src/google-speech-model-options.ts","../src/google-files.ts","../src/interactions/google-interactions-language-model-options.ts","../src/interactions/google-interactions-provider-metadata.ts","../src/interactions/google-interactions-agent.ts","../src/google-tools.ts","../src/google-image-settings.ts","../src/transcription/google-transcription-model-options.ts","../src/speech-translation/google-speech-translation-model-options.ts","../src/google-provider.ts","../src/realtime/google-realtime-model.ts","../src/realtime/google-realtime-model-options.ts","../src/transcription/google-transcription-model.ts","../src/speech-translation/google-speech-translation-model.ts","../src/version.ts"],"mappings":";;;;cAgBM,wDAAqB;;;;;;;;KAQf,kBAAkB,mBAAmB;;;KCjBrC;cAqDC,6DAA0B;;;;;;;;;;;;;;;WAA1B;;;;;;;;;;;;;;;;;;;;;;;;KA+OD,6BAA6B,mBAChC;;;cCosDI,iDAAc;;;cAAd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BR,kBAAkB,YACrB,mBAAmB;KAGT,0BAA0B,YACpC;KAGU,2BAA2B,YACrC;KAGU,qBAAqB,YAC/B;KAGU,uBAAuB,YACjC,mBAAmB;KAGT,sBAAsB,YAChC,mBAAmB;;;KC98DT,0BAA0B;KAE1B,2BAA2B;KAE3B,qBAAqB;KAErB,uBAAuB;KAEvB,sBAAsB;UAEjB;EACf,gBAAgB;EAChB,mBAAmB;;EAEnB,8BAA8B,MAAM;EACpC,oBAAoB;EACpB,eAAe;EACf,eAAe;EACf;EACA;EACA;;;;;;;EAQA;;;;;;;;;EAUA;;;;cC9GW,sCAA8B,EAAA;;;;;;;;;GAevC,EAAA,KAAA;KAEQ,uBAAuB,EAAE,MACnC,kBAAkB;;;KCJR,0BAA0B,KACpC;EAGA,eAAe;;;;KCtBL;cAuBC,8DAA2B;;;;;;;;;;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V;EACA;EACA,eAAe;EACf,YAAY;EACZ;IACE,oBAAoB;IACpB;;;cAIS,wCAAwCE;WAC1C;WACA,SAAS;mBAED;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAKF,YAAA,SAAS,gCACT,QAAQ;EAMJ,SACJ,SAASD,qDACR,QAAQ,QAAQ,WAAWC;;;;qBCpHnB"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertJsonResponseToolStream, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createNullLanguageModelUsage, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, delay, detectMediaType, downloadBlob, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, isAbortError, isCustomReasoning, isFullMediaType, isRecord, isSameOrigin, isUrlSupported, lazySchema, loadApiKey, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, parseProviderOptions, postJsonToApi, postToApi, resolve, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
1
+ import { EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertJsonResponseToolStream, convertToBase64, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createNullLanguageModelUsage, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, delay, detectMediaType, downloadBlob, encodePathSegment, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, isAbortError, isCustomReasoning, isFullMediaType, isRecord, isSameOrigin, isUrlSupported, lazySchema, loadApiKey, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, parseProviderOptions, postJsonToApi, postToApi, resolve, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
2
2
  import { Experimental_DecisionLanguageModel } from "@ai-sdk/provider-utils/experimental-decision";
3
3
  import { AISDKError, InvalidArgumentError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
4
4
  import { z } from "zod/v4";
5
5
  //#region src/version.ts
6
- const VERSION = "4.0.101";
6
+ const VERSION = "4.0.103";
7
7
  //#endregion
8
8
  //#region src/google-error.ts
9
9
  const getGoogleErrorSchema = () => z.object({
@@ -19,7 +19,7 @@ const googleFailedResponseHandler = createJsonErrorResponseHandler({
19
19
  });
20
20
  //#endregion
21
21
  //#region src/google-embedding-model-options.ts
22
- const googleEmbeddingContentPartSchema = z.union([
22
+ const googleEmbeddingContentPartSchema = () => z.union([
23
23
  z.object({ text: z.string() }),
24
24
  z.object({ inlineData: z.object({
25
25
  mimeType: z.string(),
@@ -67,7 +67,7 @@ const googleEmbeddingModelOptions = lazySchema(() => zodSchema(z.object({
67
67
  * The array length must match the number of values being embedded. In
68
68
  * the case of a single embedding, the array length must be 1.
69
69
  */
70
- content: z.array(z.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
70
+ content: z.array(z.array(googleEmbeddingContentPartSchema()).min(1).nullable()).optional()
71
71
  })));
72
72
  //#endregion
73
73
  //#region src/google-embedding-model.ts
@@ -203,7 +203,9 @@ function getModelPath(modelId) {
203
203
  * Events of the current stream are passed through unchanged. When an event
204
204
  * signals that the per-request cap was reached while budget remains
205
205
  * (`getContinuationToken` returns a token), the next request is sent with that
206
- * token once the current stream ends, and its events are appended. If the
206
+ * token once the current stream ends, and its events are appended after a
207
+ * `continuation-start` marker. The marker orders per-response state changes
208
+ * with buffered events, including when the new stream is empty. If the
207
209
  * continuation request fails, the error is emitted as a failed parse result
208
210
  * and the stream ends.
209
211
  */
@@ -230,6 +232,8 @@ function continueGoogleStream({ stream, getContinuationToken, continueStream })
230
232
  pendingContinuationToken = void 0;
231
233
  try {
232
234
  reader = (await continueStream(continuationToken)).getReader();
235
+ controller.enqueue({ type: "continuation-start" });
236
+ return;
233
237
  } catch (error) {
234
238
  controller.enqueue({
235
239
  success: false,
@@ -1922,7 +1926,7 @@ var GoogleLanguageModel = class GoogleLanguageModel {
1922
1926
  }
1923
1927
  });
1924
1928
  let finishReason = {
1925
- unified: "other",
1929
+ unified: "interrupted",
1926
1930
  raw: void 0
1927
1931
  };
1928
1932
  let usage = void 0;
@@ -1978,11 +1982,22 @@ var GoogleLanguageModel = class GoogleLanguageModel {
1978
1982
  });
1979
1983
  },
1980
1984
  transform(chunk, controller) {
1985
+ if ("type" in chunk) {
1986
+ finishReason = {
1987
+ unified: "interrupted",
1988
+ raw: void 0
1989
+ };
1990
+ return;
1991
+ }
1981
1992
  if (options.includeRawChunks) controller.enqueue({
1982
1993
  type: "raw",
1983
1994
  rawValue: chunk.rawValue
1984
1995
  });
1985
1996
  if (!chunk.success) {
1997
+ if (finishReason.unified === "interrupted") finishReason = {
1998
+ unified: "error",
1999
+ raw: void 0
2000
+ };
1986
2001
  controller.enqueue({
1987
2002
  type: "error",
1988
2003
  error: chunk.error
@@ -2524,7 +2539,7 @@ const getGroundingMetadataSchema = () => z.object({
2524
2539
  })).nullish(),
2525
2540
  retrievalMetadata: z.union([z.object({ webDynamicRetrievalScore: z.number() }), z.object({})]).nullish()
2526
2541
  });
2527
- const partialArgSchema = z.object({
2542
+ const partialArgSchema = () => z.object({
2528
2543
  jsonPath: z.string(),
2529
2544
  stringValue: z.string().nullish(),
2530
2545
  numberValue: z.number().nullish(),
@@ -2538,7 +2553,7 @@ const getContentSchema = () => z.object({ parts: z.array(z.union([
2538
2553
  id: z.string().nullish(),
2539
2554
  name: z.string().nullish(),
2540
2555
  args: z.unknown().nullish(),
2541
- partialArgs: z.array(partialArgSchema).nullish(),
2556
+ partialArgs: z.array(partialArgSchema()).nullish(),
2542
2557
  willContinue: z.boolean().nullish()
2543
2558
  }),
2544
2559
  thoughtSignature: z.string().nullish()
@@ -2589,11 +2604,11 @@ const getSafetyRatingSchema = () => z.object({
2589
2604
  severityScore: z.number().nullish(),
2590
2605
  blocked: z.boolean().nullish()
2591
2606
  });
2592
- const tokenDetailsSchema = z.array(z.object({
2607
+ const tokenDetailsSchema = () => z.array(z.object({
2593
2608
  modality: z.string(),
2594
2609
  tokenCount: z.number()
2595
2610
  }).loose()).nullish();
2596
- const usageSchema$1 = z.object({
2611
+ const usageSchema$1 = () => z.object({
2597
2612
  cachedContentTokenCount: z.number().nullish(),
2598
2613
  thoughtsTokenCount: z.number().nullish(),
2599
2614
  promptTokenCount: z.number().nullish(),
@@ -2602,10 +2617,10 @@ const usageSchema$1 = z.object({
2602
2617
  totalTokenCount: z.number().nullish(),
2603
2618
  trafficType: z.string().nullish(),
2604
2619
  serviceTier: z.string().nullish(),
2605
- promptTokensDetails: tokenDetailsSchema,
2606
- cacheTokensDetails: tokenDetailsSchema,
2607
- candidatesTokensDetails: tokenDetailsSchema,
2608
- toolUsePromptTokensDetails: tokenDetailsSchema
2620
+ promptTokensDetails: tokenDetailsSchema(),
2621
+ cacheTokensDetails: tokenDetailsSchema(),
2622
+ candidatesTokensDetails: tokenDetailsSchema(),
2623
+ toolUsePromptTokensDetails: tokenDetailsSchema()
2609
2624
  }).loose();
2610
2625
  const getUrlContextMetadataSchema = () => z.object({ urlMetadata: z.array(z.object({
2611
2626
  retrievedUrl: z.string(),
@@ -2622,7 +2637,7 @@ const responseSchema = lazySchema(() => zodSchema(z.object({
2622
2637
  groundingMetadata: getGroundingMetadataSchema().nullish(),
2623
2638
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2624
2639
  })).nullish(),
2625
- usageMetadata: usageSchema$1.nullish(),
2640
+ usageMetadata: usageSchema$1().nullish(),
2626
2641
  promptFeedback: z.object({
2627
2642
  blockReason: z.string().nullish(),
2628
2643
  safetyRatings: z.array(getSafetyRatingSchema()).nullish()
@@ -2640,7 +2655,7 @@ const chunkSchema = lazySchema(() => zodSchema(z.object({
2640
2655
  groundingMetadata: getGroundingMetadataSchema().nullish(),
2641
2656
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2642
2657
  })).nullish(),
2643
- usageMetadata: usageSchema$1.nullish(),
2658
+ usageMetadata: usageSchema$1().nullish(),
2644
2659
  promptFeedback: z.object({
2645
2660
  blockReason: z.string().nullish(),
2646
2661
  safetyRatings: z.array(getSafetyRatingSchema()).nullish()
@@ -2651,7 +2666,7 @@ function isConfirmedPromptBlockReason(blockReason) {
2651
2666
  }
2652
2667
  //#endregion
2653
2668
  //#region src/tool/google-search.ts
2654
- const googleSearchToolArgsBaseSchema = z.looseObject({
2669
+ const googleSearchToolArgsBaseSchema = () => z.looseObject({
2655
2670
  searchTypes: z.object({
2656
2671
  webSearch: z.object({}).optional(),
2657
2672
  imageSearch: z.object({}).optional()
@@ -2678,7 +2693,7 @@ const googleImageModelOptionsSchema = lazySchema(() => zodSchema(z.object({
2678
2693
  * dedicated escape hatch for grounding image generation the same way
2679
2694
  * `generateText` does.
2680
2695
  */
2681
- googleSearch: googleSearchToolArgsBaseSchema.optional() })));
2696
+ googleSearch: googleSearchToolArgsBaseSchema().optional() })));
2682
2697
  //#endregion
2683
2698
  //#region src/google-batch.ts
2684
2699
  const googleBatchInputFileMaxBytes = 2147483648;
@@ -2699,23 +2714,23 @@ function assertSupportedBatchRequests(requests) {
2699
2714
  });
2700
2715
  }
2701
2716
  }
2702
- const googleRpcStatusSchema = z.object({
2717
+ const googleRpcStatusSchema = () => z.object({
2703
2718
  code: z.union([z.number(), z.string()]).nullish(),
2704
2719
  message: z.string().nullish(),
2705
2720
  status: z.string().nullish()
2706
2721
  });
2707
- const googleBatchStatsSchema = z.object({
2722
+ const googleBatchStatsSchema = () => z.object({
2708
2723
  requestCount: z.union([z.string(), z.number()]).nullish(),
2709
2724
  successfulRequestCount: z.union([z.string(), z.number()]).nullish(),
2710
2725
  failedRequestCount: z.union([z.string(), z.number()]).nullish(),
2711
2726
  pendingRequestCount: z.union([z.string(), z.number()]).nullish()
2712
2727
  });
2713
- const googleBatchOutputSchema = z.object({
2728
+ const googleBatchOutputSchema = () => z.object({
2714
2729
  responsesFile: z.string().nullish(),
2715
2730
  inlinedResponses: z.object({ inlinedResponses: z.array(z.object({
2716
2731
  metadata: z.object({ key: z.string() }),
2717
2732
  response: z.unknown().nullish(),
2718
- error: googleRpcStatusSchema.nullish()
2733
+ error: googleRpcStatusSchema().nullish()
2719
2734
  })) }).nullish()
2720
2735
  });
2721
2736
  const googleBatchOperationZodSchema = () => z.object({
@@ -2723,12 +2738,12 @@ const googleBatchOperationZodSchema = () => z.object({
2723
2738
  metadata: z.object({
2724
2739
  state: z.string().nullish(),
2725
2740
  createTime: z.string().nullish(),
2726
- batchStats: googleBatchStatsSchema.nullish(),
2727
- output: googleBatchOutputSchema.nullish()
2741
+ batchStats: googleBatchStatsSchema().nullish(),
2742
+ output: googleBatchOutputSchema().nullish()
2728
2743
  }).nullish(),
2729
2744
  done: z.boolean().nullish(),
2730
- error: googleRpcStatusSchema.nullish(),
2731
- response: googleBatchOutputSchema.nullish()
2745
+ error: googleRpcStatusSchema().nullish(),
2746
+ response: googleBatchOutputSchema().nullish()
2732
2747
  });
2733
2748
  const googleBatchOperationSchema = lazySchema(() => zodSchema(googleBatchOperationZodSchema()));
2734
2749
  const googleBatchListResponseSchema = lazySchema(() => zodSchema(z.object({
@@ -2743,7 +2758,7 @@ const googleFileUploadResponseSchema = lazySchema(() => zodSchema(z.object({ fil
2743
2758
  const googleBatchResultLineSchema = lazySchema(() => zodSchema(z.object({
2744
2759
  key: z.string(),
2745
2760
  response: z.unknown().nullish(),
2746
- error: googleRpcStatusSchema.nullish()
2761
+ error: googleRpcStatusSchema().nullish()
2747
2762
  })));
2748
2763
  const googleBatchResponsePreviewSchema = lazySchema(() => zodSchema(z.object({
2749
2764
  candidates: z.array(z.unknown()).nullish(),
@@ -3255,7 +3270,7 @@ const enterpriseWebSearch = createProviderExecutedToolFactory({
3255
3270
  });
3256
3271
  //#endregion
3257
3272
  //#region src/tool/file-search.ts
3258
- z.looseObject({
3273
+ lazySchema(() => zodSchema(z.looseObject({
3259
3274
  /** The names of the file_search_stores to retrieve from.
3260
3275
  * Example: `fileSearchStores/my-file-search-store-123`
3261
3276
  */
@@ -3266,7 +3281,7 @@ z.looseObject({
3266
3281
  * See https://google.aip.dev/160 for the syntax of the filter expression.
3267
3282
  */
3268
3283
  metadataFilter: z.string().describe("Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.").optional()
3269
- });
3284
+ })));
3270
3285
  const fileSearch = createProviderExecutedToolFactory({
3271
3286
  id: "google.file_search",
3272
3287
  inputSchema: lazySchema(() => zodSchema(z.object({}))),
@@ -3476,10 +3491,6 @@ var GoogleImageModel = class GoogleImageModel {
3476
3491
  };
3477
3492
  //#endregion
3478
3493
  //#region src/google-files.ts
3479
- function encodePathSegment(value) {
3480
- const encodedValue = encodeURIComponent(value);
3481
- return encodedValue === "." ? "%252E" : encodedValue === ".." ? "%252E%252E" : encodedValue;
3482
- }
3483
3494
  var GoogleFiles = class {
3484
3495
  get provider() {
3485
3496
  return this.config.provider;
@@ -3847,7 +3858,7 @@ var GoogleVideoModel = class {
3847
3858
  return this.buildCompletedResult(statusOperation, responseHeaders, [], currentDate);
3848
3859
  }
3849
3860
  };
3850
- const googleOperationSchema = z.object({
3861
+ const googleOperationSchema = lazySchema(() => zodSchema(z.object({
3851
3862
  name: z.string().nullish(),
3852
3863
  done: z.boolean().nullish(),
3853
3864
  error: z.object({
@@ -3856,7 +3867,7 @@ const googleOperationSchema = z.object({
3856
3867
  status: z.string().nullish()
3857
3868
  }).nullish(),
3858
3869
  response: z.object({ generateVideoResponse: z.object({ generatedSamples: z.array(z.object({ video: z.object({ uri: z.string().nullish() }).nullish() })).nullish() }).nullish() }).nullish()
3859
- });
3870
+ })));
3860
3871
  //#endregion
3861
3872
  //#region src/google-speech-api.ts
3862
3873
  /**
@@ -3900,18 +3911,18 @@ function getGoogleSpeechInput({ text, voice, providerOptions }) {
3900
3911
  }
3901
3912
  //#endregion
3902
3913
  //#region src/google-speech-model-options.ts
3903
- const prebuiltVoiceConfigSchema = z.object({ voiceName: z.string() });
3904
- const voiceConfigSchema = z.object({
3905
- prebuiltVoiceConfig: prebuiltVoiceConfigSchema,
3914
+ const prebuiltVoiceConfigSchema = () => z.object({ voiceName: z.string() });
3915
+ const voiceConfigSchema = () => z.object({
3916
+ prebuiltVoiceConfig: prebuiltVoiceConfigSchema(),
3906
3917
  voice: z.never().optional()
3907
3918
  });
3908
- const speechMetadataSchema = z.object({
3919
+ const speechMetadataSchema = () => z.object({
3909
3920
  speaker: z.string().min(1).optional(),
3910
3921
  style: z.string().optional()
3911
3922
  });
3912
3923
  const googleSpeechProviderOptionsSchema = lazySchema(() => zodSchema(z.object({
3913
3924
  /** Turn-level directions for the top-level text, for Gemini 3.8 TTS. */
3914
- speechMetadata: speechMetadataSchema.optional(),
3925
+ speechMetadata: speechMetadataSchema().optional(),
3915
3926
  /**
3916
3927
  * Structured transcript for Gemini 3.8 TTS. Replaces the top-level text;
3917
3928
  * pass text: '' when using turns. Each multi-speaker turn must name a
@@ -3919,7 +3930,7 @@ const googleSpeechProviderOptionsSchema = lazySchema(() => zodSchema(z.object({
3919
3930
  */
3920
3931
  turns: z.array(z.object({
3921
3932
  text: z.string(),
3922
- speechMetadata: speechMetadataSchema.optional()
3933
+ speechMetadata: speechMetadataSchema().optional()
3923
3934
  })).min(1).optional(),
3924
3935
  /**
3925
3936
  * Multi-speaker configuration for dialogue audio. When provided, this
@@ -3931,7 +3942,7 @@ const googleSpeechProviderOptionsSchema = lazySchema(() => zodSchema(z.object({
3931
3942
  */
3932
3943
  multiSpeakerVoiceConfig: z.object({ speakerVoiceConfigs: z.array(z.object({
3933
3944
  speaker: z.string(),
3934
- voiceConfig: voiceConfigSchema
3945
+ voiceConfig: voiceConfigSchema()
3935
3946
  })) }).optional()
3936
3947
  })));
3937
3948
  //#endregion
@@ -4440,6 +4451,7 @@ function buildGoogleInteractionsStreamTransform({ warnings, generateId, includeR
4440
4451
  let serviceTier = headerServiceTier;
4441
4452
  let finishStatus;
4442
4453
  let hasFunctionCall = false;
4454
+ let hasCompletionEvent = false;
4443
4455
  const openBlocks = /* @__PURE__ */ new Map();
4444
4456
  const emittedSourceKeys = /* @__PURE__ */ new Set();
4445
4457
  function sourceKey(source) {
@@ -4852,6 +4864,7 @@ function buildGoogleInteractionsStreamTransform({ warnings, generateId, includeR
4852
4864
  break;
4853
4865
  }
4854
4866
  case "interaction.completed": {
4867
+ hasCompletionEvent = true;
4855
4868
  const interaction = value.interaction;
4856
4869
  if (interaction?.id != null && interaction.id.length > 0) interactionId = interaction.id;
4857
4870
  if (interaction?.status != null) finishStatus = interaction.status;
@@ -4876,12 +4889,13 @@ function buildGoogleInteractionsStreamTransform({ warnings, generateId, includeR
4876
4889
  }
4877
4890
  },
4878
4891
  flush(controller) {
4892
+ const isInterrupted = !hasCompletionEvent && (finishStatus == null || finishStatus === "in_progress");
4879
4893
  const finishReason = {
4880
- unified: mapGoogleInteractionsFinishReason({
4894
+ unified: isInterrupted ? "interrupted" : mapGoogleInteractionsFinishReason({
4881
4895
  status: finishStatus,
4882
4896
  hasFunctionCall
4883
4897
  }),
4884
- raw: finishStatus
4898
+ raw: isInterrupted ? void 0 : finishStatus
4885
4899
  };
4886
4900
  const outputTokensByModality = getGoogleInteractionsOutputTokensByModality(usage);
4887
4901
  const providerMetadata = { google: {
@@ -7400,7 +7414,7 @@ var GoogleRealtimeModel = class {
7400
7414
  * live (`gemini-3.5-transcribe-live`) transcription. Maps onto Google's
7401
7415
  * `AudioTranscriptionConfig`.
7402
7416
  */
7403
- const googleTranscriptionModelOptions = z.object({
7417
+ const googleTranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
7404
7418
  /**
7405
7419
  * BCP-47 language codes providing hints about the languages present in the
7406
7420
  * audio. If omitted or empty, defaults to automatic language detection.
@@ -7429,7 +7443,7 @@ const googleTranscriptionModelOptions = z.object({
7429
7443
  * (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
7430
7444
  */
7431
7445
  mode: z.enum(["SMART", "VERBATIM"]).optional()
7432
- });
7446
+ })));
7433
7447
  //#endregion
7434
7448
  //#region src/transcription/google-transcription-model.ts
7435
7449
  const liveWebSocketPath$1 = "google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent";
@@ -7794,25 +7808,25 @@ function validateLiveInputAudioFormat(inputAudioFormat) {
7794
7808
  message: "The Gemini Live transcription API only supports 16kHz 16-bit PCM input audio."
7795
7809
  });
7796
7810
  }
7797
- const googleInteractionsWordAnnotationSchema = z.object({
7811
+ const googleInteractionsWordAnnotationSchema = () => z.object({
7798
7812
  type: z.string().nullish(),
7799
7813
  text: z.string().nullish(),
7800
7814
  speaker: z.string().nullish(),
7801
7815
  start_offset: z.string().nullish(),
7802
7816
  end_offset: z.string().nullish()
7803
7817
  });
7804
- const googleInteractionsTranscriptionResponseSchema = z.object({
7818
+ const googleInteractionsTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
7805
7819
  status: z.string().nullish(),
7806
7820
  steps: z.array(z.object({
7807
7821
  type: z.string().nullish(),
7808
7822
  content: z.array(z.object({
7809
7823
  type: z.string().nullish(),
7810
7824
  text: z.string().nullish(),
7811
- annotations: z.array(googleInteractionsWordAnnotationSchema).nullish()
7825
+ annotations: z.array(googleInteractionsWordAnnotationSchema()).nullish()
7812
7826
  })).nullish()
7813
7827
  })).nullish(),
7814
7828
  usage: z.record(z.string(), z.json()).nullish()
7815
- });
7829
+ })));
7816
7830
  //#endregion
7817
7831
  //#region src/speech-translation/google-speech-translation-model-options.ts
7818
7832
  const googleSpeechTranslationModelOptions = lazySchema(() => zodSchema(z.object({