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
feat(memory): map a legacy per-type brain node to its connector
M3gA-Minda594c2b182e7
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rsindex cb0a71363b..d843ee102b 100644--- a/crates/openhuman-core/src/memory/brain.rs+++ b/crates/openhuman-core/src/memory/brain.rs@@ -53,6 +53,39 @@ pub fn brain_source(kind: MemorySourceKind, target: &str) -> BrainSource {}}+/// The brain source a document filed under the old per-type layout belongs+/// to now, for the migration that moves it: `old_source_id` is the id of+/// the `source:<id>` node it sits at, `item` the document itself.+///+/// - Per-format nodes (`pdf`, `markdown`, `docx`, `xlsx`, `pptx`, `code`,+/// `other`) held local files: `files`.+/// - `web` held links and feeds, but also HTML files from a folder or an+/// upload; a document with a file kind or a file path is a file.+/// - Any other node was a connector: its canonical slug (`google_drive`+/// becomes `googledrive`), so `notion`, `github` and `gmail` stay put.+#[must_use]+pub fn legacy_brain_node(old_source_id: &str, item: &StoreItem) -> BrainSource {+ let id = crate::integrations::composio::tools::canonicalize_toolkit_slug(old_source_id);+ match id.as_str() {+ "files" | "pdf" | "markdown" | "md" | "docx" | "xlsx" | "pptx" | "code" | "other" => {+ files_source()+ }+ "web" => {+ let meta = item.meta();+ let file = matches!(+ meta.source.kind,+ tinymemory_api::SourceKind::File | tinymemory_api::SourceKind::Folder+ ) || meta.file_path.is_some();+ if file {+ files_source()+ } else {+ BrainSource::Web+ }+ }+ _ => id.parse().unwrap_or_else(|_| files_source()),+ }+}+/// `item` placed in `layout`'s brain under `source`: the source's node, and/// no agent id (the brain belongs to every agent).pub fn file_into(diff --git a/crates/openhuman-core/src/memory/brain_tests.rs b/crates/openhuman-core/src/memory/brain_tests.rsindex 154a7af44c..5956f7db52 100644--- a/crates/openhuman-core/src/memory/brain_tests.rs+++ b/crates/openhuman-core/src/memory/brain_tests.rs@@ -45,6 +45,52 @@ fn synced_items_are_filed_by_their_connector() {assert_eq!(files_source().to_string(), "files");}+#[test]+fn legacy_nodes_map_to_their_connector() {+ use tinymemory_api::{SourceKind, SourceRef};+ let item = |kind: SourceKind, path: Option<&str>| {+ let mut item = document(None, path);+ item.meta_mut().source = SourceRef { kind, id: None };+ item+ };+ let link = item(SourceKind::Link, None);+ for old in [+ "pdf", "markdown", "md", "docx", "xlsx", "pptx", "code", "other", "files",+ ] {+ assert_eq!(legacy_brain_node(old, &link), files_source(), "{old}");+ }+ // `web` held links and feeds, and HTML files that were filed beside them.+ assert_eq!(legacy_brain_node("web", &link), BrainSource::Web);+ assert_eq!(+ legacy_brain_node("web", &item(SourceKind::Rss, None)),+ BrainSource::Web+ );+ assert_eq!(+ legacy_brain_node("web", &item(SourceKind::Folder, None)),+ files_source()+ );+ assert_eq!(+ legacy_brain_node("web", &item(SourceKind::File, None)),+ files_source()+ );+ // An upload carried the `Link` kind `web` implies, but kept its path.+ assert_eq!(+ legacy_brain_node("web", &item(SourceKind::Link, Some("/u/pricing.html"))),+ files_source()+ );+ // Connectors keep their node, under the slug Composio uses.+ assert_eq!(legacy_brain_node("notion", &link), BrainSource::Notion);+ assert_eq!(legacy_brain_node("github", &link), BrainSource::Github);+ assert_eq!(+ legacy_brain_node("gmail", &link),+ BrainSource::Other("gmail".into())+ );+ assert_eq!(+ legacy_brain_node("google_drive", &link),+ BrainSource::Other("googledrive".into())+ );+}+#[test]fn filing_moves_an_item_to_its_source_node_without_an_agent() {let team = MemoryLayout::new("team:acme".parse().unwrap()).unwrap();