merry_runtime/
session_projection.rs1use crate::session::TranscriptItemSnapshot;
2use merry_core::{ImageSummary, PendingToolCall, ToolCallId, ToolCallResult, ToolOutput};
3
4#[derive(Debug, Clone, PartialEq, Eq)]
9pub enum SessionTranscriptItem {
10 UserMessage {
11 text: String,
12 images: Vec<ImageSummary>,
13 },
14 AssistantText {
15 text: String,
16 },
17 AssistantReasoning {
18 text: String,
19 },
20 ToolCall {
21 call: PendingToolCall,
22 },
23 ToolResult {
24 call_id: ToolCallId,
25 result: ToolCallResult,
26 output: Option<ToolOutput>,
27 },
28}
29
30impl From<TranscriptItemSnapshot> for SessionTranscriptItem {
31 fn from(value: TranscriptItemSnapshot) -> Self {
32 match value {
33 TranscriptItemSnapshot::UserMessage { text, images, .. } => Self::UserMessage {
34 text,
35 images: images
36 .into_iter()
37 .map(|image| ImageSummary::new(image.label(), image.width(), image.height()))
38 .collect(),
39 },
40 TranscriptItemSnapshot::AssistantText { text } => Self::AssistantText { text },
41 TranscriptItemSnapshot::AssistantReasoning { text } => {
42 Self::AssistantReasoning { text }
43 }
44 TranscriptItemSnapshot::ToolCall { call } => Self::ToolCall { call },
45 TranscriptItemSnapshot::ToolResult {
46 call_id,
47 result,
48 output,
49 ..
50 } => Self::ToolResult {
51 call_id,
52 result,
53 output: Some(output),
54 },
55 }
56 }
57}