import type { AnyTrace, AudioEncoding, Modality, RequestType, ServerMessageType, SocketASRInterrupt, SocketASRStarted, SocketASRTranscript, SocketASRTranscriptPartial } from '@voiceflow/dtos-interact'; import type { RuntimeContact, RuntimeInteractStreamRequest } from '../runtime.interface'; export interface InitialDialogSessionMetadata { userID: string; sessionID?: string; environmentID?: string; versionVariant?: 'draft' | 'published'; config?: { completionEvents?: boolean; audioEvents?: boolean; audioEncoding?: AudioEncoding; platform?: string; modality?: Modality; os?: string; device?: string; browser?: string; pageURL?: string; recording?: { url?: string | null; }; }; contact?: RuntimeContact; userLocale?: string; } export interface OpenInteraction { messageID: string; createContext: () => T; request: RuntimeInteractStreamRequest; controller: ReadableStreamDefaultController; /** not running on the server: held back by this client, or rejected as uninterruptable and due to be sent again */ waiting: boolean; /** when it was started relative to the others */ sequence: number; } export declare enum ConnectionState { DISCONNECTED = "disconnected", CONNECTING = "connecting", CONNECTED = "connected", SESSION_STARTED = "session_started", RECONNECTING = "reconnecting", ERROR = "error" } export interface WebSocketMessage { type: string; payload: any; } export declare enum WebSocketMessageType { START = "start", SESSION_KEY_UPDATE = "session-key-update", RUNTIME_SESSION_END = "runtime-session-end", ACTION = "action", TRACE = "trace", REPLAY = "replay", STATE = "state", LIVE_AGENT_MESSAGE = "live-agent-message", CANCEL = "cancel" } export interface TraceWebSocketMessage { type: WebSocketMessageType.TRACE; payload: { trace: AnyTrace; messageID?: string; }; } export interface ReplayWebSocketMessage { type: WebSocketMessageType.REPLAY; payload: { replay: ({ type: 'trace'; data: AnyTrace; createdAt: string; } | { type: 'action'; data: { type: typeof RequestType.LIVE_AGENT_HANDOFF; payload: { type: 'message'; message: string; }; }; createdAt: string; })[]; }; } export interface ActionWebSocketMessage { type: WebSocketMessageType.ACTION; payload: { status: string; messageID?: string; reason?: string; }; } export interface StartWebSocketMessage { type: WebSocketMessageType.START; payload: { versionID: string; newSessionRequired: boolean; }; } export interface SessionKeyUpdateWebSocketMessage { type: WebSocketMessageType.SESSION_KEY_UPDATE; payload: { sessionKey: string; transcriptID?: string | null; turnID?: string | null; }; } export interface StateWebSocketMessage { type: WebSocketMessageType.STATE; payload: { state: Record; messageID?: string; }; } export interface CancelWebSocketMessage { type: WebSocketMessageType.CANCEL; } /** the server's stop reasons, plus the one this client synthesizes when the socket goes away */ export declare const ASRStopReason: { readonly DISCONNECT: "disconnect"; readonly CLIENT: "client"; readonly IDLE: "idle"; readonly MAX_DURATION: "max_duration"; readonly ERROR: "error"; readonly QUOTA: "quota"; }; export type ASRStopReason = (typeof ASRStopReason)[keyof typeof ASRStopReason]; export type ASRWord = SocketASRTranscriptPartial['payload']['words'][number]; export interface WebSocketMessageEvents { [WebSocketMessageType.TRACE]: (data: TraceWebSocketMessage['payload']) => void; [WebSocketMessageType.ACTION]: (data: ActionWebSocketMessage['payload']) => void; [WebSocketMessageType.START]: (data: StartWebSocketMessage['payload']) => void; [WebSocketMessageType.SESSION_KEY_UPDATE]: (data: SessionKeyUpdateWebSocketMessage['payload']) => void; [WebSocketMessageType.STATE]: (data: StateWebSocketMessage['payload']) => void; [WebSocketMessageType.CANCEL]: () => void; [WebSocketMessageType.REPLAY]: (data: ReplayWebSocketMessage['payload']) => void; [WebSocketMessageType.RUNTIME_SESSION_END]: () => void; [ServerMessageType.ASR_STARTED]: (data: SocketASRStarted['payload']) => void; [ServerMessageType.ASR_STOPPED]: (data: { reason: ASRStopReason; }) => void; [ServerMessageType.ASR_TRANSCRIPT]: (data: SocketASRTranscript['payload']) => void; [ServerMessageType.ASR_TRANSCRIPT_PARTIAL]: (data: SocketASRTranscriptPartial['payload']) => void; [ServerMessageType.ASR_INTERRUPT]: (data: SocketASRInterrupt['payload']) => void; } export interface ConnectionRequest { userID: string; projectID: string; sessionKey: string | null; webchatVersion: string; timezone?: string; environment?: string; audioEvents?: boolean; useSessionKey?: boolean; versionVariant?: 'draft' | 'published'; lastReceivedAt?: number; } //# sourceMappingURL=websocket-runtime.interface.d.ts.map