from __future__ import annotations

from typing import Any

from core.agent.event_bridge import map_internal_event


class AguiAdapter:
    def to_command(self, payload: dict[str, Any]) -> dict[str, Any]:
        message = payload.get("message")
        if not isinstance(message, str) or not message.strip():
            raise ValueError("message is required")

        return {
            "message": message,
            "session_id": payload.get("session_id"),
        }

    def to_protocol_event(self, event: dict[str, Any]) -> dict[str, Any]:
        return map_internal_event(event)
