from __future__ import annotations

from typing import Any, Dict, List, Literal, Optional

from pydantic import BaseModel, Field

AuroraMode = Literal["tactical", "forensic"]
MediaType = Literal["video", "audio", "photo", "unknown"]
JobStatus = Literal["queued", "processing", "completed", "failed", "cancelled"]


class InputFileDescriptor(BaseModel):
    name: str
    hash: str


class ProcessingStep(BaseModel):
    step: str
    agent: str
    model: str
    time_ms: int = 0
    details: Dict[str, Any] = Field(default_factory=dict)


class OutputFileDescriptor(BaseModel):
    type: str
    name: str
    url: str
    hash: str


class AuroraResult(BaseModel):
    agent: str = "Aurora"
    mode: AuroraMode
    job_id: str
    media_type: MediaType
    input_file: InputFileDescriptor
    processing_log: List[ProcessingStep] = Field(default_factory=list)
    output_files: List[OutputFileDescriptor] = Field(default_factory=list)
    digital_signature: Optional[str] = None
    metadata: Dict[str, Any] = Field(default_factory=dict)


class AuroraJob(BaseModel):
    job_id: str
    file_name: str
    mode: AuroraMode
    media_type: MediaType
    input_path: str
    input_hash: str
    status: JobStatus = "queued"
    progress: int = 0
    current_stage: str = "queued"
    error_message: Optional[str] = None
    cancel_requested: bool = False
    processing_log: List[ProcessingStep] = Field(default_factory=list)
    result: Optional[AuroraResult] = None
    created_at: str
    started_at: Optional[str] = None
    completed_at: Optional[str] = None
    metadata: Dict[str, Any] = Field(default_factory=dict)
