@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.
Files changed (43) hide show
  1. package/dist/esm/adapters/text.d.ts +9 -4
  2. package/dist/esm/adapters/text.js.map +1 -1
  3. package/dist/esm/index.d.ts +1 -1
  4. package/dist/esm/model-meta.d.ts +38 -10
  5. package/dist/esm/model-meta.js.map +1 -1
  6. package/dist/esm/tools/code-execution-tool.d.ts +6 -3
  7. package/dist/esm/tools/code-execution-tool.js +8 -0
  8. package/dist/esm/tools/code-execution-tool.js.map +1 -1
  9. package/dist/esm/tools/computer-use-tool.d.ts +6 -3
  10. package/dist/esm/tools/computer-use-tool.js +11 -0
  11. package/dist/esm/tools/computer-use-tool.js.map +1 -1
  12. package/dist/esm/tools/file-search-tool.d.ts +6 -3
  13. package/dist/esm/tools/file-search-tool.js +9 -1
  14. package/dist/esm/tools/file-search-tool.js.map +1 -1
  15. package/dist/esm/tools/function-declaration-tool.js +29 -0
  16. package/dist/esm/tools/function-declaration-tool.js.map +1 -0
  17. package/dist/esm/tools/google-maps-tool.d.ts +6 -3
  18. package/dist/esm/tools/google-maps-tool.js +9 -1
  19. package/dist/esm/tools/google-maps-tool.js.map +1 -1
  20. package/dist/esm/tools/google-search-retriveal-tool.d.ts +6 -3
  21. package/dist/esm/tools/google-search-retriveal-tool.js +9 -1
  22. package/dist/esm/tools/google-search-retriveal-tool.js.map +1 -1
  23. package/dist/esm/tools/google-search-tool.d.ts +6 -3
  24. package/dist/esm/tools/google-search-tool.js +9 -1
  25. package/dist/esm/tools/google-search-tool.js.map +1 -1
  26. package/dist/esm/tools/index.d.ts +9 -0
  27. package/dist/esm/tools/index.js +21 -0
  28. package/dist/esm/tools/index.js.map +1 -0
  29. package/dist/esm/tools/url-context-tool.d.ts +6 -3
  30. package/dist/esm/tools/url-context-tool.js +9 -1
  31. package/dist/esm/tools/url-context-tool.js.map +1 -1
  32. package/package.json +8 -3
  33. package/src/adapters/text.ts +19 -4
  34. package/src/index.ts +1 -0
  35. package/src/model-meta.ts +59 -72
  36. package/src/tools/code-execution-tool.ts +10 -4
  37. package/src/tools/computer-use-tool.ts +13 -5
  38. package/src/tools/file-search-tool.ts +13 -5
  39. package/src/tools/google-maps-tool.ts +13 -5
  40. package/src/tools/google-search-retriveal-tool.ts +15 -6
  41. package/src/tools/google-search-tool.ts +13 -5
  42. package/src/tools/index.ts +51 -0
  43. package/src/tools/url-context-tool.ts +10 -4
