agentd through a sandbox relay.
Constants
FlagTerminal
FLAG_TERMINAL, the cross-SDK constant spelling.
FlagSessionStart
FLAG_SESSION_START.
FlagShutdown
FLAG_SHUTDOWN.
Functions
m.ConnectAgentSandbox()
Example
Example
core.ready handshake. Sandbox names are limited to 128 UTF-8 bytes. Use context.WithTimeout to override the default 10s handshake timeout.
Parameters
ctxcontext.ContextBounds the handshake; defaults to a 10s timeout if none is set.
namestringSandbox name, up to 128 UTF-8 bytes.
Returns
Connected client.
error
Typed microsandbox error.
m.ConnectAgentPath()
Example
Example
agentd relay socket by path. Use this when you already have the socket path, for example one returned by AgentSocketPath(). Use context.WithTimeout to override the default 10s handshake timeout.
Parameters
ctxcontext.ContextBounds the handshake; defaults to a 10s timeout if none is set.
pathstringFilesystem path of the relay socket.
Returns
Connected client.
error
Typed microsandbox error.
m.AgentSocketPath()
Example
Example
agentd relay socket path without connecting. Returns the same path ConnectAgentSandbox() would dial internally (preferring the hashed path, falling back to the legacy name-derived path), so you can talk to agentd over a raw byte transport (for example a transparent relay that splices bytes between a WebSocket and the socket) instead of this frame client. The sandbox need not be running; the path is derived from the name and the configured home directory.
Parameters
namestringSandbox name, up to 128 UTF-8 bytes.
Returns
string
Relay socket path.
error
Typed microsandbox error.
AgentClient
Returned by ConnectAgentSandbox() · ConnectAgentPath()
Low-level client for raw agent frames.c.Request()
Example
Example
core.fs.request to its core.fs.response).
Parameters
ctxcontext.ContextCancels the request.
flagsuint8Frame flag byte, e.g.
FlagSessionStart.body[]byteCBOR-encoded protocol message body.
Returns
The single response frame.
error
Typed microsandbox error.
c.Stream()
Example
Example
AgentStream carries the protocol correlation id (read it with ID() and pass it to Send() for follow-up frames), and yields frames one at a time via Next().
Parameters
ctxcontext.ContextCancels opening the stream.
flagsuint8Frame flag byte for the opening frame, e.g.
FlagSessionStart.body[]byteCBOR-encoded protocol message body.
Returns
Open stream of raw frames.
error
Typed microsandbox error.
c.Send()
Example
Example
AgentStream.ID().
Parameters
ctxcontext.ContextCancels the send.
iduint32Correlation id of an open session.
flagsuint8Frame flag byte.
body[]byteCBOR-encoded protocol message body.
Returns
error
Typed microsandbox error.
c.ReadyBytes()
Example
Example
core.ready frame body as CBOR bytes. Captured during connect, so this reads from the cached handshake rather than producing protocol traffic.
Returns
[]byte
CBOR-encoded
core.ready frame body.error
Typed microsandbox error.
c.Close()
Example
Example
Returns
error
Typed microsandbox error.
c.CloseCtx()
Example
Example
Close(), but lets you bound or cancel the teardown.
Parameters
ctxcontext.ContextCancels the close.
Returns
error
Typed microsandbox error.
AgentStream
Returned by Stream()
An open raw agent streaming session. Drive it by callingNext() until it returns nil, which happens after a frame carrying FlagTerminal or when the underlying stream is exhausted.
s.Next()
Example
Example
nil, nil at EOF, so loop until the frame is nil or carries FlagTerminal.
Parameters
ctxcontext.ContextCancels waiting for the next frame.
Returns
Next frame, or
nil at EOF.error
Typed microsandbox error.
s.ID()
Example
Example
AgentClient.Send() for follow-up frames in the session.
Returns
uint32
Correlation id for this session.
s.Close()
Example
Example
Parameters
ctxcontext.ContextCancels the close.
Returns
error
Typed microsandbox error.
Types
RawFrame
Returned by Request() · yielded by Next()
A raw protocol frame.Body is the CBOR-encoded Message body (v, t, p) as it appeared on the wire; decode it with a CBOR library such as fxamacker/cbor.