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(artifacts): update artifact storage logic
Steven Enamakel59fa325aeceb
diff --git a/crates/openhuman-core/src/artifacts/production_tests.rs b/crates/openhuman-core/src/artifacts/production_tests.rsindex de88fffcc0..ac0e69df93 100644--- a/crates/openhuman-core/src/artifacts/production_tests.rs+++ b/crates/openhuman-core/src/artifacts/production_tests.rs@@ -92,7 +92,7 @@ async fn a_new_artifact_shares_one_id_and_one_file_between_card_and_record() {let file = record.latest().unwrap().file.clone().unwrap();assert_eq!(file.key, format!("artifacts/files/{id}/v1.pptx"));let ctx = crate::core::runtime::DispatchCtx::process_default();- let file_store = super::super::tiny_store::file_store_for(&workspace, &ctx).unwrap();+ let file_store = production.file_store.as_ref().unwrap();assert_eq!(file_store.read(&file.key).await.unwrap(), b"deck-v1");assert_eq!(files_in(&files),@@ -122,7 +122,14 @@ async fn a_revision_reuses_the_id_and_file_and_keeps_the_history() {);// Each version still holds what it was.let ctx = crate::core::runtime::DispatchCtx::process_default();- let file_store = super::super::tiny_store::file_store_for(&workspace, &ctx).unwrap();+ let (_, file_store) = super::super::tiny_store::artifacts_service_with_file_store(+ &workspace,+ FileRoots::new(&files),+ None,+ None,+ &ctx,+ );+ let file_store = file_store.unwrap();let key_of = |n: u32| record.version(n).unwrap().file.clone().unwrap().key;assert_eq!(file_store.read(&key_of(1)).await.unwrap(), b"deck-v1");assert_eq!(file_store.read(&key_of(2)).await.unwrap(), b"deck-v2!");diff --git a/crates/openhuman-tinyhumans/src/integrations/file_storage/artifact_publisher.rs b/crates/openhuman-tinyhumans/src/integrations/file_storage/artifact_publisher.rsindex abe9d8fa7c..5a758c9750 100644--- a/crates/openhuman-tinyhumans/src/integrations/file_storage/artifact_publisher.rs+++ b/crates/openhuman-tinyhumans/src/integrations/file_storage/artifact_publisher.rs@@ -85,7 +85,7 @@ async fn upload_body(files: &dyn FileStore,record: &ArtifactRecord,version: &ArtifactVersion,-) -> anyhow::Result<(Vec<u8>, String, &'static str)> {+) -> anyhow::Result<(Vec<u8>, String, String)> {if record.holds_file() {let file = version.file@@ -102,16 +102,10 @@ async fn upload_body(Some(ext) => format!("{}.{ext}", file_stem(&record.title)),None => file_stem(&record.title),};- let mime = match file.media_type.as_deref() {- Some("image/png") => "image/png",- Some("image/jpeg") => "image/jpeg",- Some("image/gif") => "image/gif",- Some("image/webp") => "image/webp",- Some("application/pdf") => "application/pdf",- Some("text/plain") => "text/plain",- Some("text/csv") => "text/csv",- _ => mime_for_path(path),- };+ let mime = file+ .media_type+ .clone()+ .unwrap_or_else(|| mime_for_path(path).to_string());return Ok((bytes, name, mime));}let ext = match record.kind {@@ -124,7 +118,8 @@ async fn upload_body(ArtifactKind::Markdown => "text/markdown",ArtifactKind::Html => "text/html",_ => "text/plain",- };+ }+ .to_string();Ok((version.body.clone().into_bytes(), name, mime))}@@ -244,7 +239,7 @@ impl ArtifactPublisher for StorageArtifactPublisher {);let part = reqwest::multipart::Part::bytes(bytes).file_name(filename)- .mime_str(mime)?;+ .mime_str(&mime)?;let visibility = if options.public { "public" } else { "private" };let form = reqwest::multipart::Form::new().part("file", part)