/** * Safe hot-reload protocol for plugins. * * Implements the 6-phase hot-reload sequence: * 1. Quiesce , stop accepting new work from the plugin * 2. Unregister, remove plugin's registrations (commands, tools, hooks) * 3. Unload - deactivate and clean up the previous plugin instance * 4. Reload , load the new version with a cache-bust timestamp * 5. Re-register, new instance calls init/activate (registers naturally) * 6. Health check → active (healthy) or degraded (unhealthy) */ import type { PluginLoaderDeps } from '../../plugins/loader.js'; import type { LoadedPlugin } from '../../plugins/loader.js'; import type { PluginHealthCheckResult, PluginManifestV2 } from './types.js'; import type { PluginLifecycleManager } from './manager.js'; /** * Options for a single plugin hot-reload operation. */ export interface HotReloadOptions { /** * Callback to retrieve the current loaded plugin instance by name. * Used to call deactivate() and run cleanup before unloading. */ getLoadedPlugin: (name: string) => LoadedPlugin | undefined; /** * Callback to remove a plugin's loaded instance from the host's registry. * Called after unload to clean up the host-side reference. */ removeLoadedPlugin: (name: string) => void; /** * Callback to store the newly loaded plugin instance in the host's registry. * Called after a successful reload. */ storeLoadedPlugin: (name: string, plugin: LoadedPlugin) => void; /** * Optional health check callback invoked after re-registration. * Return a PluginHealthCheckResult to indicate whether the plugin is healthy. * Defaults to a trivial healthy check. */ healthCheck?: ((name: string) => Promise) | undefined; /** * Maximum time (ms) to wait for the health check before timing out. * Defaults to 5000ms. */ healthCheckTimeoutMs?: number | undefined; } /** * Result of a hot-reload operation. */ export interface HotReloadResult { /** Whether the reload completed successfully and the plugin is healthy. */ success: boolean; /** Phase that failed (if success === false). */ failedPhase?: 'quiesce' | 'unregister' | 'unload' | 'reload' | 're-register' | 'health-check' | undefined; /** Error message (if success === false). */ error?: string | undefined; /** Duration of the reload in milliseconds. */ durationMs: number; /** Whether the plugin ended in degraded state (partial success). */ degraded: boolean; } /** * runHotReload, Execute the safe 6-phase hot-reload protocol for a single * plugin. * * @param name - Plugin name. * @param manifest - Current manifest for the plugin. * @param pluginDir - Absolute path to the plugin directory. * @param deps - Loader dependencies (runtime bus, registries, etc.). * @param lcm - PluginLifecycleManager to track state transitions. * @param options - Host-side callbacks and configuration. * @returns HotReloadResult describing the outcome. */ export declare function runHotReload(name: string, manifest: PluginManifestV2, pluginDir: string, deps: PluginLoaderDeps, lcm: PluginLifecycleManager, options: HotReloadOptions): Promise; //# sourceMappingURL=hot-reload.d.ts.map