from __future__ import annotations

from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Protocol


@dataclass(frozen=True)
class TranscriptionRequest:
    page_id: str
    image_path: Path
    prompt: str
    output_schema_path: Path
    model: str
    reasoning_effort: str
    timeout_seconds: int


@dataclass(frozen=True)
class BackendResult:
    success: bool
    exit_code: int | None
    final_message: str | None
    stdout: str
    stderr: str
    command: list[str]
    metadata: dict[str, Any] = field(default_factory=dict)
    error: str | None = None


class TranscriptionBackend(Protocol):
    name: str

    def transcribe(self, request: TranscriptionRequest) -> BackendResult: ...

