@devries-cameron20 / composio Mirror · read-only / commits / 4ba275ca7
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 23:15 UTC

Fix docs

haxzie committed Jun 19, 2025 at 19:31 UTC 4ba275ca75c486960c0aae7728592fb8cf3489e5
21 files changed +524 -202
fern/pages/src/tool-calling/after-execution-modifiers.mdx
+1 -1
@@ -136,7 +136,7 @@ const agenticTools = await composio.tools.get(
136 tools: ["HACKERNEWS_GET_USER"],
137 },
138 {
139 - afterExecute: (toolSlug, _toolkitSlug, result) => {
139 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
140 if (toolSlug === "HACKERNEWS_GET_USER") {
141 const {
142 data: { response_data: { karma } = {} } = {},
fern/pages/src/tool-calling/before-execution-modifiers.mdx
+1 -1
@@ -140,7 +140,7 @@ const agenticTools = await composio.tools.get(
140 ],
141 },
142 {
143 - beforeExecute: (toolSlug, _, params) => {
143 + beforeExecute: ({toolSlug, toolkitSlug, params}) => {
144 if (toolSlug === "LINEAR_CREATE_LINEAR_ISSUE") {
145 params.arguments.project_id = "1234567890";
146 }
fern/snippets/migration/tool_modifiers.ts
+7 -8
@@ -1,7 +1,6 @@
1 import { Composio } from '@composio/core';
2 import { OpenAI } from 'openai';
3
4 -
4 const userId = 'your@email.com';
5 const composio = new Composio();
6
@@ -12,15 +11,15 @@ const tools = await composio.tools.get(
11 tools: ['HACKERNEWS_GET_LATEST_POSTS', 'HACKERNEWS_GET_USER'],
12 },
13 {
15 - modifyToolSchema: (toolSlug, _, toolSchema) => {
14 + modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
15 if (toolSlug === 'HACKERNEWS_GET_LATEST_POSTS') {
17 - const { inputParameters } = toolSchema;
16 + const { inputParameters } = schema;
17 if (inputParameters?.properties) {
18 delete inputParameters.properties['page'];
19 }
20 inputParameters.required = ['size'];
21 }
23 - return toolSchema;
22 + return schema;
23 },
24 }
25 );
@@ -58,7 +57,7 @@ if (tool_calls) {
57 arguments: JSON.parse(toolArgs),
58 },
59 {
61 - beforeExecute: (toolSlug, _, params) => {
60 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
61 if (toolSlug === 'HACKERNEWS_GET_LATEST_POSTS') {
62 params.arguments.size = 1;
63 }
@@ -68,14 +67,14 @@ if (tool_calls) {
67 }
68 );
69 const result_2 = await composio.tools.execute(
71 - "HACKERNEWS_GET_USER",
70 + 'HACKERNEWS_GET_USER',
71 {
72 userId,
73 arguments: JSON.parse(toolArgs),
74 },
75 {
77 - afterToolExecute: (toolSlug, _, result) => {
78 - if (toolSlug === "HACKERNEWS_GET_USER") {
76 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
77 + if (toolSlug === 'HACKERNEWS_GET_USER') {
78 const { data } = result;
79 const { karma } = data.response_data as { karma: number };
80 return {
ts/docs/advanced/modifiers.md
+26 -26
@@ -24,7 +24,7 @@ const tools = await composio.tools.get(
24 toolkits: ['github'],
25 },
26 {
27 - modifySchema: (toolSlug, toolkitSlug, tool) => {
27 + modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
28 // Add a prefix to all tool descriptions
29 if (tool.description) {
30 tool.description = `[Enhanced] ${tool.description}`;
@@ -61,7 +61,7 @@ const result = await composio.tools.execute(
61 },
62 },
63 {
64 - beforeExecute: (toolSlug, toolkitSlug, params) => {
64 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
65 // Convert owner names to lowercase
66 if (params.arguments.owner) {
67 params.arguments.owner = params.arguments.owner.toLowerCase();
@@ -97,7 +97,7 @@ const result = await composio.tools.execute(
97 },
98 },
99 {
100 - afterExecute: (toolSlug, toolkitSlug, result) => {
100 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
101 // Only when execution was successful
102 if (result.successful) {
103 // Filter out sensitive data
@@ -141,19 +141,19 @@ const tools = await composio.tools.get(
141 },
142 {
143 // Schema modifier
144 - modifySchema: (toolSlug, toolkitSlug, tool) => {
144 + modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
145 // Enhance tool schema
146 - return tool;
146 + return schema;
147 },
148
149 // Before execution modifier (only works with agentic providers)
150 - beforeExecute: (toolSlug, toolkitSlug, params) => {
150 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
151 // Modify execution parameters
152 return params;
153 },
154
155 // After execution modifier (only works with agentic providers)
156 - afterExecute: (toolSlug, toolkitSlug, result) => {
156 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
157 // Transform execution results
158 return result;
159 },
@@ -193,19 +193,19 @@ For better code organization, you can create reusable modifier functions:
193
194 ```typescript
195 // Define reusable modifiers
196 -const addTimestamps = (toolSlug, toolkitSlug, result) => {
196 +const addTimestamps = ({ toolSlug, toolkitSlug, result }) => {
197 if (result.successful) {
198 result.data.executedAt = new Date().toISOString();
199 }
200 return result;
201 };
202
203 -const logExecutions = (toolSlug, toolkitSlug, params) => {
203 +const logExecutions = ({ toolSlug, toolkitSlug, params }) => {
204 console.log(`Executing ${toolSlug} from ${toolkitSlug} at ${new Date().toISOString()}`);
205 return params;
206 };
207
208 -const sanitizeInputs = (toolSlug, toolkitSlug, params) => {
208 +const sanitizeInputs = ({ toolSlug, toolkitSlug, params }) => {
209 // Sanitize input parameters to prevent injection attacks
210 if (params.arguments) {
211 Object.keys(params.arguments).forEach(key => {
@@ -270,18 +270,18 @@ const vercel = new Composio({
270 // All modifiers work with agentic providers
271 const agenticTools = await vercel.tools.get('default', 'HACKERNEWS_GET_USER', {
272 // Schema modifier
273 - modifySchema: (toolSlug, toolkitSlug, tool) => {
273 + modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
274 if (tool.inputParameters?.properties?.userId) {
275 tool.inputParameters.properties.userId.description = 'HackerNews username (e.g., "pg")';
276 }
277 - return tool;
277 + return schema;
278 },
279 // Execution modifiers (only work with agentic providers)
280 - beforeExecute: (toolSlug, toolkitSlug, params) => {
280 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
281 console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
282 return params;
283 },
284 - afterExecute: (toolSlug, toolkitSlug, result) => {
284 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
285 if (result.successful) {
286 result.data.processedAt = new Date().toISOString();
287 }
@@ -305,11 +305,11 @@ const toolOutputs = await openaiProvider.handleToolCalls(
305 { connectedAccountId: 'account_123' }, // Options
306 {
307 // Manually apply execution modifiers
308 - beforeExecute: (toolSlug, toolkitSlug, params) => {
308 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
309 console.log(`Executing ${toolSlug}`);
310 return params;
311 },
312 - afterExecute: (toolSlug, toolkitSlug, result) => {
312 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
313 result.data.processedAt = new Date().toISOString();
314 return result;
315 },
@@ -325,7 +325,7 @@ const toolOutputs = await openaiProvider.handleToolCalls(
325 // Simple in-memory cache
326 const cache = new Map();
327
328 -const cacheModifier = (toolSlug, toolkitSlug, params) => {
328 +const cacheModifier = ({ toolSlug, toolkitSlug, params }) => {
329 // Create a cache key based on tool slug and arguments
330 const cacheKey = `${toolSlug}-${JSON.stringify(params.arguments)}`;
331
@@ -345,7 +345,7 @@ const cacheModifier = (toolSlug, toolkitSlug, params) => {
345 return params;
346 };
347
348 -const cacheAfterModifier = (toolSlug, toolkitSlug, result) => {
348 +const cacheAfterModifier = ({ toolSlug, toolkitSlug, result }) => {
349 if (result.successful && result.__cacheKey) {
350 // Store in cache
351 cache.set(result.__cacheKey, {
@@ -390,7 +390,7 @@ try {
390 ### Adding Authentication Headers
391
392 ```typescript
393 -const authModifier = (toolSlug, toolkitSlug, params) => {
393 +const authModifier = ({ toolSlug, toolkitSlug, params }) => {
394 // Add authentication parameters for specific toolkits
395 if (toolkitSlug === 'custom-api') {
396 if (!params.customAuthParams) {
@@ -429,22 +429,22 @@ const tools = await composio.tools.get(
429 ```typescript
430 // Create a pipeline of modifiers
431 const pipeModifiers = (...modifiers) => {
432 - return (toolSlug, toolkitSlug, result) => {
432 + return ({ toolSlug, toolkitSlug, result }) => {
433 return modifiers.reduce((modifiedResult, modifier) => {
434 - return modifier(toolSlug, toolkitSlug, modifiedResult);
434 + return modifier({ toolSlug, toolkitSlug, result: modifiedResult });
435 }, result);
436 };
437 };
438
439 // Individual transformation steps
440 -const addMetadata = (toolSlug, toolkitSlug, result) => {
440 +const addMetadata = ({ toolSlug, toolkitSlug, result }) => {
441 if (result.successful) {
442 result.data.metadata = { source: toolkitSlug, tool: toolSlug };
443 }
444 return result;
445 };
446
447 -const formatDates = (toolSlug, toolkitSlug, result) => {
447 +const formatDates = ({ toolSlug, toolkitSlug, result }) => {
448 if (result.successful) {
449 // Convert all dates to a consistent format
450 Object.keys(result.data).forEach(key => {
@@ -458,7 +458,7 @@ const formatDates = (toolSlug, toolkitSlug, result) => {
458 return result;
459 };
460
461 -const removeNulls = (toolSlug, toolkitSlug, result) => {
461 +const removeNulls = ({ toolSlug, toolkitSlug, result }) => {
462 if (result.successful) {
463 // Remove null and undefined values
464 Object.keys(result.data).forEach(key => {
@@ -551,11 +551,11 @@ const result = await openaiProvider.executeToolCall(
551 { connectedAccountId: 'account_123' }, // Options
552 {
553 // Manually apply execution modifiers
554 - beforeExecute: (toolSlug, toolkitSlug, params) => {
554 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
555 console.log(`Executing ${toolSlug}`);
556 return params;
557 },
558 - afterExecute: (toolSlug, toolkitSlug, result) => {
558 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
559 result.data.processedAt = new Date().toISOString();
560 return result;
561 },
ts/docs/api/providers.md
+2 -2
@@ -102,8 +102,8 @@ const result = await openaiProvider.executeToolCall(
102 toolCall,
103 { connectedAccountId: 'conn_abc123' },
104 {
105 - beforeExecute: (toolSlug, toolkitSlug, params) => params,
106 - afterExecute: (toolSlug, toolkitSlug, result) => result,
105 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => params,
106 + afterExecute: ({ toolSlug, toolkitSlug, result }) => result,
107 }
108 );
109 ```
ts/docs/api/tools.md
+2 -2
@@ -59,11 +59,11 @@ const result = await composio.tools.execute(
59 arguments: { owner: 'composio', repo: 'sdk' },
60 },
61 {
62 - beforeExecute: (toolSlug, toolkitSlug, params) => {
62 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
63 // Modify params before execution
64 return params;
65 },
66 - afterExecute: (toolSlug, toolkitSlug, result) => {
66 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
67 // Transform result after execution
68 return result;
69 },
ts/docs/providers/openai.md
+2 -2
@@ -294,13 +294,13 @@ const tools = await composio.tools.get(
294 },
295
296 // Modify parameters before execution
297 - beforeExecute: (toolSlug, toolkitSlug, params) => {
297 + beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
298 console.log(`Executing ${toolSlug} tool`);
299 return params;
300 },
301
302 // Transform results after execution
303 - afterExecute: (toolSlug, toolkitSlug, result) => {
303 + afterExecute: ({ toolSlug, toolkitSlug, result }) => {
304 // Format the result data for better presentation
305 if (result.successful && toolSlug === 'GITHUB_GET_REPO') {
306 result.data = {
ts/packages/core/src/models/Tools.ts
+30 -6
@@ -260,7 +260,11 @@ export class Tools<
260 let modifiedParams = params;
261 if (modifier) {
262 if (typeof modifier === 'function') {
263 - modifiedParams = await modifier(toolSlug, toolkitSlug, modifiedParams);
263 + modifiedParams = await modifier({
264 + toolSlug,
265 + toolkitSlug,
266 + params: modifiedParams,
267 + });
268 } else {
269 throw new ComposioInvalidModifierError('Invalid beforeExecute modifier. Not a function.');
270 }
@@ -298,7 +302,11 @@ export class Tools<
302 let modifiedResult = result;
303 if (modifier) {
304 if (typeof modifier === 'function') {
301 - modifiedResult = await modifier(toolSlug, toolkitSlug, modifiedResult);
305 + modifiedResult = await modifier({
306 + toolSlug,
307 + toolkitSlug,
308 + result: modifiedResult,
309 + });
310 } else {
311 throw new ComposioInvalidModifierError('Invalid afterExecute modifier. Not a function.');
312 }
@@ -409,7 +417,11 @@ export class Tools<
417 if (modifier) {
418 if (typeof modifier === 'function') {
419 const modifiedPromises = modifiedTools.map(tool =>
412 - modifier(tool.slug, tool.toolkit?.slug ?? 'unknown', tool)
420 + modifier({
421 + toolSlug: tool.slug,
422 + toolkitSlug: tool.toolkit?.slug ?? 'unknown',
423 + schema: tool,
424 + })
425 );
426 modifiedTools = await Promise.all(modifiedPromises);
427 } else {
@@ -458,7 +470,11 @@ export class Tools<
470 // apply local modifiers if they are provided
471 if (modifier) {
472 if (typeof modifier === 'function') {
461 - modifiedTool = await modifier(slug, modifiedTool.toolkit?.slug ?? 'unknown', modifiedTool);
473 + modifiedTool = await modifier({
474 + toolSlug: slug,
475 + toolkitSlug: modifiedTool.toolkit?.slug ?? 'unknown',
476 + schema: modifiedTool,
477 + });
478 } else {
479 throw new ComposioInvalidModifierError('Invalid schema modifier. Not a function.');
480 }
@@ -602,7 +618,11 @@ export class Tools<
618 ): Promise<ToolExecuteResponse> {
619 if (modifiers?.beforeExecute) {
620 if (typeof modifiers.beforeExecute === 'function') {
605 - body = await modifiers.beforeExecute(tool.slug, 'unknown', body);
621 + body = await modifiers.beforeExecute({
622 + toolSlug: tool.slug,
623 + toolkitSlug: tool.toolkit?.slug ?? 'unknown',
624 + params: body,
625 + });
626 } else {
627 throw new ComposioInvalidModifierError('Invalid beforeExecute modifier. Not a function.');
628 }
@@ -612,7 +632,11 @@ export class Tools<
632
633 if (modifiers?.afterExecute) {
634 if (typeof modifiers.afterExecute === 'function') {
615 - result = await modifiers.afterExecute(tool.slug, 'unknown', result);
635 + result = await modifiers.afterExecute({
636 + toolSlug: tool.slug,
637 + toolkitSlug: tool.toolkit?.slug ?? 'unknown',
638 + result,
639 + });
640 } else {
641 throw new ComposioInvalidModifierError('Invalid afterExecute modifier. Not a function.');
642 }
ts/packages/core/src/types/modifiers.types.ts
+238 -89
@@ -18,41 +18,69 @@ import { ToolExecuteParams, ToolExecuteResponse, Tool } from './tool.types';
18 *
19 * @example
20 * ```typescript
21 - * // Add authentication headers to all tool requests
22 - * const beforeExecute = (toolSlug, toolkitSlug, params) => {
21 + * // Example 1: Add authentication headers to all tool requests
22 + * const beforeExecute = ({ params, toolSlug, toolkitSlug }) => {
23 + * // Log the execution attempt
24 + * console.log(`Executing ${toolSlug} from toolkit ${toolkitSlug}`);
25 + *
26 + * // Add authentication and tracking headers
27 * return {
28 * ...params,
29 * customAuthParams: {
30 * ...params.customAuthParams,
31 * headers: {
32 * ...params.customAuthParams?.headers,
29 - * 'X-API-Key': 'my-api-key'
33 + * 'X-API-Key': 'my-api-key',
34 + * 'X-Request-ID': generateRequestId(),
35 + * 'X-Toolkit': toolkitSlug
36 * }
37 * }
38 * };
39 * };
40 *
35 - * // Transform input parameters for a specific tool
36 - * const beforeExecute = (toolSlug, toolkitSlug, params) => {
37 - * if (toolSlug === 'GITHUB_SEARCH_REPOS') {
38 - * // Convert simple query to structured query format
39 - * return {
40 - * ...params,
41 - * arguments: {
42 - * ...params.arguments,
43 - * q: `${params.arguments.query} in:name,description`
41 + * // Example 2: Transform input parameters for specific tools with validation
42 + * const beforeExecute = ({ params, toolSlug, toolkitSlug }) => {
43 + * // Handle different tools
44 + * switch (toolSlug) {
45 + * case 'GITHUB_SEARCH_REPOS':
46 + * // Enhance search query with additional filters
47 + * return {
48 + * ...params,
49 + * arguments: {
50 + * ...params.arguments,
51 + * q: `${params.arguments.query} in:name,description language:typescript stars:>100`,
52 + * sort: 'stars',
53 + * order: 'desc'
54 + * }
55 + * };
56 + *
57 + * case 'NPM_PACKAGE_INFO':
58 + * // Validate and normalize package name
59 + * const pkgName = params.arguments.packageName.trim().toLowerCase();
60 + * if (!pkgName) {
61 + * throw new Error('Package name is required');
62 * }
45 - * };
63 + *
64 + * return {
65 + * ...params,
66 + * arguments: {
67 + * ...params.arguments,
68 + * packageName: pkgName,
69 + * includeVersions: true
70 + * }
71 + * };
72 + *
73 + * default:
74 + * return params;
75 * }
47 - * return params;
76 * };
77 * ```
78 */
51 -export type beforeExecuteModifier = (
52 - toolSlug: string,
53 - toolkitSlug: string,
54 - toolExecuteParams: ToolExecuteParams
55 -) => Promise<ToolExecuteParams> | ToolExecuteParams;
79 +export type beforeExecuteModifier = (context: {
80 + toolSlug: string;
81 + toolkitSlug: string;
82 + params: ToolExecuteParams;
83 +}) => Promise<ToolExecuteParams> | ToolExecuteParams;
84
85 /**
86 * Modifier for altering the tool execution response after execution completes.
@@ -71,44 +99,85 @@ export type beforeExecuteModifier = (
99 *
100 * @example
101 * ```typescript
74 - * // Transform the response data format
75 - * const afterExecute = (toolSlug, toolkitSlug, response) => {
76 - * if (toolSlug === 'GITHUB_LIST_REPOS' && response.successful) {
77 - * // Transform the returned repos into a simpler format
102 + * // Example 1: Transform and enrich response data
103 + * const afterExecute = ({ result, toolSlug, toolkitSlug }) => {
104 + * // Handle successful GitHub repository listing
105 + * if (toolSlug === 'GITHUB_LIST_REPOS' && result.successful) {
106 + * // Transform the returned repos into a more useful format
107 + * const repositories = result.data.items.map(repo => ({
108 + * name: repo.name,
109 + * url: repo.html_url,
110 + * stars: repo.stargazers_count,
111 + * // Add derived and computed fields
112 + * isPopular: repo.stargazers_count > 1000,
113 + * lastUpdated: new Date(repo.updated_at).toLocaleDateString(),
114 + * topics: repo.topics || [],
115 + * license: repo.license?.spdx_id || 'No License'
116 + * }));
117 + *
118 + * // Add metadata about the response
119 * return {
79 - * ...response,
120 + * ...result,
121 * data: {
81 - * repositories: response.data.items.map(repo => ({
82 - * name: repo.name,
83 - * url: repo.html_url,
84 - * stars: repo.stargazers_count
85 - * }))
122 + * repositories,
123 + * totalCount: result.data.total_count,
124 + * metadata: {
125 + * queryTime: new Date().toISOString(),
126 + * toolkit: toolkitSlug,
127 + * filterApplied: true
128 + * }
129 * }
130 * };
131 * }
89 - * return response;
132 + *
133 + * return result;
134 * };
135 *
92 - * // Add error handling with custom messages
93 - * const afterExecute = (toolSlug, toolkitSlug, response) => {
94 - * if (!response.successful) {
136 + * // Example 2: Comprehensive error handling and logging
137 + * const afterExecute = ({ result, toolSlug, toolkitSlug }) => {
138 + * // Log all executions for monitoring
139 + * logToolExecution(toolSlug, toolkitSlug, result.successful);
140 + *
141 + * if (!result.successful) {
142 + * // Get error details
143 + * const errorCode = result.error?.code || 'UNKNOWN_ERROR';
144 + * const errorMessage = result.error?.message || 'An unknown error occurred';
145 + *
146 + * // Handle specific error cases
147 + * switch (errorCode) {
148 + * case 'RATE_LIMIT_EXCEEDED':
149 + * notifyRateLimitExceeded(toolkitSlug);
150 + * break;
151 + * case 'AUTHENTICATION_FAILED':
152 + * refreshAuthToken(toolkitSlug);
153 + * break;
154 + * }
155 + *
156 + * // Return enhanced error response
157 * return {
96 - * ...response,
158 + * ...result,
159 * error: {
98 - * message: `Error using ${toolSlug}: ${response.error?.message || 'Unknown error'}`,
99 - * code: response.error?.code || 'UNKNOWN_ERROR'
160 + * message: `Error using ${toolSlug}: ${errorMessage}`,
161 + * code: errorCode,
162 + * timestamp: new Date().toISOString(),
163 + * context: {
164 + * toolkit: toolkitSlug,
165 + * severity: getSeverityLevel(errorCode),
166 + * retryable: isRetryableError(errorCode)
167 + * }
168 * }
169 * };
170 * }
103 - * return response;
171 + *
172 + * return result;
173 * };
174 * ```
175 */
107 -export type afterExecuteModifier = (
108 - toolSlug: string,
109 - toolkitSlug: string,
110 - toolExecuteResponse: ToolExecuteResponse
111 -) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
176 +export type afterExecuteModifier = (context: {
177 + toolSlug: string;
178 + toolkitSlug: string;
179 + result: ToolExecuteResponse;
180 +}) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
181
182 /**
183 * Modifier for altering the tool schema before it's exposed to consumers.
@@ -127,53 +196,133 @@ export type afterExecuteModifier = (
196 *
197 * @example
198 * ```typescript
130 - * // Modify the input parameters for a specific tool
131 - * const modifySchema = (toolSlug, toolkitSlug, toolSchema) => {
199 + * // Example 1: Comprehensive schema modification with validation
200 + * const modifySchema = ({ schema, toolSlug, toolkitSlug }) => {
201 + * // Handle specific tools
202 * if (toolSlug === 'HACKERNEWS_GET_USER') {
203 * return {
134 - * ...toolSchema,
204 + * ...schema,
205 + * name: 'Get HackerNews User Profile',
206 + * description: 'Retrieve detailed user information from HackerNews',
207 + * version: '2.0.0',
208 * inputParameters: {
136 - * ...toolSchema.inputParameters,
209 + * ...schema.inputParameters,
210 * userId: {
211 * type: 'string',
212 * description: 'The HackerNews username to retrieve information for',
140 - * required: true
213 + * required: true,
214 + * minLength: 2,
215 + * maxLength: 15,
216 + * pattern: '^[a-zA-Z0-9_-]+$'
217 + * },
218 + * includeSubmissions: {
219 + * type: 'boolean',
220 + * description: 'Include user submissions in the response',
221 + * default: false
222 + * },
223 + * submissionLimit: {
224 + * type: 'number',
225 + * description: 'Maximum number of submissions to return',
226 + * default: 10,
227 + * minimum: 1,
228 + * maximum: 100
229 + * }
230 + * },
231 + * outputSchema: {
232 + * type: 'object',
233 + * properties: {
234 + * user: {
235 + * type: 'object',
236 + * properties: {
237 + * id: { type: 'string' },
238 + * karma: { type: 'number' },
239 + * created: { type: 'string', format: 'date-time' },
240 + * submissions: { type: 'array', items: { type: 'object' } }
241 + * }
242 + * }
243 * }
244 * }
245 * };
246 * }
145 - * return toolSchema;
247 + *
248 + * return schema;
249 * };
250 *
148 - * // Add custom descriptions to all tools in a toolkit
149 - * const modifySchema = (toolSlug, toolkitSlug, toolSchema) => {
251 + * // Example 2: Add organization-specific customizations
252 + * const modifySchema = ({ schema, toolSlug, toolkitSlug }) => {
253 + * // Add organization prefix to all GitHub tools
254 * if (toolkitSlug === 'github') {
151 - * return {
152 - * ...toolSchema,
153 - * description: `Company GitHub tool: ${toolSchema.description}`,
154 - * important: true
255 + * const enhancedSchema = {
256 + * ...schema,
257 + * name: `Acme Corp - ${schema.name}`,
258 + * description: `Company GitHub tool: ${schema.description}`,
259 + * category: 'Internal Tools',
260 + * tags: [...(schema.tags || []), 'acme-corp', 'internal'],
261 + * metadata: {
262 + * ...(schema.metadata || {}),
263 + * organization: 'acme-corp',
264 + * department: 'engineering',
265 + * supportContact: 'tools@acme-corp.com'
266 + * },
267 + * authentication: {
268 + * type: 'oauth2',
269 + * scopes: ['repo', 'user'],
270 + * enterpriseServer: 'github.acme-corp.com'
271 + * }
272 * };
273 + *
274 + * // Add rate limiting metadata
275 + * if (schema.rateLimit) {
276 + * enhancedSchema.rateLimit = {
277 + * ...schema.rateLimit,
278 + * enterprise: {
279 + * requests: 5000,
280 + * per: '1 hour'
281 + * }
282 + * };
283 + * }
284 + *
285 + * return enhancedSchema;
286 * }
157 - * return toolSchema;
287 + *
288 + * return schema;
289 * };
290 *
160 - * // Simplify tool schemas for a specific consumer
161 - * const modifySchema = (toolSlug, toolkitSlug, toolSchema) => {
162 - * // Remove advanced or complex parameters
163 - * const { complexParam1, complexParam2, ...simpleInputParams } = toolSchema.inputParameters;
291 + * // Example 3: Simplify schemas for external consumers
292 + * const modifySchema = ({ schema }) => {
293 + * // Remove internal or complex parameters
294 + * const {
295 + * debugMode,
296 + * internalFlags,
297 + * experimentalFeatures,
298 + * ...simpleInputParams
299 + * } = schema.inputParameters;
300 + *
301 + * // Simplify authentication requirements
302 + * const { oauth2, apiKey, ...simpleAuth } = schema.authentication || {};
303 *
304 * return {
166 - * ...toolSchema,
167 - * inputParameters: simpleInputParams
305 + * ...schema,
306 + * inputParameters: simpleInputParams,
307 + * authentication: {
308 + * type: 'apiKey',
309 + * in: 'header',
310 + * name: 'X-API-Key'
311 + * },
312 + * // Remove internal metadata
313 + * metadata: {
314 + * isPublic: true,
315 + * version: schema.metadata?.version
316 + * }
317 * };
318 * };
319 * ```
320 */
172 -export type TransformToolSchemaModifier = (
173 - toolSlug: string,
174 - toolkitSlug: string,
175 - toolSchema: Tool
176 -) => Tool | Promise<Tool>;
321 +export type TransformToolSchemaModifier = (context: {
322 + toolSlug: string;
323 + toolkitSlug: string;
324 + schema: Tool;
325 +}) => Tool | Promise<Tool>;
326
327 /**
328 * Options for non-agentic tool configuration.
@@ -187,9 +336,9 @@ export type TransformToolSchemaModifier = (
336 * const tools = await composio.tools.get('default', {
337 * toolkits: ['github']
338 * }, {
190 - * modifySchema: (toolSlug, toolkitSlug, schema) => {
339 + * modifySchema: (context) => {
340 * // Custom schema modifications
192 - * return schema;
341 + * return context.schema;
342 * }
343 * });
344 * ```
@@ -216,15 +365,15 @@ export type ToolOptions = {
365 * userId: 'default',
366 * arguments: { owner: 'composio' }
367 * }, {
219 - * beforeExecute: (toolSlug, toolkitSlug, params) => {
220 - * console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
221 - * return params;
368 + * beforeExecute: (context) => {
369 + * console.log(`Executing ${context.toolSlug} from ${context.toolkitSlug}`);
370 + * return context.params;
371 * },
223 - * afterExecute: (toolSlug, toolkitSlug, response) => {
224 - * if (response.successful) {
225 - * console.log(`Successfully executed ${toolSlug}`);
372 + * afterExecute: (context) => {
373 + * if (context.result.successful) {
374 + * console.log(`Successfully executed ${context.toolSlug}`);
375 * }
227 - * return response;
376 + * return context.result;
377 * }
378 * });
379 * ```
@@ -254,27 +403,27 @@ export type ExecuteToolModifiers = {
403 * ```typescript
404 * // Configure agentic tools with schema and execution modifications
405 * const agenticTools = await vercel.tools.get('default', 'GITHUB_GET_REPOS', {
257 - * modifySchema: (toolSlug, toolkitSlug, schema) => {
406 + * modifySchema: (context) => {
407 * return {
259 - * ...schema,
260 - * description: `Enhanced ${toolSlug} for better context`
408 + * ...context.schema,
409 + * description: `Enhanced ${context.toolSlug} for better context`
410 * };
411 * },
412 *
413 * // Intercept before execution
265 - * beforeExecute: (toolSlug, toolkitSlug, params) => {
414 + * beforeExecute: (context) => {
415 * // Add analytics tracking
267 - * trackToolUsage(toolSlug);
268 - * return params;
416 + * trackToolUsage(context.toolSlug);
417 + * return context.params;
418 * },
419 *
420 * // Transform after execution
272 - * afterExecute: (toolSlug, toolkitSlug, response) => {
421 + * afterExecute: (context) => {
422 * // Log results and handle errors
274 - * if (!response.successful) {
275 - * logToolError(toolSlug, response.error);
423 + * if (!context.result.successful) {
424 + * logToolError(context.toolSlug, context.result.error);
425 * }
277 - * return response;
426 + * return context.result;
427 * }
428 * });
429 * ```
@@ -293,7 +442,7 @@ export type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
442 * ```typescript
443 * // With standard provider (non-agentic)
444 * const tools = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
296 - * modifySchema: (toolSlug, toolkitSlug, schema) => schema
445 + * modifySchema: (context) => context.schema
446 * });
447 *
448 * // With agentic provider (e.g., VercelProvider)
@@ -303,9 +452,9 @@ export type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
452 * });
453 *
454 * const agenticTools = await vercel.tools.get('default', 'GITHUB_GET_REPOS', {
306 - * modifySchema: (toolSlug, toolkitSlug, schema) => schema,
307 - * beforeExecute: (toolSlug, toolkitSlug, params) => params,
308 - * afterExecute: (toolSlug, toolkitSlug, response) => response
455 + * modifySchema: (context) => context.schema,
456 + * beforeExecute: (context) => context.params,
457 + * afterExecute: (context) => context.result
458 * });
459 * ```
460 */
ts/packages/core/test/provider/openai-provider.test.ts
+3 -3
@@ -126,14 +126,14 @@ describe('OpenAIProvider', () => {
126
127 // Create a valid ExecuteToolModifiers object with beforeExecute and afterExecute functions
128 const modifiers: ExecuteToolModifiers = {
129 - beforeExecute: vi.fn((toolSlug, toolkitSlug, params) => {
129 + beforeExecute: vi.fn(({ toolSlug, toolkitSlug, params }) => {
130 return {
131 ...params,
132 allowTracing: true,
133 };
134 }),
135 - afterExecute: vi.fn((toolSlug, toolkitSlug, response) => {
136 - return response;
135 + afterExecute: vi.fn(({ toolSlug, toolkitSlug, result }) => {
136 + return result;
137 }),
138 };
139
ts/packages/core/test/provider/provider.test.ts
+4 -4
@@ -110,8 +110,8 @@ describe('BaseProvider', () => {
110 arguments: { query: 'test' },
111 };
112 const modifiers = {
113 - beforeExecute: vi.fn(x => x),
114 - afterExecute: vi.fn(x => x),
113 + beforeExecute: vi.fn(({ params }) => params),
114 + afterExecute: vi.fn(({ result }) => result),
115 };
116
117 const result = await nonAgenticProvider.executeTool(toolSlug, toolParams, modifiers);
@@ -209,8 +209,8 @@ describe('BaseProvider', () => {
209 arguments: { query: 'test' },
210 };
211 const modifiers = {
212 - beforeExecute: vi.fn(x => x),
213 - afterExecute: vi.fn(x => x),
212 + beforeExecute: vi.fn(({ params }) => params),
213 + afterExecute: vi.fn(({ result }) => result),
214 };
215
216 const result = await agenticProvider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/core/test/tools/modifiers.test.ts
+164 -20
@@ -30,9 +30,11 @@ describe('Tools Modifiers', () => {
30
31 expect(schemaModifier).toHaveBeenCalledTimes(1);
32 expect(schemaModifier).toHaveBeenCalledWith(
33 - slug,
34 - expect.any(String),
35 - expect.objectContaining({ slug })
33 + expect.objectContaining({
34 + toolSlug: slug,
35 + toolkitSlug: expect.any(String),
36 + schema: expect.objectContaining({ slug }),
37 + })
38 );
39 expect(result.name).toEqual('Modified Name');
40 expect(result.description).toEqual('Modified description');
@@ -40,9 +42,9 @@ describe('Tools Modifiers', () => {
42
43 it('should apply schema modifiers to all tools when getting multiple tools', async () => {
44 const userId = 'test-user';
43 - const schemaModifier = createSchemaModifier((tool: Tool) => ({
44 - ...tool,
45 - name: `Modified ${tool.name}`,
45 + const schemaModifier = createSchemaModifier(({ schema }) => ({
46 + ...schema,
47 + name: `Modified ${schema.name}`,
48 }));
49
50 mockClient.tools.list.mockResolvedValueOnce({
@@ -82,7 +84,13 @@ describe('Tools Modifiers', () => {
84 await context.tools.execute(slug, body, { beforeExecute });
85
86 expect(beforeExecute).toHaveBeenCalledTimes(1);
85 - expect(beforeExecute).toHaveBeenCalledWith(slug, expect.any(String), body);
87 + expect(beforeExecute).toHaveBeenCalledWith(
88 + expect.objectContaining({
89 + toolSlug: slug,
90 + toolkitSlug: expect.any(String),
91 + params: body,
92 + })
93 + );
94 expect(mockClient.tools.execute).toHaveBeenCalledWith(
95 slug,
96 expect.objectContaining({
@@ -106,11 +114,13 @@ describe('Tools Modifiers', () => {
114
115 expect(afterExecute).toHaveBeenCalledTimes(1);
116 expect(afterExecute).toHaveBeenCalledWith(
109 - slug,
110 - expect.any(String),
117 expect.objectContaining({
112 - data: expect.any(Object),
113 - successful: expect.any(Boolean),
118 + toolSlug: slug,
119 + toolkitSlug: expect.any(String),
120 + result: expect.objectContaining({
121 + data: expect.any(Object),
122 + successful: expect.any(Boolean),
123 + }),
124 })
125 );
126 expect(result.data).toHaveProperty('enhanced', true);
@@ -120,32 +130,166 @@ describe('Tools Modifiers', () => {
130 describe('Combined Modifiers', () => {
131 it('should apply both schema and execution modifiers together', async () => {
132 const userId = 'test-user';
123 - const slug = 'COMPOSIO_TOOL';
133 + const slug = 'GITHUB_GET_REPOS';
134
125 - const schemaModifier = createSchemaModifier({
126 - description: 'Modified schema',
127 - });
135 + // Mock analytics and logging functions
136 + const trackToolUsage = vi.fn();
137 + const logToolError = vi.fn();
138 +
139 + const schemaModifier = createSchemaModifier(({ schema, toolSlug }) => ({
140 + ...schema,
141 + description: `Enhanced ${toolSlug} for better context`,
142 + tags: [...(schema.tags || []), 'enhanced', 'modified'],
143 + inputParameters: {
144 + type: 'object' as const,
145 + properties: {
146 + ...schema.inputParameters?.properties,
147 + tracking: {
148 + type: 'object' as const,
149 + properties: {
150 + enabled: {
151 + type: 'boolean' as const,
152 + default: true,
153 + },
154 + },
155 + },
156 + },
157 + },
158 + }));
159
129 - const executionModifiers = createExecutionModifiers();
160 + const executionModifiers = {
161 + beforeExecute: vi.fn(({ params, toolSlug }) => {
162 + // Add analytics tracking
163 + trackToolUsage(toolSlug);
164 + return {
165 + ...params,
166 + arguments: {
167 + ...(params.arguments || {}),
168 + tracking: {
169 + enabled: true,
170 + timestamp: expect.any(String),
171 + },
172 + },
173 + };
174 + }),
175 + afterExecute: vi.fn(({ result, toolSlug }) => {
176 + // Log results and handle errors
177 + if (!result.successful) {
178 + logToolError(toolSlug, result.error);
179 + }
180 + return {
181 + ...result,
182 + data: {
183 + ...(result.data || {}),
184 + processed: true,
185 + timestamp: expect.any(String),
186 + },
187 + };
188 + }),
189 + };
190
191 const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
132 - getRawComposioToolBySlugSpy.mockResolvedValueOnce({
192 + const mockTool = {
193 ...(toolMocks.transformedTool as unknown as Tool),
134 - description: 'Modified schema',
135 - });
194 + description: 'Enhanced GITHUB_GET_REPOS for better context',
195 + tags: ['enhanced', 'modified'],
196 + inputParameters: {
197 + type: 'object' as const,
198 + properties: {
199 + tracking: {
200 + type: 'object' as const,
201 + properties: {
202 + enabled: {
203 + type: 'boolean' as const,
204 + default: true,
205 + },
206 + },
207 + },
208 + },
209 + },
210 + };
211 + getRawComposioToolBySlugSpy.mockResolvedValueOnce(mockTool);
212
213 const createExecuteToolFnSpy = vi.spyOn(context.tools as any, 'createExecuteToolFn');
214 + const executeWithModifiers = async (params: any) => {
215 + // Apply beforeExecute modifier
216 + const modifiedParams = await executionModifiers.beforeExecute({
217 + toolSlug: slug,
218 + toolkitSlug: 'default',
219 + params,
220 + });
221
139 - await context.tools.get(userId, slug, {
222 + // Execute the tool
223 + const response = await mockClient.tools.execute(slug, modifiedParams);
224 +
225 + // Apply afterExecute modifier
226 + return executionModifiers.afterExecute({
227 + toolSlug: slug,
228 + toolkitSlug: 'default',
229 + result: response,
230 + });
231 + };
232 + createExecuteToolFnSpy.mockReturnValueOnce(executeWithModifiers);
233 +
234 + const tool = await context.tools.get(userId, slug, {
235 modifySchema: schemaModifier,
236 ...executionModifiers,
237 });
238
239 + // Verify schema modification
240 expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, schemaModifier);
241 + expect(mockTool.description).toBe('Enhanced GITHUB_GET_REPOS for better context');
242 + expect(mockTool.tags).toContain('enhanced');
243 + expect(mockTool.tags).toContain('modified');
244 + expect(mockTool.inputParameters).toHaveProperty(['properties', 'tracking']);
245 +
246 + // Verify execution function creation
247 expect(createExecuteToolFnSpy).toHaveBeenCalledWith(
248 userId,
249 expect.objectContaining(executionModifiers)
250 );
251 +
252 + // Mock a tool execution to verify the full flow
253 + await mockToolExecution(context.tools);
254 + mockClient.tools.execute.mockResolvedValueOnce({
255 + data: {
256 + results: true,
257 + },
258 + error: null,
259 + successful: true,
260 + log_id: '123',
261 + session_info: {},
262 + });
263 +
264 + // Execute the tool using the wrapped execute function
265 + const result = await executeWithModifiers({ query: 'test' });
266 +
267 + // Verify analytics tracking was called
268 + expect(trackToolUsage).toHaveBeenCalledWith(slug);
269 +
270 + // Verify the execution flow
271 + expect(executionModifiers.beforeExecute).toHaveBeenCalledWith({
272 + toolSlug: slug,
273 + toolkitSlug: 'default',
274 + params: { query: 'test' },
275 + });
276 +
277 + expect(executionModifiers.afterExecute).toHaveBeenCalledWith({
278 + toolSlug: slug,
279 + toolkitSlug: 'default',
280 + result: {
281 + data: {
282 + results: true,
283 + },
284 + error: null,
285 + successful: true,
286 + log_id: '123',
287 + session_info: {},
288 + },
289 + });
290 +
291 + // Verify no error logging occurred
292 + expect(logToolError).not.toHaveBeenCalled();
293 });
294 });
295 });
ts/packages/core/test/utils/toolExecuteUtils.ts
+20 -14
@@ -4,9 +4,9 @@ import { mockClient } from './mocks/client.mock';
4 import { MockProvider } from './mocks/provider.mock';
5 import { connectedAccountMocks, toolkitMocks, toolMocks } from './mocks/data.mock';
6 import ComposioClient from '@composio/client';
7 -import { Tool } from '../../src/types/tool.types';
7 +import { Tool, ToolExecuteResponse, ToolExecuteParams } from '../../src/types/tool.types';
8
9 -export type TestTools = Tools<unknown, unknown, unknown, MockProvider>;
9 +export type TestTools = Tools<Tool[], Tool, MockProvider>;
10
11 export interface TestContext {
12 tools: TestTools;
@@ -67,13 +67,15 @@ export const mockToolExecution = async (
67 };
68 };
69
70 -export type SchemaModification = Partial<Tool> | ((tool: Tool) => Partial<Tool>);
70 +export type SchemaModification =
71 + | Partial<Tool>
72 + | ((context: { schema: Tool; toolSlug: string; toolkitSlug: string }) => Partial<Tool>);
73
74 export const createSchemaModifier = (modifications: SchemaModification) => {
73 - return vi.fn((toolSlug: string, toolkitSlug: string, tool: Tool) => {
74 - const mods = typeof modifications === 'function' ? modifications(tool) : modifications;
75 + return vi.fn((context: { schema: Tool; toolSlug: string; toolkitSlug: string }) => {
76 + const mods = typeof modifications === 'function' ? modifications(context) : modifications;
77 return {
76 - ...tool,
78 + ...context.schema,
79 ...mods,
80 };
81 });
@@ -84,13 +86,17 @@ export const createExecutionModifiers = ({
86 afterModifications = {},
87 } = {}) => {
88 return {
87 - beforeExecute: vi.fn((toolSlug: string, toolkitSlug: string, params: any) => ({
88 - ...params,
89 - ...beforeModifications,
90 - })),
91 - afterExecute: vi.fn((toolSlug: string, toolkitSlug: string, response: any) => ({
92 - ...response,
93 - ...afterModifications,
94 - })),
89 + beforeExecute: vi.fn(
90 + (context: { toolSlug: string; toolkitSlug: string; params: ToolExecuteParams }) => ({
91 + ...context.params,
92 + ...beforeModifications,
93 + })
94 + ),
95 + afterExecute: vi.fn(
96 + (context: { toolSlug: string; toolkitSlug: string; result: ToolExecuteResponse }) => ({
97 + ...context.result,
98 + ...afterModifications,
99 + })
100 + ),
101 };
102 };
ts/packages/providers/anthropic/test/anthropic.test.ts
+4 -4
@@ -189,8 +189,8 @@ describe('AnthropicProvider', () => {
189 };
190
191 const modifiers = {
192 - beforeExecute: vi.fn(params => params),
193 - afterExecute: vi.fn(response => response),
192 + beforeExecute: vi.fn(({ params }) => params),
193 + afterExecute: vi.fn(({ result }) => result),
194 };
195
196 await provider.executeToolCall(userId, toolUse, options, modifiers);
@@ -344,8 +344,8 @@ describe('AnthropicProvider', () => {
344 };
345
346 const modifiers = {
347 - beforeExecute: vi.fn(params => params),
348 - afterExecute: vi.fn(response => response),
347 + beforeExecute: vi.fn(({ params }) => params),
348 + afterExecute: vi.fn(({ result }) => result),
349 };
350
351 await provider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/providers/cloudflare/test/cloudflare.test.ts
+4 -4
@@ -240,8 +240,8 @@ describe('CloudflareProvider', () => {
240 };
241
242 const modifiers = {
243 - beforeExecute: vi.fn(params => params),
244 - afterExecute: vi.fn(response => response),
243 + beforeExecute: vi.fn(({ params }) => params),
244 + afterExecute: vi.fn(({ result }) => result),
245 };
246
247 await provider.executeToolCall(userId, toolCall, options, modifiers);
@@ -285,8 +285,8 @@ describe('CloudflareProvider', () => {
285 };
286
287 const modifiers = {
288 - beforeExecute: vi.fn(params => params),
289 - afterExecute: vi.fn(response => response),
288 + beforeExecute: vi.fn(({ params }) => params),
289 + afterExecute: vi.fn(({ result }) => result),
290 };
291
292 await provider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/providers/google/test/google.test.ts
+4 -4
@@ -172,8 +172,8 @@ describe('GoogleProvider', () => {
172 };
173
174 const modifiers = {
175 - beforeExecute: vi.fn(params => params),
176 - afterExecute: vi.fn(response => response),
175 + beforeExecute: vi.fn(({ params }) => params),
176 + afterExecute: vi.fn(({ result }) => result),
177 };
178
179 await provider.executeToolCall(userId, toolCall, options, modifiers);
@@ -217,8 +217,8 @@ describe('GoogleProvider', () => {
217 };
218
219 const modifiers = {
220 - beforeExecute: vi.fn(params => params),
221 - afterExecute: vi.fn(response => response),
220 + beforeExecute: vi.fn(({ params }) => params),
221 + afterExecute: vi.fn(({ result }) => result),
222 };
223
224 await provider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/providers/mastra/test/mastra.test.ts
+2 -2
@@ -332,8 +332,8 @@ describe('MastraProvider', () => {
332 };
333
334 const modifiers = {
335 - beforeExecute: vi.fn(params => params),
336 - afterExecute: vi.fn(response => response),
335 + beforeExecute: vi.fn(({ params }) => params),
336 + afterExecute: vi.fn(({ result }) => result),
337 };
338
339 await provider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/providers/openai-agents/test/openai-agents.test.ts
+2 -2
@@ -191,8 +191,8 @@ describe('OpenAIAgentsProvider', () => {
191 };
192
193 const modifiers = {
194 - beforeExecute: vi.fn(params => params),
195 - afterExecute: vi.fn(response => response),
194 + beforeExecute: vi.fn(({ params }) => params),
195 + afterExecute: vi.fn(({ result }) => result),
196 };
197
198 await provider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/providers/openai/test/opeanai-responses.test.ts
+2 -2
@@ -199,8 +199,8 @@ describe('OpenAIResponsesProvider', () => {
199 };
200
201 const modifiers = {
202 - beforeExecute: vi.fn(params => params),
203 - afterExecute: vi.fn(response => response),
202 + beforeExecute: vi.fn(({ params }) => params),
203 + afterExecute: vi.fn(({ result }) => result),
204 };
205
206 await provider.executeToolCall(userId, toolCall, options, modifiers);
ts/packages/providers/openai/test/openai.test.ts
+4 -4
@@ -214,8 +214,8 @@ describe('OpenAIProvider', () => {
214 };
215
216 const modifiers = {
217 - beforeExecute: vi.fn(params => params),
218 - afterExecute: vi.fn(response => response),
217 + beforeExecute: vi.fn(({ params }) => params),
218 + afterExecute: vi.fn(({ result }) => result),
219 };
220
221 await provider.executeToolCall(userId, toolCall, options, modifiers);
@@ -445,8 +445,8 @@ describe('OpenAIProvider', () => {
445 };
446
447 const modifiers = {
448 - beforeExecute: vi.fn(params => params),
449 - afterExecute: vi.fn(response => response),
448 + beforeExecute: vi.fn(({ params }) => params),
449 + afterExecute: vi.fn(({ result }) => result),
450 };
451
452 await provider.executeTool(toolSlug, toolParams, modifiers);
ts/packages/providers/vercel/test/vercel.test.ts
+2 -2
@@ -187,8 +187,8 @@ describe('VercelProvider', () => {
187 };
188
189 const modifiers = {
190 - beforeExecute: vi.fn(params => params),
191 - afterExecute: vi.fn(response => response),
190 + beforeExecute: vi.fn(({ params }) => params),
191 + afterExecute: vi.fn(({ result }) => result),
192 };
193
194 await provider.executeTool(toolSlug, toolParams, modifiers);