export interface RunStuckState { isStuck: boolean; runId: string | null; status: string | null; lastProgressAt: number | null; stuckSinceMs: number | null; lastProgressSeq: number | null; heartbeatAt: number | null; heartbeatSinceMs: number | null; dispatchMode: string | null; hasInFlightWork: boolean | null; /** * The server reported no run in flight on this thread on two polls in a row. * A chat still showing "running" at that point has lost the run's ending and * should reload the thread, not keep waiting. */ serverSettled: boolean; /** * The last polls failed, so nothing here says whether the run is alive. * Distinct from "no run": the other fields are the last answer, not a fresh one. */ statusUnreadable: boolean; } export interface UseRunStuckDetectionOptions { threadId: string | null | undefined; enabled?: boolean; /** * Whether the chat is showing a run in progress. Each time it turns on, the * hook starts over, so `serverSettled` only ever reflects polls taken after * the chat began waiting, never an idle answer from before the user sent. */ awaitingResponse?: boolean; stuckThresholdMs?: number; /** * Threshold for BACKGROUND-dispatched runs (dispatchMode starts with * "background"). The server owns recovery for these — its run-manager * no-progress backstop (150s) and unclaimed-run sweep act first — so the * user-facing "stuck" affordance is a late fallback, not a race against * them. Selected inside the hook because the dispatch mode is only known * from the same poll response that computes the elapsed time. */ backgroundStuckThresholdMs?: number; liveBackgroundStuckThresholdMs?: number; pollIntervalMs?: number; apiUrl?: string; } export declare const DEFAULT_BACKGROUND_STUCK_THRESHOLD_MS = 180000; export declare const DEFAULT_LIVE_BACKGROUND_STUCK_THRESHOLD_MS: number; export declare function useRunStuckDetection({ threadId, enabled, awaitingResponse, stuckThresholdMs, backgroundStuckThresholdMs, liveBackgroundStuckThresholdMs, pollIntervalMs, apiUrl, }: UseRunStuckDetectionOptions): RunStuckState; export declare function useAbortRun(apiUrl?: string): (runId: string, reason?: string) => Promise;