@agentled/cli
Version:
CLI for Agentled — manage workflows, apps, and knowledge from the command line. Zero context-window cost for AI agents.
35 lines (34 loc) • 1.74 kB
TypeScript
/**
* Dependency-free update notifier for the agentled CLI.
*
* Checks the npm registry for a newer version of the given package and
* prints a one-line notice to stderr before the process exits. Design
* constraints:
* - Zero external dependencies (uses Node 18+ `fetch`).
* - Silent on failure — a missing network, registry hiccup, or malformed
* cache must never break the user's command.
* - Cached: one HTTP round-trip per 24h (cache miss adds ≤1.2s latency),
* cache hits are free.
* - Opt-out: honors `AGENTLED_NO_UPDATE_CHECK=1`, `NO_UPDATE_NOTIFIER=1`,
* and standard CI env vars. Also skips when stderr is not a TTY.
*/
export declare const DEFAULT_TTL_MS: number;
export declare const DEFAULT_TIMEOUT_MS = 1200;
export interface CacheEntry {
checked: number;
latest: string;
}
export declare function cachePath(pkgName: string): string;
export declare function readCache(pkgName: string): CacheEntry | null;
export declare function writeCache(pkgName: string, entry: CacheEntry): void;
export declare function isDisabled(): boolean;
export declare function semverCompare(a: string, b: string): number;
export declare function fetchLatestVersion(pkgName: string, timeoutMs: number): Promise<string | null>;
export interface CheckOptions {
ttlMs?: number;
timeoutMs?: number;
fetcher?: (pkg: string, timeoutMs: number) => Promise<string | null>;
}
export declare function checkForUpdate(pkgName: string, currentVersion: string, opts?: CheckOptions): Promise<string | null>;
export declare function renderUpdateNotice(pkgName: string, current: string, latest: string): string;
export declare function printUpdateNotice(pkgName: string, current: string, latest: string): void;