import { StartConversationOptions } from './host-types.ts'; export type { StartConversationOptions } from './host-types.ts'; export type TavusInteraction = { event_type: "conversation.echo"; properties: { text: string; modality?: "text"; }; } | { event_type: "conversation.respond"; properties: { text: string; }; } | { event_type: "conversation.interrupt"; properties?: Record; } | { event_type: "conversation.append_llm_context"; properties: { context: string; }; } | { event_type: "conversation.overwrite_llm_context"; properties: { context: string; }; } | { event_type: "conversation.tool_result"; properties: { tool_call_id: string; output?: string | Record; status?: "success" | "error"; }; }; export type TavusEventName = "tavus:ready" | "tavus:conversation-created" | "tavus:conversation-started" | "tavus:conversation-ended" | "tavus:error" | "tavus:state-change" | "tavus:chat-message" /** Retained for type-back-compat; never emitted at runtime. */ | "tavus:message" | "tavus:protocol-message" | "tavus:tool-call" | "tavus:mode-change"; export interface TavusEventMap { "tavus:ready": { deploymentId: string; }; /** The room exists and the replica is warming up; nobody has joined yet. */ "tavus:conversation-created": { conversationId: string; }; "tavus:conversation-started": { conversationId: string; }; "tavus:conversation-ended": { conversationId: string; }; "tavus:error": { code: string; message: string; }; "tavus:state-change": { state: string; }; "tavus:chat-message": unknown; /** Retained for type-back-compat; never emitted at runtime. */ "tavus:message": unknown; /** Firehose: fires for every observable protocol event. Switch on `event.detail.kind` or `event.detail.event_type`. */ "tavus:protocol-message": unknown; "tavus:tool-call": { name: string; arguments: string; tool_call_id?: string; seq?: number; turn_idx?: number; }; "tavus:mode-change": { mode: string; }; } export declare const TAVUS_EVENT_NAMES: TavusEventName[]; interface TavusElementTavusApi { /** @deprecated Use the element's `startConversation()`; this is an alias of it. */ start?: () => Promise; /** @deprecated Use the element's `endConversation()`; this is an alias of it. */ end?: () => Promise; sendChat?: (text: string) => void; sendMessage?: (interaction: TavusInteraction) => void; } export interface TavusElement extends HTMLElement { /** Expands the popup to the preview screen. `` only. */ open?: () => void; /** * The popup's own close path. Ends a call in progress and cancels a pending * start before it collapses; `tavus:conversation-ended` follows for a call * that was live. `` only. */ close?: () => void; /** Creates the room without joining it; the next start joins it. Rejects on failure. */ createConversation?: () => Promise<{ conversationId: string; }>; /** Resolves even when the start fails — failures arrive as `tavus:error`. */ startConversation?: (options?: StartConversationOptions) => Promise; endConversation?: () => Promise; /** Legacy string-based send; prefer el.tavus.sendMessage for typed interactions. */ sendMessage?: (input: TavusInteraction | string) => void; updateConfig?: (config: Record) => void; destroy?: () => void; tavus?: TavusElementTavusApi; } export declare class TavusIntegration { private element; private tagName; constructor(tagName?: "tavus-widget" | "tavus-embed"); private getElement; open(): void; close(): void; /** * Create the conversation now and join it on the next `startConversation()`. * Lets the replica warm up while the visitor is still on the preview or the * host's own haircheck. Rejects when the room could not be created; a later * start then creates one as usual. */ createConversation(): Promise<{ conversationId: string; }>; startConversation(options?: StartConversationOptions): void; endConversation(): void; /** * Send a typed interaction or a plain text string (back-compat shim). * String input is wrapped as `conversation.respond`. */ sendMessage(input: TavusInteraction | string): void; updateConfig(config: Record): void; destroy(): void; on(event: K, handler: (e: CustomEvent) => void): void; off(event: K, handler: (e: CustomEvent) => void): void; }