use crate::error::Result;
use crate::internal::sessions_fs;
use serde::{Deserialize, Serialize};
pub mod store;
pub use store::*;
pub mod store_fork;
pub use store_fork::*;
pub mod import;
pub use import::*;
pub mod local_fork;
pub use local_fork::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionInfo {
pub id: String,
pub title: String,
pub created_at: String,
pub updated_at: String,
pub message_count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionMessage {
pub id: String,
pub role: String,
pub content: String,
pub timestamp: String,
}
#[derive(Debug, Clone, Default)]
pub struct ListSessionsOptions {
pub directory: Option<String>,
pub limit: Option<usize>,
pub offset: Option<usize>,
}
#[derive(Debug, Clone)]
pub struct SessionQueryOptions {
pub session_id: String,
pub include_messages: bool,
pub directory: Option<String>,
pub limit: Option<usize>,
pub offset: Option<usize>,
}
#[derive(Debug, Clone)]
pub struct SessionMutationOptions {
pub session_id: String,
pub directory: Option<String>,
}
pub async fn list_sessions(opts: &ListSessionsOptions) -> Result<Vec<SessionInfo>> {
sessions_fs::list_sessions(opts).await
}
pub async fn get_session_info(session_id: &str, opts: &SessionQueryOptions) -> Result<SessionInfo> {
sessions_fs::get_session_info(session_id, opts.directory.as_deref()).await
}
pub async fn get_session_messages(
session_id: &str,
opts: &SessionQueryOptions,
) -> Result<Vec<SessionMessage>> {
sessions_fs::get_session_messages(
session_id,
opts.directory.as_deref(),
opts.limit,
opts.offset.unwrap_or(0),
)
.await
}
pub async fn list_subagents(session_id: &str, opts: &SessionQueryOptions) -> Result<Vec<String>> {
sessions_fs::list_subagents(session_id, opts.directory.as_deref()).await
}
pub async fn get_subagent_messages(
session_id: &str,
agent_id: &str,
opts: &SessionQueryOptions,
) -> Result<Vec<SessionMessage>> {
sessions_fs::get_subagent_messages(
session_id,
agent_id,
opts.directory.as_deref(),
opts.limit,
opts.offset.unwrap_or(0),
)
.await
}
pub async fn rename_session(
session_id: &str,
title: &str,
opts: &SessionMutationOptions,
) -> Result<()> {
sessions_fs::rename_session(session_id, title, opts.directory.as_deref()).await
}
pub async fn tag_session(
session_id: &str,
tag: Option<&str>,
opts: &SessionMutationOptions,
) -> Result<()> {
sessions_fs::tag_session(session_id, tag, opts.directory.as_deref()).await
}
pub async fn fork_session(
session_id: &str,
opts: &SessionMutationOptions,
up_to_message_id: Option<&str>,
title: Option<&str>,
) -> Result<LocalForkSessionResult> {
local_fork::fork_session(
session_id,
opts.directory.as_deref(),
up_to_message_id,
title,
)
.await
}
pub async fn delete_session(session_id: &str, opts: &SessionMutationOptions) -> Result<()> {
sessions_fs::delete_session(session_id, opts.directory.as_deref()).await
}