AAI SDK
    Preparing search index...

    Type Alias SessionCore

    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). Implements Disposable for resource cleanup.

    type SessionCore = {
        "[dispose]"(): void;
        cancel(): void;
        connect(options?: { signal?: AbortSignal }): void;
        disconnect(): void;
        end(): void;
        getSnapshot(): SessionSnapshot;
        reset(): void;
        resetState(): void;
        start(): void;
        subscribe(callback: () => void): () => void;
        toggle(): void;
    }
    Index
    • Alias for disconnect for use with using.

      Returns void

    • Cancel the current agent turn and discard in-flight TTS audio.

      Returns void

    • 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.

      Parameters

      • Optionaloptions: { signal?: AbortSignal }

        Optional. signal is an AbortSignal that, when aborted, disconnects the session.

      Returns void

    • Close the WebSocket and release all audio resources.

      Returns void

    • 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.

      Returns void

    • Return the current immutable state snapshot.

      Returns SessionSnapshot

    • Reset the session: clear state as resetState() does, then drop and reopen the connection for a fresh conversation.

      Returns void

    • Clear messages, transcripts, and error state while keeping the current connection (unlike reset(), which also reconnects).

      Returns void

    • 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.

      Returns void

    • Subscribe to state changes. Returns an unsubscribe function.

      Parameters

      • callback: () => void

      Returns () => void

    • Toggle between connected and disconnected states (after start()).

      Returns void