Skip to main content

systemprompt_models/agui/
event_type.rs

1//! AG-UI event type tags.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
10pub enum AgUiEventType {
11    RunStarted,
12    RunFinished,
13    RunError,
14    StepStarted,
15    StepFinished,
16    TextMessageStart,
17    TextMessageContent,
18    TextMessageEnd,
19    ToolCallStart,
20    ToolCallArgs,
21    ToolCallEnd,
22    ToolCallResult,
23    StateSnapshot,
24    StateDelta,
25    MessagesSnapshot,
26    Custom,
27}
28
29impl AgUiEventType {
30    pub const fn as_str(&self) -> &'static str {
31        match self {
32            Self::RunStarted => "RUN_STARTED",
33            Self::RunFinished => "RUN_FINISHED",
34            Self::RunError => "RUN_ERROR",
35            Self::StepStarted => "STEP_STARTED",
36            Self::StepFinished => "STEP_FINISHED",
37            Self::TextMessageStart => "TEXT_MESSAGE_START",
38            Self::TextMessageContent => "TEXT_MESSAGE_CONTENT",
39            Self::TextMessageEnd => "TEXT_MESSAGE_END",
40            Self::ToolCallStart => "TOOL_CALL_START",
41            Self::ToolCallArgs => "TOOL_CALL_ARGS",
42            Self::ToolCallEnd => "TOOL_CALL_END",
43            Self::ToolCallResult => "TOOL_CALL_RESULT",
44            Self::StateSnapshot => "STATE_SNAPSHOT",
45            Self::StateDelta => "STATE_DELTA",
46            Self::MessagesSnapshot => "MESSAGES_SNAPSHOT",
47            Self::Custom => "CUSTOM",
48        }
49    }
50}