export interface SafeExecOptions { /** Working directory */ cwd?: string; /** Environment variables */ env?: NodeJS.ProcessEnv; /** Timeout in milliseconds */ timeout?: number; /** Override the default 10MB maxBuffer limit */ maxBuffer?: number; /** Automatically trim the returned string. Defaults to true. */ trim?: boolean; /** Pass input to stdin */ input?: string; } /** * Execute a command synchronously with cross-platform shell protections. * * Uses `cross-spawn` instead of Node's native `child_process.execFileSync` * to avoid the `shell: IS_WIN` argument-escaping vulnerability that * previously let shell metacharacters (like `&`, `|`, `>`, `"`) in * argument values be interpreted by cmd.exe on Windows. `cross-spawn` * handles Windows `.cmd`/`.bat` shim resolution internally without * enabling `shell: true` at the Node layer, so `git.cmd`, `npm.cmd`, * and other shims still resolve while shell metacharacters in argument * values pass through verbatim (mmnto/totem#1329). * * Behavioral guarantees preserved from the previous implementation: * - Synchronous API, always returns a string (never a Buffer). * - UTF-8 encoding enforced on stdout. * - 10MB default `maxBuffer` (prevents ENOBUFS on large git diffs). * - Auto-trims output (disable with `trim: false`). * - Throws on non-zero exit, ENOENT, signal termination, or internal * spawn error. The thrown Error preserves `.cause` for chain walking. * - New (strictly additive): the thrown Error exposes optional * `.status`, `.stdout`, and `.stderr` fields matching `cross-spawn`'s * richer return shape. Callers that only read `.message` and `.cause` * continue to work unchanged. */ export declare function safeExec(command: string, args?: string[], options?: SafeExecOptions): string; /** * Error shape extension. Adds optional `.status`, `.signal`, `.stdout`, * and `.stderr` fields to the thrown Error object. Callers that only * read `.message` and `.cause` (the pre-mmnto/totem#1329 contract) * continue to work. Callers that want typed access to the extension * fields can narrow via `err as Error & SafeExecErrorFields`. * * Exported so downstream packages can type-narrow without falling back * to `any`. The fields match the raw `SpawnSyncReturns` shape that * `cross-spawn.sync` returns, so `.stdout` and `.stderr` preserve any * trailing whitespace from the subprocess. Message formatting uses * trimmed copies internally, but the fields on the error object are * raw. */ export interface SafeExecErrorFields { status?: number | null; signal?: NodeJS.Signals | null; stdout?: string; stderr?: string; } /** * Build a human-readable description from a safeExec error, unrolling * the cause chain so callers don't need to walk it manually. * * Deduplicates: if the cause message is already embedded in the wrapper * (the pre-migration concat behavior), it is not appended again. */ export declare function describeSafeExecError(err: unknown): string; //# sourceMappingURL=exec.d.ts.map