import type { Context } from "@steve.kite/stdlib"; import type { ProcessStartOptions } from "./types.js"; /** * How a running command is talked to. * * Pipes and a pseudo-terminal differ in ways the process bookkeeping should not * have to know about: a terminal merges the two output streams, echoes input, * and reports one exit rather than a separate stream close. */ export interface ProcessTransport { readonly kind: "pipe" | "pty"; readonly pid: number | null; /** Whether stderr arrives separately. A terminal merges it into stdout. */ readonly separatesStderr: boolean; endInput(data?: string | Uint8Array): void; onError(listener: (error: Error) => void): void; onExit(listener: (code: number | null, signal: NodeJS.Signals | null) => void): void; onOutputEnd(listener: () => void): void; onStderr(listener: (chunk: Buffer) => void): void; onStdout(listener: (chunk: Buffer) => void): void; /** Releases every listener; the command may still be running. */ release(): void; write(data: string | Uint8Array): boolean; } /** * Discourages terminal-shaped output from a command the model cannot watch. * * A pseudo-terminal invites full-screen redraws, colour, and pagers that wait * for a keypress. None of that survives being read as text, so the environment * asks programs not to produce it in the first place. */ export declare const NON_INTERACTIVE_TERMINAL_ENVIRONMENT: NodeJS.ProcessEnv; export declare function startProcessTransport(ctx: Context, options: ProcessStartOptions, started: (ctx: Context, transport: ProcessTransport) => Result | PromiseLike): Promise>;