moi-computer 0.3.0-next.2 → 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.
Files changed (125) hide show
  1. package/README.md +1 -1
  2. package/client/AGENTS.md +2 -2
  3. package/client/api/http.ts +1 -1
  4. package/client/api/workspace-keys.ts +1 -0
  5. package/client/app/AppRouter.tsx +14 -5
  6. package/client/app/routes/HomeRoute.tsx +1 -1
  7. package/client/app/routes/WorkspaceRoute.tsx +8 -2
  8. package/client/app/shell/SidebarLayout.tsx +10 -5
  9. package/client/assets/openai.svg +3 -0
  10. package/client/components/shared/BottomPanel.tsx +2 -2
  11. package/client/components/ui/button.tsx +3 -2
  12. package/client/components/ui/input.tsx +1 -1
  13. package/client/features/applets/AppletMount.tsx +44 -0
  14. package/client/features/applets/WidgetShell.tsx +4 -1
  15. package/client/features/applets/applet-cache.ts +8 -0
  16. package/client/features/applets/applet-styles.ts +61 -0
  17. package/client/features/chat/ChatComposer.tsx +2 -2
  18. package/client/features/chat/ChatPanel.tsx +8 -25
  19. package/client/features/chat/ChatPopup.tsx +3 -3
  20. package/client/features/chat/{ThreadSelector.tsx → ChatSelector.tsx} +4 -4
  21. package/client/features/chat/TurnView.tsx +8 -9
  22. package/client/features/chat/api.ts +1 -1
  23. package/client/features/chat/chat-send.ts +57 -0
  24. package/client/features/chat/tool-group/ToolCallGroup.tsx +2 -1
  25. package/client/features/chat/tool-group/format.ts +117 -0
  26. package/client/features/chat/useChat.ts +10 -34
  27. package/client/features/connectors/McpMenu.tsx +4 -21
  28. package/client/features/dev/DevRoutes.tsx +18 -0
  29. package/client/features/dev/HarnessDebugPage.tsx +468 -0
  30. package/client/{components/playground → features/dev}/PlaygroundPage.tsx +1 -1
  31. package/client/features/home/CreateWorkspaceDialog.tsx +64 -158
  32. package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
  33. package/client/features/home/HomeLogo.tsx +344 -0
  34. package/client/features/home/HomePage.tsx +15 -21
  35. package/client/features/home/WorkspacePreview.tsx +2 -2
  36. package/client/features/home/api.ts +11 -3
  37. package/client/features/home/workspace-presentation.tsx +4 -4
  38. package/client/features/settings/GeneralSettings.tsx +3 -3
  39. package/client/features/settings/IconPicker.tsx +4 -3
  40. package/client/features/settings/icon-picker-options.ts +0 -131
  41. package/client/features/views/ViewBuilderTab.tsx +153 -0
  42. package/client/features/views/api.ts +124 -0
  43. package/client/features/views/useViewBuilderActions.ts +72 -0
  44. package/client/features/widgets/WidgetGrid.tsx +36 -20
  45. package/client/features/widgets/Widgets.tsx +140 -90
  46. package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -9
  47. package/client/features/workspace/WorkspaceScreen.tsx +179 -40
  48. package/client/features/workspace/WorkspaceTabs.tsx +4 -4
  49. package/client/index.css +0 -35
  50. package/client/index.html +1 -1
  51. package/client/lib/app-icon-registry.ts +145 -0
  52. package/client/runtime/useWorkspaceEvents.ts +3 -1
  53. package/client/theme.css +1 -1
  54. package/dist/chunk-4vf1t6v1.js +10 -0
  55. package/dist/chunk-6c24yndg.js +61 -0
  56. package/dist/chunk-6c8cwpzc.js +1 -0
  57. package/dist/chunk-b4b276wx.js +15 -0
  58. package/dist/{chunk-c4j722at.js → chunk-cs8vbert.js} +2 -2
  59. package/dist/chunk-cwqmay73.css +1 -0
  60. package/dist/chunk-kxmvv1ax.js +48 -0
  61. package/dist/chunk-rq0ar7vp.js +1 -0
  62. package/dist/{chunk-p68fnz3q.js → chunk-vkvb3hjm.js} +1 -1
  63. package/dist/chunk-zpxrb1ce.js +2 -0
  64. package/dist/index.html +2 -2
  65. package/dist/openai-h13pza4b.svg +3 -0
  66. package/lib/format.ts +2 -2
  67. package/lib/types.ts +38 -2
  68. package/lib/view-builder-meta.ts +35 -0
  69. package/lib/workspace-layout.ts +14 -0
  70. package/package.json +2 -1
  71. package/server/AGENTS.md +3 -3
  72. package/server/api.ts +165 -51
  73. package/server/applets.ts +1 -1
  74. package/server/bundle-queue.ts +19 -0
  75. package/server/bundler/applet-css.ts +50 -0
  76. package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
  77. package/server/cli.ts +79 -2
  78. package/server/control.ts +106 -8
  79. package/server/env-apply.ts +2 -2
  80. package/server/harness/README.md +228 -0
  81. package/server/harness/claude-code/NOTES.md +578 -0
  82. package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
  83. package/server/harness/claude-code/index.ts +124 -0
  84. package/server/{mcp.ts → harness/claude-code/mcp.ts} +1 -1
  85. package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
  86. package/server/harness/claude-code/sessions.ts +42 -0
  87. package/server/harness/codex/NOTES.md +239 -0
  88. package/server/harness/codex/adapter.ts +414 -0
  89. package/server/harness/codex/client.ts +343 -0
  90. package/server/harness/codex/index.ts +68 -0
  91. package/server/harness/codex/probe.ts +186 -0
  92. package/server/harness/codex/session.ts +617 -0
  93. package/server/harness/debug.ts +57 -0
  94. package/server/harness/openclaw/NOTES.md +316 -0
  95. package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
  96. package/server/harness/openclaw/index.ts +93 -0
  97. package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
  98. package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
  99. package/server/harness/registry.ts +36 -0
  100. package/server/harness/types.ts +87 -0
  101. package/server/layout.ts +6 -12
  102. package/server/moi-scaffold.ts +1 -1
  103. package/server/registry.ts +14 -52
  104. package/server/state.ts +5 -38
  105. package/server/status.ts +7 -46
  106. package/server/vendor.ts +1 -1
  107. package/server/view-builders.ts +428 -0
  108. package/server/views.ts +0 -0
  109. package/server/web.ts +18 -40
  110. package/server/workspace-init.ts +6 -6
  111. package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -0
  112. package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
  113. package/client/assets/hermes-nous.png +0 -0
  114. package/client/hooks/useScrollFade.ts +0 -38
  115. package/dist/chunk-23cgr1tz.css +0 -1
  116. package/dist/chunk-3hy3qy6d.js +0 -10
  117. package/dist/chunk-dyfaffyz.js +0 -119
  118. package/dist/chunk-kpe40hm8.js +0 -1
  119. package/dist/chunk-ty6dvda0.js +0 -1
  120. package/dist/hermes-nous-pznd63x9.png +0 -0
  121. /package/client/{components/playground → features/dev}/PixelPainter.tsx +0 -0
  122. /package/client/{components/playground → features/dev}/ToolCallsPage.tsx +0 -0
  123. /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
  124. /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
  125. /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
