@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.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.75" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -3125,7 +3125,7 @@ function annotationToSource({
|
|
|
3125
3125
|
}
|
|
3126
3126
|
case "file_citation": {
|
|
3127
3127
|
const a = annotation;
|
|
3128
|
-
const uri = (_b = (_a = a.
|
|
3128
|
+
const uri = (_b = (_a = a.url) != null ? _a : a.document_uri) != null ? _b : a.file_name;
|
|
3129
3129
|
if (uri == null || uri.length === 0) return void 0;
|
|
3130
3130
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3131
3131
|
return {
|
|
@@ -3219,7 +3219,7 @@ function builtinToolResultToSources({
|
|
|
3219
3219
|
for (const raw of result) {
|
|
3220
3220
|
if (raw == null || typeof raw !== "object") continue;
|
|
3221
3221
|
const entry = raw;
|
|
3222
|
-
const uri = (_g = (_f = entry.
|
|
3222
|
+
const uri = (_g = (_f = entry.url) != null ? _f : entry.document_uri) != null ? _g : entry.file_name;
|
|
3223
3223
|
if (uri == null || uri.length === 0) continue;
|
|
3224
3224
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3225
3225
|
sources.push({
|
|
@@ -3335,7 +3335,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3335
3335
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3336
3336
|
},
|
|
3337
3337
|
transform(chunk, controller) {
|
|
3338
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3338
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3339
3339
|
if (includeRawChunks) {
|
|
3340
3340
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3341
3341
|
}
|
|
@@ -3347,7 +3347,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3347
3347
|
const value = chunk.value;
|
|
3348
3348
|
const eventType = value.event_type;
|
|
3349
3349
|
switch (eventType) {
|
|
3350
|
-
case "interaction.
|
|
3350
|
+
case "interaction.created": {
|
|
3351
3351
|
const event = value;
|
|
3352
3352
|
const interaction = event.interaction;
|
|
3353
3353
|
interactionId = (interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0 ? interaction.id : void 0;
|
|
@@ -3367,91 +3367,106 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3367
3367
|
});
|
|
3368
3368
|
break;
|
|
3369
3369
|
}
|
|
3370
|
-
case "
|
|
3370
|
+
case "step.start": {
|
|
3371
3371
|
const event = value;
|
|
3372
|
-
const
|
|
3372
|
+
const step = event.step;
|
|
3373
3373
|
const index = event.index;
|
|
3374
3374
|
const blockId = `${interactionId != null ? interactionId : "interaction"}:${index}`;
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3375
|
+
const stepType = step == null ? void 0 : step.type;
|
|
3376
|
+
if (stepType === "model_output") {
|
|
3377
|
+
const initial = (_a = step == null ? void 0 : step.content) == null ? void 0 : _a[0];
|
|
3378
|
+
if ((initial == null ? void 0 : initial.type) === "text") {
|
|
3379
|
+
openBlocks.set(index, {
|
|
3380
|
+
kind: "text",
|
|
3381
|
+
id: blockId,
|
|
3382
|
+
emittedSourceKeys: /* @__PURE__ */ new Set()
|
|
3383
|
+
});
|
|
3384
|
+
controller.enqueue({ type: "text-start", id: blockId });
|
|
3385
|
+
const initialSources = annotationsToSources({
|
|
3386
|
+
annotations: initial.annotations,
|
|
3387
|
+
generateId: generateId3
|
|
3388
|
+
});
|
|
3389
|
+
for (const source of initialSources) {
|
|
3390
|
+
const key = sourceKey(source);
|
|
3391
|
+
if (emittedSourceKeys.has(key)) continue;
|
|
3392
|
+
emittedSourceKeys.add(key);
|
|
3393
|
+
controller.enqueue(source);
|
|
3394
|
+
}
|
|
3395
|
+
} else if ((initial == null ? void 0 : initial.type) === "image") {
|
|
3396
|
+
openBlocks.set(index, {
|
|
3397
|
+
kind: "image",
|
|
3398
|
+
id: blockId,
|
|
3399
|
+
...initial.data != null ? { data: initial.data } : {},
|
|
3400
|
+
...initial.mime_type != null ? { mimeType: initial.mime_type } : {},
|
|
3401
|
+
...initial.uri != null ? { uri: initial.uri } : {}
|
|
3402
|
+
});
|
|
3403
|
+
} else {
|
|
3404
|
+
openBlocks.set(index, {
|
|
3405
|
+
kind: "pending_model_output",
|
|
3406
|
+
id: blockId
|
|
3407
|
+
});
|
|
3391
3408
|
}
|
|
3392
|
-
} else if (
|
|
3393
|
-
const
|
|
3394
|
-
openBlocks.set(index, {
|
|
3395
|
-
kind: "image",
|
|
3396
|
-
id: blockId,
|
|
3397
|
-
...img.data != null ? { data: img.data } : {},
|
|
3398
|
-
...img.mime_type != null ? { mimeType: img.mime_type } : {},
|
|
3399
|
-
...img.uri != null ? { uri: img.uri } : {}
|
|
3400
|
-
});
|
|
3401
|
-
} else if ((block == null ? void 0 : block.type) === "thought") {
|
|
3402
|
-
const signature = block.signature;
|
|
3409
|
+
} else if (stepType === "thought") {
|
|
3410
|
+
const signature = step == null ? void 0 : step.signature;
|
|
3403
3411
|
openBlocks.set(index, {
|
|
3404
3412
|
kind: "reasoning",
|
|
3405
3413
|
id: blockId,
|
|
3406
3414
|
...signature != null ? { signature } : {}
|
|
3407
3415
|
});
|
|
3408
3416
|
controller.enqueue({ type: "reasoning-start", id: blockId });
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3417
|
+
if (Array.isArray(step == null ? void 0 : step.summary)) {
|
|
3418
|
+
for (const item of step.summary) {
|
|
3419
|
+
if ((item == null ? void 0 : item.type) === "text" && typeof item.text === "string") {
|
|
3420
|
+
controller.enqueue({
|
|
3421
|
+
type: "reasoning-delta",
|
|
3422
|
+
id: blockId,
|
|
3423
|
+
delta: item.text
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
} else if (stepType === "function_call") {
|
|
3429
|
+
const toolCallId = (_b = step == null ? void 0 : step.id) != null ? _b : blockId;
|
|
3430
|
+
const toolName = (_c = step == null ? void 0 : step.name) != null ? _c : "unknown";
|
|
3412
3431
|
hasFunctionCall = true;
|
|
3413
3432
|
const state = {
|
|
3414
3433
|
kind: "function_call",
|
|
3415
3434
|
id: blockId,
|
|
3416
3435
|
toolCallId,
|
|
3417
|
-
toolName
|
|
3418
|
-
|
|
3419
|
-
...
|
|
3420
|
-
startEmitted: false
|
|
3436
|
+
toolName,
|
|
3437
|
+
argumentsAccum: "",
|
|
3438
|
+
...(step == null ? void 0 : step.signature) != null ? { signature: step.signature } : {}
|
|
3421
3439
|
};
|
|
3422
3440
|
openBlocks.set(index, state);
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
} else if ((block == null ? void 0 : block.type) != null && BUILTIN_TOOL_CALL_TYPES.has(block.type)) {
|
|
3432
|
-
const toolName = block.type === "mcp_server_tool_call" ? (_c = block.name) != null ? _c : "mcp_server_tool" : builtinToolNameFromCallType(block.type);
|
|
3433
|
-
const toolCallId = (_d = block.id) != null ? _d : blockId;
|
|
3441
|
+
controller.enqueue({
|
|
3442
|
+
type: "tool-input-start",
|
|
3443
|
+
id: toolCallId,
|
|
3444
|
+
toolName
|
|
3445
|
+
});
|
|
3446
|
+
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
3447
|
+
const toolName = stepType === "mcp_server_tool_call" ? (_d = step == null ? void 0 : step.name) != null ? _d : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
3448
|
+
const toolCallId = (_e = step == null ? void 0 : step.id) != null ? _e : blockId;
|
|
3434
3449
|
const state = {
|
|
3435
3450
|
kind: "builtin_tool_call",
|
|
3436
3451
|
id: blockId,
|
|
3437
|
-
blockType:
|
|
3452
|
+
blockType: stepType,
|
|
3438
3453
|
toolCallId,
|
|
3439
3454
|
toolName,
|
|
3440
|
-
arguments: (
|
|
3455
|
+
arguments: (_f = step == null ? void 0 : step.arguments) != null ? _f : {},
|
|
3441
3456
|
callEmitted: false
|
|
3442
3457
|
};
|
|
3443
3458
|
openBlocks.set(index, state);
|
|
3444
|
-
} else if (
|
|
3445
|
-
const toolName =
|
|
3446
|
-
const callId = (
|
|
3459
|
+
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
3460
|
+
const toolName = stepType === "mcp_server_tool_result" ? (_g = step == null ? void 0 : step.name) != null ? _g : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
3461
|
+
const callId = (_h = step == null ? void 0 : step.call_id) != null ? _h : blockId;
|
|
3447
3462
|
const state = {
|
|
3448
3463
|
kind: "builtin_tool_result",
|
|
3449
3464
|
id: blockId,
|
|
3450
|
-
blockType:
|
|
3465
|
+
blockType: stepType,
|
|
3451
3466
|
callId,
|
|
3452
3467
|
toolName,
|
|
3453
|
-
result: (
|
|
3454
|
-
...
|
|
3468
|
+
result: (_i = step == null ? void 0 : step.result) != null ? _i : null,
|
|
3469
|
+
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
3455
3470
|
resultEmitted: false
|
|
3456
3471
|
};
|
|
3457
3472
|
openBlocks.set(index, state);
|
|
@@ -3460,13 +3475,58 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3460
3475
|
}
|
|
3461
3476
|
break;
|
|
3462
3477
|
}
|
|
3463
|
-
case "
|
|
3478
|
+
case "step.delta": {
|
|
3464
3479
|
const event = value;
|
|
3465
|
-
|
|
3480
|
+
let open = openBlocks.get(event.index);
|
|
3466
3481
|
if (open == null) break;
|
|
3482
|
+
const dtype = (_j = event.delta) == null ? void 0 : _j.type;
|
|
3483
|
+
if (open.kind === "pending_model_output") {
|
|
3484
|
+
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
3485
|
+
const promoted = {
|
|
3486
|
+
kind: "text",
|
|
3487
|
+
id: open.id,
|
|
3488
|
+
emittedSourceKeys: /* @__PURE__ */ new Set()
|
|
3489
|
+
};
|
|
3490
|
+
openBlocks.set(event.index, promoted);
|
|
3491
|
+
open = promoted;
|
|
3492
|
+
controller.enqueue({ type: "text-start", id: promoted.id });
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
if (dtype === "image" && (open.kind === "pending_model_output" || open.kind === "text" || open.kind === "image")) {
|
|
3496
|
+
const img = event.delta;
|
|
3497
|
+
const google2 = {};
|
|
3498
|
+
if (interactionId != null) google2.interactionId = interactionId;
|
|
3499
|
+
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
3500
|
+
if ((img == null ? void 0 : img.data) != null && img.data.length > 0) {
|
|
3501
|
+
controller.enqueue({
|
|
3502
|
+
type: "file",
|
|
3503
|
+
mediaType: (_k = img.mime_type) != null ? _k : "image/png",
|
|
3504
|
+
data: img.data,
|
|
3505
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3506
|
+
});
|
|
3507
|
+
} else if ((img == null ? void 0 : img.uri) != null && img.uri.length > 0) {
|
|
3508
|
+
const uriProviderMetadata = {
|
|
3509
|
+
google: {
|
|
3510
|
+
...interactionId != null ? { interactionId } : {},
|
|
3511
|
+
imageUri: img.uri
|
|
3512
|
+
}
|
|
3513
|
+
};
|
|
3514
|
+
controller.enqueue({
|
|
3515
|
+
type: "file",
|
|
3516
|
+
mediaType: (_l = img.mime_type) != null ? _l : "image/png",
|
|
3517
|
+
data: "",
|
|
3518
|
+
providerMetadata: uriProviderMetadata
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
if (open.kind === "image") {
|
|
3522
|
+
open.data = void 0;
|
|
3523
|
+
open.uri = void 0;
|
|
3524
|
+
}
|
|
3525
|
+
break;
|
|
3526
|
+
}
|
|
3467
3527
|
const delta = event.delta;
|
|
3468
3528
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3469
|
-
const text = (
|
|
3529
|
+
const text = (_m = delta.text) != null ? _m : "";
|
|
3470
3530
|
if (text.length > 0) {
|
|
3471
3531
|
controller.enqueue({
|
|
3472
3532
|
type: "text-delta",
|
|
@@ -3474,7 +3534,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3474
3534
|
delta: text
|
|
3475
3535
|
});
|
|
3476
3536
|
}
|
|
3477
|
-
} else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text_annotation") {
|
|
3537
|
+
} else if (open.kind === "text" && ((delta == null ? void 0 : delta.type) === "text_annotation" || (delta == null ? void 0 : delta.type) === "text_annotation_delta")) {
|
|
3478
3538
|
const sources = annotationsToSources({
|
|
3479
3539
|
annotations: delta.annotations,
|
|
3480
3540
|
generateId: generateId3
|
|
@@ -3506,31 +3566,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3506
3566
|
open.signature = signature;
|
|
3507
3567
|
}
|
|
3508
3568
|
}
|
|
3509
|
-
} else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "
|
|
3569
|
+
} else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "arguments_delta") {
|
|
3570
|
+
const slice = typeof delta.arguments === "string" ? delta.arguments : "";
|
|
3571
|
+
if (slice.length > 0) {
|
|
3572
|
+
open.argumentsAccum += slice;
|
|
3573
|
+
controller.enqueue({
|
|
3574
|
+
type: "tool-input-delta",
|
|
3575
|
+
id: open.toolCallId,
|
|
3576
|
+
delta: slice
|
|
3577
|
+
});
|
|
3578
|
+
}
|
|
3510
3579
|
if (delta.id != null) {
|
|
3511
3580
|
open.toolCallId = delta.id;
|
|
3512
3581
|
}
|
|
3513
|
-
if (delta.name != null) {
|
|
3514
|
-
open.toolName = delta.name;
|
|
3515
|
-
}
|
|
3516
|
-
if (delta.arguments != null) {
|
|
3517
|
-
open.arguments = delta.arguments;
|
|
3518
|
-
}
|
|
3519
3582
|
if (delta.signature != null) {
|
|
3520
3583
|
open.signature = delta.signature;
|
|
3521
3584
|
}
|
|
3522
|
-
if (!open.startEmitted && open.toolName != null) {
|
|
3523
|
-
controller.enqueue({
|
|
3524
|
-
type: "tool-input-start",
|
|
3525
|
-
id: open.toolCallId,
|
|
3526
|
-
toolName: open.toolName
|
|
3527
|
-
});
|
|
3528
|
-
open.startEmitted = true;
|
|
3529
|
-
}
|
|
3530
3585
|
hasFunctionCall = true;
|
|
3531
3586
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3532
3587
|
if (delta.id != null) open.toolCallId = delta.id;
|
|
3533
|
-
if (delta.arguments != null
|
|
3588
|
+
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
3589
|
+
open.arguments = delta.arguments;
|
|
3590
|
+
}
|
|
3534
3591
|
if (delta.name != null && open.blockType === "mcp_server_tool_call") {
|
|
3535
3592
|
open.toolName = delta.name;
|
|
3536
3593
|
}
|
|
@@ -3544,7 +3601,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3544
3601
|
}
|
|
3545
3602
|
break;
|
|
3546
3603
|
}
|
|
3547
|
-
case "
|
|
3604
|
+
case "step.stop": {
|
|
3548
3605
|
const event = value;
|
|
3549
3606
|
const open = openBlocks.get(event.index);
|
|
3550
3607
|
if (open == null) break;
|
|
@@ -3572,7 +3629,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3572
3629
|
if (open.data != null && open.data.length > 0) {
|
|
3573
3630
|
controller.enqueue({
|
|
3574
3631
|
type: "file",
|
|
3575
|
-
mediaType: (
|
|
3632
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
3576
3633
|
data: open.data,
|
|
3577
3634
|
...providerMetadata ? { providerMetadata } : {}
|
|
3578
3635
|
});
|
|
@@ -3585,26 +3642,13 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3585
3642
|
};
|
|
3586
3643
|
controller.enqueue({
|
|
3587
3644
|
type: "file",
|
|
3588
|
-
mediaType: (
|
|
3645
|
+
mediaType: (_o = open.mimeType) != null ? _o : "image/png",
|
|
3589
3646
|
data: "",
|
|
3590
3647
|
providerMetadata: uriProviderMetadata
|
|
3591
3648
|
});
|
|
3592
3649
|
}
|
|
3593
3650
|
} else if (open.kind === "function_call") {
|
|
3594
|
-
const
|
|
3595
|
-
const argsJson = JSON.stringify((_m = open.arguments) != null ? _m : {});
|
|
3596
|
-
if (!open.startEmitted) {
|
|
3597
|
-
controller.enqueue({
|
|
3598
|
-
type: "tool-input-start",
|
|
3599
|
-
id: open.toolCallId,
|
|
3600
|
-
toolName
|
|
3601
|
-
});
|
|
3602
|
-
}
|
|
3603
|
-
controller.enqueue({
|
|
3604
|
-
type: "tool-input-delta",
|
|
3605
|
-
id: open.toolCallId,
|
|
3606
|
-
delta: argsJson
|
|
3607
|
-
});
|
|
3651
|
+
const accumulated = open.argumentsAccum.length > 0 ? open.argumentsAccum : "{}";
|
|
3608
3652
|
controller.enqueue({
|
|
3609
3653
|
type: "tool-input-end",
|
|
3610
3654
|
id: open.toolCallId
|
|
@@ -3616,8 +3660,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3616
3660
|
controller.enqueue({
|
|
3617
3661
|
type: "tool-call",
|
|
3618
3662
|
toolCallId: open.toolCallId,
|
|
3619
|
-
toolName,
|
|
3620
|
-
input:
|
|
3663
|
+
toolName: open.toolName,
|
|
3664
|
+
input: accumulated,
|
|
3621
3665
|
...providerMetadata ? { providerMetadata } : {}
|
|
3622
3666
|
});
|
|
3623
3667
|
} else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
|
|
@@ -3625,7 +3669,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3625
3669
|
type: "tool-call",
|
|
3626
3670
|
toolCallId: open.toolCallId,
|
|
3627
3671
|
toolName: open.toolName,
|
|
3628
|
-
input: JSON.stringify((
|
|
3672
|
+
input: JSON.stringify((_p = open.arguments) != null ? _p : {}),
|
|
3629
3673
|
providerExecuted: true
|
|
3630
3674
|
});
|
|
3631
3675
|
open.callEmitted = true;
|
|
@@ -3634,7 +3678,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3634
3678
|
type: "tool-result",
|
|
3635
3679
|
toolCallId: open.callId,
|
|
3636
3680
|
toolName: open.toolName,
|
|
3637
|
-
result: (
|
|
3681
|
+
result: (_q = open.result) != null ? _q : null
|
|
3638
3682
|
});
|
|
3639
3683
|
open.resultEmitted = true;
|
|
3640
3684
|
const sources = builtinToolResultToSources({
|
|
@@ -3655,12 +3699,20 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3655
3699
|
openBlocks.delete(event.index);
|
|
3656
3700
|
break;
|
|
3657
3701
|
}
|
|
3658
|
-
case "interaction.status_update":
|
|
3702
|
+
case "interaction.status_update":
|
|
3703
|
+
case "interaction.in_progress":
|
|
3704
|
+
case "interaction.requires_action": {
|
|
3659
3705
|
const event = value;
|
|
3660
|
-
|
|
3706
|
+
if (event.status != null) {
|
|
3707
|
+
finishStatus = event.status;
|
|
3708
|
+
} else if (eventType === "interaction.requires_action") {
|
|
3709
|
+
finishStatus = "requires_action";
|
|
3710
|
+
} else {
|
|
3711
|
+
finishStatus = "in_progress";
|
|
3712
|
+
}
|
|
3661
3713
|
break;
|
|
3662
3714
|
}
|
|
3663
|
-
case "interaction.
|
|
3715
|
+
case "interaction.completed": {
|
|
3664
3716
|
const event = value;
|
|
3665
3717
|
const interaction = event.interaction;
|
|
3666
3718
|
if ((interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0) {
|
|
@@ -3680,7 +3732,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3680
3732
|
case "error": {
|
|
3681
3733
|
const event = value;
|
|
3682
3734
|
finishStatus = "failed";
|
|
3683
|
-
const errorPayload = (
|
|
3735
|
+
const errorPayload = (_r = event.error) != null ? _r : {
|
|
3684
3736
|
message: "Unknown interaction error"
|
|
3685
3737
|
};
|
|
3686
3738
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -3749,7 +3801,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3749
3801
|
previousInteractionId
|
|
3750
3802
|
}) : prompt;
|
|
3751
3803
|
const systemTexts = [];
|
|
3752
|
-
const
|
|
3804
|
+
const steps = [];
|
|
3753
3805
|
for (const message of compactedPrompt) {
|
|
3754
3806
|
switch (message.role) {
|
|
3755
3807
|
case "system": {
|
|
@@ -3760,11 +3812,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3760
3812
|
const content = [];
|
|
3761
3813
|
for (const part of message.content) {
|
|
3762
3814
|
if (part.type === "text") {
|
|
3763
|
-
|
|
3764
|
-
type: "text",
|
|
3765
|
-
text: part.text
|
|
3766
|
-
};
|
|
3767
|
-
content.push(block);
|
|
3815
|
+
content.push({ type: "text", text: part.text });
|
|
3768
3816
|
} else if (part.type === "file") {
|
|
3769
3817
|
const fileBlock = convertFilePartToContent({
|
|
3770
3818
|
part,
|
|
@@ -3778,18 +3826,25 @@ function convertToGoogleInteractionsInput({
|
|
|
3778
3826
|
}
|
|
3779
3827
|
const merged = mergeAdjacentTextContent(content);
|
|
3780
3828
|
if (merged.length > 0) {
|
|
3781
|
-
|
|
3829
|
+
steps.push({ type: "user_input", content: merged });
|
|
3782
3830
|
}
|
|
3783
3831
|
break;
|
|
3784
3832
|
}
|
|
3785
3833
|
case "assistant": {
|
|
3786
|
-
|
|
3834
|
+
let pendingModelOutput = [];
|
|
3835
|
+
const flushModelOutput = () => {
|
|
3836
|
+
if (pendingModelOutput.length > 0) {
|
|
3837
|
+
steps.push({ type: "model_output", content: pendingModelOutput });
|
|
3838
|
+
pendingModelOutput = [];
|
|
3839
|
+
}
|
|
3840
|
+
};
|
|
3787
3841
|
for (const part of message.content) {
|
|
3788
3842
|
if (part.type === "text") {
|
|
3789
|
-
|
|
3843
|
+
pendingModelOutput.push({ type: "text", text: part.text });
|
|
3790
3844
|
} else if (part.type === "reasoning") {
|
|
3845
|
+
flushModelOutput();
|
|
3791
3846
|
const signature = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.signature;
|
|
3792
|
-
|
|
3847
|
+
steps.push({
|
|
3793
3848
|
type: "thought",
|
|
3794
3849
|
...signature != null ? { signature } : {},
|
|
3795
3850
|
summary: part.text.length > 0 ? [{ type: "text", text: part.text }] : void 0
|
|
@@ -3801,12 +3856,13 @@ function convertToGoogleInteractionsInput({
|
|
|
3801
3856
|
mediaResolution
|
|
3802
3857
|
});
|
|
3803
3858
|
if (fileBlock != null) {
|
|
3804
|
-
|
|
3859
|
+
pendingModelOutput.push(fileBlock);
|
|
3805
3860
|
}
|
|
3806
3861
|
} else if (part.type === "tool-call") {
|
|
3862
|
+
flushModelOutput();
|
|
3807
3863
|
const signature = (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.signature;
|
|
3808
3864
|
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_e = part.input) != null ? _e : {};
|
|
3809
|
-
|
|
3865
|
+
steps.push({
|
|
3810
3866
|
type: "function_call",
|
|
3811
3867
|
id: part.toolCallId,
|
|
3812
3868
|
name: part.toolName,
|
|
@@ -3820,9 +3876,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3820
3876
|
});
|
|
3821
3877
|
}
|
|
3822
3878
|
}
|
|
3823
|
-
|
|
3824
|
-
turns.push({ role: "model", content });
|
|
3825
|
-
}
|
|
3879
|
+
flushModelOutput();
|
|
3826
3880
|
break;
|
|
3827
3881
|
}
|
|
3828
3882
|
case "tool": {
|
|
@@ -3845,22 +3899,14 @@ function convertToGoogleInteractionsInput({
|
|
|
3845
3899
|
content.push(block);
|
|
3846
3900
|
}
|
|
3847
3901
|
if (content.length > 0) {
|
|
3848
|
-
|
|
3902
|
+
steps.push({ type: "user_input", content });
|
|
3849
3903
|
}
|
|
3850
3904
|
break;
|
|
3851
3905
|
}
|
|
3852
3906
|
}
|
|
3853
3907
|
}
|
|
3854
3908
|
const systemInstruction = systemTexts.length > 0 ? systemTexts.join("\n\n") : void 0;
|
|
3855
|
-
|
|
3856
|
-
if (turns.length === 0) {
|
|
3857
|
-
input = "";
|
|
3858
|
-
} else if (turns.length === 1 && turns[0].role === "user" && Array.isArray(turns[0].content)) {
|
|
3859
|
-
input = turns[0].content;
|
|
3860
|
-
} else {
|
|
3861
|
-
input = turns;
|
|
3862
|
-
}
|
|
3863
|
-
return { input, systemInstruction, warnings };
|
|
3909
|
+
return { input: steps, systemInstruction, warnings };
|
|
3864
3910
|
}
|
|
3865
3911
|
function convertFilePartToContent({
|
|
3866
3912
|
part,
|
|
@@ -4155,7 +4201,7 @@ var annotationSchema = () => {
|
|
|
4155
4201
|
type: import_v415.z.literal("file_citation"),
|
|
4156
4202
|
file_name: import_v415.z.string().nullish(),
|
|
4157
4203
|
document_uri: import_v415.z.string().nullish(),
|
|
4158
|
-
|
|
4204
|
+
url: import_v415.z.string().nullish(),
|
|
4159
4205
|
page_number: import_v415.z.number().nullish(),
|
|
4160
4206
|
media_id: import_v415.z.string().nullish(),
|
|
4161
4207
|
start_index: import_v415.z.number().nullish(),
|
|
@@ -4189,34 +4235,58 @@ var contentBlockSchema = () => {
|
|
|
4189
4235
|
text: import_v415.z.string(),
|
|
4190
4236
|
annotations: import_v415.z.array(annotationSchema()).nullish()
|
|
4191
4237
|
}).loose();
|
|
4192
|
-
const
|
|
4193
|
-
type: import_v415.z.literal("
|
|
4194
|
-
|
|
4195
|
-
|
|
4238
|
+
const imageContent = import_v415.z.object({
|
|
4239
|
+
type: import_v415.z.literal("image"),
|
|
4240
|
+
data: import_v415.z.string().nullish(),
|
|
4241
|
+
mime_type: import_v415.z.string().nullish(),
|
|
4242
|
+
resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4243
|
+
uri: import_v415.z.string().nullish()
|
|
4196
4244
|
}).loose();
|
|
4197
|
-
|
|
4245
|
+
return import_v415.z.union([
|
|
4246
|
+
textContent,
|
|
4247
|
+
imageContent,
|
|
4248
|
+
import_v415.z.object({ type: import_v415.z.string() }).loose()
|
|
4249
|
+
]);
|
|
4250
|
+
};
|
|
4251
|
+
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
4252
|
+
"google_search_call",
|
|
4253
|
+
"code_execution_call",
|
|
4254
|
+
"url_context_call",
|
|
4255
|
+
"file_search_call",
|
|
4256
|
+
"google_maps_call",
|
|
4257
|
+
"mcp_server_tool_call"
|
|
4258
|
+
];
|
|
4259
|
+
var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
4260
|
+
"google_search_result",
|
|
4261
|
+
"code_execution_result",
|
|
4262
|
+
"url_context_result",
|
|
4263
|
+
"file_search_result",
|
|
4264
|
+
"google_maps_result",
|
|
4265
|
+
"mcp_server_tool_result"
|
|
4266
|
+
];
|
|
4267
|
+
var stepSchema = () => {
|
|
4268
|
+
const userInputStep = import_v415.z.object({
|
|
4269
|
+
type: import_v415.z.literal("user_input"),
|
|
4270
|
+
content: import_v415.z.array(contentBlockSchema()).nullish()
|
|
4271
|
+
}).loose();
|
|
4272
|
+
const modelOutputStep = import_v415.z.object({
|
|
4273
|
+
type: import_v415.z.literal("model_output"),
|
|
4274
|
+
content: import_v415.z.array(contentBlockSchema()).nullish()
|
|
4275
|
+
}).loose();
|
|
4276
|
+
const functionCallStep = import_v415.z.object({
|
|
4198
4277
|
type: import_v415.z.literal("function_call"),
|
|
4199
4278
|
id: import_v415.z.string(),
|
|
4200
4279
|
name: import_v415.z.string(),
|
|
4201
4280
|
arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
|
|
4202
4281
|
signature: import_v415.z.string().nullish()
|
|
4203
4282
|
}).loose();
|
|
4204
|
-
const
|
|
4205
|
-
type: import_v415.z.literal("
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4209
|
-
uri: import_v415.z.string().nullish()
|
|
4283
|
+
const thoughtStep = import_v415.z.object({
|
|
4284
|
+
type: import_v415.z.literal("thought"),
|
|
4285
|
+
signature: import_v415.z.string().nullish(),
|
|
4286
|
+
summary: import_v415.z.array(thoughtSummaryItemSchema()).nullish()
|
|
4210
4287
|
}).loose();
|
|
4211
|
-
const
|
|
4212
|
-
type: import_v415.z.enum(
|
|
4213
|
-
"google_search_call",
|
|
4214
|
-
"code_execution_call",
|
|
4215
|
-
"url_context_call",
|
|
4216
|
-
"file_search_call",
|
|
4217
|
-
"google_maps_call",
|
|
4218
|
-
"mcp_server_tool_call"
|
|
4219
|
-
]),
|
|
4288
|
+
const builtinToolCallStep = import_v415.z.object({
|
|
4289
|
+
type: import_v415.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4220
4290
|
id: import_v415.z.string(),
|
|
4221
4291
|
arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
|
|
4222
4292
|
name: import_v415.z.string().nullish(),
|
|
@@ -4224,15 +4294,8 @@ var contentBlockSchema = () => {
|
|
|
4224
4294
|
search_type: import_v415.z.string().nullish(),
|
|
4225
4295
|
signature: import_v415.z.string().nullish()
|
|
4226
4296
|
}).loose();
|
|
4227
|
-
const
|
|
4228
|
-
type: import_v415.z.enum(
|
|
4229
|
-
"google_search_result",
|
|
4230
|
-
"code_execution_result",
|
|
4231
|
-
"url_context_result",
|
|
4232
|
-
"file_search_result",
|
|
4233
|
-
"google_maps_result",
|
|
4234
|
-
"mcp_server_tool_result"
|
|
4235
|
-
]),
|
|
4297
|
+
const builtinToolResultStep = import_v415.z.object({
|
|
4298
|
+
type: import_v415.z.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4236
4299
|
call_id: import_v415.z.string(),
|
|
4237
4300
|
result: import_v415.z.unknown().nullish(),
|
|
4238
4301
|
is_error: import_v415.z.boolean().nullish(),
|
|
@@ -4241,12 +4304,12 @@ var contentBlockSchema = () => {
|
|
|
4241
4304
|
signature: import_v415.z.string().nullish()
|
|
4242
4305
|
}).loose();
|
|
4243
4306
|
return import_v415.z.union([
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4307
|
+
userInputStep,
|
|
4308
|
+
modelOutputStep,
|
|
4309
|
+
functionCallStep,
|
|
4310
|
+
thoughtStep,
|
|
4311
|
+
builtinToolCallStep,
|
|
4312
|
+
builtinToolResultStep,
|
|
4250
4313
|
import_v415.z.object({ type: import_v415.z.string() }).loose()
|
|
4251
4314
|
]);
|
|
4252
4315
|
};
|
|
@@ -4264,7 +4327,7 @@ var googleInteractionsResponseSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4264
4327
|
status: interactionStatusSchema(),
|
|
4265
4328
|
model: import_v415.z.string().nullish(),
|
|
4266
4329
|
agent: import_v415.z.string().nullish(),
|
|
4267
|
-
|
|
4330
|
+
steps: import_v415.z.array(stepSchema()).nullish(),
|
|
4268
4331
|
usage: usageSchema2().nullish(),
|
|
4269
4332
|
service_tier: import_v415.z.string().nullish(),
|
|
4270
4333
|
previous_interaction_id: import_v415.z.string().nullish(),
|
|
@@ -4278,8 +4341,8 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4278
4341
|
const status = interactionStatusSchema();
|
|
4279
4342
|
const annotation = annotationSchema();
|
|
4280
4343
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4281
|
-
const
|
|
4282
|
-
event_type: import_v415.z.literal("interaction.
|
|
4344
|
+
const interactionCreatedEvent = import_v415.z.object({
|
|
4345
|
+
event_type: import_v415.z.literal("interaction.created"),
|
|
4283
4346
|
event_id: import_v415.z.string().nullish(),
|
|
4284
4347
|
interaction: import_v415.z.object({
|
|
4285
4348
|
/*
|
|
@@ -4293,94 +4356,79 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4293
4356
|
status: status.nullish()
|
|
4294
4357
|
}).loose()
|
|
4295
4358
|
}).loose();
|
|
4296
|
-
const
|
|
4297
|
-
event_type: import_v415.z.literal("
|
|
4359
|
+
const stepStartEvent = import_v415.z.object({
|
|
4360
|
+
event_type: import_v415.z.literal("step.start"),
|
|
4298
4361
|
event_id: import_v415.z.string().nullish(),
|
|
4299
4362
|
index: import_v415.z.number(),
|
|
4300
|
-
|
|
4363
|
+
step: stepSchema()
|
|
4301
4364
|
}).loose();
|
|
4302
|
-
const
|
|
4365
|
+
const stepDeltaText = import_v415.z.object({
|
|
4303
4366
|
type: import_v415.z.literal("text"),
|
|
4304
4367
|
text: import_v415.z.string()
|
|
4305
4368
|
}).loose();
|
|
4306
|
-
const
|
|
4369
|
+
const stepDeltaThoughtSummary = import_v415.z.object({
|
|
4307
4370
|
type: import_v415.z.literal("thought_summary"),
|
|
4308
4371
|
content: thoughtSummaryItem.nullish()
|
|
4309
4372
|
}).loose();
|
|
4310
|
-
const
|
|
4373
|
+
const stepDeltaThoughtSignature = import_v415.z.object({
|
|
4311
4374
|
type: import_v415.z.literal("thought_signature"),
|
|
4312
4375
|
signature: import_v415.z.string().nullish()
|
|
4313
4376
|
}).loose();
|
|
4314
|
-
const
|
|
4315
|
-
type: import_v415.z.literal("
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
|
|
4377
|
+
const stepDeltaArgumentsDelta = import_v415.z.object({
|
|
4378
|
+
type: import_v415.z.literal("arguments_delta"),
|
|
4379
|
+
arguments: import_v415.z.string().nullish(),
|
|
4380
|
+
id: import_v415.z.string().nullish(),
|
|
4319
4381
|
signature: import_v415.z.string().nullish()
|
|
4320
4382
|
}).loose();
|
|
4321
|
-
const
|
|
4322
|
-
type: import_v415.z.
|
|
4383
|
+
const stepDeltaTextAnnotation = import_v415.z.object({
|
|
4384
|
+
type: import_v415.z.enum(["text_annotation_delta", "text_annotation"]),
|
|
4323
4385
|
annotations: import_v415.z.array(annotation).nullish()
|
|
4324
4386
|
}).loose();
|
|
4325
|
-
const
|
|
4387
|
+
const stepDeltaImage = import_v415.z.object({
|
|
4326
4388
|
type: import_v415.z.literal("image"),
|
|
4327
4389
|
data: import_v415.z.string().nullish(),
|
|
4328
4390
|
mime_type: import_v415.z.string().nullish(),
|
|
4329
4391
|
resolution: import_v415.z.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4330
4392
|
uri: import_v415.z.string().nullish()
|
|
4331
4393
|
}).loose();
|
|
4332
|
-
const
|
|
4333
|
-
type: import_v415.z.enum(
|
|
4334
|
-
|
|
4335
|
-
"code_execution_call",
|
|
4336
|
-
"url_context_call",
|
|
4337
|
-
"file_search_call",
|
|
4338
|
-
"google_maps_call",
|
|
4339
|
-
"mcp_server_tool_call"
|
|
4340
|
-
]),
|
|
4341
|
-
id: import_v415.z.string(),
|
|
4394
|
+
const stepDeltaBuiltinToolCall = import_v415.z.object({
|
|
4395
|
+
type: import_v415.z.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4396
|
+
id: import_v415.z.string().nullish(),
|
|
4342
4397
|
arguments: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).nullish(),
|
|
4343
4398
|
name: import_v415.z.string().nullish(),
|
|
4344
4399
|
server_name: import_v415.z.string().nullish(),
|
|
4345
4400
|
search_type: import_v415.z.string().nullish(),
|
|
4346
4401
|
signature: import_v415.z.string().nullish()
|
|
4347
4402
|
}).loose();
|
|
4348
|
-
const
|
|
4349
|
-
type: import_v415.z.enum(
|
|
4350
|
-
|
|
4351
|
-
"code_execution_result",
|
|
4352
|
-
"url_context_result",
|
|
4353
|
-
"file_search_result",
|
|
4354
|
-
"google_maps_result",
|
|
4355
|
-
"mcp_server_tool_result"
|
|
4356
|
-
]),
|
|
4357
|
-
call_id: import_v415.z.string(),
|
|
4403
|
+
const stepDeltaBuiltinToolResult = import_v415.z.object({
|
|
4404
|
+
type: import_v415.z.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4405
|
+
call_id: import_v415.z.string().nullish(),
|
|
4358
4406
|
result: import_v415.z.unknown().nullish(),
|
|
4359
4407
|
is_error: import_v415.z.boolean().nullish(),
|
|
4360
4408
|
name: import_v415.z.string().nullish(),
|
|
4361
4409
|
server_name: import_v415.z.string().nullish(),
|
|
4362
4410
|
signature: import_v415.z.string().nullish()
|
|
4363
4411
|
}).loose();
|
|
4364
|
-
const
|
|
4365
|
-
const
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4412
|
+
const stepDeltaUnknown = import_v415.z.object({ type: import_v415.z.string() }).loose();
|
|
4413
|
+
const stepDeltaUnion = import_v415.z.union([
|
|
4414
|
+
stepDeltaText,
|
|
4415
|
+
stepDeltaImage,
|
|
4416
|
+
stepDeltaThoughtSummary,
|
|
4417
|
+
stepDeltaThoughtSignature,
|
|
4418
|
+
stepDeltaArgumentsDelta,
|
|
4419
|
+
stepDeltaTextAnnotation,
|
|
4420
|
+
stepDeltaBuiltinToolCall,
|
|
4421
|
+
stepDeltaBuiltinToolResult,
|
|
4422
|
+
stepDeltaUnknown
|
|
4375
4423
|
]);
|
|
4376
|
-
const
|
|
4377
|
-
event_type: import_v415.z.literal("
|
|
4424
|
+
const stepDeltaEvent = import_v415.z.object({
|
|
4425
|
+
event_type: import_v415.z.literal("step.delta"),
|
|
4378
4426
|
event_id: import_v415.z.string().nullish(),
|
|
4379
4427
|
index: import_v415.z.number(),
|
|
4380
|
-
delta:
|
|
4428
|
+
delta: stepDeltaUnion
|
|
4381
4429
|
}).loose();
|
|
4382
|
-
const
|
|
4383
|
-
event_type: import_v415.z.literal("
|
|
4430
|
+
const stepStopEvent = import_v415.z.object({
|
|
4431
|
+
event_type: import_v415.z.literal("step.stop"),
|
|
4384
4432
|
event_id: import_v415.z.string().nullish(),
|
|
4385
4433
|
index: import_v415.z.number()
|
|
4386
4434
|
}).loose();
|
|
@@ -4388,10 +4436,22 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4388
4436
|
event_type: import_v415.z.literal("interaction.status_update"),
|
|
4389
4437
|
event_id: import_v415.z.string().nullish(),
|
|
4390
4438
|
interaction_id: import_v415.z.string().nullish(),
|
|
4391
|
-
status
|
|
4439
|
+
status: status.nullish()
|
|
4440
|
+
}).loose();
|
|
4441
|
+
const interactionInProgressEvent = import_v415.z.object({
|
|
4442
|
+
event_type: import_v415.z.literal("interaction.in_progress"),
|
|
4443
|
+
event_id: import_v415.z.string().nullish(),
|
|
4444
|
+
interaction_id: import_v415.z.string().nullish(),
|
|
4445
|
+
status: status.nullish()
|
|
4446
|
+
}).loose();
|
|
4447
|
+
const interactionRequiresActionEvent = import_v415.z.object({
|
|
4448
|
+
event_type: import_v415.z.literal("interaction.requires_action"),
|
|
4449
|
+
event_id: import_v415.z.string().nullish(),
|
|
4450
|
+
interaction_id: import_v415.z.string().nullish(),
|
|
4451
|
+
status: status.nullish()
|
|
4392
4452
|
}).loose();
|
|
4393
|
-
const
|
|
4394
|
-
event_type: import_v415.z.literal("interaction.
|
|
4453
|
+
const interactionCompletedEvent = import_v415.z.object({
|
|
4454
|
+
event_type: import_v415.z.literal("interaction.completed"),
|
|
4395
4455
|
event_id: import_v415.z.string().nullish(),
|
|
4396
4456
|
interaction: import_v415.z.object({
|
|
4397
4457
|
id: import_v415.z.string().nullish(),
|
|
@@ -4410,12 +4470,14 @@ var googleInteractionsEventSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
4410
4470
|
}).loose();
|
|
4411
4471
|
const unknownEvent = import_v415.z.object({ event_type: import_v415.z.string() }).loose();
|
|
4412
4472
|
return import_v415.z.union([
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4473
|
+
interactionCreatedEvent,
|
|
4474
|
+
stepStartEvent,
|
|
4475
|
+
stepDeltaEvent,
|
|
4476
|
+
stepStopEvent,
|
|
4417
4477
|
interactionStatusUpdateEvent,
|
|
4418
|
-
|
|
4478
|
+
interactionInProgressEvent,
|
|
4479
|
+
interactionRequiresActionEvent,
|
|
4480
|
+
interactionCompletedEvent,
|
|
4419
4481
|
errorEvent,
|
|
4420
4482
|
unknownEvent
|
|
4421
4483
|
]);
|
|
@@ -4445,6 +4507,55 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4445
4507
|
]).nullish(),
|
|
4446
4508
|
thinkingLevel: import_v416.z.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
4447
4509
|
thinkingSummaries: import_v416.z.enum(["auto", "none"]).nullish(),
|
|
4510
|
+
/**
|
|
4511
|
+
* Output-format entries that map directly to the API's `response_format`
|
|
4512
|
+
* array. Use this to request image, audio, or non-JSON text outputs
|
|
4513
|
+
* with full control over `mime_type`, `aspect_ratio`, and `image_size`.
|
|
4514
|
+
*
|
|
4515
|
+
* Entries are sent in order. The AI SDK call-level `responseFormat: {
|
|
4516
|
+
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
4517
|
+
* text entry automatically; entries listed here are appended.
|
|
4518
|
+
*/
|
|
4519
|
+
responseFormat: import_v416.z.array(
|
|
4520
|
+
import_v416.z.union([
|
|
4521
|
+
import_v416.z.object({
|
|
4522
|
+
type: import_v416.z.literal("text"),
|
|
4523
|
+
mimeType: import_v416.z.string().nullish(),
|
|
4524
|
+
schema: import_v416.z.unknown().nullish()
|
|
4525
|
+
}).loose(),
|
|
4526
|
+
import_v416.z.object({
|
|
4527
|
+
type: import_v416.z.literal("image"),
|
|
4528
|
+
mimeType: import_v416.z.string().nullish(),
|
|
4529
|
+
aspectRatio: import_v416.z.enum([
|
|
4530
|
+
"1:1",
|
|
4531
|
+
"2:3",
|
|
4532
|
+
"3:2",
|
|
4533
|
+
"3:4",
|
|
4534
|
+
"4:3",
|
|
4535
|
+
"4:5",
|
|
4536
|
+
"5:4",
|
|
4537
|
+
"9:16",
|
|
4538
|
+
"16:9",
|
|
4539
|
+
"21:9",
|
|
4540
|
+
"1:8",
|
|
4541
|
+
"8:1",
|
|
4542
|
+
"1:4",
|
|
4543
|
+
"4:1"
|
|
4544
|
+
]).nullish(),
|
|
4545
|
+
imageSize: import_v416.z.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
4546
|
+
}).loose(),
|
|
4547
|
+
import_v416.z.object({
|
|
4548
|
+
type: import_v416.z.literal("audio"),
|
|
4549
|
+
mimeType: import_v416.z.string().nullish()
|
|
4550
|
+
}).loose()
|
|
4551
|
+
])
|
|
4552
|
+
).nullish(),
|
|
4553
|
+
/**
|
|
4554
|
+
* @deprecated Use `responseFormat` with a `{ type: 'image', ... }`
|
|
4555
|
+
* entry instead. Retained for backwards compatibility; the SDK
|
|
4556
|
+
* translates it into a matching `response_format` image entry and
|
|
4557
|
+
* emits a warning when set.
|
|
4558
|
+
*/
|
|
4448
4559
|
imageConfig: import_v416.z.object({
|
|
4449
4560
|
aspectRatio: import_v416.z.enum([
|
|
4450
4561
|
"1:1",
|
|
@@ -4532,37 +4643,69 @@ function builtinToolNameFromResultType2(type) {
|
|
|
4532
4643
|
return type.replace(/_result$/, "");
|
|
4533
4644
|
}
|
|
4534
4645
|
function parseGoogleInteractionsOutputs({
|
|
4535
|
-
|
|
4646
|
+
steps,
|
|
4536
4647
|
generateId: generateId3,
|
|
4537
4648
|
interactionId
|
|
4538
4649
|
}) {
|
|
4539
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4650
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4540
4651
|
const content = [];
|
|
4541
4652
|
let hasFunctionCall = false;
|
|
4542
|
-
if (
|
|
4653
|
+
if (steps == null) {
|
|
4543
4654
|
return { content, hasFunctionCall };
|
|
4544
4655
|
}
|
|
4545
|
-
for (const
|
|
4546
|
-
if (
|
|
4547
|
-
const type =
|
|
4656
|
+
for (const step of steps) {
|
|
4657
|
+
if (step == null || typeof step !== "object") continue;
|
|
4658
|
+
const type = step.type;
|
|
4548
4659
|
if (typeof type !== "string") continue;
|
|
4549
4660
|
switch (type) {
|
|
4550
|
-
case "
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4661
|
+
case "user_input": {
|
|
4662
|
+
break;
|
|
4663
|
+
}
|
|
4664
|
+
case "model_output": {
|
|
4665
|
+
const blocks = (_a = step.content) != null ? _a : [];
|
|
4666
|
+
for (const block of blocks) {
|
|
4667
|
+
if (block == null || typeof block !== "object") continue;
|
|
4668
|
+
const blockType = block.type;
|
|
4669
|
+
if (blockType === "text") {
|
|
4670
|
+
const text = (_b = block.text) != null ? _b : "";
|
|
4671
|
+
const annotations = block.annotations;
|
|
4672
|
+
content.push({
|
|
4673
|
+
type: "text",
|
|
4674
|
+
text,
|
|
4675
|
+
...googleProviderMetadata({ interactionId })
|
|
4676
|
+
});
|
|
4677
|
+
const sources = annotationsToSources({ annotations, generateId: generateId3 });
|
|
4678
|
+
for (const source of sources) {
|
|
4679
|
+
content.push(source);
|
|
4680
|
+
}
|
|
4681
|
+
} else if (blockType === "image") {
|
|
4682
|
+
const image = block;
|
|
4683
|
+
if (image.data != null && image.data.length > 0) {
|
|
4684
|
+
content.push({
|
|
4685
|
+
type: "file",
|
|
4686
|
+
mediaType: (_c = image.mime_type) != null ? _c : "image/png",
|
|
4687
|
+
data: image.data,
|
|
4688
|
+
...googleProviderMetadata({ interactionId })
|
|
4689
|
+
});
|
|
4690
|
+
} else if (image.uri != null && image.uri.length > 0) {
|
|
4691
|
+
content.push({
|
|
4692
|
+
type: "file",
|
|
4693
|
+
mediaType: (_d = image.mime_type) != null ? _d : "image/png",
|
|
4694
|
+
data: "",
|
|
4695
|
+
providerMetadata: {
|
|
4696
|
+
google: {
|
|
4697
|
+
...interactionId != null ? { interactionId } : {},
|
|
4698
|
+
imageUri: image.uri
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
});
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4561
4704
|
}
|
|
4562
4705
|
break;
|
|
4563
4706
|
}
|
|
4564
4707
|
case "thought": {
|
|
4565
|
-
const thought =
|
|
4708
|
+
const thought = step;
|
|
4566
4709
|
const summary = Array.isArray(thought.summary) ? thought.summary : [];
|
|
4567
4710
|
const text = summary.filter(
|
|
4568
4711
|
(item) => (item == null ? void 0 : item.type) === "text" && typeof item.text === "string"
|
|
@@ -4577,38 +4720,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
4577
4720
|
});
|
|
4578
4721
|
break;
|
|
4579
4722
|
}
|
|
4580
|
-
case "image": {
|
|
4581
|
-
const image = block;
|
|
4582
|
-
if (image.data != null && image.data.length > 0) {
|
|
4583
|
-
content.push({
|
|
4584
|
-
type: "file",
|
|
4585
|
-
mediaType: (_b = image.mime_type) != null ? _b : "image/png",
|
|
4586
|
-
data: image.data,
|
|
4587
|
-
...googleProviderMetadata({ interactionId })
|
|
4588
|
-
});
|
|
4589
|
-
} else if (image.uri != null && image.uri.length > 0) {
|
|
4590
|
-
content.push({
|
|
4591
|
-
type: "file",
|
|
4592
|
-
mediaType: (_c = image.mime_type) != null ? _c : "image/png",
|
|
4593
|
-
data: "",
|
|
4594
|
-
providerMetadata: {
|
|
4595
|
-
google: {
|
|
4596
|
-
...interactionId != null ? { interactionId } : {},
|
|
4597
|
-
imageUri: image.uri
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
});
|
|
4601
|
-
}
|
|
4602
|
-
break;
|
|
4603
|
-
}
|
|
4604
4723
|
case "function_call": {
|
|
4605
4724
|
hasFunctionCall = true;
|
|
4606
|
-
const call =
|
|
4725
|
+
const call = step;
|
|
4607
4726
|
content.push({
|
|
4608
4727
|
type: "tool-call",
|
|
4609
4728
|
toolCallId: call.id,
|
|
4610
4729
|
toolName: call.name,
|
|
4611
|
-
input: JSON.stringify((
|
|
4730
|
+
input: JSON.stringify((_e = call.arguments) != null ? _e : {}),
|
|
4612
4731
|
...googleProviderMetadata({
|
|
4613
4732
|
signature: call.signature,
|
|
4614
4733
|
interactionId
|
|
@@ -4618,27 +4737,27 @@ function parseGoogleInteractionsOutputs({
|
|
|
4618
4737
|
}
|
|
4619
4738
|
default: {
|
|
4620
4739
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
4621
|
-
const call =
|
|
4622
|
-
const toolName = type === "mcp_server_tool_call" ? (
|
|
4623
|
-
const input = JSON.stringify((
|
|
4740
|
+
const call = step;
|
|
4741
|
+
const toolName = type === "mcp_server_tool_call" ? (_f = call.name) != null ? _f : "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
4742
|
+
const input = JSON.stringify((_g = call.arguments) != null ? _g : {});
|
|
4624
4743
|
content.push({
|
|
4625
4744
|
type: "tool-call",
|
|
4626
|
-
toolCallId: (
|
|
4745
|
+
toolCallId: (_h = call.id) != null ? _h : generateId3(),
|
|
4627
4746
|
toolName,
|
|
4628
4747
|
input,
|
|
4629
4748
|
providerExecuted: true
|
|
4630
4749
|
});
|
|
4631
4750
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
4632
|
-
const result =
|
|
4633
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
4751
|
+
const result = step;
|
|
4752
|
+
const toolName = type === "mcp_server_tool_result" ? (_i = result.name) != null ? _i : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
4634
4753
|
content.push({
|
|
4635
4754
|
type: "tool-result",
|
|
4636
|
-
toolCallId: (
|
|
4755
|
+
toolCallId: (_j = result.call_id) != null ? _j : generateId3(),
|
|
4637
4756
|
toolName,
|
|
4638
|
-
result: (
|
|
4757
|
+
result: (_k = result.result) != null ? _k : null
|
|
4639
4758
|
});
|
|
4640
4759
|
const sources = builtinToolResultToSources({
|
|
4641
|
-
block,
|
|
4760
|
+
block: step,
|
|
4642
4761
|
generateId: generateId3
|
|
4643
4762
|
});
|
|
4644
4763
|
for (const source of sources) {
|
|
@@ -5012,7 +5131,7 @@ function streamGoogleInteractionEvents({
|
|
|
5012
5131
|
if (typeof ev.event_id === "string" && ev.event_id.length > 0) {
|
|
5013
5132
|
lastEventId = ev.event_id;
|
|
5014
5133
|
}
|
|
5015
|
-
if (ev.event_type === "interaction.
|
|
5134
|
+
if (ev.event_type === "interaction.completed" || ev.event_type === "error") {
|
|
5016
5135
|
complete = true;
|
|
5017
5136
|
}
|
|
5018
5137
|
}
|
|
@@ -5093,7 +5212,7 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
5093
5212
|
controller.enqueue({ type: "raw", rawValue: response });
|
|
5094
5213
|
}
|
|
5095
5214
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5096
|
-
|
|
5215
|
+
steps: (_b = response.steps) != null ? _b : null,
|
|
5097
5216
|
generateId: generateId3,
|
|
5098
5217
|
interactionId
|
|
5099
5218
|
});
|
|
@@ -5235,7 +5354,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5235
5354
|
};
|
|
5236
5355
|
}
|
|
5237
5356
|
async getArgs(options) {
|
|
5238
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
5357
|
+
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;
|
|
5239
5358
|
const warnings = [];
|
|
5240
5359
|
const opts = await (0, import_provider_utils22.parseProviderOptions)({
|
|
5241
5360
|
provider: "google",
|
|
@@ -5260,8 +5379,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5260
5379
|
toolChoiceForBody = prepared.toolChoice;
|
|
5261
5380
|
warnings.push(...prepared.toolWarnings);
|
|
5262
5381
|
}
|
|
5263
|
-
|
|
5264
|
-
let responseFormat;
|
|
5382
|
+
const responseFormatEntries = [];
|
|
5265
5383
|
if (((_a = options.responseFormat) == null ? void 0 : _a.type) === "json") {
|
|
5266
5384
|
if (isAgent) {
|
|
5267
5385
|
warnings.push({
|
|
@@ -5269,9 +5387,40 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5269
5387
|
message: "google.interactions: structured output (responseFormat) is not supported when an agent is set; responseFormat will be ignored."
|
|
5270
5388
|
});
|
|
5271
5389
|
} else {
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5390
|
+
const entry = {
|
|
5391
|
+
type: "text",
|
|
5392
|
+
mime_type: "application/json",
|
|
5393
|
+
...options.responseFormat.schema != null ? { schema: options.responseFormat.schema } : {}
|
|
5394
|
+
};
|
|
5395
|
+
responseFormatEntries.push(entry);
|
|
5396
|
+
}
|
|
5397
|
+
}
|
|
5398
|
+
if ((opts == null ? void 0 : opts.responseFormat) != null) {
|
|
5399
|
+
for (const entry of opts.responseFormat) {
|
|
5400
|
+
if (entry.type === "text") {
|
|
5401
|
+
responseFormatEntries.push(
|
|
5402
|
+
pruneUndefined({
|
|
5403
|
+
type: "text",
|
|
5404
|
+
mime_type: (_b = entry.mimeType) != null ? _b : void 0,
|
|
5405
|
+
schema: (_c = entry.schema) != null ? _c : void 0
|
|
5406
|
+
})
|
|
5407
|
+
);
|
|
5408
|
+
} else if (entry.type === "image") {
|
|
5409
|
+
responseFormatEntries.push(
|
|
5410
|
+
pruneUndefined({
|
|
5411
|
+
type: "image",
|
|
5412
|
+
mime_type: (_d = entry.mimeType) != null ? _d : void 0,
|
|
5413
|
+
aspect_ratio: (_e = entry.aspectRatio) != null ? _e : void 0,
|
|
5414
|
+
image_size: (_f = entry.imageSize) != null ? _f : void 0
|
|
5415
|
+
})
|
|
5416
|
+
);
|
|
5417
|
+
} else if (entry.type === "audio") {
|
|
5418
|
+
responseFormatEntries.push(
|
|
5419
|
+
pruneUndefined({
|
|
5420
|
+
type: "audio",
|
|
5421
|
+
mime_type: (_g = entry.mimeType) != null ? _g : void 0
|
|
5422
|
+
})
|
|
5423
|
+
);
|
|
5275
5424
|
}
|
|
5276
5425
|
}
|
|
5277
5426
|
}
|
|
@@ -5281,13 +5430,13 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5281
5430
|
warnings: convWarnings
|
|
5282
5431
|
} = convertToGoogleInteractionsInput({
|
|
5283
5432
|
prompt: options.prompt,
|
|
5284
|
-
previousInteractionId: (
|
|
5285
|
-
store: (
|
|
5286
|
-
mediaResolution: (
|
|
5433
|
+
previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
|
|
5434
|
+
store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
|
|
5435
|
+
mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
|
|
5287
5436
|
});
|
|
5288
5437
|
warnings.push(...convWarnings);
|
|
5289
5438
|
let systemInstruction = convertedSystemInstruction;
|
|
5290
|
-
const optionSystemInstruction = (
|
|
5439
|
+
const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
|
|
5291
5440
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
5292
5441
|
warnings.push({
|
|
5293
5442
|
type: "other",
|
|
@@ -5321,19 +5470,32 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5321
5470
|
generationConfig = void 0;
|
|
5322
5471
|
} else {
|
|
5323
5472
|
generationConfig = pruneUndefined({
|
|
5324
|
-
temperature: (
|
|
5325
|
-
top_p: (
|
|
5326
|
-
seed: (
|
|
5473
|
+
temperature: (_l = options.temperature) != null ? _l : void 0,
|
|
5474
|
+
top_p: (_m = options.topP) != null ? _m : void 0,
|
|
5475
|
+
seed: (_n = options.seed) != null ? _n : void 0,
|
|
5327
5476
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
5328
|
-
max_output_tokens: (
|
|
5329
|
-
thinking_level: (
|
|
5330
|
-
thinking_summaries: (
|
|
5331
|
-
image_config: (opts == null ? void 0 : opts.imageConfig) != null ? pruneUndefined({
|
|
5332
|
-
aspect_ratio: (_l = opts.imageConfig.aspectRatio) != null ? _l : void 0,
|
|
5333
|
-
image_size: (_m = opts.imageConfig.imageSize) != null ? _m : void 0
|
|
5334
|
-
}) : void 0,
|
|
5477
|
+
max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
|
|
5478
|
+
thinking_level: (_p = opts == null ? void 0 : opts.thinkingLevel) != null ? _p : void 0,
|
|
5479
|
+
thinking_summaries: (_q = opts == null ? void 0 : opts.thinkingSummaries) != null ? _q : void 0,
|
|
5335
5480
|
tool_choice: toolChoiceForBody
|
|
5336
5481
|
});
|
|
5482
|
+
if ((opts == null ? void 0 : opts.imageConfig) != null) {
|
|
5483
|
+
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
5484
|
+
(entry) => entry.type === "image"
|
|
5485
|
+
);
|
|
5486
|
+
warnings.push({
|
|
5487
|
+
type: "other",
|
|
5488
|
+
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.'
|
|
5489
|
+
});
|
|
5490
|
+
if (!alreadyHasImageEntry) {
|
|
5491
|
+
responseFormatEntries.push({
|
|
5492
|
+
type: "image",
|
|
5493
|
+
mime_type: "image/png",
|
|
5494
|
+
...opts.imageConfig.aspectRatio != null ? { aspect_ratio: opts.imageConfig.aspectRatio } : {},
|
|
5495
|
+
...opts.imageConfig.imageSize != null ? { image_size: opts.imageConfig.imageSize } : {}
|
|
5496
|
+
});
|
|
5497
|
+
}
|
|
5498
|
+
}
|
|
5337
5499
|
}
|
|
5338
5500
|
let agentConfig;
|
|
5339
5501
|
if (isAgent && (opts == null ? void 0 : opts.agentConfig) != null) {
|
|
@@ -5341,9 +5503,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5341
5503
|
if (ac.type === "deep-research") {
|
|
5342
5504
|
agentConfig = pruneUndefined({
|
|
5343
5505
|
type: "deep-research",
|
|
5344
|
-
thinking_summaries: (
|
|
5345
|
-
visualization: (
|
|
5346
|
-
collaborative_planning: (
|
|
5506
|
+
thinking_summaries: (_r = ac.thinkingSummaries) != null ? _r : void 0,
|
|
5507
|
+
visualization: (_s = ac.visualization) != null ? _s : void 0,
|
|
5508
|
+
collaborative_planning: (_t = ac.collaborativePlanning) != null ? _t : void 0
|
|
5347
5509
|
});
|
|
5348
5510
|
} else if (ac.type === "dynamic") {
|
|
5349
5511
|
agentConfig = { type: "dynamic" };
|
|
@@ -5354,12 +5516,11 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5354
5516
|
input,
|
|
5355
5517
|
system_instruction: systemInstruction,
|
|
5356
5518
|
tools: toolsForBody,
|
|
5357
|
-
response_format:
|
|
5358
|
-
response_mime_type: responseMimeType,
|
|
5519
|
+
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5359
5520
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5360
|
-
previous_interaction_id: (
|
|
5361
|
-
service_tier: (
|
|
5362
|
-
store: (
|
|
5521
|
+
previous_interaction_id: (_u = opts == null ? void 0 : opts.previousInteractionId) != null ? _u : void 0,
|
|
5522
|
+
service_tier: (_v = opts == null ? void 0 : opts.serviceTier) != null ? _v : void 0,
|
|
5523
|
+
store: (_w = opts == null ? void 0 : opts.store) != null ? _w : void 0,
|
|
5363
5524
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5364
5525
|
agent_config: agentConfig,
|
|
5365
5526
|
...isAgent ? { background: true } : {}
|
|
@@ -5368,7 +5529,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5368
5529
|
args,
|
|
5369
5530
|
warnings,
|
|
5370
5531
|
isAgent,
|
|
5371
|
-
pollingTimeoutMs: (
|
|
5532
|
+
pollingTimeoutMs: (_x = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _x : void 0
|
|
5372
5533
|
};
|
|
5373
5534
|
}
|
|
5374
5535
|
async doGenerate(options) {
|
|
@@ -5376,6 +5537,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5376
5537
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
5377
5538
|
const url = `${this.config.baseURL}/interactions`;
|
|
5378
5539
|
const mergedHeaders = (0, import_provider_utils22.combineHeaders)(
|
|
5540
|
+
INTERACTIONS_API_REVISION_HEADER,
|
|
5379
5541
|
this.config.headers ? await (0, import_provider_utils22.resolve)(this.config.headers) : void 0,
|
|
5380
5542
|
options.headers
|
|
5381
5543
|
);
|
|
@@ -5410,7 +5572,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5410
5572
|
}
|
|
5411
5573
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
5412
5574
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5413
|
-
|
|
5575
|
+
steps: (_b = response.steps) != null ? _b : null,
|
|
5414
5576
|
generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils22.generateId,
|
|
5415
5577
|
interactionId
|
|
5416
5578
|
});
|
|
@@ -5456,6 +5618,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5456
5618
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
5457
5619
|
const url = `${this.config.baseURL}/interactions`;
|
|
5458
5620
|
const mergedHeaders = (0, import_provider_utils22.combineHeaders)(
|
|
5621
|
+
INTERACTIONS_API_REVISION_HEADER,
|
|
5459
5622
|
this.config.headers ? await (0, import_provider_utils22.resolve)(this.config.headers) : void 0,
|
|
5460
5623
|
options.headers
|
|
5461
5624
|
);
|
|
@@ -5575,6 +5738,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5575
5738
|
};
|
|
5576
5739
|
}
|
|
5577
5740
|
};
|
|
5741
|
+
var INTERACTIONS_API_REVISION_HEADER = {
|
|
5742
|
+
"Api-Revision": "2026-05-20"
|
|
5743
|
+
};
|
|
5578
5744
|
function pruneUndefined(obj) {
|
|
5579
5745
|
const result = {};
|
|
5580
5746
|
for (const [key, value] of Object.entries(obj)) {
|