@@ -1 +1 @@
1
- {"version":3,"file":"computer-use-tool.js","sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import type { ComputerUse } from '@google/genai'\nimport type { Tool } from '@tanstack/ai'\n\nexport type ComputerUseTool = ComputerUse\n\nexport function convertComputerUseToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as ComputerUseTool\n return {\n computerUse: {\n environment: metadata.environment,\n excludedPredefinedFunctions: metadata.excludedPredefinedFunctions,\n },\n }\n}\n\nexport function computerUseTool(config: ComputerUseTool): Tool {\n return {\n name: 'computer_use',\n description: '',\n metadata: {\n environment: config.environment,\n excludedPredefinedFunctions: config.excludedPredefinedFunctions,\n },\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,sCAAsC,MAAY;AAChE,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,aAAa;AAAA,MACX,aAAa,SAAS;AAAA,MACtB,6BAA6B,SAAS;AAAA,IAAA;AAAA,EACxC;AAEJ;"}
1
+ {"version":3,"file":"computer-use-tool.js","sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import type { ComputerUse } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type ComputerUseToolConfig = ComputerUse\n\n/** @deprecated Renamed to `ComputerUseToolConfig`. Will be removed in a future release. */\nexport type ComputerUseTool = ComputerUseToolConfig\n\nexport type GeminiComputerUseTool = ProviderTool<'gemini', 'computer_use'>\n\nexport function convertComputerUseToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as ComputerUseToolConfig\n return {\n computerUse: {\n environment: metadata.environment,\n excludedPredefinedFunctions: metadata.excludedPredefinedFunctions,\n },\n }\n}\n\nexport function computerUseTool(\n config: ComputerUseToolConfig,\n): GeminiComputerUseTool {\n // Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.\n return {\n name: 'computer_use',\n description: '',\n metadata: {\n environment: config.environment,\n excludedPredefinedFunctions: config.excludedPredefinedFunctions,\n },\n } as unknown as GeminiComputerUseTool\n}\n"],"names":[],"mappings":"AAUO,SAAS,sCAAsC,MAAY;AAChE,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,aAAa;AAAA,MACX,aAAa,SAAS;AAAA,MACtB,6BAA6B,SAAS;AAAA,IAAA;AAAA,EACxC;AAEJ;AAEO,SAAS,gBACd,QACuB;AAEvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,MACR,aAAa,OAAO;AAAA,MACpB,6BAA6B,OAAO;AAAA,IAAA;AAAA,EACtC;AAEJ;"}
@@ -1,7 +1,10 @@
1
- import { Tool } from '@tanstack/ai';
2
1
  import { FileSearch } from '@google/genai';
3
- export type FileSearchTool = FileSearch;
2
+ import { ProviderTool, Tool } from '@tanstack/ai';
3
+ export type FileSearchToolConfig = FileSearch;
4
+ /** @deprecated Renamed to `FileSearchToolConfig`. Will be removed in a future release. */
5
+ export type FileSearchTool = FileSearchToolConfig;
6
+ export type GeminiFileSearchTool = ProviderTool<'gemini', 'file_search'>;
4
7
  export declare function convertFileSearchToolToAdapterFormat(tool: Tool): {
5
8
  fileSearch: FileSearch;
6
9
  };
7
- export declare function fileSearchTool(config: FileSearchTool): Tool;
10
+ export declare function fileSearchTool(config: FileSearchToolConfig): GeminiFileSearchTool;
@@ -4,7 +4,15 @@ function convertFileSearchToolToAdapterFormat(tool) {
4
4
  fileSearch: metadata
5
5
  };
6
6
  }
7
+ function fileSearchTool(config) {
8
+ return {
9
+ name: "file_search",
10
+ description: "",
11
+ metadata: config
12
+ };
13
+ }
7
14
  export {
8
- convertFileSearchToolToAdapterFormat
15
+ convertFileSearchToolToAdapterFormat,
16
+ fileSearchTool
9
17
  };
10
18
  //# sourceMappingURL=file-search-tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-search-tool.js","sources":["../../../src/tools/file-search-tool.ts"],"sourcesContent":["import type { Tool } from '@tanstack/ai'\nimport type { FileSearch } from '@google/genai'\n\nexport type FileSearchTool = FileSearch\n\nexport function convertFileSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as FileSearchTool\n return {\n fileSearch: metadata,\n }\n}\n\nexport function fileSearchTool(config: FileSearchTool): Tool {\n return {\n name: 'file_search',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;"}
