import { TaskStatus } from '../types/index.js';
import type { EventBus } from '../core/event-bus.js';
import type { SessionManager } from './session-manager.js';
import type { TaskCleanupService } from './task-cleanup.service.js';
import type { WorkspaceGitWatcherService } from './workspace-git-watcher.service.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 const TASK_TITLE_MAX_LENGTH = 200;
export declare const TASK_TITLE_AUTOSPLIT_THRESHOLD = 240;
export declare const TASK_PREVIEW_MAX_LENGTH = 240;
export declare const TASK_HISTORICAL_TITLE_BODY_THRESHOLD = 240;
export declare function buildTextPreview(value: string | null | undefined, maxLength?: number): string;
export declare class TaskService {
    private readonly eventBus;
    private readonly sessionManager;
    private readonly cleanupService;
    private readonly workspaceGitWatcher;
    constructor(eventBus: EventBus, sessionManager: SessionManager, cleanupService?: Pick<TaskCleanupService, 'trigger'> | undefined, workspaceGitWatcher?: Pick<WorkspaceGitWatcherService, 'unwatchWorkspace'>);
    /**
     * 获取项目的任务列表（支持按状态过滤和分页）
     */
    findByProjectId(projectId: string, params?: FindTasksParams): Promise<{
        data: ({
            id: string;
            createdAt: Date;
            status: string;
            priority: number;
            workspaces: ({
                sessions: {
                    agentType: string;
                    id: string;
                    createdAt: Date;
                    status: string;
                    updatedAt: Date;
                    workspaceId: string;
                    variant: string;
                    providerId: string | null;
                    purpose: string;
                    tokenUsage: string | null;
                }[];
            } & {
                id: string;
                createdAt: Date;
                status: string;
                taskId: string;
                updatedAt: Date;
                branchName: string;
                worktreePath: string;
                workingDir: string;
                parentWorkspaceId: string | null;
                ownerMemberId: string | null;
                baseBranch: string | null;
                workspaceKind: string;
                commitMessage: string | null;
                previewTarget: string | null;
                hibernatedAt: Date | null;
            })[];
            updatedAt: Date;
            title: string;
            position: number;
            projectId: string;
            project: {
                id: string;
                name: string;
                createdAt: Date;
                description: string | null;
                updatedAt: Date;
                repoDeletedAt: Date | null;
                archivedAt: Date | null;
                repoPath: string;
                repoRemoteUrl: string | null;
                mainBranch: string;
                copyFiles: string | null;
                setupScript: string | null;
                quickCommands: string | null;
            };
        } & {
            title: string;
            titlePreview: string;
            contentPreview: string | undefined;
            isTruncated: boolean;
        })[];
        total: number;
        page: number;
        limit: number;
        totalPages: number;
    }>;
    /**
     * 获取任务详情
     */
    findById(id: string): Promise<{
        id: string;
        createdAt: Date;
        status: string;
        priority: number;
        workspaces: ({
            sessions: {
                agentType: string;
                id: string;
                createdAt: Date;
                status: string;
                updatedAt: Date;
                workspaceId: string;
                variant: string;
                providerId: string | null;
                purpose: string;
                tokenUsage: string | null;
            }[];
        } & {
            id: string;
            createdAt: Date;
            status: string;
            taskId: string;
            updatedAt: Date;
            branchName: string;
            worktreePath: string;
            workingDir: string;
            parentWorkspaceId: string | null;
            ownerMemberId: string | null;
            baseBranch: string | null;
            workspaceKind: string;
            commitMessage: string | null;
            previewTarget: string | null;
            hibernatedAt: Date | null;
        })[];
        updatedAt: Date;
        title: string;
        position: number;
        projectId: string;
    } & {
        title: string;
        titlePreview: string;
        contentPreview: string | undefined;
        isTruncated: boolean;
    }>;
    findBodyById(id: string): Promise<{
        taskId: string;
        title: string;
        titlePreview: string;
        body: string;
        bodySource: string;
        prompt: string;
        isTruncated: boolean;
    }>;
    /**
     * 创建任务
     * - 校验项目存在
     * - 自动计算 position（同状态下最大 position + 1）
     */
    create(projectId: string, input: CreateTaskInput): Promise<{
        id: string;
        createdAt: Date;
        status: string;
        description: string | null;
        priority: number;
        updatedAt: Date;
        title: string;
        position: number;
        projectId: string;
        deletedAt: Date | null;
    }>;
    /**
     * 更新任务基本信息
     */
    update(id: string, input: UpdateTaskInput): Promise<{
        id: string;
        createdAt: Date;
        status: string;
        description: string | null;
        priority: number;
        updatedAt: Date;
        title: string;
        position: number;
        projectId: string;
        deletedAt: Date | null;
    }>;
    /**
     * 更新任务状态（含状态流转校验）
     * 更新后通过 EventBus 发射 task:updated 事件，通知前端实时更新
     */
    updateStatus(id: string, status: TaskStatus): Promise<{
        id: string;
        createdAt: Date;
        status: string;
        description: string | null;
        priority: number;
        updatedAt: Date;
        title: string;
        position: number;
        projectId: string;
        deletedAt: Date | null;
    }>;
    /**
     * 更新任务位置（用于拖拽排序）
     * 如果同时传了 status，会进行状态流转并通知前端
     */
    updatePosition(id: string, position: number, status?: TaskStatus): Promise<{
        id: string;
        createdAt: Date;
        status: string;
        description: string | null;
        priority: number;
        updatedAt: Date;
        title: string;
        position: number;
        projectId: string;
        deletedAt: Date | null;
    }>;
    /**
     * 快速删除任务
     *
     * 1. 原子标记 Task 为 deletedAt，使普通列表立即隐藏
     * 2. 保存后台清理快照
     * 3. 通过 EventBus 通知前端实时删除
     * 4. 后台 worker 再停止 Session、删除 worktree/branch，并最终硬删除 Task
     */
    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;
        createdAt: Date;
        status: string;
        description: string | null;
        priority: number;
        updatedAt: Date;
        title: string;
        position: number;
        projectId: string;
        deletedAt: Date | null;
    }>;
    /**
     * 发射 task:updated 事件，通知 SocketGateway 转发到前端
     */
    emitTaskUpdated(taskId: string, projectId: string, status: string): void;
}
export {};
//# sourceMappingURL=task.service.d.ts.map