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(core): add ThreadRunModeChanged event and propagate tool_call_id to web channel
Steven Enamakel65cb955b83f6
diff --git a/app/src/components/assistant-ui/elements/agent-plan.tsx b/app/src/components/assistant-ui/elements/agent-plan.tsxnew file mode 100644index 0000000000..c69bdcac69--- /dev/null+++ b/app/src/components/assistant-ui/elements/agent-plan.tsx@@ -0,0 +1,85 @@+'use client';++/**+ * The agent's step-by-step plan for the current thread, with a progress bar+ * and a checkmark/spinner per step.+ *+ * Vendored from the assistant-ui `elements-agent-plan` registry item+ * (https://r.assistant-ui.com/styles/base-nova/elements-agent-plan.json).+ * Changes from upstream:+ * - `cn` import path (`@/components/assistant-ui/lib/utils`).+ * - The header text `"Plan"` is a prop (`title`) with that English default,+ * so the caller (`PlanReviewPart` in+ * `features/conversations/aui/PlanReviewPart.tsx`) supplies the translated+ * string via `useT()`.+ */+import { cn } from '@/components/assistant-ui/lib/utils';+import { CheckIcon, Loader2Icon } from 'lucide-react';+import type { ComponentProps } from 'react';++import { mono } from './surfaces';+import { pct, progressOf } from '../utils/range';++export function AgentPlan({+ steps,+ activeIndex,+ title = 'Plan',+ className,+ ...props+}: Omit<ComponentProps<'div'>, 'children' | 'steps' | 'activeIndex' | 'title'> & {+ steps: readonly string[];+ activeIndex: number;+ title?: string;+}) {+ const total = steps.length;+ const completed = progressOf(activeIndex, total);+ const allDone = completed >= total;+ const progress = pct(completed, total);++ return (+ <div+ data-slot="agent-plan"+ className={cn('flex w-full max-w-sm flex-col gap-3', className)}+ {...props}>+ <div className="flex items-center justify-between">+ <span className="text-[13.5px] font-medium">{title}</span>+ <span className={cn(mono, 'text-foreground/35 tabular-nums')}>+ {completed} of {total}+ </span>+ </div>+ <div className="bg-foreground/[0.06] h-[3px] w-full overflow-hidden rounded-full">+ <span+ className="bg-foreground/80 block h-full rounded-full transition-[width] duration-500"+ style={{ width: `${progress}%` }}+ />+ </div>+ <ul className="flex flex-col gap-2.5">+ {steps.map((step, i) => {+ const done = allDone || i < completed;+ const active = !allDone && i === completed;+ return (+ <li key={step} className="flex items-center gap-2.5 text-[13.5px]">+ <span className="flex size-4 shrink-0 items-center justify-center">+ {done ? (+ <CheckIcon className="text-foreground/35 size-3.5" />+ ) : active ? (+ <Loader2Icon className="text-foreground/90 size-3.5 animate-spin motion-reduce:animate-none" />+ ) : (+ <span aria-hidden className="bg-foreground/15 size-1.5 rounded-full" />+ )}+ </span>+ <span+ className={cn(+ done && 'text-foreground/40',+ active && 'text-foreground/90',+ !done && !active && 'text-foreground/35'+ )}>+ {step}+ </span>+ </li>+ );+ })}+ </ul>+ </div>+ );+}diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rsindex e27a139b6b..2a0dfe18f5 100644--- a/crates/openhuman-core/src/core/events.rs+++ b/crates/openhuman-core/src/core/events.rs@@ -1476,6 +1476,17 @@ pub enum DomainEvent {/// Full todo-list snapshot, owned by `tinyagents-graph`'s todo shape.todos: serde_json::Value,},+ // ── Plan mode ───────────────────────────────────────────────────────+ /// A thread's [`tinyagents_harness::middleware::RunMode`] (Plan vs Build)+ /// changed, via `agent.set_run_mode` or the `plan_exit` tool. Bridged to+ /// the `run_mode_changed` web-channel socket event by+ /// `crate::agent::tinyagents::run_mode::set_mode`'s caller.+ ThreadRunModeChanged {+ thread_id: String,+ /// `"plan"` or `"build"` — see+ /// `crate::agent::tinyagents::run_mode::mode_label`.+ mode: String,+ },}/// Truncate to `max` characters, appending `…` when anything was dropped.@@ -1615,7 +1626,8 @@ impl DomainEvent {Self::ThreadGoalUpdated { .. }| Self::ThreadGoalCleared { .. }- | Self::ThreadTodosChanged { .. } => "agent",+ | Self::ThreadTodosChanged { .. }+ | Self::ThreadRunModeChanged { .. } => "agent",Self::SubconsciousTriggerProcessed { .. } => "subconscious",diff --git a/crates/openhuman-core/src/threads/transcript_view/project.rs b/crates/openhuman-core/src/threads/transcript_view/project.rsindex c1eb7236e4..0c98ae31da 100644--- a/crates/openhuman-core/src/threads/transcript_view/project.rs+++ b/crates/openhuman-core/src/threads/transcript_view/project.rs@@ -68,6 +68,7 @@ pub fn project_from_files(thread_id: &str,root_paths: &[PathBuf],sub_paths: &[PathBuf],+ workspace_dir: Option<&Path>,) -> ProjectedTranscript {log::debug!("{LOG_PREFIX} projecting thread={thread_id} roots={} subagent_files={}",@@ -126,7 +127,12 @@ pub fn project_from_files(let mut items = project_records(&records);let top_level = items.len();- subagents::attach(&mut items, sub_paths, &subagents::turn_segments(&records));+ subagents::attach(+ &mut items,+ sub_paths,+ &subagents::turn_segments(&records),+ workspace_dir,+ );log::debug!("{LOG_PREFIX} projected thread={thread_id} top_level_items={top_level} subagents={}",items.len() - top_leveldiff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rsindex 593c5e3213..008d6b7863 100644--- a/crates/openhuman-core/src/web_chat/event_bus.rs+++ b/crates/openhuman-core/src/web_chat/event_bus.rs@@ -360,7 +360,8 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {size_bytes,thread_id,client_id,- ..+ tool_call_id,+ request_id,} => {let (Some(thread_id), Some(client_id)) = (thread_id, client_id) else {log::debug!(@@ -369,12 +370,14 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {return;};log::info!(- "[web-channel] artifact-surface emitting artifact_ready id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id}"+ "[web-channel] artifact-surface emitting artifact_ready id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} tool_call_id={tool_call_id:?}");publish_web_channel_event(WebChannelEvent {event: "artifact_ready".to_string(),client_id: client_id.clone(),thread_id: thread_id.clone(),+ tool_call_id: tool_call_id.clone(),+ turn_request_id: request_id.clone(),args: Some(serde_json::json!({"artifact_id": artifact_id,"kind": kind,@@ -394,7 +397,8 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {error,thread_id,client_id,- ..+ tool_call_id,+ request_id,} => {let (Some(thread_id), Some(client_id)) = (thread_id, client_id) else {log::debug!(@@ -403,13 +407,15 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {return;};log::warn!(- "[web-channel] artifact-surface emitting artifact_failed id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} error_len={}",+ "[web-channel] artifact-surface emitting artifact_failed id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} tool_call_id={tool_call_id:?} error_len={}",error.len());publish_web_channel_event(WebChannelEvent {event: "artifact_failed".to_string(),client_id: client_id.clone(),thread_id: thread_id.clone(),+ tool_call_id: tool_call_id.clone(),+ turn_request_id: request_id.clone(),args: Some(serde_json::json!({"artifact_id": artifact_id,"kind": kind,@@ -428,7 +434,8 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {path,thread_id,client_id,- ..+ tool_call_id,+ request_id,} => {let (Some(thread_id), Some(client_id)) = (thread_id, client_id) else {log::debug!(@@ -437,12 +444,14 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {return;};log::info!(- "[web-channel] artifact-surface emitting artifact_pending id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id}"+ "[web-channel] artifact-surface emitting artifact_pending id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} tool_call_id={tool_call_id:?}");publish_web_channel_event(WebChannelEvent {event: "artifact_pending".to_string(),client_id: client_id.clone(),thread_id: thread_id.clone(),+ tool_call_id: tool_call_id.clone(),+ turn_request_id: request_id.clone(),args: Some(serde_json::json!({"artifact_id": artifact_id,"kind": kind,