#, which carries all 36 event types. Revisit"
)]
#![cfg_attr(
not(feature = "sse"),
doc = "Use the `sse` module — enable the `sse` feature — which carries all 36",
doc = "event types. Revisit"
)]
use crate::encode::{EventStreamFormatter, PROTOBUF_MEDIA_TYPE};
use crate::error::{Error, Result};
use crate::event::{Event, EventType};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct ProtobufFormatter;
impl ProtobufFormatter {
pub const fn new() -> Self {
Self
}
}
impl EventStreamFormatter for ProtobufFormatter {
fn content_type(&self) -> &'static str {
PROTOBUF_MEDIA_TYPE
}
fn encode(&self, _event: &Event) -> Result<Vec<u8>> {
Err(Error::UnsupportedTransport(
"the AG-UI protobuf schema covers only 21 of 36 event types; use SSE",
))
}
}
pub const COVERED_EVENT_TYPES: &[EventType] = &[
EventType::TextMessageStart,
EventType::TextMessageContent,
EventType::TextMessageEnd,
EventType::TextMessageChunk,
EventType::ToolCallStart,
EventType::ToolCallArgs,
EventType::ToolCallEnd,
EventType::ToolCallChunk,
EventType::StateSnapshot,
EventType::StateDelta,
EventType::MessagesSnapshot,
EventType::Raw,
EventType::Custom,
EventType::RunStarted,
EventType::RunFinished,
EventType::RunError,
EventType::StepStarted,
EventType::StepFinished,
EventType::SubagentStarted,
EventType::SubagentFinished,
EventType::SubagentError,
];
pub fn is_covered(event_type: EventType) -> bool {
COVERED_EVENT_TYPES.contains(&event_type)
}