moi-computer 0.9.0 → 0.9.1-next.1

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 (120) hide show
  1. package/client/api/app-config.ts +51 -0
  2. package/client/api/workspace-keys.ts +1 -0
  3. package/client/app/routes/WorkspaceRoute.tsx +4 -2
  4. package/client/assets/hermes.png +0 -0
  5. package/client/components/shared/IconGhost.tsx +15 -18
  6. package/client/components/ui/button.tsx +2 -2
  7. package/client/components/ui/hover-card.tsx +1 -1
  8. package/client/components/ui/popover.tsx +3 -1
  9. package/client/features/applets/api.ts +38 -0
  10. package/client/features/applets/applet-thumbnail.ts +208 -0
  11. package/client/features/chat/ChatEmptyState.tsx +30 -10
  12. package/client/features/chat/ChatPanel.tsx +67 -31
  13. package/client/features/chat/ChatPopup.tsx +3 -2
  14. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  15. package/client/features/chat/ChatSelector.tsx +29 -10
  16. package/client/features/chat/MarkdownContent.tsx +3 -3
  17. package/client/features/chat/attachment-staging.ts +153 -0
  18. package/client/features/chat/chat-send.ts +55 -0
  19. package/client/features/chat/chat-store.ts +32 -8
  20. package/client/features/chat/composer/ChatComposer.tsx +190 -77
  21. package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
  22. package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
  23. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
  24. package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
  25. package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
  26. package/client/features/chat/tool-group/format/claude.ts +48 -0
  27. package/client/features/chat/tool-group/format/codex.ts +126 -0
  28. package/client/features/chat/tool-group/format/hermes.ts +68 -0
  29. package/client/features/chat/tool-group/format/index.ts +34 -0
  30. package/client/features/chat/tool-group/format/mcp.ts +64 -0
  31. package/client/features/chat/tool-group/format/openclaw.ts +116 -0
  32. package/client/features/chat/tool-group/format/shared.ts +49 -0
  33. package/client/features/chat/useChat.ts +5 -10
  34. package/client/features/drawings/DrawingLayer.tsx +49 -0
  35. package/client/features/drawings/DrawingToolbar.tsx +95 -0
  36. package/client/features/drawings/capture-element.ts +45 -0
  37. package/client/features/drawings/useChatAnnotation.ts +222 -0
  38. package/client/features/drawings/useDrawingLayer.ts +758 -0
  39. package/client/features/drawings/useViewBuilderSketch.ts +151 -0
  40. package/client/features/home/HomePage.tsx +13 -0
  41. package/client/features/home/WorkspacePreview.tsx +10 -5
  42. package/client/features/home/workspace-presentation.tsx +6 -2
  43. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
  44. package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
  45. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +13 -7
  46. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
  47. package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
  48. package/client/features/views/ViewBuilder.tsx +238 -0
  49. package/client/features/views/ViewManager.tsx +18 -2
  50. package/client/features/views/api.ts +1 -0
  51. package/client/features/views/useViewBuilderActions.ts +24 -3
  52. package/client/features/views/useViewBuilderDrafts.ts +66 -0
  53. package/client/features/widgets/WidgetFrame.tsx +1 -1
  54. package/client/features/widgets/WidgetGrid.tsx +1 -1
  55. package/client/features/widgets/Widgets.tsx +39 -54
  56. package/client/features/workspace/CustomizePanel.tsx +30 -9
  57. package/client/features/workspace/WorkspaceScreen.tsx +158 -64
  58. package/client/features/workspace/WorkspaceTabs.tsx +3 -3
  59. package/client/features/workspace/useFitsSplitLayout.ts +14 -8
  60. package/client/index.css +8 -0
  61. package/client/index.tsx +6 -1
  62. package/client/runtime/useWorkspaceEvents.ts +17 -0
  63. package/client/runtime/workspace-theme.ts +29 -6
  64. package/client/store/ui.ts +19 -0
  65. package/client/theme.css +33 -8
  66. package/dist/chunk-5c19v3zr.js +10 -0
  67. package/dist/chunk-6wx91x8j.js +1 -0
  68. package/dist/chunk-8s41nd3g.js +1 -0
  69. package/dist/{chunk-kkj86722.js → chunk-a7fzp0z0.js} +78 -78
  70. package/dist/{chunk-2vaafjp4.js → chunk-b959mdkj.js} +1 -1
  71. package/dist/chunk-cagtq45k.js +1 -0
  72. package/dist/chunk-cva7jpt4.js +82 -0
  73. package/dist/chunk-sapvd7he.css +1 -0
  74. package/dist/{chunk-35fq49qa.js → chunk-zbeq02yc.js} +1 -1
  75. package/dist/chunk-zbt8emsw.js +2 -0
  76. package/dist/chunk-zfz3b4xg.js +2 -0
  77. package/dist/hermes-pznd63x9.png +0 -0
  78. package/dist/index.html +1 -1
  79. package/lib/format.ts +1 -1
  80. package/lib/themes.ts +8 -8
  81. package/lib/types.ts +68 -42
  82. package/lib/workspace-types.ts +2 -1
  83. package/package.json +2 -1
  84. package/server/api.ts +90 -33
  85. package/server/app-config.ts +144 -0
  86. package/server/applets.ts +17 -0
  87. package/server/cli.ts +235 -14
  88. package/server/harness/README.md +64 -17
  89. package/server/harness/acp/adapter.ts +220 -0
  90. package/server/harness/acp/archived.ts +88 -0
  91. package/server/harness/acp/client.ts +328 -0
  92. package/server/harness/acp/discovery.ts +130 -0
  93. package/server/harness/acp/run-durations.ts +68 -0
  94. package/server/harness/acp/session.ts +788 -0
  95. package/server/harness/acp/wire.ts +132 -0
  96. package/server/harness/executable.ts +15 -1
  97. package/server/harness/hermes/NOTES.md +815 -0
  98. package/server/harness/hermes/discovery.ts +155 -0
  99. package/server/harness/hermes/index.ts +155 -0
  100. package/server/harness/hermes/models.ts +79 -0
  101. package/server/harness/registry.ts +3 -1
  102. package/server/layout.ts +40 -45
  103. package/server/moi-scaffold.ts +37 -1
  104. package/server/thumbnails.ts +197 -0
  105. package/server/view-builders.ts +4 -2
  106. package/server/views.ts +10 -1
  107. package/server/widgets.ts +4 -18
  108. package/server/workspace-import.ts +30 -1
  109. package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
  110. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
  111. package/client/features/chat/tool-group/format.ts +0 -384
  112. package/client/features/views/ViewBuilderTab.tsx +0 -152
  113. package/client/features/widgets/api.ts +0 -47
  114. package/client/features/widgets/useWidgetThumbnails.ts +0 -107
  115. package/client/features/widgets/widget-snapshot.ts +0 -71
  116. package/dist/chunk-3b3rkjet.js +0 -1
  117. package/dist/chunk-gt7n06ef.js +0 -1
  118. package/dist/chunk-ty1sqbmn.js +0 -80
  119. package/dist/chunk-xeyxk7ep.js +0 -10
  120. package/dist/chunk-yz6wd5vc.css +0 -1
