/** * The widget's single door to TORUK Core. * * The widget has no session API of its own: it builds a real `TorukClient` * from its props and uses `client.sessions.*`, the same typed client an npm * consumer gets. That is what keeps one implementation of the session plane in * the package — and it means the widget inherits visitor identity, retry, * error normalization and envelope handling rather than re-deriving them. * * Authentication: the widget never reads ambient credentials. It sends * `auth: { type: 'none' }` — correct for a public deployment — and everything * else arrives through the embedder's explicit `onRequest` hook, which is how * the previewer injects the configured `AuthConfig` headers for a private * deployment. * * Clients are cached per (apiHost, deploymentId) so a widget instance reuses * one visitor-token store instead of racing several. */ import { TorukClient } from '@/client/toruk-client'; export type WidgetClientParams = { apiHost?: string; deploymentId: string; onRequest?: (request: RequestInit) => Promise; }; /** * Build (or reuse) the widget's TorukClient. * * A missing `deploymentId` is caught by `requireDeploymentId` inside the client * on the first call, which reports a `CONFIGURATION` error rather than letting a * misconfigured embed request `/api/v1/deployments//...` — a different route * that fails somewhere far from the real cause. The check lives there, not here, * so every entry point into the client is covered by one guard. */ export declare function getWidgetClient(params: WidgetClientParams): TorukClient; /** * There is now exactly one `VisitorTokenStore` per widget client. * * A second, standalone `lookupStore` used to live here so the widget's hand-rolled * request layer could read the visitor header without touching the client cache. * Two instances of one class over the same localStorage keys agreed only because * both re-read storage — an in-memory cache on either side would have let them * drift, and a drifted visitor identity means a returning user silently loses * their history. With every widget call going through `client.employees.*`, the * client's own store attaches the header and nothing needs to peek. */ /** Test seam — drops cached clients (and with them, cached visitor tokens). */ export declare function resetWidgetClients(): void;