@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
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
* Internal TypeScript types for the Gemini Interactions API wire format.
|
|
3
3
|
*
|
|
4
4
|
* Mirrors the public types in `googleapis/js-genai`:
|
|
5
|
-
* `src/interactions/resources/interactions.ts`.
|
|
6
|
-
* thought happy path); further content/tool block variants are scaffolded as
|
|
7
|
-
* `unknown` here and populated in subsequent tasks.
|
|
5
|
+
* `src/interactions/resources/interactions.ts`.
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
8
|
export type GoogleInteractionsTextContent = {
|
|
11
9
|
type: 'text';
|
|
12
10
|
text: string;
|
|
13
|
-
annotations?: Array<
|
|
11
|
+
annotations?: Array<GoogleInteractionsAnnotation | { type: string }>;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export type GoogleInteractionsImageContent = {
|
|
@@ -49,20 +47,6 @@ export type GoogleInteractionsThoughtSummaryItem =
|
|
|
49
47
|
| GoogleInteractionsTextContent
|
|
50
48
|
| GoogleInteractionsImageContent;
|
|
51
49
|
|
|
52
|
-
export type GoogleInteractionsThoughtContent = {
|
|
53
|
-
type: 'thought';
|
|
54
|
-
signature?: string;
|
|
55
|
-
summary?: Array<GoogleInteractionsThoughtSummaryItem>;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type GoogleInteractionsFunctionCallContent = {
|
|
59
|
-
type: 'function_call';
|
|
60
|
-
id: string;
|
|
61
|
-
name: string;
|
|
62
|
-
arguments: Record<string, unknown>;
|
|
63
|
-
signature?: string;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
50
|
export type GoogleInteractionsFunctionResultContent = {
|
|
67
51
|
type: 'function_result';
|
|
68
52
|
call_id: string;
|
|
@@ -76,9 +60,11 @@ export type GoogleInteractionsFunctionResultContent = {
|
|
|
76
60
|
};
|
|
77
61
|
|
|
78
62
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* `
|
|
63
|
+
* Annotation types attached to a `text` content block:
|
|
64
|
+
* - `url_citation` (web) — `url` + optional `title`
|
|
65
|
+
* - `file_citation` — `url` for the citation target; optional `document_uri`
|
|
66
|
+
* / `file_name` for doc references
|
|
67
|
+
* - `place_citation` — Maps grounding, carries `url`
|
|
82
68
|
*/
|
|
83
69
|
export type GoogleInteractionsURLCitation = {
|
|
84
70
|
type: 'url_citation';
|
|
@@ -88,14 +74,11 @@ export type GoogleInteractionsURLCitation = {
|
|
|
88
74
|
end_index?: number;
|
|
89
75
|
};
|
|
90
76
|
|
|
91
|
-
/**
|
|
92
|
-
* File citation annotation for `text` content blocks.
|
|
93
|
-
*/
|
|
94
77
|
export type GoogleInteractionsFileCitation = {
|
|
95
78
|
type: 'file_citation';
|
|
96
79
|
file_name?: string;
|
|
97
80
|
document_uri?: string;
|
|
98
|
-
|
|
81
|
+
url?: string;
|
|
99
82
|
page_number?: number;
|
|
100
83
|
media_id?: string;
|
|
101
84
|
start_index?: number;
|
|
@@ -103,9 +86,6 @@ export type GoogleInteractionsFileCitation = {
|
|
|
103
86
|
custom_metadata?: Record<string, unknown>;
|
|
104
87
|
};
|
|
105
88
|
|
|
106
|
-
/**
|
|
107
|
-
* Place citation annotation for Google Maps grounding.
|
|
108
|
-
*/
|
|
109
89
|
export type GoogleInteractionsPlaceCitation = {
|
|
110
90
|
type: 'place_citation';
|
|
111
91
|
name?: string;
|
|
@@ -125,28 +105,42 @@ export type GoogleInteractionsAnnotation =
|
|
|
125
105
|
| GoogleInteractionsFileCitation
|
|
126
106
|
| GoogleInteractionsPlaceCitation;
|
|
127
107
|
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* `function_call
|
|
108
|
+
/*
|
|
109
|
+
* --- Step payload shapes ---
|
|
110
|
+
*
|
|
111
|
+
* `function_call`, `thought`, and the built-in `*_call`/`*_result` are
|
|
112
|
+
* top-level **step** types — their fields live directly on the step object
|
|
113
|
+
* (no `content` indirection). The types below model those payloads; the step
|
|
114
|
+
* wrapper (`type` discriminator + payload) is `GoogleInteractionsStep`
|
|
115
|
+
* further down.
|
|
132
116
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
|
|
118
|
+
export type GoogleInteractionsFunctionCallStepPayload = {
|
|
119
|
+
id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
arguments: Record<string, unknown>;
|
|
122
|
+
signature?: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type GoogleInteractionsThoughtStepPayload = {
|
|
126
|
+
signature?: string;
|
|
127
|
+
summary?: Array<GoogleInteractionsThoughtSummaryItem>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type GoogleInteractionsCodeExecutionCallStepPayload = {
|
|
135
131
|
id: string;
|
|
136
132
|
arguments?: { code?: string; language?: string };
|
|
137
133
|
signature?: string;
|
|
138
134
|
};
|
|
139
135
|
|
|
140
|
-
export type
|
|
141
|
-
type: 'code_execution_result';
|
|
136
|
+
export type GoogleInteractionsCodeExecutionResultStepPayload = {
|
|
142
137
|
call_id: string;
|
|
143
138
|
result?: string;
|
|
144
139
|
is_error?: boolean;
|
|
145
140
|
signature?: string;
|
|
146
141
|
};
|
|
147
142
|
|
|
148
|
-
export type
|
|
149
|
-
type: 'url_context_call';
|
|
143
|
+
export type GoogleInteractionsURLContextCallStepPayload = {
|
|
150
144
|
id: string;
|
|
151
145
|
arguments?: { urls?: Array<string> };
|
|
152
146
|
signature?: string;
|
|
@@ -157,16 +151,14 @@ export type GoogleInteractionsURLContextResultEntry = {
|
|
|
157
151
|
status?: 'success' | 'error' | 'paywall' | 'unsafe' | string;
|
|
158
152
|
};
|
|
159
153
|
|
|
160
|
-
export type
|
|
161
|
-
type: 'url_context_result';
|
|
154
|
+
export type GoogleInteractionsURLContextResultStepPayload = {
|
|
162
155
|
call_id: string;
|
|
163
156
|
result?: Array<GoogleInteractionsURLContextResultEntry>;
|
|
164
157
|
is_error?: boolean;
|
|
165
158
|
signature?: string;
|
|
166
159
|
};
|
|
167
160
|
|
|
168
|
-
export type
|
|
169
|
-
type: 'google_search_call';
|
|
161
|
+
export type GoogleInteractionsGoogleSearchCallStepPayload = {
|
|
170
162
|
id: string;
|
|
171
163
|
arguments?: { queries?: Array<string> };
|
|
172
164
|
search_type?: 'web_search' | 'image_search' | 'enterprise_web_search';
|
|
@@ -179,36 +171,25 @@ export type GoogleInteractionsGoogleSearchResultEntry = {
|
|
|
179
171
|
title?: string;
|
|
180
172
|
};
|
|
181
173
|
|
|
182
|
-
export type
|
|
183
|
-
type: 'google_search_result';
|
|
174
|
+
export type GoogleInteractionsGoogleSearchResultStepPayload = {
|
|
184
175
|
call_id: string;
|
|
185
176
|
result?: Array<GoogleInteractionsGoogleSearchResultEntry>;
|
|
186
177
|
is_error?: boolean;
|
|
187
178
|
signature?: string;
|
|
188
179
|
};
|
|
189
180
|
|
|
190
|
-
export type
|
|
191
|
-
type: 'file_search_call';
|
|
181
|
+
export type GoogleInteractionsFileSearchCallStepPayload = {
|
|
192
182
|
id: string;
|
|
193
183
|
signature?: string;
|
|
194
184
|
};
|
|
195
185
|
|
|
196
|
-
export type
|
|
197
|
-
file_name?: string;
|
|
198
|
-
document_uri?: string;
|
|
199
|
-
title?: string;
|
|
200
|
-
source?: string;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export type GoogleInteractionsFileSearchResultContent = {
|
|
204
|
-
type: 'file_search_result';
|
|
186
|
+
export type GoogleInteractionsFileSearchResultStepPayload = {
|
|
205
187
|
call_id: string;
|
|
206
188
|
result?: Array<unknown>;
|
|
207
189
|
signature?: string;
|
|
208
190
|
};
|
|
209
191
|
|
|
210
|
-
export type
|
|
211
|
-
type: 'google_maps_call';
|
|
192
|
+
export type GoogleInteractionsGoogleMapsCallStepPayload = {
|
|
212
193
|
id: string;
|
|
213
194
|
arguments?: { queries?: Array<string> };
|
|
214
195
|
signature?: string;
|
|
@@ -230,15 +211,13 @@ export type GoogleInteractionsGoogleMapsResultEntry = {
|
|
|
230
211
|
widget_context_token?: string;
|
|
231
212
|
};
|
|
232
213
|
|
|
233
|
-
export type
|
|
234
|
-
type: 'google_maps_result';
|
|
214
|
+
export type GoogleInteractionsGoogleMapsResultStepPayload = {
|
|
235
215
|
call_id: string;
|
|
236
216
|
result?: Array<GoogleInteractionsGoogleMapsResultEntry>;
|
|
237
217
|
signature?: string;
|
|
238
218
|
};
|
|
239
219
|
|
|
240
|
-
export type
|
|
241
|
-
type: 'mcp_server_tool_call';
|
|
220
|
+
export type GoogleInteractionsMCPServerToolCallStepPayload = {
|
|
242
221
|
id: string;
|
|
243
222
|
name: string;
|
|
244
223
|
server_name: string;
|
|
@@ -246,8 +225,7 @@ export type GoogleInteractionsMCPServerToolCallContent = {
|
|
|
246
225
|
signature?: string;
|
|
247
226
|
};
|
|
248
227
|
|
|
249
|
-
export type
|
|
250
|
-
type: 'mcp_server_tool_result';
|
|
228
|
+
export type GoogleInteractionsMCPServerToolResultStepPayload = {
|
|
251
229
|
call_id: string;
|
|
252
230
|
result?: unknown;
|
|
253
231
|
name?: string;
|
|
@@ -255,49 +233,96 @@ export type GoogleInteractionsMCPServerToolResultContent = {
|
|
|
255
233
|
signature?: string;
|
|
256
234
|
};
|
|
257
235
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
236
|
+
/*
|
|
237
|
+
* Discriminated step union — the elements of `response.steps[]` and the
|
|
238
|
+
* `step` field on `step.start` SSE events.
|
|
239
|
+
*/
|
|
240
|
+
export type GoogleInteractionsModelOutputStep = {
|
|
241
|
+
type: 'model_output';
|
|
242
|
+
content?: Array<GoogleInteractionsContentBlock>;
|
|
243
|
+
};
|
|
265
244
|
|
|
266
|
-
export type
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
| GoogleInteractionsFileSearchResultContent
|
|
271
|
-
| GoogleInteractionsGoogleMapsResultContent
|
|
272
|
-
| GoogleInteractionsMCPServerToolResultContent;
|
|
245
|
+
export type GoogleInteractionsUserInputStep = {
|
|
246
|
+
type: 'user_input';
|
|
247
|
+
content?: Array<GoogleInteractionsContentBlock>;
|
|
248
|
+
};
|
|
273
249
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
250
|
+
export type GoogleInteractionsFunctionCallStep = {
|
|
251
|
+
type: 'function_call';
|
|
252
|
+
} & GoogleInteractionsFunctionCallStepPayload;
|
|
253
|
+
|
|
254
|
+
export type GoogleInteractionsThoughtStep = {
|
|
255
|
+
type: 'thought';
|
|
256
|
+
} & GoogleInteractionsThoughtStepPayload;
|
|
257
|
+
|
|
258
|
+
export type GoogleInteractionsBuiltinToolCallStep =
|
|
259
|
+
| ({
|
|
260
|
+
type: 'google_search_call';
|
|
261
|
+
} & GoogleInteractionsGoogleSearchCallStepPayload)
|
|
262
|
+
| ({
|
|
263
|
+
type: 'code_execution_call';
|
|
264
|
+
} & GoogleInteractionsCodeExecutionCallStepPayload)
|
|
265
|
+
| ({ type: 'url_context_call' } & GoogleInteractionsURLContextCallStepPayload)
|
|
266
|
+
| ({ type: 'file_search_call' } & GoogleInteractionsFileSearchCallStepPayload)
|
|
267
|
+
| ({ type: 'google_maps_call' } & GoogleInteractionsGoogleMapsCallStepPayload)
|
|
268
|
+
| ({
|
|
269
|
+
type: 'mcp_server_tool_call';
|
|
270
|
+
} & GoogleInteractionsMCPServerToolCallStepPayload);
|
|
271
|
+
|
|
272
|
+
export type GoogleInteractionsBuiltinToolResultStep =
|
|
273
|
+
| ({
|
|
274
|
+
type: 'google_search_result';
|
|
275
|
+
} & GoogleInteractionsGoogleSearchResultStepPayload)
|
|
276
|
+
| ({
|
|
277
|
+
type: 'code_execution_result';
|
|
278
|
+
} & GoogleInteractionsCodeExecutionResultStepPayload)
|
|
279
|
+
| ({
|
|
280
|
+
type: 'url_context_result';
|
|
281
|
+
} & GoogleInteractionsURLContextResultStepPayload)
|
|
282
|
+
| ({
|
|
283
|
+
type: 'file_search_result';
|
|
284
|
+
} & GoogleInteractionsFileSearchResultStepPayload)
|
|
285
|
+
| ({
|
|
286
|
+
type: 'google_maps_result';
|
|
287
|
+
} & GoogleInteractionsGoogleMapsResultStepPayload)
|
|
288
|
+
| ({
|
|
289
|
+
type: 'mcp_server_tool_result';
|
|
290
|
+
} & GoogleInteractionsMCPServerToolResultStepPayload);
|
|
291
|
+
|
|
292
|
+
export type GoogleInteractionsStep =
|
|
293
|
+
| GoogleInteractionsUserInputStep
|
|
294
|
+
| GoogleInteractionsModelOutputStep
|
|
295
|
+
| GoogleInteractionsFunctionCallStep
|
|
296
|
+
| GoogleInteractionsThoughtStep
|
|
297
|
+
| GoogleInteractionsBuiltinToolCallStep
|
|
298
|
+
| GoogleInteractionsBuiltinToolResultStep
|
|
299
|
+
| { type: string; [k: string]: unknown };
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
* Inner content-block types (what lives inside `model_output.content[]` and
|
|
303
|
+
* `user_input.content[]`). Function calls, thoughts, and built-in tool
|
|
304
|
+
* call/result blocks are steps, not content blocks.
|
|
279
305
|
*/
|
|
280
|
-
export type
|
|
306
|
+
export type GoogleInteractionsContentBlock =
|
|
281
307
|
| GoogleInteractionsTextContent
|
|
282
308
|
| GoogleInteractionsImageContent
|
|
283
309
|
| GoogleInteractionsAudioContent
|
|
284
310
|
| GoogleInteractionsDocumentContent
|
|
285
311
|
| GoogleInteractionsVideoContent
|
|
286
|
-
| GoogleInteractionsThoughtContent
|
|
287
|
-
| GoogleInteractionsFunctionCallContent
|
|
288
312
|
| GoogleInteractionsFunctionResultContent
|
|
289
313
|
| { type: string; [k: string]: unknown };
|
|
290
314
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
315
|
+
/**
|
|
316
|
+
* Alias kept for the file-part converter surface; identical to
|
|
317
|
+
* `GoogleInteractionsContentBlock`.
|
|
318
|
+
*/
|
|
319
|
+
export type GoogleInteractionsContent = GoogleInteractionsContentBlock;
|
|
295
320
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
321
|
+
/*
|
|
322
|
+
* `input` is an array of steps. A single-turn user prompt is sent as
|
|
323
|
+
* `[{ type: 'user_input', content: [...] }]`.
|
|
324
|
+
*/
|
|
325
|
+
export type GoogleInteractionsInput = Array<GoogleInteractionsStep>;
|
|
301
326
|
|
|
302
327
|
export type GoogleInteractionsTool =
|
|
303
328
|
| {
|
|
@@ -381,25 +406,58 @@ export type GoogleInteractionsResponseModality =
|
|
|
381
406
|
|
|
382
407
|
export type GoogleInteractionsServiceTier = 'flex' | 'standard' | 'priority';
|
|
383
408
|
|
|
384
|
-
export type
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
409
|
+
export type GoogleInteractionsAspectRatio =
|
|
410
|
+
| '1:1'
|
|
411
|
+
| '2:3'
|
|
412
|
+
| '3:2'
|
|
413
|
+
| '3:4'
|
|
414
|
+
| '4:3'
|
|
415
|
+
| '4:5'
|
|
416
|
+
| '5:4'
|
|
417
|
+
| '9:16'
|
|
418
|
+
| '16:9'
|
|
419
|
+
| '21:9'
|
|
420
|
+
| '1:8'
|
|
421
|
+
| '8:1'
|
|
422
|
+
| '1:4'
|
|
423
|
+
| '4:1';
|
|
424
|
+
|
|
425
|
+
export type GoogleInteractionsImageSize = '1K' | '2K' | '4K' | '512';
|
|
426
|
+
|
|
427
|
+
/*
|
|
428
|
+
* `response_format` is a polymorphic entry. Multiple modalities are requested
|
|
429
|
+
* by sending an array of entries. Entries the SDK constructs:
|
|
430
|
+
*
|
|
431
|
+
* { type: 'text', mime_type: 'application/json', schema: <JSONSchema> }
|
|
432
|
+
* -- structured output (JSON mode). `mime_type` is required; `schema` is
|
|
433
|
+
* optional but recommended.
|
|
434
|
+
*
|
|
435
|
+
* { type: 'image', mime_type, aspect_ratio?, image_size? }
|
|
436
|
+
* -- image generation. `mime_type` defaults to `image/png`.
|
|
437
|
+
*/
|
|
438
|
+
export type GoogleInteractionsResponseFormatTextEntry = {
|
|
439
|
+
type: 'text';
|
|
440
|
+
mime_type?: string;
|
|
441
|
+
schema?: unknown;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
export type GoogleInteractionsResponseFormatImageEntry = {
|
|
445
|
+
type: 'image';
|
|
446
|
+
mime_type?: string;
|
|
447
|
+
aspect_ratio?: GoogleInteractionsAspectRatio;
|
|
448
|
+
image_size?: GoogleInteractionsImageSize;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
export type GoogleInteractionsResponseFormatAudioEntry = {
|
|
452
|
+
type: 'audio';
|
|
453
|
+
mime_type?: string;
|
|
401
454
|
};
|
|
402
455
|
|
|
456
|
+
export type GoogleInteractionsResponseFormatEntry =
|
|
457
|
+
| GoogleInteractionsResponseFormatTextEntry
|
|
458
|
+
| GoogleInteractionsResponseFormatImageEntry
|
|
459
|
+
| GoogleInteractionsResponseFormatAudioEntry;
|
|
460
|
+
|
|
403
461
|
export type GoogleInteractionsGenerationConfig = {
|
|
404
462
|
temperature?: number;
|
|
405
463
|
top_p?: number;
|
|
@@ -408,7 +466,6 @@ export type GoogleInteractionsGenerationConfig = {
|
|
|
408
466
|
max_output_tokens?: number;
|
|
409
467
|
thinking_level?: GoogleInteractionsThinkingLevel;
|
|
410
468
|
thinking_summaries?: GoogleInteractionsThinkingSummaries;
|
|
411
|
-
image_config?: GoogleInteractionsImageConfig;
|
|
412
469
|
tool_choice?: GoogleInteractionsToolChoice;
|
|
413
470
|
};
|
|
414
471
|
|
|
@@ -421,14 +478,62 @@ export type GoogleInteractionsAgentConfig =
|
|
|
421
478
|
collaborative_planning?: boolean;
|
|
422
479
|
};
|
|
423
480
|
|
|
481
|
+
export type GoogleInteractionsGcsSource = {
|
|
482
|
+
type: 'gcs';
|
|
483
|
+
source: string;
|
|
484
|
+
target?: string;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
export type GoogleInteractionsRepositorySource = {
|
|
488
|
+
type: 'repository';
|
|
489
|
+
source: string;
|
|
490
|
+
target?: string;
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
export type GoogleInteractionsInlineSource = {
|
|
494
|
+
type: 'inline';
|
|
495
|
+
content: string;
|
|
496
|
+
target: string;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
export type GoogleInteractionsEnvironmentSource =
|
|
500
|
+
| GoogleInteractionsGcsSource
|
|
501
|
+
| GoogleInteractionsRepositorySource
|
|
502
|
+
| GoogleInteractionsInlineSource;
|
|
503
|
+
|
|
504
|
+
export type GoogleInteractionsNetworkAllowlistEntry = {
|
|
505
|
+
domain: string;
|
|
506
|
+
transform?: Array<Record<string, string>>;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
export type GoogleInteractionsNetworkConfig =
|
|
510
|
+
| 'disabled'
|
|
511
|
+
| { allowlist: Array<GoogleInteractionsNetworkAllowlistEntry> };
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Environment configuration for the agent sandbox.
|
|
515
|
+
*
|
|
516
|
+
* - `"remote"`: provision a fresh sandbox for this call.
|
|
517
|
+
* - any other string: an existing `environment_id` to reuse (forks the
|
|
518
|
+
* previous sandbox so its filesystem and installed packages persist).
|
|
519
|
+
* - object form: provision a fresh sandbox and preload it with `sources`
|
|
520
|
+
* and/or constrain outbound traffic via `network`.
|
|
521
|
+
*/
|
|
522
|
+
export type GoogleInteractionsEnvironment =
|
|
523
|
+
| string
|
|
524
|
+
| {
|
|
525
|
+
type: 'remote';
|
|
526
|
+
sources?: Array<GoogleInteractionsEnvironmentSource>;
|
|
527
|
+
network?: GoogleInteractionsNetworkConfig;
|
|
528
|
+
};
|
|
529
|
+
|
|
424
530
|
export type GoogleInteractionsRequestBody = {
|
|
425
531
|
model?: string;
|
|
426
532
|
agent?: string;
|
|
427
533
|
input: GoogleInteractionsInput;
|
|
428
534
|
system_instruction?: string;
|
|
429
535
|
tools?: Array<GoogleInteractionsTool>;
|
|
430
|
-
response_format?:
|
|
431
|
-
response_mime_type?: string;
|
|
536
|
+
response_format?: Array<GoogleInteractionsResponseFormatEntry>;
|
|
432
537
|
response_modalities?: Array<GoogleInteractionsResponseModality>;
|
|
433
538
|
generation_config?: GoogleInteractionsGenerationConfig;
|
|
434
539
|
agent_config?: GoogleInteractionsAgentConfig;
|
|
@@ -436,6 +541,7 @@ export type GoogleInteractionsRequestBody = {
|
|
|
436
541
|
service_tier?: GoogleInteractionsServiceTier;
|
|
437
542
|
store?: boolean;
|
|
438
543
|
stream?: boolean;
|
|
544
|
+
environment?: GoogleInteractionsEnvironment;
|
|
439
545
|
/**
|
|
440
546
|
* Run the interaction in the background. The POST returns immediately with a
|
|
441
547
|
* non-terminal status (`in_progress` / `requires_action`); the client must
|
|
@@ -455,3 +561,22 @@ export type GoogleInteractionsStatus =
|
|
|
455
561
|
| 'failed'
|
|
456
562
|
| 'cancelled'
|
|
457
563
|
| 'incomplete';
|
|
564
|
+
|
|
565
|
+
/*
|
|
566
|
+
* Aliases used by the source extractor; structurally equivalent to their
|
|
567
|
+
* step-payload counterparts.
|
|
568
|
+
*/
|
|
569
|
+
export type GoogleInteractionsBuiltinToolResultContent =
|
|
570
|
+
GoogleInteractionsBuiltinToolResultStep;
|
|
571
|
+
export type GoogleInteractionsGoogleSearchResultContent = Extract<
|
|
572
|
+
GoogleInteractionsBuiltinToolResultStep,
|
|
573
|
+
{ type: 'google_search_result' }
|
|
574
|
+
>;
|
|
575
|
+
export type GoogleInteractionsGoogleMapsResultContent = Extract<
|
|
576
|
+
GoogleInteractionsBuiltinToolResultStep,
|
|
577
|
+
{ type: 'google_maps_result' }
|
|
578
|
+
>;
|
|
579
|
+
export type GoogleInteractionsURLContextResultContent = Extract<
|
|
580
|
+
GoogleInteractionsBuiltinToolResultStep,
|
|
581
|
+
{ type: 'url_context_result' }
|
|
582
|
+
>;
|
|
@@ -2,11 +2,9 @@ import type { LanguageModelV3FinishReason } from '@ai-sdk/provider';
|
|
|
2
2
|
import type { GoogleInteractionsStatus } from './google-interactions-prompt';
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* client-side function call (the API itself signals this via `requires_action`,
|
|
9
|
-
* but `completed + hasFunctionCall` also occurs in practice).
|
|
5
|
+
* `tool-calls` is selected when the response includes a client-side function
|
|
6
|
+
* call. The API itself signals this via `requires_action`, but
|
|
7
|
+
* `completed + hasFunctionCall` also occurs in practice.
|
|
10
8
|
*/
|
|
11
9
|
export function mapGoogleInteractionsFinishReason({
|
|
12
10
|
status,
|