import { type DkgConfig, type NetworkConfig, type ResolvedAutoUpdateConfig, type ResolvedUpdatePreferences } from '../config.js'; import { type UpdateHoldoffGate } from './auto-update-holdoff-gate.js'; import { type LastUpdateCheck } from './state.js'; export interface DaemonUpdateHoldoffGateDeps { au: Pick; /** The DKG home; the rollout deadline is kept in `/.update-holdoff.json`. */ dkgHome: string; isShuttingDown: () => boolean; /** Toggle the daemon's user-visible "is updating" flag. */ setUpdating: (updating: boolean) => void; log: (msg: string) => void; } /** Deterministic rng, clock and sleep for tests of the daemon gate. */ export interface UpdateGateSeams { rng?: () => number; now?: () => number; sleep?: (ms: number) => Promise; } /** * The rollout gate both daemon auto-update modes (git and npm) use: the jitter * window from config/env, and the persisted deadline policy over * `/.update-holdoff.json`, so a restart mid-hold resumes it. The * polling helpers below build their gates only through this function. */ export declare function createDaemonUpdateHoldoffGate(deps: DaemonUpdateHoldoffGateDeps, seams?: UpdateGateSeams): UpdateHoldoffGate; /** The timers polling is scheduled on. Injectable for tests. */ export interface UpdatePollingTimers { setTimeout(fn: () => unknown, ms: number): unknown; clearTimeout(handle: unknown): void; } /** What the daemon hands both polling helpers. */ export interface DaemonUpdatePollingDeps { /** The DKG home; the rollout deadline is kept in `/.update-holdoff.json`. */ dkgHome: string; isShuttingDown: () => boolean; setUpdating: (updating: boolean) => void; log: (msg: string) => void; lastUpdateCheck: LastUpdateCheck; /** Trigger the supervised restart after a successful install. */ onRestart: () => Promise; /** Test seams. */ timers?: UpdatePollingTimers; gateSeams?: UpdateGateSeams; } /** Running auto-update polling. `stop()` cancels the next check. */ export interface UpdatePolling { stop(): void; } /** * Start git-mode auto-update polling: one persisted rollout gate behind a * runCheck that runs shortly after boot and then `checkIntervalMinutes` after * each check finishes. */ export declare function startGitUpdatePolling(au: ResolvedAutoUpdateConfig, deps: DaemonUpdatePollingDeps): UpdatePolling; /** Poll interval when auto-update is disabled and npm mode only checks versions. */ export declare const CHECK_ONLY_INTERVAL_MINUTES = 30; export type NpmUpdatePollingOptions = /** Auto-apply: interval, channel and prerelease policy all come from `au`. */ { mode: 'npm-auto-apply'; au: ResolvedAutoUpdateConfig; nodeRole: 'edge' | 'core'; } /** Auto-update disabled: check and record the latest version on the given * policy every CHECK_ONLY_INTERVAL_MINUTES; no gate, nothing is installed. */ | { mode: 'npm-check-only'; policy: ResolvedUpdatePreferences; }; /** npm-mode counterpart to {@link startGitUpdatePolling}. */ export declare function startNpmUpdatePolling(opts: NpmUpdatePollingOptions, deps: DaemonUpdatePollingDeps): UpdatePolling; /** The daemon's auto-update startup state, as resolved from its config. */ export type DaemonUpdateMode = { mode: 'git'; au: ResolvedAutoUpdateConfig; } | { mode: 'git-disabled'; } | NpmUpdatePollingOptions /** A monorepo checkout never polls; it only says so when auto-update is enabled. */ | { mode: 'monorepo'; autoUpdateEnabled: boolean; }; /** * Resolve the daemon's auto-update state from its config, merged field by field * across ~/.dkg/config.json → network/.json → project.json. With auto-apply * disabled, npm mode still checks versions, on the operator's local policy * before the network default, so a disabled node with a local channel / * allowPrerelease pin observes its own cohort. */ export declare function resolveDaemonUpdateMode(config: Pick, network: Pick | null | undefined): DaemonUpdateMode; /** The per-mode starters. Injectable so tests can observe the dispatch. */ export interface UpdatePollingStarters { git: typeof startGitUpdatePolling; npm: typeof startNpmUpdatePolling; } /** * Log the daemon's auto-update mode and start polling for it. Returns the * running polling, or null when nothing polls. */ export declare function startDaemonUpdatePolling(state: DaemonUpdateMode, deps: DaemonUpdatePollingDeps, starters?: UpdatePollingStarters): UpdatePolling | null; /** What the daemon hands {@link startDaemonAutoUpdate}. */ export interface DaemonAutoUpdateContext { config: Pick; network: Pick | null | undefined; isShuttingDown: () => boolean; setUpdating: (updating: boolean) => void; log: (msg: string) => void; lastUpdateCheck: LastUpdateCheck; /** The daemon's shutdown; an update restarts through it with DAEMON_EXIT_CODE_RESTART. */ shutdown: (exitCode: number) => Promise; } /** * The daemon's auto-update handoff: resolve its mode from the config, start * polling with the deadline under the DKG home, and return the polling so * shutdown can stop it. `start` is injectable for tests. */ export declare function startDaemonAutoUpdate(daemon: DaemonAutoUpdateContext, start?: typeof startDaemonUpdatePolling): UpdatePolling; //# sourceMappingURL=auto-update-polling.d.ts.map