cli-textual-demo / src /cli_textual /core /chat_events.py
jim-bo's picture
feat: thinking transparency layer with /verbose command
2509530
from dataclasses import dataclass
from typing import Dict, Any, List
import asyncio
@dataclass
class ChatDeps:
"""Dependencies injected into Pydantic AI runs for interactive TUI tools."""
event_queue: asyncio.Queue
input_queue: asyncio.Queue
@dataclass
class ChatEvent:
"""Base class for all agent loop events."""
pass
@dataclass
class AgentRequiresUserInput(ChatEvent):
"""The agent needs the TUI to gather input from the user."""
tool_name: str
prompt: str
options: List[str]
@dataclass
class AgentExecuteCommand(ChatEvent):
"""The agent wants to execute a TUI slash command."""
command_name: str
args: List[str]
@dataclass
class AgentThinking(ChatEvent):
"""The agent is processing or waiting for a response."""
message: str = "Thinking..."
@dataclass
class AgentToolStart(ChatEvent):
"""The agent has decided to call a tool."""
tool_name: str
args: Dict[str, Any]
@dataclass
class AgentToolEnd(ChatEvent):
"""The agent has finished executing a tool."""
tool_name: str
result: str
@dataclass
class AgentToolOutput(ChatEvent):
"""Streaming output from a running tool (e.g., bash stdout, file contents)."""
tool_name: str
content: str
is_error: bool = False
@dataclass
class AgentThinkingChunk(ChatEvent):
"""A partial chunk of the model's reasoning/thinking tokens."""
text: str
@dataclass
class AgentThinkingComplete(ChatEvent):
"""The model has finished emitting thinking tokens for this turn."""
full_text: str
@dataclass
class AgentStreamChunk(ChatEvent):
"""A partial chunk of the final text response."""
text: str
@dataclass
class AgentComplete(ChatEvent):
"""The agent has finished the entire request loop."""
new_history: List[Any] = None # List[ModelMessage]