@ai-sdk/google 4.0.0-beta.36 → 4.0.0-beta.38

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.js CHANGED
@@ -1,81 +1,78 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- createGoogleGenerativeAI: () => createGoogleGenerativeAI,
25
- google: () => google
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/google-provider.ts
30
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ generateId as generateId2,
4
+ loadApiKey,
5
+ withoutTrailingSlash,
6
+ withUserAgentSuffix
7
+ } from "@ai-sdk/provider-utils";
31
8
 
32
9
  // src/version.ts
33
- var VERSION = true ? "4.0.0-beta.36" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0-beta.38" : "0.0.0-test";
34
11
 
35
12
  // src/google-generative-ai-embedding-model.ts
36
- var import_provider = require("@ai-sdk/provider");
37
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
38
- var import_v43 = require("zod/v4");
13
+ import {
14
+ TooManyEmbeddingValuesForCallError
15
+ } from "@ai-sdk/provider";
16
+ import {
17
+ combineHeaders,
18
+ createJsonResponseHandler,
19
+ lazySchema as lazySchema3,
20
+ parseProviderOptions,
21
+ postJsonToApi,
22
+ resolve,
23
+ serializeModelOptions,
24
+ WORKFLOW_SERIALIZE,
25
+ WORKFLOW_DESERIALIZE,
26
+ zodSchema as zodSchema3
27
+ } from "@ai-sdk/provider-utils";
28
+ import { z as z3 } from "zod/v4";
39
29
 
40
30
  // src/google-error.ts
