@composio/core 0.1.12-alpha.7 → 0.1.12-alpha.8
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/README.md +20 -0
- package/dist/index.cjs +540 -142
- package/dist/index.d.cts +926 -124
- package/dist/index.d.ts +926 -124
- package/dist/index.js +540 -142
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import { ToolProxyParams, ToolProxyResponse, ToolRetrieveEnumResponse, ToolGetIn
|
|
|
4
4
|
import { RequestOptions } from '@composio/client/internal/request-options';
|
|
5
5
|
import { TriggerInstanceListActiveParams, TriggerInstanceUpsertParams, TriggerInstanceUpsertResponse, TriggerInstanceRemoveUpsertResponse, TriggerInstanceUpdateStatusParams, TriggersTypeListParams, TriggersTypeListResponse, TriggersTypeRetrieveResponse, TriggersTypeRetrieveEnumResponse } from '@composio/client/resources/index';
|
|
6
6
|
import { AuthConfigUpdateResponse, AuthConfigDeleteResponse, AuthConfigUpdateStatusResponse } from '@composio/client/resources/auth-configs';
|
|
7
|
-
import {
|
|
7
|
+
import { ConnectedAccountRetrieveResponse as ConnectedAccountRetrieveResponse$1, ConnectedAccountListResponse as ConnectedAccountListResponse$1, ConnectedAccountDeleteResponse, ConnectedAccountRefreshResponse, ConnectedAccountUpdateStatusParams, ConnectedAccountUpdateStatusResponse } from '@composio/client/resources/connected-accounts';
|
|
8
8
|
import { OpenAI } from 'openai';
|
|
9
9
|
import { Stream } from 'openai/streaming';
|
|
10
10
|
|
|
@@ -359,47 +359,294 @@ declare abstract class BaseAgenticProvider<TToolCollection, TTool> extends BaseP
|
|
|
359
359
|
type BaseComposioProvider<TToolCollection, TTool> = BaseNonAgenticProvider<TToolCollection, TTool> | BaseAgenticProvider<TToolCollection, TTool>;
|
|
360
360
|
|
|
361
361
|
/**
|
|
362
|
-
* Modifier for altering the tool execute
|
|
363
|
-
*
|
|
362
|
+
* Modifier for altering the tool execute parameters before execution.
|
|
363
|
+
*
|
|
364
|
+
* This function allows you to intercept and modify the parameters being passed to a tool
|
|
365
|
+
* before the actual execution happens. Common use cases include:
|
|
366
|
+
* - Adding or modifying authentication parameters
|
|
367
|
+
* - Transforming input data to match expected formats
|
|
368
|
+
* - Adding contextual information to the request
|
|
369
|
+
* - Implementing request validation or normalization
|
|
370
|
+
*
|
|
371
|
+
* @param {string} toolSlug - The slug identifier of the tool being executed
|
|
372
|
+
* @param {string} toolkitSlug - The slug identifier of the toolkit containing the tool
|
|
373
|
+
* @param {ToolExecuteParams} toolExecuteParams - The original execution parameters
|
|
374
|
+
* @returns {ToolExecuteParams} The modified execution parameters
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* // Add authentication headers to all tool requests
|
|
379
|
+
* const beforeToolExecute = (toolSlug, toolkitSlug, params) => {
|
|
380
|
+
* return {
|
|
381
|
+
* ...params,
|
|
382
|
+
* customAuthParams: {
|
|
383
|
+
* ...params.customAuthParams,
|
|
384
|
+
* headers: {
|
|
385
|
+
* ...params.customAuthParams?.headers,
|
|
386
|
+
* 'X-API-Key': 'my-api-key'
|
|
387
|
+
* }
|
|
388
|
+
* }
|
|
389
|
+
* };
|
|
390
|
+
* };
|
|
391
|
+
*
|
|
392
|
+
* // Transform input parameters for a specific tool
|
|
393
|
+
* const beforeToolExecute = (toolSlug, toolkitSlug, params) => {
|
|
394
|
+
* if (toolSlug === 'GITHUB_SEARCH_REPOS') {
|
|
395
|
+
* // Convert simple query to structured query format
|
|
396
|
+
* return {
|
|
397
|
+
* ...params,
|
|
398
|
+
* arguments: {
|
|
399
|
+
* ...params.arguments,
|
|
400
|
+
* q: `${params.arguments.query} in:name,description`
|
|
401
|
+
* }
|
|
402
|
+
* };
|
|
403
|
+
* }
|
|
404
|
+
* return params;
|
|
405
|
+
* };
|
|
406
|
+
* ```
|
|
364
407
|
*/
|
|
365
408
|
type BeforeToolExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteParams: ToolExecuteParams) => ToolExecuteParams;
|
|
366
409
|
/**
|
|
367
|
-
* Modifier for altering the tool
|
|
368
|
-
*
|
|
410
|
+
* Modifier for altering the tool execution response after execution completes.
|
|
411
|
+
*
|
|
412
|
+
* This function allows you to intercept and modify the response returned from a tool
|
|
413
|
+
* after its execution has completed. Common use cases include:
|
|
414
|
+
* - Transforming response data into a more convenient format
|
|
415
|
+
* - Handling or enhancing error responses
|
|
416
|
+
* - Adding additional context or derived data to successful responses
|
|
417
|
+
* - Implementing cross-cutting concerns like logging or analytics
|
|
418
|
+
*
|
|
419
|
+
* @param {string} toolSlug - The slug identifier of the tool that was executed
|
|
420
|
+
* @param {string} toolkitSlug - The slug identifier of the toolkit containing the tool
|
|
421
|
+
* @param {ToolExecuteResponse} toolExecuteResponse - The original execution response
|
|
422
|
+
* @returns {ToolExecuteResponse} The modified execution response
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```typescript
|
|
426
|
+
* // Transform the response data format
|
|
427
|
+
* const afterToolExecute = (toolSlug, toolkitSlug, response) => {
|
|
428
|
+
* if (toolSlug === 'GITHUB_LIST_REPOS' && response.successful) {
|
|
429
|
+
* // Transform the returned repos into a simpler format
|
|
430
|
+
* return {
|
|
431
|
+
* ...response,
|
|
432
|
+
* data: {
|
|
433
|
+
* repositories: response.data.items.map(repo => ({
|
|
434
|
+
* name: repo.name,
|
|
435
|
+
* url: repo.html_url,
|
|
436
|
+
* stars: repo.stargazers_count
|
|
437
|
+
* }))
|
|
438
|
+
* }
|
|
439
|
+
* };
|
|
440
|
+
* }
|
|
441
|
+
* return response;
|
|
442
|
+
* };
|
|
443
|
+
*
|
|
444
|
+
* // Add error handling with custom messages
|
|
445
|
+
* const afterToolExecute = (toolSlug, toolkitSlug, response) => {
|
|
446
|
+
* if (!response.successful) {
|
|
447
|
+
* return {
|
|
448
|
+
* ...response,
|
|
449
|
+
* error: {
|
|
450
|
+
* message: `Error using ${toolSlug}: ${response.error?.message || 'Unknown error'}`,
|
|
451
|
+
* code: response.error?.code || 'UNKNOWN_ERROR'
|
|
452
|
+
* }
|
|
453
|
+
* };
|
|
454
|
+
* }
|
|
455
|
+
* return response;
|
|
456
|
+
* };
|
|
457
|
+
* ```
|
|
369
458
|
*/
|
|
370
459
|
type AfterToolExecuteModifier = (toolSlug: string, toolkitSlug: string, toolExecuteResponse: ToolExecuteResponse) => ToolExecuteResponse;
|
|
371
460
|
/**
|
|
372
|
-
* Modifier for altering the tool schema
|
|
373
|
-
*
|
|
461
|
+
* Modifier for altering the tool schema before it's exposed to consumers.
|
|
462
|
+
*
|
|
463
|
+
* This function allows you to customize the metadata, parameters, and behavior definitions
|
|
464
|
+
* of tools before they are used. Common use cases include:
|
|
465
|
+
* - Customizing input parameter definitions or descriptions
|
|
466
|
+
* - Adding, removing, or modifying parameters to match your application's needs
|
|
467
|
+
* - Changing the name or description of tools to better fit your context
|
|
468
|
+
* - Implementing versioning or feature flagging for tool schemas
|
|
469
|
+
*
|
|
470
|
+
* @param {string} toolSlug - The slug identifier of the tool being modified
|
|
471
|
+
* @param {string} toolkitSlug - The slug identifier of the toolkit containing the tool
|
|
472
|
+
* @param {Tool} toolSchema - The original tool schema
|
|
473
|
+
* @returns {Tool} The modified tool schema
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* // Modify the input parameters for a specific tool
|
|
478
|
+
* const modifyToolSchema = (toolSlug, toolkitSlug, toolSchema) => {
|
|
479
|
+
* if (toolSlug === 'HACKERNEWS_GET_USER') {
|
|
480
|
+
* return {
|
|
481
|
+
* ...toolSchema,
|
|
482
|
+
* inputParameters: {
|
|
483
|
+
* ...toolSchema.inputParameters,
|
|
484
|
+
* userId: {
|
|
485
|
+
* type: 'string',
|
|
486
|
+
* description: 'The HackerNews username to retrieve information for',
|
|
487
|
+
* required: true
|
|
488
|
+
* }
|
|
489
|
+
* }
|
|
490
|
+
* };
|
|
491
|
+
* }
|
|
492
|
+
* return toolSchema;
|
|
493
|
+
* };
|
|
494
|
+
*
|
|
495
|
+
* // Add custom descriptions to all tools in a toolkit
|
|
496
|
+
* const modifyToolSchema = (toolSlug, toolkitSlug, toolSchema) => {
|
|
497
|
+
* if (toolkitSlug === 'github') {
|
|
498
|
+
* return {
|
|
499
|
+
* ...toolSchema,
|
|
500
|
+
* description: `Company GitHub tool: ${toolSchema.description}`,
|
|
501
|
+
* important: true
|
|
502
|
+
* };
|
|
503
|
+
* }
|
|
504
|
+
* return toolSchema;
|
|
505
|
+
* };
|
|
506
|
+
*
|
|
507
|
+
* // Simplify tool schemas for a specific consumer
|
|
508
|
+
* const modifyToolSchema = (toolSlug, toolkitSlug, toolSchema) => {
|
|
509
|
+
* // Remove advanced or complex parameters
|
|
510
|
+
* const { complexParam1, complexParam2, ...simpleInputParams } = toolSchema.inputParameters;
|
|
511
|
+
*
|
|
512
|
+
* return {
|
|
513
|
+
* ...toolSchema,
|
|
514
|
+
* inputParameters: simpleInputParams
|
|
515
|
+
* };
|
|
516
|
+
* };
|
|
517
|
+
* ```
|
|
374
518
|
*/
|
|
375
519
|
type TransformToolSchemaModifier = (toolSlug: string, toolkitSlug: string, toolSchema: Tool) => Tool;
|
|
376
520
|
/**
|
|
377
|
-
*
|
|
521
|
+
* Options for non-agentic tool configuration.
|
|
522
|
+
*
|
|
523
|
+
* These options are used when working with non-agentic tool providers to
|
|
524
|
+
* customize the behavior of tools through schema transformation.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* // Configure tools with schema modification
|
|
529
|
+
* const tools = await composio.tools.get('default', {
|
|
530
|
+
* toolkits: ['github']
|
|
531
|
+
* }, {
|
|
532
|
+
* modifyToolSchema: (toolSlug, toolkitSlug, schema) => {
|
|
533
|
+
* // Custom schema modifications
|
|
534
|
+
* return schema;
|
|
535
|
+
* }
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
378
538
|
*/
|
|
379
539
|
type ToolOptions = {
|
|
380
540
|
/**
|
|
381
|
-
*
|
|
541
|
+
* Function to transform tool schemas before they're exposed to consumers.
|
|
542
|
+
* This allows customizing input/output parameters, descriptions, and other metadata.
|
|
382
543
|
*/
|
|
383
544
|
modifyToolSchema?: TransformToolSchemaModifier;
|
|
384
545
|
};
|
|
385
546
|
/**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
547
|
+
* Options for configuring tool execution behavior.
|
|
548
|
+
*
|
|
549
|
+
* These modifiers allow you to intercept and modify tool execution at both
|
|
550
|
+
* the request and response stages, enabling custom behavior, data transformation,
|
|
551
|
+
* error handling, and more.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* // Execute a tool with request and response modifications
|
|
556
|
+
* const result = await composio.tools.execute('GITHUB_GET_REPOS', {
|
|
557
|
+
* userId: 'default',
|
|
558
|
+
* arguments: { owner: 'composio' }
|
|
559
|
+
* }, {
|
|
560
|
+
* beforeToolExecute: (toolSlug, toolkitSlug, params) => {
|
|
561
|
+
* console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
|
|
562
|
+
* return params;
|
|
563
|
+
* },
|
|
564
|
+
* afterToolExecute: (toolSlug, toolkitSlug, response) => {
|
|
565
|
+
* if (response.successful) {
|
|
566
|
+
* console.log(`Successfully executed ${toolSlug}`);
|
|
567
|
+
* }
|
|
568
|
+
* return response;
|
|
569
|
+
* }
|
|
570
|
+
* });
|
|
571
|
+
* ```
|
|
388
572
|
*/
|
|
389
573
|
type ExecuteToolModifiers = {
|
|
390
574
|
/**
|
|
391
|
-
*
|
|
575
|
+
* Function to intercept and modify tool execution parameters before the tool is executed.
|
|
576
|
+
* This allows customizing the request based on tool-specific needs.
|
|
392
577
|
*/
|
|
393
578
|
beforeToolExecute?: BeforeToolExecuteModifier;
|
|
394
579
|
/**
|
|
395
|
-
*
|
|
580
|
+
* Function to intercept and modify tool execution responses after the tool has executed.
|
|
581
|
+
* This allows transforming the response or implementing custom error handling.
|
|
396
582
|
*/
|
|
397
583
|
afterToolExecute?: AfterToolExecuteModifier;
|
|
398
584
|
};
|
|
399
585
|
/**
|
|
400
|
-
*
|
|
586
|
+
* Options for agentic tool configuration.
|
|
587
|
+
*
|
|
588
|
+
* These options combine schema modification capabilities with execution behavior
|
|
589
|
+
* customization, providing full control over both the definition and execution
|
|
590
|
+
* of tools in agentic contexts (like LLM providers).
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* ```typescript
|
|
594
|
+
* // Configure agentic tools with schema and execution modifications
|
|
595
|
+
* const agenticTools = await vercel.tools.get('default', 'GITHUB_GET_REPOS', {
|
|
596
|
+
* modifyToolSchema: (toolSlug, toolkitSlug, schema) => {
|
|
597
|
+
* return {
|
|
598
|
+
* ...schema,
|
|
599
|
+
* description: `Enhanced ${toolSlug} for better context`
|
|
600
|
+
* };
|
|
601
|
+
* },
|
|
602
|
+
*
|
|
603
|
+
* // Intercept before execution
|
|
604
|
+
* beforeToolExecute: (toolSlug, toolkitSlug, params) => {
|
|
605
|
+
* // Add analytics tracking
|
|
606
|
+
* trackToolUsage(toolSlug);
|
|
607
|
+
* return params;
|
|
608
|
+
* },
|
|
609
|
+
*
|
|
610
|
+
* // Transform after execution
|
|
611
|
+
* afterToolExecute: (toolSlug, toolkitSlug, response) => {
|
|
612
|
+
* // Log results and handle errors
|
|
613
|
+
* if (!response.successful) {
|
|
614
|
+
* logToolError(toolSlug, response.error);
|
|
615
|
+
* }
|
|
616
|
+
* return response;
|
|
617
|
+
* }
|
|
618
|
+
* });
|
|
619
|
+
* ```
|
|
401
620
|
*/
|
|
402
621
|
type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
|
|
622
|
+
/**
|
|
623
|
+
* Provider-specific options determined by the type of provider being used.
|
|
624
|
+
*
|
|
625
|
+
* This type automatically resolves to either AgenticToolOptions or ToolOptions
|
|
626
|
+
* based on whether the provider is agentic (like OpenAI or Vercel) or non-agentic.
|
|
627
|
+
*
|
|
628
|
+
* @template T - The provider type
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* ```typescript
|
|
632
|
+
* // With standard provider (non-agentic)
|
|
633
|
+
* const tools = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
|
|
634
|
+
* modifyToolSchema: (toolSlug, toolkitSlug, schema) => schema
|
|
635
|
+
* });
|
|
636
|
+
*
|
|
637
|
+
* // With agentic provider (e.g., VercelProvider)
|
|
638
|
+
* const vercel = new Composio({
|
|
639
|
+
* apiKey: process.env.COMPOSIO_API_KEY,
|
|
640
|
+
* provider: new VercelProvider()
|
|
641
|
+
* });
|
|
642
|
+
*
|
|
643
|
+
* const agenticTools = await vercel.tools.get('default', 'GITHUB_GET_REPOS', {
|
|
644
|
+
* modifyToolSchema: (toolSlug, toolkitSlug, schema) => schema,
|
|
645
|
+
* beforeToolExecute: (toolSlug, toolkitSlug, params) => params,
|
|
646
|
+
* afterToolExecute: (toolSlug, toolkitSlug, response) => response
|
|
647
|
+
* });
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
403
650
|
type ProviderOptions<T extends BaseComposioProvider<unknown, unknown>> = T extends BaseAgenticProvider<unknown, unknown> ? AgenticToolOptions : ToolOptions;
|
|
404
651
|
|
|
405
652
|
/**
|
|
@@ -412,15 +659,27 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
|
|
|
412
659
|
private provider;
|
|
413
660
|
constructor(client: ComposioClient, provider: TProvider);
|
|
414
661
|
/**
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
662
|
+
* Transforms tool data from snake_case API format to camelCase for internal SDK use.
|
|
663
|
+
*
|
|
664
|
+
* This method standardizes the property naming convention for tools retrieved from the Composio API,
|
|
665
|
+
* making them more consistent with JavaScript/TypeScript conventions.
|
|
666
|
+
*
|
|
667
|
+
* @param {ToolRetrieveResponse | ComposioToolListResponse['items'][0]} tool - The tool object to transform
|
|
668
|
+
* @returns {Tool} The transformed tool with camelCase properties
|
|
669
|
+
*
|
|
670
|
+
* @private
|
|
418
671
|
*/
|
|
419
672
|
private transformToolCases;
|
|
420
673
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
674
|
+
* Transforms tool execution response from snake_case API format to camelCase.
|
|
675
|
+
*
|
|
676
|
+
* This method converts the response received from the Composio API to a standardized format
|
|
677
|
+
* with consistent property naming that follows JavaScript/TypeScript conventions.
|
|
678
|
+
*
|
|
679
|
+
* @param {ComposioToolExecuteResponse} response - The raw API response to transform
|
|
680
|
+
* @returns {ToolExecuteResponse} The transformed response with camelCase properties
|
|
681
|
+
*
|
|
682
|
+
* @private
|
|
424
683
|
*/
|
|
425
684
|
private transformToolExecuteResponse;
|
|
426
685
|
/**
|
|
@@ -438,9 +697,35 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
|
|
|
438
697
|
*/
|
|
439
698
|
private getConnectedAccountIdForTool;
|
|
440
699
|
/**
|
|
441
|
-
* Lists all tools available in the Composio SDK
|
|
442
|
-
*
|
|
443
|
-
*
|
|
700
|
+
* Lists all tools available in the Composio SDK including custom tools.
|
|
701
|
+
*
|
|
702
|
+
* This method fetches tools from the Composio API in raw format and combines them with
|
|
703
|
+
* any registered custom tools. The response can be filtered and modified as needed.
|
|
704
|
+
*
|
|
705
|
+
* @param {string} userId - The user ID for whom to fetch the tools
|
|
706
|
+
* @param {ToolListParams} [query={}] - Optional query parameters to filter the tools
|
|
707
|
+
* @param {TransformToolSchemaModifier} [modifier] - Optional function to transform tool schemas
|
|
708
|
+
* @returns {Promise<ToolList>} List of tools matching the query criteria
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```typescript
|
|
712
|
+
* // Get all tools
|
|
713
|
+
* const tools = await composio.tools.getRawComposioTools('default');
|
|
714
|
+
*
|
|
715
|
+
* // Get tools with filters
|
|
716
|
+
* const githubTools = await composio.tools.getRawComposioTools('default', {
|
|
717
|
+
* toolkits: ['github'],
|
|
718
|
+
* important: true
|
|
719
|
+
* });
|
|
720
|
+
*
|
|
721
|
+
* // Get tools with schema transformation
|
|
722
|
+
* const tools = await composio.tools.getRawComposioTools('default', {},
|
|
723
|
+
* (toolSlug, toolkitSlug, tool) => {
|
|
724
|
+
* // Add custom properties to tool schema
|
|
725
|
+
* return {...tool, customProperty: 'value'};
|
|
726
|
+
* }
|
|
727
|
+
* );
|
|
728
|
+
* ```
|
|
444
729
|
*/
|
|
445
730
|
getRawComposioTools(userId: string, query?: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
|
|
446
731
|
/**
|
|
@@ -456,30 +741,51 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
|
|
|
456
741
|
*/
|
|
457
742
|
getRawComposioToolBySlug(userId: string, slug: string, modifier?: TransformToolSchemaModifier): Promise<Tool>;
|
|
458
743
|
/**
|
|
459
|
-
* Get a list of tools
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* @param
|
|
463
|
-
* @
|
|
744
|
+
* Get a list of tools from Composio based on filters.
|
|
745
|
+
* This method fetches the tools from the Composio API and wraps them using the provider.
|
|
746
|
+
*
|
|
747
|
+
* @param {string} userId - The user id to get the tools for
|
|
748
|
+
* @param {ToolListParams} filters - The filters to apply when fetching tools
|
|
749
|
+
* @param {ProviderOptions<TProvider>} [options] - Optional provider options including modifiers
|
|
750
|
+
* @returns {Promise<ReturnType<T['wrapTools']>>} The wrapped tools collection
|
|
464
751
|
*
|
|
465
752
|
* @example
|
|
466
|
-
* ```
|
|
753
|
+
* ```typescript
|
|
754
|
+
* // Get tools from the GitHub toolkit
|
|
755
|
+
* const tools = await composio.tools.get('default', {
|
|
756
|
+
* toolkits: ['github'],
|
|
757
|
+
* limit: 10
|
|
758
|
+
* });
|
|
759
|
+
*
|
|
760
|
+
* // Get tools with search
|
|
467
761
|
* const tools = await composio.tools.get('default', {
|
|
468
|
-
*
|
|
762
|
+
* search: 'user',
|
|
763
|
+
* important: true
|
|
469
764
|
* });
|
|
470
765
|
* ```
|
|
471
766
|
*/
|
|
472
767
|
get<T extends TProvider>(userId: string, filters: ToolListParams, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
|
|
473
768
|
/**
|
|
474
|
-
* Get a tool by its slug
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* @param
|
|
478
|
-
* @
|
|
769
|
+
* Get a specific tool by its slug.
|
|
770
|
+
* This method fetches the tool from the Composio API and wraps it using the provider.
|
|
771
|
+
*
|
|
772
|
+
* @param {string} userId - The user id to get the tool for
|
|
773
|
+
* @param {string} slug - The slug of the tool to fetch
|
|
774
|
+
* @param {ProviderOptions<TProvider>} [options] - Optional provider options including modifiers
|
|
775
|
+
* @returns {Promise<ReturnType<T['wrapTools']>>} The wrapped tool
|
|
479
776
|
*
|
|
480
777
|
* @example
|
|
481
|
-
* ```
|
|
482
|
-
*
|
|
778
|
+
* ```typescript
|
|
779
|
+
* // Get a specific tool by slug
|
|
780
|
+
* const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
|
|
781
|
+
*
|
|
782
|
+
* // Get a tool with schema modifications
|
|
783
|
+
* const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
|
|
784
|
+
* modifyToolSchema: (toolSlug, toolkitSlug, schema) => {
|
|
785
|
+
* // Customize the tool schema
|
|
786
|
+
* return {...schema, description: 'Custom description'};
|
|
787
|
+
* }
|
|
788
|
+
* });
|
|
483
789
|
* ```
|
|
484
790
|
*/
|
|
485
791
|
get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
|
|
@@ -511,13 +817,43 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
|
|
|
511
817
|
*/
|
|
512
818
|
private handleComposioToolExecution;
|
|
513
819
|
/**
|
|
514
|
-
*
|
|
820
|
+
* Executes a given tool with the provided parameters.
|
|
515
821
|
*
|
|
516
|
-
* This method calls the Composio API to execute the tool and returns the response.
|
|
822
|
+
* This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
|
|
823
|
+
* It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
|
|
517
824
|
*
|
|
518
|
-
* @param {string} slug - The ID of the tool to be executed
|
|
825
|
+
* @param {string} slug - The slug/ID of the tool to be executed
|
|
519
826
|
* @param {ToolExecuteParams} body - The parameters to be passed to the tool
|
|
827
|
+
* @param {ExecuteToolModifiers} [modifiers] - Optional modifiers to transform the request or response
|
|
520
828
|
* @returns {Promise<ToolExecuteResponse>} - The response from the tool execution
|
|
829
|
+
*
|
|
830
|
+
* @throws {ComposioCustomToolsNotInitializedError} If the CustomTools instance is not initialized
|
|
831
|
+
* @throws {ComposioToolNotFoundError} If the tool with the given slug is not found
|
|
832
|
+
* @throws {ComposioToolExecutionError} If there is an error during tool execution
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```typescript
|
|
836
|
+
* // Execute a Composio API tool
|
|
837
|
+
* const result = await composio.tools.execute('HACKERNEWS_GET_USER', {
|
|
838
|
+
* userId: 'default',
|
|
839
|
+
* arguments: { userId: 'pg' }
|
|
840
|
+
* });
|
|
841
|
+
*
|
|
842
|
+
* // Execute with modifiers
|
|
843
|
+
* const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
|
|
844
|
+
* userId: 'default',
|
|
845
|
+
* arguments: { owner: 'composio', repo: 'sdk' }
|
|
846
|
+
* }, {
|
|
847
|
+
* beforeToolExecute: (toolSlug, toolkitSlug, params) => {
|
|
848
|
+
* // Modify params before execution
|
|
849
|
+
* return params;
|
|
850
|
+
* },
|
|
851
|
+
* afterToolExecute: (toolSlug, toolkitSlug, result) => {
|
|
852
|
+
* // Transform result after execution
|
|
853
|
+
* return result;
|
|
854
|
+
* }
|
|
855
|
+
* });
|
|
856
|
+
* ```
|
|
521
857
|
*/
|
|
522
858
|
execute(slug: string, body: ToolExecuteParams, modifiers?: ExecuteToolModifiers): Promise<ToolExecuteResponse>;
|
|
523
859
|
/**
|
|
@@ -545,9 +881,39 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
|
|
|
545
881
|
*/
|
|
546
882
|
proxyExecute(body: ToolProxyParams): Promise<ToolProxyResponse>;
|
|
547
883
|
/**
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
884
|
+
* Creates a custom tool that can be used within the Composio SDK.
|
|
885
|
+
*
|
|
886
|
+
* Custom tools allow you to extend the functionality of Composio with your own implementations
|
|
887
|
+
* while keeping a consistent interface for both built-in and custom tools.
|
|
888
|
+
*
|
|
889
|
+
* @param {CustomToolOptions} body - The configuration for the custom tool
|
|
890
|
+
* @returns {Promise<Tool>} The created custom tool
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```typescript
|
|
894
|
+
* const customTool = await composio.tools.createCustomTool({
|
|
895
|
+
* name: 'My Custom Tool',
|
|
896
|
+
* description: 'A custom tool that does something specific',
|
|
897
|
+
* slug: 'MY_CUSTOM_TOOL',
|
|
898
|
+
* inputParameters: {
|
|
899
|
+
* param1: {
|
|
900
|
+
* type: 'string',
|
|
901
|
+
* description: 'First parameter',
|
|
902
|
+
* required: true
|
|
903
|
+
* }
|
|
904
|
+
* },
|
|
905
|
+
* outputParameters: {
|
|
906
|
+
* result: {
|
|
907
|
+
* type: 'string',
|
|
908
|
+
* description: 'The result of the operation'
|
|
909
|
+
* }
|
|
910
|
+
* },
|
|
911
|
+
* handler: async (params, context) => {
|
|
912
|
+
* // Custom logic here
|
|
913
|
+
* return { data: { result: 'Success!' } };
|
|
914
|
+
* }
|
|
915
|
+
* });
|
|
916
|
+
* ```
|
|
551
917
|
*/
|
|
552
918
|
createCustomTool(body: CustomToolOptions): Promise<Tool>;
|
|
553
919
|
}
|
|
@@ -1210,7 +1576,7 @@ declare const ConnectedAccountRetrieveResponseSchema: z.ZodObject<{
|
|
|
1210
1576
|
}>;
|
|
1211
1577
|
userId: z.ZodString;
|
|
1212
1578
|
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1213
|
-
params: z.ZodRecord<z.ZodString, z.ZodUnknown
|
|
1579
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1214
1580
|
status: z.ZodEnum<["ACTIVE", "INACTIVE", "DELETED", "INITIATED", "EXPIRED", "FAILED"]>;
|
|
1215
1581
|
statusReason: z.ZodNullable<z.ZodString>;
|
|
1216
1582
|
toolkit: z.ZodObject<{
|
|
@@ -1225,7 +1591,6 @@ declare const ConnectedAccountRetrieveResponseSchema: z.ZodObject<{
|
|
|
1225
1591
|
createdAt: z.ZodString;
|
|
1226
1592
|
updatedAt: z.ZodString;
|
|
1227
1593
|
}, "strip", z.ZodTypeAny, {
|
|
1228
|
-
params: Record<string, unknown>;
|
|
1229
1594
|
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1230
1595
|
toolkit: {
|
|
1231
1596
|
slug: string;
|
|
@@ -1243,9 +1608,9 @@ declare const ConnectedAccountRetrieveResponseSchema: z.ZodObject<{
|
|
|
1243
1608
|
};
|
|
1244
1609
|
isDisabled: boolean;
|
|
1245
1610
|
statusReason: string | null;
|
|
1611
|
+
params?: Record<string, unknown> | undefined;
|
|
1246
1612
|
testRequestEndpoint?: string | undefined;
|
|
1247
1613
|
}, {
|
|
1248
|
-
params: Record<string, unknown>;
|
|
1249
1614
|
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1250
1615
|
toolkit: {
|
|
1251
1616
|
slug: string;
|
|
@@ -1263,9 +1628,167 @@ declare const ConnectedAccountRetrieveResponseSchema: z.ZodObject<{
|
|
|
1263
1628
|
};
|
|
1264
1629
|
isDisabled: boolean;
|
|
1265
1630
|
statusReason: string | null;
|
|
1631
|
+
params?: Record<string, unknown> | undefined;
|
|
1266
1632
|
testRequestEndpoint?: string | undefined;
|
|
1267
1633
|
}>;
|
|
1268
1634
|
type ConnectedAccountRetrieveResponse = z.infer<typeof ConnectedAccountRetrieveResponseSchema>;
|
|
1635
|
+
declare const ConnectedAccountListParamsSchema: z.ZodObject<{
|
|
1636
|
+
authConfigIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
1637
|
+
cursor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1638
|
+
labels: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
1639
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1640
|
+
orderBy: z.ZodOptional<z.ZodEnum<["created_at", "updated_at"]>>;
|
|
1641
|
+
statuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<["ACTIVE", "INACTIVE", "DELETED", "INITIATED", "EXPIRED", "FAILED"]>, "many">>>;
|
|
1642
|
+
toolkitSlugs: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
1643
|
+
userIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
1644
|
+
}, "strip", z.ZodTypeAny, {
|
|
1645
|
+
cursor?: number | null | undefined;
|
|
1646
|
+
limit?: number | null | undefined;
|
|
1647
|
+
authConfigIds?: string[] | null | undefined;
|
|
1648
|
+
labels?: string[] | null | undefined;
|
|
1649
|
+
orderBy?: "created_at" | "updated_at" | undefined;
|
|
1650
|
+
statuses?: ("ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED")[] | null | undefined;
|
|
1651
|
+
toolkitSlugs?: string[] | null | undefined;
|
|
1652
|
+
userIds?: string[] | null | undefined;
|
|
1653
|
+
}, {
|
|
1654
|
+
cursor?: number | null | undefined;
|
|
1655
|
+
limit?: number | null | undefined;
|
|
1656
|
+
authConfigIds?: string[] | null | undefined;
|
|
1657
|
+
labels?: string[] | null | undefined;
|
|
1658
|
+
orderBy?: "created_at" | "updated_at" | undefined;
|
|
1659
|
+
statuses?: ("ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED")[] | null | undefined;
|
|
1660
|
+
toolkitSlugs?: string[] | null | undefined;
|
|
1661
|
+
userIds?: string[] | null | undefined;
|
|
1662
|
+
}>;
|
|
1663
|
+
type ConnectedAccountListParams = z.infer<typeof ConnectedAccountListParamsSchema>;
|
|
1664
|
+
declare const ConnectedAccountListResponseSchema: z.ZodObject<{
|
|
1665
|
+
items: z.ZodArray<z.ZodObject<{
|
|
1666
|
+
id: z.ZodString;
|
|
1667
|
+
authConfig: z.ZodObject<{
|
|
1668
|
+
id: z.ZodString;
|
|
1669
|
+
authScheme: z.ZodEnum<["OAUTH2", "OAUTH1", "OAUTH1A", "API_KEY", "BASIC", "BILLCOM_AUTH", "BEARER_TOKEN", "GOOGLE_SERVICE_ACCOUNT", "NO_AUTH", "BASIC_WITH_JWT", "COMPOSIO_LINK", "CALCOM_AUTH", "SNOWFLAKE"]>;
|
|
1670
|
+
isComposioManaged: z.ZodBoolean;
|
|
1671
|
+
isDisabled: z.ZodBoolean;
|
|
1672
|
+
}, "strip", z.ZodTypeAny, {
|
|
1673
|
+
id: string;
|
|
1674
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
1675
|
+
isComposioManaged: boolean;
|
|
1676
|
+
isDisabled: boolean;
|
|
1677
|
+
}, {
|
|
1678
|
+
id: string;
|
|
1679
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
1680
|
+
isComposioManaged: boolean;
|
|
1681
|
+
isDisabled: boolean;
|
|
1682
|
+
}>;
|
|
1683
|
+
userId: z.ZodString;
|
|
1684
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1685
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1686
|
+
status: z.ZodEnum<["ACTIVE", "INACTIVE", "DELETED", "INITIATED", "EXPIRED", "FAILED"]>;
|
|
1687
|
+
statusReason: z.ZodNullable<z.ZodString>;
|
|
1688
|
+
toolkit: z.ZodObject<{
|
|
1689
|
+
slug: z.ZodString;
|
|
1690
|
+
}, "strip", z.ZodTypeAny, {
|
|
1691
|
+
slug: string;
|
|
1692
|
+
}, {
|
|
1693
|
+
slug: string;
|
|
1694
|
+
}>;
|
|
1695
|
+
testRequestEndpoint: z.ZodOptional<z.ZodString>;
|
|
1696
|
+
isDisabled: z.ZodBoolean;
|
|
1697
|
+
createdAt: z.ZodString;
|
|
1698
|
+
updatedAt: z.ZodString;
|
|
1699
|
+
}, "strip", z.ZodTypeAny, {
|
|
1700
|
+
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1701
|
+
toolkit: {
|
|
1702
|
+
slug: string;
|
|
1703
|
+
};
|
|
1704
|
+
userId: string;
|
|
1705
|
+
data: Record<string, unknown>;
|
|
1706
|
+
createdAt: string;
|
|
1707
|
+
updatedAt: string;
|
|
1708
|
+
id: string;
|
|
1709
|
+
authConfig: {
|
|
1710
|
+
id: string;
|
|
1711
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
1712
|
+
isComposioManaged: boolean;
|
|
1713
|
+
isDisabled: boolean;
|
|
1714
|
+
};
|
|
1715
|
+
isDisabled: boolean;
|
|
1716
|
+
statusReason: string | null;
|
|
1717
|
+
params?: Record<string, unknown> | undefined;
|
|
1718
|
+
testRequestEndpoint?: string | undefined;
|
|
1719
|
+
}, {
|
|
1720
|
+
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1721
|
+
toolkit: {
|
|
1722
|
+
slug: string;
|
|
1723
|
+
};
|
|
1724
|
+
userId: string;
|
|
1725
|
+
data: Record<string, unknown>;
|
|
1726
|
+
createdAt: string;
|
|
1727
|
+
updatedAt: string;
|
|
1728
|
+
id: string;
|
|
1729
|
+
authConfig: {
|
|
1730
|
+
id: string;
|
|
1731
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
1732
|
+
isComposioManaged: boolean;
|
|
1733
|
+
isDisabled: boolean;
|
|
1734
|
+
};
|
|
1735
|
+
isDisabled: boolean;
|
|
1736
|
+
statusReason: string | null;
|
|
1737
|
+
params?: Record<string, unknown> | undefined;
|
|
1738
|
+
testRequestEndpoint?: string | undefined;
|
|
1739
|
+
}>, "many">;
|
|
1740
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
1741
|
+
totalPages: z.ZodNumber;
|
|
1742
|
+
}, "strip", z.ZodTypeAny, {
|
|
1743
|
+
items: {
|
|
1744
|
+
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1745
|
+
toolkit: {
|
|
1746
|
+
slug: string;
|
|
1747
|
+
};
|
|
1748
|
+
userId: string;
|
|
1749
|
+
data: Record<string, unknown>;
|
|
1750
|
+
createdAt: string;
|
|
1751
|
+
updatedAt: string;
|
|
1752
|
+
id: string;
|
|
1753
|
+
authConfig: {
|
|
1754
|
+
id: string;
|
|
1755
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
1756
|
+
isComposioManaged: boolean;
|
|
1757
|
+
isDisabled: boolean;
|
|
1758
|
+
};
|
|
1759
|
+
isDisabled: boolean;
|
|
1760
|
+
statusReason: string | null;
|
|
1761
|
+
params?: Record<string, unknown> | undefined;
|
|
1762
|
+
testRequestEndpoint?: string | undefined;
|
|
1763
|
+
}[];
|
|
1764
|
+
nextCursor: string | null;
|
|
1765
|
+
totalPages: number;
|
|
1766
|
+
}, {
|
|
1767
|
+
items: {
|
|
1768
|
+
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1769
|
+
toolkit: {
|
|
1770
|
+
slug: string;
|
|
1771
|
+
};
|
|
1772
|
+
userId: string;
|
|
1773
|
+
data: Record<string, unknown>;
|
|
1774
|
+
createdAt: string;
|
|
1775
|
+
updatedAt: string;
|
|
1776
|
+
id: string;
|
|
1777
|
+
authConfig: {
|
|
1778
|
+
id: string;
|
|
1779
|
+
authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
|
|
1780
|
+
isComposioManaged: boolean;
|
|
1781
|
+
isDisabled: boolean;
|
|
1782
|
+
};
|
|
1783
|
+
isDisabled: boolean;
|
|
1784
|
+
statusReason: string | null;
|
|
1785
|
+
params?: Record<string, unknown> | undefined;
|
|
1786
|
+
testRequestEndpoint?: string | undefined;
|
|
1787
|
+
}[];
|
|
1788
|
+
nextCursor: string | null;
|
|
1789
|
+
totalPages: number;
|
|
1790
|
+
}>;
|
|
1791
|
+
type ConnectedAccountListResponse = z.infer<typeof ConnectedAccountListResponseSchema>;
|
|
1269
1792
|
|
|
1270
1793
|
/**
|
|
1271
1794
|
* @fileoverview Connection request class for Composio SDK, used to manage an initiated connection request.
|
|
@@ -1278,26 +1801,52 @@ type ConnectedAccountRetrieveResponse = z.infer<typeof ConnectedAccountRetrieveR
|
|
|
1278
1801
|
declare class ConnectionRequest {
|
|
1279
1802
|
private client;
|
|
1280
1803
|
id: string;
|
|
1281
|
-
status
|
|
1804
|
+
status?: ConnectedAccountStatus;
|
|
1282
1805
|
redirectUrl?: string | null;
|
|
1283
|
-
constructor(client: ComposioClient, connectedAccountId: string, connectedAccountStatus
|
|
1806
|
+
constructor(client: ComposioClient, connectedAccountId: string, connectedAccountStatus?: ConnectedAccountStatus, redirectUrl?: string | null);
|
|
1284
1807
|
/**
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1808
|
+
* Transforms the raw connected account response from the Composio API to the SDK format.
|
|
1809
|
+
*
|
|
1810
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
1811
|
+
* the data structure to match the SDK's standardized format.
|
|
1812
|
+
*
|
|
1813
|
+
* @param {OriginalConnectedAccountResponse} response - The raw API response to transform
|
|
1814
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The transformed response
|
|
1815
|
+
* @throws {ZodError} If the response fails validation against the expected schema
|
|
1816
|
+
*
|
|
1817
|
+
* @private
|
|
1288
1818
|
*/
|
|
1289
1819
|
private transformResponse;
|
|
1290
1820
|
/**
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1821
|
+
* Waits for the connection request to complete and become active.
|
|
1822
|
+
*
|
|
1823
|
+
* This method continuously polls the Composio API to check the status of the connection request
|
|
1824
|
+
* until it either becomes active, enters a terminal error state, or times out.
|
|
1825
|
+
*
|
|
1826
|
+
* @param {number} [timeout=60000] - Maximum time to wait in milliseconds before timing out (default: 60 seconds)
|
|
1827
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The final connected account response when successful
|
|
1828
|
+
* @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
|
|
1829
|
+
* @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
|
|
1830
|
+
* @throws {ConnectionRequestTimeoutError} If the connection request does not complete within the timeout period
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* ```typescript
|
|
1834
|
+
* // Wait for connection with default timeout (60 seconds)
|
|
1835
|
+
* try {
|
|
1836
|
+
* const connection = await connectionRequest.waitForConnection();
|
|
1837
|
+
* console.log('Connection established:', connection.id);
|
|
1838
|
+
* } catch (error) {
|
|
1839
|
+
* console.error('Connection failed:', error.message);
|
|
1840
|
+
* }
|
|
1841
|
+
*
|
|
1842
|
+
* // Wait for connection with custom timeout (2 minutes)
|
|
1843
|
+
* const connection = await connectionRequest.waitForConnection(120000);
|
|
1844
|
+
* ```
|
|
1295
1845
|
*/
|
|
1296
1846
|
waitForConnection(timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
|
|
1297
1847
|
}
|
|
1298
1848
|
declare const connectionRequest: (client: ComposioClient) => {
|
|
1299
1849
|
waitForConnection: (connectedAccountId: string, timeout?: number) => Promise<{
|
|
1300
|
-
params: Record<string, unknown>;
|
|
1301
1850
|
status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
|
|
1302
1851
|
toolkit: {
|
|
1303
1852
|
slug: string;
|
|
@@ -1315,6 +1864,7 @@ declare const connectionRequest: (client: ComposioClient) => {
|
|
|
1315
1864
|
};
|
|
1316
1865
|
isDisabled: boolean;
|
|
1317
1866
|
statusReason: string | null;
|
|
1867
|
+
params?: Record<string, unknown> | undefined;
|
|
1318
1868
|
testRequestEndpoint?: string | undefined;
|
|
1319
1869
|
}>;
|
|
1320
1870
|
};
|
|
@@ -1329,37 +1879,84 @@ declare class Toolkits {
|
|
|
1329
1879
|
private client;
|
|
1330
1880
|
constructor(client: ComposioClient);
|
|
1331
1881
|
/**
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1882
|
+
* Retrieves a list of toolkits based on the provided query parameters.
|
|
1883
|
+
*
|
|
1884
|
+
* This method fetches toolkits from the Composio API and transforms the response
|
|
1885
|
+
* from snake_case to camelCase format for consistency with JavaScript/TypeScript conventions.
|
|
1886
|
+
*
|
|
1887
|
+
* @param {ToolkitListParams} query - The query parameters to filter toolkits
|
|
1888
|
+
* @returns {Promise<ToolKitListResponse>} The transformed list of toolkits
|
|
1889
|
+
*
|
|
1890
|
+
* @private
|
|
1335
1891
|
*/
|
|
1336
1892
|
private getToolkits;
|
|
1337
1893
|
/**
|
|
1338
|
-
*
|
|
1339
|
-
*
|
|
1340
|
-
* @param slug - The
|
|
1341
|
-
* @
|
|
1342
|
-
* @
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1349
|
-
*
|
|
1894
|
+
* Retrieves a specific toolkit by its slug identifier.
|
|
1895
|
+
*
|
|
1896
|
+
* @param {string} slug - The unique slug identifier of the toolkit to retrieve
|
|
1897
|
+
* @returns {Promise<ToolkitRetrieveResponse>} The toolkit object with detailed information
|
|
1898
|
+
* @throws {ComposioToolNotFoundError} If no toolkit with the given slug exists
|
|
1899
|
+
*
|
|
1900
|
+
* @example
|
|
1901
|
+
* ```typescript
|
|
1902
|
+
* // Get a specific toolkit
|
|
1903
|
+
* const githubToolkit = await composio.toolkits.get('github');
|
|
1904
|
+
* console.log(githubToolkit.name); // GitHub
|
|
1905
|
+
* console.log(githubToolkit.authConfigDetails); // Authentication configuration details
|
|
1906
|
+
* ```
|
|
1350
1907
|
*/
|
|
1351
1908
|
get(slug: string): Promise<ToolkitRetrieveResponse>;
|
|
1352
1909
|
/**
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
* @param query - The parameters to
|
|
1356
|
-
* @returns {Promise<ToolKitListResponse>}
|
|
1910
|
+
* Retrieves a list of toolkits based on the provided query parameters.
|
|
1911
|
+
*
|
|
1912
|
+
* @param {ToolkitListParams} query - The query parameters to filter toolkits
|
|
1913
|
+
* @returns {Promise<ToolKitListResponse>} A paginated list of toolkits matching the query criteria
|
|
1914
|
+
*
|
|
1915
|
+
* @example
|
|
1916
|
+
* ```typescript
|
|
1917
|
+
* // Get all toolkits
|
|
1918
|
+
* const allToolkits = await composio.toolkits.get({});
|
|
1919
|
+
*
|
|
1920
|
+
* // Get toolkits by category
|
|
1921
|
+
* const devToolkits = await composio.toolkits.get({
|
|
1922
|
+
* category: 'developer-tools'
|
|
1923
|
+
* });
|
|
1924
|
+
*
|
|
1925
|
+
* // Get local toolkits
|
|
1926
|
+
* const localToolkits = await composio.toolkits.get({
|
|
1927
|
+
* isLocal: true
|
|
1928
|
+
* });
|
|
1929
|
+
* ```
|
|
1357
1930
|
*/
|
|
1358
1931
|
get(query: ToolkitListParams): Promise<ToolKitListResponse>;
|
|
1359
1932
|
/**
|
|
1360
|
-
*
|
|
1933
|
+
* Retrieves a specific toolkit by its slug identifier.
|
|
1361
1934
|
*
|
|
1362
|
-
*
|
|
1935
|
+
* This method fetches a single toolkit from the Composio API and transforms
|
|
1936
|
+
* the response to use camelCase property naming consistent with JavaScript/TypeScript conventions.
|
|
1937
|
+
*
|
|
1938
|
+
* @param {string} slug - The unique slug identifier of the toolkit to retrieve
|
|
1939
|
+
* @returns {Promise<ToolkitRetrieveResponse>} The transformed toolkit object
|
|
1940
|
+
* @throws {ValidationError} If the response cannot be properly parsed
|
|
1941
|
+
* @throws {ComposioToolNotFoundError} If no toolkit with the given slug exists
|
|
1942
|
+
*
|
|
1943
|
+
* @private
|
|
1944
|
+
*/
|
|
1945
|
+
private getToolkitBySlug;
|
|
1946
|
+
/**
|
|
1947
|
+
* Retrieves all toolkit categories available in the Composio SDK.
|
|
1948
|
+
*
|
|
1949
|
+
* This method fetches the complete list of categories from the Composio API
|
|
1950
|
+
* and transforms the response to use camelCase property naming.
|
|
1951
|
+
*
|
|
1952
|
+
* @returns {Promise<ToolkitRetrieveCategoriesResponse>} The list of toolkit categories
|
|
1953
|
+
*
|
|
1954
|
+
* @example
|
|
1955
|
+
* ```typescript
|
|
1956
|
+
* // Get all toolkit categories
|
|
1957
|
+
* const categories = await composio.toolkits.listCategories();
|
|
1958
|
+
* console.log(categories.items); // Array of category objects
|
|
1959
|
+
* ```
|
|
1363
1960
|
*/
|
|
1364
1961
|
listCategories(): Promise<ToolkitRetrieveCategoriesResponse>;
|
|
1365
1962
|
/**
|
|
@@ -1367,8 +1964,12 @@ declare class Toolkits {
|
|
|
1367
1964
|
* This method will create an auth config if one doesn't exist and initiate a connection request.
|
|
1368
1965
|
* @param {string} userId - The user id of the user to authorize
|
|
1369
1966
|
* @param {string} toolkitSlug - The slug of the toolkit to authorize
|
|
1370
|
-
* @param {string} authConfigId - The id of the auth config to use
|
|
1371
1967
|
* @returns {Promise<ConnectionRequest>} The connection request object
|
|
1968
|
+
*
|
|
1969
|
+
* @example
|
|
1970
|
+
* ```typescript
|
|
1971
|
+
* const connectionRequest = await composio.toolkits.authorize(userId, 'github');
|
|
1972
|
+
* ```
|
|
1372
1973
|
*/
|
|
1373
1974
|
authorize(userId: string, toolkitSlug: string): Promise<ConnectionRequest>;
|
|
1374
1975
|
}
|
|
@@ -1814,12 +2415,44 @@ declare class AuthConfigs {
|
|
|
1814
2415
|
* @protected
|
|
1815
2416
|
*/
|
|
1816
2417
|
protected getClient(): ComposioClient;
|
|
2418
|
+
/**
|
|
2419
|
+
* Transforms an auth config response from API format to SDK format.
|
|
2420
|
+
*
|
|
2421
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
2422
|
+
* the data structure to match the SDK's standardized format for auth configurations.
|
|
2423
|
+
*
|
|
2424
|
+
* @param {ComposioAuthConfigRetrieveResponse} authConfig - The raw API response to transform
|
|
2425
|
+
* @returns {AuthConfigRetrieveResponse} The transformed auth config data
|
|
2426
|
+
* @throws {ValidationError} If the response fails validation against the expected schema
|
|
2427
|
+
*
|
|
2428
|
+
* @private
|
|
2429
|
+
*/
|
|
1817
2430
|
private parseAuthConfigRetrieveResponse;
|
|
1818
2431
|
/**
|
|
1819
|
-
*
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
2432
|
+
* Lists authentication configurations based on provided filter criteria.
|
|
2433
|
+
*
|
|
2434
|
+
* This method retrieves auth configs from the Composio API, transforms them to the SDK format,
|
|
2435
|
+
* and supports filtering by various parameters.
|
|
2436
|
+
*
|
|
2437
|
+
* @param {AuthConfigListParams} [query] - Optional query parameters for filtering auth configs
|
|
2438
|
+
* @returns {Promise<AuthConfigListResponse>} A paginated list of auth configurations
|
|
2439
|
+
* @throws {ValidationError} If the query parameters or response fail validation
|
|
2440
|
+
*
|
|
2441
|
+
* @example
|
|
2442
|
+
* ```typescript
|
|
2443
|
+
* // List all auth configs
|
|
2444
|
+
* const allConfigs = await composio.authConfigs.list();
|
|
2445
|
+
*
|
|
2446
|
+
* // List auth configs for a specific toolkit
|
|
2447
|
+
* const githubConfigs = await composio.authConfigs.list({
|
|
2448
|
+
* toolkitSlug: 'github'
|
|
2449
|
+
* });
|
|
2450
|
+
*
|
|
2451
|
+
* // List Composio-managed auth configs
|
|
2452
|
+
* const managedConfigs = await composio.authConfigs.list({
|
|
2453
|
+
* isComposioManaged: true
|
|
2454
|
+
* });
|
|
2455
|
+
* ```
|
|
1823
2456
|
*/
|
|
1824
2457
|
list(query?: AuthConfigListParams): Promise<AuthConfigListResponse>;
|
|
1825
2458
|
/**
|
|
@@ -1842,47 +2475,130 @@ declare class AuthConfigs {
|
|
|
1842
2475
|
*/
|
|
1843
2476
|
create(toolkit: string, options?: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
|
|
1844
2477
|
/**
|
|
1845
|
-
*
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
*
|
|
2478
|
+
* Retrieves a specific authentication configuration by its ID.
|
|
2479
|
+
*
|
|
2480
|
+
* This method fetches detailed information about a single auth config
|
|
2481
|
+
* and transforms the response to the SDK's standardized format.
|
|
2482
|
+
*
|
|
2483
|
+
* @param {string} nanoid - The unique identifier of the auth config to retrieve
|
|
2484
|
+
* @returns {Promise<AuthConfigRetrieveResponse>} The auth config details
|
|
2485
|
+
* @throws {Error} If the auth config cannot be found or an API error occurs
|
|
2486
|
+
* @throws {ValidationError} If the response fails validation
|
|
2487
|
+
*
|
|
2488
|
+
* @example
|
|
2489
|
+
* ```typescript
|
|
2490
|
+
* // Get an auth config by ID
|
|
2491
|
+
* const authConfig = await composio.authConfigs.get('auth_abc123');
|
|
2492
|
+
* console.log(authConfig.name); // e.g., 'GitHub Auth'
|
|
2493
|
+
* console.log(authConfig.toolkit.slug); // e.g., 'github'
|
|
2494
|
+
* ```
|
|
1849
2495
|
*/
|
|
1850
2496
|
get(nanoid: string): Promise<AuthConfigRetrieveResponse>;
|
|
1851
2497
|
/**
|
|
1852
|
-
*
|
|
1853
|
-
*
|
|
1854
|
-
*
|
|
1855
|
-
*
|
|
1856
|
-
*
|
|
2498
|
+
* Updates an existing authentication configuration.
|
|
2499
|
+
*
|
|
2500
|
+
* This method allows you to modify properties of an auth config such as credentials,
|
|
2501
|
+
* scopes, or tool restrictions. The update type (custom or default) determines which
|
|
2502
|
+
* fields can be updated.
|
|
2503
|
+
*
|
|
2504
|
+
* @param {string} nanoid - The unique identifier of the auth config to update
|
|
2505
|
+
* @param {AuthConfigUpdateParams} data - The data to update, which can be either custom or default type
|
|
2506
|
+
* @returns {Promise<AuthConfigUpdateResponse>} The updated auth config
|
|
2507
|
+
* @throws {ValidationError} If the update parameters are invalid
|
|
2508
|
+
* @throws {Error} If the auth config cannot be found or updated
|
|
2509
|
+
*
|
|
2510
|
+
* @example
|
|
2511
|
+
* ```typescript
|
|
2512
|
+
* // Update a custom auth config with new credentials
|
|
2513
|
+
* const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
2514
|
+
* type: 'custom',
|
|
2515
|
+
* credentials: {
|
|
2516
|
+
* apiKey: 'new-api-key-value'
|
|
2517
|
+
* }
|
|
2518
|
+
* });
|
|
2519
|
+
*
|
|
2520
|
+
* // Update a default auth config with new scopes
|
|
2521
|
+
* const updatedConfig = await composio.authConfigs.update('auth_abc123', {
|
|
2522
|
+
* type: 'default',
|
|
2523
|
+
* scopes: ['read:user', 'repo']
|
|
2524
|
+
* });
|
|
2525
|
+
* ```
|
|
1857
2526
|
*/
|
|
1858
2527
|
update(nanoid: string, data: AuthConfigUpdateParams): Promise<AuthConfigUpdateResponse>;
|
|
1859
2528
|
/**
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1862
|
-
*
|
|
1863
|
-
*
|
|
2529
|
+
* Deletes an authentication configuration.
|
|
2530
|
+
*
|
|
2531
|
+
* This method permanently removes an auth config from the Composio platform.
|
|
2532
|
+
* This action cannot be undone and will prevent any connected accounts that use
|
|
2533
|
+
* this auth config from functioning.
|
|
2534
|
+
*
|
|
2535
|
+
* @param {string} nanoid - The unique identifier of the auth config to delete
|
|
2536
|
+
* @returns {Promise<AuthConfigDeleteResponse>} The deletion response
|
|
2537
|
+
* @throws {Error} If the auth config doesn't exist or cannot be deleted
|
|
2538
|
+
*
|
|
2539
|
+
* @example
|
|
2540
|
+
* ```typescript
|
|
2541
|
+
* // Delete an auth config
|
|
2542
|
+
* await composio.authConfigs.delete('auth_abc123');
|
|
2543
|
+
* ```
|
|
1864
2544
|
*/
|
|
1865
2545
|
delete(nanoid: string): Promise<AuthConfigDeleteResponse>;
|
|
1866
2546
|
/**
|
|
1867
|
-
*
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
2547
|
+
* Updates the status of an authentication configuration.
|
|
2548
|
+
*
|
|
2549
|
+
* This method allows you to enable or disable an auth config. When disabled,
|
|
2550
|
+
* the auth config cannot be used to create new connected accounts or authenticate
|
|
2551
|
+
* with third-party services.
|
|
2552
|
+
*
|
|
2553
|
+
* @param {string} status - The status to set ('ENABLED' or 'DISABLED')
|
|
2554
|
+
* @param {string} nanoid - The unique identifier of the auth config
|
|
2555
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
2556
|
+
* @throws {Error} If the auth config cannot be found or the status cannot be updated
|
|
2557
|
+
*
|
|
2558
|
+
* @example
|
|
2559
|
+
* ```typescript
|
|
2560
|
+
* // Disable an auth config
|
|
2561
|
+
* await composio.authConfigs.updateStatus('DISABLED', 'auth_abc123');
|
|
2562
|
+
*
|
|
2563
|
+
* // Enable an auth config
|
|
2564
|
+
* await composio.authConfigs.updateStatus('ENABLED', 'auth_abc123');
|
|
2565
|
+
* ```
|
|
1872
2566
|
*/
|
|
1873
2567
|
updateStatus(status: 'ENABLED' | 'DISABLED', nanoid: string): Promise<AuthConfigUpdateStatusResponse>;
|
|
1874
2568
|
/**
|
|
1875
|
-
*
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
2569
|
+
* Enables an authentication configuration.
|
|
2570
|
+
*
|
|
2571
|
+
* This is a convenience method that calls updateStatus with 'ENABLED'.
|
|
2572
|
+
* When enabled, the auth config can be used to create new connected accounts
|
|
2573
|
+
* and authenticate with third-party services.
|
|
2574
|
+
*
|
|
2575
|
+
* @param {string} nanoid - The unique identifier of the auth config to enable
|
|
2576
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
2577
|
+
* @throws {Error} If the auth config cannot be found or enabled
|
|
2578
|
+
*
|
|
2579
|
+
* @example
|
|
2580
|
+
* ```typescript
|
|
2581
|
+
* // Enable an auth config
|
|
2582
|
+
* await composio.authConfigs.enable('auth_abc123');
|
|
2583
|
+
* ```
|
|
1879
2584
|
*/
|
|
1880
2585
|
enable(nanoid: string): Promise<AuthConfigUpdateStatusResponse>;
|
|
1881
2586
|
/**
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
2587
|
+
* Disables an authentication configuration.
|
|
2588
|
+
*
|
|
2589
|
+
* This is a convenience method that calls updateStatus with 'DISABLED'.
|
|
2590
|
+
* When disabled, the auth config cannot be used to create new connected accounts
|
|
2591
|
+
* or authenticate with third-party services, but existing connections may continue to work.
|
|
2592
|
+
*
|
|
2593
|
+
* @param {string} nanoid - The unique identifier of the auth config to disable
|
|
2594
|
+
* @returns {Promise<AuthConfigUpdateStatusResponse>} The updated auth config details
|
|
2595
|
+
* @throws {Error} If the auth config cannot be found or disabled
|
|
2596
|
+
*
|
|
2597
|
+
* @example
|
|
2598
|
+
* ```typescript
|
|
2599
|
+
* // Disable an auth config
|
|
2600
|
+
* await composio.authConfigs.disable('auth_abc123');
|
|
2601
|
+
* ```
|
|
1886
2602
|
*/
|
|
1887
2603
|
disable(nanoid: string): Promise<AuthConfigUpdateStatusResponse>;
|
|
1888
2604
|
}
|
|
@@ -1904,13 +2620,45 @@ declare class AuthConfigs {
|
|
|
1904
2620
|
declare class ConnectedAccounts {
|
|
1905
2621
|
private client;
|
|
1906
2622
|
constructor(client: ComposioClient);
|
|
2623
|
+
transformConnectedAccountRetrieveResponse(response: ConnectedAccountRetrieveResponse$1 | ConnectedAccountListResponse$1['items'][0]): ConnectedAccountRetrieveResponse;
|
|
1907
2624
|
/**
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
2625
|
+
* Lists all connected accounts based on provided filter criteria.
|
|
2626
|
+
*
|
|
2627
|
+
* This method retrieves connected accounts from the Composio API with optional filtering.
|
|
2628
|
+
*
|
|
2629
|
+
* @param {ConnectedAccountListParams} [query] - Optional query parameters for filtering connected accounts
|
|
2630
|
+
* @returns {Promise<ConnectedAccountListResponse>} A paginated list of connected accounts
|
|
2631
|
+
* @throws {ValidationError} If the query fails validation against the expected schema
|
|
2632
|
+
* @example
|
|
2633
|
+
* ```typescript
|
|
2634
|
+
* // List all connected accounts
|
|
2635
|
+
* const allAccounts = await composio.connectedAccounts.list();
|
|
2636
|
+
*
|
|
2637
|
+
* // List accounts for a specific user
|
|
2638
|
+
* const userAccounts = await composio.connectedAccounts.list({
|
|
2639
|
+
* userIds: ['user123']
|
|
2640
|
+
* });
|
|
2641
|
+
*
|
|
2642
|
+
* // List accounts for a specific toolkit
|
|
2643
|
+
* const githubAccounts = await composio.connectedAccounts.list({
|
|
2644
|
+
* toolkitSlugs: ['github']
|
|
2645
|
+
* });
|
|
2646
|
+
* ```
|
|
1912
2647
|
*/
|
|
1913
2648
|
list(query?: ConnectedAccountListParams): Promise<ConnectedAccountListResponse>;
|
|
2649
|
+
/**
|
|
2650
|
+
* Transforms connected account data from API format to SDK format.
|
|
2651
|
+
*
|
|
2652
|
+
* This method converts property names from snake_case to camelCase and reorganizes
|
|
2653
|
+
* the data structure to match the SDK's standardized format for connected accounts.
|
|
2654
|
+
*
|
|
2655
|
+
* @param {ConnectedAccountRetrieveResponseRaw} response - The raw API response to transform
|
|
2656
|
+
* @returns {ConnectedAccountRetrieveResponse} The transformed connected account data
|
|
2657
|
+
* @throws {ValidationError} If the response fails validation against the expected schema
|
|
2658
|
+
*
|
|
2659
|
+
* @private
|
|
2660
|
+
*/
|
|
2661
|
+
transformConnectedAccountResponse(response: ConnectedAccountRetrieveResponse$1): ConnectedAccountRetrieveResponse;
|
|
1914
2662
|
/**
|
|
1915
2663
|
* Compound function to create a new connected account.
|
|
1916
2664
|
* This function creates a new connected account and returns a connection request.
|
|
@@ -1930,26 +2678,80 @@ declare class ConnectedAccounts {
|
|
|
1930
2678
|
* @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
|
|
1931
2679
|
*/
|
|
1932
2680
|
initiate(userId: string, authConfigId: string, options?: CreateConnectedAccountOptions): Promise<ConnectionRequest>;
|
|
2681
|
+
/**
|
|
2682
|
+
* Waits for a connection request to complete and become active.
|
|
2683
|
+
*
|
|
2684
|
+
* This method continuously polls the Composio API to check the status of a connection
|
|
2685
|
+
* until it either becomes active, enters a terminal error state, or times out.
|
|
2686
|
+
*
|
|
2687
|
+
* @param {string} connectedAccountId - The ID of the connected account to wait for
|
|
2688
|
+
* @param {number} [timeout=60000] - Maximum time to wait in milliseconds (default: 60 seconds)
|
|
2689
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The finalized connected account data
|
|
2690
|
+
* @throws {ComposioConnectedAccountNotFoundError} If the connected account cannot be found
|
|
2691
|
+
* @throws {ConnectionRequestFailedError} If the connection enters a failed, expired, or deleted state
|
|
2692
|
+
* @throws {ConnectionRequestTimeoutError} If the connection does not complete within the timeout period
|
|
2693
|
+
*
|
|
2694
|
+
* @example
|
|
2695
|
+
* ```typescript
|
|
2696
|
+
* // Wait for a connection to complete with default timeout
|
|
2697
|
+
* const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc');
|
|
2698
|
+
*
|
|
2699
|
+
* // Wait with a custom timeout of 2 minutes
|
|
2700
|
+
* const connectedAccount = await composio.connectedAccounts.waitForConnection('conn_123abc', 120000);
|
|
2701
|
+
* ```
|
|
2702
|
+
*/
|
|
1933
2703
|
waitForConnection(connectedAccountId: string, timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
|
|
1934
2704
|
/**
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1937
|
-
*
|
|
1938
|
-
*
|
|
2705
|
+
* Retrieves a specific connected account by its ID.
|
|
2706
|
+
*
|
|
2707
|
+
* This method fetches detailed information about a single connected account
|
|
2708
|
+
* and transforms the response to the SDK's standardized format.
|
|
2709
|
+
*
|
|
2710
|
+
* @param {string} nanoid - The unique identifier of the connected account
|
|
2711
|
+
* @returns {Promise<ConnectedAccountRetrieveResponse>} The connected account details
|
|
2712
|
+
* @throws {Error} If the connected account cannot be found or an API error occurs
|
|
2713
|
+
*
|
|
2714
|
+
* @example
|
|
2715
|
+
* ```typescript
|
|
2716
|
+
* // Get a connected account by ID
|
|
2717
|
+
* const account = await composio.connectedAccounts.get('conn_abc123');
|
|
2718
|
+
* console.log(account.status); // e.g., 'ACTIVE'
|
|
2719
|
+
* console.log(account.toolkit.slug); // e.g., 'github'
|
|
2720
|
+
* ```
|
|
1939
2721
|
*/
|
|
1940
2722
|
get(nanoid: string): Promise<ConnectedAccountRetrieveResponse>;
|
|
1941
2723
|
/**
|
|
1942
|
-
*
|
|
1943
|
-
*
|
|
1944
|
-
*
|
|
1945
|
-
*
|
|
2724
|
+
* Deletes a connected account.
|
|
2725
|
+
*
|
|
2726
|
+
* This method permanently removes a connected account from the Composio platform.
|
|
2727
|
+
* This action cannot be undone and will revoke any access tokens associated with the account.
|
|
2728
|
+
*
|
|
2729
|
+
* @param {string} nanoid - The unique identifier of the connected account to delete
|
|
2730
|
+
* @returns {Promise<ConnectedAccountDeleteResponse>} The deletion response
|
|
2731
|
+
* @throws {Error} If the account doesn't exist or cannot be deleted
|
|
2732
|
+
*
|
|
2733
|
+
* @example
|
|
2734
|
+
* ```typescript
|
|
2735
|
+
* // Delete a connected account
|
|
2736
|
+
* await composio.connectedAccounts.delete('conn_abc123');
|
|
2737
|
+
* ```
|
|
1946
2738
|
*/
|
|
1947
2739
|
delete(nanoid: string): Promise<ConnectedAccountDeleteResponse>;
|
|
1948
2740
|
/**
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
2741
|
+
* Refreshes a connected account's authentication credentials.
|
|
2742
|
+
*
|
|
2743
|
+
* This method attempts to refresh OAuth tokens or other credentials associated with
|
|
2744
|
+
* the connected account. This is useful when a token has expired or is about to expire.
|
|
2745
|
+
*
|
|
2746
|
+
* @param {string} nanoid - The unique identifier of the connected account to refresh
|
|
2747
|
+
* @returns {Promise<ConnectedAccountRefreshResponse>} The response containing the refreshed account details
|
|
2748
|
+
* @throws {Error} If the account doesn't exist or credentials cannot be refreshed
|
|
2749
|
+
*
|
|
2750
|
+
* @example
|
|
2751
|
+
* ```typescript
|
|
2752
|
+
* // Refresh a connected account's credentials
|
|
2753
|
+
* const refreshedAccount = await composio.connectedAccounts.refresh('conn_abc123');
|
|
2754
|
+
* ```
|
|
1953
2755
|
*/
|
|
1954
2756
|
refresh(nanoid: string): Promise<ConnectedAccountRefreshResponse>;
|
|
1955
2757
|
/**
|