"""Agent event dataclasses — emitted during run_stream() and forwarded to WebSocket clients."""

from dataclasses import dataclass


@dataclass
class ToolEvent:
    """Emitted during streaming to inform the client about tool activity."""

    tool_name: str
    arguments: dict
    result: str
    success: bool


@dataclass
class TextDelta:
    """A chunk of text from the streaming LLM response."""

    delta: str


@dataclass
class ThinkingDelta:
    """A chunk of thinking/reasoning text from the streaming LLM response."""

    delta: str


@dataclass
class ThinkingEnd:
    """Marks the end of the thinking phase."""


@dataclass
class StreamEnd:
    """Marks the end of the streaming response."""

    full_content: str
    context_tokens: int | None = None   # total tokens used in this turn
    max_context_tokens: int = 0         # ollama_num_ctx from config


@dataclass
class ContextCompressed:
    """Emitted after context compression runs successfully."""

    messages_before: int
    messages_after: int


AgentEvent = ToolEvent | TextDelta | ThinkingDelta | ThinkingEnd | StreamEnd | ContextCompressed
