@ai-sdk/google 3.0.113 → 3.0.116
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 +20 -0
- package/dist/index.d.mts +57 -3
- package/dist/index.d.ts +57 -3
- package/dist/index.js +953 -683
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +891 -613
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +93 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +93 -17
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/convert-json-schema-to-openapi-schema.ts +136 -8
- package/src/google-prepare-tools.ts +45 -21
- package/src/google-provider.ts +24 -0
- package/src/index.ts +5 -0
- package/src/transcription/google-transcription-model-options.ts +51 -0
- package/src/transcription/google-transcription-model.ts +243 -0
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
// src/google-
|
|
1
|
+
// src/transcription/google-transcription-model.ts
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
loadApiKey,
|
|
5
|
-
withoutTrailingSlash,
|
|
6
|
-
withUserAgentSuffix as withUserAgentSuffix2
|
|
7
|
-
} from "@ai-sdk/provider-utils";
|
|
8
|
-
|
|
9
|
-
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.113" : "0.0.0-test";
|
|
11
|
-
|
|
12
|
-
// src/google-generative-ai-embedding-model.ts
|
|
13
|
-
import {
|
|
14
|
-
TooManyEmbeddingValuesForCallError
|
|
3
|
+
InvalidArgumentError
|
|
15
4
|
} from "@ai-sdk/provider";
|
|
16
5
|
import {
|
|
17
6
|
combineHeaders,
|
|
7
|
+
convertToBase64,
|
|
18
8
|
createJsonResponseHandler,
|
|
19
|
-
lazySchema as lazySchema3,
|
|
20
9
|
parseProviderOptions,
|
|
21
10
|
postJsonToApi,
|
|
22
|
-
resolve
|
|
23
|
-
zodSchema as zodSchema3
|
|
11
|
+
resolve
|
|
24
12
|
} from "@ai-sdk/provider-utils";
|
|
25
13
|
import { z as z3 } from "zod/v4";
|
|
26
14
|
|
|
@@ -48,35 +36,240 @@ var googleFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
48
36
|
errorToMessage: (data) => data.error.message
|
|
49
37
|
});
|
|
50
38
|
|
|
39
|
+
// src/transcription/google-transcription-model-options.ts
|
|
40
|
+
import { z as z2 } from "zod/v4";
|
|
41
|
+
var googleTranscriptionModelOptions = z2.object({
|
|
42
|
+
/**
|
|
43
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
44
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
45
|
+
*/
|
|
46
|
+
languageCodes: z2.array(z2.string()).optional(),
|
|
47
|
+
/**
|
|
48
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
49
|
+
* toward recognizing specific terms.
|
|
50
|
+
*/
|
|
51
|
+
customVocabulary: z2.array(z2.string()).optional(),
|
|
52
|
+
/**
|
|
53
|
+
* Enables word-level timestamp generation.
|
|
54
|
+
*/
|
|
55
|
+
wordTimestamp: z2.boolean().optional(),
|
|
56
|
+
/**
|
|
57
|
+
* Enables speaker diarization.
|
|
58
|
+
*/
|
|
59
|
+
diarization: z2.boolean().optional(),
|
|
60
|
+
/**
|
|
61
|
+
* Transcription output formatting mode.
|
|
62
|
+
*
|
|
63
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
64
|
+
* words, repetitions, and false starts.
|
|
65
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
66
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
67
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
68
|
+
*/
|
|
69
|
+
mode: z2.enum(["SMART", "VERBATIM"]).optional()
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// src/transcription/google-transcription-model.ts
|
|
73
|
+
function isLiveTranscriptionModelId(modelId) {
|
|
74
|
+
return modelId.includes("-live");
|
|
75
|
+
}
|
|
76
|
+
var GoogleTranscriptionModel = class {
|
|
77
|
+
constructor(modelId, config) {
|
|
78
|
+
this.modelId = modelId;
|
|
79
|
+
this.config = config;
|
|
80
|
+
this.specificationVersion = "v3";
|
|
81
|
+
}
|
|
82
|
+
get provider() {
|
|
83
|
+
return this.config.provider;
|
|
84
|
+
}
|
|
85
|
+
async parseOptions(providerOptions) {
|
|
86
|
+
return parseProviderOptions({
|
|
87
|
+
provider: "google",
|
|
88
|
+
providerOptions,
|
|
89
|
+
schema: googleTranscriptionModelOptions
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async doGenerate(options) {
|
|
93
|
+
var _a, _b, _c, _d, _e, _f;
|
|
94
|
+
if (isLiveTranscriptionModelId(this.modelId)) {
|
|
95
|
+
throw new InvalidArgumentError({
|
|
96
|
+
argument: "modelId",
|
|
97
|
+
message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
101
|
+
const warnings = [];
|
|
102
|
+
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
103
|
+
const transcriptionConfig = buildTranscriptionConfig(googleOptions);
|
|
104
|
+
const requestBody = {
|
|
105
|
+
model: this.modelId,
|
|
106
|
+
input: [
|
|
107
|
+
{
|
|
108
|
+
type: "audio",
|
|
109
|
+
data: convertToBase64(options.audio),
|
|
110
|
+
mime_type: options.mediaType
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
...transcriptionConfig != null ? { generation_config: { transcription_config: transcriptionConfig } } : {}
|
|
114
|
+
};
|
|
115
|
+
const {
|
|
116
|
+
value: response,
|
|
117
|
+
responseHeaders,
|
|
118
|
+
rawValue: rawResponse
|
|
119
|
+
} = await postJsonToApi({
|
|
120
|
+
url: `${this.config.baseURL}/interactions`,
|
|
121
|
+
headers: combineHeaders(
|
|
122
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
123
|
+
options.headers
|
|
124
|
+
),
|
|
125
|
+
body: requestBody,
|
|
126
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
127
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
128
|
+
googleInteractionsTranscriptionResponseSchema
|
|
129
|
+
),
|
|
130
|
+
abortSignal: options.abortSignal,
|
|
131
|
+
fetch: this.config.fetch
|
|
132
|
+
});
|
|
133
|
+
let text = "";
|
|
134
|
+
const segments = [];
|
|
135
|
+
for (const step of (_d = response.steps) != null ? _d : []) {
|
|
136
|
+
for (const content of (_e = step.content) != null ? _e : []) {
|
|
137
|
+
if (content.type !== "text" || content.text == null) continue;
|
|
138
|
+
text += content.text;
|
|
139
|
+
for (const annotation of (_f = content.annotations) != null ? _f : []) {
|
|
140
|
+
if (annotation.type !== "word_info") continue;
|
|
141
|
+
const startSecond = parseOffsetSeconds(annotation.start_offset);
|
|
142
|
+
const endSecond = parseOffsetSeconds(annotation.end_offset);
|
|
143
|
+
if (annotation.text == null || startSecond == null || endSecond == null) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
segments.push({ text: annotation.text, startSecond, endSecond });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
text,
|
|
152
|
+
segments,
|
|
153
|
+
language: void 0,
|
|
154
|
+
durationInSeconds: void 0,
|
|
155
|
+
warnings,
|
|
156
|
+
response: {
|
|
157
|
+
timestamp: currentDate,
|
|
158
|
+
modelId: this.modelId,
|
|
159
|
+
headers: responseHeaders,
|
|
160
|
+
body: rawResponse
|
|
161
|
+
},
|
|
162
|
+
...response.usage != null ? {
|
|
163
|
+
providerMetadata: {
|
|
164
|
+
google: { usage: response.usage }
|
|
165
|
+
}
|
|
166
|
+
} : {}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
function buildTranscriptionConfig(options) {
|
|
171
|
+
var _a;
|
|
172
|
+
if (options == null) return void 0;
|
|
173
|
+
const config = {};
|
|
174
|
+
if (options.languageCodes != null) {
|
|
175
|
+
config.language_codes = options.languageCodes;
|
|
176
|
+
}
|
|
177
|
+
if (options.customVocabulary != null) {
|
|
178
|
+
config.custom_vocabulary = options.customVocabulary;
|
|
179
|
+
}
|
|
180
|
+
if (options.mode != null || options.diarization === true || options.wordTimestamp === true) {
|
|
181
|
+
config.mode = {
|
|
182
|
+
type: ((_a = options.mode) != null ? _a : "VERBATIM").toLowerCase(),
|
|
183
|
+
...options.diarization === true ? { diarization_mode: "speaker" } : {},
|
|
184
|
+
...options.wordTimestamp === true ? { timestamp_granularities: ["word"] } : {}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
188
|
+
}
|
|
189
|
+
function parseOffsetSeconds(offset) {
|
|
190
|
+
if (offset == null) return void 0;
|
|
191
|
+
const parsed = Number.parseFloat(offset);
|
|
192
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
193
|
+
}
|
|
194
|
+
var googleInteractionsWordAnnotationSchema = z3.object({
|
|
195
|
+
type: z3.string().nullish(),
|
|
196
|
+
text: z3.string().nullish(),
|
|
197
|
+
speaker: z3.string().nullish(),
|
|
198
|
+
start_offset: z3.string().nullish(),
|
|
199
|
+
end_offset: z3.string().nullish()
|
|
200
|
+
});
|
|
201
|
+
var googleInteractionsTranscriptionResponseSchema = z3.object({
|
|
202
|
+
status: z3.string().nullish(),
|
|
203
|
+
steps: z3.array(
|
|
204
|
+
z3.object({
|
|
205
|
+
type: z3.string().nullish(),
|
|
206
|
+
content: z3.array(
|
|
207
|
+
z3.object({
|
|
208
|
+
type: z3.string().nullish(),
|
|
209
|
+
text: z3.string().nullish(),
|
|
210
|
+
annotations: z3.array(googleInteractionsWordAnnotationSchema).nullish()
|
|
211
|
+
})
|
|
212
|
+
).nullish()
|
|
213
|
+
})
|
|
214
|
+
).nullish(),
|
|
215
|
+
usage: z3.record(z3.string(), z3.unknown()).nullish()
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// src/google-provider.ts
|
|
219
|
+
import {
|
|
220
|
+
generateId as generateId2,
|
|
221
|
+
loadApiKey,
|
|
222
|
+
withoutTrailingSlash,
|
|
223
|
+
withUserAgentSuffix as withUserAgentSuffix2
|
|
224
|
+
} from "@ai-sdk/provider-utils";
|
|
225
|
+
|
|
226
|
+
// src/version.ts
|
|
227
|
+
var VERSION = true ? "3.0.116" : "0.0.0-test";
|
|
228
|
+
|
|
229
|
+
// src/google-generative-ai-embedding-model.ts
|
|
230
|
+
import {
|
|
231
|
+
TooManyEmbeddingValuesForCallError
|
|
232
|
+
} from "@ai-sdk/provider";
|
|
233
|
+
import {
|
|
234
|
+
combineHeaders as combineHeaders2,
|
|
235
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
236
|
+
lazySchema as lazySchema3,
|
|
237
|
+
parseProviderOptions as parseProviderOptions2,
|
|
238
|
+
postJsonToApi as postJsonToApi2,
|
|
239
|
+
resolve as resolve2,
|
|
240
|
+
zodSchema as zodSchema3
|
|
241
|
+
} from "@ai-sdk/provider-utils";
|
|
242
|
+
import { z as z5 } from "zod/v4";
|
|
243
|
+
|
|
51
244
|
// src/google-generative-ai-embedding-options.ts
|
|
52
245
|
import {
|
|
53
246
|
lazySchema as lazySchema2,
|
|
54
247
|
zodSchema as zodSchema2
|
|
55
248
|
} from "@ai-sdk/provider-utils";
|
|
56
|
-
import { z as
|
|
57
|
-
var googleEmbeddingContentPartSchema =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
inlineData:
|
|
61
|
-
mimeType:
|
|
62
|
-
data:
|
|
249
|
+
import { z as z4 } from "zod/v4";
|
|
250
|
+
var googleEmbeddingContentPartSchema = z4.union([
|
|
251
|
+
z4.object({ text: z4.string() }),
|
|
252
|
+
z4.object({
|
|
253
|
+
inlineData: z4.object({
|
|
254
|
+
mimeType: z4.string(),
|
|
255
|
+
data: z4.string()
|
|
63
256
|
})
|
|
64
257
|
}),
|
|
65
|
-
|
|
66
|
-
fileData:
|
|
67
|
-
fileUri:
|
|
68
|
-
mimeType:
|
|
258
|
+
z4.object({
|
|
259
|
+
fileData: z4.object({
|
|
260
|
+
fileUri: z4.string(),
|
|
261
|
+
mimeType: z4.string()
|
|
69
262
|
})
|
|
70
263
|
})
|
|
71
264
|
]);
|
|
72
265
|
var googleEmbeddingModelOptions = lazySchema2(
|
|
73
266
|
() => zodSchema2(
|
|
74
|
-
|
|
267
|
+
z4.object({
|
|
75
268
|
/**
|
|
76
269
|
* Optional. Optional reduced dimension for the output embedding.
|
|
77
270
|
* If set, excessive values in the output embedding are truncated from the end.
|
|
78
271
|
*/
|
|
79
|
-
outputDimensionality:
|
|
272
|
+
outputDimensionality: z4.number().optional(),
|
|
80
273
|
/**
|
|
81
274
|
* Optional. Specifies the task type for generating embeddings.
|
|
82
275
|
* Supported task types:
|
|
@@ -89,7 +282,7 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
89
282
|
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
90
283
|
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
91
284
|
*/
|
|
92
|
-
taskType:
|
|
285
|
+
taskType: z4.enum([
|
|
93
286
|
"SEMANTIC_SIMILARITY",
|
|
94
287
|
"CLASSIFICATION",
|
|
95
288
|
"CLUSTERING",
|
|
@@ -108,7 +301,7 @@ var googleEmbeddingModelOptions = lazySchema2(
|
|
|
108
301
|
* The array length must match the number of values being embedded. In
|
|
109
302
|
* the case of a single embedding, the array length must be 1.
|
|
110
303
|
*/
|
|
111
|
-
content:
|
|
304
|
+
content: z4.array(z4.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
112
305
|
})
|
|
113
306
|
)
|
|
114
307
|
);
|
|
@@ -131,7 +324,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
131
324
|
abortSignal,
|
|
132
325
|
providerOptions
|
|
133
326
|
}) {
|
|
134
|
-
const googleOptions = await
|
|
327
|
+
const googleOptions = await parseProviderOptions2({
|
|
135
328
|
provider: "google",
|
|
136
329
|
providerOptions,
|
|
137
330
|
schema: googleEmbeddingModelOptions
|
|
@@ -144,8 +337,8 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
144
337
|
values
|
|
145
338
|
});
|
|
146
339
|
}
|
|
147
|
-
const mergedHeaders =
|
|
148
|
-
await
|
|
340
|
+
const mergedHeaders = combineHeaders2(
|
|
341
|
+
await resolve2(this.config.headers),
|
|
149
342
|
headers
|
|
150
343
|
);
|
|
151
344
|
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
@@ -162,7 +355,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
162
355
|
responseHeaders: responseHeaders2,
|
|
163
356
|
value: response2,
|
|
164
357
|
rawValue: rawValue2
|
|
165
|
-
} = await
|
|
358
|
+
} = await postJsonToApi2({
|
|
166
359
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
167
360
|
headers: mergedHeaders,
|
|
168
361
|
body: {
|
|
@@ -174,7 +367,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
174
367
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
175
368
|
},
|
|
176
369
|
failedResponseHandler: googleFailedResponseHandler,
|
|
177
|
-
successfulResponseHandler:
|
|
370
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
178
371
|
googleGenerativeAISingleEmbeddingResponseSchema
|
|
179
372
|
),
|
|
180
373
|
abortSignal,
|
|
@@ -191,7 +384,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
191
384
|
responseHeaders,
|
|
192
385
|
value: response,
|
|
193
386
|
rawValue
|
|
194
|
-
} = await
|
|
387
|
+
} = await postJsonToApi2({
|
|
195
388
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
196
389
|
headers: mergedHeaders,
|
|
197
390
|
body: {
|
|
@@ -210,7 +403,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
210
403
|
})
|
|
211
404
|
},
|
|
212
405
|
failedResponseHandler: googleFailedResponseHandler,
|
|
213
|
-
successfulResponseHandler:
|
|
406
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
214
407
|
googleGenerativeAITextEmbeddingResponseSchema
|
|
215
408
|
),
|
|
216
409
|
abortSignal,
|
|
@@ -226,32 +419,32 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
226
419
|
};
|
|
227
420
|
var googleGenerativeAITextEmbeddingResponseSchema = lazySchema3(
|
|
228
421
|
() => zodSchema3(
|
|
229
|
-
|
|
230
|
-
embeddings:
|
|
422
|
+
z5.object({
|
|
423
|
+
embeddings: z5.array(z5.object({ values: z5.array(z5.number()) }))
|
|
231
424
|
})
|
|
232
425
|
)
|
|
233
426
|
);
|
|
234
427
|
var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema3(
|
|
235
428
|
() => zodSchema3(
|
|
236
|
-
|
|
237
|
-
embedding:
|
|
429
|
+
z5.object({
|
|
430
|
+
embedding: z5.object({ values: z5.array(z5.number()) })
|
|
238
431
|
})
|
|
239
432
|
)
|
|
240
433
|
);
|
|
241
434
|
|
|
242
435
|
// src/google-generative-ai-language-model.ts
|
|
243
436
|
import {
|
|
244
|
-
combineHeaders as
|
|
437
|
+
combineHeaders as combineHeaders3,
|
|
245
438
|
createEventSourceResponseHandler,
|
|
246
|
-
createJsonResponseHandler as
|
|
439
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
247
440
|
generateId,
|
|
248
441
|
lazySchema as lazySchema5,
|
|
249
|
-
parseProviderOptions as
|
|
250
|
-
postJsonToApi as
|
|
251
|
-
resolve as
|
|
442
|
+
parseProviderOptions as parseProviderOptions3,
|
|
443
|
+
postJsonToApi as postJsonToApi3,
|
|
444
|
+
resolve as resolve3,
|
|
252
445
|
zodSchema as zodSchema5
|
|
253
446
|
} from "@ai-sdk/provider-utils";
|
|
254
|
-
import { z as
|
|
447
|
+
import { z as z7 } from "zod/v4";
|
|
255
448
|
|
|
256
449
|
// src/convert-google-generative-ai-usage.ts
|
|
257
450
|
function convertGoogleGenerativeAIUsage(usage) {
|
|
@@ -296,6 +489,10 @@ function convertGoogleGenerativeAIUsage(usage) {
|
|
|
296
489
|
import {
|
|
297
490
|
UnsupportedFunctionalityError
|
|
298
491
|
} from "@ai-sdk/provider";
|
|
492
|
+
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
493
|
+
function isRecursiveJSONSchemaReferenceError(error) {
|
|
494
|
+
return UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
495
|
+
}
|
|
299
496
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
300
497
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
301
498
|
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
@@ -346,9 +543,6 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
346
543
|
if (description) result.description = description;
|
|
347
544
|
if (required) result.required = required;
|
|
348
545
|
if (format) result.format = format;
|
|
349
|
-
if (constValue !== void 0) {
|
|
350
|
-
result.enum = [constValue];
|
|
351
|
-
}
|
|
352
546
|
if (type) {
|
|
353
547
|
if (Array.isArray(type)) {
|
|
354
548
|
const hasNull = type.includes("null");
|
|
@@ -365,8 +559,9 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
365
559
|
result.type = type;
|
|
366
560
|
}
|
|
367
561
|
}
|
|
368
|
-
|
|
369
|
-
|
|
562
|
+
const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
|
|
563
|
+
if (values !== void 0) {
|
|
564
|
+
addEnumToSchema({ values, type, result });
|
|
370
565
|
}
|
|
371
566
|
if (properties != null) {
|
|
372
567
|
result.properties = Object.entries(properties).reduce(
|
|
@@ -426,6 +621,68 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
426
621
|
}
|
|
427
622
|
return result;
|
|
428
623
|
}
|
|
624
|
+
function addEnumToSchema({
|
|
625
|
+
values,
|
|
626
|
+
type,
|
|
627
|
+
result
|
|
628
|
+
}) {
|
|
629
|
+
const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
|
|
630
|
+
const enumValues = nullable ? values.filter((value) => value !== null) : values;
|
|
631
|
+
if (values.length > 0 && values.every((value) => value === null)) {
|
|
632
|
+
const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
|
|
633
|
+
if (typeAllowsNull) {
|
|
634
|
+
result.type = "null";
|
|
635
|
+
if (Array.isArray(type)) {
|
|
636
|
+
delete result.anyOf;
|
|
637
|
+
}
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const enumType = getEnumType({ values: enumValues, type });
|
|
642
|
+
if (enumType === void 0) {
|
|
643
|
+
throw new UnsupportedFunctionalityError({
|
|
644
|
+
functionality: "JSON Schema enum with mixed or unsupported values",
|
|
645
|
+
message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
result.type = enumType;
|
|
649
|
+
if (Array.isArray(type)) {
|
|
650
|
+
delete result.anyOf;
|
|
651
|
+
}
|
|
652
|
+
if (nullable) {
|
|
653
|
+
result.nullable = true;
|
|
654
|
+
}
|
|
655
|
+
if (enumType === "string") {
|
|
656
|
+
result.enum = enumValues;
|
|
657
|
+
} else {
|
|
658
|
+
result.format = "enum";
|
|
659
|
+
result.enum = enumValues.map(String);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
function getEnumType({
|
|
663
|
+
values,
|
|
664
|
+
type
|
|
665
|
+
}) {
|
|
666
|
+
if (values.length === 0) {
|
|
667
|
+
return void 0;
|
|
668
|
+
}
|
|
669
|
+
const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
|
|
670
|
+
if (typeAllows("string") && values.every((value) => typeof value === "string")) {
|
|
671
|
+
return "string";
|
|
672
|
+
}
|
|
673
|
+
if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
|
|
674
|
+
if (typeAllows("number")) {
|
|
675
|
+
return "number";
|
|
676
|
+
}
|
|
677
|
+
if (values.every((value) => Number.isInteger(value))) {
|
|
678
|
+
return "integer";
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
|
|
682
|
+
return "boolean";
|
|
683
|
+
}
|
|
684
|
+
return void 0;
|
|
685
|
+
}
|
|
429
686
|
function convertJSONSchemaReference({
|
|
430
687
|
jsonSchema,
|
|
431
688
|
reference,
|
|
@@ -438,7 +695,7 @@ function convertJSONSchemaReference({
|
|
|
438
695
|
);
|
|
439
696
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
440
697
|
throw new UnsupportedFunctionalityError({
|
|
441
|
-
functionality:
|
|
698
|
+
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
442
699
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
443
700
|
});
|
|
444
701
|
}
|
|
@@ -504,7 +761,7 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
504
761
|
import {
|
|
505
762
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
506
763
|
} from "@ai-sdk/provider";
|
|
507
|
-
import { convertToBase64, secureJsonParse } from "@ai-sdk/provider-utils";
|
|
764
|
+
import { convertToBase64 as convertToBase642, secureJsonParse } from "@ai-sdk/provider-utils";
|
|
508
765
|
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
509
766
|
function getGoogleProviderOptions(providerOptions, providerOptionsName) {
|
|
510
767
|
const namespaces = [
|
|
@@ -680,7 +937,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
680
937
|
} : {
|
|
681
938
|
inlineData: {
|
|
682
939
|
mimeType: mediaType,
|
|
683
|
-
data:
|
|
940
|
+
data: convertToBase642(part.data)
|
|
684
941
|
}
|
|
685
942
|
}
|
|
686
943
|
);
|
|
@@ -725,7 +982,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
725
982
|
return {
|
|
726
983
|
inlineData: {
|
|
727
984
|
mimeType: part.mediaType,
|
|
728
|
-
data:
|
|
985
|
+
data: convertToBase642(part.data)
|
|
729
986
|
},
|
|
730
987
|
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
731
988
|
thoughtSignature
|
|
@@ -882,23 +1139,23 @@ import {
|
|
|
882
1139
|
lazySchema as lazySchema4,
|
|
883
1140
|
zodSchema as zodSchema4
|
|
884
1141
|
} from "@ai-sdk/provider-utils";
|
|
885
|
-
import { z as
|
|
1142
|
+
import { z as z6 } from "zod/v4";
|
|
886
1143
|
var googleLanguageModelOptions = lazySchema4(
|
|
887
1144
|
() => zodSchema4(
|
|
888
|
-
|
|
889
|
-
responseModalities:
|
|
890
|
-
thinkingConfig:
|
|
891
|
-
thinkingBudget:
|
|
892
|
-
includeThoughts:
|
|
1145
|
+
z6.object({
|
|
1146
|
+
responseModalities: z6.array(z6.enum(["TEXT", "IMAGE"])).optional(),
|
|
1147
|
+
thinkingConfig: z6.object({
|
|
1148
|
+
thinkingBudget: z6.number().optional(),
|
|
1149
|
+
includeThoughts: z6.boolean().optional(),
|
|
893
1150
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
894
|
-
thinkingLevel:
|
|
1151
|
+
thinkingLevel: z6.enum(["minimal", "low", "medium", "high"]).optional()
|
|
895
1152
|
}).optional(),
|
|
896
1153
|
/**
|
|
897
1154
|
* Optional.
|
|
898
1155
|
* The name of the cached content used as context to serve the prediction.
|
|
899
1156
|
* Format: cachedContents/{cachedContent}
|
|
900
1157
|
*/
|
|
901
|
-
cachedContent:
|
|
1158
|
+
cachedContent: z6.string().optional(),
|
|
902
1159
|
/**
|
|
903
1160
|
* Optional. Enable structured output. Default is true.
|
|
904
1161
|
*
|
|
@@ -907,13 +1164,13 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
907
1164
|
* Google Generative AI uses. You can use this to disable
|
|
908
1165
|
* structured outputs if you need to.
|
|
909
1166
|
*/
|
|
910
|
-
structuredOutputs:
|
|
1167
|
+
structuredOutputs: z6.boolean().optional(),
|
|
911
1168
|
/**
|
|
912
1169
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
913
1170
|
*/
|
|
914
|
-
safetySettings:
|
|
915
|
-
|
|
916
|
-
category:
|
|
1171
|
+
safetySettings: z6.array(
|
|
1172
|
+
z6.object({
|
|
1173
|
+
category: z6.enum([
|
|
917
1174
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
918
1175
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
919
1176
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -921,7 +1178,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
921
1178
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
922
1179
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
923
1180
|
]),
|
|
924
|
-
threshold:
|
|
1181
|
+
threshold: z6.enum([
|
|
925
1182
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
926
1183
|
"BLOCK_LOW_AND_ABOVE",
|
|
927
1184
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -931,7 +1188,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
931
1188
|
])
|
|
932
1189
|
})
|
|
933
1190
|
).optional(),
|
|
934
|
-
threshold:
|
|
1191
|
+
threshold: z6.enum([
|
|
935
1192
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
936
1193
|
"BLOCK_LOW_AND_ABOVE",
|
|
937
1194
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -944,19 +1201,19 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
944
1201
|
*
|
|
945
1202
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
946
1203
|
*/
|
|
947
|
-
audioTimestamp:
|
|
1204
|
+
audioTimestamp: z6.boolean().optional(),
|
|
948
1205
|
/**
|
|
949
1206
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
950
1207
|
*
|
|
951
1208
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
952
1209
|
*/
|
|
953
|
-
labels:
|
|
1210
|
+
labels: z6.record(z6.string(), z6.string()).optional(),
|
|
954
1211
|
/**
|
|
955
1212
|
* Optional. If specified, the media resolution specified will be used.
|
|
956
1213
|
*
|
|
957
1214
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
958
1215
|
*/
|
|
959
|
-
mediaResolution:
|
|
1216
|
+
mediaResolution: z6.enum([
|
|
960
1217
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
961
1218
|
"MEDIA_RESOLUTION_LOW",
|
|
962
1219
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -967,8 +1224,8 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
967
1224
|
*
|
|
968
1225
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
969
1226
|
*/
|
|
970
|
-
imageConfig:
|
|
971
|
-
aspectRatio:
|
|
1227
|
+
imageConfig: z6.object({
|
|
1228
|
+
aspectRatio: z6.enum([
|
|
972
1229
|
"1:1",
|
|
973
1230
|
"2:3",
|
|
974
1231
|
"3:2",
|
|
@@ -984,12 +1241,12 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
984
1241
|
"1:4",
|
|
985
1242
|
"4:1"
|
|
986
1243
|
]).optional(),
|
|
987
|
-
imageSize:
|
|
1244
|
+
imageSize: z6.enum(["1K", "2K", "4K", "512"]).optional(),
|
|
988
1245
|
/**
|
|
989
1246
|
* Optional. Controls the generation of people in images.
|
|
990
1247
|
* Vertex AI only.
|
|
991
1248
|
*/
|
|
992
|
-
personGeneration:
|
|
1249
|
+
personGeneration: z6.enum([
|
|
993
1250
|
"PERSON_GENERATION_UNSPECIFIED",
|
|
994
1251
|
"ALLOW_ALL",
|
|
995
1252
|
"ALLOW_ADULT",
|
|
@@ -1003,7 +1260,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1003
1260
|
*
|
|
1004
1261
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
1005
1262
|
*/
|
|
1006
|
-
prominentPeople:
|
|
1263
|
+
prominentPeople: z6.enum([
|
|
1007
1264
|
"PROMINENT_PEOPLE_UNSPECIFIED",
|
|
1008
1265
|
"ALLOW_PROMINENT_PEOPLE",
|
|
1009
1266
|
"BLOCK_PROMINENT_PEOPLE"
|
|
@@ -1012,9 +1269,9 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1012
1269
|
* Optional. The image output format for generated images.
|
|
1013
1270
|
* Vertex AI only.
|
|
1014
1271
|
*/
|
|
1015
|
-
imageOutputOptions:
|
|
1016
|
-
mimeType:
|
|
1017
|
-
compressionQuality:
|
|
1272
|
+
imageOutputOptions: z6.object({
|
|
1273
|
+
mimeType: z6.enum(["image/jpeg", "image/png"]).optional(),
|
|
1274
|
+
compressionQuality: z6.number().optional()
|
|
1018
1275
|
}).optional()
|
|
1019
1276
|
}).optional(),
|
|
1020
1277
|
/**
|
|
@@ -1023,10 +1280,10 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1023
1280
|
*
|
|
1024
1281
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1025
1282
|
*/
|
|
1026
|
-
retrievalConfig:
|
|
1027
|
-
latLng:
|
|
1028
|
-
latitude:
|
|
1029
|
-
longitude:
|
|
1283
|
+
retrievalConfig: z6.object({
|
|
1284
|
+
latLng: z6.object({
|
|
1285
|
+
latitude: z6.number(),
|
|
1286
|
+
longitude: z6.number()
|
|
1030
1287
|
}).optional()
|
|
1031
1288
|
}).optional(),
|
|
1032
1289
|
/**
|
|
@@ -1039,12 +1296,12 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1039
1296
|
*
|
|
1040
1297
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
1041
1298
|
*/
|
|
1042
|
-
streamFunctionCallArguments:
|
|
1299
|
+
streamFunctionCallArguments: z6.boolean().optional(),
|
|
1043
1300
|
/**
|
|
1044
1301
|
* Optional. The service tier to use for the request. Sent as the
|
|
1045
1302
|
* `serviceTier` body field. Gemini API only.
|
|
1046
1303
|
*/
|
|
1047
|
-
serviceTier:
|
|
1304
|
+
serviceTier: z6.enum(["standard", "flex", "priority"]).optional(),
|
|
1048
1305
|
/**
|
|
1049
1306
|
* Optional. Vertex AI only. Sent as the
|
|
1050
1307
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1055,7 +1312,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1055
1312
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1056
1313
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1057
1314
|
*/
|
|
1058
|
-
sharedRequestType:
|
|
1315
|
+
sharedRequestType: z6.enum(["priority", "flex", "standard"]).optional(),
|
|
1059
1316
|
/**
|
|
1060
1317
|
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1061
1318
|
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
@@ -1063,7 +1320,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
1063
1320
|
*
|
|
1064
1321
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1065
1322
|
*/
|
|
1066
|
-
requestType:
|
|
1323
|
+
requestType: z6.enum(["shared"]).optional()
|
|
1067
1324
|
})
|
|
1068
1325
|
)
|
|
1069
1326
|
);
|
|
@@ -1099,7 +1356,6 @@ function prepareTools({
|
|
|
1099
1356
|
modelId,
|
|
1100
1357
|
isVertexProvider = false
|
|
1101
1358
|
}) {
|
|
1102
|
-
var _a, _b;
|
|
1103
1359
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1104
1360
|
const toolWarnings = [];
|
|
1105
1361
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
@@ -1217,11 +1473,7 @@ function prepareTools({
|
|
|
1217
1473
|
const functionDeclarations2 = [];
|
|
1218
1474
|
for (const tool of tools) {
|
|
1219
1475
|
if (tool.type === "function") {
|
|
1220
|
-
functionDeclarations2.push(
|
|
1221
|
-
name: tool.name,
|
|
1222
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
1223
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1224
|
-
});
|
|
1476
|
+
functionDeclarations2.push(prepareFunctionDeclaration(tool));
|
|
1225
1477
|
}
|
|
1226
1478
|
}
|
|
1227
1479
|
const combinedToolConfig = {
|
|
@@ -1265,11 +1517,7 @@ function prepareTools({
|
|
|
1265
1517
|
for (const tool of tools) {
|
|
1266
1518
|
switch (tool.type) {
|
|
1267
1519
|
case "function":
|
|
1268
|
-
functionDeclarations.push(
|
|
1269
|
-
name: tool.name,
|
|
1270
|
-
description: (_b = tool.description) != null ? _b : "",
|
|
1271
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1272
|
-
});
|
|
1520
|
+
functionDeclarations.push(prepareFunctionDeclaration(tool));
|
|
1273
1521
|
if (tool.strict === true) {
|
|
1274
1522
|
hasStrictTools = true;
|
|
1275
1523
|
}
|
|
@@ -1336,6 +1584,27 @@ function prepareTools({
|
|
|
1336
1584
|
}
|
|
1337
1585
|
}
|
|
1338
1586
|
}
|
|
1587
|
+
function prepareFunctionDeclaration(tool) {
|
|
1588
|
+
var _a;
|
|
1589
|
+
const declaration = {
|
|
1590
|
+
name: tool.name,
|
|
1591
|
+
description: (_a = tool.description) != null ? _a : ""
|
|
1592
|
+
};
|
|
1593
|
+
try {
|
|
1594
|
+
return {
|
|
1595
|
+
...declaration,
|
|
1596
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1597
|
+
};
|
|
1598
|
+
} catch (error) {
|
|
1599
|
+
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1600
|
+
throw error;
|
|
1601
|
+
}
|
|
1602
|
+
return {
|
|
1603
|
+
...declaration,
|
|
1604
|
+
parametersJsonSchema: tool.inputSchema
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1339
1608
|
|
|
1340
1609
|
// src/google-json-accumulator.ts
|
|
1341
1610
|
var GoogleJSONAccumulator = class {
|
|
@@ -1640,13 +1909,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1640
1909
|
var _a, _b, _c;
|
|
1641
1910
|
const warnings = [];
|
|
1642
1911
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1643
|
-
let googleOptions = await
|
|
1912
|
+
let googleOptions = await parseProviderOptions3({
|
|
1644
1913
|
provider: providerOptionsName,
|
|
1645
1914
|
providerOptions,
|
|
1646
1915
|
schema: googleLanguageModelOptions
|
|
1647
1916
|
});
|
|
1648
1917
|
if (googleOptions == null && providerOptionsName !== "google") {
|
|
1649
|
-
googleOptions = await
|
|
1918
|
+
googleOptions = await parseProviderOptions3({
|
|
1650
1919
|
provider: "google",
|
|
1651
1920
|
providerOptions,
|
|
1652
1921
|
schema: googleLanguageModelOptions
|
|
@@ -1796,8 +2065,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1796
2065
|
async doGenerate(options) {
|
|
1797
2066
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1798
2067
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1799
|
-
const mergedHeaders =
|
|
1800
|
-
await
|
|
2068
|
+
const mergedHeaders = combineHeaders3(
|
|
2069
|
+
await resolve3(this.config.headers),
|
|
1801
2070
|
options.headers,
|
|
1802
2071
|
extraHeaders
|
|
1803
2072
|
);
|
|
@@ -1805,14 +2074,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1805
2074
|
responseHeaders,
|
|
1806
2075
|
value: response,
|
|
1807
2076
|
rawValue: rawResponse
|
|
1808
|
-
} = await
|
|
2077
|
+
} = await postJsonToApi3({
|
|
1809
2078
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1810
2079
|
this.modelId
|
|
1811
2080
|
)}:generateContent`,
|
|
1812
2081
|
headers: mergedHeaders,
|
|
1813
2082
|
body: args,
|
|
1814
2083
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1815
|
-
successfulResponseHandler:
|
|
2084
|
+
successfulResponseHandler: createJsonResponseHandler3(responseSchema),
|
|
1816
2085
|
abortSignal: options.abortSignal,
|
|
1817
2086
|
fetch: this.config.fetch
|
|
1818
2087
|
});
|
|
@@ -1977,12 +2246,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1977
2246
|
}
|
|
1978
2247
|
async doStream(options) {
|
|
1979
2248
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1980
|
-
const headers =
|
|
1981
|
-
await
|
|
2249
|
+
const headers = combineHeaders3(
|
|
2250
|
+
await resolve3(this.config.headers),
|
|
1982
2251
|
options.headers,
|
|
1983
2252
|
extraHeaders
|
|
1984
2253
|
);
|
|
1985
|
-
const { responseHeaders, value: response } = await
|
|
2254
|
+
const { responseHeaders, value: response } = await postJsonToApi3({
|
|
1986
2255
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1987
2256
|
this.modelId
|
|
1988
2257
|
)}:streamGenerateContent?alt=sse`,
|
|
@@ -2498,192 +2767,192 @@ function extractSources({
|
|
|
2498
2767
|
}
|
|
2499
2768
|
return sources.length > 0 ? sources : void 0;
|
|
2500
2769
|
}
|
|
2501
|
-
var getGroundingMetadataSchema = () =>
|
|
2502
|
-
webSearchQueries:
|
|
2503
|
-
imageSearchQueries:
|
|
2504
|
-
retrievalQueries:
|
|
2505
|
-
searchEntryPoint:
|
|
2506
|
-
groundingChunks:
|
|
2507
|
-
|
|
2508
|
-
web:
|
|
2509
|
-
image:
|
|
2510
|
-
sourceUri:
|
|
2511
|
-
imageUri:
|
|
2512
|
-
title:
|
|
2513
|
-
domain:
|
|
2770
|
+
var getGroundingMetadataSchema = () => z7.object({
|
|
2771
|
+
webSearchQueries: z7.array(z7.string()).nullish(),
|
|
2772
|
+
imageSearchQueries: z7.array(z7.string()).nullish(),
|
|
2773
|
+
retrievalQueries: z7.array(z7.string()).nullish(),
|
|
2774
|
+
searchEntryPoint: z7.object({ renderedContent: z7.string() }).nullish(),
|
|
2775
|
+
groundingChunks: z7.array(
|
|
2776
|
+
z7.object({
|
|
2777
|
+
web: z7.object({ uri: z7.string(), title: z7.string().nullish() }).nullish(),
|
|
2778
|
+
image: z7.object({
|
|
2779
|
+
sourceUri: z7.string(),
|
|
2780
|
+
imageUri: z7.string(),
|
|
2781
|
+
title: z7.string().nullish(),
|
|
2782
|
+
domain: z7.string().nullish()
|
|
2514
2783
|
}).nullish(),
|
|
2515
|
-
retrievedContext:
|
|
2516
|
-
uri:
|
|
2517
|
-
title:
|
|
2518
|
-
text:
|
|
2519
|
-
fileSearchStore:
|
|
2784
|
+
retrievedContext: z7.object({
|
|
2785
|
+
uri: z7.string().nullish(),
|
|
2786
|
+
title: z7.string().nullish(),
|
|
2787
|
+
text: z7.string().nullish(),
|
|
2788
|
+
fileSearchStore: z7.string().nullish()
|
|
2520
2789
|
}).nullish(),
|
|
2521
|
-
maps:
|
|
2522
|
-
uri:
|
|
2523
|
-
title:
|
|
2524
|
-
text:
|
|
2525
|
-
placeId:
|
|
2790
|
+
maps: z7.object({
|
|
2791
|
+
uri: z7.string().nullish(),
|
|
2792
|
+
title: z7.string().nullish(),
|
|
2793
|
+
text: z7.string().nullish(),
|
|
2794
|
+
placeId: z7.string().nullish()
|
|
2526
2795
|
}).nullish()
|
|
2527
2796
|
})
|
|
2528
2797
|
).nullish(),
|
|
2529
|
-
groundingSupports:
|
|
2530
|
-
|
|
2531
|
-
segment:
|
|
2532
|
-
startIndex:
|
|
2533
|
-
endIndex:
|
|
2534
|
-
text:
|
|
2798
|
+
groundingSupports: z7.array(
|
|
2799
|
+
z7.object({
|
|
2800
|
+
segment: z7.object({
|
|
2801
|
+
startIndex: z7.number().nullish(),
|
|
2802
|
+
endIndex: z7.number().nullish(),
|
|
2803
|
+
text: z7.string().nullish()
|
|
2535
2804
|
}).nullish(),
|
|
2536
|
-
segment_text:
|
|
2537
|
-
groundingChunkIndices:
|
|
2538
|
-
supportChunkIndices:
|
|
2539
|
-
confidenceScores:
|
|
2540
|
-
confidenceScore:
|
|
2805
|
+
segment_text: z7.string().nullish(),
|
|
2806
|
+
groundingChunkIndices: z7.array(z7.number()).nullish(),
|
|
2807
|
+
supportChunkIndices: z7.array(z7.number()).nullish(),
|
|
2808
|
+
confidenceScores: z7.array(z7.number()).nullish(),
|
|
2809
|
+
confidenceScore: z7.array(z7.number()).nullish()
|
|
2541
2810
|
})
|
|
2542
2811
|
).nullish(),
|
|
2543
|
-
retrievalMetadata:
|
|
2544
|
-
|
|
2545
|
-
webDynamicRetrievalScore:
|
|
2812
|
+
retrievalMetadata: z7.union([
|
|
2813
|
+
z7.object({
|
|
2814
|
+
webDynamicRetrievalScore: z7.number()
|
|
2546
2815
|
}),
|
|
2547
|
-
|
|
2816
|
+
z7.object({})
|
|
2548
2817
|
]).nullish()
|
|
2549
2818
|
});
|
|
2550
|
-
var partialArgSchema =
|
|
2551
|
-
jsonPath:
|
|
2552
|
-
stringValue:
|
|
2553
|
-
numberValue:
|
|
2554
|
-
boolValue:
|
|
2555
|
-
nullValue:
|
|
2556
|
-
willContinue:
|
|
2819
|
+
var partialArgSchema = z7.object({
|
|
2820
|
+
jsonPath: z7.string(),
|
|
2821
|
+
stringValue: z7.string().nullish(),
|
|
2822
|
+
numberValue: z7.number().nullish(),
|
|
2823
|
+
boolValue: z7.boolean().nullish(),
|
|
2824
|
+
nullValue: z7.unknown().nullish(),
|
|
2825
|
+
willContinue: z7.boolean().nullish()
|
|
2557
2826
|
});
|
|
2558
|
-
var getContentSchema = () =>
|
|
2559
|
-
parts:
|
|
2560
|
-
|
|
2827
|
+
var getContentSchema = () => z7.object({
|
|
2828
|
+
parts: z7.array(
|
|
2829
|
+
z7.union([
|
|
2561
2830
|
// note: order matters since text can be fully empty
|
|
2562
|
-
|
|
2563
|
-
functionCall:
|
|
2564
|
-
id:
|
|
2565
|
-
name:
|
|
2566
|
-
args:
|
|
2567
|
-
partialArgs:
|
|
2568
|
-
willContinue:
|
|
2831
|
+
z7.object({
|
|
2832
|
+
functionCall: z7.object({
|
|
2833
|
+
id: z7.string().nullish(),
|
|
2834
|
+
name: z7.string().nullish(),
|
|
2835
|
+
args: z7.unknown().nullish(),
|
|
2836
|
+
partialArgs: z7.array(partialArgSchema).nullish(),
|
|
2837
|
+
willContinue: z7.boolean().nullish()
|
|
2569
2838
|
}),
|
|
2570
|
-
thoughtSignature:
|
|
2839
|
+
thoughtSignature: z7.string().nullish()
|
|
2571
2840
|
}),
|
|
2572
|
-
|
|
2573
|
-
inlineData:
|
|
2574
|
-
mimeType:
|
|
2575
|
-
data:
|
|
2841
|
+
z7.object({
|
|
2842
|
+
inlineData: z7.object({
|
|
2843
|
+
mimeType: z7.string(),
|
|
2844
|
+
data: z7.string()
|
|
2576
2845
|
}),
|
|
2577
|
-
thought:
|
|
2578
|
-
thoughtSignature:
|
|
2846
|
+
thought: z7.boolean().nullish(),
|
|
2847
|
+
thoughtSignature: z7.string().nullish()
|
|
2579
2848
|
}),
|
|
2580
|
-
|
|
2581
|
-
toolCall:
|
|
2582
|
-
toolType:
|
|
2583
|
-
args:
|
|
2584
|
-
id:
|
|
2849
|
+
z7.object({
|
|
2850
|
+
toolCall: z7.object({
|
|
2851
|
+
toolType: z7.string(),
|
|
2852
|
+
args: z7.unknown().nullish(),
|
|
2853
|
+
id: z7.string()
|
|
2585
2854
|
}),
|
|
2586
|
-
thoughtSignature:
|
|
2855
|
+
thoughtSignature: z7.string().nullish()
|
|
2587
2856
|
}),
|
|
2588
|
-
|
|
2589
|
-
toolResponse:
|
|
2590
|
-
toolType:
|
|
2591
|
-
response:
|
|
2592
|
-
id:
|
|
2857
|
+
z7.object({
|
|
2858
|
+
toolResponse: z7.object({
|
|
2859
|
+
toolType: z7.string(),
|
|
2860
|
+
response: z7.unknown().nullish(),
|
|
2861
|
+
id: z7.string()
|
|
2593
2862
|
}),
|
|
2594
|
-
thoughtSignature:
|
|
2863
|
+
thoughtSignature: z7.string().nullish()
|
|
2595
2864
|
}),
|
|
2596
|
-
|
|
2597
|
-
executableCode:
|
|
2598
|
-
language:
|
|
2599
|
-
code:
|
|
2865
|
+
z7.object({
|
|
2866
|
+
executableCode: z7.object({
|
|
2867
|
+
language: z7.string(),
|
|
2868
|
+
code: z7.string()
|
|
2600
2869
|
}).nullish(),
|
|
2601
|
-
codeExecutionResult:
|
|
2602
|
-
outcome:
|
|
2603
|
-
output:
|
|
2870
|
+
codeExecutionResult: z7.object({
|
|
2871
|
+
outcome: z7.string(),
|
|
2872
|
+
output: z7.string().nullish()
|
|
2604
2873
|
}).nullish(),
|
|
2605
|
-
text:
|
|
2606
|
-
thought:
|
|
2607
|
-
thoughtSignature:
|
|
2874
|
+
text: z7.string().nullish(),
|
|
2875
|
+
thought: z7.boolean().nullish(),
|
|
2876
|
+
thoughtSignature: z7.string().nullish()
|
|
2608
2877
|
})
|
|
2609
2878
|
])
|
|
2610
2879
|
).nullish()
|
|
2611
2880
|
});
|
|
2612
|
-
var getSafetyRatingSchema = () =>
|
|
2613
|
-
category:
|
|
2614
|
-
probability:
|
|
2615
|
-
probabilityScore:
|
|
2616
|
-
severity:
|
|
2617
|
-
severityScore:
|
|
2618
|
-
blocked:
|
|
2881
|
+
var getSafetyRatingSchema = () => z7.object({
|
|
2882
|
+
category: z7.string().nullish(),
|
|
2883
|
+
probability: z7.string().nullish(),
|
|
2884
|
+
probabilityScore: z7.number().nullish(),
|
|
2885
|
+
severity: z7.string().nullish(),
|
|
2886
|
+
severityScore: z7.number().nullish(),
|
|
2887
|
+
blocked: z7.boolean().nullish()
|
|
2619
2888
|
});
|
|
2620
|
-
var tokenDetailsSchema =
|
|
2621
|
-
|
|
2622
|
-
modality:
|
|
2623
|
-
tokenCount:
|
|
2889
|
+
var tokenDetailsSchema = z7.array(
|
|
2890
|
+
z7.object({
|
|
2891
|
+
modality: z7.string(),
|
|
2892
|
+
tokenCount: z7.number()
|
|
2624
2893
|
})
|
|
2625
2894
|
).nullish();
|
|
2626
|
-
var usageSchema =
|
|
2627
|
-
cachedContentTokenCount:
|
|
2628
|
-
thoughtsTokenCount:
|
|
2629
|
-
promptTokenCount:
|
|
2630
|
-
candidatesTokenCount:
|
|
2631
|
-
totalTokenCount:
|
|
2895
|
+
var usageSchema = z7.object({
|
|
2896
|
+
cachedContentTokenCount: z7.number().nullish(),
|
|
2897
|
+
thoughtsTokenCount: z7.number().nullish(),
|
|
2898
|
+
promptTokenCount: z7.number().nullish(),
|
|
2899
|
+
candidatesTokenCount: z7.number().nullish(),
|
|
2900
|
+
totalTokenCount: z7.number().nullish(),
|
|
2632
2901
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2633
|
-
trafficType:
|
|
2634
|
-
serviceTier:
|
|
2902
|
+
trafficType: z7.string().nullish(),
|
|
2903
|
+
serviceTier: z7.string().nullish(),
|
|
2635
2904
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2636
2905
|
promptTokensDetails: tokenDetailsSchema,
|
|
2637
2906
|
candidatesTokensDetails: tokenDetailsSchema
|
|
2638
2907
|
});
|
|
2639
|
-
var getUrlContextMetadataSchema = () =>
|
|
2640
|
-
urlMetadata:
|
|
2641
|
-
|
|
2642
|
-
retrievedUrl:
|
|
2643
|
-
urlRetrievalStatus:
|
|
2908
|
+
var getUrlContextMetadataSchema = () => z7.object({
|
|
2909
|
+
urlMetadata: z7.array(
|
|
2910
|
+
z7.object({
|
|
2911
|
+
retrievedUrl: z7.string(),
|
|
2912
|
+
urlRetrievalStatus: z7.string()
|
|
2644
2913
|
})
|
|
2645
2914
|
).nullish()
|
|
2646
2915
|
});
|
|
2647
2916
|
var responseSchema = lazySchema5(
|
|
2648
2917
|
() => zodSchema5(
|
|
2649
|
-
|
|
2650
|
-
responseId:
|
|
2651
|
-
candidates:
|
|
2652
|
-
|
|
2653
|
-
content: getContentSchema().nullish().or(
|
|
2654
|
-
finishReason:
|
|
2655
|
-
finishMessage:
|
|
2656
|
-
safetyRatings:
|
|
2918
|
+
z7.object({
|
|
2919
|
+
responseId: z7.string().nullish(),
|
|
2920
|
+
candidates: z7.array(
|
|
2921
|
+
z7.object({
|
|
2922
|
+
content: getContentSchema().nullish().or(z7.object({}).strict()),
|
|
2923
|
+
finishReason: z7.string().nullish(),
|
|
2924
|
+
finishMessage: z7.string().nullish(),
|
|
2925
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish(),
|
|
2657
2926
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2658
2927
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2659
2928
|
})
|
|
2660
2929
|
),
|
|
2661
2930
|
usageMetadata: usageSchema.nullish(),
|
|
2662
|
-
promptFeedback:
|
|
2663
|
-
blockReason:
|
|
2664
|
-
safetyRatings:
|
|
2931
|
+
promptFeedback: z7.object({
|
|
2932
|
+
blockReason: z7.string().nullish(),
|
|
2933
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
2665
2934
|
}).nullish()
|
|
2666
2935
|
})
|
|
2667
2936
|
)
|
|
2668
2937
|
);
|
|
2669
2938
|
var chunkSchema = lazySchema5(
|
|
2670
2939
|
() => zodSchema5(
|
|
2671
|
-
|
|
2672
|
-
responseId:
|
|
2673
|
-
candidates:
|
|
2674
|
-
|
|
2940
|
+
z7.object({
|
|
2941
|
+
responseId: z7.string().nullish(),
|
|
2942
|
+
candidates: z7.array(
|
|
2943
|
+
z7.object({
|
|
2675
2944
|
content: getContentSchema().nullish(),
|
|
2676
|
-
finishReason:
|
|
2677
|
-
finishMessage:
|
|
2678
|
-
safetyRatings:
|
|
2945
|
+
finishReason: z7.string().nullish(),
|
|
2946
|
+
finishMessage: z7.string().nullish(),
|
|
2947
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish(),
|
|
2679
2948
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2680
2949
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2681
2950
|
})
|
|
2682
2951
|
).nullish(),
|
|
2683
2952
|
usageMetadata: usageSchema.nullish(),
|
|
2684
|
-
promptFeedback:
|
|
2685
|
-
blockReason:
|
|
2686
|
-
safetyRatings:
|
|
2953
|
+
promptFeedback: z7.object({
|
|
2954
|
+
blockReason: z7.string().nullish(),
|
|
2955
|
+
safetyRatings: z7.array(getSafetyRatingSchema()).nullish()
|
|
2687
2956
|
}).nullish()
|
|
2688
2957
|
})
|
|
2689
2958
|
)
|
|
@@ -2691,16 +2960,16 @@ var chunkSchema = lazySchema5(
|
|
|
2691
2960
|
|
|
2692
2961
|
// src/tool/code-execution.ts
|
|
2693
2962
|
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
2694
|
-
import { z as
|
|
2963
|
+
import { z as z8 } from "zod/v4";
|
|
2695
2964
|
var codeExecution = createProviderToolFactoryWithOutputSchema({
|
|
2696
2965
|
id: "google.code_execution",
|
|
2697
|
-
inputSchema:
|
|
2698
|
-
language:
|
|
2699
|
-
code:
|
|
2966
|
+
inputSchema: z8.object({
|
|
2967
|
+
language: z8.string().describe("The programming language of the code."),
|
|
2968
|
+
code: z8.string().describe("The code to be executed.")
|
|
2700
2969
|
}),
|
|
2701
|
-
outputSchema:
|
|
2702
|
-
outcome:
|
|
2703
|
-
output:
|
|
2970
|
+
outputSchema: z8.object({
|
|
2971
|
+
outcome: z8.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
2972
|
+
output: z8.string().describe("The output from the code execution.")
|
|
2704
2973
|
})
|
|
2705
2974
|
});
|
|
2706
2975
|
|
|
@@ -2710,10 +2979,10 @@ import {
|
|
|
2710
2979
|
lazySchema as lazySchema6,
|
|
2711
2980
|
zodSchema as zodSchema6
|
|
2712
2981
|
} from "@ai-sdk/provider-utils";
|
|
2713
|
-
import { z as
|
|
2982
|
+
import { z as z9 } from "zod/v4";
|
|
2714
2983
|
var enterpriseWebSearch = createProviderToolFactory({
|
|
2715
2984
|
id: "google.enterprise_web_search",
|
|
2716
|
-
inputSchema: lazySchema6(() => zodSchema6(
|
|
2985
|
+
inputSchema: lazySchema6(() => zodSchema6(z9.object({})))
|
|
2717
2986
|
});
|
|
2718
2987
|
|
|
2719
2988
|
// src/tool/file-search.ts
|
|
@@ -2722,20 +2991,20 @@ import {
|
|
|
2722
2991
|
lazySchema as lazySchema7,
|
|
2723
2992
|
zodSchema as zodSchema7
|
|
2724
2993
|
} from "@ai-sdk/provider-utils";
|
|
2725
|
-
import { z as
|
|
2726
|
-
var fileSearchArgsBaseSchema =
|
|
2994
|
+
import { z as z10 } from "zod/v4";
|
|
2995
|
+
var fileSearchArgsBaseSchema = z10.object({
|
|
2727
2996
|
/** The names of the file_search_stores to retrieve from.
|
|
2728
2997
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
2729
2998
|
*/
|
|
2730
|
-
fileSearchStoreNames:
|
|
2999
|
+
fileSearchStoreNames: z10.array(z10.string()).describe(
|
|
2731
3000
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
2732
3001
|
),
|
|
2733
3002
|
/** The number of file search retrieval chunks to retrieve. */
|
|
2734
|
-
topK:
|
|
3003
|
+
topK: z10.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
2735
3004
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
2736
3005
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
2737
3006
|
*/
|
|
2738
|
-
metadataFilter:
|
|
3007
|
+
metadataFilter: z10.string().describe(
|
|
2739
3008
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2740
3009
|
).optional()
|
|
2741
3010
|
}).passthrough();
|
|
@@ -2753,10 +3022,10 @@ import {
|
|
|
2753
3022
|
lazySchema as lazySchema8,
|
|
2754
3023
|
zodSchema as zodSchema8
|
|
2755
3024
|
} from "@ai-sdk/provider-utils";
|
|
2756
|
-
import { z as
|
|
3025
|
+
import { z as z11 } from "zod/v4";
|
|
2757
3026
|
var googleMaps = createProviderToolFactory3({
|
|
2758
3027
|
id: "google.google_maps",
|
|
2759
|
-
inputSchema: lazySchema8(() => zodSchema8(
|
|
3028
|
+
inputSchema: lazySchema8(() => zodSchema8(z11.object({})))
|
|
2760
3029
|
});
|
|
2761
3030
|
|
|
2762
3031
|
// src/tool/google-search.ts
|
|
@@ -2765,15 +3034,15 @@ import {
|
|
|
2765
3034
|
lazySchema as lazySchema9,
|
|
2766
3035
|
zodSchema as zodSchema9
|
|
2767
3036
|
} from "@ai-sdk/provider-utils";
|
|
2768
|
-
import { z as
|
|
2769
|
-
var googleSearchToolArgsBaseSchema =
|
|
2770
|
-
searchTypes:
|
|
2771
|
-
webSearch:
|
|
2772
|
-
imageSearch:
|
|
3037
|
+
import { z as z12 } from "zod/v4";
|
|
3038
|
+
var googleSearchToolArgsBaseSchema = z12.object({
|
|
3039
|
+
searchTypes: z12.object({
|
|
3040
|
+
webSearch: z12.object({}).optional(),
|
|
3041
|
+
imageSearch: z12.object({}).optional()
|
|
2773
3042
|
}).optional(),
|
|
2774
|
-
timeRangeFilter:
|
|
2775
|
-
startTime:
|
|
2776
|
-
endTime:
|
|
3043
|
+
timeRangeFilter: z12.object({
|
|
3044
|
+
startTime: z12.string(),
|
|
3045
|
+
endTime: z12.string()
|
|
2777
3046
|
}).optional()
|
|
2778
3047
|
}).passthrough();
|
|
2779
3048
|
var googleSearchToolArgsSchema = lazySchema9(
|
|
@@ -2792,20 +3061,20 @@ import {
|
|
|
2792
3061
|
lazySchema as lazySchema10,
|
|
2793
3062
|
zodSchema as zodSchema10
|
|
2794
3063
|
} from "@ai-sdk/provider-utils";
|
|
2795
|
-
import { z as
|
|
3064
|
+
import { z as z13 } from "zod/v4";
|
|
2796
3065
|
var urlContext = createProviderToolFactory5({
|
|
2797
3066
|
id: "google.url_context",
|
|
2798
|
-
inputSchema: lazySchema10(() => zodSchema10(
|
|
3067
|
+
inputSchema: lazySchema10(() => zodSchema10(z13.object({})))
|
|
2799
3068
|
});
|
|
2800
3069
|
|
|
2801
3070
|
// src/tool/vertex-rag-store.ts
|
|
2802
3071
|
import { createProviderToolFactory as createProviderToolFactory6 } from "@ai-sdk/provider-utils";
|
|
2803
|
-
import { z as
|
|
3072
|
+
import { z as z14 } from "zod/v4";
|
|
2804
3073
|
var vertexRagStore = createProviderToolFactory6({
|
|
2805
3074
|
id: "google.vertex_rag_store",
|
|
2806
|
-
inputSchema:
|
|
2807
|
-
ragCorpus:
|
|
2808
|
-
topK:
|
|
3075
|
+
inputSchema: z14.object({
|
|
3076
|
+
ragCorpus: z14.string(),
|
|
3077
|
+
topK: z14.number().optional()
|
|
2809
3078
|
})
|
|
2810
3079
|
});
|
|
2811
3080
|
|
|
@@ -2871,17 +3140,17 @@ var googleTools = {
|
|
|
2871
3140
|
|
|
2872
3141
|
// src/google-generative-ai-image-model.ts
|
|
2873
3142
|
import {
|
|
2874
|
-
combineHeaders as
|
|
2875
|
-
convertToBase64 as
|
|
2876
|
-
createJsonResponseHandler as
|
|
3143
|
+
combineHeaders as combineHeaders4,
|
|
3144
|
+
convertToBase64 as convertToBase643,
|
|
3145
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2877
3146
|
generateId as defaultGenerateId,
|
|
2878
3147
|
lazySchema as lazySchema11,
|
|
2879
|
-
parseProviderOptions as
|
|
2880
|
-
postJsonToApi as
|
|
2881
|
-
resolve as
|
|
3148
|
+
parseProviderOptions as parseProviderOptions4,
|
|
3149
|
+
postJsonToApi as postJsonToApi4,
|
|
3150
|
+
resolve as resolve4,
|
|
2882
3151
|
zodSchema as zodSchema11
|
|
2883
3152
|
} from "@ai-sdk/provider-utils";
|
|
2884
|
-
import { z as
|
|
3153
|
+
import { z as z15 } from "zod/v4";
|
|
2885
3154
|
var GoogleGenerativeAIImageModel = class {
|
|
2886
3155
|
constructor(modelId, settings, config) {
|
|
2887
3156
|
this.modelId = modelId;
|
|
@@ -2946,7 +3215,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2946
3215
|
details: "This model does not support the `seed` option through this provider."
|
|
2947
3216
|
});
|
|
2948
3217
|
}
|
|
2949
|
-
const googleOptions = await
|
|
3218
|
+
const googleOptions = await parseProviderOptions4({
|
|
2950
3219
|
provider: "google",
|
|
2951
3220
|
providerOptions,
|
|
2952
3221
|
schema: googleImageModelOptionsSchema
|
|
@@ -2973,12 +3242,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2973
3242
|
instances: [{ prompt }],
|
|
2974
3243
|
parameters
|
|
2975
3244
|
};
|
|
2976
|
-
const { responseHeaders, value: response } = await
|
|
3245
|
+
const { responseHeaders, value: response } = await postJsonToApi4({
|
|
2977
3246
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
2978
|
-
headers:
|
|
3247
|
+
headers: combineHeaders4(await resolve4(this.config.headers), headers),
|
|
2979
3248
|
body,
|
|
2980
3249
|
failedResponseHandler: googleFailedResponseHandler,
|
|
2981
|
-
successfulResponseHandler:
|
|
3250
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
2982
3251
|
googleImageResponseSchema
|
|
2983
3252
|
),
|
|
2984
3253
|
abortSignal,
|
|
@@ -3059,7 +3328,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3059
3328
|
const languageModelPrompt = [
|
|
3060
3329
|
{ role: "user", content: userContent }
|
|
3061
3330
|
];
|
|
3062
|
-
const googleImageOptions = await
|
|
3331
|
+
const googleImageOptions = await parseProviderOptions4({
|
|
3063
3332
|
provider: "google",
|
|
3064
3333
|
providerOptions,
|
|
3065
3334
|
schema: googleImageModelOptionsSchema
|
|
@@ -3099,7 +3368,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3099
3368
|
const images = [];
|
|
3100
3369
|
for (const part of result.content) {
|
|
3101
3370
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
3102
|
-
images.push(
|
|
3371
|
+
images.push(convertToBase643(part.data));
|
|
3103
3372
|
}
|
|
3104
3373
|
}
|
|
3105
3374
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -3130,16 +3399,16 @@ function isGeminiModel(modelId) {
|
|
|
3130
3399
|
}
|
|
3131
3400
|
var googleImageResponseSchema = lazySchema11(
|
|
3132
3401
|
() => zodSchema11(
|
|
3133
|
-
|
|
3134
|
-
predictions:
|
|
3402
|
+
z15.object({
|
|
3403
|
+
predictions: z15.array(z15.object({ bytesBase64Encoded: z15.string() })).default([])
|
|
3135
3404
|
})
|
|
3136
3405
|
)
|
|
3137
3406
|
);
|
|
3138
3407
|
var googleImageModelOptionsSchema = lazySchema11(
|
|
3139
3408
|
() => zodSchema11(
|
|
3140
|
-
|
|
3141
|
-
personGeneration:
|
|
3142
|
-
aspectRatio:
|
|
3409
|
+
z15.object({
|
|
3410
|
+
personGeneration: z15.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3411
|
+
aspectRatio: z15.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
3143
3412
|
/**
|
|
3144
3413
|
* Enable Google Search grounding for Gemini image models. The value is
|
|
3145
3414
|
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
@@ -3159,19 +3428,19 @@ import {
|
|
|
3159
3428
|
AISDKError
|
|
3160
3429
|
} from "@ai-sdk/provider";
|
|
3161
3430
|
import {
|
|
3162
|
-
combineHeaders as
|
|
3431
|
+
combineHeaders as combineHeaders5,
|
|
3163
3432
|
convertUint8ArrayToBase64,
|
|
3164
|
-
createJsonResponseHandler as
|
|
3433
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3165
3434
|
delay,
|
|
3166
3435
|
getFromApi,
|
|
3167
3436
|
isSameOrigin,
|
|
3168
3437
|
lazySchema as lazySchema12,
|
|
3169
|
-
parseProviderOptions as
|
|
3170
|
-
postJsonToApi as
|
|
3171
|
-
resolve as
|
|
3438
|
+
parseProviderOptions as parseProviderOptions5,
|
|
3439
|
+
postJsonToApi as postJsonToApi5,
|
|
3440
|
+
resolve as resolve5,
|
|
3172
3441
|
zodSchema as zodSchema12
|
|
3173
3442
|
} from "@ai-sdk/provider-utils";
|
|
3174
|
-
import { z as
|
|
3443
|
+
import { z as z16 } from "zod/v4";
|
|
3175
3444
|
function getFirstFrameImage(options) {
|
|
3176
3445
|
var _a, _b;
|
|
3177
3446
|
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
@@ -3250,7 +3519,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3250
3519
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3251
3520
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3252
3521
|
const warnings = [];
|
|
3253
|
-
const googleOptions = await
|
|
3522
|
+
const googleOptions = await parseProviderOptions5({
|
|
3254
3523
|
provider: "google",
|
|
3255
3524
|
providerOptions: options.providerOptions,
|
|
3256
3525
|
schema: googleVideoModelOptionsSchema
|
|
@@ -3325,17 +3594,17 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3325
3594
|
}
|
|
3326
3595
|
}
|
|
3327
3596
|
}
|
|
3328
|
-
const { value: operation } = await
|
|
3597
|
+
const { value: operation } = await postJsonToApi5({
|
|
3329
3598
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
3330
|
-
headers:
|
|
3331
|
-
await
|
|
3599
|
+
headers: combineHeaders5(
|
|
3600
|
+
await resolve5(this.config.headers),
|
|
3332
3601
|
options.headers
|
|
3333
3602
|
),
|
|
3334
3603
|
body: {
|
|
3335
3604
|
instances,
|
|
3336
3605
|
parameters
|
|
3337
3606
|
},
|
|
3338
|
-
successfulResponseHandler:
|
|
3607
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3339
3608
|
googleOperationSchema
|
|
3340
3609
|
),
|
|
3341
3610
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3370,11 +3639,11 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3370
3639
|
}
|
|
3371
3640
|
const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi({
|
|
3372
3641
|
url: `${this.config.baseURL}/${operationName}`,
|
|
3373
|
-
headers:
|
|
3374
|
-
await
|
|
3642
|
+
headers: combineHeaders5(
|
|
3643
|
+
await resolve5(this.config.headers),
|
|
3375
3644
|
options.headers
|
|
3376
3645
|
),
|
|
3377
|
-
successfulResponseHandler:
|
|
3646
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
3378
3647
|
googleOperationSchema
|
|
3379
3648
|
),
|
|
3380
3649
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3399,7 +3668,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3399
3668
|
}
|
|
3400
3669
|
const videos = [];
|
|
3401
3670
|
const videoMetadata = [];
|
|
3402
|
-
const resolvedHeaders = await
|
|
3671
|
+
const resolvedHeaders = await resolve5(this.config.headers);
|
|
3403
3672
|
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
3404
3673
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
3405
3674
|
if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
@@ -3436,20 +3705,20 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3436
3705
|
};
|
|
3437
3706
|
}
|
|
3438
3707
|
};
|
|
3439
|
-
var googleOperationSchema =
|
|
3440
|
-
name:
|
|
3441
|
-
done:
|
|
3442
|
-
error:
|
|
3443
|
-
code:
|
|
3444
|
-
message:
|
|
3445
|
-
status:
|
|
3708
|
+
var googleOperationSchema = z16.object({
|
|
3709
|
+
name: z16.string().nullish(),
|
|
3710
|
+
done: z16.boolean().nullish(),
|
|
3711
|
+
error: z16.object({
|
|
3712
|
+
code: z16.number().nullish(),
|
|
3713
|
+
message: z16.string(),
|
|
3714
|
+
status: z16.string().nullish()
|
|
3446
3715
|
}).nullish(),
|
|
3447
|
-
response:
|
|
3448
|
-
generateVideoResponse:
|
|
3449
|
-
generatedSamples:
|
|
3450
|
-
|
|
3451
|
-
video:
|
|
3452
|
-
uri:
|
|
3716
|
+
response: z16.object({
|
|
3717
|
+
generateVideoResponse: z16.object({
|
|
3718
|
+
generatedSamples: z16.array(
|
|
3719
|
+
z16.object({
|
|
3720
|
+
video: z16.object({
|
|
3721
|
+
uri: z16.string().nullish()
|
|
3453
3722
|
}).nullish()
|
|
3454
3723
|
})
|
|
3455
3724
|
).nullish()
|
|
@@ -3458,15 +3727,15 @@ var googleOperationSchema = z14.object({
|
|
|
3458
3727
|
});
|
|
3459
3728
|
var googleVideoModelOptionsSchema = lazySchema12(
|
|
3460
3729
|
() => zodSchema12(
|
|
3461
|
-
|
|
3462
|
-
pollIntervalMs:
|
|
3463
|
-
pollTimeoutMs:
|
|
3464
|
-
personGeneration:
|
|
3465
|
-
negativePrompt:
|
|
3466
|
-
referenceImages:
|
|
3467
|
-
|
|
3468
|
-
bytesBase64Encoded:
|
|
3469
|
-
gcsUri:
|
|
3730
|
+
z16.object({
|
|
3731
|
+
pollIntervalMs: z16.number().positive().nullish(),
|
|
3732
|
+
pollTimeoutMs: z16.number().positive().nullish(),
|
|
3733
|
+
personGeneration: z16.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3734
|
+
negativePrompt: z16.string().nullish(),
|
|
3735
|
+
referenceImages: z16.array(
|
|
3736
|
+
z16.object({
|
|
3737
|
+
bytesBase64Encoded: z16.string().nullish(),
|
|
3738
|
+
gcsUri: z16.string().nullish()
|
|
3470
3739
|
})
|
|
3471
3740
|
).nullish()
|
|
3472
3741
|
}).passthrough()
|
|
@@ -3475,13 +3744,13 @@ var googleVideoModelOptionsSchema = lazySchema12(
|
|
|
3475
3744
|
|
|
3476
3745
|
// src/interactions/google-interactions-language-model.ts
|
|
3477
3746
|
import {
|
|
3478
|
-
combineHeaders as
|
|
3747
|
+
combineHeaders as combineHeaders7,
|
|
3479
3748
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
3480
|
-
createJsonResponseHandler as
|
|
3749
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
3481
3750
|
generateId as defaultGenerateId2,
|
|
3482
|
-
parseProviderOptions as
|
|
3483
|
-
postJsonToApi as
|
|
3484
|
-
resolve as
|
|
3751
|
+
parseProviderOptions as parseProviderOptions6,
|
|
3752
|
+
postJsonToApi as postJsonToApi6,
|
|
3753
|
+
resolve as resolve6
|
|
3485
3754
|
} from "@ai-sdk/provider-utils";
|
|
3486
3755
|
|
|
3487
3756
|
// src/interactions/convert-google-interactions-usage.ts
|
|
@@ -4248,7 +4517,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4248
4517
|
}
|
|
4249
4518
|
|
|
4250
4519
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
4251
|
-
import { convertToBase64 as
|
|
4520
|
+
import { convertToBase64 as convertToBase644, secureJsonParse as secureJsonParse2 } from "@ai-sdk/provider-utils";
|
|
4252
4521
|
function getTopLevelMediaType(mediaType) {
|
|
4253
4522
|
const slashIndex = mediaType.indexOf("/");
|
|
4254
4523
|
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
|
|
@@ -4437,7 +4706,7 @@ function convertFilePartToContent({
|
|
|
4437
4706
|
}
|
|
4438
4707
|
return {
|
|
4439
4708
|
type: kind,
|
|
4440
|
-
data:
|
|
4709
|
+
data: convertToBase644(part.data),
|
|
4441
4710
|
mime_type: part.mediaType,
|
|
4442
4711
|
...resolutionField
|
|
4443
4712
|
};
|
|
@@ -4611,7 +4880,7 @@ function filePartToImageBlock({
|
|
|
4611
4880
|
}
|
|
4612
4881
|
return {
|
|
4613
4882
|
type: "image",
|
|
4614
|
-
data:
|
|
4883
|
+
data: convertToBase644(part.data),
|
|
4615
4884
|
mime_type: part.mediaType
|
|
4616
4885
|
};
|
|
4617
4886
|
}
|
|
@@ -4642,30 +4911,30 @@ import {
|
|
|
4642
4911
|
lazySchema as lazySchema13,
|
|
4643
4912
|
zodSchema as zodSchema13
|
|
4644
4913
|
} from "@ai-sdk/provider-utils";
|
|
4645
|
-
import { z as
|
|
4646
|
-
var tokenByModalitySchema = () =>
|
|
4647
|
-
modality:
|
|
4648
|
-
tokens:
|
|
4914
|
+
import { z as z17 } from "zod/v4";
|
|
4915
|
+
var tokenByModalitySchema = () => z17.object({
|
|
4916
|
+
modality: z17.string().nullish(),
|
|
4917
|
+
tokens: z17.number().nullish()
|
|
4649
4918
|
}).loose();
|
|
4650
|
-
var usageSchema2 = () =>
|
|
4651
|
-
total_input_tokens:
|
|
4652
|
-
total_output_tokens:
|
|
4653
|
-
total_thought_tokens:
|
|
4654
|
-
total_cached_tokens:
|
|
4655
|
-
total_tool_use_tokens:
|
|
4656
|
-
total_tokens:
|
|
4657
|
-
input_tokens_by_modality:
|
|
4658
|
-
output_tokens_by_modality:
|
|
4659
|
-
cached_tokens_by_modality:
|
|
4660
|
-
tool_use_tokens_by_modality:
|
|
4661
|
-
grounding_tool_count:
|
|
4662
|
-
|
|
4663
|
-
type:
|
|
4664
|
-
count:
|
|
4919
|
+
var usageSchema2 = () => z17.object({
|
|
4920
|
+
total_input_tokens: z17.number().nullish(),
|
|
4921
|
+
total_output_tokens: z17.number().nullish(),
|
|
4922
|
+
total_thought_tokens: z17.number().nullish(),
|
|
4923
|
+
total_cached_tokens: z17.number().nullish(),
|
|
4924
|
+
total_tool_use_tokens: z17.number().nullish(),
|
|
4925
|
+
total_tokens: z17.number().nullish(),
|
|
4926
|
+
input_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4927
|
+
output_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4928
|
+
cached_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4929
|
+
tool_use_tokens_by_modality: z17.array(tokenByModalitySchema()).nullish(),
|
|
4930
|
+
grounding_tool_count: z17.array(
|
|
4931
|
+
z17.object({
|
|
4932
|
+
type: z17.string().nullish(),
|
|
4933
|
+
count: z17.number().nullish()
|
|
4665
4934
|
}).loose()
|
|
4666
4935
|
).nullish()
|
|
4667
4936
|
}).loose();
|
|
4668
|
-
var interactionStatusSchema = () =>
|
|
4937
|
+
var interactionStatusSchema = () => z17.enum([
|
|
4669
4938
|
"in_progress",
|
|
4670
4939
|
"requires_action",
|
|
4671
4940
|
"completed",
|
|
@@ -4674,69 +4943,69 @@ var interactionStatusSchema = () => z15.enum([
|
|
|
4674
4943
|
"incomplete"
|
|
4675
4944
|
]);
|
|
4676
4945
|
var annotationSchema = () => {
|
|
4677
|
-
const urlCitation =
|
|
4678
|
-
type:
|
|
4679
|
-
url:
|
|
4680
|
-
title:
|
|
4681
|
-
start_index:
|
|
4682
|
-
end_index:
|
|
4946
|
+
const urlCitation = z17.object({
|
|
4947
|
+
type: z17.literal("url_citation"),
|
|
4948
|
+
url: z17.string().nullish(),
|
|
4949
|
+
title: z17.string().nullish(),
|
|
4950
|
+
start_index: z17.number().nullish(),
|
|
4951
|
+
end_index: z17.number().nullish()
|
|
4683
4952
|
}).loose();
|
|
4684
|
-
const fileCitation =
|
|
4685
|
-
type:
|
|
4686
|
-
file_name:
|
|
4687
|
-
document_uri:
|
|
4688
|
-
url:
|
|
4689
|
-
page_number:
|
|
4690
|
-
media_id:
|
|
4691
|
-
start_index:
|
|
4692
|
-
end_index:
|
|
4693
|
-
custom_metadata:
|
|
4953
|
+
const fileCitation = z17.object({
|
|
4954
|
+
type: z17.literal("file_citation"),
|
|
4955
|
+
file_name: z17.string().nullish(),
|
|
4956
|
+
document_uri: z17.string().nullish(),
|
|
4957
|
+
url: z17.string().nullish(),
|
|
4958
|
+
page_number: z17.number().nullish(),
|
|
4959
|
+
media_id: z17.string().nullish(),
|
|
4960
|
+
start_index: z17.number().nullish(),
|
|
4961
|
+
end_index: z17.number().nullish(),
|
|
4962
|
+
custom_metadata: z17.record(z17.string(), z17.unknown()).nullish()
|
|
4694
4963
|
}).loose();
|
|
4695
|
-
const placeCitation =
|
|
4696
|
-
type:
|
|
4697
|
-
name:
|
|
4698
|
-
url:
|
|
4699
|
-
place_id:
|
|
4700
|
-
start_index:
|
|
4701
|
-
end_index:
|
|
4964
|
+
const placeCitation = z17.object({
|
|
4965
|
+
type: z17.literal("place_citation"),
|
|
4966
|
+
name: z17.string().nullish(),
|
|
4967
|
+
url: z17.string().nullish(),
|
|
4968
|
+
place_id: z17.string().nullish(),
|
|
4969
|
+
start_index: z17.number().nullish(),
|
|
4970
|
+
end_index: z17.number().nullish()
|
|
4702
4971
|
}).loose();
|
|
4703
|
-
return
|
|
4972
|
+
return z17.union([
|
|
4704
4973
|
urlCitation,
|
|
4705
4974
|
fileCitation,
|
|
4706
4975
|
placeCitation,
|
|
4707
|
-
|
|
4976
|
+
z17.object({ type: z17.string() }).loose()
|
|
4708
4977
|
]);
|
|
4709
4978
|
};
|
|
4710
|
-
var thoughtSummaryItemSchema = () =>
|
|
4711
|
-
type:
|
|
4712
|
-
text:
|
|
4713
|
-
data:
|
|
4714
|
-
mime_type:
|
|
4979
|
+
var thoughtSummaryItemSchema = () => z17.object({
|
|
4980
|
+
type: z17.string(),
|
|
4981
|
+
text: z17.string().nullish(),
|
|
4982
|
+
data: z17.string().nullish(),
|
|
4983
|
+
mime_type: z17.string().nullish()
|
|
4715
4984
|
}).loose();
|
|
4716
4985
|
var contentBlockSchema = () => {
|
|
4717
|
-
const textContent =
|
|
4718
|
-
type:
|
|
4719
|
-
text:
|
|
4720
|
-
annotations:
|
|
4986
|
+
const textContent = z17.object({
|
|
4987
|
+
type: z17.literal("text"),
|
|
4988
|
+
text: z17.string(),
|
|
4989
|
+
annotations: z17.array(annotationSchema()).nullish()
|
|
4721
4990
|
}).loose();
|
|
4722
|
-
const imageContent =
|
|
4723
|
-
type:
|
|
4724
|
-
data:
|
|
4725
|
-
mime_type:
|
|
4726
|
-
resolution:
|
|
4727
|
-
uri:
|
|
4991
|
+
const imageContent = z17.object({
|
|
4992
|
+
type: z17.literal("image"),
|
|
4993
|
+
data: z17.string().nullish(),
|
|
4994
|
+
mime_type: z17.string().nullish(),
|
|
4995
|
+
resolution: z17.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4996
|
+
uri: z17.string().nullish()
|
|
4728
4997
|
}).loose();
|
|
4729
|
-
const videoContent =
|
|
4730
|
-
type:
|
|
4731
|
-
data:
|
|
4732
|
-
mime_type:
|
|
4733
|
-
uri:
|
|
4998
|
+
const videoContent = z17.object({
|
|
4999
|
+
type: z17.literal("video"),
|
|
5000
|
+
data: z17.string().nullish(),
|
|
5001
|
+
mime_type: z17.string().nullish(),
|
|
5002
|
+
uri: z17.string().nullish()
|
|
4734
5003
|
}).loose();
|
|
4735
|
-
return
|
|
5004
|
+
return z17.union([
|
|
4736
5005
|
textContent,
|
|
4737
5006
|
imageContent,
|
|
4738
5007
|
videoContent,
|
|
4739
|
-
|
|
5008
|
+
z17.object({ type: z17.string() }).loose()
|
|
4740
5009
|
]);
|
|
4741
5010
|
};
|
|
4742
5011
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4756,73 +5025,73 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4756
5025
|
"mcp_server_tool_result"
|
|
4757
5026
|
];
|
|
4758
5027
|
var stepSchema = () => {
|
|
4759
|
-
const userInputStep =
|
|
4760
|
-
type:
|
|
4761
|
-
content:
|
|
5028
|
+
const userInputStep = z17.object({
|
|
5029
|
+
type: z17.literal("user_input"),
|
|
5030
|
+
content: z17.array(contentBlockSchema()).nullish()
|
|
4762
5031
|
}).loose();
|
|
4763
|
-
const modelOutputStep =
|
|
4764
|
-
type:
|
|
4765
|
-
content:
|
|
5032
|
+
const modelOutputStep = z17.object({
|
|
5033
|
+
type: z17.literal("model_output"),
|
|
5034
|
+
content: z17.array(contentBlockSchema()).nullish()
|
|
4766
5035
|
}).loose();
|
|
4767
|
-
const functionCallStep =
|
|
4768
|
-
type:
|
|
4769
|
-
id:
|
|
4770
|
-
name:
|
|
4771
|
-
arguments:
|
|
4772
|
-
signature:
|
|
5036
|
+
const functionCallStep = z17.object({
|
|
5037
|
+
type: z17.literal("function_call"),
|
|
5038
|
+
id: z17.string(),
|
|
5039
|
+
name: z17.string(),
|
|
5040
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5041
|
+
signature: z17.string().nullish()
|
|
4773
5042
|
}).loose();
|
|
4774
|
-
const thoughtStep =
|
|
4775
|
-
type:
|
|
4776
|
-
signature:
|
|
4777
|
-
summary:
|
|
5043
|
+
const thoughtStep = z17.object({
|
|
5044
|
+
type: z17.literal("thought"),
|
|
5045
|
+
signature: z17.string().nullish(),
|
|
5046
|
+
summary: z17.array(thoughtSummaryItemSchema()).nullish()
|
|
4778
5047
|
}).loose();
|
|
4779
|
-
const builtinToolCallStep =
|
|
4780
|
-
type:
|
|
4781
|
-
id:
|
|
4782
|
-
arguments:
|
|
4783
|
-
name:
|
|
4784
|
-
server_name:
|
|
4785
|
-
search_type:
|
|
4786
|
-
signature:
|
|
5048
|
+
const builtinToolCallStep = z17.object({
|
|
5049
|
+
type: z17.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5050
|
+
id: z17.string(),
|
|
5051
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5052
|
+
name: z17.string().nullish(),
|
|
5053
|
+
server_name: z17.string().nullish(),
|
|
5054
|
+
search_type: z17.string().nullish(),
|
|
5055
|
+
signature: z17.string().nullish()
|
|
4787
5056
|
}).loose();
|
|
4788
|
-
const builtinToolResultStep =
|
|
4789
|
-
type:
|
|
4790
|
-
call_id:
|
|
4791
|
-
result:
|
|
4792
|
-
is_error:
|
|
4793
|
-
name:
|
|
4794
|
-
server_name:
|
|
4795
|
-
signature:
|
|
5057
|
+
const builtinToolResultStep = z17.object({
|
|
5058
|
+
type: z17.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5059
|
+
call_id: z17.string(),
|
|
5060
|
+
result: z17.unknown().nullish(),
|
|
5061
|
+
is_error: z17.boolean().nullish(),
|
|
5062
|
+
name: z17.string().nullish(),
|
|
5063
|
+
server_name: z17.string().nullish(),
|
|
5064
|
+
signature: z17.string().nullish()
|
|
4796
5065
|
}).loose();
|
|
4797
|
-
return
|
|
5066
|
+
return z17.union([
|
|
4798
5067
|
userInputStep,
|
|
4799
5068
|
modelOutputStep,
|
|
4800
5069
|
functionCallStep,
|
|
4801
5070
|
thoughtStep,
|
|
4802
5071
|
builtinToolCallStep,
|
|
4803
5072
|
builtinToolResultStep,
|
|
4804
|
-
|
|
5073
|
+
z17.object({ type: z17.string() }).loose()
|
|
4805
5074
|
]);
|
|
4806
5075
|
};
|
|
4807
5076
|
var googleInteractionsResponseSchema = lazySchema13(
|
|
4808
5077
|
() => zodSchema13(
|
|
4809
|
-
|
|
5078
|
+
z17.object({
|
|
4810
5079
|
/*
|
|
4811
5080
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4812
5081
|
* stateless mode) — there is no server-side interaction record for the
|
|
4813
5082
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4814
5083
|
*/
|
|
4815
|
-
id:
|
|
4816
|
-
created:
|
|
4817
|
-
updated:
|
|
5084
|
+
id: z17.string().nullish(),
|
|
5085
|
+
created: z17.string().nullish(),
|
|
5086
|
+
updated: z17.string().nullish(),
|
|
4818
5087
|
status: interactionStatusSchema(),
|
|
4819
|
-
model:
|
|
4820
|
-
agent:
|
|
4821
|
-
steps:
|
|
5088
|
+
model: z17.string().nullish(),
|
|
5089
|
+
agent: z17.string().nullish(),
|
|
5090
|
+
steps: z17.array(stepSchema()).nullish(),
|
|
4822
5091
|
usage: usageSchema2().nullish(),
|
|
4823
|
-
service_tier:
|
|
4824
|
-
previous_interaction_id:
|
|
4825
|
-
response_modalities:
|
|
5092
|
+
service_tier: z17.string().nullish(),
|
|
5093
|
+
previous_interaction_id: z17.string().nullish(),
|
|
5094
|
+
response_modalities: z17.array(z17.string()).nullish()
|
|
4826
5095
|
}).loose()
|
|
4827
5096
|
)
|
|
4828
5097
|
);
|
|
@@ -4832,82 +5101,82 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4832
5101
|
const status = interactionStatusSchema();
|
|
4833
5102
|
const annotation = annotationSchema();
|
|
4834
5103
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4835
|
-
const interactionCreatedEvent =
|
|
4836
|
-
event_type:
|
|
4837
|
-
event_id:
|
|
4838
|
-
interaction:
|
|
5104
|
+
const interactionCreatedEvent = z17.object({
|
|
5105
|
+
event_type: z17.literal("interaction.created"),
|
|
5106
|
+
event_id: z17.string().nullish(),
|
|
5107
|
+
interaction: z17.object({
|
|
4839
5108
|
/*
|
|
4840
5109
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4841
5110
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4842
5111
|
*/
|
|
4843
|
-
id:
|
|
4844
|
-
created:
|
|
4845
|
-
model:
|
|
4846
|
-
agent:
|
|
5112
|
+
id: z17.string().nullish(),
|
|
5113
|
+
created: z17.string().nullish(),
|
|
5114
|
+
model: z17.string().nullish(),
|
|
5115
|
+
agent: z17.string().nullish(),
|
|
4847
5116
|
status: status.nullish()
|
|
4848
5117
|
}).loose()
|
|
4849
5118
|
}).loose();
|
|
4850
|
-
const stepStartEvent =
|
|
4851
|
-
event_type:
|
|
4852
|
-
event_id:
|
|
4853
|
-
index:
|
|
5119
|
+
const stepStartEvent = z17.object({
|
|
5120
|
+
event_type: z17.literal("step.start"),
|
|
5121
|
+
event_id: z17.string().nullish(),
|
|
5122
|
+
index: z17.number(),
|
|
4854
5123
|
step: stepSchema()
|
|
4855
5124
|
}).loose();
|
|
4856
|
-
const stepDeltaText =
|
|
4857
|
-
type:
|
|
4858
|
-
text:
|
|
5125
|
+
const stepDeltaText = z17.object({
|
|
5126
|
+
type: z17.literal("text"),
|
|
5127
|
+
text: z17.string()
|
|
4859
5128
|
}).loose();
|
|
4860
|
-
const stepDeltaThoughtSummary =
|
|
4861
|
-
type:
|
|
5129
|
+
const stepDeltaThoughtSummary = z17.object({
|
|
5130
|
+
type: z17.literal("thought_summary"),
|
|
4862
5131
|
content: thoughtSummaryItem.nullish()
|
|
4863
5132
|
}).loose();
|
|
4864
|
-
const stepDeltaThoughtSignature =
|
|
4865
|
-
type:
|
|
4866
|
-
signature:
|
|
5133
|
+
const stepDeltaThoughtSignature = z17.object({
|
|
5134
|
+
type: z17.literal("thought_signature"),
|
|
5135
|
+
signature: z17.string().nullish()
|
|
4867
5136
|
}).loose();
|
|
4868
|
-
const stepDeltaArgumentsDelta =
|
|
4869
|
-
type:
|
|
4870
|
-
arguments:
|
|
4871
|
-
id:
|
|
4872
|
-
signature:
|
|
5137
|
+
const stepDeltaArgumentsDelta = z17.object({
|
|
5138
|
+
type: z17.literal("arguments_delta"),
|
|
5139
|
+
arguments: z17.string().nullish(),
|
|
5140
|
+
id: z17.string().nullish(),
|
|
5141
|
+
signature: z17.string().nullish()
|
|
4873
5142
|
}).loose();
|
|
4874
|
-
const stepDeltaTextAnnotation =
|
|
4875
|
-
type:
|
|
4876
|
-
annotations:
|
|
5143
|
+
const stepDeltaTextAnnotation = z17.object({
|
|
5144
|
+
type: z17.enum(["text_annotation_delta", "text_annotation"]),
|
|
5145
|
+
annotations: z17.array(annotation).nullish()
|
|
4877
5146
|
}).loose();
|
|
4878
|
-
const stepDeltaImage =
|
|
4879
|
-
type:
|
|
4880
|
-
data:
|
|
4881
|
-
mime_type:
|
|
4882
|
-
resolution:
|
|
4883
|
-
uri:
|
|
5147
|
+
const stepDeltaImage = z17.object({
|
|
5148
|
+
type: z17.literal("image"),
|
|
5149
|
+
data: z17.string().nullish(),
|
|
5150
|
+
mime_type: z17.string().nullish(),
|
|
5151
|
+
resolution: z17.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5152
|
+
uri: z17.string().nullish()
|
|
4884
5153
|
}).loose();
|
|
4885
|
-
const stepDeltaVideo =
|
|
4886
|
-
type:
|
|
4887
|
-
data:
|
|
4888
|
-
mime_type:
|
|
4889
|
-
uri:
|
|
5154
|
+
const stepDeltaVideo = z17.object({
|
|
5155
|
+
type: z17.literal("video"),
|
|
5156
|
+
data: z17.string().nullish(),
|
|
5157
|
+
mime_type: z17.string().nullish(),
|
|
5158
|
+
uri: z17.string().nullish()
|
|
4890
5159
|
}).loose();
|
|
4891
|
-
const stepDeltaBuiltinToolCall =
|
|
4892
|
-
type:
|
|
4893
|
-
id:
|
|
4894
|
-
arguments:
|
|
4895
|
-
name:
|
|
4896
|
-
server_name:
|
|
4897
|
-
search_type:
|
|
4898
|
-
signature:
|
|
5160
|
+
const stepDeltaBuiltinToolCall = z17.object({
|
|
5161
|
+
type: z17.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5162
|
+
id: z17.string().nullish(),
|
|
5163
|
+
arguments: z17.record(z17.string(), z17.unknown()).nullish(),
|
|
5164
|
+
name: z17.string().nullish(),
|
|
5165
|
+
server_name: z17.string().nullish(),
|
|
5166
|
+
search_type: z17.string().nullish(),
|
|
5167
|
+
signature: z17.string().nullish()
|
|
4899
5168
|
}).loose();
|
|
4900
|
-
const stepDeltaBuiltinToolResult =
|
|
4901
|
-
type:
|
|
4902
|
-
call_id:
|
|
4903
|
-
result:
|
|
4904
|
-
is_error:
|
|
4905
|
-
name:
|
|
4906
|
-
server_name:
|
|
4907
|
-
signature:
|
|
5169
|
+
const stepDeltaBuiltinToolResult = z17.object({
|
|
5170
|
+
type: z17.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5171
|
+
call_id: z17.string().nullish(),
|
|
5172
|
+
result: z17.unknown().nullish(),
|
|
5173
|
+
is_error: z17.boolean().nullish(),
|
|
5174
|
+
name: z17.string().nullish(),
|
|
5175
|
+
server_name: z17.string().nullish(),
|
|
5176
|
+
signature: z17.string().nullish()
|
|
4908
5177
|
}).loose();
|
|
4909
|
-
const stepDeltaUnknown =
|
|
4910
|
-
const stepDeltaUnion =
|
|
5178
|
+
const stepDeltaUnknown = z17.object({ type: z17.string() }).loose();
|
|
5179
|
+
const stepDeltaUnion = z17.union([
|
|
4911
5180
|
stepDeltaText,
|
|
4912
5181
|
stepDeltaImage,
|
|
4913
5182
|
stepDeltaVideo,
|
|
@@ -4919,55 +5188,55 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4919
5188
|
stepDeltaBuiltinToolResult,
|
|
4920
5189
|
stepDeltaUnknown
|
|
4921
5190
|
]);
|
|
4922
|
-
const stepDeltaEvent =
|
|
4923
|
-
event_type:
|
|
4924
|
-
event_id:
|
|
4925
|
-
index:
|
|
5191
|
+
const stepDeltaEvent = z17.object({
|
|
5192
|
+
event_type: z17.literal("step.delta"),
|
|
5193
|
+
event_id: z17.string().nullish(),
|
|
5194
|
+
index: z17.number(),
|
|
4926
5195
|
delta: stepDeltaUnion
|
|
4927
5196
|
}).loose();
|
|
4928
|
-
const stepStopEvent =
|
|
4929
|
-
event_type:
|
|
4930
|
-
event_id:
|
|
4931
|
-
index:
|
|
5197
|
+
const stepStopEvent = z17.object({
|
|
5198
|
+
event_type: z17.literal("step.stop"),
|
|
5199
|
+
event_id: z17.string().nullish(),
|
|
5200
|
+
index: z17.number()
|
|
4932
5201
|
}).loose();
|
|
4933
|
-
const interactionStatusUpdateEvent =
|
|
4934
|
-
event_type:
|
|
4935
|
-
event_id:
|
|
4936
|
-
interaction_id:
|
|
5202
|
+
const interactionStatusUpdateEvent = z17.object({
|
|
5203
|
+
event_type: z17.literal("interaction.status_update"),
|
|
5204
|
+
event_id: z17.string().nullish(),
|
|
5205
|
+
interaction_id: z17.string().nullish(),
|
|
4937
5206
|
status: status.nullish()
|
|
4938
5207
|
}).loose();
|
|
4939
|
-
const interactionInProgressEvent =
|
|
4940
|
-
event_type:
|
|
4941
|
-
event_id:
|
|
4942
|
-
interaction_id:
|
|
5208
|
+
const interactionInProgressEvent = z17.object({
|
|
5209
|
+
event_type: z17.literal("interaction.in_progress"),
|
|
5210
|
+
event_id: z17.string().nullish(),
|
|
5211
|
+
interaction_id: z17.string().nullish(),
|
|
4943
5212
|
status: status.nullish()
|
|
4944
5213
|
}).loose();
|
|
4945
|
-
const interactionRequiresActionEvent =
|
|
4946
|
-
event_type:
|
|
4947
|
-
event_id:
|
|
4948
|
-
interaction_id:
|
|
5214
|
+
const interactionRequiresActionEvent = z17.object({
|
|
5215
|
+
event_type: z17.literal("interaction.requires_action"),
|
|
5216
|
+
event_id: z17.string().nullish(),
|
|
5217
|
+
interaction_id: z17.string().nullish(),
|
|
4949
5218
|
status: status.nullish()
|
|
4950
5219
|
}).loose();
|
|
4951
|
-
const interactionCompletedEvent =
|
|
4952
|
-
event_type:
|
|
4953
|
-
event_id:
|
|
4954
|
-
interaction:
|
|
4955
|
-
id:
|
|
5220
|
+
const interactionCompletedEvent = z17.object({
|
|
5221
|
+
event_type: z17.literal("interaction.completed"),
|
|
5222
|
+
event_id: z17.string().nullish(),
|
|
5223
|
+
interaction: z17.object({
|
|
5224
|
+
id: z17.string().nullish(),
|
|
4956
5225
|
status: status.nullish(),
|
|
4957
5226
|
usage: usageSchema2().nullish(),
|
|
4958
|
-
service_tier:
|
|
5227
|
+
service_tier: z17.string().nullish()
|
|
4959
5228
|
}).loose()
|
|
4960
5229
|
}).loose();
|
|
4961
|
-
const errorEvent =
|
|
4962
|
-
event_type:
|
|
4963
|
-
event_id:
|
|
4964
|
-
error:
|
|
4965
|
-
code:
|
|
4966
|
-
message:
|
|
5230
|
+
const errorEvent = z17.object({
|
|
5231
|
+
event_type: z17.literal("error"),
|
|
5232
|
+
event_id: z17.string().nullish(),
|
|
5233
|
+
error: z17.object({
|
|
5234
|
+
code: z17.string().nullish(),
|
|
5235
|
+
message: z17.string().nullish()
|
|
4967
5236
|
}).loose().nullish()
|
|
4968
5237
|
}).loose();
|
|
4969
|
-
const unknownEvent =
|
|
4970
|
-
return
|
|
5238
|
+
const unknownEvent = z17.object({ event_type: z17.string() }).loose();
|
|
5239
|
+
return z17.union([
|
|
4971
5240
|
interactionCreatedEvent,
|
|
4972
5241
|
stepStartEvent,
|
|
4973
5242
|
stepDeltaEvent,
|
|
@@ -4988,26 +5257,26 @@ import {
|
|
|
4988
5257
|
lazySchema as lazySchema14,
|
|
4989
5258
|
zodSchema as zodSchema14
|
|
4990
5259
|
} from "@ai-sdk/provider-utils";
|
|
4991
|
-
import { z as
|
|
5260
|
+
import { z as z18 } from "zod/v4";
|
|
4992
5261
|
var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
4993
5262
|
() => zodSchema14(
|
|
4994
|
-
|
|
4995
|
-
previousInteractionId:
|
|
4996
|
-
store:
|
|
4997
|
-
agent:
|
|
4998
|
-
agentConfig:
|
|
4999
|
-
|
|
5000
|
-
type:
|
|
5263
|
+
z18.object({
|
|
5264
|
+
previousInteractionId: z18.string().nullish(),
|
|
5265
|
+
store: z18.boolean().nullish(),
|
|
5266
|
+
agent: z18.string().nullish(),
|
|
5267
|
+
agentConfig: z18.union([
|
|
5268
|
+
z18.object({
|
|
5269
|
+
type: z18.literal("dynamic")
|
|
5001
5270
|
}).loose(),
|
|
5002
|
-
|
|
5003
|
-
type:
|
|
5004
|
-
thinkingSummaries:
|
|
5005
|
-
visualization:
|
|
5006
|
-
collaborativePlanning:
|
|
5271
|
+
z18.object({
|
|
5272
|
+
type: z18.literal("deep-research"),
|
|
5273
|
+
thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
|
|
5274
|
+
visualization: z18.enum(["off", "auto"]).nullish(),
|
|
5275
|
+
collaborativePlanning: z18.boolean().nullish()
|
|
5007
5276
|
})
|
|
5008
5277
|
]).nullish(),
|
|
5009
|
-
thinkingLevel:
|
|
5010
|
-
thinkingSummaries:
|
|
5278
|
+
thinkingLevel: z18.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5279
|
+
thinkingSummaries: z18.enum(["auto", "none"]).nullish(),
|
|
5011
5280
|
/**
|
|
5012
5281
|
* Output-format entries that map directly to the API's `response_format`
|
|
5013
5282
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -5017,17 +5286,17 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5017
5286
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
5018
5287
|
* text entry automatically; entries listed here are appended.
|
|
5019
5288
|
*/
|
|
5020
|
-
responseFormat:
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
type:
|
|
5024
|
-
mimeType:
|
|
5025
|
-
schema:
|
|
5289
|
+
responseFormat: z18.array(
|
|
5290
|
+
z18.union([
|
|
5291
|
+
z18.object({
|
|
5292
|
+
type: z18.literal("text"),
|
|
5293
|
+
mimeType: z18.string().nullish(),
|
|
5294
|
+
schema: z18.unknown().nullish()
|
|
5026
5295
|
}).loose(),
|
|
5027
|
-
|
|
5028
|
-
type:
|
|
5029
|
-
mimeType:
|
|
5030
|
-
aspectRatio:
|
|
5296
|
+
z18.object({
|
|
5297
|
+
type: z18.literal("image"),
|
|
5298
|
+
mimeType: z18.string().nullish(),
|
|
5299
|
+
aspectRatio: z18.enum([
|
|
5031
5300
|
"1:1",
|
|
5032
5301
|
"2:3",
|
|
5033
5302
|
"3:2",
|
|
@@ -5043,11 +5312,11 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5043
5312
|
"1:4",
|
|
5044
5313
|
"4:1"
|
|
5045
5314
|
]).nullish(),
|
|
5046
|
-
imageSize:
|
|
5315
|
+
imageSize: z18.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5047
5316
|
}).loose(),
|
|
5048
|
-
|
|
5049
|
-
type:
|
|
5050
|
-
mimeType:
|
|
5317
|
+
z18.object({
|
|
5318
|
+
type: z18.literal("audio"),
|
|
5319
|
+
mimeType: z18.string().nullish()
|
|
5051
5320
|
}).loose()
|
|
5052
5321
|
])
|
|
5053
5322
|
).nullish(),
|
|
@@ -5057,8 +5326,8 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5057
5326
|
* translates it into a matching `response_format` image entry and
|
|
5058
5327
|
* emits a warning when set.
|
|
5059
5328
|
*/
|
|
5060
|
-
imageConfig:
|
|
5061
|
-
aspectRatio:
|
|
5329
|
+
imageConfig: z18.object({
|
|
5330
|
+
aspectRatio: z18.enum([
|
|
5062
5331
|
"1:1",
|
|
5063
5332
|
"2:3",
|
|
5064
5333
|
"3:2",
|
|
@@ -5074,35 +5343,35 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5074
5343
|
"1:4",
|
|
5075
5344
|
"4:1"
|
|
5076
5345
|
]).nullish(),
|
|
5077
|
-
imageSize:
|
|
5346
|
+
imageSize: z18.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5078
5347
|
}).nullish(),
|
|
5079
|
-
mediaResolution:
|
|
5080
|
-
responseModalities:
|
|
5081
|
-
serviceTier:
|
|
5348
|
+
mediaResolution: z18.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5349
|
+
responseModalities: z18.array(z18.enum(["text", "image", "audio", "video", "document"])).nullish(),
|
|
5350
|
+
serviceTier: z18.enum(["flex", "standard", "priority"]).nullish(),
|
|
5082
5351
|
/**
|
|
5083
5352
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5084
5353
|
* `system` message wins and a warning is emitted.
|
|
5085
5354
|
*/
|
|
5086
|
-
systemInstruction:
|
|
5355
|
+
systemInstruction: z18.string().nullish(),
|
|
5087
5356
|
/**
|
|
5088
5357
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5089
5358
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5090
5359
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5091
5360
|
* accepts the prior turn.
|
|
5092
5361
|
*/
|
|
5093
|
-
signature:
|
|
5362
|
+
signature: z18.string().nullish(),
|
|
5094
5363
|
/**
|
|
5095
5364
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5096
5365
|
* decide which messages to drop when compacting under
|
|
5097
5366
|
* `previousInteractionId`.
|
|
5098
5367
|
*/
|
|
5099
|
-
interactionId:
|
|
5368
|
+
interactionId: z18.string().nullish(),
|
|
5100
5369
|
/**
|
|
5101
5370
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5102
5371
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5103
5372
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5104
5373
|
*/
|
|
5105
|
-
pollingTimeoutMs:
|
|
5374
|
+
pollingTimeoutMs: z18.number().int().positive().nullish(),
|
|
5106
5375
|
/**
|
|
5107
5376
|
* Run the interaction in the background. Required for agents whose
|
|
5108
5377
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5111,7 +5380,7 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5111
5380
|
* reject `true`; see the agent's documentation for which mode it
|
|
5112
5381
|
* requires.
|
|
5113
5382
|
*/
|
|
5114
|
-
background:
|
|
5383
|
+
background: z18.boolean().nullish(),
|
|
5115
5384
|
/**
|
|
5116
5385
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5117
5386
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5121,36 +5390,36 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
5121
5390
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5122
5391
|
* and/or constrain outbound traffic via `network`.
|
|
5123
5392
|
*/
|
|
5124
|
-
environment:
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
type:
|
|
5128
|
-
sources:
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
type:
|
|
5132
|
-
source:
|
|
5133
|
-
target:
|
|
5393
|
+
environment: z18.union([
|
|
5394
|
+
z18.string(),
|
|
5395
|
+
z18.object({
|
|
5396
|
+
type: z18.literal("remote"),
|
|
5397
|
+
sources: z18.array(
|
|
5398
|
+
z18.union([
|
|
5399
|
+
z18.object({
|
|
5400
|
+
type: z18.literal("gcs"),
|
|
5401
|
+
source: z18.string(),
|
|
5402
|
+
target: z18.string().nullish()
|
|
5134
5403
|
}),
|
|
5135
|
-
|
|
5136
|
-
type:
|
|
5137
|
-
source:
|
|
5138
|
-
target:
|
|
5404
|
+
z18.object({
|
|
5405
|
+
type: z18.literal("repository"),
|
|
5406
|
+
source: z18.string(),
|
|
5407
|
+
target: z18.string().nullish()
|
|
5139
5408
|
}),
|
|
5140
|
-
|
|
5141
|
-
type:
|
|
5142
|
-
content:
|
|
5143
|
-
target:
|
|
5409
|
+
z18.object({
|
|
5410
|
+
type: z18.literal("inline"),
|
|
5411
|
+
content: z18.string(),
|
|
5412
|
+
target: z18.string()
|
|
5144
5413
|
})
|
|
5145
5414
|
])
|
|
5146
5415
|
).nullish(),
|
|
5147
|
-
network:
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
allowlist:
|
|
5151
|
-
|
|
5152
|
-
domain:
|
|
5153
|
-
transform:
|
|
5416
|
+
network: z18.union([
|
|
5417
|
+
z18.literal("disabled"),
|
|
5418
|
+
z18.object({
|
|
5419
|
+
allowlist: z18.array(
|
|
5420
|
+
z18.object({
|
|
5421
|
+
domain: z18.string(),
|
|
5422
|
+
transform: z18.array(z18.record(z18.string(), z18.string())).nullish()
|
|
5154
5423
|
})
|
|
5155
5424
|
)
|
|
5156
5425
|
})
|
|
@@ -5350,7 +5619,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5350
5619
|
|
|
5351
5620
|
// src/interactions/poll-google-interactions.ts
|
|
5352
5621
|
import {
|
|
5353
|
-
createJsonResponseHandler as
|
|
5622
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
5354
5623
|
delay as delay2,
|
|
5355
5624
|
getFromApi as getFromApi2,
|
|
5356
5625
|
isAbortError
|
|
@@ -5358,7 +5627,7 @@ import {
|
|
|
5358
5627
|
|
|
5359
5628
|
// src/interactions/cancel-google-interaction.ts
|
|
5360
5629
|
import {
|
|
5361
|
-
combineHeaders as
|
|
5630
|
+
combineHeaders as combineHeaders6,
|
|
5362
5631
|
getRuntimeEnvironmentUserAgent,
|
|
5363
5632
|
withUserAgentSuffix
|
|
5364
5633
|
} from "@ai-sdk/provider-utils";
|
|
@@ -5377,7 +5646,7 @@ async function cancelGoogleInteraction({
|
|
|
5377
5646
|
const response = await fetch(url, {
|
|
5378
5647
|
method: "POST",
|
|
5379
5648
|
headers: withUserAgentSuffix(
|
|
5380
|
-
|
|
5649
|
+
combineHeaders6({ "Content-Type": "application/json" }, headers),
|
|
5381
5650
|
getRuntimeEnvironmentUserAgent()
|
|
5382
5651
|
),
|
|
5383
5652
|
body: "{}"
|
|
@@ -5437,7 +5706,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5437
5706
|
url,
|
|
5438
5707
|
headers,
|
|
5439
5708
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5440
|
-
successfulResponseHandler:
|
|
5709
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
5441
5710
|
googleInteractionsResponseSchema
|
|
5442
5711
|
),
|
|
5443
5712
|
abortSignal,
|
|
@@ -5950,7 +6219,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5950
6219
|
async getArgs(options) {
|
|
5951
6220
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
|
|
5952
6221
|
const warnings = [];
|
|
5953
|
-
const opts = await
|
|
6222
|
+
const opts = await parseProviderOptions6({
|
|
5954
6223
|
provider: "google",
|
|
5955
6224
|
providerOptions: options.providerOptions,
|
|
5956
6225
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6196,17 +6465,17 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6196
6465
|
var _a, _b, _c, _d, _e, _f;
|
|
6197
6466
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6198
6467
|
const url = `${this.config.baseURL}/interactions`;
|
|
6199
|
-
const mergedHeaders =
|
|
6468
|
+
const mergedHeaders = combineHeaders7(
|
|
6200
6469
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6201
|
-
this.config.headers ? await
|
|
6470
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6202
6471
|
options.headers
|
|
6203
6472
|
);
|
|
6204
|
-
const postResult = await
|
|
6473
|
+
const postResult = await postJsonToApi6({
|
|
6205
6474
|
url,
|
|
6206
6475
|
headers: mergedHeaders,
|
|
6207
6476
|
body: args,
|
|
6208
6477
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6209
|
-
successfulResponseHandler:
|
|
6478
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6210
6479
|
googleInteractionsResponseSchema
|
|
6211
6480
|
),
|
|
6212
6481
|
abortSignal: options.abortSignal,
|
|
@@ -6281,9 +6550,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6281
6550
|
var _a;
|
|
6282
6551
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6283
6552
|
const url = `${this.config.baseURL}/interactions`;
|
|
6284
|
-
const mergedHeaders =
|
|
6553
|
+
const mergedHeaders = combineHeaders7(
|
|
6285
6554
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6286
|
-
this.config.headers ? await
|
|
6555
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6287
6556
|
options.headers
|
|
6288
6557
|
);
|
|
6289
6558
|
if (isBackground) {
|
|
@@ -6297,7 +6566,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6297
6566
|
});
|
|
6298
6567
|
}
|
|
6299
6568
|
const body = { ...args, stream: true };
|
|
6300
|
-
const { responseHeaders, value: response } = await
|
|
6569
|
+
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
6301
6570
|
url,
|
|
6302
6571
|
headers: mergedHeaders,
|
|
6303
6572
|
body,
|
|
@@ -6348,12 +6617,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6348
6617
|
pollingTimeoutMs
|
|
6349
6618
|
}) {
|
|
6350
6619
|
var _a, _b;
|
|
6351
|
-
const postResult = await
|
|
6620
|
+
const postResult = await postJsonToApi6({
|
|
6352
6621
|
url,
|
|
6353
6622
|
headers: mergedHeaders,
|
|
6354
6623
|
body: args,
|
|
6355
6624
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6356
|
-
successfulResponseHandler:
|
|
6625
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6357
6626
|
googleInteractionsResponseSchema
|
|
6358
6627
|
),
|
|
6359
6628
|
abortSignal: options.abortSignal,
|
|
@@ -6498,6 +6767,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6498
6767
|
headers: getHeaders,
|
|
6499
6768
|
fetch: options.fetch
|
|
6500
6769
|
});
|
|
6770
|
+
const createTranscriptionModel = (modelId) => new GoogleTranscriptionModel(modelId, {
|
|
6771
|
+
provider: `${providerName}.transcription`,
|
|
6772
|
+
baseURL,
|
|
6773
|
+
headers: getHeaders,
|
|
6774
|
+
fetch: options.fetch
|
|
6775
|
+
});
|
|
6501
6776
|
const createVideoModel = (modelId) => {
|
|
6502
6777
|
var _a2;
|
|
6503
6778
|
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
@@ -6539,6 +6814,8 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6539
6814
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
6540
6815
|
provider.image = createImageModel;
|
|
6541
6816
|
provider.imageModel = createImageModel;
|
|
6817
|
+
provider.transcription = createTranscriptionModel;
|
|
6818
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
6542
6819
|
provider.video = createVideoModel;
|
|
6543
6820
|
provider.videoModel = createVideoModel;
|
|
6544
6821
|
provider.interactions = createInteractionsModel;
|
|
@@ -6547,6 +6824,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6547
6824
|
}
|
|
6548
6825
|
var google = createGoogleGenerativeAI();
|
|
6549
6826
|
export {
|
|
6827
|
+
GoogleTranscriptionModel,
|
|
6550
6828
|
VERSION,
|
|
6551
6829
|
createGoogleGenerativeAI,
|
|
6552
6830
|
google
|