Skip to content

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

refactor(config): route config loads through ctx.load_config

Steven Enamakel7d983b48144c
diff --git a/crates/openhuman-core/src/config/README.md b/crates/openhuman-core/src/config/README.md
index e7dd1b4a60..f735637ff3 100644
--- a/crates/openhuman-core/src/config/README.md
+++ b/crates/openhuman-core/src/config/README.md
@@ -6,7 +6,7 @@ and CLI launch flags on top of it, runs startup data migrations, and writes it b
exposes the `config.*` RPC namespace the settings UI uses to read and change those settings.
Nearly every other domain reads its slice of settings from here (`config.agent`, `config.memory`,
-`config.channels`, `config.autonomy`, and so on), usually through `config::load_config_with_timeout()`.
+`config.channels`, `config.autonomy`, and so on), usually through `ctx.load_config()`.
## How it works
@@ -97,7 +97,7 @@ paths are already known and ignores `OPENHUMAN_WORKSPACE`, for long-lived object
`Config::load_from_default_paths` ignores `OPENHUMAN_WORKSPACE` too and is read-only; the debug prompt
dump uses it.
-Most code does not call these directly. `ops::load_config_with_timeout()` wraps `load_or_init` in a
+Most code does not call these directly. `ctx.load_config()` wraps `load_or_init` in a
30-second timeout, returns the embedding host's `Config` instead when one is installed on the current
`CoreContext`, and seeds per-token prices into the model registry in memory. Code handed a specific
workspace should call `load_config_for_workspace_with_timeout(workspace_dir)` so it does not pick up the
diff --git a/crates/openhuman-core/src/config/ops/agent.rs b/crates/openhuman-core/src/config/ops/agent.rs
index 165d30ee39..1c735aef61 100644
--- a/crates/openhuman-core/src/config/ops/agent.rs
+++ b/crates/openhuman-core/src/config/ops/agent.rs
@@ -151,13 +151,13 @@ pub async fn apply_autonomy_settings(
pub async fn load_and_apply_autonomy_settings(
update: AutonomySettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_autonomy_settings(&mut config, update).await
}
/// Returns the current `[autonomy]` settings block as JSON (no secrets).
pub async fn get_autonomy_settings() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let value = serde_json::to_value(&config.autonomy).map_err(|e| e.to_string())?;
Ok(Outcome::single_log(value, "autonomy settings read"))
}
@@ -172,7 +172,7 @@ fn auto_approve_write_lock() -> &'static tokio::sync::Mutex<()> {
/// already allow-listed. Backs the `ApproveAlwaysForTool` approval decision.
pub async fn add_auto_approve_tool(tool_name: &str) -> Result<(), String> {
let _guard = auto_approve_write_lock().lock().await;
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
if config.autonomy.auto_approve.iter().any(|t| t == tool_name) {
tracing::debug!(
tool = tool_name,
@@ -267,7 +267,7 @@ pub async fn apply_agent_settings(
pub async fn load_and_apply_agent_settings(
update: AgentSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_agent_settings(&mut config, update).await
}
@@ -275,7 +275,7 @@ pub async fn load_and_apply_agent_settings(
/// runtime-effective value and whether the `OPENHUMAN_TOOL_TIMEOUT_SECS` env var
/// is overriding the configured value, so the UI can explain a no-op control.
pub async fn get_agent_settings() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
crate::tools::timeout::set_tool_timeout_secs(config.agent.agent_timeout_secs);
let value = serde_json::json!({
"agent_timeout_secs": config.agent.agent_timeout_secs,
@@ -653,7 +653,7 @@ pub async fn apply_agent_paths_settings(
pub async fn load_and_apply_agent_paths_settings(
update: AgentPathsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_agent_paths_settings(&mut config, update).await
}
@@ -667,7 +667,7 @@ fn paths_equal(a: &Path, b: &Path) -> bool {
/// Reports the agent's filesystem roots so the UI can render them live
/// instead of hard-coding strings that drift away from `Config`.
pub async fn get_agent_paths() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
Ok(Outcome::new(
agent_paths_payload(&config),
vec![format!(
diff --git a/crates/openhuman-core/src/config/ops/computer.rs b/crates/openhuman-core/src/config/ops/computer.rs
index 6ae095a87f..542e4c2104 100644
--- a/crates/openhuman-core/src/config/ops/computer.rs
+++ b/crates/openhuman-core/src/config/ops/computer.rs
@@ -96,7 +96,7 @@ pub async fn apply_computer_settings(
pub async fn load_and_apply_computer_settings(
update: ComputerSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_computer_settings(&mut config, update).await
}
diff --git a/crates/openhuman-core/src/config/ops/loader/load.rs b/crates/openhuman-core/src/config/ops/loader/load.rs
index 73b6779ce9..3146b28aa9 100644
--- a/crates/openhuman-core/src/config/ops/loader/load.rs
+++ b/crates/openhuman-core/src/config/ops/loader/load.rs
@@ -86,7 +86,7 @@ pub async fn load_config_in(ctx: &crate::core::runtime::DispatchCtx) -> Result<C
/// runs inside a turn: [`load_config_with_timeout`] with the context's
/// inference route applied.
pub async fn load_current_or_init() -> anyhow::Result<Config> {
- let mut config = load_config_with_timeout()
+ let mut config = ctx.load_config()
.await
.map_err(anyhow::Error::msg)?;
if let Some(route) = config.ephemeral_route.clone() {
@@ -157,7 +157,7 @@ pub async fn load_config_for_workspace_with_timeout(
workspace = %workspace_dir.display(),
"[config] no config.toml beside workspace; falling back to the process-global load"
);
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
config.workspace_dir = workspace_dir.to_path_buf();
Ok(config)
}
diff --git a/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs b/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs
index e33c32f10a..1e4663629d 100644
--- a/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs
+++ b/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs
@@ -148,7 +148,7 @@ pub(crate) async fn reset_local_data_for_paths(
/// tolerate unlinking open files; on Windows the CLI invocation runs
/// without the core attached, so no handle is in the way).
pub async fn reset_local_data() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let current_openhuman_dir = config_openhuman_dir(&config);
let default_openhuman_dir = default_openhuman_dir();
reset_local_data_for_paths(&current_openhuman_dir, &default_openhuman_dir).await
@@ -165,7 +165,7 @@ pub async fn reset_local_data() -> Result<Outcome<serde_json::Value>, String> {
/// handles. See OPENHUMAN-TAURI-AF for the Windows file-locking failure
/// that motivated the split.
pub async fn get_data_paths() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let current_openhuman_dir = config_openhuman_dir(&config);
let default_openhuman_dir = default_openhuman_dir();
let active_workspace_marker = active_workspace_marker_path(&default_openhuman_dir);
diff --git a/crates/openhuman-core/src/config/ops/loader/snapshot.rs b/crates/openhuman-core/src/config/ops/loader/snapshot.rs
index 521c081958..9bd2feaa64 100644
--- a/crates/openhuman-core/src/config/ops/loader/snapshot.rs
+++ b/crates/openhuman-core/src/config/ops/loader/snapshot.rs
@@ -136,7 +136,7 @@ pub fn client_config_json(config: &Config) -> serde_json::Value {
/// Loads config and returns the client-facing AI config slice.
pub async fn load_and_get_client_config_snapshot() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let snapshot = client_config_json(&config);
Ok(Outcome::new(
snapshot,
@@ -158,7 +158,7 @@ pub async fn get_config_snapshot(config: &Config) -> Result<Outcome<serde_json::
/// Loads the configuration from disk and returns a snapshot.
pub async fn load_and_get_config_snapshot() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
get_config_snapshot(&config).await
}
@@ -178,7 +178,7 @@ pub async fn get_dashboard_settings() -> Result<Outcome<serde_json::Value>, Stri
"OPENHUMAN: get_dashboard_settings loading config"
);
- let config = load_config_with_timeout().await.map_err(|error| {
+ let config = ctx.load_config().await.map_err(|error| {
tracing::warn!(
target: "openhuman_core::config",
request_id = %request_id,
diff --git a/crates/openhuman-core/src/config/ops/model.rs b/crates/openhuman-core/src/config/ops/model.rs
index a0bf801f8d..9fead2a0f5 100644
--- a/crates/openhuman-core/src/config/ops/model.rs
+++ b/crates/openhuman-core/src/config/ops/model.rs
@@ -442,7 +442,7 @@ pub async fn apply_model_settings(
pub async fn load_and_apply_model_settings(
update: ModelSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_model_settings(&mut config, update).await
}
@@ -487,7 +487,7 @@ pub async fn apply_memory_settings(
pub async fn load_and_apply_memory_settings(
update: MemorySettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_memory_settings(&mut config, update).await
}
@@ -545,7 +545,7 @@ pub async fn apply_runtime_settings(
pub async fn load_and_apply_runtime_settings(
update: RuntimeSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_runtime_settings(&mut config, update).await
}
@@ -622,7 +622,7 @@ pub async fn apply_local_ai_settings(
pub async fn load_and_apply_local_ai_settings(
update: LocalAiSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_local_ai_settings(&mut config, update).await
}
@@ -660,13 +660,13 @@ pub async fn apply_composio_trigger_settings(
pub async fn load_and_apply_composio_trigger_settings(
update: ComposioTriggerSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_composio_trigger_settings(&mut config, update).await
}
/// Reads the current composio trigger-triage settings.
pub async fn get_composio_trigger_settings() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = serde_json::json!({
"triage_disabled": config.composio.triage_disabled,
"triage_disabled_toolkits": config.composio.triage_disabled_toolkits,
@@ -688,7 +688,7 @@ pub(crate) fn resolve_backend_api_url(config: &Config) -> Option<String> {
/// Resolves the effective backend API URL from configuration or defaults;
/// `api_url` is `null` when the core has no hosted backend.
pub async fn load_and_resolve_api_url() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let resolved = resolve_backend_api_url(&config);
Ok(Outcome::new(
serde_json::json!({ "api_url": resolved }),
diff --git a/crates/openhuman-core/src/config/ops/privacy.rs b/crates/openhuman-core/src/config/ops/privacy.rs
index b45d001abc..13b403ff36 100644
--- a/crates/openhuman-core/src/config/ops/privacy.rs
+++ b/crates/openhuman-core/src/config/ops/privacy.rs
@@ -42,7 +42,7 @@ fn privacy_mode_value(mode: PrivacyMode) -> serde_json::Value {
/// Returns the current `[privacy]` mode as `{ "mode": "<snake_case>" }`.
pub async fn get_privacy_mode() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
log::debug!(
"[privacy][rpc] get_privacy_mode -> {:?}",
config.privacy.mode
@@ -98,7 +98,7 @@ pub async fn apply_privacy_settings(
pub async fn load_and_apply_privacy_settings(
update: PrivacySettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_privacy_settings(&mut config, update).await
}
diff --git a/crates/openhuman-core/src/config/ops/sandbox.rs b/crates/openhuman-core/src/config/ops/sandbox.rs
index e5e7e4f845..e84602e058 100644
--- a/crates/openhuman-core/src/config/ops/sandbox.rs
+++ b/crates/openhuman-core/src/config/ops/sandbox.rs
@@ -17,7 +17,7 @@ pub struct SandboxSettingsPatch {
}
pub async fn get_sandbox_settings() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let sandbox = &config.sandbox;
let docker = &config.runtime.docker;
@@ -123,7 +123,7 @@ pub async fn apply_sandbox_settings(
pub async fn load_and_apply_sandbox_settings(
update: SandboxSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_sandbox_settings(&mut config, update).await
}
diff --git a/crates/openhuman-core/src/config/ops/search.rs b/crates/openhuman-core/src/config/ops/search.rs
index 63a6d87d86..02b643ca97 100644
--- a/crates/openhuman-core/src/config/ops/search.rs
+++ b/crates/openhuman-core/src/config/ops/search.rs
@@ -312,7 +312,7 @@ pub async fn apply_search_settings(
pub async fn load_and_apply_search_settings(
update: SearchSettingsPatch,
) -> Result<Outcome<Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_search_settings(&mut config, update).await
}
@@ -391,7 +391,7 @@ pub(crate) fn search_settings_json_with(config: &Config, managed_available: bool
/// Read the current search settings. Keys are reported only as booleans.
pub async fn get_search_settings() -> Result<Outcome<Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
Ok(Outcome::new(
search_settings_json(&config),
vec!["search settings read".to_string()],
diff --git a/crates/openhuman-core/src/config/ops/ui.rs b/crates/openhuman-core/src/config/ops/ui.rs
index 6ef6de8b00..1d4addb034 100644
--- a/crates/openhuman-core/src/config/ops/ui.rs
+++ b/crates/openhuman-core/src/config/ops/ui.rs
@@ -165,7 +165,7 @@ fn normalize_browser_backend(raw: &str) -> Result<String, String> {
pub async fn load_and_apply_browser_settings(
update: BrowserSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_browser_settings(&mut config, update).await
}
@@ -232,7 +232,7 @@ pub async fn apply_user_timezone(
pub async fn load_and_apply_user_timezone(
timezone: Option<String>,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_user_timezone(&mut config, timezone).await
}
@@ -249,7 +249,7 @@ pub fn user_timezone_json(config: &Config) -> serde_json::Value {
pub async fn load_and_apply_analytics_settings(
update: AnalyticsSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
apply_analytics_settings(&mut config, update).await
}
@@ -267,7 +267,7 @@ pub async fn workspace_onboarding_flag_resolve(
{
return Err("Invalid onboarding flag name".to_string());
}
- let workspace_dir = match load_config_with_timeout().await {
+ let workspace_dir = match ctx.load_config().await {
Ok(cfg) => cfg.workspace_dir,
Err(_) => fallback_workspace_dir(),
};
@@ -308,7 +308,7 @@ pub async fn workspace_onboarding_flag_set(
{
return Err("Invalid onboarding flag name".to_string());
}
- let workspace_dir = match load_config_with_timeout().await {
+ let workspace_dir = match ctx.load_config().await {
Ok(cfg) => cfg.workspace_dir,
Err(_) => fallback_workspace_dir(),
};
@@ -332,7 +332,7 @@ pub async fn workspace_onboarding_flag_set(
/// Returns whether the onboarding process has been marked as completed.
pub async fn get_onboarding_completed() -> Result<Outcome<bool>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
Ok(Outcome::single_log(
config.onboarding_completed,
"onboarding_completed read from config",
@@ -345,7 +345,7 @@ pub async fn get_onboarding_completed() -> Result<Outcome<bool>, String> {
/// cron job via [`crate::cron::seed::seed_proactive_agents`].
pub async fn set_onboarding_completed(value: bool) -> Result<Outcome<bool>, String> {
tracing::debug!(value, "[onboarding] set_onboarding_completed called");
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
let was_completed = config.onboarding_completed;
config.onboarding_completed = value;
@@ -377,7 +377,7 @@ pub async fn set_onboarding_completed(value: bool) -> Result<Outcome<bool>, Stri
/// Returns the current dictation settings as a JSON object.
pub async fn get_dictation_settings() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = json!({
"enabled": config.dictation.enabled,
"hotkey": config.dictation.hotkey,
@@ -396,7 +396,7 @@ pub async fn get_dictation_settings() -> Result<Outcome<serde_json::Value>, Stri
pub async fn load_and_apply_dictation_settings(
update: DictationSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
if let Some(enabled) = update.enabled {
config.dictation.enabled = enabled;
}
@@ -440,7 +440,7 @@ pub async fn load_and_apply_dictation_settings(
/// Returns the current voice server settings as a JSON object.
pub async fn get_voice_server_settings() -> Result<Outcome<serde_json::Value>, String> {
- let config = load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = json!({
"auto_start": config.voice_server.auto_start,
"hotkey": config.voice_server.hotkey,
@@ -463,7 +463,7 @@ pub async fn get_voice_server_settings() -> Result<Outcome<serde_json::Value>, S
pub async fn load_and_apply_voice_server_settings(
update: VoiceServerSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
- let mut config = load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
if let Some(auto_start) = update.auto_start {
config.voice_server.auto_start = auto_start;
}
diff --git a/crates/openhuman-core/src/config/workspace/ops.rs b/crates/openhuman-core/src/config/workspace/ops.rs
index d4f434b65f..6abbe6336a 100644
--- a/crates/openhuman-core/src/config/workspace/ops.rs
+++ b/crates/openhuman-core/src/config/workspace/ops.rs
@@ -68,7 +68,7 @@ fn classify_workspace_entry(
/// Create default dirs, copy bundled prompts, and the skills README.
pub async fn init_workspace(force: bool) -> Result<serde_json::Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let workspace_dir = config.workspace_dir.clone();
let mut created_dirs = Vec::new();
diff --git a/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs b/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs
index 5247fbda1d..a032cc31cc 100644
--- a/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs
+++ b/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs
@@ -43,7 +43,7 @@ pub async fn snapshot() -> Result<Outcome<AppStateSnapshot>, String> {
let t_total = Instant::now();
let t_config = Instant::now();
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
// Latch corruption recovery from *this* poll's load, not only from boot.
// `load_config_with_timeout` re-reads config.toml on every snapshot, so a
// config that becomes corrupt after boot is healed here — carrying a fresh
@@ -143,7 +143,7 @@ pub async fn snapshot() -> Result<Outcome<AppStateSnapshot>, String> {
pub async fn update_local_state(
patch: StoredAppStatePatch,
) -> Result<Outcome<StoredAppState>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let _guard = APP_STATE_FILE_LOCK.lock();
let mut current = load_stored_app_state_unlocked(&config)?;
diff --git a/crates/openhuman-core/src/desktop/control/ops.rs b/crates/openhuman-core/src/desktop/control/ops.rs
index e4c5015d90..59bb36b686 100644
--- a/crates/openhuman-core/src/desktop/control/ops.rs
+++ b/crates/openhuman-core/src/desktop/control/ops.rs
@@ -29,7 +29,7 @@ pub(crate) async fn approvals_disabled_for(tool: &dyn tinytools::Tool) -> bool {
if tool.family() != Some("desktop") || !DESKTOP_AGENT_TOOLS.contains(&tool.name()) {
return false;
}
- crate::config::rpc::load_config_with_timeout()
+ ctx.load_config()
.await
.is_ok_and(|config| approval_bypass_decision(&config, tool))
}
diff --git a/crates/openhuman-core/src/desktop/control/tools.rs b/crates/openhuman-core/src/desktop/control/tools.rs
index f91f69ce9d..8303785996 100644
--- a/crates/openhuman-core/src/desktop/control/tools.rs
+++ b/crates/openhuman-core/src/desktop/control/tools.rs
@@ -180,7 +180,7 @@ impl Tool for DesktopTool {
Err(error) => Err(error.into()),
},
DesktopToolKind::Goal => {
- let live_config = match crate::config::rpc::load_config_with_timeout().await {
+ let live_config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
return Ok(ToolResult::error(format!(
diff --git a/crates/openhuman-core/src/desktop/dashboard/README.md b/crates/openhuman-core/src/desktop/dashboard/README.md
index 9c51ad3873..c7ba168ebb 100644
--- a/crates/openhuman-core/src/desktop/dashboard/README.md
+++ b/crates/openhuman-core/src/desktop/dashboard/README.md
@@ -34,7 +34,7 @@ Aggregate, operator-facing views over local config. Today it owns a single read-
`ModelHealthEntry`: `id`, `provider`, `cost_per_1m_output` (f64), `vision` (bool), `quality_score` (`f64?`, placeholder), `hallucination_rate` (`f64?`, placeholder), `agents_using` (u64, placeholder 0), `tasks_evaluated` (u64, placeholder 0).
`ModelHealthConfigView`: `hallucination_threshold` (f64), `min_tasks_for_rating` (u64), `evaluation_window_tasks` (u64).
-The handler loads config via `crate::config::rpc::load_config_with_timeout()` and returns CLI-compatible JSON through `Outcome::into_cli_compatible_json()`. Wired into the registry in [`crates/openhuman-core/src/core/all.rs`](../../core/all.rs) (both `all_dashboard_registered_controllers` and `all_dashboard_controller_schemas`).
+The handler loads config via `ctx.load_config()` and returns CLI-compatible JSON through `Outcome::into_cli_compatible_json()`. Wired into the registry in [`crates/openhuman-core/src/core/all.rs`](../../core/all.rs) (both `all_dashboard_registered_controllers` and `all_dashboard_controller_schemas`).
## Persistence
diff --git a/crates/openhuman-core/src/desktop/notifications/rpc.rs b/crates/openhuman-core/src/desktop/notifications/rpc.rs
index bc7eb65535..0e19fcca23 100644
--- a/crates/openhuman-core/src/desktop/notifications/rpc.rs
+++ b/crates/openhuman-core/src/desktop/notifications/rpc.rs
@@ -37,7 +37,7 @@ use super::types::{
/// background task to run the triage pipeline and back-fill the score.
pub async fn handle_ingest(params: Map<String, Value>) -> Result<Value, String> {
let ingest_started_at = Utc::now();
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let req: NotificationIngestRequest = serde_json::from_value(Value::Object(params.clone()))
.map_err(|e| format!("[notification_intel] invalid ingest params: {e}"))?;
@@ -258,7 +258,7 @@ pub async fn handle_ingest(params: Map<String, Value>) -> Result<Value, String>
/// Optional params: `provider` (string), `limit` (u64), `offset` (u64),
/// `min_score` (f64).
pub async fn handle_list(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let provider = params
.get("provider")
@@ -295,7 +295,7 @@ pub async fn handle_list(params: Map<String, Value>) -> Result<Value, String> {
/// Mark a single notification as read.
pub async fn handle_mark_read(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = params
.get("id")
@@ -314,7 +314,7 @@ pub async fn handle_mark_read(params: Map<String, Value>) -> Result<Value, Strin
/// Read notification routing settings for a provider.
pub async fn handle_settings_get(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let provider = params
.get("provider")
.and_then(|v| v.as_str())
@@ -327,7 +327,7 @@ pub async fn handle_settings_get(params: Map<String, Value>) -> Result<Value, St
/// Upsert notification routing settings for a provider.
pub async fn handle_settings_set(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let req: NotificationSettingsUpsertRequest = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("[notification_intel] invalid settings_set params: {e}"))?;
let clamped = NotificationSettings {
@@ -348,7 +348,7 @@ pub async fn handle_settings_set(params: Map<String, Value>) -> Result<Value, St
/// Mark a single notification as dismissed.
pub async fn handle_dismiss(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = params
.get("id")
.and_then(|v| v.as_str())
@@ -368,7 +368,7 @@ pub async fn handle_dismiss(params: Map<String, Value>) -> Result<Value, String>
/// Mark a single notification as acted upon.
pub async fn handle_mark_acted(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = params
.get("id")
.and_then(|v| v.as_str())
@@ -397,7 +397,7 @@ pub async fn handle_mark_acted(params: Map<String, Value>) -> Result<Value, Stri
/// is broadcast-only. Optional params: `only_unread` (bool, default true),
/// `limit` (u64, default 100).
pub async fn handle_core_list(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let only_unread = params
.get("only_unread")
@@ -421,7 +421,7 @@ pub async fn handle_core_list(params: Map<String, Value>) -> Result<Value, Strin
/// Mark a persisted core notification as read so it isn't re-surfaced on the
/// next sync-down.
pub async fn handle_core_mark_read(params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let id = params
.get("id")
.and_then(|v| v.as_str())
@@ -441,7 +441,7 @@ pub async fn handle_core_mark_read(params: Map<String, Value>) -> Result<Value,
/// Return aggregate pipeline statistics.
pub async fn handle_stats(_params: Map<String, Value>) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
tracing::debug!("[notification_intel] stats requested");
let s = store::stats(&config).map_err(|e| format!("[notification_intel] stats failed: {e}"))?;
diff --git a/crates/openhuman-core/src/flows/memory_tools.rs b/crates/openhuman-core/src/flows/memory_tools.rs
index 3593128a4f..9d8147adc8 100644
--- a/crates/openhuman-core/src/flows/memory_tools.rs
+++ b/crates/openhuman-core/src/flows/memory_tools.rs
@@ -335,7 +335,7 @@ impl Tool for FlowMemoryRecallTool {
.and_then(serde_json::Value::as_u64)
.map_or(5, |v| v as usize);
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
return Ok(ToolResult::error(format!(
@@ -472,7 +472,7 @@ impl Tool for FlowMemoryRememberTool {
));
}
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
return Ok(ToolResult::error(format!(
diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rs
index 5c94dc082a..fbcbd0cea1 100644
--- a/crates/openhuman-core/src/flows/ops/streaming.rs
+++ b/crates/openhuman-core/src/flows/ops/streaming.rs
@@ -140,7 +140,7 @@ pub(super) async fn finalize_flow_stream(
// left non-terminal makes `threads_turn_state_get` report the turn as still
// running, so re-entering the thread paints a permanent "Thinking..."
// indicator under a reply that already landed.
- if let Ok(config) = crate::config::rpc::load_config_with_timeout().await {
+ if let Ok(config) = ctx.load_config().await {
let lifecycle = if result.is_ok() {
tinyagents_session::turn_state::TurnLifecycle::Completed
} else {
diff --git a/crates/openhuman-core/src/hooks/prompt_eval.rs b/crates/openhuman-core/src/hooks/prompt_eval.rs
index 85a26b801c..9934e6ffbc 100644
--- a/crates/openhuman-core/src/hooks/prompt_eval.rs
+++ b/crates/openhuman-core/src/hooks/prompt_eval.rs
@@ -19,7 +19,7 @@ use crate::config::schema::Config;
/// the fail-open / fail-closed decision, where the only thing that matters is
/// the message.
pub async fn evaluate(instruction: &str, model: Option<&str>) -> Result<String, String> {
- let mut config = crate::config::rpc::load_config_with_timeout()
+ let mut config = ctx.load_config()
.await
.map_err(|error| format!("loading config for prompt hook: {error}"))?;
if let Some(model) = model {
diff --git a/crates/openhuman-core/src/hooks/shell.rs b/crates/openhuman-core/src/hooks/shell.rs
index 60c84d63ef..ac5e6b3ce2 100644
--- a/crates/openhuman-core/src/hooks/shell.rs
+++ b/crates/openhuman-core/src/hooks/shell.rs
@@ -29,7 +29,7 @@ fn slot() -> &'static RwLock<Option<ShellInvocation>> {
pub(super) async fn resolve() {
#[cfg(feature = "modules")]
{
- let config = match crate::config::ops::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
log::warn!("[hooks] cannot read config to select the hook shell: {error}");
diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
index 62c36ae8de..52dfbf68a5 100644
--- a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
@@ -202,7 +202,7 @@ pub async fn update_settings(
use crate::config::ops as config_rpc;
use tinyinference_embeddings::format_embedding_signature;
- let mut config = config_rpc::load_config_with_timeout().await?;
+ let mut config = ctx.load_config().await?;
// Upgrade-in-place for users whose endpoint predates the retained Custom
// profile: if they disable or switch away now, capture the active profile
diff --git a/crates/openhuman-core/src/inference/ops.rs b/crates/openhuman-core/src/inference/ops.rs
index 9c89ef69c0..72deb77835 100644
--- a/crates/openhuman-core/src/inference/ops.rs
+++ b/crates/openhuman-core/src/inference/ops.rs
@@ -283,7 +283,7 @@ pub async fn inference_update_local_settings(
// The endpoint, provider or models may have changed: drop the
// cached probe verdict so the next status poll re-probes the
// user's runtime instead of reporting the old endpoint's state.
- match config_rpc::load_config_with_timeout().await {
+ match ctx.load_config().await {
Ok(config) => {
let runtime = crate::inference::local_runtime_config(&config);
local_runtime::global(&config).reset_to_idle(&runtime);
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index b8f8783e05..e43e63062b 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -442,7 +442,7 @@ mod repl_module_tests;
pub async fn query(
request: tinyjuice_bus::wire::QueryRequest,
) -> Result<tinyjuice_bus::wire::QueryResponse, String> {
- let config = crate::config::ops::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
query_for_config(&config, request).await
}
@@ -459,7 +459,7 @@ pub(crate) async fn query_for_config(
/// Extract HTML through the compiled module independently of compression settings.
pub async fn extract_html(html: String) -> Result<String, String> {
- let config = crate::config::ops::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let response: tinyjuice_bus::wire::HtmlResponse = client(&config)
.call("tinyjuice", methods::EXTRACT_HTML, (html,))
.await
diff --git a/crates/openhuman-core/src/integrations/composio/action_tool.rs b/crates/openhuman-core/src/integrations/composio/action_tool.rs
index 5f33a080b2..b6d526d183 100644
--- a/crates/openhuman-core/src/integrations/composio/action_tool.rs
+++ b/crates/openhuman-core/src/integrations/composio/action_tool.rs
@@ -165,7 +165,7 @@ impl ComposioActionTool {
async fn live_config(&self) -> Result<Config, String> {
match self.config.as_deref() {
Some(snapshot) => super::tools::live_composio_config(snapshot).await,
- None => config_rpc::load_config_with_timeout().await,
+ None => ctx.load_config().await,
}
}
}
diff --git a/crates/openhuman-core/src/integrations/composio/bus/config_changed_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/config_changed_subscriber.rs
index 08edfd670e..645c48f263 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/config_changed_subscriber.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/config_changed_subscriber.rs
@@ -62,7 +62,7 @@ impl EventHandler<DomainEvent> for ComposioConfigChangedSubscriber {
ops::invalidate_connected_integrations_cache();
tokio::spawn(async move {
- let config = match config_rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
tracing::debug!(
diff --git a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs
index acd4fb3c40..9feaa9aa0b 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs
@@ -94,7 +94,7 @@ impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {
}
async fn on_connection_created(toolkit: String, connection_id: String) {
- let config = match config_rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(c) => c,
Err(e) => {
tracing::warn!(
diff --git a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
index 654a82c126..70899c3a97 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
@@ -82,7 +82,7 @@ impl EventHandler<DomainEvent> for ComposioTriggerSubscriber {
// let the event through rather than silently dropping it. The
// existing env-var / config triage flags below remain the
// backend-mode gates.
- if let Ok(config) = config_rpc::load_config_with_timeout().await {
+ if let Ok(config) = ctx.load_config().await {
if config.composio.mode == crate::config::schema::COMPOSIO_MODE_DIRECT {
tracing::info!(
toolkit = %toolkit,
@@ -94,7 +94,7 @@ impl EventHandler<DomainEvent> for ComposioTriggerSubscriber {
}
if let Some(store) = trigger_history::global() {
- match config_rpc::load_config_with_timeout().await {
+ match ctx.load_config().await {
Ok(config) => {
let event = super::super::types::ComposioTriggerEvent {
toolkit: toolkit.clone(),
@@ -128,7 +128,7 @@ impl EventHandler<DomainEvent> for ComposioTriggerSubscriber {
// remains a global emergency kill-switch that works even when the
// config file is corrupt. Fail-open on load error: if we can't read
// the config we let triage run rather than silently drop events.
- match config_rpc::load_config_with_timeout().await {
+ match ctx.load_config().await {
Ok(config) => {
if config.composio.triage_disabled {
tracing::debug!(
diff --git a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
index 88d75a02f2..6e4f770316 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
@@ -92,7 +92,7 @@ pub async fn composio_set_api_key(
.map_err(|e| format!("[composio-direct] store_composio_api_key failed: {e}"))?;
let mode_log = if activate_direct {
- let mut cfg_mut = crate::config::rpc::load_config_with_timeout()
+ let mut cfg_mut = ctx.load_config()
.await
.map_err(|e| format!("[composio-direct] reload config failed: {e}"))?;
cfg_mut.composio.mode = crate::config::schema::COMPOSIO_MODE_DIRECT.into();
@@ -137,7 +137,7 @@ pub async fn composio_clear_api_key(config: &Config) -> OpResult<Outcome<serde_j
.await
.map_err(|e| format!("[composio-direct] clear_composio_api_key failed: {e}"))?;
- let mut cfg_mut = crate::config::rpc::load_config_with_timeout()
+ let mut cfg_mut = ctx.load_config()
.await
.map_err(|e| format!("[composio-direct] reload config failed: {e}"))?;
cfg_mut.composio.mode = crate::config::schema::COMPOSIO_MODE_BACKEND.into();
diff --git a/crates/openhuman-core/src/integrations/task_sources/bus.rs b/crates/openhuman-core/src/integrations/task_sources/bus.rs
index 3abffbf4fb..12d29ab736 100644
--- a/crates/openhuman-core/src/integrations/task_sources/bus.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/bus.rs
@@ -63,7 +63,7 @@ impl EventHandler<DomainEvent> for TaskSourcesConnectionSubscriber {
/// skipped even when the process config enables them, and the other way
/// round.
async fn fire_in_scope(provider: ProviderSlug, toolkit: &str, connection_id: &str) {
- let config = match config_rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(e) => {
tracing::debug!(error = %e, "[task_sources:bus] load_config failed, skipping scope");
diff --git a/crates/openhuman-core/src/integrations/task_sources/periodic.rs b/crates/openhuman-core/src/integrations/task_sources/periodic.rs
index 734a02df1c..d75a7db6d9 100644
--- a/crates/openhuman-core/src/integrations/task_sources/periodic.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/periodic.rs
@@ -112,7 +112,7 @@ async fn run_loop() {
/// Run a single scheduler tick. `pub(crate)` so tests can drive ticks
/// without the real `interval`.
pub(crate) async fn run_one_tick() -> Result<(), String> {
- let config = config_rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|e| format!("load_config: {e}"))?;
diff --git a/crates/openhuman-core/src/memory/bus.rs b/crates/openhuman-core/src/memory/bus.rs
index 8a800c1f6b..5916105ddf 100644
--- a/crates/openhuman-core/src/memory/bus.rs
+++ b/crates/openhuman-core/src/memory/bus.rs
@@ -57,7 +57,7 @@ impl EventHandler<DomainEvent> for PendingDeletionsSubscriber {
if kind == "cleared" {
return;
}
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
tracing::debug!(error = %error, "[memory:bus] config unavailable; deletions wait");
@@ -96,7 +96,7 @@ impl EventHandler<DomainEvent> for SystemJobsSubscriber {
if job != SOURCES_SYNC_JOB && job != BACKGROUND_JOB {
return;
}
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
tracing::debug!(error = %error, job = %job, "[memory:bus] config unavailable");
diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rs
index 1b27be12e7..4b9df781bf 100644
--- a/crates/openhuman-core/src/memory/schemas/handlers.rs
+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs
@@ -35,7 +35,7 @@ fn finish<T: Serialize>(result: MemoryResult<T>) -> Result<Value, String> {
}
async fn load() -> Result<Config, String> {
- crate::config::rpc::load_config_with_timeout().await
+ ctx.load_config().await
}
async fn save(config: &Config) -> MemoryResult<()> {
diff --git a/crates/openhuman-core/src/platform/doctor/README.md b/crates/openhuman-core/src/platform/doctor/README.md
index 16b04a48e0..799645df77 100644
--- a/crates/openhuman-core/src/platform/doctor/README.md
+++ b/crates/openhuman-core/src/platform/doctor/README.md
@@ -47,7 +47,7 @@ Namespace `doctor`, two functions:
| `doctor.report` | none | `DoctorReport` ("Run diagnostics for workspace and runtime configuration.") |
| `doctor.models` | `use_cache: Option<bool>` (default `true`) | `ModelProbeReport` ("Probe provider model availability and auth status.") |
-Both handlers load config via `config_rpc::load_config_with_timeout()` and return `Outcome::single_log(...)`. Wired into the global registry in `crates/openhuman-core/src/core/all.rs` (controllers, schemas, and the namespace description "Run diagnostics for workspace and runtime health.").
+Both handlers load config via `ctx.load_config()` and return `Outcome::single_log(...)`. Wired into the global registry in `crates/openhuman-core/src/core/all.rs` (controllers, schemas, and the namespace description "Run diagnostics for workspace and runtime health.").
## Agent tools
diff --git a/crates/openhuman-core/src/platform/socket/ops.rs b/crates/openhuman-core/src/platform/socket/ops.rs
index 737ff73ff6..a899d8e2bb 100644
--- a/crates/openhuman-core/src/platform/socket/ops.rs
+++ b/crates/openhuman-core/src/platform/socket/ops.rs
@@ -51,7 +51,7 @@ async fn connect_with_session_using(
pub async fn connect_with_session(manager: &SocketManager) -> Result<SocketState, String> {
log::info!("[socket:rpc] connect_with_session — resolving credentials");
- let config = std::sync::Arc::new(crate::config::rpc::load_config_with_timeout().await?);
+ let config = std::sync::Arc::new(ctx.load_config().await?);
let api_url = crate::backend::require_base_url(&config.api_url)?;
let token = crate::security::credentials::session_support::get_session_token(&config)
.map_err(|e| format!("failed to read session token: {e}"))?
diff --git a/crates/openhuman-core/src/platform/update/ops.rs b/crates/openhuman-core/src/platform/update/ops.rs
index be02910376..f40c1a3359 100644
--- a/crates/openhuman-core/src/platform/update/ops.rs
+++ b/crates/openhuman-core/src/platform/update/ops.rs
@@ -10,7 +10,7 @@ use crate::platform::update;
use crate::platform::update::types::{UpdateApplyResult, UpdateInfo, UpdateRunResult, VersionInfo};
async fn load_update_policy() -> Result<UpdateConfig, String> {
- config::rpc::load_config_with_timeout()
+ ctx.load_config()
.await
.map(|cfg| cfg.update)
.map_err(|err| format!("failed to load config for update policy: {err}"))
diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rs
index 52247b4858..683fb0291a 100644
--- a/crates/openhuman-core/src/sandbox/ops.rs
+++ b/crates/openhuman-core/src/sandbox/ops.rs
@@ -57,7 +57,7 @@ pub async fn command_requires_sandbox(sandbox_mode: Option<SandboxMode>) -> Resu
if matches!(sandbox_mode, Some(SandboxMode::Sandboxed)) {
return Ok(true);
}
- let config = crate::config::ops::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
if config_disables_sandbox(&config) {
return Ok(false);
}
@@ -80,7 +80,7 @@ pub(crate) async fn resolve_command_policy(
if crate::core::runtime::is_saas() {
return crate::profiles::tools::sandbox_policy(action_dir, state_dir);
}
- let config = crate::config::ops::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("Cannot read sandbox configuration: {error}"))?;
let mut policy = resolve_sandbox_policy(
@@ -232,7 +232,7 @@ pub async fn create_sandbox_backend(policy: &SandboxPolicy) -> SandboxBackendHan
backend_id: None,
});
}
- let config = match crate::config::ops::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(_) if policy.backend == SandboxBackendKind::Docker => {
return docker_error_handle();
@@ -317,7 +317,7 @@ pub(crate) async fn execute_in_sandbox_metered(
let explicitly_requested = if crate::core::runtime::is_saas() || sandbox_disabled_by_host() {
false
} else {
- let config = crate::config::ops::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|e| anyhow::anyhow!("Cannot read sandbox configuration: {e}"))?;
module_config = Some(config.clone());
@@ -349,7 +349,7 @@ pub(crate) async fn execute_in_sandbox_metered(
crate::config::ensure_usable_cwd(working_dir)?;
let config = match module_config {
Some(config) => config,
- None => crate::config::ops::load_config_with_timeout()
+ None => ctx.load_config()
.await
.map_err(|error| {
anyhow::anyhow!("Cannot read module configuration: {error}")
@@ -370,7 +370,7 @@ pub(crate) async fn execute_in_sandbox_metered(
crate::config::ensure_usable_cwd(working_dir)?;
let config = match module_config {
Some(config) => config,
- None => crate::config::ops::load_config_with_timeout()
+ None => ctx.load_config()
.await
.map_err(|error| {
anyhow::anyhow!("Cannot read module configuration: {error}")
@@ -399,7 +399,7 @@ pub(crate) async fn execute_in_sandbox_metered(
};
let config = match module_config {
Some(config) => config,
- None => crate::config::ops::load_config_with_timeout()
+ None => ctx.load_config()
.await
.map_err(|error| {
anyhow::anyhow!("Cannot read module configuration: {error}")
diff --git a/crates/openhuman-core/src/search/bus.rs b/crates/openhuman-core/src/search/bus.rs
index 987bbae5e2..2c0e76baeb 100644
--- a/crates/openhuman-core/src/search/bus.rs
+++ b/crates/openhuman-core/src/search/bus.rs
@@ -28,7 +28,7 @@ impl EventHandler<DomainEvent> for CredentialRefreshSubscriber {
let DomainEvent::CredentialChanged { kind } = event else {
return;
};
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => {
tracing::warn!(kind = %kind, %error, "[search][bus] config unavailable; skipping refresh");
diff --git a/crates/openhuman-core/src/search/tools.rs b/crates/openhuman-core/src/search/tools.rs
index 9ba37f5044..1b8e0e828f 100644
--- a/crates/openhuman-core/src/search/tools.rs
+++ b/crates/openhuman-core/src/search/tools.rs
@@ -119,7 +119,7 @@ impl TinySearchTool {
async fn live_config(&self) -> anyhow::Result<Config> {
match &self.config {
Some(config) => Ok(config.as_ref().clone()),
- None => crate::config::rpc::load_config_with_timeout()
+ None => ctx.load_config()
.await
.map_err(|error| anyhow::anyhow!(error)),
}
diff --git a/crates/openhuman-core/src/security/credentials/bus.rs b/crates/openhuman-core/src/security/credentials/bus.rs
index f622181e03..c7209084dc 100644
--- a/crates/openhuman-core/src/security/credentials/bus.rs
+++ b/crates/openhuman-core/src/security/credentials/bus.rs
@@ -86,7 +86,7 @@ impl SessionExpiredSubscriber {
// turns out to be a local offline session (never truly expired).
scheduler_gate::set_signed_out(true);
- match crate::config::rpc::load_config_with_timeout().await {
+ match ctx.load_config().await {
Ok(config) => {
// An API-key runtime has no session to clear: a backend 401 on
// the key is a per-call error for the caller, not a sign-out.
diff --git a/crates/openhuman-core/src/security/credentials/ops/credential.rs b/crates/openhuman-core/src/security/credentials/ops/credential.rs
index af6176828b..e61cdb859f 100644
--- a/crates/openhuman-core/src/security/credentials/ops/credential.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/credential.rs
@@ -551,7 +551,7 @@ async fn clear_session_credential(config: &Config) -> Result<Outcome<bool>, Stri
// Every process-global store must follow the now-active pre-login
// workspace, or a signed-out caller keeps reading the previous account's
// context until the process restarts.
- match crate::config::load_config_with_timeout().await {
+ match ctx.load_config().await {
Ok(signed_out_config) => {
logs.extend(rebind_after_credential_change(
&signed_out_config,
diff --git a/crates/openhuman-core/src/security/credentials/ops/user_scope.rs b/crates/openhuman-core/src/security/credentials/ops/user_scope.rs
index 37ae57e98e..9785dc8a1b 100644
--- a/crates/openhuman-core/src/security/credentials/ops/user_scope.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/user_scope.rs
@@ -110,7 +110,7 @@ pub(super) fn deactivate_user_scope() -> Result<(), String> {
/// activation so credentials, keys and workspaces land in the user-scoped
/// location — or `fallback` when the reload fails.
pub(super) async fn reload_config_or(_fallback: &Config) -> Result<Config, String> {
- crate::config::load_config_with_timeout()
+ ctx.load_config()
.await
.map_err(|error| error.to_string())
}
diff --git a/crates/openhuman-core/src/security/credentials/session_support.rs b/crates/openhuman-core/src/security/credentials/session_support.rs
index 3dda8f5463..1454461242 100644
--- a/crates/openhuman-core/src/security/credentials/session_support.rs
+++ b/crates/openhuman-core/src/security/credentials/session_support.rs
@@ -66,7 +66,7 @@ pub fn is_local_session_token(token: &str) -> bool {
/// this credential remains valid; those errors must not broadcast sign-out.
/// A failed lookup leaves the ordinary session-expiry path in place.
pub async fn current_session_is_local() -> bool {
- let Ok(config) = crate::config::rpc::load_config_with_timeout().await else {
+ let Ok(config) = ctx.load_config().await else {
return false;
};
get_session_token(&config)
diff --git a/crates/openhuman-core/src/security/devices/bus.rs b/crates/openhuman-core/src/security/devices/bus.rs
index c2410c5ac4..a5e11819b7 100644
--- a/crates/openhuman-core/src/security/devices/bus.rs
+++ b/crates/openhuman-core/src/security/devices/bus.rs
@@ -393,7 +393,7 @@ async fn handle_tunnel_frame(channel_id: &str, payload_b64: &str) {
// Load config from global env (best-effort; pairing persists even if config
// loading is slow — the UI will see the device on next list call).
- if let Ok(config) = crate::config::rpc::load_config_with_timeout().await {
+ if let Ok(config) = ctx.load_config().await {
match store::insert_device(
&config,
channel_id,
diff --git a/crates/openhuman-core/src/security/devices/owner.rs b/crates/openhuman-core/src/security/devices/owner.rs
index 738366f698..b0257d2e95 100644
--- a/crates/openhuman-core/src/security/devices/owner.rs
+++ b/crates/openhuman-core/src/security/devices/owner.rs
@@ -63,7 +63,7 @@ pub(super) type OwnerLookupFailed = crate::storage::agents::LookupFailed;
/// paired device. The configuration is loaded inside the scope: in SaaS mode
/// loading it needs an acting agent, which the tunnel task does not have.
async fn has_live_device(channel_id: &str) -> Result<bool, String> {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("load config: {error}"))?;
super::store::get_device(&config, channel_id)
@@ -74,7 +74,7 @@ async fn has_live_device(channel_id: &str) -> Result<bool, String> {
/// Whether the current scope holds `channel_id` as a revoked device (a missing
/// row is not revoked).
async fn is_revoked(channel_id: &str) -> Result<bool, String> {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("load config: {error}"))?;
super::store::get_device(&config, channel_id)
diff --git a/crates/openhuman-core/src/security/ops.rs b/crates/openhuman-core/src/security/ops.rs
index b46fdb7849..ffb147d3ea 100644
--- a/crates/openhuman-core/src/security/ops.rs
+++ b/crates/openhuman-core/src/security/ops.rs
@@ -25,7 +25,7 @@ pub fn security_policy_info_for_config(config: &Config) -> Outcome<serde_json::V
}
pub async fn load_and_get_security_policy_info() -> Result<Outcome<serde_json::Value>, String> {
- let config = crate::config::ops::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
Ok(security_policy_info_for_config(&config))
}
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index bd0e912330..f32fcb3002 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -155,7 +155,7 @@ pub async fn message_append(
request: AppendConversationMessageRequest,
) -> Result<Outcome<ApiEnvelope<ConversationMessageRecord>>, ThreadsError> {
let origin = crate::core::runtime::CoreContext::current_turn_origin();
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| ThreadsError::Message(format!("load config: {error}")))?;
let persistence_dir = workspace_dir().await.map_err(ThreadsError::Message)?;
@@ -407,7 +407,7 @@ pub async fn delete_after(
pub async fn thread_delete(
request: DeleteConversationThreadRequest,
) -> Result<Outcome<ApiEnvelope<DeleteConversationThreadResponse>>, String> {
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|e| format!("load config: {e}"))?;
run_to_completion("thread_delete", thread_delete_inner(config, request)).await
diff --git a/crates/openhuman-core/src/threads/store/bus.rs b/crates/openhuman-core/src/threads/store/bus.rs
index 1f87506756..8c49a5cbdd 100644
--- a/crates/openhuman-core/src/threads/store/bus.rs
+++ b/crates/openhuman-core/src/threads/store/bus.rs
@@ -356,7 +356,7 @@ async fn persist_channel_turn(
let client = crate::channels::module_fixture::client().await;
#[cfg(not(all(test, feature = "channels", feature = "modules")))]
let client = {
- let config = crate::config::rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
if config.workspace_dir != workspace_dir {
return Err("channel workspace changed".into());
}
diff --git a/crates/openhuman-core/src/tools/impl/network/host.rs b/crates/openhuman-core/src/tools/impl/network/host.rs
index fc752f12d2..9a0f1682e0 100644
--- a/crates/openhuman-core/src/tools/impl/network/host.rs
+++ b/crates/openhuman-core/src/tools/impl/network/host.rs
@@ -290,7 +290,7 @@ mod x402 {
.ok_or_else(|| {
"402 response is missing a valid PAYMENT-REQUIRED header".to_string()
})?;
- let config = crate::config::rpc::load_config_with_timeout()
+ let config = ctx.load_config()
.await
.map_err(|error| format!("x402 payment failed: {error}"))?;
declined_when_wallet_off(&config)?;
diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rs
index 64b2767337..4fadb0acd0 100644
--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs
+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs
@@ -82,7 +82,7 @@ impl ImageInspector for ModuleImageInspector<'_> {
let config = match self.config {
Some(config) => config,
None => {
- loaded = crate::config::ops::load_config_with_timeout()
+ loaded = ctx.load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
&loaded
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index 97e30a2f23..c7e6e6f81c 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -596,7 +596,7 @@ impl ShellTool {
);
let config = match self.analysis_config.as_deref() {
Some(config) => config.clone(),
- None => match crate::config::ops::load_config_with_timeout().await {
+ None => match ctx.load_config().await {
Ok(config) => config,
Err(e) => {
return (
diff --git a/crates/openhuman-core/src/tools/schemas/web_search.rs b/crates/openhuman-core/src/tools/schemas/web_search.rs
index 14d5404b11..0dd3c8f1f5 100644
--- a/crates/openhuman-core/src/tools/schemas/web_search.rs
+++ b/crates/openhuman-core/src/tools/schemas/web_search.rs
@@ -34,7 +34,7 @@ async fn run_role_tool(
arguments: Value,
method: &str,
) -> Result<Value, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
run_role_tool_with(&config, tool, arguments, method).await
}
diff --git a/crates/openhuman-core/src/web3/module_tools.rs b/crates/openhuman-core/src/web3/module_tools.rs
index d810d63b74..cd8b5f6de4 100644
--- a/crates/openhuman-core/src/web3/module_tools.rs
+++ b/crates/openhuman-core/src/web3/module_tools.rs
@@ -65,7 +65,7 @@ impl Web3ModuleTool {
chat: Option<&crate::security::approval::ApprovalChatContext>,
) -> anyhow::Result<ToolResult> {
let owner = crate::modules::web3_service::owner_of(chat);
- let config = match crate::config::rpc::load_config_with_timeout().await {
+ let config = match ctx.load_config().await {
Ok(config) => config,
Err(error) => return Ok(ToolResult::error(error)),
};
diff --git a/crates/openhuman-core/src/web3/wallet/execution.rs b/crates/openhuman-core/src/web3/wallet/execution.rs
index c4d52d0099..48f9719f8b 100644
--- a/crates/openhuman-core/src/web3/wallet/execution.rs
+++ b/crates/openhuman-core/src/web3/wallet/execution.rs
@@ -20,7 +20,7 @@ use super::ops::WalletChain;
/// Default row for every supported network, with the host's endpoints.
pub async fn network_defaults() -> Result<Outcome<Vec<WalletNetworkDefaults>>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -39,7 +39,7 @@ pub async fn network_defaults() -> Result<Outcome<Vec<WalletNetworkDefaults>>, S
/// Every asset the wallet catalogues.
pub async fn supported_assets() -> Result<Outcome<Vec<SupportedAsset>>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -58,7 +58,7 @@ pub async fn supported_assets() -> Result<Outcome<Vec<SupportedAsset>>, String>
/// Which chains have an account and a provider.
pub async fn chain_status() -> Result<Outcome<Vec<ChainStatus>>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -77,7 +77,7 @@ pub async fn chain_status() -> Result<Outcome<Vec<ChainStatus>>, String> {
/// Live native balances.
pub async fn balances() -> Result<Outcome<Vec<BalanceInfo>>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -99,7 +99,7 @@ pub async fn prepare_transfer(
params: PrepareTransferParams,
owner: Option<tinywallet_bus::wire::QuoteOwner>,
) -> Result<Outcome<PreparedTransaction>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let quote = wallet_service::prepare_native_transfer(&config, owner, params)
.await
.map_err(|error| error.to_string())?;
@@ -114,7 +114,7 @@ pub async fn execute_prepared(
params: ExecutePreparedParams,
owner: Option<tinywallet_bus::wire::QuoteOwner>,
) -> Result<Outcome<ExecutionResult>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::execute_native_transfer(&config, owner, params)
.await
.map_err(|error| error.to_string())?;
@@ -130,7 +130,7 @@ pub async fn tx_status(
evm_network: Option<EvmNetwork>,
hash: &str,
) -> Result<Outcome<TxStatusInfo>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -158,7 +158,7 @@ pub async fn tx_receipt(
evm_network: Option<EvmNetwork>,
hash: &str,
) -> Result<Outcome<TxReceiptInfo>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -186,7 +186,7 @@ pub async fn lookup_tx(
evm_network: Option<EvmNetwork>,
hash: &str,
) -> Result<Outcome<TxLookupInfo>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
&config,
@@ -210,7 +210,7 @@ pub async fn lookup_tx(
/// Encode ERC-20 transfer calldata in the loaded wallet module.
pub async fn encode_erc20_transfer(to_address: &str, amount_raw: &str) -> Result<String, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
wallet_module::encode_erc20_transfer(&config, to_address, amount_raw)
.await
.map_err(|error| error.to_string())
diff --git a/crates/openhuman-core/src/web3/wallet/ops.rs b/crates/openhuman-core/src/web3/wallet/ops.rs
index 60e3bcdbaf..97b66f6e63 100644
--- a/crates/openhuman-core/src/web3/wallet/ops.rs
+++ b/crates/openhuman-core/src/web3/wallet/ops.rs
@@ -41,7 +41,7 @@ pub async fn generate_recovery_phrase(
word_count: u8,
) -> Result<Outcome<GeneratedRecoveryPhrase>, String> {
tinywallet_bus::validate_mnemonic_word_count(word_count).map_err(|error| error.to_string())?;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let generated = crate::modules::wallet::generate_mnemonic(&config, word_count)
.await
.map_err(|error| error.to_string())?;
@@ -70,7 +70,7 @@ pub async fn derive_recovery_material(
));
}
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let mnemonic = Zeroizing::new(mnemonic);
let mnemonic = Zeroizing::new(mnemonic.split_whitespace().collect::<Vec<_>>().join(" "));
let seed = crate::modules::wallet::derive_mnemonic_seed(&config, mnemonic.to_string())
@@ -119,7 +119,7 @@ pub async fn validate_recovery_phrase(
) -> Result<Outcome<RecoveryPhraseValidation>, String> {
use crate::modules::wallet::WalletCallError;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let valid = match crate::modules::wallet::derive_mnemonic_seed(&config, mnemonic).await {
Ok(mut response) => {
if response.seed.len() != 64 {
@@ -201,7 +201,7 @@ fn validate_setup(params: &WalletSetupParams) -> Result<Vec<WalletAccount>, Stri
}
pub async fn status() -> Result<Outcome<WalletStatus>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let _guard = WALLET_STATE_FILE_LOCK.lock();
let status = to_status(&config, load_stored_wallet_state_unlocked(&config)?);
@@ -219,7 +219,7 @@ pub async fn status() -> Result<Outcome<WalletStatus>, String> {
}
pub async fn setup(params: WalletSetupParams) -> Result<Outcome<WalletStatus>, String> {
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let accounts = validate_setup(&params)?;
let encrypted_mnemonic = params
.encrypted_mnemonic
@@ -273,7 +273,7 @@ pub async fn setup(params: WalletSetupParams) -> Result<Outcome<WalletStatus>, S
pub async fn reveal_recovery_phrase() -> Result<Outcome<RevealRecoveryPhraseResult>, String> {
debug!("{LOG_PREFIX} reveal_recovery_phrase ENTRY");
- let config = config_rpc::load_config_with_timeout().await.map_err(|e| {
+ let config = ctx.load_config().await.map_err(|e| {
log::warn!("{LOG_PREFIX} reveal_recovery_phrase config load failed: {e}");
e
})?;
@@ -353,7 +353,7 @@ pub(crate) async fn secret_material(chain: WalletChain) -> Result<WalletSecretMa
"{LOG_PREFIX} secret_material loading config chain={}",
chain.as_str()
);
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
debug!(
"{LOG_PREFIX} secret_material acquiring state lock chain={}",
chain.as_str()
diff --git a/crates/openhuman-core/src/web3/wallet/test_support.rs b/crates/openhuman-core/src/web3/wallet/test_support.rs
index e1411665a1..d254fb1071 100644
--- a/crates/openhuman-core/src/web3/wallet/test_support.rs
+++ b/crates/openhuman-core/src/web3/wallet/test_support.rs
@@ -120,7 +120,7 @@ pub(crate) async fn setup_wallet_in(temp: &TempDir) -> Result<EnvVarGuard, Strin
// each test. Return a guard so the tempdir path does not leak into later
// parallel tests after this test's TempDir has been dropped.
let workspace_guard = set_workspace_env_for_test(temp).await;
- let config = config_rpc::load_config_with_timeout().await?;
+ let config = ctx.load_config().await?;
let encrypted = crate::security::encryption::rpc::encrypt_secret(&config, TEST_MNEMONIC)
.await?
.value;