@composio/core 0.1.12-alpha.7 → 0.1.12-alpha.8
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 +20 -0
- package/dist/index.cjs +540 -142
- package/dist/index.d.cts +926 -124
- package/dist/index.d.ts +926 -124
- package/dist/index.js +540 -142
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ __export(index_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(index_exports);
|
|
45
45
|
|
|
46
46
|
// src/composio.ts
|
|
47
|
-
var
|
|
47
|
+
var import_client2 = __toESM(require("@composio/client"), 1);
|
|
48
48
|
|
|
49
49
|
// src/types/tool.types.ts
|
|
50
50
|
var import_zod = require("zod");
|
|
@@ -417,8 +417,8 @@ var CustomTools = class {
|
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
toolkit_slugs: [toolkitSlug],
|
|
421
|
+
user_ids: [metadata.userId]
|
|
422
422
|
});
|
|
423
423
|
if (!connectedAccounts.items.length) {
|
|
424
424
|
throw new ComposioConnectedAccountNotFoundError(
|
|
@@ -512,6 +512,7 @@ var ValidationError = class extends ComposioError {
|
|
|
512
512
|
cause: zodErrorInstance
|
|
513
513
|
});
|
|
514
514
|
this.zodError = zodErrorInstance;
|
|
515
|
+
this.name = "ValidationError";
|
|
515
516
|
}
|
|
516
517
|
};
|
|
517
518
|
|
|
@@ -536,9 +537,15 @@ var Tools = class {
|
|
|
536
537
|
this.getRawComposioTools = this.getRawComposioTools.bind(this);
|
|
537
538
|
}
|
|
538
539
|
/**
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
540
|
+
* Transforms tool data from snake_case API format to camelCase for internal SDK use.
|
|
541
|
+
*
|
|
542
|
+
* This method standardizes the property naming convention for tools retrieved from the Composio API,
|
|
543
|
+
* making them more consistent with JavaScript/TypeScript conventions.
|
|
544
|
+
*
|
|
545
|
+
* @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool object to transform
|
|
546
|
+
* @returns {Tool} The transformed tool with camelCase properties
|
|
547
|
+
*
|
|
548
|
+
* @private
|
|
542
549
|
*/
|
|
543
550
|
transformToolCases(tool) {
|
|
544
551
|
return ToolSchema.parse({
|
|
@@ -548,9 +555,15 @@ var Tools = class {
|
|
|
548
555
|
});
|
|
549
556
|
}
|
|
550
557
|
/**
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
558
|
+
* Transforms tool execution response from snake_case API format to camelCase.
|
|
559
|
+
*
|
|
560
|
+
* This method converts the response received from the Composio API to a standardized format
|
|
561
|
+
* with consistent property naming that follows JavaScript/TypeScript conventions.
|
|
562
|
+
*
|
|
563
|
+
* @param {ComposioToolExecuteResponse} response - The raw API response to transform
|
|
564
|
+
* @returns {ToolExecuteResponse} The transformed response with camelCase properties
|
|
565
|
+
*
|
|
566
|
+
* @private
|
|
554
567
|
*/
|
|
555
568
|
transformToolExecuteResponse(response) {
|
|
556
569
|
return ToolExecuteResponseSchema.parse({
|
|
@@ -635,9 +648,35 @@ var Tools = class {
|
|
|
635
648
|
return null;
|
|
636
649
|
}
|
|
637
650
|
/**
|
|
638
|
-
* Lists all tools available in the Composio SDK
|
|
639
|
-
*
|
|
640
|
-
*
|
|
651
|
+
* Lists all tools available in the Composio SDK including custom tools.
|
|
652
|
+
*
|
|
653
|
+
* This method fetches tools from the Composio API in raw format and combines them with
|
|
654
|
+
* any registered custom tools. The response can be filtered and modified as needed.
|
|
655
|
+
*
|
|
656
|
+
* @param {string} userId - The user ID for whom to fetch the tools
|
|
657
|
+
* @param {ToolListParams} [query={}] - Optional query parameters to filter the tools
|
|
658
|
+
* @param {TransformToolSchemaModifier} [modifier] - Optional function to transform tool schemas
|
|
659
|
+
* @returns {Promise<ToolList>} List of tools matching the query criteria
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* // Get all tools
|
|
664
|
+
* const tools = await composio.tools.getRawComposioTools('default');
|
|
665
|
+
*
|
|
666
|
+
* // Get tools with filters
|
|
667
|
+
* const githubTools = await composio.tools.getRawComposioTools('default', {
|
|
668
|
+
* toolkits: ['github'],
|
|
669
|
+
* important: true
|
|
670
|
+
* });
|
|
671
|
+
*
|
|
672
|
+
* // Get tools with schema transformation
|
|
673
|
+
* const tools = await composio.tools.getRawComposioTools('default', {},
|
|
674
|
+
* (toolSlug, toolkitSlug, tool) => {
|
|
675
|
+
* // Add custom properties to tool schema
|
|
676
|
+
* return {...tool, customProperty: 'value'};
|
|
677
|
+
* }
|
|
678
|
+
* );
|
|
679
|
+
* ```
|
|
641
680
|
*/
|
|
642
681
|
async getRawComposioTools(userId, query = {}, modifier) {
|
|
643
682
|
const queryParams = ToolListParamsSchema.safeParse(query);
|
|
@@ -704,11 +743,13 @@ var Tools = class {
|
|
|
704
743
|
return modifiedToool;
|
|
705
744
|
}
|
|
706
745
|
/**
|
|
707
|
-
* Get a tool
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
* @param
|
|
711
|
-
* @
|
|
746
|
+
* Get a tool or list of tools based on the provided arguments.
|
|
747
|
+
* This is an implementation method that handles both overloads.
|
|
748
|
+
*
|
|
749
|
+
* @param {string} userId - The user id to get the tool(s) for
|
|
750
|
+
* @param {ToolListParams | string} arg2 - Either a slug string or filters object
|
|
751
|
+
* @param {ProviderOptions<TProvider>} [options] - Optional provider options
|
|
752
|
+
* @returns {Promise<TToolCollection>} The tool collection
|
|
712
753
|
*/
|
|
713
754
|
async get(userId, arg2, options) {
|
|
714
755
|
const executeToolFn = this.createExecuteToolFn(userId, options);
|
|
@@ -818,13 +859,43 @@ var Tools = class {
|
|
|
818
859
|
return result;
|
|
819
860
|
}
|
|
820
861
|
/**
|
|
821
|
-
*
|
|
862
|
+
* Executes a given tool with the provided parameters.
|
|
822
863
|
*
|
|
823
|
-
* This method calls the Composio API to execute the tool and returns the response.
|
|
864
|
+
* This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
|
|
865
|
+
* It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
|
|
824
866
|
*
|
|
825
|
-
* @param {string} slug - The ID of the tool to be executed
|
|
867
|
+
* @param {string} slug - The slug/ID of the tool to be executed
|
|
826
868
|
* @param {ToolExecuteParams} body - The parameters to be passed to the tool
|
|
869
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
|
|
827
870
|
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
871
|
+
*
|
|
872
|
+
* @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
|
|
873
|
+
* @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
|
|
874
|
+
* @throws {ComposioToolExecutionError} If there is an error during tool execution
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```typescript
|
|
878
|
+
* // Execute a Composio API tool
|
|
879
|
+
* const result = await composio.tools.execute('HACKERNEWS_GET_USER', {
|
|
880
|
+
* userId: 'default',
|
|
881
|
+
* arguments: { userId: 'pg' }
|
|
882
|
+
* });
|
|
883
|
+
*
|
|
884
|
+
* // Execute with modifiers
|
|
885
|
+
* const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
|
|
886
|
+
* userId: 'default',
|
|
887
|
+
* arguments: { owner: 'composio', repo: 'sdk' }
|
|
888
|
+
* }, {
|
|
889
|
+
* beforeToolExecute: (toolSlug, toolkitSlug, params) => {
|
|
890
|
+
* // Modify params before execution
|
|
891
|
+
* return params;
|
|
892
|
+
* },
|
|
893
|
+
* afterToolExecute: (toolSlug, toolkitSlug, result) => {
|
|
894
|
+
* // Transform result after execution
|
|
895
|
+
* return result;
|
|
896
|
+
* }
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
828
899
|
*/
|
|
829
900
|
async execute(slug, body, modifiers) {
|
|
830
901
|
if (!this.customTools) {
|
|
@@ -881,9 +952,39 @@ var Tools = class {
|
|
|
881
952
|
return this.client.tools.proxy(body);
|
|
882
953
|
}
|
|
883
954
|
/**
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
*
|
|
955
|
+
* Creates a custom tool that can be used within the Composio SDK.
|
|
956
|
+
*
|
|
957
|
+
* Custom tools allow you to extend the functionality of Composio with your own implementations
|
|
958
|
+
* while keeping a consistent interface for both built-in and custom tools.
|
|
959
|
+
*
|
|
960
|
+
* @param {CustomToolOptions} body - The configuration for the custom tool
|
|
961
|
+
* @returns {Promise<Tool>} The created custom tool
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* ```typescript
|
|
965
|
+
* const customTool = await composio.tools.createCustomTool({
|
|
966
|
+
* name: 'My Custom Tool',
|
|
967
|
+
* description: 'A custom tool that does something specific',
|
|
968
|
+
* slug: 'MY_CUSTOM_TOOL',
|
|
969
|
+
* inputParameters: {
|
|
970
|
+
* param1: {
|
|
971
|
+
* type: 'string',
|
|
972
|
+
* description: 'First parameter',
|
|
973
|
+
* required: true
|
|
974
|
+
* }
|
|
975
|
+
* },
|
|
976
|
+
* outputParameters: {
|
|
977
|
+
* result: {
|
|
978
|
+
* type: 'string',
|
|
979
|
+
* description: 'The result of the operation'
|
|
980
|
+
* }
|
|
981
|
+
* },
|
|
982
|
+
* handler: async (params, context) => {
|
|
983
|
+
* // Custom logic here
|
|
984
|
+
* return { data: { result: 'Success!' } };
|
|
985
|
+
* }
|
|
986
|
+
* });
|
|
987
|
+
* ```
|
|
887
988
|
*/
|
|
888
989
|
async createCustomTool(body) {
|
|
889
990
|
return this.customTools.createTool(body);
|
|
@@ -1088,6 +1189,18 @@ var AuthConfigs = class {
|
|
|
1088
1189
|
getClient() {
|
|
1089
1190
|
return this.client;
|
|
1090
1191
|
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Transforms an auth config response from API format to SDK format.
|
|
1194
|
+
*
|
|
1195
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1196
|
+
* the data structure to match the SDK's standardized format for auth configurations.
|
|
1197
|
+
*
|
|
1198
|
+
* @param {ComposioAuthConfigRetrieveResponse} authConfig - The raw API response to transform
|
|
1199
|
+
* @returns {AuthConfigRetrieveResponse} The transformed auth config data
|
|
1200
|
+
* @throws {ValidationError} If the response fails validation against the expected schema
|
|
1201
|
+
*
|
|
1202
|
+
* @private
|
|
1203
|
+
*/
|
|
1091
1204
|
parseAuthConfigRetrieveResponse(authConfig) {
|
|
1092
1205
|
const result = AuthConfigRetrieveResponseSchema.safeParse({
|
|
1093
1206
|
id: authConfig.id,
|
|
@@ -1113,10 +1226,30 @@ var AuthConfigs = class {
|
|
|
1113
1226
|
return result.data;
|
|
1114
1227
|
}
|
|
1115
1228
|
/**
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1229
|
+
* Lists authentication configurations based on provided filter criteria.
|
|
1230
|
+
*
|
|
1231
|
+
* This method retrieves auth configs from the Composio API, transforms them to the SDK format,
|
|
1232
|
+
* and supports filtering by various parameters.
|
|
1233
|
+
*
|
|
1234
|
+
* @param {AuthConfigListParams} [query] - Optional query parameters for filtering auth configs
|
|
1235
|
+
* @returns {Promise<AuthConfigListResponse>} A paginated list of auth configurations
|
|
1236
|
+
* @throws {ValidationError} If the query parameters or response fail validation
|
|
1237
|
+
*
|
|
1238
|
+
* @example
|
|
1239
|
+
* ```typescript
|
|
1240
|
+
* // List all auth configs
|
|
1241
|
+
* const allConfigs = await composio.authConfigs.list();
|
|
1242
|
+
*
|
|
1243
|
+
* // List auth configs for a specific toolkit
|
|
1244
|
+
* const githubConfigs = await composio.authConfigs.list({
|
|
1245
|
+
* toolkitSlug: 'github'
|
|
1246
|
+
* });
|
|
1247
|
+
*
|
|
1248
|
+
* // List Composio-managed auth configs
|
|
1249
|
+
* const managedConfigs = await composio.authConfigs.list({
|
|
1250
|
+
* isComposioManaged: true
|
|
1251
|
+
* });
|
|
1252
|
+
* ```
|
|
1120
1253
|
*/
|
|
1121
1254
|
async list(query) {
|
|
1122
1255
|
const parsedQuery = query ? AuthConfigListParamsSchema.parse(query) : void 0;
|
|
@@ -1177,21 +1310,57 @@ var AuthConfigs = class {
|
|
|
1177
1310
|
return parsedResult.data;
|
|
1178
1311
|
}
|
|
1179
1312
|
/**
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1313
|
+
* Retrieves a specific authentication configuration by its ID.
|
|
1314
|
+
*
|
|
1315
|
+
* This method fetches detailed information about a single auth config
|
|
1316
|
+
* and transforms the response to the SDK's standardized format.
|
|
1317
|
+
*
|
|
1318
|
+
* @param {string} nanoid - The unique identifier of the auth config to retrieve
|
|
1319
|
+
* @returns {Promise<AuthConfigRetrieveResponse>} The auth config details
|
|
1320
|
+
* @throws {Error} If the auth config cannot be found or an API error occurs
|
|
1321
|
+
* @throws {ValidationError} If the response fails validation
|
|
1322
|
+
*
|
|
1323
|
+
* @example
|
|
1324
|
+
* ```typescript
|
|
1325
|
+
* // Get an auth config by ID
|
|
1326
|
+
* const authConfig = await composio.authConfigs.get('auth_abc123');
|
|
1327
|
+
* console.log(authConfig.name); // e.g., 'GitHub Auth'
|
|
1328
|
+
* console.log(authConfig.toolkit.slug); // e.g., 'github'
|
|
1329
|
+
* ```
|
|
1184
1330
|
*/
|
|
1185
1331
|
async get(nanoid) {
|
|
1186
1332
|
const result = await this.client.authConfigs.retrieve(nanoid);
|
|
1187
1333
|
return this.parseAuthConfigRetrieveResponse(result);
|
|
1188
1334
|
}
|
|
1189
1335
|
/**
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1194
|
-
*
|
|
1336
|
+
* Updates an existing authentication configuration.
|
|
1337
|
+
*
|
|
1338
|
+
* This method allows you to modify properties of an auth config such as credentials,
|
|
1339
|
+
* scopes, or tool restrictions. The update type (custom or default) determines which
|
|
1340
|
+
* fields can be updated.
|
|
1341
|
+
*
|
|
1342
|
+
* @param {string} nanoid - The unique identifier of the auth config to update
|
|
1343
|
+
* @param {AuthConfigUpdateParams} data - The data to update, which can be either custom or default type
|
|
1344
|
+
* @returns {Promise<AuthConfigUpdateResponse>} The updated auth config
|
|
1345
|
+
* @throws {ValidationError} If the update parameters are invalid
|
|
1346
|
+
* @throws {Error} If the auth config cannot be found or updated
|
|
1347
|
+
*
|
|
1348
|
+
* @example
|
|
1349
|
+
* ```typescript
|
|
1350
|
+
* // Update a custom auth config with new credentials
|
|
1351
|
+
* const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
1352
|
+
* type: 'custom',
|
|
1353
|
+
* credentials: {
|
|
1354
|
+
* apiKey: 'new-api-key-value'
|
|
1355
|
+
* }
|
|
1356
|
+
* });
|
|
1357
|
+
*
|
|
1358
|
+
* // Update a default auth config with new scopes
|
|
1359
|
+
* const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
1360
|
+
* type: 'default',
|
|
1361
|
+
* scopes: ['read:user', 'repo']
|
|
1362
|
+
* });
|
|
1363
|
+
* ```
|
|
1195
1364
|
*/
|
|
1196
1365
|
async update(nanoid, data) {
|
|
1197
1366
|
const parsedData = AuthConfigUpdateParamsSchema.safeParse(data);
|
|
@@ -1212,38 +1381,85 @@ var AuthConfigs = class {
|
|
|
1212
1381
|
);
|
|
1213
1382
|
}
|
|
1214
1383
|
/**
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1384
|
+
* Deletes an authentication configuration.
|
|
1385
|
+
*
|
|
1386
|
+
* This method permanently removes an auth config from the Composio platform.
|
|
1387
|
+
* This action cannot be undone and will prevent any connected accounts that use
|
|
1388
|
+
* this auth config from functioning.
|
|
1389
|
+
*
|
|
1390
|
+
* @param {string} nanoid - The unique identifier of the auth config to delete
|
|
1391
|
+
* @returns {Promise<AuthConfigDeleteResponse>} The deletion response
|
|
1392
|
+
* @throws {Error} If the auth config doesn't exist or cannot be deleted
|
|
1393
|
+
*
|
|
1394
|
+
* @example
|
|
1395
|
+
* ```typescript
|
|
1396
|
+
* // Delete an auth config
|
|
1397
|
+
* await composio.authConfigs.delete('auth_abc123');
|
|
1398
|
+
* ```
|
|
1219
1399
|
*/
|
|
1220
1400
|
async delete(nanoid) {
|
|
1221
1401
|
return this.client.authConfigs.delete(nanoid);
|
|
1222
1402
|
}
|
|
1223
1403
|
/**
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1404
|
+
* Updates the status of an authentication configuration.
|
|
1405
|
+
*
|
|
1406
|
+
* This method allows you to enable or disable an auth config. When disabled,
|
|
1407
|
+
* the auth config cannot be used to create new connected accounts or authenticate
|
|
1408
|
+
* with third-party services.
|
|
1409
|
+
*
|
|
1410
|
+
* @param {string} status - The status to set ('ENABLED' or 'DISABLED')
|
|
1411
|
+
* @param {string} nanoid - The unique identifier of the auth config
|
|
1412
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
1413
|
+
* @throws {Error} If the auth config cannot be found or the status cannot be updated
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* ```typescript
|
|
1417
|
+
* // Disable an auth config
|
|
1418
|
+
* await composio.authConfigs.updateStatus('DISABLED', 'auth_abc123');
|
|
1419
|
+
*
|
|
1420
|
+
* // Enable an auth config
|
|
1421
|
+
* await composio.authConfigs.updateStatus('ENABLED', 'auth_abc123');
|
|
1422
|
+
* ```
|
|
1229
1423
|
*/
|
|
1230
1424
|
async updateStatus(status, nanoid) {
|
|
1231
1425
|
return this.client.authConfigs.updateStatus(status, { nanoid });
|
|
1232
1426
|
}
|
|
1233
1427
|
/**
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1428
|
+
* Enables an authentication configuration.
|
|
1429
|
+
*
|
|
1430
|
+
* This is a convenience method that calls updateStatus with 'ENABLED'.
|
|
1431
|
+
* When enabled, the auth config can be used to create new connected accounts
|
|
1432
|
+
* and authenticate with third-party services.
|
|
1433
|
+
*
|
|
1434
|
+
* @param {string} nanoid - The unique identifier of the auth config to enable
|
|
1435
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
1436
|
+
* @throws {Error} If the auth config cannot be found or enabled
|
|
1437
|
+
*
|
|
1438
|
+
* @example
|
|
1439
|
+
* ```typescript
|
|
1440
|
+
* // Enable an auth config
|
|
1441
|
+
* await composio.authConfigs.enable('auth_abc123');
|
|
1442
|
+
* ```
|
|
1238
1443
|
*/
|
|
1239
1444
|
async enable(nanoid) {
|
|
1240
1445
|
return this.client.authConfigs.updateStatus("ENABLED", { nanoid });
|
|
1241
1446
|
}
|
|
1242
1447
|
/**
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1448
|
+
* Disables an authentication configuration.
|
|
1449
|
+
*
|
|
1450
|
+
* This is a convenience method that calls updateStatus with 'DISABLED'.
|
|
1451
|
+
* When disabled, the auth config cannot be used to create new connected accounts
|
|
1452
|
+
* or authenticate with third-party services, but existing connections may continue to work.
|
|
1453
|
+
*
|
|
1454
|
+
* @param {string} nanoid - The unique identifier of the auth config to disable
|
|
1455
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
1456
|
+
* @throws {Error} If the auth config cannot be found or disabled
|
|
1457
|
+
*
|
|
1458
|
+
* @example
|
|
1459
|
+
* ```typescript
|
|
1460
|
+
* // Disable an auth config
|
|
1461
|
+
* await composio.authConfigs.disable('auth_abc123');
|
|
1462
|
+
* ```
|
|
1247
1463
|
*/
|
|
1248
1464
|
async disable(nanoid) {
|
|
1249
1465
|
return this.client.authConfigs.updateStatus("DISABLED", { nanoid });
|
|
@@ -1357,7 +1573,7 @@ var ConnectedAccountRetrieveResponseSchema = import_zod5.z.object({
|
|
|
1357
1573
|
authConfig: ConnectedAccountAuthConfigSchema,
|
|
1358
1574
|
userId: import_zod5.z.string(),
|
|
1359
1575
|
data: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()),
|
|
1360
|
-
params: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()),
|
|
1576
|
+
params: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()).optional(),
|
|
1361
1577
|
status: ConnectedAccountStatusSchema,
|
|
1362
1578
|
statusReason: import_zod5.z.string().nullable(),
|
|
1363
1579
|
toolkit: import_zod5.z.object({
|
|
@@ -1368,8 +1584,24 @@ var ConnectedAccountRetrieveResponseSchema = import_zod5.z.object({
|
|
|
1368
1584
|
createdAt: import_zod5.z.string(),
|
|
1369
1585
|
updatedAt: import_zod5.z.string()
|
|
1370
1586
|
});
|
|
1587
|
+
var ConnectedAccountListParamsSchema = import_zod5.z.object({
|
|
1588
|
+
authConfigIds: import_zod5.z.array(import_zod5.z.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
1589
|
+
cursor: import_zod5.z.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
|
|
1590
|
+
labels: import_zod5.z.array(import_zod5.z.string()).nullable().optional().describe("The labels of the connected accounts"),
|
|
1591
|
+
limit: import_zod5.z.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
1592
|
+
orderBy: import_zod5.z.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
1593
|
+
statuses: import_zod5.z.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
1594
|
+
toolkitSlugs: import_zod5.z.array(import_zod5.z.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
1595
|
+
userIds: import_zod5.z.array(import_zod5.z.string()).nullable().optional().describe("The user ids of the connected accounts")
|
|
1596
|
+
});
|
|
1597
|
+
var ConnectedAccountListResponseSchema = import_zod5.z.object({
|
|
1598
|
+
items: import_zod5.z.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
1599
|
+
nextCursor: import_zod5.z.string().nullable().describe("The next cursor to paginate through the connected accounts"),
|
|
1600
|
+
totalPages: import_zod5.z.number().describe("The total number of pages of connected accounts")
|
|
1601
|
+
});
|
|
1371
1602
|
|
|
1372
1603
|
// src/models/ConnectionRequest.ts
|
|
1604
|
+
var import_client = __toESM(require("@composio/client"), 1);
|
|
1373
1605
|
var import_zod6 = require("zod");
|
|
1374
1606
|
|
|
1375
1607
|
// src/errors/ConnectionRequestError.ts
|
|
@@ -1409,9 +1641,16 @@ var ConnectionRequest = class {
|
|
|
1409
1641
|
this.redirectUrl = redirectUrl;
|
|
1410
1642
|
}
|
|
1411
1643
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1644
|
+
* Transforms the raw connected account response from the Composio API to the SDK format.
|
|
1645
|
+
*
|
|
1646
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1647
|
+
* the data structure to match the SDK's standardized format.
|
|
1648
|
+
*
|
|
1649
|
+
* @param {OriginalConnectedAccountResponse} response - The raw API response to transform
|
|
1650
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
|
|
1651
|
+
* @throws {ZodError} If the response fails validation against the expected schema
|
|
1652
|
+
*
|
|
1653
|
+
* @private
|
|
1415
1654
|
*/
|
|
1416
1655
|
async transformResponse(response) {
|
|
1417
1656
|
try {
|
|
@@ -1441,15 +1680,48 @@ var ConnectionRequest = class {
|
|
|
1441
1680
|
}
|
|
1442
1681
|
}
|
|
1443
1682
|
/**
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1683
|
+
* Waits for the connection request to complete and become active.
|
|
1684
|
+
*
|
|
1685
|
+
* This method continuously polls the Composio API to check the status of the connection request
|
|
1686
|
+
* until it either becomes active, enters a terminal error state, or times out.
|
|
1687
|
+
*
|
|
1688
|
+
* @param {number} [timeout=60000] - Maximum time to wait in milliseconds before timing out (default: 60 seconds)
|
|
1689
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The final connected account response when successful
|
|
1690
|
+
* @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
|
|
1691
|
+
* @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
|
|
1692
|
+
* @throws {ConnectionRequestTimeoutError} If the connection request does not complete within the timeout period
|
|
1693
|
+
*
|
|
1694
|
+
* @example
|
|
1695
|
+
* ```typescript
|
|
1696
|
+
* // Wait for connection with default timeout (60 seconds)
|
|
1697
|
+
* try {
|
|
1698
|
+
* const connection = await connectionRequest.waitForConnection();
|
|
1699
|
+
* console.log('Connection established:', connection.id);
|
|
1700
|
+
* } catch (error) {
|
|
1701
|
+
* console.error('Connection failed:', error.message);
|
|
1702
|
+
* }
|
|
1703
|
+
*
|
|
1704
|
+
* // Wait for connection with custom timeout (2 minutes)
|
|
1705
|
+
* const connection = await connectionRequest.waitForConnection(120000);
|
|
1706
|
+
* ```
|
|
1448
1707
|
*/
|
|
1449
1708
|
async waitForConnection(timeout = 6e4) {
|
|
1450
|
-
|
|
1709
|
+
try {
|
|
1451
1710
|
const response = await this.client.connectedAccounts.retrieve(this.id);
|
|
1452
|
-
|
|
1711
|
+
if (response.status === ConnectedAccountStatuses.ACTIVE) {
|
|
1712
|
+
return this.transformResponse(response);
|
|
1713
|
+
}
|
|
1714
|
+
} catch (error) {
|
|
1715
|
+
if (error instanceof import_client.default.NotFoundError) {
|
|
1716
|
+
throw new ComposioConnectedAccountNotFoundError(
|
|
1717
|
+
`Connected account with id ${this.id} not found`,
|
|
1718
|
+
{
|
|
1719
|
+
connectedAccountId: this.id
|
|
1720
|
+
}
|
|
1721
|
+
);
|
|
1722
|
+
} else {
|
|
1723
|
+
throw error;
|
|
1724
|
+
}
|
|
1453
1725
|
}
|
|
1454
1726
|
const terminalErrorStates = [
|
|
1455
1727
|
ConnectedAccountStatuses.FAILED,
|
|
@@ -1501,14 +1773,95 @@ var ConnectedAccounts = class {
|
|
|
1501
1773
|
constructor(client) {
|
|
1502
1774
|
this.client = client;
|
|
1503
1775
|
}
|
|
1776
|
+
transformConnectedAccountRetrieveResponse(response) {
|
|
1777
|
+
const result = ConnectedAccountRetrieveResponseSchema.safeParse({
|
|
1778
|
+
...response,
|
|
1779
|
+
userId: response.user_id,
|
|
1780
|
+
// Add the missing userId property
|
|
1781
|
+
authConfig: {
|
|
1782
|
+
...response.auth_config,
|
|
1783
|
+
authScheme: response.auth_config.auth_scheme,
|
|
1784
|
+
isComposioManaged: response.auth_config.is_composio_managed,
|
|
1785
|
+
isDisabled: response.auth_config.is_disabled
|
|
1786
|
+
},
|
|
1787
|
+
statusReason: response.status_reason,
|
|
1788
|
+
isDisabled: response.is_disabled,
|
|
1789
|
+
createdAt: response.created_at,
|
|
1790
|
+
updatedAt: response.updated_at,
|
|
1791
|
+
testRequestEndpoint: response.test_request_endpoint
|
|
1792
|
+
});
|
|
1793
|
+
if (!result.success) {
|
|
1794
|
+
throw new ValidationError(result.error);
|
|
1795
|
+
}
|
|
1796
|
+
return result.data;
|
|
1797
|
+
}
|
|
1504
1798
|
/**
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1799
|
+
* Lists all connected accounts based on provided filter criteria.
|
|
1800
|
+
*
|
|
1801
|
+
* This method retrieves connected accounts from the Composio API with optional filtering.
|
|
1802
|
+
*
|
|
1803
|
+
* @param {ConnectedAccountListParams} [query] - Optional query parameters for filtering connected accounts
|
|
1804
|
+
* @returns {Promise<ConnectedAccountListResponse>} A paginated list of connected accounts
|
|
1805
|
+
* @throws {ValidationError} If the query fails validation against the expected schema
|
|
1806
|
+
* @example
|
|
1807
|
+
* ```typescript
|
|
1808
|
+
* // List all connected accounts
|
|
1809
|
+
* const allAccounts = await composio.connectedAccounts.list();
|
|
1810
|
+
*
|
|
1811
|
+
* // List accounts for a specific user
|
|
1812
|
+
* const userAccounts = await composio.connectedAccounts.list({
|
|
1813
|
+
* userIds: ['user123']
|
|
1814
|
+
* });
|
|
1815
|
+
*
|
|
1816
|
+
* // List accounts for a specific toolkit
|
|
1817
|
+
* const githubAccounts = await composio.connectedAccounts.list({
|
|
1818
|
+
* toolkitSlugs: ['github']
|
|
1819
|
+
* });
|
|
1820
|
+
* ```
|
|
1509
1821
|
*/
|
|
1510
1822
|
async list(query) {
|
|
1511
|
-
|
|
1823
|
+
let rawQuery = void 0;
|
|
1824
|
+
if (query) {
|
|
1825
|
+
const parsedQuery = ConnectedAccountListParamsSchema.safeParse(query);
|
|
1826
|
+
if (!parsedQuery.success) {
|
|
1827
|
+
throw new ValidationError(parsedQuery.error);
|
|
1828
|
+
}
|
|
1829
|
+
rawQuery = {
|
|
1830
|
+
auth_config_ids: parsedQuery.data.authConfigIds,
|
|
1831
|
+
cursor: parsedQuery.data.cursor,
|
|
1832
|
+
labels: parsedQuery.data.labels,
|
|
1833
|
+
limit: parsedQuery.data.limit,
|
|
1834
|
+
order_by: parsedQuery.data.orderBy,
|
|
1835
|
+
statuses: parsedQuery.data.statuses,
|
|
1836
|
+
toolkit_slugs: parsedQuery.data.toolkitSlugs,
|
|
1837
|
+
user_ids: parsedQuery.data.userIds
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
const result = await this.client.connectedAccounts.list(rawQuery);
|
|
1841
|
+
const parsedResponse = ConnectedAccountListResponseSchema.safeParse({
|
|
1842
|
+
items: result.items.map(this.transformConnectedAccountRetrieveResponse),
|
|
1843
|
+
nextCursor: result.next_cursor,
|
|
1844
|
+
totalPages: result.total_pages
|
|
1845
|
+
});
|
|
1846
|
+
if (!parsedResponse.success) {
|
|
1847
|
+
throw new ValidationError(parsedResponse.error);
|
|
1848
|
+
}
|
|
1849
|
+
return parsedResponse.data;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Transforms connected account data from API format to SDK format.
|
|
1853
|
+
*
|
|
1854
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1855
|
+
* the data structure to match the SDK's standardized format for connected accounts.
|
|
1856
|
+
*
|
|
1857
|
+
* @param {ConnectedAccountRetrieveResponseRaw} response - The raw API response to transform
|
|
1858
|
+
* @returns {ConnectedAccountRetrieveResponse} The transformed connected account data
|
|
1859
|
+
* @throws {ValidationError} If the response fails validation against the expected schema
|
|
1860
|
+
*
|
|
1861
|
+
* @private
|
|
1862
|
+
*/
|
|
1863
|
+
transformConnectedAccountResponse(response) {
|
|
1864
|
+
return this.transformConnectedAccountRetrieveResponse(response);
|
|
1512
1865
|
}
|
|
1513
1866
|
/**
|
|
1514
1867
|
* Compound function to create a new connected account.
|
|
@@ -1541,69 +1894,88 @@ var ConnectedAccounts = class {
|
|
|
1541
1894
|
});
|
|
1542
1895
|
return new ConnectionRequest(this.client, response.id, response.status, response.redirect_uri);
|
|
1543
1896
|
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Waits for a connection request to complete and become active.
|
|
1899
|
+
*
|
|
1900
|
+
* This method continuously polls the Composio API to check the status of a connection
|
|
1901
|
+
* until it either becomes active, enters a terminal error state, or times out.
|
|
1902
|
+
*
|
|
1903
|
+
* @param {string} connectedAccountId - The ID of the connected account to wait for
|
|
1904
|
+
* @param {number} [timeout=60000] - Maximum time to wait in milliseconds (default: 60 seconds)
|
|
1905
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The finalized connected account data
|
|
1906
|
+
* @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
|
|
1907
|
+
* @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
|
|
1908
|
+
* @throws {ConnectionRequestTimeoutError} If the connection does not complete within the timeout period
|
|
1909
|
+
*
|
|
1910
|
+
* @example
|
|
1911
|
+
* ```typescript
|
|
1912
|
+
* // Wait for a connection to complete with default timeout
|
|
1913
|
+
* const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc');
|
|
1914
|
+
*
|
|
1915
|
+
* // Wait with a custom timeout of 2 minutes
|
|
1916
|
+
* const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc', 120000);
|
|
1917
|
+
* ```
|
|
1918
|
+
*/
|
|
1544
1919
|
async waitForConnection(connectedAccountId, timeout = 6e4) {
|
|
1545
|
-
|
|
1546
|
-
try {
|
|
1547
|
-
connectedAccount = await this.get(connectedAccountId);
|
|
1548
|
-
} catch (error) {
|
|
1549
|
-
logger_default.error(error);
|
|
1550
|
-
throw new ComposioConnectedAccountNotFoundError(
|
|
1551
|
-
`Unable to retrieve connected account with Id: ${connectedAccountId}`,
|
|
1552
|
-
{
|
|
1553
|
-
connectedAccountId
|
|
1554
|
-
}
|
|
1555
|
-
);
|
|
1556
|
-
}
|
|
1557
|
-
const connectionRequest2 = new ConnectionRequest(
|
|
1558
|
-
this.client,
|
|
1559
|
-
connectedAccountId,
|
|
1560
|
-
connectedAccount.status
|
|
1561
|
-
);
|
|
1920
|
+
const connectionRequest2 = new ConnectionRequest(this.client, connectedAccountId);
|
|
1562
1921
|
return connectionRequest2.waitForConnection(timeout);
|
|
1563
1922
|
}
|
|
1564
1923
|
/**
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1924
|
+
* Retrieves a specific connected account by its ID.
|
|
1925
|
+
*
|
|
1926
|
+
* This method fetches detailed information about a single connected account
|
|
1927
|
+
* and transforms the response to the SDK's standardized format.
|
|
1928
|
+
*
|
|
1929
|
+
* @param {string} nanoid - The unique identifier of the connected account
|
|
1930
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The connected account details
|
|
1931
|
+
* @throws {Error} If the connected account cannot be found or an API error occurs
|
|
1932
|
+
*
|
|
1933
|
+
* @example
|
|
1934
|
+
* ```typescript
|
|
1935
|
+
* // Get a connected account by ID
|
|
1936
|
+
* const account = await composio.connectedAccounts.get('conn_abc123');
|
|
1937
|
+
* console.log(account.status); // e.g., 'ACTIVE'
|
|
1938
|
+
* console.log(account.toolkit.slug); // e.g., 'github'
|
|
1939
|
+
* ```
|
|
1569
1940
|
*/
|
|
1570
1941
|
async get(nanoid) {
|
|
1571
1942
|
const response = await this.client.connectedAccounts.retrieve(nanoid);
|
|
1572
|
-
|
|
1573
|
-
...response,
|
|
1574
|
-
userId: response.user_id,
|
|
1575
|
-
// Add the missing userId property
|
|
1576
|
-
authConfig: {
|
|
1577
|
-
...response.auth_config,
|
|
1578
|
-
authScheme: response.auth_config.auth_scheme,
|
|
1579
|
-
isComposioManaged: response.auth_config.is_composio_managed,
|
|
1580
|
-
isDisabled: response.auth_config.is_disabled
|
|
1581
|
-
},
|
|
1582
|
-
statusReason: response.status_reason,
|
|
1583
|
-
isDisabled: response.is_disabled,
|
|
1584
|
-
createdAt: response.created_at,
|
|
1585
|
-
updatedAt: response.updated_at,
|
|
1586
|
-
testRequestEndpoint: response.test_request_endpoint
|
|
1587
|
-
});
|
|
1588
|
-
if (parsedResult.error) {
|
|
1589
|
-
throw new ValidationError(parsedResult.error);
|
|
1590
|
-
}
|
|
1591
|
-
return parsedResult.data;
|
|
1943
|
+
return this.transformConnectedAccountResponse(response);
|
|
1592
1944
|
}
|
|
1593
1945
|
/**
|
|
1594
|
-
*
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1946
|
+
* Deletes a connected account.
|
|
1947
|
+
*
|
|
1948
|
+
* This method permanently removes a connected account from the Composio platform.
|
|
1949
|
+
* This action cannot be undone and will revoke any access tokens associated with the account.
|
|
1950
|
+
*
|
|
1951
|
+
* @param {string} nanoid - The unique identifier of the connected account to delete
|
|
1952
|
+
* @returns {Promise<ConnectedAccountDeleteResponse>} The deletion response
|
|
1953
|
+
* @throws {Error} If the account doesn't exist or cannot be deleted
|
|
1954
|
+
*
|
|
1955
|
+
* @example
|
|
1956
|
+
* ```typescript
|
|
1957
|
+
* // Delete a connected account
|
|
1958
|
+
* await composio.connectedAccounts.delete('conn_abc123');
|
|
1959
|
+
* ```
|
|
1598
1960
|
*/
|
|
1599
1961
|
async delete(nanoid) {
|
|
1600
1962
|
return this.client.connectedAccounts.delete(nanoid);
|
|
1601
1963
|
}
|
|
1602
1964
|
/**
|
|
1603
|
-
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
*
|
|
1965
|
+
* Refreshes a connected account's authentication credentials.
|
|
1966
|
+
*
|
|
1967
|
+
* This method attempts to refresh OAuth tokens or other credentials associated with
|
|
1968
|
+
* the connected account. This is useful when a token has expired or is about to expire.
|
|
1969
|
+
*
|
|
1970
|
+
* @param {string} nanoid - The unique identifier of the connected account to refresh
|
|
1971
|
+
* @returns {Promise<ConnectedAccountRefreshResponse>} The response containing the refreshed account details
|
|
1972
|
+
* @throws {Error} If the account doesn't exist or credentials cannot be refreshed
|
|
1973
|
+
*
|
|
1974
|
+
* @example
|
|
1975
|
+
* ```typescript
|
|
1976
|
+
* // Refresh a connected account's credentials
|
|
1977
|
+
* const refreshedAccount = await composio.connectedAccounts.refresh('conn_abc123');
|
|
1978
|
+
* ```
|
|
1607
1979
|
*/
|
|
1608
1980
|
async refresh(nanoid) {
|
|
1609
1981
|
return this.client.connectedAccounts.refresh(nanoid);
|
|
@@ -1646,9 +2018,15 @@ var Toolkits = class {
|
|
|
1646
2018
|
this.authorize = this.authorize.bind(this);
|
|
1647
2019
|
}
|
|
1648
2020
|
/**
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
2021
|
+
* Retrieves a list of toolkits based on the provided query parameters.
|
|
2022
|
+
*
|
|
2023
|
+
* This method fetches toolkits from the Composio API and transforms the response
|
|
2024
|
+
* from snake_case to camelCase format for consistency with JavaScript/TypeScript conventions.
|
|
2025
|
+
*
|
|
2026
|
+
* @param {ToolkitListParams} query - The query parameters to filter toolkits
|
|
2027
|
+
* @returns {Promise<ToolKitListResponse>} The transformed list of toolkits
|
|
2028
|
+
*
|
|
2029
|
+
* @private
|
|
1652
2030
|
*/
|
|
1653
2031
|
async getToolkits(query) {
|
|
1654
2032
|
const parsedQuery = ToolkitsListParamsSchema.parse(query);
|
|
@@ -1677,11 +2055,29 @@ var Toolkits = class {
|
|
|
1677
2055
|
return parsedResult;
|
|
1678
2056
|
}
|
|
1679
2057
|
/**
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
* @param
|
|
1683
|
-
* @
|
|
1684
|
-
|
|
2058
|
+
* Implementation method that handles both overloads for retrieving toolkits.
|
|
2059
|
+
*
|
|
2060
|
+
* @param {string | ToolkitListParams} arg - Either a toolkit slug or query parameters
|
|
2061
|
+
* @returns {Promise<ToolkitRetrieveResponse | ToolKitListResponse>} The toolkit or list of toolkits
|
|
2062
|
+
*/
|
|
2063
|
+
async get(arg) {
|
|
2064
|
+
if (typeof arg === "string") {
|
|
2065
|
+
return this.getToolkitBySlug(arg);
|
|
2066
|
+
}
|
|
2067
|
+
return this.getToolkits(arg);
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Retrieves a specific toolkit by its slug identifier.
|
|
2071
|
+
*
|
|
2072
|
+
* This method fetches a single toolkit from the Composio API and transforms
|
|
2073
|
+
* the response to use camelCase property naming consistent with JavaScript/TypeScript conventions.
|
|
2074
|
+
*
|
|
2075
|
+
* @param {string} slug - The unique slug identifier of the toolkit to retrieve
|
|
2076
|
+
* @returns {Promise<ToolkitRetrieveResponse>} The transformed toolkit object
|
|
2077
|
+
* @throws {ValidationError} If the response cannot be properly parsed
|
|
2078
|
+
* @throws {ComposioToolNotFoundError} If no toolkit with the given slug exists
|
|
2079
|
+
*
|
|
2080
|
+
* @private
|
|
1685
2081
|
*/
|
|
1686
2082
|
async getToolkitBySlug(slug) {
|
|
1687
2083
|
try {
|
|
@@ -1722,21 +2118,19 @@ var Toolkits = class {
|
|
|
1722
2118
|
}
|
|
1723
2119
|
}
|
|
1724
2120
|
/**
|
|
1725
|
-
*
|
|
1726
|
-
* This method retrieves the toolkit from the Composio API.
|
|
1727
|
-
* @param arg - The ID of the toolkit to be retrieved or a list of parameters
|
|
1728
|
-
* @returns {Promise<ToolkitRetrieveResponse | ToolKitListResponse>} The toolkit object or a list of toolkits
|
|
1729
|
-
*/
|
|
1730
|
-
async get(arg) {
|
|
1731
|
-
if (typeof arg === "string") {
|
|
1732
|
-
return this.getToolkitBySlug(arg);
|
|
1733
|
-
}
|
|
1734
|
-
return this.getToolkits(arg);
|
|
1735
|
-
}
|
|
1736
|
-
/**
|
|
1737
|
-
* Fetches all categories available in the Composio SDK
|
|
2121
|
+
* Retrieves all toolkit categories available in the Composio SDK.
|
|
1738
2122
|
*
|
|
1739
|
-
*
|
|
2123
|
+
* This method fetches the complete list of categories from the Composio API
|
|
2124
|
+
* and transforms the response to use camelCase property naming.
|
|
2125
|
+
*
|
|
2126
|
+
* @returns {Promise<ToolkitRetrieveCategoriesResponse>} The list of toolkit categories
|
|
2127
|
+
*
|
|
2128
|
+
* @example
|
|
2129
|
+
* ```typescript
|
|
2130
|
+
* // Get all toolkit categories
|
|
2131
|
+
* const categories = await composio.toolkits.listCategories();
|
|
2132
|
+
* console.log(categories.items); // Array of category objects
|
|
2133
|
+
* ```
|
|
1740
2134
|
*/
|
|
1741
2135
|
async listCategories() {
|
|
1742
2136
|
const result = await this.client.toolkits.retrieveCategories();
|
|
@@ -1758,8 +2152,12 @@ var Toolkits = class {
|
|
|
1758
2152
|
* This method will create an auth config if one doesn't exist and initiate a connection request.
|
|
1759
2153
|
* @param {string} userId - The user id of the user to authorize
|
|
1760
2154
|
* @param {string} toolkitSlug - The slug of the toolkit to authorize
|
|
1761
|
-
* @param {string} authConfigId - The id of the auth config to use
|
|
1762
2155
|
* @returns {Promise<ConnectionRequest>} The connection request object
|
|
2156
|
+
*
|
|
2157
|
+
* @example
|
|
2158
|
+
* ```typescript
|
|
2159
|
+
* const connectionRequest = await composio.toolkits.authorize(userId, 'github');
|
|
2160
|
+
* ```
|
|
1763
2161
|
*/
|
|
1764
2162
|
async authorize(userId, toolkitSlug) {
|
|
1765
2163
|
const toolkit = await this.getToolkitBySlug(toolkitSlug);
|
|
@@ -2516,7 +2914,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
2516
2914
|
};
|
|
2517
2915
|
|
|
2518
2916
|
// package.json
|
|
2519
|
-
var version = "0.1.12-alpha.
|
|
2917
|
+
var version = "0.1.12-alpha.8";
|
|
2520
2918
|
|
|
2521
2919
|
// src/utils/uuid.ts
|
|
2522
2920
|
var import_uuid = require("uuid");
|
|
@@ -2566,7 +2964,7 @@ var Composio = class {
|
|
|
2566
2964
|
if (IS_DEVELOPMENT_OR_CI) {
|
|
2567
2965
|
logger_default.info(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
|
|
2568
2966
|
}
|
|
2569
|
-
this.client = new
|
|
2967
|
+
this.client = new import_client2.default({
|
|
2570
2968
|
apiKey: apiKeyParsed,
|
|
2571
2969
|
baseURL: baseURLParsed
|
|
2572
2970
|
});
|