27 lines
660 B
Rust
27 lines
660 B
Rust
use std::sync::Arc;
|
|
|
|
use crate::agent::AgentError;
|
|
use crate::storage::{SessionRecord, SessionStore};
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct CliSessionService {
|
|
store: Arc<SessionStore>,
|
|
}
|
|
|
|
impl CliSessionService {
|
|
pub(crate) fn new(store: Arc<SessionStore>) -> Self {
|
|
Self { store }
|
|
}
|
|
|
|
/// 创建指定通道的会话
|
|
pub(crate) fn create_with_channel(
|
|
&self,
|
|
channel_name: &str,
|
|
title: Option<&str>,
|
|
) -> Result<SessionRecord, AgentError> {
|
|
self.store
|
|
.create_session(channel_name, title)
|
|
.map_err(|err| AgentError::Other(format!("create session error: {}", err)))
|
|
}
|
|
}
|