export interface CliRelease { version: string; sha256: string; } export interface Caps { edition?: string; cli?: CliRelease | null; } /** semver-ish compare: -1 (ab). Ignores prerelease tags. */ export declare function compareVersions(a: string, b: string): number; /** * Enabled = explicit flag wins; else default ON for EVERY edition. * * Cloud used to default OFF, which — with nothing at install/init ever turning * it on — meant SaaS customers silently ran a stale, buggy collector forever * and never received fixes. That's a dead end, not a security posture. The * update is same-origin only and sha256-pinned to what the server advertises, * so default-on just means "trust the server you're already syncing to." Set * CHAT_RECALL_AUTO_UPDATE=0 to opt out. */ export declare function isAutoUpdateEnabled(_edition: string | undefined, flag: string | undefined): boolean; export declare const tarballUrl: (base: string) => string; /** The higher of two versions, treating an unparseable one as older. */ export declare function newerOf(a: string, b: string | null): string; /** * The version currently ON DISK, read fresh every call. * * Deliberately not cached and deliberately not the module-load constant: the * whole point is to notice that an update already landed underneath a * long-running process. Returns null when the manifest cannot be read, which * leaves the caller's own value in charge rather than inventing one. */ export declare function installedVersion(): string | null; export interface UpdatePlan { update: boolean; reason: string; url?: string; sha256?: string; from?: string; to?: string; } /** Pure: decide whether to update, and to what — no I/O. */ export declare function planAutoUpdate(base: string, caps: Caps, ownVersion: string, flag: string | undefined): UpdatePlan; /** * Remove staging dirs left behind by older versions. * * The cleanup below only helps someone who installs a build that HAS it. Every * machine that ran an earlier version is already carrying the wreckage — the * measured case was 5,889 directories and 5.1 GB, and fixing the leak does not * give that disk back. So the updater also sweeps on the way past. * * ONLY OUR OWN, and only once they are cold: * - the name must be `cr-update-` + exactly six characters, mkdtemp's shape on * every platform, so a directory called `cr-update-notes` is never touched; * - it must hold nothing but `chat-recall.tgz`, which is the only file this * code ever writes there — anything else means it is not ours; * - it must be older than an hour, so a concurrent updater's live staging dir * is never pulled out from under it. * * Defaults to `tmpdir()`, the same root mkdtemp writes to, so it follows TMPDIR * on macOS (`/var/folders/…/T`) and %TEMP% on Windows rather than assuming * `/tmp`. macOS purges that directory itself eventually; Linux mostly does not, * which is where the backlog was measured. * * Best-effort by design: a sweep that throws must not fail an update. */ export declare function sweepStaleStaging(root?: string, now?: number): number; export interface UpdateDeps { download: (url: string) => Promise; install: (tgzPath: string) => void; restart: (platform: NodeJS.Platform) => void; platform?: NodeJS.Platform; /** Version actually on disk after the install — the post-condition check. */ verify?: () => string | null; } export interface UpdateResult { updated: boolean; reason: string; from?: string; to?: string; } /** Execute a plan: download → checksum-verify → install → restart. */ export declare function executeAutoUpdate(plan: UpdatePlan, deps: UpdateDeps): Promise; /** * The npm prefix the RUNNING copy was installed into. * * `/lib/node_modules/chat-recall/dist/auto-update.js` → ``. * Returns null when this file is not inside a node_modules tree (a source * checkout, a bundled binary), where there is nothing to reinstall over. */ export declare function runningPrefix(moduleUrl?: string): string | null; type UpdateState = { target?: string; failures?: number; }; export declare function readUpdateState(): UpdateState; /** True when this device has already given up on installing `target`. */ export declare function hasGivenUpOn(target: string, st?: UpdateState): boolean; /** Count a failed attempt; returns the new consecutive count for `target`. */ export declare function noteUpdateFailure(target: string): number; /** A successful install clears the brake. */ export declare function clearUpdateFailures(): void; export declare function runAutoUpdate(base: string, authHeaders: Record, ownVersion: string, deps?: Partial): Promise; export {}; //# sourceMappingURL=auto-update.d.ts.map