"""Auto-generated by bindgen. Do not edit."""
# ruff: noqa: E501, F401, I001
# fmt: off

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, ClassVar, Optional, TYPE_CHECKING, Union

from wasmtime.component import Variant as _WitVariant
from wasmtime.component import VariantCase as _WitVariantCase


@dataclass(kw_only=True)
class TextBlock:
    """Plain text."""
    text: str


@dataclass(kw_only=True)
class S3Location:
    """Object stored in Amazon S3."""
    uri: str
    bucket_owner: str | None


ImageSource = bytes | str | S3Location
"""Source of image bytes."""

@dataclass(kw_only=True)
class ImageBlock:
    """Image attached to a message."""
    format: str
    source: ImageSource


VideoSource = bytes | S3Location
"""Source of video bytes."""

@dataclass(kw_only=True)
class VideoBlock:
    """Video attached to a message."""
    format: str
    source: VideoSource


DocumentSource = bytes | str | list[TextBlock] | S3Location
"""Source of document bytes."""

@dataclass(kw_only=True)
class DocumentCitationsConfig:
    """Citation configuration attached to a document."""
    enabled: bool


@dataclass(kw_only=True)
class DocumentBlock:
    """Document attached to a message."""
    name: str
    format: str
    source: DocumentSource
    citations: DocumentCitationsConfig | None
    context: str | None


@dataclass(kw_only=True)
class ReasoningBlock:
    """Model's thought process. Either plain reasoning (with an optional
signature) or an opaque redacted blob."""
    text: str | None
    signature: str | None
    redacted_content: bytes | None


class CacheKind(str):
    """Prompt-caching kind. More arms will be added as providers surface
additional cache tiers (e.g. Anthropic's `ephemeral`)."""
    __slots__ = ()

    DEFAULT_CACHE: CacheKind

CacheKind.DEFAULT_CACHE = CacheKind('default-cache')  # type: ignore[attr-defined]


@dataclass(kw_only=True)
class CachePointBlock:
    """Marks a caching boundary in the prompt."""
    kind: CacheKind


class GuardQualifier(str):
    """How a piece of guard content should be evaluated."""
    __slots__ = ()

    GROUNDING_SOURCE: GuardQualifier
    QUERY: GuardQualifier
    GUARD_CONTENT: GuardQualifier

GuardQualifier.GROUNDING_SOURCE = GuardQualifier('grounding-source')  # type: ignore[attr-defined]
GuardQualifier.QUERY = GuardQualifier('query')  # type: ignore[attr-defined]
GuardQualifier.GUARD_CONTENT = GuardQualifier('guard-content')  # type: ignore[attr-defined]


@dataclass(kw_only=True)
class GuardContentText:
    """Text submitted to a guardrail for evaluation."""
    qualifiers: list[GuardQualifier]
    text: str


@dataclass(kw_only=True)
class GuardContentImage:
    """Image submitted to a guardrail for evaluation."""
    format: str
    bytes: bytes


