/** * Leaper Agent – Code Execution Tool * * Runs code in a subprocess sandbox. * Translates the core logic of Python tools/code_execution_tool.py. * * Supported languages: javascript, typescript, python, shell, bash. * Each run: * 1. Creates a temp directory with a random suffix. * 2. Writes the code to an appropriately-named file. * 3. Spawns the interpreter in that directory. * 4. Cleans up the temp directory even on timeout. * Sensitive environment variables (containing KEY, TOKEN, SECRET, PASSWORD) * are scrubbed from the subprocess environment. */ export interface CodeExecOptions { /** Timeout in milliseconds. Default: 30 000. */ timeout?: number; /** Maximum total characters in stdout+stderr. Default: 50 000. */ maxOutputChars?: number; /** Working directory for the interpreter. Default: a fresh temp dir. */ cwd?: string; /** Extra environment variables merged into the scrubbed subprocess env. */ env?: Record; } export interface CodeExecResult { stdout: string; stderr: string; exitCode: number; timedOut: boolean; language: string; error?: string; } export type SupportedLanguage = 'javascript' | 'typescript' | 'python' | 'shell' | 'bash'; /** * Execute `code` in an isolated subprocess. * * The code is written to a temp file whose extension matches the language, * then run with the appropriate interpreter. The temp directory is always * removed after execution (success, error, or timeout). */ export declare function executeCode(language: SupportedLanguage, code: string, opts?: CodeExecOptions): Promise; /** * Infer the language from code content using simple heuristics. * * Checks are applied in order; the first match wins. Falls back to * `'javascript'` when no strong signal is found. */ export declare function detectLanguage(code: string): SupportedLanguage; /** * Type-guard: return `true` when `lang` is one of the supported language IDs. */ export declare function isSupportedLanguage(lang: string): lang is SupportedLanguage; //# sourceMappingURL=code-execution.d.ts.map