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): expose staged attachment fields publicly
Steven Enamakelc4ab174f2996
diff --git a/crates/openhuman-core/src/threads/attachments.rs b/crates/openhuman-core/src/threads/attachments.rsindex c249edd156..fb2fe63a50 100644--- a/crates/openhuman-core/src/threads/attachments.rs+++ b/crates/openhuman-core/src/threads/attachments.rs@@ -21,6 +21,10 @@ const STORAGE_KEY: &str = "__openhumanStoredAttachments";#[path = "attachments/staged.rs"]mod staged;use staged::*;+pub(crate) use staged::{+ bind_staged_refs, consume_staged_parts, discard_staged_parts, resolve_staged_parts,+ stage_queued_parts, validate_opaque_parts,+};#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]diff --git a/crates/openhuman-core/src/threads/attachments/staged.rs b/crates/openhuman-core/src/threads/attachments/staged.rsindex c7604bdeee..8c03db0098 100644--- a/crates/openhuman-core/src/threads/attachments/staged.rs+++ b/crates/openhuman-core/src/threads/attachments/staged.rs@@ -5,19 +5,19 @@ use tinystoragedrivers::CollectionSpec;#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub(super) struct StagedAttachment {- tenant: crate::core::runtime::Tenant,- thread_id: String,- attachment: StoredAttachment,- expires_at: i64,+ pub(super) tenant: crate::core::runtime::Tenant,+ pub(super) thread_id: String,+ pub(super) attachment: StoredAttachment,+ pub(super) expires_at: i64,#[serde(default, skip_serializing_if = "Option::is_none")]- claim: Option<StagedAttachmentClaim>,+ pub(super) claim: Option<StagedAttachmentClaim>,}#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]#[serde(rename_all = "camelCase")]pub(super) struct StagedAttachmentClaim {- tenant: crate::core::runtime::Tenant,- thread_id: String,+ pub(super) tenant: crate::core::runtime::Tenant,+ pub(super) thread_id: String,message_id: String,part: ContentPart,#[serde(default)]@@ -70,7 +70,7 @@ pub(super) fn get_staged_record(repo: &Repo, id: &str) -> Result<Option<StagedAtpub(super) async fn read_staged_entries(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,requested: &[ContentPart],config: &crate::config::Config,) -> Result<Vec<StoredAttachment>, String> {@@ -108,7 +108,7 @@ pub(super) async fn read_staged_entries(/// paths in the returned row projection.pub(crate) async fn bind_staged_refs(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,config: &crate::config::Config,requested: &[ContentPart],message_id: &str,@@ -126,9 +126,9 @@ pub(crate) async fn bind_staged_refs())}-pub(super) fn claim_staged_refs(+pub(super) async fn claim_staged_refs(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,config: &crate::config::Config,message_id: &str,entries: &[StoredAttachment],@@ -144,8 +144,8 @@ pub(super) fn claim_staged_refs(.ok_or_else(|| "staged attachment reference is missing".to_string())?;let id = staged_doc_id(opaque_id)?;let claim = StagedAttachmentClaim {- tenant: tenant.clone(),- thread_id: thread_id.to_string(),+ pub(super) tenant: tenant.clone(),+ pub(super) thread_id: thread_id.to_string(),message_id: message_id.to_string(),part: entry.part.clone(),canceled: false,@@ -157,11 +157,11 @@ pub(super) fn claim_staged_refs(pub(super) fn claim_staged_record(repo: &Repo,- tenant: &crate::core::runtime::Tenant,- thread_id: &str,+ pub(super) tenant: &crate::core::runtime::Tenant,+ pub(super) thread_id: &str,id: &str,part: &ContentPart,- claim: &StagedAttachmentClaim,+ pub(super) claim: &StagedAttachmentClaim,) -> Result<bool, String> {let id = id.to_string();let tenant = tenant.clone();@@ -227,7 +227,7 @@ pub(super) fn claim_staged_record(/// separate from visible message history until the runner admits the turn.pub(crate) async fn stage_queued_parts(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,input: &[ContentPart],) -> Result<Vec<ContentPart>, String> {if thread_id.is_empty() || input.is_empty() {@@ -276,14 +276,14 @@ pub(crate) async fn stage_queued_parts(.ok_or_else(|| "staged attachment has no opaque reference".to_string())?;let id = staged_doc_id(opaque_id)?;let manifest = StagedAttachment {- tenant: tenant.clone(),- thread_id: thread_id.to_string(),- attachment: StoredAttachment {+ pub(super) tenant: tenant.clone(),+ pub(super) thread_id: thread_id.to_string(),+ pub(super) attachment: StoredAttachment {part: attachment.0.clone(),path: attachment.1,},expires_at,- claim: None,+ pub(super) claim: None,};let body = serde_json::to_value(&manifest).map_err(|error| format!("serialize queued attachment record: {error}"))?;@@ -303,7 +303,7 @@ pub(crate) async fn stage_queued_parts(/// checks pass.pub(crate) async fn resolve_staged_parts(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,requested: &[ContentPart],) -> Result<Vec<ContentPart>, String> {if thread_id.is_empty() || requested.is_empty() {@@ -327,7 +327,7 @@ pub(crate) async fn resolve_staged_parts(pub(super) async fn validate_staged_files(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,config: &crate::config::Config,entries: &[StoredAttachment],) -> Result<(), String> {@@ -384,7 +384,7 @@ pub(super) async fn validate_staged_files(/// Remove staged media for a queue entry that was canceled before execution.pub(crate) async fn discard_staged_parts(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,requested: &[ContentPart],) -> Result<(), String> {let config = ctx@@ -397,7 +397,7 @@ pub(crate) async fn discard_staged_parts(pub(super) async fn discard_staged_entries(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,config: &crate::config::Config,entries: Vec<StoredAttachment>,) -> Result<(), String> {@@ -418,8 +418,8 @@ pub(super) async fn discard_staged_entries(};let id = staged_doc_id(id)?;let cancellation = StagedAttachmentClaim {- tenant: tenant.clone(),- thread_id: thread_id.to_string(),+ pub(super) tenant: tenant.clone(),+ pub(super) thread_id: thread_id.to_string(),message_id: String::new(),part: entry.part.clone(),canceled: true,@@ -445,8 +445,8 @@ pub(super) async fn discard_staged_entries(pub(super) fn cancel_staged_record(repo: &Repo,- tenant: &crate::core::runtime::Tenant,- thread_id: &str,+ pub(super) tenant: &crate::core::runtime::Tenant,+ pub(super) thread_id: &str,id: &str,part: &ContentPart,cancellation: &StagedAttachmentClaim,@@ -507,7 +507,7 @@ pub(super) fn cancel_staged_record(/// that row's private attachment metadata.pub(crate) async fn consume_staged_parts(ctx: &crate::core::runtime::DispatchCtx,- thread_id: &str,+ pub(super) thread_id: &str,requested: &[ContentPart],message_id: &str,) -> Result<(), String> {