Skip to content

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

refactor(core): replace RpcOutcome with core::Outcome

Steven Enamakel09c9e64702dc
diff --git a/crates/openhuman-core/src/config/ops/computer.rs b/crates/openhuman-core/src/config/ops/computer.rs
index 0c3b767879..6ae095a87f 100644
--- a/crates/openhuman-core/src/config/ops/computer.rs
+++ b/crates/openhuman-core/src/config/ops/computer.rs
@@ -2,7 +2,7 @@
//! rescue models the module runs a task with.
use crate::config::{ComputerConfig, Config, DecisionModel};
-use crate::rpc::RpcOutcome;
+use crate::core::Outcome;
use super::loader::{load_config_with_timeout, snapshot_config_json};
@@ -73,7 +73,7 @@ pub fn patched(
pub async fn apply_computer_settings(
config: &mut Config,
update: ComputerSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
config.computer = patched(&config.computer, update)?;
tracing::debug!(
decision_model = config.computer.decision_model.as_str(),
@@ -83,7 +83,7 @@ pub async fn apply_computer_settings(
);
config.save().await.map_err(|e| e.to_string())?;
let snapshot = snapshot_config_json(config)?;
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
snapshot,
vec![format!(
"computer settings saved to {}",
@@ -95,7 +95,7 @@ pub async fn apply_computer_settings(
/// Load the configuration, update `[computer]`, and save it.
pub async fn load_and_apply_computer_settings(
update: ComputerSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
let mut config = load_config_with_timeout().await?;
apply_computer_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 0d483cac72..6cd5ff68bd 100644
--- a/crates/openhuman-core/src/config/ops/search.rs
+++ b/crates/openhuman-core/src/config/ops/search.rs
@@ -13,7 +13,7 @@ use serde_json::{json, Value};
use crate::config::{
Config, SearchPresentation, SearchRoute, MANAGED_SEARCH_PROVIDERS, SEARCH_PROVIDERS,
};
-use crate::rpc::RpcOutcome;
+use crate::core::Outcome;
use crate::search::providers::{self, parse_role, role_key, ROLES};
use super::loader::load_config_with_timeout;
@@ -289,7 +289,7 @@ pub fn apply_search_patch(config: &mut Config, update: SearchSettingsPatch) -> R
pub async fn apply_search_settings(
config: &mut Config,
update: SearchSettingsPatch,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
apply_search_patch(config, update)?;
config.save().await.map_err(|e| e.to_string())?;
#[cfg(feature = "modules")]
@@ -299,7 +299,7 @@ pub async fn apply_search_settings(
providers = ?config.search.enabled_provider_names(),
"[config][search] settings saved"
);
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
search_settings_json(config),
vec![format!(
"search settings saved to {}",
@@ -310,7 +310,7 @@ pub async fn apply_search_settings(
pub async fn load_and_apply_search_settings(
update: SearchSettingsPatch,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let mut config = load_config_with_timeout().await?;
apply_search_settings(&mut config, update).await
}
@@ -386,9 +386,9 @@ 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<RpcOutcome<Value>, String> {
+pub async fn get_search_settings() -> Result<Outcome<Value>, String> {
let config = load_config_with_timeout().await?;
- Ok(RpcOutcome::new(
+ 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 7097651ef6..acfa5987a3 100644
--- a/crates/openhuman-core/src/config/ops/ui.rs
+++ b/crates/openhuman-core/src/config/ops/ui.rs
@@ -4,7 +4,7 @@
use serde_json::json;
use crate::config::Config;
-use crate::rpc::RpcOutcome;
+use crate::core::Outcome;
use super::loader::{fallback_workspace_dir, load_config_with_timeout, snapshot_config_json};
@@ -58,7 +58,7 @@ pub struct VoiceServerSettingsPatch {
pub async fn apply_browser_settings(
config: &mut Config,
update: BrowserSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
let normalized_backend = update
.backend
.as_deref()
@@ -120,7 +120,7 @@ pub async fn apply_browser_settings(
config.browser = browser;
config.save().await.map_err(|e| e.to_string())?;
let snapshot = snapshot_config_json(config)?;
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
snapshot,
vec![format!(
"browser settings saved to {}",
@@ -155,7 +155,7 @@ fn normalize_browser_backend(raw: &str) -> Result<String, String> {
/// Loads the configuration, applies browser settings updates, and saves it.
pub async fn load_and_apply_browser_settings(
update: BrowserSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
let mut config = load_config_with_timeout().await?;
apply_browser_settings(&mut config, update).await
}
@@ -164,13 +164,13 @@ pub async fn load_and_apply_browser_settings(
pub async fn apply_analytics_settings(
config: &mut Config,
update: AnalyticsSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
if let Some(enabled) = update.enabled {
config.observability.analytics_enabled = enabled;
}
config.save().await.map_err(|e| e.to_string())?;
let snapshot = snapshot_config_json(config)?;
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
snapshot,
vec![format!(
"analytics settings saved to {}",
@@ -182,7 +182,7 @@ pub async fn apply_analytics_settings(
/// Loads the configuration, applies analytics settings updates, and saves it.
pub async fn load_and_apply_analytics_settings(
update: AnalyticsSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
let mut config = load_config_with_timeout().await?;
apply_analytics_settings(&mut config, update).await
}
@@ -191,7 +191,7 @@ pub async fn load_and_apply_analytics_settings(
pub async fn workspace_onboarding_flag_resolve(
flag_name: Option<String>,
default_name: &str,
-) -> Result<RpcOutcome<bool>, String> {
+) -> Result<Outcome<bool>, String> {
let name = flag_name.unwrap_or_else(|| default_name.to_string());
let trimmed = name.trim();
if trimmed.is_empty()
@@ -212,7 +212,7 @@ pub async fn workspace_onboarding_flag_resolve(
pub fn workspace_onboarding_flag_exists(
workspace_dir: std::path::PathBuf,
flag_name: &str,
-) -> Result<RpcOutcome<bool>, String> {
+) -> Result<Outcome<bool>, String> {
let trimmed = flag_name.trim();
if trimmed.is_empty()
|| trimmed.contains('/')
@@ -221,7 +221,7 @@ pub fn workspace_onboarding_flag_exists(
{
return Err("Invalid onboarding flag name".to_string());
}
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
workspace_dir.join(trimmed).is_file(),
"onboarding flag checked",
))
@@ -232,7 +232,7 @@ pub async fn workspace_onboarding_flag_set(
flag_name: Option<String>,
default_name: &str,
value: bool,
-) -> Result<RpcOutcome<bool>, String> {
+) -> Result<Outcome<bool>, String> {
let name = flag_name.unwrap_or_else(|| default_name.to_string());
let trimmed = name.trim();
if trimmed.is_empty()
@@ -258,16 +258,16 @@ pub async fn workspace_onboarding_flag_set(
std::fs::remove_file(&flag_path)
.map_err(|e| format!("Failed to remove onboarding flag: {e}"))?;
}
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
flag_path.is_file(),
"onboarding flag updated",
))
}
/// Returns whether the onboarding process has been marked as completed.
-pub async fn get_onboarding_completed() -> Result<RpcOutcome<bool>, String> {
+pub async fn get_onboarding_completed() -> Result<Outcome<bool>, String> {
let config = load_config_with_timeout().await?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
config.onboarding_completed,
"onboarding_completed read from config",
))
@@ -277,7 +277,7 @@ pub async fn get_onboarding_completed() -> Result<RpcOutcome<bool>, String> {
///
/// On a false→true transition, seeds the recurring morning-briefing
/// cron job via [`crate::cron::seed::seed_proactive_agents`].
-pub async fn set_onboarding_completed(value: bool) -> Result<RpcOutcome<bool>, String> {
+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 was_completed = config.onboarding_completed;
@@ -303,14 +303,14 @@ pub async fn set_onboarding_completed(value: bool) -> Result<RpcOutcome<bool>, S
);
}
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
config.onboarding_completed,
"onboarding_completed saved to config",
))
}
/// Returns the current dictation settings as a JSON object.
-pub async fn get_dictation_settings() -> Result<RpcOutcome<serde_json::Value>, String> {
+pub async fn get_dictation_settings() -> Result<Outcome<serde_json::Value>, String> {
let config = load_config_with_timeout().await?;
let result = json!({
"enabled": config.dictation.enabled,
@@ -320,7 +320,7 @@ pub async fn get_dictation_settings() -> Result<RpcOutcome<serde_json::Value>, S
"streaming": config.dictation.streaming,
"streaming_interval_ms": config.dictation.streaming_interval_ms,
});
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
result,
vec!["dictation settings read".to_string()],
))
@@ -329,7 +329,7 @@ pub async fn get_dictation_settings() -> Result<RpcOutcome<serde_json::Value>, S
/// Loads configuration, applies dictation settings updates, and saves it.
pub async fn load_and_apply_dictation_settings(
update: DictationSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
let mut config = load_config_with_timeout().await?;
if let Some(enabled) = update.enabled {
config.dictation.enabled = enabled;
@@ -363,7 +363,7 @@ pub async fn load_and_apply_dictation_settings(
}
config.save().await.map_err(|e| e.to_string())?;
let snapshot = snapshot_config_json(&config)?;
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
snapshot,
vec![format!(
"dictation settings saved to {}",
@@ -373,7 +373,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<RpcOutcome<serde_json::Value>, String> {
+pub async fn get_voice_server_settings() -> Result<Outcome<serde_json::Value>, String> {
let config = load_config_with_timeout().await?;
let result = json!({
"auto_start": config.voice_server.auto_start,
@@ -387,7 +387,7 @@ pub async fn get_voice_server_settings() -> Result<RpcOutcome<serde_json::Value>
"wake_word": config.voice_server.wake_word,
"stt_engine": config.voice_server.stt_engine,
});
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
result,
vec!["voice server settings read".to_string()],
))
@@ -396,7 +396,7 @@ pub async fn get_voice_server_settings() -> Result<RpcOutcome<serde_json::Value>
/// Loads configuration, applies voice server settings updates, and saves it.
pub async fn load_and_apply_voice_server_settings(
update: VoiceServerSettingsPatch,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+) -> Result<Outcome<serde_json::Value>, String> {
let mut config = load_config_with_timeout().await?;
if let Some(auto_start) = update.auto_start {
config.voice_server.auto_start = auto_start;
@@ -448,7 +448,7 @@ pub async fn load_and_apply_voice_server_settings(
}
config.save().await.map_err(|e| e.to_string())?;
let snapshot = snapshot_config_json(&config)?;
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
snapshot,
vec![format!(
"voice server settings saved to {}",
diff --git a/crates/openhuman-core/src/security/credentials/ops/credential.rs b/crates/openhuman-core/src/security/credentials/ops/credential.rs
index 081d4a749f..5cf8c38c54 100644
--- a/crates/openhuman-core/src/security/credentials/ops/credential.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/credential.rs
@@ -13,7 +13,7 @@ use serde::Deserialize;
use serde_json::{json, Value};
use crate::config::Config;
-use crate::rpc::RpcOutcome;
+use crate::core::Outcome;
use crate::security::credentials::jwt::decode_jwt_exp;
use crate::security::credentials::responses::AuthStateResponse;
use crate::security::credentials::session_support::{
@@ -180,7 +180,7 @@ fn resolve(request: SetCredentialRequest) -> Result<Resolved, String> {
pub async fn set_credential(
config: &Config,
request: SetCredentialRequest,
-) -> Result<RpcOutcome<AuthStateResponse>, String> {
+) -> Result<Outcome<AuthStateResponse>, String> {
let resolved = resolve(request)?;
let _mutation = CREDENTIAL_MUTATION_LOCK.lock().await;
@@ -206,7 +206,7 @@ pub async fn set_credential(
);
let state = build_session_state(config)?;
publish_credential_changed(CredentialKind::ApiKey.as_str());
- return Ok(RpcOutcome::single_log(state, "api key stored"));
+ return Ok(Outcome::single_log(state, "api key stored"));
}
let user_id = resolved
@@ -338,7 +338,7 @@ pub async fn set_credential(
let state = build_session_state(&effective_config)?;
publish_credential_changed(resolved.kind.as_str());
- Ok(RpcOutcome::new(state, logs))
+ Ok(Outcome::new(state, logs))
}
/// Remove the stored credential of `kind` — or every credential when `None`.
@@ -347,7 +347,7 @@ pub async fn set_credential(
pub async fn clear_credential(
config: &Config,
kind: Option<CredentialKind>,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let _mutation = CREDENTIAL_MUTATION_LOCK.lock().await;
let mut logs = Vec::new();
let mut removed_session = false;
@@ -457,7 +457,7 @@ pub async fn clear_credential(
if removed_session || removed_api_key {
publish_credential_changed("cleared");
}
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
json!({
"removed": removed_session || removed_api_key,
"removedSession": removed_session,
@@ -472,7 +472,7 @@ pub async fn clear_credential(
/// teardown, user-dir deactivation, service stop, rebind to the signed-out
/// workspace, and Sentry / identity clear. Callers hold
/// [`CREDENTIAL_MUTATION_LOCK`].
-async fn clear_session_credential(config: &Config) -> Result<RpcOutcome<bool>, String> {
+async fn clear_session_credential(config: &Config) -> Result<Outcome<bool>, String> {
let mut logs = Vec::new();
crate::cron::scheduler_gate::set_signed_out(true);
identity::clear_current_user();
@@ -519,7 +519,7 @@ async fn clear_session_credential(config: &Config) -> Result<RpcOutcome<bool>, S
sentry_scope::clear();
logs.push("session cleared".to_string());
- Ok(RpcOutcome::new(removed, logs))
+ Ok(Outcome::new(removed, logs))
}
/// Historical entry point: install a session (or local) credential from a
@@ -529,7 +529,7 @@ pub async fn store_session(
token: &str,
user_id: Option<String>,
user: Option<Value>,
-) -> Result<RpcOutcome<AuthStateResponse>, String> {
+) -> Result<Outcome<AuthStateResponse>, String> {
set_credential(
config,
SetCredentialRequest {
@@ -544,7 +544,7 @@ pub async fn store_session(
/// Historical entry point: sign the session out. Same as
/// [`clear_credential`] for the session kind.
-pub async fn clear_session(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn clear_session(config: &Config) -> Result<Outcome<Value>, String> {
clear_credential(config, Some(CredentialKind::Session)).await
}
diff --git a/crates/openhuman-core/src/tools/schemas/web_search.rs b/crates/openhuman-core/src/tools/schemas/web_search.rs
index ba3dd3619e..72eb26d300 100644
--- a/crates/openhuman-core/src/tools/schemas/web_search.rs
+++ b/crates/openhuman-core/src/tools/schemas/web_search.rs
@@ -76,7 +76,7 @@ async fn run_role_tool_with(
response.results.len(),
response.fallback_from.len()
)];
- crate::rpc::RpcOutcome::new(payload, log).into_cli_compatible_json()
+ crate::core::Outcome::new(payload, log).into_cli_compatible_json()
}
/// Refuse early, without loading the module, when nothing can serve the call.