@composio/google 0.4.0 → 0.5.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/index.mjs ADDED
@@ -0,0 +1,214 @@
1
+ import { BaseNonAgenticProvider } from "@composio/core";
2
+
3
+ //#region src/index.ts
4
+ /**
5
+ * Google GenAI Provider
6
+ *
7
+ * This provider provides a set of tools for interacting with Google's GenAI API.
8
+ * It supports both the Gemini Developer API and Vertex AI implementations.
9
+ *
10
+ * @packageDocumentation
11
+ * @module providers/google
12
+ */
13
+ /**
14
+ * Google GenAI Provider for Composio SDK
15
+ * Implements the BaseNonAgenticProvider to wrap Composio tools for use with Google's GenAI API
16
+ */
17
+ var GoogleProvider = class extends BaseNonAgenticProvider {
18
+ name = "google";
19
+ /**
20
+ * Creates a new instance of the GoogleProvider.
21
+ *
22
+ * This provider enables integration with Google's GenAI API,
23
+ * supporting both the Gemini Developer API and Vertex AI implementations.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Initialize the Google provider
28
+ * const provider = new GoogleProvider();
29
+ *
30
+ * // Use with Composio
31
+ * const composio = new Composio({
32
+ * apiKey: 'your-api-key',
33
+ * provider: new GoogleProvider()
34
+ * });
35
+ *
36
+ * // Use the provider to wrap tools for Google GenAI
37
+ * const googleTools = provider.wrapTools(composioTools);
38
+ * ```
39
+ */
40
+ constructor() {
41
+ super();
42
+ }
43
+ /**
44
+ * Transform MCP URL response into Anthropic-specific format.
45
+ * By default, Anthropic uses the standard format (same as default),
46
+ * but this method is here to show providers can customize if needed.
47
+ *
48
+ * @param data - The MCP URL response data
49
+ * @returns Standard MCP server response format
50
+ */
51
+ wrapMcpServerResponse(data) {
52
+ return data.map((item) => ({
53
+ url: new URL(item.url),
54
+ name: item.name
55
+ }));
56
+ }
57
+ /**
58
+ * Wraps a Composio tool in the Google GenAI function declaration format.
59
+ *
60
+ * This method transforms a Composio tool definition into the format
61
+ * expected by Google's GenAI API for function calling.
62
+ *
63
+ * @param tool - The Composio tool to wrap
64
+ * @returns The wrapped tool in Google GenAI format
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * // Wrap a single tool for use with Google GenAI
69
+ * const composioTool = {
70
+ * slug: 'SEARCH_TOOL',
71
+ * description: 'Search for information',
72
+ * inputParameters: {
73
+ * type: 'object',
74
+ * properties: {
75
+ * query: { type: 'string' }
76
+ * },
77
+ * required: ['query']
78
+ * }
79
+ * };
80
+ *
81
+ * const googleTool = provider.wrapTool(composioTool);
82
+ * // Use with Google GenAI SDK
83
+ * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
84
+ * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
85
+ *
86
+ * const result = await model.generateContent({
87
+ * contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
88
+ * tools: [googleTool]
89
+ * });
90
+ * ```
91
+ */
92
+ wrapTool(tool) {
93
+ return {
94
+ name: tool.slug,
95
+ description: tool.description || "",
96
+ parameters: {
97
+ type: "object",
98
+ description: tool.description || "",
99
+ properties: tool.inputParameters?.properties || {},
100
+ required: tool.inputParameters?.required || []
101
+ }
102
+ };
103
+ }
104
+ /**
105
+ * Wraps a list of Composio tools in the Google GenAI function declaration format.
106
+ *
107
+ * This method transforms multiple Composio tool definitions into the format
108
+ * expected by Google's GenAI API for function calling.
109
+ *
110
+ * @param tools - Array of Composio tools to wrap
111
+ * @returns Array of wrapped tools in Google GenAI format
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * // Wrap multiple tools for use with Google GenAI
116
+ * const composioTools = [
117
+ * {
118
+ * slug: 'SEARCH_TOOL',
119
+ * description: 'Search for information',
120
+ * inputParameters: {
121
+ * type: 'object',
122
+ * properties: {
123
+ * query: { type: 'string' }
124
+ * },
125
+ * required: ['query']
126
+ * }
127
+ * },
128
+ * {
129
+ * slug: 'WEATHER_TOOL',
130
+ * description: 'Get weather information',
131
+ * inputParameters: {
132
+ * type: 'object',
133
+ * properties: {
134
+ * location: { type: 'string' }
135
+ * },
136
+ * required: ['location']
137
+ * }
138
+ * }
139
+ * ];
140
+ *
141
+ * const googleTools = provider.wrapTools(composioTools);
142
+ *
143
+ * // Use with Google GenAI SDK
144
+ * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
145
+ * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
146
+ *
147
+ * const result = await model.generateContent({
148
+ * contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
149
+ * tools: googleTools
150
+ * });
151
+ * ```
152
+ */
153
+ wrapTools(tools) {
154
+ return tools.map((tool) => this.wrapTool(tool));
155
+ }
156
+ /**
157
+ * Executes a tool call from Google GenAI.
158
+ *
159
+ * This method processes a function call from Google's GenAI API,
160
+ * executes the corresponding Composio tool, and returns the result.
161
+ *
162
+ * @param userId - The user ID for authentication and tracking
163
+ * @param tool - The Google GenAI function call to execute
164
+ * @param options - Optional execution options like connected account ID
165
+ * @param modifiers - Optional execution modifiers for tool behavior
166
+ * @returns The result of the tool execution as a JSON string
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * // Execute a tool call from Google GenAI
171
+ * const functionCall = {
172
+ * name: 'SEARCH_TOOL',
173
+ * args: {
174
+ * query: 'composio documentation'
175
+ * }
176
+ * };
177
+ *
178
+ * const result = await provider.executeToolCall(
179
+ * 'user123',
180
+ * functionCall,
181
+ * { connectedAccountId: 'conn_xyz456' }
182
+ * );
183
+ *
184
+ * // Parse the result and use it in your application
185
+ * const searchResults = JSON.parse(result);
186
+ * console.log(searchResults);
187
+ *
188
+ * // You can also use the result to continue the conversation
189
+ * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
190
+ * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
191
+ *
192
+ * await model.generateContent({
193
+ * contents: [
194
+ * { role: 'user', parts: [{ text: 'Search for Composio' }] },
195
+ * { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
196
+ * ]
197
+ * });
198
+ * ```
199
+ */
200
+ async executeToolCall(userId, tool, options, modifiers) {
201
+ const payload = {
202
+ arguments: tool.args,
203
+ connectedAccountId: options?.connectedAccountId,
204
+ customAuthParams: options?.customAuthParams,
205
+ customConnectionData: options?.customConnectionData,
206
+ userId
207
+ };
208
+ const result = await this.executeTool(tool.name, payload, modifiers);
209
+ return JSON.stringify(result);
210
+ }
211
+ };
212
+
213
+ //#endregion
214
+ export { GoogleProvider };
package/package.json CHANGED
@@ -1,17 +1,25 @@
1
1
  {
2
2
  "name": "@composio/google",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Google GenAI Provider for Composio SDK",
5
- "main": "dist/index.js",
6
- "type": "module",
5
+ "main": "dist/index.mjs",
7
6
  "publishConfig": {
8
7
  "access": "public"
9
8
  },
10
9
  "exports": {
11
10
  ".": {
12
- "import": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
14
- "require": "./dist/index.cjs"
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ },
19
+ "default": {
20
+ "types": "./dist/index.d.cts",
21
+ "default": "./dist/index.cjs"
22
+ }
15
23
  }
16
24
  },
