services/storage/memory_db

SQLite-backed memory persistence. Replaces file_memory.gleam. Stateless — every function takes a Connection.

Target is a String: “memory” or “user” (matches the DB column). Character limits are enforced on add/replace.

Types

pub type Snapshot {
  Snapshot(entries: List(String), target: String)
}

Constructors

  • Snapshot(entries: List(String), target: String)

Values

pub fn add_entry(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
  content: String,
) -> Result(Nil, String)
pub fn capture_snapshot(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
) -> Result(Snapshot, String)
pub fn delete_all(
  conn: sqlight.Connection,
  user_key: String,
) -> Result(Int, String)

Delete all memories for a user_key (admin wipe).

pub fn format_for_system_prompt(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
) -> Result(String, String)
pub fn format_snapshot(snapshot: Snapshot) -> String
pub fn get_entries(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
) -> Result(List(String), String)
pub fn migrate_from_files_if_needed(
  conn: sqlight.Connection,
  user_key: String,
) -> Result(Nil, String)
pub fn remove_entry(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
  old_text: String,
) -> Result(Nil, String)
pub fn replace_entry(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
  old_text: String,
  new_content: String,
) -> Result(Nil, String)
pub fn snapshot_usage_string(snapshot: Snapshot) -> String
pub fn usage_string(
  conn: sqlight.Connection,
  user_key: String,
  target: String,
) -> Result(String, String)
Search Document