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(core): update store adapter and delivery slot types
Steven Enamakelcaebee7ece34
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions/store_adapter.rs b/crates/openhuman-core/src/agent/orchestration/background_completions/store_adapter.rsindex 8f25b8ed0a..82a41708cf 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions/store_adapter.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions/store_adapter.rs@@ -32,16 +32,15 @@ pub(in crate::agent::orchestration) fn open_driver_store(ctx: &DispatchCtx,workspace_dir: &Path,) -> anyhow::Result<Arc<dyn CompletionStore>> {- let tenant = ctx- .tenant()- .map_err(|error| anyhow::anyhow!("resolve the completion-store tenant: {error}"))?;- let backend = crate::storage::local::backend_for(workspace_dir)?;- let store = DriverCompletionStore::new(- backend,- crate::storage::sessions::session_scope(&crate::core::runtime::session_key(&tenant)),- )- .map_err(|error| anyhow::anyhow!("start the completion store bridge: {error}"))?;- Ok(Arc::new(store) as Arc<dyn CompletionStore>)+ with_storage_context(ctx, || {+ // Preserve the `background_completions` domain scope used by the+ // previous document-backed adapter. The owner API now needs the+ // backend and exact scope so it can provide its own fenced store.+ let opened = crate::storage::local::open("background_completions", workspace_dir)?;+ let store = DriverCompletionStore::new(opened.backend, opened.scope)+ .map_err(|error| anyhow::anyhow!("start the completion store bridge: {error}"))?;+ Ok(Arc::new(store) as Arc<dyn CompletionStore>)+ })}/// Scope storage access to the explicit context when one exists. A genuinelydiff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rsindex d2113cb217..70fb5ab9eb 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rs@@ -3,7 +3,7 @@use std::sync::Arc;-use tinyagents_tasks::CompletionRouter;+use tinyagents_tasks::{CompletionReceipt, CompletionRouter};use crate::core::runtime::tenant;use crate::core::runtime::DispatchCtx;@@ -15,7 +15,7 @@ pub(super) struct DeliverySlot {/// [`tenant::profile_key_in`] of the thread id.pub(super) key: String,router: Arc<CompletionRouter>,- held: Vec<String>,+ held: Vec<CompletionReceipt>,}impl DeliverySlot {@@ -37,8 +37,8 @@ impl DeliverySlot {})}- pub(super) fn hold(&mut self, task_ids: &[String]) {- self.held = task_ids.to_vec();+ pub(super) fn hold(&mut self, receipts: &[CompletionReceipt]) {+ self.held = receipts.to_vec();}}diff --git a/crates/openhuman-core/src/artifacts/ops_tests.rs b/crates/openhuman-core/src/artifacts/ops_tests.rsindex bdd585d019..2061e83d81 100644--- a/crates/openhuman-core/src/artifacts/ops_tests.rs+++ b/crates/openhuman-core/src/artifacts/ops_tests.rs@@ -508,7 +508,8 @@ async fn get_and_delete_refuse_a_record_rooted_outside_the_files_folder() {async fn sharing_without_cloud_storage_is_refused_with_a_reason() {let tmp = TempDir::new().unwrap();let config = test_config(&tmp);- let err = ai_share_artifact(&config, "a-1", None, false)+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let err = ai_share_artifact(&config, "a-1", None, false, &ctx).await.unwrap_err();assert!(err.contains("sign in"), "{err}");diff --git a/crates/openhuman-core/src/artifacts/tiny_store_tests.rs b/crates/openhuman-core/src/artifacts/tiny_store_tests.rsindex 0060f9fa95..a0bdeabbda 100644--- a/crates/openhuman-core/src/artifacts/tiny_store_tests.rs+++ b/crates/openhuman-core/src/artifacts/tiny_store_tests.rs@@ -36,7 +36,8 @@ async fn an_edit_is_appended_as_an_operator_version_and_written_to_the_file() {let (workspace, files) = temp_dirs();let store = seeded(&workspace, &files).await;- let saved = save_operator_version(&workspace, FileRoots::new(&files), "a-1", "# v2")+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let saved = save_operator_version(&workspace, FileRoots::new(&files), "a-1", "# v2", &ctx).await.unwrap();assert_eq!(@@ -64,7 +65,8 @@ async fn an_unchanged_body_appends_nothing() {let (workspace, files) = temp_dirs();let store = seeded(&workspace, &files).await;- let saved = save_operator_version(&workspace, FileRoots::new(&files), "a-1", "# v1")+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let saved = save_operator_version(&workspace, FileRoots::new(&files), "a-1", "# v1", &ctx).await.unwrap();assert_eq!(@@ -80,7 +82,8 @@ async fn an_unchanged_body_appends_nothing() {#[tokio::test]async fn a_missing_artifact_is_an_error() {let (workspace, files) = temp_dirs();- let err = save_operator_version(&workspace, FileRoots::new(&files), "nope", "x")+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let err = save_operator_version(&workspace, FileRoots::new(&files), "nope", "x", &ctx).await.unwrap_err();assert!(err.contains("not found"), "{err}");@@ -92,7 +95,8 @@ async fn an_image_filed_through_the_service_gets_a_card_and_a_copy_in_files() {let action = workspace.parent().unwrap().join("projects");std::fs::create_dir_all(&action).unwrap();std::fs::write(action.join("chart.png"), b"png-bytes").unwrap();- let artifacts = artifacts_service(&workspace, FileRoots::new(&files), Some(&action), None);+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let artifacts = artifacts_service(&workspace, FileRoots::new(&files), Some(&action), None, &ctx);let saved = artifacts.create(@@ -125,7 +129,8 @@ async fn a_file_outside_the_allowed_folders_is_refused() {let elsewhere = workspace.parent().unwrap().join("elsewhere");std::fs::create_dir_all(&elsewhere).unwrap();std::fs::write(elsewhere.join("x.pdf"), b"x").unwrap();- let artifacts = artifacts_service(&workspace, FileRoots::new(&files), None, None);+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let artifacts = artifacts_service(&workspace, FileRoots::new(&files), None, None, &ctx);let err = artifacts.create(ArtifactKind::File,@@ -142,7 +147,8 @@ async fn a_file_outside_the_allowed_folders_is_refused() {#[tokio::test]async fn deleting_an_artifact_removes_its_card() {let (workspace, files) = temp_dirs();- let artifacts = artifacts_service(&workspace, FileRoots::new(&files), None, None);+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let artifacts = artifacts_service(&workspace, FileRoots::new(&files), None, None, &ctx);let saved = artifacts.create(ArtifactKind::Markdown,@@ -213,7 +219,8 @@ async fn a_file_in_an_earlier_files_folder_can_still_be_revised() {std::fs::write(&old, b"v1").unwrap();// The files folder moved; the earlier one stays trusted.let roots = FileRoots::new(&files).with_trusted([earlier.clone()]);- let artifacts = artifacts_service(&workspace, roots, None, None);+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let artifacts = artifacts_service(&workspace, roots, None, None, &ctx);let id = artifacts.create(ArtifactKind::File,@@ -246,7 +253,8 @@ async fn a_protected_file_inside_the_working_folder_is_refused() {let ssh = action.join(".ssh");std::fs::create_dir_all(&ssh).unwrap();std::fs::write(ssh.join("id_ed25519"), b"PRIVATE").unwrap();- let artifacts = artifacts_service(&workspace, FileRoots::new(&files), Some(&action), None);+ let ctx = crate::core::runtime::DispatchCtx::process_default();+ let artifacts = artifacts_service(&workspace, FileRoots::new(&files), Some(&action), None, &ctx);let err = artifacts.create(