@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.cjs +926 -466
- package/dist/index.d.cts +490 -143
- package/dist/index.d.ts +490 -143
- package/dist/index.js +926 -466
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -922,6 +922,262 @@ var TelemetryService = class {
|
|
|
922
922
|
};
|
|
923
923
|
var telemetry = new TelemetryService();
|
|
924
924
|
|
|
925
|
+
// src/types/connectedAccounts.types.ts
|
|
926
|
+
var import_zod3 = require("zod");
|
|
927
|
+
var ConnectedAccountStatuses = {
|
|
928
|
+
INITIALIZING: "INITIALIZING",
|
|
929
|
+
INITIATED: "INITIATED",
|
|
930
|
+
ACTIVE: "ACTIVE",
|
|
931
|
+
FAILED: "FAILED",
|
|
932
|
+
EXPIRED: "EXPIRED"
|
|
933
|
+
};
|
|
934
|
+
var ConnectedAccountStatusSchema = import_zod3.z.enum([
|
|
935
|
+
ConnectedAccountStatuses.INITIALIZING,
|
|
936
|
+
ConnectedAccountStatuses.INITIATED,
|
|
937
|
+
ConnectedAccountStatuses.ACTIVE,
|
|
938
|
+
ConnectedAccountStatuses.FAILED,
|
|
939
|
+
ConnectedAccountStatuses.EXPIRED
|
|
940
|
+
]);
|
|
941
|
+
var CreateConnectedAccountParamsSchema = import_zod3.z.object({
|
|
942
|
+
authConfig: import_zod3.z.object({
|
|
943
|
+
id: import_zod3.z.string()
|
|
944
|
+
}),
|
|
945
|
+
connection: import_zod3.z.object({
|
|
946
|
+
data: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional(),
|
|
947
|
+
callbackUrl: import_zod3.z.string().optional(),
|
|
948
|
+
userId: import_zod3.z.string().optional()
|
|
949
|
+
})
|
|
950
|
+
});
|
|
951
|
+
var DefaultCreateConnectedAccountParamsSchema = import_zod3.z.object({
|
|
952
|
+
auth_config: import_zod3.z.object({
|
|
953
|
+
id: import_zod3.z.string()
|
|
954
|
+
}),
|
|
955
|
+
connection: import_zod3.z.object({
|
|
956
|
+
data: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional(),
|
|
957
|
+
callback_url: import_zod3.z.string().optional(),
|
|
958
|
+
user_id: import_zod3.z.string().optional()
|
|
959
|
+
})
|
|
960
|
+
});
|
|
961
|
+
var CreateConnectedAccountOptionsSchema = import_zod3.z.object({
|
|
962
|
+
callbackUrl: import_zod3.z.string().optional(),
|
|
963
|
+
data: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional()
|
|
964
|
+
});
|
|
965
|
+
var CreateConnectedAccountResponseSchema = import_zod3.z.object({
|
|
966
|
+
id: import_zod3.z.string(),
|
|
967
|
+
status: ConnectedAccountStatusSchema,
|
|
968
|
+
redirectUrl: import_zod3.z.string().nullable()
|
|
969
|
+
});
|
|
970
|
+
var ConnectedAccountAuthSchemes = {
|
|
971
|
+
OAUTH2: "OAUTH2",
|
|
972
|
+
OAUTH1: "OAUTH1",
|
|
973
|
+
OAUTH1A: "OAUTH1A",
|
|
974
|
+
API_KEY: "API_KEY",
|
|
975
|
+
BASIC: "BASIC",
|
|
976
|
+
BILLCOM_AUTH: "BILLCOM_AUTH",
|
|
977
|
+
BEARER_TOKEN: "BEARER_TOKEN",
|
|
978
|
+
GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
|
|
979
|
+
NO_AUTH: "NO_AUTH",
|
|
980
|
+
BASIC_WITH_JWT: "BASIC_WITH_JWT",
|
|
981
|
+
COMPOSIO_LINK: "COMPOSIO_LINK",
|
|
982
|
+
CALCOM_AUTH: "CALCOM_AUTH",
|
|
983
|
+
SNOWFLAKE: "SNOWFLAKE"
|
|
984
|
+
};
|
|
985
|
+
var ConnectedAccountAuthSchemesSchema = import_zod3.z.enum([
|
|
986
|
+
ConnectedAccountAuthSchemes.OAUTH2,
|
|
987
|
+
ConnectedAccountAuthSchemes.OAUTH1,
|
|
988
|
+
ConnectedAccountAuthSchemes.OAUTH1A,
|
|
989
|
+
ConnectedAccountAuthSchemes.API_KEY,
|
|
990
|
+
ConnectedAccountAuthSchemes.BASIC,
|
|
991
|
+
ConnectedAccountAuthSchemes.BILLCOM_AUTH,
|
|
992
|
+
ConnectedAccountAuthSchemes.BEARER_TOKEN,
|
|
993
|
+
ConnectedAccountAuthSchemes.GOOGLE_SERVICE_ACCOUNT,
|
|
994
|
+
ConnectedAccountAuthSchemes.NO_AUTH,
|
|
995
|
+
ConnectedAccountAuthSchemes.BASIC_WITH_JWT,
|
|
996
|
+
ConnectedAccountAuthSchemes.COMPOSIO_LINK,
|
|
997
|
+
ConnectedAccountAuthSchemes.CALCOM_AUTH,
|
|
998
|
+
ConnectedAccountAuthSchemes.SNOWFLAKE
|
|
999
|
+
]);
|
|
1000
|
+
var ConnectedAccountAuthConfigSchema = import_zod3.z.object({
|
|
1001
|
+
id: import_zod3.z.string(),
|
|
1002
|
+
authScheme: ConnectedAccountAuthSchemesSchema,
|
|
1003
|
+
isComposioManaged: import_zod3.z.boolean(),
|
|
1004
|
+
isDisabled: import_zod3.z.boolean()
|
|
1005
|
+
});
|
|
1006
|
+
var ConnectedAccountRetrieveResponseSchema = import_zod3.z.object({
|
|
1007
|
+
id: import_zod3.z.string(),
|
|
1008
|
+
authConfig: ConnectedAccountAuthConfigSchema,
|
|
1009
|
+
userId: import_zod3.z.string(),
|
|
1010
|
+
data: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()),
|
|
1011
|
+
params: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional(),
|
|
1012
|
+
status: ConnectedAccountStatusSchema,
|
|
1013
|
+
statusReason: import_zod3.z.string().nullable(),
|
|
1014
|
+
toolkit: import_zod3.z.object({
|
|
1015
|
+
slug: import_zod3.z.string()
|
|
1016
|
+
}),
|
|
1017
|
+
testRequestEndpoint: import_zod3.z.string().optional(),
|
|
1018
|
+
isDisabled: import_zod3.z.boolean(),
|
|
1019
|
+
createdAt: import_zod3.z.string(),
|
|
1020
|
+
updatedAt: import_zod3.z.string()
|
|
1021
|
+
});
|
|
1022
|
+
var ConnectedAccountListParamsSchema = import_zod3.z.object({
|
|
1023
|
+
authConfigIds: import_zod3.z.array(import_zod3.z.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
1024
|
+
cursor: import_zod3.z.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
|
|
1025
|
+
labels: import_zod3.z.array(import_zod3.z.string()).nullable().optional().describe("The labels of the connected accounts"),
|
|
1026
|
+
limit: import_zod3.z.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
1027
|
+
orderBy: import_zod3.z.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
1028
|
+
statuses: import_zod3.z.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
1029
|
+
toolkitSlugs: import_zod3.z.array(import_zod3.z.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
1030
|
+
userIds: import_zod3.z.array(import_zod3.z.string()).nullable().optional().describe("The user ids of the connected accounts")
|
|
1031
|
+
});
|
|
1032
|
+
var ConnectedAccountListResponseSchema = import_zod3.z.object({
|
|
1033
|
+
items: import_zod3.z.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
1034
|
+
nextCursor: import_zod3.z.string().nullable().describe("The next cursor to paginate through the connected accounts"),
|
|
1035
|
+
totalPages: import_zod3.z.number().describe("The total number of pages of connected accounts")
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
// src/errors/AuthConfigErrors.ts
|
|
1039
|
+
var AuthConfigErrorCodes = {
|
|
1040
|
+
AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
|
|
1041
|
+
};
|
|
1042
|
+
var ComposioAuthConfigNotFoundError = class extends ComposioError {
|
|
1043
|
+
constructor(message = "Auth config not found", options = {}) {
|
|
1044
|
+
super(message, {
|
|
1045
|
+
...options,
|
|
1046
|
+
code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
|
|
1047
|
+
possibleFixes: options.possibleFixes || [
|
|
1048
|
+
"Check if the auth config exists",
|
|
1049
|
+
"Check if the auth config id is correct",
|
|
1050
|
+
"Check if the auth config is enabled"
|
|
1051
|
+
]
|
|
1052
|
+
});
|
|
1053
|
+
this.name = "ComposioAuthConfigNotFoundError";
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
// src/errors/ConnectionRequestErrors.ts
|
|
1058
|
+
var ConnectionRequestErrorCodes = {
|
|
1059
|
+
CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
|
|
1060
|
+
CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
|
|
1061
|
+
};
|
|
1062
|
+
var ConnectionRequestTimeoutError = class extends ComposioError {
|
|
1063
|
+
constructor(message = "Connection request timed out", options = {}) {
|
|
1064
|
+
super(message, {
|
|
1065
|
+
...options,
|
|
1066
|
+
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
|
|
1067
|
+
});
|
|
1068
|
+
this.name = "ConnectionRequestTimeoutError";
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
var ConnectionRequestFailedError = class extends ComposioError {
|
|
1072
|
+
constructor(message = "Connection request failed", options = {}) {
|
|
1073
|
+
super(message, {
|
|
1074
|
+
...options,
|
|
1075
|
+
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
|
|
1076
|
+
});
|
|
1077
|
+
this.name = "ConnectionRequestFailedError";
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
// src/errors/ToolkitErrors.ts
|
|
1082
|
+
var ToolkitErrorCodes = {
|
|
1083
|
+
TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND"
|
|
1084
|
+
};
|
|
1085
|
+
var ComposioToolkitNotFoundError = class extends ComposioError {
|
|
1086
|
+
constructor(message = "Toolkit not found", options = {}) {
|
|
1087
|
+
super(message, {
|
|
1088
|
+
...options,
|
|
1089
|
+
code: "TOOLKIT_NOT_FOUND",
|
|
1090
|
+
possibleFixes: options.possibleFixes || [
|
|
1091
|
+
"Ensure the toolkit is correctly configured and the slug is valid"
|
|
1092
|
+
]
|
|
1093
|
+
});
|
|
1094
|
+
this.name = "ComposioToolkitNotFoundError";
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
var ComposioToolkitFetchError = class extends ComposioError {
|
|
1098
|
+
constructor(message = "Failed to fetch toolkit", options = {}) {
|
|
1099
|
+
super(message, {
|
|
1100
|
+
...options,
|
|
1101
|
+
code: "TOOLKIT_FETCH_ERROR",
|
|
1102
|
+
possibleFixes: options.possibleFixes || [
|
|
1103
|
+
"Ensure the toolkit slug is valid",
|
|
1104
|
+
"Ensure you are using the correct API key",
|
|
1105
|
+
"Ensure you are using the correct API endpoint / Base URL and it is working"
|
|
1106
|
+
]
|
|
1107
|
+
});
|
|
1108
|
+
this.name = "ComposioToolkitFetchError";
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
// src/errors/ValidationErrors.ts
|
|
1113
|
+
var import_zod4 = require("zod");
|
|
1114
|
+
var ValidationErrorCodes = {
|
|
1115
|
+
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1116
|
+
};
|
|
1117
|
+
var ValidationError = class extends ComposioError {
|
|
1118
|
+
constructor(message = "Input validation failed", options = {}) {
|
|
1119
|
+
const { cause: providedZodError, ...restOptions } = options;
|
|
1120
|
+
let zodErrorInstance;
|
|
1121
|
+
if (providedZodError instanceof import_zod4.ZodError) {
|
|
1122
|
+
zodErrorInstance = providedZodError;
|
|
1123
|
+
} else {
|
|
1124
|
+
zodErrorInstance = new import_zod4.ZodError([
|
|
1125
|
+
{
|
|
1126
|
+
path: [],
|
|
1127
|
+
message: "Invalid input",
|
|
1128
|
+
code: "custom"
|
|
1129
|
+
}
|
|
1130
|
+
]);
|
|
1131
|
+
}
|
|
1132
|
+
const issues = zodErrorInstance.issues.map(
|
|
1133
|
+
(issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`
|
|
1134
|
+
);
|
|
1135
|
+
super(message, {
|
|
1136
|
+
...restOptions,
|
|
1137
|
+
code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
|
|
1138
|
+
possibleFixes: issues,
|
|
1139
|
+
cause: zodErrorInstance
|
|
1140
|
+
});
|
|
1141
|
+
this.name = "ValidationError";
|
|
1142
|
+
const userFriendlyMessage = this.generateUserFriendlyMessage();
|
|
1143
|
+
this.message = `${message}: ${userFriendlyMessage}`;
|
|
1144
|
+
}
|
|
1145
|
+
generateUserFriendlyMessage() {
|
|
1146
|
+
if (this.cause instanceof import_zod4.ZodError && this.cause.issues.length > 0) {
|
|
1147
|
+
const issue = this.cause.issues[0];
|
|
1148
|
+
const path = issue.path.join(".");
|
|
1149
|
+
const param = path || "parameter";
|
|
1150
|
+
if (issue.code === "invalid_type") {
|
|
1151
|
+
return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
|
|
1152
|
+
}
|
|
1153
|
+
return issue.message;
|
|
1154
|
+
}
|
|
1155
|
+
return "Please check your input parameters";
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// src/errors/SDKErrors.ts
|
|
1160
|
+
var SDKErrorCodes = {
|
|
1161
|
+
NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED"
|
|
1162
|
+
};
|
|
1163
|
+
var ComposioNoAPIKeyError = class extends ComposioError {
|
|
1164
|
+
constructor(message = "No Composio API key provided", options = {}) {
|
|
1165
|
+
const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
|
|
1166
|
+
super(message, {
|
|
1167
|
+
...options,
|
|
1168
|
+
code: "NO_API_KEY",
|
|
1169
|
+
cause: options.cause || defaultCause,
|
|
1170
|
+
possibleFixes: options.possibleFixes || [
|
|
1171
|
+
"Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
|
|
1172
|
+
"To get an API key, please sign up at https://composio.dev/signup",
|
|
1173
|
+
"You can also use the Composio CLI to create a project and get an API key"
|
|
1174
|
+
],
|
|
1175
|
+
statusCode: 401
|
|
1176
|
+
});
|
|
1177
|
+
this.name = "ComposioNoAPIKeyError";
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
|
|
925
1181
|
// src/models/CustomTools.ts
|
|
926
1182
|
var CustomTools = class {
|
|
927
1183
|
client;
|
|
@@ -939,6 +1195,26 @@ var CustomTools = class {
|
|
|
939
1195
|
* This is just an in memory registry and is not persisted.
|
|
940
1196
|
* @param {CustomToolOptions} toolOptions CustomToolOptions
|
|
941
1197
|
* @returns {Tool} The tool created
|
|
1198
|
+
*
|
|
1199
|
+
* @example
|
|
1200
|
+
* ```typescript
|
|
1201
|
+
* // Create a custom tool with input parameters
|
|
1202
|
+
* const customTool = await composio.customTools.createTool({
|
|
1203
|
+
* name: 'My Custom Tool',
|
|
1204
|
+
* description: 'A tool that performs a custom operation',
|
|
1205
|
+
* slug: 'MY_CUSTOM_TOOL',
|
|
1206
|
+
* inputParams: z.object({
|
|
1207
|
+
* query: z.string().describe('The search query'),
|
|
1208
|
+
* limit: z.number().optional().describe('Maximum number of results')
|
|
1209
|
+
* }),
|
|
1210
|
+
* execute: async (input, authCredentials, executeToolRequest) => {
|
|
1211
|
+
* // Custom implementation logic
|
|
1212
|
+
* return {
|
|
1213
|
+
* data: { results: ['result1', 'result2'] }
|
|
1214
|
+
* };
|
|
1215
|
+
* }
|
|
1216
|
+
* });
|
|
1217
|
+
* ```
|
|
942
1218
|
*/
|
|
943
1219
|
async createTool(toolOptions) {
|
|
944
1220
|
const { slug, execute, inputParams, name, description } = toolOptions;
|
|
@@ -967,6 +1243,8 @@ var CustomTools = class {
|
|
|
967
1243
|
properties: {}
|
|
968
1244
|
},
|
|
969
1245
|
tags: [],
|
|
1246
|
+
// this is never set to the user provided toolkitslug so that we can differentiate
|
|
1247
|
+
// the toolkitslug is used via the execute function.
|
|
970
1248
|
toolkit: { name: "custom", slug: "custom" }
|
|
971
1249
|
};
|
|
972
1250
|
this.customToolsRegistry.set(slug.toLowerCase(), {
|
|
@@ -979,6 +1257,17 @@ var CustomTools = class {
|
|
|
979
1257
|
* Get all the custom tools from the registry.
|
|
980
1258
|
* @param {string[]} param0.toolSlugs The slugs of the tools to get
|
|
981
1259
|
* @returns {ToolList} The list of tools
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```typescript
|
|
1263
|
+
* // Get all custom tools
|
|
1264
|
+
* const allTools = await composio.customTools.getCustomTools({});
|
|
1265
|
+
*
|
|
1266
|
+
* // Get specific custom tools by slug
|
|
1267
|
+
* const specificTools = await composio.customTools.getCustomTools({
|
|
1268
|
+
* toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
|
|
1269
|
+
* });
|
|
1270
|
+
* ```
|
|
982
1271
|
*/
|
|
983
1272
|
async getCustomTools({ toolSlugs }) {
|
|
984
1273
|
const tools = [];
|
|
@@ -998,6 +1287,17 @@ var CustomTools = class {
|
|
|
998
1287
|
* Get a custom tool by slug from the registry.
|
|
999
1288
|
* @param {string} slug The slug of the tool to get
|
|
1000
1289
|
* @returns {Tool} The tool
|
|
1290
|
+
*
|
|
1291
|
+
* @example
|
|
1292
|
+
* ```typescript
|
|
1293
|
+
* // Get a specific custom tool by its slug
|
|
1294
|
+
* const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
|
|
1295
|
+
* if (myTool) {
|
|
1296
|
+
* console.log(`Found tool: ${myTool.name}`);
|
|
1297
|
+
* } else {
|
|
1298
|
+
* console.log('Tool not found');
|
|
1299
|
+
* }
|
|
1300
|
+
* ```
|
|
1001
1301
|
*/
|
|
1002
1302
|
async getCustomToolBySlug(slug) {
|
|
1003
1303
|
if (!slug) {
|
|
@@ -1017,7 +1317,7 @@ var CustomTools = class {
|
|
|
1017
1317
|
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1018
1318
|
* @returns {ConnectedAccount} The connected account
|
|
1019
1319
|
*/
|
|
1020
|
-
async
|
|
1320
|
+
async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
|
|
1021
1321
|
try {
|
|
1022
1322
|
await this.client.toolkits.retrieve(toolkitSlug);
|
|
1023
1323
|
} catch (error) {
|
|
@@ -1027,43 +1327,92 @@ var CustomTools = class {
|
|
|
1027
1327
|
}
|
|
1028
1328
|
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
1029
1329
|
toolkit_slugs: [toolkitSlug],
|
|
1030
|
-
user_ids: [
|
|
1330
|
+
user_ids: [userId]
|
|
1031
1331
|
});
|
|
1032
1332
|
if (!connectedAccounts.items.length) {
|
|
1033
1333
|
throw new ComposioConnectedAccountNotFoundError(
|
|
1034
1334
|
`No connected accounts found for toolkit ${toolkitSlug}`
|
|
1035
1335
|
);
|
|
1036
1336
|
}
|
|
1037
|
-
|
|
1337
|
+
const connectedAccount = connectedAccountId ? connectedAccounts.items.find((item) => item.id === connectedAccountId) : connectedAccounts.items[0];
|
|
1338
|
+
if (!connectedAccount) {
|
|
1339
|
+
throw new ComposioConnectedAccountNotFoundError(
|
|
1340
|
+
`Connected account not found for toolkit ${toolkitSlug} for user ${userId}`
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
const connectedAccountResponse = await ConnectedAccountRetrieveResponseSchema.safeParse({
|
|
1344
|
+
id: connectedAccount.id,
|
|
1345
|
+
authConfig: {
|
|
1346
|
+
id: connectedAccount.auth_config.id,
|
|
1347
|
+
authScheme: connectedAccount.auth_config.auth_scheme,
|
|
1348
|
+
isComposioManaged: connectedAccount.auth_config.is_composio_managed,
|
|
1349
|
+
isDisabled: connectedAccount.auth_config.is_disabled
|
|
1350
|
+
},
|
|
1351
|
+
userId: connectedAccount.user_id,
|
|
1352
|
+
data: connectedAccount.data || {},
|
|
1353
|
+
status: connectedAccount.status,
|
|
1354
|
+
statusReason: connectedAccount.status_reason,
|
|
1355
|
+
toolkit: {
|
|
1356
|
+
slug: connectedAccount.toolkit.slug
|
|
1357
|
+
},
|
|
1358
|
+
testRequestEndpoint: connectedAccount.test_request_endpoint,
|
|
1359
|
+
isDisabled: connectedAccount.is_disabled,
|
|
1360
|
+
createdAt: connectedAccount.created_at,
|
|
1361
|
+
updatedAt: connectedAccount.updated_at
|
|
1362
|
+
});
|
|
1363
|
+
if (!connectedAccountResponse.success) {
|
|
1364
|
+
throw new ValidationError(
|
|
1365
|
+
`Validation error for connected account of ${toolkitSlug} for user ${userId}`,
|
|
1366
|
+
{
|
|
1367
|
+
cause: connectedAccountResponse.error
|
|
1368
|
+
}
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
return connectedAccountResponse.data;
|
|
1038
1372
|
}
|
|
1039
1373
|
/**
|
|
1040
1374
|
* Execute a custom tool
|
|
1375
|
+
*
|
|
1376
|
+
* @description If a toolkit is used, the connected account id is used to execute the tool.
|
|
1377
|
+
* If a connected account id is provided, it is used to execute the tool.
|
|
1378
|
+
* If a connected account id is not provided, the first connected account for the toolkit is used.
|
|
1379
|
+
*
|
|
1041
1380
|
* @param {slug} slug The slug of the tool to execute
|
|
1042
1381
|
* @param {Record<string, unknown>} inputParams The input parameters for the tool
|
|
1043
1382
|
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1044
1383
|
* @returns {Promise<ToolExecuteResponse>} The response from the tool
|
|
1045
1384
|
*/
|
|
1046
|
-
async executeCustomTool(slug,
|
|
1385
|
+
async executeCustomTool(slug, body) {
|
|
1047
1386
|
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1048
1387
|
if (!tool) {
|
|
1049
1388
|
throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
|
|
1050
1389
|
}
|
|
1051
1390
|
let authCredentials = {};
|
|
1052
|
-
const { toolkitSlug, execute } = tool.options;
|
|
1391
|
+
const { toolkitSlug, execute, inputParams } = tool.options;
|
|
1392
|
+
let connectedAccountId = body.connectedAccountId;
|
|
1053
1393
|
if (toolkitSlug && toolkitSlug !== "custom") {
|
|
1054
|
-
const connectedAccount = await this.
|
|
1394
|
+
const connectedAccount = await this.getConnectedAccountForToolkit(
|
|
1395
|
+
toolkitSlug,
|
|
1396
|
+
body.userId,
|
|
1397
|
+
body.connectedAccountId
|
|
1398
|
+
);
|
|
1399
|
+
logger_default.debug(
|
|
1400
|
+
`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`,
|
|
1401
|
+
JSON.stringify(connectedAccount, null, 2)
|
|
1402
|
+
);
|
|
1055
1403
|
if (!connectedAccount) {
|
|
1056
1404
|
throw new ComposioConnectedAccountNotFoundError(
|
|
1057
|
-
`Connected account not found for toolkit ${toolkitSlug} for user ${
|
|
1405
|
+
`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`,
|
|
1058
1406
|
{
|
|
1059
1407
|
meta: {
|
|
1060
1408
|
toolkitSlug,
|
|
1061
|
-
userId:
|
|
1409
|
+
userId: body.userId
|
|
1062
1410
|
}
|
|
1063
1411
|
}
|
|
1064
1412
|
);
|
|
1065
1413
|
}
|
|
1066
|
-
authCredentials = connectedAccount.data
|
|
1414
|
+
authCredentials = connectedAccount.data;
|
|
1415
|
+
connectedAccountId = connectedAccount.id;
|
|
1067
1416
|
}
|
|
1068
1417
|
if (typeof execute !== "function") {
|
|
1069
1418
|
throw new ComposioInvalidExecuteFunctionError("Invalid execute function", {
|
|
@@ -1073,63 +1422,36 @@ var CustomTools = class {
|
|
|
1073
1422
|
});
|
|
1074
1423
|
}
|
|
1075
1424
|
const executeToolRequest = async (data) => {
|
|
1076
|
-
|
|
1425
|
+
if (toolkitSlug && toolkitSlug === "custom") {
|
|
1426
|
+
throw new ComposioInvalidExecuteFunctionError(
|
|
1427
|
+
"Custom tools without a toolkit cannot be executed using the executeToolRequest function",
|
|
1428
|
+
{
|
|
1429
|
+
possibleFixes: [
|
|
1430
|
+
"Please manually execute the tool using your logic.",
|
|
1431
|
+
"Pass a toolkit slug to execute the tool on behalf of a toolkit credentials"
|
|
1432
|
+
]
|
|
1433
|
+
}
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
const response = await this.client.tools.proxy({
|
|
1077
1437
|
...data,
|
|
1078
|
-
connected_account_id:
|
|
1438
|
+
connected_account_id: connectedAccountId
|
|
1079
1439
|
});
|
|
1440
|
+
return {
|
|
1441
|
+
data: response.data,
|
|
1442
|
+
error: null,
|
|
1443
|
+
successful: true,
|
|
1444
|
+
logId: void 0,
|
|
1445
|
+
sessionInfo: void 0
|
|
1446
|
+
};
|
|
1080
1447
|
};
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
|
|
1089
|
-
// src/errors/ValidationErrors.ts
|
|
1090
|
-
var import_zod3 = require("zod");
|
|
1091
|
-
var ValidationErrorCodes = {
|
|
1092
|
-
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1093
|
-
};
|
|
1094
|
-
var ValidationError = class extends ComposioError {
|
|
1095
|
-
constructor(message = "Input validation failed", options = {}) {
|
|
1096
|
-
const { cause: providedZodError, ...restOptions } = options;
|
|
1097
|
-
let zodErrorInstance;
|
|
1098
|
-
if (providedZodError instanceof import_zod3.ZodError) {
|
|
1099
|
-
zodErrorInstance = providedZodError;
|
|
1100
|
-
} else {
|
|
1101
|
-
zodErrorInstance = new import_zod3.ZodError([
|
|
1102
|
-
{
|
|
1103
|
-
path: [],
|
|
1104
|
-
message: "Invalid input",
|
|
1105
|
-
code: "custom"
|
|
1106
|
-
}
|
|
1107
|
-
]);
|
|
1108
|
-
}
|
|
1109
|
-
const issues = zodErrorInstance.issues.map(
|
|
1110
|
-
(issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`
|
|
1111
|
-
);
|
|
1112
|
-
super(message, {
|
|
1113
|
-
...restOptions,
|
|
1114
|
-
code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
|
|
1115
|
-
possibleFixes: issues,
|
|
1116
|
-
cause: zodErrorInstance
|
|
1117
|
-
});
|
|
1118
|
-
this.name = "ValidationError";
|
|
1119
|
-
const userFriendlyMessage = this.generateUserFriendlyMessage();
|
|
1120
|
-
this.message = `${message}: ${userFriendlyMessage}`;
|
|
1121
|
-
}
|
|
1122
|
-
generateUserFriendlyMessage() {
|
|
1123
|
-
if (this.cause instanceof import_zod3.ZodError && this.cause.issues.length > 0) {
|
|
1124
|
-
const issue = this.cause.issues[0];
|
|
1125
|
-
const path = issue.path.join(".");
|
|
1126
|
-
const param = path || "parameter";
|
|
1127
|
-
if (issue.code === "invalid_type") {
|
|
1128
|
-
return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
|
|
1129
|
-
}
|
|
1130
|
-
return issue.message;
|
|
1448
|
+
const parsedInput = inputParams.safeParse(body.arguments);
|
|
1449
|
+
if (!parsedInput.success) {
|
|
1450
|
+
throw new ValidationError("Invalid input parameters", {
|
|
1451
|
+
cause: parsedInput.error
|
|
1452
|
+
});
|
|
1131
1453
|
}
|
|
1132
|
-
return
|
|
1454
|
+
return execute(parsedInput.data, authCredentials, executeToolRequest);
|
|
1133
1455
|
}
|
|
1134
1456
|
};
|
|
1135
1457
|
|
|
@@ -1355,7 +1677,10 @@ var Tools = class {
|
|
|
1355
1677
|
async getRawComposioToolBySlug(userId, slug, modifier) {
|
|
1356
1678
|
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
1357
1679
|
if (customTool) {
|
|
1680
|
+
logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
|
|
1358
1681
|
return customTool;
|
|
1682
|
+
} else {
|
|
1683
|
+
logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
|
|
1359
1684
|
}
|
|
1360
1685
|
let tool;
|
|
1361
1686
|
try {
|
|
@@ -1433,10 +1758,7 @@ var Tools = class {
|
|
|
1433
1758
|
throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
1434
1759
|
}
|
|
1435
1760
|
}
|
|
1436
|
-
let result = await this.customTools.executeCustomTool(tool.slug, body
|
|
1437
|
-
userId: body.userId || "default",
|
|
1438
|
-
connectedAccountId: body.connectedAccountId
|
|
1439
|
-
});
|
|
1761
|
+
let result = await this.customTools.executeCustomTool(tool.slug, body);
|
|
1440
1762
|
if (modifiers?.afterExecute) {
|
|
1441
1763
|
if (typeof modifiers.afterExecute === "function") {
|
|
1442
1764
|
result = await modifiers.afterExecute(tool.slug, "unknown", result);
|
|
@@ -1554,9 +1876,16 @@ var Tools = class {
|
|
|
1554
1876
|
/**
|
|
1555
1877
|
* Fetches the list of all available tools in the Composio SDK.
|
|
1556
1878
|
*
|
|
1557
|
-
* This method is mostly used by the CLI
|
|
1879
|
+
* This method is mostly used by the CLI to get the list of tools.
|
|
1558
1880
|
* No filtering is done on the tools, the list is cached in the backend, no further optimization is required.
|
|
1559
|
-
* @returns {
|
|
1881
|
+
* @returns {Promise<ToolRetrieveEnumResponse>} The complete list of all available tools with their metadata
|
|
1882
|
+
*
|
|
1883
|
+
* @example
|
|
1884
|
+
* ```typescript
|
|
1885
|
+
* // Get all available tools as an enum
|
|
1886
|
+
* const toolsEnum = await composio.tools.getToolsEnum();
|
|
1887
|
+
* console.log(toolsEnum.items);
|
|
1888
|
+
* ```
|
|
1560
1889
|
*/
|
|
1561
1890
|
async getToolsEnum() {
|
|
1562
1891
|
return this.client.tools.retrieveEnum();
|
|
@@ -1568,15 +1897,42 @@ var Tools = class {
|
|
|
1568
1897
|
*
|
|
1569
1898
|
* @param {string} slug - The ID of the tool to find input for
|
|
1570
1899
|
* @param {ToolGetInputParams} body - The parameters to be passed to the tool
|
|
1571
|
-
* @returns
|
|
1900
|
+
* @returns {Promise<ToolGetInputResponse>} The input parameters schema for the specified tool
|
|
1901
|
+
*
|
|
1902
|
+
* @example
|
|
1903
|
+
* ```typescript
|
|
1904
|
+
* // Get input parameters for a specific tool
|
|
1905
|
+
* const inputParams = await composio.tools.getInput('GITHUB_CREATE_ISSUE', {
|
|
1906
|
+
* userId: 'default'
|
|
1907
|
+
* });
|
|
1908
|
+
* console.log(inputParams.schema);
|
|
1909
|
+
* ```
|
|
1572
1910
|
*/
|
|
1573
1911
|
async getInput(slug, body) {
|
|
1574
1912
|
return this.client.tools.getInput(slug, body);
|
|
1575
1913
|
}
|
|
1576
1914
|
/**
|
|
1577
|
-
* Proxies a custom request to a toolkit/integration
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1915
|
+
* Proxies a custom request to a toolkit/integration.
|
|
1916
|
+
*
|
|
1917
|
+
* This method allows sending custom requests to a specific toolkit or integration
|
|
1918
|
+
* when you need more flexibility than the standard tool execution methods provide.
|
|
1919
|
+
*
|
|
1920
|
+
* @param {ToolProxyParams} body - The parameters for the proxy request including toolkit slug and custom data
|
|
1921
|
+
* @returns {Promise<ToolProxyResponse>} The response from the proxied request
|
|
1922
|
+
*
|
|
1923
|
+
* @example
|
|
1924
|
+
* ```typescript
|
|
1925
|
+
* // Send a custom request to a toolkit
|
|
1926
|
+
* const response = await composio.tools.proxyExecute({
|
|
1927
|
+
* toolkitSlug: 'github',
|
|
1928
|
+
* userId: 'default',
|
|
1929
|
+
* data: {
|
|
1930
|
+
* endpoint: '/repos/owner/repo/issues',
|
|
1931
|
+
* method: 'GET'
|
|
1932
|
+
* }
|
|
1933
|
+
* });
|
|
1934
|
+
* console.log(response.data);
|
|
1935
|
+
* ```
|
|
1580
1936
|
*/
|
|
1581
1937
|
async proxyExecute(body) {
|
|
1582
1938
|
return this.client.tools.proxy(body);
|
|
@@ -1592,216 +1948,130 @@ var Tools = class {
|
|
|
1592
1948
|
*
|
|
1593
1949
|
* @example
|
|
1594
1950
|
* ```typescript
|
|
1595
|
-
*
|
|
1951
|
+
* // creating a custom tool with a toolkit
|
|
1952
|
+
* await composio.tools.createCustomTool({
|
|
1596
1953
|
* name: 'My Custom Tool',
|
|
1597
1954
|
* description: 'A custom tool that does something specific',
|
|
1598
1955
|
* slug: 'MY_CUSTOM_TOOL',
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1603
|
-
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
* outputParameters: {
|
|
1607
|
-
* result: {
|
|
1608
|
-
* type: 'string',
|
|
1609
|
-
* description: 'The result of the operation'
|
|
1610
|
-
* }
|
|
1611
|
-
* },
|
|
1612
|
-
* handler: async (params, context) => {
|
|
1956
|
+
* userId: 'default',
|
|
1957
|
+
* connectedAccountId: '123',
|
|
1958
|
+
* toolkitSlug: 'github',
|
|
1959
|
+
* inputParameters: z.object({
|
|
1960
|
+
* param1: z.string().describe('First parameter'),
|
|
1961
|
+
* }),
|
|
1962
|
+
* execute: async (input, authCredentials, executeToolRequest) => {
|
|
1613
1963
|
* // Custom logic here
|
|
1614
1964
|
* return { data: { result: 'Success!' } };
|
|
1615
1965
|
* }
|
|
1616
1966
|
* });
|
|
1617
1967
|
* ```
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
var ToolKitMetaSchema = import_zod4.z.object({
|
|
1638
|
-
categories: import_zod4.z.array(
|
|
1639
|
-
import_zod4.z.object({
|
|
1640
|
-
slug: import_zod4.z.string(),
|
|
1641
|
-
name: import_zod4.z.string()
|
|
1642
|
-
})
|
|
1643
|
-
).optional(),
|
|
1644
|
-
appUrl: import_zod4.z.string().optional(),
|
|
1645
|
-
createdAt: import_zod4.z.string().optional(),
|
|
1646
|
-
description: import_zod4.z.string().optional(),
|
|
1647
|
-
logo: import_zod4.z.string().optional(),
|
|
1648
|
-
toolsCount: import_zod4.z.number().optional(),
|
|
1649
|
-
triggersCount: import_zod4.z.number().optional(),
|
|
1650
|
-
updatedAt: import_zod4.z.string().optional()
|
|
1651
|
-
});
|
|
1652
|
-
var ToolKitItemSchema = import_zod4.z.object({
|
|
1653
|
-
name: import_zod4.z.string(),
|
|
1654
|
-
slug: import_zod4.z.string(),
|
|
1655
|
-
meta: ToolKitMetaSchema,
|
|
1656
|
-
isLocalToolkit: import_zod4.z.boolean(),
|
|
1657
|
-
authSchemes: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
1658
|
-
composioManagedAuthSchemes: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
1659
|
-
noAuth: import_zod4.z.boolean().optional()
|
|
1660
|
-
});
|
|
1661
|
-
var ToolKitListResponseSchema = import_zod4.z.object({
|
|
1662
|
-
items: import_zod4.z.array(ToolKitItemSchema),
|
|
1663
|
-
nextCursor: import_zod4.z.string().nullable(),
|
|
1664
|
-
totalPages: import_zod4.z.number()
|
|
1665
|
-
});
|
|
1666
|
-
var ToolkitAuthFieldSchema = import_zod4.z.object({
|
|
1667
|
-
name: import_zod4.z.string(),
|
|
1668
|
-
displayName: import_zod4.z.string(),
|
|
1669
|
-
type: import_zod4.z.string(),
|
|
1670
|
-
default: import_zod4.z.string().nullable().optional()
|
|
1671
|
-
});
|
|
1672
|
-
var ToolkitAuthConfigDetailsSchema = import_zod4.z.object({
|
|
1673
|
-
name: import_zod4.z.string(),
|
|
1674
|
-
mode: import_zod4.z.string(),
|
|
1675
|
-
fields: import_zod4.z.object({
|
|
1676
|
-
authConfigCreation: import_zod4.z.object({
|
|
1677
|
-
optional: import_zod4.z.array(ToolkitAuthFieldSchema),
|
|
1678
|
-
required: import_zod4.z.array(ToolkitAuthFieldSchema)
|
|
1679
|
-
}),
|
|
1680
|
-
connectedAccountInitiation: import_zod4.z.object({
|
|
1681
|
-
optional: import_zod4.z.array(ToolkitAuthFieldSchema),
|
|
1682
|
-
required: import_zod4.z.array(ToolkitAuthFieldSchema)
|
|
1683
|
-
})
|
|
1684
|
-
}),
|
|
1685
|
-
proxy: import_zod4.z.object({
|
|
1686
|
-
baseUrl: import_zod4.z.string().optional()
|
|
1687
|
-
}).optional()
|
|
1688
|
-
});
|
|
1689
|
-
var ToolkitRetrieveResponseSchema = import_zod4.z.object({
|
|
1690
|
-
name: import_zod4.z.string(),
|
|
1691
|
-
slug: import_zod4.z.string(),
|
|
1692
|
-
meta: ToolKitMetaSchema,
|
|
1693
|
-
isLocalToolkit: import_zod4.z.boolean(),
|
|
1694
|
-
composioManagedAuthSchemes: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
1695
|
-
authConfigDetails: import_zod4.z.array(ToolkitAuthConfigDetailsSchema).optional()
|
|
1696
|
-
});
|
|
1697
|
-
var ToolkitCategorySchema = import_zod4.z.object({
|
|
1698
|
-
id: import_zod4.z.string(),
|
|
1699
|
-
name: import_zod4.z.string()
|
|
1700
|
-
});
|
|
1701
|
-
var ToolkitRetrieveCategoriesResponseSchema = import_zod4.z.object({
|
|
1702
|
-
items: import_zod4.z.array(ToolkitCategorySchema),
|
|
1703
|
-
nextCursor: import_zod4.z.string().nullable(),
|
|
1704
|
-
totalPages: import_zod4.z.number()
|
|
1705
|
-
});
|
|
1706
|
-
|
|
1707
|
-
// src/errors/AuthConfigErrors.ts
|
|
1708
|
-
var AuthConfigErrorCodes = {
|
|
1709
|
-
AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
|
|
1710
|
-
};
|
|
1711
|
-
var ComposioAuthConfigNotFoundError = class extends ComposioError {
|
|
1712
|
-
constructor(message = "Auth config not found", options = {}) {
|
|
1713
|
-
super(message, {
|
|
1714
|
-
...options,
|
|
1715
|
-
code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
|
|
1716
|
-
possibleFixes: options.possibleFixes || [
|
|
1717
|
-
"Check if the auth config exists",
|
|
1718
|
-
"Check if the auth config id is correct",
|
|
1719
|
-
"Check if the auth config is enabled"
|
|
1720
|
-
]
|
|
1721
|
-
});
|
|
1722
|
-
this.name = "ComposioAuthConfigNotFoundError";
|
|
1723
|
-
}
|
|
1724
|
-
};
|
|
1725
|
-
|
|
1726
|
-
// src/errors/ConnectionRequestErrors.ts
|
|
1727
|
-
var ConnectionRequestErrorCodes = {
|
|
1728
|
-
CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
|
|
1729
|
-
CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
|
|
1730
|
-
};
|
|
1731
|
-
var ConnectionRequestTimeoutError = class extends ComposioError {
|
|
1732
|
-
constructor(message = "Connection request timed out", options = {}) {
|
|
1733
|
-
super(message, {
|
|
1734
|
-
...options,
|
|
1735
|
-
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
|
|
1736
|
-
});
|
|
1737
|
-
this.name = "ConnectionRequestTimeoutError";
|
|
1738
|
-
}
|
|
1739
|
-
};
|
|
1740
|
-
var ConnectionRequestFailedError = class extends ComposioError {
|
|
1741
|
-
constructor(message = "Connection request failed", options = {}) {
|
|
1742
|
-
super(message, {
|
|
1743
|
-
...options,
|
|
1744
|
-
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
|
|
1745
|
-
});
|
|
1746
|
-
this.name = "ConnectionRequestFailedError";
|
|
1968
|
+
*
|
|
1969
|
+
* @example
|
|
1970
|
+
* ```typescript
|
|
1971
|
+
* // creating a custom tool without a toolkit
|
|
1972
|
+
* await composio.tools.createCustomTool({
|
|
1973
|
+
* name: 'My Custom Tool',
|
|
1974
|
+
* description: 'A custom tool that does something specific',
|
|
1975
|
+
* slug: 'MY_CUSTOM_TOOL',
|
|
1976
|
+
* inputParameters: z.object({
|
|
1977
|
+
* param1: z.string().describe('First parameter'),
|
|
1978
|
+
* }),
|
|
1979
|
+
* execute: async (input) => {
|
|
1980
|
+
* // Custom logic here
|
|
1981
|
+
* return { data: { result: 'Success!' } };
|
|
1982
|
+
* }
|
|
1983
|
+
* });
|
|
1984
|
+
*/
|
|
1985
|
+
async createCustomTool(body) {
|
|
1986
|
+
return this.customTools.createTool(body);
|
|
1747
1987
|
}
|
|
1748
1988
|
};
|
|
1749
1989
|
|
|
1750
|
-
// src/
|
|
1751
|
-
var
|
|
1752
|
-
TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND"
|
|
1753
|
-
};
|
|
1754
|
-
var ComposioToolkitNotFoundError = class extends ComposioError {
|
|
1755
|
-
constructor(message = "Toolkit not found", options = {}) {
|
|
1756
|
-
super(message, {
|
|
1757
|
-
...options,
|
|
1758
|
-
code: "TOOLKIT_NOT_FOUND",
|
|
1759
|
-
possibleFixes: options.possibleFixes || [
|
|
1760
|
-
"Ensure the toolkit is correctly configured and the slug is valid"
|
|
1761
|
-
]
|
|
1762
|
-
});
|
|
1763
|
-
this.name = "ComposioToolkitNotFoundError";
|
|
1764
|
-
}
|
|
1765
|
-
};
|
|
1766
|
-
var ComposioToolkitFetchError = class extends ComposioError {
|
|
1767
|
-
constructor(message = "Failed to fetch toolkit", options = {}) {
|
|
1768
|
-
super(message, {
|
|
1769
|
-
...options,
|
|
1770
|
-
code: "TOOLKIT_FETCH_ERROR",
|
|
1771
|
-
possibleFixes: options.possibleFixes || [
|
|
1772
|
-
"Ensure the toolkit slug is valid",
|
|
1773
|
-
"Ensure you are using the correct API key",
|
|
1774
|
-
"Ensure you are using the correct API endpoint / Base URL and it is working"
|
|
1775
|
-
]
|
|
1776
|
-
});
|
|
1777
|
-
this.name = "ComposioToolkitFetchError";
|
|
1778
|
-
}
|
|
1779
|
-
};
|
|
1990
|
+
// src/models/Toolkits.ts
|
|
1991
|
+
var import_client4 = __toESM(require("@composio/client"), 1);
|
|
1780
1992
|
|
|
1781
|
-
// src/
|
|
1782
|
-
var
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
var
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1993
|
+
// src/types/toolkit.types.ts
|
|
1994
|
+
var import_zod5 = require("zod");
|
|
1995
|
+
var ToolkitMangedByEnumSchema = import_zod5.z.enum(["all", "composio", "project"]);
|
|
1996
|
+
var ToolkitSortByEnumSchema = import_zod5.z.enum(["usage", "alphabetically"]);
|
|
1997
|
+
var ToolkitsListParamsSchema = import_zod5.z.object({
|
|
1998
|
+
category: import_zod5.z.string().optional(),
|
|
1999
|
+
isLocal: import_zod5.z.boolean().optional(),
|
|
2000
|
+
managedBy: ToolkitMangedByEnumSchema.optional(),
|
|
2001
|
+
sortBy: ToolkitSortByEnumSchema.optional()
|
|
2002
|
+
});
|
|
2003
|
+
var ToolKitMetaSchema = import_zod5.z.object({
|
|
2004
|
+
categories: import_zod5.z.array(
|
|
2005
|
+
import_zod5.z.object({
|
|
2006
|
+
slug: import_zod5.z.string(),
|
|
2007
|
+
name: import_zod5.z.string()
|
|
2008
|
+
})
|
|
2009
|
+
).optional(),
|
|
2010
|
+
appUrl: import_zod5.z.string().optional(),
|
|
2011
|
+
createdAt: import_zod5.z.string().optional(),
|
|
2012
|
+
description: import_zod5.z.string().optional(),
|
|
2013
|
+
logo: import_zod5.z.string().optional(),
|
|
2014
|
+
toolsCount: import_zod5.z.number().optional(),
|
|
2015
|
+
triggersCount: import_zod5.z.number().optional(),
|
|
2016
|
+
updatedAt: import_zod5.z.string().optional()
|
|
2017
|
+
});
|
|
2018
|
+
var ToolKitItemSchema = import_zod5.z.object({
|
|
2019
|
+
name: import_zod5.z.string(),
|
|
2020
|
+
slug: import_zod5.z.string(),
|
|
2021
|
+
meta: ToolKitMetaSchema,
|
|
2022
|
+
isLocalToolkit: import_zod5.z.boolean(),
|
|
2023
|
+
authSchemes: import_zod5.z.array(import_zod5.z.string()).optional(),
|
|
2024
|
+
composioManagedAuthSchemes: import_zod5.z.array(import_zod5.z.string()).optional(),
|
|
2025
|
+
noAuth: import_zod5.z.boolean().optional()
|
|
2026
|
+
});
|
|
2027
|
+
var ToolKitListResponseSchema = import_zod5.z.object({
|
|
2028
|
+
items: import_zod5.z.array(ToolKitItemSchema),
|
|
2029
|
+
nextCursor: import_zod5.z.string().nullable(),
|
|
2030
|
+
totalPages: import_zod5.z.number()
|
|
2031
|
+
});
|
|
2032
|
+
var ToolkitAuthFieldSchema = import_zod5.z.object({
|
|
2033
|
+
name: import_zod5.z.string(),
|
|
2034
|
+
displayName: import_zod5.z.string(),
|
|
2035
|
+
type: import_zod5.z.string(),
|
|
2036
|
+
default: import_zod5.z.string().nullable().optional()
|
|
2037
|
+
});
|
|
2038
|
+
var ToolkitAuthConfigDetailsSchema = import_zod5.z.object({
|
|
2039
|
+
name: import_zod5.z.string(),
|
|
2040
|
+
mode: import_zod5.z.string(),
|
|
2041
|
+
fields: import_zod5.z.object({
|
|
2042
|
+
authConfigCreation: import_zod5.z.object({
|
|
2043
|
+
optional: import_zod5.z.array(ToolkitAuthFieldSchema),
|
|
2044
|
+
required: import_zod5.z.array(ToolkitAuthFieldSchema)
|
|
2045
|
+
}),
|
|
2046
|
+
connectedAccountInitiation: import_zod5.z.object({
|
|
2047
|
+
optional: import_zod5.z.array(ToolkitAuthFieldSchema),
|
|
2048
|
+
required: import_zod5.z.array(ToolkitAuthFieldSchema)
|
|
2049
|
+
})
|
|
2050
|
+
}),
|
|
2051
|
+
proxy: import_zod5.z.object({
|
|
2052
|
+
baseUrl: import_zod5.z.string().optional()
|
|
2053
|
+
}).optional()
|
|
2054
|
+
});
|
|
2055
|
+
var ToolkitRetrieveResponseSchema = import_zod5.z.object({
|
|
2056
|
+
name: import_zod5.z.string(),
|
|
2057
|
+
slug: import_zod5.z.string(),
|
|
2058
|
+
meta: ToolKitMetaSchema,
|
|
2059
|
+
isLocalToolkit: import_zod5.z.boolean(),
|
|
2060
|
+
composioManagedAuthSchemes: import_zod5.z.array(import_zod5.z.string()).optional(),
|
|
2061
|
+
authConfigDetails: import_zod5.z.array(ToolkitAuthConfigDetailsSchema).optional()
|
|
2062
|
+
});
|
|
2063
|
+
var ToolkitCategorySchema = import_zod5.z.object({
|
|
2064
|
+
id: import_zod5.z.string(),
|
|
2065
|
+
name: import_zod5.z.string()
|
|
2066
|
+
});
|
|
2067
|
+
var ToolkitRetrieveCategoriesResponseSchema = import_zod5.z.object({
|
|
2068
|
+
items: import_zod5.z.array(ToolkitCategorySchema),
|
|
2069
|
+
nextCursor: import_zod5.z.string().nullable(),
|
|
2070
|
+
totalPages: import_zod5.z.number()
|
|
2071
|
+
});
|
|
1802
2072
|
|
|
1803
2073
|
// src/types/authConfigs.types.ts
|
|
1804
|
-
var
|
|
2074
|
+
var import_zod6 = require("zod");
|
|
1805
2075
|
var AuthConfigTypes = {
|
|
1806
2076
|
CUSTOM: "use_custom_auth",
|
|
1807
2077
|
COMPOSIO_MANAGED: "use_composio_managed_auth"
|
|
@@ -1821,7 +2091,7 @@ var AuthSchemeTypes = {
|
|
|
1821
2091
|
CALCOM_AUTH: "CALCOM_AUTH",
|
|
1822
2092
|
SNOWFLAKE: "SNOWFLAKE"
|
|
1823
2093
|
};
|
|
1824
|
-
var AuthSchemeEnum =
|
|
2094
|
+
var AuthSchemeEnum = import_zod6.z.enum([
|
|
1825
2095
|
"OAUTH2",
|
|
1826
2096
|
"OAUTH1",
|
|
1827
2097
|
"OAUTH1A",
|
|
@@ -1836,67 +2106,67 @@ var AuthSchemeEnum = import_zod5.z.enum([
|
|
|
1836
2106
|
"CALCOM_AUTH",
|
|
1837
2107
|
"SNOWFLAKE"
|
|
1838
2108
|
]);
|
|
1839
|
-
var CreateCustomAuthConfigParamsSchema =
|
|
1840
|
-
type:
|
|
1841
|
-
name:
|
|
1842
|
-
credentials:
|
|
2109
|
+
var CreateCustomAuthConfigParamsSchema = import_zod6.z.object({
|
|
2110
|
+
type: import_zod6.z.literal("use_custom_auth"),
|
|
2111
|
+
name: import_zod6.z.string().optional(),
|
|
2112
|
+
credentials: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.union([import_zod6.z.string(), import_zod6.z.number(), import_zod6.z.boolean()])),
|
|
1843
2113
|
authScheme: AuthSchemeEnum
|
|
1844
2114
|
});
|
|
1845
|
-
var CreateComposioManagedAuthConfigParamsSchema =
|
|
1846
|
-
type:
|
|
1847
|
-
name:
|
|
1848
|
-
credentials:
|
|
2115
|
+
var CreateComposioManagedAuthConfigParamsSchema = import_zod6.z.object({
|
|
2116
|
+
type: import_zod6.z.literal("use_composio_managed_auth"),
|
|
2117
|
+
name: import_zod6.z.string().optional(),
|
|
2118
|
+
credentials: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.union([import_zod6.z.string(), import_zod6.z.number(), import_zod6.z.boolean()])).optional()
|
|
1849
2119
|
});
|
|
1850
|
-
var CreateAuthConfigParamsSchema =
|
|
2120
|
+
var CreateAuthConfigParamsSchema = import_zod6.z.discriminatedUnion("type", [
|
|
1851
2121
|
CreateCustomAuthConfigParamsSchema,
|
|
1852
2122
|
CreateComposioManagedAuthConfigParamsSchema
|
|
1853
2123
|
]);
|
|
1854
|
-
var CreateAuthConfigResponseSchema =
|
|
1855
|
-
id:
|
|
1856
|
-
authScheme:
|
|
1857
|
-
isComposioManaged:
|
|
1858
|
-
toolkit:
|
|
2124
|
+
var CreateAuthConfigResponseSchema = import_zod6.z.object({
|
|
2125
|
+
id: import_zod6.z.string(),
|
|
2126
|
+
authScheme: import_zod6.z.string(),
|
|
2127
|
+
isComposioManaged: import_zod6.z.boolean(),
|
|
2128
|
+
toolkit: import_zod6.z.string()
|
|
1859
2129
|
});
|
|
1860
|
-
var AuthConfigRetrieveResponseSchema =
|
|
1861
|
-
id:
|
|
1862
|
-
name:
|
|
1863
|
-
toolkit:
|
|
1864
|
-
logo:
|
|
1865
|
-
slug:
|
|
2130
|
+
var AuthConfigRetrieveResponseSchema = import_zod6.z.object({
|
|
2131
|
+
id: import_zod6.z.string(),
|
|
2132
|
+
name: import_zod6.z.string(),
|
|
2133
|
+
toolkit: import_zod6.z.object({
|
|
2134
|
+
logo: import_zod6.z.string(),
|
|
2135
|
+
slug: import_zod6.z.string()
|
|
1866
2136
|
}),
|
|
1867
|
-
noOfConnections:
|
|
1868
|
-
status:
|
|
1869
|
-
uuid:
|
|
2137
|
+
noOfConnections: import_zod6.z.number(),
|
|
2138
|
+
status: import_zod6.z.enum(["ENABLED", "DISABLED"]),
|
|
2139
|
+
uuid: import_zod6.z.string(),
|
|
1870
2140
|
authScheme: AuthSchemeEnum.optional(),
|
|
1871
|
-
credentials:
|
|
1872
|
-
expectedInputFields:
|
|
1873
|
-
isComposioManaged:
|
|
1874
|
-
createdBy:
|
|
1875
|
-
createdAt:
|
|
1876
|
-
lastUpdatedAt:
|
|
2141
|
+
credentials: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional(),
|
|
2142
|
+
expectedInputFields: import_zod6.z.array(import_zod6.z.unknown()).optional(),
|
|
2143
|
+
isComposioManaged: import_zod6.z.boolean().optional(),
|
|
2144
|
+
createdBy: import_zod6.z.string().optional(),
|
|
2145
|
+
createdAt: import_zod6.z.string().optional(),
|
|
2146
|
+
lastUpdatedAt: import_zod6.z.string().optional()
|
|
1877
2147
|
});
|
|
1878
|
-
var AuthConfigListParamsSchema =
|
|
1879
|
-
cursor:
|
|
1880
|
-
isComposioManaged:
|
|
1881
|
-
limit:
|
|
1882
|
-
toolkit:
|
|
2148
|
+
var AuthConfigListParamsSchema = import_zod6.z.object({
|
|
2149
|
+
cursor: import_zod6.z.string().optional(),
|
|
2150
|
+
isComposioManaged: import_zod6.z.boolean().optional(),
|
|
2151
|
+
limit: import_zod6.z.number().optional(),
|
|
2152
|
+
toolkit: import_zod6.z.string().optional()
|
|
1883
2153
|
});
|
|
1884
|
-
var AuthConfigListResponseSchema =
|
|
1885
|
-
items:
|
|
1886
|
-
nextCursor:
|
|
1887
|
-
totalPages:
|
|
2154
|
+
var AuthConfigListResponseSchema = import_zod6.z.object({
|
|
2155
|
+
items: import_zod6.z.array(AuthConfigRetrieveResponseSchema),
|
|
2156
|
+
nextCursor: import_zod6.z.string().nullable(),
|
|
2157
|
+
totalPages: import_zod6.z.number()
|
|
1888
2158
|
});
|
|
1889
|
-
var AuthCustomConfigUpdateParamsSchema =
|
|
1890
|
-
credentials:
|
|
1891
|
-
type:
|
|
1892
|
-
restrictToFollowingTools:
|
|
2159
|
+
var AuthCustomConfigUpdateParamsSchema = import_zod6.z.object({
|
|
2160
|
+
credentials: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.union([import_zod6.z.string(), import_zod6.z.unknown()])),
|
|
2161
|
+
type: import_zod6.z.literal("custom"),
|
|
2162
|
+
restrictToFollowingTools: import_zod6.z.array(import_zod6.z.string()).optional()
|
|
1893
2163
|
});
|
|
1894
|
-
var AuthDefaultConfigUpdateParamsSchema =
|
|
1895
|
-
scopes:
|
|
1896
|
-
type:
|
|
1897
|
-
restrictToFollowingTools:
|
|
2164
|
+
var AuthDefaultConfigUpdateParamsSchema = import_zod6.z.object({
|
|
2165
|
+
scopes: import_zod6.z.string(),
|
|
2166
|
+
type: import_zod6.z.literal("default"),
|
|
2167
|
+
restrictToFollowingTools: import_zod6.z.array(import_zod6.z.string()).optional()
|
|
1898
2168
|
});
|
|
1899
|
-
var AuthConfigUpdateParamsSchema =
|
|
2169
|
+
var AuthConfigUpdateParamsSchema = import_zod6.z.discriminatedUnion("type", [
|
|
1900
2170
|
AuthCustomConfigUpdateParamsSchema,
|
|
1901
2171
|
AuthDefaultConfigUpdateParamsSchema
|
|
1902
2172
|
]);
|
|
@@ -2203,119 +2473,6 @@ var AuthConfigs = class {
|
|
|
2203
2473
|
}
|
|
2204
2474
|
};
|
|
2205
2475
|
|
|
2206
|
-
// src/types/connectedAccounts.types.ts
|
|
2207
|
-
var import_zod6 = require("zod");
|
|
2208
|
-
var ConnectedAccountStatuses = {
|
|
2209
|
-
INITIALIZING: "INITIALIZING",
|
|
2210
|
-
INITIATED: "INITIATED",
|
|
2211
|
-
ACTIVE: "ACTIVE",
|
|
2212
|
-
FAILED: "FAILED",
|
|
2213
|
-
EXPIRED: "EXPIRED"
|
|
2214
|
-
};
|
|
2215
|
-
var ConnectedAccountStatusSchema = import_zod6.z.enum([
|
|
2216
|
-
ConnectedAccountStatuses.INITIALIZING,
|
|
2217
|
-
ConnectedAccountStatuses.INITIATED,
|
|
2218
|
-
ConnectedAccountStatuses.ACTIVE,
|
|
2219
|
-
ConnectedAccountStatuses.FAILED,
|
|
2220
|
-
ConnectedAccountStatuses.EXPIRED
|
|
2221
|
-
]);
|
|
2222
|
-
var CreateConnectedAccountParamsSchema = import_zod6.z.object({
|
|
2223
|
-
authConfig: import_zod6.z.object({
|
|
2224
|
-
id: import_zod6.z.string()
|
|
2225
|
-
}),
|
|
2226
|
-
connection: import_zod6.z.object({
|
|
2227
|
-
data: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional(),
|
|
2228
|
-
callbackUrl: import_zod6.z.string().optional(),
|
|
2229
|
-
userId: import_zod6.z.string().optional()
|
|
2230
|
-
})
|
|
2231
|
-
});
|
|
2232
|
-
var DefaultCreateConnectedAccountParamsSchema = import_zod6.z.object({
|
|
2233
|
-
auth_config: import_zod6.z.object({
|
|
2234
|
-
id: import_zod6.z.string()
|
|
2235
|
-
}),
|
|
2236
|
-
connection: import_zod6.z.object({
|
|
2237
|
-
data: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional(),
|
|
2238
|
-
callback_url: import_zod6.z.string().optional(),
|
|
2239
|
-
user_id: import_zod6.z.string().optional()
|
|
2240
|
-
})
|
|
2241
|
-
});
|
|
2242
|
-
var CreateConnectedAccountOptionsSchema = import_zod6.z.object({
|
|
2243
|
-
callbackUrl: import_zod6.z.string().optional(),
|
|
2244
|
-
data: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional()
|
|
2245
|
-
});
|
|
2246
|
-
var CreateConnectedAccountResponseSchema = import_zod6.z.object({
|
|
2247
|
-
id: import_zod6.z.string(),
|
|
2248
|
-
status: ConnectedAccountStatusSchema,
|
|
2249
|
-
redirectUrl: import_zod6.z.string().nullable()
|
|
2250
|
-
});
|
|
2251
|
-
var ConnectedAccountAuthSchemes = {
|
|
2252
|
-
OAUTH2: "OAUTH2",
|
|
2253
|
-
OAUTH1: "OAUTH1",
|
|
2254
|
-
OAUTH1A: "OAUTH1A",
|
|
2255
|
-
API_KEY: "API_KEY",
|
|
2256
|
-
BASIC: "BASIC",
|
|
2257
|
-
BILLCOM_AUTH: "BILLCOM_AUTH",
|
|
2258
|
-
BEARER_TOKEN: "BEARER_TOKEN",
|
|
2259
|
-
GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
|
|
2260
|
-
NO_AUTH: "NO_AUTH",
|
|
2261
|
-
BASIC_WITH_JWT: "BASIC_WITH_JWT",
|
|
2262
|
-
COMPOSIO_LINK: "COMPOSIO_LINK",
|
|
2263
|
-
CALCOM_AUTH: "CALCOM_AUTH",
|
|
2264
|
-
SNOWFLAKE: "SNOWFLAKE"
|
|
2265
|
-
};
|
|
2266
|
-
var ConnectedAccountAuthSchemesSchema = import_zod6.z.enum([
|
|
2267
|
-
ConnectedAccountAuthSchemes.OAUTH2,
|
|
2268
|
-
ConnectedAccountAuthSchemes.OAUTH1,
|
|
2269
|
-
ConnectedAccountAuthSchemes.OAUTH1A,
|
|
2270
|
-
ConnectedAccountAuthSchemes.API_KEY,
|
|
2271
|
-
ConnectedAccountAuthSchemes.BASIC,
|
|
2272
|
-
ConnectedAccountAuthSchemes.BILLCOM_AUTH,
|
|
2273
|
-
ConnectedAccountAuthSchemes.BEARER_TOKEN,
|
|
2274
|
-
ConnectedAccountAuthSchemes.GOOGLE_SERVICE_ACCOUNT,
|
|
2275
|
-
ConnectedAccountAuthSchemes.NO_AUTH,
|
|
2276
|
-
ConnectedAccountAuthSchemes.BASIC_WITH_JWT,
|
|
2277
|
-
ConnectedAccountAuthSchemes.COMPOSIO_LINK,
|
|
2278
|
-
ConnectedAccountAuthSchemes.CALCOM_AUTH,
|
|
2279
|
-
ConnectedAccountAuthSchemes.SNOWFLAKE
|
|
2280
|
-
]);
|
|
2281
|
-
var ConnectedAccountAuthConfigSchema = import_zod6.z.object({
|
|
2282
|
-
id: import_zod6.z.string(),
|
|
2283
|
-
authScheme: ConnectedAccountAuthSchemesSchema,
|
|
2284
|
-
isComposioManaged: import_zod6.z.boolean(),
|
|
2285
|
-
isDisabled: import_zod6.z.boolean()
|
|
2286
|
-
});
|
|
2287
|
-
var ConnectedAccountRetrieveResponseSchema = import_zod6.z.object({
|
|
2288
|
-
id: import_zod6.z.string(),
|
|
2289
|
-
authConfig: ConnectedAccountAuthConfigSchema,
|
|
2290
|
-
userId: import_zod6.z.string(),
|
|
2291
|
-
data: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()),
|
|
2292
|
-
params: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional(),
|
|
2293
|
-
status: ConnectedAccountStatusSchema,
|
|
2294
|
-
statusReason: import_zod6.z.string().nullable(),
|
|
2295
|
-
toolkit: import_zod6.z.object({
|
|
2296
|
-
slug: import_zod6.z.string()
|
|
2297
|
-
}),
|
|
2298
|
-
testRequestEndpoint: import_zod6.z.string().optional(),
|
|
2299
|
-
isDisabled: import_zod6.z.boolean(),
|
|
2300
|
-
createdAt: import_zod6.z.string(),
|
|
2301
|
-
updatedAt: import_zod6.z.string()
|
|
2302
|
-
});
|
|
2303
|
-
var ConnectedAccountListParamsSchema = import_zod6.z.object({
|
|
2304
|
-
authConfigIds: import_zod6.z.array(import_zod6.z.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
2305
|
-
cursor: import_zod6.z.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
|
|
2306
|
-
labels: import_zod6.z.array(import_zod6.z.string()).nullable().optional().describe("The labels of the connected accounts"),
|
|
2307
|
-
limit: import_zod6.z.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
2308
|
-
orderBy: import_zod6.z.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
2309
|
-
statuses: import_zod6.z.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
2310
|
-
toolkitSlugs: import_zod6.z.array(import_zod6.z.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
2311
|
-
userIds: import_zod6.z.array(import_zod6.z.string()).nullable().optional().describe("The user ids of the connected accounts")
|
|
2312
|
-
});
|
|
2313
|
-
var ConnectedAccountListResponseSchema = import_zod6.z.object({
|
|
2314
|
-
items: import_zod6.z.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
2315
|
-
nextCursor: import_zod6.z.string().nullable().describe("The next cursor to paginate through the connected accounts"),
|
|
2316
|
-
totalPages: import_zod6.z.number().describe("The total number of pages of connected accounts")
|
|
2317
|
-
});
|
|
2318
|
-
|
|
2319
2476
|
// src/models/ConnectionRequest.ts
|
|
2320
2477
|
var import_client3 = __toESM(require("@composio/client"), 1);
|
|
2321
2478
|
var import_zod7 = require("zod");
|
|
@@ -2693,8 +2850,21 @@ var ConnectedAccounts = class {
|
|
|
2693
2850
|
* Update the status of a connected account
|
|
2694
2851
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
2695
2852
|
* @param {ConnectedAccountUpdateStatusParams} params - Parameters for updating the status
|
|
2696
|
-
* @param {RequestOptions} options - Request options
|
|
2697
2853
|
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
2854
|
+
*
|
|
2855
|
+
* @example
|
|
2856
|
+
* ```typescript
|
|
2857
|
+
* // Enable a connected account
|
|
2858
|
+
* const updatedAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
|
|
2859
|
+
* enabled: true
|
|
2860
|
+
* });
|
|
2861
|
+
*
|
|
2862
|
+
* // Disable a connected account with a reason
|
|
2863
|
+
* const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
|
|
2864
|
+
* enabled: false,
|
|
2865
|
+
* reason: 'Token expired'
|
|
2866
|
+
* });
|
|
2867
|
+
* ```
|
|
2698
2868
|
*/
|
|
2699
2869
|
async updateStatus(nanoid, params) {
|
|
2700
2870
|
return this.client.connectedAccounts.updateStatus(nanoid, params);
|
|
@@ -2702,8 +2872,14 @@ var ConnectedAccounts = class {
|
|
|
2702
2872
|
/**
|
|
2703
2873
|
* Enable a connected account
|
|
2704
2874
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
2705
|
-
* @param {RequestOptions} options - Request options
|
|
2706
2875
|
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
2876
|
+
*
|
|
2877
|
+
* @example
|
|
2878
|
+
* ```typescript
|
|
2879
|
+
* // Enable a previously disabled connected account
|
|
2880
|
+
* const enabledAccount = await composio.connectedAccounts.enable('conn_abc123');
|
|
2881
|
+
* console.log(enabledAccount.isDisabled); // false
|
|
2882
|
+
* ```
|
|
2707
2883
|
*/
|
|
2708
2884
|
async enable(nanoid) {
|
|
2709
2885
|
return this.client.connectedAccounts.updateStatus(nanoid, { enabled: true });
|
|
@@ -2711,8 +2887,20 @@ var ConnectedAccounts = class {
|
|
|
2711
2887
|
/**
|
|
2712
2888
|
* Disable a connected account
|
|
2713
2889
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
2714
|
-
* @param {RequestOptions} options - Request options
|
|
2715
2890
|
* @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
|
|
2891
|
+
*
|
|
2892
|
+
* @example
|
|
2893
|
+
* ```typescript
|
|
2894
|
+
* // Disable a connected account
|
|
2895
|
+
* const disabledAccount = await composio.connectedAccounts.disable('conn_abc123');
|
|
2896
|
+
* console.log(disabledAccount.isDisabled); // true
|
|
2897
|
+
*
|
|
2898
|
+
* // You can also use updateStatus with a reason
|
|
2899
|
+
* // const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
|
|
2900
|
+
* // enabled: false,
|
|
2901
|
+
* // reason: 'No longer needed'
|
|
2902
|
+
* // });
|
|
2903
|
+
* ```
|
|
2716
2904
|
*/
|
|
2717
2905
|
async disable(nanoid) {
|
|
2718
2906
|
return this.client.connectedAccounts.updateStatus(nanoid, { enabled: false });
|
|
@@ -3689,10 +3877,54 @@ var BaseAgenticProvider = class extends BaseProvider {
|
|
|
3689
3877
|
var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
3690
3878
|
name = "openai";
|
|
3691
3879
|
/**
|
|
3692
|
-
*
|
|
3693
|
-
*
|
|
3694
|
-
*
|
|
3695
|
-
*
|
|
3880
|
+
* Creates a new instance of the OpenAIProvider.
|
|
3881
|
+
*
|
|
3882
|
+
* This is the default provider for the Composio SDK and is automatically
|
|
3883
|
+
* available without additional installation.
|
|
3884
|
+
*
|
|
3885
|
+
* @example
|
|
3886
|
+
* ```typescript
|
|
3887
|
+
* // The OpenAIProvider is used by default when initializing Composio
|
|
3888
|
+
* const composio = new Composio({
|
|
3889
|
+
* apiKey: 'your-api-key'
|
|
3890
|
+
* });
|
|
3891
|
+
*
|
|
3892
|
+
* // You can also explicitly specify it
|
|
3893
|
+
* const composio = new Composio({
|
|
3894
|
+
* apiKey: 'your-api-key',
|
|
3895
|
+
* provider: new OpenAIProvider()
|
|
3896
|
+
* });
|
|
3897
|
+
* ```
|
|
3898
|
+
*/
|
|
3899
|
+
constructor() {
|
|
3900
|
+
super();
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* Wraps a Composio tool in the OpenAI function calling format.
|
|
3904
|
+
*
|
|
3905
|
+
* This method transforms a Composio tool definition into the format
|
|
3906
|
+
* expected by OpenAI's function calling API.
|
|
3907
|
+
*
|
|
3908
|
+
* @param tool - The Composio tool to wrap
|
|
3909
|
+
* @returns The wrapped tool in OpenAI format
|
|
3910
|
+
*
|
|
3911
|
+
* @example
|
|
3912
|
+
* ```typescript
|
|
3913
|
+
* // Wrap a single tool for use with OpenAI
|
|
3914
|
+
* const composioTool = {
|
|
3915
|
+
* slug: 'SEARCH_TOOL',
|
|
3916
|
+
* description: 'Search for information',
|
|
3917
|
+
* inputParameters: {
|
|
3918
|
+
* type: 'object',
|
|
3919
|
+
* properties: {
|
|
3920
|
+
* query: { type: 'string' }
|
|
3921
|
+
* },
|
|
3922
|
+
* required: ['query']
|
|
3923
|
+
* }
|
|
3924
|
+
* };
|
|
3925
|
+
*
|
|
3926
|
+
* const openAITool = provider.wrapTool(composioTool);
|
|
3927
|
+
* ```
|
|
3696
3928
|
*/
|
|
3697
3929
|
wrapTool = (tool) => {
|
|
3698
3930
|
const formattedSchema = {
|
|
@@ -3705,14 +3937,78 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
3705
3937
|
function: formattedSchema
|
|
3706
3938
|
};
|
|
3707
3939
|
};
|
|
3940
|
+
/**
|
|
3941
|
+
* Wraps multiple Composio tools in the OpenAI function calling format.
|
|
3942
|
+
*
|
|
3943
|
+
* This method transforms a list of Composio tools into the format
|
|
3944
|
+
* expected by OpenAI's function calling API.
|
|
3945
|
+
*
|
|
3946
|
+
* @param tools - Array of Composio tools to wrap
|
|
3947
|
+
* @returns Array of wrapped tools in OpenAI format
|
|
3948
|
+
*
|
|
3949
|
+
* @example
|
|
3950
|
+
* ```typescript
|
|
3951
|
+
* // Wrap multiple tools for use with OpenAI
|
|
3952
|
+
* const composioTools = [
|
|
3953
|
+
* {
|
|
3954
|
+
* slug: 'SEARCH_TOOL',
|
|
3955
|
+
* description: 'Search for information',
|
|
3956
|
+
* inputParameters: {
|
|
3957
|
+
* type: 'object',
|
|
3958
|
+
* properties: {
|
|
3959
|
+
* query: { type: 'string' }
|
|
3960
|
+
* }
|
|
3961
|
+
* }
|
|
3962
|
+
* },
|
|
3963
|
+
* {
|
|
3964
|
+
* slug: 'WEATHER_TOOL',
|
|
3965
|
+
* description: 'Get weather information',
|
|
3966
|
+
* inputParameters: {
|
|
3967
|
+
* type: 'object',
|
|
3968
|
+
* properties: {
|
|
3969
|
+
* location: { type: 'string' }
|
|
3970
|
+
* }
|
|
3971
|
+
* }
|
|
3972
|
+
* }
|
|
3973
|
+
* ];
|
|
3974
|
+
*
|
|
3975
|
+
* const openAITools = provider.wrapTools(composioTools);
|
|
3976
|
+
* ```
|
|
3977
|
+
*/
|
|
3708
3978
|
wrapTools = (tools) => {
|
|
3709
3979
|
return tools.map((tool) => this.wrapTool(tool));
|
|
3710
3980
|
};
|
|
3711
3981
|
/**
|
|
3712
|
-
*
|
|
3713
|
-
*
|
|
3714
|
-
*
|
|
3715
|
-
*
|
|
3982
|
+
* Executes a tool call from OpenAI's chat completion.
|
|
3983
|
+
*
|
|
3984
|
+
* This method processes a tool call from OpenAI's chat completion API,
|
|
3985
|
+
* executes the corresponding Composio tool, and returns the result.
|
|
3986
|
+
*
|
|
3987
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
3988
|
+
* @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool call from OpenAI
|
|
3989
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
3990
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
3991
|
+
* @returns {Promise<string>} The result of the tool call as a JSON string
|
|
3992
|
+
*
|
|
3993
|
+
* @example
|
|
3994
|
+
* ```typescript
|
|
3995
|
+
* // Execute a tool call from OpenAI
|
|
3996
|
+
* const toolCall = {
|
|
3997
|
+
* id: 'call_abc123',
|
|
3998
|
+
* type: 'function',
|
|
3999
|
+
* function: {
|
|
4000
|
+
* name: 'SEARCH_TOOL',
|
|
4001
|
+
* arguments: '{"query":"composio documentation"}'
|
|
4002
|
+
* }
|
|
4003
|
+
* };
|
|
4004
|
+
*
|
|
4005
|
+
* const result = await provider.executeToolCall(
|
|
4006
|
+
* 'user123',
|
|
4007
|
+
* toolCall,
|
|
4008
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
4009
|
+
* );
|
|
4010
|
+
* console.log(JSON.parse(result));
|
|
4011
|
+
* ```
|
|
3716
4012
|
*/
|
|
3717
4013
|
async executeToolCall(userId, tool, options, modifiers) {
|
|
3718
4014
|
const payload = {
|
|
@@ -3725,11 +4021,46 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
3725
4021
|
return JSON.stringify(result);
|
|
3726
4022
|
}
|
|
3727
4023
|
/**
|
|
3728
|
-
*
|
|
4024
|
+
* Handles tool calls from OpenAI's chat completion response.
|
|
3729
4025
|
*
|
|
3730
|
-
*
|
|
3731
|
-
*
|
|
3732
|
-
*
|
|
4026
|
+
* This method processes tool calls from an OpenAI chat completion response,
|
|
4027
|
+
* executes each tool call, and returns the results.
|
|
4028
|
+
*
|
|
4029
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
4030
|
+
* @param {OpenAI.ChatCompletion} chatCompletion - The chat completion response from OpenAI
|
|
4031
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
4032
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
4033
|
+
* @returns {Promise<string[]>} Array of tool execution results as JSON strings
|
|
4034
|
+
*
|
|
4035
|
+
* @example
|
|
4036
|
+
* ```typescript
|
|
4037
|
+
* // Handle tool calls from a chat completion response
|
|
4038
|
+
* const chatCompletion = {
|
|
4039
|
+
* choices: [
|
|
4040
|
+
* {
|
|
4041
|
+
* message: {
|
|
4042
|
+
* tool_calls: [
|
|
4043
|
+
* {
|
|
4044
|
+
* id: 'call_abc123',
|
|
4045
|
+
* type: 'function',
|
|
4046
|
+
* function: {
|
|
4047
|
+
* name: 'SEARCH_TOOL',
|
|
4048
|
+
* arguments: '{"query":"composio documentation"}'
|
|
4049
|
+
* }
|
|
4050
|
+
* }
|
|
4051
|
+
* ]
|
|
4052
|
+
* }
|
|
4053
|
+
* }
|
|
4054
|
+
* ]
|
|
4055
|
+
* };
|
|
4056
|
+
*
|
|
4057
|
+
* const results = await provider.handleToolCalls(
|
|
4058
|
+
* 'user123',
|
|
4059
|
+
* chatCompletion,
|
|
4060
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
4061
|
+
* );
|
|
4062
|
+
* console.log(results); // Array of tool execution results
|
|
4063
|
+
* ```
|
|
3733
4064
|
*/
|
|
3734
4065
|
async handleToolCalls(userId, chatCompletion, options, modifiers) {
|
|
3735
4066
|
const outputs = [];
|
|
@@ -3743,11 +4074,51 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
3743
4074
|
return outputs;
|
|
3744
4075
|
}
|
|
3745
4076
|
/**
|
|
3746
|
-
* Handles all the tool calls from the
|
|
4077
|
+
* Handles all the tool calls from the OpenAI Assistant API.
|
|
3747
4078
|
*
|
|
3748
|
-
*
|
|
3749
|
-
*
|
|
3750
|
-
*
|
|
4079
|
+
* This method processes tool calls from an OpenAI Assistant run,
|
|
4080
|
+
* executes each tool call, and returns the tool outputs for submission.
|
|
4081
|
+
*
|
|
4082
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
4083
|
+
* @param {OpenAI.Beta.Threads.Run} run - The Assistant run object containing tool calls
|
|
4084
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
4085
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
4086
|
+
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
|
|
4087
|
+
*
|
|
4088
|
+
* @example
|
|
4089
|
+
* ```typescript
|
|
4090
|
+
* // Handle tool calls from an OpenAI Assistant run
|
|
4091
|
+
* const run = {
|
|
4092
|
+
* id: 'run_abc123',
|
|
4093
|
+
* required_action: {
|
|
4094
|
+
* submit_tool_outputs: {
|
|
4095
|
+
* tool_calls: [
|
|
4096
|
+
* {
|
|
4097
|
+
* id: 'call_xyz789',
|
|
4098
|
+
* type: 'function',
|
|
4099
|
+
* function: {
|
|
4100
|
+
* name: 'SEARCH_TOOL',
|
|
4101
|
+
* arguments: '{"query":"composio documentation"}'
|
|
4102
|
+
* }
|
|
4103
|
+
* }
|
|
4104
|
+
* ]
|
|
4105
|
+
* }
|
|
4106
|
+
* }
|
|
4107
|
+
* };
|
|
4108
|
+
*
|
|
4109
|
+
* const toolOutputs = await provider.handleAssistantMessage(
|
|
4110
|
+
* 'user123',
|
|
4111
|
+
* run,
|
|
4112
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
4113
|
+
* );
|
|
4114
|
+
*
|
|
4115
|
+
* // Submit tool outputs back to OpenAI
|
|
4116
|
+
* await openai.beta.threads.runs.submitToolOutputs(
|
|
4117
|
+
* thread.id,
|
|
4118
|
+
* run.id,
|
|
4119
|
+
* { tool_outputs: toolOutputs }
|
|
4120
|
+
* );
|
|
4121
|
+
* ```
|
|
3751
4122
|
*/
|
|
3752
4123
|
async handleAssistantMessage(userId, run, options, modifiers) {
|
|
3753
4124
|
const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
|
|
@@ -3772,11 +4143,43 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
3772
4143
|
/**
|
|
3773
4144
|
* Waits for the assistant stream and handles the tool calls.
|
|
3774
4145
|
*
|
|
3775
|
-
*
|
|
3776
|
-
*
|
|
3777
|
-
*
|
|
3778
|
-
*
|
|
3779
|
-
* @
|
|
4146
|
+
* This method processes an OpenAI Assistant stream, handles any tool calls
|
|
4147
|
+
* that require action, and yields each event from the stream. It's designed
|
|
4148
|
+
* for streaming Assistant responses while handling tool calls in real-time.
|
|
4149
|
+
*
|
|
4150
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
4151
|
+
* @param {OpenAI} client - The OpenAI client instance
|
|
4152
|
+
* @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
|
|
4153
|
+
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
4154
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
4155
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
4156
|
+
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
|
|
4157
|
+
*
|
|
4158
|
+
* @example
|
|
4159
|
+
* ```typescript
|
|
4160
|
+
* // Process an OpenAI Assistant stream with tool calls
|
|
4161
|
+
* const thread = await openai.beta.threads.create();
|
|
4162
|
+
* const runStream = openai.beta.threads.runs.stream(thread.id, {
|
|
4163
|
+
* assistant_id: 'asst_abc123',
|
|
4164
|
+
* tools: provider.wrapTools(composioTools)
|
|
4165
|
+
* });
|
|
4166
|
+
*
|
|
4167
|
+
* // Process the stream and handle tool calls
|
|
4168
|
+
* const streamProcessor = provider.waitAndHandleAssistantStreamToolCalls(
|
|
4169
|
+
* 'user123',
|
|
4170
|
+
* openai,
|
|
4171
|
+
* runStream,
|
|
4172
|
+
* thread,
|
|
4173
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
4174
|
+
* );
|
|
4175
|
+
*
|
|
4176
|
+
* // Consume the stream events
|
|
4177
|
+
* for await (const event of streamProcessor) {
|
|
4178
|
+
* if (event.event === 'thread.message.delta') {
|
|
4179
|
+
* console.log(event.data.delta.content);
|
|
4180
|
+
* }
|
|
4181
|
+
* }
|
|
4182
|
+
* ```
|
|
3780
4183
|
*/
|
|
3781
4184
|
async *waitAndHandleAssistantStreamToolCalls(userId, client, runStream, thread, options, modifiers) {
|
|
3782
4185
|
let runId = null;
|
|
@@ -3828,11 +4231,45 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
3828
4231
|
/**
|
|
3829
4232
|
* Waits for the assistant tool calls and handles them.
|
|
3830
4233
|
*
|
|
3831
|
-
*
|
|
3832
|
-
*
|
|
3833
|
-
*
|
|
3834
|
-
*
|
|
3835
|
-
* @
|
|
4234
|
+
* This method polls an OpenAI Assistant run until it completes or requires action,
|
|
4235
|
+
* handles any tool calls, and returns the final run object. It's designed for
|
|
4236
|
+
* non-streaming Assistant interactions.
|
|
4237
|
+
*
|
|
4238
|
+
* @param {string} userId - The user ID for authentication and tracking
|
|
4239
|
+
* @param {OpenAI} client - The OpenAI client instance
|
|
4240
|
+
* @param {OpenAI.Beta.Threads.Run} run - The initial run object
|
|
4241
|
+
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
4242
|
+
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
4243
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
4244
|
+
* @returns {Promise<OpenAI.Beta.Threads.Run>} The final run object after completion
|
|
4245
|
+
*
|
|
4246
|
+
* @example
|
|
4247
|
+
* ```typescript
|
|
4248
|
+
* // Process an OpenAI Assistant run with tool calls
|
|
4249
|
+
* const thread = await openai.beta.threads.create();
|
|
4250
|
+
* await openai.beta.threads.messages.create(thread.id, {
|
|
4251
|
+
* role: 'user',
|
|
4252
|
+
* content: 'Find information about Composio'
|
|
4253
|
+
* });
|
|
4254
|
+
*
|
|
4255
|
+
* let run = await openai.beta.threads.runs.create(thread.id, {
|
|
4256
|
+
* assistant_id: 'asst_abc123',
|
|
4257
|
+
* tools: provider.wrapTools(composioTools)
|
|
4258
|
+
* });
|
|
4259
|
+
*
|
|
4260
|
+
* // Wait for the run to complete, handling any tool calls
|
|
4261
|
+
* run = await provider.waitAndHandleAssistantToolCalls(
|
|
4262
|
+
* 'user123',
|
|
4263
|
+
* openai,
|
|
4264
|
+
* run,
|
|
4265
|
+
* thread,
|
|
4266
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
4267
|
+
* );
|
|
4268
|
+
*
|
|
4269
|
+
* // Get the final messages after run completion
|
|
4270
|
+
* const messages = await openai.beta.threads.messages.list(thread.id);
|
|
4271
|
+
* console.log(messages.data[0].content);
|
|
4272
|
+
* ```
|
|
3836
4273
|
*/
|
|
3837
4274
|
async waitAndHandleAssistantToolCalls(userId, client, run, thread, options, modifiers) {
|
|
3838
4275
|
while (["queued", "in_progress", "requires_action"].includes(run.status)) {
|
|
@@ -3851,7 +4288,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
3851
4288
|
};
|
|
3852
4289
|
|
|
3853
4290
|
// package.json
|
|
3854
|
-
var version = "0.1.12-alpha.
|
|
4291
|
+
var version = "0.1.12-alpha.16";
|
|
3855
4292
|
|
|
3856
4293
|
// src/composio.ts
|
|
3857
4294
|
var Composio = class {
|
|
@@ -3877,13 +4314,36 @@ var Composio = class {
|
|
|
3877
4314
|
// connected accounts
|
|
3878
4315
|
connectedAccounts;
|
|
3879
4316
|
/**
|
|
3880
|
-
*
|
|
3881
|
-
*
|
|
3882
|
-
*
|
|
3883
|
-
*
|
|
3884
|
-
*
|
|
3885
|
-
* @param {
|
|
3886
|
-
* @param {
|
|
4317
|
+
* Creates a new instance of the Composio SDK.
|
|
4318
|
+
*
|
|
4319
|
+
* The constructor initializes the SDK with the provided configuration options,
|
|
4320
|
+
* sets up the API client, and initializes all core models (tools, toolkits, etc.).
|
|
4321
|
+
*
|
|
4322
|
+
* @param {ComposioConfig<TProvider>} config - Configuration options for the Composio SDK
|
|
4323
|
+
* @param {string} [config.apiKey] - The API key for authenticating with the Composio API
|
|
4324
|
+
* @param {string} [config.baseURL] - The base URL for the Composio API (defaults to production URL)
|
|
4325
|
+
* @param {boolean} [config.allowTracking=true] - Whether to allow anonymous usage analytics
|
|
4326
|
+
* @param {boolean} [config.allowTracing=true] - Whether to allow request tracing for debugging
|
|
4327
|
+
* @param {TProvider} [config.provider] - The provider to use for this Composio instance (defaults to OpenAIProvider)
|
|
4328
|
+
* @param {BaseTelemetryTransport} [config.telemetryTransport] - Custom telemetry transport implementation
|
|
4329
|
+
*
|
|
4330
|
+
* @example
|
|
4331
|
+
* ```typescript
|
|
4332
|
+
* // Initialize with default configuration
|
|
4333
|
+
* const composio = new Composio();
|
|
4334
|
+
*
|
|
4335
|
+
* // Initialize with custom API key and base URL
|
|
4336
|
+
* const composio = new Composio({
|
|
4337
|
+
* apiKey: 'your-api-key',
|
|
4338
|
+
* baseURL: 'https://api.composio.dev'
|
|
4339
|
+
* });
|
|
4340
|
+
*
|
|
4341
|
+
* // Initialize with custom provider
|
|
4342
|
+
* const composio = new Composio({
|
|
4343
|
+
* apiKey: 'your-api-key',
|
|
4344
|
+
* provider: new CustomProvider()
|
|
4345
|
+
* });
|
|
4346
|
+
* ```
|
|
3887
4347
|
*/
|
|
3888
4348
|
constructor(config) {
|
|
3889
4349
|
const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(
|