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(tinyflows): add tier gating and timeouts to capability ops
Steven Enamakelb7c1cd15ddd6
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops.rsindex 160256ce4a..ce7bdb3b6f 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops.rs@@ -138,6 +138,7 @@ pub(crate) fn http_cred_name(conn: &str) -> Option<&str> {/// connected set is never consulted then) or when the connected set could not/// be fetched (fail-closed).async fn flow_tool_allowed(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,slug: &str,connected_toolkits: Option<&[String]>,@@ -159,7 +160,7 @@ async fn flow_tool_allowed(tracing::debug!(target: "flows", %slug, %toolkit, "[flows] tool_call curation: reject — slug is not a curated action of this toolkit");return false;};- let pref = load_user_scope_pref(config, &toolkit).await;+ let pref = load_user_scope_pref(ctx, config, &toolkit).await;let allowed = pref.allows(curated.scope);tracing::debug!(target: "flows", %slug, %toolkit, allowed, "[flows] tool_call curation: static curated catalog decision");return allowed;@@ -201,7 +202,7 @@ async fn flow_tool_allowed(// classify_unknown heuristic (mirrors// `providers::is_action_visible_with_pref`'s uncurated branch), which the// pre-fix Path B never applied at all.- let pref = load_user_scope_pref(config, &toolkit).await;+ let pref = load_user_scope_pref(ctx, config, &toolkit).await;let allowed = pref.allows(classify_unknown(slug));tracing::debug!(target: "flows", %slug, %toolkit, allowed, "[flows] tool_call curation: live catalog + scope decision");allowed@@ -295,13 +296,17 @@ pub(crate) async fn classify_composio_action_for_tier(slug: &str) -> CommandClas/// Deny-by-default curation gate for a flow `tool_call` slug (see/// [`flow_tool_allowed`] for the decision matrix). Fetches the user's live/// connected-toolkit set only when the slug's toolkit has no static catalog.-pub(crate) async fn is_curated_flow_tool(config: &Config, slug: &str) -> bool {+pub(crate) async fn is_curated_flow_tool(+ ctx: &crate::core::runtime::DispatchCtx,+ config: &Config,+ slug: &str,+) -> bool {let connected = if slug_needs_connected_set(slug) {connected_toolkit_slugs(config).await} else {None};- flow_tool_allowed(config, slug, connected.as_deref()).await+ flow_tool_allowed(ctx, config, slug, connected.as_deref()).await}/// Finds the connected account a Composio `connection_id` refers to within a@@ -380,6 +385,9 @@ pub(crate) async fn resolve_composio_account(/// // For such flows authors should set `require_approval`. FOLLOW-UP: auto-force/// // approval when a trigger-driven run's tool/http config contains `=`-exprs.pub struct OpenHumanTools {+ /// The context the run acts under: the scope-pref reads of the curation+ /// gate resolve against it rather than the calling task's own scope.+ pub ctx: crate::core::runtime::DispatchCtx,pub config: Arc<Config>,pub security: Arc<SecurityPolicy>,/// The run's approval context (flow run correlation), handed to the gate@@ -582,6 +590,7 @@ impl ToolInvoker for PreflightToolInvoker {impl ToolInvoker for OpenHumanTools {async fn invoke(&self, slug: &str, args: Value, conn: Option<&str>) -> Result<Value> {let ctx = tools::ToolCallCtx {+ dispatch: &self.ctx,config: &self.config,security: &self.security,approval: &self.approval,@@ -635,6 +644,7 @@ pub fn build_capabilities(config: config.clone(),}),tools: Arc::new(OpenHumanTools {+ ctx: ctx.clone(),config: config.clone(),security: security.clone(),approval: approval.clone(),diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rsindex 9800a73796..2b1ab3b393 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs@@ -106,6 +106,7 @@ async fn composio_tool_call_blocks_under_readonly_tier() {use crate::security::AutonomyLevel;let tools = OpenHumanTools {+ ctx: crate::core::runtime::DispatchCtx::ambient(),config: Arc::new(Config::default()),security: Arc::new(policy(AutonomyLevel::ReadOnly)),approval: Default::default(),@@ -152,6 +153,7 @@ async fn composio_read_action_allowed_under_readonly_tier() {// it may still fail downstream (no Composio session configured in// this test), but never with the policy-blocked marker.let tools = OpenHumanTools {+ ctx: crate::core::runtime::DispatchCtx::ambient(),config: Arc::new(Config::default()),security: Arc::new(policy(AutonomyLevel::ReadOnly)),approval: Default::default(),@@ -189,6 +191,7 @@ async fn composio_read_action_does_not_prompt_under_supervised_tier() {);let tools = OpenHumanTools {+ ctx: crate::core::runtime::DispatchCtx::ambient(),config: Arc::new(Config::default()),security: Arc::new(policy(AutonomyLevel::Supervised)),approval: Default::default(),diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rsindex 53b09cfadf..12336f85cc 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs@@ -129,7 +129,7 @@ impl ToolBackend for ComposioToolBackend {// doc for why this differs from the general agent tool-call path).// Runs before anything else — a rejected slug never reaches the// composio client at all.- if !super::super::is_curated_flow_tool(&live_config, slug).await {+ if !super::super::is_curated_flow_tool(ctx.dispatch, &live_config, slug).await {tracing::warn!(target: "flows",%slug,diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rsindex e3c28e390e..8e9ad5c6a8 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tools/mod.rs@@ -46,6 +46,8 @@ pub(crate) const NATIVE_TOOL_PREFIX: &str = "oh:";////// Borrowed rather than owned so dispatch clones nothing per call.pub(crate) struct ToolCallCtx<'a> {+ /// The context the run acts under.+ pub dispatch: &'a crate::core::runtime::DispatchCtx,/// Host config — credentials, entity id, composio mode.pub config: &'a Config,/// The autonomy tier / approval policy in force for this run.diff --git a/crates/openhuman-core/src/flows/tinyflows/tinyflows_tests.rs b/crates/openhuman-core/src/flows/tinyflows/tinyflows_tests.rsindex 952e939825..293720ee06 100644--- a/crates/openhuman-core/src/flows/tinyflows/tinyflows_tests.rs+++ b/crates/openhuman-core/src/flows/tinyflows/tinyflows_tests.rs@@ -107,6 +107,7 @@ fn tools_adapter(config: Arc<Config>) -> OpenHumanTools {&config.action_dir,));OpenHumanTools {+ ctx: crate::core::runtime::DispatchCtx::ambient(),config,security,approval: Default::default(),