@ai-sdk/google 3.0.74 → 3.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,7 @@ import type {
34
34
  GoogleInteractionsAgentConfig,
35
35
  GoogleInteractionsGenerationConfig,
36
36
  GoogleInteractionsRequestBody,
37
+ GoogleInteractionsResponseFormatEntry,
37
38
  GoogleInteractionsTool,
38
39
  GoogleInteractionsToolChoice,
39
40
  } from './google-interactions-prompt';
@@ -140,28 +141,22 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
140
141
  }
141
142
 
142
143
  /*
143
- * Structured output mapping (resolves PRD Open Q1).
144
+ * `response_format` is a polymorphic array of entries. Three sources
145
+ * contribute, in order:
144
146
  *
145
- * The Interactions API exposes structured output via two top-level body
146
- * fields: `response_mime_type` (always `'application/json'` here) and
147
- * `response_format` (typed as `unknown` in the js-genai SDK). Per the
148
- * canonical sample at
149
- * `googleapis/js-genai/sdk-samples/interactions_structured_output_json.ts`,
150
- * `response_format` accepts a **plain JSON Schema** value directly - no
151
- * wrapping object, no OpenAPI conversion. The js-genai resource type
152
- * (`src/interactions/resources/interactions.ts:1399`) confirms the field is
153
- * passed through verbatim. We therefore send the AI SDK
154
- * `responseFormat.schema` (a `JSONSchema7`) as-is.
155
- *
156
- * If a future API revision rejects plain JSON Schema, fall back to
157
- * `convertJSONSchemaToOpenAPISchema(...)` (already imported by
158
- * `google-language-model.ts`); empirically that has not been needed.
147
+ * 1. AI SDK call-level `responseFormat: { type: 'json', schema }`
148
+ * `{ type: 'text', mime_type: 'application/json', schema }`.
149
+ * 2. `providerOptions.google.responseFormat` (primary path) entries
150
+ * are appended verbatim with camelCase → snake_case translation.
151
+ * 3. `providerOptions.google.imageConfig` (deprecated fallback) — only
152
+ * contributes if no `{type:'image'}` entry was already provided via
153
+ * sources 1 or 2; emits a deprecation warning when used.
159
154
  *
160
155
  * Agent calls cannot send `generation_config` and (per the API) cannot
161
- * combine with structured output - emit a warning and drop the field.
156
+ * combine with structured output emit a warning and drop the field.
162
157
  */
