@composio/core 0.1.12-alpha.15 → 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 +487 -406
- package/dist/index.d.cts +113 -101
- package/dist/index.d.ts +113 -101
- package/dist/index.js +487 -406
- package/package.json +1 -1
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,7 +1132,7 @@ 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
|
|
879
|
-
*
|
|
1135
|
+
*
|
|
880
1136
|
* @example
|
|
881
1137
|
* ```typescript
|
|
882
1138
|
* // Create a custom tool with input parameters
|
|
@@ -924,6 +1180,8 @@ var CustomTools = class {
|
|
|
924
1180
|
properties: {}
|
|
925
1181
|
},
|
|
926
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.
|
|
927
1185
|
toolkit: { name: "custom", slug: "custom" }
|
|
928
1186
|
};
|
|
929
1187
|
this.customToolsRegistry.set(slug.toLowerCase(), {
|
|
@@ -936,12 +1194,12 @@ var CustomTools = class {
|
|
|
936
1194
|
* Get all the custom tools from the registry.
|
|
937
1195
|
* @param {string[]} param0.toolSlugs The slugs of the tools to get
|
|
938
1196
|
* @returns {ToolList} The list of tools
|
|
939
|
-
*
|
|
1197
|
+
*
|
|
940
1198
|
* @example
|
|
941
1199
|
* ```typescript
|
|
942
1200
|
* // Get all custom tools
|
|
943
1201
|
* const allTools = await composio.customTools.getCustomTools({});
|
|
944
|
-
*
|
|
1202
|
+
*
|
|
945
1203
|
* // Get specific custom tools by slug
|
|
946
1204
|
* const specificTools = await composio.customTools.getCustomTools({
|
|
947
1205
|
* toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
|
|
@@ -966,7 +1224,7 @@ var CustomTools = class {
|
|
|
966
1224
|
* Get a custom tool by slug from the registry.
|
|
967
1225
|
* @param {string} slug The slug of the tool to get
|
|
968
1226
|
* @returns {Tool} The tool
|
|
969
|
-
*
|
|
1227
|
+
*
|
|
970
1228
|
* @example
|
|
971
1229
|
* ```typescript
|
|
972
1230
|
* // Get a specific custom tool by its slug
|
|
@@ -996,7 +1254,7 @@ var CustomTools = class {
|
|
|
996
1254
|
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
997
1255
|
* @returns {ConnectedAccount} The connected account
|
|
998
1256
|
*/
|
|
999
|
-
async
|
|
1257
|
+
async getConnectedAccountForToolkit(toolkitSlug, userId, connectedAccountId) {
|
|
1000
1258
|
try {
|
|
1001
1259
|
await this.client.toolkits.retrieve(toolkitSlug);
|
|
1002
1260
|
} catch (error) {
|
|
@@ -1006,43 +1264,92 @@ var CustomTools = class {
|
|
|
1006
1264
|
}
|
|
1007
1265
|
const connectedAccounts = await this.client.connectedAccounts.list({
|
|
1008
1266
|
toolkit_slugs: [toolkitSlug],
|
|
1009
|
-
user_ids: [
|
|
1267
|
+
user_ids: [userId]
|
|
1010
1268
|
});
|
|
1011
1269
|
if (!connectedAccounts.items.length) {
|
|
1012
1270
|
throw new ComposioConnectedAccountNotFoundError(
|
|
1013
1271
|
`No connected accounts found for toolkit ${toolkitSlug}`
|
|
1014
1272
|
);
|
|
1015
1273
|
}
|
|
1016
|
-
|
|
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;
|
|
1017
1309
|
}
|
|
1018
1310
|
/**
|
|
1019
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
|
+
*
|
|
1020
1317
|
* @param {slug} slug The slug of the tool to execute
|
|
1021
1318
|
* @param {Record<string, unknown>} inputParams The input parameters for the tool
|
|
1022
1319
|
* @param {ExecuteMetadata} metadata The metadata of the execution
|
|
1023
1320
|
* @returns {Promise<ToolExecuteResponse>} The response from the tool
|
|
1024
1321
|
*/
|
|
1025
|
-
async executeCustomTool(slug,
|
|
1322
|
+
async executeCustomTool(slug, body) {
|
|
1026
1323
|
const tool = this.customToolsRegistry.get(slug.toLowerCase());
|
|
1027
1324
|
if (!tool) {
|
|
1028
1325
|
throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
|
|
1029
1326
|
}
|
|
1030
1327
|
let authCredentials = {};
|
|
1031
|
-
const { toolkitSlug, execute } = tool.options;
|
|
1328
|
+
const { toolkitSlug, execute, inputParams } = tool.options;
|
|
1329
|
+
let connectedAccountId = body.connectedAccountId;
|
|
1032
1330
|
if (toolkitSlug && toolkitSlug !== "custom") {
|
|
1033
|
-
const connectedAccount = await this.
|
|
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
|
+
);
|
|
1034
1340
|
if (!connectedAccount) {
|
|
1035
1341
|
throw new ComposioConnectedAccountNotFoundError(
|
|
1036
|
-
`Connected account not found for toolkit ${toolkitSlug} for user ${
|
|
1342
|
+
`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`,
|
|
1037
1343
|
{
|
|
1038
1344
|
meta: {
|
|
1039
1345
|
toolkitSlug,
|
|
1040
|
-
userId:
|
|
1346
|
+
userId: body.userId
|
|
1041
1347
|
}
|
|
1042
1348
|
}
|
|
1043
1349
|
);
|
|
1044
1350
|
}
|
|
1045
|
-
authCredentials = connectedAccount.data
|
|
1351
|
+
authCredentials = connectedAccount.data;
|
|
1352
|
+
connectedAccountId = connectedAccount.id;
|
|
1046
1353
|
}
|
|
1047
1354
|
if (typeof execute !== "function") {
|
|
1048
1355
|
throw new ComposioInvalidExecuteFunctionError("Invalid execute function", {
|
|
@@ -1052,63 +1359,36 @@ var CustomTools = class {
|
|
|
1052
1359
|
});
|
|
1053
1360
|
}
|
|
1054
1361
|
const executeToolRequest = async (data) => {
|
|
1055
|
-
|
|
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({
|
|
1056
1374
|
...data,
|
|
1057
|
-
connected_account_id:
|
|
1375
|
+
connected_account_id: connectedAccountId
|
|
1058
1376
|
});
|
|
1377
|
+
return {
|
|
1378
|
+
data: response.data,
|
|
1379
|
+
error: null,
|
|
1380
|
+
successful: true,
|
|
1381
|
+
logId: void 0,
|
|
1382
|
+
sessionInfo: void 0
|
|
1383
|
+
};
|
|
1059
1384
|
};
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
// src/errors/ValidationErrors.ts
|
|
1069
|
-
import { ZodError as ZodError2 } from "zod";
|
|
1070
|
-
var ValidationErrorCodes = {
|
|
1071
|
-
VALIDATION_ERROR: "VALIDATION_ERROR"
|
|
1072
|
-
};
|
|
1073
|
-
var ValidationError = class extends ComposioError {
|
|
1074
|
-
constructor(message = "Input validation failed", options = {}) {
|
|
1075
|
-
const { cause: providedZodError, ...restOptions } = options;
|
|
1076
|
-
let zodErrorInstance;
|
|
1077
|
-
if (providedZodError instanceof ZodError2) {
|
|
1078
|
-
zodErrorInstance = providedZodError;
|
|
1079
|
-
} else {
|
|
1080
|
-
zodErrorInstance = new ZodError2([
|
|
1081
|
-
{
|
|
1082
|
-
path: [],
|
|
1083
|
-
message: "Invalid input",
|
|
1084
|
-
code: "custom"
|
|
1085
|
-
}
|
|
1086
|
-
]);
|
|
1087
|
-
}
|
|
1088
|
-
const issues = zodErrorInstance.issues.map(
|
|
1089
|
-
(issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`
|
|
1090
|
-
);
|
|
1091
|
-
super(message, {
|
|
1092
|
-
...restOptions,
|
|
1093
|
-
code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
|
|
1094
|
-
possibleFixes: issues,
|
|
1095
|
-
cause: zodErrorInstance
|
|
1096
|
-
});
|
|
1097
|
-
this.name = "ValidationError";
|
|
1098
|
-
const userFriendlyMessage = this.generateUserFriendlyMessage();
|
|
1099
|
-
this.message = `${message}: ${userFriendlyMessage}`;
|
|
1100
|
-
}
|
|
1101
|
-
generateUserFriendlyMessage() {
|
|
1102
|
-
if (this.cause instanceof ZodError2 && this.cause.issues.length > 0) {
|
|
1103
|
-
const issue = this.cause.issues[0];
|
|
1104
|
-
const path = issue.path.join(".");
|
|
1105
|
-
const param = path || "parameter";
|
|
1106
|
-
if (issue.code === "invalid_type") {
|
|
1107
|
-
return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
|
|
1108
|
-
}
|
|
1109
|
-
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
|
+
});
|
|
1110
1390
|
}
|
|
1111
|
-
return
|
|
1391
|
+
return execute(parsedInput.data, authCredentials, executeToolRequest);
|
|
1112
1392
|
}
|
|
1113
1393
|
};
|
|
1114
1394
|
|
|
@@ -1334,7 +1614,10 @@ var Tools = class {
|
|
|
1334
1614
|
async getRawComposioToolBySlug(userId, slug, modifier) {
|
|
1335
1615
|
const customTool = await this.customTools.getCustomToolBySlug(slug);
|
|
1336
1616
|
if (customTool) {
|
|
1617
|
+
logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
|
|
1337
1618
|
return customTool;
|
|
1619
|
+
} else {
|
|
1620
|
+
logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
|
|
1338
1621
|
}
|
|
1339
1622
|
let tool;
|
|
1340
1623
|
try {
|
|
@@ -1412,10 +1695,7 @@ var Tools = class {
|
|
|
1412
1695
|
throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
1413
1696
|
}
|
|
1414
1697
|
}
|
|
1415
|
-
let result = await this.customTools.executeCustomTool(tool.slug, body
|
|
1416
|
-
userId: body.userId || "default",
|
|
1417
|
-
connectedAccountId: body.connectedAccountId
|
|
1418
|
-
});
|
|
1698
|
+
let result = await this.customTools.executeCustomTool(tool.slug, body);
|
|
1419
1699
|
if (modifiers?.afterExecute) {
|
|
1420
1700
|
if (typeof modifiers.afterExecute === "function") {
|
|
1421
1701
|
result = await modifiers.afterExecute(tool.slug, "unknown", result);
|
|
@@ -1555,7 +1835,7 @@ var Tools = class {
|
|
|
1555
1835
|
* @param {string} slug - The ID of the tool to find input for
|
|
1556
1836
|
* @param {ToolGetInputParams} body - The parameters to be passed to the tool
|
|
1557
1837
|
* @returns {Promise<ToolGetInputResponse>} The input parameters schema for the specified tool
|
|
1558
|
-
*
|
|
1838
|
+
*
|
|
1559
1839
|
* @example
|
|
1560
1840
|
* ```typescript
|
|
1561
1841
|
* // Get input parameters for a specific tool
|
|
@@ -1570,13 +1850,13 @@ var Tools = class {
|
|
|
1570
1850
|
}
|
|
1571
1851
|
/**
|
|
1572
1852
|
* Proxies a custom request to a toolkit/integration.
|
|
1573
|
-
*
|
|
1853
|
+
*
|
|
1574
1854
|
* This method allows sending custom requests to a specific toolkit or integration
|
|
1575
1855
|
* when you need more flexibility than the standard tool execution methods provide.
|
|
1576
1856
|
*
|
|
1577
1857
|
* @param {ToolProxyParams} body - The parameters for the proxy request including toolkit slug and custom data
|
|
1578
1858
|
* @returns {Promise<ToolProxyResponse>} The response from the proxied request
|
|
1579
|
-
*
|
|
1859
|
+
*
|
|
1580
1860
|
* @example
|
|
1581
1861
|
* ```typescript
|
|
1582
1862
|
* // Send a custom request to a toolkit
|
|
@@ -1605,29 +1885,39 @@ var Tools = class {
|
|
|
1605
1885
|
*
|
|
1606
1886
|
* @example
|
|
1607
1887
|
* ```typescript
|
|
1608
|
-
*
|
|
1888
|
+
* // creating a custom tool with a toolkit
|
|
1889
|
+
* await composio.tools.createCustomTool({
|
|
1609
1890
|
* name: 'My Custom Tool',
|
|
1610
1891
|
* description: 'A custom tool that does something specific',
|
|
1611
1892
|
* slug: 'MY_CUSTOM_TOOL',
|
|
1612
|
-
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1619
|
-
* outputParameters: {
|
|
1620
|
-
* result: {
|
|
1621
|
-
* type: 'string',
|
|
1622
|
-
* description: 'The result of the operation'
|
|
1623
|
-
* }
|
|
1624
|
-
* },
|
|
1625
|
-
* 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) => {
|
|
1626
1900
|
* // Custom logic here
|
|
1627
1901
|
* return { data: { result: 'Success!' } };
|
|
1628
1902
|
* }
|
|
1629
1903
|
* });
|
|
1630
1904
|
* ```
|
|
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
|
+
* });
|
|
1631
1921
|
*/
|
|
1632
1922
|
async createCustomTool(body) {
|
|
1633
1923
|
return this.customTools.createTool(body);
|
|
@@ -1638,183 +1928,87 @@ var Tools = class {
|
|
|
1638
1928
|
import ComposioClient2 from "@composio/client";
|
|
1639
1929
|
|
|
1640
1930
|
// src/types/toolkit.types.ts
|
|
1641
|
-
import { z as
|
|
1642
|
-
var ToolkitMangedByEnumSchema =
|
|
1643
|
-
var ToolkitSortByEnumSchema =
|
|
1644
|
-
var ToolkitsListParamsSchema =
|
|
1645
|
-
category:
|
|
1646
|
-
isLocal:
|
|
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(),
|
|
1647
1937
|
managedBy: ToolkitMangedByEnumSchema.optional(),
|
|
1648
1938
|
sortBy: ToolkitSortByEnumSchema.optional()
|
|
1649
1939
|
});
|
|
1650
|
-
var ToolKitMetaSchema =
|
|
1651
|
-
categories:
|
|
1652
|
-
|
|
1653
|
-
slug:
|
|
1654
|
-
name:
|
|
1940
|
+
var ToolKitMetaSchema = z3.object({
|
|
1941
|
+
categories: z3.array(
|
|
1942
|
+
z3.object({
|
|
1943
|
+
slug: z3.string(),
|
|
1944
|
+
name: z3.string()
|
|
1655
1945
|
})
|
|
1656
1946
|
).optional(),
|
|
1657
|
-
appUrl:
|
|
1658
|
-
createdAt:
|
|
1659
|
-
description:
|
|
1660
|
-
logo:
|
|
1661
|
-
toolsCount:
|
|
1662
|
-
triggersCount:
|
|
1663
|
-
updatedAt:
|
|
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()
|
|
1664
1954
|
});
|
|
1665
|
-
var ToolKitItemSchema =
|
|
1666
|
-
name:
|
|
1667
|
-
slug:
|
|
1955
|
+
var ToolKitItemSchema = z3.object({
|
|
1956
|
+
name: z3.string(),
|
|
1957
|
+
slug: z3.string(),
|
|
1668
1958
|
meta: ToolKitMetaSchema,
|
|
1669
|
-
isLocalToolkit:
|
|
1670
|
-
authSchemes:
|
|
1671
|
-
composioManagedAuthSchemes:
|
|
1672
|
-
noAuth:
|
|
1959
|
+
isLocalToolkit: z3.boolean(),
|
|
1960
|
+
authSchemes: z3.array(z3.string()).optional(),
|
|
1961
|
+
composioManagedAuthSchemes: z3.array(z3.string()).optional(),
|
|
1962
|
+
noAuth: z3.boolean().optional()
|
|
1673
1963
|
});
|
|
1674
|
-
var ToolKitListResponseSchema =
|
|
1675
|
-
items:
|
|
1676
|
-
nextCursor:
|
|
1677
|
-
totalPages:
|
|
1964
|
+
var ToolKitListResponseSchema = z3.object({
|
|
1965
|
+
items: z3.array(ToolKitItemSchema),
|
|
1966
|
+
nextCursor: z3.string().nullable(),
|
|
1967
|
+
totalPages: z3.number()
|
|
1678
1968
|
});
|
|
1679
|
-
var ToolkitAuthFieldSchema =
|
|
1680
|
-
name:
|
|
1681
|
-
displayName:
|
|
1682
|
-
type:
|
|
1683
|
-
default:
|
|
1969
|
+
var ToolkitAuthFieldSchema = z3.object({
|
|
1970
|
+
name: z3.string(),
|
|
1971
|
+
displayName: z3.string(),
|
|
1972
|
+
type: z3.string(),
|
|
1973
|
+
default: z3.string().nullable().optional()
|
|
1684
1974
|
});
|
|
1685
|
-
var ToolkitAuthConfigDetailsSchema =
|
|
1686
|
-
name:
|
|
1687
|
-
mode:
|
|
1688
|
-
fields:
|
|
1689
|
-
authConfigCreation:
|
|
1690
|
-
optional:
|
|
1691
|
-
required:
|
|
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)
|
|
1692
1982
|
}),
|
|
1693
|
-
connectedAccountInitiation:
|
|
1694
|
-
optional:
|
|
1695
|
-
required:
|
|
1983
|
+
connectedAccountInitiation: z3.object({
|
|
1984
|
+
optional: z3.array(ToolkitAuthFieldSchema),
|
|
1985
|
+
required: z3.array(ToolkitAuthFieldSchema)
|
|
1696
1986
|
})
|
|
1697
1987
|
}),
|
|
1698
|
-
proxy:
|
|
1699
|
-
baseUrl:
|
|
1988
|
+
proxy: z3.object({
|
|
1989
|
+
baseUrl: z3.string().optional()
|
|
1700
1990
|
}).optional()
|
|
1701
1991
|
});
|
|
1702
|
-
var ToolkitRetrieveResponseSchema =
|
|
1703
|
-
name:
|
|
1704
|
-
slug:
|
|
1992
|
+
var ToolkitRetrieveResponseSchema = z3.object({
|
|
1993
|
+
name: z3.string(),
|
|
1994
|
+
slug: z3.string(),
|
|
1705
1995
|
meta: ToolKitMetaSchema,
|
|
1706
|
-
isLocalToolkit:
|
|
1707
|
-
composioManagedAuthSchemes:
|
|
1708
|
-
authConfigDetails:
|
|
1996
|
+
isLocalToolkit: z3.boolean(),
|
|
1997
|
+
composioManagedAuthSchemes: z3.array(z3.string()).optional(),
|
|
1998
|
+
authConfigDetails: z3.array(ToolkitAuthConfigDetailsSchema).optional()
|
|
1709
1999
|
});
|
|
1710
|
-
var ToolkitCategorySchema =
|
|
1711
|
-
id:
|
|
1712
|
-
name:
|
|
2000
|
+
var ToolkitCategorySchema = z3.object({
|
|
2001
|
+
id: z3.string(),
|
|
2002
|
+
name: z3.string()
|
|
1713
2003
|
});
|
|
1714
|
-
var ToolkitRetrieveCategoriesResponseSchema =
|
|
1715
|
-
items:
|
|
1716
|
-
nextCursor:
|
|
1717
|
-
totalPages:
|
|
2004
|
+
var ToolkitRetrieveCategoriesResponseSchema = z3.object({
|
|
2005
|
+
items: z3.array(ToolkitCategorySchema),
|
|
2006
|
+
nextCursor: z3.string().nullable(),
|
|
2007
|
+
totalPages: z3.number()
|
|
1718
2008
|
});
|
|
1719
2009
|
|
|
1720
|
-
// src/errors/AuthConfigErrors.ts
|
|
1721
|
-
var AuthConfigErrorCodes = {
|
|
1722
|
-
AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
|
|
1723
|
-
};
|
|
1724
|
-
var ComposioAuthConfigNotFoundError = class extends ComposioError {
|
|
1725
|
-
constructor(message = "Auth config not found", options = {}) {
|
|
1726
|
-
super(message, {
|
|
1727
|
-
...options,
|
|
1728
|
-
code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
|
|
1729
|
-
possibleFixes: options.possibleFixes || [
|
|
1730
|
-
"Check if the auth config exists",
|
|
1731
|
-
"Check if the auth config id is correct",
|
|
1732
|
-
"Check if the auth config is enabled"
|
|
1733
|
-
]
|
|
1734
|
-
});
|
|
1735
|
-
this.name = "ComposioAuthConfigNotFoundError";
|
|
1736
|
-
}
|
|
1737
|
-
};
|
|
1738
|
-
|
|
1739
|
-
// src/errors/ConnectionRequestErrors.ts
|
|
1740
|
-
var ConnectionRequestErrorCodes = {
|
|
1741
|
-
CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
|
|
1742
|
-
CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
|
|
1743
|
-
};
|
|
1744
|
-
var ConnectionRequestTimeoutError = class extends ComposioError {
|
|
1745
|
-
constructor(message = "Connection request timed out", options = {}) {
|
|
1746
|
-
super(message, {
|
|
1747
|
-
...options,
|
|
1748
|
-
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
|
|
1749
|
-
});
|
|
1750
|
-
this.name = "ConnectionRequestTimeoutError";
|
|
1751
|
-
}
|
|
1752
|
-
};
|
|
1753
|
-
var ConnectionRequestFailedError = class extends ComposioError {
|
|
1754
|
-
constructor(message = "Connection request failed", options = {}) {
|
|
1755
|
-
super(message, {
|
|
1756
|
-
...options,
|
|
1757
|
-
code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
|
|
1758
|
-
});
|
|
1759
|
-
this.name = "ConnectionRequestFailedError";
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
|
-
// src/errors/ToolkitErrors.ts
|
|
1764
|
-
var ToolkitErrorCodes = {
|
|
1765
|
-
TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND"
|
|
1766
|
-
};
|
|
1767
|
-
var ComposioToolkitNotFoundError = class extends ComposioError {
|
|
1768
|
-
constructor(message = "Toolkit not found", options = {}) {
|
|
1769
|
-
super(message, {
|
|
1770
|
-
...options,
|
|
1771
|
-
code: "TOOLKIT_NOT_FOUND",
|
|
1772
|
-
possibleFixes: options.possibleFixes || [
|
|
1773
|
-
"Ensure the toolkit is correctly configured and the slug is valid"
|
|
1774
|
-
]
|
|
1775
|
-
});
|
|
1776
|
-
this.name = "ComposioToolkitNotFoundError";
|
|
1777
|
-
}
|
|
1778
|
-
};
|
|
1779
|
-
var ComposioToolkitFetchError = class extends ComposioError {
|
|
1780
|
-
constructor(message = "Failed to fetch toolkit", options = {}) {
|
|
1781
|
-
super(message, {
|
|
1782
|
-
...options,
|
|
1783
|
-
code: "TOOLKIT_FETCH_ERROR",
|
|
1784
|
-
possibleFixes: options.possibleFixes || [
|
|
1785
|
-
"Ensure the toolkit slug is valid",
|
|
1786
|
-
"Ensure you are using the correct API key",
|
|
1787
|
-
"Ensure you are using the correct API endpoint / Base URL and it is working"
|
|
1788
|
-
]
|
|
1789
|
-
});
|
|
1790
|
-
this.name = "ComposioToolkitFetchError";
|
|
1791
|
-
}
|
|
1792
|
-
};
|
|
1793
|
-
|
|
1794
|
-
// src/errors/SDKErrors.ts
|
|
1795
|
-
var SDKErrorCodes = {
|
|
1796
|
-
NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED"
|
|
1797
|
-
};
|
|
1798
|
-
var ComposioNoAPIKeyError = class extends ComposioError {
|
|
1799
|
-
constructor(message = "No Composio API key provided", options = {}) {
|
|
1800
|
-
const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
|
|
1801
|
-
super(message, {
|
|
1802
|
-
...options,
|
|
1803
|
-
code: "NO_API_KEY",
|
|
1804
|
-
cause: options.cause || defaultCause,
|
|
1805
|
-
possibleFixes: options.possibleFixes || [
|
|
1806
|
-
"Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
|
|
1807
|
-
"To get an API key, please sign up at https://composio.dev/signup",
|
|
1808
|
-
"You can also use the Composio CLI to create a project and get an API key"
|
|
1809
|
-
],
|
|
1810
|
-
statusCode: 401
|
|
1811
|
-
});
|
|
1812
|
-
this.name = "ComposioNoAPIKeyError";
|
|
1813
|
-
}
|
|
1814
|
-
};
|
|
1815
|
-
|
|
1816
2010
|
// src/types/authConfigs.types.ts
|
|
1817
|
-
import { z as
|
|
2011
|
+
import { z as z4 } from "zod";
|
|
1818
2012
|
var AuthConfigTypes = {
|
|
1819
2013
|
CUSTOM: "use_custom_auth",
|
|
1820
2014
|
COMPOSIO_MANAGED: "use_composio_managed_auth"
|
|
@@ -1834,7 +2028,7 @@ var AuthSchemeTypes = {
|
|
|
1834
2028
|
CALCOM_AUTH: "CALCOM_AUTH",
|
|
1835
2029
|
SNOWFLAKE: "SNOWFLAKE"
|
|
1836
2030
|
};
|
|
1837
|
-
var AuthSchemeEnum =
|
|
2031
|
+
var AuthSchemeEnum = z4.enum([
|
|
1838
2032
|
"OAUTH2",
|
|
1839
2033
|
"OAUTH1",
|
|
1840
2034
|
"OAUTH1A",
|
|
@@ -1849,67 +2043,67 @@ var AuthSchemeEnum = z3.enum([
|
|
|
1849
2043
|
"CALCOM_AUTH",
|
|
1850
2044
|
"SNOWFLAKE"
|
|
1851
2045
|
]);
|
|
1852
|
-
var CreateCustomAuthConfigParamsSchema =
|
|
1853
|
-
type:
|
|
1854
|
-
name:
|
|
1855
|
-
credentials:
|
|
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()])),
|
|
1856
2050
|
authScheme: AuthSchemeEnum
|
|
1857
2051
|
});
|
|
1858
|
-
var CreateComposioManagedAuthConfigParamsSchema =
|
|
1859
|
-
type:
|
|
1860
|
-
name:
|
|
1861
|
-
credentials:
|
|
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()
|
|
1862
2056
|
});
|
|
1863
|
-
var CreateAuthConfigParamsSchema =
|
|
2057
|
+
var CreateAuthConfigParamsSchema = z4.discriminatedUnion("type", [
|
|
1864
2058
|
CreateCustomAuthConfigParamsSchema,
|
|
1865
2059
|
CreateComposioManagedAuthConfigParamsSchema
|
|
1866
2060
|
]);
|
|
1867
|
-
var CreateAuthConfigResponseSchema =
|
|
1868
|
-
id:
|
|
1869
|
-
authScheme:
|
|
1870
|
-
isComposioManaged:
|
|
1871
|
-
toolkit:
|
|
2061
|
+
var CreateAuthConfigResponseSchema = z4.object({
|
|
2062
|
+
id: z4.string(),
|
|
2063
|
+
authScheme: z4.string(),
|
|
2064
|
+
isComposioManaged: z4.boolean(),
|
|
2065
|
+
toolkit: z4.string()
|
|
1872
2066
|
});
|
|
1873
|
-
var AuthConfigRetrieveResponseSchema =
|
|
1874
|
-
id:
|
|
1875
|
-
name:
|
|
1876
|
-
toolkit:
|
|
1877
|
-
logo:
|
|
1878
|
-
slug:
|
|
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()
|
|
1879
2073
|
}),
|
|
1880
|
-
noOfConnections:
|
|
1881
|
-
status:
|
|
1882
|
-
uuid:
|
|
2074
|
+
noOfConnections: z4.number(),
|
|
2075
|
+
status: z4.enum(["ENABLED", "DISABLED"]),
|
|
2076
|
+
uuid: z4.string(),
|
|
1883
2077
|
authScheme: AuthSchemeEnum.optional(),
|
|
1884
|
-
credentials:
|
|
1885
|
-
expectedInputFields:
|
|
1886
|
-
isComposioManaged:
|
|
1887
|
-
createdBy:
|
|
1888
|
-
createdAt:
|
|
1889
|
-
lastUpdatedAt:
|
|
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()
|
|
1890
2084
|
});
|
|
1891
|
-
var AuthConfigListParamsSchema =
|
|
1892
|
-
cursor:
|
|
1893
|
-
isComposioManaged:
|
|
1894
|
-
limit:
|
|
1895
|
-
toolkit:
|
|
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()
|
|
1896
2090
|
});
|
|
1897
|
-
var AuthConfigListResponseSchema =
|
|
1898
|
-
items:
|
|
1899
|
-
nextCursor:
|
|
1900
|
-
totalPages:
|
|
2091
|
+
var AuthConfigListResponseSchema = z4.object({
|
|
2092
|
+
items: z4.array(AuthConfigRetrieveResponseSchema),
|
|
2093
|
+
nextCursor: z4.string().nullable(),
|
|
2094
|
+
totalPages: z4.number()
|
|
1901
2095
|
});
|
|
1902
|
-
var AuthCustomConfigUpdateParamsSchema =
|
|
1903
|
-
credentials:
|
|
1904
|
-
type:
|
|
1905
|
-
restrictToFollowingTools:
|
|
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()
|
|
1906
2100
|
});
|
|
1907
|
-
var AuthDefaultConfigUpdateParamsSchema =
|
|
1908
|
-
scopes:
|
|
1909
|
-
type:
|
|
1910
|
-
restrictToFollowingTools:
|
|
2101
|
+
var AuthDefaultConfigUpdateParamsSchema = z4.object({
|
|
2102
|
+
scopes: z4.string(),
|
|
2103
|
+
type: z4.literal("default"),
|
|
2104
|
+
restrictToFollowingTools: z4.array(z4.string()).optional()
|
|
1911
2105
|
});
|
|
1912
|
-
var AuthConfigUpdateParamsSchema =
|
|
2106
|
+
var AuthConfigUpdateParamsSchema = z4.discriminatedUnion("type", [
|
|
1913
2107
|
AuthCustomConfigUpdateParamsSchema,
|
|
1914
2108
|
AuthDefaultConfigUpdateParamsSchema
|
|
1915
2109
|
]);
|
|
@@ -2216,119 +2410,6 @@ var AuthConfigs = class {
|
|
|
2216
2410
|
}
|
|
2217
2411
|
};
|
|
2218
2412
|
|
|
2219
|
-
// src/types/connectedAccounts.types.ts
|
|
2220
|
-
import { z as z4 } from "zod";
|
|
2221
|
-
var ConnectedAccountStatuses = {
|
|
2222
|
-
INITIALIZING: "INITIALIZING",
|
|
2223
|
-
INITIATED: "INITIATED",
|
|
2224
|
-
ACTIVE: "ACTIVE",
|
|
2225
|
-
FAILED: "FAILED",
|
|
2226
|
-
EXPIRED: "EXPIRED"
|
|
2227
|
-
};
|
|
2228
|
-
var ConnectedAccountStatusSchema = z4.enum([
|
|
2229
|
-
ConnectedAccountStatuses.INITIALIZING,
|
|
2230
|
-
ConnectedAccountStatuses.INITIATED,
|
|
2231
|
-
ConnectedAccountStatuses.ACTIVE,
|
|
2232
|
-
ConnectedAccountStatuses.FAILED,
|
|
2233
|
-
ConnectedAccountStatuses.EXPIRED
|
|
2234
|
-
]);
|
|
2235
|
-
var CreateConnectedAccountParamsSchema = z4.object({
|
|
2236
|
-
authConfig: z4.object({
|
|
2237
|
-
id: z4.string()
|
|
2238
|
-
}),
|
|
2239
|
-
connection: z4.object({
|
|
2240
|
-
data: z4.record(z4.string(), z4.unknown()).optional(),
|
|
2241
|
-
callbackUrl: z4.string().optional(),
|
|
2242
|
-
userId: z4.string().optional()
|
|
2243
|
-
})
|
|
2244
|
-
});
|
|
2245
|
-
var DefaultCreateConnectedAccountParamsSchema = z4.object({
|
|
2246
|
-
auth_config: z4.object({
|
|
2247
|
-
id: z4.string()
|
|
2248
|
-
}),
|
|
2249
|
-
connection: z4.object({
|
|
2250
|
-
data: z4.record(z4.string(), z4.unknown()).optional(),
|
|
2251
|
-
callback_url: z4.string().optional(),
|
|
2252
|
-
user_id: z4.string().optional()
|
|
2253
|
-
})
|
|
2254
|
-
});
|
|
2255
|
-
var CreateConnectedAccountOptionsSchema = z4.object({
|
|
2256
|
-
callbackUrl: z4.string().optional(),
|
|
2257
|
-
data: z4.record(z4.string(), z4.unknown()).optional()
|
|
2258
|
-
});
|
|
2259
|
-
var CreateConnectedAccountResponseSchema = z4.object({
|
|
2260
|
-
id: z4.string(),
|
|
2261
|
-
status: ConnectedAccountStatusSchema,
|
|
2262
|
-
redirectUrl: z4.string().nullable()
|
|
2263
|
-
});
|
|
2264
|
-
var ConnectedAccountAuthSchemes = {
|
|
2265
|
-
OAUTH2: "OAUTH2",
|
|
2266
|
-
OAUTH1: "OAUTH1",
|
|
2267
|
-
OAUTH1A: "OAUTH1A",
|
|
2268
|
-
API_KEY: "API_KEY",
|
|
2269
|
-
BASIC: "BASIC",
|
|
2270
|
-
BILLCOM_AUTH: "BILLCOM_AUTH",
|
|
2271
|
-
BEARER_TOKEN: "BEARER_TOKEN",
|
|
2272
|
-
GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
|
|
2273
|
-
NO_AUTH: "NO_AUTH",
|
|
2274
|
-
BASIC_WITH_JWT: "BASIC_WITH_JWT",
|
|
2275
|
-
COMPOSIO_LINK: "COMPOSIO_LINK",
|
|
2276
|
-
CALCOM_AUTH: "CALCOM_AUTH",
|
|
2277
|
-
SNOWFLAKE: "SNOWFLAKE"
|
|
2278
|
-
};
|
|
2279
|
-
var ConnectedAccountAuthSchemesSchema = z4.enum([
|
|
2280
|
-
ConnectedAccountAuthSchemes.OAUTH2,
|
|
2281
|
-
ConnectedAccountAuthSchemes.OAUTH1,
|
|
2282
|
-
ConnectedAccountAuthSchemes.OAUTH1A,
|
|
2283
|
-
ConnectedAccountAuthSchemes.API_KEY,
|
|
2284
|
-
ConnectedAccountAuthSchemes.BASIC,
|
|
2285
|
-
ConnectedAccountAuthSchemes.BILLCOM_AUTH,
|
|
2286
|
-
ConnectedAccountAuthSchemes.BEARER_TOKEN,
|
|
2287
|
-
ConnectedAccountAuthSchemes.GOOGLE_SERVICE_ACCOUNT,
|
|
2288
|
-
ConnectedAccountAuthSchemes.NO_AUTH,
|
|
2289
|
-
ConnectedAccountAuthSchemes.BASIC_WITH_JWT,
|
|
2290
|
-
ConnectedAccountAuthSchemes.COMPOSIO_LINK,
|
|
2291
|
-
ConnectedAccountAuthSchemes.CALCOM_AUTH,
|
|
2292
|
-
ConnectedAccountAuthSchemes.SNOWFLAKE
|
|
2293
|
-
]);
|
|
2294
|
-
var ConnectedAccountAuthConfigSchema = z4.object({
|
|
2295
|
-
id: z4.string(),
|
|
2296
|
-
authScheme: ConnectedAccountAuthSchemesSchema,
|
|
2297
|
-
isComposioManaged: z4.boolean(),
|
|
2298
|
-
isDisabled: z4.boolean()
|
|
2299
|
-
});
|
|
2300
|
-
var ConnectedAccountRetrieveResponseSchema = z4.object({
|
|
2301
|
-
id: z4.string(),
|
|
2302
|
-
authConfig: ConnectedAccountAuthConfigSchema,
|
|
2303
|
-
userId: z4.string(),
|
|
2304
|
-
data: z4.record(z4.string(), z4.unknown()),
|
|
2305
|
-
params: z4.record(z4.string(), z4.unknown()).optional(),
|
|
2306
|
-
status: ConnectedAccountStatusSchema,
|
|
2307
|
-
statusReason: z4.string().nullable(),
|
|
2308
|
-
toolkit: z4.object({
|
|
2309
|
-
slug: z4.string()
|
|
2310
|
-
}),
|
|
2311
|
-
testRequestEndpoint: z4.string().optional(),
|
|
2312
|
-
isDisabled: z4.boolean(),
|
|
2313
|
-
createdAt: z4.string(),
|
|
2314
|
-
updatedAt: z4.string()
|
|
2315
|
-
});
|
|
2316
|
-
var ConnectedAccountListParamsSchema = z4.object({
|
|
2317
|
-
authConfigIds: z4.array(z4.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
|
|
2318
|
-
cursor: z4.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
|
|
2319
|
-
labels: z4.array(z4.string()).nullable().optional().describe("The labels of the connected accounts"),
|
|
2320
|
-
limit: z4.number().nullable().optional().describe("The limit of the connected accounts to return"),
|
|
2321
|
-
orderBy: z4.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
|
|
2322
|
-
statuses: z4.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
|
|
2323
|
-
toolkitSlugs: z4.array(z4.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
|
|
2324
|
-
userIds: z4.array(z4.string()).nullable().optional().describe("The user ids of the connected accounts")
|
|
2325
|
-
});
|
|
2326
|
-
var ConnectedAccountListResponseSchema = z4.object({
|
|
2327
|
-
items: z4.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
|
|
2328
|
-
nextCursor: z4.string().nullable().describe("The next cursor to paginate through the connected accounts"),
|
|
2329
|
-
totalPages: z4.number().describe("The total number of pages of connected accounts")
|
|
2330
|
-
});
|
|
2331
|
-
|
|
2332
2413
|
// src/models/ConnectionRequest.ts
|
|
2333
2414
|
import ComposioClient from "@composio/client";
|
|
2334
2415
|
import { ZodError as ZodError3 } from "zod";
|
|
@@ -4144,7 +4225,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4144
4225
|
};
|
|
4145
4226
|
|
|
4146
4227
|
// package.json
|
|
4147
|
-
var version = "0.1.12-alpha.
|
|
4228
|
+
var version = "0.1.12-alpha.16";
|
|
4148
4229
|
|
|
4149
4230
|
// src/composio.ts
|
|
4150
4231
|
var Composio = class {
|