ConversationOptions object. They’re invoked synchronously on the LiveKit event loop — keep them fast or defer work with queueMicrotask.
ConversationStatus
connecting— the initial state, set the moment theWebRTCConnectionis constructed.connected— afterroom.connect(),createLocalAudioTrack(), andpublishTrack()all succeed.disconnecting—endSession()has been called but the room hasn’t acknowledged yet.disconnected— LiveKit has firedDisconnected, OR an error duringconnect()(connection, mic) short-circuited to this state.
onStatusChange fires only on actual transitions; duplicate transitions are deduped.
ConversationMode
RoomEvent.ActiveSpeakersChanged: speaking when any remote participant is in the active-speakers set, listening otherwise. Useful for UI states like “agent talking now — show the voice animation”.
Deduped on transition — onModeChange won’t fire twice for the same mode.
ConversationMessage
onMessage fires for every inbound data-channel packet the SDK recognises as a message:
| Inbound packet | Becomes |
|---|---|
transcript | { source: packet.source, text, isFinal: packet.isFinal ?? true } |
agent_message | { source: 'agent', text, isFinal: packet.isFinal ?? true } |
user_message_echo | { source: 'user', text, isFinal: true } |
isFinal: false) transcripts may arrive multiple times for the same utterance before a final one. Replace your in-progress transcript state keyed by source; finals are terminal.
See Data channel protocol for the raw wire format.
DisconnectionDetails
DisconnectReason into a smaller, intent-oriented set:
LiveKit DisconnectReason | Mapped reason |
|---|---|
CLIENT_INITIATED | user |
PARTICIPANT_REMOVED / ROOM_DELETED / ROOM_CLOSED | agent |
JOIN_FAILURE | error |
everything else (including undefined) | unknown |
message is the raw LiveKit enum name when available (useful for debugging / logging).
onConnect
connected. conversationId is the LiveKit room name (same value as conversation.getId()).
onError
- Malformed inbound data packets — wrapped in
SpekoClientErrorwith codeINVALID_MESSAGE. RoomEvent.MediaDevicesErrorfrom LiveKit.- Output device selection failures (
setSinkIdrejections).
create() are thrown, not routed to onError. See Errors.