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 schema registry for thread operations
Steven Enamakelca28b81d8d38
diff --git a/crates/openhuman-core/src/threads/ops.rs b/crates/openhuman-core/src/threads/ops.rsindex 48613425b8..10e1474c6c 100644--- a/crates/openhuman-core/src/threads/ops.rs+++ b/crates/openhuman-core/src/threads/ops.rs@@ -13,6 +13,7 @@ mod title_generation;mod transcript;mod turn_state_ops;mod usage;+mod working_dir;pub use crud::{delete_after, message_append, message_update, messages_list, thread_create_new, thread_delete,@@ -26,6 +27,8 @@ pub use live_state::{};pub use purge::threads_purge;pub use title_generation::thread_generate_title;+pub use working_dir::thread_update_working_dir;+pub(crate) use working_dir::thread_working_dir;pub use transcript::{transcript_get, TranscriptGetRequest};pub use turn_state_ops::{turn_state_clear, turn_state_get, turn_state_get_turn, turn_state_history, turn_state_list,diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rsindex df8e837e33..829698080c 100644--- a/crates/openhuman-core/src/threads/ops/crud.rs+++ b/crates/openhuman-core/src/threads/ops/crud.rs@@ -69,6 +69,7 @@ pub async fn thread_create_new(request: CreateConversationThreadRequest,) -> Result<Outcome<ApiEnvelope<ConversationThreadSummary>>, String> {let dir = workspace_dir().await?;+ let working_dir = super::working_dir::validate_working_dir(request.action_dir.as_deref())?;let id = format!("thread-{}", uuid::Uuid::new_v4());let now = chrono::Local::now();let title = format!("Chat {} {}", now.format("%b %-d"), now.format("%-I:%M %p"));@@ -85,13 +86,14 @@ pub async fn thread_create_new(// of truth for default labels.labels: request.labels,personality_id: request.personality_id,- working_dir: None,+ working_dir,},).await?;tracing::debug!(thread_id = %thread.id,labels = ?thread.labels,+ working_dir_bound = thread.working_dir.is_some(),"[threads] created new thread");Ok(envelope(diff --git a/crates/openhuman-core/src/threads/schemas/handlers.rs b/crates/openhuman-core/src/threads/schemas/handlers.rsindex c6a46a9432..91e5303e99 100644--- a/crates/openhuman-core/src/threads/schemas/handlers.rs+++ b/crates/openhuman-core/src/threads/schemas/handlers.rs@@ -11,7 +11,8 @@ use crate::threads::{AppendConversationMessageRequest, ConversationMessagesRequest, CreateConversationThreadRequest,DeleteConversationThreadRequest, EmptyRequest, GenerateConversationThreadTitleRequest,UpdateConversationMessageRequest, UpdateConversationThreadLabelsRequest,- UpdateConversationThreadTitleRequest, UpsertConversationThreadRequest,+ UpdateConversationThreadTitleRequest, UpdateConversationThreadWorkingDirRequest,+ UpsertConversationThreadRequest,};use super::super::ops;@@ -69,6 +70,13 @@ pub(super) fn handle_update_title(params: Map<String, Value>) -> ControllerFutur})}+pub(super) fn handle_update_working_dir(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let p = parse::<UpdateConversationThreadWorkingDirRequest>(params)?;+ to_json(ops::thread_update_working_dir(p).await?)+ })+}+pub(super) fn handle_message_update(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let p = parse::<UpdateConversationMessageRequest>(params)?;diff --git a/crates/openhuman-core/src/threads/schemas/registry.rs b/crates/openhuman-core/src/threads/schemas/registry.rsindex 4ec8c4f24a..3d183bb4a5 100644--- a/crates/openhuman-core/src/threads/schemas/registry.rs+++ b/crates/openhuman-core/src/threads/schemas/registry.rs@@ -10,6 +10,7 @@ use super::handlers::{handle_regenerate, handle_todos_get, handle_token_usage, handle_transcript_get,handle_turn_state_clear, handle_turn_state_get, handle_turn_state_get_turn,handle_turn_state_history, handle_turn_state_list, handle_update_labels, handle_update_title,+ handle_update_working_dir,handle_upsert,};use super::schema_defs::schemas;@@ -24,6 +25,7 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {schemas("generate_title"),schemas("update_labels"),schemas("update_title"),+ schemas("update_working_dir"),schemas("message_update"),schemas("delete"),schemas("purge"),@@ -75,6 +77,10 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {schema: schemas("update_title"),handler: handle_update_title,},+ RegisteredController {+ schema: schemas("update_working_dir"),+ handler: handle_update_working_dir,+ },RegisteredController {schema: schemas("message_update"),handler: handle_message_update,diff --git a/crates/openhuman-core/src/threads/schemas/schema_defs.rs b/crates/openhuman-core/src/threads/schemas/schema_defs.rsindex 7a681675d7..446755a18e 100644--- a/crates/openhuman-core/src/threads/schemas/schema_defs.rs+++ b/crates/openhuman-core/src/threads/schemas/schema_defs.rs@@ -57,12 +57,20 @@ pub(crate) fn schemas(function: &str) -> 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,- }],+ inputs: vec![+ FieldSchema {+ name: "labels",+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),+ comment: "Optional labels to assign to the new thread.",+ required: false,+ },+ FieldSchema {+ name: "action_dir",+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),+ comment: "Optional absolute working folder for the thread's agent; empty or absent uses the global action_dir.",+ required: false,+ },+ ],outputs: vec![FieldSchema {name: "result",ty: TypeSchema::Json,@@ -195,6 +203,31 @@ pub(crate) fn schemas(function: &str) -> ControllerSchema {required: true,}],},+ "update_working_dir" => ControllerSchema {+ namespace: "threads",+ function: "update_working_dir",+ description: "Bind or clear the working folder of a thread that has no messages yet.",+ inputs: vec![+ FieldSchema {+ name: "thread_id",+ ty: TypeSchema::String,+ comment: "Thread identifier.",+ required: true,+ },+ FieldSchema {+ name: "action_dir",+ ty: TypeSchema::String,+ comment: "Absolute folder path; empty clears back to the global action_dir.",+ 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",diff --git a/crates/openhuman-core/src/threads/schemas_tests.rs b/crates/openhuman-core/src/threads/schemas_tests.rsindex 458e4fe8b0..103038e8e8 100644--- a/crates/openhuman-core/src/threads/schemas_tests.rs+++ b/crates/openhuman-core/src/threads/schemas_tests.rs@@ -10,6 +10,7 @@ const ALL_FUNCTIONS: &[&str] = &["generate_title","update_labels","update_title",+ "update_working_dir","message_update","delete","purge",diff --git a/crates/openhuman-core/src/web_chat/run_task.rs b/crates/openhuman-core/src/web_chat/run_task.rsindex a9e84f99c6..dc2629e2cf 100644--- a/crates/openhuman-core/src/web_chat/run_task.rs+++ b/crates/openhuman-core/src/web_chat/run_task.rs@@ -97,7 +97,17 @@ pub(crate) async fn run_chat_task(}}- let config = config_rpc::load_config_with_timeout().await?;+ let mut config = config_rpc::load_config_with_timeout().await?;+ // A thread started in a chosen folder acts there, not in the global+ // `action_dir`. Applied before checkout so the session agent, its security+ // policy (which grants `action_dir` as a trusted root) and its tools are+ // all built on the thread's folder.+ if let Some(dir) =+ crate::threads::ops::thread_working_dir(config.workspace_dir.clone(), thread_id).await+ {+ log::debug!("[web-channel] thread working folder applied thread_id={thread_id}");+ config.action_dir = dir;+ }let model_override = normalize_model_override(model_override);// The cached session (or a cold-boot resumed one) is the thread's single// live history; every turn on the thread checks it out through this path.