Skip to content

AIDK API Reference / aidk-client / TransportState

Type Alias: TransportState ​

ts
type TransportState = "disconnected" | "connecting" | "connected" | "reconnecting" | "offline";

Defined in: packages/client/src/core/transport.ts:30

ChannelTransport - Abstract bidirectional transport interface

All transports appear bidirectional from the caller's perspective. The transport encapsulates HOW it sends/receives:

  • SSE: receives via EventSource, sends via HTTP POST
  • WebSocket: sends and receives on same connection
  • Polling: receives via polling, sends via HTTP POST

Example ​

typescript
// SSE transport (internally uses HTTP for send)
const transport = new SSETransport({
  buildUrl: () => '/events/sse',
  sendUrl: '/events',
});

// WebSocket transport (uses WS for both)
const transport = new WebSocketTransport({
  url: 'wss://api.example.com/ws',
});

// Both used the same way
transport.connect();
transport.onMessage((data) => console.log(data));
await transport.send({ channel: 'foo', type: 'bar', payload: {} });

Released under the MIT License.