@@ -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)
@@ -0,0 +1,49 @@
1
+ import type { KeyboardEventHandler, PointerEventHandler, ReactNode, RefObject } from 'react'
2
+
3
+ export type DrawingCanvasPointerProps = {
4
+ onPointerDown: PointerEventHandler<HTMLCanvasElement>
5
+ onPointerMove: PointerEventHandler<HTMLCanvasElement>
6
+ onPointerUp: PointerEventHandler<HTMLCanvasElement>
7
+ onPointerCancel: PointerEventHandler<HTMLCanvasElement>
8
+ }
9
+
10
+ export type DrawingLayerProps = {
11
+ visible: boolean
12
+ editing: boolean
13
+ canvasRef: RefObject<HTMLCanvasElement | null>
14
+ width: number
15
+ height: number
16
+ pointerProps: DrawingCanvasPointerProps
17
+ onKeyDown: KeyboardEventHandler<HTMLDivElement>
18
+ children?: ReactNode
19
+ }
20
+
21
+ // The layer only renders the drawing canvas and an optional controls slot. All
22
+ // capture, history, and export behavior belongs to useDrawingLayer.
23
+ export function DrawingLayer({
24
+ visible,
25
+ editing,
26
+ canvasRef,
27
+ width,
28
+ height,
29
+ pointerProps,
30
+ onKeyDown,
31
+ children
32
+ }: DrawingLayerProps) {
33
+ if (!visible) return null
34
+
35
+ return (
36
+ <div className="absolute inset-0 animate-in duration-100 fade-in" onKeyDown={onKeyDown}>
37
+ <canvas
38
+ ref={canvasRef}
39
+ {...pointerProps}
40
+ width={width}
41
+ height={height}
42
+ aria-label="Drawing area"
43
+ tabIndex={0}
44
+ className="absolute inset-0 size-full cursor-pencil touch-none outline-none"
45
+ />
46
+ {editing && children}
47
+ </div>
48
+ )
49
+ }
@@ -0,0 +1,95 @@
1
+ import { IconArrowBackUp, IconArrowForwardUp, IconCheck, IconX } from '@tabler/icons-react'
2
+ import { AnimatePresence, motion } from 'motion/react'
3
+
4
+ import { Button } from '@/client/components/ui/button'
5
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
6
+ import { cn } from '@/client/lib/cn'
7
+
8
+ import { type DrawingControls, useDrawingHistoryState } from './useDrawingLayer'
9
+
10
+ type DrawingToolbarProps = {
11
+ controls: DrawingControls
12
+ title: string
13
+ busy: boolean
14
+ onComplete: () => void
15
+ }
16
+
17
+ export function DrawingToolbar({ controls, title, busy, onComplete }: DrawingToolbarProps) {
18
+ const { canUndo, canRedo, hasStrokes } = useDrawingHistoryState(controls)
19
+
20
+ return (
21
+ <div className="absolute bottom-3 left-1/2 flex -translate-x-1/2 items-center gap-2 rounded-lg bg-popover p-1.5 shadow-md">
22
+ <span className="mr-2 ml-2 text-sm font-medium">{title}</span>
23
+ <div className="flex gap-1">
24
+ <Tooltip>
25
+ <TooltipTrigger
26
+ render={
27
+ <Button
28
+ type="button"
29
+ variant="outline"
30
+ size="icon-sm"
31
+ onClick={controls.undo}
32
+ disabled={busy || !canUndo}
33
+ aria-label="Undo"
34
+ >
35
+ <IconArrowBackUp stroke={1.75} />
36
+ </Button>
37
+ }
38
+ />
39
+ <TooltipContent>Undo</TooltipContent>
40
+ </Tooltip>
41
+ <Tooltip>
42
+ <TooltipTrigger
43
+ render={
44
+ <Button
45
+ type="button"
46
+ variant="outline"
47
+ size="icon-sm"
48
+ onClick={controls.redo}
49
+ disabled={busy || !canRedo}
50
+ aria-label="Redo"
51
+ >
52
+ <IconArrowForwardUp stroke={1.75} />
53
+ </Button>
54
+ }
55
+ />
56
+ <TooltipContent>Redo</TooltipContent>
57
+ </Tooltip>
58
+ <Button
59
+ type="button"
60
+ variant="outline"
61
+ size="sm"
62
+ onClick={controls.clear}
63
+ disabled={busy || !hasStrokes}
64
+ >
65
+ Clear
66
+ </Button>
67
+ </div>
68
+ <AnimatePresence mode="popLayout" initial={false}>
69
+ <motion.div
70
+ key={hasStrokes ? 'complete' : 'cancel'}
71
+ variants={{
72
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
73
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
74
+ }}
75
+ initial="from"
76
+ animate="to"
77
+ exit="from"
78
+ transition={{ type: 'spring', duration: 0.1, bounce: 0 }}
79
+ >
80
+ <Button
81
+ type="button"
82
+ variant={hasStrokes ? 'default' : 'ghost'}
83
+ size="icon-sm"
84
+ onClick={onComplete}
85
+ disabled={busy}
86
+ aria-label="Complete"
87
+ className={cn(!hasStrokes && 'text-muted-foreground')}
88
+ >
89
+ {hasStrokes ? <IconCheck stroke={1.75} /> : <IconX stroke={1.75} />}
90
+ </Button>
91
+ </motion.div>
92
+ </AnimatePresence>
93
+ </div>
94
+ )
95
+ }