from typing import Any

from pydantic import BaseModel, Field


class ModelOrganismConfig(BaseModel):
    """Configuration for model organisms."""

    name: str = Field(..., description="Name of the model organism")
    config: dict[str, Any] = Field(
        default_factory=dict, description="Configuration for the model organism"
    )


class EnvironmentConfig(BaseModel):
    """Configuration for environments."""

    name: str = Field(..., description="Name of the environment")
    eval_config: dict[str, Any] = Field(
        default_factory=dict, description="Evaluation configuration"
    )


class DetectorConfig(BaseModel):
    """Configuration for detectors."""

    name: str = Field(..., description="Name of the detector")
    config: dict[str, Any] = Field(
        default_factory=dict, description="Configuration for the detector"
    )


class ValidateModelConfig(BaseModel):
    """Configuration for validate-model command."""

    model_organism: ModelOrganismConfig = Field(
        ..., description="Model organism configuration"
    )
    environments: list[EnvironmentConfig] = Field(
        ..., description="Environment configuration"
    )
    model_config = {"extra": "forbid"}


class RunDetectorConfig(BaseModel):
    """Configuration for run-detector command."""

    detector: DetectorConfig = Field(..., description="Detector configuration")
    model_organism: ModelOrganismConfig = Field(
        ..., description="Model organism configuration"
    )
    environments: list[EnvironmentConfig] = Field(
        ..., description="Environment configuration"
    )
    model_config = {"extra": "forbid"}
