import { ReactNode } from 'react'; import { Vowel } from '../core'; import { VoiceSessionState } from '../managers'; import { FloatingCursorConfig } from '../types'; /** * Vowel Context type */ export interface VowelContextType { /** Vowel client instance (null if not initialized) */ client: Vowel | null; /** Current session state */ state: VoiceSessionState; /** Start a voice session */ startSession: () => Promise; /** Stop the current session */ stopSession: () => void; /** Toggle session on/off */ toggleSession: () => Promise; /** Clear transcript history */ clearTranscripts: () => void; /** * Notify the AI about an app event * Triggers an AI voice response without requiring user speech input * * @param eventDetails - Description of the event * @param context - Optional context data */ notifyEvent: (eventDetails: string, context?: Record) => Promise; /** * Send text to the AI for processing * Lower-level method for custom text interactions * * @param text - Text to send to the AI */ sendText: (text: string) => Promise; /** * Update the dynamic context that gets appended to system prompt. * Context is stringified, wrapped in `` tags and sent via session.update. * * When context changes, a session.update event is automatically sent * to update the system prompt so the AI knows about the current context. * * @param context - Context object to append to system prompt. Use null to clear. * * @example * ```tsx * const { updateContext } = useVowel(); * * useEffect(() => { * updateContext({ page: 'product', productId: 'iphone-15-pro' }); * return () => updateContext(null); // Clear on unmount * }, [product]); * ``` */ updateContext: (context: Record | null) => void; /** * Get current context value * * @returns Current context object (null if no context set) * * @example * ```tsx * const { getContext } = useVowel(); * const currentContext = getContext(); * ``` */ getContext: () => Record | null; } /** * Props for VowelProvider */ export interface VowelProviderProps { /** Vowel client instance (can be null if not yet initialized) */ client: Vowel | null; /** Children to render */ children: ReactNode; /** * Optional: Floating cursor configuration for React mode * When enabled, cursor will be rendered as a native React component * * @default { enabled: true } (enabled by default) * * Set to false to disable: * @example * ```tsx * * * * ``` * * Or customize appearance: * @example * ```tsx * * * * ``` */ floatingCursor?: FloatingCursorConfig | false; /** * How to handle transient null clients. * * - `sticky` (default): keep the last known good client across transient nulls. * - `strict`: immediately clear the active client when prop becomes null. */ clientMode?: "sticky" | "strict"; /** * In sticky mode, how long to wait before releasing an idle client after prop=null. * * This timeout is ignored while a session is live (connected/connecting/resuming/disconnecting). * * @default 5000 */ nullClientGraceMs?: number; } /** * Provider component for Vowel voice agent * Wrap your app with this to enable voice interactions * * This is the ONLY provider users need to manage. * Floating cursor is enabled by default and automatically wrapped. * * @example Basic usage (floating cursor enabled by default) * ```tsx * import { VowelProvider, VowelAgent } from '@vowel.to/client/react'; * import { vowel } from './vowel.client'; * * function App() { * return ( * * * * ); * } * ``` * * @example Disable floating cursor * ```tsx * * * * ``` * * @example Customize floating cursor * ```tsx * * * * ``` */ export declare function VowelProvider({ client, children, floatingCursor, clientMode, nullClientGraceMs, }: VowelProviderProps): import("react/jsx-runtime").JSX.Element; /** * Hook to access Vowel context * * @example * ```tsx * function MyComponent() { * const { state, toggleSession, client } = useVowel(); * * // Don't render if client is not available yet * if (!client) { * return null; * } * * return ( * * ); * } * ``` */ export declare function useVowel(): VowelContextType; //# sourceMappingURL=VowelProviderSimple.d.ts.map