Skip to content

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

feat(integrations): add media provider and request helpers

Steven Enamakel76b8834d783f
diff --git a/crates/openhuman-tinyhumans/src/integrations/client.rs b/crates/openhuman-tinyhumans/src/integrations/client.rs
index 4e5070cfae..43287a14df 100644
--- a/crates/openhuman-tinyhumans/src/integrations/client.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/client.rs
@@ -5,7 +5,7 @@ mod construct;
mod download;
mod errors;
mod pricing;
-mod requests;
+pub(crate) mod requests;
pub use construct::IntegrationClient;
pub use pricing::{build_client, pricing_for_config};
diff --git a/crates/openhuman-tinyhumans/src/integrations/client/requests.rs b/crates/openhuman-tinyhumans/src/integrations/client/requests.rs
index d1a4c0ac7d..b076a5e0d8 100644
--- a/crates/openhuman-tinyhumans/src/integrations/client/requests.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/client/requests.rs
@@ -13,11 +13,52 @@ pub(super) fn managed_budget_applies_to_path(path: &str) -> bool {
/// Build the egress descriptor for a managed-backend round-trip. The query
/// string is stripped so only the endpoint (the "to where") is described, never
/// any data carried in the query.
-pub(super) fn backend_egress_descriptor(
+///
+/// The descriptor is classified here ([`is_control_plane_path`]); the core only
+/// honours the flag.
+pub(crate) fn backend_egress_descriptor(
path: &str,
) -> openhuman_embed::__host::egress::EgressDescriptor {
let endpoint = path.split('?').next().unwrap_or(path);
openhuman_embed::__host::egress::EgressDescriptor::integration(endpoint)
+ .with_control_plane(is_control_plane_path(endpoint))
+}
+
+/// Is `path` a backend **control-plane** round-trip that must keep flowing
+/// under `LocalOnly` (it carries no user content: auth tokens, ids, routing
+/// metadata)? Two shapes are exempt:
+///
+/// 1. **Any path outside the user-data tool namespace** (not under
+/// `/agent-integrations/`). Every user-data integration call (composio
+/// execute, research, file-storage uploads, ...) routes through
+/// `IntegrationClient` under that prefix, while session / team / billing /
+/// auth round-trips go through `BackendClient` and never build an egress
+/// descriptor. A path outside the prefix only reaches here if a caller
+/// re-homes a control-plane call onto this descriptor; exempt it
+/// defensively so a re-home can never brick login.
+/// 2. **A narrow allow-list of read-only sub-routes** that set up or describe
+/// an integration without shipping user content: `pricing`, and under
+/// `composio/` only `connections` (list + per-connection delete),
+/// `authorize` (OAuth handoff), `tools` and `toolkits` (catalog).
+///
+/// Everything else is **blocked** (fail-closed): `composio/execute` (tool
+/// arguments), `composio/triggers[/available]` (user-data writes; the
+/// descriptor carries no HTTP method, so the reads on the same path block with
+/// them), `composio/github/repos`, any unknown composio sub-route, and every
+/// non-composio tool namespace.
+pub(crate) fn is_control_plane_path(path: &str) -> bool {
+ let path = path.trim_start_matches('/');
+ let Some(subroute) = path.strip_prefix("agent-integrations/") else {
+ return true;
+ };
+ if subroute == "pricing" {
+ return true;
+ }
+ if let Some(rest) = subroute.strip_prefix("composio/") {
+ let head = rest.split(['/', '?']).next().unwrap_or(rest);
+ return matches!(head, "connections" | "authorize" | "tools" | "toolkits");
+ }
+ false
}
/// Egress spine (privacy epic S2, #4436): disclose an OpenHuman managed-backend
@@ -35,7 +76,7 @@ pub(super) fn emit_backend_egress(approval: &ApprovalTurnContext, path: &str) {
/// `Ok(())` for control-plane paths (session / team / billing / integration
/// connection-management + catalog) even under `LocalOnly` — blocking those
/// would break sign-in and the Connections UI for no privacy benefit. See
-/// [`is_control_plane`](openhuman_embed::__host::egress). Call before
+/// [`is_control_plane_path`]. Call before
/// [`emit_backend_egress`] so a blocked call is neither disclosed nor sent.
pub(super) fn enforce_backend_egress(path: &str) -> anyhow::Result<()> {
openhuman_embed::__host::egress::enforce_egress(&backend_egress_descriptor(path))
@@ -171,3 +212,7 @@ impl IntegrationClient {
Ok(serde_json::from_value(value)?)
}
}
+
+#[cfg(test)]
+#[path = "requests_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-tinyhumans/src/integrations/client/requests_tests.rs b/crates/openhuman-tinyhumans/src/integrations/client/requests_tests.rs
new file mode 100644
index 0000000000..656d6ca2f2
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/integrations/client/requests_tests.rs
@@ -0,0 +1,70 @@
+use super::*;
+
+#[test]
+fn control_plane_exempts_non_tool_namespace() {
+ // A control-plane call re-homed onto an integration descriptor: anything
+ // not under /agent-integrations/ is exempt.
+ for path in [
+ "/teams/me/usage",
+ "/payments/stripe/currentPlan",
+ "/auth/refresh",
+ ] {
+ assert!(
+ backend_egress_descriptor(path).control_plane,
+ "{path} must be treated as control-plane"
+ );
+ }
+}
+
+#[test]
+fn control_plane_exempts_composio_management_and_pricing() {
+ // Connection-management / catalog / OAuth / pricing carry no user content.
+ for path in [
+ "/agent-integrations/pricing",
+ "/agent-integrations/composio/connections",
+ // Per-connection delete rides the same `connections` head.
+ "/agent-integrations/composio/connections/conn_123",
+ "/agent-integrations/composio/authorize",
+ "/agent-integrations/composio/tools",
+ "/agent-integrations/composio/toolkits",
+ // The query is stripped before classification.
+ "/agent-integrations/composio/tools?toolkits=gmail",
+ ] {
+ assert!(
+ backend_egress_descriptor(path).control_plane,
+ "{path} must be exempt (control-plane)"
+ );
+ }
+}
+
+#[test]
+fn control_plane_does_not_exempt_user_data_paths() {
+ for path in [
+ "/agent-integrations/composio/execute",
+ "/agent-integrations/composio/triggers",
+ "/agent-integrations/composio/triggers/available",
+ "/agent-integrations/composio/github/repos",
+ // An unknown composio sub-route defaults to blocked (fail-closed).
+ "/agent-integrations/composio/some-future-write",
+ "/agent-integrations/parallel/research",
+ "/agent-integrations/tinyfish/fetch",
+ "/agent-integrations/file-storage/files",
+ "/agent-integrations/google-places/search",
+ "/agent-integrations/openrouter/images",
+ ] {
+ assert!(
+ !backend_egress_descriptor(path).control_plane,
+ "{path} must NOT be exempt (ships user data)"
+ );
+ }
+}
+
+#[test]
+fn local_only_keeps_control_plane_flowing_and_blocks_user_data() {
+ use openhuman_embed::__host::egress::local_only_blocks;
+ use openhuman_embed::__host::config::PrivacyMode;
+ let pricing = backend_egress_descriptor("/agent-integrations/pricing");
+ assert!(!local_only_blocks(PrivacyMode::LocalOnly, &pricing));
+ let execute = backend_egress_descriptor("/agent-integrations/composio/execute");
+ assert!(local_only_blocks(PrivacyMode::LocalOnly, &execute));
+}
diff --git a/crates/openhuman-tinyhumans/src/integrations/media/provider.rs b/crates/openhuman-tinyhumans/src/integrations/media/provider.rs
index 86beba2c2a..9ebae30b95 100644
--- a/crates/openhuman-tinyhumans/src/integrations/media/provider.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/media/provider.rs
@@ -112,9 +112,9 @@ impl Guard {
/// Local-only enforcement, then the egress disclosure. A blocked call is
/// neither disclosed nor sent.
fn admit(&self, route: &str) -> ti_image::Result<()> {
- let descriptor = openhuman_embed::__host::egress::EgressDescriptor::integration(format!(
- "{OPENROUTER_PROXY_PATH}/{route}"
- ));
+ let descriptor = crate::integrations::client::requests::backend_egress_descriptor(
+ &format!("{OPENROUTER_PROXY_PATH}/{route}"),
+ );
openhuman_embed::__host::egress::enforce_egress(&descriptor).map_err(|error| {
tracing::info!(route, %error, "[media_generation] blocked by privacy policy");
ti_image::Error::Validation(format!("blocked by the privacy policy: {error}"))