Skip to content

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

refactor(config): route RPC handlers through DispatchCtx::load_config

Steven Enamakelfb7c0cf9664f
diff --git a/crates/openhuman-core/src/agent/artifacts/schemas.rs b/crates/openhuman-core/src/agent/artifacts/schemas.rs
index 4b38c11c0c..4833c5ad01 100644
--- a/crates/openhuman-core/src/agent/artifacts/schemas.rs
+++ b/crates/openhuman-core/src/agent/artifacts/schemas.rs
@@ -253,9 +253,9 @@ fn artifact_id_input(comment: &'static str) -> FieldSchema {
}
}
-fn handle_list_artifacts(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_artifacts(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let offset = read_optional_u64(&params, "offset")?
.map(|raw| {
usize::try_from(raw).map_err(|_| "offset is too large for usize".to_string())
@@ -277,17 +277,17 @@ fn handle_list_artifacts(_ctx: DispatchCtx, params: Map<String, Value>) -> Contr
})
}
-fn handle_get_artifact(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_artifact(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let artifact_id = read_required::<String>(&params, "artifact_id")?;
to_json(crate::agent::artifacts::ops::ai_get_artifact(&config, artifact_id.trim()).await?)
})
}
-fn handle_delete_artifact(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_delete_artifact(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let artifact_id = read_required::<String>(&params, "artifact_id")?;
to_json(
crate::agent::artifacts::ops::ai_delete_artifact(&config, artifact_id.trim()).await?,
@@ -295,9 +295,9 @@ fn handle_delete_artifact(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-fn handle_regenerate(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_regenerate(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let artifact_id = read_required::<String>(&params, "artifact_id")?;
let thread_id = read_required::<String>(&params, "thread_id")?;
let client_id = read_required::<String>(&params, "client_id")?;
diff --git a/crates/openhuman-core/src/agent/orchestration/agent_teams/schemas.rs b/crates/openhuman-core/src/agent/orchestration/agent_teams/schemas.rs
index 6c71004f42..745a7b52b3 100644
--- a/crates/openhuman-core/src/agent/orchestration/agent_teams/schemas.rs
+++ b/crates/openhuman-core/src/agent/orchestration/agent_teams/schemas.rs
@@ -253,11 +253,11 @@ fn schema_for(function: &str) -> ControllerSchema {
}
}
-fn handle_create(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] create.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] create.config_failed err={err}");
})?;
let lead = require_str(&params, "leadAgentId")?;
@@ -278,11 +278,11 @@ fn handle_create(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-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 cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] list.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] list.config_failed err={err}");
})?;
let request: AgentTeamListRequest = if params.is_empty() {
@@ -304,11 +304,11 @@ fn handle_list(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
})
}
-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 cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] get.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] get.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -320,11 +320,11 @@ fn handle_get(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
})
}
-fn handle_assign_task(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_assign_task(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] assign_task.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] assign_task.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -347,11 +347,11 @@ fn handle_assign_task(_ctx: DispatchCtx, params: Map<String, Value>) -> Controll
})
}
-fn handle_claim_task(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_claim_task(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] claim_task.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] claim_task.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -366,11 +366,11 @@ fn handle_claim_task(_ctx: DispatchCtx, params: Map<String, Value>) -> Controlle
})
}
-fn handle_message_member(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_message_member(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] message_member.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] message_member.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -394,11 +394,11 @@ fn handle_message_member(_ctx: DispatchCtx, params: Map<String, Value>) -> Contr
})
}
-fn handle_list_messages(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_messages(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] list_messages.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] list_messages.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -414,11 +414,11 @@ fn handle_list_messages(_ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-fn handle_complete_task(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_complete_task(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] complete_task.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] complete_task.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -438,11 +438,11 @@ fn handle_complete_task(_ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-fn handle_shutdown_member(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_shutdown_member(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] shutdown_member.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] shutdown_member.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -455,11 +455,11 @@ fn handle_shutdown_member(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-fn handle_close(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_close(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] close.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] close.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
@@ -472,11 +472,11 @@ fn handle_close(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu
})
}
-fn handle_start_member(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_start_member(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] start_member.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "agent_team_rpc", "[agent_team_rpc][{cid}] start_member.config_failed err={err}");
})?;
let team_id = require_str(&params, "teamId")?;
diff --git a/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs b/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs
index c30db20372..f5f05a9ade 100644
--- a/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs
+++ b/crates/openhuman-core/src/agent/orchestration/command_center/schemas.rs
@@ -86,11 +86,11 @@ fn schema_for(function: &str) -> ControllerSchema {
}
}
-fn handle_agent_work_list(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_agent_work_list(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "command_center_rpc", "[command_center_rpc][{cid}] list.entry");
- let config = config_rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.inspect_err(|err| {
log::warn!(target: "command_center_rpc", "[command_center_rpc][{cid}] list.config_failed err={err}");
@@ -112,11 +112,11 @@ fn handle_agent_work_list(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-fn handle_agent_work_control(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_agent_work_control(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "command_center_rpc", "[command_center_rpc][{cid}] control.entry");
- let config = config_rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.inspect_err(|err| {
log::warn!(target: "command_center_rpc", "[command_center_rpc][{cid}] control.config_failed err={err}");
diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/schemas.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/schemas.rs
index e858c937d5..20927321ca 100644
--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/schemas.rs
+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/schemas.rs
@@ -143,11 +143,11 @@ fn handle_list_definitions(_ctx: DispatchCtx, _params: Map<String, Value>) -> Co
})
}
-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 cid = new_correlation_id();
log::debug!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] list.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] list.config_failed err={err}");
})?;
let request: WorkflowRunListRequest = if params.is_empty() {
@@ -171,11 +171,11 @@ fn handle_list(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
})
}
-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 cid = new_correlation_id();
log::debug!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] get.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] get.config_failed err={err}");
})?;
let id = params
@@ -193,11 +193,11 @@ fn handle_get(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
})
}
-fn handle_start(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_start(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] start.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] start.config_failed err={err}");
})?;
let definition_id = params
@@ -228,11 +228,11 @@ fn handle_start(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu
})
}
-fn handle_stop(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_stop(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] stop.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] stop.config_failed err={err}");
})?;
let id = params
@@ -250,11 +250,11 @@ fn handle_stop(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
})
}
-fn handle_resume(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_resume(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] resume.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "workflow_run_rpc", "[workflow_run_rpc][{cid}] resume.config_failed err={err}");
})?;
let id = params
diff --git a/crates/openhuman-core/src/agent/schemas.rs b/crates/openhuman-core/src/agent/schemas.rs
index caac889ec8..a93d7d11d4 100644
--- a/crates/openhuman-core/src/agent/schemas.rs
+++ b/crates/openhuman-core/src/agent/schemas.rs
@@ -260,10 +260,10 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_chat(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_chat(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<AgentChatParams>(params)?;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
to_json(
crate::inference::host_runtime::rpc::agent_chat(
&mut config,
@@ -283,10 +283,10 @@ fn handle_chat(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
})
}
-fn handle_chat_simple(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_chat_simple(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<AgentChatParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::host_runtime::rpc::agent_chat_simple(
&config,
@@ -577,7 +577,7 @@ fn local_catalog_models_from_config(
.collect()
}
-fn handle_registry_snapshot(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_registry_snapshot(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
use tinyagents_registry::{ComponentKind, ComponentMetadata, RegistrySnapshot};
@@ -588,7 +588,7 @@ fn handle_registry_snapshot(_ctx: DispatchCtx, _params: Map<String, Value>) -> C
// any entry whose provider is a local runtime (ollama, lmstudio, mlx, …)
// is overlaid as a free, runtime-profiled catalog entry so local models
// appear in the one projection alongside priced vendor rows.
- let local_models = match config_rpc::load_config_with_timeout().await {
+ let local_models = match ctx.load_config().await {
Ok(config) => local_catalog_models_from_config(&config),
Err(err) => {
tracing::debug!(
diff --git a/crates/openhuman-core/src/agent/session_db/schemas.rs b/crates/openhuman-core/src/agent/session_db/schemas.rs
index 5531444bbc..07c5c929d6 100644
--- a/crates/openhuman-core/src/agent/session_db/schemas.rs
+++ b/crates/openhuman-core/src/agent/session_db/schemas.rs
@@ -95,11 +95,11 @@ fn new_correlation_id() -> String {
uuid::Uuid::new_v4().simple().to_string()[..8].to_string()
}
-fn handle_run_ledger_list(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_run_ledger_list(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "run_ledger_rpc", "[run_ledger_rpc][{cid}] list.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "run_ledger_rpc", "[run_ledger_rpc][{cid}] list.config_failed err={err}");
})?;
let request: AgentRunListRequest = if params.is_empty() {
@@ -125,11 +125,11 @@ fn handle_run_ledger_list(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-fn handle_run_ledger_get(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_run_ledger_get(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "run_ledger_rpc", "[run_ledger_rpc][{cid}] get.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "run_ledger_rpc", "[run_ledger_rpc][{cid}] get.config_failed err={err}");
})?;
let id = params
@@ -149,11 +149,11 @@ fn handle_run_ledger_get(_ctx: DispatchCtx, params: Map<String, Value>) -> Contr
})
}
-fn handle_run_ledger_events(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_run_ledger_events(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "run_ledger_rpc", "[run_ledger_rpc][{cid}] events.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "run_ledger_rpc", "[run_ledger_rpc][{cid}] events.config_failed err={err}");
})?;
let request: RunEventListRequest =
diff --git a/crates/openhuman-core/src/channels/controllers/schemas.rs b/crates/openhuman-core/src/channels/controllers/schemas.rs
index 6bcc7a2c78..9d2ef8773b 100644
--- a/crates/openhuman-core/src/channels/controllers/schemas.rs
+++ b/crates/openhuman-core/src/channels/controllers/schemas.rs
@@ -239,9 +239,9 @@ fn handle_describe(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerF
})
}
-fn handle_connect(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_connect(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<ConnectParams>(params)?;
connect_with_config(&config, p).await
})
@@ -259,9 +259,9 @@ async fn connect_with_config(config: &Config, p: ConnectParams) -> Result<Value,
to_json(Outcome::new(outcome.value, logs))
}
-fn handle_disconnect(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_disconnect(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<DisconnectParams>(params)?;
let channel = p.channel.trim();
let mode: ChannelAuthMode = p
@@ -283,9 +283,9 @@ fn handle_disconnect(_ctx: DispatchCtx, params: Map<String, Value>) -> Controlle
})
}
-fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_status(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = if params.is_empty() {
StatusParams { channel: None }
} else {
@@ -305,24 +305,24 @@ fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-fn handle_set_default(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_set_default(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
let p = deserialize_params::<SetDefaultParams>(params)?;
to_json(super::ops::set_default_channel(&mut config, p.channel.trim()).await?)
})
}
-fn handle_get_default(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_default(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(super::ops::get_default_channel(&config)?)
})
}
-fn handle_test(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_test(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<TestParams>(params)?;
test_with_config(&config, p).await
})
@@ -338,27 +338,27 @@ async fn test_with_config(config: &Config, params: TestParams) -> Result<Value,
)
}
-fn handle_discord_list_guilds(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_discord_list_guilds(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(super::ops::discord_list_guilds(&config).await?)
})
}
-fn handle_discord_list_channels(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_discord_list_channels(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<DiscordListChannelsParams>(params)?;
to_json(super::ops::discord_list_channels(&config, p.guild_id.trim()).await?)
})
}
fn handle_discord_check_permissions(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<DiscordCheckPermissionsParams>(params)?;
to_json(
super::ops::discord_check_permissions(&config, p.guild_id.trim(), p.channel_id.trim())
@@ -367,9 +367,9 @@ fn handle_discord_check_permissions(
})
}
-fn handle_send_message(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_send_message(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<SendMessageParams>(params)?;
send_with_config(&config, p).await
})
@@ -393,9 +393,9 @@ async fn send_with_config(config: &Config, p: SendMessageParams) -> Result<Value
))
}
-fn handle_send_reaction(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_send_reaction(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<SendReactionParams>(params)?;
let backend = OpenHumanChannelBackend::new(config.clone());
let result = backend
@@ -409,9 +409,9 @@ fn handle_send_reaction(_ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-fn handle_create_thread(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_create_thread(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<CreateThreadParams>(params)?;
let backend = OpenHumanChannelBackend::new(config.clone());
let result = backend
@@ -425,9 +425,9 @@ fn handle_create_thread(_ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-fn handle_update_thread(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_update_thread(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<UpdateThreadParams>(params)?;
let backend = OpenHumanChannelBackend::new(config.clone());
let result = backend
@@ -446,9 +446,9 @@ fn handle_update_thread(_ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-fn handle_list_threads(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_threads(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<ListThreadsParams>(params)?;
let backend = OpenHumanChannelBackend::new(config.clone());
let result = backend
diff --git a/crates/openhuman-core/src/config/ops/mod.rs b/crates/openhuman-core/src/config/ops/mod.rs
index 0852f67a56..977ac18a9c 100644
--- a/crates/openhuman-core/src/config/ops/mod.rs
+++ b/crates/openhuman-core/src/config/ops/mod.rs
@@ -24,7 +24,7 @@ pub use loader::{
agent_server_status, client_config_json, core_rpc_url_from_env, get_config_snapshot,
get_dashboard_settings, get_data_paths, get_data_paths_for_user, get_runtime_flags,
load_and_get_client_config_snapshot, load_and_get_config_snapshot,
- load_config_for_workspace_with_timeout, load_config_with_timeout, load_current_or_init,
+ load_config_for_workspace_with_timeout, load_config_in, load_config_with_timeout, load_current_or_init,
reload_config_from_paths, reload_config_snapshot_with_timeout, reset_local_data,
set_browser_allow_all, snapshot_config_json, RuntimeFlagsOut,
};
diff --git a/crates/openhuman-core/src/config/schemas/controllers/voice.rs b/crates/openhuman-core/src/config/schemas/controllers/voice.rs
index 4dddde119b..f0264eb2d5 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/voice.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/voice.rs
@@ -43,7 +43,7 @@ pub(super) fn handle_get_voice_server_settings(
}
pub(super) fn handle_update_voice_server_settings(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
@@ -65,7 +65,7 @@ pub(super) fn handle_update_voice_server_settings(
// Settings switch takes effect without a restart. Don't fail the RPC if
// the reload hiccups, but DO surface it — otherwise the saved setting
// silently wouldn't apply until the next launch.
- match config_rpc::load_config_with_timeout().await {
+ match ctx.load_config().await {
Ok(config) => {
log::info!("[config][rpc] voice settings saved; applying live always-on state");
crate::voice::always_on::start_if_enabled(&config).await;
diff --git a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
index c04b46d7f1..e8e2df3748 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
@@ -69,11 +69,11 @@ pub(super) fn handle_update_user_timezone(
}
pub(super) fn handle_get_user_timezone(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::core::Outcome::single_log(
config_rpc::user_timezone_json(&config),
"user time zone read",
@@ -82,12 +82,12 @@ pub(super) fn handle_get_user_timezone(
}
pub(super) fn handle_get_analytics_settings(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async {
use crate::core::Outcome;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = serde_json::json!({
"enabled": config.observability.analytics_enabled,
});
diff --git a/crates/openhuman-core/src/config/workspace/schemas.rs b/crates/openhuman-core/src/config/workspace/schemas.rs
index 2a3da492e2..c5c28e0a9d 100644
--- a/crates/openhuman-core/src/config/workspace/schemas.rs
+++ b/crates/openhuman-core/src/config/workspace/schemas.rs
@@ -116,9 +116,9 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_file_read(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_file_read(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let filename = read_required::<String>(&params, "filename")?;
let filename = filename.trim();
log::debug!("[workspace][rpc] handle_file_read filename='{filename}'");
@@ -130,9 +130,9 @@ fn handle_file_read(_ctx: DispatchCtx, params: Map<String, Value>) -> Controller
})
}
-fn handle_file_write(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_file_write(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let filename = read_required::<String>(&params, "filename")?;
let contents = read_required::<String>(&params, "contents")?;
let filename = filename.trim();
@@ -149,9 +149,9 @@ fn handle_file_write(_ctx: DispatchCtx, params: Map<String, Value>) -> Controlle
})
}
-fn handle_file_reset(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_file_reset(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let filename = read_required::<String>(&params, "filename")?;
let filename = filename.trim();
log::debug!("[workspace][rpc] handle_file_reset filename='{filename}'");
diff --git a/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs b/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
index 16c5ce1438..b32577076a 100644
--- a/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
+++ b/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs
@@ -81,6 +81,14 @@ impl DispatchCtx {
.and_then(|core| core.embedder_config().cloned())
}
+ /// Loads the config this call runs against: the bound context's embedder
+ /// config when it has one, else the persisted config. Fails closed in
+ /// SaaS when no context is bound. See
+ /// [`load_config_in`](crate::config::ops::load_config_in).
+ pub async fn load_config(&self) -> Result<crate::config::Config, String> {
+ crate::config::ops::load_config_in(self).await
+ }
+
/// The context this call runs under, if any.
pub fn core(&self) -> Option<&Arc<CoreContext>> {
self.core.as_ref()
diff --git a/crates/openhuman-core/src/cron/schemas.rs b/crates/openhuman-core/src/cron/schemas.rs
index 5eb382e1df..44659ff0fa 100644
--- a/crates/openhuman-core/src/cron/schemas.rs
+++ b/crates/openhuman-core/src/cron/schemas.rs
@@ -282,9 +282,9 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_add(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_add(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let schedule: tinyflows_schedule::types::Schedule = read_required(&params, "schedule")?;
let name = params
@@ -403,41 +403,41 @@ fn handle_add(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
})
}
-fn handle_list(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_list(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::cron::rpc::cron_list(&config).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let job_id = read_required::<String>(&params, "job_id")?;
let patch = read_required::<CronJobPatch>(&params, "patch")?;
to_json(crate::cron::rpc::cron_update(&config, job_id.trim(), patch).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let job_id = read_required::<String>(&params, "job_id")?;
to_json(crate::cron::rpc::cron_remove(&config, job_id.trim()).await?)
})
}
-fn handle_run(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let job_id = read_required::<String>(&params, "job_id")?;
to_json(crate::cron::rpc::cron_run(&config, job_id.trim()).await?)
})
}
-fn handle_runs(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_runs(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let job_id = read_required::<String>(&params, "job_id")?;
let limit = read_optional_u64(&params, "limit")?
.map(|raw| usize::try_from(raw).map_err(|_| "limit is too large for usize".to_string()))
diff --git a/crates/openhuman-core/src/desktop/control/schemas.rs b/crates/openhuman-core/src/desktop/control/schemas.rs
index a1f4197168..3acaa28b78 100644
--- a/crates/openhuman-core/src/desktop/control/schemas.rs
+++ b/crates/openhuman-core/src/desktop/control/schemas.rs
@@ -76,9 +76,9 @@ fn schema(function: &'static str) -> ControllerSchema {
}
}
-fn status(_ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
+fn status(ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
crate::core::runtime::components::require_config(&config, "computer")?;
@@ -86,13 +86,13 @@ fn status(_ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
})
}
-fn set_enabled(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn set_enabled(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let value = params
.get("enabled")
.and_then(Value::as_bool)
.ok_or_else(|| "enabled must be a boolean".to_owned())?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
crate::core::runtime::components::require_config(&config, "computer")?;
@@ -101,9 +101,9 @@ fn set_enabled(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
})
}
-fn probe(_ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
+fn probe(ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
crate::core::runtime::components::require_config(&config, "computer")?;
@@ -111,9 +111,9 @@ fn probe(_ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
})
}
-fn pending(_ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
+fn pending(ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
crate::core::runtime::components::require_config(&config, "computer")?;
@@ -121,7 +121,7 @@ fn pending(_ctx: DispatchCtx, _: Map<String, Value>) -> ControllerFuture {
})
}
-fn confirm(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn confirm(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let id = params
.get("confirmation_id")
@@ -132,7 +132,7 @@ fn confirm(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
.get("approve")
.and_then(Value::as_bool)
.ok_or_else(|| "approve must be a boolean".to_owned())?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
crate::core::runtime::components::require_config(&config, "computer")?;
diff --git a/crates/openhuman-core/src/desktop/dashboard/schemas.rs b/crates/openhuman-core/src/desktop/dashboard/schemas.rs
index 10d5159529..8b8bcdbe80 100644
--- a/crates/openhuman-core/src/desktop/dashboard/schemas.rs
+++ b/crates/openhuman-core/src/desktop/dashboard/schemas.rs
@@ -164,12 +164,12 @@ fn model_health_config_fields() -> Vec<FieldSchema> {
}
fn handle_dashboard_model_health(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
log::debug!("[dashboard] model_health request received");
- let cfg = crate::config::rpc::load_config_with_timeout()
+ let cfg = ctx.load_config()
.await
.map_err(|err| {
log::warn!("[dashboard] model_health failed to load config: {err}");
diff --git a/crates/openhuman-core/src/flows/schemas_handlers.rs b/crates/openhuman-core/src/flows/schemas_handlers.rs
index c10faae4ff..983493c596 100644
--- a/crates/openhuman-core/src/flows/schemas_handlers.rs
+++ b/crates/openhuman-core/src/flows/schemas_handlers.rs
@@ -1,7 +1,7 @@
use crate::core::runtime::DispatchCtx;
-fn handle_create(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let name = read_required::<String>(&params, "name")?;
let graph = read_required::<Value>(&params, "graph")?;
let require_approval = params
@@ -44,39 +44,39 @@ fn handle_import(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-fn handle_duplicate(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_duplicate(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_duplicate(&config, id.trim()).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_get(&config, id.trim()).await?)
})
}
-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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::flows_list(&config).await?)
})
}
-fn handle_list_connections(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_connections(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::flows_list_connections(&config).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let name = params
.get("name")
@@ -116,17 +116,17 @@ fn handle_update(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-fn handle_delete(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_delete(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_delete(&config, id.trim()).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let enabled = params
.get("enabled")
@@ -136,9 +136,9 @@ fn handle_set_enabled(_ctx: DispatchCtx, params: Map<String, Value>) -> Controll
})
}
-fn handle_run(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let input = params.get("input").cloned().unwrap_or(Value::Null);
let inputs = read_declared_inputs(&params)?;
@@ -155,9 +155,9 @@ fn handle_run(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
})
}
-fn handle_run_detached(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_run_detached(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let input = params.get("input").cloned().unwrap_or(Value::Null);
let inputs = read_declared_inputs(&params)?;
@@ -198,9 +198,9 @@ fn read_declared_inputs(params: &Map<String, Value>) -> Result<Map<String, Value
}
}
-fn handle_resume(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_resume(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let thread_id = read_required::<String>(&params, "thread_id")?;
let approvals: Vec<String> = params
@@ -225,17 +225,17 @@ fn handle_resume(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-fn handle_cancel_run(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_cancel_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let run_id = read_required::<String>(&params, "run_id")?;
to_json(ops::flows_cancel_run(&config, run_id.trim()).await?)
})
}
-fn handle_list_runs(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_runs(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let limit = params
.get("limit")
@@ -246,9 +246,9 @@ fn handle_list_runs(_ctx: DispatchCtx, params: Map<String, Value>) -> Controller
})
}
-fn handle_list_all_runs(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_all_runs(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let limit = params
.get("limit")
.and_then(Value::as_u64)
@@ -258,25 +258,25 @@ fn handle_list_all_runs(_ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-fn handle_get_run(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let run_id = read_required::<String>(&params, "run_id")?;
to_json(ops::flows_get_run(&config, run_id.trim()).await?)
})
}
-fn handle_prune_runs(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_prune_runs(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_prune_runs(&config, id.trim()).await?)
})
}
-fn handle_build(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_build(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// Optional streaming target: when the copilot passes its chat `thread_id`
// the builder turn streams live text/tool/proposal events into that
// thread (Phase B). Read + strip the transport-only keys before the rest
@@ -303,9 +303,9 @@ fn handle_build_cancel(_ctx: DispatchCtx, params: Map<String, Value>) -> Control
})
}
-fn handle_discover(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_discover(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// Optional streaming target for the Flow Scout run (Phase B) — same
// `thread_id`/`request_id` convention as `flows.build`.
let stream = read_flow_stream_target(&params);
@@ -329,9 +329,9 @@ fn read_flow_stream_target(params: &Map<String, Value>) -> Option<ops::FlowStrea
ops::FlowStreamTarget::from_params(thread_id, request_id)
}
-fn handle_list_suggestions(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_suggestions(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let status = params
.get("status")
.and_then(Value::as_str)
@@ -342,33 +342,33 @@ fn handle_list_suggestions(_ctx: DispatchCtx, params: Map<String, Value>) -> Con
})
}
-fn handle_dismiss_suggestion(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_dismiss_suggestion(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_dismiss_suggestion(&config, id.trim()).await?)
})
}
-fn handle_mark_suggestion_built(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_mark_suggestion_built(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_mark_suggestion_built(&config, id.trim()).await?)
})
}
-fn handle_required_connections(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_required_connections(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let graph = read_required::<Value>(&params, "graph")?;
to_json(ops::flows_required_connections(&config, graph).await?)
})
}
-fn handle_approval_manifest(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_approval_manifest(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = params
.get("id")
.and_then(Value::as_str)
@@ -379,9 +379,9 @@ fn handle_approval_manifest(_ctx: DispatchCtx, params: Map<String, Value>) -> Co
})
}
-fn handle_search_tool_catalog(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_search_tool_catalog(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let query = read_required::<String>(&params, "query")?;
let toolkit = params
.get("toolkit")
@@ -396,17 +396,17 @@ fn handle_search_tool_catalog(_ctx: DispatchCtx, params: Map<String, Value>) ->
})
}
-fn handle_get_tool_contract(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_tool_contract(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let slug = read_required::<String>(&params, "slug")?;
to_json(ops::flows_get_tool_contract(&config, slug.trim()).await?)
})
}
-fn handle_get_history(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_history(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let limit = params
.get("limit")
@@ -417,9 +417,9 @@ fn handle_get_history(_ctx: DispatchCtx, params: Map<String, Value>) -> Controll
})
}
-fn handle_rollback(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_rollback(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let revision_id = read_required::<String>(&params, "revision_id")?;
let expected_version = params
@@ -433,9 +433,9 @@ fn handle_rollback(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerF
})
}
-fn handle_draft_create(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_draft_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let name = read_required::<String>(&params, "name")?;
let graph = read_required::<Value>(&params, "graph")?;
let flow_id = params
@@ -454,17 +454,17 @@ fn handle_draft_create(_ctx: DispatchCtx, params: Map<String, Value>) -> Control
})
}
-fn handle_draft_get(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_draft_get(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_draft_get(&config, id.trim())?)
})
}
-fn handle_draft_update(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_draft_update(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let name = params
.get("name")
@@ -485,24 +485,24 @@ fn handle_draft_update(_ctx: DispatchCtx, params: Map<String, Value>) -> Control
})
}
-fn handle_draft_list(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_draft_list(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::flows_draft_list(&config)?)
})
}
-fn handle_draft_delete(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_draft_delete(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::flows_draft_delete(&config, id.trim())?)
})
}
-fn handle_draft_promote(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_draft_promote(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let require_approval = params.get("require_approval").and_then(Value::as_bool);
to_json(ops::flows_draft_promote(&config, id.trim(), require_approval).await?)
diff --git a/crates/openhuman-core/src/hooks/schemas.rs b/crates/openhuman-core/src/hooks/schemas.rs
index 5ee5f25712..92cf0cf3c6 100644
--- a/crates/openhuman-core/src/hooks/schemas.rs
+++ b/crates/openhuman-core/src/hooks/schemas.rs
@@ -109,9 +109,9 @@ fn handle_list(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFutu
Box::pin(async move { Ok(describe(super::host::engine().snapshot().await.as_ref())) })
}
-fn handle_reload(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_reload(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
super::ops::init(&config).await;
Ok(describe(super::host::engine().snapshot().await.as_ref()))
})
diff --git a/crates/openhuman-core/src/inference/embedding_host/schemas.rs b/crates/openhuman-core/src/inference/embedding_host/schemas.rs
index bdb17dd4b7..f2bf987ffb 100644
--- a/crates/openhuman-core/src/inference/embedding_host/schemas.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/schemas.rs
@@ -171,9 +171,9 @@ struct TestConnectionParams {
// ── Handlers ───────────────────────────────────────────────
-fn handle_get_settings(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_settings(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(super::rpc::get_settings(&config).await?)
})
}
@@ -194,34 +194,34 @@ fn handle_update_settings(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-fn handle_set_api_key(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_set_api_key(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<SetApiKeyParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(super::rpc::set_api_key(&config, &p.provider, &p.api_key).await?)
})
}
-fn handle_clear_api_key(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_clear_api_key(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<ClearApiKeyParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(super::rpc::clear_api_key(&config, &p.provider).await?)
})
}
-fn handle_embed(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_embed(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<EmbedParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(super::rpc::embed(&config, &p.inputs).await?)
})
}
-fn handle_test_connection(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_test_connection(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<TestConnectionParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
super::rpc::test_connection(
&config,
diff --git a/crates/openhuman-core/src/inference/host_runtime/schemas.rs b/crates/openhuman-core/src/inference/host_runtime/schemas.rs
index 32e88edd21..a088eba570 100644
--- a/crates/openhuman-core/src/inference/host_runtime/schemas.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/schemas.rs
@@ -223,10 +223,10 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_agent_chat(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_agent_chat(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<AgentChatParams>(params)?;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
let target = match p.agent_id.as_deref().map(str::trim) {
Some(id) if !id.is_empty() => {
crate::inference::host_runtime::ops::AgentChatTarget::AgentId(id)
@@ -250,10 +250,10 @@ fn handle_agent_chat(_ctx: DispatchCtx, params: Map<String, Value>) -> Controlle
})
}
-fn handle_agent_chat_simple(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_agent_chat_simple(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<AgentChatParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::host_runtime::ops::agent_chat_simple(
&config,
@@ -267,10 +267,10 @@ fn handle_agent_chat_simple(_ctx: DispatchCtx, params: Map<String, Value>) -> Co
})
}
-fn handle_local_ai_transcribe(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_local_ai_transcribe(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<LocalAiTranscribeParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::host_runtime::ops::local_ai_transcribe(&config, p.audio_path.trim())
.await?,
@@ -279,12 +279,12 @@ fn handle_local_ai_transcribe(_ctx: DispatchCtx, params: Map<String, Value>) ->
}
fn handle_local_ai_transcribe_bytes(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<LocalAiTranscribeBytesParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::host_runtime::ops::local_ai_transcribe_bytes(
&config,
@@ -296,10 +296,10 @@ fn handle_local_ai_transcribe_bytes(
})
}
-fn handle_local_ai_tts(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_local_ai_tts(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<LocalAiTtsParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::host_runtime::ops::local_ai_tts(
&config,
diff --git a/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs b/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
index 58e5bcf1f3..289361f3a5 100644
--- a/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
@@ -46,12 +46,12 @@ pub(super) fn handle_inference_claude_code_auth_status(
}
pub(super) fn handle_inference_claude_code_settings(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
use tinyagents_harness::providers::claude_code::settings;
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let workspace = config.config_path.parent().unwrap_or(&config.workspace_dir);
let settings = settings::load(workspace);
log::debug!(
@@ -63,13 +63,13 @@ pub(super) fn handle_inference_claude_code_settings(
}
pub(super) fn handle_inference_claude_code_set_full_access(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
use tinyagents_harness::providers::claude_code::settings;
Box::pin(async move {
let p = deserialize_params::<InferenceClaudeCodeSetFullAccessParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let workspace = config.config_path.parent().unwrap_or(&config.workspace_dir);
let settings = settings::ClaudeCodeSettings {
full_access: p.enabled,
diff --git a/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs b/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs
index fbe2ae16d6..4ede57b6bd 100644
--- a/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs
@@ -16,21 +16,21 @@ pub(super) struct InferenceOpenAiOAuthCompleteParams {
}
pub(super) fn handle_inference_openai_oauth_start(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_openai_oauth_start(&config).await?)
})
}
pub(super) fn handle_inference_openai_oauth_complete(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload = deserialize_params::<InferenceOpenAiOAuthCompleteParams>(params)?;
to_json(
crate::inference::rpc::inference_openai_oauth_complete(
@@ -43,31 +43,31 @@ pub(super) fn handle_inference_openai_oauth_complete(
}
pub(super) fn handle_inference_openai_oauth_import_codex_cli(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_openai_oauth_import_codex_cli(&config).await?)
})
}
pub(super) fn handle_inference_openai_oauth_status(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_openai_oauth_status(&config).await?)
})
}
pub(super) fn handle_inference_openai_oauth_disconnect(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_openai_oauth_disconnect(&config).await?)
})
}
diff --git a/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs b/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs
index cf079b7b8d..ae5fa67d2c 100644
--- a/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs
@@ -42,23 +42,23 @@ pub(super) struct InferenceAnalyzeSentimentParams {
}
pub(super) fn handle_inference_summarize(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<InferenceSummarizeParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_summarize(&config, &p.text, p.max_tokens).await?)
})
}
pub(super) fn handle_inference_prompt(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<InferencePromptParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::rpc::inference_prompt(&config, &p.prompt, p.max_tokens, p.no_think)
.await?,
@@ -67,12 +67,12 @@ pub(super) fn handle_inference_prompt(
}
pub(super) fn handle_inference_vision_prompt(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<InferenceVisionPromptParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::rpc::inference_vision_prompt(
&config,
@@ -86,12 +86,12 @@ pub(super) fn handle_inference_vision_prompt(
}
pub(super) fn handle_inference_test_provider_model(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<InferenceTestChatModelParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::inference::rpc::inference_test_provider_model(
&config,
@@ -105,12 +105,12 @@ pub(super) fn handle_inference_test_provider_model(
}
pub(super) fn handle_inference_analyze_sentiment(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<InferenceAnalyzeSentimentParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_analyze_sentiment(&config, &p.message).await?)
})
}
diff --git a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
index 39f89e475a..d6be1b7102 100644
--- a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
@@ -82,12 +82,12 @@ pub(super) struct InferenceListModelsParams {
}
pub(super) fn handle_inference_resolve_model(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<InferenceResolveModelParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let resolved =
crate::inference::provider::factory::resolve_model_for_hint(&p.hint, &config);
// Whether the resolved model accepts image input — drives the chat UI's
@@ -105,11 +105,11 @@ pub(super) fn handle_inference_resolve_model(
}
pub(super) fn handle_inference_status(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_status(&config).await?)
})
}
@@ -303,11 +303,11 @@ pub(super) fn handle_inference_provider_auth_errors(
}
pub(super) fn handle_inference_diagnostics(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::inference::rpc::inference_diagnostics(&config).await?)
})
}
diff --git a/crates/openhuman-core/src/inference/tokenjuice/schemas.rs b/crates/openhuman-core/src/inference/tokenjuice/schemas.rs
index 041a25d60f..81aecd48df 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/schemas.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/schemas.rs
@@ -369,10 +369,10 @@ fn handle_retrieve(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerF
})
}
-fn handle_settings_get(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_settings_get(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|e| format!("load config: {e}"))?;
let settings = serde_json::to_value(&config.tokenjuice)
@@ -381,7 +381,7 @@ fn handle_settings_get(_ctx: DispatchCtx, _params: Map<String, Value>) -> Contro
})
}
-fn handle_settings_update(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_settings_update(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
// Accept either {"patch": {...}} or a bare object of fields.
@@ -392,7 +392,7 @@ fn handle_settings_update(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
let patch: super::config_patch::TokenjuiceSettingsPatch =
serde_json::from_value(patch).map_err(|e| format!("invalid patch: {e}"))?;
- let mut config = crate::config::rpc::load_config_with_timeout()
+ let mut config = ctx.load_config()
.await
.map_err(|e| format!("load config: {e}"))?;
patch.apply(&mut config.tokenjuice);
@@ -410,11 +410,11 @@ fn handle_settings_update(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-fn handle_savings_stats(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_savings_stats(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
let cache = super::cache_stats().await?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|e| e.to_string())?;
super::install_from_config(&config).await?;
@@ -429,10 +429,10 @@ fn handle_savings_stats(_ctx: DispatchCtx, _params: Map<String, Value>) -> Contr
})
}
-fn handle_savings_reset(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_savings_reset(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|e| e.to_string())?;
super::install_from_config(&config).await?;
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
index e68c2ea695..6e07a8b9ef 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
@@ -13,48 +13,48 @@ use crate::integrations::composio::ops;
use super::util::{read_optional, read_required_non_empty, to_json};
pub(super) fn handle_list_toolkits(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_list_toolkits(&config).await?)
})
}
pub(super) fn handle_list_capabilities(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_list_capabilities(&config).await?)
})
}
pub(super) fn handle_list_agent_ready_toolkits(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_list_agent_ready_toolkits(&config).await?)
})
}
pub(super) fn handle_list_connections(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_list_connections(&config).await?)
})
}
-pub(super) fn handle_authorize(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_authorize(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let toolkit = read_required_non_empty(&params, "toolkit")?;
let extra_params = params.get("extra_params").cloned();
to_json(ops::composio_authorize(&config, &toolkit, extra_params).await?)
@@ -62,31 +62,31 @@ pub(super) fn handle_authorize(_ctx: DispatchCtx, params: Map<String, Value>) ->
}
pub(super) fn handle_delete_connection(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let connection_id = read_required_non_empty(&params, "connection_id")?;
to_json(ops::composio_delete_connection(&config, &connection_id).await?)
})
}
-pub(super) fn handle_get_mode(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_get_mode(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
tracing::debug!("[composio-direct] rpc get_mode entry");
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_get_mode(&config).await?)
})
}
pub(super) fn handle_set_api_key(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
tracing::debug!("[composio-direct] rpc set_api_key entry");
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let api_key = read_required_non_empty(&params, "api_key")?;
let activate_direct = read_optional::<bool>(&params, "activate_direct")?.unwrap_or(false);
to_json(ops::composio_set_api_key(&config, &api_key, activate_direct).await?)
@@ -94,12 +94,12 @@ pub(super) fn handle_set_api_key(
}
pub(super) fn handle_clear_api_key(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
tracing::debug!("[composio-direct] rpc clear_api_key entry");
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_clear_api_key(&config).await?)
})
}
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs
index 1c9cbfcfa9..6e21e02ff3 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs
@@ -12,28 +12,28 @@ use crate::integrations::composio::{contract, ops};
use super::util::{read_required, read_required_non_empty, to_json};
pub(super) fn handle_get_user_profile(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let connection_id = read_required_non_empty(&params, "connection_id")?;
to_json(ops::composio_get_user_profile(&config, &connection_id).await?)
})
}
pub(super) fn handle_refresh_all_identities(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::composio_refresh_all_identities(&config).await?)
})
}
pub(super) fn handle_get_user_scopes(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
@@ -63,7 +63,7 @@ pub(super) fn handle_get_user_scopes(
// never had a failing path, and turning "settings file momentarily
// unreadable" into an RPC error would make the scopes panel fail where
// it used to render the defaults.
- let pref = match config_rpc::load_config_with_timeout().await {
+ let pref = match ctx.load_config().await {
Ok(config) => ops::load_user_scope_pref(&config, &toolkit).await,
Err(error) => {
tracing::warn!(
@@ -88,7 +88,7 @@ pub(super) fn handle_get_user_scopes(
}
pub(super) fn handle_set_user_scopes(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
@@ -120,7 +120,7 @@ pub(super) fn handle_set_user_scopes(
// client not initialised" rather than reporting a save it had not
// done, and `ops::user_scopes::save` refuses on the same three
// grounds (no driver, no `Graph` family, backend write failure).
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
if let Err(e) = ops::save_user_scope_pref(&config, &toolkit, pref).await {
tracing::error!(
method = "composio.set_user_scopes",
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs
index 5f2e2d3eb7..53bdad3f21 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs
@@ -9,18 +9,18 @@ use crate::integrations::composio::ops;
use super::util::{read_optional, read_required_non_empty, to_json};
-pub(super) fn handle_list_tools(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_list_tools(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let toolkits = read_optional::<Vec<String>>(&params, "toolkits")?;
let tags = read_optional::<Vec<String>>(&params, "tags")?;
to_json(ops::composio_list_tools(&config, toolkits, tags).await?)
})
}
-pub(super) fn handle_execute(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_execute(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let tool = read_required_non_empty(&params, "tool")?;
let arguments = read_optional::<Value>(&params, "arguments")?;
let connection_id = read_optional::<String>(&params, "connection_id")?;
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs
index 4eab5e2e87..223c392e88 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs
@@ -16,11 +16,11 @@ use super::params::{
use super::util::{read_required_non_empty, to_json};
pub(super) fn handle_list_github_repos(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().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?)
@@ -28,11 +28,11 @@ pub(super) fn handle_list_github_repos(
}
pub(super) fn handle_create_trigger(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload: CreateTriggerParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
let slug = payload.slug.trim();
@@ -52,11 +52,11 @@ pub(super) fn handle_create_trigger(
}
pub(super) fn handle_list_trigger_history(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().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?)
@@ -64,11 +64,11 @@ pub(super) fn handle_list_trigger_history(
}
pub(super) fn handle_list_available_triggers(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload: ListAvailableTriggersParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
let toolkit = payload.toolkit.trim();
@@ -82,11 +82,11 @@ pub(super) fn handle_list_available_triggers(
}
pub(super) fn handle_list_triggers(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().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?)
@@ -94,11 +94,11 @@ pub(super) fn handle_list_triggers(
}
pub(super) fn handle_enable_trigger(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().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();
@@ -117,11 +117,11 @@ pub(super) fn handle_enable_trigger(
}
pub(super) fn handle_disable_trigger(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let trigger_id = read_required_non_empty(&params, "trigger_id")?;
to_json(ops::composio_disable_trigger(&config, &trigger_id).await?)
})
diff --git a/crates/openhuman-core/src/integrations/task_sources/schemas.rs b/crates/openhuman-core/src/integrations/task_sources/schemas.rs
index a8f439707d..0ba638f635 100644
--- a/crates/openhuman-core/src/integrations/task_sources/schemas.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/schemas.rs
@@ -407,24 +407,24 @@ 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 {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::list(&config).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::get(&config, id.trim()).await?)
})
}
-fn handle_add(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_add(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let provider = read_provider(&params)?;
let filter = read_required::<FilterSpec>(&params, "filter")?;
let name = read_optional::<String>(&params, "name")?;
@@ -448,41 +448,41 @@ fn handle_add(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
})
}
-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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let patch = read_required::<TaskSourcePatch>(&params, "patch")?;
to_json(ops::update(&config, id.trim(), patch).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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::remove(&config, id.trim()).await?)
})
}
-fn handle_fetch(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_fetch(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
to_json(ops::fetch(&config, id.trim()).await?)
})
}
-fn handle_sync(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_sync(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::sync(&config).await?)
})
}
-fn handle_list_tasks(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_tasks(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let limit = match read_optional::<u64>(&params, "limit")? {
Some(n) => Some(
@@ -495,9 +495,9 @@ fn handle_list_tasks(_ctx: DispatchCtx, params: Map<String, Value>) -> Controlle
})
}
-fn handle_preview_filter(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_preview_filter(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let provider = read_provider(&params)?;
let filter = read_required::<FilterSpec>(&params, "filter")?;
let connection_id = read_optional::<String>(&params, "connection_id")?;
@@ -506,18 +506,18 @@ fn handle_preview_filter(_ctx: DispatchCtx, params: Map<String, Value>) -> Contr
})
}
-fn handle_list_databases(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_databases(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let provider = read_provider(&params)?;
let connection_id = read_optional::<String>(&params, "connection_id")?;
to_json(ops::list_databases(&config, provider, connection_id).await?)
})
}
-fn handle_status(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_status(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(ops::status(&config).await?)
})
}
diff --git a/crates/openhuman-core/src/mcp/audit/schemas.rs b/crates/openhuman-core/src/mcp/audit/schemas.rs
index fa74e982eb..54874e5bc3 100644
--- a/crates/openhuman-core/src/mcp/audit/schemas.rs
+++ b/crates/openhuman-core/src/mcp/audit/schemas.rs
@@ -81,11 +81,11 @@ fn schema() -> 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 {
log::debug!("[mcp_audit] handle_list enter params={params:?}");
log::trace!("[mcp_audit] handle_list loading config");
- let config = match config_rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => {
log::trace!(
"[mcp_audit] handle_list config loaded workspace={}",
diff --git a/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs b/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs
index 52c565b017..b3fe22640c 100644
--- a/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs
+++ b/crates/openhuman-core/src/mcp/registry/schemas/handlers.rs
@@ -14,11 +14,11 @@ use super::params::{
// ── Handler implementations ──────────────────────────────────────────────────
pub(super) fn handle_registry_search(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let query = read_optional_string(&params, "query")?;
let transport = read_optional_string(&params, "transport")?;
let page = read_optional_u32(&params, "page")?;
@@ -33,88 +33,88 @@ pub(super) fn handle_registry_search(
}
pub(super) fn handle_registry_get(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let qualified_name = read_required::<String>(&params, "qualified_name")?;
to_json(crate::mcp::registry::ops::mcp_clients_registry_get(&config, qualified_name).await?)
})
}
pub(super) fn handle_installed_list(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let _ = params;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::mcp::registry::ops::mcp_clients_installed_list(&config).await?)
})
}
-pub(super) fn handle_update_env(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_update_env(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
let env = read_required::<std::collections::HashMap<String, String>>(&params, "env")?;
to_json(crate::mcp::registry::ops::mcp_clients_update_env(&config, server_id, env).await?)
})
}
-pub(super) fn handle_uninstall(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_uninstall(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
to_json(crate::mcp::registry::ops::mcp_clients_uninstall(&config, server_id).await?)
})
}
pub(super) fn handle_detect_auth(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
to_json(crate::mcp::registry::ops::mcp_clients_detect_auth(&config, server_id).await?)
})
}
pub(super) fn handle_oauth_begin(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
to_json(crate::mcp::registry::ops::mcp_clients_oauth_begin(&config, server_id).await?)
})
}
-pub(super) fn handle_connect(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_connect(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
to_json(crate::mcp::registry::ops::mcp_clients_connect(&config, server_id).await?)
})
}
-pub(super) fn handle_disconnect(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_disconnect(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
to_json(crate::mcp::registry::ops::mcp_clients_disconnect(&config, server_id).await?)
})
}
pub(super) fn handle_set_enabled(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
let enabled = read_required::<bool>(&params, "enabled")?;
to_json(
@@ -123,17 +123,17 @@ pub(super) fn handle_set_enabled(
})
}
-pub(super) fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_status(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let _ = params;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::mcp::registry::ops::mcp_clients_status(&config).await?)
})
}
-pub(super) fn handle_list_tools(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_list_tools(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let server_id = read_required::<String>(&params, "server_id")?;
to_json(
crate::mcp::registry::ops::mcp_clients_list_tools(
@@ -146,7 +146,7 @@ pub(super) fn handle_list_tools(_ctx: DispatchCtx, params: Map<String, Value>) -
})
}
-pub(super) fn handle_tool_call(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_tool_call(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let server_id = read_required::<String>(&params, "server_id")?;
let tool_name = read_required::<String>(&params, "tool_name")?;
@@ -154,7 +154,7 @@ pub(super) fn handle_tool_call(_ctx: DispatchCtx, params: Map<String, Value>) ->
.get("arguments")
.cloned()
.unwrap_or(Value::Object(Map::new()));
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(
crate::mcp::registry::ops::mcp_clients_tool_call(
&config, server_id, tool_name, arguments,
@@ -164,17 +164,17 @@ pub(super) fn handle_tool_call(_ctx: DispatchCtx, params: Map<String, Value>) ->
})
}
-pub(super) fn handle_config_get(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_config_get(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let _ = params;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::mcp::registry::config_ops::mcp_clients_config_get(&config).await?)
})
}
-pub(super) fn handle_config_set(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_config_set(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// The whole document is the parameter set: `{ "mcpServers": { … } }`
// is what a user pastes, and wrapping it in another key would make the
// wire shape differ from the file shape for no reason.
@@ -184,25 +184,25 @@ pub(super) fn handle_config_set(_ctx: DispatchCtx, params: Map<String, Value>) -
}
pub(super) fn handle_registry_settings_get(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let _ = params;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::mcp::registry::ops::mcp_clients_registry_settings_get(&config).await?)
})
}
pub(super) fn handle_registry_settings_set(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let smithery_api_key = read_optional::<String>(&params, "smithery_api_key")?;
let mcp_official_base = read_optional::<String>(&params, "mcp_official_base")?;
let mcp_official_token = read_optional::<String>(&params, "mcp_official_token")?;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
to_json(
crate::mcp::registry::ops::mcp_clients_registry_settings_set(
&mut config,
diff --git a/crates/openhuman-core/src/mcp/ui/schemas.rs b/crates/openhuman-core/src/mcp/ui/schemas.rs
index e1c896a051..5957927520 100644
--- a/crates/openhuman-core/src/mcp/ui/schemas.rs
+++ b/crates/openhuman-core/src/mcp/ui/schemas.rs
@@ -90,25 +90,25 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_resource_read(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_resource_read(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let server_id = read_optional::<String>(&params, "server_id")?;
let uri = read_optional::<String>(&params, "uri")?;
let inline_id = read_optional::<String>(&params, "inline_id")?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let port = HostUiPort::new(Arc::new(config));
let outcome = ops::resource_read(&port, server_id, uri, inline_id).await?;
Ok(outcome.value)
})
}
-fn handle_tool_call(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_tool_call(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let server_id = read_optional::<String>(&params, "server_id")?;
let tool_name = read_optional::<String>(&params, "tool_name")?;
let arguments = params.get("arguments").cloned();
let confirmed = read_optional::<bool>(&params, "confirmed")?.unwrap_or(false);
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let security = crate::security::live_policy::current().unwrap_or_else(|| {
Arc::new(SecurityPolicy::from_config(
&config.autonomy,
diff --git a/crates/openhuman-core/src/modules/schemas.rs b/crates/openhuman-core/src/modules/schemas.rs
index aa3b92d4c7..37290973ef 100644
--- a/crates/openhuman-core/src/modules/schemas.rs
+++ b/crates/openhuman-core/src/modules/schemas.rs
@@ -201,11 +201,11 @@ fn readiness_error(detail: &str) -> String {
}
fn handle_browser_check_readiness(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
crate::core::runtime::components::require_config(&config, "computer")?;
// The probe never navigates. Give its disposable session a non-routable
// origin so an empty website allowlist does not prevent a Chrome check.
@@ -242,7 +242,7 @@ fn handle_browser_check_readiness(
})
}
-fn handle_browser_forget_sites(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_browser_forget_sites(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
// A blank or non-text site must not read as "every site".
let site = match params.get("site") {
@@ -255,7 +255,7 @@ fn handle_browser_forget_sites(_ctx: DispatchCtx, params: Map<String, Value>) ->
)
}
};
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
crate::core::runtime::components::require_config(&config, "computer")?;
let forgotten = super::site_memory_host::forget(&config, site.as_deref())
.await
@@ -269,10 +269,10 @@ fn handle_browser_forget_sites(_ctx: DispatchCtx, params: Map<String, Value>) ->
})
}
-fn handle_computer_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_computer_status(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let load = params.get("load").and_then(Value::as_bool).unwrap_or(false);
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
crate::core::runtime::components::require_config(&config, "computer")?;
controller_value(super::computer::status(&config, load).await)
})
@@ -282,17 +282,17 @@ fn controller_value(value: impl serde::Serialize) -> Result<Value, String> {
serde_json::to_value(value).map_err(|error| error.to_string())
}
-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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
Ok(serde_json::json!({ "modules": ops::list(&config) }))
})
}
-fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_status(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let id = string_param(&params, "id").ok_or("`id` is required")?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
match ops::list(&config).into_iter().find(|m| m.id == id) {
Some(module) => Ok(serde_json::json!({ "module": module })),
None => Err(format!("unknown module '{id}'")),
@@ -300,10 +300,10 @@ fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-fn handle_load(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_load(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let id = string_param(&params, "id").ok_or("`id` is required")?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// A failed load is reported through the returned status rather than as
// an RPC error: the caller asked "what happened", and the answer is a
// state plus a reason, not a transport failure.
diff --git a/crates/openhuman-core/src/platform/cost/schemas.rs b/crates/openhuman-core/src/platform/cost/schemas.rs
index 44e2ae5e88..3eb258c300 100644
--- a/crates/openhuman-core/src/platform/cost/schemas.rs
+++ b/crates/openhuman-core/src/platform/cost/schemas.rs
@@ -224,11 +224,11 @@ fn new_correlation_id() -> String {
uuid::Uuid::new_v4().simple().to_string()[..8].to_string()
}
-fn handle_cost_get_dashboard(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_cost_get_dashboard(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_dashboard.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_dashboard.config_load_failed err={err}");
})?;
let outcome = cost_rpc::dashboard(&config).map_err(|e| {
@@ -243,13 +243,13 @@ fn handle_cost_get_dashboard(_ctx: DispatchCtx, _params: Map<String, Value>) ->
}
fn handle_cost_get_daily_history(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_daily_history.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_daily_history.config_load_failed err={err}");
})?;
let payload = if params.is_empty() {
@@ -277,11 +277,11 @@ fn handle_cost_get_daily_history(
})
}
-fn handle_cost_get_summary(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_cost_get_summary(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_summary.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_summary.config_load_failed err={err}");
})?;
let outcome = cost_rpc::summary(&config).map_err(|e| {
@@ -295,11 +295,11 @@ fn handle_cost_get_summary(_ctx: DispatchCtx, _params: Map<String, Value>) -> Co
})
}
-fn handle_cost_get_usage_log(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_cost_get_usage_log(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_usage_log.entry");
- let config = config_rpc::load_config_with_timeout().await.inspect_err(|err| {
+ let config = ctx.load_config().await.inspect_err(|err| {
log::warn!(target: "cost_rpc", "[cost_rpc][{cid}] cost_get_usage_log.config_load_failed err={err}");
})?;
let payload = if params.is_empty() {
@@ -340,11 +340,11 @@ fn parse_report_params<T: serde::de::DeserializeOwned + Default>(
serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))
}
-fn handle_cost_report(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_cost_report(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "cost_rpc", "[cost_rpc][{cid}] cost_report.entry");
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p: ReportParams = parse_report_params(params)?;
let days = p.days.unwrap_or_else(default_usage_days);
let outcome = cost_rpc::usage_report(&config, days, &p.group_by, &p.filter)
@@ -353,11 +353,11 @@ fn handle_cost_report(_ctx: DispatchCtx, params: Map<String, Value>) -> Controll
})
}
-fn handle_cost_cache_report(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_cost_cache_report(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let cid = new_correlation_id();
log::debug!(target: "cost_rpc", "[cost_rpc][{cid}] cost_cache_report.entry");
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p: CacheReportParams = parse_report_params(params)?;
let days = p.days.unwrap_or_else(default_usage_days);
let limit = p.limit.unwrap_or(200);
diff --git a/crates/openhuman-core/src/platform/doctor/schemas.rs b/crates/openhuman-core/src/platform/doctor/schemas.rs
index 4ae4731251..28a3f5c2bf 100644
--- a/crates/openhuman-core/src/platform/doctor/schemas.rs
+++ b/crates/openhuman-core/src/platform/doctor/schemas.rs
@@ -70,16 +70,16 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_report(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_report(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::doctor::rpc::doctor_report(&config).await?)
})
}
-fn handle_models(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_models(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let use_cache = read_optional::<bool>(&params, "use_cache")?.unwrap_or(true);
to_json(crate::platform::doctor::rpc::doctor_models(&config, use_cache).await?)
})
diff --git a/crates/openhuman-core/src/platform/service/schemas.rs b/crates/openhuman-core/src/platform/service/schemas.rs
index b3aa35bf01..05f229f6ce 100644
--- a/crates/openhuman-core/src/platform/service/schemas.rs
+++ b/crates/openhuman-core/src/platform/service/schemas.rs
@@ -175,17 +175,17 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_install(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_install(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::service_install(&config).await?)
})
}
/// Service controller for `service.start`.
-fn handle_start(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_start(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::service_start(&config).await?)
})
}
@@ -227,25 +227,25 @@ fn handle_shutdown(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerF
}
/// Service controller for `service.stop`.
-fn handle_stop(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_stop(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::service_stop(&config).await?)
})
}
/// Service controller for `service.status`.
-fn handle_status(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_status(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::service_status(&config).await?)
})
}
/// Service controller for `service.uninstall`.
-fn handle_uninstall(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_uninstall(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::service_uninstall(&config).await?)
})
}
@@ -256,19 +256,19 @@ struct DaemonHostSetParams {
}
/// Service controller for `service.daemon_host_get`.
-fn handle_daemon_host_get(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_daemon_host_get(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::daemon_host_get(&config).await?)
})
}
/// Service controller for `service.daemon_host_set`.
-fn handle_daemon_host_set(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_daemon_host_set(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let payload: DaemonHostSetParams =
serde_json::from_value(Value::Object(params)).map_err(|e| e.to_string())?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::platform::service::rpc::daemon_host_set(&config, payload.show_tray).await?)
})
}
diff --git a/crates/openhuman-core/src/sandbox/schemas.rs b/crates/openhuman-core/src/sandbox/schemas.rs
index 9bc50c3f4b..3366c01082 100644
--- a/crates/openhuman-core/src/sandbox/schemas.rs
+++ b/crates/openhuman-core/src/sandbox/schemas.rs
@@ -168,7 +168,7 @@ pub fn schemas(function: &str) -> ControllerSchema {
/// requested name — so `backend:"docker"` on a native-config host reports Local,
/// matching what a real session on that host would run. Reporting the requested
/// backend instead was the conflation fixed in #6081.
-fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_status(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
let backend_str = params
@@ -195,7 +195,7 @@ fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
// and the mounted workspace, not the compiled-in `RuntimeConfig::default()`
// (#6081). A failed config load surfaces to the caller rather than
// silently answering from defaults.
- let config = match config_rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(err) => {
log::warn!("[sandbox] handle_status config load failed error={err}");
@@ -225,7 +225,7 @@ fn handle_status(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFut
})
}
-fn handle_resolve_policy(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_resolve_policy(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
let mode_str = params
@@ -248,7 +248,7 @@ fn handle_resolve_policy(_ctx: DispatchCtx, params: Map<String, Value>) -> Contr
// and the user's action dir, not the compiled-in `RuntimeConfig::default()`
// and `default_action_dir()` (#6081). A failed config load surfaces to
// the caller rather than silently answering from defaults.
- let config = match config_rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(err) => {
log::warn!("[sandbox] handle_resolve_policy config load failed error={err}");
@@ -284,10 +284,10 @@ fn handle_resolve_policy(_ctx: DispatchCtx, params: Map<String, Value>) -> Contr
})
}
-fn handle_cleanup_orphans(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_cleanup_orphans(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async {
gate()?;
- let config = match crate::config::ops::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => return Err(error),
};
@@ -301,7 +301,7 @@ fn handle_cleanup_orphans(_ctx: DispatchCtx, _params: Map<String, Value>) -> Con
})
}
-fn handle_validate_policy(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_validate_policy(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
gate()?;
let policy_val = params.get("policy").cloned().unwrap_or(Value::Null);
@@ -309,7 +309,7 @@ fn handle_validate_policy(_ctx: DispatchCtx, params: Map<String, Value>) -> Cont
Ok(p) => p,
Err(e) => return Err(format!("Invalid policy: {e}")),
};
- let config = crate::config::ops::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// The module owns the verdict; a missing one is an error, never "valid".
let issues = super::docker::validate_docker_policy(&config, &policy)
.await
diff --git a/crates/openhuman-core/src/security/credentials/schemas.rs b/crates/openhuman-core/src/security/credentials/schemas.rs
index e65134d714..2f1d1319c5 100644
--- a/crates/openhuman-core/src/security/credentials/schemas.rs
+++ b/crates/openhuman-core/src/security/credentials/schemas.rs
@@ -193,18 +193,18 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_auth_set_credential(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_auth_set_credential(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload =
deserialize_params::<crate::security::credentials::SetCredentialRequest>(params)?;
to_json(crate::security::credentials::rpc::set_credential(&config, payload).await?)
})
}
-fn handle_auth_clear_credential(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_auth_clear_credential(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload = deserialize_params::<AuthClearCredentialParams>(params)?;
let kind = match payload
.kind
@@ -222,29 +222,29 @@ fn handle_auth_clear_credential(_ctx: DispatchCtx, params: Map<String, Value>) -
})
}
-fn handle_auth_get_state(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_auth_get_state(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::security::credentials::rpc::auth_get_state(&config).await?)
})
}
fn handle_auth_get_session_token(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::security::credentials::rpc::auth_get_session_token_json(&config).await?)
})
}
fn handle_auth_store_provider_credentials(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload = deserialize_params::<AuthStoreProviderCredentialsParams>(params)?;
to_json(
crate::security::credentials::rpc::store_provider_credentials(
@@ -261,11 +261,11 @@ fn handle_auth_store_provider_credentials(
}
fn handle_auth_remove_provider_credentials(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload = deserialize_params::<AuthRemoveProviderCredentialsParams>(params)?;
to_json(
crate::security::credentials::rpc::remove_provider_credentials(
@@ -279,11 +279,11 @@ fn handle_auth_remove_provider_credentials(
}
fn handle_auth_list_provider_credentials(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let payload = if params.is_empty() {
AuthListProviderCredentialsParams::default()
} else {
diff --git a/crates/openhuman-core/src/security/devices/schemas.rs b/crates/openhuman-core/src/security/devices/schemas.rs
index 02b922b2c7..d293bdb281 100644
--- a/crates/openhuman-core/src/security/devices/schemas.rs
+++ b/crates/openhuman-core/src/security/devices/schemas.rs
@@ -150,24 +150,24 @@ pub fn schemas(function: &str) -> ControllerSchema {
// Handler bridges
// ---------------------------------------------------------------------------
-fn handle_create_pairing(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_create_pairing(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let label = read_optional_string(&params, "label")?;
to_json(crate::security::devices::rpc::devices_create_pairing(&config, label).await?)
})
}
-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 config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::security::devices::rpc::devices_list(&config).await?)
})
}
-fn handle_revoke(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_revoke(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let channel_id = read_required::<String>(&params, "channel_id")?;
to_json(crate::security::devices::rpc::devices_revoke(&config, channel_id).await?)
})
diff --git a/crates/openhuman-core/src/security/encryption/schemas.rs b/crates/openhuman-core/src/security/encryption/schemas.rs
index 29f528a5af..25c0cfeeb7 100644
--- a/crates/openhuman-core/src/security/encryption/schemas.rs
+++ b/crates/openhuman-core/src/security/encryption/schemas.rs
@@ -75,17 +75,17 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_encrypt_secret(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_encrypt_secret(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let plaintext = read_required::<String>(&params, "plaintext")?;
to_json(crate::security::encryption::rpc::encrypt_secret(&config, &plaintext).await?)
})
}
-fn handle_decrypt_secret(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_decrypt_secret(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let ciphertext = read_required::<String>(&params, "ciphertext")?;
to_json(crate::security::encryption::rpc::decrypt_secret(&config, &ciphertext).await?)
})
diff --git a/crates/openhuman-core/src/tools/schemas/composio.rs b/crates/openhuman-core/src/tools/schemas/composio.rs
index 847625ddae..36a5ead977 100644
--- a/crates/openhuman-core/src/tools/schemas/composio.rs
+++ b/crates/openhuman-core/src/tools/schemas/composio.rs
@@ -8,7 +8,7 @@ use crate::core::all::ControllerFuture;
use crate::core::Outcome;
pub(super) fn handle_composio_execute(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
@@ -19,7 +19,7 @@ pub(super) fn handle_composio_execute(
.ok_or_else(|| "missing required `action`".to_string())?;
let action_args = params.get("params").cloned();
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// The connector module owns the mode split (backend proxy vs. the
// user's personal direct tenant, #1710); this only supplies the config.
let resp = crate::integrations::composio::execute_dispatch::execute_composio_action(
diff --git a/crates/openhuman-core/src/voice/live/schemas.rs b/crates/openhuman-core/src/voice/live/schemas.rs
index 5492e66a83..97462cea10 100644
--- a/crates/openhuman-core/src/voice/live/schemas.rs
+++ b/crates/openhuman-core/src/voice/live/schemas.rs
@@ -118,34 +118,34 @@ struct TestParams {
provider: String,
}
-fn handle_live_providers(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_live_providers(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_value(ops::live_providers(&config).value)
})
}
-fn handle_live_settings_get(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_live_settings_get(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_value(ops::live_settings_get(&config).value)
})
}
-fn handle_live_settings_set(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_live_settings_set(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let patch: LiveSettingsPatch = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
to_value(ops::live_settings_set(&mut config, patch).await?.value)
})
}
-fn handle_live_test_provider(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_live_test_provider(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let params: TestParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_value(
ops::live_test_provider(&config, &params.provider)
.await
diff --git a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
index a37d8dc7fe..be74625dac 100644
--- a/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
+++ b/crates/openhuman-core/src/voice/schemas/handlers/provider_server.rs
@@ -20,12 +20,12 @@ use crate::voice::schemas::params::{
// ---------------------------------------------------------------------------
pub(crate) fn handle_voice_set_providers(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<SetProvidersParams>(params)?;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
if let Some(stt) = p
.stt_provider
@@ -83,7 +83,7 @@ pub(crate) fn handle_voice_set_providers(
}
pub(crate) fn handle_voice_update_provider_settings(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
@@ -94,7 +94,7 @@ pub(crate) fn handle_voice_update_provider_settings(
use tinyinference_voice::external_tts::TtsApiStyle;
let p = deserialize_params::<VoiceUpdateProviderSettingsParams>(params)?;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
if let Some(providers) = p.voice_providers {
let mut new_entries = Vec::with_capacity(providers.len());
@@ -238,12 +238,12 @@ pub(crate) fn handle_voice_update_provider_settings(
}
pub(crate) fn handle_voice_list_models(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<VoiceListModelsParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let provider_id = p.provider_id.trim();
let capability = p.capability.as_deref().unwrap_or("both");
@@ -306,12 +306,12 @@ pub(crate) fn handle_voice_list_models(
}
pub(crate) fn handle_voice_test_provider(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
let p = deserialize_params::<VoiceTestProviderParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let start = std::time::Instant::now();
log::debug!(
@@ -425,14 +425,14 @@ pub(crate) fn handle_voice_test_provider(
// ---------------------------------------------------------------------------
pub(crate) fn handle_voice_server_start(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
use crate::voice::server::{global_server, VoiceServerConfig};
use tinyvoice_bus::hotkey::ActivationMode;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let hotkey = params
.get("hotkey")
diff --git a/crates/openhuman-core/src/voice/schemas/handlers/transcribe_tts.rs b/crates/openhuman-core/src/voice/schemas/handlers/transcribe_tts.rs
index c5b0514ae2..c1ca672363 100644
--- a/crates/openhuman-core/src/voice/schemas/handlers/transcribe_tts.rs
+++ b/crates/openhuman-core/src/voice/schemas/handlers/transcribe_tts.rs
@@ -15,11 +15,11 @@ use crate::voice::schemas::params::{
};
pub(crate) fn handle_voice_status(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::voice::voice_status(&config).await?)
})
}
@@ -27,21 +27,21 @@ pub(crate) fn handle_voice_status(
/// Mint a realtime voice-agent signed WebSocket URL (#5399). Takes no params —
/// the agent is server-configured; the desktop only asks for a fresh signed URL.
pub(crate) fn handle_voice_agent_signed_url(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
to_json(crate::voice::realtime::mint_voice_agent_signed_url(&config).await?)
})
}
pub(crate) fn handle_voice_transcribe(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<TranscribeParams>(params)?;
to_json(
crate::voice::voice_transcribe(
@@ -56,11 +56,11 @@ pub(crate) fn handle_voice_transcribe(
}
pub(crate) fn handle_voice_transcribe_bytes(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<TranscribeBytesParams>(params)?;
to_json(
crate::voice::voice_transcribe_bytes(
@@ -75,20 +75,20 @@ pub(crate) fn handle_voice_transcribe_bytes(
})
}
-pub(crate) fn handle_voice_tts(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(crate) fn handle_voice_tts(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<TtsParams>(params)?;
to_json(crate::voice::voice_tts(&config, &p.text, p.output_path.as_deref()).await?)
})
}
pub(crate) fn handle_voice_reply_synthesize(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<ReplySynthesizeParams>(params)?;
// Dispatch through the TTS factory so the user's `tts_provider`
// setting (cloud / piper / …) is honored on the spoken-reply path,
@@ -132,11 +132,11 @@ pub(crate) fn handle_voice_reply_synthesize(
}
pub(crate) fn handle_voice_cloud_transcribe(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<CloudTranscribeParams>(params)?;
let opts = tinyinference_voice::cloud::CloudTranscribeOptions {
model: p.model,
@@ -152,11 +152,11 @@ pub(crate) fn handle_voice_cloud_transcribe(
}
pub(crate) fn handle_voice_stt_dispatch(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<SttDispatchParams>(params)?;
let provider_name = p
.provider
@@ -196,11 +196,11 @@ pub(crate) fn handle_voice_stt_dispatch(
}
pub(crate) fn handle_voice_tts_dispatch(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let p = deserialize_params::<TtsDispatchParams>(params)?;
let provider_name = p
.provider
diff --git a/crates/openhuman-core/src/web3/bridge/schemas.rs b/crates/openhuman-core/src/web3/bridge/schemas.rs
index c76de358d9..6a14566d19 100644
--- a/crates/openhuman-core/src/web3/bridge/schemas.rs
+++ b/crates/openhuman-core/src/web3/bridge/schemas.rs
@@ -92,9 +92,9 @@ pub fn schema(function: &str) -> ControllerSchema {
}
}
-fn handle_quote(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_quote(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let quote = web3_service::quote(
&config,
None,
@@ -107,11 +107,11 @@ fn handle_quote(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu
})
}
-fn handle_execute(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_execute(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let parsed: web3_service::ExecuteParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = web3_service::execute(&config, None, parsed.quote_id, parsed.confirmed)
.await
.map_err(|error| error.to_string())?;
diff --git a/crates/openhuman-core/src/web3/dapp/schemas.rs b/crates/openhuman-core/src/web3/dapp/schemas.rs
index d8d9defa80..918fb2cc48 100644
--- a/crates/openhuman-core/src/web3/dapp/schemas.rs
+++ b/crates/openhuman-core/src/web3/dapp/schemas.rs
@@ -75,9 +75,9 @@ pub fn schema(function: &str) -> ControllerSchema {
}
}
-fn handle_call(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_call(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let quote = web3_service::quote(
&config,
None,
@@ -90,11 +90,11 @@ fn handle_call(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
})
}
-fn handle_execute(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_execute(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let parsed: web3_service::ExecuteParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = web3_service::execute(&config, None, parsed.quote_id, parsed.confirmed)
.await
.map_err(|error| error.to_string())?;
diff --git a/crates/openhuman-core/src/web3/swap/schemas.rs b/crates/openhuman-core/src/web3/swap/schemas.rs
index 300d921d1d..f594b9a096 100644
--- a/crates/openhuman-core/src/web3/swap/schemas.rs
+++ b/crates/openhuman-core/src/web3/swap/schemas.rs
@@ -103,9 +103,9 @@ fn unknown_schema() -> ControllerSchema {
}
}
-fn handle_quote(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_quote(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let quote = web3_service::quote(
&config,
None,
@@ -118,11 +118,11 @@ fn handle_quote(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu
})
}
-fn handle_execute(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_execute(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let parsed: web3_service::ExecuteParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = web3_service::execute(&config, None, parsed.quote_id, parsed.confirmed)
.await
.map_err(|error| error.to_string())?;
@@ -131,9 +131,9 @@ fn handle_execute(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFu
})
}
-fn handle_routes(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_routes(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let routes = web3_service::routes(&config)
.await
.map_err(|error| error.to_string())?;
diff --git a/crates/openhuman-core/src/web3/x402/schemas.rs b/crates/openhuman-core/src/web3/x402/schemas.rs
index 724a031546..078dcc06c4 100644
--- a/crates/openhuman-core/src/web3/x402/schemas.rs
+++ b/crates/openhuman-core/src/web3/x402/schemas.rs
@@ -109,9 +109,9 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-fn handle_get_summary(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+fn handle_get_summary(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("x402 get_summary: {error}"))?;
let summary = crate::modules::x402_service::summary(&config)
@@ -128,12 +128,12 @@ struct ListPaymentsParams {
limit: Option<u64>,
}
-fn handle_list_payments(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_list_payments(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p: ListPaymentsParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("x402 list_payments params: {e}"))?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("x402 list_payments: {error}"))?;
let limit = p.limit.unwrap_or(50).min(500);
@@ -159,12 +159,12 @@ struct UpdateBudgetParams {
monthly_max: Option<u64>,
}
-fn handle_update_budget(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_update_budget(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let p: UpdateBudgetParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("x402 update_budget params: {e}"))?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("x402 update_budget: {error}"))?;
let summary = crate::modules::x402_service::update_budget(