/** * createTorukPreviewer — embeddable chat preview, wrapping the existing * SolidJS widget (src/widget/) without redesigning the UI. * * The widget exposes execute()/executeFull()/destroy() in src/widget/window.ts * and registers / custom elements * via src/widget/register.tsx. The previewer is a thin façade over those * primitives that: * * - Takes a typed TorukClientConfig (baseUrl + AuthConfig) — no * localStorage reads required from the host app. * - Translates AuthConfig into an `onRequest` closure that injects * auth headers (matching the widget's existing extension hook). * - Maps the SDK's mode names (inline / modal / floating) onto the * widget's bubble vs. full-page templates. * * Mode mapping: * floating → bubble template (), appended to * inline → full template (), mounted in the * host-provided container * modal → full template inside a fixed-position overlay container * the previewer creates (and removes on unmount) */ import type { TorukClientConfig } from '../types/common'; import type { WidgetFeatureOverrides } from '../types/features'; import type { WidgetScope } from '../chat'; import type { WidgetSessionConfig } from '../widget/types/session'; export type PreviewerMode = 'inline' | 'modal' | 'floating'; export type PreviewerVariant = 'luna' | 'erebus' | 'neptune'; export type PreviewerMountOptions = { /** Chatflow or agentflow UUID. */ deploymentId: string; /** @deprecated use `deploymentId` — accepted as a fallback for one minor cycle. */ workflowId?: string; /** * Preview/trial mount (e.g. a deployment wizard review step). The widget * makes no server session reads/writes and persists chat state under an * isolated `preview:` localStorage scope. */ previewMode?: boolean; /** UI presentation mode. Defaults to 'floating'. */ mode?: PreviewerMode; /** Full-page visual variant (only used for inline/modal). */ variant?: PreviewerVariant; /** Whether to render the sidebar in full-page modes. */ withSidebar?: boolean; /** Feature switches; only `false` has an effect (BotProps.features). */ features?: WidgetFeatureOverrides; /** Pin the widget to one conversation (BotProps.session). */ session?: WidgetSessionConfig; /** Which part of the conversation to render (BotProps.scope). */ scope?: WidgetScope; /** `'en'` (default) or `'ar'` (BotProps.language). */ language?: string; /** Theme override passed through to the widget (BotProps.theme). */ theme?: Record; /** Per-task engine config — passes through to TORUK-CORE. */ taskConfig?: Record; /** @deprecated use `taskConfig`. */ workflowConfig?: Record; /** Custom request hook called before every widget request. Composes with the SDK's auth headers (auth wins on collisions). */ onRequest?: (req: RequestInit) => Promise; }; export type TorukPreviewerInstance = { /** Mount the widget. `target` is a CSS selector or Element for inline/modal; ignored for floating. Returns a Promise that resolves once the widget element is in the DOM. */ mount(target: string | Element | null, options: PreviewerMountOptions): Promise; /** Remove the widget from the DOM and tear down its event listeners. */ unmount(): void; /** Show the widget (no-op for inline; un-hides modal/floating). */ open(): void; /** Hide the widget (no-op for inline; hides modal/floating). */ close(): void; /** Synchronous: hot-update the running widget's config in place. Returns immediately — no await needed. */ updateConfig(options: Partial): void; /** The mounted DOM element, or undefined before mount/after unmount. */ readonly element: Element | undefined; }; export declare function createTorukPreviewer(config: TorukClientConfig & { onRequest?: (req: RequestInit) => Promise; }): TorukPreviewerInstance;