import type { ProcessHost } from './ProcessHost.ts'; /** Conventional exit code for a process terminated by SIGINT (128 + 2). */ export declare const INTERRUPT_EXIT_CODE = 130; /** * How long the pre-session startup path gets to unwind on its own after an * interrupt before the process is terminated. Startup checkpoints normally * unwind well inside this; the timer exists for the awaits that never return. */ export declare const DEFAULT_STARTUP_INTERRUPT_TIMEOUT_MS = 10000; /** Output sink used on the interrupt path; failures in it are swallowed. */ export interface RuntimeInterruptLogger { error(...values: readonly unknown[]): void; info(...values: readonly unknown[]): void; } export declare function logInterruptError(logger: RuntimeInterruptLogger, ...values: readonly unknown[]): void; export declare function logInterruptInfo(logger: RuntimeInterruptLogger, ...values: readonly unknown[]): void; /** Adapts a {@link ProcessHost}'s IO into the interrupt-path logger shape. */ export declare function hostInterruptLogger(host: Pick): RuntimeInterruptLogger; export interface RuntimeInterruptControllerParams { readonly host: ProcessHost; /** Overrides {@link DEFAULT_STARTUP_INTERRUPT_TIMEOUT_MS}. Zero or less disables the timer. */ readonly startupTimeoutMs?: number; } export interface RuntimeInterruptController { /** True once at least one interrupt has been observed. */ readonly isInterrupted: boolean; /** True once {@link adoptSession} has handed the graceful path to a session. */ readonly isSessionAdopted: boolean; /** * Aborted on the first interrupt. Startup work that can be cut short should * watch this instead of running to completion. */ readonly signal: AbortSignal; /** * Hands the graceful path to a bound runtime session. After this the * controller only escalates repeat interrupts — the session owns the first. */ adoptSession(): void; /** Removes the process listener. Only needed when startup never reaches a session. */ dispose(): void; } /** * Installs the process-wide interrupt policy for one CLI run. * * Two gaps make an un-escalated Ctrl+C look like a dead key, and this closes * both: * * 1. **Before the runtime session exists** nothing is bound, so the whole * startup path — wallet resolution, connection setup, provider graph * construction — relies on the host's default interrupt behavior. * Installing this controller takes on the job of getting the process out: * it aborts {@link RuntimeInterruptController.signal} for the startup * checkpoints and arms a timer for awaits that never return. * 2. **After the session is bound** `RuntimeSession.handleInterrupt` coalesces * every later interrupt into the first one and keeps its process listener * registered, so a shutdown that stalls swallows every subsequent Ctrl+C. * This controller stays registered alongside it and turns the second * interrupt into an immediate exit. */ export declare function installRuntimeInterruptController({ host, startupTimeoutMs }: RuntimeInterruptControllerParams): RuntimeInterruptController; //# sourceMappingURL=runtimeInterrupt.d.ts.map