@ai-sdk/google 3.0.74 → 3.0.77
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 +19 -0
- package/dist/index.d.mts +55 -12
- package/dist/index.d.ts +55 -12
- package/dist/index.js +687 -375
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +687 -375
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -2
- package/dist/internal/index.d.ts +1 -2
- package/dist/internal/index.js +97 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +97 -59
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +73 -16
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +104 -56
- package/src/google-generative-ai-options.ts +24 -8
- package/src/google-provider.ts +9 -4
- 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-agent.ts +6 -7
- package/src/interactions/google-interactions-api.ts +179 -115
- package/src/interactions/google-interactions-language-model-options.ts +126 -0
- package/src/interactions/google-interactions-language-model.ts +173 -60
- package/src/interactions/google-interactions-prompt.ts +239 -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 +2 -2
- 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.77" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -860,17 +860,32 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
860
860
|
*/
|
|
861
861
|
streamFunctionCallArguments: z4.boolean().optional(),
|
|
862
862
|
/**
|
|
863
|
-
* Optional. The service tier to use for the request.
|
|
863
|
+
* Optional. The service tier to use for the request. Sent as the
|
|
864
|
+
* `serviceTier` body field. Gemini API only.
|
|
864
865
|
*/
|
|
865
|
-
serviceTier: z4.enum(["standard", "flex", "priority"]).optional()
|
|
866
|
+
serviceTier: z4.enum(["standard", "flex", "priority"]).optional(),
|
|
867
|
+
/**
|
|
868
|
+
* Optional. Vertex AI only. Sent as the
|
|
869
|
+
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
870
|
+
* shared (PayGo) tier. With Provisioned Throughput allocated and
|
|
871
|
+
* `requestType` unset, the request falls back to this tier only if
|
|
872
|
+
* PT capacity is exhausted.
|
|
873
|
+
*
|
|
874
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
875
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
876
|
+
*/
|
|
877
|
+
sharedRequestType: z4.enum(["priority", "flex", "standard"]).optional(),
|
|
878
|
+
/**
|
|
879
|
+
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
880
|
+
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
881
|
+
* to bypass Provisioned Throughput entirely.
|
|
882
|
+
*
|
|
883
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
884
|
+
*/
|
|
885
|
+
requestType: z4.enum(["shared"]).optional()
|
|
866
886
|
})
|
|
867
887
|
)
|
|
868
888
|
);
|
|
869
|
-
var VertexServiceTierMap = {
|
|
870
|
-
standard: "SERVICE_TIER_STANDARD",
|
|
871
|
-
flex: "SERVICE_TIER_FLEX",
|
|
872
|
-
priority: "SERVICE_TIER_PRIORITY"
|
|
873
|
-
};
|
|
874
889
|
|
|
875
890
|
// src/google-prepare-tools.ts
|
|
876
891
|
import {
|
|
@@ -1437,10 +1452,27 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1437
1452
|
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
1438
1453
|
});
|
|
1439
1454
|
}
|
|
1440
|
-
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1441
1455
|
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
1442
|
-
|
|
1456
|
+
warnings.push({
|
|
1457
|
+
type: "other",
|
|
1458
|
+
message: "'serviceTier' is a Gemini API option and is not supported on Vertex AI. Use 'sharedRequestType' (and optionally 'requestType') instead. See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo"
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
|
|
1462
|
+
warnings.push({
|
|
1463
|
+
type: "other",
|
|
1464
|
+
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
|
|
1465
|
+
});
|
|
1443
1466
|
}
|
|
1467
|
+
const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
|
|
1468
|
+
...googleOptions.sharedRequestType && {
|
|
1469
|
+
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
1470
|
+
},
|
|
1471
|
+
...googleOptions.requestType && {
|
|
1472
|
+
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
1473
|
+
}
|
|
1474
|
+
} : void 0;
|
|
1475
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1444
1476
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1445
1477
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1446
1478
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
@@ -1512,18 +1544,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1512
1544
|
toolConfig,
|
|
1513
1545
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1514
1546
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1515
|
-
serviceTier:
|
|
1547
|
+
serviceTier: bodyServiceTier
|
|
1516
1548
|
},
|
|
1517
1549
|
warnings: [...warnings, ...toolWarnings],
|
|
1518
|
-
providerOptionsName
|
|
1550
|
+
providerOptionsName,
|
|
1551
|
+
extraHeaders: vertexPaygoHeaders
|
|
1519
1552
|
};
|
|
1520
1553
|
}
|
|
1521
1554
|
async doGenerate(options) {
|
|
1522
1555
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1523
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1556
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1524
1557
|
const mergedHeaders = combineHeaders2(
|
|
1525
1558
|
await resolve2(this.config.headers),
|
|
1526
|
-
options.headers
|
|
1559
|
+
options.headers,
|
|
1560
|
+
extraHeaders
|
|
1527
1561
|
);
|
|
1528
1562
|
const {
|
|
1529
1563
|
responseHeaders,
|
|
@@ -1688,7 +1722,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1688
1722
|
safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
|
|
1689
1723
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1690
1724
|
finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
|
|
1691
|
-
serviceTier: (_r =
|
|
1725
|
+
serviceTier: (_r = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _r : null
|
|
1692
1726
|
}
|
|
1693
1727
|
},
|
|
1694
1728
|
request: { body: args },
|
|
@@ -1700,13 +1734,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1700
1734
|
};
|
|
1701
1735
|
}
|
|
1702
1736
|
async doStream(options) {
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
{ isStreaming: true }
|
|
1706
|
-
);
|
|
1737
|
+
var _a;
|
|
1738
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1707
1739
|
const headers = combineHeaders2(
|
|
1708
1740
|
await resolve2(this.config.headers),
|
|
1709
|
-
options.headers
|
|
1741
|
+
options.headers,
|
|
1742
|
+
extraHeaders
|
|
1710
1743
|
);
|
|
1711
1744
|
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
1712
1745
|
url: `${this.config.baseURL}/${getModelPath(
|
|
@@ -1727,7 +1760,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1727
1760
|
let providerMetadata = void 0;
|
|
1728
1761
|
let lastGroundingMetadata = null;
|
|
1729
1762
|
let lastUrlContextMetadata = null;
|
|
1730
|
-
|
|
1763
|
+
const serviceTier = (_a = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _a : null;
|
|
1731
1764
|
const generateId3 = this.config.generateId;
|
|
1732
1765
|
let hasToolCalls = false;
|
|
1733
1766
|
let currentTextBlockId = null;
|
|
@@ -1737,6 +1770,34 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1737
1770
|
let lastCodeExecutionToolCallId;
|
|
1738
1771
|
let lastServerToolCallId;
|
|
1739
1772
|
const activeStreamingToolCalls = [];
|
|
1773
|
+
const finishActiveStreamingToolCall = (controller) => {
|
|
1774
|
+
const active = activeStreamingToolCalls.pop();
|
|
1775
|
+
if (active == null) {
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1779
|
+
if (closingDelta.length > 0) {
|
|
1780
|
+
controller.enqueue({
|
|
1781
|
+
type: "tool-input-delta",
|
|
1782
|
+
id: active.toolCallId,
|
|
1783
|
+
delta: closingDelta,
|
|
1784
|
+
providerMetadata: active.providerMetadata
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
controller.enqueue({
|
|
1788
|
+
type: "tool-input-end",
|
|
1789
|
+
id: active.toolCallId,
|
|
1790
|
+
providerMetadata: active.providerMetadata
|
|
1791
|
+
});
|
|
1792
|
+
controller.enqueue({
|
|
1793
|
+
type: "tool-call",
|
|
1794
|
+
toolCallId: active.toolCallId,
|
|
1795
|
+
toolName: active.toolName,
|
|
1796
|
+
input: finalJSON,
|
|
1797
|
+
providerMetadata: active.providerMetadata
|
|
1798
|
+
});
|
|
1799
|
+
hasToolCalls = true;
|
|
1800
|
+
};
|
|
1740
1801
|
return {
|
|
1741
1802
|
stream: response.pipeThrough(
|
|
1742
1803
|
new TransformStream({
|
|
@@ -1744,7 +1805,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1744
1805
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1745
1806
|
},
|
|
1746
1807
|
transform(chunk, controller) {
|
|
1747
|
-
var
|
|
1808
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1748
1809
|
if (options.includeRawChunks) {
|
|
1749
1810
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1750
1811
|
}
|
|
@@ -1757,10 +1818,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1757
1818
|
if (usageMetadata != null) {
|
|
1758
1819
|
usage = usageMetadata;
|
|
1759
1820
|
}
|
|
1760
|
-
|
|
1761
|
-
serviceTier = value.serviceTier;
|
|
1762
|
-
}
|
|
1763
|
-
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1821
|
+
const candidate = (_a2 = value.candidates) == null ? void 0 : _a2[0];
|
|
1764
1822
|
if (candidate == null) {
|
|
1765
1823
|
return;
|
|
1766
1824
|
}
|
|
@@ -1949,7 +2007,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1949
2007
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1950
2008
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
1951
2009
|
if (isStreamingChunk) {
|
|
1952
|
-
if (part.functionCall.name != null
|
|
2010
|
+
if (part.functionCall.name != null) {
|
|
1953
2011
|
const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
|
|
1954
2012
|
const accumulator = new GoogleJSONAccumulator();
|
|
1955
2013
|
activeStreamingToolCalls.push({
|
|
@@ -1965,9 +2023,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1965
2023
|
providerMetadata: providerMeta
|
|
1966
2024
|
});
|
|
1967
2025
|
if (part.functionCall.partialArgs != null) {
|
|
1968
|
-
const
|
|
1969
|
-
|
|
1970
|
-
);
|
|
2026
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2027
|
+
const { textDelta } = accumulator.processPartialArgs(partialArgs);
|
|
1971
2028
|
if (textDelta.length > 0) {
|
|
1972
2029
|
controller.enqueue({
|
|
1973
2030
|
type: "tool-input-delta",
|
|
@@ -1976,12 +2033,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1976
2033
|
providerMetadata: providerMeta
|
|
1977
2034
|
});
|
|
1978
2035
|
}
|
|
2036
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2037
|
+
finishActiveStreamingToolCall(controller);
|
|
2038
|
+
}
|
|
1979
2039
|
}
|
|
1980
2040
|
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
1981
2041
|
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
);
|
|
2042
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2043
|
+
const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
|
|
1985
2044
|
if (textDelta.length > 0) {
|
|
1986
2045
|
controller.enqueue({
|
|
1987
2046
|
type: "tool-input-delta",
|
|
@@ -1990,31 +2049,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1990
2049
|
providerMetadata: providerMeta
|
|
1991
2050
|
});
|
|
1992
2051
|
}
|
|
2052
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2053
|
+
finishActiveStreamingToolCall(controller);
|
|
2054
|
+
}
|
|
1993
2055
|
}
|
|
1994
2056
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
1995
|
-
|
|
1996
|
-
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1997
|
-
if (closingDelta.length > 0) {
|
|
1998
|
-
controller.enqueue({
|
|
1999
|
-
type: "tool-input-delta",
|
|
2000
|
-
id: active.toolCallId,
|
|
2001
|
-
delta: closingDelta,
|
|
2002
|
-
providerMetadata: active.providerMetadata
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
controller.enqueue({
|
|
2006
|
-
type: "tool-input-end",
|
|
2007
|
-
id: active.toolCallId,
|
|
2008
|
-
providerMetadata: active.providerMetadata
|
|
2009
|
-
});
|
|
2010
|
-
controller.enqueue({
|
|
2011
|
-
type: "tool-call",
|
|
2012
|
-
toolCallId: active.toolCallId,
|
|
2013
|
-
toolName: active.toolName,
|
|
2014
|
-
input: finalJSON,
|
|
2015
|
-
providerMetadata: active.providerMetadata
|
|
2016
|
-
});
|
|
2017
|
-
hasToolCalls = true;
|
|
2057
|
+
finishActiveStreamingToolCall(controller);
|
|
2018
2058
|
} else if (isCompleteCall) {
|
|
2019
2059
|
const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
|
|
2020
2060
|
const toolName = part.functionCall.name;
|
|
@@ -2373,8 +2413,7 @@ var responseSchema = lazySchema5(
|
|
|
2373
2413
|
promptFeedback: z5.object({
|
|
2374
2414
|
blockReason: z5.string().nullish(),
|
|
2375
2415
|
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
|
2376
|
-
}).nullish()
|
|
2377
|
-
serviceTier: z5.string().nullish()
|
|
2416
|
+
}).nullish()
|
|
2378
2417
|
})
|
|
2379
2418
|
)
|
|
2380
2419
|
);
|
|
@@ -2395,8 +2434,7 @@ var chunkSchema = lazySchema5(
|
|
|
2395
2434
|
promptFeedback: z5.object({
|
|
2396
2435
|
blockReason: z5.string().nullish(),
|
|
2397
2436
|
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
|
2398
|
-
}).nullish()
|
|
2399
|
-
serviceTier: z5.string().nullish()
|
|
2437
|
+
}).nullish()
|
|
2400
2438
|
})
|
|
2401
2439
|
)
|
|
2402
2440
|
);
|
|
@@ -3187,7 +3225,7 @@ function annotationToSource({
|
|
|
3187
3225
|
}
|
|
3188
3226
|
case "file_citation": {
|
|
3189
3227
|
const a = annotation;
|
|
3190
|
-
const uri = (_b = (_a = a.
|
|
3228
|
+
const uri = (_b = (_a = a.url) != null ? _a : a.document_uri) != null ? _b : a.file_name;
|
|
3191
3229
|
if (uri == null || uri.length === 0) return void 0;
|
|
3192
3230
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3193
3231
|
return {
|
|
@@ -3281,7 +3319,7 @@ function builtinToolResultToSources({
|
|
|
3281
3319
|
for (const raw of result) {
|
|
3282
3320
|
if (raw == null || typeof raw !== "object") continue;
|
|
3283
3321
|
const entry = raw;
|
|
3284
|
-
const uri = (_g = (_f = entry.
|
|
3322
|
+
const uri = (_g = (_f = entry.url) != null ? _f : entry.document_uri) != null ? _g : entry.file_name;
|
|
3285
3323
|
if (uri == null || uri.length === 0) continue;
|
|
3286
3324
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3287
3325
|
sources.push({
|
|
@@ -3397,7 +3435,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3397
3435
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3398
3436
|
},
|
|
3399
3437
|
transform(chunk, controller) {
|
|
3400
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3438
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3401
3439
|
if (includeRawChunks) {
|
|
3402
3440
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3403
3441
|
}
|
|
@@ -3409,7 +3447,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3409
3447
|
const value = chunk.value;
|
|
3410
3448
|
const eventType = value.event_type;
|
|
3411
3449
|
switch (eventType) {
|
|
3412
|
-
case "interaction.
|
|
3450
|
+
case "interaction.created": {
|
|
3413
3451
|
const event = value;
|
|
3414
3452
|
const interaction = event.interaction;
|
|
3415
3453
|
interactionId = (interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0 ? interaction.id : void 0;
|
|
@@ -3429,91 +3467,106 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3429
3467
|
});
|
|
3430
3468
|
break;
|
|
3431
3469
|
}
|
|
3432
|
-
case "
|
|
3470
|
+
case "step.start": {
|
|
3433
3471
|
const event = value;
|
|
3434
|
-
const
|
|
3472
|
+
const step = event.step;
|
|
3435
3473
|
const index = event.index;
|
|
3436
3474
|
const blockId = `${interactionId != null ? interactionId : "interaction"}:${index}`;
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3475
|
+
const stepType = step == null ? void 0 : step.type;
|
|
3476
|
+
if (stepType === "model_output") {
|
|
3477
|
+
const initial = (_a = step == null ? void 0 : step.content) == null ? void 0 : _a[0];
|
|
3478
|
+
if ((initial == null ? void 0 : initial.type) === "text") {
|
|
3479
|
+
openBlocks.set(index, {
|
|
3480
|
+
kind: "text",
|
|
3481
|
+
id: blockId,
|
|
3482
|
+
emittedSourceKeys: /* @__PURE__ */ new Set()
|
|
3483
|
+
});
|
|
3484
|
+
controller.enqueue({ type: "text-start", id: blockId });
|
|
3485
|
+
const initialSources = annotationsToSources({
|
|
3486
|
+
annotations: initial.annotations,
|
|
3487
|
+
generateId: generateId3
|
|
3488
|
+
});
|
|
3489
|
+
for (const source of initialSources) {
|
|
3490
|
+
const key = sourceKey(source);
|
|
3491
|
+
if (emittedSourceKeys.has(key)) continue;
|
|
3492
|
+
emittedSourceKeys.add(key);
|
|
3493
|
+
controller.enqueue(source);
|
|
3494
|
+
}
|
|
3495
|
+
} else if ((initial == null ? void 0 : initial.type) === "image") {
|
|
3496
|
+
openBlocks.set(index, {
|
|
3497
|
+
kind: "image",
|
|
3498
|
+
id: blockId,
|
|
3499
|
+
...initial.data != null ? { data: initial.data } : {},
|
|
3500
|
+
...initial.mime_type != null ? { mimeType: initial.mime_type } : {},
|
|
3501
|
+
...initial.uri != null ? { uri: initial.uri } : {}
|
|
3502
|
+
});
|
|
3503
|
+
} else {
|
|
3504
|
+
openBlocks.set(index, {
|
|
3505
|
+
kind: "pending_model_output",
|
|
3506
|
+
id: blockId
|
|
3507
|
+
});
|
|
3453
3508
|
}
|
|
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;
|
|
3509
|
+
} else if (stepType === "thought") {
|
|
3510
|
+
const signature = step == null ? void 0 : step.signature;
|
|
3465
3511
|
openBlocks.set(index, {
|
|
3466
3512
|
kind: "reasoning",
|
|
3467
3513
|
id: blockId,
|
|
3468
3514
|
...signature != null ? { signature } : {}
|
|
3469
3515
|
});
|
|
3470
3516
|
controller.enqueue({ type: "reasoning-start", id: blockId });
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3517
|
+
if (Array.isArray(step == null ? void 0 : step.summary)) {
|
|
3518
|
+
for (const item of step.summary) {
|
|
3519
|
+
if ((item == null ? void 0 : item.type) === "text" && typeof item.text === "string") {
|
|
3520
|
+
controller.enqueue({
|
|
3521
|
+
type: "reasoning-delta",
|
|
3522
|
+
id: blockId,
|
|
3523
|
+
delta: item.text
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
} else if (stepType === "function_call") {
|
|
3529
|
+
const toolCallId = (_b = step == null ? void 0 : step.id) != null ? _b : blockId;
|
|
3530
|
+
const toolName = (_c = step == null ? void 0 : step.name) != null ? _c : "unknown";
|
|
3474
3531
|
hasFunctionCall = true;
|
|
3475
3532
|
const state = {
|
|
3476
3533
|
kind: "function_call",
|
|
3477
3534
|
id: blockId,
|
|
3478
3535
|
toolCallId,
|
|
3479
|
-
toolName
|
|
3480
|
-
|
|
3481
|
-
...
|
|
3482
|
-
startEmitted: false
|
|
3536
|
+
toolName,
|
|
3537
|
+
argumentsAccum: "",
|
|
3538
|
+
...(step == null ? void 0 : step.signature) != null ? { signature: step.signature } : {}
|
|
3483
3539
|
};
|
|
3484
3540
|
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;
|
|
3541
|
+
controller.enqueue({
|
|
3542
|
+
type: "tool-input-start",
|
|
3543
|
+
id: toolCallId,
|
|
3544
|
+
toolName
|
|
3545
|
+
});
|
|
3546
|
+
} else if (stepType != null && BUILTIN_TOOL_CALL_TYPES.has(stepType)) {
|
|
3547
|
+
const toolName = stepType === "mcp_server_tool_call" ? (_d = step == null ? void 0 : step.name) != null ? _d : "mcp_server_tool" : builtinToolNameFromCallType(stepType);
|
|
3548
|
+
const toolCallId = (_e = step == null ? void 0 : step.id) != null ? _e : blockId;
|
|
3496
3549
|
const state = {
|
|
3497
3550
|
kind: "builtin_tool_call",
|
|
3498
3551
|
id: blockId,
|
|
3499
|
-
blockType:
|
|
3552
|
+
blockType: stepType,
|
|
3500
3553
|
toolCallId,
|
|
3501
3554
|
toolName,
|
|
3502
|
-
arguments: (
|
|
3555
|
+
arguments: (_f = step == null ? void 0 : step.arguments) != null ? _f : {},
|
|
3503
3556
|
callEmitted: false
|
|
3504
3557
|
};
|
|
3505
3558
|
openBlocks.set(index, state);
|
|
3506
|
-
} else if (
|
|
3507
|
-
const toolName =
|
|
3508
|
-
const callId = (
|
|
3559
|
+
} else if (stepType != null && BUILTIN_TOOL_RESULT_TYPES.has(stepType)) {
|
|
3560
|
+
const toolName = stepType === "mcp_server_tool_result" ? (_g = step == null ? void 0 : step.name) != null ? _g : "mcp_server_tool" : builtinToolNameFromResultType(stepType);
|
|
3561
|
+
const callId = (_h = step == null ? void 0 : step.call_id) != null ? _h : blockId;
|
|
3509
3562
|
const state = {
|
|
3510
3563
|
kind: "builtin_tool_result",
|
|
3511
3564
|
id: blockId,
|
|
3512
|
-
blockType:
|
|
3565
|
+
blockType: stepType,
|
|
3513
3566
|
callId,
|
|
3514
3567
|
toolName,
|
|
3515
|
-
result: (
|
|
3516
|
-
...
|
|
3568
|
+
result: (_i = step == null ? void 0 : step.result) != null ? _i : null,
|
|
3569
|
+
...(step == null ? void 0 : step.is_error) != null ? { isError: step.is_error } : {},
|
|
3517
3570
|
resultEmitted: false
|
|
3518
3571
|
};
|
|
3519
3572
|
openBlocks.set(index, state);
|
|
@@ -3522,13 +3575,58 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3522
3575
|
}
|
|
3523
3576
|
break;
|
|
3524
3577
|
}
|
|
3525
|
-
case "
|
|
3578
|
+
case "step.delta": {
|
|
3526
3579
|
const event = value;
|
|
3527
|
-
|
|
3580
|
+
let open = openBlocks.get(event.index);
|
|
3528
3581
|
if (open == null) break;
|
|
3582
|
+
const dtype = (_j = event.delta) == null ? void 0 : _j.type;
|
|
3583
|
+
if (open.kind === "pending_model_output") {
|
|
3584
|
+
if (dtype === "text" || dtype === "text_annotation" || dtype === "text_annotation_delta") {
|
|
3585
|
+
const promoted = {
|
|
3586
|
+
kind: "text",
|
|
3587
|
+
id: open.id,
|
|
3588
|
+
emittedSourceKeys: /* @__PURE__ */ new Set()
|
|
3589
|
+
};
|
|
3590
|
+
openBlocks.set(event.index, promoted);
|
|
3591
|
+
open = promoted;
|
|
3592
|
+
controller.enqueue({ type: "text-start", id: promoted.id });
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
if (dtype === "image" && (open.kind === "pending_model_output" || open.kind === "text" || open.kind === "image")) {
|
|
3596
|
+
const img = event.delta;
|
|
3597
|
+
const google2 = {};
|
|
3598
|
+
if (interactionId != null) google2.interactionId = interactionId;
|
|
3599
|
+
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
3600
|
+
if ((img == null ? void 0 : img.data) != null && img.data.length > 0) {
|
|
3601
|
+
controller.enqueue({
|
|
3602
|
+
type: "file",
|
|
3603
|
+
mediaType: (_k = img.mime_type) != null ? _k : "image/png",
|
|
3604
|
+
data: img.data,
|
|
3605
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3606
|
+
});
|
|
3607
|
+
} else if ((img == null ? void 0 : img.uri) != null && img.uri.length > 0) {
|
|
3608
|
+
const uriProviderMetadata = {
|
|
3609
|
+
google: {
|
|
3610
|
+
...interactionId != null ? { interactionId } : {},
|
|
3611
|
+
imageUri: img.uri
|
|
3612
|
+
}
|
|
3613
|
+
};
|
|
3614
|
+
controller.enqueue({
|
|
3615
|
+
type: "file",
|
|
3616
|
+
mediaType: (_l = img.mime_type) != null ? _l : "image/png",
|
|
3617
|
+
data: "",
|
|
3618
|
+
providerMetadata: uriProviderMetadata
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
if (open.kind === "image") {
|
|
3622
|
+
open.data = void 0;
|
|
3623
|
+
open.uri = void 0;
|
|
3624
|
+
}
|
|
3625
|
+
break;
|
|
3626
|
+
}
|
|
3529
3627
|
const delta = event.delta;
|
|
3530
3628
|
if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3531
|
-
const text = (
|
|
3629
|
+
const text = (_m = delta.text) != null ? _m : "";
|
|
3532
3630
|
if (text.length > 0) {
|
|
3533
3631
|
controller.enqueue({
|
|
3534
3632
|
type: "text-delta",
|
|
@@ -3536,7 +3634,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3536
3634
|
delta: text
|
|
3537
3635
|
});
|
|
3538
3636
|
}
|
|
3539
|
-
} else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text_annotation") {
|
|
3637
|
+
} else if (open.kind === "text" && ((delta == null ? void 0 : delta.type) === "text_annotation" || (delta == null ? void 0 : delta.type) === "text_annotation_delta")) {
|
|
3540
3638
|
const sources = annotationsToSources({
|
|
3541
3639
|
annotations: delta.annotations,
|
|
3542
3640
|
generateId: generateId3
|
|
@@ -3568,31 +3666,28 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3568
3666
|
open.signature = signature;
|
|
3569
3667
|
}
|
|
3570
3668
|
}
|
|
3571
|
-
} else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "
|
|
3669
|
+
} else if (open.kind === "function_call" && (delta == null ? void 0 : delta.type) === "arguments_delta") {
|
|
3670
|
+
const slice = typeof delta.arguments === "string" ? delta.arguments : "";
|
|
3671
|
+
if (slice.length > 0) {
|
|
3672
|
+
open.argumentsAccum += slice;
|
|
3673
|
+
controller.enqueue({
|
|
3674
|
+
type: "tool-input-delta",
|
|
3675
|
+
id: open.toolCallId,
|
|
3676
|
+
delta: slice
|
|
3677
|
+
});
|
|
3678
|
+
}
|
|
3572
3679
|
if (delta.id != null) {
|
|
3573
3680
|
open.toolCallId = delta.id;
|
|
3574
3681
|
}
|
|
3575
|
-
if (delta.name != null) {
|
|
3576
|
-
open.toolName = delta.name;
|
|
3577
|
-
}
|
|
3578
|
-
if (delta.arguments != null) {
|
|
3579
|
-
open.arguments = delta.arguments;
|
|
3580
|
-
}
|
|
3581
3682
|
if (delta.signature != null) {
|
|
3582
3683
|
open.signature = delta.signature;
|
|
3583
3684
|
}
|
|
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
3685
|
hasFunctionCall = true;
|
|
3593
3686
|
} else if (open.kind === "builtin_tool_call" && (delta == null ? void 0 : delta.type) === open.blockType) {
|
|
3594
3687
|
if (delta.id != null) open.toolCallId = delta.id;
|
|
3595
|
-
if (delta.arguments != null
|
|
3688
|
+
if (delta.arguments != null && typeof delta.arguments === "object") {
|
|
3689
|
+
open.arguments = delta.arguments;
|
|
3690
|
+
}
|
|
3596
3691
|
if (delta.name != null && open.blockType === "mcp_server_tool_call") {
|
|
3597
3692
|
open.toolName = delta.name;
|
|
3598
3693
|
}
|
|
@@ -3606,7 +3701,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3606
3701
|
}
|
|
3607
3702
|
break;
|
|
3608
3703
|
}
|
|
3609
|
-
case "
|
|
3704
|
+
case "step.stop": {
|
|
3610
3705
|
const event = value;
|
|
3611
3706
|
const open = openBlocks.get(event.index);
|
|
3612
3707
|
if (open == null) break;
|
|
@@ -3634,7 +3729,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3634
3729
|
if (open.data != null && open.data.length > 0) {
|
|
3635
3730
|
controller.enqueue({
|
|
3636
3731
|
type: "file",
|
|
3637
|
-
mediaType: (
|
|
3732
|
+
mediaType: (_n = open.mimeType) != null ? _n : "image/png",
|
|
3638
3733
|
data: open.data,
|
|
3639
3734
|
...providerMetadata ? { providerMetadata } : {}
|
|
3640
3735
|
});
|
|
@@ -3647,26 +3742,13 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3647
3742
|
};
|
|
3648
3743
|
controller.enqueue({
|
|
3649
3744
|
type: "file",
|
|
3650
|
-
mediaType: (
|
|
3745
|
+
mediaType: (_o = open.mimeType) != null ? _o : "image/png",
|
|
3651
3746
|
data: "",
|
|
3652
3747
|
providerMetadata: uriProviderMetadata
|
|
3653
3748
|
});
|
|
3654
3749
|
}
|
|
3655
3750
|
} 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
|
-
});
|
|
3751
|
+
const accumulated = open.argumentsAccum.length > 0 ? open.argumentsAccum : "{}";
|
|
3670
3752
|
controller.enqueue({
|
|
3671
3753
|
type: "tool-input-end",
|
|
3672
3754
|
id: open.toolCallId
|
|
@@ -3678,8 +3760,8 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3678
3760
|
controller.enqueue({
|
|
3679
3761
|
type: "tool-call",
|
|
3680
3762
|
toolCallId: open.toolCallId,
|
|
3681
|
-
toolName,
|
|
3682
|
-
input:
|
|
3763
|
+
toolName: open.toolName,
|
|
3764
|
+
input: accumulated,
|
|
3683
3765
|
...providerMetadata ? { providerMetadata } : {}
|
|
3684
3766
|
});
|
|
3685
3767
|
} else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
|
|
@@ -3687,7 +3769,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3687
3769
|
type: "tool-call",
|
|
3688
3770
|
toolCallId: open.toolCallId,
|
|
3689
3771
|
toolName: open.toolName,
|
|
3690
|
-
input: JSON.stringify((
|
|
3772
|
+
input: JSON.stringify((_p = open.arguments) != null ? _p : {}),
|
|
3691
3773
|
providerExecuted: true
|
|
3692
3774
|
});
|
|
3693
3775
|
open.callEmitted = true;
|
|
@@ -3696,7 +3778,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3696
3778
|
type: "tool-result",
|
|
3697
3779
|
toolCallId: open.callId,
|
|
3698
3780
|
toolName: open.toolName,
|
|
3699
|
-
result: (
|
|
3781
|
+
result: (_q = open.result) != null ? _q : null
|
|
3700
3782
|
});
|
|
3701
3783
|
open.resultEmitted = true;
|
|
3702
3784
|
const sources = builtinToolResultToSources({
|
|
@@ -3717,12 +3799,20 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3717
3799
|
openBlocks.delete(event.index);
|
|
3718
3800
|
break;
|
|
3719
3801
|
}
|
|
3720
|
-
case "interaction.status_update":
|
|
3802
|
+
case "interaction.status_update":
|
|
3803
|
+
case "interaction.in_progress":
|
|
3804
|
+
case "interaction.requires_action": {
|
|
3721
3805
|
const event = value;
|
|
3722
|
-
|
|
3806
|
+
if (event.status != null) {
|
|
3807
|
+
finishStatus = event.status;
|
|
3808
|
+
} else if (eventType === "interaction.requires_action") {
|
|
3809
|
+
finishStatus = "requires_action";
|
|
3810
|
+
} else {
|
|
3811
|
+
finishStatus = "in_progress";
|
|
3812
|
+
}
|
|
3723
3813
|
break;
|
|
3724
3814
|
}
|
|
3725
|
-
case "interaction.
|
|
3815
|
+
case "interaction.completed": {
|
|
3726
3816
|
const event = value;
|
|
3727
3817
|
const interaction = event.interaction;
|
|
3728
3818
|
if ((interaction == null ? void 0 : interaction.id) != null && interaction.id.length > 0) {
|
|
@@ -3742,7 +3832,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3742
3832
|
case "error": {
|
|
3743
3833
|
const event = value;
|
|
3744
3834
|
finishStatus = "failed";
|
|
3745
|
-
const errorPayload = (
|
|
3835
|
+
const errorPayload = (_r = event.error) != null ? _r : {
|
|
3746
3836
|
message: "Unknown interaction error"
|
|
3747
3837
|
};
|
|
3748
3838
|
controller.enqueue({ type: "error", error: errorPayload });
|
|
@@ -3811,7 +3901,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3811
3901
|
previousInteractionId
|
|
3812
3902
|
}) : prompt;
|
|
3813
3903
|
const systemTexts = [];
|
|
3814
|
-
const
|
|
3904
|
+
const steps = [];
|
|
3815
3905
|
for (const message of compactedPrompt) {
|
|
3816
3906
|
switch (message.role) {
|
|
3817
3907
|
case "system": {
|
|
@@ -3822,11 +3912,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3822
3912
|
const content = [];
|
|
3823
3913
|
for (const part of message.content) {
|
|
3824
3914
|
if (part.type === "text") {
|
|
3825
|
-
|
|
3826
|
-
type: "text",
|
|
3827
|
-
text: part.text
|
|
3828
|
-
};
|
|
3829
|
-
content.push(block);
|
|
3915
|
+
content.push({ type: "text", text: part.text });
|
|
3830
3916
|
} else if (part.type === "file") {
|
|
3831
3917
|
const fileBlock = convertFilePartToContent({
|
|
3832
3918
|
part,
|
|
@@ -3840,18 +3926,25 @@ function convertToGoogleInteractionsInput({
|
|
|
3840
3926
|
}
|
|
3841
3927
|
const merged = mergeAdjacentTextContent(content);
|
|
3842
3928
|
if (merged.length > 0) {
|
|
3843
|
-
|
|
3929
|
+
steps.push({ type: "user_input", content: merged });
|
|
3844
3930
|
}
|
|
3845
3931
|
break;
|
|
3846
3932
|
}
|
|
3847
3933
|
case "assistant": {
|
|
3848
|
-
|
|
3934
|
+
let pendingModelOutput = [];
|
|
3935
|
+
const flushModelOutput = () => {
|
|
3936
|
+
if (pendingModelOutput.length > 0) {
|
|
3937
|
+
steps.push({ type: "model_output", content: pendingModelOutput });
|
|
3938
|
+
pendingModelOutput = [];
|
|
3939
|
+
}
|
|
3940
|
+
};
|
|
3849
3941
|
for (const part of message.content) {
|
|
3850
3942
|
if (part.type === "text") {
|
|
3851
|
-
|
|
3943
|
+
pendingModelOutput.push({ type: "text", text: part.text });
|
|
3852
3944
|
} else if (part.type === "reasoning") {
|
|
3945
|
+
flushModelOutput();
|
|
3853
3946
|
const signature = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.signature;
|
|
3854
|
-
|
|
3947
|
+
steps.push({
|
|
3855
3948
|
type: "thought",
|
|
3856
3949
|
...signature != null ? { signature } : {},
|
|
3857
3950
|
summary: part.text.length > 0 ? [{ type: "text", text: part.text }] : void 0
|
|
@@ -3863,12 +3956,13 @@ function convertToGoogleInteractionsInput({
|
|
|
3863
3956
|
mediaResolution
|
|
3864
3957
|
});
|
|
3865
3958
|
if (fileBlock != null) {
|
|
3866
|
-
|
|
3959
|
+
pendingModelOutput.push(fileBlock);
|
|
3867
3960
|
}
|
|
3868
3961
|
} else if (part.type === "tool-call") {
|
|
3962
|
+
flushModelOutput();
|
|
3869
3963
|
const signature = (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.signature;
|
|
3870
3964
|
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_e = part.input) != null ? _e : {};
|
|
3871
|
-
|
|
3965
|
+
steps.push({
|
|
3872
3966
|
type: "function_call",
|
|
3873
3967
|
id: part.toolCallId,
|
|
3874
3968
|
name: part.toolName,
|
|
@@ -3882,9 +3976,7 @@ function convertToGoogleInteractionsInput({
|
|
|
3882
3976
|
});
|
|
3883
3977
|
}
|
|
3884
3978
|
}
|
|
3885
|
-
|
|
3886
|
-
turns.push({ role: "model", content });
|
|
3887
|
-
}
|
|
3979
|
+
flushModelOutput();
|
|
3888
3980
|
break;
|
|
3889
3981
|
}
|
|
3890
3982
|
case "tool": {
|
|
@@ -3907,22 +3999,14 @@ function convertToGoogleInteractionsInput({
|
|
|
3907
3999
|
content.push(block);
|
|
3908
4000
|
}
|
|
3909
4001
|
if (content.length > 0) {
|
|
3910
|
-
|
|
4002
|
+
steps.push({ type: "user_input", content });
|
|
3911
4003
|
}
|
|
3912
4004
|
break;
|
|
3913
4005
|
}
|
|
3914
4006
|
}
|
|
3915
4007
|
}
|
|
3916
4008
|
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 };
|
|
4009
|
+
return { input: steps, systemInstruction, warnings };
|
|
3926
4010
|
}
|
|
3927
4011
|
function convertFilePartToContent({
|
|
3928
4012
|
part,
|
|
@@ -4220,7 +4304,7 @@ var annotationSchema = () => {
|
|
|
4220
4304
|
type: z15.literal("file_citation"),
|
|
4221
4305
|
file_name: z15.string().nullish(),
|
|
4222
4306
|
document_uri: z15.string().nullish(),
|
|
4223
|
-
|
|
4307
|
+
url: z15.string().nullish(),
|
|
4224
4308
|
page_number: z15.number().nullish(),
|
|
4225
4309
|
media_id: z15.string().nullish(),
|
|
4226
4310
|
start_index: z15.number().nullish(),
|
|
@@ -4254,34 +4338,58 @@ var contentBlockSchema = () => {
|
|
|
4254
4338
|
text: z15.string(),
|
|
4255
4339
|
annotations: z15.array(annotationSchema()).nullish()
|
|
4256
4340
|
}).loose();
|
|
4257
|
-
const
|
|
4258
|
-
type: z15.literal("
|
|
4259
|
-
|
|
4260
|
-
|
|
4341
|
+
const imageContent = z15.object({
|
|
4342
|
+
type: z15.literal("image"),
|
|
4343
|
+
data: z15.string().nullish(),
|
|
4344
|
+
mime_type: z15.string().nullish(),
|
|
4345
|
+
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4346
|
+
uri: z15.string().nullish()
|
|
4347
|
+
}).loose();
|
|
4348
|
+
return z15.union([
|
|
4349
|
+
textContent,
|
|
4350
|
+
imageContent,
|
|
4351
|
+
z15.object({ type: z15.string() }).loose()
|
|
4352
|
+
]);
|
|
4353
|
+
};
|
|
4354
|
+
var BUILTIN_TOOL_CALL_STEP_TYPES = [
|
|
4355
|
+
"google_search_call",
|
|
4356
|
+
"code_execution_call",
|
|
4357
|
+
"url_context_call",
|
|
4358
|
+
"file_search_call",
|
|
4359
|
+
"google_maps_call",
|
|
4360
|
+
"mcp_server_tool_call"
|
|
4361
|
+
];
|
|
4362
|
+
var BUILTIN_TOOL_RESULT_STEP_TYPES = [
|
|
4363
|
+
"google_search_result",
|
|
4364
|
+
"code_execution_result",
|
|
4365
|
+
"url_context_result",
|
|
4366
|
+
"file_search_result",
|
|
4367
|
+
"google_maps_result",
|
|
4368
|
+
"mcp_server_tool_result"
|
|
4369
|
+
];
|
|
4370
|
+
var stepSchema = () => {
|
|
4371
|
+
const userInputStep = z15.object({
|
|
4372
|
+
type: z15.literal("user_input"),
|
|
4373
|
+
content: z15.array(contentBlockSchema()).nullish()
|
|
4374
|
+
}).loose();
|
|
4375
|
+
const modelOutputStep = z15.object({
|
|
4376
|
+
type: z15.literal("model_output"),
|
|
4377
|
+
content: z15.array(contentBlockSchema()).nullish()
|
|
4261
4378
|
}).loose();
|
|
4262
|
-
const
|
|
4379
|
+
const functionCallStep = z15.object({
|
|
4263
4380
|
type: z15.literal("function_call"),
|
|
4264
4381
|
id: z15.string(),
|
|
4265
4382
|
name: z15.string(),
|
|
4266
4383
|
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4267
4384
|
signature: z15.string().nullish()
|
|
4268
4385
|
}).loose();
|
|
4269
|
-
const
|
|
4270
|
-
type: z15.literal("
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4274
|
-
uri: z15.string().nullish()
|
|
4386
|
+
const thoughtStep = z15.object({
|
|
4387
|
+
type: z15.literal("thought"),
|
|
4388
|
+
signature: z15.string().nullish(),
|
|
4389
|
+
summary: z15.array(thoughtSummaryItemSchema()).nullish()
|
|
4275
4390
|
}).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
|
-
]),
|
|
4391
|
+
const builtinToolCallStep = z15.object({
|
|
4392
|
+
type: z15.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4285
4393
|
id: z15.string(),
|
|
4286
4394
|
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4287
4395
|
name: z15.string().nullish(),
|
|
@@ -4289,15 +4397,8 @@ var contentBlockSchema = () => {
|
|
|
4289
4397
|
search_type: z15.string().nullish(),
|
|
4290
4398
|
signature: z15.string().nullish()
|
|
4291
4399
|
}).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
|
-
]),
|
|
4400
|
+
const builtinToolResultStep = z15.object({
|
|
4401
|
+
type: z15.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4301
4402
|
call_id: z15.string(),
|
|
4302
4403
|
result: z15.unknown().nullish(),
|
|
4303
4404
|
is_error: z15.boolean().nullish(),
|
|
@@ -4306,12 +4407,12 @@ var contentBlockSchema = () => {
|
|
|
4306
4407
|
signature: z15.string().nullish()
|
|
4307
4408
|
}).loose();
|
|
4308
4409
|
return z15.union([
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4410
|
+
userInputStep,
|
|
4411
|
+
modelOutputStep,
|
|
4412
|
+
functionCallStep,
|
|
4413
|
+
thoughtStep,
|
|
4414
|
+
builtinToolCallStep,
|
|
4415
|
+
builtinToolResultStep,
|
|
4315
4416
|
z15.object({ type: z15.string() }).loose()
|
|
4316
4417
|
]);
|
|
4317
4418
|
};
|
|
@@ -4329,7 +4430,7 @@ var googleInteractionsResponseSchema = lazySchema13(
|
|
|
4329
4430
|
status: interactionStatusSchema(),
|
|
4330
4431
|
model: z15.string().nullish(),
|
|
4331
4432
|
agent: z15.string().nullish(),
|
|
4332
|
-
|
|
4433
|
+
steps: z15.array(stepSchema()).nullish(),
|
|
4333
4434
|
usage: usageSchema2().nullish(),
|
|
4334
4435
|
service_tier: z15.string().nullish(),
|
|
4335
4436
|
previous_interaction_id: z15.string().nullish(),
|
|
@@ -4343,8 +4444,8 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4343
4444
|
const status = interactionStatusSchema();
|
|
4344
4445
|
const annotation = annotationSchema();
|
|
4345
4446
|
const thoughtSummaryItem = thoughtSummaryItemSchema();
|
|
4346
|
-
const
|
|
4347
|
-
event_type: z15.literal("interaction.
|
|
4447
|
+
const interactionCreatedEvent = z15.object({
|
|
4448
|
+
event_type: z15.literal("interaction.created"),
|
|
4348
4449
|
event_id: z15.string().nullish(),
|
|
4349
4450
|
interaction: z15.object({
|
|
4350
4451
|
/*
|
|
@@ -4358,94 +4459,79 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4358
4459
|
status: status.nullish()
|
|
4359
4460
|
}).loose()
|
|
4360
4461
|
}).loose();
|
|
4361
|
-
const
|
|
4362
|
-
event_type: z15.literal("
|
|
4462
|
+
const stepStartEvent = z15.object({
|
|
4463
|
+
event_type: z15.literal("step.start"),
|
|
4363
4464
|
event_id: z15.string().nullish(),
|
|
4364
4465
|
index: z15.number(),
|
|
4365
|
-
|
|
4466
|
+
step: stepSchema()
|
|
4366
4467
|
}).loose();
|
|
4367
|
-
const
|
|
4468
|
+
const stepDeltaText = z15.object({
|
|
4368
4469
|
type: z15.literal("text"),
|
|
4369
4470
|
text: z15.string()
|
|
4370
4471
|
}).loose();
|
|
4371
|
-
const
|
|
4472
|
+
const stepDeltaThoughtSummary = z15.object({
|
|
4372
4473
|
type: z15.literal("thought_summary"),
|
|
4373
4474
|
content: thoughtSummaryItem.nullish()
|
|
4374
4475
|
}).loose();
|
|
4375
|
-
const
|
|
4476
|
+
const stepDeltaThoughtSignature = z15.object({
|
|
4376
4477
|
type: z15.literal("thought_signature"),
|
|
4377
4478
|
signature: z15.string().nullish()
|
|
4378
4479
|
}).loose();
|
|
4379
|
-
const
|
|
4380
|
-
type: z15.literal("
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4480
|
+
const stepDeltaArgumentsDelta = z15.object({
|
|
4481
|
+
type: z15.literal("arguments_delta"),
|
|
4482
|
+
arguments: z15.string().nullish(),
|
|
4483
|
+
id: z15.string().nullish(),
|
|
4384
4484
|
signature: z15.string().nullish()
|
|
4385
4485
|
}).loose();
|
|
4386
|
-
const
|
|
4387
|
-
type: z15.
|
|
4486
|
+
const stepDeltaTextAnnotation = z15.object({
|
|
4487
|
+
type: z15.enum(["text_annotation_delta", "text_annotation"]),
|
|
4388
4488
|
annotations: z15.array(annotation).nullish()
|
|
4389
4489
|
}).loose();
|
|
4390
|
-
const
|
|
4490
|
+
const stepDeltaImage = z15.object({
|
|
4391
4491
|
type: z15.literal("image"),
|
|
4392
4492
|
data: z15.string().nullish(),
|
|
4393
4493
|
mime_type: z15.string().nullish(),
|
|
4394
4494
|
resolution: z15.enum(["low", "medium", "high", "ultra_high"]).nullish(),
|
|
4395
4495
|
uri: z15.string().nullish()
|
|
4396
4496
|
}).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(),
|
|
4497
|
+
const stepDeltaBuiltinToolCall = z15.object({
|
|
4498
|
+
type: z15.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4499
|
+
id: z15.string().nullish(),
|
|
4407
4500
|
arguments: z15.record(z15.string(), z15.unknown()).nullish(),
|
|
4408
4501
|
name: z15.string().nullish(),
|
|
4409
4502
|
server_name: z15.string().nullish(),
|
|
4410
4503
|
search_type: z15.string().nullish(),
|
|
4411
4504
|
signature: z15.string().nullish()
|
|
4412
4505
|
}).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(),
|
|
4506
|
+
const stepDeltaBuiltinToolResult = z15.object({
|
|
4507
|
+
type: z15.enum(BUILTIN_TOOL_RESULT_STEP_TYPES),
|
|
4508
|
+
call_id: z15.string().nullish(),
|
|
4423
4509
|
result: z15.unknown().nullish(),
|
|
4424
4510
|
is_error: z15.boolean().nullish(),
|
|
4425
4511
|
name: z15.string().nullish(),
|
|
4426
4512
|
server_name: z15.string().nullish(),
|
|
4427
4513
|
signature: z15.string().nullish()
|
|
4428
4514
|
}).loose();
|
|
4429
|
-
const
|
|
4430
|
-
const
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4515
|
+
const stepDeltaUnknown = z15.object({ type: z15.string() }).loose();
|
|
4516
|
+
const stepDeltaUnion = z15.union([
|
|
4517
|
+
stepDeltaText,
|
|
4518
|
+
stepDeltaImage,
|
|
4519
|
+
stepDeltaThoughtSummary,
|
|
4520
|
+
stepDeltaThoughtSignature,
|
|
4521
|
+
stepDeltaArgumentsDelta,
|
|
4522
|
+
stepDeltaTextAnnotation,
|
|
4523
|
+
stepDeltaBuiltinToolCall,
|
|
4524
|
+
stepDeltaBuiltinToolResult,
|
|
4525
|
+
stepDeltaUnknown
|
|
4440
4526
|
]);
|
|
4441
|
-
const
|
|
4442
|
-
event_type: z15.literal("
|
|
4527
|
+
const stepDeltaEvent = z15.object({
|
|
4528
|
+
event_type: z15.literal("step.delta"),
|
|
4443
4529
|
event_id: z15.string().nullish(),
|
|
4444
4530
|
index: z15.number(),
|
|
4445
|
-
delta:
|
|
4531
|
+
delta: stepDeltaUnion
|
|
4446
4532
|
}).loose();
|
|
4447
|
-
const
|
|
4448
|
-
event_type: z15.literal("
|
|
4533
|
+
const stepStopEvent = z15.object({
|
|
4534
|
+
event_type: z15.literal("step.stop"),
|
|
4449
4535
|
event_id: z15.string().nullish(),
|
|
4450
4536
|
index: z15.number()
|
|
4451
4537
|
}).loose();
|
|
@@ -4453,10 +4539,22 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4453
4539
|
event_type: z15.literal("interaction.status_update"),
|
|
4454
4540
|
event_id: z15.string().nullish(),
|
|
4455
4541
|
interaction_id: z15.string().nullish(),
|
|
4456
|
-
status
|
|
4542
|
+
status: status.nullish()
|
|
4457
4543
|
}).loose();
|
|
4458
|
-
const
|
|
4459
|
-
event_type: z15.literal("interaction.
|
|
4544
|
+
const interactionInProgressEvent = z15.object({
|
|
4545
|
+
event_type: z15.literal("interaction.in_progress"),
|
|
4546
|
+
event_id: z15.string().nullish(),
|
|
4547
|
+
interaction_id: z15.string().nullish(),
|
|
4548
|
+
status: status.nullish()
|
|
4549
|
+
}).loose();
|
|
4550
|
+
const interactionRequiresActionEvent = z15.object({
|
|
4551
|
+
event_type: z15.literal("interaction.requires_action"),
|
|
4552
|
+
event_id: z15.string().nullish(),
|
|
4553
|
+
interaction_id: z15.string().nullish(),
|
|
4554
|
+
status: status.nullish()
|
|
4555
|
+
}).loose();
|
|
4556
|
+
const interactionCompletedEvent = z15.object({
|
|
4557
|
+
event_type: z15.literal("interaction.completed"),
|
|
4460
4558
|
event_id: z15.string().nullish(),
|
|
4461
4559
|
interaction: z15.object({
|
|
4462
4560
|
id: z15.string().nullish(),
|
|
@@ -4475,12 +4573,14 @@ var googleInteractionsEventSchema = lazySchema13(
|
|
|
4475
4573
|
}).loose();
|
|
4476
4574
|
const unknownEvent = z15.object({ event_type: z15.string() }).loose();
|
|
4477
4575
|
return z15.union([
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4576
|
+
interactionCreatedEvent,
|
|
4577
|
+
stepStartEvent,
|
|
4578
|
+
stepDeltaEvent,
|
|
4579
|
+
stepStopEvent,
|
|
4482
4580
|
interactionStatusUpdateEvent,
|
|
4483
|
-
|
|
4581
|
+
interactionInProgressEvent,
|
|
4582
|
+
interactionRequiresActionEvent,
|
|
4583
|
+
interactionCompletedEvent,
|
|
4484
4584
|
errorEvent,
|
|
4485
4585
|
unknownEvent
|
|
4486
4586
|
]);
|
|
@@ -4513,6 +4613,55 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
4513
4613
|
]).nullish(),
|
|
4514
4614
|
thinkingLevel: z16.enum(["minimal", "low", "medium", "high"]).nullish(),
|
|
4515
4615
|
thinkingSummaries: z16.enum(["auto", "none"]).nullish(),
|
|
4616
|
+
/**
|
|
4617
|
+
* Output-format entries that map directly to the API's `response_format`
|
|
4618
|
+
* array. Use this to request image, audio, or non-JSON text outputs
|
|
4619
|
+
* with full control over `mime_type`, `aspect_ratio`, and `image_size`.
|
|
4620
|
+
*
|
|
4621
|
+
* Entries are sent in order. The AI SDK call-level `responseFormat: {
|
|
4622
|
+
* type: 'json', schema }` still drives JSON-mode and adds a matching
|
|
4623
|
+
* text entry automatically; entries listed here are appended.
|
|
4624
|
+
*/
|
|
4625
|
+
responseFormat: z16.array(
|
|
4626
|
+
z16.union([
|
|
4627
|
+
z16.object({
|
|
4628
|
+
type: z16.literal("text"),
|
|
4629
|
+
mimeType: z16.string().nullish(),
|
|
4630
|
+
schema: z16.unknown().nullish()
|
|
4631
|
+
}).loose(),
|
|
4632
|
+
z16.object({
|
|
4633
|
+
type: z16.literal("image"),
|
|
4634
|
+
mimeType: z16.string().nullish(),
|
|
4635
|
+
aspectRatio: z16.enum([
|
|
4636
|
+
"1:1",
|
|
4637
|
+
"2:3",
|
|
4638
|
+
"3:2",
|
|
4639
|
+
"3:4",
|
|
4640
|
+
"4:3",
|
|
4641
|
+
"4:5",
|
|
4642
|
+
"5:4",
|
|
4643
|
+
"9:16",
|
|
4644
|
+
"16:9",
|
|
4645
|
+
"21:9",
|
|
4646
|
+
"1:8",
|
|
4647
|
+
"8:1",
|
|
4648
|
+
"1:4",
|
|
4649
|
+
"4:1"
|
|
4650
|
+
]).nullish(),
|
|
4651
|
+
imageSize: z16.enum(["1K", "2K", "4K", "512"]).nullish()
|
|
4652
|
+
}).loose(),
|
|
4653
|
+
z16.object({
|
|
4654
|
+
type: z16.literal("audio"),
|
|
4655
|
+
mimeType: z16.string().nullish()
|
|
4656
|
+
}).loose()
|
|
4657
|
+
])
|
|
4658
|
+
).nullish(),
|
|
4659
|
+
/**
|
|
4660
|
+
* @deprecated Use `responseFormat` with a `{ type: 'image', ... }`
|
|
4661
|
+
* entry instead. Retained for backwards compatibility; the SDK
|
|
4662
|
+
* translates it into a matching `response_format` image entry and
|
|
4663
|
+
* emits a warning when set.
|
|
4664
|
+
*/
|
|
4516
4665
|
imageConfig: z16.object({
|
|
4517
4666
|
aspectRatio: z16.enum([
|
|
4518
4667
|
"1:1",
|
|
@@ -4558,7 +4707,61 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
4558
4707
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
4559
4708
|
* such as deep research can take tens of minutes — increase if needed.
|
|
4560
4709
|
*/
|
|
4561
|
-
pollingTimeoutMs: z16.number().int().positive().nullish()
|
|
4710
|
+
pollingTimeoutMs: z16.number().int().positive().nullish(),
|
|
4711
|
+
/**
|
|
4712
|
+
* Run the interaction in the background. Required for agents whose
|
|
4713
|
+
* server-side workflow cannot complete within a single request/response.
|
|
4714
|
+
* When `true`, the POST returns with a non-terminal status and the SDK
|
|
4715
|
+
* polls `GET /interactions/{id}` until the work completes. Some agents
|
|
4716
|
+
* reject `true`; see the agent's documentation for which mode it
|
|
4717
|
+
* requires.
|
|
4718
|
+
*/
|
|
4719
|
+
background: z16.boolean().nullish(),
|
|
4720
|
+
/**
|
|
4721
|
+
* Environment configuration for the agent sandbox. Only applies to agent
|
|
4722
|
+
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
4723
|
+
*
|
|
4724
|
+
* - `"remote"`: provision a fresh sandbox for this call.
|
|
4725
|
+
* - any other string: an existing `environment_id` to reuse.
|
|
4726
|
+
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
4727
|
+
* and/or constrain outbound traffic via `network`.
|
|
4728
|
+
*/
|
|
4729
|
+
environment: z16.union([
|
|
4730
|
+
z16.string(),
|
|
4731
|
+
z16.object({
|
|
4732
|
+
type: z16.literal("remote"),
|
|
4733
|
+
sources: z16.array(
|
|
4734
|
+
z16.union([
|
|
4735
|
+
z16.object({
|
|
4736
|
+
type: z16.literal("gcs"),
|
|
4737
|
+
source: z16.string(),
|
|
4738
|
+
target: z16.string().nullish()
|
|
4739
|
+
}),
|
|
4740
|
+
z16.object({
|
|
4741
|
+
type: z16.literal("repository"),
|
|
4742
|
+
source: z16.string(),
|
|
4743
|
+
target: z16.string().nullish()
|
|
4744
|
+
}),
|
|
4745
|
+
z16.object({
|
|
4746
|
+
type: z16.literal("inline"),
|
|
4747
|
+
content: z16.string(),
|
|
4748
|
+
target: z16.string()
|
|
4749
|
+
})
|
|
4750
|
+
])
|
|
4751
|
+
).nullish(),
|
|
4752
|
+
network: z16.union([
|
|
4753
|
+
z16.literal("disabled"),
|
|
4754
|
+
z16.object({
|
|
4755
|
+
allowlist: z16.array(
|
|
4756
|
+
z16.object({
|
|
4757
|
+
domain: z16.string(),
|
|
4758
|
+
transform: z16.array(z16.record(z16.string(), z16.string())).nullish()
|
|
4759
|
+
})
|
|
4760
|
+
)
|
|
4761
|
+
})
|
|
4762
|
+
]).nullish()
|
|
4763
|
+
})
|
|
4764
|
+
]).nullish()
|
|
4562
4765
|
})
|
|
4563
4766
|
)
|
|
4564
4767
|
);
|
|
@@ -4600,37 +4803,69 @@ function builtinToolNameFromResultType2(type) {
|
|
|
4600
4803
|
return type.replace(/_result$/, "");
|
|
4601
4804
|
}
|
|
4602
4805
|
function parseGoogleInteractionsOutputs({
|
|
4603
|
-
|
|
4806
|
+
steps,
|
|
4604
4807
|
generateId: generateId3,
|
|
4605
4808
|
interactionId
|
|
4606
4809
|
}) {
|
|
4607
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4810
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4608
4811
|
const content = [];
|
|
4609
4812
|
let hasFunctionCall = false;
|
|
4610
|
-
if (
|
|
4813
|
+
if (steps == null) {
|
|
4611
4814
|
return { content, hasFunctionCall };
|
|
4612
4815
|
}
|
|
4613
|
-
for (const
|
|
4614
|
-
if (
|
|
4615
|
-
const type =
|
|
4816
|
+
for (const step of steps) {
|
|
4817
|
+
if (step == null || typeof step !== "object") continue;
|
|
4818
|
+
const type = step.type;
|
|
4616
4819
|
if (typeof type !== "string") continue;
|
|
4617
4820
|
switch (type) {
|
|
4618
|
-
case "
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4821
|
+
case "user_input": {
|
|
4822
|
+
break;
|
|
4823
|
+
}
|
|
4824
|
+
case "model_output": {
|
|
4825
|
+
const blocks = (_a = step.content) != null ? _a : [];
|
|
4826
|
+
for (const block of blocks) {
|
|
4827
|
+
if (block == null || typeof block !== "object") continue;
|
|
4828
|
+
const blockType = block.type;
|
|
4829
|
+
if (blockType === "text") {
|
|
4830
|
+
const text = (_b = block.text) != null ? _b : "";
|
|
4831
|
+
const annotations = block.annotations;
|
|
4832
|
+
content.push({
|
|
4833
|
+
type: "text",
|
|
4834
|
+
text,
|
|
4835
|
+
...googleProviderMetadata({ interactionId })
|
|
4836
|
+
});
|
|
4837
|
+
const sources = annotationsToSources({ annotations, generateId: generateId3 });
|
|
4838
|
+
for (const source of sources) {
|
|
4839
|
+
content.push(source);
|
|
4840
|
+
}
|
|
4841
|
+
} else if (blockType === "image") {
|
|
4842
|
+
const image = block;
|
|
4843
|
+
if (image.data != null && image.data.length > 0) {
|
|
4844
|
+
content.push({
|
|
4845
|
+
type: "file",
|
|
4846
|
+
mediaType: (_c = image.mime_type) != null ? _c : "image/png",
|
|
4847
|
+
data: image.data,
|
|
4848
|
+
...googleProviderMetadata({ interactionId })
|
|
4849
|
+
});
|
|
4850
|
+
} else if (image.uri != null && image.uri.length > 0) {
|
|
4851
|
+
content.push({
|
|
4852
|
+
type: "file",
|
|
4853
|
+
mediaType: (_d = image.mime_type) != null ? _d : "image/png",
|
|
4854
|
+
data: "",
|
|
4855
|
+
providerMetadata: {
|
|
4856
|
+
google: {
|
|
4857
|
+
...interactionId != null ? { interactionId } : {},
|
|
4858
|
+
imageUri: image.uri
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
});
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4629
4864
|
}
|
|
4630
4865
|
break;
|
|
4631
4866
|
}
|
|
4632
4867
|
case "thought": {
|
|
4633
|
-
const thought =
|
|
4868
|
+
const thought = step;
|
|
4634
4869
|
const summary = Array.isArray(thought.summary) ? thought.summary : [];
|
|
4635
4870
|
const text = summary.filter(
|
|
4636
4871
|
(item) => (item == null ? void 0 : item.type) === "text" && typeof item.text === "string"
|
|
@@ -4645,38 +4880,14 @@ function parseGoogleInteractionsOutputs({
|
|
|
4645
4880
|
});
|
|
4646
4881
|
break;
|
|
4647
4882
|
}
|
|
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
4883
|
case "function_call": {
|
|
4673
4884
|
hasFunctionCall = true;
|
|
4674
|
-
const call =
|
|
4885
|
+
const call = step;
|
|
4675
4886
|
content.push({
|
|
4676
4887
|
type: "tool-call",
|
|
4677
4888
|
toolCallId: call.id,
|
|
4678
4889
|
toolName: call.name,
|
|
4679
|
-
input: JSON.stringify((
|
|
4890
|
+
input: JSON.stringify((_e = call.arguments) != null ? _e : {}),
|
|
4680
4891
|
...googleProviderMetadata({
|
|
4681
4892
|
signature: call.signature,
|
|
4682
4893
|
interactionId
|
|
@@ -4686,27 +4897,27 @@ function parseGoogleInteractionsOutputs({
|
|
|
4686
4897
|
}
|
|
4687
4898
|
default: {
|
|
4688
4899
|
if (BUILTIN_TOOL_CALL_TYPES2.has(type)) {
|
|
4689
|
-
const call =
|
|
4690
|
-
const toolName = type === "mcp_server_tool_call" ? (
|
|
4691
|
-
const input = JSON.stringify((
|
|
4900
|
+
const call = step;
|
|
4901
|
+
const toolName = type === "mcp_server_tool_call" ? (_f = call.name) != null ? _f : "mcp_server_tool" : builtinToolNameFromCallType2(type);
|
|
4902
|
+
const input = JSON.stringify((_g = call.arguments) != null ? _g : {});
|
|
4692
4903
|
content.push({
|
|
4693
4904
|
type: "tool-call",
|
|
4694
|
-
toolCallId: (
|
|
4905
|
+
toolCallId: (_h = call.id) != null ? _h : generateId3(),
|
|
4695
4906
|
toolName,
|
|
4696
4907
|
input,
|
|
4697
4908
|
providerExecuted: true
|
|
4698
4909
|
});
|
|
4699
4910
|
} else if (BUILTIN_TOOL_RESULT_TYPES2.has(type)) {
|
|
4700
|
-
const result =
|
|
4701
|
-
const toolName = type === "mcp_server_tool_result" ? (
|
|
4911
|
+
const result = step;
|
|
4912
|
+
const toolName = type === "mcp_server_tool_result" ? (_i = result.name) != null ? _i : "mcp_server_tool" : builtinToolNameFromResultType2(type);
|
|
4702
4913
|
content.push({
|
|
4703
4914
|
type: "tool-result",
|
|
4704
|
-
toolCallId: (
|
|
4915
|
+
toolCallId: (_j = result.call_id) != null ? _j : generateId3(),
|
|
4705
4916
|
toolName,
|
|
4706
|
-
result: (
|
|
4917
|
+
result: (_k = result.result) != null ? _k : null
|
|
4707
4918
|
});
|
|
4708
4919
|
const sources = builtinToolResultToSources({
|
|
4709
|
-
block,
|
|
4920
|
+
block: step,
|
|
4710
4921
|
generateId: generateId3
|
|
4711
4922
|
});
|
|
4712
4923
|
for (const source of sources) {
|
|
@@ -5094,7 +5305,7 @@ function streamGoogleInteractionEvents({
|
|
|
5094
5305
|
if (typeof ev.event_id === "string" && ev.event_id.length > 0) {
|
|
5095
5306
|
lastEventId = ev.event_id;
|
|
5096
5307
|
}
|
|
5097
|
-
if (ev.event_type === "interaction.
|
|
5308
|
+
if (ev.event_type === "interaction.completed" || ev.event_type === "error") {
|
|
5098
5309
|
complete = true;
|
|
5099
5310
|
}
|
|
5100
5311
|
}
|
|
@@ -5175,7 +5386,7 @@ function synthesizeGoogleInteractionsAgentStream({
|
|
|
5175
5386
|
controller.enqueue({ type: "raw", rawValue: response });
|
|
5176
5387
|
}
|
|
5177
5388
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5178
|
-
|
|
5389
|
+
steps: (_b = response.steps) != null ? _b : null,
|
|
5179
5390
|
generateId: generateId3,
|
|
5180
5391
|
interactionId
|
|
5181
5392
|
});
|
|
@@ -5292,6 +5503,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5292
5503
|
if (typeof modelOrAgent === "string") {
|
|
5293
5504
|
this.modelId = modelOrAgent;
|
|
5294
5505
|
this.agent = void 0;
|
|
5506
|
+
} else if ("managedAgent" in modelOrAgent) {
|
|
5507
|
+
this.modelId = modelOrAgent.managedAgent;
|
|
5508
|
+
this.agent = modelOrAgent.managedAgent;
|
|
5295
5509
|
} else {
|
|
5296
5510
|
this.modelId = modelOrAgent.agent;
|
|
5297
5511
|
this.agent = modelOrAgent.agent;
|
|
@@ -5317,7 +5531,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5317
5531
|
};
|
|
5318
5532
|
}
|
|
5319
5533
|
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;
|
|
5534
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
5321
5535
|
const warnings = [];
|
|
5322
5536
|
const opts = await parseProviderOptions5({
|
|
5323
5537
|
provider: "google",
|
|
@@ -5342,8 +5556,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5342
5556
|
toolChoiceForBody = prepared.toolChoice;
|
|
5343
5557
|
warnings.push(...prepared.toolWarnings);
|
|
5344
5558
|
}
|
|
5345
|
-
|
|
5346
|
-
let responseFormat;
|
|
5559
|
+
const responseFormatEntries = [];
|
|
5347
5560
|
if (((_a = options.responseFormat) == null ? void 0 : _a.type) === "json") {
|
|
5348
5561
|
if (isAgent) {
|
|
5349
5562
|
warnings.push({
|
|
@@ -5351,9 +5564,40 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5351
5564
|
message: "google.interactions: structured output (responseFormat) is not supported when an agent is set; responseFormat will be ignored."
|
|
5352
5565
|
});
|
|
5353
5566
|
} else {
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5567
|
+
const entry = {
|
|
5568
|
+
type: "text",
|
|
5569
|
+
mime_type: "application/json",
|
|
5570
|
+
...options.responseFormat.schema != null ? { schema: options.responseFormat.schema } : {}
|
|
5571
|
+
};
|
|
5572
|
+
responseFormatEntries.push(entry);
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
if ((opts == null ? void 0 : opts.responseFormat) != null) {
|
|
5576
|
+
for (const entry of opts.responseFormat) {
|
|
5577
|
+
if (entry.type === "text") {
|
|
5578
|
+
responseFormatEntries.push(
|
|
5579
|
+
pruneUndefined({
|
|
5580
|
+
type: "text",
|
|
5581
|
+
mime_type: (_b = entry.mimeType) != null ? _b : void 0,
|
|
5582
|
+
schema: (_c = entry.schema) != null ? _c : void 0
|
|
5583
|
+
})
|
|
5584
|
+
);
|
|
5585
|
+
} else if (entry.type === "image") {
|
|
5586
|
+
responseFormatEntries.push(
|
|
5587
|
+
pruneUndefined({
|
|
5588
|
+
type: "image",
|
|
5589
|
+
mime_type: (_d = entry.mimeType) != null ? _d : void 0,
|
|
5590
|
+
aspect_ratio: (_e = entry.aspectRatio) != null ? _e : void 0,
|
|
5591
|
+
image_size: (_f = entry.imageSize) != null ? _f : void 0
|
|
5592
|
+
})
|
|
5593
|
+
);
|
|
5594
|
+
} else if (entry.type === "audio") {
|
|
5595
|
+
responseFormatEntries.push(
|
|
5596
|
+
pruneUndefined({
|
|
5597
|
+
type: "audio",
|
|
5598
|
+
mime_type: (_g = entry.mimeType) != null ? _g : void 0
|
|
5599
|
+
})
|
|
5600
|
+
);
|
|
5357
5601
|
}
|
|
5358
5602
|
}
|
|
5359
5603
|
}
|
|
@@ -5363,13 +5607,13 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5363
5607
|
warnings: convWarnings
|
|
5364
5608
|
} = convertToGoogleInteractionsInput({
|
|
5365
5609
|
prompt: options.prompt,
|
|
5366
|
-
previousInteractionId: (
|
|
5367
|
-
store: (
|
|
5368
|
-
mediaResolution: (
|
|
5610
|
+
previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
|
|
5611
|
+
store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
|
|
5612
|
+
mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
|
|
5369
5613
|
});
|
|
5370
5614
|
warnings.push(...convWarnings);
|
|
5371
5615
|
let systemInstruction = convertedSystemInstruction;
|
|
5372
|
-
const optionSystemInstruction = (
|
|
5616
|
+
const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
|
|
5373
5617
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
5374
5618
|
warnings.push({
|
|
5375
5619
|
type: "other",
|
|
@@ -5403,19 +5647,32 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5403
5647
|
generationConfig = void 0;
|
|
5404
5648
|
} else {
|
|
5405
5649
|
generationConfig = pruneUndefined({
|
|
5406
|
-
temperature: (
|
|
5407
|
-
top_p: (
|
|
5408
|
-
seed: (
|
|
5650
|
+
temperature: (_l = options.temperature) != null ? _l : void 0,
|
|
5651
|
+
top_p: (_m = options.topP) != null ? _m : void 0,
|
|
5652
|
+
seed: (_n = options.seed) != null ? _n : void 0,
|
|
5409
5653
|
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,
|
|
5654
|
+
max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
|
|
5655
|
+
thinking_level: (_p = opts == null ? void 0 : opts.thinkingLevel) != null ? _p : void 0,
|
|
5656
|
+
thinking_summaries: (_q = opts == null ? void 0 : opts.thinkingSummaries) != null ? _q : void 0,
|
|
5417
5657
|
tool_choice: toolChoiceForBody
|
|
5418
5658
|
});
|
|
5659
|
+
if ((opts == null ? void 0 : opts.imageConfig) != null) {
|
|
5660
|
+
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
5661
|
+
(entry) => entry.type === "image"
|
|
5662
|
+
);
|
|
5663
|
+
warnings.push({
|
|
5664
|
+
type: "other",
|
|
5665
|
+
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.'
|
|
5666
|
+
});
|
|
5667
|
+
if (!alreadyHasImageEntry) {
|
|
5668
|
+
responseFormatEntries.push({
|
|
5669
|
+
type: "image",
|
|
5670
|
+
mime_type: "image/png",
|
|
5671
|
+
...opts.imageConfig.aspectRatio != null ? { aspect_ratio: opts.imageConfig.aspectRatio } : {},
|
|
5672
|
+
...opts.imageConfig.imageSize != null ? { image_size: opts.imageConfig.imageSize } : {}
|
|
5673
|
+
});
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5419
5676
|
}
|
|
5420
5677
|
let agentConfig;
|
|
5421
5678
|
if (isAgent && (opts == null ? void 0 : opts.agentConfig) != null) {
|
|
@@ -5423,34 +5680,84 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5423
5680
|
if (ac.type === "deep-research") {
|
|
5424
5681
|
agentConfig = pruneUndefined({
|
|
5425
5682
|
type: "deep-research",
|
|
5426
|
-
thinking_summaries: (
|
|
5427
|
-
visualization: (
|
|
5428
|
-
collaborative_planning: (
|
|
5683
|
+
thinking_summaries: (_r = ac.thinkingSummaries) != null ? _r : void 0,
|
|
5684
|
+
visualization: (_s = ac.visualization) != null ? _s : void 0,
|
|
5685
|
+
collaborative_planning: (_t = ac.collaborativePlanning) != null ? _t : void 0
|
|
5429
5686
|
});
|
|
5430
5687
|
} else if (ac.type === "dynamic") {
|
|
5431
5688
|
agentConfig = { type: "dynamic" };
|
|
5432
5689
|
}
|
|
5433
5690
|
}
|
|
5691
|
+
let environment;
|
|
5692
|
+
if ((opts == null ? void 0 : opts.environment) != null) {
|
|
5693
|
+
if (!isAgent) {
|
|
5694
|
+
warnings.push({
|
|
5695
|
+
type: "other",
|
|
5696
|
+
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
5697
|
+
});
|
|
5698
|
+
} else if (typeof opts.environment === "string") {
|
|
5699
|
+
environment = opts.environment;
|
|
5700
|
+
} else {
|
|
5701
|
+
const env = opts.environment;
|
|
5702
|
+
const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
|
|
5703
|
+
var _a2;
|
|
5704
|
+
if (s.type === "inline") {
|
|
5705
|
+
return {
|
|
5706
|
+
type: "inline",
|
|
5707
|
+
content: s.content,
|
|
5708
|
+
target: s.target
|
|
5709
|
+
};
|
|
5710
|
+
}
|
|
5711
|
+
return pruneUndefined({
|
|
5712
|
+
type: s.type,
|
|
5713
|
+
source: s.source,
|
|
5714
|
+
target: (_a2 = s.target) != null ? _a2 : void 0
|
|
5715
|
+
});
|
|
5716
|
+
});
|
|
5717
|
+
let network;
|
|
5718
|
+
if (env.network === "disabled") {
|
|
5719
|
+
network = "disabled";
|
|
5720
|
+
} else if (env.network != null) {
|
|
5721
|
+
network = {
|
|
5722
|
+
allowlist: env.network.allowlist.map(
|
|
5723
|
+
(entry) => {
|
|
5724
|
+
var _a2;
|
|
5725
|
+
return pruneUndefined({
|
|
5726
|
+
domain: entry.domain,
|
|
5727
|
+
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
5728
|
+
});
|
|
5729
|
+
}
|
|
5730
|
+
)
|
|
5731
|
+
};
|
|
5732
|
+
}
|
|
5733
|
+
environment = pruneUndefined({
|
|
5734
|
+
type: "remote",
|
|
5735
|
+
sources: sources != null && sources.length > 0 ? sources : void 0,
|
|
5736
|
+
network
|
|
5737
|
+
});
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5434
5740
|
const args = pruneUndefined({
|
|
5435
5741
|
...isAgent ? { agent: this.agent } : { model: this.modelId },
|
|
5436
5742
|
input,
|
|
5437
5743
|
system_instruction: systemInstruction,
|
|
5438
5744
|
tools: toolsForBody,
|
|
5439
|
-
response_format:
|
|
5440
|
-
response_mime_type: responseMimeType,
|
|
5745
|
+
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5441
5746
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5442
|
-
previous_interaction_id: (
|
|
5443
|
-
service_tier: (
|
|
5444
|
-
store: (
|
|
5747
|
+
previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
|
|
5748
|
+
service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
|
|
5749
|
+
store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
|
|
5445
5750
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5446
5751
|
agent_config: agentConfig,
|
|
5447
|
-
|
|
5752
|
+
environment,
|
|
5753
|
+
background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
|
|
5448
5754
|
});
|
|
5449
5755
|
return {
|
|
5450
5756
|
args,
|
|
5451
5757
|
warnings,
|
|
5452
5758
|
isAgent,
|
|
5453
|
-
|
|
5759
|
+
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
5760
|
+
pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
|
|
5454
5761
|
};
|
|
5455
5762
|
}
|
|
5456
5763
|
async doGenerate(options) {
|
|
@@ -5458,6 +5765,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5458
5765
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
5459
5766
|
const url = `${this.config.baseURL}/interactions`;
|
|
5460
5767
|
const mergedHeaders = combineHeaders6(
|
|
5768
|
+
INTERACTIONS_API_REVISION_HEADER,
|
|
5461
5769
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
5462
5770
|
options.headers
|
|
5463
5771
|
);
|
|
@@ -5492,7 +5800,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5492
5800
|
}
|
|
5493
5801
|
const interactionId = typeof response.id === "string" && response.id.length > 0 ? response.id : void 0;
|
|
5494
5802
|
const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
|
|
5495
|
-
|
|
5803
|
+
steps: (_b = response.steps) != null ? _b : null,
|
|
5496
5804
|
generateId: (_c = this.config.generateId) != null ? _c : defaultGenerateId2,
|
|
5497
5805
|
interactionId
|
|
5498
5806
|
});
|
|
@@ -5535,13 +5843,14 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5535
5843
|
}
|
|
5536
5844
|
async doStream(options) {
|
|
5537
5845
|
var _a;
|
|
5538
|
-
const { args, warnings,
|
|
5846
|
+
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
5539
5847
|
const url = `${this.config.baseURL}/interactions`;
|
|
5540
5848
|
const mergedHeaders = combineHeaders6(
|
|
5849
|
+
INTERACTIONS_API_REVISION_HEADER,
|
|
5541
5850
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
5542
5851
|
options.headers
|
|
5543
5852
|
);
|
|
5544
|
-
if (
|
|
5853
|
+
if (isBackground) {
|
|
5545
5854
|
return this.doStreamBackground({
|
|
5546
5855
|
args,
|
|
5547
5856
|
warnings,
|
|
@@ -5657,6 +5966,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5657
5966
|
};
|
|
5658
5967
|
}
|
|
5659
5968
|
};
|
|
5969
|
+
var INTERACTIONS_API_REVISION_HEADER = {
|
|
5970
|
+
"Api-Revision": "2026-05-20"
|
|
5971
|
+
};
|
|
5660
5972
|
function pruneUndefined(obj) {
|
|
5661
5973
|
const result = {};
|
|
5662
5974
|
for (const [key, value] of Object.entries(obj)) {
|