import { Message, Session } from '../types'; import { AgUiEvent, AgUiContext, AgUiMessage, AgUiTool, AgUiToolCallInfo } from './types'; export interface UseAgUiOptions { /** * URL of the AG-UI compatible agent endpoint. */ agent: string; /** * Initial sessions to populate the chat. */ initialSessions?: Session[]; /** * Initial active session ID. */ initialActiveSessionId?: string; /** * Tools to expose to the agent. */ tools?: AgUiTool[]; /** * Context to send with each run. */ context?: AgUiContext[]; /** * Additional properties forwarded to the agent. */ forwardedProps?: Record; /** * Custom headers for the HTTP request. */ headers?: Record; /** * Called when a tool call is received from the agent. */ onToolCall?: (toolCall: AgUiToolCallInfo) => Promise | void; /** * Called when the agent run encounters an error. */ onError?: (error: Error) => void; /** * Called when an AG-UI event is received (for debugging/logging). */ onEvent?: (event: AgUiEvent) => void; } export interface UseAgUiReturn { /** * All chat sessions. */ sessions: Session[]; /** * The currently active session ID. */ activeSessionId: string | undefined; /** * Whether the agent is currently processing. */ isLoading: boolean; /** * Select a session by ID. */ selectSession: (sessionId: string) => void; /** * Delete a session by ID. */ deleteSession: (sessionId: string) => void; /** * Create a new empty session. */ createSession: () => void; /** * Send a message to the agent. */ sendMessage: (message: string) => void; /** * Stop the current agent run. */ stopMessage: () => void; } /** * Appends a message to the given session. */ export declare function addMessageToSession(sessions: Session[], sessionId: string, message: Message): Session[]; /** * Replaces the content of a message within the given session. */ export declare function updateMessageInSession(sessions: Session[], sessionId: string, messageId: string, content: string): Session[]; /** * Converts reachat Session history into AG-UI messages. */ export declare function sessionsToAgUiMessages(session: Session): AgUiMessage[]; /** * Parses a single SSE data line, returning the event or an Error * if the JSON is malformed. */ export declare function parseSSELine(line: string): AgUiEvent | Error | null; /** * Parses an SSE stream from a Response into AG-UI events. */ export declare function parseSSE(response: Response, signal: AbortSignal): AsyncGenerator; /** * React hook that connects to an AG-UI protocol endpoint and provides * all the props needed for the reachat `` component. * * @example * ```tsx * const agui = useAgUi({ agent: 'https://my-agent.example.com/run' }); * * * * * * * * ``` */ export declare function useAgUi({ agent, initialSessions, initialActiveSessionId, tools, context, forwardedProps, headers, onToolCall, onError, onEvent }: UseAgUiOptions): UseAgUiReturn;