moi-computer 0.3.0-next.1 → 0.3.0-next.3
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 +1 -1
- package/bunfig.toml +5 -1
- package/client/AGENTS.md +17 -2
- package/client/accept-hmr-dependencies.ts +22 -0
- package/client/api/http.ts +31 -0
- package/client/api/query-options.ts +6 -0
- package/client/api/workspace-keys.ts +18 -0
- package/client/app/AppRouter.tsx +44 -0
- package/client/app/routes/HomeRoute.tsx +13 -0
- package/client/app/routes/WorkspaceRoute.tsx +95 -0
- package/client/app/shell/SidebarLayout.tsx +196 -0
- package/client/assets/openai.svg +3 -0
- package/client/assets.d.ts +9 -0
- package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +2 -2
- package/client/components/shared/PanelHeader.tsx +9 -0
- package/client/components/shared/ReorderableList.tsx +199 -0
- package/client/components/ui/button.tsx +11 -7
- package/client/components/ui/collapsible.tsx +15 -0
- package/client/components/ui/dialog.tsx +2 -2
- package/client/components/ui/dropdown-menu.tsx +5 -5
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/input.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +13 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/externalize-react.ts +7 -1
- package/client/features/applets/AppletMount.tsx +44 -0
- package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
- package/client/{components → features/applets}/WidgetShell.tsx +5 -2
- package/client/{lib → features/applets}/applet-cache.ts +8 -0
- package/client/features/applets/applet-styles.ts +61 -0
- package/client/{hooks → features/applets}/useApplet.ts +6 -7
- package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +30 -24
- package/client/features/chat/ChatPanel.tsx +171 -0
- package/client/{components → features/chat}/ChatPopup.tsx +24 -13
- package/client/{components/ThreadSelector.tsx → features/chat/ChatSelector.tsx} +15 -13
- package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
- package/client/{components → features/chat}/ModelPicker.tsx +68 -17
- package/client/{components → features/chat}/TurnView.tsx +17 -11
- package/client/features/chat/api.ts +78 -0
- package/client/features/chat/chat-connection.ts +107 -0
- package/client/features/chat/chat-frames.ts +131 -0
- package/client/features/chat/chat-send.ts +57 -0
- package/client/{lib → features/chat}/preview-turn.ts +1 -1
- package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
- package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
- package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
- package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +14 -5
- package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
- package/client/{components → features/chat}/tool-group/format.ts +117 -0
- package/client/{hooks → features/chat}/useChat.ts +16 -44
- package/client/features/connectors/ConnectorsPage.tsx +92 -0
- package/client/features/connectors/McpMenu.tsx +145 -0
- package/client/features/connectors/api.ts +28 -0
- package/client/features/dev/DevRoutes.tsx +18 -0
- package/client/features/dev/HarnessDebugPage.tsx +468 -0
- package/client/{components/playground → features/dev}/PixelPainter.tsx +10 -21
- package/client/{components/playground → features/dev}/PlaygroundPage.tsx +10 -12
- package/client/{components/playground → features/dev}/ToolCallsPage.tsx +9 -11
- package/client/features/home/CreateWorkspaceDialog.tsx +130 -0
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
- package/client/features/home/HomeLogo.tsx +344 -0
- package/client/features/home/HomePage.tsx +214 -0
- package/client/{components → features/home}/WorkspacePreview.tsx +4 -4
- package/client/features/home/api.ts +156 -0
- package/client/features/home/workspace-presentation.tsx +44 -0
- package/client/features/scratchpad/Scratchpad.tsx +312 -0
- package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
- package/client/features/settings/EnvironmentSettings.tsx +149 -0
- package/client/features/settings/GeneralSettings.tsx +90 -0
- package/client/{components → features}/settings/IconPicker.tsx +76 -224
- package/client/features/settings/SettingsLayout.tsx +53 -0
- package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
- package/client/features/settings/api.ts +88 -0
- package/client/features/settings/icon-picker-options.ts +30 -0
- package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
- package/client/features/views/ViewBuilderTab.tsx +153 -0
- package/client/features/views/api.ts +124 -0
- package/client/features/views/useViewBuilderActions.ts +72 -0
- package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
- package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
- package/client/{components → features/widgets}/WidgetGrid.tsx +38 -29
- package/client/features/widgets/Widgets.tsx +265 -0
- package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
- package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
- package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
- package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +16 -15
- package/client/features/workspace/WorkspaceScreen.tsx +675 -0
- package/client/features/workspace/WorkspaceTabs.tsx +205 -0
- package/client/features/workspace/api.ts +56 -0
- package/client/features/workspace/useFitsSplitLayout.ts +37 -0
- package/client/global.d.ts +5 -0
- package/client/index.css +6 -45
- package/client/index.html +2 -2
- package/client/index.tsx +14 -31
- package/client/lib/app-icon-registry.ts +145 -0
- package/client/main.tsx +2 -2
- package/client/runtime/hmr-watchdog.ts +39 -0
- package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +12 -7
- package/client/store/ui.ts +5 -1
- package/client/theme.css +1 -3
- package/dist/chunk-11cab5dq.css +1 -0
- package/dist/chunk-4vf1t6v1.js +10 -0
- package/dist/chunk-6c24yndg.js +61 -0
- package/dist/chunk-6c8cwpzc.js +1 -0
- package/dist/chunk-b4b276wx.js +15 -0
- package/dist/chunk-cs8vbert.js +546 -0
- package/dist/chunk-cwqmay73.css +1 -0
- package/dist/chunk-kxmvv1ax.js +48 -0
- package/dist/chunk-pcnahct1.js +5 -0
- package/dist/chunk-rq0ar7vp.js +1 -0
- package/dist/chunk-tqd3pkg8.css +1 -0
- package/dist/chunk-vkvb3hjm.js +2 -0
- package/dist/chunk-zpxrb1ce.js +2 -0
- package/dist/index.html +3 -3
- package/dist/openai-h13pza4b.svg +3 -0
- package/lib/format.ts +2 -2
- package/lib/types.ts +56 -9
- package/lib/view-builder-meta.ts +35 -0
- package/lib/workspace-layout.ts +14 -0
- package/lib/workspace-name.ts +14 -0
- package/package.json +4 -2
- package/server/AGENTS.md +3 -3
- package/server/api.ts +279 -60
- package/server/applets.ts +1 -1
- package/server/bundle-queue.ts +19 -0
- package/server/bundler/applet-css.ts +50 -0
- package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
- package/server/cli.ts +90 -7
- package/server/control.ts +106 -8
- package/server/env-apply.ts +2 -2
- package/server/harness/README.md +228 -0
- package/server/harness/claude-code/NOTES.md +578 -0
- package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
- package/server/harness/claude-code/index.ts +124 -0
- package/server/{mcp.ts → harness/claude-code/mcp.ts} +73 -16
- package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
- package/server/harness/claude-code/sessions.ts +42 -0
- package/server/harness/codex/NOTES.md +239 -0
- package/server/harness/codex/adapter.ts +414 -0
- package/server/harness/codex/client.ts +343 -0
- package/server/harness/codex/index.ts +68 -0
- package/server/harness/codex/probe.ts +186 -0
- package/server/harness/codex/session.ts +617 -0
- package/server/harness/debug.ts +57 -0
- package/server/harness/openclaw/NOTES.md +316 -0
- package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
- package/server/harness/openclaw/index.ts +93 -0
- package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
- package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
- package/server/harness/registry.ts +36 -0
- package/server/harness/types.ts +87 -0
- package/server/layout.ts +36 -11
- package/server/moi-scaffold.ts +56 -11
- package/server/registry.ts +30 -52
- package/server/state.ts +5 -38
- package/server/status.ts +7 -46
- package/server/vendor.ts +1 -1
- package/server/view-builders.ts +428 -0
- package/server/views.ts +0 -0
- package/server/web.ts +19 -40
- package/server/workspace-init.ts +11 -25
- package/tsconfig.json +1 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +2 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
- package/client/api/workspaces.ts +0 -427
- package/client/assets/hermes-nous.png +0 -0
- package/client/components/App.tsx +0 -41
- package/client/components/ChatPanel.tsx +0 -275
- package/client/components/HomePage.tsx +0 -17
- package/client/components/McpMenu.tsx +0 -125
- package/client/components/Scratchpad.tsx +0 -935
- package/client/components/Widgets.tsx +0 -132
- package/client/components/WorkspacesPage.tsx +0 -245
- package/client/components/layout/SidebarLayout.tsx +0 -258
- package/client/components/routes/workspace/[id].tsx +0 -675
- package/client/components/routes/workspace/create.tsx +0 -155
- package/client/components/settings/SettingsPages.tsx +0 -255
- package/client/hooks/useFitsSidebar.ts +0 -34
- package/client/hooks/useScrollFade.ts +0 -38
- package/client/lib/connection.ts +0 -238
- package/dist/chunk-07qf2tv1.css +0 -1
- package/dist/chunk-w18801vn.js +0 -672
- package/dist/hermes-nous-pznd63x9.png +0 -0
- /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
- /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
- /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
- /package/client/{lib → features/chat}/group-turns.ts +0 -0
- /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
- /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
- /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
- /package/client/{components → features/chat}/tool-group/index.ts +0 -0
- /package/client/{lib → features/chat}/uploads.ts +0 -0
- /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
- /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
- /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
- /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
- /package/client/{lib → features/settings}/render-icon.ts +0 -0
- /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
- /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
- /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
- /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
- /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
|
@@ -5,6 +5,7 @@ import { IconCheck, IconCopy } from '@tabler/icons-react'
|
|
|
5
5
|
import { cn } from '@/client/lib/cn'
|
|
6
6
|
import type { ToolCall } from '@/lib/types'
|
|
7
7
|
|
|
8
|
+
import { Button } from '@/client/components/ui/button'
|
|
8
9
|
import { CodeBlock } from './CodeBlock'
|
|
9
10
|
import { detectOutput } from './detect'
|
|
10
11
|
import { formatBytes } from './format'
|
|
@@ -29,14 +30,14 @@ export function ToolOutput({ call, output, isError }: ToolOutputProps) {
|
|
|
29
30
|
<div
|
|
30
31
|
className={cn(
|
|
31
32
|
'rounded-md border',
|
|
32
|
-
isError ? 'border-
|
|
33
|
+
isError ? 'border-destructive/30 bg-destructive/10' : 'border-border bg-muted'
|
|
33
34
|
)}
|
|
34
35
|
>
|
|
35
36
|
<pre
|
|
36
37
|
className={cn(
|
|
37
38
|
PRE,
|
|
38
39
|
'break-all whitespace-pre-wrap',
|
|
39
|
-
isError ? 'text-
|
|
40
|
+
isError ? 'text-destructive' : 'text-muted-foreground'
|
|
40
41
|
)}
|
|
41
42
|
>
|
|
42
43
|
{output || '(empty)'}
|
|
@@ -84,19 +85,15 @@ function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
|
|
|
84
85
|
return (
|
|
85
86
|
<div className="flex items-center gap-1 border-b border-border px-2 py-1">
|
|
86
87
|
{options.map(([value, text]) => (
|
|
87
|
-
<
|
|
88
|
+
<Button
|
|
88
89
|
key={text}
|
|
89
90
|
type="button"
|
|
91
|
+
variant={raw === value ? 'outline' : 'ghost'}
|
|
92
|
+
size="sm"
|
|
90
93
|
onClick={() => onRaw(value)}
|
|
91
|
-
className={cn(
|
|
92
|
-
'rounded-md px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase transition-colors',
|
|
93
|
-
raw === value
|
|
94
|
-
? 'bg-background text-foreground shadow-[inset_0_0_0_1px_var(--border)]'
|
|
95
|
-
: 'text-muted-foreground hover:text-foreground'
|
|
96
|
-
)}
|
|
97
94
|
>
|
|
98
95
|
{text}
|
|
99
|
-
</
|
|
96
|
+
</Button>
|
|
100
97
|
))}
|
|
101
98
|
<div className="flex-1" />
|
|
102
99
|
<span className="text-[10px] font-medium text-muted-foreground tabular-nums">{size}</span>
|
|
@@ -123,17 +120,14 @@ function CopyButton({ text }: { text: string }) {
|
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
return (
|
|
126
|
-
<
|
|
123
|
+
<Button
|
|
127
124
|
type="button"
|
|
125
|
+
variant="ghost"
|
|
126
|
+
size="icon-sm"
|
|
128
127
|
onClick={copy}
|
|
129
128
|
aria-label={copied ? 'Copied' : 'Copy'}
|
|
130
|
-
className="flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground"
|
|
131
129
|
>
|
|
132
|
-
{copied ?
|
|
133
|
-
|
|
134
|
-
) : (
|
|
135
|
-
<IconCopy size={13} stroke={1.5} />
|
|
136
|
-
)}
|
|
137
|
-
</button>
|
|
130
|
+
{copied ? <IconCheck stroke={1.75} /> : <IconCopy stroke={1.75} />}
|
|
131
|
+
</Button>
|
|
138
132
|
)
|
|
139
133
|
}
|
|
@@ -36,6 +36,24 @@ export function parseNativeMcp(call: ToolCall): McpRef | null {
|
|
|
36
36
|
return { server: rest.slice(0, i), tool: rest.slice(i + 2), rest: '' }
|
|
37
37
|
}
|
|
38
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
|
+
|
|
39
57
|
// Drop the redundant server prefix many MCP tools repeat — the icon + server name
|
|
40
58
|
// already identify it: `notion-search` → `search`, `notion-get-teams` →
|
|
41
59
|
// `get-teams`. Tools that don't repeat the server pass through unchanged.
|
|
@@ -121,8 +139,55 @@ const CLAUDE_TOOL_LABELS: Record<string, string> = {
|
|
|
121
139
|
WebFetch: 'Web Fetch'
|
|
122
140
|
}
|
|
123
141
|
|
|
142
|
+
// Codex emits semantic items, which the adapter maps to a small fixed set of
|
|
143
|
+
// tool names (plus raw MCP tool names, which fall through unchanged).
|
|
144
|
+
const CODEX_TOOL_LABELS: Record<string, string> = {
|
|
145
|
+
exec: 'Bash',
|
|
146
|
+
apply_patch: 'Edit',
|
|
147
|
+
web_search: 'Web search',
|
|
148
|
+
update_plan: 'Update plan',
|
|
149
|
+
subagent: 'Run sub-agent',
|
|
150
|
+
subagent_activity: 'Sub-agent',
|
|
151
|
+
review: 'Review',
|
|
152
|
+
view_image: 'View image',
|
|
153
|
+
generate_image: 'Generate image',
|
|
154
|
+
// MCP-management introspection (can arrive under any server, incl. the
|
|
155
|
+
// "codex" pseudo-server) — plain rows, never the server-branded card.
|
|
156
|
+
list_mcp_resources: 'List MCP resources',
|
|
157
|
+
list_mcp_resource_templates: 'List MCP templates',
|
|
158
|
+
read_mcp_resource: 'Read MCP resource'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Codex classifies each shell command itself (`commandActions`, one entry per
|
|
162
|
+
// piped command). When every action agrees on a type, use a CC-style semantic
|
|
163
|
+
// label instead of "Bash".
|
|
164
|
+
type CodexCommandAction = { type?: string; name?: string; path?: string; query?: string | null }
|
|
165
|
+
|
|
166
|
+
const CODEX_ACTION_LABELS: Record<string, string> = {
|
|
167
|
+
read: 'Read',
|
|
168
|
+
listFiles: 'List files',
|
|
169
|
+
search: 'Search'
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function codexExecAction(input: unknown): CodexCommandAction | null {
|
|
173
|
+
const actions = (input as { commandActions?: unknown } | null)?.commandActions
|
|
174
|
+
if (!Array.isArray(actions) || actions.length === 0) return null
|
|
175
|
+
const first = actions[0] as CodexCommandAction
|
|
176
|
+
const type = first?.type
|
|
177
|
+
if (!type || !(type in CODEX_ACTION_LABELS)) return null
|
|
178
|
+
if (actions.some(a => (a as CodexCommandAction)?.type !== type)) return null
|
|
179
|
+
return first
|
|
180
|
+
}
|
|
181
|
+
|
|
124
182
|
export function getToolDisplayName(call: ToolCall): string {
|
|
125
183
|
if (call.provider === 'openclaw') return OPENCLAW_TOOL_LABELS[call.name] ?? call.name
|
|
184
|
+
if (call.provider === 'codex') {
|
|
185
|
+
if (call.name === 'exec') {
|
|
186
|
+
const action = codexExecAction(call.input)
|
|
187
|
+
if (action?.type) return CODEX_ACTION_LABELS[action.type]
|
|
188
|
+
}
|
|
189
|
+
return CODEX_TOOL_LABELS[call.name] ?? call.name
|
|
190
|
+
}
|
|
126
191
|
return CLAUDE_TOOL_LABELS[call.name] ?? call.name
|
|
127
192
|
}
|
|
128
193
|
|
|
@@ -139,9 +204,61 @@ export function formatInputBrief(call: ToolCall, cwd: string | null): string {
|
|
|
139
204
|
const input = (call.input as Record<string, unknown>) ?? {}
|
|
140
205
|
const shorten = makeShortenPaths(cwd)
|
|
141
206
|
if (call.provider === 'openclaw') return formatOpenClawBrief(call.name, input, shorten)
|
|
207
|
+
if (call.provider === 'codex') return formatCodexBrief(call.name, input, shorten)
|
|
142
208
|
return formatClaudeBrief(call.name, input, shorten)
|
|
143
209
|
}
|
|
144
210
|
|
|
211
|
+
function formatCodexBrief(
|
|
212
|
+
tool: string,
|
|
213
|
+
input: Record<string, unknown>,
|
|
214
|
+
shorten: (s: string) => string
|
|
215
|
+
): string {
|
|
216
|
+
if (tool === 'exec') {
|
|
217
|
+
// Semantic brief when Codex classified the command (label says Read/
|
|
218
|
+
// Search/List files); raw command otherwise.
|
|
219
|
+
const action = codexExecAction(input)
|
|
220
|
+
if (action?.type === 'read') return shorten(action.path || action.name || '')
|
|
221
|
+
if (action?.type === 'search')
|
|
222
|
+
return [action.query && `/${action.query}/`, action.path && shorten(action.path)]
|
|
223
|
+
.filter(Boolean)
|
|
224
|
+
.join(' ')
|
|
225
|
+
if (action?.type === 'listFiles') return action.path ? shorten(action.path) : ''
|
|
226
|
+
return shorten(`$ ${getInputValue(input, 'command')}`)
|
|
227
|
+
}
|
|
228
|
+
if (tool === 'apply_patch') {
|
|
229
|
+
// The adapter sends structured per-file changes: [{ path, kind, diff }].
|
|
230
|
+
const changes = input.changes
|
|
231
|
+
if (Array.isArray(changes)) {
|
|
232
|
+
const paths = changes
|
|
233
|
+
.map(c => (c && typeof c === 'object' ? (c as { path?: unknown }).path : undefined))
|
|
234
|
+
.filter((p): p is string => typeof p === 'string')
|
|
235
|
+
.map(shorten)
|
|
236
|
+
return paths.join(', ')
|
|
237
|
+
}
|
|
238
|
+
return ''
|
|
239
|
+
}
|
|
240
|
+
if (tool === 'web_search') {
|
|
241
|
+
// Multi-query fan-outs carry every query in `queries`; single searches
|
|
242
|
+
// just have `query`.
|
|
243
|
+
const queries = input.queries
|
|
244
|
+
if (Array.isArray(queries) && queries.length > 0) {
|
|
245
|
+
return queries.filter((q): q is string => typeof q === 'string').join(' · ')
|
|
246
|
+
}
|
|
247
|
+
return getInputValue(input, 'query')
|
|
248
|
+
}
|
|
249
|
+
if (tool === 'update_plan') {
|
|
250
|
+
const plan = input.plan
|
|
251
|
+
return typeof plan === 'string' ? plan.split('\n')[0] : ''
|
|
252
|
+
}
|
|
253
|
+
if (tool === 'subagent') return getInputValue(input, 'prompt') || getInputValue(input, 'action')
|
|
254
|
+
if (tool === 'subagent_activity') return getInputValue(input, 'kind')
|
|
255
|
+
if (tool === 'generate_image') return getInputValue(input, 'prompt').split('\n')[0]
|
|
256
|
+
if (tool === 'read_mcp_resource') return getInputValue(input, 'uri')
|
|
257
|
+
if (tool === 'list_mcp_resources' || tool === 'list_mcp_resource_templates')
|
|
258
|
+
return getInputValue(input, 'server')
|
|
259
|
+
return ''
|
|
260
|
+
}
|
|
261
|
+
|
|
145
262
|
function formatClaudeBrief(
|
|
146
263
|
tool: string,
|
|
147
264
|
input: Record<string, unknown>,
|
|
@@ -2,19 +2,14 @@ import { useCallback, useMemo } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '@/client/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { sendMessage } from '@/client/lib/connection'
|
|
14
|
-
import { STREAM_RESPONSES } from '@/client/lib/flags'
|
|
15
|
-
import { buildPreviewTurn } from '@/client/lib/preview-turn'
|
|
16
|
-
import { draftKey, liveStore, selectPreviews, useLive } from '@/client/store/live'
|
|
17
|
-
import { applyEvent, emptyViewState } from '@/lib/format'
|
|
5
|
+
import { useSessionView, useThreadConfig, useWorkspaceModels } from '@/client/features/chat/api'
|
|
6
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
7
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
8
|
+
import { sendMessage } from '@/client/features/chat/chat-connection'
|
|
9
|
+
import { resolveChatRunOptions, startOptimisticTurn } from '@/client/features/chat/chat-send'
|
|
10
|
+
import { buildPreviewTurn } from '@/client/features/chat/preview-turn'
|
|
11
|
+
import { draftKey, liveStore, selectPreviews, useLive } from '@/client/features/chat/chat-store'
|
|
12
|
+
import { emptyViewState } from '@/lib/format'
|
|
18
13
|
import type { Part, ViewState } from '@/lib/types'
|
|
19
14
|
|
|
20
15
|
const EMPTY: ViewState = emptyViewState()
|
|
@@ -27,8 +22,6 @@ export function useChat() {
|
|
|
27
22
|
const qc = useQueryClient()
|
|
28
23
|
const { layout } = useWorkspaceLayoutCtx()
|
|
29
24
|
const modelsData = useWorkspaceModels(workspaceId).data
|
|
30
|
-
const models = modelsData?.models
|
|
31
|
-
const supportsStreaming = modelsData?.supportsStreaming ?? false
|
|
32
25
|
|
|
33
26
|
const activeSessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
|
|
34
27
|
const processing = useLive(s =>
|
|
@@ -83,7 +76,6 @@ export function useChat() {
|
|
|
83
76
|
// upserts in place rather than duplicating. Image attachments render from
|
|
84
77
|
// their local object URL until the server's broadcast (with a data URL)
|
|
85
78
|
// upserts in place.
|
|
86
|
-
const optimisticId = `optimistic:${crypto.randomUUID()}`
|
|
87
79
|
const parts: Part[] = []
|
|
88
80
|
for (const a of ready) {
|
|
89
81
|
if (a.upload?.kind === 'image' && a.previewUrl) {
|
|
@@ -93,20 +85,12 @@ export function useChat() {
|
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
87
|
if (text) parts.push({ type: 'text', text })
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
origin: { kind: 'user-input' },
|
|
103
|
-
parts,
|
|
104
|
-
timestamp: new Date().toISOString()
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
)
|
|
108
|
-
liveStore.getState().setProcessing(workspaceId, sid, true)
|
|
109
|
-
liveStore.getState().setError(workspaceId, sid, null)
|
|
88
|
+
const optimisticId = startOptimisticTurn({
|
|
89
|
+
queryClient: qc,
|
|
90
|
+
workspaceId,
|
|
91
|
+
sessionId: sid,
|
|
92
|
+
parts
|
|
93
|
+
})
|
|
110
94
|
|
|
111
95
|
// The thread's persisted choice (workspace defaults for a new chat). Drop a
|
|
112
96
|
// model the loaded list no longer offers (stale alias) so the SDK doesn't
|
|
@@ -114,19 +98,8 @@ export function useChat() {
|
|
|
114
98
|
// (e.g. model changed under it); when the model is unknown/default we can't
|
|
115
99
|
// check, so pass it through — the SDK silently downgrades unsupported effort.
|
|
116
100
|
const pickedModel = threadCfg?.model ?? layout.selectedModel
|
|
117
|
-
const modelOk = !pickedModel || !models || models.some(m => m.value === pickedModel)
|
|
118
|
-
const model = modelOk ? pickedModel : undefined
|
|
119
|
-
const modelInfo = models?.find(m => m.value === model)
|
|
120
101
|
const pickedEffort = threadCfg?.effort ?? layout.selectedEffort
|
|
121
|
-
const effort =
|
|
122
|
-
pickedEffort &&
|
|
123
|
-
(!modelInfo || (modelInfo.supportedEffortLevels ?? []).includes(pickedEffort))
|
|
124
|
-
? pickedEffort
|
|
125
|
-
: undefined
|
|
126
|
-
// Live token streaming is a compile-time dev flag (client/lib/flags.ts),
|
|
127
|
-
// gated to providers that support it. Send `true` or omit (never `false`),
|
|
128
|
-
// so a provider that ignores it behaves identically.
|
|
129
|
-
const stream = STREAM_RESPONSES && supportsStreaming ? true : undefined
|
|
102
|
+
const { model, effort, stream } = resolveChatRunOptions(modelsData, pickedModel, pickedEffort)
|
|
130
103
|
sendMessage({
|
|
131
104
|
type: 'chat',
|
|
132
105
|
workspaceId,
|
|
@@ -152,8 +125,7 @@ export function useChat() {
|
|
|
152
125
|
layout.selectedEffort,
|
|
153
126
|
threadCfg?.model,
|
|
154
127
|
threadCfg?.effort,
|
|
155
|
-
|
|
156
|
-
supportsStreaming
|
|
128
|
+
modelsData
|
|
157
129
|
]
|
|
158
130
|
)
|
|
159
131
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IconPlugConnected } from '@tabler/icons-react'
|
|
2
|
+
|
|
3
|
+
import { useUserMcp } from './api'
|
|
4
|
+
import { McpServerCard, sortMcpServers } from '@/client/features/connectors/McpMenu'
|
|
5
|
+
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
6
|
+
import { Button } from '@/client/components/ui/button'
|
|
7
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
8
|
+
|
|
9
|
+
const CONNECTOR_SKELETONS = Array.from({ length: 6 }, (_, index) => index)
|
|
10
|
+
|
|
11
|
+
export function ConnectorsPage() {
|
|
12
|
+
return (
|
|
13
|
+
<SidebarLayout panel="flat">
|
|
14
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
15
|
+
<UserConnectorsPage />
|
|
16
|
+
</div>
|
|
17
|
+
</SidebarLayout>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function UserConnectorsPage() {
|
|
22
|
+
const connectorsQuery = useUserMcp()
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="mx-auto w-full max-w-3xl px-8 pt-14 pb-16">
|
|
26
|
+
<div className="mb-4 flex items-center justify-between gap-2">
|
|
27
|
+
<h1 className="text-sm font-medium text-foreground">Connectors</h1>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<ConnectorsContent connectorsQuery={connectorsQuery} />
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type ConnectorsContentProps = {
|
|
36
|
+
connectorsQuery: ReturnType<typeof useUserMcp>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ConnectorsContent({ connectorsQuery }: ConnectorsContentProps) {
|
|
40
|
+
if (connectorsQuery.isPending) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
role="status"
|
|
44
|
+
aria-label="Loading connectors"
|
|
45
|
+
className="grid grid-cols-1 gap-3 sm:grid-cols-2"
|
|
46
|
+
>
|
|
47
|
+
{CONNECTOR_SKELETONS.map(index => (
|
|
48
|
+
<div
|
|
49
|
+
key={index}
|
|
50
|
+
className="flex min-h-20 items-center gap-3 rounded-xl border border-border bg-card px-4 py-3"
|
|
51
|
+
>
|
|
52
|
+
<Skeleton className="size-10 shrink-0 rounded-sm" />
|
|
53
|
+
<div className="flex min-w-0 flex-1 flex-col gap-2">
|
|
54
|
+
<Skeleton className="h-4 w-36" />
|
|
55
|
+
<Skeleton className="h-3 w-20" />
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (connectorsQuery.isError) {
|
|
64
|
+
return (
|
|
65
|
+
<div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
|
|
66
|
+
<p className="text-sm text-muted-foreground">Could not load connectors.</p>
|
|
67
|
+
<Button variant="outline" size="sm" onClick={() => connectorsQuery.refetch()}>
|
|
68
|
+
Retry
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const connectors = sortMcpServers(connectorsQuery.data)
|
|
75
|
+
|
|
76
|
+
if (connectors.length === 0) {
|
|
77
|
+
return (
|
|
78
|
+
<div className="flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center">
|
|
79
|
+
<IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
|
|
80
|
+
<p className="mx-auto max-w-md text-sm text-foreground">No user connectors configured.</p>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
|
87
|
+
{connectors.map(connector => (
|
|
88
|
+
<McpServerCard key={connector.name} server={connector} />
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useWorkspaceMcp } from './api'
|
|
2
|
+
import { IconAlertCircleFilled, IconPlugConnected } from '@tabler/icons-react'
|
|
3
|
+
import { IconMcp } from '@/client/features/connectors/IconMcp'
|
|
4
|
+
import { Button } from '@/client/components/ui/button'
|
|
5
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/client/components/ui/hover-card'
|
|
6
|
+
import { formatMcpServerName, getMcpIcon } from '@/client/features/connectors/mcp-icons'
|
|
7
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
8
|
+
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
9
|
+
import { cn } from '@/client/lib/cn'
|
|
10
|
+
import type { McpServer } from '@/lib/types'
|
|
11
|
+
|
|
12
|
+
function statusLabel(status: McpServer['status']): string {
|
|
13
|
+
if (status === 'needs-auth') return 'Needs auth'
|
|
14
|
+
return status[0].toUpperCase() + status.slice(1)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function McpStatusDot({ status }: { status: McpServer['status'] }) {
|
|
18
|
+
const connected = status === 'connected'
|
|
19
|
+
return (
|
|
20
|
+
<span
|
|
21
|
+
className={cn(
|
|
22
|
+
'size-[5px] shrink-0 rounded-full',
|
|
23
|
+
connected ? 'bg-emerald-500' : 'bg-yellow-500'
|
|
24
|
+
)}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type McpServerIconProps = {
|
|
30
|
+
name: string
|
|
31
|
+
status: McpServer['status']
|
|
32
|
+
size?: 'sm' | 'lg'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function McpServerIcon({ name, status, size = 'sm' }: McpServerIconProps) {
|
|
36
|
+
const icon = getMcpIcon(name)
|
|
37
|
+
const large = size === 'lg'
|
|
38
|
+
const className = 'size-full rounded-sm ring-2 ring-background'
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<span className={cn('relative shrink-0', large ? 'size-10' : 'size-5')}>
|
|
42
|
+
{icon ? (
|
|
43
|
+
<img src={icon} alt="" className={className} />
|
|
44
|
+
) : (
|
|
45
|
+
<span
|
|
46
|
+
className={cn(
|
|
47
|
+
'flex size-full items-center justify-center bg-muted text-muted-foreground ring-2 ring-background',
|
|
48
|
+
large ? 'rounded-sm' : 'rounded'
|
|
49
|
+
)}
|
|
50
|
+
>
|
|
51
|
+
<IconMcp className={large ? 'size-5' : 'size-4'} />
|
|
52
|
+
</span>
|
|
53
|
+
)}
|
|
54
|
+
{large && status !== 'connected' && (
|
|
55
|
+
<IconAlertCircleFilled
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
size={16}
|
|
58
|
+
stroke={1.75}
|
|
59
|
+
className="absolute -top-1 -right-1 rounded-full bg-card text-amber-400"
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
</span>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function sortMcpServers(servers: McpServer[]): McpServer[] {
|
|
67
|
+
// Active (connected) servers first, then disabled/errored/auth-pending. The
|
|
68
|
+
// sort is stable, so each group keeps the server list's original order.
|
|
69
|
+
return [...servers].sort(
|
|
70
|
+
(a, b) => Number(b.status === 'connected') - Number(a.status === 'connected')
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function McpServerRow({ server }: { server: McpServer }) {
|
|
75
|
+
return (
|
|
76
|
+
<div className="flex items-center gap-2.5 rounded-xs px-2 py-1 text-foreground hover:bg-accent hover:text-accent-foreground">
|
|
77
|
+
<McpServerIcon name={server.name} status={server.status} />
|
|
78
|
+
<span className="flex-1 truncate text-sm">{formatMcpServerName(server.name)}</span>
|
|
79
|
+
<McpStatusDot status={server.status} />
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function McpServerCard({ server }: { server: McpServer }) {
|
|
85
|
+
return (
|
|
86
|
+
<div className="flex min-h-20 items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 text-card-foreground">
|
|
87
|
+
<McpServerIcon name={server.name} status={server.status} size="lg" />
|
|
88
|
+
<div className="flex min-w-0 flex-1 flex-col justify-center gap-0.5">
|
|
89
|
+
<div className="truncate text-sm font-medium text-foreground">
|
|
90
|
+
{formatMcpServerName(server.name)}
|
|
91
|
+
</div>
|
|
92
|
+
<span className="text-sm text-muted-foreground">{statusLabel(server.status)}</span>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// The scrollable server list. Overflow is signalled with scroll-aware fades;
|
|
99
|
+
// the scrollbar is hidden.
|
|
100
|
+
function McpList({ servers }: { servers: McpServer[] }) {
|
|
101
|
+
return (
|
|
102
|
+
<div className="no-scrollbar flex max-h-72 scroll-fade flex-col overflow-y-auto overscroll-contain [--scroll-fade-reveal:16px]">
|
|
103
|
+
{servers.map(server => (
|
|
104
|
+
<McpServerRow key={server.name} server={server} />
|
|
105
|
+
))}
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Project-scoped connector status hover card — Claude workspaces only
|
|
111
|
+
// (OpenClaw/Hermes use other backends). User-scoped connectors live on the
|
|
112
|
+
// standalone Connectors page.
|
|
113
|
+
export function McpMenu() {
|
|
114
|
+
const workspaceId = useWorkspaceId()
|
|
115
|
+
// Read provider from the shared layout context, not a second `useWorkspaceLayout`
|
|
116
|
+
// observer — a duplicate observer that remounts (e.g. when this menu moves
|
|
117
|
+
// between the fullscreen and two-pane headers) fires `refetchOnMount`, which
|
|
118
|
+
// overwrites an in-flight optimistic chat-mode change before it's persisted.
|
|
119
|
+
const { provider, isLoading } = useWorkspaceLayoutCtx()
|
|
120
|
+
const isClaude = !isLoading && provider !== 'openclaw'
|
|
121
|
+
const { data: servers } = useWorkspaceMcp(workspaceId, isClaude)
|
|
122
|
+
|
|
123
|
+
if (!isClaude) return null
|
|
124
|
+
if (!servers || servers.length === 0) return null
|
|
125
|
+
|
|
126
|
+
const trigger = (
|
|
127
|
+
<Button variant="ghost" size="icon-sm" aria-label="Connectors" title="Connectors">
|
|
128
|
+
<IconPlugConnected stroke={1.75} />
|
|
129
|
+
</Button>
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
const sorted = sortMcpServers(servers)
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<HoverCard>
|
|
136
|
+
<HoverCardTrigger render={trigger} delay={0} closeDelay={100} />
|
|
137
|
+
<HoverCardContent align="end" sideOffset={6} className="w-56 p-1">
|
|
138
|
+
<div className="px-2 pt-1 pb-1.5 text-xs font-medium text-muted-foreground">
|
|
139
|
+
Project connectors
|
|
140
|
+
</div>
|
|
141
|
+
<McpList servers={sorted} />
|
|
142
|
+
</HoverCardContent>
|
|
143
|
+
</HoverCard>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { requestJson } from '@/client/api/http'
|
|
4
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
+
import type { McpServer } from '@/lib/types'
|
|
6
|
+
|
|
7
|
+
export function useWorkspaceMcp(workspaceId: string, enabled: boolean) {
|
|
8
|
+
return useQuery<McpServer[]>({
|
|
9
|
+
queryKey: workspaceKeys.mcp(workspaceId),
|
|
10
|
+
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/mcp`),
|
|
11
|
+
enabled,
|
|
12
|
+
staleTime: Infinity,
|
|
13
|
+
gcTime: Infinity,
|
|
14
|
+
refetchOnMount: false,
|
|
15
|
+
refetchOnWindowFocus: false
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useUserMcp() {
|
|
20
|
+
return useQuery<McpServer[]>({
|
|
21
|
+
queryKey: workspaceKeys.userMcp,
|
|
22
|
+
queryFn: () => requestJson('/api/mcp'),
|
|
23
|
+
staleTime: 30_000,
|
|
24
|
+
gcTime: Infinity,
|
|
25
|
+
refetchOnMount: true,
|
|
26
|
+
refetchOnWindowFocus: true
|
|
27
|
+
})
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Route, Switch } from 'wouter'
|
|
2
|
+
|
|
3
|
+
import { HarnessDebugPage } from './HarnessDebugPage'
|
|
4
|
+
import { PlaygroundPage } from './PlaygroundPage'
|
|
5
|
+
import { ToolCallsPage } from './ToolCallsPage'
|
|
6
|
+
|
|
7
|
+
// All /dev/* routes, colocated with their pages so the whole dev playground
|
|
8
|
+
// (and its dependencies) lives in this folder and loads as one lazy chunk —
|
|
9
|
+
// see the dynamic import in AppRouter.
|
|
10
|
+
export default function DevRoutes() {
|
|
11
|
+
return (
|
|
12
|
+
<Switch>
|
|
13
|
+
<Route path="/dev/harness" component={HarnessDebugPage} />
|
|
14
|
+
<Route path="/dev/tool-calls" component={ToolCallsPage} />
|
|
15
|
+
<Route path="/dev" component={PlaygroundPage} />
|
|
16
|
+
</Switch>
|
|
17
|
+
)
|
|
18
|
+
}
|