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 schema definitions and handler infrastructure
Steven Enamakeld5a23ad74d15
diff --git a/crates/openhuman-core/src/memory/mod.rs b/crates/openhuman-core/src/memory/mod.rsindex c852cba706..f39a0815fd 100644--- a/crates/openhuman-core/src/memory/mod.rs+++ b/crates/openhuman-core/src/memory/mod.rs@@ -21,6 +21,7 @@ pub mod conversations;pub mod engine;pub mod error;pub mod exit;+pub mod explore;pub mod import;pub mod ops;pub mod schemas;diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex bd8cd7696b..b9db3817e0 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -317,7 +317,7 @@ pub async fn forget(config: &Config, params: ForgetParams) -> MemoryResult<Forgepub async fn items_list(config: &Config, params: ItemsListParams) -> MemoryResult<ItemsListView> {let bound = bound(config)?;let request = ListRequest {- filter: params.filter.unwrap_or_default(),+ filter: super::explore::narrowed(params.filter, ¶ms.path)?,limit: clamp_limit(params.limit),cursor: params.cursor,};diff --git a/crates/openhuman-core/src/memory/schemas.rs b/crates/openhuman-core/src/memory/schemas.rsindex a892aac48b..034fa5ae5b 100644--- a/crates/openhuman-core/src/memory/schemas.rs+++ b/crates/openhuman-core/src/memory/schemas.rs@@ -36,6 +36,8 @@ fn handler_for(function: &str) -> crate::core::all::ControllerHandler {"learn" => handlers::learn,"forget" => handlers::forget,"items_list" => handlers::items_list,+ "explore" => handlers::explore,+ "items_get" => handlers::items_get,"conversations_get" => handlers::conversations_get,"conversations_set" => handlers::conversations_set,"sources_list" => handlers::sources_list,diff --git a/crates/openhuman-core/src/memory/schemas/defs.rs b/crates/openhuman-core/src/memory/schemas/defs.rsindex a4273bf071..4d948397bf 100644--- a/crates/openhuman-core/src/memory/schemas/defs.rs+++ b/crates/openhuman-core/src/memory/schemas/defs.rs@@ -13,6 +13,8 @@ pub const FUNCTIONS: [&str; 20] = ["learn","forget","items_list",+ "explore",+ "items_get","conversations_get","conversations_set","sources_list",@@ -68,6 +70,14 @@ fn filter() -> FieldSchema {)}+fn path() -> FieldSchema {+ opt(+ "path",+ TypeSchema::Json,+ "Explorer path: [{facet, value}], each step narrowing the items (see memory_explore).",+ )+}+fn cursor() -> FieldSchema {opt("cursor",@@ -148,9 +158,29 @@ pub fn schema(function: &str) -> ControllerSchema {namespace: "memory",function: "items_list",description: "Page through stored items, newest first.",- inputs: vec![filter(), limit(), cursor()],+ inputs: vec![filter(), limit(), cursor(), path()],outputs: out("{items: Hit[], next_cursor?}"),},+ "explore" => ControllerSchema {+ namespace: "memory",+ function: "explore",+ description: "Count stored items per value of one facet (kind, source, source_id, workspace, folder, file_path, language, repo, url, thread, agent, tool_call, tag), under an explorer path.",+ inputs: vec![+ req("facet", TypeSchema::String, "The facet to group by."),+ path(),+ filter(),+ opt("limit", TypeSchema::BoundedU64 { min: 1, max: 500 }, "Most buckets, largest first (default 50)."),+ opt("scan_limit", TypeSchema::BoundedU64 { min: 1, max: 50_000 }, "Most items a listing-based engine reads (default 5000)."),+ ],+ outputs: out("{facet, buckets: {value, count}[], total, missing, more_buckets, truncated}"),+ },+ "items_get" => ControllerSchema {+ namespace: "memory",+ function: "items_get",+ description: "Read stored items whole by id, in the order asked; unknown ids are left out.",+ inputs: vec![req("ids", TypeSchema::Array(Box::new(TypeSchema::String)), "Item ids (1 to 200).")],+ outputs: out("{items: Hit[]}"),+ },"conversations_get" => ControllerSchema {namespace: "memory",function: "conversations_get",diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rsindex e4eaaca03d..9677ec6aa1 100644--- a/crates/openhuman-core/src/memory/schemas/handlers.rs+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs@@ -15,6 +15,7 @@ use crate::memory::types::{SourceAddedView, SourceRemovedView, SourcesAddParams, SourcesListView, SourcesRemoveParams,SourcesSyncParams, SourcesSyncView,};+use crate::memory::explore::{self, ExploreParams, ItemsGetParams};use crate::memory::{context, conversations, engine, import, ops, sources};fn parse<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {@@ -105,6 +106,20 @@ pub(super) fn items_list(params: Map<String, Value>) -> ControllerFuture {})}+pub(super) fn explore(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let params = parse::<ExploreParams>(params)?;+ finish(explore::explore(&load().await?, params).await)+ })+}++pub(super) fn items_get(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let params = parse::<ItemsGetParams>(params)?;+ finish(explore::items_get(&load().await?, params).await)+ })+}+pub(super) fn conversations_get(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {parse::<EmptyParams>(params)?;diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rsindex fde6fc9233..4486c2d268 100644--- a/crates/openhuman-core/src/memory/types.rs+++ b/crates/openhuman-core/src/memory/types.rs@@ -188,6 +188,9 @@ pub struct ItemsListParams {/// Engine cursor.#[serde(default)]pub cursor: Option<String>,+ /// Explorer path, applied on top of `filter` (see [`super::explore`]).+ #[serde(default)]+ pub path: Vec<super::explore::PathStep>,}/// `memory_items_list` result.