Skip to content

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

feat(threads): generate UI thread types from core wire schema

Steven Enamakel662b3470a425
diff --git a/app/src/types/thread.ts b/app/src/types/thread.ts
index 89f742aa4c..29cd5e75fe 100644
--- a/app/src/types/thread.ts
+++ b/app/src/types/thread.ts
@@ -1,53 +1,21 @@
-export interface Thread {
- id: string;
- title: string;
- chatId: number | null;
- isActive: boolean;
- messageCount: number;
- lastMessageAt: string;
- createdAt: string;
- parentThreadId?: string;
- labels: string[];
- personalityId?: string | null;
- /** Working folder the thread's agent acts in; absent means the global default. */
- actionDir?: string | null;
-}
+import type { ThreadWireTypes } from './threadWire.generated';
-export interface ThreadMessage {
- id: string;
- content: string;
- type: string;
- extraMetadata: Record<string, unknown>;
+export type Thread = ThreadWireTypes['thread'];
+
+/** UI narrows the core's open sender string to the roles it renders. */
+export type ThreadMessage = Omit<ThreadWireTypes['message'], 'sender'> & {
sender: 'user' | 'agent';
- createdAt: string;
-}
+};
-export interface ThreadsListData {
- threads: Thread[];
- count: number;
-}
+export type ThreadsListData = ThreadWireTypes['threadsList'];
-export interface ThreadMessagesData {
+export type ThreadMessagesData = Omit<ThreadWireTypes['threadMessages'], 'messages'> & {
messages: ThreadMessage[];
- count: number;
-}
+};
-export interface ThreadDeleteData {
- deleted: boolean;
-}
+export type ThreadDeleteData = ThreadWireTypes['threadDelete'];
-export interface PurgeResultData {
- messagesDeleted: number;
- agentThreadsDeleted: number;
- agentMessagesDeleted: number;
-}
+export type PurgeResultData = ThreadWireTypes['purgeResult'];
/** One message matched by `openhuman.threads_search` (global search). */
-export interface ThreadSearchHit {
- threadId: string;
- messageId: string;
- role: string;
- /** Message text around the match, `…` where it was cut. */
- snippet: string;
- createdAt: string;
-}
+export type ThreadSearchHit = ThreadWireTypes['threadSearchHit'];
diff --git a/crates/openhuman-core/src/threads/ops/search.rs b/crates/openhuman-core/src/threads/ops/search.rs
index 1c792f2905..cd98401ef8 100644
--- a/crates/openhuman-core/src/threads/ops/search.rs
+++ b/crates/openhuman-core/src/threads/ops/search.rs
@@ -27,7 +27,7 @@ pub struct ThreadSearchRequest {
}
/// One matched message.
-#[derive(Debug, Clone, PartialEq, serde::Serialize)]
+#[derive(Debug, Clone, PartialEq, serde::Serialize, schemars::JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ThreadSearchHit {
pub thread_id: String,
@@ -39,7 +39,7 @@ pub struct ThreadSearchHit {
}
/// Response for [`thread_search`]: hits newest first.
-#[derive(Debug, Clone, serde::Serialize)]
+#[derive(Debug, Clone, serde::Serialize, schemars::JsonSchema)]
pub struct ThreadSearchResponse {
pub hits: Vec<ThreadSearchHit>,
}
diff --git a/crates/openhuman-core/src/threads/wire_schema.rs b/crates/openhuman-core/src/threads/wire_schema.rs
index da01cf4aa7..74dff5e249 100644
--- a/crates/openhuman-core/src/threads/wire_schema.rs
+++ b/crates/openhuman-core/src/threads/wire_schema.rs
@@ -2,7 +2,11 @@
use schemars::JsonSchema;
-use crate::threads::rpc_models::{ConversationMessageRecord, ConversationThreadSummary};
+use crate::threads::rpc_models::{
+ ConversationMessageRecord, ConversationMessagesResponse, ConversationThreadSummary,
+ ConversationThreadsListResponse, DeleteConversationThreadResponse,
+ PurgeConversationThreadsResponse,
+};
/// Root schema whose properties provide the UI-facing thread record aliases.
#[derive(JsonSchema)]
@@ -10,6 +14,12 @@ use crate::threads::rpc_models::{ConversationMessageRecord, ConversationThreadSu
pub struct ThreadWireTypes {
pub thread: ConversationThreadSummary,
pub message: ConversationMessageRecord,
+ pub threads_list: ConversationThreadsListResponse,
+ pub thread_messages: ConversationMessagesResponse,
+ pub thread_delete: DeleteConversationThreadResponse,
+ pub purge_result: PurgeConversationThreadsResponse,
+ pub thread_search_hit: super::ops::ThreadSearchHit,
+ pub thread_search: super::ops::ThreadSearchResponse,
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,
diff --git a/crates/openhuman-core/src/threads/wire_schema_tests.rs b/crates/openhuman-core/src/threads/wire_schema_tests.rs
index 318d544029..683c8961b2 100644
--- a/crates/openhuman-core/src/threads/wire_schema_tests.rs
+++ b/crates/openhuman-core/src/threads/wire_schema_tests.rs
@@ -9,6 +9,12 @@ fn thread_wire_schema_exports_the_core_and_session_records() {
for property in [
"thread",
"message",
+ "threadsList",
+ "threadMessages",
+ "threadDelete",
+ "purgeResult",
+ "threadSearchHit",
+ "threadSearch",
"turnState",
"agentRun",
"runEvent",