@composio/core 0.1.0-rc.1
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/README.md +126 -0
- package/dist/index.cjs +1453 -0
- package/dist/index.d.cts +653 -0
- package/dist/index.d.ts +653 -0
- package/dist/index.js +1419 -0
- package/package.json +39 -0
- package/src/index.ts +30 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import ComposioClient from '@composio/client';
|
|
2
|
+
import { ToolRetrieveResponse, ToolListParams as ToolListParams$1, ToolListResponse, ToolExecuteParams, ToolExecuteResponse, ToolRetrieveEnumResponse, ToolGetInputParams, ToolGetInputResponse } from '@composio/client/resources/tools';
|
|
3
|
+
import z$1, { z } from 'zod';
|
|
4
|
+
import { RequestOptions } from '@composio/client/internal/request-options';
|
|
5
|
+
import { ToolkitListParams, ToolkitListResponse, ToolkitRetrieveResponse, ToolkitRetrieveCategoriesResponse } from '@composio/client/resources/toolkits';
|
|
6
|
+
import { TriggerInstanceListActiveParams, TriggerInstanceUpsertParams, TriggerInstanceUpsertResponse, TriggerInstanceRemoveUpsertResponse, TriggerInstanceUpdateStatusParams, TriggersTypeListParams, TriggersTypeListResponse, TriggersTypeRetrieveResponse, TriggersTypeRetrieveEnumResponse } from '@composio/client/resources/index';
|
|
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';
|
|
9
|
+
import { OpenAI } from 'openai';
|
|
10
|
+
import { Stream } from 'openai/streaming';
|
|
11
|
+
|
|
12
|
+
type Tool = ToolRetrieveResponse;
|
|
13
|
+
interface BaseTool {
|
|
14
|
+
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
input_parameters?: Record<string, any>;
|
|
17
|
+
output_parameters?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
declare const ToolListParamsSchema: z.ZodObject<{
|
|
20
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
21
|
+
important: z.ZodOptional<z.ZodString>;
|
|
22
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
23
|
+
search: z.ZodOptional<z.ZodString>;
|
|
24
|
+
toolkit_slug: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
cursor?: string | undefined;
|
|
27
|
+
important?: string | undefined;
|
|
28
|
+
limit?: string | undefined;
|
|
29
|
+
search?: string | undefined;
|
|
30
|
+
toolkit_slug?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
cursor?: string | undefined;
|
|
33
|
+
important?: string | undefined;
|
|
34
|
+
limit?: string | undefined;
|
|
35
|
+
search?: string | undefined;
|
|
36
|
+
toolkit_slug?: string | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
type ToolListParams = z.infer<typeof ToolListParamsSchema>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Interface for any instance that extends InstrumentedInstance.
|
|
42
|
+
* Classess implementing this interface will be instrumented for telemetry.
|
|
43
|
+
*/
|
|
44
|
+
interface InstrumentedInstance {
|
|
45
|
+
FILE_NAME: string;
|
|
46
|
+
}
|
|
47
|
+
type AcceptableJSONValue = Record<string, unknown> | Array<Record<string, unknown>> | string | number | boolean | null | undefined;
|
|
48
|
+
interface TelemetryTransportParams {
|
|
49
|
+
url: string;
|
|
50
|
+
method: string;
|
|
51
|
+
headers: Record<string, string>;
|
|
52
|
+
data: AcceptableJSONValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This class is used to manage tools in the Composio SDK.
|
|
57
|
+
* It provides methods to list, get, and execute tools.
|
|
58
|
+
*/
|
|
59
|
+
declare class Tools implements InstrumentedInstance {
|
|
60
|
+
readonly FILE_NAME: string;
|
|
61
|
+
private client;
|
|
62
|
+
constructor(client: ComposioClient);
|
|
63
|
+
/**
|
|
64
|
+
* Lists all tools available in the Composio SDK.
|
|
65
|
+
* This method fetches the tools from the Composio API and wraps them using the toolset.
|
|
66
|
+
* @returns {Tools[]>} List of tools
|
|
67
|
+
*/
|
|
68
|
+
list(query?: ToolListParams$1): Promise<ToolListResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves a tool by its Slug.
|
|
71
|
+
* @param slug The ID of the tool to be retrieved
|
|
72
|
+
* @returns {Promise<Tool>} The tool
|
|
73
|
+
*/
|
|
74
|
+
get(slug: string): Promise<Tool>;
|
|
75
|
+
/**
|
|
76
|
+
* Exectes a given tool with the provided parameters.
|
|
77
|
+
*
|
|
78
|
+
* This method calls the Composio API to execute the tool and returns the response.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} slug - The ID of the tool to be executed
|
|
81
|
+
* @param {ToolExecuteParams} body - The parameters to be passed to the tool
|
|
82
|
+
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
83
|
+
*/
|
|
84
|
+
execute(slug: string, body: ToolExecuteParams): Promise<ToolExecuteResponse>;
|
|
85
|
+
/**
|
|
86
|
+
* Fetches the list of all available tools in the Composio SDK.
|
|
87
|
+
*
|
|
88
|
+
* This method is mostly used by the CLI to get the list of tools.
|
|
89
|
+
* No filtering is done on the tools, the list is cached in the backend, no further optimization is required.
|
|
90
|
+
* @returns {string} - The list of all available tools as a string
|
|
91
|
+
*/
|
|
92
|
+
getToolsEnum(): Promise<ToolRetrieveEnumResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Fetches the input parameters for a given tool.
|
|
95
|
+
*
|
|
96
|
+
* This method is used to get the input parameters for a tool before executing it.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} slug - The ID of the tool to find input for
|
|
99
|
+
* @param {ToolGetInputParams} body - The parameters to be passed to the tool
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
getInput(slug: string, body: ToolGetInputParams): Promise<ToolGetInputResponse>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Toolkits class
|
|
107
|
+
*
|
|
108
|
+
* Toolkits are a collection of tools that can be used to perform various tasks.
|
|
109
|
+
* This is similar/replacement of `apps` in the Composio API.
|
|
110
|
+
*/
|
|
111
|
+
declare class Toolkits implements InstrumentedInstance {
|
|
112
|
+
readonly FILE_NAME: string;
|
|
113
|
+
private client;
|
|
114
|
+
constructor(client: ComposioClient);
|
|
115
|
+
/**
|
|
116
|
+
* List all toolkits available in the Composio SDK.
|
|
117
|
+
* This method fetches the toolkits from the Composio API.
|
|
118
|
+
* @returns {Promise<Toolkit[]>} List of toolkits
|
|
119
|
+
*/
|
|
120
|
+
list(query: ToolkitListParams, options?: RequestOptions): Promise<ToolkitListResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* Fetches a toolkit by its Slug.
|
|
123
|
+
* This method retrieves the toolkit from the Composio API.
|
|
124
|
+
* @param slug - The ID of the toolkit to be retrieved
|
|
125
|
+
* @param options - Request options
|
|
126
|
+
* @returns {Promise<ToolkitRetrieveResponse>} The toolkit object
|
|
127
|
+
*/
|
|
128
|
+
get(slug: string, options?: RequestOptions): Promise<ToolkitRetrieveResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Fetches all categories available in the Composio SDK
|
|
131
|
+
*
|
|
132
|
+
* @returns {Promise<ToolkitRetrieveCategoriesResponse>} List of categories
|
|
133
|
+
*/
|
|
134
|
+
listCategories(options?: RequestOptions): Promise<ToolkitRetrieveCategoriesResponse>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type TriggerStatusEnum = "enable" | "disable";
|
|
138
|
+
declare const ZTriggerSubscribeParam: z.ZodObject<{
|
|
139
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
140
|
+
triggerId: z.ZodOptional<z.ZodString>;
|
|
141
|
+
connectionId: z.ZodOptional<z.ZodString>;
|
|
142
|
+
integrationId: z.ZodOptional<z.ZodString>;
|
|
143
|
+
triggerName: z.ZodOptional<z.ZodString>;
|
|
144
|
+
triggerData: z.ZodOptional<z.ZodString>;
|
|
145
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
}, "strip", z.ZodTypeAny, {
|
|
147
|
+
appName?: string | undefined;
|
|
148
|
+
triggerId?: string | undefined;
|
|
149
|
+
connectionId?: string | undefined;
|
|
150
|
+
integrationId?: string | undefined;
|
|
151
|
+
triggerName?: string | undefined;
|
|
152
|
+
triggerData?: string | undefined;
|
|
153
|
+
entityId?: string | undefined;
|
|
154
|
+
}, {
|
|
155
|
+
appName?: string | undefined;
|
|
156
|
+
triggerId?: string | undefined;
|
|
157
|
+
connectionId?: string | undefined;
|
|
158
|
+
integrationId?: string | undefined;
|
|
159
|
+
triggerName?: string | undefined;
|
|
160
|
+
triggerData?: string | undefined;
|
|
161
|
+
entityId?: string | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
type TriggerSubscribeParams = z.infer<typeof ZTriggerSubscribeParam>;
|
|
164
|
+
|
|
165
|
+
type TriggerData = {
|
|
166
|
+
appName: string;
|
|
167
|
+
clientId: number;
|
|
168
|
+
payload: Record<string, unknown>;
|
|
169
|
+
originalPayload: Record<string, unknown>;
|
|
170
|
+
metadata: {
|
|
171
|
+
id: string;
|
|
172
|
+
connectionId: string;
|
|
173
|
+
triggerName: string;
|
|
174
|
+
triggerData: string;
|
|
175
|
+
triggerConfig: Record<string, unknown>;
|
|
176
|
+
connection: {
|
|
177
|
+
id: string;
|
|
178
|
+
integrationId: string;
|
|
179
|
+
clientUniqueUserId: string;
|
|
180
|
+
status: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Trigger (Instance) class
|
|
187
|
+
* /api/v3/trigger_instances
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
declare class Triggers implements InstrumentedInstance {
|
|
191
|
+
readonly FILE_NAME: string;
|
|
192
|
+
private client;
|
|
193
|
+
constructor(client: ComposioClient);
|
|
194
|
+
/**
|
|
195
|
+
* Fetch list of all the active triggers
|
|
196
|
+
* @returns {Promise<TriggerInstance[]>} List of trigger instances
|
|
197
|
+
*/
|
|
198
|
+
list(query?: TriggerInstanceListActiveParams, options?: RequestOptions): Promise<ComposioClient.TriggerInstances.TriggerInstanceListActiveResponse>;
|
|
199
|
+
/**
|
|
200
|
+
* Create a new trigger instance
|
|
201
|
+
*
|
|
202
|
+
* @param {string} slug - The slug of the trigger instance
|
|
203
|
+
* @param {TriggerInstanceUpsertParams} body - The parameters to create the trigger instance
|
|
204
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The created trigger instance
|
|
205
|
+
*/
|
|
206
|
+
create(slug: string, body: TriggerInstanceUpsertParams, options?: RequestOptions): Promise<TriggerInstanceUpsertResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Update an existing trigger instance
|
|
209
|
+
*
|
|
210
|
+
* @param {string} slug - The slug of the trigger instance
|
|
211
|
+
* @param {TriggerInstanceUpsertParams} body - The parameters to create the trigger instance
|
|
212
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance
|
|
213
|
+
*/
|
|
214
|
+
update(slug: string, body: TriggerInstanceUpsertParams, options?: RequestOptions): Promise<TriggerInstanceUpsertResponse>;
|
|
215
|
+
/**
|
|
216
|
+
* Delete a trigger instance
|
|
217
|
+
*
|
|
218
|
+
* @param {string} slug - The slug of the trigger instance
|
|
219
|
+
* @returns
|
|
220
|
+
*/
|
|
221
|
+
delete(slug: string): Promise<TriggerInstanceRemoveUpsertResponse>;
|
|
222
|
+
/**
|
|
223
|
+
* Update the status of a trigger
|
|
224
|
+
*
|
|
225
|
+
* @param {TriggerStatusEnum} status - The new status of the trigger
|
|
226
|
+
* @param {TriggerInstanceUpdateStatusParams} params - The parameters to update the trigger instance
|
|
227
|
+
* @param {RequestOptions} options - Request options
|
|
228
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance
|
|
229
|
+
*/
|
|
230
|
+
updateStatus(status: TriggerStatusEnum, params: TriggerInstanceUpdateStatusParams, options?: RequestOptions): Promise<ComposioClient.TriggerInstances.TriggerInstanceUpdateStatusResponse>;
|
|
231
|
+
/**
|
|
232
|
+
* Disable a trigger instance
|
|
233
|
+
*
|
|
234
|
+
* @param {string} slug - The slug of the trigger instance
|
|
235
|
+
* @param {RequestOptions options - Request options
|
|
236
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance
|
|
237
|
+
*/
|
|
238
|
+
disable(slug: string, options?: RequestOptions): Promise<ComposioClient.TriggerInstances.TriggerInstanceUpdateStatusResponse>;
|
|
239
|
+
/**
|
|
240
|
+
* Enable a trigger instance
|
|
241
|
+
*
|
|
242
|
+
* @param {string} slug - The slug of the trigger instance
|
|
243
|
+
* @param {RequestOptions options - Request options
|
|
244
|
+
* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance
|
|
245
|
+
*/
|
|
246
|
+
enable(slug: string, options?: RequestOptions): Promise<ComposioClient.TriggerInstances.TriggerInstanceUpdateStatusResponse>;
|
|
247
|
+
/**
|
|
248
|
+
* @TODO Learn about trigger types
|
|
249
|
+
*/
|
|
250
|
+
/**
|
|
251
|
+
* List all the trigger types
|
|
252
|
+
*
|
|
253
|
+
* @param {TriggersTypeListParams} query - The query parameters to filter the trigger types
|
|
254
|
+
* @param {RequestOptions} options - Request options
|
|
255
|
+
* @returns {Promise<TriggersTypeListResponse>} The list of trigger types
|
|
256
|
+
*/
|
|
257
|
+
listTypes(query?: TriggersTypeListParams, options?: RequestOptions): Promise<TriggersTypeListResponse>;
|
|
258
|
+
/**
|
|
259
|
+
* Retrieve a trigger type by its slug
|
|
260
|
+
*
|
|
261
|
+
* @param {string} slug - The slug of the trigger type
|
|
262
|
+
* @param {RequestOptions} options - request options
|
|
263
|
+
* @returns {Promise<TriggersTypeRetrieveResponse>} The trigger type object
|
|
264
|
+
*/
|
|
265
|
+
getType(slug: string, options?: RequestOptions): Promise<TriggersTypeRetrieveResponse>;
|
|
266
|
+
/**
|
|
267
|
+
* Fetches the list of all the available trigger enums
|
|
268
|
+
*
|
|
269
|
+
* This method is used by the CLI where filters are not required.
|
|
270
|
+
* @param options
|
|
271
|
+
* @returns
|
|
272
|
+
*/
|
|
273
|
+
listEnum(options?: RequestOptions): Promise<TriggersTypeRetrieveEnumResponse>;
|
|
274
|
+
subscribe(fn: (data: TriggerData) => void, filters?: TriggerSubscribeParams): Promise<void>;
|
|
275
|
+
unsubscribe(): Promise<void>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* AuthConfigs class
|
|
280
|
+
*
|
|
281
|
+
* This class is used to manage authentication configurations in the Composio SDK.
|
|
282
|
+
* Auth configs are used to configure authentication providers and settings.
|
|
283
|
+
*/
|
|
284
|
+
declare class AuthConfigs implements InstrumentedInstance {
|
|
285
|
+
readonly FILE_NAME: string;
|
|
286
|
+
private client;
|
|
287
|
+
constructor(client: ComposioClient);
|
|
288
|
+
/**
|
|
289
|
+
* List all auth configs
|
|
290
|
+
* @param {AuthConfigListParams} query - Query parameters for filtering auth configs
|
|
291
|
+
* @param {RequestOptions} options - Request options
|
|
292
|
+
* @returns {Promise<AuthConfigListResponse>} List of auth configs
|
|
293
|
+
*/
|
|
294
|
+
list(query?: AuthConfigListParams, options?: RequestOptions): Promise<AuthConfigListResponse>;
|
|
295
|
+
/**
|
|
296
|
+
* Create a new auth config
|
|
297
|
+
* @param {AuthConfigCreateParams} data - Data for creating a new auth config
|
|
298
|
+
* @param {RequestOptions} options - Request options
|
|
299
|
+
* @returns {Promise<AuthConfigCreateResponse>} Created auth config
|
|
300
|
+
*/
|
|
301
|
+
create(data: AuthConfigCreateParams, options?: RequestOptions): Promise<AuthConfigCreateResponse>;
|
|
302
|
+
/**
|
|
303
|
+
* Get an auth config by nanoid
|
|
304
|
+
* @param {string} nanoid - Unique identifier of the auth config
|
|
305
|
+
* @param {RequestOptions} options - Request options
|
|
306
|
+
* @returns {Promise<AuthConfigRetrieveResponse>} Auth config details
|
|
307
|
+
*/
|
|
308
|
+
get(nanoid: string, options?: RequestOptions): Promise<AuthConfigRetrieveResponse>;
|
|
309
|
+
/**
|
|
310
|
+
* Update an auth config
|
|
311
|
+
* @param {string} nanoid - Unique identifier of the auth config to update
|
|
312
|
+
* @param {AuthConfigUpdateParams} data - Data to update
|
|
313
|
+
* @param {RequestOptions} options - Request options
|
|
314
|
+
* @returns {Promise<AuthConfigUpdateResponse>} Updated auth config
|
|
315
|
+
*/
|
|
316
|
+
update(nanoid: string, data: AuthConfigUpdateParams, options?: RequestOptions): Promise<AuthConfigUpdateResponse>;
|
|
317
|
+
/**
|
|
318
|
+
* Delete an auth config
|
|
319
|
+
* @param {string} nanoid - Unique identifier of the auth config to delete
|
|
320
|
+
* @param {RequestOptions} options - Request options
|
|
321
|
+
* @returns {Promise<AuthConfigDeleteResponse>} Response from deletion
|
|
322
|
+
*/
|
|
323
|
+
delete(nanoid: string, options?: RequestOptions): Promise<AuthConfigDeleteResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Update the status of an auth config
|
|
326
|
+
* @param {string} status - The status to update the auth config to
|
|
327
|
+
* @param {string} nanoid - Unique identifier of the auth config
|
|
328
|
+
* @param {RequestOptions} options - Request options
|
|
329
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
330
|
+
*/
|
|
331
|
+
updateStatus(status: "ENABLED" | "DISABLED", nanoid: string, options?: RequestOptions): Promise<AuthConfigUpdateStatusResponse>;
|
|
332
|
+
/**
|
|
333
|
+
* Enable an auth config
|
|
334
|
+
* @param {string} nanoid - Unique identifier of the auth config
|
|
335
|
+
* @param {RequestOptions} options - Request options
|
|
336
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
337
|
+
*/
|
|
338
|
+
enable(nanoid: string, options?: RequestOptions): Promise<AuthConfigUpdateStatusResponse>;
|
|
339
|
+
/**
|
|
340
|
+
* Disable an auth config
|
|
341
|
+
* @param {string} nanoid - Unique identifier of the auth config
|
|
342
|
+
* @param {RequestOptions} options - Request options
|
|
343
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
|
|
344
|
+
*/
|
|
345
|
+
disable(nanoid: string, options?: RequestOptions): Promise<AuthConfigUpdateStatusResponse>;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* ConnectedAccounts class
|
|
350
|
+
*
|
|
351
|
+
* This class is used to manage connected accounts in the Composio SDK.
|
|
352
|
+
* Connected accounts are used to authenticate with third-party services.
|
|
353
|
+
*/
|
|
354
|
+
declare class ConnectedAccounts implements InstrumentedInstance {
|
|
355
|
+
readonly FILE_NAME: string;
|
|
356
|
+
private client;
|
|
357
|
+
constructor(client: ComposioClient);
|
|
358
|
+
/**
|
|
359
|
+
* List all connected accounts
|
|
360
|
+
* @param {ConnectedAccountListParams} query - Query parameters for filtering connected accounts
|
|
361
|
+
* @param {RequestOptions} options - Request options
|
|
362
|
+
* @returns {Promise<ConnectedAccountListResponse>} List of connected accounts
|
|
363
|
+
*/
|
|
364
|
+
list(query?: ConnectedAccountListParams, options?: RequestOptions): Promise<ConnectedAccountListResponse>;
|
|
365
|
+
/**
|
|
366
|
+
* Create a new connected account
|
|
367
|
+
* @param {ConnectedAccountCreateParams} data - Data for creating a new connected account
|
|
368
|
+
* @param {RequestOptions} options - Request options
|
|
369
|
+
* @returns {Promise<ConnectedAccountCreateResponse>} Created connected account
|
|
370
|
+
*/
|
|
371
|
+
create(data: ConnectedAccountCreateParams, options?: RequestOptions): Promise<ConnectedAccountCreateResponse>;
|
|
372
|
+
/**
|
|
373
|
+
* Get a connected account by nanoid
|
|
374
|
+
* @param {string} nanoid - Unique identifier of the connected account
|
|
375
|
+
* @param {RequestOptions} options - Request options
|
|
376
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
|
|
377
|
+
*/
|
|
378
|
+
get(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountRetrieveResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Delete a connected account
|
|
381
|
+
* @param {string} nanoid - Unique identifier of the connected account to delete
|
|
382
|
+
* @param {RequestOptions} options - Request options
|
|
383
|
+
* @returns {Promise<ConnectedAccountDeleteResponse>} Response from deletion
|
|
384
|
+
*/
|
|
385
|
+
delete(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountDeleteResponse>;
|
|
386
|
+
/**
|
|
387
|
+
* Refresh a connected account's credentials
|
|
388
|
+
* @param {string} nanoid - Unique identifier of the connected account to refresh
|
|
389
|
+
* @param {RequestOptions} options - Request options
|
|
390
|
+
* @returns {Promise<ConnectedAccountRefreshResponse>} Refreshed connected account details
|
|
391
|
+
*/
|
|
392
|
+
refresh(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountRefreshResponse>;
|
|
393
|
+
/**
|
|
394
|
+
* Update the status of a connected account
|
|
395
|
+
* @param {string} nanoid - Unique identifier of the connected account
|
|
396
|
+
* @param {ConnectedAccountUpdateStatusParams} params - Parameters for updating the status
|
|
397
|
+
* @param {RequestOptions} options - Request options
|
|
398
|
+
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
399
|
+
*/
|
|
400
|
+
updateStatus(nanoid: string, params: ConnectedAccountUpdateStatusParams, options?: RequestOptions): Promise<ConnectedAccountUpdateStatusResponse>;
|
|
401
|
+
/**
|
|
402
|
+
* Enable a connected account
|
|
403
|
+
* @param {string} nanoid - Unique identifier of the connected account
|
|
404
|
+
* @param {RequestOptions} options - Request options
|
|
405
|
+
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
406
|
+
*/
|
|
407
|
+
enable(nanoid: string, options?: RequestOptions): Promise<ConnectedAccountUpdateStatusResponse>;
|
|
408
|
+
/**
|
|
409
|
+
* Disable a connected account
|
|
410
|
+
* @param {string} nanoid - Unique identifier of the connected account
|
|
411
|
+
* @param {RequestOptions} options - Request options
|
|
412
|
+
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
413
|
+
*/
|
|
414
|
+
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
|
+
/**
|
|
466
|
+
* Ensure the client is initialized.
|
|
467
|
+
* This is automatically done by the Composio class.
|
|
468
|
+
*/
|
|
469
|
+
protected ensureClient(): void;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
declare abstract class BaseTelemetryTransport {
|
|
473
|
+
/**
|
|
474
|
+
* Send the payload to the telemetry service.
|
|
475
|
+
* @param payload - The payload to send.
|
|
476
|
+
*/
|
|
477
|
+
abstract send(payload: TelemetryTransportParams): Promise<void>;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* OpenAI ToolSet
|
|
482
|
+
*
|
|
483
|
+
* Author: @haxzie
|
|
484
|
+
* Legacy Reference: https://github.com/ComposioHQ/composio/blob/master/js/src/toolsets/openai.ts
|
|
485
|
+
*
|
|
486
|
+
* This is a default toolset for Composio SDK.
|
|
487
|
+
* This will be shipped with the SDK and users don't need to install it separately.
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
type OpenAiTool = OpenAI.ChatCompletionTool;
|
|
491
|
+
type OpenAiToolCollection = Array<OpenAiTool>;
|
|
492
|
+
declare class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, OpenAiTool> {
|
|
493
|
+
static readonly FRAMEWORK_NAME = "openai";
|
|
494
|
+
readonly FILE_NAME = "toolsets/openai/src/index.ts";
|
|
495
|
+
/**
|
|
496
|
+
* Absract method to wrap a tool in the toolset.
|
|
497
|
+
* This method is implemented by the toolset.
|
|
498
|
+
* @param tool - The tool to wrap.
|
|
499
|
+
* @returns The wrapped tool.
|
|
500
|
+
*/
|
|
501
|
+
_wrapTool: (tool: Tool) => OpenAiTool;
|
|
502
|
+
/**
|
|
503
|
+
* Get all the tools from the Composio in OpenAI format.
|
|
504
|
+
* @param params - The parameters for the tool list.
|
|
505
|
+
* @returns The tools.
|
|
506
|
+
*/
|
|
507
|
+
getTools(params?: ToolListParams): Promise<OpenAiToolCollection>;
|
|
508
|
+
/**
|
|
509
|
+
* Execute a tool call.
|
|
510
|
+
* @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool to execute.
|
|
511
|
+
* @param {string} userId - The user id.
|
|
512
|
+
* @returns {Promise<string>} The result of the tool call.
|
|
513
|
+
*/
|
|
514
|
+
executeToolCall(tool: OpenAI.ChatCompletionMessageToolCall, userId?: string): Promise<string>;
|
|
515
|
+
/**
|
|
516
|
+
* Handle the tool call from the assistant.
|
|
517
|
+
*
|
|
518
|
+
* @param {OpenAI.ChatCompletion} chatCompletion - The chat completion object.
|
|
519
|
+
* @param {string} userId - The user id.
|
|
520
|
+
* @returns {Promise<string[]>} The results of the tool call.
|
|
521
|
+
*/
|
|
522
|
+
handleToolCall(chatCompletion: OpenAI.ChatCompletion, userId?: string): Promise<string[]>;
|
|
523
|
+
/**
|
|
524
|
+
* Handles all the tool calls from the assistant.
|
|
525
|
+
*
|
|
526
|
+
* @param {OpenAI.Beta.Threads.Run} run - The run object.
|
|
527
|
+
* @param {string} userId - The user id.
|
|
528
|
+
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} The tool outputs.
|
|
529
|
+
*/
|
|
530
|
+
handleAssistantMessage(run: OpenAI.Beta.Threads.Run, userId?: string): Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>;
|
|
531
|
+
/**
|
|
532
|
+
* Waits for the assistant stream and handles the tool calls.
|
|
533
|
+
*
|
|
534
|
+
* @param {OpenAI} client - The OpenAI client.
|
|
535
|
+
* @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The run stream.
|
|
536
|
+
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object.
|
|
537
|
+
* @param {string} userId - The user id.
|
|
538
|
+
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} The run stream.
|
|
539
|
+
*/
|
|
540
|
+
waitAndHandleAssistantStreamToolCalls(client: OpenAI, runStream: Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>, thread: OpenAI.Beta.Threads.Thread, userId?: string): AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>;
|
|
541
|
+
/**
|
|
542
|
+
* Waits for the assistant tool calls and handles them.
|
|
543
|
+
*
|
|
544
|
+
* @param {OpenAI} client - The OpenAI client.
|
|
545
|
+
* @param {OpenAI.Beta.Threads.Run} run - The run object.
|
|
546
|
+
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object.
|
|
547
|
+
* @param {string} userId - The user id.
|
|
548
|
+
* @returns {Promise<OpenAI.Beta.Threads.Run>} The run object.
|
|
549
|
+
*/
|
|
550
|
+
waitAndHandleAssistantToolCalls(client: OpenAI, run: OpenAI.Beta.Threads.Run, thread: OpenAI.Beta.Threads.Thread, userId?: string): Promise<OpenAI.Beta.Threads.Runs.Run>;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
type ComposioConfig<TToolset extends BaseComposioToolset<any, any> = OpenAIToolset> = {
|
|
554
|
+
apiKey?: string;
|
|
555
|
+
baseURL?: string;
|
|
556
|
+
allowTracking?: boolean;
|
|
557
|
+
allowTracing?: boolean;
|
|
558
|
+
toolset?: TToolset;
|
|
559
|
+
userId?: string;
|
|
560
|
+
connectedAccountIds?: Record<string, string>;
|
|
561
|
+
telemetryTransport?: BaseTelemetryTransport;
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* This is the core class for Composio.
|
|
565
|
+
* It is used to initialize the Composio SDK and provide a global configuration.
|
|
566
|
+
*/
|
|
567
|
+
declare class Composio<TToolset extends BaseComposioToolset<any, any> = OpenAIToolset> {
|
|
568
|
+
private readonly DEFAULT_USER_ID;
|
|
569
|
+
readonly FILE_NAME = "core/composio.ts";
|
|
570
|
+
/**
|
|
571
|
+
* The Composio API client.
|
|
572
|
+
* @type {ComposioClient}
|
|
573
|
+
*/
|
|
574
|
+
private client;
|
|
575
|
+
/**
|
|
576
|
+
* The configuration for the Composio SDK.
|
|
577
|
+
* @type {ComposioConfig<TTool, TToolset>}
|
|
578
|
+
*/
|
|
579
|
+
private config;
|
|
580
|
+
private telemetry;
|
|
581
|
+
/**
|
|
582
|
+
* Context variables for the Composio SDK.
|
|
583
|
+
*/
|
|
584
|
+
userId?: string;
|
|
585
|
+
connectedAccountIds?: Record<string, string>;
|
|
586
|
+
/**
|
|
587
|
+
* Core models for Composio.
|
|
588
|
+
*/
|
|
589
|
+
tools: Tools;
|
|
590
|
+
toolkits: Toolkits;
|
|
591
|
+
triggers: Triggers;
|
|
592
|
+
toolset: TToolset;
|
|
593
|
+
authConfigs: AuthConfigs;
|
|
594
|
+
connectedAccounts: ConnectedAccounts;
|
|
595
|
+
/**
|
|
596
|
+
* @param {Object} config Configuration for the Composio SDK.
|
|
597
|
+
* @param {string} config.apiKey The API key for the Composio SDK.
|
|
598
|
+
* @param {string} config.baseURL The base URL for the Composio SDK.
|
|
599
|
+
* @param {string} config.runtime The runtime for the Composio SDK.
|
|
600
|
+
* @param {boolean} config.allowTracking Whether to allow analytics / tracking. Defaults to true.
|
|
601
|
+
* @param {boolean} config.allowTracing Whether to allow tracing. Defaults to true.
|
|
602
|
+
* @param {TS} config.toolset The toolset to use for this Composio instance.
|
|
603
|
+
*/
|
|
604
|
+
constructor(config: ComposioConfig<TToolset>);
|
|
605
|
+
/**
|
|
606
|
+
* Initialize the instrumentations and telemetry for the Composio SDK.
|
|
607
|
+
* @param {TelemetryMetadata} config - The configuration for the telemetry.
|
|
608
|
+
* @param {BaseTelemetryTransport} transport - The transport for the telemetry.
|
|
609
|
+
*/
|
|
610
|
+
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
|
+
/**
|
|
618
|
+
* Get the Composio SDK client.
|
|
619
|
+
* @returns {ComposioClient} The Composio API client.
|
|
620
|
+
*/
|
|
621
|
+
getClient(): ComposioClient;
|
|
622
|
+
/**
|
|
623
|
+
* Generic function to get all the tools
|
|
624
|
+
* @returns {Promise<ReturnType<TToolset["getTool"]>>} Promise with list of tools
|
|
625
|
+
*/
|
|
626
|
+
getTool(slug: string): Promise<ReturnType<TToolset["getTool"]>>;
|
|
627
|
+
/**
|
|
628
|
+
* Generic function to get all the tools
|
|
629
|
+
* @param query - Query parameters for the tools
|
|
630
|
+
* @returns {Promise<ReturnType<TToolset["getTools">} Promise with list/records of tools
|
|
631
|
+
*/
|
|
632
|
+
getTools(query?: ToolListParams$1): Promise<ReturnType<TToolset["getTools"]>>;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* This is a default toolset implementation for Composio.
|
|
637
|
+
* This class is used as a default toolset for Composio, if the user does not provide a toolset.
|
|
638
|
+
*
|
|
639
|
+
* This class shouldn't be used directly or to be extended.
|
|
640
|
+
*/
|
|
641
|
+
interface CustomTool {
|
|
642
|
+
name: string;
|
|
643
|
+
}
|
|
644
|
+
declare class ComposioToolset extends BaseComposioToolset<Array<CustomTool>, CustomTool> {
|
|
645
|
+
readonly FILE_NAME: string;
|
|
646
|
+
_wrapTool: (tool: Tool) => CustomTool;
|
|
647
|
+
getTools(params?: ToolListParams): Promise<Array<CustomTool>>;
|
|
648
|
+
test(): Promise<void>;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
declare function jsonSchemaToModel(jsonSchema: Record<string, unknown>): z$1.ZodObject<Record<string, z$1.ZodTypeAny>>;
|
|
652
|
+
|
|
653
|
+
export { BaseComposioToolset, BaseTelemetryTransport, Composio, ComposioToolset, type InstrumentedInstance, OpenAIToolset, type Tool, type ToolListParams, ToolListParamsSchema, type Toolset, jsonSchemaToModel };
|