import type { BuildResult, CommitResult, TestResult, Workspace, WorkspaceInterface } from './contracts.js'; export interface GitWorkspaceOptions { /** Repository to clone: a local path or a remote URL. */ repo: string; /** Branch, tag or commit each workspace starts from. Defaults to the clone's checked-out HEAD. */ baseRef?: string; /** Local working-tree changes to stage into each new workspace before running the baseline. */ basePatch?: string; /** Shell command that runs the project's tests inside a workspace. */ testCommand: string; /** * Installs dependencies from the lockfile, once per checkout, WITH network. Tests and builds then run offline * (see `offline`), so the only code that ever had network is the lockfile's own, never the AI's. */ installCommand?: string; /** Run tests and builds in a container with no network, no capabilities and no way to gain any. Needs Docker. */ offline?: { image: string; }; /** Shell command that builds the project inside a workspace. */ buildCommand: string; /** Directory that holds one clone per workspace. */ workspacesDir?: string; /** Prefix for the branch created in each workspace; the workspace id is appended. */ branchPrefix?: string; /** Timeout for each test or build run. */ commandTimeoutMs?: number; /** Committer identity, so commits don't depend on the host's git config. */ author?: { name: string; email: string; }; /** Environment for test and build commands. Defaults to this process's, so pass a minimal one for untrusted repos. */ env?: NodeJS.ProcessEnv; /** * Runs test and build commands as this dedicated unprivileged user, because they execute code nobody has reviewed yet * (an AI-written fix). The user can't read this process's environment or files; the commands run in a copy of the * workspace without .git, so they can't plant hooks or config that this process's git would later execute; and every * process of the user is killed after each command, so nothing lingers into the next run. Needs this process to be root. */ sandbox?: SandboxUser; } export interface SandboxUser { uid: number; gid: number; } export declare class GitWorkspaceError extends Error { readonly operation: string; constructor(operation: string, message: string); } /** * Gives each fix its own clone of the repository on a fresh branch. * * Patches are applied to both the working tree and the index, so the index is the exact record of what * the fix changed: `gitDiff` and `commit` use it, and files that tests or builds write are left out. */ export declare class GitWorkspace implements WorkspaceInterface { private options; private readonly workspacesDir; /** Sandbox copy per workspace id; tests and the build after them share it, a new patch discards it. */ private readonly runDirs; /** Directories whose dependencies are already installed, so tests and the build after them don't reinstall. */ private readonly installed; constructor(options: GitWorkspaceOptions); createWorkspace(): Promise; /** Reads from the index, which holds exactly the base plus applied patches, not files that tests or builds wrote. */ readFile(workspace: Workspace, file: string): Promise; applyPatch(workspace: Workspace, patch: string): Promise; gitDiff(workspace: Workspace): Promise; runTests(workspace: Workspace): Promise; runBuild(workspace: Workspace): Promise; /** Removes the sandbox copies. Workspaces themselves stay, for inspection. */ dispose(): Promise; commit(workspace: Workspace, message: string): Promise; /** Rejects workspaces this instance didn't create, so a caller can't point git at an arbitrary directory. */ private ownedPath; private run; /** Installs once (with network), then runs the command offline when configured. */ private runInDir; /** The workspace's index (base plus applied patches) checked out without .git into a directory the sandbox user owns. */ private sandboxCopy; private discardSandbox; private runCommand; } /** * Where the dependency install runs. On Linux (CI runners, servers): on the host, as always. Elsewhere (macOS, Windows) * native modules installed on the host are built for it and won't load in the Linux container that runs the tests and * build, so the install runs in that same image instead, with network and otherwise the same limits. */ export declare function installContainer(offline: { image: string; } | undefined, platform?: NodeJS.Platform): { image: string; network: boolean; } | undefined; /** * `docker run` arguments for a test or build with nothing to reach: no network, no capabilities, no privilege gain, * a non-root user, bounded memory, CPU and processes, and only the workspace mounted. */ export declare function dockerRunArgs(o: { name: string; image: string; network?: boolean; cwd: string; command: string; user?: SandboxUser; env: NodeJS.ProcessEnv; }): string[]; /** Whether a Docker daemon answers, so callers can choose offline tests or say why they can't have them. */ export declare function dockerAvailable(): boolean; //# sourceMappingURL=git-workspace.d.ts.map