The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(core): extract inline test modules into separate files
Steven Enamakelf65121fa980c
diff --git a/crates/openhuman-app/src/ptt_hotkeys_tests.rs b/crates/openhuman-app/src/ptt_hotkeys_tests.rsindex 5a564ceb21..32b5e0404d 100644--- a/crates/openhuman-app/src/ptt_hotkeys_tests.rs+++ b/crates/openhuman-app/src/ptt_hotkeys_tests.rs@@ -67,20 +67,6 @@ fn malformed_shortcut_with_empty_tokens_is_rejected() {Err(PttError::EmptyShortcut));}-}--/// Returns `Some(conflicting_variant)` if any expanded PTT variant overlaps-/// any expanded dictation variant. Comparison is case-insensitive.-pub(crate) fn first_conflict_with(ptt: &[String], dictation: &[String]) -> Option<String> {-for p in ptt {- let p_lc = p.to_ascii_lowercase();- for d in dictation {- if d.to_ascii_lowercase() == p_lc {- return Some(p.clone());- }- }-}-None// -- from conflict_tests --@@ -145,3 +131,4 @@ fn cas_false_to_true_succeeds_then_repeat_fails() {"stale swap should return false");}+diff --git a/crates/openhuman-core/src/api/socket.rs b/crates/openhuman-core/src/api/socket.rsindex c85e447109..4e309036e0 100644--- a/crates/openhuman-core/src/api/socket.rs+++ b/crates/openhuman-core/src/api/socket.rs@@ -25,51 +25,5 @@ pub fn websocket_url(http_or_https_base: &str) -> String {}#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn converts_https_to_wss() {- let url = websocket_url("https://api.tinyhumans.ai");- assert_eq!(- url,- "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"- );- }-- #[test]- fn converts_http_to_ws() {- let url = websocket_url("http://localhost:3000");- assert_eq!(- url,- "ws://localhost:3000/socket.io/?EIO=4&transport=websocket"- );- }-- #[test]- fn passes_through_unknown_scheme() {- let url = websocket_url("ftp://example.com");- assert_eq!(- url,- "ftp://example.com/socket.io/?EIO=4&transport=websocket"- );- }-- #[test]- fn strips_trailing_slash() {- let url = websocket_url("https://api.tinyhumans.ai/");- assert_eq!(- url,- "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"- );- }-- #[test]- fn strips_multiple_trailing_slashes() {- let url = websocket_url("https://api.tinyhumans.ai///");- assert_eq!(- url,- "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"- );- }-}+#[path = "socket_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/api/socket_tests.rs b/crates/openhuman-core/src/api/socket_tests.rsnew file mode 100644index 0000000000..9d5c8daf93--- /dev/null+++ b/crates/openhuman-core/src/api/socket_tests.rs@@ -0,0 +1,46 @@+use super::*;++#[test]+fn converts_https_to_wss() {+ let url = websocket_url("https://api.tinyhumans.ai");+ assert_eq!(+ url,+ "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"+ );+}++#[test]+fn converts_http_to_ws() {+ let url = websocket_url("http://localhost:3000");+ assert_eq!(+ url,+ "ws://localhost:3000/socket.io/?EIO=4&transport=websocket"+ );+}++#[test]+fn passes_through_unknown_scheme() {+ let url = websocket_url("ftp://example.com");+ assert_eq!(+ url,+ "ftp://example.com/socket.io/?EIO=4&transport=websocket"+ );+}++#[test]+fn strips_trailing_slash() {+ let url = websocket_url("https://api.tinyhumans.ai/");+ assert_eq!(+ url,+ "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"+ );+}++#[test]+fn strips_multiple_trailing_slashes() {+ let url = websocket_url("https://api.tinyhumans.ai///");+ assert_eq!(+ url,+ "wss://api.tinyhumans.ai/socket.io/?EIO=4&transport=websocket"+ );+}diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rsindex eaac93ac42..d20d3e14e0 100644--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs@@ -29,17 +29,11 @@ pub(super) fn handle_sync(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let config = config_rpc::load_config_with_timeout().await?;let connection_id = read_required_non_empty(¶ms, "connection_id")?;- let reason = read_optional_reason(¶ms)?;+ let reason = read_optional::<String>(¶ms, "reason")?;to_json(ops::composio_sync(&config, &connection_id, reason).await?)})}-/// Local alias so this file needs only one extra import — `reason` is the-/// only optional-param read outside the connection-id/toolkit path here.-fn read_optional_reason(params: &Map<String, Value>) -> Result<Option<String>, String> {- super::util::read_optional::<String>(params, "reason")-}-pub(super) fn handle_get_user_scopes(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let toolkit = match read_required_non_empty(¶ms, "toolkit") {diff --git a/crates/openhuman-core/src/memory/guard/test_support.rs b/crates/openhuman-core/src/memory/guard/test_support.rsindex dbc81c3000..715cb75900 100644--- a/crates/openhuman-core/src/memory/guard/test_support.rs+++ b/crates/openhuman-core/src/memory/guard/test_support.rs@@ -9,6 +9,13 @@#![cfg(test)]-include!("test_support_part_01.rs");-include!("test_support_part_02.rs");-include!("test_support_part_03.rs");+mod fixtures;++mod core_and_docs_impls;+mod provider_and_sync_impls;+mod retrieval_and_ingest_impls;++pub use fixtures::{+ document, embedded_policy, entry, export_record, external_policy, guarded, guarded_with,+ namespace_hit, namespace_summary, Call, RecordingProvider,+};diff --git a/crates/openhuman-core/src/threads/schemas/schema_defs.rs b/crates/openhuman-core/src/threads/schemas/schema_defs.rsnew file mode 100644index 0000000000..c46de3f052--- /dev/null+++ b/crates/openhuman-core/src/threads/schemas/schema_defs.rs@@ -0,0 +1,454 @@+//! Per-function [`ControllerSchema`] definitions for the `threads` namespace.++use crate::core::{ControllerSchema, FieldSchema, TypeSchema};++pub(super) fn schemas(function: &str) -> ControllerSchema {+ match function {+ "list" => ControllerSchema {+ namespace: "threads",+ function: "list",+ description: "List conversation threads.",+ inputs: vec![],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with thread summaries and count.",+ required: true,+ }],+ },+ "upsert" => ControllerSchema {+ namespace: "threads",+ function: "upsert",+ description: "Create or refresh a conversation thread.",+ inputs: vec![+ FieldSchema {+ name: "id",+ ty: TypeSchema::String,+ comment: "Stable thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "title",+ ty: TypeSchema::String,+ comment: "Human-readable thread title.",+ required: true,+ },+ FieldSchema {+ name: "created_at",+ ty: TypeSchema::String,+ comment: "RFC3339 timestamp for first thread creation.",+ required: true,+ },+ FieldSchema {+ name: "labels",+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),+ comment: "Optional list of labels to assign.",+ required: false,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the resulting thread summary.",+ required: true,+ }],+ },+ "create_new" => ControllerSchema {+ namespace: "threads",+ function: "create_new",+ description: "Create a new conversation thread with auto-generated ID and title.",+ inputs: vec![FieldSchema {+ name: "labels",+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),+ comment: "Optional labels to assign to the new thread.",+ required: false,+ }],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the created thread summary.",+ required: true,+ }],+ },+ "messages_list" => ControllerSchema {+ namespace: "threads",+ function: "messages_list",+ description: "List messages for a conversation thread.",+ inputs: vec![FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ }],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with messages and count.",+ required: true,+ }],+ },+ "message_append" => ControllerSchema {+ namespace: "threads",+ function: "message_append",+ description: "Append a message to a conversation thread.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "message",+ ty: TypeSchema::Json,+ comment: "Message payload to append.",+ required: true,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the appended message payload.",+ required: true,+ }],+ },+ "message_update" => ControllerSchema {+ namespace: "threads",+ function: "message_update",+ description: "Patch metadata on an existing conversation message.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "message_id",+ ty: TypeSchema::String,+ comment: "Message identifier.",+ required: true,+ },+ FieldSchema {+ name: "extra_metadata",+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),+ comment: "Replacement message metadata object.",+ required: false,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the updated message payload.",+ required: true,+ }],+ },+ "generate_title" => ControllerSchema {+ namespace: "threads",+ function: "generate_title",+ description:+ "Generate a short thread title from the first user message and assistant reply.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "assistant_message",+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),+ comment:+ "Optional completed assistant reply to use instead of the stored first agent message.",+ required: false,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the resulting thread summary.",+ required: true,+ }],+ },+ "update_labels" => ControllerSchema {+ namespace: "threads",+ function: "update_labels",+ description: "Update labels for a conversation thread.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "labels",+ ty: TypeSchema::Json,+ comment: "List of labels to assign.",+ required: true,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the resulting thread summary.",+ required: true,+ }],+ },+ "update_title" => ControllerSchema {+ namespace: "threads",+ function: "update_title",+ description: "Set a user-specified title on a conversation thread.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "title",+ ty: TypeSchema::String,+ comment: "New title for the thread.",+ required: true,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the resulting thread summary.",+ required: true,+ }],+ },+ "delete" => ControllerSchema {+ namespace: "threads",+ function: "delete",+ description: "Delete a conversation thread and its message log.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "deleted_at",+ ty: TypeSchema::String,+ comment: "RFC3339 deletion timestamp.",+ required: true,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with deletion status.",+ required: true,+ }],+ },+ "purge" => ControllerSchema {+ namespace: "threads",+ function: "purge",+ description: "Remove all conversation threads and messages.",+ inputs: vec![],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with deleted thread/message counts.",+ required: true,+ }],+ },+ "turn_state_get" => ControllerSchema {+ namespace: "threads",+ function: "turn_state_get",+ description: "Fetch the persisted in-flight turn snapshot for a thread, if any.",+ inputs: vec![FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ }],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope wrapping the turn state (may be null).",+ required: true,+ }],+ },+ "turn_state_list" => ControllerSchema {+ namespace: "threads",+ function: "turn_state_list",+ description:+ "List every persisted turn snapshot — used to surface interrupted turns on cold boot.",+ inputs: vec![],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the list of turn snapshots and a count.",+ required: true,+ }],+ },+ "turn_state_history" => ControllerSchema {+ namespace: "threads",+ function: "turn_state_history",+ description:+ "List every persisted turn snapshot for one thread, newest first — the per-turn process history.",+ inputs: vec![FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ }],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the thread's turn snapshots and a count.",+ required: true,+ }],+ },+ "turn_state_get_turn" => ControllerSchema {+ namespace: "threads",+ function: "turn_state_get_turn",+ description: "Fetch one specific turn of a thread by its producing request id.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "request_id",+ ty: TypeSchema::String,+ comment: "Producing request id of the turn.",+ required: true,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope wrapping the turn state (may be null).",+ required: true,+ }],+ },+ "turn_state_clear" => ControllerSchema {+ namespace: "threads",+ function: "turn_state_clear",+ description: "Delete the persisted turn snapshot for a thread.",+ inputs: vec![FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ }],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope reporting whether a snapshot was removed.",+ required: true,+ }],+ },+ "task_board_get" => ControllerSchema {+ namespace: "threads",+ function: "task_board_get",+ description: "Fetch the persisted kanban task board for a conversation thread.",+ inputs: vec![FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ }],+ outputs: vec![FieldSchema {+ name: "taskBoard",+ ty: TypeSchema::Json,+ comment: "Task board payload.",+ required: true,+ }],+ },+ "task_board_put" => ControllerSchema {+ namespace: "threads",+ function: "task_board_put",+ description: "Replace the persisted kanban task board for a conversation thread.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "cards",+ ty: TypeSchema::Json,+ comment: "Array of task board cards.",+ required: true,+ },+ ],+ outputs: vec![FieldSchema {+ name: "taskBoard",+ ty: TypeSchema::Json,+ comment: "Task board payload.",+ required: true,+ }],+ },+ "token_usage" => ControllerSchema {+ namespace: "threads",+ function: "token_usage",+ description: "Total a thread's persisted token/cost usage from its session transcripts.",+ inputs: vec![FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ }],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the thread's token/cost totals (zeros when no turns yet).",+ required: true,+ }],+ },+ "transcript_get" => ControllerSchema {+ namespace: "threads",+ function: "transcript_get",+ description:+ "Project a thread's settled transcript (derived from session_raw/*.jsonl) into typed display items, newest-first paginated.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "cursor",+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),+ comment: "Opaque pagination cursor from a prior page's nextCursor; absent starts at the newest item.",+ required: false,+ },+ FieldSchema {+ name: "limit",+ ty: TypeSchema::Option(Box::new(TypeSchema::U64)),+ comment: "Max items to return (default 50, capped at 500).",+ required: false,+ },+ ],+ outputs: vec![FieldSchema {+ name: "result",+ ty: TypeSchema::Json,+ comment: "Envelope with the newest-first page of display items, total, and nextCursor.",+ required: true,+ }],+ },+ _other => ControllerSchema {+ namespace: "threads",+ function: "unknown",+ description: "Unknown threads controller function.",+ inputs: vec![],+ outputs: vec![FieldSchema {+ name: "error",+ ty: TypeSchema::String,+ comment: "Lookup error details.",+ required: true,+ }],+ },+ }+}diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rsindex 1941a29d8a..aa3879882e 100644--- a/crates/openhuman-core/src/web_chat/ops.rs+++ b/crates/openhuman-core/src/web_chat/ops.rs@@ -12,26 +12,20 @@ mod state;mod test_hooks;mod turn_guards;-pub(super) use budget_correlation::{classify_budget_correlation, BudgetCorrelation};-#[cfg(test)]-pub(super) use budget_correlation::{clear_budget_signal, has_fresh_budget_signal, record_budget_signal};-#[cfg(not(test))]-pub(super) use budget_correlation::{clear_budget_signal, has_fresh_budget_signal, record_budget_signal};+pub(super) use budget_correlation::{+ classify_budget_correlation, clear_budget_signal, has_fresh_budget_signal,+ record_budget_signal, BudgetCorrelation,+};pub use channel_ops::{cancel_chat, cancel_chat_scoped, channel_web_cancel, channel_web_chat,channel_web_queue_clear, channel_web_queue_status,};-#[cfg(any(test, debug_assertions))]-pub use parallel_turn::spawn_parallel_turn as _spawn_parallel_turn_for_test_visibility;-pub use start_chat::start_chat;pub(super) use state::{cancel_in_flight_gracefully, event_session_id_for, key_for};-pub use state::{- cancel_should_target, in_flight_entries_for_test, invalidate_thread_sessions,-};+pub use state::{cancel_should_target, in_flight_entries_for_test, invalidate_thread_sessions};#[cfg(any(test, debug_assertions))]pub use state::parallel_in_flight_entries_for_test;pub(super) use state::{IN_FLIGHT, PARALLEL_IN_FLIGHT, THREAD_SESSIONS};