package/server/layout.ts CHANGED
@@ -2,36 +2,30 @@ import { readdir } from 'node:fs/promises'
2
2
  import { join } from 'path'
3
3
 
4
4
  import type { WidgetConfig, WorkspaceLayout, WorkspacePreview, WorkspaceTabId } from '@/lib/types'
5
-
6
- const DEFAULT: WorkspaceLayout = {
7
- version: 1,
8
- widgetGrid: [],
9
- layoutMode: 'fullscreen',
10
- tabs: { open: ['agent'], active: 'agent' }
11
- }
5
+ import { createDefaultWorkspaceLayout, createDefaultWorkspaceTabs } from '@/lib/workspace-layout'
12
6
 
13
7
  function isTabId(value: unknown): value is WorkspaceTabId {
14
8
  return (
15
9
  value === 'agent' ||
16
10
  value === 'widgets' ||
17
11
  value === 'scratchpad' ||
18
- (typeof value === 'string' && /^view:.+/.test(value))
12
+ (typeof value === 'string' && (/^view:.+/.test(value) || /^view-builder:.+/.test(value)))
19
13
  )
20
14
  }
21
15
 
22
16
  function normalizeTabs(value: unknown): WorkspaceLayout['tabs'] {
23
- if (!value || typeof value !== 'object') return { ...DEFAULT.tabs, open: [...DEFAULT.tabs.open] }
17
+ if (!value || typeof value !== 'object') return createDefaultWorkspaceTabs()
24
18
  const raw = value as Record<string, unknown>
25
19
  const open = Array.isArray(raw.open)
26
20
  ? raw.open.filter(isTabId).filter((tab, index, all) => all.indexOf(tab) === index)
27
21
  : []
28
- if (open.length === 0) return { ...DEFAULT.tabs, open: [...DEFAULT.tabs.open] }
22
+ if (open.length === 0) return createDefaultWorkspaceTabs()
29
23
  const active = isTabId(raw.active) && open.includes(raw.active) ? raw.active : open[0]
30
24
  return { open, active }
31
25
  }
