Skip to content

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

refactor(memory): update memory module imports and types

Steven Enamakel22d9f29b8a60
diff --git a/crates/openhuman-core/src/agent/prompts/flow_archetype.rs b/crates/openhuman-core/src/agent/prompts/flow_archetype.rs
index 52ccd79986..0d8134377b 100644
--- a/crates/openhuman-core/src/agent/prompts/flow_archetype.rs
+++ b/crates/openhuman-core/src/agent/prompts/flow_archetype.rs
@@ -3,7 +3,7 @@
use anyhow::{anyhow, ensure, Result};
use tinyagents_definition::PromptSource;
-use crate::{agent::harness::host_definition::AgentDefinition, config::Config};
+use crate::{agent_registry::host_definition::AgentDefinition, config::Config};
/// Whether `definition` is one of the bus-backed builtin flow prompt owners.
///
diff --git a/crates/openhuman-core/src/agent_registry/agents/flow_discovery/prompt_tests.rs b/crates/openhuman-core/src/agent_registry/agents/flow_discovery/prompt_tests.rs
index 98d3ca84ac..39235b6d65 100644
--- a/crates/openhuman-core/src/agent_registry/agents/flow_discovery/prompt_tests.rs
+++ b/crates/openhuman-core/src/agent_registry/agents/flow_discovery/prompt_tests.rs
@@ -33,7 +33,7 @@ async fn module_prompt_teaches_the_read_only_emit_invariant() {
workspace_dir: workspace.path().to_path_buf(),
..crate::config::Config::default()
};
- let registry = crate::agent::harness::host_definition::AgentDefinitionRegistry::builtins_only();
+ let registry = crate::agent_registry::host_definition::AgentDefinitionRegistry::builtins_only();
let definition = registry
.get("flow_discovery")
.expect("flow_discovery builtin");
diff --git a/crates/openhuman-core/src/memory/error.rs b/crates/openhuman-core/src/memory/error.rs
index 6c0d4f95b4..6b65801879 100644
--- a/crates/openhuman-core/src/memory/error.rs
+++ b/crates/openhuman-core/src/memory/error.rs
@@ -114,7 +114,7 @@ impl From<tinymemory_api::Error> for MemoryError {
fn from(error: tinymemory_api::Error) -> Self {
use tinymemory_api::Error as E;
// A 402 arrives as `Engine` with the backend's code on its message.
- let credits = tinymemory_integrations::cortex::is_insufficient_credits(&error);
+ let credits = tinymemory_integrations::import::is_insufficient_credits(&error);
match error {
E::Unsupported(message) => Self::Unsupported(message),
E::InvalidRequest(message) | E::NotFound(message) => Self::InvalidRequest(message),
diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host.rs b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
index ab7c59eed8..275e6d9f16 100644
--- a/crates/openhuman-core/src/memory/layout_migration/app_host.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
@@ -127,7 +127,7 @@ impl lm::LayoutHost for AppHost {
/// The claim on the legacy tree `config`'s account would move, if it is
/// shared by every account on the machine.
-pub(super) fn claim_key(config: &Config) -> Result<Option<ClaimKey>> {
+pub(super) fn claim_key(config: &Config) -> MemoryResult<Option<ClaimKey>> {
// A self-hosted key is the operator's: every local account using it
// shares one legacy tree. The hosted engine is one tenant per person.
if config.memory.engine.trim() != CORTEXDB_ENGINE {
@@ -147,12 +147,12 @@ pub(super) fn claim_key(config: &Config) -> Result<Option<ClaimKey>> {
Ok(Some(ClaimKey::new(app_dir, &endpoint, &owner)))
}
-fn signed_in_root(config: &Config) -> Result<String> {
+fn signed_in_root(config: &Config) -> MemoryResult<String> {
scope::user_root(config).ok_or_else(signed_out)
}
-fn signed_out() -> Error {
- Error::Off("sign in to move memory into its own layout".to_string())
+fn signed_out() -> MemoryError {
+ MemoryError::Off("sign in to move memory into its own layout".to_string())
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/memory/lifecycle/date_hint.rs b/crates/openhuman-core/src/memory/lifecycle/date_hint.rs
index 3af9057dbf..b5200d266e 100644
--- a/crates/openhuman-core/src/memory/lifecycle/date_hint.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/date_hint.rs
@@ -39,7 +39,7 @@ impl DateHintModel for HostDateHintModel {
};
let system = format!(
"{}\n\n{instruction}",
- crate::agent::prompts::current_datetime_line(Some(&zone))
+ crate::prompts::current_datetime_line(Some(&zone))
);
let mut request = tinyinference_llm::model::ModelRequest::new(vec![
tinyinference_llm::message::Message::system(system),
diff --git a/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs b/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs
index 9557d8b07e..fab711a40c 100644
--- a/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/session_hooks.rs
@@ -42,8 +42,8 @@ pub(super) struct PendingMemoryTurn {
/// The provider channel that owns a logged conversation, if this turn came
/// from an external channel. Event-context labels such as `cron`, `voice`, and
/// `mcp_server` are not channel owners.
-fn logged_channel(origin: Option<&crate::agent::turn_origin::AgentTurnOrigin>) -> Option<String> {
- let Some(crate::agent::turn_origin::AgentTurnOrigin::ExternalChannel {
+fn logged_channel(origin: Option<&crate::security::turn_origin::AgentTurnOrigin>) -> Option<String> {
+ let Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel {
channel,
message_id,
..
diff --git a/crates/openhuman-core/src/memory/scope.rs b/crates/openhuman-core/src/memory/scope.rs
index 0fbd61f82a..4b4a48cfd3 100644
--- a/crates/openhuman-core/src/memory/scope.rs
+++ b/crates/openhuman-core/src/memory/scope.rs
@@ -4,7 +4,9 @@
use std::collections::HashMap;
use tinymemory_api::{Error, Result};
-use tinymemory_tools::layout::identity::{self, AgentPin, IdentityPins};
+use tinymemory_tools::layout::identity::{
+ self, AgentPin, Identity as TinyMemoryIdentity, IdentityPins, ResolvedIdentity,
+};
use crate::config::{Config, MemoryLayoutMode};
@@ -34,6 +36,51 @@ pub fn identity_pins(config: &Config) -> IdentityPins {
}
}
+/// OpenHuman's identity bound to the memory settings of a config.
+///
+/// TinyMemory owns identity precedence and layout resolution; this adapter
+/// supplies the current config's host pins to that public contract.
+#[derive(Debug, Clone, Default)]
+pub struct MemoryIdentity(TinyMemoryIdentity);
+
+impl MemoryIdentity {
+ /// The host-owned memory identity used by RPC and MCP surfaces.
+ #[must_use]
+ pub fn root() -> Self {
+ Self(TinyMemoryIdentity::root())
+ }
+
+ /// An agent definition's memory identity.
+ #[must_use]
+ pub fn agent(agent_id: &str) -> Self {
+ Self(TinyMemoryIdentity::agent(agent_id))
+ }
+
+ /// A team member's memory identity.
+ #[must_use]
+ pub fn team_member(team: &str, agent_id: &str) -> Self {
+ Self(TinyMemoryIdentity::team_member(team, agent_id))
+ }
+
+ /// Resolve this identity with OpenHuman's current host pins.
+ #[must_use]
+ pub fn resolve(&self, config: &Config) -> ResolvedIdentity {
+ self.0.resolve(&identity_pins(config))
+ }
+}
+
+/// The pooled conversation node for a resolved TinyMemory layout.
+#[must_use]
+pub fn chat_node(layout: &tinymemory_tools::MemoryLayout) -> tinymemory_api::Namespace {
+ tinymemory_tools::chat_node(layout)
+}
+
+/// Whether OpenHuman's memory configuration selects layout v3.
+#[must_use]
+pub fn layout_is_v3(config: &Config) -> bool {
+ identity_pins(config).v3
+}
+
/// The engine scope root of the person `config` belongs to: `org:<id>` for a
/// TinyHumans account, or the recorded local install root. Before sign-in,
/// there is no user root.
diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rs
index e3dc4f7734..92228d5f04 100644
--- a/crates/openhuman-core/src/memory/types.rs
+++ b/crates/openhuman-core/src/memory/types.rs
@@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use tinymemory_api::{
Citation, EngineDescriptor, FetchMode, Hit, LearningKind, MemoryMeta, MetaFilter,
};
-use tinymemory_integrations::import::ImportState;
+pub use tinymemory_integrations::import::{ImportPhase, ImportState};
use tinymemory_integrations::sources::SourceStatus;
use crate::config::schema::MemorySourceKind;