from __future__ import annotations

from typing import Any, TypedDict


class UsagePayload(TypedDict, total=False):
    prompt_tokens: int
    completion_tokens: int
    total_tokens: int


class ContextRequestEntry(TypedDict, total=False):
    type: str
    path: str
    pattern: str


class ContextRequestPayload(TypedDict, total=False):
    need_more_context: bool
    requests: list[ContextRequestEntry]
    sufficiency_rationale: str


class PatcherMeta(TypedDict, total=False):
    error: str
    returncode: int
    stdout: str
    stderr: str
    timed_out: bool
    timeout_sec: float
    llm_call_count: int
    usage: UsagePayload
    status: int
    body: str
    exc: str
    attempt: int
    base_url: str
    model: str
    response_mode: str
    temperature: float
    max_tokens: int
    max_propose_sec: float
    request_context_duration_sec: float
    fallback_from: str
    fallback_reason: str
    forced_patch_attempt: bool
    forced_patch_target: str
    forced_patch_reason: str
    reason: str


JSONDict = dict[str, Any]


__all__ = [
    "ContextRequestEntry",
    "ContextRequestPayload",
    "JSONDict",
    "PatcherMeta",
    "UsagePayload",
]
