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): improve state migration and session store initialization
Steven Enamakelb1bbcb738fb9
diff --git a/crates/openhuman-core/src/integrations/composio/file_store_documents.rs b/crates/openhuman-core/src/integrations/composio/file_store_documents.rsindex a0425517bf..c259fac555 100644--- a/crates/openhuman-core/src/integrations/composio/file_store_documents.rs+++ b/crates/openhuman-core/src/integrations/composio/file_store_documents.rs@@ -28,8 +28,8 @@ use anyhow::Result;use serde::de::DeserializeOwned;use serde::{Deserialize, Serialize};use serde_json::Value;-use tinystoragedrivers_types::{Capability, CollectionSpec, Query, StorageError};use tinystoragedrivers_api::DocumentStore;+use tinystoragedrivers_types::{Capability, CollectionSpec, Query, StorageError};use crate::storage::documents::Repo;use crate::storage::import_state;@@ -165,15 +165,18 @@ pub(crate) async fn migrate_legacy_state(scoped: &Storage) -> Result<usize, Stor}let store = StateKv::over(scoped, KV_OWNER, KV_NS);let mut moved = 0;- for legacy in docs- .query_all(LEGACY_STATE, &Query::all())- .await?- {+ for legacy in docs.query_all(LEGACY_STATE, &Query::all()).await? {let Some(value) = legacy.doc.get("value") else {continue;};- if store.get::<Value>(&legacy.id).map_err(|error| StorageError::backend(error.to_string()))?.is_none() {- store.put(&legacy.id, value).map_err(|error| StorageError::backend(error.to_string()))?;+ if store+ .get::<Value>(&legacy.id)+ .map_err(|error| StorageError::backend(error.to_string()))?+ .is_none()+ {+ store+ .put(&legacy.id, value)+ .map_err(|error| StorageError::backend(error.to_string()))?;moved += 1;}}diff --git a/crates/openhuman-core/src/storage/sessions/workspace.rs b/crates/openhuman-core/src/storage/sessions/workspace.rsindex 562c79bac9..71af561fb8 100644--- a/crates/openhuman-core/src/storage/sessions/workspace.rs+++ b/crates/openhuman-core/src/storage/sessions/workspace.rs@@ -19,7 +19,9 @@ use std::sync::{Arc, LazyLock, Mutex, PoisonError};use super::tenant_router::TenantSessionStores;use tinyagents_harness::multimodal::BlobAttachmentStash;-use tinyagents_session::port::{AgentStorageFactory, AgentStores, DriverSessionStores, SessionStoreProvider, TurnStates};+use tinyagents_session::port::{+ AgentStorageFactory, AgentStores, DriverSessionStores, SessionStoreProvider, TurnStates,+};use tinyagents_session::run_ledger::{LedgerError, LedgerResult, RunLedgerStore};use tinyagents_storage_kit::ScopedStorage;use tinystoragedrivers_api::{BlobStore, DocumentStore, StorageBackend};@@ -110,9 +112,10 @@ fn refusing_provider(message: String) -> Arc<dyn SessionStoreProvider> {message.clone(),))});- Arc::new(DriverSessionStores::new(factory).unwrap_or_else(|error| {- panic!("could not start refusal-only session bridge: {error}")- }))+ Arc::new(+ DriverSessionStores::new(factory)+ .unwrap_or_else(|error| panic!("could not start refusal-only session bridge: {error}")),+ )}/// The key the calling tenant's stores are under, or `None` for a SaaS task@@ -201,10 +204,7 @@ pub fn artifact_blobs_for(workspace_dir: &Path) -> Option<Arc<dyn BlobStore>> {/// The calling tenant's scoped storage on `workspace_dir`'s backend. `what`/// only labels the log line when the backend or scope is refused.-fn tenant_scope_for(- workspace_dir: &Path,- what: &str,-) -> Option<(String, ScopedStorage)> {+fn tenant_scope_for(workspace_dir: &Path, what: &str) -> Option<(String, ScopedStorage)> {let key = tenant_agent_key()?;let backend = match crate::storage::local::backend_for(workspace_dir) {Ok(backend) => backend,