moi-computer 0.11.1-next.5 → 0.12.1-next.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 +1 -1
- package/client/AGENTS.md +2 -2
- package/client/api/app-ui-keys.ts +1 -1
- package/client/api/workspace-keys.ts +1 -3
- package/client/app/routes/WorkspaceRoute.tsx +2 -8
- package/client/features/applets/applet-runtime.ts +11 -13
- package/client/features/chat/ChatPanel.tsx +70 -49
- package/client/features/chat/ChatPopup.tsx +81 -8
- package/client/features/chat/applet-chat-intents.ts +31 -12
- package/client/features/chat/chat-send.ts +33 -1
- package/client/features/chat/chat-store.ts +10 -0
- package/client/features/chat/composer/ChatComposer.tsx +24 -27
- package/client/features/chat/composer/ModelPicker.tsx +3 -3
- package/client/features/chat/composer/attachments/draft-attachments.ts +21 -4
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +3 -3
- package/client/features/chat/connection/chat-frames.ts +14 -7
- package/client/features/chat/messages/ChatEmptyState.tsx +33 -19
- package/client/features/chat/messages/MarkdownContent.tsx +3 -3
- package/client/features/chat/messages/fork-history.ts +14 -0
- package/client/features/chat/sessions/ChatSelector.tsx +138 -79
- package/client/features/chat/sessions/api.ts +109 -19
- package/client/features/chat/sessions/browser-tab-state.ts +30 -7
- package/client/features/chat/sessions/useSelectedSession.ts +217 -51
- package/client/features/chat/useChat.ts +43 -45
- package/client/features/collab/client.ts +10 -11
- package/client/features/collab/hooks.tsx +6 -11
- package/client/features/collab/host-state.ts +57 -128
- package/client/features/collab/provider.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +6 -27
- package/client/features/collab/workspace-users-menu.tsx +3 -7
- package/client/features/drawings/{useViewBuilderSketch.ts → useViewSketch.ts} +7 -7
- package/client/features/home/HomePage.tsx +2 -2
- package/client/features/overview/Overview.tsx +3 -6
- package/client/features/overview/default/ViewsWidget.tsx +5 -12
- package/client/features/overview/default/registry.tsx +2 -4
- package/client/features/views/PendingViewScreen.tsx +279 -0
- package/client/features/views/ViewManager.tsx +10 -10
- package/client/features/views/api.ts +63 -130
- package/client/features/views/useViewActions.ts +151 -0
- package/client/features/views/useViewDrafts.ts +79 -0
- package/client/features/views/view-presentation.ts +4 -5
- package/client/features/views/view-submission.ts +88 -0
- package/client/features/workspace/WorkspaceMenu.tsx +63 -0
- package/client/features/workspace/WorkspaceScreen.tsx +180 -375
- package/client/features/workspace/browser-tab-state.ts +16 -9
- package/client/features/workspace/moi-context.ts +13 -15
- package/client/features/workspace/tab-resolution.ts +16 -29
- package/client/features/workspace/useWorkspaceNavigation.ts +146 -104
- package/client/index.tsx +5 -1
- package/client/runtime/useWorkspaceEvents.ts +7 -6
- package/client/store/ui.ts +25 -29
- package/dist/chunk-1zhnhy00.js +1 -0
- package/dist/chunk-27501vke.js +1 -0
- package/dist/{chunk-jf6czgrz.js → chunk-9xtv6djt.js} +2 -2
- package/dist/chunk-am1x230f.js +2 -0
- package/dist/{chunk-nez8sdta.js → chunk-darpsw65.js} +1 -1
- package/dist/{chunk-97eg9mjn.js → chunk-gps4qc38.js} +1 -1
- package/dist/{chunk-3a48fyf7.js → chunk-hzwr8dp8.js} +4 -4
- package/dist/{chunk-efdyz6xp.js → chunk-j905va8r.js} +1 -1
- package/dist/chunk-n33w9y38.js +10 -0
- package/dist/chunk-r63ks44z.js +68 -0
- package/dist/{chunk-vfpsc75k.js → chunk-vqpkqtdr.js} +1 -1
- package/dist/chunk-wd46nk26.css +1 -0
- package/dist/chunk-xgt7vxt9.js +1 -0
- package/dist/{chunk-z3byfve5.js → chunk-yvzhwtfa.js} +2 -2
- package/dist/index.html +1 -1
- package/lib/ids.ts +2 -5
- package/lib/moi-context.ts +100 -73
- package/lib/navigation.ts +48 -87
- package/lib/session-drafts.ts +10 -0
- package/lib/types.ts +64 -31
- package/lib/view-build-directives.ts +12 -0
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-tabs.ts +12 -7
- package/package.json +3 -1
- package/server/agent-launcher.ts +27 -0
- package/server/api.ts +119 -209
- package/server/app-config.ts +21 -2
- package/server/applets/build-worker.ts +2 -1
- package/server/applets/view-source.ts +7 -1
- package/server/cli-env.ts +72 -50
- package/server/cli.ts +127 -70
- package/server/control.ts +82 -63
- package/server/data-dir.ts +13 -0
- package/server/functions.ts +2 -1
- package/server/harness/README.md +8 -0
- package/server/harness/acp/adapter.ts +2 -2
- package/server/harness/acp/client.ts +2 -1
- package/server/harness/acp/discovery.ts +3 -3
- package/server/harness/acp/session.ts +6 -9
- package/server/harness/claude-code/adapter.ts +13 -8
- package/server/harness/claude-code/auth.ts +3 -2
- package/server/harness/claude-code/cli.ts +3 -1
- package/server/harness/claude-code/git-worktree.ts +5 -2
- package/server/harness/claude-code/index.ts +5 -0
- package/server/harness/claude-code/mcp.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -0
- package/server/harness/claude-code/session.ts +5 -34
- package/server/harness/claude-code/sessions.ts +8 -12
- package/server/harness/codex/NOTES.md +23 -4
- package/server/harness/codex/adapter.ts +5 -3
- package/server/harness/codex/client.ts +13 -21
- package/server/harness/codex/index.ts +18 -0
- package/server/harness/codex/session.ts +6 -14
- package/server/harness/codex/thread-list.ts +74 -0
- package/server/harness/fork.ts +12 -0
- package/server/harness/openclaw/adapter.ts +3 -3
- package/server/harness/openclaw/session.ts +2 -30
- package/server/harness/session-title.ts +12 -3
- package/server/harness/types.ts +8 -3
- package/server/moi-scaffold.ts +53 -20
- package/server/pending-views.ts +164 -0
- package/server/registry.ts +14 -4
- package/server/selected-session.ts +91 -44
- package/server/service.ts +16 -2
- package/server/session-archive.ts +32 -0
- package/server/session-config.ts +16 -111
- package/server/session-lifecycle.ts +17 -0
- package/server/session-store.ts +127 -0
- package/server/status.ts +3 -1
- package/server/tabs.ts +7 -10
- package/server/view-sessions.ts +267 -0
- package/server/views.ts +30 -41
- package/server/web.ts +47 -45
- package/server/workspace-env.ts +27 -0
- package/server/workspace-init.ts +12 -5
- package/workspace/.claude/skills/moi-workspace/SKILL.md +49 -20
- package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -5
- package/client/features/views/ViewBuilder.tsx +0 -239
- package/client/features/views/useViewBuilderActions.ts +0 -103
- package/client/features/views/useViewBuilderDrafts.ts +0 -68
- package/dist/chunk-2jncyq65.js +0 -1
- package/dist/chunk-9zpvdws4.js +0 -68
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-hvj7tp3y.js +0 -1
- package/dist/chunk-nzwgm8vc.css +0 -1
- package/dist/chunk-ryg9z3kn.js +0 -10
- package/dist/chunk-tpn177bt.js +0 -2
- package/lib/view-builder-directives.ts +0 -16
- package/server/chat-selection.ts +0 -22
- package/server/view-builders.ts +0 -453
package/server/views.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
2
|
|
|
3
3
|
import { viewTabId } from '@/lib/workspace-tabs'
|
|
4
|
-
import type { ViewConfig, ViewInfo } from '@/lib/types'
|
|
4
|
+
import type { CompiledView, ViewConfig, ViewInfo, WorkspaceEntry } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
import { syncAppletLogAfterBuild } from './applet-log'
|
|
7
7
|
import {
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
import { serializeWorkspaceBundle } from './bundle-queue'
|
|
16
16
|
import { reloadModules } from './functions'
|
|
17
17
|
import { loadLayout, saveLayout } from './layout'
|
|
18
|
-
import {
|
|
18
|
+
import { completeViewBuild, listPendingViews } from './pending-views'
|
|
19
|
+
import { archiveViewSessions } from './session-archive'
|
|
19
20
|
import { setViewSourceTitle } from './applets/config'
|
|
20
21
|
import { deleteViewSourceFiles, readViewSource, ViewSourceInUseError } from './applets/view-source'
|
|
21
22
|
|
|
@@ -118,7 +119,7 @@ function listBuiltViews(workspacePath: string): Promise<string[]> {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
// Built views in manifest order, with `title` resolved (falls back to the id).
|
|
121
|
-
export async function
|
|
122
|
+
export async function listCompiledViews(workspacePath: string): Promise<CompiledView[]> {
|
|
122
123
|
const [built, manifest] = await Promise.all([
|
|
123
124
|
listBuiltViews(workspacePath),
|
|
124
125
|
readManifest(workspacePath)
|
|
@@ -137,12 +138,11 @@ export async function getViewList(workspacePath: string): Promise<ViewInfo[]> {
|
|
|
137
138
|
const revision = getAppletRevision(workspacePath, 'view', id)
|
|
138
139
|
return {
|
|
139
140
|
id,
|
|
141
|
+
status: 'compiled',
|
|
140
142
|
...(revision ? { revision } : {}),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
...(requiredEnv ? { requiredEnv } : {})
|
|
145
|
-
}
|
|
143
|
+
title: raw.title || id,
|
|
144
|
+
...(icon ? { icon } : {}),
|
|
145
|
+
...(requiredEnv ? { requiredEnv } : {})
|
|
146
146
|
}
|
|
147
147
|
})
|
|
148
148
|
}
|
|
@@ -172,8 +172,15 @@ export async function collectViewRequiredEnv(
|
|
|
172
172
|
return out
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
export async function getWorkspaceViews(workspacePath: string): Promise<ViewInfo[]> {
|
|
176
|
+
const compiled = await listCompiledViews(workspacePath)
|
|
177
|
+
const ids = new Set(compiled.map(view => view.id))
|
|
178
|
+
const pending = (await listPendingViews(workspacePath)).filter(view => !ids.has(view.id))
|
|
179
|
+
return [...compiled, ...pending]
|
|
180
|
+
}
|
|
181
|
+
|
|
175
182
|
export async function listViews(workspacePath: string): Promise<Response> {
|
|
176
|
-
return Response.json({ views: await
|
|
183
|
+
return Response.json({ views: await getWorkspaceViews(workspacePath) })
|
|
177
184
|
}
|
|
178
185
|
|
|
179
186
|
export async function handleBundleViews(
|
|
@@ -181,9 +188,6 @@ export async function handleBundleViews(
|
|
|
181
188
|
workspaceId: string,
|
|
182
189
|
workspacePath: string,
|
|
183
190
|
force = false,
|
|
184
|
-
// When set, compile without advancing any view builder to `ready` (the
|
|
185
|
-
// `moi bundle --no-status` opt-out). The build still publishes `view:updated`.
|
|
186
|
-
skipStatus = false,
|
|
187
191
|
target?: string
|
|
188
192
|
) {
|
|
189
193
|
const before = await readManifest(workspacePath)
|
|
@@ -212,15 +216,7 @@ export async function handleBundleViews(
|
|
|
212
216
|
for (const r of results) {
|
|
213
217
|
if (r.status === 'built') {
|
|
214
218
|
publish({ type: 'view:updated', name: r.name, config: r.config ?? null })
|
|
215
|
-
|
|
216
|
-
await markViewBuilderReady(
|
|
217
|
-
workspaceId,
|
|
218
|
-
workspacePath,
|
|
219
|
-
r.name,
|
|
220
|
-
r.config?.title || r.name,
|
|
221
|
-
r.config?.icon
|
|
222
|
-
)
|
|
223
|
-
}
|
|
219
|
+
await completeViewBuild(workspaceId, workspacePath, r.name)
|
|
224
220
|
for (const m of r.serverModules ?? []) changedServerModules.add(m)
|
|
225
221
|
}
|
|
226
222
|
}
|
|
@@ -229,7 +225,7 @@ export async function handleBundleViews(
|
|
|
229
225
|
reloadModules([...changedServerModules], workspacePath)
|
|
230
226
|
}
|
|
231
227
|
|
|
232
|
-
const views = await
|
|
228
|
+
const views = await listCompiledViews(workspacePath)
|
|
233
229
|
if (identityChanged || orderChanged || membershipChanged) {
|
|
234
230
|
publish({ type: 'view-layout:updated', views })
|
|
235
231
|
}
|
|
@@ -243,11 +239,11 @@ export async function updateViewTitle(
|
|
|
243
239
|
workspacePath: string,
|
|
244
240
|
viewId: string,
|
|
245
241
|
title: string
|
|
246
|
-
): Promise<
|
|
242
|
+
): Promise<CompiledView> {
|
|
247
243
|
return serializeWorkspaceBundle(workspacePath, async () => {
|
|
248
|
-
const current = (await
|
|
244
|
+
const current = (await listCompiledViews(workspacePath)).find(view => view.id === viewId)
|
|
249
245
|
if (!current) throw new ViewMutationError('View not found', 404)
|
|
250
|
-
if (current.
|
|
246
|
+
if (current.title === title) return current
|
|
251
247
|
|
|
252
248
|
const source = await readViewSource(workspacePath, viewId)
|
|
253
249
|
if (!source) throw new ViewMutationError('View source not found', 409)
|
|
@@ -265,21 +261,14 @@ export async function updateViewTitle(
|
|
|
265
261
|
|
|
266
262
|
await Bun.write(source.path, updated)
|
|
267
263
|
try {
|
|
268
|
-
// A rename changed this entry; rebuild only it and
|
|
269
|
-
const results = await handleBundleViews(
|
|
270
|
-
publish,
|
|
271
|
-
workspaceId,
|
|
272
|
-
workspacePath,
|
|
273
|
-
true,
|
|
274
|
-
true,
|
|
275
|
-
viewId
|
|
276
|
-
)
|
|
264
|
+
// A rename changed this entry; rebuild only it and leave pending views alone.
|
|
265
|
+
const results = await handleBundleViews(publish, workspaceId, workspacePath, true, viewId)
|
|
277
266
|
const result = results.find(candidate => candidate.name === viewId)
|
|
278
267
|
if (result?.status !== 'built') {
|
|
279
268
|
throw new ViewMutationError(result?.error ?? 'Could not rebuild the renamed view', 422)
|
|
280
269
|
}
|
|
281
270
|
|
|
282
|
-
const renamed = (await
|
|
271
|
+
const renamed = (await listCompiledViews(workspacePath)).find(view => view.id === viewId)
|
|
283
272
|
if (!renamed) {
|
|
284
273
|
throw new ViewMutationError('Renamed view was not found after rebuilding', 422)
|
|
285
274
|
}
|
|
@@ -300,22 +289,22 @@ export async function updateViewTitle(
|
|
|
300
289
|
|
|
301
290
|
export async function deleteView(
|
|
302
291
|
publish: (msg: unknown) => void,
|
|
303
|
-
|
|
304
|
-
workspacePath: string,
|
|
292
|
+
ws: WorkspaceEntry,
|
|
305
293
|
viewId: string
|
|
306
294
|
): Promise<void> {
|
|
295
|
+
const { id: workspaceId, path: workspacePath } = ws
|
|
307
296
|
await serializeWorkspaceBundle(workspacePath, async () => {
|
|
308
|
-
const current = (await
|
|
297
|
+
const current = (await listCompiledViews(workspacePath)).some(view => view.id === viewId)
|
|
309
298
|
if (!current) throw new ViewMutationError('View not found', 404)
|
|
310
299
|
|
|
311
300
|
try {
|
|
312
|
-
await deleteViewSourceFiles(workspacePath, viewId)
|
|
301
|
+
await deleteViewSourceFiles(workspacePath, viewId, () => archiveViewSessions(ws, viewId))
|
|
313
302
|
} catch (error) {
|
|
314
303
|
if (error instanceof ViewSourceInUseError) throw new ViewMutationError(error.message, 409)
|
|
315
304
|
throw error
|
|
316
305
|
}
|
|
317
306
|
reloadModules([`views/${viewId}`], workspacePath)
|
|
318
|
-
await
|
|
307
|
+
await completeViewBuild(workspaceId, workspacePath, viewId)
|
|
319
308
|
const layout = await loadLayout(workspacePath)
|
|
320
309
|
const tab = viewTabId(viewId)
|
|
321
310
|
await saveLayout(
|
|
@@ -331,7 +320,7 @@ export async function deleteView(
|
|
|
331
320
|
|
|
332
321
|
publish({ type: 'view:deleted', workspaceId, name: viewId })
|
|
333
322
|
publish({ type: 'workspace:updated' })
|
|
334
|
-
await handleBundleViews(publish, workspaceId, workspacePath, false,
|
|
323
|
+
await handleBundleViews(publish, workspaceId, workspacePath, false, viewId)
|
|
335
324
|
})
|
|
336
325
|
}
|
|
337
326
|
|
package/server/web.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { UserProfile } from '@/lib/collab/types'
|
|
2
2
|
import { isMessageAttachments } from '@/lib/message-attachments'
|
|
3
3
|
import type { ClientMessage, StatusSnapshotMessage } from '@/lib/types'
|
|
4
|
-
import { isMoiContext
|
|
4
|
+
import { isMoiContext } from '@/lib/moi-context'
|
|
5
|
+
|
|
6
|
+
import { rm } from 'node:fs/promises'
|
|
5
7
|
|
|
6
8
|
import index from '../client/index.html'
|
|
7
9
|
import { api } from './api'
|
|
10
|
+
import { getAppConfig } from './app-config'
|
|
8
11
|
import { AttachmentUploadError } from './attachment-message'
|
|
9
12
|
import { PORT } from './constants'
|
|
10
13
|
import { control } from './control'
|
|
11
14
|
import { proxyUserState } from './collab/cloudflare-access'
|
|
12
|
-
import {
|
|
13
|
-
import { selectChatSession } from './chat-selection'
|
|
15
|
+
import { isCollabEnabled } from './collab/config'
|
|
14
16
|
import { collabManager } from './collab/manager'
|
|
15
17
|
import { EVENTS_TOPIC, setEventServer } from './events'
|
|
16
18
|
import { killBuildWorkers } from './applets/build-worker'
|
|
@@ -19,7 +21,9 @@ import { startScratchpadSweeper } from './scratchpad'
|
|
|
19
21
|
import { navigationRelay } from './navigation-relay'
|
|
20
22
|
import { resolveScratchOp } from './scratchpad-relay'
|
|
21
23
|
import { allHarnesses, harnessFor } from './harness/registry'
|
|
22
|
-
import { getWorkspace } from './registry'
|
|
24
|
+
import { getWorkspace, listWorkspaces } from './registry'
|
|
25
|
+
import { failInterruptedViewStarts, sendWorkspaceMessage } from './view-sessions'
|
|
26
|
+
import { PendingViewError } from './pending-views'
|
|
23
27
|
import {
|
|
24
28
|
addClient,
|
|
25
29
|
broadcast,
|
|
@@ -104,9 +108,22 @@ function upgrade(server: Upgradable, req: Request, data: WsData) {
|
|
|
104
108
|
// Bun owns the fullstack surface: the HTML shell + dev bundler/HMR, and the two
|
|
105
109
|
// WebSocket channels (which need Bun's native `server.upgrade` + pub/sub). Every
|
|
106
110
|
// HTTP API route is delegated to the Hono app (`./api`) via `fetch`.
|
|
111
|
+
await Promise.all((await listWorkspaces()).map(failInterruptedViewStarts))
|
|
112
|
+
|
|
113
|
+
// Managed machines serve the web side on a Unix socket file that only the
|
|
114
|
+
// machine's gateway can open, so nothing else running there reaches the API
|
|
115
|
+
// meant for people (docs/config.md). A socket file left by a previous
|
|
116
|
+
// run would make the bind fail.
|
|
117
|
+
const { unixSocket } = getAppConfig()
|
|
118
|
+
if (unixSocket) await rm(unixSocket, { force: true })
|
|
119
|
+
const listen = unixSocket
|
|
120
|
+
? { unix: unixSocket }
|
|
121
|
+
: { port: PORT, hostname: process.env.HOST ?? '127.0.0.1' }
|
|
122
|
+
|
|
107
123
|
export const app = Bun.serve<WsData>({
|
|
108
|
-
port
|
|
109
|
-
|
|
124
|
+
// Bun types the port and Unix-socket listeners as separate overloads, so a
|
|
125
|
+
// listener picked at runtime is cast to one of them; the runtime takes either.
|
|
126
|
+
...(listen as { port: number; hostname: string }),
|
|
110
127
|
// Agent startup/discovery can outlast Bun's 10s HTTP default. Allow the
|
|
111
128
|
// harness's 30s RPC timeout to return an error before the socket closes.
|
|
112
129
|
idleTimeout: 60,
|
|
@@ -203,45 +220,30 @@ export const app = Bun.serve<WsData>({
|
|
|
203
220
|
if (data.type === 'chat' && (data.content?.trim() || data.attachments?.length)) {
|
|
204
221
|
const workspace = await getWorkspace(data.workspaceId)
|
|
205
222
|
if (!workspace) return
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
effort: data.effort,
|
|
231
|
-
fastMode: data.fastMode,
|
|
232
|
-
stream: data.stream,
|
|
233
|
-
context,
|
|
234
|
-
agentId: workspace.agentId
|
|
235
|
-
})
|
|
236
|
-
.catch(error => {
|
|
237
|
-
if (error instanceof AttachmentUploadError) {
|
|
238
|
-
broadcast(data.workspaceId, {
|
|
239
|
-
kind: 'error',
|
|
240
|
-
sessionId: data.sessionId,
|
|
241
|
-
content: error.message
|
|
242
|
-
})
|
|
243
|
-
}
|
|
244
|
-
})
|
|
223
|
+
void sendWorkspaceMessage(workspace, {
|
|
224
|
+
workspaceId: data.workspaceId,
|
|
225
|
+
workspacePath: workspace.path,
|
|
226
|
+
sessionId: data.sessionId,
|
|
227
|
+
isNew: data.isNew,
|
|
228
|
+
selectedSessionScope: data.selectedSessionScope,
|
|
229
|
+
content: data.content.trim(),
|
|
230
|
+
attachments: data.attachments,
|
|
231
|
+
optimisticId: data.optimisticId,
|
|
232
|
+
model: data.model,
|
|
233
|
+
effort: data.effort,
|
|
234
|
+
fastMode: data.fastMode,
|
|
235
|
+
stream: data.stream,
|
|
236
|
+
context: data.context,
|
|
237
|
+
agentId: workspace.agentId
|
|
238
|
+
}).catch(error => {
|
|
239
|
+
if (error instanceof AttachmentUploadError || error instanceof PendingViewError) {
|
|
240
|
+
broadcast(workspace.id, {
|
|
241
|
+
kind: 'error',
|
|
242
|
+
sessionId: data.sessionId,
|
|
243
|
+
content: error.message
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
})
|
|
245
247
|
}
|
|
246
248
|
if (data.type === 'stop') {
|
|
247
249
|
const workspace = await getWorkspace(data.workspaceId)
|
package/server/workspace-env.ts
CHANGED
|
@@ -328,6 +328,33 @@ export type EnvUpdate = {
|
|
|
328
328
|
inheritDotenv?: boolean
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
// Validate an env patch that arrives from outside the process (PUT /env, the
|
|
332
|
+
// control port). Returns the patch, or an error message for the caller.
|
|
333
|
+
export function parseEnvUpdate(body: unknown): EnvUpdate | string {
|
|
334
|
+
if (!body || typeof body !== 'object') return 'Bad request'
|
|
335
|
+
const raw = body as Record<string, unknown>
|
|
336
|
+
const patch: EnvUpdate = {}
|
|
337
|
+
if (raw.set !== undefined) {
|
|
338
|
+
if (typeof raw.set !== 'object' || raw.set === null) return 'set must be an object'
|
|
339
|
+
for (const [k, v] of Object.entries(raw.set)) {
|
|
340
|
+
if (!isValidEnvKey(k)) return `Invalid env key: ${k}`
|
|
341
|
+
if (typeof v !== 'string') return `Value for ${k} must be a string`
|
|
342
|
+
}
|
|
343
|
+
patch.set = raw.set as Record<string, string>
|
|
344
|
+
}
|
|
345
|
+
if (raw.remove !== undefined) {
|
|
346
|
+
if (!Array.isArray(raw.remove) || raw.remove.some(k => typeof k !== 'string')) {
|
|
347
|
+
return 'remove must be an array of strings'
|
|
348
|
+
}
|
|
349
|
+
patch.remove = raw.remove as string[]
|
|
350
|
+
}
|
|
351
|
+
if (raw.inheritDotenv !== undefined) {
|
|
352
|
+
if (typeof raw.inheritDotenv !== 'boolean') return 'inheritDotenv must be a boolean'
|
|
353
|
+
patch.inheritDotenv = raw.inheritDotenv
|
|
354
|
+
}
|
|
355
|
+
return patch
|
|
356
|
+
}
|
|
357
|
+
|
|
331
358
|
// Apply a patch to a workspace's custom secrets + metadata. Patch (not replace)
|
|
332
359
|
// semantics, because values are write-only — the UI can add/update one key
|
|
333
360
|
// without resending the others. Serialized per workspace to avoid lost updates.
|
package/server/workspace-init.ts
CHANGED
|
@@ -10,8 +10,9 @@ import { join } from 'node:path'
|
|
|
10
10
|
import type { WorkspaceType } from '@/lib/types'
|
|
11
11
|
export { validateWorkspaceFolderName } from '@/lib/workspace-name'
|
|
12
12
|
|
|
13
|
+
import { getAppConfig } from './app-config'
|
|
13
14
|
import { harnessFor } from './harness/registry'
|
|
14
|
-
import { scaffoldMoiDir } from './moi-scaffold'
|
|
15
|
+
import { createDependencyInstallLogPath, scaffoldMoiDir } from './moi-scaffold'
|
|
15
16
|
import { installBundledSkills } from './skills-template'
|
|
16
17
|
|
|
17
18
|
// Where each backend loads skills from — the harness owns the answer
|
|
@@ -24,8 +25,11 @@ export function skillsDirFor(workspaceRoot: string, type?: WorkspaceType): strin
|
|
|
24
25
|
|
|
25
26
|
// Folder that holds workspaces created from the UI (`/workspace/create`) — a
|
|
26
27
|
// visible home-dir folder, mirroring how Cowork keeps its session folders under
|
|
27
|
-
// the user's home rather than an app-data dir.
|
|
28
|
-
|
|
28
|
+
// the user's home rather than an app-data dir. Managed machines set their own
|
|
29
|
+
// (`workspacesDir` in config.json).
|
|
30
|
+
export function createdWorkspacesRoot(): string {
|
|
31
|
+
return getAppConfig().workspacesDir ?? join(homedir(), 'moi')
|
|
32
|
+
}
|
|
29
33
|
|
|
30
34
|
export type ProvisionResult = {
|
|
31
35
|
// Where the skills were installed (backend-dependent, see skillsDirFor).
|
|
@@ -34,6 +38,8 @@ export type ProvisionResult = {
|
|
|
34
38
|
// install continues in the background, else the install exit code (non-zero
|
|
35
39
|
// means deps are missing — not fatal, the agent installs on demand).
|
|
36
40
|
scaffold: 'exists' | 'installing' | number
|
|
41
|
+
// Unique temporary log for this install attempt; unused when scaffold exists.
|
|
42
|
+
installLogPath: string
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
// Lay down everything a workspace needs: create the folder, copy the bundled
|
|
@@ -47,6 +53,7 @@ export async function provisionWorkspace(
|
|
|
47
53
|
const skillsDir = skillsDirFor(workspaceRoot, type)
|
|
48
54
|
await mkdir(workspaceRoot, { recursive: true })
|
|
49
55
|
await installBundledSkills(skillsDir)
|
|
50
|
-
const
|
|
51
|
-
|
|
56
|
+
const installLogPath = createDependencyInstallLogPath()
|
|
57
|
+
const scaffold = await scaffoldMoiDir(workspaceRoot, undefined, undefined, installLogPath)
|
|
58
|
+
return { skillsDir, scaffold, installLogPath }
|
|
52
59
|
}
|
|
@@ -46,7 +46,7 @@ Workspace features/pages:
|
|
|
46
46
|
or completing a multi-step task.
|
|
47
47
|
|
|
48
48
|
User can switch between these, but can access the chat (this conversation and other chats) from
|
|
49
|
-
**any place in the app**
|
|
49
|
+
**any place in the app** through the docked sidebar or floating popup.
|
|
50
50
|
|
|
51
51
|
## Working in the workspace
|
|
52
52
|
|
|
@@ -120,7 +120,14 @@ Use the task-specific sections below for workflow guidance. The CLI will grow ov
|
|
|
120
120
|
Use `moi:/` addresses in chat, CLI commands, and applets. They refer to the current workspace,
|
|
121
121
|
independently of its domain and deployment path.
|
|
122
122
|
|
|
123
|
-
Supported destinations:
|
|
123
|
+
Supported destinations:
|
|
124
|
+
|
|
125
|
+
- `moi:/overview`: open the workspace overview.
|
|
126
|
+
- `moi:/scratchpad`: open the shared canvas.
|
|
127
|
+
- `moi:/views/<id>`: open a specific view.
|
|
128
|
+
- `moi:/chat`: show the current chat.
|
|
129
|
+
- `moi:/chats/<session-id>`: open a specific chat.
|
|
130
|
+
|
|
124
131
|
Run `moi tabs` to discover views and their addresses. Widgets are not navigation destinations.
|
|
125
132
|
|
|
126
133
|
Put view params in the query string. Values are strings; read the target view's `Params` type
|
|
@@ -288,7 +295,7 @@ Views are full-screen apps, one per tab.
|
|
|
288
295
|
```ts
|
|
289
296
|
export const config = {
|
|
290
297
|
title: 'Customer overview', // sentence-case nav label — defaults to the file name
|
|
291
|
-
icon: 'user', // icon id; use the
|
|
298
|
+
icon: 'user', // icon id; use the selected icon for a pending view
|
|
292
299
|
requiredEnv: ['CRM_API_KEY'] // optional env-key hints (advisory; see Environment and secrets)
|
|
293
300
|
} as const
|
|
294
301
|
```
|
|
@@ -300,23 +307,44 @@ Keep shareable or reload-safe state in URL query params,
|
|
|
300
307
|
read it from `params`, and update it with `navigate()`. Keep temporary state, such as drafts and
|
|
301
308
|
hover, in React. See [Applet intents](references/INTENTS.md#view-params-and-history).
|
|
302
309
|
|
|
303
|
-
####
|
|
310
|
+
#### Creating views from chat
|
|
311
|
+
|
|
312
|
+
When the user asks for a new view, use the current session ID and pin state from the
|
|
313
|
+
hidden context. If this chat is pinned, build in this turn:
|
|
314
|
+
|
|
315
|
+
```sh
|
|
316
|
+
moi views create --requirements "<complete requirements>"
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Otherwise, start the build in a separate chat by forking the current session:
|
|
320
|
+
|
|
321
|
+
```sh
|
|
322
|
+
moi views create --from-session <session-id> --requirements "<complete requirements>"
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
The command returns a permanent `viewId` and opens its view tab before returning.
|
|
326
|
+
|
|
327
|
+
- `mode: "handoff"`: another chat continues the build. Finish this turn with a link such as
|
|
328
|
+
`[Open the view](moi:/views/<viewId>)`.
|
|
329
|
+
- `mode: "in-place"`: no chat was created or attached. Continue the build in this turn using the
|
|
330
|
+
returned id and build instructions.
|
|
331
|
+
- Navigation fails: include the same `[Open the view](moi:/views/<viewId>)` link in your reply.
|
|
332
|
+
|
|
333
|
+
#### Pending view builds
|
|
304
334
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
first word of the title. Your first action must claim them:
|
|
335
|
+
Read the applet design guidance before editing.
|
|
336
|
+
When the direction is clear, choose a sentence-case title and relevant icon. Preserve proper names
|
|
337
|
+
and acronyms. Set this provisional metadata before the first bundle:
|
|
309
338
|
|
|
310
339
|
```sh
|
|
311
|
-
moi
|
|
340
|
+
moi views set <view-id> --title "<title>" --icon <icon-id>
|
|
312
341
|
```
|
|
313
342
|
|
|
314
|
-
Choose
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
ready; the build state is otherwise server-managed, so you never set it to done by hand.)
|
|
343
|
+
Choose from the available view icons in the hidden context when that list is present. Then write
|
|
344
|
+
`.moi/views/<view-id>.tsx` and use the same title and icon in its config. Run
|
|
345
|
+
`moi check --only views/<view-id>` before `moi bundle --only views/<view-id>`. A successful bundle
|
|
346
|
+
replaces the pending screen in the same tab. Keep the user's current tab open and finish with a
|
|
347
|
+
`moi:/views/<view-id>` link.
|
|
320
348
|
|
|
321
349
|
### Styling and UI components
|
|
322
350
|
|
|
@@ -421,14 +449,15 @@ needs another focused check. Do not search for repo tests by default. Run an exi
|
|
|
421
449
|
`moi call-server-fn` only when the change touches the behavior it covers. If native-app inspection is
|
|
422
450
|
unavailable, keep verification in the browser instead of retrying the unsupported tool.
|
|
423
451
|
|
|
424
|
-
After the final successful checks,
|
|
452
|
+
After the final successful checks, hand off the result according to the task:
|
|
425
453
|
|
|
426
454
|
- After building or editing a widget, run `moi navigate 'moi:/overview'`.
|
|
427
|
-
- After
|
|
428
|
-
|
|
455
|
+
- After editing an existing view, run `moi navigate 'moi:/views/<view-id>'`.
|
|
456
|
+
- After a pending view build, keep the current tab open and link to `moi:/views/<view-id>` in the
|
|
457
|
+
final reply.
|
|
429
458
|
|
|
430
|
-
|
|
431
|
-
|
|
459
|
+
Keep the final reply brief and user-facing. Do not include file or storage links, file paths, or
|
|
460
|
+
bundle, test, and runtime-log summaries.
|
|
432
461
|
|
|
433
462
|
### Debugging
|
|
434
463
|
|
|
@@ -27,8 +27,8 @@ This tracks tab visibility, not idle time. A user on another page can still be a
|
|
|
27
27
|
|
|
28
28
|
Use `useMe()` when an action needs the current user's identity, such as assigning a task
|
|
29
29
|
to yourself. Use `useUser(id)` to resolve a stored author or assignee, including an offline
|
|
30
|
-
member. Both return `undefined` when the profile cannot be resolved
|
|
31
|
-
|
|
30
|
+
member. Both return `undefined` when the profile cannot be resolved. Handle that before
|
|
31
|
+
reading profile fields.
|
|
32
32
|
|
|
33
33
|
#### `useWorkspaceUsers` and `usePeers`
|
|
34
34
|
|
|
@@ -39,9 +39,6 @@ Use `usePeers()` to find other connected users on the current page. It excludes
|
|
|
39
39
|
user and combines multiple browser tabs into one user. Set `scope: 'workspace'` to include
|
|
40
40
|
other pages; its status filter accepts `'active'` or `'away'`.
|
|
41
41
|
|
|
42
|
-
A host-supplied directory is authoritative, including an empty list. Without one, user
|
|
43
|
-
lookups fall back to your profile and connected users; they cannot discover offline members.
|
|
44
|
-
|
|
45
42
|
### Components
|
|
46
43
|
|
|
47
44
|
#### `User` and `UserAvatar`
|