@ai-sdk/google 2.0.17 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.d.mts +139 -132
- package/dist/index.d.ts +139 -132
- package/dist/index.js +332 -270
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +327 -251
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +139 -11
- package/dist/internal/index.d.ts +139 -11
- package/dist/internal/index.js +263 -220
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +254 -205
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
8
8
|
|
9
9
|
// src/version.ts
|
10
|
-
var VERSION = true ? "2.0.
|
10
|
+
var VERSION = true ? "2.0.19" : "0.0.0-test";
|
11
11
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
13
13
|
import {
|
@@ -16,58 +16,76 @@ import {
|
|
16
16
|
import {
|
17
17
|
combineHeaders,
|
18
18
|
createJsonResponseHandler,
|
19
|
+
lazySchema as lazySchema3,
|
19
20
|
parseProviderOptions,
|
20
21
|
postJsonToApi,
|
21
|
-
resolve
|
22
|
+
resolve,
|
23
|
+
zodSchema as zodSchema3
|
22
24
|
} from "@ai-sdk/provider-utils";
|
23
|
-
import
|
25
|
+
import * as z3 from "zod/v4";
|
24
26
|
|
25
27
|
// src/google-error.ts
|
26
|
-
import {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
import {
|
29
|
+
createJsonErrorResponseHandler,
|
30
|
+
lazySchema,
|
31
|
+
zodSchema
|
32
|
+
} from "@ai-sdk/provider-utils";
|
33
|
+
import * as z from "zod/v4";
|
34
|
+
var googleErrorDataSchema = lazySchema(
|
35
|
+
() => zodSchema(
|
36
|
+
z.object({
|
37
|
+
error: z.object({
|
38
|
+
code: z.number().nullable(),
|
39
|
+
message: z.string(),
|
40
|
+
status: z.string()
|
41
|
+
})
|
42
|
+
})
|
43
|
+
)
|
44
|
+
);
|
35
45
|
var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
36
46
|
errorSchema: googleErrorDataSchema,
|
37
47
|
errorToMessage: (data) => data.error.message
|
38
48
|
});
|
39
49
|
|
40
50
|
// src/google-generative-ai-embedding-options.ts
|
41
|
-
import {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
51
|
+
import {
|
52
|
+
lazySchema as lazySchema2,
|
53
|
+
zodSchema as zodSchema2
|
54
|
+
} from "@ai-sdk/provider-utils";
|
55
|
+
import * as z2 from "zod/v4";
|
56
|
+
var googleGenerativeAIEmbeddingProviderOptions = lazySchema2(
|
57
|
+
() => zodSchema2(
|
58
|
+
z2.object({
|
59
|
+
/**
|
60
|
+
* Optional. Optional reduced dimension for the output embedding.
|
61
|
+
* If set, excessive values in the output embedding are truncated from the end.
|
62
|
+
*/
|
63
|
+
outputDimensionality: z2.number().optional(),
|
64
|
+
/**
|
65
|
+
* Optional. Specifies the task type for generating embeddings.
|
66
|
+
* Supported task types:
|
67
|
+
* - SEMANTIC_SIMILARITY: Optimized for text similarity.
|
68
|
+
* - CLASSIFICATION: Optimized for text classification.
|
69
|
+
* - CLUSTERING: Optimized for clustering texts based on similarity.
|
70
|
+
* - RETRIEVAL_DOCUMENT: Optimized for document retrieval.
|
71
|
+
* - RETRIEVAL_QUERY: Optimized for query-based retrieval.
|
72
|
+
* - QUESTION_ANSWERING: Optimized for answering questions.
|
73
|
+
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
74
|
+
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
75
|
+
*/
|
76
|
+
taskType: z2.enum([
|
77
|
+
"SEMANTIC_SIMILARITY",
|
78
|
+
"CLASSIFICATION",
|
79
|
+
"CLUSTERING",
|
80
|
+
"RETRIEVAL_DOCUMENT",
|
81
|
+
"RETRIEVAL_QUERY",
|
82
|
+
"QUESTION_ANSWERING",
|
83
|
+
"FACT_VERIFICATION",
|
84
|
+
"CODE_RETRIEVAL_QUERY"
|
85
|
+
]).optional()
|
86
|
+
})
|
87
|
+
)
|
88
|
+
);
|
71
89
|
|
72
90
|
// src/google-generative-ai-embedding-model.ts
|
73
91
|
var GoogleGenerativeAIEmbeddingModel = class {
|
@@ -162,12 +180,20 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
162
180
|
};
|
163
181
|
}
|
164
182
|
};
|
165
|
-
var googleGenerativeAITextEmbeddingResponseSchema =
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
183
|
+
var googleGenerativeAITextEmbeddingResponseSchema = lazySchema3(
|
184
|
+
() => zodSchema3(
|
185
|
+
z3.object({
|
186
|
+
embeddings: z3.array(z3.object({ values: z3.array(z3.number()) }))
|
187
|
+
})
|
188
|
+
)
|
189
|
+
);
|
190
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
191
|
+
() => zodSchema3(
|
192
|
+
z3.object({
|
193
|
+
embedding: z3.object({ values: z3.array(z3.number()) })
|
194
|
+
})
|
195
|
+
)
|
196
|
+
);
|
171
197
|
|
172
198
|
// src/google-generative-ai-language-model.ts
|
173
199
|
import {
|
@@ -175,11 +201,13 @@ import {
|
|
175
201
|
createEventSourceResponseHandler,
|
176
202
|
createJsonResponseHandler as createJsonResponseHandler2,
|
177
203
|
generateId,
|
204
|
+
lazySchema as lazySchema5,
|
178
205
|
parseProviderOptions as parseProviderOptions2,
|
179
206
|
postJsonToApi as postJsonToApi2,
|
180
|
-
resolve as resolve2
|
207
|
+
resolve as resolve2,
|
208
|
+
zodSchema as zodSchema5
|
181
209
|
} from "@ai-sdk/provider-utils";
|
182
|
-
import
|
210
|
+
import * as z5 from "zod/v4";
|
183
211
|
|
184
212
|
// src/convert-json-schema-to-openapi-schema.ts
|
185
213
|
function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
@@ -204,12 +232,9 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
204
232
|
enum: enumValues
|
205
233
|
} = jsonSchema;
|
206
234
|
const result = {};
|
207
|
-
if (description)
|
208
|
-
|
209
|
-
if (
|
210
|
-
result.required = required;
|
211
|
-
if (format)
|
212
|
-
result.format = format;
|
235
|
+
if (description) result.description = description;
|
236
|
+
if (required) result.required = required;
|
237
|
+
if (format) result.format = format;
|
213
238
|
if (constValue !== void 0) {
|
214
239
|
result.enum = [constValue];
|
215
240
|
}
|
@@ -456,41 +481,57 @@ function getModelPath(modelId) {
|
|
456
481
|
}
|
457
482
|
|
458
483
|
// src/google-generative-ai-options.ts
|
459
|
-
import {
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
/**
|
467
|
-
Optional.
|
468
|
-
The name of the cached content used as context to serve the prediction.
|
469
|
-
Format: cachedContents/{cachedContent}
|
470
|
-
*/
|
471
|
-
cachedContent: z4.string().optional(),
|
472
|
-
/**
|
473
|
-
* Optional. Enable structured output. Default is true.
|
474
|
-
*
|
475
|
-
* This is useful when the JSON Schema contains elements that are
|
476
|
-
* not supported by the OpenAPI schema version that
|
477
|
-
* Google Generative AI uses. You can use this to disable
|
478
|
-
* structured outputs if you need to.
|
479
|
-
*/
|
480
|
-
structuredOutputs: z4.boolean().optional(),
|
481
|
-
/**
|
482
|
-
Optional. A list of unique safety settings for blocking unsafe content.
|
483
|
-
*/
|
484
|
-
safetySettings: z4.array(
|
484
|
+
import {
|
485
|
+
lazySchema as lazySchema4,
|
486
|
+
zodSchema as zodSchema4
|
487
|
+
} from "@ai-sdk/provider-utils";
|
488
|
+
import * as z4 from "zod/v4";
|
489
|
+
var googleGenerativeAIProviderOptions = lazySchema4(
|
490
|
+
() => zodSchema4(
|
485
491
|
z4.object({
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
492
|
+
responseModalities: z4.array(z4.enum(["TEXT", "IMAGE"])).optional(),
|
493
|
+
thinkingConfig: z4.object({
|
494
|
+
thinkingBudget: z4.number().optional(),
|
495
|
+
includeThoughts: z4.boolean().optional()
|
496
|
+
}).optional(),
|
497
|
+
/**
|
498
|
+
* Optional.
|
499
|
+
* The name of the cached content used as context to serve the prediction.
|
500
|
+
* Format: cachedContents/{cachedContent}
|
501
|
+
*/
|
502
|
+
cachedContent: z4.string().optional(),
|
503
|
+
/**
|
504
|
+
* Optional. Enable structured output. Default is true.
|
505
|
+
*
|
506
|
+
* This is useful when the JSON Schema contains elements that are
|
507
|
+
* not supported by the OpenAPI schema version that
|
508
|
+
* Google Generative AI uses. You can use this to disable
|
509
|
+
* structured outputs if you need to.
|
510
|
+
*/
|
511
|
+
structuredOutputs: z4.boolean().optional(),
|
512
|
+
/**
|
513
|
+
* Optional. A list of unique safety settings for blocking unsafe content.
|
514
|
+
*/
|
515
|
+
safetySettings: z4.array(
|
516
|
+
z4.object({
|
517
|
+
category: z4.enum([
|
518
|
+
"HARM_CATEGORY_UNSPECIFIED",
|
519
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
520
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
521
|
+
"HARM_CATEGORY_HARASSMENT",
|
522
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
523
|
+
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
524
|
+
]),
|
525
|
+
threshold: z4.enum([
|
526
|
+
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
527
|
+
"BLOCK_LOW_AND_ABOVE",
|
528
|
+
"BLOCK_MEDIUM_AND_ABOVE",
|
529
|
+
"BLOCK_ONLY_HIGH",
|
530
|
+
"BLOCK_NONE",
|
531
|
+
"OFF"
|
532
|
+
])
|
533
|
+
})
|
534
|
+
).optional(),
|
494
535
|
threshold: z4.enum([
|
495
536
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
496
537
|
"BLOCK_LOW_AND_ABOVE",
|
@@ -498,30 +539,33 @@ var googleGenerativeAIProviderOptions = z4.object({
|
|
498
539
|
"BLOCK_ONLY_HIGH",
|
499
540
|
"BLOCK_NONE",
|
500
541
|
"OFF"
|
501
|
-
])
|
542
|
+
]).optional(),
|
543
|
+
/**
|
544
|
+
* Optional. Enables timestamp understanding for audio-only files.
|
545
|
+
*
|
546
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
547
|
+
*/
|
548
|
+
audioTimestamp: z4.boolean().optional(),
|
549
|
+
/**
|
550
|
+
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
551
|
+
*
|
552
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
553
|
+
*/
|
554
|
+
labels: z4.record(z4.string(), z4.string()).optional(),
|
555
|
+
/**
|
556
|
+
* Optional. If specified, the media resolution specified will be used.
|
557
|
+
*
|
558
|
+
* https://ai.google.dev/api/generate-content#MediaResolution
|
559
|
+
*/
|
560
|
+
mediaResolution: z4.enum([
|
561
|
+
"MEDIA_RESOLUTION_UNSPECIFIED",
|
562
|
+
"MEDIA_RESOLUTION_LOW",
|
563
|
+
"MEDIA_RESOLUTION_MEDIUM",
|
564
|
+
"MEDIA_RESOLUTION_HIGH"
|
565
|
+
]).optional()
|
502
566
|
})
|
503
|
-
)
|
504
|
-
|
505
|
-
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
506
|
-
"BLOCK_LOW_AND_ABOVE",
|
507
|
-
"BLOCK_MEDIUM_AND_ABOVE",
|
508
|
-
"BLOCK_ONLY_HIGH",
|
509
|
-
"BLOCK_NONE",
|
510
|
-
"OFF"
|
511
|
-
]).optional(),
|
512
|
-
/**
|
513
|
-
* Optional. Enables timestamp understanding for audio-only files.
|
514
|
-
*
|
515
|
-
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
516
|
-
*/
|
517
|
-
audioTimestamp: z4.boolean().optional(),
|
518
|
-
/**
|
519
|
-
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
520
|
-
*
|
521
|
-
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
522
|
-
*/
|
523
|
-
labels: z4.record(z4.string(), z4.string()).optional()
|
524
|
-
});
|
567
|
+
)
|
568
|
+
);
|
525
569
|
|
526
570
|
// src/google-prepare-tools.ts
|
527
571
|
import {
|
@@ -694,64 +738,6 @@ function mapGoogleGenerativeAIFinishReason({
|
|
694
738
|
}
|
695
739
|
}
|
696
740
|
|
697
|
-
// src/tool/google-search.ts
|
698
|
-
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
699
|
-
import { z as z5 } from "zod/v4";
|
700
|
-
var groundingChunkSchema = z5.object({
|
701
|
-
web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
|
702
|
-
retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
|
703
|
-
});
|
704
|
-
var groundingMetadataSchema = z5.object({
|
705
|
-
webSearchQueries: z5.array(z5.string()).nullish(),
|
706
|
-
retrievalQueries: z5.array(z5.string()).nullish(),
|
707
|
-
searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
|
708
|
-
groundingChunks: z5.array(groundingChunkSchema).nullish(),
|
709
|
-
groundingSupports: z5.array(
|
710
|
-
z5.object({
|
711
|
-
segment: z5.object({
|
712
|
-
startIndex: z5.number().nullish(),
|
713
|
-
endIndex: z5.number().nullish(),
|
714
|
-
text: z5.string().nullish()
|
715
|
-
}),
|
716
|
-
segment_text: z5.string().nullish(),
|
717
|
-
groundingChunkIndices: z5.array(z5.number()).nullish(),
|
718
|
-
supportChunkIndices: z5.array(z5.number()).nullish(),
|
719
|
-
confidenceScores: z5.array(z5.number()).nullish(),
|
720
|
-
confidenceScore: z5.array(z5.number()).nullish()
|
721
|
-
})
|
722
|
-
).nullish(),
|
723
|
-
retrievalMetadata: z5.union([
|
724
|
-
z5.object({
|
725
|
-
webDynamicRetrievalScore: z5.number()
|
726
|
-
}),
|
727
|
-
z5.object({})
|
728
|
-
]).nullish()
|
729
|
-
});
|
730
|
-
var googleSearch = createProviderDefinedToolFactory({
|
731
|
-
id: "google.google_search",
|
732
|
-
name: "google_search",
|
733
|
-
inputSchema: z5.object({
|
734
|
-
mode: z5.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
735
|
-
dynamicThreshold: z5.number().default(1)
|
736
|
-
})
|
737
|
-
});
|
738
|
-
|
739
|
-
// src/tool/url-context.ts
|
740
|
-
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
741
|
-
import { z as z6 } from "zod/v4";
|
742
|
-
var urlMetadataSchema = z6.object({
|
743
|
-
retrievedUrl: z6.string(),
|
744
|
-
urlRetrievalStatus: z6.string()
|
745
|
-
});
|
746
|
-
var urlContextMetadataSchema = z6.object({
|
747
|
-
urlMetadata: z6.array(urlMetadataSchema)
|
748
|
-
});
|
749
|
-
var urlContext = createProviderDefinedToolFactory2({
|
750
|
-
id: "google.url_context",
|
751
|
-
name: "url_context",
|
752
|
-
inputSchema: z6.object({})
|
753
|
-
});
|
754
|
-
|
755
741
|
// src/google-generative-ai-language-model.ts
|
756
742
|
var GoogleGenerativeAILanguageModel = class {
|
757
743
|
constructor(modelId, config) {
|
@@ -1244,103 +1230,183 @@ function extractSources({
|
|
1244
1230
|
title: chunk.web.title
|
1245
1231
|
}));
|
1246
1232
|
}
|
1247
|
-
var
|
1248
|
-
|
1249
|
-
|
1233
|
+
var getGroundingMetadataSchema = () => z5.object({
|
1234
|
+
webSearchQueries: z5.array(z5.string()).nullish(),
|
1235
|
+
retrievalQueries: z5.array(z5.string()).nullish(),
|
1236
|
+
searchEntryPoint: z5.object({ renderedContent: z5.string() }).nullish(),
|
1237
|
+
groundingChunks: z5.array(
|
1238
|
+
z5.object({
|
1239
|
+
web: z5.object({ uri: z5.string(), title: z5.string() }).nullish(),
|
1240
|
+
retrievedContext: z5.object({ uri: z5.string(), title: z5.string() }).nullish()
|
1241
|
+
})
|
1242
|
+
).nullish(),
|
1243
|
+
groundingSupports: z5.array(
|
1244
|
+
z5.object({
|
1245
|
+
segment: z5.object({
|
1246
|
+
startIndex: z5.number().nullish(),
|
1247
|
+
endIndex: z5.number().nullish(),
|
1248
|
+
text: z5.string().nullish()
|
1249
|
+
}),
|
1250
|
+
segment_text: z5.string().nullish(),
|
1251
|
+
groundingChunkIndices: z5.array(z5.number()).nullish(),
|
1252
|
+
supportChunkIndices: z5.array(z5.number()).nullish(),
|
1253
|
+
confidenceScores: z5.array(z5.number()).nullish(),
|
1254
|
+
confidenceScore: z5.array(z5.number()).nullish()
|
1255
|
+
})
|
1256
|
+
).nullish(),
|
1257
|
+
retrievalMetadata: z5.union([
|
1258
|
+
z5.object({
|
1259
|
+
webDynamicRetrievalScore: z5.number()
|
1260
|
+
}),
|
1261
|
+
z5.object({})
|
1262
|
+
]).nullish()
|
1263
|
+
});
|
1264
|
+
var getContentSchema = () => z5.object({
|
1265
|
+
parts: z5.array(
|
1266
|
+
z5.union([
|
1250
1267
|
// note: order matters since text can be fully empty
|
1251
|
-
|
1252
|
-
functionCall:
|
1253
|
-
name:
|
1254
|
-
args:
|
1268
|
+
z5.object({
|
1269
|
+
functionCall: z5.object({
|
1270
|
+
name: z5.string(),
|
1271
|
+
args: z5.unknown()
|
1255
1272
|
}),
|
1256
|
-
thoughtSignature:
|
1273
|
+
thoughtSignature: z5.string().nullish()
|
1257
1274
|
}),
|
1258
|
-
|
1259
|
-
inlineData:
|
1260
|
-
mimeType:
|
1261
|
-
data:
|
1275
|
+
z5.object({
|
1276
|
+
inlineData: z5.object({
|
1277
|
+
mimeType: z5.string(),
|
1278
|
+
data: z5.string()
|
1262
1279
|
})
|
1263
1280
|
}),
|
1264
|
-
|
1265
|
-
executableCode:
|
1266
|
-
language:
|
1267
|
-
code:
|
1281
|
+
z5.object({
|
1282
|
+
executableCode: z5.object({
|
1283
|
+
language: z5.string(),
|
1284
|
+
code: z5.string()
|
1268
1285
|
}).nullish(),
|
1269
|
-
codeExecutionResult:
|
1270
|
-
outcome:
|
1271
|
-
output:
|
1286
|
+
codeExecutionResult: z5.object({
|
1287
|
+
outcome: z5.string(),
|
1288
|
+
output: z5.string()
|
1272
1289
|
}).nullish(),
|
1273
|
-
text:
|
1274
|
-
thought:
|
1275
|
-
thoughtSignature:
|
1290
|
+
text: z5.string().nullish(),
|
1291
|
+
thought: z5.boolean().nullish(),
|
1292
|
+
thoughtSignature: z5.string().nullish()
|
1276
1293
|
})
|
1277
1294
|
])
|
1278
1295
|
).nullish()
|
1279
1296
|
});
|
1280
|
-
var
|
1281
|
-
category:
|
1282
|
-
probability:
|
1283
|
-
probabilityScore:
|
1284
|
-
severity:
|
1285
|
-
severityScore:
|
1286
|
-
blocked:
|
1297
|
+
var getSafetyRatingSchema = () => z5.object({
|
1298
|
+
category: z5.string().nullish(),
|
1299
|
+
probability: z5.string().nullish(),
|
1300
|
+
probabilityScore: z5.number().nullish(),
|
1301
|
+
severity: z5.string().nullish(),
|
1302
|
+
severityScore: z5.number().nullish(),
|
1303
|
+
blocked: z5.boolean().nullish()
|
1287
1304
|
});
|
1288
|
-
var usageSchema =
|
1289
|
-
cachedContentTokenCount:
|
1290
|
-
thoughtsTokenCount:
|
1291
|
-
promptTokenCount:
|
1292
|
-
candidatesTokenCount:
|
1293
|
-
totalTokenCount:
|
1305
|
+
var usageSchema = z5.object({
|
1306
|
+
cachedContentTokenCount: z5.number().nullish(),
|
1307
|
+
thoughtsTokenCount: z5.number().nullish(),
|
1308
|
+
promptTokenCount: z5.number().nullish(),
|
1309
|
+
candidatesTokenCount: z5.number().nullish(),
|
1310
|
+
totalTokenCount: z5.number().nullish()
|
1294
1311
|
});
|
1295
|
-
var
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
safetyRatings: z7.array(safetyRatingSchema).nullish(),
|
1301
|
-
groundingMetadata: groundingMetadataSchema.nullish(),
|
1302
|
-
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1312
|
+
var getUrlContextMetadataSchema = () => z5.object({
|
1313
|
+
urlMetadata: z5.array(
|
1314
|
+
z5.object({
|
1315
|
+
retrievedUrl: z5.string(),
|
1316
|
+
urlRetrievalStatus: z5.string()
|
1303
1317
|
})
|
1304
|
-
)
|
1305
|
-
usageMetadata: usageSchema.nullish(),
|
1306
|
-
promptFeedback: z7.object({
|
1307
|
-
blockReason: z7.string().nullish(),
|
1308
|
-
safetyRatings: z7.array(safetyRatingSchema).nullish()
|
1309
|
-
}).nullish()
|
1318
|
+
)
|
1310
1319
|
});
|
1311
|
-
var
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1320
|
+
var responseSchema = lazySchema5(
|
1321
|
+
() => zodSchema5(
|
1322
|
+
z5.object({
|
1323
|
+
candidates: z5.array(
|
1324
|
+
z5.object({
|
1325
|
+
content: getContentSchema().nullish().or(z5.object({}).strict()),
|
1326
|
+
finishReason: z5.string().nullish(),
|
1327
|
+
safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
|
1328
|
+
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
1329
|
+
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
1330
|
+
})
|
1331
|
+
),
|
1332
|
+
usageMetadata: usageSchema.nullish(),
|
1333
|
+
promptFeedback: z5.object({
|
1334
|
+
blockReason: z5.string().nullish(),
|
1335
|
+
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
1336
|
+
}).nullish()
|
1319
1337
|
})
|
1320
|
-
)
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1338
|
+
)
|
1339
|
+
);
|
1340
|
+
var chunkSchema = lazySchema5(
|
1341
|
+
() => zodSchema5(
|
1342
|
+
z5.object({
|
1343
|
+
candidates: z5.array(
|
1344
|
+
z5.object({
|
1345
|
+
content: getContentSchema().nullish(),
|
1346
|
+
finishReason: z5.string().nullish(),
|
1347
|
+
safetyRatings: z5.array(getSafetyRatingSchema()).nullish(),
|
1348
|
+
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
1349
|
+
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
1350
|
+
})
|
1351
|
+
).nullish(),
|
1352
|
+
usageMetadata: usageSchema.nullish(),
|
1353
|
+
promptFeedback: z5.object({
|
1354
|
+
blockReason: z5.string().nullish(),
|
1355
|
+
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
1356
|
+
}).nullish()
|
1357
|
+
})
|
1358
|
+
)
|
1359
|
+
);
|
1327
1360
|
|
1328
1361
|
// src/tool/code-execution.ts
|
1329
1362
|
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
1330
|
-
import
|
1363
|
+
import * as z6 from "zod/v4";
|
1331
1364
|
var codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
|
1332
1365
|
id: "google.code_execution",
|
1333
1366
|
name: "code_execution",
|
1334
|
-
inputSchema:
|
1335
|
-
language:
|
1336
|
-
code:
|
1367
|
+
inputSchema: z6.object({
|
1368
|
+
language: z6.string().describe("The programming language of the code."),
|
1369
|
+
code: z6.string().describe("The code to be executed.")
|
1337
1370
|
}),
|
1338
|
-
outputSchema:
|
1339
|
-
outcome:
|
1340
|
-
output:
|
1371
|
+
outputSchema: z6.object({
|
1372
|
+
outcome: z6.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
1373
|
+
output: z6.string().describe("The output from the code execution.")
|
1341
1374
|
})
|
1342
1375
|
});
|
1343
1376
|
|
1377
|
+
// src/tool/google-search.ts
|
1378
|
+
import {
|
1379
|
+
createProviderDefinedToolFactory,
|
1380
|
+
lazySchema as lazySchema6,
|
1381
|
+
zodSchema as zodSchema6
|
1382
|
+
} from "@ai-sdk/provider-utils";
|
1383
|
+
import * as z7 from "zod/v4";
|
1384
|
+
var googleSearch = createProviderDefinedToolFactory({
|
1385
|
+
id: "google.google_search",
|
1386
|
+
name: "google_search",
|
1387
|
+
inputSchema: lazySchema6(
|
1388
|
+
() => zodSchema6(
|
1389
|
+
z7.object({
|
1390
|
+
mode: z7.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
1391
|
+
dynamicThreshold: z7.number().default(1)
|
1392
|
+
})
|
1393
|
+
)
|
1394
|
+
)
|
1395
|
+
});
|
1396
|
+
|
1397
|
+
// src/tool/url-context.ts
|
1398
|
+
import {
|
1399
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
1400
|
+
lazySchema as lazySchema7,
|
1401
|
+
zodSchema as zodSchema7
|
1402
|
+
} from "@ai-sdk/provider-utils";
|
1403
|
+
import * as z8 from "zod/v4";
|
1404
|
+
var urlContext = createProviderDefinedToolFactory2({
|
1405
|
+
id: "google.url_context",
|
1406
|
+
name: "url_context",
|
1407
|
+
inputSchema: lazySchema7(() => zodSchema7(z8.object({})))
|
1408
|
+
});
|
1409
|
+
|
1344
1410
|
// src/google-tools.ts
|
1345
1411
|
var googleTools = {
|
1346
1412
|
/**
|
@@ -1370,11 +1436,13 @@ var googleTools = {
|
|
1370
1436
|
import {
|
1371
1437
|
combineHeaders as combineHeaders3,
|
1372
1438
|
createJsonResponseHandler as createJsonResponseHandler3,
|
1439
|
+
lazySchema as lazySchema8,
|
1373
1440
|
parseProviderOptions as parseProviderOptions3,
|
1374
1441
|
postJsonToApi as postJsonToApi3,
|
1375
|
-
resolve as resolve3
|
1442
|
+
resolve as resolve3,
|
1443
|
+
zodSchema as zodSchema8
|
1376
1444
|
} from "@ai-sdk/provider-utils";
|
1377
|
-
import
|
1445
|
+
import * as z9 from "zod/v4";
|
1378
1446
|
var GoogleGenerativeAIImageModel = class {
|
1379
1447
|
constructor(modelId, settings, config) {
|
1380
1448
|
this.modelId = modelId;
|
@@ -1466,13 +1534,21 @@ var GoogleGenerativeAIImageModel = class {
|
|
1466
1534
|
};
|
1467
1535
|
}
|
1468
1536
|
};
|
1469
|
-
var googleImageResponseSchema =
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1537
|
+
var googleImageResponseSchema = lazySchema8(
|
1538
|
+
() => zodSchema8(
|
1539
|
+
z9.object({
|
1540
|
+
predictions: z9.array(z9.object({ bytesBase64Encoded: z9.string() })).default([])
|
1541
|
+
})
|
1542
|
+
)
|
1543
|
+
);
|
1544
|
+
var googleImageProviderOptionsSchema = lazySchema8(
|
1545
|
+
() => zodSchema8(
|
1546
|
+
z9.object({
|
1547
|
+
personGeneration: z9.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
1548
|
+
aspectRatio: z9.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
1549
|
+
})
|
1550
|
+
)
|
1551
|
+
);
|
1476
1552
|
|
1477
1553
|
// src/google-provider.ts
|
1478
1554
|
function createGoogleGenerativeAI(options = {}) {
|