moi-computer 0.3.0-next.1 → 0.3.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +1 -1
  2. package/bunfig.toml +5 -1
  3. package/client/AGENTS.md +17 -2
  4. package/client/accept-hmr-dependencies.ts +22 -0
  5. package/client/api/http.ts +31 -0
  6. package/client/api/query-options.ts +6 -0
  7. package/client/api/workspace-keys.ts +18 -0
  8. package/client/app/AppRouter.tsx +44 -0
  9. package/client/app/routes/HomeRoute.tsx +13 -0
  10. package/client/app/routes/WorkspaceRoute.tsx +95 -0
  11. package/client/app/shell/SidebarLayout.tsx +196 -0
  12. package/client/assets/openai.svg +3 -0
  13. package/client/assets.d.ts +9 -0
  14. package/client/components/{BottomPanel.tsx → shared/BottomPanel.tsx} +2 -2
  15. package/client/components/shared/PanelHeader.tsx +9 -0
  16. package/client/components/shared/ReorderableList.tsx +199 -0
  17. package/client/components/ui/button.tsx +11 -7
  18. package/client/components/ui/collapsible.tsx +15 -0
  19. package/client/components/ui/dialog.tsx +2 -2
  20. package/client/components/ui/dropdown-menu.tsx +5 -5
  21. package/client/components/ui/hover-card.tsx +1 -1
  22. package/client/components/ui/input.tsx +1 -1
  23. package/client/components/ui/popover.tsx +1 -1
  24. package/client/components/ui/skeleton.tsx +13 -0
  25. package/client/components/ui/tooltip.tsx +1 -1
  26. package/client/externalize-react.ts +7 -1
  27. package/client/features/applets/AppletMount.tsx +44 -0
  28. package/client/{components → features/applets}/WidgetErrorBoundary.tsx +1 -1
  29. package/client/{components → features/applets}/WidgetShell.tsx +5 -2
  30. package/client/{lib → features/applets}/applet-cache.ts +8 -0
  31. package/client/features/applets/applet-styles.ts +61 -0
  32. package/client/{hooks → features/applets}/useApplet.ts +6 -7
  33. package/client/{components/ChatInput.tsx → features/chat/ChatComposer.tsx} +30 -24
  34. package/client/features/chat/ChatPanel.tsx +171 -0
  35. package/client/{components → features/chat}/ChatPopup.tsx +24 -13
  36. package/client/{components/ThreadSelector.tsx → features/chat/ChatSelector.tsx} +15 -13
  37. package/client/{components → features/chat}/MarkdownContent.tsx +1 -1
  38. package/client/{components → features/chat}/ModelPicker.tsx +68 -17
  39. package/client/{components → features/chat}/TurnView.tsx +17 -11
  40. package/client/features/chat/api.ts +78 -0
  41. package/client/features/chat/chat-connection.ts +107 -0
  42. package/client/features/chat/chat-frames.ts +131 -0
  43. package/client/features/chat/chat-send.ts +57 -0
  44. package/client/{lib → features/chat}/preview-turn.ts +1 -1
  45. package/client/{components → features/chat}/tool-group/ReadImagePreview.tsx +1 -1
  46. package/client/{components → features/chat}/tool-group/SubagentCard.tsx +12 -10
  47. package/client/{components → features/chat}/tool-group/TimelineRow.tsx +5 -5
  48. package/client/{components → features/chat}/tool-group/ToolCallGroup.tsx +14 -5
  49. package/client/{components → features/chat}/tool-group/ToolOutput.tsx +12 -18
  50. package/client/{components → features/chat}/tool-group/format.ts +117 -0
  51. package/client/{hooks → features/chat}/useChat.ts +16 -44
  52. package/client/features/connectors/ConnectorsPage.tsx +92 -0
  53. package/client/features/connectors/McpMenu.tsx +145 -0
  54. package/client/features/connectors/api.ts +28 -0
  55. package/client/features/dev/DevRoutes.tsx +18 -0
  56. package/client/features/dev/HarnessDebugPage.tsx +468 -0
  57. package/client/{components/playground → features/dev}/PixelPainter.tsx +10 -21
  58. package/client/{components/playground → features/dev}/PlaygroundPage.tsx +10 -12
  59. package/client/{components/playground → features/dev}/ToolCallsPage.tsx +9 -11
  60. package/client/features/home/CreateWorkspaceDialog.tsx +130 -0
  61. package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
  62. package/client/features/home/HomeLogo.tsx +344 -0
  63. package/client/features/home/HomePage.tsx +214 -0
  64. package/client/{components → features/home}/WorkspacePreview.tsx +4 -4
  65. package/client/features/home/api.ts +156 -0
  66. package/client/features/home/workspace-presentation.tsx +44 -0
  67. package/client/features/scratchpad/Scratchpad.tsx +312 -0
  68. package/client/features/scratchpad/ScratchpadControls.tsx +503 -0
  69. package/client/features/scratchpad/useScratchpadSnapshot.tsx +115 -0
  70. package/client/features/settings/EnvironmentSettings.tsx +149 -0
  71. package/client/features/settings/GeneralSettings.tsx +90 -0
  72. package/client/{components → features}/settings/IconPicker.tsx +76 -224
  73. package/client/features/settings/SettingsLayout.tsx +53 -0
  74. package/client/{components → features}/settings/WorkspaceSettings.tsx +12 -16
  75. package/client/features/settings/api.ts +88 -0
  76. package/client/features/settings/icon-picker-options.ts +30 -0
  77. package/client/{hooks → features/settings}/useEnvVars.ts +4 -4
  78. package/client/features/views/ViewBuilderTab.tsx +153 -0
  79. package/client/features/views/api.ts +124 -0
  80. package/client/features/views/useViewBuilderActions.ts +72 -0
  81. package/client/{components → features/widgets}/HiddenPanel.tsx +3 -3
  82. package/client/{components → features/widgets}/WidgetFrame.tsx +3 -8
  83. package/client/{components → features/widgets}/WidgetGrid.tsx +38 -29
  84. package/client/features/widgets/Widgets.tsx +265 -0
  85. package/client/{lib/grid-pack.ts → features/widgets/grid.ts} +7 -1
  86. package/client/{hooks → features/widgets}/useGridReconcile.ts +1 -1
  87. package/client/{components → features/workspace}/CustomizePanel.tsx +5 -6
  88. package/client/{lib → features/workspace}/WorkspaceLayoutContext.tsx +16 -15
  89. package/client/features/workspace/WorkspaceScreen.tsx +675 -0
  90. package/client/features/workspace/WorkspaceTabs.tsx +205 -0
  91. package/client/features/workspace/api.ts +56 -0
  92. package/client/features/workspace/useFitsSplitLayout.ts +37 -0
  93. package/client/global.d.ts +5 -0
  94. package/client/index.css +6 -45
  95. package/client/index.html +2 -2
  96. package/client/index.tsx +14 -31
  97. package/client/lib/app-icon-registry.ts +145 -0
  98. package/client/main.tsx +2 -2
  99. package/client/runtime/hmr-watchdog.ts +39 -0
  100. package/client/{hooks/useMeiEvents.ts → runtime/useWorkspaceEvents.ts} +12 -7
  101. package/client/store/ui.ts +5 -1
  102. package/client/theme.css +1 -3
  103. package/dist/chunk-11cab5dq.css +1 -0
  104. package/dist/chunk-4vf1t6v1.js +10 -0
  105. package/dist/chunk-6c24yndg.js +61 -0
  106. package/dist/chunk-6c8cwpzc.js +1 -0
  107. package/dist/chunk-b4b276wx.js +15 -0
  108. package/dist/chunk-cs8vbert.js +546 -0
  109. package/dist/chunk-cwqmay73.css +1 -0
  110. package/dist/chunk-kxmvv1ax.js +48 -0
  111. package/dist/chunk-pcnahct1.js +5 -0
  112. package/dist/chunk-rq0ar7vp.js +1 -0
  113. package/dist/chunk-tqd3pkg8.css +1 -0
  114. package/dist/chunk-vkvb3hjm.js +2 -0
  115. package/dist/chunk-zpxrb1ce.js +2 -0
  116. package/dist/index.html +3 -3
  117. package/dist/openai-h13pza4b.svg +3 -0
  118. package/lib/format.ts +2 -2
  119. package/lib/types.ts +56 -9
  120. package/lib/view-builder-meta.ts +35 -0
  121. package/lib/workspace-layout.ts +14 -0
  122. package/lib/workspace-name.ts +14 -0
  123. package/package.json +4 -2
  124. package/server/AGENTS.md +3 -3
  125. package/server/api.ts +279 -60
  126. package/server/applets.ts +1 -1
  127. package/server/bundle-queue.ts +19 -0
  128. package/server/bundler/applet-css.ts +50 -0
  129. package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
  130. package/server/cli.ts +90 -7
  131. package/server/control.ts +106 -8
  132. package/server/env-apply.ts +2 -2
  133. package/server/harness/README.md +228 -0
  134. package/server/harness/claude-code/NOTES.md +578 -0
  135. package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
  136. package/server/harness/claude-code/index.ts +124 -0
  137. package/server/{mcp.ts → harness/claude-code/mcp.ts} +73 -16
  138. package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
  139. package/server/harness/claude-code/sessions.ts +42 -0
  140. package/server/harness/codex/NOTES.md +239 -0
  141. package/server/harness/codex/adapter.ts +414 -0
  142. package/server/harness/codex/client.ts +343 -0
  143. package/server/harness/codex/index.ts +68 -0
  144. package/server/harness/codex/probe.ts +186 -0
  145. package/server/harness/codex/session.ts +617 -0
  146. package/server/harness/debug.ts +57 -0
  147. package/server/harness/openclaw/NOTES.md +316 -0
  148. package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
  149. package/server/harness/openclaw/index.ts +93 -0
  150. package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
  151. package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
  152. package/server/harness/registry.ts +36 -0
  153. package/server/harness/types.ts +87 -0
  154. package/server/layout.ts +36 -11
  155. package/server/moi-scaffold.ts +56 -11
  156. package/server/registry.ts +30 -52
  157. package/server/state.ts +5 -38
  158. package/server/status.ts +7 -46
  159. package/server/vendor.ts +1 -1
  160. package/server/view-builders.ts +428 -0
  161. package/server/views.ts +0 -0
  162. package/server/web.ts +19 -40
  163. package/server/workspace-init.ts +11 -25
  164. package/tsconfig.json +1 -1
  165. package/workspace/.claude/skills/moi-workspace/DESIGN.md +2 -1
  166. package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
  167. package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +1 -1
  168. package/client/api/workspaces.ts +0 -427
  169. package/client/assets/hermes-nous.png +0 -0
  170. package/client/components/App.tsx +0 -41
  171. package/client/components/ChatPanel.tsx +0 -275
  172. package/client/components/HomePage.tsx +0 -17
  173. package/client/components/McpMenu.tsx +0 -125
  174. package/client/components/Scratchpad.tsx +0 -935
  175. package/client/components/Widgets.tsx +0 -132
  176. package/client/components/WorkspacesPage.tsx +0 -245
  177. package/client/components/layout/SidebarLayout.tsx +0 -258
  178. package/client/components/routes/workspace/[id].tsx +0 -675
  179. package/client/components/routes/workspace/create.tsx +0 -155
  180. package/client/components/settings/SettingsPages.tsx +0 -255
  181. package/client/hooks/useFitsSidebar.ts +0 -34
  182. package/client/hooks/useScrollFade.ts +0 -38
  183. package/client/lib/connection.ts +0 -238
  184. package/dist/chunk-07qf2tv1.css +0 -1
  185. package/dist/chunk-w18801vn.js +0 -672
  186. package/dist/hermes-nous-pznd63x9.png +0 -0
  187. /package/client/components/{playground → shared}/LedLogo.tsx +0 -0
  188. /package/client/{components → features/chat}/ShimmerText.tsx +0 -0
  189. /package/client/{store/live.ts → features/chat/chat-store.ts} +0 -0
  190. /package/client/{lib → features/chat}/group-turns.ts +0 -0
  191. /package/client/{components → features/chat}/tool-group/CodeBlock.tsx +0 -0
  192. /package/client/{components → features/chat}/tool-group/Collapse.tsx +0 -0
  193. /package/client/{components → features/chat}/tool-group/detect.ts +0 -0
  194. /package/client/{components → features/chat}/tool-group/fixtures.ts +0 -0
  195. /package/client/{components → features/chat}/tool-group/index.ts +0 -0
  196. /package/client/{lib → features/chat}/uploads.ts +0 -0
  197. /package/client/{hooks → features/chat}/useStickToBottom.ts +0 -0
  198. /package/client/{components → features/connectors}/IconMcp.tsx +0 -0
  199. /package/client/{lib → features/connectors}/mcp-icons.ts +0 -0
  200. /package/client/{lib → features/scratchpad}/scratch-executor.ts +0 -0
  201. /package/client/{lib → features/settings}/render-icon.ts +0 -0
  202. /package/client/{lib → features/workspace}/WorkspaceContext.tsx +0 -0
  203. /package/client/{hooks → features/workspace}/useWorkspaceTheme.ts +0 -0
  204. /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
  205. /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
  206. /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
