export interface WorktreeOptions {
    /** Unique job ID. Must match `[a-zA-Z0-9_-]{1,64}`. */
    jobId: string;
    /** Branch / commit / ref to base the worktree on. Default: `main`. */
    baseRef?: string;
    /** Repository root. Default: `process.cwd()`. */
    workingDir?: string;
}
export interface WorktreeHandle {
    jobId: string;
    worktreePath: string;
    baseRef: string;
    workingDir: string;
}
export declare class WorktreeError extends Error {
    readonly cause?: unknown | undefined;
    constructor(message: string, cause?: unknown | undefined);
}
declare function resolveWorktreePath(jobId: string): string;
/**
 * Create a git worktree at `<tmpdir>/sp-autopatch-<jobId>` based on `baseRef`.
 *
 * Throws WorktreeError if jobId is invalid, already in flight, or git refuses.
 * Callers should pair this with `removeWorktree` in a `finally` block, or
 * simply use `withWorktree` which handles that automatically.
 */
export declare function createWorktree(opts: WorktreeOptions): Promise<WorktreeHandle>;
/**
 * Remove a previously-created worktree. Idempotent: if the path doesn't exist
 * git emits a recoverable error, which we swallow when `force === true` so
 * cleanup never masks the original error from the caller's main flow. The
 * swallowed error is logged for debuggability.
 */
export declare function removeWorktree(handle: WorktreeHandle, force?: boolean): Promise<void>;
/**
 * Run `fn` inside a freshly-created worktree, cleaning up afterwards.
 *
 * Cleanup uses `force=true` so a failure inside `fn` doesn't leave an orphan
 * worktree on disk; the original error from `fn` always propagates.
 */
export declare function withWorktree<T>(opts: WorktreeOptions, fn: (handle: WorktreeHandle) => Promise<T>): Promise<T>;
/** Exposed for tests so they can inspect path resolution and validation rules. */
export declare const __testing: {
    resolveWorktreePath: typeof resolveWorktreePath;
    JOB_ID_RE: RegExp;
    ACTIVE_JOBS: Set<string>;
};
export {};
//# sourceMappingURL=worktreeRunner.d.ts.map