pub struct RepositorySessionManager { /* private fields */ }Expand description
Session manager that uses a repository for persistence.
This is the primary session manager for production use, providing agent initialization, message appending, and state synchronization.
Implementations§
Source§impl RepositorySessionManager
impl RepositorySessionManager
Sourcepub async fn new(
session_id: impl Into<String>,
session_repository: Arc<dyn SessionRepository>,
) -> Result<Self>
pub async fn new( session_id: impl Into<String>, session_repository: Arc<dyn SessionRepository>, ) -> Result<Self>
Create a new RepositorySessionManager.
If no session with the specified session_id exists, it will be created.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Get the session ID.
Sourcepub async fn append_message(
&self,
message: Message,
agent_id: &str,
) -> Result<()>
pub async fn append_message( &self, message: Message, agent_id: &str, ) -> Result<()>
Append a message to the agent’s session.
Sourcepub async fn redact_latest_message(
&self,
redact_message: Message,
agent_id: &str,
) -> Result<()>
pub async fn redact_latest_message( &self, redact_message: Message, agent_id: &str, ) -> Result<()>
Redact the latest message appended to the session.
Sourcepub async fn sync_agent(&self, agent: &SessionAgent) -> Result<()>
pub async fn sync_agent(&self, agent: &SessionAgent) -> Result<()>
Sync an agent’s state to the session repository.
Sourcepub async fn initialize_agent(
&self,
agent_id: &str,
) -> Result<Option<SessionAgent>>
pub async fn initialize_agent( &self, agent_id: &str, ) -> Result<Option<SessionAgent>>
Initialize an agent with a session.
If the agent already exists in the session, its state will be restored. Otherwise, a new agent entry will be created.
Sourcepub async fn restore_messages(
&self,
agent_id: &str,
offset: usize,
) -> Result<Vec<Message>>
pub async fn restore_messages( &self, agent_id: &str, offset: usize, ) -> Result<Vec<Message>>
Restore messages for an agent.
Sourcepub async fn sync_multi_agent(
&self,
multi_agent_id: &str,
state: &Value,
) -> Result<()>
pub async fn sync_multi_agent( &self, multi_agent_id: &str, state: &Value, ) -> Result<()>
Sync multi-agent state to the session repository.
Auto Trait Implementations§
impl !Freeze for RepositorySessionManager
impl !RefUnwindSafe for RepositorySessionManager
impl Send for RepositorySessionManager
impl Sync for RepositorySessionManager
impl Unpin for RepositorySessionManager
impl !UnwindSafe for RepositorySessionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.