@ai-sdk/google 3.0.114 → 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 +14 -0
- package/dist/index.d.mts +57 -3
- package/dist/index.d.ts +57 -3
- package/dist/index.js +926 -672
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +863 -601
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +65 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +65 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/convert-json-schema-to-openapi-schema.ts +123 -7
- 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.114" : "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,10 +474,10 @@ 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");
|
|
293
478
|
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
294
479
|
function isRecursiveJSONSchemaReferenceError(error) {
|
|
295
|
-
return
|
|
480
|
+
return import_provider3.UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
296
481
|
}
|
|
297
482
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
298
483
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
@@ -344,9 +529,6 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
344
529
|
if (description) result.description = description;
|
|
345
530
|
if (required) result.required = required;
|
|
346
531
|
if (format) result.format = format;
|
|
347
|
-
if (constValue !== void 0) {
|
|
348
|
-
result.enum = [constValue];
|
|
349
|
-
}
|
|
350
532
|
if (type) {
|
|
351
533
|
if (Array.isArray(type)) {
|
|
352
534
|
const hasNull = type.includes("null");
|
|
@@ -363,8 +545,9 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
363
545
|
result.type = type;
|
|
364
546
|
}
|
|
365
547
|
}
|
|
366
|
-
|
|
367
|
-
|
|
548
|
+
const values = enumValues != null ? enumValues : constValue !== void 0 ? [constValue] : void 0;
|
|
549
|
+
if (values !== void 0) {
|
|
550
|
+
addEnumToSchema({ values, type, result });
|
|
368
551
|
}
|
|
369
552
|
if (properties != null) {
|
|
370
553
|
result.properties = Object.entries(properties).reduce(
|
|
@@ -424,6 +607,68 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
424
607
|
}
|
|
425
608
|
return result;
|
|
426
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
|
+
}
|
|
427
672
|
function convertJSONSchemaReference({
|
|
428
673
|
jsonSchema,
|
|
429
674
|
reference,
|
|
@@ -435,7 +680,7 @@ function convertJSONSchemaReference({
|
|
|
435
680
|
referenceContext
|
|
436
681
|
);
|
|
437
682
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
438
|
-
throw new
|
|
683
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
439
684
|
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
440
685
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
441
686
|
});
|
|
@@ -489,7 +734,7 @@ function getReferencedDefinition(reference, referenceContext) {
|
|
|
489
734
|
};
|
|
490
735
|
}
|
|
491
736
|
function throwUnsupportedReference(reference) {
|
|
492
|
-
throw new
|
|
737
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
493
738
|
functionality: `JSON Schema reference: ${reference}`,
|
|
494
739
|
message: "Google schema conversion only supports references to direct children of root-level $defs or definitions."
|
|
495
740
|
});
|
|
@@ -499,8 +744,8 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
499
744
|
}
|
|
500
745
|
|
|
501
746
|
// src/convert-to-google-generative-ai-messages.ts
|
|
502
|
-
var
|
|
503
|
-
var
|
|
747
|
+
var import_provider4 = require("@ai-sdk/provider");
|
|
748
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
504
749
|
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
505
750
|
function getGoogleProviderOptions(providerOptions, providerOptionsName) {
|
|
506
751
|
const namespaces = [
|
|
@@ -649,7 +894,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
649
894
|
switch (role) {
|
|
650
895
|
case "system": {
|
|
651
896
|
if (!systemMessagesAllowed) {
|
|
652
|
-
throw new
|
|
897
|
+
throw new import_provider4.UnsupportedFunctionalityError({
|
|
653
898
|
functionality: "system messages are only supported at the beginning of the conversation"
|
|
654
899
|
});
|
|
655
900
|
}
|
|
@@ -676,7 +921,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
676
921
|
} : {
|
|
677
922
|
inlineData: {
|
|
678
923
|
mimeType: mediaType,
|
|
679
|
-
data: (0,
|
|
924
|
+
data: (0, import_provider_utils5.convertToBase64)(part.data)
|
|
680
925
|
}
|
|
681
926
|
}
|
|
682
927
|
);
|
|
@@ -714,14 +959,14 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
714
959
|
}
|
|
715
960
|
case "file": {
|
|
716
961
|
if (part.data instanceof URL) {
|
|
717
|
-
throw new
|
|
962
|
+
throw new import_provider4.UnsupportedFunctionalityError({
|
|
718
963
|
functionality: "File data URLs in assistant messages are not supported"
|
|
719
964
|
});
|
|
720
965
|
}
|
|
721
966
|
return {
|
|
722
967
|
inlineData: {
|
|
723
968
|
mimeType: part.mediaType,
|
|
724
|
-
data: (0,
|
|
969
|
+
data: (0, import_provider_utils5.convertToBase64)(part.data)
|
|
725
970
|
},
|
|
726
971
|
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
727
972
|
thoughtSignature
|
|
@@ -746,7 +991,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
746
991
|
return {
|
|
747
992
|
toolCall: {
|
|
748
993
|
toolType: serverToolType,
|
|
749
|
-
args: typeof part.input === "string" ? (0,
|
|
994
|
+
args: typeof part.input === "string" ? (0, import_provider_utils5.secureJsonParse)(part.input) : part.input,
|
|
750
995
|
id: serverToolCallId
|
|
751
996
|
},
|
|
752
997
|
thoughtSignature: effectiveThoughtSignature
|
|
@@ -874,24 +1119,24 @@ function getModelPath(modelId) {
|
|
|
874
1119
|
}
|
|
875
1120
|
|
|
876
1121
|
// src/google-generative-ai-options.ts
|
|
877
|
-
var
|
|
878
|
-
var
|
|
879
|
-
var googleLanguageModelOptions = (0,
|
|
880
|
-
() => (0,
|
|
881
|
-
|
|
882
|
-
responseModalities:
|
|
883
|
-
thinkingConfig:
|
|
884
|
-
thinkingBudget:
|
|
885
|
-
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(),
|
|
886
1131
|
// https://ai.google.dev/gemini-api/docs/gemini-3?thinking=high#thinking_level
|
|
887
|
-
thinkingLevel:
|
|
1132
|
+
thinkingLevel: import_v46.z.enum(["minimal", "low", "medium", "high"]).optional()
|
|
888
1133
|
}).optional(),
|
|
889
1134
|
/**
|
|
890
1135
|
* Optional.
|
|
891
1136
|
* The name of the cached content used as context to serve the prediction.
|
|
892
1137
|
* Format: cachedContents/{cachedContent}
|
|
893
1138
|
*/
|
|
894
|
-
cachedContent:
|
|
1139
|
+
cachedContent: import_v46.z.string().optional(),
|
|
895
1140
|
/**
|
|
896
1141
|
* Optional. Enable structured output. Default is true.
|
|
897
1142
|
*
|
|
@@ -900,13 +1145,13 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
900
1145
|
* Google Generative AI uses. You can use this to disable
|
|
901
1146
|
* structured outputs if you need to.
|
|
902
1147
|
*/
|
|
903
|
-
structuredOutputs:
|
|
1148
|
+
structuredOutputs: import_v46.z.boolean().optional(),
|
|
904
1149
|
/**
|
|
905
1150
|
* Optional. A list of unique safety settings for blocking unsafe content.
|
|
906
1151
|
*/
|
|
907
|
-
safetySettings:
|
|
908
|
-
|
|
909
|
-
category:
|
|
1152
|
+
safetySettings: import_v46.z.array(
|
|
1153
|
+
import_v46.z.object({
|
|
1154
|
+
category: import_v46.z.enum([
|
|
910
1155
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
911
1156
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
912
1157
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -914,7 +1159,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
914
1159
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
915
1160
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
916
1161
|
]),
|
|
917
|
-
threshold:
|
|
1162
|
+
threshold: import_v46.z.enum([
|
|
918
1163
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
919
1164
|
"BLOCK_LOW_AND_ABOVE",
|
|
920
1165
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -924,7 +1169,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
924
1169
|
])
|
|
925
1170
|
})
|
|
926
1171
|
).optional(),
|
|
927
|
-
threshold:
|
|
1172
|
+
threshold: import_v46.z.enum([
|
|
928
1173
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
929
1174
|
"BLOCK_LOW_AND_ABOVE",
|
|
930
1175
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -937,19 +1182,19 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
937
1182
|
*
|
|
938
1183
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
939
1184
|
*/
|
|
940
|
-
audioTimestamp:
|
|
1185
|
+
audioTimestamp: import_v46.z.boolean().optional(),
|
|
941
1186
|
/**
|
|
942
1187
|
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
943
1188
|
*
|
|
944
1189
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
945
1190
|
*/
|
|
946
|
-
labels:
|
|
1191
|
+
labels: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional(),
|
|
947
1192
|
/**
|
|
948
1193
|
* Optional. If specified, the media resolution specified will be used.
|
|
949
1194
|
*
|
|
950
1195
|
* https://ai.google.dev/api/generate-content#MediaResolution
|
|
951
1196
|
*/
|
|
952
|
-
mediaResolution:
|
|
1197
|
+
mediaResolution: import_v46.z.enum([
|
|
953
1198
|
"MEDIA_RESOLUTION_UNSPECIFIED",
|
|
954
1199
|
"MEDIA_RESOLUTION_LOW",
|
|
955
1200
|
"MEDIA_RESOLUTION_MEDIUM",
|
|
@@ -960,8 +1205,8 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
960
1205
|
*
|
|
961
1206
|
* https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
|
|
962
1207
|
*/
|
|
963
|
-
imageConfig:
|
|
964
|
-
aspectRatio:
|
|
1208
|
+
imageConfig: import_v46.z.object({
|
|
1209
|
+
aspectRatio: import_v46.z.enum([
|
|
965
1210
|
"1:1",
|
|
966
1211
|
"2:3",
|
|
967
1212
|
"3:2",
|
|
@@ -977,12 +1222,12 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
977
1222
|
"1:4",
|
|
978
1223
|
"4:1"
|
|
979
1224
|
]).optional(),
|
|
980
|
-
imageSize:
|
|
1225
|
+
imageSize: import_v46.z.enum(["1K", "2K", "4K", "512"]).optional(),
|
|
981
1226
|
/**
|
|
982
1227
|
* Optional. Controls the generation of people in images.
|
|
983
1228
|
* Vertex AI only.
|
|
984
1229
|
*/
|
|
985
|
-
personGeneration:
|
|
1230
|
+
personGeneration: import_v46.z.enum([
|
|
986
1231
|
"PERSON_GENERATION_UNSPECIFIED",
|
|
987
1232
|
"ALLOW_ALL",
|
|
988
1233
|
"ALLOW_ADULT",
|
|
@@ -996,7 +1241,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
996
1241
|
*
|
|
997
1242
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
|
|
998
1243
|
*/
|
|
999
|
-
prominentPeople:
|
|
1244
|
+
prominentPeople: import_v46.z.enum([
|
|
1000
1245
|
"PROMINENT_PEOPLE_UNSPECIFIED",
|
|
1001
1246
|
"ALLOW_PROMINENT_PEOPLE",
|
|
1002
1247
|
"BLOCK_PROMINENT_PEOPLE"
|
|
@@ -1005,9 +1250,9 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1005
1250
|
* Optional. The image output format for generated images.
|
|
1006
1251
|
* Vertex AI only.
|
|
1007
1252
|
*/
|
|
1008
|
-
imageOutputOptions:
|
|
1009
|
-
mimeType:
|
|
1010
|
-
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()
|
|
1011
1256
|
}).optional()
|
|
1012
1257
|
}).optional(),
|
|
1013
1258
|
/**
|
|
@@ -1016,10 +1261,10 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1016
1261
|
*
|
|
1017
1262
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
1018
1263
|
*/
|
|
1019
|
-
retrievalConfig:
|
|
1020
|
-
latLng:
|
|
1021
|
-
latitude:
|
|
1022
|
-
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()
|
|
1023
1268
|
}).optional()
|
|
1024
1269
|
}).optional(),
|
|
1025
1270
|
/**
|
|
@@ -1032,12 +1277,12 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1032
1277
|
*
|
|
1033
1278
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc
|
|
1034
1279
|
*/
|
|
1035
|
-
streamFunctionCallArguments:
|
|
1280
|
+
streamFunctionCallArguments: import_v46.z.boolean().optional(),
|
|
1036
1281
|
/**
|
|
1037
1282
|
* Optional. The service tier to use for the request. Sent as the
|
|
1038
1283
|
* `serviceTier` body field. Gemini API only.
|
|
1039
1284
|
*/
|
|
1040
|
-
serviceTier:
|
|
1285
|
+
serviceTier: import_v46.z.enum(["standard", "flex", "priority"]).optional(),
|
|
1041
1286
|
/**
|
|
1042
1287
|
* Optional. Vertex AI only. Sent as the
|
|
1043
1288
|
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
@@ -1048,7 +1293,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1048
1293
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1049
1294
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1050
1295
|
*/
|
|
1051
|
-
sharedRequestType:
|
|
1296
|
+
sharedRequestType: import_v46.z.enum(["priority", "flex", "standard"]).optional(),
|
|
1052
1297
|
/**
|
|
1053
1298
|
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1054
1299
|
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
@@ -1056,7 +1301,7 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
1056
1301
|
*
|
|
1057
1302
|
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1058
1303
|
*/
|
|
1059
|
-
requestType:
|
|
1304
|
+
requestType: import_v46.z.enum(["shared"]).optional()
|
|
1060
1305
|
})
|
|
1061
1306
|
)
|
|
1062
1307
|
);
|
|
@@ -1083,7 +1328,7 @@ function getGoogleModelCapabilities(modelId) {
|
|
|
1083
1328
|
}
|
|
1084
1329
|
|
|
1085
1330
|
// src/google-prepare-tools.ts
|
|
1086
|
-
var
|
|
1331
|
+
var import_provider5 = require("@ai-sdk/provider");
|
|
1087
1332
|
function prepareTools({
|
|
1088
1333
|
tools,
|
|
1089
1334
|
toolChoice,
|
|
@@ -1312,7 +1557,7 @@ function prepareTools({
|
|
|
1312
1557
|
};
|
|
1313
1558
|
default: {
|
|
1314
1559
|
const _exhaustiveCheck = type;
|
|
1315
|
-
throw new
|
|
1560
|
+
throw new import_provider5.UnsupportedFunctionalityError({
|
|
1316
1561
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1317
1562
|
});
|
|
1318
1563
|
}
|
|
@@ -1616,7 +1861,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1616
1861
|
var _a;
|
|
1617
1862
|
this.modelId = modelId;
|
|
1618
1863
|
this.config = config;
|
|
1619
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1864
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
|
|
1620
1865
|
}
|
|
1621
1866
|
get provider() {
|
|
1622
1867
|
return this.config.provider;
|
|
@@ -1643,13 +1888,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1643
1888
|
var _a, _b, _c;
|
|
1644
1889
|
const warnings = [];
|
|
1645
1890
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1646
|
-
let googleOptions = await (0,
|
|
1891
|
+
let googleOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
1647
1892
|
provider: providerOptionsName,
|
|
1648
1893
|
providerOptions,
|
|
1649
1894
|
schema: googleLanguageModelOptions
|
|
1650
1895
|
});
|
|
1651
1896
|
if (googleOptions == null && providerOptionsName !== "google") {
|
|
1652
|
-
googleOptions = await (0,
|
|
1897
|
+
googleOptions = await (0, import_provider_utils7.parseProviderOptions)({
|
|
1653
1898
|
provider: "google",
|
|
1654
1899
|
providerOptions,
|
|
1655
1900
|
schema: googleLanguageModelOptions
|
|
@@ -1799,8 +2044,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1799
2044
|
async doGenerate(options) {
|
|
1800
2045
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1801
2046
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1802
|
-
const mergedHeaders = (0,
|
|
1803
|
-
await (0,
|
|
2047
|
+
const mergedHeaders = (0, import_provider_utils7.combineHeaders)(
|
|
2048
|
+
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
1804
2049
|
options.headers,
|
|
1805
2050
|
extraHeaders
|
|
1806
2051
|
);
|
|
@@ -1808,14 +2053,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1808
2053
|
responseHeaders,
|
|
1809
2054
|
value: response,
|
|
1810
2055
|
rawValue: rawResponse
|
|
1811
|
-
} = await (0,
|
|
2056
|
+
} = await (0, import_provider_utils7.postJsonToApi)({
|
|
1812
2057
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1813
2058
|
this.modelId
|
|
1814
2059
|
)}:generateContent`,
|
|
1815
2060
|
headers: mergedHeaders,
|
|
1816
2061
|
body: args,
|
|
1817
2062
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1818
|
-
successfulResponseHandler: (0,
|
|
2063
|
+
successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(responseSchema),
|
|
1819
2064
|
abortSignal: options.abortSignal,
|
|
1820
2065
|
fetch: this.config.fetch
|
|
1821
2066
|
});
|
|
@@ -1980,19 +2225,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1980
2225
|
}
|
|
1981
2226
|
async doStream(options) {
|
|
1982
2227
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1983
|
-
const headers = (0,
|
|
1984
|
-
await (0,
|
|
2228
|
+
const headers = (0, import_provider_utils7.combineHeaders)(
|
|
2229
|
+
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
1985
2230
|
options.headers,
|
|
1986
2231
|
extraHeaders
|
|
1987
2232
|
);
|
|
1988
|
-
const { responseHeaders, value: response } = await (0,
|
|
2233
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
|
|
1989
2234
|
url: `${this.config.baseURL}/${getModelPath(
|
|
1990
2235
|
this.modelId
|
|
1991
2236
|
)}:streamGenerateContent?alt=sse`,
|
|
1992
2237
|
headers,
|
|
1993
2238
|
body: args,
|
|
1994
2239
|
failedResponseHandler: googleFailedResponseHandler,
|
|
1995
|
-
successfulResponseHandler: (0,
|
|
2240
|
+
successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(chunkSchema),
|
|
1996
2241
|
abortSignal: options.abortSignal,
|
|
1997
2242
|
fetch: this.config.fetch
|
|
1998
2243
|
});
|
|
@@ -2501,272 +2746,272 @@ function extractSources({
|
|
|
2501
2746
|
}
|
|
2502
2747
|
return sources.length > 0 ? sources : void 0;
|
|
2503
2748
|
}
|
|
2504
|
-
var getGroundingMetadataSchema = () =>
|
|
2505
|
-
webSearchQueries:
|
|
2506
|
-
imageSearchQueries:
|
|
2507
|
-
retrievalQueries:
|
|
2508
|
-
searchEntryPoint:
|
|
2509
|
-
groundingChunks:
|
|
2510
|
-
|
|
2511
|
-
web:
|
|
2512
|
-
image:
|
|
2513
|
-
sourceUri:
|
|
2514
|
-
imageUri:
|
|
2515
|
-
title:
|
|
2516
|
-
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()
|
|
2517
2762
|
}).nullish(),
|
|
2518
|
-
retrievedContext:
|
|
2519
|
-
uri:
|
|
2520
|
-
title:
|
|
2521
|
-
text:
|
|
2522
|
-
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()
|
|
2523
2768
|
}).nullish(),
|
|
2524
|
-
maps:
|
|
2525
|
-
uri:
|
|
2526
|
-
title:
|
|
2527
|
-
text:
|
|
2528
|
-
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()
|
|
2529
2774
|
}).nullish()
|
|
2530
2775
|
})
|
|
2531
2776
|
).nullish(),
|
|
2532
|
-
groundingSupports:
|
|
2533
|
-
|
|
2534
|
-
segment:
|
|
2535
|
-
startIndex:
|
|
2536
|
-
endIndex:
|
|
2537
|
-
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()
|
|
2538
2783
|
}).nullish(),
|
|
2539
|
-
segment_text:
|
|
2540
|
-
groundingChunkIndices:
|
|
2541
|
-
supportChunkIndices:
|
|
2542
|
-
confidenceScores:
|
|
2543
|
-
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()
|
|
2544
2789
|
})
|
|
2545
2790
|
).nullish(),
|
|
2546
|
-
retrievalMetadata:
|
|
2547
|
-
|
|
2548
|
-
webDynamicRetrievalScore:
|
|
2791
|
+
retrievalMetadata: import_v47.z.union([
|
|
2792
|
+
import_v47.z.object({
|
|
2793
|
+
webDynamicRetrievalScore: import_v47.z.number()
|
|
2549
2794
|
}),
|
|
2550
|
-
|
|
2795
|
+
import_v47.z.object({})
|
|
2551
2796
|
]).nullish()
|
|
2552
2797
|
});
|
|
2553
|
-
var partialArgSchema =
|
|
2554
|
-
jsonPath:
|
|
2555
|
-
stringValue:
|
|
2556
|
-
numberValue:
|
|
2557
|
-
boolValue:
|
|
2558
|
-
nullValue:
|
|
2559
|
-
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()
|
|
2560
2805
|
});
|
|
2561
|
-
var getContentSchema = () =>
|
|
2562
|
-
parts:
|
|
2563
|
-
|
|
2806
|
+
var getContentSchema = () => import_v47.z.object({
|
|
2807
|
+
parts: import_v47.z.array(
|
|
2808
|
+
import_v47.z.union([
|
|
2564
2809
|
// note: order matters since text can be fully empty
|
|
2565
|
-
|
|
2566
|
-
functionCall:
|
|
2567
|
-
id:
|
|
2568
|
-
name:
|
|
2569
|
-
args:
|
|
2570
|
-
partialArgs:
|
|
2571
|
-
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()
|
|
2572
2817
|
}),
|
|
2573
|
-
thoughtSignature:
|
|
2818
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2574
2819
|
}),
|
|
2575
|
-
|
|
2576
|
-
inlineData:
|
|
2577
|
-
mimeType:
|
|
2578
|
-
data:
|
|
2820
|
+
import_v47.z.object({
|
|
2821
|
+
inlineData: import_v47.z.object({
|
|
2822
|
+
mimeType: import_v47.z.string(),
|
|
2823
|
+
data: import_v47.z.string()
|
|
2579
2824
|
}),
|
|
2580
|
-
thought:
|
|
2581
|
-
thoughtSignature:
|
|
2825
|
+
thought: import_v47.z.boolean().nullish(),
|
|
2826
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2582
2827
|
}),
|
|
2583
|
-
|
|
2584
|
-
toolCall:
|
|
2585
|
-
toolType:
|
|
2586
|
-
args:
|
|
2587
|
-
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()
|
|
2588
2833
|
}),
|
|
2589
|
-
thoughtSignature:
|
|
2834
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2590
2835
|
}),
|
|
2591
|
-
|
|
2592
|
-
toolResponse:
|
|
2593
|
-
toolType:
|
|
2594
|
-
response:
|
|
2595
|
-
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()
|
|
2596
2841
|
}),
|
|
2597
|
-
thoughtSignature:
|
|
2842
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2598
2843
|
}),
|
|
2599
|
-
|
|
2600
|
-
executableCode:
|
|
2601
|
-
language:
|
|
2602
|
-
code:
|
|
2844
|
+
import_v47.z.object({
|
|
2845
|
+
executableCode: import_v47.z.object({
|
|
2846
|
+
language: import_v47.z.string(),
|
|
2847
|
+
code: import_v47.z.string()
|
|
2603
2848
|
}).nullish(),
|
|
2604
|
-
codeExecutionResult:
|
|
2605
|
-
outcome:
|
|
2606
|
-
output:
|
|
2849
|
+
codeExecutionResult: import_v47.z.object({
|
|
2850
|
+
outcome: import_v47.z.string(),
|
|
2851
|
+
output: import_v47.z.string().nullish()
|
|
2607
2852
|
}).nullish(),
|
|
2608
|
-
text:
|
|
2609
|
-
thought:
|
|
2610
|
-
thoughtSignature:
|
|
2853
|
+
text: import_v47.z.string().nullish(),
|
|
2854
|
+
thought: import_v47.z.boolean().nullish(),
|
|
2855
|
+
thoughtSignature: import_v47.z.string().nullish()
|
|
2611
2856
|
})
|
|
2612
2857
|
])
|
|
2613
2858
|
).nullish()
|
|
2614
2859
|
});
|
|
2615
|
-
var getSafetyRatingSchema = () =>
|
|
2616
|
-
category:
|
|
2617
|
-
probability:
|
|
2618
|
-
probabilityScore:
|
|
2619
|
-
severity:
|
|
2620
|
-
severityScore:
|
|
2621
|
-
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()
|
|
2622
2867
|
});
|
|
2623
|
-
var tokenDetailsSchema =
|
|
2624
|
-
|
|
2625
|
-
modality:
|
|
2626
|
-
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()
|
|
2627
2872
|
})
|
|
2628
2873
|
).nullish();
|
|
2629
|
-
var usageSchema =
|
|
2630
|
-
cachedContentTokenCount:
|
|
2631
|
-
thoughtsTokenCount:
|
|
2632
|
-
promptTokenCount:
|
|
2633
|
-
candidatesTokenCount:
|
|
2634
|
-
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(),
|
|
2635
2880
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2636
|
-
trafficType:
|
|
2637
|
-
serviceTier:
|
|
2881
|
+
trafficType: import_v47.z.string().nullish(),
|
|
2882
|
+
serviceTier: import_v47.z.string().nullish(),
|
|
2638
2883
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2639
2884
|
promptTokensDetails: tokenDetailsSchema,
|
|
2640
2885
|
candidatesTokensDetails: tokenDetailsSchema
|
|
2641
2886
|
});
|
|
2642
|
-
var getUrlContextMetadataSchema = () =>
|
|
2643
|
-
urlMetadata:
|
|
2644
|
-
|
|
2645
|
-
retrievedUrl:
|
|
2646
|
-
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()
|
|
2647
2892
|
})
|
|
2648
2893
|
).nullish()
|
|
2649
2894
|
});
|
|
2650
|
-
var responseSchema = (0,
|
|
2651
|
-
() => (0,
|
|
2652
|
-
|
|
2653
|
-
responseId:
|
|
2654
|
-
candidates:
|
|
2655
|
-
|
|
2656
|
-
content: getContentSchema().nullish().or(
|
|
2657
|
-
finishReason:
|
|
2658
|
-
finishMessage:
|
|
2659
|
-
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(),
|
|
2660
2905
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2661
2906
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2662
2907
|
})
|
|
2663
2908
|
),
|
|
2664
2909
|
usageMetadata: usageSchema.nullish(),
|
|
2665
|
-
promptFeedback:
|
|
2666
|
-
blockReason:
|
|
2667
|
-
safetyRatings:
|
|
2910
|
+
promptFeedback: import_v47.z.object({
|
|
2911
|
+
blockReason: import_v47.z.string().nullish(),
|
|
2912
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish()
|
|
2668
2913
|
}).nullish()
|
|
2669
2914
|
})
|
|
2670
2915
|
)
|
|
2671
2916
|
);
|
|
2672
|
-
var chunkSchema = (0,
|
|
2673
|
-
() => (0,
|
|
2674
|
-
|
|
2675
|
-
responseId:
|
|
2676
|
-
candidates:
|
|
2677
|
-
|
|
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({
|
|
2678
2923
|
content: getContentSchema().nullish(),
|
|
2679
|
-
finishReason:
|
|
2680
|
-
finishMessage:
|
|
2681
|
-
safetyRatings:
|
|
2924
|
+
finishReason: import_v47.z.string().nullish(),
|
|
2925
|
+
finishMessage: import_v47.z.string().nullish(),
|
|
2926
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish(),
|
|
2682
2927
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
2683
2928
|
urlContextMetadata: getUrlContextMetadataSchema().nullish()
|
|
2684
2929
|
})
|
|
2685
2930
|
).nullish(),
|
|
2686
2931
|
usageMetadata: usageSchema.nullish(),
|
|
2687
|
-
promptFeedback:
|
|
2688
|
-
blockReason:
|
|
2689
|
-
safetyRatings:
|
|
2932
|
+
promptFeedback: import_v47.z.object({
|
|
2933
|
+
blockReason: import_v47.z.string().nullish(),
|
|
2934
|
+
safetyRatings: import_v47.z.array(getSafetyRatingSchema()).nullish()
|
|
2690
2935
|
}).nullish()
|
|
2691
2936
|
})
|
|
2692
2937
|
)
|
|
2693
2938
|
);
|
|
2694
2939
|
|
|
2695
2940
|
// src/tool/code-execution.ts
|
|
2696
|
-
var
|
|
2697
|
-
var
|
|
2698
|
-
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)({
|
|
2699
2944
|
id: "google.code_execution",
|
|
2700
|
-
inputSchema:
|
|
2701
|
-
language:
|
|
2702
|
-
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.")
|
|
2703
2948
|
}),
|
|
2704
|
-
outputSchema:
|
|
2705
|
-
outcome:
|
|
2706
|
-
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.")
|
|
2707
2952
|
})
|
|
2708
2953
|
});
|
|
2709
2954
|
|
|
2710
2955
|
// src/tool/enterprise-web-search.ts
|
|
2711
|
-
var
|
|
2712
|
-
var
|
|
2713
|
-
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)({
|
|
2714
2959
|
id: "google.enterprise_web_search",
|
|
2715
|
-
inputSchema: (0,
|
|
2960
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v49.z.object({})))
|
|
2716
2961
|
});
|
|
2717
2962
|
|
|
2718
2963
|
// src/tool/file-search.ts
|
|
2719
|
-
var
|
|
2720
|
-
var
|
|
2721
|
-
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({
|
|
2722
2967
|
/** The names of the file_search_stores to retrieve from.
|
|
2723
2968
|
* Example: `fileSearchStores/my-file-search-store-123`
|
|
2724
2969
|
*/
|
|
2725
|
-
fileSearchStoreNames:
|
|
2970
|
+
fileSearchStoreNames: import_v410.z.array(import_v410.z.string()).describe(
|
|
2726
2971
|
"The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"
|
|
2727
2972
|
),
|
|
2728
2973
|
/** The number of file search retrieval chunks to retrieve. */
|
|
2729
|
-
topK:
|
|
2974
|
+
topK: import_v410.z.number().int().positive().describe("The number of file search retrieval chunks to retrieve.").optional(),
|
|
2730
2975
|
/** Metadata filter to apply to the file search retrieval documents.
|
|
2731
2976
|
* See https://google.aip.dev/160 for the syntax of the filter expression.
|
|
2732
2977
|
*/
|
|
2733
|
-
metadataFilter:
|
|
2978
|
+
metadataFilter: import_v410.z.string().describe(
|
|
2734
2979
|
"Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
|
|
2735
2980
|
).optional()
|
|
2736
2981
|
}).passthrough();
|
|
2737
|
-
var fileSearchArgsSchema = (0,
|
|
2738
|
-
() => (0,
|
|
2982
|
+
var fileSearchArgsSchema = (0, import_provider_utils10.lazySchema)(
|
|
2983
|
+
() => (0, import_provider_utils10.zodSchema)(fileSearchArgsBaseSchema)
|
|
2739
2984
|
);
|
|
2740
|
-
var fileSearch = (0,
|
|
2985
|
+
var fileSearch = (0, import_provider_utils10.createProviderToolFactory)({
|
|
2741
2986
|
id: "google.file_search",
|
|
2742
2987
|
inputSchema: fileSearchArgsSchema
|
|
2743
2988
|
});
|
|
2744
2989
|
|
|
2745
2990
|
// src/tool/google-maps.ts
|
|
2746
|
-
var
|
|
2747
|
-
var
|
|
2748
|
-
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)({
|
|
2749
2994
|
id: "google.google_maps",
|
|
2750
|
-
inputSchema: (0,
|
|
2995
|
+
inputSchema: (0, import_provider_utils11.lazySchema)(() => (0, import_provider_utils11.zodSchema)(import_v411.z.object({})))
|
|
2751
2996
|
});
|
|
2752
2997
|
|
|
2753
2998
|
// src/tool/google-search.ts
|
|
2754
|
-
var
|
|
2755
|
-
var
|
|
2756
|
-
var googleSearchToolArgsBaseSchema =
|
|
2757
|
-
searchTypes:
|
|
2758
|
-
webSearch:
|
|
2759
|
-
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()
|
|
2760
3005
|
}).optional(),
|
|
2761
|
-
timeRangeFilter:
|
|
2762
|
-
startTime:
|
|
2763
|
-
endTime:
|
|
3006
|
+
timeRangeFilter: import_v412.z.object({
|
|
3007
|
+
startTime: import_v412.z.string(),
|
|
3008
|
+
endTime: import_v412.z.string()
|
|
2764
3009
|
}).optional()
|
|
2765
3010
|
}).passthrough();
|
|
2766
|
-
var googleSearchToolArgsSchema = (0,
|
|
2767
|
-
() => (0,
|
|
3011
|
+
var googleSearchToolArgsSchema = (0, import_provider_utils12.lazySchema)(
|
|
3012
|
+
() => (0, import_provider_utils12.zodSchema)(googleSearchToolArgsBaseSchema)
|
|
2768
3013
|
);
|
|
2769
|
-
var googleSearch = (0,
|
|
3014
|
+
var googleSearch = (0, import_provider_utils12.createProviderToolFactory)(
|
|
2770
3015
|
{
|
|
2771
3016
|
id: "google.google_search",
|
|
2772
3017
|
inputSchema: googleSearchToolArgsSchema
|
|
@@ -2774,21 +3019,21 @@ var googleSearch = (0, import_provider_utils11.createProviderToolFactory)(
|
|
|
2774
3019
|
);
|
|
2775
3020
|
|
|
2776
3021
|
// src/tool/url-context.ts
|
|
2777
|
-
var
|
|
2778
|
-
var
|
|
2779
|
-
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)({
|
|
2780
3025
|
id: "google.url_context",
|
|
2781
|
-
inputSchema: (0,
|
|
3026
|
+
inputSchema: (0, import_provider_utils13.lazySchema)(() => (0, import_provider_utils13.zodSchema)(import_v413.z.object({})))
|
|
2782
3027
|
});
|
|
2783
3028
|
|
|
2784
3029
|
// src/tool/vertex-rag-store.ts
|
|
2785
|
-
var
|
|
2786
|
-
var
|
|
2787
|
-
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)({
|
|
2788
3033
|
id: "google.vertex_rag_store",
|
|
2789
|
-
inputSchema:
|
|
2790
|
-
ragCorpus:
|
|
2791
|
-
topK:
|
|
3034
|
+
inputSchema: import_v414.z.object({
|
|
3035
|
+
ragCorpus: import_v414.z.string(),
|
|
3036
|
+
topK: import_v414.z.number().optional()
|
|
2792
3037
|
})
|
|
2793
3038
|
});
|
|
2794
3039
|
|
|
@@ -2853,8 +3098,8 @@ var googleTools = {
|
|
|
2853
3098
|
};
|
|
2854
3099
|
|
|
2855
3100
|
// src/google-generative-ai-image-model.ts
|
|
2856
|
-
var
|
|
2857
|
-
var
|
|
3101
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
3102
|
+
var import_v415 = require("zod/v4");
|
|
2858
3103
|
var GoogleGenerativeAIImageModel = class {
|
|
2859
3104
|
constructor(modelId, settings, config) {
|
|
2860
3105
|
this.modelId = modelId;
|
|
@@ -2919,7 +3164,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2919
3164
|
details: "This model does not support the `seed` option through this provider."
|
|
2920
3165
|
});
|
|
2921
3166
|
}
|
|
2922
|
-
const googleOptions = await (0,
|
|
3167
|
+
const googleOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
2923
3168
|
provider: "google",
|
|
2924
3169
|
providerOptions,
|
|
2925
3170
|
schema: googleImageModelOptionsSchema
|
|
@@ -2946,12 +3191,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2946
3191
|
instances: [{ prompt }],
|
|
2947
3192
|
parameters
|
|
2948
3193
|
};
|
|
2949
|
-
const { responseHeaders, value: response } = await (0,
|
|
3194
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
|
|
2950
3195
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
2951
|
-
headers: (0,
|
|
3196
|
+
headers: (0, import_provider_utils15.combineHeaders)(await (0, import_provider_utils15.resolve)(this.config.headers), headers),
|
|
2952
3197
|
body,
|
|
2953
3198
|
failedResponseHandler: googleFailedResponseHandler,
|
|
2954
|
-
successfulResponseHandler: (0,
|
|
3199
|
+
successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
|
|
2955
3200
|
googleImageResponseSchema
|
|
2956
3201
|
),
|
|
2957
3202
|
abortSignal,
|
|
@@ -3032,7 +3277,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3032
3277
|
const languageModelPrompt = [
|
|
3033
3278
|
{ role: "user", content: userContent }
|
|
3034
3279
|
];
|
|
3035
|
-
const googleImageOptions = await (0,
|
|
3280
|
+
const googleImageOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
3036
3281
|
provider: "google",
|
|
3037
3282
|
providerOptions,
|
|
3038
3283
|
schema: googleImageModelOptionsSchema
|
|
@@ -3043,7 +3288,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3043
3288
|
baseURL: this.config.baseURL,
|
|
3044
3289
|
headers: (_b = this.config.headers) != null ? _b : {},
|
|
3045
3290
|
fetch: this.config.fetch,
|
|
3046
|
-
generateId: (_c = this.config.generateId) != null ? _c :
|
|
3291
|
+
generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils15.generateId
|
|
3047
3292
|
});
|
|
3048
3293
|
const result = await languageModel.doGenerate({
|
|
3049
3294
|
prompt: languageModelPrompt,
|
|
@@ -3072,7 +3317,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3072
3317
|
const images = [];
|
|
3073
3318
|
for (const part of result.content) {
|
|
3074
3319
|
if (part.type === "file" && part.mediaType.startsWith("image/")) {
|
|
3075
|
-
images.push((0,
|
|
3320
|
+
images.push((0, import_provider_utils15.convertToBase64)(part.data));
|
|
3076
3321
|
}
|
|
3077
3322
|
}
|
|
3078
3323
|
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
@@ -3101,18 +3346,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
3101
3346
|
function isGeminiModel(modelId) {
|
|
3102
3347
|
return modelId.startsWith("gemini-");
|
|
3103
3348
|
}
|
|
3104
|
-
var googleImageResponseSchema = (0,
|
|
3105
|
-
() => (0,
|
|
3106
|
-
|
|
3107
|
-
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([])
|
|
3108
3353
|
})
|
|
3109
3354
|
)
|
|
3110
3355
|
);
|
|
3111
|
-
var googleImageModelOptionsSchema = (0,
|
|
3112
|
-
() => (0,
|
|
3113
|
-
|
|
3114
|
-
personGeneration:
|
|
3115
|
-
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(),
|
|
3116
3361
|
/**
|
|
3117
3362
|
* Enable Google Search grounding for Gemini image models. The value is
|
|
3118
3363
|
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
@@ -3128,9 +3373,9 @@ var googleImageModelOptionsSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
3128
3373
|
);
|
|
3129
3374
|
|
|
3130
3375
|
// src/google-generative-ai-video-model.ts
|
|
3131
|
-
var
|
|
3132
|
-
var
|
|
3133
|
-
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");
|
|
3134
3379
|
function getFirstFrameImage(options) {
|
|
3135
3380
|
var _a, _b;
|
|
3136
3381
|
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
@@ -3164,7 +3409,7 @@ function convertFileToGoogleImage(file, warnings) {
|
|
|
3164
3409
|
});
|
|
3165
3410
|
return void 0;
|
|
3166
3411
|
}
|
|
3167
|
-
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);
|
|
3168
3413
|
return {
|
|
3169
3414
|
bytesBase64Encoded: base64Data,
|
|
3170
3415
|
mimeType: file.mediaType || "image/png"
|
|
@@ -3209,7 +3454,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3209
3454
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3210
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();
|
|
3211
3456
|
const warnings = [];
|
|
3212
|
-
const googleOptions = await (0,
|
|
3457
|
+
const googleOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
3213
3458
|
provider: "google",
|
|
3214
3459
|
providerOptions: options.providerOptions,
|
|
3215
3460
|
schema: googleVideoModelOptionsSchema
|
|
@@ -3284,17 +3529,17 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3284
3529
|
}
|
|
3285
3530
|
}
|
|
3286
3531
|
}
|
|
3287
|
-
const { value: operation } = await (0,
|
|
3532
|
+
const { value: operation } = await (0, import_provider_utils16.postJsonToApi)({
|
|
3288
3533
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
3289
|
-
headers: (0,
|
|
3290
|
-
await (0,
|
|
3534
|
+
headers: (0, import_provider_utils16.combineHeaders)(
|
|
3535
|
+
await (0, import_provider_utils16.resolve)(this.config.headers),
|
|
3291
3536
|
options.headers
|
|
3292
3537
|
),
|
|
3293
3538
|
body: {
|
|
3294
3539
|
instances,
|
|
3295
3540
|
parameters
|
|
3296
3541
|
},
|
|
3297
|
-
successfulResponseHandler: (0,
|
|
3542
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3298
3543
|
googleOperationSchema
|
|
3299
3544
|
),
|
|
3300
3545
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3303,7 +3548,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3303
3548
|
});
|
|
3304
3549
|
const operationName = operation.name;
|
|
3305
3550
|
if (!operationName) {
|
|
3306
|
-
throw new
|
|
3551
|
+
throw new import_provider6.AISDKError({
|
|
3307
3552
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
3308
3553
|
message: "No operation name returned from API"
|
|
3309
3554
|
});
|
|
@@ -3315,25 +3560,25 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3315
3560
|
let responseHeaders;
|
|
3316
3561
|
while (!finalOperation.done) {
|
|
3317
3562
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
3318
|
-
throw new
|
|
3563
|
+
throw new import_provider6.AISDKError({
|
|
3319
3564
|
name: "GOOGLE_VIDEO_GENERATION_TIMEOUT",
|
|
3320
3565
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
3321
3566
|
});
|
|
3322
3567
|
}
|
|
3323
|
-
await (0,
|
|
3568
|
+
await (0, import_provider_utils16.delay)(pollIntervalMs);
|
|
3324
3569
|
if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
|
|
3325
|
-
throw new
|
|
3570
|
+
throw new import_provider6.AISDKError({
|
|
3326
3571
|
name: "GOOGLE_VIDEO_GENERATION_ABORTED",
|
|
3327
3572
|
message: "Video generation request was aborted"
|
|
3328
3573
|
});
|
|
3329
3574
|
}
|
|
3330
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await (0,
|
|
3575
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils16.getFromApi)({
|
|
3331
3576
|
url: `${this.config.baseURL}/${operationName}`,
|
|
3332
|
-
headers: (0,
|
|
3333
|
-
await (0,
|
|
3577
|
+
headers: (0, import_provider_utils16.combineHeaders)(
|
|
3578
|
+
await (0, import_provider_utils16.resolve)(this.config.headers),
|
|
3334
3579
|
options.headers
|
|
3335
3580
|
),
|
|
3336
|
-
successfulResponseHandler: (0,
|
|
3581
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3337
3582
|
googleOperationSchema
|
|
3338
3583
|
),
|
|
3339
3584
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -3344,25 +3589,25 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3344
3589
|
responseHeaders = pollHeaders;
|
|
3345
3590
|
}
|
|
3346
3591
|
if (finalOperation.error) {
|
|
3347
|
-
throw new
|
|
3592
|
+
throw new import_provider6.AISDKError({
|
|
3348
3593
|
name: "GOOGLE_VIDEO_GENERATION_FAILED",
|
|
3349
3594
|
message: `Video generation failed: ${finalOperation.error.message}`
|
|
3350
3595
|
});
|
|
3351
3596
|
}
|
|
3352
3597
|
const response = finalOperation.response;
|
|
3353
3598
|
if (!((_g = response == null ? void 0 : response.generateVideoResponse) == null ? void 0 : _g.generatedSamples) || response.generateVideoResponse.generatedSamples.length === 0) {
|
|
3354
|
-
throw new
|
|
3599
|
+
throw new import_provider6.AISDKError({
|
|
3355
3600
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
3356
3601
|
message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
|
|
3357
3602
|
});
|
|
3358
3603
|
}
|
|
3359
3604
|
const videos = [];
|
|
3360
3605
|
const videoMetadata = [];
|
|
3361
|
-
const resolvedHeaders = await (0,
|
|
3606
|
+
const resolvedHeaders = await (0, import_provider_utils16.resolve)(this.config.headers);
|
|
3362
3607
|
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
3363
3608
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
3364
3609
|
if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
3365
|
-
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;
|
|
3366
3611
|
videos.push({
|
|
3367
3612
|
type: "url",
|
|
3368
3613
|
url: urlWithAuth,
|
|
@@ -3374,7 +3619,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3374
3619
|
}
|
|
3375
3620
|
}
|
|
3376
3621
|
if (videos.length === 0) {
|
|
3377
|
-
throw new
|
|
3622
|
+
throw new import_provider6.AISDKError({
|
|
3378
3623
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
3379
3624
|
message: "No valid videos in response"
|
|
3380
3625
|
});
|
|
@@ -3395,37 +3640,37 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3395
3640
|
};
|
|
3396
3641
|
}
|
|
3397
3642
|
};
|
|
3398
|
-
var googleOperationSchema =
|
|
3399
|
-
name:
|
|
3400
|
-
done:
|
|
3401
|
-
error:
|
|
3402
|
-
code:
|
|
3403
|
-
message:
|
|
3404
|
-
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()
|
|
3405
3650
|
}).nullish(),
|
|
3406
|
-
response:
|
|
3407
|
-
generateVideoResponse:
|
|
3408
|
-
generatedSamples:
|
|
3409
|
-
|
|
3410
|
-
video:
|
|
3411
|
-
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()
|
|
3412
3657
|
}).nullish()
|
|
3413
3658
|
})
|
|
3414
3659
|
).nullish()
|
|
3415
3660
|
}).nullish()
|
|
3416
3661
|
}).nullish()
|
|
3417
3662
|
});
|
|
3418
|
-
var googleVideoModelOptionsSchema = (0,
|
|
3419
|
-
() => (0,
|
|
3420
|
-
|
|
3421
|
-
pollIntervalMs:
|
|
3422
|
-
pollTimeoutMs:
|
|
3423
|
-
personGeneration:
|
|
3424
|
-
negativePrompt:
|
|
3425
|
-
referenceImages:
|
|
3426
|
-
|
|
3427
|
-
bytesBase64Encoded:
|
|
3428
|
-
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()
|
|
3429
3674
|
})
|
|
3430
3675
|
).nullish()
|
|
3431
3676
|
}).passthrough()
|
|
@@ -3433,7 +3678,7 @@ var googleVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
|
|
|
3433
3678
|
);
|
|
3434
3679
|
|
|
3435
3680
|
// src/interactions/google-interactions-language-model.ts
|
|
3436
|
-
var
|
|
3681
|
+
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
3437
3682
|
|
|
3438
3683
|
// src/interactions/convert-google-interactions-usage.ts
|
|
3439
3684
|
function convertGoogleInteractionsUsage(usage) {
|
|
@@ -4199,7 +4444,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4199
4444
|
}
|
|
4200
4445
|
|
|
4201
4446
|
// src/interactions/convert-to-google-interactions-input.ts
|
|
4202
|
-
var
|
|
4447
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
4203
4448
|
function getTopLevelMediaType(mediaType) {
|
|
4204
4449
|
const slashIndex = mediaType.indexOf("/");
|
|
4205
4450
|
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
|
|
@@ -4388,7 +4633,7 @@ function convertFilePartToContent({
|
|
|
4388
4633
|
}
|
|
4389
4634
|
return {
|
|
4390
4635
|
type: kind,
|
|
4391
|
-
data: (0,
|
|
4636
|
+
data: (0, import_provider_utils17.convertToBase64)(part.data),
|
|
4392
4637
|
mime_type: part.mediaType,
|
|
4393
4638
|
...resolutionField
|
|
4394
4639
|
};
|
|
@@ -4439,7 +4684,7 @@ function compactPromptForPreviousInteraction({
|
|
|
4439
4684
|
}
|
|
4440
4685
|
function safeParseToolArgs(input) {
|
|
4441
4686
|
try {
|
|
4442
|
-
const parsed = (0,
|
|
4687
|
+
const parsed = (0, import_provider_utils17.secureJsonParse)(input);
|
|
4443
4688
|
if (parsed != null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
4444
4689
|
return parsed;
|
|
4445
4690
|
}
|
|
@@ -4562,7 +4807,7 @@ function filePartToImageBlock({
|
|
|
4562
4807
|
}
|
|
4563
4808
|
return {
|
|
4564
4809
|
type: "image",
|
|
4565
|
-
data: (0,
|
|
4810
|
+
data: (0, import_provider_utils17.convertToBase64)(part.data),
|
|
4566
4811
|
mime_type: part.mediaType
|
|
4567
4812
|
};
|
|
4568
4813
|
}
|
|
@@ -4589,31 +4834,31 @@ ${block.text}`
|
|
|
4589
4834
|
}
|
|
4590
4835
|
|
|
4591
4836
|
// src/interactions/google-interactions-api.ts
|
|
4592
|
-
var
|
|
4593
|
-
var
|
|
4594
|
-
var tokenByModalitySchema = () =>
|
|
4595
|
-
modality:
|
|
4596
|
-
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()
|
|
4597
4842
|
}).loose();
|
|
4598
|
-
var usageSchema2 = () =>
|
|
4599
|
-
total_input_tokens:
|
|
4600
|
-
total_output_tokens:
|
|
4601
|
-
total_thought_tokens:
|
|
4602
|
-
total_cached_tokens:
|
|
4603
|
-
total_tool_use_tokens:
|
|
4604
|
-
total_tokens:
|
|
4605
|
-
input_tokens_by_modality:
|
|
4606
|
-
output_tokens_by_modality:
|
|
4607
|
-
cached_tokens_by_modality:
|
|
4608
|
-
tool_use_tokens_by_modality:
|
|
4609
|
-
grounding_tool_count:
|
|
4610
|
-
|
|
4611
|
-
type:
|
|
4612
|
-
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()
|
|
4613
4858
|
}).loose()
|
|
4614
4859
|
).nullish()
|
|
4615
4860
|
}).loose();
|
|
4616
|
-
var interactionStatusSchema = () =>
|
|
4861
|
+
var interactionStatusSchema = () => import_v417.z.enum([
|
|
4617
4862
|
"in_progress",
|
|
4618
4863
|
"requires_action",
|
|
4619
4864
|
"completed",
|
|
@@ -4622,69 +4867,69 @@ var interactionStatusSchema = () => import_v415.z.enum([
|
|
|
4622
4867
|
"incomplete"
|
|
4623
4868
|
]);
|
|
4624
4869
|
var annotationSchema = () => {
|
|
4625
|
-
const urlCitation =
|
|
4626
|
-
type:
|
|
4627
|
-
url:
|
|
4628
|
-
title:
|
|
4629
|
-
start_index:
|
|
4630
|
-
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()
|
|
4631
4876
|
}).loose();
|
|
4632
|
-
const fileCitation =
|
|
4633
|
-
type:
|
|
4634
|
-
file_name:
|
|
4635
|
-
document_uri:
|
|
4636
|
-
url:
|
|
4637
|
-
page_number:
|
|
4638
|
-
media_id:
|
|
4639
|
-
start_index:
|
|
4640
|
-
end_index:
|
|
4641
|
-
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()
|
|
4642
4887
|
}).loose();
|
|
4643
|
-
const placeCitation =
|
|
4644
|
-
type:
|
|
4645
|
-
name:
|
|
4646
|
-
url:
|
|
4647
|
-
place_id:
|
|
4648
|
-
start_index:
|
|
4649
|
-
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()
|
|
4650
4895
|
}).loose();
|
|
4651
|
-
return
|
|
4896
|
+
return import_v417.z.union([
|
|
4652
4897
|
urlCitation,
|
|
4653
4898
|
fileCitation,
|
|
4654
4899
|
placeCitation,
|
|
4655
|
-
|
|
4900
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
4656
4901
|
]);
|
|
4657
4902
|
};
|
|
4658
|
-
var thoughtSummaryItemSchema = () =>
|
|
4659
|
-
type:
|
|
4660
|
-
text:
|
|
4661
|
-
data:
|
|
4662
|
-
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()
|
|
4663
4908
|
}).loose();
|
|
4664
4909
|
var contentBlockSchema = () => {
|
|
4665
|
-
const textContent =
|
|
4666
|
-
type:
|
|
4667
|
-
text:
|
|
4668
|
-
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()
|
|
4669
4914
|
}).loose();
|
|
4670
|
-
const imageContent =
|
|
4671
|
-
type:
|
|
4672
|
-
data:
|
|
4673
|
-
mime_type:
|
|
4674
|
-
resolution:
|
|
4675
|
-
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()
|
|
4676
4921
|
}).loose();
|
|
4677
|
-
const videoContent =
|
|
4678
|
-
type:
|
|
4679
|
-
data:
|
|
4680
|
-
mime_type:
|
|
4681
|
-
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()
|
|
4682
4927
|
}).loose();
|
|
4683
|
-
return
|
|
4928
|
+
return import_v417.z.union([
|
|
4684
4929
|
textContent,
|
|
4685
4930
|
imageContent,
|
|
4686
4931
|
videoContent,
|
|
4687
|
-
|
|
4932
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
4688
4933
|
]);
|
|
4689
4934
|
};
|
|
4690
4935
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4704,158 +4949,158 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4704
4949
|
"mcp_server_tool_result"
|
|
4705
4950
|
];
|
|
4706
4951
|
var stepSchema = () => {
|
|
4707
|
-
const userInputStep =
|
|
4708
|
-
type:
|
|
4709
|
-
content:
|
|
4952
|
+
const userInputStep = import_v417.z.object({
|
|
4953
|
+
type: import_v417.z.literal("user_input"),
|
|
4954
|
+
content: import_v417.z.array(contentBlockSchema()).nullish()
|
|
4710
4955
|
}).loose();
|
|
4711
|
-
const modelOutputStep =
|
|
4712
|
-
type:
|
|
4713
|
-
content:
|
|
4956
|
+
const modelOutputStep = import_v417.z.object({
|
|
4957
|
+
type: import_v417.z.literal("model_output"),
|
|
4958
|
+
content: import_v417.z.array(contentBlockSchema()).nullish()
|
|
4714
4959
|
}).loose();
|
|
4715
|
-
const functionCallStep =
|
|
4716
|
-
type:
|
|
4717
|
-
id:
|
|
4718
|
-
name:
|
|
4719
|
-
arguments:
|
|
4720
|
-
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()
|
|
4721
4966
|
}).loose();
|
|
4722
|
-
const thoughtStep =
|
|
4723
|
-
type:
|
|
4724
|
-
signature:
|
|
4725
|
-
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()
|
|
4726
4971
|
}).loose();
|
|
4727
|
-
const builtinToolCallStep =
|
|
4728
|
-
type:
|
|
4729
|
-
id:
|
|
4730
|
-
arguments:
|
|
4731
|
-
name:
|
|
4732
|
-
server_name:
|
|
4733
|
-
search_type:
|
|
4734
|
-
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()
|
|
4735
4980
|
}).loose();
|
|
4736
|
-
const builtinToolResultStep =
|
|
4737
|
-
type:
|
|
4738
|
-
call_id:
|
|
4739
|
-
result:
|
|
4740
|
-
is_error:
|
|
4741
|
-
name:
|
|
4742
|
-
server_name:
|
|
4743
|
-
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()
|
|
4744
4989
|
}).loose();
|
|
4745
|
-
return
|
|
4990
|
+
return import_v417.z.union([
|
|
4746
4991
|
userInputStep,
|
|
4747
4992
|
modelOutputStep,
|
|
4748
4993
|
functionCallStep,
|
|
4749
4994
|
thoughtStep,
|
|
4750
4995
|
builtinToolCallStep,
|
|
4751
4996
|
builtinToolResultStep,
|
|
4752
|
-
|
|
4997
|
+
import_v417.z.object({ type: import_v417.z.string() }).loose()
|
|
4753
4998
|
]);
|
|
4754
4999
|
};
|
|
4755
|
-
var googleInteractionsResponseSchema = (0,
|
|
4756
|
-
() => (0,
|
|
4757
|
-
|
|
5000
|
+
var googleInteractionsResponseSchema = (0, import_provider_utils18.lazySchema)(
|
|
5001
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
5002
|
+
import_v417.z.object({
|
|
4758
5003
|
/*
|
|
4759
5004
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4760
5005
|
* stateless mode) — there is no server-side interaction record for the
|
|
4761
5006
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4762
5007
|
*/
|
|
4763
|
-
id:
|
|
4764
|
-
created:
|
|
4765
|
-
updated:
|
|
5008
|
+
id: import_v417.z.string().nullish(),
|
|
5009
|
+
created: import_v417.z.string().nullish(),
|
|
5010
|
+
updated: import_v417.z.string().nullish(),
|
|
4766
5011
|
status: interactionStatusSchema(),
|
|
4767
|
-
model:
|
|
4768
|
-
agent:
|
|
4769
|
-
steps:
|
|
5012
|
+
model: import_v417.z.string().nullish(),
|
|
5013
|
+
agent: import_v417.z.string().nullish(),
|
|
5014
|
+
steps: import_v417.z.array(stepSchema()).nullish(),
|
|
4770
5015
|
usage: usageSchema2().nullish(),
|
|
4771
|
-
service_tier:
|
|
4772
|
-
previous_interaction_id:
|
|
4773
|
-
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()
|
|
4774
5019
|
}).loose()
|
|
4775
5020
|
)
|
|
4776
5021
|
);
|
|
4777
|
-
var googleInteractionsEventSchema = (0,
|
|
4778
|
-
() => (0,
|
|
5022
|
+
var googleInteractionsEventSchema = (0, import_provider_utils18.lazySchema)(
|
|
5023
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
4779
5024
|
(() => {
|
|
4780
5025
|
const status = interactionStatusSchema();
|
|
4781
5026
|
const annotation = annotationSchema();
|
|
4782
5027
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4783
|
-
const interactionCreatedEvent =
|
|
4784
|
-
event_type:
|
|
4785
|
-
event_id:
|
|
4786
|
-
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({
|
|
4787
5032
|
/*
|
|
4788
5033
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4789
5034
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4790
5035
|
*/
|
|
4791
|
-
id:
|
|
4792
|
-
created:
|
|
4793
|
-
model:
|
|
4794
|
-
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(),
|
|
4795
5040
|
status: status.nullish()
|
|
4796
5041
|
}).loose()
|
|
4797
5042
|
}).loose();
|
|
4798
|
-
const stepStartEvent =
|
|
4799
|
-
event_type:
|
|
4800
|
-
event_id:
|
|
4801
|
-
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(),
|
|
4802
5047
|
step: stepSchema()
|
|
4803
5048
|
}).loose();
|
|
4804
|
-
const stepDeltaText =
|
|
4805
|
-
type:
|
|
4806
|
-
text:
|
|
5049
|
+
const stepDeltaText = import_v417.z.object({
|
|
5050
|
+
type: import_v417.z.literal("text"),
|
|
5051
|
+
text: import_v417.z.string()
|
|
4807
5052
|
}).loose();
|
|
4808
|
-
const stepDeltaThoughtSummary =
|
|
4809
|
-
type:
|
|
5053
|
+
const stepDeltaThoughtSummary = import_v417.z.object({
|
|
5054
|
+
type: import_v417.z.literal("thought_summary"),
|
|
4810
5055
|
content: thoughtSummaryItem.nullish()
|
|
4811
5056
|
}).loose();
|
|
4812
|
-
const stepDeltaThoughtSignature =
|
|
4813
|
-
type:
|
|
4814
|
-
signature:
|
|
5057
|
+
const stepDeltaThoughtSignature = import_v417.z.object({
|
|
5058
|
+
type: import_v417.z.literal("thought_signature"),
|
|
5059
|
+
signature: import_v417.z.string().nullish()
|
|
4815
5060
|
}).loose();
|
|
4816
|
-
const stepDeltaArgumentsDelta =
|
|
4817
|
-
type:
|
|
4818
|
-
arguments:
|
|
4819
|
-
id:
|
|
4820
|
-
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()
|
|
4821
5066
|
}).loose();
|
|
4822
|
-
const stepDeltaTextAnnotation =
|
|
4823
|
-
type:
|
|
4824
|
-
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()
|
|
4825
5070
|
}).loose();
|
|
4826
|
-
const stepDeltaImage =
|
|
4827
|
-
type:
|
|
4828
|
-
data:
|
|
4829
|
-
mime_type:
|
|
4830
|
-
resolution:
|
|
4831
|
-
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()
|
|
4832
5077
|
}).loose();
|
|
4833
|
-
const stepDeltaVideo =
|
|
4834
|
-
type:
|
|
4835
|
-
data:
|
|
4836
|
-
mime_type:
|
|
4837
|
-
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()
|
|
4838
5083
|
}).loose();
|
|
4839
|
-
const stepDeltaBuiltinToolCall =
|
|
4840
|
-
type:
|
|
4841
|
-
id:
|
|
4842
|
-
arguments:
|
|
4843
|
-
name:
|
|
4844
|
-
server_name:
|
|
4845
|
-
search_type:
|
|
4846
|
-
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()
|
|
4847
5092
|
}).loose();
|
|
4848
|
-
const stepDeltaBuiltinToolResult =
|
|
4849
|
-
type:
|
|
4850
|
-
call_id:
|
|
4851
|
-
result:
|
|
4852
|
-
is_error:
|
|
4853
|
-
name:
|
|
4854
|
-
server_name:
|
|
4855
|
-
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()
|
|
4856
5101
|
}).loose();
|
|
4857
|
-
const stepDeltaUnknown =
|
|
4858
|
-
const stepDeltaUnion =
|
|
5102
|
+
const stepDeltaUnknown = import_v417.z.object({ type: import_v417.z.string() }).loose();
|
|
5103
|
+
const stepDeltaUnion = import_v417.z.union([
|
|
4859
5104
|
stepDeltaText,
|
|
4860
5105
|
stepDeltaImage,
|
|
4861
5106
|
stepDeltaVideo,
|
|
@@ -4867,55 +5112,55 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4867
5112
|
stepDeltaBuiltinToolResult,
|
|
4868
5113
|
stepDeltaUnknown
|
|
4869
5114
|
]);
|
|
4870
|
-
const stepDeltaEvent =
|
|
4871
|
-
event_type:
|
|
4872
|
-
event_id:
|
|
4873
|
-
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(),
|
|
4874
5119
|
delta: stepDeltaUnion
|
|
4875
5120
|
}).loose();
|
|
4876
|
-
const stepStopEvent =
|
|
4877
|
-
event_type:
|
|
4878
|
-
event_id:
|
|
4879
|
-
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()
|
|
4880
5125
|
}).loose();
|
|
4881
|
-
const interactionStatusUpdateEvent =
|
|
4882
|
-
event_type:
|
|
4883
|
-
event_id:
|
|
4884
|
-
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(),
|
|
4885
5130
|
status: status.nullish()
|
|
4886
5131
|
}).loose();
|
|
4887
|
-
const interactionInProgressEvent =
|
|
4888
|
-
event_type:
|
|
4889
|
-
event_id:
|
|
4890
|
-
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(),
|
|
4891
5136
|
status: status.nullish()
|
|
4892
5137
|
}).loose();
|
|
4893
|
-
const interactionRequiresActionEvent =
|
|
4894
|
-
event_type:
|
|
4895
|
-
event_id:
|
|
4896
|
-
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(),
|
|
4897
5142
|
status: status.nullish()
|
|
4898
5143
|
}).loose();
|
|
4899
|
-
const interactionCompletedEvent =
|
|
4900
|
-
event_type:
|
|
4901
|
-
event_id:
|
|
4902
|
-
interaction:
|
|
4903
|
-
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(),
|
|
4904
5149
|
status: status.nullish(),
|
|
4905
5150
|
usage: usageSchema2().nullish(),
|
|
4906
|
-
service_tier:
|
|
5151
|
+
service_tier: import_v417.z.string().nullish()
|
|
4907
5152
|
}).loose()
|
|
4908
5153
|
}).loose();
|
|
4909
|
-
const errorEvent =
|
|
4910
|
-
event_type:
|
|
4911
|
-
event_id:
|
|
4912
|
-
error:
|
|
4913
|
-
code:
|
|
4914
|
-
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()
|
|
4915
5160
|
}).loose().nullish()
|
|
4916
5161
|
}).loose();
|
|
4917
|
-
const unknownEvent =
|
|
4918
|
-
return
|
|
5162
|
+
const unknownEvent = import_v417.z.object({ event_type: import_v417.z.string() }).loose();
|
|
5163
|
+
return import_v417.z.union([
|
|
4919
5164
|
interactionCreatedEvent,
|
|
4920
5165
|
stepStartEvent,
|
|
4921
5166
|
stepDeltaEvent,
|
|
@@ -4932,27 +5177,27 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4932
5177
|
);
|
|
4933
5178
|
|
|
4934
5179
|
// src/interactions/google-interactions-language-model-options.ts
|
|
4935
|
-
var
|
|
4936
|
-
var
|
|
4937
|
-
var googleInteractionsLanguageModelOptions = (0,
|
|
4938
|
-
() => (0,
|
|
4939
|
-
|
|
4940
|
-
previousInteractionId:
|
|
4941
|
-
store:
|
|
4942
|
-
agent:
|
|
4943
|
-
agentConfig:
|
|
4944
|
-
|
|
4945
|
-
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")
|
|
4946
5191
|
}).loose(),
|
|
4947
|
-
|
|
4948
|
-
type:
|
|
4949
|
-
thinkingSummaries:
|
|
4950
|
-
visualization:
|
|
4951
|
-
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()
|
|
4952
5197
|
})
|
|
4953
5198
|
]).nullish(),
|
|
4954
|
-
thinkingLevel:
|
|
4955
|
-
thinkingSummaries:
|
|
5199
|
+
thinkingLevel: import_v418.z.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5200
|
+
thinkingSummaries: import_v418.z.enum(["auto", "none"]).nullish(),
|
|
4956
5201
|
/**
|
|
4957
5202
|
* Output-format entries that map directly to the API's `response_format`
|
|
4958
5203
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -4962,17 +5207,17 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4962
5207
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
4963
5208
|
* text entry automatically; entries listed here are appended.
|
|
4964
5209
|
*/
|
|
4965
|
-
responseFormat:
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
type:
|
|
4969
|
-
mimeType:
|
|
4970
|
-
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()
|
|
4971
5216
|
}).loose(),
|
|
4972
|
-
|
|
4973
|
-
type:
|
|
4974
|
-
mimeType:
|
|
4975
|
-
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([
|
|
4976
5221
|
"1:1",
|
|
4977
5222
|
"2:3",
|
|
4978
5223
|
"3:2",
|
|
@@ -4988,11 +5233,11 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4988
5233
|
"1:4",
|
|
4989
5234
|
"4:1"
|
|
4990
5235
|
]).nullish(),
|
|
4991
|
-
imageSize:
|
|
5236
|
+
imageSize: import_v418.z.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
4992
5237
|
}).loose(),
|
|
4993
|
-
|
|
4994
|
-
type:
|
|
4995
|
-
mimeType:
|
|
5238
|
+
import_v418.z.object({
|
|
5239
|
+
type: import_v418.z.literal("audio"),
|
|
5240
|
+
mimeType: import_v418.z.string().nullish()
|
|
4996
5241
|
}).loose()
|
|
4997
5242
|
])
|
|
4998
5243
|
).nullish(),
|
|
@@ -5002,8 +5247,8 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5002
5247
|
* translates it into a matching `response_format` image entry and
|
|
5003
5248
|
* emits a warning when set.
|
|
5004
5249
|
*/
|
|
5005
|
-
imageConfig:
|
|
5006
|
-
aspectRatio:
|
|
5250
|
+
imageConfig: import_v418.z.object({
|
|
5251
|
+
aspectRatio: import_v418.z.enum([
|
|
5007
5252
|
"1:1",
|
|
5008
5253
|
"2:3",
|
|
5009
5254
|
"3:2",
|
|
@@ -5019,35 +5264,35 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5019
5264
|
"1:4",
|
|
5020
5265
|
"4:1"
|
|
5021
5266
|
]).nullish(),
|
|
5022
|
-
imageSize:
|
|
5267
|
+
imageSize: import_v418.z.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5023
5268
|
}).nullish(),
|
|
5024
|
-
mediaResolution:
|
|
5025
|
-
responseModalities:
|
|
5026
|
-
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(),
|
|
5027
5272
|
/**
|
|
5028
5273
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5029
5274
|
* `system` message wins and a warning is emitted.
|
|
5030
5275
|
*/
|
|
5031
|
-
systemInstruction:
|
|
5276
|
+
systemInstruction: import_v418.z.string().nullish(),
|
|
5032
5277
|
/**
|
|
5033
5278
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5034
5279
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5035
5280
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5036
5281
|
* accepts the prior turn.
|
|
5037
5282
|
*/
|
|
5038
|
-
signature:
|
|
5283
|
+
signature: import_v418.z.string().nullish(),
|
|
5039
5284
|
/**
|
|
5040
5285
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5041
5286
|
* decide which messages to drop when compacting under
|
|
5042
5287
|
* `previousInteractionId`.
|
|
5043
5288
|
*/
|
|
5044
|
-
interactionId:
|
|
5289
|
+
interactionId: import_v418.z.string().nullish(),
|
|
5045
5290
|
/**
|
|
5046
5291
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5047
5292
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5048
5293
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5049
5294
|
*/
|
|
5050
|
-
pollingTimeoutMs:
|
|
5295
|
+
pollingTimeoutMs: import_v418.z.number().int().positive().nullish(),
|
|
5051
5296
|
/**
|
|
5052
5297
|
* Run the interaction in the background. Required for agents whose
|
|
5053
5298
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5056,7 +5301,7 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5056
5301
|
* reject `true`; see the agent's documentation for which mode it
|
|
5057
5302
|
* requires.
|
|
5058
5303
|
*/
|
|
5059
|
-
background:
|
|
5304
|
+
background: import_v418.z.boolean().nullish(),
|
|
5060
5305
|
/**
|
|
5061
5306
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5062
5307
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5066,36 +5311,36 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
5066
5311
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5067
5312
|
* and/or constrain outbound traffic via `network`.
|
|
5068
5313
|
*/
|
|
5069
|
-
environment:
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
type:
|
|
5073
|
-
sources:
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
type:
|
|
5077
|
-
source:
|
|
5078
|
-
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()
|
|
5079
5324
|
}),
|
|
5080
|
-
|
|
5081
|
-
type:
|
|
5082
|
-
source:
|
|
5083
|
-
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()
|
|
5084
5329
|
}),
|
|
5085
|
-
|
|
5086
|
-
type:
|
|
5087
|
-
content:
|
|
5088
|
-
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()
|
|
5089
5334
|
})
|
|
5090
5335
|
])
|
|
5091
5336
|
).nullish(),
|
|
5092
|
-
network:
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
allowlist:
|
|
5096
|
-
|
|
5097
|
-
domain:
|
|
5098
|
-
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()
|
|
5099
5344
|
})
|
|
5100
5345
|
)
|
|
5101
5346
|
})
|
|
@@ -5294,10 +5539,10 @@ function parseGoogleInteractionsOutputs({
|
|
|
5294
5539
|
}
|
|
5295
5540
|
|
|
5296
5541
|
// src/interactions/poll-google-interactions.ts
|
|
5297
|
-
var
|
|
5542
|
+
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
5298
5543
|
|
|
5299
5544
|
// src/interactions/cancel-google-interaction.ts
|
|
5300
|
-
var
|
|
5545
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
5301
5546
|
var getOriginalFetch = () => globalThis.fetch;
|
|
5302
5547
|
async function cancelGoogleInteraction({
|
|
5303
5548
|
baseURL,
|
|
@@ -5312,9 +5557,9 @@ async function cancelGoogleInteraction({
|
|
|
5312
5557
|
try {
|
|
5313
5558
|
const response = await fetch(url, {
|
|
5314
5559
|
method: "POST",
|
|
5315
|
-
headers: (0,
|
|
5316
|
-
(0,
|
|
5317
|
-
(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)()
|
|
5318
5563
|
),
|
|
5319
5564
|
body: "{}"
|
|
5320
5565
|
});
|
|
@@ -5364,16 +5609,16 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5364
5609
|
`google.interactions: timed out polling interaction ${interactionId} after ${timeoutMs}ms.`
|
|
5365
5610
|
);
|
|
5366
5611
|
}
|
|
5367
|
-
await (0,
|
|
5612
|
+
await (0, import_provider_utils21.delay)(nextDelayMs, { abortSignal });
|
|
5368
5613
|
const {
|
|
5369
5614
|
value: response,
|
|
5370
5615
|
rawValue: rawResponse,
|
|
5371
5616
|
responseHeaders
|
|
5372
|
-
} = await (0,
|
|
5617
|
+
} = await (0, import_provider_utils21.getFromApi)({
|
|
5373
5618
|
url,
|
|
5374
5619
|
headers,
|
|
5375
5620
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5376
|
-
successfulResponseHandler: (0,
|
|
5621
|
+
successfulResponseHandler: (0, import_provider_utils21.createJsonResponseHandler)(
|
|
5377
5622
|
googleInteractionsResponseSchema
|
|
5378
5623
|
),
|
|
5379
5624
|
abortSignal,
|
|
@@ -5385,7 +5630,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5385
5630
|
nextDelayMs = Math.min(nextDelayMs * 2, maxDelayMs);
|
|
5386
5631
|
}
|
|
5387
5632
|
} catch (error) {
|
|
5388
|
-
if ((0,
|
|
5633
|
+
if ((0, import_provider_utils21.isAbortError)(error)) {
|
|
5389
5634
|
await cancelOnServer();
|
|
5390
5635
|
}
|
|
5391
5636
|
throw error;
|
|
@@ -5541,7 +5786,7 @@ function prepareGoogleInteractionsTools({
|
|
|
5541
5786
|
}
|
|
5542
5787
|
|
|
5543
5788
|
// src/interactions/stream-google-interactions.ts
|
|
5544
|
-
var
|
|
5789
|
+
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
5545
5790
|
var DEFAULT_MAX_RETRIES = 3;
|
|
5546
5791
|
var DEFAULT_RETRY_DELAY_MS = 500;
|
|
5547
5792
|
function streamGoogleInteractionEvents({
|
|
@@ -5588,11 +5833,11 @@ function streamGoogleInteractionEvents({
|
|
|
5588
5833
|
return `${base}?${params.toString()}`;
|
|
5589
5834
|
}
|
|
5590
5835
|
async function openReader() {
|
|
5591
|
-
const { value: stream } = await (0,
|
|
5836
|
+
const { value: stream } = await (0, import_provider_utils22.getFromApi)({
|
|
5592
5837
|
url: buildUrl(),
|
|
5593
5838
|
headers: eventSourceHeaders,
|
|
5594
5839
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5595
|
-
successfulResponseHandler: (0,
|
|
5840
|
+
successfulResponseHandler: (0, import_provider_utils22.createEventSourceResponseHandler)(
|
|
5596
5841
|
googleInteractionsEventSchema
|
|
5597
5842
|
),
|
|
5598
5843
|
abortSignal: effectiveSignal,
|
|
@@ -5609,7 +5854,7 @@ function streamGoogleInteractionEvents({
|
|
|
5609
5854
|
currentReader = await openReader();
|
|
5610
5855
|
receivedAnyEventThisAttempt = false;
|
|
5611
5856
|
} catch (error) {
|
|
5612
|
-
if ((0,
|
|
5857
|
+
if ((0, import_provider_utils22.isAbortError)(error) || effectiveSignal.aborted) {
|
|
5613
5858
|
controller.error(error);
|
|
5614
5859
|
return;
|
|
5615
5860
|
}
|
|
@@ -5618,7 +5863,7 @@ function streamGoogleInteractionEvents({
|
|
|
5618
5863
|
controller.error(error);
|
|
5619
5864
|
return;
|
|
5620
5865
|
}
|
|
5621
|
-
await (0,
|
|
5866
|
+
await (0, import_provider_utils22.delay)(retryDelayMs * attempt, {
|
|
5622
5867
|
abortSignal: effectiveSignal
|
|
5623
5868
|
});
|
|
5624
5869
|
continue;
|
|
@@ -5639,7 +5884,7 @@ function streamGoogleInteractionEvents({
|
|
|
5639
5884
|
);
|
|
5640
5885
|
return;
|
|
5641
5886
|
}
|
|
5642
|
-
await (0,
|
|
5887
|
+
await (0, import_provider_utils22.delay)(retryDelayMs * attempt, {
|
|
5643
5888
|
abortSignal: effectiveSignal
|
|
5644
5889
|
});
|
|
5645
5890
|
} else {
|
|
@@ -5659,7 +5904,7 @@ function streamGoogleInteractionEvents({
|
|
|
5659
5904
|
}
|
|
5660
5905
|
controller.enqueue(value);
|
|
5661
5906
|
} catch (error) {
|
|
5662
|
-
if ((0,
|
|
5907
|
+
if ((0, import_provider_utils22.isAbortError)(error) || effectiveSignal.aborted) {
|
|
5663
5908
|
controller.error(error);
|
|
5664
5909
|
return;
|
|
5665
5910
|
}
|
|
@@ -5669,7 +5914,7 @@ function streamGoogleInteractionEvents({
|
|
|
5669
5914
|
controller.error(error);
|
|
5670
5915
|
return;
|
|
5671
5916
|
}
|
|
5672
|
-
await (0,
|
|
5917
|
+
await (0, import_provider_utils22.delay)(retryDelayMs * attempt, {
|
|
5673
5918
|
abortSignal: effectiveSignal
|
|
5674
5919
|
});
|
|
5675
5920
|
}
|
|
@@ -5881,7 +6126,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5881
6126
|
async getArgs(options) {
|
|
5882
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;
|
|
5883
6128
|
const warnings = [];
|
|
5884
|
-
const opts = await (0,
|
|
6129
|
+
const opts = await (0, import_provider_utils23.parseProviderOptions)({
|
|
5885
6130
|
provider: "google",
|
|
5886
6131
|
providerOptions: options.providerOptions,
|
|
5887
6132
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6127,17 +6372,17 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6127
6372
|
var _a, _b, _c, _d, _e, _f;
|
|
6128
6373
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6129
6374
|
const url = `${this.config.baseURL}/interactions`;
|
|
6130
|
-
const mergedHeaders = (0,
|
|
6375
|
+
const mergedHeaders = (0, import_provider_utils23.combineHeaders)(
|
|
6131
6376
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6132
|
-
this.config.headers ? await (0,
|
|
6377
|
+
this.config.headers ? await (0, import_provider_utils23.resolve)(this.config.headers) : void 0,
|
|
6133
6378
|
options.headers
|
|
6134
6379
|
);
|
|
6135
|
-
const postResult = await (0,
|
|
6380
|
+
const postResult = await (0, import_provider_utils23.postJsonToApi)({
|
|
6136
6381
|
url,
|
|
6137
6382
|
headers: mergedHeaders,
|
|
6138
6383
|
body: args,
|
|
6139
6384
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6140
|
-
successfulResponseHandler: (0,
|
|
6385
|
+
successfulResponseHandler: (0, import_provider_utils23.createJsonResponseHandler)(
|
|
6141
6386
|
googleInteractionsResponseSchema
|
|
6142
6387
|
),
|
|
6143
6388
|
abortSignal: options.abortSignal,
|
|
@@ -6164,7 +6409,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6164
6409
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
6165
6410
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
6166
6411
|
steps: (_b = response.steps) != null ? _b : null,
|
|
6167
|
-
generateId: (_c = this.config.generateId) != null ? _c :
|
|
6412
|
+
generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils23.generateId,
|
|
6168
6413
|
interactionId
|
|
6169
6414
|
});
|
|
6170
6415
|
const finishReason = {
|
|
@@ -6212,9 +6457,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6212
6457
|
var _a;
|
|
6213
6458
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6214
6459
|
const url = `${this.config.baseURL}/interactions`;
|
|
6215
|
-
const mergedHeaders = (0,
|
|
6460
|
+
const mergedHeaders = (0, import_provider_utils23.combineHeaders)(
|
|
6216
6461
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6217
|
-
this.config.headers ? await (0,
|
|
6462
|
+
this.config.headers ? await (0, import_provider_utils23.resolve)(this.config.headers) : void 0,
|
|
6218
6463
|
options.headers
|
|
6219
6464
|
);
|
|
6220
6465
|
if (isBackground) {
|
|
@@ -6228,12 +6473,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6228
6473
|
});
|
|
6229
6474
|
}
|
|
6230
6475
|
const body = { ...args, stream: true };
|
|
6231
|
-
const { responseHeaders, value: response } = await (0,
|
|
6476
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils23.postJsonToApi)({
|
|
6232
6477
|
url,
|
|
6233
6478
|
headers: mergedHeaders,
|
|
6234
6479
|
body,
|
|
6235
6480
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6236
|
-
successfulResponseHandler: (0,
|
|
6481
|
+
successfulResponseHandler: (0, import_provider_utils23.createEventSourceResponseHandler)(
|
|
6237
6482
|
googleInteractionsEventSchema
|
|
6238
6483
|
),
|
|
6239
6484
|
abortSignal: options.abortSignal,
|
|
@@ -6242,7 +6487,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6242
6487
|
const headerServiceTier = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"];
|
|
6243
6488
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
6244
6489
|
warnings,
|
|
6245
|
-
generateId: (_a = this.config.generateId) != null ? _a :
|
|
6490
|
+
generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils23.generateId,
|
|
6246
6491
|
includeRawChunks: options.includeRawChunks,
|
|
6247
6492
|
serviceTier: headerServiceTier
|
|
6248
6493
|
});
|
|
@@ -6279,12 +6524,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6279
6524
|
pollingTimeoutMs
|
|
6280
6525
|
}) {
|
|
6281
6526
|
var _a, _b;
|
|
6282
|
-
const postResult = await (0,
|
|
6527
|
+
const postResult = await (0, import_provider_utils23.postJsonToApi)({
|
|
6283
6528
|
url,
|
|
6284
6529
|
headers: mergedHeaders,
|
|
6285
6530
|
body: args,
|
|
6286
6531
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6287
|
-
successfulResponseHandler: (0,
|
|
6532
|
+
successfulResponseHandler: (0, import_provider_utils23.createJsonResponseHandler)(
|
|
6288
6533
|
googleInteractionsResponseSchema
|
|
6289
6534
|
),
|
|
6290
6535
|
abortSignal: options.abortSignal,
|
|
@@ -6302,7 +6547,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6302
6547
|
const synthesized = synthesizeGoogleInteractionsAgentStream({
|
|
6303
6548
|
response: postResponse,
|
|
6304
6549
|
warnings,
|
|
6305
|
-
generateId: (_a = this.config.generateId) != null ? _a :
|
|
6550
|
+
generateId: (_a = this.config.generateId) != null ? _a : import_provider_utils23.generateId,
|
|
6306
6551
|
includeRawChunks: options.includeRawChunks,
|
|
6307
6552
|
headerServiceTier
|
|
6308
6553
|
});
|
|
@@ -6322,7 +6567,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
6322
6567
|
});
|
|
6323
6568
|
const transform = buildGoogleInteractionsStreamTransform({
|
|
6324
6569
|
warnings,
|
|
6325
|
-
generateId: (_b = this.config.generateId) != null ? _b :
|
|
6570
|
+
generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils23.generateId,
|
|
6326
6571
|
includeRawChunks: options.includeRawChunks,
|
|
6327
6572
|
serviceTier: headerServiceTier
|
|
6328
6573
|
});
|
|
@@ -6376,11 +6621,11 @@ function supportsExternalFileUrls(modelId) {
|
|
|
6376
6621
|
}
|
|
6377
6622
|
function createGoogleGenerativeAI(options = {}) {
|
|
6378
6623
|
var _a, _b;
|
|
6379
|
-
const baseURL = (_a = (0,
|
|
6624
|
+
const baseURL = (_a = (0, import_provider_utils24.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
|
6380
6625
|
const providerName = (_b = options.name) != null ? _b : "google.generative-ai";
|
|
6381
|
-
const getHeaders = () => (0,
|
|
6626
|
+
const getHeaders = () => (0, import_provider_utils24.withUserAgentSuffix)(
|
|
6382
6627
|
{
|
|
6383
|
-
"x-goog-api-key": (0,
|
|
6628
|
+
"x-goog-api-key": (0, import_provider_utils24.loadApiKey)({
|
|
6384
6629
|
apiKey: options.apiKey,
|
|
6385
6630
|
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
6386
6631
|
description: "Google Generative AI"
|
|
@@ -6395,7 +6640,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6395
6640
|
provider: providerName,
|
|
6396
6641
|
baseURL,
|
|
6397
6642
|
headers: getHeaders,
|
|
6398
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6643
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId,
|
|
6399
6644
|
supportedUrls: () => ({
|
|
6400
6645
|
"*": [
|
|
6401
6646
|
// Google Generative Language "files" endpoint
|
|
@@ -6429,6 +6674,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6429
6674
|
headers: getHeaders,
|
|
6430
6675
|
fetch: options.fetch
|
|
6431
6676
|
});
|
|
6677
|
+
const createTranscriptionModel = (modelId) => new GoogleTranscriptionModel(modelId, {
|
|
6678
|
+
provider: `${providerName}.transcription`,
|
|
6679
|
+
baseURL,
|
|
6680
|
+
headers: getHeaders,
|
|
6681
|
+
fetch: options.fetch
|
|
6682
|
+
});
|
|
6432
6683
|
const createVideoModel = (modelId) => {
|
|
6433
6684
|
var _a2;
|
|
6434
6685
|
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
@@ -6436,7 +6687,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6436
6687
|
baseURL,
|
|
6437
6688
|
headers: getHeaders,
|
|
6438
6689
|
fetch: options.fetch,
|
|
6439
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6690
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId
|
|
6440
6691
|
});
|
|
6441
6692
|
};
|
|
6442
6693
|
const createInteractionsModel = (modelIdOrAgent) => {
|
|
@@ -6447,7 +6698,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6447
6698
|
provider: `${providerName}.interactions`,
|
|
6448
6699
|
baseURL,
|
|
6449
6700
|
headers: getHeaders,
|
|
6450
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
6701
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils24.generateId,
|
|
6451
6702
|
fetch: options.fetch
|
|
6452
6703
|
}
|
|
6453
6704
|
);
|
|
@@ -6470,6 +6721,8 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6470
6721
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
6471
6722
|
provider.image = createImageModel;
|
|
6472
6723
|
provider.imageModel = createImageModel;
|
|
6724
|
+
provider.transcription = createTranscriptionModel;
|
|
6725
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
6473
6726
|
provider.video = createVideoModel;
|
|
6474
6727
|
provider.videoModel = createVideoModel;
|
|
6475
6728
|
provider.interactions = createInteractionsModel;
|
|
@@ -6479,6 +6732,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
6479
6732
|
var google = createGoogleGenerativeAI();
|
|
6480
6733
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6481
6734
|
0 && (module.exports = {
|
|
6735
|
+
GoogleTranscriptionModel,
|
|
6482
6736
|
VERSION,
|
|
6483
6737
|
createGoogleGenerativeAI,
|
|
6484
6738
|
google
|