import { type MaintenanceConfig } from '../global-config.js';
import { type RestartIntent } from '../services/restart-intent-store.js';
export interface MaintenanceState {
    /** Local date the auto-update run was last handled (fired or skipped). */
    autoUpdate?: {
        lastDate: string;
    };
}
export interface MaintenanceDeps {
    now: () => number;
    readConfig: () => MaintenanceConfig | undefined;
    readState: () => MaintenanceState;
    writeState: (s: MaintenanceState) => void;
    anyBusy: () => boolean;
    isLocalDev: () => boolean;
    /** Current on-disk botmux version (read fresh — changes after runUpdate). */
    currentVersion: () => string;
    /** Runs `npm install -g botmux@latest` (download/install only). Throws on failure. */
    runUpdate: () => void;
    writeIntent: (intent: RestartIntent) => void;
    /** Spawn a detached `botmux restart` (this process is then killed by pm2). */
    triggerRestart: () => void;
    log?: (msg: string) => void;
}
/**
 * One maintenance tick. The schedule is driven solely by auto-update's time
 * (once/day). At that time: install the latest version (download only), and
 * — only if a newer version was actually installed AND the auto-restart toggle
 * is on — restart to apply it. A busy session anywhere skips the whole run to
 * the next day; auto-restart off ⇒ install only (applied on the next restart).
 * Pure orchestration over injected deps.
 */
export declare function runMaintenanceTick(deps: MaintenanceDeps): void;
export declare function maintenanceStatePathIn(dir: string): string;
export declare function readMaintenanceStateTo(dir: string): MaintenanceState;
export declare function writeMaintenanceStateTo(dir: string, s: MaintenanceState): void;
/** How often to evaluate the schedule. Sub-minute so an HH:MM target fires
 *  within the same minute it's reached. */
export declare const MAINTENANCE_TICK_MS = 60000;
/** Where the auto-restart driver's stdout/stderr is captured, so a failed
 *  restart-to-apply is diagnosable (previously stdio was 'ignore'). */
export declare function maintenanceRestartLogPath(): string;
/**
 * Build the command to launch `botmux restart` for applying an auto-update.
 *
 * The restart driver must NOT remain a descendant of the daemon it's about to
 * tear down: `botmux restart` deletes botmux-0 (the very daemon that spawned
 * this), and when PM2 kills botmux-0 a child in its process tree gets
 * interrupted — so the restart aborts after deleting botmux-0 and never
 * restarts the rest (the 2026-06-11 incident). `setsid` starts it in a brand
 * new session, reparented to init, immune to botmux-0's teardown. Without
 * setsid we fall back to a plain spawn (still detached by the caller).
 */
export declare function buildRestartLauncher(node: string, cliEntry: string, hasSetsid: boolean): {
    cmd: string;
    args: string[];
};
/** Start the maintenance loop. Call only on the primary daemon (bot-0). */
export declare function startMaintenance(): void;
export declare function stopMaintenance(): void;
//# sourceMappingURL=maintenance.d.ts.map