import type { ClientRole } from '../../../core/runtime/broker-protocol.js'; import type { BrokerToClient } from '../../../core/runtime/broker-protocol.js'; import type { AttachSession } from './context.js'; export interface ReconnectHooks { /** This viewer's CURRENT role, read at send time — see `sendHello`. */ role: () => ClientRole; /** This viewer's stable client id, echoed by the broker to prove control. */ clientId: string; /** Every broker frame, in wire order. */ onFrame: (frame: BrokerToClient) => void; setNotice: (msg: string, opts?: { sticky?: boolean; }) => void; /** True once teardown has begun — the supervisor loop's exit condition. */ isTornDown: () => boolean; /** End the session. `node-done` is a clean finalize (the node pushed its * final report) and closes the pane; `broker-gone` freezes the corpse. */ teardown: (reason: 'node-done' | 'broker-gone') => void; /** Called once each time the node is first seen as dormant. An idle-released * broker has settled its turn and will relay no final session event, so the * viewer must clear its live-only display itself. */ onEnterDormancy: () => void; } export interface ReconnectSupervisor { /** Send the hello handshake. Called once after `tui.start()`, then again on * every successful redial. */ sendHello: () => void; /** True while the node has no live broker — the input layer routes a * submitted prompt through a wake message rather than a dead socket. */ isDormant: () => boolean; /** The last socket-level error, for a broker-gone teardown message. */ lastSocketError: () => string | undefined; /** Install the permanent frame/error/close handlers. Call once, AFTER the * connect race is settled and its temporary listeners are gone. */ install: () => void; } export declare function createReconnect(ctx: Pick, hooks: ReconnectHooks): ReconnectSupervisor;