import type { VersionUpdate } from "@oh-my-pi/pi-tui/prompt/welcome"; /** A finished attempt at a version holds off the next attempt at that version this long. */ export declare const RETRY_AFTER_MS: number; /** Worker phases; `done`, `current`, and `failed` end a run. */ export type AutoUpdatePhase = "checking" | "downloading" | "installing" | "done" | "current" | "failed"; /** The worker's status file. */ export interface AutoUpdateState { phase: AutoUpdatePhase; /** Version the spawning launch's check offered; keys the retry hold-off. */ target?: string; /** Version being installed, or (`done`) the version the PATH launcher now reports. */ version?: string; /** Bytes downloaded so far of `total` (`downloading`). */ received?: number; total?: number; /** Why the run failed. */ error?: string; /** `Date.now()` at the write. */ at: number; } /** Where {@link runAutoUpdate} reports. */ export interface AutoUpdateSinks { /** Show, or with `null` clear, the indicator after the welcome banner's version. */ show(update: VersionUpdate | null): void; /** Fall back to the startup notice that tells the user to run `omp update`. */ notify(version: string): void; } /** What the welcome banner shows for a worker's `state`; null when nothing (no update, or no version to name). */ export declare function describeAutoUpdate(state: AutoUpdateState): VersionUpdate | null; /** * Whether a launch whose check offered `target` starts a worker, given the * status `last` left by the previous run: always for a new version, else once * that run is {@link RETRY_AFTER_MS} old, however it ended. */ export declare function shouldStartWorker(last: AutoUpdateState | undefined, target: string, now?: number): boolean; /** * Launch side of auto-update. Follows a worker another launch already runs; * otherwise, once `check` resolves to a newer version, starts a worker, unless * a recent attempt at that version finished: then it shows that attempt's * install as ready, or after a failure the startup notice. Where omp cannot * update itself (Tern, Nix, a source checkout) the check only feeds the notice. * Resolves when the worker ends or nothing needs doing; never throws. */ export declare function runAutoUpdate(check: Promise, sinks: AutoUpdateSinks): Promise; /** * Worker entry (`__omp_worker_auto_update`): install the newest release the * way `omp update` would, mirroring progress into the status file, and record * the outcome. Exits at once when another worker holds the status lock. */ export declare function runAutoUpdateWorker(): Promise;