import type { WorkerConfig } from "./config"; export interface PendingUpdate { id: string; dockerImage?: string; workerVersion?: string; message: string; force: boolean; } export type UpdateStatus = "idle" | "updating" | "updated" | "failed"; /** * Manages OTA updates for the worker node. * * Lifecycle: * 1. API heartbeat response includes `pendingUpdate` when an update is available. * 2. UpdateManager stores it and waits for the worker to become idle (0 active containers). * 3. When idle, it pauses the BullMQ worker (no new jobs), performs the update * (docker pull + npm update), verifies, then resumes the worker. * 4. Acknowledges the update to the API. * * If `force` is true, the update proceeds immediately regardless of active jobs. */ export declare class UpdateManager { private readonly config; private readonly callbacks; private pendingUpdate; private _status; private _updating; constructor(config: WorkerConfig, callbacks: { /** Pause the BullMQ worker so no new jobs are picked up. */ pauseWorker: () => Promise; /** Resume the BullMQ worker after update. */ resumeWorker: () => Promise; /** Get current number of active containers (jobs + helpers). */ getActiveContainers: () => number; /** * Restart the worker process so a freshly-installed npm package takes * effect. `npm update` only changes files on disk; the running process * keeps executing the old code until it relaunches. */ requestRestart: (reason: string) => void; }); get status(): UpdateStatus; get isUpdating(): boolean; /** Called from heartbeat response — stores the pending update. */ setPendingUpdate(update: PendingUpdate): void; /** * Called periodically (from heartbeat loop). * Checks if conditions are right to apply the pending update. */ checkAndApply(): Promise; private applyUpdate; private pullDockerImage; /** * Run npm update and report whether the installed version actually changed. * Returns false when the package was already up to date — the caller uses * this to skip a pointless restart (and avoid re-applying the same update in * a loop after relaunch). */ private updateWorkerPackage; /** Read the currently-installed @nikx/dory-worker version, or null. */ private getInstalledVersion; private verifyDocker; private acknowledgeUpdate; } //# sourceMappingURL=update-manager.d.ts.map