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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .agent_key import AgentKey
from .agent_session_key import AgentSessionKey


class AgentSession(UniversalBaseModel):
    """
    A session for interacting with an agent, allowing conversation context.
    """

    key: typing.Optional[AgentSessionKey] = None
    agent_key: AgentKey
    name: str = pydantic.Field()
    """
    Human-readable name for the session.
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optional description of the session purpose or context.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Arbitrary metadata associated with the session.
    """

    enabled: bool = pydantic.Field()
    """
    Whether the session is currently active and can accept new messages.
    """

    tti_minutes: typing.Optional[int] = pydantic.Field(default=None)
    """
    Time-to-idle in minutes for the session. If no events occur in the session for this duration, the session will be automatically deleted. If not specified, the session will not expire.
    """

    created_at: dt.datetime = pydantic.Field()
    """
    Timestamp when the session was created.
    """

    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
