Skip to content

TerminalOutputChunk

Base classes

Name Children Inherits
AnnotatedObject
aclientp.schema.v2.base
A v2 object with the ``_meta`` extension point.

⋔ Inheritance diagram

graph TD
  95970869963536["terminals.TerminalOutputChunk"]
  95970868359040["base.AnnotatedObject"]
  95970855946400["base.Schema"]
  95970851503232["main.BaseModel"]
  125067848591872["builtins.object"]
  95970868359040 --> 95970869963536
  95970855946400 --> 95970868359040
  95970851503232 --> 95970855946400
  125067848591872 --> 95970851503232

🛈 DocStrings

Bases: AnnotatedObject

A chunk of bytes appended to an agent-owned terminal's output.

Source code in src/aclientp/schema/v2/terminals.py
class TerminalOutputChunk(AnnotatedObject):
    """A chunk of bytes appended to an agent-owned terminal's output."""

    session_update: Literal["terminal_output_chunk"] = Field(
        default="terminal_output_chunk", init=False
    )

    terminal_id: TerminalId
    """The terminal receiving these bytes."""

    data: str
    """Independently base64-encoded terminal output bytes."""

    @classmethod
    def from_bytes(cls, terminal_id: TerminalId, data: bytes) -> Self:
        """Create a chunk from raw output bytes."""
        return cls(terminal_id=terminal_id, data=base64.b64encode(data).decode("ascii"))

    def decode(self) -> bytes:
        """The raw output bytes."""
        return base64.b64decode(self.data)

data instance-attribute

data: str

Independently base64-encoded terminal output bytes.

terminal_id instance-attribute

terminal_id: TerminalId

The terminal receiving these bytes.

decode

decode() -> bytes

The raw output bytes.

Source code in src/aclientp/schema/v2/terminals.py
def decode(self) -> bytes:
    """The raw output bytes."""
    return base64.b64decode(self.data)

from_bytes classmethod

from_bytes(terminal_id: TerminalId, data: bytes) -> Self

Create a chunk from raw output bytes.

Source code in src/aclientp/schema/v2/terminals.py
@classmethod
def from_bytes(cls, terminal_id: TerminalId, data: bytes) -> Self:
    """Create a chunk from raw output bytes."""
    return cls(terminal_id=terminal_id, data=base64.b64encode(data).decode("ascii"))

:fa-brands-github: Show source on GitHub