//
// OpenRocky — Voice-first AI Agent
// https://github.com/openrocky
//
// Developed by everettjf with the assistance of Claude Code and Codex.
// Date: 2026-03-25
// Copyright (c) 2026 everettjf. All rights reserved.
//

import Foundation

enum OpenRockyRealtimeEvent: Sendable {
    case status(String)
    case sessionReady(model: String)
    case microphoneActive(Bool)
    case inputSpeechStarted
    case userTranscriptDelta(String)
    case userTranscriptFinal(String)
    case assistantTranscriptDelta(String)
    case assistantTranscriptFinal(String)
    case assistantAudioChunk(String)
    case assistantAudioDone
    case toolCallRequested(name: String, arguments: String, callID: String)
    /// Server-reported token usage from `response.done`. Strictly more accurate than
    /// the transcript-length estimate the runtime used to compute.
    case usageReported(promptTokens: Int, completionTokens: Int, totalTokens: Int)
    /// The transport closed without a manual stop. Emitted exactly once per drop;
    /// the Bridge uses this to drive reconnect-with-backoff so a transient Wi-Fi
    /// → cell handoff doesn't strand the user with a dead session. `lastError`
    /// is the most recent server-side error message (if any) — the bridge uses
    /// it to bail out of the retry loop for unrecoverable failures like auth /
    /// quota / model-not-found, which retrying can't fix.
    case disconnected(lastError: String?)
    case error(String)
}
