Provider-agnostic event types for agent communication.
These structs represent the events that flow from a provider (pi RPC,
direct API, etc.) to the Agent.Session. The session uses them to
update conversation state, status, and UI without knowing anything
about the underlying provider protocol.
Summary
Types
Agent has finished processing.
Agent has started processing a prompt.
Pre-send estimated context usage.
An error occurred in the agent.
Union of all agent event types.
A chunk of assistant response text.
A chunk of the agent's internal reasoning.
Token usage statistics from a completed response.
A destructive tool call needs user approval before executing.
A tool call has completed.
A file-modifying tool captured before/after content for diff review.
A tool call has started.
Partial progress on a running tool call.
The agent reached its per-prompt turn limit.
Types
@type agent_end() :: %MingaAgent.Event.AgentEnd{usage: token_usage() | nil}
Agent has finished processing.
@type agent_start() :: %MingaAgent.Event.AgentStart{}
Agent has started processing a prompt.
@type context_usage() :: %MingaAgent.Event.ContextUsage{ context_limit: non_neg_integer() | nil, estimated_tokens: non_neg_integer() }
Pre-send estimated context usage.
@type error() :: %MingaAgent.Event.Error{message: String.t()}
An error occurred in the agent.
@type t() :: agent_start() | agent_end() | text_delta() | thinking_delta() | tool_start() | tool_update() | tool_end() | tool_approval() | tool_file_changed() | context_usage() | turn_limit_reached() | error()
Union of all agent event types.
@type text_delta() :: %MingaAgent.Event.TextDelta{delta: String.t()}
A chunk of assistant response text.
@type thinking_delta() :: %MingaAgent.Event.ThinkingDelta{delta: String.t()}
A chunk of the agent's internal reasoning.
@type token_usage() :: MingaAgent.TurnUsage.t()
Token usage statistics from a completed response.
@type tool_approval() :: %MingaAgent.Event.ToolApproval{ args: map(), name: String.t(), reply_to: pid(), tool_call_id: String.t() }
A destructive tool call needs user approval before executing.
@type tool_end() :: %MingaAgent.Event.ToolEnd{ is_error: boolean(), name: String.t(), result: String.t(), tool_call_id: String.t() }
A tool call has completed.
@type tool_file_changed() :: %MingaAgent.Event.ToolFileChanged{ after_content: String.t(), before_content: String.t(), path: String.t(), tool_call_id: String.t() }
A file-modifying tool captured before/after content for diff review.
@type tool_start() :: %MingaAgent.Event.ToolStart{ args: map(), name: String.t(), tool_call_id: String.t() }
A tool call has started.
@type tool_update() :: %MingaAgent.Event.ToolUpdate{ name: String.t(), partial_result: String.t(), tool_call_id: String.t() }
Partial progress on a running tool call.
@type turn_limit_reached() :: %MingaAgent.Event.TurnLimitReached{ current: non_neg_integer(), limit: pos_integer() }
The agent reached its per-prompt turn limit.