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.
- package/README.md +49 -12
- package/client/api/workspace-keys.ts +2 -2
- package/client/app/AppRouter.tsx +0 -2
- package/client/app/shell/SidebarLayout.tsx +3 -16
- package/client/assets/openai.svg +1 -3
- package/client/components/shared/Composer.tsx +53 -2
- package/client/components/ui/button.tsx +1 -1
- package/client/components/ui/tooltip.tsx +12 -15
- package/client/features/chat/ChatComposer.tsx +25 -15
- package/client/features/chat/ChatPanel.tsx +5 -2
- package/client/features/chat/MarkdownContent.tsx +20 -2
- package/client/features/chat/ModelPicker.tsx +5 -3
- package/client/features/chat/TurnView.tsx +2 -2
- package/client/features/chat/chat-frames.ts +13 -6
- package/client/features/chat/chat-send.ts +1 -1
- package/client/features/chat/chat-store.ts +22 -17
- package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
- package/client/features/chat/tool-group/format.ts +22 -7
- package/client/features/chat/useChat.ts +11 -2
- package/client/features/connectors/McpServerCards.tsx +95 -0
- package/client/features/connectors/api.ts +0 -11
- package/client/features/dev/HarnessDebugPage.tsx +210 -74
- package/client/features/home/HomePage.tsx +33 -28
- package/client/features/home/api.ts +24 -12
- package/client/features/home/workspace-presentation.tsx +17 -15
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
- package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
- package/client/features/settings/ConnectorsSettings.tsx +89 -0
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +8 -4
- package/client/features/views/ViewBuilderTab.tsx +19 -15
- package/client/features/views/useViewBuilderActions.ts +1 -1
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
- package/client/features/workspace/WorkspaceScreen.tsx +11 -3
- package/client/features/workspace/api.ts +19 -1
- package/client/features/workspace/moi-context.ts +85 -0
- package/client/main.tsx +16 -5
- package/dist/chunk-19g80zc9.css +1 -0
- package/dist/{chunk-jen6xcm1.js → chunk-2vaafjp4.js} +1 -1
- package/dist/{chunk-vkvb3hjm.js → chunk-35fq49qa.js} +1 -1
- package/dist/chunk-69nhbjhy.js +50 -0
- package/dist/{chunk-axszxe4c.js → chunk-72atbmh3.js} +1 -1
- package/dist/{chunk-zpxrb1ce.js → chunk-7mkv2gr0.js} +2 -2
- package/dist/{chunk-cs8vbert.js → chunk-fh2mf6v9.js} +3 -3
- package/dist/chunk-gt7n06ef.js +1 -0
- package/dist/chunk-jwmc32rp.js +63 -0
- package/dist/chunk-kh24bstm.js +10 -0
- package/dist/chunk-sfa4mbmx.js +15 -0
- package/dist/index.html +1 -1
- package/dist/openai-ep9ht2pq.svg +1 -0
- package/lib/ids.ts +15 -0
- package/lib/moi-context.ts +170 -0
- package/lib/types.ts +29 -11
- package/lib/view-builder-directives.ts +16 -0
- package/lib/workspace-types.ts +12 -0
- package/package.json +2 -1
- package/server/api.ts +92 -30
- package/server/harness/README.md +25 -9
- package/server/harness/claude-code/NOTES.md +20 -6
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/git-worktree.ts +32 -0
- package/server/harness/claude-code/index.ts +33 -12
- package/server/harness/claude-code/mcp.ts +16 -65
- package/server/harness/claude-code/models.ts +3 -0
- package/server/harness/claude-code/session.ts +196 -61
- package/server/harness/codex/NOTES.md +41 -11
- package/server/harness/codex/adapter.ts +121 -16
- package/server/harness/codex/client.ts +67 -18
- package/server/harness/codex/discovery.ts +114 -0
- package/server/harness/codex/index.ts +10 -5
- package/server/harness/codex/probe.ts +4 -2
- package/server/harness/codex/session.ts +89 -13
- package/server/harness/executable.ts +82 -0
- package/server/harness/openclaw/adapter.ts +8 -1
- package/server/harness/openclaw/index.ts +8 -14
- package/server/harness/openclaw/session.ts +50 -10
- package/server/harness/openclaw/strip.ts +2 -2
- package/server/harness/shell-path.ts +79 -0
- package/server/harness/types.ts +22 -5
- package/server/registry.ts +57 -12
- package/server/view-builders.ts +3 -2
- package/server/web.ts +24 -8
- package/server/workspace-import.ts +45 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +3 -3
- package/client/features/connectors/ConnectorsPage.tsx +0 -92
- package/client/features/connectors/McpMenu.tsx +0 -145
- package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
- package/dist/chunk-4vf1t6v1.js +0 -10
- package/dist/chunk-6c8cwpzc.js +0 -1
- package/dist/chunk-b3ynfk4g.js +0 -62
- package/dist/chunk-b4b276wx.js +0 -15
- package/dist/chunk-kxmvv1ax.js +0 -48
- package/dist/chunk-npwq6jmr.css +0 -1
- package/dist/openai-h13pza4b.svg +0 -3
- package/lib/view-builder-meta.ts +0 -35
package/server/registry.ts
CHANGED
|
@@ -2,10 +2,13 @@ import { mkdir } from 'node:fs/promises'
|
|
|
2
2
|
import { homedir } from 'node:os'
|
|
3
3
|
import { join, resolve, sep } from 'path'
|
|
4
4
|
|
|
5
|
+
import { newWorkspaceId } from '@/lib/ids'
|
|
5
6
|
import type { DiscoveredWorkspace, WorkspaceEntry, WorkspaceType } from '@/lib/types'
|
|
7
|
+
import { orderWorkspaceTypes } from '@/lib/workspace-types'
|
|
6
8
|
|
|
7
9
|
import { DATA_DIR } from './data-dir'
|
|
8
10
|
import { allHarnesses } from './harness/registry'
|
|
11
|
+
import type { DiscoveredWorkspaceCandidate } from './harness/types'
|
|
9
12
|
|
|
10
13
|
// Replace the home-dir prefix with `~` for display. Keeps the original
|
|
11
14
|
// absolute path in place; callers should put the result in `displayPath`.
|
|
@@ -61,7 +64,7 @@ export async function registerWorkspace(
|
|
|
61
64
|
const existing = entries.find(e => e.path === normalPath)
|
|
62
65
|
if (existing) return existing
|
|
63
66
|
const entry: WorkspaceEntry = {
|
|
64
|
-
id:
|
|
67
|
+
id: newWorkspaceId(),
|
|
65
68
|
path: normalPath,
|
|
66
69
|
addedAt: new Date().toISOString(),
|
|
67
70
|
...(opts.type ? { type: opts.type } : {}),
|
|
@@ -138,20 +141,62 @@ export function liftToWorkspaceRoot(p: string): string {
|
|
|
138
141
|
return segments.slice(0, i).join(sep) || sep
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// same path — CC sessions exist in most directories an agent ever ran in.
|
|
145
|
-
export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
146
|
-
const registeredPaths = new Set((await readRegistry()).map(e => e.path))
|
|
144
|
+
async function collectDiscoveredWorkspaces(
|
|
145
|
+
registeredPaths: Set<string>
|
|
146
|
+
): Promise<DiscoveredWorkspaceCandidate[]> {
|
|
147
147
|
const perHarness = await Promise.all(
|
|
148
148
|
allHarnesses().map(
|
|
149
149
|
h => h.discoverWorkspaces?.(registeredPaths).catch(() => []) ?? Promise.resolve([])
|
|
150
150
|
)
|
|
151
151
|
)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
return perHarness.flat()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function groupDiscoveredWorkspaces(
|
|
156
|
+
candidates: DiscoveredWorkspaceCandidate[],
|
|
157
|
+
registeredPaths: Set<string> = new Set()
|
|
158
|
+
): DiscoveredWorkspace[] {
|
|
159
|
+
const normalizedRegisteredPaths = new Set([...registeredPaths].map(path => resolve(path)))
|
|
160
|
+
const byPath = new Map<string, Set<WorkspaceType>>()
|
|
161
|
+
|
|
162
|
+
for (const candidate of candidates) {
|
|
163
|
+
const path = resolve(candidate.path)
|
|
164
|
+
if (normalizedRegisteredPaths.has(path)) continue
|
|
165
|
+
const types = byPath.get(path) ?? new Set<WorkspaceType>()
|
|
166
|
+
types.add(candidate.type)
|
|
167
|
+
byPath.set(path, types)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return [...byPath].map(([path, types]) => ({
|
|
171
|
+
path,
|
|
172
|
+
types: orderWorkspaceTypes(types)
|
|
173
|
+
}))
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function discoveredWorkspaceForPath(
|
|
177
|
+
path: string,
|
|
178
|
+
candidates: DiscoveredWorkspaceCandidate[]
|
|
179
|
+
): DiscoveredWorkspace {
|
|
180
|
+
const normalizedPath = resolve(path)
|
|
181
|
+
return (
|
|
182
|
+
groupDiscoveredWorkspaces(candidates).find(workspace => workspace.path === normalizedPath) ?? {
|
|
183
|
+
path: normalizedPath,
|
|
184
|
+
types: []
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Ask every harness for workspaces it knows about that aren't registered yet,
|
|
190
|
+
// then combine providers that claim the same normalized folder.
|
|
191
|
+
export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
192
|
+
const registeredPaths = new Set((await readRegistry()).map(e => e.path))
|
|
193
|
+
const found = await collectDiscoveredWorkspaces(registeredPaths)
|
|
194
|
+
return groupDiscoveredWorkspaces(found, registeredPaths).map(withDisplayPath)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Inspect one folder through the same provider discovery used by the home
|
|
198
|
+
// suggestions. An empty types list means no provider recognized the folder.
|
|
199
|
+
export async function discoverWorkspace(path: string): Promise<DiscoveredWorkspace> {
|
|
200
|
+
const found = await collectDiscoveredWorkspaces(new Set())
|
|
201
|
+
return withDisplayPath(discoveredWorkspaceForPath(path, found))
|
|
157
202
|
}
|
package/server/view-builders.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdir, rename } from 'node:fs/promises'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
|
|
4
|
+
import { newBuilderId } from '@/lib/ids'
|
|
4
5
|
import type { AppletKind, ViewBuilder, ViewInfo } from '@/lib/types'
|
|
5
6
|
|
|
6
7
|
import { DATA_DIR } from './data-dir'
|
|
@@ -107,7 +108,7 @@ export async function createViewBuilder(
|
|
|
107
108
|
const builder = await mutateBuilders(workspacePath, builders => {
|
|
108
109
|
const now = Date.now()
|
|
109
110
|
const created: ViewBuilder = {
|
|
110
|
-
id:
|
|
111
|
+
id: newBuilderId(),
|
|
111
112
|
kind: 'view',
|
|
112
113
|
status: 'draft',
|
|
113
114
|
input: { requirements: '' },
|
|
@@ -215,7 +216,7 @@ export async function setBuilder(
|
|
|
215
216
|
const now = Date.now()
|
|
216
217
|
const status = input.status ?? 'building'
|
|
217
218
|
const created: ViewBuilder = {
|
|
218
|
-
id:
|
|
219
|
+
id: newBuilderId(),
|
|
219
220
|
kind,
|
|
220
221
|
status,
|
|
221
222
|
input: { requirements: '' },
|
package/server/web.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ClientMessage } from '@/lib/types'
|
|
1
|
+
import type { ClientMessage, StatusSnapshotMessage } from '@/lib/types'
|
|
2
|
+
import { isMoiContext } from '@/lib/moi-context'
|
|
2
3
|
|
|
3
4
|
import index from '../client/index.html'
|
|
4
5
|
import { api } from './api'
|
|
@@ -10,7 +11,7 @@ import { startScratchpadSweeper } from './scratchpad'
|
|
|
10
11
|
import { resolveScratchOp } from './scratchpad-relay'
|
|
11
12
|
import { allHarnesses, harnessFor } from './harness/registry'
|
|
12
13
|
import { getWorkspace } from './registry'
|
|
13
|
-
import { addClient, removeClient, sendToClient } from './state'
|
|
14
|
+
import { addClient, broadcastAll, getClientCount, removeClient, sendToClient } from './state'
|
|
14
15
|
import { distShell, prebuilt } from './static'
|
|
15
16
|
import { renderStatus } from './status'
|
|
16
17
|
import { serveVendorEmojibase, serveVendorReact } from './vendor'
|
|
@@ -29,6 +30,7 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
29
30
|
model?: unknown
|
|
30
31
|
effort?: unknown
|
|
31
32
|
stream?: unknown
|
|
33
|
+
context?: unknown
|
|
32
34
|
attachments?: unknown
|
|
33
35
|
opId?: unknown
|
|
34
36
|
}
|
|
@@ -42,6 +44,7 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
42
44
|
(v.model === undefined || typeof v.model === 'string') &&
|
|
43
45
|
(v.effort === undefined || typeof v.effort === 'string') &&
|
|
44
46
|
(v.stream === undefined || typeof v.stream === 'boolean') &&
|
|
47
|
+
(v.context === undefined || isMoiContext(v.context)) &&
|
|
45
48
|
(v.attachments === undefined ||
|
|
46
49
|
(Array.isArray(v.attachments) && v.attachments.every(a => typeof a === 'string')))
|
|
47
50
|
)
|
|
@@ -55,6 +58,13 @@ function isClientMessage(value: unknown): value is ClientMessage {
|
|
|
55
58
|
// stays here, in the routes table, so Bun's dev bundler keys off it.
|
|
56
59
|
const shell = prebuilt ? distShell : index
|
|
57
60
|
|
|
61
|
+
// Authoritative activity snapshot across all harnesses. Sent on chat-socket
|
|
62
|
+
// connect and re-broadcast periodically (below) so a spinner whose terminal
|
|
63
|
+
// status frame was lost self-heals without a reconnect.
|
|
64
|
+
function statusSnapshot(): StatusSnapshotMessage {
|
|
65
|
+
return { type: 'status_snapshot', sessions: allHarnesses().flatMap(h => h.activeSessions()) }
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
type Upgradable = { upgrade(req: Request, opts: { data: WsData }): boolean }
|
|
59
69
|
|
|
60
70
|
function upgrade(server: Upgradable, req: Request, data: WsData) {
|
|
@@ -89,7 +99,6 @@ export const app = Bun.serve<WsData>({
|
|
|
89
99
|
|
|
90
100
|
// Client-side routes — serve the SPA shell.
|
|
91
101
|
'/': shell,
|
|
92
|
-
'/connectors': shell,
|
|
93
102
|
'/dev': shell,
|
|
94
103
|
'/dev/*': shell,
|
|
95
104
|
'/workspace/*': shell,
|
|
@@ -111,11 +120,10 @@ export const app = Bun.serve<WsData>({
|
|
|
111
120
|
open(ws) {
|
|
112
121
|
if (ws.data.channel === 'chat') {
|
|
113
122
|
addClient(ws)
|
|
114
|
-
// Authoritative snapshot of every
|
|
115
|
-
// so the client can light/clear spinners correctly even for
|
|
116
|
-
// status transitions it missed while disconnected.
|
|
117
|
-
|
|
118
|
-
sendToClient(ws, { type: 'status_snapshot', running })
|
|
123
|
+
// Authoritative snapshot of every non-idle session across all
|
|
124
|
+
// harnesses so the client can light/clear spinners correctly even for
|
|
125
|
+
// runs whose status transitions it missed while disconnected.
|
|
126
|
+
sendToClient(ws, statusSnapshot())
|
|
119
127
|
} else {
|
|
120
128
|
ws.subscribe(EVENTS_TOPIC)
|
|
121
129
|
}
|
|
@@ -144,6 +152,7 @@ export const app = Bun.serve<WsData>({
|
|
|
144
152
|
model: data.model,
|
|
145
153
|
effort: data.effort,
|
|
146
154
|
stream: data.stream,
|
|
155
|
+
context: data.context,
|
|
147
156
|
agentId: workspace.agentId
|
|
148
157
|
})
|
|
149
158
|
.catch(() => {})
|
|
@@ -173,6 +182,13 @@ export const app = Bun.serve<WsData>({
|
|
|
173
182
|
// importing web.ts (which binds ports on load).
|
|
174
183
|
setEventServer(app)
|
|
175
184
|
|
|
185
|
+
// The snapshot heartbeat: the client's reconcile fully replaces its activity
|
|
186
|
+
// map from each snapshot, so any stale spinner clears within one interval.
|
|
187
|
+
const SNAPSHOT_INTERVAL_MS = 30_000
|
|
188
|
+
setInterval(() => {
|
|
189
|
+
if (getClientCount() > 0) broadcastAll(statusSnapshot())
|
|
190
|
+
}, SNAPSHOT_INTERVAL_MS)
|
|
191
|
+
|
|
176
192
|
// Periodically reclaim scratchpad asset files nothing references anymore —
|
|
177
193
|
// deleting an image in the browser (or an upload whose tab died) otherwise
|
|
178
194
|
// leaves its file behind forever. See sweepOrphanAssets.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
|
|
3
|
+
import type { WorkspaceType } from '@/lib/types'
|
|
4
|
+
|
|
5
|
+
import { discoverOpenClawAgents } from './harness/openclaw/discovery'
|
|
6
|
+
import type { OpenClawAgent } from './harness/openclaw/discovery'
|
|
7
|
+
|
|
8
|
+
export type WorkspaceImportMetadata = {
|
|
9
|
+
name?: string
|
|
10
|
+
agentId?: string
|
|
11
|
+
isDefault?: boolean
|
|
12
|
+
lastRunAt?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type DiscoverOpenClawAgents = () => Promise<OpenClawAgent[]>
|
|
16
|
+
|
|
17
|
+
function compareOpenClawAgents(a: OpenClawAgent, b: OpenClawAgent): number {
|
|
18
|
+
if (a.isDefault !== b.isDefault) return a.isDefault ? -1 : 1
|
|
19
|
+
const byLastRun = (b.lastRunAt ?? '').localeCompare(a.lastRunAt ?? '')
|
|
20
|
+
return byLastRun || a.agentId.localeCompare(b.agentId)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function resolveWorkspaceImportMetadata(
|
|
24
|
+
path: string,
|
|
25
|
+
type: WorkspaceType,
|
|
26
|
+
discoverAgents: DiscoverOpenClawAgents = discoverOpenClawAgents
|
|
27
|
+
): Promise<WorkspaceImportMetadata> {
|
|
28
|
+
if (type !== 'openclaw') return {}
|
|
29
|
+
|
|
30
|
+
const normalizedPath = resolve(path)
|
|
31
|
+
const agent = (await discoverAgents())
|
|
32
|
+
.filter(candidate => resolve(candidate.path) === normalizedPath)
|
|
33
|
+
.sort(compareOpenClawAgents)[0]
|
|
34
|
+
|
|
35
|
+
if (!agent) {
|
|
36
|
+
throw new Error('OpenClaw is not initialized for this folder')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...(agent.name ? { name: agent.name } : {}),
|
|
41
|
+
agentId: agent.agentId,
|
|
42
|
+
...(agent.isDefault ? { isDefault: true } : {}),
|
|
43
|
+
...(agent.lastRunAt ? { lastRunAt: agent.lastRunAt } : {})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: moi-workspace
|
|
3
|
-
description: The moi workspace — the web UI the user chats from, extended with agent-authored applets (widgets, views) plus theme & config. Read this FIRST in two cases. (a) A message carries hidden <moi>…</moi>
|
|
3
|
+
description: The moi workspace — the web UI the user chats from, extended with agent-authored applets (widgets, views) plus theme & config. Read this FIRST in two cases. (a) A message carries a hidden <moi-context>…</moi-context> envelope: it was fired from a moi workspace, so you are running inside one even if nothing else says so. (b) The user uses moi vocab — workspace, applet, widget, view, scratchpad, dashboard, or a `moi` command — or asks to build, edit, customize, or theme the workspace UI or its layout.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Workspace
|
|
@@ -289,7 +289,7 @@ Full-screen apps, one per nav tab — the user switches tabs; there is no routin
|
|
|
289
289
|
|
|
290
290
|
## View builder requests
|
|
291
291
|
|
|
292
|
-
When the
|
|
292
|
+
When the message's hidden `<moi-context>` envelope is marked `View builder request`, this chat is
|
|
293
293
|
linked to a pending view tab. Before reading files, planning, or writing code, infer a short stable
|
|
294
294
|
id, a clear sentence-case title, and a relevant icon from the requirements. Capitalize only the
|
|
295
295
|
first word of the title. Your first action must claim them:
|
|
@@ -328,4 +328,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
|
|
|
328
328
|
- **Then** — if you updated, mention it.
|
|
329
329
|
|
|
330
330
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
331
|
-
<moi-skill version="0.
|
|
331
|
+
<moi-skill version="0.7.0" />
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { type ReactElement, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconX } from '@tabler/icons-react'
|
|
4
|
-
import { useLocation } from 'wouter'
|
|
5
|
-
|
|
6
|
-
import { useAddWorkspace, useChooseFolder, useCreateWorkspace, useCreateWorkspaceInfo } from './api'
|
|
7
|
-
import { WorkspaceAgentStep, WorkspaceNameStep } from './CreateWorkspaceDialogSteps'
|
|
8
|
-
import { Button } from '@/client/components/ui/button'
|
|
9
|
-
import { Dialog, DialogClose, DialogContent, DialogTrigger } from '@/client/components/ui/dialog'
|
|
10
|
-
import { validateWorkspaceFolderName } from '@/lib/workspace-name'
|
|
11
|
-
import type { WorkspaceType } from '@/lib/types'
|
|
12
|
-
|
|
13
|
-
type CreateWorkspaceDialogProps = {
|
|
14
|
-
trigger: ReactElement
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type CreateWorkspaceStep = 'agent' | 'name'
|
|
18
|
-
|
|
19
|
-
const DEFAULT_WORKSPACE_TYPE: WorkspaceType = 'claude-code'
|
|
20
|
-
|
|
21
|
-
export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
|
|
22
|
-
const [, navigate] = useLocation()
|
|
23
|
-
const info = useCreateWorkspaceInfo()
|
|
24
|
-
const createMutation = useCreateWorkspace()
|
|
25
|
-
const addMutation = useAddWorkspace()
|
|
26
|
-
const chooseFolder = useChooseFolder()
|
|
27
|
-
|
|
28
|
-
const [open, setOpen] = useState(false)
|
|
29
|
-
const [step, setStep] = useState<CreateWorkspaceStep>('agent')
|
|
30
|
-
const [type, setType] = useState<WorkspaceType>(DEFAULT_WORKSPACE_TYPE)
|
|
31
|
-
const [name, setName] = useState('')
|
|
32
|
-
|
|
33
|
-
const trimmedName = name.trim()
|
|
34
|
-
const nameError = trimmedName ? validateWorkspaceFolderName(trimmedName) : null
|
|
35
|
-
const canChooseFolder = info.data?.canChooseFolder ?? true
|
|
36
|
-
const isImporting = chooseFolder.isPending || addMutation.isPending
|
|
37
|
-
const isCreating = createMutation.isPending
|
|
38
|
-
|
|
39
|
-
function resetDialog() {
|
|
40
|
-
setOpen(false)
|
|
41
|
-
setStep('agent')
|
|
42
|
-
setType(DEFAULT_WORKSPACE_TYPE)
|
|
43
|
-
setName('')
|
|
44
|
-
chooseFolder.reset()
|
|
45
|
-
addMutation.reset()
|
|
46
|
-
createMutation.reset()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function handleOpenChange(nextOpen: boolean) {
|
|
50
|
-
if (nextOpen) {
|
|
51
|
-
setOpen(true)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
resetDialog()
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function finish(workspaceId: string) {
|
|
58
|
-
resetDialog()
|
|
59
|
-
navigate(`/workspace/${workspaceId}`)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function handleUseExisting() {
|
|
63
|
-
if (isImporting) return
|
|
64
|
-
|
|
65
|
-
chooseFolder.reset()
|
|
66
|
-
addMutation.reset()
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const result = await chooseFolder.mutateAsync()
|
|
70
|
-
if ('canceled' in result) return
|
|
71
|
-
const entry = await addMutation.mutateAsync({ path: result.path, type })
|
|
72
|
-
finish(entry.id)
|
|
73
|
-
} catch {
|
|
74
|
-
// The active step renders the mutation error.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function handleContinue() {
|
|
79
|
-
createMutation.reset()
|
|
80
|
-
setStep('name')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function handleCreate() {
|
|
84
|
-
if (!trimmedName || nameError || isCreating) return
|
|
85
|
-
|
|
86
|
-
createMutation.reset()
|
|
87
|
-
createMutation.mutate({ name: trimmedName, type }, { onSuccess: entry => finish(entry.id) })
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Dialog open={open} onOpenChange={handleOpenChange}>
|
|
92
|
-
<DialogTrigger render={trigger} />
|
|
93
|
-
<DialogContent className="w-[calc(100%-2rem)] max-w-lg p-6">
|
|
94
|
-
<DialogClose
|
|
95
|
-
render={
|
|
96
|
-
<Button
|
|
97
|
-
variant="ghost"
|
|
98
|
-
size="icon-sm"
|
|
99
|
-
aria-label="Close"
|
|
100
|
-
className="absolute top-4 right-4"
|
|
101
|
-
>
|
|
102
|
-
<IconX stroke={1.75} />
|
|
103
|
-
</Button>
|
|
104
|
-
}
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
{step === 'agent' ? (
|
|
108
|
-
<WorkspaceAgentStep
|
|
109
|
-
type={type}
|
|
110
|
-
canChooseFolder={canChooseFolder}
|
|
111
|
-
isPending={isImporting}
|
|
112
|
-
errorMessage={(chooseFolder.error ?? addMutation.error)?.message}
|
|
113
|
-
onTypeChange={setType}
|
|
114
|
-
onUseExisting={handleUseExisting}
|
|
115
|
-
onContinue={handleContinue}
|
|
116
|
-
/>
|
|
117
|
-
) : (
|
|
118
|
-
<WorkspaceNameStep
|
|
119
|
-
name={name}
|
|
120
|
-
validationError={nameError}
|
|
121
|
-
requestError={createMutation.error?.message}
|
|
122
|
-
isPending={isCreating}
|
|
123
|
-
onNameChange={setName}
|
|
124
|
-
onSubmit={handleCreate}
|
|
125
|
-
/>
|
|
126
|
-
)}
|
|
127
|
-
</DialogContent>
|
|
128
|
-
</Dialog>
|
|
129
|
-
)
|
|
130
|
-
}
|