import { type FetchLike } from './monitor.js'; export declare const DAEMON_RECOVERY_MAX_ATTEMPTS = 6; export declare const DAEMON_RECOVERY_INITIAL_BACKOFF_MS = 1000; export declare const DAEMON_RECOVERY_MAX_BACKOFF_MS = 5000; export declare const DAEMON_RECOVERY_DEADLINE_MS = 60000; export interface DaemonGeneration { bootId: string; pid: number; startedAt: number; stateDir: string; } export type DaemonGenerationProbe = { state: 'ready'; generation: DaemonGeneration; } | { state: 'unavailable'; reason: string; }; export type DaemonGenerationObservation = { kind: 'baseline' | 'stable' | 'available'; generation: DaemonGeneration; } | { kind: 'changed'; previous: DaemonGeneration; generation: DaemonGeneration; } | { kind: 'lost' | 'unavailable'; previous?: DaemonGeneration; reason: string; }; interface GenerationProbeDeps { readText?(path: string): string; canonicalize?(path: string): string; } /** * Corroborate the loopback daemon's unauthenticated `/info`, its credentialed * identity-index readiness route, and its local boot-generation record. The * index enforces auth when the daemon visibility requires it; open visibility * deliberately does not. No source is sufficient * alone: `/info` has no boot id, the identity index has no generation, and a * stale `ready` file can outlive the process that wrote it. */ export declare function probeDaemonGeneration(fetch: FetchLike, env: NodeJS.ProcessEnv, deps?: GenerationProbeDeps): Promise; export declare class DaemonGenerationObserver { private current?; private unavailable; observe(probe: DaemonGenerationProbe): DaemonGenerationObservation; } export declare function daemonRecoveryBackoff(attempt: number): number; export type RecoveryPath = 'agent' | 'owner'; export type RecoveryPathResult = { ok: true; } | { ok: false; reason: string; }; export interface RoleRecoveryControllerOptions { role: string; identity: string; stateDir: string; now(): number; sleep(ms: number): Promise; recoverAgent(epoch: string): Promise; recoverOwner(epoch: string): Promise; log(line: string): void; } export interface RecoveryStatus { version: 1; identity: string; epoch: string; state: 'recovering' | 'recovered' | 'degraded' | 'cancelled'; paths: Record; updatedAt: string; } export declare function readDaemonRecoveryStatus(dir: string): RecoveryStatus | undefined; /** Per-role, per-generation bounded recovery with path-level fault isolation. */ export declare class RoleRecoveryController { private readonly options; private token; private activeEpoch?; private active?; private status?; constructor(options: RoleRecoveryControllerOptions); recover(generation: DaemonGeneration): Promise; cancel(): void; noteLoss(reason: string): void; private write; } export {};