Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/agents/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,47 @@ def dimensions(self) -> tuple[int, int] | None:

@abc.abstractmethod
def screenshot(self) -> str:
"""Take a screenshot and return the base64-encoded image data."""
pass

@abc.abstractmethod
def click(self, x: int, y: int, button: Button) -> None:
"""Click a mouse button at the given (x, y) screen coordinates."""
pass

@abc.abstractmethod
def double_click(self, x: int, y: int) -> None:
"""Double-click at the given (x, y) screen coordinates."""
pass

@abc.abstractmethod
def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
"""Scroll at the given (x, y) coordinates by (scroll_x, scroll_y) units."""
pass

@abc.abstractmethod
def type(self, text: str) -> None:
"""Type the given text at the current cursor position."""
pass

@abc.abstractmethod
def wait(self) -> None:
"""Wait for the computer to be ready for the next action."""
pass

@abc.abstractmethod
def move(self, x: int, y: int) -> None:
"""Move the mouse cursor to the given (x, y) screen coordinates."""
pass

@abc.abstractmethod
def keypress(self, keys: list[str]) -> None:
"""Press one or more keys simultaneously (e.g. ``["ctrl", "c"]``)."""
pass

@abc.abstractmethod
def drag(self, path: list[tuple[int, int]]) -> None:
"""Click-and-drag the mouse along the sequence of (x, y) waypoints."""
pass


Expand All @@ -72,36 +81,45 @@ def dimensions(self) -> tuple[int, int] | None:

@abc.abstractmethod
async def screenshot(self) -> str:
"""Take a screenshot and return the base64-encoded image data."""
pass

@abc.abstractmethod
async def click(self, x: int, y: int, button: Button) -> None:
"""Click a mouse button at the given (x, y) screen coordinates."""
pass

@abc.abstractmethod
async def double_click(self, x: int, y: int) -> None:
"""Double-click at the given (x, y) screen coordinates."""
pass

@abc.abstractmethod
async def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
"""Scroll at the given (x, y) coordinates by (scroll_x, scroll_y) units."""
pass

@abc.abstractmethod
async def type(self, text: str) -> None:
"""Type the given text at the current cursor position."""
pass

@abc.abstractmethod
async def wait(self) -> None:
"""Wait for the computer to be ready for the next action."""
pass

@abc.abstractmethod
async def move(self, x: int, y: int) -> None:
"""Move the mouse cursor to the given (x, y) screen coordinates."""
pass

@abc.abstractmethod
async def keypress(self, keys: list[str]) -> None:
"""Press one or more keys simultaneously (e.g. ``["ctrl", "c"]``)."""
pass

@abc.abstractmethod
async def drag(self, path: list[tuple[int, int]]) -> None:
"""Click-and-drag the mouse along the sequence of (x, y) waypoints."""
pass