163
- let responseMimeType: string | undefined;
164
- let responseFormat: unknown | undefined;
158
+ const responseFormatEntries: Array<GoogleInteractionsResponseFormatEntry> =
159
+ [];
165
160
  if (options.responseFormat?.type === 'json') {
166
161
  if (isAgent) {
167
162
  warnings.push({
@@ -170,9 +165,43 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
170
165
  'google.interactions: structured output (responseFormat) is not supported when an agent is set; responseFormat will be ignored.',
171
166
  });
172
167
  } else {
173
- responseMimeType = 'application/json';
174
- if (options.responseFormat.schema != null) {
175
- responseFormat = options.responseFormat.schema;
168
+ const entry: GoogleInteractionsResponseFormatEntry = {
169
+ type: 'text',
170
+ mime_type: 'application/json',
171
+ ...(options.responseFormat.schema != null
172
+ ? { schema: options.responseFormat.schema }
173
+ : {}),
174
+ };
175
+ responseFormatEntries.push(entry);
176
+ }
177
+ }
178
+
179
+ if (opts?.responseFormat != null) {
180
+ for (const entry of opts.responseFormat) {
181
+ if (entry.type === 'text') {
182
+ responseFormatEntries.push(
183
+ pruneUndefined({
184
+ type: 'text' as const,
185
+ mime_type: entry.mimeType ?? undefined,
186
+ schema: entry.schema ?? undefined,
187
+ }),
188
+ );
189
+ } else if (entry.type === 'image') {
190
+ responseFormatEntries.push(
191
+ pruneUndefined({
192
+ type: 'image' as const,
193
+ mime_type: entry.mimeType ?? undefined,
194
+ aspect_ratio: entry.aspectRatio ?? undefined,
195
+ image_size: entry.imageSize ?? undefined,
196
+ }),
197
+ );
198
+ } else if (entry.type === 'audio') {
199
+ responseFormatEntries.push(
200
+ pruneUndefined({
201
+ type: 'audio' as const,
202
+ mime_type: entry.mimeType ?? undefined,
203
+ }),
204
+ );
176
205
  }
177
206
  }
178
207
  }
@@ -205,14 +234,13 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
205
234
  /*
206
235
  * The Interactions API splits per-call config into `generation_config`
207
236
  * (model branch) and `agent_config` (agent branch); the two are mutually
208
- * exclusive. We stay minimal here for TASK-1 - only the AI SDK call-level
209
- * generation params and the thinking/imageConfig provider options flow
210
- * into `generation_config`. Tool-related fields land here in later tasks.
237
+ * exclusive. The AI SDK call-level generation params and the thinking /
238
+ * imageConfig provider options flow into `generation_config`.
211
239
  *
212
- * When an agent is set, none of these fields are accepted by the API. Per
213
- * PRD US 31 we emit a single `LanguageModelV3CallWarning` listing the
214
- * dropped field names and continue (do not throw); the agent-only
215
- * `agent_config` field supersedes them.
240
+ * When an agent is set, none of these fields are accepted by the API.
241
+ * Emit a single `LanguageModelV3CallWarning` listing the dropped field
242
+ * names and continue (do not throw); the agent-only `agent_config`
243
+ * field supersedes them.
216
244
  */
217
245
  let generationConfig: GoogleInteractionsGenerationConfig | undefined;
218
246
  if (isAgent) {
@@ -249,15 +277,38 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
249
277
  max_output_tokens: options.maxOutputTokens ?? undefined,
250
278
  thinking_level: opts?.thinkingLevel ?? undefined,
251
279
  thinking_summaries: opts?.thinkingSummaries ?? undefined,
252
- image_config:
253
- opts?.imageConfig != null
254
- ? pruneUndefined({
255
- aspect_ratio: opts.imageConfig.aspectRatio ?? undefined,
256
- image_size: opts.imageConfig.imageSize ?? undefined,
257
- })
258
- : undefined,
259
280
  tool_choice: toolChoiceForBody,
260
281
  });
282
+
283
+ /*
284
+ * Deprecated fallback path: `imageConfig` contributes an image entry
285
+ * only when none was supplied via `responseFormat`. A warning is
286
+ * always emitted when `imageConfig` is set so callers migrate to the
287
+ * `responseFormat` shape.
288
+ */
289
+ if (opts?.imageConfig != null) {
290
+ const alreadyHasImageEntry = responseFormatEntries.some(
291
+ entry => entry.type === 'image',
292
+ );
293
+ warnings.push({
294
+ type: 'other',
295
+ message: alreadyHasImageEntry
296
+ ? 'google.interactions: providerOptions.google.imageConfig is deprecated and was ignored because providerOptions.google.responseFormat already supplies an image entry. Use responseFormat exclusively.'
297
+ : 'google.interactions: providerOptions.google.imageConfig is deprecated. Use providerOptions.google.responseFormat with a { type: "image", ... } entry instead.',
298
+ });
299
+ if (!alreadyHasImageEntry) {
300
+ responseFormatEntries.push({
301
+ type: 'image',
302
+ mime_type: 'image/png',
303
+ ...(opts.imageConfig.aspectRatio != null
304
+ ? { aspect_ratio: opts.imageConfig.aspectRatio }
305
+ : {}),
306
+ ...(opts.imageConfig.imageSize != null
307
+ ? { image_size: opts.imageConfig.imageSize }
308
+ : {}),
309
+ });
310
+ }
311
+ }
261
312
  }
262
313
 
263
314
  let agentConfig: GoogleInteractionsAgentConfig | undefined;
@@ -293,8 +344,8 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
293
344
  input,
294
345
  system_instruction: systemInstruction,
