DocsCommontransportAgentTransport
Package: @hexos/common

Abstract transport interface for client-server communication in Hexos.

Defines the contract for connecting to a backend, sending messages, receiving events, and disconnecting. SSETransport is the default implementation using HTTP Server-Sent Events. Future implementations could support WebSockets or other protocols.

Related: SSETransport implements this interface, AgentConfig configures the connection, TransportMessage is the outbound payload, TransportEvent is the inbound event type.

interface AgentTransport {
    connect(config: AgentConfig): Promise<void>;
    send(message: TransportMessage): void;
    onMessage(callback: (event: TransportEvent) => void): () => void;
    disconnect(): void;
}

connect

(config: AgentConfig) => Promise

send

(message: TransportMessage) => void

onMessage

(callback: (event: TransportEvent) => void) => () => void

disconnect

() => void