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): add memory schema and operation modules
Steven Enamakel6156c2f4dcbb
diff --git a/crates/openhuman-core/src/memory/ops/mod.rs b/crates/openhuman-core/src/memory/ops/mod.rsindex 0dba05e841..4cff527735 100644--- a/crates/openhuman-core/src/memory/ops/mod.rs+++ b/crates/openhuman-core/src/memory/ops/mod.rs@@ -24,6 +24,8 @@//! - [`files`] — `ai_*_memory_file` handlers (use `tokio::fs`).pub mod documents;+pub mod engine;+pub mod engine_migrate;pub mod envelope;pub mod files;pub mod guard;@@ -57,6 +59,13 @@ pub use kv_graph::{GraphUpsertParams, KvGetDeleteParams, KvSetParams,};pub use learn::{memory_learn_all, LearnAllParams, LearnAllResult, NamespaceLearnResult};+pub use engine::{+ memory_engine_get, memory_engine_set, memory_engines_list, EngineState, EngineTargetParams,+ EnginesList,+};+pub use engine_migrate::{+ memory_engine_migrate, memory_engine_migrate_status, MigrateParams, MigrateStatusParams,+};pub use provider::{memory_provider_status, memory_subsystem_status};pub use sync::{memory_ingestion_status, memory_scheduler_override, memory_sync_all, memory_sync_channel,diff --git a/crates/openhuman-core/src/memory/schemas/engine.rs b/crates/openhuman-core/src/memory/schemas/engine.rsnew file mode 100644index 0000000000..a8a85b0aff--- /dev/null+++ b/crates/openhuman-core/src/memory/schemas/engine.rs@@ -0,0 +1,185 @@+//! Schemas and handlers for the memory-engine RPCs: `engines_list`,+//! `engine_get`, `engine_set`, `engine_migrate`, `engine_migrate_status`.+//!+//! Registered with the provider family, which is never capability-gated:+//! switching engines must stay possible whatever the current engine advertises.++use serde_json::{Map, Value};++use crate::core::all::{ControllerFuture, RegisteredController};+use crate::core::{ControllerSchema, FieldSchema, TypeSchema};+use crate::memory::rpc::{+ self, EngineTargetParams, MigrateParams, MigrateStatusParams,+};++use super::{parse_params, to_json};++pub(super) const FUNCTIONS: &[&str] = &[+ "engines_list",+ "engine_get",+ "engine_set",+ "engine_migrate",+ "engine_migrate_status",+];++pub(super) fn controllers() -> Vec<RegisteredController> {+ vec![+ RegisteredController {+ schema: schema("engines_list").unwrap(),+ handler: handle_engines_list,+ },+ RegisteredController {+ schema: schema("engine_get").unwrap(),+ handler: handle_engine_get,+ },+ RegisteredController {+ schema: schema("engine_set").unwrap(),+ handler: handle_engine_set,+ },+ RegisteredController {+ schema: schema("engine_migrate").unwrap(),+ handler: handle_engine_migrate,+ },+ RegisteredController {+ schema: schema("engine_migrate_status").unwrap(),+ handler: handle_engine_migrate_status,+ },+ ]+}++fn field(name: &'static str, ty: TypeSchema, comment: &'static str, required: bool) -> FieldSchema {+ FieldSchema {+ name,+ ty,+ comment,+ required,+ }+}++fn opt_string() -> TypeSchema {+ TypeSchema::Option(Box::new(TypeSchema::String))+}++fn target_inputs() -> Vec<FieldSchema> {+ vec![+ field(+ "driver",+ TypeSchema::String,+ "Engine id from engines_list (tinymemory, tinyhumans, supermemory, mem0, cognee, cortex, agentmemory).",+ true,+ ),+ field(+ "endpoint",+ opt_string(),+ "Base URL for engines that take one. Ignored for tinyhumans.",+ false,+ ),+ field(+ "deployment",+ opt_string(),+ "cloud | self_hosted, for engines with more than one deployment.",+ false,+ ),+ field(+ "api_key",+ opt_string(),+ "API key. Stored in the OS keychain, never in config, and never returned.",+ false,+ ),+ ]+}++fn state_outputs() -> Vec<FieldSchema> {+ vec![+ field("driver", TypeSchema::String, "Bound engine id (null after a fallback).", true),+ field("endpoint", opt_string(), "Endpoint in use, when the engine has one.", false),+ field("deployment", opt_string(), "Deployment in use, when the engine has several.", false),+ field("has_credential", TypeSchema::Bool, "Whether a credential is available. The credential itself is never returned.", true),+ field("class", TypeSchema::String, "How the engine is bound: module | external | null.", true),+ field("fell_back_from", opt_string(), "The engine that was asked for and refused, when this is a fallback.", false),+ field("last_error", opt_string(), "Why the fallback happened; null when clean.", false),+ ]+}++pub(super) fn schema(function: &str) -> Option<ControllerSchema> {+ Some(match function {+ "engines_list" => ControllerSchema {+ namespace: "memory",+ function: "engines_list",+ description: "The memory engines this build offers, and which one is active.",+ inputs: vec![],+ outputs: vec![+ field("engines", TypeSchema::Array(Box::new(TypeSchema::Json)), "Engine descriptors: id, label, description, needs_endpoint, needs_key, key_optional, deployments, default_endpoint, hosted, capabilities.", true),+ field("active", TypeSchema::String, "Id of the bound engine.", true),+ ],+ },+ "engine_get" => ControllerSchema {+ namespace: "memory",+ function: "engine_get",+ description: "The active memory engine's configuration and binding state. Never returns a secret.",+ inputs: vec![],+ outputs: state_outputs(),+ },+ "engine_set" => ControllerSchema {+ namespace: "memory",+ function: "engine_set",+ description: "Switch the memory engine. Stores the key in the keychain, writes [subsystems.memory], and rebinds without a restart. Existing memories are not copied; use engine_migrate for that.",+ inputs: target_inputs(),+ outputs: state_outputs(),+ },+ "engine_migrate" => ControllerSchema {+ namespace: "memory",+ function: "engine_migrate",+ description: "Copy every memory from the active engine into another, then switch to it. Returns a job id; poll engine_migrate_status.",+ inputs: vec![field(+ "to",+ TypeSchema::Json,+ "The target engine: { driver, endpoint?, deployment?, api_key? }.",+ true,+ )],+ outputs: vec![field("job_id", TypeSchema::String, "Migration job id.", true)],+ },+ "engine_migrate_status" => ControllerSchema {+ namespace: "memory",+ function: "engine_migrate_status",+ description: "Progress of an engine migration job.",+ inputs: vec![field("job_id", TypeSchema::String, "Id returned by engine_migrate.", true)],+ outputs: vec![+ field("state", TypeSchema::String, "running | done | failed.", true),+ field("copied", TypeSchema::U64, "Records copied so far.", true),+ field("total", TypeSchema::Option(Box::new(TypeSchema::U64)), "Total records when known; null otherwise.", false),+ field("error", opt_string(), "Failure reason; null unless failed.", false),+ ],+ },+ _ => return None,+ })+}++fn handle_engines_list(_params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move { to_json(rpc::memory_engines_list().await?) })+}++fn handle_engine_get(_params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move { to_json(rpc::memory_engine_get().await?) })+}++fn handle_engine_set(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let payload = parse_params::<EngineTargetParams>(params)?;+ to_json(rpc::memory_engine_set(payload).await?)+ })+}++fn handle_engine_migrate(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let payload = parse_params::<MigrateParams>(params)?;+ to_json(rpc::memory_engine_migrate(payload).await?)+ })+}++fn handle_engine_migrate_status(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let payload = parse_params::<MigrateStatusParams>(params)?;+ to_json(rpc::memory_engine_migrate_status(payload).await?)+ })+}diff --git a/crates/openhuman-core/src/memory/schemas/mod.rs b/crates/openhuman-core/src/memory/schemas/mod.rsindex 8c526ce41e..89e36b8422 100644--- a/crates/openhuman-core/src/memory/schemas/mod.rs+++ b/crates/openhuman-core/src/memory/schemas/mod.rs@@ -13,7 +13,9 @@//! - [`kv_graph`] — key-value and knowledge-graph schemas + handlers.//! - [`sync`] — `sync_channel`, `sync_all`, `ingestion_status`.//! - [`learn`] — `learn_all`.-//! - [`provider`] — `provider_status` (the bound memory driver).+//! - [`provider`] — `provider_status` (the bound memory driver) and the+//! [`engine`] selector RPCs (`engines_list`, `engine_get`, `engine_set`,+//! `engine_migrate`, `engine_migrate_status`).//! - [`files`] — file-based memory schemas + handlers.//! - [`tool_memory`] — tool-scoped memory rules (#1400).//!@@ -32,6 +34,7 @@ use crate::core::{ControllerSchema, FieldSchema, TypeSchema};use crate::rpc::RpcOutcome;mod documents;+mod engine;mod files;mod kv_graph;mod learn;diff --git a/crates/openhuman-core/src/memory/schemas/provider.rs b/crates/openhuman-core/src/memory/schemas/provider.rsindex a2c8fe26a2..2adce1b6b8 100644--- a/crates/openhuman-core/src/memory/schemas/provider.rs+++ b/crates/openhuman-core/src/memory/schemas/provider.rs@@ -7,15 +7,25 @@ use crate::core::all::{ControllerFuture, RegisteredController};use crate::core::{ControllerSchema, FieldSchema, TypeSchema};use crate::memory::rpc;-use super::to_json;+use super::{engine, to_json};-pub(super) const FUNCTIONS: &[&str] = &["provider_status"];+pub(super) const FUNCTIONS: &[&str] = &[+ "provider_status",+ "engines_list",+ "engine_get",+ "engine_set",+ "engine_migrate",+ "engine_migrate_status",+];pub(super) fn controllers() -> Vec<RegisteredController> {- vec![RegisteredController {+ let mut controllers = vec![RegisteredController {schema: schema("provider_status").unwrap(),handler: handle_provider_status,- }]+ }];+ // The engine selector rides with the status RPC: same never-gated rule.+ controllers.extend(engine::controllers());+ controllers}pub(super) fn schema(function: &str) -> Option<ControllerSchema> {@@ -82,7 +92,7 @@ pub(super) fn schema(function: &str) -> Option<ControllerSchema> {},],},- _ => return None,+ other => return engine::schema(other),})}