@ai-sdk/google 4.0.62 → 4.0.64
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 +15 -0
- package/dist/index.d.ts +32 -3
- package/dist/index.js +277 -106
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -4
- package/dist/internal/index.js +195 -32
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +135 -30
- package/package.json +1 -1
- package/src/convert-json-schema-to-openapi-schema.ts +10 -0
- package/src/google-batch.ts +82 -70
- package/src/google-language-model-options.ts +1 -0
- package/src/google-language-model.ts +35 -8
- package/src/index.ts +1 -0
- package/src/interactions/build-google-interactions-stream-transform.ts +52 -1
- package/src/interactions/convert-to-google-interactions-input.ts +99 -0
- package/src/interactions/google-interactions-api.ts +18 -0
- package/src/interactions/google-interactions-language-model-options.ts +24 -0
- package/src/interactions/google-interactions-prompt.ts +31 -0
- package/src/interactions/google-interactions-provider-metadata.ts +12 -0
- package/src/interactions/parse-google-interactions-outputs.ts +44 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
2
|
+
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema, createToolNameMapping } from '@ai-sdk/provider-utils';
|
|
3
3
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
4
4
|
import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, SharedV4Warning, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SpeechModelV4 } from '@ai-sdk/provider';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
@@ -67,7 +67,7 @@ type GoogleFunctionResponsePart = {
|
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
70
|
+
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
71
71
|
|
|
72
72
|
type GoogleLanguageModelConfig = {
|
|
73
73
|
provider: string;
|
|
@@ -169,11 +169,13 @@ declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
169
169
|
warnings: SharedV4Warning[];
|
|
170
170
|
providerOptionsNames: readonly string[];
|
|
171
171
|
extraHeaders: Record<string, string> | undefined;
|
|
172
|
+
toolNameMapping: _ai_sdk_provider_utils.ToolNameMapping;
|
|
172
173
|
}>;
|
|
173
|
-
protected convertGenerateContentResponse({ response, warnings, providerOptionsNames, }: {
|
|
174
|
+
protected convertGenerateContentResponse({ response, warnings, providerOptionsNames, toolNameMapping, }: {
|
|
174
175
|
response: InferSchema<typeof responseSchema>;
|
|
175
176
|
warnings: SharedV4Warning[];
|
|
176
177
|
providerOptionsNames: readonly string[];
|
|
178
|
+
toolNameMapping?: ReturnType<typeof createToolNameMapping>;
|
|
177
179
|
}): LanguageModelV4GenerateResult;
|
|
178
180
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
179
181
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
@@ -521,7 +523,7 @@ declare const googleTools: {
|
|
|
521
523
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
522
524
|
* may diverge over time.
|
|
523
525
|
*/
|
|
524
|
-
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
526
|
+
type GoogleInteractionsModelId = 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro' | 'gemini-2.5-pro-preview-tts' | 'gemini-3-flash-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-pro-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-3.8-flash' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
525
527
|
|
|
526
528
|
type GoogleInteractionsConfig = {
|
|
527
529
|
provider: string;
|
package/dist/internal/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/google-language-model.ts
|
|
2
2
|
import {
|
|
3
3
|
combineHeaders,
|
|
4
|
+
createToolNameMapping,
|
|
4
5
|
createEventSourceResponseHandler,
|
|
5
6
|
createJsonResponseHandler,
|
|
6
7
|
generateId,
|
|
@@ -97,6 +98,8 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
97
98
|
format,
|
|
98
99
|
const: constValue,
|
|
99
100
|
minLength,
|
|
101
|
+
minItems,
|
|
102
|
+
maxItems,
|
|
100
103
|
enum: enumValues
|
|
101
104
|
} = jsonSchema;
|
|
102
105
|
const result = {};
|
|
@@ -179,6 +182,12 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
179
182
|
if (minLength !== void 0) {
|
|
180
183
|
result.minLength = minLength;
|
|
181
184
|
}
|
|
185
|
+
if (minItems !== void 0) {
|
|
186
|
+
result.minItems = minItems;
|
|
187
|
+
}
|
|
188
|
+
if (maxItems !== void 0) {
|
|
189
|
+
result.maxItems = maxItems;
|
|
190
|
+
}
|
|
182
191
|
return result;
|
|
183
192
|
}
|
|
184
193
|
function convertJSONSchemaReference({
|
|
@@ -1703,6 +1712,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1703
1712
|
modelId: this.modelId,
|
|
1704
1713
|
isVertexProvider
|
|
1705
1714
|
});
|
|
1715
|
+
const toolNameMapping = createToolNameMapping({
|
|
1716
|
+
tools,
|
|
1717
|
+
providerToolNames: {
|
|
1718
|
+
"google.code_execution": "code_execution"
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1706
1721
|
const resolvedThinking = resolveThinkingConfig({
|
|
1707
1722
|
reasoning,
|
|
1708
1723
|
modelId: this.modelId,
|
|
@@ -1767,15 +1782,17 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1767
1782
|
},
|
|
1768
1783
|
warnings: [...warnings, ...toolWarnings],
|
|
1769
1784
|
providerOptionsNames,
|
|
1770
|
-
extraHeaders: vertexPaygoHeaders
|
|
1785
|
+
extraHeaders: vertexPaygoHeaders,
|
|
1786
|
+
toolNameMapping
|
|
1771
1787
|
};
|
|
1772
1788
|
}
|
|
1773
1789
|
convertGenerateContentResponse({
|
|
1774
1790
|
response,
|
|
1775
1791
|
warnings,
|
|
1776
|
-
providerOptionsNames
|
|
1792
|
+
providerOptionsNames,
|
|
1793
|
+
toolNameMapping
|
|
1777
1794
|
}) {
|
|
1778
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1795
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1779
1796
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1780
1797
|
providerOptionsNames.map((name) => [name, payload])
|
|
1781
1798
|
);
|
|
@@ -1795,7 +1812,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1795
1812
|
content.push({
|
|
1796
1813
|
type: "tool-call",
|
|
1797
1814
|
toolCallId,
|
|
1798
|
-
toolName: "code_execution",
|
|
1815
|
+
toolName: (_h = toolNameMapping == null ? void 0 : toolNameMapping.toCustomToolName("code_execution")) != null ? _h : "code_execution",
|
|
1799
1816
|
input: JSON.stringify(part.executableCode),
|
|
1800
1817
|
providerExecuted: true
|
|
1801
1818
|
});
|
|
@@ -1804,10 +1821,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1804
1821
|
type: "tool-result",
|
|
1805
1822
|
// Results correspond to the most recent executable code part.
|
|
1806
1823
|
toolCallId: lastCodeExecutionToolCallId,
|
|
1807
|
-
toolName: "code_execution",
|
|
1824
|
+
toolName: (_i = toolNameMapping == null ? void 0 : toolNameMapping.toCustomToolName("code_execution")) != null ? _i : "code_execution",
|
|
1808
1825
|
result: {
|
|
1809
1826
|
outcome: part.codeExecutionResult.outcome,
|
|
1810
|
-
output: (
|
|
1827
|
+
output: (_j = part.codeExecutionResult.output) != null ? _j : ""
|
|
1811
1828
|
}
|
|
1812
1829
|
});
|
|
1813
1830
|
} else if ("text" in part && part.text != null) {
|
|
@@ -1831,7 +1848,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1831
1848
|
type: "tool-call",
|
|
1832
1849
|
toolCallId: part.functionCall.id || this.config.generateId(),
|
|
1833
1850
|
toolName: part.functionCall.name,
|
|
1834
|
-
input: JSON.stringify((
|
|
1851
|
+
input: JSON.stringify((_k = part.functionCall.args) != null ? _k : {}),
|
|
1835
1852
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1836
1853
|
thoughtSignature: part.thoughtSignature
|
|
1837
1854
|
}) : void 0
|
|
@@ -1854,7 +1871,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1854
1871
|
type: "tool-call",
|
|
1855
1872
|
toolCallId,
|
|
1856
1873
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1857
|
-
input: JSON.stringify((
|
|
1874
|
+
input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
|
|
1858
1875
|
providerExecuted: true,
|
|
1859
1876
|
dynamic: true,
|
|
1860
1877
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -1872,7 +1889,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1872
1889
|
type: "tool-result",
|
|
1873
1890
|
toolCallId: responseToolCallId,
|
|
1874
1891
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1875
|
-
result: (
|
|
1892
|
+
result: (_m = part.toolResponse.response) != null ? _m : {},
|
|
1876
1893
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1877
1894
|
thoughtSignature: part.thoughtSignature,
|
|
1878
1895
|
serverToolCallId: responseToolCallId,
|
|
@@ -1885,10 +1902,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1885
1902
|
lastServerToolCallId = void 0;
|
|
1886
1903
|
}
|
|
1887
1904
|
}
|
|
1888
|
-
const sources = (
|
|
1905
|
+
const sources = (_n = extractSources({
|
|
1889
1906
|
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
1890
1907
|
generateId: this.config.generateId
|
|
1891
|
-
})) != null ?
|
|
1908
|
+
})) != null ? _n : [];
|
|
1892
1909
|
for (const source of sources) {
|
|
1893
1910
|
content.push(source);
|
|
1894
1911
|
}
|
|
@@ -1907,22 +1924,28 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1907
1924
|
usage: convertGoogleUsage(usageMetadata),
|
|
1908
1925
|
warnings,
|
|
1909
1926
|
providerMetadata: wrapProviderMetadata({
|
|
1910
|
-
promptFeedback: (
|
|
1911
|
-
groundingMetadata: (
|
|
1912
|
-
urlContextMetadata: (
|
|
1913
|
-
safetyRatings: (
|
|
1927
|
+
promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
|
|
1928
|
+
groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
|
|
1929
|
+
urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
|
|
1930
|
+
safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
|
|
1914
1931
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1915
|
-
finishMessage: (
|
|
1916
|
-
serviceTier: (
|
|
1932
|
+
finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
|
|
1933
|
+
serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
|
|
1917
1934
|
}),
|
|
1918
1935
|
response: {
|
|
1919
1936
|
// TODO timestamp, model id
|
|
1920
|
-
id: (
|
|
1937
|
+
id: (_u = response.responseId) != null ? _u : void 0
|
|
1921
1938
|
}
|
|
1922
1939
|
};
|
|
1923
1940
|
}
|
|
1924
1941
|
async doGenerate(options) {
|
|
1925
|
-
const {
|
|
1942
|
+
const {
|
|
1943
|
+
args,
|
|
1944
|
+
warnings,
|
|
1945
|
+
providerOptionsNames,
|
|
1946
|
+
extraHeaders,
|
|
1947
|
+
toolNameMapping
|
|
1948
|
+
} = await this.getArgs(options);
|
|
1926
1949
|
const mergedHeaders = combineHeaders(
|
|
1927
1950
|
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1928
1951
|
options.headers,
|
|
@@ -1946,7 +1969,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1946
1969
|
const result = this.convertGenerateContentResponse({
|
|
1947
1970
|
response,
|
|
1948
1971
|
warnings,
|
|
1949
|
-
providerOptionsNames
|
|
1972
|
+
providerOptionsNames,
|
|
1973
|
+
toolNameMapping
|
|
1950
1974
|
});
|
|
1951
1975
|
return {
|
|
1952
1976
|
...result,
|
|
@@ -1959,7 +1983,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1959
1983
|
};
|
|
1960
1984
|
}
|
|
1961
1985
|
async doStream(options) {
|
|
1962
|
-
const {
|
|
1986
|
+
const {
|
|
1987
|
+
args,
|
|
1988
|
+
warnings,
|
|
1989
|
+
providerOptionsNames,
|
|
1990
|
+
extraHeaders,
|
|
1991
|
+
toolNameMapping
|
|
1992
|
+
} = await this.getArgs(options, { isStreaming: true });
|
|
1963
1993
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1964
1994
|
providerOptionsNames.map((name) => [name, payload])
|
|
1965
1995
|
);
|
|
@@ -2100,7 +2130,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2100
2130
|
controller.enqueue({
|
|
2101
2131
|
type: "tool-call",
|
|
2102
2132
|
toolCallId,
|
|
2103
|
-
toolName: "code_execution",
|
|
2133
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2104
2134
|
input: JSON.stringify(part.executableCode),
|
|
2105
2135
|
providerExecuted: true
|
|
2106
2136
|
});
|
|
@@ -2110,7 +2140,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2110
2140
|
controller.enqueue({
|
|
2111
2141
|
type: "tool-result",
|
|
2112
2142
|
toolCallId,
|
|
2113
|
-
toolName: "code_execution",
|
|
2143
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2114
2144
|
result: {
|
|
2115
2145
|
outcome: part.codeExecutionResult.outcome,
|
|
2116
2146
|
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|
|
@@ -3623,6 +3653,21 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3623
3653
|
}
|
|
3624
3654
|
}
|
|
3625
3655
|
}
|
|
3656
|
+
} else if (stepType === "processing_call" || stepType === "processing_result") {
|
|
3657
|
+
const google = {};
|
|
3658
|
+
if ((step == null ? void 0 : step.signature) != null) google.signature = step.signature;
|
|
3659
|
+
if (interactionId != null) google.interactionId = interactionId;
|
|
3660
|
+
if (stepType === "processing_call") {
|
|
3661
|
+
google.processingId = (step == null ? void 0 : step.id) || blockId;
|
|
3662
|
+
} else {
|
|
3663
|
+
google.processingCallId = (step == null ? void 0 : step.call_id) || blockId;
|
|
3664
|
+
}
|
|
3665
|
+
openBlocks.set(index, {
|
|
3666
|
+
kind: "custom",
|
|
3667
|
+
id: blockId,
|
|
3668
|
+
customKind: `google.${stepType}`,
|
|
3669
|
+
google
|
|
3670
|
+
});
|
|
3626
3671
|
} else if (stepType === "function_call") {
|
|
3627
3672
|
const toolCallId = (step == null ? void 0 : step.id) || blockId;
|
|
3628
3673
|
const toolName = (_b = step == null ? void 0 : step.name) != null ? _b : "unknown";
|
|
@@ -3739,7 +3784,16 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3739
3784
|
break;
|
|
3740
3785
|
}
|
|
3741
3786
|
const delta = event.delta;
|
|
3742
|
-
if (open.kind === "
|
|
3787
|
+
if (open.kind === "custom" && ((delta == null ? void 0 : delta.type) === "processing_call" || (delta == null ? void 0 : delta.type) === "processing_result")) {
|
|
3788
|
+
if (delta.signature != null)
|
|
3789
|
+
open.google.signature = delta.signature;
|
|
3790
|
+
if (delta.type === "processing_call" && delta.id != null && delta.id.length > 0) {
|
|
3791
|
+
open.google.processingId = delta.id;
|
|
3792
|
+
}
|
|
3793
|
+
if (delta.type === "processing_result" && delta.call_id != null && delta.call_id.length > 0) {
|
|
3794
|
+
open.google.processingCallId = delta.call_id;
|
|
3795
|
+
}
|
|
3796
|
+
} else if (open.kind === "text" && (delta == null ? void 0 : delta.type) === "text") {
|
|
3743
3797
|
const text = (_l = delta.text) != null ? _l : "";
|
|
3744
3798
|
if (text.length > 0) {
|
|
3745
3799
|
controller.enqueue({
|
|
@@ -3876,6 +3930,12 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3876
3930
|
input: accumulated,
|
|
3877
3931
|
...providerMetadata ? { providerMetadata } : {}
|
|
3878
3932
|
});
|
|
3933
|
+
} else if (open.kind === "custom") {
|
|
3934
|
+
controller.enqueue({
|
|
3935
|
+
type: "custom",
|
|
3936
|
+
kind: open.customKind,
|
|
3937
|
+
providerMetadata: { google: open.google }
|
|
3938
|
+
});
|
|
3879
3939
|
} else if (open.kind === "builtin_tool_call" && !open.callEmitted) {
|
|
3880
3940
|
controller.enqueue({
|
|
3881
3941
|
type: "tool-call",
|
|
@@ -4000,7 +4060,7 @@ function convertToGoogleInteractionsInput({
|
|
|
4000
4060
|
store,
|
|
4001
4061
|
mediaResolution
|
|
4002
4062
|
}) {
|
|
4003
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4063
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4004
4064
|
const warnings = [];
|
|
4005
4065
|
const incoherentCombo = previousInteractionId != null && store === false;
|
|
4006
4066
|
const shouldCompact = previousInteractionId != null && store !== false;
|
|
@@ -4072,10 +4132,32 @@ function convertToGoogleInteractionsInput({
|
|
|
4072
4132
|
if (fileBlock != null) {
|
|
4073
4133
|
pendingModelOutput.push(fileBlock);
|
|
4074
4134
|
}
|
|
4135
|
+
} else if (part.type === "custom") {
|
|
4136
|
+
flushModelOutput();
|
|
4137
|
+
const google = (_c = part.providerOptions) == null ? void 0 : _c.google;
|
|
4138
|
+
const signature = typeof (google == null ? void 0 : google.signature) === "string" ? google.signature : void 0;
|
|
4139
|
+
if (part.kind === "google.processing_call" && typeof (google == null ? void 0 : google.processingId) === "string") {
|
|
4140
|
+
steps.push({
|
|
4141
|
+
type: "processing_call",
|
|
4142
|
+
id: google.processingId,
|
|
4143
|
+
...signature != null ? { signature } : {}
|
|
4144
|
+
});
|
|
4145
|
+
} else if (part.kind === "google.processing_result" && typeof (google == null ? void 0 : google.processingCallId) === "string") {
|
|
4146
|
+
steps.push({
|
|
4147
|
+
type: "processing_result",
|
|
4148
|
+
call_id: google.processingCallId,
|
|
4149
|
+
...signature != null ? { signature } : {}
|
|
4150
|
+
});
|
|
4151
|
+
} else {
|
|
4152
|
+
warnings.push({
|
|
4153
|
+
type: "other",
|
|
4154
|
+
message: `google.interactions: unsupported or invalid custom assistant content part "${part.kind}"; part dropped.`
|
|
4155
|
+
});
|
|
4156
|
+
}
|
|
4075
4157
|
} else if (part.type === "tool-call") {
|
|
4076
4158
|
flushModelOutput();
|
|
4077
|
-
const signature = (
|
|
4078
|
-
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (
|
|
4159
|
+
const signature = (_e = (_d = part.providerOptions) == null ? void 0 : _d.google) == null ? void 0 : _e.signature;
|
|
4160
|
+
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_f = part.input) != null ? _f : {};
|
|
4079
4161
|
steps.push({
|
|
4080
4162
|
type: "function_call",
|
|
4081
4163
|
id: part.toolCallId,
|
|
@@ -4107,7 +4189,7 @@ function convertToGoogleInteractionsInput({
|
|
|
4107
4189
|
toolCallId: part.toolCallId,
|
|
4108
4190
|
toolName: part.toolName,
|
|
4109
4191
|
output: part.output,
|
|
4110
|
-
signature: (
|
|
4192
|
+
signature: (_h = (_g = part.providerOptions) == null ? void 0 : _g.google) == null ? void 0 : _h.signature,
|
|
4111
4193
|
warnings
|
|
4112
4194
|
});
|
|
4113
4195
|
content.push(block);
|
|
@@ -4160,6 +4242,7 @@ function convertFilePartToContent({
|
|
|
4160
4242
|
return void 0;
|
|
4161
4243
|
}
|
|
4162
4244
|
const resolutionField = mediaResolution != null && (kind === "image" || kind === "video") ? { resolution: mediaResolution } : {};
|
|
4245
|
+
const processingField = kind === "video" ? getVideoProcessingField({ part, warnings }) : {};
|
|
4163
4246
|
switch (part.data.type) {
|
|
4164
4247
|
case "data": {
|
|
4165
4248
|
const mimeType = resolveFullMediaType2({ part });
|
|
@@ -4167,7 +4250,8 @@ function convertFilePartToContent({
|
|
|
4167
4250
|
type: kind,
|
|
4168
4251
|
data: convertToBase642(part.data.data),
|
|
4169
4252
|
mime_type: mimeType,
|
|
4170
|
-
...resolutionField
|
|
4253
|
+
...resolutionField,
|
|
4254
|
+
...processingField
|
|
4171
4255
|
};
|
|
4172
4256
|
}
|
|
4173
4257
|
case "url": {
|
|
@@ -4175,7 +4259,8 @@ function convertFilePartToContent({
|
|
|
4175
4259
|
type: kind,
|
|
4176
4260
|
uri: part.data.url.toString(),
|
|
4177
4261
|
...isFullMediaType2(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
4178
|
-
...resolutionField
|
|
4262
|
+
...resolutionField,
|
|
4263
|
+
...processingField
|
|
4179
4264
|
};
|
|
4180
4265
|
}
|
|
4181
4266
|
case "reference": {
|
|
@@ -4187,11 +4272,41 @@ function convertFilePartToContent({
|
|
|
4187
4272
|
type: kind,
|
|
4188
4273
|
uri,
|
|
4189
4274
|
...isFullMediaType2(part.mediaType) ? { mime_type: part.mediaType } : {},
|
|
4190
|
-
...resolutionField
|
|
4275
|
+
...resolutionField,
|
|
4276
|
+
...processingField
|
|
4191
4277
|
};
|
|
4192
4278
|
}
|
|
4193
4279
|
}
|
|
4194
4280
|
}
|
|
4281
|
+
function getVideoProcessingField({
|
|
4282
|
+
part,
|
|
4283
|
+
warnings
|
|
4284
|
+
}) {
|
|
4285
|
+
var _a, _b;
|
|
4286
|
+
const processing = (_b = (_a = part.providerOptions) == null ? void 0 : _a.google) == null ? void 0 : _b.processing;
|
|
4287
|
+
if (processing == null) {
|
|
4288
|
+
return {};
|
|
4289
|
+
}
|
|
4290
|
+
if (processing === "agentic" || processing === "static") {
|
|
4291
|
+
return { processing };
|
|
4292
|
+
}
|
|
4293
|
+
if (typeof processing === "object" && !Array.isArray(processing) && processing.type === "static") {
|
|
4294
|
+
const config = processing;
|
|
4295
|
+
return {
|
|
4296
|
+
processing: {
|
|
4297
|
+
type: "static",
|
|
4298
|
+
...typeof config.startOffset === "number" ? { start_offset: config.startOffset } : {},
|
|
4299
|
+
...typeof config.endOffset === "number" ? { end_offset: config.endOffset } : {},
|
|
4300
|
+
...typeof config.fps === "number" ? { fps: config.fps } : {}
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4303
|
+
}
|
|
4304
|
+
warnings.push({
|
|
4305
|
+
type: "other",
|
|
4306
|
+
message: 'google.interactions: invalid providerOptions.google.processing on video file part; expected "agentic", "static", or a static processing configuration. Option dropped.'
|
|
4307
|
+
});
|
|
4308
|
+
return {};
|
|
4309
|
+
}
|
|
4195
4310
|
function compactPromptForPreviousInteraction({
|
|
4196
4311
|
prompt,
|
|
4197
4312
|
previousInteractionId
|
|
@@ -4511,6 +4626,16 @@ var stepSchema = () => {
|
|
|
4511
4626
|
signature: z13.string().nullish(),
|
|
4512
4627
|
summary: z13.array(thoughtSummaryItemSchema()).nullish()
|
|
4513
4628
|
}).loose();
|
|
4629
|
+
const processingCallStep = z13.object({
|
|
4630
|
+
type: z13.literal("processing_call"),
|
|
4631
|
+
id: z13.string(),
|
|
4632
|
+
signature: z13.string().nullish()
|
|
4633
|
+
}).loose();
|
|
4634
|
+
const processingResultStep = z13.object({
|
|
4635
|
+
type: z13.literal("processing_result"),
|
|
4636
|
+
call_id: z13.string(),
|
|
4637
|
+
signature: z13.string().nullish()
|
|
4638
|
+
}).loose();
|
|
4514
4639
|
const builtinToolCallStep = z13.object({
|
|
4515
4640
|
type: z13.enum(BUILTIN_TOOL_CALL_STEP_TYPES),
|
|
4516
4641
|
id: z13.string(),
|
|
@@ -4534,6 +4659,8 @@ var stepSchema = () => {
|
|
|
4534
4659
|
modelOutputStep,
|
|
4535
4660
|
functionCallStep,
|
|
4536
4661
|
thoughtStep,
|
|
4662
|
+
processingCallStep,
|
|
4663
|
+
processingResultStep,
|
|
4537
4664
|
builtinToolCallStep,
|
|
4538
4665
|
builtinToolResultStep,
|
|
4539
4666
|
z13.object({ type: z13.string() }).loose()
|
|
@@ -4907,7 +5034,9 @@ var googleInteractionsLanguageModelOptions = lazySchema13(
|
|
|
4907
5034
|
// src/interactions/parse-google-interactions-outputs.ts
|
|
4908
5035
|
function googleProviderMetadata({
|
|
4909
5036
|
signature,
|
|
4910
|
-
interactionId
|
|
5037
|
+
interactionId,
|
|
5038
|
+
processingId,
|
|
5039
|
+
processingCallId
|
|
4911
5040
|
}) {
|
|
4912
5041
|
const google = {};
|
|
4913
5042
|
if (signature != null) {
|
|
@@ -4916,6 +5045,12 @@ function googleProviderMetadata({
|
|
|
4916
5045
|
if (interactionId != null) {
|
|
4917
5046
|
google.interactionId = interactionId;
|
|
4918
5047
|
}
|
|
5048
|
+
if (processingId != null) {
|
|
5049
|
+
google.processingId = processingId;
|
|
5050
|
+
}
|
|
5051
|
+
if (processingCallId != null) {
|
|
5052
|
+
google.processingCallId = processingCallId;
|
|
5053
|
+
}
|
|
4919
5054
|
return Object.keys(google).length > 0 ? { providerMetadata: { google } } : {};
|
|
4920
5055
|
}
|
|
4921
5056
|
var BUILTIN_TOOL_CALL_TYPES2 = /* @__PURE__ */ new Set([
|
|
@@ -5030,6 +5165,34 @@ function parseGoogleInteractionsOutputs({
|
|
|
5030
5165
|
});
|
|
5031
5166
|
break;
|
|
5032
5167
|
}
|
|
5168
|
+
case "processing_call": {
|
|
5169
|
+
const call = step;
|
|
5170
|
+
const processingId = call.id || generateId2();
|
|
5171
|
+
content.push({
|
|
5172
|
+
type: "custom",
|
|
5173
|
+
kind: "google.processing_call",
|
|
5174
|
+
...googleProviderMetadata({
|
|
5175
|
+
signature: call.signature,
|
|
5176
|
+
interactionId,
|
|
5177
|
+
processingId
|
|
5178
|
+
})
|
|
5179
|
+
});
|
|
5180
|
+
break;
|
|
5181
|
+
}
|
|
5182
|
+
case "processing_result": {
|
|
5183
|
+
const result = step;
|
|
5184
|
+
const processingCallId = result.call_id || generateId2();
|
|
5185
|
+
content.push({
|
|
5186
|
+
type: "custom",
|
|
5187
|
+
kind: "google.processing_result",
|
|
5188
|
+
...googleProviderMetadata({
|
|
5189
|
+
signature: result.signature,
|
|
5190
|
+
interactionId,
|
|
5191
|
+
processingCallId
|
|
5192
|
+
})
|
|
5193
|
+
});
|
|
5194
|
+
break;
|
|
5195
|
+
}
|
|
5033
5196
|
case "function_call": {
|
|
5034
5197
|
hasFunctionCall = true;
|
|
5035
5198
|
const call = step;
|