import type { InterruptionDetectionError } from '../inference/interruption/errors.js';
import type { OverlappingSpeechEvent } from '../inference/interruption/types.js';
import type { LanguageCode } from '../language.js';
import type { AgentHandoffItem, ChatMessage, FunctionCall, FunctionCallOutput, LLM, RealtimeModel, RealtimeModelError } from '../llm/index.js';
import type { LLMError } from '../llm/llm.js';
import type { AgentMetrics } from '../metrics/base.js';
import type { STT } from '../stt/index.js';
import type { STTError } from '../stt/stt.js';
import type { TTS } from '../tts/index.js';
import type { TTSError } from '../tts/tts.js';
import type { AgentSessionUsage } from './agent_session.js';
import type { SpeechHandle } from './speech_handle.js';
export declare enum AgentSessionEventTypes {
    UserInputTranscribed = "user_input_transcribed",
    UserTranscriptionTimeout = "user_transcription_timeout",
    AgentStateChanged = "agent_state_changed",
    UserStateChanged = "user_state_changed",
    ConversationItemAdded = "conversation_item_added",
    FunctionToolsExecuted = "function_tools_executed",
    MetricsCollected = "metrics_collected",
    SessionUsageUpdated = "session_usage_updated",
    DebugMessage = "debug_message",
    SpeechCreated = "speech_created",
    AgentFalseInterruption = "agent_false_interruption",
    OverlappingSpeech = "overlapping_speech",
    /** Audio EOT detector emitted a per-turn prediction. */
    EotPrediction = "eot_prediction",
    Error = "error",
    /** Emitted after activity teardown, when the session is no longer running. */
    Close = "close"
}
export type UserState = 'speaking' | 'listening' | 'away';
export type AgentState = 'initializing' | 'idle' | 'listening' | 'thinking' | 'speaking';
export declare enum CloseReason {
    ERROR = "error",
    JOB_SHUTDOWN = "job_shutdown",
    PARTICIPANT_DISCONNECTED = "participant_disconnected",
    USER_INITIATED = "user_initiated"
}
export type ShutdownReason = CloseReason | string;
export type SpeechSource = 'say' | 'generate_reply' | 'tool_response';
export type UserStateChangedEvent = {
    type: 'user_state_changed';
    oldState: UserState;
    newState: UserState;
    createdAt: number;
};
export declare const createUserStateChangedEvent: (oldState: UserState, newState: UserState, createdAt?: number) => UserStateChangedEvent;
export type AgentStateChangedEvent = {
    type: 'agent_state_changed';
    oldState: AgentState;
    newState: AgentState;
    createdAt: number;
};
export declare const createAgentStateChangedEvent: (oldState: AgentState, newState: AgentState, createdAt?: number) => AgentStateChangedEvent;
export type UserInputTranscribedEvent = {
    type: 'user_input_transcribed';
    transcript: string;
    isFinal: boolean;
    /** Provider-specific ID for the transcribed input item, when available. */
    itemId: string | null;
    /** Not supported yet. Always null by default. */
    speakerId: string | null;
    createdAt: number;
    language: LanguageCode | null;
};
export declare const createUserInputTranscribedEvent: ({ transcript, isFinal, itemId, speakerId, language, createdAt, }: {
    transcript: string;
    isFinal: boolean;
    itemId?: string | null;
    speakerId?: string | null;
    language?: LanguageCode | null;
    createdAt?: number;
}) => UserInputTranscribedEvent;
export type UserTranscriptionTimeoutEvent = {
    type: 'user_transcription_timeout';
    /** Total VAD-detected speech in the turn that produced no transcript, in milliseconds. */
    speechDuration: number;
    /** When VAD first detected speech for this untranscribed turn, in milliseconds since epoch. */
    vadSpeechStartedAt: number;
    createdAt: number;
};
export declare const createUserTranscriptionTimeoutEvent: ({ speechDuration, vadSpeechStartedAt, createdAt, }: {
    speechDuration: number;
    vadSpeechStartedAt: number;
    createdAt?: number;
}) => UserTranscriptionTimeoutEvent;
export type MetricsCollectedEvent = {
    type: 'metrics_collected';
    metrics: AgentMetrics;
    createdAt: number;
};
export declare const createMetricsCollectedEvent: ({ metrics, createdAt, }: {
    metrics: AgentMetrics;
    createdAt?: number;
}) => MetricsCollectedEvent;
export type SessionUsageUpdatedEvent = {
    type: 'session_usage_updated';
    usage: AgentSessionUsage;
    createdAt: number;
};
export declare const createSessionUsageUpdatedEvent: ({ usage, createdAt, }: {
    usage: AgentSessionUsage;
    createdAt?: number;
}) => SessionUsageUpdatedEvent;
export type ConversationItemAddedEvent = {
    type: 'conversation_item_added';
    item: ChatMessage | AgentHandoffItem;
    createdAt: number;
};
export declare const createConversationItemAddedEvent: (item: ChatMessage | AgentHandoffItem, createdAt?: number) => ConversationItemAddedEvent;
export type FunctionToolsExecutedEvent = {
    type: 'function_tools_executed';
    /**
     * Function calls and outputs are parallel arrays: the output at a given index
     * belongs to the call at the same index, and its `callId` matches the paired
     * function call's `callId`.
     */
    functionCalls: FunctionCall[];
    functionCallOutputs: FunctionCallOutput[];
    createdAt: number;
};
export declare const createFunctionToolsExecutedEvent: ({ functionCalls, functionCallOutputs, createdAt, }: {
    functionCalls: FunctionCall[];
    functionCallOutputs: FunctionCallOutput[];
    createdAt?: number;
}) => FunctionToolsExecutedEvent;
export declare const zipFunctionCallsAndOutputs: (event: FunctionToolsExecutedEvent) => Array<[FunctionCall, FunctionCallOutput]>;
export type SpeechCreatedEvent = {
    type: 'speech_created';
    /**
     * True if the speech was created using public methods like `say` or `generate_reply`
     */
    userInitiated: boolean;
    /**
     * Source indicating how the speech handle was created
     */
    source: SpeechSource;
    /**
     * The speech handle that was created
     */
    speechHandle: SpeechHandle;
    /**
     * The timestamp when the speech handle was created
     */
    createdAt: number;
};
export declare const createSpeechCreatedEvent: ({ userInitiated, source, speechHandle, createdAt, }: {
    userInitiated: boolean;
    source: SpeechSource;
    speechHandle: SpeechHandle;
    createdAt?: number;
}) => SpeechCreatedEvent;
/**
 * Audio EOT prediction landed on the wire. Emitted once per turn boundary
 * decision when a `TurnDetector` is wired into the session.
 */
