moi-computer 0.3.1-next.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +49 -12
  2. package/client/api/workspace-keys.ts +2 -2
  3. package/client/app/AppRouter.tsx +0 -2
  4. package/client/app/shell/SidebarLayout.tsx +3 -16
  5. package/client/assets/openai.svg +1 -3
  6. package/client/components/shared/Composer.tsx +53 -2
  7. package/client/components/ui/button.tsx +1 -1
  8. package/client/components/ui/tooltip.tsx +12 -15
  9. package/client/features/chat/ChatComposer.tsx +25 -15
  10. package/client/features/chat/ChatPanel.tsx +5 -2
  11. package/client/features/chat/MarkdownContent.tsx +20 -2
  12. package/client/features/chat/ModelPicker.tsx +5 -3
  13. package/client/features/chat/TurnView.tsx +2 -2
  14. package/client/features/chat/chat-frames.ts +13 -6
  15. package/client/features/chat/chat-send.ts +1 -1
  16. package/client/features/chat/chat-store.ts +22 -17
  17. package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
  18. package/client/features/chat/tool-group/format.ts +22 -7
  19. package/client/features/chat/useChat.ts +11 -2
  20. package/client/features/connectors/McpServerCards.tsx +95 -0
  21. package/client/features/connectors/api.ts +0 -11
  22. package/client/features/dev/HarnessDebugPage.tsx +210 -74
  23. package/client/features/home/HomePage.tsx +33 -28
  24. package/client/features/home/api.ts +24 -12
  25. package/client/features/home/workspace-presentation.tsx +17 -15
  26. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
  27. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
  28. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
  29. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
  30. package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
  31. package/client/features/settings/ConnectorsSettings.tsx +89 -0
  32. package/client/features/settings/SettingsLayout.tsx +2 -2
  33. package/client/features/settings/WorkspaceSettings.tsx +8 -4
  34. package/client/features/views/ViewBuilderTab.tsx +19 -15
  35. package/client/features/views/useViewBuilderActions.ts +1 -1
  36. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
  37. package/client/features/workspace/WorkspaceScreen.tsx +11 -3
  38. package/client/features/workspace/api.ts +19 -1
  39. package/client/features/workspace/moi-context.ts +85 -0
  40. package/client/main.tsx +16 -5
  41. package/dist/chunk-19g80zc9.css +1 -0
  42. package/dist/{chunk-jen6xcm1.js → chunk-2vaafjp4.js} +1 -1
  43. package/dist/{chunk-vkvb3hjm.js → chunk-35fq49qa.js} +1 -1
  44. package/dist/chunk-69nhbjhy.js +50 -0
  45. package/dist/{chunk-axszxe4c.js → chunk-72atbmh3.js} +1 -1
  46. package/dist/{chunk-zpxrb1ce.js → chunk-7mkv2gr0.js} +2 -2
  47. package/dist/{chunk-cs8vbert.js → chunk-fh2mf6v9.js} +3 -3
  48. package/dist/chunk-gt7n06ef.js +1 -0
  49. package/dist/chunk-jwmc32rp.js +63 -0
  50. package/dist/chunk-kh24bstm.js +10 -0
  51. package/dist/chunk-sfa4mbmx.js +15 -0
  52. package/dist/index.html +1 -1
  53. package/dist/openai-ep9ht2pq.svg +1 -0
  54. package/lib/ids.ts +15 -0
  55. package/lib/moi-context.ts +170 -0
  56. package/lib/types.ts +29 -11
  57. package/lib/view-builder-directives.ts +16 -0
  58. package/lib/workspace-types.ts +12 -0
  59. package/package.json +2 -1
  60. package/server/api.ts +92 -30
  61. package/server/harness/README.md +25 -9
  62. package/server/harness/claude-code/NOTES.md +20 -6
  63. package/server/harness/claude-code/adapter.ts +2 -2
  64. package/server/harness/claude-code/git-worktree.ts +32 -0
  65. package/server/harness/claude-code/index.ts +33 -12
  66. package/server/harness/claude-code/mcp.ts +16 -65
  67. package/server/harness/claude-code/models.ts +3 -0
  68. package/server/harness/claude-code/session.ts +196 -61
  69. package/server/harness/codex/NOTES.md +41 -11
  70. package/server/harness/codex/adapter.ts +121 -16
  71. package/server/harness/codex/client.ts +67 -18
  72. package/server/harness/codex/discovery.ts +114 -0
  73. package/server/harness/codex/index.ts +10 -5
  74. package/server/harness/codex/probe.ts +4 -2
  75. package/server/harness/codex/session.ts +89 -13
  76. package/server/harness/executable.ts +82 -0
  77. package/server/harness/openclaw/adapter.ts +8 -1
  78. package/server/harness/openclaw/index.ts +8 -14
  79. package/server/harness/openclaw/session.ts +50 -10
  80. package/server/harness/openclaw/strip.ts +2 -2
  81. package/server/harness/shell-path.ts +79 -0
  82. package/server/harness/types.ts +22 -5
  83. package/server/registry.ts +57 -12
  84. package/server/view-builders.ts +3 -2
  85. package/server/web.ts +24 -8
  86. package/server/workspace-import.ts +45 -0
  87. package/workspace/.claude/skills/moi-workspace/SKILL.md +3 -3
  88. package/client/features/connectors/ConnectorsPage.tsx +0 -92
  89. package/client/features/connectors/McpMenu.tsx +0 -145
  90. package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
  91. package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
  92. package/dist/chunk-4vf1t6v1.js +0 -10
  93. package/dist/chunk-6c8cwpzc.js +0 -1
  94. package/dist/chunk-b3ynfk4g.js +0 -62
  95. package/dist/chunk-b4b276wx.js +0 -15
  96. package/dist/chunk-kxmvv1ax.js +0 -48
  97. package/dist/chunk-npwq6jmr.css +0 -1
  98. package/dist/openai-h13pza4b.svg +0 -3
  99. package/lib/view-builder-meta.ts +0 -35
