@composio/core 0.1.36-next.8 → 0.1.36

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
@@ -14,13 +14,603 @@ var __export = (target, all) => {
14
14
  import ComposioClient4 from "@composio/client";
15
15
 
16
16
  // src/types/tool.types.ts
17
+ import { z as z3 } from "zod";
18
+
19
+ // src/types/connectedAccountAuthStates.types.ts
20
+ import { z as z2 } from "zod";
21
+
22
+ // src/types/authConfigs.types.ts
17
23
  import { z } from "zod";
18
- var ToolkitSchema = z.object({
19
- slug: z.string().describe("The slug of the toolkit"),
20
- name: z.string().describe("The name of the toolkit"),
21
- logo: z.string().describe("The logo of the toolkit").optional()
24
+ var AuthConfigTypes = {
25
+ CUSTOM: "use_custom_auth",
26
+ COMPOSIO_MANAGED: "use_composio_managed_auth"
27
+ };
28
+ var AuthSchemeTypes = {
29
+ OAUTH1: "OAUTH1",
30
+ OAUTH2: "OAUTH2",
31
+ API_KEY: "API_KEY",
32
+ BASIC: "BASIC",
33
+ BEARER_TOKEN: "BEARER_TOKEN",
34
+ BILLCOM_AUTH: "BILLCOM_AUTH",
35
+ GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
36
+ NO_AUTH: "NO_AUTH",
37
+ BASIC_WITH_JWT: "BASIC_WITH_JWT",
38
+ COMPOSIO_LINK: "COMPOSIO_LINK",
39
+ CALCOM_AUTH: "CALCOM_AUTH"
40
+ };
41
+ var AuthSchemeEnum = z.enum([
42
+ "OAUTH2",
43
+ "OAUTH1",
44
+ "API_KEY",
45
+ "BASIC",
46
+ "BILLCOM_AUTH",
47
+ "BEARER_TOKEN",
48
+ "GOOGLE_SERVICE_ACCOUNT",
49
+ "NO_AUTH",
50
+ "BASIC_WITH_JWT",
51
+ "COMPOSIO_LINK",
52
+ "CALCOM_AUTH"
53
+ ]);
54
+ var CreateCustomAuthConfigParamsSchema = z.object({
55
+ type: z.literal("use_custom_auth"),
56
+ name: z.string().optional(),
57
+ credentials: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])),
58
+ authScheme: AuthSchemeEnum,
59
+ restrictToFollowingTools: z.array(z.string()).optional()
60
+ });
61
+ var CreateComposioManagedAuthConfigParamsSchema = z.object({
62
+ type: z.literal("use_composio_managed_auth"),
63
+ name: z.string().optional(),
64
+ credentials: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
65
+ restrictToFollowingTools: z.array(z.string()).optional()
66
+ });
67
+ var CreateAuthConfigParamsSchema = z.discriminatedUnion("type", [
68
+ CreateCustomAuthConfigParamsSchema,
69
+ CreateComposioManagedAuthConfigParamsSchema
70
+ ]);
71
+ var CreateAuthConfigResponseSchema = z.object({
72
+ id: z.string(),
73
+ authScheme: z.string(),
74
+ isComposioManaged: z.boolean(),
75
+ toolkit: z.string()
76
+ });
77
+ var AuthConfigRetrieveResponseSchema = z.object({
78
+ id: z.string(),
79
+ name: z.string(),
80
+ toolkit: z.object({
81
+ logo: z.string(),
82
+ slug: z.string()
83
+ }),
84
+ noOfConnections: z.number(),
85
+ status: z.enum(["ENABLED", "DISABLED"]),
86
+ uuid: z.string(),
87
+ authScheme: AuthSchemeEnum.optional(),
88
+ credentials: z.record(z.string(), z.unknown()).optional(),
89
+ expectedInputFields: z.array(z.unknown()).optional(),
90
+ restrictToFollowingTools: z.array(z.string()).optional(),
91
+ isComposioManaged: z.boolean().optional(),
92
+ createdBy: z.string().optional(),
93
+ createdAt: z.string().optional(),
94
+ lastUpdatedAt: z.string().optional()
22
95
  });
