@devries-cameron20 / composio-1 / commits / 513c0c552
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix typos and toolsets

haxzie committed May 5, 2025 at 19:17 UTC 513c0c552947d3393d4da34d83bd8d892da8f26a
5 files changed +47 -47
packages/core/src/toolset/BaseToolset.ts
+9 -9
@@ -17,7 +17,7 @@ import { ComposioError } from '../utils/error';
17 export abstract class BaseComposioToolset<TToolCollection, TTool>
18 implements Toolset<TTool, TToolCollection>
19 {
20 - protected client: Composio<this> | undefined;
20 + protected composio: Composio<this> | undefined;
21 abstract FILE_NAME: string;
22 protected DEFAULT_ENTITY_ID = 'default';
23
@@ -25,8 +25,8 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
25 * Set the client for the toolset. This is automatically done by the Composio class.
26 * @param client - The Composio client.
27 */
28 - setClient(client: Composio<this>): void {
29 - this.client = client;
28 + setComposio(composio: Composio<this>): void {
29 + this.composio = composio;
30 }
31
32 /**
@@ -42,7 +42,7 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
42 * @returns The tool.
43 */
44 async getToolBySlug(slug: string): Promise<TTool> {
45 - const tool = await this.getComposioClient().tools.getToolBySlug(slug);
45 + const tool = await this.getComposio().tools.getToolBySlug(slug);
46 return this._wrapTool(tool);
47 }
48
@@ -71,14 +71,14 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
71 text?: string;
72 customAuthParams?: CustomAuthParams;
73 }) {
74 - const tool = await this.client?.tools.getToolBySlug(toolSlug);
74 + const tool = await this.getComposio()?.tools.getToolBySlug(toolSlug);
75
76 if (!tool) {
77 throw new ComposioError(`Tool with slug ${toolSlug} not found`);
78 }
79
80 try {
81 - const result = await this.getComposioClient().tools.execute(toolSlug, {
81 + const result = await this.getComposio().tools.execute(toolSlug, {
82 arguments: params,
83 userId: entityId,
84 connectedAccountId: connectedAccountId,
@@ -95,12 +95,12 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
95 * Get the Composio client.
96 * @returns The Composio client.
97 */
98 - protected getComposioClient(): Composio<this> {
99 - if (!this.client) {
98 + protected getComposio(): Composio<this> {
99 + if (!this.composio) {
100 throw new Error(
101 'Client not initialized. Make sure the toolset is properly initialized with Composio.'
102 );
103 }
104 - return this.client;
104 + return this.composio;
105 }
106 }
packages/core/src/toolset/OpenAIToolset.ts
+7 -15
@@ -43,7 +43,7 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
43 * @returns The tools.
44 */
45 async getTools(params?: ToolListParams): Promise<OpenAiToolCollection> {
46 - const tools = await this.client?.tools.getTools(params);
46 + const tools = await this.getComposio()?.tools.getTools(params);
47 return tools?.items.map((tool) => this._wrapTool(tool as Tool)) ?? [];
48 }
49
@@ -57,26 +57,18 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
57 tool: OpenAI.ChatCompletionMessageToolCall,
58 userId?: string
59 ): Promise<string> {
60 -
61 - if (!this.client) {
62 - throw new Error("Client not set");
63 - }
64 -
65 - /**
66 - * @TODO: This is redundant, we should be able to get the tool name from the tool call
67 - */
68 - const toolSchema = await this.client.tools.getToolBySlug(tool.function.name);
60 + const toolSchema = await this.getComposio().tools.getToolBySlug(tool.function.name);
61 const appSlug = toolSchema?.toolkit?.slug.toLowerCase();
62 if (!appSlug) {
63 throw new Error("App slug not found");
64 }
73 - const connectedAccountId = this.client.getConnectedAccountId(appSlug);
65 + const connectedAccountId = this.getComposio().getConnectedAccountId(appSlug);
66 const payload = {
75 - entity_id: userId ?? this.client.userId,
67 + entity_id: userId ?? this.getComposio().userId,
68 connected_account_id: connectedAccountId,
69 arguments: JSON.parse(tool.function.arguments),
70 }
79 - const results = await this.client.tools.execute(toolSchema.slug, payload);
71 + const results = await this.getComposio().tools.execute(toolSchema.slug, payload);
72 return JSON.stringify(results);
73 }
74
@@ -148,7 +140,7 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
140 userId?: string) {
141
142 // @TODO: Log the run stream
151 - const defaultUserId = this.client?.userId;
143 + const defaultUserId = this.getComposio()?.userId;
144 let runId = null;
145
146 // Start processing the runStream events
@@ -238,7 +230,7 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
230 thread: OpenAI.Beta.Threads.Thread,
231 userId?: string
232 ) {
241 - const defaultUserId = this.client?.userId;
233 + const defaultUserId = this.getComposio()?.userId;
234 while (["queued", "in_progress", "requires_action"].includes(run.status)) {
235 // logger.debug(`Current run status: ${run.status}`);
236 const tool_outputs = await this.handleAssistantMessage(
packages/toolsets/cloudflare/src/index.ts
+10 -7
@@ -56,11 +56,11 @@ export class CloudflareToolset extends BaseComposioToolset<
56 * @returns {Promise<Record<string, AiTextGenerationToolInput>>} The tools from the Cloudflare API.
57 */
58 override async getTools(query?: ToolListParams): Promise<AiToolCollection> {
59 - if (!this.client) {
59 + if (!this.getComposio()) {
60 throw new Error('Client not set');
61 }
62
63 - const tools = await this.client.tools.list(query);
63 + const tools = await this.getComposio().tools.getTools(query);
64 return tools.items.reduce(
65 (tools, tool) => ({
66 ...tools,
@@ -80,17 +80,20 @@ export class CloudflareToolset extends BaseComposioToolset<
80 tool: { name: string; arguments: unknown },
81 userId?: string
82 ): Promise<string> {
83 - if (!this.client) {
83 + if (!this.getComposio()) {
84 throw new Error('Client not set');
85 }
86
87 - const toolSchema = await this.client.tools.get(tool.name);
87 + const toolSchema = await this.getComposio().tools.getToolBySlug(tool.name);
88 const appName = toolSchema?.toolkit?.name.toLowerCase();
89 + if (!appName) {
90 + throw new Error('App name not found');
91 + }
92 const args = typeof tool.arguments === 'string' ? JSON.parse(tool.arguments) : tool.arguments;
90 - const results = await this.client?.tools.execute(toolSchema.slug, {
93 + const results = await this.getComposio()?.tools.execute(toolSchema.slug, {
94 arguments: args,
92 - entity_id: userId ?? this.DEFAULT_ENTITY_ID,
93 - connected_account_id: this.client?.getConnectedAccountId(appName),
95 + userId: userId ?? this.DEFAULT_ENTITY_ID,
96 + connectedAccountId: this.getComposio()?.getConnectedAccountId(appName),
97 });
98
99 return JSON.stringify(results);
packages/toolsets/langchain/src/index.ts
+13 -8
@@ -28,26 +28,31 @@ export class LangchainToolset extends BaseComposioToolset<LangChainToolCollectio
28 _wrapTool(tool: Tool): DynamicStructuredTool {
29 const toolName = tool.slug
30 const description = tool.description;
31 - const appName = tool.toolkit.name?.toLowerCase();
31 + const appName = tool.toolkit?.name?.toLowerCase();
32 + if (!appName) {
33 + throw new Error("App name is not defined");
34 + }
35
36 const func = async (...kwargs: unknown[]): Promise<unknown> => {
34 - const connectedAccountId = this.client?.getConnectedAccountId(appName)
37 + const connectedAccountId = this.getComposio()?.getConnectedAccountId(appName)
38 return JSON.stringify(
36 - await this.client?.tools.execute(toolName, {
39 + await this.getComposio()?.tools.execute(toolName, {
40 arguments: kwargs[0] as Record<string, unknown>,
38 - entity_id: this.client.userId ?? this.DEFAULT_ENTITY_ID,
39 - connected_account_id: connectedAccountId,
41 + userId: this.getComposio().userId ?? this.DEFAULT_ENTITY_ID,
42 + connectedAccountId: connectedAccountId,
43 })
44 );
45 };
43 -
46 + if (!tool.input_parameters) {
47 + throw new Error("Tool input parameters are not defined");
48 + }
49 const parameters = jsonSchemaToModel(tool.input_parameters);
50
51 // @TODO: Add escriiption an other stuff here
52
53 return new DynamicStructuredTool({
54 name: toolName,
50 - description,
55 + description: description || "",
56 schema: parameters,
57 func: func,
58 });
@@ -59,7 +64,7 @@ export class LangchainToolset extends BaseComposioToolset<LangChainToolCollectio
64 * @returns The tools.
65 */
66 async getTools(params?: ToolListParams): Promise<LangChainToolCollection> {
62 - const tools = await this.client?.tools.list(params);
67 + const tools = await this.getComposio()?.tools.getTools(params);
68 return tools?.items.map((tool) => this._wrapTool(tool as Tool)) ?? [];
69 }
70 }
packages/toolsets/vercel/src/index.ts
+8 -8
@@ -27,10 +27,10 @@ export class VercelToolset extends BaseComposioToolset<VercelToolCollection, Ver
27 * @returns The tools.
28 */
29 override async getTools(params?: ToolListParams): Promise<VercelToolCollection> {
30 - if (!this.client) {
30 + if (!this.getComposio()) {
31 throw new Error('Client not initialized');
32 }
33 - const tools = await this.client.tools.list(params);
33 + const tools = await this.getComposio().tools.getTools(params);
34 return tools.items.reduce(
35 (tools, tool) => ({
36 ...tools,
@@ -50,18 +50,18 @@ export class VercelToolset extends BaseComposioToolset<VercelToolCollection, Ver
50 tool: { name: string; arguments: unknown },
51 userId?: string
52 ): Promise<string> {
53 - if (!this.client) {
53 + if (!this.getComposio()) {
54 throw new Error('Client not initialized');
55 }
56
57 - const toolSchema = await this.client.tools.get(tool.name);
57 + const toolSchema = await this.getComposio().tools.getToolBySlug(tool.name);
58 const appName = toolSchema?.name.toLowerCase();
59 const args = typeof tool.arguments === 'string' ? JSON.parse(tool.arguments) : tool.arguments;
60
61 - const results = await this.client.tools.execute(toolSchema.slug, {
61 + const results = await this.getComposio().tools.execute(toolSchema.slug, {
62 arguments: args,
63 - entity_id: userId ?? this.client.userId,
64 - connected_account_id: this.client.getConnectedAccountId(appName),
63 + userId: userId ?? this.getComposio().userId,
64 + connectedAccountId: this.getComposio().getConnectedAccountId(appName),
65 });
66
67 return JSON.stringify(results);
@@ -77,7 +77,7 @@ export class VercelToolset extends BaseComposioToolset<VercelToolCollection, Ver
77 name: composioTool.slug,
78 arguments: JSON.stringify(params),
79 },
80 - this.client?.userId
80 + this.getComposio()?.userId
81 );
82 },
83 });