import type { ReleaseChannel } from './emergency-upgrade.js'; import { type VersionPointer } from './version-store.js'; export type UpgradeJobPhase = 'prepared' | 'stopping' | 'installing' | 'restarting' | 'completed' | 'failed'; export interface UpgradeJob { schemaVersion: 1; jobId: string; sourceVersion: string; targetVersion: string; channel: ReleaseChannel; phase: UpgradeJobPhase; createdAt: string; updatedAt: string; launchSpecPath?: string; error?: string; } export declare const EXTERNAL_UPGRADE_PROTOCOL_VERSION = 1; export type ExternalUpgradeOperation = 'upgrade' | 'rollback'; export type ExternalUpgradePhase = 'created' | 'downloading' | 'verifying' | 'staging' | 'self-checking' | 'worker-starting' | 'worker-ready' | 'shutdown-requested' | 'old-agent-stopped' | 'switching' | 'target-starting' | 'target-local-health' | 'relay-pending' | 'rolling-back' | 'rollback-starting' | 'rollback-local-health' | 'repair-starting' | 'completed' | 'rolled-back' | 'repair-required' | 'failed'; export interface ProcessIdentity { pid: number; processStartIdentity: string; } export interface ExternalUpgradeJob { schemaVersion: 2; jobId: string; requestId: string; operation: ExternalUpgradeOperation; channel: ReleaseChannel; sourceVersion: string; targetVersion: string; phase: ExternalUpgradePhase; dataRoot: string; launchSpecPath: string; launchSpecDigest: string; oldRuntime: ProcessIdentity & { processInstanceId: string; sessionId: string; sessionUrlHash: string; }; worker?: ProcessIdentity & { protocolVersion: 1; }; targetLauncher?: ProcessIdentity; rollbackLauncher?: ProcessIdentity; targetRuntime?: ProcessIdentity & { processInstanceId: string; }; rollbackRuntime?: ProcessIdentity & { processInstanceId: string; }; repairLauncher?: ProcessIdentity; repairRuntime?: ProcessIdentity & { processInstanceId: string; }; restartOwner: 'worker'; sourceSelection: VersionPointer; targetSelection: VersionPointer; lastKnownGoodSelection: VersionPointer; lockNonce: string; handoffExpiresAt: string; createdAt: string; updatedAt: string; error: string | null; } export declare const EXTERNAL_TERMINAL_PHASES: readonly ExternalUpgradePhase[]; export declare function isExternalUpgradeTerminal(phase: ExternalUpgradePhase): boolean; export declare function getUpgradeRoot(): string; export declare function getExternalUpgradeJobDirectory(jobId: string): string; export declare function getExternalUpgradeJobPath(jobId: string): string; export declare function getExternalUpgradeEventsPath(jobId: string): string; export declare function createUpgradeJob(input: { sourceVersion: string; targetVersion: string; channel: ReleaseChannel; launchSpecPath?: string; now?: Date; }): UpgradeJob; export declare function updateUpgradeJob(jobId: string, phase: UpgradeJobPhase, options?: { error?: string; now?: Date; }): UpgradeJob; export declare function validateExternalUpgradeJob(value: unknown): ExternalUpgradeJob; export declare function createExternalUpgradeJob(input: Omit & { operation?: ExternalUpgradeOperation; now?: Date; }): ExternalUpgradeJob; export declare function loadExternalUpgradeJob(jobId: string): ExternalUpgradeJob; export declare function loadLatestExternalUpgradeJob(): ExternalUpgradeJob | null; export declare function findExternalUpgradeJobByRequestId(requestId: string): ExternalUpgradeJob | null; export declare function transitionExternalUpgradeJob(jobId: string, phase: ExternalUpgradePhase, options?: { worker?: ExternalUpgradeJob['worker']; targetLauncher?: ExternalUpgradeJob['targetLauncher']; rollbackLauncher?: ExternalUpgradeJob['rollbackLauncher']; targetRuntime?: ExternalUpgradeJob['targetRuntime']; rollbackRuntime?: ExternalUpgradeJob['rollbackRuntime']; repairLauncher?: ExternalUpgradeJob['repairLauncher']; repairRuntime?: ExternalUpgradeJob['repairRuntime']; lockNonce?: string; handoffExpiresAt?: string; clearRepairLauncher?: boolean; clearRepairRuntime?: boolean; error?: string | null; now?: Date; }): ExternalUpgradeJob; export declare function appendExternalUpgradeEvent(job: ExternalUpgradeJob, code: string, detail?: string): void; export declare function markExternalUpgradeRepaired(jobId: string, now?: Date): ExternalUpgradeJob;