/** * Exactly one SSE reader may fold a given run/turn into UI state. * * Two readers attach to the same run routinely: the chat adapter's own stream, * and AssistantChat's reconnect reader for runs with no live adapter stream * (page reload, tab restore). When both are attached they build two independent * accumulators from the same events, and the UI renders both — duplicate tool * cards (one spinning, one static) and the same assistant text streaming twice. * * The previous guard read a React ref (`isRuntimeRunningRef`) at attach time and * re-checked it from a 1s poll. That is a race, not a lock: the ref lags a * render behind, the poll is skipped while the tab is hidden, and the refs were * per-component-instance while MultiTabAssistantChat mounts several instances * against one run. Ownership therefore lives here — module scope, one registry * per browser tab, claimed and checked synchronously. * * Claims are advisory in one direction only: a reader that does not hold the * claim must not mutate UI state. It may still drain its socket to completion. */ export declare function createRunStreamToken(label?: string): symbol; /** * Take ownership of a run's UI fold. When a logical turn id is present, all * background continuation run ids share one claim. Returns false when another * live reader already holds it — the caller must not attach, or must attach * read-only. Re-claiming with the same token is a no-op success so retry loops * are safe. */ export declare function claimRunStream(threadId: string, runId: string, token: symbol, turnId?: string): boolean; export declare function preemptRunStream(threadId: string, runId: string, token: symbol, turnId?: string): boolean; export declare function ownsRunStream(threadId: string, runId: string, token: symbol, turnId?: string): boolean; /** Release only if still held by this token, so a late unmount cannot free a successor's claim. */ export declare function releaseRunStream(threadId: string, runId: string, token: symbol, turnId?: string): void; export declare function __resetRunStreamOwnership(): void;