1
+ {"version":3,"file":"file-search-tool.js","sources":["../../../src/tools/file-search-tool.ts"],"sourcesContent":["import type { FileSearch } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type FileSearchToolConfig = FileSearch\n\n/** @deprecated Renamed to `FileSearchToolConfig`. Will be removed in a future release. */\nexport type FileSearchTool = FileSearchToolConfig\n\nexport type GeminiFileSearchTool = ProviderTool<'gemini', 'file_search'>\n\nexport function convertFileSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as FileSearchToolConfig\n return {\n fileSearch: metadata,\n }\n}\n\nexport function fileSearchTool(\n config: FileSearchToolConfig,\n): GeminiFileSearchTool {\n // Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.\n return {\n name: 'file_search',\n description: '',\n metadata: config,\n } as unknown as GeminiFileSearchTool\n}\n"],"names":[],"mappings":"AAUO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;AAEO,SAAS,eACd,QACsB;AAEtB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA;AAEd;"}
@@ -0,0 +1,29 @@
1
+ const validateFunctionDeclarationTool = (tool) => {
2
+ const nameRegex = /^[a-zA-Z0-9_:.-]{1,64}$/;
3
+ const valid = nameRegex.test(tool.name);
4
+ if (!valid) {
5
+ throw new Error(
6
+ `Invalid function name: ${tool.name}. Must be 1-64 characters long and contain only a-z, A-Z, 0-9, underscores, colons, dots, and dashes.`
7
+ );
8
+ }
9
+ if (tool.parameters && tool.parametersJsonSchema) {
10
+ throw new Error(
11
+ `FunctionDeclarationTool cannot have both 'parameters' and 'parametersJsonSchema' defined. Please use only one.`
12
+ );
13
+ }
14
+ if (tool.response && tool.responseJsonSchema) {
15
+ throw new Error(
16
+ `FunctionDeclarationTool cannot have both 'response' and 'responseJsonSchema' defined. Please use only one.`
17
+ );
18
+ }
19
+ };
20
+ function functionDeclarationTools(tools) {
21
+ tools.forEach(validateFunctionDeclarationTool);
22
+ return {
23
+ functionDeclarations: tools
24
+ };
25
+ }
26
+ export {
27
+ functionDeclarationTools
28
+ };
29
+ //# sourceMappingURL=function-declaration-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-declaration-tool.js","sources":["../../../src/tools/function-declaration-tool.ts"],"sourcesContent":["import type { FunctionDeclaration } from '@google/genai'\n\nexport type FunctionDeclarationTool = FunctionDeclaration\n\nconst validateFunctionDeclarationTool = (tool: FunctionDeclarationTool) => {\n const nameRegex = /^[a-zA-Z0-9_:.-]{1,64}$/\n const valid = nameRegex.test(tool.name!)\n if (!valid) {\n throw new Error(\n `Invalid function name: ${tool.name}. Must be 1-64 characters long and contain only a-z, A-Z, 0-9, underscores, colons, dots, and dashes.`,\n )\n }\n\n if (tool.parameters && tool.parametersJsonSchema) {\n throw new Error(\n `FunctionDeclarationTool cannot have both 'parameters' and 'parametersJsonSchema' defined. Please use only one.`,\n )\n }\n\n if (tool.response && tool.responseJsonSchema) {\n throw new Error(\n `FunctionDeclarationTool cannot have both 'response' and 'responseJsonSchema' defined. Please use only one.`,\n )\n }\n}\n\nexport function functionDeclarationTools(\n tools: Array<FunctionDeclarationTool>,\n) {\n tools.forEach(validateFunctionDeclarationTool)\n return {\n functionDeclarations: tools,\n }\n}\n"],"names":[],"mappings":"AAIA,MAAM,kCAAkC,CAAC,SAAkC;AACzE,QAAM,YAAY;AAClB,QAAM,QAAQ,UAAU,KAAK,KAAK,IAAK;AACvC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR,0BAA0B,KAAK,IAAI;AAAA,IAAA;AAAA,EAEvC;AAEA,MAAI,KAAK,cAAc,KAAK,sBAAsB;AAChD,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,MAAI,KAAK,YAAY,KAAK,oBAAoB;AAC5C,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACF;AAEO,SAAS,yBACd,OACA;AACA,QAAM,QAAQ,+BAA+B;AAC7C,SAAO;AAAA,IACL,sBAAsB;AAAA,EAAA;AAE1B;"}
@@ -1,7 +1,10 @@
1
1
  import { GoogleMaps } from '@google/genai';
2
- import { Tool } from '@tanstack/ai';
3
- export type GoogleMapsTool = GoogleMaps;
2
+ import { ProviderTool, Tool } from '@tanstack/ai';
3
+ export type GoogleMapsToolConfig = GoogleMaps;
4
+ /** @deprecated Renamed to `GoogleMapsToolConfig`. Will be removed in a future release. */
5
+ export type GoogleMapsTool = GoogleMapsToolConfig;
6
+ export type GeminiGoogleMapsTool = ProviderTool<'gemini', 'google_maps'>;
4
7
  export declare function convertGoogleMapsToolToAdapterFormat(tool: Tool): {
5
8
  googleMaps: GoogleMaps;
6
9
  };
