@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.js
CHANGED
|
@@ -20,21 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
GoogleTranscriptionModel: () => GoogleTranscriptionModel,
|
|
23
24
|
VERSION: () => VERSION,
|
|
24
25
|
createGoogleGenerativeAI: () => createGoogleGenerativeAI,
|
|
25
26
|
google: () => google
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(index_exports);
|
|
28
29
|
|
|
29
|
-
// src/google-
|
|
30
|
-
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
|
-
|
|
32
|
-
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.113" : "0.0.0-test";
|
|
34
|
-
|
|
35
|
-
// src/google-generative-ai-embedding-model.ts
|
|
30
|
+
// src/transcription/google-transcription-model.ts
|
|
36
31
|
var import_provider = require("@ai-sdk/provider");
|
|
37
|
-
var
|
|
32
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
38
33
|
var import_v43 = require("zod/v4");
|
|
39
34
|
|
|
40
35
|
// src/google-error.ts
|
|
@@ -57,32 +52,222 @@ var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
57
52
|
errorToMessage: (data) => data.error.message
|
|
58
53
|
});
|
|
59
54
|
|
|
60
|
-
// src/google-
|
|
61
|
-
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
55
|
+
// src/transcription/google-transcription-model-options.ts
|
|
62
56
|
var import_v42 = require("zod/v4");
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
var googleTranscriptionModelOptions = import_v42.z.object({
|
|
58
|
+
/**
|
|
59
|
+
* BCP-47 language codes providing hints about the languages present in the
|
|
60
|
+
* audio. If omitted or empty, defaults to automatic language detection.
|
|
61
|
+
*/
|
|
62
|
+
languageCodes: import_v42.z.array(import_v42.z.string()).optional(),
|
|
63
|
+
/**
|
|
64
|
+
* Custom vocabulary phrases, which bias the speech recognition model
|
|
65
|
+
* toward recognizing specific terms.
|
|
66
|
+
*/
|
|
67
|
+
customVocabulary: import_v42.z.array(import_v42.z.string()).optional(),
|
|
68
|
+
/**
|
|
69
|
+
* Enables word-level timestamp generation.
|
|
70
|
+
*/
|
|
71
|
+
wordTimestamp: import_v42.z.boolean().optional(),
|
|
72
|
+
/**
|
|
73
|
+
* Enables speaker diarization.
|
|
74
|
+
*/
|
|
75
|
+
diarization: import_v42.z.boolean().optional(),
|
|
76
|
+
/**
|
|
77
|
+
* Transcription output formatting mode.
|
|
78
|
+
*
|
|
79
|
+
* - `VERBATIM` (default): exact literal transcript preserving filler
|
|
80
|
+
* words, repetitions, and false starts.
|
|
81
|
+
* - `SMART`: cleans up and structures the transcript in real time —
|
|
82
|
+
* disfluency removal, inline self-corrections, structured formatting
|
|
83
|
+
* (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
|
|
84
|
+
*/
|
|
85
|
+
mode: import_v42.z.enum(["SMART", "VERBATIM"]).optional()
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/transcription/google-transcription-model.ts
|
|
89
|
+
function isLiveTranscriptionModelId(modelId) {
|
|
90
|
+
return modelId.includes("-live");
|
|
91
|
+
}
|
|
92
|
+
var GoogleTranscriptionModel = class {
|
|
93
|
+
constructor(modelId, config) {
|
|
94
|
+
this.modelId = modelId;
|
|
95
|
+
this.config = config;
|
|
96
|
+
this.specificationVersion = "v3";
|
|
97
|
+
}
|
|
98
|
+
get provider() {
|
|
99
|
+
return this.config.provider;
|
|
100
|
+
}
|
|
101
|
+
async parseOptions(providerOptions) {
|
|
102
|
+
return (0, import_provider_utils2.parseProviderOptions)({
|
|
103
|
+
provider: "google",
|
|
104
|
+
providerOptions,
|
|
105
|
+
schema: googleTranscriptionModelOptions
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async doGenerate(options) {
|
|
109
|
+
var _a, _b, _c, _d, _e, _f;
|
|
110
|
+
if (isLiveTranscriptionModelId(this.modelId)) {
|
|
111
|
+
throw new import_provider.InvalidArgumentError({
|
|
112
|
+
argument: "modelId",
|
|
113
|
+
message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
117
|
+
const warnings = [];
|
|
118
|
+
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
119
|
+
const transcriptionConfig = buildTranscriptionConfig(googleOptions);
|
|
120
|
+
const requestBody = {
|
|
121
|
+
model: this.modelId,
|
|
122
|
+
input: [
|
|
123
|
+
{
|
|
124
|
+
type: "audio",
|
|
125
|
+
data: (0, import_provider_utils2.convertToBase64)(options.audio),
|
|
126
|
+
mime_type: options.mediaType
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
...transcriptionConfig != null ? { generation_config: { transcription_config: transcriptionConfig } } : {}
|
|
130
|
+
};
|
|
131
|
+
const {
|
|
132
|
+
value: response,
|
|
133
|
+
responseHeaders,
|
|
134
|
+
rawValue: rawResponse
|
|
135
|
+
} = await (0, import_provider_utils2.postJsonToApi)({
|
|
136
|
+
url: `${this.config.baseURL}/interactions`,
|
|
137
|
+
headers: (0, import_provider_utils2.combineHeaders)(
|
|
138
|
+
this.config.headers ? await (0, import_provider_utils2.resolve)(this.config.headers) : void 0,
|
|
139
|
+
options.headers
|
|
140
|
+
),
|
|
141
|
+
body: requestBody,
|
|
142
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
143
|
+
successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
|
|
144
|
+
googleInteractionsTranscriptionResponseSchema
|
|
145
|
+
),
|
|
146
|
+
abortSignal: options.abortSignal,
|
|
147
|
+
fetch: this.config.fetch
|
|
148
|
+
});
|
|
149
|
+
let text = "";
|
|
150
|
+
const segments = [];
|
|
151
|
+
for (const step of (_d = response.steps) != null ? _d : []) {
|
|
152
|
+
for (const content of (_e = step.content) != null ? _e : []) {
|
|
153
|
+
if (content.type !== "text" || content.text == null) continue;
|
|
154
|
+
text += content.text;
|
|
155
|
+
for (const annotation of (_f = content.annotations) != null ? _f : []) {
|
|
156
|
+
if (annotation.type !== "word_info") continue;
|
|
157
|
+
const startSecond = parseOffsetSeconds(annotation.start_offset);
|
|
158
|
+
const endSecond = parseOffsetSeconds(annotation.end_offset);
|
|
159
|
+
if (annotation.text == null || startSecond == null || endSecond == null) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
segments.push({ text: annotation.text, startSecond, endSecond });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
text,
|
|
168
|
+
segments,
|
|
169
|
+
language: void 0,
|
|
170
|
+
durationInSeconds: void 0,
|
|
171
|
+
warnings,
|
|
172
|
+
response: {
|
|
173
|
+
timestamp: currentDate,
|
|
174
|
+
modelId: this.modelId,
|
|
175
|
+
headers: responseHeaders,
|
|
176
|
+
body: rawResponse
|
|
177
|
+
},
|
|
178
|
+
...response.usage != null ? {
|
|
179
|
+
providerMetadata: {
|
|
180
|
+
google: { usage: response.usage }
|
|
181
|
+
}
|
|
182
|
+
} : {}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function buildTranscriptionConfig(options) {
|
|
187
|
+
var _a;
|
|
188
|
+
if (options == null) return void 0;
|
|
189
|
+
const config = {};
|
|
190
|
+
if (options.languageCodes != null) {
|
|
191
|
+
config.language_codes = options.languageCodes;
|
|
192
|
+
}
|
|
193
|
+
if (options.customVocabulary != null) {
|
|
194
|
+
config.custom_vocabulary = options.customVocabulary;
|
|
195
|
+
}
|
|
196
|
+
if (options.mode != null || options.diarization === true || options.wordTimestamp === true) {
|
|
197
|
+
config.mode = {
|
|
198
|
+
type: ((_a = options.mode) != null ? _a : "VERBATIM").toLowerCase(),
|
|
199
|
+
...options.diarization === true ? { diarization_mode: "speaker" } : {},
|
|
200
|
+
...options.wordTimestamp === true ? { timestamp_granularities: ["word"] } : {}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return Object.keys(config).length > 0 ? config : void 0;
|
|
204
|
+
}
|
|
205
|
+
function parseOffsetSeconds(offset) {
|
|
206
|
+
if (offset == null) return void 0;
|
|
207
|
+
const parsed = Number.parseFloat(offset);
|
|
208
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
209
|
+
}
|
|
210
|
+
var googleInteractionsWordAnnotationSchema = import_v43.z.object({
|
|
211
|
+
type: import_v43.z.string().nullish(),
|
|
212
|
+
text: import_v43.z.string().nullish(),
|
|
213
|
+
speaker: import_v43.z.string().nullish(),
|
|
214
|
+
start_offset: import_v43.z.string().nullish(),
|
|
215
|
+
end_offset: import_v43.z.string().nullish()
|
|
216
|
+
});
|
|
217
|
+
var googleInteractionsTranscriptionResponseSchema = import_v43.z.object({
|
|
218
|
+
status: import_v43.z.string().nullish(),
|
|
219
|
+
steps: import_v43.z.array(
|
|
220
|
+
import_v43.z.object({
|
|
221
|
+
type: import_v43.z.string().nullish(),
|
|
222
|
+
content: import_v43.z.array(
|
|
223
|
+
import_v43.z.object({
|
|
224
|
+
type: import_v43.z.string().nullish(),
|
|
225
|
+
text: import_v43.z.string().nullish(),
|
|
226
|
+
annotations: import_v43.z.array(googleInteractionsWordAnnotationSchema).nullish()
|
|
227
|
+
})
|
|
228
|
+
).nullish()
|
|
229
|
+
})
|
|
230
|
+
).nullish(),
|
|
231
|
+
usage: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).nullish()
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// src/google-provider.ts
|
|
235
|
+
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
236
|
+
|
|
237
|
+
// src/version.ts
|
|
238
|
+
var VERSION = true ? "3.0.116" : "0.0.0-test";
|
|
239
|
+
|
|
240
|
+
// src/google-generative-ai-embedding-model.ts
|
|
241
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
242
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
243
|
+
var import_v45 = require("zod/v4");
|
|
244
|
+
|
|
245
|
+
// src/google-generative-ai-embedding-options.ts
|
|
246
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
247
|
+
var import_v44 = require("zod/v4");
|
|
248
|
+
var googleEmbeddingContentPartSchema = import_v44.z.union([
|
|
249
|
+
import_v44.z.object({ text: import_v44.z.string() }),
|
|
250
|
+
import_v44.z.object({
|
|
251
|
+
inlineData: import_v44.z.object({
|
|
252
|
+
mimeType: import_v44.z.string(),
|
|
253
|
+
data: import_v44.z.string()
|
|
69
254
|
})
|
|
70
255
|
}),
|
|
71
|
-
|
|
72
|
-
fileData:
|
|
73
|
-
fileUri:
|
|
74
|
-
mimeType:
|
|
256
|
+
import_v44.z.object({
|
|
257
|
+
fileData: import_v44.z.object({
|
|
258
|
+
fileUri: import_v44.z.string(),
|
|
259
|
+
mimeType: import_v44.z.string()
|
|
75
260
|
})
|
|
76
261
|
})
|
|
77
262
|
]);
|
|
78
|
-
var googleEmbeddingModelOptions = (0,
|
|
79
|
-
() => (0,
|
|
80
|
-
|
|
263
|
+
var googleEmbeddingModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
264
|
+
() => (0, import_provider_utils3.zodSchema)(
|
|
265
|
+
import_v44.z.object({
|
|
81
266
|
/**
|
|
82
267
|
* Optional. Optional reduced dimension for the output embedding.
|
|
83
268
|
* If set, excessive values in the output embedding are truncated from the end.
|
|
84
269
|
*/
|
|
85
|
-
outputDimensionality:
|
|
270
|
+
outputDimensionality: import_v44.z.number().optional(),
|
|
86
271
|
/**
|
|
87
272
|
* Optional. Specifies the task type for generating embeddings.
|
|
88
273
|
* Supported task types:
|
|
@@ -95,7 +280,7 @@ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
|
|
|
95
280
|
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
96
281
|
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
97
282
|
*/
|
|
98
|
-
taskType:
|
|
283
|
+
taskType: import_v44.z.enum([
|
|
99
284
|
"SEMANTIC_SIMILARITY",
|
|
100
285
|
"CLASSIFICATION",
|
|
101
286
|
"CLUSTERING",
|
|
@@ -114,7 +299,7 @@ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
|
|
|
114
299
|
* The array length must match the number of values being embedded. In
|
|
115
300
|
* the case of a single embedding, the array length must be 1.
|
|
116
301
|
*/
|
|
117
|
-
content:
|
|
302
|
+
content: import_v44.z.array(import_v44.z.array(googleEmbeddingContentPartSchema).min(1).nullable()).optional()
|
|
118
303
|
})
|
|
119
304
|
)
|
|
120
305
|
);
|
|
@@ -137,21 +322,21 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
137
322
|
abortSignal,
|
|
138
323
|
providerOptions
|
|
139
324
|
}) {
|
|
140
|
-
const googleOptions = await (0,
|
|
325
|
+
const googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
141
326
|
provider: "google",
|
|
142
327
|
providerOptions,
|
|
143
328
|
schema: googleEmbeddingModelOptions
|
|
144
329
|
});
|
|
145
330
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
146
|
-
throw new
|
|
331
|
+
throw new import_provider2.TooManyEmbeddingValuesForCallError({
|
|
147
332
|
provider: this.provider,
|
|
148
333
|
modelId: this.modelId,
|
|
149
334
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
150
335
|
values
|
|
151
336
|
});
|
|
152
337
|
}
|
|
153
|
-
const mergedHeaders = (0,
|
|
154
|
-
await (0,
|
|
338
|
+
const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
|
|
339
|
+
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
155
340
|
headers
|
|
156
341
|
);
|
|
157
342
|
const multimodalContent = googleOptions == null ? void 0 : googleOptions.content;
|
|
@@ -168,7 +353,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
168
353
|
responseHeaders: responseHeaders2,
|
|
169
354
|
value: response2,
|
|
170
355
|
rawValue: rawValue2
|
|
171
|
-
} = await (0,
|
|
356
|
+
} = await (0, import_provider_utils4.postJsonToApi)({
|
|
172
357
|
url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
|
|
173
358
|
headers: mergedHeaders,
|
|
174
359
|
body: {
|
|
@@ -180,7 +365,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
180
365
|
taskType: googleOptions == null ? void 0 : googleOptions.taskType
|
|
181
366
|
},
|
|
182
367
|
failedResponseHandler: googleFailedResponseHandler,
|
|
183
|
-
successfulResponseHandler: (0,
|
|
368
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
184
369
|
googleGenerativeAISingleEmbeddingResponseSchema
|
|
185
370
|
),
|
|
186
371
|
abortSignal,
|
|
@@ -197,7 +382,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
197
382
|
responseHeaders,
|
|
198
383
|
value: response,
|
|
199
384
|
rawValue
|
|
200
|
-
} = await (0,
|
|
385
|
+
} = await (0, import_provider_utils4.postJsonToApi)({
|
|
201
386
|
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
|
|
202
387
|
headers: mergedHeaders,
|
|
203
388
|
body: {
|
|
@@ -216,7 +401,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
216
401
|
})
|
|
217
402
|
},
|
|
218
403
|
failedResponseHandler: googleFailedResponseHandler,
|
|
219
|
-
successfulResponseHandler: (0,
|
|
404
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
220
405
|
googleGenerativeAITextEmbeddingResponseSchema
|
|
221
406
|
),
|
|
222
407
|
abortSignal,
|
|
@@ -230,24 +415,24 @@ var GoogleGenerativeAIEmbeddingModel = class {
|
|
|
230
415
|
};
|
|
231
416
|
}
|
|
232
417
|
};
|
|
233
|
-
var googleGenerativeAITextEmbeddingResponseSchema = (0,
|
|
234
|
-
() => (0,
|
|
235
|
-
|
|
236
|
-
embeddings:
|
|
418
|
+
var googleGenerativeAITextEmbeddingResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
419
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
420
|
+
import_v45.z.object({
|
|
421
|
+
embeddings: import_v45.z.array(import_v45.z.object({ values: import_v45.z.array(import_v45.z.number()) }))
|
|
237
422
|
})
|
|
238
423
|
)
|
|
239
424
|
);
|
|
240
|
-
var googleGenerativeAISingleEmbeddingResponseSchema = (0,
|
|
241
|
-
() => (0,
|
|
242
|
-
|
|
243
|
-
embedding:
|
|
425
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
426
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
427
|
+
import_v45.z.object({
|
|
428
|
+
embedding: import_v45.z.object({ values: import_v45.z.array(import_v45.z.number()) })
|
|
244
429
|
})
|
|
245
430
|
)
|
|
246
431
|
);
|
|
247
432
|
|
|
248
433
|
// src/google-generative-ai-language-model.ts
|
|
249
|
-
var
|
|
250
|
-
var
|
|
434
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
435
|
+
var import_v47 = require("zod/v4");
|
|
251
436
|
|
|
252
437
|
// src/convert-google-generative-ai-usage.ts
|
|
253
438
|
function convertGoogleGenerativeAIUsage(usage) {
|
|
@@ -289,7 +474,11 @@ function convertGoogleGenerativeAIUsage(usage) {
|
|
|
289
474
|
}
|
|
290
475
|
|
|
291
476
|
// src/convert-json-schema-to-openapi-schema.ts
|
|
292
|
-
var
|
|
477
|
+
var import_provider3 = require("@ai-sdk/provider");
|
|
478
|
+
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
479
|
+
function isRecursiveJSONSchemaReferenceError(error) {
|
|
480
|
+
return import_provider3.UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
481
|
+
}
|
|
293
482
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
294
483
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
295
484
|
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
@@ -340,9 +529,6 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
340
529
|
if (description) result.description = description;
|
|
341
530
|
if (required) result.required = required;
|
|
342
531
|
if (format) result.format = format;
|
|
343
|
-
if (constValue !== void 0) {
|
|
344
|
-
result.enum = [constValue];
|
|
345
|
-
}
|
|
346
532
|
if (type) {
|
|
347
533
|
if (Array.isArray(type)) {
|
|
348
534
|
const hasNull = type.includes("null");
|
|
@@ -359,8 +545,9 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
359
545
|
result.type = type;
|
|
360
546
|
}
|
|
361
547
|
}
|
|
362
|
-
|
|
363
|
-
|
|
548
|
+
const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
|
|
549
|
+
if (values !== void 0) {
|
|
550
|
+
addEnumToSchema({ values, type, result });
|
|
364
551
|
}
|
|
365
552
|
if (properties != null) {
|
|
366
553
|
result.properties = Object.entries(properties).reduce(
|
|
@@ -420,6 +607,68 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
420
607
|
}
|
|
421
608
|
return result;
|
|
422
609
|
}
|
|
610
|
+
function addEnumToSchema({
|
|
611
|
+
values,
|
|
612
|
+
type,
|
|
613
|
+
result
|
|
614
|
+
}) {
|
|
615
|
+
const nullable = Array.isArray(type) && type.includes("null") || type === void 0 && values.includes(null);
|
|
616
|
+
const enumValues = nullable ? values.filter((value) => value !== null) : values;
|
|
617
|
+
if (values.length > 0 && values.every((value) => value === null)) {
|
|
618
|
+
const typeAllowsNull = type === void 0 || type === "null" || Array.isArray(type) && type.includes("null");
|
|
619
|
+
if (typeAllowsNull) {
|
|
620
|
+
result.type = "null";
|
|
621
|
+
if (Array.isArray(type)) {
|
|
622
|
+
delete result.anyOf;
|
|
623
|
+
}
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
const enumType = getEnumType({ values: enumValues, type });
|
|
628
|
+
if (enumType === void 0) {
|
|
629
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
630
|
+
functionality: "JSON Schema enum with mixed or unsupported values",
|
|
631
|
+
message: "Google does not support this JSON Schema enum. Enum values must share one supported primitive type and match the schema type."
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
result.type = enumType;
|
|
635
|
+
if (Array.isArray(type)) {
|
|
636
|
+
delete result.anyOf;
|
|
637
|
+
}
|
|
638
|
+
if (nullable) {
|
|
639
|
+
result.nullable = true;
|
|
640
|
+
}
|
|
641
|
+
if (enumType === "string") {
|
|
642
|
+
result.enum = enumValues;
|
|
643
|
+
} else {
|
|
644
|
+
result.format = "enum";
|
|
645
|
+
result.enum = enumValues.map(String);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function getEnumType({
|
|
649
|
+
values,
|
|
650
|
+
type
|
|
651
|
+
}) {
|
|
652
|
+
if (values.length === 0) {
|
|
653
|
+
return void 0;
|
|
654
|
+
}
|
|
655
|
+
const typeAllows = (enumType) => type === void 0 || type === enumType || Array.isArray(type) && type.includes(enumType);
|
|
656
|
+
if (typeAllows("string") && values.every((value) => typeof value === "string")) {
|
|
657
|
+
return "string";
|
|
658
|
+
}
|
|
659
|
+
if ((typeAllows("number") || typeAllows("integer")) && values.every((value) => typeof value === "number" && Number.isFinite(value))) {
|
|
660
|
+
if (typeAllows("number")) {
|
|
661
|
+
return "number";
|
|
662
|
+
}
|
|
663
|
+
if (values.every((value) => Number.isInteger(value))) {
|
|
664
|
+
return "integer";
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (typeAllows("boolean") && values.every((value) => typeof value === "boolean")) {
|
|
668
|
+
return "boolean";
|
|
669
|
+
}
|
|
670
|
+
return void 0;
|
|
671
|
+
}
|
|
423
672
|
function convertJSONSchemaReference({
|
|
424
673
|
jsonSchema,
|
|
425
674
|
reference,
|
|
@@ -431,8 +680,8 @@ function convertJSONSchemaReference({
|
|
|
431
680
|
referenceContext
|
|
432
681
|
);
|
|
433
682
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
434
|
-
throw new
|
|
435
|
-
functionality:
|
|
683
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
684
|
+
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
436
685
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
437
686
|
});
|
|
438
687
|
}
|
|
@@ -485,7 +734,7 @@ function getReferencedDefinition(reference, referenceContext) {
|
|
|
485
734
|
};
|
|
486
735
|
}
|
|
487
736
|
function throwUnsupportedReference(reference) {
|
|
488
|
-
throw new
|
|
737
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
489
738
|
functionality: `JSON Schema reference: ${reference}`,
|
|
490
739
|
message: "Google schema conversion only supports references to direct children of root-level $defs or definitions."
|
|
491
740
|
});
|
|
@@ -495,8 +744,8 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
495
744
|
}
|
|
496
745
|
|
|
497
746
|
// src/convert-to-google-generative-ai-messages.ts
|
|
498
|
-
var
|
|
499
|
-
var
|
|
747
|
+
var import_provider4 = require("@ai-sdk/provider");
|
|
748
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
500
749
|
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
501
750
|
function getGoogleProviderOptions(providerOptions, providerOptionsName) {
|
|
502
751
|
const namespaces = [
|
|
@@ -645,7 +894,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
645
894
|
switch (role) {
|
|
646
895
|
case "system": {
|
|
647
896
|
if (!systemMessagesAllowed) {
|
|
648
|
-
throw new
|
|
897
|
+
throw new import_provider4.UnsupportedFunctionalityError({
|
|
649
898
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
650
899
|
});
|
|
651
900
|
}
|
|
@@ -672,7 +921,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
672
921
|
} : {
|
|
673
922
|
inlineData: {
|
|
674
923
|
mimeType: mediaType,
|
|
675
|
-
data: (0,
|
|
924
|
+
data: (0, import_provider_utils5.convertToBase64)(part.data)
|
|
676
925
|
}
|
|
677
926
|
}
|
|
678
927
|
);
|
|
@@ -710,14 +959,14 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
710
959
|
}
|
|
711
960
|
case "file": {
|
|
712
961
|
if (part.data instanceof URL) {
|
|
713
|
-
throw new
|
|
962
|
+
throw new import_provider4.UnsupportedFunctionalityError({
|
|
714
963
|
functionality: "File data URLs in assistant messages are not supported"
|
|
715
964
|
});
|
|
716
965
|
}
|
|
717
966
|
return {
|
|
718
967
|
inlineData: {
|
|
719
968
|
mimeType: part.mediaType,
|
|
720
|
-
data: (0,
|
|
969
|
+
data: (0, import_provider_utils5.convertToBase64)(part.data)
|
|
721
970
|
},
|
|
722
971
|
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
723
972
|
thoughtSignature
|
|
@@ -742,7 +991,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
742
991
|
return {
|
|
743
992
|
toolCall: {
|
|
744
993
|
toolType: serverToolType,
|
|
745
|
-
args: typeof part.input === "string" ? (0,
|
|
994
|
+
args: typeof part.input === "string" ? (0, import_provider_utils5.secureJsonParse)(part.input) : part.input,
|
|
746
995
|
id: serverToolCallId
|
|
747
996
|
},
|
|
748
997
|
thoughtSignature: effectiveThoughtSignature
|
|
@@ -870,24 +1119,24 @@ function getModelPath(modelId) {
|
|
|
870
1119
|
}
|
|
871
1120
|
|
|
872
1121
|
// src/google-generative-ai-options.ts
|
|
873
|
-
var
|
|
874
|
-
var
|
|
875
|
-
var googleLanguageModelOptions = (0,
|
|
876
|
-
() => (0,
|
|
877
|
-
|
|
878
|
-
responseModalities:
|
|
879
|
-
thinkingConfig:
|
|
880
|
-
thinkingBudget:
|
|
881
|
-
includeThoughts:
|
|
1122
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1123
|
+
var import_v46 = require("zod/v4");
|
|
1124
|
+
var googleLanguageModelOptions = (0, import_provider_utils6.lazySchema)(
|
|
1125
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
1126
|
+
import_v46.z.object({
|
|
1127
|
+
responseModalities: import_v46.z.array(import_v46.z.enum(["TEXT", "IMAGE"])).optional(),
|
|
1128
|
+
thinkingConfig: import_v46.z.object({
|
|
1129
|
+
thinkingBudget: import_v46.z.number().optional(),
|
|
1130
|
+
includeThoughts: import_v46.z.boolean().optional(),
|
|
882
1131
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
883
|
-
thinkingLevel:
|
|
1132
|
+
thinkingLevel: import_v46.z.enum(["minimal", "low", "medium", "high"]).optional()
|
|
884
1133
|
}).optional(),
|
|
885
1134
|
/**
|
|
886
1135
|
* Optional.
|
|
887
1136
|
* The name of the cached content used as context to serve the prediction.
|
|
888
1137
|
* Format: cachedContents/{cachedContent}
|
|
889
1138
|
*/
|
|
890
|
-
cachedContent:
|
|
1139
|
+
cachedContent: import_v46.z.string().optional(),
|
|
891
1140
|
/**
|
|
892
1141
|
* Optional. Enable structured output. Default is true.
|
|
893
1142
|
*
|
|
@@ -896,13 +1145,13 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
896
1145
|
* Google Generative AI uses. You can use this to disable
|
|
897
1146
|
* structured outputs if you need to.
|
|
898
1147
|
*/
|
|
899
|
-
structuredOutputs:
|
|
1148
|
+
structuredOutputs: import_v46.z.boolean().optional(),
|
|
900
1149
|
/**
|
|
901
1150
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
902
1151
|
*/
|
|
903
|
-
safetySettings:
|
|
904
|
-
|
|
905
|
-
category:
|
|
1152
|
+
safetySettings: import_v46.z.array(
|
|
1153
|
+
import_v46.z.object({
|
|
1154
|
+
category: import_v46.z.enum([
|
|
906
1155
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
907
1156
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
908
1157
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -910,7 +1159,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
910
1159
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
911
1160
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
912
1161
|
]),
|
|
913
|
-
threshold:
|
|
1162
|
+
threshold: import_v46.z.enum([
|
|
914
1163
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
915
1164
|
"BLOCK_LOW_AND_ABOVE",
|
|
916
1165
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -920,7 +1169,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
920
1169
|
])
|
|
921
1170
|
})
|
|
922
1171
|
).optional(),
|
|
923
|
-
threshold:
|
|
1172
|
+
threshold: import_v46.z.enum([
|
|
924
1173
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
925
1174
|
"BLOCK_LOW_AND_ABOVE",
|
|
926
1175
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -933,19 +1182,19 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
933
1182
|
*
|
|
934
1183
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
935
1184
|
*/
|
|
936
|
-
audioTimestamp:
|
|
1185
|
+
audioTimestamp: import_v46.z.boolean().optional(),
|
|
937
1186
|
/**
|
|
938
1187
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
939
1188
|
*
|
|
940
1189
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
941
1190
|
*/
|
|
942
|
-
labels:
|
|
1191
|
+
labels: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional(),
|
|
943
1192
|
/**
|
|
944
1193
|
* Optional. If specified, the media resolution specified will be used.
|
|
945
1194
|
*
|
|
946
1195
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
947
1196
|
*/
|
|
948
|
-
mediaResolution:
|
|
1197
|
+
mediaResolution: import_v46.z.enum([
|
|
949
1198
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
950
1199
|
"MEDIA_RESOLUTION_LOW",
|
|
951
1200
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -956,8 +1205,8 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
956
1205
|
*
|
|
957
1206
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
958
1207
|
*/
|
|
959
|
-
imageConfig:
|
|
960
|
-
aspectRatio:
|
|
1208
|
+
imageConfig: import_v46.z.object({
|
|
1209
|
+
aspectRatio: import_v46.z.enum([
|
|
961
1210
|
"1:1",
|
|
962
1211
|
"2:3",
|
|
963
1212
|
"3:2",
|
|
@@ -973,12 +1222,12 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
973
1222
|
"1:4",
|
|
974
1223
|
"4:1"
|
|
975
1224
|
]).optional(),
|
|
976
|
-
imageSize:
|
|
1225
|
+
imageSize: import_v46.z.enum(["1K", "2K", "4K", "512"]).optional(),
|
|
977
1226
|
/**
|
|
978
1227
|
* Optional. Controls the generation of people in images.
|
|
979
1228
|
* Vertex AI only.
|
|
980
1229
|
*/
|
|
981
|
-
personGeneration:
|
|
1230
|
+
personGeneration: import_v46.z.enum([
|
|
982
1231
|
"PERSON_GENERATION_UNSPECIFIED",
|
|
983
1232
|
"ALLOW_ALL",
|
|
984
1233
|
"ALLOW_ADULT",
|
|
@@ -992,7 +1241,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
992
1241
|
*
|
|
993
1242
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
994
1243
|
*/
|
|
995
|
-
prominentPeople:
|
|
1244
|
+
prominentPeople: import_v46.z.enum([
|
|
996
1245
|
"PROMINENT_PEOPLE_UNSPECIFIED",
|
|
997
1246
|
"ALLOW_PROMINENT_PEOPLE",
|
|
998
1247
|
"BLOCK_PROMINENT_PEOPLE"
|
|
@@ -1001,9 +1250,9 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1001
1250
|
* Optional. The image output format for generated images.
|
|
1002
1251
|
* Vertex AI only.
|
|
1003
1252
|
*/
|
|
1004
|
-
imageOutputOptions:
|
|
1005
|
-
mimeType:
|
|
1006
|
-
compressionQuality:
|
|
1253
|
+
imageOutputOptions: import_v46.z.object({
|
|
1254
|
+
mimeType: import_v46.z.enum(["image/jpeg", "image/png"]).optional(),
|
|
1255
|
+
compressionQuality: import_v46.z.number().optional()
|
|
1007
1256
|
}).optional()
|
|
1008
1257
|
}).optional(),
|
|
1009
1258
|
/**
|
|
@@ -1012,10 +1261,10 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1012
1261
|
*
|
|
1013
1262
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1014
1263
|
*/
|
|
1015
|
-
retrievalConfig:
|
|
1016
|
-
latLng:
|
|
1017
|
-
latitude:
|
|
1018
|
-
longitude:
|
|
1264
|
+
retrievalConfig: import_v46.z.object({
|
|
1265
|
+
latLng: import_v46.z.object({
|
|
1266
|
+
latitude: import_v46.z.number(),
|
|
1267
|
+
longitude: import_v46.z.number()
|
|
1019
1268
|
}).optional()
|
|
1020
1269
|
}).optional(),
|
|
1021
1270
|
/**
|
|
@@ -1028,12 +1277,12 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1028
1277
|
*
|
|
1029
1278
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
1030
1279
|
*/
|
|
1031
|
-
streamFunctionCallArguments:
|
|
1280
|
+
streamFunctionCallArguments: import_v46.z.boolean().optional(),
|
|
1032
1281
|
/**
|
|
1033
1282
|
* Optional. The service tier to use for the request. Sent as the
|
|
1034
1283
|
* `serviceTier` body field. Gemini API only.
|
|
1035
1284
|
*/
|
|
1036
|
-
serviceTier:
|
|
1285
|
+
serviceTier: import_v46.z.enum(["standard", "flex", "priority"]).optional(),
|
|
1037
1286
|
/**
|
|
1038
1287
|
* Optional. Vertex AI only. Sent as the
|
|
1039
1288
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1044,7 +1293,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1044
1293
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1045
1294
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1046
1295
|
*/
|
|
1047
|
-
sharedRequestType:
|
|
1296
|
+
sharedRequestType: import_v46.z.enum(["priority", "flex", "standard"]).optional(),
|
|
1048
1297
|
/**
|
|
1049
1298
|
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1050
1299
|
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
@@ -1052,7 +1301,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1052
1301
|
*
|
|
1053
1302
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1054
1303
|
*/
|
|
1055
|
-
requestType:
|
|
1304
|
+
requestType: import_v46.z.enum(["shared"]).optional()
|
|
1056
1305
|
})
|
|
1057
1306
|
)
|
|
1058
1307
|
);
|
|
@@ -1079,14 +1328,13 @@ function getGoogleModelCapabilities(modelId) {
|
|
|
1079
1328
|
}
|
|
1080
1329
|
|
|
1081
1330
|
// src/google-prepare-tools.ts
|
|
1082
|
-
var
|
|
1331
|
+
var import_provider5 = require("@ai-sdk/provider");
|
|
1083
1332
|
function prepareTools({
|
|
1084
1333
|
tools,
|
|
1085
1334
|
toolChoice,
|
|
1086
1335
|
modelId,
|
|
1087
1336
|
isVertexProvider = false
|
|
1088
1337
|
}) {
|
|
1089
|
-
var _a, _b;
|
|
1090
1338
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1091
1339
|
const toolWarnings = [];
|
|
1092
1340
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
@@ -1204,11 +1452,7 @@ function prepareTools({
|
|
|
1204
1452
|
const functionDeclarations2 = [];
|
|
1205
1453
|
for (const tool of tools) {
|
|
1206
1454
|
if (tool.type === "function") {
|
|
1207
|
-
functionDeclarations2.push(
|
|
1208
|
-
name: tool.name,
|
|
1209
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
1210
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1211
|
-
});
|
|
1455
|
+
functionDeclarations2.push(prepareFunctionDeclaration(tool));
|
|
1212
1456
|
}
|
|
1213
1457
|
}
|
|
1214
1458
|
const combinedToolConfig = {
|
|
@@ -1252,11 +1496,7 @@ function prepareTools({
|
|
|
1252
1496
|
for (const tool of tools) {
|
|
1253
1497
|
switch (tool.type) {
|
|
1254
1498
|
case "function":
|
|
1255
|
-
functionDeclarations.push(
|
|
1256
|
-
name: tool.name,
|
|
1257
|
-
description: (_b = tool.description) != null ? _b : "",
|
|
1258
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1259
|
-
});
|
|
1499
|
+
functionDeclarations.push(prepareFunctionDeclaration(tool));
|
|
1260
1500
|
if (tool.strict === true) {
|
|
1261
1501
|
hasStrictTools = true;
|
|
1262
1502
|
}
|
|
@@ -1317,12 +1557,33 @@ function prepareTools({
|
|
|
1317
1557
|
};
|
|
1318
1558
|
default: {
|
|
1319
1559
|
const _exhaustiveCheck = type;
|
|
1320
|
-
throw new
|
|
1560
|
+
throw new import_provider5.UnsupportedFunctionalityError({
|
|
1321
1561
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1322
1562
|
});
|
|
1323
1563
|
}
|
|
1324
1564
|
}
|
|
1325
1565
|
}
|
|
1566
|
+
function prepareFunctionDeclaration(tool) {
|
|
1567
|
+
var _a;
|
|
1568
|
+
const declaration = {
|
|
1569
|
+
name: tool.name,
|
|
1570
|
+
description: (_a = tool.description) != null ? _a : ""
|
|
1571
|
+
};
|
|
1572
|
+
try {
|
|
1573
|
+
return {
|
|
1574
|
+
...declaration,
|
|
1575
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1576
|
+
};
|
|
1577
|
+
} catch (error) {
|
|
1578
|
+
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1579
|
+
throw error;
|
|
1580
|
+
}
|
|
1581
|
+
return {
|
|
1582
|
+
...declaration,
|
|
1583
|
+
parametersJsonSchema: tool.inputSchema
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1326
1587
|
|
|
1327
1588
|
// src/google-json-accumulator.ts
|
|
1328
1589
|
var GoogleJSONAccumulator = class {
|
|
@@ -1600,7 +1861,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1600
1861
|
var _a;
|
|
1601
1862
|
this.modelId = modelId;
|
|
1602
1863
|
this.config = config;
|
|
1603
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1864
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
|
|
1604
1865
|
}
|
|
1605
1866
|
get provider() {
|
|
1606
1867
|
return this.config.provider;
|
|
@@ -1627,13 +1888,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1627
1888
|
var _a, _b, _c;
|
|
1628
1889
|
const warnings = [];
|
|
1629
1890
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1630
|
-
let googleOptions = await (0,
|
|
1891
|
+
let googleOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
1631
1892
|
provider: providerOptionsName,
|
|
1632
1893
|
providerOptions,
|
|
1633
1894
|
schema: googleLanguageModelOptions
|
|
1634
1895
|
});
|
|
1635
1896
|
if (googleOptions == null && providerOptionsName !== "google") {
|
|
1636
|
-
googleOptions = await (0,
|
|
1897
|
+
googleOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
1637
1898
|
provider: "google",
|
|
1638
1899
|
providerOptions,
|
|
1639
1900
|
schema: googleLanguageModelOptions
|
|
@@ -1783,8 +2044,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1783
2044
|
async doGenerate(options) {
|
|
1784
2045
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1785
2046
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1786
|
-
const mergedHeaders = (0,
|
|
1787
|
-
await (0,
|
|
2047
|
+
const mergedHeaders = (0, import_provider_utils7.combineHeaders)(
|
|
2048
|
+
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
1788
2049
|
options.headers,
|
|
1789
2050
|
extraHeaders
|
|
1790
2051
|
);
|
|
@@ -1792,14 +2053,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1792
2053
|
responseHeaders,
|
|
1793
2054
|
value: response,
|
|
1794
2055
|
rawValue: rawResponse
|
|
1795
|
-
} = await (0,
|
|
2056
|
+
} = await (0, import_provider_utils7.postJsonToApi)({
|
|
1796
2057
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1797
2058
|
this.modelId
|
|
1798
2059
|
)}:generateContent`,
|
|
1799
2060
|
headers: mergedHeaders,
|
|
1800
2061
|
body: args,
|
|
1801
2062
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1802
|
-
successfulResponseHandler: (0,
|
|
2063
|
+
successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(responseSchema),
|
|
1803
2064
|
abortSignal: options.abortSignal,
|
|
1804
2065
|
fetch: this.config.fetch
|
|
1805
2066
|
});
|
|
@@ -1964,19 +2225,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1964
2225
|
}
|
|
1965
2226
|
async doStream(options) {
|
|
1966
2227
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1967
|
-
const headers = (0,
|
|
1968
|
-
await (0,
|
|
2228
|
+
const headers = (0, import_provider_utils7.combineHeaders)(
|
|
2229
|
+
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
1969
2230
|
options.headers,
|
|
1970
2231
|
extraHeaders
|
|
1971
2232
|
);
|
|
1972
|
-
const { responseHeaders, value: response } = await (0,
|
|
2233
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
|
|
1973
2234
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1974
2235
|
this.modelId
|
|
1975
2236
|
)}:streamGenerateContent?alt=sse`,
|
|
1976
2237
|
headers,
|
|
1977
2238
|
body: args,
|
|
1978
2239
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1979
|
-
successfulResponseHandler: (0,
|
|
2240
|
+
successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(chunkSchema),
|
|
1980
2241
|
abortSignal: options.abortSignal,
|
|
1981
2242
|
fetch: this.config.fetch
|
|
1982
2243
|
});
|
|
@@ -2485,272 +2746,272 @@ function extractSources({
|
|
|
2485
2746
|
}
|
|
2486
2747
|
return sources.length > 0 ? sources : void 0;
|
|
2487
2748
|
}
|
|
2488
|
-
var getGroundingMetadataSchema = () =>
|
|
2489
|
-
webSearchQueries:
|
|
2490
|
-
imageSearchQueries:
|
|
2491
|
-
retrievalQueries:
|
|
2492
|
-
searchEntryPoint:
|
|
2493
|
-
groundingChunks:
|
|
2494
|
-
|
|
2495
|
-
web:
|
|
2496
|
-
image:
|
|
2497
|
-
sourceUri:
|
|
2498
|
-
imageUri:
|
|
2499
|
-
title:
|
|
2500
|
-
domain:
|
|
2749
|
+
var getGroundingMetadataSchema = () => import_v47.z.object({
|
|
2750
|
+
webSearchQueries: import_v47.z.array(import_v47.z.string()).nullish(),
|
|
2751
|
+
imageSearchQueries: import_v47.z.array(import_v47.z.string()).nullish(),
|
|
2752
|
+
retrievalQueries: import_v47.z.array(import_v47.z.string()).nullish(),
|
|
2753
|
+
searchEntryPoint: import_v47.z.object({ renderedContent: import_v47.z.string() }).nullish(),
|
|
2754
|
+
groundingChunks: import_v47.z.array(
|
|
2755
|
+
import_v47.z.object({
|
|
2756
|
+
web: import_v47.z.object({ uri: import_v47.z.string(), title: import_v47.z.string().nullish() }).nullish(),
|
|
2757
|
+
image: import_v47.z.object({
|
|
2758
|
+
sourceUri: import_v47.z.string(),
|
|
2759
|
+
imageUri: import_v47.z.string(),
|
|
2760
|
+
title: import_v47.z.string().nullish(),
|
|
2761
|
+
domain: import_v47.z.string().nullish()
|
|
2501
2762
|
}).nullish(),
|
|
2502
|
-
retrievedContext:
|
|
2503
|
-
uri:
|
|
2504
|
-
title:
|
|
2505
|
-
text:
|
|
2506
|
-
fileSearchStore:
|
|
2763
|
+
retrievedContext: import_v47.z.object({
|
|
2764
|
+
uri: import_v47.z.string().nullish(),
|
|
2765
|
+
title: import_v47.z.string().nullish(),
|
|
2766
|
+
text: import_v47.z.string().nullish(),
|
|
2767
|
+
fileSearchStore: import_v47.z.string().nullish()
|
|
2507
2768
|
}).nullish(),
|
|
2508
|
-
maps:
|
|
2509
|
-
uri:
|
|
2510
|
-
title:
|
|
2511
|
-
text:
|
|
2512
|
-
placeId:
|
|
2769
|
+
maps: import_v47.z.object({
|
|
2770
|
+
uri: import_v47.z.string().nullish(),
|
|
2771
|
+
title: import_v47.z.string().nullish(),
|
|
2772
|
+
text: import_v47.z.string().nullish(),
|
|
2773
|
+
placeId: import_v47.z.string().nullish()
|
|
2513
2774
|
}).nullish()
|
|
2514
2775
|
})
|
|
2515
2776
|
).nullish(),
|
|
2516
|
-
groundingSupports:
|
|
2517
|
-
|
|
2518
|
-
segment:
|
|
2519
|
-
startIndex:
|
|
2520
|
-
endIndex:
|
|
2521
|
-
text:
|
|
2777
|
+
groundingSupports: import_v47.z.array(
|
|
2778
|
+
import_v47.z.object({
|
|
2779
|
+
segment: import_v47.z.object({
|
|
2780
|
+
startIndex: import_v47.z.number().nullish(),
|
|
2781
|
+
endIndex: import_v47.z.number().nullish(),
|
|
2782
|
+
text: import_v47.z.string().nullish()
|
|
2522
2783
|
}).nullish(),
|
|
2523
|
-
segment_text:
|
|
2524
|
-
groundingChunkIndices:
|
|
2525
|
-
supportChunkIndices:
|
|
2526
|
-
confidenceScores:
|
|
2527
|
-
confidenceScore:
|
|
2784
|
+
segment_text: import_v47.z.string().nullish(),
|
|
2785
|
+
groundingChunkIndices: import_v47.z.array(import_v47.z.number()).nullish(),
|
|
2786
|
+
supportChunkIndices: import_v47.z.array(import_v47.z.number()).nullish(),
|
|
2787
|
+
confidenceScores: import_v47.z.array(import_v47.z.number()).nullish(),
|
|
2788
|
+
confidenceScore: import_v47.z.array(import_v47.z.number()).nullish()
|
|
2528
2789
|
})
|
|
2529
2790
|
).nullish(),
|
|
2530
|
-
retrievalMetadata:
|
|
2531
|
-
|
|
2532
|
-
webDynamicRetrievalScore:
|
|
2791
|
+
retrievalMetadata: import_v47.z.union([
|
|
2792
|
+
import_v47.z.object({
|
|
2793
|
+
webDynamicRetrievalScore: import_v47.z.number()
|
|
2533
2794
|
}),
|
|
2534
|
-
|
|
2795
|
+
import_v47.z.object({})
|
|
2535
2796
|
]).nullish()
|
|
2536
2797
|
});
|
|
2537
|
-
var partialArgSchema =
|
|
2538
|
-
jsonPath:
|
|
2539
|
-
stringValue:
|
|
2540
|
-
numberValue:
|
|
2541
|
-
boolValue:
|
|
2542
|
-
nullValue:
|
|
2543
|
-
willContinue:
|
|
2798
|
+
var partialArgSchema = import_v47.z.object({
|
|
2799
|
+
jsonPath: import_v47.z.string(),
|
|
2800
|
+
stringValue: import_v47.z.string().nullish(),
|
|
2801
|
+
numberValue: import_v47.z.number().nullish(),
|
|
2802
|
+
boolValue: import_v47.z.boolean().nullish(),
|
|
2803
|
+
nullValue: import_v47.z.unknown().nullish(),
|
|
2804
|
+
willContinue: import_v47.z.boolean().nullish()
|
|
2544
2805
|
});
|
|
2545
|
-
var getContentSchema = () =>
|
|
2546
|
-
parts:
|
|
2547
|
-
|
|
2806
|
+
var getContentSchema = () => import_v47.z.object({
|
|
2807
|
+
parts: import_v47.z.array(
|
|
2808
|
+
import_v47.z.union([
|
|
2548
2809
|
// note: order matters since text can be fully empty
|
|
2549
|
-
|
|
2550
|
-
functionCall:
|
|
2551
|
-
id:
|
|
2552
|
-
name:
|
|
2553
|
-
args:
|
|
2554
|
-
partialArgs:
|
|
2555
|
-
willContinue:
|
|
2810
|
+
import_v47.z.object({
|
|
2811
|
+
functionCall: import_v47.z.object({
|
|
2812
|
+
id: import_v47.z.string().nullish(),
|
|
2813
|
+
name: import_v47.z.string().nullish(),
|
|
2814
|
+
args: import_v47.z.unknown().nullish(),
|
|
2815
|
+
partialArgs: import_v47.z.array(partialArgSchema).nullish(),
|
|
2816
|
+
willContinue: import_v47.z.boolean().nullish()
|
|
2556
2817
|
}),
|
|
2557
|
-
thoughtSignature:
|
|
2818
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2558
2819
|
}),
|
|
2559
|
-
|
|
2560
|
-
inlineData:
|
|
2561
|
-
mimeType:
|
|
2562
|
-
data:
|
|
2820
|
+
import_v47.z.object({
|
|
2821
|
+
inlineData: import_v47.z.object({
|
|
2822
|
+
mimeType: import_v47.z.string(),
|
|
2823
|
+
data: import_v47.z.string()
|
|
2563
2824
|
}),
|
|
2564
|
-
thought:
|
|
2565
|
-
thoughtSignature:
|
|
2825
|
+
thought: import_v47.z.boolean().nullish(),
|
|
2826
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2566
2827
|
}),
|
|
2567
|
-
|
|
2568
|
-
toolCall:
|
|
2569
|
-
toolType:
|
|
2570
|
-
args:
|
|
2571
|
-
id:
|
|
2828
|
+
import_v47.z.object({
|
|
2829
|
+
toolCall: import_v47.z.object({
|
|
2830
|
+
toolType: import_v47.z.string(),
|
|
2831
|
+
args: import_v47.z.unknown().nullish(),
|
|
2832
|
+
id: import_v47.z.string()
|
|
2572
2833
|
}),
|
|
2573
|
-
thoughtSignature:
|
|
2834
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2574
2835
|
}),
|
|
2575
|
-
|
|
2576
|
-
toolResponse:
|
|
2577
|
-
toolType:
|
|
2578
|
-
response:
|
|
2579
|
-
id:
|
|
2836
|
+
import_v47.z.object({
|
|
2837
|
+
toolResponse: import_v47.z.object({
|
|
2838
|
+
toolType: import_v47.z.string(),
|
|
2839
|
+
response: import_v47.z.unknown().nullish(),
|
|
2840
|
+
id: import_v47.z.string()
|
|
2580
2841
|
}),
|
|
2581
|
-
thoughtSignature:
|
|
2842
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2582
2843
|
}),
|
|
2583
|
-
|
|
2584
|
-
executableCode:
|
|
2585
|
-
language:
|
|
2586
|
-
code:
|
|
2844
|
+
import_v47.z.object({
|
|
2845
|
+
executableCode: import_v47.z.object({
|
|
2846
|
+
language: import_v47.z.string(),
|
|
2847
|
+
code: import_v47.z.string()
|
|
2587
2848
|
}).nullish(),
|
|
2588
|
-
codeExecutionResult:
|
|
2589
|
-
outcome:
|
|
2590
|
-
output:
|
|
2849
|
+
codeExecutionResult: import_v47.z.object({
|
|
2850
|
+
outcome: import_v47.z.string(),
|
|
2851
|
+
output: import_v47.z.string().nullish()
|
|
2591
2852
|
}).nullish(),
|
|
2592
|
-
text:
|
|
2593
|
-
thought:
|
|
2594
|
-
thoughtSignature:
|
|
2853
|
+
text: import_v47.z.string().nullish(),
|
|
2854
|
+
thought: import_v47.z.boolean().nullish(),
|
|
2855
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2595
2856
|
})
|
|
2596
2857
|
])
|
|
2597
2858
|
).nullish()
|
|
2598
2859
|
});
|
|
2599
|
-
var getSafetyRatingSchema = () =>
|
|
2600
|
-
category:
|
|
2601
|
-
probability:
|
|
2602
|
-
probabilityScore:
|
|
2603
|
-
severity:
|
|
2604
|
-
severityScore:
|
|
2605
|
-
blocked:
|
|
2860
|
+
var getSafetyRatingSchema = () => import_v47.z.object({
|
|
2861
|
+
category: import_v47.z.string().nullish(),
|
|
2862
|
+
probability: import_v47.z.string().nullish(),
|
|
2863
|
+
probabilityScore: import_v47.z.number().nullish(),
|
|
2864
|
+
severity: import_v47.z.string().nullish(),
|
|
2865
|
+
severityScore: import_v47.z.number().nullish(),
|
|
2866
|
+
blocked: import_v47.z.boolean().nullish()
|
|
2606
2867
|
});
|
|
2607
|
-
var tokenDetailsSchema =
|
|
2608
|
-
|
|
2609
|
-
modality:
|
|
2610
|
-
tokenCount:
|
|
2868
|
+
var tokenDetailsSchema = import_v47.z.array(
|
|
2869
|
+
import_v47.z.object({
|
|
2870
|
+
modality: import_v47.z.string(),
|
|
2871
|
+
tokenCount: import_v47.z.number()
|
|
2611
2872
|
})
|
|
2612
2873
|
).nullish();
|
|
2613
|
-
var usageSchema =
|
|
2614
|
-
cachedContentTokenCount:
|
|
2615
|
-
thoughtsTokenCount:
|
|
2616
|
-
promptTokenCount:
|
|
2617
|
-
candidatesTokenCount:
|
|
2618
|
-
totalTokenCount:
|
|
2874
|
+
var usageSchema = import_v47.z.object({
|
|
2875
|
+
cachedContentTokenCount: import_v47.z.number().nullish(),
|
|
2876
|
+
thoughtsTokenCount: import_v47.z.number().nullish(),
|
|
2877
|
+
promptTokenCount: import_v47.z.number().nullish(),
|
|
2878
|
+
candidatesTokenCount: import_v47.z.number().nullish(),
|
|
2879
|
+
totalTokenCount: import_v47.z.number().nullish(),
|
|
2619
2880
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2620
|
-
trafficType:
|
|
2621
|
-
serviceTier:
|
|
2881
|
+
trafficType: import_v47.z.string().nullish(),
|
|
2882
|
+
serviceTier: import_v47.z.string().nullish(),
|
|
2622
2883
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2623
2884
|
promptTokensDetails: tokenDetailsSchema,
|
|
2624
2885
|
candidatesTokensDetails: tokenDetailsSchema
|
|
2625
2886
|
});
|
|
2626
|
-
var getUrlContextMetadataSchema = () =>
|
|
2627
|
-
urlMetadata:
|
|
2628
|
-
|
|
2629
|
-
retrievedUrl:
|
|
2630
|
-
urlRetrievalStatus:
|
|
2887
|
+
var getUrlContextMetadataSchema = () => import_v47.z.object({
|
|
2888
|
+
urlMetadata: import_v47.z.array(
|
|
2889
|
+
import_v47.z.object({
|
|
2890
|
+
retrievedUrl: import_v47.z.string(),
|
|
2891
|
+
urlRetrievalStatus: import_v47.z.string()
|
|
2631
2892
|
})
|
|
2632
2893
|
).nullish()
|
|
2633
2894
|
});
|
|
2634
|
-
var responseSchema = (0,
|
|
2635
|
-
() => (0,
|
|
2636
|
-
|
|
2637
|
-
responseId:
|
|
2638
|
-
candidates:
|
|
2639
|
-
|
|
2640
|
-
content: getContentSchema().nullish().or(
|
|
2641
|
-
finishReason:
|
|
2642
|
-
finishMessage:
|
|
2643
|
-
safetyRatings:
|
|
2895
|
+
var responseSchema = (0, import_provider_utils7.lazySchema)(
|
|
2896
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
2897
|
+
import_v47.z.object({
|
|
2898
|
+
responseId: import_v47.z.string().nullish(),
|
|
2899
|
+
candidates: import_v47.z.array(
|
|
2900
|
+
import_v47.z.object({
|
|
2901
|
+
content: getContentSchema().nullish().or(import_v47.z.object({}).strict()),
|
|
2902
|
+
finishReason: import_v47.z.string().nullish(),
|
|
2903
|
+
finishMessage: import_v47.z.string().nullish(),
|
|
2904
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish(),
|
|
2644
2905
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2645
2906
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2646
2907
|
})
|
|
2647
2908
|
),
|
|
2648
2909
|
usageMetadata: usageSchema.nullish(),
|
|
2649
|
-
promptFeedback:
|
|
2650
|
-
blockReason:
|
|
2651
|
-
safetyRatings:
|
|
2910
|
+
promptFeedback: import_v47.z.object({
|
|
2911
|
+
blockReason: import_v47.z.string().nullish(),
|
|
2912
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish()
|
|
2652
2913
|
}).nullish()
|
|
2653
2914
|
})
|
|
2654
2915
|
)
|
|
2655
2916
|
);
|
|
2656
|
-
var chunkSchema = (0,
|
|
2657
|
-
() => (0,
|
|
2658
|
-
|
|
2659
|
-
responseId:
|
|
2660
|
-
candidates:
|
|
2661
|
-
|
|
2917
|
+
var chunkSchema = (0, import_provider_utils7.lazySchema)(
|
|
2918
|
+
() => (0, import_provider_utils7.zodSchema)(
|
|
2919
|
+
import_v47.z.object({
|
|
2920
|
+
responseId: import_v47.z.string().nullish(),
|
|
2921
|
+
candidates: import_v47.z.array(
|
|
2922
|
+
import_v47.z.object({
|
|
2662
2923
|
content: getContentSchema().nullish(),
|
|
2663
|
-
finishReason:
|
|
2664
|
-
finishMessage:
|
|
2665
|
-
safetyRatings:
|
|
2924
|
+
finishReason: import_v47.z.string().nullish(),
|
|
2925
|
+
finishMessage: import_v47.z.string().nullish(),
|
|
2926
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish(),
|
|
2666
2927
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2667
2928
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2668
2929
|
})
|
|
2669
2930
|
).nullish(),
|
|
2670
2931
|
usageMetadata: usageSchema.nullish(),
|
|
2671
|
-
promptFeedback:
|
|
2672
|
-
blockReason:
|
|
2673
|
-
safetyRatings:
|
|
2932
|
+
promptFeedback: import_v47.z.object({
|
|
2933
|
+
blockReason: import_v47.z.string().nullish(),
|
|
2934
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish()
|
|
2674
2935
|
}).nullish()
|
|
2675
2936
|
})
|
|
2676
2937
|
)
|
|
2677
2938
|
);
|
|
2678
2939
|
|
|
2679
2940
|
// src/tool/code-execution.ts
|
|
2680
|
-
var
|
|
2681
|
-
var
|
|
2682
|
-
var codeExecution = (0,
|
|
2941
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
2942
|
+
var import_v48 = require("zod/v4");
|
|
2943
|
+
var codeExecution = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
2683
2944
|
id: "google.code_execution",
|
|
2684
|
-
inputSchema:
|
|
2685
|
-
language:
|
|
2686
|
-
code:
|
|
2945
|
+
inputSchema: import_v48.z.object({
|
|
2946
|
+
language: import_v48.z.string().describe("The programming language of the code."),
|
|
2947
|
+
code: import_v48.z.string().describe("The code to be executed.")
|
|
2687
2948
|
}),
|
|
2688
|
-
outputSchema:
|
|
2689
|
-
outcome:
|
|
2690
|
-
output:
|
|
2949
|
+
outputSchema: import_v48.z.object({
|
|
2950
|
+
outcome: import_v48.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
2951
|
+
output: import_v48.z.string().describe("The output from the code execution.")
|
|
2691
2952
|
})
|
|
2692
2953
|
});
|
|
2693
2954
|
|
|
2694
2955
|
// src/tool/enterprise-web-search.ts
|
|
2695
|
-
var
|
|
2696
|
-
var
|
|
2697
|
-
var enterpriseWebSearch = (0,
|
|
2956
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
2957
|
+
var import_v49 = require("zod/v4");
|
|
2958
|
+
var enterpriseWebSearch = (0, import_provider_utils9.createProviderToolFactory)({
|
|
2698
2959
|
id: "google.enterprise_web_search",
|
|
2699
|
-
inputSchema: (0,
|
|
2960
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v49.z.object({})))
|
|
2700
2961
|
});
|
|
2701
2962
|
|
|
2702
2963
|
// src/tool/file-search.ts
|
|
2703
|
-
var
|
|
2704
|
-
var
|
|
2705
|
-
var fileSearchArgsBaseSchema =
|
|
2964
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
2965
|
+
var import_v410 = require("zod/v4");
|
|
2966
|
+
var fileSearchArgsBaseSchema = import_v410.z.object({
|
|
2706
2967
|
/** The names of the file_search_stores to retrieve from.
|
|
2707
2968
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
2708
2969
|
*/
|
|
2709
|
-
fileSearchStoreNames:
|
|
2970
|
+
fileSearchStoreNames: import_v410.z.array(import_v410.z.string()).describe(
|
|
2710
2971
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
2711
2972
|
),
|
|
2712
2973
|
/** The number of file search retrieval chunks to retrieve. */
|
|
2713
|
-
topK:
|
|
2974
|
+
topK: import_v410.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
2714
2975
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
2715
2976
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
2716
2977
|
*/
|
|
2717
|
-
metadataFilter:
|
|
2978
|
+
metadataFilter: import_v410.z.string().describe(
|
|
2718
2979
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2719
2980
|
).optional()
|
|
2720
2981
|
}).passthrough();
|
|
2721
|
-
var fileSearchArgsSchema = (0,
|
|
2722
|
-
() => (0,
|
|
2982
|
+
var fileSearchArgsSchema = (0, import_provider_utils10.lazySchema)(
|
|
2983
|
+
() => (0, import_provider_utils10.zodSchema)(fileSearchArgsBaseSchema)
|
|
2723
2984
|
);
|
|
2724
|
-
var fileSearch = (0,
|
|
2985
|
+
var fileSearch = (0, import_provider_utils10.createProviderToolFactory)({
|
|
2725
2986
|
id: "google.file_search",
|
|
2726
2987
|
inputSchema: fileSearchArgsSchema
|
|
2727
2988
|
});
|
|
2728
2989
|
|
|
2729
2990
|
// src/tool/google-maps.ts
|
|
2730
|
-
var
|
|
2731
|
-
var
|
|
2732
|
-
var googleMaps = (0,
|
|
2991
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2992
|
+
var import_v411 = require("zod/v4");
|
|
2993
|
+
var googleMaps = (0, import_provider_utils11.createProviderToolFactory)({
|
|
2733
2994
|
id: "google.google_maps",
|
|
2734
|
-
inputSchema: (0,
|
|
2995
|
+
inputSchema: (0, import_provider_utils11.lazySchema)(() => (0, import_provider_utils11.zodSchema)(import_v411.z.object({})))
|
|
2735
2996
|
});
|
|
2736
2997
|
|
|
2737
2998
|
// src/tool/google-search.ts
|
|
2738
|
-
var
|
|
2739
|
-
var
|
|
2740
|
-
var googleSearchToolArgsBaseSchema =
|
|
2741
|
-
searchTypes:
|
|
2742
|
-
webSearch:
|
|
2743
|
-
imageSearch:
|
|
2999
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
3000
|
+
var import_v412 = require("zod/v4");
|
|
3001
|
+
var googleSearchToolArgsBaseSchema = import_v412.z.object({
|
|
3002
|
+
searchTypes: import_v412.z.object({
|
|
3003
|
+
webSearch: import_v412.z.object({}).optional(),
|
|
3004
|
+
imageSearch: import_v412.z.object({}).optional()
|
|
2744
3005
|
}).optional(),
|
|
2745
|
-
timeRangeFilter:
|
|
2746
|
-
startTime:
|
|
2747
|
-
endTime:
|
|
3006
|
+
timeRangeFilter: import_v412.z.object({
|
|
3007
|
+
startTime: import_v412.z.string(),
|
|
3008
|
+
endTime: import_v412.z.string()
|
|
2748
3009
|
}).optional()
|
|
2749
3010
|
}).passthrough();
|
|
2750
|
-
var googleSearchToolArgsSchema = (0,
|
|
2751
|
-
() => (0,
|
|
3011
|
+
var googleSearchToolArgsSchema = (0, import_provider_utils12.lazySchema)(
|
|
3012
|
+
() => (0, import_provider_utils12.zodSchema)(googleSearchToolArgsBaseSchema)
|
|
2752
3013
|
);
|
|
2753
|
-
var googleSearch = (0,
|
|
3014
|
+
var googleSearch = (0, import_provider_utils12.createProviderToolFactory)(
|
|
2754
3015
|
{
|
|
2755
3016
|
id: "google.google_search",
|
|
2756
3017
|
inputSchema: googleSearchToolArgsSchema
|
|
@@ -2758,21 +3019,21 @@ var googleSearch = (0, import_provider_utils11.createProviderToolFactory)(
|
|
|
2758
3019
|
);
|
|
2759
3020
|
|
|
2760
3021
|
// src/tool/url-context.ts
|
|
2761
|
-
var
|
|
2762
|
-
var
|
|
2763
|
-
var urlContext = (0,
|
|
3022
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
3023
|
+
var import_v413 = require("zod/v4");
|
|
3024
|
+
var urlContext = (0, import_provider_utils13.createProviderToolFactory)({
|
|
2764
3025
|
id: "google.url_context",
|
|
2765
|
-
inputSchema: (0,
|
|
3026
|
+
inputSchema: (0, import_provider_utils13.lazySchema)(() => (0, import_provider_utils13.zodSchema)(import_v413.z.object({})))
|
|
2766
3027
|
});
|
|
2767
3028
|
|
|
2768
3029
|
// src/tool/vertex-rag-store.ts
|
|
2769
|
-
var
|
|
2770
|
-
var
|
|
2771
|
-
var vertexRagStore = (0,
|
|
3030
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
3031
|
+
var import_v414 = require("zod/v4");
|
|
3032
|
+
var vertexRagStore = (0, import_provider_utils14.createProviderToolFactory)({
|
|
2772
3033
|
id: "google.vertex_rag_store",
|
|
2773
|
-
inputSchema:
|
|
2774
|
-
ragCorpus:
|
|
2775
|
-
topK:
|
|
3034
|
+
inputSchema: import_v414.z.object({
|
|
3035
|
+
ragCorpus: import_v414.z.string(),
|
|
3036
|
+
topK: import_v414.z.number().optional()
|
|
2776
3037
|
})
|
|
2777
3038
|
});
|
|
2778
3039
|
|
|
@@ -2837,8 +3098,8 @@ var googleTools = {
|
|
|
2837
3098
|
};
|
|
2838
3099
|
|
|
2839
3100
|
// src/google-generative-ai-image-model.ts
|
|
2840
|
-
var
|
|
2841
|
-
var
|
|
3101
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
3102
|
+
var import_v415 = require("zod/v4");
|
|
2842
3103
|
var GoogleGenerativeAIImageModel = class {
|
|
2843
3104
|
constructor(modelId, settings, config) {
|
|
2844
3105
|
this.modelId = modelId;
|
|
@@ -2903,7 +3164,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2903
3164
|
details: "This model does not support the `seed` option through this provider."
|
|
2904
3165
|
});
|
|
2905
3166
|
}
|
|
2906
|
-
const googleOptions = await (0,
|
|
3167
|
+
const googleOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2907
3168
|
provider: "google",
|
|
2908
3169
|
providerOptions,
|
|
2909
3170
|
schema: googleImageModelOptionsSchema
|
|
@@ -2930,12 +3191,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2930
3191
|
instances: [{ prompt }],
|
|
2931
3192
|
parameters
|
|
2932
3193
|
};
|
|
2933
|
-
const { responseHeaders, value: response } = await (0,
|
|
3194
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
|
|
2934
3195
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
2935
|
-
headers: (0,
|
|
3196
|
+
headers: (0, import_provider_utils15.combineHeaders)(await (0, import_provider_utils15.resolve)(this.config.headers), headers),
|
|
2936
3197
|
body,
|
|
2937
3198
|
failedResponseHandler: googleFailedResponseHandler,
|
|
2938
|
-
successfulResponseHandler: (0,
|
|
3199
|
+
successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
|
|
2939
3200
|
googleImageResponseSchema
|
|
2940
3201
|
),
|
|
2941
3202
|
abortSignal,
|
|
@@ -3016,7 +3277,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3016
3277
|
const languageModelPrompt = [
|
|
3017
3278
|
{ role: "user", content: userContent }
|
|
3018
3279
|
];
|
|
3019
|
-
const googleImageOptions = await (0,
|
|
3280
|
+
const googleImageOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
3020
3281
|
provider: "google",
|
|
3021
3282
|
providerOptions,
|
|
3022
3283
|
schema: googleImageModelOptionsSchema
|
|
@@ -3027,7 +3288,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3027
3288
|
baseURL: this.config.baseURL,
|
|
3028
3289
|
headers: (_b = this.config.headers) != null ? _b : {},
|
|
3029
3290
|
fetch: this.config.fetch,
|
|
3030
|
-
generateId: (_c = this.config.generateId) != null ? _c :
|
|
3291
|
+
generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils15.generateId
|
|
3031
3292
|
});
|
|
3032
3293
|
const result = await languageModel.doGenerate({
|
|
3033
3294
|
prompt: languageModelPrompt,
|
|
@@ -3056,7 +3317,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3056
3317
|
const images = [];
|
|
3057
3318
|
for (const part of result.content) {
|
|
3058
3319
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
3059
|
-
images.push((0,
|
|
3320
|
+
images.push((0, import_provider_utils15.convertToBase64)(part.data));
|
|
3060
3321
|
}
|
|
3061
3322
|
}
|
|
3062
3323
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -3085,18 +3346,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3085
3346
|
function isGeminiModel(modelId) {
|
|
3086
3347
|
return modelId.startsWith("gemini-");
|
|
3087
3348
|
}
|
|
3088
|
-
var googleImageResponseSchema = (0,
|
|
3089
|
-
() => (0,
|
|
3090
|
-
|
|
3091
|
-
predictions:
|
|
3349
|
+
var googleImageResponseSchema = (0, import_provider_utils15.lazySchema)(
|
|
3350
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
3351
|
+
import_v415.z.object({
|
|
3352
|
+
predictions: import_v415.z.array(import_v415.z.object({ bytesBase64Encoded: import_v415.z.string() })).default([])
|
|
3092
3353
|
})
|
|
3093
3354
|
)
|
|
3094
3355
|
);
|
|
3095
|
-
var googleImageModelOptionsSchema = (0,
|
|
3096
|
-
() => (0,
|
|
3097
|
-
|
|
3098
|
-
personGeneration:
|
|
3099
|
-
aspectRatio:
|
|
3356
|
+
var googleImageModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
|
|
3357
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
3358
|
+
import_v415.z.object({
|
|
3359
|
+
personGeneration: import_v415.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3360
|
+
aspectRatio: import_v415.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
3100
3361
|
/**
|
|
3101
3362
|
* Enable Google Search grounding for Gemini image models. The value is
|
|
3102
3363
|
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
@@ -3112,9 +3373,9 @@ var googleImageModelOptionsSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
3112
3373
|
);
|
|
3113
3374
|
|
|
3114
3375
|
// src/google-generative-ai-video-model.ts
|
|
3115
|
-
var
|
|
3116
|
-
var
|
|
3117
|
-
var
|
|
3376
|
+
var import_provider6 = require("@ai-sdk/provider");
|
|
3377
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
3378
|
+
var import_v416 = require("zod/v4");
|
|
3118
3379
|
function getFirstFrameImage(options) {
|
|
3119
3380
|
var _a, _b;
|
|
3120
3381
|
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
@@ -3148,7 +3409,7 @@ function convertFileToGoogleImage(file, warnings) {
|
|
|
3148
3409
|
});
|
|
3149
3410
|
return void 0;
|
|
3150
3411
|
}
|
|
3151
|
-
const base64Data = typeof file.data === "string" ? file.data : (0,
|
|
3412
|
+
const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils16.convertUint8ArrayToBase64)(file.data);
|
|
3152
3413
|
return {
|
|
3153
3414
|
bytesBase64Encoded: base64Data,
|
|
3154
3415
|
mimeType: file.mediaType || "image/png"
|
|
@@ -3193,7 +3454,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3193
3454
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3194
3455
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3195
3456
|
const warnings = [];
|
|
3196
|
-
const googleOptions = await (0,
|
|
3457
|
+
const googleOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
3197
3458
|
provider: "google",
|
|
3198
3459
|
providerOptions: options.providerOptions,
|
|
3199
3460
|
schema: googleVideoModelOptionsSchema
|
|
@@ -3268,17 +3529,17 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3268
3529
|
}
|
|
3269
3530
|
}
|
|
3270
3531
|
}
|
|
3271
|
-
const { value: operation } = await (0,
|
|
3532
|
+
const { value: operation } = await (0, import_provider_utils16.postJsonToApi)({
|
|
3272
3533
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
3273
|
-
headers: (0,
|
|
3274
|
-
await (0,
|
|
3534
|
+
headers: (0, import_provider_utils16.combineHeaders)(
|
|
3535
|
+
await (0, import_provider_utils16.resolve)(this.config.headers),
|
|
3275
3536
|
options.headers
|
|
3276
3537
|
),
|
|
3277
3538
|
body: {
|
|
3278
3539
|
instances,
|
|
3279
3540
|
parameters
|
|
3280
3541
|
},
|
|
3281
|
-
successfulResponseHandler: (0,
|
|
3542
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3282
3543
|
googleOperationSchema
|
|
3283
3544
|
),
|
|
3284
3545
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3287,7 +3548,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3287
3548
|
});
|
|
3288
3549
|
const operationName = operation.name;
|
|
3289
3550
|
if (!operationName) {
|
|
3290
|
-
throw new
|
|
3551
|
+
throw new import_provider6.AISDKError({
|
|
3291
3552
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
3292
3553
|
message: "No operation name returned from API"
|
|
3293
3554
|
});
|
|
@@ -3299,25 +3560,25 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3299
3560
|
let responseHeaders;
|
|
3300
3561
|
while (!finalOperation.done) {
|
|
3301
3562
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
3302
|
-
throw new
|
|
3563
|
+
throw new import_provider6.AISDKError({
|
|
3303
3564
|
name: "GOOGLE_VIDEO_GENERATION_TIMEOUT",
|
|
3304
3565
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
3305
3566
|
});
|
|
3306
3567
|
}
|
|
3307
|
-
await (0,
|
|
3568
|
+
await (0, import_provider_utils16.delay)(pollIntervalMs);
|
|
3308
3569
|
if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
|
|
3309
|
-
throw new
|
|
3570
|
+
throw new import_provider6.AISDKError({
|
|
3310
3571
|
name: "GOOGLE_VIDEO_GENERATION_ABORTED",
|
|
3311
3572
|
message: "Video generation request was aborted"
|
|
3312
3573
|
});
|
|
3313
3574
|
}
|
|
3314
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await (0,
|
|
3575
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils16.getFromApi)({
|
|
3315
3576
|
url: `${this.config.baseURL}/${operationName}`,
|
|
3316
|
-
headers: (0,
|
|
3317
|
-
await (0,
|
|
3577
|
+
headers: (0, import_provider_utils16.combineHeaders)(
|
|
3578
|
+
await (0, import_provider_utils16.resolve)(this.config.headers),
|
|
3318
3579
|
options.headers
|
|
3319
3580
|
),
|
|
3320
|
-
successfulResponseHandler: (0,
|
|
3581
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3321
3582
|
googleOperationSchema
|
|
3322
3583
|
),
|
|
3323
3584
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3328,25 +3589,25 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3328
3589
|
responseHeaders = pollHeaders;
|
|
3329
3590
|
}
|
|
3330
3591
|
if (finalOperation.error) {
|
|
3331
|
-
throw new
|
|
3592
|
+
throw new import_provider6.AISDKError({
|
|
3332
3593
|
name: "GOOGLE_VIDEO_GENERATION_FAILED",
|
|
3333
3594
|
message: `Video generation failed: ${finalOperation.error.message}`
|
|
3334
3595
|
});
|
|
3335
3596
|
}
|
|
3336
3597
|
const response = finalOperation.response;
|
|
3337
3598
|
if (!((_g = response == null ? void 0 : response.generateVideoResponse) == null ? void 0 : _g.generatedSamples) || response.generateVideoResponse.generatedSamples.length === 0) {
|
|
3338
|
-
throw new
|
|
3599
|
+
throw new import_provider6.AISDKError({
|
|
3339
3600
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
3340
3601
|
message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
|
|
3341
3602
|
});
|
|
3342
3603
|
}
|
|
3343
3604
|
const videos = [];
|
|
3344
3605
|
const videoMetadata = [];
|
|
3345
|
-
const resolvedHeaders = await (0,
|
|
3606
|
+
const resolvedHeaders = await (0, import_provider_utils16.resolve)(this.config.headers);
|
|
3346
3607
|
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
3347
3608
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
3348
3609
|
if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
3349
|
-
const urlWithAuth = apiKey && (0,
|
|
3610
|
+
const urlWithAuth = apiKey && (0, import_provider_utils16.isSameOrigin)(generatedSample.video.uri, this.config.baseURL) ? `${generatedSample.video.uri}${generatedSample.video.uri.includes("?") ? "&" : "?"}key=${apiKey}` : generatedSample.video.uri;
|
|
3350
3611
|
videos.push({
|
|
3351
3612
|
type: "url",
|
|
3352
3613
|
url: urlWithAuth,
|
|
@@ -3358,7 +3619,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3358
3619
|
}
|
|
3359
3620
|
}
|
|
3360
3621
|
if (videos.length === 0) {
|
|
3361
|
-
throw new
|
|
3622
|
+
throw new import_provider6.AISDKError({
|
|
3362
3623
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
3363
3624
|
message: "No valid videos in response"
|
|
3364
3625
|
});
|
|
@@ -3379,37 +3640,37 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3379
3640
|
};
|
|
3380
3641
|
}
|
|
3381
3642
|
};
|
|
3382
|
-
var googleOperationSchema =
|
|
3383
|
-
name:
|
|
3384
|
-
done:
|
|
3385
|
-
error:
|
|
3386
|
-
code:
|
|
3387
|
-
message:
|
|
3388
|
-
status:
|
|
3643
|
+
var googleOperationSchema = import_v416.z.object({
|
|
3644
|
+
name: import_v416.z.string().nullish(),
|
|
3645
|
+
done: import_v416.z.boolean().nullish(),
|
|
3646
|
+
error: import_v416.z.object({
|
|
3647
|
+
code: import_v416.z.number().nullish(),
|
|
3648
|
+
message: import_v416.z.string(),
|
|
3649
|
+
status: import_v416.z.string().nullish()
|
|
3389
3650
|
}).nullish(),
|
|
3390
|
-
response:
|
|
3391
|
-
generateVideoResponse:
|
|
3392
|
-
generatedSamples:
|
|
3393
|
-
|
|
3394
|
-
video:
|
|
3395
|
-
uri:
|
|
3651
|
+
response: import_v416.z.object({
|
|
3652
|
+
generateVideoResponse: import_v416.z.object({
|
|
3653
|
+
generatedSamples: import_v416.z.array(
|
|
3654
|
+
import_v416.z.object({
|
|
3655
|
+
video: import_v416.z.object({
|
|
3656
|
+
uri: import_v416.z.string().nullish()
|
|
3396
3657
|
}).nullish()
|
|
3397
3658
|
})
|
|
3398
3659
|
).nullish()
|
|
3399
3660
|
}).nullish()
|
|
3400
3661
|
}).nullish()
|
|
3401
3662
|
});
|
|
3402
|
-
var googleVideoModelOptionsSchema = (0,
|
|
3403
|
-
() => (0,
|
|
3404
|
-
|
|
3405
|
-
pollIntervalMs:
|
|
3406
|
-
pollTimeoutMs:
|
|
3407
|
-
personGeneration:
|
|
3408
|
-
negativePrompt:
|
|
3409
|
-
referenceImages:
|
|
3410
|
-
|
|
3411
|
-
bytesBase64Encoded:
|
|
3412
|
-
gcsUri:
|
|
3663
|
+
var googleVideoModelOptionsSchema = (0, import_provider_utils16.lazySchema)(
|
|
3664
|
+
() => (0, import_provider_utils16.zodSchema)(
|
|
3665
|
+
import_v416.z.object({
|
|
3666
|
+
pollIntervalMs: import_v416.z.number().positive().nullish(),
|
|
3667
|
+
pollTimeoutMs: import_v416.z.number().positive().nullish(),
|
|
3668
|
+
personGeneration: import_v416.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
3669
|
+
negativePrompt: import_v416.z.string().nullish(),
|
|
3670
|
+
referenceImages: import_v416.z.array(
|
|
3671
|
+
import_v416.z.object({
|
|
3672
|
+
bytesBase64Encoded: import_v416.z.string().nullish(),
|
|
3673
|
+
gcsUri: import_v416.z.string().nullish()
|
|
3413
3674
|
})
|
|
3414
3675
|
).nullish()
|
|
3415
3676
|
}).passthrough()
|
|
@@ -3417,7 +3678,7 @@ var googleVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
|
|
|
3417
3678
|
);
|
|
3418
3679
|
|
|
3419
3680
|
// src/interactions/google-interactions-language-model.ts
|
|
3420
|
-
var
|
|
3681
|
+
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
3421
3682
|
|
|
3422
3683
|
// src/interactions/convert-google-interactions-usage.ts
|
|
3423
3684
|
function convertGoogleInteractionsUsage(usage) {
|
|
@@ -4183,7 +4444,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4183
4444
|
}
|
|
4184
4445
|
|
|
4185
4446
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
4186
|
-
var
|
|
4447
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
4187
4448
|
function getTopLevelMediaType(mediaType) {
|
|
4188
4449
|
const slashIndex = mediaType.indexOf("/");
|
|
4189
4450
|
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
|
|
@@ -4372,7 +4633,7 @@ function convertFilePartToContent({
|
|
|
4372
4633
|
}
|
|
4373
4634
|
return {
|
|
4374
4635
|
type: kind,
|
|
4375
|
-
data: (0,
|
|
4636
|
+
data: (0, import_provider_utils17.convertToBase64)(part.data),
|
|
4376
4637
|
mime_type: part.mediaType,
|
|
4377
4638
|
...resolutionField
|
|
4378
4639
|
};
|
|
@@ -4423,7 +4684,7 @@ function compactPromptForPreviousInteraction({
|
|
|
4423
4684
|
}
|
|
4424
4685
|
function safeParseToolArgs(input) {
|
|
4425
4686
|
try {
|
|
4426
|
-
const parsed = (0,
|
|
4687
|
+
const parsed = (0, import_provider_utils17.secureJsonParse)(input);
|
|
4427
4688
|
if (parsed != null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
4428
4689
|
return parsed;
|
|
4429
4690
|
}
|
|
@@ -4546,7 +4807,7 @@ function filePartToImageBlock({
|
|
|
4546
4807
|
}
|
|
4547
4808
|
return {
|
|
4548
4809
|
type: "image",
|
|
4549
|
-
data: (0,
|
|
4810
|
+
data: (0, import_provider_utils17.convertToBase64)(part.data),
|
|
4550
4811
|
mime_type: part.mediaType
|
|
4551
4812
|
};
|
|
4552
4813
|
}
|
|
@@ -4573,31 +4834,31 @@ ${block.text}`
|
|
|
4573
4834
|
}
|
|
4574
4835
|
|
|
4575
4836
|
// src/interactions/google-interactions-api.ts
|
|
4576
|
-
var
|
|
4577
|
-
var
|
|
4578
|
-
var tokenByModalitySchema = () =>
|
|
4579
|
-
modality:
|
|
4580
|
-
tokens:
|
|
4837
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
4838
|
+
var import_v417 = require("zod/v4");
|
|
4839
|
+
var tokenByModalitySchema = () => import_v417.z.object({
|
|
4840
|
+
modality: import_v417.z.string().nullish(),
|
|
4841
|
+
tokens: import_v417.z.number().nullish()
|
|
4581
4842
|
}).loose();
|
|
4582
|
-
var usageSchema2 = () =>
|
|
4583
|
-
total_input_tokens:
|
|
4584
|
-
total_output_tokens:
|
|
4585
|
-
total_thought_tokens:
|
|
4586
|
-
total_cached_tokens:
|
|
4587
|
-
total_tool_use_tokens:
|
|
4588
|
-
total_tokens:
|
|
4589
|
-
input_tokens_by_modality:
|
|
4590
|
-
output_tokens_by_modality:
|
|
4591
|
-
cached_tokens_by_modality:
|
|
4592
|
-
tool_use_tokens_by_modality:
|
|
4593
|
-
grounding_tool_count:
|
|
4594
|
-
|
|
4595
|
-
type:
|
|
4596
|
-
count:
|
|
4843
|
+
var usageSchema2 = () => import_v417.z.object({
|
|
4844
|
+
total_input_tokens: import_v417.z.number().nullish(),
|
|
4845
|
+
total_output_tokens: import_v417.z.number().nullish(),
|
|
4846
|
+
total_thought_tokens: import_v417.z.number().nullish(),
|
|
4847
|
+
total_cached_tokens: import_v417.z.number().nullish(),
|
|
4848
|
+
total_tool_use_tokens: import_v417.z.number().nullish(),
|
|
4849
|
+
total_tokens: import_v417.z.number().nullish(),
|
|
4850
|
+
input_tokens_by_modality: import_v417.z.array(tokenByModalitySchema()).nullish(),
|
|
4851
|
+
output_tokens_by_modality: import_v417.z.array(tokenByModalitySchema()).nullish(),
|
|
4852
|
+
cached_tokens_by_modality: import_v417.z.array(tokenByModalitySchema()).nullish(),
|
|
4853
|
+
tool_use_tokens_by_modality: import_v417.z.array(tokenByModalitySchema()).nullish(),
|
|
4854
|
+
grounding_tool_count: import_v417.z.array(
|
|
4855
|
+
import_v417.z.object({
|
|
4856
|
+
type: import_v417.z.string().nullish(),
|
|
4857
|
+
count: import_v417.z.number().nullish()
|
|
4597
4858
|
}).loose()
|
|
4598
4859
|
).nullish()
|
|
4599
4860
|
}).loose();
|
|
4600
|
-
var interactionStatusSchema = () =>
|
|
4861
|
+
var interactionStatusSchema = () => import_v417.z.enum([
|
|
4601
4862
|
"in_progress",
|
|
4602
4863
|
"requires_action",
|
|
4603
4864
|
"completed",
|
|
@@ -4606,69 +4867,69 @@ var interactionStatusSchema = () => import_v415.z.enum([
|
|
|
4606
4867
|
"incomplete"
|
|
4607
4868
|
]);
|
|
4608
4869
|
var annotationSchema = () => {
|
|
4609
|
-
const urlCitation =
|
|
4610
|
-
type:
|
|
4611
|
-
url:
|
|
4612
|
-
title:
|
|
4613
|
-
start_index:
|
|
4614
|
-
end_index:
|
|
4870
|
+
const urlCitation = import_v417.z.object({
|
|
4871
|
+
type: import_v417.z.literal("url_citation"),
|
|
4872
|
+
url: import_v417.z.string().nullish(),
|
|
4873
|
+
title: import_v417.z.string().nullish(),
|
|
4874
|
+
start_index: import_v417.z.number().nullish(),
|
|
4875
|
+
end_index: import_v417.z.number().nullish()
|
|
4615
4876
|
}).loose();
|
|
4616
|
-
const fileCitation =
|
|
4617
|
-
type:
|
|
4618
|
-
file_name:
|
|
4619
|
-
document_uri:
|
|
4620
|
-
url:
|
|
4621
|
-
page_number:
|
|
4622
|
-
media_id:
|
|
4623
|
-
start_index:
|
|
4624
|
-
end_index:
|
|
4625
|
-
custom_metadata:
|
|
4877
|
+
const fileCitation = import_v417.z.object({
|
|
4878
|
+
type: import_v417.z.literal("file_citation"),
|
|
4879
|
+
file_name: import_v417.z.string().nullish(),
|
|
4880
|
+
document_uri: import_v417.z.string().nullish(),
|
|
4881
|
+
url: import_v417.z.string().nullish(),
|
|
4882
|
+
page_number: import_v417.z.number().nullish(),
|
|
4883
|
+
media_id: import_v417.z.string().nullish(),
|
|
4884
|
+
start_index: import_v417.z.number().nullish(),
|
|
4885
|
+
end_index: import_v417.z.number().nullish(),
|
|
4886
|
+
custom_metadata: import_v417.z.record(import_v417.z.string(), import_v417.z.unknown()).nullish()
|
|
4626
4887
|
}).loose();
|
|
4627
|
-
const placeCitation =
|
|
4628
|
-
type:
|
|
4629
|
-
name:
|
|
4630
|
-
url:
|
|
4631
|
-
place_id:
|
|
4632
|
-
start_index:
|
|
4633
|
-
end_index:
|
|
4888
|
+
const placeCitation = import_v417.z.object({
|
|
4889
|
+
type: import_v417.z.literal("place_citation"),
|
|
4890
|
+
name: import_v417.z.string().nullish(),
|
|
4891
|
+
url: import_v417.z.string().nullish(),
|
|
4892
|
+
place_id: import_v417.z.string().nullish(),
|
|
4893
|
+
start_index: import_v417.z.number().nullish(),
|
|
4894
|
+
end_index: import_v417.z.number().nullish()
|
|
4634
4895
|
}).loose();
|
|
4635
|
-
return
|
|
4896
|
+
return import_v417.z.union([
|
|
4636
4897
|
urlCitation,
|
|
4637
4898
|
fileCitation,
|
|
4638
4899
|
placeCitation,
|
|
4639
|
-
|
|
4900
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
4640
4901
|
]);
|
|
4641
4902
|
};
|
|
4642
|
-
var thoughtSummaryItemSchema = () =>
|
|
4643
|
-
type:
|
|
4644
|
-
text:
|
|
4645
|
-
data:
|
|
4646
|
-
mime_type:
|
|
4903
|
+
var thoughtSummaryItemSchema = () => import_v417.z.object({
|
|
4904
|
+
type: import_v417.z.string(),
|
|
4905
|
+
text: import_v417.z.string().nullish(),
|
|
4906
|
+
data: import_v417.z.string().nullish(),
|
|
4907
|
+
mime_type: import_v417.z.string().nullish()
|
|
4647
4908
|
}).loose();
|
|
4648
4909
|
var contentBlockSchema = () => {
|
|
4649
|
-
const textContent =
|
|
4650
|
-
type:
|
|
4651
|
-
text:
|
|
4652
|
-
annotations:
|
|
4910
|
+
const textContent = import_v417.z.object({
|
|
4911
|
+
type: import_v417.z.literal("text"),
|
|
4912
|
+
text: import_v417.z.string(),
|
|
4913
|
+
annotations: import_v417.z.array(annotationSchema()).nullish()
|
|
4653
4914
|
}).loose();
|
|
4654
|
-
const imageContent =
|
|
4655
|
-
type:
|
|
4656
|
-
data:
|
|
4657
|
-
mime_type:
|
|
4658
|
-
resolution:
|
|
4659
|
-
uri:
|
|
4915
|
+
const imageContent = import_v417.z.object({
|
|
4916
|
+
type: import_v417.z.literal("image"),
|
|
4917
|
+
data: import_v417.z.string().nullish(),
|
|
4918
|
+
mime_type: import_v417.z.string().nullish(),
|
|
4919
|
+
resolution: import_v417.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4920
|
+
uri: import_v417.z.string().nullish()
|
|
4660
4921
|
}).loose();
|
|
4661
|
-
const videoContent =
|
|
4662
|
-
type:
|
|
4663
|
-
data:
|
|
4664
|
-
mime_type:
|
|
4665
|
-
uri:
|
|
4922
|
+
const videoContent = import_v417.z.object({
|
|
4923
|
+
type: import_v417.z.literal("video"),
|
|
4924
|
+
data: import_v417.z.string().nullish(),
|
|
4925
|
+
mime_type: import_v417.z.string().nullish(),
|
|
4926
|
+
uri: import_v417.z.string().nullish()
|
|
4666
4927
|
}).loose();
|
|
4667
|
-
return
|
|
4928
|
+
return import_v417.z.union([
|
|
4668
4929
|
textContent,
|
|
4669
4930
|
imageContent,
|
|
4670
4931
|
videoContent,
|
|
4671
|
-
|
|
4932
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
4672
4933
|
]);
|
|
4673
4934
|
};
|
|
4674
4935
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4688,158 +4949,158 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4688
4949
|
"mcp_server_tool_result"
|
|
4689
4950
|
];
|
|
4690
4951
|
var stepSchema = () => {
|
|
4691
|
-
const userInputStep =
|
|
4692
|
-
type:
|
|
4693
|
-
content:
|
|
4952
|
+
const userInputStep = import_v417.z.object({
|
|
4953
|
+
type: import_v417.z.literal("user_input"),
|
|
4954
|
+
content: import_v417.z.array(contentBlockSchema()).nullish()
|
|
4694
4955
|
}).loose();
|
|
4695
|
-
const modelOutputStep =
|
|
4696
|
-
type:
|
|
4697
|
-
content:
|
|
4956
|
+
const modelOutputStep = import_v417.z.object({
|
|
4957
|
+
type: import_v417.z.literal("model_output"),
|
|
4958
|
+
content: import_v417.z.array(contentBlockSchema()).nullish()
|
|
4698
4959
|
}).loose();
|
|
4699
|
-
const functionCallStep =
|
|
4700
|
-
type:
|
|
4701
|
-
id:
|
|
4702
|
-
name:
|
|
4703
|
-
arguments:
|
|
4704
|
-
signature:
|
|
4960
|
+
const functionCallStep = import_v417.z.object({
|
|
4961
|
+
type: import_v417.z.literal("function_call"),
|
|
4962
|
+
id: import_v417.z.string(),
|
|
4963
|
+
name: import_v417.z.string(),
|
|
4964
|
+
arguments: import_v417.z.record(import_v417.z.string(), import_v417.z.unknown()).nullish(),
|
|
4965
|
+
signature: import_v417.z.string().nullish()
|
|
4705
4966
|
}).loose();
|
|
4706
|
-
const thoughtStep =
|
|
4707
|
-
type:
|
|
4708
|
-
signature:
|
|
4709
|
-
summary:
|
|
4967
|
+
const thoughtStep = import_v417.z.object({
|
|
4968
|
+
type: import_v417.z.literal("thought"),
|
|
4969
|
+
signature: import_v417.z.string().nullish(),
|
|
4970
|
+
summary: import_v417.z.array(thoughtSummaryItemSchema()).nullish()
|
|
4710
4971
|
}).loose();
|
|
4711
|
-
const builtinToolCallStep =
|
|
4712
|
-
type:
|
|
4713
|
-
id:
|
|
4714
|
-
arguments:
|
|
4715
|
-
name:
|
|
4716
|
-
server_name:
|
|
4717
|
-
search_type:
|
|
4718
|
-
signature:
|
|
4972
|
+
const builtinToolCallStep = import_v417.z.object({
|
|
4973
|
+
type: import_v417.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4974
|
+
id: import_v417.z.string(),
|
|
4975
|
+
arguments: import_v417.z.record(import_v417.z.string(), import_v417.z.unknown()).nullish(),
|
|
4976
|
+
name: import_v417.z.string().nullish(),
|
|
4977
|
+
server_name: import_v417.z.string().nullish(),
|
|
4978
|
+
search_type: import_v417.z.string().nullish(),
|
|
4979
|
+
signature: import_v417.z.string().nullish()
|
|
4719
4980
|
}).loose();
|
|
4720
|
-
const builtinToolResultStep =
|
|
4721
|
-
type:
|
|
4722
|
-
call_id:
|
|
4723
|
-
result:
|
|
4724
|
-
is_error:
|
|
4725
|
-
name:
|
|
4726
|
-
server_name:
|
|
4727
|
-
signature:
|
|
4981
|
+
const builtinToolResultStep = import_v417.z.object({
|
|
4982
|
+
type: import_v417.z.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4983
|
+
call_id: import_v417.z.string(),
|
|
4984
|
+
result: import_v417.z.unknown().nullish(),
|
|
4985
|
+
is_error: import_v417.z.boolean().nullish(),
|
|
4986
|
+
name: import_v417.z.string().nullish(),
|
|
4987
|
+
server_name: import_v417.z.string().nullish(),
|
|
4988
|
+
signature: import_v417.z.string().nullish()
|
|
4728
4989
|
}).loose();
|
|
4729
|
-
return
|
|
4990
|
+
return import_v417.z.union([
|
|
4730
4991
|
userInputStep,
|
|
4731
4992
|
modelOutputStep,
|
|
4732
4993
|
functionCallStep,
|
|
4733
4994
|
thoughtStep,
|
|
4734
4995
|
builtinToolCallStep,
|
|
4735
4996
|
builtinToolResultStep,
|
|
4736
|
-
|
|
4997
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
4737
4998
|
]);
|
|
4738
4999
|
};
|
|
4739
|
-
var googleInteractionsResponseSchema = (0,
|
|
4740
|
-
() => (0,
|
|
4741
|
-
|
|
5000
|
+
var googleInteractionsResponseSchema = (0, import_provider_utils18.lazySchema)(
|
|
5001
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
5002
|
+
import_v417.z.object({
|
|
4742
5003
|
/*
|
|
4743
5004
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4744
5005
|
* stateless mode) — there is no server-side interaction record for the
|
|
4745
5006
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4746
5007
|
*/
|
|
4747
|
-
id:
|
|
4748
|
-
created:
|
|
4749
|
-
updated:
|
|
5008
|
+
id: import_v417.z.string().nullish(),
|
|
5009
|
+
created: import_v417.z.string().nullish(),
|
|
5010
|
+
updated: import_v417.z.string().nullish(),
|
|
4750
5011
|
status: interactionStatusSchema(),
|
|
4751
|
-
model:
|
|
4752
|
-
agent:
|
|
4753
|
-
steps:
|
|
5012
|
+
model: import_v417.z.string().nullish(),
|
|
5013
|
+
agent: import_v417.z.string().nullish(),
|
|
5014
|
+
steps: import_v417.z.array(stepSchema()).nullish(),
|
|
4754
5015
|
usage: usageSchema2().nullish(),
|
|
4755
|
-
service_tier:
|
|
4756
|
-
previous_interaction_id:
|
|
4757
|
-
response_modalities:
|
|
5016
|
+
service_tier: import_v417.z.string().nullish(),
|
|
5017
|
+
previous_interaction_id: import_v417.z.string().nullish(),
|
|
5018
|
+
response_modalities: import_v417.z.array(import_v417.z.string()).nullish()
|
|
4758
5019
|
}).loose()
|
|
4759
5020
|
)
|
|
4760
5021
|
);
|
|
4761
|
-
var googleInteractionsEventSchema = (0,
|
|
4762
|
-
() => (0,
|
|
5022
|
+
var googleInteractionsEventSchema = (0, import_provider_utils18.lazySchema)(
|
|
5023
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
4763
5024
|
(() => {
|
|
4764
5025
|
const status = interactionStatusSchema();
|
|
4765
5026
|
const annotation = annotationSchema();
|
|
4766
5027
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4767
|
-
const interactionCreatedEvent =
|
|
4768
|
-
event_type:
|
|
4769
|
-
event_id:
|
|
4770
|
-
interaction:
|
|
5028
|
+
const interactionCreatedEvent = import_v417.z.object({
|
|
5029
|
+
event_type: import_v417.z.literal("interaction.created"),
|
|
5030
|
+
event_id: import_v417.z.string().nullish(),
|
|
5031
|
+
interaction: import_v417.z.object({
|
|
4771
5032
|
/*
|
|
4772
5033
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4773
5034
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4774
5035
|
*/
|
|
4775
|
-
id:
|
|
4776
|
-
created:
|
|
4777
|
-
model:
|
|
4778
|
-
agent:
|
|
5036
|
+
id: import_v417.z.string().nullish(),
|
|
5037
|
+
created: import_v417.z.string().nullish(),
|
|
5038
|
+
model: import_v417.z.string().nullish(),
|
|
5039
|
+
agent: import_v417.z.string().nullish(),
|
|
4779
5040
|
status: status.nullish()
|
|
4780
5041
|
}).loose()
|
|
4781
5042
|
}).loose();
|
|
4782
|
-
const stepStartEvent =
|
|
4783
|
-
event_type:
|
|
4784
|
-
event_id:
|
|
4785
|
-
index:
|
|
5043
|
+
const stepStartEvent = import_v417.z.object({
|
|
5044
|
+
event_type: import_v417.z.literal("step.start"),
|
|
5045
|
+
event_id: import_v417.z.string().nullish(),
|
|
5046
|
+
index: import_v417.z.number(),
|
|
4786
5047
|
step: stepSchema()
|
|
4787
5048
|
}).loose();
|
|
4788
|
-
const stepDeltaText =
|
|
4789
|
-
type:
|
|
4790
|
-
text:
|
|
5049
|
+
const stepDeltaText = import_v417.z.object({
|
|
5050
|
+
type: import_v417.z.literal("text"),
|
|
5051
|
+
text: import_v417.z.string()
|
|
4791
5052
|
}).loose();
|
|
4792
|
-
const stepDeltaThoughtSummary =
|
|
4793
|
-
type:
|
|
5053
|
+
const stepDeltaThoughtSummary = import_v417.z.object({
|
|
5054
|
+
type: import_v417.z.literal("thought_summary"),
|
|
4794
5055
|
content: thoughtSummaryItem.nullish()
|
|
4795
5056
|
}).loose();
|
|
4796
|
-
const stepDeltaThoughtSignature =
|
|
4797
|
-
type:
|
|
4798
|
-
signature:
|
|
5057
|
+
const stepDeltaThoughtSignature = import_v417.z.object({
|
|
5058
|
+
type: import_v417.z.literal("thought_signature"),
|
|
5059
|
+
signature: import_v417.z.string().nullish()
|
|
4799
5060
|
}).loose();
|
|
4800
|
-
const stepDeltaArgumentsDelta =
|
|
4801
|
-
type:
|
|
4802
|
-
arguments:
|
|
4803
|
-
id:
|
|
4804
|
-
signature:
|
|
5061
|
+
const stepDeltaArgumentsDelta = import_v417.z.object({
|
|
5062
|
+
type: import_v417.z.literal("arguments_delta"),
|
|
5063
|
+
arguments: import_v417.z.string().nullish(),
|
|
5064
|
+
id: import_v417.z.string().nullish(),
|
|
5065
|
+
signature: import_v417.z.string().nullish()
|
|
4805
5066
|
}).loose();
|
|
4806
|
-
const stepDeltaTextAnnotation =
|
|
4807
|
-
type:
|
|
4808
|
-
annotations:
|
|
5067
|
+
const stepDeltaTextAnnotation = import_v417.z.object({
|
|
5068
|
+
type: import_v417.z.enum(["text_annotation_delta", "text_annotation"]),
|
|
5069
|
+
annotations: import_v417.z.array(annotation).nullish()
|
|
4809
5070
|
}).loose();
|
|
4810
|
-
const stepDeltaImage =
|
|
4811
|
-
type:
|
|
4812
|
-
data:
|
|
4813
|
-
mime_type:
|
|
4814
|
-
resolution:
|
|
4815
|
-
uri:
|
|
5071
|
+
const stepDeltaImage = import_v417.z.object({
|
|
5072
|
+
type: import_v417.z.literal("image"),
|
|
5073
|
+
data: import_v417.z.string().nullish(),
|
|
5074
|
+
mime_type: import_v417.z.string().nullish(),
|
|
5075
|
+
resolution: import_v417.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5076
|
+
uri: import_v417.z.string().nullish()
|
|
4816
5077
|
}).loose();
|
|
4817
|
-
const stepDeltaVideo =
|
|
4818
|
-
type:
|
|
4819
|
-
data:
|
|
4820
|
-
mime_type:
|
|
4821
|
-
uri:
|
|
5078
|
+
const stepDeltaVideo = import_v417.z.object({
|
|
5079
|
+
type: import_v417.z.literal("video"),
|
|
5080
|
+
data: import_v417.z.string().nullish(),
|
|
5081
|
+
mime_type: import_v417.z.string().nullish(),
|
|
5082
|
+
uri: import_v417.z.string().nullish()
|
|
4822
5083
|
}).loose();
|
|
4823
|
-
const stepDeltaBuiltinToolCall =
|
|
4824
|
-
type:
|
|
4825
|
-
id:
|
|
4826
|
-
arguments:
|
|
4827
|
-
name:
|
|
4828
|
-
server_name:
|
|
4829
|
-
search_type:
|
|
4830
|
-
signature:
|
|
5084
|
+
const stepDeltaBuiltinToolCall = import_v417.z.object({
|
|
5085
|
+
type: import_v417.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5086
|
+
id: import_v417.z.string().nullish(),
|
|
5087
|
+
arguments: import_v417.z.record(import_v417.z.string(), import_v417.z.unknown()).nullish(),
|
|
5088
|
+
name: import_v417.z.string().nullish(),
|
|
5089
|
+
server_name: import_v417.z.string().nullish(),
|
|
5090
|
+
search_type: import_v417.z.string().nullish(),
|
|
5091
|
+
signature: import_v417.z.string().nullish()
|
|
4831
5092
|
}).loose();
|
|
4832
|
-
const stepDeltaBuiltinToolResult =
|
|
4833
|
-
type:
|
|
4834
|
-
call_id:
|
|
4835
|
-
result:
|
|
4836
|
-
is_error:
|
|
4837
|
-
name:
|
|
4838
|
-
server_name:
|
|
4839
|
-
signature:
|
|
5093
|
+
const stepDeltaBuiltinToolResult = import_v417.z.object({
|
|
5094
|
+
type: import_v417.z.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5095
|
+
call_id: import_v417.z.string().nullish(),
|
|
5096
|
+
result: import_v417.z.unknown().nullish(),
|
|
5097
|
+
is_error: import_v417.z.boolean().nullish(),
|
|
5098
|
+
name: import_v417.z.string().nullish(),
|
|
5099
|
+
server_name: import_v417.z.string().nullish(),
|
|
5100
|
+
signature: import_v417.z.string().nullish()
|
|
4840
5101
|
}).loose();
|
|
4841
|
-
const stepDeltaUnknown =
|
|
4842
|
-
const stepDeltaUnion =
|
|
5102
|
+
const stepDeltaUnknown = import_v417.z.object({ type: import_v417.z.string() }).loose();
|
|
5103
|
+
const stepDeltaUnion = import_v417.z.union([
|
|
4843
5104
|
stepDeltaText,
|
|
4844
5105
|
stepDeltaImage,
|
|
4845
5106
|
stepDeltaVideo,
|
|
@@ -4851,55 +5112,55 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4851
5112
|
stepDeltaBuiltinToolResult,
|
|
4852
5113
|
stepDeltaUnknown
|
|
4853
5114
|
]);
|
|
4854
|
-
const stepDeltaEvent =
|
|
4855
|
-
event_type:
|
|
4856
|
-
event_id:
|
|
4857
|
-
index:
|
|
5115
|
+
const stepDeltaEvent = import_v417.z.object({
|
|
5116
|
+
event_type: import_v417.z.literal("step.delta"),
|
|
5117
|
+
event_id: import_v417.z.string().nullish(),
|
|
5118
|
+
index: import_v417.z.number(),
|
|
4858
5119
|
delta: stepDeltaUnion
|
|
4859
5120
|
}).loose();
|
|
4860
|
-
const stepStopEvent =
|
|
4861
|
-
event_type:
|
|
4862
|
-
event_id:
|
|
4863
|
-
index:
|
|
5121
|
+
const stepStopEvent = import_v417.z.object({
|
|
5122
|
+
event_type: import_v417.z.literal("step.stop"),
|
|
5123
|
+
event_id: import_v417.z.string().nullish(),
|
|
5124
|
+
index: import_v417.z.number()
|
|
4864
5125
|
}).loose();
|
|
4865
|
-
const interactionStatusUpdateEvent =
|
|
4866
|
-
event_type:
|
|
4867
|
-
event_id:
|
|
4868
|
-
interaction_id:
|
|
5126
|
+
const interactionStatusUpdateEvent = import_v417.z.object({
|
|
5127
|
+
event_type: import_v417.z.literal("interaction.status_update"),
|
|
5128
|
+
event_id: import_v417.z.string().nullish(),
|
|
5129
|
+
interaction_id: import_v417.z.string().nullish(),
|
|
4869
5130
|
status: status.nullish()
|
|
4870
5131
|
}).loose();
|
|
4871
|
-
const interactionInProgressEvent =
|
|
4872
|
-
event_type:
|
|
4873
|
-
event_id:
|
|
4874
|
-
interaction_id:
|
|
5132
|
+
const interactionInProgressEvent = import_v417.z.object({
|
|
5133
|
+
event_type: import_v417.z.literal("interaction.in_progress"),
|
|
5134
|
+
event_id: import_v417.z.string().nullish(),
|
|
5135
|
+
interaction_id: import_v417.z.string().nullish(),
|
|
4875
5136
|
status: status.nullish()
|
|
4876
5137
|
}).loose();
|
|
4877
|
-
const interactionRequiresActionEvent =
|
|
4878
|
-
event_type:
|
|
4879
|
-
event_id:
|
|
4880
|
-
interaction_id:
|
|
5138
|
+
const interactionRequiresActionEvent = import_v417.z.object({
|
|
5139
|
+
event_type: import_v417.z.literal("interaction.requires_action"),
|
|
5140
|
+
event_id: import_v417.z.string().nullish(),
|
|
5141
|
+
interaction_id: import_v417.z.string().nullish(),
|
|
4881
5142
|
status: status.nullish()
|
|
4882
5143
|
}).loose();
|
|
4883
|
-
const interactionCompletedEvent =
|
|
4884
|
-
event_type:
|
|
4885
|
-
event_id:
|
|
4886
|
-
interaction:
|
|
4887
|
-
id:
|
|
5144
|
+
const interactionCompletedEvent = import_v417.z.object({
|
|
5145
|
+
event_type: import_v417.z.literal("interaction.completed"),
|
|
5146
|
+
event_id: import_v417.z.string().nullish(),
|
|
5147
|
+
interaction: import_v417.z.object({
|
|
5148
|
+
id: import_v417.z.string().nullish(),
|
|
4888
5149
|
status: status.nullish(),
|
|
4889
5150
|
usage: usageSchema2().nullish(),
|
|
4890
|
-
service_tier:
|
|
5151
|
+
service_tier: import_v417.z.string().nullish()
|
|
4891
5152
|
}).loose()
|
|
4892
5153
|
}).loose();
|
|
4893
|
-
const errorEvent =
|
|
4894
|
-
event_type:
|
|
4895
|
-
event_id:
|
|
4896
|
-
error:
|
|
4897
|
-
code:
|
|
4898
|
-
message:
|
|
5154
|
+
const errorEvent = import_v417.z.object({
|
|
5155
|
+
event_type: import_v417.z.literal("error"),
|
|
5156
|
+
event_id: import_v417.z.string().nullish(),
|
|
5157
|
+
error: import_v417.z.object({
|
|
5158
|
+
code: import_v417.z.string().nullish(),
|
|
5159
|
+
message: import_v417.z.string().nullish()
|
|
4899
5160
|
}).loose().nullish()
|
|
4900
5161
|
}).loose();
|
|
4901
|
-
const unknownEvent =
|
|
4902
|
-
return
|
|
5162
|
+
const unknownEvent = import_v417.z.object({ event_type: import_v417.z.string() }).loose();
|
|
5163
|
+
return import_v417.z.union([
|
|
4903
5164
|
interactionCreatedEvent,
|
|
4904
5165
|
stepStartEvent,
|
|
4905
5166
|
stepDeltaEvent,
|
|
@@ -4916,27 +5177,27 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4916
5177
|
);
|
|
4917
5178
|
|
|
4918
5179
|
// src/interactions/google-interactions-language-model-options.ts
|
|
4919
|
-
var
|
|
4920
|
-
var
|
|
4921
|
-
var googleInteractionsLanguageModelOptions = (0,
|
|
4922
|
-
() => (0,
|
|
4923
|
-
|
|
4924
|
-
previousInteractionId:
|
|
4925
|
-
store:
|
|
4926
|
-
agent:
|
|
4927
|
-
agentConfig:
|
|
4928
|
-
|
|
4929
|
-
type:
|
|
5180
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
|
5181
|
+
var import_v418 = require("zod/v4");
|
|
5182
|
+
var googleInteractionsLanguageModelOptions = (0, import_provider_utils19.lazySchema)(
|
|
5183
|
+
() => (0, import_provider_utils19.zodSchema)(
|
|
5184
|
+
import_v418.z.object({
|
|
5185
|
+
previousInteractionId: import_v418.z.string().nullish(),
|
|
5186
|
+
store: import_v418.z.boolean().nullish(),
|
|
5187
|
+
agent: import_v418.z.string().nullish(),
|
|
5188
|
+
agentConfig: import_v418.z.union([
|
|
5189
|
+
import_v418.z.object({
|
|
5190
|
+
type: import_v418.z.literal("dynamic")
|
|
4930
5191
|
}).loose(),
|
|
4931
|
-
|
|
4932
|
-
type:
|
|
4933
|
-
thinkingSummaries:
|
|
4934
|
-
visualization:
|
|
4935
|
-
collaborativePlanning:
|
|
5192
|
+
import_v418.z.object({
|
|
5193
|
+
type: import_v418.z.literal("deep-research"),
|
|
5194
|
+
thinkingSummaries: import_v418.z.enum(["auto", "none"]).nullish(),
|
|
5195
|
+
visualization: import_v418.z.enum(["off", "auto"]).nullish(),
|
|
5196
|
+
collaborativePlanning: import_v418.z.boolean().nullish()
|
|
4936
5197
|
})
|
|
4937
5198
|
]).nullish(),
|
|
4938
|
-
thinkingLevel:
|
|
4939
|
-
thinkingSummaries:
|
|
5199
|
+
thinkingLevel: import_v418.z.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5200
|
+
thinkingSummaries: import_v418.z.enum(["auto", "none"]).nullish(),
|
|
4940
5201
|
/**
|
|
4941
5202
|
* Output-format entries that map directly to the API's `response_format`
|
|
4942
5203
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -4946,17 +5207,17 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4946
5207
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
4947
5208
|
* text entry automatically; entries listed here are appended.
|
|
4948
5209
|
*/
|
|
4949
|
-
responseFormat:
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
type:
|
|
4953
|
-
mimeType:
|
|
4954
|
-
schema:
|
|
5210
|
+
responseFormat: import_v418.z.array(
|
|
5211
|
+
import_v418.z.union([
|
|
5212
|
+
import_v418.z.object({
|
|
5213
|
+
type: import_v418.z.literal("text"),
|
|
5214
|
+
mimeType: import_v418.z.string().nullish(),
|
|
5215
|
+
schema: import_v418.z.unknown().nullish()
|
|
4955
5216
|
}).loose(),
|
|
4956
|
-
|
|
4957
|
-
type:
|
|
4958
|
-
mimeType:
|
|
4959
|
-
aspectRatio:
|
|
5217
|
+
import_v418.z.object({
|
|
5218
|
+
type: import_v418.z.literal("image"),
|
|
5219
|
+
mimeType: import_v418.z.string().nullish(),
|
|
5220
|
+
aspectRatio: import_v418.z.enum([
|
|
4960
5221
|
"1:1",
|
|
4961
5222
|
"2:3",
|
|
4962
5223
|
"3:2",
|
|
@@ -4972,11 +5233,11 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4972
5233
|
"1:4",
|
|
4973
5234
|
"4:1"
|
|
4974
5235
|
]).nullish(),
|
|
4975
|
-
imageSize:
|
|
5236
|
+
imageSize: import_v418.z.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
4976
5237
|
}).loose(),
|
|
4977
|
-
|
|
4978
|
-
type:
|
|
4979
|
-
mimeType:
|
|
5238
|
+
import_v418.z.object({
|
|
5239
|
+
type: import_v418.z.literal("audio"),
|
|
5240
|
+
mimeType: import_v418.z.string().nullish()
|
|
4980
5241
|
}).loose()
|
|
4981
5242
|
])
|
|
4982
5243
|
).nullish(),
|
|
@@ -4986,8 +5247,8 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4986
5247
|
* translates it into a matching `response_format` image entry and
|
|
4987
5248
|
* emits a warning when set.
|
|
4988
5249
|
*/
|
|
4989
|
-
imageConfig:
|
|
4990
|
-
aspectRatio:
|
|
5250
|
+
imageConfig: import_v418.z.object({
|
|
5251
|
+
aspectRatio: import_v418.z.enum([
|
|
4991
5252
|
"1:1",
|
|
4992
5253
|
"2:3",
|
|
4993
5254
|
"3:2",
|
|
@@ -5003,35 +5264,35 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5003
5264
|
"1:4",
|
|
5004
5265
|
"4:1"
|
|
5005
5266
|
]).nullish(),
|
|
5006
|
-
imageSize:
|
|
5267
|
+
imageSize: import_v418.z.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5007
5268
|
}).nullish(),
|
|
5008
|
-
mediaResolution:
|
|
5009
|
-
responseModalities:
|
|
5010
|
-
serviceTier:
|
|
5269
|
+
mediaResolution: import_v418.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5270
|
+
responseModalities: import_v418.z.array(import_v418.z.enum(["text", "image", "audio", "video", "document"])).nullish(),
|
|
5271
|
+
serviceTier: import_v418.z.enum(["flex", "standard", "priority"]).nullish(),
|
|
5011
5272
|
/**
|
|
5012
5273
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5013
5274
|
* `system` message wins and a warning is emitted.
|
|
5014
5275
|
*/
|
|
5015
|
-
systemInstruction:
|
|
5276
|
+
systemInstruction: import_v418.z.string().nullish(),
|
|
5016
5277
|
/**
|
|
5017
5278
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5018
5279
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5019
5280
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5020
5281
|
* accepts the prior turn.
|
|
5021
5282
|
*/
|
|
5022
|
-
signature:
|
|
5283
|
+
signature: import_v418.z.string().nullish(),
|
|
5023
5284
|
/**
|
|
5024
5285
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5025
5286
|
* decide which messages to drop when compacting under
|
|
5026
5287
|
* `previousInteractionId`.
|
|
5027
5288
|
*/
|
|
5028
|
-
interactionId:
|
|
5289
|
+
interactionId: import_v418.z.string().nullish(),
|
|
5029
5290
|
/**
|
|
5030
5291
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5031
5292
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5032
5293
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5033
5294
|
*/
|
|
5034
|
-
pollingTimeoutMs:
|
|
5295
|
+
pollingTimeoutMs: import_v418.z.number().int().positive().nullish(),
|
|
5035
5296
|
/**
|
|
5036
5297
|
* Run the interaction in the background. Required for agents whose
|
|
5037
5298
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5040,7 +5301,7 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5040
5301
|
* reject `true`; see the agent's documentation for which mode it
|
|
5041
5302
|
* requires.
|
|
5042
5303
|
*/
|
|
5043
|
-
background:
|
|
5304
|
+
background: import_v418.z.boolean().nullish(),
|
|
5044
5305
|
/**
|
|
5045
5306
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5046
5307
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5050,36 +5311,36 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5050
5311
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5051
5312
|
* and/or constrain outbound traffic via `network`.
|
|
5052
5313
|
*/
|
|
5053
|
-
environment:
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
type:
|
|
5057
|
-
sources:
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
type:
|
|
5061
|
-
source:
|
|
5062
|
-
target:
|
|
5314
|
+
environment: import_v418.z.union([
|
|
5315
|
+
import_v418.z.string(),
|
|
5316
|
+
import_v418.z.object({
|
|
5317
|
+
type: import_v418.z.literal("remote"),
|
|
5318
|
+
sources: import_v418.z.array(
|
|
5319
|
+
import_v418.z.union([
|
|
5320
|
+
import_v418.z.object({
|
|
5321
|
+
type: import_v418.z.literal("gcs"),
|
|
5322
|
+
source: import_v418.z.string(),
|
|
5323
|
+
target: import_v418.z.string().nullish()
|
|
5063
5324
|
}),
|
|
5064
|
-
|
|
5065
|
-
type:
|
|
5066
|
-
source:
|
|
5067
|
-
target:
|
|
5325
|
+
import_v418.z.object({
|
|
5326
|
+
type: import_v418.z.literal("repository"),
|
|
5327
|
+
source: import_v418.z.string(),
|
|
5328
|
+
target: import_v418.z.string().nullish()
|
|
5068
5329
|
}),
|
|
5069
|
-
|
|
5070
|
-
type:
|
|
5071
|
-
content:
|
|
5072
|
-
target:
|
|
5330
|
+
import_v418.z.object({
|
|
5331
|
+
type: import_v418.z.literal("inline"),
|
|
5332
|
+
content: import_v418.z.string(),
|
|
5333
|
+
target: import_v418.z.string()
|
|
5073
5334
|
})
|
|
5074
5335
|
])
|
|
5075
5336
|
).nullish(),
|
|
5076
|
-
network:
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
allowlist:
|
|
5080
|
-
|
|
5081
|
-
domain:
|
|
5082
|
-
transform:
|
|
5337
|
+
network: import_v418.z.union([
|
|
5338
|
+
import_v418.z.literal("disabled"),
|
|
5339
|
+
import_v418.z.object({
|
|
5340
|
+
allowlist: import_v418.z.array(
|
|
5341
|
+
import_v418.z.object({
|
|
5342
|
+
domain: import_v418.z.string(),
|
|
5343
|
+
transform: import_v418.z.array(import_v418.z.record(import_v418.z.string(), import_v418.z.string())).nullish()
|
|
5083
5344
|
})
|
|
5084
5345
|
)
|
|
5085
5346
|
})
|
|
@@ -5278,10 +5539,10 @@ function parseGoogleInteractionsOutputs({
|
|
|
5278
5539
|
}
|
|
5279
5540
|
|
|
5280
5541
|
// src/interactions/poll-google-interactions.ts
|
|
5281
|
-
var
|
|
5542
|
+
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
5282
5543
|
|
|
5283
5544
|
// src/interactions/cancel-google-interaction.ts
|
|
5284
|
-
var
|
|
5545
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
5285
5546
|
var getOriginalFetch = () => globalThis.fetch;
|
|
5286
5547
|
async function cancelGoogleInteraction({
|
|
5287
5548
|
baseURL,
|
|
@@ -5296,9 +5557,9 @@ async function cancelGoogleInteraction({
|
|
|
5296
5557
|
try {
|
|
5297
5558
|
const response = await fetch(url, {
|
|
5298
5559
|
method: "POST",
|
|
5299
|
-
headers: (0,
|
|
5300
|
-
(0,
|
|
5301
|
-
(0,
|
|
5560
|
+
headers: (0, import_provider_utils20.withUserAgentSuffix)(
|
|
5561
|
+
(0, import_provider_utils20.combineHeaders)({ "Content-Type": "application/json" }, headers),
|
|
5562
|
+
(0, import_provider_utils20.getRuntimeEnvironmentUserAgent)()
|
|
5302
5563
|
),
|
|
5303
5564
|
body: "{}"
|
|
5304
5565
|
});
|
|
@@ -5348,16 +5609,16 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5348
5609
|
`google.interactions: timed out polling interaction ${interactionId} after ${timeoutMs}ms.`
|
|
5349
5610
|
);
|
|
5350
5611
|
}
|
|
5351
|
-
await (0,
|
|
5612
|
+
await (0, import_provider_utils21.delay)(nextDelayMs, { abortSignal });
|
|
5352
5613
|
const {
|
|
5353
5614
|
value: response,
|
|
5354
5615
|
rawValue: rawResponse,
|
|
5355
5616
|
responseHeaders
|
|
5356
|
-
} = await (0,
|
|
5617
|
+
} = await (0, import_provider_utils21.getFromApi)({
|
|
5357
5618
|
url,
|
|
5358
5619
|
headers,
|
|
5359
5620
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5360
|
-
successfulResponseHandler: (0,
|
|
5621
|
+
successfulResponseHandler: (0, import_provider_utils21.createJsonResponseHandler)(
|
|
5361
5622
|
googleInteractionsResponseSchema
|
|
5362
5623
|
),
|
|
5363
5624
|
abortSignal,
|
|
@@ -5369,7 +5630,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5369
5630
|
nextDelayMs = Math.min(nextDelayMs * 2, maxDelayMs);
|
|
5370
5631
|
}
|
|
5371
5632
|
} catch (error) {
|
|
5372
|
-
if ((0,
|
|
5633
|
+
if ((0, import_provider_utils21.isAbortError)(error)) {
|
|
5373
5634
|
await cancelOnServer();
|
|
5374
5635
|
}
|
|
5375
5636
|
throw error;
|
|
@@ -5525,7 +5786,7 @@ function prepareGoogleInteractionsTools({
|
|
|
5525
5786
|
}
|
|
5526
5787
|
|
|
5527
5788
|
// src/interactions/stream-google-interactions.ts
|
|
5528
|
-
var
|
|
5789
|
+
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
5529
5790
|
var DEFAULT_MAX_RETRIES = 3;
|
|
5530
5791
|
var DEFAULT_RETRY_DELAY_MS = 500;
|
|
5531
5792
|
function streamGoogleInteractionEvents({
|
|
@@ -5572,11 +5833,11 @@ function streamGoogleInteractionEvents({
|
|
|
5572
5833
|
return `${base}?${params.toString()}`;
|
|
5573
5834
|
}
|
|
5574
5835
|
async function openReader() {
|
|
5575
|
-
const { value: stream } = await (0,
|
|
5836
|
+
const { value: stream } = await (0, import_provider_utils22.getFromApi)({
|
|
5576
5837
|
url: buildUrl(),
|
|
5577
5838
|
headers: eventSourceHeaders,
|
|
5578
5839
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5579
|
-
successfulResponseHandler: (0,
|
|
5840
|
+
successfulResponseHandler: (0, import_provider_utils22.createEventSourceResponseHandler)(
|
|
5580
5841
|
googleInteractionsEventSchema
|
|
5581
5842
|
),
|
|
5582
5843
|
abortSignal: effectiveSignal,
|
|
@@ -5593,7 +5854,7 @@ function streamGoogleInteractionEvents({
|
|
|
5593
5854
|
currentReader = await openReader();
|
|
5594
5855
|
receivedAnyEventThisAttempt = false;
|
|
5595
5856
|
} catch (error) {
|
|
5596
|
-
if ((0,
|
|
5857
|
+
if ((0, import_provider_utils22.isAbortError)(error) || effectiveSignal.aborted) {
|
|
5597
5858
|
controller.error(error);
|
|
5598
5859
|
return;
|
|
5599
5860
|
}
|
|
@@ -5602,7 +5863,7 @@ function streamGoogleInteractionEvents({
|
|
|
5602
5863
|
controller.error(error);
|
|
5603
5864
|
return;
|
|
5604
5865
|
}
|
|
5605
|
-
await (0,
|
|
5866
|
+
await (0, import_provider_utils22.delay)(retryDelayMs * attempt, {
|
|
5606
5867
|
abortSignal: effectiveSignal
|
|
5607
5868
|
});
|
|
5608
5869
|
continue;
|
|
@@ -5623,7 +5884,7 @@ function streamGoogleInteractionEvents({
|
|
|
5623
5884
|
);
|
|
5624
5885
|
return;
|
|
5625
5886
|
}
|
|
5626
|
-
await (0,
|
|
5887
|
+
await (0, import_provider_utils22.delay)(retryDelayMs * attempt, {
|
|
5627
5888
|
abortSignal: effectiveSignal
|
|
5628
5889
|
});
|
|
5629
5890
|
} else {
|
|
@@ -5643,7 +5904,7 @@ function streamGoogleInteractionEvents({
|
|
|
5643
5904
|
}
|
|
5644
5905
|
controller.enqueue(value);
|
|
5645
5906
|
} catch (error) {
|
|
5646
|
-
if ((0,
|
|
5907
|
+
if ((0, import_provider_utils22.isAbortError)(error) || effectiveSignal.aborted) {
|
|
5647
5908
|
controller.error(error);
|
|
5648
5909
|
return;
|
|
5649
5910
|
}
|
|
@@ -5653,7 +5914,7 @@ function streamGoogleInteractionEvents({
|
|
|
5653
5914
|
controller.error(error);
|
|
5654
5915
|
return;
|
|
5655
5916
|
}
|
|
5656
|
-
await (0,
|
|
5917
|
+
await (0, import_provider_utils22.delay)(retryDelayMs * attempt, {
|
|
5657
5918
|
abortSignal: effectiveSignal
|
|
5658
5919
|
});
|
|
5659
5920
|
}
|
|
@@ -5865,7 +6126,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5865
6126
|
async getArgs(options) {
|
|
5866
6127
|
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;
|
|
5867
6128
|
const warnings = [];
|
|
5868
|
-
const opts = await (0,
|
|
6129
|
+
const opts = await (0, import_provider_utils23.parseProviderOptions)({
|
|
5869
6130
|
provider: "google",
|
|
5870
6131
|
providerOptions: options.providerOptions,
|
|
5871
6132
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6111,17 +6372,17 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6111
6372
|
var _a, _b, _c, _d, _e, _f;
|
|
6112
6373
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6113
6374
|
const url = `${this.config.baseURL}/interactions`;
|
|
6114
|
-
const mergedHeaders = (0,
|
|
6375
|
+
const mergedHeaders = (0, import_provider_utils23.combineHeaders)(
|
|
6115
6376
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6116
|
-
this.config.headers ? await (0,
|
|
6377
|
+
this.config.headers ? await (0, import_provider_utils23.resolve)(this.config.headers) : void 0,
|
|
6117
6378
|
options.headers
|
|
6118
6379
|
);
|
|
6119
|
-
const postResult = await (0,
|
|
6380
|
+
const postResult = await (0, import_provider_utils23.postJsonToApi)({
|
|
6120
6381
|
url,
|
|
6121
6382
|
headers: mergedHeaders,
|
|
6122
6383
|
body: args,
|
|
6123
6384
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6124
|
-
successfulResponseHandler: (0,
|
|
6385
|
+
successfulResponseHandler: (0, import_provider_utils23.createJsonResponseHandler)(
|
|
6125
6386
|
googleInteractionsResponseSchema
|
|
6126
6387
|
),
|
|
6127
6388
|
abortSignal: options.abortSignal,
|
|
@@ -6148,7 +6409,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6148
6409
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
6149
6410
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
6150
6411
|
steps: (_b = response.steps) != null ? _b : null,
|
|
6151
|
-
generateId: (_c = this.config.generateId) != null ? _c :
|
|
6412
|
+
generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils23.generateId,
|
|
6152
6413
|
interactionId
|
|
6153
6414
|
});
|
|
6154
6415
|
const finishReason = {
|
|
@@ -6196,9 +6457,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6196
6457
|
var _a;
|
|
6197
6458
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6198
6459
|
const url = `${this.config.baseURL}/interactions`;
|
|
6199
|
-
const mergedHeaders = (0,
|
|
6460
|
+
const mergedHeaders = (0, import_provider_utils23.combineHeaders)(
|
|
6200
6461
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6201
|
-
this.config.headers ? await (0,
|
|
6462
|
+
this.config.headers ? await (0, import_provider_utils23.resolve)(this.config.headers) : void 0,
|
|
6202
6463
|
options.headers
|
|
6203
6464
|
);
|
|
6204
6465
|
if (isBackground) {
|
|
@@ -6212,12 +6473,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6212
6473
|
});
|
|
6213
6474
|
}
|
|
6214
6475
|
const body = { ...args, stream: true };
|
|
6215
|
-
const { responseHeaders, value: response } = await (0,
|
|
6476
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils23.postJsonToApi)({
|
|
6216
6477
|
url,
|
|
6217
6478
|
headers: mergedHeaders,
|
|
6218
6479
|
body,
|
|
6219
6480
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6220
|
-
successfulResponseHandler: (0,
|
|
6481
|
+
successfulResponseHandler: (0, import_provider_utils23.createEventSourceResponseHandler)(
|
|
6221
6482
|
googleInteractionsEventSchema
|
|
6222
6483
|
),
|
|
6223
6484
|
abortSignal: options.abortSignal,
|
|
@@ -6226,7 +6487,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6226
6487
|
const headerServiceTier = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"];
|
|
6227
6488
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
6228
6489
|
warnings,
|
|
6229
|
-
generateId: (_a = this.config.generateId) != null ? _a :
|
|
6490
|
+
generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils23.generateId,
|
|
6230
6491
|
includeRawChunks: options.includeRawChunks,
|
|
6231
6492
|
serviceTier: headerServiceTier
|
|
6232
6493
|
});
|
|
@@ -6263,12 +6524,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6263
6524
|
pollingTimeoutMs
|
|
6264
6525
|
}) {
|
|
6265
6526
|
var _a, _b;
|
|
6266
|
-
const postResult = await (0,
|
|
6527
|
+
const postResult = await (0, import_provider_utils23.postJsonToApi)({
|
|
6267
6528
|
url,
|
|
6268
6529
|
headers: mergedHeaders,
|
|
6269
6530
|
body: args,
|
|
6270
6531
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6271
|
-
successfulResponseHandler: (0,
|
|
6532
|
+
successfulResponseHandler: (0, import_provider_utils23.createJsonResponseHandler)(
|
|
6272
6533
|
googleInteractionsResponseSchema
|
|
6273
6534
|
),
|
|
6274
6535
|
abortSignal: options.abortSignal,
|
|
@@ -6286,7 +6547,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6286
6547
|
const synthesized = synthesizeGoogleInteractionsAgentStream({
|
|
6287
6548
|
response: postResponse,
|
|
6288
6549
|
warnings,
|
|
6289
|
-
generateId: (_a = this.config.generateId) != null ? _a :
|
|
6550
|
+
generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils23.generateId,
|
|
6290
6551
|
includeRawChunks: options.includeRawChunks,
|
|
6291
6552
|
headerServiceTier
|
|
6292
6553
|
});
|
|
@@ -6306,7 +6567,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6306
6567
|
});
|
|
6307
6568
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
6308
6569
|
warnings,
|
|
6309
|
-
generateId: (_b = this.config.generateId) != null ? _b :
|
|
6570
|
+
generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils23.generateId,
|
|
6310
6571
|
includeRawChunks: options.includeRawChunks,
|
|
6311
6572
|
serviceTier: headerServiceTier
|
|
6312
6573
|
});
|
|
@@ -6360,11 +6621,11 @@ function supportsExternalFileUrls(modelId) {
|
|
|
6360
6621
|
}
|
|
6361
6622
|
function createGoogleGenerativeAI(options = {}) {
|
|
6362
6623
|
var _a, _b;
|
|
6363
|
-
const baseURL = (_a = (0,
|
|
6624
|
+
const baseURL = (_a = (0, import_provider_utils24.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
6364
6625
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
6365
|
-
const getHeaders = () => (0,
|
|
6626
|
+
const getHeaders = () => (0, import_provider_utils24.withUserAgentSuffix)(
|
|
6366
6627
|
{
|
|
6367
|
-
"x-goog-api-key": (0,
|
|
6628
|
+
"x-goog-api-key": (0, import_provider_utils24.loadApiKey)({
|
|
6368
6629
|
apiKey: options.apiKey,
|
|
6369
6630
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
6370
6631
|
description: "Google Generative AI"
|
|
@@ -6379,7 +6640,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6379
6640
|
provider: providerName,
|
|
6380
6641
|
baseURL,
|
|
6381
6642
|
headers: getHeaders,
|
|
6382
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6643
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId,
|
|
6383
6644
|
supportedUrls: () => ({
|
|
6384
6645
|
"*": [
|
|
6385
6646
|
// Google Generative Language "files" endpoint
|
|
@@ -6413,6 +6674,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6413
6674
|
headers: getHeaders,
|
|
6414
6675
|
fetch: options.fetch
|
|
6415
6676
|
});
|
|
6677
|
+
const createTranscriptionModel = (modelId) => new GoogleTranscriptionModel(modelId, {
|
|
6678
|
+
provider: `${providerName}.transcription`,
|
|
6679
|
+
baseURL,
|
|
6680
|
+
headers: getHeaders,
|
|
6681
|
+
fetch: options.fetch
|
|
6682
|
+
});
|
|
6416
6683
|
const createVideoModel = (modelId) => {
|
|
6417
6684
|
var _a2;
|
|
6418
6685
|
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
@@ -6420,7 +6687,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6420
6687
|
baseURL,
|
|
6421
6688
|
headers: getHeaders,
|
|
6422
6689
|
fetch: options.fetch,
|
|
6423
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6690
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId
|
|
6424
6691
|
});
|
|
6425
6692
|
};
|
|
6426
6693
|
const createInteractionsModel = (modelIdOrAgent) => {
|
|
@@ -6431,7 +6698,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6431
6698
|
provider: `${providerName}.interactions`,
|
|
6432
6699
|
baseURL,
|
|
6433
6700
|
headers: getHeaders,
|
|
6434
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6701
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId,
|
|
6435
6702
|
fetch: options.fetch
|
|
6436
6703
|
}
|
|
6437
6704
|
);
|
|
@@ -6454,6 +6721,8 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6454
6721
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
6455
6722
|
provider.image = createImageModel;
|
|
6456
6723
|
provider.imageModel = createImageModel;
|
|
6724
|
+
provider.transcription = createTranscriptionModel;
|
|
6725
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
6457
6726
|
provider.video = createVideoModel;
|
|
6458
6727
|
provider.videoModel = createVideoModel;
|
|
6459
6728
|
provider.interactions = createInteractionsModel;
|
|
@@ -6463,6 +6732,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6463
6732
|
var google = createGoogleGenerativeAI();
|
|
6464
6733
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6465
6734
|
0 && (module.exports = {
|
|
6735
|
+
GoogleTranscriptionModel,
|
|
6466
6736
|
VERSION,
|
|
6467
6737
|
createGoogleGenerativeAI,
|
|
6468
6738
|
google
|