/**
 * Raised by {@link Conversation.connect} when the caller already holds another
 * active conversation session. The application must end that session before a
 * new one can be created — retrying immediately will fail the same way.
 */
export declare class ActiveSessionError extends Error {
    constructor();
}

/**
 * An error answer from the Nuance API that the SDK has no more specific error
 * for, such as a `401` for an expired or used session token, a `429` when today's
 * credits are spent, or a `503` once the SDK has stopped
 * retrying a busy service. See the Errors guide for each status and `code`.
 *
 * Act on `status` and `code`, never on `message`: the message is the server's
 * `detail`, written for you, and it can change.
 *
 * @example
 * ```ts
 * try {
 *   await conversation.connect();
 * } catch (error) {
 *   if (error instanceof ApiError && error.status === 401) {
 *     // The session token expired or was used: the next connect() fetches a new one.
 *   }
 * }
 * ```
 */
export declare class ApiError extends Error {
    /** The HTTP status, such as `401` or `503`. */
    readonly status: number;
    /** The error's `code` when the server sent one, such as `"busy"` or `"unavailable"`. */
    readonly code: string | null;
    /** How long to wait before trying again, when the server said. */
    readonly retryAfterSeconds: number | null;
    /**
     * When the allowance the refusal is about renews (UTC, ISO 8601), when the
     * server said, such as today's credits for a `429`.
     */
    readonly renewsAt: string | null;
    /** The parsed JSON body of the answer, or `null` when it had none. */
    readonly body: unknown;
    constructor(status: number, detail: string, body?: unknown);
}

/** What an append adds: see {@link Conversation.append}. */
export declare type AppendKind = "thinking" | "instructions" | "commentary";

/** How an append treats a reply the persona has already started. */
export declare interface AppendOptions {
    /**
     * `"finish"`, the default, lets the persona finish the reply as drafted;
     * `"revise"` cuts it and has the persona carry on with the line.
     */
    whileSpeaking?: "finish" | "revise";
}

/**
 * An audio track that can be attached to or detached from an audio element.
 */
export declare interface AudioTrack {
    /** Attaches the audio track to an HTML audio element. */
    attach(element: HTMLAudioElement): void;
    /** Detaches the track from its currently attached element, if any. */
    detach(): void;
    /** Whether the audio track is currently enabled. */
    readonly isEnabled: boolean;
    /** The underlying media track, when the provider exposes one — feeds
     *  local visualizations (e.g. an analyser-driven waveform). */
    readonly mediaStreamTrack?: MediaStreamTrack | null;
}

/**
 * The AI persona in a conversation: the remote participant.
 */
export declare interface AvatarParticipant {
    /** The persona's video, when available. */
    readonly videoTrack: VideoTrack | null;
    /** The persona's audio, when available. */
    readonly audioTrack: AudioTrack | null;
    /** Mutes the persona's audio playback locally. */
    muteAudio(): Promise<void>;
    /** Unmutes the persona's audio playback locally. */
    unmuteAudio(): Promise<void>;
    /** Whether the persona's audio playback is muted locally. */
    readonly isMuted: boolean;
    /** Whether the persona's video is currently enabled. */
    readonly isVideoEnabled: boolean;
    /**
     * Whether the persona is ready to be shown — its first audiovisual output has
     * reached the client. Audio playback is gated on this automatically (kept muted
     * while attached so buffers warm, then unmuted on ready), so consumers only need
     * this to gate visual presentation, e.g. revealing the video once in sync.
     */
    readonly isReady: boolean;
}

/**
 * What a throwaway connection did in this browser while the conversation was
 * created: whether it made an offer, and how many ICE candidates it found with
 * no server. A browser that can call finds candidates at once; one whose WebRTC
 * a setting or an extension limits finds none. A hint, not a verdict: some
 * such browsers still connect through the media service's relay.
 */
export declare interface BrowserCheck {
    /** Milliseconds to the offer, or null when there was none in time. */
    offerMs: number | null;
    /** ICE candidates found, or null when the check did not get that far. */
    iceCandidates: number | null;
    /** The ICE gathering state when the check stopped, or null when it did not
     * get that far. `"new"` with no candidates: gathering never started. */
    iceGathering: string | null;
}

/** The direction a camera faces relative to the user. */
export declare type CameraFacing = "user" | "environment";


/**
 * A live conversation with an AI persona, controlled by the SDK.
 *
 * A conversation owns the connection lifecycle and exposes the local user and
 * remote persona participants after it is connected.
 */
