/** * Configuration hot reload manager */ import type { Config } from './schema.js'; import { type ReloadPlan } from './rules.js'; export interface HotReloadConfig { debounceMs: number; enabled: boolean; } export interface ReloadResult { success: boolean; plan?: ReloadPlan; error?: string; } /** * Callback types for different reload actions */ export type ReloadCallback = (newConfig: Config) => void | Promise; export interface ReloadCallbacks { onModelsReload?: ReloadCallback; onAgentDefaultsReload?: ReloadCallback; onChannelsReload?: ReloadCallback; onCronReload?: ReloadCallback; onHeartbeatReload?: ReloadCallback; onToolsReload?: ReloadCallback; onMcpReload?: ReloadCallback; onWebSearchReload?: ReloadCallback; /** All `extensions.*` hot paths in one batch (deduplicated in applyReload). */ onExtensionsReload?: (newConfig: Config, changedPaths: string[]) => void | Promise; onFullRestart?: ReloadCallback; } /** * Configuration hot reload manager */ export declare class ConfigHotReloader { private configPath; private callbacks; private watcher; private modelsJsonWatcher; private debounceTimer; private currentConfig; private debounceMs; private enabled; constructor(configPath: string, initialConfig: Config, callbacks: ReloadCallbacks, options?: HotReloadConfig); /** * Start watching config file for changes */ start(): void; /** * Stop watching config file */ stop(): Promise; /** * Schedule a reload with debounce */ private scheduleReload; /** * Watch models.json independently so direct file edits are picked up without restarting. * The watcher is best-effort: if the file does not exist yet, it will not be watched. */ private startModelsJsonWatcher; /** * Debounced handler for models.json changes. * Calls onModelsReload with the current config so the registry is refreshed. */ private scheduleModelsJsonReload; /** * Reload configuration and apply changes */ reload(): Promise; /** * Apply reload based on plan */ private applyReload; /** * Apply a single hot-reloadable path */ private applyHotPath; /** * Manually trigger a reload */ triggerReload(): Promise; /** * Align diff baseline with a freshly loaded config (e.g. Weixin QR wrote token files but JSON unchanged). */ syncCurrentConfig(config: Config): void; /** * Get current config */ getConfig(): Config; /** * Check if hot reload is enabled */ isEnabled(): boolean; } export { diffConfigPaths } from './diff.js'; export { buildReloadPlan, matchReloadRule, BASE_RELOAD_RULES } from './rules.js';