from datetime import datetime from pathlib import Path from uuid import UUID from pydantic import BaseModel, ConfigDict, field_validator class HealthResponse(BaseModel): status: str app: str env: str class CreateSandboxRequest(BaseModel): model_config = ConfigDict(extra='forbid') chat_id: UUID agent_id: str volume_host_path: str @field_validator('agent_id') @classmethod def validate_agent_id(cls, value: str) -> str: if not value.strip(): raise ValueError('invalid agent_id') return value @field_validator('volume_host_path') @classmethod def validate_volume_host_path(cls, value: str) -> str: path = Path(value).expanduser() if not path.is_absolute(): raise ValueError('invalid volume_host_path') return str(path.resolve(strict=False)) class SandboxEndpointResponse(BaseModel): ip: str port: int class SandboxSessionResponse(BaseModel): session_id: UUID chat_id: UUID agent_id: str volume_host_path: str container_id: str endpoint: SandboxEndpointResponse status: str expires_at: datetime class DeleteSandboxResponse(BaseModel): chat_id: UUID result: str session_id: UUID | None = None container_id: str | None = None class ErrorResponse(BaseModel): detail: str