/** * Configuration Service * * Centralized service for loading, validating, and managing Wave configuration files. * Replaces distributed configuration logic previously embedded in hook.ts. */ import type { ConfigurationLoadResult, ValidationResult, ConfigurationPaths, WaveConfiguration, Scope, MarketplaceConfig } from "../types/configuration.js"; import { type EnvironmentValidationResult, type MergedEnvironmentContext, type EnvironmentMergeOptions } from "../types/environment.js"; import { GatewayConfig, ModelConfig, PermissionMode, AgentOptions } from "../types/index.js"; import { ClientOptions } from "openai"; /** * Default ConfigurationService implementation * * Provides centralized configuration loading, validation, and management. * Extracted from distributed logic in hook.ts with improved error handling. */ export declare class ConfigurationService { private currentConfiguration; private options; private _configuredEnvKeys; /** * Set agent options for configuration resolution */ setOptions(options: AgentOptions): void; /** * Load and merge configuration with comprehensive validation */ loadMergedConfiguration(workdir: string): Promise; /** * Validate configuration object structure and values */ validateConfiguration(config: WaveConfiguration): ValidationResult; /** * Validate configuration file without loading */ validateConfigurationFile(filePath: string): ValidationResult; /** * Set environment variables from configuration * This replaces direct process.env modification */ setEnvironmentVars(env: Record): void; /** * Read SSO token from ~/.wave/auth.json */ private readSSOToken; /** * Resolves gateway configuration from constructor args and environment * Resolution priority: SSO_TOKEN > options > env (from settings.json) > process.env > error * @param apiKey - API key override (optional) * @param baseURL - Base URL override (optional) * @param defaultHeaders - HTTP headers override (optional) * @param fetchOptions - Fetch options override (optional) * @param fetch - Custom fetch implementation override (optional) * @returns Resolved gateway configuration * @returns Resolved model configuration (model/fastModel may be undefined if not yet configured) */ resolveGatewayConfig(apiKey?: string, baseURL?: string, defaultHeaders?: Record, fetchOptions?: ClientOptions["fetchOptions"], fetch?: ClientOptions["fetch"]): GatewayConfig; /** * Resolves model configuration with fallbacks * Resolution priority: override > options > env (from settings.json) > process.env > default * @param model - Agent model override (optional) * @param fastModel - Fast model override (optional) * @param maxTokens - Max output tokens override (optional) * @param permissionMode - Permission mode override (optional) * @returns Resolved model configuration with defaults */ resolveModelConfig(model?: string, fastModel?: string, maxTokens?: number, permissionMode?: PermissionMode): ModelConfig; /** * Resolves token limit with fallbacks * Resolution priority: override > options > env (from settings.json) > process.env > default * @param constructorLimit - Token limit override (optional) * @returns Resolved token limit */ resolveMaxInputTokens(constructorLimit?: number): number; /** * Resolves preferred language with fallbacks * Resolution priority: override > options > settings.json > undefined * @param constructorLanguage - Language override (optional) * @returns Resolved language or undefined */ resolveLanguage(constructorLanguage?: string): string | undefined; /** * Resolves auto-memory enabled state with fallbacks * Resolution priority: settings.json > WAVE_DISABLE_AUTO_MEMORY > default (true) * @returns Resolved auto-memory enabled state */ resolveAutoMemoryEnabled(): boolean; /** * Resolves auto-memory extraction frequency with fallbacks * Resolution priority: settings.json > WAVE_AUTO_MEMORY_FREQUENCY > default (1) * @returns Resolved auto-memory extraction frequency (turns) */ resolveAutoMemoryFrequency(): number; /** * Resolves max output tokens with fallbacks * Resolution priority: override > options > env (from settings.json) > process.env > default * @param constructorLimit - Max output tokens override (optional) * @returns Resolved max output tokens */ resolveMaxOutputTokens(constructorLimit?: number): number; /** * Set the active model in the session */ setModel(model: string): void; private persistModelToSettings; /** * Get all configured models from settings.json and environment */ getConfiguredModels(): string[]; /** * Get the telemetry config from the loaded settings. */ resolveTelemetryConfig(): Partial | undefined; /** * Resolve all configuration file paths */ getConfigurationPaths(workdir: string): ConfigurationPaths; /** * Add a permission rule to the local settings.local.json */ addAllowedRule(workdir: string, rule: string): Promise; /** * Update the enabled state of a plugin in the specified scope */ updateEnabledPlugin(workdir: string, scope: Scope, pluginId: string, enabled: boolean): Promise; /** * Get merged marketplaces from all scopes */ getMergedMarketplaces(workdir: string): Record; /** * Get marketplaces at a specific scope */ getScopedMarketplaces(workdir: string, scope: Scope): Record; /** * Add a marketplace to the specified scope */ addMarketplaceToScope(workdir: string, scope: Scope, name: string, config: MarketplaceConfig): Promise; /** * Remove a marketplace from the specified scope */ removeMarketplaceFromScope(workdir: string, scope: Scope, name: string): Promise; /** * Remove a plugin from the enabled plugins in the specified scope */ removeEnabledPlugin(workdir: string, scope: Scope, pluginId: string): Promise; /** * Get merged enabled plugins from all scopes */ getMergedEnabledPlugins(workdir: string): Record; /** * Load Wave configuration from a JSON file * Supports both hooks and environment variables with proper validation */ loadWaveConfigFromFile(filePath: string): WaveConfiguration | null; } /** * Validate environment variable configuration */ export declare function validateEnvironmentConfig(env: unknown, configPath?: string): EnvironmentValidationResult; /** * Merge environment configurations with project taking precedence over user */ export declare function mergeEnvironmentConfig(userEnv: Record | undefined, projectEnv: Record | undefined, options?: EnvironmentMergeOptions): MergedEnvironmentContext; /** * Load Wave configuration from a JSON file * Supports both hooks and environment variables with proper validation */ export declare function loadWaveConfigFromFile(filePath: string): WaveConfiguration | null; /** * Load and merge Wave configuration from both user and project sources * Project configuration takes precedence over user configuration * Checks .local.json files first, then falls back to .json files */ export declare function loadMergedWaveConfig(workdir: string): WaveConfiguration | null;