import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
// Create a tool that should require approval
const deleteUserTool = createTool({
id: 'delete-user',
description: 'Delete a user from the system',
inputSchema: z.object({ userId: z.string() }),
requireApproval: true, // ← This should require approval
execute: async ({ userId }) => {
console.log(`Deleting user ${userId}`);
return { success: true };
},
});
// Pass it via toolsets
const stream = await agent.stream('Delete user 123', {
toolsets: {
admin: {
deleteUser: deleteUserTool
}
},
});
import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
// Create a tool that should require approval
const deleteUserTool = createTool({
id: 'delete-user',
description: 'Delete a user from the system',
inputSchema: z.object({ userId: z.string() }),
requireApproval: true, // ← This should require approval
execute: async ({ userId }) => {
console.log(`Deleting user ${userId}`);
return { success: true };
},
});
// Pass it via toolsets
const stream = await agent.stream('Delete user 123', {
toolsets: {
admin: {
deleteUser: deleteUserTool
}
},
});