Skip to content

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

haxzie513c0c552947
diff --git a/packages/core/src/toolset/BaseToolset.ts b/packages/core/src/toolset/BaseToolset.ts
index 4ca242f24..4611284f1 100644
--- a/packages/core/src/toolset/BaseToolset.ts
+++ b/packages/core/src/toolset/BaseToolset.ts
@@ -17,7 +17,7 @@ import { ComposioError } from '../utils/error';
export abstract class BaseComposioToolset<TToolCollection, TTool>
implements Toolset<TTool, TToolCollection>
{
- protected client: Composio<this> | undefined;
+ protected composio: Composio<this> | undefined;
abstract FILE_NAME: string;
protected DEFAULT_ENTITY_ID = 'default';
@@ -25,8 +25,8 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
* Set the client for the toolset. This is automatically done by the Composio class.
* @param client - The Composio client.
*/
- setClient(client: Composio<this>): void {
- this.client = client;
+ setComposio(composio: Composio<this>): void {
+ this.composio = composio;
}
/**
@@ -42,7 +42,7 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
* @returns The tool.
*/
async getToolBySlug(slug: string): Promise<TTool> {
- const tool = await this.getComposioClient().tools.getToolBySlug(slug);
+ const tool = await this.getComposio().tools.getToolBySlug(slug);
return this._wrapTool(tool);
}
@@ -71,14 +71,14 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
text?: string;
customAuthParams?: CustomAuthParams;
}) {
- const tool = await this.client?.tools.getToolBySlug(toolSlug);
+ const tool = await this.getComposio()?.tools.getToolBySlug(toolSlug);
if (!tool) {
throw new ComposioError(`Tool with slug ${toolSlug} not found`);
}
try {
- const result = await this.getComposioClient().tools.execute(toolSlug, {
+ const result = await this.getComposio().tools.execute(toolSlug, {
arguments: params,
userId: entityId,
connectedAccountId: connectedAccountId,
@@ -95,12 +95,12 @@ export abstract class BaseComposioToolset<TToolCollection, TTool>
* Get the Composio client.
* @returns The Composio client.
*/
- protected getComposioClient(): Composio<this> {
- if (!this.client) {
+ protected getComposio(): Composio<this> {
+ if (!this.composio) {
throw new Error(
'Client not initialized. Make sure the toolset is properly initialized with Composio.'
);
}
- return this.client;
+ return this.composio;
}
}
diff --git a/packages/core/src/toolset/OpenAIToolset.ts b/packages/core/src/toolset/OpenAIToolset.ts
index f11ddd77d..7d9ebe848 100644
--- a/packages/core/src/toolset/OpenAIToolset.ts
+++ b/packages/core/src/toolset/OpenAIToolset.ts
@@ -43,7 +43,7 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
* @returns The tools.
*/
async getTools(params?: ToolListParams): Promise<OpenAiToolCollection> {
- const tools = await this.client?.tools.getTools(params);
+ const tools = await this.getComposio()?.tools.getTools(params);
return tools?.items.map((tool) => this._wrapTool(tool as Tool)) ?? [];
}
@@ -57,26 +57,18 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
tool: OpenAI.ChatCompletionMessageToolCall,
userId?: string
): Promise<string> {
-
- if (!this.client) {
- throw new Error("Client not set");
- }
-
- /**
- * @TODO: This is redundant, we should be able to get the tool name from the tool call
- */
- const toolSchema = await this.client.tools.getToolBySlug(tool.function.name);
+ const toolSchema = await this.getComposio().tools.getToolBySlug(tool.function.name);
const appSlug = toolSchema?.toolkit?.slug.toLowerCase();
if (!appSlug) {
throw new Error("App slug not found");
}
- const connectedAccountId = this.client.getConnectedAccountId(appSlug);
+ const connectedAccountId = this.getComposio().getConnectedAccountId(appSlug);
const payload = {
- entity_id: userId ?? this.client.userId,
+ entity_id: userId ?? this.getComposio().userId,
connected_account_id: connectedAccountId,
arguments: JSON.parse(tool.function.arguments),
}
- const results = await this.client.tools.execute(toolSchema.slug, payload);
+ const results = await this.getComposio().tools.execute(toolSchema.slug, payload);
return JSON.stringify(results);
}
@@ -148,7 +140,7 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
userId?: string) {
// @TODO: Log the run stream
- const defaultUserId = this.client?.userId;
+ const defaultUserId = this.getComposio()?.userId;
let runId = null;
// Start processing the runStream events
@@ -238,7 +230,7 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAiToolCollection, Ope
thread: OpenAI.Beta.Threads.Thread,
userId?: string
) {
- const defaultUserId = this.client?.userId;
+ const defaultUserId = this.getComposio()?.userId;
while (["queued", "in_progress", "requires_action"].includes(run.status)) {
// logger.debug(`Current run status: ${run.status}`);
const tool_outputs = await this.handleAssistantMessage(
diff --git a/packages/toolsets/cloudflare/src/index.ts b/packages/toolsets/cloudflare/src/index.ts
index ccb5b3aa1..c22150a29 100644
--- a/packages/toolsets/cloudflare/src/index.ts
+++ b/packages/toolsets/cloudflare/src/index.ts
@@ -56,11 +56,11 @@ export class CloudflareToolset extends BaseComposioToolset<
* @returns {Promise<Record<string, AiTextGenerationToolInput>>} The tools from the Cloudflare API.
*/
override async getTools(query?: ToolListParams): Promise<AiToolCollection> {
- if (!this.client) {
+ if (!this.getComposio()) {
throw new Error('Client not set');
}
- const tools = await this.client.tools.list(query);
+ const tools = await this.getComposio().tools.getTools(query);
return tools.items.reduce(
(tools, tool) => ({
...tools,
@@ -80,17 +80,20 @@ export class CloudflareToolset extends BaseComposioToolset<
tool: { name: string; arguments: unknown },
userId?: string
): Promise<string> {
- if (!this.client) {
+ if (!this.getComposio()) {
throw new Error('Client not set');
}
- const toolSchema = await this.client.tools.get(tool.name);
+ const toolSchema = await this.getComposio().tools.getToolBySlug(tool.name);
const appName = toolSchema?.toolkit?.name.toLowerCase();
+ if (!appName) {
+ throw new Error('App name not found');
+ }
const args = typeof tool.arguments === 'string' ? JSON.parse(tool.arguments) : tool.arguments;
- const results = await this.client?.tools.execute(toolSchema.slug, {
+ const results = await this.getComposio()?.tools.execute(toolSchema.slug, {
arguments: args,
- entity_id: userId ?? this.DEFAULT_ENTITY_ID,
- connected_account_id: this.client?.getConnectedAccountId(appName),
+ userId: userId ?? this.DEFAULT_ENTITY_ID,
+ connectedAccountId: this.getComposio()?.getConnectedAccountId(appName),
});
return JSON.stringify(results);
diff --git a/packages/toolsets/langchain/src/index.ts b/packages/toolsets/langchain/src/index.ts
index d2c82ceb5..a9c72ba62 100644
--- a/packages/toolsets/langchain/src/index.ts
+++ b/packages/toolsets/langchain/src/index.ts
@@ -28,26 +28,31 @@ export class LangchainToolset extends BaseComposioToolset<LangChainToolCollectio
_wrapTool(tool: Tool): DynamicStructuredTool {
const toolName = tool.slug
const description = tool.description;
- const appName = tool.toolkit.name?.toLowerCase();
+ const appName = tool.toolkit?.name?.toLowerCase();
+ if (!appName) {
+ throw new Error("App name is not defined");
+ }
const func = async (...kwargs: unknown[]): Promise<unknown> => {
- const connectedAccountId = this.client?.getConnectedAccountId(appName)
+ const connectedAccountId = this.getComposio()?.getConnectedAccountId(appName)
return JSON.stringify(
- await this.client?.tools.execute(toolName, {
+ await this.getComposio()?.tools.execute(toolName, {
arguments: kwargs[0] as Record<string, unknown>,
- entity_id: this.client.userId ?? this.DEFAULT_ENTITY_ID,
- connected_account_id: connectedAccountId,
+ userId: this.getComposio().userId ?? this.DEFAULT_ENTITY_ID,
+ connectedAccountId: connectedAccountId,
})
);
};
-
+ if (!tool.input_parameters) {
+ throw new Error("Tool input parameters are not defined");
+ }
const parameters = jsonSchemaToModel(tool.input_parameters);
// @TODO: Add escriiption an other stuff here
return new DynamicStructuredTool({
name: toolName,
- description,
+ description: description || "",
schema: parameters,
func: func,
});
@@ -59,7 +64,7 @@ export class LangchainToolset extends BaseComposioToolset<LangChainToolCollectio
* @returns The tools.
*/
async getTools(params?: ToolListParams): Promise<LangChainToolCollection> {
- const tools = await this.client?.tools.list(params);
+ const tools = await this.getComposio()?.tools.getTools(params);
return tools?.items.map((tool) => this._wrapTool(tool as Tool)) ?? [];
}
}
diff --git a/packages/toolsets/vercel/src/index.ts b/packages/toolsets/vercel/src/index.ts
index 24f9d440b..36864e472 100644
--- a/packages/toolsets/vercel/src/index.ts
+++ b/packages/toolsets/vercel/src/index.ts
@@ -27,10 +27,10 @@ export class VercelToolset extends BaseComposioToolset<VercelToolCollection, Ver
* @returns The tools.
*/
override async getTools(params?: ToolListParams): Promise<VercelToolCollection> {
- if (!this.client) {
+ if (!this.getComposio()) {
throw new Error('Client not initialized');
}
- const tools = await this.client.tools.list(params);
+ const tools = await this.getComposio().tools.getTools(params);
return tools.items.reduce(
(tools, tool) => ({
...tools,
@@ -50,18 +50,18 @@ export class VercelToolset extends BaseComposioToolset<VercelToolCollection, Ver
tool: { name: string; arguments: unknown },
userId?: string
): Promise<string> {
- if (!this.client) {
+ if (!this.getComposio()) {
throw new Error('Client not initialized');
}
- const toolSchema = await this.client.tools.get(tool.name);
+ const toolSchema = await this.getComposio().tools.getToolBySlug(tool.name);
const appName = toolSchema?.name.toLowerCase();
const args = typeof tool.arguments === 'string' ? JSON.parse(tool.arguments) : tool.arguments;
- const results = await this.client.tools.execute(toolSchema.slug, {
+ const results = await this.getComposio().tools.execute(toolSchema.slug, {
arguments: args,
- entity_id: userId ?? this.client.userId,
- connected_account_id: this.client.getConnectedAccountId(appName),
+ userId: userId ?? this.getComposio().userId,
+ connectedAccountId: this.getComposio().getConnectedAccountId(appName),
});
return JSON.stringify(results);
@@ -77,7 +77,7 @@ export class VercelToolset extends BaseComposioToolset<VercelToolCollection, Ver
name: composioTool.slug,
arguments: JSON.stringify(params),
},
- this.client?.userId
+ this.getComposio()?.userId
);
},
});