/**
 * Cross-Platform Signal Handler for Awake Lambda Development
 *
 * Provides graceful shutdown handling across macOS, Linux, and Windows.
 * Handles SIGTERM, SIGINT on Unix and process termination on Windows.
 *
 * @module bin/commands/dev/signal-handler
 *
 * @see Requirements 7.4
 */
import { EventEmitter } from 'events';
/**
 * Signal types that can be handled.
 */
export type SignalType = 'SIGINT' | 'SIGTERM' | 'SIGHUP' | 'SIGBREAK' | 'exit' | 'uncaughtException' | 'unhandledRejection';
/**
 * Shutdown reason.
 */
export interface ShutdownReason {
    /** Signal or event that triggered shutdown */
    readonly signal: SignalType | string;
    /** Exit code (if applicable) */
    readonly exitCode?: number;
    /** Error that caused shutdown (if applicable) */
    readonly error?: Error;
    /** Timestamp of shutdown trigger */
    readonly timestamp: number;
}
/**
 * Shutdown handler function type.
 */
export type ShutdownHandler = (reason: ShutdownReason) => Promise<void> | void;
/**
 * Signal handler configuration.
 */
export interface SignalHandlerConfig {
    /** Timeout for graceful shutdown in milliseconds (default: 10000) */
    readonly shutdownTimeoutMs?: number;
    /** Whether to exit process after shutdown (default: true) */
    readonly exitOnShutdown?: boolean;
    /** Exit code to use on graceful shutdown (default: 0) */
    readonly gracefulExitCode?: number;
    /** Exit code to use on forced shutdown (default: 1) */
    readonly forcedExitCode?: number;
    /** Whether to handle uncaught exceptions (default: true) */
    readonly handleUncaughtExceptions?: boolean;
    /** Whether to handle unhandled rejections (default: true) */
    readonly handleUnhandledRejections?: boolean;
}
/**
 * Events emitted by SignalHandler.
 */
export interface SignalHandlerEvents {
    'shutdown-start': (reason: ShutdownReason) => void;
    'shutdown-complete': (reason: ShutdownReason) => void;
    'shutdown-timeout': (reason: ShutdownReason) => void;
    'shutdown-error': (error: Error, reason: ShutdownReason) => void;
}
/**
 * Signal handler state.
 */
export type SignalHandlerState = 'idle' | 'registered' | 'shutting-down' | 'shutdown';
/**
 * Cross-Platform Signal Handler.
 *
 * Provides graceful shutdown handling across macOS, Linux, and Windows.
 * Registers handlers for various termination signals and coordinates
 * cleanup before process exit.
 *
 * @see Requirements 7.4
 *
 * @example
 * ```typescript
 * const signalHandler = new SignalHandler({
 *   shutdownTimeoutMs: 10000,
 * });
 *
 * // Register cleanup handlers
 * signalHandler.onShutdown(async (reason) => {
 *   console.log('Shutting down due to:', reason.signal);
 *   await deregisterSession();
 *   await closeMqttConnection();
 *   await shutdownWorker();
 * });
 *
 * // Start listening for signals
 * signalHandler.register();
 *
 * // Later, to manually trigger shutdown
 * await signalHandler.shutdown('manual');
 * ```
 */
export declare class SignalHandler extends EventEmitter {
    /** Current state */
    private state;
    /** Configuration */
    private readonly config;
    /** Registered shutdown handlers */
    private readonly shutdownHandlers;
    /** Whether shutdown has been initiated */
    private shutdownInitiated;
    /** Bound signal handlers for cleanup */
    private boundHandlers;
    /**
     * Create a new SignalHandler.
     *
     * @param config - Signal handler configuration
     */
    constructor(config?: SignalHandlerConfig);
    /**
     * Get current state.
     */
    getState(): SignalHandlerState;
    /**
     * Check if shutdown has been initiated.
     */
    isShuttingDown(): boolean;
    /**
     * Register a shutdown handler.
     *
     * Handlers are called in order of registration during shutdown.
     *
     * @param handler - Shutdown handler function
     * @returns This instance for chaining
     */
    onShutdown(handler: ShutdownHandler): this;
    /**
     * Register signal handlers.
     *
     * Sets up handlers for SIGINT, SIGTERM, SIGHUP (Unix) and
     * SIGBREAK, exit events (Windows).
     *
     * @see Requirements 7.4
     */
    register(): void;
    /**
     * Register a specific signal handler.
     *
     * @param signal - Signal to handle
     * @private
     */
    private registerSignal;
    /**
     * Unregister all signal handlers.
     */
    unregister(): void;
    /**
     * Initiate graceful shutdown.
     *
     * @param reason - Shutdown reason
     * @private
     */
    private initiateShutdown;
    /**
     * Manually trigger shutdown.
     *
     * @param signal - Signal name for logging
     * @param exitCode - Exit code to use
     */
    shutdown(signal?: string, exitCode?: number): Promise<void>;
    /**
     * Get diagnostic information.
     */
    getDiagnostics(): {
        state: SignalHandlerState;
        shutdownInitiated: boolean;
        handlerCount: number;
        registeredSignals: string[];
        config: SignalHandlerConfig;
    };
}
/**
 * Create a signal handler with common defaults for Live Dev CLI.
 *
 * @param options - Additional options
 * @returns Configured SignalHandler instance
 */
export declare function createRuntimeAwakeSignalHandler(options?: {
    onShutdown?: ShutdownHandler;
    shutdownTimeoutMs?: number;
}): SignalHandler;
/**
 * Check if the current platform is Windows.
 */
export declare function isWindows(): boolean;
/**
 * Check if the current platform is macOS.
 */
export declare function isMacOS(): boolean;
/**
 * Check if the current platform is Linux.
 */
export declare function isLinux(): boolean;
/**
 * Get the appropriate termination signal for the current platform.
 */
export declare function getTerminationSignal(): NodeJS.Signals;
/**
 * Get the appropriate interrupt signal for the current platform.
 */
export declare function getInterruptSignal(): NodeJS.Signals;
