from __future__ import annotations

from threading import Lock

from app.modules.api.domain.models.agent_request import AgentRequest


class InMemoryRequestStore:
    def __init__(self) -> None:
        self._items: dict[str, AgentRequest] = {}
        self._lock = Lock()

    def save(self, request: AgentRequest) -> AgentRequest:
        with self._lock:
            self._items[request.request_id] = request
        return request

    def get(self, request_id: str) -> AgentRequest | None:
        with self._lock:
            return self._items.get(request_id)
