import { type ChatConfigProvider, type Theme, type ToolCallEvent, type ToolCallHandler, type TriggerButtonConfig, type UserIdentity, type VoiceMachine, type WidgetMode } from "@yak-io/javascript"; export type ToolCallEventHandler = (event: ToolCallEvent) => void; export type YakProviderOptions = { appId: string; mode?: WidgetMode; getConfig?: ChatConfigProvider; onToolCall?: ToolCallHandler; theme?: Theme; onRedirect?: (path: string) => void; disableRestartButton?: boolean; /** * Privacy opt-out: stop sending any page context (URL, title, visible text) * to the assistant. The widget still works; it just won't be aware of the * current page. */ disablePageContent?: boolean; trigger?: boolean | TriggerButtonConfig; /** * Signed end-user identity. When supplied, the widget persists conversations * server-side keyed to this user and surfaces a history pane. The `hash` must * be HMAC-SHA256(apiSecret, id) computed on the integrator's backend — never * expose `apiSecret` to the browser. Omit for anonymous mode (no persistence). * Use `setUser()` to change it after setup (login/logout). */ user?: UserIdentity; }; export type YakState = { isOpen: boolean; isReady: boolean; chatLoading: boolean; voiceMachine: VoiceMachine; voiceLoading: boolean; }; /** Handle for controlling the Yak widget — chat + voice — from Angular. */ export type YakApi = { /** Whether the chat panel is currently open. */ readonly isOpen: boolean; /** Whether the chat iframe is ready to receive messages. */ readonly isReady: boolean; /** Whether the chat is opening but not yet interactive (`isOpen && !isReady`). */ readonly chatLoading: boolean; /** Current voice state-machine snapshot. `idle` when mode is `chat`. */ readonly voiceMachine: VoiceMachine; /** Whether the voice session is establishing its connection (`state === "connecting"`). */ readonly voiceLoading: boolean; /** Open the chat panel. */ open: () => void; /** Close the chat panel. */ close: () => void; /** Open the chat panel and send a specific prompt. */ openWithPrompt: (prompt: string) => void; /** Start a voice session. Must be invoked from a user gesture. */ voiceStart: () => Promise; /** Stop the current voice session. */ voiceStop: () => Promise; /** Toggle voice: start if idle/error, stop if active. */ voiceToggle: () => Promise; /** * Set or clear the signed end-user identity after setup. Call on login * (`setUser({ id, hash })`) and logout (`setUser(undefined)`). Switching to a * different id or logging out rotates the stored session token; the first * login after anonymous use keeps it so pre-login history can be claimed. */ setUser: (user?: UserIdentity) => void; /** Subscribe to tool-call completion events; returns an unsubscribe function. */ subscribeToToolEvents: (handler: ToolCallEventHandler) => () => void; /** Subscribe to chat + voice state changes. */ subscribeToState: (handler: (state: YakState) => void) => () => void; /** Mount the widget into the DOM. */ mount: () => void; /** Tear down the widget and remove its listeners. */ destroy: () => void; }; /** * Creates a yak widget (chat + voice) for Angular. * Call `mount()` in `ngOnInit` and `destroy()` in `ngOnDestroy`. */ export declare function createYakProvider(options: YakProviderOptions): YakApi; //# sourceMappingURL=service.d.ts.map