/** * The cadence half of the same mechanism, re-exported here so every consumer * reaches "when to look" and "what to do when something is found" through one * module instead of two competing update stories. See update-schedule.ts. */ export { BOOT_SETTLE_CHECK_DELAY_MS, DEFAULT_UPDATE_BUSY_RETRY_MS, DEFAULT_UPDATE_CHECK_INTERVAL_MS, PeriodicUpdateLoop, type PeriodicCheckOutcome, type PeriodicUpdateLoopOptions, } from './update-schedule.js'; export declare function normalizeVersion(version: string): string; /** * Compares two version strings component-wise as dotted non-negative * integers (a leading "v" is ignored, matching the "vX.Y.Z" release tag * format). Returns -1/0/1 for ab. Non-numeric or missing * components are treated as 0, so "1.2" and "1.2.0" compare equal. */ export declare function compareVersions(a: string, b: string): -1 | 0 | 1; /** * Extracts the release tag from a GitHub "/releases/latest" redirect * Location header (everything after the final slash of the redirect target). */ export declare function parseReleaseTagFromLocation(location: string | null | undefined): string | null; /** Minimal fetch shape so tests inject a stub instead of the real network. */ export interface UpdateFetchLike { (url: string, init?: { method?: string; redirect?: 'manual' | 'follow' | 'error'; }): Promise<{ readonly ok: boolean; readonly status: number; readonly url: string; readonly headers: { get(name: string): string | null; }; text(): Promise; arrayBuffer(): Promise; }>; } /** * Resolves the latest release tag via a HEAD request with redirects NOT * followed, reading the tag out of the redirect Location header. Throws if * no tag can be resolved, callers must not silently fall back to * "already current". */ export declare function resolveLatestReleaseTag(fetchImpl: UpdateFetchLike, releasesLatestUrl: string): Promise; export declare const CHECKSUM_MANIFEST_NAME = "SHA256SUMS.txt"; export interface ReleaseArtifactNames { readonly app: string; readonly daemon: string; } export declare function resolveArtifactNames(platform: string, arch: string): ReleaseArtifactNames | null; export interface SqliteVecAsset { /** Release asset filename, e.g. `sqlite-vec-linux-x64.so`. */ readonly assetName: string; /** Directory name the loader resolves, e.g. `sqlite-vec-linux-x64`. */ readonly dirName: string; /** File the loader opens inside that directory, e.g. `vec0.so`. */ readonly fileName: string; } /** * Names the sqlite-vec native addon for a platform/arch. Unlike the binaries * (whose release tag maps darwin to "macos"), the addon keeps the Node-style * platform tag because that is exactly what the extension loader resolves at * `/lib/sqlite-vec--/vec0.`. */ export declare function resolveSqliteVecAsset(platform: string, arch: string): SqliteVecAsset | null; export declare function sha256(buffer: Buffer | Uint8Array): string; export declare function parseChecksumFile(contents: string): Map; /** * Verify a downloaded artifact's checksum against the parsed manifest. * An artifact with no entry in the manifest is a hard failure, identical * in severity to a mismatching entry, never treated as "unverifiable, so * skip the check". Throws naming the artifact and the manifest. */ export declare function verifyChecksum(artifactName: string, actual: string, expected: string | undefined, manifestName?: string): void; /** * Suffix under which every swap keeps the file it replaced, right beside the * live one. This is what makes rollback a one-command operation instead of a * re-download: the version that ran before the last update is always still * on disk at `.previous`. */ export declare const PREVIOUS_FILE_SUFFIX = ".previous"; /** Injectable filesystem surface for the swap/rollback policy. */ export interface UpdateFileIo { writeFile(path: string, data: Buffer): void; rename(from: string, to: string): void; chmod(path: string, mode: number): void; exists(path: string): boolean; mkdir(path: string): void; } export declare const realUpdateFileIo: UpdateFileIo; /** * Writes the new file beside the target, then renames over it, an atomic * replace on the same filesystem, so a currently-running process that * already opened the old file keeps its old inode instead of executing a * half-written file. Before the replace, the outgoing file is parked at * `.previous` (overwriting any older parked copy). */ export declare function swapFileAtomically(targetPath: string, buffer: Buffer, options: { executable: boolean; io?: UpdateFileIo; platform?: NodeJS.Platform; }): void; export interface UpdateTarget { /** Human label for receipts and errors, e.g. "daemon binary". */ readonly label: string; /** Absolute path the artifact installs to. */ readonly path: string; /** Release asset name to download and verify for this target. */ readonly assetName: string; /** Whether the installed file needs the execute bit. */ readonly executable: boolean; } export interface ApplyVerifiedUpdateOptions { readonly fetchImpl: UpdateFetchLike; /** Release download base, e.g. `https://github.com///releases/download/`. */ readonly downloadBaseUrl: string; readonly targets: readonly UpdateTarget[]; readonly io?: UpdateFileIo; readonly platform?: NodeJS.Platform; } /** * Downloads the checksum manifest and every target artifact, verifies ALL of * them, and only then swaps each into place with a kept previous copy. A * checksum failure on any artifact means zero files are touched. */ export declare function applyVerifiedUpdate(options: ApplyVerifiedUpdateOptions): Promise; export interface RollbackTarget { readonly label: string; readonly path: string; } export interface RollbackResult { /** Targets whose kept previous version is now live. */ readonly restored: readonly RollbackTarget[]; /** Targets with no kept previous version, left untouched. */ readonly skipped: readonly RollbackTarget[]; } /** * One-command rollback: every target with a kept `.previous` counterpart is * EXCHANGED with it, the previous version becomes live, and the version * being rolled back is itself kept at `.previous`, so a second rollback * rolls forward again. Three same-directory renames per file (atomic on * POSIX), never a copy; nothing is downloaded. */ export declare function rollbackKeptPrevious(targets: readonly RollbackTarget[], io?: UpdateFileIo): RollbackResult; //# sourceMappingURL=self-update.d.ts.map