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(webhooks): remove unused webhook schema and operation files
Steven Enamakel67f30521015c
diff --git a/crates/openhuman-core/src/skills/webhooks/ops.rs b/crates/openhuman-core/src/skills/webhooks/ops.rsindex d862b8d1d3..9f476f0af8 100644--- a/crates/openhuman-core/src/skills/webhooks/ops.rs+++ b/crates/openhuman-core/src/skills/webhooks/ops.rs@@ -1,45 +1,11 @@-use crate::api::config::effective_backend_api_url;-use crate::api::jwt::get_session_token;-use crate::api::BackendOAuthClient;-use crate::config::Config;use crate::rpc::RpcOutcome;use crate::skills::webhooks::{WebhookDebugLogListResult, WebhookDebugLogsClearedResult, WebhookDebugRegistrationsResult,WebhookRequest, WebhookResponseData,};use base64::Engine;-use reqwest::Method;-use serde_json::Value;use std::collections::HashMap;-fn require_token(config: &Config) -> Result<String, String> {- get_session_token(config)?- .and_then(|v| {- let t = v.trim().to_string();- if t.is_empty() {- None- } else {- Some(t)- }- })- .ok_or_else(|| "no backend session token; run auth_store_session first".to_string())-}--async fn get_authed_value(- config: &Config,- method: Method,- path: &str,- body: Option<Value>,-) -> Result<Value, String> {- let token = require_token(config)?;- let api_url = effective_backend_api_url(&config.api_url);- let client = BackendOAuthClient::new(&api_url).map_err(|e| e.to_string())?;- client- .authed_json(&token, method, path, body)- .await- .map_err(|e| e.to_string())-}-/// Retrieve the global webhook router, returning an error if the socket/// manager or router is not yet initialised.fn get_router() -> Result<std::sync::Arc<crate::skills::webhooks::WebhookRouter>, String> {@@ -267,93 +233,6 @@ pub fn build_echo_response(request: &WebhookRequest) -> WebhookResponseData {}}-pub async fn list_tunnels(config: &Config) -> Result<RpcOutcome<Value>, String> {- let data = get_authed_value(config, Method::GET, "/webhooks/core", None).await?;- Ok(RpcOutcome::single_log(data, "webhook tunnels fetched"))-}--pub async fn create_tunnel(- config: &Config,- name: &str,- description: Option<String>,-) -> Result<RpcOutcome<Value>, String> {- let name = name.trim();- if name.is_empty() {- return Err("name is required".to_string());- }- let mut body_map = serde_json::Map::new();- body_map.insert(- "name".to_string(),- serde_json::Value::String(name.to_string()),- );- if let Some(desc) = description {- let desc = desc.trim().to_string();- if !desc.is_empty() {- body_map.insert("description".to_string(), serde_json::Value::String(desc));- }- }- let body = serde_json::Value::Object(body_map);- let data = get_authed_value(config, Method::POST, "/webhooks/core", Some(body)).await?;- Ok(RpcOutcome::single_log(data, "webhook tunnel created"))-}--pub async fn get_tunnel(config: &Config, id: &str) -> Result<RpcOutcome<Value>, String> {- let id = id.trim();- if id.is_empty() {- return Err("id is required".to_string());- }- let encoded_id = urlencoding::encode(id);- let data = get_authed_value(- config,- Method::GET,- &format!("/webhooks/core/{encoded_id}"),- None,- )- .await?;- Ok(RpcOutcome::single_log(data, "webhook tunnel fetched"))-}--pub async fn update_tunnel(- config: &Config,- id: &str,- payload: Value,-) -> Result<RpcOutcome<Value>, String> {- let id = id.trim();- if id.is_empty() {- return Err("id is required".to_string());- }- let encoded_id = urlencoding::encode(id);- let data = get_authed_value(- config,- Method::PATCH,- &format!("/webhooks/core/{encoded_id}"),- Some(payload),- )- .await?;- Ok(RpcOutcome::single_log(data, "webhook tunnel updated"))-}--pub async fn delete_tunnel(config: &Config, id: &str) -> Result<RpcOutcome<Value>, String> {- let id = id.trim();- if id.is_empty() {- return Err("id is required".to_string());- }- let encoded_id = urlencoding::encode(id);- let data = get_authed_value(- config,- Method::DELETE,- &format!("/webhooks/core/{encoded_id}"),- None,- )- .await?;- Ok(RpcOutcome::single_log(data, "webhook tunnel deleted"))-}--pub async fn get_bandwidth(config: &Config) -> Result<RpcOutcome<Value>, String> {- let data = get_authed_value(config, Method::GET, "/webhooks/core/bandwidth", None).await?;- Ok(RpcOutcome::single_log(data, "webhook bandwidth fetched"))-}-#[cfg(test)]#[path = "ops_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/skills/webhooks/ops_tests.rs b/crates/openhuman-core/src/skills/webhooks/ops_tests.rsindex 72970fcb2c..016bcf9587 100644--- a/crates/openhuman-core/src/skills/webhooks/ops_tests.rs+++ b/crates/openhuman-core/src/skills/webhooks/ops_tests.rs@@ -9,92 +9,8 @@ use axum::{use serde_json::json;use tempfile::TempDir;-fn test_config(tmp: &TempDir) -> Config {- Config {- workspace_dir: tmp.path().join("workspace"),- action_dir: tmp.path().join("workspace"),- config_path: tmp.path().join("config.toml"),- ..Config::default()- }-}--fn store_session_token(config: &Config, token: &str) {- let service = AuthService::from_config(config);- service- .store_provider_token(- APP_SESSION_PROVIDER,- DEFAULT_AUTH_PROFILE_NAME,- token,- std::collections::HashMap::new(),- true,- )- .expect("store session token");-}--async fn spawn_mock_backend(app: Router) -> String {- let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();- let addr = listener.local_addr().unwrap();- tokio::spawn(async move {- axum::serve(listener, app).await.unwrap();- });- // Poll for readiness so the accept loop is live before the- // first authed HTTP call — same pattern used by composio/ops.- let deadline = std::time::Instant::now() + std::time::Duration::from_secs(2);- let mut backoff = std::time::Duration::from_millis(2);- loop {- if tokio::net::TcpStream::connect(addr).await.is_ok() {- break;- }- if std::time::Instant::now() >= deadline {- panic!("mock backend at {addr} did not become ready");- }- tokio::time::sleep(backoff).await;- backoff = (backoff * 2).min(std::time::Duration::from_millis(50));- }- format!("http://127.0.0.1:{}", addr.port())-}--fn config_with_backend(tmp: &TempDir, base: String) -> Config {- let mut c = test_config(tmp);- c.api_url = Some(base);- store_session_token(&c, "test-session-token");- c-}-// ── require_token ─────────────────────────────────────────────-#[test]-fn require_token_errors_when_no_session_stored() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- let err = require_token(&config).unwrap_err();- assert!(- err.contains("no backend session token"),- "expected 'no backend session token', got: {err}"- );-}--#[test]-fn require_token_returns_stored_token_trimmed() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- store_session_token(&config, " tok-123 ");- let got = require_token(&config).expect("token");- assert_eq!(got, "tok-123");-}--#[test]-fn require_token_rejects_whitespace_only_stored_token() {- // A token that exists in the store but is just whitespace must- // be treated as absent — otherwise downstream HTTP calls would- // send an empty `Authorization: Bearer` header.- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- store_session_token(&config, " ");- let err = require_token(&config).unwrap_err();- assert!(err.contains("no backend session token"));-}-// ── Router-not-initialized fallback paths ─────────────────────// These tests run without a global SocketManager so the router// accessor returns an error and the ops fall back gracefully.@@ -196,195 +112,4 @@ fn build_echo_response_encodes_request_fields_and_sets_headers() {// ── Validation on trimmed inputs ──────────────────────────────-#[tokio::test]-async fn create_tunnel_rejects_empty_or_whitespace_name() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- for name in ["", " "] {- let err = create_tunnel(&config, name, None).await.unwrap_err();- assert!(- err.contains("name is required"),- "expected 'name is required' for `{name:?}`, got: {err}"- );- }-}--#[tokio::test]-async fn id_bearing_tunnel_ops_reject_empty_or_whitespace_id() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- for id in ["", " "] {- assert!(get_tunnel(&config, id)- .await- .unwrap_err()- .contains("id is required"));- assert!(delete_tunnel(&config, id)- .await- .unwrap_err()- .contains("id is required"));- assert!(update_tunnel(&config, id, json!({}))- .await- .unwrap_err()- .contains("id is required"));- }-}-// ── Authed HTTP round-trips via a mock backend ───────────────--#[tokio::test]-#[ignore = "backend webhook routes are intentionally excluded"]-async fn list_tunnels_hits_webhooks_core_endpoint_and_returns_payload() {- // Inspect the inbound Authorization header so we catch regressions- // where the JWT stops being forwarded (or is sent with the wrong- // scheme). `config_with_backend` stores `test-session-token`, so- // the header must be `Bearer test-session-token`.- let app = Router::new().route(- "/webhooks/core",- get(|headers: HeaderMap| async move {- let auth = headers- .get("authorization")- .and_then(|v| v.to_str().ok())- .unwrap_or("")- .to_string();- assert_eq!(- auth, "Bearer test-session-token",- "authorization header must forward the stored session token"- );- Json(json!({"tunnels": [{"id": "t-1"}]}))- }),- );- let base = spawn_mock_backend(app).await;- let tmp = TempDir::new().unwrap();- let config = config_with_backend(&tmp, base);- let out = list_tunnels(&config).await.unwrap();- assert_eq!(out.value["tunnels"][0]["id"], json!("t-1"));- assert!(out- .logs- .iter()- .any(|l| l.contains("webhook tunnels fetched")));-}--#[tokio::test]-#[ignore = "backend webhook routes are intentionally excluded"]-async fn create_tunnel_posts_name_and_optional_description() {- let app = Router::new().route(- "/webhooks/core",- post(|Json(body): Json<serde_json::Value>| async move {- // Echo back the received body so the test can verify- // trimming and optional-description handling.- Json(json!({ "echoed": body }))- }),- );- let base = spawn_mock_backend(app).await;- let tmp = TempDir::new().unwrap();- let config = config_with_backend(&tmp, base);-- // Description with surrounding whitespace must be trimmed into- // the outgoing payload; empty description must be dropped.- let out = create_tunnel(&config, " my-hook ", Some(" desc ".into()))- .await- .unwrap();- assert_eq!(out.value["echoed"]["name"], json!("my-hook"));- assert_eq!(out.value["echoed"]["description"], json!("desc"));-- let out2 = create_tunnel(&config, "nodesc", Some(" ".into()))- .await- .unwrap();- assert_eq!(out2.value["echoed"]["name"], json!("nodesc"));- assert!(- out2.value["echoed"].get("description").is_none(),- "whitespace-only description must not be forwarded"- );-}--#[tokio::test]-#[ignore = "backend webhook routes are intentionally excluded"]-async fn get_tunnel_encodes_id_in_path() {- // Use an id full of reserved URL characters so we actually verify- // percent-encoding on the outbound path. axum's `Path` extractor- // decodes before handing us the string, so the server must see- // the trimmed, *decoded* form of the id.- let app = Router::new().route(- "/webhooks/core/{id}",- get(|Path(id): Path<String>| async move { Json(json!({ "id": id })) }),- );- let base = spawn_mock_backend(app).await;- let tmp = TempDir::new().unwrap();- let config = config_with_backend(&tmp, base);- let raw_id = " abc:/?#[ ]@!$&'()*+,;=% ";- let trimmed = raw_id.trim();- let out = get_tunnel(&config, raw_id).await.unwrap();- assert_eq!(- out.value["id"],- json!(trimmed),- "server should receive the trimmed, decoded id — proves the client \- percent-encoded reserved chars instead of sending them raw"- );-}--#[tokio::test]-#[ignore = "backend webhook routes are intentionally excluded"]-async fn update_tunnel_patches_id_with_body() {- let app = Router::new().route(- "/webhooks/core/{id}",- patch(- |Path(id): Path<String>, Json(body): Json<serde_json::Value>| async move {- Json(json!({ "id": id, "patched": body }))- },- ),- );- let base = spawn_mock_backend(app).await;- let tmp = TempDir::new().unwrap();- let config = config_with_backend(&tmp, base);- let out = update_tunnel(&config, "t-1", json!({"name":"renamed","isActive":true}))- .await- .unwrap();- assert_eq!(out.value["id"], json!("t-1"));- assert_eq!(out.value["patched"]["name"], json!("renamed"));- assert_eq!(out.value["patched"]["isActive"], json!(true));-}--#[tokio::test]-#[ignore = "backend webhook routes are intentionally excluded"]-async fn delete_tunnel_deletes_by_id() {- let app = Router::new().route(- "/webhooks/core/{id}",- delete(|Path(id): Path<String>| async move { Json(json!({"deleted": id})) }),- );- let base = spawn_mock_backend(app).await;- let tmp = TempDir::new().unwrap();- let config = config_with_backend(&tmp, base);- let out = delete_tunnel(&config, "t-42").await.unwrap();- assert_eq!(out.value["deleted"], json!("t-42"));-}--#[tokio::test]-#[ignore = "backend webhook routes are intentionally excluded"]-async fn get_bandwidth_fetches_the_bandwidth_endpoint() {- let app = Router::new().route(- "/webhooks/core/bandwidth",- get(|| async { Json(json!({"remaining": 1024})) }),- );- let base = spawn_mock_backend(app).await;- let tmp = TempDir::new().unwrap();- let config = config_with_backend(&tmp, base);- let out = get_bandwidth(&config).await.unwrap();- assert_eq!(out.value["remaining"], json!(1024));-}--#[tokio::test]-async fn authed_http_calls_surface_require_token_error_without_session() {- // No token stored → all authed endpoints should error with the- // shared "no backend session token" message before any network- // call is made.- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- assert!(list_tunnels(&config)- .await- .unwrap_err()- .contains("no backend session token"));- assert!(get_bandwidth(&config)- .await- .unwrap_err()- .contains("no backend session token"));-}diff --git a/crates/openhuman-core/src/skills/webhooks/schemas.rs b/crates/openhuman-core/src/skills/webhooks/schemas.rsindex ab9db3aa87..80cae57d7e 100644--- a/crates/openhuman-core/src/skills/webhooks/schemas.rs+++ b/crates/openhuman-core/src/skills/webhooks/schemas.rs@@ -43,26 +43,6 @@ struct WebhookTriggerAgentParams {payload: Option<Value>,}-#[derive(Debug, Deserialize)]-struct WebhookCreateTunnelParams {- name: String,- description: Option<String>,-}--#[derive(Debug, Deserialize)]-struct WebhookTunnelIdParams {- id: String,-}--#[derive(Debug, Deserialize)]-#[serde(rename_all = "camelCase")]-struct WebhookUpdateTunnelParams {- id: String,- name: Option<String>,- description: Option<String>,- is_active: Option<bool>,-}-pub fn all_controller_schemas() -> Vec<ControllerSchema> {vec![schemas("list_registrations"),@@ -72,12 +52,6 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {schemas("unregister_echo"),schemas("register_agent"),schemas("trigger_agent"),- schemas("list_tunnels"),- schemas("create_tunnel"),- schemas("get_tunnel"),- schemas("update_tunnel"),- schemas("delete_tunnel"),- schemas("get_bandwidth"),]}@@ -111,30 +85,6 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {schema: schemas("trigger_agent"),handler: handle_trigger_agent,},- RegisteredController {- schema: schemas("list_tunnels"),- handler: handle_list_tunnels,- },- RegisteredController {- schema: schemas("create_tunnel"),- handler: handle_create_tunnel,- },- RegisteredController {- schema: schemas("get_tunnel"),- handler: handle_get_tunnel,- },- RegisteredController {- schema: schemas("update_tunnel"),- handler: handle_update_tunnel,- },- RegisteredController {- schema: schemas("delete_tunnel"),- handler: handle_delete_tunnel,- },- RegisteredController {- schema: schemas("get_bandwidth"),- handler: handle_get_bandwidth,- },]}@@ -272,96 +222,6 @@ pub fn schemas(function: &str) -> ControllerSchema {],outputs: vec![json_output("result", "Triage decision result.")],},- "list_tunnels" => ControllerSchema {- namespace: "webhooks",- function: "list_tunnels",- description: "List backend-managed webhook tunnels for the current user.",- inputs: vec![],- outputs: vec![json_output("result", "Webhook tunnel list.")],- },- "create_tunnel" => ControllerSchema {- namespace: "webhooks",- function: "create_tunnel",- description: "Create a backend-managed webhook tunnel.",- inputs: vec![- FieldSchema {- name: "name",- ty: TypeSchema::String,- comment: "Tunnel name.",- required: true,- },- FieldSchema {- name: "description",- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment: "Optional tunnel description.",- required: false,- },- ],- outputs: vec![json_output("result", "Created webhook tunnel.")],- },- "delete_tunnel" => ControllerSchema {- namespace: "webhooks",- function: "delete_tunnel",- description: "Delete a backend-managed webhook tunnel.",- inputs: vec![FieldSchema {- name: "id",- ty: TypeSchema::String,- comment: "Backend tunnel id.",- required: true,- }],- outputs: vec![json_output("result", "Delete webhook tunnel result.")],- },- "get_tunnel" => ControllerSchema {- namespace: "webhooks",- function: "get_tunnel",- description: "Fetch a backend-managed webhook tunnel by id.",- inputs: vec![FieldSchema {- name: "id",- ty: TypeSchema::String,- comment: "Backend tunnel id.",- required: true,- }],- outputs: vec![json_output("result", "Webhook tunnel payload.")],- },- "update_tunnel" => ControllerSchema {- namespace: "webhooks",- function: "update_tunnel",- description: "Update a backend-managed webhook tunnel.",- inputs: vec![- FieldSchema {- name: "id",- ty: TypeSchema::String,- comment: "Backend tunnel id.",- required: true,- },- FieldSchema {- name: "name",- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment: "Optional tunnel name.",- required: false,- },- FieldSchema {- name: "description",- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment: "Optional tunnel description.",- required: false,- },- FieldSchema {- name: "isActive",- ty: TypeSchema::Option(Box::new(TypeSchema::Bool)),- comment: "Optional active flag.",- required: false,- },- ],- outputs: vec![json_output("result", "Updated webhook tunnel payload.")],- },- "get_bandwidth" => ControllerSchema {- namespace: "webhooks",- function: "get_bandwidth",- description: "Fetch the remaining webhook bandwidth budget.",- inputs: vec![],- outputs: vec![json_output("result", "Webhook bandwidth payload.")],- },_ => ControllerSchema {namespace: "webhooks",function: "unknown",@@ -446,72 +306,6 @@ fn handle_trigger_agent(params: Map<String, Value>) -> ControllerFuture {})}-fn handle_list_tunnels(_params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = crate::config::rpc::load_config_with_timeout().await?;- to_json(crate::skills::webhooks::ops::list_tunnels(&config).await?)- })-}--fn handle_create_tunnel(params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = crate::config::rpc::load_config_with_timeout().await?;- let payload = deserialize_params::<WebhookCreateTunnelParams>(params)?;- to_json(- crate::skills::webhooks::ops::create_tunnel(- &config,- payload.name.trim(),- payload.description,- )- .await?,- )- })-}--fn handle_delete_tunnel(params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = crate::config::rpc::load_config_with_timeout().await?;- let payload = deserialize_params::<WebhookTunnelIdParams>(params)?;- to_json(crate::skills::webhooks::ops::delete_tunnel(&config, payload.id.trim()).await?)- })-}--fn handle_get_tunnel(params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = crate::config::rpc::load_config_with_timeout().await?;- let payload = deserialize_params::<WebhookTunnelIdParams>(params)?;- to_json(crate::skills::webhooks::ops::get_tunnel(&config, payload.id.trim()).await?)- })-}--fn handle_update_tunnel(params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = crate::config::rpc::load_config_with_timeout().await?;- let payload = deserialize_params::<WebhookUpdateTunnelParams>(params)?;- let mut body = serde_json::Map::new();- if let Some(name) = payload.name {- body.insert("name".to_string(), Value::String(name));- }- if let Some(desc) = payload.description {- body.insert("description".to_string(), Value::String(desc));- }- if let Some(active) = payload.is_active {- body.insert("isActive".to_string(), Value::Bool(active));- }- let body = Value::Object(body);- to_json(- crate::skills::webhooks::ops::update_tunnel(&config, payload.id.trim(), body).await?,- )- })-}--fn handle_get_bandwidth(_params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move {- let config = crate::config::rpc::load_config_with_timeout().await?;- to_json(crate::skills::webhooks::ops::get_bandwidth(&config).await?)- })-}-fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))}diff --git a/crates/openhuman-core/src/skills/webhooks/schemas_tests.rs b/crates/openhuman-core/src/skills/webhooks/schemas_tests.rsindex 01e0a170ee..2b1300082c 100644--- a/crates/openhuman-core/src/skills/webhooks/schemas_tests.rs+++ b/crates/openhuman-core/src/skills/webhooks/schemas_tests.rs@@ -11,12 +11,6 @@ const EXPECTED_FUNCTIONS: &[&str] = &["unregister_echo","register_agent","trigger_agent",- "list_tunnels",- "create_tunnel",- "get_tunnel",- "update_tunnel",- "delete_tunnel",- "get_bandwidth",];#[test]@@ -165,50 +159,6 @@ fn trigger_agent_requires_caller_id_only() {}}-#[test]-fn list_tunnels_has_no_inputs() {- assert!(schemas("list_tunnels").inputs.is_empty());-}--#[test]-fn create_tunnel_requires_name_and_allows_optional_description() {- let s = schemas("create_tunnel");- assert_eq!(required_input_names(&s), vec!["name"]);- assert!(s- .inputs- .iter()- .any(|f| f.name == "description" && !f.required));-}--#[test]-fn get_and_delete_tunnel_require_id_only() {- for fn_name in ["get_tunnel", "delete_tunnel"] {- let s = schemas(fn_name);- assert_eq!(- required_input_names(&s),- vec!["id"],- "`{fn_name}` must require only `id`"- );- }-}--#[test]-fn update_tunnel_requires_id_and_allows_optional_name_description_is_active() {- let s = schemas("update_tunnel");- assert_eq!(required_input_names(&s), vec!["id"]);- for optional in ["name", "description", "isActive"] {- assert!(- s.inputs.iter().any(|f| f.name == optional && !f.required),- "`update_tunnel` must accept optional `{optional}`"- );- }-}--#[test]-fn get_bandwidth_has_no_inputs() {- assert!(schemas("get_bandwidth").inputs.is_empty());-}-#[test]fn unknown_function_returns_error_fallback_schema() {let s = schemas("no_such_fn");