@ai-sdk/google 4.0.0-beta.7 → 4.0.0-beta.82

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +614 -5
  2. package/README.md +6 -4
  3. package/dist/index.d.ts +301 -50
  4. package/dist/index.js +5410 -639
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +100 -26
  7. package/dist/internal/index.js +1653 -451
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +784 -69
  10. package/package.json +16 -17
  11. package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +13 -5
  12. package/src/convert-json-schema-to-openapi-schema.ts +1 -1
  13. package/src/convert-to-google-messages.ts +647 -0
  14. package/src/{google-generative-ai-embedding-options.ts → google-embedding-model-options.ts} +9 -2
  15. package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +31 -18
  16. package/src/google-error.ts +1 -1
  17. package/src/google-files.ts +225 -0
  18. package/src/google-image-model-options.ts +35 -0
  19. package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +116 -65
  20. package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
  21. package/src/google-json-accumulator.ts +371 -0
  22. package/src/{google-generative-ai-options.ts → google-language-model-options.ts} +50 -5
  23. package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +701 -219
  24. package/src/google-prepare-tools.ts +72 -12
  25. package/src/google-prompt.ts +86 -0
  26. package/src/google-provider.ts +157 -53
  27. package/src/google-speech-api.ts +36 -0
  28. package/src/google-speech-model-options.ts +48 -0
  29. package/src/google-speech-model.ts +311 -0
  30. package/src/google-video-model-options.ts +43 -0
  31. package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +25 -60
  32. package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +2 -1
  33. package/src/index.ts +40 -9
  34. package/src/interactions/build-google-interactions-stream-transform.ts +818 -0
  35. package/src/interactions/cancel-google-interaction.ts +60 -0
  36. package/src/interactions/convert-google-interactions-usage.ts +47 -0
  37. package/src/interactions/convert-to-google-interactions-input.ts +557 -0
  38. package/src/interactions/extract-google-interactions-sources.ts +252 -0
  39. package/src/interactions/google-interactions-agent.ts +15 -0
  40. package/src/interactions/google-interactions-api.ts +530 -0
  41. package/src/interactions/google-interactions-language-model-options.ts +262 -0
  42. package/src/interactions/google-interactions-language-model.ts +776 -0
  43. package/src/interactions/google-interactions-prompt.ts +582 -0
  44. package/src/interactions/google-interactions-provider-metadata.ts +23 -0
  45. package/src/interactions/map-google-interactions-finish-reason.ts +31 -0
  46. package/src/interactions/parse-google-interactions-outputs.ts +252 -0
  47. package/src/interactions/poll-google-interactions.ts +129 -0
  48. package/src/interactions/prepare-google-interactions-tools.ts +245 -0
  49. package/src/interactions/stream-google-interactions.ts +242 -0
  50. package/src/interactions/synthesize-google-interactions-agent-stream.ts +185 -0
  51. package/src/internal/index.ts +3 -2
  52. package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +3 -3
  53. package/src/realtime/google-realtime-event-mapper.ts +383 -0
  54. package/src/realtime/google-realtime-model-options.ts +3 -0
  55. package/src/realtime/google-realtime-model.ts +160 -0
  56. package/src/realtime/index.ts +2 -0
  57. package/src/tool/code-execution.ts +2 -2
  58. package/src/tool/enterprise-web-search.ts +9 -3
  59. package/src/tool/file-search.ts +5 -7
  60. package/src/tool/google-maps.ts +3 -2
  61. package/src/tool/google-search.ts +11 -12
  62. package/src/tool/url-context.ts +4 -2
  63. package/src/tool/vertex-rag-store.ts +9 -6
  64. package/dist/index.d.mts +0 -376
  65. package/dist/index.mjs +0 -2517
  66. package/dist/index.mjs.map +0 -1
  67. package/dist/internal/index.d.mts +0 -284
  68. package/dist/internal/index.mjs +0 -1706
  69. package/dist/internal/index.mjs.map +0 -1
  70. package/src/convert-to-google-generative-ai-messages.ts +0 -239
  71. package/src/google-generative-ai-prompt.ts +0 -38
