/**
 * Agent Master Singleton
 *
 * Single source of truth for whether this process is serving as master.
 * Shared across all tool executions in the same process.
 */
let _agentServer = null;
let _agentConfig = null;
export const agentMaster = {
    /** Get current master server instance */
    getServer() {
        return _agentServer;
    },
    /** Get current master config */
    getConfig() {
        return _agentConfig;
    },
    /** Check if currently serving as master */
    isServing() {
        return !!_agentServer;
    },
    /** Set master server instance */
    setServer(server, config) {
        _agentServer = server;
        _agentConfig = config;
    },
    /** Clear master server instance (on shutdown) */
    clear() {
        if (_agentServer) {
            _agentServer.close();
        }
        _agentServer = null;
        _agentConfig = null;
    },
    /** Get master endpoint if serving */
    getEndpoint() {
        if (_agentServer && _agentConfig) {
            return `http://localhost:${_agentServer.port}`;
        }
        return null;
    },
};
//# sourceMappingURL=agent-master.js.map