/** * ConfigManager interface and implementation for @a5c-ai/agent-mux. * * Provides unified configuration access for all supported agents. * Reads and writes each agent's native config through the adapter layer. * * @see 08-config-and-auth.md */ import type { AgentName, McpServerConfig } from './types.js'; import type { AdapterRegistry } from './adapter-registry.js'; import type { ProfileManager } from './profiles.js'; import type { AgentConfig, AgentConfigSchema } from './config-types.js'; export type { AgentConfig, AgentConfigSchema, ConfigField, ValidationResult, ConfigValidationError, ConfigValidationWarning, ModelSelection, } from './config-types.js'; import type { ModelSelection, ValidationResult } from './config-types.js'; /** Unified configuration access for all supported agents. */ export interface ConfigManager { /** Read the full merged configuration for an agent. */ get(agent: AgentName): AgentConfig; /** Read a single field from the merged configuration. */ getField(agent: AgentName, field: string): unknown; /** Write partial configuration updates to the agent's native config file. */ set(agent: AgentName, fields: Partial): Promise; /** Write a single field to the agent's native config file. */ setField(agent: AgentName, field: string, value: unknown): Promise; /** Returns the configuration schema for an agent. */ schema(agent: AgentName): AgentConfigSchema; /** Validate a partial config against the agent's schema. */ validate(agent: AgentName, config: Partial): ValidationResult; /** Returns all MCP server configurations from the agent's config. */ getMcpServers(agent: AgentName): McpServerConfig[]; /** Returns configured/default/effective model selection for an agent. */ getModelSelection(agent: AgentName): ModelSelection; /** Update model/provider selection fields in the agent config. */ setModelSelection(agent: AgentName, selection: { model?: string | null; provider?: string | null; }): Promise; /** Add an MCP server to the agent's config. */ addMcpServer(agent: AgentName, server: McpServerConfig): Promise; /** Remove an MCP server from the agent's config by name. */ removeMcpServer(agent: AgentName, serverName: string): Promise; /** Invalidate cache and re-read from disk. */ reload(agent?: AgentName): Promise; /** Returns the ProfileManager instance. */ profiles(): ProfileManager; } /** * Implementation of ConfigManager. * * Delegates file I/O to agent adapters. Provides caching, * deep merge, field-level access, and schema introspection. */ export declare class ConfigManagerImpl implements ConfigManager { private readonly _adapters; private readonly _profileManager; private readonly _cache; /** * Per-agent write serialisation. All `.set()` / `.setField()` / MCP mutation * calls for a given agent queue onto the same promise so concurrent callers * cannot interleave read-modify-write sequences. File-level atomicity is * additionally enforced by the adapter writing through `writeJsonAtomic` * from `atomic-fs.ts`, which uses a tmp+fsync+rename + advisory lockfile. */ private readonly _writeQueue; constructor(adapters: AdapterRegistry, profileManager: ProfileManager); private _getAdapter; get(agent: AgentName): AgentConfig; getField(agent: AgentName, field: string): unknown; set(agent: AgentName, fields: Partial): Promise; /** Serialise writes per agent so concurrent `.set()` cannot interleave. */ private _enqueueWrite; setField(agent: AgentName, field: string, value: unknown): Promise; schema(agent: AgentName): AgentConfigSchema; validate(_agent: AgentName, _config: Partial): ValidationResult; getMcpServers(agent: AgentName): McpServerConfig[]; getModelSelection(agent: AgentName): ModelSelection; setModelSelection(agent: AgentName, selection: { model?: string | null; provider?: string | null; }): Promise; addMcpServer(agent: AgentName, server: McpServerConfig): Promise; removeMcpServer(agent: AgentName, serverName: string): Promise; reload(agent?: AgentName): Promise; profiles(): ProfileManager; }