import type { FileStat, SandboxCapabilities, SandboxEnv, SandboxExecOptions, SandboxSnapshot } from './sandbox.js'; import type { ShellResult } from './types.js'; export interface SuspendingSandboxOptions { /** Auto-suspend after this many milliseconds of inactivity. */ idleSuspendMs: number; /** * When true (default), the next operation on a suspended sandbox auto-resumes it. * When false, operations against a suspended sandbox throw `SANDBOX_UNAVAILABLE`. */ autoResumeOnAccess?: boolean; } /** * Decorator that adds idle-based auto-suspend to any `SandboxEnv` whose * underlying implementation supports `suspend()` / `resume()`. If the inner * env doesn't implement them, the decorator is a no-op pass-through (the * idle timer never fires anything). * * The decorator tracks a `lastAccessAt` timestamp on every operation. After * `idleSuspendMs` elapses without activity, it calls `inner.suspend()`. The * next operation transparently calls `inner.resume()` first (unless * `autoResumeOnAccess: false`). * * `cleanup()` cancels the idle timer. */ export declare class SuspendingSandboxEnv implements SandboxEnv { private readonly inner; readonly cwd: string; readonly capabilities?: SandboxCapabilities; private suspended; private idleTimer; private inFlight; private readonly idleMs; private readonly autoResume; constructor(inner: SandboxEnv, options: SuspendingSandboxOptions); resolvePath(path: string): string; exec(command: string, options?: SandboxExecOptions): Promise; readFile(path: string): Promise; readFileBuffer(path: string): Promise; writeFile(path: string, content: string | Uint8Array): Promise; stat(path: string): Promise; readdir(path: string): Promise; exists(path: string): Promise; mkdir(path: string, options?: { recursive?: boolean; }): Promise; rm(path: string, options?: { recursive?: boolean; force?: boolean; }): Promise; snapshot(): Promise; restore(snapshot: SandboxSnapshot): Promise; fork(snapshot: SandboxSnapshot): Promise; suspend(): Promise; resume(): Promise; cleanup(): Promise; /** True when the sandbox is currently suspended (for tests / introspection). */ get isSuspended(): boolean; private access; private scheduleIdleTimer; private cancelIdleTimer; } /** * Wrap any `SandboxEnv` with idle-based auto-suspend. Returns the inner env * unchanged when `idleSuspendMs` is undefined or the inner env doesn't * implement `suspend()`. */ export declare function withIdleSuspend(inner: SandboxEnv, options: SuspendingSandboxOptions | undefined): SandboxEnv; //# sourceMappingURL=suspending-sandbox.d.ts.map