steer_core/app/domain/
delta.rs1use crate::app::domain::types::{MessageId, OpId, ToolCallId};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub enum StreamDelta {
6 TextChunk {
7 op_id: OpId,
8 message_id: MessageId,
9 delta: String,
10 },
11
12 ThinkingChunk {
13 op_id: OpId,
14 message_id: MessageId,
15 delta: String,
16 },
17
18 ToolCallChunk {
19 op_id: OpId,
20 message_id: MessageId,
21 tool_call_id: ToolCallId,
22 delta: ToolCallDelta,
23 },
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub enum ToolCallDelta {
28 Name(String),
29 ArgumentChunk(String),
30}
31
32impl StreamDelta {
33 pub fn op_id(&self) -> OpId {
34 match self {
35 StreamDelta::TextChunk { op_id, .. }
36 | StreamDelta::ThinkingChunk { op_id, .. }
37 | StreamDelta::ToolCallChunk { op_id, .. } => *op_id,
38 }
39 }
40
41 pub fn message_id(&self) -> Option<&MessageId> {
42 match self {
43 StreamDelta::TextChunk { message_id, .. }
44 | StreamDelta::ThinkingChunk { message_id, .. }
45 | StreamDelta::ToolCallChunk { message_id, .. } => Some(message_id),
46 }
47 }
48
49 pub fn is_text(&self) -> bool {
50 matches!(self, StreamDelta::TextChunk { .. })
51 }
52
53 pub fn is_thinking(&self) -> bool {
54 matches!(self, StreamDelta::ThinkingChunk { .. })
55 }
56}