export declare interface Conversation {
    /**
     * Subscribes to calls of your tools in a `responses` delegation. Each call
     * arrives once, as soon as the backend makes it; answer every call with
     * {@link Conversation.sendToolResult}. A call waits for its result for as
     * long as the session lasts, and the persona keeps talking meanwhile.
     *
     * @example
     * ```ts
     * conversation.onToolCall(async (call) => {
     *   if (call.name === "get_weather") {
     *     const weather = await lookUpWeather(call.arguments?.city);
     *     await conversation.sendToolResult(call.callId, weather);
     *   }
     * });
     * ```
     *
     * @returns A function that removes the handler.
     */
    onToolCall(handler: (call: ToolCall) => void): () => void;
    /**
     * Answers a tool call. The backend takes a step's results together: they
     * are sent once the step is complete and each of its calls has a result,
     * and then the task goes on. A step the session withdraws or that fails
     * drops the results it had. Pass `{ reply: false }` for a result the
     * persona should not reply to ({@link ToolResultOptions.reply}).
     *
     * @throws If no call with that id is waiting, or it already has a result.
     */
    sendToolResult(callId: string, output: ToolOutput, options?: ToolResultOptions): Promise<void>;
    /**
     * Replaces the tools the backend may call, from its next step on: pass
     * every tool that can run now, each as you listed it in the session token.
     * The persona is told what the backend can do now.
     *
     * @throws If the conversation is not connected.
     */
    setTools(tools: NuanceLiveTool[]): Promise<void>;
    /**
     * Adds a line of up to 2,000 characters to the conversation, without
     * asking the persona to speak:
     *
     * - `"thinking"`: quiet context, such as what just happened in your app.
     *   While the persona and the user are both quiet, the persona may speak on
     *   the line or let it pass; to have it answer, send `response.create` after.
     * - `"instructions"`: an instruction the persona acts on in a turn of its own.
     * - `"commentary"`: something to tell the user in the persona's own words.
     *
     * An empty `"thinking"` line turns off the persona's wait line for the tasks under way.
     *
     * @throws If the conversation is not connected.
     */
    append(kind: AppendKind, content: string, options?: AppendOptions): Promise<void>;
    /**
     * Starts the conversation.
     *
     * This creates or joins the underlying session and requests local camera and
     * microphone access when required. A session the server ends while it
     * joins is left at once: `connect()` then resolves after `session-ended`,
     * with the state `"disconnected"`.
     */
    connect(): Promise<void>;
    /**
     * Ends the conversation and releases local connection resources.
     */
    disconnect(): Promise<void>;
    /**
     * Current lifecycle state for the conversation.
     */
    readonly state: ConversationStateValue;
    /**
     * Server-assigned conversation id, available once connected. Remains readable
     * after disconnect so callers can reference the session. Null before the
     * conversation has been created.
     */
    readonly id: string | null;
    /**
     * How the last {@link Conversation.connect} went: how far it got, and what
     * the browser check found. Read it when `connect()` rejects, to report where
     * a start failed. Null before the first `connect()`.
     */
    readonly lastJoin: JoinReport | null;
    /**
     * Local user participant.
     *
     * @throws If accessed before the conversation is connected.
     */
    readonly user: UserParticipant;
    /**
     * The AI persona, the remote participant.
     *
     * @throws If accessed before the conversation is connected.
     */
    readonly avatar: AvatarParticipant;
    /**
     * The interface the session runs on, whose events
     * {@link Conversation.onInterfaceEvent} and
     * {@link Conversation.sendInterfaceEvent} carry: `"nuance_live"`.
     */
    readonly interface: string;
    /**
     * Subscribes to conversation lifecycle and media events.
     *
     * @returns A function that removes the event handler.
     */
    onChange(handler: (event: ConversationEvent) => void): () => void;
    /**
     * Subscribes to the session's Nuance Live events: each JSON object the
     * runtime sends on the interface's topic, parsed, in the order it was sent.
     * What the user and the persona say, its turns, its tool calls through a
     * delegation and the session's end all arrive here. An event too large for one packet arrives as `message.part`
     * packets; the handler gets the event they carry, in its place, and never
     * the parts. Subscribe before `connect()` to see the session's first
     * events; a handler stays subscribed when the conversation connects again.
     * Events sent while the connection was down are not delivered again.
     *
     * @example
     * ```ts
     * conversation.onInterfaceEvent((event) => {
     *   if (event.type === "session.output_transcript.delta") {
     *     transcript.textContent += String(event.delta);
     *   }
     * });
     * ```
     *
     * @returns A function that removes the handler.
     */
    onInterfaceEvent(handler: (event: Record<string, unknown>) => void): () => void;
    /**
     * Sends one Nuance Live event, such as `response.create` or
     * `response.item.create`, as JSON on the interface's topic: one reliable packet, or, for an event over 64,000 bytes as JSON
     * (UTF-8), one text stream. A `response.create` sent after a streamed event
     * waits for the runtime to read it.
     *
     * @throws If the conversation is not connected.
     */
    sendInterfaceEvent(event: Record<string, unknown>): Promise<void>;
}


