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(attachments): drop mime hints from access scope
Steven Enamakelf18a92064a71
diff --git a/crates/openhuman-core/src/agent/harness/graph.rs b/crates/openhuman-core/src/agent/harness/graph.rsindex a3eafc8f8e..29ab4c31b3 100644--- a/crates/openhuman-core/src/agent/harness/graph.rs+++ b/crates/openhuman-core/src/agent/harness/graph.rs@@ -122,7 +122,6 @@ pub(crate) async fn run_channel_turn_via_graph(Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel { .. })),workspace: workspace.clone(),- ..Default::default()};row.content =crate::attachments::stage(&row.content, "channel", config, &scope).await?;diff --git a/crates/openhuman-core/src/attachments/mod.rs b/crates/openhuman-core/src/attachments/mod.rsindex 7c7c94fb46..50aa36c312 100644--- a/crates/openhuman-core/src/attachments/mod.rs+++ b/crates/openhuman-core/src/attachments/mod.rs@@ -23,9 +23,6 @@ pub(crate) mod provider;pub(crate) struct AttachmentAccessScope {pub(crate) external_channel: bool,pub(crate) workspace: Option<PathBuf>,- /// MIME hints captured from typed transcript blocks before the owner- /// request adapter resolves their source strings.- pub(crate) mime_hints: std::collections::HashMap<String, String>,}const REQUEST_SCOPE_KEY: &str = "__openhuman_attachment_access_scope";@@ -65,7 +62,6 @@ pub(crate) fn take_request_scope(metadata: &mut serde_json::Value) -> Attachment.get("workspace").and_then(serde_json::Value::as_str).map(PathBuf::from),- mime_hints: Default::default(),}}@@ -475,7 +471,6 @@ pub(crate) async fn delegation_prompt(let scope = AttachmentAccessScope {external_channel: false,workspace: workspace.map(|workspace| workspace.root.clone()),- mime_hints: Default::default(),};stage(&prompt, "delegation", &config, &scope).await}@@ -514,7 +509,6 @@ pub(crate) async fn has_resolvable_image(let scope = AttachmentAccessScope {external_channel: false,workspace: workspace.map(|workspace| workspace.root.clone()),- mime_hints: Default::default(),};for path in paths {let path = legacy::migrate_path(&config, &path, &scope)@@ -612,7 +606,6 @@ pub(crate) async fn stage_turn(Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel { .. })),workspace: workspace.map(|workspace| workspace.root.clone()),- mime_hints: Default::default(),};stage(message, thread.unwrap_or("direct"), &config, &scope).await}diff --git a/crates/openhuman-core/src/attachments/mod_access_tests.rs b/crates/openhuman-core/src/attachments/mod_access_tests.rsindex d52202c6b1..06489961d9 100644--- a/crates/openhuman-core/src/attachments/mod_access_tests.rs+++ b/crates/openhuman-core/src/attachments/mod_access_tests.rs@@ -199,7 +199,6 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {&AttachmentAccessScope {external_channel: false,workspace: Some(root),- ..Default::default()},).awaitdiff --git a/crates/openhuman-core/src/attachments/mod_tests.rs b/crates/openhuman-core/src/attachments/mod_tests.rsindex 8e4b82a08e..b14493988b 100644--- a/crates/openhuman-core/src/attachments/mod_tests.rs+++ b/crates/openhuman-core/src/attachments/mod_tests.rs@@ -58,7 +58,6 @@ async fn legacy_migration_does_not_grant_private_file_or_disabled_image_access()let external_scope = AttachmentAccessScope {external_channel: true,workspace: None,- ..Default::default()};assert!(legacy::migrate_from(&cfg, source.to_str().unwrap(), &stash, &external_scope)@@ -413,7 +412,6 @@ async fn explicit_workspace_wins_over_config_action_dir() {let scope = AttachmentAccessScope {external_channel: false,workspace: Some(scoped.clone()),- ..Default::default()};let attachment = save(&config, "thread", "file", "text/plain", b"original", &scope).awaitdiff --git a/crates/openhuman-core/src/attachments/provider_owner.rs b/crates/openhuman-core/src/attachments/provider_owner.rsindex 128e5fe6bb..4c9bbb9932 100644--- a/crates/openhuman-core/src/attachments/provider_owner.rs+++ b/crates/openhuman-core/src/attachments/provider_owner.rs@@ -39,12 +39,7 @@ pub(super) fn wrap(let model = MediaRequestModel::new(inner,request_config,- |_, request| {- let mime_hints = typed_mime_hints(request);- let mut scope = super::super::take_request_scope(&mut request.metadata);- scope.mime_hints = mime_hints;- Ok(scope)- },+ |_, request| Ok(super::super::take_request_scope(&mut request.metadata)),host.clone(),extractor,)@@ -99,19 +94,15 @@ impl MediaSourceResolver<AttachmentAccessScope> for AttachmentModel {.or_else(|| tinyagents_harness::multimodal::mime::detect_image_mime(Some(std::path::Path::new(&path)),&bytes,- scope.mime_hints.get(source).map(String::as_str),+ None,)).ok_or_else(|| "image attachment type cannot be determined".to_string())?;} else if mime == "application/octet-stream" {- mime = scope- .mime_hints- .get(source)- .cloned()- .or_else(|| tinyagents_harness::multimodal::mime::detect_file_mime(+ mime = tinyagents_harness::multimodal::mime::detect_file_mime(Some(std::path::Path::new(&path)),&bytes,None,- ))+ ).unwrap_or(mime);}let mut resolved = ResolvedMedia::new(ResolvedAttachment {@@ -252,37 +243,6 @@ impl MediaHistoryFallback<AttachmentAccessScope> for AttachmentModel {}}-fn typed_mime_hints(request: &ModelRequest) -> std::collections::HashMap<String, String> {- let mut hints = std::collections::HashMap::new();- for message in &request.messages {- let Message::User(user) = message else { continue };- for block in &user.content {- match block {- ContentBlock::Image(image) => {- if let Some(mime) = &image.mime_type {- hints.insert(image.url.clone(), mime.clone());- }- }- ContentBlock::Audio(media)- | ContentBlock::Video(media)- | ContentBlock::Document(media) => {- let (source, mime) = match media {- MediaRef::Path { path, media_type } => (path.clone(), media_type.clone()),- MediaRef::Url { url, media_type } => (url.clone(), media_type.clone()),- MediaRef::Base64 { data, media_type } => (- format!("data:{media_type};base64,{data}"),- Some(media_type.clone()),- ),- };- if let Some(mime) = mime { hints.insert(source, mime); }- }- _ => ()- }- }- }- hints-}-struct OwnedDocumentsExtractor {ctx: Option<std::sync::Weak<crate::core::runtime::CoreContext>>,}diff --git a/crates/openhuman-core/src/attachments/provider_security_tests.rs b/crates/openhuman-core/src/attachments/provider_security_tests.rsindex 4c38d40dda..93f29809a0 100644--- a/crates/openhuman-core/src/attachments/provider_security_tests.rs+++ b/crates/openhuman-core/src/attachments/provider_security_tests.rs@@ -40,7 +40,6 @@ async fn secure_open_rejects_parent_symlink_replaced_after_path_validation() {let scope = AttachmentAccessScope {external_channel: false,workspace: Some(root.clone()),- ..Default::default()};let validated = crate::attachments::resolve_path(&config, "nested/file.png", &scope).awaitdiff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex 9deb01fcc6..67581ab99b 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -492,7 +492,6 @@ pub async fn agent_chat_reply_for(let scope = crate::attachments::AttachmentAccessScope {external_channel: false,workspace: turn_cwd.clone(),- ..Default::default()};let references = crate::attachments::host::stage_host(attachments,diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rsindex f8561dfd78..023d22feb4 100644--- a/crates/openhuman-core/src/threads/ops/crud.rs+++ b/crates/openhuman-core/src/threads/ops/crud.rs@@ -255,7 +255,6 @@ async fn message_append_with_config(Some(crate::security::turn_origin::AgentTurnOrigin::ExternalChannel { .. })),workspace: Some(workspace.clone()),- ..Default::default()};let path = crate::attachments::resolve_path(config, &file.path, &scope).awaitdiff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rsindex 7fa415f73c..8251e45ff4 100644--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs@@ -214,7 +214,6 @@ async fn start_chat_inner(&crate::attachments::AttachmentAccessScope {external_channel: false,workspace: Some(workspace),- ..Default::default()},).await