pub trait Emitter:
Send
+ Sync
+ Debug {
// Required methods
fn emit_output(&self, message: &str);
fn emit_output_with_level(&self, message: &str, level: &str);
fn clone_box(&self) -> Box<dyn Emitter>;
// Provided methods
fn emit_event(
&self,
_category: &str,
_operation: &str,
_payload: Value,
) -> bool { ... }
fn board_recent(&self, _n: usize) -> Vec<Value> { ... }
fn request(
&self,
_target: &str,
_operation: &str,
_payload: Value,
_timeout_ms: Option<u64>,
) -> Result<Value, String> { ... }
fn is_alive(&self, _target_fqn: &str) -> bool { ... }
}Expand description
Trait for emitting events from Components.
Components receive an implementation of this trait via
Component::set_emitter.
The emitter allows Components to:
- Send output to the user (via IO)
- Broadcast signals to other Components
Required Methods§
Sourcefn emit_output(&self, message: &str)
fn emit_output(&self, message: &str)
Emits an output message (info level).
The message will be displayed to the user via IOBridge.
Sourcefn emit_output_with_level(&self, message: &str, level: &str)
fn emit_output_with_level(&self, message: &str, level: &str)
Emits an output message with a specific level.
§Arguments
message- The message to displaylevel- Log level (“info”, “warn”, “error”)
Provided Methods§
Sourcefn emit_event(&self, _category: &str, _operation: &str, _payload: Value) -> bool
fn emit_event(&self, _category: &str, _operation: &str, _payload: Value) -> bool
Emits a custom event (broadcast to all channels).
Creates an Extension event with the given category and broadcasts it to all registered channels. Channels subscribed to the matching Extension category will process it.
§Arguments
category- Extension kind string (e.g., “tool:result”)operation- Operation name (e.g., “complete”)payload- Event payload data
§Returns
true if the event was broadcast successfully.
Sourcefn board_recent(&self, _n: usize) -> Vec<Value>
fn board_recent(&self, _n: usize) -> Vec<Value>
Returns the most recent n Board entries as JSON values.
The Board is a shared rolling buffer of recent Output and Extension events. Components can query it to see what other components have emitted recently.
Default implementation returns an empty vec (no board attached).
§Arguments
n- Maximum number of entries to return
Sourcefn request(
&self,
_target: &str,
_operation: &str,
_payload: Value,
_timeout_ms: Option<u64>,
) -> Result<Value, String>
fn request( &self, _target: &str, _operation: &str, _payload: Value, _timeout_ms: Option<u64>, ) -> Result<Value, String>
Sends a synchronous RPC request to another Component.
Routes via EventBus to the target Component’s on_request handler
and returns the response. Blocks the calling thread until response
is received or timeout expires.
§Arguments
target- Target Component name (e.g., “skill-manager”)operation- Operation name (e.g., “list”, “activate”)payload- Request payloadtimeout_ms- Optional timeout override (default: 30s)
§Returns
Response value from the target Component, or error string.
§Default Implementation
Returns error (not supported without runtime wiring).
Sourcefn is_alive(&self, _target_fqn: &str) -> bool
fn is_alive(&self, _target_fqn: &str) -> bool
Checks whether a target Component is alive (its runner is still running).
Uses the EventBus channel handle to determine liveness without sending
a request. This is a best-effort check — the component may die
immediately after returning true (TOCTOU inherent in concurrent systems).
§Arguments
target_fqn- Fully qualified name or short name of the target Component
§Default Implementation
Returns false (no runtime wiring available).