@composio/core 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var ParametersSchema = z.object({
39
39
  required: z.array(z.string()).optional(),
40
40
  title: z.string().optional(),
41
41
  description: z.string().optional(),
42
- additionalProperties: z.boolean().optional()
42
+ additionalProperties: z.boolean().default(false).optional()
43
43
  });
44
44
  var ToolSchema = z.object({
45
45
  slug: z.string().describe('The slug of the tool. eg. "GOOGLE_SEARCH"'),
@@ -114,7 +114,7 @@ var ToolProxyParamsSchema = z.object({
114
114
  name: z.string(),
115
115
  value: z.union([z.string(), z.number()])
116
116
  })
117
- ),
117
+ ).optional(),
118
118
  connectedAccountId: z.string().optional()
119
119
  });
120
120
 
@@ -873,7 +873,411 @@ var TelemetryService = class {
873
873
  var telemetry = new TelemetryService();
874
874
 
875
875
  // src/types/connectedAccounts.types.ts
876
+ import { z as z3 } from "zod";
877
+
878
+ // src/types/connectedAccountAuthStates.types.ts
876
879
  import { z as z2 } from "zod";
880
+ var AUTH_MODES_ENUM = {
881
+ OAUTH2: "OAUTH2",
882
+ OAUTH1: "OAUTH1",
883
+ API_KEY: "API_KEY",
884
+ BASIC: "BASIC",
885
+ BILLCOM_AUTH: "BILLCOM_AUTH",
886
+ BEARER_TOKEN: "BEARER_TOKEN",
887
+ GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
888
+ NO_AUTH: "NO_AUTH",
889
+ BASIC_WITH_JWT: "BASIC_WITH_JWT",
890
+ COMPOSIO_LINK_AUTH: "COMPOSIO_LINK",
891
+ CALCOM_AUTH: "CALCOM_AUTH",
892
+ SNOWFLAKE: "SNOWFLAKE"
893
+ };
894
+ var RedirectableAuthSchemeSchema = z2.enum([
895
+ AUTH_MODES_ENUM.OAUTH1,
896
+ AUTH_MODES_ENUM.OAUTH2,
897
+ AUTH_MODES_ENUM.COMPOSIO_LINK_AUTH
898
+ ]);
899
+ var BaseSchemeRaw = z2.object({
900
+ // for posthog, freshdesk, zendesk, clickup and others
901
+ subdomain: z2.string().optional(),
902
+ // for atlassian
903
+ ["your-domain"]: z2.string().optional(),
904
+ // for mixpanel
905
+ region: z2.string().optional(),
906
+ // for shopify
907
+ shop: z2.string().optional(),
908
+ // for snowflake
909
+ account_url: z2.string().optional(),
910
+ // likely pipedrive
911
+ COMPANYDOMAIN: z2.string().optional(),
912
+ // likely zoho
913
+ extension: z2.string().optional(),
914
+ // likely formsite
915
+ form_api_base_url: z2.string().optional(),
916
+ // likely salesforce
917
+ instanceEndpoint: z2.string().optional(),
918
+ // likely active campaign
919
+ api_url: z2.string().optional(),
920
+ // for borneo
921
+ borneo_dashboard_url: z2.string().optional(),
922
+ // for zenrows proxy
923
+ proxy_username: z2.string().optional(),
924
+ proxy_password: z2.string().optional(),
925
+ // for d2l
926
+ domain: z2.string().optional(),
927
+ version: z2.string().optional(),
928
+ // for mailchimp
929
+ dc: z2.string().optional(),
930
+ // for sharepoint
931
+ site_name: z2.string().optional(),
932
+ // for servicenow
933
+ instanceName: z2.string().optional(),
934
+ // for netsuite
935
+ account_id: z2.string().optional(),
936
+ // for custom servers
937
+ your_server: z2.string().optional(),
938
+ // for ragic
939
+ server_location: z2.string().optional(),
940
+ // base_url only
941
+ base_url: z2.string().optional()
942
+ });
943
+ var Oauth2InitiatingConnectionDataSchema = BaseSchemeRaw.extend({
944
+ status: z2.literal("INITIALIZING" /* INITIALIZING */)
945
+ }).catchall(z2.unknown());
946
+ var Oauth2InitiatedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
947
+ status: z2.literal("INITIATED" /* INITIATED */),
948
+ code_verifier: z2.string().optional(),
949
+ redirectUrl: z2.string(),
950
+ callback_url: z2.string().optional(),
951
+ finalRedirectUri: z2.string().optional(),
952
+ // previously verification_token, will be sent as verification_token to slack
953
+ webhook_signature: z2.string().optional()
954
+ }).catchall(z2.unknown());
955
+ var Oauth2ActiveConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
956
+ status: z2.literal("ACTIVE" /* ACTIVE */),
957
+ access_token: z2.string(),
958
+ id_token: z2.string().optional(),
959
+ token_type: z2.string(),
960
+ refresh_token: z2.string().optional(),
961
+ expires_in: z2.number().optional(),
962
+ scope: z2.string().optional(),
963
+ // previously verification_token, will be sent as verification_token to slack
964
+ webhook_signature: z2.string().optional(),
965
+ authed_user: z2.object({
966
+ access_token: z2.string().optional(),
967
+ scope: z2.string().optional()
968
+ }).optional().describe("for slack user scopes")
969
+ }).catchall(z2.unknown());
970
+ var Oauth2FailedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
971
+ status: z2.literal("FAILED" /* FAILED */),
972
+ error: z2.string().optional(),
973
+ error_description: z2.string().optional()
974
+ }).catchall(z2.unknown());
975
+ var Oauth2ExpiredConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
976
+ status: z2.literal("EXPIRED" /* EXPIRED */),
977
+ expired_at: z2.string().optional()
978
+ }).catchall(z2.unknown());
979
+ var Oauth2ConnectionDataSchema = z2.discriminatedUnion("status", [
980
+ Oauth2InitiatingConnectionDataSchema,
981
+ Oauth2InitiatedConnectionDataSchema,
982
+ Oauth2ActiveConnectionDataSchema,
983
+ Oauth2FailedConnectionDataSchema,
984
+ Oauth2ExpiredConnectionDataSchema
985
+ ]);
986
+ var Oauth1InitiatingConnectionDataSchema = BaseSchemeRaw.extend({
987
+ status: z2.literal("INITIALIZING" /* INITIALIZING */)
988
+ }).catchall(z2.unknown());
989
+ var Oauth1InitiatedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
990
+ status: z2.literal("INITIATED" /* INITIATED */),
991
+ oauth_token: z2.string(),
992
+ authUri: z2.string(),
993
+ oauth_token_secret: z2.string(),
994
+ redirectUrl: z2.string(),
995
+ callbackUrl: z2.string().optional()
996
+ }).catchall(z2.unknown());
997
+ var Oauth1ActiveConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
998
+ status: z2.literal("ACTIVE" /* ACTIVE */),
999
+ oauth_token: z2.string(),
1000
+ consumer_key: z2.string().optional(),
1001
+ redirectUrl: z2.string().optional(),
1002
+ callback_url: z2.string().optional()
1003
+ }).catchall(z2.unknown());
1004
+ var Oauth1FailedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
1005
+ status: z2.literal("FAILED" /* FAILED */),
1006
+ error: z2.string().optional(),
1007
+ error_description: z2.string().optional()
1008
+ }).catchall(z2.unknown());
1009
+ var Oauth1ExpiredConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
1010
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1011
+ expired_at: z2.string().optional()
1012
+ }).catchall(z2.unknown());
1013
+ var Oauth1ConnectionDataSchema = z2.discriminatedUnion("status", [
1014
+ Oauth1InitiatingConnectionDataSchema,
1015
+ Oauth1InitiatedConnectionDataSchema,
1016
+ Oauth1ActiveConnectionDataSchema,
1017
+ Oauth1FailedConnectionDataSchema,
1018
+ Oauth1ExpiredConnectionDataSchema
1019
+ ]);
1020
+ var ComposioLinkInitiatingSchema = BaseSchemeRaw.extend({
1021
+ status: z2.literal("INITIALIZING" /* INITIALIZING */)
1022
+ }).catchall(z2.unknown());
1023
+ var ComposioLinkConnectionDataSchema = z2.discriminatedUnion("status", [
1024
+ ComposioLinkInitiatingSchema,
1025
+ ComposioLinkInitiatingSchema.extend({
1026
+ status: z2.literal("INITIATED" /* INITIATED */),
1027
+ redirectUrl: z2.string()
1028
+ }).catchall(z2.unknown()),
1029
+ ComposioLinkInitiatingSchema.extend({
1030
+ status: z2.literal("ACTIVE" /* ACTIVE */)
1031
+ }).catchall(z2.unknown()),
1032
+ ComposioLinkInitiatingSchema.extend({
1033
+ status: z2.literal("FAILED" /* FAILED */),
1034
+ error: z2.string().optional(),
1035
+ error_description: z2.string().optional()
1036
+ }).catchall(z2.unknown()),
1037
+ ComposioLinkInitiatingSchema.extend({
1038
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1039
+ expired_at: z2.string().optional()
1040
+ }).catchall(z2.unknown())
1041
+ ]);
1042
+ var BillcomAuthInitiatingSchema = BaseSchemeRaw.extend({
1043
+ status: z2.literal("INITIALIZING" /* INITIALIZING */)
1044
+ }).catchall(z2.unknown());
1045
+ var BillcomAuthConnectionDataSchema = z2.discriminatedUnion("status", [
1046
+ BillcomAuthInitiatingSchema,
1047
+ BillcomAuthInitiatingSchema.extend({
1048
+ status: z2.literal("INITIATED" /* INITIATED */),
1049
+ redirectUrl: z2.string()
1050
+ }).catchall(z2.unknown()),
1051
+ BillcomAuthInitiatingSchema.extend({
1052
+ status: z2.literal("ACTIVE" /* ACTIVE */),
1053
+ sessionId: z2.string(),
1054
+ devKey: z2.string()
1055
+ }).catchall(z2.unknown()),
1056
+ BillcomAuthInitiatingSchema.extend({
1057
+ status: z2.literal("FAILED" /* FAILED */),
1058
+ error: z2.string().optional(),
1059
+ error_description: z2.string().optional()
1060
+ }).catchall(z2.unknown()),
1061
+ BillcomAuthInitiatingSchema.extend({
1062
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1063
+ expired_at: z2.string().optional()
1064
+ }).catchall(z2.unknown())
1065
+ ]);
1066
+ var BasicWithJwtInitiatingSchema = BaseSchemeRaw.extend({
1067
+ status: z2.literal("ACTIVE" /* ACTIVE */),
1068
+ username: z2.string(),
1069
+ password: z2.string()
1070
+ }).catchall(z2.unknown());
1071
+ var BasicWithJwtConnectionDataSchema = z2.discriminatedUnion("status", [
1072
+ BasicWithJwtInitiatingSchema,
1073
+ BasicWithJwtInitiatingSchema.extend({
1074
+ status: z2.literal("FAILED" /* FAILED */),
1075
+ error: z2.string().optional(),
1076
+ error_description: z2.string().optional()
1077
+ }).catchall(z2.unknown()),
1078
+ BasicWithJwtInitiatingSchema.extend({
1079
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1080
+ expired_at: z2.string().optional()
1081
+ }).catchall(z2.unknown())
1082
+ ]);
1083
+ var ApiKeyInitiatingSchema = BaseSchemeRaw.extend({
1084
+ status: z2.literal("ACTIVE" /* ACTIVE */),
1085
+ api_key: z2.string()
1086
+ }).catchall(z2.unknown());
1087
+ var ApiKeyConnectionDataSchema = z2.discriminatedUnion("status", [
1088
+ ApiKeyInitiatingSchema,
1089
+ ApiKeyInitiatingSchema.extend({
1090
+ status: z2.literal("FAILED" /* FAILED */),
1091
+ error: z2.string().optional(),
1092
+ error_description: z2.string().optional()
1093
+ }).catchall(z2.unknown()),
1094
+ ApiKeyInitiatingSchema.extend({
1095
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1096
+ expired_at: z2.string().optional()
1097
+ }).catchall(z2.unknown())
1098
+ ]);
1099
+ var BasicInitiatingSchema = BaseSchemeRaw.extend({
1100
+ status: z2.literal("ACTIVE" /* ACTIVE */),
1101
+ username: z2.string(),
1102
+ password: z2.string()
1103
+ }).catchall(z2.unknown());
1104
+ var BasicConnectionDataSchema = z2.discriminatedUnion("status", [
1105
+ BasicInitiatingSchema,
1106
+ BasicInitiatingSchema.extend({
1107
+ status: z2.literal("FAILED" /* FAILED */),
1108
+ error: z2.string().optional(),
1109
+ error_description: z2.string().optional()
1110
+ }).catchall(z2.unknown()),
1111
+ BasicInitiatingSchema.extend({
1112
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1113
+ expired_at: z2.string().optional()
1114
+ }).catchall(z2.unknown())
1115
+ ]);
1116
+ var BearerTokenInitiatingSchema = BaseSchemeRaw.extend({
1117
+ status: z2.literal("ACTIVE" /* ACTIVE */),
1118
+ token: z2.string()
1119
+ }).catchall(z2.unknown());
1120
+ var BearerTokenConnectionDataSchema = z2.discriminatedUnion("status", [
1121
+ BearerTokenInitiatingSchema,
1122
+ BearerTokenInitiatingSchema.extend({
1123
+ status: z2.literal("FAILED" /* FAILED */),
1124
+ error: z2.string().optional(),
1125
+ error_description: z2.string().optional()
1126
+ }).catchall(z2.unknown()),
1127
+ BearerTokenInitiatingSchema.extend({
1128
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1129
+ expired_at: z2.string().optional()
1130
+ }).catchall(z2.unknown())
1131
+ ]);
1132
+ var GoogleServiceAccountInitiatingSchema = BaseSchemeRaw.extend({
1133
+ status: z2.literal("ACTIVE" /* ACTIVE */),
1134
+ credentials_json: z2.string()
1135
+ }).catchall(z2.unknown());
1136
+ var GoogleServiceAccountConnectionDataSchema = z2.discriminatedUnion("status", [
1137
+ GoogleServiceAccountInitiatingSchema,
1138
+ GoogleServiceAccountInitiatingSchema.extend({
1139
+ status: z2.literal("FAILED" /* FAILED */),
1140
+ error: z2.string().optional(),
1141
+ error_description: z2.string().optional()
1142
+ }).catchall(z2.unknown()),
1143
+ GoogleServiceAccountInitiatingSchema.extend({
1144
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1145
+ expired_at: z2.string().optional()
1146
+ }).catchall(z2.unknown())
1147
+ ]);
1148
+ var NoAuthInitiatingSchema = BaseSchemeRaw.extend({
1149
+ status: z2.literal("ACTIVE" /* ACTIVE */)
1150
+ }).catchall(z2.unknown());
1151
+ var NoAuthConnectionDataSchema = z2.discriminatedUnion("status", [
1152
+ NoAuthInitiatingSchema,
1153
+ NoAuthInitiatingSchema.extend({
1154
+ status: z2.literal("FAILED" /* FAILED */),
1155
+ error: z2.string().optional(),
1156
+ error_description: z2.string().optional()
1157
+ }).catchall(z2.unknown()),
1158
+ NoAuthInitiatingSchema.extend({
1159
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1160
+ expired_at: z2.string().optional()
1161
+ }).catchall(z2.unknown())
1162
+ ]);
1163
+ var CalcomAuthInitiatingSchema = BaseSchemeRaw.extend({
1164
+ status: z2.literal("ACTIVE" /* ACTIVE */)
1165
+ }).catchall(z2.unknown());
1166
+ var CalcomAuthConnectionDataSchema = z2.discriminatedUnion("status", [
1167
+ CalcomAuthInitiatingSchema,
1168
+ CalcomAuthInitiatingSchema.extend({
1169
+ status: z2.literal("FAILED" /* FAILED */),
1170
+ error: z2.string().optional(),
1171
+ error_description: z2.string().optional()
1172
+ }).catchall(z2.unknown()),
1173
+ CalcomAuthInitiatingSchema.extend({
1174
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1175
+ expired_at: z2.string().optional()
1176
+ }).catchall(z2.unknown())
1177
+ ]);
1178
+ var SnowflakeInitiatingSchema = BaseSchemeRaw.extend({
1179
+ status: z2.literal("ACTIVE" /* ACTIVE */)
1180
+ }).catchall(z2.unknown());
1181
+ var SnowflakeConnectionDataSchema = z2.discriminatedUnion("status", [
1182
+ SnowflakeInitiatingSchema,
1183
+ SnowflakeInitiatingSchema.extend({
1184
+ status: z2.literal("FAILED" /* FAILED */),
1185
+ error: z2.string().optional(),
1186
+ error_description: z2.string().optional()
1187
+ }).catchall(z2.unknown()),
1188
+ SnowflakeInitiatingSchema.extend({
1189
+ status: z2.literal("EXPIRED" /* EXPIRED */),
1190
+ expired_at: z2.string().optional()
1191
+ }).catchall(z2.unknown())
1192
+ ]);
1193
+ var ConnectionDataSchema = z2.discriminatedUnion("authScheme", [
1194
+ z2.object({
1195
+ authScheme: z2.literal(AUTH_MODES_ENUM.OAUTH1),
1196
+ /**
1197
+ * the main connection data discriminated by auth scheme
1198
+ */
1199
+ val: Oauth1ConnectionDataSchema
1200
+ }),
1201
+ z2.object({
1202
+ authScheme: z2.literal(AUTH_MODES_ENUM.OAUTH2),
1203
+ /**
1204
+ * the main connection data discriminated by auth scheme
1205
+ */
1206
+ val: Oauth2ConnectionDataSchema
1207
+ }),
1208
+ z2.object({
1209
+ authScheme: z2.literal(AUTH_MODES_ENUM.COMPOSIO_LINK_AUTH),
1210
+ /**
1211
+ * the main connection data discriminated by auth scheme
1212
+ */
1213
+ val: ComposioLinkConnectionDataSchema
1214
+ }),
1215
+ z2.object({
1216
+ authScheme: z2.literal(AUTH_MODES_ENUM.API_KEY),
1217
+ /**
1218
+ * the main connection data discriminated by auth scheme
1219
+ */
1220
+ val: ApiKeyConnectionDataSchema
1221
+ }),
1222
+ z2.object({
1223
+ authScheme: z2.literal(AUTH_MODES_ENUM.BASIC),
1224
+ /**
1225
+ * the main connection data discriminated by auth scheme
1226
+ */
1227
+ val: BasicConnectionDataSchema
1228
+ }),
1229
+ z2.object({
1230
+ authScheme: z2.literal(AUTH_MODES_ENUM.BEARER_TOKEN),
1231
+ /**
1232
+ * the main connection data discriminated by auth scheme
1233
+ */
1234
+ val: BearerTokenConnectionDataSchema
1235
+ }),
1236
+ z2.object({
1237
+ authScheme: z2.literal(AUTH_MODES_ENUM.GOOGLE_SERVICE_ACCOUNT),
1238
+ /**
1239
+ * the main connection data discriminated by auth scheme
1240
+ */
1241
+ val: GoogleServiceAccountConnectionDataSchema
1242
+ }),
1243
+ z2.object({
1244
+ authScheme: z2.literal(AUTH_MODES_ENUM.NO_AUTH),
1245
+ /**
1246
+ * the main connection data discriminated by auth scheme
1247
+ */
1248
+ val: NoAuthConnectionDataSchema
1249
+ }),
1250
+ z2.object({
1251
+ authScheme: z2.literal(AUTH_MODES_ENUM.CALCOM_AUTH),
1252
+ /**
1253
+ * the main connection data discriminated by auth scheme
1254
+ */
1255
+ val: CalcomAuthConnectionDataSchema
1256
+ }),
1257
+ z2.object({
1258
+ authScheme: z2.literal(AUTH_MODES_ENUM.SNOWFLAKE),
1259
+ /**
1260
+ * the main connection data discriminated by auth scheme
1261
+ */
1262
+ val: SnowflakeConnectionDataSchema
1263
+ }),
1264
+ z2.object({
1265
+ authScheme: z2.literal(AUTH_MODES_ENUM.BILLCOM_AUTH),
1266
+ /**
1267
+ * the main connection data discriminated by auth scheme
1268
+ */
1269
+ val: BillcomAuthConnectionDataSchema
1270
+ }),
1271
+ z2.object({
1272
+ authScheme: z2.literal(AUTH_MODES_ENUM.BASIC_WITH_JWT),
1273
+ /**
1274
+ * the main connection data discriminated by auth scheme
1275
+ */
1276
+ val: BasicWithJwtConnectionDataSchema
1277
+ })
1278
+ ]);
1279
+
1280
+ // src/types/connectedAccounts.types.ts
877
1281
  var ConnectedAccountStatuses = {
878
1282
  INITIALIZING: "INITIALIZING",
879
1283
  INITIATED: "INITIATED",
@@ -881,41 +1285,42 @@ var ConnectedAccountStatuses = {
881
1285
  FAILED: "FAILED",
882
1286
  EXPIRED: "EXPIRED"
883
1287
  };
884
- var ConnectedAccountStatusSchema = z2.enum([
1288
+ var ConnectedAccountStatusSchema = z3.enum([
885
1289
  ConnectedAccountStatuses.INITIALIZING,
886
1290
  ConnectedAccountStatuses.INITIATED,
887
1291
  ConnectedAccountStatuses.ACTIVE,
888
1292
  ConnectedAccountStatuses.FAILED,
889
1293
  ConnectedAccountStatuses.EXPIRED
890
1294
  ]);
891
- var CreateConnectedAccountParamsSchema = z2.object({
892
- authConfig: z2.object({
893
- id: z2.string()
1295
+ var CreateConnectedAccountParamsSchema = z3.object({
1296
+ authConfig: z3.object({
1297
+ id: z3.string()
894
1298
  }),
895
- connection: z2.object({
896
- data: z2.record(z2.string(), z2.unknown()).optional(),
897
- callbackUrl: z2.string().optional(),
898
- userId: z2.string().optional()
1299
+ connection: z3.object({
1300
+ data: z3.record(z3.string(), z3.unknown()).optional(),
1301
+ callbackUrl: z3.string().optional(),
1302
+ userId: z3.string().optional()
899
1303
  })
900
1304
  });
901
- var DefaultCreateConnectedAccountParamsSchema = z2.object({
902
- auth_config: z2.object({
903
- id: z2.string()
1305
+ var DefaultCreateConnectedAccountParamsSchema = z3.object({
1306
+ auth_config: z3.object({
1307
+ id: z3.string()
904
1308
  }),
905
- connection: z2.object({
906
- data: z2.record(z2.string(), z2.unknown()).optional(),
907
- callback_url: z2.string().optional(),
908
- user_id: z2.string().optional()
1309
+ connection: z3.object({
1310
+ state: ConnectionDataSchema.optional(),
1311
+ data: z3.record(z3.string(), z3.unknown()).optional(),
1312
+ callback_url: z3.string().optional(),
1313
+ user_id: z3.string().optional()
909
1314
  })
910
1315
  });
911
- var CreateConnectedAccountOptionsSchema = z2.object({
912
- callbackUrl: z2.string().optional(),
913
- data: z2.record(z2.string(), z2.unknown()).optional()
1316
+ var CreateConnectedAccountOptionsSchema = z3.object({
1317
+ callbackUrl: z3.string().optional(),
1318
+ state: ConnectionDataSchema.optional()
914
1319
  });
915
- var CreateConnectedAccountResponseSchema = z2.object({
916
- id: z2.string(),
1320
+ var CreateConnectedAccountResponseSchema = z3.object({
1321
+ id: z3.string(),
917
1322
  status: ConnectedAccountStatusSchema,
918
- redirectUrl: z2.string().nullable()
1323
+ redirectUrl: z3.string().nullable()
919
1324
  });
920
1325
  var ConnectedAccountAuthSchemes = {
921
1326
  OAUTH2: "OAUTH2",
@@ -932,7 +1337,7 @@ var ConnectedAccountAuthSchemes = {
932
1337
  CALCOM_AUTH: "CALCOM_AUTH",
933
1338
  SNOWFLAKE: "SNOWFLAKE"
934
1339
  };
935
- var ConnectedAccountAuthSchemesSchema = z2.enum([
1340
+ var ConnectedAccountAuthSchemesSchema = z3.enum([
936
1341
  ConnectedAccountAuthSchemes.OAUTH2,
937
1342
  ConnectedAccountAuthSchemes.OAUTH1,
938
1343
  ConnectedAccountAuthSchemes.OAUTH1A,
@@ -947,42 +1352,41 @@ var ConnectedAccountAuthSchemesSchema = z2.enum([
947
1352
  ConnectedAccountAuthSchemes.CALCOM_AUTH,
948
1353
  ConnectedAccountAuthSchemes.SNOWFLAKE
949
1354
  ]);
950
- var ConnectedAccountAuthConfigSchema = z2.object({
951
- id: z2.string(),
952
- authScheme: ConnectedAccountAuthSchemesSchema,
953
- isComposioManaged: z2.boolean(),
954
- isDisabled: z2.boolean()
1355
+ var ConnectedAccountAuthConfigSchema = z3.object({
1356
+ id: z3.string(),
1357
+ isComposioManaged: z3.boolean(),
1358
+ isDisabled: z3.boolean()
955
1359
  });
956
- var ConnectedAccountRetrieveResponseSchema = z2.object({
957
- id: z2.string(),
1360
+ var ConnectedAccountRetrieveResponseSchema = z3.object({
1361
+ id: z3.string(),
958
1362
  authConfig: ConnectedAccountAuthConfigSchema,
959
- userId: z2.string(),
960
- data: z2.record(z2.string(), z2.unknown()),
961
- params: z2.record(z2.string(), z2.unknown()).optional(),
1363
+ data: z3.record(z3.string(), z3.unknown()),
1364
+ params: z3.record(z3.string(), z3.unknown()).optional(),
962
1365
  status: ConnectedAccountStatusSchema,
963
- statusReason: z2.string().nullable(),
964
- toolkit: z2.object({
965
- slug: z2.string()
1366
+ statusReason: z3.string().nullable(),
1367
+ toolkit: z3.object({
1368
+ slug: z3.string()
966
1369
  }),
967
- testRequestEndpoint: z2.string().optional(),
968
- isDisabled: z2.boolean(),
969
- createdAt: z2.string(),
970
- updatedAt: z2.string()
1370
+ state: ConnectionDataSchema.optional(),
1371
+ testRequestEndpoint: z3.string().optional(),
1372
+ isDisabled: z3.boolean(),
1373
+ createdAt: z3.string(),
1374
+ updatedAt: z3.string()
971
1375
  });
972
- var ConnectedAccountListParamsSchema = z2.object({
973
- authConfigIds: z2.array(z2.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
974
- cursor: z2.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
975
- labels: z2.array(z2.string()).nullable().optional().describe("The labels of the connected accounts"),
976
- limit: z2.number().nullable().optional().describe("The limit of the connected accounts to return"),
977
- orderBy: z2.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
978
- statuses: z2.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
979
- toolkitSlugs: z2.array(z2.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
980
- userIds: z2.array(z2.string()).nullable().optional().describe("The user ids of the connected accounts")
1376
+ var ConnectedAccountListParamsSchema = z3.object({
1377
+ authConfigIds: z3.array(z3.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
1378
+ cursor: z3.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
1379
+ labels: z3.array(z3.string()).nullable().optional().describe("The labels of the connected accounts"),
1380
+ limit: z3.number().nullable().optional().describe("The limit of the connected accounts to return"),
1381
+ orderBy: z3.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
1382
+ statuses: z3.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
1383
+ toolkitSlugs: z3.array(z3.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
1384
+ userIds: z3.array(z3.string()).nullable().optional().describe("The user ids of the connected accounts")
981
1385
  });
982
- var ConnectedAccountListResponseSchema = z2.object({
983
- items: z2.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
984
- nextCursor: z2.string().nullable().describe("The next cursor to paginate through the connected accounts"),
985
- totalPages: z2.number().describe("The total number of pages of connected accounts")
1386
+ var ConnectedAccountListResponseSchema = z3.object({
1387
+ items: z3.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
1388
+ nextCursor: z3.string().nullable().describe("The next cursor to paginate through the connected accounts"),
1389
+ totalPages: z3.number().describe("The total number of pages of connected accounts")
986
1390
  });
987
1391
 
988
1392
  // src/errors/AuthConfigErrors.ts
@@ -1062,7 +1466,8 @@ var ComposioToolkitFetchError = class extends ComposioError {
1062
1466
  // src/errors/ValidationErrors.ts
1063
1467
  import { ZodError as ZodError2 } from "zod";
1064
1468
  var ValidationErrorCodes = {
1065
- VALIDATION_ERROR: "VALIDATION_ERROR"
1469
+ VALIDATION_ERROR: "VALIDATION_ERROR",
1470
+ JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
1066
1471
  };
1067
1472
  var ValidationError = class extends ComposioError {
1068
1473
  constructor(message = "Input validation failed", options = {}) {
@@ -1105,6 +1510,14 @@ var ValidationError = class extends ComposioError {
1105
1510
  return "Please check your input parameters";
1106
1511
  }
1107
1512
  };
1513
+ var JsonSchemaToZodError = class extends ComposioError {
1514
+ constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
1515
+ super(message, {
1516
+ ...options,
1517
+ code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR
1518
+ });
1519
+ }
1520
+ };
1108
1521
 
1109
1522
  // src/errors/SDKErrors.ts
1110
1523
  var SDKErrorCodes = {
@@ -1751,7 +2164,7 @@ var Tools = class {
1751
2164
  connected_account_id: body.connectedAccountId,
1752
2165
  custom_auth_params: body.customAuthParams,
1753
2166
  arguments: body.arguments,
1754
- entity_id: body.userId,
2167
+ user_id: body.userId,
1755
2168
  version: body.version,
1756
2169
  text: body.text
1757
2170
  });
@@ -1973,87 +2386,87 @@ var Tools = class {
1973
2386
  import ComposioClient2 from "@composio/client";
1974
2387
 
1975
2388
  // src/types/toolkit.types.ts
1976
- import { z as z3 } from "zod";
1977
- var ToolkitMangedByEnumSchema = z3.enum(["all", "composio", "project"]);
1978
- var ToolkitSortByEnumSchema = z3.enum(["usage", "alphabetically"]);
1979
- var ToolkitsListParamsSchema = z3.object({
1980
- category: z3.string().optional(),
1981
- isLocal: z3.boolean().optional(),
2389
+ import { z as z4 } from "zod";
2390
+ var ToolkitMangedByEnumSchema = z4.enum(["all", "composio", "project"]);
2391
+ var ToolkitSortByEnumSchema = z4.enum(["usage", "alphabetically"]);
2392
+ var ToolkitsListParamsSchema = z4.object({
2393
+ category: z4.string().optional(),
2394
+ isLocal: z4.boolean().optional(),
1982
2395
  managedBy: ToolkitMangedByEnumSchema.optional(),
1983
2396
  sortBy: ToolkitSortByEnumSchema.optional()
1984
2397
  });
1985
- var ToolKitMetaSchema = z3.object({
1986
- categories: z3.array(
1987
- z3.object({
1988
- slug: z3.string(),
1989
- name: z3.string()
2398
+ var ToolKitMetaSchema = z4.object({
2399
+ categories: z4.array(
2400
+ z4.object({
2401
+ slug: z4.string(),
2402
+ name: z4.string()
1990
2403
  })
1991
2404
  ).optional(),
1992
- appUrl: z3.string().optional(),
1993
- createdAt: z3.string().optional(),
1994
- description: z3.string().optional(),
1995
- logo: z3.string().optional(),
1996
- toolsCount: z3.number().optional(),
1997
- triggersCount: z3.number().optional(),
1998
- updatedAt: z3.string().optional()
2405
+ appUrl: z4.string().optional(),
2406
+ createdAt: z4.string().optional(),
2407
+ description: z4.string().optional(),
2408
+ logo: z4.string().optional(),
2409
+ toolsCount: z4.number().optional(),
2410
+ triggersCount: z4.number().optional(),
2411
+ updatedAt: z4.string().optional()
1999
2412
  });
2000
- var ToolKitItemSchema = z3.object({
2001
- name: z3.string(),
2002
- slug: z3.string(),
2413
+ var ToolKitItemSchema = z4.object({
2414
+ name: z4.string(),
2415
+ slug: z4.string(),
2003
2416
  meta: ToolKitMetaSchema,
2004
- isLocalToolkit: z3.boolean(),
2005
- authSchemes: z3.array(z3.string()).optional(),
2006
- composioManagedAuthSchemes: z3.array(z3.string()).optional(),
2007
- noAuth: z3.boolean().optional()
2417
+ isLocalToolkit: z4.boolean(),
2418
+ authSchemes: z4.array(z4.string()).optional(),
2419
+ composioManagedAuthSchemes: z4.array(z4.string()).optional(),
2420
+ noAuth: z4.boolean().optional()
2008
2421
  });
2009
- var ToolKitListResponseSchema = z3.object({
2010
- items: z3.array(ToolKitItemSchema),
2011
- nextCursor: z3.string().nullable(),
2012
- totalPages: z3.number()
2422
+ var ToolKitListResponseSchema = z4.object({
2423
+ items: z4.array(ToolKitItemSchema),
2424
+ nextCursor: z4.string().nullable(),
2425
+ totalPages: z4.number()
2013
2426
  });
2014
- var ToolkitAuthFieldSchema = z3.object({
2015
- name: z3.string(),
2016
- displayName: z3.string(),
2017
- type: z3.string(),
2018
- default: z3.string().nullable().optional()
2427
+ var ToolkitAuthFieldSchema = z4.object({
2428
+ name: z4.string(),
2429
+ displayName: z4.string(),
2430
+ type: z4.string(),
2431
+ default: z4.string().nullable().optional()
2019
2432
  });
2020
- var ToolkitAuthConfigDetailsSchema = z3.object({
2021
- name: z3.string(),
2022
- mode: z3.string(),
2023
- fields: z3.object({
2024
- authConfigCreation: z3.object({
2025
- optional: z3.array(ToolkitAuthFieldSchema),
2026
- required: z3.array(ToolkitAuthFieldSchema)
2433
+ var ToolkitAuthConfigDetailsSchema = z4.object({
2434
+ name: z4.string(),
2435
+ mode: z4.string(),
2436
+ fields: z4.object({
2437
+ authConfigCreation: z4.object({
2438
+ optional: z4.array(ToolkitAuthFieldSchema),
2439
+ required: z4.array(ToolkitAuthFieldSchema)
2027
2440
  }),
2028
- connectedAccountInitiation: z3.object({
2029
- optional: z3.array(ToolkitAuthFieldSchema),
2030
- required: z3.array(ToolkitAuthFieldSchema)
2441
+ connectedAccountInitiation: z4.object({
2442
+ optional: z4.array(ToolkitAuthFieldSchema),
2443
+ required: z4.array(ToolkitAuthFieldSchema)
2031
2444
  })
2032
2445
  }),
2033
- proxy: z3.object({
2034
- baseUrl: z3.string().optional()
2446
+ proxy: z4.object({
2447
+ baseUrl: z4.string().optional()
2035
2448
  }).optional()
2036
2449
  });
2037
- var ToolkitRetrieveResponseSchema = z3.object({
2038
- name: z3.string(),
2039
- slug: z3.string(),
2450
+ var ToolkitRetrieveResponseSchema = z4.object({
2451
+ name: z4.string(),
2452
+ slug: z4.string(),
2040
2453
  meta: ToolKitMetaSchema,
2041
- isLocalToolkit: z3.boolean(),
2042
- composioManagedAuthSchemes: z3.array(z3.string()).optional(),
2043
- authConfigDetails: z3.array(ToolkitAuthConfigDetailsSchema).optional()
2454
+ isLocalToolkit: z4.boolean(),
2455
+ composioManagedAuthSchemes: z4.array(z4.string()).optional(),
2456
+ authConfigDetails: z4.array(ToolkitAuthConfigDetailsSchema).optional()
2044
2457
  });
2045
- var ToolkitCategorySchema = z3.object({
2046
- id: z3.string(),
2047
- name: z3.string()
2458
+ var ToolkitCategorySchema = z4.object({
2459
+ id: z4.string(),
2460
+ name: z4.string()
2048
2461
  });
2049
- var ToolkitRetrieveCategoriesResponseSchema = z3.object({
2050
- items: z3.array(ToolkitCategorySchema),
2051
- nextCursor: z3.string().nullable(),
2052
- totalPages: z3.number()
2462
+ var ToolkitRetrieveCategoriesResponseSchema = z4.object({
2463
+ items: z4.array(ToolkitCategorySchema),
2464
+ nextCursor: z4.string().nullable(),
2465
+ totalPages: z4.number()
2053
2466
  });
2054
2467
 
2055
2468
  // src/types/authConfigs.types.ts
2056
- import { z as z4 } from "zod";
2469
+ import { z as z5 } from "zod";
2057
2470
  var AuthConfigTypes = {
2058
2471
  CUSTOM: "use_custom_auth",
2059
2472
  COMPOSIO_MANAGED: "use_composio_managed_auth"
@@ -2073,10 +2486,9 @@ var AuthSchemeTypes = {
2073
2486
  CALCOM_AUTH: "CALCOM_AUTH",
2074
2487
  SNOWFLAKE: "SNOWFLAKE"
2075
2488
  };
2076
- var AuthSchemeEnum = z4.enum([
2489
+ var AuthSchemeEnum = z5.enum([
2077
2490
  "OAUTH2",
2078
2491
  "OAUTH1",
2079
- "OAUTH1A",
2080
2492
  "API_KEY",
2081
2493
  "BASIC",
2082
2494
  "BILLCOM_AUTH",
@@ -2088,67 +2500,69 @@ var AuthSchemeEnum = z4.enum([
2088
2500
  "CALCOM_AUTH",
2089
2501
  "SNOWFLAKE"
2090
2502
  ]);
2091
- var CreateCustomAuthConfigParamsSchema = z4.object({
2092
- type: z4.literal("use_custom_auth"),
2093
- name: z4.string().optional(),
2094
- credentials: z4.record(z4.string(), z4.union([z4.string(), z4.number(), z4.boolean()])),
2095
- authScheme: AuthSchemeEnum
2503
+ var CreateCustomAuthConfigParamsSchema = z5.object({
2504
+ type: z5.literal("use_custom_auth"),
2505
+ name: z5.string().optional(),
2506
+ credentials: z5.record(z5.string(), z5.union([z5.string(), z5.number(), z5.boolean()])),
2507
+ authScheme: AuthSchemeEnum,
2508
+ restrictToFollowingTools: z5.array(z5.string()).optional()
2096
2509
  });
2097
- var CreateComposioManagedAuthConfigParamsSchema = z4.object({
2098
- type: z4.literal("use_composio_managed_auth"),
2099
- name: z4.string().optional(),
2100
- credentials: z4.record(z4.string(), z4.union([z4.string(), z4.number(), z4.boolean()])).optional()
2510
+ var CreateComposioManagedAuthConfigParamsSchema = z5.object({
2511
+ type: z5.literal("use_composio_managed_auth"),
2512
+ name: z5.string().optional(),
2513
+ credentials: z5.record(z5.string(), z5.union([z5.string(), z5.number(), z5.boolean()])).optional(),
2514
+ restrictToFollowingTools: z5.array(z5.string()).optional()
2101
2515
  });
2102
- var CreateAuthConfigParamsSchema = z4.discriminatedUnion("type", [
2516
+ var CreateAuthConfigParamsSchema = z5.discriminatedUnion("type", [
2103
2517
  CreateCustomAuthConfigParamsSchema,
2104
2518
  CreateComposioManagedAuthConfigParamsSchema
2105
2519
  ]);
2106
- var CreateAuthConfigResponseSchema = z4.object({
2107
- id: z4.string(),
2108
- authScheme: z4.string(),
2109
- isComposioManaged: z4.boolean(),
2110
- toolkit: z4.string()
2520
+ var CreateAuthConfigResponseSchema = z5.object({
2521
+ id: z5.string(),
2522
+ authScheme: z5.string(),
2523
+ isComposioManaged: z5.boolean(),
2524
+ toolkit: z5.string()
2111
2525
  });
2112
- var AuthConfigRetrieveResponseSchema = z4.object({
2113
- id: z4.string(),
2114
- name: z4.string(),
2115
- toolkit: z4.object({
2116
- logo: z4.string(),
2117
- slug: z4.string()
2526
+ var AuthConfigRetrieveResponseSchema = z5.object({
2527
+ id: z5.string(),
2528
+ name: z5.string(),
2529
+ toolkit: z5.object({
2530
+ logo: z5.string(),
2531
+ slug: z5.string()
2118
2532
  }),
2119
- noOfConnections: z4.number(),
2120
- status: z4.enum(["ENABLED", "DISABLED"]),
2121
- uuid: z4.string(),
2533
+ noOfConnections: z5.number(),
2534
+ status: z5.enum(["ENABLED", "DISABLED"]),
2535
+ uuid: z5.string(),
2122
2536
  authScheme: AuthSchemeEnum.optional(),
2123
- credentials: z4.record(z4.string(), z4.unknown()).optional(),
2124
- expectedInputFields: z4.array(z4.unknown()).optional(),
2125
- isComposioManaged: z4.boolean().optional(),
2126
- createdBy: z4.string().optional(),
2127
- createdAt: z4.string().optional(),
2128
- lastUpdatedAt: z4.string().optional()
2537
+ credentials: z5.record(z5.string(), z5.unknown()).optional(),
2538
+ expectedInputFields: z5.array(z5.unknown()).optional(),
2539
+ isComposioManaged: z5.boolean().optional(),
2540
+ createdBy: z5.string().optional(),
2541
+ createdAt: z5.string().optional(),
2542
+ lastUpdatedAt: z5.string().optional()
2129
2543
  });
2130
- var AuthConfigListParamsSchema = z4.object({
2131
- cursor: z4.string().optional(),
2132
- isComposioManaged: z4.boolean().optional(),
2133
- limit: z4.number().optional(),
2134
- toolkit: z4.string().optional()
2544
+ var AuthConfigListParamsSchema = z5.object({
2545
+ cursor: z5.string().optional(),
2546
+ isComposioManaged: z5.boolean().optional(),
2547
+ limit: z5.number().optional(),
2548
+ toolkit: z5.string().optional()
2135
2549
  });
2136
- var AuthConfigListResponseSchema = z4.object({
2137
- items: z4.array(AuthConfigRetrieveResponseSchema),
2138
- nextCursor: z4.string().nullable(),
2139
- totalPages: z4.number()
2550
+ var AuthConfigListResponseSchema = z5.object({
2551
+ items: z5.array(AuthConfigRetrieveResponseSchema),
2552
+ nextCursor: z5.string().nullable(),
2553
+ totalPages: z5.number()
2140
2554
  });
2141
- var AuthCustomConfigUpdateParamsSchema = z4.object({
2142
- credentials: z4.record(z4.string(), z4.union([z4.string(), z4.unknown()])),
2143
- type: z4.literal("custom"),
2144
- restrictToFollowingTools: z4.array(z4.string()).optional()
2555
+ var AuthCustomConfigUpdateParamsSchema = z5.object({
2556
+ credentials: z5.record(z5.string(), z5.union([z5.string(), z5.unknown()])),
2557
+ type: z5.literal("custom"),
2558
+ restrictToFollowingTools: z5.array(z5.string()).optional()
2145
2559
  });
2146
- var AuthDefaultConfigUpdateParamsSchema = z4.object({
2147
- scopes: z4.string(),
2148
- type: z4.literal("default"),
2149
- restrictToFollowingTools: z4.array(z4.string()).optional()
2560
+ var AuthDefaultConfigUpdateParamsSchema = z5.object({
2561
+ scopes: z5.string(),
2562
+ type: z5.literal("default"),
2563
+ restrictToFollowingTools: z5.array(z5.string()).optional()
2150
2564
  });
2151
- var AuthConfigUpdateParamsSchema = z4.discriminatedUnion("type", [
2565
+ var AuthConfigUpdateParamsSchema = z5.discriminatedUnion("type", [
2152
2566
  AuthCustomConfigUpdateParamsSchema,
2153
2567
  AuthDefaultConfigUpdateParamsSchema
2154
2568
  ]);
@@ -2281,7 +2695,18 @@ var AuthConfigs = class {
2281
2695
  toolkit: {
2282
2696
  slug: toolkit
2283
2697
  },
2284
- auth_config: parsedOptions.data
2698
+ auth_config: parsedOptions.data.type === "use_custom_auth" ? {
2699
+ type: parsedOptions.data.type,
2700
+ name: parsedOptions.data.name,
2701
+ authScheme: parsedOptions.data.authScheme,
2702
+ credentials: parsedOptions.data.credentials,
2703
+ restrict_to_following_tools: parsedOptions.data.restrictToFollowingTools
2704
+ } : {
2705
+ type: parsedOptions.data.type,
2706
+ credentials: parsedOptions.data.credentials,
2707
+ name: parsedOptions.data.name,
2708
+ restrict_to_following_tools: parsedOptions.data.restrictToFollowingTools
2709
+ }
2285
2710
  });
2286
2711
  const parsedResult = CreateAuthConfigResponseSchema.safeParse({
2287
2712
  id: result.auth_config.id,
@@ -2457,7 +2882,34 @@ var AuthConfigs = class {
2457
2882
 
2458
2883
  // src/models/ConnectionRequest.ts
2459
2884
  import ComposioClient from "@composio/client";
2460
- import { ZodError as ZodError3 } from "zod";
2885
+
2886
+ // src/utils/transformers/connectedAccounts.ts
2887
+ function transformConnectedAccountResponse(response) {
2888
+ const result = ConnectedAccountRetrieveResponseSchema.safeParse({
2889
+ ...response,
2890
+ authConfig: {
2891
+ ...response.auth_config,
2892
+ id: response.auth_config.id,
2893
+ isComposioManaged: response.auth_config.is_composio_managed,
2894
+ isDisabled: response.auth_config.is_disabled
2895
+ },
2896
+ state: response.state,
2897
+ status: response.status,
2898
+ statusReason: response.status_reason,
2899
+ isDisabled: response.is_disabled,
2900
+ createdAt: response.created_at,
2901
+ updatedAt: response.updated_at,
2902
+ testRequestEndpoint: response.test_request_endpoint
2903
+ });
2904
+ if (!result.success) {
2905
+ throw new ValidationError("Failed to parse connected account retrieve response", {
2906
+ cause: result.error
2907
+ });
2908
+ }
2909
+ return result.data;
2910
+ }
2911
+
2912
+ // src/models/ConnectionRequest.ts
2461
2913
  var ConnectionRequest = class {
2462
2914
  client;
2463
2915
  id;
@@ -2470,45 +2922,6 @@ var ConnectionRequest = class {
2470
2922
  this.redirectUrl = redirectUrl;
2471
2923
  telemetry.instrument(this);
2472
2924
  }
2473
- /**
2474
- * Transforms the raw connected account response from the Composio API to the SDK format.
2475
- *
2476
- * This method converts property names from snake_case to camelCase and reorganizes
2477
- * the data structure to match the SDK's standardized format.
2478
- *
2479
- * @param {OriginalConnectedAccountResponse} response - The raw API response to transform
2480
- * @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
2481
- * @throws {ZodError} If the response fails validation against the expected schema
2482
- *
2483
- * @private
2484
- */
2485
- async transformResponse(response) {
2486
- try {
2487
- const parsedResponse = ConnectedAccountRetrieveResponseSchema.parse({
2488
- ...response,
2489
- userId: response.user_id,
2490
- // Add the missing userId property
2491
- authConfig: {
2492
- ...response.auth_config,
2493
- authScheme: response.auth_config.auth_scheme,
2494
- isComposioManaged: response.auth_config.is_composio_managed,
2495
- isDisabled: response.auth_config.is_disabled
2496
- },
2497
- statusReason: response.status_reason,
2498
- isDisabled: response.is_disabled,
2499
- createdAt: response.created_at,
2500
- updatedAt: response.updated_at,
2501
- testRequestEndpoint: response.test_request_endpoint
2502
- });
2503
- return parsedResponse;
2504
- } catch (error) {
2505
- logger_default.error("Error transforming response", error);
2506
- if (error instanceof ZodError3) {
2507
- logger_default.error(JSON.stringify(error.errors, null, 2));
2508
- }
2509
- throw error;
2510
- }
2511
- }
2512
2925
  /**
2513
2926
  * Waits for the connection request to complete and become active.
2514
2927
  *
@@ -2540,7 +2953,7 @@ var ConnectionRequest = class {
2540
2953
  const response = await this.client.connectedAccounts.retrieve(this.id);
2541
2954
  if (response.status === ConnectedAccountStatuses.ACTIVE) {
2542
2955
  this.status = ConnectedAccountStatuses.ACTIVE;
2543
- return this.transformResponse(response);
2956
+ return transformConnectedAccountResponse(response);
2544
2957
  }
2545
2958
  } catch (error) {
2546
2959
  if (error instanceof ComposioClient.NotFoundError) {
@@ -2567,14 +2980,13 @@ var ConnectionRequest = class {
2567
2980
  const response = await this.client.connectedAccounts.retrieve(this.id);
2568
2981
  this.status = response.status;
2569
2982
  if (response.status === ConnectedAccountStatuses.ACTIVE) {
2570
- return this.transformResponse(response);
2983
+ return transformConnectedAccountResponse(response);
2571
2984
  }
2572
2985
  if (terminalErrorStates.includes(response.status)) {
2573
2986
  throw new ConnectionRequestFailedError(
2574
2987
  `Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`,
2575
2988
  {
2576
2989
  meta: {
2577
- userId: response.user_id,
2578
2990
  connectedAccountId: this.id,
2579
2991
  status: response.status,
2580
2992
  statusReason: response.status_reason
@@ -2615,30 +3027,6 @@ var ConnectedAccounts = class {
2615
3027
  this.client = client;
2616
3028
  telemetry.instrument(this);
2617
3029
  }
2618
- transformConnectedAccountRetrieveResponse(response) {
2619
- const result = ConnectedAccountRetrieveResponseSchema.safeParse({
2620
- ...response,
2621
- userId: response.user_id,
2622
- // Add the missing userId property
2623
- authConfig: {
2624
- ...response.auth_config,
2625
- authScheme: response.auth_config.auth_scheme,
2626
- isComposioManaged: response.auth_config.is_composio_managed,
2627
- isDisabled: response.auth_config.is_disabled
2628
- },
2629
- statusReason: response.status_reason,
2630
- isDisabled: response.is_disabled,
2631
- createdAt: response.created_at,
2632
- updatedAt: response.updated_at,
2633
- testRequestEndpoint: response.test_request_endpoint
2634
- });
2635
- if (!result.success) {
2636
- throw new ValidationError("Failed to parse connected account retrieve response", {
2637
- cause: result.error
2638
- });
2639
- }
2640
- return result.data;
2641
- }
2642
3030
  /**
2643
3031
  * Lists all connected accounts based on provided filter criteria.
2644
3032
  *
@@ -2685,7 +3073,7 @@ var ConnectedAccounts = class {
2685
3073
  }
2686
3074
  const result = await this.client.connectedAccounts.list(rawQuery);
2687
3075
  const parsedResponse = ConnectedAccountListResponseSchema.safeParse({
2688
- items: result.items.map(this.transformConnectedAccountRetrieveResponse),
3076
+ items: result.items.map(transformConnectedAccountResponse),
2689
3077
  nextCursor: result.next_cursor,
2690
3078
  totalPages: result.total_pages
2691
3079
  });
@@ -2696,21 +3084,6 @@ var ConnectedAccounts = class {
2696
3084
  }
2697
3085
  return parsedResponse.data;
2698
3086
  }
2699
- /**
2700
- * Transforms connected account data from API format to SDK format.
2701
- *
2702
- * This method converts property names from snake_case to camelCase and reorganizes
2703
- * the data structure to match the SDK's standardized format for connected accounts.
2704
- *
2705
- * @param {ConnectedAccountRetrieveResponseRaw} response - The raw API response to transform
2706
- * @returns {ConnectedAccountRetrieveResponse} The transformed connected account data
2707
- * @throws {ValidationError} If the response fails validation against the expected schema
2708
- *
2709
- * @private
2710
- */
2711
- transformConnectedAccountResponse(response) {
2712
- return this.transformConnectedAccountRetrieveResponse(response);
2713
- }
2714
3087
  /**
2715
3088
  * Compound function to create a new connected account.
2716
3089
  * This function creates a new connected account and returns a connection request.
@@ -2735,12 +3108,18 @@ var ConnectedAccounts = class {
2735
3108
  id: authConfigId
2736
3109
  },
2737
3110
  connection: {
2738
- data: options?.data,
3111
+ state: options?.state,
2739
3112
  callback_url: options?.callbackUrl,
2740
3113
  user_id: userId
2741
3114
  }
2742
3115
  });
2743
- return new ConnectionRequest(this.client, response.id, response.status, response.redirect_url);
3116
+ const redirectUrl = typeof response.connectionData?.val?.redirectUrl === "string" ? response.connectionData.val.redirectUrl : null;
3117
+ return new ConnectionRequest(
3118
+ this.client,
3119
+ response.id,
3120
+ response.connectionData.val.status,
3121
+ redirectUrl
3122
+ );
2744
3123
  }
2745
3124
  /**
2746
3125
  * Waits for a connection request to complete and become active.
@@ -2788,7 +3167,7 @@ var ConnectedAccounts = class {
2788
3167
  */
2789
3168
  async get(nanoid) {
2790
3169
  const response = await this.client.connectedAccounts.retrieve(nanoid);
2791
- return this.transformConnectedAccountResponse(response);
3170
+ return transformConnectedAccountResponse(response);
2792
3171
  }
2793
3172
  /**
2794
3173
  * Deletes a connected account.
@@ -2833,14 +3212,14 @@ var ConnectedAccounts = class {
2833
3212
  * @param {string} nanoid - Unique identifier of the connected account
2834
3213
  * @param {ConnectedAccountUpdateStatusParams} params - Parameters for updating the status
2835
3214
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
2836
- *
3215
+ *
2837
3216
  * @example
2838
3217
  * ```typescript
2839
3218
  * // Enable a connected account
2840
3219
  * const updatedAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
2841
3220
  * enabled: true
2842
3221
  * });
2843
- *
3222
+ *
2844
3223
  * // Disable a connected account with a reason
2845
3224
  * const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
2846
3225
  * enabled: false,
@@ -2855,7 +3234,7 @@ var ConnectedAccounts = class {
2855
3234
  * Enable a connected account
2856
3235
  * @param {string} nanoid - Unique identifier of the connected account
2857
3236
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
2858
- *
3237
+ *
2859
3238
  * @example
2860
3239
  * ```typescript
2861
3240
  * // Enable a previously disabled connected account
@@ -2870,13 +3249,13 @@ var ConnectedAccounts = class {
2870
3249
  * Disable a connected account
2871
3250
  * @param {string} nanoid - Unique identifier of the connected account
2872
3251
  * @returns {Promise<ConnectedAccountUpdateStatusResponse>} Updated connected account details
2873
- *
3252
+ *
2874
3253
  * @example
2875
3254
  * ```typescript
2876
3255
  * // Disable a connected account
2877
3256
  * const disabledAccount = await composio.connectedAccounts.disable('conn_abc123');
2878
3257
  * console.log(disabledAccount.isDisabled); // true
2879
- *
3258
+ *
2880
3259
  * // You can also use updateStatus with a reason
2881
3260
  * // const disabledAccount = await composio.connectedAccounts.updateStatus('conn_abc123', {
2882
3261
  * // enabled: false,
@@ -3097,88 +3476,88 @@ var Toolkits = class {
3097
3476
  };
3098
3477
 
3099
3478
  // src/types/triggers.types.ts
3100
- import { z as z5 } from "zod";
3101
- var TriggerStatusEnum = z5.enum(["enable", "disable"]);
3102
- var TriggerSubscribeParamSchema = z5.object({
3103
- toolkits: z5.array(z5.string()).optional(),
3104
- triggerId: z5.string().optional(),
3105
- connectedAccountId: z5.string().optional(),
3106
- authConfigId: z5.string().optional(),
3107
- triggerSlug: z5.array(z5.string()).optional(),
3108
- triggerData: z5.string().optional(),
3109
- userId: z5.string().optional()
3479
+ import { z as z6 } from "zod";
3480
+ var TriggerStatusEnum = z6.enum(["enable", "disable"]);
3481
+ var TriggerSubscribeParamSchema = z6.object({
3482
+ toolkits: z6.array(z6.string()).optional(),
3483
+ triggerId: z6.string().optional(),
3484
+ connectedAccountId: z6.string().optional(),
3485
+ authConfigId: z6.string().optional(),
3486
+ triggerSlug: z6.array(z6.string()).optional(),
3487
+ triggerData: z6.string().optional(),
3488
+ userId: z6.string().optional()
3110
3489
  });
3111
- var TriggerInstanceListActiveParamsSchema = z5.object({
3112
- authConfigIds: z5.array(z5.string()).nullable().optional(),
3113
- connectedAccountIds: z5.array(z5.string()).nullable().optional(),
3114
- limit: z5.number().optional(),
3115
- page: z5.number().optional(),
3116
- showDisabled: z5.boolean().nullable().optional(),
3117
- triggerIds: z5.array(z5.string()).nullable().optional(),
3118
- triggerNames: z5.array(z5.string()).nullable().optional()
3490
+ var TriggerInstanceListActiveParamsSchema = z6.object({
3491
+ authConfigIds: z6.array(z6.string()).nullable().optional(),
3492
+ connectedAccountIds: z6.array(z6.string()).nullable().optional(),
3493
+ limit: z6.number().optional(),
3494
+ page: z6.number().optional(),
3495
+ showDisabled: z6.boolean().nullable().optional(),
3496
+ triggerIds: z6.array(z6.string()).nullable().optional(),
3497
+ triggerNames: z6.array(z6.string()).nullable().optional()
3119
3498
  });
3120
- var TriggerInstanceListActiveResponseItemSchema = z5.object({
3121
- id: z5.string(),
3122
- connectedAccountId: z5.string(),
3123
- disabledAt: z5.string().nullable(),
3124
- state: z5.record(z5.unknown()),
3125
- triggerConfig: z5.record(z5.unknown()),
3126
- triggerName: z5.string(),
3127
- updatedAt: z5.string(),
3128
- triggerData: z5.string().optional(),
3129
- uuid: z5.string().optional()
3499
+ var TriggerInstanceListActiveResponseItemSchema = z6.object({
3500
+ id: z6.string(),
3501
+ connectedAccountId: z6.string(),
3502
+ disabledAt: z6.string().nullable(),
3503
+ state: z6.record(z6.unknown()),
3504
+ triggerConfig: z6.record(z6.unknown()),
3505
+ triggerName: z6.string(),
3506
+ updatedAt: z6.string(),
3507
+ triggerData: z6.string().optional(),
3508
+ uuid: z6.string().optional()
3130
3509
  });
3131
- var TriggerInstanceListActiveResponseSchema = z5.object({
3132
- items: z5.array(TriggerInstanceListActiveResponseItemSchema),
3133
- nextCursor: z5.string().nullable(),
3134
- totalPages: z5.number()
3510
+ var TriggerInstanceListActiveResponseSchema = z6.object({
3511
+ items: z6.array(TriggerInstanceListActiveResponseItemSchema),
3512
+ nextCursor: z6.string().nullable(),
3513
+ totalPages: z6.number()
3135
3514
  });
3136
- var TriggerInstanceUpsertParamsSchema = z5.object({
3137
- connectedAccountId: z5.string().optional(),
3138
- triggerConfig: z5.record(z5.unknown()).optional()
3515
+ var TriggerInstanceUpsertParamsSchema = z6.object({
3516
+ connectedAccountId: z6.string().optional(),
3517
+ triggerConfig: z6.record(z6.unknown()).optional()
3139
3518
  });
3140
- var TriggerInstanceUpsertResponseSchema = z5.object({
3141
- triggerId: z5.string()
3519
+ var TriggerInstanceUpsertResponseSchema = z6.object({
3520
+ triggerId: z6.string()
3142
3521
  });
3143
- var TriggerInstanceManageUpdateParamsSchema = z5.object({
3144
- status: z5.enum(["enable", "disable"])
3522
+ var TriggerInstanceManageUpdateParamsSchema = z6.object({
3523
+ status: z6.enum(["enable", "disable"])
3145
3524
  });
3146
- var TriggerInstanceManageUpdateResponseSchema = z5.object({
3147
- status: z5.enum(["success"])
3525
+ var TriggerInstanceManageUpdateResponseSchema = z6.object({
3526
+ status: z6.enum(["success"])
3148
3527
  });
3149
- var TriggerInstanceManageDeleteResponseSchema = z5.object({
3150
- triggerId: z5.string()
3528
+ var TriggerInstanceManageDeleteResponseSchema = z6.object({
3529
+ triggerId: z6.string()
3151
3530
  });
3152
- var IncomingTriggerPayloadSchema = z5.object({
3153
- id: z5.string().describe("The ID of the trigger"),
3154
- triggerSlug: z5.string().describe("The slug of the trigger that triggered the event"),
3155
- toolkitSlug: z5.string().describe("The slug of the toolkit that triggered the event"),
3156
- userId: z5.string().describe("The ID of the user that triggered the event"),
3157
- payload: z5.record(z5.unknown()).describe("The payload of the trigger").optional(),
3158
- originalPayload: z5.record(z5.unknown()).describe("The original payload of the trigger").optional(),
3159
- metadata: z5.object({
3160
- id: z5.string(),
3161
- toolkitSlug: z5.string(),
3162
- triggerSlug: z5.string(),
3163
- triggerData: z5.string().optional(),
3164
- triggerConfig: z5.record(z5.unknown()),
3165
- connectedAccount: z5.object({
3166
- id: z5.string(),
3167
- uuid: z5.string(),
3168
- authConfigId: z5.string(),
3169
- authConfigUUID: z5.string(),
3170
- userId: z5.string(),
3171
- status: z5.enum(["ACTIVE", "INACTIVE"])
3531
+ var IncomingTriggerPayloadSchema = z6.object({
3532
+ id: z6.string().describe("The ID of the trigger"),
3533
+ triggerSlug: z6.string().describe("The slug of the trigger that triggered the event"),
3534
+ toolkitSlug: z6.string().describe("The slug of the toolkit that triggered the event"),
3535
+ userId: z6.string().describe("The ID of the user that triggered the event"),
3536
+ payload: z6.record(z6.unknown()).describe("The payload of the trigger").optional(),
3537
+ originalPayload: z6.record(z6.unknown()).describe("The original payload of the trigger").optional(),
3538
+ metadata: z6.object({
3539
+ id: z6.string(),
3540
+ toolkitSlug: z6.string(),
3541
+ triggerSlug: z6.string(),
3542
+ triggerData: z6.string().optional(),
3543
+ triggerConfig: z6.record(z6.unknown()),
3544
+ connectedAccount: z6.object({
3545
+ id: z6.string(),
3546
+ uuid: z6.string(),
3547
+ authConfigId: z6.string(),
3548
+ authConfigUUID: z6.string(),
3549
+ userId: z6.string(),
3550
+ status: z6.enum(["ACTIVE", "INACTIVE"])
3172
3551
  })
3173
3552
  })
3174
3553
  });
3175
3554
 
3176
3555
  // src/services/internal/InternalService.types.ts
3177
- import { z as z6 } from "zod";
3178
- var SDKRealtimeCredentialsResponseSchema = z6.object({
3179
- projectId: z6.string().describe("The project ID"),
3180
- pusherKey: z6.string().describe("The Pusher key"),
3181
- pusherCluster: z6.string().describe("The Pusher cluster")
3556
+ import { z as z7 } from "zod";
3557
+ var SDKRealtimeCredentialsResponseSchema = z7.object({
3558
+ projectId: z7.string().describe("The project ID"),
3559
+ pusherKey: z7.string().describe("The Pusher key"),
3560
+ pusherCluster: z7.string().describe("The Pusher cluster")
3182
3561
  });
3183
3562
 
3184
3563
  // src/services/internal/InternalService.ts
@@ -3544,12 +3923,12 @@ var Triggers = class {
3544
3923
  /**
3545
3924
  * Update an existing trigger instance
3546
3925
  *
3547
- * @param {string} slug - The slug of the trigger instance
3548
- * @param {TriggerInstanceManageUpdateParams} body - The parameters to create the trigger instance
3549
- * @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance
3926
+ * @param {string} triggerId - The Id of the trigger instance
3927
+ * @param {TriggerInstanceManageUpdateParams} body - The parameters to update the trigger instance
3928
+ * @returns {Promise<TriggerInstanceManageUpdateResponse>} The updated trigger instance response
3550
3929
  */
3551
- async update(slug, body) {
3552
- return this.client.triggerInstances.manage.update(slug, body);
3930
+ async update(triggerId, body) {
3931
+ return this.client.triggerInstances.manage.update(triggerId, body);
3553
3932
  }
3554
3933
  /**
3555
3934
  * Delete a trigger instance
@@ -4271,10 +4650,10 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
4271
4650
  };
4272
4651
 
4273
4652
  // package.json
4274
- var version = "0.1.12";
4653
+ var version = "0.1.14";
4275
4654
 
4276
4655
  // src/composio.ts
4277
- var Composio = class {
4656
+ var Composio = class _Composio {
4278
4657
  /**
4279
4658
  * The Composio API client.
4280
4659
  * @type {ComposioClient}
@@ -4298,10 +4677,10 @@ var Composio = class {
4298
4677
  connectedAccounts;
4299
4678
  /**
4300
4679
  * Creates a new instance of the Composio SDK.
4301
- *
4680
+ *
4302
4681
  * The constructor initializes the SDK with the provided configuration options,
4303
4682
  * sets up the API client, and initializes all core models (tools, toolkits, etc.).
4304
- *
4683
+ *
4305
4684
  * @param {ComposioConfig<TProvider>} config - Configuration options for the Composio SDK
4306
4685
  * @param {string} [config.apiKey] - The API key for authenticating with the Composio API
4307
4686
  * @param {string} [config.baseURL] - The base URL for the Composio API (defaults to production URL)
@@ -4309,18 +4688,18 @@ var Composio = class {
4309
4688
  * @param {boolean} [config.allowTracing=true] - Whether to allow request tracing for debugging
4310
4689
  * @param {TProvider} [config.provider] - The provider to use for this Composio instance (defaults to OpenAIProvider)
4311
4690
  * @param {BaseTelemetryTransport} [config.telemetryTransport] - Custom telemetry transport implementation
4312
- *
4691
+ *
4313
4692
  * @example
4314
4693
  * ```typescript
4315
4694
  * // Initialize with default configuration
4316
4695
  * const composio = new Composio();
4317
- *
4696
+ *
4318
4697
  * // Initialize with custom API key and base URL
4319
4698
  * const composio = new Composio({
4320
4699
  * apiKey: 'your-api-key',
4321
4700
  * baseURL: 'https://api.composio.dev'
4322
4701
  * });
4323
- *
4702
+ *
4324
4703
  * // Initialize with custom provider
4325
4704
  * const composio = new Composio({
4326
4705
  * apiKey: 'your-api-key',
@@ -4338,7 +4717,9 @@ var Composio = class {
4338
4717
  }
4339
4718
  this.client = new ComposioClient3({
4340
4719
  apiKey: apiKeyParsed,
4341
- baseURL: baseURLParsed
4720
+ baseURL: baseURLParsed,
4721
+ defaultHeaders: config?.defaultHeaders,
4722
+ logLevel: process.env.COMPOSIO_LOG_LEVEL ?? void 0
4342
4723
  });
4343
4724
  this.config = {
4344
4725
  ...config,
@@ -4384,6 +4765,46 @@ var Composio = class {
4384
4765
  }
4385
4766
  return this.client;
4386
4767
  }
4768
+ /**
4769
+ * Creates a new instance of the Composio SDK with custom request options while preserving the existing configuration.
4770
+ * This method is particularly useful when you need to:
4771
+ * - Add custom headers for specific requests
4772
+ * - Track request contexts with unique identifiers
4773
+ * - Override default request behavior for a subset of operations
4774
+ *
4775
+ * The new instance inherits all configuration from the parent instance (apiKey, baseURL, provider, etc.)
4776
+ * but allows you to specify custom request options that will be used for all API calls made through this session.
4777
+ *
4778
+ * @param {MergedRequestInit} fetchOptions - Custom request options to be used for all API calls in this session.
4779
+ * This follows the Fetch API RequestInit interface with additional options.
4780
+ * @returns {Composio<TProvider>} A new Composio instance with the custom request options applied.
4781
+ *
4782
+ * @example
4783
+ * ```typescript
4784
+ * // Create a base Composio instance
4785
+ * const composio = new Composio({
4786
+ * apiKey: 'your-api-key'
4787
+ * });
4788
+ *
4789
+ * // Create a session with request tracking headers
4790
+ * const composioWithCustomHeaders = composio.createSession({
4791
+ * headers: {
4792
+ * 'x-request-id': '1234567890',
4793
+ * 'x-correlation-id': 'session-abc-123',
4794
+ * 'x-custom-header': 'custom-value'
4795
+ * }
4796
+ * });
4797
+ *
4798
+ * // Use the session for making API calls with the custom headers
4799
+ * await composioWithCustomHeaders.tools.list();
4800
+ * ```
4801
+ */
4802
+ createSession(options) {
4803
+ return new _Composio({
4804
+ ...this.config,
4805
+ defaultHeaders: options?.headers
4806
+ });
4807
+ }
4387
4808
  };
4388
4809
 
4389
4810
  // src/provider/ComposioProvider.ts
@@ -4409,112 +4830,15 @@ var ConsoleTelemetryTransport = class {
4409
4830
  };
4410
4831
 
4411
4832
  // src/utils/jsonSchema.ts
4412
- import { z as z7 } from "zod";
4413
- function jsonSchemaPropertiesToTSTypes(value) {
4414
- if (!value.type) {
4415
- return z7.object({});
4416
- }
4417
- let zodType;
4418
- switch (value.type) {
4419
- case "string":
4420
- zodType = z7.string().describe(
4421
- (value.description || "") + (value.examples ? `
4422
- Examples: ${value.examples.join(", ")}` : "")
4423
- );
4424
- break;
4425
- case "number":
4426
- zodType = z7.number().describe(
4427
- (value.description || "") + (value.examples ? `
4428
- Examples: ${value.examples.join(", ")}` : "")
4429
- );
4430
- break;
4431
- case "integer":
4432
- zodType = z7.number().int().describe(
4433
- (value.description || "") + (value.examples ? `
4434
- Examples: ${value.examples.join(", ")}` : "")
4435
- );
4436
- break;
4437
- case "boolean":
4438
- zodType = z7.boolean().describe(
4439
- (value.description || "") + (value.examples ? `
4440
- Examples: ${value.examples.join(", ")}` : "")
4441
- );
4442
- break;
4443
- case "array":
4444
- zodType = z7.array(
4445
- jsonSchemaPropertiesToTSTypes(
4446
- value.items
4447
- )
4448
- ).describe(
4449
- (value.description || "") + (value.examples ? `
4450
- Examples: ${value.examples.join(", ")}` : "")
4451
- );
4452
- break;
4453
- case "object":
4454
- zodType = jsonSchemaToZodSchema(value).describe(
4455
- (value.description || "") + (value.examples ? `
4456
- Examples: ${value.examples.join(", ")}` : "")
4457
- );
4458
- break;
4459
- case "null":
4460
- zodType = z7.null().describe(value.description || "");
4461
- break;
4462
- default:
4463
- throw new Error(`Unsupported JSON schema type: ${value.type}`);
4464
- }
4465
- return zodType;
4466
- }
4833
+ import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
4467
4834
  function jsonSchemaToZodSchema(jsonSchema) {
4468
- const properties = jsonSchema.properties;
4469
- const requiredFields = jsonSchema.required || [];
4470
- if (!properties) {
4471
- return z7.object({});
4472
- }
4473
- const zodSchema = {};
4474
- for (const [key, _] of Object.entries(properties)) {
4475
- const value = _;
4476
- let zodType;
4477
- if (value.anyOf) {
4478
- const anyOfTypes = value.anyOf.map(
4479
- (schema) => jsonSchemaPropertiesToTSTypes(
4480
- schema
4481
- )
4482
- );
4483
- zodType = z7.union(anyOfTypes).describe(
4484
- (value.description || "") + (value.examples ? `
4485
- Examples: ${value.examples.join(", ")}` : "")
4486
- );
4487
- } else if (value.allOf) {
4488
- const allOfTypes = value.allOf.map(
4489
- (schema) => jsonSchemaPropertiesToTSTypes(
4490
- schema
4491
- )
4492
- );
4493
- zodType = z7.intersection(
4494
- allOfTypes[0],
4495
- allOfTypes.slice(1).reduce((acc, schema) => acc.and(schema), allOfTypes[0])
4496
- ).describe(
4497
- (value.description || "") + (value.examples ? `
4498
- Examples: ${value.examples.join(", ")}` : "")
4499
- );
4500
- } else {
4501
- if (!value.type) {
4502
- value.type = "string";
4503
- }
4504
- zodType = jsonSchemaPropertiesToTSTypes(
4505
- value
4506
- );
4507
- }
4508
- if (value.description) {
4509
- zodType = zodType.describe(value.description);
4510
- }
4511
- if (requiredFields.includes(key)) {
4512
- zodSchema[key] = zodType;
4513
- } else {
4514
- zodSchema[key] = zodType.optional();
4515
- }
4835
+ try {
4836
+ return jsonSchemaToZod(jsonSchema);
4837
+ } catch (error) {
4838
+ throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
4839
+ cause: error
4840
+ });
4516
4841
  }
4517
- return z7.object(zodSchema);
4518
4842
  }
4519
4843
  export {
4520
4844
  AuthConfigErrorCodes,
@@ -4543,6 +4867,7 @@ export {
4543
4867
  ConnectionRequestFailedError,
4544
4868
  ConnectionRequestTimeoutError,
4545
4869
  ConsoleTelemetryTransport,
4870
+ JsonSchemaToZodError,
4546
4871
  OpenAIProvider,
4547
4872
  SDKErrorCodes,
4548
4873
  ToolErrorCodes,