@@ -0,0 +1,262 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ /**
9
+ * Type-only union of Gemini model IDs that the Interactions API accepts via
10
+ * `model:`. Mirrors `Model` from `googleapis/js-genai`
11
+ * `src/interactions/resources/interactions.ts`.
12
+ *
13
+ * Kept as a separate type from `GoogleModelId` even though most IDs overlap;
14
+ * the two surfaces (`:generateContent` vs `/interactions`) are independent and
15
+ * may diverge over time.
16
+ */
17
+ export type GoogleInteractionsModelId =
18
+ | 'gemini-2.5-computer-use-preview-10-2025'
19
+ | 'gemini-2.5-flash'
20
+ | 'gemini-2.5-flash-image'
21
+ | 'gemini-2.5-flash-lite'
22
+ | 'gemini-2.5-flash-lite-preview-09-2025'
23
+ | 'gemini-2.5-flash-native-audio-preview-12-2025'
24
+ | 'gemini-2.5-flash-preview-09-2025'
25
+ | 'gemini-2.5-flash-preview-tts'
26
+ | 'gemini-2.5-pro'
27
+ | 'gemini-2.5-pro-preview-tts'
28
+ | 'gemini-3-flash-preview'
29
+ | 'gemini-3-pro-image-preview'
30
+ | 'gemini-3-pro-preview'
31
+ | 'gemini-3.1-pro-preview'
32
+ | 'gemini-3.1-flash-image-preview'
33
+ | 'gemini-3.1-flash-lite-preview'
34
+ | 'gemini-3.1-flash-tts-preview'
35
+ | 'gemini-3.5-flash'
36
+ | 'lyria-3-clip-preview'
37
+ | 'lyria-3-pro-preview'
38
+ | (string & {});
39
+
40
+ /**
41
+ * Provider-options schema for `google.interactions(...)` calls. Read from the
42
+ * shared `providerOptions.google.*` namespace (per PRD); per-call options that
43
+ * the AI SDK doesn't natively expose live here.
44
+ *
45
+ * All fields are `.nullish()` per the existing google provider convention.
46
+ */
47
+ export const googleInteractionsLanguageModelOptions = lazySchema(() =>
48
+ zodSchema(
49
+ z.object({
50
+ previousInteractionId: z.string().nullish(),
51
+ store: z.boolean().nullish(),
52
+
53
+ agent: z.string().nullish(),
54
+ agentConfig: z
55
+ .union([
56
+ z
57
+ .object({
58
+ type: z.literal('dynamic'),
59
+ })
60
+ .loose(),
61
+ z.object({
62
+ type: z.literal('deep-research'),
63
+ thinkingSummaries: z.enum(['auto', 'none']).nullish(),
64
+ visualization: z.enum(['off', 'auto']).nullish(),
65
+ collaborativePlanning: z.boolean().nullish(),
66
+ }),
67
+ ])
68
+ .nullish(),
69
+
70
+ thinkingLevel: z.enum(['minimal', 'low', 'medium', 'high']).nullish(),
71
+ thinkingSummaries: z.enum(['auto', 'none']).nullish(),
72
+
73
+ /**
74
+ * Output-format entries that map directly to the API's `response_format`
75
+ * array. Use this to request image, audio, or non-JSON text outputs
76
+ * with full control over `mime_type`, `aspect_ratio`, and `image_size`.
77
+ *
78
+ * Entries are sent in order. The AI SDK call-level `responseFormat: {
79
+ * type: 'json', schema }` still drives JSON-mode and adds a matching
80
+ * text entry automatically; entries listed here are appended.
81
+ */
82
+ responseFormat: z
83
+ .array(
84
+ z.union([
85
+ z
86
+ .object({
87
+ type: z.literal('text'),
88
+ mimeType: z.string().nullish(),
89
+ schema: z.unknown().nullish(),
90
+ })
91
+ .loose(),
92
+ z
93
+ .object({
94
+ type: z.literal('image'),
95
+ mimeType: z.string().nullish(),
96
+ aspectRatio: z
97
+ .enum([
98
+ '1:1',
99
+ '2:3',
100
+ '3:2',
101
+ '3:4',
102
+ '4:3',
103
+ '4:5',
104
+ '5:4',
105
+ '9:16',
106
+ '16:9',
107
+ '21:9',
108
+ '1:8',
109
+ '8:1',
110
+ '1:4',
111
+ '4:1',
112
+ ])
113
+ .nullish(),
114
+ imageSize: z.enum(['1K', '2K', '4K', '512']).nullish(),
115
+ })
116
+ .loose(),
117
+ z
118
+ .object({
119
+ type: z.literal('audio'),
120
+ mimeType: z.string().nullish(),
121
+ })
122
+ .loose(),
123
+ ]),
124
+ )
125
+ .nullish(),
126
+
127
+ /**
128
+ * @deprecated Use `responseFormat` with a `{ type: 'image', ... }`
129
+ * entry instead. Retained for backwards compatibility; the SDK
130
+ * translates it into a matching `response_format` image entry and
131
+ * emits a warning when set.
132
+ */
133
+ imageConfig: z
134
+ .object({
135
+ aspectRatio: z
136
+ .enum([
137
+ '1:1',
138
+ '2:3',
139
+ '3:2',
140
+ '3:4',
141
+ '4:3',
142
+ '4:5',
143
+ '5:4',
144
+ '9:16',
145
+ '16:9',
146
+ '21:9',
147
+ '1:8',
148
+ '8:1',
149
+ '1:4',
150
+ '4:1',
151
+ ])
152
+ .nullish(),
153
+ imageSize: z.enum(['1K', '2K', '4K', '512']).nullish(),
154
+ })
155
+ .nullish(),
156
+ mediaResolution: z
157
+ .enum(['low', 'medium', 'high', 'ultra_high'])
158
+ .nullish(),
159
+
160
+ responseModalities: z
161
+ .array(z.enum(['text', 'image', 'audio', 'video', 'document']))
162
+ .nullish(),
163
+ serviceTier: z.enum(['flex', 'standard', 'priority']).nullish(),
164
+
165
+ /**
166
+ * Alternative to AI SDK `system` message. If both are set, the AI SDK
167
+ * `system` message wins and a warning is emitted.
168
+ */
169
+ systemInstruction: z.string().nullish(),
170
+
171
+ /**
172
+ * Per-block signature for round-tripping `thought.signature` and
173
+ * `function_call.signature` blocks. Set by the SDK on output reasoning /
174
+ * tool-call parts; passed back unchanged on input parts so the API
175
+ * accepts the prior turn.
176
+ */
177
+ signature: z.string().nullish(),
178
+
179
+ /**
180
+ * Set by the SDK on output assistant messages. The converter uses it to
181
+ * decide which messages to drop when compacting under
182
+ * `previousInteractionId`.
183
+ */
184
+ interactionId: z.string().nullish(),
185
+
186
+ /**
187
+ * Maximum time, in milliseconds, to poll a background interaction (agent
188
+ * call) before giving up. Defaults to 30 minutes. Long-running agents
189
+ * such as deep research can take tens of minutes — increase if needed.
190
+ */
191
+ pollingTimeoutMs: z.number().int().positive().nullish(),
192
+
193
+ /**
194
+ * Run the interaction in the background. Required for agents whose
195
+ * server-side workflow cannot complete within a single request/response.
196
+ * When `true`, the POST returns with a non-terminal status and the SDK
197
+ * polls `GET /interactions/{id}` until the work completes. Some agents
198
+ * reject `true`; see the agent's documentation for which mode it
199
+ * requires.
200
+ */
201
+ background: z.boolean().nullish(),
202
+
203
+ /**
204
+ * Environment configuration for the agent sandbox. Only applies to agent
205
+ * calls (`google.interactions({ agent })`); ignored on model-id calls.
206
+ *
207
+ * - `"remote"`: provision a fresh sandbox for this call.
208
+ * - any other string: an existing `environment_id` to reuse.
209
+ * - object: provision a fresh sandbox and optionally preload `sources`
210
+ * and/or constrain outbound traffic via `network`.
211
+ */
212
+ environment: z
213
+ .union([
214
+ z.string(),
215
+ z.object({
216
+ type: z.literal('remote'),
217
+ sources: z
218
+ .array(
219
+ z.union([
220
+ z.object({
221
+ type: z.literal('gcs'),
222
+ source: z.string(),
223
+ target: z.string().nullish(),
224
+ }),
225
+ z.object({
226
+ type: z.literal('repository'),
227
+ source: z.string(),
228
+ target: z.string().nullish(),
229
+ }),
230
+ z.object({
231
+ type: z.literal('inline'),
232
+ content: z.string(),
233
+ target: z.string(),
234
+ }),
235
+ ]),
236
+ )
237
+ .nullish(),
238
+ network: z
239
+ .union([
240
+ z.literal('disabled'),
241
+ z.object({
242
+ allowlist: z.array(
243
+ z.object({
244
+ domain: z.string(),
245
+ transform: z
246
+ .array(z.record(z.string(), z.string()))
247
+ .nullish(),
248
+ }),
249
+ ),
250
+ }),
251
+ ])
252
+ .nullish(),
253
+ }),
254
+ ])
255
+ .nullish(),
256
+ }),
257
+ ),
258
+ );
259
+
260
+ export type GoogleLanguageModelInteractionsOptions = InferSchema<
261
+ typeof googleInteractionsLanguageModelOptions
262
+ >;