@@ -1,238 +0,0 @@
1
- import type { QueryClient } from '@tanstack/react-query'
2
-
3
- import { workspaceKeys } from '@/client/api/workspaces'
4
- import { getScratchExecutor } from '@/client/lib/scratch-executor'
5
- import { wsUrl } from '@/client/lib/ws-url'
6
- import { liveStore } from '@/client/store/live'
7
- import { applyEvent } from '@/lib/format'
8
- import type {
9
- ClientMessage,
10
- PreviewFrame,
11
- ScratchOp,
12
- StreamEvent,
13
- ThreadConfig,
14
- ViewState
15
- } from '@/lib/types'
16
-
17
- // App-wide chat connection: ONE WebSocket for the whole client, opened once at
18
- // startup and never torn down on navigation. Every server frame is tagged with
19
- // `workspaceId`, so a single socket serves every workspace and the client routes
20
- // each frame to the right `(workspaceId, sessionId)` slice — live transcript
21
- // deltas into the React Query cache, status/error/rename into the live store.
22
- //
23
- // Socket identity is tracked by a monotonic `generation`: each socket captures
24
- // the generation at creation and every callback bails if it's no longer current,
25
- // so a delayed close/open from a superseded socket can't corrupt live state.
26
-
27
- let qc: QueryClient | null = null
28
- let socket: WebSocket | null = null
29
- let generation = 0
30
- let reconnectTimer: ReturnType<typeof setTimeout> | null = null
31
- const queue: ClientMessage[] = []
32
- let onWorkspaceSwitch: ((workspaceId: string) => void) | null = null
33
- let sweepTimer: ReturnType<typeof setInterval> | null = null
34
-
35
- // TTL backstop for live previews. Every clear path (turn arrival, run end,
36
- // reconnect) is exact and should fire first; this only reaps a preview whose
37
- // clear was somehow missed, so it can be generous.
38
- const PREVIEW_TTL_MS = 15_000
39
-
40
- export function initConnection(queryClient: QueryClient) {
41
- qc = queryClient
42
- if (!sweepTimer) {
43
- sweepTimer = setInterval(
44
- () => liveStore.getState().sweepPreviews(PREVIEW_TTL_MS, Date.now()),
45
- 5_000
46
- )
47
- }
48
- if (socket) return // already connected (mount/StrictMode re-invoke safety)
49
- connect()
50
- }
51
-
52
- function connect() {
53
- const myGen = ++generation
54
- if (reconnectTimer) {
55
- clearTimeout(reconnectTimer)
56
- reconnectTimer = null
57
- }
58
-
59
- const s = new WebSocket(wsUrl('/ws'))
60
- socket = s
61
-
62
- s.onopen = () => {
63
- if (generation !== myGen) {
64
- s.close()
65
- return
66
- }
67
- for (const m of queue) s.send(JSON.stringify(m))
68
- queue.length = 0
69
- // Heal any deltas missed while disconnected: refetch every live transcript.
70
- // No-op on the first connect (nothing cached yet).
71
- qc?.invalidateQueries({ queryKey: ['workspaces', 'events'] })
72
- // Any in-flight preview from before the drop is superseded by that refetch
73
- // (which returns the authoritative disk state) — drop them all so a frozen
74
- // half-streamed preview can't linger over the healed transcript.
75
- liveStore.getState().clearAllPreviews()
76
- }
77
-
78
- s.onmessage = e => {
79
- if (generation !== myGen) return
80
- let data: unknown
81
- try {
82
- data = JSON.parse(e.data)
83
- } catch {
84
- return
85
- }
86
- handleFrame(data as Record<string, unknown>)
87
- }
88
-
89
- s.onclose = () => {
90
- if (generation !== myGen) return
91
- socket = null
92
- reconnectTimer = setTimeout(connect, 1000)
93
- }
94
-
95
- s.onerror = () => s.close()
96
- }
97
-
98
- export function handleFrame(data: Record<string, unknown>) {
99
- const store = liveStore.getState()
100
-
101
- // Control frames first.
102
- if (data.type === 'status_snapshot') {
103
- store.reconcileProcessing(
104
- (data.running as { workspaceId: string; sessionId: string }[] | undefined) ?? []
105
- )
106
- return
107
- }
108
- if (data.type === 'status') {
109
- const workspaceId = data.workspaceId as string
110
- const sessionId = data.sessionId as string
111
- const processing = data.processing as boolean
112
- store.setProcessing(workspaceId, sessionId, processing)
113
- // Run fully ended → any leftover preview for this session is stale (its
114
- // finalized turns already arrived). Belt for a per-message clear that was
115
- // missed (e.g. a turn that carried no apiMessageId).
116
- if (!processing) store.clearPreviewsForSession(workspaceId, sessionId)
117
- return
118
- }
119
- if (data.type === 'preview') {
120
- const frame = data as unknown as PreviewFrame
121
- // Only hold previews for a thread whose transcript is loaded (mirrors
122
- // patchView): keeps the store bounded and never renders a preview over a
123
- // history-less background session that would then never refetch.
124
- const key = workspaceKeys.events(frame.workspaceId, frame.sessionId)
125
- if (qc?.getQueryData(key) === undefined) return
126
- store.setPreview({
127
- workspaceId: frame.workspaceId,
128
- sessionId: frame.sessionId,
129
- messageId: frame.messageId,
130
- parentToolUseId: frame.parentToolUseId,
131
- blocks: frame.blocks
132
- })
133
- return
134
- }
135
- if (data.type === 'session_renamed') {
136
- const workspaceId = data.workspaceId as string
137
- const from = data.from as string
138
- const to = data.to as string
139
- store.renameSession(workspaceId, from, to)
140
- // Move the cached transcript from the client's temp id to the real one.
141
- const prev = qc?.getQueryData<ViewState>(workspaceKeys.events(workspaceId, from))
142
- if (prev !== undefined) {
143
- qc?.setQueryData(workspaceKeys.events(workspaceId, to), prev)
144
- qc?.removeQueries({ queryKey: workspaceKeys.events(workspaceId, from) })
145
- }
146
- // Likewise move any per-thread config the picker wrote under the temp id, so
147
- // a model/effort change made before the rename lands isn't stranded. The
148
- // server migrates the stored config in renameSession to match.
149
- const cfg = qc?.getQueryData<ThreadConfig>(workspaceKeys.threadConfig(workspaceId, from))
150
- if (cfg !== undefined) {
151
- qc?.setQueryData(workspaceKeys.threadConfig(workspaceId, to), cfg)
152
- qc?.removeQueries({ queryKey: workspaceKeys.threadConfig(workspaceId, from) })
153
- }
154
- // The real id now exists on disk — refresh the thread list so it appears.
155
- qc?.invalidateQueries({ queryKey: workspaceKeys.sessions(workspaceId) })
156
- return
157
- }
158
- if (data.type === 'workspace:switch') {
159
- onWorkspaceSwitch?.(data.workspaceId as string)
160
- return
161
- }
162
-
163
- // A relayed Scratchpad op from `moi scratch`. Only run it if THIS tab has a
164
- // live editor for that workspace; otherwise ignore (another tab — or none —
165
- // handles it, and the server times out if no tab answers). Ids are
166
- // deterministic, so if several tabs run it they converge; first reply wins.
167
- if (data.type === 'scratchpad:op') {
168
- const run = getScratchExecutor(data.workspaceId as string)
169
- if (!run) return
170
- const opId = data.opId as string
171
- run(data.op as ScratchOp).then(
172
- result => sendMessage({ type: 'scratchpad:op-result', opId, result }),
173
- err =>
174
- sendMessage({
175
- type: 'scratchpad:op-result',
176
- opId,
177
- error: err instanceof Error ? err.message : String(err)
178
- })
179
- )
180
- return
181
- }
182
-
183
- // StreamEvent frames — tagged with workspaceId + sessionId.
184
- const workspaceId = data.workspaceId as string | undefined
185
- const sessionId = data.sessionId as string | undefined
186
- if (!workspaceId || !sessionId) return
187
- const kind = data.kind
188
-
189
- if (kind === 'snapshot' || kind === 'turn' || kind === 'notice' || kind === 'result') {
190
- patchView(workspaceId, sessionId, data as unknown as StreamEvent)
191
- // The real turn superseding a live preview is the clean handoff: drop the
192
- // preview for that exact message id the instant its finalized turn lands, so
193
- // there's no double-render and no flicker (both updates commit together).
194
- if (kind === 'turn') {
195
- const mid = (data as unknown as { turn?: { meta?: { apiMessageId?: string } } }).turn?.meta
196
- ?.apiMessageId
197
- if (mid) store.clearPreview(mid)
198
- }
199
- // A `result` ends the turn — sweep any preview that never got an exact clear.
200
- if (kind === 'result') store.clearPreviewsForSession(workspaceId, sessionId)
201
- }
202
- if (kind === 'error' && typeof data.content === 'string') {
203
- store.setError(workspaceId, sessionId, data.content)
204
- store.clearPreviewsForSession(workspaceId, sessionId)
205
- }
206
- if (kind === 'stopped') {
207
- store.setProcessing(workspaceId, sessionId, false)
208
- store.clearPreviewsForSession(workspaceId, sessionId)
209
- }
210
- }
211
-
212
- // Fold a delta into a thread's cached transcript — but only if that transcript
213
- // is already loaded/primed. A never-viewed background session has no cache
214
- // entry; we deliberately skip it so a stray mid-run delta can't seed a partial,
215
- // history-less view that would then never refetch. It loads in full from disk
216
- // when the user actually opens it.
217
- function patchView(workspaceId: string, sessionId: string, ev: StreamEvent) {
218
- const queryKey = workspaceKeys.events(workspaceId, sessionId)
219
- const existing = qc?.getQueryData<ViewState>(queryKey)
220
- if (existing === undefined) return
221
- qc?.setQueryData<ViewState>(queryKey, applyEvent(existing, ev))
222
- }
223
-
224
- export function sendMessage(msg: ClientMessage) {
225
- if (socket && socket.readyState === WebSocket.OPEN) socket.send(JSON.stringify(msg))
226
- else queue.push(msg)
227
- }
228
-
229
- export function setWorkspaceSwitchHandler(fn: ((workspaceId: string) => void) | null) {
230
- onWorkspaceSwitch = fn
231
- }
232
-
233
- // Test seam: inject the QueryClient the frame handler reads, without opening a
234
- // socket (the browser-only `connect()` path). Production always goes through
235
- // `initConnection`.
236
- export function __setQueryClientForTests(client: QueryClient | null) {
237
- qc = client
238
- }