AsyncPtyClient
Source: leap0/_async/pty.py
Signature
Section titled “Signature”AsyncPtyClient(transport: AsyncTransport)Overview
Section titled “Overview”Create and connect to PTY sessions asynchronously.
Attributes: None.
Methods
Section titled “Methods”async list(sandbox: SandboxRef) -> list[PtySession]List PTY sessions for a sandbox.
Args: sandbox: Sandbox ID or object.
Returns: object: Result returned by this operation.
create
Section titled “create”async create(sandbox: SandboxRef, *, session_id: str | None = None, cols: int | None = None, rows: int | None = None, cwd: str | None = None, envs: dict[str, str] | None = None, lazy_start: bool | None = None, http_timeout: float | None = None) -> PtySessionCreate a terminal session with a shell process.
Args: sandbox: Sandbox ID or object. session_id: Session ID. Auto-generated if omitted. cols: Terminal columns. rows: Terminal rows. cwd: Starting directory. envs: Environment variables. lazy_start: Defer shell start until the first WebSocket connection. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: PtySession: Metadata for the created PTY session.
async get(sandbox: SandboxRef, session_id: str) -> PtySessionGet an object by ID or identifier.
Args: sandbox: Sandbox ID or object. session_id: PTY session identifier.
Returns: object: Result returned by this operation.
delete
Section titled “delete”async delete(sandbox: SandboxRef, session_id: str, http_timeout: float | None = None) -> NoneKill the shell process and remove the session.
Args: sandbox: Sandbox ID or object. session_id: PTY session identifier. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
resize
Section titled “resize”async resize(sandbox: SandboxRef, session_id: str, *, cols: int, rows: int) -> PtySessionResize a PTY session.
Args: sandbox: Sandbox ID or object. session_id: PTY session identifier. cols: Parameter for this operation. rows: Parameter for this operation.
Returns: object: Result returned by this operation.
websocket_url
Section titled “websocket_url”websocket_url(sandbox: SandboxRef, session_id: str) -> strBuild a websocket URL for this sandbox.
Args: sandbox: Sandbox ID or object. session_id: PTY session identifier.
Returns: object: Result returned by this operation.
connect
Section titled “connect”async connect(sandbox: SandboxRef, session_id: str, open_timeout: float | None = None, http_timeout: float | None = None, **kwargs: Any) -> AsyncPtyConnectionOpen a WebSocket connection for interactive terminal I/O.
Important:
Callers are responsible for closing the returned connection, ideally
with try/finally or an async context manager wrapper.
Args:
sandbox: Sandbox ID or object.
session_id: PTY session identifier.
open_timeout: Optional WebSocket open timeout in seconds.
http_timeout: Deprecated alias for open_timeout.
**kwargs: Additional keyword arguments passed to websockets.asyncio.client.connect.
Returns: AsyncPtyConnection: Open WebSocket-backed PTY connection.