/** * @file version-poller.ts * @description Background polling service that checks npm registry for new package versions. * Triggers callbacks when a new version matching the semver range is detected. */ import type { FrontMcpLogger } from '../common'; import type { EsmRegistryAuth } from './esm-auth.types'; import type { ParsedPackageSpecifier } from './package-specifier'; /** * Result of checking a single package for updates. */ export interface VersionCheckResult { /** Full package name */ packageName: string; /** Currently loaded version */ currentVersion: string; /** Latest version matching the range */ latestVersion: string; /** Whether a newer version is available */ hasUpdate: boolean; /** Whether the latest version satisfies the original range */ satisfiesRange: boolean; } /** * Options for the version poller. */ export interface VersionPollerOptions { /** Polling interval in milliseconds (default: 300000 = 5 minutes) */ intervalMs?: number; /** Authentication for private registries */ registryAuth?: EsmRegistryAuth; /** Logger instance */ logger?: FrontMcpLogger; /** Callback when a new version is detected */ onNewVersion: (packageName: string, oldVersion: string, newVersion: string) => Promise; } /** * Background service that periodically checks npm registry for package updates. * * When a new version matching the semver range is detected, triggers the * `onNewVersion` callback to drive hot-reload of ESM packages. */ export declare class VersionPoller { private readonly intervalMs; private readonly logger?; private readonly onNewVersion; private readonly versionResolver; private readonly packages; private intervalId?; private running; private polling; constructor(options: VersionPollerOptions); /** * Add a package to the polling watchlist. * * @param specifier - Parsed package specifier with semver range * @param currentVersion - Currently loaded concrete version */ addPackage(specifier: ParsedPackageSpecifier, currentVersion: string): void; /** * Remove a package from the polling watchlist. */ removePackage(packageName: string): void; /** * Update the current version for a tracked package (after hot-reload). * * @returns `true` if the package was found and updated, `false` if unknown. */ updateCurrentVersion(packageName: string, newVersion: string): boolean; /** * Start the background polling loop. */ start(): void; /** * Stop the background polling loop. */ stop(): void; /** * Check all tracked packages for updates immediately (without waiting for the interval). * * @returns Array of check results for all tracked packages */ checkNow(): Promise; /** * Whether the poller is currently running. */ isRunning(): boolean; /** * Number of packages being tracked. */ get trackedCount(): number; /** * Internal polling loop iteration. */ private poll; /** * Check a single package for updates. */ private checkPackage; } //# sourceMappingURL=version-poller.d.ts.map