@@ -1,7 +1,7 @@
1
1
  import { useStore } from 'zustand'
2
2
  import { createStore } from 'zustand/vanilla'
3
3
 
4
- import type { PreviewBlock, PreviewFrame, UploadInfo } from '@/lib/types'
4
+ import type { PreviewBlock, PreviewFrame, SessionActivity, UploadInfo } from '@/lib/types'
5
5
 
6
6
  // One composer attachment, tracked per thread until the message is sent. It is
7
7
  // uploaded as soon as it's added (drop/paste/pick); `status` reflects that
@@ -20,7 +20,7 @@ export type ChatAttachment = {
20
20
  // App-level ephemeral chat state — the bits that are *pushed* from the server
21
21
  // over the WebSocket and can't be re-fetched as request/response data:
22
22
  // - which thread is active per workspace (a UI selection),
23
- // - per-session `processing` (spinner) flags,
23
+ // - per-session `activity` (spinner) state,
24
24
  // - per-session error banners.
25
25
  //
26
26
  // The durable message transcripts live in the React Query cache (see
@@ -56,7 +56,10 @@ export type LivePreview = {
56
56
 
57
57
  export type LiveStore = {
58
58
  activeByWorkspace: Record<string, string | null>
59
- processing: Record<string, boolean>
59
+ // Per-session activity mirrored from server `status` frames. Only `running`
60
+ // shows the loader/Stop; `requires-action` is tracked but not rendered yet.
61
+ // Missing key = idle.
62
+ activity: Record<string, SessionActivity>
60
63
  errors: Record<string, string | null>
61
64
  // Live token-streaming previews, keyed by `messageId` (the API `msg_...` id)
62
65
  // so concurrent streams never collide. Reconciled against the durable
@@ -73,11 +76,13 @@ export type LiveStore = {
73
76
  attachments: Record<string, ChatAttachment[]>
74
77
 
75
78
  setActive: (workspaceId: string, sessionId: string | null) => void
76
- setProcessing: (workspaceId: string, sessionId: string, value: boolean) => void
79
+ setActivity: (workspaceId: string, sessionId: string, value: SessionActivity) => void
77
80
  // Authoritative reconcile from a server `status_snapshot`: exactly the listed
78
- // sessions are processing; everything else is cleared (fixes a spinner whose
79
- // terminal status was emitted while we were disconnected).
80
- reconcileProcessing: (running: { workspaceId: string; sessionId: string }[]) => void
81
+ // sessions are active; everything else is cleared to idle (fixes a spinner
82
+ // whose terminal status frame was lost while we were disconnected).
83
+ reconcileActivity: (
84
+ sessions: { workspaceId: string; sessionId: string; activity: SessionActivity }[]
85
+ ) => void
81
86
  setError: (workspaceId: string, sessionId: string, message: string | null) => void
82
87
  setDraft: (workspaceId: string, sessionId: string | null, value: string) => void
83
88
  addAttachments: (workspaceId: string, sessionId: string | null, items: ChatAttachment[]) => void
@@ -107,7 +112,7 @@ export type LiveStore = {
107
112
 
108
113
  export const liveStore = createStore<LiveStore>()(set => ({
109
114
  activeByWorkspace: {},
110
- processing: {},
115
+ activity: {},
111
116
  errors: {},
112
117
  drafts: {},
113
118
  previews: {},
@@ -116,12 +121,12 @@ export const liveStore = createStore<LiveStore>()(set => ({
116
121
  setActive: (workspaceId, sessionId) =>
117
122
  set(s => ({ activeByWorkspace: { ...s.activeByWorkspace, [workspaceId]: sessionId } })),
118
123
 
119
- setProcessing: (workspaceId, sessionId, value) =>
120
- set(s => ({ processing: { ...s.processing, [key(workspaceId, sessionId)]: value } })),
124
+ setActivity: (workspaceId, sessionId, value) =>
125
+ set(s => ({ activity: { ...s.activity, [key(workspaceId, sessionId)]: value } })),
121
126
 
122
- reconcileProcessing: running =>
127
+ reconcileActivity: sessions =>
123
128
  set(() => ({
124
- processing: Object.fromEntries(running.map(r => [key(r.workspaceId, r.sessionId), true]))
129
+ activity: Object.fromEntries(sessions.map(r => [key(r.workspaceId, r.sessionId), r.activity]))
125
130
  })),
126
131
 
127
132
  setError: (workspaceId, sessionId, message) =>
@@ -219,11 +224,11 @@ export const liveStore = createStore<LiveStore>()(set => ({
219
224
  set(s => {
220
225
  const fromKey = key(workspaceId, from)
221
226
  const toKey = key(workspaceId, to)
222
- const processing = { ...s.processing }
227
+ const activity = { ...s.activity }
223
228
  const errors = { ...s.errors }
224
- if (fromKey in processing) {
225
- processing[toKey] = processing[fromKey]
226
- delete processing[fromKey]
229
+ if (fromKey in activity) {
230
+ activity[toKey] = activity[fromKey]
231
+ delete activity[fromKey]
227
232
  }
228
233
  if (fromKey in errors) {
229
234
  errors[toKey] = errors[fromKey]
@@ -246,7 +251,7 @@ export const liveStore = createStore<LiveStore>()(set => ({
246
251
  previews[id] = { ...p, sessionId: to }
247
252
  }
248
253
  }
249
- return { processing, errors, activeByWorkspace, previews }
254
+ return { activity, errors, activeByWorkspace, previews }
250
255
  })
251
256
  }))
252
257
 
@@ -8,7 +8,6 @@ import type { ToolCall } from '@/lib/types'
8
8
  import { Button } from '@/client/components/ui/button'
9
9
  import { CodeBlock } from './CodeBlock'
10
10
  import { detectOutput } from './detect'
11
- import { formatBytes } from './format'
12
11
 
13
12
  type ToolOutputProps = { call: ToolCall; output: string; isError: boolean }
14
13
 
@@ -49,13 +48,7 @@ export function ToolOutput({ call, output, isError }: ToolOutputProps) {
49
48
  return (
50
49
  <div className="overflow-hidden rounded-md border border-border bg-muted">
51
50
  {/* Size is always the raw output; copy grabs whatever's currently shown. */}
52
- <Header
53
- raw={raw}
54
- onRaw={setRaw}
55
- label={view.label}
56
- size={formatBytes(output)}
57
- copyText={raw ? output : view.code}
58
- />
51
+ <Header raw={raw} onRaw={setRaw} label={view.label} copyText={raw ? output : view.code} />
59
52
  {raw ? (
60
53
  <pre className={cn(PRE, 'break-all whitespace-pre-wrap text-muted-foreground')}>
61
54
  {output || '(empty)'}
@@ -71,19 +64,18 @@ type HeaderProps = {
71
64
  raw: boolean
72
65
  onRaw: (raw: boolean) => void
73
66
  label: string
74
- size: string
75
67
  copyText: string
76
68
  }
77
69
 
78
70
  // Output toolbar: a left outline switch (<label> | raw), and on the right the
79
71
  // raw byte size + a copy button.
80
- function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
72
+ function Header({ raw, onRaw, label, copyText }: HeaderProps) {
81
73
  const options: [boolean, string][] = [
82
74
  [false, label],
83
75
  [true, 'raw']
84
76
  ]
85
77
  return (
86
- <div className="flex items-center gap-1 border-b border-border px-2 py-1">
78
+ <div className="flex items-center gap-1 border-b border-border p-2">
87
79
  {options.map(([value, text]) => (
88
80
  <Button
89
81
  key={text}
@@ -91,12 +83,12 @@ function Header({ raw, onRaw, label, size, copyText }: HeaderProps) {
91
83
  variant={raw === value ? 'outline' : 'ghost'}
92
84
  size="sm"
93
85
  onClick={() => onRaw(value)}
86
+ className="rounded-full text-xs uppercase"
94
87
  >
95
88
  {text}
96
89
  </Button>
97
90
  ))}
98
91
  <div className="flex-1" />
99
- <span className="text-[10px] font-medium text-muted-foreground tabular-nums">{size}</span>
100
92
  <CopyButton text={copyText} />
101
93
  </div>
102
94
  )
@@ -68,12 +68,6 @@ function getInputValue(input: Record<string, unknown>, key: string): string {
68
68
  return typeof value === 'string' ? value : ''
69
69
  }
70
70
 
71
- // Human byte size of a string (UTF-8): `124B`, `2.5KB`.
72
- export function formatBytes(text: string): string {
73
- const n = new TextEncoder().encode(text).length
74
- return n < 1024 ? `${n}B` : `${(n / 1024).toFixed(1)}KB`
75
- }
76
-
77
71
  // Compact wall-clock duration: sub-second → "850ms", under a minute → "3.2s" /
78
72
  // "11s", longer → "1m 5s". Used on the subagent card's duration badge.
79
73
  export function formatDuration(ms: number): string {
@@ -179,6 +173,15 @@ function codexExecAction(input: unknown): CodexCommandAction | null {
179
173
  return first
180
174
  }
181
175
 
176
+ // Codex collab tool actions (`input.action` on the `subagent` card). `wait`
177
+ // never reaches the UI — the adapter drops it.
178
+ const CODEX_SUBAGENT_ACTION_LABELS: Record<string, string> = {
179
+ spawn_agent: 'Run sub-agent',
180
+ send_input: 'Message the agent',
181
+ resume_agent: 'Resume the agent',
182
+ close_agent: 'Stopping the agent'
183
+ }
184
+
182
185
  export function getToolDisplayName(call: ToolCall): string {
183
186
  if (call.provider === 'openclaw') return OPENCLAW_TOOL_LABELS[call.name] ?? call.name
184
187
  if (call.provider === 'codex') {
@@ -186,6 +189,12 @@ export function getToolDisplayName(call: ToolCall): string {
186
189
  const action = codexExecAction(call.input)
187
190
  if (action?.type) return CODEX_ACTION_LABELS[action.type]
188
191
  }
192
+ if (call.name === 'subagent') {
193
+ const action = (call.input as { action?: unknown } | null)?.action
194
+ if (typeof action === 'string' && action in CODEX_SUBAGENT_ACTION_LABELS) {
195
+ return CODEX_SUBAGENT_ACTION_LABELS[action]
196
+ }
197
+ }
189
198
  return CODEX_TOOL_LABELS[call.name] ?? call.name
190
199
  }
191
200
  return CLAUDE_TOOL_LABELS[call.name] ?? call.name
@@ -250,7 +259,13 @@ function formatCodexBrief(
250
259
  const plan = input.plan
251
260
  return typeof plan === 'string' ? plan.split('\n')[0] : ''
252
261
  }
253
- if (tool === 'subagent') return getInputValue(input, 'prompt') || getInputValue(input, 'action')
262
+ if (tool === 'subagent') {
263
+ // The label already names the action; the brief carries the text being
264
+ // sent (spawn prompt, send_input/resume_agent message). close_agent has
265
+ // none — the label alone reads fine.
266
+ if (getInputValue(input, 'action') === 'close_agent') return ''
267
+ return getInputValue(input, 'prompt')
268
+ }
254
269
  if (tool === 'subagent_activity') return getInputValue(input, 'kind')
255
270
  if (tool === 'generate_image') return getInputValue(input, 'prompt').split('\n')[0]
256
271
  if (tool === 'read_mcp_resource') return getInputValue(input, 'uri')
@@ -4,6 +4,7 @@ import { useQueryClient } from '@tanstack/react-query'
4
4
 
5
5
  import { workspaceKeys } from '@/client/api/workspace-keys'
6
6
  import { useSessionView, useThreadConfig, useWorkspaceModels } from '@/client/features/chat/api'
7
+ import { useMoiUserMessageContext } from '@/client/features/workspace/moi-context'
7
8
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
8
9
  import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
9
10
  import { sendMessage } from '@/client/features/chat/chat-connection'
@@ -23,11 +24,17 @@ export function useChat() {
23
24
  const qc = useQueryClient()
24
25
  const { layout } = useWorkspaceLayoutCtx()
25
26
  const modelsData = useWorkspaceModels(workspaceId).data
27
+ // Snapshot of the workspace's ambient UI state + queued one-shot
28
+ // directives, taken when the message actually goes out.
29
+ const buildMoiContext = useMoiUserMessageContext()
26
30
 
27
31
  const activeSessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
28
- const processing = useLive(s =>
29
- activeSessionId ? (s.processing[`${workspaceId}:${activeSessionId}`] ?? false) : false
32
+ const activity = useLive(s =>
33
+ activeSessionId ? (s.activity[`${workspaceId}:${activeSessionId}`] ?? 'idle') : 'idle'
30
34
  )
35
+ // Only `running` shows the loader/Stop. `requires-action` (agent blocked on
36
+ // user input) deliberately renders like idle until it gets its own UI.
37
+ const processing = activity === 'running'
31
38
  const error = useLive(s =>
32
39
  activeSessionId ? (s.errors[`${workspaceId}:${activeSessionId}`] ?? null) : null
33
40
  )
@@ -111,6 +118,7 @@ export function useChat() {
111
118
  model,
112
119
  effort,
113
120
  stream,
121
+ context: buildMoiContext(),
114
122
  ...(ready.length > 0 ? { attachments: ready.map(a => a.upload!.id) } : {})
115
123
  })
116
124
  if (isNew) {
@@ -127,6 +135,7 @@ export function useChat() {
127
135
  qc,
128
136
  layout.selectedModel,
129
137
  layout.selectedEffort,
138
+ buildMoiContext,
130
139
  threadCfg?.model,
131
140
  threadCfg?.effort,
132
141
  modelsData
@@ -0,0 +1,95 @@
1
+ import type { ReactNode } from 'react'
2
+
3
+ import { IconAlertCircleFilled } from '@tabler/icons-react'
4
+
5
+ import { Skeleton } from '@/client/components/ui/skeleton'
6
+ import { IconMcp } from '@/client/features/connectors/IconMcp'
7
+ import { formatMcpServerName, getMcpIcon } from '@/client/features/connectors/mcp-icons'
8
+ import type { McpServer } from '@/lib/types'
9
+
10
+ function statusLabel(status: McpServer['status']): string {
11
+ if (status === 'needs-auth') return 'Needs auth'
12
+ return status[0].toUpperCase() + status.slice(1)
13
+ }
14
+
15
+ type McpServerIconProps = {
16
+ name: string
17
+ status: McpServer['status']
18
+ }
19
+
20
+ function McpServerIcon({ name, status }: McpServerIconProps) {
21
+ const icon = getMcpIcon(name)
22
+ const className = 'size-full rounded-sm ring-2 ring-background'
23
+
24
+ return (
25
+ <span className="relative size-10 shrink-0">
26
+ {icon ? (
27
+ <img src={icon} alt="" className={className} />
28
+ ) : (
29
+ <span className="flex size-full items-center justify-center rounded-sm bg-muted text-muted-foreground ring-2 ring-background">
30
+ <IconMcp className="size-5" />
31
+ </span>
32
+ )}
33
+ {status !== 'connected' && (
34
+ <IconAlertCircleFilled
35
+ aria-hidden="true"
36
+ size={16}
37
+ stroke={1.75}
38
+ className="absolute -top-1 -right-1 rounded-full bg-card text-amber-400"
39
+ />
40
+ )}
41
+ </span>
42
+ )
43
+ }
44
+
45
+ export function sortMcpServers(servers: McpServer[]): McpServer[] {
46
+ return [...servers].sort(
47
+ (a, b) => Number(b.status === 'connected') - Number(a.status === 'connected')
48
+ )
49
+ }
50
+
51
+ type McpServerCardProps = {
52
+ server: McpServer
53
+ }
54
+
55
+ type McpServerCardLayoutProps = {
56
+ icon: ReactNode
57
+ children: ReactNode
58
+ }
59
+
60
+ function McpServerCardLayout({ icon, children }: McpServerCardLayoutProps) {
61
+ return (
62
+ <div className="flex items-center gap-3 text-card-foreground">
63
+ {icon}
64
+ <div className="flex min-w-0 flex-1 flex-col justify-center gap-0.5">{children}</div>
65
+ </div>
66
+ )
67
+ }
68
+
69
+ export function McpServerCard({ server }: McpServerCardProps) {
70
+ return (
71
+ <McpServerCardLayout icon={<McpServerIcon name={server.name} status={server.status} />}>
72
+ <div className="truncate text-sm font-medium text-foreground">
73
+ {formatMcpServerName(server.name)}
74
+ </div>
75
+ <span className="text-sm text-muted-foreground">{statusLabel(server.status)}</span>
76
+ </McpServerCardLayout>
77
+ )
78
+ }
79
+
80
+ export function McpServerCardSkeleton() {
81
+ return (
82
+ <McpServerCardLayout icon={<Skeleton className="size-10 shrink-0 rounded-sm" />}>
83
+ <Skeleton className="h-4 w-36 max-w-full" />
84
+ <Skeleton className="h-4 w-20" />
85
+ </McpServerCardLayout>
86
+ )
87
+ }
88
+
89
+ type McpServerGridProps = {
90
+ children: ReactNode
91
+ }
92
+
93
+ export function McpServerGrid({ children }: McpServerGridProps) {
94
+ return <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">{children}</div>
95
+ }
@@ -15,14 +15,3 @@ export function useWorkspaceMcp(workspaceId: string, enabled: boolean) {
15
15
  refetchOnWindowFocus: false
16
16
  })
17
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
- }