export declare const DEFAULT_MAX_OUTPUT_BYTES = 1048576; export declare const DEFAULT_MAX_RUNTIME_MS = 1800000; export declare const HARD_MAX_RUNTIME_MS = 21600000; export declare const DEFAULT_AWAIT_MS = 30000; export declare const HARD_AWAIT_MS = 120000; export declare const DEFAULT_MAX_JOBS_PER_SESSION = 8; export declare const DEFAULT_JOB_TTL_MS = 21600000; export declare const DEFAULT_KILL_GRACE_MS = 2000; export declare const MIN_MAX_RUNTIME_MS = 1000; export declare const MAX_REGEX_LENGTH = 1024; export declare const TASK_ID_RE: RegExp; export type BackgroundShellErrorCode = "CAPABILITY_DISABLED" | "PERMISSION_DENIED" | "INVALID_WORKDIR" | "INVALID_REGEX" | "JOB_NOT_FOUND" | "JOB_LIMIT" | "ID_COLLISION" | "SPAWN_FAILED" | "SUPERVISOR_DISPOSED"; export type BackgroundShellStatus = "running" | "complete" | "error" | "cancelled"; export declare class BackgroundShellError extends Error { readonly code: BackgroundShellErrorCode; constructor(code: BackgroundShellErrorCode, message: string); } export interface BackgroundShellSupervisorOptions { /** Directory for `.txt` output files. Created on demand. */ outputDirectory: string; /** Shell binary. Defaults to `$SHELL` or `/bin/sh`. */ shell?: string; maxOutputBytes?: number; defaultMaxRuntimeMs?: number; hardMaxRuntimeMs?: number; defaultAwaitMs?: number; hardAwaitMs?: number; maxJobsPerSession?: number; jobTtlMs?: number; killGraceMs?: number; /** Injectable clock for TTL tests. */ now?: () => number; } export interface BackgroundShellSpawnInput { sessionId: string; messageId: string; command: string; workingDirectory: string; description?: string; maxRuntimeMs?: number; signal?: AbortSignal; } export interface BackgroundShellAwaitInput { sessionId: string; taskId: string; blockUntilMs?: number; regex?: string; signal?: AbortSignal; } /** Snapshot field order is part of the public contract when JSON-stringified. */ export interface BackgroundShellSnapshot { taskId: string; status: BackgroundShellStatus; runtimeMs: number; outputFilePath: string; outputLength: number; regexRequested: boolean; regexMatch: string | null; exitCode: number | null; signal: string | null; truncated: boolean; } export interface BackgroundShellSupervisor { spawn(input: BackgroundShellSpawnInput): Promise; await(input: BackgroundShellAwaitInput): Promise; disposeSession(sessionId: string): Promise; disposeAll(): Promise; /** Test helper: process-group leader PID while the job is known. */ getPid(taskId: string): number | null; } export declare function createBackgroundShellSupervisor(options: BackgroundShellSupervisorOptions): BackgroundShellSupervisor;