import type { PluginConfig, PluginVersionInfo } from '../plugins/types.js'; import type { UpdateChannel } from '../types/update.js'; /** * Plugin update result */ export interface PluginUpdateResult { package: string; previousVersion: string; newVersion: string; success: boolean; error?: string; } /** * Plugin auto-update service configuration */ export interface PluginAutoUpdateServiceConfig { /** Global enable/disable (default: true) */ enabled: boolean; /** Check interval in milliseconds (default: 5 minutes) */ checkIntervalMs: number; /** Default channel for plugins without specific channel (default: 'latest') */ defaultChannel: UpdateChannel; /** Maximum random delay before applying update for staged rollout (ms). 0 = no delay */ stagedRolloutMaxDelayMs: number; } export declare const DEFAULT_PLUGIN_UPDATE_CONFIG: PluginAutoUpdateServiceConfig; export declare class PluginAutoUpdateService { private checkInterval; private initialCheckTimeout; private stagedRolloutTimeout; private readonly config; private readonly plugins; private readonly installedVersions; constructor(plugins: PluginConfig[], config?: Partial); /** * Start the plugin auto-update service. * Performs initial check after 2 minutes, then checks periodically. */ start(): void; /** * Stop the plugin auto-update service. */ stop(): void; /** * Check for updates for all plugins without installing. */ checkForUpdates(): Promise; /** * Trigger immediate update check and installation. * Used by HTTP endpoint to update plugins on-demand. * Returns results of update attempts. */ triggerUpdates(): Promise; /** * Check for updates and install if available (internal periodic check). * Includes staged rollout delay to prevent thundering herd. */ private checkAndUpdateAll; /** * Calculate random delay for staged rollout. */ private calculateStagedDelay; /** * Sleep for specified milliseconds. */ private sleep; /** * Update a single plugin via npm install -g. * Installs globally to ensure consistent plugin versions across the system. * The plugin loader always loads from global npm. */ private updatePlugin; /** Cached global npm prefix */ private cachedGlobalPrefix; /** * Get the global npm prefix path. * Results are cached for performance. */ private getGlobalNpmPrefix; /** * Detect currently installed versions by checking global npm packages. * Plugins are always installed and loaded from global npm. */ private detectInstalledVersions; /** * Get latest version from npm registry. */ private getLatestVersion; /** * Compare semver versions using the semver package. * Returns true if `latest` is newer than `current`. * Properly handles pre-releases (e.g., 1.0.0-beta.1 < 1.0.0) * and build metadata (ignored per semver spec). */ private isNewer; /** * Acquire update lock file. * Returns false if another agent is updating. */ private acquireLock; /** * Release update lock file. */ private releaseLock; /** * Request daemon restart via SIGTERM. * systemd will restart us with the new plugin versions. */ private requestRestart; } /** * Load plugin auto-update config from environment or use defaults. */ export declare function loadPluginUpdateConfig(): PluginAutoUpdateServiceConfig; //# sourceMappingURL=plugin-auto-update.d.ts.map