コンテンツにスキップ

Computer

Computer

Bases: ABC

A computer implemented with sync operations.

Subclasses provide the local runtime behind ComputerTool. Mouse action methods may also accept a keyword-only keys argument to receive held modifier keys when the driver supports them.

Source code in src/agents/computer.py
class Computer(abc.ABC):
    """A computer implemented with sync operations.

    Subclasses provide the local runtime behind `ComputerTool`. Mouse action methods may
    also accept a keyword-only `keys` argument to receive held modifier keys when the
    driver supports them.
    """

    @property
    def environment(self) -> Environment | None:
        """Return preview tool metadata when the preview computer payload is required."""
        return None

    @property
    def dimensions(self) -> tuple[int, int] | None:
        """Return preview display dimensions when the preview computer payload is required."""
        return None

    @abc.abstractmethod
    def screenshot(self) -> str:
        """Return a base64-encoded PNG screenshot of the current display."""
        pass

    @abc.abstractmethod
    def click(self, x: int, y: int, button: Button) -> None:
        """Click `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 `(x, y)` by `(scroll_x, scroll_y)` units."""
        pass

    @abc.abstractmethod
    def type(self, text: str) -> None:
        """Type `text` into the currently focused target."""
        pass

    @abc.abstractmethod
    def wait(self) -> None:
        """Wait until the computer is 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 the provided keys, such as `["ctrl", "c"]`."""
        pass

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

environment property

environment: Environment | None

Return preview tool metadata when the preview computer payload is required.

dimensions property

dimensions: tuple[int, int] | None

Return preview display dimensions when the preview computer payload is required.

screenshot abstractmethod

screenshot() -> str

Return a base64-encoded PNG screenshot of the current display.

Source code in src/agents/computer.py
@abc.abstractmethod
def screenshot(self) -> str:
    """Return a base64-encoded PNG screenshot of the current display."""
    pass

click abstractmethod

click(x: int, y: int, button: Button) -> None

Click button at the given (x, y) screen coordinates.

Source code in src/agents/computer.py
@abc.abstractmethod
def click(self, x: int, y: int, button: Button) -> None:
    """Click `button` at the given `(x, y)` screen coordinates."""
    pass

double_click abstractmethod

double_click(x: int, y: int) -> None

Double-click at the given (x, y) screen coordinates.

Source code in src/agents/computer.py
@abc.abstractmethod
def double_click(self, x: int, y: int) -> None:
    """Double-click at the given `(x, y)` screen coordinates."""
    pass

scroll abstractmethod

scroll(
    x: int, y: int, scroll_x: int, scroll_y: int
) -> None

Scroll at (x, y) by (scroll_x, scroll_y) units.

Source code in src/agents/computer.py
@abc.abstractmethod
def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
    """Scroll at `(x, y)` by `(scroll_x, scroll_y)` units."""
    pass

type abstractmethod

type(text: str) -> None

Type text into the currently focused target.

Source code in src/agents/computer.py
@abc.abstractmethod
def type(self, text: str) -> None:
    """Type `text` into the currently focused target."""
    pass

wait abstractmethod

wait() -> None

Wait until the computer is ready for the next action.

Source code in src/agents/computer.py
@abc.abstractmethod
def wait(self) -> None:
    """Wait until the computer is ready for the next action."""
    pass

move abstractmethod

move(x: int, y: int) -> None

Move the mouse cursor to the given (x, y) screen coordinates.

Source code in src/agents/computer.py
@abc.abstractmethod
def move(self, x: int, y: int) -> None:
    """Move the mouse cursor to the given `(x, y)` screen coordinates."""
    pass

keypress abstractmethod

keypress(keys: list[str]) -> None

Press the provided keys, such as ["ctrl", "c"].

Source code in src/agents/computer.py
@abc.abstractmethod
def keypress(self, keys: list[str]) -> None:
    """Press the provided keys, such as `["ctrl", "c"]`."""
    pass

drag abstractmethod

drag(path: list[tuple[int, int]]) -> None

Click-and-drag the mouse along the given sequence of (x, y) waypoints.

Source code in src/agents/computer.py
@abc.abstractmethod
def drag(self, path: list[tuple[int, int]]) -> None:
    """Click-and-drag the mouse along the given sequence of `(x, y)` waypoints."""
    pass

AsyncComputer

