Skip to content

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

refactor(artifacts): update artifact service initialization with context

Steven Enamakel3707324ad0cf
diff --git a/crates/openhuman-core/src/artifacts/production.rs b/crates/openhuman-core/src/artifacts/production.rs
index fab60b7430..52904d8fc9 100644
--- a/crates/openhuman-core/src/artifacts/production.rs
+++ b/crates/openhuman-core/src/artifacts/production.rs
@@ -141,6 +141,7 @@ impl Production {
files.clone(),
None,
chat,
+ ctx,
scoped,
None,
);
diff --git a/crates/openhuman-core/src/artifacts/production_tests.rs b/crates/openhuman-core/src/artifacts/production_tests.rs
index 84ff0a0d6c..41f39795ad 100644
--- a/crates/openhuman-core/src/artifacts/production_tests.rs
+++ b/crates/openhuman-core/src/artifacts/production_tests.rs
@@ -1,6 +1,5 @@
use std::path::PathBuf;
-use tiny_artifacts::FileStore;
use tiny_artifacts::{ArtifactKind, ArtifactStatus as RecordStatus, ArtifactStore};
use super::*;
diff --git a/crates/openhuman-core/src/artifacts/tiny_store.rs b/crates/openhuman-core/src/artifacts/tiny_store.rs
index 2ca3dad0a9..c058119aac 100644
--- a/crates/openhuman-core/src/artifacts/tiny_store.rs
+++ b/crates/openhuman-core/src/artifacts/tiny_store.rs
@@ -298,20 +298,6 @@ impl LegacyUiBridge {
.map_err(anyhow::Error::msg)?;
Ok(())
}
-}
-
-fn same_file(a: &Path, b: &Path) -> bool {
- match (std::fs::canonicalize(a), std::fs::canonicalize(b)) {
- (Ok(a), Ok(b)) => a == b,
- _ => false,
- }
-}
-
-#[async_trait]
-impl ArtifactObserver for LegacyUiBridge {
- async fn on_event(&self, event: &ArtifactEvent) -> anyhow::Result<()> {
- self.ctx.enter(self.on_event_in_scope(event)).await
- }
async fn on_event_in_scope(&self, event: &ArtifactEvent) -> anyhow::Result<()> {
let id = &event.record.id;
@@ -349,6 +335,21 @@ impl ArtifactObserver for LegacyUiBridge {
}
}
+fn same_file(a: &Path, b: &Path) -> bool {
+ match (std::fs::canonicalize(a), std::fs::canonicalize(b)) {
+ (Ok(a), Ok(b)) => a == b,
+ _ => false,
+ }
+}
+
+#[async_trait]
+impl ArtifactObserver for LegacyUiBridge {
+ async fn on_event(&self, event: &ArtifactEvent) -> anyhow::Result<()> {
+ self.ctx.enter(self.on_event_in_scope(event)).await
+ }
+
+}
+
/// The folders a file version may point into: its own kept copy, the agent's
/// working folder, and every files folder the host trusts. A folder used
/// before the current one stays trusted, so an artifact made there can still
@@ -450,7 +451,15 @@ fn build_artifacts_service(
publisher: Option<&super::publisher_slot::ArtifactPublisherBinder>,
) -> (Artifacts, Option<Arc<dyn FileStore>>) {
let scoped = crate::storage::sessions::artifact_scoped_for_in(workspace_dir, ctx);
- build_artifacts_service_with_scope(workspace_dir, files, action_dir, chat, scoped, publisher)
+ build_artifacts_service_with_scope(
+ workspace_dir,
+ files,
+ action_dir,
+ chat,
+ ctx,
+ scoped,
+ publisher,
+ )
}
pub(super) fn build_artifacts_service_with_scope(
@@ -458,6 +467,7 @@ pub(super) fn build_artifacts_service_with_scope(
files: FileRoots,
action_dir: Option<&Path>,
chat: Option<&ApprovalChatContext>,
+ ctx: &crate::core::runtime::DispatchCtx,
scoped: Option<crate::storage::ScopedStorage>,
publisher: Option<&super::publisher_slot::ArtifactPublisherBinder>,
) -> (Artifacts, Option<Arc<dyn FileStore>>) {
@@ -465,12 +475,12 @@ pub(super) fn build_artifacts_service_with_scope(
let file_store = scoped
.as_ref()
.map(|scoped| Arc::new(tiny_artifacts::BlobFileStore::new(scoped)) as Arc<dyn FileStore>);
- let mut records: Arc<dyn ArtifactStore> = Arc::new(match scoped.as_ref() {
- Some(scoped) => {
- super::version_documents::DocumentArtifactStore::over(workspace_dir, scoped)
- }
- None => UnavailableArtifactStore,
- });
+ let mut records: Arc<dyn ArtifactStore> = match scoped.as_ref() {
+ Some(scoped) => Arc::new(
+ super::version_documents::DocumentArtifactStore::over(workspace_dir, scoped),
+ ),
+ None => Arc::new(UnavailableArtifactStore),
+ };
if let Some(store) = file_store.as_ref() {
records = Arc::new(LegacyFileImportStore {
records,
diff --git a/crates/openhuman-core/src/artifacts/tiny_store_tests.rs b/crates/openhuman-core/src/artifacts/tiny_store_tests.rs
index 33579c4d51..ce46f6e645 100644
--- a/crates/openhuman-core/src/artifacts/tiny_store_tests.rs
+++ b/crates/openhuman-core/src/artifacts/tiny_store_tests.rs
@@ -212,6 +212,7 @@ async fn missing_artifact_storage_binding_does_not_fall_back_to_ambient_records(
FileRoots::new(&files),
None,
None,
+ &context_b,
None,
None,
);