from __future__ import annotations

from enum import Enum
from typing import Any, Callable, TypeVar, cast

F = TypeVar("F", bound=Callable[..., Any])


class Status(str, Enum):
    PENDING = "pending"
    EXECUTING = "executing"
    COMPLETED = "completed"
    FAILED = "failed"


def tool(func: F | None = None) -> F | Callable[[F], F]:
    """
    Lightweight tool decorator used by Armorer.

    We keep tools as regular Python callables and convert them to OpenAI Agents
    function tools at runtime inside BaseAgent.
    """

    def _decorate(f: F) -> F:
        setattr(f, "__armorer_tool__", True)
        return f

    if func is None:
        return _decorate
    return cast(F, _decorate(func))
