Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Update preprocessor examples
haxzie committed
May 16, 2025 at 13:15 UTC
0da268ed5775ddc805456f3dffd360085eeebfb6
4 files changed
+22
-18
examples/pre-processors/src/index.ts
+13
-10
@@ -40,21 +40,24 @@ const vercel = new Composio({
40
toolset: new VercelToolset(),
41
});
42
43
-vercel.tools.get(
44
- 'user-id',
43
+const agenticTools = await vercel.tools.get(
44
+ 'default',
45
// what is the type error i am getting here?
46
- { toolkits: [''] },
46
+ { tools: ['HACKERNEWS_GET_USER'] },
47
{
48
- // here for toolkitSlug and toolSlug before the generation mapping thing comes we should have basic generic that gets from the input type itself
49
- // so if i have toolkits then i get toolkit name and if i have tools then i get tool name
50
- modifyToolSchema: (toolSlug, toolSchema) => {
51
- return toolSchema;
52
- },
48
afterToolExecute: (toolSlug, result) => {
54
- // hmm i wonder about this
49
+ // modify the result
50
+ return result;
51
},
52
beforeToolExecute: (toolSlug, params) => {
57
- // here we should give a subset of params like userId should not be mutable here
53
+ // modify the params
54
+ return params;
55
+ },
56
+ modifyToolSchema: (toolSlug, toolSchema) => {
57
+ // modify the tool schema
58
+ return toolSchema;
59
},
60
}
61
);
62
+
63
+console.log(agenticTools);
packages/core/src/models/Tools.ts
+3
-2
@@ -206,13 +206,14 @@ export class Tools<
206
}
207
208
const tools = await this.client.tools.list({
209
+ tool_slugs: queryParams.data.tools?.join(','),
210
+ toolkit_slug: queryParams.data.toolkits?.join(','),
211
cursor: queryParams.data.cursor,
212
important: queryParams.data.important,
213
limit: queryParams.data.limit,
214
search: queryParams.data.search,
213
- toolkit_slug: queryParams.data.toolkits?.join(','),
214
- tool_slugs: queryParams.data.tools?.join(','),
215
});
216
+
217
if (!tools) {
218
return [];
219
}
packages/core/src/types/tool.types.ts
+1
-1
@@ -56,12 +56,12 @@ export type ToolList = Array<Tool>;
56
* ToolListParams is the parameters for the list of tools.
57
*/
58
export const ToolListParamsSchema = z.object({
59
+ tools: z.array(z.string()).optional(),
60
cursor: z.string().optional(),
61
important: z.string().optional(),
62
limit: z.string().optional(),
63
search: z.string().optional(),
64
toolkits: z.array(z.string()).optional(),
64
- tools: z.array(z.string()).optional(),
65
});
66
export type ToolListParams = z.infer<typeof ToolListParamsSchema>;
67
pnpm-lock.yaml
+5
-5
@@ -123,8 +123,8 @@ importers:
123
specifier: ^1.3.16
124
version: 1.3.22(zod@3.24.4)
125
'@composio/core':
126
- specifier: ^0.1.8-alpha.0
127
- version: 0.1.8-alpha.0(encoding@0.1.13)(ws@8.18.2)
126
+ specifier: workspace:*
127
+ version: link:../../packages/core
128
'@composio/vercel':
129
specifier: workspace:*
130
version: link:../../packages/toolsets/vercel
@@ -6289,10 +6289,10 @@ snapshots:
6289
- encoding
6290
- ws
6291
6292
- '@composio/langchain@0.1.0-rc.6(encoding@0.1.13)(openai@4.98.0(encoding@0.1.13)(zod@3.24.4))':
6292
+ '@composio/langchain@0.1.0-rc.6(encoding@0.1.13)(openai@4.94.0(encoding@0.1.13)(ws@8.18.2)(zod@3.24.2))(ws@8.18.2)':
6293
dependencies:
6294
- '@composio/core': 0.1.0-rc.5(encoding@0.1.13)
6295
- '@langchain/core': 0.3.56(openai@4.98.0(encoding@0.1.13)(zod@3.24.4))
6294
+ '@composio/core': 0.1.0-rc.5(encoding@0.1.13)(ws@8.18.2)
6295
+ '@langchain/core': 0.3.44(openai@4.94.0(encoding@0.1.13)(ws@8.18.2)(zod@3.24.2))
6296
transitivePeerDependencies:
6297
- encoding
6298
- openai