"""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 .multi_agent import NodeResult


class EdgeHandlerError:
    """Why an edge evaluation failed."""

    class Unknown(_WitVariantCase):
        """No handler registered for the given id."""
        tag = 'unknown'

    class Failed(_WitVariantCase):
        """Handler raised an exception."""
        tag = 'failed'

    _CASES: dict[str, type] = {
        'unknown': Unknown,
        'failed': Failed,
    }

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

@dataclass(kw_only=True)
class HandlerState:
    """State snapshot passed to `evaluate` so the handler can branch on
prior node results."""
    results: list[NodeResult]
    execution_count: int
