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(storage): add import support for tinybox and tinyconnectors
Steven Enamakel457682e351f9
diff --git a/crates/openhuman-core/src/modules/storage_import_support.rs b/crates/openhuman-core/src/modules/storage_import_support.rsindex c4b55dc8f3..5475864755 100644--- a/crates/openhuman-core/src/modules/storage_import_support.rs+++ b/crates/openhuman-core/src/modules/storage_import_support.rs@@ -16,11 +16,14 @@ use tinystoragedrivers::{CollectionSpec, DocumentStore, ErrorKind, Precondition,/// The module's scope of the installed backend, or `None` when the process/// runs without a storage backend (the module is then not using this storage).-pub(super) fn module_scope(module_id: &str) -> Result<Option<ScopedStorage>> {+pub(super) fn module_scope(+ ctx: &crate::core::runtime::DispatchCtx,+ module_id: &str,+) -> Result<Option<ScopedStorage>> {let Some(backend) = crate::storage::installed() else {return Ok(None);};- let scope = super::storage_host::current_module_scope(&crate::core::runtime::DispatchCtx::ambient(), module_id)+ let scope = super::storage_host::current_module_scope(ctx, module_id).map_err(|error| anyhow!("resolve the module scope: {:?}", error.kind()))?;let scoped = backend.for_scope(&scope)diff --git a/crates/openhuman-core/src/modules/storage_import_tinybox.rs b/crates/openhuman-core/src/modules/storage_import_tinybox.rsindex caddb35b61..c6ddc49f5a 100644--- a/crates/openhuman-core/src/modules/storage_import_tinybox.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinybox.rs@@ -51,8 +51,8 @@ pub(crate) enum Outcome {/// Imports the index under `<workspace_dir>/jails` into the module's scope of/// the installed backend.-pub(crate) async fn import_legacy(workspace_dir: &Path) -> Result<Outcome> {- let Some(scoped) = support::module_scope(MODULE_ID)? else {+pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Result<Outcome> {+ let Some(scoped) = support::module_scope(ctx, MODULE_ID)? else {return Ok(Outcome::NoBackend);};import_into(&scoped, &workspace_dir.join(BASE_DIR)).awaitdiff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rsindex 8bd1c7b0fa..ffee50a4a8 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs@@ -54,11 +54,11 @@ pub(crate) enum Outcome {/// Imports the legacy files under `state_dir` into the module's scope of the/// installed backend.-pub(crate) async fn import_legacy(state_dir: &Path) -> Result<Outcome> {- let Some(scoped) = support::module_scope(MODULE_ID)? else {+pub(crate) async fn import_legacy(ctx: &DispatchCtx, state_dir: &Path) -> Result<Outcome> {+ let Some(scoped) = support::module_scope(ctx, MODULE_ID)? else {return Ok(Outcome::NoBackend);};- import_into(&scoped, state_dir).await+ import_into(ctx, &scoped, state_dir).await}/// A preference file: the toolkit key and its bare JSON value.@@ -79,7 +79,11 @@ struct Legacy {skipped: usize,}-async fn import_into(scoped: &ScopedStorage, state_dir: &Path) -> Result<Outcome> {+async fn import_into(+ ctx: &DispatchCtx,+ scoped: &ScopedStorage,+ state_dir: &Path,+) -> Result<Outcome> {let docs = scoped.documents();let marker = support::marker_id("connectors", state_dir);if support::already_imported(docs, MARKER_COLLECTION, &marker).await? {@@ -92,7 +96,7 @@ async fn import_into(scoped: &ScopedStorage, state_dir: &Path) -> Result<Outcome}let legacy =- crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir))+ ctx.spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir)).await.context("the legacy reader panicked")??;diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rsindex 19b31a1c3b..d011e76f70 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs@@ -58,11 +58,11 @@ pub(crate) enum Outcome {/// Imports the CCR files under `root` into the module's scope of the installed/// backend. `ttl` is the configured original lifetime; `None` keeps them.-pub(crate) async fn import_legacy(root: &Path, ttl: Option<Duration>) -> Result<Outcome> {- let Some(scoped) = support::module_scope(MODULE_ID)? else {+pub(crate) async fn import_legacy(ctx: &DispatchCtx, root: &Path, ttl: Option<Duration>) -> Result<Outcome> {+ let Some(scoped) = support::module_scope(ctx, MODULE_ID)? else {return Ok(Outcome::NoBackend);};- import_into(&scoped, root, ttl, SystemTime::now()).await+ import_into(ctx, &scoped, root, ttl, SystemTime::now()).await}/// One readable original: its token, text and age.@@ -73,6 +73,7 @@ struct LegacyOriginal {}async fn import_into(+ ctx: &DispatchCtx,scoped: &ScopedStorage,root: &Path,ttl: Option<Duration>,@@ -93,7 +94,7 @@ async fn import_into(let dir = root.to_owned();let (originals, mut skipped) =- crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || read_originals(&dir, now))+ ctx.spawn_blocking(move || read_originals(&dir, now)).await.context("the legacy reader panicked")??;diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp.rsindex 6b78c07f73..9f3e66f069 100644--- a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs@@ -69,11 +69,11 @@ pub(crate) enum Outcome {/// Imports the legacy files under `data_dir` into the module's scope of the/// installed backend.-pub(crate) async fn import_legacy(data_dir: &Path) -> Result<Outcome> {+pub(crate) async fn import_legacy(ctx: &DispatchCtx, data_dir: &Path) -> Result<Outcome> {let Some(backend) = crate::storage::installed() else {return Ok(Outcome::NoBackend);};- let scope = super::storage_host::current_module_scope(&crate::core::runtime::DispatchCtx::ambient(), MODULE_ID)+ let scope = super::storage_host::current_module_scope(ctx, MODULE_ID).map_err(|error| anyhow!("resolve the module scope: {:?}", error.kind()))?;let scoped = backend.for_scope(&scope)@@ -81,10 +81,11 @@ pub(crate) async fn import_legacy(data_dir: &Path) -> Result<Outcome> {let keys = crate::storage::secrets::keys().map_err(|error| anyhow!("no key provider for module secrets: {:?}", error.kind()))?;let secrets = DocumentSecrets::new(&scoped, keys);- import_into(&scoped, &secrets, data_dir).await+ import_into(ctx, &scoped, &secrets, data_dir).await}async fn import_into(+ ctx: &DispatchCtx,scoped: &ScopedStorage,secrets: &dyn SecretStore,data_dir: &Path,@@ -110,7 +111,7 @@ async fn import_into(// The files are read on a blocking thread, from copies.let (legacy_servers, legacy_audit) =- crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || -> Result<_> {+ ctx.spawn_blocking(move || -> Result<_> {let servers = if clients.exists() {read_servers(&clients)?} else {diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rsindex da7b0967a7..9bb486cfa2 100644--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs@@ -49,14 +49,18 @@ pub(crate) enum Outcome {/// Imports the legacy ledger under `workspace_dir` into the module's scope of/// the installed backend.-pub(crate) async fn import_legacy(workspace_dir: &Path) -> Result<Outcome> {- let Some(scoped) = support::module_scope(MODULE_ID)? else {+pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Result<Outcome> {+ let Some(scoped) = support::module_scope(ctx, MODULE_ID)? else {return Ok(Outcome::NoBackend);};- import_into(&scoped, workspace_dir).await+ import_into(ctx, &scoped, workspace_dir).await}-async fn import_into(scoped: &ScopedStorage, workspace_dir: &Path) -> Result<Outcome> {+async fn import_into(+ ctx: &DispatchCtx,+ scoped: &ScopedStorage,+ workspace_dir: &Path,+) -> Result<Outcome> {let docs = scoped.documents();let marker = support::marker_id("x402", workspace_dir);if support::already_imported(docs, MARKER_COLLECTION, &marker).await? {@@ -66,7 +70,7 @@ async fn import_into(scoped: &ScopedStorage, workspace_dir: &Path) -> Result<Outif !ledger.is_file() {return Ok(Outcome::NoSource);}- let (records, skipped) = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || -> Result<_> {+ let (records, skipped) = ctx.spawn_blocking(move || -> Result<_> {let text = std::fs::read_to_string(&ledger).with_context(|| format!("read {}", ledger.display()))?;Ok(support::parse_jsonl(&text))