"use strict";
/**
 * CLIProxy Proxy Lifecycle Service
 *
 * Handles start/stop/status operations for CLIProxy instances.
 * Delegates to session-tracker and service-manager for actual process management.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveSessionCount = exports.isProxyRunning = exports.startProxy = exports.stopProxy = exports.getProxyStatus = void 0;
const session_tracker_1 = require("../session-tracker");
const service_manager_1 = require("../service-manager");
const port_manager_1 = require("../config/port-manager");
/**
 * Get current proxy status
 */
function getProxyStatus(port = (0, port_manager_1.resolveLifecyclePort)()) {
    return (0, session_tracker_1.getProxyStatus)(port);
}
exports.getProxyStatus = getProxyStatus;
/**
 * Stop the running CLIProxy instance
 */
async function stopProxy(port = (0, port_manager_1.resolveLifecyclePort)()) {
    return (0, session_tracker_1.stopProxy)(port);
}
exports.stopProxy = stopProxy;
/**
 * Start CLIProxy service (or reuse existing running instance)
 */
async function startProxy(port = (0, port_manager_1.resolveLifecyclePort)(), verbose = false) {
    return (0, service_manager_1.ensureCliproxyService)(port, verbose);
}
exports.startProxy = startProxy;
/**
 * Check if proxy is currently running
 */
function isProxyRunning() {
    const status = (0, session_tracker_1.getProxyStatus)((0, port_manager_1.resolveLifecyclePort)());
    return status.running;
}
exports.isProxyRunning = isProxyRunning;
/**
 * Get active session count
 */
function getActiveSessionCount() {
    const status = (0, session_tracker_1.getProxyStatus)((0, port_manager_1.resolveLifecyclePort)());
    return status.sessionCount ?? 0;
}
exports.getActiveSessionCount = getActiveSessionCount;
//# sourceMappingURL=proxy-lifecycle-service.js.map