Skip to content

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

fix: correct test module structure for memory RPC tests

Steven Enamakeld7b78658cb59
diff --git a/crates/openhuman-core/src/desktop/accessibility/helper/process.rs b/crates/openhuman-core/src/desktop/accessibility/helper/process.rs
index 704f2cfbf5..820c18544f 100644
--- a/crates/openhuman-core/src/desktop/accessibility/helper/process.rs
+++ b/crates/openhuman-core/src/desktop/accessibility/helper/process.rs
@@ -160,7 +160,7 @@ pub(crate) fn helper_send_receive(
/// Used for `show`, `hide`, and `quit` commands.
/// Only acquires UNIFIED_HELPER (for the stdin write) — never blocks on I/O.
#[cfg(target_os = "macos")]
-pub(super) fn helper_send_fire_and_forget(request: &serde_json::Value) -> Result<(), String> {
+pub(in crate::desktop::accessibility) fn helper_send_fire_and_forget(request: &serde_json::Value) -> Result<(), String> {
ensure_helper_running()?;
let mut guard = UNIFIED_HELPER
.lock()
@@ -181,7 +181,7 @@ pub(super) fn helper_send_fire_and_forget(request: &serde_json::Value) -> Result
/// Quit and clean up the helper process.
#[cfg(target_os = "macos")]
-pub(super) fn helper_quit() -> Result<(), String> {
+pub(in crate::desktop::accessibility) fn helper_quit() -> Result<(), String> {
// Drop the response channel first so the reader thread exits cleanly.
{
let mut rx_guard = RESPONSE_RX
diff --git a/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs b/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs
new file mode 100644
index 0000000000..669464436e
--- /dev/null
+++ b/crates/openhuman-core/src/inference/provider/ops/models/openrouter.rs
@@ -0,0 +1,78 @@
+//! OpenRouter detection and API-key validation.
+
+use super::*;
+
+pub fn is_openrouter_provider(
+ entry: &crate::config::schema::cloud_providers::CloudProviderCreds,
+) -> bool {
+ if entry.slug.eq_ignore_ascii_case("openrouter") {
+ return true;
+ }
+
+ reqwest::Url::parse(&entry.endpoint)
+ .ok()
+ .and_then(|url| url.host_str().map(|host| host.to_ascii_lowercase()))
+ .is_some_and(|host| host == "openrouter.ai" || host.ends_with(".openrouter.ai"))
+}
+
+pub(super) async fn validate_openrouter_api_key(
+ client: &reqwest::Client,
+ base: &str,
+ api_key: &str,
+) -> Result<(), String> {
+ if api_key.is_empty() {
+ return Err("OpenRouter API key is required before enabling the provider".to_string());
+ }
+
+ let key_url = format!("{}/key", base);
+ log::debug!("[providers][list_models] validating OpenRouter API key");
+ let response = client
+ .get(&key_url)
+ .header("Authorization", format!("Bearer {api_key}"))
+ .send()
+ .await
+ .map_err(|e| format!("[providers][list_models] OpenRouter key validation failed: {e}"))?;
+
+ let status = response.status();
+ let text = response.text().await.unwrap_or_default();
+ if !status.is_success() {
+ let sanitized = sanitize_api_error(&text);
+ let truncated = crate::util::truncate_with_ellipsis(&sanitized, 300);
+ log::debug!(
+ "[providers][list_models] OpenRouter key validation failed status={} body={}",
+ status.as_u16(),
+ truncated
+ );
+ return Err(format!(
+ "OpenRouter key validation returned {}: {}",
+ status.as_u16(),
+ truncated
+ ));
+ }
+
+ if let Ok(body) = serde_json::from_str::<serde_json::Value>(&text) {
+ if let Some(err_field) = body.get("error") {
+ let msg = err_field
+ .as_str()
+ .map(|s| s.to_string())
+ .or_else(|| {
+ err_field
+ .get("message")
+ .and_then(|m| m.as_str())
+ .map(|s| s.to_string())
+ })
+ .unwrap_or_else(|| err_field.to_string());
+ let sanitized = sanitize_api_error(&msg);
+ log::debug!(
+ "[providers][list_models] OpenRouter key validation returned error payload={}",
+ sanitized
+ );
+ return Err(format!(
+ "OpenRouter key validation returned error payload: {}",
+ sanitized
+ ));
+ }
+ }
+
+ Ok(())
+}
diff --git a/crates/openhuman-core/src/memory/read_rpc_tests_part_02_tests.rs b/crates/openhuman-core/src/memory/display_name_and_vault_rpc_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/memory/read_rpc_tests_part_02_tests.rs
rename to crates/openhuman-core/src/memory/display_name_and_vault_rpc_tests.rs
diff --git a/crates/openhuman-core/src/memory/read_rpc_tests_part_01_tests.rs b/crates/openhuman-core/src/memory/flush_now_rpc_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/memory/read_rpc_tests_part_01_tests.rs
rename to crates/openhuman-core/src/memory/flush_now_rpc_tests.rs
diff --git a/crates/openhuman-core/src/memory/read_rpc_tests.rs b/crates/openhuman-core/src/memory/read_rpc_tests.rs
index 8351dba3a9..e8caed3c21 100644
--- a/crates/openhuman-core/src/memory/read_rpc_tests.rs
+++ b/crates/openhuman-core/src/memory/read_rpc_tests.rs
@@ -20,7 +20,7 @@ fn test_config() -> (TempDir, Config) {
// ── tree-mode graph export (summaries + leaf chunks) ────────────────────
-#[path = "read_rpc_tests_part_01_tests.rs"]
-mod part_01_tests;
-#[path = "read_rpc_tests_part_02_tests.rs"]
-mod part_02_tests;
+#[path = "flush_now_rpc_tests.rs"]
+mod flush_now_rpc_tests;
+#[path = "display_name_and_vault_rpc_tests.rs"]
+mod display_name_and_vault_rpc_tests;