@composio/core 0.5.5 → 0.6.1

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.
Files changed (58) hide show
  1. package/dist/BaseProvider-QPPZprGx.d.mts +26875 -0
  2. package/dist/BaseProvider-dBg5sg9H.d.cts +26875 -0
  3. package/dist/FileToolModifier.utils.neutral-BN_L8usp.mjs +78 -0
  4. package/dist/FileToolModifier.utils.neutral-Bcl7LVf4.cjs +102 -0
  5. package/dist/Telemetry-Bn5VseVi.mjs +331 -0
  6. package/dist/Telemetry-DErMJqj0.cjs +337 -0
  7. package/dist/buffer-BFpVRahf.mjs +382 -0
  8. package/dist/buffer-CYf1Z6Sd.cjs +478 -0
  9. package/dist/composio-h_UeXpQT.d.cts +6325 -0
  10. package/dist/composio-ivOweCw4.d.mts +6325 -0
  11. package/dist/fileUtils.node-DLp53qm1.cjs +232 -0
  12. package/dist/fileUtils.node-MOEGtpnI.mjs +219 -0
  13. package/dist/index.cjs +273 -417
  14. package/dist/index.d.cts +6 -33161
  15. package/dist/index.d.mts +6 -33161
  16. package/dist/index.mjs +182 -325
  17. package/dist/models/Files.node.cjs +6 -4
  18. package/dist/models/Files.node.d.cts +1 -1
  19. package/dist/models/Files.node.d.mts +1 -1
  20. package/dist/models/Files.node.mjs +4 -2
  21. package/dist/models/Files.workerd.cjs +1 -1
  22. package/dist/models/Files.workerd.mjs +1 -1
  23. package/dist/platform/node.cjs +6 -3
  24. package/dist/platform/node.d.cts +1 -1
  25. package/dist/platform/node.d.mts +1 -1
  26. package/dist/platform/node.mjs +6 -3
  27. package/dist/platform/workerd.d.cts +1 -1
  28. package/dist/platform/workerd.d.mts +1 -1
  29. package/dist/{types-BaUqjuX3.d.mts → types-BF2OQZRP.d.cts} +8 -5
  30. package/dist/types-BXCpxUsu.d.cts +13 -0
  31. package/dist/{types-BrsW5suw.d.cts → types-Cvt_yFsu.d.mts} +8 -5
  32. package/dist/types-anOdQ7KW.d.mts +13 -0
  33. package/dist/utils/config-defaults/ConfigDefaults.node.cjs +10 -0
  34. package/dist/utils/config-defaults/ConfigDefaults.node.d.cts +7 -0
  35. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +8 -0
  36. package/dist/utils/config-defaults/ConfigDefaults.node.mjs +9 -0
  37. package/dist/utils/config-defaults/ConfigDefaults.workerd.cjs +10 -0
  38. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.cts +7 -0
  39. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +8 -0
  40. package/dist/utils/config-defaults/ConfigDefaults.workerd.mjs +9 -0
  41. package/dist/utils/modifiers/FileToolModifier.node.cjs +172 -0
  42. package/dist/utils/modifiers/FileToolModifier.node.d.cts +21 -0
  43. package/dist/utils/modifiers/FileToolModifier.node.d.mts +21 -0
  44. package/dist/utils/modifiers/FileToolModifier.node.mjs +173 -0
  45. package/dist/utils/modifiers/FileToolModifier.workerd.cjs +27 -0
  46. package/dist/utils/modifiers/FileToolModifier.workerd.d.cts +20 -0
  47. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +20 -0
  48. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +27 -0
  49. package/package.json +25 -1
  50. package/src/platform/index.ts +1 -1
  51. package/src/platform/node.ts +17 -9
  52. package/src/platform/types.ts +9 -5
  53. package/src/platform/workerd.ts +7 -3
  54. package/dist/fileUtils-2bnnG7dq.cjs +0 -979
  55. package/dist/fileUtils-Dbn-fnh5.mjs +0 -900
  56. /package/dist/{chunk-0j-ceAHr.mjs → chunk-Dx2NuYGI.mjs} +0 -0
  57. /package/dist/{files.types-B7P5A1Z5.d.mts → files.types-BDqIUdfP.d.mts} +0 -0
  58. /package/dist/{files.types-D-RzIOHq.d.cts → files.types-nK6eTNnc.d.cts} +0 -0
package/dist/index.cjs CHANGED
@@ -1,15 +1,16 @@
1
1
  const require_chunk = require('./chunk-CQwRTUmo.cjs');
2
- const require_fileUtils = require('./fileUtils-2bnnG7dq.cjs');
2
+ const require_buffer = require('./buffer-CYf1Z6Sd.cjs');
3
+ const require_Telemetry = require('./Telemetry-DErMJqj0.cjs');
3
4
  let _composio_client = require("@composio/client");
4
5
  _composio_client = require_chunk.__toESM(_composio_client);
6
+ let _file_tool_modifier = require("#file_tool_modifier");
5
7
  let zod_v3 = require("zod/v3");
6
8
  zod_v3 = require_chunk.__toESM(zod_v3);
7
9
  let zod_to_json_schema = require("zod-to-json-schema");
8
10
  zod_to_json_schema = require_chunk.__toESM(zod_to_json_schema);
9
- let node_crypto = require("node:crypto");
10
- node_crypto = require_chunk.__toESM(node_crypto);
11
- let _platform = require("#platform");
11
+ let _config_defaults = require("#config_defaults");
12
12
  let openai = require("openai");
13
+ let _platform = require("#platform");
13
14
  let semver = require("semver");
14
15
  semver = require_chunk.__toESM(semver);
15
16
  let _files = require("#files");
@@ -934,7 +935,7 @@ const ConnectedAccountErrorCodes = {
934
935
  MULTIPLE_CONNECTED_ACCOUNTS: "MULTIPLE_CONNECTED_ACCOUNTS",
935
936
  FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: "FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK"
936
937
  };
