@ai-sdk/google 4.0.61 → 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 +15 -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 +2 -2
- 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/dist/internal/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ type GoogleFunctionResponsePart = {
|
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
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 & {});
|
|
70
|
+
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 & {});
|
|
71
71
|
|
|
72
72
|
type GoogleLanguageModelConfig = {
|
|
73
73
|
provider: string;
|
|
@@ -521,7 +521,7 @@ declare const googleTools: {
|
|
|
521
521
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
522
522
|
* may diverge over time.
|
|
523
523
|
*/
|
|
524
|
-
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 & {});
|
|
524
|
+
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 & {});
|
|
525
525
|
|
|
526
526
|
type GoogleInteractionsConfig = {
|
|
527
527
|
provider: string;
|
package/dist/internal/index.js
CHANGED
|
@@ -3623,6 +3623,21 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3623
3623
|
}
|
|
3624
3624
|
}
|
|
3625
3625
|
}
|
|
3626
|
+
} else if (stepType === "processing_call" || stepType === "processing_result") {
|
|
3627
|
+
const google = {};
|
|
3628
|
+
if ((step == null ? void 0 : step.signature) != null) google.signature = step.signature;
|
|
3629
|
+
if (interactionId != null) google.interactionId = interactionId;
|
|
3630
|
+
if (stepType === "processing_call") {
|
|
3631
|
+
google.processingId = (step == null ? void 0 : step.id) || blockId;
|
|
3632
|
+
} else {
|
|
3633
|
+
google.processingCallId = (step == null ? void 0 : step.call_id) || blockId;
|
|
3634
|
+
}
|
|
3635
|
+
openBlocks.set(index, {
|
|
3636
|
+
kind: "custom",
|
|
3637
|
+
id: blockId,
|
|
3638
|
+
customKind: `google.${stepType}`,
|
|
3639
|
+
google
|
|
3640
|
+
});
|
|
3626
3641
|
} else if (stepType === "function_call") {
|
|
3627
3642
|
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
3628
3643
|
const toolName = (_b = step == null ? void 0 : step.name) != null ? _b : "unknown";
|
|
@@ -3739,7 +3754,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3739
3754
|
break;
|
|
3740
3755
|
}
|
|
3741
3756
|
const delta = event.delta;
|
|
3742
|
-
if (open.kind === "
|
|
3757
|
+
if (open.kind === "custom" && ((delta == null ? void 0 : delta.type) === "processing_call" || (delta == null ? void 0 : delta.type) === "processing_result")) {
|
|
3758
|
+
if (delta.signature != null)
|
|
3759
|
+
open.google.signature = delta.signature;
|
|
3760
|
+
if (delta.type === "processing_call" && delta.id != null && delta.id.length > 0) {
|
|
3761
|
+
open.google.processingId = delta.id;
|
|
3762
|
+
}
|
|
3763
|
+
if (delta.type === "processing_result" && delta.call_id != null && delta.call_id.length > 0) {
|
|
3764
|
+
open.google.processingCallId = delta.call_id;
|
|
3765
|
+
}
|
|
3766
|
+
} else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3743
3767
|
const text = (_l = delta.text) != null ? _l : "";
|
|
3744
3768
|
if (text.length > 0) {
|
|
3745
3769
|
controller.enqueue({
|
|
@@ -3876,6 +3900,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3876
3900
|
input: accumulated,
|
|
3877
3901
|
...providerMetadata ? { providerMetadata } : {}
|
|
3878
3902
|
});
|
|
3903
|
+
} else if (open.kind === "custom") {
|
|
3904
|
+
controller.enqueue({
|
|
3905
|
+
type: "custom",
|
|
3906
|
+
kind: open.customKind,
|
|
3907
|
+
providerMetadata: { google: open.google }
|
|
3908
|
+
});
|
|
3879
3909
|
} else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
|
|
3880
3910
|
controller.enqueue({
|
|
3881
3911
|
type: "tool-call",
|
|
@@ -4000,7 +4030,7 @@ function convertToGoogleInteractionsInput({
|
|
|
4000
4030
|
store,
|
|
4001
4031
|
mediaResolution
|
|
4002
4032
|
}) {
|
|
4003
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4033
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4004
4034
|
const warnings = [];
|
|
4005
4035
|
const incoherentCombo = previousInteractionId != null && store === false;
|
|
4006
4036
|
const shouldCompact = previousInteractionId != null && store !== false;
|
|
@@ -4072,10 +4102,32 @@ function convertToGoogleInteractionsInput({
|
|
|
4072
4102
|
if (fileBlock != null) {
|
|
4073
4103
|
pendingModelOutput.push(fileBlock);
|
|
4074
4104
|
}
|
|
4105
|
+
} else if (part.type === "custom") {
|
|
4106
|
+
flushModelOutput();
|
|
4107
|
+
const google = (_c = part.providerOptions) == null ? void 0 : _c.google;
|
|
4108
|
+
const signature = typeof (google == null ? void 0 : google.signature) === "string" ? google.signature : void 0;
|
|
4109
|
+
if (part.kind === "google.processing_call" && typeof (google == null ? void 0 : google.processingId) === "string") {
|
|
4110
|
+
steps.push({
|
|
4111
|
+
type: "processing_call",
|
|
4112
|
+
id: google.processingId,
|
|
4113
|
+
...signature != null ? { signature } : {}
|
|
4114
|
+
});
|
|
4115
|
+
} else if (part.kind === "google.processing_result" && typeof (google == null ? void 0 : google.processingCallId) === "string") {
|
|
4116
|
+
steps.push({
|
|
4117
|
+
type: "processing_result",
|
|
4118
|
+
call_id: google.processingCallId,
|
|
4119
|
+
...signature != null ? { signature } : {}
|
|
4120
|
+
});
|
|
4121
|
+
} else {
|
|
4122
|
+
warnings.push({
|
|
4123
|
+
type: "other",
|
|
4124
|
+
message: `google.interactions: unsupported or invalid custom assistant content part "${part.kind}"; part dropped.`
|
|
4125
|
+
});
|
|
4126
|
+
}
|
|
4075
4127
|
} else if (part.type === "tool-call") {
|
|
4076
4128
|
flushModelOutput();
|
|
4077
|
-
const signature = (
|
|
4078
|
-
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (
|
|
4129
|
+
const signature = (_e = (_d = part.providerOptions) == null ? void 0 : _d.google) == null ? void 0 : _e.signature;
|
|
4130
|
+
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_f = part.input) != null ? _f : {};
|
|
4079
4131
|
steps.push({
|
|
4080
4132
|
type: "function_call",
|
|
4081
4133
|
id: part.toolCallId,
|
|
@@ -4107,7 +4159,7 @@ function convertToGoogleInteractionsInput({
|
|
|
4107
4159
|
toolCallId: part.toolCallId,
|
|
4108
4160
|
toolName: part.toolName,
|
|
4109
4161
|
output: part.output,
|
|
4110
|
-
signature: (
|
|
4162
|
+
signature: (_h = (_g = part.providerOptions) == null ? void 0 : _g.google) == null ? void 0 : _h.signature,
|
|
4111
4163
|
warnings
|
|
4112
4164
|
});
|
|
4113
4165
|
content.push(block);
|
|
@@ -4160,6 +4212,7 @@ function convertFilePartToContent({
|
|
|
4160
4212
|
return void 0;
|
|
4161
4213
|
}
|
|
4162
4214
|
const resolutionField = mediaResolution != null && (kind === "image" || kind === "video") ? { resolution: mediaResolution } : {};
|
|
4215
|
+
const processingField = kind === "video" ? getVideoProcessingField({ part, warnings }) : {};
|
|
4163
4216
|
switch (part.data.type) {
|
|
4164
4217
|
case "data": {
|
|
4165
4218
|
const mimeType = resolveFullMediaType2({ part });
|
|
@@ -4167,7 +4220,8 @@ function convertFilePartToContent({
|
|
|
4167
4220
|
type: kind,
|
|
4168
4221
|
data: convertToBase642(part.data.data),
|
|
4169
4222
|
mime_type: mimeType,
|
|
4170
|
-
...resolutionField
|
|
4223
|
+
...resolutionField,
|
|
4224
|
+
...processingField
|
|
4171
4225
|
};
|
|
4172
4226
|
}
|
|
4173
4227
|
case "url": {
|
|
@@ -4175,7 +4229,8 @@ function convertFilePartToContent({
|
|
|
4175
4229
|
type: kind,
|
|
4176
4230
|
uri: part.data.url.toString(),
|
|
4177
4231
|
...isFullMediaType2(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
4178
|
-
...resolutionField
|
|
4232
|
+
...resolutionField,
|
|
4233
|
+
...processingField
|
|
4179
4234
|
};
|
|
4180
4235
|
}
|
|
4181
4236
|
case "reference": {
|
|
@@ -4187,11 +4242,41 @@ function convertFilePartToContent({
|
|
|
4187
4242
|
type: kind,
|
|
4188
4243
|
uri,
|
|
4189
4244
|
...isFullMediaType2(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
4190
|
-
...resolutionField
|
|
4245
|
+
...resolutionField,
|
|
4246
|
+
...processingField
|
|
4191
4247
|
};
|
|
4192
4248
|
}
|
|
4193
4249
|
}
|
|
4194
4250
|
}
|
|
4251
|
+
function getVideoProcessingField({
|
|
4252
|
+
part,
|
|
4253
|
+
warnings
|
|
4254
|
+
}) {
|
|
4255
|
+
var _a, _b;
|
|
4256
|
+
const processing = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.processing;
|
|
4257
|
+
if (processing == null) {
|
|
4258
|
+
return {};
|
|
4259
|
+
}
|
|
4260
|
+
if (processing === "agentic" || processing === "static") {
|
|
4261
|
+
return { processing };
|
|
4262
|
+
}
|
|
4263
|
+
if (typeof processing === "object" && !Array.isArray(processing) && processing.type === "static") {
|
|
4264
|
+
const config = processing;
|
|
4265
|
+
return {
|
|
4266
|
+
processing: {
|
|
4267
|
+
type: "static",
|
|
4268
|
+
...typeof config.startOffset === "number" ? { start_offset: config.startOffset } : {},
|
|
4269
|
+
...typeof config.endOffset === "number" ? { end_offset: config.endOffset } : {},
|
|
4270
|
+
...typeof config.fps === "number" ? { fps: config.fps } : {}
|
|
4271
|
+
}
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
4274
|
+
warnings.push({
|
|
4275
|
+
type: "other",
|
|
4276
|
+
message: 'google.interactions: invalid providerOptions.google.processing on video file part; expected "agentic", "static", or a static processing configuration. Option dropped.'
|
|
4277
|
+
});
|
|
4278
|
+
return {};
|
|
4279
|
+
}
|
|
4195
4280
|
function compactPromptForPreviousInteraction({
|
|
4196
4281
|
prompt,
|
|
4197
4282
|
previousInteractionId
|
|
@@ -4511,6 +4596,16 @@ var stepSchema = () => {
|
|
|
4511
4596
|
signature: z13.string().nullish(),
|
|
4512
4597
|
summary: z13.array(thoughtSummaryItemSchema()).nullish()
|
|
4513
4598
|
}).loose();
|
|
4599
|
+
const processingCallStep = z13.object({
|
|
4600
|
+
type: z13.literal("processing_call"),
|
|
4601
|
+
id: z13.string(),
|
|
4602
|
+
signature: z13.string().nullish()
|
|
4603
|
+
}).loose();
|
|
4604
|
+
const processingResultStep = z13.object({
|
|
4605
|
+
type: z13.literal("processing_result"),
|
|
4606
|
+
call_id: z13.string(),
|
|
4607
|
+
signature: z13.string().nullish()
|
|
4608
|
+
}).loose();
|
|
4514
4609
|
const builtinToolCallStep = z13.object({
|
|
4515
4610
|
type: z13.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4516
4611
|
id: z13.string(),
|
|
@@ -4534,6 +4629,8 @@ var stepSchema = () => {
|
|
|
4534
4629
|
modelOutputStep,
|
|
4535
4630
|
functionCallStep,
|
|
4536
4631
|
thoughtStep,
|
|
4632
|
+
processingCallStep,
|
|
4633
|
+
processingResultStep,
|
|
4537
4634
|
builtinToolCallStep,
|
|
4538
4635
|
builtinToolResultStep,
|
|
4539
4636
|
z13.object({ type: z13.string() }).loose()
|
|
@@ -4907,7 +5004,9 @@ var googleInteractionsLanguageModelOptions = lazySchema13(
|
|
|
4907
5004
|
// src/interactions/parse-google-interactions-outputs.ts
|
|
4908
5005
|
function googleProviderMetadata({
|
|
4909
5006
|
signature,
|
|
4910
|
-
interactionId
|
|
5007
|
+
interactionId,
|
|
5008
|
+
processingId,
|
|
5009
|
+
processingCallId
|
|
4911
5010
|
}) {
|
|
4912
5011
|
const google = {};
|
|
4913
5012
|
if (signature != null) {
|
|
@@ -4916,6 +5015,12 @@ function googleProviderMetadata({
|
|
|
4916
5015
|
if (interactionId != null) {
|
|
4917
5016
|
google.interactionId = interactionId;
|
|
4918
5017
|
}
|
|
5018
|
+
if (processingId != null) {
|
|
5019
|
+
google.processingId = processingId;
|
|
5020
|
+
}
|
|
5021
|
+
if (processingCallId != null) {
|
|
5022
|
+
google.processingCallId = processingCallId;
|
|
5023
|
+
}
|
|
4919
5024
|
return Object.keys(google).length > 0 ? { providerMetadata: { google } } : {};
|
|
4920
5025
|
}
|
|
4921
5026
|
var BUILTIN_TOOL_CALL_TYPES2 = /* @__PURE__ */ new Set([
|
|
@@ -5030,6 +5135,34 @@ function parseGoogleInteractionsOutputs({
|
|
|
5030
5135
|
});
|
|
5031
5136
|
break;
|
|
5032
5137
|
}
|
|
5138
|
+
case "processing_call": {
|
|
5139
|
+
const call = step;
|
|
5140
|
+
const processingId = call.id || generateId2();
|
|
5141
|
+
content.push({
|
|
5142
|
+
type: "custom",
|
|
5143
|
+
kind: "google.processing_call",
|
|
5144
|
+
...googleProviderMetadata({
|
|
5145
|
+
signature: call.signature,
|
|
5146
|
+
interactionId,
|
|
5147
|
+
processingId
|
|
5148
|
+
})
|
|
5149
|
+
});
|
|
5150
|
+
break;
|
|
5151
|
+
}
|
|
5152
|
+
case "processing_result": {
|
|
5153
|
+
const result = step;
|
|
5154
|
+
const processingCallId = result.call_id || generateId2();
|
|
5155
|
+
content.push({
|
|
5156
|
+
type: "custom",
|
|
5157
|
+
kind: "google.processing_result",
|
|
5158
|
+
...googleProviderMetadata({
|
|
5159
|
+
signature: result.signature,
|
|
5160
|
+
interactionId,
|
|
5161
|
+
processingCallId
|
|
5162
|
+
})
|
|
5163
|
+
});
|
|
5164
|
+
break;
|
|
5165
|
+
}
|
|
5033
5166
|
case "function_call": {
|
|
5034
5167
|
hasFunctionCall = true;
|
|
5035
5168
|
const call = step;
|