/**
 * Events emitted by {@link Conversation.onChange}.
 */
export declare type ConversationEvent = 
/** The conversation lifecycle state changed. */
    {
    type: "state-changed";
    state: ConversationStateValue;
}
/**
* The server created the session and assigned {@link Conversation.id}.
* Fires before any wait for a slot, so a host can key UI on the id
* (a page for the conversation) while the connection is still underway.
*/
| {
    type: "session-created";
    id: string;
}
/**
* A runtime is held for an API conversation and is getting ready for it,
* which can take up to about half a minute; the conversation then connects.
* Fires once, while `connecting`. An API conversation never queues, so this
* is all it is told before it connects.
*/
| {
    type: "avatar-preparing";
}
/** The avatar participant joined the conversation. */
| {
    type: "avatar-connected";
}
/** The avatar participant left the conversation. */
| {
    type: "avatar-disconnected";
}
/**
* The avatar is ready to be shown ({@link AvatarParticipant.isReady}). Gate
* presentation of the avatar's video/audio on this so it is revealed in view
* and in sync.
*/
| {
    type: "avatar-ready";
}
/**
* The avatar is presented, and the session's recording starts. She can
* speak once your page sends `response.create` (see `startOn`). Follows
* `avatar-ready`, at once by default. With `startOn: "full-quality"` it
* waits until her video has reached its full size and held it, or the wait
* ran out; in between she is in view but not yet presented.
*/
| {
    type: "avatar-presented";
}
/** User or avatar media tracks changed. */
| {
    type: "tracks-changed";
}
/** The active microphone changed; read {@link UserParticipant.microphoneId}. */
| {
    type: "microphone-changed";
}
/** The active camera changed; read {@link UserParticipant.cameraId}. */
| {
    type: "camera-changed";
}
/** Speaking activity changed for the user or avatar. */
| {
    type: "speaking-changed";
    participant: "user" | "avatar";
    isSpeaking: boolean;
}
/**
* The user's microphone is on in the app but nothing from it reaches the
* call: the browser sends no audio, or the system stopped or muted the
* capture. Never reported while the user has muted it in the app. Fires
* on each change, and clears when the conversation stops sampling.
*/
| {
    type: "mic-silent-changed";
    silent: boolean;
}
/** The connection's {@link NetworkQuality} changed. Starts `"good"`. */
| {
    type: "network-changed";
    quality: NetworkQuality;
}
/**
* The call has not connected 10 s after this connect's turn came, longer than
* nearly every start takes. Fires at most once per connect, while
* `connecting`. A page can tell the person it is still trying, and that a
* network or a browser setting (a VPN, a privacy extension) can block calls.
* A join still not connected after a minute ends with `connect()` rejecting
* with a `JoinTimeoutError`.
*/
| {
    type: "join-slow";
}
/**
* The runtime found this client's link to the avatar poor for a sustained
* span; sent at most once per session, and only by a runtime that offers it.
* A caller can offer the user to end the call.
*/
| {
    type: "link-poor";
}
/**
* The round trip between this client and the runtime serving it, as the
* runtime measured it at the session's start. It grows with the distance
* to the runtime, which the client's own link statistics do not see when
* the media server it reaches is nearby. Sent once per session, and only
* by a runtime that offers it.
*/
| {
    type: "round-trip";
    rttMs: number;
}
/**
* How long the live session has left, when it is capped.
*
* Emitted when the time left is learned or corrected, so it steps rather
* than ticks; a caller showing a countdown should count down from the latest.
*/
| {
    type: "time-remaining";
    secondsRemaining: number;
}
/**
* The server considers the session over.
*
* A runtime that stops at its limit does not necessarily leave the transport,
* so a caller cannot infer this from the connection alone. `reason` is
* `"time-limit"` when the session was capped and ran out its clock,
* `"policy-violation"` when a safety check ended it for a policy
* violation, `"age-check"` when it ended because the camera showed only
* people who look under 18 (each with `message`, the same words for every
* end of its kind, for you to show the person), `"refused"`
* when the runtime would not start it, with its reason in `message` when it
* gave one, or when the server refused to create it.
*
* On any end the server makes (its goodbye, the time limit, a policy end,
* an age check), the SDK then leaves the call and stops the camera and
* microphone: the state becomes `"disconnected"`, and `user` and `avatar`
* throw from then on. An end that arrives while the conversation joins
* stops the join and releases any camera or microphone it opened, so
* `connect()` can resolve with the state already `"disconnected"`. With
* {@link CreateNuanceConversationOptions.stayConnectedOnEnd} it stays in
* the call until you call {@link Conversation.disconnect}.
*
* `endReason` is the runtime's own word for the end ({@link EndReason}),
* and says who ended the session where `reason` cannot: an agent that hung
* up reads `"end_call"`, a runtime that failed the session `"error"`. It is
* absent only when the end reached the SDK without one. `reason` keeps the
* values it has always had, so code reading it needs no change.
*/
| {
    type: "session-ended";
    reason: SessionEndReason;
    endReason?: EndReason;
    message?: string;
    /**
     * Why the server refused to create the conversation, when it did: the
     * error `connect()` rejects with, such as an `ApiError` with the
     * answer's `status`, `code` and `renewsAt`. It comes before the state
     * becomes `"disconnected"`.
     */
    error?: Error;
}
/**
* The session's place in the queue moved, or its estimate changed.
*
* Emitted only while waiting. `estimatedWaitSeconds` never increases for a
* given session: a wait that grows reads as the service failing, and arriving
* early is forgiven. Null when there is no serving capacity to estimate from.
* `preparing` is true once the session is next and an avatar is held for it
* while it gets ready; the session connects when it is.
*/
| {
    type: "queue-changed";
    position: number;
    estimatedWaitSeconds: number | null;
    poolSlots: number | null;
    preparing: boolean;
};

