1use std::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum ResponseEvent {
6 Created,
7 InProgress,
8 Completed,
9}
10
11impl ResponseEvent {
12 pub const CREATED: &'static str = "response.created";
13 pub const IN_PROGRESS: &'static str = "response.in_progress";
14 pub const COMPLETED: &'static str = "response.completed";
15
16 pub const fn as_str(&self) -> &'static str {
17 match self {
18 Self::Created => Self::CREATED,
19 Self::InProgress => Self::IN_PROGRESS,
20 Self::Completed => Self::COMPLETED,
21 }
22 }
23}
24
25impl fmt::Display for ResponseEvent {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 f.write_str(self.as_str())
28 }
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
33pub enum OutputItemEvent {
34 Added,
35 Done,
36 Delta,
37}
38
39impl OutputItemEvent {
40 pub const ADDED: &'static str = "response.output_item.added";
41 pub const DONE: &'static str = "response.output_item.done";
42 pub const DELTA: &'static str = "response.output_item.delta";
43
44 pub const fn as_str(&self) -> &'static str {
45 match self {
46 Self::Added => Self::ADDED,
47 Self::Done => Self::DONE,
48 Self::Delta => Self::DELTA,
49 }
50 }
51}
52
53impl fmt::Display for OutputItemEvent {
54 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
55 f.write_str(self.as_str())
56 }
57}
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
61pub enum FunctionCallEvent {
62 ArgumentsDelta,
63 ArgumentsDone,
64}
65
66impl FunctionCallEvent {
67 pub const ARGUMENTS_DELTA: &'static str = "response.function_call_arguments.delta";
68 pub const ARGUMENTS_DONE: &'static str = "response.function_call_arguments.done";
69
70 pub const fn as_str(&self) -> &'static str {
71 match self {
72 Self::ArgumentsDelta => Self::ARGUMENTS_DELTA,
73 Self::ArgumentsDone => Self::ARGUMENTS_DONE,
74 }
75 }
76}
77
78impl fmt::Display for FunctionCallEvent {
79 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
80 f.write_str(self.as_str())
81 }
82}
83
84#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
86pub enum ContentPartEvent {
87 Added,
88 Done,
89}
90
91impl ContentPartEvent {
92 pub const ADDED: &'static str = "response.content_part.added";
93 pub const DONE: &'static str = "response.content_part.done";
94
95 pub const fn as_str(&self) -> &'static str {
96 match self {
97 Self::Added => Self::ADDED,
98 Self::Done => Self::DONE,
99 }
100 }
101}
102
103impl fmt::Display for ContentPartEvent {
104 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
105 f.write_str(self.as_str())
106 }
107}
108
109#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
111pub enum OutputTextEvent {
112 Delta,
113 Done,
114}
115
116impl OutputTextEvent {
117 pub const DELTA: &'static str = "response.output_text.delta";
118 pub const DONE: &'static str = "response.output_text.done";
119
120 pub const fn as_str(&self) -> &'static str {
121 match self {
122 Self::Delta => Self::DELTA,
123 Self::Done => Self::DONE,
124 }
125 }
126}
127
128impl fmt::Display for OutputTextEvent {
129 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
130 f.write_str(self.as_str())
131 }
132}
133
134#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
140pub enum McpEvent {
141 CallArgumentsDelta,
142 CallArgumentsDone,
143 CallInProgress,
144 CallCompleted,
145 CallFailed,
146 ListToolsInProgress,
147 ListToolsCompleted,
148}
149
150impl McpEvent {
151 pub const CALL_ARGUMENTS_DELTA: &'static str = "response.mcp_call_arguments.delta";
152 pub const CALL_ARGUMENTS_DONE: &'static str = "response.mcp_call_arguments.done";
153 pub const CALL_IN_PROGRESS: &'static str = "response.mcp_call.in_progress";
154 pub const CALL_COMPLETED: &'static str = "response.mcp_call.completed";
155 pub const CALL_FAILED: &'static str = "response.mcp_call.failed";
156 pub const LIST_TOOLS_IN_PROGRESS: &'static str = "response.mcp_list_tools.in_progress";
157 pub const LIST_TOOLS_COMPLETED: &'static str = "response.mcp_list_tools.completed";
158
159 pub const fn as_str(&self) -> &'static str {
160 match self {
161 Self::CallArgumentsDelta => Self::CALL_ARGUMENTS_DELTA,
162 Self::CallArgumentsDone => Self::CALL_ARGUMENTS_DONE,
163 Self::CallInProgress => Self::CALL_IN_PROGRESS,
164 Self::CallCompleted => Self::CALL_COMPLETED,
165 Self::CallFailed => Self::CALL_FAILED,
166 Self::ListToolsInProgress => Self::LIST_TOOLS_IN_PROGRESS,
167 Self::ListToolsCompleted => Self::LIST_TOOLS_COMPLETED,
168 }
169 }
170}
171
172impl fmt::Display for McpEvent {
173 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
174 f.write_str(self.as_str())
175 }
176}
177
178#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
180pub enum ItemType {
181 FunctionCall,
182 FunctionToolCall,
183 McpCall,
184 Function,
185 McpListTools,
186}
187
188impl ItemType {
189 pub const FUNCTION_CALL: &'static str = "function_call";
190 pub const FUNCTION_TOOL_CALL: &'static str = "function_tool_call";
191 pub const MCP_CALL: &'static str = "mcp_call";
192 pub const FUNCTION: &'static str = "function";
193 pub const MCP_LIST_TOOLS: &'static str = "mcp_list_tools";
194
195 pub const fn as_str(&self) -> &'static str {
196 match self {
197 Self::FunctionCall => Self::FUNCTION_CALL,
198 Self::FunctionToolCall => Self::FUNCTION_TOOL_CALL,
199 Self::McpCall => Self::MCP_CALL,
200 Self::Function => Self::FUNCTION,
201 Self::McpListTools => Self::MCP_LIST_TOOLS,
202 }
203 }
204
205 pub const fn is_function_call(&self) -> bool {
207 matches!(self, Self::FunctionCall | Self::FunctionToolCall)
208 }
209}
210
211impl fmt::Display for ItemType {
212 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
213 f.write_str(self.as_str())
214 }
215}
216
217pub fn is_response_event(event_type: &str) -> bool {
219 matches!(
220 event_type,
221 ResponseEvent::CREATED | ResponseEvent::IN_PROGRESS | ResponseEvent::COMPLETED
222 )
223}
224
225pub fn is_function_call_type(item_type: &str) -> bool {
227 item_type == ItemType::FUNCTION_CALL || item_type == ItemType::FUNCTION_TOOL_CALL
228}