7
- export declare function googleMapsTool(config?: GoogleMapsTool): Tool;
10
+ export declare function googleMapsTool(config?: GoogleMapsToolConfig): GeminiGoogleMapsTool;
@@ -4,7 +4,15 @@ function convertGoogleMapsToolToAdapterFormat(tool) {
4
4
  googleMaps: metadata
5
5
  };
6
6
  }
7
+ function googleMapsTool(config) {
8
+ return {
9
+ name: "google_maps",
10
+ description: "",
11
+ metadata: config
12
+ };
13
+ }
7
14
  export {
8
- convertGoogleMapsToolToAdapterFormat
15
+ convertGoogleMapsToolToAdapterFormat,
16
+ googleMapsTool
9
17
  };
10
18
  //# sourceMappingURL=google-maps-tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"google-maps-tool.js","sources":["../../../src/tools/google-maps-tool.ts"],"sourcesContent":["import type { GoogleMaps } from '@google/genai'\nimport type { Tool } from '@tanstack/ai'\n\nexport type GoogleMapsTool = GoogleMaps\n\nexport function convertGoogleMapsToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleMapsTool\n return {\n googleMaps: metadata,\n }\n}\n\nexport function googleMapsTool(config?: GoogleMapsTool): Tool {\n return {\n name: 'google_maps',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;"}
1
+ {"version":3,"file":"google-maps-tool.js","sources":["../../../src/tools/google-maps-tool.ts"],"sourcesContent":["import type { GoogleMaps } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type GoogleMapsToolConfig = GoogleMaps\n\n/** @deprecated Renamed to `GoogleMapsToolConfig`. Will be removed in a future release. */\nexport type GoogleMapsTool = GoogleMapsToolConfig\n\nexport type GeminiGoogleMapsTool = ProviderTool<'gemini', 'google_maps'>\n\nexport function convertGoogleMapsToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleMapsToolConfig\n return {\n googleMaps: metadata,\n }\n}\n\nexport function googleMapsTool(\n config?: GoogleMapsToolConfig,\n): GeminiGoogleMapsTool {\n // Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.\n return {\n name: 'google_maps',\n description: '',\n metadata: config,\n } as unknown as GeminiGoogleMapsTool\n}\n"],"names":[],"mappings":"AAUO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;AAEO,SAAS,eACd,QACsB;AAEtB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA;AAEd;"}
@@ -1,7 +1,10 @@
1
1
  import { GoogleSearchRetrieval } from '@google/genai';
2
- import { Tool } from '@tanstack/ai';
3
- export type GoogleSearchRetrievalTool = GoogleSearchRetrieval;
2
+ import { ProviderTool, Tool } from '@tanstack/ai';
3
+ export type GoogleSearchRetrievalToolConfig = GoogleSearchRetrieval;
4
+ /** @deprecated Renamed to `GoogleSearchRetrievalToolConfig`. Will be removed in a future release. */
5
+ export type GoogleSearchRetrievalTool = GoogleSearchRetrievalToolConfig;
6
+ export type GeminiGoogleSearchRetrievalTool = ProviderTool<'gemini', 'google_search_retrieval'>;
4
7
  export declare function convertGoogleSearchRetrievalToolToAdapterFormat(tool: Tool): {
5
8
  googleSearchRetrieval: GoogleSearchRetrieval;
6
9
  };
7
- export declare function googleSearchRetrievalTool(config?: GoogleSearchRetrievalTool): Tool;
10
+ export declare function googleSearchRetrievalTool(config?: GoogleSearchRetrievalToolConfig): GeminiGoogleSearchRetrievalTool;
@@ -4,7 +4,15 @@ function convertGoogleSearchRetrievalToolToAdapterFormat(tool) {
4
4
  googleSearchRetrieval: metadata
5
5
  };
6
6
  }
7
+ function googleSearchRetrievalTool(config) {
8
+ return {
9
+ name: "google_search_retrieval",
10
+ description: "",
11
+ metadata: config
12
+ };
13
+ }
7
14
  export {
8
- convertGoogleSearchRetrievalToolToAdapterFormat
15
+ convertGoogleSearchRetrievalToolToAdapterFormat,
16
+ googleSearchRetrievalTool
9
17
  };
