from dataclasses import dataclass
from typing import Protocol, TypeVar, Any, Iterable

ToolCallT = TypeVar("ToolCallT", contravariant=True)

ToolT = TypeVar("ToolT", contravariant=True)


@dataclass(frozen=True)
class ToolCallInfo:
    id: str
    name: str
    args: dict[str, Any]


class FrameworkAdapter(Protocol[ToolCallT, ToolT]):
    def serialize_tool_args(self, tool_args: dict[str, Any]) -> str: ...
    def serialize_agent_state(self, agent_state: dict[str, Any]) -> str: ...
    def get_tool_call_info(self, tool_call: ToolCallT) -> ToolCallInfo: ...

    def tool_args_to_dict(self, tool_args: dict[str, Any]) -> dict[str, Any]: ...

    def agent_state_to_dict(self, agent_state: dict[str, Any]) -> dict[str, Any]: ...

    def get_user_query(self, agent_state: dict[str, Any]) -> str | None: ...

    def wrap_tools(self, tools: Iterable[ToolT]) -> Iterable[ToolT]: ...
