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
fix(medulla): restore envelope test for socket message handling
Steven Enamakel347bd23982bb
diff --git a/app/src/utils/toolTimelineFormatting.ts b/app/src/utils/toolTimelineFormatting.tsindex 8d792a1d7e..ec207fb10e 100644--- a/app/src/utils/toolTimelineFormatting.ts+++ b/app/src/utils/toolTimelineFormatting.ts@@ -1,156 +1,53 @@+/**+ * Timeline-row formatting for tool calls.+ *+ * Every label, icon and category is resolved by the tool presentation+ * registry (`features/conversations/tools/toolPresentation.ts`); this module+ * adapts {@link ToolTimelineEntry} rows onto it and keeps the timeline-only+ * helpers (processing blocks, sources, envelope stripping).+ */+import { parseWebSearchResult } from '../features/conversations/tools/parseWebSearchResult';+import {+ describeToolCall,+ type ToolCallPresentation,+ type ToolCategory,+ toolLabel,+ type Translate,+} from '../features/conversations/tools/toolPresentation';+import { fillPlaceholders } from '../features/conversations/tools/toolPhrases';import type { ToolTimelineEntry } from '../store/chatRuntimeSlice';import type { PersistedTranscriptItem } from '../types/turnState';-interface ParsedToolArgs {- agent_id?: string;- prompt?: string;- toolkit?: string;- command?: string;- url?: string;- path?: string;- file_path?: string;- pattern?: string;- query?: string;- tool_name?: string;- question?: string;-}+export type { ToolCategory, Translate };-const TOOL_DISPLAY_NAMES: Record<string, string> = {- shell: 'Running command',- node_exec: 'Running command',- npm_exec: 'Running command',- web_fetch: 'Fetching',- http_request: 'Fetching',- curl: 'Fetching',- web_search: 'Searching the web',- // The name the core actually registers and streams for the canonical search- // slot, whichever engine owns it (`crates/openhuman-core/src/search/registry.rs`).- // `web_search` above is the settings-family id, which never reaches a- // timeline row — without this entry a real search rendered as the- // humanized "Web Search Tool".- web_search_tool: 'Searching the web',- gitbooks_search: 'Searching docs',- file_read: 'Reading file',- file_write: 'Writing file',- edit: 'Editing file',- apply_patch: 'Applying patch',- grep: 'Searching code',- glob: 'Finding files',- list: 'Listing directory',- read_diff: 'Reading diff',- git_operations: 'Git operation',- browser: 'Browsing',- browser_open: 'Opening browser',- image_info: 'Analyzing image',- install_tool: 'Installing tool',- lsp: 'Code intelligence',- keyboard: 'Typing',- mouse: 'Clicking',- csv_export: 'Exporting CSV',- update_memory_md: 'Updating memory',- read_workspace_state: 'Reading workspace',- current_time: 'Checking time',- schedule: 'Scheduling',- detect_tools: 'Detecting tools',- tool_stats: 'Tool statistics',- vault_write_markdown: 'Writing to vault',- run_linter: 'Running linter',- run_tests: 'Running tests',- proxy_config: 'Configuring proxy',- update_check: 'Checking for updates',- update_apply: 'Applying update',- pushover: 'Sending notification',- insert_sql_record: 'Inserting record',- mcp_list_servers: 'Listing MCP servers',- mcp_list_tools: 'Listing MCP tools',- mcp_call_tool: 'Calling MCP tool',- gmail_unsubscribe: 'Unsubscribing',- gitbooks_get_page: 'Reading docs page',- audio_generate_podcast: 'Generating podcast',- audio_email_podcast: 'Emailing podcast',- audio_generate_and_email_podcast: 'Generating & emailing podcast',- composio_list_connections: 'Viewing your Connections',- agent_prepare_context: 'Preparing context',- propose_workflow: 'Proposing workflow',- // Harness work state: the session todo list and the thread goal. The pane- // renders both from these calls' results (`utils/harnessState.ts`), so the- // rows read as bookkeeping, not as work in their own right.- todo: 'Updating todo list',- goal_set: 'Setting goal',- goal_get: 'Checking goal',- goal_complete: 'Completing goal',-};+/** Resolve a timeline row through the registry. */+export function presentTimelineEntry(entry: ToolTimelineEntry): ToolCallPresentation {+ return describeToolCall({+ name: entry.name,+ args: entry.argsBuffer,+ status: entry.status,+ serverLabel: entry.displayName,+ serverDetail: entry.detail,+ });+}/**- * Format a raw tool name into a short human-readable label.- * Used for subagent child tool rows and sub-mascot activity text.+ * Present-tense label for a bare tool name ("Searching the web"). Used where+ * only the name is known: sub-agent child rows and the mascot's activity line.*/-export function formatToolName(toolName: string | undefined): string {+export function formatToolName(toolName: string | undefined, t?: Translate): string {if (!toolName) return '';- return TOOL_DISPLAY_NAMES[toolName] ?? humanizeIdentifier(toolName);+ return toolLabel(describeToolCall({ name: toolName, status: 'running' }), t);}/**- * The fixed set of built-in / special tools this client formatter labels- * well on its own (with args-aware detail). For these, the client label is- * authoritative and a server-supplied `display_label` is ignored — the- * server label only wins for *dynamic* tools (Composio/MCP/integration- * actions) the client can't possibly know, which is where raw `snake_case`- * used to leak through. Keep in sync with {@link formatTimelineEntry} /- * {@link formatToolDetail}.- */-const CLIENT_KNOWN_TOOLS = new Set<string>([- ...Object.keys(TOOL_DISPLAY_NAMES),- // args-aware built-ins handled by formatToolDetail()- 'shell',- 'node_exec',- 'npm_exec',- 'web_fetch',- 'http_request',- 'curl',- 'web_search',- 'web_search_tool',- 'gitbooks_search',- 'file_read',- 'file_write',- 'vault_write_markdown',- 'edit',- 'apply_patch',- 'grep',- 'glob',- 'list',- 'git_operations',- 'browser',- 'browser_open',- 'image_info',- 'install_tool',- 'lsp',- 'run_tests',- 'run_linter',- 'read_diff',- // special-cased agent / integration rows- 'spawn_subagent',- 'integrations_agent',- 'researcher',- 'agent_prepare_context',- 'context_scout',- 'composio_list_connections',- 'orchestrator',- 'critic',- 'tools_agent',- 'code_executor',-]);--/**- * Whether the client formatter recognizes this tool (so its label should win- * over any server-supplied one). True for built-ins, the special agent rows,- * and the `subagent:` / `delegate_` families that {@link formatTimelineEntry}- * handles explicitly.+ * Whether the registry describes this tool on its own. For these the client+ * label is authoritative and a server `display_label` is ignored; the server+ * label wins only for dynamic tools the registry cannot know.*/export function isKnownClientTool(name: string): boolean {- return (- name.startsWith('subagent:') || name.startsWith('delegate_') || CLIENT_KNOWN_TOOLS.has(name)- );+ const { source } = describeToolCall({ name });+ return source !== 'server' && source !== 'fallback';}/**@@ -168,185 +65,68 @@ export function stripToolCallEnvelopes(text: string | undefined | null): string.replace(/<tool_call\b[^>]*>[\s\S]*$/i, '');}-/** Broad activity category for a tool, used to group + icon timeline rows. */-export type ToolCategory = 'read' | 'write' | 'search' | 'run' | 'fetch' | 'browse' | 'other';--const TOOL_CATEGORIES: Record<string, ToolCategory> = {- file_read: 'read',- list: 'read',- read_diff: 'read',- file_write: 'write',- vault_write_markdown: 'write',- edit: 'write',- apply_patch: 'write',- grep: 'search',- glob: 'search',- // `web_search_tool` is the runtime tool name; `web_search` is only the UI- // toggle id the core expands from (`tools/user_filter.rs:79-80`, and- // `test/e2e/specs/harness-search-tool-flow.spec.ts:10` says so outright).- // Both are mapped: the toggle id never reaches a timeline row, but leaving- // it out would break any older snapshot that recorded the alias.- web_search: 'search',- web_search_tool: 'search',- gitbooks_search: 'search',- gitbooks_get_page: 'read',- shell: 'run',- node_exec: 'run',- npm_exec: 'run',- run_tests: 'run',- run_linter: 'run',- git_operations: 'run',- web_fetch: 'fetch',- http_request: 'fetch',- curl: 'fetch',- browser: 'browse',- browser_open: 'browse',-};-/** Categorize a (possibly `subagent:`-prefixed) tool name for grouping/icons. */export function categorizeTool(name: string): ToolCategory {- const base = name.replace(/^subagent:/, '');- return TOOL_CATEGORIES[base] ?? 'other';+ return describeToolCall({ name }).category;}-/** Plural-aware verb phrase per category, e.g. `read` + 2 → "Read 2 files". */-const CATEGORY_PHRASE: Record<- ToolCategory,- { verb: string; noun: [singular: string, plural: string] }-> = {- read: { verb: 'Read', noun: ['file', 'files'] },- write: { verb: 'Edited', noun: ['file', 'files'] },- search: { verb: 'Ran', noun: ['search', 'searches'] },- run: { verb: 'Ran', noun: ['command', 'commands'] },- fetch: { verb: 'Fetched', noun: ['page', 'pages'] },- browse: { verb: 'Browsed', noun: ['page', 'pages'] },- other: { verb: 'Ran', noun: ['step', 'steps'] },-};+const STEPS_KEY = { one: 'conversations.tools.steps.one', other: 'conversations.tools.steps.other' };+const STEPS_EN = { one: '{count} step', other: '{count} steps' };++/** "3 steps" in the caller's locale. */+export function formatStepCount(count: number, t?: Translate): string {+ const form = count === 1 ? 'one' : 'other';+ const template = t ? t(STEPS_KEY[form], STEPS_EN[form]) : STEPS_EN[form];+ return fillPlaceholders(template, { count: String(count) });+}/**- * Summarize a group of consecutive tool rows into a single Hermes-style- * header — "Viewed 2 files", "Ran 3 commands", or, for a mixed group, the- * distinct category phrases joined ("Edited a file, read a file"). A- * single-row group defers to that row's specific label (more informative- * than a generic count). Pure + deterministic for unit testing.+ * Summarize a group of tool rows for a timeline header.+ *+ * One row reads as that row's own label. Several read as a step count plus+ * the distinct things done, most frequent first, e.g. "6 steps · Read file+ * ×3, Searched the web ×2, Ran command". Labels come from the registry, so+ * the summary is translated with the rows and never invents a category+ * phrase that disagrees with them.*/-export function summarizeToolGroup(entries: ToolTimelineEntry[]): string {+export function summarizeToolGroup(entries: ToolTimelineEntry[], t?: Translate): string {if (entries.length === 0) return '';- if (entries.length === 1) {- return formatTimelineEntry(entries[0]).title;- }- // Count per category, preserving first-seen order.- const order: ToolCategory[] = [];- const counts = new Map<ToolCategory, number>();+ if (entries.length === 1) return formatTimelineEntry(entries[0], t).title;+ const counts = new Map<string, number>();for (const entry of entries) {- const cat = categorizeTool(entry.name);- if (!counts.has(cat)) order.push(cat);- counts.set(cat, (counts.get(cat) ?? 0) + 1);+ const label = toolLabel({ ...presentTimelineEntry(entry), tense: 'done' }, t);+ counts.set(label, (counts.get(label) ?? 0) + 1);}- const phrases = order.map((cat, i) => {- const n = counts.get(cat) ?? 0;- const { verb, noun } = CATEGORY_PHRASE[cat];- const word = n === 1 ? noun[0] : noun[1];- const phrase = `${verb} ${n} ${word}`;- // Lowercase the leading verb on all but the first phrase so the joined- // sentence reads naturally ("Edited a file, ran 2 commands").- return i === 0 ? phrase : phrase.charAt(0).toLowerCase() + phrase.slice(1);- });- return phrases.join(', ');+ const parts = [...counts.entries()]+ .sort((a, b) => b[1] - a[1])+ .slice(0, 3)+ .map(([label, n]) => (n > 1 ? `${label} ×${n}` : label));+ if (counts.size > 3) parts.push('…');+ return `${formatStepCount(entries.length, t)} · ${parts.join(', ')}`;}-export function formatTimelineEntry(entry: ToolTimelineEntry): { title: string; detail?: string } {- const parsedArgs = parseToolArgs(entry.argsBuffer);-- if (entry.name === 'spawn_subagent' && parsedArgs?.agent_id === 'integrations_agent') {- const provider =- inferIntegrationName(parsedArgs.toolkit) ?? inferIntegrationNameFromPrompt(parsedArgs.prompt);- return {- title: provider ? integrationActivityTitle(provider) : 'Checking your connected app',- detail: parsedArgs.prompt?.trim() || entry.detail,- };- }-- if (entry.name === 'integrations_agent' || entry.name === 'subagent:integrations_agent') {- const provider =- inferIntegrationName(entry.sourceToolName) ??- inferIntegrationName(parsedArgs?.toolkit) ??- inferIntegrationNameFromPrompt(entry.detail) ??- inferIntegrationNameFromPrompt(parsedArgs?.prompt);-- return {- title: provider ? integrationActivityTitle(provider) : 'Checking your connected app',- detail: entry.detail,- };- }-- if (entry.name === 'subagent:researcher' || entry.name === 'researcher') {- return { title: 'Researching', detail: entry.detail };- }- if (entry.name === 'agent_prepare_context') {- return { title: 'Preparing context', detail: parsedArgs?.question?.trim() || entry.detail };- }- if (entry.name === 'subagent:context_scout' || entry.name === 'context_scout') {- return { title: 'Scouting context', detail: entry.detail };- }- if (entry.name === 'composio_list_connections') {- return { title: 'Viewing your Connections', detail: entry.detail };- }- if (entry.name === 'subagent:orchestrator' || entry.name === 'orchestrator') {- return { title: 'Planning next steps', detail: entry.detail };- }- if (entry.name === 'subagent:critic' || entry.name === 'critic') {- return { title: 'Reviewing the work', detail: entry.detail };- }- if (entry.name === 'subagent:tools_agent' || entry.name === 'tools_agent') {- return { title: 'Using tools', detail: entry.detail };- }- if (entry.name === 'subagent:code_executor' || entry.name === 'code_executor') {- return { title: 'Running code', detail: entry.detail };- }-- if (entry.name.startsWith('delegate_')) {- const provider =- inferIntegrationName(parsedArgs?.toolkit) ??- inferIntegrationNameFromPrompt(parsedArgs?.prompt) ??- inferIntegrationName(entry.name);-- const title = provider ? integrationActivityTitle(provider) : humanizeIdentifier(entry.name);- return { title, detail: entry.detail ?? parsedArgs?.prompt };- }-- // A connected-service action called directly (`GMAIL_SEND_EMAIL`,- // `SLACK_SEND_MESSAGE`): the orchestrator finds these through- // `tool_search` and calls them itself, so this is the row a user sees- // for "send that email". Label it by the service, with the action as- // the detail, rather than a raw humanised slug.- const directAction = inferIntegrationActionName(entry.name);- if (directAction) {- return {- title: integrationActivityTitle(directAction.provider),- detail: entry.detail ?? directAction.action,- };- }-- // ── Tool-specific formatting with args-derived detail ──────────────- // Pass the completed result text so args-aware formatters can surface- // details only known post-execution (e.g. the resolved search provider).- const toolDetail = formatToolDetail(entry.name, parsedArgs, entry.result);- if (toolDetail) {- return { title: toolDetail.title, detail: toolDetail.detail ?? entry.detail };+/**+ * Title and detail for one timeline row. The title is tense-aware ("Reading+ * file" while running, "Read file" once settled); the detail is the row's+ * target, or for a delegation the full prompt the agent was given.+ */+export function formatTimelineEntry(+ entry: ToolTimelineEntry,+ t?: Translate+): { title: string; detail?: string } {+ const presentation = presentTimelineEntry(entry);+ const title = toolLabel(presentation, t);+ if (presentation.category === 'agent') {+ return { title, detail: entry.detail ?? presentation.chip };}-- return {- title: entry.displayName ?? humanizeIdentifier(entry.name),- detail: entry.detail ?? parsedArgs?.prompt,- };+ return { title, detail: presentation.chip ?? entry.detail };}/*** A render block for the "View processing" panel — either a prose block* (the agent's narration or hidden reasoning) or a group of consecutive- * tool rows under a Hermes-style summary. {@link buildProcessingBlocks}- * derives an ordered list of these from the interleaved transcript.+ * tool rows under a summary. {@link buildProcessingBlocks} derives an+ * ordered list of these from the interleaved transcript.*/type ProcessingBlock =| { kind: 'narration'; key: string; text: string }@@ -355,9 +135,9 @@ type ProcessingBlock =/*** Turn the ordered transcript (narration / thinking / tool-call pointers)- * plus the tool timeline into the interleaved Hermes render model: prose- * flows inline, and runs of consecutive tool calls collapse into one group- * with a summary header. Tool pointers are resolved against `entries` by id;+ * plus the tool timeline into the interleaved render model: prose flows+ * inline, and runs of consecutive tool calls collapse into one group with a+ * summary header. Tool pointers are resolved against `entries` by id;* unknown ids are skipped. Pure + deterministic for unit testing.** When `transcript` is empty (legacy snapshot / pre-streaming row), returns a@@ -365,13 +145,14 @@ type ProcessingBlock =*/export function buildProcessingBlocks(transcript: PersistedTranscriptItem[],- entries: ToolTimelineEntry[]+ entries: ToolTimelineEntry[],+ t?: Translate): ProcessingBlock[] {const byId = new Map(entries.map(e => [e.id, e]));if (transcript.length === 0) {return entries.length > 0- ? [{ kind: 'toolGroup', key: 'all', summary: summarizeToolGroup(entries), entries }]+ ? [{ kind: 'toolGroup', key: 'all', summary: summarizeToolGroup(entries, t), entries }]: [];}@@ -384,7 +165,7 @@ export function buildProcessingBlocks(blocks.push({kind: 'toolGroup',key: `tg-${group[0].id}`,- summary: summarizeToolGroup(group),+ summary: summarizeToolGroup(group, t),entries: group,});group = [];@@ -407,54 +188,67 @@ export function buildProcessingBlocks(}export function promptFromArgsBuffer(argsBuffer?: string): string | undefined {- return parseToolArgs(argsBuffer)?.prompt?.trim() || undefined;+ const prompt = parseArgsObject(argsBuffer)?.prompt;+ return typeof prompt === 'string' ? prompt.trim() || undefined : undefined;}-/** A web source an agent fetched/browsed during a run. */+/** A web source an agent fetched, browsed or found during a run. */export interface AgentSource {- /** Stable id (the originating timeline entry id). */+ /** Stable id (the originating timeline entry id, plus a hit index for searches). */id: string;- /** Display title — the URL hostname. */+ /** Display title — the page title for a search hit, else the URL hostname. */title: string;/** Full URL. */url: string;}/** Tools whose `url` arg represents a real web source the agent visited. */-const URL_SOURCE_TOOLS = new Set(['web_fetch', 'http_request', 'curl', 'browser', 'browser_open']);+const URL_SOURCE_TOOLS = new Set([+ 'web_fetch',+ 'http_request',+ 'curl',+ 'browser',+ 'browser_open',+ 'tinyfish_fetch',+ 'gitbooks_get_page',+]);/**- * Extract the distinct web sources an agent run touched, for the- * "Agent Process Source" panel. Derived from real `url` args on- * fetch/browse timeline entries — never fabricated. Deduplicated by URL,- * preserving first-seen order.+ * Extract the distinct web sources an agent run touched, for the sources+ * list under an answer. Two kinds, both from real data, never fabricated:+ * the `url` argument of fetch/browse calls, and the hits a completed web+ * search returned. Deduplicated by URL, first-seen order.*/export function extractAgentSources(entries: ToolTimelineEntry[]): AgentSource[] {const seen = new Set<string>();const sources: AgentSource[] = [];+ const add = (source: AgentSource) => {+ // `url` is model- or provider-supplied — prompt-injection-influenceable+ // and not guaranteed to be a real web address. Only http(s) sources may+ // reach an `<a href>`, so a `javascript:` / `data:` / `file:` value never+ // becomes clickable.+ if (!source.url || seen.has(source.url) || !isHttpUrl(source.url)) return;+ seen.add(source.url);+ sources.push(source);+ };for (const entry of entries) {- const baseName = entry.name.replace(/^subagent:/, '');- if (!URL_SOURCE_TOOLS.has(baseName)) continue;- const url = parseToolArgs(entry.argsBuffer)?.url?.trim();- // `url` is the raw tool-call argument the model emitted — it is- // prompt-injection-influenceable and not guaranteed to be a real web- // address. Only surface http(s) sources as clickable links so a- // `javascript:` / `data:` / `file:` value can never reach an `<a href>`.- if (!url || seen.has(url) || !isHttpUrl(url)) continue;- seen.add(url);- sources.push({ id: entry.id, title: hostnameFromUrl(url) ?? url, url });+ const presentation = presentTimelineEntry(entry);+ if (presentation.body === 'webSearch' && entry.status === 'success') {+ const parsed = parseWebSearchResult(entry.result, entry.structured);+ parsed?.results.forEach((hit, index) =>+ add({ id: `${entry.id}#${index}`, title: hit.title, url: hit.url })+ );+ continue;+ }+ if (!URL_SOURCE_TOOLS.has(presentation.baseName)) continue;+ const url = parseArgsObject(entry.argsBuffer)?.url;+ if (typeof url !== 'string') continue;+ const trimmed = url.trim();+ add({ id: entry.id, title: hostnameFromUrl(trimmed) ?? trimmed, url: trimmed });}return sources;}-const MAX_DETAIL_LEN = 120;--function truncateDetail(value: string): string {- const cleaned = value.trim().replace(/\s+/g, ' ');- if (cleaned.length <= MAX_DETAIL_LEN) return cleaned;- return `${cleaned.slice(0, MAX_DETAIL_LEN - 1)}…`;-}-function hostnameFromUrl(url: string): string | undefined {try {return new URL(url).hostname;@@ -473,12 +267,6 @@ function isHttpUrl(url: string): boolean {}}-function shortenPath(filePath: string): string {- const parts = filePath.split('/');- if (parts.length <= 3) return filePath;- return `…/${parts.slice(-2).join('/')}`;-}-/** Upper bound on a provider label, so a malformed marker can't blow up a row. */const MAX_SEARCH_PROVIDER_LENGTH = 32;@@ -487,8 +275,8 @@ const MAX_SEARCH_PROVIDER_LENGTH = 32;* Every search engine tags its output with a `(via <Provider>)` marker on the* heading line (managed resolves to "Exa" by default, or to whatever the* backend reports; BYOK engines tag "Brave"/"Querit"/"Seltz"/"Tavily"). Reading it back- * keeps the timeline attribution dynamic: it is driven by what actually ran,- * never by a hardcoded provider name (#5136).+ * keeps the attribution dynamic: it is driven by what actually ran, never by+ * a hardcoded provider name (#5136).** Only the first line is inspected, and only its *trailing* marker, so neither* a `(via …)` string inside a result excerpt nor one inside the echoed query@@ -499,251 +287,19 @@ const MAX_SEARCH_PROVIDER_LENGTH = 32;export function extractSearchProvider(result: string | undefined): string | undefined {if (!result) return undefined;const headingLine = result.split('\n', 1)[0];- const provider = headingLine?.match(/\(via ([^)]+)\)\s*$/i)?.[1]?.trim();+ const provider = headingLine?.match(/\(via ([^)]+)\)\s*_?$/i)?.[1]?.trim();if (!provider || provider.length > MAX_SEARCH_PROVIDER_LENGTH) return undefined;return provider;}-function formatToolDetail(- name: string,- args: ParsedToolArgs | null,- result?: string-): { title: string; detail?: string } | null {- switch (name) {- case 'shell':- case 'node_exec':- case 'npm_exec': {- const cmd = args?.command?.trim();- return { title: 'Running command', detail: cmd ? truncateDetail(cmd) : undefined };- }-- case 'web_fetch':- case 'http_request':- case 'curl': {- const url = args?.url?.trim();- const host = url ? hostnameFromUrl(url) : undefined;- return {- title: host ? `Fetching ${host}` : 'Fetching',- detail: url ? truncateDetail(url) : undefined,- };- }-- // `web_search_tool` is the name the core streams; `web_search` is kept for- // the settings-family id and older persisted rows.- case 'web_search':- case 'web_search_tool': {- const query = args?.query?.trim();- // Once the call completes, attribute the search to the provider that- // actually served it ("Searched with Exa"); the query moves to the- // detail line so it stays visible.- const provider = extractSearchProvider(result);- if (provider) {- return {- title: `Searched with ${provider}`,- detail: query ? truncateDetail(query) : undefined,- };- }- return { title: query ? `Searching: ${truncateDetail(query)}` : 'Searching the web' };- }-- case 'gitbooks_search': {- const query = args?.query?.trim();- return { title: query ? `Searching docs: ${truncateDetail(query)}` : 'Searching docs' };- }-- case 'file_read': {- const p = args?.path?.trim() ?? args?.file_path?.trim();- return { title: 'Reading file', detail: p ? shortenPath(p) : undefined };- }-- case 'file_write':- case 'vault_write_markdown': {- const p = args?.path?.trim() ?? args?.file_path?.trim();- return { title: 'Writing file', detail: p ? shortenPath(p) : undefined };- }-- case 'edit':- case 'apply_patch': {- const p = args?.path?.trim() ?? args?.file_path?.trim();- return { title: 'Editing file', detail: p ? shortenPath(p) : undefined };- }-- case 'grep': {- const pat = args?.pattern?.trim();- return { title: pat ? `Searching: ${truncateDetail(pat)}` : 'Searching code' };- }-- case 'glob': {- const pat = args?.pattern?.trim();- return { title: pat ? `Finding: ${truncateDetail(pat)}` : 'Finding files' };- }-- case 'list': {- const p = args?.path?.trim();- return { title: 'Listing directory', detail: p ? shortenPath(p) : undefined };- }-- case 'git_operations': {- const cmd = args?.command?.trim();- if (cmd) {- const verb = cmd.split(/\s+/)[0];- return { title: `Git ${verb}`, detail: truncateDetail(cmd) };- }- return { title: 'Git operation' };- }-- case 'browser':- case 'browser_open': {- const url = args?.url?.trim();- const host = url ? hostnameFromUrl(url) : undefined;- return { title: host ? `Browsing ${host}` : 'Browsing' };- }-- case 'image_info':- return { title: 'Analyzing image' };-- case 'install_tool': {- const tn = args?.tool_name?.trim();- return { title: tn ? `Installing ${tn}` : 'Installing tool' };- }-- case 'lsp':- return { title: 'Code intelligence' };-- case 'run_tests':- return { title: 'Running tests' };-- case 'run_linter':- return { title: 'Running linter' };-- case 'read_diff':- return { title: 'Reading diff' };-- default:- return null;- }-}--/**- * Recognise the small set of known integration toolkit slugs. Used to- * gate `inferIntegrationName` so unknown `delegate_<x>` names (e.g.- * `delegate_summarize`, `delegate_router`) don't get fake-humanised- * into bogus "integration" labels in the tool timeline.- */-const KNOWN_TOOLKIT_RE =- /^(gmail|notion|github|slack|discord|linear|jira|google_calendar|google_drive|calendar)$/i;--function inferIntegrationName(input?: string): string | undefined {- if (!input) return undefined;-- const delegateMatch = input.match(/^delegate_(.+)$/);- if (delegateMatch && KNOWN_TOOLKIT_RE.test(delegateMatch[1])) {- return normalizeIntegrationName(delegateMatch[1]);- }-- if (KNOWN_TOOLKIT_RE.test(input)) {- return normalizeIntegrationName(input);- }-- return undefined;-}--/**- * Split a Composio action slug (`GMAIL_SEND_EMAIL`) into its known provider- * and a readable action ("Send email"). `undefined` for anything that is not- * an upper-case `<TOOLKIT>_<ACTION>` name on a known toolkit, so ordinary- * tools and unknown toolkits keep their generic label.- */-function inferIntegrationActionName(- name: string-): { provider: string; action: string } | undefined {- if (!/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/.test(name)) return undefined;- // Try the longest toolkit prefix first (`GOOGLE_CALENDAR_...`), then the- // shortest (`GMAIL_...`).- const parts = name.split('_');- for (let i = Math.min(parts.length - 1, 2); i >= 1; i -= 1) {- const toolkit = parts.slice(0, i).join('_');- if (KNOWN_TOOLKIT_RE.test(toolkit)) {- const action = parts.slice(i).join(' ').toLowerCase();- return {- provider: normalizeIntegrationName(toolkit),- action: action.charAt(0).toUpperCase() + action.slice(1),- };- }- }- return undefined;-}--function integrationActivityTitle(provider: string): string {- switch (provider) {- case 'GitHub':- case 'Gmail':- case 'Linear':- case 'Jira':- return `Making requests to your ${provider} account`;- case 'Notion':- return 'Working in your Notion workspace';- case 'Slack':- case 'Discord':- return `Working in your ${provider} workspace`;- case 'Google Calendar':- return 'Updating your Google Calendar';- case 'Google Drive':- return 'Working in your Google Drive';- default:- return `Checking your ${provider}`;- }-}--function inferIntegrationNameFromPrompt(prompt?: string): string | undefined {- if (!prompt) return undefined;- const known = [- 'Notion',- 'Gmail',- 'GitHub',- 'Slack',- 'Discord',- 'Linear',- 'Jira',- 'Google Calendar',- 'Google Drive',- ];-- const lower = prompt.toLowerCase();- return known.find(name => lower.includes(name.toLowerCase()));-}--function parseToolArgs(argsBuffer?: string): ParsedToolArgs | null {+function parseArgsObject(argsBuffer?: string): Record<string, unknown> | null {if (!argsBuffer) return null;try {- const parsed = JSON.parse(argsBuffer) as ParsedToolArgs;- return parsed && typeof parsed === 'object' ? parsed : null;+ const parsed: unknown = JSON.parse(argsBuffer);+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed)+ ? (parsed as Record<string, unknown>)+ : null;} catch {return null;}}--function normalizeIntegrationName(value: string): string {- switch (value.toLowerCase()) {- case 'github':- return 'GitHub';- case 'gmail':- return 'Gmail';- case 'google_calendar':- case 'calendar':- return 'Google Calendar';- case 'google_drive':- return 'Google Drive';- default:- return humanizeIdentifier(value);- }-}--function humanizeIdentifier(value: string | undefined | null): string {- if (!value) return '';- return value- .replace(/^subagent:/, '')- .replace(/^delegate_/, '')- .replace(/_/g, ' ')- .replace(/\b\w/g, char => char.toUpperCase());-}diff --git a/crates/openhuman-core/src/platform/socket/medulla/envelope_tests.rs b/crates/openhuman-core/src/platform/socket/medulla/envelope_tests.rsindex 6371340f66..3f26378d9d 100644--- a/crates/openhuman-core/src/platform/socket/medulla/envelope_tests.rs+++ b/crates/openhuman-core/src/platform/socket/medulla/envelope_tests.rs@@ -132,6 +132,9 @@ fn tool_call_and_result_map_to_their_kinds() {elapsed_ms: 5,iteration: 1,failure: None,+ display_label: None,+ display_detail: None,+ structured: None,};match progress_to_event_kind(&completed) {Some(HarnessEventKind::ToolResult(tr)) => {