Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(memory): add composio and twitter source readers

Steven Enamakel7daf6458797c
diff --git a/src/openhuman/memory/sources/readers/composio.rs b/src/openhuman/memory/sources/readers/composio.rs
new file mode 100644
index 0000000000..52e5f3fcd8
--- /dev/null
+++ b/src/openhuman/memory/sources/readers/composio.rs
@@ -0,0 +1,70 @@
+//! 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::openhuman::memory::sources::types::{
+ ContentType, MemorySourceEntry, SourceContent, SourceItem, SourceKind,
+};
+use crate::openhuman::config::Config;
+
+use crate::openhuman::memory::sources::readers::SourceReader;
+
+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/src/openhuman/memory/sources/readers/composio_tests.rs b/src/openhuman/memory/sources/readers/composio_tests.rs
new file mode 100644
index 0000000000..bb25ffe473
--- /dev/null
+++ b/src/openhuman/memory/sources/readers/composio_tests.rs
@@ -0,0 +1,39 @@
+//! Tests for the surrounding module.
+
+use super::*;
+use crate::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 = TestHostConfig::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/src/openhuman/memory/sources/readers/twitter.rs b/src/openhuman/memory/sources/readers/twitter.rs
new file mode 100644
index 0000000000..9c30c2612c
--- /dev/null
+++ b/src/openhuman/memory/sources/readers/twitter.rs
@@ -0,0 +1,70 @@
+//! 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::openhuman::memory::sources::types::{MemorySourceEntry, SourceContent, SourceItem, SourceKind};
+use crate::openhuman::config::Config;
+
+use crate::openhuman::memory::sources::readers::SourceReader;
+
+const DEFAULT_SINCE_DAYS: u32 = 7;
+
+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/src/openhuman/memory/sources/readers/twitter_tests.rs b/src/openhuman/memory/sources/readers/twitter_tests.rs
new file mode 100644
index 0000000000..15239bf71e
--- /dev/null
+++ b/src/openhuman/memory/sources/readers/twitter_tests.rs
@@ -0,0 +1,39 @@
+//! 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(), &TestHostConfig::default())
+ .await;
+ assert!(result.is_err());
+ assert!(result.unwrap_err().contains("not yet configured"));
+}