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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class ArtifactReference(UniversalBaseModel):
    """
    Reference to an artifact stored in the agent session workspace.

    Artifacts are files or documents that belong to a specific agent session, providing a persistent workspace where agents and users can share files throughout a conversation. When users upload files (such as PDFs, Word documents, PowerPoint presentations, or images) to an agent session, these files are stored as artifacts that remain available for the duration of the session.

    **Session Binding**: Each artifact is scoped to a specific agent session and cannot be accessed from other sessions, ensuring data privacy and security.

    **Lifecycle**: Artifacts are created when users upload files via multipart requests or when agent tools generate new files (such as converting a PDF to markdown). Artifacts have a configurable time-to-live and are automatically removed when they expire or when the session is deleted. Size limits apply to individual artifacts and total session storage.

    **How Agents Use Artifacts**: Agent tools can read artifacts, process them, and create new derived artifacts. For example, the document conversion tool can take a PDF artifact, convert it to markdown, and store the result as a new artifact. This enables multi-step document processing workflows within a single session.

    **Common Use Cases**: Upload a document for the agent to analyze, provide multiple reference files for context, enable the agent to convert between formats, or allow the agent to generate and store processed files for later retrieval.
    """

    artifact_id: str = pydantic.Field()
    """
    Unique identifier for the artifact
    """

    filename: str = pydantic.Field()
    """
    Original filename of the artifact
    """

    mime_type: str = pydantic.Field()
    """
    MIME type of the file
    """

    size_bytes: int = pydantic.Field()
    """
    File size in bytes
    """

    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
