@composio/core 0.1.12-alpha.2 → 0.1.12-alpha.4

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 CHANGED
@@ -35,8 +35,8 @@ const composio = new Composio({
35
35
  provider: new OpenAIProvider(),
36
36
  });
37
37
 
38
- // Fetch a single tool
39
- const searchTool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS');
38
+ // Fetch a single tool by slig
39
+ const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS');
40
40
 
41
41
  // Fetch multiple tools
42
42
  const tools = await composio.tools.get('user123', {
@@ -69,7 +69,7 @@ Composio SDK supports powerful modifiers to transform tool schemas and execution
69
69
  Schema modifiers allow you to transform tool schemas before they are used:
70
70
 
71
71
  ```typescript
72
- const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
72
+ const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
73
73
  modifyToolSchema: (toolSlug: string, toolkitSlug: string, tool: Tool) => ({
74
74
  ...tool,
75
75
  description: 'Enhanced HackerNews search with additional features',
@@ -90,7 +90,7 @@ const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
90
90
  For agentic providers (like Vercel AI and Langchain), you can also modify tool execution behavior:
91
91
 
92
92
  ```typescript
93
- const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
93
+ const tools = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
94
94
  // Transform input before execution
95
95
  beforeToolExecute: (toolSlug: string, toolkitSlug: string, params: ToolExecuteParams) => ({
96
96
  ...params,
package/dist/index.cjs CHANGED
@@ -531,6 +531,7 @@ var Tools = class {
531
531
  this.customTools = new CustomTools(client);
532
532
  this.provider = provider;
533
533
  this.execute = this.execute.bind(this);
534
+ this.provider._setExecuteToolFn(this.execute);
534
535
  this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
535
536
  this.getRawComposioTools = this.getRawComposioTools.bind(this);
536
537
  }
@@ -635,7 +636,7 @@ var Tools = class {
635
636
  }
636
637
  /**
637
638
  * Lists all tools available in the Composio SDK as well as custom tools.
638
- * This method fetches the tools from the Composio API and wraps them using the provider.
639
+ * This method fetches the tools from the Composio API in the raw format.
639
640
  * @returns {ToolList} List of tools
640
641
  */
641
642
  async getRawComposioTools(userId, query = {}, modifier) {
@@ -672,6 +673,7 @@ var Tools = class {
672
673
  }
673
674
  /**
674
675
  * Retrieves a tool by its Slug.
676
+ * This method is used to get the raw tools from the composio API.
675
677
  * @param slug The ID of the tool to be retrieved
676
678
  * @returns {Promise<Tool>} The tool
677
679
  *
@@ -712,7 +714,7 @@ var Tools = class {
712
714
  const executeToolFn = this.createExecuteToolFn(userId, options);
713
715
  if (typeof arg2 === "string") {
714
716
  const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
715
- return this.provider.wrapTool(tool, executeToolFn);
717
+ return this.provider.wrapTools([tool], executeToolFn);
716
718
  } else {
717
719
  const tools = await this.getRawComposioTools(userId, arg2, options?.modifyToolSchema);
718
720
  return this.provider.wrapTools(tools, executeToolFn);
@@ -1152,7 +1154,7 @@ var AuthConfigs = class {
1152
1154
  *
1153
1155
  * @link https://docs.composio.dev/reference/auth-configs/create-auth-config
1154
1156
  */
1155
- async create(toolkit, options) {
1157
+ async create(toolkit, options = { type: "use_composio_managed_auth" }) {
1156
1158
  const parsedOptions = CreateAuthConfigParamsSchema.safeParse(options);
1157
1159
  if (parsedOptions.error) {
1158
1160
  throw new ValidationError(parsedOptions.error);
@@ -1481,6 +1483,17 @@ var ConnectionRequest = class {
1481
1483
  throw new ConnectionRequestTimeoutError(`Connection request timed out for ${this.id}`);
1482
1484
  }
1483
1485
  };
1486
+ var connectionRequest = (client) => {
1487
+ return {
1488
+ waitForConnection: async (connectedAccountId, timeout = 6e4) => {
1489
+ return new ConnectionRequest(
1490
+ client,
1491
+ connectedAccountId,
1492
+ ConnectedAccountStatuses.INITIATED
1493
+ ).waitForConnection(timeout);
1494
+ }
1495
+ };
1496
+ };
1484
1497
 
1485
1498
  // src/models/ConnectedAccounts.ts
1486
1499
  var ConnectedAccounts = class {
@@ -1528,6 +1541,26 @@ var ConnectedAccounts = class {
1528
1541
  });
1529
1542
  return new ConnectionRequest(this.client, response.id, response.status, response.redirect_uri);
1530
1543
  }
1544
+ async waitForConnection(connectedAccountId, timeout = 6e4) {
1545
+ let connectedAccount;
1546
+ try {
1547
+ connectedAccount = await this.get(connectedAccountId);
1548
+ } catch (error) {
1549
+ logger_default.error(error);
1550
+ throw new ComposioConnectedAccountNotFoundError(
1551
+ `Unable to retrieve connected account with Id: ${connectedAccountId}`,
1552
+ {
1553
+ connectedAccountId
1554
+ }
1555
+ );
1556
+ }
1557
+ const connectionRequest2 = new ConnectionRequest(
1558
+ this.client,
1559
+ connectedAccountId,
1560
+ connectedAccount.status
1561
+ );
1562
+ return connectionRequest2.waitForConnection(timeout);
1563
+ }
1531
1564
  /**
1532
1565
  * Get a connected account by nanoid
1533
1566
  * @param {string} nanoid - Unique identifier of the connected account
@@ -1535,7 +1568,27 @@ var ConnectedAccounts = class {
1535
1568
  * @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
1536
1569
  */
1537
1570
  async get(nanoid) {
1538
- return this.client.connectedAccounts.retrieve(nanoid);
1571
+ const response = await this.client.connectedAccounts.retrieve(nanoid);
1572
+ const parsedResult = ConnectedAccountRetrieveResponseSchema.safeParse({
1573
+ ...response,
1574
+ userId: response.user_id,
1575
+ // Add the missing userId property
1576
+ authConfig: {
1577
+ ...response.auth_config,
1578
+ authScheme: response.auth_config.auth_scheme,
1579
+ isComposioManaged: response.auth_config.is_composio_managed,
1580
+ isDisabled: response.auth_config.is_disabled
1581
+ },
1582
+ statusReason: response.status_reason,
1583
+ isDisabled: response.is_disabled,
1584
+ createdAt: response.created_at,
1585
+ updatedAt: response.updated_at,
1586
+ testRequestEndpoint: response.test_request_endpoint
1587
+ });
1588
+ if (parsedResult.error) {
1589
+ throw new ValidationError(parsedResult.error);
1590
+ }
1591
+ return parsedResult.data;
1539
1592
  }
1540
1593
  /**
1541
1594
  * Delete a connected account
@@ -2463,7 +2516,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
2463
2516
  };
2464
2517
 
2465
2518
  // package.json
2466
- var version = "0.1.12-alpha.0";
2519
+ var version = "0.1.12-alpha.4";
2467
2520
 
2468
2521
  // src/utils/uuid.ts
2469
2522
  var import_uuid = require("uuid");
@@ -2493,10 +2546,9 @@ var Composio = class {
2493
2546
  provider;
2494
2547
  // auth configs
2495
2548
  authConfigs;
2496
- createAuthConfig;
2497
2549
  // connected accounts
2498
2550
  connectedAccounts;
2499
- initiateConnection;
2551
+ experimental;
2500
2552
  /**
2501
2553
  * @param {Object} config Configuration for the Composio SDK.
2502
2554
  * @param {string} config.apiKey The API key for the Composio SDK.
@@ -2524,13 +2576,13 @@ var Composio = class {
2524
2576
  };
2525
2577
  this.provider = config.provider ?? new OpenAIProvider();
2526
2578
  this.tools = new Tools(this.client, this.provider);
2527
- this.provider._setExecuteToolFn(this.tools.execute);
2528
2579
  this.toolkits = new Toolkits(this.client);
2529
2580
  this.triggers = new Triggers(this.client);
2530
2581
  this.authConfigs = new AuthConfigs(this.client);
2531
- this.createAuthConfig = this.authConfigs.create.bind(this.authConfigs);
2532
2582
  this.connectedAccounts = new ConnectedAccounts(this.client);
2533
- this.initiateConnection = this.connectedAccounts.initiate.bind(this.connectedAccounts);
2583
+ this.experimental = {
2584
+ connectionRequest: connectionRequest(this.client)
2585
+ };
2534
2586
  if (this.config.allowTracking ?? true) {
2535
2587
  this.initializeTelemetry(
2536
2588
  {
@@ -2574,24 +2626,6 @@ var Composio = class {
2574
2626
  }
2575
2627
  return this.client;
2576
2628
  }
2577
- /**
2578
- * Fetch all the tools from Composio.
2579
- * @param {ToolListParams} params Parameters to fetch the tools.
2580
- * @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
2581
- * @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
2582
- */
2583
- getTools(userId, filters, modifiers) {
2584
- return this.tools.get(userId, filters, modifiers);
2585
- }
2586
- /**
2587
- * Fetch a tool from Composio by its slug.
2588
- * @param {string} slug slug of the tool
2589
- * @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
2590
- * @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
2591
- */
2592
- getToolBySlug(userId, slug, modifiers) {
2593
- return this.tools.get(userId, slug, modifiers);
2594
- }
2595
2629
  };
2596
2630
 
2597
2631
  // src/provider/ComposioProvider.ts
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 { ConnectedAccountListParams, ConnectedAccountListResponse, ConnectedAccountRetrieveResponse as ConnectedAccountRetrieveResponse$1, ConnectedAccountDeleteResponse, ConnectedAccountRefreshResponse, ConnectedAccountUpdateStatusParams, ConnectedAccountUpdateStatusResponse } from '@composio/client/resources/connected-accounts';
7
+ import { ConnectedAccountListParams, ConnectedAccountListResponse, 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
 
@@ -439,12 +439,13 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
439
439
  private getConnectedAccountIdForTool;
440
440
  /**
441
441
  * Lists all tools available in the Composio SDK as well as custom tools.
442
- * This method fetches the tools from the Composio API and wraps them using the provider.
442
+ * This method fetches the tools from the Composio API in the raw format.
443
443
  * @returns {ToolList} List of tools
444
444
  */
445
445
  getRawComposioTools(userId: string, query?: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
446
446
  /**
447
447
  * Retrieves a tool by its Slug.
448
+ * This method is used to get the raw tools from the composio API.
448
449
  * @param slug The ID of the tool to be retrieved
449
450
  * @returns {Promise<Tool>} The tool
450
451
  *
@@ -454,19 +455,6 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
454
455
  * ```
455
456
  */
456
457
  getRawComposioToolBySlug(userId: string, slug: string, modifier?: TransformToolSchemaModifier): Promise<Tool>;
457
- /**
458
- * Get a tool by its slug
459
- * @param userId - The user id
460
- * @param slug - The slug of the tool
461
- * @param options - The options for the tool
462
- * @returns The tool
463
- *
464
- * @example
465
- * ```ts
466
- * const tool = await composio.tools.get('default', 'github');
467
- * ```
468
- */
469
- get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTool']>>;
470
458
  /**
471
459
  * Get a list of tools by their slugs
472
460
  * @param userId - The user id
@@ -482,6 +470,19 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
482
470
  * ```
483
471
  */
484
472
  get<T extends TProvider>(userId: string, filters: ToolListParams, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
473
+ /**
474
+ * Get a tool by its slug
475
+ * @param userId - The user id
476
+ * @param slug - The slug of the tool
477
+ * @param options - The options for the tool
478
+ * @returns The tool
479
+ *
480
+ * @example
481
+ * ```ts
482
+ * const tool = await composio.tools.get('default', 'github');
483
+ * ```
484
+ */
485
+ get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
485
486
  /**
486
487
  * @internal
487
488
  * Creates a function that executes a tool.
@@ -1294,6 +1295,29 @@ declare class ConnectionRequest {
1294
1295
  */
1295
1296
  waitForConnection(timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
1296
1297
  }
1298
+ declare const connectionRequest: (client: ComposioClient) => {
1299
+ waitForConnection: (connectedAccountId: string, timeout?: number) => Promise<{
1300
+ params: Record<string, unknown>;
1301
+ status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
1302
+ toolkit: {
1303
+ slug: string;
1304
+ };
1305
+ userId: string;
1306
+ data: Record<string, unknown>;
1307
+ createdAt: string;
1308
+ updatedAt: string;
1309
+ id: string;
1310
+ authConfig: {
1311
+ id: string;
1312
+ authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
1313
+ isComposioManaged: boolean;
1314
+ isDisabled: boolean;
1315
+ };
1316
+ isDisabled: boolean;
1317
+ statusReason: string | null;
1318
+ testRequestEndpoint?: string | undefined;
1319
+ }>;
1320
+ };
1297
1321
 
1298
1322
  /**
1299
1323
  * Toolkits class
@@ -1816,7 +1840,7 @@ declare class AuthConfigs {
1816
1840
  *
1817
1841
  * @link https://docs.composio.dev/reference/auth-configs/create-auth-config
1818
1842
  */
1819
- create(toolkit: string, options: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
1843
+ create(toolkit: string, options?: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
1820
1844
  /**
1821
1845
  * Get an auth config by nanoid
1822
1846
  * @param {string} nanoid - Unique identifier of the auth config
@@ -1906,13 +1930,14 @@ declare class ConnectedAccounts {
1906
1930
  * @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
1907
1931
  */
1908
1932
  initiate(userId: string, authConfigId: string, options?: CreateConnectedAccountOptions): Promise<ConnectionRequest>;
1933
+ waitForConnection(connectedAccountId: string, timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
1909
1934
  /**
1910
1935
  * Get a connected account by nanoid
1911
1936
  * @param {string} nanoid - Unique identifier of the connected account
1912
1937
  * @param {RequestOptions} options - Request options
1913
1938
  * @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
1914
1939
  */
1915
- get(nanoid: string): Promise<ConnectedAccountRetrieveResponse$1>;
1940
+ get(nanoid: string): Promise<ConnectedAccountRetrieveResponse>;
1916
1941
  /**
1917
1942
  * Delete a connected account
1918
1943
  * @param {string} nanoid - Unique identifier of the connected account to delete
@@ -2066,9 +2091,10 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
2066
2091
  triggers: Triggers;
2067
2092
  provider: TProvider;
2068
2093
  authConfigs: AuthConfigs;
2069
- createAuthConfig: AuthConfigs['create'];
2070
2094
  connectedAccounts: ConnectedAccounts;
2071
- initiateConnection: ConnectedAccounts['initiate'];
2095
+ experimental: {
2096
+ connectionRequest: ReturnType<typeof connectionRequest>;
2097
+ };
2072
2098
  /**
2073
2099
  * @param {Object} config Configuration for the Composio SDK.
2074
2100
  * @param {string} config.apiKey The API key for the Composio SDK.
@@ -2090,20 +2116,6 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
2090
2116
  * @returns {ComposioClient} The Composio API client.
2091
2117
  */
2092
2118
  getClient(): ComposioClient;
2093
- /**
2094
- * Fetch all the tools from Composio.
2095
- * @param {ToolListParams} params Parameters to fetch the tools.
2096
- * @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
2097
- * @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
2098
- */
2099
- getTools<T extends TProvider>(userId: string, filters: ToolListParams, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTools']>>;
2100
- /**
2101
- * Fetch a tool from Composio by its slug.
2102
- * @param {string} slug slug of the tool
2103
- * @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
2104
- * @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
2105
- */
2106
- getToolBySlug<T extends TProvider>(userId: string, slug: string, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTool']>>;
2107
2119
  }
2108
2120
 
2109
2121
  /**
package/dist/index.d.ts 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 { ConnectedAccountListParams, ConnectedAccountListResponse, ConnectedAccountRetrieveResponse as ConnectedAccountRetrieveResponse$1, ConnectedAccountDeleteResponse, ConnectedAccountRefreshResponse, ConnectedAccountUpdateStatusParams, ConnectedAccountUpdateStatusResponse } from '@composio/client/resources/connected-accounts';
7
+ import { ConnectedAccountListParams, ConnectedAccountListResponse, 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
 
@@ -439,12 +439,13 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
439
439
  private getConnectedAccountIdForTool;
440
440
  /**
441
441
  * Lists all tools available in the Composio SDK as well as custom tools.
442
- * This method fetches the tools from the Composio API and wraps them using the provider.
442
+ * This method fetches the tools from the Composio API in the raw format.
443
443
  * @returns {ToolList} List of tools
444
444
  */
445
445
  getRawComposioTools(userId: string, query?: ToolListParams, modifier?: TransformToolSchemaModifier): Promise<ToolList>;
446
446
  /**
447
447
  * Retrieves a tool by its Slug.
448
+ * This method is used to get the raw tools from the composio API.
448
449
  * @param slug The ID of the tool to be retrieved
449
450
  * @returns {Promise<Tool>} The tool
450
451
  *
@@ -454,19 +455,6 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
454
455
  * ```
455
456
  */
456
457
  getRawComposioToolBySlug(userId: string, slug: string, modifier?: TransformToolSchemaModifier): Promise<Tool>;
457
- /**
458
- * Get a tool by its slug
459
- * @param userId - The user id
460
- * @param slug - The slug of the tool
461
- * @param options - The options for the tool
462
- * @returns The tool
463
- *
464
- * @example
465
- * ```ts
466
- * const tool = await composio.tools.get('default', 'github');
467
- * ```
468
- */
469
- get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTool']>>;
470
458
  /**
471
459
  * Get a list of tools by their slugs
472
460
  * @param userId - The user id
@@ -482,6 +470,19 @@ declare class Tools<TToolCollection, TTool, TProvider extends BaseComposioProvid
482
470
  * ```
483
471
  */
484
472
  get<T extends TProvider>(userId: string, filters: ToolListParams, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
473
+ /**
474
+ * Get a tool by its slug
475
+ * @param userId - The user id
476
+ * @param slug - The slug of the tool
477
+ * @param options - The options for the tool
478
+ * @returns The tool
479
+ *
480
+ * @example
481
+ * ```ts
482
+ * const tool = await composio.tools.get('default', 'github');
483
+ * ```
484
+ */
485
+ get<T extends TProvider>(userId: string, slug: string, options?: ProviderOptions<TProvider>): Promise<ReturnType<T['wrapTools']>>;
485
486
  /**
486
487
  * @internal
487
488
  * Creates a function that executes a tool.
@@ -1294,6 +1295,29 @@ declare class ConnectionRequest {
1294
1295
  */
1295
1296
  waitForConnection(timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
1296
1297
  }
1298
+ declare const connectionRequest: (client: ComposioClient) => {
1299
+ waitForConnection: (connectedAccountId: string, timeout?: number) => Promise<{
1300
+ params: Record<string, unknown>;
1301
+ status: "ACTIVE" | "INACTIVE" | "DELETED" | "INITIATED" | "EXPIRED" | "FAILED";
1302
+ toolkit: {
1303
+ slug: string;
1304
+ };
1305
+ userId: string;
1306
+ data: Record<string, unknown>;
1307
+ createdAt: string;
1308
+ updatedAt: string;
1309
+ id: string;
1310
+ authConfig: {
1311
+ id: string;
1312
+ authScheme: "NO_AUTH" | "OAUTH2" | "OAUTH1" | "OAUTH1A" | "API_KEY" | "BASIC" | "BILLCOM_AUTH" | "BEARER_TOKEN" | "GOOGLE_SERVICE_ACCOUNT" | "BASIC_WITH_JWT" | "COMPOSIO_LINK" | "CALCOM_AUTH" | "SNOWFLAKE";
1313
+ isComposioManaged: boolean;
1314
+ isDisabled: boolean;
1315
+ };
1316
+ isDisabled: boolean;
1317
+ statusReason: string | null;
1318
+ testRequestEndpoint?: string | undefined;
1319
+ }>;
1320
+ };
1297
1321
 
1298
1322
  /**
1299
1323
  * Toolkits class
@@ -1816,7 +1840,7 @@ declare class AuthConfigs {
1816
1840
  *
1817
1841
  * @link https://docs.composio.dev/reference/auth-configs/create-auth-config
1818
1842
  */
1819
- create(toolkit: string, options: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
1843
+ create(toolkit: string, options?: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
1820
1844
  /**
1821
1845
  * Get an auth config by nanoid
1822
1846
  * @param {string} nanoid - Unique identifier of the auth config
@@ -1906,13 +1930,14 @@ declare class ConnectedAccounts {
1906
1930
  * @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
1907
1931
  */
1908
1932
  initiate(userId: string, authConfigId: string, options?: CreateConnectedAccountOptions): Promise<ConnectionRequest>;
1933
+ waitForConnection(connectedAccountId: string, timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
1909
1934
  /**
1910
1935
  * Get a connected account by nanoid
1911
1936
  * @param {string} nanoid - Unique identifier of the connected account
1912
1937
  * @param {RequestOptions} options - Request options
1913
1938
  * @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
1914
1939
  */
1915
- get(nanoid: string): Promise<ConnectedAccountRetrieveResponse$1>;
1940
+ get(nanoid: string): Promise<ConnectedAccountRetrieveResponse>;
1916
1941
  /**
1917
1942
  * Delete a connected account
1918
1943
  * @param {string} nanoid - Unique identifier of the connected account to delete
@@ -2066,9 +2091,10 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
2066
2091
  triggers: Triggers;
2067
2092
  provider: TProvider;
2068
2093
  authConfigs: AuthConfigs;
2069
- createAuthConfig: AuthConfigs['create'];
2070
2094
  connectedAccounts: ConnectedAccounts;
2071
- initiateConnection: ConnectedAccounts['initiate'];
2095
+ experimental: {
2096
+ connectionRequest: ReturnType<typeof connectionRequest>;
2097
+ };
2072
2098
  /**
2073
2099
  * @param {Object} config Configuration for the Composio SDK.
2074
2100
  * @param {string} config.apiKey The API key for the Composio SDK.
@@ -2090,20 +2116,6 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
2090
2116
  * @returns {ComposioClient} The Composio API client.
2091
2117
  */
2092
2118
  getClient(): ComposioClient;
2093
- /**
2094
- * Fetch all the tools from Composio.
2095
- * @param {ToolListParams} params Parameters to fetch the tools.
2096
- * @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
2097
- * @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
2098
- */
2099
- getTools<T extends TProvider>(userId: string, filters: ToolListParams, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTools']>>;
2100
- /**
2101
- * Fetch a tool from Composio by its slug.
2102
- * @param {string} slug slug of the tool
2103
- * @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
2104
- * @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
2105
- */
2106
- getToolBySlug<T extends TProvider>(userId: string, slug: string, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTool']>>;
2107
2119
  }
2108
2120
 
2109
2121
  /**
package/dist/index.js CHANGED
@@ -493,6 +493,7 @@ var Tools = class {
493
493
  this.customTools = new CustomTools(client);
494
494
  this.provider = provider;
495
495
  this.execute = this.execute.bind(this);
496
+ this.provider._setExecuteToolFn(this.execute);
496
497
  this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
497
498
  this.getRawComposioTools = this.getRawComposioTools.bind(this);
498
499
  }
@@ -597,7 +598,7 @@ var Tools = class {
597
598
  }
598
599
  /**
599
600
  * Lists all tools available in the Composio SDK as well as custom tools.
600
- * This method fetches the tools from the Composio API and wraps them using the provider.
601
+ * This method fetches the tools from the Composio API in the raw format.
601
602
  * @returns {ToolList} List of tools
602
603
  */
603
604
  async getRawComposioTools(userId, query = {}, modifier) {
@@ -634,6 +635,7 @@ var Tools = class {
634
635
  }
635
636
  /**
636
637
  * Retrieves a tool by its Slug.
638
+ * This method is used to get the raw tools from the composio API.
637
639
  * @param slug The ID of the tool to be retrieved
638
640
  * @returns {Promise<Tool>} The tool
639
641
  *
@@ -674,7 +676,7 @@ var Tools = class {
674
676
  const executeToolFn = this.createExecuteToolFn(userId, options);
675
677
  if (typeof arg2 === "string") {
676
678
  const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
677
- return this.provider.wrapTool(tool, executeToolFn);
679
+ return this.provider.wrapTools([tool], executeToolFn);
678
680
  } else {
679
681
  const tools = await this.getRawComposioTools(userId, arg2, options?.modifyToolSchema);
680
682
  return this.provider.wrapTools(tools, executeToolFn);
@@ -1114,7 +1116,7 @@ var AuthConfigs = class {
1114
1116
  *
1115
1117
  * @link https://docs.composio.dev/reference/auth-configs/create-auth-config
1116
1118
  */
1117
- async create(toolkit, options) {
1119
+ async create(toolkit, options = { type: "use_composio_managed_auth" }) {
1118
1120
  const parsedOptions = CreateAuthConfigParamsSchema.safeParse(options);
1119
1121
  if (parsedOptions.error) {
1120
1122
  throw new ValidationError(parsedOptions.error);
@@ -1443,6 +1445,17 @@ var ConnectionRequest = class {
1443
1445
  throw new ConnectionRequestTimeoutError(`Connection request timed out for ${this.id}`);
1444
1446
  }
1445
1447
  };
1448
+ var connectionRequest = (client) => {
1449
+ return {
1450
+ waitForConnection: async (connectedAccountId, timeout = 6e4) => {
1451
+ return new ConnectionRequest(
1452
+ client,
1453
+ connectedAccountId,
1454
+ ConnectedAccountStatuses.INITIATED
1455
+ ).waitForConnection(timeout);
1456
+ }
1457
+ };
1458
+ };
1446
1459
 
1447
1460
  // src/models/ConnectedAccounts.ts
1448
1461
  var ConnectedAccounts = class {
@@ -1490,6 +1503,26 @@ var ConnectedAccounts = class {
1490
1503
  });
1491
1504
  return new ConnectionRequest(this.client, response.id, response.status, response.redirect_uri);
1492
1505
  }
1506
+ async waitForConnection(connectedAccountId, timeout = 6e4) {
1507
+ let connectedAccount;
1508
+ try {
1509
+ connectedAccount = await this.get(connectedAccountId);
1510
+ } catch (error) {
1511
+ logger_default.error(error);
1512
+ throw new ComposioConnectedAccountNotFoundError(
1513
+ `Unable to retrieve connected account with Id: ${connectedAccountId}`,
1514
+ {
1515
+ connectedAccountId
1516
+ }
1517
+ );
1518
+ }
1519
+ const connectionRequest2 = new ConnectionRequest(
1520
+ this.client,
1521
+ connectedAccountId,
1522
+ connectedAccount.status
1523
+ );
1524
+ return connectionRequest2.waitForConnection(timeout);
1525
+ }
1493
1526
  /**
1494
1527
  * Get a connected account by nanoid
1495
1528
  * @param {string} nanoid - Unique identifier of the connected account
@@ -1497,7 +1530,27 @@ var ConnectedAccounts = class {
1497
1530
  * @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
1498
1531
  */
1499
1532
  async get(nanoid) {
1500
- return this.client.connectedAccounts.retrieve(nanoid);
1533
+ const response = await this.client.connectedAccounts.retrieve(nanoid);
1534
+ const parsedResult = ConnectedAccountRetrieveResponseSchema.safeParse({
1535
+ ...response,
1536
+ userId: response.user_id,
1537
+ // Add the missing userId property
1538
+ authConfig: {
1539
+ ...response.auth_config,
1540
+ authScheme: response.auth_config.auth_scheme,
1541
+ isComposioManaged: response.auth_config.is_composio_managed,
1542
+ isDisabled: response.auth_config.is_disabled
1543
+ },
1544
+ statusReason: response.status_reason,
1545
+ isDisabled: response.is_disabled,
1546
+ createdAt: response.created_at,
1547
+ updatedAt: response.updated_at,
1548
+ testRequestEndpoint: response.test_request_endpoint
1549
+ });
1550
+ if (parsedResult.error) {
1551
+ throw new ValidationError(parsedResult.error);
1552
+ }
1553
+ return parsedResult.data;
1501
1554
  }
1502
1555
  /**
1503
1556
  * Delete a connected account
@@ -2425,7 +2478,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
2425
2478
  };
2426
2479
 
2427
2480
  // package.json
2428
- var version = "0.1.12-alpha.0";
2481
+ var version = "0.1.12-alpha.4";
2429
2482
 
2430
2483
  // src/utils/uuid.ts
2431
2484
  import { v4 as uuidv4 } from "uuid";
@@ -2455,10 +2508,9 @@ var Composio = class {
2455
2508
  provider;
2456
2509
  // auth configs
2457
2510
  authConfigs;
2458
- createAuthConfig;
2459
2511
  // connected accounts
2460
2512
  connectedAccounts;
2461
- initiateConnection;
2513
+ experimental;
2462
2514
  /**
2463
2515
  * @param {Object} config Configuration for the Composio SDK.
2464
2516
  * @param {string} config.apiKey The API key for the Composio SDK.
@@ -2486,13 +2538,13 @@ var Composio = class {
2486
2538
  };
2487
2539
  this.provider = config.provider ?? new OpenAIProvider();
2488
2540
  this.tools = new Tools(this.client, this.provider);
2489
- this.provider._setExecuteToolFn(this.tools.execute);
2490
2541
  this.toolkits = new Toolkits(this.client);
2491
2542
  this.triggers = new Triggers(this.client);
2492
2543
  this.authConfigs = new AuthConfigs(this.client);
2493
- this.createAuthConfig = this.authConfigs.create.bind(this.authConfigs);
2494
2544
  this.connectedAccounts = new ConnectedAccounts(this.client);
2495
- this.initiateConnection = this.connectedAccounts.initiate.bind(this.connectedAccounts);
2545
+ this.experimental = {
2546
+ connectionRequest: connectionRequest(this.client)
2547
+ };
2496
2548
  if (this.config.allowTracking ?? true) {
2497
2549
  this.initializeTelemetry(
2498
2550
  {
@@ -2536,24 +2588,6 @@ var Composio = class {
2536
2588
  }
2537
2589
  return this.client;
2538
2590
  }
2539
- /**
2540
- * Fetch all the tools from Composio.
2541
- * @param {ToolListParams} params Parameters to fetch the tools.
2542
- * @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
2543
- * @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
2544
- */
2545
- getTools(userId, filters, modifiers) {
2546
- return this.tools.get(userId, filters, modifiers);
2547
- }
2548
- /**
2549
- * Fetch a tool from Composio by its slug.
2550
- * @param {string} slug slug of the tool
2551
- * @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
2552
- * @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
2553
- */
2554
- getToolBySlug(userId, slug, modifiers) {
2555
- return this.tools.get(userId, slug, modifiers);
2556
- }
2557
2591
  };
2558
2592
 
2559
2593
  // src/provider/ComposioProvider.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/core",
3
- "version": "0.1.12-alpha.2",
3
+ "version": "0.1.12-alpha.4",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -42,5 +42,5 @@
42
42
  "zod": "^3.24.2",
43
43
  "zod-to-json-schema": "^3.24.5"
44
44
  },
45
- "gitHead": "b2d06cfc901435c847a61f929c6685b0f1babfea"
45
+ "gitHead": "ba5a2b5e403cdee65f3acca8d047c62eadce9be0"
46
46
  }