moi-computer 0.8.1-next.0 → 0.9.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/client/assets/hermes.png +0 -0
  2. package/client/components/shared/IconGhost.tsx +15 -18
  3. package/client/components/ui/button.tsx +2 -2
  4. package/client/components/ui/hover-card.tsx +1 -1
  5. package/client/components/ui/popover.tsx +3 -1
  6. package/client/features/chat/ChatEmptyState.tsx +25 -7
  7. package/client/features/chat/ChatPanel.tsx +70 -28
  8. package/client/features/chat/ChatPopup.tsx +3 -2
  9. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  10. package/client/features/chat/MarkdownContent.tsx +1 -1
  11. package/client/features/chat/attachment-staging.ts +153 -0
  12. package/client/features/chat/chat-send.ts +55 -0
  13. package/client/features/chat/chat-store.ts +32 -8
  14. package/client/features/chat/composer/ChatComposer.tsx +190 -77
  15. package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
  16. package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
  17. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
  18. package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
  19. package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
  20. package/client/features/chat/tool-group/format/claude.ts +48 -0
  21. package/client/features/chat/tool-group/format/codex.ts +126 -0
  22. package/client/features/chat/tool-group/format/hermes.ts +68 -0
  23. package/client/features/chat/tool-group/format/index.ts +34 -0
  24. package/client/features/chat/tool-group/format/mcp.ts +64 -0
  25. package/client/features/chat/tool-group/format/openclaw.ts +116 -0
  26. package/client/features/chat/tool-group/format/shared.ts +49 -0
  27. package/client/features/chat/useChat.ts +5 -10
  28. package/client/features/dev/ChatStatesPage.tsx +40 -2
  29. package/client/features/drawings/DrawingLayer.tsx +49 -0
  30. package/client/features/drawings/DrawingToolbar.tsx +95 -0
  31. package/client/features/drawings/annotation-availability.ts +10 -0
  32. package/client/features/drawings/capture-element.ts +45 -0
  33. package/client/features/drawings/useChatAnnotation.ts +222 -0
  34. package/client/features/drawings/useDrawingLayer.ts +758 -0
  35. package/client/features/drawings/useViewBuilderSketch.ts +151 -0
  36. package/client/features/home/workspace-presentation.tsx +6 -2
  37. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +12 -6
  38. package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
  39. package/client/features/views/ViewBuilder.tsx +224 -0
  40. package/client/features/views/api.ts +1 -0
  41. package/client/features/views/useViewBuilderActions.ts +24 -3
  42. package/client/features/views/useViewBuilderDrafts.ts +66 -0
  43. package/client/features/widgets/Widgets.tsx +23 -39
  44. package/client/features/workspace/CustomizePanel.tsx +1 -1
  45. package/client/features/workspace/WorkspaceScreen.tsx +157 -57
  46. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  47. package/client/features/workspace/useFitsSplitLayout.ts +14 -8
  48. package/client/index.css +8 -0
  49. package/client/store/ui.ts +19 -0
  50. package/client/theme.css +33 -8
  51. package/dist/chunk-3becmq75.js +81 -0
  52. package/dist/{chunk-kkj86722.js → chunk-6w6j9g4b.js} +78 -78
  53. package/dist/{chunk-xeyxk7ep.js → chunk-8ew39cvq.js} +4 -4
  54. package/dist/chunk-c8gtrjwp.js +1 -0
  55. package/dist/{chunk-2vaafjp4.js → chunk-pp62fnxh.js} +1 -1
  56. package/dist/{chunk-35fq49qa.js → chunk-sxc24vfp.js} +1 -1
  57. package/dist/{chunk-xzx7c9hq.js → chunk-v964b5g7.js} +1 -1
  58. package/dist/chunk-zx33ts9d.css +1 -0
  59. package/dist/hermes-pznd63x9.png +0 -0
  60. package/dist/index.html +1 -1
  61. package/lib/format.ts +21 -7
  62. package/lib/themes.ts +8 -8
  63. package/lib/types.ts +8 -1
  64. package/lib/workspace-types.ts +2 -1
  65. package/package.json +6 -4
  66. package/server/api.ts +21 -2
  67. package/server/bundler/build-applet.ts +35 -44
  68. package/server/cli-env.ts +2 -2
  69. package/server/cli.ts +227 -56
  70. package/server/constants.ts +8 -0
  71. package/server/control-client.ts +124 -0
  72. package/server/control.ts +2 -2
  73. package/server/harness/README.md +74 -23
  74. package/server/harness/acp/adapter.ts +220 -0
  75. package/server/harness/acp/archived.ts +88 -0
  76. package/server/harness/acp/client.ts +328 -0
  77. package/server/harness/acp/discovery.ts +130 -0
  78. package/server/harness/acp/run-durations.ts +68 -0
  79. package/server/harness/acp/session.ts +788 -0
  80. package/server/harness/acp/wire.ts +132 -0
  81. package/server/harness/executable.ts +15 -1
  82. package/server/harness/hermes/NOTES.md +815 -0
  83. package/server/harness/hermes/discovery.ts +155 -0
  84. package/server/harness/hermes/index.ts +155 -0
  85. package/server/harness/hermes/models.ts +79 -0
  86. package/server/harness/openclaw/NOTES.md +196 -94
  87. package/server/harness/openclaw/adapter.ts +28 -55
  88. package/server/harness/openclaw/compat.ts +4 -8
  89. package/server/harness/openclaw/session.ts +257 -238
  90. package/server/harness/openclaw/strip.ts +10 -34
  91. package/server/harness/openclaw/thinking.ts +5 -53
  92. package/server/harness/registry.ts +3 -1
  93. package/server/service.ts +2 -2
  94. package/server/view-builders.ts +4 -2
  95. package/server/workspace-import.ts +30 -1
  96. package/workspace/.claude/skills/moi-workspace/SKILL.md +6 -6
  97. package/client/features/chat/tool-group/format.ts +0 -359
  98. package/client/features/views/ViewBuilderTab.tsx +0 -152
  99. package/dist/chunk-gny990qx.css +0 -1
  100. package/dist/chunk-gt7n06ef.js +0 -1
  101. package/dist/chunk-n7pga5x3.js +0 -80
  102. /package/workspace/.claude/skills/moi-workspace/{DESIGN.md → references/DESIGN.md} +0 -0
  103. /package/workspace/.claude/skills/moi-workspace/{SCRATCHPAD.md → references/SCRATCHPAD.md} +0 -0
