// Define BufferEncoding type for TypeScript compatibility.
type BufferEncoding = globalThis.BufferEncoding;
// Type for promise-spawn options.
export type PromiseSpawnOptions = {
    cwd?: string | undefined;
    stdioString?: boolean | undefined;
    stdio?: StdioType | undefined;
    env?: NodeJS.ProcessEnv | undefined;
    shell?: boolean | string | undefined;
    signal?: AbortSignal | undefined;
    timeout?: number | undefined;
    uid?: number | undefined;
    gid?: number | undefined;
};
// Type for promise-spawn result.
export type PromiseSpawnResult = Promise<{
    cmd: string;
    args: string[] | readonly string[];
    code: number;
    signal: NodeJS.Signals | null;
    stdout: string | Buffer;
    stderr: string | Buffer;
}> & {
    process: ChildProcessType;
    stdin: WritableStreamType | null;
};
/**
 * Check if a value is a spawn error.
 */
export type SpawnError = {
    args: string[];
    cmd: string;
    code: number;
    name: string;
    message: string;
    signal: NodeJS.Signals | null;
    stack: string;
    stderr: string | Buffer;
    stdout: string | Buffer;
};
export type SpawnErrorWithOutputString = SpawnError & {
    stdout: string;
    stderr: string;
};
export type SpawnErrorWithOutputBuffer = SpawnError & {
    stdout: Buffer;
    stderr: Buffer;
};
export type SpawnExtra = Record<string, unknown>;
export type IOType = 'pipe' | 'ignore' | 'inherit' | 'overlapped';
export type StdioType = IOType | 'ipc' | Array<IOType | 'ipc'>;
export interface SpawnSyncReturns<T> {
    pid: number;
    output: Array<T | null>;
    stdout: T;
    stderr: T;
    status: number | null;
    signal: NodeJS.Signals | null;
    error?: Error | undefined;
}
/**
 * Check if a value is a spawn error with expected properties.
 */
/*@__NO_SIDE_EFFECTS__*/
export declare function isSpawnError(value: unknown): value is SpawnError;
/**
 * Check if stdio configuration matches a specific type.
 */
/*@__NO_SIDE_EFFECTS__*/
export declare function isStdioType(stdio: string | string[], type?: StdioType | undefined): boolean;
/*@__NO_SIDE_EFFECTS__*/
// Duplicated from Node.js child_process.SpawnOptions
// These are the options passed to child_process.spawn()
interface NodeSpawnOptions {
    cwd?: string | URL | undefined;
    env?: NodeJS.ProcessEnv | undefined;
    argv0?: string | undefined;
    // biome-ignore lint/suspicious/noExplicitAny: Stdio can be complex union of types from Node.js.
    stdio?: any;
    detached?: boolean | undefined;
    uid?: number | undefined;
    gid?: number | undefined;
    serialization?: 'json' | 'advanced' | undefined;
    shell?: boolean | string | undefined;
    windowsVerbatimArguments?: boolean | undefined;
    windowsHide?: boolean | undefined;
    signal?: AbortSignal | undefined;
    timeout?: number | undefined;
    killSignal?: NodeJS.Signals | number | undefined;
}
// Duplicated from Node.js child_process.ChildProcess
// This represents a spawned child process
interface ChildProcessType {
    stdin: NodeJS.WritableStream | null;
    stdout: NodeJS.ReadableStream | null;
    stderr: NodeJS.ReadableStream | null;
    // biome-ignore lint/suspicious/noExplicitAny: IPC channel type from Node.js.
    readonly channel?: any;
    readonly stdio: [
        NodeJS.WritableStream | null,
        NodeJS.ReadableStream | null,
        NodeJS.ReadableStream | null,
        NodeJS.ReadableStream | NodeJS.WritableStream | null | undefined,
        NodeJS.ReadableStream | NodeJS.WritableStream | null | undefined
    ];
    readonly killed: boolean;
    readonly pid?: number | undefined;
    readonly connected: boolean;
    readonly exitCode: number | null;
    readonly signalCode: NodeJS.Signals | null;
    readonly spawnargs: string[];
    readonly spawnfile: string;
    kill(signal?: NodeJS.Signals | number): boolean;
    // biome-ignore lint/suspicious/noExplicitAny: IPC message type from Node.js.
    send(message: any, callback?: (error: Error | null) => void): boolean;
    send(
    // biome-ignore lint/suspicious/noExplicitAny: IPC message and handle types from Node.js.
    message: any, 
    // biome-ignore lint/suspicious/noExplicitAny: IPC message and handle types from Node.js.
    sendHandle?: any | undefined, callback?: (error: Error | null) => void): boolean;
    send(
    // biome-ignore lint/suspicious/noExplicitAny: IPC message, handle, and options types from Node.js.
    message: any, 
    // biome-ignore lint/suspicious/noExplicitAny: IPC message, handle, and options types from Node.js.
    sendHandle?: any | undefined, 
    // biome-ignore lint/suspicious/noExplicitAny: IPC message, handle, and options types from Node.js.
    options?: any | undefined, callback?: (error: Error | null) => void): boolean;
    disconnect(): void;
    unref(): void;
    ref(): void;
}
// Duplicated from Node.js stream.Writable
interface WritableStreamType {
    writable: boolean;
    writableEnded: boolean;
    writableFinished: boolean;
    writableHighWaterMark: number;
    writableLength: number;
    writableObjectMode: boolean;
    writableCorked: number;
    destroyed: boolean;
    write(
    // biome-ignore lint/suspicious/noExplicitAny: Stream chunk can be any type.
    chunk: any, encoding?: BufferEncoding | undefined, callback?: (error?: Error | null) => void): boolean;
    // biome-ignore lint/suspicious/noExplicitAny: Stream chunk can be any type.
    write(chunk: any, callback?: (error?: Error | null) => void): boolean;
    end(cb?: () => void): this;
    // biome-ignore lint/suspicious/noExplicitAny: Stream chunk can be any type.
    end(chunk: any, cb?: () => void): this;
    // biome-ignore lint/suspicious/noExplicitAny: Stream chunk can be any type.
    end(chunk: any, encoding?: BufferEncoding | undefined, cb?: () => void): this;
    cork(): void;
    uncork(): void;
    destroy(error?: Error | undefined): this;
}
/**
 * Spawn a child process with enhanced error handling and output capture.
 */