class GuardContentBlock:
    """Content submitted to a guardrail for evaluation."""
    if TYPE_CHECKING:
        Text: ClassVar[type["_GuardContentBlock_Text"]]
        Image: ClassVar[type["_GuardContentBlock_Image"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "GuardContentBlock": ...

class _GuardContentBlock_Text(_WitVariantCase, GuardContentBlock):
    """Text guard content."""
    tag = 'text'
GuardContentBlock.Text = _GuardContentBlock_Text  # type: ignore[attr-defined]

class _GuardContentBlock_Image(_WitVariantCase, GuardContentBlock):
    """Image guard content."""
    tag = 'image'
GuardContentBlock.Image = _GuardContentBlock_Image  # type: ignore[attr-defined]

GuardContentBlock._CASES = {  # type: ignore[attr-defined]
    'text': GuardContentBlock.Text,
    'image': GuardContentBlock.Image,
}


def _GuardContentBlock_lift(raw: _WitVariant) -> GuardContentBlock:
    cls = GuardContentBlock._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown GuardContentBlock arm: {raw.tag!r}')
    return cls(raw.payload)
GuardContentBlock.lift = staticmethod(_GuardContentBlock_lift)  # type: ignore[attr-defined]

@dataclass(kw_only=True)
class DocumentRange:
    """Range within a source document (characters, pages, or chunks)."""
    document_index: int
    start: int
    end: int


@dataclass(kw_only=True)
class SearchResultRange:
    """Range within a search result."""
    search_result_index: int
    start: int
    end: int


@dataclass(kw_only=True)
class WebLocation:
    """Web citation target."""
    url: str
    domain: str | None


class CitationLocation:
    """Anchor a citation points to."""
    if TYPE_CHECKING:
        DocumentChar: ClassVar[type["_CitationLocation_DocumentChar"]]
        DocumentPage: ClassVar[type["_CitationLocation_DocumentPage"]]
        DocumentChunk: ClassVar[type["_CitationLocation_DocumentChunk"]]
        SearchResult: ClassVar[type["_CitationLocation_SearchResult"]]
        Web: ClassVar[type["_CitationLocation_Web"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "CitationLocation": ...

class _CitationLocation_DocumentChar(_WitVariantCase, CitationLocation):
    """Character range within a document."""
    tag = 'document-char'
CitationLocation.DocumentChar = _CitationLocation_DocumentChar  # type: ignore[attr-defined]

class _CitationLocation_DocumentPage(_WitVariantCase, CitationLocation):
    """Page range within a document."""
    tag = 'document-page'
CitationLocation.DocumentPage = _CitationLocation_DocumentPage  # type: ignore[attr-defined]

class _CitationLocation_DocumentChunk(_WitVariantCase, CitationLocation):
    """Chunk range within a document."""
    tag = 'document-chunk'
CitationLocation.DocumentChunk = _CitationLocation_DocumentChunk  # type: ignore[attr-defined]

class _CitationLocation_SearchResult(_WitVariantCase, CitationLocation):
    """Range within a search result."""
    tag = 'search-result'
CitationLocation.SearchResult = _CitationLocation_SearchResult  # type: ignore[attr-defined]

class _CitationLocation_Web(_WitVariantCase, CitationLocation):
    """Web page."""
    tag = 'web'
CitationLocation.Web = _CitationLocation_Web  # type: ignore[attr-defined]

CitationLocation._CASES = {  # type: ignore[attr-defined]
    'document-char': CitationLocation.DocumentChar,
    'document-page': CitationLocation.DocumentPage,
    'document-chunk': CitationLocation.DocumentChunk,
    'search-result': CitationLocation.SearchResult,
    'web': CitationLocation.Web,
}


def _CitationLocation_lift(raw: _WitVariant) -> CitationLocation:
    cls = CitationLocation._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown CitationLocation arm: {raw.tag!r}')
    return cls(raw.payload)
CitationLocation.lift = staticmethod(_CitationLocation_lift)  # type: ignore[attr-defined]

@dataclass(kw_only=True)
class CitationText:
    """Text fragment from a source or a generated answer."""
    text: str


@dataclass(kw_only=True)
class Citation:
    """Link from generated content back to a source location."""
    location: CitationLocation
    source: str
    source_content: list[CitationText]
    title: str


@dataclass(kw_only=True)
class CitationsBlock:
    """Citations emitted by the model when citations are enabled."""
    citations: list[Citation]
    content: list[CitationText]


@dataclass(kw_only=True)
class ToolUseBlock:
    """Model's request to call a tool."""
    name: str
    tool_use_id: str
    input: str
    reasoning_signature: str | None


class ToolResultStatus(str):
    """Whether a tool invocation succeeded. Richer classification lives on `tools.tool-error`."""
    __slots__ = ()

    SUCCESS: ToolResultStatus
    ERROR: ToolResultStatus

ToolResultStatus.SUCCESS = ToolResultStatus('success')  # type: ignore[attr-defined]
ToolResultStatus.ERROR = ToolResultStatus('error')  # type: ignore[attr-defined]


@dataclass(kw_only=True)
class JsonBlock:
    """Structured JSON payload. Used for tool results and agent-as-tool
outputs that carry schema-validated data, not prose."""
    json: str


class ToolResultContent:
    """Block valid inside `tool-result-block.content`. Narrower than `content-block`."""
    if TYPE_CHECKING:
        Text: ClassVar[type["_ToolResultContent_Text"]]
        Json: ClassVar[type["_ToolResultContent_Json"]]
        Image: ClassVar[type["_ToolResultContent_Image"]]
        Video: ClassVar[type["_ToolResultContent_Video"]]
        Document: ClassVar[type["_ToolResultContent_Document"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "ToolResultContent": ...

class _ToolResultContent_Text(_WitVariantCase, ToolResultContent):
    """Text output."""
    tag = 'text'
ToolResultContent.Text = _ToolResultContent_Text  # type: ignore[attr-defined]

class _ToolResultContent_Json(_WitVariantCase, ToolResultContent):
    """Structured JSON output."""
    tag = 'json'
ToolResultContent.Json = _ToolResultContent_Json  # type: ignore[attr-defined]

class _ToolResultContent_Image(_WitVariantCase, ToolResultContent):
    """Image output."""
    tag = 'image'
ToolResultContent.Image = _ToolResultContent_Image  # type: ignore[attr-defined]

class _ToolResultContent_Video(_WitVariantCase, ToolResultContent):
    """Video output."""
    tag = 'video'
ToolResultContent.Video = _ToolResultContent_Video  # type: ignore[attr-defined]

class _ToolResultContent_Document(_WitVariantCase, ToolResultContent):
    """Document output."""
    tag = 'document'
ToolResultContent.Document = _ToolResultContent_Document  # type: ignore[attr-defined]

ToolResultContent._CASES = {  # type: ignore[attr-defined]
    'text': ToolResultContent.Text,
    'json': ToolResultContent.Json,
    'image': ToolResultContent.Image,
    'video': ToolResultContent.Video,
    'document': ToolResultContent.Document,
}


def _ToolResultContent_lift(raw: _WitVariant) -> ToolResultContent:
    cls = ToolResultContent._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown ToolResultContent arm: {raw.tag!r}')
    return cls(raw.payload)
ToolResultContent.lift = staticmethod(_ToolResultContent_lift)  # type: ignore[attr-defined]

@dataclass(kw_only=True)
class ToolResultBlock:
    """Outcome of a tool execution."""
    tool_use_id: str
    status: ToolResultStatus
    content: list[ToolResultContent]


@dataclass(kw_only=True)
class InterruptResponseBlock:
    """User response to a previously-raised interrupt. Supplied on the
next invocation to resume the paused agent."""
    interrupt_id: str
    response: str


class ContentBlock:
    """Any block that can appear inside a message."""
    if TYPE_CHECKING:
        Text: ClassVar[type["_ContentBlock_Text"]]
        Json: ClassVar[type["_ContentBlock_Json"]]
        ToolUse: ClassVar[type["_ContentBlock_ToolUse"]]
        ToolResult: ClassVar[type["_ContentBlock_ToolResult"]]
        Reasoning: ClassVar[type["_ContentBlock_Reasoning"]]
        CachePoint: ClassVar[type["_ContentBlock_CachePoint"]]
        GuardContent: ClassVar[type["_ContentBlock_GuardContent"]]
        Image: ClassVar[type["_ContentBlock_Image"]]
        Video: ClassVar[type["_ContentBlock_Video"]]
        Document: ClassVar[type["_ContentBlock_Document"]]
        Citations: ClassVar[type["_ContentBlock_Citations"]]
        InterruptResponse: ClassVar[type["_ContentBlock_InterruptResponse"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "ContentBlock": ...

class _ContentBlock_Text(_WitVariantCase, ContentBlock):
    """Plain text."""
    tag = 'text'
ContentBlock.Text = _ContentBlock_Text  # type: ignore[attr-defined]

class _ContentBlock_Json(_WitVariantCase, ContentBlock):
    """Structured JSON payload."""
    tag = 'json'
ContentBlock.Json = _ContentBlock_Json  # type: ignore[attr-defined]

class _ContentBlock_ToolUse(_WitVariantCase, ContentBlock):
    """Model requested a tool call."""
    tag = 'tool-use'
ContentBlock.ToolUse = _ContentBlock_ToolUse  # type: ignore[attr-defined]

class _ContentBlock_ToolResult(_WitVariantCase, ContentBlock):
    """Tool call completed."""
    tag = 'tool-result'
ContentBlock.ToolResult = _ContentBlock_ToolResult  # type: ignore[attr-defined]

class _ContentBlock_Reasoning(_WitVariantCase, ContentBlock):
    """Model reasoning."""
    tag = 'reasoning'
ContentBlock.Reasoning = _ContentBlock_Reasoning  # type: ignore[attr-defined]

class _ContentBlock_CachePoint(_WitVariantCase, ContentBlock):
    """Caching boundary marker."""
    tag = 'cache-point'
ContentBlock.CachePoint = _ContentBlock_CachePoint  # type: ignore[attr-defined]

class _ContentBlock_GuardContent(_WitVariantCase, ContentBlock):
    """Content submitted for guardrail evaluation."""
    tag = 'guard-content'
ContentBlock.GuardContent = _ContentBlock_GuardContent  # type: ignore[attr-defined]

class _ContentBlock_Image(_WitVariantCase, ContentBlock):
    """Image."""
    tag = 'image'
ContentBlock.Image = _ContentBlock_Image  # type: ignore[attr-defined]

class _ContentBlock_Video(_WitVariantCase, ContentBlock):
    """Video."""
    tag = 'video'
ContentBlock.Video = _ContentBlock_Video  # type: ignore[attr-defined]

class _ContentBlock_Document(_WitVariantCase, ContentBlock):
    """Document."""
    tag = 'document'
ContentBlock.Document = _ContentBlock_Document  # type: ignore[attr-defined]

class _ContentBlock_Citations(_WitVariantCase, ContentBlock):
    """Citations emitted by the model."""
    tag = 'citations'
ContentBlock.Citations = _ContentBlock_Citations  # type: ignore[attr-defined]

class _ContentBlock_InterruptResponse(_WitVariantCase, ContentBlock):
    """Response to a prior interrupt, supplied when resuming."""
    tag = 'interrupt-response'
ContentBlock.InterruptResponse = _ContentBlock_InterruptResponse  # type: ignore[attr-defined]

ContentBlock._CASES = {  # type: ignore[attr-defined]
    'text': ContentBlock.Text,
    'json': ContentBlock.Json,
    'tool-use': ContentBlock.ToolUse,
    'tool-result': ContentBlock.ToolResult,
    'reasoning': ContentBlock.Reasoning,
    'cache-point': ContentBlock.CachePoint,
    'guard-content': ContentBlock.GuardContent,
    'image': ContentBlock.Image,
    'video': ContentBlock.Video,
    'document': ContentBlock.Document,
    'citations': ContentBlock.Citations,
    'interrupt-response': ContentBlock.InterruptResponse,
}


def _ContentBlock_lift(raw: _WitVariant) -> ContentBlock:
    cls = ContentBlock._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown ContentBlock arm: {raw.tag!r}')
    return cls(raw.payload)
ContentBlock.lift = staticmethod(_ContentBlock_lift)  # type: ignore[attr-defined]

class Role(str):
    """Who a message is from."""
    __slots__ = ()

    USER: Role
    ASSISTANT: Role

Role.USER = Role('user')  # type: ignore[attr-defined]
Role.ASSISTANT = Role('assistant')  # type: ignore[attr-defined]


@dataclass(kw_only=True)
class Usage:
    """Token consumption for a model invocation."""
    input_tokens: int
    output_tokens: int
    total_tokens: int
    cache_read_input_tokens: int | None
    cache_write_input_tokens: int | None


@dataclass(kw_only=True)
class Metrics:
    """Performance metrics for a model invocation."""
    latency_ms: float


@dataclass(kw_only=True)
class MessageMetadata:
    """Metadata attached to a message. Not sent to model providers; persisted
alongside the message for bookkeeping."""
    usage: Usage | None
    metrics: Metrics | None
    custom: str | None


@dataclass(kw_only=True)
class Message:
    """A complete message in a conversation."""
    role: Role
    content: list[ContentBlock]
    metadata: MessageMetadata | None


PromptInput = str | list[ContentBlock]
"""A prompt-style input: either prose or structured content. Used for
both system prompts and user input."""