/**
 * Lifecycle states emitted by a conversation.
 */
export declare enum ConversationState {
    /** The conversation has been created locally but has not started connecting. */
    Idle = "idle",
    /** Waiting to start, with nothing wrong: the service is busy and the SDK
     * tries again on its own, or the session has a place in line and starts when
     * a slot frees. Distinct from Connecting: there is nothing for the app to
     * retry. */
    Queued = "queued",
    /** The SDK is creating or joining the underlying session. */
    Connecting = "connecting",
    /** The conversation is connected and media can flow. */
    Connected = "connected",
    /** The conversation was disconnected intentionally or by the remote service. */
    Disconnected = "disconnected",
    /** The conversation failed to connect or encountered a terminal error. */
    Failed = "failed"
}

/**
 * String value form of {@link ConversationState}.
 */
export declare type ConversationStateValue = `${ConversationState}`;

/**
 * Creates a conversation with a Nuance AI persona.
 *
 * The returned conversation is idle until {@link Conversation.connect} is
 * called. The SDK creates the backend conversation session, waits until it is
 * ready, and connects using the connection details returned by the Nuance API.
 * An option it does not know is ignored, with a warning in the console that
 * names it.
 *
 * @example
 * ```ts
 * import { createNuanceConversation } from "@nuancelabs/js-sdk";
 *
 * const conversation = createNuanceConversation({
 *   // Your server mints a session token with its API key.
 *   token: async () => {
 *     const response = await fetch("/api/nuance-token", { method: "POST" });
 *     if (!response.ok) throw new Error(await response.text());
 *     return (await response.json()).token;
 *   },
 * });
 *
 * conversation.onChange((event) => {
 *   if (event.type === "tracks-changed") {
 *     conversation.avatar.videoTrack?.attach(videoElement);
 *   }
 * });
 *
 * await conversation.connect();
 * ```
 */
export declare function createNuanceConversation(options?: CreateNuanceConversationOptions): Conversation;

/**
 * Options for creating a Nuance conversation.
 */
export declare interface CreateNuanceConversationOptions {
    /**
     * Fetches a session token, for authenticating from a web page.
     *
     * Your server mints the token with its API key (`POST /session-tokens`) and
     * returns it to the page. The SDK asks for a fresh one each time it starts a
     * conversation, since a token creates one conversation and then reaches only
     * that conversation. The conversation's settings are fixed when your
     * server mints the token.
     *
     * @example
     * ```ts
     * token: async () => {
     *   const response = await fetch("/api/nuance-token", { method: "POST" });
     *   if (!response.ok) throw new Error(await response.text());
     *   return (await response.json()).token;
     * }
     * ```
     */
    token?: () => Promise<string>;
    /**
     * Who the persona is in the conversation, such as your own
     * {@link SessionPersonality.system_prompt}. Left out, it is the default
     * personality.
     *
     * Only for a conversation the SDK creates with an API key, which a page
     * never holds. With a {@link CreateNuanceConversationOptions.token}, the
     * personality is set when your server mints the token: the token fixes it,
     * and a conversation that sets its own is refused.
     */
    personality?: PersonalityChoice;
    /**
     * The longest the conversation may run, in seconds. The server holds it to
     * the account's maximum, so a longer value runs for that maximum; left out,
     * the conversation runs for the maximum.
     */
    maxSessionSeconds?: number;
    /**
     * Capture constraints for the user's camera.
     *
     * When omitted, 720p by default.
     */
    videoCapture?: VideoCaptureConstraints;
    /** Local capture preferences, resolved once for each connection attempt. */
    mediaDevices?: MediaDevicePreferences | (() => MediaDevicePreferences);
    /**
     * When `avatar-presented` fires. The persona doesn't speak first: send
     * `response.create` on `avatar-presented` to have it open, or wait for the
     * user to speak.
     *
     * - `"first-frame"`: as soon as the persona's first frame reaches the page.
     *   `avatar-presented` follows `avatar-ready` at once. The video may be
     *   soft for its first few seconds while the connection ramps up.
     * - `"full-quality"`: once the video has reached its full size and held
     *   it, or after at most about 12 seconds. The persona is in view in
     *   between, so a page using this should cover it until `avatar-presented`.
     *
     * @defaultValue `"first-frame"`
     */
    startOn?: StartOn;
    /**
     * Sends the persona over solid green (`#00FF00`), so your page can key the
     * green out and draw the persona over its own background. Only where the
     * deployment offers it: elsewhere the conversation is refused and `connect()`
     * throws an {@link ApiError} with code `green_screen_not_offered`. Some
     * personas cannot be drawn over green (their cutout would miss part of them),
     * so a token that asks for one of them and the green screen is refused when
     * it is minted: choose another persona, or leave this out.
     *
     * @defaultValue `false`
     */
    greenScreen?: boolean;
    /**
     * Stays in the call after the conversation ends on the server's side (its
     * goodbye, the time limit, a policy end, an age check), with the camera
     * and microphone on, until you call `disconnect()`. Left out, the SDK
     * leaves the call and stops the camera and microphone right after it
     * reports `session-ended`. `useNuanceConversation` leaves on every end
     * whatever this says.
     *
     * @defaultValue `false`
     */
    stayConnectedOnEnd?: boolean;
}


