/** * `guard_exec` — drop-in defended replacement for child_process.exec. * * Forces an args[] vector, rejects shell:true, applies allowlist match, * runs through the sandbox + replay window. Returns a structured * result that callers can serialise as MCP tool output. */ import { spawn } from "node:child_process"; import type { ReplayWindow } from "./replay.js"; import type { AllowlistRegistry } from "./allowlist.js"; import { type TrustTier } from "./tier.js"; export interface GuardExecInput { toolName: string; command: string; args: string[]; cwd?: string; env?: Record; /** * Override the sandbox timeout for this single invocation. Must be * <= the profile timeout — caller cannot widen the limit. */ timeoutMs?: number; /** * Hard-fail if the canonical hash is already in the replay window. * Default false — replay is reported in the result, not enforced. */ blockOnReplay?: boolean; } export interface GuardExecOutput { stdout: string; stderr: string; exitCode: number; durationMs: number; trustTier: TrustTier; canonicalHash: string; isReplay: boolean; signal: NodeJS.Signals | null; } export interface GuardExecDeps { registry: AllowlistRegistry; replay: ReplayWindow; /** Test seam — defaults to node:child_process.spawn. */ spawnImpl?: typeof spawn; /** Test seam for performance timing. */ now?: () => number; } export declare function guardExec(input: GuardExecInput, deps: GuardExecDeps): Promise; //# sourceMappingURL=exec.d.ts.map