295
346
  tools: toolsForBody,
296
- response_format: responseFormat,
297
- response_mime_type: responseMimeType,
347
+ response_format:
348
+ responseFormatEntries.length > 0 ? responseFormatEntries : undefined,
298
349
  response_modalities:
299
350
  opts?.responseModalities != null
300
351
  ? (opts.responseModalities as Array<
@@ -329,6 +380,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
329
380
  const url = `${this.config.baseURL}/interactions`;
330
381
 
331
382
  const mergedHeaders = combineHeaders(
383
+ INTERACTIONS_API_REVISION_HEADER,
332
384
  this.config.headers ? await resolve(this.config.headers) : undefined,
333
385
  options.headers,
334
386
  );
@@ -383,7 +435,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
383
435
  : undefined;
384
436
 
385
437
  const { content, hasFunctionCall } = parseGoogleInteractionsOutputs({
386
- outputs: response.outputs ?? null,
438
+ steps: response.steps ?? null,
387
439
  generateId: this.config.generateId ?? defaultGenerateId,
388
440
  interactionId,
389
441
  });
@@ -457,6 +509,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
457
509
  const url = `${this.config.baseURL}/interactions`;
458
510
 
459
511
  const mergedHeaders = combineHeaders(
512
+ INTERACTIONS_API_REVISION_HEADER,
460
513
  this.config.headers ? await resolve(this.config.headers) : undefined,
461
514
  options.headers,
462
515
  );
@@ -625,6 +678,15 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV3 {
625
678
  }
626
679
  }
627
680
 