export type SpawnOptions = import('./objects').Remap<NodeSpawnOptions & {
    spinner?: import('./spinner').Spinner | undefined;
    stdioString?: boolean;
    stripAnsi?: boolean;
}>;
export type SpawnResult = PromiseSpawnResult;
export type SpawnStdioResult = {
    cmd: string;
    args: string[] | readonly string[];
    code: number;
    signal: NodeJS.Signals | null;
    stdout: string | Buffer;
    stderr: string | Buffer;
};
/**
 * Spawn a child process and return a promise that resolves when it completes.
 *
 * SECURITY: This function uses array-based arguments which prevent command injection.
 * Arguments in the `args` array are passed directly to the OS without shell
 * interpretation. Shell metacharacters (;|&$()`) are treated as literal strings,
 * not as commands or operators. This is the PRIMARY SECURITY DEFENSE.
 *
 * Even when shell: true is used (on Windows for .cmd/.bat execution), the array-based
 * approach remains secure because Node.js properly escapes each argument before passing
 * to the shell.
 *
 * @param cmd - Command to execute (not user-controlled)
 * @param args - Array of arguments (safe even with user input due to array-based passing)
 * @param options - Spawn options
 * @param extra - Extra options for promise-spawn
 *
 * @example
 * // ✔ DO THIS - Array-based arguments
 * spawn('git', ['commit', '-m', userMessage])
 * // Each argument is properly escaped, even if userMessage = "foo; rm -rf /"
 *
 * @example
 * // ✖ NEVER DO THIS - String concatenation
 * spawn(`git commit -m "${userMessage}"`, { shell: true })
 * // Vulnerable to injection if userMessage = '"; rm -rf / #'
 */
export declare function spawn(cmd: string, args?: string[] | readonly string[], options?: SpawnOptions | undefined, extra?: SpawnExtra | undefined): SpawnResult;
/*@__NO_SIDE_EFFECTS__*/
/**
 * Synchronously spawn a child process.
 */
export type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>;
export declare function spawnSync(cmd: string, args?: string[] | readonly string[], options?: SpawnSyncOptions | undefined): SpawnSyncReturns<string | Buffer>;
export {};
