Skip to content

Architecture

The SDK is made of small, composable layers:

┌──────────────── UI (your app) ────────────────┐
│  subscribe to SDK events, render bubbles       │
└──────────────▲────────────────────────────────┘

        Chat SDK (orchestrator)  ← requestId correlation, status mapping,
               │                    prompt/moderation (frontend-controlled)

     AIChatSocket (typed Socket.IO client)


      Socket.IO Backend (your server) ⇄ Tools/Model


     Conversation / Node / Path (graph + telemetry)


          TypingObserver (IME-aware UX)

Key ideas

  • Event-first UI: the SDK emits conversation:update, status:change, ai:token, system:update, typing, error.
  • requestId correlation: when sending, the SDK includes a requestId so tokens/final messages map to the right pair.
  • Status mapping: map server statuses (queued/working/retrying) to a stable UI status set (queued/running/done/error).
  • Graph model: Conversation tracks Nodes (USER or SYSTEM) and Paths (links with process/steps). Perfect for rendering and metrics.

What changed in the socket layer (additive)

  • Arbitrary connect params via ioOptions.query/ioOptions.auth.
  • Optional/no-room join with joinEvent: null or a custom joinPayload.
  • Per-emit meta (AIChatSocketOptions.meta) merged into client→server emits.
  • Dynamic topics & discovery remain as before.

MIT Licensed