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(core): enable secrets feature for tinystoragedrivers
Steven Enamakelcd699f3755eb
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.tomlindex fd7f62e7b8..bf311e2d1a 100644--- a/crates/openhuman-core/Cargo.toml+++ b/crates/openhuman-core/Cargo.toml@@ -152,7 +152,7 @@ tinyagents-registry = { path = "../../vendor/tinyagents/crates/tinyagents-registtinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session", features = ["storage-drivers"] }# The storage ports and the URL-to-backend facade (`storage` domain). No driver# by default: the `storage-*` features below add them.-tinystoragedrivers = { path = "../../vendor/tinyagents/vendor/tinystoragedrivers/crates/tinystoragedrivers", default-features = false, features = ["blocking"] }+tinystoragedrivers = { path = "../../vendor/tinyagents/vendor/tinystoragedrivers/crates/tinystoragedrivers", default-features = false, features = ["blocking", "secrets"] }tinyagents-runtime = { path = "../../vendor/tinyagents/crates/tinyagents-runtime" }tinyagents-orchestration = { path = "../../vendor/tinyagents/crates/tinyagents-orchestration" }tinyinference-core = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-core" }diff --git a/crates/openhuman-core/src/storage/secrets.rs b/crates/openhuman-core/src/storage/secrets.rsnew file mode 100644index 0000000000..c234b0661d--- /dev/null+++ b/crates/openhuman-core/src/storage/secrets.rs@@ -0,0 +1,59 @@+//! Secrets on the installed storage backend.+//!+//! With a backend configured, the keyring's user secrets+//! ([`crate::security::keyring::get`] / `set` / `delete`) and the credential+//! stores' files live here instead of the OS keychain or `secrets.enc`: one+//! encrypted document per secret (`tinystoragedrivers` `DocumentSecrets`,+//! `enc2:` ChaCha20-Poly1305), under the acting agent's storage scope.+//!+//! Each scope has its own data key, derived from one master key with+//! HKDF-SHA256 (`DerivedKeys`), so one tenant's key exposes no other's. The+//! master key is the keyring's: `OPENHUMAN_KEYRING_MASTER_KEY` /+//! `OPENHUMAN_KEYRING_MASTER_KEY_FILE`, else the OS keychain. With no master+//! key the secrets fail closed.+//!+//! The config-field encryption key (`SecretStore`'s `secretstore.master_key`)+//! does **not** move: it encrypts the process's own `config.toml`, which is+//! loaded before any agent acts, so it stays on the process keyring backend.++use std::sync::{Arc, OnceLock};++use tinystoragedrivers::secrets::{DerivedKeys, DocumentSecrets, KeyProvider};+use zeroize::Zeroizing;++use super::{current_scoped, ScopedStorage, StorageError};++/// The key provider every scope's secrets use, built once per process.+fn keys() -> Result<Arc<dyn KeyProvider>, StorageError> {+ static KEYS: OnceLock<Result<Arc<dyn KeyProvider>, String>> = OnceLock::new();+ KEYS.get_or_init(|| {+ crate::security::keyring::encrypted_file_backend::storage_master_key().map(|master| {+ Arc::new(DerivedKeys::new(Zeroizing::new(master))) as Arc<dyn KeyProvider>+ })+ })+ .clone()+ .map_err(|error| StorageError::crypto(format!("no master key for storage secrets: {error}")))+}++/// The secret store for this call when the host configured a backend, in+/// the acting agent's scope; `None` keeps secrets on the process keyring.+///+/// # Errors+///+/// When the scope cannot be resolved (SaaS mode with no acting agent) or no+/// master key is available.+pub fn current() -> Result<Option<DocumentSecrets>, StorageError> {+ let Some(scoped) = current_scoped()? else {+ return Ok(None);+ };+ Ok(Some(over(&scoped, keys()?)))+}++/// Secrets in `scoped` under `keys` (tests and explicit scopes).+pub fn over(scoped: &ScopedStorage, keys: Arc<dyn KeyProvider>) -> DocumentSecrets {+ DocumentSecrets::new(scoped, keys)+}++#[cfg(test)]+#[path = "secrets_tests.rs"]+mod tests;