@composio/core 0.1.12-alpha.14 → 0.1.12-alpha.16

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.js CHANGED
@@ -859,6 +859,262 @@ var TelemetryService = class {
859
859
  };
860
860
  var telemetry = new TelemetryService();
861
861
 
862
+ // src/types/connectedAccounts.types.ts
863
+ import { z as z2 } from "zod";
864
+ var ConnectedAccountStatuses = {
865
+ INITIALIZING: "INITIALIZING",
866
+ INITIATED: "INITIATED",
867
+ ACTIVE: "ACTIVE",
868
+ FAILED: "FAILED",
869
+ EXPIRED: "EXPIRED"
870
+ };
871
+ var ConnectedAccountStatusSchema = z2.enum([
872
+ ConnectedAccountStatuses.INITIALIZING,
873
+ ConnectedAccountStatuses.INITIATED,
874
+ ConnectedAccountStatuses.ACTIVE,
875
+ ConnectedAccountStatuses.FAILED,
876
+ ConnectedAccountStatuses.EXPIRED
877
+ ]);
878
+ var CreateConnectedAccountParamsSchema = z2.object({
879
+ authConfig: z2.object({
880
+ id: z2.string()
881
+ }),
882
+ connection: z2.object({
883
+ data: z2.record(z2.string(), z2.unknown()).optional(),
884
+ callbackUrl: z2.string().optional(),
885
+ userId: z2.string().optional()
886
+ })
887
+ });
888
+ var DefaultCreateConnectedAccountParamsSchema = z2.object({
889
+ auth_config: z2.object({
890
+ id: z2.string()
891
+ }),
892
+ connection: z2.object({
893
+ data: z2.record(z2.string(), z2.unknown()).optional(),
894
+ callback_url: z2.string().optional(),
895
+ user_id: z2.string().optional()
896
+ })
897
+ });
898
+ var CreateConnectedAccountOptionsSchema = z2.object({
899
+ callbackUrl: z2.string().optional(),
900
+ data: z2.record(z2.string(), z2.unknown()).optional()
901
+ });
902
+ var CreateConnectedAccountResponseSchema = z2.object({
903
+ id: z2.string(),
904
+ status: ConnectedAccountStatusSchema,
905
+ redirectUrl: z2.string().nullable()
906
+ });
907
+ var ConnectedAccountAuthSchemes = {
908
+ OAUTH2: "OAUTH2",
909
+ OAUTH1: "OAUTH1",
910
+ OAUTH1A: "OAUTH1A",
911
+ API_KEY: "API_KEY",
912
+ BASIC: "BASIC",
913
+ BILLCOM_AUTH: "BILLCOM_AUTH",
914
+ BEARER_TOKEN: "BEARER_TOKEN",
915
+ GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
916
+ NO_AUTH: "NO_AUTH",
917
+ BASIC_WITH_JWT: "BASIC_WITH_JWT",
918
+ COMPOSIO_LINK: "COMPOSIO_LINK",
919
+ CALCOM_AUTH: "CALCOM_AUTH",
920
+ SNOWFLAKE: "SNOWFLAKE"
921
+ };
922
+ var ConnectedAccountAuthSchemesSchema = z2.enum([
923
+ ConnectedAccountAuthSchemes.OAUTH2,
924
+ ConnectedAccountAuthSchemes.OAUTH1,
925
+ ConnectedAccountAuthSchemes.OAUTH1A,
926
+ ConnectedAccountAuthSchemes.API_KEY,
927
+ ConnectedAccountAuthSchemes.BASIC,
928
+ ConnectedAccountAuthSchemes.BILLCOM_AUTH,
929
+ ConnectedAccountAuthSchemes.BEARER_TOKEN,
930
+ ConnectedAccountAuthSchemes.GOOGLE_SERVICE_ACCOUNT,
931
+ ConnectedAccountAuthSchemes.NO_AUTH,
932
+ ConnectedAccountAuthSchemes.BASIC_WITH_JWT,
933
+ ConnectedAccountAuthSchemes.COMPOSIO_LINK,
934
+ ConnectedAccountAuthSchemes.CALCOM_AUTH,
935
+ ConnectedAccountAuthSchemes.SNOWFLAKE
936
+ ]);
937
+ var ConnectedAccountAuthConfigSchema = z2.object({
938
+ id: z2.string(),
939
+ authScheme: ConnectedAccountAuthSchemesSchema,
940
+ isComposioManaged: z2.boolean(),
941
+ isDisabled: z2.boolean()
942
+ });
943
+ var ConnectedAccountRetrieveResponseSchema = z2.object({
944
+ id: z2.string(),
945
+ authConfig: ConnectedAccountAuthConfigSchema,
946
+ userId: z2.string(),
947
+ data: z2.record(z2.string(), z2.unknown()),
948
+ params: z2.record(z2.string(), z2.unknown()).optional(),
949
+ status: ConnectedAccountStatusSchema,
950
+ statusReason: z2.string().nullable(),
951
+ toolkit: z2.object({
952
+ slug: z2.string()
953
+ }),
954
+ testRequestEndpoint: z2.string().optional(),
955
+ isDisabled: z2.boolean(),
956
+ createdAt: z2.string(),
957
+ updatedAt: z2.string()
958
+ });
959
+ var ConnectedAccountListParamsSchema = z2.object({
960
+ authConfigIds: z2.array(z2.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
961
+ cursor: z2.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
962
+ labels: z2.array(z2.string()).nullable().optional().describe("The labels of the connected accounts"),
963
+ limit: z2.number().nullable().optional().describe("The limit of the connected accounts to return"),
964
+ orderBy: z2.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
965
+ statuses: z2.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
966
+ toolkitSlugs: z2.array(z2.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
967
+ userIds: z2.array(z2.string()).nullable().optional().describe("The user ids of the connected accounts")
968
+ });
969
+ var ConnectedAccountListResponseSchema = z2.object({
970
+ items: z2.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
971
+ nextCursor: z2.string().nullable().describe("The next cursor to paginate through the connected accounts"),
972
+ totalPages: z2.number().describe("The total number of pages of connected accounts")
973
+ });
974
+
975
+ // src/errors/AuthConfigErrors.ts
976
+ var AuthConfigErrorCodes = {
977
+ AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
978
+ };
979
+ var ComposioAuthConfigNotFoundError = class extends ComposioError {
980
+ constructor(message = "Auth config not found", options = {}) {
981
+ super(message, {
982
+ ...options,
983
+ code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
984
+ possibleFixes: options.possibleFixes || [
985
+ "Check if the auth config exists",
986
+ "Check if the auth config id is correct",
987
+ "Check if the auth config is enabled"
988
+ ]
989
+ });
990
+ this.name = "ComposioAuthConfigNotFoundError";
991
+ }
992
+ };
993
+
994
+ // src/errors/ConnectionRequestErrors.ts
995
+ var ConnectionRequestErrorCodes = {
996
+ CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
997
+ CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
998
+ };
999
+ var ConnectionRequestTimeoutError = class extends ComposioError {
1000
+ constructor(message = "Connection request timed out", options = {}) {
1001
+ super(message, {
1002
+ ...options,
1003
+ code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
1004
+ });
1005
+ this.name = "ConnectionRequestTimeoutError";
1006
+ }
1007
+ };
1008
+ var ConnectionRequestFailedError = class extends ComposioError {
1009
+ constructor(message = "Connection request failed", options = {}) {
1010
+ super(message, {
1011
+ ...options,
1012
+ code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
1013
+ });
1014
+ this.name = "ConnectionRequestFailedError";
1015
+ }
1016
+ };
1017
+
1018
+ // src/errors/ToolkitErrors.ts
1019
+ var ToolkitErrorCodes = {
1020
+ TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND"
1021
+ };
1022
+ var ComposioToolkitNotFoundError = class extends ComposioError {
1023
+ constructor(message = "Toolkit not found", options = {}) {
1024
+ super(message, {
1025
+ ...options,
1026
+ code: "TOOLKIT_NOT_FOUND",
1027
+ possibleFixes: options.possibleFixes || [
1028
+ "Ensure the toolkit is correctly configured and the slug is valid"
1029
+ ]
1030
+ });
1031
+ this.name = "ComposioToolkitNotFoundError";
1032
+ }
1033
+ };
1034
+ var ComposioToolkitFetchError = class extends ComposioError {
1035
+ constructor(message = "Failed to fetch toolkit", options = {}) {
1036
+ super(message, {
1037
+ ...options,
1038
+ code: "TOOLKIT_FETCH_ERROR",
1039
+ possibleFixes: options.possibleFixes || [
1040
+ "Ensure the toolkit slug is valid",
1041
+ "Ensure you are using the correct API key",
1042
+ "Ensure you are using the correct API endpoint / Base URL and it is working"
1043
+ ]
1044
+ });
1045
+ this.name = "ComposioToolkitFetchError";
1046
+ }
1047
+ };
1048
+
1049
+ // src/errors/ValidationErrors.ts
1050
+ import { ZodError as ZodError2 } from "zod";
1051
+ var ValidationErrorCodes = {
1052
+ VALIDATION_ERROR: "VALIDATION_ERROR"
1053
+ };
1054
+ var ValidationError = class extends ComposioError {
1055
+ constructor(message = "Input validation failed", options = {}) {
1056
+ const { cause: providedZodError, ...restOptions } = options;
1057
+ let zodErrorInstance;
1058
+ if (providedZodError instanceof ZodError2) {
1059
+ zodErrorInstance = providedZodError;
1060
+ } else {
1061
+ zodErrorInstance = new ZodError2([
1062
+ {
1063
+ path: [],
1064
+ message: "Invalid input",
1065
+ code: "custom"
1066
+ }
1067
+ ]);
1068
+ }
1069
+ const issues = zodErrorInstance.issues.map(
1070
+ (issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`
1071
+ );
1072
+ super(message, {
1073
+ ...restOptions,
1074
+ code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
1075
+ possibleFixes: issues,
1076
+ cause: zodErrorInstance
1077
+ });
1078
+ this.name = "ValidationError";
1079
+ const userFriendlyMessage = this.generateUserFriendlyMessage();
1080
+ this.message = `${message}: ${userFriendlyMessage}`;
1081
+ }
1082
+ generateUserFriendlyMessage() {
1083
+ if (this.cause instanceof ZodError2 && this.cause.issues.length > 0) {
1084
+ const issue = this.cause.issues[0];
1085
+ const path = issue.path.join(".");
1086
+ const param = path || "parameter";
1087
+ if (issue.code === "invalid_type") {
1088
+ return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
1089
+ }
1090
+ return issue.message;
1091
+ }
1092
+ return "Please check your input parameters";
1093
+ }
1094
+ };
1095
+
1096
+ // src/errors/SDKErrors.ts
1097
+ var SDKErrorCodes = {
1098
+ NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED"
1099
+ };
1100
+ var ComposioNoAPIKeyError = class extends ComposioError {
1101
+ constructor(message = "No Composio API key provided", options = {}) {
1102
+ const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
1103
+ super(message, {
1104
+ ...options,
1105
+ code: "NO_API_KEY",
1106
+ cause: options.cause || defaultCause,
1107
+ possibleFixes: options.possibleFixes || [
1108
+ "Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
1109
+ "To get an API key, please sign up at https://composio.dev/signup",
1110
+ "You can also use the Composio CLI to create a project and get an API key"
1111
+ ],
1112
+ statusCode: 401
1113
+ });
1114
+ this.name = "ComposioNoAPIKeyError";
1115
+ }
1116
+ };
1117
+
862
1118
  // src/models/CustomTools.ts
863
1119
  var CustomTools = class {
864
1120
  client;
@@ -876,6 +1132,26 @@ var CustomTools = class {
876
1132
  * This is just an in memory registry and is not persisted.
877
1133
  * @param {CustomToolOptions} toolOptions CustomToolOptions
878
1134
  * @returns {Tool} The tool created
1135
+ *
1136
+ * @example
1137
+ * ```typescript
1138
+ * // Create a custom tool with input parameters
1139
+ * const customTool = await composio.customTools.createTool({
1140
+ * name: 'My Custom Tool',
1141
+ * description: 'A tool that performs a custom operation',
1142
+ * slug: 'MY_CUSTOM_TOOL',
1143
+ * inputParams: z.object({
1144
+ * query: z.string().describe('The search query'),
1145
+ * limit: z.number().optional().describe('Maximum number of results')
1146
+ * }),
1147
+ * execute: async (input, authCredentials, executeToolRequest) => {
1148
+ * // Custom implementation logic
1149
+ * return {
1150
+ * data: { results: ['result1', 'result2'] }
1151
+ * };
1152
+ * }
1153
+ * });
1154
+ * ```
879
1155
  */
880
1156
  async createTool(toolOptions) {
881
1157
  const { slug, execute, inputParams, name, description } = toolOptions;
@@ -904,6 +1180,8 @@ var CustomTools = class {
904
1180
  properties: {}
905
1181
  },
906
1182
  tags: [],
1183
+ // this is never set to the user provided toolkitslug so that we can differentiate
1184
+ // the toolkitslug is used via the execute function.
907
1185
  toolkit: { name: "custom", slug: "custom" }
908
1186
  };
909
1187
  this.customToolsRegistry.set(slug.toLowerCase(), {
@@ -916,6 +1194,17 @@ var CustomTools = class {
916
1194
  * Get all the custom tools from the registry.
917
1195
  * @param {string[]} param0.toolSlugs The slugs of the tools to get
918
1196
  * @returns {ToolList} The list of tools
1197
+ *
1198
+ * @example
1199
+ * ```typescript
1200
+ * // Get all custom tools
1201
+ * const allTools = await composio.customTools.getCustomTools({});
1202
+ *
1203
+ * // Get specific custom tools by slug
1204
+ * const specificTools = await composio.customTools.getCustomTools({
1205
+ * toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
1206
+ * });
1207
+ * ```
919
1208
  */
920
1209
  async getCustomTools({ toolSlugs }) {
921
1210
  const tools = [];
@@ -935,6 +1224,17 @@ var CustomTools = class {
935
1224
  * Get a custom tool by slug from the registry.
936
1225
  * @param {string} slug The slug of the tool to get
937
1226
  * @returns {Tool} The tool
1227
+ *
1228
+ * @example
1229
+ * ```typescript
1230
+ * // Get a specific custom tool by its slug
1231
+ * const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
1232
+ * if (myTool) {
1233
+ * console.log(`Found tool: ${myTool.name}`);
1234
+ * } else {
1235
+ * console.log('Tool not found');
1236
+ * }
1237
+ * ```
938
1238
  */
939
1239
  async getCustomToolBySlug(slug) {
940
1240
  if (!slug) {
@@ -954,7 +1254,7 @@ var CustomTools = class {
954
1254
  * @param {ExecuteMetadata} metadata The metadata of the execution
955
1255
  * @returns {ConnectedAccount} The connected account
956
1256
  */
957
- async getConnectedAccount(toolkitSlug, metadata) {
1257
+ async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
958
1258
  try {
959
1259
  await this.client.toolkits.retrieve(toolkitSlug);
960
1260
  } catch (error) {
@@ -964,43 +1264,92 @@ var CustomTools = class {
964
1264
  }
965
1265
  const connectedAccounts = await this.client.connectedAccounts.list({
966
1266
  toolkit_slugs: [toolkitSlug],
967
- user_ids: [metadata.userId]
1267
+ user_ids: [userId]
968
1268
  });
969
1269
  if (!connectedAccounts.items.length) {
970
1270
  throw new ComposioConnectedAccountNotFoundError(
971
1271
  `No connected accounts found for toolkit ${toolkitSlug}`
972
1272
  );
973
1273
  }
974
- return metadata.connectedAccountId ? connectedAccounts.items.find((item) => item.id === metadata.connectedAccountId) : connectedAccounts.items[0];
1274
+ const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
1275
+ if (!connectedAccount) {
1276
+ throw new ComposioConnectedAccountNotFoundError(
1277
+ `Connected account not found for toolkit ${toolkitSlug} for user ${userId}`
1278
+ );
1279
+ }
1280
+ const connectedAccountResponse = await ConnectedAccountRetrieveResponseSchema.safeParse({
1281
+ id: connectedAccount.id,
1282
+ authConfig: {
1283
+ id: connectedAccount.auth_config.id,
1284
+ authScheme: connectedAccount.auth_config.auth_scheme,
1285
+ isComposioManaged: connectedAccount.auth_config.is_composio_managed,
1286
+ isDisabled: connectedAccount.auth_config.is_disabled
1287
+ },
1288
+ userId: connectedAccount.user_id,
1289
+ data: connectedAccount.data || {},
1290
+ status: connectedAccount.status,
1291
+ statusReason: connectedAccount.status_reason,
1292
+ toolkit: {
1293
+ slug: connectedAccount.toolkit.slug
1294
+ },
1295
+ testRequestEndpoint: connectedAccount.test_request_endpoint,
1296
+ isDisabled: connectedAccount.is_disabled,
1297
+ createdAt: connectedAccount.created_at,
1298
+ updatedAt: connectedAccount.updated_at
1299
+ });
1300
+ if (!connectedAccountResponse.success) {
1301
+ throw new ValidationError(
1302
+ `Validation error for connected account of ${toolkitSlug} for user ${userId}`,
1303
+ {
1304
+ cause: connectedAccountResponse.error
1305
+ }
1306
+ );
1307
+ }
1308
+ return connectedAccountResponse.data;
975
1309
  }
976
1310
  /**
977
1311
  * Execute a custom tool
1312
+ *
1313
+ * @description If a toolkit is used, the connected account id is used to execute the tool.
1314
+ * If a connected account id is provided, it is used to execute the tool.
1315
+ * If a connected account id is not provided, the first connected account for the toolkit is used.
1316
+ *
978
1317
  * @param {slug} slug The slug of the tool to execute
979
1318
  * @param {Record<string, unknown>} inputParams The input parameters for the tool
980
1319
  * @param {ExecuteMetadata} metadata The metadata of the execution
981
1320
  * @returns {Promise<ToolExecuteResponse>} The response from the tool
982
1321
  */
983
- async executeCustomTool(slug, inputParams, metadata) {
1322
+ async executeCustomTool(slug, body) {
984
1323
  const tool = this.customToolsRegistry.get(slug.toLowerCase());
985
1324
  if (!tool) {
986
1325
  throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
987
1326
  }
988
1327
  let authCredentials = {};
989
- const { toolkitSlug, execute } = tool.options;
1328
+ const { toolkitSlug, execute, inputParams } = tool.options;
1329
+ let connectedAccountId = body.connectedAccountId;
990
1330
  if (toolkitSlug && toolkitSlug !== "custom") {
991
- const connectedAccount = await this.getConnectedAccount(toolkitSlug, metadata);
1331
+ const connectedAccount = await this.getConnectedAccountForToolkit(
1332
+ toolkitSlug,
1333
+ body.userId,
1334
+ body.connectedAccountId
1335
+ );
1336
+ logger_default.debug(
1337
+ `[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`,
1338
+ JSON.stringify(connectedAccount, null, 2)
1339
+ );
992
1340
  if (!connectedAccount) {
993
1341
  throw new ComposioConnectedAccountNotFoundError(
994
- `Connected account not found for toolkit ${toolkitSlug} for user ${metadata.userId}`,
1342
+ `Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`,
995
1343
  {
996
1344
  meta: {
997
1345
  toolkitSlug,
998
- userId: metadata.userId
1346
+ userId: body.userId
999
1347
  }
1000
1348
  }
1001
1349
  );
1002
1350
  }
1003
- authCredentials = connectedAccount.data?.connectionParams;
1351
+ authCredentials = connectedAccount.data;
1352
+ connectedAccountId = connectedAccount.id;
1004
1353
  }
1005
1354
  if (typeof execute !== "function") {
1006
1355
  throw new ComposioInvalidExecuteFunctionError("Invalid execute function", {
@@ -1010,63 +1359,36 @@ var CustomTools = class {
1010
1359
  });
1011
1360
  }
1012
1361
  const executeToolRequest = async (data) => {
1013
- return this.client.tools.proxy({
1362
+ if (toolkitSlug && toolkitSlug === "custom") {
1363
+ throw new ComposioInvalidExecuteFunctionError(
1364
+ "Custom tools without a toolkit cannot be executed using the executeToolRequest function",
1365
+ {
1366
+ possibleFixes: [
1367
+ "Please manually execute the tool using your logic.",
1368
+ "Pass a toolkit slug to execute the tool on behalf of a toolkit credentials"
1369
+ ]
1370
+ }
1371
+ );
1372
+ }
1373
+ const response = await this.client.tools.proxy({
1014
1374
  ...data,
1015
- connected_account_id: metadata.connectedAccountId
1375
+ connected_account_id: connectedAccountId
1016
1376
  });
1377
+ return {
1378
+ data: response.data,
1379
+ error: null,
1380
+ successful: true,
1381
+ logId: void 0,
1382
+ sessionInfo: void 0
1383
+ };
1017
1384
  };
1018
- return execute(
1019
- inputParams,
1020
- authCredentials,
1021
- executeToolRequest
1022
- );
1023
- }
1024
- };
1025
-
1026
- // src/errors/ValidationErrors.ts
1027
- import { ZodError as ZodError2 } from "zod";
1028
- var ValidationErrorCodes = {
1029
- VALIDATION_ERROR: "VALIDATION_ERROR"
1030
- };
1031
- var ValidationError = class extends ComposioError {
1032
- constructor(message = "Input validation failed", options = {}) {
1033
- const { cause: providedZodError, ...restOptions } = options;
1034
- let zodErrorInstance;
1035
- if (providedZodError instanceof ZodError2) {
1036
- zodErrorInstance = providedZodError;
1037
- } else {
1038
- zodErrorInstance = new ZodError2([
1039
- {
1040
- path: [],
1041
- message: "Invalid input",
1042
- code: "custom"
1043
- }
1044
- ]);
1045
- }
1046
- const issues = zodErrorInstance.issues.map(
1047
- (issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`
1048
- );
1049
- super(message, {
1050
- ...restOptions,
1051
- code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
1052
- possibleFixes: issues,
1053
- cause: zodErrorInstance
1054
- });
1055
- this.name = "ValidationError";
1056
- const userFriendlyMessage = this.generateUserFriendlyMessage();
1057
- this.message = `${message}: ${userFriendlyMessage}`;
1058
- }
1059
- generateUserFriendlyMessage() {
1060
- if (this.cause instanceof ZodError2 && this.cause.issues.length > 0) {
1061
- const issue = this.cause.issues[0];
1062
- const path = issue.path.join(".");
1063
- const param = path || "parameter";
1064
- if (issue.code === "invalid_type") {
1065
- return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
1066
- }
1067
- return issue.message;
1385
+ const parsedInput = inputParams.safeParse(body.arguments);
1386
+ if (!parsedInput.success) {
1387
+ throw new ValidationError("Invalid input parameters", {
1388
+ cause: parsedInput.error
1389
+ });
1068
1390
  }
1069
- return "Please check your input parameters";
1391
+ return execute(parsedInput.data, authCredentials, executeToolRequest);
1070
1392
  }
1071
1393
  };
1072
1394
 
@@ -1292,7 +1614,10 @@ var Tools = class {
1292
1614
  async getRawComposioToolBySlug(userId, slug, modifier) {
1293
1615
  const customTool = await this.customTools.getCustomToolBySlug(slug);
1294
1616
  if (customTool) {
1617
+ logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
1295
1618
  return customTool;
1619
+ } else {
1620
+ logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
1296
1621
  }
1297
1622
  let tool;
1298
1623
  try {
@@ -1370,10 +1695,7 @@ var Tools = class {
1370
1695
  throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
1371
1696
  }
1372
1697
  }
1373
- let result = await this.customTools.executeCustomTool(tool.slug, body, {
1374
- userId: body.userId || "default",
1375
- connectedAccountId: body.connectedAccountId
1376
- });
1698
+ let result = await this.customTools.executeCustomTool(tool.slug, body);
1377
1699
  if (modifiers?.afterExecute) {
1378
1700
  if (typeof modifiers.afterExecute === "function") {
1379
1701
  result = await modifiers.afterExecute(tool.slug, "unknown", result);
@@ -1491,9 +1813,16 @@ var Tools = class {
1491
1813
  /**
1492
1814
  * Fetches the list of all available tools in the Composio SDK.
1493
1815
  *
1494
- * This method is mostly used by the CLI to get the list of tools.
1816
+ * This method is mostly used by the CLI to get the list of tools.
1495
1817
  * No filtering is done on the tools, the list is cached in the backend, no further optimization is required.
1496
- * @returns {string} - The list of all available tools as a string
1818
+ * @returns {Promise<ToolRetrieveEnumResponse>} The complete list of all available tools with their metadata
1819
+ *
1820
+ * @example
1821
+ * ```typescript
1822
+ * // Get all available tools as an enum
1823
+ * const toolsEnum = await composio.tools.getToolsEnum();
1824
+ * console.log(toolsEnum.items);
1825
+ * ```
1497
1826
  */
1498
1827
  async getToolsEnum() {
1499
1828
  return this.client.tools.retrieveEnum();
@@ -1505,15 +1834,42 @@ var Tools = class {
1505
1834
  *
1506
1835
  * @param {string} slug - The ID of the tool to find input for
1507
1836
  * @param {ToolGetInputParams} body - The parameters to be passed to the tool
1508
- * @returns
1837
+ * @returns {Promise<ToolGetInputResponse>} The input parameters schema for the specified tool
1838
+ *
1839
+ * @example
1840
+ * ```typescript
1841
+ * // Get input parameters for a specific tool
1842
+ * const inputParams = await composio.tools.getInput('GITHUB_CREATE_ISSUE', {
1843
+ * userId: 'default'
1844
+ * });
1845
+ * console.log(inputParams.schema);
1846
+ * ```
1509
1847
  */
1510
1848
  async getInput(slug, body) {
1511
1849
  return this.client.tools.getInput(slug, body);
1512
1850
  }
1513
1851
  /**
1514
- * Proxies a custom request to a toolkit/integration
1515
- * @param body
1516
- * @returns
1852
+ * Proxies a custom request to a toolkit/integration.
1853
+ *
1854
+ * This method allows sending custom requests to a specific toolkit or integration
1855
+ * when you need more flexibility than the standard tool execution methods provide.
1856
+ *
1857
+ * @param {ToolProxyParams} body - The parameters for the proxy request including toolkit slug and custom data
1858
+ * @returns {Promise<ToolProxyResponse>} The response from the proxied request
1859
+ *
1860
+ * @example
1861
+ * ```typescript
1862
+ * // Send a custom request to a toolkit
1863
+ * const response = await composio.tools.proxyExecute({
1864
+ * toolkitSlug: 'github',
1865
+ * userId: 'default',
1866
+ * data: {
1867
+ * endpoint: '/repos/owner/repo/issues',
1868
+ * method: 'GET'
1869
+ * }
1870
+ * });
1871
+ * console.log(response.data);
1872
+ * ```
1517
1873
  */
1518
1874
  async proxyExecute(body) {
1519
1875
  return this.client.tools.proxy(body);
@@ -1529,216 +1885,130 @@ var Tools = class {
1529
1885
  *
1530
1886
  * @example
1531
1887
  * ```typescript
1532
- * const customTool = await composio.tools.createCustomTool({
1888
+ * // creating a custom tool with a toolkit
1889
+ * await composio.tools.createCustomTool({
1533
1890
  * name: 'My Custom Tool',
1534
1891
  * description: 'A custom tool that does something specific',
1535
1892
  * slug: 'MY_CUSTOM_TOOL',
1536
- * inputParameters: {
1537
- * param1: {
1538
- * type: 'string',
1539
- * description: 'First parameter',
1540
- * required: true
1541
- * }
1542
- * },
1543
- * outputParameters: {
1544
- * result: {
1545
- * type: 'string',
1546
- * description: 'The result of the operation'
1547
- * }
1548
- * },
1549
- * handler: async (params, context) => {
1893
+ * userId: 'default',
1894
+ * connectedAccountId: '123',
1895
+ * toolkitSlug: 'github',
1896
+ * inputParameters: z.object({
1897
+ * param1: z.string().describe('First parameter'),
1898
+ * }),
1899
+ * execute: async (input, authCredentials, executeToolRequest) => {
1550
1900
  * // Custom logic here
1551
1901
  * return { data: { result: 'Success!' } };
1552
1902
  * }
1553
1903
  * });
1554
1904
  * ```
1555
- */
1556
- async createCustomTool(body) {
1557
- return this.customTools.createTool(body);
1558
- }
1559
- };
1560
-
1561
- // src/models/Toolkits.ts
1562
- import ComposioClient2 from "@composio/client";
1563
-
1564
- // src/types/toolkit.types.ts
1565
- import { z as z2 } from "zod";
1566
- var ToolkitMangedByEnumSchema = z2.enum(["all", "composio", "project"]);
1567
- var ToolkitSortByEnumSchema = z2.enum(["usage", "alphabetically"]);
1568
- var ToolkitsListParamsSchema = z2.object({
1569
- category: z2.string().optional(),
1570
- isLocal: z2.boolean().optional(),
1571
- managedBy: ToolkitMangedByEnumSchema.optional(),
1572
- sortBy: ToolkitSortByEnumSchema.optional()
1573
- });
1574
- var ToolKitMetaSchema = z2.object({
1575
- categories: z2.array(
1576
- z2.object({
1577
- slug: z2.string(),
1578
- name: z2.string()
1579
- })
1580
- ).optional(),
1581
- appUrl: z2.string().optional(),
1582
- createdAt: z2.string().optional(),
1583
- description: z2.string().optional(),
1584
- logo: z2.string().optional(),
1585
- toolsCount: z2.number().optional(),
1586
- triggersCount: z2.number().optional(),
1587
- updatedAt: z2.string().optional()
1588
- });
1589
- var ToolKitItemSchema = z2.object({
1590
- name: z2.string(),
1591
- slug: z2.string(),
1592
- meta: ToolKitMetaSchema,
1593
- isLocalToolkit: z2.boolean(),
1594
- authSchemes: z2.array(z2.string()).optional(),
1595
- composioManagedAuthSchemes: z2.array(z2.string()).optional(),
1596
- noAuth: z2.boolean().optional()
1597
- });
1598
- var ToolKitListResponseSchema = z2.object({
1599
- items: z2.array(ToolKitItemSchema),
1600
- nextCursor: z2.string().nullable(),
1601
- totalPages: z2.number()
1602
- });
1603
- var ToolkitAuthFieldSchema = z2.object({
1604
- name: z2.string(),
1605
- displayName: z2.string(),
1606
- type: z2.string(),
1607
- default: z2.string().nullable().optional()
1608
- });
1609
- var ToolkitAuthConfigDetailsSchema = z2.object({
1610
- name: z2.string(),
1611
- mode: z2.string(),
1612
- fields: z2.object({
1613
- authConfigCreation: z2.object({
1614
- optional: z2.array(ToolkitAuthFieldSchema),
1615
- required: z2.array(ToolkitAuthFieldSchema)
1616
- }),
1617
- connectedAccountInitiation: z2.object({
1618
- optional: z2.array(ToolkitAuthFieldSchema),
1619
- required: z2.array(ToolkitAuthFieldSchema)
1620
- })
1621
- }),
1622
- proxy: z2.object({
1623
- baseUrl: z2.string().optional()
1624
- }).optional()
1625
- });
1626
- var ToolkitRetrieveResponseSchema = z2.object({
1627
- name: z2.string(),
1628
- slug: z2.string(),
1629
- meta: ToolKitMetaSchema,
1630
- isLocalToolkit: z2.boolean(),
1631
- composioManagedAuthSchemes: z2.array(z2.string()).optional(),
1632
- authConfigDetails: z2.array(ToolkitAuthConfigDetailsSchema).optional()
1633
- });
1634
- var ToolkitCategorySchema = z2.object({
1635
- id: z2.string(),
1636
- name: z2.string()
1637
- });
1638
- var ToolkitRetrieveCategoriesResponseSchema = z2.object({
1639
- items: z2.array(ToolkitCategorySchema),
1640
- nextCursor: z2.string().nullable(),
1641
- totalPages: z2.number()
1642
- });
1643
-
1644
- // src/errors/AuthConfigErrors.ts
1645
- var AuthConfigErrorCodes = {
1646
- AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
1647
- };
1648
- var ComposioAuthConfigNotFoundError = class extends ComposioError {
1649
- constructor(message = "Auth config not found", options = {}) {
1650
- super(message, {
1651
- ...options,
1652
- code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
1653
- possibleFixes: options.possibleFixes || [
1654
- "Check if the auth config exists",
1655
- "Check if the auth config id is correct",
1656
- "Check if the auth config is enabled"
1657
- ]
1658
- });
1659
- this.name = "ComposioAuthConfigNotFoundError";
1660
- }
1661
- };
1662
-
1663
- // src/errors/ConnectionRequestErrors.ts
1664
- var ConnectionRequestErrorCodes = {
1665
- CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
1666
- CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
1667
- };
1668
- var ConnectionRequestTimeoutError = class extends ComposioError {
1669
- constructor(message = "Connection request timed out", options = {}) {
1670
- super(message, {
1671
- ...options,
1672
- code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
1673
- });
1674
- this.name = "ConnectionRequestTimeoutError";
1675
- }
1676
- };
1677
- var ConnectionRequestFailedError = class extends ComposioError {
1678
- constructor(message = "Connection request failed", options = {}) {
1679
- super(message, {
1680
- ...options,
1681
- code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
1682
- });
1683
- this.name = "ConnectionRequestFailedError";
1905
+ *
1906
+ * @example
1907
+ * ```typescript
1908
+ * // creating a custom tool without a toolkit
1909
+ * await composio.tools.createCustomTool({
1910
+ * name: 'My Custom Tool',
1911
+ * description: 'A custom tool that does something specific',
1912
+ * slug: 'MY_CUSTOM_TOOL',
1913
+ * inputParameters: z.object({
1914
+ * param1: z.string().describe('First parameter'),
1915
+ * }),
1916
+ * execute: async (input) => {
1917
+ * // Custom logic here
1918
+ * return { data: { result: 'Success!' } };
1919
+ * }
1920
+ * });
1921
+ */
1922
+ async createCustomTool(body) {
1923
+ return this.customTools.createTool(body);
1684
1924
  }
1685
1925
  };
1686
1926
 
1687
- // src/errors/ToolkitErrors.ts
1688
- var ToolkitErrorCodes = {
1689
- TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND"
1690
- };
1691
- var ComposioToolkitNotFoundError = class extends ComposioError {
1692
- constructor(message = "Toolkit not found", options = {}) {
1693
- super(message, {
1694
- ...options,
1695
- code: "TOOLKIT_NOT_FOUND",
1696
- possibleFixes: options.possibleFixes || [
1697
- "Ensure the toolkit is correctly configured and the slug is valid"
1698
- ]
1699
- });
1700
- this.name = "ComposioToolkitNotFoundError";
1701
- }
1702
- };
1703
- var ComposioToolkitFetchError = class extends ComposioError {
1704
- constructor(message = "Failed to fetch toolkit", options = {}) {
1705
- super(message, {
1706
- ...options,
1707
- code: "TOOLKIT_FETCH_ERROR",
1708
- possibleFixes: options.possibleFixes || [
1709
- "Ensure the toolkit slug is valid",
1710
- "Ensure you are using the correct API key",
1711
- "Ensure you are using the correct API endpoint / Base URL and it is working"
1712
- ]
1713
- });
1714
- this.name = "ComposioToolkitFetchError";
1715
- }
1716
- };
1927
+ // src/models/Toolkits.ts
1928
+ import ComposioClient2 from "@composio/client";
1717
1929
 
1718
- // src/errors/SDKErrors.ts
1719
- var SDKErrorCodes = {
1720
- NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED"
1721
- };
1722
- var ComposioNoAPIKeyError = class extends ComposioError {
1723
- constructor(message = "No Composio API key provided", options = {}) {
1724
- const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
1725
- super(message, {
1726
- ...options,
1727
- code: "NO_API_KEY",
1728
- cause: options.cause || defaultCause,
1729
- possibleFixes: options.possibleFixes || [
1730
- "Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
1731
- "To get an API key, please sign up at https://composio.dev/signup",
1732
- "You can also use the Composio CLI to create a project and get an API key"
1733
- ],
1734
- statusCode: 401
1735
- });
1736
- this.name = "ComposioNoAPIKeyError";
1737
- }
1738
- };
1930
+ // src/types/toolkit.types.ts
1931
+ import { z as z3 } from "zod";
1932
+ var ToolkitMangedByEnumSchema = z3.enum(["all", "composio", "project"]);
1933
+ var ToolkitSortByEnumSchema = z3.enum(["usage", "alphabetically"]);
1934
+ var ToolkitsListParamsSchema = z3.object({
1935
+ category: z3.string().optional(),
1936
+ isLocal: z3.boolean().optional(),
1937
+ managedBy: ToolkitMangedByEnumSchema.optional(),
1938
+ sortBy: ToolkitSortByEnumSchema.optional()
1939
+ });
1940
+ var ToolKitMetaSchema = z3.object({
1941
+ categories: z3.array(
1942
+ z3.object({
1943
+ slug: z3.string(),
1944
+ name: z3.string()
1945
+ })
1946
+ ).optional(),
1947
+ appUrl: z3.string().optional(),
1948
+ createdAt: z3.string().optional(),
1949
+ description: z3.string().optional(),
1950
+ logo: z3.string().optional(),
1951
+ toolsCount: z3.number().optional(),
1952
+ triggersCount: z3.number().optional(),
1953
+ updatedAt: z3.string().optional()
1954
+ });
1955
+ var ToolKitItemSchema = z3.object({
1956
+ name: z3.string(),
1957
+ slug: z3.string(),
1958
+ meta: ToolKitMetaSchema,
1959
+ isLocalToolkit: z3.boolean(),
1960
+ authSchemes: z3.array(z3.string()).optional(),
1961
+ composioManagedAuthSchemes: z3.array(z3.string()).optional(),
1962
+ noAuth: z3.boolean().optional()
1963
+ });
1964
+ var ToolKitListResponseSchema = z3.object({
1965
+ items: z3.array(ToolKitItemSchema),
1966
+ nextCursor: z3.string().nullable(),
1967
+ totalPages: z3.number()
1968
+ });
1969
+ var ToolkitAuthFieldSchema = z3.object({
1970
+ name: z3.string(),
1971
+ displayName: z3.string(),
1972
+ type: z3.string(),
1973
+ default: z3.string().nullable().optional()
1974
+ });
1975
+ var ToolkitAuthConfigDetailsSchema = z3.object({
1976
+ name: z3.string(),
1977
+ mode: z3.string(),
1978
+ fields: z3.object({
1979
+ authConfigCreation: z3.object({
1980
+ optional: z3.array(ToolkitAuthFieldSchema),
1981
+ required: z3.array(ToolkitAuthFieldSchema)
1982
+ }),
1983
+ connectedAccountInitiation: z3.object({
1984
+ optional: z3.array(ToolkitAuthFieldSchema),
1985
+ required: z3.array(ToolkitAuthFieldSchema)
1986
+ })
1987
+ }),
1988
+ proxy: z3.object({
1989
+ baseUrl: z3.string().optional()
1990
+ }).optional()
1991
+ });
1992
+ var ToolkitRetrieveResponseSchema = z3.object({
1993
+ name: z3.string(),
1994
+ slug: z3.string(),
1995
+ meta: ToolKitMetaSchema,
1996
+ isLocalToolkit: z3.boolean(),
1997
+ composioManagedAuthSchemes: z3.array(z3.string()).optional(),
1998
+ authConfigDetails: z3.array(ToolkitAuthConfigDetailsSchema).optional()
1999
+ });
2000
+ var ToolkitCategorySchema = z3.object({
2001
+ id: z3.string(),
2002
+ name: z3.string()
2003
+ });
2004
+ var ToolkitRetrieveCategoriesResponseSchema = z3.object({
2005
+ items: z3.array(ToolkitCategorySchema),
2006
+ nextCursor: z3.string().nullable(),
2007
+ totalPages: z3.number()
2008
+ });
1739
2009
 
1740
2010
  // src/types/authConfigs.types.ts
1741
- import { z as z3 } from "zod";
2011
+ import { z as z4 } from "zod";
1742
2012
  var AuthConfigTypes = {
1743
2013
  CUSTOM: "use_custom_auth",
1744
2014
  COMPOSIO_MANAGED: "use_composio_managed_auth"
@@ -1758,7 +2028,7 @@ var AuthSchemeTypes = {
1758
2028
  CALCOM_AUTH: "CALCOM_AUTH",
1759
2029
  SNOWFLAKE: "SNOWFLAKE"
1760
2030
  };
1761
- var AuthSchemeEnum = z3.enum([
2031
+ var AuthSchemeEnum = z4.enum([
1762
2032
  "OAUTH2",
1763
2033
  "OAUTH1",
1764
2034
  "OAUTH1A",
@@ -1773,67 +2043,67 @@ var AuthSchemeEnum = z3.enum([
1773
2043
  "CALCOM_AUTH",
1774
2044
  "SNOWFLAKE"
1775
2045
  ]);
1776
- var CreateCustomAuthConfigParamsSchema = z3.object({
1777
- type: z3.literal("use_custom_auth"),
1778
- name: z3.string().optional(),
1779
- credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()])),
2046
+ var CreateCustomAuthConfigParamsSchema = z4.object({
2047
+ type: z4.literal("use_custom_auth"),
2048
+ name: z4.string().optional(),
2049
+ credentials: z4.record(z4.string(), z4.union([z4.string(), z4.number(), z4.boolean()])),
1780
2050
  authScheme: AuthSchemeEnum
1781
2051
  });
1782
- var CreateComposioManagedAuthConfigParamsSchema = z3.object({
1783
- type: z3.literal("use_composio_managed_auth"),
1784
- name: z3.string().optional(),
1785
- credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()])).optional()
2052
+ var CreateComposioManagedAuthConfigParamsSchema = z4.object({
2053
+ type: z4.literal("use_composio_managed_auth"),
2054
+ name: z4.string().optional(),
2055
+ credentials: z4.record(z4.string(), z4.union([z4.string(), z4.number(), z4.boolean()])).optional()
1786
2056
  });
1787
- var CreateAuthConfigParamsSchema = z3.discriminatedUnion("type", [
2057
+ var CreateAuthConfigParamsSchema = z4.discriminatedUnion("type", [
1788
2058
  CreateCustomAuthConfigParamsSchema,
1789
2059
  CreateComposioManagedAuthConfigParamsSchema
1790
2060
  ]);
1791
- var CreateAuthConfigResponseSchema = z3.object({
1792
- id: z3.string(),
1793
- authScheme: z3.string(),
1794
- isComposioManaged: z3.boolean(),
1795
- toolkit: z3.string()
2061
+ var CreateAuthConfigResponseSchema = z4.object({
2062
+ id: z4.string(),
2063
+ authScheme: z4.string(),
2064
+ isComposioManaged: z4.boolean(),
2065
+ toolkit: z4.string()
1796
2066
  });
1797
- var AuthConfigRetrieveResponseSchema = z3.object({
1798
- id: z3.string(),
1799
- name: z3.string(),
1800
- toolkit: z3.object({
1801
- logo: z3.string(),
1802
- slug: z3.string()
2067
+ var AuthConfigRetrieveResponseSchema = z4.object({
2068
+ id: z4.string(),
2069
+ name: z4.string(),
2070
+ toolkit: z4.object({
2071
+ logo: z4.string(),
2072
+ slug: z4.string()
1803
2073
  }),
1804
- noOfConnections: z3.number(),
1805
- status: z3.enum(["ENABLED", "DISABLED"]),
1806
- uuid: z3.string(),
2074
+ noOfConnections: z4.number(),
2075
+ status: z4.enum(["ENABLED", "DISABLED"]),
2076
+ uuid: z4.string(),
1807
2077
  authScheme: AuthSchemeEnum.optional(),
1808
- credentials: z3.record(z3.string(), z3.unknown()).optional(),
1809
- expectedInputFields: z3.array(z3.unknown()).optional(),
1810
- isComposioManaged: z3.boolean().optional(),
1811
- createdBy: z3.string().optional(),
1812
- createdAt: z3.string().optional(),
1813
- lastUpdatedAt: z3.string().optional()
2078
+ credentials: z4.record(z4.string(), z4.unknown()).optional(),
2079
+ expectedInputFields: z4.array(z4.unknown()).optional(),
2080
+ isComposioManaged: z4.boolean().optional(),
2081
+ createdBy: z4.string().optional(),
2082
+ createdAt: z4.string().optional(),
2083
+ lastUpdatedAt: z4.string().optional()
1814
2084
  });
1815
- var AuthConfigListParamsSchema = z3.object({
1816
- cursor: z3.string().optional(),
1817
- isComposioManaged: z3.boolean().optional(),
1818
- limit: z3.number().optional(),
1819
- toolkit: z3.string().optional()
2085
+ var AuthConfigListParamsSchema = z4.object({
2086
+ cursor: z4.string().optional(),
2087
+ isComposioManaged: z4.boolean().optional(),
2088
+ limit: z4.number().optional(),
2089
+ toolkit: z4.string().optional()
1820
2090
  });
1821
- var AuthConfigListResponseSchema = z3.object({
1822
- items: z3.array(AuthConfigRetrieveResponseSchema),
1823
- nextCursor: z3.string().nullable(),
1824
- totalPages: z3.number()
2091
+ var AuthConfigListResponseSchema = z4.object({
2092
+ items: z4.array(AuthConfigRetrieveResponseSchema),
2093
+ nextCursor: z4.string().nullable(),
2094
+ totalPages: z4.number()
1825
2095
  });
1826
- var AuthCustomConfigUpdateParamsSchema = z3.object({
1827
- credentials: z3.record(z3.string(), z3.union([z3.string(), z3.unknown()])),
1828
- type: z3.literal("custom"),
1829
- restrictToFollowingTools: z3.array(z3.string()).optional()
2096
+ var AuthCustomConfigUpdateParamsSchema = z4.object({
2097
+ credentials: z4.record(z4.string(), z4.union([z4.string(), z4.unknown()])),
2098
+ type: z4.literal("custom"),
2099
+ restrictToFollowingTools: z4.array(z4.string()).optional()
1830
2100
  });
1831
- var AuthDefaultConfigUpdateParamsSchema = z3.object({
1832
- scopes: z3.string(),
1833
- type: z3.literal("default"),
1834
- restrictToFollowingTools: z3.array(z3.string()).optional()
2101
+ var AuthDefaultConfigUpdateParamsSchema = z4.object({
2102
+ scopes: z4.string(),
2103
+ type: z4.literal("default"),
2104
+ restrictToFollowingTools: z4.array(z4.string()).optional()
1835
2105
  });
1836
- var AuthConfigUpdateParamsSchema = z3.discriminatedUnion("type", [
2106
+ var AuthConfigUpdateParamsSchema = z4.discriminatedUnion("type", [
1837
2107
  AuthCustomConfigUpdateParamsSchema,
1838
2108
  AuthDefaultConfigUpdateParamsSchema
1839
2109
  ]);
@@ -2140,119 +2410,6 @@ var AuthConfigs = class {
2140
2410
  }
2141
2411
  };
2142
2412
 
2143
- // src/types/connectedAccounts.types.ts
2144
- import { z as z4 } from "zod";
2145
- var ConnectedAccountStatuses = {
2146
- INITIALIZING: "INITIALIZING",
2147
- INITIATED: "INITIATED",
2148
- ACTIVE: "ACTIVE",
2149
- FAILED: "FAILED",
2150
- EXPIRED: "EXPIRED"
2151
- };
2152
- var ConnectedAccountStatusSchema = z4.enum([
2153
- ConnectedAccountStatuses.INITIALIZING,
2154
- ConnectedAccountStatuses.INITIATED,
2155
- ConnectedAccountStatuses.ACTIVE,
2156
- ConnectedAccountStatuses.FAILED,
2157
- ConnectedAccountStatuses.EXPIRED
2158
- ]);
2159
- var CreateConnectedAccountParamsSchema = z4.object({
2160
- authConfig: z4.object({
2161
- id: z4.string()
2162
- }),
2163
- connection: z4.object({
2164
- data: z4.record(z4.string(), z4.unknown()).optional(),
2165
- callbackUrl: z4.string().optional(),
2166
- userId: z4.string().optional()
2167
- })
2168
- });
2169
- var DefaultCreateConnectedAccountParamsSchema = z4.object({
2170
- auth_config: z4.object({
2171
- id: z4.string()
2172
- }),
2173
- connection: z4.object({
2174
- data: z4.record(z4.string(), z4.unknown()).optional(),
2175
- callback_url: z4.string().optional(),
2176
- user_id: z4.string().optional()
2177
- })
2178
- });
2179
- var CreateConnectedAccountOptionsSchema = z4.object({
2180
- callbackUrl: z4.string().optional(),
2181
- data: z4.record(z4.string(), z4.unknown()).optional()
2182
- });
2183
- var CreateConnectedAccountResponseSchema = z4.object({
2184
- id: z4.string(),
2185
- status: ConnectedAccountStatusSchema,
2186
- redirectUrl: z4.string().nullable()
2187
- });
2188
- var ConnectedAccountAuthSchemes = {
2189
- OAUTH2: "OAUTH2",
2190
- OAUTH1: "OAUTH1",
2191
- OAUTH1A: "OAUTH1A",
2192
- API_KEY: "API_KEY",
2193
- BASIC: "BASIC",
2194
- BILLCOM_AUTH: "BILLCOM_AUTH",
2195
- BEARER_TOKEN: "BEARER_TOKEN",
2196
- GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
2197
- NO_AUTH: "NO_AUTH",
2198
- BASIC_WITH_JWT: "BASIC_WITH_JWT",
2199
- COMPOSIO_LINK: "COMPOSIO_LINK",
2200
- CALCOM_AUTH: "CALCOM_AUTH",
2201
- SNOWFLAKE: "SNOWFLAKE"
2202
- };
2203
- var ConnectedAccountAuthSchemesSchema = z4.enum([
2204
- ConnectedAccountAuthSchemes.OAUTH2,
2205
- ConnectedAccountAuthSchemes.OAUTH1,
2206
- ConnectedAccountAuthSchemes.OAUTH1A,
2207
- ConnectedAccountAuthSchemes.API_KEY,
2208
- ConnectedAccountAuthSchemes.BASIC,
2209
- ConnectedAccountAuthSchemes.BILLCOM_AUTH,
2210
- ConnectedAccountAuthSchemes.BEARER_TOKEN,
2211
- ConnectedAccountAuthSchemes.GOOGLE_SERVICE_ACCOUNT,
2212
- ConnectedAccountAuthSchemes.NO_AUTH,
2213
- ConnectedAccountAuthSchemes.BASIC_WITH_JWT,
2214
- ConnectedAccountAuthSchemes.COMPOSIO_LINK,
2215
- ConnectedAccountAuthSchemes.CALCOM_AUTH,
2216
- ConnectedAccountAuthSchemes.SNOWFLAKE
2217
- ]);
2218
- var ConnectedAccountAuthConfigSchema = z4.object({
2219
- id: z4.string(),
2220
- authScheme: ConnectedAccountAuthSchemesSchema,
2221
- isComposioManaged: z4.boolean(),
2222
- isDisabled: z4.boolean()
2223
- });
2224
- var ConnectedAccountRetrieveResponseSchema = z4.object({
2225
- id: z4.string(),
2226
- authConfig: ConnectedAccountAuthConfigSchema,
2227
- userId: z4.string(),
2228
- data: z4.record(z4.string(), z4.unknown()),
2229
- params: z4.record(z4.string(), z4.unknown()).optional(),
2230
- status: ConnectedAccountStatusSchema,
2231
- statusReason: z4.string().nullable(),
2232
- toolkit: z4.object({
2233
- slug: z4.string()
2234
- }),
2235
- testRequestEndpoint: z4.string().optional(),
2236
- isDisabled: z4.boolean(),
2237
- createdAt: z4.string(),
2238
- updatedAt: z4.string()
2239
- });
2240
- var ConnectedAccountListParamsSchema = z4.object({
2241
- authConfigIds: z4.array(z4.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
2242
- cursor: z4.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
2243
- labels: z4.array(z4.string()).nullable().optional().describe("The labels of the connected accounts"),
2244
- limit: z4.number().nullable().optional().describe("The limit of the connected accounts to return"),
2245
- orderBy: z4.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
2246
- statuses: z4.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
2247
- toolkitSlugs: z4.array(z4.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
2248
- userIds: z4.array(z4.string()).nullable().optional().describe("The user ids of the connected accounts")
2249
- });
2250
- var ConnectedAccountListResponseSchema = z4.object({
2251
- items: z4.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
2252
- nextCursor: z4.string().nullable().describe("The next cursor to paginate through the connected accounts"),
2253
- totalPages: z4.number().describe("The total number of pages of connected accounts")
2254
- });
2255
-
2256
2413
  // src/models/ConnectionRequest.ts
2257
2414
  import ComposioClient from "@composio/client";
2258
2415
  import { ZodError as ZodError3 } from "zod";
@@ -2630,8 +2787,21 @@ var ConnectedAccounts = class {
2630
2787
  * Update the status of a connected account
2631
2788
  * @param {string} nanoid - Unique identifier of the connected account
2632
2789
  * @param {ConnectedAccountUpdateStatusParams} params - Parameters for updating the status
2633
- * @param {RequestOptions} options - Request options
2634
2790
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
2791
+ *
2792
+ * @example
2793
+ * ```typescript
2794
+ * // Enable a connected account
2795
+ * const updatedAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
2796
+ * enabled: true
2797
+ * });
2798
+ *
2799
+ * // Disable a connected account with a reason
2800
+ * const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
2801
+ * enabled: false,
2802
+ * reason: 'Token expired'
2803
+ * });
2804
+ * ```
2635
2805
  */
2636
2806
  async updateStatus(nanoid, params) {
2637
2807
  return this.client.connectedAccounts.updateStatus(nanoid, params);
@@ -2639,8 +2809,14 @@ var ConnectedAccounts = class {
2639
2809
  /**
2640
2810
  * Enable a connected account
2641
2811
  * @param {string} nanoid - Unique identifier of the connected account
2642
- * @param {RequestOptions} options - Request options
2643
2812
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
2813
+ *
2814
+ * @example
2815
+ * ```typescript
2816
+ * // Enable a previously disabled connected account
2817
+ * const enabledAccount = await composio.connectedAccounts.enable('conn_abc123');
2818
+ * console.log(enabledAccount.isDisabled); // false
2819
+ * ```
2644
2820
  */
2645
2821
  async enable(nanoid) {
2646
2822
  return this.client.connectedAccounts.updateStatus(nanoid, { enabled: true });
@@ -2648,8 +2824,20 @@ var ConnectedAccounts = class {
2648
2824
  /**
2649
2825
  * Disable a connected account
2650
2826
  * @param {string} nanoid - Unique identifier of the connected account
2651
- * @param {RequestOptions} options - Request options
2652
2827
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
2828
+ *
2829
+ * @example
2830
+ * ```typescript
2831
+ * // Disable a connected account
2832
+ * const disabledAccount = await composio.connectedAccounts.disable('conn_abc123');
2833
+ * console.log(disabledAccount.isDisabled); // true
2834
+ *
2835
+ * // You can also use updateStatus with a reason
2836
+ * // const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
2837
+ * // enabled: false,
2838
+ * // reason: 'No longer needed'
2839
+ * // });
2840
+ * ```
2653
2841
  */
2654
2842
  async disable(nanoid) {
2655
2843
  return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false });
@@ -3626,10 +3814,54 @@ var BaseAgenticProvider = class extends BaseProvider {
3626
3814
  var OpenAIProvider = class extends BaseNonAgenticProvider {
3627
3815
  name = "openai";
3628
3816
  /**
3629
- * Absract method to wrap a tool in the provider.
3630
- * This method is implemented by the provider.
3631
- * @param tool - The tool to wrap.
3632
- * @returns The wrapped tool.
3817
+ * Creates a new instance of the OpenAIProvider.
3818
+ *
3819
+ * This is the default provider for the Composio SDK and is automatically
3820
+ * available without additional installation.
3821
+ *
3822
+ * @example
3823
+ * ```typescript
3824
+ * // The OpenAIProvider is used by default when initializing Composio
3825
+ * const composio = new Composio({
3826
+ * apiKey: 'your-api-key'
3827
+ * });
3828
+ *
3829
+ * // You can also explicitly specify it
3830
+ * const composio = new Composio({
3831
+ * apiKey: 'your-api-key',
3832
+ * provider: new OpenAIProvider()
3833
+ * });
3834
+ * ```
3835
+ */
3836
+ constructor() {
3837
+ super();
3838
+ }
3839
+ /**
3840
+ * Wraps a Composio tool in the OpenAI function calling format.
3841
+ *
3842
+ * This method transforms a Composio tool definition into the format
3843
+ * expected by OpenAI's function calling API.
3844
+ *
3845
+ * @param tool - The Composio tool to wrap
3846
+ * @returns The wrapped tool in OpenAI format
3847
+ *
3848
+ * @example
3849
+ * ```typescript
3850
+ * // Wrap a single tool for use with OpenAI
3851
+ * const composioTool = {
3852
+ * slug: 'SEARCH_TOOL',
3853
+ * description: 'Search for information',
3854
+ * inputParameters: {
3855
+ * type: 'object',
3856
+ * properties: {
3857
+ * query: { type: 'string' }
3858
+ * },
3859
+ * required: ['query']
3860
+ * }
3861
+ * };
3862
+ *
3863
+ * const openAITool = provider.wrapTool(composioTool);
3864
+ * ```
3633
3865
  */
3634
3866
  wrapTool = (tool) => {
3635
3867
  const formattedSchema = {
@@ -3642,14 +3874,78 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3642
3874
  function: formattedSchema
3643
3875
  };
3644
3876
  };
3877
+ /**
3878
+ * Wraps multiple Composio tools in the OpenAI function calling format.
3879
+ *
3880
+ * This method transforms a list of Composio tools into the format
3881
+ * expected by OpenAI's function calling API.
3882
+ *
3883
+ * @param tools - Array of Composio tools to wrap
3884
+ * @returns Array of wrapped tools in OpenAI format
3885
+ *
3886
+ * @example
3887
+ * ```typescript
3888
+ * // Wrap multiple tools for use with OpenAI
3889
+ * const composioTools = [
3890
+ * {
3891
+ * slug: 'SEARCH_TOOL',
3892
+ * description: 'Search for information',
3893
+ * inputParameters: {
3894
+ * type: 'object',
3895
+ * properties: {
3896
+ * query: { type: 'string' }
3897
+ * }
3898
+ * }
3899
+ * },
3900
+ * {
3901
+ * slug: 'WEATHER_TOOL',
3902
+ * description: 'Get weather information',
3903
+ * inputParameters: {
3904
+ * type: 'object',
3905
+ * properties: {
3906
+ * location: { type: 'string' }
3907
+ * }
3908
+ * }
3909
+ * }
3910
+ * ];
3911
+ *
3912
+ * const openAITools = provider.wrapTools(composioTools);
3913
+ * ```
3914
+ */
3645
3915
  wrapTools = (tools) => {
3646
3916
  return tools.map((tool) => this.wrapTool(tool));
3647
3917
  };
3648
3918
  /**
3649
- * Execute a tool call.
3650
- * @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool to execute.
3651
- * @param {string} userId - The user id.
3652
- * @returns {Promise<string>} The result of the tool call.
3919
+ * Executes a tool call from OpenAI's chat completion.
3920
+ *
3921
+ * This method processes a tool call from OpenAI's chat completion API,
3922
+ * executes the corresponding Composio tool, and returns the result.
3923
+ *
3924
+ * @param {string} userId - The user ID for authentication and tracking
3925
+ * @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool call from OpenAI
3926
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
3927
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
3928
+ * @returns {Promise<string>} The result of the tool call as a JSON string
3929
+ *
3930
+ * @example
3931
+ * ```typescript
3932
+ * // Execute a tool call from OpenAI
3933
+ * const toolCall = {
3934
+ * id: 'call_abc123',
3935
+ * type: 'function',
3936
+ * function: {
3937
+ * name: 'SEARCH_TOOL',
3938
+ * arguments: '{"query":"composio documentation"}'
3939
+ * }
3940
+ * };
3941
+ *
3942
+ * const result = await provider.executeToolCall(
3943
+ * 'user123',
3944
+ * toolCall,
3945
+ * { connectedAccountId: 'conn_xyz456' }
3946
+ * );
3947
+ * console.log(JSON.parse(result));
3948
+ * ```
3653
3949
  */
3654
3950
  async executeToolCall(userId, tool, options, modifiers) {
3655
3951
  const payload = {
@@ -3662,11 +3958,46 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3662
3958
  return JSON.stringify(result);
3663
3959
  }
3664
3960
  /**
3665
- * Handle the tool call from the assistant.
3961
+ * Handles tool calls from OpenAI's chat completion response.
3666
3962
  *
3667
- * @param {OpenAI.ChatCompletion} chatCompletion - The chat completion object.
3668
- * @param {string} userId - The user id.
3669
- * @returns {Promise<string[]>} The results of the tool call.
3963
+ * This method processes tool calls from an OpenAI chat completion response,
3964
+ * executes each tool call, and returns the results.
3965
+ *
3966
+ * @param {string} userId - The user ID for authentication and tracking
3967
+ * @param {OpenAI.ChatCompletion} chatCompletion - The chat completion response from OpenAI
3968
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
3969
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
3970
+ * @returns {Promise<string[]>} Array of tool execution results as JSON strings
3971
+ *
3972
+ * @example
3973
+ * ```typescript
3974
+ * // Handle tool calls from a chat completion response
3975
+ * const chatCompletion = {
3976
+ * choices: [
3977
+ * {
3978
+ * message: {
3979
+ * tool_calls: [
3980
+ * {
3981
+ * id: 'call_abc123',
3982
+ * type: 'function',
3983
+ * function: {
3984
+ * name: 'SEARCH_TOOL',
3985
+ * arguments: '{"query":"composio documentation"}'
3986
+ * }
3987
+ * }
3988
+ * ]
3989
+ * }
3990
+ * }
3991
+ * ]
3992
+ * };
3993
+ *
3994
+ * const results = await provider.handleToolCalls(
3995
+ * 'user123',
3996
+ * chatCompletion,
3997
+ * { connectedAccountId: 'conn_xyz456' }
3998
+ * );
3999
+ * console.log(results); // Array of tool execution results
4000
+ * ```
3670
4001
  */
3671
4002
  async handleToolCalls(userId, chatCompletion, options, modifiers) {
3672
4003
  const outputs = [];
@@ -3680,11 +4011,51 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3680
4011
  return outputs;
3681
4012
  }
3682
4013
  /**
3683
- * Handles all the tool calls from the assistant.
4014
+ * Handles all the tool calls from the OpenAI Assistant API.
3684
4015
  *
3685
- * @param {OpenAI.Beta.Threads.Run} run - The run object.
3686
- * @param {string} userId - The user id.
3687
- * @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} The tool outputs.
4016
+ * This method processes tool calls from an OpenAI Assistant run,
4017
+ * executes each tool call, and returns the tool outputs for submission.
4018
+ *
4019
+ * @param {string} userId - The user ID for authentication and tracking
4020
+ * @param {OpenAI.Beta.Threads.Run} run - The Assistant run object containing tool calls
4021
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
4022
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4023
+ * @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
4024
+ *
4025
+ * @example
4026
+ * ```typescript
4027
+ * // Handle tool calls from an OpenAI Assistant run
4028
+ * const run = {
4029
+ * id: 'run_abc123',
4030
+ * required_action: {
4031
+ * submit_tool_outputs: {
4032
+ * tool_calls: [
4033
+ * {
4034
+ * id: 'call_xyz789',
4035
+ * type: 'function',
4036
+ * function: {
4037
+ * name: 'SEARCH_TOOL',
4038
+ * arguments: '{"query":"composio documentation"}'
4039
+ * }
4040
+ * }
4041
+ * ]
4042
+ * }
4043
+ * }
4044
+ * };
4045
+ *
4046
+ * const toolOutputs = await provider.handleAssistantMessage(
4047
+ * 'user123',
4048
+ * run,
4049
+ * { connectedAccountId: 'conn_xyz456' }
4050
+ * );
4051
+ *
4052
+ * // Submit tool outputs back to OpenAI
4053
+ * await openai.beta.threads.runs.submitToolOutputs(
4054
+ * thread.id,
4055
+ * run.id,
4056
+ * { tool_outputs: toolOutputs }
4057
+ * );
4058
+ * ```
3688
4059
  */
3689
4060
  async handleAssistantMessage(userId, run, options, modifiers) {
3690
4061
  const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
@@ -3709,11 +4080,43 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3709
4080
  /**
3710
4081
  * Waits for the assistant stream and handles the tool calls.
3711
4082
  *
3712
- * @param {OpenAI} client - The OpenAI client.
3713
- * @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The run stream.
3714
- * @param {OpenAI.Beta.Threads.Thread} thread - The thread object.
3715
- * @param {string} userId - The user id.
3716
- * @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} The run stream.
4083
+ * This method processes an OpenAI Assistant stream, handles any tool calls
4084
+ * that require action, and yields each event from the stream. It's designed
4085
+ * for streaming Assistant responses while handling tool calls in real-time.
4086
+ *
4087
+ * @param {string} userId - The user ID for authentication and tracking
4088
+ * @param {OpenAI} client - The OpenAI client instance
4089
+ * @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
4090
+ * @param {OpenAI.Beta.Threads.Thread} thread - The thread object
4091
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
4092
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4093
+ * @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
4094
+ *
4095
+ * @example
4096
+ * ```typescript
4097
+ * // Process an OpenAI Assistant stream with tool calls
4098
+ * const thread = await openai.beta.threads.create();
4099
+ * const runStream = openai.beta.threads.runs.stream(thread.id, {
4100
+ * assistant_id: 'asst_abc123',
4101
+ * tools: provider.wrapTools(composioTools)
4102
+ * });
4103
+ *
4104
+ * // Process the stream and handle tool calls
4105
+ * const streamProcessor = provider.waitAndHandleAssistantStreamToolCalls(
4106
+ * 'user123',
4107
+ * openai,
4108
+ * runStream,
4109
+ * thread,
4110
+ * { connectedAccountId: 'conn_xyz456' }
4111
+ * );
4112
+ *
4113
+ * // Consume the stream events
4114
+ * for await (const event of streamProcessor) {
4115
+ * if (event.event === 'thread.message.delta') {
4116
+ * console.log(event.data.delta.content);
4117
+ * }
4118
+ * }
4119
+ * ```
3717
4120
  */
3718
4121
  async *waitAndHandleAssistantStreamToolCalls(userId, client, runStream, thread, options, modifiers) {
3719
4122
  let runId = null;
@@ -3765,11 +4168,45 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3765
4168
  /**
3766
4169
  * Waits for the assistant tool calls and handles them.
3767
4170
  *
3768
- * @param {OpenAI} client - The OpenAI client.
3769
- * @param {OpenAI.Beta.Threads.Run} run - The run object.
3770
- * @param {OpenAI.Beta.Threads.Thread} thread - The thread object.
3771
- * @param {string} userId - The user id.
3772
- * @returns {Promise<OpenAI.Beta.Threads.Run>} The run object.
4171
+ * This method polls an OpenAI Assistant run until it completes or requires action,
4172
+ * handles any tool calls, and returns the final run object. It's designed for
4173
+ * non-streaming Assistant interactions.
4174
+ *
4175
+ * @param {string} userId - The user ID for authentication and tracking
4176
+ * @param {OpenAI} client - The OpenAI client instance
4177
+ * @param {OpenAI.Beta.Threads.Run} run - The initial run object
4178
+ * @param {OpenAI.Beta.Threads.Thread} thread - The thread object
4179
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
4180
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
4181
+ * @returns {Promise<OpenAI.Beta.Threads.Run>} The final run object after completion
4182
+ *
4183
+ * @example
4184
+ * ```typescript
4185
+ * // Process an OpenAI Assistant run with tool calls
4186
+ * const thread = await openai.beta.threads.create();
4187
+ * await openai.beta.threads.messages.create(thread.id, {
4188
+ * role: 'user',
4189
+ * content: 'Find information about Composio'
4190
+ * });
4191
+ *
4192
+ * let run = await openai.beta.threads.runs.create(thread.id, {
4193
+ * assistant_id: 'asst_abc123',
4194
+ * tools: provider.wrapTools(composioTools)
4195
+ * });
4196
+ *
4197
+ * // Wait for the run to complete, handling any tool calls
4198
+ * run = await provider.waitAndHandleAssistantToolCalls(
4199
+ * 'user123',
4200
+ * openai,
4201
+ * run,
4202
+ * thread,
4203
+ * { connectedAccountId: 'conn_xyz456' }
4204
+ * );
4205
+ *
4206
+ * // Get the final messages after run completion
4207
+ * const messages = await openai.beta.threads.messages.list(thread.id);
4208
+ * console.log(messages.data[0].content);
4209
+ * ```
3773
4210
  */
3774
4211
  async waitAndHandleAssistantToolCalls(userId, client, run, thread, options, modifiers) {
3775
4212
  while (["queued", "in_progress", "requires_action"].includes(run.status)) {
@@ -3788,7 +4225,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
3788
4225
  };
3789
4226
 
3790
4227
  // package.json
3791
- var version = "0.1.12-alpha.14";
4228
+ var version = "0.1.12-alpha.16";
3792
4229
 
3793
4230
  // src/composio.ts
3794
4231
  var Composio = class {
@@ -3814,13 +4251,36 @@ var Composio = class {
3814
4251
  // connected accounts
3815
4252
  connectedAccounts;
3816
4253
  /**
3817
- * @param {Object} config Configuration for the Composio SDK.
3818
- * @param {string} config.apiKey The API key for the Composio SDK.
3819
- * @param {string} config.baseURL The base URL for the Composio SDK.
3820
- * @param {string} config.runtime The runtime for the Composio SDK.
3821
- * @param {boolean} config.allowTracking Whether to allow analytics / tracking. Defaults to true.
3822
- * @param {boolean} config.allowTracing Whether to allow tracing. Defaults to true.
3823
- * @param {TProvider} config.provider The provider to use for this Composio instance.
4254
+ * Creates a new instance of the Composio SDK.
4255
+ *
4256
+ * The constructor initializes the SDK with the provided configuration options,
4257
+ * sets up the API client, and initializes all core models (tools, toolkits, etc.).
4258
+ *
4259
+ * @param {ComposioConfig<TProvider>} config - Configuration options for the Composio SDK
4260
+ * @param {string} [config.apiKey] - The API key for authenticating with the Composio API
4261
+ * @param {string} [config.baseURL] - The base URL for the Composio API (defaults to production URL)
4262
+ * @param {boolean} [config.allowTracking=true] - Whether to allow anonymous usage analytics
4263
+ * @param {boolean} [config.allowTracing=true] - Whether to allow request tracing for debugging
4264
+ * @param {TProvider} [config.provider] - The provider to use for this Composio instance (defaults to OpenAIProvider)
4265
+ * @param {BaseTelemetryTransport} [config.telemetryTransport] - Custom telemetry transport implementation
4266
+ *
4267
+ * @example
4268
+ * ```typescript
4269
+ * // Initialize with default configuration
4270
+ * const composio = new Composio();
4271
+ *
4272
+ * // Initialize with custom API key and base URL
4273
+ * const composio = new Composio({
4274
+ * apiKey: 'your-api-key',
4275
+ * baseURL: 'https://api.composio.dev'
4276
+ * });
4277
+ *
4278
+ * // Initialize with custom provider
4279
+ * const composio = new Composio({
4280
+ * apiKey: 'your-api-key',
4281
+ * provider: new CustomProvider()
4282
+ * });
4283
+ * ```
3824
4284
  */
3825
4285
  constructor(config) {
3826
4286
  const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(