@ai-sdk/google 4.0.0-canary.75 → 4.0.0-canary.76
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 +6 -0
- package/dist/index.d.ts +25 -2
- package/dist/index.js +557 -290
- package/dist/index.js.map +1 -1
- package/docs/15-google.mdx +77 -0
- package/package.json +1 -1
- package/src/google-provider.ts +23 -0
- package/src/google-speech-api.ts +36 -0
- package/src/google-speech-model-options.ts +48 -0
- package/src/google-speech-model.ts +286 -0
- package/src/index.ts +4 -0
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.0-canary.
|
|
10
|
+
var VERSION = true ? "4.0.0-canary.76" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -3573,12 +3573,11 @@ var googleOperationSchema = z17.object({
|
|
|
3573
3573
|
}).nullish()
|
|
3574
3574
|
});
|
|
3575
3575
|
|
|
3576
|
-
// src/
|
|
3576
|
+
// src/google-speech-model.ts
|
|
3577
3577
|
import {
|
|
3578
|
-
combineHeaders as
|
|
3579
|
-
|
|
3580
|
-
createJsonResponseHandler as
|
|
3581
|
-
generateId as defaultGenerateId2,
|
|
3578
|
+
combineHeaders as combineHeaders6,
|
|
3579
|
+
convertBase64ToUint8Array,
|
|
3580
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
3582
3581
|
parseProviderOptions as parseProviderOptions6,
|
|
3583
3582
|
postJsonToApi as postJsonToApi5,
|
|
3584
3583
|
resolve as resolve5,
|
|
@@ -3587,6 +3586,266 @@ import {
|
|
|
3587
3586
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE4
|
|
3588
3587
|
} from "@ai-sdk/provider-utils";
|
|
3589
3588
|
|
|
3589
|
+
// src/google-speech-api.ts
|
|
3590
|
+
import { lazySchema as lazySchema16, zodSchema as zodSchema16 } from "@ai-sdk/provider-utils";
|
|
3591
|
+
import { z as z18 } from "zod/v4";
|
|
3592
|
+
var googleSpeechResponseSchema = lazySchema16(
|
|
3593
|
+
() => zodSchema16(
|
|
3594
|
+
z18.object({
|
|
3595
|
+
candidates: z18.array(
|
|
3596
|
+
z18.object({
|
|
3597
|
+
content: z18.object({
|
|
3598
|
+
parts: z18.array(
|
|
3599
|
+
z18.object({
|
|
3600
|
+
inlineData: z18.object({
|
|
3601
|
+
mimeType: z18.string().nullish(),
|
|
3602
|
+
data: z18.string().nullish()
|
|
3603
|
+
}).nullish()
|
|
3604
|
+
})
|
|
3605
|
+
).nullish()
|
|
3606
|
+
}).nullish()
|
|
3607
|
+
})
|
|
3608
|
+
).nullish()
|
|
3609
|
+
})
|
|
3610
|
+
)
|
|
3611
|
+
);
|
|
3612
|
+
|
|
3613
|
+
// src/google-speech-model-options.ts
|
|
3614
|
+
import {
|
|
3615
|
+
lazySchema as lazySchema17,
|
|
3616
|
+
zodSchema as zodSchema17
|
|
3617
|
+
} from "@ai-sdk/provider-utils";
|
|
3618
|
+
import { z as z19 } from "zod/v4";
|
|
3619
|
+
var prebuiltVoiceConfigSchema = z19.object({
|
|
3620
|
+
voiceName: z19.string()
|
|
3621
|
+
});
|
|
3622
|
+
var voiceConfigSchema = z19.object({
|
|
3623
|
+
prebuiltVoiceConfig: prebuiltVoiceConfigSchema
|
|
3624
|
+
});
|
|
3625
|
+
var googleSpeechProviderOptionsSchema = lazySchema17(
|
|
3626
|
+
() => zodSchema17(
|
|
3627
|
+
z19.object({
|
|
3628
|
+
/**
|
|
3629
|
+
* Multi-speaker configuration for dialogue audio. When provided, this
|
|
3630
|
+
* overrides the top-level `voice`. The Gemini TTS API supports up to two
|
|
3631
|
+
* speakers; each speaker name must match a name used in the input text.
|
|
3632
|
+
*
|
|
3633
|
+
* https://ai.google.dev/gemini-api/docs/speech-generation#multi-speaker
|
|
3634
|
+
*/
|
|
3635
|
+
multiSpeakerVoiceConfig: z19.object({
|
|
3636
|
+
speakerVoiceConfigs: z19.array(
|
|
3637
|
+
z19.object({
|
|
3638
|
+
speaker: z19.string(),
|
|
3639
|
+
voiceConfig: voiceConfigSchema
|
|
3640
|
+
})
|
|
3641
|
+
)
|
|
3642
|
+
}).optional()
|
|
3643
|
+
})
|
|
3644
|
+
)
|
|
3645
|
+
);
|
|
3646
|
+
|
|
3647
|
+
// src/google-speech-model.ts
|
|
3648
|
+
var DEFAULT_VOICE = "Kore";
|
|
3649
|
+
var DEFAULT_SAMPLE_RATE = 24e3;
|
|
3650
|
+
var GoogleSpeechModel = class _GoogleSpeechModel {
|
|
3651
|
+
constructor(modelId, config) {
|
|
3652
|
+
this.modelId = modelId;
|
|
3653
|
+
this.config = config;
|
|
3654
|
+
this.specificationVersion = "v4";
|
|
3655
|
+
}
|
|
3656
|
+
static [WORKFLOW_SERIALIZE4](model) {
|
|
3657
|
+
return serializeModelOptions4({
|
|
3658
|
+
modelId: model.modelId,
|
|
3659
|
+
config: model.config
|
|
3660
|
+
});
|
|
3661
|
+
}
|
|
3662
|
+
static [WORKFLOW_DESERIALIZE4](options) {
|
|
3663
|
+
return new _GoogleSpeechModel(options.modelId, options.config);
|
|
3664
|
+
}
|
|
3665
|
+
get provider() {
|
|
3666
|
+
return this.config.provider;
|
|
3667
|
+
}
|
|
3668
|
+
async getArgs({
|
|
3669
|
+
text,
|
|
3670
|
+
voice = DEFAULT_VOICE,
|
|
3671
|
+
outputFormat,
|
|
3672
|
+
instructions,
|
|
3673
|
+
speed,
|
|
3674
|
+
language,
|
|
3675
|
+
providerOptions
|
|
3676
|
+
}) {
|
|
3677
|
+
const warnings = [];
|
|
3678
|
+
const googleOptions = await parseProviderOptions6({
|
|
3679
|
+
provider: "google",
|
|
3680
|
+
providerOptions,
|
|
3681
|
+
schema: googleSpeechProviderOptionsSchema
|
|
3682
|
+
});
|
|
3683
|
+
const multiSpeakerVoiceConfig = googleOptions == null ? void 0 : googleOptions.multiSpeakerVoiceConfig;
|
|
3684
|
+
const speechConfig = multiSpeakerVoiceConfig ? { multiSpeakerVoiceConfig } : { voiceConfig: { prebuiltVoiceConfig: { voiceName: voice } } };
|
|
3685
|
+
let promptText = text;
|
|
3686
|
+
if (instructions != null) {
|
|
3687
|
+
if (multiSpeakerVoiceConfig) {
|
|
3688
|
+
warnings.push({
|
|
3689
|
+
type: "unsupported",
|
|
3690
|
+
feature: "instructions",
|
|
3691
|
+
details: "Google Gemini TTS ignores `instructions` when `multiSpeakerVoiceConfig` is set, because prepending them would break multi-speaker transcript parsing."
|
|
3692
|
+
});
|
|
3693
|
+
} else {
|
|
3694
|
+
promptText = `${instructions}: ${text}`;
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
if (speed != null) {
|
|
3698
|
+
warnings.push({
|
|
3699
|
+
type: "unsupported",
|
|
3700
|
+
feature: "speed",
|
|
3701
|
+
details: "Google Gemini TTS models do not support the `speed` option. It was ignored."
|
|
3702
|
+
});
|
|
3703
|
+
}
|
|
3704
|
+
if (language != null) {
|
|
3705
|
+
warnings.push({
|
|
3706
|
+
type: "unsupported",
|
|
3707
|
+
feature: "language",
|
|
3708
|
+
details: "Google Gemini TTS models do not support the `language` option. Language is detected automatically from the input text."
|
|
3709
|
+
});
|
|
3710
|
+
}
|
|
3711
|
+
let resolvedOutputFormat = "wav";
|
|
3712
|
+
if (outputFormat === "pcm") {
|
|
3713
|
+
resolvedOutputFormat = "pcm";
|
|
3714
|
+
} else if (outputFormat != null && outputFormat !== "wav") {
|
|
3715
|
+
warnings.push({
|
|
3716
|
+
type: "unsupported",
|
|
3717
|
+
feature: "outputFormat",
|
|
3718
|
+
details: `Unsupported output format: ${outputFormat}. Using wav instead.`
|
|
3719
|
+
});
|
|
3720
|
+
}
|
|
3721
|
+
const requestBody = {
|
|
3722
|
+
contents: [{ parts: [{ text: promptText }] }],
|
|
3723
|
+
generationConfig: {
|
|
3724
|
+
responseModalities: ["AUDIO"],
|
|
3725
|
+
speechConfig
|
|
3726
|
+
}
|
|
3727
|
+
};
|
|
3728
|
+
return { requestBody, warnings, outputFormat: resolvedOutputFormat };
|
|
3729
|
+
}
|
|
3730
|
+
async doGenerate(options) {
|
|
3731
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3732
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
3733
|
+
const { requestBody, warnings, outputFormat } = await this.getArgs(options);
|
|
3734
|
+
const {
|
|
3735
|
+
value: response,
|
|
3736
|
+
responseHeaders,
|
|
3737
|
+
rawValue: rawResponse
|
|
3738
|
+
} = await postJsonToApi5({
|
|
3739
|
+
url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
|
|
3740
|
+
headers: combineHeaders6(
|
|
3741
|
+
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
3742
|
+
options.headers
|
|
3743
|
+
),
|
|
3744
|
+
body: requestBody,
|
|
3745
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
3746
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
3747
|
+
googleSpeechResponseSchema
|
|
3748
|
+
),
|
|
3749
|
+
abortSignal: options.abortSignal,
|
|
3750
|
+
fetch: this.config.fetch
|
|
3751
|
+
});
|
|
3752
|
+
let base64Audio;
|
|
3753
|
+
let mimeType;
|
|
3754
|
+
for (const candidate of (_d = response.candidates) != null ? _d : []) {
|
|
3755
|
+
for (const part of (_f = (_e = candidate.content) == null ? void 0 : _e.parts) != null ? _f : []) {
|
|
3756
|
+
if ((_g = part.inlineData) == null ? void 0 : _g.data) {
|
|
3757
|
+
base64Audio = part.inlineData.data;
|
|
3758
|
+
mimeType = (_h = part.inlineData.mimeType) != null ? _h : void 0;
|
|
3759
|
+
break;
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
if (base64Audio != null) {
|
|
3763
|
+
break;
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
const sampleRate = (_i = parseSampleRate(mimeType)) != null ? _i : DEFAULT_SAMPLE_RATE;
|
|
3767
|
+
const pcm = base64Audio != null ? convertBase64ToUint8Array(base64Audio) : new Uint8Array(0);
|
|
3768
|
+
const audio = outputFormat === "pcm" || pcm.length === 0 ? pcm : addWavHeader(pcm, sampleRate);
|
|
3769
|
+
if (outputFormat === "pcm" && pcm.length > 0) {
|
|
3770
|
+
warnings.push({
|
|
3771
|
+
type: "unsupported",
|
|
3772
|
+
feature: "outputFormat",
|
|
3773
|
+
details: `Returning raw PCM audio (signed 16-bit little-endian, mono, ${sampleRate} Hz). These bytes have no container header and are not directly playable; see providerMetadata.google for the sample rate and mime type.`
|
|
3774
|
+
});
|
|
3775
|
+
}
|
|
3776
|
+
return {
|
|
3777
|
+
audio,
|
|
3778
|
+
warnings,
|
|
3779
|
+
request: {
|
|
3780
|
+
body: JSON.stringify(requestBody)
|
|
3781
|
+
},
|
|
3782
|
+
response: {
|
|
3783
|
+
timestamp: currentDate,
|
|
3784
|
+
modelId: this.modelId,
|
|
3785
|
+
headers: responseHeaders,
|
|
3786
|
+
body: rawResponse
|
|
3787
|
+
},
|
|
3788
|
+
providerMetadata: {
|
|
3789
|
+
google: {
|
|
3790
|
+
sampleRate,
|
|
3791
|
+
mimeType: mimeType != null ? mimeType : null
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
}
|
|
3796
|
+
};
|
|
3797
|
+
function parseSampleRate(mimeType) {
|
|
3798
|
+
if (mimeType == null) {
|
|
3799
|
+
return void 0;
|
|
3800
|
+
}
|
|
3801
|
+
const match = /rate=(\d+)/.exec(mimeType);
|
|
3802
|
+
return match ? Number.parseInt(match[1], 10) : void 0;
|
|
3803
|
+
}
|
|
3804
|
+
function addWavHeader(pcm, sampleRate) {
|
|
3805
|
+
const numChannels = 1;
|
|
3806
|
+
const bitsPerSample = 16;
|
|
3807
|
+
const blockAlign = numChannels * bitsPerSample / 8;
|
|
3808
|
+
const byteRate = sampleRate * blockAlign;
|
|
3809
|
+
const dataSize = pcm.length;
|
|
3810
|
+
const buffer = new ArrayBuffer(44 + dataSize);
|
|
3811
|
+
const view = new DataView(buffer);
|
|
3812
|
+
writeAscii(view, 0, "RIFF");
|
|
3813
|
+
view.setUint32(4, 36 + dataSize, true);
|
|
3814
|
+
writeAscii(view, 8, "WAVE");
|
|
3815
|
+
writeAscii(view, 12, "fmt ");
|
|
3816
|
+
view.setUint32(16, 16, true);
|
|
3817
|
+
view.setUint16(20, 1, true);
|
|
3818
|
+
view.setUint16(22, numChannels, true);
|
|
3819
|
+
view.setUint32(24, sampleRate, true);
|
|
3820
|
+
view.setUint32(28, byteRate, true);
|
|
3821
|
+
view.setUint16(32, blockAlign, true);
|
|
3822
|
+
view.setUint16(34, bitsPerSample, true);
|
|
3823
|
+
writeAscii(view, 36, "data");
|
|
3824
|
+
view.setUint32(40, dataSize, true);
|
|
3825
|
+
const out = new Uint8Array(buffer);
|
|
3826
|
+
out.set(pcm, 44);
|
|
3827
|
+
return out;
|
|
3828
|
+
}
|
|
3829
|
+
function writeAscii(view, offset, text) {
|
|
3830
|
+
for (let i = 0; i < text.length; i++) {
|
|
3831
|
+
view.setUint8(offset + i, text.charCodeAt(i));
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3835
|
+
// src/interactions/google-interactions-language-model.ts
|
|
3836
|
+
import {
|
|
3837
|
+
combineHeaders as combineHeaders8,
|
|
3838
|
+
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
3839
|
+
createJsonResponseHandler as createJsonResponseHandler8,
|
|
3840
|
+
generateId as defaultGenerateId2,
|
|
3841
|
+
parseProviderOptions as parseProviderOptions7,
|
|
3842
|
+
postJsonToApi as postJsonToApi6,
|
|
3843
|
+
resolve as resolve6,
|
|
3844
|
+
serializeModelOptions as serializeModelOptions5,
|
|
3845
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE5,
|
|
3846
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
|
|
3847
|
+
} from "@ai-sdk/provider-utils";
|
|
3848
|
+
|
|
3590
3849
|
// src/interactions/convert-google-interactions-usage.ts
|
|
3591
3850
|
function convertGoogleInteractionsUsage(usage) {
|
|
3592
3851
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -4686,33 +4945,33 @@ ${block.text}`
|
|
|
4686
4945
|
|
|
4687
4946
|
// src/interactions/google-interactions-api.ts
|
|
4688
4947
|
import {
|
|
4689
|
-
lazySchema as
|
|
4690
|
-
zodSchema as
|
|
4948
|
+
lazySchema as lazySchema18,
|
|
4949
|
+
zodSchema as zodSchema18
|
|
4691
4950
|
} from "@ai-sdk/provider-utils";
|
|
4692
|
-
import { z as
|
|
4693
|
-
var tokenByModalitySchema = () =>
|
|
4694
|
-
modality:
|
|
4695
|
-
tokens:
|
|
4951
|
+
import { z as z20 } from "zod/v4";
|
|
4952
|
+
var tokenByModalitySchema = () => z20.object({
|
|
4953
|
+
modality: z20.string().nullish(),
|
|
4954
|
+
tokens: z20.number().nullish()
|
|
4696
4955
|
}).loose();
|
|
4697
|
-
var usageSchema2 = () =>
|
|
4698
|
-
total_input_tokens:
|
|
4699
|
-
total_output_tokens:
|
|
4700
|
-
total_thought_tokens:
|
|
4701
|
-
total_cached_tokens:
|
|
4702
|
-
total_tool_use_tokens:
|
|
4703
|
-
total_tokens:
|
|
4704
|
-
input_tokens_by_modality:
|
|
4705
|
-
output_tokens_by_modality:
|
|
4706
|
-
cached_tokens_by_modality:
|
|
4707
|
-
tool_use_tokens_by_modality:
|
|
4708
|
-
grounding_tool_count:
|
|
4709
|
-
|
|
4710
|
-
type:
|
|
4711
|
-
count:
|
|
4956
|
+
var usageSchema2 = () => z20.object({
|
|
4957
|
+
total_input_tokens: z20.number().nullish(),
|
|
4958
|
+
total_output_tokens: z20.number().nullish(),
|
|
4959
|
+
total_thought_tokens: z20.number().nullish(),
|
|
4960
|
+
total_cached_tokens: z20.number().nullish(),
|
|
4961
|
+
total_tool_use_tokens: z20.number().nullish(),
|
|
4962
|
+
total_tokens: z20.number().nullish(),
|
|
4963
|
+
input_tokens_by_modality: z20.array(tokenByModalitySchema()).nullish(),
|
|
4964
|
+
output_tokens_by_modality: z20.array(tokenByModalitySchema()).nullish(),
|
|
4965
|
+
cached_tokens_by_modality: z20.array(tokenByModalitySchema()).nullish(),
|
|
4966
|
+
tool_use_tokens_by_modality: z20.array(tokenByModalitySchema()).nullish(),
|
|
4967
|
+
grounding_tool_count: z20.array(
|
|
4968
|
+
z20.object({
|
|
4969
|
+
type: z20.string().nullish(),
|
|
4970
|
+
count: z20.number().nullish()
|
|
4712
4971
|
}).loose()
|
|
4713
4972
|
).nullish()
|
|
4714
4973
|
}).loose();
|
|
4715
|
-
var interactionStatusSchema = () =>
|
|
4974
|
+
var interactionStatusSchema = () => z20.enum([
|
|
4716
4975
|
"in_progress",
|
|
4717
4976
|
"requires_action",
|
|
4718
4977
|
"completed",
|
|
@@ -4721,62 +4980,62 @@ var interactionStatusSchema = () => z18.enum([
|
|
|
4721
4980
|
"incomplete"
|
|
4722
4981
|
]);
|
|
4723
4982
|
var annotationSchema = () => {
|
|
4724
|
-
const urlCitation =
|
|
4725
|
-
type:
|
|
4726
|
-
url:
|
|
4727
|
-
title:
|
|
4728
|
-
start_index:
|
|
4729
|
-
end_index:
|
|
4983
|
+
const urlCitation = z20.object({
|
|
4984
|
+
type: z20.literal("url_citation"),
|
|
4985
|
+
url: z20.string().nullish(),
|
|
4986
|
+
title: z20.string().nullish(),
|
|
4987
|
+
start_index: z20.number().nullish(),
|
|
4988
|
+
end_index: z20.number().nullish()
|
|
4730
4989
|
}).loose();
|
|
4731
|
-
const fileCitation =
|
|
4732
|
-
type:
|
|
4733
|
-
file_name:
|
|
4734
|
-
document_uri:
|
|
4735
|
-
url:
|
|
4736
|
-
page_number:
|
|
4737
|
-
media_id:
|
|
4738
|
-
start_index:
|
|
4739
|
-
end_index:
|
|
4740
|
-
custom_metadata:
|
|
4990
|
+
const fileCitation = z20.object({
|
|
4991
|
+
type: z20.literal("file_citation"),
|
|
4992
|
+
file_name: z20.string().nullish(),
|
|
4993
|
+
document_uri: z20.string().nullish(),
|
|
4994
|
+
url: z20.string().nullish(),
|
|
4995
|
+
page_number: z20.number().nullish(),
|
|
4996
|
+
media_id: z20.string().nullish(),
|
|
4997
|
+
start_index: z20.number().nullish(),
|
|
4998
|
+
end_index: z20.number().nullish(),
|
|
4999
|
+
custom_metadata: z20.record(z20.string(), z20.unknown()).nullish()
|
|
4741
5000
|
}).loose();
|
|
4742
|
-
const placeCitation =
|
|
4743
|
-
type:
|
|
4744
|
-
name:
|
|
4745
|
-
url:
|
|
4746
|
-
place_id:
|
|
4747
|
-
start_index:
|
|
4748
|
-
end_index:
|
|
5001
|
+
const placeCitation = z20.object({
|
|
5002
|
+
type: z20.literal("place_citation"),
|
|
5003
|
+
name: z20.string().nullish(),
|
|
5004
|
+
url: z20.string().nullish(),
|
|
5005
|
+
place_id: z20.string().nullish(),
|
|
5006
|
+
start_index: z20.number().nullish(),
|
|
5007
|
+
end_index: z20.number().nullish()
|
|
4749
5008
|
}).loose();
|
|
4750
|
-
return
|
|
5009
|
+
return z20.union([
|
|
4751
5010
|
urlCitation,
|
|
4752
5011
|
fileCitation,
|
|
4753
5012
|
placeCitation,
|
|
4754
|
-
|
|
5013
|
+
z20.object({ type: z20.string() }).loose()
|
|
4755
5014
|
]);
|
|
4756
5015
|
};
|
|
4757
|
-
var thoughtSummaryItemSchema = () =>
|
|
4758
|
-
type:
|
|
4759
|
-
text:
|
|
4760
|
-
data:
|
|
4761
|
-
mime_type:
|
|
5016
|
+
var thoughtSummaryItemSchema = () => z20.object({
|
|
5017
|
+
type: z20.string(),
|
|
5018
|
+
text: z20.string().nullish(),
|
|
5019
|
+
data: z20.string().nullish(),
|
|
5020
|
+
mime_type: z20.string().nullish()
|
|
4762
5021
|
}).loose();
|
|
4763
5022
|
var contentBlockSchema = () => {
|
|
4764
|
-
const textContent =
|
|
4765
|
-
type:
|
|
4766
|
-
text:
|
|
4767
|
-
annotations:
|
|
5023
|
+
const textContent = z20.object({
|
|
5024
|
+
type: z20.literal("text"),
|
|
5025
|
+
text: z20.string(),
|
|
5026
|
+
annotations: z20.array(annotationSchema()).nullish()
|
|
4768
5027
|
}).loose();
|
|
4769
|
-
const imageContent =
|
|
4770
|
-
type:
|
|
4771
|
-
data:
|
|
4772
|
-
mime_type:
|
|
4773
|
-
resolution:
|
|
4774
|
-
uri:
|
|
5028
|
+
const imageContent = z20.object({
|
|
5029
|
+
type: z20.literal("image"),
|
|
5030
|
+
data: z20.string().nullish(),
|
|
5031
|
+
mime_type: z20.string().nullish(),
|
|
5032
|
+
resolution: z20.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5033
|
+
uri: z20.string().nullish()
|
|
4775
5034
|
}).loose();
|
|
4776
|
-
return
|
|
5035
|
+
return z20.union([
|
|
4777
5036
|
textContent,
|
|
4778
5037
|
imageContent,
|
|
4779
|
-
|
|
5038
|
+
z20.object({ type: z20.string() }).loose()
|
|
4780
5039
|
]);
|
|
4781
5040
|
};
|
|
4782
5041
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4796,152 +5055,152 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4796
5055
|
"mcp_server_tool_result"
|
|
4797
5056
|
];
|
|
4798
5057
|
var stepSchema = () => {
|
|
4799
|
-
const userInputStep =
|
|
4800
|
-
type:
|
|
4801
|
-
content:
|
|
5058
|
+
const userInputStep = z20.object({
|
|
5059
|
+
type: z20.literal("user_input"),
|
|
5060
|
+
content: z20.array(contentBlockSchema()).nullish()
|
|
4802
5061
|
}).loose();
|
|
4803
|
-
const modelOutputStep =
|
|
4804
|
-
type:
|
|
4805
|
-
content:
|
|
5062
|
+
const modelOutputStep = z20.object({
|
|
5063
|
+
type: z20.literal("model_output"),
|
|
5064
|
+
content: z20.array(contentBlockSchema()).nullish()
|
|
4806
5065
|
}).loose();
|
|
4807
|
-
const functionCallStep =
|
|
4808
|
-
type:
|
|
4809
|
-
id:
|
|
4810
|
-
name:
|
|
4811
|
-
arguments:
|
|
4812
|
-
signature:
|
|
5066
|
+
const functionCallStep = z20.object({
|
|
5067
|
+
type: z20.literal("function_call"),
|
|
5068
|
+
id: z20.string(),
|
|
5069
|
+
name: z20.string(),
|
|
5070
|
+
arguments: z20.record(z20.string(), z20.unknown()).nullish(),
|
|
5071
|
+
signature: z20.string().nullish()
|
|
4813
5072
|
}).loose();
|
|
4814
|
-
const thoughtStep =
|
|
4815
|
-
type:
|
|
4816
|
-
signature:
|
|
4817
|
-
summary:
|
|
5073
|
+
const thoughtStep = z20.object({
|
|
5074
|
+
type: z20.literal("thought"),
|
|
5075
|
+
signature: z20.string().nullish(),
|
|
5076
|
+
summary: z20.array(thoughtSummaryItemSchema()).nullish()
|
|
4818
5077
|
}).loose();
|
|
4819
|
-
const builtinToolCallStep =
|
|
4820
|
-
type:
|
|
4821
|
-
id:
|
|
4822
|
-
arguments:
|
|
4823
|
-
name:
|
|
4824
|
-
server_name:
|
|
4825
|
-
search_type:
|
|
4826
|
-
signature:
|
|
5078
|
+
const builtinToolCallStep = z20.object({
|
|
5079
|
+
type: z20.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5080
|
+
id: z20.string(),
|
|
5081
|
+
arguments: z20.record(z20.string(), z20.unknown()).nullish(),
|
|
5082
|
+
name: z20.string().nullish(),
|
|
5083
|
+
server_name: z20.string().nullish(),
|
|
5084
|
+
search_type: z20.string().nullish(),
|
|
5085
|
+
signature: z20.string().nullish()
|
|
4827
5086
|
}).loose();
|
|
4828
|
-
const builtinToolResultStep =
|
|
4829
|
-
type:
|
|
4830
|
-
call_id:
|
|
4831
|
-
result:
|
|
4832
|
-
is_error:
|
|
4833
|
-
name:
|
|
4834
|
-
server_name:
|
|
4835
|
-
signature:
|
|
5087
|
+
const builtinToolResultStep = z20.object({
|
|
5088
|
+
type: z20.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5089
|
+
call_id: z20.string(),
|
|
5090
|
+
result: z20.unknown().nullish(),
|
|
5091
|
+
is_error: z20.boolean().nullish(),
|
|
5092
|
+
name: z20.string().nullish(),
|
|
5093
|
+
server_name: z20.string().nullish(),
|
|
5094
|
+
signature: z20.string().nullish()
|
|
4836
5095
|
}).loose();
|
|
4837
|
-
return
|
|
5096
|
+
return z20.union([
|
|
4838
5097
|
userInputStep,
|
|
4839
5098
|
modelOutputStep,
|
|
4840
5099
|
functionCallStep,
|
|
4841
5100
|
thoughtStep,
|
|
4842
5101
|
builtinToolCallStep,
|
|
4843
5102
|
builtinToolResultStep,
|
|
4844
|
-
|
|
5103
|
+
z20.object({ type: z20.string() }).loose()
|
|
4845
5104
|
]);
|
|
4846
5105
|
};
|
|
4847
|
-
var googleInteractionsResponseSchema =
|
|
4848
|
-
() =>
|
|
4849
|
-
|
|
5106
|
+
var googleInteractionsResponseSchema = lazySchema18(
|
|
5107
|
+
() => zodSchema18(
|
|
5108
|
+
z20.object({
|
|
4850
5109
|
/*
|
|
4851
5110
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4852
5111
|
* stateless mode) — there is no server-side interaction record for the
|
|
4853
5112
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4854
5113
|
*/
|
|
4855
|
-
id:
|
|
4856
|
-
created:
|
|
4857
|
-
updated:
|
|
5114
|
+
id: z20.string().nullish(),
|
|
5115
|
+
created: z20.string().nullish(),
|
|
5116
|
+
updated: z20.string().nullish(),
|
|
4858
5117
|
status: interactionStatusSchema(),
|
|
4859
|
-
model:
|
|
4860
|
-
agent:
|
|
4861
|
-
steps:
|
|
5118
|
+
model: z20.string().nullish(),
|
|
5119
|
+
agent: z20.string().nullish(),
|
|
5120
|
+
steps: z20.array(stepSchema()).nullish(),
|
|
4862
5121
|
usage: usageSchema2().nullish(),
|
|
4863
|
-
service_tier:
|
|
4864
|
-
previous_interaction_id:
|
|
4865
|
-
response_modalities:
|
|
5122
|
+
service_tier: z20.string().nullish(),
|
|
5123
|
+
previous_interaction_id: z20.string().nullish(),
|
|
5124
|
+
response_modalities: z20.array(z20.string()).nullish()
|
|
4866
5125
|
}).loose()
|
|
4867
5126
|
)
|
|
4868
5127
|
);
|
|
4869
|
-
var googleInteractionsEventSchema =
|
|
4870
|
-
() =>
|
|
5128
|
+
var googleInteractionsEventSchema = lazySchema18(
|
|
5129
|
+
() => zodSchema18(
|
|
4871
5130
|
(() => {
|
|
4872
5131
|
const status = interactionStatusSchema();
|
|
4873
5132
|
const annotation = annotationSchema();
|
|
4874
5133
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4875
|
-
const interactionCreatedEvent =
|
|
4876
|
-
event_type:
|
|
4877
|
-
event_id:
|
|
4878
|
-
interaction:
|
|
5134
|
+
const interactionCreatedEvent = z20.object({
|
|
5135
|
+
event_type: z20.literal("interaction.created"),
|
|
5136
|
+
event_id: z20.string().nullish(),
|
|
5137
|
+
interaction: z20.object({
|
|
4879
5138
|
/*
|
|
4880
5139
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4881
5140
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4882
5141
|
*/
|
|
4883
|
-
id:
|
|
4884
|
-
created:
|
|
4885
|
-
model:
|
|
4886
|
-
agent:
|
|
5142
|
+
id: z20.string().nullish(),
|
|
5143
|
+
created: z20.string().nullish(),
|
|
5144
|
+
model: z20.string().nullish(),
|
|
5145
|
+
agent: z20.string().nullish(),
|
|
4887
5146
|
status: status.nullish()
|
|
4888
5147
|
}).loose()
|
|
4889
5148
|
}).loose();
|
|
4890
|
-
const stepStartEvent =
|
|
4891
|
-
event_type:
|
|
4892
|
-
event_id:
|
|
4893
|
-
index:
|
|
5149
|
+
const stepStartEvent = z20.object({
|
|
5150
|
+
event_type: z20.literal("step.start"),
|
|
5151
|
+
event_id: z20.string().nullish(),
|
|
5152
|
+
index: z20.number(),
|
|
4894
5153
|
step: stepSchema()
|
|
4895
5154
|
}).loose();
|
|
4896
|
-
const stepDeltaText =
|
|
4897
|
-
type:
|
|
4898
|
-
text:
|
|
5155
|
+
const stepDeltaText = z20.object({
|
|
5156
|
+
type: z20.literal("text"),
|
|
5157
|
+
text: z20.string()
|
|
4899
5158
|
}).loose();
|
|
4900
|
-
const stepDeltaThoughtSummary =
|
|
4901
|
-
type:
|
|
5159
|
+
const stepDeltaThoughtSummary = z20.object({
|
|
5160
|
+
type: z20.literal("thought_summary"),
|
|
4902
5161
|
content: thoughtSummaryItem.nullish()
|
|
4903
5162
|
}).loose();
|
|
4904
|
-
const stepDeltaThoughtSignature =
|
|
4905
|
-
type:
|
|
4906
|
-
signature:
|
|
5163
|
+
const stepDeltaThoughtSignature = z20.object({
|
|
5164
|
+
type: z20.literal("thought_signature"),
|
|
5165
|
+
signature: z20.string().nullish()
|
|
4907
5166
|
}).loose();
|
|
4908
|
-
const stepDeltaArgumentsDelta =
|
|
4909
|
-
type:
|
|
4910
|
-
arguments:
|
|
4911
|
-
id:
|
|
4912
|
-
signature:
|
|
5167
|
+
const stepDeltaArgumentsDelta = z20.object({
|
|
5168
|
+
type: z20.literal("arguments_delta"),
|
|
5169
|
+
arguments: z20.string().nullish(),
|
|
5170
|
+
id: z20.string().nullish(),
|
|
5171
|
+
signature: z20.string().nullish()
|
|
4913
5172
|
}).loose();
|
|
4914
|
-
const stepDeltaTextAnnotation =
|
|
4915
|
-
type:
|
|
4916
|
-
annotations:
|
|
5173
|
+
const stepDeltaTextAnnotation = z20.object({
|
|
5174
|
+
type: z20.enum(["text_annotation_delta", "text_annotation"]),
|
|
5175
|
+
annotations: z20.array(annotation).nullish()
|
|
4917
5176
|
}).loose();
|
|
4918
|
-
const stepDeltaImage =
|
|
4919
|
-
type:
|
|
4920
|
-
data:
|
|
4921
|
-
mime_type:
|
|
4922
|
-
resolution:
|
|
4923
|
-
uri:
|
|
5177
|
+
const stepDeltaImage = z20.object({
|
|
5178
|
+
type: z20.literal("image"),
|
|
5179
|
+
data: z20.string().nullish(),
|
|
5180
|
+
mime_type: z20.string().nullish(),
|
|
5181
|
+
resolution: z20.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5182
|
+
uri: z20.string().nullish()
|
|
4924
5183
|
}).loose();
|
|
4925
|
-
const stepDeltaBuiltinToolCall =
|
|
4926
|
-
type:
|
|
4927
|
-
id:
|
|
4928
|
-
arguments:
|
|
4929
|
-
name:
|
|
4930
|
-
server_name:
|
|
4931
|
-
search_type:
|
|
4932
|
-
signature:
|
|
5184
|
+
const stepDeltaBuiltinToolCall = z20.object({
|
|
5185
|
+
type: z20.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
5186
|
+
id: z20.string().nullish(),
|
|
5187
|
+
arguments: z20.record(z20.string(), z20.unknown()).nullish(),
|
|
5188
|
+
name: z20.string().nullish(),
|
|
5189
|
+
server_name: z20.string().nullish(),
|
|
5190
|
+
search_type: z20.string().nullish(),
|
|
5191
|
+
signature: z20.string().nullish()
|
|
4933
5192
|
}).loose();
|
|
4934
|
-
const stepDeltaBuiltinToolResult =
|
|
4935
|
-
type:
|
|
4936
|
-
call_id:
|
|
4937
|
-
result:
|
|
4938
|
-
is_error:
|
|
4939
|
-
name:
|
|
4940
|
-
server_name:
|
|
4941
|
-
signature:
|
|
5193
|
+
const stepDeltaBuiltinToolResult = z20.object({
|
|
5194
|
+
type: z20.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
5195
|
+
call_id: z20.string().nullish(),
|
|
5196
|
+
result: z20.unknown().nullish(),
|
|
5197
|
+
is_error: z20.boolean().nullish(),
|
|
5198
|
+
name: z20.string().nullish(),
|
|
5199
|
+
server_name: z20.string().nullish(),
|
|
5200
|
+
signature: z20.string().nullish()
|
|
4942
5201
|
}).loose();
|
|
4943
|
-
const stepDeltaUnknown =
|
|
4944
|
-
const stepDeltaUnion =
|
|
5202
|
+
const stepDeltaUnknown = z20.object({ type: z20.string() }).loose();
|
|
5203
|
+
const stepDeltaUnion = z20.union([
|
|
4945
5204
|
stepDeltaText,
|
|
4946
5205
|
stepDeltaImage,
|
|
4947
5206
|
stepDeltaThoughtSummary,
|
|
@@ -4952,55 +5211,55 @@ var googleInteractionsEventSchema = lazySchema16(
|
|
|
4952
5211
|
stepDeltaBuiltinToolResult,
|
|
4953
5212
|
stepDeltaUnknown
|
|
4954
5213
|
]);
|
|
4955
|
-
const stepDeltaEvent =
|
|
4956
|
-
event_type:
|
|
4957
|
-
event_id:
|
|
4958
|
-
index:
|
|
5214
|
+
const stepDeltaEvent = z20.object({
|
|
5215
|
+
event_type: z20.literal("step.delta"),
|
|
5216
|
+
event_id: z20.string().nullish(),
|
|
5217
|
+
index: z20.number(),
|
|
4959
5218
|
delta: stepDeltaUnion
|
|
4960
5219
|
}).loose();
|
|
4961
|
-
const stepStopEvent =
|
|
4962
|
-
event_type:
|
|
4963
|
-
event_id:
|
|
4964
|
-
index:
|
|
5220
|
+
const stepStopEvent = z20.object({
|
|
5221
|
+
event_type: z20.literal("step.stop"),
|
|
5222
|
+
event_id: z20.string().nullish(),
|
|
5223
|
+
index: z20.number()
|
|
4965
5224
|
}).loose();
|
|
4966
|
-
const interactionStatusUpdateEvent =
|
|
4967
|
-
event_type:
|
|
4968
|
-
event_id:
|
|
4969
|
-
interaction_id:
|
|
5225
|
+
const interactionStatusUpdateEvent = z20.object({
|
|
5226
|
+
event_type: z20.literal("interaction.status_update"),
|
|
5227
|
+
event_id: z20.string().nullish(),
|
|
5228
|
+
interaction_id: z20.string().nullish(),
|
|
4970
5229
|
status: status.nullish()
|
|
4971
5230
|
}).loose();
|
|
4972
|
-
const interactionInProgressEvent =
|
|
4973
|
-
event_type:
|
|
4974
|
-
event_id:
|
|
4975
|
-
interaction_id:
|
|
5231
|
+
const interactionInProgressEvent = z20.object({
|
|
5232
|
+
event_type: z20.literal("interaction.in_progress"),
|
|
5233
|
+
event_id: z20.string().nullish(),
|
|
5234
|
+
interaction_id: z20.string().nullish(),
|
|
4976
5235
|
status: status.nullish()
|
|
4977
5236
|
}).loose();
|
|
4978
|
-
const interactionRequiresActionEvent =
|
|
4979
|
-
event_type:
|
|
4980
|
-
event_id:
|
|
4981
|
-
interaction_id:
|
|
5237
|
+
const interactionRequiresActionEvent = z20.object({
|
|
5238
|
+
event_type: z20.literal("interaction.requires_action"),
|
|
5239
|
+
event_id: z20.string().nullish(),
|
|
5240
|
+
interaction_id: z20.string().nullish(),
|
|
4982
5241
|
status: status.nullish()
|
|
4983
5242
|
}).loose();
|
|
4984
|
-
const interactionCompletedEvent =
|
|
4985
|
-
event_type:
|
|
4986
|
-
event_id:
|
|
4987
|
-
interaction:
|
|
4988
|
-
id:
|
|
5243
|
+
const interactionCompletedEvent = z20.object({
|
|
5244
|
+
event_type: z20.literal("interaction.completed"),
|
|
5245
|
+
event_id: z20.string().nullish(),
|
|
5246
|
+
interaction: z20.object({
|
|
5247
|
+
id: z20.string().nullish(),
|
|
4989
5248
|
status: status.nullish(),
|
|
4990
5249
|
usage: usageSchema2().nullish(),
|
|
4991
|
-
service_tier:
|
|
5250
|
+
service_tier: z20.string().nullish()
|
|
4992
5251
|
}).loose()
|
|
4993
5252
|
}).loose();
|
|
4994
|
-
const errorEvent =
|
|
4995
|
-
event_type:
|
|
4996
|
-
event_id:
|
|
4997
|
-
error:
|
|
4998
|
-
code:
|
|
4999
|
-
message:
|
|
5253
|
+
const errorEvent = z20.object({
|
|
5254
|
+
event_type: z20.literal("error"),
|
|
5255
|
+
event_id: z20.string().nullish(),
|
|
5256
|
+
error: z20.object({
|
|
5257
|
+
code: z20.string().nullish(),
|
|
5258
|
+
message: z20.string().nullish()
|
|
5000
5259
|
}).loose().nullish()
|
|
5001
5260
|
}).loose();
|
|
5002
|
-
const unknownEvent =
|
|
5003
|
-
return
|
|
5261
|
+
const unknownEvent = z20.object({ event_type: z20.string() }).loose();
|
|
5262
|
+
return z20.union([
|
|
5004
5263
|
interactionCreatedEvent,
|
|
5005
5264
|
stepStartEvent,
|
|
5006
5265
|
stepDeltaEvent,
|
|
@@ -5018,29 +5277,29 @@ var googleInteractionsEventSchema = lazySchema16(
|
|
|
5018
5277
|
|
|
5019
5278
|
// src/interactions/google-interactions-language-model-options.ts
|
|
5020
5279
|
import {
|
|
5021
|
-
lazySchema as
|
|
5022
|
-
zodSchema as
|
|
5280
|
+
lazySchema as lazySchema19,
|
|
5281
|
+
zodSchema as zodSchema19
|
|
5023
5282
|
} from "@ai-sdk/provider-utils";
|
|
5024
|
-
import { z as
|
|
5025
|
-
var googleInteractionsLanguageModelOptions =
|
|
5026
|
-
() =>
|
|
5027
|
-
|
|
5028
|
-
previousInteractionId:
|
|
5029
|
-
store:
|
|
5030
|
-
agent:
|
|
5031
|
-
agentConfig:
|
|
5032
|
-
|
|
5033
|
-
type:
|
|
5283
|
+
import { z as z21 } from "zod/v4";
|
|
5284
|
+
var googleInteractionsLanguageModelOptions = lazySchema19(
|
|
5285
|
+
() => zodSchema19(
|
|
5286
|
+
z21.object({
|
|
5287
|
+
previousInteractionId: z21.string().nullish(),
|
|
5288
|
+
store: z21.boolean().nullish(),
|
|
5289
|
+
agent: z21.string().nullish(),
|
|
5290
|
+
agentConfig: z21.union([
|
|
5291
|
+
z21.object({
|
|
5292
|
+
type: z21.literal("dynamic")
|
|
5034
5293
|
}).loose(),
|
|
5035
|
-
|
|
5036
|
-
type:
|
|
5037
|
-
thinkingSummaries:
|
|
5038
|
-
visualization:
|
|
5039
|
-
collaborativePlanning:
|
|
5294
|
+
z21.object({
|
|
5295
|
+
type: z21.literal("deep-research"),
|
|
5296
|
+
thinkingSummaries: z21.enum(["auto", "none"]).nullish(),
|
|
5297
|
+
visualization: z21.enum(["off", "auto"]).nullish(),
|
|
5298
|
+
collaborativePlanning: z21.boolean().nullish()
|
|
5040
5299
|
})
|
|
5041
5300
|
]).nullish(),
|
|
5042
|
-
thinkingLevel:
|
|
5043
|
-
thinkingSummaries:
|
|
5301
|
+
thinkingLevel: z21.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5302
|
+
thinkingSummaries: z21.enum(["auto", "none"]).nullish(),
|
|
5044
5303
|
/**
|
|
5045
5304
|
* Output-format entries that map directly to the API's `response_format`
|
|
5046
5305
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -5050,17 +5309,17 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5050
5309
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
5051
5310
|
* text entry automatically; entries listed here are appended.
|
|
5052
5311
|
*/
|
|
5053
|
-
responseFormat:
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
type:
|
|
5057
|
-
mimeType:
|
|
5058
|
-
schema:
|
|
5312
|
+
responseFormat: z21.array(
|
|
5313
|
+
z21.union([
|
|
5314
|
+
z21.object({
|
|
5315
|
+
type: z21.literal("text"),
|
|
5316
|
+
mimeType: z21.string().nullish(),
|
|
5317
|
+
schema: z21.unknown().nullish()
|
|
5059
5318
|
}).loose(),
|
|
5060
|
-
|
|
5061
|
-
type:
|
|
5062
|
-
mimeType:
|
|
5063
|
-
aspectRatio:
|
|
5319
|
+
z21.object({
|
|
5320
|
+
type: z21.literal("image"),
|
|
5321
|
+
mimeType: z21.string().nullish(),
|
|
5322
|
+
aspectRatio: z21.enum([
|
|
5064
5323
|
"1:1",
|
|
5065
5324
|
"2:3",
|
|
5066
5325
|
"3:2",
|
|
@@ -5076,11 +5335,11 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5076
5335
|
"1:4",
|
|
5077
5336
|
"4:1"
|
|
5078
5337
|
]).nullish(),
|
|
5079
|
-
imageSize:
|
|
5338
|
+
imageSize: z21.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5080
5339
|
}).loose(),
|
|
5081
|
-
|
|
5082
|
-
type:
|
|
5083
|
-
mimeType:
|
|
5340
|
+
z21.object({
|
|
5341
|
+
type: z21.literal("audio"),
|
|
5342
|
+
mimeType: z21.string().nullish()
|
|
5084
5343
|
}).loose()
|
|
5085
5344
|
])
|
|
5086
5345
|
).nullish(),
|
|
@@ -5090,8 +5349,8 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5090
5349
|
* translates it into a matching `response_format` image entry and
|
|
5091
5350
|
* emits a warning when set.
|
|
5092
5351
|
*/
|
|
5093
|
-
imageConfig:
|
|
5094
|
-
aspectRatio:
|
|
5352
|
+
imageConfig: z21.object({
|
|
5353
|
+
aspectRatio: z21.enum([
|
|
5095
5354
|
"1:1",
|
|
5096
5355
|
"2:3",
|
|
5097
5356
|
"3:2",
|
|
@@ -5107,35 +5366,35 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5107
5366
|
"1:4",
|
|
5108
5367
|
"4:1"
|
|
5109
5368
|
]).nullish(),
|
|
5110
|
-
imageSize:
|
|
5369
|
+
imageSize: z21.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5111
5370
|
}).nullish(),
|
|
5112
|
-
mediaResolution:
|
|
5113
|
-
responseModalities:
|
|
5114
|
-
serviceTier:
|
|
5371
|
+
mediaResolution: z21.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
5372
|
+
responseModalities: z21.array(z21.enum(["text", "image", "audio", "video", "document"])).nullish(),
|
|
5373
|
+
serviceTier: z21.enum(["flex", "standard", "priority"]).nullish(),
|
|
5115
5374
|
/**
|
|
5116
5375
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5117
5376
|
* `system` message wins and a warning is emitted.
|
|
5118
5377
|
*/
|
|
5119
|
-
systemInstruction:
|
|
5378
|
+
systemInstruction: z21.string().nullish(),
|
|
5120
5379
|
/**
|
|
5121
5380
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5122
5381
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5123
5382
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5124
5383
|
* accepts the prior turn.
|
|
5125
5384
|
*/
|
|
5126
|
-
signature:
|
|
5385
|
+
signature: z21.string().nullish(),
|
|
5127
5386
|
/**
|
|
5128
5387
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5129
5388
|
* decide which messages to drop when compacting under
|
|
5130
5389
|
* `previousInteractionId`.
|
|
5131
5390
|
*/
|
|
5132
|
-
interactionId:
|
|
5391
|
+
interactionId: z21.string().nullish(),
|
|
5133
5392
|
/**
|
|
5134
5393
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5135
5394
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5136
5395
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5137
5396
|
*/
|
|
5138
|
-
pollingTimeoutMs:
|
|
5397
|
+
pollingTimeoutMs: z21.number().int().positive().nullish(),
|
|
5139
5398
|
/**
|
|
5140
5399
|
* Run the interaction in the background. Required for agents whose
|
|
5141
5400
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5144,7 +5403,7 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5144
5403
|
* reject `true`; see the agent's documentation for which mode it
|
|
5145
5404
|
* requires.
|
|
5146
5405
|
*/
|
|
5147
|
-
background:
|
|
5406
|
+
background: z21.boolean().nullish(),
|
|
5148
5407
|
/**
|
|
5149
5408
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5150
5409
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5154,36 +5413,36 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5154
5413
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5155
5414
|
* and/or constrain outbound traffic via `network`.
|
|
5156
5415
|
*/
|
|
5157
|
-
environment:
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
type:
|
|
5161
|
-
sources:
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
type:
|
|
5165
|
-
source:
|
|
5166
|
-
target:
|
|
5416
|
+
environment: z21.union([
|
|
5417
|
+
z21.string(),
|
|
5418
|
+
z21.object({
|
|
5419
|
+
type: z21.literal("remote"),
|
|
5420
|
+
sources: z21.array(
|
|
5421
|
+
z21.union([
|
|
5422
|
+
z21.object({
|
|
5423
|
+
type: z21.literal("gcs"),
|
|
5424
|
+
source: z21.string(),
|
|
5425
|
+
target: z21.string().nullish()
|
|
5167
5426
|
}),
|
|
5168
|
-
|
|
5169
|
-
type:
|
|
5170
|
-
source:
|
|
5171
|
-
target:
|
|
5427
|
+
z21.object({
|
|
5428
|
+
type: z21.literal("repository"),
|
|
5429
|
+
source: z21.string(),
|
|
5430
|
+
target: z21.string().nullish()
|
|
5172
5431
|
}),
|
|
5173
|
-
|
|
5174
|
-
type:
|
|
5175
|
-
content:
|
|
5176
|
-
target:
|
|
5432
|
+
z21.object({
|
|
5433
|
+
type: z21.literal("inline"),
|
|
5434
|
+
content: z21.string(),
|
|
5435
|
+
target: z21.string()
|
|
5177
5436
|
})
|
|
5178
5437
|
])
|
|
5179
5438
|
).nullish(),
|
|
5180
|
-
network:
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
allowlist:
|
|
5184
|
-
|
|
5185
|
-
domain:
|
|
5186
|
-
transform:
|
|
5439
|
+
network: z21.union([
|
|
5440
|
+
z21.literal("disabled"),
|
|
5441
|
+
z21.object({
|
|
5442
|
+
allowlist: z21.array(
|
|
5443
|
+
z21.object({
|
|
5444
|
+
domain: z21.string(),
|
|
5445
|
+
transform: z21.array(z21.record(z21.string(), z21.string())).nullish()
|
|
5187
5446
|
})
|
|
5188
5447
|
)
|
|
5189
5448
|
})
|
|
@@ -5356,7 +5615,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5356
5615
|
|
|
5357
5616
|
// src/interactions/poll-google-interactions.ts
|
|
5358
5617
|
import {
|
|
5359
|
-
createJsonResponseHandler as
|
|
5618
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
5360
5619
|
delay as delay3,
|
|
5361
5620
|
getFromApi as getFromApi3,
|
|
5362
5621
|
isAbortError
|
|
@@ -5364,7 +5623,7 @@ import {
|
|
|
5364
5623
|
|
|
5365
5624
|
// src/interactions/cancel-google-interaction.ts
|
|
5366
5625
|
import {
|
|
5367
|
-
combineHeaders as
|
|
5626
|
+
combineHeaders as combineHeaders7,
|
|
5368
5627
|
getRuntimeEnvironmentUserAgent,
|
|
5369
5628
|
withUserAgentSuffix
|
|
5370
5629
|
} from "@ai-sdk/provider-utils";
|
|
@@ -5383,7 +5642,7 @@ async function cancelGoogleInteraction({
|
|
|
5383
5642
|
const response = await fetch(url, {
|
|
5384
5643
|
method: "POST",
|
|
5385
5644
|
headers: withUserAgentSuffix(
|
|
5386
|
-
|
|
5645
|
+
combineHeaders7({ "Content-Type": "application/json" }, headers),
|
|
5387
5646
|
getRuntimeEnvironmentUserAgent()
|
|
5388
5647
|
),
|
|
5389
5648
|
body: "{}"
|
|
@@ -5443,7 +5702,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5443
5702
|
url,
|
|
5444
5703
|
headers,
|
|
5445
5704
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5446
|
-
successfulResponseHandler:
|
|
5705
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
5447
5706
|
googleInteractionsResponseSchema
|
|
5448
5707
|
),
|
|
5449
5708
|
abortSignal,
|
|
@@ -5935,16 +6194,16 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5935
6194
|
}
|
|
5936
6195
|
this.config = config;
|
|
5937
6196
|
}
|
|
5938
|
-
static [
|
|
6197
|
+
static [WORKFLOW_SERIALIZE5](model) {
|
|
5939
6198
|
return {
|
|
5940
|
-
...
|
|
6199
|
+
...serializeModelOptions5({
|
|
5941
6200
|
modelId: model.modelId,
|
|
5942
6201
|
config: model.config
|
|
5943
6202
|
}),
|
|
5944
6203
|
agent: model.agent
|
|
5945
6204
|
};
|
|
5946
6205
|
}
|
|
5947
|
-
static [
|
|
6206
|
+
static [WORKFLOW_DESERIALIZE5](options) {
|
|
5948
6207
|
return new _GoogleInteractionsLanguageModel(
|
|
5949
6208
|
options.agent != null ? { agent: options.agent } : options.modelId,
|
|
5950
6209
|
options.config
|
|
@@ -5971,7 +6230,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5971
6230
|
async getArgs(options) {
|
|
5972
6231
|
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;
|
|
5973
6232
|
const warnings = [];
|
|
5974
|
-
const googleOptions = await
|
|
6233
|
+
const googleOptions = await parseProviderOptions7({
|
|
5975
6234
|
provider: "google",
|
|
5976
6235
|
providerOptions: options.providerOptions,
|
|
5977
6236
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6203,17 +6462,17 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6203
6462
|
var _a, _b, _c, _d, _e, _f;
|
|
6204
6463
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6205
6464
|
const url = `${this.config.baseURL}/interactions`;
|
|
6206
|
-
const mergedHeaders =
|
|
6465
|
+
const mergedHeaders = combineHeaders8(
|
|
6207
6466
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6208
|
-
this.config.headers ? await
|
|
6467
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6209
6468
|
options.headers
|
|
6210
6469
|
);
|
|
6211
|
-
const postResult = await
|
|
6470
|
+
const postResult = await postJsonToApi6({
|
|
6212
6471
|
url,
|
|
6213
6472
|
headers: mergedHeaders,
|
|
6214
6473
|
body: args,
|
|
6215
6474
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6216
|
-
successfulResponseHandler:
|
|
6475
|
+
successfulResponseHandler: createJsonResponseHandler8(
|
|
6217
6476
|
googleInteractionsResponseSchema
|
|
6218
6477
|
),
|
|
6219
6478
|
abortSignal: options.abortSignal,
|
|
@@ -6284,9 +6543,9 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6284
6543
|
var _a;
|
|
6285
6544
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6286
6545
|
const url = `${this.config.baseURL}/interactions`;
|
|
6287
|
-
const mergedHeaders =
|
|
6546
|
+
const mergedHeaders = combineHeaders8(
|
|
6288
6547
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6289
|
-
this.config.headers ? await
|
|
6548
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6290
6549
|
options.headers
|
|
6291
6550
|
);
|
|
6292
6551
|
if (isBackground) {
|
|
@@ -6300,7 +6559,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6300
6559
|
});
|
|
6301
6560
|
}
|
|
6302
6561
|
const body = { ...args, stream: true };
|
|
6303
|
-
const { responseHeaders, value: response } = await
|
|
6562
|
+
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
6304
6563
|
url,
|
|
6305
6564
|
headers: mergedHeaders,
|
|
6306
6565
|
body,
|
|
@@ -6351,12 +6610,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6351
6610
|
pollingTimeoutMs
|
|
6352
6611
|
}) {
|
|
6353
6612
|
var _a, _b;
|
|
6354
|
-
const postResult = await
|
|
6613
|
+
const postResult = await postJsonToApi6({
|
|
6355
6614
|
url,
|
|
6356
6615
|
headers: mergedHeaders,
|
|
6357
6616
|
body: args,
|
|
6358
6617
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6359
|
-
successfulResponseHandler:
|
|
6618
|
+
successfulResponseHandler: createJsonResponseHandler8(
|
|
6360
6619
|
googleInteractionsResponseSchema
|
|
6361
6620
|
),
|
|
6362
6621
|
abortSignal: options.abortSignal,
|
|
@@ -6483,6 +6742,12 @@ function createGoogle(options = {}) {
|
|
|
6483
6742
|
generateId: (_a2 = options.generateId) != null ? _a2 : generateId2
|
|
6484
6743
|
});
|
|
6485
6744
|
};
|
|
6745
|
+
const createSpeechModel = (modelId) => new GoogleSpeechModel(modelId, {
|
|
6746
|
+
provider: `${providerName}.speech`,
|
|
6747
|
+
baseURL,
|
|
6748
|
+
headers: getHeaders,
|
|
6749
|
+
fetch: options.fetch
|
|
6750
|
+
});
|
|
6486
6751
|
const createInteractionsModel = (modelIdOrAgent) => {
|
|
6487
6752
|
var _a2;
|
|
6488
6753
|
return new GoogleInteractionsLanguageModel(
|
|
@@ -6517,6 +6782,8 @@ function createGoogle(options = {}) {
|
|
|
6517
6782
|
provider.video = createVideoModel;
|
|
6518
6783
|
provider.videoModel = createVideoModel;
|
|
6519
6784
|
provider.files = createFiles;
|
|
6785
|
+
provider.speech = createSpeechModel;
|
|
6786
|
+
provider.speechModel = createSpeechModel;
|
|
6520
6787
|
provider.interactions = createInteractionsModel;
|
|
6521
6788
|
provider.tools = googleTools;
|
|
6522
6789
|
return provider;
|