moi-computer 0.3.0 → 0.3.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 (121) hide show
  1. package/client/api/workspace-keys.ts +2 -2
  2. package/client/app/AppRouter.tsx +0 -2
  3. package/client/app/routes/WorkspaceRoute.tsx +3 -1
  4. package/client/app/shell/SidebarLayout.tsx +3 -16
  5. package/client/assets/openai.svg +1 -3
  6. package/client/components/shared/Composer.tsx +112 -0
  7. package/client/components/ui/button.tsx +1 -1
  8. package/client/components/ui/dropdown-menu.tsx +3 -3
  9. package/client/components/ui/tooltip.tsx +12 -15
  10. package/client/features/applets/WidgetErrorBoundary.tsx +19 -3
  11. package/client/features/applets/WidgetShell.tsx +8 -1
  12. package/client/features/applets/applet-log.ts +100 -0
  13. package/client/features/applets/useApplet.ts +21 -7
  14. package/client/features/chat/ChatComposer.tsx +33 -30
  15. package/client/features/chat/ChatPanel.tsx +5 -2
  16. package/client/features/chat/MarkdownContent.tsx +20 -2
  17. package/client/features/chat/ModelPicker.tsx +29 -41
  18. package/client/features/chat/TurnView.tsx +2 -2
  19. package/client/features/chat/chat-frames.ts +14 -6
  20. package/client/features/chat/chat-send.ts +1 -1
  21. package/client/features/chat/chat-store.ts +22 -17
  22. package/client/features/chat/model-order.ts +47 -0
  23. package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
  24. package/client/features/chat/tool-group/format.ts +0 -6
  25. package/client/features/chat/useChat.ts +15 -2
  26. package/client/features/connectors/McpServerCards.tsx +95 -0
  27. package/client/features/connectors/api.ts +0 -11
  28. package/client/features/home/HomePage.tsx +45 -42
  29. package/client/features/home/WorkspacePreview.tsx +179 -38
  30. package/client/features/home/api.ts +24 -12
  31. package/client/features/home/workspace-presentation.tsx +17 -15
  32. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
  33. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
  34. package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
  35. package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
  36. package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
  37. package/client/features/settings/ConnectorsSettings.tsx +89 -0
  38. package/client/features/settings/GeneralSettings.tsx +12 -0
  39. package/client/features/settings/SettingsLayout.tsx +2 -2
  40. package/client/features/settings/WorkspaceSettings.tsx +8 -4
  41. package/client/features/views/ViewBuilderTab.tsx +28 -29
  42. package/client/features/views/useViewBuilderActions.ts +1 -1
  43. package/client/features/widgets/WidgetFrame.tsx +3 -0
  44. package/client/features/widgets/WidgetGrid.tsx +1 -0
  45. package/client/features/widgets/Widgets.tsx +12 -3
  46. package/client/features/widgets/api.ts +47 -0
  47. package/client/features/widgets/useWidgetThumbnails.ts +107 -0
  48. package/client/features/widgets/widget-snapshot.ts +71 -0
  49. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
  50. package/client/features/workspace/WorkspaceScreen.tsx +19 -4
  51. package/client/features/workspace/api.ts +25 -3
  52. package/client/features/workspace/moi-context.ts +85 -0
  53. package/client/index.css +0 -5
  54. package/client/main.tsx +13 -4
  55. package/dist/{chunk-cs8vbert.js → chunk-1dfbr7n2.js} +2 -2
  56. package/dist/chunk-339jds4x.js +15 -0
  57. package/dist/chunk-3xsvsnhr.css +1 -0
  58. package/dist/{chunk-zpxrb1ce.js → chunk-anqmsbjt.js} +2 -2
  59. package/dist/chunk-hbvfb6sk.js +63 -0
  60. package/dist/chunk-jen6xcm1.js +14 -0
  61. package/dist/{chunk-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
  62. package/dist/{chunk-fjksw6xf.js → chunk-sxbfh73c.js} +1 -1
  63. package/dist/chunk-yp4srgqt.js +10 -0
  64. package/dist/index.html +1 -1
  65. package/dist/openai-ep9ht2pq.svg +1 -0
  66. package/lib/ids.ts +15 -0
  67. package/lib/moi-context.ts +170 -0
  68. package/lib/types.ts +95 -13
  69. package/lib/view-builder-directives.ts +16 -0
  70. package/lib/workspace-types.ts +12 -0
  71. package/package.json +4 -2
  72. package/server/api.ts +180 -34
  73. package/server/applet-log.ts +149 -0
  74. package/server/cli.ts +161 -7
  75. package/server/control.ts +81 -1
  76. package/server/functions.ts +44 -14
  77. package/server/harness/README.md +26 -9
  78. package/server/harness/claude-code/NOTES.md +20 -6
  79. package/server/harness/claude-code/adapter.ts +2 -2
  80. package/server/harness/claude-code/git-worktree.ts +32 -0
  81. package/server/harness/claude-code/index.ts +35 -13
  82. package/server/harness/claude-code/mcp.ts +16 -65
  83. package/server/harness/claude-code/models.ts +3 -0
  84. package/server/harness/claude-code/session.ts +196 -61
  85. package/server/harness/claude-code/sessions.ts +51 -0
  86. package/server/harness/codex/NOTES.md +41 -11
  87. package/server/harness/codex/adapter.ts +52 -6
  88. package/server/harness/codex/client.ts +69 -18
  89. package/server/harness/codex/discovery.ts +114 -0
  90. package/server/harness/codex/index.ts +12 -5
  91. package/server/harness/codex/probe.ts +4 -2
  92. package/server/harness/codex/session.ts +57 -5
  93. package/server/harness/executable.ts +82 -0
  94. package/server/harness/openclaw/adapter.ts +8 -1
  95. package/server/harness/openclaw/discovery.ts +139 -6
  96. package/server/harness/openclaw/gateway.ts +40 -18
  97. package/server/harness/openclaw/index.ts +12 -15
  98. package/server/harness/openclaw/session.ts +50 -10
  99. package/server/harness/openclaw/strip.ts +2 -2
  100. package/server/harness/shell-path.ts +79 -0
  101. package/server/harness/types.ts +37 -5
  102. package/server/layout.ts +81 -51
  103. package/server/registry.ts +57 -12
  104. package/server/scratchpad-assets.ts +41 -6
  105. package/server/scratchpad.ts +30 -0
  106. package/server/view-builders.ts +3 -2
  107. package/server/views.ts +5 -0
  108. package/server/web.ts +30 -8
  109. package/server/widgets.ts +23 -2
  110. package/server/workspace-import.ts +45 -0
  111. package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -3
  112. package/client/features/connectors/ConnectorsPage.tsx +0 -92
  113. package/client/features/connectors/McpMenu.tsx +0 -145
  114. package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
  115. package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
  116. package/dist/chunk-4vf1t6v1.js +0 -10
  117. package/dist/chunk-4z52b2av.css +0 -1
  118. package/dist/chunk-b4b276wx.js +0 -15
  119. package/dist/chunk-y82s1jxm.js +0 -61
  120. package/dist/openai-h13pza4b.svg +0 -3
  121. package/lib/view-builder-meta.ts +0 -35
@@ -2,21 +2,23 @@
2
2
  // ../types.ts for the contract and ../README.md for the architecture.
3
3
  import { join } from 'node:path'
4
4
 
5
- import type { DiscoveredWorkspace, McpServer } from '@/lib/types'
5
+ import type { McpServer } from '@/lib/types'
6
6
 
7
- import type { Harness } from '../types'
7
+ import type { DiscoveredWorkspaceCandidate, Harness } from '../types'
8
+ import { pathHarnessAvailability } from '../executable'
9
+ import { isLinkedGitWorktree } from './git-worktree'
8
10
  import { getMcpStatus } from './mcp'
9
11
  import { getClaudeModels } from './models'
10
12
  import {
11
13
  SESSION_LIMITS,
12
14
  getCCDebugSnapshot,
13
- getCCRunningSessions,
15
+ getCCActiveSessions,
14
16
  interruptCCSession,
15
17
  killAllCCSessions,
16
18
  restartWorkspaceSessions,
17
19
  sendCCMessage
18
20
  } from './session'
19
- import { getSessionEvents, getSessions } from './sessions'
21
+ import { getSessionEvents, getSessions, getSessionWorkspacePreview } from './sessions'
20
22
 
21
23
  function fmtDuration(ms: number): string {
22
24
  const s = Math.floor(ms / 1000)
@@ -38,7 +40,9 @@ function fmtAgo(ts: number, now: number): string {
38
40
  }
39
41
 
40
42
  // Discover directories with CC session history that aren't registered yet.
41
- async function discoverWorkspaces(registeredPaths: Set<string>): Promise<DiscoveredWorkspace[]> {
43
+ async function discoverWorkspaces(
44
+ registeredPaths: Set<string>
45
+ ): Promise<DiscoveredWorkspaceCandidate[]> {
42
46
  try {
43
47
  const { listSessions } = await import('@anthropic-ai/claude-agent-sdk')
44
48
  const sessions = await listSessions({})
@@ -51,7 +55,13 @@ async function discoverWorkspaces(registeredPaths: Set<string>): Promise<Discove
51
55
  if (info.isDirectory()) paths.add(s.cwd)
52
56
  } catch {}
53
57
  }
54
- return [...paths].map(path => ({ path, type: 'claude-code' as const }))
58
+ // Drop linked git worktrees — throwaway checkouts (e.g. worktree-isolated
59
+ // runs) that shouldn't surface as importable workspaces.
60
+ const candidates = [...paths]
61
+ const worktree = await Promise.all(candidates.map(isLinkedGitWorktree))
62
+ return candidates
63
+ .filter((_, i) => !worktree[i])
64
+ .map(path => ({ path, type: 'claude-code' as const }))
55
65
  } catch {
56
66
  return []
57
67
  }
@@ -69,15 +79,18 @@ export const claudeCodeHarness: Harness = {
69
79
 
70
80
  sendMessage: input => sendCCMessage(input),
71
81
  interrupt: (workspaceId, sessionId) => interruptCCSession(workspaceId, sessionId),
72
- runningSessions: () => getCCRunningSessions(),
82
+ activeSessions: () => getCCActiveSessions(),
73
83
 
74
84
  listSessions: ws => getSessions(ws.path),
85
+ workspacePreview: (ws, includeFirstUserMessage) =>
86
+ getSessionWorkspacePreview(ws.path, includeFirstUserMessage),
75
87
  sessionEvents: (ws, sessionId) => getSessionEvents(sessionId, ws.path),
76
88
  listModels: ws => getClaudeModels(ws.path),
77
89
  // The SDK's McpServerStatus is a superset of the UI's McpServer (extra
78
90
  // fields are ignored by the client) — pass it through unchanged.
79
- mcpStatus: async ws => (await getMcpStatus(ws.path, 'project')) as unknown as McpServer[],
91
+ mcpStatus: async ws => (await getMcpStatus(ws.path)) as unknown as McpServer[],
80
92
  discoverWorkspaces,
93
+ availability: async () => pathHarnessAvailability('claude-code'),
81
94
 
82
95
  onEnvChanged: workspacePath => restartWorkspaceSessions(workspacePath),
83
96
  shutdown: () => killAllCCSessions(),
@@ -85,7 +98,7 @@ export const claudeCodeHarness: Harness = {
85
98
 
86
99
  statusLines: now => {
87
100
  const cc = getCCDebugSnapshot()
88
- const busy = cc.sessions.filter(s => s.busy).length
101
+ const busy = cc.sessions.filter(s => s.activity !== 'idle').length
89
102
  const lines = [
90
103
  `live CC sessions ${cc.sessions.length}/${SESSION_LIMITS.maxLive} ` +
91
104
  `(${busy} busy, ${cc.sessions.length - busy} idle, ${cc.aliases} alias${cc.aliases === 1 ? '' : 'es'}, ` +
@@ -97,10 +110,19 @@ export const claudeCodeHarness: Harness = {
97
110
  }
98
111
  // Busiest / most-recently-active first.
99
112
  const sorted = [...cc.sessions].sort(
100
- (a, b) => Number(b.busy) - Number(a.busy) || b.lastActivityAt - a.lastActivityAt
113
+ (a, b) =>
114
+ Number(b.activity !== 'idle') - Number(a.activity !== 'idle') ||
115
+ b.lastActivityAt - a.lastActivityAt
101
116
  )
102
117
  for (const s of sorted) {
103
- const mark = s.busy ? '▶ busy' : s.closed ? '✗ closed' : '○ idle'
118
+ const mark =
119
+ s.activity === 'running'
120
+ ? '▶ busy'
121
+ : s.activity === 'requires-action'
122
+ ? '⏸ input'
123
+ : s.closed
124
+ ? '✗ closed'
125
+ : '○ idle'
104
126
  const bits = [
105
127
  mark.padEnd(8),
106
128
  `ws=${s.workspaceId}`,
@@ -108,13 +130,13 @@ export const claudeCodeHarness: Harness = {
108
130
  `model=${s.model ?? 'default'}`,
109
131
  `effort=${s.effort ?? 'default'}`,
110
132
  `stream=${s.stream ? 'on' : 'off'}`,
111
- `pending=${s.pendingTurns}`,
112
133
  `age=${fmtDuration(now - s.createdAt)}`,
113
134
  `lastActivity=${fmtAgo(s.lastActivityAt, now)}`
114
135
  ]
136
+ if (s.bgTasks > 0) bits.push(`bgTasks=${s.bgTasks}`)
115
137
  if (s.desiredEffort !== s.effort) bits.push(`desiredEffort=${s.desiredEffort ?? 'default'}`)
116
138
  if (s.desiredStream !== s.stream) bits.push(`desiredStream=${s.desiredStream ? 'on' : 'off'}`)
117
- if (!s.busy && !s.hasIdleTimer) bits.push('(no idle timer)')
139
+ if (s.activity === 'idle' && !s.hasIdleTimer) bits.push('(no idle timer)')
118
140
  let line = ' ' + bits.join(' ')
119
141
  if (s.lastUserText) line += `\n last: ${JSON.stringify(s.lastUserText)}`
120
142
  lines.push(line)
@@ -1,14 +1,8 @@
1
1
  import { query } from '@anthropic-ai/claude-agent-sdk'
2
- import type {
3
- McpServerConfig,
4
- McpServerStatus,
5
- SDKUserMessage
6
- } from '@anthropic-ai/claude-agent-sdk'
7
- import { join } from 'path'
2
+ import type { McpServerStatus, SDKUserMessage } from '@anthropic-ai/claude-agent-sdk'
8
3
 
9
4
  import { debugEnabled } from '../../debug'
10
-
11
- export type McpScope = 'user' | 'project'
5
+ import { requireHarnessExecutable } from '../executable'
12
6
 
13
7
  // MCP server status probing. Intentionally decoupled from agent chat runs
14
8
  // (cc-session.ts): connecting to MCP servers and reading their status is a
@@ -38,9 +32,9 @@ function isSettled(status: McpServerStatus[]): boolean {
38
32
  // attention (failed / needs-auth / still-pending) called out by name. The full
39
33
  // per-server dump (every `connected` line too) is opt-in via `moi start --debug`.
40
34
  // `connected`/`disabled` are the boring majority, so they're folded into counts.
41
- function logMcpStatus(scope: McpScope, status: McpServerStatus[]): void {
35
+ function logMcpStatus(status: McpServerStatus[]): void {
42
36
  if (debugEnabled) {
43
- console.log(`[mcp:${scope}]`, status.map(s => `${s.name}:${s.status}`).join(', '))
37
+ console.log('[mcp]', status.map(s => `${s.name}:${s.status}`).join(', '))
44
38
  return
45
39
  }
46
40
  const connected = status.filter(s => s.status === 'connected').length
@@ -49,41 +43,10 @@ function logMcpStatus(scope: McpScope, status: McpServerStatus[]): void {
49
43
  const parts = [`${connected} connected`]
50
44
  if (disabled) parts.push(`${disabled} disabled`)
51
45
  for (const s of attention) parts.push(`${s.status}: ${s.name}`)
52
- console.log(`[mcp:${scope}]`, parts.join(' · '))
53
- }
54
-
55
- function isRecord(value: unknown): value is Record<string, unknown> {
56
- return typeof value === 'object' && value !== null && !Array.isArray(value)
46
+ console.log('[mcp]', parts.join(' · '))
57
47
  }
58
48
 
59
- async function projectMcpServers(workspacePath: string): Promise<Record<string, McpServerConfig>> {
60
- const file = Bun.file(join(workspacePath, '.mcp.json'))
61
- if (!(await file.exists())) return {}
62
-
63
- const parsed = await file.json().catch(() => null)
64
- if (!isRecord(parsed) || !isRecord(parsed.mcpServers)) return {}
65
-
66
- const servers: Record<string, McpServerConfig> = {}
67
- for (const [name, config] of Object.entries(parsed.mcpServers)) {
68
- // The SDK owns the detailed MCP config union; here we only need to confirm
69
- // the project JSON declares an object keyed by server name before passing it
70
- // through unchanged.
71
- if (isRecord(config)) servers[name] = config as unknown as McpServerConfig
72
- }
73
- return servers
74
- }
75
-
76
- async function probeMcpStatus(workspacePath: string, scope: McpScope): Promise<McpServerStatus[]> {
77
- // Known gap, revisit: the project probe covers only `.mcp.json` (strict), and
78
- // the user probe runs from the server's cwd — so servers added via `claude
79
- // mcp add` (user scope) or `.claude/settings(.local).json` never appear in
80
- // the workspace connectors menu, even though chat sessions still load them
81
- // (cc-session runs with settingSources ['user','project']). Surfacing those
82
- // scopes here needs a per-workspace user+project probe without double-listing
83
- // servers across the menu and the /connectors page.
84
- const mcpServers = scope === 'project' ? await projectMcpServers(workspacePath) : undefined
85
- if (scope === 'project' && Object.keys(mcpServers ?? {}).length === 0) return []
86
-
49
+ async function probeMcpStatus(workspacePath: string): Promise<McpServerStatus[]> {
87
50
  // A prompt that never yields keeps the session alive without a model turn.
88
51
  let release!: () => void
89
52
  const done = new Promise<void>(r => (release = r))
@@ -98,9 +61,9 @@ async function probeMcpStatus(workspacePath: string, scope: McpScope): Promise<M
98
61
  prompt: keepAlive(),
99
62
  options: {
100
63
  cwd: workspacePath,
64
+ pathToClaudeCodeExecutable: requireHarnessExecutable('claude-code'),
101
65
  persistSession: false,
102
- settingSources: [scope],
103
- ...(mcpServers && { mcpServers, strictMcpConfig: true }),
66
+ settingSources: ['user', 'project'],
104
67
  env: { ...process.env, CLAUDECODE: undefined }
105
68
  }
106
69
  })
@@ -113,7 +76,7 @@ async function probeMcpStatus(workspacePath: string, scope: McpScope): Promise<M
113
76
  if (isSettled(status)) break
114
77
  await new Promise(r => setTimeout(r, POLL_INTERVAL_MS))
115
78
  }
116
- logMcpStatus(scope, status)
79
+ logMcpStatus(status)
117
80
  return status
118
81
  } finally {
119
82
  release()
@@ -150,33 +113,21 @@ const cache = new Map<string, CacheEntry>()
150
113
  // cheap insurance against parallel probes of the same workspace.
151
114
  const inflight = new Map<string, Promise<McpServerStatus[]>>()
152
115
 
153
- function cacheKey(scope: McpScope, workspacePath: string): string {
154
- return `${scope}:${workspacePath}`
155
- }
156
-
157
- export async function getMcpStatus(
158
- workspacePath: string,
159
- scope: McpScope = 'project'
160
- ): Promise<McpServerStatus[]> {
161
- const key = cacheKey(scope, workspacePath)
162
- const cached = cache.get(key)
116
+ export async function getMcpStatus(workspacePath: string): Promise<McpServerStatus[]> {
117
+ const cached = cache.get(workspacePath)
163
118
  if (cached && cached.expiresAt > Date.now()) return cached.status
164
119
 
165
- const existing = inflight.get(key)
120
+ const existing = inflight.get(workspacePath)
166
121
  if (existing) return existing
167
122
 
168
- const probe = probeMcpStatus(workspacePath, scope)
123
+ const probe = probeMcpStatus(workspacePath)
169
124
  .then(status => {
170
125
  const ttl = ttlFor(status)
171
- if (ttl > 0) cache.set(key, { status, expiresAt: Date.now() + ttl })
126
+ if (ttl > 0) cache.set(workspacePath, { status, expiresAt: Date.now() + ttl })
172
127
  return status
173
128
  })
174
- .finally(() => inflight.delete(key))
129
+ .finally(() => inflight.delete(workspacePath))
175
130
 
176
- inflight.set(key, probe)
131
+ inflight.set(workspacePath, probe)
177
132
  return probe
178
133
  }
179
-
180
- export async function getUserMcpStatus(): Promise<McpServerStatus[]> {
181
- return getMcpStatus(process.cwd(), 'user')
182
- }
@@ -1,6 +1,8 @@
1
1
  import { query } from '@anthropic-ai/claude-agent-sdk'
2
2
  import type { ModelInfo } from '@anthropic-ai/claude-agent-sdk'
3
3
 
4
+ import { requireHarnessExecutable } from '../executable'
5
+
4
6
  // Chat runs live in `cc-session.ts` (streaming-input sessions held per thread).
5
7
  // MCP status probing lives in `mcp.ts`. This module now only probes the agent
6
8
  // backend for the model list — spins up a throwaway `query()` and reads metadata.
@@ -13,6 +15,7 @@ async function fetchClaudeModels(cwd: string): Promise<ModelInfo[]> {
13
15
  prompt: '',
14
16
  options: {
15
17
  cwd,
18
+ pathToClaudeCodeExecutable: requireHarnessExecutable('claude-code'),
16
19
  persistSession: false,
17
20
  settingSources: ['user', 'project'],
18
21
  env: { ...process.env, CLAUDECODE: undefined }