/** * `` — a framework-light embeddable chat web component. * * Ported (and simplified) from smooai's `@smooai/ui-chat-widget`. The original is a * React custom element that mounts the heavyweight `@smooai/ui` ChatWidget and * pulls in the whole monorepo (Tailwind, shadcn, react-phone-number-input, MSW, * Supabase auth …). This is a clean, dependency-light rewrite that preserves the * embedding model — a custom element with a launcher + popover panel, declarative * HTML attributes, and a programmatic API — while talking to the * `@smooai/smooth-operator` protocol client instead of `@smooai/realtime`. * * Embedding model: * * or programmatically via {@link mountChatWidget}. */ import type { ChatWidgetConfig } from './config.js'; export declare const ELEMENT_TAG = "smooth-agent-chat"; /** * Return `url` only if it is a valid absolute `http(s)` URL, else `null`. * * SECURITY: citation URLs originate from indexed content (web / GitHub * connectors), which can be attacker-influenceable. Assigning an arbitrary * string to `.href` allows `javascript:`/`data:`/`vbscript:` URLs that * execute on click — a stored-XSS vector. Only http(s) links are rendered as * anchors; anything else falls back to plain text. */ export declare function safeHttpUrl(url: string | undefined | null): string | null; export declare class SmoothAgentChatElement extends HTMLElement { static get observedAttributes(): readonly string[]; private readonly root; private controller; private overrides; private open; private messages; private status; private mounted; private panelEl; private launcherEl; private messagesEl; private statusEl; private inputEl; private sendBtn; constructor(); connectedCallback(): void; disconnectedCallback(): void; attributeChangedCallback(): void; /** * Programmatically merge config overrides (endpoint, agentId, theme, …). Values * set here take precedence over HTML attributes. Re-renders the widget. */ configure(config: Partial): void; /** Open the chat panel. */ openChat(): void; /** Collapse the chat panel back to the launcher. */ closeChat(): void; private readConfig; private render; private syncOpenState; private renderMessages; /** * Render a chat-native button prompt (SEP `ui/confirm` / `ui/select`). Each * option is a button; clicking one resumes the paused turn via * {@link ConversationController.answerPrompt}. Once answered the buttons * disable and the chosen label is shown, so the record stays in the * transcript. Built with DOM APIs (no innerHTML) — prompt text is untrusted. */ private renderPrompt; /** * Build the collapsible "Sources (N)" block for an assistant message's * citations. Each source renders its `title` (linked to `citation.url` when * present — `target=_blank rel=noopener` — plain text otherwise) plus the * grounding `snippet`. Built with DOM APIs (not innerHTML) so citation text * can't inject markup. */ private renderSources; private renderStatus; private renderComposerState; private submit; } /** Register the custom element once. Safe to call multiple times. */ export declare function defineChatWidget(): void; /** * Programmatically create, configure, and append a widget to the page. * Returns the element so the host can drive `openChat()` / `closeChat()`. */ export declare function mountChatWidget(config: ChatWidgetConfig, target?: HTMLElement): SmoothAgentChatElement; /** * Ergonomic helper for the full-page layout: mounts a `` in * `mode: "fullpage"` (no launcher — the chat fills its container/viewport with a * Smooth-branded header, a scrollable message list, and an input bar) and * returns the element. * * `target` defaults to `document.body`; pass a sized container to embed the * full-page chat inside a layout region (e.g. a `/chat` route shell or an * iframe). The `mode` is forced to `"fullpage"` regardless of the passed config. * * ```ts * mountFullPageChat({ endpoint: 'wss://…/ws', agentId: '…', agentName: 'Support' }); * ``` */ export declare function mountFullPageChat(config: Omit, target?: HTMLElement): SmoothAgentChatElement; //# sourceMappingURL=element.d.ts.map