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(sessions): expose scoped artifact storage access
Steven Enamakel86d3d6239871
diff --git a/crates/openhuman-core/src/storage/sessions/mod.rs b/crates/openhuman-core/src/storage/sessions/mod.rsindex a6ac9023c2..bacc63063d 100644--- a/crates/openhuman-core/src/storage/sessions/mod.rs+++ b/crates/openhuman-core/src/storage/sessions/mod.rs@@ -26,10 +26,11 @@ mod workspace;pub use rebound::{rebind_all, ReboundSessionStores, StoreRegistry};pub use tenant_router::TenantSessionStores;pub use workspace::{- artifact_blobs_for, attachment_stash_for, current_documents_for, default_turn_states_for,- ledger_for, provider_for_workspace, provider_for_workspace_in, release_workspace,- release_workspace_defaults, require_ledger, session_scope, status_store_for, stores_for,- stores_or_ephemeral, turn_states_for, with_ledger, with_ledger_async, WorkspaceSessionStores,+ artifact_blobs_for, artifact_scoped_for_in, attachment_stash_for, current_documents_for,+ default_turn_states_for, ledger_for, provider_for_workspace, provider_for_workspace_in,+ release_workspace, release_workspace_defaults, require_ledger, session_scope,+ status_store_for, stores_for, stores_or_ephemeral, turn_states_for, with_ledger,+ with_ledger_async, WorkspaceSessionStores,};static PROVIDER: LazyLock<RwLock<Option<Arc<dyn SessionStoreProvider>>>> =diff --git a/crates/openhuman-core/src/storage/sessions/workspace.rs b/crates/openhuman-core/src/storage/sessions/workspace.rsindex 3d75e85c75..eace3c471a 100644--- a/crates/openhuman-core/src/storage/sessions/workspace.rs+++ b/crates/openhuman-core/src/storage/sessions/workspace.rs@@ -21,7 +21,7 @@ use super::tenant_router::TenantSessionStores;use tinyagents_harness::multimodal::BlobAttachmentStash;use tinyagents_session::port::{AgentStores, SessionStoreProvider, TurnStates};use tinyagents_session::run_ledger::{LedgerError, LedgerResult, RunLedgerStore};-use tinystoragedrivers::{BlobStore, DocumentStore, MemoryStorage, StorageBackend};+use tinystoragedrivers::{BlobStore, DocumentStore, MemoryStorage, ScopedStorage, StorageBackend};/// One fallback provider and the backend it was built over.struct Fallback {@@ -213,6 +213,39 @@ pub fn artifact_blobs_for(workspace_dir: &Path) -> Option<Arc<dyn BlobStore>> {Some(Arc::clone(scoped.blobs()))}+/// The artifact ports for the tenant carried by `context` on the workspace's+/// storage backend. Unlike [`artifact_blobs_for`], this does not consult the+/// ambient dispatch context, so a tool that was moved to a detached task keeps+/// using the profile that authorized the call.+#[must_use]+pub fn artifact_scoped_for_in(+ workspace_dir: &Path,+ context: &crate::core::runtime::DispatchCtx,+) -> Option<ScopedStorage> {+ let tenant = match context.tenant() {+ Ok(tenant) => tenant,+ Err(no_tenant) => {+ log::warn!("[session_store] no tenant for artifact scope: {no_tenant}");+ return None;+ }+ };+ let key = crate::core::runtime::session_key(&tenant);+ let backend = match crate::storage::local::backend_for(workspace_dir) {+ Ok(backend) => backend,+ Err(error) => {+ log::warn!("[session_store] no storage backend for artifacts: {error:#}");+ return None;+ }+ };+ match backend.for_scope(&session_scope(&key)) {+ Ok(scoped) => Some(scoped),+ Err(error) => {+ log::warn!("[session_store] artifact scope refused agent={key}: {error}");+ None+ }+ }+}+/// 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(