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(storage): extract session agent helpers into a submodule
Steven Enamakel89069647b27a
diff --git a/crates/openhuman-core/src/storage/import/sessions.rs b/crates/openhuman-core/src/storage/import/sessions.rsindex 7b3c90c9b7..223a5dcc3d 100644--- a/crates/openhuman-core/src/storage/import/sessions.rs+++ b/crates/openhuman-core/src/storage/import/sessions.rs@@ -47,6 +47,9 @@ use crate::config::Config;use crate::storage::sessions::DEFAULT_AGENT;use crate::storage::StorageBackend;+mod agents;+pub(super) use agents::{agent_of, known_agents};+/// The marker name of the session import.pub const SESSIONS_DOMAIN: &str = "sessions";@@ -619,53 +622,6 @@ fn replay_transcript(Ok(replayed)}-/// The agent definitions a stem may belong to, by the component their ids-/// encode to in a stem.-fn known_agents() -> HashMap<String, String> {- let mut ids: Vec<String> =- crate::agent_registry::host_definition::AgentDefinitionRegistry::builtins_only()- .list()- .iter()- .map(|def| def.id.clone())- .collect();- if let Some(current) =- crate::agent_registry::host_definition::AgentDefinitionRegistry::current()- {- ids.extend(current.list().iter().map(|def| def.id.clone()));- }- ids.sort();- ids.dedup();- ids.into_iter()- .filter_map(|id| agent_component(&id).map(|component| (component, id)))- .collect()-}--/// The text a stem carries for agent `id`: `session_stem` of a probe session,-/// without its session key. A stem is `<key>.<agent>[.g<n>]`, each component-/// sanitized (a `.` inside one becomes `-`) and followed by a digest, so the-/// agent's component is what follows the first `.`.-fn agent_component(id: &str) -> Option<String> {- let stem = session_stem(&SessionRef::scoped("probe", id));- stem.split_once('.').map(|(_, agent)| agent.to_owned())-}--/// The agent whose component `stem` carries, if it is one of `known`.-fn agent_of(stem: &str, known: &HashMap<String, String>) -> Option<String> {- // Sub-agent transcripts (`parent__child`) belong to their root's agent.- let root = stem.split("__").next().unwrap_or(stem);- let mut parts: Vec<&str> = root.split('.').collect();- if parts.last().is_some_and(|last| {- last.strip_prefix('g')- .is_some_and(|n| !n.is_empty() && n.chars().all(|c| c.is_ascii_digit()))- }) {- parts.pop();- }- if parts.len() < 2 {- return None;- }- known.get(*parts.last()?).cloned()-}-/// Every `*.jsonl` under `raw` (flat and date-grouped), flat winning a/// duplicate stem, as `(stem, path)`.fn transcript_files(raw: &Path) -> Result<Vec<(String, PathBuf)>> {diff --git a/crates/openhuman-core/src/storage/import/sessions/agents.rs b/crates/openhuman-core/src/storage/import/sessions/agents.rsnew file mode 100644index 0000000000..ffa3ce14d9--- /dev/null+++ b/crates/openhuman-core/src/storage/import/sessions/agents.rs@@ -0,0 +1,48 @@+use std::collections::HashMap;++use tinyagents_session::transcript::{session_stem, SessionRef};++/// The agent definitions a stem may belong to, by the component their ids+/// encode to in a stem.+pub(super) fn known_agents() -> HashMap<String, String> {+ let mut ids: Vec<String> =+ crate::agent_registry::host_definition::AgentDefinitionRegistry::builtins_only()+ .list()+ .iter()+ .map(|def| def.id.clone())+ .collect();+ if let Some(current) =+ crate::agent_registry::host_definition::AgentDefinitionRegistry::current()+ {+ ids.extend(current.list().iter().map(|def| def.id.clone()));+ }+ ids.sort();+ ids.dedup();+ ids.into_iter()+ .filter_map(|id| agent_component(&id).map(|component| (component, id)))+ .collect()+}++/// The text a stem carries for agent `id`: `session_stem` of a probe session,+/// without its session key.+fn agent_component(id: &str) -> Option<String> {+ let stem = session_stem(&SessionRef::scoped("probe", id));+ stem.split_once('.').map(|(_, agent)| agent.to_owned())+}++/// The agent whose component `stem` carries, if it is one of `known`.+pub(super) fn agent_of(stem: &str, known: &HashMap<String, String>) -> Option<String> {+ // Sub-agent transcripts (`parent__child`) belong to their root's agent.+ let root = stem.split("__").next().unwrap_or(stem);+ let mut parts: Vec<&str> = root.split('.').collect();+ if parts.last().is_some_and(|last| {+ last.strip_prefix('g')+ .is_some_and(|n| !n.is_empty() && n.chars().all(|c| c.is_ascii_digit()))+ }) {+ parts.pop();+ }+ if parts.len() < 2 {+ return None;+ }+ known.get(*parts.last()?).cloned()+}