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
feat(threads): add wire schema module for thread RPC types
Steven Enamakel9901507dc670
diff --git a/crates/openhuman-cli/Cargo.toml b/crates/openhuman-cli/Cargo.tomlindex 1287e89f4f..0e09f24c98 100644--- a/crates/openhuman-cli/Cargo.toml+++ b/crates/openhuman-cli/Cargo.toml@@ -49,6 +49,10 @@ path = "src/bin/fleet.rs"# (no `http-server`) this target is skipped rather than failing to link.required-features = ["http-server", "bin-tools"]+[[example]]+name = "thread_wire_schema"+path = "examples/thread_wire_schema.rs"+# The benchmark and profiling binaries (`library-profile`, `rss-bench`,# `tool-search-bench`, `tool-dialect-bench`) and their driver scripts live in# tinyhumansai/openhuman-benchmarks (`profile/`), which builds them against adiff --git a/crates/openhuman-cli/examples/thread_wire_schema.rs b/crates/openhuman-cli/examples/thread_wire_schema.rsnew file mode 100644index 0000000000..c26349cd1e--- /dev/null+++ b/crates/openhuman-cli/examples/thread_wire_schema.rs@@ -0,0 +1,4 @@+fn main() -> Result<(), Box<dyn std::error::Error>> {+ println!("{}", openhuman_core::threads::wire_schema::thread_wire_schema_json()?);+ Ok(())+}diff --git a/crates/openhuman-core/src/threads/mod.rs b/crates/openhuman-core/src/threads/mod.rsindex 1adea2380c..fd3ab57da6 100644--- a/crates/openhuman-core/src/threads/mod.rs+++ b/crates/openhuman-core/src/threads/mod.rs@@ -13,6 +13,7 @@ pub mod store;#[cfg(test)]mod transcript_host_tests;pub mod turn_state;+pub mod wire_schema;pub mod welcome_migration;pub use error::{ThreadsError, THREAD_NOT_FOUND_KIND};diff --git a/crates/openhuman-core/src/threads/rpc_models.rs b/crates/openhuman-core/src/threads/rpc_models.rsindex bf1c3de248..9b25461d44 100644--- a/crates/openhuman-core/src/threads/rpc_models.rs+++ b/crates/openhuman-core/src/threads/rpc_models.rs@@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};pub use crate::core::envelope::{ApiEnvelope, ApiError, ApiMeta, EmptyRequest, PaginationMeta};/// Request to create a new conversation thread.-#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]+#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(deny_unknown_fields)]pub struct CreateConversationThreadRequest {#[serde(default)]@@ -25,7 +25,7 @@ pub struct CreateConversationThreadRequest {/// Request to bind or clear the working folder of a thread that has no/// messages yet.-#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]+#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(deny_unknown_fields)]pub struct UpdateConversationThreadWorkingDirRequest {pub thread_id: String,@@ -34,7 +34,7 @@ pub struct UpdateConversationThreadWorkingDirRequest {}/// Summary information for a workspace-backed conversation thread.-#[derive(Debug, Clone, Serialize, Deserialize)]+#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]#[serde(rename_all = "camelCase")]pub struct ConversationThreadSummary {pub id: String,@@ -57,7 +57,7 @@ pub struct ConversationThreadSummary {}/// A single persisted conversation message.-#[derive(Debug, Clone, Serialize, Deserialize)]+#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]#[serde(rename_all = "camelCase")]pub struct ConversationMessageRecord {pub id: String,diff --git a/crates/openhuman-core/src/threads/wire_schema.rs b/crates/openhuman-core/src/threads/wire_schema.rsnew file mode 100644index 0000000000..da01cf4aa7--- /dev/null+++ b/crates/openhuman-core/src/threads/wire_schema.rs@@ -0,0 +1,26 @@+//! JSON Schema for the thread and persisted turn records consumed by the UI.++use schemars::JsonSchema;++use crate::threads::rpc_models::{ConversationMessageRecord, ConversationThreadSummary};++/// Root schema whose properties provide the UI-facing thread record aliases.+#[derive(JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct ThreadWireTypes {+ pub thread: ConversationThreadSummary,+ pub message: ConversationMessageRecord,+ pub turn_state: tinyagents_session::turn_state::types::TurnState,+ pub agent_run: tinyagents_session::run_ledger::types::AgentRun,+ pub run_event: tinyagents_session::run_ledger::types::RunEvent,+ pub run_telemetry: tinyagents_session::run_ledger::types::RunTelemetry,+}++/// Serialize the authoritative core/session record schemas for TypeScript codegen.+pub fn thread_wire_schema_json() -> Result<String, serde_json::Error> {+ serde_json::to_string_pretty(&schemars::schema_for!(ThreadWireTypes))+}++#[cfg(test)]+#[path = "wire_schema_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/threads/wire_schema_tests.rs b/crates/openhuman-core/src/threads/wire_schema_tests.rsnew file mode 100644index 0000000000..318d544029--- /dev/null+++ b/crates/openhuman-core/src/threads/wire_schema_tests.rs@@ -0,0 +1,19 @@+use super::*;++#[test]+fn thread_wire_schema_exports_the_core_and_session_records() {+ let schema: serde_json::Value =+ serde_json::from_str(&thread_wire_schema_json().expect("schema serializes"))+ .expect("schema is JSON");+ let properties = schema["properties"].as_object().expect("root properties");+ for property in [+ "thread",+ "message",+ "turnState",+ "agentRun",+ "runEvent",+ "runTelemetry",+ ] {+ assert!(properties.contains_key(property), "schema is missing {property}");+ }+}