pub struct ExtensionEmitter { /* private fields */ }Expand description
An AgentEmitter that fans each AgentEvent out to every plugin handler
registered for the event’s tag. Built from a RegistrySnapshot (so it
shares the registry’s staleness flag) and installed into
AgentHarnessOptions.agent_emitter alongside the host’s
[BroadcastEmitter] — events flow to BOTH the TUI (which drains the
broadcast receiver) and the plugin handlers (which receive translated
StablePluginEvents). The host composes the two via
TeeEmitter; this emitter alone only dispatches to
plugins.
Dispatch is catch_unwind-wrapped: a panicking plugin handler is logged and
skipped (abort-on-unwind policy would be too aggressive for event dispatch
where one bad handler shouldn’t kill the session; we log + continue, unlike
tool-partial dispatch which aborts because it cannot unwind across FFI from
a blocking thread). The distinction: emit runs on the async runtime thread
where catch_unwind can recover cleanly; the tool partial cb runs inside
spawn_blocking cross-FFI where recovery is unsafe.
Implementations§
Source§impl ExtensionEmitter
impl ExtensionEmitter
Sourcepub fn new(
snapshot: Arc<RegistrySnapshot>,
keepalive: Arc<PluginKeepalive>,
) -> Self
pub fn new( snapshot: Arc<RegistrySnapshot>, keepalive: Arc<PluginKeepalive>, ) -> Self
Build an emitter over a snapshot. The keepalive keeps the cdylibs that
own the snapshot’s handler fn pointers mapped for the emitter’s lifetime.
Trait Implementations§
Source§impl AgentEmitter for ExtensionEmitter
impl AgentEmitter for ExtensionEmitter
Source§fn emit(&self, event: AgentEvent) -> BoxFuture<'static, ()>
fn emit(&self, event: AgentEvent) -> BoxFuture<'static, ()>
Source§fn try_emit(&self, event: AgentEvent)
fn try_emit(&self, event: AgentEvent)
on_update path. Must never panic
and must never block (it’s called from a &dyn Fn closure inside
execute). Default impl is a no-op so custom emitters opt in.