@@ -9,12 +9,26 @@ import { browserSessions, type BrowserAction, SelectorType } from './types.js';
99// Schema for browser action
1010const browserActionSchema = z
1111 . object ( {
12- type : z . enum ( [ 'goto' , 'click' , 'type' , 'wait' , 'content' , 'close' ] ) ,
13- url : z . string ( ) . url ( ) . optional ( ) ,
14- selector : z . string ( ) . optional ( ) ,
15- selectorType : z . nativeEnum ( SelectorType ) . optional ( ) ,
16- text : z . string ( ) . optional ( ) ,
17- options : z . object ( { } ) . optional ( ) ,
12+ actionType : z . enum ( [ 'goto' , 'click' , 'type' , 'wait' , 'content' , 'close' ] ) ,
13+ url : z
14+ . string ( )
15+ . url ( )
16+ . optional ( )
17+ . describe ( 'URL to navigate to if "goto" actionType' ) ,
18+ selector : z
19+ . string ( )
20+ . optional ( )
21+ . describe ( 'Selector to click if "click" actionType' ) ,
22+ selectorType : z
23+ . nativeEnum ( SelectorType )
24+ . optional ( )
25+ . describe ( 'Type of selector if "click" actionType' ) ,
26+ text : z
27+ . string ( )
28+ . optional ( )
29+ . describe (
30+ 'Text to type if "type" actionType, for other actionType, this is ignored' ,
31+ ) ,
1832 } )
1933 . describe ( 'Browser action to perform' ) ;
2034
@@ -57,7 +71,7 @@ export const browseMessageTool: Tool<Parameters, ReturnType> = {
5771 returns : zodToJsonSchema ( returnSchema ) ,
5872
5973 execute : async ( { instanceId, action } , { logger } ) : Promise < ReturnType > => {
60- logger . verbose ( `Executing browser action: ${ action . type } ` ) ;
74+ logger . verbose ( `Executing browser action: ${ action . actionType } ` ) ;
6175
6276 try {
6377 const session = browserSessions . get ( instanceId ) ;
@@ -67,7 +81,7 @@ export const browseMessageTool: Tool<Parameters, ReturnType> = {
6781
6882 const { page } = session ;
6983
70- switch ( action . type ) {
84+ switch ( action . actionType ) {
7185 case 'goto' : {
7286 if ( ! action . url ) {
7387 throw new Error ( 'URL required for goto action' ) ;
@@ -136,7 +150,7 @@ export const browseMessageTool: Tool<Parameters, ReturnType> = {
136150
137151 default : {
138152 throw new Error (
139- `Unsupported action type: ${ ( action as BrowserAction ) . type } ` ,
153+ `Unsupported action type: ${ ( action as BrowserAction ) . actionType } ` ,
140154 ) ;
141155 }
142156 }
@@ -150,7 +164,9 @@ export const browseMessageTool: Tool<Parameters, ReturnType> = {
150164 } ,
151165
152166 logParameters : ( { action, description } , { logger } ) => {
153- logger . info ( `Performing browser action: ${ action . type } , ${ description } ` ) ;
167+ logger . info (
168+ `Performing browser action: ${ action . actionType } , ${ description } ` ,
169+ ) ;
154170 } ,
155171
156172 logReturns : ( output , { logger } ) => {
0 commit comments