/** * Runtime detection — polyglot sandbox. * * Detects which language runtimes are installed on the host so the executor * can pick the right interpreter/compiler per language. Rewritten fresh in TS * (approach ported from context-mode `runtime.ts`); no code copied. * * Trust model: massa-th0th is a LOCAL-DEV tool that runs user-supplied code on * the host. Runtime detection here is best-effort and never escalates * privilege — it only reports what `command -v` / `where` + a `--version` * probe can see on PATH. */ export type Language = "javascript" | "typescript" | "python" | "shell" | "ruby" | "go" | "rust" | "php" | "perl" | "r"; export interface RuntimeMap { javascript: string | null; typescript: string | null; python: string | null; shell: string; ruby: string | null; go: string | null; rust: string | null; php: string | null; perl: string | null; r: string | null; } export interface RuntimeInfo { command: string; available: boolean; version: string; } /** * Dependency seam so unit tests can mock the `which`-equivalent probe without * spawning real shells. Production callers omit it. */ export interface DetectDeps { commandExists?: (cmd: string) => boolean; getVersion?: (cmd: string, args?: string[]) => string; } /** * Default `command -v` / `where` probe. Returns true if the binary is on PATH. * Kept deliberately cheap (no --version run) — availability for routing is * enough; the executor itself surfaces real launch failures. */ export declare function commandExists(cmd: string): boolean; /** * Stricter probe: requires ` --version` to exit 0. Filters out OS stubs * (e.g. the Windows Store python alias that pops the Store instead of running). */ export declare function runnableExists(cmd: string, deps?: DetectDeps): boolean; /** * Return the first line of ` --version` (or "unknown" if it can't be * read within a short timeout). Exported so callers/tests can inspect versions. */ export declare function getVersion(cmd: string, args?: string[], deps?: DetectDeps): string; /** * Detect all runtimes on the host. `shell` always resolves to a fallback * (`sh` on POSIX, `cmd.exe` on Windows) even when nothing better is present, * because a shell is the one runtime we can assume exists. * * `deps` is a test seam — production callers omit it. */ export declare function detectRuntimes(deps?: DetectDeps): RuntimeMap; /** * Human-readable summary of detected runtimes (for diagnostics / tool output). */ export declare function getRuntimeSummary(runtimes: RuntimeMap): string; /** * Languages that are actually runnable given the detected runtimes. */ export declare function getAvailableLanguages(runtimes: RuntimeMap): Language[]; /** * Resolve the spawn argv for a given language + temp script path. Throws a * clear, actionable error when the language is unavailable (so the tool layer * can surface it instead of an opaque ENOENT). * * Rust is special-cased with the sentinel `"__rust_compile_run__"` — the * executor handles compile+run itself. */ export declare function buildCommand(runtimes: RuntimeMap, language: Language, filePath: string): string[]; /** Temp-script file extension per language. */ export declare const SCRIPT_EXT: Record; //# sourceMappingURL=runtime.d.ts.map