41
- var import_provider_utils = require("@ai-sdk/provider-utils");
42
- var import_v4 = require("zod/v4");
43
- var googleErrorDataSchema = (0, import_provider_utils.lazySchema)(
44
- () => (0, import_provider_utils.zodSchema)(
45
- import_v4.z.object({
46
- error: import_v4.z.object({
47
- code: import_v4.z.number().nullable(),
48
- message: import_v4.z.string(),
49
- status: import_v4.z.string()
31
+ import {
32
+ createJsonErrorResponseHandler,
33
+ lazySchema,
34
+ zodSchema
35
+ } from "@ai-sdk/provider-utils";
36
+ import { z } from "zod/v4";
37
+ var googleErrorDataSchema = lazySchema(
38
+ () => zodSchema(
39
+ z.object({
40
+ error: z.object({
41
+ code: z.number().nullable(),
42
+ message: z.string(),
43
+ status: z.string()
50
44
  })
51
45
  })
52
46
  )
53
47
  );
54
- var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
48
+ var googleFailedResponseHandler = createJsonErrorResponseHandler({
55
49
  errorSchema: googleErrorDataSchema,
56
50
  errorToMessage: (data) => data.error.message
57
51
  });
58
52
 
59
53
  // src/google-generative-ai-embedding-options.ts
60
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
61
- var import_v42 = require("zod/v4");
62
- var googleEmbeddingContentPartSchema = import_v42.z.union([
63
- import_v42.z.object({ text: import_v42.z.string() }),
64
- import_v42.z.object({
65
- inlineData: import_v42.z.object({
66
- mimeType: import_v42.z.string(),
67
- data: import_v42.z.string()
54
+ import {
55
+ lazySchema as lazySchema2,
56
+ zodSchema as zodSchema2
57
+ } from "@ai-sdk/provider-utils";
58
+ import { z as z2 } from "zod/v4";
59
+ var googleEmbeddingContentPartSchema = z2.union([
60
+ z2.object({ text: z2.string() }),
61
+ z2.object({
62
+ inlineData: z2.object({
63
+ mimeType: z2.string(),
64
+ data: z2.string()
68
65
  })
69
66
  })
70
67
  ]);
71
- var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
72
- () => (0, import_provider_utils2.zodSchema)(
73
- import_v42.z.object({
68
+ var googleEmbeddingModelOptions = lazySchema2(
69
+ () => zodSchema2(
70
+ z2.object({
74
71
  /**
75
72
  * Optional. Optional reduced dimension for the output embedding.
76
73
  * If set, excessive values in the output embedding are truncated from the end.
77
74
  */
78
- outputDimensionality: import_v42.z.number().optional(),
75
+ outputDimensionality: z2.number().optional(),
79
76
  /**
80
77
  * Optional. Specifies the task type for generating embeddings.
81
78
  * Supported task types:
@@ -88,7 +85,7 @@ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
88
85
  * - FACT_VERIFICATION: Optimized for verifying factual information.
89
86
  * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
90
87
  */
91
- taskType: import_v42.z.enum([
88
+ taskType: z2.enum([
92
89
  "SEMANTIC_SIMILARITY",
93
90
  "CLASSIFICATION",
94
91
  "CLUSTERING",
@@ -107,13 +104,13 @@ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
107
104
  * The array length must match the number of values being embedded. In
108
105
  * the case of a single embedding, the array length must be 1.
109
106
  */
110
- content: import_v42.z.array(import_v42.z.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
107
+ content: z2.array(z2.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
111
108
  })
112
109
  )
113
110
  );
114
111
 
115
112
  // src/google-generative-ai-embedding-model.ts
116
- var GoogleGenerativeAIEmbeddingModel = class {
113
+ var GoogleGenerativeAIEmbeddingModel = class _GoogleGenerativeAIEmbeddingModel {
117
114
  constructor(modelId, config) {
118
115
  this.specificationVersion = "v4";
119
116
  this.maxEmbeddingsPerCall = 2048;
@@ -121,6 +118,18 @@ var GoogleGenerativeAIEmbeddingModel = class {
121
118
  this.modelId = modelId;
122
119
  this.config = config;
123
120
  }
121
+ static [WORKFLOW_SERIALIZE](model) {
122
+ return serializeModelOptions({
123
+ modelId: model.modelId,
124
+ config: model.config
125
+ });
126
+ }
127
+ static [WORKFLOW_DESERIALIZE](options) {
128
+ return new _GoogleGenerativeAIEmbeddingModel(
129
+ options.modelId,
130
+ options.config
131
+ );
132
+ }
124
133
  get provider() {
125
134
  return this.config.provider;
126
135
  }
@@ -130,21 +139,21 @@ var GoogleGenerativeAIEmbeddingModel = class {
130
139
  abortSignal,
131
140
  providerOptions
132
141
  }) {
133
- const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
142
+ const googleOptions = await parseProviderOptions({
134
143
  provider: "google",
135
144
  providerOptions,
136
145
  schema: googleEmbeddingModelOptions
137
146
  });
138
147
  if (values.length > this.maxEmbeddingsPerCall) {
139
- throw new import_provider.TooManyEmbeddingValuesForCallError({
148
+ throw new TooManyEmbeddingValuesForCallError({
140
149
  provider: this.provider,
141
150
  modelId: this.modelId,
142
151
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
143
152
  values
144
153
  });
145
154
  }
146
- const mergedHeaders = (0, import_provider_utils3.combineHeaders)(
147
- await (0, import_provider_utils3.resolve)(this.config.headers),
155
+ const mergedHeaders = combineHeaders(
156
+ this.config.headers ? await resolve(this.config.headers) : void 0,
148
157
  headers
149
158
  );
150
159
  const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
@@ -161,7 +170,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
161
170
  responseHeaders: responseHeaders2,
162
171
  value: response2,
163
172
  rawValue: rawValue2
164
- } = await (0, import_provider_utils3.postJsonToApi)({
173
+ } = await postJsonToApi({
165
174
  url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
166
175
  headers: mergedHeaders,
167
176
  body: {
@@ -173,7 +182,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
173
182
  taskType: googleOptions == null ? void 0 : googleOptions.taskType
174
183
  },
175
184
  failedResponseHandler: googleFailedResponseHandler,
176
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
185
+ successfulResponseHandler: createJsonResponseHandler(
177
186
  googleGenerativeAISingleEmbeddingResponseSchema
178
187
  ),
179
188
  abortSignal,
@@ -190,7 +199,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
190
199
  responseHeaders,
191
200
  value: response,
192
201
  rawValue
193
- } = await (0, import_provider_utils3.postJsonToApi)({
202
+ } = await postJsonToApi({
194
203
  url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
195
204
  headers: mergedHeaders,
196
205
  body: {
@@ -209,7 +218,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
209
218
  })
210
219
  },
211
220
  failedResponseHandler: googleFailedResponseHandler,
212
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
221
+ successfulResponseHandler: createJsonResponseHandler(
213
222
  googleGenerativeAITextEmbeddingResponseSchema
214
223
  ),
215
224
  abortSignal,
@@ -223,24 +232,40 @@ var GoogleGenerativeAIEmbeddingModel = class {
223
232
  };
224
233
  }
225
234
  };
226
- var googleGenerativeAITextEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
227
- () => (0, import_provider_utils3.zodSchema)(
228
- import_v43.z.object({
229
- embeddings: import_v43.z.array(import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) }))
235
+ var googleGenerativeAITextEmbeddingResponseSchema = lazySchema3(
236
+ () => zodSchema3(
237
+ z3.object({
238
+ embeddings: z3.array(z3.object({ values: z3.array(z3.number()) }))
230
239
  })
231
240
  )
232
241
  );
233
- var googleGenerativeAISingleEmbeddingResponseSchema = (0, import_provider_utils3.lazySchema)(
234
- () => (0, import_provider_utils3.zodSchema)(
235
- import_v43.z.object({
236
- embedding: import_v43.z.object({ values: import_v43.z.array(import_v43.z.number()) })
242
+ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
243
+ () => zodSchema3(
244
+ z3.object({
245
+ embedding: z3.object({ values: z3.array(z3.number()) })
237
246
  })
238
247
  )
239
248
  );
240
249
 
241
250
  // src/google-generative-ai-language-model.ts
242
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
243
- var import_v45 = require("zod/v4");
251
+ import {
252
+ combineHeaders as combineHeaders2,
253
+ createEventSourceResponseHandler,
254
+ createJsonResponseHandler as createJsonResponseHandler2,
255
+ generateId,
256
+ isCustomReasoning,
257
+ lazySchema as lazySchema5,
258
+ mapReasoningToProviderBudget,
259
+ mapReasoningToProviderEffort,
260
+ parseProviderOptions as parseProviderOptions2,
261
+ postJsonToApi as postJsonToApi2,
262
+ resolve as resolve2,
263
+ serializeModelOptions as serializeModelOptions2,
264
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
265
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
266
+ zodSchema as zodSchema5
267
+ } from "@ai-sdk/provider-utils";
268
+ import { z as z5 } from "zod/v4";
244
269
 
245
270
  // src/convert-google-generative-ai-usage.ts
246
271
  function convertGoogleGenerativeAIUsage(usage) {
@@ -398,8 +423,14 @@ function isEmptyObjectSchema(jsonSchema) {
398
423
  }
399
424
 
400
425
  // src/convert-to-google-generative-ai-messages.ts
401
- var import_provider2 = require("@ai-sdk/provider");
402
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
426
+ import {
427
+ UnsupportedFunctionalityError
428
+ } from "@ai-sdk/provider";
429
+ import {
430
+ convertToBase64,
431
+ isProviderReference,
432
+ resolveProviderReference
433
+ } from "@ai-sdk/provider-utils";
403
434
  var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
404
435
  function parseBase64DataUrl(value) {
405
436
  const match = dataUrlRegex.exec(value);
@@ -432,7 +463,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
432
463
  responseTextParts.push(contentPart.text);
433
464
  break;
434
465
  }
435
- case "image-data":
436
466
  case "file-data": {
437
467
  functionResponseParts.push({
438
468
  inlineData: {
@@ -442,7 +472,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
442
472
  });
443
473
  break;
444
474
  }
445
- case "image-url":
446
475
  case "file-url": {
447
476
  const functionResponsePart = convertUrlToolResultPart(
448
477
  contentPart.url
@@ -485,18 +514,22 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
485
514
  }
486
515
  });
487
516
  break;
488
- case "image-data":
489
- parts.push(
490
- {
491
- inlineData: {
492
- mimeType: String(contentPart.mediaType),
493
- data: String(contentPart.data)
517
+ case "file-data":
518
+ if (contentPart.mediaType.startsWith("image/")) {
519
+ parts.push(
520
+ {
521
+ inlineData: {
522
+ mimeType: contentPart.mediaType,
523
+ data: contentPart.data
524
+ }
525
+ },
526
+ {
527
+ text: "Tool executed successfully and returned this image as a response"
494
528
  }
495
- },
496
- {
497
- text: "Tool executed successfully and returned this image as a response"
498
- }
499
- );
529
+ );
530
+ } else {
531
+ parts.push({ text: JSON.stringify(contentPart) });
532
+ }
500
533
  break;
501
534
  default:
502
535
  parts.push({ text: JSON.stringify(contentPart) });
@@ -516,7 +549,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
516
549
  switch (role) {
517
550
  case "system": {
518
551
  if (!systemMessagesAllowed) {
519
- throw new import_provider2.UnsupportedFunctionalityError({
552
+ throw new UnsupportedFunctionalityError({
520
553
  functionality: "system messages are only supported at the beginning of the conversation"
521
554
  });
522
555
  }
@@ -541,16 +574,16 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
541
574
  fileUri: part.data.toString()
542
575
  }
543
576
  });
544
- } else if ((0, import_provider_utils4.isProviderReference)(part.data)) {
577
+ } else if (isProviderReference(part.data)) {
545
578
  if (providerOptionsName === "vertex") {
546
- throw new import_provider2.UnsupportedFunctionalityError({
579
+ throw new UnsupportedFunctionalityError({
547
580
  functionality: "file parts with provider references"
548
581
  });
549
582
  }
550
583
  parts.push({
551
584
  fileData: {
552
585
  mimeType: mediaType,
553
- fileUri: (0, import_provider_utils4.resolveProviderReference)({
586
+ fileUri: resolveProviderReference({
554
587
  reference: part.data,
555
588
  provider: "google"
556
589
  })
@@ -560,7 +593,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
560
593
  parts.push({
561
594
  inlineData: {
562
595
  mimeType: mediaType,
563
- data: (0, import_provider_utils4.convertToBase64)(part.data)
596
+ data: convertToBase64(part.data)
564
597
  }
565
598
  });
566
599
  }
@@ -595,14 +628,14 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
595
628
  }
596
629
  case "reasoning-file": {
597
630
  if (part.data instanceof URL) {
598
- throw new import_provider2.UnsupportedFunctionalityError({
631
+ throw new UnsupportedFunctionalityError({
599
632
  functionality: "File data URLs in assistant messages are not supported"
600
633
  });
601
634
  }
602
635
  return {
603
636
  inlineData: {
604
637
  mimeType: part.mediaType,
605
- data: (0, import_provider_utils4.convertToBase64)(part.data)
638
+ data: convertToBase64(part.data)
606
639
  },
607
640
  thought: true,
608
641
  thoughtSignature
@@ -610,20 +643,20 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
610
643
  }
611
644
  case "file": {
612
645
  if (part.data instanceof URL) {
613
- throw new import_provider2.UnsupportedFunctionalityError({
646
+ throw new UnsupportedFunctionalityError({
614
647
  functionality: "File data URLs in assistant messages are not supported"
615
648
  });
616
649
  }
617
- if ((0, import_provider_utils4.isProviderReference)(part.data)) {
650
+ if (isProviderReference(part.data)) {
618
651
  if (providerOptionsName === "vertex") {
619
- throw new import_provider2.UnsupportedFunctionalityError({
652
+ throw new UnsupportedFunctionalityError({
620
653
  functionality: "file parts with provider references"
621
654
  });
622
655
  }
623
656
  return {
624
657
  fileData: {
625
658
  mimeType: part.mediaType,
626
- fileUri: (0, import_provider_utils4.resolveProviderReference)({
659
+ fileUri: resolveProviderReference({
627
660
  reference: part.data,
628
661
  provider: "google"
629
662
  })
@@ -635,7 +668,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
635
668
  return {
636
669
  inlineData: {
637
670
  mimeType: part.mediaType,
638
- data: (0, import_provider_utils4.convertToBase64)(part.data)
671
+ data: convertToBase64(part.data)
639
672
  },
640
673
  ...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
641
674
  thoughtSignature
@@ -752,24 +785,24 @@ function getModelPath(modelId) {
752
785
  }
753
786
 
754
787
  // src/google-generative-ai-options.ts
755
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
756
- var import_v44 = require("zod/v4");
757
- var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
758
- () => (0, import_provider_utils5.zodSchema)(
759
- import_v44.z.object({
760
- responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
761
- thinkingConfig: import_v44.z.object({
762
- thinkingBudget: import_v44.z.number().optional(),
763
- includeThoughts: import_v44.z.boolean().optional(),
788
+ import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
789
+ import { z as z4 } from "zod/v4";
790
+ var googleLanguageModelOptions = lazySchema4(
791
+ () => zodSchema4(
792
+ z4.object({
793
+ responseModalities: z4.array(z4.enum(["TEXT", "IMAGE"])).optional(),
794
+ thinkingConfig: z4.object({
795
+ thinkingBudget: z4.number().optional(),
796
+ includeThoughts: z4.boolean().optional(),
764
797
  // https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
765
- thinkingLevel: import_v44.z.enum(["minimal", "low", "medium", "high"]).optional()
798
+ thinkingLevel: z4.enum(["minimal", "low", "medium", "high"]).optional()
766
799
  }).optional(),
767
800
  /**
768
801
  * Optional.
769
802
  * The name of the cached content used as context to serve the prediction.
770
803
  * Format: cachedContents/{cachedContent}
771
804
  */
772
- cachedContent: import_v44.z.string().optional(),
805
+ cachedContent: z4.string().optional(),
773
806
  /**
774
807
  * Optional. Enable structured output. Default is true.
775
808
  *
@@ -778,13 +811,13 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
778
811
  * Google Generative AI uses. You can use this to disable
779
812
  * structured outputs if you need to.
780
813
  */
781
- structuredOutputs: import_v44.z.boolean().optional(),
814
+ structuredOutputs: z4.boolean().optional(),
782
815
  /**
783
816
  * Optional. A list of unique safety settings for blocking unsafe content.
784
817
  */
785
- safetySettings: import_v44.z.array(
786
- import_v44.z.object({
787
- category: import_v44.z.enum([
818
+ safetySettings: z4.array(
819
+ z4.object({
820
+ category: z4.enum([
788
821
  "HARM_CATEGORY_UNSPECIFIED",
789
822
  "HARM_CATEGORY_HATE_SPEECH",
790
823
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -792,7 +825,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
792
825
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
793
826
  "HARM_CATEGORY_CIVIC_INTEGRITY"
794
827
  ]),
795
- threshold: import_v44.z.enum([
828
+ threshold: z4.enum([
796
829
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
797
830
  "BLOCK_LOW_AND_ABOVE",
798
831
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -802,7 +835,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
802
835
  ])
803
836
  })
804
837
  ).optional(),
805
- threshold: import_v44.z.enum([
838
+ threshold: z4.enum([
806
839
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
807
840
  "BLOCK_LOW_AND_ABOVE",
808
841
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -815,19 +848,19 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
815
848
  *
816
849
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
817
850
  */
818
- audioTimestamp: import_v44.z.boolean().optional(),
851
+ audioTimestamp: z4.boolean().optional(),
819
852
  /**
820
853
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
821
854
  *
822
855
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
823
856
  */
824
- labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional(),
857
+ labels: z4.record(z4.string(), z4.string()).optional(),
825
858
  /**
826
859
  * Optional. If specified, the media resolution specified will be used.
827
860
  *
828
861
  * https://ai.google.dev/api/generate-content#MediaResolution
829
862
  */
830
- mediaResolution: import_v44.z.enum([
863
+ mediaResolution: z4.enum([
831
864
  "MEDIA_RESOLUTION_UNSPECIFIED",
832
865
  "MEDIA_RESOLUTION_LOW",
833
866
  "MEDIA_RESOLUTION_MEDIUM",
@@ -838,8 +871,8 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
838
871
  *
839
872
  * https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
840
873
  */
841
- imageConfig: import_v44.z.object({
842
- aspectRatio: import_v44.z.enum([
874
+ imageConfig: z4.object({
875
+ aspectRatio: z4.enum([
843
876
  "1:1",
844
877
  "2:3",
845
878
  "3:2",
@@ -855,7 +888,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
855
888
  "1:4",
856
889
  "4:1"
857
890
  ]).optional(),
858
- imageSize: import_v44.z.enum(["1K", "2K", "4K", "512"]).optional()
891
+ imageSize: z4.enum(["1K", "2K", "4K", "512"]).optional()
859
892
  }).optional(),
860
893
  /**
861
894
  * Optional. Configuration for grounding retrieval.
@@ -863,10 +896,10 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
863
896
  *
864
897
  * https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
865
898
  */
866
- retrievalConfig: import_v44.z.object({
867
- latLng: import_v44.z.object({
868
- latitude: import_v44.z.number(),
869
- longitude: import_v44.z.number()
899
+ retrievalConfig: z4.object({
900
+ latLng: z4.object({
901
+ latitude: z4.number(),
902
+ longitude: z4.number()
870
903
  }).optional()
871
904
  }).optional(),
872
905
  /**
@@ -879,11 +912,11 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
879
912
  *
880
913
  * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
881
914
  */
882
- streamFunctionCallArguments: import_v44.z.boolean().optional(),
915
+ streamFunctionCallArguments: z4.boolean().optional(),
883
916
  /**
884
917
  * Optional. The service tier to use for the request.
885
918
  */
886
- serviceTier: import_v44.z.enum(["standard", "flex", "priority"]).optional()
919
+ serviceTier: z4.enum(["standard", "flex", "priority"]).optional()
887
920
  })
888
921
  )
889
922
  );
@@ -894,7 +927,9 @@ var VertexServiceTierMap = {
894
927
  };
895
928
 
896
929
  // src/google-prepare-tools.ts
897
- var import_provider3 = require("@ai-sdk/provider");
930
+ import {
931
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
932
+ } from "@ai-sdk/provider";
898
933
  function prepareTools({
899
934
  tools,
900
935
  toolChoice,
@@ -1136,7 +1171,7 @@ function prepareTools({
1136
1171
  };
1137
1172
  default: {
1138
1173
  const _exhaustiveCheck = type;
1139
- throw new import_provider3.UnsupportedFunctionalityError({
1174
+ throw new UnsupportedFunctionalityError2({
1140
1175
  functionality: `tool choice type: ${_exhaustiveCheck}`
1141
1176
  });
1142
1177
  }
@@ -1393,13 +1428,22 @@ function mapGoogleGenerativeAIFinishReason({
1393
1428
  }
1394
1429
 
1395
1430
  // src/google-generative-ai-language-model.ts
1396
- var GoogleGenerativeAILanguageModel = class {
1431
+ var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
1397
1432
  constructor(modelId, config) {
1398
1433
  this.specificationVersion = "v4";
1399
1434
  var _a;
1400
1435
  this.modelId = modelId;
1401
1436
  this.config = config;
1402
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils6.generateId;
1437
+ this.generateId = (_a = config.generateId) != null ? _a : generateId;
1438
+ }
1439
+ static [WORKFLOW_SERIALIZE2](model) {
1440
+ return serializeModelOptions2({
1441
+ modelId: model.modelId,
1442
+ config: model.config
1443
+ });
1444
+ }
1445
+ static [WORKFLOW_DESERIALIZE2](options) {
1446
+ return new _GoogleGenerativeAILanguageModel(options.modelId, options.config);
1403
1447
  }
1404
1448
  get provider() {
1405
1449
  return this.config.provider;
@@ -1427,13 +1471,13 @@ var GoogleGenerativeAILanguageModel = class {
1427
1471
  var _a, _b;
1428
1472
  const warnings = [];
1429
1473
  const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
1430
- let googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
1474
+ let googleOptions = await parseProviderOptions2({
1431
1475
  provider: providerOptionsName,
1432
1476
  providerOptions,
1433
1477
  schema: googleLanguageModelOptions
1434
1478
  });
1435
1479
  if (googleOptions == null && providerOptionsName !== "google") {
1436
- googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
1480
+ googleOptions = await parseProviderOptions2({
1437
1481
  provider: "google",
1438
1482
  providerOptions,
1439
1483
  schema: googleLanguageModelOptions
@@ -1543,22 +1587,22 @@ var GoogleGenerativeAILanguageModel = class {
1543
1587
  async doGenerate(options) {
1544
1588
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1545
1589
  const { args, warnings, providerOptionsName } = await this.getArgs(options);
1546
- const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
1547
- await (0, import_provider_utils6.resolve)(this.config.headers),
1590
+ const mergedHeaders = combineHeaders2(
1591
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
1548
1592
  options.headers
1549
1593
  );
1550
1594
  const {
1551
1595
  responseHeaders,
1552
1596
  value: response,
1553
1597
  rawValue: rawResponse
1554
- } = await (0, import_provider_utils6.postJsonToApi)({
1598
+ } = await postJsonToApi2({
1555
1599
  url: `${this.config.baseURL}/${getModelPath(
1556
1600
  this.modelId
1557
1601
  )}:generateContent`,
1558
1602
  headers: mergedHeaders,
1559
1603
  body: args,
1560
1604
  failedResponseHandler: googleFailedResponseHandler,
1561
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(responseSchema),
1605
+ successfulResponseHandler: createJsonResponseHandler2(responseSchema),
1562
1606
  abortSignal: options.abortSignal,
1563
1607
  fetch: this.config.fetch
1564
1608
  });
@@ -1725,18 +1769,18 @@ var GoogleGenerativeAILanguageModel = class {
1725
1769
  options,
1726
1770
  { isStreaming: true }
1727
1771
  );
1728
- const headers = (0, import_provider_utils6.combineHeaders)(
1729
- await (0, import_provider_utils6.resolve)(this.config.headers),
1772
+ const headers = combineHeaders2(
1773
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
1730
1774
  options.headers
1731
1775
  );
1732
- const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
1776
+ const { responseHeaders, value: response } = await postJsonToApi2({
1733
1777
  url: `${this.config.baseURL}/${getModelPath(
1734
1778
  this.modelId
1735
1779
  )}:streamGenerateContent?alt=sse`,
1736
1780
  headers,
1737
1781
  body: args,
1738
1782
  failedResponseHandler: googleFailedResponseHandler,
1739
- successfulResponseHandler: (0, import_provider_utils6.createEventSourceResponseHandler)(chunkSchema),
1783
+ successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
1740
1784
  abortSignal: options.abortSignal,
1741
1785
  fetch: this.config.fetch
1742
1786
  });
@@ -2132,7 +2176,7 @@ function resolveThinkingConfig({
2132
2176
  modelId,
2133
2177
  warnings
2134
2178
  }) {
2135
- if (!(0, import_provider_utils6.isCustomReasoning)(reasoning)) {
2179
+ if (!isCustomReasoning(reasoning)) {
2136
2180
  return void 0;
2137
2181
  }
2138
2182
  if (isGemini3Model(modelId) && !modelId.includes("gemini-3-pro-image")) {
@@ -2147,7 +2191,7 @@ function resolveGemini3ThinkingConfig({
2147
2191
  if (reasoning === "none") {
2148
2192
  return { thinkingLevel: "minimal" };
2149
2193
  }
2150
- const thinkingLevel = (0, import_provider_utils6.mapReasoningToProviderEffort)({
2194
+ const thinkingLevel = mapReasoningToProviderEffort({
2151
2195
  reasoning,
2152
2196
  effortMap: {
2153
2197
  minimal: "minimal",
@@ -2171,7 +2215,7 @@ function resolveGemini25ThinkingConfig({
2171
2215
  if (reasoning === "none") {
2172
2216
  return { thinkingBudget: 0 };
2173
2217
  }
2174
- const thinkingBudget = (0, import_provider_utils6.mapReasoningToProviderBudget)({
2218
+ const thinkingBudget = mapReasoningToProviderBudget({
2175
2219
  reasoning,
2176
2220
  maxOutputTokens: getMaxOutputTokensForGemini25Model(),
2177
2221
  maxReasoningBudget: getMaxThinkingTokensForGemini25Model(modelId),
@@ -2277,270 +2321,286 @@ function extractSources({
2277
2321
  }
2278
2322
  return sources.length > 0 ? sources : void 0;
2279
2323
  }
2280
- var getGroundingMetadataSchema = () => import_v45.z.object({
2281
- webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
2282
- imageSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
2283
- retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
2284
- searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
2285
- groundingChunks: import_v45.z.array(
2286
- import_v45.z.object({
2287
- web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
2288
- image: import_v45.z.object({
2289
- sourceUri: import_v45.z.string(),
2290
- imageUri: import_v45.z.string(),
2291
- title: import_v45.z.string().nullish(),
2292
- domain: import_v45.z.string().nullish()
2324
+ var getGroundingMetadataSchema = () => z5.object({
2325
+ webSearchQueries: z5.array(z5.string()).nullish(),
2326
+ imageSearchQueries: z5.array(z5.string()).nullish(),
2327
+ retrievalQueries: z5.array(z5.string()).nullish(),
2328
+ searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
2329
+ groundingChunks: z5.array(
2330
+ z5.object({
2331
+ web: z5.object({ uri: z5.string(), title: z5.string().nullish() }).nullish(),
2332
+ image: z5.object({
2333
+ sourceUri: z5.string(),
2334
+ imageUri: z5.string(),
2335
+ title: z5.string().nullish(),
2336
+ domain: z5.string().nullish()
2293
2337
  }).nullish(),
2294
- retrievedContext: import_v45.z.object({
2295
- uri: import_v45.z.string().nullish(),
2296
- title: import_v45.z.string().nullish(),
2297
- text: import_v45.z.string().nullish(),
2298
- fileSearchStore: import_v45.z.string().nullish()
2338
+ retrievedContext: z5.object({
2339
+ uri: z5.string().nullish(),
2340
+ title: z5.string().nullish(),
2341
+ text: z5.string().nullish(),
2342
+ fileSearchStore: z5.string().nullish()
2299
2343
  }).nullish(),
2300
- maps: import_v45.z.object({
2301
- uri: import_v45.z.string().nullish(),
2302
- title: import_v45.z.string().nullish(),
2303
- text: import_v45.z.string().nullish(),
2304
- placeId: import_v45.z.string().nullish()
2344
+ maps: z5.object({
2345
+ uri: z5.string().nullish(),
2346
+ title: z5.string().nullish(),
2347
+ text: z5.string().nullish(),
2348
+ placeId: z5.string().nullish()
2305
2349
  }).nullish()
2306
2350
  })
2307
2351
  ).nullish(),
2308
- groundingSupports: import_v45.z.array(
2309
- import_v45.z.object({
2310
- segment: import_v45.z.object({
2311
- startIndex: import_v45.z.number().nullish(),
2312
- endIndex: import_v45.z.number().nullish(),
2313
- text: import_v45.z.string().nullish()
2352
+ groundingSupports: z5.array(
2353
+ z5.object({
2354
+ segment: z5.object({
2355
+ startIndex: z5.number().nullish(),
2356
+ endIndex: z5.number().nullish(),
2357
+ text: z5.string().nullish()
2314
2358
  }).nullish(),
2315
- segment_text: import_v45.z.string().nullish(),
2316
- groundingChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
2317
- supportChunkIndices: import_v45.z.array(import_v45.z.number()).nullish(),
2318
- confidenceScores: import_v45.z.array(import_v45.z.number()).nullish(),
2319
- confidenceScore: import_v45.z.array(import_v45.z.number()).nullish()
2359
+ segment_text: z5.string().nullish(),
2360
+ groundingChunkIndices: z5.array(z5.number()).nullish(),
2361
+ supportChunkIndices: z5.array(z5.number()).nullish(),
2362
+ confidenceScores: z5.array(z5.number()).nullish(),
2363
+ confidenceScore: z5.array(z5.number()).nullish()
2320
2364
  })
2321
2365
  ).nullish(),
2322
- retrievalMetadata: import_v45.z.union([
2323
- import_v45.z.object({
2324
- webDynamicRetrievalScore: import_v45.z.number()
2366
+ retrievalMetadata: z5.union([
2367
+ z5.object({
2368
+ webDynamicRetrievalScore: z5.number()
2325
2369
  }),
2326
- import_v45.z.object({})
2370
+ z5.object({})
2327
2371
  ]).nullish()
2328
2372
  });
2329
- var partialArgSchema = import_v45.z.object({
2330
- jsonPath: import_v45.z.string(),
2331
- stringValue: import_v45.z.string().nullish(),
2332
- numberValue: import_v45.z.number().nullish(),
2333
- boolValue: import_v45.z.boolean().nullish(),
2334
- nullValue: import_v45.z.unknown().nullish(),
2335
- willContinue: import_v45.z.boolean().nullish()
2373
+ var partialArgSchema = z5.object({
2374
+ jsonPath: z5.string(),
2375
+ stringValue: z5.string().nullish(),
2376
+ numberValue: z5.number().nullish(),
2377
+ boolValue: z5.boolean().nullish(),
2378
+ nullValue: z5.unknown().nullish(),
2379
+ willContinue: z5.boolean().nullish()
2336
2380
  });
2337
- var getContentSchema = () => import_v45.z.object({
2338
- parts: import_v45.z.array(
2339
- import_v45.z.union([
2381
+ var getContentSchema = () => z5.object({
2382
+ parts: z5.array(
2383
+ z5.union([
2340
2384
  // note: order matters since text can be fully empty
2341
- import_v45.z.object({
2342
- functionCall: import_v45.z.object({
2343
- name: import_v45.z.string().nullish(),
2344
- args: import_v45.z.unknown().nullish(),
2345
- partialArgs: import_v45.z.array(partialArgSchema).nullish(),
2346
- willContinue: import_v45.z.boolean().nullish()
2385
+ z5.object({
2386
+ functionCall: z5.object({
2387
+ name: z5.string().nullish(),
2388
+ args: z5.unknown().nullish(),
2389
+ partialArgs: z5.array(partialArgSchema).nullish(),
2390
+ willContinue: z5.boolean().nullish()
2347
2391
  }),
2348
- thoughtSignature: import_v45.z.string().nullish()
2392
+ thoughtSignature: z5.string().nullish()
2349
2393
  }),
2350
- import_v45.z.object({
2351
- inlineData: import_v45.z.object({
2352
- mimeType: import_v45.z.string(),
2353
- data: import_v45.z.string()
2394
+ z5.object({
2395
+ inlineData: z5.object({
2396
+ mimeType: z5.string(),
2397
+ data: z5.string()
2354
2398
  }),
2355
- thought: import_v45.z.boolean().nullish(),
2356
- thoughtSignature: import_v45.z.string().nullish()
2399
+ thought: z5.boolean().nullish(),
2400
+ thoughtSignature: z5.string().nullish()
2357
2401
  }),
2358
- import_v45.z.object({
2359
- toolCall: import_v45.z.object({
2360
- toolType: import_v45.z.string(),
2361
- args: import_v45.z.unknown().nullish(),
2362
- id: import_v45.z.string()
2402
+ z5.object({
2403
+ toolCall: z5.object({
2404
+ toolType: z5.string(),
2405
+ args: z5.unknown().nullish(),
2406
+ id: z5.string()
2363
2407
  }),
2364
- thoughtSignature: import_v45.z.string().nullish()
2408
+ thoughtSignature: z5.string().nullish()
2365
2409
  }),
2366
- import_v45.z.object({
2367
- toolResponse: import_v45.z.object({
2368
- toolType: import_v45.z.string(),
2369
- response: import_v45.z.unknown().nullish(),
2370
- id: import_v45.z.string()
2410
+ z5.object({
2411
+ toolResponse: z5.object({
2412
+ toolType: z5.string(),
2413
+ response: z5.unknown().nullish(),
2414
+ id: z5.string()
2371
2415
  }),
2372
- thoughtSignature: import_v45.z.string().nullish()
2416
+ thoughtSignature: z5.string().nullish()
2373
2417
  }),
2374
- import_v45.z.object({
2375
- executableCode: import_v45.z.object({
2376
- language: import_v45.z.string(),
2377
- code: import_v45.z.string()
2418
+ z5.object({
2419
+ executableCode: z5.object({
2420
+ language: z5.string(),
2421
+ code: z5.string()
2378
2422
  }).nullish(),
2379
- codeExecutionResult: import_v45.z.object({
2380
- outcome: import_v45.z.string(),
2381
- output: import_v45.z.string().nullish()
2423
+ codeExecutionResult: z5.object({
2424
+ outcome: z5.string(),
2425
+ output: z5.string().nullish()
2382
2426
  }).nullish(),
2383
- text: import_v45.z.string().nullish(),
2384
- thought: import_v45.z.boolean().nullish(),
2385
- thoughtSignature: import_v45.z.string().nullish()
2427
+ text: z5.string().nullish(),
2428
+ thought: z5.boolean().nullish(),
2429
+ thoughtSignature: z5.string().nullish()
2386
2430
  })
2387
2431
  ])
2388
2432
  ).nullish()
2389
2433
  });
2390
- var getSafetyRatingSchema = () => import_v45.z.object({
2391
- category: import_v45.z.string().nullish(),
2392
- probability: import_v45.z.string().nullish(),
2393
- probabilityScore: import_v45.z.number().nullish(),
2394
- severity: import_v45.z.string().nullish(),
2395
- severityScore: import_v45.z.number().nullish(),
2396
- blocked: import_v45.z.boolean().nullish()
2434
+ var getSafetyRatingSchema = () => z5.object({
2435
+ category: z5.string().nullish(),
2436
+ probability: z5.string().nullish(),
2437
+ probabilityScore: z5.number().nullish(),
2438
+ severity: z5.string().nullish(),
2439
+ severityScore: z5.number().nullish(),
2440
+ blocked: z5.boolean().nullish()
2397
2441
  });
2398
- var tokenDetailsSchema = import_v45.z.array(
2399
- import_v45.z.object({
2400
- modality: import_v45.z.string(),
2401
- tokenCount: import_v45.z.number()
2442
+ var tokenDetailsSchema = z5.array(
2443
+ z5.object({
2444
+ modality: z5.string(),
2445
+ tokenCount: z5.number()
2402
2446
  })
2403
2447
  ).nullish();
2404
- var usageSchema = import_v45.z.object({
2405
- cachedContentTokenCount: import_v45.z.number().nullish(),
2406
- thoughtsTokenCount: import_v45.z.number().nullish(),
2407
- promptTokenCount: import_v45.z.number().nullish(),
2408
- candidatesTokenCount: import_v45.z.number().nullish(),
2409
- totalTokenCount: import_v45.z.number().nullish(),
2448
+ var usageSchema = z5.object({
2449
+ cachedContentTokenCount: z5.number().nullish(),
2450
+ thoughtsTokenCount: z5.number().nullish(),
2451
+ promptTokenCount: z5.number().nullish(),
2452
+ candidatesTokenCount: z5.number().nullish(),
2453
+ totalTokenCount: z5.number().nullish(),
2410
2454
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
2411
- trafficType: import_v45.z.string().nullish(),
2455
+ trafficType: z5.string().nullish(),
2412
2456
  // https://ai.google.dev/api/generate-content#Modality
2413
2457
  promptTokensDetails: tokenDetailsSchema,
2414
2458
  candidatesTokensDetails: tokenDetailsSchema
2415
2459
  });
2416
- var getUrlContextMetadataSchema = () => import_v45.z.object({
2417
- urlMetadata: import_v45.z.array(
2418
- import_v45.z.object({
2419
- retrievedUrl: import_v45.z.string(),
2420
- urlRetrievalStatus: import_v45.z.string()
2460
+ var getUrlContextMetadataSchema = () => z5.object({
2461
+ urlMetadata: z5.array(
2462
+ z5.object({
2463
+ retrievedUrl: z5.string(),
2464
+ urlRetrievalStatus: z5.string()
2421
2465
  })
2422
2466
  ).nullish()
2423
2467
  });
2424
- var responseSchema = (0, import_provider_utils6.lazySchema)(
2425
- () => (0, import_provider_utils6.zodSchema)(
2426
- import_v45.z.object({
2427
- candidates: import_v45.z.array(
2428
- import_v45.z.object({
2429
- content: getContentSchema().nullish().or(import_v45.z.object({}).strict()),
2430
- finishReason: import_v45.z.string().nullish(),
2431
- finishMessage: import_v45.z.string().nullish(),
2432
- safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish(),
2468
+ var responseSchema = lazySchema5(
2469
+ () => zodSchema5(
2470
+ z5.object({
2471
+ candidates: z5.array(
2472
+ z5.object({
2473
+ content: getContentSchema().nullish().or(z5.object({}).strict()),
2474
+ finishReason: z5.string().nullish(),
2475
+ finishMessage: z5.string().nullish(),
2476
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
2433
2477
  groundingMetadata: getGroundingMetadataSchema().nullish(),
2434
2478
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2435
2479
  })
2436
2480
  ),
2437
2481
  usageMetadata: usageSchema.nullish(),
2438
- promptFeedback: import_v45.z.object({
2439
- blockReason: import_v45.z.string().nullish(),
2440
- safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
2482
+ promptFeedback: z5.object({
2483
+ blockReason: z5.string().nullish(),
2484
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
2441
2485
  }).nullish(),
2442
- serviceTier: import_v45.z.string().nullish()
2486
+ serviceTier: z5.string().nullish()
2443
2487
  })
2444
2488
  )
2445
2489
  );
2446
- var chunkSchema = (0, import_provider_utils6.lazySchema)(
2447
- () => (0, import_provider_utils6.zodSchema)(
2448
- import_v45.z.object({
2449
- candidates: import_v45.z.array(
2450
- import_v45.z.object({
2490
+ var chunkSchema = lazySchema5(
2491
+ () => zodSchema5(
2492
+ z5.object({
2493
+ candidates: z5.array(
2494
+ z5.object({
2451
2495
  content: getContentSchema().nullish(),
2452
- finishReason: import_v45.z.string().nullish(),
2453
- finishMessage: import_v45.z.string().nullish(),
2454
- safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish(),
2496
+ finishReason: z5.string().nullish(),
2497
+ finishMessage: z5.string().nullish(),
2498
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
2455
2499
  groundingMetadata: getGroundingMetadataSchema().nullish(),
2456
2500
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
2457
2501
  })
2458
2502
  ).nullish(),
2459
2503
  usageMetadata: usageSchema.nullish(),
2460
- promptFeedback: import_v45.z.object({
2461
- blockReason: import_v45.z.string().nullish(),
2462
- safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
2504
+ promptFeedback: z5.object({
2505
+ blockReason: z5.string().nullish(),
2506
+ safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
2463
2507
  }).nullish(),
2464
- serviceTier: import_v45.z.string().nullish()
2508
+ serviceTier: z5.string().nullish()
2465
2509
  })
2466
2510
  )
2467
2511
  );
2468
2512
 
2469
2513
  // src/tool/code-execution.ts
2470
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
2471
- var import_v46 = require("zod/v4");
2472
- var codeExecution = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
2514
+ import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
2515
+ import { z as z6 } from "zod/v4";
2516
+ var codeExecution = createProviderToolFactoryWithOutputSchema({
2473
2517
  id: "google.code_execution",
2474
- inputSchema: import_v46.z.object({
2475
- language: import_v46.z.string().describe("The programming language of the code."),
2476
- code: import_v46.z.string().describe("The code to be executed.")
2518
+ inputSchema: z6.object({
2519
+ language: z6.string().describe("The programming language of the code."),
2520
+ code: z6.string().describe("The code to be executed.")
2477
2521
  }),
2478
- outputSchema: import_v46.z.object({
2479
- outcome: import_v46.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
2480
- output: import_v46.z.string().describe("The output from the code execution.")
2522
+ outputSchema: z6.object({
2523
+ outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
2524
+ output: z6.string().describe("The output from the code execution.")
2481
2525
  })
2482
2526
  });
2483
2527
 
2484
2528
  // src/tool/enterprise-web-search.ts
2485
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
2486
- var import_v47 = require("zod/v4");
2487
- var enterpriseWebSearch = (0, import_provider_utils8.createProviderToolFactory)({
2529
+ import {
2530
+ createProviderToolFactory,
2531
+ lazySchema as lazySchema6,
2532
+ zodSchema as zodSchema6
2533
+ } from "@ai-sdk/provider-utils";
2534
+ import { z as z7 } from "zod/v4";
2535
+ var enterpriseWebSearch = createProviderToolFactory({
2488
2536
  id: "google.enterprise_web_search",
2489
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v47.z.object({})))
2537
+ inputSchema: lazySchema6(() => zodSchema6(z7.object({})))
2490
2538
  });
2491
2539
 
2492
2540
  // src/tool/file-search.ts
2493
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
2494
- var import_v48 = require("zod/v4");
2495
- var fileSearchArgsBaseSchema = import_v48.z.object({
2541
+ import {
2542
+ createProviderToolFactory as createProviderToolFactory2,
2543
+ lazySchema as lazySchema7,
2544
+ zodSchema as zodSchema7
2545
+ } from "@ai-sdk/provider-utils";
2546
+ import { z as z8 } from "zod/v4";
2547
+ var fileSearchArgsBaseSchema = z8.object({
2496
2548
  /** The names of the file_search_stores to retrieve from.
2497
2549
  * Example: `fileSearchStores/my-file-search-store-123`
2498
2550
  */
2499
- fileSearchStoreNames: import_v48.z.array(import_v48.z.string()).describe(
2551
+ fileSearchStoreNames: z8.array(z8.string()).describe(
2500
2552
  "The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
2501
2553
  ),
2502
2554
  /** The number of file search retrieval chunks to retrieve. */
2503
- topK: import_v48.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
2555
+ topK: z8.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
2504
2556
  /** Metadata filter to apply to the file search retrieval documents.
2505
2557
  * See https://google.aip.dev/160 for the syntax of the filter expression.
2506
2558
  */
2507
- metadataFilter: import_v48.z.string().describe(
2559
+ metadataFilter: z8.string().describe(
2508
2560
  "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
2509
2561
  ).optional()
2510
2562
  }).passthrough();
2511
- var fileSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
2512
- () => (0, import_provider_utils9.zodSchema)(fileSearchArgsBaseSchema)
2563
+ var fileSearchArgsSchema = lazySchema7(
2564
+ () => zodSchema7(fileSearchArgsBaseSchema)
2513
2565
  );
2514
- var fileSearch = (0, import_provider_utils9.createProviderToolFactory)({
2566
+ var fileSearch = createProviderToolFactory2({
2515
2567
  id: "google.file_search",
2516
2568
  inputSchema: fileSearchArgsSchema
2517
2569
  });
2518
2570
 
2519
2571
  // src/tool/google-maps.ts
2520
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
2521
- var import_v49 = require("zod/v4");
2522
- var googleMaps = (0, import_provider_utils10.createProviderToolFactory)({
2572
+ import {
2573
+ createProviderToolFactory as createProviderToolFactory3,
2574
+ lazySchema as lazySchema8,
2575
+ zodSchema as zodSchema8
2576
+ } from "@ai-sdk/provider-utils";
2577
+ import { z as z9 } from "zod/v4";
2578
+ var googleMaps = createProviderToolFactory3({
2523
2579
  id: "google.google_maps",
2524
- inputSchema: (0, import_provider_utils10.lazySchema)(() => (0, import_provider_utils10.zodSchema)(import_v49.z.object({})))
2580
+ inputSchema: lazySchema8(() => zodSchema8(z9.object({})))
2525
2581
  });
2526
2582
 
2527
2583
  // src/tool/google-search.ts
2528
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2529
- var import_v410 = require("zod/v4");
2530
- var googleSearchToolArgsBaseSchema = import_v410.z.object({
2531
- searchTypes: import_v410.z.object({
2532
- webSearch: import_v410.z.object({}).optional(),
2533
- imageSearch: import_v410.z.object({}).optional()
2584
+ import {
2585
+ createProviderToolFactory as createProviderToolFactory4,
2586
+ lazySchema as lazySchema9,
2587
+ zodSchema as zodSchema9
2588
+ } from "@ai-sdk/provider-utils";
2589
+ import { z as z10 } from "zod/v4";
2590
+ var googleSearchToolArgsBaseSchema = z10.object({
2591
+ searchTypes: z10.object({
2592
+ webSearch: z10.object({}).optional(),
2593
+ imageSearch: z10.object({}).optional()
2534
2594
  }).optional(),
2535
- timeRangeFilter: import_v410.z.object({
2536
- startTime: import_v410.z.string(),
2537
- endTime: import_v410.z.string()
2595
+ timeRangeFilter: z10.object({
2596
+ startTime: z10.string(),
2597
+ endTime: z10.string()
2538
2598
  }).optional()
2539
2599
  }).passthrough();
2540
- var googleSearchToolArgsSchema = (0, import_provider_utils11.lazySchema)(
2541
- () => (0, import_provider_utils11.zodSchema)(googleSearchToolArgsBaseSchema)
2600
+ var googleSearchToolArgsSchema = lazySchema9(
2601
+ () => zodSchema9(googleSearchToolArgsBaseSchema)
2542
2602
  );
2543
- var googleSearch = (0, import_provider_utils11.createProviderToolFactory)(
2603
+ var googleSearch = createProviderToolFactory4(
2544
2604
  {
2545
2605
  id: "google.google_search",
2546
2606
  inputSchema: googleSearchToolArgsSchema
@@ -2548,21 +2608,25 @@ var googleSearch = (0, import_provider_utils11.createProviderToolFactory)(
2548
2608
  );
2549
2609
 
2550
2610
  // src/tool/url-context.ts
2551
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2552
- var import_v411 = require("zod/v4");
2553
- var urlContext = (0, import_provider_utils12.createProviderToolFactory)({
2611
+ import {
2612
+ createProviderToolFactory as createProviderToolFactory5,
2613
+ lazySchema as lazySchema10,
2614
+ zodSchema as zodSchema10
2615
+ } from "@ai-sdk/provider-utils";
2616
+ import { z as z11 } from "zod/v4";
2617
+ var urlContext = createProviderToolFactory5({
2554
2618
  id: "google.url_context",
2555
- inputSchema: (0, import_provider_utils12.lazySchema)(() => (0, import_provider_utils12.zodSchema)(import_v411.z.object({})))
2619
+ inputSchema: lazySchema10(() => zodSchema10(z11.object({})))
2556
2620
  });
2557
2621
 
2558
2622
  // src/tool/vertex-rag-store.ts
2559
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2560
- var import_v412 = require("zod/v4");
2561
- var vertexRagStore = (0, import_provider_utils13.createProviderToolFactory)({
2623
+ import { createProviderToolFactory as createProviderToolFactory6 } from "@ai-sdk/provider-utils";
2624
+ import { z as z12 } from "zod/v4";
2625
+ var vertexRagStore = createProviderToolFactory6({
2562
2626
  id: "google.vertex_rag_store",
2563
- inputSchema: import_v412.z.object({
2564
- ragCorpus: import_v412.z.string(),
2565
- topK: import_v412.z.number().optional()
2627
+ inputSchema: z12.object({
2628
+ ragCorpus: z12.string(),
2629
+ topK: z12.number().optional()
2566
2630
  })
2567
2631
  });
2568
2632
 
@@ -2627,15 +2691,41 @@ var googleTools = {
2627
2691
  };
2628
2692
 
2629
2693
  // src/google-generative-ai-image-model.ts
2630
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2631
- var import_v413 = require("zod/v4");
2632
- var GoogleGenerativeAIImageModel = class {
2694
+ import {
2695
+ combineHeaders as combineHeaders3,
2696
+ convertToBase64 as convertToBase642,
2697
+ createJsonResponseHandler as createJsonResponseHandler3,
2698
+ generateId as defaultGenerateId,
2699
+ lazySchema as lazySchema11,
2700
+ parseProviderOptions as parseProviderOptions3,
2701
+ postJsonToApi as postJsonToApi3,
2702
+ resolve as resolve3,
2703
+ serializeModelOptions as serializeModelOptions3,
2704
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
2705
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
2706
+ zodSchema as zodSchema11
2707
+ } from "@ai-sdk/provider-utils";
2708
+ import { z as z13 } from "zod/v4";
2709
+ var GoogleGenerativeAIImageModel = class _GoogleGenerativeAIImageModel {
2633
2710
  constructor(modelId, settings, config) {
2634
2711
  this.modelId = modelId;
2635
2712
  this.settings = settings;
2636
2713
  this.config = config;
2637
2714
  this.specificationVersion = "v4";
2638
2715
  }
2716
+ static [WORKFLOW_SERIALIZE3](model) {
2717
+ return serializeModelOptions3({
2718
+ modelId: model.modelId,
2719
+ config: model.config
2720
+ });
2721
+ }
2722
+ static [WORKFLOW_DESERIALIZE3](options) {
2723
+ return new _GoogleGenerativeAIImageModel(
2724
+ options.modelId,
2725
+ {},
2726
+ options.config
2727
+ );
2728
+ }
2639
2729
  get maxImagesPerCall() {
2640
2730
  if (this.settings.maxImagesPerCall != null) {
2641
2731
  return this.settings.maxImagesPerCall;
@@ -2693,7 +2783,7 @@ var GoogleGenerativeAIImageModel = class {
2693
2783
  details: "This model does not support the `seed` option through this provider."
2694
2784
  });
2695
2785
  }
2696
- const googleOptions = await (0, import_provider_utils14.parseProviderOptions)({
2786
+ const googleOptions = await parseProviderOptions3({
2697
2787
  provider: "google",
2698
2788
  providerOptions,
2699
2789
  schema: googleImageModelOptionsSchema
@@ -2712,12 +2802,15 @@ var GoogleGenerativeAIImageModel = class {
2712
2802
  instances: [{ prompt }],
2713
2803
  parameters
2714
2804
  };
2715
- const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
2805
+ const { responseHeaders, value: response } = await postJsonToApi3({
2716
2806
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
2717
- headers: (0, import_provider_utils14.combineHeaders)(await (0, import_provider_utils14.resolve)(this.config.headers), headers),
2807
+ headers: combineHeaders3(
2808
+ this.config.headers ? await resolve3(this.config.headers) : void 0,
2809
+ headers
2810
+ ),
2718
2811
  body,
2719
2812
  failedResponseHandler: googleFailedResponseHandler,
2720
- successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
2813
+ successfulResponseHandler: createJsonResponseHandler3(
2721
2814
  googleImageResponseSchema
2722
2815
  ),
2723
2816
  abortSignal,
@@ -2803,7 +2896,7 @@ var GoogleGenerativeAIImageModel = class {
2803
2896
  baseURL: this.config.baseURL,
2804
2897
  headers: (_a = this.config.headers) != null ? _a : {},
2805
2898
  fetch: this.config.fetch,
2806
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils14.generateId
2899
+ generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId
2807
2900
  });
2808
2901
  const result = await languageModel.doGenerate({
2809
2902
  prompt: languageModelPrompt,
@@ -2824,7 +2917,7 @@ var GoogleGenerativeAIImageModel = class {
2824
2917
  const images = [];
2825
2918
  for (const part of result.content) {
2826
2919
  if (part.type === "file" && part.mediaType.startsWith("image/")) {
2827
- images.push((0, import_provider_utils14.convertToBase64)(part.data));
2920
+ images.push(convertToBase642(part.data));
2828
2921
  }
2829
2922
  }
2830
2923
  return {
@@ -2851,26 +2944,36 @@ var GoogleGenerativeAIImageModel = class {
2851
2944
  function isGeminiModel(modelId) {
2852
2945
  return modelId.startsWith("gemini-");
2853
2946
  }
2854
- var googleImageResponseSchema = (0, import_provider_utils14.lazySchema)(
2855
- () => (0, import_provider_utils14.zodSchema)(
2856
- import_v413.z.object({
2857
- predictions: import_v413.z.array(import_v413.z.object({ bytesBase64Encoded: import_v413.z.string() })).default([])
2947
+ var googleImageResponseSchema = lazySchema11(
2948
+ () => zodSchema11(
2949
+ z13.object({
2950
+ predictions: z13.array(z13.object({ bytesBase64Encoded: z13.string() })).default([])
2858
2951
  })
2859
2952
  )
2860
2953
  );
2861
- var googleImageModelOptionsSchema = (0, import_provider_utils14.lazySchema)(
2862
- () => (0, import_provider_utils14.zodSchema)(
2863
- import_v413.z.object({
2864
- personGeneration: import_v413.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
2865
- aspectRatio: import_v413.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
2954
+ var googleImageModelOptionsSchema = lazySchema11(
2955
+ () => zodSchema11(
2956
+ z13.object({
2957
+ personGeneration: z13.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
2958
+ aspectRatio: z13.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
2866
2959
  })
2867
2960
  )
2868
2961
  );
2869
2962
 
2870
2963
  // src/google-generative-ai-files.ts
2871
- var import_provider4 = require("@ai-sdk/provider");
2872
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
2873
- var import_v414 = require("zod/v4");
2964
+ import {
2965
+ AISDKError
2966
+ } from "@ai-sdk/provider";
2967
+ import {
2968
+ combineHeaders as combineHeaders4,
2969
+ createJsonResponseHandler as createJsonResponseHandler4,
2970
+ delay,
2971
+ lazySchema as lazySchema12,
2972
+ parseProviderOptions as parseProviderOptions4,
2973
+ zodSchema as zodSchema12,
2974
+ getFromApi
2975
+ } from "@ai-sdk/provider-utils";
2976
+ import { z as z14 } from "zod/v4";
2874
2977
  var GoogleGenerativeAIFiles = class {
2875
2978
  constructor(config) {
2876
2979
  this.config = config;
@@ -2881,7 +2984,7 @@ var GoogleGenerativeAIFiles = class {
2881
2984
  }
2882
2985
  async uploadFile(options) {
2883
2986
  var _a, _b, _c, _d;
2884
- const googleOptions = await (0, import_provider_utils15.parseProviderOptions)({
2987
+ const googleOptions = await parseProviderOptions4({
2885
2988
  provider: "google",
2886
2989
  providerOptions: options.providerOptions,
2887
2990
  schema: googleFilesUploadOptionsSchema
@@ -2915,14 +3018,14 @@ var GoogleGenerativeAIFiles = class {
2915
3018
  });
2916
3019
  if (!initResponse.ok) {
2917
3020
  const errorBody = await initResponse.text();
2918
- throw new import_provider4.AISDKError({
3021
+ throw new AISDKError({
2919
3022
  name: "GOOGLE_FILES_UPLOAD_ERROR",
2920
3023
  message: `Failed to initiate resumable upload: ${initResponse.status} ${errorBody}`
2921
3024
  });
2922
3025
  }
2923
3026
  const uploadUrl = initResponse.headers.get("x-goog-upload-url");
2924
3027
  if (!uploadUrl) {
2925
- throw new import_provider4.AISDKError({
3028
+ throw new AISDKError({
2926
3029
  name: "GOOGLE_FILES_UPLOAD_ERROR",
2927
3030
  message: "No upload URL returned from initiation request"
2928
3031
  });
@@ -2938,7 +3041,7 @@ var GoogleGenerativeAIFiles = class {
2938
3041
  });
2939
3042
  if (!uploadResponse.ok) {
2940
3043
  const errorBody = await uploadResponse.text();
2941
- throw new import_provider4.AISDKError({
3044
+ throw new AISDKError({
2942
3045
  name: "GOOGLE_FILES_UPLOAD_ERROR",
2943
3046
  message: `Failed to upload file data: ${uploadResponse.status} ${errorBody}`
2944
3047
  });
@@ -2950,16 +3053,16 @@ var GoogleGenerativeAIFiles = class {
2950
3053
  const startTime = Date.now();
2951
3054
  while (file.state === "PROCESSING") {
2952
3055
  if (Date.now() - startTime > pollTimeoutMs) {
2953
- throw new import_provider4.AISDKError({
3056
+ throw new AISDKError({
2954
3057
  name: "GOOGLE_FILES_UPLOAD_TIMEOUT",
2955
3058
  message: `File processing timed out after ${pollTimeoutMs}ms`
2956
3059
  });
2957
3060
  }
2958
- await (0, import_provider_utils15.delay)(pollIntervalMs);
2959
- const { value: fileStatus } = await (0, import_provider_utils15.getFromApi)({
3061
+ await delay(pollIntervalMs);
3062
+ const { value: fileStatus } = await getFromApi({
2960
3063
  url: `${this.config.baseURL}/${file.name}`,
2961
- headers: (0, import_provider_utils15.combineHeaders)(resolvedHeaders),
2962
- successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3064
+ headers: combineHeaders4(resolvedHeaders),
3065
+ successfulResponseHandler: createJsonResponseHandler4(
2963
3066
  googleFileResponseSchema
2964
3067
  ),
2965
3068
  failedResponseHandler: googleFailedResponseHandler,
@@ -2968,7 +3071,7 @@ var GoogleGenerativeAIFiles = class {
2968
3071
  file = fileStatus;
2969
3072
  }
2970
3073
  if (file.state === "FAILED") {
2971
- throw new import_provider4.AISDKError({
3074
+ throw new AISDKError({
2972
3075
  name: "GOOGLE_FILES_UPLOAD_FAILED",
2973
3076
  message: `File processing failed for ${file.name}`
2974
3077
  });
@@ -2994,36 +3097,49 @@ var GoogleGenerativeAIFiles = class {
2994
3097
  };
2995
3098
  }
2996
3099
  };
2997
- var googleFileResponseSchema = (0, import_provider_utils15.lazySchema)(
2998
- () => (0, import_provider_utils15.zodSchema)(
2999
- import_v414.z.object({
3000
- name: import_v414.z.string(),
3001
- displayName: import_v414.z.string().nullish(),
3002
- mimeType: import_v414.z.string(),
3003
- sizeBytes: import_v414.z.string().nullish(),
3004
- createTime: import_v414.z.string().nullish(),
3005
- updateTime: import_v414.z.string().nullish(),
3006
- expirationTime: import_v414.z.string().nullish(),
3007
- sha256Hash: import_v414.z.string().nullish(),
3008
- uri: import_v414.z.string(),
3009
- state: import_v414.z.string()
3100
+ var googleFileResponseSchema = lazySchema12(
3101
+ () => zodSchema12(
3102
+ z14.object({
3103
+ name: z14.string(),
3104
+ displayName: z14.string().nullish(),
3105
+ mimeType: z14.string(),
3106
+ sizeBytes: z14.string().nullish(),
3107
+ createTime: z14.string().nullish(),
3108
+ updateTime: z14.string().nullish(),
3109
+ expirationTime: z14.string().nullish(),
3110
+ sha256Hash: z14.string().nullish(),
3111
+ uri: z14.string(),
3112
+ state: z14.string()
3010
3113
  })
3011
3114
  )
3012
3115
  );
3013
- var googleFilesUploadOptionsSchema = (0, import_provider_utils15.lazySchema)(
3014
- () => (0, import_provider_utils15.zodSchema)(
3015
- import_v414.z.object({
3016
- displayName: import_v414.z.string().nullish(),
3017
- pollIntervalMs: import_v414.z.number().positive().nullish(),
3018
- pollTimeoutMs: import_v414.z.number().positive().nullish()
3116
+ var googleFilesUploadOptionsSchema = lazySchema12(
3117
+ () => zodSchema12(
3118
+ z14.object({
3119
+ displayName: z14.string().nullish(),
3120
+ pollIntervalMs: z14.number().positive().nullish(),
3121
+ pollTimeoutMs: z14.number().positive().nullish()
3019
3122
  }).passthrough()
3020
3123
  )
3021
3124
  );
3022
3125
 
3023
3126
  // src/google-generative-ai-video-model.ts
3024
- var import_provider5 = require("@ai-sdk/provider");
3025
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3026
- var import_v415 = require("zod/v4");
3127
+ import {
3128
+ AISDKError as AISDKError2
3129
+ } from "@ai-sdk/provider";
3130
+ import {
3131
+ combineHeaders as combineHeaders5,
3132
+ convertUint8ArrayToBase64,
3133
+ createJsonResponseHandler as createJsonResponseHandler5,
3134
+ delay as delay2,
3135
+ getFromApi as getFromApi2,
3136
+ lazySchema as lazySchema13,
3137
+ parseProviderOptions as parseProviderOptions5,
3138
+ postJsonToApi as postJsonToApi4,
3139
+ resolve as resolve4,
3140
+ zodSchema as zodSchema13
3141
+ } from "@ai-sdk/provider-utils";
3142
+ import { z as z15 } from "zod/v4";
3027
3143
  var GoogleGenerativeAIVideoModel = class {
3028
3144
  constructor(modelId, config) {
3029
3145
  this.modelId = modelId;
@@ -3040,7 +3156,7 @@ var GoogleGenerativeAIVideoModel = class {
3040
3156
  var _a, _b, _c, _d, _e, _f, _g, _h;
3041
3157
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3042
3158
  const warnings = [];
3043
- const googleOptions = await (0, import_provider_utils16.parseProviderOptions)({
3159
+ const googleOptions = await parseProviderOptions5({
3044
3160
  provider: "google",
3045
3161
  providerOptions: options.providerOptions,
3046
3162
  schema: googleVideoModelOptionsSchema
@@ -3058,7 +3174,7 @@ var GoogleGenerativeAIVideoModel = class {
3058
3174
  details: "Google Generative AI video models require base64-encoded images. URL will be ignored."
3059
3175
  });
3060
3176
  } else {
3061
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils16.convertUint8ArrayToBase64)(options.image.data);
3177
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
3062
3178
  instance.image = {
3063
3179
  inlineData: {
3064
3180
  mimeType: options.image.mediaType || "image/png",
@@ -3124,17 +3240,17 @@ var GoogleGenerativeAIVideoModel = class {
3124
3240
  }
3125
3241
  }
3126
3242
  }
3127
- const { value: operation } = await (0, import_provider_utils16.postJsonToApi)({
3243
+ const { value: operation } = await postJsonToApi4({
3128
3244
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
3129
- headers: (0, import_provider_utils16.combineHeaders)(
3130
- await (0, import_provider_utils16.resolve)(this.config.headers),
3245
+ headers: combineHeaders5(
3246
+ await resolve4(this.config.headers),
3131
3247
  options.headers
3132
3248
  ),
3133
3249
  body: {
3134
3250
  instances,
3135
3251
  parameters
3136
3252
  },
3137
- successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
3253
+ successfulResponseHandler: createJsonResponseHandler5(
3138
3254
  googleOperationSchema
3139
3255
  ),
3140
3256
  failedResponseHandler: googleFailedResponseHandler,
@@ -3143,7 +3259,7 @@ var GoogleGenerativeAIVideoModel = class {
3143
3259
  });
3144
3260
  const operationName = operation.name;
3145
3261
  if (!operationName) {
3146
- throw new import_provider5.AISDKError({
3262
+ throw new AISDKError2({
3147
3263
  name: "GOOGLE_VIDEO_GENERATION_ERROR",
3148
3264
  message: "No operation name returned from API"
3149
3265
  });
@@ -3155,25 +3271,25 @@ var GoogleGenerativeAIVideoModel = class {
3155
3271
  let responseHeaders;
3156
3272
  while (!finalOperation.done) {
3157
3273
  if (Date.now() - startTime > pollTimeoutMs) {
3158
- throw new import_provider5.AISDKError({
3274
+ throw new AISDKError2({
3159
3275
  name: "GOOGLE_VIDEO_GENERATION_TIMEOUT",
3160
3276
  message: `Video generation timed out after ${pollTimeoutMs}ms`
3161
3277
  });
3162
3278
  }
3163
- await (0, import_provider_utils16.delay)(pollIntervalMs);
3279
+ await delay2(pollIntervalMs);
3164
3280
  if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
3165
- throw new import_provider5.AISDKError({
3281
+ throw new AISDKError2({
3166
3282
  name: "GOOGLE_VIDEO_GENERATION_ABORTED",
3167
3283
  message: "Video generation request was aborted"
3168
3284
  });
3169
3285
  }
3170
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils16.getFromApi)({
3286
+ const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi2({
3171
3287
  url: `${this.config.baseURL}/${operationName}`,
3172
- headers: (0, import_provider_utils16.combineHeaders)(
3173
- await (0, import_provider_utils16.resolve)(this.config.headers),
3288
+ headers: combineHeaders5(
3289
+ await resolve4(this.config.headers),
3174
3290
  options.headers
3175
3291
  ),
3176
- successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
3292
+ successfulResponseHandler: createJsonResponseHandler5(
3177
3293
  googleOperationSchema
3178
3294
  ),
3179
3295
  failedResponseHandler: googleFailedResponseHandler,
@@ -3184,21 +3300,21 @@ var GoogleGenerativeAIVideoModel = class {
3184
3300
  responseHeaders = pollHeaders;
3185
3301
  }
3186
3302
  if (finalOperation.error) {
3187
- throw new import_provider5.AISDKError({
3303
+ throw new AISDKError2({
3188
3304
  name: "GOOGLE_VIDEO_GENERATION_FAILED",
3189
3305
  message: `Video generation failed: ${finalOperation.error.message}`
3190
3306
  });
3191
3307
  }
3192
3308
  const response = finalOperation.response;
3193
3309
  if (!((_g = response == null ? void 0 : response.generateVideoResponse) == null ? void 0 : _g.generatedSamples) || response.generateVideoResponse.generatedSamples.length === 0) {
3194
- throw new import_provider5.AISDKError({
3310
+ throw new AISDKError2({
3195
3311
  name: "GOOGLE_VIDEO_GENERATION_ERROR",
3196
3312
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
3197
3313
  });
3198
3314
  }
3199
3315
  const videos = [];
3200
3316
  const videoMetadata = [];
3201
- const resolvedHeaders = await (0, import_provider_utils16.resolve)(this.config.headers);
3317
+ const resolvedHeaders = await resolve4(this.config.headers);
3202
3318
  const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
3203
3319
  for (const generatedSample of response.generateVideoResponse.generatedSamples) {
3204
3320
  if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
@@ -3214,7 +3330,7 @@ var GoogleGenerativeAIVideoModel = class {
3214
3330
  }
3215
3331
  }
3216
3332
  if (videos.length === 0) {
3217
- throw new import_provider5.AISDKError({
3333
+ throw new AISDKError2({
3218
3334
  name: "GOOGLE_VIDEO_GENERATION_ERROR",
3219
3335
  message: "No valid videos in response"
3220
3336
  });
@@ -3235,37 +3351,37 @@ var GoogleGenerativeAIVideoModel = class {
3235
3351
  };
3236
3352
  }
3237
3353
  };
3238
- var googleOperationSchema = import_v415.z.object({
3239
- name: import_v415.z.string().nullish(),
3240
- done: import_v415.z.boolean().nullish(),
3241
- error: import_v415.z.object({
3242
- code: import_v415.z.number().nullish(),
3243
- message: import_v415.z.string(),
3244
- status: import_v415.z.string().nullish()
3354
+ var googleOperationSchema = z15.object({
3355
+ name: z15.string().nullish(),
3356
+ done: z15.boolean().nullish(),
3357
+ error: z15.object({
3358
+ code: z15.number().nullish(),
3359
+ message: z15.string(),
3360
+ status: z15.string().nullish()
3245
3361
  }).nullish(),
3246
- response: import_v415.z.object({
3247
- generateVideoResponse: import_v415.z.object({
3248
- generatedSamples: import_v415.z.array(
3249
- import_v415.z.object({
3250
- video: import_v415.z.object({
3251
- uri: import_v415.z.string().nullish()
3362
+ response: z15.object({
3363
+ generateVideoResponse: z15.object({
3364
+ generatedSamples: z15.array(
3365
+ z15.object({
3366
+ video: z15.object({
3367
+ uri: z15.string().nullish()
3252
3368
  }).nullish()
3253
3369
  })
3254
3370
  ).nullish()
3255
3371
  }).nullish()
3256
3372
  }).nullish()
3257
3373
  });
3258
- var googleVideoModelOptionsSchema = (0, import_provider_utils16.lazySchema)(
3259
- () => (0, import_provider_utils16.zodSchema)(
3260
- import_v415.z.object({
3261
- pollIntervalMs: import_v415.z.number().positive().nullish(),
3262
- pollTimeoutMs: import_v415.z.number().positive().nullish(),
3263
- personGeneration: import_v415.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
3264
- negativePrompt: import_v415.z.string().nullish(),
3265
- referenceImages: import_v415.z.array(
3266
- import_v415.z.object({
3267
- bytesBase64Encoded: import_v415.z.string().nullish(),
3268
- gcsUri: import_v415.z.string().nullish()
3374
+ var googleVideoModelOptionsSchema = lazySchema13(
3375
+ () => zodSchema13(
3376
+ z15.object({
3377
+ pollIntervalMs: z15.number().positive().nullish(),
3378
+ pollTimeoutMs: z15.number().positive().nullish(),
3379
+ personGeneration: z15.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
3380
+ negativePrompt: z15.string().nullish(),
3381
+ referenceImages: z15.array(
3382
+ z15.object({
3383
+ bytesBase64Encoded: z15.string().nullish(),
3384
+ gcsUri: z15.string().nullish()
3269
3385
  })
3270
3386
  ).nullish()
3271
3387
  }).passthrough()
@@ -3275,11 +3391,11 @@ var googleVideoModelOptionsSchema = (0, import_provider_utils16.lazySchema)(
3275
3391
  // src/google-provider.ts
3276
3392
  function createGoogleGenerativeAI(options = {}) {
3277
3393
  var _a, _b;
3278
- const baseURL = (_a = (0, import_provider_utils17.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
3394
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
3279
3395
  const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
3280
- const getHeaders = () => (0, import_provider_utils17.withUserAgentSuffix)(
3396
+ const getHeaders = () => withUserAgentSuffix(
3281
3397
  {
3282
- "x-goog-api-key": (0, import_provider_utils17.loadApiKey)({
3398
+ "x-goog-api-key": loadApiKey({
3283
3399
  apiKey: options.apiKey,
3284
3400
  environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
3285
3401
  description: "Google Generative AI"
@@ -3294,7 +3410,7 @@ function createGoogleGenerativeAI(options = {}) {
3294
3410
  provider: providerName,
3295
3411
  baseURL,
3296
3412
  headers: getHeaders,
3297
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils17.generateId,
3413
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
3298
3414
  supportedUrls: () => ({
3299
3415
  "*": [
3300
3416
  // Google Generative Language "files" endpoint
@@ -3335,7 +3451,7 @@ function createGoogleGenerativeAI(options = {}) {
3335
3451
  baseURL,
3336
3452
  headers: getHeaders,
3337
3453
  fetch: options.fetch,
3338
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils17.generateId
3454
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2
3339
3455
  });
3340
3456
  };
3341
3457
  const provider = function(modelId) {
@@ -3363,10 +3479,9 @@ function createGoogleGenerativeAI(options = {}) {
3363
3479
  return provider;
3364
3480
  }
3365
3481
  var google = createGoogleGenerativeAI();
3366
- // Annotate the CommonJS export names for ESM import in node:
3367
- 0 && (module.exports = {
3482
+ export {
3368
3483
  VERSION,
3369
3484
  createGoogleGenerativeAI,
3370
3485
  google
3371
- });
3486
+ };
3372
3487
  //# sourceMappingURL=index.js.map