Skip to content

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

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

Steven Enamakel6d9c27545a9e
diff --git a/crates/openhuman-tinyhumans/src/hosted/announcements/ops.rs b/crates/openhuman-tinyhumans/src/hosted/announcements/ops.rs
index a3e34e3b65..3d1d56dabf 100644
--- a/crates/openhuman-tinyhumans/src/hosted/announcements/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/announcements/ops.rs
@@ -30,7 +30,7 @@ fn is_not_found<T>(result: &Result<T, SdkError>) -> bool {
/// signal (TAURI-RUST-HW0, TAURI-RUST-KHX). Any other error (5xx, a response
/// that no longer matches the announcement schema, session expiry, …) still
/// propagates.
-pub async fn get_latest_announcement(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_latest_announcement(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let result = client
.sdk()
@@ -39,7 +39,7 @@ pub async fn get_latest_announcement(config: &Config) -> Result<RpcOutcome<Value
.await;
if is_not_found(&result) {
log::debug!("[hosted][announcements] 404 on GET /announcements/latest — no announcement");
- return Ok(RpcOutcome::single_log(
+ return Ok(Outcome::single_log(
Value::Null,
"no announcement available (404)",
));
@@ -47,7 +47,7 @@ pub async fn get_latest_announcement(config: &Config) -> Result<RpcOutcome<Value
let announcement = client.finish("GET /announcements/latest", result)?;
let data = serde_json::to_value(announcement)
.map_err(|e| format!("failed to encode announcement: {e}"))?;
- Ok(RpcOutcome::single_log(data, "latest announcement fetched"))
+ Ok(Outcome::single_log(data, "latest announcement fetched"))
}
#[cfg(test)]
diff --git a/crates/openhuman-tinyhumans/src/hosted/billing/ops.rs b/crates/openhuman-tinyhumans/src/hosted/billing/ops.rs
index ca737213f3..acea33f2e6 100644
--- a/crates/openhuman-tinyhumans/src/hosted/billing/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/billing/ops.rs
@@ -34,34 +34,34 @@ fn parse_enum<T: serde::de::DeserializeOwned>(field: &str, raw: &str) -> Result<
.map_err(|_| format!("unsupported {field}: {raw}"))
}
-pub async fn get_current_plan(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_current_plan(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /payments/stripe/currentPlan",
client.sdk().payments().get_current_plan().await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"current plan fetched from backend",
))
}
-pub async fn get_summary(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_summary(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /payments/summary",
client.sdk().payments().get_summary().await,
)?;
- Ok(RpcOutcome::single_log(data, "billing summary fetched"))
+ Ok(Outcome::single_log(data, "billing summary fetched"))
}
-pub async fn get_balance(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_balance(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /payments/credits/balance",
client.sdk().payments().get_credit_balance().await,
)?;
- Ok(RpcOutcome::single_log(data, "credit balance fetched"))
+ Ok(Outcome::single_log(data, "credit balance fetched"))
}
pub async fn get_transactions(
@@ -84,19 +84,16 @@ pub async fn get_transactions(
.list_credit_transactions(&query)
.await,
)?;
- Ok(RpcOutcome::single_log(data, "credit transactions fetched"))
+ Ok(Outcome::single_log(data, "credit transactions fetched"))
}
-pub async fn get_auto_recharge(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_auto_recharge(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /payments/credits/auto-recharge",
client.sdk().payments().get_auto_recharge().await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "auto recharge settings fetched",
- ))
+ Ok(Outcome::single_log(data, "auto recharge settings fetched"))
}
/// `PATCH /payments/credits/auto-recharge`.
@@ -108,7 +105,7 @@ pub async fn get_auto_recharge(config: &Config) -> Result<RpcOutcome<Value>, Str
pub async fn update_auto_recharge(
config: &Config,
payload: Value,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish(
"PATCH /payments/credits/auto-recharge",
@@ -124,22 +121,19 @@ pub async fn update_auto_recharge(
)
.await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "auto recharge settings updated",
- ))
+ Ok(Outcome::single_log(data, "auto recharge settings updated"))
}
-pub async fn get_cards(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_cards(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /payments/credits/auto-recharge/cards",
client.sdk().payments().list_auto_recharge_cards().await,
)?;
- Ok(RpcOutcome::single_log(data, "saved cards fetched"))
+ Ok(Outcome::single_log(data, "saved cards fetched"))
}
-pub async fn create_setup_intent(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn create_setup_intent(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"POST /payments/credits/auto-recharge/cards/setup-intent",
@@ -149,7 +143,7 @@ pub async fn create_setup_intent(config: &Config) -> Result<RpcOutcome<Value>, S
.create_auto_recharge_card_setup_intent()
.await,
)?;
- Ok(RpcOutcome::single_log(data, "setup intent created"))
+ Ok(Outcome::single_log(data, "setup intent created"))
}
pub async fn update_card(
@@ -175,7 +169,7 @@ pub async fn update_card(
.update_auto_recharge_card(payment_method_id, &UpdateAutoRechargeCardRequest { fields })
.await,
)?;
- Ok(RpcOutcome::single_log(data, "saved card updated"))
+ Ok(Outcome::single_log(data, "saved card updated"))
}
pub async fn delete_card(
@@ -195,13 +189,13 @@ pub async fn delete_card(
.delete_auto_recharge_card(payment_method_id)
.await,
)?;
- Ok(RpcOutcome::single_log(data, "saved card deleted"))
+ Ok(Outcome::single_log(data, "saved card deleted"))
}
/// `POST /payments/stripe/purchasePlan`. `plan` is one of the SDK's
/// [`BillingPlan`] values (`BASIC_MONTHLY`, `BASIC_YEARLY`, `PRO_MONTHLY`,
/// `PRO_YEARLY` — the frontend's `PlanIdentifier`).
-pub async fn purchase_plan(config: &Config, plan: &str) -> Result<RpcOutcome<Value>, String> {
+pub async fn purchase_plan(config: &Config, plan: &str) -> Result<Outcome<Value>, String> {
let plan = plan.trim();
if plan.is_empty() {
return Err("plan is required".to_string());
@@ -215,22 +209,16 @@ pub async fn purchase_plan(config: &Config, plan: &str) -> Result<RpcOutcome<Val
"POST /payments/stripe/purchasePlan",
client.sdk().payments().purchase_stripe_plan(&request).await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "plan purchase session created",
- ))
+ Ok(Outcome::single_log(data, "plan purchase session created"))
}
-pub async fn create_portal_session(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn create_portal_session(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"POST /payments/stripe/portal",
client.sdk().payments().create_stripe_portal_session().await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "customer portal session created",
- ))
+ Ok(Outcome::single_log(data, "customer portal session created"))
}
fn default_gateway() -> String {
@@ -271,7 +259,7 @@ pub async fn top_up_credits(
"POST /payments/credits/top-up",
client.sdk().payments().create_credit_top_up(&request).await,
)?;
- Ok(RpcOutcome::single_log(data, "credit top-up initiated"))
+ Ok(Outcome::single_log(data, "credit top-up initiated"))
}
/// Create a Coinbase Commerce charge (the "payment link" for crypto / annual billing).
@@ -306,10 +294,7 @@ pub async fn create_coinbase_charge(
.create_coinbase_charge(&request)
.await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "Coinbase payment link created",
- ))
+ Ok(Outcome::single_log(data, "Coinbase payment link created"))
}
// ── Coupon operations ──────────────────────────────────────────────────────
@@ -329,18 +314,18 @@ pub async fn redeem_coupon(config: &Config, code: &str) -> Result<Outcome<Value>
"POST /coupons/redeem",
client.sdk().coupons().redeem_coupon(&request).await,
)?;
- Ok(RpcOutcome::single_log(data, "coupon redeemed"))
+ Ok(Outcome::single_log(data, "coupon redeemed"))
}
/// List coupons redeemed by the current user.
/// Maps to `GET /coupons/me`.
-pub async fn get_user_coupons(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_user_coupons(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /coupons/me",
client.sdk().coupons().list_my_coupons().await,
)?;
- Ok(RpcOutcome::single_log(data, "user coupons fetched"))
+ Ok(Outcome::single_log(data, "user coupons fetched"))
}
#[cfg(test)]
diff --git a/crates/openhuman-tinyhumans/src/hosted/channel_link/managed.rs b/crates/openhuman-tinyhumans/src/hosted/channel_link/managed.rs
index 13cc01c4c6..e07bea3cf2 100644
--- a/crates/openhuman-tinyhumans/src/hosted/channel_link/managed.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/channel_link/managed.rs
@@ -12,7 +12,7 @@ use tinychannels_bus::controllers::{
use openhuman_core::config::app_env::{app_env_from_env, is_staging_app_env};
use openhuman_core::config::Config;
-use openhuman_core::rpc::RpcOutcome;
+use openhuman_core::core::Outcome;
use openhuman_core::security::credentials;
use super::ops::link_token_payload;
@@ -109,7 +109,7 @@ async fn store_managed_marker(
/// Step 1: create a Telegram link token and return the deep link URL.
pub async fn telegram_login_start(
config: &Config,
-) -> Result<RpcOutcome<TelegramLoginStartResult>, String> {
+) -> Result<Outcome<TelegramLoginStartResult>, String> {
let client = HostedClient::from_config(config)?;
log::debug!("[telegram-login] creating channel link token");
let payload = link_token_payload(&client, "telegram")
@@ -122,7 +122,7 @@ pub async fn telegram_login_start(
"[telegram-login] link token created, length={}",
link_token.len()
);
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
TelegramLoginStartResult {
link_token,
telegram_url,
@@ -138,7 +138,7 @@ pub async fn telegram_login_start(
pub async fn telegram_login_check(
config: &Config,
_link_token: &str,
-) -> Result<RpcOutcome<TelegramLoginCheckResult>, String> {
+) -> Result<Outcome<TelegramLoginCheckResult>, String> {
let client = HostedClient::from_config(config)?;
log::debug!("[telegram-login] checking if user profile has telegramId via GET /auth/me");
let profile = fetch_profile(&client)
@@ -153,7 +153,7 @@ pub async fn telegram_login_check(
.map_err(|e| format!("failed to store managed channel credentials: {e}"))?;
log::info!("[telegram-login] Telegram managed DM linked; credentials stored as {key}");
}
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
TelegramLoginCheckResult {
linked,
details: linked.then_some(profile),
@@ -166,7 +166,7 @@ pub async fn telegram_login_check(
/// `!start <token>`.
pub async fn discord_link_start(
config: &Config,
-) -> Result<RpcOutcome<DiscordLinkStartResult>, String> {
+) -> Result<Outcome<DiscordLinkStartResult>, String> {
let client = HostedClient::from_config(config)?;
log::debug!("[discord-link] creating channel link token");
let payload = link_token_payload(&client, "discord")
@@ -179,7 +179,7 @@ pub async fn discord_link_start(
"[discord-link] link token created, length={}",
link_token.len()
);
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
DiscordLinkStartResult {
link_token,
instructions,
@@ -193,7 +193,7 @@ pub async fn discord_link_start(
pub async fn discord_link_check(
config: &Config,
_link_token: &str,
-) -> Result<RpcOutcome<DiscordLinkCheckResult>, String> {
+) -> Result<Outcome<DiscordLinkCheckResult>, String> {
let client = HostedClient::from_config(config)?;
log::debug!("[discord-link] checking if user profile has discordId via GET /auth/me");
let profile = fetch_profile(&client)
@@ -208,7 +208,7 @@ pub async fn discord_link_check(
.map_err(|e| format!("failed to store Discord managed channel credentials: {e}"))?;
log::info!("[discord-link] Discord managed DM linked; credentials stored as {key}");
}
- Ok(RpcOutcome::new(
+ Ok(Outcome::new(
DiscordLinkCheckResult {
linked,
details: linked.then_some(profile),
diff --git a/crates/openhuman-tinyhumans/src/hosted/channel_link/ops.rs b/crates/openhuman-tinyhumans/src/hosted/channel_link/ops.rs
index 4603ffbf32..5f55fc5729 100644
--- a/crates/openhuman-tinyhumans/src/hosted/channel_link/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/channel_link/ops.rs
@@ -7,7 +7,7 @@
use serde_json::Value;
use openhuman_core::config::Config;
-use openhuman_core::rpc::RpcOutcome;
+use openhuman_core::core::Outcome;
use crate::hosted::client::HostedClient;
@@ -39,14 +39,11 @@ pub(super) async fn link_token_payload(
pub async fn auth_create_channel_link_token(
config: &Config,
channel: &str,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let channel = normalize_channel(channel)?;
let client = HostedClient::from_config(config)?;
let payload = link_token_payload(&client, &channel).await?;
- Ok(RpcOutcome::single_log(
- payload,
- "channel link token created",
- ))
+ Ok(Outcome::single_log(payload, "channel link token created"))
}
#[cfg(test)]
diff --git a/crates/openhuman-tinyhumans/src/hosted/channel_link/schemas.rs b/crates/openhuman-tinyhumans/src/hosted/channel_link/schemas.rs
index d66f60f40d..2e4309ba34 100644
--- a/crates/openhuman-tinyhumans/src/hosted/channel_link/schemas.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/channel_link/schemas.rs
@@ -4,8 +4,8 @@ use serde_json::{Map, Value};
use openhuman_core::config::rpc as config_rpc;
use openhuman_core::core::all::{ControllerFuture, RegisteredController};
+use openhuman_core::core::Outcome;
use openhuman_core::core::{ControllerSchema, FieldSchema, TypeSchema};
-use openhuman_core::rpc::RpcOutcome;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -154,7 +154,7 @@ fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result
/// Channel results serialize bare (no logs), exactly as the core's channel
/// handlers answered.
-fn to_json<T: serde::Serialize>(outcome: RpcOutcome<T>) -> Result<Value, String> {
+fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {
outcome.into_cli_compatible_json()
}
diff --git a/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs b/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs
index d138f42577..547f062076 100644
--- a/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs
@@ -9,7 +9,7 @@ use tinyhumans_sdk::api::types::IntegrationTokenRequest;
use super::handoff::decrypt_handoff_blob;
use openhuman_core::config::Config;
-use openhuman_core::rpc::RpcOutcome;
+use openhuman_core::core::Outcome;
use super::types::{IntegrationSummary, IntegrationTokensHandoff};
use crate::hosted::client::HostedClient;
@@ -43,7 +43,7 @@ pub async fn oauth_connect(
skill_id: Option<&str>,
response_type: Option<&str>,
encryption_mode: Option<&str>,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let provider = require_provider(provider)?;
let client = HostedClient::from_config(config)?;
let query = [
@@ -67,14 +67,14 @@ pub async fn oauth_connect(
.and_then(Value::as_str)
.filter(|state| !state.is_empty())
.ok_or_else(|| "auth connect request: missing state".to_string())?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
json!({ "oauthUrl": oauth_url, "state": state }),
"oauth connect URL ready",
))
}
/// `GET /auth/integrations` — the user's active integrations.
-pub async fn oauth_list_integrations(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn oauth_list_integrations(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let value = client.finish_value(
"GET /auth/integrations",
@@ -86,7 +86,7 @@ pub async fn oauth_list_integrations(config: &Config) -> Result<RpcOutcome<Value
.unwrap_or_else(|| value.clone());
let list: Vec<IntegrationSummary> = serde_json::from_value(integrations)
.map_err(|e| format!("parse integrations response: {e}"))?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
serde_json::to_value(&list).map_err(|e| e.to_string())?,
"integrations listed",
))
@@ -100,7 +100,7 @@ pub async fn oauth_fetch_integration_tokens(
config: &Config,
integration_id: &str,
encryption_key: &str,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let id = require_integration_id(integration_id)?;
let client = HostedClient::from_config(config)?;
let request = IntegrationTokenRequest {
@@ -122,7 +122,7 @@ pub async fn oauth_fetch_integration_tokens(
.map_err(|e| format!("integration tokens handoff: {e:#}"))?;
let tokens: IntegrationTokensHandoff =
serde_json::from_str(&plaintext).map_err(|e| format!("parse decrypted token JSON: {e}"))?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
serde_json::to_value(&tokens).map_err(|e| e.to_string())?,
"integration tokens retrieved",
))
@@ -132,7 +132,7 @@ pub async fn oauth_fetch_integration_tokens(
pub async fn oauth_revoke_integration(
config: &Config,
integration_id: &str,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let id = integration_id.trim();
if id.is_empty() {
return Err("integration id is required".to_string());
@@ -142,7 +142,7 @@ pub async fn oauth_revoke_integration(
"DELETE /auth/integrations/{integrationId}",
client.sdk().auth().delete_integration(id).await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
json!({ "revoked": true, "integrationId": integration_id }),
"integration revoked",
))
diff --git a/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs b/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs
index 5eb958261d..51d2fafed3 100644
--- a/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs
@@ -4,8 +4,8 @@ use serde_json::{Map, Value};
use openhuman_core::config::rpc as config_rpc;
use openhuman_core::core::all::{ControllerFuture, RegisteredController};
+use openhuman_core::core::Outcome;
use openhuman_core::core::{ControllerSchema, FieldSchema, TypeSchema};
-use openhuman_core::rpc::RpcOutcome;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -199,7 +199,7 @@ fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {
}
}
-fn to_json<T: serde::Serialize>(outcome: RpcOutcome<T>) -> Result<Value, String> {
+fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {
outcome.into_cli_compatible_json()
}
diff --git a/crates/openhuman-tinyhumans/src/hosted/referral/ops.rs b/crates/openhuman-tinyhumans/src/hosted/referral/ops.rs
index 2b81b31e56..d0ee9ff4be 100644
--- a/crates/openhuman-tinyhumans/src/hosted/referral/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/referral/ops.rs
@@ -12,13 +12,13 @@ use openhuman_core::core::Outcome;
use crate::hosted::client::HostedClient;
-pub async fn get_stats(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_stats(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /referral/stats",
client.sdk().referral().get_referral_stats().await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"referral stats fetched from backend GET /referral/stats",
))
@@ -28,7 +28,7 @@ pub async fn claim_referral(
config: &Config,
code: &str,
device_fingerprint: Option<&str>,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let request = ClaimReferralRequest {
code: code.trim().to_string(),
@@ -41,7 +41,7 @@ pub async fn claim_referral(
"POST /referral/claim",
client.sdk().referral().claim_referral(&request).await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"referral claim accepted by backend POST /referral/claim",
))
diff --git a/crates/openhuman-tinyhumans/src/hosted/team/ops.rs b/crates/openhuman-tinyhumans/src/hosted/team/ops.rs
index e46e7ee68c..f08f953a07 100644
--- a/crates/openhuman-tinyhumans/src/hosted/team/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/team/ops.rs
@@ -18,8 +18,8 @@ use tinyhumans_sdk::api::types::{CodeRequest, CreateTeamInviteRequest};
use crate::backend::url::effective_backend_api_url;
use openhuman_core::backend::BackendClient;
use openhuman_core::config::Config;
+use openhuman_core::core::Outcome;
use openhuman_core::integrations::client::budget_gate;
-use openhuman_core::rpc::RpcOutcome;
use crate::hosted::client::HostedClient;
@@ -46,7 +46,7 @@ fn clamp_u32(value: Option<u64>, field: &str) -> Result<Option<u32>, String> {
/// The credential is resolved first: a user with no TinyHumans account gets
/// the core's `BACKEND_UNAVAILABLE:` sentinel without a request and without
/// opening a backoff streak (Sentry 36649).
-pub async fn get_usage(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_usage(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let backend_key = effective_backend_api_url(&config.api_url);
budget_gate::usage_with_failure_backoff(&backend_key, || async {
@@ -65,16 +65,16 @@ pub async fn list_members(config: &Config, team_id: &str) -> Result<Outcome<Valu
"GET /teams/{teamId}/members",
client.sdk().teams().list_members(&team_id).await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"team members fetched from backend",
))
}
-pub async fn list_teams(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn list_teams(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value("GET /teams", client.sdk().teams().list_teams().await)?;
- Ok(RpcOutcome::single_log(data, "teams fetched from backend"))
+ Ok(Outcome::single_log(data, "teams fetched from backend"))
}
pub async fn get_team(config: &Config, team_id: &str) -> Result<Outcome<Value>, String> {
@@ -84,7 +84,7 @@ pub async fn get_team(config: &Config, team_id: &str) -> Result<Outcome<Value>,
"GET /teams/{teamId}",
client.sdk().teams().get_team(&team_id).await,
)?;
- Ok(RpcOutcome::single_log(data, "team fetched from backend"))
+ Ok(Outcome::single_log(data, "team fetched from backend"))
}
/// `POST /teams` through the core's `BackendClient::authed_json`.
@@ -93,7 +93,7 @@ pub async fn get_team(config: &Config, team_id: &str) -> Result<Outcome<Value>,
/// and its generated public-route registry has no entry for it (teams were
/// folded into users on the backend). Until the route is added to the SDK
/// upstream, or the RPC is retired, it stays on the pre-SDK path unchanged.
-pub async fn create_team(config: &Config, name: &str) -> Result<RpcOutcome<Value>, String> {
+pub async fn create_team(config: &Config, name: &str) -> Result<Outcome<Value>, String> {
let trimmed = name.trim();
if trimmed.is_empty() {
return Err("name is required".to_string());
@@ -146,15 +146,15 @@ pub async fn update_team(
.update_team(&team_id, &Value::Object(body))
.await,
)?;
- Ok(RpcOutcome::single_log(data, "team updated via backend"))
+ Ok(Outcome::single_log(data, "team updated via backend"))
}
/// `DELETE /teams/{teamId}` on the pre-SDK path — see [`create_team`].
-pub async fn delete_team(config: &Config, team_id: &str) -> Result<RpcOutcome<Value>, String> {
+pub async fn delete_team(config: &Config, team_id: &str) -> Result<Outcome<Value>, String> {
let team_id = normalize_id(team_id, "teamId")?;
let path = format!("/teams/{}", tinyhumans_sdk::enc(&team_id));
let data = legacy_authed_value(config, Method::DELETE, &path, None).await?;
- Ok(RpcOutcome::single_log(data, "team deleted via backend"))
+ Ok(Outcome::single_log(data, "team deleted via backend"))
}
pub async fn switch_team(config: &Config, team_id: &str) -> Result<Outcome<Value>, String> {
@@ -164,7 +164,7 @@ pub async fn switch_team(config: &Config, team_id: &str) -> Result<Outcome<Value
"POST /teams/{teamId}/switch",
client.sdk().teams().switch_team(&team_id).await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"active team switched via backend",
))
@@ -177,7 +177,7 @@ pub async fn leave_team(config: &Config, team_id: &str) -> Result<Outcome<Value>
"POST /teams/{teamId}/leave",
client.sdk().teams().leave_team(&team_id).await,
)?;
- Ok(RpcOutcome::single_log(data, "team left via backend"))
+ Ok(Outcome::single_log(data, "team left via backend"))
}
pub async fn join_team(config: &Config, code: &str) -> Result<Outcome<Value>, String> {
@@ -193,7 +193,7 @@ pub async fn join_team(config: &Config, code: &str) -> Result<Outcome<Value>, St
"POST /teams/join",
client.sdk().teams().join_team(&request).await,
)?;
- Ok(RpcOutcome::single_log(data, "team joined via backend"))
+ Ok(Outcome::single_log(data, "team joined via backend"))
}
pub async fn create_invite(
@@ -212,10 +212,7 @@ pub async fn create_invite(
"POST /teams/{teamId}/invites",
client.sdk().teams().create_invite(&team_id, &request).await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "team invite created via backend",
- ))
+ Ok(Outcome::single_log(data, "team invite created via backend"))
}
pub async fn remove_member(
@@ -230,10 +227,7 @@ pub async fn remove_member(
"DELETE /teams/{teamId}/members/{userId}",
client.sdk().teams().remove_member(&team_id, &user_id).await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "team member removed via backend",
- ))
+ Ok(Outcome::single_log(data, "team member removed via backend"))
}
pub async fn change_member_role(
@@ -254,21 +248,21 @@ pub async fn change_member_role(
.update_member_role(&team_id, &user_id, &json!({ "role": role }))
.await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"team member role updated via backend",
))
}
/// List all active invites for a team (`GET /teams/:teamId/invites`).
-pub async fn list_invites(config: &Config, team_id: &str) -> Result<RpcOutcome<Value>, String> {
+pub async fn list_invites(config: &Config, team_id: &str) -> Result<Outcome<Value>, String> {
let team_id = normalize_id(team_id, "teamId")?;
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /teams/{teamId}/invites",
client.sdk().teams().list_invites(&team_id).await,
)?;
- Ok(RpcOutcome::single_log(
+ Ok(Outcome::single_log(
data,
"team invites listed from backend",
))
@@ -291,10 +285,7 @@ pub async fn revoke_invite(
.revoke_invite(&team_id, &invite_id)
.await,
)?;
- Ok(RpcOutcome::single_log(
- data,
- "team invite revoked via backend",
- ))
+ Ok(Outcome::single_log(data, "team invite revoked via backend"))
}
#[cfg(test)]
diff --git a/crates/openhuman-tinyhumans/src/hosted/webhooks/ops.rs b/crates/openhuman-tinyhumans/src/hosted/webhooks/ops.rs
index e0f9868dab..db9c5eeaeb 100644
--- a/crates/openhuman-tinyhumans/src/hosted/webhooks/ops.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/webhooks/ops.rs
@@ -8,7 +8,7 @@ use serde_json::Value;
use tinyhumans_sdk::api::webhooks::{CreateWebhookTunnelRequest, UpdateWebhookTunnelRequest};
use openhuman_core::config::Config;
-use openhuman_core::rpc::RpcOutcome;
+use openhuman_core::core::Outcome;
use crate::hosted::client::HostedClient;
@@ -21,13 +21,13 @@ fn require_id(id: &str) -> Result<&str, String> {
}
/// `GET /webhooks/core` — the user's tunnels.
-pub async fn list_tunnels(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn list_tunnels(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /webhooks/core",
client.sdk().webhooks().list_tunnels().await,
)?;
- Ok(RpcOutcome::single_log(data, "webhook tunnels fetched"))
+ Ok(Outcome::single_log(data, "webhook tunnels fetched"))
}
/// `POST /webhooks/core`. `name` is trimmed and required; a blank
@@ -36,7 +36,7 @@ pub async fn create_tunnel(
config: &Config,
name: &str,
description: Option<String>,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let name = name.trim();
if name.is_empty() {
return Err("name is required".to_string());
@@ -52,18 +52,18 @@ pub async fn create_tunnel(
"POST /webhooks/core",
client.sdk().webhooks().create_tunnel(&request).await,
)?;
- Ok(RpcOutcome::single_log(data, "webhook tunnel created"))
+ Ok(Outcome::single_log(data, "webhook tunnel created"))
}
/// `GET /webhooks/core/{id}`.
-pub async fn get_tunnel(config: &Config, id: &str) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_tunnel(config: &Config, id: &str) -> Result<Outcome<Value>, String> {
let id = require_id(id)?;
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /webhooks/core/{id}",
client.sdk().webhooks().get_tunnel(id).await,
)?;
- Ok(RpcOutcome::single_log(data, "webhook tunnel fetched"))
+ Ok(Outcome::single_log(data, "webhook tunnel fetched"))
}
/// `PATCH /webhooks/core/{id}`; omitted fields are left unchanged.
@@ -71,35 +71,35 @@ pub async fn update_tunnel(
config: &Config,
id: &str,
request: UpdateWebhookTunnelRequest,
-) -> Result<RpcOutcome<Value>, String> {
+) -> Result<Outcome<Value>, String> {
let id = require_id(id)?;
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"PATCH /webhooks/core/{id}",
client.sdk().webhooks().update_tunnel(id, &request).await,
)?;
- Ok(RpcOutcome::single_log(data, "webhook tunnel updated"))
+ Ok(Outcome::single_log(data, "webhook tunnel updated"))
}
/// `DELETE /webhooks/core/{id}`.
-pub async fn delete_tunnel(config: &Config, id: &str) -> Result<RpcOutcome<Value>, String> {
+pub async fn delete_tunnel(config: &Config, id: &str) -> Result<Outcome<Value>, String> {
let id = require_id(id)?;
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"DELETE /webhooks/core/{id}",
client.sdk().webhooks().delete_tunnel(id).await,
)?;
- Ok(RpcOutcome::single_log(data, "webhook tunnel deleted"))
+ Ok(Outcome::single_log(data, "webhook tunnel deleted"))
}
/// `GET /webhooks/core/bandwidth` — the remaining bandwidth budget.
-pub async fn get_bandwidth(config: &Config) -> Result<RpcOutcome<Value>, String> {
+pub async fn get_bandwidth(config: &Config) -> Result<Outcome<Value>, String> {
let client = HostedClient::from_config(config)?;
let data = client.finish_value(
"GET /webhooks/core/bandwidth",
client.sdk().webhooks().get_bandwidth().await,
)?;
- Ok(RpcOutcome::single_log(data, "webhook bandwidth fetched"))
+ Ok(Outcome::single_log(data, "webhook bandwidth fetched"))
}
#[cfg(test)]
diff --git a/crates/openhuman-tinyhumans/src/hosted/webhooks/schemas.rs b/crates/openhuman-tinyhumans/src/hosted/webhooks/schemas.rs
index 7da5ac36dc..f8cc5b8ab9 100644
--- a/crates/openhuman-tinyhumans/src/hosted/webhooks/schemas.rs
+++ b/crates/openhuman-tinyhumans/src/hosted/webhooks/schemas.rs
@@ -5,8 +5,8 @@ use tinyhumans_sdk::api::webhooks::UpdateWebhookTunnelRequest;
use openhuman_core::config::rpc as config_rpc;
use openhuman_core::core::all::{ControllerFuture, RegisteredController};
+use openhuman_core::core::Outcome;
use openhuman_core::core::{ControllerSchema, FieldSchema, TypeSchema};
-use openhuman_core::rpc::RpcOutcome;
#[derive(Debug, Deserialize)]
struct WebhookCreateTunnelParams {
@@ -240,7 +240,7 @@ fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result
serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))
}
-fn to_json<T: serde::Serialize>(outcome: RpcOutcome<T>) -> Result<Value, String> {
+fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {
outcome.into_cli_compatible_json()
}