/** * useConversation — the headless core of the React bindings. * * This hook owns the entire conversation lifecycle (connect → session → stream) * and exposes nothing but state + actions, so you can render a completely custom * UI with zero styling opinions from this package. `` and the parts * components are thin views over exactly this hook. * * It is the React analogue of the widget's `ConversationController`: same wire * flow, same defensive payload reading, but message state lives in React so your * components re-render on every streamed token. */ import { SmoothAgentClient } from '../client.js'; import type { ChatMessage, ConnectionStatus } from './types.js'; export interface UseConversationOptions { /** WebSocket endpoint, e.g. `wss://your-host/ws`. Ignored if `client` is given. */ url?: string; /** * Bring your own pre-constructed {@link SmoothAgentClient} (e.g. one created by * a {@link SmoothOperatorProvider} and shared, or one with a custom transport * for tests). When provided, the hook does NOT own the client's lifecycle — * it won't disconnect it on unmount. */ client?: SmoothAgentClient; /** UUID of the agent to converse with. */ agentId: string; /** Optional display name for the user participant. */ userName?: string; /** Optional email for the user participant. */ userEmail?: string; /** * Short-lived auth token for BYO-auth deployments. Appended to the WS URL as * `?token=…` (browsers can't set WebSocket headers), which the server reads * into the request `Principal` / `AccessContext`. Ignored if `client` is given. */ authToken?: string; /** Connect automatically on mount. Default `true`. */ autoConnect?: boolean; /** Message shown in the assistant bubble when the connection fails mid-turn. */ connectionErrorMessage?: string; } export interface UseConversationResult { /** Current connection lifecycle state. */ status: ConnectionStatus; /** The ordered message list (re-renders on every streamed token). */ messages: ChatMessage[]; /** Last error message, or `null`. */ error: string | null; /** The active session id once a session has been created. */ sessionId: string | null; /** Open the transport + create a conversation session. Idempotent. */ connect: () => Promise; /** Submit a user message and stream the assistant reply into `messages`. */ send: (text: string) => Promise; /** Tear down the client (only if this hook owns it) and reset to `closed`. */ disconnect: () => void; } export declare function useConversation(options: UseConversationOptions): UseConversationResult; //# sourceMappingURL=use-conversation.d.ts.map