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
fix(approval): remove unused test file and fix message processor import
Steven Enamakelc7f1a722deb1
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/message.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/message.rsnew file mode 100644index 0000000000..862f927f60--- /dev/null+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/message.rs@@ -0,0 +1,32 @@+//! The runtime's internal message envelope, wrapping a legacy+//! [`traits::ChannelMessage`] with the original TinyChannels inbound+//! envelope (when the message arrived via the relay transport).++use crate::channels::traits;++#[derive(Debug, Clone)]+pub(crate) struct RuntimeChannelMessage {+ pub(crate) message: traits::ChannelMessage,+ pub(crate) inbound_envelope: Option<tinychannels::ChannelInboundEnvelope>,+}++impl RuntimeChannelMessage {+ pub(crate) fn with_inbound_envelope(+ message: traits::ChannelMessage,+ inbound_envelope: tinychannels::ChannelInboundEnvelope,+ ) -> Self {+ Self {+ message,+ inbound_envelope: Some(inbound_envelope),+ }+ }+}++impl From<traits::ChannelMessage> for RuntimeChannelMessage {+ fn from(message: traits::ChannelMessage) -> Self {+ Self {+ message,+ inbound_envelope: None,+ }+ }+}diff --git a/crates/openhuman-core/src/integrations/file_storage/tools/upload.rs b/crates/openhuman-core/src/integrations/file_storage/tools/upload.rsnew file mode 100644index 0000000000..d41a1bcbcb--- /dev/null+++ b/crates/openhuman-core/src/integrations/file_storage/tools/upload.rs@@ -0,0 +1,196 @@+//! `storage_upload_file` — upload a workspace file to managed cloud storage.++use std::path::{Path, PathBuf};+use std::sync::Arc;++use async_trait::async_trait;+use serde_json::{json, Value};++use super::helpers::{mime_for_path, readonly_autonomy_block, resolve_upload_path};+use crate::integrations::IntegrationClient;+use crate::security::SecurityPolicy;+use crate::tools::traits::{PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolResult};+use tinytools::ToolRunContext;++use super::helpers::{action_dir_for_context, FILES_PATH};+use super::types::UploadResponse;++pub struct StorageUploadFileTool {+ client: Arc<IntegrationClient>,+ action_dir: PathBuf,+ security: Arc<SecurityPolicy>,+}++impl StorageUploadFileTool {+ pub fn new(client: Arc<IntegrationClient>, action_dir: PathBuf) -> Self {+ Self::new_with_security(client, action_dir, Arc::new(SecurityPolicy::default()))+ }++ pub fn new_with_security(+ client: Arc<IntegrationClient>,+ action_dir: PathBuf,+ security: Arc<SecurityPolicy>,+ ) -> Self {+ Self {+ client,+ action_dir,+ security,+ }+ }++ async fn run(&self, args: Value, action_dir: &Path) -> anyhow::Result<ToolResult> {+ if let Some(blocked) = readonly_autonomy_block(&self.security) {+ return Ok(blocked);+ }++ let raw_path = match args.get("path").and_then(|v| v.as_str()) {+ Some(p) if !p.trim().is_empty() => p.trim(),+ _ => return Ok(ToolResult::error("path is required")),+ };+ let resolved = match resolve_upload_path(action_dir, raw_path) {+ Ok(p) => p,+ Err(e) => return Ok(ToolResult::error(e)),+ };++ let visibility = match args.get("visibility").and_then(|v| v.as_str()) {+ Some(v) => match super::helpers::validate_visibility(v) {+ Ok(v) => Some(v),+ Err(e) => return Ok(ToolResult::error(e)),+ },+ None => None,+ };+ let ttl_days = match args.get("ttl_days") {+ Some(v) => match v.as_u64() {+ Some(d) if d >= 1 => Some(d),+ _ => return Ok(ToolResult::error("ttl_days must be a positive integer")),+ },+ None => None,+ };++ let bytes = match tokio::fs::read(&resolved).await {+ Ok(b) => b,+ Err(e) => {+ return Ok(ToolResult::error(format!(+ "failed to read {}: {e}",+ resolved.display()+ )))+ }+ };+ let filename = resolved+ .file_name()+ .and_then(|n| n.to_str())+ .unwrap_or("file")+ .to_string();+ let mime = mime_for_path(&resolved);++ tracing::debug!(+ "[file_storage] uploading {} ({} bytes, mime={}, visibility={:?}, ttl_days={:?})",+ resolved.display(),+ bytes.len(),+ mime,+ visibility,+ ttl_days+ );++ let part = match reqwest::multipart::Part::bytes(bytes)+ .file_name(filename.clone())+ .mime_str(mime)+ {+ Ok(p) => p,+ Err(e) => return Ok(ToolResult::error(format!("invalid mime '{mime}': {e}"))),+ };+ let mut form = reqwest::multipart::Form::new().part("file", part);+ if let Some(v) = &visibility {+ form = form.text("visibility", v.clone());+ }+ if let Some(d) = ttl_days {+ form = form.text("ttlDays", d.to_string());+ }++ match self+ .client+ .upload_multipart::<UploadResponse>(FILES_PATH, form)+ .await+ {+ Ok(resp) => {+ let mut lines = vec![format!(+ "Uploaded {} ({} bytes) as file_id {} — visibility {}, expires {}.",+ resp.filename,+ resp.size,+ resp.file_id,+ resp.visibility,+ resp.expires_at.as_deref().unwrap_or("unknown"),+ )];+ if let Some(url) = &resp.public_url {+ lines.push(format!("Public URL: {url}"));+ }+ lines.push(format!("Cost: ${:.4}", resp.cost_usd));+ let payload = json!({+ "file_id": resp.file_id,+ "filename": resp.filename,+ "size": resp.size,+ "content_type": resp.content_type,+ "visibility": resp.visibility,+ "expires_at": resp.expires_at,+ "public_url": resp.public_url,+ "cost_usd": resp.cost_usd,+ });+ Ok(ToolResult::success_with_markdown(payload, lines.join("\n")))+ }+ Err(e) => Ok(ToolResult::error(format!("File upload failed: {e}"))),+ }+ }+}++#[async_trait]+impl Tool for StorageUploadFileTool {+ fn name(&self) -> &str {+ "storage_upload_file"+ }++ fn description(&self) -> &str {+ "Upload a file from the agent workspace to managed cloud file storage and get a \+ file_id (and, for public files, a stable public URL). The path must be inside the \+ agent workspace. Files are billed at S3 rates plus margin (storage for the whole \+ TTL charged upfront on upload). Quota: 1 GiB per user. TTL: 7 days free / up to \+ 1 year on paid plans."+ }++ fn parameters_schema(&self) -> Value {+ json!({+ "type": "object",+ "properties": {+ "path": { "type": "string", "description": "File to upload — absolute or relative to the agent workspace; must resolve inside the workspace" },+ "visibility": { "type": "string", "enum": ["public", "private"], "description": "Default private. Public files get a stable public URL anyone can fetch (egress billed to you)." },+ "ttl_days": { "type": "integer", "minimum": 1, "description": "File lifetime in days (clamped to plan max: 7 free / 365 paid). Default: plan max." }+ },+ "required": ["path"]+ })+ }++ fn permission_level(&self) -> PermissionLevel {+ PermissionLevel::Execute+ }++ fn category(&self) -> ToolCategory {+ ToolCategory::Workflow+ }++ fn external_effect(&self) -> bool {+ true+ }++ async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {+ self.run(args, &self.action_dir).await+ }++ async fn execute_with_context(+ &self,+ args: Value,+ _options: ToolCallOptions,+ context: Option<&dyn ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ let action_dir = action_dir_for_context(&self.action_dir, context, self.name());+ self.run(args, &action_dir).await+ }+}diff --git a/crates/openhuman-core/src/security/approval/gate_tests.rs b/crates/openhuman-core/src/security/approval/gate_tests.rsindex ff9fb0294b..1b11031bab 100644--- a/crates/openhuman-core/src/security/approval/gate_tests.rs+++ b/crates/openhuman-core/src/security/approval/gate_tests.rs@@ -203,9 +203,9 @@ async fn find_flow_gate_notification(}}-#[path = "gate_tests_part_01_tests.rs"]-mod part_01_tests;-#[path = "gate_tests_part_02_tests.rs"]-mod part_02_tests;-#[path = "gate_tests_part_03_tests.rs"]-mod part_03_tests;+#[path = "gate_core_flow_tests.rs"]+mod core_flow_tests;+#[path = "gate_ttl_and_triage_tests.rs"]+mod ttl_and_triage_tests;+#[path = "gate_origin_intercept_tests.rs"]+mod origin_intercept_tests;