- README 添加 feature 组合表 + 模块级 features 清单 + 升级指南 - 18 个 example 顶部添加 Required features 注释 - roadmap.md 和 roadmap-v0.3.2.md 同步 Phase 26-27 完成状态 - cargo fmt 全量格式化(修复预存格式问题,CI format job 可通过)
40 lines
1.6 KiB
Rust
40 lines
1.6 KiB
Rust
//! 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<i64>,
|
||
}
|
||
|
||
/// 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<String, crate::agent::context::ContextSlot>,
|
||
pub current_slot_id: String,
|
||
pub last_summary_turn: Option<u32>,
|
||
#[serde(default)]
|
||
pub session_memory_data: std::collections::HashMap<String, SessionMemoryEntry>,
|
||
}
|