# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .file_attachment import FileAttachment
from .message_author import MessageAuthor
from .message_style import MessageStyle
from .text_format import TextFormat


class TaskMessageContent_ClaudeMessage(UniversalBaseModel):
    type: typing.Literal["claude_message"] = "claude_message"
    author: MessageAuthor
    message_type: str
    raw_message: typing.Dict[str, typing.Any]
    session_id: typing.Optional[str] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class TaskMessageContent_Data(UniversalBaseModel):
    type: typing.Literal["data"] = "data"
    author: MessageAuthor
    data: typing.Dict[str, typing.Any]
    style: typing.Optional[MessageStyle] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class TaskMessageContent_Reasoning(UniversalBaseModel):
    type: typing.Literal["reasoning"] = "reasoning"
    author: MessageAuthor
    content: typing.Optional[typing.List[str]] = None
    style: typing.Optional[MessageStyle] = None
    summary: typing.List[str]

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class TaskMessageContent_Text(UniversalBaseModel):
    type: typing.Literal["text"] = "text"
    attachments: typing.Optional[typing.List[FileAttachment]] = None
    author: MessageAuthor
    content: str
    format: typing.Optional[TextFormat] = None
    style: typing.Optional[MessageStyle] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class TaskMessageContent_ToolRequest(UniversalBaseModel):
    type: typing.Literal["tool_request"] = "tool_request"
    arguments: typing.Dict[str, typing.Any]
    author: MessageAuthor
    name: str
    style: typing.Optional[MessageStyle] = None
    tool_call_id: str

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class TaskMessageContent_ToolResponse(UniversalBaseModel):
    type: typing.Literal["tool_response"] = "tool_response"
    author: MessageAuthor
    content: typing.Any
    name: str
    style: typing.Optional[MessageStyle] = None
    tool_call_id: str

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


TaskMessageContent = typing_extensions.Annotated[
    typing.Union[
        TaskMessageContent_ClaudeMessage,
        TaskMessageContent_Data,
        TaskMessageContent_Reasoning,
        TaskMessageContent_Text,
        TaskMessageContent_ToolRequest,
        TaskMessageContent_ToolResponse,
    ],
    pydantic.Field(discriminator="type"),
]
