/** * Leaper Agent – Terminal Tool * * Local-only command execution (no Docker / Modal / SSH). * Translates the core logic of Python tools/terminal_tool.py. */ export interface CommandResult { stdout: string; stderr: string; exitCode: number; timedOut: boolean; backgroundPid?: number; } export interface ExecOptions { /** Working directory for the command. */ cwd?: string; /** Timeout in milliseconds. Default: 30 000. */ timeout?: number; /** Maximum characters kept per stream. Default: 50 000. */ maxOutputChars?: number; /** Extra environment variables merged on top of process.env. */ env?: Record; /** Run the process in the background; return immediately. */ background?: boolean; } export interface ProcessRecord { pid: number; cmd: string; startedAt: Date; background: boolean; } /** * Execute a shell command. * * - Captures stdout and stderr into in-memory buffers. * - Kills the child process on timeout and sets `timedOut = true`. * - When `opts.background` is true the function returns as soon as the child * is spawned and includes `backgroundPid` in the result. * - Output is truncated to `maxOutputChars` using a head+tail strategy. */ export declare function execCommand(cmd: string, opts?: ExecOptions): Promise; /** * Parse leading `KEY=value` assignments from a shell command string. * * Example: `"FOO=1 BAR=hello cmd arg"` → `{ FOO: '1', BAR: 'hello' }`. * The parsed tokens are the ones that appear *before* the first non-assignment * token (i.e. a token that is not of the form `IDENTIFIER=...`). */ export declare function parseEnvVars(cmd: string): Record; /** * Return `true` when the entire command is a single `KEY=value` assignment * (no spaces, no nested shell syntax – just variable assignment). */ export declare function isEnvVarAssignment(cmd: string): boolean; /** * Truncate `output` to at most `maxChars` characters. * * When truncation is needed the function keeps the first `maxChars/2` * characters, appends a `\n...[truncated]...\n` marker, then appends the * last `maxChars/2` characters of the original string. */ export declare function truncateOutput(output: string, maxChars: number): string; /** * Return a snapshot of currently-tracked background processes. */ export declare function listProcesses(): ProcessRecord[]; /** * Attempt to kill a tracked background process by PID. * * Returns `true` if the signal was delivered successfully, `false` otherwise. */ export declare function killProcess(pid: number): boolean; /** * Validate and resolve a working-directory path. * * - `~` is expanded to the user's home directory. * - Relative paths are resolved against `process.cwd()`. * - Defaults to `process.cwd()` when `cwd` is undefined or empty. * - Throws if the resolved path does not exist or is not a directory. */ export declare function resolveWorkingDir(cwd?: string): string; //# sourceMappingURL=terminal.d.ts.map