Expand description
Server-Sent Events (SSE) broadcasting infrastructure for systemprompt.io.
This crate hosts the in-process event bus that fans out A2A, AG-UI,
analytics, and context events to per-user SSE connections. It is shared
between the HTTP API entry crate and the runtime layer so that any
component holding a UserId can publish typed events without knowing
about the wire format.
§Modules
services— theGenericBroadcasterimplementation, the per-event broadcaster type aliases, and the staticEventRouter.sse— theToSsetrait andserde-driven implementations that convertsystemprompt_modelsevent types intoaxumSSE records.error— the publicEventError/EventResultsurface.
§Feature flags
This crate has no Cargo features; everything compiles by default.
§Example
use systemprompt_events::{A2A_BROADCASTER, Broadcaster};
use systemprompt_identifiers::UserId;
use systemprompt_models::A2AEvent;
let user_id = UserId::new("user_abc");
let delivered = A2A_BROADCASTER.broadcast(&user_id, event).await;
tracing::info!(delivered, "A2A event fanned out");Re-exports§
pub use error::EventError;pub use error::EventResult;pub use sse::ToSse;pub use extension::EventsExtension;pub use services::A2A_BROADCASTER;pub use services::A2ABroadcaster;pub use services::AGUI_BROADCASTER;pub use services::ANALYTICS_BROADCASTER;pub use services::AgUiBroadcaster;pub use services::AnalyticsBroadcaster;pub use services::CONTEXT_BROADCASTER;pub use services::ConnectionGuard;pub use services::ContextBroadcaster;pub use services::EventRouter;pub use services::GenericBroadcaster;pub use services::HEARTBEAT_INTERVAL;pub use services::HEARTBEAT_JSON;pub use services::OUTBOX_CHANNEL;pub use services::OutboxChannel;pub use services::PostgresEventBridge;pub use services::standard_keep_alive;
Modules§
- error
- Error types raised by the event-broadcasting infrastructure.
- extension
- Extension-framework registration for the events crate.
- services
- Broadcaster implementations, the static fan-out
EventRouter, and the cross-replicaPostgresEventBridge. - sse
- Conversion from typed event payloads into
axumServer-Sent Event records.