from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any, Callable

from app.schemas.chat import TaskArtifact, TaskResultType


ProgressCallback = Callable[[str, str, str, dict | None], Any]


@dataclass(slots=True)
class TaskRuntimeContext:
    task_id: str
    dialog_session_id: str
    rag_session_id: str
    mode: str
    message: str
    attachments: list[dict[str, Any]] = field(default_factory=list)
    files: list[dict[str, Any]] = field(default_factory=list)
    files_map: dict[str, dict[str, Any]] = field(default_factory=dict)
    progress_cb: ProgressCallback | None = None
    trace: Any = None
    repo_context: Any = None
    conversation_state: Any = None
    route_result: Any = None
    enriched_context: dict[str, Any] = field(default_factory=dict)


@dataclass(slots=True)
class WorkflowExecutionResult:
    result_type: TaskResultType
    answer: str = ""
    artifacts: list[TaskArtifact] = field(default_factory=list)
    meta: dict[str, Any] = field(default_factory=dict)
