pub enum AgentEvent {
Show 13 variants
Connected {
session_id: String,
cwd: String,
current_model: CurrentModel,
available_models: Vec<AvailableModel>,
mode: Option<ModeState>,
history_updates: Option<Vec<Message>>,
compaction_count: u32,
},
ConnectionFailed {
message: String,
kind: SpawnFailureKind,
},
TurnError {
session_id: String,
message: String,
class: TurnErrorClass,
},
PermissionRequest {
session_id: String,
request: PermissionRequest,
},
QuestionRequest {
session_id: String,
request: QuestionRequest,
},
PromptCancelResolved {
uuid: String,
cancelled: bool,
},
McpOperationError {
session_id: String,
error: McpOperationError,
},
SetModeFailed {
session_id: String,
mode: PermissionMode,
message: String,
},
SetModelFailed {
session_id: String,
model: String,
message: String,
},
ContextUsage {
session_id: String,
percentage: Option<u8>,
max_tokens: Option<u64>,
total_tokens: Option<u64>,
effective_max_tokens: Option<u64>,
},
McpSnapshot {
session_id: String,
servers: Vec<McpServerStatus>,
error: Option<String>,
},
SdkMessage {
session_id: String,
msg: Message,
},
HookObservation {
session_id: String,
tool_use_id: Option<String>,
permission_mode: Option<String>,
effort: Option<String>,
agent_id: Option<String>,
agent_type: Option<String>,
},
}Variants§
Connected
ConnectionFailed
A spawn failure the bridge could name, carried beside the message so a consumer reads the variant rather than searching rendered prose for a word that a path can also contain.
TurnError
A user-facing turn never reached the CLI (or was never
acknowledged): a view committed to Thinking before the
dispatch, so without this event the spinner never tears down.
Fields
class: TurnErrorClassThe class of the failure, derived from message where the
event is built so no reader has to search the prose again.
PermissionRequest
QuestionRequest
PromptCancelResolved
The CLI answered a cancel_async_message. cancelled: false means the
prompt was already dequeued for execution - it is on its way to the
model, and a reader has to say so rather than pretend it was dropped.
McpOperationError
SetModeFailed
The CLI refused (or failed) a set_permission_mode control
request. message carries the underlying error text so the
consumer can roll back the optimistic mode change and surface
the reason.
SetModelFailed
The CLI refused (or failed) a set_model control request.
message carries the underlying error text so the consumer can
roll back the optimistic model change and surface the reason.
ContextUsage
Fields
McpSnapshot
SdkMessage
Raw forge_primitives::Message envelope from the underlying
SDK Client, forwarded to the consumer (e.g. a view’s app)
for per-variant dispatch and state mutation.
HookObservation
Observation of CLI runtime state captured from a hook input
payload as it passes through the SDK’s hook-callback dispatch.
Hooks fire on every tool use, prompt submit, etc., so this is
a high-fidelity signal compared to the lower-frequency
system/status events. Fields are Option because the CLI
only populates the relevant subset on each hook event (e.g.
agent_id / agent_type are absent for main-agent tool calls).
Fields
tool_use_id: Option<String>tool_use_id when the hook event is tool-lifecycle scoped.
None for events that aren’t bound to a specific tool call
(UserPromptSubmit, Stop, etc.).
permission_mode: Option<String>Permission mode active at the moment the hook fired. Wire
value as a string (e.g. "acceptEdits", "plan"); the
consumer types it with forge_primitives::PermissionMode.
effort: Option<String>Effort level active at the moment the hook fired (CLI
2.1.133+, absent for older CLIs). Wire value as a string
("low" / "medium" / "high" / "xhigh" / "max");
the consumer maps to forge_primitives::EffortLevel.