/** * @file Exec-backend injection point: WHERE a shell command runs, a separate * axis from WHICH model produced it (`ai/backends`). The lib owns the * INTERFACE plus the cheap built-in `real` runner (the host shell via lib * `spawn`); a SANDBOXED runner is INJECTED by the caller, never imported * here. That keeps the small-dist lib free of a heavy sandbox dependency — * Socket's sandbox of choice (`just-bash`, ~40MB incl. WASM) is owned by the * wheelhouse hook / CI tooling and passed in, so a lib consumer that never * sandboxes pays nothing. Layering: ExecRunner.run() — the injectable * primitive (real | sandboxed) composed into ExecContext — { runners: { real, * sandboxed? }, resolve(trust) } used by runShell(script, { context, trust }) * — the ergonomic entry point Pick a runner by TRUST LEVEL, never by model. * `untrusted` resolves to the sandboxed runner — which a caller that hasn't * injected one cannot run, so `resolve` throws a clear "provide a sandboxed * runner" error rather than silently falling back to the host shell. Both * runners normalize to one `ExecResult` so callers swap trust levels without * reshaping result handling. */ export type ExecBackend = 'real' | 'sandboxed'; export type ExecTrust = 'trusted' | 'untrusted'; export interface ExecResult { readonly stdout: string; readonly stderr: string; readonly exitCode: number; } export interface ExecRunOptions { readonly cwd?: string | undefined; readonly env?: Record | undefined; readonly files?: Record | undefined; readonly signal?: AbortSignal | undefined; readonly stdin?: string | undefined; } export interface ExecRunner { run(script: string, options?: ExecRunOptions | undefined): Promise; } export interface ExecContext { readonly runners: { readonly real: ExecRunner; readonly sandboxed?: ExecRunner | undefined; }; resolve(trust: ExecTrust): ExecRunner; } export declare const realRunner: ExecRunner; export declare function backendForTrust(trust: ExecTrust): ExecBackend; export declare function createExecContext(options?: { real?: ExecRunner | undefined; sandboxed?: ExecRunner | undefined; } | undefined): ExecContext; export declare function runShell(script: string, options?: (ExecRunOptions & { context?: ExecContext | undefined; trust?: ExecTrust | undefined; }) | undefined): Promise;