@ai-sdk/google 4.0.0-canary.67 → 4.0.0-canary.69
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 +13 -0
- package/dist/index.d.ts +37 -11
- package/dist/index.js +158 -40
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +40 -30
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +197 -48
- package/package.json +1 -1
- package/src/google-language-model-options.ts +1 -0
- package/src/google-language-model.ts +58 -38
- package/src/google-provider.ts +9 -4
- package/src/interactions/google-interactions-agent.ts +6 -7
- package/src/interactions/google-interactions-language-model-options.ts +65 -0
- package/src/interactions/google-interactions-language-model.ts +73 -22
- package/src/interactions/google-interactions-prompt.ts +50 -0
- package/src/interactions/stream-google-interactions.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.0-canary.69
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7f04802: feat(provider/google): add support for managed agents in the Interactions API
|
|
8
|
+
|
|
9
|
+
## 4.0.0-canary.68
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a2609df: fix(google): fix streaming tool call args
|
|
14
|
+
- 546cefe: feat(provider/google): add `gemini-3.5-flash`
|
|
15
|
+
|
|
3
16
|
## 4.0.0-canary.67
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
11
11
|
}>;
|
|
12
12
|
type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
|
|
13
13
|
|
|
14
|
-
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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | '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 & {});
|
|
14
|
+
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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | '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 & {});
|
|
15
15
|
declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
16
16
|
responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
|
|
17
17
|
thinkingConfig?: {
|
|
@@ -268,7 +268,7 @@ type GoogleFilesUploadOptions = {
|
|
|
268
268
|
* the two surfaces (`:generateContent` vs `/interactions`) are independent and
|
|
269
269
|
* may diverge over time.
|
|
270
270
|
*/
|
|
271
|
-
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' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
271
|
+
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' | 'lyria-3-clip-preview' | 'lyria-3-pro-preview' | (string & {});
|
|
272
272
|
/**
|
|
273
273
|
* Provider-options schema for `google.interactions(...)` calls. Read from the
|
|
274
274
|
* shared `providerOptions.google.*` namespace (per PRD); per-call options that
|
|
@@ -318,6 +318,29 @@ declare const googleInteractionsLanguageModelOptions: _ai_sdk_provider_utils.Laz
|
|
|
318
318
|
signature?: string | null | undefined;
|
|
319
319
|
interactionId?: string | null | undefined;
|
|
320
320
|
pollingTimeoutMs?: number | null | undefined;
|
|
321
|
+
background?: boolean | null | undefined;
|
|
322
|
+
environment?: string | {
|
|
323
|
+
type: "remote";
|
|
324
|
+
sources?: ({
|
|
325
|
+
type: "gcs";
|
|
326
|
+
source: string;
|
|
327
|
+
target?: string | null | undefined;
|
|
328
|
+
} | {
|
|
329
|
+
type: "repository";
|
|
330
|
+
source: string;
|
|
331
|
+
target?: string | null | undefined;
|
|
332
|
+
} | {
|
|
333
|
+
type: "inline";
|
|
334
|
+
content: string;
|
|
335
|
+
target: string;
|
|
336
|
+
})[] | null | undefined;
|
|
337
|
+
network?: "disabled" | {
|
|
338
|
+
allowlist: {
|
|
339
|
+
domain: string;
|
|
340
|
+
transform?: Record<string, string>[] | null | undefined;
|
|
341
|
+
}[];
|
|
342
|
+
} | null | undefined;
|
|
343
|
+
} | null | undefined;
|
|
321
344
|
}>;
|
|
322
345
|
type GoogleLanguageModelInteractionsOptions = InferSchema<typeof googleInteractionsLanguageModelOptions>;
|
|
323
346
|
|
|
@@ -347,14 +370,12 @@ type GoogleInteractionsProviderMetadata = {
|
|
|
347
370
|
* Type-only module: declares the union of supported Gemini Interactions agent
|
|
348
371
|
* names. Used by the `google.interactions({ agent })` factory branch.
|
|
349
372
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* passing an unknown agent name is a compile-time error. Add new agents here
|
|
355
|
-
* as Google publishes them.
|
|
373
|
+
* Strict string-literal union: unknown agent names are a compile-time error.
|
|
374
|
+
* User-defined agents (created via the `/agents` endpoint) are addressed by
|
|
375
|
+
* a separate `{ managedAgent: string }` factory shape — see
|
|
376
|
+
* `GoogleInteractionsModelInput`.
|
|
356
377
|
*/
|
|
357
|
-
type GoogleInteractionsAgentName = 'deep-research-pro-preview-12-2025' | 'deep-research-preview-04-2026' | 'deep-research-max-preview-04-2026';
|
|
378
|
+
type GoogleInteractionsAgentName = 'deep-research-pro-preview-12-2025' | 'deep-research-preview-04-2026' | 'deep-research-max-preview-04-2026' | 'antigravity-preview-05-2026';
|
|
358
379
|
|
|
359
380
|
declare const googleTools: {
|
|
360
381
|
/**
|
|
@@ -486,11 +507,16 @@ interface GoogleProvider extends ProviderV4 {
|
|
|
486
507
|
files(): FilesV4;
|
|
487
508
|
/**
|
|
488
509
|
* Creates a language model targeting the Gemini Interactions API
|
|
489
|
-
* (`POST /v1beta/interactions`). Pass
|
|
490
|
-
*
|
|
510
|
+
* (`POST /v1beta/interactions`). Pass:
|
|
511
|
+
* - a model ID (string),
|
|
512
|
+
* - `{ agent: <name> }` to use a known Gemini agent preset, or
|
|
513
|
+
* - `{ managedAgent: <name> }` to use a user-defined agent created via
|
|
514
|
+
* the `/v1beta/agents` endpoint.
|
|
491
515
|
*/
|
|
492
516
|
interactions(modelIdOrAgent: GoogleInteractionsModelId | {
|
|
493
517
|
agent: GoogleInteractionsAgentName;
|
|
518
|
+
} | {
|
|
519
|
+
managedAgent: string;
|
|
494
520
|
}): LanguageModelV4;
|
|
495
521
|
tools: typeof googleTools;
|
|
496
522
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.0-canary.
|
|
10
|
+
var VERSION = true ? "4.0.0-canary.69" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -1872,6 +1872,34 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1872
1872
|
let lastCodeExecutionToolCallId;
|
|
1873
1873
|
let lastServerToolCallId;
|
|
1874
1874
|
const activeStreamingToolCalls = [];
|
|
1875
|
+
const finishActiveStreamingToolCall = (controller) => {
|
|
1876
|
+
const active = activeStreamingToolCalls.pop();
|
|
1877
|
+
if (active == null) {
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1881
|
+
if (closingDelta.length > 0) {
|
|
1882
|
+
controller.enqueue({
|
|
1883
|
+
type: "tool-input-delta",
|
|
1884
|
+
id: active.toolCallId,
|
|
1885
|
+
delta: closingDelta,
|
|
1886
|
+
providerMetadata: active.providerMetadata
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
controller.enqueue({
|
|
1890
|
+
type: "tool-input-end",
|
|
1891
|
+
id: active.toolCallId,
|
|
1892
|
+
providerMetadata: active.providerMetadata
|
|
1893
|
+
});
|
|
1894
|
+
controller.enqueue({
|
|
1895
|
+
type: "tool-call",
|
|
1896
|
+
toolCallId: active.toolCallId,
|
|
1897
|
+
toolName: active.toolName,
|
|
1898
|
+
input: finalJSON,
|
|
1899
|
+
providerMetadata: active.providerMetadata
|
|
1900
|
+
});
|
|
1901
|
+
hasToolCalls = true;
|
|
1902
|
+
};
|
|
1875
1903
|
return {
|
|
1876
1904
|
stream: response.pipeThrough(
|
|
1877
1905
|
new TransformStream({
|
|
@@ -2073,7 +2101,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2073
2101
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
2074
2102
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
2075
2103
|
if (isStreamingChunk) {
|
|
2076
|
-
if (part.functionCall.name != null
|
|
2104
|
+
if (part.functionCall.name != null) {
|
|
2077
2105
|
const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
|
|
2078
2106
|
const accumulator = new GoogleJSONAccumulator();
|
|
2079
2107
|
activeStreamingToolCalls.push({
|
|
@@ -2089,9 +2117,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2089
2117
|
providerMetadata: providerMeta
|
|
2090
2118
|
});
|
|
2091
2119
|
if (part.functionCall.partialArgs != null) {
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
);
|
|
2120
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2121
|
+
const { textDelta } = accumulator.processPartialArgs(partialArgs);
|
|
2095
2122
|
if (textDelta.length > 0) {
|
|
2096
2123
|
controller.enqueue({
|
|
2097
2124
|
type: "tool-input-delta",
|
|
@@ -2100,12 +2127,14 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2100
2127
|
providerMetadata: providerMeta
|
|
2101
2128
|
});
|
|
2102
2129
|
}
|
|
2130
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2131
|
+
finishActiveStreamingToolCall(controller);
|
|
2132
|
+
}
|
|
2103
2133
|
}
|
|
2104
2134
|
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
2105
2135
|
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2108
|
-
);
|
|
2136
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2137
|
+
const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
|
|
2109
2138
|
if (textDelta.length > 0) {
|
|
2110
2139
|
controller.enqueue({
|
|
2111
2140
|
type: "tool-input-delta",
|
|
@@ -2114,31 +2143,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2114
2143
|
providerMetadata: providerMeta
|
|
2115
2144
|
});
|
|
2116
2145
|
}
|
|
2146
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2147
|
+
finishActiveStreamingToolCall(controller);
|
|
2148
|
+
}
|
|
2117
2149
|
}
|
|
2118
2150
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
2119
|
-
|
|
2120
|
-
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
2121
|
-
if (closingDelta.length > 0) {
|
|
2122
|
-
controller.enqueue({
|
|
2123
|
-
type: "tool-input-delta",
|
|
2124
|
-
id: active.toolCallId,
|
|
2125
|
-
delta: closingDelta,
|
|
2126
|
-
providerMetadata: active.providerMetadata
|
|
2127
|
-
});
|
|
2128
|
-
}
|
|
2129
|
-
controller.enqueue({
|
|
2130
|
-
type: "tool-input-end",
|
|
2131
|
-
id: active.toolCallId,
|
|
2132
|
-
providerMetadata: active.providerMetadata
|
|
2133
|
-
});
|
|
2134
|
-
controller.enqueue({
|
|
2135
|
-
type: "tool-call",
|
|
2136
|
-
toolCallId: active.toolCallId,
|
|
2137
|
-
toolName: active.toolName,
|
|
2138
|
-
input: finalJSON,
|
|
2139
|
-
providerMetadata: active.providerMetadata
|
|
2140
|
-
});
|
|
2141
|
-
hasToolCalls = true;
|
|
2151
|
+
finishActiveStreamingToolCall(controller);
|
|
2142
2152
|
} else if (isCompleteCall) {
|
|
2143
2153
|
const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
|
|
2144
2154
|
const toolName = part.functionCall.name;
|
|
@@ -5039,7 +5049,61 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5039
5049
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5040
5050
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5041
5051
|
*/
|
|
5042
|
-
pollingTimeoutMs: z19.number().int().positive().nullish()
|
|
5052
|
+
pollingTimeoutMs: z19.number().int().positive().nullish(),
|
|
5053
|
+
/**
|
|
5054
|
+
* Run the interaction in the background. Required for agents whose
|
|
5055
|
+
* server-side workflow cannot complete within a single request/response.
|
|
5056
|
+
* When `true`, the POST returns with a non-terminal status and the SDK
|
|
5057
|
+
* polls `GET /interactions/{id}` until the work completes. Some agents
|
|
5058
|
+
* reject `true`; see the agent's documentation for which mode it
|
|
5059
|
+
* requires.
|
|
5060
|
+
*/
|
|
5061
|
+
background: z19.boolean().nullish(),
|
|
5062
|
+
/**
|
|
5063
|
+
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5064
|
+
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
5065
|
+
*
|
|
5066
|
+
* - `"remote"`: provision a fresh sandbox for this call.
|
|
5067
|
+
* - any other string: an existing `environment_id` to reuse.
|
|
5068
|
+
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5069
|
+
* and/or constrain outbound traffic via `network`.
|
|
5070
|
+
*/
|
|
5071
|
+
environment: z19.union([
|
|
5072
|
+
z19.string(),
|
|
5073
|
+
z19.object({
|
|
5074
|
+
type: z19.literal("remote"),
|
|
5075
|
+
sources: z19.array(
|
|
5076
|
+
z19.union([
|
|
5077
|
+
z19.object({
|
|
5078
|
+
type: z19.literal("gcs"),
|
|
5079
|
+
source: z19.string(),
|
|
5080
|
+
target: z19.string().nullish()
|
|
5081
|
+
}),
|
|
5082
|
+
z19.object({
|
|
5083
|
+
type: z19.literal("repository"),
|
|
5084
|
+
source: z19.string(),
|
|
5085
|
+
target: z19.string().nullish()
|
|
5086
|
+
}),
|
|
5087
|
+
z19.object({
|
|
5088
|
+
type: z19.literal("inline"),
|
|
5089
|
+
content: z19.string(),
|
|
5090
|
+
target: z19.string()
|
|
5091
|
+
})
|
|
5092
|
+
])
|
|
5093
|
+
).nullish(),
|
|
5094
|
+
network: z19.union([
|
|
5095
|
+
z19.literal("disabled"),
|
|
5096
|
+
z19.object({
|
|
5097
|
+
allowlist: z19.array(
|
|
5098
|
+
z19.object({
|
|
5099
|
+
domain: z19.string(),
|
|
5100
|
+
transform: z19.array(z19.record(z19.string(), z19.string())).nullish()
|
|
5101
|
+
})
|
|
5102
|
+
)
|
|
5103
|
+
})
|
|
5104
|
+
]).nullish()
|
|
5105
|
+
})
|
|
5106
|
+
]).nullish()
|
|
5043
5107
|
})
|
|
5044
5108
|
)
|
|
5045
5109
|
);
|
|
@@ -5776,6 +5840,9 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5776
5840
|
if (typeof modelOrAgent === "string") {
|
|
5777
5841
|
this.modelId = modelOrAgent;
|
|
5778
5842
|
this.agent = void 0;
|
|
5843
|
+
} else if ("managedAgent" in modelOrAgent) {
|
|
5844
|
+
this.modelId = modelOrAgent.managedAgent;
|
|
5845
|
+
this.agent = modelOrAgent.managedAgent;
|
|
5779
5846
|
} else {
|
|
5780
5847
|
this.modelId = modelOrAgent.agent;
|
|
5781
5848
|
this.agent = modelOrAgent.agent;
|
|
@@ -5816,7 +5883,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5816
5883
|
};
|
|
5817
5884
|
}
|
|
5818
5885
|
async getArgs(options) {
|
|
5819
|
-
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;
|
|
5886
|
+
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;
|
|
5820
5887
|
const warnings = [];
|
|
5821
5888
|
const opts = await parseProviderOptions6({
|
|
5822
5889
|
provider: "google",
|
|
@@ -5973,6 +6040,55 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5973
6040
|
agentConfig = { type: "dynamic" };
|
|
5974
6041
|
}
|
|
5975
6042
|
}
|
|
6043
|
+
let environment;
|
|
6044
|
+
if ((opts == null ? void 0 : opts.environment) != null) {
|
|
6045
|
+
if (!isAgent) {
|
|
6046
|
+
warnings.push({
|
|
6047
|
+
type: "other",
|
|
6048
|
+
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
6049
|
+
});
|
|
6050
|
+
} else if (typeof opts.environment === "string") {
|
|
6051
|
+
environment = opts.environment;
|
|
6052
|
+
} else {
|
|
6053
|
+
const env = opts.environment;
|
|
6054
|
+
const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
|
|
6055
|
+
var _a2;
|
|
6056
|
+
if (s.type === "inline") {
|
|
6057
|
+
return {
|
|
6058
|
+
type: "inline",
|
|
6059
|
+
content: s.content,
|
|
6060
|
+
target: s.target
|
|
6061
|
+
};
|
|
6062
|
+
}
|
|
6063
|
+
return pruneUndefined({
|
|
6064
|
+
type: s.type,
|
|
6065
|
+
source: s.source,
|
|
6066
|
+
target: (_a2 = s.target) != null ? _a2 : void 0
|
|
6067
|
+
});
|
|
6068
|
+
});
|
|
6069
|
+
let network;
|
|
6070
|
+
if (env.network === "disabled") {
|
|
6071
|
+
network = "disabled";
|
|
6072
|
+
} else if (env.network != null) {
|
|
6073
|
+
network = {
|
|
6074
|
+
allowlist: env.network.allowlist.map(
|
|
6075
|
+
(entry) => {
|
|
6076
|
+
var _a2;
|
|
6077
|
+
return pruneUndefined({
|
|
6078
|
+
domain: entry.domain,
|
|
6079
|
+
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
6080
|
+
});
|
|
6081
|
+
}
|
|
6082
|
+
)
|
|
6083
|
+
};
|
|
6084
|
+
}
|
|
6085
|
+
environment = pruneUndefined({
|
|
6086
|
+
type: "remote",
|
|
6087
|
+
sources: sources != null && sources.length > 0 ? sources : void 0,
|
|
6088
|
+
network
|
|
6089
|
+
});
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
5976
6092
|
const args = pruneUndefined({
|
|
5977
6093
|
...isAgent ? { agent: this.agent } : { model: this.modelId },
|
|
5978
6094
|
input,
|
|
@@ -5980,18 +6096,20 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5980
6096
|
tools: toolsForBody,
|
|
5981
6097
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5982
6098
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5983
|
-
previous_interaction_id: (
|
|
5984
|
-
service_tier: (
|
|
5985
|
-
store: (
|
|
6099
|
+
previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
|
|
6100
|
+
service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
|
|
6101
|
+
store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
|
|
5986
6102
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5987
6103
|
agent_config: agentConfig,
|
|
5988
|
-
|
|
6104
|
+
environment,
|
|
6105
|
+
background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
|
|
5989
6106
|
});
|
|
5990
6107
|
return {
|
|
5991
6108
|
args,
|
|
5992
6109
|
warnings,
|
|
5993
6110
|
isAgent,
|
|
5994
|
-
|
|
6111
|
+
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
6112
|
+
pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
|
|
5995
6113
|
};
|
|
5996
6114
|
}
|
|
5997
6115
|
async doGenerate(options) {
|
|
@@ -6077,14 +6195,14 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6077
6195
|
}
|
|
6078
6196
|
async doStream(options) {
|
|
6079
6197
|
var _a;
|
|
6080
|
-
const { args, warnings,
|
|
6198
|
+
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6081
6199
|
const url = `${this.config.baseURL}/interactions`;
|
|
6082
6200
|
const mergedHeaders = combineHeaders7(
|
|
6083
6201
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6084
6202
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
6085
6203
|
options.headers
|
|
6086
6204
|
);
|
|
6087
|
-
if (
|
|
6205
|
+
if (isBackground) {
|
|
6088
6206
|
return this.doStreamBackground({
|
|
6089
6207
|
args,
|
|
6090
6208
|
warnings,
|