/** * Configuration loader - loads config from file and environment variables */ import { type Config } from './schema.js'; export declare class ConfigLoader { private config; private configPath; private rawConfig; constructor(configPath?: string); /** * Load configuration with multi-level cascade: * 1. Package defaults (data/config.default.json) * 2. Global user preferences (~/.valora/config.json) * 3. Project-specific settings (.valora/config.json) * 4. Environment variables (VALORA_* with AI_* alias) * 5. CLI flags */ load(cliOverrides?: Partial): Promise; /** * Applies regardless of trust level — a trusted-but-compromised config, a * malicious plugin, or a misconfigured env var can set a provider's * `baseUrl` just as easily as an untrusted project config can, and every * provider sends the real API key as a plaintext Authorization header to * whatever `baseUrl` names. Strips (doesn't throw on) an unsafe value so a * single bad provider entry can't crash config load for the whole run. */ private sanitizeProviderBaseUrls; private sanitizeSingleProviderBaseUrl; /** * Load package default config from the configured path */ private loadPackageConfig; /** * Load global user config (~/.valora/config.json) */ private loadGlobalConfig; /** * Load project config (.valora/config.json) */ private loadProjectConfig; /** * An untrusted project's config.json can override just a provider's * `baseUrl` (or `defaults.default_provider`) with no trust gate at all — * silently redirecting the real API key, resolved separately from a * trusted global config/env var, to an attacker-controlled endpoint on * the very next LLM call. Strip these two specific fields when the * project isn't trusted; every other project-config field still applies * normally. Deletes the keys outright rather than setting them to * `undefined` — `mergeSingleConfig` spreads `config.defaults` directly * (`{...result.defaults, ...config.defaults}`), so an explicit * `default_provider: undefined` would overwrite a legitimate value from * an earlier (trusted) layer instead of just not contributing one. */ private stripUntrustedProviderOverrides; /** * Emit a one-time warning for any provider key in config that has no registered descriptor. * Call this after plugin initialisation so plugin-contributed providers are already registered. */ warnUnknownProviders(): void; /** * Auto-migrate: set default_provider if missing but providers exist */ private autoMigrateDefaultProvider; /** * Load configuration from environment variables */ private loadFromEnv; /** * Load provider configurations from environment variables */ private loadProvidersFromEnv; /** * Load defaults configuration from environment variables. * Supports both VALORA_* and AI_* prefixes (VALORA_* takes precedence). */ private loadDefaultsFromEnv; /** * Load logging configuration from environment variables */ private loadLoggingFromEnv; /** * Load sessions configuration from environment variables */ private loadSessionsFromEnv; /** * Load feature flags from environment variables */ private loadFeaturesFromEnv; /** * Merge multiple config objects */ private mergeConfigs; /** * Merge a single config into the result */ private mergeSingleConfig; /** * Deep-merge individual provider configs so higher-priority layers override * specific fields without erasing fields absent from the higher-priority layer. * Undefined values in the incoming config are skipped. */ private mergeProviderConfigs; /** * Build local provider config from env vars, omitting default_model when unset * to avoid overriding a lower-priority config layer's value. */ private buildLocalEnvConfig; /** * Merge feature flags */ private mergeFeatures; /** * Check if any of the environment variables exist */ private hasAnyEnvVar; /** * Apply environment variable mapping to a config section */ private applyEnvMapping; /** * Save configuration to file */ save(config: Config): Promise; /** * Get current configuration */ get(): Config; /** * Get the merged config before schema validation — preserves keys that CONFIG_SCHEMA strips. * Intended for plugin config consumption via api.config.extend(). */ getRaw(): Record; /** * Check if configuration file exists */ exists(): boolean; /** * Get configuration file path */ getConfigPath(): string; /** * Load raw config file content without cascade, env vars, or DEFAULT_CONFIG merging. * Used by the setup wizard to preserve existing settings when updating config. */ loadRaw(): Promise>; /** * Load configuration from a specific file path */ loadFromPath(filePath: string): Promise; /** * Reload configuration */ reload(): Promise; } /** * Resets the warned-unknown-providers tracking set. Intended for use in tests only. */ export declare function resetUnknownProviderWarningsForTests(): void; export declare function getConfigLoader(configPath?: string): ConfigLoader; /** * Set global CLI overrides that will be applied to all configuration loading */ export declare function setGlobalCliOverrides(overrides: Partial): void; /** * Get current global CLI overrides */ export declare function getGlobalCliOverrides(): null | Partial; //# sourceMappingURL=loader.d.ts.map