"use strict";
/**
 * Standardized exit codes for CCS CLI
 *
 * Exit codes follow Unix conventions:
 * - 0: Success
 * - 1-125: Application errors
 * - 126-127: Command execution errors (reserved by shell)
 * - 128+N: Signal termination (128 + signal number)
 * - 130: SIGINT (Ctrl+C) - 128 + 2
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRecoverable = exports.isSuccess = exports.EXIT_CODE_DESCRIPTIONS = exports.ExitCode = void 0;
var ExitCode;
(function (ExitCode) {
    /** Successful execution */
    ExitCode[ExitCode["SUCCESS"] = 0] = "SUCCESS";
    /** General/unspecified error */
    ExitCode[ExitCode["GENERAL_ERROR"] = 1] = "GENERAL_ERROR";
    /** Configuration file errors (missing, invalid, corrupt) */
    ExitCode[ExitCode["CONFIG_ERROR"] = 2] = "CONFIG_ERROR";
    /** Network-related errors (connection, timeout, DNS) */
    ExitCode[ExitCode["NETWORK_ERROR"] = 3] = "NETWORK_ERROR";
    /** Authentication/authorization errors (invalid token, expired, forbidden) */
    ExitCode[ExitCode["AUTH_ERROR"] = 4] = "AUTH_ERROR";
    /** Binary/executable errors (missing Claude CLI, corrupted binary) */
    ExitCode[ExitCode["BINARY_ERROR"] = 5] = "BINARY_ERROR";
    /** Provider-specific errors (API errors, rate limits, service unavailable) */
    ExitCode[ExitCode["PROVIDER_ERROR"] = 6] = "PROVIDER_ERROR";
    /** Profile not found or invalid */
    ExitCode[ExitCode["PROFILE_ERROR"] = 7] = "PROFILE_ERROR";
    /** Proxy-related errors (startup failure, port conflict) */
    ExitCode[ExitCode["PROXY_ERROR"] = 8] = "PROXY_ERROR";
    /** Migration errors (failed to migrate config) */
    ExitCode[ExitCode["MIGRATION_ERROR"] = 9] = "MIGRATION_ERROR";
    /** User aborted operation (Ctrl+C, SIGINT) */
    ExitCode[ExitCode["USER_ABORT"] = 130] = "USER_ABORT";
})(ExitCode || (exports.ExitCode = ExitCode = {}));
/**
 * Human-readable descriptions for exit codes
 * Used in error messages and documentation
 */
exports.EXIT_CODE_DESCRIPTIONS = {
    [ExitCode.SUCCESS]: 'Success',
    [ExitCode.GENERAL_ERROR]: 'General error',
    [ExitCode.CONFIG_ERROR]: 'Configuration error',
    [ExitCode.NETWORK_ERROR]: 'Network error',
    [ExitCode.AUTH_ERROR]: 'Authentication error',
    [ExitCode.BINARY_ERROR]: 'Binary/executable error',
    [ExitCode.PROVIDER_ERROR]: 'Provider error',
    [ExitCode.PROFILE_ERROR]: 'Profile error',
    [ExitCode.PROXY_ERROR]: 'Proxy error',
    [ExitCode.MIGRATION_ERROR]: 'Migration error',
    [ExitCode.USER_ABORT]: 'User abort (Ctrl+C)',
};
/**
 * Check if an exit code indicates success
 */
function isSuccess(code) {
    return code === ExitCode.SUCCESS;
}
exports.isSuccess = isSuccess;
/**
 * Check if an exit code indicates a recoverable error
 * (errors that might succeed on retry)
 */
function isRecoverable(code) {
    const recoverableCodes = [ExitCode.NETWORK_ERROR, ExitCode.PROVIDER_ERROR];
    return recoverableCodes.includes(code);
}
exports.isRecoverable = isRecoverable;
//# sourceMappingURL=exit-codes.js.map