import * as natives from "@pk-nerdsaver-ai/pi-natives";
declare const IsoBackendKind: typeof natives.IsoBackendKind;
type IsoBackendKind = natives.IsoBackendKind;
/** Baseline state for a single git repository. */
export interface RepoBaseline {
    repoRoot: string;
    headCommit: string;
    staged: string;
    unstaged: string;
    untracked: string[];
    untrackedPatch: string;
}
/** Baseline state for the project, including any nested git repos. */
export interface WorktreeBaseline {
    root: RepoBaseline;
    /** Nested git repos (path relative to root.repoRoot). */
    nested: Array<{
        relativePath: string;
        baseline: RepoBaseline;
    }>;
}
export declare function getRepoRoot(cwd: string): Promise<string>;
export declare function getGitNoIndexNullPath(): string;
export declare function captureBaseline(repoRoot: string): Promise<WorktreeBaseline>;
export interface NestedRepoPatch {
    relativePath: string;
    patch: string;
}
export interface DeltaPatchResult {
    rootPatch: string;
    nestedPatches: NestedRepoPatch[];
}
export declare function captureDeltaPatch(isolationDir: string, baseline: WorktreeBaseline): Promise<DeltaPatchResult>;
/**
 * Apply nested repo patches directly to their working directories after parent merge.
 * @param commitMessage Optional async function to generate a commit message from the combined diff.
 *                      If omitted or returns null, falls back to a generic message.
 */
export declare function applyNestedPatches(repoRoot: string, patches: NestedRepoPatch[], commitMessage?: (diff: string) => Promise<string | null>): Promise<void>;
/**
 * User-facing isolation mode names exposed by the `task.isolation.mode`
 * setting. Mapped to a backend-kind hint via {@link parseIsolationMode};
 * the PAL's `iso_resolve` then falls back through the kind order
 * whenever the hint isn't available on the current host.
 */
export type TaskIsolationMode = "none" | "auto" | "apfs" | "btrfs" | "zfs" | "reflink" | "overlayfs" | "projfs" | "block-clone" | "rcopy" | "worktree" | "fuse-overlay" | "fuse-projfs";
/**
 * Translate a {@link TaskIsolationMode} string to an [`IsoBackendKind`]
 * the PAL can act on. `"none"` returns `null` (caller skips isolation
 * entirely); `"auto"` returns `undefined` (no hint — let the resolver
 * pick). Anything else returns the matching kind.
 */
export declare function parseIsolationMode(mode: TaskIsolationMode): IsoBackendKind | undefined;
export interface IsolationHandle {
    /** Merged view materialised by the backend; pass this to the task. */
    mergedDir: string;
    /** Backend the PAL actually used. */
    backend: IsoBackendKind;
    /** True when the resolver downgraded from `preferred` to `backend`. */
    fellBack: boolean;
    /** Optional reason associated with `fellBack`. */
    fallbackReason: string | null;
}
export declare function ensureIsolation(baseCwd: string, id: string, preferred?: IsoBackendKind): Promise<IsolationHandle>;
/** Tear down a handle returned by {@link ensureIsolation}. */
export declare function cleanupIsolation(handle: IsolationHandle): Promise<void>;
export interface CommitToBranchResult {
    branchName?: string;
    nestedPatches: NestedRepoPatch[];
}
/**
 * Commit task-only changes to a new branch.
 * Only root repo changes go on the branch. Nested repo patches are returned
 * separately since the parent git can't track files inside gitlinks.
 */
export declare function commitToBranch(isolationDir: string, baseline: WorktreeBaseline, taskId: string, description: string | undefined, commitMessage?: (diff: string) => Promise<string | null>): Promise<CommitToBranchResult | null>;
export interface MergeBranchResult {
    merged: string[];
    failed: string[];
    conflict?: string;
    /** Set when cherry-picks landed on HEAD but restoring the stashed working tree failed. */
    stashConflict?: string;
}
/**
 * Cherry-pick task branch commits sequentially onto HEAD.
 * Each branch has a single commit that gets replayed cleanly.
 * Stops on first conflict and reports which branches succeeded.
 */
export declare function mergeTaskBranches(repoRoot: string, branches: Array<{
    branchName: string;
    taskId: string;
    description?: string;
}>): Promise<MergeBranchResult>;
/** Clean up temporary task branches. */
export declare function cleanupTaskBranches(repoRoot: string, branches: string[]): Promise<void>;
export {};
