use serde_json::Value as JsonValue;
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct ConversationMessage {
pub entry_id: String,
pub kind: MessageKind,
}
impl ConversationMessage {
pub fn role_label(&self) -> String {
match &self.kind {
MessageKind::TextContent(tc) => {
if tc.role.is_empty() {
"unknown".to_string()
} else {
tc.role.clone()
}
}
MessageKind::AssistantResponse(_) => "assistant".to_string(),
MessageKind::ToolResultData(tr) => format!("tool/{}", tr.tool_name),
MessageKind::BashOutput(_) => "bash".to_string(),
}
}
}
#[derive(Debug, Clone)]
pub enum MessageKind {
TextContent(TextContent),
AssistantResponse(AssistantResponse),
ToolResultData(ToolResultData),
BashOutput(BashOutput),
}
#[derive(Debug, Clone)]
pub struct TextContent {
pub role: String,
pub text: String,
}
#[derive(Debug, Clone)]
pub struct AssistantResponse {
pub thinking: Vec<String>,
pub tool_calls: Vec<ToolCall>,
pub text: String,
}
#[derive(Debug, Clone)]
pub struct ToolResultData {
pub tool_name: String,
pub content: String,
pub is_error: bool,
}
#[derive(Debug, Clone)]
pub struct BashOutput {
pub command: String,
pub output: String,
}
#[derive(Debug, Clone)]
pub struct ToolCall {
pub name: String,
pub arguments: JsonValue,
}
#[derive(Debug, Clone)]
pub struct Entry {
pub id: String,
pub parent_id: String,
}
#[derive(Debug, Clone)]
pub struct Context {
pub entries: Vec<Entry>,
pub messages: Vec<ConversationMessage>,
}
#[derive(Debug, Clone)]
pub struct SearchHit {
pub entry_id: String,
pub score: f64,
pub role: String,
pub text: String,
pub files: Vec<String>,
}
#[derive(Debug, Clone)]
pub struct ContextListing {
pub id: String,
pub detail: String,
pub path: Option<PathBuf>,
}