Expand description
Session 模块
提供 session 管理功能,包括:
SessionStoretrait: 可插拔的存储抽象SessionManager: 向后兼容的静态方法(使用全局 store)- SQLite 默认实现
§使用方式
§方式 1: 使用默认 SQLite 存储(向后兼容)
ⓘ
use aster::session::SessionManager;
let session = SessionManager::create_session(dir, name, session_type).await?;§方式 2: 注入自定义存储(推荐)
ⓘ
use aster::session::{SessionStore, NoopSessionStore};
use aster::agents::Agent;
let store = Arc::new(MyCustomStore::new());
let agent = Agent::new().with_session_store(store);Re-exports§
pub use extension_data::EnabledExtensionsState;pub use extension_data::ExtensionData;pub use extension_data::ExtensionState;pub use extension_data::TodoState;pub use resume::build_resume_message;pub use resume::delete_summary;pub use resume::has_summary;pub use resume::list_summaries;pub use resume::load_summary;pub use resume::load_summary_data;pub use resume::save_summary;pub use resume::SummaryCacheData;pub use session_manager::Session;pub use session_manager::SessionInsights;pub use session_manager::SessionManager;pub use session_manager::SessionType;
Modules§
- extension_
data - resume
- Session Resume Support
- session_
manager
Structs§
- Bulk
Archive Result - Result of bulk archive operation
- Chat
History Match - 聊天历史搜索结果
- Cleanup
Stats - Cleanup statistics
- Export
Options - Export options
- Fork
Metadata - Fork metadata stored in extension_data
- Fork
Options - Fork options for creating a new session branch
- Merge
Options - Merge options for combining sessions
- Noop
Session Store - 空存储实现(不保存任何数据)
- Session
Branch Tree - Session branch tree structure
- Session
Statistics - Detailed session statistics
- Session
Summary - Brief session summary for statistics
- Token
Stats Update - Token 统计更新参数
Enums§
- Export
Format - Export format options
- Merge
Strategy - Strategy for merging session messages
- Metadata
Strategy - Strategy for preserving metadata during merge
Constants§
- DEFAULT_
CLEANUP_ PERIOD_ DAYS - Default cleanup period in days
Traits§
- Session
Store - Session 存储 trait
Functions§
- archive_
and_ delete_ session - Archive and delete a session
- archive_
session - Archive a session by exporting it to the archive directory
- bulk_
archive_ sessions - Bulk archive sessions
- bulk_
export_ sessions - Bulk export multiple sessions
- calculate_
statistics - Calculate statistics from a list of sessions
- cleanup_
expired_ data - Clean up expired data (summaries only for now)
- delete_
archived_ session - Delete an archived session permanently
- export_
session - Export a session to the specified format
- export_
session_ to_ file - Export session to file
- force_
cleanup - Force cleanup synchronously
- fork_
session - Fork a session to create a new branch
- generate_
diagnostics - generate_
report - Generate a text report of session statistics
- get_
all_ statistics - Get statistics for all sessions
- get_
cutoff_ date - Get the cutoff date for cleanup
- get_
global_ session_ store - 获取全局 session store
- get_
session_ branch_ tree - Get the branch tree for a session
- is_
global_ session_ store_ set - 检查全局 session store 是否已设置
- list_
archived_ sessions - List archived sessions
- merge_
sessions - Merge one session into another
- restore_
archived_ session - Restore an archived session
- schedule_
cleanup - Schedule cleanup to run asynchronously
- set_
global_ session_ store - 设置全局 session store