@ai-sdk/google 4.0.0-canary.74 → 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 +12 -0
- package/dist/index.d.ts +27 -4
- package/dist/index.js +638 -366
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +10 -10
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +78 -0
- package/package.json +1 -1
- package/src/google-embedding-model-options.ts +1 -0
- package/src/google-json-accumulator.ts +10 -10
- package/src/google-language-model-options.ts +2 -0
- 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/src/interactions/build-google-interactions-stream-transform.ts +7 -7
- package/src/interactions/extract-google-interactions-sources.ts +20 -13
- package/src/interactions/google-interactions-language-model.ts +50 -46
- package/src/interactions/stream-google-interactions.ts +8 -5
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 {
|
|
@@ -1428,19 +1428,19 @@ var GoogleJSONAccumulator = class {
|
|
|
1428
1428
|
let fragment = "";
|
|
1429
1429
|
const startIdx = this.pathStack.length - 1;
|
|
1430
1430
|
for (let i = startIdx; i < targetContainer.length; i++) {
|
|
1431
|
-
const
|
|
1431
|
+
const pathSegment = targetContainer[i];
|
|
1432
1432
|
const parentEntry = this.pathStack[this.pathStack.length - 1];
|
|
1433
1433
|
if (parentEntry.childCount > 0) {
|
|
1434
1434
|
fragment += ",";
|
|
1435
1435
|
}
|
|
1436
1436
|
parentEntry.childCount++;
|
|
1437
|
-
if (typeof
|
|
1438
|
-
fragment += `${JSON.stringify(
|
|
1437
|
+
if (typeof pathSegment === "string") {
|
|
1438
|
+
fragment += `${JSON.stringify(pathSegment)}:`;
|
|
1439
1439
|
}
|
|
1440
1440
|
const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
|
|
1441
1441
|
const isArray = typeof childSeg === "number";
|
|
1442
1442
|
fragment += isArray ? "[" : "{";
|
|
1443
|
-
this.pathStack.push({ segment:
|
|
1443
|
+
this.pathStack.push({ segment: pathSegment, isArray, childCount: 0 });
|
|
1444
1444
|
}
|
|
1445
1445
|
return fragment;
|
|
1446
1446
|
}
|
|
@@ -1486,21 +1486,21 @@ function parsePath(rawPath) {
|
|
|
1486
1486
|
}
|
|
1487
1487
|
function getNestedValue(obj, segments) {
|
|
1488
1488
|
let current = obj;
|
|
1489
|
-
for (const
|
|
1489
|
+
for (const pathSegment of segments) {
|
|
1490
1490
|
if (current == null || typeof current !== "object") return void 0;
|
|
1491
|
-
current = current[
|
|
1491
|
+
current = current[pathSegment];
|
|
1492
1492
|
}
|
|
1493
1493
|
return current;
|
|
1494
1494
|
}
|
|
1495
1495
|
function setNestedValue(obj, segments, value) {
|
|
1496
1496
|
let current = obj;
|
|
1497
1497
|
for (let i = 0; i < segments.length - 1; i++) {
|
|
1498
|
-
const
|
|
1498
|
+
const pathSegment = segments[i];
|
|
1499
1499
|
const nextSeg = segments[i + 1];
|
|
1500
|
-
if (current[
|
|
1501
|
-
current[
|
|
1500
|
+
if (current[pathSegment] == null) {
|
|
1501
|
+
current[pathSegment] = typeof nextSeg === "number" ? [] : {};
|
|
1502
1502
|
}
|
|
1503
|
-
current = current[
|
|
1503
|
+
current = current[pathSegment];
|
|
1504
1504
|
}
|
|
1505
1505
|
current[segments[segments.length - 1]] = value;
|
|
1506
1506
|
}
|
|
@@ -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;
|
|
@@ -3654,19 +3913,21 @@ function annotationToSource({
|
|
|
3654
3913
|
var _a, _b, _c, _d, _e;
|
|
3655
3914
|
switch (annotation.type) {
|
|
3656
3915
|
case "url_citation": {
|
|
3657
|
-
const
|
|
3658
|
-
if (
|
|
3916
|
+
const urlCitation = annotation;
|
|
3917
|
+
if (urlCitation.url == null || urlCitation.url.length === 0) {
|
|
3918
|
+
return void 0;
|
|
3919
|
+
}
|
|
3659
3920
|
return {
|
|
3660
3921
|
type: "source",
|
|
3661
3922
|
sourceType: "url",
|
|
3662
3923
|
id: generateId3(),
|
|
3663
|
-
url:
|
|
3664
|
-
...
|
|
3924
|
+
url: urlCitation.url,
|
|
3925
|
+
...urlCitation.title != null ? { title: urlCitation.title } : {}
|
|
3665
3926
|
};
|
|
3666
3927
|
}
|
|
3667
3928
|
case "file_citation": {
|
|
3668
|
-
const
|
|
3669
|
-
const uri = (_b = (_a =
|
|
3929
|
+
const fileCitation = annotation;
|
|
3930
|
+
const uri = (_b = (_a = fileCitation.url) != null ? _a : fileCitation.document_uri) != null ? _b : fileCitation.file_name;
|
|
3670
3931
|
if (uri == null || uri.length === 0) return void 0;
|
|
3671
3932
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3672
3933
|
return {
|
|
@@ -3674,29 +3935,31 @@ function annotationToSource({
|
|
|
3674
3935
|
sourceType: "url",
|
|
3675
3936
|
id: generateId3(),
|
|
3676
3937
|
url: uri,
|
|
3677
|
-
...
|
|
3938
|
+
...fileCitation.file_name != null ? { title: fileCitation.file_name } : {}
|
|
3678
3939
|
};
|
|
3679
3940
|
}
|
|
3680
|
-
const filename = (_c =
|
|
3941
|
+
const filename = (_c = fileCitation.file_name) != null ? _c : basename(uri);
|
|
3681
3942
|
const mediaType = inferDocMediaType(uri);
|
|
3682
3943
|
return {
|
|
3683
3944
|
type: "source",
|
|
3684
3945
|
sourceType: "document",
|
|
3685
3946
|
id: generateId3(),
|
|
3686
3947
|
mediaType,
|
|
3687
|
-
title: (_e = (_d =
|
|
3948
|
+
title: (_e = (_d = fileCitation.file_name) != null ? _d : filename) != null ? _e : uri,
|
|
3688
3949
|
...filename != null ? { filename } : {}
|
|
3689
3950
|
};
|
|
3690
3951
|
}
|
|
3691
3952
|
case "place_citation": {
|
|
3692
|
-
const
|
|
3693
|
-
if (
|
|
3953
|
+
const placeCitation = annotation;
|
|
3954
|
+
if (placeCitation.url == null || placeCitation.url.length === 0) {
|
|
3955
|
+
return void 0;
|
|
3956
|
+
}
|
|
3694
3957
|
return {
|
|
3695
3958
|
type: "source",
|
|
3696
3959
|
sourceType: "url",
|
|
3697
3960
|
id: generateId3(),
|
|
3698
|
-
url:
|
|
3699
|
-
...
|
|
3961
|
+
url: placeCitation.url,
|
|
3962
|
+
...placeCitation.name != null ? { title: placeCitation.name } : {}
|
|
3700
3963
|
};
|
|
3701
3964
|
}
|
|
3702
3965
|
default:
|
|
@@ -4034,22 +4297,22 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4034
4297
|
}
|
|
4035
4298
|
}
|
|
4036
4299
|
if (dtype === "image" && (open.kind === "pending_model_output" || open.kind === "text" || open.kind === "image")) {
|
|
4037
|
-
const
|
|
4300
|
+
const imageDelta = event.delta;
|
|
4038
4301
|
const google2 = {};
|
|
4039
4302
|
if (interactionId != null) google2.interactionId = interactionId;
|
|
4040
4303
|
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
4041
|
-
if ((
|
|
4304
|
+
if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
|
|
4042
4305
|
controller.enqueue({
|
|
4043
4306
|
type: "file",
|
|
4044
|
-
mediaType: (_k =
|
|
4045
|
-
data: { type: "data", data:
|
|
4307
|
+
mediaType: (_k = imageDelta.mime_type) != null ? _k : "image/png",
|
|
4308
|
+
data: { type: "data", data: imageDelta.data },
|
|
4046
4309
|
...providerMetadata ? { providerMetadata } : {}
|
|
4047
4310
|
});
|
|
4048
|
-
} else if ((
|
|
4311
|
+
} else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
|
|
4049
4312
|
controller.enqueue({
|
|
4050
4313
|
type: "file",
|
|
4051
|
-
mediaType: (_l =
|
|
4052
|
-
data: { type: "url", url: new URL(
|
|
4314
|
+
mediaType: (_l = imageDelta.mime_type) != null ? _l : "image/png",
|
|
4315
|
+
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
4053
4316
|
...providerMetadata ? { providerMetadata } : {}
|
|
4054
4317
|
});
|
|
4055
4318
|
}
|
|
@@ -4682,33 +4945,33 @@ ${block.text}`
|
|
|
4682
4945
|
|
|
4683
4946
|
// src/interactions/google-interactions-api.ts
|
|
4684
4947
|
import {
|
|
4685
|
-
lazySchema as
|
|
4686
|
-
zodSchema as
|
|
4948
|
+
lazySchema as lazySchema18,
|
|
4949
|
+
zodSchema as zodSchema18
|
|
4687
4950
|
} from "@ai-sdk/provider-utils";
|
|
4688
|
-
import { z as
|
|
4689
|
-
var tokenByModalitySchema = () =>
|
|
4690
|
-
modality:
|
|
4691
|
-
tokens:
|
|
4951
|
+
import { z as z20 } from "zod/v4";
|
|
4952
|
+
var tokenByModalitySchema = () => z20.object({
|
|
4953
|
+
modality: z20.string().nullish(),
|
|
4954
|
+
tokens: z20.number().nullish()
|
|
4692
4955
|
}).loose();
|
|
4693
|
-
var usageSchema2 = () =>
|
|
4694
|
-
total_input_tokens:
|
|
4695
|
-
total_output_tokens:
|
|
4696
|
-
total_thought_tokens:
|
|
4697
|
-
total_cached_tokens:
|
|
4698
|
-
total_tool_use_tokens:
|
|
4699
|
-
total_tokens:
|
|
4700
|
-
input_tokens_by_modality:
|
|
4701
|
-
output_tokens_by_modality:
|
|
4702
|
-
cached_tokens_by_modality:
|
|
4703
|
-
tool_use_tokens_by_modality:
|
|
4704
|
-
grounding_tool_count:
|
|
4705
|
-
|
|
4706
|
-
type:
|
|
4707
|
-
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()
|
|
4708
4971
|
}).loose()
|
|
4709
4972
|
).nullish()
|
|
4710
4973
|
}).loose();
|
|
4711
|
-
var interactionStatusSchema = () =>
|
|
4974
|
+
var interactionStatusSchema = () => z20.enum([
|
|
4712
4975
|
"in_progress",
|
|
4713
4976
|
"requires_action",
|
|
4714
4977
|
"completed",
|
|
@@ -4717,62 +4980,62 @@ var interactionStatusSchema = () => z18.enum([
|
|
|
4717
4980
|
"incomplete"
|
|
4718
4981
|
]);
|
|
4719
4982
|
var annotationSchema = () => {
|
|
4720
|
-
const urlCitation =
|
|
4721
|
-
type:
|
|
4722
|
-
url:
|
|
4723
|
-
title:
|
|
4724
|
-
start_index:
|
|
4725
|
-
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()
|
|
4726
4989
|
}).loose();
|
|
4727
|
-
const fileCitation =
|
|
4728
|
-
type:
|
|
4729
|
-
file_name:
|
|
4730
|
-
document_uri:
|
|
4731
|
-
url:
|
|
4732
|
-
page_number:
|
|
4733
|
-
media_id:
|
|
4734
|
-
start_index:
|
|
4735
|
-
end_index:
|
|
4736
|
-
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()
|
|
4737
5000
|
}).loose();
|
|
4738
|
-
const placeCitation =
|
|
4739
|
-
type:
|
|
4740
|
-
name:
|
|
4741
|
-
url:
|
|
4742
|
-
place_id:
|
|
4743
|
-
start_index:
|
|
4744
|
-
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()
|
|
4745
5008
|
}).loose();
|
|
4746
|
-
return
|
|
5009
|
+
return z20.union([
|
|
4747
5010
|
urlCitation,
|
|
4748
5011
|
fileCitation,
|
|
4749
5012
|
placeCitation,
|
|
4750
|
-
|
|
5013
|
+
z20.object({ type: z20.string() }).loose()
|
|
4751
5014
|
]);
|
|
4752
5015
|
};
|
|
4753
|
-
var thoughtSummaryItemSchema = () =>
|
|
4754
|
-
type:
|
|
4755
|
-
text:
|
|
4756
|
-
data:
|
|
4757
|
-
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()
|
|
4758
5021
|
}).loose();
|
|
4759
5022
|
var contentBlockSchema = () => {
|
|
4760
|
-
const textContent =
|
|
4761
|
-
type:
|
|
4762
|
-
text:
|
|
4763
|
-
annotations:
|
|
5023
|
+
const textContent = z20.object({
|
|
5024
|
+
type: z20.literal("text"),
|
|
5025
|
+
text: z20.string(),
|
|
5026
|
+
annotations: z20.array(annotationSchema()).nullish()
|
|
4764
5027
|
}).loose();
|
|
4765
|
-
const imageContent =
|
|
4766
|
-
type:
|
|
4767
|
-
data:
|
|
4768
|
-
mime_type:
|
|
4769
|
-
resolution:
|
|
4770
|
-
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()
|
|
4771
5034
|
}).loose();
|
|
4772
|
-
return
|
|
5035
|
+
return z20.union([
|
|
4773
5036
|
textContent,
|
|
4774
5037
|
imageContent,
|
|
4775
|
-
|
|
5038
|
+
z20.object({ type: z20.string() }).loose()
|
|
4776
5039
|
]);
|
|
4777
5040
|
};
|
|
4778
5041
|
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
@@ -4792,152 +5055,152 @@ var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
|
4792
5055
|
"mcp_server_tool_result"
|
|
4793
5056
|
];
|
|
4794
5057
|
var stepSchema = () => {
|
|
4795
|
-
const userInputStep =
|
|
4796
|
-
type:
|
|
4797
|
-
content:
|
|
5058
|
+
const userInputStep = z20.object({
|
|
5059
|
+
type: z20.literal("user_input"),
|
|
5060
|
+
content: z20.array(contentBlockSchema()).nullish()
|
|
4798
5061
|
}).loose();
|
|
4799
|
-
const modelOutputStep =
|
|
4800
|
-
type:
|
|
4801
|
-
content:
|
|
5062
|
+
const modelOutputStep = z20.object({
|
|
5063
|
+
type: z20.literal("model_output"),
|
|
5064
|
+
content: z20.array(contentBlockSchema()).nullish()
|
|
4802
5065
|
}).loose();
|
|
4803
|
-
const functionCallStep =
|
|
4804
|
-
type:
|
|
4805
|
-
id:
|
|
4806
|
-
name:
|
|
4807
|
-
arguments:
|
|
4808
|
-
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()
|
|
4809
5072
|
}).loose();
|
|
4810
|
-
const thoughtStep =
|
|
4811
|
-
type:
|
|
4812
|
-
signature:
|
|
4813
|
-
summary:
|
|
5073
|
+
const thoughtStep = z20.object({
|
|
5074
|
+
type: z20.literal("thought"),
|
|
5075
|
+
signature: z20.string().nullish(),
|
|
5076
|
+
summary: z20.array(thoughtSummaryItemSchema()).nullish()
|
|
4814
5077
|
}).loose();
|
|
4815
|
-
const builtinToolCallStep =
|
|
4816
|
-
type:
|
|
4817
|
-
id:
|
|
4818
|
-
arguments:
|
|
4819
|
-
name:
|
|
4820
|
-
server_name:
|
|
4821
|
-
search_type:
|
|
4822
|
-
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()
|
|
4823
5086
|
}).loose();
|
|
4824
|
-
const builtinToolResultStep =
|
|
4825
|
-
type:
|
|
4826
|
-
call_id:
|
|
4827
|
-
result:
|
|
4828
|
-
is_error:
|
|
4829
|
-
name:
|
|
4830
|
-
server_name:
|
|
4831
|
-
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()
|
|
4832
5095
|
}).loose();
|
|
4833
|
-
return
|
|
5096
|
+
return z20.union([
|
|
4834
5097
|
userInputStep,
|
|
4835
5098
|
modelOutputStep,
|
|
4836
5099
|
functionCallStep,
|
|
4837
5100
|
thoughtStep,
|
|
4838
5101
|
builtinToolCallStep,
|
|
4839
5102
|
builtinToolResultStep,
|
|
4840
|
-
|
|
5103
|
+
z20.object({ type: z20.string() }).loose()
|
|
4841
5104
|
]);
|
|
4842
5105
|
};
|
|
4843
|
-
var googleInteractionsResponseSchema =
|
|
4844
|
-
() =>
|
|
4845
|
-
|
|
5106
|
+
var googleInteractionsResponseSchema = lazySchema18(
|
|
5107
|
+
() => zodSchema18(
|
|
5108
|
+
z20.object({
|
|
4846
5109
|
/*
|
|
4847
5110
|
* `id` is omitted from the response body when `store: false` (fully
|
|
4848
5111
|
* stateless mode) — there is no server-side interaction record for the
|
|
4849
5112
|
* client to reference. `nullish` lets the schema accept that shape.
|
|
4850
5113
|
*/
|
|
4851
|
-
id:
|
|
4852
|
-
created:
|
|
4853
|
-
updated:
|
|
5114
|
+
id: z20.string().nullish(),
|
|
5115
|
+
created: z20.string().nullish(),
|
|
5116
|
+
updated: z20.string().nullish(),
|
|
4854
5117
|
status: interactionStatusSchema(),
|
|
4855
|
-
model:
|
|
4856
|
-
agent:
|
|
4857
|
-
steps:
|
|
5118
|
+
model: z20.string().nullish(),
|
|
5119
|
+
agent: z20.string().nullish(),
|
|
5120
|
+
steps: z20.array(stepSchema()).nullish(),
|
|
4858
5121
|
usage: usageSchema2().nullish(),
|
|
4859
|
-
service_tier:
|
|
4860
|
-
previous_interaction_id:
|
|
4861
|
-
response_modalities:
|
|
5122
|
+
service_tier: z20.string().nullish(),
|
|
5123
|
+
previous_interaction_id: z20.string().nullish(),
|
|
5124
|
+
response_modalities: z20.array(z20.string()).nullish()
|
|
4862
5125
|
}).loose()
|
|
4863
5126
|
)
|
|
4864
5127
|
);
|
|
4865
|
-
var googleInteractionsEventSchema =
|
|
4866
|
-
() =>
|
|
5128
|
+
var googleInteractionsEventSchema = lazySchema18(
|
|
5129
|
+
() => zodSchema18(
|
|
4867
5130
|
(() => {
|
|
4868
5131
|
const status = interactionStatusSchema();
|
|
4869
5132
|
const annotation = annotationSchema();
|
|
4870
5133
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4871
|
-
const interactionCreatedEvent =
|
|
4872
|
-
event_type:
|
|
4873
|
-
event_id:
|
|
4874
|
-
interaction:
|
|
5134
|
+
const interactionCreatedEvent = z20.object({
|
|
5135
|
+
event_type: z20.literal("interaction.created"),
|
|
5136
|
+
event_id: z20.string().nullish(),
|
|
5137
|
+
interaction: z20.object({
|
|
4875
5138
|
/*
|
|
4876
5139
|
* `id` is omitted when `store: false` (fully stateless mode);
|
|
4877
5140
|
* see the matching note on `googleInteractionsResponseSchema.id`.
|
|
4878
5141
|
*/
|
|
4879
|
-
id:
|
|
4880
|
-
created:
|
|
4881
|
-
model:
|
|
4882
|
-
agent:
|
|
5142
|
+
id: z20.string().nullish(),
|
|
5143
|
+
created: z20.string().nullish(),
|
|
5144
|
+
model: z20.string().nullish(),
|
|
5145
|
+
agent: z20.string().nullish(),
|
|
4883
5146
|
status: status.nullish()
|
|
4884
5147
|
}).loose()
|
|
4885
5148
|
}).loose();
|
|
4886
|
-
const stepStartEvent =
|
|
4887
|
-
event_type:
|
|
4888
|
-
event_id:
|
|
4889
|
-
index:
|
|
5149
|
+
const stepStartEvent = z20.object({
|
|
5150
|
+
event_type: z20.literal("step.start"),
|
|
5151
|
+
event_id: z20.string().nullish(),
|
|
5152
|
+
index: z20.number(),
|
|
4890
5153
|
step: stepSchema()
|
|
4891
5154
|
}).loose();
|
|
4892
|
-
const stepDeltaText =
|
|
4893
|
-
type:
|
|
4894
|
-
text:
|
|
5155
|
+
const stepDeltaText = z20.object({
|
|
5156
|
+
type: z20.literal("text"),
|
|
5157
|
+
text: z20.string()
|
|
4895
5158
|
}).loose();
|
|
4896
|
-
const stepDeltaThoughtSummary =
|
|
4897
|
-
type:
|
|
5159
|
+
const stepDeltaThoughtSummary = z20.object({
|
|
5160
|
+
type: z20.literal("thought_summary"),
|
|
4898
5161
|
content: thoughtSummaryItem.nullish()
|
|
4899
5162
|
}).loose();
|
|
4900
|
-
const stepDeltaThoughtSignature =
|
|
4901
|
-
type:
|
|
4902
|
-
signature:
|
|
5163
|
+
const stepDeltaThoughtSignature = z20.object({
|
|
5164
|
+
type: z20.literal("thought_signature"),
|
|
5165
|
+
signature: z20.string().nullish()
|
|
4903
5166
|
}).loose();
|
|
4904
|
-
const stepDeltaArgumentsDelta =
|
|
4905
|
-
type:
|
|
4906
|
-
arguments:
|
|
4907
|
-
id:
|
|
4908
|
-
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()
|
|
4909
5172
|
}).loose();
|
|
4910
|
-
const stepDeltaTextAnnotation =
|
|
4911
|
-
type:
|
|
4912
|
-
annotations:
|
|
5173
|
+
const stepDeltaTextAnnotation = z20.object({
|
|
5174
|
+
type: z20.enum(["text_annotation_delta", "text_annotation"]),
|
|
5175
|
+
annotations: z20.array(annotation).nullish()
|
|
4913
5176
|
}).loose();
|
|
4914
|
-
const stepDeltaImage =
|
|
4915
|
-
type:
|
|
4916
|
-
data:
|
|
4917
|
-
mime_type:
|
|
4918
|
-
resolution:
|
|
4919
|
-
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()
|
|
4920
5183
|
}).loose();
|
|
4921
|
-
const stepDeltaBuiltinToolCall =
|
|
4922
|
-
type:
|
|
4923
|
-
id:
|
|
4924
|
-
arguments:
|
|
4925
|
-
name:
|
|
4926
|
-
server_name:
|
|
4927
|
-
search_type:
|
|
4928
|
-
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()
|
|
4929
5192
|
}).loose();
|
|
4930
|
-
const stepDeltaBuiltinToolResult =
|
|
4931
|
-
type:
|
|
4932
|
-
call_id:
|
|
4933
|
-
result:
|
|
4934
|
-
is_error:
|
|
4935
|
-
name:
|
|
4936
|
-
server_name:
|
|
4937
|
-
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()
|
|
4938
5201
|
}).loose();
|
|
4939
|
-
const stepDeltaUnknown =
|
|
4940
|
-
const stepDeltaUnion =
|
|
5202
|
+
const stepDeltaUnknown = z20.object({ type: z20.string() }).loose();
|
|
5203
|
+
const stepDeltaUnion = z20.union([
|
|
4941
5204
|
stepDeltaText,
|
|
4942
5205
|
stepDeltaImage,
|
|
4943
5206
|
stepDeltaThoughtSummary,
|
|
@@ -4948,55 +5211,55 @@ var googleInteractionsEventSchema = lazySchema16(
|
|
|
4948
5211
|
stepDeltaBuiltinToolResult,
|
|
4949
5212
|
stepDeltaUnknown
|
|
4950
5213
|
]);
|
|
4951
|
-
const stepDeltaEvent =
|
|
4952
|
-
event_type:
|
|
4953
|
-
event_id:
|
|
4954
|
-
index:
|
|
5214
|
+
const stepDeltaEvent = z20.object({
|
|
5215
|
+
event_type: z20.literal("step.delta"),
|
|
5216
|
+
event_id: z20.string().nullish(),
|
|
5217
|
+
index: z20.number(),
|
|
4955
5218
|
delta: stepDeltaUnion
|
|
4956
5219
|
}).loose();
|
|
4957
|
-
const stepStopEvent =
|
|
4958
|
-
event_type:
|
|
4959
|
-
event_id:
|
|
4960
|
-
index:
|
|
5220
|
+
const stepStopEvent = z20.object({
|
|
5221
|
+
event_type: z20.literal("step.stop"),
|
|
5222
|
+
event_id: z20.string().nullish(),
|
|
5223
|
+
index: z20.number()
|
|
4961
5224
|
}).loose();
|
|
4962
|
-
const interactionStatusUpdateEvent =
|
|
4963
|
-
event_type:
|
|
4964
|
-
event_id:
|
|
4965
|
-
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(),
|
|
4966
5229
|
status: status.nullish()
|
|
4967
5230
|
}).loose();
|
|
4968
|
-
const interactionInProgressEvent =
|
|
4969
|
-
event_type:
|
|
4970
|
-
event_id:
|
|
4971
|
-
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(),
|
|
4972
5235
|
status: status.nullish()
|
|
4973
5236
|
}).loose();
|
|
4974
|
-
const interactionRequiresActionEvent =
|
|
4975
|
-
event_type:
|
|
4976
|
-
event_id:
|
|
4977
|
-
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(),
|
|
4978
5241
|
status: status.nullish()
|
|
4979
5242
|
}).loose();
|
|
4980
|
-
const interactionCompletedEvent =
|
|
4981
|
-
event_type:
|
|
4982
|
-
event_id:
|
|
4983
|
-
interaction:
|
|
4984
|
-
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(),
|
|
4985
5248
|
status: status.nullish(),
|
|
4986
5249
|
usage: usageSchema2().nullish(),
|
|
4987
|
-
service_tier:
|
|
5250
|
+
service_tier: z20.string().nullish()
|
|
4988
5251
|
}).loose()
|
|
4989
5252
|
}).loose();
|
|
4990
|
-
const errorEvent =
|
|
4991
|
-
event_type:
|
|
4992
|
-
event_id:
|
|
4993
|
-
error:
|
|
4994
|
-
code:
|
|
4995
|
-
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()
|
|
4996
5259
|
}).loose().nullish()
|
|
4997
5260
|
}).loose();
|
|
4998
|
-
const unknownEvent =
|
|
4999
|
-
return
|
|
5261
|
+
const unknownEvent = z20.object({ event_type: z20.string() }).loose();
|
|
5262
|
+
return z20.union([
|
|
5000
5263
|
interactionCreatedEvent,
|
|
5001
5264
|
stepStartEvent,
|
|
5002
5265
|
stepDeltaEvent,
|
|
@@ -5014,29 +5277,29 @@ var googleInteractionsEventSchema = lazySchema16(
|
|
|
5014
5277
|
|
|
5015
5278
|
// src/interactions/google-interactions-language-model-options.ts
|
|
5016
5279
|
import {
|
|
5017
|
-
lazySchema as
|
|
5018
|
-
zodSchema as
|
|
5280
|
+
lazySchema as lazySchema19,
|
|
5281
|
+
zodSchema as zodSchema19
|
|
5019
5282
|
} from "@ai-sdk/provider-utils";
|
|
5020
|
-
import { z as
|
|
5021
|
-
var googleInteractionsLanguageModelOptions =
|
|
5022
|
-
() =>
|
|
5023
|
-
|
|
5024
|
-
previousInteractionId:
|
|
5025
|
-
store:
|
|
5026
|
-
agent:
|
|
5027
|
-
agentConfig:
|
|
5028
|
-
|
|
5029
|
-
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")
|
|
5030
5293
|
}).loose(),
|
|
5031
|
-
|
|
5032
|
-
type:
|
|
5033
|
-
thinkingSummaries:
|
|
5034
|
-
visualization:
|
|
5035
|
-
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()
|
|
5036
5299
|
})
|
|
5037
5300
|
]).nullish(),
|
|
5038
|
-
thinkingLevel:
|
|
5039
|
-
thinkingSummaries:
|
|
5301
|
+
thinkingLevel: z21.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
5302
|
+
thinkingSummaries: z21.enum(["auto", "none"]).nullish(),
|
|
5040
5303
|
/**
|
|
5041
5304
|
* Output-format entries that map directly to the API's `response_format`
|
|
5042
5305
|
* array. Use this to request image, audio, or non-JSON text outputs
|
|
@@ -5046,17 +5309,17 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5046
5309
|
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
5047
5310
|
* text entry automatically; entries listed here are appended.
|
|
5048
5311
|
*/
|
|
5049
|
-
responseFormat:
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
type:
|
|
5053
|
-
mimeType:
|
|
5054
|
-
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()
|
|
5055
5318
|
}).loose(),
|
|
5056
|
-
|
|
5057
|
-
type:
|
|
5058
|
-
mimeType:
|
|
5059
|
-
aspectRatio:
|
|
5319
|
+
z21.object({
|
|
5320
|
+
type: z21.literal("image"),
|
|
5321
|
+
mimeType: z21.string().nullish(),
|
|
5322
|
+
aspectRatio: z21.enum([
|
|
5060
5323
|
"1:1",
|
|
5061
5324
|
"2:3",
|
|
5062
5325
|
"3:2",
|
|
@@ -5072,11 +5335,11 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5072
5335
|
"1:4",
|
|
5073
5336
|
"4:1"
|
|
5074
5337
|
]).nullish(),
|
|
5075
|
-
imageSize:
|
|
5338
|
+
imageSize: z21.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5076
5339
|
}).loose(),
|
|
5077
|
-
|
|
5078
|
-
type:
|
|
5079
|
-
mimeType:
|
|
5340
|
+
z21.object({
|
|
5341
|
+
type: z21.literal("audio"),
|
|
5342
|
+
mimeType: z21.string().nullish()
|
|
5080
5343
|
}).loose()
|
|
5081
5344
|
])
|
|
5082
5345
|
).nullish(),
|
|
@@ -5086,8 +5349,8 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5086
5349
|
* translates it into a matching `response_format` image entry and
|
|
5087
5350
|
* emits a warning when set.
|
|
5088
5351
|
*/
|
|
5089
|
-
imageConfig:
|
|
5090
|
-
aspectRatio:
|
|
5352
|
+
imageConfig: z21.object({
|
|
5353
|
+
aspectRatio: z21.enum([
|
|
5091
5354
|
"1:1",
|
|
5092
5355
|
"2:3",
|
|
5093
5356
|
"3:2",
|
|
@@ -5103,35 +5366,35 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5103
5366
|
"1:4",
|
|
5104
5367
|
"4:1"
|
|
5105
5368
|
]).nullish(),
|
|
5106
|
-
imageSize:
|
|
5369
|
+
imageSize: z21.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
5107
5370
|
}).nullish(),
|
|
5108
|
-
mediaResolution:
|
|
5109
|
-
responseModalities:
|
|
5110
|
-
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(),
|
|
5111
5374
|
/**
|
|
5112
5375
|
* Alternative to AI SDK `system` message. If both are set, the AI SDK
|
|
5113
5376
|
* `system` message wins and a warning is emitted.
|
|
5114
5377
|
*/
|
|
5115
|
-
systemInstruction:
|
|
5378
|
+
systemInstruction: z21.string().nullish(),
|
|
5116
5379
|
/**
|
|
5117
5380
|
* Per-block signature for round-tripping `thought.signature` and
|
|
5118
5381
|
* `function_call.signature` blocks. Set by the SDK on output reasoning /
|
|
5119
5382
|
* tool-call parts; passed back unchanged on input parts so the API
|
|
5120
5383
|
* accepts the prior turn.
|
|
5121
5384
|
*/
|
|
5122
|
-
signature:
|
|
5385
|
+
signature: z21.string().nullish(),
|
|
5123
5386
|
/**
|
|
5124
5387
|
* Set by the SDK on output assistant messages. The converter uses it to
|
|
5125
5388
|
* decide which messages to drop when compacting under
|
|
5126
5389
|
* `previousInteractionId`.
|
|
5127
5390
|
*/
|
|
5128
|
-
interactionId:
|
|
5391
|
+
interactionId: z21.string().nullish(),
|
|
5129
5392
|
/**
|
|
5130
5393
|
* Maximum time, in milliseconds, to poll a background interaction (agent
|
|
5131
5394
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5132
5395
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5133
5396
|
*/
|
|
5134
|
-
pollingTimeoutMs:
|
|
5397
|
+
pollingTimeoutMs: z21.number().int().positive().nullish(),
|
|
5135
5398
|
/**
|
|
5136
5399
|
* Run the interaction in the background. Required for agents whose
|
|
5137
5400
|
* server-side workflow cannot complete within a single request/response.
|
|
@@ -5140,7 +5403,7 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5140
5403
|
* reject `true`; see the agent's documentation for which mode it
|
|
5141
5404
|
* requires.
|
|
5142
5405
|
*/
|
|
5143
|
-
background:
|
|
5406
|
+
background: z21.boolean().nullish(),
|
|
5144
5407
|
/**
|
|
5145
5408
|
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5146
5409
|
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
@@ -5150,36 +5413,36 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5150
5413
|
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5151
5414
|
* and/or constrain outbound traffic via `network`.
|
|
5152
5415
|
*/
|
|
5153
|
-
environment:
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
type:
|
|
5157
|
-
sources:
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
type:
|
|
5161
|
-
source:
|
|
5162
|
-
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()
|
|
5163
5426
|
}),
|
|
5164
|
-
|
|
5165
|
-
type:
|
|
5166
|
-
source:
|
|
5167
|
-
target:
|
|
5427
|
+
z21.object({
|
|
5428
|
+
type: z21.literal("repository"),
|
|
5429
|
+
source: z21.string(),
|
|
5430
|
+
target: z21.string().nullish()
|
|
5168
5431
|
}),
|
|
5169
|
-
|
|
5170
|
-
type:
|
|
5171
|
-
content:
|
|
5172
|
-
target:
|
|
5432
|
+
z21.object({
|
|
5433
|
+
type: z21.literal("inline"),
|
|
5434
|
+
content: z21.string(),
|
|
5435
|
+
target: z21.string()
|
|
5173
5436
|
})
|
|
5174
5437
|
])
|
|
5175
5438
|
).nullish(),
|
|
5176
|
-
network:
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
allowlist:
|
|
5180
|
-
|
|
5181
|
-
domain:
|
|
5182
|
-
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()
|
|
5183
5446
|
})
|
|
5184
5447
|
)
|
|
5185
5448
|
})
|
|
@@ -5352,7 +5615,7 @@ function parseGoogleInteractionsOutputs({
|
|
|
5352
5615
|
|
|
5353
5616
|
// src/interactions/poll-google-interactions.ts
|
|
5354
5617
|
import {
|
|
5355
|
-
createJsonResponseHandler as
|
|
5618
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
5356
5619
|
delay as delay3,
|
|
5357
5620
|
getFromApi as getFromApi3,
|
|
5358
5621
|
isAbortError
|
|
@@ -5360,7 +5623,7 @@ import {
|
|
|
5360
5623
|
|
|
5361
5624
|
// src/interactions/cancel-google-interaction.ts
|
|
5362
5625
|
import {
|
|
5363
|
-
combineHeaders as
|
|
5626
|
+
combineHeaders as combineHeaders7,
|
|
5364
5627
|
getRuntimeEnvironmentUserAgent,
|
|
5365
5628
|
withUserAgentSuffix
|
|
5366
5629
|
} from "@ai-sdk/provider-utils";
|
|
@@ -5379,7 +5642,7 @@ async function cancelGoogleInteraction({
|
|
|
5379
5642
|
const response = await fetch(url, {
|
|
5380
5643
|
method: "POST",
|
|
5381
5644
|
headers: withUserAgentSuffix(
|
|
5382
|
-
|
|
5645
|
+
combineHeaders7({ "Content-Type": "application/json" }, headers),
|
|
5383
5646
|
getRuntimeEnvironmentUserAgent()
|
|
5384
5647
|
),
|
|
5385
5648
|
body: "{}"
|
|
@@ -5439,7 +5702,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5439
5702
|
url,
|
|
5440
5703
|
headers,
|
|
5441
5704
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5442
|
-
successfulResponseHandler:
|
|
5705
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
5443
5706
|
googleInteractionsResponseSchema
|
|
5444
5707
|
),
|
|
5445
5708
|
abortSignal,
|
|
@@ -5720,11 +5983,11 @@ function streamGoogleInteractionEvents({
|
|
|
5720
5983
|
}
|
|
5721
5984
|
receivedAnyEventThisAttempt = true;
|
|
5722
5985
|
if (value.success) {
|
|
5723
|
-
const
|
|
5724
|
-
if (typeof
|
|
5725
|
-
lastEventId =
|
|
5986
|
+
const streamEvent = value.value;
|
|
5987
|
+
if (typeof streamEvent.event_id === "string" && streamEvent.event_id.length > 0) {
|
|
5988
|
+
lastEventId = streamEvent.event_id;
|
|
5726
5989
|
}
|
|
5727
|
-
if (
|
|
5990
|
+
if (streamEvent.event_type === "interaction.completed" || streamEvent.event_type === "error") {
|
|
5728
5991
|
complete = true;
|
|
5729
5992
|
}
|
|
5730
5993
|
}
|
|
@@ -5931,16 +6194,16 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5931
6194
|
}
|
|
5932
6195
|
this.config = config;
|
|
5933
6196
|
}
|
|
5934
|
-
static [
|
|
6197
|
+
static [WORKFLOW_SERIALIZE5](model) {
|
|
5935
6198
|
return {
|
|
5936
|
-
...
|
|
6199
|
+
...serializeModelOptions5({
|
|
5937
6200
|
modelId: model.modelId,
|
|
5938
6201
|
config: model.config
|
|
5939
6202
|
}),
|
|
5940
6203
|
agent: model.agent
|
|
5941
6204
|
};
|
|
5942
6205
|
}
|
|
5943
|
-
static [
|
|
6206
|
+
static [WORKFLOW_DESERIALIZE5](options) {
|
|
5944
6207
|
return new _GoogleInteractionsLanguageModel(
|
|
5945
6208
|
options.agent != null ? { agent: options.agent } : options.modelId,
|
|
5946
6209
|
options.config
|
|
@@ -5967,7 +6230,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5967
6230
|
async getArgs(options) {
|
|
5968
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;
|
|
5969
6232
|
const warnings = [];
|
|
5970
|
-
const
|
|
6233
|
+
const googleOptions = await parseProviderOptions7({
|
|
5971
6234
|
provider: "google",
|
|
5972
6235
|
providerOptions: options.providerOptions,
|
|
5973
6236
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -6006,8 +6269,8 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6006
6269
|
responseFormatEntries.push(entry);
|
|
6007
6270
|
}
|
|
6008
6271
|
}
|
|
6009
|
-
if ((
|
|
6010
|
-
for (const entry of
|
|
6272
|
+
if ((googleOptions == null ? void 0 : googleOptions.responseFormat) != null) {
|
|
6273
|
+
for (const entry of googleOptions.responseFormat) {
|
|
6011
6274
|
if (entry.type === "text") {
|
|
6012
6275
|
responseFormatEntries.push(
|
|
6013
6276
|
pruneUndefined({
|
|
@@ -6041,13 +6304,13 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6041
6304
|
warnings: convWarnings
|
|
6042
6305
|
} = convertToGoogleInteractionsInput({
|
|
6043
6306
|
prompt: options.prompt,
|
|
6044
|
-
previousInteractionId: (_h =
|
|
6045
|
-
store: (_i =
|
|
6046
|
-
mediaResolution: (_j =
|
|
6307
|
+
previousInteractionId: (_h = googleOptions == null ? void 0 : googleOptions.previousInteractionId) != null ? _h : void 0,
|
|
6308
|
+
store: (_i = googleOptions == null ? void 0 : googleOptions.store) != null ? _i : void 0,
|
|
6309
|
+
mediaResolution: (_j = googleOptions == null ? void 0 : googleOptions.mediaResolution) != null ? _j : void 0
|
|
6047
6310
|
});
|
|
6048
6311
|
warnings.push(...convWarnings);
|
|
6049
6312
|
let systemInstruction = convertedSystemInstruction;
|
|
6050
|
-
const optionSystemInstruction = (_k =
|
|
6313
|
+
const optionSystemInstruction = (_k = googleOptions == null ? void 0 : googleOptions.systemInstruction) != null ? _k : void 0;
|
|
6051
6314
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
6052
6315
|
warnings.push({
|
|
6053
6316
|
type: "other",
|
|
@@ -6067,11 +6330,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6067
6330
|
}
|
|
6068
6331
|
if (options.maxOutputTokens != null)
|
|
6069
6332
|
droppedFields.push("maxOutputTokens");
|
|
6070
|
-
if ((
|
|
6071
|
-
|
|
6333
|
+
if ((googleOptions == null ? void 0 : googleOptions.thinkingLevel) != null)
|
|
6334
|
+
droppedFields.push("thinkingLevel");
|
|
6335
|
+
if ((googleOptions == null ? void 0 : googleOptions.thinkingSummaries) != null) {
|
|
6072
6336
|
droppedFields.push("thinkingSummaries");
|
|
6073
6337
|
}
|
|
6074
|
-
if ((
|
|
6338
|
+
if ((googleOptions == null ? void 0 : googleOptions.imageConfig) != null) droppedFields.push("imageConfig");
|
|
6075
6339
|
if (droppedFields.length > 0) {
|
|
6076
6340
|
warnings.push({
|
|
6077
6341
|
type: "other",
|
|
@@ -6086,11 +6350,11 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6086
6350
|
seed: (_n = options.seed) != null ? _n : void 0,
|
|
6087
6351
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
6088
6352
|
max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
|
|
6089
|
-
thinking_level: (_p =
|
|
6090
|
-
thinking_summaries: (_q =
|
|
6353
|
+
thinking_level: (_p = googleOptions == null ? void 0 : googleOptions.thinkingLevel) != null ? _p : void 0,
|
|
6354
|
+
thinking_summaries: (_q = googleOptions == null ? void 0 : googleOptions.thinkingSummaries) != null ? _q : void 0,
|
|
6091
6355
|
tool_choice: toolChoiceForBody
|
|
6092
6356
|
});
|
|
6093
|
-
if ((
|
|
6357
|
+
if ((googleOptions == null ? void 0 : googleOptions.imageConfig) != null) {
|
|
6094
6358
|
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
6095
6359
|
(entry) => entry.type === "image"
|
|
6096
6360
|
);
|
|
@@ -6102,58 +6366,58 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6102
6366
|
responseFormatEntries.push({
|
|
6103
6367
|
type: "image",
|
|
6104
6368
|
mime_type: "image/png",
|
|
6105
|
-
...
|
|
6106
|
-
...
|
|
6369
|
+
...googleOptions.imageConfig.aspectRatio != null ? { aspect_ratio: googleOptions.imageConfig.aspectRatio } : {},
|
|
6370
|
+
...googleOptions.imageConfig.imageSize != null ? { image_size: googleOptions.imageConfig.imageSize } : {}
|
|
6107
6371
|
});
|
|
6108
6372
|
}
|
|
6109
6373
|
}
|
|
6110
6374
|
}
|
|
6111
6375
|
let agentConfig;
|
|
6112
|
-
if (isAgent && (
|
|
6113
|
-
const
|
|
6114
|
-
if (
|
|
6376
|
+
if (isAgent && (googleOptions == null ? void 0 : googleOptions.agentConfig) != null) {
|
|
6377
|
+
const agentConfigOptions = googleOptions.agentConfig;
|
|
6378
|
+
if (agentConfigOptions.type === "deep-research") {
|
|
6115
6379
|
agentConfig = pruneUndefined({
|
|
6116
6380
|
type: "deep-research",
|
|
6117
|
-
thinking_summaries: (_r =
|
|
6118
|
-
visualization: (_s =
|
|
6119
|
-
collaborative_planning: (_t =
|
|
6381
|
+
thinking_summaries: (_r = agentConfigOptions.thinkingSummaries) != null ? _r : void 0,
|
|
6382
|
+
visualization: (_s = agentConfigOptions.visualization) != null ? _s : void 0,
|
|
6383
|
+
collaborative_planning: (_t = agentConfigOptions.collaborativePlanning) != null ? _t : void 0
|
|
6120
6384
|
});
|
|
6121
|
-
} else if (
|
|
6385
|
+
} else if (agentConfigOptions.type === "dynamic") {
|
|
6122
6386
|
agentConfig = { type: "dynamic" };
|
|
6123
6387
|
}
|
|
6124
6388
|
}
|
|
6125
6389
|
let environment;
|
|
6126
|
-
if ((
|
|
6390
|
+
if ((googleOptions == null ? void 0 : googleOptions.environment) != null) {
|
|
6127
6391
|
if (!isAgent) {
|
|
6128
6392
|
warnings.push({
|
|
6129
6393
|
type: "other",
|
|
6130
6394
|
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
6131
6395
|
});
|
|
6132
|
-
} else if (typeof
|
|
6133
|
-
environment =
|
|
6396
|
+
} else if (typeof googleOptions.environment === "string") {
|
|
6397
|
+
environment = googleOptions.environment;
|
|
6134
6398
|
} else {
|
|
6135
|
-
const
|
|
6136
|
-
const sources = (_u =
|
|
6399
|
+
const environmentOptions = googleOptions.environment;
|
|
6400
|
+
const sources = (_u = environmentOptions.sources) == null ? void 0 : _u.map((source) => {
|
|
6137
6401
|
var _a2;
|
|
6138
|
-
if (
|
|
6402
|
+
if (source.type === "inline") {
|
|
6139
6403
|
return {
|
|
6140
6404
|
type: "inline",
|
|
6141
|
-
content:
|
|
6142
|
-
target:
|
|
6405
|
+
content: source.content,
|
|
6406
|
+
target: source.target
|
|
6143
6407
|
};
|
|
6144
6408
|
}
|
|
6145
6409
|
return pruneUndefined({
|
|
6146
|
-
type:
|
|
6147
|
-
source:
|
|
6148
|
-
target: (_a2 =
|
|
6410
|
+
type: source.type,
|
|
6411
|
+
source: source.source,
|
|
6412
|
+
target: (_a2 = source.target) != null ? _a2 : void 0
|
|
6149
6413
|
});
|
|
6150
6414
|
});
|
|
6151
6415
|
let network;
|
|
6152
|
-
if (
|
|
6416
|
+
if (environmentOptions.network === "disabled") {
|
|
6153
6417
|
network = "disabled";
|
|
6154
|
-
} else if (
|
|
6418
|
+
} else if (environmentOptions.network != null) {
|
|
6155
6419
|
network = {
|
|
6156
|
-
allowlist:
|
|
6420
|
+
allowlist: environmentOptions.network.allowlist.map(
|
|
6157
6421
|
(entry) => {
|
|
6158
6422
|
var _a2;
|
|
6159
6423
|
return pruneUndefined({
|
|
@@ -6177,38 +6441,38 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6177
6441
|
system_instruction: systemInstruction,
|
|
6178
6442
|
tools: toolsForBody,
|
|
6179
6443
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
6180
|
-
response_modalities: (
|
|
6181
|
-
previous_interaction_id: (_v =
|
|
6182
|
-
service_tier: (_w =
|
|
6183
|
-
store: (_x =
|
|
6444
|
+
response_modalities: (googleOptions == null ? void 0 : googleOptions.responseModalities) != null ? googleOptions.responseModalities : void 0,
|
|
6445
|
+
previous_interaction_id: (_v = googleOptions == null ? void 0 : googleOptions.previousInteractionId) != null ? _v : void 0,
|
|
6446
|
+
service_tier: (_w = googleOptions == null ? void 0 : googleOptions.serviceTier) != null ? _w : void 0,
|
|
6447
|
+
store: (_x = googleOptions == null ? void 0 : googleOptions.store) != null ? _x : void 0,
|
|
6184
6448
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
6185
6449
|
agent_config: agentConfig,
|
|
6186
6450
|
environment,
|
|
6187
|
-
background: (_y =
|
|
6451
|
+
background: (_y = googleOptions == null ? void 0 : googleOptions.background) != null ? _y : void 0
|
|
6188
6452
|
});
|
|
6189
6453
|
return {
|
|
6190
6454
|
args,
|
|
6191
6455
|
warnings,
|
|
6192
6456
|
isAgent,
|
|
6193
|
-
isBackground: (
|
|
6194
|
-
pollingTimeoutMs: (_z =
|
|
6457
|
+
isBackground: (googleOptions == null ? void 0 : googleOptions.background) === true,
|
|
6458
|
+
pollingTimeoutMs: (_z = googleOptions == null ? void 0 : googleOptions.pollingTimeoutMs) != null ? _z : void 0
|
|
6195
6459
|
};
|
|
6196
6460
|
}
|
|
6197
6461
|
async doGenerate(options) {
|
|
6198
6462
|
var _a, _b, _c, _d, _e, _f;
|
|
6199
6463
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
6200
6464
|
const url = `${this.config.baseURL}/interactions`;
|
|
6201
|
-
const mergedHeaders =
|
|
6465
|
+
const mergedHeaders = combineHeaders8(
|
|
6202
6466
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6203
|
-
this.config.headers ? await
|
|
6467
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6204
6468
|
options.headers
|
|
6205
6469
|
);
|
|
6206
|
-
const postResult = await
|
|
6470
|
+
const postResult = await postJsonToApi6({
|
|
6207
6471
|
url,
|
|
6208
6472
|
headers: mergedHeaders,
|
|
6209
6473
|
body: args,
|
|
6210
6474
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6211
|
-
successfulResponseHandler:
|
|
6475
|
+
successfulResponseHandler: createJsonResponseHandler8(
|
|
6212
6476
|
googleInteractionsResponseSchema
|
|
6213
6477
|
),
|
|
6214
6478
|
abortSignal: options.abortSignal,
|
|
@@ -6279,9 +6543,9 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6279
6543
|
var _a;
|
|
6280
6544
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6281
6545
|
const url = `${this.config.baseURL}/interactions`;
|
|
6282
|
-
const mergedHeaders =
|
|
6546
|
+
const mergedHeaders = combineHeaders8(
|
|
6283
6547
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6284
|
-
this.config.headers ? await
|
|
6548
|
+
this.config.headers ? await resolve6(this.config.headers) : void 0,
|
|
6285
6549
|
options.headers
|
|
6286
6550
|
);
|
|
6287
6551
|
if (isBackground) {
|
|
@@ -6295,7 +6559,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6295
6559
|
});
|
|
6296
6560
|
}
|
|
6297
6561
|
const body = { ...args, stream: true };
|
|
6298
|
-
const { responseHeaders, value: response } = await
|
|
6562
|
+
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
6299
6563
|
url,
|
|
6300
6564
|
headers: mergedHeaders,
|
|
6301
6565
|
body,
|
|
@@ -6346,12 +6610,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6346
6610
|
pollingTimeoutMs
|
|
6347
6611
|
}) {
|
|
6348
6612
|
var _a, _b;
|
|
6349
|
-
const postResult = await
|
|
6613
|
+
const postResult = await postJsonToApi6({
|
|
6350
6614
|
url,
|
|
6351
6615
|
headers: mergedHeaders,
|
|
6352
6616
|
body: args,
|
|
6353
6617
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6354
|
-
successfulResponseHandler:
|
|
6618
|
+
successfulResponseHandler: createJsonResponseHandler8(
|
|
6355
6619
|
googleInteractionsResponseSchema
|
|
6356
6620
|
),
|
|
6357
6621
|
abortSignal: options.abortSignal,
|
|
@@ -6478,6 +6742,12 @@ function createGoogle(options = {}) {
|
|
|
6478
6742
|
generateId: (_a2 = options.generateId) != null ? _a2 : generateId2
|
|
6479
6743
|
});
|
|
6480
6744
|
};
|
|
6745
|
+
const createSpeechModel = (modelId) => new GoogleSpeechModel(modelId, {
|
|
6746
|
+
provider: `${providerName}.speech`,
|
|
6747
|
+
baseURL,
|
|
6748
|
+
headers: getHeaders,
|
|
6749
|
+
fetch: options.fetch
|
|
6750
|
+
});
|
|
6481
6751
|
const createInteractionsModel = (modelIdOrAgent) => {
|
|
6482
6752
|
var _a2;
|
|
6483
6753
|
return new GoogleInteractionsLanguageModel(
|
|
@@ -6512,6 +6782,8 @@ function createGoogle(options = {}) {
|
|
|
6512
6782
|
provider.video = createVideoModel;
|
|
6513
6783
|
provider.videoModel = createVideoModel;
|
|
6514
6784
|
provider.files = createFiles;
|
|
6785
|
+
provider.speech = createSpeechModel;
|
|
6786
|
+
provider.speechModel = createSpeechModel;
|
|
6515
6787
|
provider.interactions = createInteractionsModel;
|
|
6516
6788
|
provider.tools = googleTools;
|
|
6517
6789
|
return provider;
|