@composio/core 0.1.12-alpha.3 → 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 +4 -4
- package/dist/index.cjs +47 -28
- package/dist/index.d.cts +19 -33
- package/dist/index.d.ts +19 -33
- package/dist/index.js +47 -28
- package/package.json +2 -2
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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);
|
|
@@ -1539,6 +1541,26 @@ var ConnectedAccounts = class {
|
|
|
1539
1541
|
});
|
|
1540
1542
|
return new ConnectionRequest(this.client, response.id, response.status, response.redirect_uri);
|
|
1541
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
|
+
}
|
|
1542
1564
|
/**
|
|
1543
1565
|
* Get a connected account by nanoid
|
|
1544
1566
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
@@ -1546,7 +1568,27 @@ var ConnectedAccounts = class {
|
|
|
1546
1568
|
* @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
|
|
1547
1569
|
*/
|
|
1548
1570
|
async get(nanoid) {
|
|
1549
|
-
|
|
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;
|
|
1550
1592
|
}
|
|
1551
1593
|
/**
|
|
1552
1594
|
* Delete a connected account
|
|
@@ -2474,7 +2516,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
2474
2516
|
};
|
|
2475
2517
|
|
|
2476
2518
|
// package.json
|
|
2477
|
-
var version = "0.1.12-alpha.
|
|
2519
|
+
var version = "0.1.12-alpha.4";
|
|
2478
2520
|
|
|
2479
2521
|
// src/utils/uuid.ts
|
|
2480
2522
|
var import_uuid = require("uuid");
|
|
@@ -2507,8 +2549,6 @@ var Composio = class {
|
|
|
2507
2549
|
// connected accounts
|
|
2508
2550
|
connectedAccounts;
|
|
2509
2551
|
experimental;
|
|
2510
|
-
createAuthConfig;
|
|
2511
|
-
initiateConnection;
|
|
2512
2552
|
/**
|
|
2513
2553
|
* @param {Object} config Configuration for the Composio SDK.
|
|
2514
2554
|
* @param {string} config.apiKey The API key for the Composio SDK.
|
|
@@ -2536,13 +2576,10 @@ var Composio = class {
|
|
|
2536
2576
|
};
|
|
2537
2577
|
this.provider = config.provider ?? new OpenAIProvider();
|
|
2538
2578
|
this.tools = new Tools(this.client, this.provider);
|
|
2539
|
-
this.provider._setExecuteToolFn(this.tools.execute);
|
|
2540
2579
|
this.toolkits = new Toolkits(this.client);
|
|
2541
2580
|
this.triggers = new Triggers(this.client);
|
|
2542
2581
|
this.authConfigs = new AuthConfigs(this.client);
|
|
2543
|
-
this.createAuthConfig = this.authConfigs.create.bind(this.authConfigs);
|
|
2544
2582
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
2545
|
-
this.initiateConnection = this.connectedAccounts.initiate.bind(this.connectedAccounts);
|
|
2546
2583
|
this.experimental = {
|
|
2547
2584
|
connectionRequest: connectionRequest(this.client)
|
|
2548
2585
|
};
|
|
@@ -2589,24 +2626,6 @@ var Composio = class {
|
|
|
2589
2626
|
}
|
|
2590
2627
|
return this.client;
|
|
2591
2628
|
}
|
|
2592
|
-
/**
|
|
2593
|
-
* Fetch all the tools from Composio.
|
|
2594
|
-
* @param {ToolListParams} params Parameters to fetch the tools.
|
|
2595
|
-
* @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
|
|
2596
|
-
* @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
|
|
2597
|
-
*/
|
|
2598
|
-
getTools(userId, filters, modifiers) {
|
|
2599
|
-
return this.tools.get(userId, filters, modifiers);
|
|
2600
|
-
}
|
|
2601
|
-
/**
|
|
2602
|
-
* Fetch a tool from Composio by its slug.
|
|
2603
|
-
* @param {string} slug slug of the tool
|
|
2604
|
-
* @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
|
|
2605
|
-
* @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
|
|
2606
|
-
*/
|
|
2607
|
-
getToolBySlug(userId, slug, modifiers) {
|
|
2608
|
-
return this.tools.get(userId, slug, modifiers);
|
|
2609
|
-
}
|
|
2610
2629
|
};
|
|
2611
2630
|
|
|
2612
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,
|
|
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
|
|
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.
|
|
@@ -1839,7 +1840,7 @@ declare class AuthConfigs {
|
|
|
1839
1840
|
*
|
|
1840
1841
|
* @link https://docs.composio.dev/reference/auth-configs/create-auth-config
|
|
1841
1842
|
*/
|
|
1842
|
-
create(toolkit: string, options
|
|
1843
|
+
create(toolkit: string, options?: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
|
|
1843
1844
|
/**
|
|
1844
1845
|
* Get an auth config by nanoid
|
|
1845
1846
|
* @param {string} nanoid - Unique identifier of the auth config
|
|
@@ -1929,13 +1930,14 @@ declare class ConnectedAccounts {
|
|
|
1929
1930
|
* @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
|
|
1930
1931
|
*/
|
|
1931
1932
|
initiate(userId: string, authConfigId: string, options?: CreateConnectedAccountOptions): Promise<ConnectionRequest>;
|
|
1933
|
+
waitForConnection(connectedAccountId: string, timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
|
|
1932
1934
|
/**
|
|
1933
1935
|
* Get a connected account by nanoid
|
|
1934
1936
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
1935
1937
|
* @param {RequestOptions} options - Request options
|
|
1936
1938
|
* @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
|
|
1937
1939
|
*/
|
|
1938
|
-
get(nanoid: string): Promise<ConnectedAccountRetrieveResponse
|
|
1940
|
+
get(nanoid: string): Promise<ConnectedAccountRetrieveResponse>;
|
|
1939
1941
|
/**
|
|
1940
1942
|
* Delete a connected account
|
|
1941
1943
|
* @param {string} nanoid - Unique identifier of the connected account to delete
|
|
@@ -2093,8 +2095,6 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
|
|
|
2093
2095
|
experimental: {
|
|
2094
2096
|
connectionRequest: ReturnType<typeof connectionRequest>;
|
|
2095
2097
|
};
|
|
2096
|
-
createAuthConfig: AuthConfigs['create'];
|
|
2097
|
-
initiateConnection: ConnectedAccounts['initiate'];
|
|
2098
2098
|
/**
|
|
2099
2099
|
* @param {Object} config Configuration for the Composio SDK.
|
|
2100
2100
|
* @param {string} config.apiKey The API key for the Composio SDK.
|
|
@@ -2116,20 +2116,6 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
|
|
|
2116
2116
|
* @returns {ComposioClient} The Composio API client.
|
|
2117
2117
|
*/
|
|
2118
2118
|
getClient(): ComposioClient;
|
|
2119
|
-
/**
|
|
2120
|
-
* Fetch all the tools from Composio.
|
|
2121
|
-
* @param {ToolListParams} params Parameters to fetch the tools.
|
|
2122
|
-
* @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
|
|
2123
|
-
* @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
|
|
2124
|
-
*/
|
|
2125
|
-
getTools<T extends TProvider>(userId: string, filters: ToolListParams, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTools']>>;
|
|
2126
|
-
/**
|
|
2127
|
-
* Fetch a tool from Composio by its slug.
|
|
2128
|
-
* @param {string} slug slug of the tool
|
|
2129
|
-
* @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
|
|
2130
|
-
* @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
|
|
2131
|
-
*/
|
|
2132
|
-
getToolBySlug<T extends TProvider>(userId: string, slug: string, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTool']>>;
|
|
2133
2119
|
}
|
|
2134
2120
|
|
|
2135
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,
|
|
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
|
|
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.
|
|
@@ -1839,7 +1840,7 @@ declare class AuthConfigs {
|
|
|
1839
1840
|
*
|
|
1840
1841
|
* @link https://docs.composio.dev/reference/auth-configs/create-auth-config
|
|
1841
1842
|
*/
|
|
1842
|
-
create(toolkit: string, options
|
|
1843
|
+
create(toolkit: string, options?: CreateAuthConfigParams): Promise<CreateAuthConfigResponse>;
|
|
1843
1844
|
/**
|
|
1844
1845
|
* Get an auth config by nanoid
|
|
1845
1846
|
* @param {string} nanoid - Unique identifier of the auth config
|
|
@@ -1929,13 +1930,14 @@ declare class ConnectedAccounts {
|
|
|
1929
1930
|
* @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
|
|
1930
1931
|
*/
|
|
1931
1932
|
initiate(userId: string, authConfigId: string, options?: CreateConnectedAccountOptions): Promise<ConnectionRequest>;
|
|
1933
|
+
waitForConnection(connectedAccountId: string, timeout?: number): Promise<ConnectedAccountRetrieveResponse>;
|
|
1932
1934
|
/**
|
|
1933
1935
|
* Get a connected account by nanoid
|
|
1934
1936
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
1935
1937
|
* @param {RequestOptions} options - Request options
|
|
1936
1938
|
* @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
|
|
1937
1939
|
*/
|
|
1938
|
-
get(nanoid: string): Promise<ConnectedAccountRetrieveResponse
|
|
1940
|
+
get(nanoid: string): Promise<ConnectedAccountRetrieveResponse>;
|
|
1939
1941
|
/**
|
|
1940
1942
|
* Delete a connected account
|
|
1941
1943
|
* @param {string} nanoid - Unique identifier of the connected account to delete
|
|
@@ -2093,8 +2095,6 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
|
|
|
2093
2095
|
experimental: {
|
|
2094
2096
|
connectionRequest: ReturnType<typeof connectionRequest>;
|
|
2095
2097
|
};
|
|
2096
|
-
createAuthConfig: AuthConfigs['create'];
|
|
2097
|
-
initiateConnection: ConnectedAccounts['initiate'];
|
|
2098
2098
|
/**
|
|
2099
2099
|
* @param {Object} config Configuration for the Composio SDK.
|
|
2100
2100
|
* @param {string} config.apiKey The API key for the Composio SDK.
|
|
@@ -2116,20 +2116,6 @@ declare class Composio<TProvider extends BaseComposioProvider<unknown, unknown>
|
|
|
2116
2116
|
* @returns {ComposioClient} The Composio API client.
|
|
2117
2117
|
*/
|
|
2118
2118
|
getClient(): ComposioClient;
|
|
2119
|
-
/**
|
|
2120
|
-
* Fetch all the tools from Composio.
|
|
2121
|
-
* @param {ToolListParams} params Parameters to fetch the tools.
|
|
2122
|
-
* @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
|
|
2123
|
-
* @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
|
|
2124
|
-
*/
|
|
2125
|
-
getTools<T extends TProvider>(userId: string, filters: ToolListParams, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTools']>>;
|
|
2126
|
-
/**
|
|
2127
|
-
* Fetch a tool from Composio by its slug.
|
|
2128
|
-
* @param {string} slug slug of the tool
|
|
2129
|
-
* @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
|
|
2130
|
-
* @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
|
|
2131
|
-
*/
|
|
2132
|
-
getToolBySlug<T extends TProvider>(userId: string, slug: string, modifiers?: ProviderOptions<T>): Promise<ReturnType<T['wrapTool']>>;
|
|
2133
2119
|
}
|
|
2134
2120
|
|
|
2135
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
|
|
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.
|
|
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);
|
|
@@ -1501,6 +1503,26 @@ var ConnectedAccounts = class {
|
|
|
1501
1503
|
});
|
|
1502
1504
|
return new ConnectionRequest(this.client, response.id, response.status, response.redirect_uri);
|
|
1503
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
|
+
}
|
|
1504
1526
|
/**
|
|
1505
1527
|
* Get a connected account by nanoid
|
|
1506
1528
|
* @param {string} nanoid - Unique identifier of the connected account
|
|
@@ -1508,7 +1530,27 @@ var ConnectedAccounts = class {
|
|
|
1508
1530
|
* @returns {Promise<ConnectedAccountRetrieveResponse>} Connected account details
|
|
1509
1531
|
*/
|
|
1510
1532
|
async get(nanoid) {
|
|
1511
|
-
|
|
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;
|
|
1512
1554
|
}
|
|
1513
1555
|
/**
|
|
1514
1556
|
* Delete a connected account
|
|
@@ -2436,7 +2478,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
2436
2478
|
};
|
|
2437
2479
|
|
|
2438
2480
|
// package.json
|
|
2439
|
-
var version = "0.1.12-alpha.
|
|
2481
|
+
var version = "0.1.12-alpha.4";
|
|
2440
2482
|
|
|
2441
2483
|
// src/utils/uuid.ts
|
|
2442
2484
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -2469,8 +2511,6 @@ var Composio = class {
|
|
|
2469
2511
|
// connected accounts
|
|
2470
2512
|
connectedAccounts;
|
|
2471
2513
|
experimental;
|
|
2472
|
-
createAuthConfig;
|
|
2473
|
-
initiateConnection;
|
|
2474
2514
|
/**
|
|
2475
2515
|
* @param {Object} config Configuration for the Composio SDK.
|
|
2476
2516
|
* @param {string} config.apiKey The API key for the Composio SDK.
|
|
@@ -2498,13 +2538,10 @@ var Composio = class {
|
|
|
2498
2538
|
};
|
|
2499
2539
|
this.provider = config.provider ?? new OpenAIProvider();
|
|
2500
2540
|
this.tools = new Tools(this.client, this.provider);
|
|
2501
|
-
this.provider._setExecuteToolFn(this.tools.execute);
|
|
2502
2541
|
this.toolkits = new Toolkits(this.client);
|
|
2503
2542
|
this.triggers = new Triggers(this.client);
|
|
2504
2543
|
this.authConfigs = new AuthConfigs(this.client);
|
|
2505
|
-
this.createAuthConfig = this.authConfigs.create.bind(this.authConfigs);
|
|
2506
2544
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
2507
|
-
this.initiateConnection = this.connectedAccounts.initiate.bind(this.connectedAccounts);
|
|
2508
2545
|
this.experimental = {
|
|
2509
2546
|
connectionRequest: connectionRequest(this.client)
|
|
2510
2547
|
};
|
|
@@ -2551,24 +2588,6 @@ var Composio = class {
|
|
|
2551
2588
|
}
|
|
2552
2589
|
return this.client;
|
|
2553
2590
|
}
|
|
2554
|
-
/**
|
|
2555
|
-
* Fetch all the tools from Composio.
|
|
2556
|
-
* @param {ToolListParams} params Parameters to fetch the tools.
|
|
2557
|
-
* @param {ProviderOptions<TProvider>} modifiers Modifiers to apply to the tools.
|
|
2558
|
-
* @returns {Promise<ReturnType<TProvider['getTools']>>} The tools from the provider.
|
|
2559
|
-
*/
|
|
2560
|
-
getTools(userId, filters, modifiers) {
|
|
2561
|
-
return this.tools.get(userId, filters, modifiers);
|
|
2562
|
-
}
|
|
2563
|
-
/**
|
|
2564
|
-
* Fetch a tool from Composio by its slug.
|
|
2565
|
-
* @param {string} slug slug of the tool
|
|
2566
|
-
* @param {ProviderOptions<TProvider>} modifiers to be applied to the tool
|
|
2567
|
-
* @returns {Promise<ReturnType<TProvider['getToolBySlug']>>} The tool from the provider.
|
|
2568
|
-
*/
|
|
2569
|
-
getToolBySlug(userId, slug, modifiers) {
|
|
2570
|
-
return this.tools.get(userId, slug, modifiers);
|
|
2571
|
-
}
|
|
2572
2591
|
};
|
|
2573
2592
|
|
|
2574
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.
|
|
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": "
|
|
45
|
+
"gitHead": "ba5a2b5e403cdee65f3acca8d047c62eadce9be0"
|
|
46
46
|
}
|