"""Pydantic schemas for the in-session copilot."""
from typing import Optional, Any
from uuid import UUID
from datetime import datetime
from pydantic import BaseModel, Field


class SuggestedFlow(BaseModel):
    tree_id: UUID
    tree_name: str
    tree_type: str
    relevance_snippet: str


class CopilotStartRequest(BaseModel):
    tree_id: UUID
    session_id: Optional[UUID] = None
    current_node_id: Optional[str] = None


class CopilotStartResponse(BaseModel):
    conversation_id: UUID
    greeting: str


class CopilotMessageRequest(BaseModel):
    message: str = Field(..., min_length=1, max_length=4000)
    current_node_id: Optional[str] = None


class CopilotMessageResponse(BaseModel):
    content: str
    suggested_flows: list[SuggestedFlow] = []


class CopilotConversationResponse(BaseModel):
    id: UUID
    tree_id: UUID
    messages: list[dict[str, Any]]
    current_node_id: Optional[str] = None
    message_count: int
    created_at: datetime

    model_config = {"from_attributes": True}
