"""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, Optional, 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."""

    class Text(_WitVariantCase):
        """Text guard content."""
        tag = 'text'

    class Image(_WitVariantCase):
        """Image guard content."""
        tag = 'image'

    _CASES: dict[str, type] = {
        'text': Text,
        'image': Image,
    }

    @staticmethod
    def lift(raw: _WitVariant) -> GuardContentBlock:
        cls = GuardContentBlock._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown GuardContentBlock arm: {raw.tag!r}')
        return cls(raw.payload)

@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."""

    class DocumentChar(_WitVariantCase):
        """Character range within a document."""
        tag = 'document-char'

    class DocumentPage(_WitVariantCase):
        """Page range within a document."""
        tag = 'document-page'

    class DocumentChunk(_WitVariantCase):
        """Chunk range within a document."""
        tag = 'document-chunk'

    class SearchResult(_WitVariantCase):
        """Range within a search result."""
        tag = 'search-result'

    class Web(_WitVariantCase):
        """Web page."""
        tag = 'web'

    _CASES: dict[str, type] = {
        'document-char': DocumentChar,
        'document-page': DocumentPage,
        'document-chunk': DocumentChunk,
        'search-result': SearchResult,
        'web': Web,
    }

    @staticmethod
    def lift(raw: _WitVariant) -> CitationLocation:
        cls = CitationLocation._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown CitationLocation arm: {raw.tag!r}')
        return cls(raw.payload)

@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`."""

    class Text(_WitVariantCase):
        """Text output."""
        tag = 'text'

    class Json(_WitVariantCase):
        """Structured JSON output."""
        tag = 'json'

    class Image(_WitVariantCase):
        """Image output."""
        tag = 'image'

    class Video(_WitVariantCase):
        """Video output."""
        tag = 'video'

    class Document(_WitVariantCase):
        """Document output."""
        tag = 'document'

    _CASES: dict[str, type] = {
        'text': Text,
        'json': Json,
        'image': Image,
        'video': Video,
        'document': Document,
    }

    @staticmethod
    def lift(raw: _WitVariant) -> ToolResultContent:
        cls = ToolResultContent._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown ToolResultContent arm: {raw.tag!r}')
        return cls(raw.payload)

@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."""

    class Text(_WitVariantCase):
        """Plain text."""
        tag = 'text'

    class Json(_WitVariantCase):
        """Structured JSON payload."""
        tag = 'json'

    class ToolUse(_WitVariantCase):
        """Model requested a tool call."""
        tag = 'tool-use'

    class ToolResult(_WitVariantCase):
        """Tool call completed."""
        tag = 'tool-result'

    class Reasoning(_WitVariantCase):
        """Model reasoning."""
        tag = 'reasoning'

    class CachePoint(_WitVariantCase):
        """Caching boundary marker."""
        tag = 'cache-point'

    class GuardContent(_WitVariantCase):
        """Content submitted for guardrail evaluation."""
        tag = 'guard-content'

    class Image(_WitVariantCase):
        """Image."""
        tag = 'image'

    class Video(_WitVariantCase):
        """Video."""
        tag = 'video'

    class Document(_WitVariantCase):
        """Document."""
        tag = 'document'

    class Citations(_WitVariantCase):
        """Citations emitted by the model."""
        tag = 'citations'

    class InterruptResponse(_WitVariantCase):
        """Response to a prior interrupt, supplied when resuming."""
        tag = 'interrupt-response'

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

    @staticmethod
    def lift(raw: _WitVariant) -> ContentBlock:
        cls = ContentBlock._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown ContentBlock arm: {raw.tag!r}')
        return cls(raw.payload)

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."""
