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
chore(config, tests): extract inline config tests to separate file
Steven Enamakeled69f795952d
diff --git a/crates/openhuman-core/src/api/config.rs b/crates/openhuman-core/src/api/config.rsindex 6bcd85c711..b7ad6ac855 100644--- a/crates/openhuman-core/src/api/config.rs+++ b/crates/openhuman-core/src/api/config.rs@@ -729,650 +729,6 @@ pub(crate) fn backend_env_test_lock() -> std::sync::MutexGuard<'static, ()> {}// ─── Tests ───────────────────────────────────────────────────────────────────-#[cfg(test)]-mod tests {- use std::sync::MutexGuard;-- use super::*;-- // ── Test infrastructure ───────────────────────────────────────────────────-- /// Serialises all env-mutating tests via the crate-wide backend env lock- /// (see [`super::backend_env_test_lock`]) — module-local locks cannot- /// stop other modules' tests from racing on the same process globals.- fn env_lock() -> MutexGuard<'static, ()> {- super::backend_env_test_lock()- }-- /// RAII guard that captures the current values of the four backend env- /// vars, removes them, and restores them on drop — even if the test panics.- struct EnvSnapshot {- vars: [(&'static str, Option<String>); 4],- }-- impl EnvSnapshot {- fn clear_backend_env() -> Self {- let keys = [- "BACKEND_URL",- "VITE_BACKEND_URL",- APP_ENV_VAR,- VITE_APP_ENV_VAR,- ];- let vars = keys.map(|k| (k, std::env::var(k).ok()));- for (k, _) in &vars {- std::env::remove_var(k);- }- Self { vars }- }- }-- impl Drop for EnvSnapshot {- fn drop(&mut self) {- for (key, value) in &self.vars {- match value {- Some(v) => std::env::set_var(key, v),- None => std::env::remove_var(key),- }- }- }- }-- /// The URL that should be used as the backend base when no config override- /// is present and the runtime env has been cleared for the test.- fn fallback_backend_base_for_current_build() -> String {- api_base_from_env().unwrap_or_else(|| {- default_api_base_url_for_env(app_env_from_env().as_deref()).to_string()- })- }-- // ── api_url ───────────────────────────────────────────────────────────────-- #[test]- fn api_url_empty_path_returns_normalized_base() {- assert_eq!(- api_url("https://api.tinyhumans.ai", ""),- "https://api.tinyhumans.ai"- );- assert_eq!(- api_url("https://api.tinyhumans.ai/", ""),- "https://api.tinyhumans.ai"- );- assert_eq!(- api_url(" https://api.tinyhumans.ai/ ", ""),- "https://api.tinyhumans.ai"- );- }-- #[test]- fn api_url_absolute_path_replaces_base_path() {- // Regression: a base with an inference path baked in must not corrupt- // /agent-integrations/* calls.- assert_eq!(- api_url(- "https://api.tinyhumans.ai/openai/v1/chat/completions",- "/agent-integrations/composio/toolkits",- ),- "https://api.tinyhumans.ai/agent-integrations/composio/toolkits"- );- }-- #[test]- fn api_url_clean_base_joins_cleanly() {- let expected = "https://api.tinyhumans.ai/agent-integrations/composio/toolkits";- assert_eq!(- api_url(- "https://api.tinyhumans.ai",- "/agent-integrations/composio/toolkits"- ),- expected- );- assert_eq!(- api_url(- "https://api.tinyhumans.ai/",- "/agent-integrations/composio/toolkits"- ),- expected- );- }-- #[test]- fn api_url_preserves_query_string_on_path() {- assert_eq!(- api_url(- "https://api.tinyhumans.ai",- "/agent-integrations/composio/tools?toolkits=gmail"- ),- "https://api.tinyhumans.ai/agent-integrations/composio/tools?toolkits=gmail"- );- }-- #[test]- fn api_url_unparseable_base_falls_back_to_concat() {- assert_eq!(api_url("not a url", "/x"), "not a url/x");- assert_eq!(api_url("not a url/", "/x"), "not a url/x");- }-- #[test]- fn api_url_with_lm_studio_base_joins_correctly() {- // LM Studio URL must not reach effective_backend_api_url in practice- // (it redirects), but api_url itself must not panic and the result- // must use the correct host root.- assert_eq!(- api_url("http://localhost:1234/v1", "/agent-integrations/foo"),- "http://localhost:1234/agent-integrations/foo"- );- }-- #[test]- fn api_url_multiple_trailing_slashes_on_base_are_stripped() {- assert_eq!(- api_url("https://api.tinyhumans.ai///", "/v1/foo"),- "https://api.tinyhumans.ai/v1/foo"- );- }-- #[test]- fn api_url_relative_path_without_leading_slash_does_not_panic() {- // Documented edge-case: relative paths are resolved RFC 3986-style- // (last base segment dropped). The exact result depends on base- // structure; we just pin the no-panic contract.- assert!(!api_url("https://api.tinyhumans.ai", "relative").is_empty());- }-- // ── normalize_api_base_url ────────────────────────────────────────────────-- #[test]- fn normalize_strips_trailing_slashes_and_whitespace() {- assert_eq!(- normalize_api_base_url("https://api.tinyhumans.ai/"),- "https://api.tinyhumans.ai"- );- assert_eq!(- normalize_api_base_url("https://api.tinyhumans.ai///"),- "https://api.tinyhumans.ai"- );- assert_eq!(- normalize_api_base_url(" https://api.tinyhumans.ai "),- "https://api.tinyhumans.ai"- );- assert_eq!(- normalize_api_base_url(" https://api.tinyhumans.ai/ "),- "https://api.tinyhumans.ai"- );- }-- #[test]- fn normalize_preserves_mid_path() {- assert_eq!(- normalize_api_base_url("https://api.tinyhumans.ai/v2"),- "https://api.tinyhumans.ai/v2"- );- }-- #[test]- fn normalize_empty_string_returns_empty() {- assert_eq!(normalize_api_base_url(""), "");- }-- // ── normalize_backend_api_base_url ────────────────────────────────────────-- #[test]- fn normalize_backend_strips_inference_path() {- assert_eq!(- normalize_backend_api_base_url("https://api.tinyhumans.ai/openai/v1/chat/completions"),- "https://api.tinyhumans.ai"- );- }-- #[test]- fn normalize_backend_handles_schemeless_input() {- // Sentry OPENHUMAN-TAURI-H6 / issue #2075.- assert_eq!(- normalize_backend_api_base_url("api.tinyhumans.ai/openai/v1/chat/completions"),- "https://api.tinyhumans.ai"- );- }-- #[test]- fn normalize_backend_passes_through_clean_root() {- assert_eq!(- normalize_backend_api_base_url("https://api.tinyhumans.ai/"),- "https://api.tinyhumans.ai"- );- }-- #[test]- fn normalize_backend_empty_string_is_idempotent() {- assert_eq!(normalize_backend_api_base_url(""), "");- }-- // ── app / api env resolution ──────────────────────────────────────────────-- #[test]- fn staging_env_resolves_to_staging_url() {- assert_eq!(- default_api_base_url_for_env(Some("staging")),- DEFAULT_STAGING_API_BASE_URL- );- assert!(is_staging_app_env(Some("STAGING")));- }-- #[test]- fn non_staging_env_resolves_to_production_url() {- assert_eq!(- default_api_base_url_for_env(Some("production")),- DEFAULT_API_BASE_URL- );- assert_eq!(default_api_base_url_for_env(None), DEFAULT_API_BASE_URL);- assert!(!is_staging_app_env(Some("development")));- }-- #[test]- fn app_env_from_env_reads_runtime_var() {- // Setting APP_ENV to "staging" flips `default_root_dir_name()` to- // `.openhuman-staging` process-wide, which breaks any concurrent test- // resolving the root openhuman dir. Hold the crate-wide env lock too,- // in the established order (TEST_ENV_LOCK before the backend lock).- let _env_guard = crate::config::TEST_ENV_LOCK- .lock()- .unwrap_or_else(|e| e.into_inner());- let _guard = env_lock();- let prev = std::env::var(APP_ENV_VAR).ok();- std::env::set_var(APP_ENV_VAR, "staging");- let result = app_env_from_env();- match prev {- Some(v) => std::env::set_var(APP_ENV_VAR, v),- None => std::env::remove_var(APP_ENV_VAR),- }- assert_eq!(result.as_deref(), Some("staging"));- }-- #[test]- fn app_env_empty_primary_falls_through_to_secondary() {- // Same staging-root hazard as `app_env_from_env_reads_runtime_var`.- let _env_guard = crate::config::TEST_ENV_LOCK- .lock()- .unwrap_or_else(|e| e.into_inner());- let _guard = env_lock();- let prev_p = std::env::var(APP_ENV_VAR).ok();- let prev_s = std::env::var(VITE_APP_ENV_VAR).ok();- std::env::set_var(APP_ENV_VAR, "");- std::env::set_var(VITE_APP_ENV_VAR, "staging");- let result = app_env_from_env();- match prev_p {- Some(v) => std::env::set_var(APP_ENV_VAR, v),- None => std::env::remove_var(APP_ENV_VAR),- }- match prev_s {- Some(v) => std::env::set_var(VITE_APP_ENV_VAR, v),- None => std::env::remove_var(VITE_APP_ENV_VAR),- }- assert_eq!(result.as_deref(), Some("staging"));- }-- #[test]- fn api_base_from_env_reads_runtime_var() {- let _guard = env_lock();- let prev = std::env::var("BACKEND_URL").ok();- std::env::set_var("BACKEND_URL", "https://staging-api.tinyhumans.ai/");- let result = api_base_from_env();- match prev {- Some(v) => std::env::set_var("BACKEND_URL", v),- None => std::env::remove_var("BACKEND_URL"),- }- assert_eq!(result.as_deref(), Some("https://staging-api.tinyhumans.ai"));- }-- #[test]- fn api_base_empty_primary_falls_through_to_secondary() {- let _guard = env_lock();- let prev_p = std::env::var("BACKEND_URL").ok();- let prev_s = std::env::var("VITE_BACKEND_URL").ok();- std::env::set_var("BACKEND_URL", "");- std::env::set_var("VITE_BACKEND_URL", "https://staging-api.tinyhumans.ai/");- let result = api_base_from_env();- match prev_p {- Some(v) => std::env::set_var("BACKEND_URL", v),- None => std::env::remove_var("BACKEND_URL"),- }- match prev_s {- Some(v) => std::env::set_var("VITE_BACKEND_URL", v),- None => std::env::remove_var("VITE_BACKEND_URL"),- }- assert_eq!(result.as_deref(), Some("https://staging-api.tinyhumans.ai"));- }-- // ── looks_like_local_ai_endpoint ─────────────────────────────────────────-- #[test]- fn local_ai_matches_loopback_hosts() {- assert!(looks_like_local_ai_endpoint("http://127.0.0.1:11434/v1"));- assert!(looks_like_local_ai_endpoint(- "http://127.0.0.1:8080/v1/chat/completions"- ));- assert!(looks_like_local_ai_endpoint("http://localhost:11434/v1"));- assert!(looks_like_local_ai_endpoint("http://[::1]:11434"));- assert!(looks_like_local_ai_endpoint("http://0.0.0.0:11434/v1"));- }-- #[test]- fn local_ai_matches_chat_completions_path_on_any_host() {- assert!(looks_like_local_ai_endpoint(- "http://203.0.113.5:8080/v1/chat/completions"- ));- assert!(looks_like_local_ai_endpoint(- "https://my-ollama.example/v1/completions"- ));- }-- #[test]- fn local_ai_rejects_bare_loopback_with_random_port() {- assert!(!looks_like_local_ai_endpoint("http://127.0.0.1:54321"));- assert!(!looks_like_local_ai_endpoint("http://127.0.0.1:42000/"));- assert!(!looks_like_local_ai_endpoint("http://localhost:33333"));- assert!(!looks_like_local_ai_endpoint("http://[::1]:51234"));- }-- #[test]- fn local_ai_matches_private_lan_hosts() {- assert!(looks_like_local_ai_endpoint(- "http://192.168.1.100:11434/v1"- ));- assert!(looks_like_local_ai_endpoint("http://10.0.0.5:8080/v1"));- assert!(looks_like_local_ai_endpoint("http://172.16.0.42:8000"));- }-- #[test]- fn local_ai_rejects_real_backends() {- assert!(!looks_like_local_ai_endpoint("https://api.tinyhumans.ai"));- assert!(!looks_like_local_ai_endpoint(- "https://staging-api.tinyhumans.ai"- ));- // OpenAI public API exposes /v1 as a version prefix — must NOT match.- assert!(!looks_like_local_ai_endpoint("https://api.openai.com/v1"));- assert!(!looks_like_local_ai_endpoint(- "https://my-backend.example/v1"- ));- }-- #[test]- fn local_ai_rejects_substring_path_false_positives() {- // Earlier version used `contains` — these are the regressions it caused.- assert!(!looks_like_local_ai_endpoint(- "https://real-backend.example/audit/v1/chat/completions-logs"- ));- assert!(!looks_like_local_ai_endpoint(- "https://real-backend.example/v1/chat/completions/history"- ));- assert!(!looks_like_local_ai_endpoint(- "https://real-backend.example/v1/completions-archive"- ));- }-- #[test]- fn local_ai_handles_garbage_input() {- assert!(!looks_like_local_ai_endpoint(""));- assert!(!looks_like_local_ai_endpoint(" "));- assert!(!looks_like_local_ai_endpoint("not a url"));- assert!(!looks_like_local_ai_endpoint("/v1/chat/completions")); // relative — must not panic- }-- #[test]- fn local_ai_matches_lm_studio_default_port() {- assert!(looks_like_local_ai_endpoint("http://localhost:1234"));- assert!(looks_like_local_ai_endpoint("http://127.0.0.1:1234"));- assert!(looks_like_local_ai_endpoint(- "http://127.0.0.1:1234/v1/chat/completions"- ));- }-- #[test]- fn local_ai_matches_v1_subpath_on_loopback() {- assert!(looks_like_local_ai_endpoint(- "http://localhost:11434/v1/models"- ));- assert!(looks_like_local_ai_endpoint(- "http://127.0.0.1:8080/v1/embeddings"- ));- }-- // ── openhuman_backend detection ───────────────────────────────────────────-- #[test]- fn openhuman_backend_detection_accepts_hosted_api_paths() {- assert!(looks_like_openhuman_backend_endpoint(- "https://api.tinyhumans.ai/openai/v1/chat/completions"- ));- assert!(looks_like_openhuman_backend_endpoint(- "https://staging-api.tinyhumans.ai/openai/v1/chat/completions"- ));- assert!(!looks_like_openhuman_backend_endpoint(- "https://openrouter.ai/api/v1/chat/completions"- ));- assert!(!looks_like_openhuman_backend_endpoint(- "http://localhost:1234/v1/chat/completions"- ));- }-- // ── effective_backend_api_url ─────────────────────────────────────────────-- #[test]- fn backend_url_handles_llm_endpoint_overrides() {- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- let fallback = fallback_backend_base_for_current_build();-- let cases: &[(&str, &str)] = &[- (- "https://api.tinyhumans.ai/openai/v1/chat/completions",- "https://api.tinyhumans.ai",- ),- ("http://localhost:11434/v1/chat/completions", &fallback),- ("https://api.tinyhumans.ai", "https://api.tinyhumans.ai"),- (- "https://api.tinyhumans.ai/openai/v1/",- "https://api.tinyhumans.ai",- ),- ("https://openrouter.ai/api/v1/chat/completions", &fallback),- ];-- for (api_url, expected) in cases {- assert_eq!(- effective_backend_api_url(&Some(api_url.to_string())),- *expected,- "api_url = {api_url}"- );- }- }-- #[test]- fn backend_url_falls_back_for_local_ai_override() {- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- let expected = fallback_backend_base_for_current_build();-- assert_eq!(- effective_backend_api_url(&Some("http://127.0.0.1:11434/v1".to_string())),- expected- );- }-- #[test]- fn backend_url_falls_back_for_cloud_inference_base() {- // Regression: TAURI-RUST-HW1. A BYO user whose `api_url` is a public- // cloud-inference provider's *canonical base* (no `/chat/completions`- // path, public host) must NOT have backend domain calls routed there —- // `GET /teams/me/usage` was 400ing against `openrouter.ai`.- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- let fallback = fallback_backend_base_for_current_build();-- let falls_back: &[&str] = &[- "https://openrouter.ai/api/v1",- "https://api.atlascloud.ai/v1",- "https://api.openai.com/v1",- "https://api.groq.com/openai/v1",- "https://generativelanguage.googleapis.com/v1beta/openai",- ];- for api_url in falls_back {- assert_eq!(- effective_backend_api_url(&Some(api_url.to_string())),- fallback,- "cloud inference base must fall back: {api_url}"- );- }-- // Our own hosted backend still passes through (is_openhuman short-circuit),- // but an UNKNOWN custom backend at a bare `/v1` base is now classified as- // an OpenAI-compatible inference base (#4153, Signal 2) and falls back so- // control-plane calls are not misrouted. A self-hosted backend must use a- // non-`/v1` base (see the `my-openhuman.example.com` case) to keep routing.- assert_eq!(- effective_backend_api_url(&Some("https://api.tinyhumans.ai/v1".to_string())),- "https://api.tinyhumans.ai",- "openhuman backend host must pass through"- );- assert_eq!(- effective_backend_api_url(&Some("https://my-backend.example/v1".to_string())),- fallback,- "unknown bare-/v1 base is an inference base and must fall back"- );- }-- #[test]- fn backend_url_falls_back_to_env_when_override_is_local_ai() {- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- std::env::set_var("BACKEND_URL", "https://staging-api.tinyhumans.ai/");-- assert_eq!(- effective_backend_api_url(&Some(- "http://127.0.0.1:8080/v1/chat/completions".to_string()- )),- "https://staging-api.tinyhumans.ai"- );- }-- #[test]- fn backend_url_keeps_real_backend_override() {- assert_eq!(- effective_backend_api_url(&Some("https://staging-api.tinyhumans.ai/".to_string())),- "https://staging-api.tinyhumans.ai"- );- }-- #[test]- fn backend_url_without_override_matches_effective_api_url() {- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- assert_eq!(effective_backend_api_url(&None), effective_api_url(&None));- }-- // ── GH #4153: remote managed inference providers parked in `api_url` ──────-- #[test]- fn inference_provider_matches_known_remote_hosts() {- // The hosts the #4058 `host` tag pinned the `/teams/me/usage` flood to.- assert!(looks_like_inference_provider_endpoint(- "https://openrouter.ai/api/v1"- ));- assert!(looks_like_inference_provider_endpoint(- "https://api.openmodel.ai/v1"- ));- assert!(looks_like_inference_provider_endpoint(- "https://api.atlascloud.ai/v1"- ));- // Other managed providers, apex and subdomain.- assert!(looks_like_inference_provider_endpoint(- "https://api.openai.com/v1"- ));- assert!(looks_like_inference_provider_endpoint(- "https://api.groq.com/openai/v1"- ));- assert!(looks_like_inference_provider_endpoint(- "https://api.mistral.ai"- ));- }-- #[test]- fn inference_provider_matches_bare_v1_base_on_unknown_host() {- // An unknown OpenAI-compatible provider, recognised by its `/v1` base.- assert!(looks_like_inference_provider_endpoint(- "https://llm.unknown-provider.example/v1"- ));- assert!(looks_like_inference_provider_endpoint(- "https://gw.example.test/api/v1/"- ));- }-- #[test]- fn inference_provider_excludes_openhuman_backend_and_plain_hosts() {- // Our own hosted backend is a backend, even though it serves inference.- assert!(!looks_like_inference_provider_endpoint(- "https://api.tinyhumans.ai/openai/v1/chat/completions"- ));- assert!(!looks_like_inference_provider_endpoint(- "https://staging-api.tinyhumans.ai/"- ));- // A custom self-hosted OpenHuman backend (no provider host, no `/v1`- // base) must keep routing control-plane calls to itself.- assert!(!looks_like_inference_provider_endpoint(- "https://my-openhuman.example.com/"- ));- // Garbage / relative input never panics or matches.- assert!(!looks_like_inference_provider_endpoint(""));- assert!(!looks_like_inference_provider_endpoint("not a url"));- }-- #[test]- fn backend_url_falls_back_for_remote_inference_provider_override() {- // The core of #4153: `config.api_url` set to a managed inference- // provider must NOT be used as the control-plane base; backend calls- // fall back to the canonical default chain.- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- let expected = fallback_backend_base_for_current_build();-- assert_eq!(- effective_backend_api_url(&Some("https://openrouter.ai/api/v1".to_string())),- expected- );- assert_eq!(- effective_backend_api_url(&Some("https://api.openmodel.ai/v1".to_string())),- expected- );- assert_eq!(- effective_backend_api_url(&Some("https://api.atlascloud.ai/v1".to_string())),- expected- );- }-- #[test]- fn backend_url_falls_back_to_env_for_remote_inference_provider() {- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- std::env::set_var("BACKEND_URL", "https://staging-api.tinyhumans.ai/");-- assert_eq!(- effective_backend_api_url(&Some("https://openrouter.ai/api/v1".to_string())),- "https://staging-api.tinyhumans.ai"- );- }-- #[test]- fn backend_url_strips_inference_path_from_env() {- // Regression: OPENHUMAN-TAURI-H6 / -HN, issue #2075.- let _guard = env_lock();- let _env = EnvSnapshot::clear_backend_env();- std::env::set_var(- "BACKEND_URL",- "https://api.tinyhumans.ai/openai/v1/chat/completions",- );-- assert_eq!(- effective_backend_api_url(&None),- "https://api.tinyhumans.ai"- );- }-}+#[path = "config_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rsnew file mode 100644index 0000000000..1a0fe7b5b8--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs@@ -0,0 +1,101 @@+//! GitHub-repo listing and trigger handlers: `list_github_repos`,+//! `create_trigger`, `list_trigger_history`, `list_available_triggers`,+//! `list_triggers`, `enable_trigger`, `disable_trigger`.++use serde_json::{Map, Value};++use crate::config::rpc as config_rpc;+use crate::core::all::ControllerFuture;+use crate::integrations::composio::ops;++use super::params::{+ CreateTriggerParams, EnableTriggerParams, ListAvailableTriggersParams, ListGithubReposParams,+ ListTriggersParams, TriggerHistoryParams,+};+use super::util::{read_required_non_empty, to_json};++pub(super) fn handle_list_github_repos(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload: ListGithubReposParams = serde_json::from_value(Value::Object(params))+ .map_err(|e| format!("invalid params: {e}"))?;+ to_json(ops::composio_list_github_repos(&config, payload.connection_id).await?)+ })+}++pub(super) fn handle_create_trigger(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload: CreateTriggerParams = serde_json::from_value(Value::Object(params))+ .map_err(|e| format!("invalid params: {e}"))?;+ let slug = payload.slug.trim();+ if slug.is_empty() {+ return Err("invalid params: 'slug' must not be empty".to_string());+ }+ to_json(+ ops::composio_create_trigger(&config, slug, payload.connection_id, payload.trigger_config)+ .await?,+ )+ })+}++pub(super) fn handle_list_trigger_history(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload: TriggerHistoryParams = serde_json::from_value(Value::Object(params))+ .map_err(|e| format!("invalid params: {e}"))?;+ to_json(ops::composio_list_trigger_history(&config, payload.limit).await?)+ })+}++pub(super) fn handle_list_available_triggers(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload: ListAvailableTriggersParams = serde_json::from_value(Value::Object(params))+ .map_err(|e| format!("invalid params: {e}"))?;+ let toolkit = payload.toolkit.trim();+ if toolkit.is_empty() {+ return Err("invalid params: 'toolkit' must not be empty".to_string());+ }+ to_json(+ ops::composio_list_available_triggers(&config, toolkit, payload.connection_id).await?,+ )+ })+}++pub(super) fn handle_list_triggers(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload: ListTriggersParams = serde_json::from_value(Value::Object(params))+ .map_err(|e| format!("invalid params: {e}"))?;+ to_json(ops::composio_list_triggers(&config, payload.toolkit).await?)+ })+}++pub(super) fn handle_enable_trigger(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload: EnableTriggerParams = serde_json::from_value(Value::Object(params))+ .map_err(|e| format!("invalid params: {e}"))?;+ let connection_id = payload.connection_id.trim();+ let slug = payload.slug.trim();+ if connection_id.is_empty() {+ return Err("invalid params: 'connection_id' must not be empty".to_string());+ }+ if slug.is_empty() {+ return Err("invalid params: 'slug' must not be empty".to_string());+ }+ to_json(+ ops::composio_enable_trigger(&config, connection_id, slug, payload.trigger_config)+ .await?,+ )+ })+}++pub(super) fn handle_disable_trigger(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let trigger_id = read_required_non_empty(¶ms, "trigger_id")?;+ to_json(ops::composio_disable_trigger(&config, &trigger_id).await?)+ })+}diff --git a/crates/openhuman-core/src/threads/schemas/registry.rs b/crates/openhuman-core/src/threads/schemas/registry.rsnew file mode 100644index 0000000000..461d720a13--- /dev/null+++ b/crates/openhuman-core/src/threads/schemas/registry.rs@@ -0,0 +1,124 @@+//! Controller schema and registered-controller lists for the `threads`+//! namespace.++use crate::core::all::RegisteredController;+use crate::core::ControllerSchema;++use super::handlers::{+ handle_create_new, handle_delete, handle_generate_title, handle_list, handle_message_append,+ handle_message_update, handle_messages_list, handle_purge, handle_task_board_get,+ handle_task_board_put, handle_token_usage, handle_transcript_get, handle_turn_state_clear,+ handle_turn_state_get, handle_turn_state_get_turn, handle_turn_state_history,+ handle_turn_state_list, handle_update_labels, handle_update_title, handle_upsert,+};+use super::schema_defs::schemas;++pub fn all_controller_schemas() -> Vec<ControllerSchema> {+ vec![+ schemas("list"),+ schemas("upsert"),+ schemas("create_new"),+ schemas("messages_list"),+ schemas("message_append"),+ schemas("generate_title"),+ schemas("update_labels"),+ schemas("update_title"),+ schemas("message_update"),+ schemas("delete"),+ schemas("purge"),+ schemas("turn_state_get"),+ schemas("turn_state_list"),+ schemas("turn_state_history"),+ schemas("turn_state_get_turn"),+ schemas("turn_state_clear"),+ schemas("task_board_get"),+ schemas("task_board_put"),+ schemas("token_usage"),+ schemas("transcript_get"),+ ]+}++pub fn all_registered_controllers() -> Vec<RegisteredController> {+ vec![+ RegisteredController {+ schema: schemas("list"),+ handler: handle_list,+ },+ RegisteredController {+ schema: schemas("upsert"),+ handler: handle_upsert,+ },+ RegisteredController {+ schema: schemas("create_new"),+ handler: handle_create_new,+ },+ RegisteredController {+ schema: schemas("messages_list"),+ handler: handle_messages_list,+ },+ RegisteredController {+ schema: schemas("message_append"),+ handler: handle_message_append,+ },+ RegisteredController {+ schema: schemas("generate_title"),+ handler: handle_generate_title,+ },+ RegisteredController {+ schema: schemas("update_labels"),+ handler: handle_update_labels,+ },+ RegisteredController {+ schema: schemas("update_title"),+ handler: handle_update_title,+ },+ RegisteredController {+ schema: schemas("message_update"),+ handler: handle_message_update,+ },+ RegisteredController {+ schema: schemas("delete"),+ handler: handle_delete,+ },+ RegisteredController {+ schema: schemas("purge"),+ handler: handle_purge,+ },+ RegisteredController {+ schema: schemas("turn_state_get"),+ handler: handle_turn_state_get,+ },+ RegisteredController {+ schema: schemas("turn_state_list"),+ handler: handle_turn_state_list,+ },+ RegisteredController {+ schema: schemas("turn_state_history"),+ handler: handle_turn_state_history,+ },+ RegisteredController {+ schema: schemas("turn_state_get_turn"),+ handler: handle_turn_state_get_turn,+ },+ RegisteredController {+ schema: schemas("turn_state_clear"),+ handler: handle_turn_state_clear,+ },+ RegisteredController {+ schema: schemas("task_board_get"),+ handler: handle_task_board_get,+ },+ RegisteredController {+ schema: schemas("task_board_put"),+ handler: handle_task_board_put,+ },+ RegisteredController {+ schema: schemas("token_usage"),+ handler: handle_token_usage,+ },+ RegisteredController {+ schema: schemas("transcript_get"),+ handler: handle_transcript_get,+ },+ ]+}diff --git a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_part_02_tests.rs b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rssimilarity index 100%rename from crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_part_02_tests.rsrename to crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs