use serde::{Deserialize, Serialize};
pub const PENDING_STREAM_COMMENTARY_SEGMENT_ID: &str = "pending-stream-commentary";
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SegmentKind {
Commentary,
Answer,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TurnSegment {
pub segment_id: String,
pub kind: SegmentKind,
pub before_tool_call_id: Option<String>,
pub text: String,
pub open: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ToolStep {
pub tool_call_id: String,
pub name: String,
pub summary: String,
pub before_commentary: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Turn {
pub pre_tool_timeline: Vec<String>,
pub steps: Vec<ToolStep>,
pub segments: Vec<TurnSegment>,
pub tool_phase_open: bool,
}
impl Turn {
pub fn segment_by_id_mut(&mut self, id: &str) -> Option<&mut TurnSegment> {
self.segments.iter_mut().find(|s| s.segment_id == id)
}
pub fn step_by_call_id_mut(&mut self, id: &str) -> Option<&mut ToolStep> {
self.steps.iter_mut().find(|s| s.tool_call_id == id)
}
pub fn step_by_call_id(&self, id: &str) -> Option<&ToolStep> {
self.steps.iter().find(|s| s.tool_call_id == id)
}
}