10
18
  //# sourceMappingURL=google-search-retriveal-tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"google-search-retriveal-tool.js","sources":["../../../src/tools/google-search-retriveal-tool.ts"],"sourcesContent":["import type { GoogleSearchRetrieval } from '@google/genai'\nimport type { Tool } from '@tanstack/ai'\n\nexport type GoogleSearchRetrievalTool = GoogleSearchRetrieval\n\nexport function convertGoogleSearchRetrievalToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleSearchRetrievalTool\n return {\n googleSearchRetrieval: metadata,\n }\n}\n\nexport function googleSearchRetrievalTool(\n config?: GoogleSearchRetrievalTool,\n): Tool {\n return {\n name: 'google_search_retrieval',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,gDAAgD,MAAY;AAC1E,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,uBAAuB;AAAA,EAAA;AAE3B;"}
1
+ {"version":3,"file":"google-search-retriveal-tool.js","sources":["../../../src/tools/google-search-retriveal-tool.ts"],"sourcesContent":["import type { GoogleSearchRetrieval } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type GoogleSearchRetrievalToolConfig = GoogleSearchRetrieval\n\n/** @deprecated Renamed to `GoogleSearchRetrievalToolConfig`. Will be removed in a future release. */\nexport type GoogleSearchRetrievalTool = GoogleSearchRetrievalToolConfig\n\nexport type GeminiGoogleSearchRetrievalTool = ProviderTool<\n 'gemini',\n 'google_search_retrieval'\n>\n\nexport function convertGoogleSearchRetrievalToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleSearchRetrievalToolConfig\n return {\n googleSearchRetrieval: metadata,\n }\n}\n\nexport function googleSearchRetrievalTool(\n config?: GoogleSearchRetrievalToolConfig,\n): GeminiGoogleSearchRetrievalTool {\n // Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.\n return {\n name: 'google_search_retrieval',\n description: '',\n metadata: config,\n } as unknown as GeminiGoogleSearchRetrievalTool\n}\n"],"names":[],"mappings":"AAaO,SAAS,gDAAgD,MAAY;AAC1E,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,uBAAuB;AAAA,EAAA;AAE3B;AAEO,SAAS,0BACd,QACiC;AAEjC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA;AAEd;"}
@@ -1,7 +1,10 @@
1
1
  import { GoogleSearch } from '@google/genai';
2
- import { Tool } from '@tanstack/ai';
3
- export type GoogleSearchTool = GoogleSearch;
2
+ import { ProviderTool, Tool } from '@tanstack/ai';
3
+ export type GoogleSearchToolConfig = GoogleSearch;
4
+ /** @deprecated Renamed to `GoogleSearchToolConfig`. Will be removed in a future release. */
5
+ export type GoogleSearchTool = GoogleSearchToolConfig;
6
+ export type GeminiGoogleSearchTool = ProviderTool<'gemini', 'google_search'>;
4
7
  export declare function convertGoogleSearchToolToAdapterFormat(tool: Tool): {
5
8
  googleSearch: GoogleSearch;
6
9
  };
7
- export declare function googleSearchTool(config?: GoogleSearchTool): Tool;
10
+ export declare function googleSearchTool(config?: GoogleSearchToolConfig): GeminiGoogleSearchTool;
@@ -4,7 +4,15 @@ function convertGoogleSearchToolToAdapterFormat(tool) {
4
4
  googleSearch: metadata
5
5
  };
6
6
  }
7
+ function googleSearchTool(config) {
8
+ return {
9
+ name: "google_search",
10
+ description: "",
11
+ metadata: config
12
+ };
13
+ }
7
14
  export {
8
- convertGoogleSearchToolToAdapterFormat
15
+ convertGoogleSearchToolToAdapterFormat,
16
+ googleSearchTool
9
17
  };
