import { type GlobalErrorHandler } from "./global-error.js"; /** Get command-line arguments (cross-runtime: Deno.args or process.argv). */ export declare function getArgs(): string[]; /** Exit the process with an optional code (cross-runtime: Deno.exit or process.exit). */ export declare function exit(code?: number): never; /** Return the current working directory. */ export declare function cwd(): string; export declare function chdir(directory: string): void; export declare function pid(): number; export declare function memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; external: number; }; /** * Read the real V8 heap size limit in bytes from runtime heap statistics * (`node:v8` `getHeapStatistics().heap_size_limit`). * * Unlike env strings such as `DENO_V8_FLAGS`, this reflects the limit V8 is * actually enforcing. Returns `undefined` when the runtime does not expose a * fixed V8 heap limit. Bun's `node:v8` compatibility value is process-derived * and changes as peak memory grows, so it is intentionally not accepted. */ export declare function getV8HeapSizeLimit(): number | undefined; /** * Check if stdin is a TTY (terminal) */ export declare function isInteractive(): boolean; /** * Check if stdout is a TTY (terminal) */ export declare function isStdoutTTY(): boolean; /** * Get terminal size (columns and rows) * Returns default fallback values if terminal size cannot be determined */ export declare function getTerminalSize(): { columns: number; rows: number; }; /** * Get runtime version string */ export declare function getRuntimeVersion(): string; /** * Get the operating system type * Returns: "darwin" (macOS), "linux", "windows", or the raw platform string */ export declare function getOsType(): string; /** * Register a SIGINT or SIGTERM handler for graceful shutdown. * * If registration fails after a runtime partially installs the handler, this * function removes that exact registration. When removal also fails, both * failures are exposed in registration-first order through an AggregateError. * * @returns An idempotent disposer for the exact signal and handler pair. */ export declare function onSignal(signal: "SIGINT" | "SIGTERM", handler: () => void): () => void; /** * Register global error handlers for uncaught exceptions and unhandled promise rejections. * These handlers prevent the process from crashing due to application code errors. * * IMPORTANT: These handlers should be registered early in the application lifecycle * to catch errors that escape try/catch blocks. * * @param onError - Callback invoked with the error. Return true to prevent process exit. */ export declare function onGlobalError(onError: GlobalErrorHandler): void; /** * Unreference a timer to prevent it from keeping the process alive */ export declare function unrefTimer(timerId: ReturnType): void; /** * Get the executable path of the current runtime */ export declare function execPath(): string; /** * Get process uptime in seconds * Returns OS uptime on Deno, process uptime on Node.js */ export declare function uptime(): number; /** * Get stdout stream for writing * Returns null if not available (e.g., in browser/workers) */ export declare function getStdout(): { write: (data: string) => void; } | null; /** * Write text directly to stdout (sync) * No-op if stdout is not available */ export declare function writeStdout(text: string): void; /** * Write data to stdout asynchronously * Returns a promise that resolves when the write is complete */ export declare function writeStdoutAsync(data: Uint8Array): Promise; /** * Synchronous prompt function that works across Deno and Bun. * Displays a message and reads user input from stdin. * * Note: This relies on globalThis.prompt which is available in Deno and Bun. * Returns null in environments where prompt is not available (e.g., Node.js ESM). */ export declare function promptSync(message?: string): string | null; /** @internal Minimal `node:fs` surface used for synchronous stdin reads. */ export interface NodeReadSyncFs { readSync(fd: number, buffer: Uint8Array, offset: number, length: number, position: null): number; } /** * @internal Exported for tests: the Node branch of {@link readStdinByteSync}. * * libuv puts a raw-mode TTY in non-blocking mode, so `readSync` throws EAGAIN * every time the user has not typed yet. That means "nothing ready", not EOF — * treating it as EOF ends the read before a single keystroke arrives. */ export declare function testReadStdinByteSyncNode(fs: NodeReadSyncFs, buf: Uint8Array, sleep?: (ms: number) => void): number | null; /** * Read a single byte from stdin synchronously. * Requires raw mode to be enabled for character-by-character reading. * Returns null on EOF or if stdin is not available. */ export declare function readStdinByteSync(): number | null; //# sourceMappingURL=lifecycle.d.ts.map