"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mcpRegistry = void 0;
/**
 * Singleton registry for the MCP adapter.
 *
 * Follows the same pattern as telemetryRegistry (single adapter):
 * - register(adapter) — set the MCP adapter
 * - connect()         — start server + connect clients
 * - disconnect()      — stop server + disconnect clients
 * - clear()           — reset (for tests)
 *
 * The built-in adapter manages both the Human Queue MCP server
 * and client connections to external MCP servers.
 */
class LTMcpRegistry {
    constructor() {
        this.adapter = null;
        this.connected = false;
    }
    register(adapter) {
        this.adapter = adapter;
    }
    async connect() {
        if (this.connected || !this.adapter)
            return;
        await this.adapter.connect();
        this.connected = true;
    }
    async disconnect() {
        if (!this.adapter)
            return;
        await this.adapter.disconnect();
        this.connected = false;
    }
    clear() {
        this.adapter = null;
        this.connected = false;
    }
    get hasAdapter() {
        return this.adapter !== null;
    }
    get current() {
        return this.adapter;
    }
}
exports.mcpRegistry = new LTMcpRegistry();
