moi-computer 0.9.1-next.4 → 0.10.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.
- package/README.md +124 -58
- package/client/app/shell/SidebarLayout.tsx +114 -69
- package/client/assets/floppy-disk.webp +0 -0
- package/client/assets.d.ts +5 -0
- package/client/components/ui/button.tsx +2 -1
- package/client/features/chat/ChatEmptyState.tsx +70 -34
- package/client/features/chat/ChatPanel.tsx +8 -1
- package/client/features/chat/chat-store.ts +4 -0
- package/client/features/chat/tool-group/format/claude.ts +2 -1
- package/client/features/chat/tool-group/format/codex.ts +2 -1
- package/client/features/chat/tool-group/format/hermes.ts +2 -1
- package/client/features/chat/tool-group/format/mcp.ts +7 -3
- package/client/features/chat/tool-group/format/openclaw.ts +6 -2
- package/client/features/chat/tool-group/format/shell.ts +162 -0
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/dev/TextureLabPage.tsx +149 -0
- package/client/features/home/HomePage.tsx +5 -5
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +3 -3
- package/client/features/home/workspace-setup/DemoDialog.tsx +239 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +22 -5
- package/client/features/settings/GeneralSettings.tsx +27 -23
- package/client/features/update/Update.tsx +78 -0
- package/client/features/update/api.ts +35 -0
- package/client/features/widgets/WidgetFrame.tsx +1 -0
- package/client/features/workspace/WorkspaceScreen.tsx +15 -0
- package/client/index.css +2 -2
- package/client/runtime/workspace-theme.ts +12 -4
- package/client/theme.css +26 -22
- package/dist/{chunk-zbt8emsw.js → chunk-0set7tmf.js} +2 -2
- package/dist/chunk-4057kxht.css +1 -0
- package/dist/{chunk-zcyvyebg.js → chunk-5t06zksf.js} +2 -2
- package/dist/{chunk-zbeq02yc.js → chunk-97eg9mjn.js} +1 -1
- package/dist/chunk-b5c62p8h.js +1 -0
- package/dist/chunk-dfe7qnrp.js +1 -0
- package/dist/{chunk-b959mdkj.js → chunk-efdyz6xp.js} +1 -1
- package/dist/chunk-f6xmz3tn.js +83 -0
- package/dist/chunk-h2kj1ysj.js +1 -0
- package/dist/{chunk-zfz3b4xg.js → chunk-ht1f95h9.js} +2 -2
- package/dist/chunk-qtc5a8qa.js +10 -0
- package/dist/floppy-disk-wmjs0n85.webp +0 -0
- package/dist/index.html +1 -1
- package/lib/ids.ts +27 -0
- package/lib/themes.ts +12 -12
- package/lib/types.ts +11 -2
- package/lib/update.ts +2 -0
- package/package.json +2 -1
- package/server/api.ts +47 -1
- package/server/app-config.ts +2 -2
- package/server/bundler/build-applet.ts +2 -3
- package/server/cli.ts +30 -7
- package/server/constants.ts +4 -2
- package/server/registry.ts +37 -2
- package/server/update.ts +293 -5
- package/server/web.ts +1 -1
- package/client/features/home/workspace-setup/InstallMoiDialog.tsx +0 -245
- package/dist/chunk-87q78504.js +0 -1
- package/dist/chunk-8s41nd3g.js +0 -1
- package/dist/chunk-cagtq45k.js +0 -1
- package/dist/chunk-ek6zde7t.js +0 -10
- package/dist/chunk-n8tq2494.js +0 -82
- package/dist/chunk-v82nefjq.css +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IconArticle,
|
|
3
|
-
IconBriefcase,
|
|
4
3
|
IconFileSearch,
|
|
5
4
|
IconGhost,
|
|
6
5
|
IconLayout2,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
IconSketching,
|
|
10
9
|
IconTableSpark,
|
|
11
10
|
IconUmbrella2,
|
|
11
|
+
IconWallet,
|
|
12
12
|
type TablerIcon
|
|
13
13
|
} from '@tabler/icons-react'
|
|
14
14
|
|
|
@@ -24,7 +24,7 @@ const ONBOARDING_HANDOFF_DIRECTIVE =
|
|
|
24
24
|
|
|
25
25
|
export const CHAT_WELCOME_PROMPTS = [
|
|
26
26
|
{
|
|
27
|
-
label:
|
|
27
|
+
label: 'Check the weather',
|
|
28
28
|
prompt:
|
|
29
29
|
"Build me a set of weather widgets that surface current conditions, today's hourly forecast, and a simple weekly outlook at a glance",
|
|
30
30
|
context: [
|
|
@@ -38,7 +38,23 @@ export const CHAT_WELCOME_PROMPTS = [
|
|
|
38
38
|
icon: IconUmbrella2
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
label: '
|
|
41
|
+
label: 'Track my finances',
|
|
42
|
+
prompt:
|
|
43
|
+
'Build me a personal finance view for tracking income, expenses, monthly budgets, spending trends, and savings, with an agent action that can add sample transactions',
|
|
44
|
+
context: [
|
|
45
|
+
"Build this onboarding example immediately without asking follow-up questions, and don't use external services or bank connections.",
|
|
46
|
+
'Create a responsive View with a month selector, income, spending, and savings summaries, an income-versus-spending trend, category breakdowns, budget progress, and recent transactions.',
|
|
47
|
+
'Support adding, editing, and deleting income and expense transactions, categories, and monthly category budgets.',
|
|
48
|
+
'Persist transactions, categories, and budgets in a workspace-local SQLite database accessed through server functions. Store monetary amounts as integer cents and seed realistic sample data only when the database is empty.',
|
|
49
|
+
'Add an “Add with agent” action that imports `sendChatMessage` from `moi` and sends a concise request for the agent to generate and insert a realistic batch of sample transactions into the same database.',
|
|
50
|
+
'Provide a small documented workspace script the agent can use to validate and append transactions safely, then refresh the View data after the agent updates the database.',
|
|
51
|
+
'Include loading, empty, and error states, then bundle the View and smoke-test its SQLite persistence and transaction mutations before finishing.',
|
|
52
|
+
ONBOARDING_HANDOFF_DIRECTIVE
|
|
53
|
+
],
|
|
54
|
+
icon: IconWallet
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Build a playful synthesizer',
|
|
42
58
|
prompt:
|
|
43
59
|
'Build me a view with a simple, playful synthesizer featuring a keyboard, five sound controls, and the ability to record, save, and load music files from the workspace',
|
|
44
60
|
context: [
|
|
@@ -50,22 +66,6 @@ export const CHAT_WELCOME_PROMPTS = [
|
|
|
50
66
|
ONBOARDING_HANDOFF_DIRECTIVE
|
|
51
67
|
],
|
|
52
68
|
icon: IconPiano
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: 'Make a job tracker',
|
|
56
|
-
prompt:
|
|
57
|
-
'Build me a view with a visual job search board where I can add opportunities by pasting a job link, automatically extract the details, move opportunities through stages, and keep notes and related files in the workspace',
|
|
58
|
-
context: [
|
|
59
|
-
'Build this onboarding example immediately without asking follow-up questions.',
|
|
60
|
-
'Create a visual View with Saved, Applied, Interviewing, Offer, and Closed stages.',
|
|
61
|
-
'Let the user add a job by pasting its URL, and use a server function to parse public metadata for the title, company, and location.',
|
|
62
|
-
'When a page blocks parsing or lacks metadata, keep the URL and provide editable manual fields.',
|
|
63
|
-
'Support moving opportunities between stages, editing their details and notes, and referencing related workspace files.',
|
|
64
|
-
'Persist the board in a workspace-local JSON file and include loading, empty, and error states.',
|
|
65
|
-
'Bundle the View and smoke-test its persistence and parsing functions before finishing.',
|
|
66
|
-
ONBOARDING_HANDOFF_DIRECTIVE
|
|
67
|
-
],
|
|
68
|
-
icon: IconBriefcase
|
|
69
69
|
}
|
|
70
70
|
] satisfies ChatPrompt[]
|
|
71
71
|
|
|
@@ -82,6 +82,7 @@ export const WORKSPACE_ANALYSIS_PROMPT = {
|
|
|
82
82
|
} satisfies ChatPrompt
|
|
83
83
|
|
|
84
84
|
export type ChatEmptyStateKind = 'view-builder' | 'chat-welcome' | 'workspace-welcome' | 'empty'
|
|
85
|
+
export type ChatWelcomeDestination = 'agent' | 'widgets' | 'views' | 'scratchpad'
|
|
85
86
|
|
|
86
87
|
type ResolveChatEmptyStateOptions = {
|
|
87
88
|
isViewBuilderDraft: boolean
|
|
@@ -106,14 +107,22 @@ type ChatEmptyStateProps = {
|
|
|
106
107
|
kind: ChatEmptyStateKind
|
|
107
108
|
disabled?: boolean
|
|
108
109
|
onSelectPrompt: (prompt: ChatPrompt) => void
|
|
110
|
+
onNavigate: (destination: ChatWelcomeDestination) => void
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
export function ChatEmptyState({
|
|
113
|
+
export function ChatEmptyState({
|
|
114
|
+
kind,
|
|
115
|
+
disabled = false,
|
|
116
|
+
onSelectPrompt,
|
|
117
|
+
onNavigate
|
|
118
|
+
}: ChatEmptyStateProps) {
|
|
112
119
|
switch (kind) {
|
|
113
120
|
case 'view-builder':
|
|
114
121
|
return <ViewBuilderChatEmptyState />
|
|
115
122
|
case 'chat-welcome':
|
|
116
|
-
return
|
|
123
|
+
return (
|
|
124
|
+
<ChatWelcome disabled={disabled} onSelectPrompt={onSelectPrompt} onNavigate={onNavigate} />
|
|
125
|
+
)
|
|
117
126
|
case 'workspace-welcome':
|
|
118
127
|
return <ChatWorkspaceWelcome disabled={disabled} onSelectPrompt={onSelectPrompt} />
|
|
119
128
|
case 'empty':
|
|
@@ -137,7 +146,11 @@ type WelcomeProps = {
|
|
|
137
146
|
onSelectPrompt: (prompt: ChatPrompt) => void
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
|
|
149
|
+
type ChatWelcomeProps = WelcomeProps & {
|
|
150
|
+
onNavigate: (destination: ChatWelcomeDestination) => void
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function ChatWelcome({ disabled = false, onSelectPrompt, onNavigate }: ChatWelcomeProps) {
|
|
141
154
|
return (
|
|
142
155
|
<div className={cn(EMPTY_STATE_STYLES, '@container w-full max-w-md min-w-0')}>
|
|
143
156
|
<div className="prose prose-sm min-w-0 wrap-anywhere prose-inherit">
|
|
@@ -146,13 +159,25 @@ export function ChatWelcome({ disabled = false, onSelectPrompt }: WelcomeProps)
|
|
|
146
159
|
doing.
|
|
147
160
|
</p>
|
|
148
161
|
<p>
|
|
149
|
-
Ask
|
|
150
|
-
<WelcomeTerm Icon={
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
Ask{' '}
|
|
163
|
+
<WelcomeTerm Icon={IconGhost} destination="agent" onNavigate={onNavigate}>
|
|
164
|
+
Agent
|
|
165
|
+
</WelcomeTerm>{' '}
|
|
166
|
+
to build{' '}
|
|
167
|
+
<WelcomeTerm Icon={IconLayout2} destination="widgets" onNavigate={onNavigate}>
|
|
168
|
+
Widgets
|
|
169
|
+
</WelcomeTerm>{' '}
|
|
170
|
+
that surface information and quick actions, or entire{' '}
|
|
171
|
+
<WelcomeTerm Icon={IconArticle} destination="views" onNavigate={onNavigate}>
|
|
172
|
+
Views
|
|
173
|
+
</WelcomeTerm>{' '}
|
|
174
|
+
for more complex tools. Use{' '}
|
|
175
|
+
<WelcomeTerm Icon={IconSketching} destination="scratchpad" onNavigate={onNavigate}>
|
|
176
|
+
Scratchpad
|
|
177
|
+
</WelcomeTerm>{' '}
|
|
178
|
+
for exploring and shaping ideas with your agent.
|
|
154
179
|
</p>
|
|
155
|
-
<p>
|
|
180
|
+
<p>Try an example:</p>
|
|
156
181
|
</div>
|
|
157
182
|
<ChatPromptBubbles
|
|
158
183
|
prompts={CHAT_WELCOME_PROMPTS}
|
|
@@ -166,8 +191,12 @@ export function ChatWelcome({ disabled = false, onSelectPrompt }: WelcomeProps)
|
|
|
166
191
|
export function ChatWorkspaceWelcome({ disabled = false, onSelectPrompt }: WelcomeProps) {
|
|
167
192
|
return (
|
|
168
193
|
<div className={cn(EMPTY_STATE_STYLES, 'gap-2')}>
|
|
169
|
-
<div className="prose prose-sm max-w-
|
|
170
|
-
<p
|
|
194
|
+
<div className="prose prose-sm max-w-xs min-w-0 text-center wrap-anywhere prose-inherit">
|
|
195
|
+
<p className="font-medium text-foreground">Start with what’s already here</p>
|
|
196
|
+
<p className="text-muted-foreground">
|
|
197
|
+
Your agent can explore this workspace and suggest useful widgets and views based on its
|
|
198
|
+
contents.
|
|
199
|
+
</p>
|
|
171
200
|
</div>
|
|
172
201
|
<ChatPromptBubble
|
|
173
202
|
prompt={WORKSPACE_ANALYSIS_PROMPT}
|
|
@@ -192,13 +221,20 @@ function EmptyState() {
|
|
|
192
221
|
type WelcomeTermProps = {
|
|
193
222
|
Icon: TablerIcon
|
|
194
223
|
children: string
|
|
224
|
+
destination: ChatWelcomeDestination
|
|
225
|
+
onNavigate: (destination: ChatWelcomeDestination) => void
|
|
195
226
|
}
|
|
196
227
|
|
|
197
|
-
function WelcomeTerm({ Icon, children }: WelcomeTermProps) {
|
|
228
|
+
function WelcomeTerm({ Icon, children, destination, onNavigate }: WelcomeTermProps) {
|
|
198
229
|
return (
|
|
199
|
-
<
|
|
200
|
-
|
|
230
|
+
<button
|
|
231
|
+
type="button"
|
|
232
|
+
data-welcome-destination={destination}
|
|
233
|
+
onClick={() => onNavigate(destination)}
|
|
234
|
+
className="-mx-0.5 inline-flex cursor-pointer items-center gap-0.5 rounded-xs px-0.5 align-bottom font-medium text-foreground hover:bg-accent focus-visible:bg-accent focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
|
|
235
|
+
>
|
|
236
|
+
<Icon size={16} stroke={1.75} aria-hidden />
|
|
201
237
|
{children}
|
|
202
|
-
</
|
|
238
|
+
</button>
|
|
203
239
|
)
|
|
204
240
|
}
|
|
@@ -18,7 +18,11 @@ import type { SystemNotice, Turn, ViewState } from '@/lib/types'
|
|
|
18
18
|
|
|
19
19
|
import type { ComposerBanner } from './composer/banners/ComposerBanner'
|
|
20
20
|
import { ChatComposer, type ComposerAnnotationControls } from './composer/ChatComposer'
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
ChatEmptyState,
|
|
23
|
+
type ChatWelcomeDestination,
|
|
24
|
+
resolveChatEmptyState
|
|
25
|
+
} from './ChatEmptyState'
|
|
22
26
|
import { ChatSelector } from './ChatSelector'
|
|
23
27
|
import { ThinkingIndicator, TurnView } from './TurnView'
|
|
24
28
|
import { Button } from '@/client/components/ui/button'
|
|
@@ -57,6 +61,7 @@ type ChatPanelProps = {
|
|
|
57
61
|
annotation?: ComposerAnnotationControls
|
|
58
62
|
send: (text: string, options?: ChatSendOptions) => void
|
|
59
63
|
stop: () => void
|
|
64
|
+
onNavigateFromWelcome: (destination: ChatWelcomeDestination) => void
|
|
60
65
|
// Chat on a separate tab doesn't have a close button
|
|
61
66
|
onClose?: () => void
|
|
62
67
|
builderDraft?: ViewBuilderChatDraft
|
|
@@ -79,6 +84,7 @@ export function ChatPanel({
|
|
|
79
84
|
annotation,
|
|
80
85
|
send,
|
|
81
86
|
stop,
|
|
87
|
+
onNavigateFromWelcome,
|
|
82
88
|
onClose,
|
|
83
89
|
builderDraft
|
|
84
90
|
}: ChatPanelProps) {
|
|
@@ -190,6 +196,7 @@ export function ChatPanel({
|
|
|
190
196
|
kind={emptyStateKind}
|
|
191
197
|
disabled={promptDisabled}
|
|
192
198
|
onSelectPrompt={handlePromptSelect}
|
|
199
|
+
onNavigate={onNavigateFromWelcome}
|
|
193
200
|
/>
|
|
194
201
|
)}
|
|
195
202
|
{timeline.map(item =>
|
|
@@ -57,6 +57,10 @@ export function isRunningActivity(activity: SessionActivity | undefined): boolea
|
|
|
57
57
|
return activity === 'running'
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export function hasRunningActivity(activity: Record<string, SessionActivity>): boolean {
|
|
61
|
+
return Object.values(activity).some(isRunningActivity)
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
export function isSessionRunning(
|
|
61
65
|
activity: Record<string, SessionActivity>,
|
|
62
66
|
workspaceId: string,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Claude Code vocabulary — also the default when a call carries no provider.
|
|
2
2
|
import type { ToolCall } from '@/lib/types'
|
|
3
3
|
|
|
4
|
+
import { shellBrief } from './shell'
|
|
4
5
|
import { getInputValue, toolInput, type Shorten, type ToolFormatter } from './shared'
|
|
5
6
|
|
|
6
7
|
// Claude tool names are mostly already presentable (Read, Bash, …); only a few
|
|
@@ -24,7 +25,7 @@ function shortToolName(name: string): string {
|
|
|
24
25
|
function brief(call: ToolCall, shorten: Shorten): string {
|
|
25
26
|
const tool = call.name
|
|
26
27
|
const input = toolInput(call)
|
|
27
|
-
if (tool === 'Bash') return
|
|
28
|
+
if (tool === 'Bash') return shellBrief(getInputValue(input, 'command'), shorten)
|
|
28
29
|
if (tool === 'Read' || tool === 'Write' || tool === 'Edit')
|
|
29
30
|
return shorten(getInputValue(input, 'file_path'))
|
|
30
31
|
if (tool === 'Glob') return shorten(getInputValue(input, 'pattern'))
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// unchanged).
|
|
4
4
|
import type { ToolCall } from '@/lib/types'
|
|
5
5
|
|
|
6
|
+
import { shellBrief } from './shell'
|
|
6
7
|
import { getInputValue, toolInput, type Shorten, type ToolFormatter } from './shared'
|
|
7
8
|
|
|
8
9
|
// Exported for mcp.ts: these management pseudo-tools stay plain rows, never
|
|
@@ -81,7 +82,7 @@ function brief(call: ToolCall, shorten: Shorten): string {
|
|
|
81
82
|
.filter(Boolean)
|
|
82
83
|
.join(' ')
|
|
83
84
|
if (action?.type === 'listFiles') return action.path ? shorten(action.path) : ''
|
|
84
|
-
return
|
|
85
|
+
return shellBrief(getInputValue(input, 'command'), shorten)
|
|
85
86
|
}
|
|
86
87
|
if (tool === 'apply_patch') {
|
|
87
88
|
// The adapter sends structured per-file changes: [{ path, kind, diff }].
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// the brief.
|
|
7
7
|
import type { ToolCall } from '@/lib/types'
|
|
8
8
|
|
|
9
|
+
import { prettifyShellCommand } from './shell'
|
|
9
10
|
import type { Shorten, ToolFormatter } from './shared'
|
|
10
11
|
|
|
11
12
|
// Split the action from its parenthesized qualifier and colon detail so the
|
|
@@ -62,7 +63,7 @@ function brief(call: ToolCall, shorten: Shorten): string {
|
|
|
62
63
|
const { action, qualifier, detail } = splitTitle(call.name)
|
|
63
64
|
const text = detail || qualifier
|
|
64
65
|
if (!text) return ''
|
|
65
|
-
return action === 'terminal' ? `$ ${text}` : shorten(text)
|
|
66
|
+
return action === 'terminal' ? `$ ${prettifyShellCommand(text)}` : shorten(text)
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export const hermesFormatter: ToolFormatter = { displayName, brief }
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { ToolCall } from '@/lib/types'
|
|
4
4
|
|
|
5
5
|
import { CODEX_TOOL_LABELS } from './codex'
|
|
6
|
+
import { prettifyShellCommand } from './shell'
|
|
6
7
|
|
|
7
8
|
export type McpRef = { server: string; tool: string; rest: string }
|
|
8
9
|
|
|
@@ -11,11 +12,14 @@ export type McpRef = { server: string; tool: string; rest: string }
|
|
|
11
12
|
// stops at the first command separator so a chained command doesn't bleed into
|
|
12
13
|
// `rest`. Returns null for non-`call` invocations.
|
|
13
14
|
export function parseMcporterCall(call: ToolCall): McpRef | null {
|
|
14
|
-
const isShell = call.name === 'Bash' || call.name === 'exec'
|
|
15
|
+
const isShell = call.name === 'Bash' || call.name === 'exec' || call.name === 'bash'
|
|
15
16
|
if (!isShell) return null
|
|
16
17
|
const input = (call.input as Record<string, unknown>) ?? {}
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
18
|
+
const raw = typeof input.command === 'string' ? input.command : ''
|
|
19
|
+
if (!raw) return null
|
|
20
|
+
// Match against the unwrapped command: providers that hand the script to
|
|
21
|
+
// `/bin/bash -lc "…"` would otherwise leave escaped quotes inside `rest`.
|
|
22
|
+
const command = prettifyShellCommand(raw)
|
|
19
23
|
const m = command.match(
|
|
20
24
|
/(?:^|\s|\$\()mcporter(?:\)?)\s+call\s+([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)((?:\s+(?!&&|\|\||;|\|)\S+)*)/
|
|
21
25
|
)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { ToolCall } from '@/lib/types'
|
|
6
6
|
|
|
7
7
|
import { claudeFormatter } from './claude'
|
|
8
|
+
import { prettifyShellCommand, shellBrief } from './shell'
|
|
8
9
|
import { getInputValue, toolInput, type Shorten, type ToolFormatter } from './shared'
|
|
9
10
|
|
|
10
11
|
const LABELS: Record<string, string> = {
|
|
@@ -74,14 +75,17 @@ function openclawBrief(call: ToolCall, shorten: Shorten): string {
|
|
|
74
75
|
// `command` on 2026.7.1 + the newer `bash` tool; the 2026.7.2 exec sandbox
|
|
75
76
|
// instead carries a `code` script (JS that shells out) — show whichever.
|
|
76
77
|
const command = getInputValue(input, 'command') || getInputValue(input, 'code')
|
|
77
|
-
return command
|
|
78
|
+
return shellBrief(command, shorten)
|
|
78
79
|
}
|
|
79
80
|
if (tool === 'ls' || tool === 'find' || tool === 'grep')
|
|
80
81
|
return shorten(getInputValue(input, 'path') || getInputValue(input, 'pattern'))
|
|
81
82
|
if (tool === 'process') {
|
|
82
83
|
const action = getInputValue(input, 'action')
|
|
83
84
|
const name = getInputValue(input, 'name')
|
|
84
|
-
return
|
|
85
|
+
return (
|
|
86
|
+
[action, name].filter(Boolean).join(' ') ||
|
|
87
|
+
shorten(prettifyShellCommand(getInputValue(input, 'command')))
|
|
88
|
+
)
|
|
85
89
|
}
|
|
86
90
|
if (tool === 'web_search' || tool === 'x_search') return getInputValue(input, 'query')
|
|
87
91
|
if (tool === 'web_fetch') return getInputValue(input, 'url')
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Shell-command display normalization, shared by every provider's shell tool
|
|
2
|
+
// (Claude `Bash`, Codex/OpenClaw `exec`/`bash`, Hermes `terminal:` titles).
|
|
3
|
+
//
|
|
4
|
+
// Agents rarely hand us the command a person would have typed. Codex and
|
|
5
|
+
// OpenClaw hand the model's script to the login shell, so the tool input is
|
|
6
|
+
// the wrapper invocation:
|
|
7
|
+
//
|
|
8
|
+
// /bin/bash -c "sed -n '1,240p' SKILL.md && sed -n '1,240p' .moi/FIRMA.md"
|
|
9
|
+
//
|
|
10
|
+
// The wrapper is noise in a one-line brief: the shell path and `-lc` eat the
|
|
11
|
+
// width, and the inner quoting arrives escaped, so the row shows `\"` where
|
|
12
|
+
// the model wrote `"`. Rendering strips the wrapper and removes one quoting
|
|
13
|
+
// level, leaving what actually ran:
|
|
14
|
+
//
|
|
15
|
+
// sed -n '1,240p' SKILL.md && sed -n '1,240p' .moi/FIRMA.md
|
|
16
|
+
//
|
|
17
|
+
// Word splitting is `shell-quote`'s, not ours — quoting rules have too many
|
|
18
|
+
// corners (`'` inside `"`, `\d` staying literal, `$(…)` and backticks passing
|
|
19
|
+
// through) to re-derive here.
|
|
20
|
+
//
|
|
21
|
+
// Display only — nothing here feeds execution, so an unrecognized shape is
|
|
22
|
+
// never an error: every step falls back to the raw command unchanged.
|
|
23
|
+
import { parse } from 'shell-quote'
|
|
24
|
+
|
|
25
|
+
import type { Shorten } from './shared'
|
|
26
|
+
|
|
27
|
+
// `shell-quote` resolves `$VAR` through this callback, defaulting to the empty
|
|
28
|
+
// string. We render commands rather than run them, so put the variable back
|
|
29
|
+
// verbatim. Braces only survive where they carry meaning (`${FOO:-x}`); a bare
|
|
30
|
+
// `${FOO}` reads the same without them. A command or arithmetic substitution
|
|
31
|
+
// (`$(pwd)`, `$((1+2))`) arrives here as an empty key — a bare `$` restores it.
|
|
32
|
+
function keepVariable(key: string): string {
|
|
33
|
+
if (!key) return '$'
|
|
34
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) ? `$${key}` : `\${${key}}`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// `shell-quote` throws on a few malformed inputs (`${}`), and a streaming tool
|
|
38
|
+
// call can always show us a half-written command. Unparseable means "render it
|
|
39
|
+
// as it came".
|
|
40
|
+
function splitWords(command: string): ReturnType<typeof parse> | null {
|
|
41
|
+
try {
|
|
42
|
+
return parse(command, keepVariable)
|
|
43
|
+
} catch {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function basename(path: string): string {
|
|
49
|
+
return path.split('/').pop() ?? path
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Shells whose `-c` argument is a command string we can lift out. Keep this to
|
|
53
|
+
// real shells: unwrapping `docker run … sh -c …` would hide where the command
|
|
54
|
+
// ran, which is the useful part of that row.
|
|
55
|
+
const SHELLS = new Set([
|
|
56
|
+
'bash',
|
|
57
|
+
'sh',
|
|
58
|
+
'zsh',
|
|
59
|
+
'fish',
|
|
60
|
+
'dash',
|
|
61
|
+
'ash',
|
|
62
|
+
'ksh',
|
|
63
|
+
'mksh',
|
|
64
|
+
'csh',
|
|
65
|
+
'tcsh',
|
|
66
|
+
'nu',
|
|
67
|
+
'pwsh',
|
|
68
|
+
'powershell'
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
// Flags that consume the next word, so it isn't mistaken for the script
|
|
72
|
+
// (`bash -o pipefail -c …`).
|
|
73
|
+
const FLAGS_WITH_VALUE = new Set(['-o', '+o', '-O', '+O', '--rcfile', '--init-file'])
|
|
74
|
+
|
|
75
|
+
const ENV_ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/
|
|
76
|
+
|
|
77
|
+
// `-c`, plus the combined short forms shells are usually invoked with (`-lc`,
|
|
78
|
+
// `-ic`, `-euc`) and the long spellings (`--command`, pwsh's `-Command`).
|
|
79
|
+
function isCommandFlag(word: string): boolean {
|
|
80
|
+
if (/^-[a-zA-Z]*c$/.test(word)) return true
|
|
81
|
+
const lower = word.toLowerCase()
|
|
82
|
+
return lower === '--command' || lower === '-command'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// One unwrap pass: `[VAR=v …] [env] <shell> [flags] -c <script>` → `<script>`.
|
|
86
|
+
// Returns null when the command isn't that shape, which means "leave it alone".
|
|
87
|
+
function unwrapOnce(command: string): string | null {
|
|
88
|
+
// Operators, globs and comments come back as objects rather than strings;
|
|
89
|
+
// a wrapper invocation is plain words all the way to the script, so a
|
|
90
|
+
// non-string where a word belongs ends the match.
|
|
91
|
+
const words = splitWords(command)
|
|
92
|
+
if (!words || words.length < 3) return null
|
|
93
|
+
const word = (index: number): string | null => {
|
|
94
|
+
const entry = words[index]
|
|
95
|
+
return typeof entry === 'string' ? entry : null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let i = 0
|
|
99
|
+
const skipAssignments = () => {
|
|
100
|
+
while (ENV_ASSIGNMENT.test(word(i) ?? '')) i++
|
|
101
|
+
}
|
|
102
|
+
skipAssignments()
|
|
103
|
+
if (basename(word(i) ?? '') === 'env') {
|
|
104
|
+
i++
|
|
105
|
+
skipAssignments()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!SHELLS.has(basename(word(i) ?? ''))) return null
|
|
109
|
+
i++
|
|
110
|
+
|
|
111
|
+
while (i < words.length) {
|
|
112
|
+
const flag = word(i)
|
|
113
|
+
if (flag === null) return null
|
|
114
|
+
if (isCommandFlag(flag)) {
|
|
115
|
+
// The script must be the final word. `bash -c script name arg` binds the
|
|
116
|
+
// extra words to `$0`/`$1`, and a brief that dropped them would claim the
|
|
117
|
+
// run was something it wasn't.
|
|
118
|
+
if (i + 2 !== words.length) return null
|
|
119
|
+
const script = word(i + 1)?.trim()
|
|
120
|
+
return script || null
|
|
121
|
+
}
|
|
122
|
+
if (!flag.startsWith('-') && !flag.startsWith('+')) return null
|
|
123
|
+
i += FLAGS_WITH_VALUE.has(flag) ? 2 : 1
|
|
124
|
+
}
|
|
125
|
+
return null
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Strip shell wrappers down to the command that actually ran. Bounded, because
|
|
129
|
+
// wrappers nest in practice (a `bash -lc` that runs `sh -c …`) and a malformed
|
|
130
|
+
// self-similar string must not loop.
|
|
131
|
+
export function unwrapShellCommand(command: string): string {
|
|
132
|
+
let out = command
|
|
133
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
134
|
+
const inner = unwrapOnce(out)
|
|
135
|
+
if (inner === null) return out
|
|
136
|
+
out = inner
|
|
137
|
+
}
|
|
138
|
+
return out
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Flatten a command to one line: the brief is a single truncating row, so a
|
|
142
|
+
// multi-line script would otherwise render as its first line with the rest
|
|
143
|
+
// silently collapsed by the browser, and its indentation as a wide gap.
|
|
144
|
+
export function collapseCommand(command: string): string {
|
|
145
|
+
return command
|
|
146
|
+
.replace(/\\\r?\n[ \t]*/g, ' ') // line continuations: drop the backslash too
|
|
147
|
+
.replace(/[ \t]*\r?\n[ \t]*/g, ' ')
|
|
148
|
+
.replace(/[ \t]{2,}/g, ' ')
|
|
149
|
+
.trim()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// The rendered form of a shell command: wrapper stripped, one line.
|
|
153
|
+
export function prettifyShellCommand(command: string): string {
|
|
154
|
+
return collapseCommand(unwrapShellCommand(command))
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The `$ …` brief every provider's shell tool shows. Empty command → empty
|
|
158
|
+
// brief, so the row falls back to the bare label instead of a lone `$`.
|
|
159
|
+
export function shellBrief(command: string, shorten: Shorten): string {
|
|
160
|
+
const pretty = prettifyShellCommand(command)
|
|
161
|
+
return pretty ? shorten(`$ ${pretty}`) : ''
|
|
162
|
+
}
|
|
@@ -18,6 +18,11 @@ const DEV_ROUTES: DevRouteEntry[] = [
|
|
|
18
18
|
title: 'Tool calls',
|
|
19
19
|
description: 'Tool-call group fixtures: single and merged runs, live states, subagent traces.'
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
path: '/dev/textures',
|
|
23
|
+
title: 'Texture lab',
|
|
24
|
+
description: 'Every texture across color presets, dark mode, widget tokens, and vivid surfaces.'
|
|
25
|
+
},
|
|
21
26
|
{
|
|
22
27
|
path: '/dev/harness',
|
|
23
28
|
title: 'Harness debug',
|
|
@@ -3,6 +3,7 @@ import { Route, Switch } from 'wouter'
|
|
|
3
3
|
import { ChatStatesPage } from './ChatStatesPage'
|
|
4
4
|
import { DevIndexPage } from './DevIndexPage'
|
|
5
5
|
import { HarnessDebugPage } from './HarnessDebugPage'
|
|
6
|
+
import { TextureLabPage } from './TextureLabPage'
|
|
6
7
|
import { ToolCallsPage } from './ToolCallsPage'
|
|
7
8
|
|
|
8
9
|
// All /dev/* routes, colocated with their pages so the whole dev playground
|
|
@@ -15,6 +16,7 @@ export default function DevRoutes() {
|
|
|
15
16
|
<Route path="/dev/harness" component={HarnessDebugPage} />
|
|
16
17
|
<Route path="/dev/chat-states" component={ChatStatesPage} />
|
|
17
18
|
<Route path="/dev/tool-calls" component={ToolCallsPage} />
|
|
19
|
+
<Route path="/dev/textures" component={TextureLabPage} />
|
|
18
20
|
<Route path="/dev" component={DevIndexPage} />
|
|
19
21
|
</Switch>
|
|
20
22
|
)
|