/** * DEC-107 — EVO-8: CLI auto-upgrade. Three levels: * (1) `h2a upgrade [--check]` — explicit, user-invoked; * (2) `mcp-serve` boot version-check notice — non-blocking, cached, opt-out; * (3) `mcp-serve --auto-upgrade` — self-install `@latest` at boot (the new * version applies on the NEXT launch — a running Node process cannot * replace its own binary in flight). * * Pure version logic + an injectable `UpgradeRuntime` (network/exec/clock/cache) * so everything is testable without npm or the network. */ export declare const H2A_CLI_PACKAGE = "@sentropic/h2a"; /** Re-check at most once per this window for the passive `--upgrade-check` notice. */ export declare const H2A_UPGRADE_CHECK_TTL_MS: number; /** * Shorter throttle for `--auto-upgrade`: it is opt-in to *stay current*, so a * 24h notice cache must not make it lag a same-day release (the bug that left * agents on 0.39.0 after a restart). 1h still dedups a mass restart through the * shared per-root cache (only the first booting host hits the network). */ export declare const H2A_AUTO_UPGRADE_CHECK_TTL_MS: number; /** Parse a strict X.Y.Z triple, or undefined if it is not one. */ export declare function parseSemver(v: string): { major: number; minor: number; patch: number; } | undefined; /** True iff `latest` is a strictly higher X.Y.Z than `current`. */ export declare function isNewerVersion(latest: string, current: string): boolean; /** The version of the running `@sentropic/h2a` (from its package.json). */ export declare function currentCliVersion(): string; export interface UpgradeCacheEntry { readonly checkedAt: number; readonly latest?: string; } /** I/O the upgrade flow needs — injected so tests supply fakes. */ export interface UpgradeRuntime { /** Latest published version of `pkg`, or undefined on any failure. */ fetchLatest(pkg: string): string | undefined; /** `npm i -g pkg@latest`; true on success. */ runInstall(pkg: string): boolean; now(): number; readCache(path: string): UpgradeCacheEntry | undefined; writeCache(path: string, entry: UpgradeCacheEntry): void; } export declare const defaultUpgradeRuntime: UpgradeRuntime; export interface UpgradeCheckResult { readonly current: string; readonly latest?: string; readonly upgradeAvailable: boolean; /** True if the latest came from a fresh cache hit (no network this call). */ readonly fromCache: boolean; } export interface CheckUpgradeOptions { readonly runtime?: UpgradeRuntime; /** Cache file path; when set, a fresh entry within TTL skips the network. */ readonly cachePath?: string; readonly ttlMs?: number; /** Skip the cache entirely (always hit the network). */ readonly force?: boolean; } /** * Determine whether a newer CLI is published. Cached + throttled when a * `cachePath` is given (level-2 boot notice); always-fresh otherwise. Never * throws — a network failure yields `{ latest: undefined, upgradeAvailable:false }`. */ export declare function checkUpgrade(current: string, options?: CheckUpgradeOptions): UpgradeCheckResult; /** Run the global install of `@latest`. Returns true on success. */ export declare function performUpgrade(runtime?: UpgradeRuntime): boolean; /** Default cache path for the boot check, under the store root. */ export declare function upgradeCachePath(root: string): string; /** * Env flag set across an in-place re-exec so the freshly-exec'd process does * NOT auto-upgrade + re-exec again this boot (breaks any pathological loop if * an install reports success without changing the on-disk version). */ export declare const H2A_REEXEC_GUARD_ENV = "H2A_UPGRADE_REEXECED"; export interface ReexecOptions { /** Injectable for tests; defaults to `process.execve` when present. */ readonly execve?: (file: string, args: readonly string[], env: Record) => never; readonly execPath?: string; readonly argv?: readonly string[]; readonly env?: Record; } /** True when an in-place re-exec is possible (POSIX `process.execve`, Node ≥ 23.10). */ export declare function canReexec(): boolean; /** * Re-exec the current process into the (just-upgraded) binary at the SAME path, * preserving PID + stdio fds — so a host-spawned `mcp-serve` picks up the new * version immediately without the host seeing a disconnect. On success the * process image is replaced and this never returns; returns `false` if re-exec * is unavailable or failed (caller falls back to "applies next launch"). The * `H2A_REEXEC_GUARD_ENV` flag is set so the new image does not re-upgrade. */ export declare function reexecSelf(options?: ReexecOptions): boolean; //# sourceMappingURL=index.d.ts.map