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


Duration = int

class JitterKind(str):
    """How much random variation to apply to computed delays."""
    __slots__ = ()

    NONE: JitterKind
    FULL: JitterKind
    EQUAL: JitterKind
    DECORRELATED: JitterKind

JitterKind.NONE = JitterKind('none')  # type: ignore[attr-defined]
JitterKind.FULL = JitterKind('full')  # type: ignore[attr-defined]
JitterKind.EQUAL = JitterKind('equal')  # type: ignore[attr-defined]
JitterKind.DECORRELATED = JitterKind('decorrelated')  # type: ignore[attr-defined]


@dataclass(kw_only=True)
class ConstantBackoff:
    """Fixed delay between attempts."""
    delay: int


@dataclass(kw_only=True)
class LinearBackoff:
    """Delay grows linearly with attempt number."""
    base: int
    max: int
    jitter: JitterKind


@dataclass(kw_only=True)
class ExponentialBackoff:
    """Delay grows exponentially with attempt number."""
    base: int
    max: int
    factor: float
    jitter: JitterKind


class BackoffStrategy:
    """Backoff curve applied between attempts."""

    class Constant(_WitVariantCase):
        """Fixed delay."""
        tag = 'constant'

    class Linear(_WitVariantCase):
        """Linear growth."""
        tag = 'linear'

    class Exponential(_WitVariantCase):
        """Exponential growth."""
        tag = 'exponential'

    _CASES: dict[str, type] = {
        'constant': Constant,
        'linear': Linear,
        'exponential': Exponential,
    }

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

@dataclass(kw_only=True)
class ModelRetryStrategy:
    """A single retry strategy. Default is exponential backoff, full jitter, 6 attempts."""
    max_attempts: int
    backoff: BackoffStrategy
    total_budget: int | None


@dataclass(kw_only=True)
class RetryConfig:
    """Retry configuration attached to an agent.
Every strategy observes every failure; the first to request a delay wins.
Empty list disables retries; omitting `agent-config.retry` applies a default
single exponential strategy. Two strategies with the same `backoff` arm
surface as `agent-error::invalid-input`."""
    strategies: list[ModelRetryStrategy]
