@ai-sdk/google 3.0.74 → 3.0.75
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.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +478 -312
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +478 -312
- package/dist/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +72 -16
- package/package.json +1 -1
- package/src/interactions/build-google-interactions-stream-transform.ts +285 -154
- package/src/interactions/convert-to-google-interactions-input.ts +57 -133
- package/src/interactions/extract-google-interactions-sources.ts +3 -3
- package/src/interactions/google-interactions-api.ts +179 -115
- package/src/interactions/google-interactions-language-model-options.ts +61 -0
- package/src/interactions/google-interactions-language-model.ts +100 -38
- package/src/interactions/google-interactions-prompt.ts +189 -114
- package/src/interactions/map-google-interactions-finish-reason.ts +3 -5
- package/src/interactions/parse-google-interactions-outputs.ts +80 -74
- package/src/interactions/prepare-google-interactions-tools.ts +1 -1
- package/src/interactions/stream-google-interactions.ts +1 -1
- package/src/interactions/synthesize-google-interactions-agent-stream.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.75" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -3187,7 +3187,7 @@ function annotationToSource({
|
|
|
3187
3187
|
}
|
|
3188
3188
|
case "file_citation": {
|
|
3189
3189
|
const a = annotation;
|
|
3190
|
-
const uri = (_b = (_a = a.
|
|
3190
|
+
const uri = (_b = (_a = a.url) != null ? _a : a.document_uri) != null ? _b : a.file_name;
|
|
3191
3191
|
if (uri == null || uri.length === 0) return void 0;
|
|
3192
3192
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3193
3193
|
return {
|
|
@@ -3281,7 +3281,7 @@ function builtinToolResultToSources({
|
|
|
3281
3281
|
for (const raw of result) {
|
|
3282
3282
|
if (raw == null || typeof raw !== "object") continue;
|
|
3283
3283
|
const entry = raw;
|
|
3284
|
-
const uri = (_g = (_f = entry.
|
|
3284
|
+
const uri = (_g = (_f = entry.url) != null ? _f : entry.document_uri) != null ? _g : entry.file_name;
|
|
3285
3285
|
if (uri == null || uri.length === 0) continue;
|
|
3286
3286
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3287
3287
|
sources.push({
|
|
@@ -3397,7 +3397,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3397
3397
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3398
3398
|
},
|
|
3399
3399
|
transform(chunk, controller) {
|
|
3400
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3400
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3401
3401
|
if (includeRawChunks) {
|
|
3402
3402
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3403
3403
|
}
|
|
@@ -3409,7 +3409,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3409
3409
|
const value = chunk.value;
|
|
3410
3410
|
const eventType = value.event_type;
|
|
3411
3411
|
switch (eventType) {
|
|
3412
|
-
case "interaction.
|
|
3412
|
+
case "interaction.created": {
|
|
3413
3413
|
const event = value;
|
|
3414
3414
|
const interaction = event.interaction;
|
|
3415
3415
|
interactionId = (interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0 ? interaction.id : void 0;
|
|
@@ -3429,91 +3429,106 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3429
3429
|
});
|
|
3430
3430
|
break;
|
|
3431
3431
|
}
|
|
3432
|
-
case "
|
|
3432
|
+
case "step.start": {
|
|
3433
3433
|
const event = value;
|
|
3434
|
-
const
|
|
3434
|
+
const step = event.step;
|
|
3435
3435
|
const index = event.index;
|
|
3436
3436
|
const blockId = `${interactionId != null ? interactionId : "interaction"}:${index}`;
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3437
|
+
const stepType = step == null ? void 0 : step.type;
|
|
3438
|
+
if (stepType === "model_output") {
|
|
3439
|
+
const initial = (_a = step == null ? void 0 : step.content) == null ? void 0 : _a[0];
|
|
3440
|
+
if ((initial == null ? void 0 : initial.type) === "text") {
|
|
3441
|
+
openBlocks.set(index, {
|
|
3442
|
+
kind: "text",
|
|
3443
|
+
id: blockId,
|
|
3444
|
+
emittedSourceKeys: /* @__PURE__ */ new Set()
|
|
3445
|
+
});
|
|
3446
|
+
controller.enqueue({ type: "text-start", id: blockId });
|
|
3447
|
+
const initialSources = annotationsToSources({
|
|
3448
|
+
annotations: initial.annotations,
|
|
3449
|
+
generateId: generateId3
|
|
3450
|
+
});
|
|
3451
|
+
for (const source of initialSources) {
|
|
3452
|
+
const key = sourceKey(source);
|
|
3453
|
+
if (emittedSourceKeys.has(key)) continue;
|
|
3454
|
+
emittedSourceKeys.add(key);
|
|
3455
|
+
controller.enqueue(source);
|
|
3456
|
+
}
|
|
3457
|
+
} else if ((initial == null ? void 0 : initial.type) === "image") {
|
|
3458
|
+
openBlocks.set(index, {
|
|
3459
|
+
kind: "image",
|
|
3460
|
+
id: blockId,
|
|
3461
|
+
...initial.data != null ? { data: initial.data } : {},
|
|
3462
|
+
...initial.mime_type != null ? { mimeType: initial.mime_type } : {},
|
|
3463
|
+
...initial.uri != null ? { uri: initial.uri } : {}
|
|
3464
|
+
});
|
|
3465
|
+
} else {
|
|
3466
|
+
openBlocks.set(index, {
|
|
3467
|
+
kind: "pending_model_output",
|
|
3468
|
+
id: blockId
|
|
3469
|
+
});
|
|
3453
3470
|
}
|
|
3454
|
-
} else if (
|
|
3455
|
-
const
|
|
3456
|
-
openBlocks.set(index, {
|
|
3457
|
-
kind: "image",
|
|
3458
|
-
id: blockId,
|
|
3459
|
-
...img.data != null ? { data: img.data } : {},
|
|
3460
|
-
...img.mime_type != null ? { mimeType: img.mime_type } : {},
|
|
3461
|
-
...img.uri != null ? { uri: img.uri } : {}
|
|
3462
|
-
});
|
|
3463
|
-
} else if ((block == null ? void 0 : block.type) === "thought") {
|
|
3464
|
-
const signature = block.signature;
|
|
3471
|
+
} else if (stepType === "thought") {
|
|
3472
|
+
const signature = step == null ? void 0 : step.signature;
|
|
3465
3473
|
openBlocks.set(index, {
|
|
3466
3474
|
kind: "reasoning",
|
|
3467
3475
|
id: blockId,
|
|
3468
3476
|
...signature != null ? { signature } : {}
|
|
3469
3477
|
});
|
|
3470
3478
|
controller.enqueue({ type: "reasoning-start", id: blockId });
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3479
|
+
if (Array.isArray(step == null ? void 0 : step.summary)) {
|
|
3480
|
+
for (const item of step.summary) {
|
|
3481
|
+
if ((item == null ? void 0 : item.type) === "text" && typeof item.text === "string") {
|
|
3482
|
+
controller.enqueue({
|
|
3483
|
+
type: "reasoning-delta",
|
|
3484
|
+
id: blockId,
|
|
3485
|
+
delta: item.text
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
} else if (stepType === "function_call") {
|
|
3491
|
+
const toolCallId = (_b = step == null ? void 0 : step.id) != null ? _b : blockId;
|
|
3492
|
+
const toolName = (_c = step == null ? void 0 : step.name) != null ? _c : "unknown";
|
|
3474
3493
|
hasFunctionCall = true;
|
|
3475
3494
|
const state = {
|
|
3476
3495
|
kind: "function_call",
|
|
3477
3496
|
id: blockId,
|
|
3478
3497
|
toolCallId,
|
|
3479
|
-
toolName
|
|
3480
|
-
|
|
3481
|
-
...
|
|
3482
|
-
startEmitted: false
|
|
3498
|
+
toolName,
|
|
3499
|
+
argumentsAccum: "",
|
|
3500
|
+
...(step == null ? void 0 : step.signature) != null ? { signature: step.signature } : {}
|
|
3483
3501
|
};
|
|
3484
3502
|
openBlocks.set(index, state);
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
} else if ((block == null ? void 0 : block.type) != null && BUILTIN_TOOL_CALL_TYPES.has(block.type)) {
|
|
3494
|
-
const toolName = block.type === "mcp_server_tool_call" ? (_c = block.name) != null ? _c : "mcp_server_tool" : builtinToolNameFromCallType(block.type);
|
|
3495
|
-
const toolCallId = (_d = block.id) != null ? _d : blockId;
|
|
3503
|
+
controller.enqueue({
|
|
3504
|
+
type: "tool-input-start",
|
|
3505
|
+
id: toolCallId,
|
|
3506
|
+
toolName
|
|
3507
|
+
});
|
|
3508
|
+
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
3509
|
+
const toolName = stepType === "mcp_server_tool_call" ? (_d = step == null ? void 0 : step.name) != null ? _d : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
3510
|
+
const toolCallId = (_e = step == null ? void 0 : step.id) != null ? _e : blockId;
|
|
3496
3511
|
const state = {
|
|
3497
3512
|
kind: "builtin_tool_call",
|
|
3498
3513
|
id: blockId,
|
|
3499
|
-
blockType:
|
|
3514
|
+
blockType: stepType,
|
|
3500
3515
|
toolCallId,
|
|
3501
3516
|
toolName,
|
|
3502
|
-
arguments: (
|
|
3517
|
+
arguments: (_f = step == null ? void 0 : step.arguments) != null ? _f : {},
|
|
3503
3518
|
callEmitted: false
|
|
3504
3519
|
};
|
|
3505
3520
|
openBlocks.set(index, state);
|
|
3506
|
-
} else if (
|
|
3507
|
-
const toolName =
|
|
3508
|
-
const callId = (
|
|
3521
|
+
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
3522
|
+
const toolName = stepType === "mcp_server_tool_result" ? (_g = step == null ? void 0 : step.name) != null ? _g : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
3523
|
+
const callId = (_h = step == null ? void 0 : step.call_id) != null ? _h : blockId;
|
|
3509
3524
|
const state = {
|
|
3510
3525
|
kind: "builtin_tool_result",
|
|
3511
3526
|
id: blockId,
|
|
3512
|
-
blockType:
|
|
3527
|
+
blockType: stepType,
|
|
3513
3528
|
callId,
|
|
3514
3529
|
toolName,
|
|
3515
|
-
result: (
|
|
3516
|
-
...
|
|
3530
|
+
result: (_i = step == null ? void 0 : step.result) != null ? _i : null,
|
|
3531
|
+
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
3517
3532
|
resultEmitted: false
|
|
3518
3533
|
};
|
|
3519
3534
|
openBlocks.set(index, state);
|
|
@@ -3522,13 +3537,58 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3522
3537
|
}
|
|
3523
3538
|
break;
|
|
3524
3539
|
}
|
|
3525
|
-
case "
|
|
3540
|
+
case "step.delta": {
|
|
3526
3541
|
const event = value;
|
|
3527
|
-
|
|
3542
|
+
let open = openBlocks.get(event.index);
|
|
3528
3543
|
if (open == null) break;
|
|
3544
|
+
const dtype = (_j = event.delta) == null ? void 0 : _j.type;
|
|
3545
|
+
if (open.kind === "pending_model_output") {
|
|
3546
|
+
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
3547
|
+
const promoted = {
|
|
3548
|
+
kind: "text",
|
|
3549
|
+
id: open.id,
|
|
3550
|
+
emittedSourceKeys: /* @__PURE__ */ new Set()
|
|
3551
|
+
};
|
|
3552
|
+
openBlocks.set(event.index, promoted);
|
|
3553
|
+
open = promoted;
|
|
3554
|
+
controller.enqueue({ type: "text-start", id: promoted.id });
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
if (dtype === "image" && (open.kind === "pending_model_output" || open.kind === "text" || open.kind === "image")) {
|
|
3558
|
+
const img = event.delta;
|
|
3559
|
+
const google2 = {};
|
|
3560
|
+
if (interactionId != null) google2.interactionId = interactionId;
|
|
3561
|
+
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
3562
|
+
if ((img == null ? void 0 : img.data) != null && img.data.length > 0) {
|
|
3563
|
+
controller.enqueue({
|
|
3564
|
+
type: "file",
|
|
3565
|
+
mediaType: (_k = img.mime_type) != null ? _k : "image/png",
|
|
3566
|
+
data: img.data,
|
|
3567
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3568
|
+
});
|
|
3569
|
+
} else if ((img == null ? void 0 : img.uri) != null && img.uri.length > 0) {
|
|
3570
|
+
const uriProviderMetadata = {
|
|
3571
|
+
google: {
|
|
3572
|
+
...interactionId != null ? { interactionId } : {},
|
|
3573
|
+
imageUri: img.uri
|
|
3574
|
+
}
|
|
3575
|
+
};
|
|
3576
|
+
controller.enqueue({
|
|
3577
|
+
type: "file",
|
|
3578
|
+
mediaType: (_l = img.mime_type) != null ? _l : "image/png",
|
|
3579
|
+
data: "",
|
|
3580
|
+
providerMetadata: uriProviderMetadata
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
if (open.kind === "image") {
|
|
3584
|
+
open.data = void 0;
|
|
3585
|
+
open.uri = void 0;
|
|
3586
|
+
}
|
|
3587
|
+
break;
|
|
3588
|
+
}
|
|
3529
3589
|
const delta = event.delta;
|
|
3530
3590
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3531
|
-
const text = (
|
|
3591
|
+
const text = (_m = delta.text) != null ? _m : "";
|
|
3532
3592
|
if (text.length > 0) {
|
|
3533
3593
|
controller.enqueue({
|
|
3534
3594
|
type: "text-delta",
|
|
@@ -3536,7 +3596,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3536
3596
|
delta: text
|
|
3537
3597
|
});
|
|
3538
3598
|
}
|
|
3539
|
-
} else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text_annotation") {
|
|
3599
|
+
} else if (open.kind === "text" && ((delta == null ? void 0 : delta.type) === "text_annotation" || (delta == null ? void 0 : delta.type) === "text_annotation_delta")) {
|
|
3540
3600
|
const sources = annotationsToSources({
|
|
3541
3601
|
annotations: delta.annotations,
|
|
3542
3602
|
generateId: generateId3
|
|
@@ -3568,31 +3628,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3568
3628
|
open.signature = signature;
|
|
3569
3629
|
}
|
|
3570
3630
|
}
|
|
3571
|
-
} else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "
|
|
3631
|
+
} else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "arguments_delta") {
|
|
3632
|
+
const slice = typeof delta.arguments === "string" ? delta.arguments : "";
|
|
3633
|
+
if (slice.length > 0) {
|
|
3634
|
+
open.argumentsAccum += slice;
|
|
3635
|
+
controller.enqueue({
|
|
3636
|
+
type: "tool-input-delta",
|
|
3637
|
+
id: open.toolCallId,
|
|
3638
|
+
delta: slice
|
|
3639
|
+
});
|
|
3640
|
+
}
|
|
3572
3641
|
if (delta.id != null) {
|
|
3573
3642
|
open.toolCallId = delta.id;
|
|
3574
3643
|
}
|
|
3575
|
-
if (delta.name != null) {
|
|
3576
|
-
open.toolName = delta.name;
|
|
3577
|
-
}
|
|
3578
|
-
if (delta.arguments != null) {
|
|
3579
|
-
open.arguments = delta.arguments;
|
|
3580
|
-
}
|
|
3581
3644
|
if (delta.signature != null) {
|
|
3582
3645
|
open.signature = delta.signature;
|
|
3583
3646
|
}
|
|
3584
|
-
if (!open.startEmitted && open.toolName != null) {
|
|
3585
|
-
controller.enqueue({
|
|
3586
|
-
type: "tool-input-start",
|
|
3587
|
-
id: open.toolCallId,
|
|
3588
|
-
toolName: open.toolName
|
|
3589
|
-
});
|
|
3590
|
-
open.startEmitted = true;
|
|
3591
|
-
}
|
|
3592
3647
|
hasFunctionCall = true;
|
|
3593
3648
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3594
3649
|
if (delta.id != null) open.toolCallId = delta.id;
|
|
3595
|
-
if (delta.arguments != null
|
|
3650
|
+
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
3651
|
+
open.arguments = delta.arguments;
|
|
3652
|
+
}
|
|
3596
3653
|
if (delta.name != null && open.blockType === "mcp_server_tool_call") {
|
|
3597
3654
|
open.toolName = delta.name;
|
|
3598
3655
|
}
|
|
@@ -3606,7 +3663,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3606
3663
|
}
|
|
3607
3664
|
break;
|
|
3608
3665
|
}
|
|
3609
|
-
case "
|
|
3666
|
+
case "step.stop": {
|
|
3610
3667
|
const event = value;
|
|
3611
3668
|
const open = openBlocks.get(event.index);
|
|
3612
3669
|
if (open == null) break;
|
|
@@ -3634,7 +3691,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3634
3691
|
if (open.data != null && open.data.length > 0) {
|
|
3635
3692
|
controller.enqueue({
|
|
3636
3693
|
type: "file",
|
|
3637
|
-
mediaType: (
|
|
3694
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
3638
3695
|
data: open.data,
|
|
3639
3696
|
...providerMetadata ? { providerMetadata } : {}
|
|
3640
3697
|
});
|
|
@@ -3647,26 +3704,13 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3647
3704
|
};
|
|
3648
3705
|
controller.enqueue({
|
|
3649
3706
|
type: "file",
|
|
3650
|
-
mediaType: (
|
|
3707
|
+
mediaType: (_o = open.mimeType) != null ? _o : "image/png",
|
|
3651
3708
|
data: "",
|
|
3652
3709
|
providerMetadata: uriProviderMetadata
|
|
3653
3710
|
});
|
|
3654
3711
|
}
|
|
3655
3712
|
} else if (open.kind === "function_call") {
|
|
3656
|
-
const
|
|
3657
|
-
const argsJson = JSON.stringify((_m = open.arguments) != null ? _m : {});
|
|
3658
|
-
if (!open.startEmitted) {
|
|
3659
|
-
controller.enqueue({
|
|
3660
|
-
type: "tool-input-start",
|
|
3661
|
-
id: open.toolCallId,
|
|
3662
|
-
toolName
|
|
3663
|
-
});
|
|
3664
|
-
}
|
|
3665
|
-
controller.enqueue({
|
|
3666
|
-
type: "tool-input-delta",
|
|
3667
|
-
id: open.toolCallId,
|
|
3668
|
-
delta: argsJson
|
|
3669
|
-
});
|
|
3713
|
+
const accumulated = open.argumentsAccum.length > 0 ? open.argumentsAccum : "{}";
|
|
3670
3714
|
controller.enqueue({
|
|
3671
3715
|
type: "tool-input-end",
|
|
3672
3716
|
id: open.toolCallId
|
|
@@ -3678,8 +3722,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3678
3722
|
controller.enqueue({
|
|
3679
3723
|
type: "tool-call",
|
|
3680
3724
|
toolCallId: open.toolCallId,
|
|
3681
|
-
toolName,
|
|
3682
|
-
input:
|
|
3725
|
+
toolName: open.toolName,
|
|
3726
|
+
input: accumulated,
|
|
3683
3727
|
...providerMetadata ? { providerMetadata } : {}
|
|
3684
3728
|
});
|
|
3685
3729
|
} else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
|
|
@@ -3687,7 +3731,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3687
3731
|
type: "tool-call",
|
|
3688
3732
|
toolCallId: open.toolCallId,
|
|
3689
3733
|
toolName: open.toolName,
|
|
3690
|
-
input: JSON.stringify((
|
|
3734
|
+
input: JSON.stringify((_p = open.arguments) != null ? _p : {}),
|
|
3691
3735
|
providerExecuted: true
|
|
3692
3736
|
});
|
|
3693
3737
|
open.callEmitted = true;
|
|
@@ -3696,7 +3740,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3696
3740
|
type: "tool-result",
|
|
3697
3741
|
toolCallId: open.callId,
|
|
3698
3742
|
toolName: open.toolName,
|
|
3699
|
-
result: (
|
|
3743
|
+
result: (_q = open.result) != null ? _q : null
|
|
3700
3744
|
});
|
|
3701
3745
|
open.resultEmitted = true;
|
|
3702
3746
|
const sources = builtinToolResultToSources({
|
|
@@ -3717,12 +3761,20 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3717
3761
|
openBlocks.delete(event.index);
|
|
3718
3762
|
break;
|
|
3719
3763
|
}
|
|
3720
|
-
case "interaction.status_update":
|
|
3764
|
+
case "interaction.status_update":
|
|
3765
|
+
case "interaction.in_progress":
|
|
3766
|
+
case "interaction.requires_action": {
|
|
3721
3767
|
const event = value;
|
|
3722
|
-
|
|
3768
|
+
if (event.status != null) {
|
|
3769
|
+
finishStatus = event.status;
|
|
3770
|
+
} else if (eventType === "interaction.requires_action") {
|
|
3771
|
+
finishStatus = "requires_action";
|
|
3772
|
+
} else {
|
|
3773
|
+
finishStatus = "in_progress";
|
|
3774
|
+
}
|
|
3723
3775
|
break;
|
|
3724
3776
|
}
|
|
3725
|
-
case "interaction.
|
|
3777
|
+
case "interaction.completed": {
|
|
3726
3778
|
const event = value;
|
|
3727
3779
|
const interaction = event.interaction;
|
|
3728
3780
|
if ((interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0) {
|
|
@@ -3742,7 +3794,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3742
3794
|
case "error": {
|
|
3743
3795
|
const event = value;
|
|
3744
3796
|
finishStatus = "failed";
|
|
3745
|
-
const errorPayload = (
|
|
3797
|
+
const errorPayload = (_r = event.error) != null ? _r : {
|
|
3746
3798
|
message: "Unknown interaction error"
|
|
3747
3799
|
};
|
|
3748
3800
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -3811,7 +3863,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3811
3863
|
previousInteractionId
|
|
3812
3864
|
}) : prompt;
|
|
3813
3865
|
const systemTexts = [];
|
|
3814
|
-
const
|
|
3866
|
+
const steps = [];
|
|
3815
3867
|
for (const message of compactedPrompt) {
|
|
3816
3868
|
switch (message.role) {
|
|
3817
3869
|
case "system": {
|
|
@@ -3822,11 +3874,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3822
3874
|
const content = [];
|
|
3823
3875
|
for (const part of message.content) {
|
|
3824
3876
|
if (part.type === "text") {
|
|
3825
|
-
|
|
3826
|
-
type: "text",
|
|
3827
|
-
text: part.text
|
|
3828
|
-
};
|
|
3829
|
-
content.push(block);
|
|
3877
|
+
content.push({ type: "text", text: part.text });
|
|
3830
3878
|
} else if (part.type === "file") {
|
|
3831
3879
|
const fileBlock = convertFilePartToContent({
|
|
3832
3880
|
part,
|
|
@@ -3840,18 +3888,25 @@ function convertToGoogleInteractionsInput({
|
|
|
3840
3888
|
}
|
|
3841
3889
|
const merged = mergeAdjacentTextContent(content);
|
|
3842
3890
|
if (merged.length > 0) {
|
|
3843
|
-
|
|
3891
|
+
steps.push({ type: "user_input", content: merged });
|
|
3844
3892
|
}
|
|
3845
3893
|
break;
|
|
3846
3894
|
}
|
|
3847
3895
|
case "assistant": {
|
|
3848
|
-
|
|
3896
|
+
let pendingModelOutput = [];
|
|
3897
|
+
const flushModelOutput = () => {
|
|
3898
|
+
if (pendingModelOutput.length > 0) {
|
|
3899
|
+
steps.push({ type: "model_output", content: pendingModelOutput });
|
|
3900
|
+
pendingModelOutput = [];
|
|
3901
|
+
}
|
|
3902
|
+
};
|
|
3849
3903
|
for (const part of message.content) {
|
|
3850
3904
|
if (part.type === "text") {
|
|
3851
|
-
|
|
3905
|
+
pendingModelOutput.push({ type: "text", text: part.text });
|
|
3852
3906
|
} else if (part.type === "reasoning") {
|
|
3907
|
+
flushModelOutput();
|
|
3853
3908
|
const signature = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.signature;
|
|
3854
|
-
|
|
3909
|
+
steps.push({
|
|
3855
3910
|
type: "thought",
|
|
3856
3911
|
...signature != null ? { signature } : {},
|
|
3857
3912
|
summary: part.text.length > 0 ? [{ type: "text", text: part.text }] : void 0
|
|
@@ -3863,12 +3918,13 @@ function convertToGoogleInteractionsInput({
|
|
|
3863
3918
|
mediaResolution
|
|
3864
3919
|
});
|
|
3865
3920
|
if (fileBlock != null) {
|
|
3866
|
-
|
|
3921
|
+
pendingModelOutput.push(fileBlock);
|
|
3867
3922
|
}
|
|
3868
3923
|
} else if (part.type === "tool-call") {
|
|
3924
|
+
flushModelOutput();
|
|
3869
3925
|
const signature = (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.signature;
|
|
3870
3926
|
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_e = part.input) != null ? _e : {};
|
|
3871
|
-
|
|
3927
|
+
steps.push({
|
|
3872
3928
|
type: "function_call",
|
|
3873
3929
|
id: part.toolCallId,
|
|
3874
3930
|
name: part.toolName,
|
|
@@ -3882,9 +3938,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3882
3938
|
});
|
|
3883
3939
|
}
|
|
3884
3940
|
}
|
|
3885
|
-
|
|
3886
|
-
turns.push({ role: "model", content });
|
|
3887
|
-
}
|
|
3941
|
+
flushModelOutput();
|
|
3888
3942
|
break;
|
|
3889
3943
|
}
|
|
3890
3944
|
case "tool": {
|
|
@@ -3907,22 +3961,14 @@ function convertToGoogleInteractionsInput({
|
|
|
3907
3961
|
content.push(block);
|
|
3908
3962
|
}
|
|
3909
3963
|
if (content.length > 0) {
|
|
3910
|
-
|
|
3964
|
+
steps.push({ type: "user_input", content });
|
|
3911
3965
|
}
|
|
3912
3966
|
break;
|
|
3913
3967
|
}
|
|
3914
3968
|
}
|
|
3915
3969
|
}
|
|
3916
3970
|
const systemInstruction = systemTexts.length > 0 ? systemTexts.join("\n\n") : void 0;
|
|
3917
|
-
|
|
3918
|
-
if (turns.length === 0) {
|
|
3919
|
-
input = "";
|
|
3920
|
-
} else if (turns.length === 1 && turns[0].role === "user" && Array.isArray(turns[0].content)) {
|
|
3921
|
-
input = turns[0].content;
|
|
3922
|
-
} else {
|
|
3923
|
-
input = turns;
|
|
3924
|
-
}
|
|
3925
|
-
return { input, systemInstruction, warnings };
|
|
3971
|
+
return { input: steps, systemInstruction, warnings };
|
|
3926
3972
|
}
|
|
3927
3973
|
function convertFilePartToContent({
|
|
3928
3974
|
part,
|
|
@@ -4220,7 +4266,7 @@ var annotationSchema = () => {
|
|
|
4220
4266
|
type: z15.literal("file_citation"),
|
|
4221
4267
|
file_name: z15.string().nullish(),
|
|
4222
4268
|
document_uri: z15.string().nullish(),
|
|
4223
|
-
|
|
4269
|
+
url: z15.string().nullish(),
|
|
4224
4270
|
page_number: z15.number().nullish(),
|
|
4225
4271
|
media_id: z15.string().nullish(),
|
|
4226
4272
|
start_index: z15.number().nullish(),
|
|
@@ -4254,34 +4300,58 @@ var contentBlockSchema = () => {
|
|
|
4254
4300
|
text: z15.string(),
|
|
4255
4301
|
annotations: z15.array(annotationSchema()).nullish()
|
|
4256
4302
|
}).loose();
|
|
4257
|
-
const
|
|
4258
|
-
type: z15.literal("
|
|
4259
|
-
|
|
4260
|
-
|
|
4303
|
+
const imageContent = z15.object({
|
|
4304
|
+
type: z15.literal("image"),
|
|
4305
|
+
data: z15.string().nullish(),
|
|
4306
|
+
mime_type: z15.string().nullish(),
|
|
4307
|
+
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4308
|
+
uri: z15.string().nullish()
|
|
4261
4309
|
}).loose();
|
|
4262
|
-
|
|
4310
|
+
return z15.union([
|
|
4311
|
+
textContent,
|
|
4312
|
+
imageContent,
|
|
4313
|
+
z15.object({ type: z15.string() }).loose()
|
|
4314
|
+
]);
|
|
4315
|
+
};
|
|
4316
|
+
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
4317
|
+
"google_search_call",
|
|
4318
|
+
"code_execution_call",
|
|
4319
|
+
"url_context_call",
|
|
4320
|
+
"file_search_call",
|
|
4321
|
+
"google_maps_call",
|
|
4322
|
+
"mcp_server_tool_call"
|
|
4323
|
+
];
|
|
4324
|
+
var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
4325
|
+
"google_search_result",
|
|
4326
|
+
"code_execution_result",
|
|
4327
|
+
"url_context_result",
|
|
4328
|
+
"file_search_result",
|
|
4329
|
+
"google_maps_result",
|
|
4330
|
+
"mcp_server_tool_result"
|
|
4331
|
+
];
|
|
4332
|
+
var stepSchema = () => {
|
|
4333
|
+
const userInputStep = z15.object({
|
|
4334
|
+
type: z15.literal("user_input"),
|
|
4335
|
+
content: z15.array(contentBlockSchema()).nullish()
|
|
4336
|
+
}).loose();
|
|
4337
|
+
const modelOutputStep = z15.object({
|
|
4338
|
+
type: z15.literal("model_output"),
|
|
4339
|
+
content: z15.array(contentBlockSchema()).nullish()
|
|
4340
|
+
}).loose();
|
|
4341
|
+
const functionCallStep = z15.object({
|
|
4263
4342
|
type: z15.literal("function_call"),
|
|
4264
4343
|
id: z15.string(),
|
|
4265
4344
|
name: z15.string(),
|
|
4266
4345
|
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4267
4346
|
signature: z15.string().nullish()
|
|
4268
4347
|
}).loose();
|
|
4269
|
-
const
|
|
4270
|
-
type: z15.literal("
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4274
|
-
uri: z15.string().nullish()
|
|
4348
|
+
const thoughtStep = z15.object({
|
|
4349
|
+
type: z15.literal("thought"),
|
|
4350
|
+
signature: z15.string().nullish(),
|
|
4351
|
+
summary: z15.array(thoughtSummaryItemSchema()).nullish()
|
|
4275
4352
|
}).loose();
|
|
4276
|
-
const
|
|
4277
|
-
type: z15.enum(
|
|
4278
|
-
"google_search_call",
|
|
4279
|
-
"code_execution_call",
|
|
4280
|
-
"url_context_call",
|
|
4281
|
-
"file_search_call",
|
|
4282
|
-
"google_maps_call",
|
|
4283
|
-
"mcp_server_tool_call"
|
|
4284
|
-
]),
|
|
4353
|
+
const builtinToolCallStep = z15.object({
|
|
4354
|
+
type: z15.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4285
4355
|
id: z15.string(),
|
|
4286
4356
|
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4287
4357
|
name: z15.string().nullish(),
|
|
@@ -4289,15 +4359,8 @@ var contentBlockSchema = () => {
|
|
|
4289
4359
|
search_type: z15.string().nullish(),
|
|
4290
4360
|
signature: z15.string().nullish()
|
|
4291
4361
|
}).loose();
|
|
4292
|
-
const
|
|
4293
|
-
type: z15.enum(
|
|
4294
|
-
"google_search_result",
|
|
4295
|
-
"code_execution_result",
|
|
4296
|
-
"url_context_result",
|
|
4297
|
-
"file_search_result",
|
|
4298
|
-
"google_maps_result",
|
|
4299
|
-
"mcp_server_tool_result"
|
|
4300
|
-
]),
|
|
4362
|
+
const builtinToolResultStep = z15.object({
|
|
4363
|
+
type: z15.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4301
4364
|
call_id: z15.string(),
|
|
4302
4365
|
result: z15.unknown().nullish(),
|
|
4303
4366
|
is_error: z15.boolean().nullish(),
|
|
@@ -4306,12 +4369,12 @@ var contentBlockSchema = () => {
|
|
|
4306
4369
|
signature: z15.string().nullish()
|
|
4307
4370
|
}).loose();
|
|
4308
4371
|
return z15.union([
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4372
|
+
userInputStep,
|
|
4373
|
+
modelOutputStep,
|
|
4374
|
+
functionCallStep,
|
|
4375
|
+
thoughtStep,
|
|
4376
|
+
builtinToolCallStep,
|
|
4377
|
+
builtinToolResultStep,
|
|
4315
4378
|
z15.object({ type: z15.string() }).loose()
|
|
4316
4379
|
]);
|
|
4317
4380
|
};
|
|
@@ -4329,7 +4392,7 @@ var googleInteractionsResponseSchema = lazySchema13(
|
|
|
4329
4392
|
status: interactionStatusSchema(),
|
|
4330
4393
|
model: z15.string().nullish(),
|
|
4331
4394
|
agent: z15.string().nullish(),
|
|
4332
|
-
|
|
4395
|
+
steps: z15.array(stepSchema()).nullish(),
|
|
4333
4396
|
usage: usageSchema2().nullish(),
|
|
4334
4397
|
service_tier: z15.string().nullish(),
|
|
4335
4398
|
previous_interaction_id: z15.string().nullish(),
|
|
@@ -4343,8 +4406,8 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4343
4406
|
const status = interactionStatusSchema();
|
|
4344
4407
|
const annotation = annotationSchema();
|
|
4345
4408
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4346
|
-
const
|
|
4347
|
-
event_type: z15.literal("interaction.
|
|
4409
|
+
const interactionCreatedEvent = z15.object({
|
|
4410
|
+
event_type: z15.literal("interaction.created"),
|
|
4348
4411
|
event_id: z15.string().nullish(),
|
|
4349
4412
|
interaction: z15.object({
|
|
4350
4413
|
/*
|
|
@@ -4358,94 +4421,79 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4358
4421
|
status: status.nullish()
|
|
4359
4422
|
}).loose()
|
|
4360
4423
|
}).loose();
|
|
4361
|
-
const
|
|
4362
|
-
event_type: z15.literal("
|
|
4424
|
+
const stepStartEvent = z15.object({
|
|
4425
|
+
event_type: z15.literal("step.start"),
|
|
4363
4426
|
event_id: z15.string().nullish(),
|
|
4364
4427
|
index: z15.number(),
|
|
4365
|
-
|
|
4428
|
+
step: stepSchema()
|
|
4366
4429
|
}).loose();
|
|
4367
|
-
const
|
|
4430
|
+
const stepDeltaText = z15.object({
|
|
4368
4431
|
type: z15.literal("text"),
|
|
4369
4432
|
text: z15.string()
|
|
4370
4433
|
}).loose();
|
|
4371
|
-
const
|
|
4434
|
+
const stepDeltaThoughtSummary = z15.object({
|
|
4372
4435
|
type: z15.literal("thought_summary"),
|
|
4373
4436
|
content: thoughtSummaryItem.nullish()
|
|
4374
4437
|
}).loose();
|
|
4375
|
-
const
|
|
4438
|
+
const stepDeltaThoughtSignature = z15.object({
|
|
4376
4439
|
type: z15.literal("thought_signature"),
|
|
4377
4440
|
signature: z15.string().nullish()
|
|
4378
4441
|
}).loose();
|
|
4379
|
-
const
|
|
4380
|
-
type: z15.literal("
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4442
|
+
const stepDeltaArgumentsDelta = z15.object({
|
|
4443
|
+
type: z15.literal("arguments_delta"),
|
|
4444
|
+
arguments: z15.string().nullish(),
|
|
4445
|
+
id: z15.string().nullish(),
|
|
4384
4446
|
signature: z15.string().nullish()
|
|
4385
4447
|
}).loose();
|
|
4386
|
-
const
|
|
4387
|
-
type: z15.
|
|
4448
|
+
const stepDeltaTextAnnotation = z15.object({
|
|
4449
|
+
type: z15.enum(["text_annotation_delta", "text_annotation"]),
|
|
4388
4450
|
annotations: z15.array(annotation).nullish()
|
|
4389
4451
|
}).loose();
|
|
4390
|
-
const
|
|
4452
|
+
const stepDeltaImage = z15.object({
|
|
4391
4453
|
type: z15.literal("image"),
|
|
4392
4454
|
data: z15.string().nullish(),
|
|
4393
4455
|
mime_type: z15.string().nullish(),
|
|
4394
4456
|
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4395
4457
|
uri: z15.string().nullish()
|
|
4396
4458
|
}).loose();
|
|
4397
|
-
const
|
|
4398
|
-
type: z15.enum(
|
|
4399
|
-
|
|
4400
|
-
"code_execution_call",
|
|
4401
|
-
"url_context_call",
|
|
4402
|
-
"file_search_call",
|
|
4403
|
-
"google_maps_call",
|
|
4404
|
-
"mcp_server_tool_call"
|
|
4405
|
-
]),
|
|
4406
|
-
id: z15.string(),
|
|
4459
|
+
const stepDeltaBuiltinToolCall = z15.object({
|
|
4460
|
+
type: z15.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4461
|
+
id: z15.string().nullish(),
|
|
4407
4462
|
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4408
4463
|
name: z15.string().nullish(),
|
|
4409
4464
|
server_name: z15.string().nullish(),
|
|
4410
4465
|
search_type: z15.string().nullish(),
|
|
4411
4466
|
signature: z15.string().nullish()
|
|
4412
4467
|
}).loose();
|
|
4413
|
-
const
|
|
4414
|
-
type: z15.enum(
|
|
4415
|
-
|
|
4416
|
-
"code_execution_result",
|
|
4417
|
-
"url_context_result",
|
|
4418
|
-
"file_search_result",
|
|
4419
|
-
"google_maps_result",
|
|
4420
|
-
"mcp_server_tool_result"
|
|
4421
|
-
]),
|
|
4422
|
-
call_id: z15.string(),
|
|
4468
|
+
const stepDeltaBuiltinToolResult = z15.object({
|
|
4469
|
+
type: z15.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4470
|
+
call_id: z15.string().nullish(),
|
|
4423
4471
|
result: z15.unknown().nullish(),
|
|
4424
4472
|
is_error: z15.boolean().nullish(),
|
|
4425
4473
|
name: z15.string().nullish(),
|
|
4426
4474
|
server_name: z15.string().nullish(),
|
|
4427
4475
|
signature: z15.string().nullish()
|
|
4428
4476
|
}).loose();
|
|
4429
|
-
const
|
|
4430
|
-
const
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4477
|
+
const stepDeltaUnknown = z15.object({ type: z15.string() }).loose();
|
|
4478
|
+
const stepDeltaUnion = z15.union([
|
|
4479
|
+
stepDeltaText,
|
|
4480
|
+
stepDeltaImage,
|
|
4481
|
+
stepDeltaThoughtSummary,
|
|
4482
|
+
stepDeltaThoughtSignature,
|
|
4483
|
+
stepDeltaArgumentsDelta,
|
|
4484
|
+
stepDeltaTextAnnotation,
|
|
4485
|
+
stepDeltaBuiltinToolCall,
|
|
4486
|
+
stepDeltaBuiltinToolResult,
|
|
4487
|
+
stepDeltaUnknown
|
|
4440
4488
|
]);
|
|
4441
|
-
const
|
|
4442
|
-
event_type: z15.literal("
|
|
4489
|
+
const stepDeltaEvent = z15.object({
|
|
4490
|
+
event_type: z15.literal("step.delta"),
|
|
4443
4491
|
event_id: z15.string().nullish(),
|
|
4444
4492
|
index: z15.number(),
|
|
4445
|
-
delta:
|
|
4493
|
+
delta: stepDeltaUnion
|
|
4446
4494
|
}).loose();
|
|
4447
|
-
const
|
|
4448
|
-
event_type: z15.literal("
|
|
4495
|
+
const stepStopEvent = z15.object({
|
|
4496
|
+
event_type: z15.literal("step.stop"),
|
|
4449
4497
|
event_id: z15.string().nullish(),
|
|
4450
4498
|
index: z15.number()
|
|
4451
4499
|
}).loose();
|
|
@@ -4453,10 +4501,22 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4453
4501
|
event_type: z15.literal("interaction.status_update"),
|
|
4454
4502
|
event_id: z15.string().nullish(),
|
|
4455
4503
|
interaction_id: z15.string().nullish(),
|
|
4456
|
-
status
|
|
4504
|
+
status: status.nullish()
|
|
4505
|
+
}).loose();
|
|
4506
|
+
const interactionInProgressEvent = z15.object({
|
|
4507
|
+
event_type: z15.literal("interaction.in_progress"),
|
|
4508
|
+
event_id: z15.string().nullish(),
|
|
4509
|
+
interaction_id: z15.string().nullish(),
|
|
4510
|
+
status: status.nullish()
|
|
4511
|
+
}).loose();
|
|
4512
|
+
const interactionRequiresActionEvent = z15.object({
|
|
4513
|
+
event_type: z15.literal("interaction.requires_action"),
|
|
4514
|
+
event_id: z15.string().nullish(),
|
|
4515
|
+
interaction_id: z15.string().nullish(),
|
|
4516
|
+
status: status.nullish()
|
|
4457
4517
|
}).loose();
|
|
4458
|
-
const
|
|
4459
|
-
event_type: z15.literal("interaction.
|
|
4518
|
+
const interactionCompletedEvent = z15.object({
|
|
4519
|
+
event_type: z15.literal("interaction.completed"),
|
|
4460
4520
|
event_id: z15.string().nullish(),
|
|
4461
4521
|
interaction: z15.object({
|
|
4462
4522
|
id: z15.string().nullish(),
|
|
@@ -4475,12 +4535,14 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4475
4535
|
}).loose();
|
|
4476
4536
|
const unknownEvent = z15.object({ event_type: z15.string() }).loose();
|
|
4477
4537
|
return z15.union([
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4538
|
+
interactionCreatedEvent,
|
|
4539
|
+
stepStartEvent,
|
|
4540
|
+
stepDeltaEvent,
|
|
4541
|
+
stepStopEvent,
|
|
4482
4542
|
interactionStatusUpdateEvent,
|
|
4483
|
-
|
|
4543
|
+
interactionInProgressEvent,
|
|
4544
|
+
interactionRequiresActionEvent,
|
|
4545
|
+
interactionCompletedEvent,
|
|
4484
4546
|
errorEvent,
|
|
4485
4547
|
unknownEvent
|
|
4486
4548
|
]);
|
|
@@ -4513,6 +4575,55 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
4513
4575
|
]).nullish(),
|
|
4514
4576
|
thinkingLevel: z16.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
4515
4577
|
thinkingSummaries: z16.enum(["auto", "none"]).nullish(),
|
|
4578
|
+
/**
|
|
4579
|
+
* Output-format entries that map directly to the API's `response_format`
|
|
4580
|
+
* array. Use this to request image, audio, or non-JSON text outputs
|
|
4581
|
+
* with full control over `mime_type`, `aspect_ratio`, and `image_size`.
|
|
4582
|
+
*
|
|
4583
|
+
* Entries are sent in order. The AI SDK call-level `responseFormat: {
|
|
4584
|
+
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
4585
|
+
* text entry automatically; entries listed here are appended.
|
|
4586
|
+
*/
|
|
4587
|
+
responseFormat: z16.array(
|
|
4588
|
+
z16.union([
|
|
4589
|
+
z16.object({
|
|
4590
|
+
type: z16.literal("text"),
|
|
4591
|
+
mimeType: z16.string().nullish(),
|
|
4592
|
+
schema: z16.unknown().nullish()
|
|
4593
|
+
}).loose(),
|
|
4594
|
+
z16.object({
|
|
4595
|
+
type: z16.literal("image"),
|
|
4596
|
+
mimeType: z16.string().nullish(),
|
|
4597
|
+
aspectRatio: z16.enum([
|
|
4598
|
+
"1:1",
|
|
4599
|
+
"2:3",
|
|
4600
|
+
"3:2",
|
|
4601
|
+
"3:4",
|
|
4602
|
+
"4:3",
|
|
4603
|
+
"4:5",
|
|
4604
|
+
"5:4",
|
|
4605
|
+
"9:16",
|
|
4606
|
+
"16:9",
|
|
4607
|
+
"21:9",
|
|
4608
|
+
"1:8",
|
|
4609
|
+
"8:1",
|
|
4610
|
+
"1:4",
|
|
4611
|
+
"4:1"
|
|
4612
|
+
]).nullish(),
|
|
4613
|
+
imageSize: z16.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
4614
|
+
}).loose(),
|
|
4615
|
+
z16.object({
|
|
4616
|
+
type: z16.literal("audio"),
|
|
4617
|
+
mimeType: z16.string().nullish()
|
|
4618
|
+
}).loose()
|
|
4619
|
+
])
|
|
4620
|
+
).nullish(),
|
|
4621
|
+
/**
|
|
4622
|
+
* @deprecated Use `responseFormat` with a `{ type: 'image', ... }`
|
|
4623
|
+
* entry instead. Retained for backwards compatibility; the SDK
|
|
4624
|
+
* translates it into a matching `response_format` image entry and
|
|
4625
|
+
* emits a warning when set.
|
|
4626
|
+
*/
|
|
4516
4627
|
imageConfig: z16.object({
|
|
4517
4628
|
aspectRatio: z16.enum([
|
|
4518
4629
|
"1:1",
|
|
@@ -4600,37 +4711,69 @@ function builtinToolNameFromResultType2(type) {
|
|
|
4600
4711
|
return type.replace(/_result$/, "");
|
|
4601
4712
|
}
|
|
4602
4713
|
function parseGoogleInteractionsOutputs({
|
|
4603
|
-
|
|
4714
|
+
steps,
|
|
4604
4715
|
generateId: generateId3,
|
|
4605
4716
|
interactionId
|
|
4606
4717
|
}) {
|
|
4607
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4718
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4608
4719
|
const content = [];
|
|
4609
4720
|
let hasFunctionCall = false;
|
|
4610
|
-
if (
|
|
4721
|
+
if (steps == null) {
|
|
4611
4722
|
return { content, hasFunctionCall };
|
|
4612
4723
|
}
|
|
4613
|
-
for (const
|
|
4614
|
-
if (
|
|
4615
|
-
const type =
|
|
4724
|
+
for (const step of steps) {
|
|
4725
|
+
if (step == null || typeof step !== "object") continue;
|
|
4726
|
+
const type = step.type;
|
|
4616
4727
|
if (typeof type !== "string") continue;
|
|
4617
4728
|
switch (type) {
|
|
4618
|
-
case "
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4729
|
+
case "user_input": {
|
|
4730
|
+
break;
|
|
4731
|
+
}
|
|
4732
|
+
case "model_output": {
|
|
4733
|
+
const blocks = (_a = step.content) != null ? _a : [];
|
|
4734
|
+
for (const block of blocks) {
|
|
4735
|
+
if (block == null || typeof block !== "object") continue;
|
|
4736
|
+
const blockType = block.type;
|
|
4737
|
+
if (blockType === "text") {
|
|
4738
|
+
const text = (_b = block.text) != null ? _b : "";
|
|
4739
|
+
const annotations = block.annotations;
|
|
4740
|
+
content.push({
|
|
4741
|
+
type: "text",
|
|
4742
|
+
text,
|
|
4743
|
+
...googleProviderMetadata({ interactionId })
|
|
4744
|
+
});
|
|
4745
|
+
const sources = annotationsToSources({ annotations, generateId: generateId3 });
|
|
4746
|
+
for (const source of sources) {
|
|
4747
|
+
content.push(source);
|
|
4748
|
+
}
|
|
4749
|
+
} else if (blockType === "image") {
|
|
4750
|
+
const image = block;
|
|
4751
|
+
if (image.data != null && image.data.length > 0) {
|
|
4752
|
+
content.push({
|
|
4753
|
+
type: "file",
|
|
4754
|
+
mediaType: (_c = image.mime_type) != null ? _c : "image/png",
|
|
4755
|
+
data: image.data,
|
|
4756
|
+
...googleProviderMetadata({ interactionId })
|
|
4757
|
+
});
|
|
4758
|
+
} else if (image.uri != null && image.uri.length > 0) {
|
|
4759
|
+
content.push({
|
|
4760
|
+
type: "file",
|
|
4761
|
+
mediaType: (_d = image.mime_type) != null ? _d : "image/png",
|
|
4762
|
+
data: "",
|
|
4763
|
+
providerMetadata: {
|
|
4764
|
+
google: {
|
|
4765
|
+
...interactionId != null ? { interactionId } : {},
|
|
4766
|
+
imageUri: image.uri
|
|
4767
|
+
}
|
|
4768
|
+
}
|
|
4769
|
+
});
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4629
4772
|
}
|
|
4630
4773
|
break;
|
|
4631
4774
|
}
|
|
4632
4775
|
case "thought": {
|
|
4633
|
-
const thought =
|
|
4776
|
+
const thought = step;
|
|
4634
4777
|
const summary = Array.isArray(thought.summary) ? thought.summary : [];
|
|
4635
4778
|
const text = summary.filter(
|
|
4636
4779
|
(item) => (item == null ? void 0 : item.type) === "text" && typeof item.text === "string"
|
|
@@ -4645,38 +4788,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
4645
4788
|
});
|
|
4646
4789
|
break;
|
|
4647
4790
|
}
|
|
4648
|
-
case "image": {
|
|
4649
|
-
const image = block;
|
|
4650
|
-
if (image.data != null && image.data.length > 0) {
|
|
4651
|
-
content.push({
|
|
4652
|
-
type: "file",
|
|
4653
|
-
mediaType: (_b = image.mime_type) != null ? _b : "image/png",
|
|
4654
|
-
data: image.data,
|
|
4655
|
-
...googleProviderMetadata({ interactionId })
|
|
4656
|
-
});
|
|
4657
|
-
} else if (image.uri != null && image.uri.length > 0) {
|
|
4658
|
-
content.push({
|
|
4659
|
-
type: "file",
|
|
4660
|
-
mediaType: (_c = image.mime_type) != null ? _c : "image/png",
|
|
4661
|
-
data: "",
|
|
4662
|
-
providerMetadata: {
|
|
4663
|
-
google: {
|
|
4664
|
-
...interactionId != null ? { interactionId } : {},
|
|
4665
|
-
imageUri: image.uri
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
|
-
});
|
|
4669
|
-
}
|
|
4670
|
-
break;
|
|
4671
|
-
}
|
|
4672
4791
|
case "function_call": {
|
|
4673
4792
|
hasFunctionCall = true;
|
|
4674
|
-
const call =
|
|
4793
|
+
const call = step;
|
|
4675
4794
|
content.push({
|
|
4676
4795
|
type: "tool-call",
|
|
4677
4796
|
toolCallId: call.id,
|
|
4678
4797
|
toolName: call.name,
|
|
4679
|
-
input: JSON.stringify((
|
|
4798
|
+
input: JSON.stringify((_e = call.arguments) != null ? _e : {}),
|
|
4680
4799
|
...googleProviderMetadata({
|
|
4681
4800
|
signature: call.signature,
|
|
4682
4801
|
interactionId
|
|
@@ -4686,27 +4805,27 @@ function parseGoogleInteractionsOutputs({
|
|
|
4686
4805
|
}
|
|
4687
4806
|
default: {
|
|
4688
4807
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
4689
|
-
const call =
|
|
4690
|
-
const toolName = type === "mcp_server_tool_call" ? (
|
|
4691
|
-
const input = JSON.stringify((
|
|
4808
|
+
const call = step;
|
|
4809
|
+
const toolName = type === "mcp_server_tool_call" ? (_f = call.name) != null ? _f : "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
4810
|
+
const input = JSON.stringify((_g = call.arguments) != null ? _g : {});
|
|
4692
4811
|
content.push({
|
|
4693
4812
|
type: "tool-call",
|
|
4694
|
-
toolCallId: (
|
|
4813
|
+
toolCallId: (_h = call.id) != null ? _h : generateId3(),
|
|
4695
4814
|
toolName,
|
|
4696
4815
|
input,
|
|
4697
4816
|
providerExecuted: true
|
|
4698
4817
|
});
|
|
4699
4818
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
4700
|
-
const result =
|
|
4701
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
4819
|
+
const result = step;
|
|
4820
|
+
const toolName = type === "mcp_server_tool_result" ? (_i = result.name) != null ? _i : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
4702
4821
|
content.push({
|
|
4703
4822
|
type: "tool-result",
|
|
4704
|
-
toolCallId: (
|
|
4823
|
+
toolCallId: (_j = result.call_id) != null ? _j : generateId3(),
|
|
4705
4824
|
toolName,
|
|
4706
|
-
result: (
|
|
4825
|
+
result: (_k = result.result) != null ? _k : null
|
|
4707
4826
|
});
|
|
4708
4827
|
const sources = builtinToolResultToSources({
|
|
4709
|
-
block,
|
|
4828
|
+
block: step,
|
|
4710
4829
|
generateId: generateId3
|
|
4711
4830
|
});
|
|
4712
4831
|
for (const source of sources) {
|
|
@@ -5094,7 +5213,7 @@ function streamGoogleInteractionEvents({
|
|
|
5094
5213
|
if (typeof ev.event_id === "string" && ev.event_id.length > 0) {
|
|
5095
5214
|
lastEventId = ev.event_id;
|
|
5096
5215
|
}
|
|
5097
|
-
if (ev.event_type === "interaction.
|
|
5216
|
+
if (ev.event_type === "interaction.completed" || ev.event_type === "error") {
|
|
5098
5217
|
complete = true;
|
|
5099
5218
|
}
|
|
5100
5219
|
}
|
|
@@ -5175,7 +5294,7 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
5175
5294
|
controller.enqueue({ type: "raw", rawValue: response });
|
|
5176
5295
|
}
|
|
5177
5296
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5178
|
-
|
|
5297
|
+
steps: (_b = response.steps) != null ? _b : null,
|
|
5179
5298
|
generateId: generateId3,
|
|
5180
5299
|
interactionId
|
|
5181
5300
|
});
|
|
@@ -5317,7 +5436,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5317
5436
|
};
|
|
5318
5437
|
}
|
|
5319
5438
|
async getArgs(options) {
|
|
5320
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
5439
|
+
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;
|
|
5321
5440
|
const warnings = [];
|
|
5322
5441
|
const opts = await parseProviderOptions5({
|
|
5323
5442
|
provider: "google",
|
|
@@ -5342,8 +5461,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5342
5461
|
toolChoiceForBody = prepared.toolChoice;
|
|
5343
5462
|
warnings.push(...prepared.toolWarnings);
|
|
5344
5463
|
}
|
|
5345
|
-
|
|
5346
|
-
let responseFormat;
|
|
5464
|
+
const responseFormatEntries = [];
|
|
5347
5465
|
if (((_a = options.responseFormat) == null ? void 0 : _a.type) === "json") {
|
|
5348
5466
|
if (isAgent) {
|
|
5349
5467
|
warnings.push({
|
|
@@ -5351,9 +5469,40 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5351
5469
|
message: "google.interactions: structured output (responseFormat) is not supported when an agent is set; responseFormat will be ignored."
|
|
5352
5470
|
});
|
|
5353
5471
|
} else {
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5472
|
+
const entry = {
|
|
5473
|
+
type: "text",
|
|
5474
|
+
mime_type: "application/json",
|
|
5475
|
+
...options.responseFormat.schema != null ? { schema: options.responseFormat.schema } : {}
|
|
5476
|
+
};
|
|
5477
|
+
responseFormatEntries.push(entry);
|
|
5478
|
+
}
|
|
5479
|
+
}
|
|
5480
|
+
if ((opts == null ? void 0 : opts.responseFormat) != null) {
|
|
5481
|
+
for (const entry of opts.responseFormat) {
|
|
5482
|
+
if (entry.type === "text") {
|
|
5483
|
+
responseFormatEntries.push(
|
|
5484
|
+
pruneUndefined({
|
|
5485
|
+
type: "text",
|
|
5486
|
+
mime_type: (_b = entry.mimeType) != null ? _b : void 0,
|
|
5487
|
+
schema: (_c = entry.schema) != null ? _c : void 0
|
|
5488
|
+
})
|
|
5489
|
+
);
|
|
5490
|
+
} else if (entry.type === "image") {
|
|
5491
|
+
responseFormatEntries.push(
|
|
5492
|
+
pruneUndefined({
|
|
5493
|
+
type: "image",
|
|
5494
|
+
mime_type: (_d = entry.mimeType) != null ? _d : void 0,
|
|
5495
|
+
aspect_ratio: (_e = entry.aspectRatio) != null ? _e : void 0,
|
|
5496
|
+
image_size: (_f = entry.imageSize) != null ? _f : void 0
|
|
5497
|
+
})
|
|
5498
|
+
);
|
|
5499
|
+
} else if (entry.type === "audio") {
|
|
5500
|
+
responseFormatEntries.push(
|
|
5501
|
+
pruneUndefined({
|
|
5502
|
+
type: "audio",
|
|
5503
|
+
mime_type: (_g = entry.mimeType) != null ? _g : void 0
|
|
5504
|
+
})
|
|
5505
|
+
);
|
|
5357
5506
|
}
|
|
5358
5507
|
}
|
|
5359
5508
|
}
|
|
@@ -5363,13 +5512,13 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5363
5512
|
warnings: convWarnings
|
|
5364
5513
|
} = convertToGoogleInteractionsInput({
|
|
5365
5514
|
prompt: options.prompt,
|
|
5366
|
-
previousInteractionId: (
|
|
5367
|
-
store: (
|
|
5368
|
-
mediaResolution: (
|
|
5515
|
+
previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
|
|
5516
|
+
store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
|
|
5517
|
+
mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
|
|
5369
5518
|
});
|
|
5370
5519
|
warnings.push(...convWarnings);
|
|
5371
5520
|
let systemInstruction = convertedSystemInstruction;
|
|
5372
|
-
const optionSystemInstruction = (
|
|
5521
|
+
const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
|
|
5373
5522
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
5374
5523
|
warnings.push({
|
|
5375
5524
|
type: "other",
|
|
@@ -5403,19 +5552,32 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5403
5552
|
generationConfig = void 0;
|
|
5404
5553
|
} else {
|
|
5405
5554
|
generationConfig = pruneUndefined({
|
|
5406
|
-
temperature: (
|
|
5407
|
-
top_p: (
|
|
5408
|
-
seed: (
|
|
5555
|
+
temperature: (_l = options.temperature) != null ? _l : void 0,
|
|
5556
|
+
top_p: (_m = options.topP) != null ? _m : void 0,
|
|
5557
|
+
seed: (_n = options.seed) != null ? _n : void 0,
|
|
5409
5558
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
5410
|
-
max_output_tokens: (
|
|
5411
|
-
thinking_level: (
|
|
5412
|
-
thinking_summaries: (
|
|
5413
|
-
image_config: (opts == null ? void 0 : opts.imageConfig) != null ? pruneUndefined({
|
|
5414
|
-
aspect_ratio: (_l = opts.imageConfig.aspectRatio) != null ? _l : void 0,
|
|
5415
|
-
image_size: (_m = opts.imageConfig.imageSize) != null ? _m : void 0
|
|
5416
|
-
}) : void 0,
|
|
5559
|
+
max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
|
|
5560
|
+
thinking_level: (_p = opts == null ? void 0 : opts.thinkingLevel) != null ? _p : void 0,
|
|
5561
|
+
thinking_summaries: (_q = opts == null ? void 0 : opts.thinkingSummaries) != null ? _q : void 0,
|
|
5417
5562
|
tool_choice: toolChoiceForBody
|
|
5418
5563
|
});
|
|
5564
|
+
if ((opts == null ? void 0 : opts.imageConfig) != null) {
|
|
5565
|
+
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
5566
|
+
(entry) => entry.type === "image"
|
|
5567
|
+
);
|
|
5568
|
+
warnings.push({
|
|
5569
|
+
type: "other",
|
|
5570
|
+
message: alreadyHasImageEntry ? "google.interactions: providerOptions.google.imageConfig is deprecated and was ignored because providerOptions.google.responseFormat already supplies an image entry. Use responseFormat exclusively." : 'google.interactions: providerOptions.google.imageConfig is deprecated. Use providerOptions.google.responseFormat with a { type: "image", ... } entry instead.'
|
|
5571
|
+
});
|
|
5572
|
+
if (!alreadyHasImageEntry) {
|
|
5573
|
+
responseFormatEntries.push({
|
|
5574
|
+
type: "image",
|
|
5575
|
+
mime_type: "image/png",
|
|
5576
|
+
...opts.imageConfig.aspectRatio != null ? { aspect_ratio: opts.imageConfig.aspectRatio } : {},
|
|
5577
|
+
...opts.imageConfig.imageSize != null ? { image_size: opts.imageConfig.imageSize } : {}
|
|
5578
|
+
});
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5419
5581
|
}
|
|
5420
5582
|
let agentConfig;
|
|
5421
5583
|
if (isAgent && (opts == null ? void 0 : opts.agentConfig) != null) {
|
|
@@ -5423,9 +5585,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5423
5585
|
if (ac.type === "deep-research") {
|
|
5424
5586
|
agentConfig = pruneUndefined({
|
|
5425
5587
|
type: "deep-research",
|
|
5426
|
-
thinking_summaries: (
|
|
5427
|
-
visualization: (
|
|
5428
|
-
collaborative_planning: (
|
|
5588
|
+
thinking_summaries: (_r = ac.thinkingSummaries) != null ? _r : void 0,
|
|
5589
|
+
visualization: (_s = ac.visualization) != null ? _s : void 0,
|
|
5590
|
+
collaborative_planning: (_t = ac.collaborativePlanning) != null ? _t : void 0
|
|
5429
5591
|
});
|
|
5430
5592
|
} else if (ac.type === "dynamic") {
|
|
5431
5593
|
agentConfig = { type: "dynamic" };
|
|
@@ -5436,12 +5598,11 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5436
5598
|
input,
|
|
5437
5599
|
system_instruction: systemInstruction,
|
|
5438
5600
|
tools: toolsForBody,
|
|
5439
|
-
response_format:
|
|
5440
|
-
response_mime_type: responseMimeType,
|
|
5601
|
+
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5441
5602
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5442
|
-
previous_interaction_id: (
|
|
5443
|
-
service_tier: (
|
|
5444
|
-
store: (
|
|
5603
|
+
previous_interaction_id: (_u = opts == null ? void 0 : opts.previousInteractionId) != null ? _u : void 0,
|
|
5604
|
+
service_tier: (_v = opts == null ? void 0 : opts.serviceTier) != null ? _v : void 0,
|
|
5605
|
+
store: (_w = opts == null ? void 0 : opts.store) != null ? _w : void 0,
|
|
5445
5606
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5446
5607
|
agent_config: agentConfig,
|
|
5447
5608
|
...isAgent ? { background: true } : {}
|
|
@@ -5450,7 +5611,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5450
5611
|
args,
|
|
5451
5612
|
warnings,
|
|
5452
5613
|
isAgent,
|
|
5453
|
-
pollingTimeoutMs: (
|
|
5614
|
+
pollingTimeoutMs: (_x = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _x : void 0
|
|
5454
5615
|
};
|
|
5455
5616
|
}
|
|
5456
5617
|
async doGenerate(options) {
|
|
@@ -5458,6 +5619,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5458
5619
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
5459
5620
|
const url = `${this.config.baseURL}/interactions`;
|
|
5460
5621
|
const mergedHeaders = combineHeaders6(
|
|
5622
|
+
INTERACTIONS_API_REVISION_HEADER,
|
|
5461
5623
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
5462
5624
|
options.headers
|
|
5463
5625
|
);
|
|
@@ -5492,7 +5654,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5492
5654
|
}
|
|
5493
5655
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
5494
5656
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5495
|
-
|
|
5657
|
+
steps: (_b = response.steps) != null ? _b : null,
|
|
5496
5658
|
generateId: (_c = this.config.generateId) != null ? _c : defaultGenerateId2,
|
|
5497
5659
|
interactionId
|
|
5498
5660
|
});
|
|
@@ -5538,6 +5700,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5538
5700
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
5539
5701
|
const url = `${this.config.baseURL}/interactions`;
|
|
5540
5702
|
const mergedHeaders = combineHeaders6(
|
|
5703
|
+
INTERACTIONS_API_REVISION_HEADER,
|
|
5541
5704
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
5542
5705
|
options.headers
|
|
5543
5706
|
);
|
|
@@ -5657,6 +5820,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5657
5820
|
};
|
|
5658
5821
|
}
|
|
5659
5822
|
};
|
|
5823
|
+
var INTERACTIONS_API_REVISION_HEADER = {
|
|
5824
|
+
"Api-Revision": "2026-05-20"
|
|
5825
|
+
};
|
|
5660
5826
|
function pruneUndefined(obj) {
|
|
5661
5827
|
const result = {};
|
|
5662
5828
|
for (const [key, value] of Object.entries(obj)) {
|