937
- var ComposioConnectedAccountNotFoundError = class extends require_fileUtils.ComposioError {
938
+ var ComposioConnectedAccountNotFoundError = class extends require_buffer.ComposioError {
938
939
  constructor(message = "Connected account not found", options = {}) {
939
940
  super(message, {
940
941
  ...options,
@@ -945,7 +946,7 @@ var ComposioConnectedAccountNotFoundError = class extends require_fileUtils.Comp
945
946
  this.name = "ComposioConnectedAccountNotFoundError";
946
947
  }
947
948
  };
948
- var ComposioMultipleConnectedAccountsError = class extends require_fileUtils.ComposioError {
949
+ var ComposioMultipleConnectedAccountsError = class extends require_buffer.ComposioError {
949
950
  constructor(message = "Multiple connected accounts found", options = {}) {
950
951
  super(message, {
951
952
  ...options,
@@ -955,7 +956,7 @@ var ComposioMultipleConnectedAccountsError = class extends require_fileUtils.Com
955
956
  this.name = "ComposioMultipleConnectedAccountsError";
956
957
  }
957
958
  };
958
- var ComposioFailedToCreateConnectedAccountLink = class extends require_fileUtils.ComposioError {
959
+ var ComposioFailedToCreateConnectedAccountLink = class extends require_buffer.ComposioError {
959
960
  constructor(message = "Failed to create connected account link", options = {}) {
960
961
  super(message, {
961
962
  ...options,
@@ -977,7 +978,7 @@ const ToolErrorCodes = {
977
978
  GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET",
978
979
  TOOL_VERSION_REQUIRED: "TOOL_VERSION_REQUIRED"
979
980
  };
980
- var ComposioProviderNotDefinedError = class extends require_fileUtils.ComposioError {
981
+ var ComposioProviderNotDefinedError = class extends require_buffer.ComposioError {
981
982
  constructor(message = "Provider not defined", options = {}) {
982
983
  super(message, {
983
984
  ...options,
@@ -987,7 +988,7 @@ var ComposioProviderNotDefinedError = class extends require_fileUtils.ComposioEr
987
988
  this.name = "ComposioProviderNotDefinedError";
988
989
  }
989
990
  };
990
- var ComposioToolNotFoundError = class extends require_fileUtils.ComposioError {
991
+ var ComposioToolNotFoundError = class extends require_buffer.ComposioError {
991
992
  constructor(message = "Tool not found", options = {}) {
992
993
  super(message, {
993
994
  ...options,
@@ -997,7 +998,7 @@ var ComposioToolNotFoundError = class extends require_fileUtils.ComposioError {
997
998
  this.name = "ComposioToolNotFoundError";
998
999
  }
999
1000
  };
1000
- var ComposioInvalidModifierError = class extends require_fileUtils.ComposioError {
1001
+ var ComposioInvalidModifierError = class extends require_buffer.ComposioError {
1001
1002
  constructor(message = "Invalid modifier", options = {}) {
1002
1003
  super(message, {
1003
1004
  ...options,
@@ -1007,7 +1008,7 @@ var ComposioInvalidModifierError = class extends require_fileUtils.ComposioError
1007
1008
  this.name = "ComposioInvalidModifierError";
1008
1009
  }
1009
1010
  };
1010
- var ComposioCustomToolsNotInitializedError = class extends require_fileUtils.ComposioError {
1011
+ var ComposioCustomToolsNotInitializedError = class extends require_buffer.ComposioError {
1011
1012
  constructor(message = "Custom tools not initialized", options = {}) {
1012
1013
  super(message, {
1013
1014
  ...options,
@@ -1017,7 +1018,7 @@ var ComposioCustomToolsNotInitializedError = class extends require_fileUtils.Com
1017
1018
  this.name = "ComposioCustomToolsNotInitializedError";
1018
1019
  }
1019
1020
  };
1020
- var ComposioToolExecutionError = class extends require_fileUtils.ComposioError {
1021
+ var ComposioToolExecutionError = class extends require_buffer.ComposioError {
1021
1022
  constructor(message = "Tool execution error", options = {}) {
1022
1023
  super(message, {
1023
1024
  ...options,
@@ -1028,7 +1029,7 @@ var ComposioToolExecutionError = class extends require_fileUtils.ComposioError {
1028
1029
  this.name = "ComposioToolExecutionError";
1029
1030
  }
1030
1031
  };
1031
- var ComposioInvalidExecuteFunctionError = class extends require_fileUtils.ComposioError {
1032
+ var ComposioInvalidExecuteFunctionError = class extends require_buffer.ComposioError {
1032
1033
  constructor(message = "Invalid execute function", options = {}) {
1033
1034
  super(message, {
1034
1035
  ...options,
@@ -1038,7 +1039,7 @@ var ComposioInvalidExecuteFunctionError = class extends require_fileUtils.Compos
1038
1039
  this.name = "ComposioInvalidExecuteFunctionError";
1039
1040
  }
1040
1041
  };
1041
- var ComposioGlobalExecuteToolFnNotSetError = class extends require_fileUtils.ComposioError {
1042
+ var ComposioGlobalExecuteToolFnNotSetError = class extends require_buffer.ComposioError {
1042
1043
  constructor(message = "Global execute tool function not set", options = {}) {
1043
1044
  super(message, {
1044
1045
  ...options,
@@ -1111,7 +1112,7 @@ var ComposioGlobalExecuteToolFnNotSetError = class extends require_fileUtils.Com
1111
1112
  * });
1112
1113
  * ```
1113
1114
  */
1114
- var ComposioToolVersionRequiredError = class extends require_fileUtils.ComposioError {
1115
+ var ComposioToolVersionRequiredError = class extends require_buffer.ComposioError {
1115
1116
  constructor(message = "Toolkit version not specified. For manual execution of the tool please pass a specific toolkit version", options = {}) {
1116
1117
  super(message, {
1117
1118
  ...options,
@@ -1142,7 +1143,7 @@ const handleToolExecutionError = (tool, actualError) => {
1142
1143
  //#endregion
1143
1144
  //#region src/errors/AuthConfigErrors.ts
1144
1145
  const AuthConfigErrorCodes = { AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND" };
1145
- var ComposioAuthConfigNotFoundError = class extends require_fileUtils.ComposioError {
1146
+ var ComposioAuthConfigNotFoundError = class extends require_buffer.ComposioError {
1146
1147
  constructor(message = "Auth config not found", options = {}) {
1147
1148
  super(message, {
1148
1149
  ...options,
@@ -1163,7 +1164,7 @@ const ConnectionRequestErrorCodes = {
1163
1164
  CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
1164
1165
  CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
1165
1166
  };
1166
- var ConnectionRequestTimeoutError = class extends require_fileUtils.ComposioError {
1167
+ var ConnectionRequestTimeoutError = class extends require_buffer.ComposioError {
1167
1168
  constructor(message = "Connection request timed out", options = {}) {
1168
1169
  super(message, {
1169
1170
  ...options,
@@ -1172,7 +1173,7 @@ var ConnectionRequestTimeoutError = class extends require_fileUtils.ComposioErro
1172
1173
  this.name = "ConnectionRequestTimeoutError";
1173
1174
  }
1174
1175
  };
1175
- var ConnectionRequestFailedError = class extends require_fileUtils.ComposioError {
1176
+ var ConnectionRequestFailedError = class extends require_buffer.ComposioError {
1176
1177
  constructor(message = "Connection request failed", options = {}) {
1177
1178
  super(message, {
1178
1179
  ...options,
@@ -1185,7 +1186,7 @@ var ConnectionRequestFailedError = class extends require_fileUtils.ComposioError
1185
1186
  //#endregion
1186
1187
  //#region src/errors/ToolkitErrors.ts
1187
1188
  const ToolkitErrorCodes = { TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND" };
1188
- var ComposioToolkitNotFoundError = class extends require_fileUtils.ComposioError {
1189
+ var ComposioToolkitNotFoundError = class extends require_buffer.ComposioError {
1189
1190
  constructor(message = "Toolkit not found", options = {}) {
1190
1191
  super(message, {
1191
1192
  ...options,
@@ -1195,7 +1196,7 @@ var ComposioToolkitNotFoundError = class extends require_fileUtils.ComposioError
1195
1196
  this.name = "ComposioToolkitNotFoundError";
1196
1197
  }
1197
1198
  };
1198
- var ComposioToolkitFetchError = class extends require_fileUtils.ComposioError {
1199
+ var ComposioToolkitFetchError = class extends require_buffer.ComposioError {
1199
1200
  constructor(message = "Failed to fetch toolkit", options = {}) {
1200
1201
  super(message, {
1201
1202
  ...options,
@@ -1219,7 +1220,7 @@ const ValidationErrorCodes = {
1219
1220
  VALIDATION_ERROR: "VALIDATION_ERROR",
1220
1221
  JSON_SCHEMA_TO_ZOD_ERROR: "JSON_SCHEMA_TO_ZOD_ERROR"
1221
1222
  };
1222
- var ValidationError = class extends require_fileUtils.ComposioError {
1223
+ var ValidationError = class extends require_buffer.ComposioError {
1223
1224
  constructor(message = "Input validation failed", options = {}) {
1224
1225
  const { cause: providedZodError, ...restOptions } = options;
1225
1226
  let zodErrorInstance;
@@ -1249,7 +1250,7 @@ var ValidationError = class extends require_fileUtils.ComposioError {
1249
1250
  return "Please check your input parameters";
1250
1251
  }
1251
1252
  };
1252
- var JsonSchemaToZodError = class extends require_fileUtils.ComposioError {
1253
+ var JsonSchemaToZodError = class extends require_buffer.ComposioError {
1253
1254
  constructor(message = "Failed to convert JSON schema to Zod schema", options = {}) {
1254
1255
  super(message, {
1255
1256
  ...options,
@@ -1261,7 +1262,7 @@ var JsonSchemaToZodError = class extends require_fileUtils.ComposioError {
1261
1262
  //#endregion
1262
1263
  //#region src/errors/SDKErrors.ts
1263
1264
  const SDKErrorCodes = { NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED" };
1264
- var ComposioNoAPIKeyError = class extends require_fileUtils.ComposioError {
1265
+ var ComposioNoAPIKeyError = class extends require_buffer.ComposioError {
1265
1266
  constructor(message = "No Composio API key provided", options = {}) {
1266
1267
  const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
1267
1268
  super(message, {
@@ -1290,7 +1291,7 @@ const TriggerErrorCodes = {
1290
1291
  WEBHOOK_SIGNATURE_VERIFICATION_FAILED: "WEBHOOK_SIGNATURE_VERIFICATION_FAILED",
1291
1292
  WEBHOOK_PAYLOAD_INVALID: "WEBHOOK_PAYLOAD_INVALID"
1292
1293
  };
1293
- var ComposioFailedToGetSDKRealtimeCredentialsError = class extends require_fileUtils.ComposioError {
1294
+ var ComposioFailedToGetSDKRealtimeCredentialsError = class extends require_buffer.ComposioError {
1294
1295
  constructor(message = "Failed to get SDK realtime credentials", options = {}) {
1295
1296
  super(message, {
1296
1297
  ...options,
@@ -1300,7 +1301,7 @@ var ComposioFailedToGetSDKRealtimeCredentialsError = class extends require_fileU
1300
1301
  this.name = "ComposioFailedToGetSDKRealtimeCredentialsError";
1301
1302
  }
1302
1303
  };
1303
- var ComposioFailedToCreatePusherClientError = class extends require_fileUtils.ComposioError {
1304
+ var ComposioFailedToCreatePusherClientError = class extends require_buffer.ComposioError {
1304
1305
  constructor(message = "Failed to create Pusher client", options = {}) {
1305
1306
  super(message, {
1306
1307
  ...options,
@@ -1310,7 +1311,7 @@ var ComposioFailedToCreatePusherClientError = class extends require_fileUtils.Co
1310
1311
  this.name = "ComposioFailedToCreatePusherClientError";
1311
1312
  }
1312
1313
  };
1313
- var ComposioFailedToSubscribeToPusherChannelError = class extends require_fileUtils.ComposioError {
1314
+ var ComposioFailedToSubscribeToPusherChannelError = class extends require_buffer.ComposioError {
1314
1315
  constructor(message = "Failed to subscribe to Pusher channel", options = {}) {
1315
1316
  super(message, {
1316
1317
  ...options,
@@ -1320,7 +1321,7 @@ var ComposioFailedToSubscribeToPusherChannelError = class extends require_fileUt
1320
1321
  this.name = "ComposioFailedToSubscribeToPusherChannelError";
1321
1322
  }
1322
1323
  };
1323
- var ComposioFailedToUnsubscribeFromPusherChannelError = class extends require_fileUtils.ComposioError {
1324
+ var ComposioFailedToUnsubscribeFromPusherChannelError = class extends require_buffer.ComposioError {
1324
1325
  constructor(message = "Failed to unsubscribe from Pusher channel", options = {}) {
1325
1326
  super(message, {
1326
1327
  ...options,
@@ -1330,7 +1331,7 @@ var ComposioFailedToUnsubscribeFromPusherChannelError = class extends require_fi
1330
1331
  this.name = "ComposioFailedToUnsubscribeFromPusherChannelError";
1331
1332
  }
1332
1333
  };
1333
- var ComposioTriggerTypeNotFoundError = class extends require_fileUtils.ComposioError {
1334
+ var ComposioTriggerTypeNotFoundError = class extends require_buffer.ComposioError {
1334
1335
  constructor(message = "Trigger type not found", options = {}) {
1335
1336
  super(message, {
1336
1337
  ...options,
@@ -1341,7 +1342,7 @@ var ComposioTriggerTypeNotFoundError = class extends require_fileUtils.ComposioE
1341
1342
  this.name = "ComposioTriggerTypeNotFoundError";
1342
1343
  }
1343
1344
  };
1344
- var ComposioWebhookSignatureVerificationError = class extends require_fileUtils.ComposioError {
1345
+ var ComposioWebhookSignatureVerificationError = class extends require_buffer.ComposioError {
1345
1346
  constructor(message = "Webhook signature verification failed", options = {}) {
1346
1347
  super(message, {
1347
1348
  ...options,
@@ -1356,7 +1357,7 @@ var ComposioWebhookSignatureVerificationError = class extends require_fileUtils.
1356
1357
  this.name = "ComposioWebhookSignatureVerificationError";
1357
1358
  }
1358
1359
  };
1359
- var ComposioWebhookPayloadError = class extends require_fileUtils.ComposioError {
1360
+ var ComposioWebhookPayloadError = class extends require_buffer.ComposioError {
1360
1361
  constructor(message = "Invalid webhook payload", options = {}) {
1361
1362
  super(message, {
1362
1363
  ...options,
@@ -1467,7 +1468,7 @@ function transform(raw) {
1467
1468
  const transformed = transformer(raw);
1468
1469
  const result = schema.safeParse(transformed);
1469
1470
  if (!result.success) {
1470
- require_fileUtils.logger_default.error(result.error);
1471
+ require_buffer.logger_default.error(result.error);
1471
1472
  return transformed;
1472
1473
  }
1473
1474
  return result.data;
@@ -1494,7 +1495,7 @@ function transformConnectedAccountResponse(response) {
1494
1495
  try {
1495
1496
  return state ? ConnectionDataSchema.parse(state) : void 0;
1496
1497
  } catch (error) {
1497
- require_fileUtils.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
1498
+ require_buffer.logger_default.warn("Unsupported auth scheme in connected account state, ignoring state field", { error });
1498
1499
  return;
1499
1500
  }
1500
1501
  };
@@ -1542,10 +1543,10 @@ var CustomTools = class {
1542
1543
  client;
1543
1544
  customToolsRegistry;
1544
1545
  constructor(client) {
1545
- if (!client) throw new require_fileUtils.ComposioError("ComposioClient is required");
1546
+ if (!client) throw new require_buffer.ComposioError("ComposioClient is required");
1546
1547
  this.client = client;
1547
1548
  this.customToolsRegistry = /* @__PURE__ */ new Map();
1548
- require_fileUtils.telemetry.instrument(this, "CustomTools");
1549
+ require_Telemetry.telemetry.instrument(this, "CustomTools");
1549
1550
  }
1550
1551
  /**
1551
1552
  * Create a custom tool and registers it in the registry.
@@ -1650,7 +1651,7 @@ var CustomTools = class {
1650
1651
  try {
1651
1652
  return this.customToolsRegistry.get(slug.toLowerCase())?.schema;
1652
1653
  } catch (error) {
1653
- require_fileUtils.logger_default.error(`Error getting custom tool: ${error}`);
1654
+ require_buffer.logger_default.error(`Error getting custom tool: ${error}`);
1654
1655
  return;
1655
1656
  }
1656
1657
  }
@@ -1696,7 +1697,7 @@ var CustomTools = class {
1696
1697
  let connectedAccountId = body.connectedAccountId;
1697
1698
  if (toolkitSlug && toolkitSlug !== "custom" && body.userId) {
1698
1699
  const connectedAccount = await this.getConnectedAccountForToolkit(toolkitSlug, body.userId, body.connectedAccountId);
1699
- require_fileUtils.logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
1700
+ require_buffer.logger_default.debug(`[CustomTool] Connected account for ${toolkitSlug} found for user ${body.userId}`, JSON.stringify(connectedAccount, null, 2));
1700
1701
  if (!connectedAccount) throw new ComposioConnectedAccountNotFoundError(`Connected account not found for toolkit ${toolkitSlug} for user ${body.userId}`, { meta: {
1701
1702
  toolkitSlug,
1702
1703
  userId: body.userId
@@ -1733,277 +1734,6 @@ var CustomTools = class {
1733
1734
  }
1734
1735
  };
1735
1736
 
1736
- //#endregion
1737
- //#region src/errors/FileModifierErrors.ts
1738
- const FileModifierErrorCodes = { FILE_UPLOAD_FAILED: "FILE_UPLOAD_FAILED" };
1739
- var ComposioFileUploadError = class extends require_fileUtils.ComposioError {
1740
- constructor(message = "Failed to upload file", options = {}) {
1741
- super(message, {
1742
- ...options,
1743
- code: FileModifierErrorCodes.FILE_UPLOAD_FAILED,
1744
- possibleFixes: options.possibleFixes || ["Check if the file exists in the location provided"]
1745
- });
1746
- this.name = "ComposioFileUploadError";
1747
- }
1748
- };
1749
-
1750
- //#endregion
1751
- //#region src/utils/modifiers/FileToolModifier.ts
1752
- /**
1753
- * Transforms a single JSON schema property, recursively handling nested properties,
1754
- * anyOf, oneOf, and allOf.
1755
- */
1756
- const transformSchema = (property) => {
1757
- if (property.file_uploadable) return {
1758
- title: property.title,
1759
- description: property.description,
1760
- format: "path",
1761
- type: "string",
1762
- file_uploadable: true
1763
- };
1764
- const newProperty = { ...property };
1765
- if (property.type === "object" && property.properties) newProperty.properties = transformProperties(property.properties);
1766
- if (property.anyOf) newProperty.anyOf = property.anyOf.map(transformSchema);
1767
- if (property.oneOf) newProperty.oneOf = property.oneOf.map(transformSchema);
1768
- if (property.allOf) newProperty.allOf = property.allOf.map(transformSchema);
1769
- if (property.items) if (Array.isArray(property.items)) newProperty.items = property.items.map(transformSchema);
1770
- else newProperty.items = transformSchema(property.items);
1771
- return newProperty;
1772
- };
1773
- /**
1774
- * Transforms the properties of the tool schema to include the file upload URL.
1775
- *
1776
- * Attaches the format: 'path' to the properties that are file uploadable for agents.
1777
- *
1778
- * @param properties - The properties of the tool schema.
1779
- * @returns The transformed properties.
1780
- */
1781
- const transformProperties = (properties) => {
1782
- const newProperties = {};
1783
- for (const [key, property] of Object.entries(properties)) newProperties[key] = transformSchema(property);
1784
- return newProperties;
1785
- };
1786
- /**
1787
- * Recursively checks if a schema (or any of its variants) contains a specific file property.
1788
- */
1789
- const schemaHasFileProperty = (schema, property) => {
1790
- if (!schema) return false;
1791
- if (schema[property]) return true;
1792
- if (schema.properties) {
1793
- for (const prop of Object.values(schema.properties)) if (schemaHasFileProperty(prop, property)) return true;
1794
- }
1795
- if (schema.anyOf) {
1796
- for (const variant of schema.anyOf) if (schemaHasFileProperty(variant, property)) return true;
1797
- }
1798
- if (schema.oneOf) {
1799
- for (const variant of schema.oneOf) if (schemaHasFileProperty(variant, property)) return true;
1800
- }
1801
- if (schema.allOf) {
1802
- for (const variant of schema.allOf) if (schemaHasFileProperty(variant, property)) return true;
1803
- }
1804
- if (schema.items) {
1805
- if (Array.isArray(schema.items)) {
1806
- for (const item of schema.items) if (schemaHasFileProperty(item, property)) return true;
1807
- } else if (schemaHasFileProperty(schema.items, property)) return true;
1808
- }
1809
- return false;
1810
- };
1811
- /**
1812
- * Recursively checks if a schema (or any of its variants) contains file_uploadable properties.
1813
- */
1814
- const schemaHasFileUploadable = (schema) => {
1815
- return schemaHasFileProperty(schema, "file_uploadable");
1816
- };
1817
- /**
1818
- * Recursively checks if a schema (or any of its variants) contains file_downloadable properties.
1819
- */
1820
- const schemaHasFileDownloadable = (schema) => {
1821
- return schemaHasFileProperty(schema, "file_downloadable");
1822
- };
1823
- /**
1824
- * Recursively walks a runtime value and its matching JSON-Schema node,
1825
- * uploading any string path whose schema node has `file_uploadable: true`.
1826
- * The function returns a **new** value with all substitutions applied;
1827
- * nothing is mutated in-place.
1828
- */
1829
- const hydrateFiles = async (value, schema, ctx) => {
1830
- if (schema?.file_uploadable) {
1831
- if (typeof value !== "string" && !(value instanceof File)) return value;
1832
- require_fileUtils.logger_default.debug(`Uploading file "${value}"`);
1833
- return require_fileUtils.getFileDataAfterUploadingToS3(value, {
1834
- toolSlug: ctx.toolSlug,
1835
- toolkitSlug: ctx.toolkitSlug,
1836
- client: ctx.client
1837
- });
1838
- }
1839
- const schemaVariants = [
1840
- ...schema?.anyOf ?? [],
1841
- ...schema?.oneOf ?? [],
1842
- ...schema?.allOf ?? []
1843
- ];
1844
- if (schemaVariants.length > 0) {
1845
- const uploadableVariants = schemaVariants.filter(schemaHasFileUploadable);
1846
- if (uploadableVariants.length > 0) {
1847
- let result = value;
1848
- for (const variant of uploadableVariants) result = await hydrateFiles(result, variant, ctx);
1849
- return result;
1850
- }
1851
- }
1852
- if (schema?.type === "object" && schema.properties && isPlainObject(value)) {
1853
- const transformed = {};
1854
- for (const [k, v] of Object.entries(value)) transformed[k] = await hydrateFiles(v, schema.properties[k], ctx);
1855
- return transformed;
1856
- }
1857
- if (schema?.type === "array" && schema.items && Array.isArray(value)) {
1858
- const itemSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
1859
- return Promise.all(value.map((item) => hydrateFiles(item, itemSchema, ctx)));
1860
- }
1861
- return value;
1862
- };
1863
- /**
1864
- * Downloads a file from S3 and returns a replacement object.
1865
- */
1866
- const downloadS3File = async (value, ctx) => {
1867
- const { s3url, mimetype } = value;
1868
- try {
1869
- require_fileUtils.logger_default.debug(`Downloading from S3: ${s3url}`);
1870
- const dl = await require_fileUtils.downloadFileFromS3({
1871
- toolSlug: ctx.toolSlug,
1872
- s3Url: s3url,
1873
- mimeType: mimetype ?? "application/octet-stream"
1874
- });
1875
- require_fileUtils.logger_default.debug(`Downloaded → ${dl.filePath}`);
1876
- return {
1877
- uri: dl.filePath,
1878
- file_downloaded: dl.filePath ? true : false,
1879
- s3url,
1880
- mimeType: dl.mimeType
1881
- };
1882
- } catch (err) {
1883
- require_fileUtils.logger_default.error(`Download failed: ${s3url}`, { cause: err });
1884
- return {
1885
- uri: "",
1886
- file_downloaded: false,
1887
- s3url,
1888
- mimeType: mimetype ?? "application/octet-stream"
1889
- };
1890
- }
1891
- };
1892
- /**
1893
- * Recursively walks an arbitrary value and its matching JSON-Schema node.
1894
- * Whenever it encounters an object that represents a file reference
1895
- * (i.e. has an `s3url`), it downloads the file and returns a replacement:
1896
- * {
1897
- * uri: "<local-path>",
1898
- * file_downloaded: true | false,
1899
- * s3url: "<original S3 URL>",
1900
- * mimeType: "<detected-or-fallback-mime-type>"
1901
- * }
1902
- *
1903
- * The function is side-effect-free: it never mutates the input value.
1904
- */
1905
- const hydrateDownloads = async (value, schema, ctx) => {
1906
- if (isPlainObject(value) && typeof value.s3url === "string") return downloadS3File(value, ctx);
1907
- if (schema?.file_downloadable && isPlainObject(value) && typeof value.s3url === "string") return downloadS3File(value, ctx);
1908
- const schemaVariants = [
1909
- ...schema?.anyOf ?? [],
1910
- ...schema?.oneOf ?? [],
1911
- ...schema?.allOf ?? []
1912
- ];
1913
- if (schemaVariants.length > 0) {
1914
- const downloadableVariants = schemaVariants.filter(schemaHasFileDownloadable);
1915
- let result = value;
1916
- for (const variant of downloadableVariants) result = await hydrateDownloads(result, variant, ctx);
1917
- if (downloadableVariants.length === 0) return hydrateDownloads(value, void 0, ctx);
1918
- return result;
1919
- }
1920
- if (isPlainObject(value)) {
1921
- const pairs = await Promise.all(Object.entries(value).map(async ([k, v]) => [k, await hydrateDownloads(v, schema?.properties?.[k], ctx)]));
1922
- return Object.fromEntries(pairs);
1923
- }
1924
- if (Array.isArray(value)) {
1925
- const itemSchema = schema?.items ? Array.isArray(schema.items) ? schema.items[0] : schema.items : void 0;
1926
- return Promise.all(value.map((item) => hydrateDownloads(item, itemSchema, ctx)));
1927
- }
1928
- return value;
1929
- };
1930
- function isPlainObject(val) {
1931
- return typeof val === "object" && val !== null && !Array.isArray(val);
1932
- }
1933
- var FileToolModifier = class {
1934
- client;
1935
- constructor(client) {
1936
- this.client = client;
1937
- }
1938
- /**
1939
- * Modifies the tool schema to include the file upload URL.
1940
- *
1941
- * @description This modifier is used to upload a file to the Composio platform and replace the file path with the file upload URL.
1942
- *
1943
- * @param _toolSlug - The slug of the tool that is being executed.
1944
- * @param _toolkitSlug - The slug of the toolkit that is being executed.
1945
- * @param schema - The schema of the tool.
1946
- * @returns The schema with the file upload URL included.
1947
- */
1948
- async modifyToolSchema(toolSlug, toolkitSlug, schema) {
1949
- if (!schema.inputParameters?.properties) return schema;
1950
- const properties = transformProperties(schema.inputParameters.properties);
1951
- return {
1952
- ...schema,
1953
- inputParameters: {
1954
- ...schema.inputParameters,
1955
- properties
1956
- }
1957
- };
1958
- }
1959
- /**
1960
- * Modifies the input parameters to include the file upload URL.
1961
- *
1962
- * @description This modifier is used to upload a file to the Composio platform and replace the file path with the file upload URL.
1963
- *
1964
- * @param toolSlug - The slug of the tool that is being executed.
1965
- * @param toolkitSlug - The slug of the toolkit that is being executed.
1966
- *
1967
- */
1968
- async fileUploadModifier(tool, options) {
1969
- const { params, toolSlug, toolkitSlug = "unknown" } = options;
1970
- const { arguments: args } = params;
1971
- if (!args || typeof args !== "object") return params;
1972
- try {
1973
- const newArgs = await hydrateFiles(args, tool.inputParameters, {
1974
- toolSlug,
1975
- toolkitSlug,
1976
- client: this.client
1977
- });
1978
- return {
1979
- ...params,
1980
- arguments: newArgs
1981
- };
1982
- } catch (error) {
1983
- throw new ComposioFileUploadError("Failed to upload file", { cause: error });
1984
- }
1985
- }
1986
- /**
1987
- * Modifies the result to include the file download URL.
1988
- *
1989
- * @description This modifier is used to download a file and
1990
- *
1991
- * @param tool - The tool schema containing output parameters.
1992
- * @param toolSlug - The slug of the tool that is being executed.
1993
- * @param toolkitSlug - The slug of the toolkit that is being executed.
1994
- * @param result - The result of the tool execution.
1995
- * @returns The result with the file download URL included.
1996
- */
1997
- async fileDownloadModifier(tool, options) {
1998
- const { result, toolSlug } = options;
1999
- const dataWithDownloads = await hydrateDownloads(result.data, tool.outputParameters, { toolSlug });
2000
- return {
2001
- ...result,
2002
- data: dataWithDownloads
2003
- };
2004
- }
2005
- };
2006
-
2007
1737
  //#endregion
2008
1738
  //#region src/utils/toolkitVersion.ts
2009
1739
  /**
@@ -2037,13 +1767,13 @@ var Tools = class {
2037
1767
  this.client = client;
2038
1768
  this.customTools = new CustomTools(client);
2039
1769
  this.provider = config.provider;
2040
- this.autoUploadDownloadFiles = config?.autoUploadDownloadFiles ?? true;
2041
- this.toolkitVersions = config?.toolkitVersions ?? "latest";
1770
+ this.autoUploadDownloadFiles = config?.autoUploadDownloadFiles ?? _config_defaults.CONFIG_DEFAULTS.autoUploadDownloadFiles;
1771
+ this.toolkitVersions = config?.toolkitVersions ?? _config_defaults.CONFIG_DEFAULTS.toolkitVersions;
2042
1772
  this.execute = this.execute.bind(this);
2043
1773
  this.provider._setExecuteToolFn(this.createExecuteFnForProviders());
2044
1774
  this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
2045
1775
  this.getRawComposioTools = this.getRawComposioTools.bind(this);
2046
- require_fileUtils.telemetry.instrument(this, "Tools");
1776
+ require_Telemetry.telemetry.instrument(this, "Tools");
2047
1777
  }
2048
1778
  /**
2049
1779
  * Transforms tool data from snake_case API format to camelCase for internal SDK use.
@@ -2093,7 +1823,7 @@ var Tools = class {
2093
1823
  */
2094
1824
  async applyDefaultSchemaModifiers(tools) {
2095
1825
  if (this.autoUploadDownloadFiles) {
2096
- const fileToolModifier = new FileToolModifier(this.client);
1826
+ const fileToolModifier = new _file_tool_modifier.FileToolModifier(this.client);
2097
1827
  return await Promise.all(tools.map((tool) => fileToolModifier.modifyToolSchema(tool.slug, tool.toolkit?.slug ?? "unknown", tool)));
2098
1828
  } else return tools;
2099
1829
  }
@@ -2107,7 +1837,7 @@ var Tools = class {
2107
1837
  */
2108
1838
  async applyBeforeExecuteModifiers(tool, { toolSlug, toolkitSlug, params }, modifier) {
2109
1839
  let modifiedParams = params;
2110
- if (this.autoUploadDownloadFiles) modifiedParams = await new FileToolModifier(this.client).fileUploadModifier(tool, {
1840
+ if (this.autoUploadDownloadFiles) modifiedParams = await new _file_tool_modifier.FileToolModifier(this.client).fileUploadModifier(tool, {
2111
1841
  toolSlug,
2112
1842
  toolkitSlug,
2113
1843
  params: modifiedParams
@@ -2130,7 +1860,7 @@ var Tools = class {
2130
1860
  */
2131
1861
  async applyAfterExecuteModifiers(tool, { toolSlug, toolkitSlug, result }, modifier) {
2132
1862
  let modifiedResult = result;
2133
- if (this.autoUploadDownloadFiles) modifiedResult = await new FileToolModifier(this.client).fileDownloadModifier(tool, {
1863
+ if (this.autoUploadDownloadFiles) modifiedResult = await new _file_tool_modifier.FileToolModifier(this.client).fileDownloadModifier(tool, {
2134
1864
  toolSlug,
2135
1865
  toolkitSlug,
2136
1866
  result: modifiedResult
@@ -2220,7 +1950,7 @@ var Tools = class {
2220
1950
  ...effectiveImportant ? { important: "true" } : {},
2221
1951
  toolkit_versions: this.toolkitVersions
2222
1952
  };
2223
- require_fileUtils.logger_default.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
1953
+ require_buffer.logger_default.debug(`Fetching tools with filters: ${JSON.stringify(filters, null, 2)}`);
2224
1954
  const tools = await this.client.tools.list(filters);
2225
1955
  if (!tools) return [];
2226
1956
  const caseTransformedTools = tools.items.map((tool) => this.transformToolCases(tool));
@@ -2323,12 +2053,13 @@ var Tools = class {
2323
2053
  async getRawComposioToolBySlug(slug, options) {
2324
2054
  const customTool = await this.customTools.getCustomToolBySlug(slug);
2325
2055
  if (customTool) {
2326
- require_fileUtils.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
2056
+ require_buffer.logger_default.debug(`Found ${slug} to be a custom tool`, JSON.stringify(customTool, null, 2));
2327
2057
  return customTool;
2328
- } else require_fileUtils.logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
2058
+ } else require_buffer.logger_default.debug(`Tool ${slug} is not a custom tool. Fetching from Composio API`);
2329
2059
  let tool;
2330
2060
  try {
2331
- tool = await this.client.tools.retrieve(slug, { toolkit_versions: this.toolkitVersions });
2061
+ const retrieveParams = options?.version ? { version: options.version } : { toolkit_versions: this.toolkitVersions };
2062
+ tool = await this.client.tools.retrieve(slug, retrieveParams);
2332
2063
  } catch (error) {
2333
2064
  throw new ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, { cause: error });
2334
2065
  }
@@ -2546,7 +2277,7 @@ var Tools = class {
2546
2277
  const executeParams = ToolExecuteParamsSchema.safeParse(body);
2547
2278
  if (!executeParams.success) throw new ValidationError("Invalid tool execute parameters", { cause: executeParams.error });
2548
2279
  const customTool = await this.customTools.getCustomToolBySlug(slug);
2549
- const tool = customTool ?? await this.getRawComposioToolBySlug(slug);
2280
+ const tool = customTool ?? await this.getRawComposioToolBySlug(slug, { version: body.version });
2550
2281
  const toolkitSlug = tool.toolkit?.slug ?? "unknown";
2551
2282
  const params = await this.applyBeforeExecuteModifiers(tool, {
2552
2283
  toolSlug: slug,
@@ -2917,7 +2648,7 @@ var AuthConfigs = class {
2917
2648
  client;
2918
2649
  constructor(client) {
2919
2650
  this.client = client;
2920
- require_fileUtils.telemetry.instrument(this, "AuthConfigs");
2651
+ require_Telemetry.telemetry.instrument(this, "AuthConfigs");
2921
2652
  }
2922
2653
  /**
2923
2654
  * Protected getter for the client instance.
@@ -3189,7 +2920,7 @@ function createConnectionRequest(client, connectedAccountId, status, redirectUrl
3189
2920
  status: status || ConnectedAccountStatuses.INITIATED,
3190
2921
  redirectUrl
3191
2922
  };
3192
- require_fileUtils.telemetry.instrument(state, "ConnectionRequest");
2923
+ require_Telemetry.telemetry.instrument(state, "ConnectionRequest");
3193
2924
  /**
3194
2925
  * Waits for the connection request to complete and become active.
3195
2926
  *
@@ -3265,7 +2996,7 @@ var ConnectedAccounts = class {
3265
2996
  client;
3266
2997
  constructor(client) {
3267
2998
  this.client = client;
3268
- require_fileUtils.telemetry.instrument(this, "ConnectedAccounts");
2999
+ require_Telemetry.telemetry.instrument(this, "ConnectedAccounts");
3269
3000
  }
3270
3001
  /**
3271
3002
  * Lists all connected accounts based on provided filter criteria.
@@ -3366,7 +3097,7 @@ var ConnectedAccounts = class {
3366
3097
  statuses: [ConnectedAccountStatuses.ACTIVE]
3367
3098
  });
3368
3099
  if (connectedAccount.items.length > 0 && !options?.allowMultiple) throw new ComposioMultipleConnectedAccountsError(`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`);
3369
- else if (connectedAccount.items.length > 0) require_fileUtils.logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
3100
+ else if (connectedAccount.items.length > 0) require_buffer.logger_default.warn(`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`);
3370
3101
  const state = options?.config ?? void 0;
3371
3102
  const response = await this.client.connectedAccounts.create({
3372
3103
  auth_config: { id: authConfigId },
@@ -3664,7 +3395,7 @@ var Toolkits = class {
3664
3395
  constructor(client) {
3665
3396
  this.client = client;
3666
3397
  this.authorize = this.authorize.bind(this);
3667
- require_fileUtils.telemetry.instrument(this, "Toolkits");
3398
+ require_Telemetry.telemetry.instrument(this, "Toolkits");
3668
3399
  }
3669
3400
  /**
3670
3401
  * Retrieves a list of toolkits based on the provided query parameters.
@@ -3732,7 +3463,7 @@ var Toolkits = class {
3732
3463
  async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
3733
3464
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
3734
3465
  if (!toolkit.authConfigDetails) throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", { meta: { toolkitSlug } });
3735
- if (toolkit.authConfigDetails.length > 1 && !authScheme) require_fileUtils.logger_default.warn(`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`, { meta: { toolkitSlug } });
3466
+ if (toolkit.authConfigDetails.length > 1 && !authScheme) require_buffer.logger_default.warn(`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`, { meta: { toolkitSlug } });
3736
3467
  const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig$1) => authConfig$1.mode === authScheme) : toolkit.authConfigDetails[0];
3737
3468
  if (!authConfig) throw new ComposioAuthConfigNotFoundError(`Auth schema ${authScheme} not found for toolkit ${toolkitSlug} with auth scheme ${authScheme}`, { meta: {
3738
3469
  toolkitSlug,
@@ -3977,11 +3708,26 @@ const WebhookVersions = {
3977
3708
  * Parameters for verifying a webhook signature
3978
3709
  */
3979
3710
  const VerifyWebhookParamsSchema = zod_v3.z.object({
3980
- id: zod_v3.z.string(),
3981
- payload: zod_v3.z.string(),
3982
- secret: zod_v3.z.string(),
3983
- signature: zod_v3.z.string(),
3984
- timestamp: zod_v3.z.string(),
3711
+ id: zod_v3.z.string({
3712
+ required_error: "Missing 'id' parameter. Pass the value of the 'webhook-id' HTTP header.",
3713
+ invalid_type_error: "Invalid 'id' parameter. Expected string from 'webhook-id' HTTP header."
3714
+ }),
3715
+ payload: zod_v3.z.string({
3716
+ required_error: "Missing 'payload' parameter. Pass the raw request body as a string (do not parse it).",
3717
+ invalid_type_error: "Invalid 'payload' parameter. Expected string (raw request body)."
3718
+ }),
3719
+ secret: zod_v3.z.string({
3720
+ required_error: "Missing 'secret' parameter. Get your webhook secret from the Composio dashboard.",
3721
+ invalid_type_error: "Invalid 'secret' parameter. Expected string."
3722
+ }),
3723
+ signature: zod_v3.z.string({
3724
+ required_error: "Missing 'signature' parameter. Pass the value of the 'webhook-signature' HTTP header.",
3725
+ invalid_type_error: "Invalid 'signature' parameter. Expected string from 'webhook-signature' HTTP header."
3726
+ }),
3727
+ timestamp: zod_v3.z.string({
3728
+ required_error: "Missing 'timestamp' parameter. Pass the value of the 'webhook-timestamp' HTTP header.",
3729
+ invalid_type_error: "Invalid 'timestamp' parameter. Expected string from 'webhook-timestamp' HTTP header."
3730
+ }),
3985
3731
  tolerance: zod_v3.z.number().optional().default(300)
3986
3732
  });
3987
3733
 
@@ -4015,7 +3761,7 @@ var InternalService = class {
4015
3761
  projectId: response.project_id,
4016
3762
  pusherCluster: response.pusher_cluster
4017
3763
  });
4018
- require_fileUtils.logger_default.debug(`[InternalService] SDK realtime credentials: ${JSON.stringify(parsedResponse, null, 2)}`);
3764
+ require_buffer.logger_default.debug(`[InternalService] SDK realtime credentials: ${JSON.stringify(parsedResponse, null, 2)}`);
4019
3765
  if (!parsedResponse.success) throw new ValidationError(`Failed to parse SDK realtime credentials`, { cause: parsedResponse.error });
4020
3766
  return parsedResponse.data;
4021
3767
  }
@@ -4036,7 +3782,7 @@ var PusherService = class {
4036
3782
  this.composioClient = client;
4037
3783
  this.pusherBaseURL = client.baseURL;
4038
3784
  this.apiKey = client.apiKey ?? process.env.COMPOSIO_API_KEY ?? "";
4039
- require_fileUtils.telemetry.instrument(this, "PusherService");
3785
+ require_Telemetry.telemetry.instrument(this, "PusherService");
4040
3786
  }
4041
3787
  /**
4042
3788
  * Creates a Pusher client
@@ -4057,7 +3803,7 @@ var PusherService = class {
4057
3803
  this.pusherKey = sdkRealtimeCredentials.pusherKey;
4058
3804
  this.pusherCluster = sdkRealtimeCredentials.pusherCluster;
4059
3805
  this.pusherChannel = `private-${this.clientId}_triggers`;
4060
- require_fileUtils.logger_default.debug(`[PusherService] Creating Pusher client for client ID: ${this.clientId} in cluster ${this.pusherCluster}`);
3806
+ require_buffer.logger_default.debug(`[PusherService] Creating Pusher client for client ID: ${this.clientId} in cluster ${this.pusherCluster}`);
4061
3807
  try {
4062
3808
  const { default: Pusher } = await import("pusher-js");
4063
3809
  this.pusherClient = new Pusher(this.pusherKey, {
@@ -4101,19 +3847,19 @@ var PusherService = class {
4101
3847
  callback(JSON.parse(ev.chunks.join("")));
4102
3848
  } catch (parseError) {
4103
3849
  const errorMessage = parseError instanceof Error ? parseError.message : String(parseError);
4104
- require_fileUtils.logger_default.error("Failed to parse chunked data:", errorMessage);
3850
+ require_buffer.logger_default.error("Failed to parse chunked data:", errorMessage);
4105
3851
  } finally {
4106
3852
  delete events[typedData.id];
4107
3853
  }
4108
3854
  } catch (error) {
4109
3855
  const errorMessage = error instanceof Error ? error.message : String(error);
4110
- require_fileUtils.logger_default.error("Error processing chunked trigger data:", errorMessage);
3856
+ require_buffer.logger_default.error("Error processing chunked trigger data:", errorMessage);
4111
3857
  if (data && typeof data === "object" && "id" in data) delete events[data.id];
4112
3858
  }
4113
3859
  });
4114
3860
  } catch (error) {
4115
3861
  const errorMessage = error instanceof Error ? error.message : String(error);
4116
- require_fileUtils.logger_default.error("Failed to bind chunked events:", error);
3862
+ require_buffer.logger_default.error("Failed to bind chunked events:", error);
4117
3863
  throw new Error(`Failed to bind chunked events: ${errorMessage}`);
4118
3864
  }
4119
3865
  }
@@ -4129,7 +3875,7 @@ var PusherService = class {
4129
3875
  */
4130
3876
  async subscribe(fn) {
4131
3877
  try {
4132
- require_fileUtils.logger_default.debug(`[PusherService] Subscribing to channel: ${this.pusherChannel}`);
3878
+ require_buffer.logger_default.debug(`[PusherService] Subscribing to channel: ${this.pusherChannel}`);
4133
3879
  const channel = await (await this.getPusherClient()).subscribe(this.pusherChannel);
4134
3880
  channel.bind("pusher:subscription_error", (data) => {
4135
3881
  const error = data.error ? String(data.error) : "Unknown subscription error";
@@ -4140,11 +3886,11 @@ var PusherService = class {
4140
3886
  fn(data);
4141
3887
  } catch (error) {
4142
3888
  const errorMessage = error instanceof Error ? error.message : String(error);
4143
- require_fileUtils.logger_default.error("❌ Error in trigger callback:", errorMessage);
3889
+ require_buffer.logger_default.error("❌ Error in trigger callback:", errorMessage);
4144
3890
  }
4145
3891
  };
4146
3892
  this.bindWithChunking(channel, "trigger_to_client", safeCallback);
4147
- require_fileUtils.logger_default.info(`✅ Subscribed to triggers. You should start receiving events now.`);
3893
+ require_buffer.logger_default.info(`✅ Subscribed to triggers. You should start receiving events now.`);
4148
3894
  } catch (error) {
4149
3895
  throw new ComposioFailedToSubscribeToPusherChannelError("Failed to subscribe to Pusher channel", { cause: error });
4150
3896
  }
@@ -4159,9 +3905,9 @@ var PusherService = class {
4159
3905
  */
4160
3906
  async unsubscribe() {
4161
3907
  try {
4162
- require_fileUtils.logger_default.debug(`[PusherService] Unsubscribing from channel: ${this.pusherChannel}`);
3908
+ require_buffer.logger_default.debug(`[PusherService] Unsubscribing from channel: ${this.pusherChannel}`);
4163
3909
  await (await this.getPusherClient()).unsubscribe(this.pusherChannel);
4164
- require_fileUtils.logger_default.info(`✅ Unsubscribed from triggers.`);
3910
+ require_buffer.logger_default.info(`✅ Unsubscribed from triggers.`);
4165
3911
  } catch (error) {
4166
3912
  throw new ComposioFailedToSubscribeToPusherChannelError("Failed to unsubscribe from Pusher channel", { cause: error });
4167
3913
  }
@@ -4247,9 +3993,44 @@ function transformTriggerInstanceListActiveResponse(response) {
4247
3993
  }));
4248
3994
  }
4249
3995
 
3996
+ //#endregion
3997
+ //#region src/utils/crypto.ts
3998
+ /**
3999
+ * Computes HMAC-SHA256 using Web Crypto API
4000
+ */
4001
+ async function hmacSha256Base64(secret, message) {
4002
+ const encoder = new TextEncoder();
4003
+ const keyData = encoder.encode(secret);
4004
+ const key = await globalThis.crypto.subtle.importKey("raw", keyData, {
4005
+ name: "HMAC",
4006
+ hash: "SHA-256"
4007
+ }, false, ["sign"]);
4008
+ const signatureData = encoder.encode(message);
4009
+ return require_buffer.arrayBufferToBase64(await globalThis.crypto.subtle.sign("HMAC", key, signatureData));
4010
+ }
4011
+ /**
4012
+ * Constant-time comparison of two strings to prevent timing attacks
4013
+ */
4014
+ function timingSafeEqual(a, b) {
4015
+ if (a.length !== b.length) return false;
4016
+ let result = 0;
4017
+ for (let i = 0; i < a.length; i++) result |= a.charCodeAt(i) ^ b.charCodeAt(i);
4018
+ return result === 0;
4019
+ }
4020
+
4250
4021
  //#endregion
4251
4022
  //#region src/models/Triggers.ts
4252
4023
  /**
4024
+ * Safely converts a value to a string, returning the default if the value is null, undefined, or empty.
4025
+ * This prevents runtime crashes when calling string methods like `.toLowerCase()` on non-string values.
4026
+ * @private
4027
+ */
4028
+ const toStringOrDefault = (value, defaultValue) => {
4029
+ if (value === null || value === void 0) return defaultValue;
4030
+ const str = String(value);
4031
+ return str.length > 0 ? str : defaultValue;
4032
+ };
4033
+ /**
4253
4034
  * Trigger (Instance) class
4254
4035
  * /api/v3/trigger_instances
4255
4036
  *
@@ -4261,8 +4042,8 @@ var Triggers = class {
4261
4042
  constructor(client, config) {
4262
4043
  this.client = client;
4263
4044
  this.pusherService = new PusherService(client);
4264
- this.toolkitVersions = config?.toolkitVersions ?? "latest";
4265
- require_fileUtils.telemetry.instrument(this, "Triggers");
4045
+ this.toolkitVersions = config?.toolkitVersions ?? _config_defaults.CONFIG_DEFAULTS.toolkitVersions;
4046
+ require_Telemetry.telemetry.instrument(this, "Triggers");
4266
4047
  }
4267
4048
  /**
4268
4049
  * Fetch list of all the active triggers
@@ -4339,7 +4120,7 @@ var Triggers = class {
4339
4120
  });
4340
4121
  if (!connectedAccountId) {
4341
4122
  connectedAccountId = connectedAccounts[0].id;
4342
- require_fileUtils.logger_default.warn(`[Warn] Multiple connected accounts found for user ${userId}, using the first one. Pass connectedAccountId to select a specific account.`);
4123
+ require_buffer.logger_default.warn(`[Warn] Multiple connected accounts found for user ${userId}, using the first one. Pass connectedAccountId to select a specific account.`);
4343
4124
  }
4344
4125
  } catch (error) {
4345
4126
  if (error instanceof _composio_client.APIError && [400, 404].includes(error.status)) throw new ComposioConnectedAccountNotFoundError(`No connected account found for user ${userId} for toolkit ${toolkitSlug}`, {
@@ -4436,30 +4217,30 @@ var Triggers = class {
4436
4217
  */
4437
4218
  shouldSendTriggerAfterFilters(filters, data) {
4438
4219
  if (filters.toolkits?.length && !filters.toolkits.map((toolkit) => toolkit.toLowerCase()).includes(data.toolkitSlug.toLowerCase())) {
4439
- require_fileUtils.logger_default.debug("Trigger does not match toolkits filter", JSON.stringify(filters.toolkits, null, 2));
4220
+ require_buffer.logger_default.debug("Trigger does not match toolkits filter", JSON.stringify(filters.toolkits, null, 2));
4440
4221
  return false;
4441
4222
  }
4442
4223
  if (filters.triggerId && filters.triggerId !== data.id) {
4443
- require_fileUtils.logger_default.debug("Trigger does not match triggerId filter", JSON.stringify(filters.triggerId, null, 2));
4224
+ require_buffer.logger_default.debug("Trigger does not match triggerId filter", JSON.stringify(filters.triggerId, null, 2));
4444
4225
  return false;
4445
4226
  }
4446
4227
  if (filters.connectedAccountId && filters.connectedAccountId !== data.metadata.connectedAccount.id) {
4447
- require_fileUtils.logger_default.debug("Trigger does not match connectedAccountId filter", JSON.stringify(filters.connectedAccountId, null, 2));
4228
+ require_buffer.logger_default.debug("Trigger does not match connectedAccountId filter", JSON.stringify(filters.connectedAccountId, null, 2));
4448
4229
  return false;
4449
4230
  }
4450
4231
  if (filters.triggerSlug?.length && !filters.triggerSlug.map((triggerSlug) => triggerSlug.toLowerCase()).includes(data.triggerSlug.toLowerCase())) {
4451
- require_fileUtils.logger_default.debug("Trigger does not match triggerSlug filter", JSON.stringify(filters.triggerSlug, null, 2));
4232
+ require_buffer.logger_default.debug("Trigger does not match triggerSlug filter", JSON.stringify(filters.triggerSlug, null, 2));
4452
4233
  return false;
4453
4234
  }
4454
4235
  if (filters.triggerData && filters.triggerData !== data.metadata.triggerData) {
4455
- require_fileUtils.logger_default.debug("Trigger does not match triggerData filter", JSON.stringify(filters.triggerData, null, 2));
4236
+ require_buffer.logger_default.debug("Trigger does not match triggerData filter", JSON.stringify(filters.triggerData, null, 2));
4456
4237
  return false;
4457
4238
  }
4458
4239
  if (filters.userId && filters.userId !== data.metadata.connectedAccount.userId) {
4459
- require_fileUtils.logger_default.debug("Trigger does not match userId filter", JSON.stringify(filters.userId, null, 2));
4240
+ require_buffer.logger_default.debug("Trigger does not match userId filter", JSON.stringify(filters.userId, null, 2));
4460
4241
  return false;
4461
4242
  }
4462
- require_fileUtils.logger_default.debug("Trigger matches all filters", JSON.stringify(filters, null, 2));
4243
+ require_buffer.logger_default.debug("Trigger matches all filters", JSON.stringify(filters, null, 2));
4463
4244
  return true;
4464
4245
  }
4465
4246
  /**
@@ -4480,19 +4261,99 @@ var Triggers = class {
4480
4261
  if (!fn) throw new Error("Function is required for trigger subscription");
4481
4262
  const parsedFilters = TriggerSubscribeParamSchema.safeParse(filters);
4482
4263
  if (!parsedFilters.success) throw new ValidationError(`Invalid parameters passed to subscribe to triggers`, { cause: parsedFilters.error });
4483
- require_fileUtils.logger_default.debug("🔄 Subscribing to triggers with filters: ", JSON.stringify(filters, null, 2));
4264
+ require_buffer.logger_default.debug("🔄 Subscribing to triggers with filters: ", JSON.stringify(filters, null, 2));
4484
4265
  await this.pusherService.subscribe((_data) => {
4485
- require_fileUtils.logger_default.debug("Received raw trigger data", JSON.stringify(_data, null, 2));
4486
- const parsedData = transformIncomingTriggerPayload(_data);
4266
+ require_buffer.logger_default.debug("Received raw trigger data", JSON.stringify(_data, null, 2));
4267
+ const parsedData = this.parsePusherPayload(_data);
4487
4268
  if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData)) try {
4488
4269
  fn(parsedData);
4489
4270
  } catch (error) {
4490
- require_fileUtils.logger_default.error("❌ Error in trigger callback:", error);
4271
+ require_buffer.logger_default.error("❌ Error in trigger callback:", error);
4491
4272
  }
4492
- else require_fileUtils.logger_default.debug("Trigger does not match filters", JSON.stringify(parsedFilters.data, null, 2));
4273
+ else require_buffer.logger_default.debug("Trigger does not match filters", JSON.stringify(parsedFilters.data, null, 2));
4493
4274
  });
4494
4275
  }
4495
4276
  /**
4277
+ * Tries to parse data as V1, V2, or V3 webhook payload format.
4278
+ * Returns the parsed result with version info, or null if no format matches.
4279
+ * Also returns any schema validation errors for debugging purposes.
4280
+ * @private
4281
+ */
4282
+ tryParseVersionedPayload(data) {
4283
+ const v3Result = WebhookPayloadV3Schema.safeParse(data);
4284
+ if (v3Result.success) return {
4285
+ ok: true,
4286
+ version: WebhookVersions.V3,
4287
+ rawPayload: v3Result.data,
4288
+ normalizedPayload: this.normalizeV3Payload(v3Result.data)
4289
+ };
4290
+ const v2Result = WebhookPayloadV2Schema.safeParse(data);
4291
+ if (v2Result.success) return {
4292
+ ok: true,
4293
+ version: WebhookVersions.V2,
4294
+ rawPayload: v2Result.data,
4295
+ normalizedPayload: this.normalizeV2Payload(v2Result.data)
4296
+ };
4297
+ const v1Result = WebhookPayloadV1Schema.safeParse(data);
4298
+ if (v1Result.success) return {
4299
+ ok: true,
4300
+ version: WebhookVersions.V1,
4301
+ rawPayload: v1Result.data,
4302
+ normalizedPayload: this.normalizeV1Payload(v1Result.data)
4303
+ };
4304
+ return {
4305
+ ok: false,
4306
+ v1Error: v1Result.error.message,
4307
+ v2Error: v2Result.error.message,
4308
+ v3Error: v3Result.error.message
4309
+ };
4310
+ }
4311
+ /**
4312
+ * Parses incoming Pusher payload, supporting V1, V2, V3, and legacy TriggerData formats.
4313
+ * @private
4314
+ */
4315
+ parsePusherPayload(data) {
4316
+ const versionedResult = this.tryParseVersionedPayload(data);
4317
+ if (versionedResult.ok) {
4318
+ require_buffer.logger_default.debug(`Parsed Pusher payload as ${versionedResult.version} format`);
4319
+ return versionedResult.normalizedPayload;
4320
+ }
4321
+ const legacyData = data;
4322
+ if (legacyData.metadata?.nanoId && legacyData.appName) {
4323
+ require_buffer.logger_default.debug("Parsed Pusher payload as legacy TriggerData format");
4324
+ return transformIncomingTriggerPayload(legacyData);
4325
+ }
4326
+ require_buffer.logger_default.warn("Unknown Pusher payload format. Payload keys: " + Object.keys(data).join(", "));
4327
+ const id = toStringOrDefault(data.id, toStringOrDefault(data.trigger_id, "unknown"));
4328
+ const uuid = toStringOrDefault(data.uuid, toStringOrDefault(data.id, "unknown"));
4329
+ const triggerSlug = toStringOrDefault(data.triggerSlug, toStringOrDefault(data.trigger_name, "UNKNOWN"));
4330
+ const toolkitSlug = toStringOrDefault(data.toolkitSlug, toStringOrDefault(data.appName, "UNKNOWN"));
4331
+ return {
4332
+ id,
4333
+ uuid,
4334
+ triggerSlug,
4335
+ toolkitSlug,
4336
+ userId: toStringOrDefault(data.userId, ""),
4337
+ payload: data.payload || data,
4338
+ originalPayload: data.originalPayload || data,
4339
+ metadata: {
4340
+ id,
4341
+ uuid,
4342
+ triggerSlug,
4343
+ toolkitSlug,
4344
+ triggerConfig: {},
4345
+ connectedAccount: {
4346
+ id: "",
4347
+ uuid: "",
4348
+ authConfigId: "",
4349
+ authConfigUUID: "",
4350
+ userId: "",
4351
+ status: "ACTIVE"
4352
+ }
4353
+ }
4354
+ };
4355
+ }
4356
+ /**
4496
4357
  * Unsubscribe from all the triggers
4497
4358
  *
4498
4359
  * @returns {Promise<void>}
@@ -4535,9 +4396,9 @@ var Triggers = class {
4535
4396
  * @example
4536
4397
  * ```ts
4537
4398
  * // In an Express.js webhook handler
4538
- * app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
4399
+ * app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
4539
4400
  * try {
4540
- * const result = composio.triggers.verifyWebhook({
4401
+ * const result = await composio.triggers.verifyWebhook({
4541
4402
  * payload: req.body.toString(),
4542
4403
  * signature: req.headers['webhook-signature'] as string,
4543
4404
  * webhookId: req.headers['webhook-id'] as string,
@@ -4556,12 +4417,24 @@ var Triggers = class {
4556
4417
  * });
4557
4418
  * ```
4558
4419
  */
4559
- verifyWebhook(params) {
4420
+ async verifyWebhook(params) {
4560
4421
  const parsedParams = VerifyWebhookParamsSchema.safeParse(params);
4561
- if (!parsedParams.success) throw new ValidationError("Invalid parameters passed to verifyWebhook", { cause: parsedParams.error });
4422
+ if (!parsedParams.success) {
4423
+ const missingParams = parsedParams.error.issues.filter((issue) => issue.code === "invalid_type" && issue.received === "undefined").map((issue) => {
4424
+ const paramName = issue.path[0];
4425
+ const headerName = {
4426
+ id: "webhook-id",
4427
+ timestamp: "webhook-timestamp",
4428
+ signature: "webhook-signature"
4429
+ }[paramName];
4430
+ return headerName ? `'${paramName}' (from '${headerName}' header)` : `'${paramName}'`;
4431
+ });
4432
+ if (missingParams.length > 0) throw new ValidationError(`Missing required parameters: ${missingParams.join(", ")}. Extract these values from the HTTP request headers and body.`, { cause: parsedParams.error });
4433
+ throw new ValidationError("Invalid parameters passed to verifyWebhook", { cause: parsedParams.error });
4434
+ }
4562
4435
  const { payload, signature, secret, id: webhookId, timestamp: webhookTimestamp, tolerance } = parsedParams.data;
4563
4436
  if (tolerance > 0) this.validateWebhookTimestamp(webhookTimestamp, tolerance);
4564
- this.verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret);
4437
+ await this.verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret);
4565
4438
  const { version: version$1, rawPayload, normalizedPayload } = this.parseWebhookPayload(payload);
4566
4439
  return {
4567
4440
  version: version$1,
@@ -4580,28 +4453,16 @@ var Triggers = class {
4580
4453
  } catch (error) {
4581
4454
  throw new ComposioWebhookPayloadError("Failed to parse webhook payload as JSON", { cause: error });
4582
4455
  }
4583
- const v3Result = WebhookPayloadV3Schema.safeParse(jsonPayload);
4584
- if (v3Result.success) return {
4585
- version: WebhookVersions.V3,
4586
- rawPayload: v3Result.data,
4587
- normalizedPayload: this.normalizeV3Payload(v3Result.data)
4588
- };
4589
- const v2Result = WebhookPayloadV2Schema.safeParse(jsonPayload);
4590
- if (v2Result.success) return {
4591
- version: WebhookVersions.V2,
4592
- rawPayload: v2Result.data,
4593
- normalizedPayload: this.normalizeV2Payload(v2Result.data)
4594
- };
4595
- const v1Result = WebhookPayloadV1Schema.safeParse(jsonPayload);
4596
- if (v1Result.success) return {
4597
- version: WebhookVersions.V1,
4598
- rawPayload: v1Result.data,
4599
- normalizedPayload: this.normalizeV1Payload(v1Result.data)
4600
- };
4456
+ const result = this.tryParseVersionedPayload(jsonPayload);
4457
+ if (result.ok) {
4458
+ const { ok, ...rest } = result;
4459
+ return rest;
4460
+ }
4461
+ const { v1Error, v2Error, v3Error } = result;
4601
4462
  throw new ComposioWebhookPayloadError("Webhook payload does not match any known version (V1, V2, or V3). Please ensure you are using a supported webhook payload format.", { cause: {
4602
- v1Error: v1Result.error?.message,
4603
- v2Error: v2Result.error?.message,
4604
- v3Error: v3Result.error?.message
4463
+ v1Error,
4464
+ v2Error,
4465
+ v3Error
4605
4466
  } });
4606
4467
  }
4607
4468
  /**
@@ -4707,7 +4568,7 @@ var Triggers = class {
4707
4568
  * The signing input is: `${msgId}.${timestamp}.${payload}`
4708
4569
  * @private
4709
4570
  */
4710
- verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret) {
4571
+ async verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret) {
4711
4572
  if (payload.length === 0) throw new ComposioWebhookSignatureVerificationError("No webhook payload was provided.");
4712
4573
  if (signature.length === 0) throw new ComposioWebhookSignatureVerificationError("No signature header value was provided. Please pass the value of the 'webhook-signature' header.");
4713
4574
  if (secret.length === 0) throw new ComposioWebhookSignatureVerificationError("No webhook secret was provided. You can find your webhook secret in your Composio dashboard.");
@@ -4720,16 +4581,11 @@ var Triggers = class {
4720
4581
  if (version$1 === "v1" && value) v1Signatures.push(value);
4721
4582
  }
4722
4583
  if (v1Signatures.length === 0) throw new ComposioWebhookSignatureVerificationError("No valid v1 signature found in the webhook-signature header. Expected format: 'v1,base64EncodedSignature'");
4723
- const toSign = `${webhookId}.${webhookTimestamp}.${payload}`;
4724
- const expectedSignature = node_crypto.createHmac("sha256", secret).update(toSign, "utf8").digest("base64");
4584
+ const expectedSignature = await hmacSha256Base64(secret, `${webhookId}.${webhookTimestamp}.${payload}`);
4725
4585
  let isValid = false;
4726
- for (const providedSignature of v1Signatures) {
4727
- const signatureBuffer = Buffer.from(providedSignature);
4728
- const expectedBuffer = Buffer.from(expectedSignature);
4729
- if (signatureBuffer.length === expectedBuffer.length && node_crypto.timingSafeEqual(signatureBuffer, expectedBuffer)) {
4730
- isValid = true;
4731
- break;
4732
- }
4586
+ for (const providedSignature of v1Signatures) if (timingSafeEqual(providedSignature, expectedSignature)) {
4587
+ isValid = true;
4588
+ break;
4733
4589
  }
4734
4590
  if (!isValid) throw new ComposioWebhookSignatureVerificationError("The signature provided is invalid. Please ensure you are using the correct webhook secret.");
4735
4591
  }
@@ -4847,7 +4703,7 @@ var MCP = class {
4847
4703
  client;
4848
4704
  constructor(client) {
4849
4705
  this.client = client;
4850
- require_fileUtils.telemetry.instrument(this, "MCP");
4706
+ require_Telemetry.telemetry.instrument(this, "MCP");
4851
4707
  }
4852
4708
  /**
4853
4709
  * Create a new MCP configuration.
@@ -5163,9 +5019,9 @@ const userDataPath = () => {
5163
5019
  try {
5164
5020
  const homeDir = _platform.platform.homedir();
5165
5021
  if (!homeDir) return null;
5166
- return _platform.platform.joinPath(homeDir, require_fileUtils.COMPOSIO_DIR, require_fileUtils.USER_DATA_FILE_NAME);
5022
+ return _platform.platform.joinPath(homeDir, require_buffer.COMPOSIO_DIR, require_buffer.USER_DATA_FILE_NAME);
5167
5023
  } catch (_error) {
5168
- require_fileUtils.logger_default.debug("Environment", `Unable to get user data path`);
5024
+ require_buffer.logger_default.debug("Environment", `Unable to get user data path`);
5169
5025
  return null;
5170
5026
  }
5171
5027
  };
@@ -5181,17 +5037,17 @@ const getUserDataJson = () => {
5181
5037
  const data = _platform.platform.readFileSync(dataPath, "utf8");
5182
5038
  return JSON.parse(data);
5183
5039
  } catch (_error) {
5184
- require_fileUtils.logger_default.debug("Environment", "No user data file found");
5040
+ require_buffer.logger_default.debug("Environment", "No user data file found");
5185
5041
  return {};
5186
5042
  }
5187
5043
  };
5188
5044
  function getSDKConfig(baseUrl, apiKey) {
5189
5045
  const { api_key: apiKeyFromUserConfig, base_url: baseURLFromUserConfig } = getUserDataJson();
5190
- const baseURLParsed = baseUrl || require_fileUtils.getEnvVariable("COMPOSIO_BASE_URL") || baseURLFromUserConfig || require_fileUtils.DEFAULT_BASE_URL;
5191
- const apiKeyParsed = apiKey || require_fileUtils.getEnvVariable("COMPOSIO_API_KEY") || apiKeyFromUserConfig || "";
5192
- if (!apiKeyParsed) require_fileUtils.ComposioError.handleAndThrow(new ComposioNoAPIKeyError());
5193
- require_fileUtils.logger_default.debug("Environment", `API Key: ${apiKeyParsed}`);
5194
- require_fileUtils.logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
5046
+ const baseURLParsed = baseUrl || require_buffer.getEnvVariable("COMPOSIO_BASE_URL") || baseURLFromUserConfig || require_buffer.DEFAULT_BASE_URL;
5047
+ const apiKeyParsed = apiKey || require_buffer.getEnvVariable("COMPOSIO_API_KEY") || apiKeyFromUserConfig || "";
5048
+ if (!apiKeyParsed) require_buffer.ComposioError.handleAndThrow(new ComposioNoAPIKeyError());
5049
+ require_buffer.logger_default.debug("Environment", `API Key: ${apiKeyParsed}`);
5050
+ require_buffer.logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
5195
5051
  return {
5196
5052
  baseURL: baseURLParsed,
5197
5053
  apiKey: apiKeyParsed
@@ -5211,7 +5067,7 @@ function getSDKConfig(baseUrl, apiKey) {
5211
5067
  */
5212
5068
  function getToolkitVersionsFromEnv(defaultVersions) {
5213
5069
  if (defaultVersions && typeof defaultVersions === "string") return defaultVersions;
5214
- const envPrefixedVersions = require_fileUtils.getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
5070
+ const envPrefixedVersions = require_buffer.getEnvsWithPrefix(`COMPOSIO_TOOLKIT_VERSION_`);
5215
5071
  const toolkitVersionsFromEnv = Object.entries(envPrefixedVersions).reduce((acc, [key, value]) => {
5216
5072
  const toolkitName = key.replace("COMPOSIO_TOOLKIT_VERSION_", "");
5217
5073
  acc[toolkitName.toLowerCase()] = value;
@@ -5241,7 +5097,7 @@ async function checkForLatestVersionFromNPM(currentVersion) {
5241
5097
  const prerelease = semver.default.prerelease(currentVersionFromPackageJson);
5242
5098
  if (prerelease && (String(prerelease[0]).includes("alpha") || String(prerelease[0]).includes("beta"))) return;
5243
5099
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${packageName}/latest`)).json()).version;
5244
- if (semver.default.gt(latestVersion, currentVersionFromPackageJson) && !require_fileUtils.IS_DEVELOPMENT_OR_CI) require_fileUtils.logger_default.info(`🚀 Upgrade available! Your composio-core version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
5100
+ if (semver.default.gt(latestVersion, currentVersionFromPackageJson) && !require_buffer.IS_DEVELOPMENT_OR_CI) require_buffer.logger_default.info(`🚀 Upgrade available! Your composio-core version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`);
5245
5101
  } catch (_error) {}
5246
5102
  }
5247
5103
 
@@ -5567,9 +5423,9 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5567
5423
  async handleAssistantMessage(userId, run, options, modifiers) {
5568
5424
  const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
5569
5425
  return await Promise.all(tool_calls.map(async (tool_call) => {
5570
- require_fileUtils.logger_default.debug(`Executing tool call: ${tool_call.id}`);
5426
+ require_buffer.logger_default.debug(`Executing tool call: ${tool_call.id}`);
5571
5427
  const tool_response = await this.executeToolCall(userId, tool_call, options, modifiers);
5572
- require_fileUtils.logger_default.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
5428
+ require_buffer.logger_default.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
5573
5429
  return {
5574
5430
  tool_call_id: tool_call.id,
5575
5431
  output: JSON.stringify(tool_response)
@@ -5728,7 +5584,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5728
5584
 
5729
5585
  //#endregion
5730
5586
  //#region package.json
5731
- var version = "0.5.5";
5587
+ var version = "0.6.1";
5732
5588
 
5733
5589
  //#endregion
5734
5590
  //#region src/utils/session.ts
@@ -5947,7 +5803,7 @@ var ToolRouter = class {
5947
5803
  constructor(client, config) {
5948
5804
  this.client = client;
5949
5805
  this.config = config;
5950
- require_fileUtils.telemetry.instrument(this, "ToolRouter");
5806
+ require_Telemetry.telemetry.instrument(this, "ToolRouter");
5951
5807
  }
5952
5808
  /**
5953
5809
  * Creates a function that authorizes a toolkit for a user.
@@ -6239,7 +6095,7 @@ var Composio = class Composio {
6239
6095
  */
6240
6096
  constructor(config) {
6241
6097
  const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(config?.baseURL, config?.apiKey);
6242
- if (require_fileUtils.IS_DEVELOPMENT_OR_CI) require_fileUtils.logger_default.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
6098
+ if (require_buffer.IS_DEVELOPMENT_OR_CI) require_buffer.logger_default.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
6243
6099
  /**
6244
6100
  * Set the default provider, if not provided by the user.
6245
6101
  */
@@ -6253,8 +6109,8 @@ var Composio = class Composio {
6253
6109
  baseURL: baseURLParsed,
6254
6110
  apiKey: apiKeyParsed,
6255
6111
  toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
6256
- allowTracking: config?.allowTracking ?? true,
6257
- autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? true,
6112
+ allowTracking: config?.allowTracking ?? _config_defaults.CONFIG_DEFAULTS.allowTracking,
6113
+ autoUploadDownloadFiles: config?.autoUploadDownloadFiles ?? _config_defaults.CONFIG_DEFAULTS.autoUploadDownloadFiles,
6258
6114
  provider: config?.provider ?? this.provider
6259
6115
  };
6260
6116
  /**
@@ -6265,7 +6121,7 @@ var Composio = class Composio {
6265
6121
  apiKey: apiKeyParsed,
6266
6122
  baseURL: baseURLParsed,
6267
6123
  defaultHeaders: getDefaultHeaders(this.config.defaultHeaders, this.provider),
6268
- logLevel: require_fileUtils.COMPOSIO_LOG_LEVEL
6124
+ logLevel: require_buffer.COMPOSIO_LOG_LEVEL
6269
6125
  });
6270
6126
  this.tools = new Tools(this.client, this.config);
6271
6127
  this.mcp = new MCP(this.client);
@@ -6284,7 +6140,7 @@ var Composio = class Composio {
6284
6140
  /**
6285
6141
  * Initialize the client telemetry.
6286
6142
  */
6287
- if (this.config.allowTracking) require_fileUtils.telemetry.setup({
6143
+ if (this.config.allowTracking) require_Telemetry.telemetry.setup({
6288
6144
  apiKey: apiKeyParsed ?? "",
6289
6145
  baseUrl: baseURLParsed ?? "",
6290
6146
  isAgentic: this.provider?._isAgentic || false,
@@ -6293,8 +6149,8 @@ var Composio = class Composio {
6293
6149
  provider: this.provider?.name ?? "openai",
6294
6150
  host: this.config.host
6295
6151
  });
6296
- require_fileUtils.telemetry.instrument(this, "Composio");
6297
- require_fileUtils.telemetry.instrument(this.provider, this.provider.name ?? this.provider.constructor.name ?? "unknown");
6152
+ require_Telemetry.telemetry.instrument(this, "Composio");
6153
+ require_Telemetry.telemetry.instrument(this.provider, this.provider.name ?? this.provider.constructor.name ?? "unknown");
6298
6154
  if (!this.config.disableVersionCheck) checkForLatestVersionFromNPM(version);
6299
6155
  }
6300
6156
  /**
@@ -6383,7 +6239,7 @@ var Composio = class Composio {
6383
6239
  * ```
6384
6240
  */
6385
6241
  async flush() {
6386
- await require_fileUtils.telemetry.flush();
6242
+ await require_Telemetry.telemetry.flush();
6387
6243
  }
6388
6244
  };
6389
6245
 
@@ -6825,7 +6681,7 @@ exports.ComposioAuthConfigNotFoundError = ComposioAuthConfigNotFoundError;
6825
6681
  exports.ComposioConnectedAccountNotFoundError = ComposioConnectedAccountNotFoundError;
6826
6682
  exports.ComposioCustomCreateResponseSchema = ComposioCustomCreateResponseSchema;
6827
6683
  exports.ComposioCustomToolsNotInitializedError = ComposioCustomToolsNotInitializedError;
6828
- exports.ComposioError = require_fileUtils.ComposioError;
6684
+ exports.ComposioError = require_buffer.ComposioError;
6829
6685
  exports.ComposioFailedToCreateConnectedAccountLink = ComposioFailedToCreateConnectedAccountLink;
6830
6686
  exports.ComposioFailedToCreatePusherClientError = ComposioFailedToCreatePusherClientError;
6831
6687
  exports.ComposioFailedToGetSDKRealtimeCredentialsError = ComposioFailedToGetSDKRealtimeCredentialsError;
@@ -6987,11 +6843,11 @@ exports.WebhookVersions = WebhookVersions;
6987
6843
  Object.defineProperty(exports, 'constants', {
6988
6844
  enumerable: true,
6989
6845
  get: function () {
6990
- return require_fileUtils.constants_exports;
6846
+ return require_buffer.constants_exports;
6991
6847
  }
6992
6848
  });
6993
6849
  exports.createConnectionRequest = createConnectionRequest;
6994
6850
  exports.handleToolExecutionError = handleToolExecutionError;
6995
6851
  exports.jsonSchemaToZodSchema = jsonSchemaToZodSchema;
6996
- exports.logger = require_fileUtils.logger_default;
6852
+ exports.logger = require_buffer.logger_default;
6997
6853
  exports.removeNonRequiredProperties = removeNonRequiredProperties;