Spaces:
Running
Running
import abc | |
from typing import Literal | |
Environment = Literal["mac", "windows", "ubuntu", "browser"] | |
Button = Literal["left", "right", "wheel", "back", "forward"] | |
class Computer(abc.ABC): | |
"""A computer implemented with sync operations. The Computer interface abstracts the | |
operations needed to control a computer or browser.""" | |
def environment(self) -> Environment: | |
pass | |
def dimensions(self) -> tuple[int, int]: | |
pass | |
def screenshot(self) -> str: | |
pass | |
def click(self, x: int, y: int, button: Button) -> None: | |
pass | |
def double_click(self, x: int, y: int) -> None: | |
pass | |
def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None: | |
pass | |
def type(self, text: str) -> None: | |
pass | |
def wait(self) -> None: | |
pass | |
def move(self, x: int, y: int) -> None: | |
pass | |
def keypress(self, keys: list[str]) -> None: | |
pass | |
def drag(self, path: list[tuple[int, int]]) -> None: | |
pass | |
class AsyncComputer(abc.ABC): | |
"""A computer implemented with async operations. The Computer interface abstracts the | |
operations needed to control a computer or browser.""" | |
def environment(self) -> Environment: | |
pass | |
def dimensions(self) -> tuple[int, int]: | |
pass | |
async def screenshot(self) -> str: | |
pass | |
async def click(self, x: int, y: int, button: Button) -> None: | |
pass | |
async def double_click(self, x: int, y: int) -> None: | |
pass | |
async def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None: | |
pass | |
async def type(self, text: str) -> None: | |
pass | |
async def wait(self) -> None: | |
pass | |
async def move(self, x: int, y: int) -> None: | |
pass | |
async def keypress(self, keys: list[str]) -> None: | |
pass | |
async def drag(self, path: list[tuple[int, int]]) -> None: | |
pass | |