import { spawn } from "node:child_process"; import type { NativePtyLoadResult } from "./native-loader.ts"; export interface PipeFallbackSessionOptions { readonly command: string; readonly args?: readonly string[]; readonly cwd?: string; readonly env?: Readonly>; readonly timeoutMs?: number; } export interface PipeFallbackSessionError { readonly code: "spawn_error"; readonly message: string; } export interface PipeFallbackSessionExit { readonly exitCode: number | null; readonly signal: NodeJS.Signals | null; readonly timedOut: boolean; readonly error?: PipeFallbackSessionError; } export type PipeFallbackOperationResult = { readonly ok: true; readonly note: string; } | { readonly ok: false; readonly code: "exited" | "not_pty" | "not_started" | "stdin_unavailable"; readonly note: string; }; type ChildProcessHandle = ReturnType; type DataHandler = (chunk: Buffer) => void; type ExitHandler = (exit: PipeFallbackSessionExit) => void; export declare function isPipeFallbackForced(env?: Readonly>): boolean; export declare function shouldUsePipeFallback(nativeLoadResult: NativePtyLoadResult, env?: Readonly>): boolean; /** * Terminate the child, preferring its whole process group on POSIX. The * detached child is its own group leader and grandchildren inherit the stdio * pipes, so leaving them alive keeps 'close' from ever firing (the POSIX twin * of the Windows taskkill /T branch below). Every path that stops a child must * go through here: when the group signal is unavailable (Windows, no pid) or * the group is already gone, it still falls back to a direct kill, so the * child is never left running. */ export declare function terminateChildTree(child: Pick, signal: NodeJS.Signals): "group" | "direct"; export declare class PipeFallbackSession { readonly backend = "pipe-fallback"; readonly note = "Running with child_process pipe fallback because no PTY backend is active; terminal screen state and resize are unavailable."; readonly options: PipeFallbackSessionOptions; private child; private exitResult; private exitPromise; private resolveExit; private spawnError; private timedOut; private timeoutHandle; private readonly dataHandlers; private readonly exitHandlers; constructor(options: PipeFallbackSessionOptions); start(): this; onData(handler: DataHandler): () => void; onExit(handler: ExitHandler): () => void; write(data: string | Uint8Array): PipeFallbackOperationResult; closeInput(): PipeFallbackOperationResult; resize(cols: number, rows: number): PipeFallbackOperationResult; kill(signal?: NodeJS.Signals): PipeFallbackOperationResult; waitExit(): Promise; private emitData; private settleExit; } export declare function createPipeFallbackSession(options: PipeFallbackSessionOptions): PipeFallbackSession; export {}; //# sourceMappingURL=pipe-fallback.d.ts.map