Alias for disconnect for use with using.
Cancel the current agent turn and discard in-flight TTS audio.
Open a WebSocket connection to the server and begin audio capture,
without touching the started/running flags — the low-level half of
start(). Most UIs call start() (first activation) or toggle()
(mute-style connect/disconnect) instead.
Optionaloptions: { signal?: AbortSignal }
Optional. signal is an AbortSignal that, when aborted, disconnects the session.
Close the WebSocket and release all audio resources.
End the call: close the connection, clear the conversation, and return
to the not-started state (started flips back to false, so a
start-screen UI shows its Start control again). Unlike reset() —
which keeps the call live and only clears the conversation — the next
start() mints a brand-new session: a new session id, fresh
per-session tool state, greeting included.
Return the current immutable state snapshot.
Reset the session: clear state as resetState() does, then drop and
reopen the connection for a fresh conversation.
Clear messages, transcripts, and error state while keeping the current
connection (unlike reset(), which also reconnects).
Start the session for the first time: sets started and running, then
connects. Use this for the initial "start conversation" action;
afterwards toggle() is the pause/resume control.
Subscribe to state changes. Returns an unsubscribe function.
Toggle between connected and disconnected states (after start()).
A framework-agnostic voice session that manages WebSocket communication, audio capture/playback, and agent state transitions.
Uses a subscribe/getSnapshot pattern (compatible with React's
useSyncExternalStore). ImplementsDisposablefor resource cleanup.