/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { DebugLogger } from '../debug/DebugLogger.js';
/**
 * Manages the discovery, loading, validation, and registration of
 * AgentDefinitions.
 */
export class AgentRegistry {
    config;
    // Using unknown output type for the internal map to handle generic variance correctly
    // Callers will cast to specific types as needed
    agents = new Map();
    logger = new DebugLogger('llxprt:agents:registry');
    constructor(config) {
        this.config = config;
        // Access config to satisfy lint and allow future conditional logging
        void this.config;
    }
    /**
     * Discovers and loads agents.
     */
    async initialize() {
        this.loadBuiltInAgents();
        this.logger.debug(() => `[AgentRegistry] Initialized with ${this.agents.size} agents.`);
    }
    loadBuiltInAgents() {
        // No built-in agents registered - CodebaseInvestigatorAgent was removed
        // because it hardcodes DEFAULT_GEMINI_MODEL, violating multi-provider support
    }
    /**
     * Registers an agent definition. If an agent with the same name exists,
     * it will be overwritten, respecting the precedence established by the
     * initialization order.
     */
    registerAgent(definition) {
        // Basic validation
        if (!definition.name || !definition.description) {
            this.logger.warn(`[AgentRegistry] Skipping invalid agent definition. Missing name or description.`);
            return;
        }
        if (this.agents.has(definition.name)) {
            this.logger.debug(`[AgentRegistry] Overriding agent '${definition.name}'`);
        }
        // Cast to default AgentDefinition type for storage - callers will cast back as needed
        this.agents.set(definition.name, definition);
    }
    /**
     * Retrieves an agent definition by name.
     * Callers should cast to their expected AgentDefinition<TOutput> shape before invoking typed callbacks.
     */
    getDefinition(name) {
        return this.agents.get(name);
    }
    /**
     * Returns all active agent definitions.
     */
    getAllDefinitions() {
        return Array.from(this.agents.values());
    }
}
//# sourceMappingURL=registry.js.map