export type EotPredictionEvent = {
    type: 'eot_prediction';
    /** End-of-turn probability in [0, 1] returned by the detector. */
    probability: number;
    /** Threshold below which the detector treats the prediction as unlikely. */
    threshold: number;
    /** Model-side inference time, in milliseconds. */
    inferenceDurationMs: number;
    /** End-of-speech → prediction receive time, in milliseconds. */
    delayMs: number;
    createdAt: number;
};
export declare const createEotPredictionEvent: ({ probability, threshold, inferenceDurationMs, delayMs, createdAt, }: {
    probability: number;
    threshold: number;
    inferenceDurationMs: number;
    delayMs: number;
    createdAt?: number;
}) => EotPredictionEvent;
/**
 * Internal: a window in which the agent could backchannel (a short acknowledgment
 * such as "mm-hmm"), as predicted by the turn detector. Passed to `AgentActivity`
 * only — not surfaced as a public `AgentSession` event (absent from `AgentEvent`,
 * `AgentSessionEventTypes`, and the package exports).
 *
 * `AgentActivity` owns the decision of what to do with it. The end-of-turn margin
 * (`endOfTurnThreshold - endOfTurnProbability`) gives a progressive risk axis: a
 * large positive margin means the user is clearly still going, so riskier
 * backchannels (yeah/okay/right) are safe; a small margin (or a negative one,
 * where `endOfTurnProbability >= endOfTurnThreshold` and a reply is imminent)
 * calls for safe, less ambiguous ones (hmm/uh-huh) that won't collide with the reply.
 *
 * @internal
 */
export type _AgentBackchannelOpportunityEvent = {
    type: 'agent_backchannel_opportunity';
    probability: number;
    threshold: number;
    endOfTurnProbability: number;
    endOfTurnThreshold: number;
    language?: string;
    createdAt: number;
};
/** @internal */
export declare const _createAgentBackchannelOpportunityEvent: ({ probability, threshold, endOfTurnProbability, endOfTurnThreshold, language, createdAt, }: {
    probability: number;
    threshold: number;
    endOfTurnProbability: number;
    endOfTurnThreshold: number;
    language?: string;
    createdAt?: number;
}) => _AgentBackchannelOpportunityEvent;
export type UserTurnExceededEvent = {
    type: 'user_turn_exceeded';
    /** Transcript from the current uncommitted user turn only. */
    transcript: string;
    /** Full transcript since the start of user speaking in the accumulation window. */
    accumulatedTranscript: string;
    /** Total word count since the start of user speaking in the accumulation window. */
    accumulatedWordCount: number;
    /** Duration of the user turn accumulation window in milliseconds. */
    duration: number;
    createdAt: number;
};
export declare const createUserTurnExceededEvent: ({ transcript, accumulatedTranscript, accumulatedWordCount, duration, createdAt, }: {
    transcript: string;
    accumulatedTranscript: string;
    accumulatedWordCount: number;
    duration: number;
    createdAt?: number;
}) => UserTurnExceededEvent;
export type ErrorEvent = {
    type: 'error';
    error: RealtimeModelError | STTError | TTSError | LLMError | InterruptionDetectionError;
    source?: LLM | STT | TTS | RealtimeModel;
    createdAt: number;
};
export declare const createErrorEvent: (error: RealtimeModelError | STTError | TTSError | LLMError | InterruptionDetectionError, source?: LLM | STT | TTS | RealtimeModel, createdAt?: number) => ErrorEvent;
export type CloseEvent = {
    type: 'close';
    error: RealtimeModelError | STTError | TTSError | LLMError | InterruptionDetectionError | null;
    reason: ShutdownReason;
    createdAt: number;
};
export declare const createCloseEvent: (reason: ShutdownReason, error?: RealtimeModelError | STTError | TTSError | LLMError | InterruptionDetectionError | null, createdAt?: number) => CloseEvent;
export type AgentFalseInterruptionEvent = {
    type: 'agent_false_interruption';
    /** Whether the false interruption was resumed automatically. */
    resumed: boolean;
    createdAt: number;
};
export declare const createAgentFalseInterruptionEvent: ({ resumed, createdAt, }: {
    resumed: boolean;
    createdAt?: number;
}) => AgentFalseInterruptionEvent;
export type AgentEvent = UserInputTranscribedEvent | UserTranscriptionTimeoutEvent | UserStateChangedEvent | AgentStateChangedEvent | MetricsCollectedEvent | SessionUsageUpdatedEvent | ConversationItemAddedEvent | FunctionToolsExecutedEvent | SpeechCreatedEvent | AgentFalseInterruptionEvent | OverlappingSpeechEvent | ErrorEvent | CloseEvent;
//# sourceMappingURL=events.d.ts.map