moi-computer 0.12.1-next.3 → 0.12.1-next.4
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/bunfig.toml +1 -5
- package/client/api/app-config.ts +1 -2
- package/client/api/app-ui-keys.ts +3 -1
- package/client/api/http.ts +4 -1
- package/client/api/workspace-keys.ts +3 -3
- package/client/app/app-provider.tsx +22 -2
- package/client/app/app-router.tsx +4 -0
- package/client/app/routes/home-route.tsx +14 -0
- package/client/app/routes/onboarding-route.tsx +11 -0
- package/client/app/routes/settings-route.tsx +1 -1
- package/client/app/routes/workspace-route.tsx +21 -19
- package/client/components/shared/screen-shell.tsx +23 -0
- package/client/components/shared/ultrafast-icon.tsx +61 -0
- package/client/components/shared/workspace-icon.tsx +2 -2
- package/client/features/account/account-test-utils.tsx +4 -3
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
- package/client/features/chat/applet-chat-intents.ts +4 -20
- package/client/features/chat/chat-send.ts +17 -13
- package/client/features/chat/composer/model-order.ts +8 -4
- package/client/features/chat/composer/model-picker.tsx +88 -34
- package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
- package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -15
- package/client/features/chat/messages/chat-empty-state.tsx +1 -4
- package/client/features/chat/messages/fork-history.ts +5 -5
- package/client/features/chat/messages/turn-view.tsx +3 -12
- package/client/features/chat/messages/user-message-bubble.tsx +63 -0
- package/client/features/chat/sessions/api.ts +121 -80
- package/client/features/chat/sessions/browser-tab-state.ts +14 -12
- package/client/features/chat/sessions/chat-selector.tsx +5 -6
- package/client/features/chat/sessions/use-selected-session.ts +172 -257
- package/client/features/chat/use-chat.ts +14 -19
- package/client/features/collab/workspace-users-menu.tsx +1 -1
- package/client/features/demo/demo-dialog.tsx +11 -3
- package/client/features/dev/dev-index-page.tsx +5 -0
- package/client/features/dev/dev-routes.tsx +2 -0
- package/client/features/dev/harness-debug-page.tsx +3 -3
- package/client/features/dev/onboarding-preview-page.tsx +76 -0
- package/client/features/dev/workspace-setup-mocks.ts +16 -14
- package/client/features/dev/workspace-setup-preview.tsx +11 -17
- package/client/features/harness/api.ts +45 -15
- package/client/features/harness/device-login-steps.tsx +9 -3
- package/client/features/harness/harness-login-panel.tsx +228 -0
- package/client/features/harness/harness-presentation.ts +15 -0
- package/client/features/harness/harness-selector.tsx +119 -0
- package/client/features/harness/use-harness-login.ts +77 -0
- package/client/features/home/home-page.tsx +7 -7
- package/client/features/onboarding/agent-setup-step.tsx +57 -0
- package/client/features/onboarding/api.ts +42 -0
- package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
- package/client/features/onboarding/onboarding-page.tsx +32 -0
- package/client/features/onboarding/onboarding-screen.tsx +20 -0
- package/client/features/onboarding/onboarding-status.tsx +24 -0
- package/client/features/onboarding/workspace-setup-step.tsx +239 -0
- package/client/features/overview/default/registry.tsx +2 -2
- package/client/features/overview/default/views-widget.tsx +6 -5
- package/client/features/overview/overview.tsx +9 -11
- package/client/features/overview/widget-canvas.tsx +1 -1
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/views/api.ts +69 -16
- package/client/features/views/pending-view-screen.tsx +30 -9
- package/client/features/views/use-view-actions.ts +19 -20
- package/client/features/views/view-presentation.ts +2 -2
- package/client/features/views/view-submission.ts +28 -41
- package/client/features/workspace/add/api.ts +3 -23
- package/client/features/workspace/add/create-workspace-dialog.tsx +6 -5
- package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
- package/client/features/workspace/add/workspace-agent-options.ts +11 -12
- package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
- package/client/features/workspace/api.ts +32 -36
- package/client/features/workspace/harness-transition.ts +88 -0
- package/client/features/{settings → workspace/settings}/api.ts +1 -34
- package/client/features/{settings → workspace/settings}/general-settings.tsx +76 -2
- package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
- package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
- package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
- package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
- package/client/features/workspace/setup/workspace-setup.tsx +34 -14
- package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +25 -9
- package/client/features/workspace/workspace-content.tsx +11 -8
- package/client/features/workspace/workspace-frame.tsx +2 -1
- package/client/features/workspace/workspace-layout-context.tsx +5 -2
- package/client/features/workspace/workspace-menu.tsx +12 -8
- package/client/features/workspace/workspace-pending-screen.tsx +10 -10
- package/client/features/workspace/workspace-presentation.tsx +5 -13
- package/client/features/workspace/workspace-state.ts +169 -0
- package/client/features/workspace/workspace-tabs.tsx +22 -2
- package/client/index.css +2 -0
- package/client/index.tsx +3 -3
- package/client/lib/flags.ts +1 -1
- package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
- package/client/runtime/workspace-events.ts +21 -4
- package/client/runtime/workspace-theme.ts +9 -0
- package/client/tailwind-config.ts +43 -0
- package/dist/chunk-0mjzg20x.js +2 -0
- package/dist/chunk-2y59vrxg.js +5 -0
- package/dist/chunk-58dyt9bk.js +2 -0
- package/dist/chunk-5aj040e5.css +1 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-71fn6rmj.js +546 -0
- package/dist/chunk-7yg1m8hx.js +2 -0
- package/dist/chunk-825hys3h.js +1 -0
- package/dist/chunk-9bb8m9rx.js +2 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-g0tcwqxc.js +1 -0
- package/dist/chunk-n0nab26d.js +1 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-v88n1bay.js +74 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +1 -1
- package/lib/{app-icons.ts → identity-icons.ts} +6 -7
- package/lib/onboarding.ts +41 -0
- package/lib/speed-mode.ts +5 -0
- package/lib/types.ts +71 -62
- package/lib/view-build-directives.ts +1 -2
- package/lib/workspace-icon.ts +2 -2
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-name.ts +15 -12
- package/package.json +9 -8
- package/server/README.md +27 -25
- package/server/api/harnesses.ts +31 -8
- package/server/api/index.ts +163 -126
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +16 -24
- package/server/app-settings.ts +6 -2
- package/server/applets/config.ts +5 -5
- package/server/applets/views.ts +19 -17
- package/server/cli/commands/init.ts +3 -3
- package/server/cli/commands/skill.ts +16 -17
- package/server/cli/commands/start.ts +8 -34
- package/server/cli/server.ts +18 -6
- package/server/collab/config.ts +1 -2
- package/server/collab/manager.ts +4 -1
- package/server/collab/skill/index.ts +1 -1
- package/server/control.ts +3 -3
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +24 -8
- package/server/harness/acp/session.ts +8 -4
- package/server/harness/auth.ts +14 -17
- package/server/harness/claude-code/NOTES.md +4 -3
- package/server/harness/claude-code/index.ts +2 -0
- package/server/harness/claude-code/models.ts +2 -20
- package/server/harness/claude-code/run-action.ts +123 -0
- package/server/harness/claude-code/session-title.ts +5 -7
- package/server/harness/claude-code/session.ts +24 -16
- package/server/harness/codex/NOTES.md +14 -9
- package/server/harness/codex/adapter.ts +14 -17
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/run-action.ts +93 -0
- package/server/harness/codex/session-title.ts +6 -8
- package/server/harness/codex/session.ts +11 -11
- package/server/harness/command.ts +45 -0
- package/server/harness/executable.ts +5 -0
- package/server/harness/fork.ts +6 -4
- package/server/harness/install.ts +49 -0
- package/server/harness/openclaw/session.ts +1 -2
- package/server/harness/run-action.ts +85 -0
- package/server/harness/session-title.ts +0 -46
- package/server/harness/types.ts +26 -2
- package/server/onboarding/brief.ts +29 -0
- package/server/onboarding/ideas.ts +48 -0
- package/server/onboarding/jobs.ts +291 -0
- package/server/onboarding/prompt.md +49 -0
- package/server/sessions/archive.ts +5 -14
- package/server/sessions/config.ts +17 -16
- package/server/sessions/lifecycle.ts +15 -13
- package/server/sessions/pending-views.ts +79 -108
- package/server/sessions/selected.ts +75 -161
- package/server/sessions/store.ts +40 -113
- package/server/sessions/view-sessions.ts +128 -111
- package/server/skills/locations.ts +82 -0
- package/server/skills/lock.ts +29 -0
- package/server/skills/template.ts +36 -25
- package/server/skills/update.ts +52 -5
- package/server/skills/version.ts +17 -22
- package/server/skills/workspace.ts +121 -0
- package/server/web.ts +22 -8
- package/server/workspace-state/file.ts +177 -0
- package/server/workspace-state/index.ts +162 -0
- package/server/workspace-state/legacy-migration.ts +79 -0
- package/server/workspace-state/lock.ts +42 -0
- package/server/workspace-state/types.ts +16 -0
- package/server/workspaces/change-harness.ts +88 -0
- package/server/workspaces/harness-transition.ts +29 -0
- package/server/workspaces/init.ts +29 -6
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +27 -1
- package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
- package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
- package/skill/references/DESIGN.md +148 -0
- package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
- package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
- package/ui-components/badge.tsx +1 -1
- package/client/accept-hmr-dependencies.ts +0 -22
- package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
- package/dist/chunk-20ynagd4.js +0 -2
- package/dist/chunk-42tde9a6.js +0 -1
- package/dist/chunk-9w543s0r.js +0 -2
- package/dist/chunk-a5372n61.js +0 -546
- package/dist/chunk-aja9y1vn.js +0 -68
- package/dist/chunk-fvcvrh3d.css +0 -1
- package/dist/chunk-gtfjw3nx.js +0 -1
- package/dist/chunk-j39y2aky.js +0 -14
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-pja30km3.js +0 -1
- package/dist/chunk-rm894bc2.js +0 -2
- package/dist/chunk-tevvtfbk.js +0 -10
- package/dist/chunk-tgt9zd0r.js +0 -2
- package/dist/chunk-tv5k5z00.js +0 -1
- package/dist/chunk-zq2ae5dx.js +0 -2
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
- /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
- /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/connectors-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
- /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
- /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
package/server/api/index.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveWorkspaceEnv } from '../workspaces/env'
|
|
2
|
+
import { changeWorkspaceHarness } from '../workspaces/change-harness'
|
|
3
|
+
import { HarnessTransitionError, reserveWorkspaceOperation } from '../workspaces/harness-transition'
|
|
4
|
+
import { onboarding } from './onboarding'
|
|
5
|
+
import type { SpeedMode } from '@/lib/types'
|
|
6
|
+
import { isSpeedMode } from '@/lib/speed-mode'
|
|
2
7
|
import { isMessageAttachments } from '@/lib/message-attachments'
|
|
3
8
|
import { Hono } from 'hono'
|
|
4
9
|
import { serveStatic } from 'hono/bun'
|
|
5
10
|
import { createMiddleware } from 'hono/factory'
|
|
6
11
|
import { existsSync } from 'node:fs'
|
|
7
|
-
import { basename,
|
|
12
|
+
import { basename, resolve } from 'node:path'
|
|
8
13
|
|
|
9
14
|
import { UPDATE_ACTIVE_AGENT_MESSAGE } from '@/lib/update'
|
|
10
15
|
import { resolveWorkspaceTheme } from '@/lib/themes'
|
|
@@ -16,7 +21,7 @@ import type {
|
|
|
16
21
|
HarnessAvailability,
|
|
17
22
|
SelectedSessionScope,
|
|
18
23
|
UploadInfo,
|
|
19
|
-
|
|
24
|
+
WorkspaceHarness,
|
|
20
25
|
WorkspaceEntry,
|
|
21
26
|
WorkspaceType
|
|
22
27
|
} from '@/lib/types'
|
|
@@ -60,17 +65,16 @@ import {
|
|
|
60
65
|
import { loadScratchpadDoc, saveScratchpadDoc } from '../scratchpad/document'
|
|
61
66
|
import { MAX_ASSET_BYTES, scratchpadAssetFile, storeScratchpadAsset } from '../scratchpad/assets'
|
|
62
67
|
import {
|
|
68
|
+
deselectSession,
|
|
63
69
|
getPinnedSession,
|
|
64
|
-
getSelectedSession,
|
|
65
|
-
getWorkspaceSessionSelection,
|
|
66
70
|
pinSession,
|
|
67
|
-
saveSelectedSession
|
|
71
|
+
saveSelectedSession,
|
|
72
|
+
unpinSession
|
|
68
73
|
} from '../sessions/selected'
|
|
69
|
-
import type { SelectedSessionUpdate } from '../sessions/selected'
|
|
70
74
|
import { saveSessionConfig } from '../sessions/config'
|
|
71
75
|
import type { SessionConfigPatch } from '../sessions/config'
|
|
72
|
-
import { getSessionRecord, withSessionRecords } from '../sessions/store'
|
|
73
76
|
import { archiveWorkspaceSession } from '../sessions/archive'
|
|
77
|
+
import { getWorkspaceState } from '../workspace-state'
|
|
74
78
|
import { DIST_DIR, prebuilt } from '../static'
|
|
75
79
|
import { getWorkspaceSkillsStatus, updateWorkspaceSkills } from '../skills/update'
|
|
76
80
|
import { serveWorkspaceImagePreview } from '../workspaces/preview'
|
|
@@ -94,7 +98,8 @@ import {
|
|
|
94
98
|
import { submitView, ViewStartupError } from '../sessions/view-sessions'
|
|
95
99
|
import { listWidgets, serveWidget } from '../applets/widgets'
|
|
96
100
|
import { getWorkspaceConfig, setWorkspaceConfig } from '../workspaces/config'
|
|
97
|
-
import {
|
|
101
|
+
import { createWorkspaceDirectory, provisionWorkspace } from '../workspaces/init'
|
|
102
|
+
import { validateWorkspaceName } from '@/lib/workspace-name'
|
|
98
103
|
import { resolveWorkspaceImportMetadata } from '../workspaces/import'
|
|
99
104
|
import type { WorkspaceImportMetadata } from '../workspaces/import'
|
|
100
105
|
import { getWorkspaceEnvView, parseEnvUpdate, updateWorkspaceEnv } from '../workspaces/env'
|
|
@@ -117,15 +122,6 @@ function eventOrigin(value: unknown): string | undefined {
|
|
|
117
122
|
return typeof value === 'string' ? value : undefined
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
function publishSelectedSession(workspaceId: string, update: SelectedSessionUpdate): void {
|
|
121
|
-
if (!update.changed) return
|
|
122
|
-
publishEvent({
|
|
123
|
-
type: 'selected-session:updated',
|
|
124
|
-
workspaceId,
|
|
125
|
-
sessionId: update.sessionId
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
125
|
async function handleFunctionCall(
|
|
130
126
|
req: Request,
|
|
131
127
|
tail: string,
|
|
@@ -170,15 +166,37 @@ async function handleFunctionCall(
|
|
|
170
166
|
const withWorkspace = createMiddleware<ApiEnv>(async (c, next) => {
|
|
171
167
|
const id = c.req.param('id')
|
|
172
168
|
if (!id) return c.text('Workspace not found', 404)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
let release: (() => void) | undefined
|
|
170
|
+
try {
|
|
171
|
+
if (c.req.method !== 'GET' && !c.req.path.endsWith('/harness'))
|
|
172
|
+
release = reserveWorkspaceOperation(id)
|
|
173
|
+
const ws = await getWorkspace(id)
|
|
174
|
+
if (!ws) return c.text('Workspace not found', 404)
|
|
175
|
+
c.set('ws', ws)
|
|
176
|
+
await next()
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (error instanceof HarnessTransitionError) return c.text(error.message, 409)
|
|
179
|
+
throw error
|
|
180
|
+
} finally {
|
|
181
|
+
release?.()
|
|
182
|
+
}
|
|
177
183
|
})
|
|
178
184
|
|
|
179
185
|
// ---- single workspace: /api/workspaces/:id/* --------------------------------
|
|
180
186
|
const one = new Hono<ApiEnv>()
|
|
181
187
|
one.use('*', withWorkspace)
|
|
188
|
+
one.patch('/harness', async c => {
|
|
189
|
+
if (getAppConfig().demo) return c.text('Changing agents is unavailable in the demo', 403)
|
|
190
|
+
const body = await c.req.json().catch(() => null)
|
|
191
|
+
if (!body || !['claude-code', 'codex'].includes(body.type))
|
|
192
|
+
return c.text('Invalid agent selection', 400)
|
|
193
|
+
try {
|
|
194
|
+
return c.json(await changeWorkspaceHarness(c.get('ws'), body.type))
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (error instanceof HarnessTransitionError) return c.text(error.message, 409)
|
|
197
|
+
throw error
|
|
198
|
+
}
|
|
199
|
+
})
|
|
182
200
|
|
|
183
201
|
one.get('/widgets', c => listWidgets(c.get('ws').path))
|
|
184
202
|
|
|
@@ -200,7 +218,7 @@ one.get('/views', c => listViews(c.get('ws').path))
|
|
|
200
218
|
one.patch('/views/:viewId', async c => {
|
|
201
219
|
const ws = c.get('ws')
|
|
202
220
|
const body = await c.req.json().catch(() => null)
|
|
203
|
-
if (await getPendingView(ws
|
|
221
|
+
if (await getPendingView(ws, c.req.param('viewId'))) {
|
|
204
222
|
try {
|
|
205
223
|
if (
|
|
206
224
|
typeof body?.requirements !== 'string' &&
|
|
@@ -209,7 +227,7 @@ one.patch('/views/:viewId', async c => {
|
|
|
209
227
|
)
|
|
210
228
|
return c.text('Expected requirements, title, or icon', 400)
|
|
211
229
|
return c.json(
|
|
212
|
-
await updatePendingView(ws
|
|
230
|
+
await updatePendingView(ws, c.req.param('viewId'), {
|
|
213
231
|
requirements: typeof body.requirements === 'string' ? body.requirements : undefined,
|
|
214
232
|
title: typeof body.title === 'string' ? body.title.trim() : undefined,
|
|
215
233
|
icon: typeof body.icon === 'string' ? body.icon : undefined
|
|
@@ -236,7 +254,7 @@ one.delete('/views/:viewId', async c => {
|
|
|
236
254
|
const ws = c.get('ws')
|
|
237
255
|
try {
|
|
238
256
|
const viewId = c.req.param('viewId')
|
|
239
|
-
if (await getPendingView(ws
|
|
257
|
+
if (await getPendingView(ws, viewId)) {
|
|
240
258
|
const active = new Set(
|
|
241
259
|
harnessFor(ws)
|
|
242
260
|
.activeSessions()
|
|
@@ -262,7 +280,7 @@ one.get('/views/*', c => {
|
|
|
262
280
|
|
|
263
281
|
one.post('/views', async c => {
|
|
264
282
|
const ws = c.get('ws')
|
|
265
|
-
return c.json(await createPendingView(ws
|
|
283
|
+
return c.json(await createPendingView(ws), 201)
|
|
266
284
|
})
|
|
267
285
|
|
|
268
286
|
one.post('/views/:viewId/submit', async c => {
|
|
@@ -274,7 +292,7 @@ one.post('/views/:viewId/submit', async c => {
|
|
|
274
292
|
selectedSessionScope?: SelectedSessionScope
|
|
275
293
|
model?: string
|
|
276
294
|
effort?: string
|
|
277
|
-
|
|
295
|
+
speedMode?: SpeedMode
|
|
278
296
|
stream?: boolean
|
|
279
297
|
attachments?: unknown
|
|
280
298
|
}>()
|
|
@@ -310,7 +328,7 @@ one.post('/views/:viewId/submit', async c => {
|
|
|
310
328
|
optimisticId: body.optimisticId,
|
|
311
329
|
model: typeof body.model === 'string' ? body.model : undefined,
|
|
312
330
|
effort: typeof body.effort === 'string' ? body.effort : undefined,
|
|
313
|
-
|
|
331
|
+
speedMode: isSpeedMode(body.speedMode) ? body.speedMode : undefined,
|
|
314
332
|
stream: body.stream === true ? true : undefined
|
|
315
333
|
})
|
|
316
334
|
return c.json(result)
|
|
@@ -478,64 +496,94 @@ one.get('/uploads/:uploadId', c => {
|
|
|
478
496
|
})
|
|
479
497
|
})
|
|
480
498
|
|
|
499
|
+
// Per-user chat state: pin, the chat each tab shows, per-chat settings and
|
|
500
|
+
// fork history, and views being built. Every write below answers with the new
|
|
501
|
+
// state; other clients get it as `state:changed`.
|
|
502
|
+
one.get('/state', async c => c.json(await getWorkspaceState(c.get('ws'))))
|
|
503
|
+
|
|
504
|
+
// The agent's chats. Tab ownership and settings come from `/state`.
|
|
481
505
|
one.get('/sessions', async c => {
|
|
482
506
|
const ws = c.get('ws')
|
|
483
|
-
return c.json(await
|
|
507
|
+
return c.json(await harnessFor(ws).listSessions(ws))
|
|
484
508
|
})
|
|
485
509
|
|
|
486
|
-
one.
|
|
487
|
-
|
|
510
|
+
one.put('/sessions/:sessionId/pin', async c => {
|
|
511
|
+
const ws = c.get('ws')
|
|
512
|
+
const sessionId = c.req.param('sessionId')
|
|
513
|
+
const harness = harnessFor(ws)
|
|
514
|
+
const found = (await harness.listSessions(ws)).some(session => session.sessionId === sessionId)
|
|
515
|
+
const active = harness
|
|
516
|
+
.activeSessions()
|
|
517
|
+
.some(session => session.workspaceId === ws.id && session.sessionId === sessionId)
|
|
518
|
+
if (!found && !active) return c.text('Chat not found', 404)
|
|
519
|
+
await pinSession(ws, sessionId)
|
|
520
|
+
return c.json(await getWorkspaceState(ws))
|
|
488
521
|
})
|
|
489
522
|
|
|
490
|
-
one.
|
|
523
|
+
one.delete('/sessions/:sessionId/pin', async c => {
|
|
491
524
|
const ws = c.get('ws')
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
return c.text('Invalid chat', 400)
|
|
495
|
-
if (body.sessionId) {
|
|
496
|
-
const harness = harnessFor(ws)
|
|
497
|
-
const found = (await harness.listSessions(ws)).some(
|
|
498
|
-
session => session.sessionId === body.sessionId
|
|
499
|
-
)
|
|
500
|
-
const active = harness
|
|
501
|
-
.activeSessions()
|
|
502
|
-
.some(session => session.workspaceId === ws.id && session.sessionId === body.sessionId)
|
|
503
|
-
if (!found && !active) return c.text('Chat not found', 404)
|
|
504
|
-
}
|
|
505
|
-
await pinSession(ws.path, body.sessionId)
|
|
506
|
-
publishEvent({
|
|
507
|
-
type: 'selected-session:updated',
|
|
508
|
-
workspaceId: ws.id,
|
|
509
|
-
sessionId: (await getSelectedSession(ws.path)) ?? null
|
|
510
|
-
})
|
|
511
|
-
return c.json({ pinnedSessionId: body.sessionId })
|
|
525
|
+
await unpinSession(ws, c.req.param('sessionId'))
|
|
526
|
+
return c.json(await getWorkspaceState(ws))
|
|
512
527
|
})
|
|
513
528
|
|
|
514
|
-
|
|
529
|
+
// Show the chat in a tab. `ifMatch` (a chat id, or null for none) applies the
|
|
530
|
+
// change only while the tab still shows that chat.
|
|
531
|
+
one.put('/sessions/:sessionId/selection', async c => {
|
|
515
532
|
const ws = c.get('ws')
|
|
516
533
|
const body: unknown = await c.req.json().catch(() => null)
|
|
517
534
|
if (!body || typeof body !== 'object') return c.text('Bad request', 400)
|
|
535
|
+
const input = body as { tabId?: unknown; ifMatch?: unknown }
|
|
536
|
+
if (!isWorkspaceTabId(input.tabId)) return c.text('Invalid chat tab', 400)
|
|
537
|
+
const hasIfMatch = Object.prototype.hasOwnProperty.call(input, 'ifMatch')
|
|
538
|
+
if (hasIfMatch && input.ifMatch !== null && typeof input.ifMatch !== 'string')
|
|
539
|
+
return c.text('ifMatch must be a chat id or null', 400)
|
|
540
|
+
if (await getPinnedSession(ws)) return c.text('Unpin chat before switching', 409)
|
|
541
|
+
await saveSelectedSession(
|
|
542
|
+
ws,
|
|
543
|
+
c.req.param('sessionId'),
|
|
544
|
+
input.tabId,
|
|
545
|
+
hasIfMatch ? (input.ifMatch as string | null) : undefined
|
|
546
|
+
)
|
|
547
|
+
return c.json(await getWorkspaceState(ws))
|
|
548
|
+
})
|
|
518
549
|
|
|
519
|
-
|
|
520
|
-
|
|
550
|
+
// Stop showing the chat in a tab, which then opens a new chat. A tab showing
|
|
551
|
+
// another chat is left alone.
|
|
552
|
+
one.delete('/sessions/:sessionId/selection', async c => {
|
|
553
|
+
const ws = c.get('ws')
|
|
554
|
+
const body: unknown = await c.req.json().catch(() => null)
|
|
555
|
+
const tabId = (body as { tabId?: unknown } | null)?.tabId
|
|
521
556
|
if (!isWorkspaceTabId(tabId)) return c.text('Invalid chat tab', 400)
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
557
|
+
await deselectSession(ws, c.req.param('sessionId'), tabId)
|
|
558
|
+
return c.json(await getWorkspaceState(ws))
|
|
559
|
+
})
|
|
560
|
+
|
|
561
|
+
// Change run settings. Omitted fields stay; null clears one.
|
|
562
|
+
one.patch('/sessions/:sessionId/config', async c => {
|
|
563
|
+
const body = await c.req.json().catch(() => null)
|
|
564
|
+
if (typeof body !== 'object' || body === null) {
|
|
565
|
+
return c.text('Expected a JSON object', 400)
|
|
566
|
+
}
|
|
567
|
+
const patch: SessionConfigPatch = {}
|
|
568
|
+
const record = body as Record<string, unknown>
|
|
569
|
+
for (const key of ['model', 'effort'] as const) {
|
|
570
|
+
if (!(key in record)) continue
|
|
571
|
+
const value = record[key]
|
|
572
|
+
if (value !== null && typeof value !== 'string') {
|
|
573
|
+
return c.text(`${key} must be a string or null`, 400)
|
|
574
|
+
}
|
|
575
|
+
patch[key] = value
|
|
576
|
+
}
|
|
577
|
+
if ('speedMode' in record) {
|
|
578
|
+
const value = record.speedMode
|
|
579
|
+
if (value !== null && !isSpeedMode(value)) {
|
|
580
|
+
return c.text('speedMode must be "normal", "fast", "ultrafast", or null', 400)
|
|
581
|
+
}
|
|
582
|
+
patch.speedMode = value
|
|
583
|
+
}
|
|
584
|
+
const ws = c.get('ws')
|
|
585
|
+
await saveSessionConfig(ws, c.req.param('sessionId'), patch)
|
|
586
|
+
return c.json(await getWorkspaceState(ws))
|
|
539
587
|
})
|
|
540
588
|
|
|
541
589
|
one.post('/sessions/:sessionId/archive', async c => {
|
|
@@ -546,7 +594,7 @@ one.post('/sessions/:sessionId/archive', async c => {
|
|
|
546
594
|
|
|
547
595
|
try {
|
|
548
596
|
await archiveWorkspaceSession(ws, sessionId)
|
|
549
|
-
return c.
|
|
597
|
+
return c.json(await getWorkspaceState(ws))
|
|
550
598
|
} catch (error) {
|
|
551
599
|
console.error(`[api] archive chat failed for ${harness.id}`, error)
|
|
552
600
|
// Harnesses translate backend refusals into actionable one-liners (e.g.
|
|
@@ -563,39 +611,6 @@ one.get('/sessions/:sessionId/events', async c => {
|
|
|
563
611
|
return c.json(await harnessFor(ws).sessionEvents(ws, sessionId))
|
|
564
612
|
})
|
|
565
613
|
|
|
566
|
-
one.get('/sessions/:sessionId', async c => {
|
|
567
|
-
return c.json(await getSessionRecord(c.get('ws').path, c.req.param('sessionId')))
|
|
568
|
-
})
|
|
569
|
-
|
|
570
|
-
// Patch run settings and return the complete session record. null clears a setting.
|
|
571
|
-
one.put('/sessions/:sessionId/config', async c => {
|
|
572
|
-
const body = await c.req.json().catch(() => null)
|
|
573
|
-
if (typeof body !== 'object' || body === null) {
|
|
574
|
-
return c.text('Expected a JSON object', 400)
|
|
575
|
-
}
|
|
576
|
-
const patch: SessionConfigPatch = {}
|
|
577
|
-
const record = body as Record<string, unknown>
|
|
578
|
-
for (const key of ['model', 'effort'] as const) {
|
|
579
|
-
if (!(key in record)) continue
|
|
580
|
-
const value = record[key]
|
|
581
|
-
if (value !== null && typeof value !== 'string') {
|
|
582
|
-
return c.text(`${key} must be a string or null`, 400)
|
|
583
|
-
}
|
|
584
|
-
patch[key] = value
|
|
585
|
-
}
|
|
586
|
-
if ('fastMode' in record) {
|
|
587
|
-
const value = record.fastMode
|
|
588
|
-
if (value !== null && typeof value !== 'boolean') {
|
|
589
|
-
return c.text('fastMode must be a boolean or null', 400)
|
|
590
|
-
}
|
|
591
|
-
patch.fastMode = value
|
|
592
|
-
}
|
|
593
|
-
const workspacePath = c.get('ws').path
|
|
594
|
-
const sessionId = c.req.param('sessionId')
|
|
595
|
-
await saveSessionConfig(workspacePath, sessionId, patch)
|
|
596
|
-
return c.json(await getSessionRecord(workspacePath, sessionId))
|
|
597
|
-
})
|
|
598
|
-
|
|
599
614
|
one.get('/mcp', async c => {
|
|
600
615
|
const ws = c.get('ws')
|
|
601
616
|
return c.json((await harnessFor(ws).mcpStatus?.(ws)) ?? [])
|
|
@@ -660,10 +675,9 @@ one.post('/skills/update', async c => {
|
|
|
660
675
|
return c.json(result.status)
|
|
661
676
|
})
|
|
662
677
|
|
|
663
|
-
//
|
|
664
|
-
//
|
|
665
|
-
|
|
666
|
-
one.get('/agent', async c => {
|
|
678
|
+
// Workspace configuration and models. Shared account status is served by
|
|
679
|
+
// /harnesses/status; only workspace overrides and gateways are probed here.
|
|
680
|
+
one.get('/harness', async c => {
|
|
667
681
|
const ws = c.get('ws')
|
|
668
682
|
const harness = harnessFor(ws)
|
|
669
683
|
const capabilities = {
|
|
@@ -674,18 +688,35 @@ one.get('/agent', async c => {
|
|
|
674
688
|
if (!existsSync(ws.path)) {
|
|
675
689
|
return c.json({
|
|
676
690
|
...capabilities,
|
|
677
|
-
|
|
691
|
+
isFolderMissing: true,
|
|
678
692
|
availability: { status: 'unavailable', reason: 'Workspace folder not found' },
|
|
679
693
|
models: []
|
|
680
|
-
} satisfies
|
|
694
|
+
} satisfies WorkspaceHarness)
|
|
681
695
|
}
|
|
696
|
+
const authEnv =
|
|
697
|
+
harness.id === 'codex'
|
|
698
|
+
? /^(OPENAI_|CODEX_)/
|
|
699
|
+
: /^(ANTHROPIC_|CLAUDE_|AWS_|GOOGLE_|AZURE_|CLOUD_ML_)/
|
|
700
|
+
const hasAuthOverrides =
|
|
701
|
+
harness.authStatus &&
|
|
702
|
+
Object.entries(await resolveWorkspaceEnv(ws.path)).some(
|
|
703
|
+
([key, value]) =>
|
|
704
|
+
value !== process.env[key] &&
|
|
705
|
+
(authEnv.test(key) || /^(HOME|USERPROFILE|XDG_CONFIG_HOME)$/.test(key))
|
|
706
|
+
)
|
|
682
707
|
const refresh = c.req.query('refresh') === 'true'
|
|
683
708
|
if (refresh) await loginShellPath({ refresh: true })
|
|
684
709
|
// A backend that can't answer (codex CLI missing, gateway down) degrades to
|
|
685
710
|
// an empty catalog — the picker hides and chat surfaces the real problem via
|
|
686
711
|
// workspace setup, instead of this endpoint failing on page load.
|
|
687
712
|
const [availability, models] = await Promise.all([
|
|
688
|
-
|
|
713
|
+
// Shared account status comes from /harnesses/status.
|
|
714
|
+
// Gateway-backed harnesses still have workspace-specific readiness.
|
|
715
|
+
harness.authStatus && !hasAuthOverrides
|
|
716
|
+
? Promise.resolve({ status: 'available' as const })
|
|
717
|
+
: refresh
|
|
718
|
+
? harnessStore.refresh(ws)
|
|
719
|
+
: harnessStore.getAvailability(ws),
|
|
689
720
|
harness.listModels(ws).catch(err => {
|
|
690
721
|
console.error(`[api] listModels failed for ${harness.id}`, err)
|
|
691
722
|
return []
|
|
@@ -694,8 +725,9 @@ one.get('/agent', async c => {
|
|
|
694
725
|
return c.json({
|
|
695
726
|
...capabilities,
|
|
696
727
|
availability,
|
|
728
|
+
hasAuthOverrides: Boolean(hasAuthOverrides),
|
|
697
729
|
models
|
|
698
|
-
} satisfies
|
|
730
|
+
} satisfies WorkspaceHarness)
|
|
699
731
|
})
|
|
700
732
|
|
|
701
733
|
// Workspace identity. Uploads use the image route below.
|
|
@@ -881,11 +913,16 @@ one.put('/', async c => {
|
|
|
881
913
|
const body = await c.req.json()
|
|
882
914
|
if (!body || body.version !== 1) return c.text('Bad request', 400)
|
|
883
915
|
// `origin` is the writing tab's id, echoed so that tab skips its own event.
|
|
884
|
-
const { origin, ...layout } = body
|
|
916
|
+
const { origin, harness, ...layout } = body
|
|
885
917
|
// Preserve server-owned identity (name/icon) across a grid/theme save so the
|
|
886
918
|
// client's PUT can't erase a `moi config`-set name. See mergeLayoutForSave.
|
|
887
919
|
const existing = await loadLayout(ws.path)
|
|
888
920
|
const next = mergeLayoutForSave(existing, layout)
|
|
921
|
+
if (harness !== undefined && harness !== (ws.type ?? 'claude-code')) {
|
|
922
|
+
next.selectedModel = existing.selectedModel
|
|
923
|
+
next.selectedEffort = existing.selectedEffort
|
|
924
|
+
next.selectedSpeedMode = existing.selectedSpeedMode
|
|
925
|
+
}
|
|
889
926
|
await saveLayout(next, ws.path)
|
|
890
927
|
if (
|
|
891
928
|
JSON.stringify(resolveWorkspaceTheme(existing.theme)) !==
|
|
@@ -1017,12 +1054,6 @@ async function workspaceTypeAvailability(type: WorkspaceType): Promise<HarnessAv
|
|
|
1017
1054
|
return (await harnessFor(type).availability?.()) ?? { status: 'available' }
|
|
1018
1055
|
}
|
|
1019
1056
|
|
|
1020
|
-
// Both workspace dialogs only need installation facts to offer agent choices.
|
|
1021
|
-
workspaces.get('/create', async c => {
|
|
1022
|
-
c.header('Cache-Control', 'no-store')
|
|
1023
|
-
return c.json({ installed: await detectInstalledHarnesses() })
|
|
1024
|
-
})
|
|
1025
|
-
|
|
1026
1057
|
// Create a brand-new workspace: a fresh folder under createdWorkspacesRoot(),
|
|
1027
1058
|
// provisioned (skills + `.moi/` scaffold) and registered.
|
|
1028
1059
|
workspaces.post('/create', async c => {
|
|
@@ -1038,18 +1069,23 @@ workspaces.post('/create', async c => {
|
|
|
1038
1069
|
}
|
|
1039
1070
|
const availability = await workspaceTypeAvailability(type)
|
|
1040
1071
|
if (availability.status !== 'available') return c.text(availability.reason, 400)
|
|
1041
|
-
const name =
|
|
1042
|
-
|
|
1072
|
+
const name =
|
|
1073
|
+
body?.name === undefined
|
|
1074
|
+
? 'My workspace'
|
|
1075
|
+
: typeof body.name === 'string'
|
|
1076
|
+
? body.name.trim()
|
|
1077
|
+
: ''
|
|
1078
|
+
const invalid = validateWorkspaceName(name)
|
|
1043
1079
|
if (invalid) return c.text(invalid, 400)
|
|
1044
|
-
const path =
|
|
1045
|
-
if (existsSync(path)) return c.text('A folder with that name already exists', 409)
|
|
1080
|
+
const path = await createWorkspaceDirectory(name, createdWorkspacesRoot())
|
|
1046
1081
|
try {
|
|
1047
1082
|
await provisionWorkspace(path, type)
|
|
1048
1083
|
} catch (err) {
|
|
1049
1084
|
const message = err instanceof Error ? err.message : String(err)
|
|
1050
1085
|
return c.text(`Could not create workspace: ${message}`, 500)
|
|
1051
1086
|
}
|
|
1052
|
-
|
|
1087
|
+
await setWorkspaceConfig(path, { name })
|
|
1088
|
+
const entry = await registerWorkspace(path, { id: basename(path), type, name })
|
|
1053
1089
|
// Nudge every connected client (the sidebar list) to refetch.
|
|
1054
1090
|
publishEvent({ type: 'workspaces-list:updated' })
|
|
1055
1091
|
return c.json(entry, 201)
|
|
@@ -1065,6 +1101,7 @@ export const api = new Hono()
|
|
|
1065
1101
|
|
|
1066
1102
|
api.route('/api/workspaces', workspaces)
|
|
1067
1103
|
api.route('/api/harnesses', harnesses)
|
|
1104
|
+
api.route('/api/onboarding', onboarding)
|
|
1068
1105
|
|
|
1069
1106
|
// Startup config (config.json in the data dir + MOI_* env), client-safe
|
|
1070
1107
|
// subset. Immutable for the process lifetime — clients cache it forever.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Hono } from 'hono'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { getAppConfig } from '../app-config'
|
|
4
|
+
import { getAppSettings } from '../app-settings'
|
|
5
|
+
import { cancelIdeas, createFromIdea, discoverIdeas } from '../onboarding/jobs'
|
|
6
|
+
|
|
7
|
+
const discoverySchema = z.object({
|
|
8
|
+
harness: z.enum(['claude-code', 'codex']),
|
|
9
|
+
runId: z.string().uuid()
|
|
10
|
+
})
|
|
11
|
+
const buildSchema = discoverySchema.extend({
|
|
12
|
+
ideaId: z.string().uuid(),
|
|
13
|
+
operationId: z.string().uuid(),
|
|
14
|
+
retry: z.boolean().optional()
|
|
15
|
+
})
|
|
16
|
+
export const onboarding = new Hono()
|
|
17
|
+
onboarding.use('*', async (c, next) => {
|
|
18
|
+
if (getAppConfig().demo || !getAppSettings().showOnboarding)
|
|
19
|
+
return c.json({ error: 'Onboarding is not enabled' }, 403)
|
|
20
|
+
c.header('Cache-Control', 'no-store')
|
|
21
|
+
await next()
|
|
22
|
+
})
|
|
23
|
+
onboarding.post('/discover', async c => {
|
|
24
|
+
const parsed = discoverySchema.safeParse(await c.req.json().catch(() => undefined))
|
|
25
|
+
if (!parsed.success) return c.json({ error: 'Invalid discovery request' }, 400)
|
|
26
|
+
return c.json(await discoverIdeas(parsed.data))
|
|
27
|
+
})
|
|
28
|
+
onboarding.post('/cancel', async c => {
|
|
29
|
+
const parsed = z
|
|
30
|
+
.object({ runId: z.string().uuid() })
|
|
31
|
+
.safeParse(await c.req.json().catch(() => undefined))
|
|
32
|
+
if (!parsed.success) return c.json({ error: 'Invalid discovery request' }, 400)
|
|
33
|
+
await cancelIdeas(parsed.data.runId)
|
|
34
|
+
return c.json({ status: 'done' })
|
|
35
|
+
})
|
|
36
|
+
onboarding.post('/create', async c => {
|
|
37
|
+
const parsed = buildSchema.safeParse(await c.req.json().catch(() => undefined))
|
|
38
|
+
if (!parsed.success) return c.json({ error: 'Invalid workspace request' }, 400)
|
|
39
|
+
const { harness, runId, ideaId, operationId, retry } = parsed.data
|
|
40
|
+
// Use the validated server result, never a browser-supplied workspace plan.
|
|
41
|
+
const discovery = await discoverIdeas({ harness, runId })
|
|
42
|
+
const idea = discovery.ideas?.find(idea => idea.id === ideaId)
|
|
43
|
+
if (discovery.status !== 'done' || !idea)
|
|
44
|
+
return c.json({ error: 'Choose an available idea' }, 409)
|
|
45
|
+
return c.json(await createFromIdea({ harness, operationId, idea }, retry))
|
|
46
|
+
})
|
package/server/app-config.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { readFileSync } from 'node:fs'
|
|
|
2
2
|
import { homedir } from 'node:os'
|
|
3
3
|
import { isAbsolute, join } from 'path'
|
|
4
4
|
|
|
5
|
-
import type { AppEnvironment, ClientAppConfig
|
|
6
|
-
import { EXPERIMENTAL_DEFAULTS } from '@/lib/experimental'
|
|
5
|
+
import type { AppEnvironment, ClientAppConfig } from '@/lib/types'
|
|
7
6
|
|
|
8
7
|
import { DATA_DIR } from './data-dir'
|
|
9
8
|
|
|
@@ -13,17 +12,16 @@ import { DATA_DIR } from './data-dir'
|
|
|
13
12
|
// runtime): config.json describes the deployment itself — nothing here changes
|
|
14
13
|
// without a server restart, and no API writes it.
|
|
15
14
|
//
|
|
16
|
-
// Resolution: defaults < config.json < env.
|
|
17
|
-
// only by explicit CLI flags.
|
|
15
|
+
// Resolution: defaults < config.json < env.
|
|
18
16
|
// A missing file is the normal local case; a malformed file or wrong-typed key
|
|
19
17
|
// warns on stderr and falls back per-key, so a broken config never takes the
|
|
20
18
|
// CLI or server down with it.
|
|
21
19
|
export type AppConfig = {
|
|
22
20
|
environment: AppEnvironment
|
|
21
|
+
collab: boolean
|
|
23
22
|
// Demo mode: workspace creation is blocked (UI shows the
|
|
24
23
|
// cloud-demo promo dialog instead) and `moi` system commands are disabled.
|
|
25
24
|
demo: boolean
|
|
26
|
-
experimental: ExperimentalFeatures
|
|
27
25
|
// Link target for the cloud-demo promo dialog.
|
|
28
26
|
demoInstallUrl: string
|
|
29
27
|
// Cloudflare Access (Zero Trust) in front of this deployment: each viewer
|
|
@@ -48,12 +46,11 @@ export type CloudflareAccessConfig = {
|
|
|
48
46
|
audience: readonly string[]
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
type DeploymentConfig = Omit<AppConfig, 'experimental'>
|
|
52
|
-
|
|
53
49
|
const DEFAULTS: AppConfig = {
|
|
54
50
|
environment: 'local',
|
|
51
|
+
// Temporarily disabled while collaboration is being reconsidered.
|
|
52
|
+
collab: false,
|
|
55
53
|
demo: false,
|
|
56
|
-
experimental: { ...EXPERIMENTAL_DEFAULTS },
|
|
57
54
|
demoInstallUrl: 'https://moi.computer',
|
|
58
55
|
cloudflareAccess: null,
|
|
59
56
|
workspacesDir: null,
|
|
@@ -197,8 +194,8 @@ function readConfigFile(file: string): Record<string, unknown> {
|
|
|
197
194
|
return parsed as Record<string, unknown>
|
|
198
195
|
}
|
|
199
196
|
|
|
200
|
-
function fileValues(raw: Record<string, unknown>): Partial<
|
|
201
|
-
const out: Partial<
|
|
197
|
+
function fileValues(raw: Record<string, unknown>): Partial<AppConfig> {
|
|
198
|
+
const out: Partial<AppConfig> = {}
|
|
202
199
|
const environment = parseEnvironment(raw.environment)
|
|
203
200
|
if (environment !== undefined) out.environment = environment
|
|
204
201
|
if (raw.demo !== undefined) {
|
|
@@ -221,33 +218,28 @@ function fileValues(raw: Record<string, unknown>): Partial<DeploymentConfig> {
|
|
|
221
218
|
// Pure resolver, exported for tests. `getAppConfig` is the cached entrypoint.
|
|
222
219
|
export function loadAppConfig(
|
|
223
220
|
file: string = APP_CONFIG_FILE,
|
|
224
|
-
env: Record<string, string | undefined> = process.env
|
|
225
|
-
cliExperimental: Partial<ExperimentalFeatures> = {}
|
|
221
|
+
env: Record<string, string | undefined> = process.env
|
|
226
222
|
): AppConfig {
|
|
227
223
|
const raw = readConfigFile(file)
|
|
228
224
|
const fromFile = fileValues(raw)
|
|
229
|
-
const fromEnv: Partial<
|
|
225
|
+
const fromEnv: Partial<AppConfig> = {
|
|
230
226
|
environment: parseEnvironment(env.MOI_ENVIRONMENT),
|
|
231
227
|
demo: parseBool(env.MOI_DEMO),
|
|
232
228
|
demoInstallUrl: parseString(env.MOI_DEMO_INSTALL_URL)
|
|
233
229
|
}
|
|
234
230
|
const merged = { ...DEFAULTS, ...fromFile }
|
|
235
|
-
for (const key of Object.keys(fromEnv) as (keyof
|
|
231
|
+
for (const key of Object.keys(fromEnv) as (keyof AppConfig)[]) {
|
|
236
232
|
if (fromEnv[key] === undefined) delete fromEnv[key]
|
|
237
233
|
}
|
|
238
234
|
const cloudflareAccess = resolveCloudflareAccess(raw.cloudflareAccess, env)
|
|
239
|
-
|
|
240
|
-
...DEFAULTS.experimental,
|
|
241
|
-
...cliExperimental
|
|
242
|
-
})
|
|
243
|
-
return Object.freeze({ ...merged, ...fromEnv, cloudflareAccess, experimental })
|
|
235
|
+
return Object.freeze({ ...merged, ...fromEnv, cloudflareAccess })
|
|
244
236
|
}
|
|
245
237
|
|
|
246
238
|
let _config: AppConfig | null = null
|
|
247
239
|
|
|
248
|
-
//
|
|
249
|
-
export function initializeAppConfig(
|
|
250
|
-
_config = loadAppConfig(
|
|
240
|
+
// Resolve deployment settings before importing the web server.
|
|
241
|
+
export function initializeAppConfig(): void {
|
|
242
|
+
_config = loadAppConfig()
|
|
251
243
|
}
|
|
252
244
|
|
|
253
245
|
export function getAppConfig(): AppConfig {
|
|
@@ -270,6 +262,6 @@ export function resetAppConfig(): void {
|
|
|
270
262
|
// The only shape that reaches the browser (GET /api/config). Server-only keys
|
|
271
263
|
// added to AppConfig later stay out unless explicitly forwarded here.
|
|
272
264
|
export function clientAppConfig(): ClientAppConfig {
|
|
273
|
-
const { environment,
|
|
274
|
-
return { environment,
|
|
265
|
+
const { environment, collab, demo, demoInstallUrl } = getAppConfig()
|
|
266
|
+
return { environment, collab, demo, demoInstallUrl }
|
|
275
267
|
}
|
package/server/app-settings.ts
CHANGED
|
@@ -16,7 +16,10 @@ export type AppSettingsPatch = Partial<AppSettings>
|
|
|
16
16
|
// Whitelist of fields the API may update. Type validation is NOT duplicated
|
|
17
17
|
// here — `saveAppSettings` validates the merged store against the conf schema
|
|
18
18
|
// before anything is written, so a bad value throws with nothing persisted.
|
|
19
|
-
const API_UPDATABLE = [
|
|
19
|
+
const API_UPDATABLE = [
|
|
20
|
+
'autoUpdateSkills',
|
|
21
|
+
'showOnboarding'
|
|
22
|
+
] as const satisfies readonly (keyof AppSettings)[]
|
|
20
23
|
|
|
21
24
|
// Pick the API-updatable fields out of an untrusted body; unknown keys are
|
|
22
25
|
// dropped. Values are intentionally unchecked — the conf schema rejects wrong
|
|
@@ -44,7 +47,8 @@ function store(): Conf<AppSettings> {
|
|
|
44
47
|
cwd: _dir,
|
|
45
48
|
configName: 'settings',
|
|
46
49
|
schema: {
|
|
47
|
-
autoUpdateSkills: { type: 'boolean', default: false }
|
|
50
|
+
autoUpdateSkills: { type: 'boolean', default: false },
|
|
51
|
+
showOnboarding: { type: 'boolean', default: true }
|
|
48
52
|
}
|
|
49
53
|
})
|
|
50
54
|
return _store
|