import { TaskStatus } from '../types/index.js';
import type { EventBus } from '../core/event-bus.js';
import type { SessionManager } from './session-manager.js';
interface CreateTaskInput {
    title: string;
    description?: string;
    priority?: number;
}
interface UpdateTaskInput {
    title?: string;
    description?: string;
    priority?: number;
}
interface FindTasksParams {
    status?: TaskStatus;
    page?: number;
    limit?: number;
}
export declare class TaskService {
    private readonly eventBus;
    private readonly sessionManager;
    constructor(eventBus: EventBus, sessionManager: SessionManager);
    /**
     * 获取项目的任务列表（支持按状态过滤和分页）
     */
    findByProjectId(projectId: string, params?: FindTasksParams): Promise<{
        data: ({
            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;
            };
            workspaces: {
                id: string;
                createdAt: Date;
                updatedAt: Date;
                status: string;
                taskId: string;
                branchName: string;
                baseBranch: string | null;
                worktreePath: string;
                commitMessage: string | null;
                hibernatedAt: Date | null;
            }[];
        } & {
            id: string;
            description: string | null;
            createdAt: Date;
            updatedAt: Date;
            title: string;
            status: string;
            priority: number;
            position: number;
            projectId: string;
        })[];
        total: number;
        page: number;
        limit: number;
        totalPages: number;
    }>;
    /**
     * 获取任务详情
     */
    findById(id: string): Promise<{
        workspaces: ({
            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;
        })[];
    } & {
        id: string;
        description: string | null;
        createdAt: Date;
        updatedAt: Date;
        title: string;
        status: string;
        priority: number;
        position: number;
        projectId: string;
    }>;
    /**
     * 创建任务
     * - 校验项目存在
     * - 自动计算 position（同状态下最大 position + 1）
     */
    create(projectId: string, input: CreateTaskInput): Promise<{
        id: string;
        description: string | null;
        createdAt: Date;
        updatedAt: Date;
        title: string;
        status: string;
        priority: number;
        position: number;
        projectId: string;
    }>;
    /**
     * 更新任务基本信息
     */
    update(id: string, input: UpdateTaskInput): Promise<{
        id: string;
        description: string | null;
        createdAt: Date;
        updatedAt: Date;
        title: string;
        status: string;
        priority: number;
        position: number;
        projectId: string;
    }>;
    /**
     * 更新任务状态（含状态流转校验）
     * 更新后通过 EventBus 发射 task:updated 事件，通知前端实时更新
     */
    updateStatus(id: string, status: TaskStatus): Promise<{
        id: string;
        description: string | null;
        createdAt: Date;
        updatedAt: Date;
        title: string;
        status: string;
        priority: number;
        position: number;
        projectId: string;
    }>;
    /**
     * 更新任务位置（用于拖拽排序）
     * 如果同时传了 status，会进行状态流转并通知前端
     */
    updatePosition(id: string, position: number, status?: TaskStatus): Promise<{
        id: string;
        description: string | null;
        createdAt: Date;
        updatedAt: Date;
        title: string;
        status: string;
        priority: number;
        position: number;
        projectId: string;
    }>;
    /**
     * 删除任务（增强版）
     *
     * 1. 停止所有 RUNNING/PENDING 状态的 Session
     * 2. 清理所有关联 Workspace 的 git worktree
     * 3. 级联删除数据库记录
     * 4. 通过 EventBus 通知前端实时删除
     */
    delete(id: string): Promise<boolean>;
    /**
     * 获取项目的任务统计
     */
    getStatsByProjectId(projectId: string): Promise<{
        total: number;
        todo: number;
        inProgress: number;
        inReview: number;
        done: number;
        cancelled: number;
    }>;
    /**
     * 重试任务
     *
     * 1. 停止当前 ACTIVE Workspace 的所有 Session
     * 2. 将 ACTIVE Workspace 标记为 ABANDONED（保留 worktree 供参考）
     * 3. 重置 Task 状态为 TODO
     * 4. 通知前端 — 用户可重新派发 Agent（会创建新 Worktree）
     */
    retry(id: string): Promise<{
        id: string;
        description: string | null;
        createdAt: Date;
        updatedAt: Date;
        title: string;
        status: string;
        priority: number;
        position: number;
        projectId: string;
    }>;
    /**
     * 发射 task:updated 事件，通知 SocketGateway 转发到前端
     */
    emitTaskUpdated(taskId: string, projectId: string, status: string): void;
}
export {};
//# sourceMappingURL=task.service.d.ts.map