//! SessionSnapshot —— 见下文 doc comment。Step 3 将填充完整实现。 //! Step 2 仅占位:定义空 struct + derive,使 `engine` 模块编译通过。 use serde::{Deserialize, Serialize}; /// SessionMemory 条目的可序列化形式(保留元数据与时间戳)。 #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct SessionMemoryEntry { /// 原始值(字符串)。 pub value: String, /// 元数据(自由 JSON)。 #[serde(default)] pub metadata: serde_json::Value, /// 创建时间(Unix 时间戳秒;`None` 兼容旧快照)。 /// /// 类型为 `i64` 而非 `u64`:`time` crate 的 `OffsetDateTime::from_unix_timestamp` 接收 `i64`, /// 这里保持与 `SessionMemory::set_with_meta` 签名一致,避免来回转换。 #[serde(default)] pub created_at: Option, } /// AgentSession 的可序列化快照。 /// /// Step 2 占位:字段已定义但未实装 to_snapshot/from_snapshot。 /// Step 3 将基于 `#[serde(default)]` 宽松反序列化,添加 `agent_name`/`turn_index`/slot 等字段。 #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct SessionSnapshot { pub session_id: String, pub agent_name: String, pub turn_index: u32, #[serde(default)] pub cost_so_far: crate::llm::types::usage::CostTracker, #[serde(default)] pub slots: std::collections::HashMap, pub current_slot_id: String, pub last_summary_turn: Option, #[serde(default)] pub session_memory_data: std::collections::HashMap, }