@composio/client 0.1.0-alpha.27 → 0.1.0-alpha.29

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/src/client.ts CHANGED
@@ -301,7 +301,7 @@ export class Composio {
301
301
  * Create a new client instance re-using the same options given to the current client with optional overriding.
302
302
  */
303
303
  withOptions(options: Partial<ClientOptions>): this {
304
- return new (this.constructor as any as new (props: ClientOptions) => typeof this)({
304
+ const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
305
305
  ...this._options,
306
306
  environment: options.environment ? options.environment : undefined,
307
307
  baseURL: options.environment ? undefined : this.baseURL,
@@ -314,6 +314,7 @@ export class Composio {
314
314
  apiKey: this.apiKey,
315
315
  ...options,
316
316
  });
317
+ return client;
317
318
  }
318
319
 
319
320
  /**
@@ -331,7 +332,7 @@ export class Composio {
331
332
  return;
332
333
  }
333
334
 
334
- protected authHeaders(opts: FinalRequestOptions): NullableHeaders | undefined {
335
+ protected async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
335
336
  if (this.apiKey == null) {
336
337
  return undefined;
337
338
  }
@@ -450,7 +451,9 @@ export class Composio {
450
451
 
451
452
  await this.prepareOptions(options);
452
453
 
453
- const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining });
454
+ const { req, url, timeout } = await this.buildRequest(options, {
455
+ retryCount: maxRetries - retriesRemaining,
456
+ });
454
457
 
455
458
  await this.prepareRequest(req, { url, options });
456
459
 
@@ -528,7 +531,7 @@ export class Composio {
528
531
  } with status ${response.status} in ${headersTime - startTime}ms`;
529
532
 
530
533
  if (!response.ok) {
531
- const shouldRetry = this.shouldRetry(response);
534
+ const shouldRetry = await this.shouldRetry(response);
532
535
  if (retriesRemaining && shouldRetry) {
533
536
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
534
537
 
@@ -627,7 +630,7 @@ export class Composio {
627
630
  }
628
631
  }
629
632
 
630
- private shouldRetry(response: Response): boolean {
633
+ private async shouldRetry(response: Response): Promise<boolean> {
631
634
  // Note this is not a standard header.
632
635
  const shouldRetryHeader = response.headers.get('x-should-retry');
633
636
 
@@ -704,10 +707,10 @@ export class Composio {
704
707
  return sleepSeconds * jitter * 1000;
705
708
  }
706
709
 
707
- buildRequest(
710
+ async buildRequest(
708
711
  inputOptions: FinalRequestOptions,
709
712
  { retryCount = 0 }: { retryCount?: number } = {},
710
- ): { req: FinalizedRequestInit; url: string; timeout: number } {
713
+ ): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
711
714
  const options = { ...inputOptions };
712
715
  const { method, path, query, defaultBaseURL } = options;
713
716
 
@@ -715,7 +718,7 @@ export class Composio {
715
718
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
716
719
  options.timeout = options.timeout ?? this.timeout;
717
720
  const { bodyHeaders, body } = this.buildBody({ options });
718
- const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
721
+ const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
719
722
 
720
723
  const req: FinalizedRequestInit = {
721
724
  method,
@@ -731,7 +734,7 @@ export class Composio {
731
734
  return { req, url, timeout: options.timeout };
732
735
  }
733
736
 
734
- private buildHeaders({
737
+ private async buildHeaders({
735
738
  options,
736
739
  method,
737
740
  bodyHeaders,
@@ -741,7 +744,7 @@ export class Composio {
741
744
  method: HTTPMethod;
742
745
  bodyHeaders: HeadersLike;
743
746
  retryCount: number;
744
- }): Headers {
747
+ }): Promise<Headers> {
745
748
  let idempotencyHeaders: HeadersLike = {};
746
749
  if (this.idempotencyHeader && method !== 'get') {
747
750
  if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
@@ -757,7 +760,7 @@ export class Composio {
757
760
  ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
758
761
  ...getPlatformHeaders(),
759
762
  },
760
- this.authHeaders(options),
763
+ await this.authHeaders(options),
761
764
  this._options.defaultHeaders,
762
765
  bodyHeaders,
763
766
  options.headers,
@@ -166,6 +166,8 @@ export interface AuthConfigRetrieveResponse {
166
166
  */
167
167
  status: 'ENABLED' | 'DISABLED';
168
168
 
169
+ tool_access_config: AuthConfigRetrieveResponse.ToolAccessConfig;
170
+
169
171
  /**
170
172
  * Information about the associated integration
171
173
  */
@@ -227,11 +229,6 @@ export interface AuthConfigRetrieveResponse {
227
229
  * ISO 8601 date-time when the auth config was last updated
228
230
  */
229
231
  last_updated_at?: string;
230
-
231
- /**
232
- * List of tool IDs this auth config is restricted to use with
233
- */
234
- restrict_to_following_tools?: Array<string>;
235
232
  }
236
233
 
237
234
  export namespace AuthConfigRetrieveResponse {
@@ -260,6 +257,20 @@ export namespace AuthConfigRetrieveResponse {
260
257
  toolkit_id?: string;
261
258
  }
262
259
 
260
+ export interface ToolAccessConfig {
261
+ /**
262
+ * The actions that the user can perform on the auth config. If passed, this will
263
+ * update the actions that the user can perform on the auth config.
264
+ */
265
+ tools_available_for_execution?: Array<string>;
266
+
267
+ /**
268
+ * Tools used to generate the minimum required scopes for the auth config (only
269
+ * valid for OAuth). If passed, this will update the scopes.
270
+ */
271
+ tools_for_connected_account_creation?: Array<string>;
272
+ }
273
+
263
274
  /**
264
275
  * Information about the associated integration
265
276
  */
@@ -317,6 +328,8 @@ export namespace AuthConfigListResponse {
317
328
  */
318
329
  status: 'ENABLED' | 'DISABLED';
319
330
 
331
+ tool_access_config: Item.ToolAccessConfig;
332
+
320
333
  /**
321
334
  * Information about the associated integration
322
335
  */
@@ -378,11 +391,6 @@ export namespace AuthConfigListResponse {
378
391
  * ISO 8601 date-time when the auth config was last updated
379
392
  */
380
393
  last_updated_at?: string;
381
-
382
- /**
383
- * List of tool IDs this auth config is restricted to use with
384
- */
385
- restrict_to_following_tools?: Array<string>;
386
394
  }
387
395
 
388
396
  export namespace Item {
@@ -411,6 +419,20 @@ export namespace AuthConfigListResponse {
411
419
  toolkit_id?: string;
412
420
  }
413
421
 
422
+ export interface ToolAccessConfig {
423
+ /**
424
+ * The actions that the user can perform on the auth config. If passed, this will
425
+ * update the actions that the user can perform on the auth config.
426
+ */
427
+ tools_available_for_execution?: Array<string>;
428
+
429
+ /**
430
+ * Tools used to generate the minimum required scopes for the auth config (only
431
+ * valid for OAuth). If passed, this will update the scopes.
432
+ */
433
+ tools_for_connected_account_creation?: Array<string>;
434
+ }
435
+
414
436
  /**
415
437
  * Information about the associated integration
416
438
  */
@@ -456,10 +478,17 @@ export namespace AuthConfigCreateParams {
456
478
  */
457
479
  name?: string;
458
480
 
459
- /**
460
- * The actions that the user can perform on the auth config
461
- */
462
- restrict_to_following_tools?: Array<string>;
481
+ tool_access_config?: UnionMember0.ToolAccessConfig;
482
+ }
483
+
484
+ export namespace UnionMember0 {
485
+ export interface ToolAccessConfig {
486
+ /**
487
+ * Tools used to generate the minimum required scopes for the auth config (only
488
+ * valid for OAuth). If passed, this will update the scopes.
489
+ */
490
+ tools_for_connected_account_creation?: Array<string>;
491
+ }
463
492
  }
464
493
 
465
494
  export interface UnionMember1 {
@@ -487,10 +516,7 @@ export namespace AuthConfigCreateParams {
487
516
 
488
517
  proxy_config?: UnionMember1.ProxyConfig;
489
518
 
490
- /**
491
- * The actions that the user can perform on the auth config
492
- */
493
- restrict_to_following_tools?: Array<string>;
519
+ tool_access_config?: UnionMember1.ToolAccessConfig;
494
520
  }
495
521
 
496
522
  export namespace UnionMember1 {
@@ -505,6 +531,14 @@ export namespace AuthConfigCreateParams {
505
531
  */
506
532
  proxy_auth_key?: string;
507
533
  }
534
+
535
+ export interface ToolAccessConfig {
536
+ /**
537
+ * Tools used to generate the minimum required scopes for the auth config (only
538
+ * valid for OAuth). If passed, this will update the scopes.
539
+ */
540
+ tools_for_connected_account_creation?: Array<string>;
541
+ }
508
542
  }
509
543
  }
510
544
 
@@ -516,15 +550,47 @@ export declare namespace AuthConfigUpdateParams {
516
550
 
517
551
  type: 'custom';
518
552
 
519
- restrict_to_following_tools?: Array<string>;
553
+ tool_access_config?: Variant0.ToolAccessConfig;
520
554
  }
521
555
 
522
- export interface Variant1 {
523
- scopes: string;
556
+ export namespace Variant0 {
557
+ export interface ToolAccessConfig {
558
+ /**
559
+ * The actions that the user can perform on the auth config. If passed, this will
560
+ * update the actions that the user can perform on the auth config.
561
+ */
562
+ tools_available_for_execution?: Array<string>;
563
+
564
+ /**
565
+ * Tools used to generate the minimum required scopes for the auth config (only
566
+ * valid for OAuth). If passed, this will update the scopes.
567
+ */
568
+ tools_for_connected_account_creation?: Array<string>;
569
+ }
570
+ }
524
571
 
572
+ export interface Variant1 {
525
573
  type: 'default';
526
574
 
527
- restrict_to_following_tools?: Array<string>;
575
+ scopes?: string;
576
+
577
+ tool_access_config?: Variant1.ToolAccessConfig;
578
+ }
579
+
580
+ export namespace Variant1 {
581
+ export interface ToolAccessConfig {
582
+ /**
583
+ * The actions that the user can perform on the auth config. If passed, this will
584
+ * update the actions that the user can perform on the auth config.
585
+ */
586
+ tools_available_for_execution?: Array<string>;
587
+
588
+ /**
589
+ * Tools used to generate the minimum required scopes for the auth config (only
590
+ * valid for OAuth). If passed, this will update the scopes.
591
+ */
592
+ tools_for_connected_account_creation?: Array<string>;
593
+ }
528
594
  }
529
595
  }
530
596
 
@@ -554,13 +620,18 @@ export interface AuthConfigListParams {
554
620
  */
555
621
  limit?: number | null;
556
622
 
623
+ /**
624
+ * Search auth configs by name
625
+ */
626
+ search?: string;
627
+
557
628
  /**
558
629
  * Show disabled auth configs
559
630
  */
560
- show_disabled?: boolean;
631
+ show_disabled?: boolean | null;
561
632
 
562
633
  /**
563
- * The slug of the toolkit to filter by
634
+ * Comma-separated list of toolkit slugs to filter auth configs by
564
635
  */
565
636
  toolkit_slug?: string;
566
637
  }
@@ -690,7 +690,7 @@ export namespace ConnectedAccountCreateResponse {
690
690
 
691
691
  proxy_username?: string;
692
692
 
693
- refresh_token?: string;
693
+ refresh_token?: string | null;
694
694
 
695
695
  region?: string;
696
696
 
@@ -780,7 +780,7 @@ export namespace ConnectedAccountCreateResponse {
780
780
 
781
781
  proxy_username?: string;
782
782
 
783
- refresh_token?: string;
783
+ refresh_token?: string | null;
784
784
 
785
785
  region?: string;
786
786
 
@@ -3381,7 +3381,7 @@ export namespace ConnectedAccountRetrieveResponse {
3381
3381
 
3382
3382
  proxy_username?: string;
3383
3383
 
3384
- refresh_token?: string;
3384
+ refresh_token?: string | null;
3385
3385
 
3386
3386
  region?: string;
3387
3387
 
@@ -3471,7 +3471,7 @@ export namespace ConnectedAccountRetrieveResponse {
3471
3471
 
3472
3472
  proxy_username?: string;
3473
3473
 
3474
- refresh_token?: string;
3474
+ refresh_token?: string | null;
3475
3475
 
3476
3476
  region?: string;
3477
3477
 
@@ -6092,7 +6092,7 @@ export namespace ConnectedAccountListResponse {
6092
6092
 
6093
6093
  proxy_username?: string;
6094
6094
 
6095
- refresh_token?: string;
6095
+ refresh_token?: string | null;
6096
6096
 
6097
6097
  region?: string;
6098
6098
 
@@ -6182,7 +6182,7 @@ export namespace ConnectedAccountListResponse {
6182
6182
 
6183
6183
  proxy_username?: string;
6184
6184
 
6185
- refresh_token?: string;
6185
+ refresh_token?: string | null;
6186
6186
 
6187
6187
  region?: string;
6188
6188
 
@@ -8787,7 +8787,7 @@ export namespace ConnectedAccountCreateParams {
8787
8787
 
8788
8788
  proxy_username?: string;
8789
8789
 
8790
- refresh_token?: string;
8790
+ refresh_token?: string | null;
8791
8791
 
8792
8792
  region?: string;
8793
8793
 
@@ -8877,7 +8877,7 @@ export namespace ConnectedAccountCreateParams {
8877
8877
 
8878
8878
  proxy_username?: string;
8879
8879
 
8880
- refresh_token?: string;
8880
+ refresh_token?: string | null;
8881
8881
 
8882
8882
  region?: string;
8883
8883
 
@@ -403,7 +403,7 @@ export interface McpListResponse {
403
403
  /**
404
404
  * Current page number being returned
405
405
  */
406
- current_page: string;
406
+ current_page: number;
407
407
 
408
408
  /**
409
409
  * Array of MCP server configurations
@@ -413,7 +413,7 @@ export interface McpListResponse {
413
413
  /**
414
414
  * Total number of pages in the paginated response
415
415
  */
416
- total_pages: string;
416
+ total_pages: number;
417
417
  }
418
418
 
419
419
  export namespace McpListResponse {
@@ -514,7 +514,7 @@ export interface McpRetrieveAppResponse {
514
514
  /**
515
515
  * Current page number being returned
516
516
  */
517
- current_page: string;
517
+ current_page: number;
518
518
 
519
519
  /**
520
520
  * Array of MCP server configurations
@@ -524,7 +524,7 @@ export interface McpRetrieveAppResponse {
524
524
  /**
525
525
  * Total number of pages in the paginated response
526
526
  */
527
- total_pages: string;
527
+ total_pages: number;
528
528
  }
529
529
 
530
530
  export namespace McpRetrieveAppResponse {
@@ -81,14 +81,27 @@ export interface ToolkitRetrieveResponse {
81
81
  */
82
82
  auth_config_details?: Array<ToolkitRetrieveResponse.AuthConfigDetail>;
83
83
 
84
+ /**
85
+ * If evaluation of base URL needs some connection info (like shopify), please
86
+ * create the connection and get the base URL from there
87
+ */
88
+ base_url?: string;
89
+
84
90
  /**
85
91
  * List of authentication methods that Composio manages for this toolkit
86
92
  */
87
93
  composio_managed_auth_schemes?: Array<string>;
94
+
95
+ /**
96
+ * Endpoint to get the current user
97
+ */
98
+ get_current_user_endpoint?: string;
88
99
  }
89
100
 
90
101
  export namespace ToolkitRetrieveResponse {
91
102
  export interface Deprecated {
103
+ rawProxyInfoByAuthSchemes: Array<{ [key: string]: unknown }>;
104
+
92
105
  toolkitId: string;
93
106
 
94
107
  getCurrentUserEndpoint?: string;
@@ -219,6 +232,8 @@ export namespace ToolkitRetrieveResponse {
219
232
  type: string;
220
233
 
221
234
  default?: string | null;
235
+
236
+ legacy_template_name?: string;
222
237
  }
223
238
 
224
239
  export interface Required {
@@ -233,6 +248,8 @@ export namespace ToolkitRetrieveResponse {
233
248
  type: string;
234
249
 
235
250
  default?: string | null;
251
+
252
+ legacy_template_name?: string;
236
253
  }
237
254
  }
238
255
 
@@ -259,6 +276,8 @@ export namespace ToolkitRetrieveResponse {
259
276
  type: string;
260
277
 
261
278
  default?: string | null;
279
+
280
+ legacy_template_name?: string;
262
281
  }
263
282
 
264
283
  export interface Required {
@@ -273,6 +292,8 @@ export namespace ToolkitRetrieveResponse {
273
292
  type: string;
274
293
 
275
294
  default?: string | null;
295
+
296
+ legacy_template_name?: string;
276
297
  }
277
298
  }
278
299
  }