/**
 * Audio end-of-turn detector with `turn-detector-v1` → `turn-detector-v1-mini`
 * (cloud → local) fallback.
 */
import type { InferenceExecutor } from '../../ipc/inference_executor.js';
import { type APIConnectOptions } from '../../types.js';
import { BaseStreamingTurnDetector, type BaseStreamingTurnDetectorOptions, BaseStreamingTurnDetectorStream, type StreamingTurnDetectionTransport } from './base.js';
import { type TurnDetectorModel, type TurnDetectorVersion } from './languages.js';
import { type CloudTransportOptions } from './transports.js';
export interface TurnDetectorOptions {
    /**
     * Which turn-detector version to run. `'v1'` is the full cloud model (served
     * over the inference gateway; model name `'turn-detector-v1'`); `'v1-mini'`
     * is the local in-process model (`'turn-detector-v1-mini'`). When omitted,
     * auto-selects `'v1'` on hosted/dev environments (falling back to `'v1-mini'`
     * if cloud creds are missing) and `'v1-mini'` otherwise.
     */
    version?: TurnDetectorVersion;
    unlikelyThreshold?: number | Record<string, number>;
    /**
     * Backchannel threshold(s): above this, a pause is a backchannel opportunity.
     * Server-driven and cloud-only by default; this is an override seam. A scalar
     * applies to every language; a map is layered over the server defaults.
     */
    backchannelThreshold?: number | Record<string, number>;
    baseUrl?: string;
    apiKey?: string;
    apiSecret?: string;
    /** Sample rate (Hz). Defaults to 16000. */
    sampleRate?: number;
    connOptions?: APIConnectOptions;
    /**
     * Inference executor that runs the local `turn-detector-v1-mini` model in the
     * shared inference process. Defaults to the current job's
     * `getJobContext().inferenceExecutor`. `undefined` (no job context / binding
     * unavailable) degrades the local model to a positive-default prediction.
     * Mainly an override seam for tests.
     */
    executor?: InferenceExecutor;
}
export declare class TurnDetector extends BaseStreamingTurnDetector {
    protected _model: TurnDetectorModel;
    protected _cloudOpts: CloudTransportOptions | undefined;
    protected _executor: InferenceExecutor | undefined;
    constructor(opts?: TurnDetectorOptions);
    /** Current model name. Starts at the construction-time selection and flips to
     * `'turn-detector-v1-mini'` after a cloud→local fallback: the detector and its
     * (single) active stream share one mutable `ThresholdOptions`, and the
     * stream writes the swap back here so EOU metrics and `audio_recognition`
     * see a consistent view. The fallback is one-way and sticky. */
    get model(): TurnDetectorModel;
    /** @internal Written by the active stream on cloud→local fallback. */
    _setModel(model: TurnDetectorModel): void;
    protected _warnThresholdOverride(): void;
    /** Replace the user threshold override at runtime. The shared
     * `ThresholdOptions` re-resolves against the current (server or shipped)
     * defaults, so an active stream picks it up immediately. */
    updateOptions(opts?: {
        unlikelyThreshold?: number | Record<string, number>;
        backchannelThreshold?: number | Record<string, number>;
    }): void;
    stream(opts?: {
        connOptions?: APIConnectOptions;
    }): BaseStreamingTurnDetectorStream;
}
export interface TurnDetectorStreamImplArgs {
    detector: TurnDetector;
    opts: BaseStreamingTurnDetectorOptions;
    cloudOpts: CloudTransportOptions | undefined;
    model: TurnDetectorModel;
    /** Shared inference executor for the `turn-detector-v1-mini` (local) model
     * (undefined degrades to a positive-default prediction). */
    executor?: InferenceExecutor;
    /** Optional transport override (for tests). When omitted, a transport is
     * constructed from `model` + `cloudOpts`. */
    transport?: StreamingTurnDetectionTransport;
}
/**
 * Stream that owns the `turn-detector-v1` → `turn-detector-v1-mini` (cloud →
 * local) fallback FSM. On cloud transport failure (`transport.run()` raises, or
 * `predictEndOfTurn` times out), the stream swaps the transport and rescales
 * per-language thresholds in place on the shared `ThresholdOptions`, then writes
 * the model swap back to the owning detector so its view stays consistent.
 */
export declare class TurnDetectorStreamImpl extends BaseStreamingTurnDetectorStream {
    protected _model: TurnDetectorModel;
    protected _cloudOpts: CloudTransportOptions | undefined;
    protected _executor: InferenceExecutor | undefined;
    protected _isFallback: boolean;
    protected _warnedCloudFailure: boolean;
    protected _warnedLocalFailure: boolean;
    private _detLogger;
    constructor(args: TurnDetectorStreamImplArgs);
    /** This stream's *current* model name (flips to `'turn-detector-v1-mini'`
     * after a cloud→local fallback). The swap is also written back to the owning
     * detector, which shares this stream's mutable `ThresholdOptions`. */
    get model(): TurnDetectorModel;
    get isFallback(): boolean;
    /** @internal Test-visible. */
    get warnedCloudFailure(): boolean;
    /** @internal Test-visible. */
    get warnedLocalFailure(): boolean;
    /** @internal Test-visible. */
    get transport(): StreamingTurnDetectionTransport;
    /** @internal Test-visible: same logic as the path taken when `_run` catches
     * a cloud transport error. Tests call this directly to verify the warning
     * dedupe across multiple invocations on the same stream. */
    _fallBackToLocal(reason: Error): void;
    /** @internal Test-visible: same logic as the path taken when `_run` sees a
     * local transport error. */
    _onLocalFailure(reason: Error): void;
    protected _emitDefaultForInflight(): void;
    aclose(): Promise<void>;
    protected _run(): Promise<void>;
    protected _onPredictTimeout(): void;
}
//# sourceMappingURL=detector.d.ts.map