Skip to content

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

feat(rpc): add server module with auth, classify, and socketio support

Steven Enamakelb8724e00fda8
diff --git a/crates/openhuman-rpc/src/lib.rs b/crates/openhuman-rpc/src/lib.rs
index f46d1a2e3a..815bd4a777 100644
--- a/crates/openhuman-rpc/src/lib.rs
+++ b/crates/openhuman-rpc/src/lib.rs
@@ -1,8 +1,8 @@
//! OpenHuman's JSON-RPC protocol, on both sides of the wire.
//!
//! The core owns what a controller *is*: its schema, the
-//! [`Outcome`](crate::core_host::core::Outcome) it returns, and in-process
-//! dispatch ([`crate::core_host::core::invoke::invoke_method`]). This crate owns
+//! `Outcome` it returns, and in-process
+//! dispatch (`openhuman::core::invoke::invoke_method`). This crate owns
//! how that is exposed over JSON-RPC 2.0, and sits above the core:
//!
//! - [`RpcRequest`], [`RpcSuccess`], [`RpcFailure`] and [`RpcError`] are the
diff --git a/crates/openhuman-rpc/src/server/auth.rs b/crates/openhuman-rpc/src/server/auth.rs
index 56138ebc8b..3df2bd2c84 100644
--- a/crates/openhuman-rpc/src/server/auth.rs
+++ b/crates/openhuman-rpc/src/server/auth.rs
@@ -1,6 +1,6 @@
//! Bearer-token authentication for the core's HTTP API.
//!
-//! The token itself is owned by [`crate::core_host::core::auth`]; this module is
+//! The token itself is owned by `openhuman::core::auth`; this module is
//! the route policy on top of it.
//!
//! Endpoints exempt from auth (checked by [`rpc_auth_middleware`]):
diff --git a/crates/openhuman-rpc/src/server/classify.rs b/crates/openhuman-rpc/src/server/classify.rs
index 4b4a494a2c..fa36fa7bbd 100644
--- a/crates/openhuman-rpc/src/server/classify.rs
+++ b/crates/openhuman-rpc/src/server/classify.rs
@@ -2,7 +2,7 @@
//!
//! [`classify_failure`] is pure so the routing can be tested without a server.
//! Whether an error is a session expiry is core's call
-//! ([`crate::core_host::core::session_expiry`]); this module only decides how
+//! (`openhuman::core::session_expiry`); this module only decides how
//! loudly the transport reports it.
use crate::core_host::core::session_expiry::is_session_expired_error;
@@ -10,7 +10,7 @@ use crate::core_host::core::session_expiry::is_session_expired_error;
/// Returns `true` when the error is the wallet's "not configured yet" message.
///
/// Wallet-backed RPCs return
-/// [`crate::core_host::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE`] before
+/// `openhuman::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE` before
/// setup. That is expected user state, not an internal failure.
///
/// Matched against the shared wallet constant (exact equality) so a wording
diff --git a/crates/openhuman-rpc/src/server/cli.rs b/crates/openhuman-rpc/src/server/cli.rs
index 930937f965..7c821b7d5b 100644
--- a/crates/openhuman-rpc/src/server/cli.rs
+++ b/crates/openhuman-rpc/src/server/cli.rs
@@ -7,7 +7,7 @@ use crate::core_host::core::server_launcher::{install_server_launcher, ServeRequ
/// Install this crate's server as the one the core CLI's `run` / `serve`
/// subcommands start. Call once, before
-/// [`run_core_from_args`](crate::core_host::run_core_from_args); later calls are
+/// `run_core_from_args`; later calls are
/// no-ops.
pub fn install_cli_server() {
crate::http_host::ensure_registered();
diff --git a/crates/openhuman-rpc/src/server/dev_connect.rs b/crates/openhuman-rpc/src/server/dev_connect.rs
index b603781882..12c10be55d 100644
--- a/crates/openhuman-rpc/src/server/dev_connect.rs
+++ b/crates/openhuman-rpc/src/server/dev_connect.rs
@@ -1,7 +1,7 @@
//! `GET /dev/connect` — hand this core to a browser-hosted dev renderer.
//!
//! The desktop shell mints the RPC bearer per launch and keeps it in memory
-//! (see [`crate::core_host::core::auth`]), so nothing on disk lets a browser tab reach the
+//! (see `openhuman::core::auth`), so nothing on disk lets a browser tab reach the
//! running desktop core. This route closes that gap for development: it
//! redirects to a loopback Vite dev server's `/__dev-connect` page with the
//! RPC URL and bearer in the URL **fragment**, and that page seeds them into
diff --git a/crates/openhuman-rpc/src/server/http/live_voice.rs b/crates/openhuman-rpc/src/server/http/live_voice.rs
index d055bbc220..11a4754d1a 100644
--- a/crates/openhuman-rpc/src/server/http/live_voice.rs
+++ b/crates/openhuman-rpc/src/server/http/live_voice.rs
@@ -2,7 +2,7 @@
//!
//! Same upgrade guard as `/ws/dictation` (origin allowlist plus the core bearer
//! from the `Authorization` header or `?token=`); the session itself is
-//! `crate::core_host::voice::live::ws::handle_live_voice_ws`.
+//! `openhuman::voice::live::ws::handle_live_voice_ws`.
use std::sync::Arc;
diff --git a/crates/openhuman-rpc/src/server/mod.rs b/crates/openhuman-rpc/src/server/mod.rs
index 26cda682b7..26cb1dc9ec 100644
--- a/crates/openhuman-rpc/src/server/mod.rs
+++ b/crates/openhuman-rpc/src/server/mod.rs
@@ -2,17 +2,17 @@
//!
//! | Module | Owns |
//! |---|---|
-//! | `serve` | [`serve`]: bind the listener for a [`CoreRuntime`](crate::core_host::core::runtime::CoreRuntime) and run until shutdown |
+//! | `serve` | [`serve`]: bind the listener for a `CoreRuntime` and run until shutdown |
//! | `shims` | the `run_server*` entry points that build a runtime and serve it |
//! | `http` | the axum router and one module per route family |
-//! | `auth` | bearer-token route policy over `crate::core_host::core::auth` |
+//! | `auth` | bearer-token route policy over `openhuman::core::auth` |
//! | `classify` | how the `/rpc` handler reports a failed call |
//! | `socketio` | the Socket.IO live-event bridge and `rpc:request` |
//! | `dev_connect` | the debug-only `/dev/connect` handoff |
//! | `cli` | [`install_cli_server`], the launcher behind `openhuman-core run` |
//!
//! Dispatch itself is core's
-//! ([`invoke_method`](crate::core_host::core::invoke::invoke_method)); every
+//! (`invoke_method`); every
//! transport here resolves a method through it.
mod auth;
diff --git a/crates/openhuman-rpc/src/server/shims.rs b/crates/openhuman-rpc/src/server/shims.rs
index b84c74adfc..1c20a728b9 100644
--- a/crates/openhuman-rpc/src/server/shims.rs
+++ b/crates/openhuman-rpc/src/server/shims.rs
@@ -1,5 +1,5 @@
//! Server entry points kept for the hosts that predate
-//! [`CoreBuilder`](crate::core_host::core::runtime::CoreBuilder).
+//! `CoreBuilder`.
//!
//! Each `run_server*` function is a thin shim that composes a `CoreBuilder`
//! and calls [`serve`](super::serve::serve).
@@ -66,7 +66,7 @@ pub async fn run_server_embedded(
/// When the caller already holds the per-launch RPC bearer in memory (the
/// Tauri shell now that the core runs in-process — PR #1061), it should
/// pass `Some(token)` so the embedded server can seed its auth subsystem
-/// via `crate::core_host::core::auth::init_rpc_token_with_value` without ever
+/// via `openhuman::core::auth::init_rpc_token_with_value` without ever
/// reading `OPENHUMAN_CORE_TOKEN` from the process environment. Passing
/// `None` preserves the env-as-config fallback (CLI / docker / cloud).
pub async fn run_server_embedded_with_ready(
diff --git a/crates/openhuman-rpc/src/server/socketio.rs b/crates/openhuman-rpc/src/server/socketio.rs
index 7ef05c076b..fbc21b5d21 100644
--- a/crates/openhuman-rpc/src/server/socketio.rs
+++ b/crates/openhuman-rpc/src/server/socketio.rs
@@ -1,12 +1,12 @@
//! Socket.IO live-event bridge to the desktop shell.
//!
//! `spawn_web_channel_bridge` spawns one forwarding task per source. Domain
-//! broadcast channels: web-chat events (`crate::core_host::web_chat`), dictation hotkeys
-//! and transcription results (`crate::core_host::voice::dictation_listener`), overlay
-//! attention bubbles (`crate::core_host::desktop::overlay::subscribe_attention_events`,
+//! broadcast channels: web-chat events (`openhuman::web_chat`), dictation hotkeys
+//! and transcription results (`openhuman::voice::dictation_listener`), overlay
+//! attention bubbles (`openhuman::desktop::overlay::subscribe_attention_events`,
//! see `desktop/overlay/README.md`), core notifications
-//! (`crate::core_host::desktop::notifications`), and shell companion state
-//! (`COMPANION_STATE_BUS`). `DomainEvent`s read off `crate::core_host::core::bus::BUS`:
+//! (`openhuman::desktop::notifications`), and shell companion state
+//! (`COMPANION_STATE_BUS`). `DomainEvent`s read off `openhuman::core::bus::BUS`:
//! session expiry, MCP setup secret requests, memory sync and tree-build
//! progress, channel listener health, and active-workspace changes. Web-chat
//! events go to the initiating client's room and the `thread:<id>` room