@@ -92,9 +92,11 @@ type BrowserPlaywrightService interface {
9292
9393// BrowserComputerService defines the subset we use for OS-level mouse & screen.
9494type BrowserComputerService interface {
95+ Batch (ctx context.Context , id string , body kernel.BrowserComputerBatchParams , opts ... option.RequestOption ) (err error )
9596 CaptureScreenshot (ctx context.Context , id string , body kernel.BrowserComputerCaptureScreenshotParams , opts ... option.RequestOption ) (res * http.Response , err error )
9697 ClickMouse (ctx context.Context , id string , body kernel.BrowserComputerClickMouseParams , opts ... option.RequestOption ) (err error )
9798 DragMouse (ctx context.Context , id string , body kernel.BrowserComputerDragMouseParams , opts ... option.RequestOption ) (err error )
99+ GetMousePosition (ctx context.Context , id string , opts ... option.RequestOption ) (res * kernel.BrowserComputerGetMousePositionResponse , err error )
98100 MoveMouse (ctx context.Context , id string , body kernel.BrowserComputerMoveMouseParams , opts ... option.RequestOption ) (err error )
99101 PressKey (ctx context.Context , id string , body kernel.BrowserComputerPressKeyParams , opts ... option.RequestOption ) (err error )
100102 Scroll (ctx context.Context , id string , body kernel.BrowserComputerScrollParams , opts ... option.RequestOption ) (err error )
@@ -172,6 +174,7 @@ type BrowsersCreateInput struct {
172174 TimeoutSeconds int
173175 Stealth BoolFlag
174176 Headless BoolFlag
177+ GPU BoolFlag
175178 Kiosk BoolFlag
176179 ProfileID string
177180 ProfileName string
@@ -340,6 +343,9 @@ func (b BrowsersCmd) Create(ctx context.Context, in BrowsersCreateInput) error {
340343 if in .Headless .Set {
341344 params .Headless = kernel .Opt (in .Headless .Value )
342345 }
346+ if in .GPU .Set {
347+ params .GPU = kernel .Opt (in .GPU .Value )
348+ }
343349 if in .Kiosk .Set {
344350 params .KioskMode = kernel .Opt (in .Kiosk .Value )
345351 }
@@ -527,6 +533,7 @@ func (b BrowsersCmd) Get(ctx context.Context, in BrowsersGetInput) error {
527533 tableData = append (tableData , []string {"Timeout (seconds)" , fmt .Sprintf ("%d" , browser .TimeoutSeconds )})
528534 tableData = append (tableData , []string {"Headless" , fmt .Sprintf ("%t" , browser .Headless )})
529535 tableData = append (tableData , []string {"Stealth" , fmt .Sprintf ("%t" , browser .Stealth )})
536+ tableData = append (tableData , []string {"GPU" , fmt .Sprintf ("%t" , browser .GPU )})
530537 tableData = append (tableData , []string {"Kiosk Mode" , fmt .Sprintf ("%t" , browser .KioskMode )})
531538 if browser .Viewport .Width > 0 && browser .Viewport .Height > 0 {
532539 viewportStr := fmt .Sprintf ("%dx%d" , browser .Viewport .Width , browser .Viewport .Height )
@@ -740,6 +747,16 @@ type BrowsersComputerSetCursorInput struct {
740747 Hidden bool
741748}
742749
750+ type BrowsersComputerGetMousePositionInput struct {
751+ Identifier string
752+ Output string
753+ }
754+
755+ type BrowsersComputerBatchInput struct {
756+ Identifier string
757+ ActionsJSON string
758+ }
759+
743760func (b BrowsersCmd ) ComputerClickMouse (ctx context.Context , in BrowsersComputerClickMouseInput ) error {
744761 if b .computer == nil {
745762 pterm .Error .Println ("computer service not available" )
@@ -956,6 +973,49 @@ func (b BrowsersCmd) ComputerSetCursor(ctx context.Context, in BrowsersComputerS
956973 return nil
957974}
958975
976+ func (b BrowsersCmd ) ComputerGetMousePosition (ctx context.Context , in BrowsersComputerGetMousePositionInput ) error {
977+ if b .computer == nil {
978+ pterm .Error .Println ("computer service not available" )
979+ return nil
980+ }
981+ br , err := b .browsers .Get (ctx , in .Identifier , kernel.BrowserGetParams {})
982+ if err != nil {
983+ return util.CleanedUpSdkError {Err : err }
984+ }
985+ res , err := b .computer .GetMousePosition (ctx , br .SessionID )
986+ if err != nil {
987+ return util.CleanedUpSdkError {Err : err }
988+ }
989+ if in .Output == "json" {
990+ enc := json .NewEncoder (os .Stdout )
991+ enc .SetIndent ("" , " " )
992+ return enc .Encode (res )
993+ }
994+ fmt .Printf ("x: %d\n y: %d\n " , res .X , res .Y )
995+ return nil
996+ }
997+
998+ func (b BrowsersCmd ) ComputerBatch (ctx context.Context , in BrowsersComputerBatchInput ) error {
999+ if b .computer == nil {
1000+ pterm .Error .Println ("computer service not available" )
1001+ return nil
1002+ }
1003+ br , err := b .browsers .Get (ctx , in .Identifier , kernel.BrowserGetParams {})
1004+ if err != nil {
1005+ return util.CleanedUpSdkError {Err : err }
1006+ }
1007+ var body kernel.BrowserComputerBatchParams
1008+ if err := json .Unmarshal ([]byte (in .ActionsJSON ), & body ); err != nil {
1009+ pterm .Error .Printf ("Invalid JSON: %v\n " , err )
1010+ return nil
1011+ }
1012+ if err := b .computer .Batch (ctx , br .SessionID , body ); err != nil {
1013+ return util.CleanedUpSdkError {Err : err }
1014+ }
1015+ pterm .Success .Println ("Batch actions executed" )
1016+ return nil
1017+ }
1018+
9591019// Replays
9601020type BrowsersReplaysListInput struct {
9611021 Identifier string
@@ -2300,7 +2360,16 @@ func init() {
23002360 computerSetCursor .Flags ().String ("hidden" , "" , "Whether to hide the cursor: true or false" )
23012361 _ = computerSetCursor .MarkFlagRequired ("hidden" )
23022362
2303- computerRoot .AddCommand (computerClick , computerMove , computerScreenshot , computerType , computerPressKey , computerScroll , computerDrag , computerSetCursor )
2363+ // computer get-mouse-position
2364+ computerGetMousePosition := & cobra.Command {Use : "get-mouse-position <id>" , Short : "Get current mouse cursor position" , Args : cobra .ExactArgs (1 ), RunE : runBrowsersComputerGetMousePosition }
2365+ computerGetMousePosition .Flags ().StringP ("output" , "o" , "" , "Output format: json for raw API response" )
2366+
2367+ // computer batch
2368+ computerBatch := & cobra.Command {Use : "batch <id>" , Short : "Execute a batch of computer actions from JSON" , Args : cobra .ExactArgs (1 ), RunE : runBrowsersComputerBatch }
2369+ computerBatch .Flags ().String ("actions" , "" , "JSON object with actions array (e.g., {\" actions\" :[{\" type\" :\" click_mouse\" ,...}]})" )
2370+ _ = computerBatch .MarkFlagRequired ("actions" )
2371+
2372+ computerRoot .AddCommand (computerClick , computerMove , computerScreenshot , computerType , computerPressKey , computerScroll , computerDrag , computerSetCursor , computerGetMousePosition , computerBatch )
23042373 browsersCmd .AddCommand (computerRoot )
23052374
23062375 // playwright
@@ -2316,6 +2385,7 @@ func init() {
23162385 _ = browsersCreateCmd .Flags ().MarkDeprecated ("persistent-id" , "use --timeout (up to 72 hours) and profiles instead" )
23172386 browsersCreateCmd .Flags ().BoolP ("stealth" , "s" , false , "Launch browser in stealth mode to avoid detection" )
23182387 browsersCreateCmd .Flags ().BoolP ("headless" , "H" , false , "Launch browser without GUI access" )
2388+ browsersCreateCmd .Flags ().Bool ("gpu" , false , "Launch browser with hardware-accelerated GPU rendering" )
23192389 browsersCreateCmd .Flags ().Bool ("kiosk" , false , "Launch browser in kiosk mode" )
23202390 browsersCreateCmd .Flags ().IntP ("timeout" , "t" , 60 , "Timeout in seconds for the browser session" )
23212391 browsersCreateCmd .Flags ().String ("profile-id" , "" , "Profile ID to load into the browser session (mutually exclusive with --profile-name)" )
@@ -2359,6 +2429,7 @@ func runBrowsersCreate(cmd *cobra.Command, args []string) error {
23592429 }
23602430 stealthVal , _ := cmd .Flags ().GetBool ("stealth" )
23612431 headlessVal , _ := cmd .Flags ().GetBool ("headless" )
2432+ gpuVal , _ := cmd .Flags ().GetBool ("gpu" )
23622433 kioskVal , _ := cmd .Flags ().GetBool ("kiosk" )
23632434 timeout , _ := cmd .Flags ().GetInt ("timeout" )
23642435 profileID , _ := cmd .Flags ().GetString ("profile-id" )
@@ -2470,6 +2541,7 @@ func runBrowsersCreate(cmd *cobra.Command, args []string) error {
24702541 TimeoutSeconds : timeout ,
24712542 Stealth : BoolFlag {Set : cmd .Flags ().Changed ("stealth" ), Value : stealthVal },
24722543 Headless : BoolFlag {Set : cmd .Flags ().Changed ("headless" ), Value : headlessVal },
2544+ GPU : BoolFlag {Set : cmd .Flags ().Changed ("gpu" ), Value : gpuVal },
24732545 Kiosk : BoolFlag {Set : cmd .Flags ().Changed ("kiosk" ), Value : kioskVal },
24742546 ProfileID : profileID ,
24752547 ProfileName : profileName ,
@@ -3001,6 +3073,24 @@ func runBrowsersComputerSetCursor(cmd *cobra.Command, args []string) error {
30013073 return b .ComputerSetCursor (cmd .Context (), BrowsersComputerSetCursorInput {Identifier : args [0 ], Hidden : hidden })
30023074}
30033075
3076+ func runBrowsersComputerGetMousePosition (cmd * cobra.Command , args []string ) error {
3077+ client := getKernelClient (cmd )
3078+ svc := client .Browsers
3079+ output , _ := cmd .Flags ().GetString ("output" )
3080+
3081+ b := BrowsersCmd {browsers : & svc , computer : & svc .Computer }
3082+ return b .ComputerGetMousePosition (cmd .Context (), BrowsersComputerGetMousePositionInput {Identifier : args [0 ], Output : output })
3083+ }
3084+
3085+ func runBrowsersComputerBatch (cmd * cobra.Command , args []string ) error {
3086+ client := getKernelClient (cmd )
3087+ svc := client .Browsers
3088+ actionsJSON , _ := cmd .Flags ().GetString ("actions" )
3089+
3090+ b := BrowsersCmd {browsers : & svc , computer : & svc .Computer }
3091+ return b .ComputerBatch (cmd .Context (), BrowsersComputerBatchInput {Identifier : args [0 ], ActionsJSON : actionsJSON })
3092+ }
3093+
30043094func truncateURL (url string , maxLen int ) string {
30053095 if len (url ) <= maxLen {
30063096 return url
0 commit comments