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.

Rename composiotools to rawcomposiotools

haxzie8f5a1773cb28
diff --git a/packages/core/src/models/Tools.ts b/packages/core/src/models/Tools.ts
index 2f1fea8fa..beba52bd6 100644
--- a/packages/core/src/models/Tools.ts
+++ b/packages/core/src/models/Tools.ts
@@ -65,8 +65,8 @@ export class Tools<
// Bind methods that use customTools to ensure correct 'this' context
this.execute = this.execute.bind(this);
- this.getComposioToolBySlug = this.getComposioToolBySlug.bind(this);
- this.getComposioTools = this.getComposioTools.bind(this);
+ this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
+ this.getRawComposioTools = this.getRawComposioTools.bind(this);
}
/**
@@ -163,7 +163,7 @@ export class Tools<
userId: string,
toolSlug: string
): Promise<string | null> {
- const tool = await this.getComposioToolBySlug(userId, toolSlug);
+ const tool = await this.getRawComposioToolBySlug(userId, toolSlug);
if (!tool.toolkit) {
throw new Error(`Unable to find toolkit for tool ${toolSlug}`);
}
@@ -203,7 +203,7 @@ export class Tools<
* This method fetches the tools from the Composio API and wraps them using the provider.
* @returns {ToolList} List of tools
*/
- async getComposioTools(
+ async getRawComposioTools(
userId: string,
query: ToolListParams = {},
modifier?: TransformToolSchemaModifier
@@ -262,10 +262,10 @@ export class Tools<
*
* @example
* ```ts
- * const tool = await composio.tools.getComposioToolBySlug('default', 'github');
+ * const tool = await composio.tools.getRawComposioToolBySlug('default', 'github');
* ```
*/
- async getComposioToolBySlug(
+ async getRawComposioToolBySlug(
userId: string,
slug: string,
modifier?: TransformToolSchemaModifier
@@ -279,7 +279,7 @@ export class Tools<
const tool = await this.client.tools.retrieve(slug);
if (!tool) {
throw new ComposioToolNotFoundError(
- `[getComposioToolBySlug] Tool with slug ${slug} not found`
+ `[getRawComposioToolBySlug] Tool with slug ${slug} not found`
);
}
// change the case of the tool to camel case
@@ -349,11 +349,11 @@ export class Tools<
const executeToolFn = this.createExecuteToolFn(userId, options as ExecuteToolModifiers);
// if the first argument is a string, get a single tool
if (typeof arg2 === 'string') {
- const tool = await this.getComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
+ const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
return this.provider.wrapTool(tool, executeToolFn) as TTool;
} else {
// if the first argument is an object, get a list of tools
- const tools = await this.getComposioTools(userId, arg2, options?.modifyToolSchema);
+ const tools = await this.getRawComposioTools(userId, arg2, options?.modifyToolSchema);
return this.provider.wrapTools(tools, executeToolFn) as TToolCollection;
}
}
@@ -502,7 +502,7 @@ export class Tools<
return this.handleCustomToolExecution(customTool, body, modifiers);
} else {
// handle composio tool execution
- const composioTool = await this.getComposioToolBySlug(body.userId, slug);
+ const composioTool = await this.getRawComposioToolBySlug(body.userId, slug);
if (!composioTool) {
throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
}
diff --git a/packages/core/test/tools/modifiers.test.ts b/packages/core/test/tools/modifiers.test.ts
index 6a84bc269..659da7511 100644
--- a/packages/core/test/tools/modifiers.test.ts
+++ b/packages/core/test/tools/modifiers.test.ts
@@ -26,7 +26,7 @@ describe('Tools Modifiers', () => {
// mock client to send back the tool
mockClient.tools.retrieve.mockResolvedValueOnce(toolMocks.rawTool);
- const result = await context.tools.getComposioToolBySlug(userId, slug, schemaModifier);
+ const result = await context.tools.getRawComposioToolBySlug(userId, slug, schemaModifier);
expect(schemaModifier).toHaveBeenCalledTimes(1);
expect(schemaModifier).toHaveBeenCalledWith(
@@ -53,7 +53,7 @@ describe('Tools Modifiers', () => {
totalPages: 1,
});
- const result = await context.tools.getComposioTools(userId, {}, schemaModifier);
+ const result = await context.tools.getRawComposioTools(userId, {}, schemaModifier);
expect(schemaModifier).toHaveBeenCalledTimes(2);
expect(result[0].name).toContain('Modified');
@@ -125,8 +125,8 @@ describe('Tools Modifiers', () => {
const executionModifiers = createExecutionModifiers();
- const getComposioToolBySlugSpy = vi.spyOn(context.tools, 'getComposioToolBySlug');
- getComposioToolBySlugSpy.mockResolvedValueOnce({
+ const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
+ getRawComposioToolBySlugSpy.mockResolvedValueOnce({
...(toolMocks.transformedTool as unknown as Tool),
description: 'Modified schema',
});
@@ -138,7 +138,7 @@ describe('Tools Modifiers', () => {
...executionModifiers,
});
- expect(getComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
expect(createExecuteToolFnSpy).toHaveBeenCalledWith(
userId,
expect.objectContaining(executionModifiers)
diff --git a/packages/core/test/tools/tools.test.ts b/packages/core/test/tools/tools.test.ts
index abe94d5da..c32a7d575 100644
--- a/packages/core/test/tools/tools.test.ts
+++ b/packages/core/test/tools/tools.test.ts
@@ -33,7 +33,7 @@ describe('Tools', () => {
});
});
- describe('getComposioTools', () => {
+ describe('getRawComposioTools', () => {
it('should fetch tools from the API', async () => {
const userId = 'test-user';
@@ -42,7 +42,7 @@ describe('Tools', () => {
totalPages: 1,
});
- const result = await context.tools.getComposioTools(userId);
+ const result = await context.tools.getRawComposioTools(userId);
expect(mockClient.tools.list).toHaveBeenCalledTimes(1);
expect(result).toHaveLength(1);
@@ -62,7 +62,7 @@ describe('Tools', () => {
totalPages: 1,
});
- await context.tools.getComposioTools(userId, query);
+ await context.tools.getRawComposioTools(userId, query);
expect(mockClient.tools.list).toHaveBeenCalledWith({
tool_slugs: ['TOOL1', 'TOOL2'],
@@ -82,7 +82,7 @@ describe('Tools', () => {
totalPages: 1,
});
- const result = await context.tools.getComposioTools(userId);
+ const result = await context.tools.getRawComposioTools(userId);
expect(result[0].inputParameters).toEqual(toolMocks.transformedTool.inputParameters);
expect(result[0].outputParameters).toEqual(toolMocks.transformedTool.outputParameters);
@@ -99,7 +99,7 @@ describe('Tools', () => {
const getCustomToolsSpy = vi.spyOn(context.tools['customTools'], 'getCustomTools');
getCustomToolsSpy.mockResolvedValueOnce([toolMocks.customTool as unknown as Tool]);
- const result = await context.tools.getComposioTools(userId);
+ const result = await context.tools.getRawComposioTools(userId);
expect(result).toHaveLength(2);
expect(result[1].slug).toEqual(toolMocks.customTool.slug);
@@ -116,7 +116,7 @@ describe('Tools', () => {
totalPages: 1,
});
- const result = await context.tools.getComposioTools(userId, {}, schemaModifier);
+ const result = await context.tools.getRawComposioTools(userId, {}, schemaModifier);
expect(schemaModifier).toHaveBeenCalled();
expect(result[0].description).toEqual('Modified description');
@@ -131,20 +131,20 @@ describe('Tools', () => {
totalPages: 1,
});
- await expect(context.tools.getComposioTools(userId, {}, invalidModifier)).rejects.toThrow(
+ await expect(context.tools.getRawComposioTools(userId, {}, invalidModifier)).rejects.toThrow(
'Invalid schema modifier. Not a function.'
);
});
});
- describe('getComposioToolBySlug', () => {
+ describe('getRawComposioToolBySlug', () => {
it('should fetch a tool by slug from the API', async () => {
const userId = 'test-user';
const slug = 'TOOL_SLUG';
mockClient.tools.retrieve.mockResolvedValueOnce(toolMocks.rawTool);
- const result = await context.tools.getComposioToolBySlug(userId, slug);
+ const result = await context.tools.getRawComposioToolBySlug(userId, slug);
expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug);
expect(result.slug).toEqual(toolMocks.transformedTool.slug);
@@ -157,7 +157,7 @@ describe('Tools', () => {
const getCustomToolBySlugSpy = vi.spyOn(context.tools['customTools'], 'getCustomToolBySlug');
getCustomToolBySlugSpy.mockResolvedValueOnce(toolMocks.customTool as unknown as Tool);
- const result = await context.tools.getComposioToolBySlug(userId, slug);
+ const result = await context.tools.getRawComposioToolBySlug(userId, slug);
expect(getCustomToolBySlugSpy).toHaveBeenCalledWith(slug);
expect(mockClient.tools.retrieve).not.toHaveBeenCalled();
@@ -172,7 +172,7 @@ describe('Tools', () => {
getCustomToolBySlugSpy.mockResolvedValueOnce(undefined);
mockClient.tools.retrieve.mockResolvedValueOnce(null);
- await expect(context.tools.getComposioToolBySlug(userId, slug)).rejects.toThrow(
+ await expect(context.tools.getRawComposioToolBySlug(userId, slug)).rejects.toThrow(
`Tool with slug ${slug} not found`
);
});
@@ -186,7 +186,7 @@ describe('Tools', () => {
mockClient.tools.retrieve.mockResolvedValueOnce(toolMocks.rawTool);
- const result = await context.tools.getComposioToolBySlug(userId, slug, schemaModifier);
+ const result = await context.tools.getRawComposioToolBySlug(userId, slug, schemaModifier);
expect(schemaModifier).toHaveBeenCalled();
expect(result.description).toEqual('Modified description');
@@ -198,14 +198,16 @@ describe('Tools', () => {
const userId = 'test-user';
const slug = 'TOOL_SLUG';
- const getComposioToolBySlugSpy = vi.spyOn(context.tools, 'getComposioToolBySlug');
- getComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
+ const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
+ getRawComposioToolBySlugSpy.mockResolvedValueOnce(
+ toolMocks.transformedTool as unknown as Tool
+ );
context.mockProvider.wrapTool.mockReturnValueOnce('wrapped-tool');
const result = await context.tools.get(userId, slug);
- expect(getComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, undefined);
+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, undefined);
expect(context.mockProvider.wrapTool).toHaveBeenCalled();
expect(result).toEqual('wrapped-tool');
});
@@ -214,14 +216,14 @@ describe('Tools', () => {
const userId = 'test-user';
const filters = { tools: ['TOOL1', 'TOOL2'] };
- const getComposioToolsSpy = vi.spyOn(context.tools, 'getComposioTools');
- getComposioToolsSpy.mockResolvedValueOnce([toolMocks.transformedTool as unknown as Tool]);
+ const getRawComposioToolsSpy = vi.spyOn(context.tools, 'getRawComposioTools');
+ getRawComposioToolsSpy.mockResolvedValueOnce([toolMocks.transformedTool as unknown as Tool]);
context.mockProvider.wrapTools.mockReturnValueOnce('wrapped-tools');
const result = await context.tools.get(userId, filters);
- expect(getComposioToolsSpy).toHaveBeenCalledWith(userId, filters, undefined);
+ expect(getRawComposioToolsSpy).toHaveBeenCalledWith(userId, filters, undefined);
expect(context.mockProvider.wrapTools).toHaveBeenCalled();
expect(result).toEqual('wrapped-tools');
});
@@ -233,12 +235,14 @@ describe('Tools', () => {
description: 'Modified description',
});
- const getComposioToolBySlugSpy = vi.spyOn(context.tools, 'getComposioToolBySlug');
- getComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
+ const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
+ getRawComposioToolBySlugSpy.mockResolvedValueOnce(
+ toolMocks.transformedTool as unknown as Tool
+ );
await context.tools.get(userId, slug, { modifyToolSchema: schemaModifier });
- expect(getComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
+ expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
});
});
diff --git a/packages/core/test/utils/toolExecuteUtils.ts b/packages/core/test/utils/toolExecuteUtils.ts
index 47e0c9cba..375c05490 100644
--- a/packages/core/test/utils/toolExecuteUtils.ts
+++ b/packages/core/test/utils/toolExecuteUtils.ts
@@ -45,8 +45,8 @@ export const mockToolExecution = async (
);
// Mock composio tool retrieval
- const getComposioToolBySlugSpy = vi.spyOn(tools, 'getComposioToolBySlug');
- getComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
+ const getRawComposioToolBySlugSpy = vi.spyOn(tools, 'getRawComposioToolBySlug');
+ getRawComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
// Mock connected account
const getConnectedAccountIdForToolSpy = vi.spyOn(
@@ -62,7 +62,7 @@ export const mockToolExecution = async (
return {
getCustomToolBySlugSpy,
- getComposioToolBySlugSpy,
+ getRawComposioToolBySlugSpy,
getConnectedAccountIdForToolSpy,
};
};