import { ApiCaller } from '../api/api-caller'; import { ModeDto } from '../types/dtos'; import { ExternalStorage } from '../types/external-storage'; import { WidgetConfig } from '../types/widget-config'; import { ContactCtx } from './contact.ctx'; import { UploadCtx } from './upload.ctx'; import { CsatCtx } from './csat.ctx'; import { DictationCtx } from './dictation.ctx'; import { MessageCtx } from './message.ctx'; import { RouterCtx } from './router.ctx'; import { SessionCtx } from './session.ctx'; import { StorageCtx } from './storage.ctx'; import { UnreadCtx } from './unread.ctx'; import { WidgetAgent, WidgetClientFeatures } from './widget-agent'; /** A configuration failure that prevents the widget from choosing a safe * runtime. The code is stable so headless consumers can render their own * recovery UI without matching error-message text. */ export declare class WidgetInitializationError extends Error { readonly code: 'config-fetch-failed'; readonly details: unknown; constructor(code: 'config-fetch-failed', message: string, details?: unknown); } export declare class WidgetCtx { config: WidgetConfig; api: ApiCaller; contactCtx: ContactCtx; sessionCtx: SessionCtx; messageCtx: MessageCtx; csatCtx: CsatCtx; uploadCtx: UploadCtx; dictationCtx: DictationCtx; routerCtx: RouterCtx; storageCtx?: StorageCtx; /** Shared by every conversation runtime: the launcher has one dot. */ unreadCtx: UnreadCtx; modes: ModeDto[]; org: { id: string; name: string; }; /** * The org's agent — branding plus which engine serves it — resolved by the * backend at init. The `bot` option overrides the branding at render time. */ readonly agent: WidgetAgent; /** * Choose the transport from the org's default and the current embed opt-out. * The backend chooses the agent version independently of this transport. */ private readonly getRequestConfig; private readonly getClientCapabilities?; get streaming(): boolean; /** * The org's features narrowed by this embed's `config.features` — the * answers the UI asks for, resolved against the current options. */ get features(): WidgetClientFeatures; private static pollingIntervalsSeconds; private activeSessionPollingCtx; private readonly ownsUnreadCtx; private disposed; private constructor(); static initialize: ({ config, storage, getClientCapabilities, getRequestConfig, }: { config: WidgetConfig; storage?: ExternalStorage; getClientCapabilities?: () => WidgetConfig["capabilities"]; getRequestConfig?: () => WidgetConfig; }) => Promise; /** Independent send/history lifecycle, sharing the authenticated visitor and session list. */ createConversation: () => WidgetCtx; /** Release a closed companion runtime after its last send has settled. */ releaseConversation: () => Promise | undefined; /** Permanently stop all polling, subscriptions and in-flight work. */ dispose: ({ clearActiveSession }?: { clearActiveSession?: boolean | undefined; }) => Promise | undefined; resetChat: () => void; /** * Ingest the canonical rows the backend persisted for a streamed turn. * Called by the agent-chat surface when a turn finishes; the polling * context owns history mapping/dedupe, so this delegates to it. */ reconcileAfterStream: (sessionId: string) => Promise; } //# sourceMappingURL=widget.ctx.d.ts.map