raw: z.boolean().optional().describe('Whether to return without compression (in PNG format). Default is false, which returns a JPEG image.'),
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.'),
element: z.string().optional().describe('Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.'),
ref: z.string().optional().describe('Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.'),
}).refine(data=>{
return!!data.element===!!data.ref;
},{
message:'Both element and ref must be provided or neither.',
path:['ref','element']
});
constscreenshot=defineTool({
capability:'core',
schema:{
name:'browser_take_screenshot',
title:'Take a screenshot',
description:`Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.`,