Skip to main content

microagents_storage/
types.rs

1use std::fmt::Debug;
2
3use microagents_events::{AgentEventAny, SessionInitEvent};
4
5/// Trait for backends that persist and retrieve agent session events.
6#[async_trait::async_trait]
7pub trait AgentStorage: Send + Debug + Sync {
8    /// Persist the initial event that starts a new session.
9    async fn create_session(&self, event: SessionInitEvent) -> anyhow::Result<()>;
10    /// Append an event to an existing session.
11    async fn update_session(&self, event: AgentEventAny) -> anyhow::Result<()>;
12    /// Retrieve all events for a given session, ordered by time.
13    async fn get_session(&self, session_id: &str) -> anyhow::Result<Vec<AgentEventAny>>;
14}
15
16/// Available storage backend implementations.
17#[derive(Debug, Clone, PartialEq, Eq, Copy)]
18pub enum AgentStorageChoice {
19    /// In-memory storage (ephemeral).
20    Memory,
21    /// JSON Lines file storage.
22    Jsonl,
23    /// SQLite database storage.
24    Sqlite,
25}