"""Get a value from memory."""

from _store import get_value

from core.pathways.context import Context
from core.pathways.models.tool import ToolOutput


async def run(
    key: str,
    namespace: str = "default",
    _context: Context | None = None,
) -> ToolOutput:
    """
    Get a value from memory.

    Args:
        key: The key to retrieve
        namespace: Memory namespace (e.g., "agent_host", "thread_abc")
        context: Execution context

    Returns
    -------
        {"found": bool, "key": str, "value": Any}
    """
    found, value = get_value(namespace, key)

    return ToolOutput(
        success=True,
        data={
            "found": found,
            "key": key,
            "namespace": namespace,
            "value": value,
        },
    )