23
- var JSONSchemaType = z.enum([
96
+ var AuthConfigListParamsSchema = z.object({
97
+ cursor: z.string().optional(),
98
+ isComposioManaged: z.boolean().optional(),
99
+ limit: z.number().optional(),
100
+ toolkit: z.string().optional()
101
+ });
102
+ var AuthConfigListResponseSchema = z.object({
103
+ items: z.array(AuthConfigRetrieveResponseSchema),
104
+ nextCursor: z.string().nullable(),
105
+ totalPages: z.number()
106
+ });
107
+ var AuthCustomConfigUpdateParamsSchema = z.object({
108
+ credentials: z.record(z.string(), z.union([z.string(), z.unknown()])),
109
+ type: z.literal("custom"),
110
+ restrictToFollowingTools: z.array(z.string()).optional()
111
+ });
112
+ var AuthDefaultConfigUpdateParamsSchema = z.object({
113
+ scopes: z.string(),
114
+ type: z.literal("default"),
115
+ restrictToFollowingTools: z.array(z.string()).optional()
116
+ });
117
+ var AuthConfigUpdateParamsSchema = z.discriminatedUnion("type", [
118
+ AuthCustomConfigUpdateParamsSchema,
119
+ AuthDefaultConfigUpdateParamsSchema
120
+ ]);
121
+
122
+ // src/types/connectedAccountAuthStates.types.ts
123
+ var ConnectionStatuses = {
124
+ INITIALIZING: "INITIALIZING",
125
+ INITIATED: "INITIATED",
126
+ ACTIVE: "ACTIVE",
127
+ FAILED: "FAILED",
128
+ EXPIRED: "EXPIRED",
129
+ INACTIVE: "INACTIVE"
130
+ };
131
+ var RedirectableAuthSchemeSchema = z2.enum([
132
+ AuthSchemeTypes.OAUTH1,
133
+ AuthSchemeTypes.OAUTH2,
134
+ AuthSchemeTypes.COMPOSIO_LINK
135
+ ]);
136
+ var BaseSchemeRaw = z2.object({
137
+ // for posthog, freshdesk, zendesk, clickup and others
138
+ subdomain: z2.string().optional(),
139
+ // for atlassian
140
+ ["your-domain"]: z2.string().optional(),
141
+ // for mixpanel
142
+ region: z2.string().optional(),
143
+ // for shopify
144
+ shop: z2.string().optional(),
145
+ // for snowflake
146
+ account_url: z2.string().optional(),
147
+ // likely pipedrive
148
+ COMPANYDOMAIN: z2.string().optional(),
149
+ // likely zoho
150
+ extension: z2.string().optional(),
151
+ // likely formsite
152
+ form_api_base_url: z2.string().optional(),
153
+ // likely salesforce
154
+ instanceEndpoint: z2.string().optional(),
155
+ // likely active campaign
156
+ api_url: z2.string().optional(),
157
+ // for borneo
158
+ borneo_dashboard_url: z2.string().optional(),
159
+ // for zenrows proxy
160
+ proxy_username: z2.string().optional(),
161
+ proxy_password: z2.string().optional(),
162
+ // for d2l
163
+ domain: z2.string().optional(),
164
+ version: z2.string().optional(),
165
+ // for mailchimp
166
+ dc: z2.string().optional(),
167
+ // for sharepoint
168
+ site_name: z2.string().optional(),
169
+ // for servicenow
170
+ instanceName: z2.string().optional(),
171
+ // for netsuite
172
+ account_id: z2.string().optional(),
173
+ // for custom servers
174
+ your_server: z2.string().optional(),
175
+ // for ragic
176
+ server_location: z2.string().optional(),
177
+ // base_url only
178
+ base_url: z2.string().optional(),
179
+ // for api key
180
+ api_key: z2.string().optional(),
181
+ // for generic api key
182
+ generic_api_key: z2.string().optional()
183
+ }).catchall(z2.unknown());
184
+ var Oauth2InitiatingConnectionDataSchema = BaseSchemeRaw.extend({
185
+ status: z2.literal(ConnectionStatuses.INITIALIZING)
186
+ }).catchall(z2.unknown());
187
+ var Oauth2InitiatedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
188
+ status: z2.literal(ConnectionStatuses.INITIATED),
189
+ code_verifier: z2.string().optional(),
190
+ redirectUrl: z2.string(),
191
+ callback_url: z2.string().optional(),
192
+ finalRedirectUri: z2.string().optional(),
193
+ // previously verification_token, will be sent as verification_token to slack
194
+ webhook_signature: z2.string().optional()
195
+ }).catchall(z2.unknown());
196
+ var Oauth2ActiveConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
197
+ status: z2.literal(ConnectionStatuses.ACTIVE),
198
+ access_token: z2.string().optional(),
199
+ id_token: z2.string().optional(),
200
+ token_type: z2.string().optional(),
201
+ refresh_token: z2.string().nullish(),
202
+ expires_in: z2.union([z2.string(), z2.number(), z2.null()]).optional(),
203
+ scope: z2.union([z2.string(), z2.array(z2.string())]).optional(),
204
+ // previously verification_token, will be sent as verification_token to slack
205
+ webhook_signature: z2.string().optional(),
206
+ authed_user: z2.object({
207
+ access_token: z2.string().optional(),
208
+ scope: z2.string().optional()
209
+ }).optional().describe("for slack user scopes")
210
+ }).catchall(z2.unknown());
211
+ var Oauth2FailedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
212
+ status: z2.literal(ConnectionStatuses.FAILED),
213
+ error: z2.string().optional(),
214
+ error_description: z2.string().optional()
215
+ }).catchall(z2.unknown());
216
+ var Oauth2ExpiredConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
217
+ status: z2.literal(ConnectionStatuses.EXPIRED),
218
+ expired_at: z2.string().optional()
219
+ }).catchall(z2.unknown());
220
+ var Oauth2InactiveConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
221
+ status: z2.literal(ConnectionStatuses.INACTIVE)
222
+ }).catchall(z2.unknown());
223
+ var Oauth2ConnectionDataSchema = z2.discriminatedUnion("status", [
224
+ Oauth2InitiatingConnectionDataSchema,
225
+ Oauth2InitiatedConnectionDataSchema,
226
+ Oauth2ActiveConnectionDataSchema,
227
+ Oauth2FailedConnectionDataSchema,
228
+ Oauth2ExpiredConnectionDataSchema,
229
+ Oauth2InactiveConnectionDataSchema
230
+ ]);
231
+ var CustomOauth2ConnectionDataSchema = Oauth2ActiveConnectionDataSchema.omit({
232
+ status: true,
233
+ access_token: true
234
+ }).extend({
235
+ access_token: z2.string()
236
+ });
237
+ var Oauth1InitiatingConnectionDataSchema = BaseSchemeRaw.extend({
238
+ status: z2.literal(ConnectionStatuses.INITIALIZING)
239
+ }).catchall(z2.unknown());
240
+ var Oauth1InitiatedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
241
+ status: z2.literal(ConnectionStatuses.INITIATED),
242
+ oauth_token: z2.string().optional(),
243
+ authUri: z2.string().optional(),
244
+ oauth_token_secret: z2.string().optional(),
245
+ redirectUrl: z2.string().optional(),
246
+ callbackUrl: z2.string().optional()
247
+ }).catchall(z2.unknown());
248
+ var Oauth1ActiveConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
249
+ status: z2.literal(ConnectionStatuses.ACTIVE),
250
+ oauth_token: z2.string().optional(),
251
+ consumer_key: z2.string().optional(),
252
+ redirectUrl: z2.string().optional(),
253
+ callback_url: z2.string().optional()
254
+ }).catchall(z2.unknown());
255
+ var Oauth1FailedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
256
+ status: z2.literal(ConnectionStatuses.FAILED),
257
+ error: z2.string().optional(),
258
+ error_description: z2.string().optional()
259
+ }).catchall(z2.unknown());
260
+ var Oauth1ExpiredConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
261
+ status: z2.literal(ConnectionStatuses.EXPIRED),
262
+ expired_at: z2.string().optional()
263
+ }).catchall(z2.unknown());
264
+ var Oauth1InactiveConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
265
+ status: z2.literal(ConnectionStatuses.INACTIVE)
266
+ }).catchall(z2.unknown());
267
+ var Oauth1ConnectionDataSchema = z2.discriminatedUnion("status", [
268
+ Oauth1InitiatingConnectionDataSchema,
269
+ Oauth1InitiatedConnectionDataSchema,
270
+ Oauth1ActiveConnectionDataSchema,
271
+ Oauth1FailedConnectionDataSchema,
272
+ Oauth1ExpiredConnectionDataSchema,
273
+ Oauth1InactiveConnectionDataSchema
274
+ ]);
275
+ var CustomOauth1ConnectionDataSchema = Oauth1ActiveConnectionDataSchema.omit({
276
+ status: true,
277
+ oauth_token: true
278
+ }).extend({
279
+ oauth_token_secret: z2.string(),
280
+ oauth_token: z2.string()
281
+ });
282
+ var ComposioLinkInitiatingSchema = BaseSchemeRaw.extend({
283
+ status: z2.literal(ConnectionStatuses.INITIALIZING)
284
+ }).catchall(z2.unknown());
285
+ var ComposioLinkConnectionDataSchema = z2.discriminatedUnion("status", [
286
+ ComposioLinkInitiatingSchema,
287
+ ComposioLinkInitiatingSchema.extend({
288
+ status: z2.literal(ConnectionStatuses.INITIATED),
289
+ redirectUrl: z2.string()
290
+ }).catchall(z2.unknown()),
291
+ ComposioLinkInitiatingSchema.extend({
292
+ status: z2.literal(ConnectionStatuses.ACTIVE)
293
+ }).catchall(z2.unknown()),
294
+ ComposioLinkInitiatingSchema.extend({
295
+ status: z2.literal(ConnectionStatuses.FAILED),
296
+ error: z2.string().optional(),
297
+ error_description: z2.string().optional()
298
+ }).catchall(z2.unknown()),
299
+ ComposioLinkInitiatingSchema.extend({
300
+ status: z2.literal(ConnectionStatuses.EXPIRED),
301
+ expired_at: z2.string().optional()
302
+ }).catchall(z2.unknown()),
303
+ ComposioLinkInitiatingSchema.extend({
304
+ status: z2.literal(ConnectionStatuses.INACTIVE)
305
+ }).catchall(z2.unknown())
306
+ ]);
307
+ var BillcomAuthInitiatingSchema = BaseSchemeRaw.extend({
308
+ status: z2.literal(ConnectionStatuses.INITIALIZING)
309
+ }).catchall(z2.unknown());
310
+ var BillcomAuthConnectionDataSchema = z2.discriminatedUnion("status", [
311
+ BillcomAuthInitiatingSchema,
312
+ BillcomAuthInitiatingSchema.extend({
313
+ status: z2.literal(ConnectionStatuses.INITIATED),
314
+ redirectUrl: z2.string()
315
+ }).catchall(z2.unknown()),
316
+ BillcomAuthInitiatingSchema.extend({
317
+ status: z2.literal(ConnectionStatuses.ACTIVE),
318
+ sessionId: z2.string(),
319
+ devKey: z2.string()
320
+ }).catchall(z2.unknown()),
321
+ BillcomAuthInitiatingSchema.extend({
322
+ status: z2.literal(ConnectionStatuses.FAILED),
323
+ error: z2.string().optional(),
324
+ error_description: z2.string().optional()
325
+ }).catchall(z2.unknown()),
326
+ BillcomAuthInitiatingSchema.extend({
327
+ status: z2.literal(ConnectionStatuses.EXPIRED),
328
+ expired_at: z2.string().optional()
329
+ }).catchall(z2.unknown()),
330
+ BillcomAuthInitiatingSchema.extend({
331
+ status: z2.literal(ConnectionStatuses.INACTIVE)
332
+ }).catchall(z2.unknown())
333
+ ]);
334
+ var BasicInitiatingSchema = BaseSchemeRaw.extend({
335
+ status: z2.literal(ConnectionStatuses.ACTIVE),
336
+ username: z2.string(),
337
+ password: z2.string()
338
+ }).catchall(z2.unknown());
339
+ var BasicConnectionDataSchema = z2.discriminatedUnion("status", [
340
+ BasicInitiatingSchema,
341
+ BasicInitiatingSchema.extend({
342
+ status: z2.literal(ConnectionStatuses.INACTIVE)
343
+ }).catchall(z2.unknown()),
344
+ BasicInitiatingSchema.extend({
345
+ status: z2.literal(ConnectionStatuses.FAILED),
346
+ error: z2.string().optional(),
347
+ error_description: z2.string().optional()
348
+ }).catchall(z2.unknown()),
349
+ BasicInitiatingSchema.extend({
350
+ status: z2.literal(ConnectionStatuses.EXPIRED),
351
+ expired_at: z2.string().optional()
352
+ }).catchall(z2.unknown())
353
+ ]);
354
+ var CustomBasicConnectionDataSchema = BasicInitiatingSchema.omit({
355
+ status: true
356
+ });
357
+ var ApiKeyInitiatingSchema = BaseSchemeRaw.extend({
358
+ status: z2.literal(ConnectionStatuses.ACTIVE),
359
+ api_key: z2.string().optional(),
360
+ generic_api_key: z2.string().optional()
361
+ }).catchall(z2.unknown());
362
+ var ApiKeyConnectionDataSchema = z2.discriminatedUnion("status", [
363
+ ApiKeyInitiatingSchema,
364
+ ApiKeyInitiatingSchema.extend({
365
+ status: z2.literal(ConnectionStatuses.INACTIVE)
366
+ }).catchall(z2.unknown()),
367
+ ApiKeyInitiatingSchema.extend({
368
+ status: z2.literal(ConnectionStatuses.FAILED),
369
+ error: z2.string().optional(),
370
+ error_description: z2.string().optional()
371
+ }).catchall(z2.unknown()),
372
+ ApiKeyInitiatingSchema.extend({
373
+ status: z2.literal(ConnectionStatuses.EXPIRED),
374
+ expired_at: z2.string().optional()
375
+ }).catchall(z2.unknown())
376
+ ]);
377
+ var CustomApiKeyConnectionDataSchema = ApiKeyInitiatingSchema.omit({
378
+ status: true
379
+ });
380
+ var BearerTokenInitiatingSchema = BaseSchemeRaw.extend({
381
+ status: z2.literal(ConnectionStatuses.ACTIVE),
382
+ token: z2.string()
383
+ }).catchall(z2.unknown());
384
+ var BearerTokenConnectionDataSchema = z2.discriminatedUnion("status", [
385
+ BearerTokenInitiatingSchema,
386
+ BearerTokenInitiatingSchema.extend({
387
+ status: z2.literal(ConnectionStatuses.INACTIVE)
388
+ }).catchall(z2.unknown()),
389
+ BearerTokenInitiatingSchema.extend({
390
+ status: z2.literal(ConnectionStatuses.FAILED),
391
+ error: z2.string().optional(),
392
+ error_description: z2.string().optional()
393
+ }).catchall(z2.unknown()),
394
+ BearerTokenInitiatingSchema.extend({
395
+ status: z2.literal(ConnectionStatuses.EXPIRED),
396
+ expired_at: z2.string().optional()
397
+ }).catchall(z2.unknown())
398
+ ]);
399
+ var CustomBearerTokenConnectionDataSchema = BearerTokenInitiatingSchema.omit({
400
+ status: true
401
+ });
402
+ var GoogleServiceAccountInitiatingSchema = BaseSchemeRaw.extend({
403
+ status: z2.literal(ConnectionStatuses.ACTIVE),
404
+ credentials_json: z2.string()
405
+ }).catchall(z2.unknown());
406
+ var GoogleServiceAccountConnectionDataSchema = z2.discriminatedUnion("status", [
407
+ GoogleServiceAccountInitiatingSchema,
408
+ GoogleServiceAccountInitiatingSchema.extend({
409
+ status: z2.literal(ConnectionStatuses.INACTIVE)
410
+ }).catchall(z2.unknown()),
411
+ GoogleServiceAccountInitiatingSchema.extend({
412
+ status: z2.literal(ConnectionStatuses.FAILED),
413
+ error: z2.string().optional(),
414
+ error_description: z2.string().optional()
415
+ }).catchall(z2.unknown()),
416
+ GoogleServiceAccountInitiatingSchema.extend({
417
+ status: z2.literal(ConnectionStatuses.EXPIRED),
418
+ expired_at: z2.string().optional()
419
+ }).catchall(z2.unknown())
420
+ ]);
421
+ var NoAuthInitiatingSchema = BaseSchemeRaw.extend({
422
+ status: z2.literal(ConnectionStatuses.ACTIVE)
423
+ }).catchall(z2.unknown());
424
+ var NoAuthConnectionDataSchema = z2.discriminatedUnion("status", [
425
+ NoAuthInitiatingSchema,
426
+ NoAuthInitiatingSchema.extend({
427
+ status: z2.literal(ConnectionStatuses.INACTIVE)
428
+ }).catchall(z2.unknown()),
429
+ NoAuthInitiatingSchema.extend({
430
+ status: z2.literal(ConnectionStatuses.FAILED),
431
+ error: z2.string().optional(),
432
+ error_description: z2.string().optional()
433
+ }).catchall(z2.unknown()),
434
+ NoAuthInitiatingSchema.extend({
435
+ status: z2.literal(ConnectionStatuses.EXPIRED),
436
+ expired_at: z2.string().optional()
437
+ }).catchall(z2.unknown())
438
+ ]);
439
+ var CustomNoAuthConnectionDataSchema = NoAuthInitiatingSchema.omit({
440
+ status: true
441
+ });
442
+ var CalcomAuthInitiatingSchema = BaseSchemeRaw.extend({
443
+ status: z2.literal(ConnectionStatuses.ACTIVE)
444
+ }).catchall(z2.unknown());
445
+ var CalcomAuthConnectionDataSchema = z2.discriminatedUnion("status", [
446
+ CalcomAuthInitiatingSchema,
447
+ CalcomAuthInitiatingSchema.extend({
448
+ status: z2.literal(ConnectionStatuses.INACTIVE)
449
+ }).catchall(z2.unknown()),
450
+ CalcomAuthInitiatingSchema.extend({
451
+ status: z2.literal(ConnectionStatuses.FAILED),
452
+ error: z2.string().optional(),
453
+ error_description: z2.string().optional()
454
+ }).catchall(z2.unknown()),
455
+ CalcomAuthInitiatingSchema.extend({
456
+ status: z2.literal(ConnectionStatuses.EXPIRED),
457
+ expired_at: z2.string().optional()
458
+ }).catchall(z2.unknown())
459
+ ]);
460
+ var BasicWithJwtInitiatingSchema = BaseSchemeRaw.extend({
461
+ status: z2.literal(ConnectionStatuses.ACTIVE),
462
+ username: z2.string(),
463
+ password: z2.string()
464
+ }).catchall(z2.unknown());
465
+ var BasicWithJwtConnectionDataSchema = z2.discriminatedUnion("status", [
466
+ BasicWithJwtInitiatingSchema,
467
+ BasicWithJwtInitiatingSchema.extend({
468
+ status: z2.literal(ConnectionStatuses.INACTIVE)
469
+ }).catchall(z2.unknown()),
470
+ BasicWithJwtInitiatingSchema.extend({
471
+ status: z2.literal(ConnectionStatuses.FAILED),
472
+ error: z2.string().optional(),
473
+ error_description: z2.string().optional()
474
+ }).catchall(z2.unknown()),
475
+ BasicWithJwtInitiatingSchema.extend({
476
+ status: z2.literal(ConnectionStatuses.EXPIRED),
477
+ expired_at: z2.string().optional()
478
+ }).catchall(z2.unknown())
479
+ ]);
480
+ var CustomBasicWithJwtConnectionDataSchema = BasicWithJwtInitiatingSchema.omit({
481
+ status: true
482
+ });
483
+ var ConnectionDataSchema = z2.discriminatedUnion("authScheme", [
484
+ z2.object({
485
+ authScheme: z2.literal(AuthSchemeTypes.OAUTH1),
486
+ /**
487
+ * the main connection data discriminated by auth scheme
488
+ */
489
+ val: Oauth1ConnectionDataSchema
490
+ }),
491
+ z2.object({
492
+ authScheme: z2.literal(AuthSchemeTypes.OAUTH2),
493
+ /**
494
+ * the main connection data discriminated by auth scheme
495
+ */
496
+ val: Oauth2ConnectionDataSchema
497
+ }),
498
+ z2.object({
499
+ authScheme: z2.literal(AuthSchemeTypes.COMPOSIO_LINK),
500
+ /**
501
+ * the main connection data discriminated by auth scheme
502
+ */
503
+ val: ComposioLinkConnectionDataSchema
504
+ }),
505
+ z2.object({
506
+ authScheme: z2.literal(AuthSchemeTypes.API_KEY),
507
+ /**
508
+ * the main connection data discriminated by auth scheme
509
+ */
510
+ val: ApiKeyConnectionDataSchema
511
+ }),
512
+ z2.object({
513
+ authScheme: z2.literal(AuthSchemeTypes.BASIC),
514
+ /**
515
+ * the main connection data discriminated by auth scheme
516
+ */
517
+ val: BasicConnectionDataSchema
518
+ }),
519
+ z2.object({
520
+ authScheme: z2.literal(AuthSchemeTypes.BEARER_TOKEN),
521
+ /**
522
+ * the main connection data discriminated by auth scheme
523
+ */
524
+ val: BearerTokenConnectionDataSchema
525
+ }),
526
+ z2.object({
527
+ authScheme: z2.literal(AuthSchemeTypes.GOOGLE_SERVICE_ACCOUNT),
528
+ /**
529
+ * the main connection data discriminated by auth scheme
530
+ */
531
+ val: GoogleServiceAccountConnectionDataSchema
532
+ }),
533
+ z2.object({
534
+ authScheme: z2.literal(AuthSchemeTypes.NO_AUTH),
535
+ /**
536
+ * the main connection data discriminated by auth scheme
537
+ */
538
+ val: NoAuthConnectionDataSchema
539
+ }),
540
+ z2.object({
541
+ authScheme: z2.literal(AuthSchemeTypes.CALCOM_AUTH),
542
+ /**
543
+ * the main connection data discriminated by auth scheme
544
+ */
545
+ val: CalcomAuthConnectionDataSchema
546
+ }),
547
+ // z.object({
548
+ // authScheme: z.literal(AuthSchemeTypes.SNOWFLAKE),
549
+ // /**
550
+ // * the main connection data discriminated by auth scheme
551
+ // */
552
+ // val: SnowflakeConnectionDataSchema,
553
+ // }),
554
+ z2.object({
555
+ authScheme: z2.literal(AuthSchemeTypes.BILLCOM_AUTH),
556
+ /**
557
+ * the main connection data discriminated by auth scheme
558
+ */
559
+ val: BillcomAuthConnectionDataSchema
560
+ }),
561
+ z2.object({
562
+ authScheme: z2.literal(AuthSchemeTypes.BASIC_WITH_JWT),
563
+ /**
564
+ * the main connection data discriminated by auth scheme
565
+ */
566
+ val: BasicWithJwtConnectionDataSchema
567
+ })
568
+ ]);
569
+ var CustomConnectionDataSchema = z2.discriminatedUnion("authScheme", [
570
+ z2.object({
571
+ authScheme: z2.literal(AuthSchemeTypes.OAUTH2),
572
+ toolkitSlug: z2.string(),
573
+ val: CustomOauth2ConnectionDataSchema
574
+ }),
575
+ z2.object({
576
+ authScheme: z2.literal(AuthSchemeTypes.API_KEY),
577
+ toolkitSlug: z2.string(),
578
+ val: CustomApiKeyConnectionDataSchema
579
+ }),
580
+ z2.object({
581
+ authScheme: z2.literal(AuthSchemeTypes.BASIC_WITH_JWT),
582
+ toolkitSlug: z2.string(),
583
+ val: CustomBasicWithJwtConnectionDataSchema
584
+ }),
585
+ z2.object({
586
+ authScheme: z2.literal(AuthSchemeTypes.BASIC),
587
+ toolkitSlug: z2.string(),
588
+ val: CustomBasicConnectionDataSchema
589
+ }),
590
+ z2.object({
591
+ authScheme: z2.literal(AuthSchemeTypes.BEARER_TOKEN),
592
+ toolkitSlug: z2.string(),
593
+ val: CustomBearerTokenConnectionDataSchema
594
+ }),
595
+ z2.object({
596
+ authScheme: z2.literal(AuthSchemeTypes.OAUTH1),
597
+ toolkitSlug: z2.string(),
598
+ val: CustomOauth1ConnectionDataSchema
599
+ }),
600
+ z2.object({
601
+ authScheme: z2.literal(AuthSchemeTypes.NO_AUTH),
602
+ toolkitSlug: z2.string(),
603
+ val: CustomNoAuthConnectionDataSchema
604
+ })
605
+ ]);
606
+
607
+ // src/types/tool.types.ts
608
+ var ToolkitSchema = z3.object({
609
+ slug: z3.string().describe("The slug of the toolkit"),
610
+ name: z3.string().describe("The name of the toolkit"),
611
+ logo: z3.string().describe("The logo of the toolkit").optional()
612
+ });
613
+ var JSONSchemaType = z3.enum([
24
614
  "string",
25
615
  "number",
26
616
  "integer",
@@ -29,133 +619,135 @@ var JSONSchemaType = z.enum([
29
619
  "array",
30
620
  "null"
31
621
  ]);
32
- var JSONSchemaPropertySchema = z.object({
33
- type: z.union([JSONSchemaType, z.array(JSONSchemaType)]).optional(),
34
- description: z.string().optional(),
35
- anyOf: z.lazy(() => z.array(JSONSchemaPropertySchema)).optional(),
36
- oneOf: z.lazy(() => z.array(JSONSchemaPropertySchema)).optional(),
37
- allOf: z.lazy(() => z.array(JSONSchemaPropertySchema)).optional(),
38
- not: z.lazy(() => JSONSchemaPropertySchema).optional(),
39
- title: z.string().optional(),
40
- default: z.any().optional(),
41
- nullable: z.boolean().optional(),
42
- properties: z.lazy(() => z.record(z.string(), JSONSchemaPropertySchema)).optional(),
43
- required: z.array(z.string()).optional(),
44
- file_uploadable: z.boolean().optional(),
45
- file_downloadable: z.boolean().optional(),
46
- items: z.lazy(() => z.union([JSONSchemaPropertySchema, z.array(JSONSchemaPropertySchema)])).optional(),
47
- enum: z.array(z.any()).optional(),
48
- const: z.any().optional(),
49
- minimum: z.number().optional(),
50
- maximum: z.number().optional(),
51
- exclusiveMinimum: z.number().optional(),
52
- exclusiveMaximum: z.number().optional(),
53
- multipleOf: z.number().optional(),
54
- minLength: z.number().optional(),
55
- maxLength: z.number().optional(),
56
- pattern: z.string().optional(),
57
- format: z.string().optional(),
58
- minItems: z.number().optional(),
59
- maxItems: z.number().optional(),
60
- uniqueItems: z.boolean().optional(),
61
- minProperties: z.number().optional(),
62
- maxProperties: z.number().optional(),
63
- patternProperties: z.lazy(() => z.record(z.string(), JSONSchemaPropertySchema)).optional(),
64
- additionalProperties: z.union([z.boolean(), z.lazy(() => JSONSchemaPropertySchema)]).optional(),
65
- examples: z.array(z.any()).optional(),
66
- readOnly: z.boolean().optional(),
67
- writeOnly: z.boolean().optional(),
68
- if: z.lazy(() => JSONSchemaPropertySchema).optional(),
69
- then: z.lazy(() => JSONSchemaPropertySchema).optional(),
70
- else: z.lazy(() => JSONSchemaPropertySchema).optional(),
71
- $ref: z.string().optional(),
72
- definitions: z.record(
73
- z.string(),
74
- z.lazy(() => JSONSchemaPropertySchema)
622
+ var JSONSchemaPropertySchema = z3.object({
623
+ type: z3.union([JSONSchemaType, z3.array(JSONSchemaType)]).optional(),
624
+ description: z3.string().optional(),
625
+ anyOf: z3.lazy(() => z3.array(JSONSchemaPropertySchema)).optional(),
626
+ oneOf: z3.lazy(() => z3.array(JSONSchemaPropertySchema)).optional(),
627
+ allOf: z3.lazy(() => z3.array(JSONSchemaPropertySchema)).optional(),
628
+ not: z3.lazy(() => JSONSchemaPropertySchema).optional(),
629
+ title: z3.string().optional(),
630
+ default: z3.any().optional(),
631
+ nullable: z3.boolean().optional(),
632
+ properties: z3.lazy(() => z3.record(z3.string(), JSONSchemaPropertySchema)).optional(),
633
+ required: z3.array(z3.string()).optional(),
634
+ file_uploadable: z3.boolean().optional(),
635
+ file_downloadable: z3.boolean().optional(),
636
+ items: z3.lazy(() => z3.union([JSONSchemaPropertySchema, z3.array(JSONSchemaPropertySchema)])).optional(),
637
+ enum: z3.array(z3.any()).optional(),
638
+ const: z3.any().optional(),
639
+ minimum: z3.number().optional(),
640
+ maximum: z3.number().optional(),
641
+ exclusiveMinimum: z3.number().optional(),
642
+ exclusiveMaximum: z3.number().optional(),
643
+ multipleOf: z3.number().optional(),
644
+ minLength: z3.number().optional(),
645
+ maxLength: z3.number().optional(),
646
+ pattern: z3.string().optional(),
647
+ format: z3.string().optional(),
648
+ minItems: z3.number().optional(),
649
+ maxItems: z3.number().optional(),
650
+ uniqueItems: z3.boolean().optional(),
651
+ minProperties: z3.number().optional(),
652
+ maxProperties: z3.number().optional(),
653
+ patternProperties: z3.lazy(() => z3.record(z3.string(), JSONSchemaPropertySchema)).optional(),
654
+ additionalProperties: z3.union([z3.boolean(), z3.lazy(() => JSONSchemaPropertySchema)]).optional(),
655
+ examples: z3.array(z3.any()).optional(),
656
+ readOnly: z3.boolean().optional(),
657
+ writeOnly: z3.boolean().optional(),
658
+ if: z3.lazy(() => JSONSchemaPropertySchema).optional(),
659
+ then: z3.lazy(() => JSONSchemaPropertySchema).optional(),
660
+ else: z3.lazy(() => JSONSchemaPropertySchema).optional(),
661
+ $ref: z3.string().optional(),
662
+ definitions: z3.record(
663
+ z3.string(),
664
+ z3.lazy(() => JSONSchemaPropertySchema)
75
665
  ).optional(),
76
- $defs: z.record(
77
- z.string(),
78
- z.lazy(() => JSONSchemaPropertySchema)
666
+ $defs: z3.record(
667
+ z3.string(),
668
+ z3.lazy(() => JSONSchemaPropertySchema)
79
669
  ).optional()
80
670
  });
81
- var ParametersSchema = z.object({
82
- type: z.literal("object"),
83
- anyOf: z.array(JSONSchemaPropertySchema).optional(),
84
- oneOf: z.array(JSONSchemaPropertySchema).optional(),
85
- allOf: z.array(JSONSchemaPropertySchema).optional(),
671
+ var ParametersSchema = z3.object({
672
+ type: z3.literal("object"),
673
+ anyOf: z3.array(JSONSchemaPropertySchema).optional(),
674
+ oneOf: z3.array(JSONSchemaPropertySchema).optional(),
675
+ allOf: z3.array(JSONSchemaPropertySchema).optional(),
86
676
  not: JSONSchemaPropertySchema.optional(),
87
- properties: z.record(z.string(), JSONSchemaPropertySchema),
88
- required: z.array(z.string()).optional(),
89
- title: z.string().optional(),
90
- default: z.any().optional(),
91
- nullable: z.boolean().optional(),
92
- description: z.string().optional(),
93
- additionalProperties: z.boolean().default(false).optional()
677
+ properties: z3.record(z3.string(), JSONSchemaPropertySchema),
678
+ required: z3.array(z3.string()).optional(),
679
+ title: z3.string().optional(),
680
+ default: z3.any().optional(),
681
+ nullable: z3.boolean().optional(),
682
+ description: z3.string().optional(),
683
+ additionalProperties: z3.boolean().default(false).optional()
94
684
  });
95
- var ToolSchema = z.object({
96
- slug: z.string().describe('The slug of the tool. eg. "GOOGLE_SEARCH"'),
97
- name: z.string().describe(`The name of the tool. eg. "Google Search"`),
98
- description: z.string().optional().describe("The description of the tool"),
685
+ var ToolSchema = z3.object({
686
+ slug: z3.string().describe('The slug of the tool. eg. "GOOGLE_SEARCH"'),
687
+ name: z3.string().describe(`The name of the tool. eg. "Google Search"`),
688
+ description: z3.string().optional().describe("The description of the tool"),
99
689
  inputParameters: ParametersSchema.optional().describe("The input parameters of the tool"),
100
690
  outputParameters: ParametersSchema.optional().describe("The output parameters of the tool"),
101
- tags: z.optional(z.array(z.string())).describe("The tags of the tool. eg: Important").default([]),
102
- toolkit: z.optional(ToolkitSchema).describe("The toolkit of the tool"),
103
- version: z.optional(z.string()).describe('The version of the tool, e.g. "1.0.0"'),
104
- scopes: z.optional(z.array(z.string())).describe('The scopes of the tool. eg: ["task:add"]')
691
+ tags: z3.optional(z3.array(z3.string())).describe("The tags of the tool. eg: Important").default([]),
692
+ toolkit: z3.optional(ToolkitSchema).describe("The toolkit of the tool"),
693
+ version: z3.optional(z3.string()).describe('The version of the tool, e.g. "1.0.0"'),
694
+ scopes: z3.optional(z3.array(z3.string())).describe('The scopes of the tool. eg: ["task:add"]')
105
695
  });
106
- var ToolListResponseSchema = z.object({
107
- items: z.array(ToolSchema),
108
- nextCursor: z.string().nullable().optional(),
109
- totalPages: z.number()
696
+ var ToolListResponseSchema = z3.object({
697
+ items: z3.array(ToolSchema),
698
+ nextCursor: z3.string().nullable().optional(),
699
+ totalPages: z3.number()
110
700
  });
111
- var ToolListParamsSchema = z.object({
112
- tools: z.array(z.string()).optional(),
113
- toolkits: z.array(z.string()).optional(),
114
- scopes: z.array(z.string()).optional(),
115
- tags: z.array(z.string()).optional(),
116
- limit: z.number().optional(),
117
- search: z.string().optional(),
118
- authConfigIds: z.array(z.string()).optional()
701
+ var ToolListParamsSchema = z3.object({
702
+ tools: z3.array(z3.string()).optional(),
703
+ toolkits: z3.array(z3.string()).optional(),
704
+ scopes: z3.array(z3.string()).optional(),
705
+ tags: z3.array(z3.string()).optional(),
706
+ limit: z3.number().optional(),
707
+ search: z3.string().optional(),
708
+ authConfigIds: z3.array(z3.string()).optional()
119
709
  });
120
- var CustomAuthParamsSchema = z.object({
121
- baseURL: z.string().optional(),
122
- body: z.record(z.string(), z.unknown()).optional(),
123
- parameters: z.array(
124
- z.object({
125
- in: z.enum(["query", "header"]),
126
- name: z.string(),
127
- value: z.union([z.string(), z.number()])
710
+ var CustomAuthParamsSchema = z3.object({
711
+ baseURL: z3.string().optional(),
712
+ body: z3.record(z3.string(), z3.unknown()).optional(),
713
+ parameters: z3.array(
714
+ z3.object({
715
+ in: z3.enum(["query", "header"]),
716
+ name: z3.string(),
717
+ value: z3.union([z3.string(), z3.number()])
128
718
  })
129
719
  )
130
720
  });
131
- var ToolExecuteParamsSchema = z.object({
132
- allowTracing: z.boolean().optional(),
133
- connectedAccountId: z.string().optional(),
721
+ var ToolExecuteParamsSchema = z3.object({
722
+ allowTracing: z3.boolean().optional(),
723
+ connectedAccountId: z3.string().optional(),
134
724
  customAuthParams: CustomAuthParamsSchema.optional(),
135
- arguments: z.record(z.string(), z.unknown()).optional(),
136
- userId: z.string(),
137
- version: z.string().optional(),
138
- text: z.string().optional()
725
+ customConnectionData: CustomConnectionDataSchema.optional(),
726
+ arguments: z3.record(z3.string(), z3.unknown()).optional(),
727
+ userId: z3.string(),
728
+ version: z3.string().optional(),
729
+ text: z3.string().optional()
139
730
  });
140
- var ToolExecuteResponseSchema = z.object({
141
- data: z.record(z.string(), z.unknown()),
142
- error: z.string().nullable(),
143
- successful: z.boolean(),
144
- logId: z.string().optional(),
145
- sessionInfo: z.unknown().optional()
731
+ var ToolExecuteResponseSchema = z3.object({
732
+ data: z3.record(z3.string(), z3.unknown()),
733
+ error: z3.string().nullable(),
734
+ successful: z3.boolean(),
735
+ logId: z3.string().optional(),
736
+ sessionInfo: z3.unknown().optional()
146
737
  });
147
- var ToolProxyParamsSchema = z.object({
148
- endpoint: z.string(),
149
- method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]),
150
- body: z.unknown().optional(),
151
- parameters: z.array(
152
- z.object({
153
- in: z.enum(["query", "header"]),
154
- name: z.string(),
155
- value: z.union([z.string(), z.number()])
738
+ var ToolProxyParamsSchema = z3.object({
739
+ endpoint: z3.string(),
740
+ method: z3.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]),
741
+ body: z3.unknown().optional(),
742
+ parameters: z3.array(
743
+ z3.object({
744
+ in: z3.enum(["query", "header"]),
745
+ name: z3.string(),
746
+ value: z3.union([z3.string(), z3.number()])
156
747
  })
157
748
  ).optional(),
158
- connectedAccountId: z.string().optional()
749
+ connectedAccountId: z3.string().optional(),
750
+ customConnectionData: CustomConnectionDataSchema.optional()
159
751
  });
160
752
 
161
753
  // src/models/CustomTools.ts
@@ -1064,418 +1656,6 @@ var ComposioNoAPIKeyError = class extends ComposioError {
1064
1656
 
1065
1657
  // src/types/connectedAccounts.types.ts
1066
1658
  import { z as z4 } from "zod";
1067
-
1068
- // src/types/connectedAccountAuthStates.types.ts
1069
- import { z as z3 } from "zod";
1070
-
1071
- // src/types/authConfigs.types.ts
1072
- import { z as z2 } from "zod";
1073
- var AuthConfigTypes = {
1074
- CUSTOM: "use_custom_auth",
1075
- COMPOSIO_MANAGED: "use_composio_managed_auth"
1076
- };
1077
- var AuthSchemeTypes = {
1078
- OAUTH1: "OAUTH1",
1079
- OAUTH2: "OAUTH2",
1080
- API_KEY: "API_KEY",
1081
- BASIC: "BASIC",
1082
- BEARER_TOKEN: "BEARER_TOKEN",
1083
- BILLCOM_AUTH: "BILLCOM_AUTH",
1084
- GOOGLE_SERVICE_ACCOUNT: "GOOGLE_SERVICE_ACCOUNT",
1085
- NO_AUTH: "NO_AUTH",
1086
- BASIC_WITH_JWT: "BASIC_WITH_JWT",
1087
- COMPOSIO_LINK: "COMPOSIO_LINK",
1088
- CALCOM_AUTH: "CALCOM_AUTH"
1089
- };
1090
- var AuthSchemeEnum = z2.enum([
1091
- "OAUTH2",
1092
- "OAUTH1",
1093
- "API_KEY",
1094
- "BASIC",
1095
- "BILLCOM_AUTH",
1096
- "BEARER_TOKEN",
1097
- "GOOGLE_SERVICE_ACCOUNT",
1098
- "NO_AUTH",
1099
- "BASIC_WITH_JWT",
1100
- "COMPOSIO_LINK",
1101
- "CALCOM_AUTH"
1102
- ]);
1103
- var CreateCustomAuthConfigParamsSchema = z2.object({
1104
- type: z2.literal("use_custom_auth"),
1105
- name: z2.string().optional(),
1106
- credentials: z2.record(z2.string(), z2.union([z2.string(), z2.number(), z2.boolean()])),
1107
- authScheme: AuthSchemeEnum,
1108
- restrictToFollowingTools: z2.array(z2.string()).optional()
1109
- });
1110
- var CreateComposioManagedAuthConfigParamsSchema = z2.object({
1111
- type: z2.literal("use_composio_managed_auth"),
1112
- name: z2.string().optional(),
1113
- credentials: z2.record(z2.string(), z2.union([z2.string(), z2.number(), z2.boolean()])).optional(),
1114
- restrictToFollowingTools: z2.array(z2.string()).optional()
1115
- });
1116
- var CreateAuthConfigParamsSchema = z2.discriminatedUnion("type", [
1117
- CreateCustomAuthConfigParamsSchema,
1118
- CreateComposioManagedAuthConfigParamsSchema
1119
- ]);
1120
- var CreateAuthConfigResponseSchema = z2.object({
1121
- id: z2.string(),
1122
- authScheme: z2.string(),
1123
- isComposioManaged: z2.boolean(),
1124
- toolkit: z2.string()
1125
- });
1126
- var AuthConfigRetrieveResponseSchema = z2.object({
1127
- id: z2.string(),
1128
- name: z2.string(),
1129
- toolkit: z2.object({
1130
- logo: z2.string(),
1131
- slug: z2.string()
1132
- }),
1133
- noOfConnections: z2.number(),
1134
- status: z2.enum(["ENABLED", "DISABLED"]),
1135
- uuid: z2.string(),
1136
- authScheme: AuthSchemeEnum.optional(),
1137
- credentials: z2.record(z2.string(), z2.unknown()).optional(),
1138
- expectedInputFields: z2.array(z2.unknown()).optional(),
1139
- restrictToFollowingTools: z2.array(z2.string()).optional(),
1140
- isComposioManaged: z2.boolean().optional(),
1141
- createdBy: z2.string().optional(),
1142
- createdAt: z2.string().optional(),
1143
- lastUpdatedAt: z2.string().optional()
1144
- });
1145
- var AuthConfigListParamsSchema = z2.object({
1146
- cursor: z2.string().optional(),
1147
- isComposioManaged: z2.boolean().optional(),
1148
- limit: z2.number().optional(),
1149
- toolkit: z2.string().optional()
1150
- });
1151
- var AuthConfigListResponseSchema = z2.object({
1152
- items: z2.array(AuthConfigRetrieveResponseSchema),
1153
- nextCursor: z2.string().nullable(),
1154
- totalPages: z2.number()
1155
- });
1156
- var AuthCustomConfigUpdateParamsSchema = z2.object({
1157
- credentials: z2.record(z2.string(), z2.union([z2.string(), z2.unknown()])),
1158
- type: z2.literal("custom"),
1159
- restrictToFollowingTools: z2.array(z2.string()).optional()
1160
- });
1161
- var AuthDefaultConfigUpdateParamsSchema = z2.object({
1162
- scopes: z2.string(),
1163
- type: z2.literal("default"),
1164
- restrictToFollowingTools: z2.array(z2.string()).optional()
1165
- });
1166
- var AuthConfigUpdateParamsSchema = z2.discriminatedUnion("type", [
1167
- AuthCustomConfigUpdateParamsSchema,
1168
- AuthDefaultConfigUpdateParamsSchema
1169
- ]);
1170
-
1171
- // src/types/connectedAccountAuthStates.types.ts
1172
- var ConnectionStatuses = {
1173
- INITIALIZING: "INITIALIZING",
1174
- INITIATED: "INITIATED",
1175
- ACTIVE: "ACTIVE",
1176
- FAILED: "FAILED",
1177
- EXPIRED: "EXPIRED"
1178
- };
1179
- var RedirectableAuthSchemeSchema = z3.enum([
1180
- AuthSchemeTypes.OAUTH1,
1181
- AuthSchemeTypes.OAUTH2,
1182
- AuthSchemeTypes.COMPOSIO_LINK
1183
- ]);
1184
- var BaseSchemeRaw = z3.object({
1185
- // for posthog, freshdesk, zendesk, clickup and others
1186
- subdomain: z3.string().optional(),
1187
- // for atlassian
1188
- ["your-domain"]: z3.string().optional(),
1189
- // for mixpanel
1190
- region: z3.string().optional(),
1191
- // for shopify
1192
- shop: z3.string().optional(),
1193
- // for snowflake
1194
- account_url: z3.string().optional(),
1195
- // likely pipedrive
1196
- COMPANYDOMAIN: z3.string().optional(),
1197
- // likely zoho
1198
- extension: z3.string().optional(),
1199
- // likely formsite
1200
- form_api_base_url: z3.string().optional(),
1201
- // likely salesforce
1202
- instanceEndpoint: z3.string().optional(),
1203
- // likely active campaign
1204
- api_url: z3.string().optional(),
1205
- // for borneo
1206
- borneo_dashboard_url: z3.string().optional(),
1207
- // for zenrows proxy
1208
- proxy_username: z3.string().optional(),
1209
- proxy_password: z3.string().optional(),
1210
- // for d2l
1211
- domain: z3.string().optional(),
1212
- version: z3.string().optional(),
1213
- // for mailchimp
1214
- dc: z3.string().optional(),
1215
- // for sharepoint
1216
- site_name: z3.string().optional(),
1217
- // for servicenow
1218
- instanceName: z3.string().optional(),
1219
- // for netsuite
1220
- account_id: z3.string().optional(),
1221
- // for custom servers
1222
- your_server: z3.string().optional(),
1223
- // for ragic
1224
- server_location: z3.string().optional(),
1225
- // base_url only
1226
- base_url: z3.string().optional(),
1227
- // for api key
1228
- api_key: z3.string().optional(),
1229
- // for generic api key
1230
- generic_api_key: z3.string().optional()
1231
- }).catchall(z3.unknown());
1232
- var Oauth2InitiatingConnectionDataSchema = BaseSchemeRaw.extend({
1233
- status: z3.literal(ConnectionStatuses.INITIALIZING)
1234
- }).catchall(z3.unknown());
1235
- var Oauth2InitiatedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
1236
- status: z3.literal(ConnectionStatuses.INITIATED),
1237
- code_verifier: z3.string().optional(),
1238
- redirectUrl: z3.string(),
1239
- callback_url: z3.string().optional(),
1240
- finalRedirectUri: z3.string().optional(),
1241
- // previously verification_token, will be sent as verification_token to slack
1242
- webhook_signature: z3.string().optional()
1243
- }).catchall(z3.unknown());
1244
- var Oauth2ActiveConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
1245
- status: z3.literal(ConnectionStatuses.ACTIVE),
1246
- access_token: z3.string(),
1247
- id_token: z3.string().optional(),
1248
- token_type: z3.string(),
1249
- refresh_token: z3.string().optional(),
1250
- expires_in: z3.number().optional(),
1251
- scope: z3.string().optional(),
1252
- // previously verification_token, will be sent as verification_token to slack
1253
- webhook_signature: z3.string().optional(),
1254
- authed_user: z3.object({
1255
- access_token: z3.string().optional(),
1256
- scope: z3.string().optional()
1257
- }).optional().describe("for slack user scopes")
1258
- }).catchall(z3.unknown());
1259
- var Oauth2FailedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
1260
- status: z3.literal(ConnectionStatuses.FAILED),
1261
- error: z3.string().optional(),
1262
- error_description: z3.string().optional()
1263
- }).catchall(z3.unknown());
1264
- var Oauth2ExpiredConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
1265
- status: z3.literal(ConnectionStatuses.EXPIRED),
1266
- expired_at: z3.string().optional()
1267
- }).catchall(z3.unknown());
1268
- var Oauth2ConnectionDataSchema = z3.discriminatedUnion("status", [
1269
- Oauth2InitiatingConnectionDataSchema,
1270
- Oauth2InitiatedConnectionDataSchema,
1271
- Oauth2ActiveConnectionDataSchema,
1272
- Oauth2FailedConnectionDataSchema,
1273
- Oauth2ExpiredConnectionDataSchema
1274
- ]);
1275
- var Oauth1InitiatingConnectionDataSchema = BaseSchemeRaw.extend({
1276
- status: z3.literal(ConnectionStatuses.INITIALIZING)
1277
- }).catchall(z3.unknown());
1278
- var Oauth1InitiatedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
1279
- status: z3.literal(ConnectionStatuses.INITIATED),
1280
- oauth_token: z3.string(),
1281
- authUri: z3.string(),
1282
- oauth_token_secret: z3.string(),
1283
- redirectUrl: z3.string(),
1284
- callbackUrl: z3.string().optional()
1285
- }).catchall(z3.unknown());
1286
- var Oauth1ActiveConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
1287
- status: z3.literal(ConnectionStatuses.ACTIVE),
1288
- oauth_token: z3.string(),
1289
- consumer_key: z3.string().optional(),
1290
- redirectUrl: z3.string().optional(),
1291
- callback_url: z3.string().optional()
1292
- }).catchall(z3.unknown());
1293
- var Oauth1FailedConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
1294
- status: z3.literal(ConnectionStatuses.FAILED),
1295
- error: z3.string().optional(),
1296
- error_description: z3.string().optional()
1297
- }).catchall(z3.unknown());
1298
- var Oauth1ExpiredConnectionDataSchema = Oauth1InitiatingConnectionDataSchema.extend({
1299
- status: z3.literal(ConnectionStatuses.EXPIRED),
1300
- expired_at: z3.string().optional()
1301
- }).catchall(z3.unknown());
1302
- var Oauth1ConnectionDataSchema = z3.discriminatedUnion("status", [
1303
- Oauth1InitiatingConnectionDataSchema,
1304
- Oauth1InitiatedConnectionDataSchema,
1305
- Oauth1ActiveConnectionDataSchema,
1306
- Oauth1FailedConnectionDataSchema,
1307
- Oauth1ExpiredConnectionDataSchema
1308
- ]);
1309
- var ComposioLinkInitiatingSchema = BaseSchemeRaw.extend({
1310
- status: z3.literal(ConnectionStatuses.INITIALIZING)
1311
- }).catchall(z3.unknown());
1312
- var ComposioLinkConnectionDataSchema = z3.discriminatedUnion("status", [
1313
- ComposioLinkInitiatingSchema,
1314
- ComposioLinkInitiatingSchema.extend({
1315
- status: z3.literal(ConnectionStatuses.INITIATED),
1316
- redirectUrl: z3.string()
1317
- }).catchall(z3.unknown()),
1318
- ComposioLinkInitiatingSchema.extend({
1319
- status: z3.literal(ConnectionStatuses.ACTIVE)
1320
- }).catchall(z3.unknown()),
1321
- ComposioLinkInitiatingSchema.extend({
1322
- status: z3.literal(ConnectionStatuses.FAILED),
1323
- error: z3.string().optional(),
1324
- error_description: z3.string().optional()
1325
- }).catchall(z3.unknown()),
1326
- ComposioLinkInitiatingSchema.extend({
1327
- status: z3.literal(ConnectionStatuses.EXPIRED),
1328
- expired_at: z3.string().optional()
1329
- }).catchall(z3.unknown())
1330
- ]);
1331
- var BillcomAuthInitiatingSchema = BaseSchemeRaw.extend({
1332
- status: z3.literal(ConnectionStatuses.INITIALIZING)
1333
- }).catchall(z3.unknown());
1334
- var BillcomAuthConnectionDataSchema = z3.discriminatedUnion("status", [
1335
- BillcomAuthInitiatingSchema,
1336
- BillcomAuthInitiatingSchema.extend({
1337
- status: z3.literal(ConnectionStatuses.INITIATED),
1338
- redirectUrl: z3.string()
1339
- }).catchall(z3.unknown()),
1340
- BillcomAuthInitiatingSchema.extend({
1341
- status: z3.literal(ConnectionStatuses.ACTIVE),
1342
- sessionId: z3.string(),
1343
- devKey: z3.string()
1344
- }).catchall(z3.unknown()),
1345
- BillcomAuthInitiatingSchema.extend({
1346
- status: z3.literal(ConnectionStatuses.FAILED),
1347
- error: z3.string().optional(),
1348
- error_description: z3.string().optional()
1349
- }).catchall(z3.unknown()),
1350
- BillcomAuthInitiatingSchema.extend({
1351
- status: z3.literal(ConnectionStatuses.EXPIRED),
1352
- expired_at: z3.string().optional()
1353
- }).catchall(z3.unknown())
1354
- ]);
1355
- var BasicInitiatingSchema = BaseSchemeRaw.extend({
1356
- status: z3.literal(ConnectionStatuses.ACTIVE),
1357
- username: z3.string(),
1358
- password: z3.string()
1359
- }).catchall(z3.unknown());
1360
- var BasicConnectionDataSchema = BasicInitiatingSchema;
1361
- var ApiKeyInitiatingSchema = BaseSchemeRaw.extend({
1362
- status: z3.literal(ConnectionStatuses.ACTIVE),
1363
- api_key: z3.string().optional(),
1364
- generic_api_key: z3.string().optional()
1365
- }).catchall(z3.unknown());
1366
- var ApiKeyConnectionDataSchema = ApiKeyInitiatingSchema;
1367
- var BearerTokenInitiatingSchema = BaseSchemeRaw.extend({
1368
- status: z3.literal(ConnectionStatuses.ACTIVE),
1369
- token: z3.string()
1370
- }).catchall(z3.unknown());
1371
- var BearerTokenConnectionDataSchema = BearerTokenInitiatingSchema;
1372
- var GoogleServiceAccountInitiatingSchema = BaseSchemeRaw.extend({
1373
- status: z3.literal(ConnectionStatuses.ACTIVE),
1374
- credentials_json: z3.string()
1375
- }).catchall(z3.unknown());
1376
- var GoogleServiceAccountConnectionDataSchema = GoogleServiceAccountInitiatingSchema;
1377
- var NoAuthInitiatingSchema = BaseSchemeRaw.extend({
1378
- status: z3.literal(ConnectionStatuses.ACTIVE)
1379
- }).catchall(z3.unknown());
1380
- var NoAuthConnectionDataSchema = NoAuthInitiatingSchema;
1381
- var CalcomAuthInitiatingSchema = BaseSchemeRaw.extend({
1382
- status: z3.literal(ConnectionStatuses.ACTIVE)
1383
- }).catchall(z3.unknown());
1384
- var CalcomAuthConnectionDataSchema = CalcomAuthInitiatingSchema;
1385
- var BasicWithJwtInitiatingSchema = BaseSchemeRaw.extend({
1386
- status: z3.literal(ConnectionStatuses.ACTIVE),
1387
- username: z3.string(),
1388
- password: z3.string()
1389
- }).catchall(z3.unknown());
1390
- var BasicWithJwtConnectionDataSchema = BasicWithJwtInitiatingSchema;
1391
- var ConnectionDataSchema = z3.discriminatedUnion("authScheme", [
1392
- z3.object({
1393
- authScheme: z3.literal(AuthSchemeTypes.OAUTH1),
1394
- /**
1395
- * the main connection data discriminated by auth scheme
1396
- */
1397
- val: Oauth1ConnectionDataSchema
1398
- }),
1399
- z3.object({
1400
- authScheme: z3.literal(AuthSchemeTypes.OAUTH2),
1401
- /**
1402
- * the main connection data discriminated by auth scheme
1403
- */
1404
- val: Oauth2ConnectionDataSchema
1405
- }),
1406
- z3.object({
1407
- authScheme: z3.literal(AuthSchemeTypes.COMPOSIO_LINK),
1408
- /**
1409
- * the main connection data discriminated by auth scheme
1410
- */
1411
- val: ComposioLinkConnectionDataSchema
1412
- }),
1413
- z3.object({
1414
- authScheme: z3.literal(AuthSchemeTypes.API_KEY),
1415
- /**
1416
- * the main connection data discriminated by auth scheme
1417
- */
1418
- val: ApiKeyConnectionDataSchema
1419
- }),
1420
- z3.object({
1421
- authScheme: z3.literal(AuthSchemeTypes.BASIC),
1422
- /**
1423
- * the main connection data discriminated by auth scheme
1424
- */
1425
- val: BasicConnectionDataSchema
1426
- }),
1427
- z3.object({
1428
- authScheme: z3.literal(AuthSchemeTypes.BEARER_TOKEN),
1429
- /**
1430
- * the main connection data discriminated by auth scheme
1431
- */
1432
- val: BearerTokenConnectionDataSchema
1433
- }),
1434
- z3.object({
1435
- authScheme: z3.literal(AuthSchemeTypes.GOOGLE_SERVICE_ACCOUNT),
1436
- /**
1437
- * the main connection data discriminated by auth scheme
1438
- */
1439
- val: GoogleServiceAccountConnectionDataSchema
1440
- }),
1441
- z3.object({
1442
- authScheme: z3.literal(AuthSchemeTypes.NO_AUTH),
1443
- /**
1444
- * the main connection data discriminated by auth scheme
1445
- */
1446
- val: NoAuthConnectionDataSchema
1447
- }),
1448
- z3.object({
1449
- authScheme: z3.literal(AuthSchemeTypes.CALCOM_AUTH),
1450
- /**
1451
- * the main connection data discriminated by auth scheme
1452
- */
1453
- val: CalcomAuthConnectionDataSchema
1454
- }),
1455
- // z.object({
1456
- // authScheme: z.literal(AuthSchemeTypes.SNOWFLAKE),
1457
- // /**
1458
- // * the main connection data discriminated by auth scheme
1459
- // */
1460
- // val: SnowflakeConnectionDataSchema,
1461
- // }),
1462
- z3.object({
1463
- authScheme: z3.literal(AuthSchemeTypes.BILLCOM_AUTH),
1464
- /**
1465
- * the main connection data discriminated by auth scheme
1466
- */
1467
- val: BillcomAuthConnectionDataSchema
1468
- }),
1469
- z3.object({
1470
- authScheme: z3.literal(AuthSchemeTypes.BASIC_WITH_JWT),
1471
- /**
1472
- * the main connection data discriminated by auth scheme
1473
- */
1474
- val: BasicWithJwtConnectionDataSchema
1475
- })
1476
- ]);
1477
-
1478
- // src/types/connectedAccounts.types.ts
1479
1659
  var ConnectedAccountStatuses = {
1480
1660
  INITIALIZING: "INITIALIZING",
1481
1661
  INITIATED: "INITIATED",
@@ -1489,7 +1669,8 @@ var ConnectedAccountStatusSchema = z4.enum([
1489
1669
  ConnectedAccountStatuses.INITIATED,
1490
1670
  ConnectedAccountStatuses.ACTIVE,
1491
1671
  ConnectedAccountStatuses.FAILED,
1492
- ConnectedAccountStatuses.EXPIRED
1672
+ ConnectedAccountStatuses.EXPIRED,
1673
+ ConnectedAccountStatuses.INACTIVE
1493
1674
  ]);
1494
1675
  var CreateConnectedAccountParamsSchema = z4.object({
1495
1676
  authConfig: z4.object({
@@ -1530,7 +1711,7 @@ var ConnectedAccountAuthConfigSchema = z4.object({
1530
1711
  var ConnectedAccountRetrieveResponseSchema = z4.object({
1531
1712
  id: z4.string(),
1532
1713
  authConfig: ConnectedAccountAuthConfigSchema,
1533
- data: z4.record(z4.string(), z4.unknown()),
1714
+ data: z4.record(z4.string(), z4.unknown()).optional(),
1534
1715
  params: z4.record(z4.string(), z4.unknown()).optional(),
1535
1716
  status: ConnectedAccountStatusSchema,
1536
1717
  statusReason: z4.string().nullable(),
@@ -1545,7 +1726,7 @@ var ConnectedAccountRetrieveResponseSchema = z4.object({
1545
1726
  });
1546
1727
  var ConnectedAccountListParamsSchema = z4.object({
1547
1728
  authConfigIds: z4.array(z4.string()).nullable().optional().describe("The auth config ids of the connected accounts"),
1548
- cursor: z4.number().nullable().optional().describe("The cursor to paginate through the connected accounts"),
1729
+ cursor: z4.string().nullish().describe("The cursor to paginate through the connected accounts"),
1549
1730
  labels: z4.array(z4.string()).nullable().optional().describe("The labels of the connected accounts"),
1550
1731
  limit: z4.number().nullable().optional().describe("The limit of the connected accounts to return"),
1551
1732
  orderBy: z4.enum(["created_at", "updated_at"]).optional().describe("The order by of the connected accounts"),
@@ -1555,36 +1736,55 @@ var ConnectedAccountListParamsSchema = z4.object({
1555
1736
  });
1556
1737
  var ConnectedAccountListResponseSchema = z4.object({
1557
1738
  items: z4.array(ConnectedAccountRetrieveResponseSchema).describe("The list of connected accounts"),
1558
- nextCursor: z4.string().nullable().describe("The next cursor to paginate through the connected accounts"),
1739
+ nextCursor: z4.string().nullish().describe("The next cursor to paginate through the connected accounts"),
1559
1740
  totalPages: z4.number().describe("The total number of pages of connected accounts")
1560
1741
  });
1561
1742
 
1743
+ // src/utils/transform.ts
1744
+ function transform(raw) {
1745
+ return {
1746
+ with(schema) {
1747
+ return {
1748
+ using(transformer, options) {
1749
+ const transformed = transformer(raw);
1750
+ const result = schema.safeParse(transformed);
1751
+ if (!result.success) {
1752
+ logger_default.error(result.error);
1753
+ return transformed;
1754
+ }
1755
+ return result.data;
1756
+ }
1757
+ };
1758
+ }
1759
+ };
1760
+ }
1761
+
1562
1762
  // src/utils/transformers/connectedAccounts.ts
1563
1763
  function transformConnectedAccountResponse(response) {
1564
- const responseToParse = {
1565
- ...response,
1764
+ return transform(response).with(ConnectedAccountRetrieveResponseSchema).using((response2) => ({
1765
+ ...response2,
1566
1766
  authConfig: {
1567
- ...response.auth_config,
1568
- id: response.auth_config.id,
1569
- isComposioManaged: response.auth_config.is_composio_managed,
1570
- isDisabled: response.auth_config.is_disabled
1767
+ ...response2.auth_config,
1768
+ id: response2.auth_config.id,
1769
+ isComposioManaged: response2.auth_config.is_composio_managed,
1770
+ isDisabled: response2.auth_config.is_disabled
1571
1771
  },
1572
- state: response.state,
1573
- status: response.status,
1574
- statusReason: response.status_reason,
1575
- isDisabled: response.is_disabled,
1576
- createdAt: response.created_at,
1577
- updatedAt: response.updated_at,
1578
- testRequestEndpoint: response.test_request_endpoint
1579
- };
1580
- const result = ConnectedAccountRetrieveResponseSchema.safeParse(responseToParse);
1581
- if (!result.success) {
1582
- logger_default.error("Failed to parse connected account retrieve response", {
1583
- cause: result.error
1584
- });
1585
- return responseToParse;
1586
- }
1587
- return result.data;
1772
+ data: response2.data ?? void 0,
1773
+ state: response2.state,
1774
+ status: response2.status,
1775
+ statusReason: response2.status_reason,
1776
+ isDisabled: response2.is_disabled,
1777
+ createdAt: response2.created_at,
1778
+ updatedAt: response2.updated_at,
1779
+ testRequestEndpoint: response2.test_request_endpoint
1780
+ }));
1781
+ }
1782
+ function transformConnectedAccountListResponse(response) {
1783
+ return transform(response).with(ConnectedAccountListResponseSchema).using((response2) => ({
1784
+ items: response2.items.map(transformConnectedAccountResponse),
1785
+ nextCursor: response2.next_cursor ?? null,
1786
+ totalPages: response2.total_pages
1787
+ }));
1588
1788
  }
1589
1789
 
1590
1790
  // src/models/CustomTools.ts
@@ -1824,7 +2024,8 @@ var CustomTools = class {
1824
2024
  method: data.method,
1825
2025
  parameters,
1826
2026
  body: data.body,
1827
- connected_account_id: data.connectedAccountId ?? connectedAccountId
2027
+ connected_account_id: data.connectedAccountId ?? connectedAccountId,
2028
+ custom_connection_data: data.customConnectionData
1828
2029
  });
1829
2030
  return {
1830
2031
  data: response.data,
@@ -2639,6 +2840,7 @@ var Tools = class {
2639
2840
  allow_tracing: body.allowTracing,
2640
2841
  connected_account_id: body.connectedAccountId,
2641
2842
  custom_auth_params: body.customAuthParams,
2843
+ custom_connection_data: body.customConnectionData,
2642
2844
  arguments: body.arguments,
2643
2845
  user_id: body.userId,
2644
2846
  version: body.version,
@@ -2795,8 +2997,8 @@ var Tools = class {
2795
2997
  };
2796
2998
  if (toolProxyParams.data.parameters) {
2797
2999
  parameters.push(
2798
- ...Object.entries(toolProxyParams.data.parameters).map(([key, value]) => ({
2799
- name: key,
3000
+ ...(toolProxyParams.data.parameters ?? []).map((value) => ({
3001
+ name: value.name,
2800
3002
  type: value.in === "header" ? parameterTypes.header : parameterTypes.query,
2801
3003
  value: value.value.toString()
2802
3004
  }))
@@ -2807,7 +3009,8 @@ var Tools = class {
2807
3009
  method: toolProxyParams.data.method,
2808
3010
  body: toolProxyParams.data.body,
2809
3011
  connected_account_id: toolProxyParams.data.connectedAccountId,
2810
- parameters
3012
+ parameters,
3013
+ custom_connection_data: toolProxyParams.data.customConnectionData
2811
3014
  });
2812
3015
  }
2813
3016
  /**
@@ -2944,6 +3147,44 @@ var ToolkitAuthFieldsResponseSchema = z5.array(
2944
3147
  })
2945
3148
  );
2946
3149
 
3150
+ // src/utils/transformers/authConfigs.ts
3151
+ function transformAuthConfigRetrieveResponse(authConfig) {
3152
+ return transform(authConfig).with(AuthConfigRetrieveResponseSchema).using((authConfig2) => ({
3153
+ id: authConfig2.id,
3154
+ name: authConfig2.name,
3155
+ noOfConnections: authConfig2.no_of_connections,
3156
+ status: authConfig2.status,
3157
+ toolkit: {
3158
+ logo: authConfig2.toolkit.logo,
3159
+ slug: authConfig2.toolkit.slug
3160
+ },
3161
+ uuid: authConfig2.uuid,
3162
+ authScheme: authConfig2.auth_scheme,
3163
+ credentials: authConfig2.credentials,
3164
+ expectedInputFields: authConfig2.expected_input_fields,
3165
+ isComposioManaged: authConfig2.is_composio_managed,
3166
+ createdBy: authConfig2.created_by,
3167
+ createdAt: authConfig2.created_at,
3168
+ lastUpdatedAt: authConfig2.last_updated_at,
3169
+ restrictToFollowingTools: authConfig2.tool_access_config?.tools_for_connected_account_creation
3170
+ }));
3171
+ }
3172
+ function transformAuthConfigListResponse(response) {
3173
+ return transform(response).with(AuthConfigListResponseSchema).using((response2) => ({
3174
+ items: response2.items.map(transformAuthConfigRetrieveResponse),
3175
+ nextCursor: response2.next_cursor ?? null,
3176
+ totalPages: response2.total_pages
3177
+ }));
3178
+ }
3179
+ function transformCreateAuthConfigResponse(response) {
3180
+ return transform(response).with(CreateAuthConfigResponseSchema).using((response2) => ({
3181
+ id: response2.auth_config.id,
3182
+ authScheme: response2.auth_config.auth_scheme,
3183
+ isComposioManaged: response2.auth_config.is_composio_managed,
3184
+ toolkit: response2.toolkit.slug
3185
+ }));
3186
+ }
3187
+
2947
3188
  // src/models/AuthConfigs.ts
2948
3189
  var AuthConfigs = class {
2949
3190
  client;
@@ -2959,45 +3200,6 @@ var AuthConfigs = class {
2959
3200
  getClient() {
2960
3201
  return this.client;
2961
3202
  }
2962
- /**
2963
- * Transforms an auth config response from API format to SDK format.
2964
- *
2965
- * This method converts property names from snake_case to camelCase and reorganizes
2966
- * the data structure to match the SDK's standardized format for auth configurations.
2967
- *
2968
- * @param {ComposioAuthConfigRetrieveResponse} authConfig - The raw API response to transform
2969
- * @returns {AuthConfigRetrieveResponse} The transformed auth config data
2970
- * @throws {ValidationError} If the response fails validation against the expected schema
2971
- *
2972
- * @private
2973
- */
2974
- parseAuthConfigRetrieveResponse(authConfig) {
2975
- const result = AuthConfigRetrieveResponseSchema.safeParse({
2976
- id: authConfig.id,
2977
- name: authConfig.name,
2978
- noOfConnections: authConfig.no_of_connections,
2979
- status: authConfig.status,
2980
- toolkit: {
2981
- logo: authConfig.toolkit.logo,
2982
- slug: authConfig.toolkit.slug
2983
- },
2984
- uuid: authConfig.uuid,
2985
- authScheme: authConfig.auth_scheme,
2986
- credentials: authConfig.credentials,
2987
- expectedInputFields: authConfig.expected_input_fields,
2988
- isComposioManaged: authConfig.is_composio_managed,
2989
- createdBy: authConfig.created_by,
2990
- createdAt: authConfig.created_at,
2991
- lastUpdatedAt: authConfig.last_updated_at,
2992
- restrictToFollowingTools: authConfig.restrict_to_following_tools
2993
- });
2994
- if (result.error) {
2995
- throw new ValidationError("Failed to parse auth config response", {
2996
- cause: result.error
2997
- });
2998
- }
2999
- return result.data;
3000
- }
3001
3203
  /**
3002
3204
  * Lists authentication configurations based on provided filter criteria.
3003
3205
  *
@@ -3032,17 +3234,7 @@ var AuthConfigs = class {
3032
3234
  limit: parsedQuery?.limit,
3033
3235
  toolkit_slug: parsedQuery?.toolkit
3034
3236
  });
3035
- const parsedResult = AuthConfigListResponseSchema.safeParse({
3036
- items: result.items.map((item) => this.parseAuthConfigRetrieveResponse(item)),
3037
- nextCursor: result.next_cursor,
3038
- totalPages: result.total_pages
3039
- });
3040
- if (parsedResult.error) {
3041
- throw new ValidationError("Failed to parse auth config list response", {
3042
- cause: parsedResult.error
3043
- });
3044
- }
3045
- return parsedResult.data;
3237
+ return transformAuthConfigListResponse(result);
3046
3238
  }
3047
3239
  /**
3048
3240
  * Create a new auth config
@@ -3078,26 +3270,19 @@ var AuthConfigs = class {
3078
3270
  name: parsedOptions.data.name,
3079
3271
  authScheme: parsedOptions.data.authScheme,
3080
3272
  credentials: parsedOptions.data.credentials,
3081
- restrict_to_following_tools: parsedOptions.data.restrictToFollowingTools
3273
+ tool_access_config: {
3274
+ tools_for_connected_account_creation: parsedOptions.data.restrictToFollowingTools
3275
+ }
3082
3276
  } : {
3083
3277
  type: parsedOptions.data.type,
3084
3278
  credentials: parsedOptions.data.credentials,
3085
3279
  name: parsedOptions.data.name,
3086
- restrict_to_following_tools: parsedOptions.data.restrictToFollowingTools
3280
+ tool_access_config: {
3281
+ tools_for_connected_account_creation: parsedOptions.data.restrictToFollowingTools
3282
+ }
3087
3283
  }
3088
3284
  });
3089
- const parsedResult = CreateAuthConfigResponseSchema.safeParse({
3090
- id: result.auth_config.id,
3091
- authScheme: result.auth_config.auth_scheme,
3092
- isComposioManaged: result.auth_config.is_composio_managed,
3093
- toolkit: result.toolkit.slug
3094
- });
3095
- if (parsedResult.error) {
3096
- throw new ValidationError("Failed to parse auth config create response", {
3097
- cause: parsedResult.error
3098
- });
3099
- }
3100
- return parsedResult.data;
3285
+ return transformCreateAuthConfigResponse(result);
3101
3286
  }
3102
3287
  /**
3103
3288
  * Retrieves a specific authentication configuration by its ID.
@@ -3120,7 +3305,7 @@ var AuthConfigs = class {
3120
3305
  */
3121
3306
  async get(nanoid) {
3122
3307
  const result = await this.client.authConfigs.retrieve(nanoid);
3123
- return this.parseAuthConfigRetrieveResponse(result);
3308
+ return transformAuthConfigRetrieveResponse(result);
3124
3309
  }
3125
3310
  /**
3126
3311
  * Updates an existing authentication configuration.
@@ -3164,11 +3349,15 @@ var AuthConfigs = class {
3164
3349
  parsedData.data.type === "custom" ? {
3165
3350
  type: "custom",
3166
3351
  credentials: parsedData.data.credentials,
3167
- restrict_to_following_tools: parsedData.data.restrictToFollowingTools
3352
+ tool_access_config: {
3353
+ tools_for_connected_account_creation: parsedData.data.restrictToFollowingTools
3354
+ }
3168
3355
  } : {
3169
3356
  type: "default",
3170
3357
  scopes: parsedData.data.scopes,
3171
- restrict_to_following_tools: parsedData.data.restrictToFollowingTools
3358
+ tool_access_config: {
3359
+ tools_for_connected_account_creation: parsedData.data.restrictToFollowingTools
3360
+ }
3172
3361
  }
3173
3362
  );
3174
3363
  }
@@ -3380,17 +3569,7 @@ var ConnectedAccounts = class {
3380
3569
  };
3381
3570
  }
3382
3571
  const result = await this.client.connectedAccounts.list(rawQuery);
3383
- const parsedResponse = ConnectedAccountListResponseSchema.safeParse({
3384
- items: result.items.map(transformConnectedAccountResponse),
3385
- nextCursor: result.next_cursor,
3386
- totalPages: result.total_pages
3387
- });
3388
- if (!parsedResponse.success) {
3389
- throw new ValidationError("Failed to parse connected account list response", {
3390
- cause: parsedResponse.error
3391
- });
3392
- }
3393
- return parsedResponse.data;
3572
+ return transformConnectedAccountListResponse(result);
3394
3573
  }
3395
3574
  /**
3396
3575
  * Compound function to create a new connected account.
@@ -3626,6 +3805,77 @@ var ConnectedAccounts = class {
3626
3805
 
3627
3806
  // src/models/Toolkits.ts
3628
3807
  import { APIError } from "openai";
3808
+
3809
+ // src/utils/transformers/toolkits.ts
3810
+ var transformToolkitListResponse = (response) => {
3811
+ return transform(response).with(ToolKitListResponseSchema).using(
3812
+ (response2) => response2.items.map((item) => ({
3813
+ name: item.name,
3814
+ slug: item.slug,
3815
+ meta: {
3816
+ ...item.meta,
3817
+ categories: item.meta.categories?.map((category) => ({
3818
+ slug: category.id,
3819
+ name: category.name
3820
+ })),
3821
+ createdAt: item.meta.created_at,
3822
+ description: item.meta.description,
3823
+ logo: item.meta.logo,
3824
+ toolsCount: item.meta.tools_count,
3825
+ triggersCount: item.meta.triggers_count,
3826
+ updatedAt: item.meta.updated_at,
3827
+ appUrl: item.meta.app_url ?? void 0
3828
+ },
3829
+ isLocalToolkit: item.is_local_toolkit,
3830
+ authSchemes: item.auth_schemes,
3831
+ composioManagedAuthSchemes: item.composio_managed_auth_schemes,
3832
+ noAuth: item.no_auth
3833
+ }))
3834
+ );
3835
+ };
3836
+ var transformToolkitRetrieveResponse = (response) => {
3837
+ return transform(response).with(ToolkitRetrieveResponseSchema).using((response2) => ({
3838
+ name: response2.name,
3839
+ slug: response2.slug,
3840
+ meta: {
3841
+ ...response2.meta,
3842
+ createdAt: response2.meta.created_at,
3843
+ updatedAt: response2.meta.updated_at,
3844
+ toolsCount: response2.meta.tools_count,
3845
+ triggersCount: response2.meta.triggers_count,
3846
+ categories: response2.meta.categories?.map((category) => ({
3847
+ slug: category.slug,
3848
+ name: category.name
3849
+ }))
3850
+ // appUrl: response.meta.app_url, @TODO Update the client type to include this
3851
+ },
3852
+ isLocalToolkit: response2.is_local_toolkit,
3853
+ composioManagedAuthSchemes: response2.composio_managed_auth_schemes,
3854
+ authConfigDetails: response2.auth_config_details?.map((authConfig) => ({
3855
+ name: authConfig.name,
3856
+ mode: authConfig.mode,
3857
+ fields: {
3858
+ authConfigCreation: authConfig.fields.auth_config_creation,
3859
+ connectedAccountInitiation: authConfig.fields.connected_account_initiation
3860
+ },
3861
+ proxy: {
3862
+ baseUrl: authConfig.proxy?.base_url
3863
+ }
3864
+ }))
3865
+ }));
3866
+ };
3867
+ var transformToolkitRetrieveCategoriesResponse = (response) => {
3868
+ return transform(response).with(ToolkitRetrieveCategoriesResponseSchema).using((response2) => ({
3869
+ items: response2.items.map((item) => ({
3870
+ id: item.id,
3871
+ name: item.name
3872
+ })),
3873
+ nextCursor: response2.next_cursor ?? null,
3874
+ totalPages: response2.total_pages
3875
+ }));
3876
+ };
3877
+
3878
+ // src/models/Toolkits.ts
3629
3879
  var Toolkits = class {
3630
3880
  client;
3631
3881
  constructor(client) {
@@ -3658,40 +3908,7 @@ var Toolkits = class {
3658
3908
  managed_by: parsedQuery.data.managedBy,
3659
3909
  sort_by: parsedQuery.data.sortBy
3660
3910
  });
3661
- const parsedResult = ToolKitListResponseSchema.safeParse(
3662
- result.items.map((item) => {
3663
- const parsedItem = ToolKitItemSchema.safeParse({
3664
- name: item.name,
3665
- slug: item.slug,
3666
- meta: {
3667
- ...item.meta,
3668
- createdAt: item.meta.created_at,
3669
- updatedAt: item.meta.updated_at,
3670
- toolsCount: item.meta.tools_count,
3671
- triggersCount: item.meta.triggers_count,
3672
- categories: item.meta.categories,
3673
- appUrl: item.meta.app_url,
3674
- logo: item.meta.logo
3675
- },
3676
- isLocalToolkit: item.is_local_toolkit,
3677
- authSchemes: item.auth_schemes,
3678
- composioManagedAuthSchemes: item.composio_managed_auth_schemes,
3679
- noAuth: item.no_auth
3680
- });
3681
- if (!parsedItem.success) {
3682
- throw new ValidationError("Failed to parse toolkit response", {
3683
- cause: parsedItem.error
3684
- });
3685
- }
3686
- return parsedItem.data;
3687
- })
3688
- );
3689
- if (!parsedResult.success) {
3690
- throw new ValidationError("Failed to parse toolkit list response", {
3691
- cause: parsedResult.error
3692
- });
3693
- }
3694
- return parsedResult.data;
3911
+ return transformToolkitListResponse(result);
3695
3912
  } catch (error) {
3696
3913
  throw new ComposioToolkitFetchError("Failed to fetch toolkits", {
3697
3914
  cause: error
@@ -3714,37 +3931,7 @@ var Toolkits = class {
3714
3931
  async getToolkitBySlug(slug) {
3715
3932
  try {
3716
3933
  const result = await this.client.toolkits.retrieve(slug);
3717
- const parsedResult = ToolkitRetrieveResponseSchema.safeParse({
3718
- name: result.name,
3719
- slug: result.slug,
3720
- meta: {
3721
- ...result.meta,
3722
- createdAt: result.meta.created_at,
3723
- updatedAt: result.meta.updated_at,
3724
- toolsCount: result.meta.tools_count,
3725
- triggersCount: result.meta.triggers_count
3726
- // appUrl: result.meta.app_url, @TODO Update the client type to include this
3727
- },
3728
- isLocalToolkit: result.is_local_toolkit,
3729
- composioManagedAuthSchemes: result.composio_managed_auth_schemes,
3730
- authConfigDetails: result.auth_config_details?.map((authConfig) => ({
3731
- name: authConfig.name,
3732
- mode: authConfig.mode,
3733
- fields: {
3734
- authConfigCreation: authConfig.fields.auth_config_creation,
3735
- connectedAccountInitiation: authConfig.fields.connected_account_initiation
3736
- },
3737
- proxy: {
3738
- baseUrl: authConfig.proxy?.base_url
3739
- }
3740
- }))
3741
- });
3742
- if (!parsedResult.success) {
3743
- throw new ValidationError("Failed to parse toolkit response", {
3744
- cause: parsedResult.error
3745
- });
3746
- }
3747
- return parsedResult.data;
3934
+ return transformToolkitRetrieveResponse(result);
3748
3935
  } catch (error) {
3749
3936
  if (error instanceof APIError && (error.status === 404 || error.status === 400)) {
3750
3937
  throw new ComposioToolkitNotFoundError(`Toolkit with slug ${slug} not found`, {
@@ -3772,7 +3959,7 @@ var Toolkits = class {
3772
3959
  if (typeof arg === "string") {
3773
3960
  return this.getToolkitBySlug(arg);
3774
3961
  }
3775
- return this.getToolkits(arg);
3962
+ return this.getToolkits(arg ?? {});
3776
3963
  }
3777
3964
  async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
3778
3965
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
@@ -3865,23 +4052,7 @@ var Toolkits = class {
3865
4052
  */
3866
4053
  async listCategories() {
3867
4054
  const result = await this.client.toolkits.retrieveCategories();
3868
- const parsedResult = ToolkitRetrieveCategoriesResponseSchema.safeParse({
3869
- items: result.items.map((item) => {
3870
- const parsedItem = ToolkitCategorySchema.parse({
3871
- id: item.id,
3872
- name: item.name
3873
- });
3874
- return parsedItem;
3875
- }),
3876
- nextCursor: result.next_cursor,
3877
- totalPages: result.total_pages
3878
- });
3879
- if (!parsedResult.success) {
3880
- throw new ValidationError("Failed to parse toolkit categories response", {
3881
- cause: parsedResult.error
3882
- });
3883
- }
3884
- return parsedResult.data;
4055
+ return transformToolkitRetrieveCategoriesResponse(result);
3885
4056
  }
3886
4057
  /**
3887
4058
  * Authorizes a user to use a toolkit.
@@ -3895,22 +4066,24 @@ var Toolkits = class {
3895
4066
  * const connectionRequest = await composio.toolkits.authorize(userId, 'github');
3896
4067
  * ```
3897
4068
  */
3898
- async authorize(userId, toolkitSlug) {
4069
+ async authorize(userId, toolkitSlug, authConfigId) {
3899
4070
  const toolkit = await this.getToolkitBySlug(toolkitSlug);
3900
4071
  const composioAuthConfig = new AuthConfigs(this.client);
3901
- let authConfigIdToUse;
3902
- const authConfig = await composioAuthConfig.list({
3903
- toolkit: toolkitSlug
3904
- });
3905
- authConfigIdToUse = authConfig.items[0]?.id;
4072
+ let authConfigIdToUse = authConfigId;
4073
+ if (!authConfigIdToUse) {
4074
+ const authConfig = await composioAuthConfig.list({
4075
+ toolkit: toolkitSlug
4076
+ });
4077
+ authConfigIdToUse = authConfig.items[0]?.id;
4078
+ }
3906
4079
  if (!authConfigIdToUse) {
3907
4080
  if (toolkit.authConfigDetails && toolkit.authConfigDetails.length > 0) {
3908
4081
  try {
3909
- const authConfig2 = await composioAuthConfig.create(toolkitSlug, {
4082
+ const authConfig = await composioAuthConfig.create(toolkitSlug, {
3910
4083
  type: "use_composio_managed_auth",
3911
4084
  name: `${toolkit.name} Auth Config`
3912
4085
  });
3913
- authConfigIdToUse = authConfig2.id;
4086
+ authConfigIdToUse = authConfig.id;
3914
4087
  } catch (error) {
3915
4088
  if (error instanceof ComposioClient2.APIError && error.status === 400) {
3916
4089
  throw new ComposioAuthConfigNotFoundError(
@@ -4052,7 +4225,7 @@ var TriggerTypeSchema = z6.object({
4052
4225
  });
4053
4226
  var TriggersTypeListResponseSchema = z6.object({
4054
4227
  items: z6.array(TriggerTypeSchema),
4055
- nextCursor: z6.string().nullable(),
4228
+ nextCursor: z6.string().nullish(),
4056
4229
  totalPages: z6.number()
4057
4230
  });
4058
4231
 
@@ -4325,27 +4498,75 @@ var PusherService = class {
4325
4498
  }
4326
4499
  };
4327
4500
 
4328
- // src/utils/transform.ts
4329
- function transform(raw) {
4330
- return {
4331
- with(schema) {
4332
- return {
4333
- using(transformer, options) {
4334
- const transformed = transformer(raw);
4335
- const result = schema.safeParse(transformed);
4336
- if (!result.success) {
4337
- throw new ValidationError(
4338
- `Failed to transform${options?.label ? ` ${options.label}` : ""}`,
4339
- {
4340
- cause: result.error
4341
- }
4342
- );
4343
- }
4344
- return result.data;
4345
- }
4346
- };
4501
+ // src/utils/transformers/triggers.ts
4502
+ function transformIncomingTriggerPayload(response) {
4503
+ return transform(response).with(IncomingTriggerPayloadSchema).using((response2) => ({
4504
+ id: response2.metadata.nanoId,
4505
+ uuid: response2.metadata.id,
4506
+ triggerSlug: response2.metadata.triggerName,
4507
+ toolkitSlug: response2.appName,
4508
+ userId: response2.metadata.connection?.clientUniqueUserId,
4509
+ payload: response2.payload,
4510
+ originalPayload: response2.originalPayload,
4511
+ metadata: {
4512
+ id: response2.metadata.nanoId,
4513
+ uuid: response2.metadata.id,
4514
+ triggerConfig: response2.metadata.triggerConfig,
4515
+ triggerSlug: response2.metadata.triggerName,
4516
+ toolkitSlug: response2.appName,
4517
+ triggerData: response2.metadata.triggerData,
4518
+ connectedAccount: {
4519
+ id: response2.metadata.connection?.connectedAccountNanoId,
4520
+ uuid: response2.metadata.connection?.id,
4521
+ authConfigId: response2.metadata.connection?.authConfigNanoId,
4522
+ authConfigUUID: response2.metadata.connection?.integrationId,
4523
+ userId: response2.metadata.connection?.clientUniqueUserId,
4524
+ status: response2.metadata.connection?.status
4525
+ }
4347
4526
  }
4348
- };
4527
+ }));
4528
+ }
4529
+ function transformTriggerTypeRetrieveResponse(response) {
4530
+ return transform(response).with(TriggerTypeSchema).using((response2) => ({
4531
+ slug: response2.slug,
4532
+ name: response2.name,
4533
+ description: response2.description,
4534
+ instructions: response2.instructions,
4535
+ toolkit: {
4536
+ logo: response2.toolkit.logo,
4537
+ slug: response2.toolkit.slug,
4538
+ name: response2.toolkit.name
4539
+ },
4540
+ payload: response2.payload,
4541
+ config: response2.config
4542
+ }));
4543
+ }
4544
+ function transformTriggerTypeListResponse(response) {
4545
+ return transform(response).with(TriggersTypeListResponseSchema).using((response2) => ({
4546
+ items: response2.items,
4547
+ nextCursor: response2.next_cursor ?? null,
4548
+ totalPages: response2.total_pages
4549
+ }));
4550
+ }
4551
+ function transformTriggerInstanceListActiveItem(response) {
4552
+ return transform(response).with(TriggerInstanceListActiveResponseItemSchema).using((response2) => ({
4553
+ id: response2.id,
4554
+ connectedAccountId: response2.connected_account_id,
4555
+ disabledAt: response2.disabled_at,
4556
+ state: response2.state,
4557
+ triggerConfig: response2.trigger_config,
4558
+ triggerName: response2.trigger_name,
4559
+ updatedAt: response2.updated_at,
4560
+ triggerData: response2.trigger_data,
4561
+ uuid: response2.uuid
4562
+ }));
4563
+ }
4564
+ function transformTriggerInstanceListActiveResponse(response) {
4565
+ return transform(response).with(TriggerInstanceListActiveResponseSchema).using((response2) => ({
4566
+ items: response2.items.map((item) => transformTriggerInstanceListActiveItem(item)),
4567
+ nextCursor: response2.next_cursor ?? null,
4568
+ totalPages: response2.total_pages
4569
+ }));
4349
4570
  }
4350
4571
 
4351
4572
  // src/models/Triggers.ts
@@ -4357,31 +4578,6 @@ var Triggers = class {
4357
4578
  this.pusherService = new PusherService(client);
4358
4579
  telemetry.instrument(this);
4359
4580
  }
4360
- /**
4361
- * Parse the trigger instance list active item
4362
- *
4363
- * @param response - The response from the composio client
4364
- * @returns The parsed trigger instance list active item
4365
- */
4366
- parseTriggerInstanceListActiveItem(response) {
4367
- const parsed = TriggerInstanceListActiveResponseItemSchema.safeParse({
4368
- id: response.id,
4369
- connectedAccountId: response.connected_account_id,
4370
- disabledAt: response.disabled_at,
4371
- state: response.state,
4372
- triggerConfig: response.trigger_config,
4373
- triggerName: response.trigger_name,
4374
- updatedAt: response.updated_at,
4375
- triggerData: response.trigger_data,
4376
- uuid: response.uuid
4377
- });
4378
- if (!parsed.success) {
4379
- throw new ValidationError(`Invalid trigger instance list active item`, {
4380
- cause: parsed.error
4381
- });
4382
- }
4383
- return parsed.data;
4384
- }
4385
4581
  /**
4386
4582
  * Fetch list of all the active triggers
4387
4583
  *
@@ -4417,17 +4613,7 @@ var Triggers = class {
4417
4613
  trigger_names: parsedParams.data.triggerNames
4418
4614
  } : void 0
4419
4615
  );
4420
- const parsedResult = TriggerInstanceListActiveResponseSchema.safeParse({
4421
- items: result.items.map((item) => this.parseTriggerInstanceListActiveItem(item)),
4422
- nextCursor: result.next_cursor,
4423
- totalPages: result.total_pages
4424
- });
4425
- if (!parsedResult.success) {
4426
- throw new ValidationError(`Invalid trigger instance list active response`, {
4427
- cause: parsedResult.error
4428
- });
4429
- }
4430
- return parsedResult.data;
4616
+ return transformTriggerInstanceListActiveResponse(result);
4431
4617
  }
4432
4618
  /**
4433
4619
  * Create a new trigger instance for a user
@@ -4515,15 +4701,9 @@ var Triggers = class {
4515
4701
  connected_account_id: connectedAccountId,
4516
4702
  trigger_config: parsedBody.data.triggerConfig
4517
4703
  });
4518
- const parsedResult = TriggerInstanceUpsertResponseSchema.safeParse({
4704
+ return {
4519
4705
  triggerId: result.trigger_id
4520
- });
4521
- if (!parsedResult.success) {
4522
- throw new ValidationError(`Invalid trigger instance upsert response`, {
4523
- cause: parsedResult.error
4524
- });
4525
- }
4526
- return parsedResult.data;
4706
+ };
4527
4707
  }
4528
4708
  /**
4529
4709
  * Update an existing trigger instance
@@ -4543,15 +4723,9 @@ var Triggers = class {
4543
4723
  */
4544
4724
  async delete(triggerId) {
4545
4725
  const result = await this.client.triggerInstances.manage.delete(triggerId);
4546
- const parsedResult = TriggerInstanceManageDeleteResponseSchema.safeParse({
4726
+ return {
4547
4727
  triggerId: result.trigger_id
4548
- });
4549
- if (!parsedResult.success) {
4550
- throw new ValidationError(`Invalid trigger instance manage delete response`, {
4551
- cause: parsedResult.error
4552
- });
4553
- }
4554
- return parsedResult.data;
4728
+ };
4555
4729
  }
4556
4730
  /**
4557
4731
  * Disable a trigger instance
@@ -4592,12 +4766,7 @@ var Triggers = class {
4592
4766
  limit: parsedQuery.limit,
4593
4767
  toolkit_slugs: parsedQuery.toolkits
4594
4768
  });
4595
- const parsedResult = transform(result).with(TriggersTypeListResponseSchema).using((raw) => ({
4596
- items: raw.items,
4597
- nextCursor: raw.next_cursor ?? null,
4598
- totalPages: raw.total_pages
4599
- }));
4600
- return parsedResult;
4769
+ return transformTriggerTypeListResponse(result);
4601
4770
  }
4602
4771
  /**
4603
4772
  * Retrieve a trigger type by its slug
@@ -4608,20 +4777,7 @@ var Triggers = class {
4608
4777
  */
4609
4778
  async getType(slug) {
4610
4779
  const result = await this.client.triggersTypes.retrieve(slug);
4611
- const parsedResult = transform(result).with(TriggerTypeSchema).using((raw) => ({
4612
- slug: raw.slug,
4613
- name: raw.name,
4614
- description: raw.description,
4615
- instructions: raw.instructions,
4616
- toolkit: {
4617
- logo: raw.toolkit.logo,
4618
- slug: raw.toolkit.slug,
4619
- name: raw.toolkit.name
4620
- },
4621
- payload: raw.payload,
4622
- config: raw.config
4623
- }));
4624
- return parsedResult;
4780
+ return transformTriggerTypeRetrieveResponse(result);
4625
4781
  }
4626
4782
  /**
4627
4783
  * Fetches the list of all the available trigger enums
@@ -4707,40 +4863,10 @@ var Triggers = class {
4707
4863
  await this.pusherService.subscribe((_data) => {
4708
4864
  logger_default.debug("Received raw trigger data", JSON.stringify(_data, null, 2));
4709
4865
  const data = _data;
4710
- const parsedData = IncomingTriggerPayloadSchema.safeParse({
4711
- id: data.metadata.nanoId,
4712
- uuid: data.metadata.id,
4713
- triggerSlug: data.metadata.triggerName,
4714
- toolkitSlug: data.appName,
4715
- userId: data.metadata.connection?.clientUniqueUserId,
4716
- payload: data.payload,
4717
- originalPayload: data.originalPayload,
4718
- metadata: {
4719
- id: data.metadata.nanoId,
4720
- uuid: data.metadata.id,
4721
- triggerConfig: data.metadata.triggerConfig,
4722
- triggerSlug: data.metadata.triggerName,
4723
- toolkitSlug: data.appName,
4724
- triggerData: data.metadata.triggerData,
4725
- connectedAccount: {
4726
- id: data.metadata.connection?.connectedAccountNanoId,
4727
- uuid: data.metadata.connection?.id,
4728
- authConfigId: data.metadata.connection?.authConfigNanoId,
4729
- authConfigUUID: data.metadata.connection?.integrationId,
4730
- userId: data.metadata.connection?.clientUniqueUserId,
4731
- status: data.metadata.connection?.status
4732
- }
4733
- }
4734
- });
4735
- logger_default.debug("Parsed trigger data", JSON.stringify(parsedData.data, null, 2));
4736
- if (parsedData.error) {
4737
- throw new ValidationError(`Invalid trigger payload`, {
4738
- cause: parsedData.error
4739
- });
4740
- }
4741
- if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData.data)) {
4866
+ const parsedData = transformIncomingTriggerPayload(data);
4867
+ if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData)) {
4742
4868
  try {
4743
- fn(parsedData.data);
4869
+ fn(parsedData);
4744
4870
  } catch (error) {
4745
4871
  logger_default.error("\u274C Error in trigger callback:", error);
4746
4872
  }
@@ -4781,7 +4907,7 @@ var MCPToolkitConfigsArraySchema = z8.array(MCPToolkitConfigSchema).min(1, "At l
4781
4907
  return uniqueToolkits.size === toolkits.length;
4782
4908
  }, "Duplicate toolkits are not allowed. Each toolkit must be unique.");
4783
4909
  var MCPAuthOptionsSchema = z8.object({
4784
- useComposioManagedAuth: z8.boolean().optional()
4910
+ isChatAuth: z8.boolean().optional()
4785
4911
  });
4786
4912
  var MCPGetServerParamsSchema = z8.object({
4787
4913
  userId: z8.string().min(1, "User ID cannot be empty").optional(),
@@ -4799,7 +4925,7 @@ var MCPGetServerParamsSchema = z8.object({
4799
4925
  var MCPGenerateURLParamsSchema = z8.object({
4800
4926
  userIds: z8.array(z8.string()).optional(),
4801
4927
  connectedAccountIds: z8.array(z8.string()).optional(),
4802
- useComposioManagedAuth: z8.boolean().optional()
4928
+ isChatAuth: z8.boolean().optional()
4803
4929
  });
4804
4930
  var ComposioGenerateURLParamsSchema = z8.object({
4805
4931
  user_ids: z8.array(z8.string()).optional(),
@@ -4853,6 +4979,11 @@ var MCPServerUpdateParamsSchema = z8.object({
4853
4979
  allowedTools: z8.array(z8.string()).optional().describe("Updated list of allowed tools")
4854
4980
  });
4855
4981
  var MCPServerCreateResponseSchema = MCPServerSchema;
4982
+ var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
4983
+ ConnectionStatus2["CONNECTED"] = "CONNECTED";
4984
+ ConnectionStatus2["DISCONNECTED"] = "DISCONNECTED";
4985
+ return ConnectionStatus2;
4986
+ })(ConnectionStatus || {});
4856
4987
  var CustomCreateResponseSchema = z8.object({
4857
4988
  id: z8.string().min(1, "Server ID cannot be empty"),
4858
4989
  name: z8.string().min(1, "Server name cannot be empty"),
@@ -4897,7 +5028,14 @@ var McpRetrieveResponseSchema = z8.object({
4897
5028
  status: z8.string().optional(),
4898
5029
  toolkits: z8.array(z8.string()).optional(),
4899
5030
  tools: z8.array(z8.string()).optional(),
4900
- managedAuthViaComposio: z8.boolean().optional()
5031
+ managedAuthViaComposio: z8.boolean().optional(),
5032
+ authConfigIds: z8.array(z8.string()).optional(),
5033
+ mcpUrl: z8.string(),
5034
+ commands: z8.object({
5035
+ claude: z8.string(),
5036
+ cursor: z8.string(),
5037
+ windsurf: z8.string()
5038
+ })
4901
5039
  });
4902
5040
  var ComposioMcpRetrieveResponseSchema = z8.object({
4903
5041
  id: z8.string().min(1, "Server ID cannot be empty"),
@@ -4980,8 +5118,11 @@ function transformMcpRetrieveResponse(response) {
4980
5118
  updatedAt: response.updated_at,
4981
5119
  status: response.status,
4982
5120
  toolkits: response.toolkits,
4983
- tools: response.tools,
4984
- managedAuthViaComposio: response.managed_auth_via_composio
5121
+ tools: response.allowed_tools,
5122
+ managedAuthViaComposio: response.managed_auth_via_composio,
5123
+ authConfigIds: response.auth_config_ids,
5124
+ mcpUrl: response.mcp_url,
5125
+ commands: response.commands
4985
5126
  });
4986
5127
  if (!result.success) {
4987
5128
  throw new ValidationError("Failed to parse MCP retrieve response", {
@@ -5038,9 +5179,11 @@ function transformMcpGenerateUrlResponse(response) {
5038
5179
  var MCP = class {
5039
5180
  client;
5040
5181
  provider;
5182
+ toolkits;
5041
5183
  constructor(client, provider) {
5042
5184
  this.client = client;
5043
5185
  this.provider = provider;
5186
+ this.toolkits = new Toolkits(client);
5044
5187
  telemetry.instrument(this);
5045
5188
  }
5046
5189
  /**
@@ -5068,47 +5211,100 @@ var MCP = class {
5068
5211
  }
5069
5212
  /**
5070
5213
  * Create a new MCP server
5071
- * @param {string} name - Unique name for the MCP server
5072
- * @param {MCPToolkitConfig[]} toolkitConfigs - Array of toolkit configurations
5073
- * @param {MCPAuthOptions} [authOptions] - Authentication configuration options
5214
+ * @param {Object} params - Parameters for creating the MCP server
5215
+ * @param {Array} params.authConfig - Array of auth configurations with id and allowed tools
5216
+ * @param {Object} params.options - Server creation options
5217
+ * @param {string} params.options.name - Unique name for the MCP server
5218
+ * @param {boolean} [params.options.isChatAuth] - Whether to use chat-based authentication
5074
5219
  * @returns {Promise<McpServerCreateResponse<T>>} Created server details with instance getter
5075
5220
  *
5076
5221
  * @example
5077
5222
  * ```typescript
5078
- * const server = await composio.mcp.create(
5079
- * "personal-mcp-server",
5080
- * [
5223
+ * const server = await composio.mcp.create("personal-mcp-server", [
5081
5224
  * {
5082
- * toolkit: "GMAIL",
5083
- * authConfigId: "ac_sdhkjfhjksdk",
5084
- * allowedTools: ["GMAIL_FETCH_EMAILS"],
5085
- * },
5225
+ * authConfigId: "ac_xyz",
5226
+ * allowedTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"]
5227
+ * }
5086
5228
  * ],
5087
- * { useComposioManagedAuth: true },
5088
- * );
5089
- *
5090
- * // Option 1: Use convenience method on response
5091
- * const urls = await server.getServer({
5092
- * connectedAccountIds: { gmail: "account_id" }
5229
+ * {
5230
+ * isChatAuth: true
5231
+ * }
5093
5232
  * });
5094
5233
  *
5095
- * // Option 2: Use standalone method later
5096
- * const urlsLater = await composio.mcp.getServer(server.id, {
5097
- * connectedAccountIds: { gmail: "account_id" }
5234
+ * // Use convenience method on response
5235
+ * const urls = await server.getServer({
5236
+ * userId: "user123"
5098
5237
  * });
5099
5238
  * ```
5100
5239
  */
5101
- async create(name, toolkitConfigs, authOptions) {
5102
- this.validateInputs(toolkitConfigs, authOptions);
5103
- const toolkits = toolkitConfigs.map((config) => config.toolkit);
5240
+ async create(name, serverConfig, options) {
5241
+ if (!serverConfig || serverConfig.length === 0) {
5242
+ throw new ValidationError("At least one auth config is required", {});
5243
+ }
5244
+ if (!name) {
5245
+ throw new ValidationError("Server name is required", {});
5246
+ }
5247
+ try {
5248
+ const mcpServer = await this.getByName(name);
5249
+ const authConfigs = mcpServer.authConfigIds?.sort();
5250
+ const sortedCurrentAuthConfigs = serverConfig.map((config) => config.authConfigId).sort();
5251
+ if (authConfigs.length > 0 && !authConfigs.every((config, index) => config === sortedCurrentAuthConfigs[index])) {
5252
+ throw new ValidationError(
5253
+ "MCP server with this name already exists with different auth configs",
5254
+ {
5255
+ meta: { serverName: name }
5256
+ }
5257
+ );
5258
+ }
5259
+ const tools = mcpServer.tools?.sort();
5260
+ const sortedCurrentTools = serverConfig.flatMap((config) => config.allowedTools).sort();
5261
+ console.log(tools, sortedCurrentTools, "tools");
5262
+ if (tools?.length > 0 && !tools.every((tool, index) => tool === sortedCurrentTools[index])) {
5263
+ throw new ValidationError("MCP server with this name already exists with different tools", {
5264
+ meta: { serverName: name }
5265
+ });
5266
+ }
5267
+ const authConfigDetails2 = await Promise.all(
5268
+ serverConfig.map((config) => this.client.authConfigs.retrieve(config.authConfigId))
5269
+ );
5270
+ const toolkits2 = authConfigDetails2.map((config) => config.toolkit.slug);
5271
+ const camelCaseResponse2 = transformMcpCreateResponse({
5272
+ id: mcpServer.id,
5273
+ name: mcpServer.name,
5274
+ auth_config_ids: serverConfig.map((config) => config.authConfigId),
5275
+ allowed_tools: serverConfig.flatMap((config) => config.allowedTools),
5276
+ managed_auth_via_composio: options.isChatAuth || false,
5277
+ commands: mcpServer.commands,
5278
+ created_at: mcpServer.createdAt,
5279
+ updated_at: mcpServer.updatedAt,
5280
+ mcp_url: mcpServer.mcpUrl
5281
+ });
5282
+ return {
5283
+ ...camelCaseResponse2,
5284
+ toolkits: toolkits2,
5285
+ getServer: async (params) => {
5286
+ return this.getServer(camelCaseResponse2.id, params.userId || "", {
5287
+ isChatAuth: options.isChatAuth
5288
+ });
5289
+ }
5290
+ };
5291
+ } catch (error) {
5292
+ if (error instanceof ValidationError && !error.message.includes("not found")) {
5293
+ throw error;
5294
+ }
5295
+ }
5296
+ const authConfigDetails = await Promise.all(
5297
+ serverConfig.map((config) => this.client.authConfigs.retrieve(config.authConfigId))
5298
+ );
5299
+ const toolkits = authConfigDetails.map((config) => config.toolkit.slug);
5104
5300
  let mcpServerCreatedResponse;
5105
5301
  try {
5106
5302
  mcpServerCreatedResponse = await this.client.mcp.custom.create({
5107
5303
  name,
5108
5304
  toolkits,
5109
- custom_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
5110
- managed_auth_via_composio: authOptions?.useComposioManagedAuth || false,
5111
- auth_config_ids: toolkitConfigs.map((config) => config.authConfigId)
5305
+ custom_tools: serverConfig.flatMap((config) => config.allowedTools),
5306
+ managed_auth_via_composio: options.isChatAuth || false,
5307
+ auth_config_ids: serverConfig.map((config) => config.authConfigId)
5112
5308
  });
5113
5309
  } catch (error) {
5114
5310
  throw new ValidationError("Failed to create MCP server", {
@@ -5126,53 +5322,200 @@ var MCP = class {
5126
5322
  ...camelCaseResponse,
5127
5323
  toolkits,
5128
5324
  getServer: async (params) => {
5129
- return this.getServer(camelCaseResponse.id, params, authOptions);
5325
+ return this.getServer(camelCaseResponse.id, params.userId || "", {
5326
+ isChatAuth: options.isChatAuth
5327
+ });
5130
5328
  }
5131
5329
  };
5132
5330
  }
5133
5331
  /**
5134
- * Get server URLs for an existing MCP server
5135
- * @param {string} id - Server UUID
5136
- * @param {MCPGetServerParams} params - Parameters for getting server URLs
5137
- * @param {MCPAuthOptions} [authOptions] - Authentication options (optional, will use server's default if not provided)
5138
- * @returns {Promise<T>} Transformed server URLs in provider-specific format
5332
+ * Get the connection status of a user for an MCP server
5333
+ *
5334
+ * Checks whether a user has the necessary connected accounts to use all toolkits
5335
+ * configured in the specified MCP server. Returns both overall connection status
5336
+ * and individual status for each toolkit.
5337
+ *
5338
+ * @param {Object} params - Parameters for checking connection status
5339
+ * @param {string} params.id - The UUID of the MCP server to check
5340
+ * @param {string} params.userId - The ID of the user to check connection status for
5341
+ * @returns {Promise<McpUserConnectionStatus>} Complete connection status including:
5342
+ * - `type`: Overall status (CONNECTED if all toolkits are connected, DISCONNECTED otherwise)
5343
+ * - `connected`: Boolean indicating if user can use the MCP server
5344
+ * - `connectedToolkits`: Record mapping each toolkit name to its individual connection status
5345
+ *
5346
+ * @throws {ValidationError} When MCP server has no toolkits configured
5347
+ * @throws {ValidationError} When MCP server retrieval fails
5348
+ *
5349
+ * @example
5350
+ * ```typescript
5351
+ * // Check if user can access an MCP server with Gmail and Slack toolkits
5352
+ * const connectionStatus = await composio.mcp.getUserConnectionStatus('user123', 'mcp-server-uuid');
5353
+ *
5354
+ * if (connectionStatus.connected) {
5355
+ * console.log('User can access all required toolkits');
5356
+ * // connectionStatus.type === ConnectionStatus.CONNECTED
5357
+ * } else {
5358
+ * console.log('User is missing some toolkit connections');
5359
+ * // Check individual toolkit statuses
5360
+ * Object.entries(connectionStatus.connectedToolkits).forEach(([toolkit, status]) => {
5361
+ * if (!status.connected) {
5362
+ * console.log(`Missing connection for toolkit: ${toolkit}`);
5363
+ * }
5364
+ * });
5365
+ * }
5366
+ * ```
5139
5367
  *
5140
5368
  * @example
5141
5369
  * ```typescript
5142
- * // Get URLs for an existing server
5143
- * const urls = await composio.mcp.getServer("server-id", {
5144
- * connectedAccountIds: {
5145
- * gmail: "connected_account_id"
5370
+ * // Example response when user has Gmail connected but missing Slack
5371
+ * {
5372
+ * type: ConnectionStatus.DISCONNECTED,
5373
+ * connected: false,
5374
+ * connectedToolkits: {
5375
+ * GMAIL: {
5376
+ * type: ConnectionStatus.CONNECTED,
5377
+ * connected: true,
5378
+ * toolkit: 'GMAIL',
5379
+ * connectedAccountId: 'conn_gmail_123'
5380
+ * },
5381
+ * SLACK: {
5382
+ * type: ConnectionStatus.DISCONNECTED,
5383
+ * connected: false,
5384
+ * toolkit: 'SLACK'
5385
+ * }
5146
5386
  * }
5147
- * });
5387
+ * }
5148
5388
  * ```
5149
5389
  */
5150
- async getServer(id, params, authOptions) {
5151
- const serverDetails = await this.get(id);
5152
- const paramsResult = MCPGetServerParamsSchema.safeParse(params);
5153
- if (paramsResult.error) {
5154
- throw new ValidationError("Failed to parse get server parameters", {
5155
- cause: paramsResult.error
5390
+ async getUserConnectionStatus(userId, serverId) {
5391
+ const serverDetails = await this.get(serverId);
5392
+ if (!serverDetails.toolkits || serverDetails.toolkits.length === 0) {
5393
+ throw new ValidationError("MCP server has no toolkits configured", {
5394
+ meta: { serverId }
5156
5395
  });
5157
5396
  }
5158
- const toolkits = serverDetails.toolkits || [];
5159
- if (paramsResult.data.connectedAccountIds) {
5160
- const providedToolkits = Object.keys(paramsResult.data.connectedAccountIds);
5161
- const invalidToolkits = providedToolkits.filter((toolkit) => !toolkits.includes(toolkit));
5162
- if (invalidToolkits.length > 0) {
5163
- throw new ValidationError(
5164
- `Invalid toolkits provided: ${invalidToolkits.join(", ")}. Available toolkits are: ${toolkits.join(", ")}`,
5165
- {}
5166
- );
5397
+ const connectedAccounts = await this.client.connectedAccounts.list({
5398
+ user_ids: [userId],
5399
+ toolkit_slugs: serverDetails.toolkits.map((toolkit) => toolkit.toLowerCase()),
5400
+ statuses: ["ACTIVE"]
5401
+ });
5402
+ const connectedAccountsByToolkit = /* @__PURE__ */ new Map();
5403
+ connectedAccounts.items?.forEach((account) => {
5404
+ connectedAccountsByToolkit.set(account.toolkit.slug.toLowerCase(), account.id);
5405
+ });
5406
+ const connectedToolkits = {};
5407
+ let allToolkitsConnected = true;
5408
+ for (const toolkit of serverDetails.toolkits) {
5409
+ const connectedAccountId = connectedAccountsByToolkit.get(toolkit.toLowerCase());
5410
+ if (connectedAccountId) {
5411
+ connectedToolkits[toolkit] = {
5412
+ type: "CONNECTED" /* CONNECTED */,
5413
+ connected: true,
5414
+ toolkit,
5415
+ connectedAccountId
5416
+ };
5417
+ } else {
5418
+ connectedToolkits[toolkit] = {
5419
+ type: "DISCONNECTED" /* DISCONNECTED */,
5420
+ connected: false,
5421
+ toolkit
5422
+ };
5423
+ allToolkitsConnected = false;
5167
5424
  }
5168
5425
  }
5426
+ if (allToolkitsConnected) {
5427
+ return {
5428
+ type: "CONNECTED" /* CONNECTED */,
5429
+ connected: true,
5430
+ connectedToolkits
5431
+ };
5432
+ } else {
5433
+ return {
5434
+ type: "DISCONNECTED" /* DISCONNECTED */,
5435
+ connected: false,
5436
+ connectedToolkits
5437
+ };
5438
+ }
5439
+ }
5440
+ /**
5441
+ * Get the connection parameters for a toolkit
5442
+ * @param {string} serverId - The UUID of the MCP server
5443
+ * @param {string} toolkit - The toolkit to get connection parameters for
5444
+ * @returns {Promise<ToolkitAuthFieldsResponse>} Connection parameters for the toolkit
5445
+ */
5446
+ async getConnectionParams(serverId, toolkit) {
5447
+ const mcpServerDetails = await this.get(serverId);
5448
+ const authConfigs = mcpServerDetails.authConfigIds ? await Promise.all(
5449
+ mcpServerDetails.authConfigIds.map((id) => this.client.authConfigs.retrieve(id))
5450
+ ) : [];
5451
+ const authConfig = authConfigs.find((config) => config.toolkit.slug === toolkit);
5452
+ if (!authConfig) {
5453
+ throw new ValidationError("Auth config not found", {
5454
+ meta: { serverId, toolkit }
5455
+ });
5456
+ }
5457
+ const connectionParams = await this.toolkits.getConnectedAccountInitiationFields(
5458
+ toolkit,
5459
+ authConfig.auth_scheme
5460
+ );
5461
+ return connectionParams;
5462
+ }
5463
+ /**
5464
+ * Authorize a user for a toolkit
5465
+ * @param {string} serverId - The UUID of the MCP server
5466
+ * @param {string} userId - The ID of the user to authorize
5467
+ * @param {string} toolkit - The toolkit to authorize
5468
+ * @returns {Promise<ConnectionRequest>} Connection request for the toolkit
5469
+ */
5470
+ async authorize(userId, serverId, toolkit) {
5471
+ const mcpServerDetails = await this.get(serverId);
5472
+ const authConfigId = mcpServerDetails.authConfigIds?.[0];
5473
+ return this.toolkits.authorize(userId, toolkit, authConfigId);
5474
+ }
5475
+ /**
5476
+ * Get server URLs for an existing MCP server
5477
+ * @param {string} serverId - Server UUID
5478
+ * @param {string} userId - User ID to get server URLs for
5479
+ * @param {Object} [options] - Additional options for server configuration
5480
+ * @param {string[]} [options.limitTools] - Subset of tools to limit (from MCP config)
5481
+ * @param {boolean} [options.isChatAuth] - Whether to use chat-based authentication
5482
+ * @returns {Promise<T>} Transformed server URLs in provider-specific format
5483
+ *
5484
+ * @example
5485
+ * ```typescript
5486
+ * // Get URLs for an existing server with basic user ID
5487
+ * const urls = await composio.mcp.getServer("mcp_xyz", "hey@example.com");
5488
+ *
5489
+ * // Get URLs with additional options
5490
+ * const urls = await composio.mcp.getServer("mcp_xyz", "hey@example.com", {
5491
+ * limitTools: ["GMAIL_FETCH_EMAILS", "SLACK_SEND_MESSAGE"],
5492
+ * isChatAuth: true
5493
+ * });
5494
+ * ```
5495
+ */
5496
+ async getServer(serverId, userId, options) {
5497
+ const serverDetails = await this.get(serverId);
5498
+ if (!userId) {
5499
+ throw new ValidationError("User ID is required", {});
5500
+ }
5501
+ const toolkits = serverDetails.toolkits || [];
5502
+ const connectedAccountIds = (await Promise.all(
5503
+ toolkits.map(
5504
+ (toolkit) => this.client.connectedAccounts.list({
5505
+ user_ids: [userId],
5506
+ toolkit_slugs: [toolkit],
5507
+ statuses: ["ACTIVE"]
5508
+ }).then((res) => res.items?.[0]?.id)
5509
+ )
5510
+ )).filter(Boolean);
5169
5511
  let data;
5170
5512
  try {
5171
5513
  data = await this.client.mcp.generate.url({
5172
- user_ids: paramsResult.data.userId ? [paramsResult.data.userId] : [],
5173
- connected_account_ids: paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : [],
5174
- mcp_server_id: id,
5175
- managed_auth_by_composio: authOptions?.useComposioManagedAuth ?? serverDetails.managedAuthViaComposio ?? false
5514
+ user_ids: [userId],
5515
+ // @TODO(utkarsh-dixit): Add support for this later
5516
+ connected_account_ids: [],
5517
+ mcp_server_id: serverId,
5518
+ managed_auth_by_composio: options?.isChatAuth ?? serverDetails.managedAuthViaComposio ?? false
5176
5519
  });
5177
5520
  } catch (error) {
5178
5521
  throw new ValidationError("Failed to generate MCP server URL", {
@@ -5189,9 +5532,9 @@ var MCP = class {
5189
5532
  return this.wrapMcpServerResponse(
5190
5533
  camelCaseData,
5191
5534
  serverDetails.name,
5192
- paramsResult.data.connectedAccountIds ? Object.values(paramsResult.data.connectedAccountIds) : void 0,
5193
- paramsResult.data.userId ? [paramsResult.data.userId] : void 0,
5194
- paramsResult.data.connectedAccountIds ? Object.keys(paramsResult.data.connectedAccountIds) : void 0
5535
+ connectedAccountIds,
5536
+ [userId],
5537
+ toolkits
5195
5538
  );
5196
5539
  }
5197
5540
  /**
@@ -5226,8 +5569,8 @@ var MCP = class {
5226
5569
  listResponse = await this.client.mcp.list({
5227
5570
  page_no: options.page || 1,
5228
5571
  limit: options.limit || 10,
5229
- toolkits: options?.toolkits?.join(",") || "",
5230
- auth_config_ids: options?.authConfigs?.join(",") || "",
5572
+ toolkits: options?.toolkits?.join(",") || void 0,
5573
+ auth_config_ids: options?.authConfigs?.join(",") || void 0,
5231
5574
  name: options?.name
5232
5575
  });
5233
5576
  } catch (error) {
@@ -5245,7 +5588,7 @@ var MCP = class {
5245
5588
  }
5246
5589
  /**
5247
5590
  * Get details of a specific MCP server
5248
- * @param {string} id - Server UUID
5591
+ * @param {string} serverId - Server UUID
5249
5592
  * @returns {Promise<McpRetrieveResponse>} Server details
5250
5593
  *
5251
5594
  * @example
@@ -5253,16 +5596,19 @@ var MCP = class {
5253
5596
  * const serverDetails = await composio.mcp.get('server-uuid');
5254
5597
  * ```
5255
5598
  */
5256
- async get(id) {
5599
+ async get(serverId) {
5257
5600
  let retrieveResponse;
5258
5601
  try {
5259
- retrieveResponse = await this.client.mcp.retrieve(id);
5602
+ retrieveResponse = await this.client.mcp.retrieve(serverId);
5260
5603
  } catch (error) {
5261
5604
  throw new ValidationError("Failed to retrieve MCP server", {
5262
5605
  cause: error
5263
5606
  });
5264
5607
  }
5265
- const retrieveResponseResult = McpRetrieveResponseSchema.safeParse(retrieveResponse);
5608
+ const retrieveResponseResult = McpRetrieveResponseSchema.safeParse({
5609
+ ...retrieveResponse,
5610
+ mcpUrl: retrieveResponse.mcp_url
5611
+ });
5266
5612
  if (retrieveResponseResult.error) {
5267
5613
  throw new ValidationError("Failed to parse MCP server retrieve response", {
5268
5614
  cause: retrieveResponseResult.error
@@ -5272,7 +5618,7 @@ var MCP = class {
5272
5618
  }
5273
5619
  /**
5274
5620
  * Delete an MCP server
5275
- * @param {string} id - Server UUID
5621
+ * @param {string} serverId - Server UUID
5276
5622
  * @returns {Promise<McpDeleteResponse>} Deletion response
5277
5623
  *
5278
5624
  * @example
@@ -5280,10 +5626,10 @@ var MCP = class {
5280
5626
  * const result = await composio.mcp.delete('server-uuid');
5281
5627
  * ```
5282
5628
  */
5283
- async delete(id) {
5629
+ async delete(serverId) {
5284
5630
  let deleteResponse;
5285
5631
  try {
5286
- deleteResponse = await this.client.mcp.delete(id);
5632
+ deleteResponse = await this.client.mcp.delete(serverId);
5287
5633
  } catch (error) {
5288
5634
  throw new ValidationError("Failed to delete MCP server", {
5289
5635
  cause: error
@@ -5318,21 +5664,21 @@ var MCP = class {
5318
5664
  * },
5319
5665
  * ],
5320
5666
  * {
5321
- * useComposioManagedAuth: true,
5667
+ * isChatAuth: true,
5322
5668
  * }
5323
5669
  * );
5324
5670
  * ```
5325
5671
  */
5326
- async update(id, name, toolkitConfigs, authOptions) {
5672
+ async update(serverId, name, toolkitConfigs, authOptions) {
5327
5673
  this.validateInputs(toolkitConfigs, authOptions);
5328
5674
  const toolkits = toolkitConfigs.map((config) => config.toolkit);
5329
5675
  let updateResponse;
5330
5676
  try {
5331
- updateResponse = await this.client.mcp.update(id, {
5677
+ updateResponse = await this.client.mcp.update(serverId, {
5332
5678
  name,
5333
5679
  toolkits,
5334
5680
  allowed_tools: toolkitConfigs.flatMap((config) => config.allowedTools),
5335
- managed_auth_via_composio: authOptions?.useComposioManagedAuth || false
5681
+ managed_auth_via_composio: authOptions?.isChatAuth || false
5336
5682
  });
5337
5683
  } catch (error) {
5338
5684
  throw new ValidationError("Failed to update MCP server", {
@@ -5349,20 +5695,20 @@ var MCP = class {
5349
5695
  }
5350
5696
  /**
5351
5697
  * Generate URL for an MCP server
5698
+ * @param {string} serverId - Server UUID
5352
5699
  * @param {GenerateURLParams} params - Parameters for URL generation
5353
5700
  * @returns {Promise<GenerateURLResponse>} Generated URL response
5354
5701
  *
5355
5702
  * @example
5356
5703
  * ```typescript
5357
- * const urlResponse = await composio.mcp.generateUrl({
5704
+ * const urlResponse = await composio.mcp.generateUrl('server-uuid', {
5358
5705
  * userIds: ['user123'],
5359
5706
  * connectedAccountIds: ['account456'],
5360
- * mcpServerId: 'server-uuid',
5361
- * composioManagedAuth: true
5707
+ * isChatAuth: true
5362
5708
  * });
5363
5709
  * ```
5364
5710
  */
5365
- async generateUrl(params) {
5711
+ async generateUrl(serverId, params) {
5366
5712
  const paramsResult = GenerateURLParamsSchema.safeParse(params);
5367
5713
  if (paramsResult.error) {
5368
5714
  throw new ValidationError("Failed to parse generateUrl parameters", {
@@ -5372,7 +5718,7 @@ var MCP = class {
5372
5718
  let urlResponse;
5373
5719
  try {
5374
5720
  urlResponse = await this.client.mcp.generate.url({
5375
- mcp_server_id: params.mcpServerId,
5721
+ mcp_server_id: serverId,
5376
5722
  user_ids: params.userIds,
5377
5723
  connected_account_ids: params.connectedAccountIds,
5378
5724
  managed_auth_by_composio: params.composioManagedAuth
@@ -5442,6 +5788,48 @@ var MCP = class {
5442
5788
  name: serverName
5443
5789
  };
5444
5790
  }
5791
+ /**
5792
+ * Get details of a specific MCP server by name
5793
+ * @param {string} name - Server name
5794
+ * @returns {Promise<McpRetrieveResponse>} Server details
5795
+ * @throws {ValidationError} If no server found with the given name
5796
+ * @throws {ValidationError} If multiple servers found with the same name
5797
+ *
5798
+ * @example
5799
+ * ```typescript
5800
+ * const serverDetails = await composio.mcp.getByName('my-gmail-server');
5801
+ * ```
5802
+ */
5803
+ async getByName(serverName) {
5804
+ if (!serverName) {
5805
+ throw new ValidationError("Server name is required", {});
5806
+ }
5807
+ let listResponse;
5808
+ try {
5809
+ listResponse = await this.client.mcp.list({
5810
+ name: serverName,
5811
+ limit: 10
5812
+ });
5813
+ } catch (error) {
5814
+ console.error(error);
5815
+ throw new ValidationError("Failed to search MCP servers by name", {
5816
+ cause: error
5817
+ });
5818
+ }
5819
+ const listResponseResult = ComposioMcpListResponseSchema.safeParse(listResponse);
5820
+ if (listResponseResult.error) {
5821
+ throw new ValidationError("Failed to parse MCP server list response", {
5822
+ cause: listResponseResult.error
5823
+ });
5824
+ }
5825
+ const servers = listResponse.items || [];
5826
+ if (servers.length === 0) {
5827
+ throw new ValidationError(`MCP server with name '${serverName}' not found`, {
5828
+ meta: { serverName }
5829
+ });
5830
+ }
5831
+ return this.get(servers[0].id);
5832
+ }
5445
5833
  };
5446
5834
 
5447
5835
  // src/utils/sdk.ts
@@ -5700,6 +6088,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5700
6088
  arguments: JSON.parse(tool.function.arguments),
5701
6089
  connectedAccountId: options?.connectedAccountId,
5702
6090
  customAuthParams: options?.customAuthParams,
6091
+ customConnectionData: options?.customConnectionData,
5703
6092
  userId
5704
6093
  };
5705
6094
  const result = await this.executeTool(tool.function.name, payload, modifiers);
@@ -5981,7 +6370,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
5981
6370
  };
5982
6371
 
5983
6372
  // package.json
5984
- var version = "0.1.36-next.8";
6373
+ var version = "0.1.36";
5985
6374
 
5986
6375
  // src/models/Files.ts
5987
6376
  var Files = class {
@@ -6423,6 +6812,7 @@ export {
6423
6812
  ConnectionRequestErrorCodes,
6424
6813
  ConnectionRequestFailedError,
6425
6814
  ConnectionRequestTimeoutError,
6815
+ ConnectionStatus,
6426
6816
  ConnectionStatuses,
6427
6817
  CreateAuthConfigParamsSchema,
6428
6818
  CreateAuthConfigResponseSchema,
@@ -6432,7 +6822,10 @@ export {
6432
6822
  CreateConnectedAccountResponseSchema,
6433
6823
  CreateCustomAuthConfigParamsSchema,
6434
6824
  CustomAuthParamsSchema,
6825
+ CustomConnectionDataSchema,
6435
6826
  CustomCreateResponseSchema,
6827
+ CustomOauth1ConnectionDataSchema,
6828
+ CustomOauth2ConnectionDataSchema,
6436
6829
  DefaultCreateConnectedAccountParamsSchema,
6437
6830
  GenerateURLParamsSchema,
6438
6831
  GenerateURLResponseSchema,
@@ -6459,12 +6852,14 @@ export {
6459
6852
  Oauth1ConnectionDataSchema,
6460
6853
  Oauth1ExpiredConnectionDataSchema,
6461
6854
  Oauth1FailedConnectionDataSchema,
6855
+ Oauth1InactiveConnectionDataSchema,
6462
6856
  Oauth1InitiatedConnectionDataSchema,
6463
6857
  Oauth1InitiatingConnectionDataSchema,
6464
6858
  Oauth2ActiveConnectionDataSchema,
6465
6859
  Oauth2ConnectionDataSchema,
6466
6860
  Oauth2ExpiredConnectionDataSchema,
6467
6861
  Oauth2FailedConnectionDataSchema,
6862
+ Oauth2InactiveConnectionDataSchema,
6468
6863
  Oauth2InitiatedConnectionDataSchema,
6469
6864
  Oauth2InitiatingConnectionDataSchema,
6470
6865
  OpenAIProvider,