@devries-cameron20 / composio-1 / commits / 8f5a1773c
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.

Rename composiotools to rawcomposiotools

haxzie committed May 19, 2025 at 18:38 UTC 8f5a1773cb28ec926455039ae496768f401a9f41
4 files changed +43 -39
packages/core/src/models/Tools.ts
+10 -10
@@ -65,8 +65,8 @@ export class Tools<
65
66 // Bind methods that use customTools to ensure correct 'this' context
67 this.execute = this.execute.bind(this);
68 - this.getComposioToolBySlug = this.getComposioToolBySlug.bind(this);
69 - this.getComposioTools = this.getComposioTools.bind(this);
68 + this.getRawComposioToolBySlug = this.getRawComposioToolBySlug.bind(this);
69 + this.getRawComposioTools = this.getRawComposioTools.bind(this);
70 }
71
72 /**
@@ -163,7 +163,7 @@ export class Tools<
163 userId: string,
164 toolSlug: string
165 ): Promise<string | null> {
166 - const tool = await this.getComposioToolBySlug(userId, toolSlug);
166 + const tool = await this.getRawComposioToolBySlug(userId, toolSlug);
167 if (!tool.toolkit) {
168 throw new Error(`Unable to find toolkit for tool ${toolSlug}`);
169 }
@@ -203,7 +203,7 @@ export class Tools<
203 * This method fetches the tools from the Composio API and wraps them using the provider.
204 * @returns {ToolList} List of tools
205 */
206 - async getComposioTools(
206 + async getRawComposioTools(
207 userId: string,
208 query: ToolListParams = {},
209 modifier?: TransformToolSchemaModifier
@@ -262,10 +262,10 @@ export class Tools<
262 *
263 * @example
264 * ```ts
265 - * const tool = await composio.tools.getComposioToolBySlug('default', 'github');
265 + * const tool = await composio.tools.getRawComposioToolBySlug('default', 'github');
266 * ```
267 */
268 - async getComposioToolBySlug(
268 + async getRawComposioToolBySlug(
269 userId: string,
270 slug: string,
271 modifier?: TransformToolSchemaModifier
@@ -279,7 +279,7 @@ export class Tools<
279 const tool = await this.client.tools.retrieve(slug);
280 if (!tool) {
281 throw new ComposioToolNotFoundError(
282 - `[getComposioToolBySlug] Tool with slug ${slug} not found`
282 + `[getRawComposioToolBySlug] Tool with slug ${slug} not found`
283 );
284 }
285 // change the case of the tool to camel case
@@ -349,11 +349,11 @@ export class Tools<
349 const executeToolFn = this.createExecuteToolFn(userId, options as ExecuteToolModifiers);
350 // if the first argument is a string, get a single tool
351 if (typeof arg2 === 'string') {
352 - const tool = await this.getComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
352 + const tool = await this.getRawComposioToolBySlug(userId, arg2, options?.modifyToolSchema);
353 return this.provider.wrapTool(tool, executeToolFn) as TTool;
354 } else {
355 // if the first argument is an object, get a list of tools
356 - const tools = await this.getComposioTools(userId, arg2, options?.modifyToolSchema);
356 + const tools = await this.getRawComposioTools(userId, arg2, options?.modifyToolSchema);
357 return this.provider.wrapTools(tools, executeToolFn) as TToolCollection;
358 }
359 }
@@ -502,7 +502,7 @@ export class Tools<
502 return this.handleCustomToolExecution(customTool, body, modifiers);
503 } else {
504 // handle composio tool execution
505 - const composioTool = await this.getComposioToolBySlug(body.userId, slug);
505 + const composioTool = await this.getRawComposioToolBySlug(body.userId, slug);
506 if (!composioTool) {
507 throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
508 }
packages/core/test/tools/modifiers.test.ts
+5 -5
@@ -26,7 +26,7 @@ describe('Tools Modifiers', () => {
26 // mock client to send back the tool
27 mockClient.tools.retrieve.mockResolvedValueOnce(toolMocks.rawTool);
28
29 - const result = await context.tools.getComposioToolBySlug(userId, slug, schemaModifier);
29 + const result = await context.tools.getRawComposioToolBySlug(userId, slug, schemaModifier);
30
31 expect(schemaModifier).toHaveBeenCalledTimes(1);
32 expect(schemaModifier).toHaveBeenCalledWith(
@@ -53,7 +53,7 @@ describe('Tools Modifiers', () => {
53 totalPages: 1,
54 });
55
56 - const result = await context.tools.getComposioTools(userId, {}, schemaModifier);
56 + const result = await context.tools.getRawComposioTools(userId, {}, schemaModifier);
57
58 expect(schemaModifier).toHaveBeenCalledTimes(2);
59 expect(result[0].name).toContain('Modified');
@@ -125,8 +125,8 @@ describe('Tools Modifiers', () => {
125
126 const executionModifiers = createExecutionModifiers();
127
128 - const getComposioToolBySlugSpy = vi.spyOn(context.tools, 'getComposioToolBySlug');
129 - getComposioToolBySlugSpy.mockResolvedValueOnce({
128 + const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
129 + getRawComposioToolBySlugSpy.mockResolvedValueOnce({
130 ...(toolMocks.transformedTool as unknown as Tool),
131 description: 'Modified schema',
132 });
@@ -138,7 +138,7 @@ describe('Tools Modifiers', () => {
138 ...executionModifiers,
139 });
140
141 - expect(getComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
141 + expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
142 expect(createExecuteToolFnSpy).toHaveBeenCalledWith(
143 userId,
144 expect.objectContaining(executionModifiers)
packages/core/test/tools/tools.test.ts
+25 -21
@@ -33,7 +33,7 @@ describe('Tools', () => {
33 });
34 });
35
36 - describe('getComposioTools', () => {
36 + describe('getRawComposioTools', () => {
37 it('should fetch tools from the API', async () => {
38 const userId = 'test-user';
39
@@ -42,7 +42,7 @@ describe('Tools', () => {
42 totalPages: 1,
43 });
44
45 - const result = await context.tools.getComposioTools(userId);
45 + const result = await context.tools.getRawComposioTools(userId);
46
47 expect(mockClient.tools.list).toHaveBeenCalledTimes(1);
48 expect(result).toHaveLength(1);
@@ -62,7 +62,7 @@ describe('Tools', () => {
62 totalPages: 1,
63 });
64
65 - await context.tools.getComposioTools(userId, query);
65 + await context.tools.getRawComposioTools(userId, query);
66
67 expect(mockClient.tools.list).toHaveBeenCalledWith({
68 tool_slugs: ['TOOL1', 'TOOL2'],
@@ -82,7 +82,7 @@ describe('Tools', () => {
82 totalPages: 1,
83 });
84
85 - const result = await context.tools.getComposioTools(userId);
85 + const result = await context.tools.getRawComposioTools(userId);
86
87 expect(result[0].inputParameters).toEqual(toolMocks.transformedTool.inputParameters);
88 expect(result[0].outputParameters).toEqual(toolMocks.transformedTool.outputParameters);
@@ -99,7 +99,7 @@ describe('Tools', () => {
99 const getCustomToolsSpy = vi.spyOn(context.tools['customTools'], 'getCustomTools');
100 getCustomToolsSpy.mockResolvedValueOnce([toolMocks.customTool as unknown as Tool]);
101
102 - const result = await context.tools.getComposioTools(userId);
102 + const result = await context.tools.getRawComposioTools(userId);
103
104 expect(result).toHaveLength(2);
105 expect(result[1].slug).toEqual(toolMocks.customTool.slug);
@@ -116,7 +116,7 @@ describe('Tools', () => {
116 totalPages: 1,
117 });
118
119 - const result = await context.tools.getComposioTools(userId, {}, schemaModifier);
119 + const result = await context.tools.getRawComposioTools(userId, {}, schemaModifier);
120
121 expect(schemaModifier).toHaveBeenCalled();
122 expect(result[0].description).toEqual('Modified description');
@@ -131,20 +131,20 @@ describe('Tools', () => {
131 totalPages: 1,
132 });
133
134 - await expect(context.tools.getComposioTools(userId, {}, invalidModifier)).rejects.toThrow(
134 + await expect(context.tools.getRawComposioTools(userId, {}, invalidModifier)).rejects.toThrow(
135 'Invalid schema modifier. Not a function.'
136 );
137 });
138 });
139
140 - describe('getComposioToolBySlug', () => {
140 + describe('getRawComposioToolBySlug', () => {
141 it('should fetch a tool by slug from the API', async () => {
142 const userId = 'test-user';
143 const slug = 'TOOL_SLUG';
144
145 mockClient.tools.retrieve.mockResolvedValueOnce(toolMocks.rawTool);
146
147 - const result = await context.tools.getComposioToolBySlug(userId, slug);
147 + const result = await context.tools.getRawComposioToolBySlug(userId, slug);
148
149 expect(mockClient.tools.retrieve).toHaveBeenCalledWith(slug);
150 expect(result.slug).toEqual(toolMocks.transformedTool.slug);
@@ -157,7 +157,7 @@ describe('Tools', () => {
157 const getCustomToolBySlugSpy = vi.spyOn(context.tools['customTools'], 'getCustomToolBySlug');
158 getCustomToolBySlugSpy.mockResolvedValueOnce(toolMocks.customTool as unknown as Tool);
159
160 - const result = await context.tools.getComposioToolBySlug(userId, slug);
160 + const result = await context.tools.getRawComposioToolBySlug(userId, slug);
161
162 expect(getCustomToolBySlugSpy).toHaveBeenCalledWith(slug);
163 expect(mockClient.tools.retrieve).not.toHaveBeenCalled();
@@ -172,7 +172,7 @@ describe('Tools', () => {
172 getCustomToolBySlugSpy.mockResolvedValueOnce(undefined);
173 mockClient.tools.retrieve.mockResolvedValueOnce(null);
174
175 - await expect(context.tools.getComposioToolBySlug(userId, slug)).rejects.toThrow(
175 + await expect(context.tools.getRawComposioToolBySlug(userId, slug)).rejects.toThrow(
176 `Tool with slug ${slug} not found`
177 );
178 });
@@ -186,7 +186,7 @@ describe('Tools', () => {
186
187 mockClient.tools.retrieve.mockResolvedValueOnce(toolMocks.rawTool);
188
189 - const result = await context.tools.getComposioToolBySlug(userId, slug, schemaModifier);
189 + const result = await context.tools.getRawComposioToolBySlug(userId, slug, schemaModifier);
190
191 expect(schemaModifier).toHaveBeenCalled();
192 expect(result.description).toEqual('Modified description');
@@ -198,14 +198,16 @@ describe('Tools', () => {
198 const userId = 'test-user';
199 const slug = 'TOOL_SLUG';
200
201 - const getComposioToolBySlugSpy = vi.spyOn(context.tools, 'getComposioToolBySlug');
202 - getComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
201 + const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
202 + getRawComposioToolBySlugSpy.mockResolvedValueOnce(
203 + toolMocks.transformedTool as unknown as Tool
204 + );
205
206 context.mockProvider.wrapTool.mockReturnValueOnce('wrapped-tool');
207
208 const result = await context.tools.get(userId, slug);
209
208 - expect(getComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, undefined);
210 + expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, undefined);
211 expect(context.mockProvider.wrapTool).toHaveBeenCalled();
212 expect(result).toEqual('wrapped-tool');
213 });
@@ -214,14 +216,14 @@ describe('Tools', () => {
216 const userId = 'test-user';
217 const filters = { tools: ['TOOL1', 'TOOL2'] };
218
217 - const getComposioToolsSpy = vi.spyOn(context.tools, 'getComposioTools');
218 - getComposioToolsSpy.mockResolvedValueOnce([toolMocks.transformedTool as unknown as Tool]);
219 + const getRawComposioToolsSpy = vi.spyOn(context.tools, 'getRawComposioTools');
220 + getRawComposioToolsSpy.mockResolvedValueOnce([toolMocks.transformedTool as unknown as Tool]);
221
222 context.mockProvider.wrapTools.mockReturnValueOnce('wrapped-tools');
223
224 const result = await context.tools.get(userId, filters);
225
224 - expect(getComposioToolsSpy).toHaveBeenCalledWith(userId, filters, undefined);
226 + expect(getRawComposioToolsSpy).toHaveBeenCalledWith(userId, filters, undefined);
227 expect(context.mockProvider.wrapTools).toHaveBeenCalled();
228 expect(result).toEqual('wrapped-tools');
229 });
@@ -233,12 +235,14 @@ describe('Tools', () => {
235 description: 'Modified description',
236 });
237
236 - const getComposioToolBySlugSpy = vi.spyOn(context.tools, 'getComposioToolBySlug');
237 - getComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
238 + const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
239 + getRawComposioToolBySlugSpy.mockResolvedValueOnce(
240 + toolMocks.transformedTool as unknown as Tool
241 + );
242
243 await context.tools.get(userId, slug, { modifyToolSchema: schemaModifier });
244
241 - expect(getComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
245 + expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
246 });
247 });
248
packages/core/test/utils/toolExecuteUtils.ts
+3 -3
@@ -45,8 +45,8 @@ export const mockToolExecution = async (
45 );
46
47 // Mock composio tool retrieval
48 - const getComposioToolBySlugSpy = vi.spyOn(tools, 'getComposioToolBySlug');
49 - getComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
48 + const getRawComposioToolBySlugSpy = vi.spyOn(tools, 'getRawComposioToolBySlug');
49 + getRawComposioToolBySlugSpy.mockResolvedValueOnce(toolMocks.transformedTool as unknown as Tool);
50
51 // Mock connected account
52 const getConnectedAccountIdForToolSpy = vi.spyOn(
@@ -62,7 +62,7 @@ export const mockToolExecution = async (
62
63 return {
64 getCustomToolBySlugSpy,
65 - getComposioToolBySlugSpy,
65 + getRawComposioToolBySlugSpy,
66 getConnectedAccountIdForToolSpy,
67 };
68 };