pub struct UserMemoryView { /* private fields */ }Expand description
A per-user view over the shared agent memory store.
Provides file routing and search merging for multi-user deployments:
- Shared files (
SOUL.md,HEARTBEAT.md,BOOT.md,BOOTSTRAP.md) come from the agent-level store and are shared across all users. - Per-user files (
USER.md,MEMORY.md,memory/*daily logs) live inusers/<id>/and are indexed in a per-user SQLite FTS5 database. - Search queries both agent-level and user-level indexes concurrently, merging results by rank.
- Writes automatically route to the correct store based on the file path, with FTS reindexing handled transparently.
Implementations§
Source§impl UserMemoryView
impl UserMemoryView
Sourcepub async fn new(
agent_store: Arc<MemoryStore>,
user_dir: PathBuf,
) -> Result<Self>
pub async fn new( agent_store: Arc<MemoryStore>, user_dir: PathBuf, ) -> Result<Self>
Create a new per-user memory view.
Creates the user directory structure, seeds default USER.md and
MEMORY.md if they don’t exist, and initializes a per-user FTS5
index (stored in user_dir/memory.db).
This is async because it initializes the per-user SQLite database.
Sourcepub fn bootstrap_context(&self, bootstrap_file_cap: usize) -> Result<String>
pub fn bootstrap_context(&self, bootstrap_file_cap: usize) -> Result<String>
Build bootstrap context: SOUL.md from agent, USER.md + MEMORY.md + recent logs from user.
Sourcepub async fn search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SearchResult>>
pub async fn search( &self, query: &str, limit: usize, ) -> Result<Vec<SearchResult>>
Search both agent-level and user-level content.
Queries both the shared agent FTS index and the per-user FTS index
concurrently, merges results by rank, and returns the top limit.
Sourcepub async fn write_file(&self, name: &str, content: &str) -> Result<()>
pub async fn write_file(&self, name: &str, content: &str) -> Result<()>
Write a file, routing to the appropriate location.
USER.md,MEMORY.md,memory/*→ user store (with FTS reindex)- Everything else → agent store (shared)
Sourcepub async fn append_daily(&self, text: &str) -> Result<()>
pub async fn append_daily(&self, text: &str) -> Result<()>
Append to the user’s daily log (with FTS reindex).
Sourcepub fn read_file(&self, name: &str) -> Result<String>
pub fn read_file(&self, name: &str) -> Result<String>
Read a file from the appropriate location.
Sourcepub fn has_bootstrap(&self) -> bool
pub fn has_bootstrap(&self) -> bool
Check if BOOTSTRAP.md exists (delegates to agent store).
Sourcepub fn clear_bootstrap(&self) -> Result<()>
pub fn clear_bootstrap(&self) -> Result<()>
Clear BOOTSTRAP.md (delegates to agent store).
Auto Trait Implementations§
impl Freeze for UserMemoryView
impl !RefUnwindSafe for UserMemoryView
impl Send for UserMemoryView
impl Sync for UserMemoryView
impl Unpin for UserMemoryView
impl UnsafeUnpin for UserMemoryView
impl !UnwindSafe for UserMemoryView
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
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>
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>
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 more