// Agent configuration types
export type AgentConfig = {
  agentId: string
  apiKey: string
  tools?: {
    [toolName: string]: (args: any) => Promise<unknown> | unknown
  }
  conversationConfig?: {
    agentConfig?: object
    ttsConfig?: object
    customLlmExtraBody?: { temperature?: number; max_tokens?: number; [key: string]: unknown }
    dynamicVariables?: Record<string, string | number | boolean>
  }
}

// Event types emitted by the Agent
export type AgentEvent =
  // Connection lifecycle
  | {
      type: "connected"
      conversationId: string
      audioFormat: {
        agent_output_audio_format?: string
        user_input_audio_format?: string
      }
    }
  | { type: "disconnected" }
  | { type: "error"; error: Error }
  // Conversation events
  | { type: "user_transcript"; transcript: string }
  | { type: "agent_response"; response: string }
  | { type: "agent_response_correction"; original: string; corrected: string }
  | { type: "tentative_agent_response"; response: string }
  | { type: "audio"; audioBase64: string; eventId: number }
  | { type: "interruption"; eventId: number }
  // Tool events
  | { type: "tool_call"; name: string; args: Record<string, unknown>; callId: string }
  | { type: "tool_result"; name: string; result: unknown; callId: string }
  | { type: "tool_error"; name: string; error: Error; callId: string }
  // Optional events
  | { type: "vad_score"; score: number }
  | { type: "ping"; eventId: number; pingMs: number }
