@@ -17,6 +17,11 @@ const dblClickSchema = zod
1717 . optional ( )
1818 . describe ( 'Set to true for double clicks. Default is false.' ) ;
1919
20+ const includeSnapshotSchema = zod
21+ . boolean ( )
22+ . optional ( )
23+ . describe ( 'Whether to include a snapshot in the response. Default is true.' ) ;
24+
2025export const click = defineTool ( {
2126 name : 'click' ,
2227 description : `Clicks on the provided element` ,
@@ -31,6 +36,7 @@ export const click = defineTool({
3136 'The uid of an element on the page from the page content snapshot' ,
3237 ) ,
3338 dblClick : dblClickSchema ,
39+ includeSnapshot : includeSnapshotSchema ,
3440 } ,
3541 handler : async ( request , response , context ) => {
3642 const uid = request . params . uid ;
@@ -46,7 +52,9 @@ export const click = defineTool({
4652 ? `Successfully double clicked on the element`
4753 : `Successfully clicked on the element` ,
4854 ) ;
49- response . includeSnapshot ( ) ;
55+ if ( request . params . includeSnapshot !== false ) {
56+ response . includeSnapshot ( ) ;
57+ }
5058 } finally {
5159 void handle . dispose ( ) ;
5260 }
@@ -65,6 +73,7 @@ export const clickAt = defineTool({
6573 x : zod . number ( ) . describe ( 'The x coordinate' ) ,
6674 y : zod . number ( ) . describe ( 'The y coordinate' ) ,
6775 dblClick : dblClickSchema ,
76+ includeSnapshot : includeSnapshotSchema ,
6877 } ,
6978 handler : async ( request , response , context ) => {
7079 const page = context . getSelectedPage ( ) ;
@@ -78,7 +87,9 @@ export const clickAt = defineTool({
7887 ? `Successfully double clicked at the coordinates`
7988 : `Successfully clicked at the coordinates` ,
8089 ) ;
81- response . includeSnapshot ( ) ;
90+ if ( request . params . includeSnapshot !== false ) {
91+ response . includeSnapshot ( ) ;
92+ }
8293 } ,
8394} ) ;
8495
@@ -95,6 +106,7 @@ export const hover = defineTool({
95106 . describe (
96107 'The uid of an element on the page from the page content snapshot' ,
97108 ) ,
109+ includeSnapshot : includeSnapshotSchema ,
98110 } ,
99111 handler : async ( request , response , context ) => {
100112 const uid = request . params . uid ;
@@ -104,7 +116,9 @@ export const hover = defineTool({
104116 await handle . asLocator ( ) . hover ( ) ;
105117 } ) ;
106118 response . appendResponseLine ( `Successfully hovered over the element` ) ;
107- response . includeSnapshot ( ) ;
119+ if ( request . params . includeSnapshot !== false ) {
120+ response . includeSnapshot ( ) ;
121+ }
108122 } finally {
109123 void handle . dispose ( ) ;
110124 }
@@ -185,6 +199,7 @@ export const fill = defineTool({
185199 'The uid of an element on the page from the page content snapshot' ,
186200 ) ,
187201 value : zod . string ( ) . describe ( 'The value to fill in' ) ,
202+ includeSnapshot : includeSnapshotSchema ,
188203 } ,
189204 handler : async ( request , response , context ) => {
190205 await context . waitForEventsAfterAction ( async ( ) => {
@@ -196,7 +211,9 @@ export const fill = defineTool({
196211 ) ;
197212 } ) ;
198213 response . appendResponseLine ( `Successfully filled out the element` ) ;
199- response . includeSnapshot ( ) ;
214+ if ( request . params . includeSnapshot !== false ) {
215+ response . includeSnapshot ( ) ;
216+ }
200217 } ,
201218} ) ;
202219
@@ -210,6 +227,7 @@ export const drag = defineTool({
210227 schema : {
211228 from_uid : zod . string ( ) . describe ( 'The uid of the element to drag' ) ,
212229 to_uid : zod . string ( ) . describe ( 'The uid of the element to drop into' ) ,
230+ includeSnapshot : includeSnapshotSchema ,
213231 } ,
214232 handler : async ( request , response , context ) => {
215233 const fromHandle = await context . getElementByUid ( request . params . from_uid ) ;
@@ -221,7 +239,9 @@ export const drag = defineTool({
221239 await toHandle . drop ( fromHandle ) ;
222240 } ) ;
223241 response . appendResponseLine ( `Successfully dragged an element` ) ;
224- response . includeSnapshot ( ) ;
242+ if ( request . params . includeSnapshot !== false ) {
243+ response . includeSnapshot ( ) ;
244+ }
225245 } finally {
226246 void fromHandle . dispose ( ) ;
227247 void toHandle . dispose ( ) ;
@@ -245,6 +265,7 @@ export const fillForm = defineTool({
245265 } ) ,
246266 )
247267 . describe ( 'Elements from snapshot to fill out.' ) ,
268+ includeSnapshot : includeSnapshotSchema ,
248269 } ,
249270 handler : async ( request , response , context ) => {
250271 for ( const element of request . params . elements ) {
@@ -257,7 +278,9 @@ export const fillForm = defineTool({
257278 } ) ;
258279 }
259280 response . appendResponseLine ( `Successfully filled out the form` ) ;
260- response . includeSnapshot ( ) ;
281+ if ( request . params . includeSnapshot !== false ) {
282+ response . includeSnapshot ( ) ;
283+ }
261284 } ,
262285} ) ;
263286
@@ -275,6 +298,7 @@ export const uploadFile = defineTool({
275298 'The uid of the file input element or an element that will open file chooser on the page from the page content snapshot' ,
276299 ) ,
277300 filePath : zod . string ( ) . describe ( 'The local path of the file to upload' ) ,
301+ includeSnapshot : includeSnapshotSchema ,
278302 } ,
279303 handler : async ( request , response , context ) => {
280304 const { uid, filePath} = request . params ;
@@ -301,7 +325,9 @@ export const uploadFile = defineTool({
301325 ) ;
302326 }
303327 }
304- response . includeSnapshot ( ) ;
328+ if ( request . params . includeSnapshot !== false ) {
329+ response . includeSnapshot ( ) ;
330+ }
305331 response . appendResponseLine ( `File uploaded from ${ filePath } .` ) ;
306332 } finally {
307333 void handle . dispose ( ) ;
@@ -322,6 +348,7 @@ export const pressKey = defineTool({
322348 . describe (
323349 'A key or a combination (e.g., "Enter", "Control+A", "Control++", "Control+Shift+R"). Modifiers: Control, Shift, Alt, Meta' ,
324350 ) ,
351+ includeSnapshot : includeSnapshotSchema ,
325352 } ,
326353 handler : async ( request , response , context ) => {
327354 const page = context . getSelectedPage ( ) ;
@@ -341,6 +368,8 @@ export const pressKey = defineTool({
341368 response . appendResponseLine (
342369 `Successfully pressed key: ${ request . params . key } ` ,
343370 ) ;
344- response . includeSnapshot ( ) ;
371+ if ( request . params . includeSnapshot !== false ) {
372+ response . includeSnapshot ( ) ;
373+ }
345374 } ,
346375} ) ;
0 commit comments