moi-computer 0.5.2-next.1 → 0.6.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 +39 -0
- package/client/AGENTS.md +9 -0
- package/client/api/app-ui-keys.ts +4 -0
- package/client/api/workspace-keys.ts +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +8 -28
- package/client/components/shared/Composer.tsx +3 -6
- package/client/components/shared/IconGhost.tsx +130 -0
- package/client/components/ui/dropdown-menu.tsx +1 -1
- package/client/components/ui/spinner.tsx +18 -0
- package/client/components/ui/toast.tsx +220 -0
- package/client/features/chat/ChatComposer.tsx +3 -2
- package/client/features/chat/ChatPanel.tsx +7 -6
- package/client/features/chat/ChatPopup.tsx +10 -4
- package/client/features/chat/ChatSelector.tsx +263 -48
- package/client/features/chat/ModelPicker.tsx +13 -18
- package/client/features/chat/api.ts +36 -9
- package/client/features/chat/chat-frames.ts +35 -6
- package/client/features/chat/chat-send.ts +25 -1
- package/client/features/chat/chat-store.ts +43 -18
- package/client/features/chat/useChat.ts +54 -52
- package/client/features/chat/useSelectedSession.ts +151 -0
- package/client/features/chat/useStickToBottom.ts +3 -3
- package/client/features/home/api.ts +0 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +6 -6
- package/client/features/views/ViewBuilderTab.tsx +3 -4
- package/client/features/views/useViewBuilderActions.ts +3 -1
- package/client/features/workspace/WorkspaceScreen.tsx +38 -17
- package/client/features/workspace/WorkspaceTabs.tsx +10 -1
- package/client/main.tsx +2 -0
- package/client/runtime/useWorkspaceEvents.ts +1 -0
- package/client/store/ui.ts +2 -2
- package/dist/{chunk-zs4mte79.js → chunk-0pcdwjkp.js} +1 -1
- package/dist/chunk-175bm057.js +27 -0
- package/dist/chunk-55sh4dty.js +2 -0
- package/dist/{chunk-tzz101ea.js → chunk-9y2zbzqz.js} +1 -1
- package/dist/{chunk-jvhvme3z.js → chunk-afgbg75t.js} +1 -1
- package/dist/chunk-agtetn7n.css +1 -0
- package/dist/chunk-dfs36zgc.js +1 -0
- package/dist/chunk-exj6hr30.js +9 -0
- package/dist/{chunk-bcrkdhwe.js → chunk-m11ckkxd.js} +1 -1
- package/dist/{chunk-kfw1qwqe.js → chunk-rxvx4ta9.js} +3 -3
- package/dist/{chunk-xwhya7kb.js → chunk-w3tnv51j.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/attachment-note.ts +18 -0
- package/lib/chat-title.ts +6 -0
- package/lib/types.ts +24 -10
- package/package.json +1 -1
- package/server/agent-caller.ts +16 -0
- package/server/api.ts +90 -9
- package/server/app-settings.ts +1 -1
- package/server/cli.ts +628 -45
- package/server/control.ts +18 -1
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +6 -0
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/session-title.ts +106 -0
- package/server/harness/claude-code/session.ts +107 -17
- package/server/harness/claude-code/sessions.ts +63 -4
- package/server/harness/codex/client.ts +33 -13
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/session-title.ts +149 -0
- package/server/harness/codex/session.ts +84 -11
- package/server/harness/openclaw/adapter.ts +4 -2
- package/server/harness/openclaw/discovery.ts +2 -0
- package/server/harness/openclaw/session.ts +15 -7
- package/server/harness/session-title.ts +96 -0
- package/server/harness/types.ts +2 -0
- package/server/selected-session.ts +132 -0
- package/server/service.ts +786 -0
- package/server/{thread-config.ts → session-config.ts} +57 -39
- package/server/status.ts +2 -0
- package/server/update.ts +141 -0
- package/server/version.ts +41 -0
- package/server/web.ts +17 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +16 -26
- package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
- package/dist/chunk-94m3q9ce.js +0 -1
- package/dist/chunk-k9dcnd73.js +0 -27
- package/dist/chunk-pk11vfzs.js +0 -9
- package/dist/chunk-r2bqaege.js +0 -2
- package/dist/chunk-y4g8j7mv.css +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { mkdir, rename } from 'node:fs/promises'
|
|
1
|
+
import { mkdir, rename, rm } from 'node:fs/promises'
|
|
2
2
|
import { join } from 'path'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { SessionConfig } from '@/lib/types'
|
|
5
5
|
|
|
6
6
|
import { DATA_DIR } from './data-dir'
|
|
7
7
|
|
|
8
|
-
// Per-
|
|
8
|
+
// Per-session model/effort/Fast-mode overrides. Stored OUTSIDE
|
|
9
9
|
// the user's workspace (no repo churn) in ONE global JSON file in moi's data
|
|
10
10
|
// dir, alongside the workspace registry. Keyed by workspace path then sessionId:
|
|
11
11
|
// { "<workspacePath>": { "<sessionId>": { model?, effort?, fastMode? } } }
|
|
@@ -13,47 +13,63 @@ import { DATA_DIR } from './data-dir'
|
|
|
13
13
|
// up with the SDK's path-based session storage.
|
|
14
14
|
|
|
15
15
|
// A patch may clear a field with `null` (vs `undefined`, which leaves it alone).
|
|
16
|
-
export type
|
|
16
|
+
export type SessionConfigPatch = {
|
|
17
17
|
model?: string | null
|
|
18
18
|
effort?: string | null
|
|
19
19
|
fastMode?: boolean | null
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
type Store = Record<string, Record<string,
|
|
22
|
+
type Store = Record<string, Record<string, SessionConfig>>
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
export const DEFAULT_SESSION_CONFIG_PATH = join(DATA_DIR, 'session-config.json')
|
|
25
|
+
export const LEGACY_SESSION_CONFIG_PATH = join(DATA_DIR, 'thread-config.json')
|
|
26
|
+
|
|
27
|
+
let storePath = DEFAULT_SESSION_CONFIG_PATH
|
|
28
|
+
let legacyStorePath = LEGACY_SESSION_CONFIG_PATH
|
|
25
29
|
|
|
26
30
|
// Test seam: point the store at a scratch file (mirrors registry.setRegistryPath).
|
|
27
|
-
export function
|
|
28
|
-
|
|
31
|
+
export function setSessionConfigPath(path: string, legacyPath?: string): void {
|
|
32
|
+
storePath = path
|
|
33
|
+
legacyStorePath = legacyPath ?? join(path, '..', 'thread-config.json')
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
function clean(cfg:
|
|
32
|
-
const out:
|
|
36
|
+
function clean(cfg: SessionConfig | undefined): SessionConfig {
|
|
37
|
+
const out: SessionConfig = {}
|
|
33
38
|
if (typeof cfg?.model === 'string') out.model = cfg.model
|
|
34
39
|
if (typeof cfg?.effort === 'string') out.effort = cfg.effort
|
|
35
40
|
if (typeof cfg?.fastMode === 'boolean') out.fastMode = cfg.fastMode
|
|
36
41
|
return out
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
function isEmpty(cfg:
|
|
44
|
+
function isEmpty(cfg: SessionConfig): boolean {
|
|
40
45
|
return cfg.model === undefined && cfg.effort === undefined && cfg.fastMode === undefined
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
async function
|
|
48
|
+
async function readStoreFile(path: string): Promise<Store | null> {
|
|
44
49
|
try {
|
|
45
|
-
const parsed = JSON.parse(await Bun.file(
|
|
50
|
+
const parsed = JSON.parse(await Bun.file(path).text())
|
|
46
51
|
return parsed && typeof parsed === 'object' ? (parsed as Store) : {}
|
|
47
52
|
} catch {
|
|
48
|
-
return
|
|
53
|
+
return null
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
async function writeStore(store: Store): Promise<void> {
|
|
53
|
-
await mkdir(join(
|
|
54
|
-
const tmp = `${
|
|
58
|
+
await mkdir(join(storePath, '..'), { recursive: true })
|
|
59
|
+
const tmp = `${storePath}.${process.pid}.tmp`
|
|
55
60
|
await Bun.write(tmp, JSON.stringify(store, null, 2))
|
|
56
|
-
await rename(tmp,
|
|
61
|
+
await rename(tmp, storePath)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function readStore(): Promise<Store> {
|
|
65
|
+
const current = await readStoreFile(storePath)
|
|
66
|
+
if (current) return current
|
|
67
|
+
|
|
68
|
+
const legacy = await readStoreFile(legacyStorePath)
|
|
69
|
+
if (!legacy) return {}
|
|
70
|
+
await writeStore(legacy)
|
|
71
|
+
await rm(legacyStorePath, { force: true })
|
|
72
|
+
return legacy
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
// Serialize read-modify-write so concurrent save/rename calls can't clobber the
|
|
@@ -65,30 +81,32 @@ function locked<T>(fn: () => Promise<T>): Promise<T> {
|
|
|
65
81
|
return run
|
|
66
82
|
}
|
|
67
83
|
|
|
68
|
-
export async function
|
|
84
|
+
export async function getSessionConfig(
|
|
69
85
|
workspacePath: string,
|
|
70
86
|
sessionId: string
|
|
71
|
-
): Promise<
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
): Promise<SessionConfig> {
|
|
88
|
+
return locked(async () => {
|
|
89
|
+
const store = await readStore()
|
|
90
|
+
return clean(store[workspacePath]?.[sessionId])
|
|
91
|
+
})
|
|
74
92
|
}
|
|
75
93
|
|
|
76
|
-
export async function
|
|
77
|
-
return !isEmpty(await
|
|
94
|
+
export async function hasSessionConfig(workspacePath: string, sessionId: string): Promise<boolean> {
|
|
95
|
+
return !isEmpty(await getSessionConfig(workspacePath, sessionId))
|
|
78
96
|
}
|
|
79
97
|
|
|
80
98
|
// Merge a patch over the stored config and write it back. `null` clears a field,
|
|
81
99
|
// `undefined` leaves it untouched, and a typed value sets it. An emptied entry
|
|
82
100
|
// is dropped to keep the file tidy. Returns the merged config.
|
|
83
|
-
export async function
|
|
101
|
+
export async function saveSessionConfig(
|
|
84
102
|
workspacePath: string,
|
|
85
103
|
sessionId: string,
|
|
86
|
-
patch:
|
|
87
|
-
): Promise<
|
|
104
|
+
patch: SessionConfigPatch
|
|
105
|
+
): Promise<SessionConfig> {
|
|
88
106
|
return locked(async () => {
|
|
89
107
|
const store = await readStore()
|
|
90
|
-
const
|
|
91
|
-
const next = clean(
|
|
108
|
+
const sessions = store[workspacePath] ?? {}
|
|
109
|
+
const next = clean(sessions[sessionId])
|
|
92
110
|
for (const key of ['model', 'effort'] as const) {
|
|
93
111
|
const value = patch[key]
|
|
94
112
|
if (value === undefined) continue
|
|
@@ -97,19 +115,19 @@ export async function saveThreadConfig(
|
|
|
97
115
|
}
|
|
98
116
|
if (patch.fastMode === null) delete next.fastMode
|
|
99
117
|
else if (patch.fastMode !== undefined) next.fastMode = patch.fastMode
|
|
100
|
-
if (isEmpty(next)) delete
|
|
101
|
-
else
|
|
102
|
-
if (Object.keys(
|
|
103
|
-
else store[workspacePath] =
|
|
118
|
+
if (isEmpty(next)) delete sessions[sessionId]
|
|
119
|
+
else sessions[sessionId] = next
|
|
120
|
+
if (Object.keys(sessions).length === 0) delete store[workspacePath]
|
|
121
|
+
else store[workspacePath] = sessions
|
|
104
122
|
await writeStore(store)
|
|
105
123
|
return next
|
|
106
124
|
})
|
|
107
125
|
}
|
|
108
126
|
|
|
109
|
-
// Move a
|
|
127
|
+
// Move a session's config from one id to another (temp id → SDK real id on
|
|
110
128
|
// rename). Merges onto whatever the destination already holds (destination wins,
|
|
111
129
|
// so a concurrent write under the real id isn't lost) and removes the source.
|
|
112
|
-
export async function
|
|
130
|
+
export async function renameSessionConfig(
|
|
113
131
|
workspacePath: string,
|
|
114
132
|
from: string,
|
|
115
133
|
to: string
|
|
@@ -117,12 +135,12 @@ export async function renameThreadConfig(
|
|
|
117
135
|
if (from === to) return
|
|
118
136
|
await locked(async () => {
|
|
119
137
|
const store = await readStore()
|
|
120
|
-
const
|
|
121
|
-
const src = clean(
|
|
138
|
+
const sessions = store[workspacePath]
|
|
139
|
+
const src = clean(sessions?.[from])
|
|
122
140
|
if (isEmpty(src)) return
|
|
123
|
-
|
|
124
|
-
delete
|
|
125
|
-
store[workspacePath] =
|
|
141
|
+
sessions![to] = { ...src, ...clean(sessions![to]) }
|
|
142
|
+
delete sessions![from]
|
|
143
|
+
store[workspacePath] = sessions!
|
|
126
144
|
await writeStore(store)
|
|
127
145
|
})
|
|
128
146
|
}
|
package/server/status.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { WORKER_LIMITS, type WorkerDebugInfo, getWorkersDebugSnapshot } from './
|
|
|
11
11
|
import { allHarnesses } from './harness/registry'
|
|
12
12
|
import { tildify } from './registry'
|
|
13
13
|
import { getClientCount } from './state'
|
|
14
|
+
import { VERSION } from './version'
|
|
14
15
|
|
|
15
16
|
const STARTED_AT = Date.now()
|
|
16
17
|
|
|
@@ -70,6 +71,7 @@ export function renderStatus(): string {
|
|
|
70
71
|
lines.push('moi server status')
|
|
71
72
|
lines.push('=================')
|
|
72
73
|
lines.push('')
|
|
74
|
+
lines.push(`version ${VERSION}${process.env.MOI_SERVICE ? ' (service-managed)' : ''}`)
|
|
73
75
|
lines.push(`uptime ${fmtDuration(now - STARTED_AT)}`)
|
|
74
76
|
lines.push(`http port ${PORT}`)
|
|
75
77
|
lines.push(`control port ${CONTROL_PORT}`)
|
package/server/update.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// `moi update` mechanics: check the npm registry for the latest published
|
|
2
|
+
// version, find the package manager that owns the current global install, and
|
|
3
|
+
// update through it — never around it, so no second shadowing install appears.
|
|
4
|
+
// Manual command only; nothing here runs in the background.
|
|
5
|
+
import { realpathSync } from 'node:fs'
|
|
6
|
+
|
|
7
|
+
import { PACKAGE_ROOT } from './version'
|
|
8
|
+
|
|
9
|
+
export const PACKAGE_NAME = 'moi-computer'
|
|
10
|
+
|
|
11
|
+
// Test seam: point at a local mock registry (`MOI_NPM_REGISTRY`).
|
|
12
|
+
function registryBase(): string {
|
|
13
|
+
return (process.env.MOI_NPM_REGISTRY || 'https://registry.npmjs.org').replace(/\/$/, '')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Resolve the `latest` dist-tag. Throws with a friendly message on network or
|
|
17
|
+
// registry trouble — the CLI shows it verbatim.
|
|
18
|
+
export async function fetchLatestVersion(pkg = PACKAGE_NAME): Promise<string> {
|
|
19
|
+
const url = `${registryBase()}/${pkg}/latest`
|
|
20
|
+
let res: Response
|
|
21
|
+
try {
|
|
22
|
+
res = await fetch(url, { signal: AbortSignal.timeout(10_000) })
|
|
23
|
+
} catch {
|
|
24
|
+
throw new Error(`Could not reach the npm registry (${registryBase()}) — check your network.`)
|
|
25
|
+
}
|
|
26
|
+
if (!res.ok) {
|
|
27
|
+
throw new Error(`npm registry returned ${res.status} for ${pkg} — try again later.`)
|
|
28
|
+
}
|
|
29
|
+
const data = (await res.json().catch(() => null)) as { version?: unknown } | null
|
|
30
|
+
if (!data || typeof data.version !== 'string') {
|
|
31
|
+
throw new Error('Unexpected npm registry response — try again later.')
|
|
32
|
+
}
|
|
33
|
+
return data.version
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// `Bun.semver.order` handles prerelease precedence correctly
|
|
37
|
+
// (0.5.2-next.1 < 0.5.2).
|
|
38
|
+
export function isNewer(candidate: string, current: string): boolean {
|
|
39
|
+
try {
|
|
40
|
+
return Bun.semver.order(candidate, current) === 1
|
|
41
|
+
} catch {
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ---- owning package manager -------------------------------------------------
|
|
47
|
+
|
|
48
|
+
export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'
|
|
49
|
+
|
|
50
|
+
// Where each manager keeps its global tree leaves a recognizable path
|
|
51
|
+
// signature; npm's prefix is freeform, so it gets confirmed by asking npm
|
|
52
|
+
// itself (only when nothing else matched — `npm root -g` costs a process).
|
|
53
|
+
export async function detectPackageManager(
|
|
54
|
+
installRoot: string = safeRealpath(PACKAGE_ROOT),
|
|
55
|
+
npmRootDir: () => Promise<string | null> = defaultNpmRootDir
|
|
56
|
+
): Promise<PackageManager | null> {
|
|
57
|
+
const root = installRoot.replaceAll('\\', '/')
|
|
58
|
+
if (root.includes('/.bun/')) return 'bun'
|
|
59
|
+
if (root.includes('/.pnpm/') || root.includes('/pnpm/')) return 'pnpm'
|
|
60
|
+
if (root.includes('/.yarn/') || root.includes('/yarn/')) return 'yarn'
|
|
61
|
+
const npmRoot = await npmRootDir()
|
|
62
|
+
if (npmRoot && root.startsWith(npmRoot.replaceAll('\\', '/').replace(/\/$/, '') + '/')) {
|
|
63
|
+
return 'npm'
|
|
64
|
+
}
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function safeRealpath(path: string): string {
|
|
69
|
+
try {
|
|
70
|
+
return realpathSync(path)
|
|
71
|
+
} catch {
|
|
72
|
+
return path
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function defaultNpmRootDir(): Promise<string | null> {
|
|
77
|
+
try {
|
|
78
|
+
const proc = Bun.spawn(['npm', 'root', '-g'], {
|
|
79
|
+
stdin: 'ignore',
|
|
80
|
+
stdout: 'pipe',
|
|
81
|
+
stderr: 'ignore'
|
|
82
|
+
})
|
|
83
|
+
const [code, out] = await Promise.all([proc.exited, new Response(proc.stdout).text()])
|
|
84
|
+
if (code !== 0) return null
|
|
85
|
+
const dir = out.trim()
|
|
86
|
+
return dir ? safeRealpath(dir) : null
|
|
87
|
+
} catch {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// The exact global-install command per manager, pinned to the resolved version
|
|
93
|
+
// so the install matches what the check reported.
|
|
94
|
+
export function updateArgv(pm: PackageManager, version: string): string[] {
|
|
95
|
+
const spec = `${PACKAGE_NAME}@${version}`
|
|
96
|
+
switch (pm) {
|
|
97
|
+
case 'bun':
|
|
98
|
+
return ['bun', 'install', '-g', spec]
|
|
99
|
+
case 'npm':
|
|
100
|
+
return ['npm', 'install', '-g', spec]
|
|
101
|
+
case 'pnpm':
|
|
102
|
+
return ['pnpm', 'add', '-g', spec]
|
|
103
|
+
case 'yarn':
|
|
104
|
+
return ['yarn', 'global', 'add', spec]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// One manual line per manager, for when detection comes up empty.
|
|
109
|
+
export function manualUpdateLines(version: string): string[] {
|
|
110
|
+
return (['bun', 'npm', 'pnpm', 'yarn'] as const).map(pm => updateArgv(pm, version).join(' '))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Run the owning package manager with live output (the user watches their own
|
|
114
|
+
// tool do the work). Returns the exit code.
|
|
115
|
+
export async function runPackageManager(argv: string[]): Promise<number> {
|
|
116
|
+
try {
|
|
117
|
+
const proc = Bun.spawn(argv, { stdin: 'ignore', stdout: 'inherit', stderr: 'inherit' })
|
|
118
|
+
return await proc.exited
|
|
119
|
+
} catch {
|
|
120
|
+
return 127
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Ask the freshly-updated install what version it is now, through the same bin
|
|
125
|
+
// users run — catching both a failed install and a PATH that resolves to some
|
|
126
|
+
// other, shadowing install.
|
|
127
|
+
export async function installedBinVersion(bin: string): Promise<string | null> {
|
|
128
|
+
try {
|
|
129
|
+
const proc = Bun.spawn([bin, 'version'], {
|
|
130
|
+
stdin: 'ignore',
|
|
131
|
+
stdout: 'pipe',
|
|
132
|
+
stderr: 'ignore'
|
|
133
|
+
})
|
|
134
|
+
const [code, out] = await Promise.all([proc.exited, new Response(proc.stdout).text()])
|
|
135
|
+
if (code !== 0) return null
|
|
136
|
+
const m = out.trim().match(/^(\S+)/)
|
|
137
|
+
return m ? m[1] : null
|
|
138
|
+
} catch {
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
|
|
4
|
+
// The package root of the code that is actually running — server and CLI both
|
|
5
|
+
// resolve their own tree, so a CLI from one install never reports another's
|
|
6
|
+
// version.
|
|
7
|
+
export const PACKAGE_ROOT = join(import.meta.dir, '..')
|
|
8
|
+
|
|
9
|
+
function readPackageVersion(): string {
|
|
10
|
+
try {
|
|
11
|
+
const pkg = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8')) as {
|
|
12
|
+
version?: string
|
|
13
|
+
}
|
|
14
|
+
if (typeof pkg.version === 'string') return pkg.version
|
|
15
|
+
} catch {}
|
|
16
|
+
return '0.0.0'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Snapshotted at module load, deliberately: after `bun i -g` swaps the install
|
|
20
|
+
// tree under a running server, the server must keep reporting the version of
|
|
21
|
+
// the code it loaded — reading package.json lazily would claim the new version
|
|
22
|
+
// while old code runs (and under pnpm the old realpath may not even exist).
|
|
23
|
+
export const VERSION = readPackageVersion()
|
|
24
|
+
|
|
25
|
+
// True for a prerelease like `0.5.2-next.1` — those are published to a dist-tag
|
|
26
|
+
// other than `latest`, so `moi update` leaves them alone.
|
|
27
|
+
export function isPrerelease(version: string): boolean {
|
|
28
|
+
return version.includes('-')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// `<package version> (<8-char commit>)`, e.g. `0.1.3 (27e17e80)`. The commit is
|
|
32
|
+
// read from git at call time, so it appears for a source/`bun link` checkout and
|
|
33
|
+
// is simply omitted for a published package (which ships no .git).
|
|
34
|
+
export function versionWithCommit(): string {
|
|
35
|
+
let commit = ''
|
|
36
|
+
try {
|
|
37
|
+
const out = Bun.spawnSync(['git', 'rev-parse', '--short=8', 'HEAD'], { cwd: PACKAGE_ROOT })
|
|
38
|
+
if (out.success) commit = out.stdout.toString().trim()
|
|
39
|
+
} catch {}
|
|
40
|
+
return commit ? `${VERSION} (${commit})` : VERSION
|
|
41
|
+
}
|
package/server/web.ts
CHANGED
|
@@ -5,13 +5,15 @@ import index from '../client/index.html'
|
|
|
5
5
|
import { api } from './api'
|
|
6
6
|
import { PORT } from './constants'
|
|
7
7
|
import { control } from './control'
|
|
8
|
-
import { EVENTS_TOPIC, setEventServer } from './events'
|
|
8
|
+
import { EVENTS_TOPIC, publishEvent, setEventServer } from './events'
|
|
9
9
|
import { killAllWorkers } from './functions'
|
|
10
10
|
import { startScratchpadSweeper } from './scratchpad'
|
|
11
11
|
import { resolveScratchOp } from './scratchpad-relay'
|
|
12
12
|
import { allHarnesses, harnessFor } from './harness/registry'
|
|
13
13
|
import { getWorkspace } from './registry'
|
|
14
|
+
import { saveSelectedSession } from './selected-session'
|
|
14
15
|
import { addClient, broadcastAll, getClientCount, removeClient, sendToClient } from './state'
|
|
16
|
+
import { startServiceLogMaintenance } from './service'
|
|
15
17
|
import { distShell, prebuilt } from './static'
|
|
16
18
|
import { renderStatus } from './status'
|
|
17
19
|
import { serveVendorEmojibase, serveVendorReact } from './vendor'
|
|
@@ -140,6 +142,16 @@ export const app = Bun.serve<WsData>({
|
|
|
140
142
|
if (data.type === 'chat' && (data.content?.trim() || data.attachments?.length)) {
|
|
141
143
|
const workspace = await getWorkspace(data.workspaceId)
|
|
142
144
|
if (!workspace) return
|
|
145
|
+
if (data.isNew) {
|
|
146
|
+
const selection = await saveSelectedSession(workspace.path, data.sessionId, null)
|
|
147
|
+
if (selection.changed) {
|
|
148
|
+
publishEvent({
|
|
149
|
+
type: 'selected-session:updated',
|
|
150
|
+
workspaceId: workspace.id,
|
|
151
|
+
sessionId: selection.sessionId
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
}
|
|
143
155
|
// Harnesses ignore fields they don't support (see SendMessageInput);
|
|
144
156
|
// failures surface as error frames from inside the harness.
|
|
145
157
|
void harnessFor(workspace)
|
|
@@ -197,6 +209,10 @@ setInterval(() => {
|
|
|
197
209
|
// leaves its file behind forever. See sweepOrphanAssets.
|
|
198
210
|
startScratchpadSweeper()
|
|
199
211
|
|
|
212
|
+
// Under launchd the service log is a plain file nothing rotates — bound it
|
|
213
|
+
// here. No-op outside the macOS service context.
|
|
214
|
+
startServiceLogMaintenance()
|
|
215
|
+
|
|
200
216
|
// Graceful shutdown. In dev the supervisor sends SIGTERM on server-file
|
|
201
217
|
// changes; in any context Ctrl-C sends SIGINT. Close both servers and kill the
|
|
202
218
|
// per-workspace function workers so no child processes are orphaned.
|
|
@@ -14,10 +14,10 @@ Design around the content and the task. Give every applet a clear first reading,
|
|
|
14
14
|
proportion to its size and purpose. Dense information is welcome when hierarchy and alignment keep
|
|
15
15
|
it easy to scan.
|
|
16
16
|
|
|
17
|
-
An applet may have one expressive focal point: a visualization, strong surface, image,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
An applet may have one expressive focal point: a visualization, strong surface, image, or satisfying
|
|
18
|
+
state change. It is optional. Use it when it helps the content and keep the rest restrained so it
|
|
19
|
+
remains meaningful. Avoid decorative clutter, competing effects, and a different visual system for
|
|
20
|
+
every section.
|
|
21
21
|
|
|
22
22
|
Every visible element must help the user understand useful content, see a real state, or take an
|
|
23
23
|
action. Do not add category eyebrows that repeat the title, readiness badges for an obvious default
|
|
@@ -58,7 +58,7 @@ Views are separate pages. Their semantic tokens inherit the workspace theme, so
|
|
|
58
58
|
| Floating surface | `bg-popover text-popover-foreground` | Menus, tooltips, and other floating content |
|
|
59
59
|
| Primary action | `bg-primary text-primary-foreground` | The most important action in a local region |
|
|
60
60
|
| Subdued surface | `bg-muted` | Skeletons, quiet fills, and disabled structure |
|
|
61
|
-
|
|
|
61
|
+
| Control state | `bg-accent text-accent-foreground` | Hover, active, and selected states on interactive controls |
|
|
62
62
|
| Error or danger | `text-destructive` / `bg-destructive` | Errors, destructive actions, and invalid states |
|
|
63
63
|
| Structure | `ring-border`, `border-input`, `ring-ring` | Container edges, controls, and visible focus on semantic surfaces |
|
|
64
64
|
|
|
@@ -124,28 +124,18 @@ must not look capsule-shaped.
|
|
|
124
124
|
|
|
125
125
|
## Interaction and motion
|
|
126
126
|
|
|
127
|
-
Widgets
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
Widgets may include compact controls such as filters, toggles, refresh actions, and links. Keep
|
|
128
|
+
interaction feedback on the control that performs the action. The widget surface stays unchanged on
|
|
129
|
+
hover. Multi-step workflows and deep navigation belong in a view.
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
Controls must be obvious, keyboard-operable, and large enough to use comfortably. Give them a
|
|
132
|
+
visible focus state and an accessible name. Use Tabler icons with consistent visual weight. Do not
|
|
133
|
+
rely on color alone, and keep charts understandable with labels, legends, patterns, or direct values
|
|
134
|
+
where needed.
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
2. Interaction feedback covers hover, active, loading, disabled, and optimistic states.
|
|
140
|
-
3. At most one signature animation may act as the expressive focal point.
|
|
141
|
-
|
|
142
|
-
Keep motion short, interruptible, and safe for reduced-motion preferences. Animate transform and
|
|
143
|
-
opacity where possible. Do not loop decorative motion or animate frequently updating numbers. Audio
|
|
144
|
-
and video must be user-initiated.
|
|
145
|
-
|
|
146
|
-
A single interactive surface may use a restrained tactile treatment such as an inset highlight,
|
|
147
|
-
ring, or soft shadow. Keep this away from the widget's outer root because the host owns the card
|
|
148
|
-
shell.
|
|
136
|
+
Use short, interruptible motion for meaningful state changes and control feedback. Respect
|
|
137
|
+
reduced-motion preferences and animate transform and opacity where possible. Do not loop decorative
|
|
138
|
+
motion or animate frequently updating numbers. Audio and video must be user-initiated.
|
|
149
139
|
|
|
150
140
|
## States
|
|
151
141
|
|
|
@@ -259,6 +249,6 @@ Before finishing an applet, confirm:
|
|
|
259
249
|
- Numeric UI values use the default font, with `tabular-nums` when alignment helps.
|
|
260
250
|
- Custom container outlines suit their surface and stay subtle.
|
|
261
251
|
- The layout handles realistic content and deliberate overflow.
|
|
262
|
-
- Every
|
|
252
|
+
- Every control is necessary, complete, and accessible.
|
|
263
253
|
- The widget or view follows its frame, sizing, and scrolling rules.
|
|
264
254
|
- It feels related to the workspace without copying the quieter host shell.
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: moi-workspace
|
|
3
|
-
description:
|
|
3
|
+
description: >-
|
|
4
|
+
The moi workspace — the web UI the user chats from, extended with agent-authored applets
|
|
5
|
+
(widgets, views) plus theme & config. Read this FIRST in two cases. (a) A message carries a hidden
|
|
6
|
+
moi-context envelope: it was fired from a moi workspace, so you are running inside one even if
|
|
7
|
+
nothing else says so. (b) The user uses moi vocab — workspace, applet, widget, view, scratchpad,
|
|
8
|
+
dashboard, or a `moi` command — or asks to build, edit, customize, or theme the workspace UI or
|
|
9
|
+
its layout.
|
|
4
10
|
---
|
|
5
11
|
|
|
6
12
|
# Workspace
|
|
@@ -402,4 +408,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
|
|
|
402
408
|
- **Then** — if you updated, mention it.
|
|
403
409
|
|
|
404
410
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
405
|
-
<moi-skill version="0.
|
|
411
|
+
<moi-skill version="0.10.0" />
|
package/dist/chunk-94m3q9ce.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"/chunk-pcnahct1.js";import"/chunk-tzz101ea.js";export{a as sanitizeSvg};
|