/** How long a cached dist-tag lookup is considered current. */ export declare const UPDATE_CACHE_TTL_MS: number; export type UpdateCache = { /** ISO timestamp of the last successful registry read. */ checkedAt: string; /** dist-tag → version, as returned by the registry. */ tags: Record; /** * ISO timestamp of the last registry read *attempt*, successful or not. * * Tracked separately from `checkedAt` so a failing registry is backed off * like a successful one. Without it, an offline machine or a blackholed * proxy never persists anything, and every interactive command pays the * full request timeout again — turning a documented once-a-day cost into a * per-invocation one. Absent in caches written before this field existed. */ lastAttemptAt?: string; }; /** * Read the cache, or null when it is missing, unreadable, or malformed. * A malformed cache is treated as absent (and will be overwritten on the next * successful fetch) — there is nothing here worth recovering or warning about. */ export declare function readUpdateCache(cachePath?: string): Promise; /** * Persist the cache. Failures are swallowed: a read-only or full home * directory should cost the user a repeated registry lookup, not a failed * command. */ export declare function writeUpdateCache(cache: UpdateCache, cachePath?: string): Promise; /** * True when `cache` holds a successful read from within `ttlMs` of `now` — * i.e. its `tags` may be used without going back to the registry. */ export declare function isCacheFresh(cache: UpdateCache | null, now: number, ttlMs?: number): boolean; /** * Merge an out-of-band "latest" hint — the sync response's advisory * `cli.latest` (`cli-self-update-plan.md` §6) — into the cache's tags. * * Registry wins: a hint that is not strictly newer than what is already * cached for this channel is dropped silently, so a stale or lagging * deployment can never downgrade a fresher registry answer. A hint that * doesn't parse as a version is dropped the same way. * * Deliberately leaves `checkedAt`/`lastAttemptAt` untouched (or, absent any * prior cache, stamped as never-checked). Those two fields are cache-wide, * not per-channel, and a real registry read populates every known tag in one * request — so their meaning is "this whole tags map was just verified". * Advancing them here would claim that for every *other* cached channel too: * seeding `latest` after an `alpha` tag was cached from a real check would * mark that `alpha` entry falsely fresh, suppressing the registry read an * `alpha` install needs for up to `UPDATE_CACHE_TTL_MS` once it switches * channels. Leaving them alone means the tag value is available immediately * to anything reading `tags` directly, without ever blocking a channel this * hint didn't actually verify. */ export declare function seedLatestFromSyncHint(channel: string, latest: string, cachePath?: string): Promise; /** * True when a registry read was *attempted* within `ttlMs` of `now`, whether * or not it succeeded. * * Gates the network call, where `isCacheFresh` gates use of the data. The two * differ only while the registry is unreachable: the attempt is recent (so we * back off) but there is no fresh data (so any stale tags are still shown). * Falls back to `checkedAt` for caches written before `lastAttemptAt` existed. */ export declare function isAttemptRecent(cache: UpdateCache | null, now: number, ttlMs?: number): boolean; //# sourceMappingURL=cache.d.ts.map