tirea_protocol_ag_ui/
output_encoder.rs

1use super::{AgUiEventContext, Event};
2use tirea_contract::{AgentEvent, Transcoder};
3
4pub struct AgUiProtocolEncoder {
5    ctx: AgUiEventContext,
6}
7
8impl AgUiProtocolEncoder {
9    pub fn new() -> Self {
10        Self {
11            ctx: AgUiEventContext::new(),
12        }
13    }
14
15    pub fn new_with_frontend_run_id(run_id: impl Into<String>) -> Self {
16        Self {
17            ctx: AgUiEventContext::new().with_frontend_run_id(run_id),
18        }
19    }
20}
21
22impl Default for AgUiProtocolEncoder {
23    fn default() -> Self {
24        Self::new()
25    }
26}
27
28impl Transcoder for AgUiProtocolEncoder {
29    type Input = AgentEvent;
30    type Output = Event;
31
32    fn transcode(&mut self, item: &AgentEvent) -> Vec<Event> {
33        self.ctx.on_agent_event(item)
34    }
35}