681
+ /*
682
+ * Pins the Interactions API revision the SDK targets. Sent on every request
683
+ * the model issues so model-id calls, agent calls, polling, SSE reconnects,
684
+ * and cancellation all hit the same schema.
685
+ */
686
+ const INTERACTIONS_API_REVISION_HEADER: Record<string, string> = {
687
+ 'Api-Revision': '2026-05-20',
688
+ };
689
+
628
690
  function pruneUndefined<T extends Record<string, unknown>>(obj: T): T {
629
691
  const result: Record<string, unknown> = {};
630
692
  for (const [key, value] of Object.entries(obj)) {
@@ -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`. Kept minimal for TASK-1 (text +
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<unknown>;
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
- * URL citation annotation for `text` content blocks.
80
- * Mirrors `Annotation.URLCitation` in `googleapis/js-genai`
81
- * `src/interactions/resources/interactions.ts`.
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
- source?: string;
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
- * Built-in tool call content blocks. The Interactions API exposes server-side
130
- * tool invocations via paired `*_call`/`*_result` blocks (as opposed to
131
- * `function_call`/`function_result` for client-executed tools).
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
- export type GoogleInteractionsCodeExecutionCallContent = {
134
- type: 'code_execution_call';
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 GoogleInteractionsCodeExecutionResultContent = {
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 GoogleInteractionsURLContextCallContent = {
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 GoogleInteractionsURLContextResultContent = {
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 GoogleInteractionsGoogleSearchCallContent = {
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 GoogleInteractionsGoogleSearchResultContent = {
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 GoogleInteractionsFileSearchCallContent = {
191
- type: 'file_search_call';
181
+ export type GoogleInteractionsFileSearchCallStepPayload = {
192
182
  id: string;
193
183
  signature?: string;
194
184
  };
195
185
 
196
- export type GoogleInteractionsFileSearchResultEntry = {
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 GoogleInteractionsGoogleMapsCallContent = {
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 GoogleInteractionsGoogleMapsResultContent = {
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 GoogleInteractionsMCPServerToolCallContent = {
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 GoogleInteractionsMCPServerToolResultContent = {
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
- export type GoogleInteractionsBuiltinToolCallContent =
259
- | GoogleInteractionsCodeExecutionCallContent
260
- | GoogleInteractionsURLContextCallContent
261
- | GoogleInteractionsGoogleSearchCallContent
262
- | GoogleInteractionsFileSearchCallContent
263
- | GoogleInteractionsGoogleMapsCallContent
264
- | GoogleInteractionsMCPServerToolCallContent;
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 GoogleInteractionsBuiltinToolResultContent =
267
- | GoogleInteractionsCodeExecutionResultContent
268
- | GoogleInteractionsURLContextResultContent
269
- | GoogleInteractionsGoogleSearchResultContent
270
- | GoogleInteractionsFileSearchResultContent
271
- | GoogleInteractionsGoogleMapsResultContent
272
- | GoogleInteractionsMCPServerToolResultContent;
245
+ export type GoogleInteractionsUserInputStep = {
246
+ type: 'user_input';
247
+ content?: Array<GoogleInteractionsContentBlock>;
248
+ };
273
249
 
274
- /**
275
- * Discriminated union of every content block kind the API supports. For
276
- * TASK-1, only `text` and `thought` are exercised end-to-end; the remaining
277
- * variants are listed for type completeness so subsequent tasks can extend the
278
- * parser/converter without widening the type.
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 GoogleInteractionsContent =
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
- export type GoogleInteractionsTurn = {
292
- role: 'user' | 'model' | string;
293
- content?: string | Array<GoogleInteractionsContent>;
294
- };
315
+ /**
316
+ * Alias kept for the file-part converter surface; identical to
317
+ * `GoogleInteractionsContentBlock`.
318
+ */
319
+ export type GoogleInteractionsContent = GoogleInteractionsContentBlock;
295
320
 
296
- export type GoogleInteractionsInput =
297
- | string
298
- | GoogleInteractionsContent
299
- | Array<GoogleInteractionsContent>
300
- | Array<GoogleInteractionsTurn>;
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 GoogleInteractionsImageConfig = {
385
- aspect_ratio?:
386
- | '1:1'
387
- | '2:3'
388
- | '3:2'
389
- | '3:4'
390
- | '4:3'
391
- | '4:5'
392
- | '5:4'
393
- | '9:16'
394
- | '16:9'
395
- | '21:9'
396
- | '1:8'
397
- | '8:1'
398
- | '1:4'
399
- | '4:1';
400
- image_size?: '1K' | '2K' | '4K' | '512';
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;
401
449
  };
402
450
 
451
+ export type GoogleInteractionsResponseFormatAudioEntry = {
452
+ type: 'audio';
453
+ mime_type?: string;
454
+ };
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
 
@@ -427,8 +484,7 @@ export type GoogleInteractionsRequestBody = {
427
484
  input: GoogleInteractionsInput;
428
485
  system_instruction?: string;
429
486
  tools?: Array<GoogleInteractionsTool>;
430
- response_format?: unknown;
431
- response_mime_type?: string;
487
+ response_format?: Array<GoogleInteractionsResponseFormatEntry>;
432
488
  response_modalities?: Array<GoogleInteractionsResponseModality>;
433
489
  generation_config?: GoogleInteractionsGenerationConfig;
434
490
  agent_config?: GoogleInteractionsAgentConfig;
@@ -455,3 +511,22 @@ export type GoogleInteractionsStatus =
455
511
  | 'failed'
456
512
  | 'cancelled'
457
513
  | 'incomplete';
514
+
515
+ /*
516
+ * Aliases used by the source extractor; structurally equivalent to their
517
+ * step-payload counterparts.
518
+ */
519
+ export type GoogleInteractionsBuiltinToolResultContent =
520
+ GoogleInteractionsBuiltinToolResultStep;
521
+ export type GoogleInteractionsGoogleSearchResultContent = Extract<
522
+ GoogleInteractionsBuiltinToolResultStep,
523
+ { type: 'google_search_result' }
524
+ >;
525
+ export type GoogleInteractionsGoogleMapsResultContent = Extract<
526
+ GoogleInteractionsBuiltinToolResultStep,
527
+ { type: 'google_maps_result' }
528
+ >;
529
+ export type GoogleInteractionsURLContextResultContent = Extract<
530
+ GoogleInteractionsBuiltinToolResultStep,
531
+ { type: 'url_context_result' }
532
+ >;