10
18
  //# sourceMappingURL=google-search-tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"google-search-tool.js","sources":["../../../src/tools/google-search-tool.ts"],"sourcesContent":["import type { GoogleSearch } from '@google/genai'\nimport type { Tool } from '@tanstack/ai'\n\nexport type GoogleSearchTool = GoogleSearch\n\nexport function convertGoogleSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleSearchTool\n return {\n googleSearch: metadata,\n }\n}\n\nexport function googleSearchTool(config?: GoogleSearchTool): Tool {\n return {\n name: 'google_search',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,uCAAuC,MAAY;AACjE,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,cAAc;AAAA,EAAA;AAElB;"}
1
+ {"version":3,"file":"google-search-tool.js","sources":["../../../src/tools/google-search-tool.ts"],"sourcesContent":["import type { GoogleSearch } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type GoogleSearchToolConfig = GoogleSearch\n\n/** @deprecated Renamed to `GoogleSearchToolConfig`. Will be removed in a future release. */\nexport type GoogleSearchTool = GoogleSearchToolConfig\n\nexport type GeminiGoogleSearchTool = ProviderTool<'gemini', 'google_search'>\n\nexport function convertGoogleSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleSearchToolConfig\n return {\n googleSearch: metadata,\n }\n}\n\nexport function googleSearchTool(\n config?: GoogleSearchToolConfig,\n): GeminiGoogleSearchTool {\n // Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.\n return {\n name: 'google_search',\n description: '',\n metadata: config,\n } as unknown as GeminiGoogleSearchTool\n}\n"],"names":[],"mappings":"AAUO,SAAS,uCAAuC,MAAY;AACjE,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,cAAc;AAAA,EAAA;AAElB;AAEO,SAAS,iBACd,QACwB;AAExB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA;AAEd;"}
@@ -6,4 +6,13 @@ import { GoogleMapsTool } from './google-maps-tool.js';
6
6
  import { GoogleSearchRetrievalTool } from './google-search-retriveal-tool.js';
7
7
  import { GoogleSearchTool } from './google-search-tool.js';
8
8
  import { UrlContextTool } from './url-context-tool.js';
9
+ export { codeExecutionTool, type GeminiCodeExecutionTool, type CodeExecutionToolConfig, type CodeExecutionTool, } from './code-execution-tool.js';
10
+ export { computerUseTool, type GeminiComputerUseTool, type ComputerUseToolConfig, type ComputerUseTool, } from './computer-use-tool.js';
11
+ export { fileSearchTool, type GeminiFileSearchTool, type FileSearchToolConfig, type FileSearchTool, } from './file-search-tool.js';
12
+ export { functionDeclarationTools, type FunctionDeclarationTool, } from './function-declaration-tool.js';
13
+ export { googleMapsTool, type GeminiGoogleMapsTool, type GoogleMapsToolConfig, type GoogleMapsTool, } from './google-maps-tool.js';
14
+ export { googleSearchRetrievalTool, type GeminiGoogleSearchRetrievalTool, type GoogleSearchRetrievalToolConfig, type GoogleSearchRetrievalTool, } from './google-search-retriveal-tool.js';
15
+ export { googleSearchTool, type GeminiGoogleSearchTool, type GoogleSearchToolConfig, type GoogleSearchTool, } from './google-search-tool.js';
16
+ export { urlContextTool, type GeminiUrlContextTool, type UrlContextToolConfig, type UrlContextTool, } from './url-context-tool.js';
9
17
  export type GoogleGeminiTool = CodeExecutionTool | ComputerUseTool | FileSearchTool | FunctionDeclarationTool | GoogleMapsTool | GoogleSearchRetrievalTool | GoogleSearchTool | UrlContextTool;