@@ -0,0 +1,48 @@
1
+ // Claude Code vocabulary — also the default when a call carries no provider.
2
+ import type { ToolCall } from '@/lib/types'
3
+
4
+ import { getInputValue, toolInput, type Shorten, type ToolFormatter } from './shared'
5
+
6
+ // Claude tool names are mostly already presentable (Read, Bash, …); only a few
7
+ // need spacing/relabelling. Unknown names fall through to the raw name so
8
+ // plugin tools still render something.
9
+ const LABELS: Record<string, string> = {
10
+ ToolSearch: 'Tool search',
11
+ WebSearch: 'Web search',
12
+ WebFetch: 'Web fetch'
13
+ }
14
+
15
+ // Short tool label from a fully-qualified MCP tool name: `mcp__notion__notion-
16
+ // search` → `notion-search` (drop the `mcp__<server>__` prefix). Plain names
17
+ // pass through.
18
+ function shortToolName(name: string): string {
19
+ if (!name.startsWith('mcp__')) return name
20
+ const parts = name.slice(5).split('__')
21
+ return parts.length >= 2 ? parts.slice(1).join('__') : parts[0]
22
+ }
23
+
24
+ function brief(call: ToolCall, shorten: Shorten): string {
25
+ const tool = call.name
26
+ const input = toolInput(call)
27
+ if (tool === 'Bash') return shorten(`$ ${getInputValue(input, 'command')}`)
28
+ if (tool === 'Read' || tool === 'Write' || tool === 'Edit')
29
+ return shorten(getInputValue(input, 'file_path'))
30
+ if (tool === 'Glob') return shorten(getInputValue(input, 'pattern'))
31
+ if (tool === 'Grep')
32
+ return `/${getInputValue(input, 'pattern')}/ ${shorten(getInputValue(input, 'path'))}`
33
+ if (tool === 'WebSearch') return getInputValue(input, 'query')
34
+ if (tool === 'WebFetch') return getInputValue(input, 'url')
35
+ if (tool === 'ToolSearch') {
36
+ const query = getInputValue(input, 'query')
37
+ // `select:a,b,c` loads those tools → list their short names; otherwise it's a
38
+ // free-text discovery query → show it as-is.
39
+ if (query.startsWith('select:')) return query.slice(7).split(',').map(shortToolName).join(', ')
40
+ return query
41
+ }
42
+ return ''
43
+ }
44
+
45
+ export const claudeFormatter: ToolFormatter = {
46
+ displayName: call => LABELS[call.name] ?? call.name,
47
+ brief
48
+ }
@@ -0,0 +1,126 @@
1
+ // Codex vocabulary. Codex emits semantic items, which the adapter maps to a
2
+ // small fixed set of tool names (plus raw MCP tool names, which fall through
3
+ // unchanged).
4
+ import type { ToolCall } from '@/lib/types'
5
+
6
+ import { getInputValue, toolInput, type Shorten, type ToolFormatter } from './shared'
7
+
8
+ // Exported for mcp.ts: these management pseudo-tools stay plain rows, never
9
+ // the server-branded MCP card.
10
+ export const CODEX_TOOL_LABELS: Record<string, string> = {
11
+ exec: 'Bash',
12
+ apply_patch: 'Edit',
13
+ web_search: 'Web search',
14
+ update_plan: 'Update plan',
15
+ subagent: 'Run sub-agent',
16
+ subagent_activity: 'Sub-agent',
17
+ review: 'Review',
18
+ view_image: 'View image',
19
+ generate_image: 'Generate image',
20
+ // MCP-management introspection (can arrive under any server, incl. the
21
+ // "codex" pseudo-server) — plain rows, never the server-branded card.
22
+ list_mcp_resources: 'List MCP resources',
23
+ list_mcp_resource_templates: 'List MCP templates',
24
+ read_mcp_resource: 'Read MCP resource'
25
+ }
26
+
27
+ // Codex classifies each shell command itself (`commandActions`, one entry per
28
+ // piped command). When every action agrees on a type, use a CC-style semantic
29
+ // label instead of "Bash".
30
+ type CommandAction = { type?: string; name?: string; path?: string; query?: string | null }
31
+
32
+ const ACTION_LABELS: Record<string, string> = {
33
+ read: 'Read',
34
+ listFiles: 'List files',
35
+ search: 'Search'
36
+ }
37
+
38
+ function execAction(input: unknown): CommandAction | null {
39
+ const actions = (input as { commandActions?: unknown } | null)?.commandActions
40
+ if (!Array.isArray(actions) || actions.length === 0) return null
41
+ const first = actions[0] as CommandAction
42
+ const type = first?.type
43
+ if (!type || !(type in ACTION_LABELS)) return null
44
+ if (actions.some(a => (a as CommandAction)?.type !== type)) return null
45
+ return first
46
+ }
47
+
48
+ // Codex collab tool actions (`input.action` on the `subagent` card). `wait`
49
+ // never reaches the UI — the adapter drops it.
50
+ const SUBAGENT_ACTION_LABELS: Record<string, string> = {
51
+ spawn_agent: 'Run sub-agent',
52
+ send_input: 'Message the agent',
53
+ resume_agent: 'Resume the agent',
54
+ close_agent: 'Stopping the agent'
55
+ }
56
+
57
+ function displayName(call: ToolCall): string {
58
+ if (call.name === 'exec') {
59
+ const action = execAction(call.input)
60
+ if (action?.type) return ACTION_LABELS[action.type]
61
+ }
62
+ if (call.name === 'subagent') {
63
+ const action = (call.input as { action?: unknown } | null)?.action
64
+ if (typeof action === 'string' && action in SUBAGENT_ACTION_LABELS) {
65
+ return SUBAGENT_ACTION_LABELS[action]
66
+ }
67
+ }
68
+ return CODEX_TOOL_LABELS[call.name] ?? call.name
69
+ }
70
+
71
+ function brief(call: ToolCall, shorten: Shorten): string {
72
+ const tool = call.name
73
+ const input = toolInput(call)
74
+ if (tool === 'exec') {
75
+ // Semantic brief when Codex classified the command (label says Read/
76
+ // Search/List files); raw command otherwise.
77
+ const action = execAction(input)
78
+ if (action?.type === 'read') return shorten(action.path || action.name || '')
79
+ if (action?.type === 'search')
80
+ return [action.query && `/${action.query}/`, action.path && shorten(action.path)]
81
+ .filter(Boolean)
82
+ .join(' ')
83
+ if (action?.type === 'listFiles') return action.path ? shorten(action.path) : ''
84
+ return shorten(`$ ${getInputValue(input, 'command')}`)
85
+ }
86
+ if (tool === 'apply_patch') {
87
+ // The adapter sends structured per-file changes: [{ path, kind, diff }].
88
+ const changes = input.changes
89
+ if (Array.isArray(changes)) {
90
+ const paths = changes
91
+ .map(c => (c && typeof c === 'object' ? (c as { path?: unknown }).path : undefined))
92
+ .filter((p): p is string => typeof p === 'string')
93
+ .map(shorten)
94
+ return paths.join(', ')
95
+ }
96
+ return ''
97
+ }
98
+ if (tool === 'web_search') {
99
+ // Multi-query fan-outs carry every query in `queries`; single searches
100
+ // just have `query`.
101
+ const queries = input.queries
102
+ if (Array.isArray(queries) && queries.length > 0) {
103
+ return queries.filter((q): q is string => typeof q === 'string').join(' · ')
104
+ }
105
+ return getInputValue(input, 'query')
106
+ }
107
+ if (tool === 'update_plan') {
108
+ const plan = input.plan
109
+ return typeof plan === 'string' ? plan.split('\n')[0] : ''
110
+ }
111
+ if (tool === 'subagent') {
112
+ // The label already names the action; the brief carries the text being
113
+ // sent (spawn prompt, send_input/resume_agent message). close_agent has
114
+ // none — the label alone reads fine.
115
+ if (getInputValue(input, 'action') === 'close_agent') return ''
116
+ return getInputValue(input, 'prompt')
117
+ }
118
+ if (tool === 'subagent_activity') return getInputValue(input, 'kind')
119
+ if (tool === 'generate_image') return getInputValue(input, 'prompt').split('\n')[0]
120
+ if (tool === 'read_mcp_resource') return getInputValue(input, 'uri')
121
+ if (tool === 'list_mcp_resources' || tool === 'list_mcp_resource_templates')
122
+ return getInputValue(input, 'server')
123
+ return ''
124
+ }
125
+
126
+ export const codexFormatter: ToolFormatter = { displayName, brief }
@@ -0,0 +1,68 @@
1
+ // Hermes vocabulary. ACP backends send display-ready titles rather than raw
2
+ // function names, in three shapes (`acp_adapter/tools.py` build_tool_title):
3
+ // "terminal: echo hi", "todo (4 items)", "patch (replace): a.txt". The input
4
+ // is almost always empty (only file/search tools get a synthesized `{path}`
5
+ // from ACP locations), so the title is the only source for both the label and
6
+ // the brief.
7
+ import type { ToolCall } from '@/lib/types'
8
+
9
+ import type { Shorten, ToolFormatter } from './shared'
10
+
11
+ // Split the action from its parenthesized qualifier and colon detail so the
12
+ // label/brief split matches every other provider.
13
+ function splitTitle(name: string): { action: string; qualifier: string; detail: string } {
14
+ const idx = name.indexOf(':')
15
+ const head = (idx > 0 ? name.slice(0, idx) : name).trim()
16
+ const detail = idx > 0 ? name.slice(idx + 1).trim() : ''
17
+ const m = head.match(/^(.*?)\s*\(([^)]*)\)$/)
18
+ if (!m) return { action: head, qualifier: '', detail }
19
+ return { action: m[1].trim(), qualifier: m[2].trim(), detail }
20
+ }
21
+
22
+ // Keyed by the title's action part — multi-word for tools whose title embeds
23
+ // the sub-action ("process wait", "skills list"). Unmatched actions fall back
24
+ // to sentence-cased raw text, so new tools still render presentably.
25
+ const LABELS: Record<string, string> = {
26
+ terminal: 'Run command',
27
+ read: 'Read',
28
+ write: 'Write',
29
+ edit: 'Edit',
30
+ patch: 'Edit',
31
+ search: 'Search',
32
+ extract: 'Fetch webpage',
33
+ 'web extract': 'Fetch webpage',
34
+ 'web search': 'Web search',
35
+ delegate: 'Delegate task',
36
+ 'delegate batch': 'Delegate tasks',
37
+ todo: 'Update TODO',
38
+ python: 'Run Python',
39
+ 'process wait': 'Wait for process',
40
+ 'session search': 'Search sessions',
41
+ 'skills list': 'List skills',
42
+ 'skill view': 'View skill'
43
+ }
44
+
45
+ function displayName(call: ToolCall): string {
46
+ const { action } = splitTitle(call.name)
47
+ const label = LABELS[action]
48
+ if (label) return label
49
+ // Fallback-titled tools arrive as raw names ("send_message") or lowercase
50
+ // phrases ("browser snapshot") — sentence-case them.
51
+ const plain = action.replace(/_/g, ' ')
52
+ return plain.charAt(0).toUpperCase() + plain.slice(1)
53
+ }
54
+
55
+ function brief(call: ToolCall, shorten: Shorten): string {
56
+ // Paths in the detail shorten against the cwd like every other provider;
57
+ // shell commands pass through with the familiar `$` prefix. Titles without
58
+ // a colon detail surface the qualifier instead ("todo (4 items)" → "4
59
+ // items", "skill view (moi-workspace)" → "moi-workspace"); when both are
60
+ // present the qualifier is a mode ("patch (replace): a.txt") the Edit
61
+ // label already implies, so the detail wins.
62
+ const { action, qualifier, detail } = splitTitle(call.name)
63
+ const text = detail || qualifier
64
+ if (!text) return ''
65
+ return action === 'terminal' ? `$ ${text}` : shorten(text)
66
+ }
67
+
68
+ export const hermesFormatter: ToolFormatter = { displayName, brief }
@@ -0,0 +1,34 @@
1
+ // Formatting utils for tool rows: turn a raw ToolCall into the display name
2
+ // and one-line brief. Each provider vocabulary lives in its own module; this
3
+ // file only dispatches on `call.provider` and re-exports the shared helpers.
4
+ import type { ToolCall } from '@/lib/types'
5
+
6
+ import { claudeFormatter } from './claude'
7
+ import { codexFormatter } from './codex'
8
+ import { hermesFormatter } from './hermes'
9
+ import { openclawFormatter } from './openclaw'
10
+ import { makeShortenPaths, type ToolFormatter } from './shared'
11
+
12
+ export { formatDuration } from './shared'
13
+ export { formatMcpTool, parseCodexMcp, parseMcporterCall, parseNativeMcp, type McpRef } from './mcp'
14
+
15
+ const FORMATTERS: Record<NonNullable<ToolCall['provider']>, ToolFormatter> = {
16
+ 'claude-code': claudeFormatter,
17
+ openclaw: openclawFormatter,
18
+ codex: codexFormatter,
19
+ hermes: hermesFormatter
20
+ }
21
+
22
+ // Calls persisted before the provider field existed carry none — they came
23
+ // from Claude Code, which is also the default vocabulary.
24
+ function formatterFor(call: ToolCall): ToolFormatter {
25
+ return FORMATTERS[call.provider ?? 'claude-code']
26
+ }
27
+
28
+ export function getToolDisplayName(call: ToolCall): string {
29
+ return formatterFor(call).displayName(call)
30
+ }
31
+
32
+ export function formatInputBrief(call: ToolCall, cwd: string | null): string {
33
+ return formatterFor(call).brief(call, makeShortenPaths(cwd))
34
+ }
@@ -0,0 +1,64 @@
1
+ // Parsers for the three MCP call shapes — these decide when a row renders as
2
+ // the server-branded MCP card instead of a plain tool row.
3
+ import type { ToolCall } from '@/lib/types'
4
+
5
+ import { CODEX_TOOL_LABELS } from './codex'
6
+
7
+ export type McpRef = { server: string; tool: string; rest: string }
8
+
9
+ // Detect a `mcporter call <server>.<tool> [args...]` invocation inside a shell
10
+ // command. Accepts any prefix (env VAR=…, `$(which mcporter)`, `npx mcporter`),
11
+ // stops at the first command separator so a chained command doesn't bleed into
12
+ // `rest`. Returns null for non-`call` invocations.
13
+ export function parseMcporterCall(call: ToolCall): McpRef | null {
14
+ const isShell = call.name === 'Bash' || call.name === 'exec'
15
+ if (!isShell) return null
16
+ const input = (call.input as Record<string, unknown>) ?? {}
17
+ const command = typeof input.command === 'string' ? input.command : ''
18
+ if (!command) return null
19
+ const m = command.match(
20
+ /(?:^|\s|\$\()mcporter(?:\)?)\s+call\s+([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)((?:\s+(?!&&|\|\||;|\|)\S+)*)/
21
+ )
22
+ if (!m) return null
23
+ return { server: m[1], tool: m[2], rest: (m[3] ?? '').trim() }
24
+ }
25
+
26
+ // Native MCP tool calls arrive as `mcp__<server>__<tool>` (the server is encoded
27
+ // in the name; `caller` is `model` and `mcpServer` is unset). Server tokens use
28
+ // single underscores, so split on the FIRST `__` after the prefix.
29
+ // e.g. `mcp__notion__notion-search` → notion / notion-search.
30
+ export function parseNativeMcp(call: ToolCall): McpRef | null {
31
+ const name = call.name
32
+ if (!name.startsWith('mcp__')) return null
33
+ const rest = name.slice(5)
34
+ const i = rest.indexOf('__')
35
+ if (i <= 0) return null
36
+ return { server: rest.slice(0, i), tool: rest.slice(i + 2), rest: '' }
37
+ }
38
+
39
+ // Codex MCP calls arrive with a real `mcpServer` field and a plain tool name.
40
+ // Two shapes get the server-branded card:
41
+ // - a call against a configured server (`server: "codex_apps"`), where app
42
+ // tools are dotted `<app>.<tool>` (`resume_io.build_resume_with_templates`)
43
+ // — brand by the app, not the host;
44
+ // - anything else brands by the server itself.
45
+ // Codex's own MCP-management pseudo-tools (`server: "codex"`, or the
46
+ // list/read management names on any server) stay plain rows — they're
47
+ // runtime introspection, not a call INTO a server (see CODEX_TOOL_LABELS).
48
+ export function parseCodexMcp(call: ToolCall): McpRef | null {
49
+ if (call.provider !== 'codex' || !call.mcpServer) return null
50
+ if (call.name in CODEX_TOOL_LABELS) return null
51
+ if (call.mcpServer === 'codex') return null
52
+ const dot = call.name.indexOf('.')
53
+ if (dot > 0) return { server: call.name.slice(0, dot), tool: call.name.slice(dot + 1), rest: '' }
54
+ return { server: call.mcpServer, tool: call.name, rest: '' }
55
+ }
56
+
57
+ // Drop the redundant server prefix many MCP tools repeat — the icon + server name
58
+ // already identify it: `notion-search` → `search`, `notion-get-teams` →
59
+ // `get-teams`. Tools that don't repeat the server pass through unchanged.
60
+ export function formatMcpTool(server: string, tool: string): string {
61
+ const lower = tool.toLowerCase()
62
+ const sep = ['-', '_', '.'].find(s => lower.startsWith(server.toLowerCase() + s))
63
+ return sep ? tool.slice(server.length + 1) : tool
64
+ }
@@ -0,0 +1,116 @@
1
+ // OpenClaw vocabulary. An OpenClaw agent pinned to the `claude-cli` runtime
2
+ // reports Claude Code's own tool names (`Read`, `Bash`, `Edit`, …) and
3
+ // argument keys (`file_path`, not `path`), so the Claude formatter is the
4
+ // fallback for both the label and the brief before giving up.
5
+ import type { ToolCall } from '@/lib/types'
6
+
7
+ import { claudeFormatter } from './claude'
8
+ import { getInputValue, toolInput, type Shorten, type ToolFormatter } from './shared'
9
+
10
+ const LABELS: Record<string, string> = {
11
+ read: 'Read file',
12
+ write: 'Write file',
13
+ edit: 'Edit file',
14
+ apply_patch: 'Edit',
15
+ exec: 'Bash',
16
+ // 2026.7.2+ renamed the shell tool `bash` and split filesystem tools out.
17
+ bash: 'Bash',
18
+ ls: 'List files',
19
+ find: 'Find files',
20
+ grep: 'Search',
21
+ process: 'Manage process',
22
+ web_search: 'Web search',
23
+ web_fetch: 'Fetch',
24
+ sessions_list: 'List sessions',
25
+ sessions_history: 'Recall session',
26
+ sessions_yield: 'Yield to session',
27
+ sessions_send: 'Send to session',
28
+ sessions_spawn: 'Spawn session',
29
+ subagents: 'Run sub-agent',
30
+ agents_list: 'List agents',
31
+ session_status: 'Session status',
32
+ image: 'Analyze image',
33
+ image_generate: 'Generate image',
34
+ memory_get: 'Read memory',
35
+ memory_search: 'Search memory',
36
+ update_plan: 'Update plan',
37
+ message: 'Send message',
38
+ browser: 'Browser',
39
+ canvas: 'Canvas',
40
+ cron: 'Cron',
41
+ gateway: 'Gateway',
42
+ code_execution: 'Run Python',
43
+ tts: 'Text-to-speech',
44
+ music_generate: 'Generate music',
45
+ video_generate: 'Generate video',
46
+ x_search: 'Search X'
47
+ }
48
+
49
+ function openclawBrief(call: ToolCall, shorten: Shorten): string {
50
+ const tool = call.name
51
+ const input = toolInput(call)
52
+ if (tool === 'read' || tool === 'write' || tool === 'edit')
53
+ return shorten(getInputValue(input, 'path'))
54
+ if (tool === 'apply_patch') {
55
+ // The codex runtime describes an edit structurally: `{ changes: [{ path,
56
+ // kind }] }` (captured live on 2026.7.1). Name the file, or count them when
57
+ // one patch touches several.
58
+ const changes = input.changes
59
+ if (Array.isArray(changes) && changes.length > 0) {
60
+ const paths = changes
61
+ .map(c =>
62
+ c && typeof c === 'object' ? getInputValue(c as Record<string, unknown>, 'path') : ''
63
+ )
64
+ .filter(Boolean)
65
+ if (paths.length === 1) return shorten(paths[0])
66
+ if (paths.length > 1) return `${paths.length} files`
67
+ }
68
+ // Older shape: the raw patch text, whose `*** ` header names the file.
69
+ const patch = getInputValue(input, 'patch') || getInputValue(input, 'input')
70
+ const firstLine = patch.split('\n').find(l => l.startsWith('*** ')) ?? patch.split('\n')[0]
71
+ return shorten(firstLine ?? '')
72
+ }
73
+ if (tool === 'exec' || tool === 'bash') {
74
+ // `command` on 2026.7.1 + the newer `bash` tool; the 2026.7.2 exec sandbox
75
+ // instead carries a `code` script (JS that shells out) — show whichever.
76
+ const command = getInputValue(input, 'command') || getInputValue(input, 'code')
77
+ return command ? shorten(`$ ${command}`) : ''
78
+ }
79
+ if (tool === 'ls' || tool === 'find' || tool === 'grep')
80
+ return shorten(getInputValue(input, 'path') || getInputValue(input, 'pattern'))
81
+ if (tool === 'process') {
82
+ const action = getInputValue(input, 'action')
83
+ const name = getInputValue(input, 'name')
84
+ return [action, name].filter(Boolean).join(' ') || shorten(getInputValue(input, 'command'))
85
+ }
86
+ if (tool === 'web_search' || tool === 'x_search') return getInputValue(input, 'query')
87
+ if (tool === 'web_fetch') return getInputValue(input, 'url')
88
+ if (tool === 'memory_search') return getInputValue(input, 'query')
89
+ if (tool === 'memory_get') return getInputValue(input, 'key') || getInputValue(input, 'name')
90
+ if (tool === 'sessions_history' || tool === 'sessions_send' || tool === 'sessions_yield')
91
+ return getInputValue(input, 'sessionKey') || getInputValue(input, 'agentId')
92
+ if (tool === 'sessions_list' || tool === 'agents_list') return getInputValue(input, 'agentId')
93
+ if (tool === 'subagents' || tool === 'sessions_spawn')
94
+ return getInputValue(input, 'task') || getInputValue(input, 'agentId')
95
+ if (tool === 'image' || tool === 'image_generate')
96
+ return getInputValue(input, 'prompt') || shorten(getInputValue(input, 'path'))
97
+ if (tool === 'message') return getInputValue(input, 'recipient') || getInputValue(input, 'to')
98
+ if (tool === 'update_plan') {
99
+ const plan = input.plan
100
+ if (Array.isArray(plan)) {
101
+ const inProgress = plan.find(
102
+ (p): p is { step: string } =>
103
+ !!p && typeof p === 'object' && (p as { status?: unknown }).status === 'in_progress'
104
+ )
105
+ const step = inProgress?.step ?? (plan[0] as { step?: unknown })?.step
106
+ if (typeof step === 'string') return step
107
+ }
108
+ return ''
109
+ }
110
+ return ''
111
+ }
112
+
113
+ export const openclawFormatter: ToolFormatter = {
114
+ displayName: call => LABELS[call.name] ?? claudeFormatter.displayName(call),
115
+ brief: (call, shorten) => openclawBrief(call, shorten) || claudeFormatter.brief(call, shorten)
116
+ }
@@ -0,0 +1,49 @@
1
+ // Shared plumbing for the per-provider tool-row formatters. Pure functions,
2
+ // no React.
3
+ import { relative } from 'pathe'
4
+
5
+ import type { ToolCall } from '@/lib/types'
6
+
7
+ export type Shorten = (s: string) => string
8
+
9
+ // A provider's contribution to a tool row: the user-facing label and the gray
10
+ // one-line brief beside it. One implementation per provider vocabulary
11
+ // (claude.ts, openclaw.ts, codex.ts, hermes.ts); index.ts dispatches on
12
+ // `call.provider`.
13
+ export type ToolFormatter = {
14
+ displayName: (call: ToolCall) => string
15
+ brief: (call: ToolCall, shorten: Shorten) => string
16
+ }
17
+
18
+ export function toolInput(call: ToolCall): Record<string, unknown> {
19
+ return (call.input as Record<string, unknown>) ?? {}
20
+ }
21
+
22
+ export function getInputValue(input: Record<string, unknown>, key: string): string {
23
+ const value = input[key]
24
+ return typeof value === 'string' ? value : ''
25
+ }
26
+
27
+ export function makeShortenPaths(cwd: string | null): Shorten {
28
+ return s =>
29
+ s.replace(/\/[^\s"']+/g, p => {
30
+ if (!cwd) return p
31
+ const rel = relative(cwd, p)
32
+ return rel.startsWith('..') ? p : rel
33
+ })
34
+ }
35
+
36
+ // Compact wall-clock duration in whole seconds: under a minute → "3s", longer
37
+ // → "1m 5s". Used on agent-run and subagent duration labels.
38
+ //
39
+ // Never milliseconds. A column of "Thought for 514ms" / "Thought for 784ms"
40
+ // rows reads as jitter — the exact figure is noise at this size, and the
41
+ // varying width makes the list look ragged next to a plain "Thought for 1s".
42
+ // Sub-second durations round UP so a real pause never renders as "0s".
43
+ export function formatDuration(ms: number): string {
44
+ const s = Math.max(1, Math.round(ms / 1000))
45
+ if (s < 60) return `${s}s`
46
+ const m = Math.floor(s / 60)
47
+ const rem = s % 60
48
+ return rem ? `${m}m ${rem}s` : `${m}m`
49
+ }
@@ -15,11 +15,13 @@ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayo
15
15
  import { sendMessage } from '@/client/features/chat/chat-connection'
16
16
  import {
17
17
  type ChatSendOptions,
18
+ attachmentPartsForOptimisticTurn,
18
19
  attachmentsForSend,
19
20
  ownsComposerAttachments,
20
21
  resolveChatRunOptions,
21
22
  startOptimisticSession,
22
- startOptimisticTurn
23
+ startOptimisticTurn,
24
+ withAttachmentDirectives
23
25
  } from '@/client/features/chat/chat-send'
24
26
  import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
25
27
  import {
@@ -117,14 +119,7 @@ export function useChat(address: WorkspaceTabAddress) {
117
119
  // upserts in place rather than duplicating. Image attachments render from
118
120
  // their local object URL until the server's broadcast (with a data URL)
119
121
  // upserts in place.
120
- const parts: Part[] = []
121
- for (const a of ready) {
122
- if (a.upload?.kind === 'image' && a.previewUrl) {
123
- parts.push({ type: 'file', mediaType: a.mediaType, url: a.previewUrl, filename: a.name })
124
- } else {
125
- parts.push({ type: 'file', mediaType: a.mediaType, url: '', filename: a.name })
126
- }
127
- }
122
+ const parts: Part[] = attachmentPartsForOptimisticTurn(ready)
128
123
  if (text) parts.push({ type: 'text', text })
129
124
  const optimisticId = startOptimisticTurn({
130
125
  queryClient: qc,
@@ -159,7 +154,7 @@ export function useChat(address: WorkspaceTabAddress) {
159
154
  effort,
160
155
  fastMode,
161
156
  stream,
162
- context: buildMoiContext(options),
157
+ context: buildMoiContext(withAttachmentDirectives(options, ready)),
163
158
  ...(ready.length > 0 ? { attachments: ready.map(a => a.upload!.id) } : {})
164
159
  })
165
160
  useUiStore.getState().markMessageSentFromMoi(workspaceId)
@@ -33,6 +33,7 @@ import {
33
33
  WorkspaceLayoutContext,
34
34
  type WorkspaceLayoutContextValue
35
35
  } from '@/client/features/workspace/WorkspaceLayoutContext'
36
+ import { cn } from '@/client/lib/cn'
36
37
  import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
37
38
  import type { SystemNotice, Turn } from '@/lib/types'
38
39
 
@@ -70,6 +71,7 @@ const ANCHOR_BY_ITEM_ID: Record<string, string> = Object.fromEntries(
70
71
  )
71
72
 
72
73
  type TailState = 'none' | 'dots' | 'thinking' | 'text'
74
+ type BackgroundState = 'default' | 'muted'
73
75
 
74
76
  const TAIL_OPTIONS: { value: TailState; label: string }[] = [
75
77
  { value: 'none', label: 'None' },
@@ -78,6 +80,11 @@ const TAIL_OPTIONS: { value: TailState; label: string }[] = [
78
80
  { value: 'text', label: 'Text' }
79
81
  ]
80
82
 
83
+ const BACKGROUND_OPTIONS: { value: BackgroundState; label: string }[] = [
84
+ { value: 'default', label: 'Default' },
85
+ { value: 'muted', label: 'Muted' }
86
+ ]
87
+
81
88
  function tailPreviewTurn(tail: TailState): Turn | null {
82
89
  if (tail === 'thinking') return buildPreviewTurn(toLivePreview(reasoningStreamPreview))
83
90
  if (tail === 'text') return buildPreviewTurn(toLivePreview(textStreamPreview))
@@ -187,6 +194,8 @@ function SelectorHeader() {
187
194
  type TailControlsProps = {
188
195
  tail: TailState
189
196
  onTail: (tail: TailState) => void
197
+ background: BackgroundState
198
+ onBackground: (background: BackgroundState) => void
190
199
  showError: boolean
191
200
  onShowError: (show: boolean) => void
192
201
  }
@@ -194,7 +203,14 @@ type TailControlsProps = {
194
203
  // Fixed dev control for the conversation's live tail and the error banner.
195
204
  // Sits at the end of the page DOM, so it paints above the content without
196
205
  // z-index.
197
- function TailControls({ tail, onTail, showError, onShowError }: TailControlsProps) {
206
+ function TailControls({
207
+ tail,
208
+ onTail,
209
+ background,
210
+ onBackground,
211
+ showError,
212
+ onShowError
213
+ }: TailControlsProps) {
198
214
  return (
199
215
  <div className="fixed right-4 bottom-20 flex flex-col gap-2 rounded-xl bg-popover p-2 text-popover-foreground shadow-md ring-1 ring-border">
200
216
  <span className="px-1 text-xs text-muted-foreground">Live tail</span>
@@ -211,6 +227,20 @@ function TailControls({ tail, onTail, showError, onShowError }: TailControlsProp
211
227
  </Button>
212
228
  ))}
213
229
  </div>
230
+ <span className="px-1 text-xs text-muted-foreground">Background</span>
231
+ <div className="flex gap-1 rounded-lg bg-accent p-1">
232
+ {BACKGROUND_OPTIONS.map(option => (
233
+ <Button
234
+ key={option.value}
235
+ type="button"
236
+ variant={background === option.value ? 'default' : 'ghost'}
237
+ size="sm"
238
+ onClick={() => onBackground(option.value)}
239
+ >
240
+ {option.label}
241
+ </Button>
242
+ ))}
243
+ </div>
214
244
  <label className="flex items-center justify-between gap-2 px-1 text-xs text-muted-foreground">
215
245
  Error banner
216
246
  <Switch checked={showError} onCheckedChange={onShowError} />
@@ -221,6 +251,7 @@ function TailControls({ tail, onTail, showError, onShowError }: TailControlsProp
221
251
 
222
252
  export function ChatStatesPage() {
223
253
  const [tail, setTail] = useState<TailState>('text')
254
+ const [background, setBackground] = useState<BackgroundState>('default')
224
255
  const [showError, setShowError] = useState(false)
225
256
 
226
257
  // The running selector row's spinner reads the live activity store. Seed it,
@@ -246,7 +277,12 @@ export function ChatStatesPage() {
246
277
 
247
278
  return (
248
279
  <WorkspaceLayoutContext value={layoutCtxValue}>
249
- <div className="min-h-dvh bg-background font-sans text-foreground">
280
+ <div
281
+ className={cn(
282
+ 'min-h-dvh font-sans text-foreground',
283
+ background === 'default' ? 'bg-background' : 'bg-muted'
284
+ )}
285
+ >
250
286
  <div className="mx-auto flex w-full max-w-5xl gap-10 px-6 py-10">
251
287
  <nav className="sticky top-10 hidden h-fit w-44 shrink-0 flex-col gap-1.5 self-start xl:flex">
252
288
  <span className="pb-1 text-[11px] font-medium tracking-widest text-muted-foreground uppercase">
@@ -419,6 +455,8 @@ export function ChatStatesPage() {
419
455
  <TailControls
420
456
  tail={tail}
421
457
  onTail={setTail}
458
+ background={background}
459
+ onBackground={setBackground}
422
460
  showError={showError}
423
461
  onShowError={setShowError}
424
462
  />