@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.cjs +212 -223
- package/dist/index.d.cts +5133 -174
- package/dist/index.d.mts +5160 -0
- package/dist/index.mjs +214 -0
- package/package.json +19 -11
- package/dist/index.d.ts +0 -201
- package/dist/index.js +0 -202
package/dist/index.cjs
CHANGED
|
@@ -1,225 +1,214 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
let _composio_core = require("@composio/core");
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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 _composio_core.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
|
+
}
|
|
221
211
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
});
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
exports.GoogleProvider = GoogleProvider;
|