/**
 * A {@link KnownEndReason}, or any other string the runtime sends. A reason
 * the SDK does not know is passed through as it arrived rather than dropped
 * or flattened, so a value a newer runtime adds still reaches the app.
 */
export declare type EndReason = KnownEndReason | (string & {});

/**
 * Raised by {@link Conversation.connect} when the server refuses a guest's new
 * session because a guest limit is used up. `reason` says which: `used` (this
 * guest has had its conversations), `device` (so has this browser) or `network`
 * (so has this network today). The message is the server's, written for the
 * person.
 */
export declare class GuestLimitError extends Error {
    readonly reason: string;
    constructor(reason: string, message: string);
}

/** How the last {@link Conversation.connect} went, for a report of a failed start. */
export declare interface JoinReport {
    /** How far it got. */
    stage: JoinStage;
    /** The browser check, or null while it runs or where it did not run. */
    check: BrowserCheck | null;
}

/**
 * How far a start got, from the request to a live call:
 *
 * - `"create"`: the conversation is being created.
 * - `"queue"`: it is created and waits for its turn.
 * - `"token"`: its turn came; the media connection has not started.
 * - `"connecting"`: the media connection started; its signal channel is not up
 *   yet (the browser may still be preparing, or the media service does not
 *   answer from this network).
 * - `"media"`: the signal channel is up; the audio and video path has not
 *   connected (a network or a browser setting can block it).
 * - `"publish"`: the call is up; the microphone or camera is opening.
 */
export declare type JoinStage = "create" | "queue" | "token" | "connecting" | "media" | "publish";

/**
 * Raised by {@link Conversation.connect} when the call did not connect within
 * a minute of its turn coming. The conversation is let go; a new
 * `connect()` starts another. `stage` says how far it got: `"connecting"` or
 * `"media"` usually means a network or a browser setting (often a VPN or a
 * privacy extension) blocks calls.
 */
export declare class JoinTimeoutError extends Error {
    readonly stage: JoinStage;
    constructor(stage: JoinStage);
}

/**
 * The reasons a session ends for. A session ends for exactly one of these.
 *
 * - `close_requested`: a client closed the session with `session.close`.
 * - `content`: a safety check ended it for a policy violation.
 * - `age_check`: the age check ended it: the camera showed only people who
 *   look under 18.
 * - `expired`: it ran out its time cap or its idle limit.
 * - `end_call`: the persona hung up.
 * - `error`: the session ended on the server's side. It failed (for example,
 *   the machine it ran on was taken back), your server ended it with
 *   `POST /conversation/{id}/end` (for now; it did not fail), or Nuance ended
 *   it (for example, for a suspended organization).
 * - `connection_lost`: the client's connection went away without closing.
 */
export declare type KnownEndReason = "close_requested" | "content" | "age_check" | "expired" | "end_call" | "error" | "connection_lost";

/**
 * Raised by {@link Conversation.connect} when the server refuses a new session
 * because the account behind it has not accepted the terms the session needs:
 * for a session token, the API Developer Agreement and the Acceptable Use
 * Policy, which the account that made the API key accepts on the platform.
 * Retrying before they are accepted fails the same way.
 */