Bases: ABC

A computer implemented with async operations.

Subclasses provide the local runtime behind ComputerTool. Mouse action methods may also accept a keyword-only keys argument to receive held modifier keys when the driver supports them.

Source code in src/agents/computer.py
class AsyncComputer(abc.ABC):
    """A computer implemented with async operations.

    Subclasses provide the local runtime behind `ComputerTool`. Mouse action methods may
    also accept a keyword-only `keys` argument to receive held modifier keys when the
    driver supports them.
    """

    @property
    def environment(self) -> Environment | None:
        """Return preview tool metadata when the preview computer payload is required."""
        return None

    @property
    def dimensions(self) -> tuple[int, int] | None:
        """Return preview display dimensions when the preview computer payload is required."""
        return None

    @abc.abstractmethod
    async def screenshot(self) -> str:
        """Return a base64-encoded PNG screenshot of the current display."""
        pass

    @abc.abstractmethod
    async def click(self, x: int, y: int, button: Button) -> None:
        """Click `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 `(x, y)` by `(scroll_x, scroll_y)` units."""
        pass

    @abc.abstractmethod
    async def type(self, text: str) -> None:
        """Type `text` into the currently focused target."""
        pass

    @abc.abstractmethod
    async def wait(self) -> None:
        """Wait until the computer is 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 the provided keys, such as `["ctrl", "c"]`."""
        pass

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

environment property

environment: Environment | None

Return preview tool metadata when the preview computer payload is required.

dimensions property

dimensions: tuple[int, int] | None

Return preview display dimensions when the preview computer payload is required.

screenshot abstractmethod async

screenshot() -> str

Return a base64-encoded PNG screenshot of the current display.

Source code in src/agents/computer.py
@abc.abstractmethod
async def screenshot(self) -> str:
    """Return a base64-encoded PNG screenshot of the current display."""
    pass

click abstractmethod async

click(x: int, y: int, button: Button) -> None

Click button at the given (x, y) screen coordinates.

Source code in src/agents/computer.py
@abc.abstractmethod
async def click(self, x: int, y: int, button: Button) -> None:
    """Click `button` at the given `(x, y)` screen coordinates."""
    pass

double_click abstractmethod async

double_click(x: int, y: int) -> None

Double-click at the given (x, y) screen coordinates.

Source code in src/agents/computer.py
@abc.abstractmethod
async def double_click(self, x: int, y: int) -> None:
    """Double-click at the given `(x, y)` screen coordinates."""
    pass

scroll abstractmethod async

scroll(
    x: int, y: int, scroll_x: int, scroll_y: int
) -> None

Scroll at (x, y) by (scroll_x, scroll_y) units.

Source code in src/agents/computer.py
@abc.abstractmethod
async def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
    """Scroll at `(x, y)` by `(scroll_x, scroll_y)` units."""
    pass

type abstractmethod async

type(text: str) -> None

Type text into the currently focused target.

Source code in src/agents/computer.py
@abc.abstractmethod
async def type(self, text: str) -> None:
    """Type `text` into the currently focused target."""
    pass

wait abstractmethod async

wait() -> None

Wait until the computer is ready for the next action.

Source code in src/agents/computer.py
@abc.abstractmethod
async def wait(self) -> None:
    """Wait until the computer is ready for the next action."""
    pass

move abstractmethod async

move(x: int, y: int) -> None

Move the mouse cursor to the given (x, y) screen coordinates.

Source code in src/agents/computer.py
@abc.abstractmethod
async def move(self, x: int, y: int) -> None:
    """Move the mouse cursor to the given `(x, y)` screen coordinates."""
    pass

keypress abstractmethod async

keypress(keys: list[str]) -> None

Press the provided keys, such as ["ctrl", "c"].

Source code in src/agents/computer.py
@abc.abstractmethod
async def keypress(self, keys: list[str]) -> None:
    """Press the provided keys, such as `["ctrl", "c"]`."""
    pass

drag abstractmethod async

drag(path: list[tuple[int, int]]) -> None

Click-and-drag the mouse along the given sequence of (x, y) waypoints.

Source code in src/agents/computer.py
@abc.abstractmethod
async def drag(self, path: list[tuple[int, int]]) -> None:
    """Click-and-drag the mouse along the given sequence of `(x, y)` waypoints."""
    pass