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
feat(core): introduce staged native media handling
Steven Enamakelb0f57da59f46
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rsindex ad1a20f825..c7e03eaae1 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs@@ -34,13 +34,14 @@ pub(super) async fn resolve_typed_message(config: &crate::config::Config,envelope: &ChannelInboundEnvelope,thread_id: &str,-) -> Result<Option<Message>, String> {+) -> Result<Option<ResolvedNativeMessage>, String> {if !requires_typed_preparation(envelope) {return Ok(None);}validate_native_parts(&envelope.parts)?;let scope = media_scope(envelope)?;let mut parts = envelope.parts.clone();+ let mut staged_parts = Vec::new();let mut image_count = 0usize;let mut file_count = 0usize;let (max_images, image_mb) = config.multimodal.effective_limits();@@ -132,20 +133,30 @@ pub(super) async fn resolve_typed_message(.content_type.as_deref().ok_or_else(|| "native media has no content type".to_owned())?;- let staged = crate::agent::attachments::store_scoped_channel_media(- config, thread_id, &name, mime, &bytes,+ let staged = crate::threads::attachments::stage_native_channel_part(+ &dispatch,+ thread_id,+ config,+ part,+ &name,+ mime,+ &bytes,)- .await- .map_err(|_| "native media could not be staged safely".to_owned())?;- media.path = Some(staged.path);- media.url = None;- media.local_cache_path = None;- media.opaque_id = None;- media.content_type = Some(staged.mime);- media.size_bytes = Some(staged.size_bytes as u64);+ .await?;+ *part = staged.clone();+ staged_parts.push(staged);}- crate::agent::message_convert::user_message_from_parts("", &parts).map(Some)+ let message = crate::agent::message_convert::user_message_from_parts("", &parts)?;+ Ok(Some(ResolvedNativeMessage {+ message,+ staged_parts,+ }))+}++pub(super) struct ResolvedNativeMessage {+ pub(super) message: Message,+ pub(super) staged_parts: Vec<ContentPart>,}fn media_scope(envelope: &ChannelInboundEnvelope) -> Result<HostVoiceScope, String> {diff --git a/crates/openhuman-core/src/threads/attachments/staged.rs b/crates/openhuman-core/src/threads/attachments/staged.rsindex 2ba7b281a4..48fbc85ec6 100644--- a/crates/openhuman-core/src/threads/attachments/staged.rs+++ b/crates/openhuman-core/src/threads/attachments/staged.rs@@ -334,8 +334,9 @@ pub(crate) async fn stage_native_channel_part(let mut part = input.clone();let media = opaque_media_mut(&mut part).ok_or_else(|| "native attachment kind cannot be staged".to_owned())?;- media.opaque_id = Some(uuid::Uuid::new_v4().simple().to_string());- media.path = None;+ let opaque_id = uuid::Uuid::new_v4().simple().to_string();+ media.opaque_id = Some(opaque_id.clone());+ media.path = Some(format!("openhuman-staged://{opaque_id}"));media.url = None;media.local_cache_path = None;media.content_type = Some(file.mime.clone());@@ -343,10 +344,7 @@ pub(crate) async fn stage_native_channel_part(let tenant = tenant_for(ctx)?;let repo = staged_repo(ctx, &config.workspace_dir)?;- let opaque_id = opaque_media(&part)- .and_then(|media| media.opaque_id.as_deref())- .ok_or_else(|| "native attachment has no opaque reference".to_owned())?;- let id = staged_doc_id(opaque_id)?;+ let id = staged_doc_id(&opaque_id)?;let manifest = StagedAttachment {tenant,thread_id: thread_id.to_owned(),