32
26
 
33
27
  function normalizeLayout(parsed: Record<string, unknown>): WorkspaceLayout {
34
- const layout = { ...DEFAULT, ...parsed } as Record<string, unknown>
28
+ const layout = { ...createDefaultWorkspaceLayout(), ...parsed } as Record<string, unknown>
35
29
  if (layout.layoutMode !== 'split') layout.layoutMode = 'fullscreen'
36
30
  layout.tabs = normalizeTabs(layout.tabs)
37
31
  delete layout.sectionMode
@@ -53,7 +47,7 @@ export async function loadLayout(workspacePath: string): Promise<WorkspaceLayout
53
47
  const parsed = JSON.parse(text)
54
48
  if (parsed?.version === 1) return normalizeLayout(parsed)
55
49
  } catch {}
56
- return { ...DEFAULT }
50
+ return createDefaultWorkspaceLayout()
57
51
  }
58
52
 
59
53
  export async function saveLayout(layout: WorkspaceLayout, workspacePath: string): Promise<void> {
@@ -6,7 +6,7 @@ import { mkdir } from 'node:fs/promises'
6
6
  import { join, resolve, sep } from 'node:path'
7
7
 
8
8
  // Dependency set available to widgets. `react`/`react-dom` are stubs — at
9
- // runtime they resolve to Moi's locally-vendored ESM via the browser importmap
9
+ // runtime they resolve to moi's locally-vendored ESM via the browser importmap
10
10
  // (/vendor/react); they're listed so editors pick up the correct types.
11
11
  export const MOI_PACKAGE_JSON = {
12
12
  name: 'widgets',
@@ -5,7 +5,7 @@ import { join, resolve, sep } from 'path'
5
5
  import type { DiscoveredWorkspace, WorkspaceEntry, WorkspaceType } from '@/lib/types'
6
6
 
7
7
  import { DATA_DIR } from './data-dir'
8
- import { type OpenClawAgent, discoverOpenClawAgents } from './openclaw'
8
+ import { allHarnesses } from './harness/registry'
9
9
 
10
10
  // Replace the home-dir prefix with `~` for display. Keeps the original
11
11
  // absolute path in place; callers should put the result in `displayPath`.
@@ -138,58 +138,20 @@ export function liftToWorkspaceRoot(p: string): string {
138
138
  return segments.slice(0, i).join(sep) || sep
139
139
  }
140
140
 
141
- // Discover CC-active directories not yet in the registry
142
- async function discoverFromCC(registeredPaths: Set<string>): Promise<string[]> {
143
- try {
144
- const { listSessions } = await import('@anthropic-ai/claude-agent-sdk')
145
- const sessions = await listSessions({})
146
- const { stat } = await import('node:fs/promises')
147
- const paths = new Set<string>()
148
-
149
- for (const s of sessions) {
150
- if (!s.cwd || registeredPaths.has(s.cwd)) continue
151
- try {
152
- const info = await stat(s.cwd)
153
- if (info.isDirectory()) paths.add(s.cwd)
154
- } catch {}
155
- }
156
-
157
- return [...paths]
158
- } catch {
159
- return []
160
- }
161
- }
162
-
163
- // Discover OpenClaw agents via the gateway WebSocket (2s timeout). Returns []
164
- // if the gateway is unreachable, auth is missing, or probes time out.
165
- async function discoverFromOpenClaw(registeredPaths: Set<string>): Promise<OpenClawAgent[]> {
166
- const agents = await discoverOpenClawAgents()
167
- return agents.filter(a => !registeredPaths.has(a.path))
168
- }
169
-
141
+ // Ask every harness for workspaces it knows about that aren't registered yet.
142
+ // Precedence: entries from a specific backend (OpenClaw agents, Codex threads)
143
+ // win over Claude Code's generic session-history scan when they claim the
144
+ // same path — CC sessions exist in most directories an agent ever ran in.
170
145
  export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
171
146
  const registeredPaths = new Set((await readRegistry()).map(e => e.path))
172
- const [ccPaths, openclawAgents] = await Promise.all([
173
- discoverFromCC(registeredPaths),
174
- discoverFromOpenClaw(registeredPaths)
175
- ])
176
- const openclawByPath = new Map(openclawAgents.map(a => [a.path, a]))
177
- const out: DiscoveredWorkspace[] = []
178
- for (const a of openclawAgents) {
179
- out.push(
180
- withDisplayPath({
181
- path: a.path,
182
- type: 'openclaw',
183
- ...(a.name ? { name: a.name } : {}),
184
- ...(a.agentId ? { agentId: a.agentId } : {}),
185
- ...(a.isDefault ? { isDefault: a.isDefault } : {}),
186
- ...(a.lastRunAt ? { lastRunAt: a.lastRunAt } : {})
187
- })
147
+ const perHarness = await Promise.all(
148
+ allHarnesses().map(
149
+ h => h.discoverWorkspaces?.(registeredPaths).catch(() => []) ?? Promise.resolve([])
188
150
  )
189
- }
190
- for (const p of ccPaths) {
191
- if (openclawByPath.has(p)) continue
192
- out.push(withDisplayPath({ path: p, type: 'claude-code' }))
193
- }
194
- return out
151
+ )
152
+ const found = perHarness.flat()
153
+ const specific = found.filter(w => w.type !== 'claude-code')
154
+ const specificPaths = new Set(specific.map(w => w.path))
155
+ const generic = found.filter(w => w.type === 'claude-code' && !specificPaths.has(w.path))
156
+ return [...specific, ...generic].map(withDisplayPath)
195
157
  }
package/server/state.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { getSessionMessages, listSessions } from '@anthropic-ai/claude-agent-sdk'
1
+ import type { BroadcastFrame, ServerMessage } from '@/lib/types'
2
2
 
3
- import { ClaudeAdapter } from '@/lib/claude-adapter'
4
- import type { BroadcastFrame, ServerMessage, SessionInfo, StreamEvent } from '@/lib/types'
3
+ import { tapClientFrame } from './harness/debug'
5
4
 
6
5
  // The chat socket is app-wide (one per client tab, not per workspace), so a
7
6
  // single set of all connected chat clients is enough. Each broadcast frame
@@ -23,7 +22,10 @@ export function getClientCount(): number {
23
22
 
24
23
  // Stamp `workspaceId` onto the frame and fan it out to every connected chat
25
24
  // client. (Phase 1: broadcast-all; Phase 2 will scope by topic subscription.)
25
+ // Every frame is also tapped into the per-workspace debug ring so the
26
+ // /playground/harness page can show exactly what clients received.
26
27
  export function broadcast(workspaceId: string, frame: BroadcastFrame) {
28
+ tapClientFrame(workspaceId, { ...frame, workspaceId })
27
29
  const json = JSON.stringify({ ...frame, workspaceId })
28
30
  for (const ws of chatClients) ws.send(json)
29
31
  }
@@ -36,38 +38,3 @@ export function broadcastAll(msg: ServerMessage) {
36
38
  export function sendToClient(ws: Bun.ServerWebSocket<unknown>, msg: ServerMessage) {
37
39
  ws.send(JSON.stringify(msg))
38
40
  }
39
-
40
- export async function getSessions(workspacePath: string): Promise<SessionInfo[]> {
41
- const sessions = await listSessions({ dir: workspacePath })
42
- return sessions.map(s => ({
43
- sessionId: s.sessionId,
44
- summary: s.summary,
45
- lastModified: s.lastModified,
46
- cwd: s.cwd
47
- }))
48
- }
49
-
50
- /**
51
- * Replay a session's persisted raw messages through a fresh adapter and
52
- * return the resulting StreamEvents. Events are carefully NOT deduplicated —
53
- * the client reducer is idempotent under upsert-by-id.
54
- */
55
- export async function getSessionEvents(
56
- sessionId: string,
57
- workspacePath: string
58
- ): Promise<StreamEvent[]> {
59
- const adapter = new ClaudeAdapter()
60
- const events: StreamEvent[] = []
61
- try {
62
- const raw = await getSessionMessages(sessionId, { dir: workspacePath })
63
- for (const msg of raw) {
64
- // Disk replay carries no `stream_event` messages, so the adapter never
65
- // produces previews here — filter defensively to keep this the pure,
66
- // persisted StreamEvent path that reconnect-healing trusts.
67
- for (const ev of adapter.ingest(msg)) if (ev.kind !== 'preview') events.push(ev)
68
- }
69
- } catch {
70
- // session file missing or unreadable — return whatever we have (often [])
71
- }
72
- return events
73
- }
package/server/status.ts CHANGED
@@ -5,11 +5,10 @@
5
5
  // chat appears stuck (loader spinning) and you want to know whether the server
6
6
  // still holds a live session for that thread, or when a widget's server call
7
7
  // hangs and you want to see whether its worker is alive and what it has loaded.
8
- import { type CCDebugSession, SESSION_LIMITS, getCCDebugSnapshot } from './cc-session'
9
8
  import { CONTROL_PORT, PORT } from './constants'
10
9
  import { debugEnabled } from './debug'
11
10
  import { WORKER_LIMITS, type WorkerDebugInfo, getWorkersDebugSnapshot } from './functions'
12
- import { getOpenClawRunningSessions } from './openclaw-session'
11
+ import { allHarnesses } from './harness/registry'
13
12
  import { tildify } from './registry'
14
13
  import { getClientCount } from './state'
15
14
 
@@ -64,31 +63,8 @@ function workerLine(w: WorkerDebugInfo, now: number): string {
64
63
  return line
65
64
  }
66
65
 
67
- function sessionLine(s: CCDebugSession, now: number): string {
68
- const mark = s.busy ? '▶ busy' : s.closed ? '✗ closed' : '○ idle'
69
- const bits = [
70
- mark.padEnd(8),
71
- `ws=${s.workspaceId}`,
72
- `session=${s.sessionId}`,
73
- `model=${s.model ?? 'default'}`,
74
- `effort=${s.effort ?? 'default'}`,
75
- `stream=${s.stream ? 'on' : 'off'}`,
76
- `pending=${s.pendingTurns}`,
77
- `age=${fmtDuration(now - s.createdAt)}`,
78
- `lastActivity=${fmtAgo(s.lastActivityAt, now)}`
79
- ]
80
- if (s.desiredEffort !== s.effort) bits.push(`desiredEffort=${s.desiredEffort ?? 'default'}`)
81
- if (s.desiredStream !== s.stream) bits.push(`desiredStream=${s.desiredStream ? 'on' : 'off'}`)
82
- if (!s.busy && !s.hasIdleTimer) bits.push('(no idle timer)')
83
- let line = ' ' + bits.join(' ')
84
- if (s.lastUserText) line += `\n last: ${JSON.stringify(s.lastUserText)}`
85
- return line
86
- }
87
-
88
66
  export function renderStatus(): string {
89
67
  const now = Date.now()
90
- const cc = getCCDebugSnapshot()
91
- const openclawRunning = getOpenClawRunningSessions()
92
68
 
93
69
  const lines: string[] = []
94
70
  lines.push('moi server status')
@@ -101,28 +77,13 @@ export function renderStatus(): string {
101
77
  lines.push(`connected tabs ${getClientCount()}`)
102
78
  lines.push('')
103
79
 
104
- const busy = cc.sessions.filter(s => s.busy).length
105
- lines.push(
106
- `live CC sessions ${cc.sessions.length}/${SESSION_LIMITS.maxLive} ` +
107
- `(${busy} busy, ${cc.sessions.length - busy} idle, ${cc.aliases} alias${cc.aliases === 1 ? '' : 'es'}, ` +
108
- `idle TTL ${fmtDuration(SESSION_LIMITS.idleTtlMs)})`
109
- )
110
- if (cc.sessions.length === 0) {
111
- lines.push(' (none held in memory — next message will resume from disk)')
112
- } else {
113
- // Busiest / most-recently-active first.
114
- const sorted = [...cc.sessions].sort(
115
- (a, b) => Number(b.busy) - Number(a.busy) || b.lastActivityAt - a.lastActivityAt
116
- )
117
- for (const s of sorted) lines.push(sessionLine(s, now))
118
- }
119
- lines.push('')
120
-
121
- lines.push(`live OpenClaw runs ${openclawRunning.length}`)
122
- for (const r of openclawRunning) {
123
- lines.push(` ▶ busy ws=${r.workspaceId} session=${r.sessionId}`)
80
+ // One section per harness — each formats its own live-session view.
81
+ for (const h of allHarnesses()) {
82
+ const section = h.statusLines?.(now)
83
+ if (!section?.length) continue
84
+ lines.push(...section)
85
+ lines.push('')
124
86
  }
125
- lines.push('')
126
87
 
127
88
  const workers = getWorkersDebugSnapshot()
128
89
  lines.push(
package/server/vendor.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Serves the locally-vendored React ESM (client/vendor/react, generated by
2
2
  // scripts/build-vendor.ts) behind the stable `/vendor/react/*` URLs the
3
- // importmap in client/index.html points at. This is what makes Moi run offline
3
+ // importmap in client/index.html points at. This is what makes moi run offline
4
4
  // — no esm.sh fetch.
5
5
  //
6
6
  // The importmap URLs carry no dev/prod distinction; we pick the build here so