/** * Update Checker & Auto-Updater for agi-cli * * This module provides a FULLY NON-INTERACTIVE update system that does not * rely on stdin/raw mode, avoiding conflicts with the chat box input handling. * * Update behavior is controlled by user preferences: * - autoUpdate: true -> Automatically update in background * - autoUpdate: false -> Silently skip updates * - autoUpdate: null -> Show notification banner with instructions */ export interface UpdateInfo { current: string; latest: string; updateAvailable: boolean; } export interface AutoUpdateResult { attempted: boolean; updated: boolean; latestVersion?: string; command?: string; skippedReason?: string; error?: string; } export interface AutoUpdateState { lastCheck?: number; lastSeenLatest?: string; lastAttempt?: number; lastAttemptedVersion?: string; lastUpdatedVersion?: string; } type Logger = (message: string) => void; /** * Check for updates from npm registry. */ export declare function checkForUpdates(currentVersion: string): Promise; /** * Attempt to auto-update the CLI when a newer version is available. * This is throttled and disabled in CI/test environments or when explicitly opted out. */ export declare function maybeAutoUpdate(currentVersion: string, options?: { updateInfo?: UpdateInfo | null; logger?: Logger; }): Promise; /** * Format update notification message */ export declare function formatUpdateNotification(updateInfo: UpdateInfo, note?: string): string; /** * Format a simple update notification banner (non-interactive). * Returns a string that can be displayed to the user. */ export declare function formatUpdateBanner(updateInfo: UpdateInfo, preference: 'auto' | 'skip' | 'ask'): string; /** * Get the user's update decision based on their saved preference. * No interactive input required - purely preference-based. */ export declare function getUpdateDecision(autoUpdatePref: boolean | null): 'auto' | 'skip' | 'ask'; /** * Check if we should show update notification (respects quiet period after recent attempts). */ export declare function shouldShowUpdateNotification(state: AutoUpdateState): boolean; /** * Read the auto-update state from disk. */ export declare function readAutoUpdateState(): AutoUpdateState; export interface UpdatePromptResult { choice: 'update' | 'skip'; rememberChoice: boolean; } /** * DEPRECATED: Interactive prompts conflict with chat box input handling. * Use getUpdateDecision() for preference-based decisions instead. * * This function now returns skip without any interaction. * The interactive prompt has been removed to avoid stdin conflicts. */ export declare function promptForUpdate(_updateInfo: UpdateInfo): Promise; /** * Perform a background update without blocking the main process. * Spawns the update command in a detached process. */ export declare function performBackgroundUpdate(updateInfo: UpdateInfo, logger?: (message: string) => void): Promise<{ started: boolean; error?: string; }>; /** * Perform the update with progress feedback (blocking). */ export declare function performUpdate(updateInfo: UpdateInfo, logger?: (message: string) => void): Promise<{ success: boolean; error?: string; }>; export interface SessionState { workingDirectory: string; pendingTasks?: string[]; lastPrompt?: string; contextSummary?: string; timestamp: number; version: string; resumeCommand?: string; } /** * Save session state before update for resumption after restart. */ export declare function saveSessionState(state: Omit): void; /** * Load session state for resumption after update. */ export declare function loadSessionState(): SessionState | null; /** * Clear session state after successful resumption. */ export declare function clearSessionState(): void; /** * Check if there's a pending session to resume. */ export declare function hasPendingSession(): boolean; /** * Perform update and automatically restart to continue work. * Saves session state, performs update, then spawns new process with --resume flag. */ export declare function updateAndContinue(updateInfo: UpdateInfo, sessionState: Omit, logger?: (message: string) => void): Promise<{ success: boolean; error?: string; restarting?: boolean; }>; /** * Install specific npm package version and optionally restart. */ export declare function installPackageVersion(packageName: string, version: string, options?: { global?: boolean; restart?: boolean; sessionState?: Omit; logger?: (message: string) => void; }): Promise<{ success: boolean; error?: string; }>; /** * Run npm install in current directory. */ export declare function runNpmInstall(cwd?: string, logger?: (message: string) => void): Promise<{ success: boolean; error?: string; }>; export {}; //# sourceMappingURL=updateChecker.d.ts.map