Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Computer

Computer

Bases: ABC

A computer implemented with sync operations. The Computer interface abstracts the operations needed to control a computer or browser.

Source code in src/agents/computer.py
class Computer(abc.ABC):
    """A computer implemented with sync operations. The Computer interface abstracts the
    operations needed to control a computer or browser."""

    @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:
        pass

    @abc.abstractmethod
    def click(self, x: int, y: int, button: Button) -> None:
        pass

    @abc.abstractmethod
    def double_click(self, x: int, y: int) -> None:
        pass

    @abc.abstractmethod
    def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
        pass

    @abc.abstractmethod
    def type(self, text: str) -> None:
        pass

    @abc.abstractmethod
    def wait(self) -> None:
        pass

    @abc.abstractmethod
    def move(self, x: int, y: int) -> None:
        pass

    @abc.abstractmethod
    def keypress(self, keys: list[str]) -> None:
        pass

    @abc.abstractmethod
    def drag(self, path: list[tuple[int, int]]) -> None:
        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.

AsyncComputer

Bases: ABC

A computer implemented with async operations. The Computer interface abstracts the operations needed to control a computer or browser.

Source code in src/agents/computer.py
class AsyncComputer(abc.ABC):
    """A computer implemented with async operations. The Computer interface abstracts the
    operations needed to control a computer or browser."""

    @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:
        pass

    @abc.abstractmethod
    async def click(self, x: int, y: int, button: Button) -> None:
        pass

    @abc.abstractmethod
    async def double_click(self, x: int, y: int) -> None:
        pass

    @abc.abstractmethod
    async def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
        pass

    @abc.abstractmethod
    async def type(self, text: str) -> None:
        pass

    @abc.abstractmethod
    async def wait(self) -> None:
        pass

    @abc.abstractmethod
    async def move(self, x: int, y: int) -> None:
        pass

    @abc.abstractmethod
    async def keypress(self, keys: list[str]) -> None:
        pass

    @abc.abstractmethod
    async def drag(self, path: list[tuple[int, int]]) -> None:
        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.