export interface PowerShellConfig { shell: string; args: string[]; flavor: "pwsh" | "powershell"; /** Whether to hide the window on Windows (windowsHide spawn option) */ windowsHide: boolean; } /** * Get shell configuration based on platform. * Resolution order: * 1. User-specified shellPath in settings.json * 2. On Windows: Git Bash in known locations, then bash on PATH * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh */ export declare function getShellConfig(): { shell: string; args: string[]; }; export declare function getPowerShellConfig(): PowerShellConfig; export declare function resetShellConfigCache(): void; export declare function getShellEnv(): NodeJS.ProcessEnv; /** * Sanitize binary output for display/storage. * Removes characters that crash string-width or cause display issues: * - Control characters (except tab, newline, carriage return) * - Lone surrogates * - Unicode Format characters (crash string-width due to a bug) * - Characters with undefined code points */ export declare function sanitizeBinaryOutput(str: string): string; /** * Kill a process and all its children (cross-platform) */ export declare function killProcessTree(pid: number): void; /** * PowerShell preamble for remote execution via SSH. * Sets up: error action preference, progress suppression, output encoding. * Compatible with Windows PowerShell 5.1 and PowerShell 7+. */ export declare const REMOTE_POWERSHELL_PREAMBLE: string; /** * Encode a PowerShell script as a UTF-16LE Base64 string suitable for * powershell.exe -EncodedCommand. * * Windows PowerShell and pwsh both require UTF-16LE encoding. * Using UTF-8 produces garbled output or parse errors. * * No BOM is included — both PowerShell 7 and Windows PowerShell 5.1 * accept UTF-16LE without BOM. A BOM (U+FEFF) causes corruption of * the first statement when used with -EncodedCommand. * * This function is pure — it does not execute anything, does not shell-quote, * and is fully unit-testable. * * @param source - PowerShell source code (can contain Unicode) * @returns Base64-encoded UTF-16LE string (no BOM) */ export declare function encodePowerShellCommand(source: string): string; /** * Validate an SSH hostname/destination for use in spawn argv. * * Rejects: empty hosts, hosts starting with "-" (option injection), * hosts containing spaces or newlines, hosts that are empty after trim. * * Accepts: user@host, host-alias, IPv4, IPv6 (with or without brackets), * and any hostname valid per RFC 952/1123. * * Throws a descriptive Error on invalid input so the caller gets a * clear failure instead of a silently corrupted command. */ export declare function validateSshHost(host: string): void; /** * Build argv for executing a PowerShell command on a remote Windows host via SSH. * * Produces a structured argv array suitable for spawn/exec with shell: false. * Uses -EncodedCommand for reliable quoting, exit code propagation, and Unicode. * * The returned array includes "--" to prevent hostname-based option injection. * * @param host - SSH hostname (validated; must not be empty, start with -, or contain spaces) * @param command - PowerShell source code * @returns Structured argv for the ssh process */ export declare function buildRemotePowerShellArgs(host: string, command: string): string[]; /** * Build argv for a simple PowerShell command on a remote Windows host via SSH. * * Uses -Command (not -EncodedCommand). Only appropriate for simple commands * without pipes, complex quoting, multiline scripts, or untrusted data. * * The returned array includes "--" to prevent hostname-based option injection. * * @param host - SSH hostname (validated) * @param command - Simple PowerShell command * @returns Structured argv for the ssh process */ export declare function buildSimpleRemotePowerShellArgs(host: string, command: string): string[]; //# sourceMappingURL=shell.d.ts.map