export declare class LegalRequiredError extends Error {
    constructor();
}

/**
 * Raised by {@link Conversation.connect} when the server refuses a new session
 * because the service is under maintenance. `message` is the notice the
 * operators wrote, safe to show as is.
 */
export declare class MaintenanceError extends Error {
    constructor(message: string);
}

/**
 * A local media failure raised by {@link Conversation.connect}. Exposes the
 * affected device and a classified reason so the application can render (and
 * localize) the user-facing copy and choose recovery UI. The `Error` message is
 * terse and developer-facing — do not show it to users.
 */
export declare class MediaAccessError extends Error {
    readonly device: MediaDevice;
    readonly reason: MediaErrorReason;
    constructor(cause: unknown, device?: MediaDevice);
}

/**
 * Which local capture device a media failure concerns.
 */
export declare type MediaDevice = "camera" | "microphone" | "unknown";

/** Preferred local devices. Unavailable device IDs fall back to browser defaults. */
export declare interface MediaDevicePreferences {
    microphoneId?: string;
    cameraId?: string;
    /** Whether to capture video on connect. Defaults to true; video can be enabled later. */
    cameraEnabled?: boolean;
    /** Required camera direction; takes precedence over cameraId. */
    cameraFacing?: CameraFacing;
}

/**
 * Why a local capture device could not be acquired.
 */
export declare type MediaErrorReason = "permission-denied" | "device-not-found" | "device-in-use" | "unknown";

/**
 * How well media is getting through: the worse of the user's own link and
 * the persona's, as the media server scores them. `"poor"`: degraded (loss,
 * jitter, low bandwidth). `"lost"`: media has stopped arriving.
 */
export declare type NetworkQuality = "good" | "poor" | "lost";

/**
 * Who does the work the persona hands off: `client`, your page, which reports
 * back with appends naming the delegation; `responses`, a backend that calls
 * your tools, which your page runs; or `none`, when nothing on your side would
 * answer a hand-off: the persona hands nothing off and answers with its own
 * tools.
 */
export declare type NuanceLiveDelegation = {
    type: "client";
    acknowledgement_delay_ms?: number;
} | {
    type: "none";
} | {
    type: "responses";
    /** Accepted and recorded, 0 to 800; changes nothing. */
    acknowledgement_delay_ms?: number;
    responses: NuanceLiveResponses;
};

/** The backend's settings in a `responses` delegation. */
export declare type NuanceLiveResponses = {
    /** Required: any non-empty name up to 256 characters. It is recorded; the backend runs Nuance's own model. */
    model: string;
    /** The backend's instructions, up to 65,536 characters, which only the backend sees. */
    instructions?: string;
    /** Your function tools; a session runs at most 16. */
    tools?: NuanceLiveTool[];
    /** `auto` (the default), `none`, `required`, or one tool by name. */
    tool_choice?: "auto" | "none" | "required" | {
        type: "function";
        name: string;
    };
    /** `true` (the default) lets a step make several calls; `false`, one per step. */
    parallel_tool_calls?: boolean;
    /** The most a step writes, from 16. Reasoning tokens count toward it. */
    max_output_tokens?: number;
    /** How much the backend thinks before each step; `low` is the default. */
    reasoning?: {
        effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
        /** Accepted and echoed; changes nothing. */
        summary?: "concise" | "detailed" | "auto";
    };
    /** Accepted and echoed; changes nothing. */
    service_tier?: "auto" | "default" | "flex" | "priority" | "fast_tier_temp_pilot" | "ultrafast";
    /** Accepted and echoed; changes nothing. */
    text?: {
        verbosity?: "low" | "medium" | "high";
    };
};

/** Nuance Live's settings in a session token (`interface_setup`). */
export declare type NuanceLiveSetup = {
    /** Who does the work the persona hands off: your page (the default), a backend, or nobody. */
    delegation?: NuanceLiveDelegation;
    /**
     * The persona's own tools, each on (`true`) or off (`false`). Left out, a tool
     * keeps its default: `stay_quiet` on, `end_call` and `call_time` off. A tool
     * runs only where the service offers it.
     */
    runtime_tools?: {
        stay_quiet?: boolean;
        end_call?: boolean;
        call_time?: boolean;
        /** @deprecated An API session never changes the persona's look: `true` is refused. */
        switch_identity?: boolean;
    };
    /** `{ input: { camera: false } }` keeps the persona from using the user's camera. */
    video?: {
        input?: {
            camera?: boolean;
        };
    };
};

/**
 * One of your tools in a `responses` delegation: the backend calls it, and
 * your page runs it and sends back the result.
 */
