pub struct Handler {
agent_to_block: HashMap<String, String>,
block_to_agent: HashMap<String, String>,
agent_info: HashMap<String, AgentRegistration>,
input_sender: Option<Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>>,
message_sender: Option<Arc<dyn Fn(&str, &str) -> Result<bool, String> + Send + Sync>>,
audit_log: Vec<AuditLogEntry>,
rate_limiter: RateLimiter,
include_source_in_message: bool,
}Expand description
Core reactive messaging handler.
Manages agent registrations, rate limiting, message injection, and audit logging.
Fields§
§agent_to_block: HashMap<String, String>§block_to_agent: HashMap<String, String>§agent_info: HashMap<String, AgentRegistration>§input_sender: Option<Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>>§message_sender: Option<Arc<dyn Fn(&str, &str) -> Result<bool, String> + Send + Sync>>Controller-aware delivery for non-PTY agents (persistent stream-json / ACP).
When set, it is tried before the PTY keystroke path so messages reach (and
steer) agents that have no terminal. See set_message_sender.
audit_log: Vec<AuditLogEntry>§rate_limiter: RateLimiter§include_source_in_message: boolImplementations§
Source§impl Handler
impl Handler
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new handler without an input sender.
Call set_input_sender before injecting messages.
Sourcepub fn set_input_sender(
&mut self,
sender: Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>,
)
pub fn set_input_sender( &mut self, sender: Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>, )
Set the input sender function for message injection.
Sourcepub fn set_message_sender(
&mut self,
sender: Arc<dyn Fn(&str, &str) -> Result<bool, String> + Send + Sync>,
)
pub fn set_message_sender( &mut self, sender: Arc<dyn Fn(&str, &str) -> Result<bool, String> + Send + Sync>, )
Set the controller-aware message sender. When present, inject_message
tries it first: persistent stream-json and ACP agents receive a structured
message on their live channel (mid-turn steering); PTY-based agents report
back so injection falls through to the keystroke path.
Sourcepub fn set_include_source(&mut self, include: bool)
pub fn set_include_source(&mut self, include: bool)
Set whether to include source agent prefix in injected messages.
Sourcepub fn register_agent(
&mut self,
agent_id: &str,
block_id: &str,
tab_id: Option<&str>,
) -> Result<(), String>
pub fn register_agent( &mut self, agent_id: &str, block_id: &str, tab_id: Option<&str>, ) -> Result<(), String>
Register an agent with a block.
Sourcepub fn unregister_agent(&mut self, agent_id: &str)
pub fn unregister_agent(&mut self, agent_id: &str)
Unregister an agent.
Sourcepub fn unregister_block(&mut self, block_id: &str)
pub fn unregister_block(&mut self, block_id: &str)
Unregister by block ID.
Sourcepub fn update_last_seen(&mut self, agent_id: &str)
pub fn update_last_seen(&mut self, agent_id: &str)
Update the last_seen timestamp for an agent.
Sourcepub fn get_agent(&self, agent_id: &str) -> Option<&AgentRegistration>
pub fn get_agent(&self, agent_id: &str) -> Option<&AgentRegistration>
Get agent registration by agent ID.
Sourcepub fn get_agent_by_block(&self, block_id: &str) -> Option<&AgentRegistration>
pub fn get_agent_by_block(&self, block_id: &str) -> Option<&AgentRegistration>
Get agent registration by block ID.
Sourcepub fn list_agents(&self) -> Vec<AgentRegistration>
pub fn list_agents(&self) -> Vec<AgentRegistration>
List all registered agents.
Sourcepub fn list_active_blocks(&self) -> Vec<String>
pub fn list_active_blocks(&self) -> Vec<String>
List all block IDs that have a registered agent.
Sourcepub fn inject_message(&mut self, req: InjectionRequest) -> InjectionResponse
pub fn inject_message(&mut self, req: InjectionRequest) -> InjectionResponse
Inject a message into an agent’s terminal.
Sends message\r as a single payload (required for text display),
then spawns 3 delayed \r sends at 200ms intervals as separate
PTY writes to ensure submission. See specs/jekt-inject-timing.md.
Sourcepub fn get_audit_log(&self, limit: usize) -> Vec<AuditLogEntry>
pub fn get_audit_log(&self, limit: usize) -> Vec<AuditLogEntry>
Get audit log entries, most recent first.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handler
impl !RefUnwindSafe for Handler
impl Send for Handler
impl Sync for Handler
impl Unpin for Handler
impl !UnwindSafe for Handler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more