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

from .models import ModelConfig


@dataclass(kw_only=True)
class SlidingWindowConversationManager:
    """Sliding-window strategy: trim oldest messages once the conversation
exceeds `window-size`."""
    window_size: int
    should_truncate_results: bool


@dataclass(kw_only=True)
class SummarizingConversationManager:
    """Summarizing strategy: once the conversation grows, summarize older
messages into a single summary message and keep the rest verbatim."""
    summary_ratio: float
    preserve_recent_messages: int
    summarization_system_prompt: str | None
    summarization_model: ModelConfig | None


class ConversationManagerConfig:
    """Which conversation manager the agent uses. Wrapped in
``option<>`` at the call site; ``none`` means history grows without
bound and context-overflow errors propagate to the caller."""

    class SlidingWindow(_WitVariantCase):
        """Sliding-window trimming."""
        tag = 'sliding-window'

    class Summarizing(_WitVariantCase):
        """Summarization of older messages."""
        tag = 'summarizing'

    _CASES: dict[str, type] = {
        'sliding-window': SlidingWindow,
        'summarizing': Summarizing,
    }

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