18
+ export { convertToolsToProviderFormat } from './tool-converter.js';
@@ -0,0 +1,21 @@
1
+ import { codeExecutionTool } from "./code-execution-tool.js";
2
+ import { computerUseTool } from "./computer-use-tool.js";
3
+ import { fileSearchTool } from "./file-search-tool.js";
4
+ import { functionDeclarationTools } from "./function-declaration-tool.js";
5
+ import { googleMapsTool } from "./google-maps-tool.js";
6
+ import { googleSearchRetrievalTool } from "./google-search-retriveal-tool.js";
7
+ import { googleSearchTool } from "./google-search-tool.js";
8
+ import { urlContextTool } from "./url-context-tool.js";
9
+ import { convertToolsToProviderFormat } from "./tool-converter.js";
10
+ export {
11
+ codeExecutionTool,
12
+ computerUseTool,
13
+ convertToolsToProviderFormat,
14
+ fileSearchTool,
15
+ functionDeclarationTools,
16
+ googleMapsTool,
17
+ googleSearchRetrievalTool,
18
+ googleSearchTool,
19
+ urlContextTool
20
+ };
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -1,7 +1,10 @@
1
- import { Tool } from '@tanstack/ai';
2
- export interface UrlContextTool {
1
+ import { ProviderTool, Tool } from '@tanstack/ai';
2
+ export interface UrlContextToolConfig {
3
3
  }
4
+ /** @deprecated Renamed to `UrlContextToolConfig`. Will be removed in a future release. */
5
+ export type UrlContextTool = UrlContextToolConfig;
6
+ export type GeminiUrlContextTool = ProviderTool<'gemini', 'url_context'>;
4
7
  export declare function convertUrlContextToolToAdapterFormat(_tool: Tool): {
5
8
  urlContext: {};
6
9
  };
7
- export declare function urlContextTool(): Tool;
10
+ export declare function urlContextTool(): GeminiUrlContextTool;
@@ -3,7 +3,15 @@ function convertUrlContextToolToAdapterFormat(_tool) {
3
3
  urlContext: {}
4
4
  };
5
5
  }
6
+ function urlContextTool() {
7
+ return {
8
+ name: "url_context",
9
+ description: "",
10
+ metadata: {}
11
+ };
12
+ }
6
13
  export {
7
- convertUrlContextToolToAdapterFormat
14
+ convertUrlContextToolToAdapterFormat,
15
+ urlContextTool
8
16
  };
9
17
  //# sourceMappingURL=url-context-tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"url-context-tool.js","sources":["../../../src/tools/url-context-tool.ts"],"sourcesContent":["import type { Tool } from '@tanstack/ai'\n\nexport interface UrlContextTool {}\n\nexport function convertUrlContextToolToAdapterFormat(_tool: Tool) {\n return {\n urlContext: {},\n }\n}\n\nexport function urlContextTool(): Tool {\n return {\n name: 'url_context',\n description: '',\n metadata: {},\n }\n}\n"],"names":[],"mappings":"AAIO,SAAS,qCAAqC,OAAa;AAChE,SAAO;AAAA,IACL,YAAY,CAAA;AAAA,EAAC;AAEjB;"}
1
+ {"version":3,"file":"url-context-tool.js","sources":["../../../src/tools/url-context-tool.ts"],"sourcesContent":["import type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport interface UrlContextToolConfig {}\n\n/** @deprecated Renamed to `UrlContextToolConfig`. Will be removed in a future release. */\nexport type UrlContextTool = UrlContextToolConfig\n\nexport type GeminiUrlContextTool = ProviderTool<'gemini', 'url_context'>\n\nexport function convertUrlContextToolToAdapterFormat(_tool: Tool) {\n return {\n urlContext: {},\n }\n}\n\nexport function urlContextTool(): GeminiUrlContextTool {\n // Phantom-brand cast: '~provider'/'~toolKind' are type-only and never assigned at runtime.\n return {\n name: 'url_context',\n description: '',\n metadata: {},\n } as unknown as GeminiUrlContextTool\n}\n"],"names":[],"mappings":"AASO,SAAS,qCAAqC,OAAa;AAChE,SAAO;AAAA,IACL,YAAY,CAAA;AAAA,EAAC;AAEjB;AAEO,SAAS,iBAAuC;AAErD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU,CAAA;AAAA,EAAC;AAEf;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-gemini",
3
- "version": "0.8.9",
3
+ "version": "0.9.0",
4
4
  "description": "Google Gemini adapter for TanStack AI",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -16,6 +16,10 @@
16
16
  ".": {
17
17
  "types": "./dist/esm/index.d.ts",
18
18
  "import": "./dist/esm/index.js"
19
+ },
20
+ "./tools": {
21
+ "types": "./dist/esm/tools/index.d.ts",
22
+ "import": "./dist/esm/tools/index.js"
19
23
  }
20
24
  },
21
25
  "files": [
@@ -33,12 +37,13 @@
33
37
  "@google/genai": "^1.43.0"
34
38
  },
