@tanstack/ai-gemini 0.8.9 → 0.9.0
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/dist/esm/adapters/text.d.ts +9 -4
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/model-meta.d.ts +38 -10
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/tools/code-execution-tool.d.ts +6 -3
- package/dist/esm/tools/code-execution-tool.js +8 -0
- package/dist/esm/tools/code-execution-tool.js.map +1 -1
- package/dist/esm/tools/computer-use-tool.d.ts +6 -3
- package/dist/esm/tools/computer-use-tool.js +11 -0
- package/dist/esm/tools/computer-use-tool.js.map +1 -1
- package/dist/esm/tools/file-search-tool.d.ts +6 -3
- package/dist/esm/tools/file-search-tool.js +9 -1
- package/dist/esm/tools/file-search-tool.js.map +1 -1
- package/dist/esm/tools/function-declaration-tool.js +29 -0
- package/dist/esm/tools/function-declaration-tool.js.map +1 -0
- package/dist/esm/tools/google-maps-tool.d.ts +6 -3
- package/dist/esm/tools/google-maps-tool.js +9 -1
- package/dist/esm/tools/google-maps-tool.js.map +1 -1
- package/dist/esm/tools/google-search-retriveal-tool.d.ts +6 -3
- package/dist/esm/tools/google-search-retriveal-tool.js +9 -1
- package/dist/esm/tools/google-search-retriveal-tool.js.map +1 -1
- package/dist/esm/tools/google-search-tool.d.ts +6 -3
- package/dist/esm/tools/google-search-tool.js +9 -1
- package/dist/esm/tools/google-search-tool.js.map +1 -1
- package/dist/esm/tools/index.d.ts +9 -0
- package/dist/esm/tools/index.js +21 -0
- package/dist/esm/tools/index.js.map +1 -0
- package/dist/esm/tools/url-context-tool.d.ts +6 -3
- package/dist/esm/tools/url-context-tool.js +9 -1
- package/dist/esm/tools/url-context-tool.js.map +1 -1
- package/package.json +8 -3
- package/src/adapters/text.ts +19 -4
- package/src/index.ts +1 -0
- package/src/model-meta.ts +59 -72
- package/src/tools/code-execution-tool.ts +10 -4
- package/src/tools/computer-use-tool.ts +13 -5
- package/src/tools/file-search-tool.ts +13 -5
- package/src/tools/google-maps-tool.ts +13 -5
- package/src/tools/google-search-retriveal-tool.ts +15 -6
- package/src/tools/google-search-tool.ts +13 -5
- package/src/tools/index.ts +51 -0
- package/src/tools/url-context-tool.ts +10 -4
package/src/model-meta.ts
CHANGED
|
@@ -17,16 +17,19 @@ interface ModelMeta<TProviderOptions = unknown> {
|
|
|
17
17
|
| 'audio_generation'
|
|
18
18
|
| 'batch_api'
|
|
19
19
|
| 'caching'
|
|
20
|
-
| 'code_execution'
|
|
21
|
-
| 'file_search'
|
|
22
20
|
| 'function_calling'
|
|
23
|
-
| 'grounding_with_gmaps'
|
|
24
|
-
| 'image_generation'
|
|
25
21
|
| 'live_api'
|
|
26
|
-
| 'search_grounding'
|
|
27
22
|
| 'structured_output'
|
|
28
23
|
| 'thinking'
|
|
24
|
+
>
|
|
25
|
+
tools?: Array<
|
|
26
|
+
| 'code_execution'
|
|
27
|
+
| 'file_search'
|
|
28
|
+
| 'google_search'
|
|
29
|
+
| 'google_search_retrieval'
|
|
30
|
+
| 'google_maps'
|
|
29
31
|
| 'url_context'
|
|
32
|
+
| 'computer_use'
|
|
30
33
|
>
|
|
31
34
|
}
|
|
32
35
|
max_input_tokens?: number
|
|
@@ -58,14 +61,11 @@ const GEMINI_3_1_PRO = {
|
|
|
58
61
|
capabilities: [
|
|
59
62
|
'batch_api',
|
|
60
63
|
'caching',
|
|
61
|
-
'code_execution',
|
|
62
|
-
'file_search',
|
|
63
64
|
'function_calling',
|
|
64
|
-
'search_grounding',
|
|
65
65
|
'structured_output',
|
|
66
66
|
'thinking',
|
|
67
|
-
'url_context',
|
|
68
67
|
],
|
|
68
|
+
tools: ['code_execution', 'file_search', 'google_search', 'url_context'],
|
|
69
69
|
},
|
|
70
70
|
pricing: {
|
|
71
71
|
input: {
|
|
@@ -96,14 +96,11 @@ const GEMINI_3_PRO = {
|
|
|
96
96
|
capabilities: [
|
|
97
97
|
'batch_api',
|
|
98
98
|
'caching',
|
|
99
|
-
'code_execution',
|
|
100
|
-
'file_search',
|
|
101
99
|
'function_calling',
|
|
102
|
-
'search_grounding',
|
|
103
100
|
'structured_output',
|
|
104
101
|
'thinking',
|
|
105
|
-
'url_context',
|
|
106
102
|
],
|
|
103
|
+
tools: ['code_execution', 'file_search', 'google_search', 'url_context'],
|
|
107
104
|
},
|
|
108
105
|
pricing: {
|
|
109
106
|
input: {
|
|
@@ -134,14 +131,11 @@ const GEMINI_3_FLASH = {
|
|
|
134
131
|
capabilities: [
|
|
135
132
|
'batch_api',
|
|
136
133
|
'caching',
|
|
137
|
-
'code_execution',
|
|
138
|
-
'file_search',
|
|
139
134
|
'function_calling',
|
|
140
|
-
'search_grounding',
|
|
141
135
|
'structured_output',
|
|
142
136
|
'thinking',
|
|
143
|
-
'url_context',
|
|
144
137
|
],
|
|
138
|
+
tools: ['code_execution', 'file_search', 'google_search', 'url_context'],
|
|
145
139
|
},
|
|
146
140
|
pricing: {
|
|
147
141
|
input: {
|
|
@@ -169,13 +163,8 @@ const GEMINI_3_PRO_IMAGE = {
|
|
|
169
163
|
supports: {
|
|
170
164
|
input: ['text', 'image'],
|
|
171
165
|
output: ['text', 'image'],
|
|
172
|
-
capabilities: [
|
|
173
|
-
|
|
174
|
-
'image_generation',
|
|
175
|
-
'search_grounding',
|
|
176
|
-
'structured_output',
|
|
177
|
-
'thinking',
|
|
178
|
-
],
|
|
166
|
+
capabilities: ['batch_api', 'structured_output', 'thinking'],
|
|
167
|
+
tools: ['google_search'],
|
|
179
168
|
},
|
|
180
169
|
pricing: {
|
|
181
170
|
input: {
|
|
@@ -203,13 +192,8 @@ const GEMINI_3_1_FLASH_IMAGE = {
|
|
|
203
192
|
supports: {
|
|
204
193
|
input: ['text', 'image'],
|
|
205
194
|
output: ['text', 'image'],
|
|
206
|
-
capabilities: [
|
|
207
|
-
|
|
208
|
-
'image_generation',
|
|
209
|
-
'search_grounding',
|
|
210
|
-
'structured_output',
|
|
211
|
-
'thinking',
|
|
212
|
-
],
|
|
195
|
+
capabilities: ['batch_api', 'structured_output', 'thinking'],
|
|
196
|
+
tools: ['google_search'],
|
|
213
197
|
},
|
|
214
198
|
pricing: {
|
|
215
199
|
input: {
|
|
@@ -239,14 +223,11 @@ const GEMINI_3_1_FLASH_LITE = {
|
|
|
239
223
|
capabilities: [
|
|
240
224
|
'batch_api',
|
|
241
225
|
'caching',
|
|
242
|
-
'code_execution',
|
|
243
|
-
'file_search',
|
|
244
226
|
'function_calling',
|
|
245
|
-
'search_grounding',
|
|
246
227
|
'structured_output',
|
|
247
228
|
'thinking',
|
|
248
|
-
'url_context',
|
|
249
229
|
],
|
|
230
|
+
tools: ['code_execution', 'file_search', 'google_search', 'url_context'],
|
|
250
231
|
},
|
|
251
232
|
pricing: {
|
|
252
233
|
input: {
|
|
@@ -276,13 +257,15 @@ const GEMINI_2_5_PRO = {
|
|
|
276
257
|
capabilities: [
|
|
277
258
|
'batch_api',
|
|
278
259
|
'caching',
|
|
279
|
-
'code_execution',
|
|
280
|
-
'file_search',
|
|
281
260
|
'function_calling',
|
|
282
|
-
'grounding_with_gmaps',
|
|
283
|
-
'search_grounding',
|
|
284
261
|
'structured_output',
|
|
285
262
|
'thinking',
|
|
263
|
+
],
|
|
264
|
+
tools: [
|
|
265
|
+
'code_execution',
|
|
266
|
+
'file_search',
|
|
267
|
+
'google_maps',
|
|
268
|
+
'google_search',
|
|
286
269
|
'url_context',
|
|
287
270
|
],
|
|
288
271
|
},
|
|
@@ -311,7 +294,8 @@ const GEMINI_2_5_PRO_TTS = {
|
|
|
311
294
|
supports: {
|
|
312
295
|
input: ['text'],
|
|
313
296
|
output: ['audio'],
|
|
314
|
-
capabilities: ['audio_generation'
|
|
297
|
+
capabilities: ['audio_generation'],
|
|
298
|
+
tools: ['file_search'],
|
|
315
299
|
},
|
|
316
300
|
pricing: {
|
|
317
301
|
input: {
|
|
@@ -339,13 +323,15 @@ const GEMINI_2_5_FLASH = {
|
|
|
339
323
|
capabilities: [
|
|
340
324
|
'batch_api',
|
|
341
325
|
'caching',
|
|
342
|
-
'code_execution',
|
|
343
|
-
'file_search',
|
|
344
326
|
'function_calling',
|
|
345
|
-
'grounding_with_gmaps',
|
|
346
|
-
'search_grounding',
|
|
347
327
|
'structured_output',
|
|
348
328
|
'thinking',
|
|
329
|
+
],
|
|
330
|
+
tools: [
|
|
331
|
+
'code_execution',
|
|
332
|
+
'file_search',
|
|
333
|
+
'google_maps',
|
|
334
|
+
'google_search',
|
|
349
335
|
'url_context',
|
|
350
336
|
],
|
|
351
337
|
},
|
|
@@ -377,14 +363,11 @@ const GEMINI_2_5_FLASH_PREVIEW = {
|
|
|
377
363
|
capabilities: [
|
|
378
364
|
'batch_api',
|
|
379
365
|
'caching',
|
|
380
|
-
'code_execution',
|
|
381
|
-
'file_search',
|
|
382
366
|
'function_calling',
|
|
383
|
-
'search_grounding',
|
|
384
367
|
'structured_output',
|
|
385
368
|
'thinking',
|
|
386
|
-
'url_context',
|
|
387
369
|
],
|
|
370
|
+
tools: ['code_execution', 'file_search', 'google_search', 'url_context'],
|
|
388
371
|
},
|
|
389
372
|
pricing: {
|
|
390
373
|
input: {
|
|
@@ -411,13 +394,8 @@ const GEMINI_2_5_FLASH_IMAGE = {
|
|
|
411
394
|
supports: {
|
|
412
395
|
input: ['text', 'image'],
|
|
413
396
|
output: ['text', 'image'],
|
|
414
|
-
capabilities: [
|
|
415
|
-
|
|
416
|
-
'caching',
|
|
417
|
-
'file_search',
|
|
418
|
-
'image_generation',
|
|
419
|
-
'structured_output',
|
|
420
|
-
],
|
|
397
|
+
capabilities: ['batch_api', 'caching', 'structured_output'],
|
|
398
|
+
tools: ['file_search'],
|
|
421
399
|
},
|
|
422
400
|
pricing: {
|
|
423
401
|
input: {
|
|
@@ -476,7 +454,8 @@ const GEMINI_2_5_FLASH_TTS = {
|
|
|
476
454
|
supports: {
|
|
477
455
|
input: ['text'],
|
|
478
456
|
output: ['audio'],
|
|
479
|
-
capabilities: ['audio_generation', 'batch_api'
|
|
457
|
+
capabilities: ['audio_generation', 'batch_api'],
|
|
458
|
+
tools: ['file_search'],
|
|
480
459
|
},
|
|
481
460
|
pricing: {
|
|
482
461
|
input: {
|
|
@@ -504,14 +483,11 @@ const GEMINI_2_5_FLASH_LITE = {
|
|
|
504
483
|
capabilities: [
|
|
505
484
|
'batch_api',
|
|
506
485
|
'caching',
|
|
507
|
-
'code_execution',
|
|
508
486
|
'function_calling',
|
|
509
|
-
'grounding_with_gmaps',
|
|
510
|
-
'search_grounding',
|
|
511
487
|
'structured_output',
|
|
512
488
|
'thinking',
|
|
513
|
-
'url_context',
|
|
514
489
|
],
|
|
490
|
+
tools: ['code_execution', 'google_maps', 'google_search', 'url_context'],
|
|
515
491
|
},
|
|
516
492
|
pricing: {
|
|
517
493
|
input: {
|
|
@@ -541,13 +517,11 @@ const GEMINI_2_5_FLASH_LITE_PREVIEW = {
|
|
|
541
517
|
capabilities: [
|
|
542
518
|
'batch_api',
|
|
543
519
|
'caching',
|
|
544
|
-
'code_execution',
|
|
545
520
|
'function_calling',
|
|
546
|
-
'search_grounding',
|
|
547
521
|
'structured_output',
|
|
548
522
|
'thinking',
|
|
549
|
-
'url_context',
|
|
550
523
|
],
|
|
524
|
+
tools: ['code_execution', 'google_search', 'url_context'],
|
|
551
525
|
},
|
|
552
526
|
pricing: {
|
|
553
527
|
input: {
|
|
@@ -577,13 +551,11 @@ const GEMINI_2_FLASH = {
|
|
|
577
551
|
capabilities: [
|
|
578
552
|
'batch_api',
|
|
579
553
|
'caching',
|
|
580
|
-
'code_execution',
|
|
581
554
|
'function_calling',
|
|
582
|
-
'grounding_with_gmaps',
|
|
583
555
|
'live_api',
|
|
584
|
-
'search_grounding',
|
|
585
556
|
'structured_output',
|
|
586
557
|
],
|
|
558
|
+
tools: ['code_execution', 'google_maps', 'google_search'],
|
|
587
559
|
},
|
|
588
560
|
pricing: {
|
|
589
561
|
input: {
|
|
@@ -609,12 +581,8 @@ const GEMINI_2_FLASH_IMAGE = {
|
|
|
609
581
|
supports: {
|
|
610
582
|
input: ['text', 'image', 'audio', 'video'],
|
|
611
583
|
output: ['text'],
|
|
612
|
-
capabilities: [
|
|
613
|
-
|
|
614
|
-
'caching',
|
|
615
|
-
'image_generation',
|
|
616
|
-
'structured_output',
|
|
617
|
-
],
|
|
584
|
+
capabilities: ['batch_api', 'caching', 'structured_output'],
|
|
585
|
+
tools: [],
|
|
618
586
|
},
|
|
619
587
|
pricing: {
|
|
620
588
|
input: {
|
|
@@ -679,6 +647,7 @@ const GEMINI_2_FLASH_LITE = {
|
|
|
679
647
|
'function_calling',
|
|
680
648
|
'structured_output',
|
|
681
649
|
],
|
|
650
|
+
tools: [],
|
|
682
651
|
},
|
|
683
652
|
pricing: {
|
|
684
653
|
input: {
|
|
@@ -1092,6 +1061,24 @@ export type GeminiChatModelProviderOptionsByName = {
|
|
|
1092
1061
|
GeminiStructuredOutputOptions
|
|
1093
1062
|
}
|
|
1094
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Type-only map from chat model name to its supported tool capabilities.
|
|
1066
|
+
* Based on the 'supports.tools' arrays defined for each model.
|
|
1067
|
+
*/
|
|
1068
|
+
export type GeminiChatModelToolCapabilitiesByName = {
|
|
1069
|
+
[GEMINI_3_1_PRO.name]: typeof GEMINI_3_1_PRO.supports.tools
|
|
1070
|
+
[GEMINI_3_PRO.name]: typeof GEMINI_3_PRO.supports.tools
|
|
1071
|
+
[GEMINI_3_FLASH.name]: typeof GEMINI_3_FLASH.supports.tools
|
|
1072
|
+
[GEMINI_3_1_FLASH_LITE.name]: typeof GEMINI_3_1_FLASH_LITE.supports.tools
|
|
1073
|
+
[GEMINI_2_5_PRO.name]: typeof GEMINI_2_5_PRO.supports.tools
|
|
1074
|
+
[GEMINI_2_5_FLASH.name]: typeof GEMINI_2_5_FLASH.supports.tools
|
|
1075
|
+
[GEMINI_2_5_FLASH_PREVIEW.name]: typeof GEMINI_2_5_FLASH_PREVIEW.supports.tools
|
|
1076
|
+
[GEMINI_2_5_FLASH_LITE.name]: typeof GEMINI_2_5_FLASH_LITE.supports.tools
|
|
1077
|
+
[GEMINI_2_5_FLASH_LITE_PREVIEW.name]: typeof GEMINI_2_5_FLASH_LITE_PREVIEW.supports.tools
|
|
1078
|
+
[GEMINI_2_FLASH.name]: typeof GEMINI_2_FLASH.supports.tools
|
|
1079
|
+
[GEMINI_2_FLASH_LITE.name]: typeof GEMINI_2_FLASH_LITE.supports.tools
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1095
1082
|
/**
|
|
1096
1083
|
* Type-only map from chat model name to its supported input modalities.
|
|
1097
1084
|
* Based on the 'supports.input' arrays defined for each model.
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type { Tool } from '@tanstack/ai'
|
|
1
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface CodeExecutionToolConfig {}
|
|
4
|
+
|
|
5
|
+
/** @deprecated Renamed to `CodeExecutionToolConfig`. Will be removed in a future release. */
|
|
6
|
+
export type CodeExecutionTool = CodeExecutionToolConfig
|
|
7
|
+
|
|
8
|
+
export type GeminiCodeExecutionTool = ProviderTool<'gemini', 'code_execution'>
|
|
4
9
|
|
|
5
10
|
export function convertCodeExecutionToolToAdapterFormat(_tool: Tool) {
|
|
6
11
|
return {
|
|
@@ -8,10 +13,11 @@ export function convertCodeExecutionToolToAdapterFormat(_tool: Tool) {
|
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
export function codeExecutionTool():
|
|
16
|
+
export function codeExecutionTool(): GeminiCodeExecutionTool {
|
|
17
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
12
18
|
return {
|
|
13
19
|
name: 'code_execution',
|
|
14
20
|
description: '',
|
|
15
21
|
metadata: {},
|
|
16
|
-
}
|
|
22
|
+
} as unknown as GeminiCodeExecutionTool
|
|
17
23
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { ComputerUse } from '@google/genai'
|
|
2
|
-
import type { Tool } from '@tanstack/ai'
|
|
2
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type ComputerUseToolConfig = ComputerUse
|
|
5
|
+
|
|
6
|
+
/** @deprecated Renamed to `ComputerUseToolConfig`. Will be removed in a future release. */
|
|
7
|
+
export type ComputerUseTool = ComputerUseToolConfig
|
|
8
|
+
|
|
9
|
+
export type GeminiComputerUseTool = ProviderTool<'gemini', 'computer_use'>
|
|
5
10
|
|
|
6
11
|
export function convertComputerUseToolToAdapterFormat(tool: Tool) {
|
|
7
|
-
const metadata = tool.metadata as
|
|
12
|
+
const metadata = tool.metadata as ComputerUseToolConfig
|
|
8
13
|
return {
|
|
9
14
|
computerUse: {
|
|
10
15
|
environment: metadata.environment,
|
|
@@ -13,7 +18,10 @@ export function convertComputerUseToolToAdapterFormat(tool: Tool) {
|
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
export function computerUseTool(
|
|
21
|
+
export function computerUseTool(
|
|
22
|
+
config: ComputerUseToolConfig,
|
|
23
|
+
): GeminiComputerUseTool {
|
|
24
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
17
25
|
return {
|
|
18
26
|
name: 'computer_use',
|
|
19
27
|
description: '',
|
|
@@ -21,5 +29,5 @@ export function computerUseTool(config: ComputerUseTool): Tool {
|
|
|
21
29
|
environment: config.environment,
|
|
22
30
|
excludedPredefinedFunctions: config.excludedPredefinedFunctions,
|
|
23
31
|
},
|
|
24
|
-
}
|
|
32
|
+
} as unknown as GeminiComputerUseTool
|
|
25
33
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import type { Tool } from '@tanstack/ai'
|
|
2
1
|
import type { FileSearch } from '@google/genai'
|
|
2
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type FileSearchToolConfig = FileSearch
|
|
5
|
+
|
|
6
|
+
/** @deprecated Renamed to `FileSearchToolConfig`. Will be removed in a future release. */
|
|
7
|
+
export type FileSearchTool = FileSearchToolConfig
|
|
8
|
+
|
|
9
|
+
export type GeminiFileSearchTool = ProviderTool<'gemini', 'file_search'>
|
|
5
10
|
|
|
6
11
|
export function convertFileSearchToolToAdapterFormat(tool: Tool) {
|
|
7
|
-
const metadata = tool.metadata as
|
|
12
|
+
const metadata = tool.metadata as FileSearchToolConfig
|
|
8
13
|
return {
|
|
9
14
|
fileSearch: metadata,
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
export function fileSearchTool(
|
|
18
|
+
export function fileSearchTool(
|
|
19
|
+
config: FileSearchToolConfig,
|
|
20
|
+
): GeminiFileSearchTool {
|
|
21
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
14
22
|
return {
|
|
15
23
|
name: 'file_search',
|
|
16
24
|
description: '',
|
|
17
25
|
metadata: config,
|
|
18
|
-
}
|
|
26
|
+
} as unknown as GeminiFileSearchTool
|
|
19
27
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { GoogleMaps } from '@google/genai'
|
|
2
|
-
import type { Tool } from '@tanstack/ai'
|
|
2
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type GoogleMapsToolConfig = GoogleMaps
|
|
5
|
+
|
|
6
|
+
/** @deprecated Renamed to `GoogleMapsToolConfig`. Will be removed in a future release. */
|
|
7
|
+
export type GoogleMapsTool = GoogleMapsToolConfig
|
|
8
|
+
|
|
9
|
+
export type GeminiGoogleMapsTool = ProviderTool<'gemini', 'google_maps'>
|
|
5
10
|
|
|
6
11
|
export function convertGoogleMapsToolToAdapterFormat(tool: Tool) {
|
|
7
|
-
const metadata = tool.metadata as
|
|
12
|
+
const metadata = tool.metadata as GoogleMapsToolConfig
|
|
8
13
|
return {
|
|
9
14
|
googleMaps: metadata,
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
export function googleMapsTool(
|
|
18
|
+
export function googleMapsTool(
|
|
19
|
+
config?: GoogleMapsToolConfig,
|
|
20
|
+
): GeminiGoogleMapsTool {
|
|
21
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
14
22
|
return {
|
|
15
23
|
name: 'google_maps',
|
|
16
24
|
description: '',
|
|
17
25
|
metadata: config,
|
|
18
|
-
}
|
|
26
|
+
} as unknown as GeminiGoogleMapsTool
|
|
19
27
|
}
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
import type { GoogleSearchRetrieval } from '@google/genai'
|
|
2
|
-
import type { Tool } from '@tanstack/ai'
|
|
2
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type GoogleSearchRetrievalToolConfig = GoogleSearchRetrieval
|
|
5
|
+
|
|
6
|
+
/** @deprecated Renamed to `GoogleSearchRetrievalToolConfig`. Will be removed in a future release. */
|
|
7
|
+
export type GoogleSearchRetrievalTool = GoogleSearchRetrievalToolConfig
|
|
8
|
+
|
|
9
|
+
export type GeminiGoogleSearchRetrievalTool = ProviderTool<
|
|
10
|
+
'gemini',
|
|
11
|
+
'google_search_retrieval'
|
|
12
|
+
>
|
|
5
13
|
|
|
6
14
|
export function convertGoogleSearchRetrievalToolToAdapterFormat(tool: Tool) {
|
|
7
|
-
const metadata = tool.metadata as
|
|
15
|
+
const metadata = tool.metadata as GoogleSearchRetrievalToolConfig
|
|
8
16
|
return {
|
|
9
17
|
googleSearchRetrieval: metadata,
|
|
10
18
|
}
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export function googleSearchRetrievalTool(
|
|
14
|
-
config?:
|
|
15
|
-
):
|
|
22
|
+
config?: GoogleSearchRetrievalToolConfig,
|
|
23
|
+
): GeminiGoogleSearchRetrievalTool {
|
|
24
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
16
25
|
return {
|
|
17
26
|
name: 'google_search_retrieval',
|
|
18
27
|
description: '',
|
|
19
28
|
metadata: config,
|
|
20
|
-
}
|
|
29
|
+
} as unknown as GeminiGoogleSearchRetrievalTool
|
|
21
30
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { GoogleSearch } from '@google/genai'
|
|
2
|
-
import type { Tool } from '@tanstack/ai'
|
|
2
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type GoogleSearchToolConfig = GoogleSearch
|
|
5
|
+
|
|
6
|
+
/** @deprecated Renamed to `GoogleSearchToolConfig`. Will be removed in a future release. */
|
|
7
|
+
export type GoogleSearchTool = GoogleSearchToolConfig
|
|
8
|
+
|
|
9
|
+
export type GeminiGoogleSearchTool = ProviderTool<'gemini', 'google_search'>
|
|
5
10
|
|
|
6
11
|
export function convertGoogleSearchToolToAdapterFormat(tool: Tool) {
|
|
7
|
-
const metadata = tool.metadata as
|
|
12
|
+
const metadata = tool.metadata as GoogleSearchToolConfig
|
|
8
13
|
return {
|
|
9
14
|
googleSearch: metadata,
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
export function googleSearchTool(
|
|
18
|
+
export function googleSearchTool(
|
|
19
|
+
config?: GoogleSearchToolConfig,
|
|
20
|
+
): GeminiGoogleSearchTool {
|
|
21
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
14
22
|
return {
|
|
15
23
|
name: 'google_search',
|
|
16
24
|
description: '',
|
|
17
25
|
metadata: config,
|
|
18
|
-
}
|
|
26
|
+
} as unknown as GeminiGoogleSearchTool
|
|
19
27
|
}
|
package/src/tools/index.ts
CHANGED
|
@@ -7,6 +7,55 @@ import type { GoogleSearchRetrievalTool } from './google-search-retriveal-tool'
|
|
|
7
7
|
import type { GoogleSearchTool } from './google-search-tool'
|
|
8
8
|
import type { UrlContextTool } from './url-context-tool'
|
|
9
9
|
|
|
10
|
+
export {
|
|
11
|
+
codeExecutionTool,
|
|
12
|
+
type GeminiCodeExecutionTool,
|
|
13
|
+
type CodeExecutionToolConfig,
|
|
14
|
+
type CodeExecutionTool,
|
|
15
|
+
} from './code-execution-tool'
|
|
16
|
+
export {
|
|
17
|
+
computerUseTool,
|
|
18
|
+
type GeminiComputerUseTool,
|
|
19
|
+
type ComputerUseToolConfig,
|
|
20
|
+
type ComputerUseTool,
|
|
21
|
+
} from './computer-use-tool'
|
|
22
|
+
export {
|
|
23
|
+
fileSearchTool,
|
|
24
|
+
type GeminiFileSearchTool,
|
|
25
|
+
type FileSearchToolConfig,
|
|
26
|
+
type FileSearchTool,
|
|
27
|
+
} from './file-search-tool'
|
|
28
|
+
export {
|
|
29
|
+
functionDeclarationTools,
|
|
30
|
+
type FunctionDeclarationTool,
|
|
31
|
+
} from './function-declaration-tool'
|
|
32
|
+
export {
|
|
33
|
+
googleMapsTool,
|
|
34
|
+
type GeminiGoogleMapsTool,
|
|
35
|
+
type GoogleMapsToolConfig,
|
|
36
|
+
type GoogleMapsTool,
|
|
37
|
+
} from './google-maps-tool'
|
|
38
|
+
export {
|
|
39
|
+
googleSearchRetrievalTool,
|
|
40
|
+
type GeminiGoogleSearchRetrievalTool,
|
|
41
|
+
type GoogleSearchRetrievalToolConfig,
|
|
42
|
+
type GoogleSearchRetrievalTool,
|
|
43
|
+
} from './google-search-retriveal-tool'
|
|
44
|
+
export {
|
|
45
|
+
googleSearchTool,
|
|
46
|
+
type GeminiGoogleSearchTool,
|
|
47
|
+
type GoogleSearchToolConfig,
|
|
48
|
+
type GoogleSearchTool,
|
|
49
|
+
} from './google-search-tool'
|
|
50
|
+
export {
|
|
51
|
+
urlContextTool,
|
|
52
|
+
type GeminiUrlContextTool,
|
|
53
|
+
type UrlContextToolConfig,
|
|
54
|
+
type UrlContextTool,
|
|
55
|
+
} from './url-context-tool'
|
|
56
|
+
|
|
57
|
+
// Keep the existing discriminated union defined inline (no barrel exports).
|
|
58
|
+
// Built from the deprecated config-type aliases — matches the SDK-adapter shape.
|
|
10
59
|
export type GoogleGeminiTool =
|
|
11
60
|
| CodeExecutionTool
|
|
12
61
|
| ComputerUseTool
|
|
@@ -16,3 +65,5 @@ export type GoogleGeminiTool =
|
|
|
16
65
|
| GoogleSearchRetrievalTool
|
|
17
66
|
| GoogleSearchTool
|
|
18
67
|
| UrlContextTool
|
|
68
|
+
|
|
69
|
+
export { convertToolsToProviderFormat } from './tool-converter'
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type { Tool } from '@tanstack/ai'
|
|
1
|
+
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface UrlContextToolConfig {}
|
|
4
|
+
|
|
5
|
+
/** @deprecated Renamed to `UrlContextToolConfig`. Will be removed in a future release. */
|
|
6
|
+
export type UrlContextTool = UrlContextToolConfig
|
|
7
|
+
|
|
8
|
+
export type GeminiUrlContextTool = ProviderTool<'gemini', 'url_context'>
|
|
4
9
|
|
|
5
10
|
export function convertUrlContextToolToAdapterFormat(_tool: Tool) {
|
|
6
11
|
return {
|
|
@@ -8,10 +13,11 @@ export function convertUrlContextToolToAdapterFormat(_tool: Tool) {
|
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
export function urlContextTool():
|
|
16
|
+
export function urlContextTool(): GeminiUrlContextTool {
|
|
17
|
+
// Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.
|
|
12
18
|
return {
|
|
13
19
|
name: 'url_context',
|
|
14
20
|
description: '',
|
|
15
21
|
metadata: {},
|
|
16
|
-
}
|
|
22
|
+
} as unknown as GeminiUrlContextTool
|
|
17
23
|
}
|