/** * Configuration Manager for AgentRouter * * Handles loading, merging, validating, and watching configuration files. * Supports multiple config sources with priority-based merging and * environment variable interpolation. */ import { EventEmitter } from 'events'; import { type Config, type DefaultConfig, type RoleConfig, type ProviderConfig } from '../types.js'; /** * Events emitted by ConfigManager. */ export interface ConfigManagerEvents { /** Emitted when config is reloaded due to file changes */ change: [config: Config]; /** Emitted when a config reload fails */ error: [error: Error, path: string]; } /** * Options for ConfigManager initialization. */ export interface ConfigManagerOptions { /** Additional config file path to load (CLI override) */ configPath?: string; /** Whether to watch for config file changes (default: true) */ watch?: boolean; /** Whether to allow missing environment variables (default: false) */ allowMissingEnv?: boolean; } /** * Configuration manager with hot reload support. * Extends EventEmitter for change notifications. */ export declare class ConfigManager extends EventEmitter { private config; private validator; private merger; private configPaths; private watchers; private options; private loadedPaths; /** * Private constructor - use static load() method to create instances. */ private constructor(); /** * Load configuration and create a ConfigManager instance. * This is the primary way to create a ConfigManager. * * @param options - Configuration options * @returns Promise resolving to initialized ConfigManager * @throws ConfigurationError if config loading fails */ static load(options?: ConfigManagerOptions): Promise; /** * Load and merge configuration from all sources. * Config files are loaded in reverse priority order (lowest first) * so that higher priority configs override lower ones. */ private loadConfig; /** * Interpolate environment variables in configuration values. * Replaces ${VAR_NAME} patterns with the corresponding env value. * * @param obj - Object to interpolate * @returns Object with interpolated values * @throws ConfigurationError if required env var is missing */ private interpolateEnv; /** * Watch loaded config files for changes. * Emits 'change' event when config is successfully reloaded. * Emits 'error' event when reload fails. */ private watchConfig; /** * Stop watching config files. */ private stopWatching; /** * Manually reload configuration. * Useful when programmatically updating config files. * * @returns Promise resolving when reload is complete * @throws ConfigurationError if reload fails */ reload(): Promise; /** * Close the ConfigManager and stop watching files. * Should be called when shutting down. */ close(): void; /** * Get the full configuration object. * * @returns Complete configuration */ get(): Config; /** * Get the version string from config. * * @returns Config version */ getVersion(): string; /** * Get all role configurations. * * @returns Map of role names to role configs */ getRoles(): Record; /** * Get a specific role configuration. * * @param roleName - Name of the role * @returns Role configuration or undefined if not found */ getRole(roleName: string): RoleConfig | undefined; /** * Get all provider configurations. * * @returns Map of provider names to provider configs */ getProviders(): Record; /** * Get a specific provider configuration. * * @param providerName - Name of the provider * @returns Provider configuration or undefined if not found */ getProvider(providerName: string): ProviderConfig | undefined; /** * Get default configuration values. * * @returns Default config values */ getDefaults(): DefaultConfig; /** * Get list of available role names. * * @returns Array of role names */ getRoleNames(): string[]; /** * Get list of available provider names. * * @returns Array of provider names */ getProviderNames(): string[]; /** * Check if a role exists. * * @param roleName - Name of the role to check * @returns True if role exists */ hasRole(roleName: string): boolean; /** * Check if a provider exists. * * @param providerName - Name of the provider to check * @returns True if provider exists */ hasProvider(providerName: string): boolean; /** * Get the paths of all loaded config files. * * @returns Array of loaded config file paths */ getLoadedPaths(): string[]; /** * Get all config search paths (including unloaded). * * @returns Array of all config paths that are searched */ getSearchPaths(): string[]; } /** * Convenience function to load configuration. * Creates a ConfigManager and returns the config object. * * @param options - Configuration options * @returns Promise resolving to the loaded Config */ export declare function loadConfig(options?: ConfigManagerOptions): Promise; //# sourceMappingURL=manager.d.ts.map