The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(memory): replace local reader adapters with re-exports from tinymemory_sources
Steven Enamakelaa8302c193ce
diff --git a/crates/openhuman-core/src/memory/sources/readers/composio.rs b/crates/openhuman-core/src/memory/sources/readers/composio.rsdeleted file mode 100644index 12be6f8b89..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/composio.rs+++ /dev/null@@ -1,76 +0,0 @@-//! Composio source reader — delegates to the existing composio sync layer.-//!-//! For Composio sources, `list_items` returns the sync targets and-//! `read_item` is not meaningful (sync is provider-driven, not-//! item-by-item). The reader exists so the registry can uniformly-//! query all source kinds.--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::types::{- ContentType, MemorySourceEntry, SourceContent, SourceItem, SourceKind,-};--use crate::memory::sources::readers::SourceReader;--/// Lists a Composio connection as a single sync target.-///-/// Composio data arrives through the provider sync pipeline rather than-/// item-by-item, so `read_item` returns a description of that rather than-/// content. The reader exists so the registry can query every source kind-/// uniformly.-pub struct ComposioReader;--#[async_trait]-impl SourceReader for ComposioReader {- fn kind(&self) -> SourceKind {- SourceKind::Composio- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- _config: &Config,- ) -> Result<Vec<SourceItem>, String> {- let toolkit = source.toolkit.as_deref().unwrap_or("unknown");- let connection_id = source.connection_id.as_deref().unwrap_or("unknown");-- tracing::debug!(- toolkit = %toolkit,- connection_id = %connection_id,- "[memory_sources:composio] list_items"- );-- Ok(vec![SourceItem {- id: connection_id.to_string(),- title: format!("{toolkit} connection"),- updated_at_ms: None,- }])- }-- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- _config: &Config,- ) -> Result<SourceContent, String> {- let toolkit = source.toolkit.as_deref().unwrap_or("unknown");- Ok(SourceContent {- id: item_id.to_string(),- title: format!("{toolkit} sync data"),- body: format!(- "Composio {toolkit} data is synced via the provider sync pipeline, not read item-by-item."- ),- content_type: ContentType::Plaintext,- metadata: serde_json::json!({- "toolkit": toolkit,- "connection_id": source.connection_id,- }),- })- }-}--#[cfg(test)]-#[path = "composio_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/memory/sources/readers/composio_tests.rs b/crates/openhuman-core/src/memory/sources/readers/composio_tests.rsdeleted file mode 100644index 3c866e05ee..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/composio_tests.rs+++ /dev/null@@ -1,39 +0,0 @@-//! Tests for the surrounding module.--use super::*;-use crate::memory::sources::types::MemorySourceEntry;--fn test_source() -> MemorySourceEntry {- MemorySourceEntry {- id: "src_1".into(),- kind: SourceKind::Composio,- label: "Gmail".into(),- enabled: true,- toolkit: Some("gmail".into()),- connection_id: Some("cmp_123".into()),- path: None,- glob: None,- url: None,- branch: None,- paths: Vec::new(),- query: None,- since_days: None,- max_items: None,- max_commits: None,- max_issues: None,- max_prs: None,- selector: None,- max_tokens_per_sync: None,- max_cost_per_sync_usd: None,- sync_depth_days: None,- }-}--#[tokio::test]-async fn list_items_returns_connection_as_item() {- let reader = ComposioReader;- let config = Config::default();- let items = reader.list_items(&test_source(), &config).await.unwrap();- assert_eq!(items.len(), 1);- assert_eq!(items[0].id, "cmp_123");-}diff --git a/crates/openhuman-core/src/memory/sources/readers/conversation.rs b/crates/openhuman-core/src/memory/sources/readers/conversation.rsdeleted file mode 100644index e1ec31e05d..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/conversation.rs+++ /dev/null@@ -1,47 +0,0 @@-//! Product `Config` adapter for the engine-neutral `conversation` reader.--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::readers::SourceReader;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--/// Reads `conversation` sources by delegating to [`tinymemory_sources::readers::conversation`].-pub struct ConversationReader;--#[async_trait]-impl SourceReader for ConversationReader {- fn kind(&self) -> SourceKind {- SourceKind::Conversation- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- config: &Config,- ) -> Result<Vec<SourceItem>, String> {- tinymemory_sources::readers::SourceReader::list_items(- &tinymemory_sources::readers::conversation::ConversationReader,- source,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- config: &Config,- ) -> Result<SourceContent, String> {- tinymemory_sources::readers::SourceReader::read_item(- &tinymemory_sources::readers::conversation::ConversationReader,- source,- item_id,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-}diff --git a/crates/openhuman-core/src/memory/sources/readers/folder.rs b/crates/openhuman-core/src/memory/sources/readers/folder.rsdeleted file mode 100644index 1d63cefc33..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/folder.rs+++ /dev/null@@ -1,47 +0,0 @@-//! Product `Config` adapter for the engine-neutral `folder` reader.--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::readers::SourceReader;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--/// Reads `folder` sources by delegating to [`tinymemory_sources::readers::folder`].-pub struct FolderReader;--#[async_trait]-impl SourceReader for FolderReader {- fn kind(&self) -> SourceKind {- SourceKind::Folder- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- config: &Config,- ) -> Result<Vec<SourceItem>, String> {- tinymemory_sources::readers::SourceReader::list_items(- &tinymemory_sources::readers::folder::FolderReader,- source,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- config: &Config,- ) -> Result<SourceContent, String> {- tinymemory_sources::readers::SourceReader::read_item(- &tinymemory_sources::readers::folder::FolderReader,- source,- item_id,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-}diff --git a/crates/openhuman-core/src/memory/sources/readers/github.rs b/crates/openhuman-core/src/memory/sources/readers/github.rsdeleted file mode 100644index 93dff5a45f..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/github.rs+++ /dev/null@@ -1,50 +0,0 @@-//! Product `Config` adapter for the engine-neutral `github` reader.--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::readers::SourceReader;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--pub use tinymemory_sources::readers::github::{repo_archive_source_id, repo_chunk_scope};--/// Reads `github_repo` sources by delegating to-/// [`tinymemory_sources::readers::github`].-pub struct GithubReader;--#[async_trait]-impl SourceReader for GithubReader {- fn kind(&self) -> SourceKind {- SourceKind::GithubRepo- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- config: &Config,- ) -> Result<Vec<SourceItem>, String> {- tinymemory_sources::readers::SourceReader::list_items(- &tinymemory_sources::readers::github::GithubReader,- source,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- config: &Config,- ) -> Result<SourceContent, String> {- tinymemory_sources::readers::SourceReader::read_item(- &tinymemory_sources::readers::github::GithubReader,- source,- item_id,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-}diff --git a/crates/openhuman-core/src/memory/sources/readers/mod.rs b/crates/openhuman-core/src/memory/sources/readers/mod.rsindex 31def5281b..9a1ce4fd52 100644--- a/crates/openhuman-core/src/memory/sources/readers/mod.rs+++ b/crates/openhuman-core/src/memory/sources/readers/mod.rs@@ -1,89 +1,29 @@//! Source readers: the [`SourceReader`] trait plus one implementation per-//! [`SourceKind`].+//! [`SourceKind`], all of which live in [`tinymemory_sources::readers`].//!//! A reader knows how to *list* the items available in a source and *read* the-//! content of one item, so ingestion can be driven uniformly across kinds.+//! content of one item, so ingestion can be driven uniformly across kinds. The+//! trait takes the workspace directory as a `&Path` and reports+//! `tinymemory_api::error::MemoryError`; the RPC handlers that call it pass+//! `config.workspace_dir` and stringify the error.//!-//! # Why this is here and not reached through the engine (#5560)-//!-//! It was `tinymemory_core::sources::readers`, re-exported by a glob. Five of-//! the seven readers were already adapters over-//! [`tinymemory_sources::readers`], which this crate now depends on directly;-//! the other two — `composio` and `twitter` — were implemented in the engine-//! crate but named nothing engine-shaped, so they came home as they were.-//!-//! # The trait takes a `&Config`, the crate's takes a `&Path`-//!-//! [`tinymemory_sources::readers::SourceReader`] is deliberately narrower: it-//! takes `workspace: &std::path::Path` and knows nothing about OpenHuman's-//! configuration. This trait is the product-shaped one every host call site-//! already names, so the adapters below are where a `&Config` becomes the-//! workspace path the crate wants. That is the whole of the difference.-//!-//! # `reader_for` hands out network readers, and that is a real decision+//! # `reader_for_request` hands out network readers, and that is a real decision//!//! [`tinymemory_sources::readers::reader_for`] returns `None` for the network-//! kinds **on purpose**. Its docs are explicit: a network reader is meant to be-//! "constructed explicitly by a caller that has already decided the fetch is-//! allowed; it is never handed out by the kind-dispatch that the workspace sync-//! loop drives on a timer", which is what keeps the host in charge of egress,-//! OAuth and cost budgeting.-//!-//! This [`reader_for`] hands out all seven, matching the engine's, because the-//! callers here are RPC handlers acting on an explicit user request — a-//! `memory_sources_*` call naming one source id — and not a timer. **Do not-//! reuse it from a polling loop.** If one ever needs a reader, it should reach-//! for the local kinds through the crate's dispatch and construct a network-//! reader deliberately, so the decision stays visible.--pub mod composio;-pub mod conversation;-pub mod folder;-pub mod github;-pub mod rss;-pub mod twitter;-pub mod web_page;--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--/// A reader that can list items and read content from a memory source.-#[async_trait]-pub trait SourceReader: Send + Sync {- /// The [`SourceKind`] this reader serves.- fn kind(&self) -> SourceKind;-- /// List the items currently available in `source`.- async fn list_items(- &self,- source: &MemorySourceEntry,- config: &Config,- ) -> Result<Vec<SourceItem>, String>;-- /// Read the content of a single item by its reader-scoped `item_id`.- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- config: &Config,- ) -> Result<SourceContent, String>;-}+//! kinds **on purpose**: a network reader is meant to be "constructed+//! explicitly by a caller that has already decided the fetch is allowed; it is+//! never handed out by the kind-dispatch that the workspace sync loop drives on+//! a timer", which is what keeps the host in charge of egress, OAuth and cost+//! budgeting.+//!+//! [`reader_for_request`] hands out all seven, because the callers here are RPC+//! handlers acting on an explicit user request — a `memory_sources_*` call+//! naming one source id — and not a timer. **Do not reuse it from a polling+//! loop.** If one ever needs a reader, it should reach for the local kinds+//! through the crate's dispatch and construct a network reader deliberately, so+//! the decision stays visible.-/// Get the reader for a given source kind.-///-/// Read the module docs before calling this from anything that is not-/// servicing an explicit user request: it hands out the network readers.-#[must_use]-pub fn reader_for(kind: &SourceKind) -> Box<dyn SourceReader> {- match kind {- SourceKind::Composio => Box::new(composio::ComposioReader),- SourceKind::Conversation => Box::new(conversation::ConversationReader),- SourceKind::Folder => Box::new(folder::FolderReader),- SourceKind::GithubRepo => Box::new(github::GithubReader),- SourceKind::TwitterQuery => Box::new(twitter::TwitterReader),- SourceKind::RssFeed => Box::new(rss::RssReader::new()),- SourceKind::WebPage => Box::new(web_page::WebPageReader),- }-}+pub use tinymemory_sources::readers::{+ composio, conversation, folder, github, reader_for_request, rss, twitter, web_page,+ SourceReader,+};diff --git a/crates/openhuman-core/src/memory/sources/readers/rss.rs b/crates/openhuman-core/src/memory/sources/readers/rss.rsdeleted file mode 100644index 098d83fa22..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/rss.rs+++ /dev/null@@ -1,71 +0,0 @@-//! Product `Config` adapter for the engine-neutral `rss` reader.--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::readers::SourceReader;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--/// Reads `rss_feed` sources by delegating to-/// [`tinymemory_sources::readers::rss`].-///-/// The inner reader caches a freshly fetched feed between `list_items` and-/// `read_item`, so constructing it per trait call would turn one sync into N+1-/// downloads. That is why this one owns its delegate where the others are-/// unit structs.-pub struct RssReader {- inner: tinymemory_sources::readers::rss::RssReader,-}--impl RssReader {- /// Build a reader with an empty feed cache.- #[must_use]- pub fn new() -> Self {- Self {- inner: tinymemory_sources::readers::rss::RssReader::new(),- }- }-}--impl Default for RssReader {- fn default() -> Self {- Self::new()- }-}--#[async_trait]-impl SourceReader for RssReader {- fn kind(&self) -> SourceKind {- SourceKind::RssFeed- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- config: &Config,- ) -> Result<Vec<SourceItem>, String> {- tinymemory_sources::readers::SourceReader::list_items(- &self.inner,- source,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- config: &Config,- ) -> Result<SourceContent, String> {- tinymemory_sources::readers::SourceReader::read_item(- &self.inner,- source,- item_id,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-}diff --git a/crates/openhuman-core/src/memory/sources/readers/twitter.rs b/crates/openhuman-core/src/memory/sources/readers/twitter.rsdeleted file mode 100644index 2f596a5a9b..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/twitter.rs+++ /dev/null@@ -1,75 +0,0 @@-//! Twitter/X query source reader.-//!-//! Fetches tweets matching a search query. Uses the Twitter API v2-//! search endpoint. Requires bearer token configuration (not yet-//! wired — this reader validates the source config and returns a-//! clear error when no credentials are available).--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--use crate::memory::sources::readers::SourceReader;--const DEFAULT_SINCE_DAYS: u32 = 7;--/// Reads `twitter_query` sources.-///-/// Unimplemented: the Twitter API v2 search endpoint needs a bearer token and-/// that credential wiring has not landed, so both methods validate the source-/// and return an error naming what is missing.-pub struct TwitterReader;--#[async_trait]-impl SourceReader for TwitterReader {- fn kind(&self) -> SourceKind {- SourceKind::TwitterQuery- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- _config: &Config,- ) -> Result<Vec<SourceItem>, String> {- let query = source- .query- .as_deref()- .map(str::trim)- .filter(|q| !q.is_empty())- .ok_or("twitter source requires a non-empty query")?;- let _since_days = source.since_days.unwrap_or(DEFAULT_SINCE_DAYS);-- tracing::debug!(- query = %query,- "[memory_sources:twitter] list_items"- );-- // Twitter API v2 requires a bearer token. For now, return an- // informative error until credential wiring lands.- Err(format!(- "Twitter API integration not yet configured. Query '{query}' is saved and will \- sync once a Twitter bearer token is provided in settings."- ))- }-- async fn read_item(- &self,- _source: &MemorySourceEntry,- item_id: &str,- _config: &Config,- ) -> Result<SourceContent, String> {- tracing::debug!(- item_id = %item_id,- "[memory_sources:twitter] read_item"- );-- Err("Twitter API integration not yet configured. \- Individual tweet reading requires a bearer token."- .to_string())- }-}--#[cfg(test)]-#[path = "twitter_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/memory/sources/readers/twitter_tests.rs b/crates/openhuman-core/src/memory/sources/readers/twitter_tests.rsdeleted file mode 100644index 0d0e392774..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/twitter_tests.rs+++ /dev/null@@ -1,39 +0,0 @@-//! Tests for the surrounding module.--use super::*;--fn twitter_source() -> MemorySourceEntry {- MemorySourceEntry {- id: "src_tw".into(),- kind: SourceKind::TwitterQuery,- label: "AI tweets".into(),- enabled: true,- toolkit: None,- connection_id: None,- path: None,- glob: None,- url: None,- branch: None,- paths: Vec::new(),- query: Some("AI safety".into()),- since_days: Some(3),- max_items: None,- max_commits: None,- max_issues: None,- max_prs: None,- selector: None,- max_tokens_per_sync: None,- max_cost_per_sync_usd: None,- sync_depth_days: None,- }-}--#[tokio::test]-async fn list_items_returns_not_configured_error() {- let reader = TwitterReader;- let result = reader- .list_items(&twitter_source(), &Config::default())- .await;- assert!(result.is_err());- assert!(result.unwrap_err().contains("not yet configured"));-}diff --git a/crates/openhuman-core/src/memory/sources/readers/web_page.rs b/crates/openhuman-core/src/memory/sources/readers/web_page.rsdeleted file mode 100644index a9b7230052..0000000000--- a/crates/openhuman-core/src/memory/sources/readers/web_page.rs+++ /dev/null@@ -1,47 +0,0 @@-//! Product `Config` adapter for the engine-neutral `web_page` reader.--use async_trait::async_trait;--use crate::config::Config;-use crate::memory::sources::readers::SourceReader;-use crate::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};--/// Reads `web_page` sources by delegating to [`tinymemory_sources::readers::web_page`].-pub struct WebPageReader;--#[async_trait]-impl SourceReader for WebPageReader {- fn kind(&self) -> SourceKind {- SourceKind::WebPage- }-- async fn list_items(- &self,- source: &MemorySourceEntry,- config: &Config,- ) -> Result<Vec<SourceItem>, String> {- tinymemory_sources::readers::SourceReader::list_items(- &tinymemory_sources::readers::web_page::WebPageReader,- source,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-- async fn read_item(- &self,- source: &MemorySourceEntry,- item_id: &str,- config: &Config,- ) -> Result<SourceContent, String> {- tinymemory_sources::readers::SourceReader::read_item(- &tinymemory_sources::readers::web_page::WebPageReader,- source,- item_id,- &config.workspace_dir,- )- .await- .map_err(|error| error.to_string())- }-}diff --git a/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs b/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rsindex e81d6c13ef..4050de283e 100644--- a/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs+++ b/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs@@ -115,8 +115,11 @@ pub async fn estimate_sync_cost_rpc(return Err(unserved(&binding, "source sync", "estimate_sync_cost"));};- let reader = readers::reader_for(&source.kind);- let items = reader.list_items(&source, &config).await?;+ let reader = readers::reader_for_request(&source.kind);+ let items = reader+ .list_items(&source, &config.workspace_dir)+ .await+ .map_err(|error| error.to_string())?;let item_count = items.len() as u32;// estimated_tokens includes both input (500/item) and output (100/item)diff --git a/crates/openhuman-core/src/memory/sources/rpc/registry_crud.rs b/crates/openhuman-core/src/memory/sources/rpc/registry_crud.rsindex c5a0bfdf9b..b831c8702a 100644--- a/crates/openhuman-core/src/memory/sources/rpc/registry_crud.rs+++ b/crates/openhuman-core/src/memory/sources/rpc/registry_crud.rs@@ -254,8 +254,11 @@ pub async fn list_items_rpc(req: ListItemsRequest) -> Result<Outcome<ListItemsRe.ok_or_else(|| format!("source '{}' not found", req.source_id))?;let config = config_rpc::load_config_with_timeout().await?;- let reader = readers::reader_for(&source.kind);- let items = reader.list_items(&source, &config).await?;+ let reader = readers::reader_for_request(&source.kind);+ let items = reader+ .list_items(&source, &config.workspace_dir)+ .await+ .map_err(|error| error.to_string())?;Ok(Outcome::new(ListItemsResponse { items }, vec![]))}@@ -285,8 +288,11 @@ pub async fn read_item_rpc(req: ReadItemRequest) -> Result<Outcome<ReadItemRespo.ok_or_else(|| format!("source '{}' not found", req.source_id))?;let config = config_rpc::load_config_with_timeout().await?;- let reader = readers::reader_for(&source.kind);- let content = reader.read_item(&source, &req.item_id, &config).await?;+ let reader = readers::reader_for_request(&source.kind);+ let content = reader+ .read_item(&source, &req.item_id, &config.workspace_dir)+ .await+ .map_err(|error| error.to_string())?;Ok(Outcome::new(ReadItemResponse { content }, vec![]))}