moi-computer 0.11.1-dev.1c52199 → 0.11.1-dev.be1ed10
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/client/api/app-config.ts +1 -2
- package/client/app/routes/WorkspaceRoute.tsx +19 -27
- package/client/features/applets/AppletMount.tsx +1 -4
- package/client/features/applets/applet-runtime.ts +2 -13
- package/client/features/chat/applet-chat-intents.ts +6 -15
- package/client/features/chat/sessions/useSelectedSession.ts +20 -64
- package/client/features/chat/useChat.ts +0 -4
- package/client/features/dev/DevIndexPage.tsx +0 -5
- package/client/features/dev/DevRoutes.tsx +1 -14
- package/client/features/views/ViewManager.tsx +1 -4
- package/client/features/views/api.ts +2 -2
- package/client/features/views/useViewBuilderActions.ts +0 -3
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -18
- package/client/features/workspace/WorkspaceScreen.tsx +11 -19
- package/client/features/workspace/api.ts +1 -3
- package/client/features/workspace/moi-context.ts +2 -7
- package/client/features/workspace/useWorkspaceNavigation.ts +3 -12
- package/client/index.tsx +3 -4
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-wnmf38ta.js → chunk-mzrgr577.js} +1 -1
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -0
- package/dist/index.html +1 -1
- package/lib/moi-context.ts +0 -7
- package/lib/types.ts +6 -12
- package/package.json +1 -3
- package/server/api.ts +2 -23
- package/server/app-config.ts +34 -127
- package/server/applet-typecheck.ts +1 -6
- package/server/applets/build-applet.ts +0 -10
- package/server/cli.ts +12 -57
- package/server/layout.ts +3 -16
- package/server/skills-template.ts +2 -14
- package/server/web.ts +17 -62
- package/ui-components/avatar.tsx +4 -5
- package/ui-components/docs/avatar.md +5 -5
- package/client/features/collab/DevCollabIdentity.tsx +0 -170
- package/client/features/collab/DevCollabKit.tsx +0 -501
- package/client/features/collab/DevCollabPage.tsx +0 -25
- package/client/features/collab/WorkspaceCollabControls.tsx +0 -313
- package/client/features/collab/client.ts +0 -146
- package/client/features/collab/components.tsx +0 -307
- package/client/features/collab/dev-persona.ts +0 -66
- package/client/features/collab/engine.ts +0 -96
- package/client/features/collab/entry.tsx +0 -35
- package/client/features/collab/facehash-avatar.ts +0 -132
- package/client/features/collab/fake-engine.ts +0 -130
- package/client/features/collab/hooks.tsx +0 -253
- package/client/features/collab/identity.ts +0 -305
- package/client/features/collab/index.ts +0 -45
- package/client/features/collab/people.ts +0 -102
- package/client/features/collab/personal-state.ts +0 -61
- package/client/features/collab/presence-publisher.ts +0 -29
- package/client/features/collab/presence-target.ts +0 -10
- package/client/features/collab/primitives.tsx +0 -398
- package/client/features/collab/proxy-identity.ts +0 -24
- package/client/features/collab/store.ts +0 -156
- package/client/features/workspace/layout-save.ts +0 -13
- package/dist/chunk-1ftessc8.js +0 -2
- package/dist/chunk-3802vh2p.js +0 -2
- package/dist/chunk-542a2m9m.js +0 -1
- package/dist/chunk-5745d83v.js +0 -2
- package/dist/chunk-5zxdsjym.js +0 -1
- package/dist/chunk-7r4z77ry.js +0 -2
- package/dist/chunk-9cm0wjah.js +0 -79
- package/dist/chunk-cvgdm1hq.js +0 -2
- package/dist/chunk-gptm4jpd.js +0 -546
- package/dist/chunk-xaehhr1j.css +0 -1
- package/dist/chunk-xpt063fx.js +0 -1
- package/lib/collab/colors.ts +0 -24
- package/lib/collab/protocol.ts +0 -83
- package/lib/collab/types.ts +0 -63
- package/lib/experimental.ts +0 -14
- package/server/chat-selection.ts +0 -23
- package/server/collab/applet-module.ts +0 -50
- package/server/collab/cloudflare-access.ts +0 -77
- package/server/collab/config.ts +0 -18
- package/server/collab/ipc.ts +0 -10
- package/server/collab/manager.ts +0 -407
- package/server/collab/service.ts +0 -137
- package/server/collab/skill/collab-env.d.ts +0 -92
- package/server/collab/skill/index.ts +0 -59
- package/server/collab/worker.ts +0 -52
- package/workspace/.claude/skills/moi-workspace/references/COLLABORATIVE.md +0 -151
package/server/api.ts
CHANGED
|
@@ -23,14 +23,10 @@ import type {
|
|
|
23
23
|
import type { MoiContext } from '@/lib/moi-context'
|
|
24
24
|
import { viewBuilderDirectives } from '@/lib/view-builder-directives'
|
|
25
25
|
|
|
26
|
-
import { proxyIdentity } from './collab/cloudflare-access'
|
|
27
|
-
import { getCollabReferencePath } from './collab/config'
|
|
28
|
-
import { collabManager } from './collab/manager'
|
|
29
26
|
import { agentStore } from './agent'
|
|
30
27
|
import { clientAppConfig, getAppConfig } from './app-config'
|
|
31
28
|
import { getAppSettings, pickAppSettingsPatch, saveAppSettings } from './app-settings'
|
|
32
29
|
import { appletForModule, recordAppletError } from './applet-log'
|
|
33
|
-
import { selectChatSession } from './chat-selection'
|
|
34
30
|
import { apiBaseFor, parseAppletTail, serveWorkspaceFile } from './applets'
|
|
35
31
|
import { applyEnvChanged } from './env-apply'
|
|
36
32
|
import { publishEvent } from './events'
|
|
@@ -302,7 +298,6 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
302
298
|
const body = await c.req.json<{
|
|
303
299
|
input?: Partial<ViewBuilderInput>
|
|
304
300
|
optimisticId?: string
|
|
305
|
-
personalSelection?: boolean
|
|
306
301
|
model?: string
|
|
307
302
|
effort?: string
|
|
308
303
|
fastMode?: boolean
|
|
@@ -316,9 +311,6 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
316
311
|
if (body.optimisticId !== undefined && typeof body.optimisticId !== 'string') {
|
|
317
312
|
return c.text('Invalid optimisticId', 400)
|
|
318
313
|
}
|
|
319
|
-
if (body.personalSelection !== undefined && typeof body.personalSelection !== 'boolean') {
|
|
320
|
-
return c.text('Invalid personalSelection', 400)
|
|
321
|
-
}
|
|
322
314
|
const availableIcons = parseAvailableViewIcons(body.availableIcons)
|
|
323
315
|
if (!availableIcons) return c.text('Available view icons are required', 400)
|
|
324
316
|
const attachments = body.attachments ?? []
|
|
@@ -342,9 +334,7 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
342
334
|
// The bootstrap instructions ride the moi-context envelope, injected by
|
|
343
335
|
// the harness like any other ambient context; the user text stays bare.
|
|
344
336
|
// The user submits from the builder's own tab, so that's the active tab.
|
|
345
|
-
const collabReference = await getCollabReferencePath(ws.path, ws.type)
|
|
346
337
|
const context: MoiContext = {
|
|
347
|
-
...(collabReference ? { collabReference } : {}),
|
|
348
338
|
activeTab: `view-builders/${builder.id}`,
|
|
349
339
|
directives: [
|
|
350
340
|
...viewBuilderDirectives(builder.id, availableIcons),
|
|
@@ -354,7 +344,7 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
354
344
|
]
|
|
355
345
|
}
|
|
356
346
|
try {
|
|
357
|
-
await
|
|
347
|
+
publishSelectedSession(ws.id, await saveSelectedSession(ws.path, builder.sessionId))
|
|
358
348
|
await harnessFor(ws).sendMessage({
|
|
359
349
|
workspaceId: ws.id,
|
|
360
350
|
workspacePath: ws.path,
|
|
@@ -914,16 +904,13 @@ one.delete('/icon', async c => {
|
|
|
914
904
|
one.get('/', async c => {
|
|
915
905
|
const ws = c.get('ws')
|
|
916
906
|
const layout = await loadLayout(ws.path)
|
|
917
|
-
const collabReference = await getCollabReferencePath(ws.path, ws.type)
|
|
918
907
|
return c.json({
|
|
919
908
|
...layout,
|
|
920
909
|
// Resolved display name: the settings override, or the folder name.
|
|
921
910
|
name: layout.name || basename(ws.path),
|
|
922
911
|
cwd: ws.path,
|
|
923
912
|
provider: ws.type,
|
|
924
|
-
agentId: ws.agentId
|
|
925
|
-
// Undefined is omitted from JSON and overrides stale persisted metadata.
|
|
926
|
-
collabReference
|
|
913
|
+
agentId: ws.agentId
|
|
927
914
|
})
|
|
928
915
|
})
|
|
929
916
|
|
|
@@ -993,7 +980,6 @@ one.delete('/', async c => {
|
|
|
993
980
|
const ok = await removeWorkspace(ws.id)
|
|
994
981
|
if (!ok) return c.text('Workspace not found', 404)
|
|
995
982
|
harnessFor(ws).stopWorkspace?.(ws.path)
|
|
996
|
-
await collabManager.stopWorkspace(ws.path)
|
|
997
983
|
return c.body(null, 204)
|
|
998
984
|
})
|
|
999
985
|
|
|
@@ -1155,13 +1141,6 @@ api.route('/api/workspaces', workspaces)
|
|
|
1155
1141
|
// subset. Immutable for the process lifetime — clients cache it forever.
|
|
1156
1142
|
api.get('/api/config', c => c.json(clientAppConfig()))
|
|
1157
1143
|
|
|
1158
|
-
// The viewer's identity as verified by a configured proxy (Cloudflare Access).
|
|
1159
|
-
// It differs per request, so neither browsers nor Cloudflare's edge may cache it.
|
|
1160
|
-
api.get('/api/identity', async c => {
|
|
1161
|
-
c.header('Cache-Control', 'private, no-store')
|
|
1162
|
-
return c.json(await proxyIdentity(c.req.raw))
|
|
1163
|
-
})
|
|
1164
|
-
|
|
1165
1144
|
// Served from a lazily-refreshed cache: this handler is a memory read, and the
|
|
1166
1145
|
// registry is consulted on the schedule `getCachedUpdateStatus` owns rather
|
|
1167
1146
|
// than once per request. `no-store` keeps the browser from adding a second,
|
package/server/app-config.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
2
|
import { join } from 'path'
|
|
3
3
|
|
|
4
|
-
import type { ClientAppConfig
|
|
5
|
-
import { EXPERIMENTAL_DEFAULTS } from '@/lib/experimental'
|
|
4
|
+
import type { ClientAppConfig } from '@/lib/types'
|
|
6
5
|
|
|
7
6
|
import { DATA_DIR } from './data-dir'
|
|
8
7
|
|
|
@@ -12,37 +11,23 @@ import { DATA_DIR } from './data-dir'
|
|
|
12
11
|
// runtime): config.json describes the deployment itself — nothing here changes
|
|
13
12
|
// without a server restart, and no API writes it.
|
|
14
13
|
//
|
|
15
|
-
// Resolution: defaults < config.json < env.
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// warns on stderr and falls back per-key, so a broken config never takes the
|
|
19
|
-
// CLI or server down with it.
|
|
14
|
+
// Resolution: defaults < config.json < env. A missing file is the normal local
|
|
15
|
+
// case; a malformed file or wrong-typed key warns on stderr and falls back
|
|
16
|
+
// per-key, so a broken config never takes the CLI or server down with it.
|
|
20
17
|
export type AppConfig = {
|
|
21
18
|
// Cloud demo deployment: workspace creation is blocked (UI shows the
|
|
22
19
|
// cloud-demo promo dialog instead) and `moi` system commands are disabled.
|
|
23
20
|
cloudDemo: boolean
|
|
24
|
-
experimental
|
|
21
|
+
// Gated experimental features, checked by slug.
|
|
22
|
+
experiments: string[]
|
|
25
23
|
// Link target for the cloud-demo promo dialog.
|
|
26
24
|
demoInstallUrl: string
|
|
27
|
-
// Cloudflare Access (Zero Trust) in front of this deployment: each viewer
|
|
28
|
-
// inherits the identity from Access's signed token. Null trusts no proxy.
|
|
29
|
-
cloudflareAccess: CloudflareAccessConfig | null
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
export type CloudflareAccessConfig = {
|
|
33
|
-
// Token issuer and signing-key host, e.g. https://acme.cloudflareaccess.com.
|
|
34
|
-
teamDomain: string
|
|
35
|
-
// Application audience (AUD) tags; a token must be issued for one of them.
|
|
36
|
-
audience: readonly string[]
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type DeploymentConfig = Omit<AppConfig, 'experimental'>
|
|
40
|
-
|
|
41
27
|
const DEFAULTS: AppConfig = {
|
|
42
28
|
cloudDemo: false,
|
|
43
|
-
|
|
44
|
-
demoInstallUrl: 'https://moi.computer'
|
|
45
|
-
cloudflareAccess: null
|
|
29
|
+
experiments: [],
|
|
30
|
+
demoInstallUrl: 'https://moi.computer'
|
|
46
31
|
}
|
|
47
32
|
|
|
48
33
|
export const APP_CONFIG_FILE = join(DATA_DIR, 'config.json')
|
|
@@ -61,91 +46,22 @@ function parseBool(raw: string | undefined): boolean | undefined {
|
|
|
61
46
|
return undefined
|
|
62
47
|
}
|
|
63
48
|
|
|
49
|
+
// "a, b,c" → ['a','b','c']; empty entries dropped. An empty string clears the
|
|
50
|
+
// list (explicitly setting MOI_EXPERIMENTS= disables file-set experiments).
|
|
51
|
+
function parseList(raw: string | undefined): string[] | undefined {
|
|
52
|
+
if (raw === undefined) return undefined
|
|
53
|
+
return raw
|
|
54
|
+
.split(',')
|
|
55
|
+
.map(item => item.trim())
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
}
|
|
58
|
+
|
|
64
59
|
function parseString(raw: string | undefined): string | undefined {
|
|
65
60
|
if (raw === undefined || raw.trim() === '') return undefined
|
|
66
61
|
return raw.trim()
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
// origin. Anything with a path, query, or credentials is rejected.
|
|
71
|
-
function parseTeamDomain(raw: string): string | undefined {
|
|
72
|
-
const value = raw.trim()
|
|
73
|
-
if (!value) return undefined
|
|
74
|
-
const host = /^[a-z0-9-]+$/i.test(value) ? `${value}.cloudflareaccess.com` : value
|
|
75
|
-
try {
|
|
76
|
-
const url = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(host) ? host : `https://${host}`)
|
|
77
|
-
if (url.protocol !== 'https:' || url.pathname !== '/' || url.search || url.hash)
|
|
78
|
-
return undefined
|
|
79
|
-
if (url.username || url.password) return undefined
|
|
80
|
-
return url.origin
|
|
81
|
-
} catch {
|
|
82
|
-
return undefined
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// One AUD tag, a comma-separated list, or (in config.json) an array of tags.
|
|
87
|
-
function parseAudience(raw: unknown): string[] | undefined {
|
|
88
|
-
const items = typeof raw === 'string' ? raw.split(',') : raw
|
|
89
|
-
if (!Array.isArray(items) || !items.every(item => typeof item === 'string')) return undefined
|
|
90
|
-
const tags = items.map(item => item.trim()).filter(Boolean)
|
|
91
|
-
return tags.length ? tags : undefined
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function fileCloudflareAccess(value: unknown): Partial<CloudflareAccessConfig> {
|
|
95
|
-
if (value === undefined || value === null) return {}
|
|
96
|
-
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
97
|
-
warn('ignoring "cloudflareAccess" — expected an object')
|
|
98
|
-
return {}
|
|
99
|
-
}
|
|
100
|
-
const { teamDomain, audience } = value as Record<string, unknown>
|
|
101
|
-
const out: Partial<CloudflareAccessConfig> = {}
|
|
102
|
-
if (teamDomain !== undefined) {
|
|
103
|
-
const parsed = typeof teamDomain === 'string' ? parseTeamDomain(teamDomain) : undefined
|
|
104
|
-
if (parsed) out.teamDomain = parsed
|
|
105
|
-
else warn('ignoring "cloudflareAccess.teamDomain" — expected <team>.cloudflareaccess.com')
|
|
106
|
-
}
|
|
107
|
-
if (audience !== undefined) {
|
|
108
|
-
const parsed = parseAudience(audience)
|
|
109
|
-
if (parsed) out.audience = parsed
|
|
110
|
-
else warn('ignoring "cloudflareAccess.audience" — expected an AUD tag or an array of tags')
|
|
111
|
-
}
|
|
112
|
-
return out
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function envCloudflareAccess(
|
|
116
|
-
env: Record<string, string | undefined>
|
|
117
|
-
): Partial<CloudflareAccessConfig> {
|
|
118
|
-
const out: Partial<CloudflareAccessConfig> = {}
|
|
119
|
-
const teamDomain = parseString(env.MOI_CLOUDFLARE_ACCESS_TEAM_DOMAIN)
|
|
120
|
-
if (teamDomain !== undefined) {
|
|
121
|
-
const parsed = parseTeamDomain(teamDomain)
|
|
122
|
-
if (parsed) out.teamDomain = parsed
|
|
123
|
-
else warn('ignoring MOI_CLOUDFLARE_ACCESS_TEAM_DOMAIN — expected <team>.cloudflareaccess.com')
|
|
124
|
-
}
|
|
125
|
-
const audience = parseAudience(parseString(env.MOI_CLOUDFLARE_ACCESS_AUD))
|
|
126
|
-
if (audience) out.audience = audience
|
|
127
|
-
return out
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Per field, env wins over config.json. Verification needs both the issuer and
|
|
131
|
-
// an audience, so half a configuration trusts nothing rather than guessing.
|
|
132
|
-
function resolveCloudflareAccess(
|
|
133
|
-
fileValue: unknown,
|
|
134
|
-
env: Record<string, string | undefined>
|
|
135
|
-
): CloudflareAccessConfig | null {
|
|
136
|
-
const { teamDomain, audience } = {
|
|
137
|
-
...fileCloudflareAccess(fileValue),
|
|
138
|
-
...envCloudflareAccess(env)
|
|
139
|
-
}
|
|
140
|
-
if (!teamDomain && !audience) return null
|
|
141
|
-
if (!teamDomain || !audience) {
|
|
142
|
-
warn('ignoring Cloudflare Access — it needs both a team domain and an audience (AUD) tag')
|
|
143
|
-
return null
|
|
144
|
-
}
|
|
145
|
-
return Object.freeze({ teamDomain, audience: Object.freeze(audience) })
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function readConfigFile(file: string): Record<string, unknown> {
|
|
64
|
+
function fileValues(file: string): Partial<AppConfig> {
|
|
149
65
|
let text: string
|
|
150
66
|
try {
|
|
151
67
|
text = readFileSync(file, 'utf8')
|
|
@@ -171,15 +87,17 @@ function readConfigFile(file: string): Record<string, unknown> {
|
|
|
171
87
|
warn(`ignoring ${file} — expected a JSON object`)
|
|
172
88
|
return {}
|
|
173
89
|
}
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function fileValues(raw: Record<string, unknown>): Partial<DeploymentConfig> {
|
|
178
|
-
const out: Partial<DeploymentConfig> = {}
|
|
90
|
+
const raw = parsed as Record<string, unknown>
|
|
91
|
+
const out: Partial<AppConfig> = {}
|
|
179
92
|
if (raw.cloudDemo !== undefined) {
|
|
180
93
|
if (typeof raw.cloudDemo === 'boolean') out.cloudDemo = raw.cloudDemo
|
|
181
94
|
else warn('ignoring "cloudDemo" — expected a boolean')
|
|
182
95
|
}
|
|
96
|
+
if (raw.experiments !== undefined) {
|
|
97
|
+
if (Array.isArray(raw.experiments) && raw.experiments.every(item => typeof item === 'string')) {
|
|
98
|
+
out.experiments = raw.experiments
|
|
99
|
+
} else warn('ignoring "experiments" — expected an array of strings')
|
|
100
|
+
}
|
|
183
101
|
if (raw.demoInstallUrl !== undefined) {
|
|
184
102
|
if (typeof raw.demoInstallUrl === 'string') out.demoInstallUrl = raw.demoInstallUrl
|
|
185
103
|
else warn('ignoring "demoInstallUrl" — expected a string')
|
|
@@ -190,34 +108,23 @@ function fileValues(raw: Record<string, unknown>): Partial<DeploymentConfig> {
|
|
|
190
108
|
// Pure resolver, exported for tests. `getAppConfig` is the cached entrypoint.
|
|
191
109
|
export function loadAppConfig(
|
|
192
110
|
file: string = APP_CONFIG_FILE,
|
|
193
|
-
env: Record<string, string | undefined> = process.env
|
|
194
|
-
cliExperimental: Partial<ExperimentalFeatures> = {}
|
|
111
|
+
env: Record<string, string | undefined> = process.env
|
|
195
112
|
): AppConfig {
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const fromEnv: Partial<DeploymentConfig> = {
|
|
113
|
+
const fromFile = fileValues(file)
|
|
114
|
+
const fromEnv: Partial<AppConfig> = {
|
|
199
115
|
cloudDemo: parseBool(env.MOI_CLOUD_DEMO),
|
|
116
|
+
experiments: parseList(env.MOI_EXPERIMENTS),
|
|
200
117
|
demoInstallUrl: parseString(env.MOI_DEMO_INSTALL_URL)
|
|
201
118
|
}
|
|
202
119
|
const merged = { ...DEFAULTS, ...fromFile }
|
|
203
|
-
for (const key of Object.keys(fromEnv) as (keyof
|
|
120
|
+
for (const key of Object.keys(fromEnv) as (keyof AppConfig)[]) {
|
|
204
121
|
if (fromEnv[key] === undefined) delete fromEnv[key]
|
|
205
122
|
}
|
|
206
|
-
|
|
207
|
-
const experimental = Object.freeze({
|
|
208
|
-
...DEFAULTS.experimental,
|
|
209
|
-
...cliExperimental
|
|
210
|
-
})
|
|
211
|
-
return Object.freeze({ ...merged, ...fromEnv, cloudflareAccess, experimental })
|
|
123
|
+
return Object.freeze({ ...merged, ...fromEnv })
|
|
212
124
|
}
|
|
213
125
|
|
|
214
126
|
let _config: AppConfig | null = null
|
|
215
127
|
|
|
216
|
-
// The CLI supplies explicit startup flags before importing the web server.
|
|
217
|
-
export function initializeAppConfig(experimental: Partial<ExperimentalFeatures> = {}): void {
|
|
218
|
-
_config = loadAppConfig(undefined, undefined, experimental)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
128
|
export function getAppConfig(): AppConfig {
|
|
222
129
|
_config ??= loadAppConfig()
|
|
223
130
|
return _config
|
|
@@ -232,6 +139,6 @@ export function resetAppConfig(): void {
|
|
|
232
139
|
// The only shape that reaches the browser (GET /api/config). Server-only keys
|
|
233
140
|
// added to AppConfig later stay out unless explicitly forwarded here.
|
|
234
141
|
export function clientAppConfig(): ClientAppConfig {
|
|
235
|
-
const { cloudDemo,
|
|
236
|
-
return { cloudDemo,
|
|
142
|
+
const { cloudDemo, experiments, demoInstallUrl } = getAppConfig()
|
|
143
|
+
return { cloudDemo, experiments: [...experiments], demoInstallUrl }
|
|
237
144
|
}
|
|
@@ -64,13 +64,8 @@ export async function typecheckApplets(
|
|
|
64
64
|
if (files.length === 0) return { files, diagnostics: [] }
|
|
65
65
|
|
|
66
66
|
await writeAppletEnvDts(workspaceRoot)
|
|
67
|
-
const collabTypes = join(moiRoot, 'collab-env.d.ts')
|
|
68
67
|
const program = ts.createProgram({
|
|
69
|
-
rootNames: [
|
|
70
|
-
join(moiRoot, 'applet-env.d.ts'),
|
|
71
|
-
...(existsSync(collabTypes) ? [collabTypes] : []),
|
|
72
|
-
...files
|
|
73
|
-
],
|
|
68
|
+
rootNames: [join(moiRoot, 'applet-env.d.ts'), ...files],
|
|
74
69
|
options: {
|
|
75
70
|
allowImportingTsExtensions: true,
|
|
76
71
|
esModuleInterop: true,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { COLLAB_MODULE_SOURCE } from '../collab/applet-module'
|
|
2
1
|
import type { BunPlugin } from 'bun'
|
|
3
2
|
import tailwind from 'bun-plugin-tailwind'
|
|
4
3
|
import { realpathSync } from 'node:fs'
|
|
@@ -146,15 +145,6 @@ function appletRuntimePlugin(
|
|
|
146
145
|
path: Bun.resolveSync('devalue', import.meta.dir)
|
|
147
146
|
}))
|
|
148
147
|
|
|
149
|
-
// Collaboration forwards to the same host bridge as the applet runtime.
|
|
150
|
-
build.onResolve({ filter: /^moi\/collab$/ }, () => ({
|
|
151
|
-
path: 'moi/collab',
|
|
152
|
-
namespace: 'moi-collab'
|
|
153
|
-
}))
|
|
154
|
-
build.onLoad({ filter: /.*/, namespace: 'moi-collab' }, () => ({
|
|
155
|
-
contents: COLLAB_MODULE_SOURCE,
|
|
156
|
-
loader: 'js'
|
|
157
|
-
}))
|
|
158
148
|
// The applet-facing runtime. A bare specifier, so match it exactly.
|
|
159
149
|
build.onResolve({ filter: /^moi$/ }, () => ({ path: MOI_MODULE_PATH }))
|
|
160
150
|
|
package/server/cli.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { dirname, join, resolve } from 'path'
|
|
|
9
9
|
import pc from './cli-pc'
|
|
10
10
|
|
|
11
11
|
import { isAgentCaller } from './agent-caller'
|
|
12
|
-
import { getAppConfig
|
|
12
|
+
import { getAppConfig } from './app-config'
|
|
13
13
|
|
|
14
14
|
import { appletSelectorMatches, parseAppletSelector } from '@/lib/applet-selector'
|
|
15
15
|
import type { AppletSelector } from '@/lib/applet-selector'
|
|
@@ -23,8 +23,6 @@ import {
|
|
|
23
23
|
} from '@/lib/themes'
|
|
24
24
|
import type { AgentTheme, ColorTheme, FontTheme, RadiusTheme } from '@/lib/themes'
|
|
25
25
|
import { parseMoiHref } from '@/lib/navigation'
|
|
26
|
-
import { EXPERIMENTAL_FEATURES, experimentalFlagName } from '@/lib/experimental'
|
|
27
|
-
import type { ExperimentalFeatures } from '@/lib/experimental'
|
|
28
26
|
import type {
|
|
29
27
|
AppletLogEntry,
|
|
30
28
|
ScratchArrowEnd,
|
|
@@ -47,7 +45,6 @@ import {
|
|
|
47
45
|
resolveCwdWorkspace
|
|
48
46
|
} from './cli-env'
|
|
49
47
|
import { columns, keyValue } from './cli-ui'
|
|
50
|
-
import { installCollabSkill } from './collab/skill'
|
|
51
48
|
import { CONTROL_HOST, CONTROL_PORT, CONTROL_URL, PORT } from './constants'
|
|
52
49
|
import { type ControlProbe, controlFailureMessage, probeControlServer } from './control-client'
|
|
53
50
|
import {
|
|
@@ -160,19 +157,14 @@ async function openBrowser(url: string) {
|
|
|
160
157
|
// (see runDevSupervisor).
|
|
161
158
|
function spawnServer(
|
|
162
159
|
cwd: string,
|
|
163
|
-
env: Record<string, string | undefined> = process.env
|
|
164
|
-
experimentalFlags: string[] = []
|
|
160
|
+
env: Record<string, string | undefined> = process.env
|
|
165
161
|
): ReturnType<typeof Bun.spawn> {
|
|
166
|
-
|
|
167
|
-
return Bun.spawn(argv, {
|
|
162
|
+
return Bun.spawn(['bun', import.meta.filename, 'start'], {
|
|
168
163
|
stdin: 'inherit',
|
|
169
164
|
stdout: 'inherit',
|
|
170
165
|
stderr: 'inherit',
|
|
171
166
|
cwd,
|
|
172
|
-
env: {
|
|
173
|
-
...env,
|
|
174
|
-
MOI_SERVER: '1'
|
|
175
|
-
}
|
|
167
|
+
env: { ...env, MOI_SERVER: '1' }
|
|
176
168
|
})
|
|
177
169
|
}
|
|
178
170
|
|
|
@@ -183,12 +175,11 @@ function spawnServer(
|
|
|
183
175
|
// (closing servers + killing function workers), so restarts leak nothing.
|
|
184
176
|
async function runDevSupervisor(
|
|
185
177
|
projectRoot: string,
|
|
186
|
-
env: Record<string, string | undefined
|
|
187
|
-
experimentalFlags: string[]
|
|
178
|
+
env: Record<string, string | undefined>
|
|
188
179
|
): Promise<void> {
|
|
189
180
|
const { watch } = await import('node:fs')
|
|
190
181
|
|
|
191
|
-
let child = spawnServer(projectRoot, env
|
|
182
|
+
let child = spawnServer(projectRoot, env)
|
|
192
183
|
let restarting = false
|
|
193
184
|
let debounce: ReturnType<typeof setTimeout> | undefined
|
|
194
185
|
|
|
@@ -207,7 +198,7 @@ async function runDevSupervisor(
|
|
|
207
198
|
await child.exited
|
|
208
199
|
clearTimeout(sigkill)
|
|
209
200
|
restarting = false
|
|
210
|
-
child = spawnServer(projectRoot, env
|
|
201
|
+
child = spawnServer(projectRoot, env)
|
|
211
202
|
}
|
|
212
203
|
|
|
213
204
|
for (const dir of ['server', 'lib']) {
|
|
@@ -343,11 +334,6 @@ const init = defineCommand({
|
|
|
343
334
|
default: false,
|
|
344
335
|
description: 'Start the web server if not already running'
|
|
345
336
|
},
|
|
346
|
-
'experimental-collab': {
|
|
347
|
-
type: 'boolean',
|
|
348
|
-
default: false,
|
|
349
|
-
description: 'Include the optional collaboration guide and applet types'
|
|
350
|
-
},
|
|
351
337
|
id: {
|
|
352
338
|
type: 'string',
|
|
353
339
|
description:
|
|
@@ -410,11 +396,6 @@ const init = defineCommand({
|
|
|
410
396
|
// package.json + bun install). An existing `.moi/` is left untouched.
|
|
411
397
|
console.log()
|
|
412
398
|
const { scaffold, skillsDir } = await provisionWorkspace(target, type)
|
|
413
|
-
if (args['experimental-collab']) {
|
|
414
|
-
const { referencePath } = await installCollabSkill(target, type)
|
|
415
|
-
console.log(pc.dim(' Collaboration guide installed to ' + referencePath))
|
|
416
|
-
console.log(pc.dim(' Live presence requires moi start --experimental-collab'))
|
|
417
|
-
}
|
|
418
399
|
if (scaffold !== 'exists') {
|
|
419
400
|
if (scaffold === 'installing') {
|
|
420
401
|
console.log(pc.dim(' Widget dependencies still installing in .moi/ (background)'))
|
|
@@ -487,38 +468,15 @@ const init = defineCommand({
|
|
|
487
468
|
}
|
|
488
469
|
})
|
|
489
470
|
|
|
490
|
-
const experimentalArgs = Object.fromEntries(
|
|
491
|
-
EXPERIMENTAL_FEATURES.map(feature => {
|
|
492
|
-
const name = experimentalFlagName(feature)
|
|
493
|
-
const label = name.slice('experimental-'.length).replaceAll('-', ' ')
|
|
494
|
-
return [name, { type: 'boolean' as const, description: `Enable experimental ${label}` }]
|
|
495
|
-
})
|
|
496
|
-
)
|
|
497
|
-
|
|
498
471
|
const start = defineCommand({
|
|
499
472
|
meta: { name: 'start', description: 'Start the moi web server' },
|
|
500
473
|
args: {
|
|
501
474
|
port: {
|
|
502
475
|
type: 'string',
|
|
503
476
|
description: 'HTTP port to listen on (default: 13337)'
|
|
504
|
-
},
|
|
505
|
-
...experimentalArgs
|
|
506
|
-
},
|
|
507
|
-
async run({ args, rawArgs }) {
|
|
508
|
-
const knownFlags = new Set(EXPERIMENTAL_FEATURES.map(experimentalFlagName))
|
|
509
|
-
for (const arg of rawArgs) {
|
|
510
|
-
if (arg.startsWith('--experimental-') && !knownFlags.has(arg.slice(2))) {
|
|
511
|
-
throw new Error(`Unknown experimental feature: ${arg.slice('--experimental-'.length)}`)
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
const experimental: Partial<ExperimentalFeatures> = {}
|
|
515
|
-
const experimentalFlags: string[] = []
|
|
516
|
-
for (const feature of EXPERIMENTAL_FEATURES) {
|
|
517
|
-
const flag = experimentalFlagName(feature)
|
|
518
|
-
if (args[flag] !== true) continue
|
|
519
|
-
experimental[feature] = true
|
|
520
|
-
experimentalFlags.push(`--${flag}`)
|
|
521
477
|
}
|
|
478
|
+
},
|
|
479
|
+
async run({ args }) {
|
|
522
480
|
const projectRoot = join(import.meta.dir, '..')
|
|
523
481
|
// Undocumented: --dev runs the watch-and-full-restart dev supervisor.
|
|
524
482
|
const dev = process.argv.includes('--dev')
|
|
@@ -571,20 +529,17 @@ const start = defineCommand({
|
|
|
571
529
|
...(debug ? { MOI_DEBUG: '1' } : {})
|
|
572
530
|
}
|
|
573
531
|
if (dev) {
|
|
574
|
-
await runDevSupervisor(projectRoot, env
|
|
532
|
+
await runDevSupervisor(projectRoot, env)
|
|
575
533
|
return
|
|
576
534
|
}
|
|
577
535
|
const cwd = serverCwd(projectRoot, dev)
|
|
578
|
-
const proc = spawnServer(cwd, env
|
|
579
|
-
process.exit(
|
|
580
|
-
await superviseServerUpdates(proc, () => spawnServer(cwd, env, experimentalFlags))
|
|
581
|
-
)
|
|
536
|
+
const proc = spawnServer(cwd, env)
|
|
537
|
+
process.exit(await superviseServerUpdates(proc, () => spawnServer(cwd, env)))
|
|
582
538
|
}
|
|
583
539
|
|
|
584
540
|
// This IS the server process (MOI_SERVER=1). cwd is the package root when the
|
|
585
541
|
// dev bundler runs (bunfig loaded at Bun startup) or a neutral dir for a
|
|
586
542
|
// prebuilt install — see serverCwd().
|
|
587
|
-
initializeAppConfig(experimental)
|
|
588
543
|
try {
|
|
589
544
|
await import('./web')
|
|
590
545
|
} catch (err) {
|
package/server/layout.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
AppletKind,
|
|
5
|
-
WorkspaceLayout,
|
|
6
|
-
WorkspaceLayoutSave,
|
|
7
|
-
WorkspacePreview
|
|
8
|
-
} from '@/lib/types'
|
|
3
|
+
import type { AppletKind, WorkspaceLayout, WorkspacePreview } from '@/lib/types'
|
|
9
4
|
import { createDefaultWorkspaceLayout, normalizeWorkspaceTabs } from '@/lib/workspace-layout'
|
|
10
5
|
import { isWorkspaceIcon } from '@/lib/workspace-icon'
|
|
11
6
|
|
|
@@ -18,9 +13,6 @@ function normalizeLayout(parsed: Record<string, unknown>): WorkspaceLayout {
|
|
|
18
13
|
layout.layoutMode = defaults.layoutMode
|
|
19
14
|
}
|
|
20
15
|
layout.tabs = normalizeWorkspaceTabs(layout.tabs)
|
|
21
|
-
delete layout.experimental
|
|
22
|
-
delete layout.collab
|
|
23
|
-
delete layout.collabReference
|
|
24
16
|
if (typeof layout.icon === 'string') {
|
|
25
17
|
layout.icon = { type: 'upload', value: layout.icon }
|
|
26
18
|
} else if (layout.icon !== undefined && !isWorkspaceIcon(layout.icon)) {
|
|
@@ -67,20 +59,15 @@ export async function saveLayout(layout: WorkspaceLayout, workspacePath: string)
|
|
|
67
59
|
// as `name: undefined`.
|
|
68
60
|
export function mergeLayoutForSave(
|
|
69
61
|
existing: WorkspaceLayout,
|
|
70
|
-
body:
|
|
62
|
+
body: WorkspaceLayout
|
|
71
63
|
): WorkspaceLayout {
|
|
72
64
|
const { name: _name, icon: _icon, ...editor } = body
|
|
73
|
-
delete (editor as Record<string, unknown>).experimental
|
|
74
|
-
delete (editor as Record<string, unknown>).collab
|
|
75
|
-
delete (editor as Record<string, unknown>).collabReference
|
|
76
65
|
// Stale clients may still round-trip the pre-`.cache` thumbnail records;
|
|
77
66
|
// never let a layout PUT resurrect them in `.workspace.json`.
|
|
78
67
|
delete (editor as Record<string, unknown>).appletThumbnails
|
|
79
68
|
return {
|
|
80
69
|
...editor,
|
|
81
|
-
|
|
82
|
-
// round-trip a stale copy of the workspace's authored defaults.
|
|
83
|
-
tabs: editor.tabs === undefined ? existing.tabs : normalizeWorkspaceTabs(editor.tabs),
|
|
70
|
+
tabs: normalizeWorkspaceTabs(editor.tabs),
|
|
84
71
|
...(existing.name !== undefined && { name: existing.name }),
|
|
85
72
|
...(existing.icon !== undefined && { icon: existing.icon })
|
|
86
73
|
}
|
|
@@ -14,18 +14,6 @@ export const TEMPLATE_DIR = join(import.meta.dir, '..', 'workspace')
|
|
|
14
14
|
// for what `moi skill update` copies and what versions it compares against.
|
|
15
15
|
export const BUNDLED_SKILLS_DIR = join(TEMPLATE_DIR, '.claude', 'skills')
|
|
16
16
|
|
|
17
|
-
export const COLLAB_REFERENCE_SOURCE_PATH = join(
|
|
18
|
-
BUNDLED_SKILLS_DIR,
|
|
19
|
-
'moi-workspace',
|
|
20
|
-
'references',
|
|
21
|
-
'COLLABORATIVE.md'
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
// The guide lives beside the other references, but only explicit collab init installs it.
|
|
25
|
-
function isDefaultSkillFile(source: string): boolean {
|
|
26
|
-
return source !== COLLAB_REFERENCE_SOURCE_PATH
|
|
27
|
-
}
|
|
28
|
-
|
|
29
17
|
async function matchesBundledPath(source: string, target: string): Promise<boolean> {
|
|
30
18
|
const sourceStat = await lstat(source)
|
|
31
19
|
const targetStat = await lstat(target).catch(() => null)
|
|
@@ -33,7 +21,7 @@ async function matchesBundledPath(source: string, target: string): Promise<boole
|
|
|
33
21
|
|
|
34
22
|
if (sourceStat.isDirectory()) {
|
|
35
23
|
if (!targetStat.isDirectory()) return false
|
|
36
|
-
const entries =
|
|
24
|
+
const entries = await readdir(source)
|
|
37
25
|
const matches = await Promise.all(
|
|
38
26
|
entries.map(entry => matchesBundledPath(join(source, entry), join(target, entry)))
|
|
39
27
|
)
|
|
@@ -74,7 +62,7 @@ export async function installBundledSkills(targetSkillsDir: string): Promise<str
|
|
|
74
62
|
const target = join(targetSkillsDir, entry.name)
|
|
75
63
|
if (await matchesBundledPath(source, target)) continue
|
|
76
64
|
|
|
77
|
-
await cp(source, target, { recursive: true, force: true
|
|
65
|
+
await cp(source, target, { recursive: true, force: true })
|
|
78
66
|
changedSkills.push(entry.name)
|
|
79
67
|
}
|
|
80
68
|
|