Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(storage): update storage import modules to use unified storage trait

Steven Enamakelb131d088a6b1
diff --git a/crates/openhuman-core/src/modules/storage_import_tinybox.rs b/crates/openhuman-core/src/modules/storage_import_tinybox.rs
index 97a383100d..68213dddd3 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinybox.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinybox.rs
@@ -23,7 +23,7 @@ use std::path::Path;
use anyhow::{Context, Result};
use serde_json::Value;
-use tinystoragedrivers::{CollectionSpec, ScopedStorage};
+use crate::storage::{CollectionSpec, Storage};
use super::storage_grant_schemas::tinybox::{JAIL_INDEX_COLLECTION, MODULE_ID};
use super::storage_import_support as support;
@@ -59,7 +59,7 @@ pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Re
import_into(&scoped, &workspace_dir.join(BASE_DIR)).await
}
-async fn import_into(scoped: &ScopedStorage, base: &Path) -> Result<Outcome> {
+async fn import_into(scoped: &Storage, base: &Path) -> Result<Outcome> {
let docs = scoped.documents();
let marker = support::marker_id("tinybox", base);
if support::already_imported(scoped, MARKER_COLLECTION, &marker).await? {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
index a4b69eb69a..e513ba6323 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
@@ -24,7 +24,7 @@ use std::path::Path;
use anyhow::{anyhow, Context, Result};
use serde_json::{json, Value};
-use tinystoragedrivers::{CollectionSpec, ScopedStorage};
+use crate::storage::{CollectionSpec, Storage};
use super::storage_grant_schemas::tinyconnectors::{
MODULE_ID, PREFS_COLLECTION, TRIGGER_STREAM_PREFIX,
@@ -84,7 +84,7 @@ struct Legacy {
async fn import_into(
ctx: &DispatchCtx,
- scoped: &ScopedStorage,
+ scoped: &Storage,
state_dir: &Path,
) -> Result<Outcome> {
let docs = scoped.documents();
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
index d920bc47fe..bf82ea13e9 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
@@ -24,7 +24,9 @@ use std::path::Path;
use std::time::{Duration, SystemTime};
use anyhow::{anyhow, Context, Result};
-use tinystoragedrivers::{Capability, ScopedStorage};
+use tinystoragedrivers_types::Capability;
+
+use crate::storage::Storage;
use super::storage_grant_schemas::tinyjuice::{CCR_BLOB_PREFIX, MODULE_ID};
use super::storage_import_support as support;
@@ -78,7 +80,7 @@ struct LegacyOriginal {
async fn import_into(
ctx: &DispatchCtx,
- scoped: &ScopedStorage,
+ scoped: &Storage,
root: &Path,
ttl: Option<Duration>,
now: SystemTime,
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs
index d62e80de2e..7633b6721c 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs
@@ -22,7 +22,7 @@ use std::path::{Path, PathBuf};
use anyhow::{Context, Result};
use tinyjuice_bus::savings::SavingsAggregate;
-use tinystoragedrivers::ScopedStorage;
+use crate::storage::Storage;
use super::storage_grant_schemas::tinyjuice::MODULE_ID;
use super::storage_import_support as support;
@@ -69,7 +69,7 @@ where
import_into(&scoped, file, adopt).await
}
-async fn import_into<F, Fut>(scoped: &ScopedStorage, file: &Path, adopt: F) -> Result<Outcome>
+async fn import_into<F, Fut>(scoped: &Storage, file: &Path, adopt: F) -> Result<Outcome>
where
F: FnOnce(SavingsAggregate) -> Fut,
Fut: Future<Output = Result<bool>>,
diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
index 6b008a67f6..ded4d39f36 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
@@ -32,8 +32,8 @@ use std::sync::Arc;
use anyhow::{anyhow, Context, Result};
use serde_json::{json, Value};
use sha2::Digest;
-use tinystoragedrivers::secrets::{DocumentSecrets, SecretStore};
-use tinystoragedrivers::{CollectionSpec, DocumentStore, ErrorKind, Precondition, ScopedStorage};
+use crate::storage::{CollectionSpec, DocumentStore, ErrorKind, Precondition, Storage};
+use tinystoragedrivers_api::SecretStore;
use crate::core::runtime::DispatchCtx;
use crate::storage::rusqlite::{self, Connection, OpenFlags};
@@ -81,13 +81,13 @@ pub(crate) async fn import_legacy(ctx: &DispatchCtx, data_dir: &Path) -> Result<
.map_err(|error| anyhow!("open the module scope: {:?}", error.kind()))?;
let keys = crate::storage::secrets::keys()
.map_err(|error| anyhow!("no key provider for module secrets: {:?}", error.kind()))?;
- let secrets = DocumentSecrets::new(&scoped, keys);
+ let secrets = scoped.secrets();
import_into(ctx, &scoped, &secrets, data_dir).await
}
async fn import_into(
ctx: &DispatchCtx,
- scoped: &ScopedStorage,
+ scoped: &Storage,
secrets: &dyn SecretStore,
data_dir: &Path,
) -> Result<Outcome> {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
index 63832e4c39..676bb7616f 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
@@ -23,7 +23,7 @@
use std::path::Path;
use anyhow::{anyhow, Context, Result};
-use tinystoragedrivers::ScopedStorage;
+use crate::storage::Storage;
use super::storage_grant_schemas::tinywallet::{MODULE_ID, PAYMENTS_STREAM};
use super::storage_import_support as support;
@@ -58,7 +58,7 @@ pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Re
async fn import_into(
ctx: &DispatchCtx,
- scoped: &ScopedStorage,
+ scoped: &Storage,
workspace_dir: &Path,
) -> Result<Outcome> {
let marker = support::marker_id("x402", workspace_dir);