import { SessionSnapshot, WorktreeMergeCheckResult, WorktreeMergeResult } from "./types.js"; export interface WorktreeSetupSpec { /** Branch, tag, or commit used as the task's immutable starting point. */ baseRef?: string; /** Human-readable task name used in the generated branch. */ taskName?: string; /** Gitignored repo-relative paths copied into the new worktree. */ copyPaths?: string[]; /** Gitignored repo-relative paths symlinked from the main checkout. */ sharedDirectories?: string[]; } interface WorktreeSetupOptions { cwd: string; sessionId: string; spec?: WorktreeSetupSpec; } interface WorktreeSetupResult { cwd: string; worktreeEnabled: boolean; worktree: NonNullable; } interface WorktreeOperationOptions { worktree: NonNullable; /** Primarily exposed for bounded request handling and deterministic tests. */ gitTimeoutMs?: number; } interface WorktreeMergeOptions extends WorktreeOperationOptions { targetBranch?: string; } export declare class WorktreeMergeError extends Error { readonly code: string; readonly result?: Partial | undefined; constructor(code: string, message: string, result?: Partial | undefined); } export interface WorktreeTargetBranch { repoRoot: string; targetBranch: string; } export declare function getWorktreeMergeErrorCode(error: unknown): string | undefined; /** Resolve one stable merge target for every worktree belonging to a project. */ export declare function resolveWorktreeTargetBranchAsync(cwd: string, gitTimeoutMs?: number): Promise; /** Async HTTP-facing worktree check; commands remain deliberately serial. */ export declare function checkSessionWorktreeMergeabilityAsync(options: WorktreeMergeOptions): Promise; export declare function cleanupSessionWorktreeAsync(options: WorktreeOperationOptions): Promise; /** * Best-effort synchronous cleanup of a session/task worktree directory and its * branch. Uses `--force` + `-D` (mirroring workspace-task deletion): deleting a * session means discarding everything tied to it, including any uncommitted * work in its isolated worktree. Any failure (already removed, locked, or a * missing repo root) is swallowed so a stale or half-cleaned worktree can never * block session deletion. */ export declare function cleanupWorktreeSync(worktree: { path: string; branch: string; repoRoot?: string; } | null | undefined): void; /** Async HTTP-facing merge with serial, non-cancellable rollback. */ export declare function mergeSessionWorktreeAsync(options: WorktreeMergeOptions): Promise; export declare function prepareSessionWorktree(options: WorktreeSetupOptions): WorktreeSetupResult; export {};