"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from acuvity.types import BaseModel
from enum import Enum
import pydantic
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class Direction(str, Enum):
    r"""The communication direction of the MCP message which can be from client to
    server, or from server to client.
    """

    CLIENT2_SERVER = "Client2Server"
    SERVER2_CLIENT = "Server2Client"


class McpmessageType(str, Enum):
    r"""The MCP message type which can be Request, Response or Notification."""

    REQUEST = "Request"
    RESPONSE = "Response"
    NOTIFICATION = "Notification"


class McpmessageTypedDict(TypedDict):
    r"""Represents MCP message details."""

    direction: Direction
    r"""The communication direction of the MCP message which can be from client to
    server, or from server to client.
    """
    type: McpmessageType
    r"""The MCP message type which can be Request, Response or Notification."""
    is_error: NotRequired[bool]
    r"""IsError is true in case if a response is an error response as opposed to a
    result. Note that this is not the same as a result which has isError set to true
    within the result. This is a protocol level error. This will always be false for
    requests and notifications, and false for reponses when the response has a
    result.
    """
    method: NotRequired[str]
    r"""This is the method name of the request or notification. Contrary to MCP this is
    set on responses as well if possible in which case the format will be of the
    form method/params.name.
    """
    request_id: NotRequired[str]
    r"""The ID of a request or a response. We always extract this as a string even
    though this can be a string or number in MCP. It is derived from the id field of
    a request or a response.
    """
    session_id: NotRequired[str]
    r"""The session ID that this MCP message belongs to. This is strictly speaking not
    part of MCP, and this can be empty.
    """


class Mcpmessage(BaseModel):
    r"""Represents MCP message details."""

    direction: Direction
    r"""The communication direction of the MCP message which can be from client to
    server, or from server to client.
    """

    type: McpmessageType
    r"""The MCP message type which can be Request, Response or Notification."""

    is_error: Annotated[Optional[bool], pydantic.Field(alias="isError")] = None
    r"""IsError is true in case if a response is an error response as opposed to a
    result. Note that this is not the same as a result which has isError set to true
    within the result. This is a protocol level error. This will always be false for
    requests and notifications, and false for reponses when the response has a
    result.
    """

    method: Optional[str] = None
    r"""This is the method name of the request or notification. Contrary to MCP this is
    set on responses as well if possible in which case the format will be of the
    form method/params.name.
    """

    request_id: Annotated[Optional[str], pydantic.Field(alias="requestID")] = None
    r"""The ID of a request or a response. We always extract this as a string even
    though this can be a string or number in MCP. It is derived from the id field of
    a request or a response.
    """

    session_id: Annotated[Optional[str], pydantic.Field(alias="sessionID")] = None
    r"""The session ID that this MCP message belongs to. This is strictly speaking not
    part of MCP, and this can be empty.
    """
