import type { GitOperationStatus } from '@agent-tower/shared';
export declare class WorkspaceService {
    private sessionService;
    private eventBus;
    private getBaseBranch;
    findById(id: string): Promise<({
        task: {
            project: {
                name: string;
                repoDeletedAt: Date | null;
                archivedAt: Date | null;
                repoRemoteUrl: string | null;
                id: string;
                description: string | null;
                repoPath: string;
                mainBranch: string;
                copyFiles: string | null;
                setupScript: string | null;
                quickCommands: string | null;
                createdAt: Date;
                updatedAt: Date;
            };
        } & {
            id: string;
            description: string | null;
            createdAt: Date;
            updatedAt: Date;
            title: string;
            status: string;
            priority: number;
            position: number;
            projectId: string;
        };
        sessions: {
            id: string;
            createdAt: Date;
            updatedAt: Date;
            status: string;
            workspaceId: string;
            agentType: string;
            variant: string;
            providerId: string | null;
            prompt: string;
            purpose: string;
            logSnapshot: string | null;
            tokenUsage: string | null;
        }[];
    } & {
        id: string;
        createdAt: Date;
        updatedAt: Date;
        status: string;
        taskId: string;
        branchName: string;
        baseBranch: string | null;
        worktreePath: string;
        commitMessage: string | null;
        hibernatedAt: Date | null;
    }) | null>;
    /**
     * 获取 Task 下所有 Workspace
     */
    findByTaskId(taskId: string): Promise<({
        sessions: {
            id: string;
            createdAt: Date;
            updatedAt: Date;
            status: string;
            workspaceId: string;
            agentType: string;
            variant: string;
            providerId: string | null;
            prompt: string;
            purpose: string;
            logSnapshot: string | null;
            tokenUsage: string | null;
        }[];
    } & {
        id: string;
        createdAt: Date;
        updatedAt: Date;
        status: string;
        taskId: string;
        branchName: string;
        baseBranch: string | null;
        worktreePath: string;
        commitMessage: string | null;
        hibernatedAt: Date | null;
    })[]>;
    /**
     * 创建 Workspace
     *
     * - 默认分支名: at/{workspace-short-id}（ID 前 8 位）
     * - 支持用户自定义分支名
     * - 创建前校验分支名合法性 & 是否已存在
     * - 创建后自动将关联 Task 状态改为 IN_PROGRESS
     * - 失败时回滚已创建的数据库记录
     */
    create(taskId: string, branchName?: string): Promise<{
        task: {
            project: {
                name: string;
                repoDeletedAt: Date | null;
                archivedAt: Date | null;
                repoRemoteUrl: string | null;
                id: string;
                description: string | null;
                repoPath: string;
                mainBranch: string;
                copyFiles: string | null;
                setupScript: string | null;
                quickCommands: string | null;
                createdAt: Date;
                updatedAt: Date;
            };
        } & {
            id: string;
            description: string | null;
            createdAt: Date;
            updatedAt: Date;
            title: string;
            status: string;
            priority: number;
            position: number;
            projectId: string;
        };
        sessions: {
            id: string;
            createdAt: Date;
            updatedAt: Date;
            status: string;
            workspaceId: string;
            agentType: string;
            variant: string;
            providerId: string | null;
            prompt: string;
            purpose: string;
            logSnapshot: string | null;
            tokenUsage: string | null;
        }[];
    } & {
        id: string;
        createdAt: Date;
        updatedAt: Date;
        status: string;
        taskId: string;
        branchName: string;
        baseBranch: string | null;
        worktreePath: string;
        commitMessage: string | null;
        hibernatedAt: Date | null;
    }>;
    /**
     * 删除 Workspace
     *
     * - 删除前检查是否有 RUNNING 状态的 Session，有则拒绝删除
     * - 删除时先停止所有关联 Session 的进程
     * - 删除时调用 WorktreeManager.remove 清理 worktree
     * - worktree 清理失败时仍然删除数据库记录（记录警告日志）
     */
    delete(id: string): Promise<boolean>;
    getDiff(id: string): Promise<string>;
    /**
     * Rebase 工作空间分支到最新的基础分支
     */
    rebase(id: string): Promise<void>;
    /**
     * 获取工作空间的 Git 操作状态
     */
    getGitStatus(id: string): Promise<GitOperationStatus>;
    /**
     * 中止工作空间当前进行中的 Git 操作
     */
    abortOperation(id: string): Promise<void>;
    /**
     * 合并 Workspace 到主分支（squash merge）
     *
     * @param commitMessage - 可选的自定义 commit message
     * @returns squash commit 的 SHA
     */
    merge(id: string, commitMessage?: string): Promise<string>;
    /**
     * 归档 Workspace（标记状态为 ABANDONED）
     */
    archive(id: string): Promise<{
        task: {
            project: {
                name: string;
                repoDeletedAt: Date | null;
                archivedAt: Date | null;
                repoRemoteUrl: string | null;
                id: string;
                description: string | null;
                repoPath: string;
                mainBranch: string;
                copyFiles: string | null;
                setupScript: string | null;
                quickCommands: string | null;
                createdAt: Date;
                updatedAt: Date;
            };
        } & {
            id: string;
            description: string | null;
            createdAt: Date;
            updatedAt: Date;
            title: string;
            status: string;
            priority: number;
            position: number;
            projectId: string;
        };
        sessions: {
            id: string;
            createdAt: Date;
            updatedAt: Date;
            status: string;
            workspaceId: string;
            agentType: string;
            variant: string;
            providerId: string | null;
            prompt: string;
            purpose: string;
            logSnapshot: string | null;
            tokenUsage: string | null;
        }[];
    } & {
        id: string;
        createdAt: Date;
        updatedAt: Date;
        status: string;
        taskId: string;
        branchName: string;
        baseBranch: string | null;
        worktreePath: string;
        commitMessage: string | null;
        hibernatedAt: Date | null;
    }>;
    /**
     * 休眠单个 workspace：auto-commit dirty changes → 删除 worktree 目录 → 标记 HIBERNATED
     * Branch 保留，可随时通过 reactivate() 恢复。
     */
    hibernate(id: string): Promise<void>;
    /**
     * 唤醒休眠的 workspace：从 branch 重建 worktree → 复制文件 → 执行 setup → 恢复 ACTIVE
     */
    reactivate(id: string): Promise<{
        task: {
            project: {
                name: string;
                repoDeletedAt: Date | null;
                archivedAt: Date | null;
                repoRemoteUrl: string | null;
                id: string;
                description: string | null;
                repoPath: string;
                mainBranch: string;
                copyFiles: string | null;
                setupScript: string | null;
                quickCommands: string | null;
                createdAt: Date;
                updatedAt: Date;
            };
        } & {
            id: string;
            description: string | null;
            createdAt: Date;
            updatedAt: Date;
            title: string;
            status: string;
            priority: number;
            position: number;
            projectId: string;
        };
        sessions: {
            id: string;
            createdAt: Date;
            updatedAt: Date;
            status: string;
            workspaceId: string;
            agentType: string;
            variant: string;
            providerId: string | null;
            prompt: string;
            purpose: string;
            logSnapshot: string | null;
            tokenUsage: string | null;
        }[];
    } & {
        id: string;
        createdAt: Date;
        updatedAt: Date;
        status: string;
        taskId: string;
        branchName: string;
        baseBranch: string | null;
        worktreePath: string;
        commitMessage: string | null;
        hibernatedAt: Date | null;
    }>;
    /**
     * 批量休眠空闲 workspace：
     * - ACTIVE 状态
     * - 没有运行中的 session
     * - task 状态不是 IN_PROGRESS / IN_REVIEW
     * - 超过 idleThresholdHours 未活动
     *
     * @returns 休眠的 workspace 数量
     */
    hibernateIdle(idleThresholdHours?: number): Promise<number>;
    /**
     * Auto-commit all changes in a worktree directory to prevent data loss.
     */
    private autoCommitIfDirty;
    /**
     * 清理所有 ABANDONED/MERGED 状态且关联 Task 为 DONE 的 Workspace
     *
     * @returns 被清理的 Workspace 数量
     */
    cleanup(): Promise<number>;
    /**
     * 复制项目配置的文件到 worktree
     */
    private runCopyFiles;
    /**
     * 在 worktree 中执行 setup 脚本（逐行执行），通过 EventBus 推送进度
     */
    private runSetupScript;
    /**
     * Fire-and-forget 包装：异步执行 setup 脚本，不阻塞调用方
     */
    private fireSetupScript;
    /**
     * 服务启动时调用：对所有项目执行 git worktree prune
     */
    static pruneAllWorktrees(): Promise<void>;
}
//# sourceMappingURL=workspace.service.d.ts.map