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


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."""
    if TYPE_CHECKING:
        Constant: ClassVar[type["_BackoffStrategy_Constant"]]
        Linear: ClassVar[type["_BackoffStrategy_Linear"]]
        Exponential: ClassVar[type["_BackoffStrategy_Exponential"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "BackoffStrategy": ...

class _BackoffStrategy_Constant(_WitVariantCase, BackoffStrategy):
    """Fixed delay."""
    tag = 'constant'
BackoffStrategy.Constant = _BackoffStrategy_Constant  # type: ignore[attr-defined]

class _BackoffStrategy_Linear(_WitVariantCase, BackoffStrategy):
    """Linear growth."""
    tag = 'linear'
BackoffStrategy.Linear = _BackoffStrategy_Linear  # type: ignore[attr-defined]

class _BackoffStrategy_Exponential(_WitVariantCase, BackoffStrategy):
    """Exponential growth."""
    tag = 'exponential'
BackoffStrategy.Exponential = _BackoffStrategy_Exponential  # type: ignore[attr-defined]

BackoffStrategy._CASES = {  # type: ignore[attr-defined]
    'constant': BackoffStrategy.Constant,
    'linear': BackoffStrategy.Linear,
    'exponential': BackoffStrategy.Exponential,
}


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

@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]
