import uuid
from typing import Any, Optional
from pydantic import BaseModel, Field


class SynthesizeBotRequest(BaseModel):
    prompt: str = Field(min_length=10, max_length=2000, description="Natural language description of the desired bot.")
    channel: str = Field(default="telegram", description="Target messaging platform")


class WorkflowNode(BaseModel):
    id: str
    type: str  # trigger | ai_agent | mcp_tool | condition | message_reply
    label: str
    config: dict[str, Any]


class WorkflowEdge(BaseModel):
    source: str
    target: str


class SynthesizedBotProposal(BaseModel):
    proposal_id: uuid.UUID
    bot_name: str
    matched_template_id: str
    matched_template_name: str
    headline: str
    category: str
    generated_system_prompt: str
    selected_modules: list[str]
    selected_mcp_tools: list[str]
    suggested_config: dict[str, Any]
    workflow_nodes: list[WorkflowNode]
    workflow_edges: list[WorkflowEdge]
    sample_preview_message: str
    required_permissions: list[str]
    security_verdict: dict[str, Any]


class DeployProposalRequest(BaseModel):
    proposal_id: uuid.UUID
    bot_id: Optional[uuid.UUID] = None
    custom_name: Optional[str] = None
    config_overrides: Optional[dict[str, Any]] = None
