/** * Adaptive Chatbot — Lit Mountable * * Thin wrapper that mounts from @syntrologie/chat with an * AgUiTransport pointed at the adaptive AG-UI streaming endpoint. * * Four pieces this mountable owns: * * 1. SDK token plumbing. The chat backend (`/api/adaptive/*`) is identified * by the workspace's `syn_*` SDK token. The token rides the RUNTIME * handle (`runtime.token`, populated by `Syntro.init({token})` — the * same single-source contract as `runtime.backendUrl`); we read it at * mount time and forward it via `Authorization: Bearer` header. Never * a window global (BUG-1785360157). * * 2. Cloudflare Turnstile bot-check token, acquired on the visitor's FIRST * SEND (never at mount) and only when the backend reports it enforces * the check (`GET /api/adaptive/bot_check`, BUG-1789605814). When it * runs, it renders a single `size: 'flexible'` widget with * `appearance: 'interaction-only'` against a `managed`-mode sitekey: * • Clean traffic: CF passive-grades silently, token resolves in * ~100ms, no UI is ever shown. * • Flagged traffic (datacenter IP, automation, strict-privacy): * CF renders an "I am human" checkbox inside the in-chat verify * panel; on solve, swap to the chat UI. * • Total failure (CSP blocks CF, network error, user dismisses): * fall through with no token; backend enforcement 403s and the * existing fallback card renders. * The widget mode MUST be `managed` on the CF side — see * cloudflare/turnstile/main.tf in syntro-infra. (`mode = 'invisible'` * rejects any `size` other than `invisible`, and `size: 'invisible'` * against `mode = 'managed'` fails with a synchronous TurnstileError — * don't mix.) * Skipped entirely when the sitekey is empty or the backend mode is `off`. * * 3. Fallback card. If the first agent run fails (Cloudflare Turnstile * bot-check failure, CORS / network error, or a server-side rejection), * swap the chat UI for a per-customer fallback card built from * `props.fallback`. The end-user is redirected to the customer's normal * support path instead of seeing a raw error. * * 4. A2UI passthrough. AG-UI CUSTOM events carrying A2UI payloads * (createSurface, updateDataModel, …) get forwarded to * `runtime.actions.applyBatch` so tiles can render server-driven UI * inside the chat surface. */ import '@syntrologie/chat'; import type { ChatbotConfig, ChatbotFallback, ChatbotWidgetRuntime } from './types.js'; export interface ChatAssistantLitProps { config: ChatbotConfig; runtime: ChatbotWidgetRuntime; tileId?: string; } /** * Build the inline HTML for the fallback card. Customer-supplied copy wins; * everything else falls back to generic copy. The card avoids any reference * to Cloudflare or Turnstile so the end-user is never confronted with our * implementation details. */ export declare function renderFallbackHtml(fallback: ChatbotFallback | undefined): string; export declare const ChatAssistantLitMountable: { mount(container: HTMLElement, mountConfig?: Record): () => void; }; //# sourceMappingURL=ChatAssistantLit.d.ts.map