@composio/core 0.1.0-rc.5 → 0.1.0-rc.7
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 +956 -392
- package/dist/index.d.cts +586 -133
- package/dist/index.d.ts +586 -133
- package/dist/index.js +953 -391
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,77 +1,380 @@
|
|
|
1
1
|
import ComposioClient from '@composio/client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { z, ZodObject, ZodString, ZodNumber, ZodBoolean, ZodOptional } from 'zod';
|
|
3
|
+
import { ToolProxyParams, ToolProxyResponse, ToolListParams as ToolListParams$1, ToolRetrieveEnumResponse, ToolGetInputParams, ToolGetInputResponse } from '@composio/client/resources/tools';
|
|
4
4
|
import { RequestOptions } from '@composio/client/internal/request-options';
|
|
5
5
|
import { ToolkitListParams, ToolkitListResponse, ToolkitRetrieveResponse, ToolkitRetrieveCategoriesResponse } from '@composio/client/resources/toolkits';
|
|
6
6
|
import { TriggerInstanceListActiveParams, TriggerInstanceUpsertParams, TriggerInstanceUpsertResponse, TriggerInstanceRemoveUpsertResponse, TriggerInstanceUpdateStatusParams, TriggersTypeListParams, TriggersTypeListResponse, TriggersTypeRetrieveResponse, TriggersTypeRetrieveEnumResponse } from '@composio/client/resources/index';
|
|
7
7
|
import { AuthConfigListParams, AuthConfigListResponse, AuthConfigCreateParams, AuthConfigCreateResponse, AuthConfigRetrieveResponse, AuthConfigUpdateParams, AuthConfigUpdateResponse, AuthConfigDeleteResponse, AuthConfigUpdateStatusResponse } from '@composio/client/resources/auth-configs';
|
|
8
|
-
import { ConnectedAccountListParams, ConnectedAccountListResponse, ConnectedAccountCreateParams, ConnectedAccountCreateResponse, ConnectedAccountRetrieveResponse, ConnectedAccountDeleteResponse, ConnectedAccountRefreshResponse, ConnectedAccountUpdateStatusParams, ConnectedAccountUpdateStatusResponse } from '@composio/client/resources/connected-accounts';
|
|
8
|
+
import { ConnectedAccountListParams, ConnectedAccountListResponse, ConnectedAccountCreateParams, ConnectedAccountCreateResponse, ConnectedAccountRetrieveResponse as ConnectedAccountRetrieveResponse$1, ConnectedAccountDeleteResponse, ConnectedAccountRefreshResponse, ConnectedAccountUpdateStatusParams, ConnectedAccountUpdateStatusResponse } from '@composio/client/resources/connected-accounts';
|
|
9
9
|
import { OpenAI } from 'openai';
|
|
10
10
|
import { Stream } from 'openai/streaming';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Tool is a single action that can be performed by a toolkit.
|
|
14
|
+
* Tool is simlar to an action that an app can perform.
|
|
15
|
+
*
|
|
16
|
+
* eg. Google Search, Google Maps, Google Translate, etc.
|
|
17
|
+
*/
|
|
18
|
+
declare const ToolSchema: z.ZodObject<{
|
|
19
|
+
slug: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
description: z.ZodOptional<z.ZodString>;
|
|
22
|
+
inputParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
outputParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
24
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
25
|
+
toolkit: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
slug: z.ZodString;
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
logo: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
slug: string;
|
|
31
|
+
name: string;
|
|
32
|
+
logo?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
slug: string;
|
|
35
|
+
name: string;
|
|
36
|
+
logo?: string | undefined;
|
|
37
|
+
}>>;
|
|
38
|
+
version: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
slug: string;
|
|
14
41
|
name: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
tags: string[];
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
inputParameters?: Record<string, unknown> | undefined;
|
|
45
|
+
outputParameters?: Record<string, unknown> | undefined;
|
|
46
|
+
toolkit?: {
|
|
47
|
+
slug: string;
|
|
48
|
+
name: string;
|
|
49
|
+
logo?: string | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
version?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
slug: string;
|
|
54
|
+
name: string;
|
|
55
|
+
description?: string | undefined;
|
|
56
|
+
inputParameters?: Record<string, unknown> | undefined;
|
|
57
|
+
outputParameters?: Record<string, unknown> | undefined;
|
|
58
|
+
tags?: string[] | undefined;
|
|
59
|
+
toolkit?: {
|
|
60
|
+
slug: string;
|
|
61
|
+
name: string;
|
|
62
|
+
logo?: string | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
version?: string | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
type Tool = z.infer<typeof ToolSchema>;
|
|
67
|
+
/**
|
|
68
|
+
* Plain SDK level Tool List
|
|
69
|
+
*/
|
|
70
|
+
type ToolList = Array<Tool>;
|
|
71
|
+
/**
|
|
72
|
+
* ToolListParams is the parameters for the list of tools.
|
|
73
|
+
*/
|
|
19
74
|
declare const ToolListParamsSchema: z.ZodObject<{
|
|
20
75
|
cursor: z.ZodOptional<z.ZodString>;
|
|
21
76
|
important: z.ZodOptional<z.ZodString>;
|
|
22
77
|
limit: z.ZodOptional<z.ZodString>;
|
|
23
78
|
search: z.ZodOptional<z.ZodString>;
|
|
24
|
-
|
|
79
|
+
toolkitSlug: z.ZodOptional<z.ZodString>;
|
|
80
|
+
toolSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
81
|
}, "strip", z.ZodTypeAny, {
|
|
26
82
|
cursor?: string | undefined;
|
|
27
83
|
important?: string | undefined;
|
|
28
84
|
limit?: string | undefined;
|
|
29
85
|
search?: string | undefined;
|
|
30
|
-
|
|
86
|
+
toolkitSlug?: string | undefined;
|
|
87
|
+
toolSlugs?: string[] | undefined;
|
|
31
88
|
}, {
|
|
32
89
|
cursor?: string | undefined;
|
|
33
90
|
important?: string | undefined;
|
|
34
91
|
limit?: string | undefined;
|
|
35
92
|
search?: string | undefined;
|
|
36
|
-
|
|
93
|
+
toolkitSlug?: string | undefined;
|
|
94
|
+
toolSlugs?: string[] | undefined;
|
|
37
95
|
}>;
|
|
38
96
|
type ToolListParams = z.infer<typeof ToolListParamsSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* ToolExecuteParams is the parameters for the tool execution.
|
|
99
|
+
*/
|
|
100
|
+
declare const ToolExecuteParamsSchema: z.ZodObject<{
|
|
101
|
+
allowTracing: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
connectedAccountId: z.ZodOptional<z.ZodString>;
|
|
103
|
+
customAuthParams: z.ZodOptional<z.ZodObject<{
|
|
104
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
105
|
+
body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
106
|
+
parameters: z.ZodArray<z.ZodObject<{
|
|
107
|
+
in: z.ZodEnum<["query", "header"]>;
|
|
108
|
+
name: z.ZodString;
|
|
109
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
name: string;
|
|
112
|
+
value: string | number;
|
|
113
|
+
in: "query" | "header";
|
|
114
|
+
}, {
|
|
115
|
+
name: string;
|
|
116
|
+
value: string | number;
|
|
117
|
+
in: "query" | "header";
|
|
118
|
+
}>, "many">;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
parameters: {
|
|
121
|
+
name: string;
|
|
122
|
+
value: string | number;
|
|
123
|
+
in: "query" | "header";
|
|
124
|
+
}[];
|
|
125
|
+
baseURL?: string | undefined;
|
|
126
|
+
body?: Record<string, unknown> | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
parameters: {
|
|
129
|
+
name: string;
|
|
130
|
+
value: string | number;
|
|
131
|
+
in: "query" | "header";
|
|
132
|
+
}[];
|
|
133
|
+
baseURL?: string | undefined;
|
|
134
|
+
body?: Record<string, unknown> | undefined;
|
|
135
|
+
}>>;
|
|
136
|
+
arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
137
|
+
userId: z.ZodString;
|
|
138
|
+
version: z.ZodOptional<z.ZodString>;
|
|
139
|
+
text: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
userId: string;
|
|
142
|
+
version?: string | undefined;
|
|
143
|
+
allowTracing?: boolean | undefined;
|
|
144
|
+
connectedAccountId?: string | undefined;
|
|
145
|
+
customAuthParams?: {
|
|
146
|
+
parameters: {
|
|
147
|
+
name: string;
|
|
148
|
+
value: string | number;
|
|
149
|
+
in: "query" | "header";
|
|
150
|
+
}[];
|
|
151
|
+
baseURL?: string | undefined;
|
|
152
|
+
body?: Record<string, unknown> | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
arguments?: Record<string, unknown> | undefined;
|
|
155
|
+
text?: string | undefined;
|
|
156
|
+
}, {
|
|
157
|
+
userId: string;
|
|
158
|
+
version?: string | undefined;
|
|
159
|
+
allowTracing?: boolean | undefined;
|
|
160
|
+
connectedAccountId?: string | undefined;
|
|
161
|
+
customAuthParams?: {
|
|
162
|
+
parameters: {
|
|
163
|
+
name: string;
|
|
164
|
+
value: string | number;
|
|
165
|
+
in: "query" | "header";
|
|
166
|
+
}[];
|
|
167
|
+
baseURL?: string | undefined;
|
|
168
|
+
body?: Record<string, unknown> | undefined;
|
|
169
|
+
} | undefined;
|
|
170
|
+
arguments?: Record<string, unknown> | undefined;
|
|
171
|
+
text?: string | undefined;
|
|
172
|
+
}>;
|
|
173
|
+
type ToolExecuteParams = z.infer<typeof ToolExecuteParamsSchema>;
|
|
174
|
+
/**
|
|
175
|
+
* ToolResponse Schema
|
|
176
|
+
*/
|
|
177
|
+
declare const ToolExecuteResponseSchema: z.ZodObject<{
|
|
178
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
179
|
+
error: z.ZodNullable<z.ZodString>;
|
|
180
|
+
successful: z.ZodBoolean;
|
|
181
|
+
logId: z.ZodOptional<z.ZodString>;
|
|
182
|
+
sessionInfo: z.ZodOptional<z.ZodUnknown>;
|
|
183
|
+
}, "strip", z.ZodTypeAny, {
|
|
184
|
+
data: Record<string, unknown>;
|
|
185
|
+
error: string | null;
|
|
186
|
+
successful: boolean;
|
|
187
|
+
logId?: string | undefined;
|
|
188
|
+
sessionInfo?: unknown;
|
|
189
|
+
}, {
|
|
190
|
+
data: Record<string, unknown>;
|
|
191
|
+
error: string | null;
|
|
192
|
+
successful: boolean;
|
|
193
|
+
logId?: string | undefined;
|
|
194
|
+
sessionInfo?: unknown;
|
|
195
|
+
}>;
|
|
196
|
+
type ToolExecuteResponse = z.infer<typeof ToolExecuteResponseSchema>;
|
|
197
|
+
|
|
198
|
+
type CustomToolInputParameter = ZodObject<{
|
|
199
|
+
[key: string]: ZodString | ZodNumber | ZodBoolean | ZodOptional<ZodString | ZodNumber | ZodBoolean>;
|
|
200
|
+
}>;
|
|
201
|
+
type CustomToolInput<T extends CustomToolInputParameter> = {
|
|
202
|
+
[K in keyof z.infer<T>]: z.infer<T>[K];
|
|
203
|
+
};
|
|
204
|
+
interface CustomToolOptions<T extends CustomToolInputParameter = CustomToolInputParameter> {
|
|
205
|
+
slug: string;
|
|
206
|
+
name: string;
|
|
207
|
+
toolkitSlug?: string | null;
|
|
208
|
+
description?: string;
|
|
209
|
+
inputParams: T;
|
|
210
|
+
execute: (input: CustomToolInput<T>, authCredentials?: Record<string, unknown>, executeAppRequest?: (data: ToolProxyParams) => Promise<ToolProxyResponse>) => Promise<ToolExecuteResponse>;
|
|
211
|
+
}
|
|
212
|
+
interface ExecuteMetadata {
|
|
213
|
+
userId: string;
|
|
214
|
+
connectedAccountId?: string;
|
|
215
|
+
}
|
|
39
216
|
|
|
40
217
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
218
|
+
* @fileoverview Custom tools class for Composio SDK, used to manage custom tools created by users.
|
|
219
|
+
*
|
|
220
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
221
|
+
* @date 2025-05-05
|
|
222
|
+
* @module CustomTools
|
|
43
223
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
224
|
+
|
|
225
|
+
declare class CustomTools {
|
|
226
|
+
private client;
|
|
227
|
+
private customToolsRegistry;
|
|
228
|
+
constructor(client: ComposioClient);
|
|
229
|
+
/**
|
|
230
|
+
* Create a custom tool and registers it in the registry.
|
|
231
|
+
* This is just an in memory registry and is not persisted.
|
|
232
|
+
* @param {CustomToolOptions} toolOptions CustomToolOptions
|
|
233
|
+
* @returns {Tool} The tool created
|
|
234
|
+
*/
|
|
235
|
+
createTool(toolOptions: CustomToolOptions): Promise<Tool>;
|
|
236
|
+
/**
|
|
237
|
+
* Get all the custom tools from the registry.
|
|
238
|
+
* @param {string[]} param0.toolSlugs The slugs of the tools to get
|
|
239
|
+
* @returns {ToolList} The list of tools
|
|
240
|
+
*/
|
|
241
|
+
getCustomTools({ toolSlugs }: {
|
|
242
|
+
toolSlugs?: string[];
|
|
243
|
+
}): Promise<ToolList>;
|
|
244
|
+
/**
|
|
245
|
+
* Get a custom tool by slug from the registry.
|
|
246
|
+
* @param {string} slug The slug of the tool to get
|
|
247
|
+
* @returns {Tool} The tool
|
|
248
|
+
*/
|
|
249
|
+
getCustomToolBySlug(slug: string): Promise<Tool | null>;
|
|
250
|
+
/**
|
|
251
|
+
* Get the connected account for the user and toolkit.
|
|
252
|
+
* @param {string} toolkitSlug The slug of the toolkit
|
|
253
|
+
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
254
|
+
* @returns {ConnectedAccount} The connected account
|
|
255
|
+
*/
|
|
256
|
+
private getConnectedAccount;
|
|
257
|
+
/**
|
|
258
|
+
* Execute a custom tool
|
|
259
|
+
* @param {slug} slug The slug of the tool to execute
|
|
260
|
+
* @param {Record<string, unknown>} inputParams The input parameters for the tool
|
|
261
|
+
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
262
|
+
* @returns {Promise<ToolExecuteResponse>} The response from the tool
|
|
263
|
+
*/
|
|
264
|
+
executeCustomTool(slug: string, inputParams: Record<string, unknown>, metadata: ExecuteMetadata): Promise<ToolExecuteResponse>;
|
|
46
265
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
266
|
+
|
|
267
|
+
declare abstract class BaseNonAgenticToolset<TToolCollection, TTool> {
|
|
268
|
+
protected composio: Composio<BaseComposioToolset<TToolCollection, TTool>> | undefined;
|
|
269
|
+
setComposio(composio: Composio<BaseComposioToolset<TToolCollection, TTool>>): void;
|
|
270
|
+
abstract getTools(userId: string, params: ToolListParams, options?: ToolOptions): Promise<TToolCollection>;
|
|
271
|
+
abstract getToolBySlug(userId: string, slug: string, options?: ToolOptions): Promise<TTool>;
|
|
272
|
+
abstract wrapTool(tool: Tool): TTool;
|
|
273
|
+
protected getComposio(): Composio<BaseComposioToolset<TToolCollection, TTool>>;
|
|
274
|
+
}
|
|
275
|
+
declare abstract class BaseAgenticToolset<TToolCollection, TTool> {
|
|
276
|
+
protected composio: Composio<BaseComposioToolset<TToolCollection, TTool>> | undefined;
|
|
277
|
+
setComposio(composio: Composio<BaseComposioToolset<TToolCollection, TTool>>): void;
|
|
278
|
+
abstract getToolBySlug(userId: string, slug: string, options?: AgenticToolOptions): Promise<TTool>;
|
|
279
|
+
abstract getTools(userId: string, params: ToolListParams, options?: AgenticToolOptions): Promise<TToolCollection>;
|
|
280
|
+
abstract wrapTool(userId: string, tool: Tool, modifers?: ExecuteToolModifiers): TTool;
|
|
281
|
+
protected getComposio(): Composio<BaseComposioToolset<TToolCollection, TTool>>;
|
|
53
282
|
}
|
|
283
|
+
type BaseComposioToolset<TToolCollection, TTool> = BaseNonAgenticToolset<TToolCollection, TTool> | BaseAgenticToolset<TToolCollection, TTool>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Modifier for altering the tool execute params
|
|
287
|
+
* Called before the tool execute call
|
|
288
|
+
*/
|
|
289
|
+
type BeforeToolExecuteModifier = (toolSlug: string, toolExecuteParams: ToolExecuteParams) => ToolExecuteParams;
|
|
290
|
+
/**
|
|
291
|
+
* Modifier for altering the tool execute response
|
|
292
|
+
* Called after the tool execute call
|
|
293
|
+
*/
|
|
294
|
+
type AfterToolExecuteModifier = (toolSlug: string, toolExecuteResponse: ToolExecuteResponse) => ToolExecuteResponse;
|
|
295
|
+
/**
|
|
296
|
+
* Modifier for altering the tool schema
|
|
297
|
+
* Called after the tool schema is retrieved
|
|
298
|
+
*/
|
|
299
|
+
type TransformToolSchemaModifier = (toolSlug: string, toolSchema: Tool) => Tool;
|
|
300
|
+
/**
|
|
301
|
+
* Non Agentic tool options. These are used by Non-Agentic toolsets
|
|
302
|
+
*/
|
|
303
|
+
type ToolOptions = {
|
|
304
|
+
/**
|
|
305
|
+
* Transform tool schema modifier
|
|
306
|
+
*/
|
|
307
|
+
modifyToolSchema?: TransformToolSchemaModifier;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Modifiers for the tool execution
|
|
311
|
+
* This is used by execute call and handleToolCall of Non-Agentic toolsets
|
|
312
|
+
*/
|
|
313
|
+
type ExecuteToolModifiers = {
|
|
314
|
+
/**
|
|
315
|
+
* Before tool execute modifier
|
|
316
|
+
*/
|
|
317
|
+
beforeToolExecute?: BeforeToolExecuteModifier;
|
|
318
|
+
/**
|
|
319
|
+
* After tool execute modifier
|
|
320
|
+
*/
|
|
321
|
+
afterToolExecute?: AfterToolExecuteModifier;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Agentic tool options. These are used by Agentic toolsets
|
|
325
|
+
*/
|
|
326
|
+
type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
|
|
327
|
+
type ToolsetOptions<T extends BaseComposioToolset<unknown, unknown>> = T extends BaseAgenticToolset<unknown, unknown> ? AgenticToolOptions : ToolOptions;
|
|
54
328
|
|
|
55
329
|
/**
|
|
56
330
|
* This class is used to manage tools in the Composio SDK.
|
|
57
331
|
* It provides methods to list, get, and execute tools.
|
|
58
332
|
*/
|
|
59
|
-
declare class Tools
|
|
60
|
-
readonly FILE_NAME: string;
|
|
333
|
+
declare class Tools<TToolCollection, TTool, TToolset extends BaseComposioToolset<TToolCollection, TTool>> {
|
|
61
334
|
private client;
|
|
62
|
-
|
|
335
|
+
customTools: CustomTools;
|
|
336
|
+
private toolset;
|
|
337
|
+
constructor(client: ComposioClient, toolset: TToolset);
|
|
338
|
+
/**
|
|
339
|
+
* Transform the tool cases
|
|
340
|
+
* @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool to transform
|
|
341
|
+
* @returns {Tool} The transformed tool
|
|
342
|
+
*/
|
|
343
|
+
private transformToolCases;
|
|
63
344
|
/**
|
|
64
|
-
*
|
|
345
|
+
* Transform the tool execute response to camelcase
|
|
346
|
+
* @param {ComposioToolExecuteResponse} response - The response to transform
|
|
347
|
+
* @returns {ToolExecuteResponse} The transformed response
|
|
348
|
+
*/
|
|
349
|
+
private transformToolExecuteResponse;
|
|
350
|
+
/**
|
|
351
|
+
* Check if the connected account exists for the given tools.
|
|
352
|
+
* @param {string} userId - The user id.
|
|
353
|
+
* @param {ToolList} tools - The tools to check.
|
|
354
|
+
* @returns {Promise<boolean>} True if the connected account exists for the given tools, false otherwise.
|
|
355
|
+
*/
|
|
356
|
+
private checkIfConnectedAccountExistsForTools;
|
|
357
|
+
/**
|
|
358
|
+
* Get the connected account id for a given tool
|
|
359
|
+
* @param {string} userId - The user id
|
|
360
|
+
* @param {string} toolSlug - The tool slug
|
|
361
|
+
* @returns {Promise<string | null>} The connected account id or null if the toolkit is a no auth app
|
|
362
|
+
*/
|
|
363
|
+
private getConnectedAccountIdForTool;
|
|
364
|
+
/**
|
|
365
|
+
* Lists all tools available in the Composio SDK as well as custom tools.
|
|
65
366
|
* This method fetches the tools from the Composio API and wraps them using the toolset.
|
|
66
|
-
* @returns {
|
|
367
|
+
* @returns {ToolList} List of tools
|
|
67
368
|
*/
|
|
68
|
-
|
|
369
|
+
getComposioTools(userId: string, query?: ToolListParams$1, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
|
|
69
370
|
/**
|
|
70
371
|
* Retrieves a tool by its Slug.
|
|
71
372
|
* @param slug The ID of the tool to be retrieved
|
|
72
373
|
* @returns {Promise<Tool>} The tool
|
|
73
374
|
*/
|
|
74
|
-
|
|
375
|
+
getComposioToolBySlug(userId: string, slug: string, modifier?: TransformToolSchemaModifier): Promise<Tool>;
|
|
376
|
+
get(userId: string, slug: string, options?: ToolsetOptions<TToolset>): Promise<TTool>;
|
|
377
|
+
get(userId: string, filters: ToolListParams$1, options?: ToolsetOptions<TToolset>): Promise<TToolCollection>;
|
|
75
378
|
/**
|
|
76
379
|
* Exectes a given tool with the provided parameters.
|
|
77
380
|
*
|
|
@@ -81,7 +384,7 @@ declare class Tools implements InstrumentedInstance {
|
|
|
81
384
|
* @param {ToolExecuteParams} body - The parameters to be passed to the tool
|
|
82
385
|
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
83
386
|
*/
|
|
84
|
-
execute(slug: string, body: ToolExecuteParams): Promise<ToolExecuteResponse>;
|
|
387
|
+
execute(slug: string, body: ToolExecuteParams, modifiers?: ExecuteToolModifiers): Promise<ToolExecuteResponse>;
|
|
85
388
|
/**
|
|
86
389
|
* Fetches the list of all available tools in the Composio SDK.
|
|
87
390
|
*
|
|
@@ -100,6 +403,18 @@ declare class Tools implements InstrumentedInstance {
|
|
|
100
403
|
* @returns
|
|
101
404
|
*/
|
|
102
405
|
getInput(slug: string, body: ToolGetInputParams): Promise<ToolGetInputResponse>;
|
|
406
|
+
/**
|
|
407
|
+
* Proxies a custom request to a toolkit/integration
|
|
408
|
+
* @param body
|
|
409
|
+
* @returns
|
|
410
|
+
*/
|
|
411
|
+
proxyExecute(body: ToolProxyParams): Promise<ToolProxyResponse>;
|
|
412
|
+
/**
|
|
413
|
+
* Execute a custom tool
|
|
414
|
+
* @param body
|
|
415
|
+
* @returns
|
|
416
|
+
*/
|
|
417
|
+
createCustomTool(body: CustomToolOptions): Promise<Tool>;
|
|
103
418
|
}
|
|
104
419
|
|
|
105
420
|
/**
|
|
@@ -108,8 +423,7 @@ declare class Tools implements InstrumentedInstance {
|
|
|
108
423
|
* Toolkits are a collection of tools that can be used to perform various tasks.
|
|
109
424
|
* This is similar/replacement of `apps` in the Composio API.
|
|
110
425
|
*/
|
|
111
|
-
declare class Toolkits
|
|
112
|
-
readonly FILE_NAME: string;
|
|
426
|
+
declare class Toolkits {
|
|
113
427
|
private client;
|
|
114
428
|
constructor(client: ComposioClient);
|
|
115
429
|
/**
|
|
@@ -117,7 +431,7 @@ declare class Toolkits implements InstrumentedInstance {
|
|
|
117
431
|
* This method fetches the toolkits from the Composio API.
|
|
118
432
|
* @returns {Promise<Toolkit[]>} List of toolkits
|
|
119
433
|
*/
|
|
120
|
-
|
|
434
|
+
getToolkits(query: ToolkitListParams, options?: RequestOptions): Promise<ToolkitListResponse>;
|
|
121
435
|
/**
|
|
122
436
|
* Fetches a toolkit by its Slug.
|
|
123
437
|
* This method retrieves the toolkit from the Composio API.
|
|
@@ -125,7 +439,7 @@ declare class Toolkits implements InstrumentedInstance {
|
|
|
125
439
|
* @param options - Request options
|
|
126
440
|
* @returns {Promise<ToolkitRetrieveResponse>} The toolkit object
|
|
127
441
|
*/
|
|
128
|
-
|
|
442
|
+
getToolkitBySlug(slug: string, options?: RequestOptions): Promise<ToolkitRetrieveResponse>;
|
|
129
443
|
/**
|
|
130
444
|
* Fetches all categories available in the Composio SDK
|
|
131
445
|
*
|
|
@@ -187,8 +501,7 @@ type TriggerData = {
|
|
|
187
501
|
* /api/v3/trigger_instances
|
|
188
502
|
*
|
|
189
503
|
*/
|
|
190
|
-
declare class Triggers
|
|
191
|
-
readonly FILE_NAME: string;
|
|
504
|
+
declare class Triggers {
|
|
192
505
|
private client;
|
|
193
506
|
constructor(client: ComposioClient);
|
|
194
507
|
/**
|
|
@@ -275,13 +588,21 @@ declare class Triggers implements InstrumentedInstance {
|
|
|
275
588
|
unsubscribe(): Promise<void>;
|
|
276
589
|
}
|
|
277
590
|
|
|
591
|
+
/**
|
|
592
|
+
* @fileoverview Auth configs class for Composio SDK, used to manage authentication configurations.
|
|
593
|
+
*
|
|
594
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
595
|
+
* @date 2025-05-05
|
|
596
|
+
* @module AuthConfigs
|
|
597
|
+
*/
|
|
598
|
+
|
|
278
599
|
/**
|
|
279
600
|
* AuthConfigs class
|
|
280
601
|
*
|
|
281
602
|
* This class is used to manage authentication configurations in the Composio SDK.
|
|
282
603
|
* Auth configs are used to configure authentication providers and settings.
|
|
283
604
|
*/
|
|
284
|
-
declare class AuthConfigs
|
|
605
|
+
declare class AuthConfigs {
|
|
285
606
|
readonly FILE_NAME: string;
|
|
286
607
|
private client;
|
|
287
608
|
constructor(client: ComposioClient);
|
|
@@ -328,7 +649,7 @@ declare class AuthConfigs implements InstrumentedInstance {
|
|
|
328
649
|
* @param {RequestOptions} options - Request options
|
|
329
650
|
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
330
651
|
*/
|
|
331
|
-
updateStatus(status:
|
|
652
|
+
updateStatus(status: 'ENABLED' | 'DISABLED', nanoid: string, options?: RequestOptions): Promise<AuthConfigUpdateStatusResponse>;
|
|
332
653
|
/**
|
|
333
654
|
* Enable an auth config
|
|
334
655
|
* @param {string} nanoid - Unique identifier of the auth config
|
|
@@ -345,14 +666,183 @@ declare class AuthConfigs implements InstrumentedInstance {
|
|
|
345
666
|
disable(nanoid: string, options?: RequestOptions): Promise<AuthConfigUpdateStatusResponse>;
|
|
346
667
|
}
|
|
347
668
|
|
|
669
|
+
/**
|
|
670
|
+
* Connected Account create parameters
|
|
671
|
+
*/
|
|
672
|
+
declare const ConnectedAccountStatuses: {
|
|
673
|
+
readonly ACTIVE: "ACTIVE";
|
|
674
|
+
readonly INACTIVE: "INACTIVE";
|
|
675
|
+
readonly PENDING: "DELETED";
|
|
676
|
+
readonly INITIATED: "INITIATED";
|
|
677
|
+
readonly EXPIRED: "EXPIRED";
|
|
678
|
+
readonly FAILED: "FAILED";
|
|
679
|
+
};
|
|
680
|
+
type ConnectedAccountStatus = (typeof ConnectedAccountStatuses)[keyof typeof ConnectedAccountStatuses];
|
|
681
|
+
declare const CreateConnectedAccountParamsSchema: z.ZodObject<{
|
|
682
|
+
authConfig: z.ZodObject<{
|
|
683
|
+
id: z.ZodString;
|
|
684
|
+
}, "strip", z.ZodTypeAny, {
|
|
685
|
+
id: string;
|
|
686
|
+
}, {
|
|
687
|
+
id: string;
|
|
688
|
+
}>;
|
|
689
|
+
connection: z.ZodObject<{
|
|
690
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
691
|
+
rediretUrl: z.ZodOptional<z.ZodString>;
|
|
692
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
693
|
+
}, "strip", z.ZodTypeAny, {
|
|
694
|
+
userId?: string | undefined;
|
|
695
|
+
data?: Record<string, unknown> | undefined;
|
|
696
|
+
rediretUrl?: string | undefined;
|
|
697
|
+
}, {
|
|
698
|
+
userId?: string | undefined;
|
|
699
|
+
data?: Record<string, unknown> | undefined;
|
|
700
|
+
rediretUrl?: string | undefined;
|
|
701
|
+
}>;
|
|
702
|
+
}, "strip", z.ZodTypeAny, {
|
|
703
|
+
authConfig: {
|
|
704
|
+
id: string;
|
|
705
|
+
};
|
|
706
|
+
connection: {
|
|
707
|
+
userId?: string | undefined;
|
|
708
|
+
data?: Record<string, unknown> | undefined;
|
|
709
|
+
rediretUrl?: string | undefined;
|
|
710
|
+
};
|
|
711
|
+
}, {
|
|
712
|
+
authConfig: {
|
|
713
|
+
id: string;
|
|
714
|
+
};
|
|
715
|
+
connection: {
|
|
716
|
+
userId?: string | undefined;
|
|
717
|
+
data?: Record<string, unknown> | undefined;
|
|
718
|
+
rediretUrl?: string | undefined;
|
|
719
|
+
};
|
|
720
|
+
}>;
|
|
721
|
+
type CreateConnectedAccountParams = z.infer<typeof CreateConnectedAccountParamsSchema>;
|
|
722
|
+
declare const ConnectedAccountRetrieveResponseSchema: z.ZodObject<{
|
|
723
|
+
id: z.ZodString;
|
|
724
|
+
uuid: z.ZodString;
|
|
725
|
+
authConfig: z.ZodObject<{
|
|
726
|
+
id: z.ZodString;
|
|
727
|
+
authScheme: z.ZodEnum<["OAUTH2", "OAUTH1", "OAUTH1A", "API_KEY", "BASIC", "BILLCOM_AUTH", "BEARER_TOKEN", "GOOGLE_SERVICE_ACCOUNT", "NO_AUTH", "BASIC_WITH_JWT", "COMPOSIO_LINK", "CALCOM_AUTH", "SNOWFLAKE"]>;
|
|
728
|
+
isComposioManaged: z.ZodBoolean;
|
|
729
|
+
isDisabled: z.ZodBoolean;
|
|
730
|
+
}, "strip", z.ZodTypeAny, {
|
|
731
|
+
id: string;
|
|
732
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
733
|
+
isComposioManaged: boolean;
|
|
734
|
+
isDisabled: boolean;
|
|
735
|
+
}, {
|
|
736
|
+
id: string;
|
|
737
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
738
|
+
isComposioManaged: boolean;
|
|
739
|
+
isDisabled: boolean;
|
|
740
|
+
}>;
|
|
741
|
+
userId: z.ZodString;
|
|
742
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
743
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
744
|
+
status: z.ZodEnum<["ACTIVE", "INACTIVE", "DELETED", "INITIATED", "EXPIRED", "FAILED"]>;
|
|
745
|
+
statusReason: z.ZodNullable<z.ZodString>;
|
|
746
|
+
toolkit: z.ZodObject<{
|
|
747
|
+
slug: z.ZodString;
|
|
748
|
+
}, "strip", z.ZodTypeAny, {
|
|
749
|
+
slug: string;
|
|
750
|
+
}, {
|
|
751
|
+
slug: string;
|
|
752
|
+
}>;
|
|
753
|
+
testRequestEndpoint: z.ZodOptional<z.ZodString>;
|
|
754
|
+
isDisabled: z.ZodBoolean;
|
|
755
|
+
createdAt: z.ZodString;
|
|
756
|
+
updatedAt: z.ZodString;
|
|
757
|
+
}, "strip", z.ZodTypeAny, {
|
|
758
|
+
params: Record<string, unknown>;
|
|
759
|
+
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
760
|
+
toolkit: {
|
|
761
|
+
slug: string;
|
|
762
|
+
};
|
|
763
|
+
userId: string;
|
|
764
|
+
data: Record<string, unknown>;
|
|
765
|
+
id: string;
|
|
766
|
+
authConfig: {
|
|
767
|
+
id: string;
|
|
768
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
769
|
+
isComposioManaged: boolean;
|
|
770
|
+
isDisabled: boolean;
|
|
771
|
+
};
|
|
772
|
+
isDisabled: boolean;
|
|
773
|
+
uuid: string;
|
|
774
|
+
statusReason: string | null;
|
|
775
|
+
createdAt: string;
|
|
776
|
+
updatedAt: string;
|
|
777
|
+
testRequestEndpoint?: string | undefined;
|
|
778
|
+
}, {
|
|
779
|
+
params: Record<string, unknown>;
|
|
780
|
+
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
781
|
+
toolkit: {
|
|
782
|
+
slug: string;
|
|
783
|
+
};
|
|
784
|
+
userId: string;
|
|
785
|
+
data: Record<string, unknown>;
|
|
786
|
+
id: string;
|
|
787
|
+
authConfig: {
|
|
788
|
+
id: string;
|
|
789
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
790
|
+
isComposioManaged: boolean;
|
|
791
|
+
isDisabled: boolean;
|
|
792
|
+
};
|
|
793
|
+
isDisabled: boolean;
|
|
794
|
+
uuid: string;
|
|
795
|
+
statusReason: string | null;
|
|
796
|
+
createdAt: string;
|
|
797
|
+
updatedAt: string;
|
|
798
|
+
testRequestEndpoint?: string | undefined;
|
|
799
|
+
}>;
|
|
800
|
+
type ConnectedAccountRetrieveResponse = z.infer<typeof ConnectedAccountRetrieveResponseSchema>;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* @fileoverview Connection request class for Composio SDK, used to manage an initiated connection request.
|
|
804
|
+
*
|
|
805
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
806
|
+
* @date 2025-05-05
|
|
807
|
+
* @module ConnectionRequest
|
|
808
|
+
*/
|
|
809
|
+
|
|
810
|
+
declare class ConnectionRequest {
|
|
811
|
+
readonly FILE_NAME: string;
|
|
812
|
+
private client;
|
|
813
|
+
private connectedAccountId;
|
|
814
|
+
private connectedAccountStatus;
|
|
815
|
+
constructor(client: ComposioClient, connectedAccountId: string, connectedAccountStatus: ConnectedAccountStatus);
|
|
816
|
+
/**
|
|
817
|
+
* Transform the response from the Composio API to the SDK format
|
|
818
|
+
* @param response
|
|
819
|
+
* @returns
|
|
820
|
+
*/
|
|
821
|
+
private transformResponse;
|
|
822
|
+
/**
|
|
823
|
+
* Wait for the connection to be established.
|
|
824
|
+
* The function will poll the Composio API every second until the connection is established or the timeout is reached.
|
|
825
|
+
* @param {number} timeout - The time in milliseconds to wait for the connection to be established. Default is 30 seconds.
|
|
826
|
+
* @returns
|
|
827
|
+
*/
|
|
828
|
+
waitForConnection(timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.
|
|
833
|
+
*
|
|
834
|
+
* @author Musthaq Ahamad <musthaq@composio.dev>
|
|
835
|
+
* @date 2025-05-05
|
|
836
|
+
* @module ConnectedAccounts
|
|
837
|
+
*/
|
|
838
|
+
|
|
348
839
|
/**
|
|
349
840
|
* ConnectedAccounts class
|
|
350
841
|
*
|
|
351
842
|
* This class is used to manage connected accounts in the Composio SDK.
|
|
352
843
|
* Connected accounts are used to authenticate with third-party services.
|
|
353
844
|
*/
|
|
354
|
-
declare class ConnectedAccounts
|
|
355
|
-
readonly FILE_NAME: string;
|
|
845
|
+
declare class ConnectedAccounts {
|
|
356
846
|
private client;
|
|
357
847
|
constructor(client: ComposioClient);
|
|
358
848
|
/**
|
|
@@ -375,7 +865,7 @@ declare class ConnectedAccounts implements InstrumentedInstance {
|
|
|
375
865
|
* @param {RequestOptions} options - Request options
|
|
376
866
|
* @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
|
|
377
867
|
*/
|
|
378
|
-
get(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountRetrieveResponse>;
|
|
868
|
+
get(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountRetrieveResponse$1>;
|
|
379
869
|
/**
|
|
380
870
|
* Delete a connected account
|
|
381
871
|
* @param {string} nanoid - Unique identifier of the connected account to delete
|
|
@@ -412,61 +902,22 @@ declare class ConnectedAccounts implements InstrumentedInstance {
|
|
|
412
902
|
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
413
903
|
*/
|
|
414
904
|
disable(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountUpdateStatusResponse>;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Base toolset implementation, which needs to be implemented by the extended class.
|
|
419
|
-
* This class is used to create a base toolset by implementing this class.
|
|
420
|
-
* This class also extends InstrumentedInstance, so that the telemetry can be instrumented for the toolset.
|
|
421
|
-
*/
|
|
422
|
-
interface Toolset<TTool = BaseTool, TToolCollection = TTool[]> extends InstrumentedInstance {
|
|
423
|
-
_wrapTool: (tool: Tool) => TTool;
|
|
424
|
-
getTools: (params?: ToolListParams) => Promise<TToolCollection>;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Base toolset implementation with proper generic defaults
|
|
429
|
-
* This class is used to create a different toolsets by extending this class.
|
|
430
|
-
*
|
|
431
|
-
* This class provides basic functionality to get tools, pre-process and post-process tools.
|
|
432
|
-
* Every toolset should extend this class and implement the `_wrapTool` method,
|
|
433
|
-
* these extended toolsets can add their own functionality/methods to the toolset.
|
|
434
|
-
*
|
|
435
|
-
* eg:
|
|
436
|
-
* class YourToolSet extends BaseComposioToolset<CustomToolCollection, CustomTool> {}
|
|
437
|
-
*/
|
|
438
|
-
declare abstract class BaseComposioToolset<TToolCollection, TTool> implements Toolset<TTool, TToolCollection> {
|
|
439
|
-
protected client: Composio<this> | undefined;
|
|
440
|
-
abstract FILE_NAME: string;
|
|
441
|
-
protected DEFAULT_ENTITY_ID: string;
|
|
442
|
-
/**
|
|
443
|
-
* Set the client for the toolset. This is automatically done by the Composio class.
|
|
444
|
-
* @param client - The Composio client.
|
|
445
|
-
*/
|
|
446
|
-
setClient(client: Composio<this>): void;
|
|
447
|
-
/**
|
|
448
|
-
* Get all the tools from the client.
|
|
449
|
-
* @param params - The parameters for the tool list.
|
|
450
|
-
* @returns The tools.
|
|
451
|
-
*/
|
|
452
|
-
abstract getTools(params?: ToolListParams): Promise<TToolCollection>;
|
|
453
|
-
/**
|
|
454
|
-
* Get a tool from the client.
|
|
455
|
-
* @param slug - The slug of the tool.
|
|
456
|
-
* @returns The tool.
|
|
457
|
-
*/
|
|
458
|
-
getTool(slug: string): Promise<TTool>;
|
|
459
|
-
/**
|
|
460
|
-
* Wrap a tool in the toolset.
|
|
461
|
-
* @param tool - The tool to wrap.
|
|
462
|
-
* @returns The wrapped tool.
|
|
463
|
-
*/
|
|
464
|
-
abstract _wrapTool(tool: Tool): TTool;
|
|
465
905
|
/**
|
|
466
|
-
*
|
|
467
|
-
* This
|
|
906
|
+
* Compound function to create a new connected account.
|
|
907
|
+
* This function creates a new connected account and returns a connection request.
|
|
908
|
+
* Users can then wait for the connection to be established using the `waitForConnection` method.
|
|
909
|
+
* @param {CreateConnectedAccountParams} data - Data for creating a new connected account
|
|
910
|
+
* @returns {Promise<ConnectionRequest>} Connection request object
|
|
468
911
|
*/
|
|
469
|
-
|
|
912
|
+
createConnectedAccount(data: CreateConnectedAccountParams): Promise<ConnectionRequest>;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
type AcceptableJSONValue = Record<string, unknown> | Array<Record<string, unknown>> | string | number | boolean | null | undefined;
|
|
916
|
+
interface TelemetryTransportParams {
|
|
917
|
+
url: string;
|
|
918
|
+
method: string;
|
|
919
|
+
headers: Record<string, string>;
|
|
920
|
+
data: AcceptableJSONValue;
|
|
470
921
|
}
|
|
471
922
|
|
|
472
923
|
declare abstract class BaseTelemetryTransport {
|
|
@@ -480,7 +931,7 @@ declare abstract class BaseTelemetryTransport {
|
|
|
480
931
|
/**
|
|
481
932
|
* OpenAI ToolSet
|
|
482
933
|
*
|
|
483
|
-
* Author: @
|
|
934
|
+
* Author: Musthaq Ahamad <musthaq@composio.dev>
|
|
484
935
|
* Legacy Reference: https://github.com/ComposioHQ/composio/blob/master/js/src/toolsets/openai.ts
|
|
485
936
|
*
|
|
486
937
|
* This is a default toolset for Composio SDK.
|
|
@@ -489,29 +940,29 @@ declare abstract class BaseTelemetryTransport {
|
|
|
489
940
|
|
|
490
941
|
type OpenAiTool = OpenAI.ChatCompletionTool;
|
|
491
942
|
type OpenAiToolCollection = Array<OpenAiTool>;
|
|
492
|
-
declare class OpenAIToolset extends
|
|
493
|
-
static readonly FRAMEWORK_NAME = "openai";
|
|
494
|
-
readonly FILE_NAME = "toolsets/openai/src/index.ts";
|
|
943
|
+
declare class OpenAIToolset extends BaseNonAgenticToolset<OpenAiToolCollection, OpenAiTool> {
|
|
495
944
|
/**
|
|
496
945
|
* Absract method to wrap a tool in the toolset.
|
|
497
946
|
* This method is implemented by the toolset.
|
|
498
947
|
* @param tool - The tool to wrap.
|
|
499
948
|
* @returns The wrapped tool.
|
|
500
949
|
*/
|
|
501
|
-
|
|
950
|
+
wrapTool: (tool: Tool) => OpenAiTool;
|
|
502
951
|
/**
|
|
503
952
|
* Get all the tools from the Composio in OpenAI format.
|
|
504
953
|
* @param params - The parameters for the tool list.
|
|
954
|
+
* @param modifiers - Optional modifiers to transform tool schemas
|
|
505
955
|
* @returns The tools.
|
|
506
956
|
*/
|
|
507
|
-
getTools(params?: ToolListParams): Promise<OpenAiToolCollection>;
|
|
957
|
+
getTools(userId: string, params?: ToolListParams, modifiers?: ToolOptions): Promise<OpenAiToolCollection>;
|
|
958
|
+
getToolBySlug(userId: string, slug: string, modifiers?: ToolOptions): Promise<OpenAiTool>;
|
|
508
959
|
/**
|
|
509
960
|
* Execute a tool call.
|
|
510
961
|
* @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool to execute.
|
|
511
962
|
* @param {string} userId - The user id.
|
|
512
963
|
* @returns {Promise<string>} The result of the tool call.
|
|
513
964
|
*/
|
|
514
|
-
executeToolCall(tool: OpenAI.ChatCompletionMessageToolCall,
|
|
965
|
+
executeToolCall(userId: string, tool: OpenAI.ChatCompletionMessageToolCall, modifiers?: ExecuteToolModifiers): Promise<string>;
|
|
515
966
|
/**
|
|
516
967
|
* Handle the tool call from the assistant.
|
|
517
968
|
*
|
|
@@ -519,7 +970,7 @@ declare class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Op
|
|
|
519
970
|
* @param {string} userId - The user id.
|
|
520
971
|
* @returns {Promise<string[]>} The results of the tool call.
|
|
521
972
|
*/
|
|
522
|
-
handleToolCall(chatCompletion: OpenAI.ChatCompletion,
|
|
973
|
+
handleToolCall(userId: string, chatCompletion: OpenAI.ChatCompletion, modifiers?: ExecuteToolModifiers): Promise<string[]>;
|
|
523
974
|
/**
|
|
524
975
|
* Handles all the tool calls from the assistant.
|
|
525
976
|
*
|
|
@@ -527,7 +978,7 @@ declare class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Op
|
|
|
527
978
|
* @param {string} userId - The user id.
|
|
528
979
|
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} The tool outputs.
|
|
529
980
|
*/
|
|
530
|
-
handleAssistantMessage(run: OpenAI.Beta.Threads.Run,
|
|
981
|
+
handleAssistantMessage(userId: string, run: OpenAI.Beta.Threads.Run, modifiers?: ExecuteToolModifiers): Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>;
|
|
531
982
|
/**
|
|
532
983
|
* Waits for the assistant stream and handles the tool calls.
|
|
533
984
|
*
|
|
@@ -537,7 +988,7 @@ declare class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Op
|
|
|
537
988
|
* @param {string} userId - The user id.
|
|
538
989
|
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} The run stream.
|
|
539
990
|
*/
|
|
540
|
-
waitAndHandleAssistantStreamToolCalls(client: OpenAI, runStream: Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>, thread: OpenAI.Beta.Threads.Thread,
|
|
991
|
+
waitAndHandleAssistantStreamToolCalls(userId: string, client: OpenAI, runStream: Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>, thread: OpenAI.Beta.Threads.Thread, modifiers?: ExecuteToolModifiers): AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>;
|
|
541
992
|
/**
|
|
542
993
|
* Waits for the assistant tool calls and handles them.
|
|
543
994
|
*
|
|
@@ -547,7 +998,7 @@ declare class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Op
|
|
|
547
998
|
* @param {string} userId - The user id.
|
|
548
999
|
* @returns {Promise<OpenAI.Beta.Threads.Run>} The run object.
|
|
549
1000
|
*/
|
|
550
|
-
waitAndHandleAssistantToolCalls(client: OpenAI, run: OpenAI.Beta.Threads.Run, thread: OpenAI.Beta.Threads.Thread,
|
|
1001
|
+
waitAndHandleAssistantToolCalls(userId: string, client: OpenAI, run: OpenAI.Beta.Threads.Run, thread: OpenAI.Beta.Threads.Thread, modifiers?: ExecuteToolModifiers): Promise<OpenAI.Beta.Threads.Runs.Run>;
|
|
551
1002
|
}
|
|
552
1003
|
|
|
553
1004
|
type ComposioConfig<TToolset extends BaseComposioToolset<unknown, unknown> = OpenAIToolset> = {
|
|
@@ -556,8 +1007,6 @@ type ComposioConfig<TToolset extends BaseComposioToolset<unknown, unknown> = Ope
|
|
|
556
1007
|
allowTracking?: boolean;
|
|
557
1008
|
allowTracing?: boolean;
|
|
558
1009
|
toolset?: TToolset;
|
|
559
|
-
userId?: string;
|
|
560
|
-
connectedAccountIds?: Record<string, string>;
|
|
561
1010
|
telemetryTransport?: BaseTelemetryTransport;
|
|
562
1011
|
};
|
|
563
1012
|
/**
|
|
@@ -566,7 +1015,6 @@ type ComposioConfig<TToolset extends BaseComposioToolset<unknown, unknown> = Ope
|
|
|
566
1015
|
*/
|
|
567
1016
|
declare class Composio<TToolset extends BaseComposioToolset<unknown, unknown> = OpenAIToolset> {
|
|
568
1017
|
private readonly DEFAULT_USER_ID;
|
|
569
|
-
readonly FILE_NAME = "core/composio.ts";
|
|
570
1018
|
/**
|
|
571
1019
|
* The Composio API client.
|
|
572
1020
|
* @type {ComposioClient}
|
|
@@ -574,24 +1022,20 @@ declare class Composio<TToolset extends BaseComposioToolset<unknown, unknown> =
|
|
|
574
1022
|
private client;
|
|
575
1023
|
/**
|
|
576
1024
|
* The configuration for the Composio SDK.
|
|
577
|
-
* @type {ComposioConfig<
|
|
1025
|
+
* @type {ComposioConfig<TToolset>}
|
|
578
1026
|
*/
|
|
579
1027
|
private config;
|
|
580
1028
|
private telemetry;
|
|
581
|
-
/**
|
|
582
|
-
* Context variables for the Composio SDK.
|
|
583
|
-
*/
|
|
584
|
-
userId?: string;
|
|
585
|
-
connectedAccountIds?: Record<string, string>;
|
|
586
1029
|
/**
|
|
587
1030
|
* Core models for Composio.
|
|
588
1031
|
*/
|
|
589
|
-
tools: Tools
|
|
1032
|
+
tools: Tools<unknown, unknown, TToolset>;
|
|
590
1033
|
toolkits: Toolkits;
|
|
591
1034
|
triggers: Triggers;
|
|
592
1035
|
toolset: TToolset;
|
|
593
1036
|
authConfigs: AuthConfigs;
|
|
594
1037
|
connectedAccounts: ConnectedAccounts;
|
|
1038
|
+
createConnectedAccount: ConnectedAccounts['createConnectedAccount'];
|
|
595
1039
|
/**
|
|
596
1040
|
* @param {Object} config Configuration for the Composio SDK.
|
|
597
1041
|
* @param {string} config.apiKey The API key for the Composio SDK.
|
|
@@ -599,7 +1043,7 @@ declare class Composio<TToolset extends BaseComposioToolset<unknown, unknown> =
|
|
|
599
1043
|
* @param {string} config.runtime The runtime for the Composio SDK.
|
|
600
1044
|
* @param {boolean} config.allowTracking Whether to allow analytics / tracking. Defaults to true.
|
|
601
1045
|
* @param {boolean} config.allowTracing Whether to allow tracing. Defaults to true.
|
|
602
|
-
* @param {
|
|
1046
|
+
* @param {TToolset} config.toolset The toolset to use for this Composio instance.
|
|
603
1047
|
*/
|
|
604
1048
|
constructor(config: ComposioConfig<TToolset>);
|
|
605
1049
|
/**
|
|
@@ -608,28 +1052,25 @@ declare class Composio<TToolset extends BaseComposioToolset<unknown, unknown> =
|
|
|
608
1052
|
* @param {BaseTelemetryTransport} transport - The transport for the telemetry.
|
|
609
1053
|
*/
|
|
610
1054
|
private initializeTelemetry;
|
|
611
|
-
/**
|
|
612
|
-
* Get the connected account id for the given app name.
|
|
613
|
-
* @param appName - The name of the app.
|
|
614
|
-
* @returns {string | undefined} The connected account id for the given app name.
|
|
615
|
-
*/
|
|
616
|
-
getConnectedAccountId(appName: string): string | undefined;
|
|
617
1055
|
/**
|
|
618
1056
|
* Get the Composio SDK client.
|
|
619
1057
|
* @returns {ComposioClient} The Composio API client.
|
|
620
1058
|
*/
|
|
621
1059
|
getClient(): ComposioClient;
|
|
622
1060
|
/**
|
|
623
|
-
*
|
|
624
|
-
* @
|
|
1061
|
+
* Fetch all the tools from Composio.
|
|
1062
|
+
* @param {ToolListParams} params Parameters to fetch the tools.
|
|
1063
|
+
* @param {ToolsetOptions<TToolset>} modifiers Modifiers to apply to the tools.
|
|
1064
|
+
* @returns {Promise<ReturnType<TToolset['getTools']>>} The tools from the toolset.
|
|
625
1065
|
*/
|
|
626
|
-
|
|
1066
|
+
getTools<T extends TToolset>(userId: string, filters: ToolListParams, modifiers?: ToolsetOptions<T>): Promise<ReturnType<T['getTools']>>;
|
|
627
1067
|
/**
|
|
628
|
-
*
|
|
629
|
-
* @param
|
|
630
|
-
* @
|
|
1068
|
+
* Fetch a tool from Composio by its slug.
|
|
1069
|
+
* @param {string} slug slug of the tool
|
|
1070
|
+
* @param {ToolsetOptions<TToolset>} modifiers to be applied to the tool
|
|
1071
|
+
* @returns {Promise<ReturnType<TToolset['getToolBySlug']>>} The tool from the toolset.
|
|
631
1072
|
*/
|
|
632
|
-
|
|
1073
|
+
getToolBySlug<T extends TToolset>(userId: string, slug: string, modifiers?: ToolsetOptions<T>): Promise<ReturnType<T['getToolBySlug']>>;
|
|
633
1074
|
}
|
|
634
1075
|
|
|
635
1076
|
/**
|
|
@@ -641,13 +1082,25 @@ declare class Composio<TToolset extends BaseComposioToolset<unknown, unknown> =
|
|
|
641
1082
|
interface CustomTool {
|
|
642
1083
|
name: string;
|
|
643
1084
|
}
|
|
644
|
-
declare class ComposioToolset extends
|
|
1085
|
+
declare class ComposioToolset extends BaseNonAgenticToolset<Array<CustomTool>, CustomTool> {
|
|
645
1086
|
readonly FILE_NAME: string;
|
|
646
|
-
|
|
647
|
-
|
|
1087
|
+
constructor();
|
|
1088
|
+
wrapTool: (tool: Tool) => CustomTool;
|
|
1089
|
+
getTools(userId: string, params?: ToolListParams, options?: ToolOptions): Promise<Array<CustomTool>>;
|
|
1090
|
+
getToolBySlug(userId: string, slug: string, modifiers?: ToolOptions): Promise<CustomTool>;
|
|
648
1091
|
test(): Promise<void>;
|
|
649
1092
|
}
|
|
650
1093
|
|
|
651
1094
|
declare function jsonSchemaToModel(jsonSchema: Record<string, unknown>): z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
652
1095
|
|
|
653
|
-
|
|
1096
|
+
/**
|
|
1097
|
+
* Base toolset implementation, which needs to be implemented by the extended class.
|
|
1098
|
+
* This class is used to create a base toolset by implementing this class.
|
|
1099
|
+
* This class also extends InstrumentedInstance, so that the telemetry can be instrumented for the toolset.
|
|
1100
|
+
*/
|
|
1101
|
+
interface Toolset<TTool, TToolCollection> {
|
|
1102
|
+
wrapTool: (tool: Tool) => TTool;
|
|
1103
|
+
getTools: (params?: ToolListParams) => Promise<TToolCollection>;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
export { type AfterToolExecuteModifier, type AgenticToolOptions, BaseAgenticToolset, type BaseComposioToolset, BaseNonAgenticToolset, BaseTelemetryTransport, type BeforeToolExecuteModifier, Composio, ComposioToolset, type ExecuteMetadata, type ExecuteToolModifiers, OpenAIToolset, type Tool, type ToolListParams, ToolListParamsSchema, type ToolOptions, type Toolset, type TransformToolSchemaModifier, jsonSchemaToModel };
|