Skip to main content
Low-level raw CBOR transport for communicating with agentd through a sandbox relay.

Constants

AgentClient

AgentClient.connect_sandbox()

Connect to a running sandbox by name. Sandbox names are limited to 128 UTF-8 bytes.

Parameters

namestr
Sandbox name, up to 128 UTF-8 bytes.
timeoutfloat | None
Connection timeout in seconds. None uses the default.

Returns

AgentClient
Connected client.

AgentClient.connect()

Connect to an agent relay socket by path. Use this when you already know the socket path, for example one returned by socket_path().

Parameters

pathstr
Path to the agentd relay socket.
timeoutfloat | None
Connection timeout in seconds. None uses the default.

Returns

AgentClient
Connected client.

AgentClient.socket_path()

Resolve a sandbox’s agentd relay socket path without connecting. Returns the same path connect_sandbox() would dial, so you can talk to agentd over a raw byte transport (for example a transparent relay that splices bytes to and from the socket) instead of this frame client. The sandbox need not be running. Sandbox names are limited to 128 UTF-8 bytes.

Parameters

namestr
Sandbox name, up to 128 UTF-8 bytes.

Returns

str
Filesystem path to the relay socket.

Instance methods

client.request()

Send one raw frame and wait for one response frame.

Parameters

flagsint
Frame flag byte, e.g. a combination of FLAG_* constants.
bodybytes
CBOR-encoded protocol message body.

Returns

The response frame.

client.stream()

Open a raw streaming session. The returned AgentStream carries the protocol correlation id and is also an async iterator of raw frames.

Parameters

flagsint
Frame flag byte; pass FLAG_SESSION_START to open a session.
bodybytes
CBOR-encoded protocol message body.

Returns

Open streaming session.

client.send()

Send a follow-up frame on an existing correlation id. Use the id from the AgentStream returned by stream().

Parameters

idint
Correlation id of an open session, from stream.id.
flagsint
Frame flag byte.
bodybytes
CBOR-encoded protocol message body.

client.ready_bytes()

Return the cached handshake core.ready frame body as CBOR bytes.

Returns

bytes
CBOR-encoded core.ready frame body.

client.close()

Close the client. Calling it more than once is safe.

AgentStream

Returned by stream()

An async iterator of raw agent frames.

stream.id

int Protocol correlation id; pass to send() for follow-up frames

stream.next()

Read the next frame; returns None at EOF

Returns

Awaitable[RawFrame \| None]

stream.close()

Release the stream handle early; safe to call more than once

Returns

Awaitable[None]

Types

RawFrame

Returned by request() · yielded by AgentStream

A raw protocol frame with a CBOR-encoded body.