"""Typed response models for manager-facing worker APIs."""

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, Field


class WorkerListItemResponse(BaseModel):
    worker_id: str
    status: str
    chip: str | None = None
    memory_gb: int | None = None
    gpu_cores: int | None = None
    available_handlers: list[str]
    available_models: list[str]
    model_capabilities: list[dict[str, Any]] = Field(default_factory=list)
    capabilities_advertised_at: str | None = None
    capabilities_confirmed_at: str | None = None
    capability_state: str
    capability_state_reason: str
    last_poll_at: str | None = None
    last_heartbeat: str | None = None
    last_claimed_at: str | None = None
    last_claimed_job_id: str | None = None
    last_job_failure_at: str | None = None
    last_job_failure_detail: str | None = None
    last_failed_job_id: str | None = None
    last_seen_at: str | None = None
    jobs_completed: int
    registered_at: str
    token_last_four: str | None = None
    token_issued_at: str | None = None
    token_revoked_at: str | None = None
    credential_state: str
    observed_state: str
    observed_state_reason: str
    latest_benchmarks: list[dict[str, Any]] = Field(default_factory=list)
    benchmark_rollup: dict[str, Any] | None = None


class WorkerListResponse(BaseModel):
    workers: list[WorkerListItemResponse]
    total: int
