/** * ConfigWatcher — Hot-reload configuration from disk. * * Uses `fs.watch()` to monitor config files and applies changes to * live CONFIG, trust levels, resource profiles, and budget ceilings. * Emits events on reload so components can react. * * @module ConfigWatcher */ import { EventEmitter } from 'events'; /** Fields that can be hot-reloaded on CONFIG */ export interface ReloadableConfig { maxParallelAgents?: number; defaultTimeout?: number; enableTracing?: boolean; grantTokenTTL?: number; maxBlackboardValueSize?: number; [key: string]: unknown; } /** Trust level entry */ export interface TrustEntry { agentId: string; level: number; tags?: string[]; } /** Budget overrides */ export interface BudgetOverrides { ceiling?: number; perAgentCeiling?: number; } /** Callback targets for reloaded config */ export interface ConfigTargets { /** Mutable CONFIG object to patch in-place */ config?: Record; /** AuthGuardian instance — for trust level updates */ authGuardian?: { setTrustLevel?(agentId: string, level: number): void; }; /** FederatedBudget instance — for ceiling updates */ budget?: { setCeiling?(ceiling: number): void; }; } /** Emitted on successful reload */ export interface ReloadEvent { file: string; timestamp: number; changes: string[]; } /** Emitted on reload error */ export interface ReloadError { file: string; timestamp: number; error: string; } /** * Watches config files on disk and applies changes to live objects. * * Supports three config file types: * - **config.json** — patches `CONFIG` object fields * - **trust_levels.json** — array of `{ agentId, level }` applied to AuthGuardian * - **budget.json** — `{ ceiling, perAgentCeiling }` applied to FederatedBudget * * @example * ```ts * const watcher = new ConfigWatcher({ * configPath: './data/config.json', * trustPath: './data/trust_levels.json', * targets: { config: CONFIG, authGuardian: guardian, budget: fed }, * }); * watcher.on('reload', (evt) => console.log('Reloaded:', evt.file)); * watcher.start(); * // ... later * watcher.stop(); * ``` */ export declare class ConfigWatcher extends EventEmitter { private watchers; private targets; private configPath?; private trustPath?; private budgetPath?; private debounceMs; private debounceTimers; private running; constructor(options?: { configPath?: string; trustPath?: string; budgetPath?: string; targets?: ConfigTargets; debounceMs?: number; }); /** Update targets after construction */ setTargets(targets: ConfigTargets): void; /** Start watching all configured paths */ start(): void; /** Stop all watchers */ stop(): void; /** Manually trigger a reload for a specific file */ reload(filePath: string): void; /** Whether the watcher is currently active */ isRunning(): boolean; private debouncedReload; private applyReload; private applyConfig; private applyTrust; private applyBudget; } //# sourceMappingURL=config-watcher.d.ts.map