"""Return type for run()."""

from __future__ import annotations

from dataclasses import dataclass, field


@dataclass
class RunResult:
    """Result of a Claude Agent SDK session."""

    text: str = ""
    """Joined TextBlock content from all AssistantMessages."""

    cost_usd: float = 0.0
    """Total session cost from ResultMessage.total_cost_usd."""

    usage: dict = field(default_factory=dict)
    """Token breakdown from the ResultMessage."""

    duration_ms: int = 0
    """Wall-clock duration of the session in milliseconds."""

    num_turns: int = 0
    """Number of conversational turns."""

    session_id: str = ""
    """SDK session identifier."""

    is_error: bool = False
    """True if the session ended with an error."""

    error: str | None = None
    """Error description if is_error is True."""

    result_message: object | None = None
    """Raw ResultMessage from the SDK (typed as object to avoid forcing SDK imports)."""

    messages: list = field(default_factory=list)
    """All raw SDK messages received during the session."""
