Skip to main content

openagent/api/response/
event.rs

1//! Event types for OpenAI Response SSE API.
2
3#![allow(missing_docs)]
4
5// self
6use super::{object::*, r#type::*};
7use crate::_prelude::*;
8
9/// All possible events from the OpenAI Response API stream.
10#[derive(Debug, Deserialize)]
11#[serde(tag = "type")]
12pub enum ResponseEvent {
13	#[serde(rename = "response.created")]
14	Created(ResponseCreatedEvent),
15	#[serde(rename = "response.in_progress")]
16	InProgress(ResponseInProgressEvent),
17	#[serde(rename = "response.completed")]
18	Completed(ResponseCompletedEvent),
19	#[serde(rename = "response.failed")]
20	Failed(ResponseFailedEvent),
21	#[serde(rename = "response.incomplete")]
22	Incomplete(ResponseIncompleteEvent),
23	#[serde(rename = "response.queued")]
24	Queued(ResponseQueuedEvent),
25	#[serde(rename = "response.output_item.added")]
26	OutputItemAdded(ResponseOutputItemAddedEvent),
27	#[serde(rename = "response.output_item.done")]
28	OutputItemDone(ResponseOutputItemDoneEvent),
29	#[serde(rename = "response.content_part.added")]
30	ContentPartAdded(ResponseContentPartAddedEvent),
31	#[serde(rename = "response.content_part.done")]
32	ContentPartDone(ResponseContentPartDoneEvent),
33	#[serde(rename = "response.output_text.delta")]
34	OutputTextDelta(ResponseOutputTextDeltaEvent),
35	#[serde(rename = "response.output_text.done")]
36	OutputTextDone(ResponseOutputTextDoneEvent),
37	#[serde(rename = "response.refusal.delta")]
38	RefusalDelta(ResponseRefusalDeltaEvent),
39	#[serde(rename = "response.refusal.done")]
40	RefusalDone(ResponseRefusalDoneEvent),
41	#[serde(rename = "response.function_call_arguments.delta")]
42	FunctionCallArgumentsDelta(ResponseFunctionCallArgumentsDeltaEvent),
43	#[serde(rename = "response.function_call_arguments.done")]
44	FunctionCallArgumentsDone(ResponseFunctionCallArgumentsDoneEvent),
45	#[serde(rename = "response.file_search_call.in_progress")]
46	FileSearchCallInProgress(ResponseFileSearchCallInProgressEvent),
47	#[serde(rename = "response.file_search_call.searching")]
48	FileSearchCallSearching(ResponseFileSearchCallSearchingEvent),
49	#[serde(rename = "response.file_search_call.completed")]
50	FileSearchCallCompleted(ResponseFileSearchCallCompletedEvent),
51	#[serde(rename = "response.web_search_call.in_progress")]
52	WebSearchCallInProgress(ResponseWebSearchCallInProgressEvent),
53	#[serde(rename = "response.web_search_call.searching")]
54	WebSearchCallSearching(ResponseWebSearchCallSearchingEvent),
55	#[serde(rename = "response.web_search_call.completed")]
56	WebSearchCallCompleted(ResponseWebSearchCallCompletedEvent),
57	#[serde(rename = "response.reasoning_summary_part.added")]
58	ReasoningSummaryPartAdded(ResponseReasoningSummaryPartAddedEvent),
59	#[serde(rename = "response.reasoning_summary_part.done")]
60	ReasoningSummaryPartDone(ResponseReasoningSummaryPartDoneEvent),
61	#[serde(rename = "response.reasoning_summary_text.delta")]
62	ReasoningSummaryTextDelta(ResponseReasoningSummaryTextDeltaEvent),
63	#[serde(rename = "response.reasoning_summary_text.done")]
64	ReasoningSummaryTextDone(ResponseReasoningSummaryTextDoneEvent),
65	#[serde(rename = "response.image_generation_call.completed")]
66	ImageGenerationCallCompleted(ResponseImageGenerationCallCompletedEvent),
67	#[serde(rename = "response.image_generation_call.generating")]
68	ImageGenerationCallGenerating(ResponseImageGenerationCallGeneratingEvent),
69	#[serde(rename = "response.image_generation_call.in_progress")]
70	ImageGenerationCallInProgress(ResponseImageGenerationCallInProgressEvent),
71	#[serde(rename = "response.image_generation_call.partial_image")]
72	ImageGenerationCallPartialImage(ResponseImageGenerationCallPartialImageEvent),
73	#[serde(rename = "response.mcp_call.arguments.delta")]
74	McpCallArgumentsDelta(ResponseMcpCallArgumentsDeltaEvent),
75	#[serde(rename = "response.mcp_call.arguments.done")]
76	McpCallArgumentsDone(ResponseMcpCallArgumentsDoneEvent),
77	#[serde(rename = "response.mcp_call.completed")]
78	McpCallCompleted(ResponseMcpCallCompletedEvent),
79	#[serde(rename = "response.mcp_call.failed")]
80	McpCallFailed(ResponseMcpCallFailedEvent),
81	#[serde(rename = "response.mcp_call.in_progress")]
82	McpCallInProgress(ResponseMcpCallInProgressEvent),
83	#[serde(rename = "response.mcp_list_tools.completed")]
84	McpListToolsCompleted(ResponseMcpListToolsCompletedEvent),
85	#[serde(rename = "response.mcp_list_tools.failed")]
86	McpListToolsFailed(ResponseMcpListToolsFailedEvent),
87	#[serde(rename = "response.mcp_list_tools.in_progress")]
88	McpListToolsInProgress(ResponseMcpListToolsInProgressEvent),
89	#[serde(rename = "response.output_text.annotation.added")]
90	OutputTextAnnotationAdded(ResponseOutputTextAnnotationAddedEvent),
91	#[serde(rename = "response.reasoning.delta")]
92	ReasoningDelta(ResponseReasoningDeltaEvent),
93	#[serde(rename = "response.reasoning.done")]
94	ReasoningDone(ResponseReasoningDoneEvent),
95	#[serde(rename = "response.reasoning_summary.delta")]
96	ReasoningSummaryDelta(ResponseReasoningSummaryDeltaEvent),
97	#[serde(rename = "response.reasoning_summary.done")]
98	ReasoningSummaryDone(ResponseReasoningSummaryDoneEvent),
99	#[serde(rename = "error")]
100	Error(ErrorEvent),
101}
102
103#[derive(Debug, Deserialize)]
104pub struct EventBase {
105	pub sequence_number: u32,
106}
107
108#[derive(Debug, Deserialize)]
109pub struct ResponseCreatedEvent {
110	#[serde(flatten)]
111	pub base: EventBase,
112	pub response: ResponseObject,
113}
114
115#[derive(Debug, Deserialize)]
116pub struct ResponseInProgressEvent {
117	#[serde(flatten)]
118	pub base: EventBase,
119	pub response: ResponseObject,
120}
121
122#[derive(Debug, Deserialize)]
123pub struct ResponseCompletedEvent {
124	#[serde(flatten)]
125	pub base: EventBase,
126	pub response: ResponseObject,
127}
128
129#[derive(Debug, Deserialize)]
130pub struct ResponseFailedEvent {
131	#[serde(flatten)]
132	pub base: EventBase,
133	pub response: ResponseObject,
134}
135
136#[derive(Debug, Deserialize)]
137pub struct ResponseIncompleteEvent {
138	#[serde(flatten)]
139	pub base: EventBase,
140	pub response: ResponseObject,
141}
142
143#[derive(Debug, Deserialize)]
144pub struct ResponseQueuedEvent {
145	#[serde(flatten)]
146	pub base: EventBase,
147	pub response: Value,
148}
149
150#[derive(Debug, Deserialize)]
151pub struct ResponseOutputItemAddedEvent {
152	#[serde(flatten)]
153	pub base: EventBase,
154	pub output_index: u32,
155	pub item: ResponseOutput,
156}
157
158#[derive(Debug, Deserialize)]
159pub struct ResponseOutputItemDoneEvent {
160	#[serde(flatten)]
161	pub base: EventBase,
162	pub output_index: u32,
163	pub item: ResponseOutput,
164}
165
166#[derive(Debug, Deserialize)]
167pub struct ResponseContentPartAddedEvent {
168	#[serde(flatten)]
169	pub base: EventBase,
170	pub item_id: String,
171	pub output_index: u32,
172	pub content_index: u32,
173	pub part: ResponseMessageOutputContent,
174}
175
176#[derive(Debug, Deserialize)]
177pub struct ResponseContentPartDoneEvent {
178	#[serde(flatten)]
179	pub base: EventBase,
180	pub item_id: String,
181	pub output_index: u32,
182	pub content_index: u32,
183	pub part: Value,
184}
185
186#[derive(Debug, Deserialize)]
187pub struct ResponseOutputTextDeltaEvent {
188	#[serde(flatten)]
189	pub base: EventBase,
190	pub item_id: String,
191	pub output_index: u32,
192	pub content_index: u32,
193	pub delta: String,
194}
195
196#[derive(Debug, Deserialize)]
197pub struct ResponseOutputTextDoneEvent {
198	#[serde(flatten)]
199	pub base: EventBase,
200	pub item_id: String,
201	pub output_index: u32,
202	pub content_index: u32,
203	pub text: String,
204}
205
206#[derive(Debug, Deserialize)]
207pub struct ResponseRefusalDeltaEvent {
208	#[serde(flatten)]
209	pub base: EventBase,
210	pub item_id: String,
211	pub output_index: u32,
212	pub content_index: u32,
213	pub delta: String,
214}
215
216#[derive(Debug, Deserialize)]
217pub struct ResponseRefusalDoneEvent {
218	#[serde(flatten)]
219	pub base: EventBase,
220	pub item_id: String,
221	pub output_index: u32,
222	pub content_index: u32,
223	pub refusal: String,
224}
225
226#[derive(Debug, Deserialize)]
227pub struct ResponseFunctionCallArgumentsDeltaEvent {
228	#[serde(flatten)]
229	pub base: EventBase,
230	pub item_id: String,
231	pub output_index: u32,
232	pub delta: String,
233}
234
235#[derive(Debug, Deserialize)]
236pub struct ResponseFunctionCallArgumentsDoneEvent {
237	#[serde(flatten)]
238	pub base: EventBase,
239	pub item_id: String,
240	pub output_index: u32,
241	pub arguments: String,
242}
243
244#[derive(Debug, Deserialize)]
245pub struct ResponseFileSearchCallInProgressEvent {
246	#[serde(flatten)]
247	pub base: EventBase,
248	pub item_id: String,
249	pub output_index: u32,
250}
251
252#[derive(Debug, Deserialize)]
253pub struct ResponseFileSearchCallSearchingEvent {
254	#[serde(flatten)]
255	pub base: EventBase,
256	pub item_id: String,
257	pub output_index: u32,
258}
259
260#[derive(Debug, Deserialize)]
261pub struct ResponseFileSearchCallCompletedEvent {
262	#[serde(flatten)]
263	pub base: EventBase,
264	pub item_id: String,
265	pub output_index: u32,
266}
267
268#[derive(Debug, Deserialize)]
269pub struct ResponseWebSearchCallInProgressEvent {
270	#[serde(flatten)]
271	pub base: EventBase,
272	pub item_id: String,
273	pub output_index: u32,
274}
275
276#[derive(Debug, Deserialize)]
277pub struct ResponseWebSearchCallSearchingEvent {
278	#[serde(flatten)]
279	pub base: EventBase,
280	pub item_id: String,
281	pub output_index: u32,
282}
283
284#[derive(Debug, Deserialize)]
285pub struct ResponseWebSearchCallCompletedEvent {
286	#[serde(flatten)]
287	pub base: EventBase,
288	pub item_id: String,
289	pub output_index: u32,
290}
291
292#[derive(Debug, Deserialize)]
293pub struct ResponseReasoningSummaryPartAddedEvent {
294	#[serde(flatten)]
295	pub base: EventBase,
296	pub item_id: String,
297	pub output_index: u32,
298	pub summary_index: u32,
299	pub part: Value,
300}
301
302#[derive(Debug, Deserialize)]
303pub struct ResponseReasoningSummaryPartDoneEvent {
304	#[serde(flatten)]
305	pub base: EventBase,
306	pub item_id: String,
307	pub output_index: u32,
308	pub summary_index: u32,
309	pub part: Value,
310}
311
312#[derive(Debug, Deserialize)]
313pub struct ResponseReasoningSummaryTextDeltaEvent {
314	#[serde(flatten)]
315	pub base: EventBase,
316	pub item_id: String,
317	pub output_index: u32,
318	pub summary_index: u32,
319	pub delta: String,
320}
321
322#[derive(Debug, Deserialize)]
323pub struct ResponseReasoningSummaryTextDoneEvent {
324	#[serde(flatten)]
325	pub base: EventBase,
326	pub item_id: String,
327	pub output_index: u32,
328	pub summary_index: u32,
329	pub text: String,
330}
331
332#[derive(Debug, Deserialize)]
333pub struct ResponseImageGenerationCallCompletedEvent {
334	#[serde(flatten)]
335	pub base: EventBase,
336	pub item_id: String,
337	pub output_index: u32,
338}
339
340#[derive(Debug, Deserialize)]
341pub struct ResponseImageGenerationCallGeneratingEvent {
342	#[serde(flatten)]
343	pub base: EventBase,
344	pub item_id: String,
345	pub output_index: u32,
346}
347
348#[derive(Debug, Deserialize)]
349pub struct ResponseImageGenerationCallInProgressEvent {
350	#[serde(flatten)]
351	pub base: EventBase,
352	pub item_id: String,
353	pub output_index: u32,
354}
355
356#[derive(Debug, Deserialize)]
357pub struct ResponseImageGenerationCallPartialImageEvent {
358	#[serde(flatten)]
359	pub base: EventBase,
360	pub item_id: String,
361	pub output_index: u32,
362	pub partial_image_index: u32,
363	pub partial_image_b64: String,
364}
365
366#[derive(Debug, Deserialize)]
367pub struct ResponseMcpCallArgumentsDeltaEvent {
368	#[serde(flatten)]
369	pub base: EventBase,
370	pub item_id: String,
371	pub output_index: u32,
372	pub delta: Value,
373}
374
375#[derive(Debug, Deserialize)]
376pub struct ResponseMcpCallArgumentsDoneEvent {
377	#[serde(flatten)]
378	pub base: EventBase,
379	pub item_id: String,
380	pub output_index: u32,
381	pub arguments: Value,
382}
383
384#[derive(Debug, Deserialize)]
385pub struct ResponseMcpCallCompletedEvent {
386	#[serde(flatten)]
387	pub base: EventBase,
388}
389
390#[derive(Debug, Deserialize)]
391pub struct ResponseMcpCallFailedEvent {
392	#[serde(flatten)]
393	pub base: EventBase,
394}
395
396#[derive(Debug, Deserialize)]
397pub struct ResponseMcpCallInProgressEvent {
398	#[serde(flatten)]
399	pub base: EventBase,
400	pub item_id: String,
401	pub output_index: u32,
402}
403
404#[derive(Debug, Deserialize)]
405pub struct ResponseMcpListToolsCompletedEvent {
406	#[serde(flatten)]
407	pub base: EventBase,
408}
409
410#[derive(Debug, Deserialize)]
411pub struct ResponseMcpListToolsFailedEvent {
412	#[serde(flatten)]
413	pub base: EventBase,
414}
415
416#[derive(Debug, Deserialize)]
417pub struct ResponseMcpListToolsInProgressEvent {
418	#[serde(flatten)]
419	pub base: EventBase,
420}
421
422#[derive(Debug, Deserialize)]
423pub struct ResponseOutputTextAnnotationAddedEvent {
424	#[serde(flatten)]
425	pub base: EventBase,
426	pub item_id: String,
427	pub output_index: u32,
428	pub content_index: u32,
429	pub annotation_index: u32,
430	pub annotation: Annotation,
431}
432
433#[derive(Debug, Deserialize)]
434pub struct ResponseReasoningDeltaEvent {
435	#[serde(flatten)]
436	pub base: EventBase,
437	pub item_id: String,
438	pub output_index: u32,
439	pub content_index: u32,
440	pub delta: Value,
441}
442
443#[derive(Debug, Deserialize)]
444pub struct ResponseReasoningDoneEvent {
445	#[serde(flatten)]
446	pub base: EventBase,
447	pub item_id: String,
448	pub output_index: u32,
449	pub content_index: u32,
450	pub text: String,
451}
452
453#[derive(Debug, Deserialize)]
454pub struct ResponseReasoningSummaryDeltaEvent {
455	#[serde(flatten)]
456	pub base: EventBase,
457	pub item_id: String,
458	pub output_index: u32,
459	pub summary_index: u32,
460	pub delta: Value,
461}
462
463#[derive(Debug, Deserialize)]
464pub struct ResponseReasoningSummaryDoneEvent {
465	#[serde(flatten)]
466	pub base: EventBase,
467	pub item_id: String,
468	pub output_index: u32,
469	pub summary_index: u32,
470	pub text: String,
471}
472
473#[derive(Debug, Deserialize)]
474pub struct ErrorEvent {
475	#[serde(flatten)]
476	pub error: ErrorBase,
477	#[serde(flatten)]
478	pub event: EventBase,
479}