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
chore: files changed crates/openhuman-core/src/memory/explore.rs,crates/openhuman-core/src/memory/op
Steven Enamakelaaaf3f58d970
diff --git a/crates/openhuman-core/src/memory/explore.rs b/crates/openhuman-core/src/memory/explore.rsindex 92382d9a0d..e19c3e7542 100644--- a/crates/openhuman-core/src/memory/explore.rs+++ b/crates/openhuman-core/src/memory/explore.rs@@ -13,27 +13,13 @@//! `memory_items_get {ids}` reads one whole.use serde::{Deserialize, Serialize};-use tinymemory_api::{ExplorePage, ExploreRequest, Facet, GetRequest, Hit, ItemId, MetaFilter};+use tinymemory_api::{ExplorePage, Facet, Hit, ItemId, MetaFilter, Result};+use tinymemory_tools::ops::ExploreOptions;use crate::config::Config;use super::engine;-use tinymemory_api::{Error, Result};--/// Default bucket count of `memory_explore`.-pub const DEFAULT_BUCKETS: usize = 50;--/// Most steps an explorer path may take (one per facet is the useful most).-pub const MAX_PATH_STEPS: usize = 16;--/// One step down the explorer: the items whose `facet` is `value`.-#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]-pub struct PathStep {- /// The facet.- pub facet: Facet,- /// Its chosen value, as a bucket reported it.- pub value: String,-}+pub use tinymemory_tools::ops::{narrowed, PathStep, DEFAULT_BUCKETS, MAX_PATH_STEPS};/// `memory_explore` params.#[derive(Debug, Clone, Deserialize)]@@ -71,35 +57,21 @@ pub struct ItemsGetView {pub items: Vec<Hit>,}-/// `filter` narrowed by every step of `path`.-///-/// # Errors-///-/// [`Error::InvalidRequest`] for a path that is too long or a step whose-/// value the facet cannot take (blank, or an unknown kind).-pub fn narrowed(filter: Option<MetaFilter>, path: &[PathStep]) -> Result<MetaFilter> {- if path.len() > MAX_PATH_STEPS {- return Err(Error::InvalidRequest(format!(- "an explorer path takes at most {MAX_PATH_STEPS} steps"- )));- }- let mut filter = filter.unwrap_or_default();- for step in path {- step.facet.narrow(&mut filter, &step.value)?;- }- Ok(filter)-}-/// `memory_explore`.pub async fn explore(config: &Config, params: ExploreParams) -> Result<ExplorePage> {let bound = engine::resolve(config).engine()?;- let mut request = ExploreRequest::new(params.facet, params.limit.unwrap_or(DEFAULT_BUCKETS));- request.filter = super::ops::confine_filter(config, narrowed(params.filter, ¶ms.path)?)?;- if let Some(scan_limit) = params.scan_limit {- request.scan_limit = scan_limit;- }- request.validate()?;- let page = bound.engine.explore(request).await?;+ let page = super::ops::memory_ops(config)?+ .explore(+ bound.engine.as_ref(),+ ExploreOptions {+ facet: params.facet,+ path: params.path,+ filter: params.filter,+ limit: params.limit,+ scan_limit: params.scan_limit,+ },+ )+ .await?;tracing::debug!(engine = %bound.id,facet = params.facet.as_str(),@@ -115,13 +87,11 @@ pub async fn explore(config: &Config, params: ExploreParams) -> Result<ExplorePa/// `memory_items_get`.pub async fn items_get(config: &Config, params: ItemsGetParams) -> Result<ItemsGetView> {let bound = engine::resolve(config).engine()?;- let request = GetRequest {- ids: params.ids.into_iter().map(ItemId::new).collect(),- reach: params.reach,- };- request.validate()?;- let asked = request.ids.len();- let items = bound.engine.get(request).await?;+ let ids: Vec<ItemId> = params.ids.into_iter().map(ItemId::new).collect();+ let asked = ids.len();+ let items = super::ops::memory_ops(config)?+ .items_get(bound.engine.as_ref(), ids, params.reach)+ .await?;tracing::debug!(engine = %bound.id,asked,diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex 279d50b2bd..b888373217 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -29,9 +29,9 @@ use super::engine::{self, Binding, BoundEngine, CORTEXDB_ENGINE, DISABLED_ENGINE, TINYHUMANS_ENGINE,};use super::types::{- clamp_limit, EngineSetParams, EngineStatus, EngineView, EnginesListView, EraseAllParams,- EraseAllView, FetchParams, FetchView, ForgetParams, ForgetView, ItemsListParams, ItemsListView,- LearnParams, LearnView, RecallParams, RecallView, RefersTo,+ EngineSetParams, EngineStatus, EngineView, EnginesListView, EraseAllParams, EraseAllView,+ FetchParams, FetchView, ForgetParams, ForgetView, ItemsListParams, ItemsListView, LearnParams,+ LearnView, RecallParams, RecallView, RefersTo,};use tinymemory_api::{Error, Result};@@ -616,27 +616,6 @@ pub async fn erase_all(})}-/// The ids among `ids` naming an item in `reach`, read through `get` in-/// chunks of its id limit.-async fn within_reach(- bound: &BoundEngine,- ids: Vec<ItemId>,- reach: tinymemory_api::Reach,-) -> Result<Vec<ItemId>> {- let mut kept = Vec::new();- for chunk in ids.chunks(tinymemory_api::explore::MAX_GET_IDS) {- let found = bound- .engine- .get(tinymemory_api::GetRequest {- ids: chunk.to_vec(),- reach: Some(reach.clone()),- })- .await?;- kept.extend(found.into_iter().map(|hit| hit.id));- }- Ok(kept)-}-/// `memory_items_list`.pub async fn items_list(config: &Config, params: ItemsListParams) -> Result<ItemsListView> {let bound = bound(config)?;diff --git a/crates/openhuman-core/src/memory/sources/mod.rs b/crates/openhuman-core/src/memory/sources/mod.rsindex 04c36016b0..69bb684c23 100644--- a/crates/openhuman-core/src/memory/sources/mod.rs+++ b/crates/openhuman-core/src/memory/sources/mod.rs@@ -10,7 +10,6 @@pub mod state;mod sync;-use tinymemory_api::MetaFilter;use tinymemory_tools::ops::MemoryOps;use crate::config::schema::{MemorySourceConfig, MemorySourceKind};