@ai-sdk/google 4.0.62 → 4.0.63
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 +8 -0
- package/dist/index.d.ts +32 -3
- package/dist/index.js +224 -83
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +142 -9
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +135 -30
- package/package.json +1 -1
- package/src/google-batch.ts +82 -70
- package/src/google-language-model-options.ts +1 -0
- package/src/index.ts +1 -0
- package/src/interactions/build-google-interactions-stream-transform.ts +52 -1
- package/src/interactions/convert-to-google-interactions-input.ts +99 -0
- package/src/interactions/google-interactions-api.ts +18 -0
- package/src/interactions/google-interactions-language-model-options.ts +24 -0
- package/src/interactions/google-interactions-prompt.ts +31 -0
- package/src/interactions/google-interactions-provider-metadata.ts +12 -0
- package/src/interactions/parse-google-interactions-outputs.ts +44 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.63
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 18ad19c: feat(google): support agentic video processing in the Interactions API
|
|
8
|
+
- 048ce06: feat(batch): surface the uploaded input file on the batch start result (`providerMetadata.<provider>.inputFileId` / `inputFileExpiresAt`) and accept an `inputFileExpiresAfter` provider option on the OpenAI and xAI batch input file upload
|
|
9
|
+
- 622fa7f: feat(google): add gemini-3.8-flash model
|
|
10
|
+
|
|
3
11
|
## 4.0.62
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
14
14
|
}>;
|
|
15
15
|
type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
|
|
16
16
|
|
|
17
|
-
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
17
|
+
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
18
18
|
declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
19
19
|
responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
|
|
20
20
|
thinkingConfig?: {
|
|
@@ -320,7 +320,26 @@ type GoogleFilesUploadOptions = {
|
|
|
320
320
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
321
321
|
* may diverge over time.
|
|
322
322
|
*/
|
|
323
|
-
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
323
|
+
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
324
|
+
/**
|
|
325
|
+
* Provider options for an individual video file part sent to the Gemini
|
|
326
|
+
* Interactions API.
|
|
327
|
+
*/
|
|
328
|
+
type GoogleInteractionsVideoOptions = {
|
|
329
|
+
/**
|
|
330
|
+
* Controls how Gemini processes this video.
|
|
331
|
+
*
|
|
332
|
+
* Agentic processing dynamically explores the video timeline. Static
|
|
333
|
+
* processing samples frames at a fixed rate and optionally supports clipping
|
|
334
|
+
* and custom frame rates.
|
|
335
|
+
*/
|
|
336
|
+
processing?: 'agentic' | 'static' | {
|
|
337
|
+
type: 'static';
|
|
338
|
+
startOffset?: number;
|
|
339
|
+
endOffset?: number;
|
|
340
|
+
fps?: number;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
324
343
|
/**
|
|
325
344
|
* Provider-options schema for `google.interactions(...)` calls. Read from the
|
|
326
345
|
* shared `providerOptions.google.*` namespace (per PRD); per-call options that
|
|
@@ -431,6 +450,16 @@ type GoogleInteractionsProviderMetadata = {
|
|
|
431
450
|
* reasoning / tool-call parts and round-tripped on input parts.
|
|
432
451
|
*/
|
|
433
452
|
signature?: string;
|
|
453
|
+
/**
|
|
454
|
+
* ID of an agentic video `processing_call` step. Present on
|
|
455
|
+
* `google.processing_call` custom parts.
|
|
456
|
+
*/
|
|
457
|
+
processingId?: string;
|
|
458
|
+
/**
|
|
459
|
+
* ID of the corresponding agentic video processing call. Present on
|
|
460
|
+
* `google.processing_result` custom parts.
|
|
461
|
+
*/
|
|
462
|
+
processingCallId?: string;
|
|
434
463
|
};
|
|
435
464
|
|
|
436
465
|
/**
|
|
@@ -790,4 +819,4 @@ declare class GoogleSpeechTranslationModel implements Experimental_SpeechTransla
|
|
|
790
819
|
|
|
791
820
|
declare const VERSION: string;
|
|
792
821
|
|
|
793
|
-
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleSpeechTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleSpeechTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleSpeechTranslationModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleTranslationModelOptions, type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleLanguageModelInteractionsOptions, type GoogleLanguageModelOptions, type GoogleProvider, type GoogleProviderMetadata, type GoogleProviderSettings, type GoogleSpeechModelId, type GoogleSpeechModelOptions, GoogleTranscriptionModel, type GoogleTranscriptionModelId, type GoogleTranscriptionModelOptions, type GoogleVideoModelId, type GoogleVideoModelOptions, VERSION, createGoogle, createGoogle as createGoogleGenerativeAI, google };
|
|
822
|
+
export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleSpeechTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleSpeechTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleSpeechTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleSpeechTranslationModelOptions, GoogleSpeechTranslationModel as Experimental_GoogleTranslationModel, type GoogleSpeechTranslationModelConfig as Experimental_GoogleTranslationModelConfig, type GoogleSpeechTranslationModelId as Experimental_GoogleTranslationModelId, type GoogleSpeechTranslationModelOptions as Experimental_GoogleTranslationModelOptions, type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleInteractionsVideoOptions, type GoogleLanguageModelInteractionsOptions, type GoogleLanguageModelOptions, type GoogleProvider, type GoogleProviderMetadata, type GoogleProviderSettings, type GoogleSpeechModelId, type GoogleSpeechModelOptions, GoogleTranscriptionModel, type GoogleTranscriptionModelId, type GoogleTranscriptionModelOptions, type GoogleVideoModelId, type GoogleVideoModelOptions, VERSION, createGoogle, createGoogle as createGoogleGenerativeAI, google };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.63" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -3070,7 +3070,8 @@ var googleFileUploadResponseSchema = lazySchema6(
|
|
|
3070
3070
|
() => zodSchema6(
|
|
3071
3071
|
z6.object({
|
|
3072
3072
|
file: z6.object({
|
|
3073
|
-
name: z6.string()
|
|
3073
|
+
name: z6.string(),
|
|
3074
|
+
expirationTime: z6.string().nullish()
|
|
3074
3075
|
})
|
|
3075
3076
|
})
|
|
3076
3077
|
)
|
|
@@ -3178,9 +3179,8 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
|
|
|
3178
3179
|
const createUrl = `${this.batchConfig.baseURL}/${getModelPath(
|
|
3179
3180
|
this.modelId
|
|
3180
3181
|
)}:batchGenerateContent`;
|
|
3181
|
-
let operation;
|
|
3182
3182
|
if (fileParts == null) {
|
|
3183
|
-
const { value } = await postJsonToApi3({
|
|
3183
|
+
const { value: operation2 } = await postJsonToApi3({
|
|
3184
3184
|
url: createUrl,
|
|
3185
3185
|
headers,
|
|
3186
3186
|
body: inlineBatchBody,
|
|
@@ -3191,81 +3191,89 @@ var GoogleBatchLanguageModel = class _GoogleBatchLanguageModel extends GoogleLan
|
|
|
3191
3191
|
abortSignal: options.abortSignal,
|
|
3192
3192
|
fetch: this.batchConfig.fetch
|
|
3193
3193
|
});
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
headers: combineHeaders3(headers, {
|
|
3207
|
-
"X-Goog-Upload-Protocol": "resumable",
|
|
3208
|
-
"X-Goog-Upload-Command": "start",
|
|
3209
|
-
"X-Goog-Upload-Header-Content-Length": String(inputFile.size),
|
|
3210
|
-
"X-Goog-Upload-Header-Content-Type": "application/jsonl"
|
|
3211
|
-
}),
|
|
3212
|
-
body: {
|
|
3213
|
-
file: {
|
|
3214
|
-
display_name: `${displayName}-input`
|
|
3215
|
-
}
|
|
3216
|
-
},
|
|
3217
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
3218
|
-
successfulResponseHandler: googleUploadUrlResponseHandler,
|
|
3219
|
-
abortSignal: options.abortSignal,
|
|
3220
|
-
fetch: this.batchConfig.fetch
|
|
3221
|
-
});
|
|
3222
|
-
const { value: uploadedFile } = await postToApi({
|
|
3223
|
-
url: uploadUrl,
|
|
3224
|
-
headers: {
|
|
3225
|
-
"X-Goog-Upload-Offset": "0",
|
|
3226
|
-
"X-Goog-Upload-Command": "upload, finalize",
|
|
3227
|
-
"Content-Type": "application/jsonl"
|
|
3228
|
-
},
|
|
3229
|
-
body: {
|
|
3230
|
-
content: inputFile,
|
|
3231
|
-
values: {
|
|
3232
|
-
byteLength: inputFile.size,
|
|
3233
|
-
mediaType: "application/jsonl"
|
|
3234
|
-
}
|
|
3235
|
-
},
|
|
3236
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
3237
|
-
successfulResponseHandler: createJsonResponseHandler3(
|
|
3238
|
-
googleFileUploadResponseSchema
|
|
3239
|
-
),
|
|
3240
|
-
abortSignal: options.abortSignal,
|
|
3241
|
-
fetch: this.batchConfig.fetch
|
|
3242
|
-
});
|
|
3243
|
-
const { value } = await postJsonToApi3({
|
|
3244
|
-
url: createUrl,
|
|
3245
|
-
headers,
|
|
3246
|
-
body: {
|
|
3247
|
-
batch: {
|
|
3248
|
-
displayName,
|
|
3249
|
-
...options.webhookUrl != null && {
|
|
3250
|
-
webhookConfig: { uris: [options.webhookUrl] }
|
|
3251
|
-
},
|
|
3252
|
-
inputConfig: {
|
|
3253
|
-
fileName: uploadedFile.file.name
|
|
3254
|
-
}
|
|
3255
|
-
}
|
|
3256
|
-
},
|
|
3257
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
3258
|
-
successfulResponseHandler: createJsonResponseHandler3(
|
|
3259
|
-
googleBatchOperationSchema
|
|
3260
|
-
),
|
|
3261
|
-
abortSignal: options.abortSignal,
|
|
3262
|
-
fetch: this.batchConfig.fetch
|
|
3194
|
+
return {
|
|
3195
|
+
batchId: operation2.name,
|
|
3196
|
+
...convertGoogleBatchStatus(operation2),
|
|
3197
|
+
warnings
|
|
3198
|
+
};
|
|
3199
|
+
}
|
|
3200
|
+
const inputFile = new Blob(fileParts, { type: "application/jsonl" });
|
|
3201
|
+
fileParts.length = 0;
|
|
3202
|
+
if (inputFile.size > googleBatchInputFileMaxBytes) {
|
|
3203
|
+
throw new InvalidArgumentError({
|
|
3204
|
+
argument: "requests",
|
|
3205
|
+
message: "Google batch input files must not exceed 2 GB."
|
|
3263
3206
|
});
|
|
3264
|
-
operation = value;
|
|
3265
3207
|
}
|
|
3208
|
+
const { value: uploadUrl } = await postJsonToApi3({
|
|
3209
|
+
url: `${this.getBaseOrigin()}/upload/v1beta/files`,
|
|
3210
|
+
headers: combineHeaders3(headers, {
|
|
3211
|
+
"X-Goog-Upload-Protocol": "resumable",
|
|
3212
|
+
"X-Goog-Upload-Command": "start",
|
|
3213
|
+
"X-Goog-Upload-Header-Content-Length": String(inputFile.size),
|
|
3214
|
+
"X-Goog-Upload-Header-Content-Type": "application/jsonl"
|
|
3215
|
+
}),
|
|
3216
|
+
body: {
|
|
3217
|
+
file: {
|
|
3218
|
+
display_name: `${displayName}-input`
|
|
3219
|
+
}
|
|
3220
|
+
},
|
|
3221
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
3222
|
+
successfulResponseHandler: googleUploadUrlResponseHandler,
|
|
3223
|
+
abortSignal: options.abortSignal,
|
|
3224
|
+
fetch: this.batchConfig.fetch
|
|
3225
|
+
});
|
|
3226
|
+
const { value: uploadedFile } = await postToApi({
|
|
3227
|
+
url: uploadUrl,
|
|
3228
|
+
headers: {
|
|
3229
|
+
"X-Goog-Upload-Offset": "0",
|
|
3230
|
+
"X-Goog-Upload-Command": "upload, finalize",
|
|
3231
|
+
"Content-Type": "application/jsonl"
|
|
3232
|
+
},
|
|
3233
|
+
body: {
|
|
3234
|
+
content: inputFile,
|
|
3235
|
+
values: {
|
|
3236
|
+
byteLength: inputFile.size,
|
|
3237
|
+
mediaType: "application/jsonl"
|
|
3238
|
+
}
|
|
3239
|
+
},
|
|
3240
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
3241
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
3242
|
+
googleFileUploadResponseSchema
|
|
3243
|
+
),
|
|
3244
|
+
abortSignal: options.abortSignal,
|
|
3245
|
+
fetch: this.batchConfig.fetch
|
|
3246
|
+
});
|
|
3247
|
+
const { value: operation } = await postJsonToApi3({
|
|
3248
|
+
url: createUrl,
|
|
3249
|
+
headers,
|
|
3250
|
+
body: {
|
|
3251
|
+
batch: {
|
|
3252
|
+
displayName,
|
|
3253
|
+
...options.webhookUrl != null && {
|
|
3254
|
+
webhookConfig: { uris: [options.webhookUrl] }
|
|
3255
|
+
},
|
|
3256
|
+
inputConfig: {
|
|
3257
|
+
fileName: uploadedFile.file.name
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
},
|
|
3261
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
3262
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
3263
|
+
googleBatchOperationSchema
|
|
3264
|
+
),
|
|
3265
|
+
abortSignal: options.abortSignal,
|
|
3266
|
+
fetch: this.batchConfig.fetch
|
|
3267
|
+
});
|
|
3266
3268
|
return {
|
|
3267
3269
|
batchId: operation.name,
|
|
3268
3270
|
...convertGoogleBatchStatus(operation),
|
|
3271
|
+
providerMetadata: {
|
|
3272
|
+
google: {
|
|
3273
|
+
inputFileId: uploadedFile.file.name,
|
|
3274
|
+
...uploadedFile.file.expirationTime != null ? { inputFileExpiresAt: uploadedFile.file.expirationTime } : {}
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3269
3277
|
warnings
|
|
3270
3278
|
};
|
|
3271
3279
|
}
|
|
@@ -5096,6 +5104,21 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5096
5104
|
}
|
|
5097
5105
|
}
|
|
5098
5106
|
}
|
|
5107
|
+
} else if (stepType === "processing_call" || stepType === "processing_result") {
|
|
5108
|
+
const google2 = {};
|
|
5109
|
+
if ((step == null ? void 0 : step.signature) != null) google2.signature = step.signature;
|
|
5110
|
+
if (interactionId != null) google2.interactionId = interactionId;
|
|
5111
|
+
if (stepType === "processing_call") {
|
|
5112
|
+
google2.processingId = (step == null ? void 0 : step.id) || blockId;
|
|
5113
|
+
} else {
|
|
5114
|
+
google2.processingCallId = (step == null ? void 0 : step.call_id) || blockId;
|
|
5115
|
+
}
|
|
5116
|
+
openBlocks.set(index, {
|
|
5117
|
+
kind: "custom",
|
|
5118
|
+
id: blockId,
|
|
5119
|
+
customKind: `google.${stepType}`,
|
|
5120
|
+
google: google2
|
|
5121
|
+
});
|
|
5099
5122
|
} else if (stepType === "function_call") {
|
|
5100
5123
|
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
5101
5124
|
const toolName = (_b = step == null ? void 0 : step.name) != null ? _b : "unknown";
|
|
@@ -5212,7 +5235,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5212
5235
|
break;
|
|
5213
5236
|
}
|
|
5214
5237
|
const delta = event.delta;
|
|
5215
|
-
if (open.kind === "
|
|
5238
|
+
if (open.kind === "custom" && ((delta == null ? void 0 : delta.type) === "processing_call" || (delta == null ? void 0 : delta.type) === "processing_result")) {
|
|
5239
|
+
if (delta.signature != null)
|
|
5240
|
+
open.google.signature = delta.signature;
|
|
5241
|
+
if (delta.type === "processing_call" && delta.id != null && delta.id.length > 0) {
|
|
5242
|
+
open.google.processingId = delta.id;
|
|
5243
|
+
}
|
|
5244
|
+
if (delta.type === "processing_result" && delta.call_id != null && delta.call_id.length > 0) {
|
|
5245
|
+
open.google.processingCallId = delta.call_id;
|
|
5246
|
+
}
|
|
5247
|
+
} else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
5216
5248
|
const text = (_l = delta.text) != null ? _l : "";
|
|
5217
5249
|
if (text.length > 0) {
|
|
5218
5250
|
controller.enqueue({
|
|
@@ -5349,6 +5381,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
5349
5381
|
input: accumulated,
|
|
5350
5382
|
...providerMetadata ? { providerMetadata } : {}
|
|
5351
5383
|
});
|
|
5384
|
+
} else if (open.kind === "custom") {
|
|
5385
|
+
controller.enqueue({
|
|
5386
|
+
type: "custom",
|
|
5387
|
+
kind: open.customKind,
|
|
5388
|
+
providerMetadata: { google: open.google }
|
|
5389
|
+
});
|
|
5352
5390
|
} else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
|
|
5353
5391
|
controller.enqueue({
|
|
5354
5392
|
type: "tool-call",
|
|
@@ -5473,7 +5511,7 @@ function convertToGoogleInteractionsInput({
|
|
|
5473
5511
|
store,
|
|
5474
5512
|
mediaResolution
|
|
5475
5513
|
}) {
|
|
5476
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5514
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5477
5515
|
const warnings = [];
|
|
5478
5516
|
const incoherentCombo = previousInteractionId != null && store === false;
|
|
5479
5517
|
const shouldCompact = previousInteractionId != null && store !== false;
|
|
@@ -5545,10 +5583,32 @@ function convertToGoogleInteractionsInput({
|
|
|
5545
5583
|
if (fileBlock != null) {
|
|
5546
5584
|
pendingModelOutput.push(fileBlock);
|
|
5547
5585
|
}
|
|
5586
|
+
} else if (part.type === "custom") {
|
|
5587
|
+
flushModelOutput();
|
|
5588
|
+
const google2 = (_c = part.providerOptions) == null ? void 0 : _c.google;
|
|
5589
|
+
const signature = typeof (google2 == null ? void 0 : google2.signature) === "string" ? google2.signature : void 0;
|
|
5590
|
+
if (part.kind === "google.processing_call" && typeof (google2 == null ? void 0 : google2.processingId) === "string") {
|
|
5591
|
+
steps.push({
|
|
5592
|
+
type: "processing_call",
|
|
5593
|
+
id: google2.processingId,
|
|
5594
|
+
...signature != null ? { signature } : {}
|
|
5595
|
+
});
|
|
5596
|
+
} else if (part.kind === "google.processing_result" && typeof (google2 == null ? void 0 : google2.processingCallId) === "string") {
|
|
5597
|
+
steps.push({
|
|
5598
|
+
type: "processing_result",
|
|
5599
|
+
call_id: google2.processingCallId,
|
|
5600
|
+
...signature != null ? { signature } : {}
|
|
5601
|
+
});
|
|
5602
|
+
} else {
|
|
5603
|
+
warnings.push({
|
|
5604
|
+
type: "other",
|
|
5605
|
+
message: `google.interactions: unsupported or invalid custom assistant content part "${part.kind}"; part dropped.`
|
|
5606
|
+
});
|
|
5607
|
+
}
|
|
5548
5608
|
} else if (part.type === "tool-call") {
|
|
5549
5609
|
flushModelOutput();
|
|
5550
|
-
const signature = (
|
|
5551
|
-
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (
|
|
5610
|
+
const signature = (_e = (_d = part.providerOptions) == null ? void 0 : _d.google) == null ? void 0 : _e.signature;
|
|
5611
|
+
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_f = part.input) != null ? _f : {};
|
|
5552
5612
|
steps.push({
|
|
5553
5613
|
type: "function_call",
|
|
5554
5614
|
id: part.toolCallId,
|
|
@@ -5580,7 +5640,7 @@ function convertToGoogleInteractionsInput({
|
|
|
5580
5640
|
toolCallId: part.toolCallId,
|
|
5581
5641
|
toolName: part.toolName,
|
|
5582
5642
|
output: part.output,
|
|
5583
|
-
signature: (
|
|
5643
|
+
signature: (_h = (_g = part.providerOptions) == null ? void 0 : _g.google) == null ? void 0 : _h.signature,
|
|
5584
5644
|
warnings
|
|
5585
5645
|
});
|
|
5586
5646
|
content.push(block);
|
|
@@ -5633,6 +5693,7 @@ function convertFilePartToContent({
|
|
|
5633
5693
|
return void 0;
|
|
5634
5694
|
}
|
|
5635
5695
|
const resolutionField = mediaResolution != null && (kind === "image" || kind === "video") ? { resolution: mediaResolution } : {};
|
|
5696
|
+
const processingField = kind === "video" ? getVideoProcessingField({ part, warnings }) : {};
|
|
5636
5697
|
switch (part.data.type) {
|
|
5637
5698
|
case "data": {
|
|
5638
5699
|
const mimeType = resolveFullMediaType2({ part });
|
|
@@ -5640,7 +5701,8 @@ function convertFilePartToContent({
|
|
|
5640
5701
|
type: kind,
|
|
5641
5702
|
data: convertToBase643(part.data.data),
|
|
5642
5703
|
mime_type: mimeType,
|
|
5643
|
-
...resolutionField
|
|
5704
|
+
...resolutionField,
|
|
5705
|
+
...processingField
|
|
5644
5706
|
};
|
|
5645
5707
|
}
|
|
5646
5708
|
case "url": {
|
|
@@ -5648,7 +5710,8 @@ function convertFilePartToContent({
|
|
|
5648
5710
|
type: kind,
|
|
5649
5711
|
uri: part.data.url.toString(),
|
|
5650
5712
|
...isFullMediaType2(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
5651
|
-
...resolutionField
|
|
5713
|
+
...resolutionField,
|
|
5714
|
+
...processingField
|
|
5652
5715
|
};
|
|
5653
5716
|
}
|
|
5654
5717
|
case "reference": {
|
|
@@ -5660,11 +5723,41 @@ function convertFilePartToContent({
|
|
|
5660
5723
|
type: kind,
|
|
5661
5724
|
uri,
|
|
5662
5725
|
...isFullMediaType2(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
5663
|
-
...resolutionField
|
|
5726
|
+
...resolutionField,
|
|
5727
|
+
...processingField
|
|
5664
5728
|
};
|
|
5665
5729
|
}
|
|
5666
5730
|
}
|
|
5667
5731
|
}
|
|
5732
|
+
function getVideoProcessingField({
|
|
5733
|
+
part,
|
|
5734
|
+
warnings
|
|
5735
|
+
}) {
|
|
5736
|
+
var _a, _b;
|
|
5737
|
+
const processing = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.processing;
|
|
5738
|
+
if (processing == null) {
|
|
5739
|
+
return {};
|
|
5740
|
+
}
|
|
5741
|
+
if (processing === "agentic" || processing === "static") {
|
|
5742
|
+
return { processing };
|
|
5743
|
+
}
|
|
5744
|
+
if (typeof processing === "object" && !Array.isArray(processing) && processing.type === "static") {
|
|
5745
|
+
const config = processing;
|
|
5746
|
+
return {
|
|
5747
|
+
processing: {
|
|
5748
|
+
type: "static",
|
|
5749
|
+
...typeof config.startOffset === "number" ? { start_offset: config.startOffset } : {},
|
|
5750
|
+
...typeof config.endOffset === "number" ? { end_offset: config.endOffset } : {},
|
|
5751
|
+
...typeof config.fps === "number" ? { fps: config.fps } : {}
|
|
5752
|
+
}
|
|
5753
|
+
};
|
|
5754
|
+
}
|
|
5755
|
+
warnings.push({
|
|
5756
|
+
type: "other",
|
|
5757
|
+
message: 'google.interactions: invalid providerOptions.google.processing on video file part; expected "agentic", "static", or a static processing configuration. Option dropped.'
|
|
5758
|
+
});
|
|
5759
|
+
return {};
|
|
5760
|
+
}
|
|
5668
5761
|
function compactPromptForPreviousInteraction({
|
|
5669
5762
|
prompt,
|
|
5670
5763
|
previousInteractionId
|
|
@@ -5984,6 +6077,16 @@ var stepSchema = () => {
|
|
|
5984
6077
|
signature: z20.string().nullish(),
|
|
5985
6078
|
summary: z20.array(thoughtSummaryItemSchema()).nullish()
|
|
5986
6079
|
}).loose();
|
|
6080
|
+
const processingCallStep = z20.object({
|
|
6081
|
+
type: z20.literal("processing_call"),
|
|
6082
|
+
id: z20.string(),
|
|
6083
|
+
signature: z20.string().nullish()
|
|
6084
|
+
}).loose();
|
|
6085
|
+
const processingResultStep = z20.object({
|
|
6086
|
+
type: z20.literal("processing_result"),
|
|
6087
|
+
call_id: z20.string(),
|
|
6088
|
+
signature: z20.string().nullish()
|
|
6089
|
+
}).loose();
|
|
5987
6090
|
const builtinToolCallStep = z20.object({
|
|
5988
6091
|
type: z20.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5989
6092
|
id: z20.string(),
|
|
@@ -6007,6 +6110,8 @@ var stepSchema = () => {
|
|
|
6007
6110
|
modelOutputStep,
|
|
6008
6111
|
functionCallStep,
|
|
6009
6112
|
thoughtStep,
|
|
6113
|
+
processingCallStep,
|
|
6114
|
+
processingResultStep,
|
|
6010
6115
|
builtinToolCallStep,
|
|
6011
6116
|
builtinToolResultStep,
|
|
6012
6117
|
z20.object({ type: z20.string() }).loose()
|
|
@@ -6380,7 +6485,9 @@ var googleInteractionsLanguageModelOptions = lazySchema19(
|
|
|
6380
6485
|
// src/interactions/parse-google-interactions-outputs.ts
|
|
6381
6486
|
function googleProviderMetadata({
|
|
6382
6487
|
signature,
|
|
6383
|
-
interactionId
|
|
6488
|
+
interactionId,
|
|
6489
|
+
processingId,
|
|
6490
|
+
processingCallId
|
|
6384
6491
|
}) {
|
|
6385
6492
|
const google2 = {};
|
|
6386
6493
|
if (signature != null) {
|
|
@@ -6389,6 +6496,12 @@ function googleProviderMetadata({
|
|
|
6389
6496
|
if (interactionId != null) {
|
|
6390
6497
|
google2.interactionId = interactionId;
|
|
6391
6498
|
}
|
|
6499
|
+
if (processingId != null) {
|
|
6500
|
+
google2.processingId = processingId;
|
|
6501
|
+
}
|
|
6502
|
+
if (processingCallId != null) {
|
|
6503
|
+
google2.processingCallId = processingCallId;
|
|
6504
|
+
}
|
|
6392
6505
|
return Object.keys(google2).length > 0 ? { providerMetadata: { google: google2 } } : {};
|
|
6393
6506
|
}
|
|
6394
6507
|
var BUILTIN_TOOL_CALL_TYPES2 = /* @__PURE__ */ new Set([
|
|
@@ -6503,6 +6616,34 @@ function parseGoogleInteractionsOutputs({
|
|
|
6503
6616
|
});
|
|
6504
6617
|
break;
|
|
6505
6618
|
}
|
|
6619
|
+
case "processing_call": {
|
|
6620
|
+
const call = step;
|
|
6621
|
+
const processingId = call.id || generateId4();
|
|
6622
|
+
content.push({
|
|
6623
|
+
type: "custom",
|
|
6624
|
+
kind: "google.processing_call",
|
|
6625
|
+
...googleProviderMetadata({
|
|
6626
|
+
signature: call.signature,
|
|
6627
|
+
interactionId,
|
|
6628
|
+
processingId
|
|
6629
|
+
})
|
|
6630
|
+
});
|
|
6631
|
+
break;
|
|
6632
|
+
}
|
|
6633
|
+
case "processing_result": {
|
|
6634
|
+
const result = step;
|
|
6635
|
+
const processingCallId = result.call_id || generateId4();
|
|
6636
|
+
content.push({
|
|
6637
|
+
type: "custom",
|
|
6638
|
+
kind: "google.processing_result",
|
|
6639
|
+
...googleProviderMetadata({
|
|
6640
|
+
signature: result.signature,
|
|
6641
|
+
interactionId,
|
|
6642
|
+
processingCallId
|
|
6643
|
+
})
|
|
6644
|
+
});
|
|
6645
|
+
break;
|
|
6646
|
+
}
|
|
6506
6647
|
case "function_call": {
|
|
6507
6648
|
hasFunctionCall = true;
|
|
6508
6649
|
const call = step;
|