Skip to content

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

fix(chat): restore missing chat runtime provider export

Steven Enamakel7e2a74cc16c2
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsx
index 6ec8552142..61139b2e64 100644
--- a/app/src/providers/ChatRuntimeProvider.tsx
+++ b/app/src/providers/ChatRuntimeProvider.tsx
@@ -268,6 +268,25 @@ function chatErrorExtraMetadata(event: ChatErrorEvent): Record<string, unknown>
return { [CHAT_ERROR_METADATA_KEY]: { errorType: event.error_type, guardrail: event.guardrail } };
}
+/**
+ * `extraMetadata` for the partial reply a `chat_cancelled` turn persists.
+ *
+ * `stopped: true` is the flag `assistantUiMessages.ts` reads to give the
+ * message `status: { type: 'incomplete', reason: 'cancelled' }`, which is
+ * what makes `thread.tsx` render the vendored `StoppedRun` element instead of
+ * the plain text. `cancelReason`/`supersededBy` ride through unchanged on
+ * `metadata.custom.extraMetadata` (that converter's existing pass-through) so
+ * `StoppedRunSlot` can pick "Stopped" vs "Replaced by a newer message".
+ */
+function chatCancelledExtraMetadata(event: ChatCancelledEvent): Record<string, unknown> {
+ return {
+ stopped: true,
+ ...(event.cancel_reason ? { cancelReason: event.cancel_reason } : {}),
+ ...(event.superseded_by ? { supersededBy: event.superseded_by } : {}),
+ ...(event.request_id ? { requestId: event.request_id } : {}),
+ };
+}
+
/**
* Message id for a reply the CORE already persisted before announcing it.
*
diff --git a/crates/openhuman-core/src/commands/ops.rs b/crates/openhuman-core/src/commands/ops.rs
new file mode 100644
index 0000000000..cf463b85d5
--- /dev/null
+++ b/crates/openhuman-core/src/commands/ops.rs
@@ -0,0 +1,130 @@
+//! Business logic for `commands.list`: the fixed built-in table, plus
+//! best-effort fetches of `skills.list` / `flows.list` through their own
+//! registered controllers (rather than reaching into their private types)
+//! so this module has no compile-time dependency on either domain's wire
+//! shape — only on the JSON both already return over RPC.
+
+use serde_json::{Map, Value};
+
+use crate::core::all::RegisteredController;
+use crate::rpc::{unwrap_rpc, RpcOutcome};
+
+use super::types::{CommandEntry, CommandKind};
+
+/// Fixed slash commands the core itself understands. `(command, description)`;
+/// the leading `/` is part of the wire `label`/`insert` text, not the `id`.
+const BUILTINS: &[(&str, &str)] = &[
+ ("/new", "Start a new conversation"),
+ ("/clear", "Clear the current conversation"),
+ ("/plan", "Switch to plan mode (draft without side effects)"),
+ ("/build", "Switch to build mode (resume normal tool execution)"),
+ ("/goal", "Set or view this thread's goal"),
+ ("/todo", "View or manage the thread's todo list"),
+ ("/stop", "Stop the current run"),
+];
+
+fn builtin_entries() -> Vec<CommandEntry> {
+ BUILTINS
+ .iter()
+ .map(|(command, description)| CommandEntry {
+ id: command.trim_start_matches('/').to_string(),
+ label: (*command).to_string(),
+ description: (*description).to_string(),
+ kind: CommandKind::Builtin,
+ insert: Some((*command).to_string()),
+ })
+ .collect()
+}
+
+/// Calls the registered `{namespace}.{function}` controller directly —
+/// bypassing JSON-RPC dispatch entirely, since this runs in-process — and
+/// returns its unwrapped JSON on success. `None` on any failure (missing
+/// controller, handler error): a broken skills/flows catalog must never
+/// take down the whole command palette.
+async fn invoke(
+ controllers: &[RegisteredController],
+ namespace: &str,
+ function: &str,
+ params: Map<String, Value>,
+) -> Option<Value> {
+ let controller = controllers
+ .iter()
+ .find(|c| c.schema.namespace == namespace && c.schema.function == function)?;
+ match (controller.handler)(params).await {
+ Ok(value) => Some(unwrap_rpc(&value).clone()),
+ Err(error) => {
+ log::debug!(
+ "[commands] {namespace}.{function} lookup failed, omitting from palette: {error}"
+ );
+ None
+ }
+ }
+}
+
+fn entries_from_array(
+ value: &Value,
+ array_field: &str,
+ kind: CommandKind,
+) -> Vec<CommandEntry> {
+ let Some(items) = value.get(array_field).and_then(Value::as_array) else {
+ return Vec::new();
+ };
+ items
+ .iter()
+ .filter_map(|item| {
+ let id = item.get("id").and_then(Value::as_str)?.to_string();
+ let label = item
+ .get("name")
+ .and_then(Value::as_str)
+ .filter(|s| !s.is_empty())
+ .unwrap_or(&id)
+ .to_string();
+ let description = item
+ .get("description")
+ .and_then(Value::as_str)
+ .unwrap_or_default()
+ .to_string();
+ Some(CommandEntry {
+ id,
+ label,
+ description,
+ kind,
+ // Skills/workflows dispatch through their own run RPC, not
+ // by inserting text into the composer.
+ insert: None,
+ })
+ })
+ .collect()
+}
+
+/// Builds the merged command list: built-ins first (stable order, cheapest),
+/// then skills, then workflows.
+pub async fn commands_list() -> Result<RpcOutcome<Vec<CommandEntry>>, String> {
+ let mut entries = builtin_entries();
+
+ let skills_controllers = crate::skills::all_skills_registered_controllers();
+ let mut skills_params = Map::new();
+ // Include capability skills (`skills/` roots), not just `workflows/`-root
+ // automations — the palette wants everything runnable, not just the
+ // Automations tab's default view.
+ skills_params.insert("include_skills".to_string(), Value::Bool(true));
+ if let Some(value) = invoke(&skills_controllers, "skills", "list", skills_params).await {
+ entries.extend(entries_from_array(&value, "skills", CommandKind::Skill));
+ }
+
+ let flows_controllers = crate::flows::all_flows_registered_controllers();
+ if let Some(value) = invoke(&flows_controllers, "flows", "list", Map::new()).await {
+ entries.extend(entries_from_array(&value, "flows", CommandKind::Workflow));
+ }
+
+ log::debug!(
+ "[commands] list: {} builtin + {} total entries",
+ BUILTINS.len(),
+ entries.len()
+ );
+ Ok(RpcOutcome::new(entries, Vec::new()))
+}
+
+#[cfg(test)]
+#[path = "ops_tests.rs"]
+mod tests;