Skip to content

TerminalState

🛈 DocStrings

An agent-owned terminal: display only, referenced by tool calls.

Source code in src/acptui/protocol/state.py
@dataclass(eq=False)
class TerminalState:
    """An agent-owned terminal: display only, referenced by tool calls."""

    terminal_id: str
    command: str | None = None
    cwd: str | None = None
    output: bytearray = field(default_factory=bytearray)
    exit_status: TerminalExitStatus | None = None
    size: TerminalSize | None = None
    can_cancel: bool = False

    @property
    def exited(self) -> bool:
        """Whether the process has exited."""
        return self.exit_status is not None

    def append(self, data: bytes) -> None:
        """Append output, keeping at most :data:`MAX_TERMINAL_BYTES`."""
        self.output.extend(data)
        if len(self.output) > MAX_TERMINAL_BYTES:
            del self.output[: len(self.output) - MAX_TERMINAL_BYTES]

exited property

exited: bool

Whether the process has exited.

append

append(data: bytes) -> None

Append output, keeping at most :data:MAX_TERMINAL_BYTES.

Source code in src/acptui/protocol/state.py
def append(self, data: bytes) -> None:
    """Append output, keeping at most :data:`MAX_TERMINAL_BYTES`."""
    self.output.extend(data)
    if len(self.output) > MAX_TERMINAL_BYTES:
        del self.output[: len(self.output) - MAX_TERMINAL_BYTES]

:fa-brands-github: Show source on GitHub