Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 23, 03:00 UTC
Update the sdk client to alpha10
haxzie committed
May 19, 2025 at 17:15 UTC
8cded8b41b4b243883a4e987fdf851ef8559f52b
8 files changed
+51
-17
packages/core/package.json
+1
-1
@@ -35,7 +35,7 @@
35
"vitest": "^3.1.3"
36
},
37
"dependencies": {
38
- "@composio/client": "0.1.0-alpha.9",
38
+ "@composio/client": "^0.1.0-alpha.10",
39
"openai": "^4.94.0",
40
"pusher-js": "^8.4.0",
41
"uuid": "^11.1.0",
packages/core/src/models/AuthConfigs.ts
+19
-5
@@ -20,6 +20,7 @@ import {
20
AuthConfigRetrieveResponse,
21
AuthConfigRetrieveResponseSchema,
22
AuthConfigUpdateParams,
23
+ AuthConfigUpdateParamsSchema,
24
CreateAuthConfigParams,
25
CreateAuthConfigParamsSchema,
26
CreateAuthConfigResponse,
@@ -164,11 +165,24 @@ export class AuthConfigs {
165
* @returns {Promise<AuthConfigUpdateResponse>} Updated auth config
166
*/
167
async update(nanoid: string, data: AuthConfigUpdateParams): Promise<AuthConfigUpdateResponse> {
167
- return this.client.authConfigs.update(nanoid, {
168
- auth_config: {
169
- credentials: data.credentials,
170
- },
171
- });
168
+ const parsedData = AuthConfigUpdateParamsSchema.safeParse(data);
169
+ if (parsedData.error) {
170
+ throw new ValidationError(parsedData.error);
171
+ }
172
+ return this.client.authConfigs.update(
173
+ nanoid,
174
+ parsedData.data.type === 'custom'
175
+ ? {
176
+ type: 'custom',
177
+ credentials: parsedData.data.credentials,
178
+ restrict_to_following_tools: parsedData.data.restrictToFollowingTools,
179
+ }
180
+ : {
181
+ type: 'default',
182
+ scopes: parsedData.data.scopes,
183
+ restrict_to_following_tools: parsedData.data.restrictToFollowingTools,
184
+ }
185
+ );
186
}
187
188
/**
packages/core/src/models/Tools.ts
+5
-5
@@ -106,7 +106,7 @@ export class Tools<
106
* @returns {Promise<boolean>} True if the connected account exists for the given tools, false otherwise.
107
*/
108
private async checkIfConnectedAccountExistsForTools(
109
- userId: string,
109
+ userIds: string[],
110
tools: ToolList
111
): Promise<boolean> {
112
// @TODO: Filter out tools that don't require a connected account
@@ -116,7 +116,7 @@ export class Tools<
116
return true;
117
}
118
const connectedAccounts = await this.client.connectedAccounts.list({
119
- user_id: userId,
119
+ user_ids: userIds,
120
});
121
// if no connected accounts, return false
122
if (connectedAccounts.items.length === 0) {
@@ -180,8 +180,8 @@ export class Tools<
180
// if the toolkit is not a no auth app, fetch connected accounts
181
if (!isNoAuthApp) {
182
const connectedAccounts = await this.client.connectedAccounts.list({
183
- user_id: userId,
184
- toolkit_slug: tool.toolkit.slug,
183
+ user_ids: [userId],
184
+ toolkit_slugs: [tool.toolkit.slug],
185
});
186
// if no connected accounts, throw an error
187
if (connectedAccounts.items.length === 0) {
@@ -214,7 +214,7 @@ export class Tools<
214
}
215
216
const tools = await this.client.tools.list({
217
- tool_slugs: queryParams.data.tools?.join(','),
217
+ tool_slugs: queryParams.data.tools,
218
toolkit_slug: queryParams.data.toolkits?.join(','),
219
cursor: queryParams.data.cursor,
220
important: queryParams.data.important,
packages/core/src/models/Triggers.ts
+1
@@ -162,6 +162,7 @@ export class Triggers {
162
const clientId = sessionInfo.project?.id;
163
164
if (!clientId) throw new Error('Client ID not found');
165
+ if (!this.client.apiKey) throw new Error('API key not found');
166
167
await PusherUtils.getPusherClient(this.client.baseURL, this.client.apiKey);
168
packages/core/src/types/authConfigs.types.ts
+16
-2
@@ -104,7 +104,21 @@ export const AuthConfigListResponseSchema = z.object({
104
});
105
export type AuthConfigListResponse = z.infer<typeof AuthConfigListResponseSchema>;
106
107
-export const AuthConfigUpdateParamsSchema = z.object({
108
- credentials: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])),
107
+export const AuthCustomConfigUpdateParamsSchema = z.object({
108
+ credentials: z.record(z.string(), z.union([z.string(), z.unknown()])),
109
+ type: z.literal('custom'),
110
+ restrictToFollowingTools: z.array(z.string()).optional(),
111
+});
112
+
113
+export const AuthDefaultConfigUpdateParamsSchema = z.object({
114
+ scopes: z.string(),
115
+ type: z.literal('default'),
116
+ restrictToFollowingTools: z.array(z.string()).optional(),
117
});
118
+
119
+export const AuthConfigUpdateParamsSchema = z.discriminatedUnion('type', [
120
+ AuthCustomConfigUpdateParamsSchema,
121
+ AuthDefaultConfigUpdateParamsSchema,
122
+]);
123
+
124
export type AuthConfigUpdateParams = z.infer<typeof AuthConfigUpdateParamsSchema>;
packages/core/src/types/toolkit.types.ts
+1
-1
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
/**
4
* Toolkit list params
5
*/
6
-export const ToolkitMangedByEnumSchema = z.enum(['all', 'composio_managed', 'project_managed']);
6
+export const ToolkitMangedByEnumSchema = z.enum(['all', 'composio', 'project']);
7
export const ToolkitSortByEnumSchema = z.enum(['usage', 'alphabetically']);
8
export const ToolkitsListParamsSchema = z.object({
9
category: z.string().optional(),
packages/core/test/tools/tools.test.ts
+1
-1
@@ -65,7 +65,7 @@ describe('Tools', () => {
65
await context.tools.getComposioTools(userId, query);
66
67
expect(mockClient.tools.list).toHaveBeenCalledWith({
68
- tool_slugs: 'TOOL1,TOOL2',
68
+ tool_slugs: ['TOOL1', 'TOOL2'],
69
limit: '10',
70
cursor: undefined,
71
important: undefined,
pnpm-lock.yaml
+7
-2
@@ -180,8 +180,8 @@ importers:
180
packages/core:
181
dependencies:
182
'@composio/client':
183
- specifier: 0.1.0-alpha.9
184
- version: 0.1.0-alpha.9
183
+ specifier: ^0.1.0-alpha.10
184
+ version: 0.1.0-alpha.10
185
openai:
186
specifier: ^4.94.0
187
version: 4.98.0(encoding@0.1.13)(zod@3.24.4)
@@ -323,6 +323,9 @@ packages:
323
'@cloudflare/workers-types@4.20250515.0':
324
resolution: {integrity: sha512-KoHFMH04gOXp3KEI+wrFIU+3ZfoSXnwqZTpybNQjalHoN3pWjtWBb/030cCRAZ639YX+DAHAxNF7AvEYGz1oaA==}
325
326
+ '@composio/client@0.1.0-alpha.10':
327
+ resolution: {integrity: sha512-ieaVXwx9A0zKvLS6yFEr7YZCAoBHQrPzFK8jTjN8QDjqLdQEuufuFfzM5ZUEN5UCX2bckR77OplZZjAn3TikWA==}
328
+
329
'@composio/client@0.1.0-alpha.9':
330
resolution: {integrity: sha512-uhXW5NxIY+j5IZ7WnzOLrVmOAhSCb1FdQbvDxPCcQqpE7d78uRHS9i/aK4Xn6UNIPv+pt1BT8unR0zEdKjG3Ng==}
331
@@ -3997,6 +4000,8 @@ snapshots:
4000
4001
'@cloudflare/workers-types@4.20250515.0': {}
4002
4003
+ '@composio/client@0.1.0-alpha.10': {}
4004
+
4005
'@composio/client@0.1.0-alpha.9': {}
4006
4007
'@composio/core@0.1.9-alpha.0(encoding@0.1.13)':