import { AssistantMode, Placement } from './shape-spec'; export type Theme = "light" | "dark" | Record; export { SHAPE_SPECS, LIVE_MODES, DEFAULT_MODE, REACH_SHAPES, DEFAULT_SELECTION_ANSWERS, isAssistantMode, resolveReach, resolveSelectionAnswers, type AssistantMode, type ReachChannel, type SelectionAnswers, type ShapeSpec, type ShapeContainer, type ShapeInitial, type ShapeTrigger, type ShapeStatus, } from './shape-spec'; export type { Placement }; export type AssistantPreviewMessage = { role: "user" | "assistant"; text: string; }; export type AssistantConfig = { tenantId: string; assistantId: string; displayName?: string; /** Hide the "Powered by Olotalk" link. Server/plan-driven, see Assistant.svelte. */ hideBranding?: boolean; theme?: Record; /** * Preview-only sample transcript used by the dashboard's live preview so the * operator can see a user bubble before a real visitor has typed anything. */ previewMessages?: AssistantPreviewMessage[]; launcher?: { logoUrl?: string; position?: "bottom-right" | "bottom-left"; /** * Starter bubbles, the stack of starter questions that rises off the * launcher on hover. Named `teaser` for history (it used to drive a canned * tooltip); `enabled` is the only field read. The rest are accepted and * ignored so stored configs keep parsing. */ teaser?: { enabled?: boolean; /** @deprecated The bubbles carry `starters` questions. Read by nothing. */ messages?: string[]; /** @deprecated The stack lives as long as the hover does. */ durationMs?: number; /** @deprecated A hover needs no delay budget. */ delayMs?: number; /** @deprecated A hover needs no cooldown. */ cooldownMs?: number; /** @deprecated A hover needs no per-session cap. */ maxShowsPerSession?: number; }; }; allowedDomains?: string[]; features?: { domRagEnabled?: boolean; siteRagEnabled?: boolean; citationsEnabled?: boolean; streamingEnabled?: boolean; }; security?: { rateLimitPer5Min?: number; captchaMode?: boolean; }; privacy?: { piiRedaction?: boolean; retentionDays?: number; }; conversion?: { enabled?: boolean; leadCapture?: { fields?: Array<"email" | "name" | "company" | "useCase">; minIntentConfidence?: number; }; ctas?: Array<{ id: string; label: string; intents: Array<"pricing" | "demo" | "integration" | "support" | "general">; minIntentConfidence?: number; pagePatterns?: string[]; action: "lead_form" | "link" | "escalate_to_human" | "trigger_webhook"; href?: string; }>; }; welcomeMessage?: string; }; export type CreateAssistantOptions = { assistantId?: string; siteId?: string; origin?: string; config?: AssistantConfig; theme?: Theme; mount?: HTMLElement; /** * Which shape to mount (ADR 0202). One word publicly; internally it resolves * to a spec record over container / initial / modal / trigger. A `planned` * shape resolves to the default rather than a mount the runtime cannot draw. */ mode?: AssistantMode; /** * @deprecated Use `mode`. Kept because it is in live customer snippets: * `floating` resolves to `bubble`, `embedded` to `inline`. */ placement?: Placement; /** * Additive reach over the mounted shape (ADR 0226): a comma-separated list * of trigger-capable shape ids, "selection", "commandk", whose triggers * open THIS mount rather than conjuring their own panel. Typed as a plain * string so an older embed can hand a newer bundle's vocabulary through; * unknown ids are dropped with a warning, never silently. */ reach?: string; /** * Where a SELECTION-triggered open lands the panel (ADR 0226 amendment): * `"beside"` (default) flies the residence to the highlighted words, * `"in-place"` opens it where it lives. Typed as a plain string for the * reason `reach` is, the assistant owns the vocabulary and warns on values * it does not know. */ selectionAnswers?: string; cssUrl?: string; locale?: string; sandboxToken?: string; }; /** What a trigger hands the panel when it fires (ADR 0202). */ export type OpenOptions = { /** Seed the composer with this text. */ prefill?: string; /** * Ask it immediately. Defaults to the shape's own answer: a starter chip or a * submitted nav field carries a complete question and sends, while a * highlighted passage does not and waits for the visitor to amend it. */ send?: boolean; /** * The element this panel is ABOUT, anchored shapes only. The runtime has * accepted these two since the anchored shape shipped; the type lagged, which * made the documented anchored wiring fail to compile for TS integrators. */ anchor?: HTMLElement; /** * Land the panel beside `anchor` even when the mounted shape lives somewhere * else, position only, anatomy untouched (ADR 0226). Honoured by the * floating containers (`corner`, `edge`, `center`); ignored by in-flow, full * page, rail and by a shape that is already anchored. */ anchorPresentation?: boolean; /** * A passage to quote as CONTEXT. Unlike `prefill` it never enters the * composer: it renders above it as a removable quote, the composer keeps its * placeholder, and a send combines the two. Capped at 600 characters. */ quote?: string; /** * What to call that element when the anchor is not visible (the mobile * sheet names its context). Falls back to the element's * `data-olotalk-context`, `aria-label`, or its own heading. */ context?: string; }; export type AssistantInstance = { /** * The shape this mount actually resolved to, after aliasing (`floating` → * `bubble`) and after an unknown mode fell back. Read by declarative doors * (`data-olotalk-open="drawer"`) and useful to a host that wants to know * what it got rather than what it asked for. */ mode: string; open: (opts?: OpenOptions) => void; close: () => void; /** Whether this panel is showing. Read by toggling doors (ADR 0243). */ isOpen: () => boolean; setTheme: (t: Theme) => void; /** * Change the language after mount, keeping the conversation. For hosts whose * own language switcher does not reload the page, the assistant resolves a * locale once, at mount, and cannot see a switch that happens after it. */ setLocale: (locale: string) => Promise; destroy: (opts?: { outro?: boolean; }) => Promise; on: (ev: "ready" | "open" | "close" | "send" | "cta_click" | "lead_submit", handler: (e: any) => void) => () => void; }; /** * The mounted assistant for an ID, if there is one. This is what a trigger * calls before `open({ prefill })`. */ export declare function getAssistant(assistantId: string): AssistantInstance | undefined; export declare function createAssistant(mountEl: HTMLElement, opts: CreateAssistantOptions): AssistantInstance; export declare class OlotalkAssistantElement extends HTMLElement { private instance; private configOverride; private themeOverride; static get observedAttributes(): string[]; get config(): AssistantConfig | undefined; set config(value: AssistantConfig | undefined); get theme(): Theme | undefined; set theme(value: Theme | undefined); connectedCallback(): void; disconnectedCallback(): void; attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void; open(opts?: OpenOptions): void; close(): void; destroy(): Promise; private resolveTheme; private resolveConfig; private resolveOptions; private ensureInstance; private rebuild; } export declare function defineOlotalkAssistantElement(tagName?: string): typeof OlotalkAssistantElement | null; declare global { interface HTMLElementTagNameMap { "olotalk-assistant": OlotalkAssistantElement; } } declare const _default: { createAssistant: typeof createAssistant; getAssistant: typeof getAssistant; defineOlotalkAssistantElement: typeof defineOlotalkAssistantElement; OlotalkAssistantElement: typeof OlotalkAssistantElement; }; export default _default;