/**
 * Workspace Manager
 *
 * Provides full isolation between parallel visor runs with human-readable project names.
 * Each run gets its own workspace in /tmp containing worktrees for all projects.
 */
export interface WorkspaceConfig {
    enabled: boolean;
    basePath: string;
    cleanupOnExit: boolean;
    name?: string;
    mainProjectName?: string;
}
export interface WorkspaceInfo {
    sessionId: string;
    workspacePath: string;
    mainProjectPath: string;
    mainProjectName: string;
    originalPath: string;
    /** The git worktree root (before subdirectory offset). Used for cleanup. */
    worktreeRootPath?: string;
}
export interface ProjectInfo {
    name: string;
    path: string;
    worktreePath: string;
    repository: string;
}
/**
 * WorkspaceManager creates isolated workspaces for parallel visor runs.
 * Each run gets a unique workspace directory containing worktrees for all projects.
 */
export declare class WorkspaceManager {
    private static instances;
    private sessionId;
    private basePath;
    private workspacePath;
    private originalPath;
    private config;
    private initialized;
    private mainProjectInfo;
    private projects;
    private cleanupHandlersRegistered;
    private usedNames;
    private activeOperations;
    private cleanupRequested;
    private cleanupResolvers;
    private constructor();
    /**
     * Get or create a WorkspaceManager instance for a session
     */
    static getInstance(sessionId: string, originalPath: string, config?: Partial<WorkspaceConfig>): WorkspaceManager;
    /**
     * Clear all instances (for testing)
     */
    static clearInstances(): void;
    /**
     * Check if workspace isolation is enabled
     */
    isEnabled(): boolean;
    /**
     * Acquire a reference to the workspace (prevents cleanup while held)
     * Call release() when done with the operation.
     */
    acquire(): void;
    /**
     * Release a reference to the workspace.
     * If cleanup was requested and this was the last reference, cleanup will proceed.
     */
    release(): void;
    /**
     * Get the number of active operations
     */
    getActiveOperations(): number;
    /**
     * Get the workspace path
     */
    getWorkspacePath(): string;
    /**
     * Get the original working directory
     */
    getOriginalPath(): string;
    /**
     * Get workspace info (only available after initialize)
     */
    getWorkspaceInfo(): WorkspaceInfo | null;
    /**
     * Initialize the workspace - creates workspace directory and main project worktree
     */
    initialize(): Promise<WorkspaceInfo>;
    /**
     * Add a project to the workspace (creates symlink to worktree)
     * If the same repository already exists, updates the symlink to the new worktree path.
     */
    addProject(repository: string, worktreePath: string, description?: string): Promise<string>;
    /**
     * List all projects in the workspace
     */
    listProjects(): ProjectInfo[];
    /**
     * Cleanup the workspace.
     * If there are active operations, waits for them to complete before cleaning up.
     * @param timeout Maximum time to wait for active operations (default: 60s)
     */
    cleanup(timeout?: number): Promise<void>;
    /**
     * Check if a path exists (file or directory).
     */
    private pathExists;
    /**
     * Clean up stale workspace directories older than maxAge.
     * Call periodically (e.g. at socket-runner startup) to prevent disk bloat.
     */
    static cleanupStale(basePath?: string, maxAgeMs?: number): Promise<number>;
    /**
     * visor-disable: architecture - The helpers below (resolveUpstreamRef,
     * fetchAndResolveUpstream, resetAndCleanWorktree, refreshWorktreeToUpstream)
     * are NOT duplicates of WorktreeManager's fetchRef/getCommitShaForRef/cleanWorktree.
     * WorktreeManager operates on BARE repo caches cloned from remote URLs, while
     * WorkspaceManager operates on the LOCAL working repo the user already has checked out.
     * The git commands differ (e.g. `fetch origin --prune` vs `fetch origin <ref>:<ref>`)
     * and sharing code would require adding a "local mode" to WorktreeManager for no benefit.
     */
    /**
     * Resolve the upstream default branch ref.
     * Tries origin/HEAD (symbolic), then origin/main, then origin/master.
     * Falls back to local HEAD if no remote is configured.
     */
    private resolveUpstreamRef;
    /**
     * Fetch latest from origin, resolve the upstream default branch, and return
     * both the ref name and the resolved commit SHA.
     */
    private fetchAndResolveUpstream;
    /**
     * Reset a worktree to a specific commit and clean all modifications.
     */
    private resetAndCleanWorktree;
    /**
     * Delete local branches in a worktree that are safe to remove.
     * IMPORTANT: Git worktrees share the branch namespace with the main repo
     * and all other worktrees. We must NOT delete branches that are checked out
     * in the main working tree or any other worktree — doing so would destroy
     * the user's work.
     */
    private deleteLocalBranches;
    /**
     * Refresh an existing worktree to the latest upstream default branch
     * and ensure it has no modified or untracked files.
     */
    private refreshWorktreeToUpstream;
    /**
     * Create worktree for the main project.
     * See visor-disable comment above resolveUpstreamRef for why this doesn't use WorktreeManager.
     */
    private createMainProjectWorktree;
    /**
     * Remove main project worktree
     */
    private removeMainProjectWorktree;
    /**
     * Check if a path is a git repository
     */
    private isGitRepository;
    /**
     * Extract project name from path
     */
    private extractProjectName;
    /**
     * Extract repository name from owner/repo format
     */
    private extractRepoName;
    /**
     * Get a unique name by appending a number if needed
     */
    private getUniqueName;
    /**
     * Register cleanup handlers for process exit
     */
    private registerCleanupHandlers;
}
//# sourceMappingURL=workspace-manager.d.ts.map