shuvarie-core 0.3.3

Blazingly fast AI coding TUI for chivalrous people (core module)
use shuvarie_db::StoredToolCall;
use shuvarie_llm::FileChange;

#[derive(Debug, Clone)]
pub struct ToolRecord {
    pub name: String,
    pub args_json: String,
    pub output: String,
    pub stderr: String,
    pub ok: bool,
    /// The call never returned: it was cut off when its turn was interrupted.
    /// Persisted so a reload still shows the block (as killed, not failed).
    pub killed: bool,
    pub worker: Option<String>,
    pub message_id: u64,
    pub message_seq: u64,
    pub file_change: Option<FileChange>,
    pub original_content: Option<String>,
    pub new_content: Option<String>,
    pub duration_ms: u64,
}

impl ToolRecord {
    pub fn from_stored(tc: StoredToolCall) -> Self {
        let file_change = if tc.file_change_json.is_empty() {
            None
        } else {
            serde_json::from_str::<FileChange>(&tc.file_change_json).ok()
        };
        Self {
            name: tc.name,
            args_json: tc.args_json,
            output: tc.output,
            stderr: tc.stderr,
            ok: tc.ok,
            killed: tc.killed,
            worker: tc.worker,
            message_id: tc.message_id,
            message_seq: tc.seq,
            file_change,
            original_content: tc.original_content,
            new_content: tc.new_content,
            duration_ms: tc.duration_ms,
        }
    }
}