Skip to content

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

refactor(attachments): move attachments module out of agent

Steven Enamakel8936254f141b
diff --git a/crates/openhuman-core/src/agent/harness/graph.rs b/crates/openhuman-core/src/agent/harness/graph.rs
index 436c8470a3..d409234a3f 100644
--- a/crates/openhuman-core/src/agent/harness/graph.rs
+++ b/crates/openhuman-core/src/agent/harness/graph.rs
@@ -116,7 +116,7 @@ pub(crate) async fn run_channel_turn_via_graph(
.expect("config loaded for a marker-bearing history row");
let workspace = Some(config.action_dir.clone());
attachment_workspace = workspace.clone();
- let scope = crate::agent::attachments::AttachmentAccessScope {
+ let scope = crate::attachments::AttachmentAccessScope {
external_channel: matches!(
origin.as_ref(),
Some(crate::agent::turn_origin::AgentTurnOrigin::ExternalChannel { .. })
@@ -124,7 +124,7 @@ pub(crate) async fn run_channel_turn_via_graph(
workspace: workspace.clone(),
};
row.content =
- crate::agent::attachments::stage(&row.content, "channel", config, &scope).await?;
+ crate::attachments::stage(&row.content, "channel", config, &scope).await?;
row.parts = None;
}
}
@@ -249,7 +249,7 @@ fn seed_channel_attachments(
.map(crate::agent::message_convert::chat_message_to_message)
{
context.attachment_placeholders =
- Arc::new(crate::agent::attachments::image_references(&input, &[]));
+ Arc::new(crate::attachments::image_references(&input, &[]));
}
}
diff --git a/crates/openhuman-core/src/agent/harness/graph_tests.rs b/crates/openhuman-core/src/agent/harness/graph_tests.rs
index b59de259d1..3153f27417 100644
--- a/crates/openhuman-core/src/agent/harness/graph_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/graph_tests.rs
@@ -169,10 +169,10 @@ fn channel_current_images_are_available_to_vision_delegation() {
context.attachment_placeholders.as_ref(),
&vec!["[IMAGE:uploads/thread/image.png]".to_string()]
);
- assert!(crate::agent::attachments::should_forward_parent_images(
+ assert!(crate::attachments::should_forward_parent_images(
"describe the image"
));
- assert!(!crate::agent::attachments::should_forward_parent_images(
+ assert!(!crate::attachments::should_forward_parent_images(
"[IMAGE:uploads/explicit.png]"
));
}
diff --git a/crates/openhuman-core/src/agent/message_convert.rs b/crates/openhuman-core/src/agent/message_convert.rs
index c502bf4e28..f10f85f018 100644
--- a/crates/openhuman-core/src/agent/message_convert.rs
+++ b/crates/openhuman-core/src/agent/message_convert.rs
@@ -99,17 +99,17 @@ pub(crate) fn chat_message_to_message(msg: &TranscriptMessage) -> Message {
/// [`user_text_with_markers`] gives back exactly the text that came in. Text
/// without a ready marker is a plain text message, byte for byte.
pub(crate) fn user_message_from_text(text: &str) -> Message {
- if !crate::agent::attachments::parse(text).1.is_empty() {
+ if !crate::attachments::parse(text).1.is_empty() {
let mut content = Vec::new();
- for segment in crate::agent::attachments::segments(text) {
+ for segment in crate::attachments::segments(text) {
let attachment = match segment {
- crate::agent::attachments::Segment::Text(text) => {
+ crate::attachments::Segment::Text(text) => {
if let Message::User(user) = user_message_from_text(&text) {
content.extend(user.content);
}
continue;
}
- crate::agent::attachments::Segment::Attachment(file) => file,
+ crate::attachments::Segment::Attachment(file) => file,
};
content.push(ContentBlock::Text(attachment.description()));
let media = MediaRef::Path {
@@ -207,7 +207,7 @@ pub(crate) fn user_text_with_markers(msg: &Message) -> String {
/// is empty or malformed is kept verbatim as text. Local references are
/// resolved by the host model decorator before provider serialization.
fn user_content_blocks(text: String) -> Vec<ContentBlock> {
- if !crate::agent::attachments::parse(&text).1.is_empty() {
+ if !crate::attachments::parse(&text).1.is_empty() {
if let Message::User(user) = user_message_from_text(&text) {
return user.content;
}
diff --git a/crates/openhuman-core/src/agent/message_convert_tests.rs b/crates/openhuman-core/src/agent/message_convert_tests.rs
index 3b65b50c94..729948587a 100644
--- a/crates/openhuman-core/src/agent/message_convert_tests.rs
+++ b/crates/openhuman-core/src/agent/message_convert_tests.rs
@@ -11,7 +11,7 @@ fn durable_upload_parts_survive_message_row_replay_without_inline_payloads() {
("video.mp4", "video/mp4"),
("archive.zip", "application/zip"),
] {
- let attachment = crate::agent::attachments::Attachment {
+ let attachment = crate::attachments::Attachment {
path: format!("uploads/thread/id/{name}"),
name: name.into(),
mime: mime.into(),
diff --git a/crates/openhuman-core/src/agent/mod.rs b/crates/openhuman-core/src/agent/mod.rs
index 75cb276547..a7bbc9d4c9 100644
--- a/crates/openhuman-core/src/agent/mod.rs
+++ b/crates/openhuman-core/src/agent/mod.rs
@@ -18,8 +18,7 @@
//! - **[`subagent_host`]**: OpenHuman's planner, executor and persistence
//! adapters for sub-agents driven by the neutral TinyAgents lifecycle.
//! within a parent agent's tool loop, enabling hierarchical delegation.
-pub(crate) mod attachments;
-pub use attachments::host::HostAttachment;
+pub use crate::attachments::HostAttachment;
pub mod bus;
pub mod context;
pub(crate) mod cost;
diff --git a/crates/openhuman-core/src/agent/multimodal.rs b/crates/openhuman-core/src/agent/multimodal.rs
index 60298cf2cd..ebe3580dc4 100644
--- a/crates/openhuman-core/src/agent/multimodal.rs
+++ b/crates/openhuman-core/src/agent/multimodal.rs
@@ -1,6 +1,6 @@
//! Legacy attachment marker compatibility and configuration adapters.
//!
-//! New uploads are handled by `agent::attachments`: originals live beneath
+//! New uploads are handled by `attachments`: originals live beneath
//! the acting workspace and provider bytes are prepared only on request copies.
//! The older stash remains readable so existing conversations can resume.
@@ -14,16 +14,17 @@ use async_trait::async_trait;
use reqwest::Client;
use crate::config::{
- MultimodalConfig, MultimodalFileConfig, build_runtime_proxy_client_with_timeouts,
+ build_runtime_proxy_client_with_timeouts, MultimodalConfig, MultimodalFileConfig,
};
use tinyagents_session::transcript::{TranscriptMessage, TranscriptPart};
use tinyagents_harness::multimodal::{
- self as mm, BlobAttachmentStash,
+ self as mm,
config::{FileLimits, ImageLimits},
markers,
payload::sha256_prefix,
- resolve::{TextExtractor, resolve_file, resolve_image},
+ resolve::{resolve_file, resolve_image, TextExtractor},
+ BlobAttachmentStash,
};
use tinyagents_harness::multimodal::{FilePayload, MultimodalError};
@@ -162,11 +163,6 @@ impl TextExtractor for DocumentsTextExtractor<'_> {
// ── Marker helpers over `TranscriptMessage` ────────────────────────────────────
-/// The base64 payload Ollama's `images` array expects, or `None`.
-pub fn extract_ollama_image_payload(image_ref: &str) -> Option<String> {
- markers::extract_ollama_image_payload(image_ref)
-}
-
/// Count `[IMAGE:…]` markers in the **latest** user message only.
///
/// Earlier versions summed markers across every user-role message in the
@@ -497,14 +493,6 @@ pub async fn stash_image_attachments(message: &str, image_config: &MultimodalCon
// ── Placeholders over `TranscriptMessage` ──────────────────────────────────────
-/// Extract the `[Image: … #att:<id>]` sidecar placeholder tokens from `text`,
-/// in order. Used to forward a user's attached images into a delegated vision
-/// sub-agent's prompt so its turn rehydrates them (the orchestrator itself, on
-/// a non-vision tier, keeps the placeholder as text and never sees the image).
-pub fn extract_image_placeholders_in_text(text: &str) -> Vec<String> {
- markers::extract_image_placeholders_in_text(text)
-}
-
/// True if any message carries an `[Image: … #att:<id>]` sidecar placeholder.
pub fn has_image_placeholders(messages: &[TranscriptMessage]) -> bool {
messages.iter().any(row_has_image_placeholders)
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/archetype_delegation.rs b/crates/openhuman-core/src/agent/orchestration/tools/archetype_delegation.rs
index ae2b4778eb..a132d13a71 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/archetype_delegation.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/archetype_delegation.rs
@@ -178,7 +178,7 @@ pub(crate) async fn execute_archetype_delegation_with_live_parent(
)));
}
let prompt = render_structured_handoff(&raw_prompt, &args);
- let prompt = match crate::agent::attachments::delegation_prompt(
+ let prompt = match crate::attachments::delegation_prompt(
&run_context.dispatch_ctx(),
&prompt,
&args,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs
index 38790dabf8..2c63c9ed4d 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs
@@ -366,7 +366,7 @@ pub(crate) async fn execute_collapsed_delegation_with_live_parent(
)));
}
let prompt = render_structured_handoff(&raw_prompt, &args);
- let prompt = match crate::agent::attachments::delegation_prompt(
+ let prompt = match crate::attachments::delegation_prompt(
&run_context.dispatch_ctx(),
&prompt,
&args,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
index 20f6a23b95..461e45fb0b 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs
@@ -232,7 +232,7 @@ pub(crate) async fn dispatch_subagent_with_live_parent(
definition.model.resolve(parent_model)
}
};
- if crate::agent::attachments::should_forward_parent_images(prompt)
+ if crate::attachments::should_forward_parent_images(prompt)
&& !images.is_empty()
&& (agent_id == "vision_agent"
|| crate::inference::provider::factory::oh_tier_supports_vision(&subagent_model))
@@ -250,7 +250,7 @@ pub(crate) async fn dispatch_subagent_with_live_parent(
};
if agent_id == "vision_agent" {
- match crate::agent::attachments::has_resolvable_image(
+ match crate::attachments::has_resolvable_image(
&run_context.dispatch_ctx(),
prompt,
parent_workspace_descriptor.as_ref(),
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs
index 26e8027098..d1ad11d8ff 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs
@@ -34,7 +34,7 @@ impl OpenHumanSessionHost {
self.host_env.core = crate::core::runtime::DispatchCtx::ambient().downgrade();
}
self.ensure_runtime_session()?;
- let staged = crate::agent::attachments::stage_turn(
+ let staged = crate::attachments::stage_turn(
user_message,
self.runtime_config.as_deref(),
self.workspace_descriptor.as_ref(),
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
index 78a70c3ba4..ae501bba7e 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
@@ -455,7 +455,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
_state: &(),
request: &mut ModelRequest,
) -> TaResult<()> {
- crate::agent::attachments::attach_request_scope(request, &context.data);
+ crate::attachments::attach_request_scope(request, &context.data);
Ok(())
}
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context_tests.rs
index bb84b548ca..da8a2bc1db 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context_tests.rs
@@ -26,7 +26,7 @@ async fn attachment_scope_is_request_local_and_contains_only_typed_authority() {
.expect("scope carrier is installed");
let mut provider_metadata = request.metadata.clone();
- let scope = crate::agent::attachments::take_request_scope(&mut provider_metadata);
+ let scope = crate::attachments::take_request_scope(&mut provider_metadata);
assert!(scope.external_channel);
assert_eq!(scope.workspace.as_deref(), Some(root.as_path()));
assert_eq!(provider_metadata, serde_json::json!({"preserved": true}));
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs b/crates/openhuman-core/src/agent/tinyagents/turn_models.rs
index b4e9b2ce14..7a98f77e2c 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_models.rs
@@ -140,7 +140,7 @@ fn build_turn_models_crate(
role, config, m, true, thread_id, &egress,
)?;
return Ok(Arc::new(RouteRecordingModel::new(
- crate::agent::attachments::provider::wrap(
+ crate::attachments::provider::wrap(
ctx,
backend,
Arc::new(config.clone()),
@@ -172,7 +172,7 @@ fn build_turn_models_crate(
),
}?;
Ok(Arc::new(RouteRecordingModel::new(
- crate::agent::attachments::provider::wrap(
+ crate::attachments::provider::wrap(
ctx,
model,
Arc::new(config.clone()),
@@ -204,7 +204,7 @@ fn build_turn_models_crate(
}) {
routes.push((
tier.to_string(),
- crate::agent::attachments::provider::wrap_injected(
+ crate::attachments::provider::wrap_injected(
ctx,
custom,
Arc::new(config.clone()),
@@ -232,7 +232,7 @@ fn build_turn_models_crate(
Ok((route_model, provider, resolved_model)) => routes.push((
tier.to_string(),
Arc::new(RouteRecordingModel::new(
- crate::agent::attachments::provider::wrap(
+ crate::attachments::provider::wrap(
ctx,
route_model,
Arc::new(config.clone()),
@@ -260,7 +260,7 @@ fn build_turn_models_crate(
.host_overrides()
.and_then(|local| local.role_models.get("summarization").cloned())
{
- Some(custom) => crate::agent::attachments::provider::wrap_injected(
+ Some(custom) => crate::attachments::provider::wrap_injected(
ctx,
custom,
Arc::new(config.clone()),
@@ -473,7 +473,7 @@ impl TurnModelSource {
{
models.routes.push((
tier.to_owned(),
- crate::agent::attachments::provider::wrap_injected(
+ crate::attachments::provider::wrap_injected(
&source_ctx,
custom.clone(),
source.config.clone(),
@@ -482,7 +482,7 @@ impl TurnModelSource {
}
}
if let Some(custom) = local.role_models.get("summarization") {
- models.summarizer = crate::agent::attachments::provider::wrap_injected(
+ models.summarizer = crate::attachments::provider::wrap_injected(
&source_ctx,
custom.clone(),
source.config.clone(),
@@ -513,12 +513,12 @@ impl TurnModelSource {
);
let (primary, summarizer) = match &self.attachment_config {
Some(config) => (
- crate::agent::attachments::provider::wrap_injected(
+ crate::attachments::provider::wrap_injected(
&self.dispatch_ctx(),
primary,
config.clone(),
),
- crate::agent::attachments::provider::wrap_injected(
+ crate::attachments::provider::wrap_injected(
&self.dispatch_ctx(),
direct.clone(),
config.clone(),
@@ -598,7 +598,7 @@ impl TurnModelSource {
.with_request_temperature(temperature),
);
return Ok(match &self.attachment_config {
- Some(config) => crate::agent::attachments::provider::wrap_injected(
+ Some(config) => crate::attachments::provider::wrap_injected(
&self.dispatch_ctx(),
summarizer,
config.clone(),
@@ -612,7 +612,7 @@ impl TurnModelSource {
.model_for("summarization")
.or_else(|| local.model_for(&cn.role))
}) {
- return Ok(crate::agent::attachments::provider::wrap_injected(
+ return Ok(crate::attachments::provider::wrap_injected(
&cn.ctx(),
custom,
cn.config.clone(),
@@ -639,7 +639,7 @@ impl TurnModelSource {
thread_id,
&crate::security::egress::EgressLedger::none(),
)
- .map(|(inner, _)| crate::agent::attachments::provider::wrap(&cn.ctx(), inner, cn.config.clone(), model, "openhuman"));
+ .map(|(inner, _)| crate::attachments::provider::wrap(&cn.ctx(), inner, cn.config.clone(), model, "openhuman"));
}
let built = match cn.primary_override.as_deref() {
Some(ps) => {
@@ -671,7 +671,7 @@ impl TurnModelSource {
.and_then(|p| p.model.as_deref())
.unwrap_or(model)
.to_owned();
- crate::agent::attachments::provider::wrap(
+ crate::attachments::provider::wrap(
&cn.ctx(),
inner,
cn.config.clone(),
diff --git a/crates/openhuman-core/src/attachments/host_tests.rs b/crates/openhuman-core/src/attachments/host_tests.rs
index d90991643c..740ed6d4a6 100644
--- a/crates/openhuman-core/src/attachments/host_tests.rs
+++ b/crates/openhuman-core/src/attachments/host_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::agent::attachments::parse;
+use crate::attachments::parse;
use tinyinference_llm::message::{ContentBlock, Message};
const PNG: &[u8] = b"\x89PNG\r\n\x1a\n\0\0\0\rIHDRpixels";
diff --git a/crates/openhuman-core/src/attachments/mod.rs b/crates/openhuman-core/src/attachments/mod.rs
index e5a97588a9..b506afb514 100644
--- a/crates/openhuman-core/src/attachments/mod.rs
+++ b/crates/openhuman-core/src/attachments/mod.rs
@@ -13,6 +13,7 @@ use crate::config::Config;
use crate::security::SecurityPolicy;
pub(crate) mod host;
+pub use host::HostAttachment;
pub(crate) mod legacy;
pub(crate) mod provider;
diff --git a/crates/openhuman-core/src/attachments/provider.rs b/crates/openhuman-core/src/attachments/provider.rs
index ad271ef555..eaf645e8f1 100644
--- a/crates/openhuman-core/src/attachments/provider.rs
+++ b/crates/openhuman-core/src/attachments/provider.rs
@@ -411,11 +411,9 @@ fn is_local_reference(source: &str) -> bool {
windows_drive_path || url::Url::parse(source).is_err()
}
-#[path = "provider_open.rs"]
-pub(crate) mod open;
#[cfg(any(test, windows))]
-use open::normalize_windows_path_for_comparison;
-use open::secure_open;
+use crate::security::secure_open::normalize_windows_path_for_comparison;
+use crate::security::secure_open::secure_open;
#[async_trait]
impl ChatModel<()> for AttachmentModel {
diff --git a/crates/openhuman-core/src/attachments/provider_security_tests.rs b/crates/openhuman-core/src/attachments/provider_security_tests.rs
index 5da1265398..93f29809a0 100644
--- a/crates/openhuman-core/src/attachments/provider_security_tests.rs
+++ b/crates/openhuman-core/src/attachments/provider_security_tests.rs
@@ -41,7 +41,7 @@ async fn secure_open_rejects_parent_symlink_replaced_after_path_validation() {
external_channel: false,
workspace: Some(root.clone()),
};
- let validated = crate::agent::attachments::resolve_path(&config, "nested/file.png", &scope)
+ let validated = crate::attachments::resolve_path(&config, "nested/file.png", &scope)
.await
.unwrap();
let canonical_root = tokio::fs::canonicalize(&root).await.unwrap();
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
index ad3837da4f..2f19a4f7f5 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
@@ -489,11 +489,11 @@ pub async fn agent_chat_reply_for(
}
None => config.clone(),
};
- let scope = crate::agent::attachments::AttachmentAccessScope {
+ let scope = crate::attachments::AttachmentAccessScope {
external_channel: false,
workspace: turn_cwd.clone(),
};
- let references = crate::agent::attachments::host::stage_host(
+ let references = crate::attachments::host::stage_host(
attachments,
turn_session_id.unwrap_or("direct"),
&staging_config,
diff --git a/crates/openhuman-core/src/lib.rs b/crates/openhuman-core/src/lib.rs
index 5083a8056d..19680e9a4c 100644
--- a/crates/openhuman-core/src/lib.rs
+++ b/crates/openhuman-core/src/lib.rs
@@ -9,7 +9,7 @@
//! Business logic lives one directory per domain family under `src/`, listed
//! below in the order they are declared (module declarations are kept
//! alphabetical, with the `rpc` re-export sitting between `platform` and
-//! `runtime` — keep new modules sorted the same way): `agent`, `agent_registry`, `api`, `artifacts`,
+//! `runtime` — keep new modules sorted the same way): `agent`, `agent_registry`, `api`, `artifacts`, `attachments`,
//! `channels`, `config`, `core`, `cron`, `desktop`, `flows` (feature
//! `flows`), `hooks`, `hosting` (feature `hosting`),
//! `inference`, `integrations`,
@@ -56,6 +56,7 @@ pub mod agent;
pub mod agent_registry;
pub mod agent_runs;
pub mod artifacts;
+pub mod attachments;
pub mod backend;
pub mod channels;
pub mod commands;
diff --git a/crates/openhuman-core/src/mcp/ui/tools.rs b/crates/openhuman-core/src/mcp/ui/tools.rs
index ecac08f51e..18d8077529 100644
--- a/crates/openhuman-core/src/mcp/ui/tools.rs
+++ b/crates/openhuman-core/src/mcp/ui/tools.rs
@@ -116,7 +116,7 @@ pub async fn read_confined(
) -> Result<String, String> {
ctx.spawn_blocking(move || {
use std::io::Read;
- let file = crate::agent::attachments::provider::open::secure_open(&resolved, &root)
+ let file = crate::security::secure_open::secure_open(&resolved, &root)
.map_err(|error| {
tracing::debug!(?error, "[mcp_ui] show_ui refused the file open");
"the file is not inside the workspace or a skill bundle".to_string()
diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.md
index 7b88864764..b1bd7c3710 100644
--- a/crates/openhuman-core/src/modules/README.md
+++ b/crates/openhuman-core/src/modules/README.md
@@ -433,7 +433,7 @@ loadable:
`resolve` and `RuntimeCallError` from `modules::runtime` so `runtime/`
compiles without the gate; wallet, Web3, and x402 adapters use `wallet.rs`;
`tools/impl/document`, `tools/impl/presentation`,
- `agent/multimodal.rs` and `agent/attachments/` use `documents.rs`;
+ `agent/multimodal.rs` and `attachments/` use `documents.rs`;
`voice/always_on` and `voice/streaming.rs` use `voice.rs`;
`tools/impl/browser/` and `desktop/control/` use the TinyComputer files;
`integrations/composio/module_client.rs` uses [`connectors.rs`](./connectors.rs);
diff --git a/crates/openhuman-core/src/security/mod.rs b/crates/openhuman-core/src/security/mod.rs
index b7193b1d99..39cc9764f7 100644
--- a/crates/openhuman-core/src/security/mod.rs
+++ b/crates/openhuman-core/src/security/mod.rs
@@ -21,36 +21,37 @@ pub mod policy;
pub mod prompt_injection;
pub mod scrub;
pub mod secret_storage;
+pub(crate) mod secure_open;
#[allow(unused_imports)]
pub use self::secret_storage::SecretStore;
#[allow(unused_imports)]
pub use audit::{
- get_or_create_workspace_audit_logger, AuditEvent, AuditEventType, AuditLogger,
- CommandExecutionLog,
+ AuditEvent, AuditEventType, AuditLogger, CommandExecutionLog,
+ get_or_create_workspace_audit_logger,
};
pub use core::*;
#[allow(unused_imports)]
pub use egress::{
- emit_external_transfer, enforce_egress, local_only_blocks, local_only_tool_block, DataKind,
- EgressDescriptor, EgressReason, IdentificationRisk,
+ DataKind, EgressDescriptor, EgressReason, IdentificationRisk, emit_external_transfer,
+ enforce_egress, local_only_blocks, local_only_tool_block,
};
pub use ops as rpc;
pub use ops::*;
-pub use policy::validate_path_within_root;
#[allow(unused_imports)]
pub use policy::AutonomyLevel;
#[allow(unused_imports)]
pub use policy::GateDecision;
pub use policy::SecurityPolicy;
pub use policy::ToolOperation;
-pub use policy::{ensure_openhuman_scratch_dir, openhuman_scratch_dir};
+pub use policy::validate_path_within_root;
#[allow(unused_imports)]
pub use policy::{TrustedAccess, TrustedRoot};
+pub use policy::{ensure_openhuman_scratch_dir, openhuman_scratch_dir};
#[allow(unused_imports)]
pub use {
- pairing::ensure_core_rpc_token_for_bind, pairing::is_public_bind, pairing::CoreBindTokenError,
- pairing::CORE_TOKEN_ENV_VAR,
+ pairing::CORE_TOKEN_ENV_VAR, pairing::CoreBindTokenError,
+ pairing::ensure_core_rpc_token_for_bind, pairing::is_public_bind,
};
pub use schemas::{
diff --git a/crates/openhuman-core/src/security/secure_open.rs b/crates/openhuman-core/src/security/secure_open.rs
index bf8a982dae..3241e0e72c 100644
--- a/crates/openhuman-core/src/security/secure_open.rs
+++ b/crates/openhuman-core/src/security/secure_open.rs
@@ -133,7 +133,7 @@ pub(crate) fn secure_open(
}
#[cfg(any(windows, test))]
-pub(super) fn normalize_windows_path_for_comparison(value: &str) -> String {
+pub(crate) fn normalize_windows_path_for_comparison(value: &str) -> String {
value
.strip_prefix("\\\\?\\UNC\\")
.map(|unc| format!("\\\\{unc}"))
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index 3745f2f5ea..c12079a638 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -206,12 +206,12 @@ async fn message_append_with_config(
if request.message.sender == "user" {
let raw_upload = request.message.content.contains("[IMAGE:")
|| request.message.content.contains("[FILE:");
- let durable_files = crate::agent::attachments::parse(&request.message.content).1;
+ let durable_files = crate::attachments::parse(&request.message.content).1;
let durable_upload = !durable_files.is_empty();
// Raw and durable uploads both live under the thread's working folder,
// where the turn reads them (#7714).
let workspace = if raw_upload || durable_upload {
- crate::agent::attachments::thread_action_dir(
+ crate::attachments::thread_action_dir(
ctx,
config,
persistence_dir,
@@ -249,14 +249,14 @@ async fn message_append_with_config(
));
}
for file in &durable_files {
- let scope = crate::agent::attachments::AttachmentAccessScope {
+ let scope = crate::attachments::AttachmentAccessScope {
external_channel: matches!(
origin,
Some(crate::agent::turn_origin::AgentTurnOrigin::ExternalChannel { .. })
),
workspace: Some(workspace.clone()),
};
- let path = crate::agent::attachments::resolve_path(config, &file.path, &scope)
+ let path = crate::attachments::resolve_path(config, &file.path, &scope)
.await
.map_err(|error| {
ThreadsError::Message(format!("validate user attachment: {error}"))
@@ -298,7 +298,7 @@ async fn message_append_with_config(
"user upload bytes require attachment markers before persistence".into(),
));
}
- request.message.content = crate::agent::attachments::stage_turn(
+ request.message.content = crate::attachments::stage_turn(
&request.message.content,
Some(config),
Some(&tinytools::WorkspaceDescriptor::new(workspace)),
diff --git a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs
index fd608e7e8f..c0a09c5d82 100644
--- a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs
@@ -73,7 +73,7 @@ async fn user_append_stages_original_strips_upload_bytes_and_reuses_returned_con
.value
.data
.unwrap();
- let (_, files) = crate::agent::attachments::parse(&first.content);
+ let (_, files) = crate::attachments::parse(&first.content);
assert_eq!(files.len(), 1);
assert_eq!(
tokio::fs::read(config.action_dir.join(&files[0].path))
@@ -98,7 +98,7 @@ async fn user_append_stages_original_strips_upload_bytes_and_reuses_returned_con
.data
.unwrap();
assert_eq!(second.content, first.content);
- let staged = crate::agent::attachments::stage_turn(
+ let staged = crate::attachments::stage_turn(
&second.content,
Some(&config),
None,
@@ -162,7 +162,7 @@ async fn rejected_upload_never_appends_a_message() {
#[tokio::test]
async fn external_origin_cannot_reuse_an_existing_attachment_marker() {
let (_temp, config) = setup().await;
- let staged = crate::agent::attachments::stage_turn(
+ let staged = crate::attachments::stage_turn(
"[IMAGE:data:image/png;base64,iVBORw0KGgo=]",
Some(&config),
None,
@@ -320,7 +320,7 @@ async fn raw_append_stages_in_the_bound_thread_folder() {
.value
.data
.unwrap();
- let (_, files) = crate::agent::attachments::parse(&staged.content);
+ let (_, files) = crate::attachments::parse(&staged.content);
assert_eq!(files.len(), 1);
assert!(folder.join(&files[0].path).is_file());
assert!(!config.action_dir.join("uploads").exists());
diff --git a/crates/openhuman-core/src/web_chat/README.md b/crates/openhuman-core/src/web_chat/README.md
index 6750b5fbf6..e25f0292a1 100644
--- a/crates/openhuman-core/src/web_chat/README.md
+++ b/crates/openhuman-core/src/web_chat/README.md
@@ -53,7 +53,7 @@ subscriber all listen to.
model, temperature, locale or queue-mode overrides.
2. `start_chat` stages `[FILE:...]` and `[IMAGE:...]` markers through
- `agent::attachments::stage` first. A multi-megabyte base64 blob must never
+ `attachments::stage` first. A multi-megabyte base64 blob must never
reach prompt-injection scanning or persistence. It then runs
`security::prompt_injection::enforce_prompt_input`; a block comes back as
`StartChatError::Guardrail` with a verdict, score and reasons so the
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index cb2531c0b4..7a8740256f 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -199,7 +199,7 @@ async fn start_chat_inner(
})?;
// Stage where the turn will read: the thread's working folder when
// one is bound (`run_task` applies the same folder), else action_dir.
- let workspace = crate::agent::attachments::thread_action_dir(
+ let workspace = crate::attachments::thread_action_dir(
ctx,
&config,
&config.workspace_dir,
@@ -207,11 +207,11 @@ async fn start_chat_inner(
)
.await
.map_err(|error| StartChatError::Other(format!("upload could not be saved: {error}")))?;
- crate::agent::attachments::stage(
+ crate::attachments::stage(
&message,
&thread_id,
&config,
- &crate::agent::attachments::AttachmentAccessScope {
+ &crate::attachments::AttachmentAccessScope {
external_channel: false,
workspace: Some(workspace),
},
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index 1e010593ee..f9b8771f74 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -678,7 +678,7 @@ The thread JSONL store moved to `tinyagents_session::threads` (`vendor/tinyagent
| 16.1.27 | Scoped builtin command environments | RI | `crates/openhuman-embed/tests/tool_environment.rs`, `crates/openhuman-embed/tests/tool_hook_context.rs` | ✅ | Overlapping subprocess maps exclude host inheritance on Unix; a real shell receives its turn's variables while excluding host HOME and preserving command-owned runtime/security additions |
| 16.1.20 | Host turn observer privacy and runtime propagation | RI | `crates/openhuman-embed/tests/turn_observers.rs`, `crates/openhuman-embed/tests/observed_turns.rs` | ✅ | Sanitized terminal failures, opt-in payloads, root runtime scope propagation, real model/tool callbacks and answering-model usage |
| 16.1.28 | Host-installed key stores and default in-memory library secrets | RU+RI+MS | `crates/openhuman-core/src/security/secret_storage/encrypted_file_backend/key_source_tests.rs`, `crates/openhuman-core/src/security/secret_storage/store_tests_2_tests.rs`, `crates/openhuman-core/src/security/secret_storage/memory_backend_tests.rs`, `crates/openhuman-rpc/src/keyring/*_tests.rs`, `crates/openhuman-embed/tests/headless_keys.rs`, `tests/keyring_headless_e2e.rs` | 🟡 | In-memory CRUD, isolation and threaded access, no-file embed defaults, installed-provider precedence, denied-source preservation, private workspace-key creation/reuse, and explicit encrypted-store restart persistence are automated. Existing native desktop profile decryption remains a cross-platform release smoke check. |
-| 16.1.29 | Host-supplied turn attachments (`Turn::attach`) | RU+RI | `crates/openhuman-core/src/agent/attachments/host_tests.rs`, `crates/openhuman-embed/tests/turn_attachments.rs`, `crates/openhuman-embed/tests/orchestrator_attachments.rs` | ✅ | Bytes are staged under the turn's thread and lead the message in order as image/document blocks with no payload in the reference; generic MIME types are sniffed; image/file count, size and empty files are refused before any model call; a caller-built orchestrator refuses with `attachments_unsupported`; `Debug` prints no payload |
+| 16.1.29 | Host-supplied turn attachments (`Turn::attach`) | RU+RI | `crates/openhuman-core/src/attachments/host_tests.rs`, `crates/openhuman-embed/tests/turn_attachments.rs`, `crates/openhuman-embed/tests/orchestrator_attachments.rs` | ✅ | Bytes are staged under the turn's thread and lead the message in order as image/document blocks with no payload in the reference; generic MIME types are sniffed; image/file count, size and empty files are refused before any model call; a caller-built orchestrator refuses with `attachments_unsupported`; `Debug` prints no payload |
| 16.1.30 | Steering a running turn | RU+RI | `crates/openhuman-embed/tests/turn_steering.rs`, `crates/openhuman-embed/src/turn_steering_tests.rs` | ✅ | A steer sent during a plain chat turn's only model call follows the draft answer and earns one more call in the same turn; a steer queued before send reaches the first call; steers the turn did not apply come back on the outcome or, after a failure or cancellation, from the handle; a steer after the turn ended is refused with its text |
diff --git a/scripts/ci/storage-bypass-baseline.json b/scripts/ci/storage-bypass-baseline.json
index 072c792096..f2d912f913 100644
--- a/scripts/ci/storage-bypass-baseline.json
+++ b/scripts/ci/storage-bypass-baseline.json
@@ -1,35 +1,35 @@
[
{
"rule": "json-write",
- "path": "crates/openhuman-core/src/agent/attachments/legacy.rs",
+ "path": "crates/openhuman-core/src/attachments/legacy.rs",
"line": 143,
"text": "let mut file = tokio::fs::OpenOptions::new()",
"occurrence": 1
},
{
"rule": "json-write",
- "path": "crates/openhuman-core/src/agent/attachments/mod.rs",
+ "path": "crates/openhuman-core/src/attachments/mod.rs",
"line": 288,
"text": "let mut file = tokio::fs::OpenOptions::new()",
"occurrence": 1
},
{
"rule": "json-write",
- "path": "crates/openhuman-core/src/agent/attachments/provider_cache.rs",
+ "path": "crates/openhuman-core/src/attachments/provider_cache.rs",
"line": 163,
"text": "let mut file = tokio::fs::OpenOptions::new()",
"occurrence": 1
},
{
"rule": "json-write",
- "path": "crates/openhuman-core/src/agent/attachments/provider_open.rs",
+ "path": "crates/openhuman-core/src/security/secure_open.rs",
"line": 20,
"text": "let filesystem_root = std::fs::OpenOptions::new()",
"occurrence": 1
},
{
"rule": "json-write",
- "path": "crates/openhuman-core/src/agent/attachments/provider_source.rs",
+ "path": "crates/openhuman-core/src/attachments/provider_source.rs",
"line": 232,
"text": "let mut file = tokio::fs::OpenOptions::new()",
"occurrence": 1
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 041b752d57..6562f27fdf 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 041b752d5761b214d08a827e4ee4bb19da651697
+Subproject commit 6562f27fdfbb7fa2fa6e6160432106cc610f70b4