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(agent): add registry ops, rpc, and schemas modules
Steven Enamakel52d4dc079022
diff --git a/crates/openhuman-core/src/agent/registry/ops.rs b/crates/openhuman-core/src/agent/registry/ops.rsindex f272efed3f..4f3ce14cf6 100644--- a/crates/openhuman-core/src/agent/registry/ops.rs+++ b/crates/openhuman-core/src/agent/registry/ops.rs@@ -4,7 +4,7 @@ use std::collections::HashMap;use crate::agent::harness::host_definition::AgentDefinitionRegistry;use crate::agent::OpenHumanSessionHost;-use crate::config::rpc as config_rpc;+use crate::core::runtime::DispatchCtx;use crate::config::Config;use super::defaults::default_agents;@@ -12,15 +12,15 @@ use super::types::{AgentRegistryEntry, AgentRegistryPatch, AgentRegistrySource,const ORCHESTRATOR_AGENT_ID: &str = "orchestrator";-pub async fn list_agents(include_disabled: bool) -> Result<Vec<AgentRegistryEntry>, String> {- let config = config_rpc::load_config_with_timeout().await?;+pub async fn list_agents(ctx: &DispatchCtx, include_disabled: bool) -> Result<Vec<AgentRegistryEntry>, String> {+ let config = ctx.load_config().await?;Ok(merge_entries(&config.agent_registry.entries,include_disabled,))}-pub async fn get_agent(id: &str) -> Result<Option<AgentRegistryEntry>, String> {+pub async fn get_agent(ctx: &DispatchCtx, id: &str) -> Result<Option<AgentRegistryEntry>, String> {let id = id.trim();Ok(list_agents(true).await?@@ -29,6 +29,7 @@ pub async fn get_agent(id: &str) -> Result<Option<AgentRegistryEntry>, String> {}pub async fn upsert_custom_agent(+ ctx: &DispatchCtx,mut entry: AgentRegistryEntry,) -> Result<AgentRegistryEntry, String> {entry.source = AgentRegistrySource::Custom;@@ -41,7 +42,7 @@ pub async fn upsert_custom_agent());}- let mut config = config_rpc::load_config_with_timeout().await?;+ let mut config = ctx.load_config().await?;match config.agent_registry.entries@@ -59,6 +60,7 @@ pub async fn upsert_custom_agent(}pub async fn update_agent(+ ctx: &DispatchCtx,id: &str,patch: AgentRegistryPatch,) -> Result<AgentRegistryEntry, String> {@@ -68,7 +70,7 @@ pub async fn update_agent(}let defaults = default_agents();- let mut config = config_rpc::load_config_with_timeout().await?;+ let mut config = ctx.load_config().await?;let entry = match config.agent_registry.entries@@ -102,8 +104,9 @@ pub async fn update_agent(Ok(updated)}-pub async fn set_agent_enabled(id: &str, enabled: bool) -> Result<AgentRegistryEntry, String> {+pub async fn set_agent_enabled(ctx: &DispatchCtx, id: &str, enabled: bool) -> Result<AgentRegistryEntry, String> {update_agent(+ ctx,id,AgentRegistryPatch {enabled: Some(enabled),@@ -113,13 +116,13 @@ pub async fn set_agent_enabled(id: &str, enabled: bool) -> Result<AgentRegistryE.await}-pub async fn remove_agent(id: &str) -> Result<bool, String> {+pub async fn remove_agent(ctx: &DispatchCtx, id: &str) -> Result<bool, String> {let id = id.trim();if id.is_empty() {return Err("id is required".to_string());}- let mut config = config_rpc::load_config_with_timeout().await?;+ let mut config = ctx.load_config().await?;let before = config.agent_registry.entries.len();config.agent_registry.entries.retain(|agent| agent.id != id);let removed = config.agent_registry.entries.len() < before;@@ -144,8 +147,8 @@ pub async fn remove_agent(id: &str) -> Result<bool, String> {/// live in a separate set and are intentionally not included — the picker/// surfaces the stable built-in surface only. Sorted + deduped by name for a/// stable picker UI.-pub async fn available_tools() -> Result<Vec<AgentToolInfo>, String> {- let config = config_rpc::load_config_with_timeout().await?;+pub async fn available_tools(ctx: &DispatchCtx) -> Result<Vec<AgentToolInfo>, String> {+ let config = ctx.load_config().await?;AgentDefinitionRegistry::init_global(&config.workspace_dir).map_err(|e| format!("failed to initialise AgentDefinitionRegistry: {e}"))?;let agent = OpenHumanSessionHost::from_config_for_agent(&config, ORCHESTRATOR_AGENT_ID)diff --git a/crates/openhuman-core/src/agent/registry/rpc.rs b/crates/openhuman-core/src/agent/registry/rpc.rsindex 4e81a475ff..0e45fad185 100644--- a/crates/openhuman-core/src/agent/registry/rpc.rs+++ b/crates/openhuman-core/src/agent/registry/rpc.rs@@ -3,6 +3,7 @@use serde::{Deserialize, Serialize};use serde_json::Value;+use crate::core::runtime::DispatchCtx;use crate::core::Outcome;use super::ops;@@ -21,10 +22,10 @@ pub struct ListResponse {pub agents: Vec<AgentRegistryEntry>,}-pub async fn list_rpc(req: ListRequest) -> Result<Outcome<ListResponse>, String> {+pub async fn list_rpc(ctx: &DispatchCtx, req: ListRequest) -> Result<Outcome<ListResponse>, String> {Ok(Outcome::new(ListResponse {- agents: ops::list_agents(req.include_disabled).await?,+ agents: ops::list_agents(ctx, req.include_disabled).await?,},vec![],))@@ -43,7 +44,7 @@ pub async fn available_tools_rpc() -> Result<Outcome<AvailableToolsResponse>, String> {Ok(Outcome::new(AvailableToolsResponse {- tools: ops::available_tools().await?,+ tools: ops::available_tools(ctx).await?,},vec![],))@@ -59,10 +60,10 @@ pub struct GetResponse {pub agent: Option<AgentRegistryEntry>,}-pub async fn get_rpc(req: GetRequest) -> Result<Outcome<GetResponse>, String> {+pub async fn get_rpc(ctx: &DispatchCtx, req: GetRequest) -> Result<Outcome<GetResponse>, String> {Ok(Outcome::new(GetResponse {- agent: ops::get_agent(&req.id).await?,+ agent: ops::get_agent(ctx, &req.id).await?,},vec![],))@@ -116,10 +117,10 @@ impl CreateCustomRequest {}}-pub async fn create_custom_rpc(req: CreateCustomRequest) -> Result<Outcome<AgentResponse>, String> {+pub async fn create_custom_rpc(ctx: &DispatchCtx, req: CreateCustomRequest) -> Result<Outcome<AgentResponse>, String> {Ok(Outcome::new(AgentResponse {- agent: ops::upsert_custom_agent(req.into_entry()).await?,+ agent: ops::upsert_custom_agent(ctx, req.into_entry()).await?,},vec![],))@@ -135,10 +136,10 @@ pub struct AgentResponse {pub agent: AgentRegistryEntry,}-pub async fn upsert_custom_rpc(req: UpsertCustomRequest) -> Result<Outcome<AgentResponse>, String> {+pub async fn upsert_custom_rpc(ctx: &DispatchCtx, req: UpsertCustomRequest) -> Result<Outcome<AgentResponse>, String> {Ok(Outcome::new(AgentResponse {- agent: ops::upsert_custom_agent(req.agent).await?,+ agent: ops::upsert_custom_agent(ctx, req.agent).await?,},vec![],))@@ -151,10 +152,10 @@ pub struct UpdateRequest {pub patch: AgentRegistryPatch,}-pub async fn update_rpc(req: UpdateRequest) -> Result<Outcome<AgentResponse>, String> {+pub async fn update_rpc(ctx: &DispatchCtx, req: UpdateRequest) -> Result<Outcome<AgentResponse>, String> {Ok(Outcome::new(AgentResponse {- agent: ops::update_agent(&req.id, req.patch).await?,+ agent: ops::update_agent(ctx, &req.id, req.patch).await?,},vec![],))@@ -166,10 +167,10 @@ pub struct SetEnabledRequest {pub enabled: bool,}-pub async fn set_enabled_rpc(req: SetEnabledRequest) -> Result<Outcome<AgentResponse>, String> {+pub async fn set_enabled_rpc(ctx: &DispatchCtx, req: SetEnabledRequest) -> Result<Outcome<AgentResponse>, String> {Ok(Outcome::new(AgentResponse {- agent: ops::set_agent_enabled(&req.id, req.enabled).await?,+ agent: ops::set_agent_enabled(ctx, &req.id, req.enabled).await?,},vec![],))@@ -185,10 +186,10 @@ pub struct RemoveResponse {pub removed: bool,}-pub async fn remove_rpc(req: RemoveRequest) -> Result<Outcome<RemoveResponse>, String> {+pub async fn remove_rpc(ctx: &DispatchCtx, req: RemoveRequest) -> Result<Outcome<RemoveResponse>, String> {Ok(Outcome::new(RemoveResponse {- removed: ops::remove_agent(&req.id).await?,+ removed: ops::remove_agent(ctx, &req.id).await?,},vec![],))diff --git a/crates/openhuman-core/src/agent/registry/schemas.rs b/crates/openhuman-core/src/agent/registry/schemas.rsindex 548f8bcd0a..5c502ff9b2 100644--- a/crates/openhuman-core/src/agent/registry/schemas.rs+++ b/crates/openhuman-core/src/agent/registry/schemas.rs@@ -214,59 +214,59 @@ pub fn schemas(function: &str) -> ControllerSchema {}}-fn handle_list(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_list(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::ListRequest>(Value::Object(params))?;- to_json(rpc::list_rpc(req).await?)+ to_json(rpc::list_rpc(&ctx, req).await?)})}-fn handle_available_tools(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_available_tools(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::AvailableToolsRequest>(Value::Object(params))?;- to_json(rpc::available_tools_rpc(req).await?)+ to_json(rpc::available_tools_rpc(&ctx, req).await?)})}-fn handle_get(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_get(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::GetRequest>(Value::Object(params))?;- to_json(rpc::get_rpc(req).await?)+ to_json(rpc::get_rpc(&ctx, req).await?)})}-fn handle_create_custom(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_create_custom(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::CreateCustomRequest>(Value::Object(params))?;- to_json(rpc::create_custom_rpc(req).await?)+ to_json(rpc::create_custom_rpc(&ctx, req).await?)})}-fn handle_upsert_custom(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_upsert_custom(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::UpsertCustomRequest>(Value::Object(params))?;- to_json(rpc::upsert_custom_rpc(req).await?)+ to_json(rpc::upsert_custom_rpc(&ctx, req).await?)})}-fn handle_update(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_update(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::UpdateRequest>(Value::Object(params))?;- to_json(rpc::update_rpc(req).await?)+ to_json(rpc::update_rpc(&ctx, req).await?)})}-fn handle_set_enabled(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_set_enabled(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::SetEnabledRequest>(Value::Object(params))?;- to_json(rpc::set_enabled_rpc(req).await?)+ to_json(rpc::set_enabled_rpc(&ctx, req).await?)})}-fn handle_remove(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_remove(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let req = parse_value::<rpc::RemoveRequest>(Value::Object(params))?;- to_json(rpc::remove_rpc(req).await?)+ to_json(rpc::remove_rpc(&ctx, req).await?)})}