/** Callback invoked for each line of stdout/stderr during streaming exec. */ export type OnLine = (stream: "stdout" | "stderr", line: string) => void; /** @internal exported for testing — drop both env caches. */ export declare function _resetEnvCaches(): void; /** * Capture MSVC environment by running vcvarsall.bat and parsing `set` output. * Cached for the lifetime of the server process. Windows-only. */ export declare function getMsvcEnv(): Record; export interface ExecResult { success: boolean; stdout: string; stderr: string; exitCode: number; durationMs: number; } /** * Run a command with the MSVC environment, capturing output. Windows-only. */ export declare function runWithMsvc(cmd: string, cwd: string, timeoutMs?: number): ExecResult; /** * Run a command in the default shell, capturing output. */ export declare function runCommand(cmd: string, cwd: string, timeoutMs?: number): ExecResult; /** * Run an arbitrary executable with argv array (no shell). Use for inputs that * may contain user-controlled strings — eliminates shell-injection risk. */ export declare function runArgvStream(cmd: string, args: string[], cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal, env?: Record): Promise; /** * Run a command with the MSVC environment, streaming output line-by-line. */ export declare function runWithMsvcStream(cmd: string, cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal): Promise; /** * Run a command in the default shell, streaming output line-by-line. */ export declare function runCommandStream(cmd: string, cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal): Promise; /** * Capture ESP-IDF environment. Cached for the lifetime of the server process. * - Windows: runs export.bat and parses `set` output * - Linux/Mac: sources export.sh and captures env via null-delimited output */ export declare function getIdfEnv(): Record; /** * Run a command with the ESP-IDF environment, capturing output. */ export declare function runWithIdf(cmd: string, cwd: string, timeoutMs?: number): ExecResult; /** * Run a command with the ESP-IDF environment, streaming output line-by-line. */ export declare function runWithIdfStream(cmd: string, cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal): Promise; /** * Run with IDF env in argv mode (no shell) — use for commands taking * user-controlled args (port path, firmware path). */ export declare function runIdfArgvStream(cmd: string, args: string[], cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal): Promise; /** * Run a build command with the appropriate environment for the current platform. * Windows: MSVC env + cmd.exe shell. Unix: default shell. */ export declare function runBuild(cmd: string, cwd: string, timeoutMs?: number): ExecResult; /** * Run a build command with streaming output, platform-aware. * Windows: MSVC env + cmd.exe shell. Unix: default shell. */ export declare function runBuildStream(cmd: string, cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal): Promise; /** * Run a command with the ESP-IDF environment, platform-aware. */ export declare function runIdf(cmd: string, cwd: string, timeoutMs?: number): ExecResult; /** * Run a command with the ESP-IDF environment, streaming, platform-aware. */ export declare function runIdfStream(cmd: string, cwd: string, onLine: OnLine, timeoutMs?: number, signal?: AbortSignal): Promise; /** How many timestamped logs a detached launch leaves behind before the oldest * are removed. One per launch, and nothing else ever deletes them. */ export declare const KEEP_LAUNCH_LOGS = 20; /** * Delete all but the newest `keep` logs that share `sibling`'s naming scheme. * * Scoped to the sibling's own prefix on purpose: `hil_logs/` is shared with * console, diagnose and capture files, and a directory-wide sweep would eat * someone else's evidence. */ export declare function pruneLaunchLogs(sibling: string, keep?: number): void; /** * Spawn a detached process (for crosspad_run). * * With `logPath` both streams are appended to that file instead of discarded. * A simulator that dies during startup says why on stderr, and with stdio * ignored that explanation was gone by the time anyone asked. */ export declare function spawnDetached(exe: string, args: string[], cwd: string, logPath?: string): number | null;