17
25
  "files": [
@@ -28,18 +36,18 @@
28
36
  "author": "",
29
37
  "license": "ISC",
30
38
  "peerDependencies": {
31
- "@composio/core": "0.4.0",
39
+ "@composio/core": "0.5.0",
32
40
  "@google/genai": "^1.1.0"
33
41
  },
34
42
  "devDependencies": {
35
- "tsup": "^8.5.0",
43
+ "tsdown": "^0.18.4",
36
44
  "typescript": "^5.9.2",
37
- "@composio/core": "0.4.0"
45
+ "@composio/core": "0.5.0"
38
46
  },
39
47
  "scripts": {
40
48
  "clean": "git clean -xdf node_modules",
41
- "build": "tsup",
49
+ "build": "tsdown",
42
50
  "test": "vitest run"
43
51
  },
44
- "types": "dist/index.d.ts"
52
+ "types": "dist/index.d.mts"
45
53
  }
package/dist/index.d.ts DELETED
@@ -1,201 +0,0 @@
1
- import { BaseNonAgenticProvider, McpServerGetResponse, McpUrlResponse, Tool, ExecuteToolFnOptions, ExecuteToolModifiers } from '@composio/core';
2
- import { FunctionDeclaration } from '@google/genai';
3
-
4
- /**
5
- * Google GenAI Provider
6
- *
7
- * This provider provides a set of tools for interacting with Google's GenAI API.
8
- * It supports both the Gemini Developer API and Vertex AI implementations.
9
- *
10
- * @packageDocumentation
11
- * @module providers/google
12
- */
13
-
14
- /**
15
- * Interface for Google GenAI function declaration
16
- * Based on the FunctionDeclaration type from @google/genai
17
- */
18
- type GoogleTool = FunctionDeclaration;
19
- /**
20
- * Interface for Google GenAI function call
21
- * Based on the FunctionCall type from @google/genai
22
- */
23
- interface GoogleGenAIFunctionCall {
24
- name: string;
25
- args: Record<string, unknown>;
26
- }
27
- /**
28
- * Type for a collection of Google GenAI function declarations
29
- */
30
- type GoogleGenAIToolCollection = GoogleTool[];
31
- /**
32
- * Google GenAI Provider for Composio SDK
33
- * Implements the BaseNonAgenticProvider to wrap Composio tools for use with Google's GenAI API
34
- */
35
- declare class GoogleProvider extends BaseNonAgenticProvider<GoogleGenAIToolCollection, GoogleTool, McpServerGetResponse> {
36
- readonly name = "google";
37
- /**
38
- * Creates a new instance of the GoogleProvider.
39
- *
40
- * This provider enables integration with Google's GenAI API,
41
- * supporting both the Gemini Developer API and Vertex AI implementations.
42
- *
43
- * @example
44
- * ```typescript
45
- * // Initialize the Google provider
46
- * const provider = new GoogleProvider();
47
- *
48
- * // Use with Composio
49
- * const composio = new Composio({
50
- * apiKey: 'your-api-key',
51
- * provider: new GoogleProvider()
52
- * });
53
- *
54
- * // Use the provider to wrap tools for Google GenAI
55
- * const googleTools = provider.wrapTools(composioTools);
56
- * ```
57
- */
58
- constructor();
59
- /**
60
- * Transform MCP URL response into Anthropic-specific format.
61
- * By default, Anthropic uses the standard format (same as default),
62
- * but this method is here to show providers can customize if needed.
63
- *
64
- * @param data - The MCP URL response data
65
- * @returns Standard MCP server response format
66
- */
67
- wrapMcpServerResponse(data: McpUrlResponse): McpServerGetResponse;
68
- /**
69
- * Wraps a Composio tool in the Google GenAI function declaration format.
70
- *
71
- * This method transforms a Composio tool definition into the format
72
- * expected by Google's GenAI API for function calling.
73
- *
74
- * @param tool - The Composio tool to wrap
75
- * @returns The wrapped tool in Google GenAI format
76
- *
77
- * @example
78
- * ```typescript
79
- * // Wrap a single tool for use with Google GenAI
80
- * const composioTool = {
81
- * slug: 'SEARCH_TOOL',
82
- * description: 'Search for information',
83
- * inputParameters: {
84
- * type: 'object',
85
- * properties: {
86
- * query: { type: 'string' }
87
- * },
88
- * required: ['query']
89
- * }
90
- * };
91
- *
92
- * const googleTool = provider.wrapTool(composioTool);
93
- * // Use with Google GenAI SDK
94
- * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
95
- * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
96
- *
97
- * const result = await model.generateContent({
98
- * contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
99
- * tools: [googleTool]
100
- * });
101
- * ```
102
- */
103
- wrapTool(tool: Tool): GoogleTool;
104
- /**
105
- * Wraps a list of Composio tools in the Google GenAI function declaration format.
106
- *
107
- * This method transforms multiple Composio tool definitions into the format
108
- * expected by Google's GenAI API for function calling.
109
- *
110
- * @param tools - Array of Composio tools to wrap
111
- * @returns Array of wrapped tools in Google GenAI format
112
- *
113
- * @example
114
- * ```typescript
115
- * // Wrap multiple tools for use with Google GenAI
116
- * const composioTools = [
117
- * {
118
- * slug: 'SEARCH_TOOL',
119
- * description: 'Search for information',
120
- * inputParameters: {
121
- * type: 'object',
122
- * properties: {
123
- * query: { type: 'string' }
124
- * },
125
- * required: ['query']
126
- * }
127
- * },
128
- * {
129
- * slug: 'WEATHER_TOOL',
130
- * description: 'Get weather information',
131
- * inputParameters: {
132
- * type: 'object',
133
- * properties: {
134
- * location: { type: 'string' }
135
- * },
136
- * required: ['location']
137
- * }
138
- * }
139
- * ];
140
- *
141
- * const googleTools = provider.wrapTools(composioTools);
142
- *
143
- * // Use with Google GenAI SDK
144
- * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
145
- * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
146
- *
147
- * const result = await model.generateContent({
148
- * contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
149
- * tools: googleTools
150
- * });
151
- * ```
152
- */
153
- wrapTools(tools: Tool[]): GoogleGenAIToolCollection;
154
- /**
155
- * Executes a tool call from Google GenAI.
156
- *
157
- * This method processes a function call from Google's GenAI API,
158
- * executes the corresponding Composio tool, and returns the result.
159
- *
160
- * @param userId - The user ID for authentication and tracking
161
- * @param tool - The Google GenAI function call to execute
162
- * @param options - Optional execution options like connected account ID
163
- * @param modifiers - Optional execution modifiers for tool behavior
164
- * @returns The result of the tool execution as a JSON string
165
- *
166
- * @example
167
- * ```typescript
168
- * // Execute a tool call from Google GenAI
169
- * const functionCall = {
170
- * name: 'SEARCH_TOOL',
171
- * args: {
172
- * query: 'composio documentation'
173
- * }
174
- * };
175
- *
176
- * const result = await provider.executeToolCall(
177
- * 'user123',
178
- * functionCall,
179
- * { connectedAccountId: 'conn_xyz456' }
180
- * );
181
- *
182
- * // Parse the result and use it in your application
183
- * const searchResults = JSON.parse(result);
184
- * console.log(searchResults);
185
- *
186
- * // You can also use the result to continue the conversation
187
- * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
188
- * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
189
- *
190
- * await model.generateContent({
191
- * contents: [
192
- * { role: 'user', parts: [{ text: 'Search for Composio' }] },
193
- * { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
194
- * ]
195
- * });
196
- * ```
197
- */
198
- executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>;
199
- }
200
-
201
- export { type GoogleGenAIFunctionCall, type GoogleGenAIToolCollection, GoogleProvider, type GoogleTool };
package/dist/index.js DELETED
@@ -1,202 +0,0 @@
1
- // src/index.ts
2
- import {
3
- BaseNonAgenticProvider
4
- } from "@composio/core";
5
- var GoogleProvider = class extends BaseNonAgenticProvider {
6
- name = "google";
7
- /**
8
- * Creates a new instance of the GoogleProvider.
9
- *
10
- * This provider enables integration with Google's GenAI API,
11
- * supporting both the Gemini Developer API and Vertex AI implementations.
12
- *
13
- * @example
14
- * ```typescript
15
- * // Initialize the Google provider
16
- * const provider = new GoogleProvider();
17
- *
18
- * // Use with Composio
19
- * const composio = new Composio({
20
- * apiKey: 'your-api-key',
21
- * provider: new GoogleProvider()
22
- * });
23
- *
24
- * // Use the provider to wrap tools for Google GenAI
25
- * const googleTools = provider.wrapTools(composioTools);
26
- * ```
27
- */
28
- constructor() {
29
- super();
30
- }
31
- /**
32
- * Transform MCP URL response into Anthropic-specific format.
33
- * By default, Anthropic uses the standard format (same as default),
34
- * but this method is here to show providers can customize if needed.
35
- *
36
- * @param data - The MCP URL response data
37
- * @returns Standard MCP server response format
38
- */
39
- wrapMcpServerResponse(data) {
40
- return data.map((item) => ({
41
- url: new URL(item.url),
42
- name: item.name
43
- }));
44
- }
45
- /**
46
- * Wraps a Composio tool in the Google GenAI function declaration format.
47
- *
48
- * This method transforms a Composio tool definition into the format
49
- * expected by Google's GenAI API for function calling.
50
- *
51
- * @param tool - The Composio tool to wrap
52
- * @returns The wrapped tool in Google GenAI format
53
- *
54
- * @example
55
- * ```typescript
56
- * // Wrap a single tool for use with Google GenAI
57
- * const composioTool = {
58
- * slug: 'SEARCH_TOOL',
59
- * description: 'Search for information',
60
- * inputParameters: {
61
- * type: 'object',
62
- * properties: {
63
- * query: { type: 'string' }
64
- * },
65
- * required: ['query']
66
- * }
67
- * };
68
- *
69
- * const googleTool = provider.wrapTool(composioTool);
70
- * // Use with Google GenAI SDK
71
- * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
72
- * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
73
- *
74
- * const result = await model.generateContent({
75
- * contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
76
- * tools: [googleTool]
77
- * });
78
- * ```
79
- */
80
- wrapTool(tool) {
81
- return {
82
- name: tool.slug,
83
- description: tool.description || "",
84
- parameters: {
85
- type: "object",
86
- description: tool.description || "",
87
- properties: tool.inputParameters?.properties || {},
88
- required: tool.inputParameters?.required || []
89
- }
90
- };
91
- }
92
- /**
93
- * Wraps a list of Composio tools in the Google GenAI function declaration format.
94
- *
95
- * This method transforms multiple Composio tool definitions into the format
96
- * expected by Google's GenAI API for function calling.
97
- *
98
- * @param tools - Array of Composio tools to wrap
99
- * @returns Array of wrapped tools in Google GenAI format
100
- *
101
- * @example
102
- * ```typescript
103
- * // Wrap multiple tools for use with Google GenAI
104
- * const composioTools = [
105
- * {
106
- * slug: 'SEARCH_TOOL',
107
- * description: 'Search for information',
108
- * inputParameters: {
109
- * type: 'object',
110
- * properties: {
111
- * query: { type: 'string' }
112
- * },
113
- * required: ['query']
114
- * }
115
- * },
116
- * {
117
- * slug: 'WEATHER_TOOL',
118
- * description: 'Get weather information',
119
- * inputParameters: {
120
- * type: 'object',
121
- * properties: {
122
- * location: { type: 'string' }
123
- * },
124
- * required: ['location']
125
- * }
126
- * }
127
- * ];
128
- *
129
- * const googleTools = provider.wrapTools(composioTools);
130
- *
131
- * // Use with Google GenAI SDK
132
- * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
133
- * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
134
- *
135
- * const result = await model.generateContent({
136
- * contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
137
- * tools: googleTools
138
- * });
139
- * ```
140
- */
141
- wrapTools(tools) {
142
- return tools.map((tool) => this.wrapTool(tool));
143
- }
144
- /**
145
- * Executes a tool call from Google GenAI.
146
- *
147
- * This method processes a function call from Google's GenAI API,
148
- * executes the corresponding Composio tool, and returns the result.
149
- *
150
- * @param userId - The user ID for authentication and tracking
151
- * @param tool - The Google GenAI function call to execute
152
- * @param options - Optional execution options like connected account ID
153
- * @param modifiers - Optional execution modifiers for tool behavior
154
- * @returns The result of the tool execution as a JSON string
155
- *
156
- * @example
157
- * ```typescript
158
- * // Execute a tool call from Google GenAI
159
- * const functionCall = {
160
- * name: 'SEARCH_TOOL',
161
- * args: {
162
- * query: 'composio documentation'
163
- * }
164
- * };
165
- *
166
- * const result = await provider.executeToolCall(
167
- * 'user123',
168
- * functionCall,
169
- * { connectedAccountId: 'conn_xyz456' }
170
- * );
171
- *
172
- * // Parse the result and use it in your application
173
- * const searchResults = JSON.parse(result);
174
- * console.log(searchResults);
175
- *
176
- * // You can also use the result to continue the conversation
177
- * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
178
- * const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
179
- *
180
- * await model.generateContent({
181
- * contents: [
182
- * { role: 'user', parts: [{ text: 'Search for Composio' }] },
183
- * { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
184
- * ]
185
- * });
186
- * ```
187
- */
188
- async executeToolCall(userId, tool, options, modifiers) {
189
- const payload = {
190
- arguments: tool.args,
191
- connectedAccountId: options?.connectedAccountId,
192
- customAuthParams: options?.customAuthParams,
193
- customConnectionData: options?.customConnectionData,
194
- userId
195
- };
196
- const result = await this.executeTool(tool.name, payload, modifiers);
197
- return JSON.stringify(result);
198
- }
199
- };
200
- export {
201
- GoogleProvider
202
- };