import type { Activity, ConversationEvent } from "@cubos/agent-sdk"; export interface UseConversationEventsOptions { /** * Events per page. Counts events, not messages — the log holds the agent's * tool calls and bookkeeping too. */ pageSize?: number; /** Fires for each event as it arrives, in stream order, after it has been * folded into `events`. For cross-cache effects, not for rendering. */ onEvent?: (event: ConversationEvent) => void; } export interface UseConversationEventsResult { /** Oldest first, deduped by id. A row that changes — a tentative event * consolidated, a delivery receipt — replaces the one held. */ events: ConversationEvent[]; /** The first page has landed. Distinguishes "loading" from "empty". */ initialLoaded: boolean; /** There is older history behind what is held. */ hasOlder: boolean; isLoadingOlder: boolean; /** Prepends the page before the oldest event held; resolves with how many * were added, so a caller can tell "nothing came back" from "we reached the * beginning". */ loadOlder: () => Promise; /** * Whether a turn is running, from the frames that ride this same stream — * so "the turn ended" can never overtake the events it ended with. Reading it * from anywhere else is what puts a finished turn on screen with no answer * in it. */ activity: Activity; } /** * The conversation's event log, live. * * The companion to `useConversation` for a UI that draws the log itself rather * than a conversation — an operator console, an audit view, an activity tree. * Same connection and same guarantees; what differs is only how much is hidden: * `useConversation` hands you `Message`s, this hands you the rows. * * What it owns is the part that is easy to get subtly wrong, and that every app * writing this by hand has had to rediscover: the first page, then a stream that * resumes from that page's cursor so nothing lands twice and nothing is missed, * upsert-by-id because the server re-emits a row it mutated, and paging * backwards while events keep arriving at the other end. */ export declare function useConversationEvents(conversationId: string | null, options?: UseConversationEventsOptions): UseConversationEventsResult;