export declare type NuanceLiveTool = {
    type: "function";
    /** Letters, digits, `_` and `-`, up to 64 characters, unique in the list. */
    name: string;
    /** When to use it, up to 2,000 characters. */
    description?: string;
    /**
     * A JSON Schema whose `type` is `"object"`, up to 16,000 characters as
     * compact JSON. Left out, the tool takes no arguments.
     */
    parameters?: Record<string, unknown>;
    strict?: boolean;
    /**
     * `confirm`: the persona reads the call back and sends it only after the
     * user's clear yes. `safety_resource`: a tool that gives a crisis or
     * safety resource, whose numbers the persona must say in full.
     */
    policy?: {
        confirm?: boolean;
        safety_resource?: boolean;
    };
    /** MCP's tool hints; see {@link ToolAnnotations}. */
    annotations?: ToolAnnotations;
};

/**
 * Who the persona is in a conversation created with
 * {@link CreateNuanceConversationOptions.personality}.
 */
export declare interface PersonalityChoice extends SessionPersonality {
}

/**
 * Raised by {@link Conversation.connect} when the server refuses a new session
 * because the runtime recently ended too many of this account's sessions for
 * content-policy violations. `retryAfterSeconds` is the server's estimate of
 * when a new session may be started, when it sent one. `message` says so in
 * words to show the person, with the wait when it is known.
 */
export declare class PolicyCurfewError extends Error {
    readonly retryAfterSeconds: number | null;
    constructor(retryAfterSeconds: number | null);
}

/**
 * Why a session is over. `"time-limit"`: the capped session ran out its clock.
 * `"policy-violation"`: the runtime ended it for content that breaks the usage
 * policy. `"age-check"`: the runtime ended it because the camera showed only
 * people who look under 18. `"refused"`: it never started: the runtime would not start it, for
 * the reason in the event's `message`, or the server refused to create it,
 * for the reason in its `error`. `"ended"`: any other server-side end.
 */
export declare type SessionEndReason = "time-limit" | "ended" | "policy-violation" | "age-check" | "refused" | "connection-lost";



/** Who the persona is in a conversation. */
export declare interface SessionPersonality {
    /**
     * Your own prompt: who the persona is, where it works, and what it knows
     * about the person and the situation, written as you would brief a person
     * before a call, in plain text.
     */
    system_prompt?: string;
    /**
     * The persona the conversation is drawn as: who it looks and sounds like,
     * `"sam"`, `"sonia"` or `"mira"`. Leave it out for `"sam"`. Any other id,
     * `"emma"` included, is refused when the token is minted.
     */
    persona_id?: string;
}

/**
 * What your server sends to `POST /session-tokens` with its API key. Every
 * field is fixed for the conversation the token starts. Send `end_user_id`
 * with every token; leave the other fields out for the defaults.
 */
export declare interface SessionTokenRequest {
    /** Who the persona is in the conversation. Leave it out for the default personality. */
    personality?: SessionPersonality;
    /**
     * Your own id for the person this conversation is for, such as a hash of
     * your user id. After repeated policy violations, new conversations pause
     * for this person only, not for your whole app. Letters, digits and
     * `_ . : -`, up to 128 characters: never an email address or a name.
     */
    end_user_id?: string;
    /**
     * The interface the conversation runs: Nuance Live, the default, whose
     * events your page sends and receives with `conversation.sendInterfaceEvent`
     * and `conversation.onInterfaceEvent`. Leave it out.
     */
    interface?: "nuance_live";
    /**
     * Nuance Live's settings for the session, fixed by the token: who does the
     * work the persona hands off, its own tools, and whether it sees the
     * user's camera. Any key it doesn't list is refused with `422`
     * `interface_setup`.
     */
    interface_setup?: NuanceLiveSetup;
    /**
     * How much the persona's face and head move, from 0 to 2: lower is calmer,
     * higher more expressive. Leave it out for 1, the persona's own tuned
     * level. A value outside 0 to 2 is refused with `422`.
     */
    expressiveness?: number;
}

/** What `POST /session-tokens` returns. */
export declare interface SessionTokenResponse {
    /** The session token, `st_…`: pass it to {@link CreateNuanceConversationOptions.token}. */
    token: string;
    /** When the token stops being able to start a conversation (UTC, ISO 8601). */
    expires_at: string;
    /** What to change in how you mint tokens; empty when nothing. */
    warnings?: string[];
}

/** When `avatar-presented` fires: see {@link CreateNuanceConversationOptions.startOn}. */
export declare type StartOn = "first-frame" | "full-quality";

/**
 * MCP's tool hints, up to 2,000 characters as compact JSON. A tool whose
 * `readOnlyHint` and `idempotentHint` are both `false` or left out is called
 * at most once per user request with the same arguments, across all the
 * session's tasks: annotate tools that send, book, pay or post this way. A
 * tool with no `annotations` runs every call. MCP's other hints are accepted
 * and not read.
 */
