from __future__ import annotations

import pytest

from core.agent.agui_adapter import AguiAdapter


def test_to_command_maps_payload_fields() -> None:
    adapter = AguiAdapter()

    command = adapter.to_command(
        {
            "message": "hello",
            "session_id": "00000000-0000-0000-0000-000000000001",
        }
    )

    assert command["message"] == "hello"
    assert command["session_id"] == "00000000-0000-0000-0000-000000000001"


def test_to_protocol_event_maps_internal_event() -> None:
    adapter = AguiAdapter()

    mapped = adapter.to_protocol_event(
        {
            "kind": "run_completed",
            "session_id": "run-1",
            "output": "done",
        }
    )

    assert mapped == {"type": "run.completed", "run_id": "run-1", "output": "done"}


def test_to_protocol_event_raises_for_invalid_event() -> None:
    adapter = AguiAdapter()

    with pytest.raises(ValueError):
        adapter.to_protocol_event({"kind": "unknown"})