35
39
  "peerDependencies": {
36
- "@tanstack/ai": "^0.11.0"
40
+ "@tanstack/ai": "^0.12.0"
37
41
  },
38
42
  "devDependencies": {
39
43
  "@vitest/coverage-v8": "4.0.14",
40
44
  "vite": "^7.2.7",
41
- "@tanstack/ai": "0.11.0"
45
+ "zod": "^4.2.0",
46
+ "@tanstack/ai": "0.12.0"
42
47
  },
43
48
  "scripts": {
44
49
  "build": "vite build",
@@ -9,6 +9,7 @@ import {
9
9
  import type {
10
10
  GEMINI_MODELS,
11
11
  GeminiChatModelProviderOptionsByName,
12
+ GeminiChatModelToolCapabilitiesByName,
12
13
  GeminiModelInputModalitiesByName,
13
14
  } from '../model-meta'
14
15
  import type {
@@ -71,6 +72,15 @@ type ResolveInputModalities<TModel extends string> =
71
72
  ? GeminiModelInputModalitiesByName[TModel]
72
73
  : readonly ['text', 'image', 'audio', 'video', 'document']
73
74
 
75
+ /**
76
+ * Resolve tool capabilities for a specific model.
77
+ * If the model has explicit tools in the map, use those; otherwise use empty tuple.
78
+ */
79
+ type ResolveToolCapabilities<TModel extends string> =
80
+ TModel extends keyof GeminiChatModelToolCapabilitiesByName
81
+ ? NonNullable<GeminiChatModelToolCapabilitiesByName[TModel]>
82
+ : readonly []
83
+
74
84
  // ===========================
75
85
  // Adapter Implementation
76
86
  // ===========================
@@ -83,14 +93,17 @@ type ResolveInputModalities<TModel extends string> =
83
93
  */
84
94
  export class GeminiTextAdapter<
85
95
  TModel extends (typeof GEMINI_MODELS)[number],
86
- TProviderOptions extends object = ResolveProviderOptions<TModel>,
96
+ TProviderOptions extends Record<string, any> = ResolveProviderOptions<TModel>,
87
97
  TInputModalities extends ReadonlyArray<Modality> =
88
98
  ResolveInputModalities<TModel>,
99
+ TToolCapabilities extends ReadonlyArray<string> =
100
+ ResolveToolCapabilities<TModel>,
89
101
  > extends BaseTextAdapter<
90
102
  TModel,
91
103
  TProviderOptions,
92
104
  TInputModalities,
93
- GeminiMessageMetadataByModality
105
+ GeminiMessageMetadataByModality,
106
+ TToolCapabilities
94
107
  > {
95
108
  readonly kind = 'text' as const
96
109
  readonly name = 'gemini' as const
@@ -810,7 +823,8 @@ export function createGeminiChat<TModel extends (typeof GEMINI_MODELS)[number]>(
810
823
  ): GeminiTextAdapter<
811
824
  TModel,
812
825
  ResolveProviderOptions<TModel>,
813
- ResolveInputModalities<TModel>
826
+ ResolveInputModalities<TModel>,
827
+ ResolveToolCapabilities<TModel>
814
828
  > {
815
829
  return new GeminiTextAdapter({ apiKey, ...config }, model)
816
830
  }
@@ -825,7 +839,8 @@ export function geminiText<TModel extends (typeof GEMINI_MODELS)[number]>(
825
839
  ): GeminiTextAdapter<
826
840
  TModel,
827
841
  ResolveProviderOptions<TModel>,
828
- ResolveInputModalities<TModel>
842
+ ResolveInputModalities<TModel>,
843
+ ResolveToolCapabilities<TModel>
829
844
  > {
830
845
  const apiKey = getGeminiApiKeyFromEnv()
831
846
  return createGeminiChat(model, apiKey, config)
package/src/index.ts CHANGED
@@ -67,6 +67,7 @@ export type { GeminiTTSVoice } from './model-meta'
67
67
 
68
68
  export type {
69
69
  GeminiChatModelProviderOptionsByName,
70
+ GeminiChatModelToolCapabilitiesByName,
70
71
  GeminiModelInputModalitiesByName,
71
72
  } from './model-meta'
72
73
  export type {