pub struct PreLlmCtx {
pub session_id: SessionId,
pub messages: Vec<ChatMessage>,
pub tools: Vec<Value>,
pub emit_fn: Option<Box<dyn Fn(UserEvent) + Send + Sync>>,
pub turn_count: u32,
pub max_turns: u32,
}Fields§
§session_id: SessionId§messages: Vec<ChatMessage>§tools: Vec<Value>§emit_fn: Option<Box<dyn Fn(UserEvent) + Send + Sync>>Unified emit function: sends UserEvent to both the renderer (real-time)
and the event bus (persistence). Set by the react loop; middleware calls
emit() which delegates to this closure.
The closure captures the renderer callback and the event bus, so middleware never needs to know about broadcast channels or drain mechanics.
turn_count: u32Current turn count (1-indexed).
max_turns: u32Maximum turns allowed for this run.
Implementations§
Source§impl PreLlmCtx
impl PreLlmCtx
Sourcepub fn emit(&self, event: UserEvent)
pub fn emit(&self, event: UserEvent)
Emit a UserEvent to both the renderer and the event bus.
This is the single entry point for middleware to send events. The event is delivered to the renderer callback (real-time display) and to the event bus (persistence, event_log, checkpoint) in one call.
Does nothing if the emit function was not set (e.g. in tests). Panics inside the emit function are caught and logged as warnings.