@@ -12,6 +12,11 @@ import {parseKey} from '../utils/keyboard.js';
1212import { ToolCategory } from './categories.js' ;
1313import { defineTool } from './ToolDefinition.js' ;
1414
15+ const dblClickSchema = zod
16+ . boolean ( )
17+ . optional ( )
18+ . describe ( 'Set to true for double clicks. Default is false.' ) ;
19+
1520export const click = defineTool ( {
1621 name : 'click' ,
1722 description : `Clicks on the provided element` ,
@@ -25,10 +30,7 @@ export const click = defineTool({
2530 . describe (
2631 'The uid of an element on the page from the page content snapshot' ,
2732 ) ,
28- dblClick : zod
29- . boolean ( )
30- . optional ( )
31- . describe ( 'Set to true for double clicks. Default is false.' ) ,
33+ dblClick : dblClickSchema ,
3234 } ,
3335 handler : async ( request , response , context ) => {
3436 const uid = request . params . uid ;
@@ -51,6 +53,35 @@ export const click = defineTool({
5153 } ,
5254} ) ;
5355
56+ export const clickAt = defineTool ( {
57+ name : 'click_at' ,
58+ description : `Clicks at the provided coordinates` ,
59+ annotations : {
60+ category : ToolCategory . INPUT ,
61+ readOnlyHint : false ,
62+ conditions : [ 'computerVision' ] ,
63+ } ,
64+ schema : {
65+ x : zod . number ( ) . describe ( 'The x coordinate' ) ,
66+ y : zod . number ( ) . describe ( 'The y coordinate' ) ,
67+ dblClick : dblClickSchema ,
68+ } ,
69+ handler : async ( request , response , context ) => {
70+ const page = context . getSelectedPage ( ) ;
71+ await context . waitForEventsAfterAction ( async ( ) => {
72+ await page . mouse . click ( request . params . x , request . params . y , {
73+ clickCount : request . params . dblClick ? 2 : 1 ,
74+ } ) ;
75+ } ) ;
76+ response . appendResponseLine (
77+ request . params . dblClick
78+ ? `Successfully double clicked at the coordinates`
79+ : `Successfully clicked at the coordinates` ,
80+ ) ;
81+ response . includeSnapshot ( ) ;
82+ } ,
83+ } ) ;
84+
5485export const hover = defineTool ( {
5586 name : 'hover' ,
5687 description : `Hover over the provided element` ,
0 commit comments