export declare type ToolAnnotations = {
    /** The tool only reads: calling it again changes nothing. */
    readOnlyHint?: boolean;
    /** Calling it again with the same arguments has no further effect. */
    idempotentHint?: boolean;
    /** MCP's hint; accepted and not read. */
    destructiveHint?: boolean;
    /** MCP's hint; accepted and not read. */
    openWorldHint?: boolean;
    /** MCP's display title; accepted and not read. */
    title?: string;
};

/**
 * One call of one of your tools, made by the backend of a `responses`
 * delegation. Answer it with {@link Conversation.sendToolResult}.
 */
export declare interface ToolCall {
    /** The call's id, which its result names. */
    readonly callId: string;
    /** The tool's name, as you listed it. */
    readonly name: string;
    /**
     * The arguments, parsed from {@link ToolCall.argumentsJson}, or `null` when
     * that is not a JSON object. The backend fills them in from the
     * conversation: check them against the tool's `parameters` before use.
     */
    readonly arguments: Record<string, unknown> | null;
    /** The arguments as the backend wrote them: a JSON string. */
    readonly argumentsJson: string;
    /** The hand-off (task) the call belongs to. */
    readonly delegationId: string;
}

/**
 * A tool's result: text of up to 24,000 characters, an object (sent as JSON
 * text), or parts. A failed call answers with an error, such as
 * `{ error: { message: "Card declined" } }`.
 */
export declare type ToolOutput = string | Record<string, unknown> | ToolOutputPart[];

/** One part of a tool result made of parts, such as text beside an image. */
export declare type ToolOutputPart = {
    type: "input_text";
    text: string;
}
/** A base64 `data:` URL of a JPEG or PNG; up to 4 per result. */
| {
    type: "input_image";
    image_url: string;
};

/** How a tool result is delivered. */
export declare interface ToolResultOptions {
    /**
     * Whether the persona replies to the result. `false` suits a tool that only
     * changes something on your page, such as a score or a scene: the task
     * still goes on, but when every result of its step says `false`, its
     * answer is not spoken, and the persona's next turn comes when the user
     * speaks. A failed call is still told. Default `true`.
     */
    reply?: boolean;
}

/**
 * The local user participant in a conversation.
 */
export declare interface UserParticipant {
    /** Local camera video, when available. */
    readonly videoTrack: VideoTrack | null;
    /** Local microphone audio, when available. */
    readonly audioTrack: AudioTrack | null;
    /** Current microphone device id, or the selected device while muted. */
    readonly microphoneId: string | null;
    /** Changes the microphone without ending the conversation or changing mute. */
    setMicrophone(deviceId: string): Promise<void>;
    /** Current camera device id, or the selected device while the camera is off. */
    readonly cameraId: string | null;
    /** Changes the camera without ending the conversation or enabling video. */
    setCamera(deviceId: string): Promise<void>;
    /** Current camera direction, or the selected direction while video is off. */
    readonly cameraFacing: CameraFacing | null;
    /** Selects the front or back camera without enabling video. */
    setCameraFacing(facing: CameraFacing): Promise<void>;
    /** Enables the local camera. */
    enableVideo(): Promise<void>;
    /** Disables the local camera. */
    disableVideo(): Promise<void>;
    /** Mutes the local microphone. */
    muteAudio(): Promise<void>;
    /** Unmutes the local microphone. */
    unmuteAudio(): Promise<void>;
    /** Whether the local microphone is muted. */
    readonly isMuted: boolean;
    /** Whether the local camera is enabled. */
    readonly isVideoEnabled: boolean;
    /** Whether the user is currently detected as speaking. */
    readonly isSpeaking: boolean;
}

/**
 * Capture constraints for the user's published camera track.
 *
 * Use this to match the capture to what your UI actually displays, so
 * recordings and other downstream consumers receive the same frame the user
 * sees in their self-view — e.g. a square self-view should capture square
 * video. Values are applied as ideal constraints; a browser that cannot
 * satisfy them falls back to its nearest supported format.
 */
export declare interface VideoCaptureConstraints {
    width: number;
    height: number;
    /** @defaultValue `width / height` */
    aspectRatio?: number;
}

/**
 * A video track that can be attached to or detached from a video element.
 */
export declare interface VideoTrack {
    /** Attaches the video track to an HTML video element. */
    attach(element: HTMLVideoElement): void;
    /** Detaches the track from its currently attached element, if any. */
    detach(): void;
    /** Whether the video track is currently enabled. */
    readonly isEnabled: boolean;
}

/**
 * Raised by {@link Conversation.connect} when this browser cannot make calls:
 * its WebRTC is turned off, by a setting, a policy or an extension. No
 * conversation is created. Ask the person to turn WebRTC on for this site or to
 * use another browser.
 */
export declare class WebRTCUnavailableError extends Error {
    constructor();
}

export { }
