@composio/core 0.1.12-alpha.0 → 0.1.12-alpha.11

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
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  });
7
7
 
8
8
  // src/composio.ts
9
- import ComposioClient from "@composio/client";
9
+ import ComposioClient3 from "@composio/client";
10
10
 
11
11
  // src/types/tool.types.ts
12
12
  import { z } from "zod";
@@ -69,12 +69,14 @@ var ToolExecuteResponseSchema = z.object({
69
69
  // src/models/CustomTools.ts
70
70
  import zodToJsonSchema from "zod-to-json-schema";
71
71
 
72
+ // src/utils/logger.ts
73
+ import chalk from "chalk";
74
+
72
75
  // src/utils/env.ts
73
76
  var getEnvVariable = (name, defaultValue = void 0) => {
74
77
  try {
75
78
  return process.env[name] || defaultValue;
76
79
  } catch (_e) {
77
- logger_default.error(`Error getting environment variable ${name}:`, _e);
78
80
  return defaultValue;
79
81
  }
80
82
  };
@@ -93,7 +95,7 @@ var LOG_LEVELS = {
93
95
  // Debug information
94
96
  };
95
97
  var getLogLevel = () => {
96
- const envLevel = getEnvVariable("COMPOSIO_LOGGING_LEVEL", "info")?.toLowerCase();
98
+ const envLevel = getEnvVariable("COMPOSIO_LOG_LEVEL", "info")?.toLowerCase();
97
99
  return envLevel && envLevel in LOG_LEVELS ? envLevel : "info";
98
100
  };
99
101
  var Logger = class {
@@ -106,12 +108,25 @@ var Logger = class {
106
108
  this.console = console;
107
109
  }
108
110
  formatMessage(args) {
109
- const formattedArgs = args.map((arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)).join("\n");
111
+ const formattedArgs = args.map((arg, index) => {
112
+ if (typeof arg === "object") {
113
+ return JSON.stringify(arg);
114
+ } else {
115
+ if (index === 0) {
116
+ if (args.length > 1) {
117
+ return chalk.yellow(`${arg}`);
118
+ } else {
119
+ return String(arg);
120
+ }
121
+ }
122
+ return String(arg);
123
+ }
124
+ }).join("\n");
110
125
  if (!this.includeTimestamp) {
111
126
  return formattedArgs;
112
127
  }
113
128
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
114
- return `${timestamp} - ${formattedArgs}`;
129
+ return `${chalk.gray(timestamp)} - ${formattedArgs}`;
115
130
  }
116
131
  shouldLog(level) {
117
132
  return LOG_LEVELS[level] <= LOG_LEVELS[this.level];
@@ -141,34 +156,211 @@ var logger = new Logger();
141
156
  var logger_default = logger;
142
157
 
143
158
  // src/errors/ComposioError.ts
144
- var ComposioError = class extends Error {
159
+ import chalk2 from "chalk";
160
+ import { ZodError } from "zod";
161
+ import { BadRequestError } from "@composio/client";
162
+ var ComposioError = class _ComposioError extends Error {
163
+ /** @readonly Error name */
145
164
  name = "ComposioError";
146
165
  code;
147
- statusCode;
148
- cause;
149
- meta;
150
166
  possibleFixes;
167
+ errorId;
168
+ /**
169
+ * Creates a new ComposioError
170
+ * @param message Error message
171
+ * @param options Additional error options
172
+ */
151
173
  constructor(message, options = {}) {
152
174
  super(message);
153
- this.code = options.code;
154
- this.statusCode = options.statusCode;
155
- this.cause = options.cause;
156
- this.meta = options.meta;
175
+ const statusCode = options.statusCode || (options.cause instanceof BadRequestError ? options.cause.status : void 0);
176
+ this.code = `TS-SDK::${options.code}`;
157
177
  this.possibleFixes = options.possibleFixes;
178
+ this.definePropertyIfExists("statusCode", statusCode);
179
+ this.definePropertyIfExists("cause", options.cause);
180
+ this.definePropertyIfExists("stack", options.stack);
181
+ if (options.meta && Object.keys(options.meta).length > 0) {
182
+ this.definePropertyIfExists("meta", options.meta);
183
+ }
158
184
  if (Error.captureStackTrace) {
159
185
  Error.captureStackTrace(this, this.constructor);
160
186
  }
161
187
  }
162
- toJSON() {
163
- return {
188
+ /**
189
+ * Helper method to define a property only if it has a value
190
+ * @param propertyName Name of the property to define
191
+ * @param value Value to assign to the property
192
+ * @private
193
+ */
194
+ definePropertyIfExists(propertyName, value) {
195
+ if (value !== void 0) {
196
+ Object.defineProperty(this, propertyName, {
197
+ value,
198
+ enumerable: true,
199
+ writable: false,
200
+ configurable: true
201
+ });
202
+ }
203
+ }
204
+ /**
205
+ * Extract and normalize error data for formatting
206
+ * @param includeStack Whether to include stack trace information
207
+ * @returns Structured error data for formatting
208
+ * @private
209
+ */
210
+ getErrorData(includeStack = false) {
211
+ const data = {
164
212
  name: this.name,
165
- message: this.message,
166
- code: this.code,
167
- statusCode: this.statusCode,
168
- cause: this.cause instanceof Error ? this.cause.message : this.cause,
169
- meta: this.meta,
170
- possibleFixes: this.possibleFixes?.length ? this.possibleFixes.join("\n") : void 0
213
+ message: this.message
171
214
  };
215
+ const { cause, code, stack, statusCode, meta, possibleFixes } = this;
216
+ if (cause !== void 0) {
217
+ const rawCause = cause;
218
+ data.cause = rawCause instanceof Error ? rawCause.message : String(rawCause);
219
+ }
220
+ if (code) {
221
+ data.code = code;
222
+ }
223
+ if (statusCode !== void 0) {
224
+ data.statusCode = statusCode;
225
+ }
226
+ if (meta) {
227
+ data.meta = meta;
228
+ }
229
+ if (possibleFixes) {
230
+ data.possibleFixes = possibleFixes;
231
+ }
232
+ if (includeStack && stack) {
233
+ data.stack = stack.split("\n").slice(1);
234
+ }
235
+ return data;
236
+ }
237
+ /**
238
+ * Prints a user-friendly, colorful representation of the error to the logger
239
+ * @param includeStack Whether to include the stack trace in the output (default: false)
240
+ */
241
+ prettyPrint(includeStack = false) {
242
+ const data = this.getErrorData(includeStack);
243
+ let output = "\n" + chalk2.bgRed.white.bold(" ERROR ") + " " + chalk2.white.bold(data.message) + "\n";
244
+ if (data.code) {
245
+ output += chalk2.yellow(`Error Code: ${data.code}`) + "\n";
246
+ }
247
+ if (data.statusCode !== void 0) {
248
+ output += chalk2.yellow(`Status: ${data.statusCode}`) + "\n";
249
+ }
250
+ if (data.cause) {
251
+ output += chalk2.gray("Reason:") + "\n";
252
+ output += " " + chalk2.white(data.cause) + "\n";
253
+ }
254
+ if (data.meta) {
255
+ output += chalk2.gray("Additional Information:") + "\n";
256
+ output += " " + chalk2.white(JSON.stringify(data.meta, null, 2).replace(/\n/g, "\n ")) + "\n";
257
+ }
258
+ if (data.possibleFixes?.length) {
259
+ output += "\n" + chalk2.cyan.bold("Try the following:") + "\n";
260
+ const fixes = data.possibleFixes?.map((fix, index) => ` ${index + 1}. ` + chalk2.white(fix));
261
+ output += fixes?.join("\n") + "\n";
262
+ }
263
+ if (data.stack?.length) {
264
+ output += "\n" + chalk2.gray("Stack Trace:") + "\n";
265
+ output += chalk2.gray(data.stack.join("\n")) + "\n";
266
+ }
267
+ output += "\n";
268
+ logger_default.error(output);
269
+ }
270
+ /**
271
+ * Static factory method to create and pretty print an error in one step
272
+ * @param message Error message
273
+ * @param options Error options
274
+ * @param includeStack Whether to include the stack trace in the output
275
+ * @returns The created error instance
276
+ */
277
+ static createAndPrint(message, options = {}, includeStack = false) {
278
+ const error = new _ComposioError(message, options);
279
+ error.prettyPrint(includeStack);
280
+ return error;
281
+ }
282
+ /**
283
+ * Utility function to handle errors in a consistent way
284
+ * This properly displays the error and exits the process if needed
285
+ * @param error The error to handle
286
+ * @param options Options for error handling
287
+ */
288
+ static handle(error, options = {}) {
289
+ const { includeStack = false, exitProcess = false, exitCode = 1 } = options;
290
+ if (error instanceof _ComposioError) {
291
+ error.prettyPrint(includeStack);
292
+ } else if (error instanceof ZodError) {
293
+ this.handleZodError(error, includeStack);
294
+ } else if (error instanceof Error) {
295
+ this.handleStandardError(error, includeStack);
296
+ } else {
297
+ this.handleUnknownError(error);
298
+ }
299
+ if (exitProcess && typeof process !== "undefined") {
300
+ process.exit(exitCode);
301
+ }
302
+ }
303
+ /**
304
+ * Helper method to handle Zod validation errors
305
+ * @param error The Zod error to handle
306
+ * @param includeStack Whether to include the stack trace
307
+ * @private
308
+ */
309
+ static handleZodError(error, includeStack) {
310
+ logger_default.error("\n" + chalk2.bgRed.white.bold(" ERROR ") + " " + chalk2.white.bold(error.message));
311
+ logger_default.error(chalk2.gray("Invalid parameters:"));
312
+ error.errors.forEach((err) => {
313
+ logger_default.error(chalk2.yellow(err.path.join(".")) + " " + chalk2.white(err.message));
314
+ });
315
+ logger_default.error(chalk2.gray("Expected parameters:"));
316
+ error.errors.forEach((err) => {
317
+ logger_default.error(chalk2.yellow(err.path.join(".")) + " " + chalk2.white(err.message));
318
+ });
319
+ if (includeStack) {
320
+ logger_default.error("\n" + chalk2.gray("Validation Errors:"));
321
+ error.errors.forEach((err) => {
322
+ const path = err.path.join(".");
323
+ logger_default.error(
324
+ chalk2.gray(" \u2022 ") + chalk2.yellow(path ? `${path}: ` : "") + chalk2.white(err.message)
325
+ );
326
+ });
327
+ if (error.stack) {
328
+ logger_default.error("\n" + chalk2.gray("Stack Trace:"));
329
+ const stackLines = error.stack.split("\n").slice(1);
330
+ logger_default.error(chalk2.gray(stackLines.join("\n")));
331
+ }
332
+ }
333
+ logger_default.error("");
334
+ }
335
+ /**
336
+ * Helper method to handle standard Error objects
337
+ * @param error The standard error to handle
338
+ * @param includeStack Whether to include the stack trace
339
+ * @private
340
+ */
341
+ static handleStandardError(error, includeStack) {
342
+ logger_default.error("\n" + chalk2.bgRed.white.bold(" ERROR ") + " " + chalk2.white.bold(error.message));
343
+ if (includeStack && error.stack) {
344
+ logger_default.error("\n" + chalk2.gray("Stack Trace:"));
345
+ const stackLines = error.stack.split("\n").slice(1);
346
+ logger_default.error(chalk2.gray(stackLines.join("\n")));
347
+ }
348
+ logger_default.error("");
349
+ }
350
+ /**
351
+ * Helper method to handle unknown error types
352
+ * @param error The unknown error value
353
+ * @private
354
+ */
355
+ static handleUnknownError(error) {
356
+ logger_default.error(
357
+ "\n" + chalk2.bgRed.white.bold(" ERROR ") + " " + chalk2.white.bold("Unknown error occurred")
358
+ );
359
+ if (error !== null && error !== void 0) {
360
+ logger_default.error(chalk2.gray("Error details:"));
361
+ logger_default.error(" " + chalk2.white(String(error)));
362
+ }
363
+ logger_default.error("");
172
364
  }
173
365
  };
174
366
 
@@ -183,11 +375,11 @@ var ToolErrorCodes = {
183
375
  GLOBAL_EXECUTE_TOOL_FN_NOT_SET: "GLOBAL_EXECUTE_TOOL_FN_NOT_SET"
184
376
  };
185
377
  var ComposioProviderNotDefinedError = class extends ComposioError {
186
- constructor(message = "Provider not defined", meta = {}) {
378
+ constructor(message = "Provider not defined", options = {}) {
187
379
  super(message, {
380
+ ...options,
188
381
  code: ToolErrorCodes.TOOLSET_NOT_DEFINED,
189
- meta,
190
- possibleFixes: [
382
+ possibleFixes: options.possibleFixes || [
191
383
  "Ensure that the provider is defined in the Composio project and passed into the tool instance"
192
384
  ]
193
385
  });
@@ -195,86 +387,408 @@ var ComposioProviderNotDefinedError = class extends ComposioError {
195
387
  }
196
388
  };
197
389
  var ComposioToolNotFoundError = class extends ComposioError {
198
- constructor(message = "Tool not found", meta = {}) {
390
+ constructor(message = "Tool not found", options = {}) {
199
391
  super(message, {
392
+ ...options,
200
393
  code: ToolErrorCodes.TOOL_NOT_FOUND,
201
- meta,
202
- possibleFixes: ["Ensure the tool slug is correct and exists in the Composio project"]
394
+ possibleFixes: options.possibleFixes || [
395
+ "Ensure the tool slug is correct and exists in the Composio project"
396
+ ]
203
397
  });
204
398
  this.name = "ComposioToolNotFoundError";
205
399
  }
206
400
  };
207
401
  var ComposioInvalidModifierError = class extends ComposioError {
208
- constructor(message = "Invalid modifier", meta = {}) {
402
+ constructor(message = "Invalid modifier", options = {}) {
209
403
  super(message, {
404
+ ...options,
210
405
  code: ToolErrorCodes.INVALID_MODIFIER,
211
- meta,
212
- possibleFixes: ["Ensure the modifier is a function and returns a valid result"]
406
+ possibleFixes: options.possibleFixes || [
407
+ "Ensure the modifier is a function and returns a valid result"
408
+ ]
213
409
  });
214
410
  this.name = "ComposioInvalidModifierError";
215
411
  }
216
412
  };
217
413
  var ComposioCustomToolsNotInitializedError = class extends ComposioError {
218
- constructor(message = "Custom tools not initialized", meta = {}) {
414
+ constructor(message = "Custom tools not initialized", options = {}) {
219
415
  super(message, {
416
+ ...options,
220
417
  code: ToolErrorCodes.CUSTOM_TOOLS_NOT_INITIALIZED,
221
- meta,
222
- possibleFixes: ["Ensure the custom tools class is initialized in the Tools instance"]
418
+ possibleFixes: options.possibleFixes || [
419
+ "Ensure the custom tools class is initialized in the Tools instance"
420
+ ]
223
421
  });
224
422
  this.name = "ComposioCustomToolsNotInitializedError";
225
423
  }
226
424
  };
227
425
  var ComposioToolExecutionError = class extends ComposioError {
228
426
  error;
229
- constructor(error, message = "Tool execution error", meta = {}) {
427
+ constructor(message = "Tool execution error", options = {}) {
428
+ const { originalError, ...restOptions } = options;
230
429
  super(message, {
231
- code: ToolErrorCodes.TOOL_EXECUTION_ERROR,
232
- cause: error,
233
- meta,
234
- possibleFixes: ["Ensure the tool is correctly configured and the input is valid"]
430
+ ...restOptions,
431
+ code: options.code || ToolErrorCodes.TOOL_EXECUTION_ERROR,
432
+ cause: options.cause || originalError,
433
+ possibleFixes: options.possibleFixes || [
434
+ "Ensure the tool is correctly configured and the input is valid"
435
+ ]
235
436
  });
236
- this.error = error;
437
+ this.error = originalError || (options.cause instanceof Error ? options.cause : new Error(String(options.cause)));
237
438
  this.name = "ComposioToolExecutionError";
238
439
  }
239
440
  };
240
441
  var ComposioInvalidExecuteFunctionError = class extends ComposioError {
241
- constructor(message = "Invalid execute function", meta = {}) {
442
+ constructor(message = "Invalid execute function", options = {}) {
242
443
  super(message, {
444
+ ...options,
243
445
  code: ToolErrorCodes.INVALID_EXECUTE_FUNCTION,
244
- meta,
245
- possibleFixes: ["Ensure the execute function is a valid function and returns a valid result"]
446
+ possibleFixes: options.possibleFixes || [
447
+ "Ensure the execute function is a valid function and returns a valid result"
448
+ ]
246
449
  });
247
450
  this.name = "ComposioInvalidExecuteFunctionError";
248
451
  }
249
452
  };
250
453
  var ComposioGlobalExecuteToolFnNotSetError = class extends ComposioError {
251
- constructor(message = "Global execute tool function not set", meta = {}) {
454
+ constructor(message = "Global execute tool function not set", options = {}) {
252
455
  super(message, {
456
+ ...options,
253
457
  code: ToolErrorCodes.GLOBAL_EXECUTE_TOOL_FN_NOT_SET,
254
- meta,
255
- possibleFixes: ["Ensure the global execute tool function is set in the provider"]
458
+ possibleFixes: options.possibleFixes || [
459
+ "Ensure the global execute tool function is set in the provider"
460
+ ]
256
461
  });
257
462
  this.name = "ComposioGlobalExecuteToolFnNotSetError";
258
463
  }
259
464
  };
260
465
 
261
- // src/errors/ConnectedAccountsError.ts
466
+ // src/errors/ConnectedAccountsErrors.ts
262
467
  var ConnectedAccountErrorCodes = {
263
468
  CONNECTED_ACCOUNT_NOT_FOUND: "CONNECTED_ACCOUNT_NOT_FOUND"
264
469
  };
265
470
  var ComposioConnectedAccountNotFoundError = class extends ComposioError {
266
- constructor(message = "Connected account not found", meta = {}) {
471
+ constructor(message = "Connected account not found", options = {}) {
267
472
  super(message, {
473
+ ...options,
268
474
  code: ConnectedAccountErrorCodes.CONNECTED_ACCOUNT_NOT_FOUND,
269
475
  statusCode: 404,
270
- meta,
271
- possibleFixes: [
476
+ possibleFixes: options.possibleFixes || [
272
477
  "Ensure the connected account exists and is active in your Composio dashboard"
273
478
  ]
274
479
  });
480
+ this.name = "ComposioConnectedAccountNotFoundError";
481
+ }
482
+ };
483
+
484
+ // src/telemetry/Telemetry.ts
485
+ import { ComposioError as ComposioClientError } from "@composio/client";
486
+
487
+ // src/types/telemetry.types.ts
488
+ var TELEMETRY_EVENTS = {
489
+ SDK_INITIALIZED: "SDK_INITIALIZED",
490
+ SDK_METHOD_INVOKED: "SDK_METHOD_INVOKED",
491
+ SDK_METHOD_ERROR: "SDK_METHOD_ERROR",
492
+ CLI_INVOKED: "CLI_INVOKED"
493
+ };
494
+
495
+ // src/utils/constants.ts
496
+ var COMPOSIO_DIR = ".composio";
497
+ var USER_DATA_FILE_NAME = "user_data.json";
498
+ var DEFAULT_BASE_URL = "https://backend.composio.dev";
499
+ var TELEMETRY_URL = "https://app.composio.dev";
500
+ var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
501
+
502
+ // src/telemetry/BatchProcessor.ts
503
+ var BatchProcessor = class {
504
+ batch = [];
505
+ time;
506
+ batchSize;
507
+ processBatchCallback;
508
+ timer = null;
509
+ constructor(time = 2e3, batchSize = 100, processBatchCallback) {
510
+ this.batch = [];
511
+ this.time = time;
512
+ this.batchSize = batchSize;
513
+ this.processBatchCallback = processBatchCallback;
514
+ }
515
+ pushItem(item) {
516
+ this.batch.push(item);
517
+ if (this.batch.length >= this.batchSize) {
518
+ this.processBatch();
519
+ } else if (!this.timer) {
520
+ this.timer = setTimeout(() => this.processBatch(), this.time);
521
+ }
522
+ }
523
+ processBatch() {
524
+ if (this.batch.length > 0) {
525
+ this.processBatchCallback(this.batch);
526
+ this.batch = [];
527
+ }
528
+ if (this.timer) {
529
+ clearTimeout(this.timer);
530
+ this.timer = null;
531
+ }
532
+ }
533
+ };
534
+
535
+ // src/telemetry/transports/BrowserTransport.ts
536
+ var BrowserTelemetryTransport = class {
537
+ send(payload) {
538
+ if (typeof window === "undefined") {
539
+ return Promise.reject(
540
+ new Error("BrowserTelemetryTransport can only be used in browser environments")
541
+ );
542
+ }
543
+ return new Promise((resolve) => {
544
+ try {
545
+ const xhr = new XMLHttpRequest();
546
+ xhr.open(payload.method, payload.url, true);
547
+ xhr.setRequestHeader("Content-Type", "application/json");
548
+ Object.entries(payload.headers || {}).forEach(([key, value]) => {
549
+ xhr.setRequestHeader(key, value);
550
+ });
551
+ xhr.onload = function() {
552
+ resolve();
553
+ };
554
+ xhr.send(JSON.stringify(payload.data));
555
+ } catch (error) {
556
+ logger_default.error("Error sending error to telemetry", error);
557
+ resolve();
558
+ }
559
+ });
275
560
  }
276
561
  };
277
562
 
563
+ // src/telemetry/transports/ProcessTransport.ts
564
+ import chalk3 from "chalk";
565
+ var ProcessTelemetryTransport = class {
566
+ send(payload) {
567
+ if (typeof window !== "undefined") {
568
+ return Promise.reject(
569
+ new Error("ProcessTelemetryTransport can only be used in Node.js environments")
570
+ );
571
+ }
572
+ return new Promise((resolve) => {
573
+ try {
574
+ const url = new URL(payload.url);
575
+ const protocol = url.protocol === "https:" ? "https" : "http";
576
+ const port = url.port || (url.protocol === "https:" ? 443 : 80);
577
+ const args = [
578
+ "-e",
579
+ `
580
+ const http = require('${protocol}');
581
+ const options = {
582
+ hostname: '${url.hostname}',
583
+ path: '${url.pathname}${url.search}',
584
+ port: ${port},
585
+ method: '${payload.method}',
586
+ headers: ${JSON.stringify(payload.headers)}
587
+ };
588
+
589
+ const req = http.request(options, (res) => {
590
+ res.on('data', () => {});
591
+ res.on('end', () => {
592
+ process.exit(0);
593
+ });
594
+ });
595
+
596
+ req.on('error', () => {
597
+ process.exit(0);
598
+ });
599
+
600
+ req.write(JSON.stringify(${JSON.stringify(payload.data)}));
601
+ req.end();
602
+ `
603
+ ];
604
+ import("child_process").then(({ spawn }) => {
605
+ spawn("node", args, {
606
+ stdio: "ignore",
607
+ detached: false,
608
+ shell: false
609
+ }).unref();
610
+ resolve();
611
+ }).catch((error) => {
612
+ logger_default.error("Error sending telemetry", error);
613
+ resolve();
614
+ });
615
+ logger_default.debug(chalk3.yellow("Process Telemetry"), JSON.stringify(payload, null, 2));
616
+ } catch (error) {
617
+ logger_default.error("Error sending telemetry", error);
618
+ resolve();
619
+ }
620
+ });
621
+ }
622
+ };
623
+
624
+ // src/utils/uuid.ts
625
+ import { v4 as uuidv4 } from "uuid";
626
+ function getRandomUUID() {
627
+ return uuidv4();
628
+ }
629
+
630
+ // src/telemetry/Telemetry.ts
631
+ var TelemetryService = class {
632
+ telemetryMetadata;
633
+ transport;
634
+ isTelemetryDisabled = true;
635
+ batchProcessor = new BatchProcessor(100, 10, async (data) => {
636
+ await this.sendTelemetry(data);
637
+ });
638
+ setup(metadata, transport) {
639
+ this.telemetryMetadata = metadata;
640
+ this.isTelemetryDisabled = false;
641
+ const isBrowser = typeof window !== "undefined";
642
+ if (transport) {
643
+ this.transport = transport;
644
+ } else if (isBrowser) {
645
+ this.transport = new BrowserTelemetryTransport();
646
+ this.telemetryMetadata.transport = "browser";
647
+ } else {
648
+ this.transport = new ProcessTelemetryTransport();
649
+ this.telemetryMetadata.transport = "process";
650
+ }
651
+ this.sendTelemetry([
652
+ {
653
+ eventName: TELEMETRY_EVENTS.SDK_INITIALIZED,
654
+ data: {}
655
+ }
656
+ ]);
657
+ }
658
+ /**
659
+ * Instrument the telemetry for the given instance.
660
+ *
661
+ * You can pass the instance and the file name of the instance to instrument the telemetry.
662
+ * This will instrument all the methods of the instance and log the telemetry for each method call.
663
+ * @param instance - any instance that extends InstrumentedInstance
664
+ * @param fileName - the file name of the instance
665
+ * @returns
666
+ */
667
+ instrument(instance, fileName) {
668
+ const proto = Object.getPrototypeOf(instance);
669
+ const methodNames = Object.getOwnPropertyNames(proto).filter((key) => {
670
+ const descriptor = Object.getOwnPropertyDescriptor(proto, key);
671
+ return key !== "constructor" && descriptor && typeof descriptor.value === "function" && descriptor.value.constructor.name === "AsyncFunction";
672
+ });
673
+ const instrumentedClassName = instance.constructor?.name || fileName || "unknown";
674
+ for (const name of methodNames) {
675
+ const originalMethod = instance[name];
676
+ instance[name] = async (...args) => {
677
+ const telemetryPayload = {
678
+ eventName: TELEMETRY_EVENTS.SDK_METHOD_INVOKED,
679
+ data: {
680
+ fileName: instrumentedClassName,
681
+ method: name,
682
+ params: args
683
+ }
684
+ };
685
+ this.batchProcessor.pushItem(telemetryPayload);
686
+ try {
687
+ return await originalMethod.apply(instance, args);
688
+ } catch (error) {
689
+ if (error instanceof Error && !error.errorId) {
690
+ error.errorId = getRandomUUID();
691
+ this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
692
+ }
693
+ throw error;
694
+ }
695
+ };
696
+ }
697
+ return instance;
698
+ }
699
+ /**
700
+ * Check if the telemetry should be sent.
701
+ * @returns true if the telemetry should be sent, false otherwise
702
+ */
703
+ shouldSendTelemetry() {
704
+ const devEnvironments = ["test", "development", "CI"];
705
+ const nodeEnv = (getEnvVariable("NODE_ENV", "development") || "").toLowerCase();
706
+ const isDevEnvironment = devEnvironments.includes(nodeEnv);
707
+ const isTelemetryDisabledByEnv = getEnvVariable("TELEMETRY_DISABLED", "false") === "true";
708
+ return this.transport && !this.isTelemetryDisabled && !isTelemetryDisabledByEnv && !isDevEnvironment;
709
+ }
710
+ /**
711
+ * Prepare and send the error telemetry.
712
+ *
713
+ * @TODO This currently blocks the thread and sends the telemetry to the server.
714
+ *
715
+ * @param {unknown} error - The error to send.
716
+ * @param {string} instrumentedClassName - The class name of the instrumented class.
717
+ * @param {string} name - The name of the method that threw the error.
718
+ */
719
+ prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
720
+ if (error instanceof ComposioClientError) {
721
+ const telemetryPayload = {
722
+ error_id: error.errorId || "",
723
+ error_message: error.message,
724
+ original_error: error.cause || error,
725
+ current_stack: error.stack?.split("\n") || [],
726
+ description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
727
+ };
728
+ this.sendErrorTelemetry(telemetryPayload);
729
+ } else if (error instanceof ComposioError) {
730
+ const telemetryPayload = {
731
+ error_id: error.errorId || "",
732
+ error_message: error.message,
733
+ original_error: error.cause || error,
734
+ current_stack: error.stack?.split("\n") || [],
735
+ error_code: error.code,
736
+ possible_fix: error.possibleFixes?.join("\n"),
737
+ description: `Original Call : ${instrumentedClassName}.${name}(${JSON.stringify(args)})`
738
+ };
739
+ this.sendErrorTelemetry(telemetryPayload);
740
+ } else if (error instanceof Error) {
741
+ const telemetryPayload = {
742
+ error_id: error.errorId || "",
743
+ error_message: error instanceof Error ? error.name : "Unknown error",
744
+ original_error: error,
745
+ current_stack: error.stack?.split("\n") || [],
746
+ description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
747
+ };
748
+ this.sendErrorTelemetry(telemetryPayload);
749
+ }
750
+ }
751
+ /**
752
+ * Send the telemetry payload to the server.
753
+ * @param payload - the telemetry payload to send
754
+ * @returns
755
+ */
756
+ async sendTelemetry(payload) {
757
+ if (!this.shouldSendTelemetry()) {
758
+ return;
759
+ }
760
+ const url = `${TELEMETRY_URL}/api/sdk_metrics/telemetry`;
761
+ const reqPayload = {
762
+ data: payload.map((p) => ({
763
+ ...p,
764
+ sdk_meta: this.telemetryMetadata
765
+ })),
766
+ url,
767
+ method: "POST",
768
+ headers: { "Content-Type": "application/json" }
769
+ };
770
+ this.transport.send(reqPayload);
771
+ }
772
+ // @TODO: check if this will send the error telemetry to the server
773
+ async sendErrorTelemetry(payload) {
774
+ if (!this.shouldSendTelemetry()) {
775
+ return;
776
+ }
777
+ const url = `${TELEMETRY_URL}/api/sdk_metrics/error`;
778
+ const reqPayload = {
779
+ data: {
780
+ ...payload,
781
+ sdk_meta: this.telemetryMetadata
782
+ },
783
+ url,
784
+ method: "POST",
785
+ headers: { "Content-Type": "application/json" }
786
+ };
787
+ this.transport.send(reqPayload);
788
+ }
789
+ };
790
+ var telemetry = new TelemetryService();
791
+
278
792
  // src/models/CustomTools.ts
279
793
  var CustomTools = class {
280
794
  client;
@@ -285,6 +799,7 @@ var CustomTools = class {
285
799
  }
286
800
  this.client = client;
287
801
  this.customToolsRegistry = /* @__PURE__ */ new Map();
802
+ telemetry.instrument(this);
288
803
  }
289
804
  /**
290
805
  * Create a custom tool and registers it in the registry.
@@ -379,8 +894,8 @@ var CustomTools = class {
379
894
  });
380
895
  }
381
896
  const connectedAccounts = await this.client.connectedAccounts.list({
382
- toolkit_slug: toolkitSlug,
383
- user_id: metadata.userId
897
+ toolkit_slugs: [toolkitSlug],
898
+ user_ids: [metadata.userId]
384
899
  });
385
900
  if (!connectedAccounts.items.length) {
386
901
  throw new ComposioConnectedAccountNotFoundError(
@@ -440,40 +955,50 @@ var CustomTools = class {
440
955
  }
441
956
  };
442
957
 
443
- // src/errors/ValidationError.ts
444
- import { ZodError } from "zod";
958
+ // src/errors/ValidationErrors.ts
959
+ import { ZodError as ZodError2 } from "zod";
445
960
  var ValidationErrorCodes = {
446
961
  VALIDATION_ERROR: "VALIDATION_ERROR"
447
962
  };
448
963
  var ValidationError = class extends ComposioError {
449
- zodError;
450
- constructor(zodError, message = "Input validation failed") {
964
+ constructor(message = "Input validation failed", options = {}) {
965
+ const { cause: providedZodError, ...restOptions } = options;
451
966
  let zodErrorInstance;
452
- if (!(zodError instanceof ZodError)) {
453
- zodErrorInstance = new ZodError([
967
+ if (providedZodError instanceof ZodError2) {
968
+ zodErrorInstance = providedZodError;
969
+ } else {
970
+ zodErrorInstance = new ZodError2([
454
971
  {
455
972
  path: [],
456
973
  message: "Invalid input",
457
974
  code: "custom"
458
975
  }
459
976
  ]);
460
- } else {
461
- zodErrorInstance = zodError;
462
977
  }
978
+ const issues = zodErrorInstance.issues.map(
979
+ (issue) => `[${issue.code}] ${issue.path.join(".")} - ${issue.message}`
980
+ );
463
981
  super(message, {
464
- code: ValidationErrorCodes.VALIDATION_ERROR,
465
- meta: {
466
- issues: JSON.stringify(
467
- zodErrorInstance.issues.map((issue) => ({
468
- path: issue.path.join("."),
469
- message: issue.message,
470
- code: issue.code
471
- }))
472
- )
473
- },
982
+ ...restOptions,
983
+ code: options.code || ValidationErrorCodes.VALIDATION_ERROR,
984
+ possibleFixes: issues,
474
985
  cause: zodErrorInstance
475
986
  });
476
- this.zodError = zodErrorInstance;
987
+ this.name = "ValidationError";
988
+ const userFriendlyMessage = this.generateUserFriendlyMessage();
989
+ this.message = `${message}: ${userFriendlyMessage}`;
990
+ }
991
+ generateUserFriendlyMessage() {
992
+ if (this.cause instanceof ZodError2 && this.cause.issues.length > 0) {
993
+ const issue = this.cause.issues[0];
994
+ const path = issue.path.join(".");
995
+ const param = path || "parameter";
996
+ if (issue.code === "invalid_type") {
997
+ return `The ${param} should be a ${issue.expected}, but you provided a ${issue.received}`;
998
+ }
999
+ return issue.message;
1000
+ }
1001
+ return "Please check your input parameters";
477
1002
  }
478
1003
  };
479
1004
 
@@ -493,13 +1018,21 @@ var Tools = class {
493
1018
  this.customTools = new CustomTools(client);
494
1019
  this.provider = provider;
495
1020
  this.execute = this.execute.bind(this);
1021
+ this.provider._setExecuteToolFn(this.execute);
496
1022
  this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
497
1023
  this.getRawComposioTools = this.getRawComposioTools.bind(this);
1024
+ telemetry.instrument(this);
498
1025
  }
499
1026
  /**
500
- * Transform the tool cases
501
- * @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool to transform
502
- * @returns {Tool} The transformed tool
1027
+ * Transforms tool data from snake_case API format to camelCase for internal SDK use.
1028
+ *
1029
+ * This method standardizes the property naming convention for tools retrieved from the Composio API,
1030
+ * making them more consistent with JavaScript/TypeScript conventions.
1031
+ *
1032
+ * @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool object to transform
1033
+ * @returns {Tool} The transformed tool with camelCase properties
1034
+ *
1035
+ * @private
503
1036
  */
504
1037
  transformToolCases(tool) {
505
1038
  return ToolSchema.parse({
@@ -509,9 +1042,15 @@ var Tools = class {
509
1042
  });
510
1043
  }
511
1044
  /**
512
- * Transform the tool execute response to camelcase
513
- * @param {ComposioToolExecuteResponse} response - The response to transform
514
- * @returns {ToolExecuteResponse} The transformed response
1045
+ * Transforms tool execution response from snake_case API format to camelCase.
1046
+ *
1047
+ * This method converts the response received from the Composio API to a standardized format
1048
+ * with consistent property naming that follows JavaScript/TypeScript conventions.
1049
+ *
1050
+ * @param {ComposioToolExecuteResponse} response - The raw API response to transform
1051
+ * @returns {ToolExecuteResponse} The transformed response with camelCase properties
1052
+ *
1053
+ * @private
515
1054
  */
516
1055
  transformToolExecuteResponse(response) {
517
1056
  return ToolExecuteResponseSchema.parse({
@@ -596,14 +1135,42 @@ var Tools = class {
596
1135
  return null;
597
1136
  }
598
1137
  /**
599
- * Lists all tools available in the Composio SDK as well as custom tools.
600
- * This method fetches the tools from the Composio API and wraps them using the provider.
601
- * @returns {ToolList} List of tools
1138
+ * Lists all tools available in the Composio SDK including custom tools.
1139
+ *
1140
+ * This method fetches tools from the Composio API in raw format and combines them with
1141
+ * any registered custom tools. The response can be filtered and modified as needed.
1142
+ *
1143
+ * @param {string} userId - The user ID for whom to fetch the tools
1144
+ * @param {ToolListParams} [query={}] - Optional query parameters to filter the tools
1145
+ * @param {TransformToolSchemaModifier} [modifier] - Optional function to transform tool schemas
1146
+ * @returns {Promise<ToolList>} List of tools matching the query criteria
1147
+ *
1148
+ * @example
1149
+ * ```typescript
1150
+ * // Get all tools
1151
+ * const tools = await composio.tools.getRawComposioTools('default');
1152
+ *
1153
+ * // Get tools with filters
1154
+ * const githubTools = await composio.tools.getRawComposioTools('default', {
1155
+ * toolkits: ['github'],
1156
+ * important: true
1157
+ * });
1158
+ *
1159
+ * // Get tools with schema transformation
1160
+ * const tools = await composio.tools.getRawComposioTools('default', {},
1161
+ * (toolSlug, toolkitSlug, tool) => {
1162
+ * // Add custom properties to tool schema
1163
+ * return {...tool, customProperty: 'value'};
1164
+ * }
1165
+ * );
1166
+ * ```
602
1167
  */
603
1168
  async getRawComposioTools(userId, query = {}, modifier) {
604
1169
  const queryParams = ToolListParamsSchema.safeParse(query);
605
1170
  if (queryParams.error) {
606
- throw new ValidationError(queryParams.error);
1171
+ throw new ValidationError("Invalid tool list parameters", {
1172
+ cause: queryParams.error
1173
+ });
607
1174
  }
608
1175
  const tools = await this.client.tools.list({
609
1176
  tool_slugs: queryParams.data.tools,
@@ -634,6 +1201,7 @@ var Tools = class {
634
1201
  }
635
1202
  /**
636
1203
  * Retrieves a tool by its Slug.
1204
+ * This method is used to get the raw tools from the composio API.
637
1205
  * @param slug The ID of the tool to be retrieved
638
1206
  * @returns {Promise<Tool>} The tool
639
1207
  *
@@ -647,11 +1215,13 @@ var Tools = class {
647
1215
  if (customTool) {
648
1216
  return customTool;
649
1217
  }
650
- const tool = await this.client.tools.retrieve(slug);
651
- if (!tool) {
652
- throw new ComposioToolNotFoundError(
653
- `[getRawComposioToolBySlug] Tool with slug ${slug} not found`
654
- );
1218
+ let tool;
1219
+ try {
1220
+ tool = await this.client.tools.retrieve(slug);
1221
+ } catch (error) {
1222
+ throw new ComposioToolNotFoundError(`Unable to retrieve tool with slug ${slug}`, {
1223
+ cause: error
1224
+ });
655
1225
  }
656
1226
  let modifiedToool = this.transformToolCases(tool);
657
1227
  if (modifier) {
@@ -664,19 +1234,21 @@ var Tools = class {
664
1234
  return modifiedToool;
665
1235
  }
666
1236
  /**
667
- * Get a tool by its slug
668
- * @param userId - The user id
669
- * @param arg2 - The slug of the tool or the filters for the tools
670
- * @param options - The options for the tools
671
- * @returns The tool or the tools
1237
+ * Get a tool or list of tools based on the provided arguments.
1238
+ * This is an implementation method that handles both overloads.
1239
+ *
1240
+ * @param {string} userId - The user id to get the tool(s) for
1241
+ * @param {ToolListParams | string} arg2 - Either a slug string or filters object
1242
+ * @param {ProviderOptions<TProvider>} [options] - Optional provider options
1243
+ * @returns {Promise<TToolCollection>} The tool collection
672
1244
  */
673
1245
  async get(userId, arg2, options) {
674
1246
  const executeToolFn = this.createExecuteToolFn(userId, options);
675
1247
  if (typeof arg2 === "string") {
676
- const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
677
- return this.provider.wrapTool(tool, executeToolFn);
1248
+ const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifySchema);
1249
+ return this.provider.wrapTools([tool], executeToolFn);
678
1250
  } else {
679
- const tools = await this.getRawComposioTools(userId, arg2, options?.modifyToolSchema);
1251
+ const tools = await this.getRawComposioTools(userId, arg2, options?.modifySchema);
680
1252
  return this.provider.wrapTools(tools, executeToolFn);
681
1253
  }
682
1254
  }
@@ -710,26 +1282,22 @@ var Tools = class {
710
1282
  * @returns The response from the tool execution
711
1283
  */
712
1284
  async handleCustomToolExecution(tool, body, modifiers) {
713
- if (modifiers?.beforeToolExecute) {
714
- if (typeof modifiers.beforeToolExecute === "function") {
715
- body = modifiers.beforeToolExecute(tool.slug, "unkown", body);
1285
+ if (modifiers?.beforeExecute) {
1286
+ if (typeof modifiers.beforeExecute === "function") {
1287
+ body = modifiers.beforeExecute(tool.slug, "unkown", body);
716
1288
  } else {
717
- throw new ComposioInvalidModifierError(
718
- "Invalid beforeToolExecute modifier. Not a function."
719
- );
1289
+ throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
720
1290
  }
721
1291
  }
722
1292
  let result = await this.customTools.executeCustomTool(tool.slug, body, {
723
1293
  userId: body.userId || "default",
724
1294
  connectedAccountId: body.connectedAccountId
725
1295
  });
726
- if (modifiers?.afterToolExecute) {
727
- if (typeof modifiers.afterToolExecute === "function") {
728
- result = modifiers.afterToolExecute(tool.slug, "unkown", result);
1296
+ if (modifiers?.afterExecute) {
1297
+ if (typeof modifiers.afterExecute === "function") {
1298
+ result = modifiers.afterExecute(tool.slug, "unkown", result);
729
1299
  } else {
730
- throw new ComposioInvalidModifierError(
731
- "Invalid afterToolExecute modifier. Not a function."
732
- );
1300
+ throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
733
1301
  }
734
1302
  }
735
1303
  return result;
@@ -743,13 +1311,11 @@ var Tools = class {
743
1311
  * @returns The response from the tool execution
744
1312
  */
745
1313
  async handleComposioToolExecution(tool, body, modifiers) {
746
- if (modifiers?.beforeToolExecute) {
747
- if (typeof modifiers.beforeToolExecute === "function") {
748
- body = modifiers.beforeToolExecute(tool.slug, tool.toolkit?.slug || "unkown", body);
1314
+ if (modifiers?.beforeExecute) {
1315
+ if (typeof modifiers.beforeExecute === "function") {
1316
+ body = modifiers.beforeExecute(tool.slug, tool.toolkit?.slug || "unkown", body);
749
1317
  } else {
750
- throw new ComposioInvalidModifierError(
751
- "Invalid beforeToolExecute modifier. Not a function."
752
- );
1318
+ throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
753
1319
  }
754
1320
  }
755
1321
  let connectedAccountId = body.connectedAccountId;
@@ -766,25 +1332,53 @@ var Tools = class {
766
1332
  text: body.text
767
1333
  });
768
1334
  result = this.transformToolExecuteResponse(result);
769
- if (modifiers?.afterToolExecute) {
770
- if (typeof modifiers.afterToolExecute === "function") {
771
- result = modifiers.afterToolExecute(tool.slug, tool.toolkit?.slug || "unkown", result);
1335
+ if (modifiers?.afterExecute) {
1336
+ if (typeof modifiers.afterExecute === "function") {
1337
+ result = modifiers.afterExecute(tool.slug, tool.toolkit?.slug || "unkown", result);
772
1338
  } else {
773
- throw new ComposioInvalidModifierError(
774
- "Invalid afterToolExecute modifier. Not a function."
775
- );
1339
+ throw new ComposioInvalidModifierError("Invalid afterExecute modifier. Not a function.");
776
1340
  }
777
1341
  }
778
1342
  return result;
779
1343
  }
780
1344
  /**
781
- * Exectes a given tool with the provided parameters.
1345
+ * Executes a given tool with the provided parameters.
782
1346
  *
783
- * This method calls the Composio API to execute the tool and returns the response.
1347
+ * This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
1348
+ * It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
784
1349
  *
785
- * @param {string} slug - The ID of the tool to be executed
1350
+ * @param {string} slug - The slug/ID of the tool to be executed
786
1351
  * @param {ToolExecuteParams} body - The parameters to be passed to the tool
1352
+ * @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
787
1353
  * @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
1354
+ *
1355
+ * @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
1356
+ * @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
1357
+ * @throws {ComposioToolExecutionError} If there is an error during tool execution
1358
+ *
1359
+ * @example
1360
+ * ```typescript
1361
+ * // Execute a Composio API tool
1362
+ * const result = await composio.tools.execute('HACKERNEWS_GET_USER', {
1363
+ * userId: 'default',
1364
+ * arguments: { userId: 'pg' }
1365
+ * });
1366
+ *
1367
+ * // Execute with modifiers
1368
+ * const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
1369
+ * userId: 'default',
1370
+ * arguments: { owner: 'composio', repo: 'sdk' }
1371
+ * }, {
1372
+ * beforeExecute: (toolSlug, toolkitSlug, params) => {
1373
+ * // Modify params before execution
1374
+ * return params;
1375
+ * },
1376
+ * afterExecute: (toolSlug, toolkitSlug, result) => {
1377
+ * // Transform result after execution
1378
+ * return result;
1379
+ * }
1380
+ * });
1381
+ * ```
788
1382
  */
789
1383
  async execute(slug, body, modifiers) {
790
1384
  if (!this.customTools) {
@@ -804,9 +1398,12 @@ var Tools = class {
804
1398
  return this.handleComposioToolExecution(composioTool, body, modifiers);
805
1399
  }
806
1400
  } catch (error) {
807
- throw new ComposioToolExecutionError(error, `Error executing tool ${slug}`, {
808
- toolSlug: slug,
809
- body
1401
+ throw new ComposioToolExecutionError(`Error executing tool ${slug}`, {
1402
+ originalError: error,
1403
+ meta: {
1404
+ toolSlug: slug,
1405
+ body
1406
+ }
810
1407
  });
811
1408
  }
812
1409
  }
@@ -841,15 +1438,48 @@ var Tools = class {
841
1438
  return this.client.tools.proxy(body);
842
1439
  }
843
1440
  /**
844
- * Execute a custom tool
845
- * @param body
846
- * @returns
1441
+ * Creates a custom tool that can be used within the Composio SDK.
1442
+ *
1443
+ * Custom tools allow you to extend the functionality of Composio with your own implementations
1444
+ * while keeping a consistent interface for both built-in and custom tools.
1445
+ *
1446
+ * @param {CustomToolOptions} body - The configuration for the custom tool
1447
+ * @returns {Promise<Tool>} The created custom tool
1448
+ *
1449
+ * @example
1450
+ * ```typescript
1451
+ * const customTool = await composio.tools.createCustomTool({
1452
+ * name: 'My Custom Tool',
1453
+ * description: 'A custom tool that does something specific',
1454
+ * slug: 'MY_CUSTOM_TOOL',
1455
+ * inputParameters: {
1456
+ * param1: {
1457
+ * type: 'string',
1458
+ * description: 'First parameter',
1459
+ * required: true
1460
+ * }
1461
+ * },
1462
+ * outputParameters: {
1463
+ * result: {
1464
+ * type: 'string',
1465
+ * description: 'The result of the operation'
1466
+ * }
1467
+ * },
1468
+ * handler: async (params, context) => {
1469
+ * // Custom logic here
1470
+ * return { data: { result: 'Success!' } };
1471
+ * }
1472
+ * });
1473
+ * ```
847
1474
  */
848
1475
  async createCustomTool(body) {
849
1476
  return this.customTools.createTool(body);
850
1477
  }
851
1478
  };
852
1479
 
1480
+ // src/models/Toolkits.ts
1481
+ import ComposioClient2 from "@composio/client";
1482
+
853
1483
  // src/types/toolkit.types.ts
854
1484
  import { z as z2 } from "zod";
855
1485
  var ToolkitMangedByEnumSchema = z2.enum(["all", "composio", "project"]);
@@ -930,8 +1560,101 @@ var ToolkitRetrieveCategoriesResponseSchema = z2.object({
930
1560
  totalPages: z2.number()
931
1561
  });
932
1562
 
933
- // src/models/Toolkits.ts
934
- import { ZodError as ZodError3 } from "zod";
1563
+ // src/errors/AuthConfigErrors.ts
1564
+ var AuthConfigErrorCodes = {
1565
+ AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
1566
+ };
1567
+ var ComposioAuthConfigNotFoundError = class extends ComposioError {
1568
+ constructor(message = "Auth config not found", options = {}) {
1569
+ super(message, {
1570
+ ...options,
1571
+ code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
1572
+ possibleFixes: options.possibleFixes || [
1573
+ "Check if the auth config exists",
1574
+ "Check if the auth config id is correct",
1575
+ "Check if the auth config is enabled"
1576
+ ]
1577
+ });
1578
+ this.name = "ComposioAuthConfigNotFoundError";
1579
+ }
1580
+ };
1581
+
1582
+ // src/errors/ConnectionRequestErrors.ts
1583
+ var ConnectionRequestErrorCodes = {
1584
+ CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
1585
+ CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
1586
+ };
1587
+ var ConnectionRequestTimeoutError = class extends ComposioError {
1588
+ constructor(message = "Connection request timed out", options = {}) {
1589
+ super(message, {
1590
+ ...options,
1591
+ code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT
1592
+ });
1593
+ this.name = "ConnectionRequestTimeoutError";
1594
+ }
1595
+ };
1596
+ var ConnectionRequestFailedError = class extends ComposioError {
1597
+ constructor(message = "Connection request failed", options = {}) {
1598
+ super(message, {
1599
+ ...options,
1600
+ code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED
1601
+ });
1602
+ this.name = "ConnectionRequestFailedError";
1603
+ }
1604
+ };
1605
+
1606
+ // src/errors/ToolkitErrors.ts
1607
+ var ToolkitErrorCodes = {
1608
+ TOOLKIT_NOT_FOUND: "TOOLKIT_NOT_FOUND"
1609
+ };
1610
+ var ComposioToolkitNotFoundError = class extends ComposioError {
1611
+ constructor(message = "Toolkit not found", options = {}) {
1612
+ super(message, {
1613
+ ...options,
1614
+ code: "TOOLKIT_NOT_FOUND",
1615
+ possibleFixes: options.possibleFixes || [
1616
+ "Ensure the toolkit is correctly configured and the slug is valid"
1617
+ ]
1618
+ });
1619
+ this.name = "ComposioToolkitNotFoundError";
1620
+ }
1621
+ };
1622
+ var ComposioToolkitFetchError = class extends ComposioError {
1623
+ constructor(message = "Failed to fetch toolkit", options = {}) {
1624
+ super(message, {
1625
+ ...options,
1626
+ code: "TOOLKIT_FETCH_ERROR",
1627
+ possibleFixes: options.possibleFixes || [
1628
+ "Ensure the toolkit slug is valid",
1629
+ "Ensure you are using the correct API key",
1630
+ "Ensure you are using the correct API endpoint / Base URL and it is working"
1631
+ ]
1632
+ });
1633
+ this.name = "ComposioToolkitFetchError";
1634
+ }
1635
+ };
1636
+
1637
+ // src/errors/SDKErrors.ts
1638
+ var SDKErrorCodes = {
1639
+ NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED"
1640
+ };
1641
+ var ComposioNoAPIKeyError = class extends ComposioError {
1642
+ constructor(message = "No Composio API key provided", options = {}) {
1643
+ const defaultCause = "Couldn't find an API key in the params, environment variables or in the user config file";
1644
+ super(message, {
1645
+ ...options,
1646
+ code: "NO_API_KEY",
1647
+ cause: options.cause || defaultCause,
1648
+ possibleFixes: options.possibleFixes || [
1649
+ "Ensure you have an API key passed in the params, or in environment variable (COMPOSIO_API_KEY) or in the user config file",
1650
+ "To get an API key, please sign up at https://composio.dev/signup",
1651
+ "You can also use the Composio CLI to create a project and get an API key"
1652
+ ],
1653
+ statusCode: 401
1654
+ });
1655
+ this.name = "ComposioNoAPIKeyError";
1656
+ }
1657
+ };
935
1658
 
936
1659
  // src/types/authConfigs.types.ts
937
1660
  import { z as z3 } from "zod";
@@ -1001,7 +1724,7 @@ var AuthConfigRetrieveResponseSchema = z3.object({
1001
1724
  status: z3.enum(["ENABLED", "DISABLED"]),
1002
1725
  uuid: z3.string(),
1003
1726
  authScheme: AuthSchemeEnum.optional(),
1004
- credentials: z3.record(z3.string(), z3.union([z3.string(), z3.number(), z3.boolean()])),
1727
+ credentials: z3.record(z3.string(), z3.unknown()).optional(),
1005
1728
  expectedInputFields: z3.array(z3.unknown()).optional(),
1006
1729
  isComposioManaged: z3.boolean().optional(),
1007
1730
  createdBy: z3.string().optional(),
@@ -1012,7 +1735,7 @@ var AuthConfigListParamsSchema = z3.object({
1012
1735
  cursor: z3.string().optional(),
1013
1736
  isComposioManaged: z3.boolean().optional(),
1014
1737
  limit: z3.number().optional(),
1015
- toolkitSlug: z3.string().optional()
1738
+ toolkit: z3.string().optional()
1016
1739
  });
1017
1740
  var AuthConfigListResponseSchema = z3.object({
1018
1741
  items: z3.array(AuthConfigRetrieveResponseSchema),
@@ -1039,6 +1762,7 @@ var AuthConfigs = class {
1039
1762
  client;
1040
1763
  constructor(client) {
1041
1764
  this.client = client;
1765
+ telemetry.instrument(this);
1042
1766
  }
1043
1767
  /**
1044
1768
  * Protected getter for the client instance.
@@ -1048,6 +1772,18 @@ var AuthConfigs = class {
1048
1772
  getClient() {
1049
1773
  return this.client;
1050
1774
  }
1775
+ /**
1776
+ * Transforms an auth config response from API format to SDK format.
1777
+ *
1778
+ * This method converts property names from snake_case to camelCase and reorganizes
1779
+ * the data structure to match the SDK's standardized format for auth configurations.
1780
+ *
1781
+ * @param {ComposioAuthConfigRetrieveResponse} authConfig - The raw API response to transform
1782
+ * @returns {AuthConfigRetrieveResponse} The transformed auth config data
1783
+ * @throws {ValidationError} If the response fails validation against the expected schema
1784
+ *
1785
+ * @private
1786
+ */
1051
1787
  parseAuthConfigRetrieveResponse(authConfig) {
1052
1788
  const result = AuthConfigRetrieveResponseSchema.safeParse({
1053
1789
  id: authConfig.id,
@@ -1068,15 +1804,37 @@ var AuthConfigs = class {
1068
1804
  lastUpdatedAt: authConfig.last_updated_at
1069
1805
  });
1070
1806
  if (result.error) {
1071
- throw new ValidationError(result.error);
1807
+ throw new ValidationError("Failed to parse auth config response", {
1808
+ cause: result.error
1809
+ });
1072
1810
  }
1073
1811
  return result.data;
1074
1812
  }
1075
1813
  /**
1076
- * List all auth configs
1077
- * @param {AuthConfigListParams} query - Query parameters for filtering auth configs
1078
- * @param {RequestOptions} options - Request options
1079
- * @returns {Promise<AuthConfigListResponse>} List of auth configs
1814
+ * Lists authentication configurations based on provided filter criteria.
1815
+ *
1816
+ * This method retrieves auth configs from the Composio API, transforms them to the SDK format,
1817
+ * and supports filtering by various parameters.
1818
+ *
1819
+ * @param {AuthConfigListParams} [query] - Optional query parameters for filtering auth configs
1820
+ * @returns {Promise<AuthConfigListResponse>} A paginated list of auth configurations
1821
+ * @throws {ValidationError} If the query parameters or response fail validation
1822
+ *
1823
+ * @example
1824
+ * ```typescript
1825
+ * // List all auth configs
1826
+ * const allConfigs = await composio.authConfigs.list();
1827
+ *
1828
+ * // List auth configs for a specific toolkit
1829
+ * const githubConfigs = await composio.authConfigs.list({
1830
+ * toolkit: 'github'
1831
+ * });
1832
+ *
1833
+ * // List Composio-managed auth configs
1834
+ * const managedConfigs = await composio.authConfigs.list({
1835
+ * isComposioManaged: true
1836
+ * });
1837
+ * ```
1080
1838
  */
1081
1839
  async list(query) {
1082
1840
  const parsedQuery = query ? AuthConfigListParamsSchema.parse(query) : void 0;
@@ -1084,7 +1842,7 @@ var AuthConfigs = class {
1084
1842
  cursor: parsedQuery?.cursor,
1085
1843
  is_composio_managed: parsedQuery?.isComposioManaged,
1086
1844
  limit: parsedQuery?.limit?.toString(),
1087
- toolkit_slug: parsedQuery?.toolkitSlug
1845
+ toolkit_slug: parsedQuery?.toolkit
1088
1846
  });
1089
1847
  const parsedResult = AuthConfigListResponseSchema.safeParse({
1090
1848
  items: result.items.map((item) => this.parseAuthConfigRetrieveResponse(item)),
@@ -1092,7 +1850,9 @@ var AuthConfigs = class {
1092
1850
  totalPages: result.total_pages
1093
1851
  });
1094
1852
  if (parsedResult.error) {
1095
- throw new ValidationError(parsedResult.error);
1853
+ throw new ValidationError("Failed to parse auth config list response", {
1854
+ cause: parsedResult.error
1855
+ });
1096
1856
  }
1097
1857
  return parsedResult.data;
1098
1858
  }
@@ -1114,10 +1874,12 @@ var AuthConfigs = class {
1114
1874
  *
1115
1875
  * @link https://docs.composio.dev/reference/auth-configs/create-auth-config
1116
1876
  */
1117
- async create(toolkit, options) {
1877
+ async create(toolkit, options = { type: "use_composio_managed_auth" }) {
1118
1878
  const parsedOptions = CreateAuthConfigParamsSchema.safeParse(options);
1119
1879
  if (parsedOptions.error) {
1120
- throw new ValidationError(parsedOptions.error);
1880
+ throw new ValidationError("Failed to parse auth config create options", {
1881
+ cause: parsedOptions.error
1882
+ });
1121
1883
  }
1122
1884
  const result = await this.client.authConfigs.create({
1123
1885
  toolkit: {
@@ -1132,31 +1894,71 @@ var AuthConfigs = class {
1132
1894
  toolkit: result.toolkit.slug
1133
1895
  });
1134
1896
  if (parsedResult.error) {
1135
- throw new ValidationError(parsedResult.error);
1897
+ throw new ValidationError("Failed to parse auth config create response", {
1898
+ cause: parsedResult.error
1899
+ });
1136
1900
  }
1137
1901
  return parsedResult.data;
1138
1902
  }
1139
1903
  /**
1140
- * Get an auth config by nanoid
1141
- * @param {string} nanoid - Unique identifier of the auth config
1142
- * @param {RequestOptions} options - Request options
1143
- * @returns {Promise<AuthConfigRetrieveResponse>} Auth config details
1904
+ * Retrieves a specific authentication configuration by its ID.
1905
+ *
1906
+ * This method fetches detailed information about a single auth config
1907
+ * and transforms the response to the SDK's standardized format.
1908
+ *
1909
+ * @param {string} nanoid - The unique identifier of the auth config to retrieve
1910
+ * @returns {Promise<AuthConfigRetrieveResponse>} The auth config details
1911
+ * @throws {Error} If the auth config cannot be found or an API error occurs
1912
+ * @throws {ValidationError} If the response fails validation
1913
+ *
1914
+ * @example
1915
+ * ```typescript
1916
+ * // Get an auth config by ID
1917
+ * const authConfig = await composio.authConfigs.get('auth_abc123');
1918
+ * console.log(authConfig.name); // e.g., 'GitHub Auth'
1919
+ * console.log(authConfig.toolkit.slug); // e.g., 'github'
1920
+ * ```
1144
1921
  */
1145
1922
  async get(nanoid) {
1146
1923
  const result = await this.client.authConfigs.retrieve(nanoid);
1147
1924
  return this.parseAuthConfigRetrieveResponse(result);
1148
1925
  }
1149
1926
  /**
1150
- * Update an auth config
1151
- * @param {string} nanoid - Unique identifier of the auth config to update
1152
- * @param {AuthConfigUpdateParams} data - Data to update
1153
- * @param {RequestOptions} options - Request options
1154
- * @returns {Promise<AuthConfigUpdateResponse>} Updated auth config
1927
+ * Updates an existing authentication configuration.
1928
+ *
1929
+ * This method allows you to modify properties of an auth config such as credentials,
1930
+ * scopes, or tool restrictions. The update type (custom or default) determines which
1931
+ * fields can be updated.
1932
+ *
1933
+ * @param {string} nanoid - The unique identifier of the auth config to update
1934
+ * @param {AuthConfigUpdateParams} data - The data to update, which can be either custom or default type
1935
+ * @returns {Promise<AuthConfigUpdateResponse>} The updated auth config
1936
+ * @throws {ValidationError} If the update parameters are invalid
1937
+ * @throws {Error} If the auth config cannot be found or updated
1938
+ *
1939
+ * @example
1940
+ * ```typescript
1941
+ * // Update a custom auth config with new credentials
1942
+ * const updatedConfig = await composio.authConfigs.update('auth_abc123', {
1943
+ * type: 'custom',
1944
+ * credentials: {
1945
+ * apiKey: 'new-api-key-value'
1946
+ * }
1947
+ * });
1948
+ *
1949
+ * // Update a default auth config with new scopes
1950
+ * const updatedConfig = await composio.authConfigs.update('auth_abc123', {
1951
+ * type: 'default',
1952
+ * scopes: ['read:user', 'repo']
1953
+ * });
1954
+ * ```
1155
1955
  */
1156
1956
  async update(nanoid, data) {
1157
1957
  const parsedData = AuthConfigUpdateParamsSchema.safeParse(data);
1158
1958
  if (parsedData.error) {
1159
- throw new ValidationError(parsedData.error);
1959
+ throw new ValidationError("Failed to parse auth config update data", {
1960
+ cause: parsedData.error
1961
+ });
1160
1962
  }
1161
1963
  return this.client.authConfigs.update(
1162
1964
  nanoid,
@@ -1172,63 +1974,91 @@ var AuthConfigs = class {
1172
1974
  );
1173
1975
  }
1174
1976
  /**
1175
- * Delete an auth config
1176
- * @param {string} nanoid - Unique identifier of the auth config to delete
1177
- * @param {RequestOptions} options - Request options
1178
- * @returns {Promise<AuthConfigDeleteResponse>} Response from deletion
1977
+ * Deletes an authentication configuration.
1978
+ *
1979
+ * This method permanently removes an auth config from the Composio platform.
1980
+ * This action cannot be undone and will prevent any connected accounts that use
1981
+ * this auth config from functioning.
1982
+ *
1983
+ * @param {string} nanoid - The unique identifier of the auth config to delete
1984
+ * @returns {Promise<AuthConfigDeleteResponse>} The deletion response
1985
+ * @throws {Error} If the auth config doesn't exist or cannot be deleted
1986
+ *
1987
+ * @example
1988
+ * ```typescript
1989
+ * // Delete an auth config
1990
+ * await composio.authConfigs.delete('auth_abc123');
1991
+ * ```
1179
1992
  */
1180
1993
  async delete(nanoid) {
1181
1994
  return this.client.authConfigs.delete(nanoid);
1182
1995
  }
1183
1996
  /**
1184
- * Update the status of an auth config
1185
- * @param {string} status - The status to update the auth config to
1186
- * @param {string} nanoid - Unique identifier of the auth config
1187
- * @param {RequestOptions} options - Request options
1188
- * @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
1997
+ * Updates the status of an authentication configuration.
1998
+ *
1999
+ * This method allows you to enable or disable an auth config. When disabled,
2000
+ * the auth config cannot be used to create new connected accounts or authenticate
2001
+ * with third-party services.
2002
+ *
2003
+ * @param {string} status - The status to set ('ENABLED' or 'DISABLED')
2004
+ * @param {string} nanoid - The unique identifier of the auth config
2005
+ * @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
2006
+ * @throws {Error} If the auth config cannot be found or the status cannot be updated
2007
+ *
2008
+ * @example
2009
+ * ```typescript
2010
+ * // Disable an auth config
2011
+ * await composio.authConfigs.updateStatus('DISABLED', 'auth_abc123');
2012
+ *
2013
+ * // Enable an auth config
2014
+ * await composio.authConfigs.updateStatus('ENABLED', 'auth_abc123');
2015
+ * ```
1189
2016
  */
1190
2017
  async updateStatus(status, nanoid) {
1191
2018
  return this.client.authConfigs.updateStatus(status, { nanoid });
1192
2019
  }
1193
2020
  /**
1194
- * Enable an auth config
1195
- * @param {string} nanoid - Unique identifier of the auth config
1196
- * @param {RequestOptions} options - Request options
1197
- * @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
2021
+ * Enables an authentication configuration.
2022
+ *
2023
+ * This is a convenience method that calls updateStatus with 'ENABLED'.
2024
+ * When enabled, the auth config can be used to create new connected accounts
2025
+ * and authenticate with third-party services.
2026
+ *
2027
+ * @param {string} nanoid - The unique identifier of the auth config to enable
2028
+ * @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
2029
+ * @throws {Error} If the auth config cannot be found or enabled
2030
+ *
2031
+ * @example
2032
+ * ```typescript
2033
+ * // Enable an auth config
2034
+ * await composio.authConfigs.enable('auth_abc123');
2035
+ * ```
1198
2036
  */
1199
2037
  async enable(nanoid) {
1200
2038
  return this.client.authConfigs.updateStatus("ENABLED", { nanoid });
1201
2039
  }
1202
2040
  /**
1203
- * Disable an auth config
1204
- * @param {string} nanoid - Unique identifier of the auth config
1205
- * @param {RequestOptions} options - Request options
1206
- * @returns {Promise<AuthConfigUpdateStatusResponse>} Updated auth config details
2041
+ * Disables an authentication configuration.
2042
+ *
2043
+ * This is a convenience method that calls updateStatus with 'DISABLED'.
2044
+ * When disabled, the auth config cannot be used to create new connected accounts
2045
+ * or authenticate with third-party services, but existing connections may continue to work.
2046
+ *
2047
+ * @param {string} nanoid - The unique identifier of the auth config to disable
2048
+ * @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
2049
+ * @throws {Error} If the auth config cannot be found or disabled
2050
+ *
2051
+ * @example
2052
+ * ```typescript
2053
+ * // Disable an auth config
2054
+ * await composio.authConfigs.disable('auth_abc123');
2055
+ * ```
1207
2056
  */
1208
2057
  async disable(nanoid) {
1209
2058
  return this.client.authConfigs.updateStatus("DISABLED", { nanoid });
1210
2059
  }
1211
2060
  };
1212
2061
 
1213
- // src/errors/AuthConfigErrors.ts
1214
- var AuthConfigErrorCodes = {
1215
- AUTH_CONFIG_NOT_FOUND: "AUTH_CONFIG_NOT_FOUND"
1216
- };
1217
- var ComposioAuthConfigNotFoundError = class extends ComposioError {
1218
- constructor(message, meta) {
1219
- super(message, {
1220
- code: AuthConfigErrorCodes.AUTH_CONFIG_NOT_FOUND,
1221
- cause: meta,
1222
- possibleFixes: [
1223
- "Check if the auth config exists",
1224
- "Check if the auth config id is correct",
1225
- "Check if the auth config is enabled"
1226
- ]
1227
- });
1228
- this.name = "ComposioAuthConfigNotFoundError";
1229
- }
1230
- };
1231
-
1232
2062
  // src/types/connectedAccounts.types.ts
1233
2063
  import { z as z4 } from "zod";
1234
2064
  var ConnectedAccountStatuses = {
@@ -1253,7 +2083,7 @@ var CreateConnectedAccountParamsSchema = z4.object({
1253
2083
  }),
1254
2084
  connection: z4.object({
1255
2085
  data: z4.record(z4.string(), z4.unknown()).optional(),
1256
- redirectUrl: z4.string().optional(),
2086
+ callbackUrl: z4.string().optional(),
1257
2087
  userId: z4.string().optional()
1258
2088
  })
1259
2089
  });
@@ -1263,12 +2093,12 @@ var DefaultCreateConnectedAccountParamsSchema = z4.object({
1263
2093
  }),
1264
2094
  connection: z4.object({
1265
2095
  data: z4.record(z4.string(), z4.unknown()).optional(),
1266
- redirect_uri: z4.string().optional(),
2096
+ callback_url: z4.string().optional(),
1267
2097
  user_id: z4.string().optional()
1268
2098
  })
1269
2099
  });
1270
2100
  var CreateConnectedAccountOptionsSchema = z4.object({
1271
- redirectUrl: z4.string().optional(),
2101
+ callbackUrl: z4.string().optional(),
1272
2102
  data: z4.record(z4.string(), z4.unknown()).optional()
1273
2103
  });
1274
2104
  var CreateConnectedAccountResponseSchema = z4.object({
@@ -1317,7 +2147,7 @@ var ConnectedAccountRetrieveResponseSchema = z4.object({
1317
2147
  authConfig: ConnectedAccountAuthConfigSchema,
1318
2148
  userId: z4.string(),
1319
2149
  data: z4.record(z4.string(), z4.unknown()),
1320
- params: z4.record(z4.string(), z4.unknown()),
2150
+ params: z4.record(z4.string(), z4.unknown()).optional(),
1321
2151
  status: ConnectedAccountStatusSchema,
1322
2152
  statusReason: z4.string().nullable(),
1323
2153
  toolkit: z4.object({
@@ -1328,50 +2158,48 @@ var ConnectedAccountRetrieveResponseSchema = z4.object({
1328
2158
  createdAt: z4.string(),
1329
2159
  updatedAt: z4.string()
1330
2160
  });
2161
+ var ConnectedAccountListParamsSchema = z4.object({
2162
+ authConfigIds: z4.array(z4.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
2163
+ cursor: z4.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
2164
+ labels: z4.array(z4.string()).nullable().optional().describe("The labels of the connected accounts"),
2165
+ limit: z4.number().nullable().optional().describe("The limit of the connected accounts to return"),
2166
+ orderBy: z4.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
2167
+ statuses: z4.array(ConnectedAccountStatusSchema).nullable().optional().describe("The statuses of the connected accounts"),
2168
+ toolkitSlugs: z4.array(z4.string()).nullable().optional().describe("The toolkit slugs of the connected accounts"),
2169
+ userIds: z4.array(z4.string()).nullable().optional().describe("The user ids of the connected accounts")
2170
+ });
2171
+ var ConnectedAccountListResponseSchema = z4.object({
2172
+ items: z4.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
2173
+ nextCursor: z4.string().nullable().describe("The next cursor to paginate through the connected accounts"),
2174
+ totalPages: z4.number().describe("The total number of pages of connected accounts")
2175
+ });
1331
2176
 
1332
2177
  // src/models/ConnectionRequest.ts
1333
- import { ZodError as ZodError2 } from "zod";
1334
-
1335
- // src/errors/ConnectionRequestError.ts
1336
- var ConnectionRequestErrorCodes = {
1337
- CONNECTION_REQUEST_TIMEOUT: "CONNECTION_REQUEST_TIMEOUT",
1338
- CONNECTION_REQUEST_FAILED: "CONNECTION_REQUEST_FAILED"
1339
- };
1340
- var ConnectionRequestTimeoutError = class extends ComposioError {
1341
- constructor(message = "Connection request timed out", meta = {}) {
1342
- super(message, {
1343
- code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_TIMEOUT,
1344
- meta
1345
- });
1346
- this.name = "ConnectionRequestTimeoutError";
1347
- }
1348
- };
1349
- var ConnectionRequestFailedError = class extends ComposioError {
1350
- constructor(message = "Connection request failed", meta = {}) {
1351
- super(message, {
1352
- code: ConnectionRequestErrorCodes.CONNECTION_REQUEST_FAILED,
1353
- meta
1354
- });
1355
- this.name = "ConnectionRequestFailedError";
1356
- }
1357
- };
1358
-
1359
- // src/models/ConnectionRequest.ts
2178
+ import ComposioClient from "@composio/client";
2179
+ import { ZodError as ZodError3 } from "zod";
1360
2180
  var ConnectionRequest = class {
1361
2181
  client;
1362
- connectedAccountId;
1363
- connectedAccountStatus;
2182
+ id;
2183
+ status;
1364
2184
  redirectUrl;
1365
- constructor(client, connectedAccountId, connectedAccountStatus, redirectUrl) {
2185
+ constructor(client, connectedAccountId, status, redirectUrl) {
1366
2186
  this.client = client;
1367
- this.connectedAccountId = connectedAccountId;
1368
- this.connectedAccountStatus = connectedAccountStatus;
2187
+ this.id = connectedAccountId;
2188
+ this.status = status || ConnectedAccountStatuses.INITIATED;
1369
2189
  this.redirectUrl = redirectUrl;
2190
+ telemetry.instrument(this);
1370
2191
  }
1371
2192
  /**
1372
- * Transform the response from the Composio API to the SDK format
1373
- * @param response
1374
- * @returns
2193
+ * Transforms the raw connected account response from the Composio API to the SDK format.
2194
+ *
2195
+ * This method converts property names from snake_case to camelCase and reorganizes
2196
+ * the data structure to match the SDK's standardized format.
2197
+ *
2198
+ * @param {OriginalConnectedAccountResponse} response - The raw API response to transform
2199
+ * @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
2200
+ * @throws {ZodError} If the response fails validation against the expected schema
2201
+ *
2202
+ * @private
1375
2203
  */
1376
2204
  async transformResponse(response) {
1377
2205
  try {
@@ -1394,22 +2222,58 @@ var ConnectionRequest = class {
1394
2222
  return parsedResponse;
1395
2223
  } catch (error) {
1396
2224
  logger_default.error("Error transforming response", error);
1397
- if (error instanceof ZodError2) {
2225
+ if (error instanceof ZodError3) {
1398
2226
  logger_default.error(JSON.stringify(error.errors, null, 2));
1399
2227
  }
1400
2228
  throw error;
1401
2229
  }
1402
2230
  }
1403
2231
  /**
1404
- * Wait for the connection to be established.
1405
- * The function will poll the Composio API every second until the connection is established or the timeout is reached.
1406
- * @param {number} timeout - The time in milliseconds to wait for the connection to be established. Default is 30 seconds.
1407
- * @returns
2232
+ * Waits for the connection request to complete and become active.
2233
+ *
2234
+ * This method continuously polls the Composio API to check the status of the connection request
2235
+ * until it either becomes active, enters a terminal error state, or times out.
2236
+ *
2237
+ * @param {number} [timeout=60000] - Maximum time to wait in milliseconds before timing out (default: 60 seconds)
2238
+ * @returns {Promise<ConnectedAccountRetrieveResponse>} The final connected account response when successful
2239
+ * @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
2240
+ * @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
2241
+ * @throws {ConnectionRequestTimeoutError} If the connection request does not complete within the timeout period
2242
+ *
2243
+ * @example
2244
+ * ```typescript
2245
+ * // Wait for connection with default timeout (60 seconds)
2246
+ * try {
2247
+ * const connection = await connectionRequest.waitForConnection();
2248
+ * console.log('Connection established:', connection.id);
2249
+ * } catch (error) {
2250
+ * console.error('Connection failed:', error.message);
2251
+ * }
2252
+ *
2253
+ * // Wait for connection with custom timeout (2 minutes)
2254
+ * const connection = await connectionRequest.waitForConnection(120000);
2255
+ * ```
1408
2256
  */
1409
2257
  async waitForConnection(timeout = 6e4) {
1410
- if (this.connectedAccountStatus === ConnectedAccountStatuses.ACTIVE) {
1411
- const response = await this.client.connectedAccounts.retrieve(this.connectedAccountId);
1412
- return this.transformResponse(response);
2258
+ try {
2259
+ const response = await this.client.connectedAccounts.retrieve(this.id);
2260
+ if (response.status === ConnectedAccountStatuses.ACTIVE) {
2261
+ this.status = ConnectedAccountStatuses.ACTIVE;
2262
+ return this.transformResponse(response);
2263
+ }
2264
+ } catch (error) {
2265
+ if (error instanceof ComposioClient.NotFoundError) {
2266
+ throw new ComposioConnectedAccountNotFoundError(
2267
+ `Connected account with id ${this.id} not found`,
2268
+ {
2269
+ meta: {
2270
+ connectedAccountId: this.id
2271
+ }
2272
+ }
2273
+ );
2274
+ } else {
2275
+ throw error;
2276
+ }
1413
2277
  }
1414
2278
  const terminalErrorStates = [
1415
2279
  ConnectedAccountStatuses.FAILED,
@@ -1420,7 +2284,8 @@ var ConnectionRequest = class {
1420
2284
  const pollInterval = 1e3;
1421
2285
  while (Date.now() - start < timeout) {
1422
2286
  try {
1423
- const response = await this.client.connectedAccounts.retrieve(this.connectedAccountId);
2287
+ const response = await this.client.connectedAccounts.retrieve(this.id);
2288
+ this.status = response.status;
1424
2289
  if (response.status === ConnectedAccountStatuses.ACTIVE) {
1425
2290
  return this.transformResponse(response);
1426
2291
  }
@@ -1428,10 +2293,12 @@ var ConnectionRequest = class {
1428
2293
  throw new ConnectionRequestFailedError(
1429
2294
  `Connection request failed with status: ${response.status}${response.status_reason ? `, reason: ${response.status_reason}` : ""}`,
1430
2295
  {
1431
- userId: response.user_id,
1432
- connectedAccountId: this.connectedAccountId,
1433
- status: response.status,
1434
- statusReason: response.status_reason
2296
+ meta: {
2297
+ userId: response.user_id,
2298
+ connectedAccountId: this.id,
2299
+ status: response.status,
2300
+ statusReason: response.status_reason
2301
+ }
1435
2302
  }
1436
2303
  );
1437
2304
  }
@@ -1440,9 +2307,7 @@ var ConnectionRequest = class {
1440
2307
  throw error;
1441
2308
  }
1442
2309
  }
1443
- throw new ConnectionRequestTimeoutError(
1444
- `Connection request timed out for ${this.connectedAccountId}`
1445
- );
2310
+ throw new ConnectionRequestTimeoutError(`Connection request timed out for ${this.id}`);
1446
2311
  }
1447
2312
  };
1448
2313
 
@@ -1451,15 +2316,103 @@ var ConnectedAccounts = class {
1451
2316
  client;
1452
2317
  constructor(client) {
1453
2318
  this.client = client;
2319
+ telemetry.instrument(this);
2320
+ }
2321
+ transformConnectedAccountRetrieveResponse(response) {
2322
+ const result = ConnectedAccountRetrieveResponseSchema.safeParse({
2323
+ ...response,
2324
+ userId: response.user_id,
2325
+ // Add the missing userId property
2326
+ authConfig: {
2327
+ ...response.auth_config,
2328
+ authScheme: response.auth_config.auth_scheme,
2329
+ isComposioManaged: response.auth_config.is_composio_managed,
2330
+ isDisabled: response.auth_config.is_disabled
2331
+ },
2332
+ statusReason: response.status_reason,
2333
+ isDisabled: response.is_disabled,
2334
+ createdAt: response.created_at,
2335
+ updatedAt: response.updated_at,
2336
+ testRequestEndpoint: response.test_request_endpoint
2337
+ });
2338
+ if (!result.success) {
2339
+ throw new ValidationError("Failed to parse connected account retrieve response", {
2340
+ cause: result.error
2341
+ });
2342
+ }
2343
+ return result.data;
1454
2344
  }
1455
2345
  /**
1456
- * List all connected accounts
1457
- * @param {ConnectedAccountListParams} query - Query parameters for filtering connected accounts
1458
- * @param {RequestOptions} options - Request options
1459
- * @returns {Promise<ConnectedAccountListResponse>} List of connected accounts
2346
+ * Lists all connected accounts based on provided filter criteria.
2347
+ *
2348
+ * This method retrieves connected accounts from the Composio API with optional filtering.
2349
+ *
2350
+ * @param {ConnectedAccountListParams} [query] - Optional query parameters for filtering connected accounts
2351
+ * @returns {Promise<ConnectedAccountListResponse>} A paginated list of connected accounts
2352
+ * @throws {ValidationError} If the query fails validation against the expected schema
2353
+ * @example
2354
+ * ```typescript
2355
+ * // List all connected accounts
2356
+ * const allAccounts = await composio.connectedAccounts.list();
2357
+ *
2358
+ * // List accounts for a specific user
2359
+ * const userAccounts = await composio.connectedAccounts.list({
2360
+ * userIds: ['user123']
2361
+ * });
2362
+ *
2363
+ * // List accounts for a specific toolkit
2364
+ * const githubAccounts = await composio.connectedAccounts.list({
2365
+ * toolkitSlugs: ['github']
2366
+ * });
2367
+ * ```
1460
2368
  */
1461
2369
  async list(query) {
1462
- return this.client.connectedAccounts.list(query);
2370
+ let rawQuery = void 0;
2371
+ if (query) {
2372
+ const parsedQuery = ConnectedAccountListParamsSchema.safeParse(query);
2373
+ if (!parsedQuery.success) {
2374
+ throw new ValidationError("Failed to parse connected account list query", {
2375
+ cause: parsedQuery.error
2376
+ });
2377
+ }
2378
+ rawQuery = {
2379
+ auth_config_ids: parsedQuery.data.authConfigIds,
2380
+ cursor: parsedQuery.data.cursor,
2381
+ labels: parsedQuery.data.labels,
2382
+ limit: parsedQuery.data.limit,
2383
+ order_by: parsedQuery.data.orderBy,
2384
+ statuses: parsedQuery.data.statuses,
2385
+ toolkit_slugs: parsedQuery.data.toolkitSlugs,
2386
+ user_ids: parsedQuery.data.userIds
2387
+ };
2388
+ }
2389
+ const result = await this.client.connectedAccounts.list(rawQuery);
2390
+ const parsedResponse = ConnectedAccountListResponseSchema.safeParse({
2391
+ items: result.items.map(this.transformConnectedAccountRetrieveResponse),
2392
+ nextCursor: result.next_cursor,
2393
+ totalPages: result.total_pages
2394
+ });
2395
+ if (!parsedResponse.success) {
2396
+ throw new ValidationError("Failed to parse connected account list response", {
2397
+ cause: parsedResponse.error
2398
+ });
2399
+ }
2400
+ return parsedResponse.data;
2401
+ }
2402
+ /**
2403
+ * Transforms connected account data from API format to SDK format.
2404
+ *
2405
+ * This method converts property names from snake_case to camelCase and reorganizes
2406
+ * the data structure to match the SDK's standardized format for connected accounts.
2407
+ *
2408
+ * @param {ConnectedAccountRetrieveResponseRaw} response - The raw API response to transform
2409
+ * @returns {ConnectedAccountRetrieveResponse} The transformed connected account data
2410
+ * @throws {ValidationError} If the response fails validation against the expected schema
2411
+ *
2412
+ * @private
2413
+ */
2414
+ transformConnectedAccountResponse(response) {
2415
+ return this.transformConnectedAccountRetrieveResponse(response);
1463
2416
  }
1464
2417
  /**
1465
2418
  * Compound function to create a new connected account.
@@ -1486,35 +2439,94 @@ var ConnectedAccounts = class {
1486
2439
  },
1487
2440
  connection: {
1488
2441
  data: options?.data,
1489
- redirect_uri: options?.redirectUrl,
2442
+ callback_url: options?.callbackUrl,
1490
2443
  user_id: userId
1491
2444
  }
1492
2445
  });
1493
- return new ConnectionRequest(this.client, response.id, response.status, response.redirect_uri);
2446
+ return new ConnectionRequest(this.client, response.id, response.status, response.redirect_url);
1494
2447
  }
1495
2448
  /**
1496
- * Get a connected account by nanoid
1497
- * @param {string} nanoid - Unique identifier of the connected account
1498
- * @param {RequestOptions} options - Request options
1499
- * @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
2449
+ * Waits for a connection request to complete and become active.
2450
+ *
2451
+ * This method continuously polls the Composio API to check the status of a connection
2452
+ * until it either becomes active, enters a terminal error state, or times out.
2453
+ *
2454
+ * @param {string} connectedAccountId - The ID of the connected account to wait for
2455
+ * @param {number} [timeout=60000] - Maximum time to wait in milliseconds (default: 60 seconds)
2456
+ * @returns {Promise<ConnectedAccountRetrieveResponse>} The finalized connected account data
2457
+ * @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
2458
+ * @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
2459
+ * @throws {ConnectionRequestTimeoutError} If the connection does not complete within the timeout period
2460
+ *
2461
+ * @example
2462
+ * ```typescript
2463
+ * // Wait for a connection to complete with default timeout
2464
+ * const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc');
2465
+ *
2466
+ * // Wait with a custom timeout of 2 minutes
2467
+ * const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc', 120000);
2468
+ * ```
2469
+ */
2470
+ async waitForConnection(connectedAccountId, timeout = 6e4) {
2471
+ const connectionRequest = new ConnectionRequest(this.client, connectedAccountId);
2472
+ return connectionRequest.waitForConnection(timeout);
2473
+ }
2474
+ /**
2475
+ * Retrieves a specific connected account by its ID.
2476
+ *
2477
+ * This method fetches detailed information about a single connected account
2478
+ * and transforms the response to the SDK's standardized format.
2479
+ *
2480
+ * @param {string} nanoid - The unique identifier of the connected account
2481
+ * @returns {Promise<ConnectedAccountRetrieveResponse>} The connected account details
2482
+ * @throws {Error} If the connected account cannot be found or an API error occurs
2483
+ *
2484
+ * @example
2485
+ * ```typescript
2486
+ * // Get a connected account by ID
2487
+ * const account = await composio.connectedAccounts.get('conn_abc123');
2488
+ * console.log(account.status); // e.g., 'ACTIVE'
2489
+ * console.log(account.toolkit.slug); // e.g., 'github'
2490
+ * ```
1500
2491
  */
1501
2492
  async get(nanoid) {
1502
- return this.client.connectedAccounts.retrieve(nanoid);
2493
+ const response = await this.client.connectedAccounts.retrieve(nanoid);
2494
+ return this.transformConnectedAccountResponse(response);
1503
2495
  }
1504
2496
  /**
1505
- * Delete a connected account
1506
- * @param {string} nanoid - Unique identifier of the connected account to delete
1507
- * @param {RequestOptions} options - Request options
1508
- * @returns {Promise<ConnectedAccountDeleteResponse>} Response from deletion
2497
+ * Deletes a connected account.
2498
+ *
2499
+ * This method permanently removes a connected account from the Composio platform.
2500
+ * This action cannot be undone and will revoke any access tokens associated with the account.
2501
+ *
2502
+ * @param {string} nanoid - The unique identifier of the connected account to delete
2503
+ * @returns {Promise<ConnectedAccountDeleteResponse>} The deletion response
2504
+ * @throws {Error} If the account doesn't exist or cannot be deleted
2505
+ *
2506
+ * @example
2507
+ * ```typescript
2508
+ * // Delete a connected account
2509
+ * await composio.connectedAccounts.delete('conn_abc123');
2510
+ * ```
1509
2511
  */
1510
2512
  async delete(nanoid) {
1511
2513
  return this.client.connectedAccounts.delete(nanoid);
1512
2514
  }
1513
2515
  /**
1514
- * Refresh a connected account's credentials
1515
- * @param {string} nanoid - Unique identifier of the connected account to refresh
1516
- * @param {RequestOptions} options - Request options
1517
- * @returns {Promise<ConnectedAccountRefreshResponse>} Refreshed connected account details
2516
+ * Refreshes a connected account's authentication credentials.
2517
+ *
2518
+ * This method attempts to refresh OAuth tokens or other credentials associated with
2519
+ * the connected account. This is useful when a token has expired or is about to expire.
2520
+ *
2521
+ * @param {string} nanoid - The unique identifier of the connected account to refresh
2522
+ * @returns {Promise<ConnectedAccountRefreshResponse>} The response containing the refreshed account details
2523
+ * @throws {Error} If the account doesn't exist or credentials cannot be refreshed
2524
+ *
2525
+ * @example
2526
+ * ```typescript
2527
+ * // Refresh a connected account's credentials
2528
+ * const refreshedAccount = await composio.connectedAccounts.refresh('conn_abc123');
2529
+ * ```
1518
2530
  */
1519
2531
  async refresh(nanoid) {
1520
2532
  return this.client.connectedAccounts.refresh(nanoid);
@@ -1555,49 +2567,78 @@ var Toolkits = class {
1555
2567
  constructor(client) {
1556
2568
  this.client = client;
1557
2569
  this.authorize = this.authorize.bind(this);
2570
+ telemetry.instrument(this);
1558
2571
  }
1559
2572
  /**
1560
- * List all toolkits available in the Composio SDK.
1561
- * This method fetches the toolkits from the Composio API.
1562
- * @returns {Promise<Toolkit[]>} List of toolkits
2573
+ * Retrieves a list of toolkits based on the provided query parameters.
2574
+ *
2575
+ * This method fetches toolkits from the Composio API and transforms the response
2576
+ * from snake_case to camelCase format for consistency with JavaScript/TypeScript conventions.
2577
+ *
2578
+ * @param {ToolkitListParams} query - The query parameters to filter toolkits
2579
+ * @returns {Promise<ToolKitListResponse>} The transformed list of toolkits
2580
+ *
2581
+ * @private
1563
2582
  */
1564
2583
  async getToolkits(query) {
1565
- const parsedQuery = ToolkitsListParamsSchema.parse(query);
1566
- const result = await this.client.toolkits.list({
1567
- category: parsedQuery.category,
1568
- is_local: parsedQuery.isLocal,
1569
- managed_by: parsedQuery.managedBy,
1570
- sort_by: parsedQuery.sortBy
1571
- });
1572
- const parsedResult = ToolKitListResponseSchema.parse({
1573
- items: result.items.map((item) => {
1574
- const parsedItem = ToolKitItemSchema.parse({
1575
- name: item.name,
1576
- slug: item.slug,
1577
- meta: item.meta,
1578
- isLocalToolkit: item.is_local_toolkit,
1579
- authSchemes: item.auth_schemes,
1580
- composioManagedAuthSchemes: item.composio_managed_auth_schemes,
1581
- noAuth: item.no_auth
2584
+ try {
2585
+ const parsedQuery = ToolkitsListParamsSchema.safeParse(query);
2586
+ if (!parsedQuery.success) {
2587
+ throw new ValidationError("Failed to parse toolkit list query", {
2588
+ cause: parsedQuery.error
1582
2589
  });
1583
- return parsedItem;
1584
- }),
1585
- nextCursor: result.next_cursor,
1586
- totalPages: result.total_pages
1587
- });
1588
- return parsedResult;
2590
+ }
2591
+ const result = await this.client.toolkits.list({
2592
+ category: parsedQuery.data.category,
2593
+ is_local: parsedQuery.data.isLocal,
2594
+ managed_by: parsedQuery.data.managedBy,
2595
+ sort_by: parsedQuery.data.sortBy
2596
+ });
2597
+ const parsedResult = ToolKitListResponseSchema.safeParse({
2598
+ items: result.items.map((item) => {
2599
+ const parsedItem = ToolKitItemSchema.parse({
2600
+ name: item.name,
2601
+ slug: item.slug,
2602
+ meta: item.meta,
2603
+ isLocalToolkit: item.is_local_toolkit,
2604
+ authSchemes: item.auth_schemes,
2605
+ composioManagedAuthSchemes: item.composio_managed_auth_schemes,
2606
+ noAuth: item.no_auth
2607
+ });
2608
+ return parsedItem;
2609
+ }),
2610
+ nextCursor: result.next_cursor,
2611
+ totalPages: result.total_pages
2612
+ });
2613
+ if (!parsedResult.success) {
2614
+ throw new ValidationError("Failed to parse toolkit list response", {
2615
+ cause: parsedResult.error
2616
+ });
2617
+ }
2618
+ return parsedResult.data;
2619
+ } catch (error) {
2620
+ throw new ComposioToolkitFetchError("Failed to fetch toolkits", {
2621
+ cause: error
2622
+ });
2623
+ }
1589
2624
  }
1590
2625
  /**
1591
- * Fetches a toolkit by its Slug.
1592
- * This method retrieves the toolkit from the Composio API.
1593
- * @param slug - The ID of the toolkit to be retrieved
1594
- * @param options - Request options
1595
- * @returns {Promise<ToolkitRetrieveResponse>} The toolkit object
2626
+ * Retrieves a specific toolkit by its slug identifier.
2627
+ *
2628
+ * This method fetches a single toolkit from the Composio API and transforms
2629
+ * the response to use camelCase property naming consistent with JavaScript/TypeScript conventions.
2630
+ *
2631
+ * @param {string} slug - The unique slug identifier of the toolkit to retrieve
2632
+ * @returns {Promise<ToolkitRetrieveResponse>} The transformed toolkit object
2633
+ * @throws {ValidationError} If the response cannot be properly parsed
2634
+ * @throws {ComposioToolNotFoundError} If no toolkit with the given slug exists
2635
+ *
2636
+ * @private
1596
2637
  */
1597
2638
  async getToolkitBySlug(slug) {
1598
2639
  try {
1599
2640
  const result = await this.client.toolkits.retrieve(slug);
1600
- const parsedResult = ToolkitRetrieveResponseSchema.parse({
2641
+ const parsedResult = ToolkitRetrieveResponseSchema.safeParse({
1601
2642
  name: result.name,
1602
2643
  slug: result.slug,
1603
2644
  meta: {
@@ -1622,21 +2663,34 @@ var Toolkits = class {
1622
2663
  }
1623
2664
  }))
1624
2665
  });
1625
- return parsedResult;
2666
+ if (!parsedResult.success) {
2667
+ throw new ValidationError("Failed to parse toolkit response", {
2668
+ cause: parsedResult.error
2669
+ });
2670
+ }
2671
+ return parsedResult.data;
1626
2672
  } catch (error) {
1627
- if (error instanceof ZodError3) {
1628
- throw new ValidationError(error);
2673
+ if (error instanceof ComposioClient2.NotFoundError) {
2674
+ throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
2675
+ meta: {
2676
+ slug
2677
+ },
2678
+ cause: error
2679
+ });
1629
2680
  }
1630
- throw new ComposioToolNotFoundError(`Toolkit with slug ${slug} not found`, {
1631
- slug
2681
+ throw new ComposioToolkitFetchError(`Couldn't fetch Toolkit with slug: ${slug}`, {
2682
+ meta: {
2683
+ slug
2684
+ },
2685
+ cause: error
1632
2686
  });
1633
2687
  }
1634
2688
  }
1635
2689
  /**
1636
- * Fetches a toolkit by its Slug or a list of toolkits.
1637
- * This method retrieves the toolkit from the Composio API.
1638
- * @param arg - The ID of the toolkit to be retrieved or a list of parameters
1639
- * @returns {Promise<ToolkitRetrieveResponse | ToolKitListResponse>} The toolkit object or a list of toolkits
2690
+ * Implementation method that handles both overloads for retrieving toolkits.
2691
+ *
2692
+ * @param {string | ToolkitListParams} arg - Either a toolkit slug or query parameters
2693
+ * @returns {Promise<ToolkitRetrieveResponse | ToolKitListResponse>} The toolkit or list of toolkits
1640
2694
  */
1641
2695
  async get(arg) {
1642
2696
  if (typeof arg === "string") {
@@ -1645,9 +2699,19 @@ var Toolkits = class {
1645
2699
  return this.getToolkits(arg);
1646
2700
  }
1647
2701
  /**
1648
- * Fetches all categories available in the Composio SDK
2702
+ * Retrieves all toolkit categories available in the Composio SDK.
2703
+ *
2704
+ * This method fetches the complete list of categories from the Composio API
2705
+ * and transforms the response to use camelCase property naming.
2706
+ *
2707
+ * @returns {Promise<ToolkitRetrieveCategoriesResponse>} The list of toolkit categories
1649
2708
  *
1650
- * @returns {Promise<ToolkitRetrieveCategoriesResponse>} List of categories
2709
+ * @example
2710
+ * ```typescript
2711
+ * // Get all toolkit categories
2712
+ * const categories = await composio.toolkits.listCategories();
2713
+ * console.log(categories.items); // Array of category objects
2714
+ * ```
1651
2715
  */
1652
2716
  async listCategories() {
1653
2717
  const result = await this.client.toolkits.retrieveCategories();
@@ -1669,15 +2733,19 @@ var Toolkits = class {
1669
2733
  * This method will create an auth config if one doesn't exist and initiate a connection request.
1670
2734
  * @param {string} userId - The user id of the user to authorize
1671
2735
  * @param {string} toolkitSlug - The slug of the toolkit to authorize
1672
- * @param {string} authConfigId - The id of the auth config to use
1673
2736
  * @returns {Promise<ConnectionRequest>} The connection request object
2737
+ *
2738
+ * @example
2739
+ * ```typescript
2740
+ * const connectionRequest = await composio.toolkits.authorize(userId, 'github');
2741
+ * ```
1674
2742
  */
1675
2743
  async authorize(userId, toolkitSlug) {
1676
2744
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
1677
2745
  const composioAuthConfig = new AuthConfigs(this.client);
1678
2746
  let authConfigIdToUse;
1679
2747
  const authConfig = await composioAuthConfig.list({
1680
- toolkitSlug
2748
+ toolkit: toolkitSlug
1681
2749
  });
1682
2750
  authConfigIdToUse = authConfig.items[0]?.id;
1683
2751
  if (!authConfigIdToUse) {
@@ -1689,7 +2757,9 @@ var Toolkits = class {
1689
2757
  authConfigIdToUse = authConfig2.id;
1690
2758
  } else {
1691
2759
  throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
1692
- toolkitSlug
2760
+ meta: {
2761
+ toolkitSlug
2762
+ }
1693
2763
  });
1694
2764
  }
1695
2765
  }
@@ -1794,6 +2864,7 @@ var Session = class {
1794
2864
  client;
1795
2865
  constructor(client) {
1796
2866
  this.client = client;
2867
+ telemetry.instrument(this);
1797
2868
  }
1798
2869
  /**
1799
2870
  * Get the active session info
@@ -1809,6 +2880,7 @@ var Triggers = class {
1809
2880
  client;
1810
2881
  constructor(client) {
1811
2882
  this.client = client;
2883
+ telemetry.instrument(this);
1812
2884
  }
1813
2885
  /**
1814
2886
  * Fetch list of all the active triggers
@@ -1940,235 +3012,6 @@ var Triggers = class {
1940
3012
  }
1941
3013
  };
1942
3014
 
1943
- // src/types/telemetry.types.ts
1944
- var TELEMETRY_EVENTS = {
1945
- SDK_INITIALIZED: "SDK_INITIALIZED",
1946
- SDK_METHOD_INVOKED: "SDK_METHOD_INVOKED",
1947
- SDK_METHOD_ERROR: "SDK_METHOD_ERROR",
1948
- CLI_INVOKED: "CLI_INVOKED"
1949
- };
1950
-
1951
- // src/utils/constants.ts
1952
- var COMPOSIO_DIR = ".composio";
1953
- var USER_DATA_FILE_NAME = "user_data.json";
1954
- var DEFAULT_BASE_URL = "https://backend.composio.dev";
1955
- var TELEMETRY_URL = "https://app.composio.dev";
1956
- var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
1957
-
1958
- // src/telemetry/BatchProcessor.ts
1959
- var BatchProcessor = class {
1960
- batch = [];
1961
- time;
1962
- batchSize;
1963
- processBatchCallback;
1964
- timer = null;
1965
- constructor(time = 2e3, batchSize = 100, processBatchCallback) {
1966
- this.batch = [];
1967
- this.time = time;
1968
- this.batchSize = batchSize;
1969
- this.processBatchCallback = processBatchCallback;
1970
- }
1971
- pushItem(item) {
1972
- this.batch.push(item);
1973
- if (this.batch.length >= this.batchSize) {
1974
- this.processBatch();
1975
- } else if (!this.timer) {
1976
- this.timer = setTimeout(() => this.processBatch(), this.time);
1977
- }
1978
- }
1979
- processBatch() {
1980
- if (this.batch.length > 0) {
1981
- this.processBatchCallback(this.batch);
1982
- this.batch = [];
1983
- }
1984
- if (this.timer) {
1985
- clearTimeout(this.timer);
1986
- this.timer = null;
1987
- }
1988
- }
1989
- };
1990
-
1991
- // src/telemetry/transports/BrowserTransport.ts
1992
- var BrowserTelemetryTransport = class {
1993
- send(payload) {
1994
- if (typeof window === "undefined") {
1995
- return Promise.reject(
1996
- new Error("BrowserTelemetryTransport can only be used in browser environments")
1997
- );
1998
- }
1999
- return new Promise((resolve) => {
2000
- try {
2001
- const xhr = new XMLHttpRequest();
2002
- xhr.open(payload.method, payload.url, true);
2003
- xhr.setRequestHeader("Content-Type", "application/json");
2004
- Object.entries(payload.headers || {}).forEach(([key, value]) => {
2005
- xhr.setRequestHeader(key, value);
2006
- });
2007
- xhr.onload = function() {
2008
- resolve();
2009
- };
2010
- xhr.send(JSON.stringify(payload.data));
2011
- } catch (error) {
2012
- logger_default.error("Error sending error to telemetry", error);
2013
- resolve();
2014
- }
2015
- });
2016
- }
2017
- };
2018
-
2019
- // src/telemetry/transports/ProcessTransport.ts
2020
- var ProcessTelemetryTransport = class {
2021
- send(payload) {
2022
- if (typeof window !== "undefined") {
2023
- return Promise.reject(
2024
- new Error("ProcessTelemetryTransport can only be used in Node.js environments")
2025
- );
2026
- }
2027
- return new Promise((resolve) => {
2028
- try {
2029
- const url = new URL(payload.url);
2030
- const protocol = url.protocol === "https:" ? "https" : "http";
2031
- const port = url.port || (url.protocol === "https:" ? 443 : 80);
2032
- const args = [
2033
- "-e",
2034
- `
2035
- const http = require('${protocol}');
2036
- const options = {
2037
- hostname: '${url.hostname}',
2038
- path: '${url.pathname}${url.search}',
2039
- port: ${port},
2040
- method: '${payload.method}',
2041
- headers: ${JSON.stringify(payload.headers)}
2042
- };
2043
-
2044
- const req = http.request(options, (res) => {
2045
- res.on('data', () => {});
2046
- res.on('end', () => {
2047
- process.exit(0);
2048
- });
2049
- });
2050
-
2051
- req.on('error', () => {
2052
- process.exit(0);
2053
- });
2054
-
2055
- req.write(JSON.stringify(${JSON.stringify(payload.data)}));
2056
- req.end();
2057
- `
2058
- ];
2059
- import("child_process").then(({ spawn }) => {
2060
- spawn("node", args, {
2061
- stdio: "ignore",
2062
- detached: true,
2063
- shell: false
2064
- }).unref();
2065
- resolve();
2066
- }).catch(() => {
2067
- resolve();
2068
- });
2069
- } catch (error) {
2070
- logger_default.error("Error sending telemetry", error);
2071
- resolve();
2072
- }
2073
- });
2074
- }
2075
- };
2076
-
2077
- // src/telemetry/Telemetry.ts
2078
- var Telemetry = class {
2079
- telemetryMetadata;
2080
- transport;
2081
- batchProcessor = new BatchProcessor(100, 10, async (data) => {
2082
- await this.sendTelemetry(data);
2083
- });
2084
- constructor(metadata, transport) {
2085
- this.telemetryMetadata = metadata;
2086
- const isBrowser = typeof window !== "undefined";
2087
- if (transport) {
2088
- this.transport = transport;
2089
- } else if (isBrowser) {
2090
- this.transport = new BrowserTelemetryTransport();
2091
- } else {
2092
- this.transport = new ProcessTelemetryTransport();
2093
- }
2094
- this.sendTelemetry([
2095
- {
2096
- eventName: TELEMETRY_EVENTS.SDK_INITIALIZED,
2097
- data: {},
2098
- sdk_meta: this.telemetryMetadata
2099
- }
2100
- ]);
2101
- }
2102
- /**
2103
- * Instrument the telemetry for the given instance.
2104
- *
2105
- * You can pass the instance and the file name of the instance to instrument the telemetry.
2106
- * This will instrument all the methods of the instance and log the telemetry for each method call.
2107
- * @param instance - any instance that extends InstrumentedInstance
2108
- * @param fileName - the file name of the instance
2109
- * @returns
2110
- */
2111
- instrumentTelemetry(instance, fileName) {
2112
- const proto = Object.getPrototypeOf(instance);
2113
- const methodNames = Object.getOwnPropertyNames(proto).filter((key) => {
2114
- const descriptor = Object.getOwnPropertyDescriptor(proto, key);
2115
- return key !== "constructor" && descriptor && typeof descriptor.value === "function" && descriptor.value.constructor.name === "AsyncFunction";
2116
- });
2117
- const instrumentedClassName = instance.constructor?.name || fileName || "unknown";
2118
- for (const name of methodNames) {
2119
- const originalMethod = instance[name];
2120
- instance[name] = async (...args) => {
2121
- const telemetryPayload = {
2122
- eventName: TELEMETRY_EVENTS.SDK_METHOD_INVOKED,
2123
- data: {
2124
- fileName: instrumentedClassName,
2125
- method: name,
2126
- params: args
2127
- },
2128
- sdk_meta: this.telemetryMetadata
2129
- };
2130
- this.batchProcessor.pushItem(telemetryPayload);
2131
- try {
2132
- return await originalMethod.apply(instance, args);
2133
- } catch (error) {
2134
- const telemetryPayload2 = {
2135
- eventName: TELEMETRY_EVENTS.SDK_METHOD_ERROR,
2136
- data: {
2137
- fileName: instrumentedClassName,
2138
- method: name,
2139
- params: args,
2140
- error
2141
- },
2142
- sdk_meta: this.telemetryMetadata
2143
- };
2144
- this.batchProcessor.pushItem(telemetryPayload2);
2145
- throw error;
2146
- }
2147
- };
2148
- }
2149
- return instance;
2150
- }
2151
- /**
2152
- * Send the telemetry payload to the server.
2153
- * @param payload - the telemetry payload to send
2154
- * @returns
2155
- */
2156
- async sendTelemetry(payload) {
2157
- const isTelemetryDisabled = getEnvVariable("TELEMETRY_DISABLED", "false") === "true";
2158
- if (isTelemetryDisabled) {
2159
- return;
2160
- }
2161
- const url = `${TELEMETRY_URL}/api/sdk_metrics/telemetry`;
2162
- const reqPayload = {
2163
- data: payload,
2164
- url,
2165
- method: "POST",
2166
- headers: { "Content-Type": "application/json" }
2167
- };
2168
- this.transport.send(reqPayload);
2169
- }
2170
- };
2171
-
2172
3015
  // src/utils/sdk.ts
2173
3016
  var userDataPath = () => {
2174
3017
  try {
@@ -2176,6 +3019,7 @@ var userDataPath = () => {
2176
3019
  const os = __require("os");
2177
3020
  return path.join(os.homedir(), COMPOSIO_DIR, USER_DATA_FILE_NAME);
2178
3021
  } catch (_error) {
3022
+ logger_default.debug("Environment", `Unable to get user data path`);
2179
3023
  return null;
2180
3024
  }
2181
3025
  };
@@ -2185,6 +3029,7 @@ var getUserDataJson = () => {
2185
3029
  const data = fs.readFileSync(userDataPath(), "utf8");
2186
3030
  return JSON.parse(data);
2187
3031
  } catch (_error) {
3032
+ logger_default.debug("Environment", "No user data file found");
2188
3033
  return {};
2189
3034
  }
2190
3035
  };
@@ -2193,27 +3038,33 @@ function getSDKConfig(baseUrl, apiKey) {
2193
3038
  const { api_key: apiKeyFromUserConfig, base_url: baseURLFromUserConfig } = userData;
2194
3039
  const baseURLParsed = baseUrl || getEnvVariable("COMPOSIO_BASE_URL") || baseURLFromUserConfig || DEFAULT_BASE_URL;
2195
3040
  const apiKeyParsed = apiKey || getEnvVariable("COMPOSIO_API_KEY") || apiKeyFromUserConfig || "";
3041
+ if (!apiKeyParsed) {
3042
+ ComposioError.handle(new ComposioNoAPIKeyError(), {
3043
+ exitProcess: true
3044
+ });
3045
+ }
3046
+ logger_default.debug("Environment", `API Key: ${apiKeyParsed}`);
3047
+ logger_default.debug("Environment", `Base URL: ${baseURLParsed}`);
2196
3048
  return { baseURL: baseURLParsed, apiKey: apiKeyParsed };
2197
3049
  }
2198
3050
 
2199
3051
  // src/utils/version.ts
2200
- function isNewerVersion(version1, version2) {
2201
- const v1 = version1.split(".").map(Number);
2202
- const v2 = version2.split(".").map(Number);
2203
- for (let i = 0; i < 3; i++) {
2204
- if (v1[i] > v2[i]) return true;
2205
- if (v1[i] < v2[i]) return false;
2206
- }
2207
- return false;
2208
- }
3052
+ import semver from "semver";
2209
3053
  async function checkForLatestVersionFromNPM(currentVersion) {
2210
3054
  try {
2211
- const packageName = "composio-core";
3055
+ const packageName = "@composio/core";
2212
3056
  const currentVersionFromPackageJson = currentVersion;
3057
+ if (!semver.valid(currentVersionFromPackageJson)) {
3058
+ return;
3059
+ }
3060
+ const prerelease = semver.prerelease(currentVersionFromPackageJson);
3061
+ if (prerelease && (String(prerelease[0]).includes("alpha") || String(prerelease[0]).includes("beta"))) {
3062
+ return;
3063
+ }
2213
3064
  const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
2214
3065
  const data = await response.json();
2215
3066
  const latestVersion = data.version;
2216
- if (isNewerVersion(latestVersion, currentVersionFromPackageJson) && !IS_DEVELOPMENT_OR_CI) {
3067
+ if (semver.gt(latestVersion, currentVersionFromPackageJson) && !IS_DEVELOPMENT_OR_CI) {
2217
3068
  logger_default.info(
2218
3069
  `\u{1F680} Upgrade available! Your composio-core version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`
2219
3070
  );
@@ -2427,13 +3278,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
2427
3278
  };
2428
3279
 
2429
3280
  // package.json
2430
- var version = "0.1.12-alpha.0";
2431
-
2432
- // src/utils/uuid.ts
2433
- import { v4 as uuidv4 } from "uuid";
2434
- function getRandomUUID() {
2435
- return uuidv4();
2436
- }
3281
+ var version = "0.1.12-alpha.11";
2437
3282
 
2438
3283
  // src/composio.ts
2439
3284
  var Composio = class {
@@ -2447,7 +3292,6 @@ var Composio = class {
2447
3292
  * @type {ComposioConfig<TProvider>}
2448
3293
  */
2449
3294
  config;
2450
- telemetry;
2451
3295
  /**
2452
3296
  * Core models for Composio.
2453
3297
  */
@@ -2457,10 +3301,8 @@ var Composio = class {
2457
3301
  provider;
2458
3302
  // auth configs
2459
3303
  authConfigs;
2460
- createAuthConfig;
2461
3304
  // connected accounts
2462
3305
  connectedAccounts;
2463
- initiateConnection;
2464
3306
  /**
2465
3307
  * @param {Object} config Configuration for the Composio SDK.
2466
3308
  * @param {string} config.apiKey The API key for the Composio SDK.
@@ -2476,58 +3318,46 @@ var Composio = class {
2476
3318
  config?.apiKey
2477
3319
  );
2478
3320
  if (IS_DEVELOPMENT_OR_CI) {
2479
- logger_default.info(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
3321
+ logger_default.debug(`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`);
2480
3322
  }
2481
- this.client = new ComposioClient({
3323
+ this.client = new ComposioClient3({
2482
3324
  apiKey: apiKeyParsed,
2483
3325
  baseURL: baseURLParsed
2484
3326
  });
2485
3327
  this.config = {
2486
3328
  ...config,
2487
- allowTracking: config.allowTracking ?? true
3329
+ allowTracking: config?.allowTracking ?? true,
3330
+ allowTracing: config?.allowTracing ?? true
2488
3331
  };
2489
- this.provider = config.provider ?? new OpenAIProvider();
3332
+ this.provider = config?.provider ?? new OpenAIProvider();
2490
3333
  this.tools = new Tools(this.client, this.provider);
2491
- this.provider._setExecuteToolFn(this.tools.execute);
2492
3334
  this.toolkits = new Toolkits(this.client);
2493
3335
  this.triggers = new Triggers(this.client);
2494
3336
  this.authConfigs = new AuthConfigs(this.client);
2495
- this.createAuthConfig = this.authConfigs.create.bind(this.authConfigs);
2496
3337
  this.connectedAccounts = new ConnectedAccounts(this.client);
2497
- this.initiateConnection = this.connectedAccounts.initiate.bind(this.connectedAccounts);
2498
- if (this.config.allowTracking ?? true) {
2499
- this.initializeTelemetry(
3338
+ if (this.config.allowTracking) {
3339
+ telemetry.setup(
2500
3340
  {
2501
3341
  apiKey: apiKeyParsed ?? "",
2502
3342
  baseUrl: baseURLParsed ?? "",
2503
- frameworkRuntime: "node",
2504
- source: "node",
2505
- // @TODO: get the source
2506
- composioVersion: version,
3343
+ frameworkRuntime: this.provider?.name || "unknown",
3344
+ isAgentic: this.provider?._isAgentic || false,
3345
+ source: "javascript",
3346
+ version,
3347
+ sdkType: "Typescript-V3",
2507
3348
  isBrowser: typeof window !== "undefined",
2508
- sessionId: getRandomUUID()
3349
+ // @TODO: Users might want to pass their own session id
3350
+ // @TODO: We shouldn't be doing this as people might always have one session id throughout the process in server
3351
+ sessionId: this.config.allowTracing ? getRandomUUID() : void 0
2509
3352
  // @TODO: get the session id
2510
3353
  },
2511
- config.telemetryTransport
3354
+ config?.telemetryTransport
2512
3355
  );
2513
3356
  }
3357
+ telemetry.instrument(this);
3358
+ telemetry.instrument(this.provider);
2514
3359
  checkForLatestVersionFromNPM(version);
2515
3360
  }
2516
- /**
2517
- * Initialize the instrumentations and telemetry for the Composio SDK.
2518
- * @param {TelemetryMetadata} config - The configuration for the telemetry.
2519
- * @param {BaseTelemetryTransport} transport - The transport for the telemetry.
2520
- */
2521
- initializeTelemetry(config, transport) {
2522
- this.telemetry = new Telemetry(config, transport);
2523
- this.telemetry.instrumentTelemetry(this);
2524
- this.telemetry.instrumentTelemetry(this.tools);
2525
- this.telemetry.instrumentTelemetry(this.toolkits);
2526
- this.telemetry.instrumentTelemetry(this.triggers);
2527
- this.telemetry.instrumentTelemetry(this.authConfigs);
2528
- this.telemetry.instrumentTelemetry(this.connectedAccounts);
2529
- this.telemetry.instrumentTelemetry(this.provider);
2530
- }
2531
3361
  /**
2532
3362
  * Get the Composio SDK client.
2533
3363
  * @returns {ComposioClient} The Composio API client.
@@ -2538,24 +3368,6 @@ var Composio = class {
2538
3368
  }
2539
3369
  return this.client;
2540
3370
  }
2541
- /**
2542
- * Fetch all the tools from Composio.
2543
- * @param {ToolListParams} params Parameters to fetch the tools.
2544
- * @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
2545
- * @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
2546
- */
2547
- getTools(userId, filters, modifiers) {
2548
- return this.tools.get(userId, filters, modifiers);
2549
- }
2550
- /**
2551
- * Fetch a tool from Composio by its slug.
2552
- * @param {string} slug slug of the tool
2553
- * @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
2554
- * @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
2555
- */
2556
- getToolBySlug(userId, slug, modifiers) {
2557
- return this.tools.get(userId, slug, modifiers);
2558
- }
2559
3371
  };
2560
3372
 
2561
3373
  // src/provider/ComposioProvider.ts
@@ -2570,8 +3382,15 @@ var ComposioProvider = class extends BaseNonAgenticProvider {
2570
3382
  };
2571
3383
 
2572
3384
  // src/telemetry/TelemetryTransport.ts
3385
+ import chalk4 from "chalk";
2573
3386
  var BaseTelemetryTransport = class {
2574
3387
  };
3388
+ var ConsoleTelemetryTransport = class {
3389
+ send(payload) {
3390
+ logger_default.debug(chalk4.yellow("telemetry"), JSON.stringify(payload, null, 2));
3391
+ return Promise.resolve();
3392
+ }
3393
+ };
2575
3394
 
2576
3395
  // src/utils/jsonSchema.ts
2577
3396
  import { z as z5 } from "zod";
@@ -2682,14 +3501,38 @@ Examples: ${value.examples.join(", ")}` : "")
2682
3501
  return z5.object(zodSchema);
2683
3502
  }
2684
3503
  export {
3504
+ AuthConfigErrorCodes,
2685
3505
  AuthConfigTypes,
2686
3506
  AuthSchemeTypes,
2687
3507
  BaseAgenticProvider,
2688
3508
  BaseNonAgenticProvider,
2689
3509
  BaseTelemetryTransport,
2690
3510
  Composio,
3511
+ ComposioAuthConfigNotFoundError,
3512
+ ComposioConnectedAccountNotFoundError,
3513
+ ComposioCustomToolsNotInitializedError,
3514
+ ComposioError,
3515
+ ComposioGlobalExecuteToolFnNotSetError,
3516
+ ComposioInvalidExecuteFunctionError,
3517
+ ComposioInvalidModifierError,
3518
+ ComposioNoAPIKeyError,
2691
3519
  ComposioProvider,
3520
+ ComposioProviderNotDefinedError,
3521
+ ComposioToolExecutionError,
3522
+ ComposioToolNotFoundError,
3523
+ ComposioToolkitFetchError,
3524
+ ComposioToolkitNotFoundError,
3525
+ ConnectedAccountErrorCodes,
3526
+ ConnectionRequestErrorCodes,
3527
+ ConnectionRequestFailedError,
3528
+ ConnectionRequestTimeoutError,
3529
+ ConsoleTelemetryTransport,
2692
3530
  OpenAIProvider,
3531
+ SDKErrorCodes,
3532
+ ToolErrorCodes,
2693
3533
  ToolListParamsSchema,
3534
+ ToolkitErrorCodes,
3535
+ ValidationError,
3536
+ ValidationErrorCodes,
2694
3537
  jsonSchemaToModel
2695
3538
  };