moi-computer 0.4.0 → 0.4.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 +41 -5
- package/bin/moi.mjs +11 -0
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/AppRouter.tsx +5 -1
- package/client/app/routes/WorkspaceRoute.tsx +9 -5
- package/client/app/shell/SidebarLayout.tsx +9 -7
- package/client/components/shared/BottomPanel.tsx +24 -5
- package/client/components/shared/Composer.tsx +1 -1
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/ui/button.tsx +5 -5
- package/client/components/ui/dropdown-menu.tsx +6 -6
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/input.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/skeleton.tsx +1 -1
- package/client/components/ui/textarea.tsx +1 -1
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/applets/applet-cache.ts +20 -1
- package/client/features/applets/applet-log.ts +10 -30
- package/client/features/applets/applet-runtime.ts +272 -0
- package/client/features/applets/useApplet.ts +36 -10
- package/client/features/chat/ChatComposer.tsx +1 -1
- package/client/features/chat/ChatEmptyState.tsx +186 -0
- package/client/features/chat/ChatPanel.tsx +95 -54
- package/client/features/chat/ChatPopup.tsx +3 -13
- package/client/features/chat/ChatPromptBubbles.tsx +74 -0
- package/client/features/chat/MarkdownContent.tsx +15 -3
- package/client/features/chat/ModelPicker.tsx +1 -1
- package/client/features/chat/TurnView.tsx +6 -17
- package/client/features/chat/chat-send.ts +26 -1
- package/client/features/chat/tool-group/CodeBlock.tsx +1 -1
- package/client/features/chat/tool-group/ReadImagePreview.tsx +1 -1
- package/client/features/chat/tool-group/SubagentCard.tsx +1 -1
- package/client/features/chat/tool-group/TimelineRow.tsx +4 -4
- package/client/features/chat/tool-group/ToolCallGroup.tsx +12 -5
- package/client/features/chat/tool-group/ToolOutput.tsx +2 -2
- package/client/features/chat/tool-group/format.ts +3 -3
- package/client/features/chat/useAppletChatMessage.ts +69 -0
- package/client/features/chat/useChat.ts +49 -14
- package/client/features/chat/useStickToBottom.ts +11 -1
- package/client/features/connectors/McpServerCards.tsx +3 -3
- package/client/features/dev/HarnessDebugPage.tsx +4 -4
- package/client/features/dev/PixelPainter.tsx +1 -1
- package/client/features/dev/PlaygroundPage.tsx +1 -1
- package/client/features/dev/ToolCallsPage.tsx +2 -2
- package/client/features/home/HomePage.tsx +17 -14
- package/client/features/home/WorkspacePreview.tsx +12 -13
- package/client/features/home/api.ts +8 -5
- package/client/features/home/workspace-presentation.tsx +1 -1
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +1 -1
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +21 -8
- package/client/features/scratchpad/Scratchpad.tsx +41 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +13 -13
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +1 -1
- package/client/features/settings/EnvironmentSettings.tsx +1 -1
- package/client/features/settings/IconPicker.tsx +11 -11
- package/client/features/settings/SettingsLayout.tsx +1 -1
- package/client/features/settings/WorkspaceSettings.tsx +2 -2
- package/client/features/settings/api.ts +33 -1
- package/client/features/widgets/HiddenPanel.tsx +4 -3
- package/client/features/widgets/Widgets.tsx +1 -0
- package/client/features/workspace/CustomizePanel.tsx +96 -82
- package/client/features/workspace/WorkspaceScreen.tsx +129 -107
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +91 -0
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/features/workspace/api.ts +52 -0
- package/client/features/workspace/moi-context.ts +63 -17
- package/client/features/workspace/tab-resolution.ts +75 -0
- package/client/features/workspace/useWorkspaceNavigation.ts +128 -0
- package/client/features/workspace/useWorkspaceSkillUpdates.ts +160 -0
- package/client/index.css +10 -15
- package/client/lib/app-icon-registry.ts +77 -70
- package/client/lib/rate-limit.ts +77 -0
- package/client/runtime/useWorkspaceEvents.ts +15 -2
- package/client/runtime/workspace-theme.ts +115 -0
- package/client/store/ui.ts +42 -17
- package/client/theme.css +20 -15
- package/dist/{chunk-fh2mf6v9.js → chunk-3m1xe1j3.js} +94 -94
- package/dist/chunk-5vaevt8z.js +2 -0
- package/dist/{chunk-69nhbjhy.js → chunk-7bzpmtxp.js} +4 -4
- package/dist/chunk-h0hk61pm.js +9 -0
- package/dist/{chunk-35fq49qa.js → chunk-h3evrtyp.js} +1 -1
- package/dist/chunk-k5sjx9s5.js +1 -0
- package/dist/{chunk-2vaafjp4.js → chunk-m9qja0nx.js} +1 -1
- package/dist/chunk-s7za1qsv.css +1 -0
- package/dist/{chunk-72atbmh3.js → chunk-tcfa3vt3.js} +1 -1
- package/dist/chunk-v797g6ap.js +51 -0
- package/dist/chunk-xyrw8318.js +27 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +73 -0
- package/lib/moi-context.ts +104 -3
- package/lib/themes.ts +83 -45
- package/lib/types.ts +44 -9
- package/lib/workspace-tabs.ts +48 -0
- package/package.json +4 -1
- package/server/api.ts +57 -5
- package/server/app-settings.ts +65 -0
- package/server/applets.ts +132 -22
- package/server/bundler/build-applet.ts +74 -16
- package/server/cli.ts +144 -17
- package/server/control.ts +53 -7
- package/server/data-dir.ts +1 -1
- package/server/events.ts +1 -1
- package/server/functions-worker.ts +15 -1
- package/server/functions.ts +51 -6
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +37 -3
- package/server/registry.ts +1 -1
- package/server/skill-update.ts +47 -0
- package/server/skill-version.ts +2 -11
- package/server/tabs.ts +59 -0
- package/server/theme.ts +8 -14
- package/server/view-builders.ts +6 -2
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +265 -107
- package/workspace/.claude/skills/moi-workspace/SKILL.md +85 -11
- package/client/features/workspace/useWorkspaceTheme.ts +0 -82
- package/dist/chunk-19g80zc9.css +0 -1
- package/dist/chunk-7mkv2gr0.js +0 -2
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-jwmc32rp.js +0 -63
- package/dist/chunk-kh24bstm.js +0 -10
- package/dist/chunk-sfa4mbmx.js +0 -15
- package/workspace/.claude/skills/moi-workspace/VIEW-DESIGN.md +0 -22
package/dist/index.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/chunk-
|
|
24
|
+
<link rel="stylesheet" crossorigin href="/chunk-s7za1qsv.css"><script type="module" crossorigin src="/chunk-tcfa3vt3.js"></script></head>
|
|
25
25
|
<body>
|
|
26
26
|
<div id="root"></div>
|
|
27
27
|
|
package/lib/app-icons.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const APP_ICON_IDS = [
|
|
2
|
+
'rocket',
|
|
3
|
+
'sparkles',
|
|
4
|
+
'bolt',
|
|
5
|
+
'flame',
|
|
6
|
+
'star',
|
|
7
|
+
'heart',
|
|
8
|
+
'diamond',
|
|
9
|
+
'trophy',
|
|
10
|
+
'target',
|
|
11
|
+
'bulb',
|
|
12
|
+
'brain',
|
|
13
|
+
'robot',
|
|
14
|
+
'wand',
|
|
15
|
+
'atom',
|
|
16
|
+
'flask',
|
|
17
|
+
'cpu',
|
|
18
|
+
'code',
|
|
19
|
+
'terminal',
|
|
20
|
+
'api',
|
|
21
|
+
'database',
|
|
22
|
+
'cube',
|
|
23
|
+
'hexagon',
|
|
24
|
+
'plug',
|
|
25
|
+
'tool',
|
|
26
|
+
'settings',
|
|
27
|
+
'bug',
|
|
28
|
+
'activity',
|
|
29
|
+
'chart',
|
|
30
|
+
'briefcase',
|
|
31
|
+
'folder',
|
|
32
|
+
'file',
|
|
33
|
+
'book',
|
|
34
|
+
'message',
|
|
35
|
+
'mail',
|
|
36
|
+
'bell',
|
|
37
|
+
'paperclip',
|
|
38
|
+
'key',
|
|
39
|
+
'shield',
|
|
40
|
+
'user',
|
|
41
|
+
'home',
|
|
42
|
+
'globe',
|
|
43
|
+
'world',
|
|
44
|
+
'planet',
|
|
45
|
+
'compass',
|
|
46
|
+
'map',
|
|
47
|
+
'calendar',
|
|
48
|
+
'cloud',
|
|
49
|
+
'sun',
|
|
50
|
+
'moon',
|
|
51
|
+
'snowflake',
|
|
52
|
+
'leaf',
|
|
53
|
+
'mountain',
|
|
54
|
+
'feather',
|
|
55
|
+
'ghost',
|
|
56
|
+
'music',
|
|
57
|
+
'piano',
|
|
58
|
+
'camera',
|
|
59
|
+
'photo',
|
|
60
|
+
'palette',
|
|
61
|
+
'gamepad',
|
|
62
|
+
'gift',
|
|
63
|
+
'cart',
|
|
64
|
+
'chef'
|
|
65
|
+
] as const
|
|
66
|
+
|
|
67
|
+
export type AppIconId = (typeof APP_ICON_IDS)[number]
|
|
68
|
+
|
|
69
|
+
const appIconIds = new Set<string>(APP_ICON_IDS)
|
|
70
|
+
|
|
71
|
+
export function isAppIconId(id: string): id is AppIconId {
|
|
72
|
+
return appIconIds.has(id)
|
|
73
|
+
}
|
package/lib/moi-context.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
// Display paths strip with `stripMoiContext` so the envelope never surfaces
|
|
22
22
|
// in a bubble, live or replayed from a transcript.
|
|
23
23
|
import type { WorkspaceTabId } from './types'
|
|
24
|
+
import { isParamsRecord } from './workspace-tabs'
|
|
24
25
|
|
|
25
26
|
const MOI_CONTEXT_OPEN = '<moi-context>'
|
|
26
27
|
const MOI_CONTEXT_CLOSE = '</moi-context>'
|
|
@@ -32,6 +33,17 @@ const MOI_CONTEXT_MARKER = 'You are running in a `moi` workspace'
|
|
|
32
33
|
const SYSTEM_REMINDER_OPEN = '<system-reminder>'
|
|
33
34
|
const SYSTEM_REMINDER_CLOSE = '</system-reminder>'
|
|
34
35
|
|
|
36
|
+
// A chat message fired from applet UI (`sendChatMessage`) rather than typed.
|
|
37
|
+
// `source` is the applet's `<kind>:<name>`, stamped host-side by the applet
|
|
38
|
+
// runtime from the identity the bridge was attached with — an applet cannot
|
|
39
|
+
// claim to be another one.
|
|
40
|
+
export type MoiAppletMessage = {
|
|
41
|
+
source: string
|
|
42
|
+
// The structured payload the applet attached to the call. JSON-plain, and
|
|
43
|
+
// dropped entirely when it doesn't survive serialization.
|
|
44
|
+
context?: Record<string, unknown>
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
// The structured form built at send time — by the client for chat sends, by
|
|
36
48
|
// the server for programmatic sends (the view builder). Extend this (and
|
|
37
49
|
// `renderMoiContext`) when new ambient fields land.
|
|
@@ -44,17 +56,77 @@ export type MoiContext = {
|
|
|
44
56
|
// view builder's claimed title while the build runs. The tab bar falls
|
|
45
57
|
// back to the id when unset; so does the envelope.
|
|
46
58
|
tabTitle?: string
|
|
59
|
+
// The params the active view is rendering with right now, straight from
|
|
60
|
+
// navigation state. The emitter side of the same contract (`focusTab`) sets
|
|
61
|
+
// them, so the agent sees a view's addressable state in both directions.
|
|
62
|
+
// Absent for tabs that take no params (widgets, scratchpad, agent).
|
|
63
|
+
tabParams?: Record<string, unknown>
|
|
64
|
+
// Set when this message came from applet UI instead of the composer.
|
|
65
|
+
applet?: MoiAppletMessage
|
|
47
66
|
// One-shot imperative lines for this message only (e.g. the view-builder
|
|
48
67
|
// bootstrap instructions from lib/view-builder-directives.ts).
|
|
49
68
|
directives?: string[]
|
|
50
69
|
}
|
|
51
70
|
|
|
71
|
+
// Cap on applet-authored JSON rendered into the envelope. Shared with the
|
|
72
|
+
// client applet runtime, which drops an oversized `context` at the trust
|
|
73
|
+
// boundary rather than letting it ride the wire — the renderer's truncation is
|
|
74
|
+
// the backstop for anything that still gets through (e.g. a server-built
|
|
75
|
+
// context).
|
|
76
|
+
export const MAX_APPLET_CONTEXT_CHARS = 2000
|
|
77
|
+
|
|
78
|
+
// Applet-authored strings (view titles, applet names, attached context) get
|
|
79
|
+
// interpolated into the envelope, and applet code is agent-authored — a
|
|
80
|
+
// crafted value containing `</moi-context>` would otherwise close the envelope
|
|
81
|
+
// early and forge sections the host never wrote. Escaping `<` defuses every
|
|
82
|
+
// such value at once: inside JSON it is the standard `<` string escape
|
|
83
|
+
// (same string, no tag), and in prose the model reads it the same.
|
|
84
|
+
function escapeTags(text: string): string {
|
|
85
|
+
return text.replaceAll('<', '\\u003c')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Render an applet-authored record for the envelope, or null when there's
|
|
89
|
+
// nothing worth printing. Non-serializable values (cycles, BigInt) drop rather
|
|
90
|
+
// than throw mid-send.
|
|
91
|
+
function renderAppletJson(value: Record<string, unknown>): string | null {
|
|
92
|
+
let json: string
|
|
93
|
+
try {
|
|
94
|
+
json = JSON.stringify(value)
|
|
95
|
+
} catch {
|
|
96
|
+
return null
|
|
97
|
+
}
|
|
98
|
+
if (!json || json === '{}') return null
|
|
99
|
+
const capped =
|
|
100
|
+
json.length > MAX_APPLET_CONTEXT_CHARS
|
|
101
|
+
? `${json.slice(0, MAX_APPLET_CONTEXT_CHARS)}… (truncated)`
|
|
102
|
+
: json
|
|
103
|
+
return escapeTags(capped)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// `<kind>:<name>` → a sentence fragment that names the applet the way the user
|
|
107
|
+
// sees it AND the file the agent edits, the same pairing `describeTab` makes
|
|
108
|
+
// for view tabs.
|
|
109
|
+
function describeAppletSource(source: string): string {
|
|
110
|
+
if (source.startsWith('widget:')) {
|
|
111
|
+
const name = escapeTags(source.slice('widget:'.length))
|
|
112
|
+
return `"${name}" widget (.moi/widgets/${name}.tsx)`
|
|
113
|
+
}
|
|
114
|
+
if (source.startsWith('view:')) {
|
|
115
|
+
const name = escapeTags(source.slice('view:'.length))
|
|
116
|
+
return `"${name}" view (.moi/views/${name}.tsx)`
|
|
117
|
+
}
|
|
118
|
+
return `"${escapeTags(source)}" applet`
|
|
119
|
+
}
|
|
120
|
+
|
|
52
121
|
// One sentence per tab, using the labels the user sees in the tab bar (except
|
|
53
122
|
// view-builder tabs, which print the builder id — that's what `moi builder
|
|
54
123
|
// set` needs). A view tab also names its backing file: the user speaks in
|
|
55
124
|
// titles ("fix the Grading review page") while the agent edits
|
|
56
125
|
// `.moi/views/<id>.tsx` — this line connects the two.
|
|
57
|
-
function describeTab(tab: WorkspaceTabId,
|
|
126
|
+
function describeTab(tab: WorkspaceTabId, rawTitle?: string): string {
|
|
127
|
+
// Titles come from applet config, so they carry the same forgery risk as any
|
|
128
|
+
// other applet-authored string in here.
|
|
129
|
+
const title = rawTitle === undefined ? undefined : escapeTags(rawTitle)
|
|
58
130
|
if (tab === 'agent') return 'The user is on the "Agent" tab (full page chat).'
|
|
59
131
|
if (tab === 'widgets') return 'The user is on the "Widgets" tab.'
|
|
60
132
|
if (tab === 'scratchpad') return 'The user is on the "Scratchpad" tab.'
|
|
@@ -82,7 +154,18 @@ export function renderMoiContextBody(ctx: MoiContext): string {
|
|
|
82
154
|
`${MOI_CONTEXT_MARKER} — a shared UI the user chats with you from, which you can extend and customize.`,
|
|
83
155
|
'Read the **`moi-workspace` skill** before responding — even to a simple question — unless you already read it in this chat.'
|
|
84
156
|
].join('\n')
|
|
85
|
-
const
|
|
157
|
+
const tabLines = [describeTab(ctx.activeTab, ctx.tabTitle)]
|
|
158
|
+
const tabParams = ctx.tabParams ? renderAppletJson(ctx.tabParams) : null
|
|
159
|
+
if (tabParams) tabLines.push(`Params it is rendering with right now: ${tabParams}`)
|
|
160
|
+
const sections = [`# Active tab\n${tabLines.join('\n')}`]
|
|
161
|
+
if (ctx.applet) {
|
|
162
|
+
const appletLines = [
|
|
163
|
+
`The message above was not typed by the user — the ${describeAppletSource(ctx.applet.source)} sent it when the user acted in its UI.`
|
|
164
|
+
]
|
|
165
|
+
const context = ctx.applet.context ? renderAppletJson(ctx.applet.context) : null
|
|
166
|
+
if (context) appletLines.push(`It attached this context: ${context}`)
|
|
167
|
+
sections.push(`# Applet message\n${appletLines.join('\n')}`)
|
|
168
|
+
}
|
|
86
169
|
if (ctx.directives?.length) {
|
|
87
170
|
sections.push(`# This message only\n${ctx.directives.join('\n')}`)
|
|
88
171
|
}
|
|
@@ -100,15 +183,33 @@ export function renderMoiContext(ctx: MoiContext): string {
|
|
|
100
183
|
// Wire-shape guard for the chat frame's `context` field (see web.ts).
|
|
101
184
|
export function isMoiContext(value: unknown): value is MoiContext {
|
|
102
185
|
if (typeof value !== 'object' || value === null) return false
|
|
103
|
-
const v = value as {
|
|
186
|
+
const v = value as {
|
|
187
|
+
activeTab?: unknown
|
|
188
|
+
tabTitle?: unknown
|
|
189
|
+
tabParams?: unknown
|
|
190
|
+
applet?: unknown
|
|
191
|
+
directives?: unknown
|
|
192
|
+
}
|
|
104
193
|
return (
|
|
105
194
|
typeof v.activeTab === 'string' &&
|
|
106
195
|
(v.tabTitle === undefined || typeof v.tabTitle === 'string') &&
|
|
196
|
+
(v.tabParams === undefined || isParamsRecord(v.tabParams)) &&
|
|
197
|
+
(v.applet === undefined || isMoiAppletMessage(v.applet)) &&
|
|
107
198
|
(v.directives === undefined ||
|
|
108
199
|
(Array.isArray(v.directives) && v.directives.every(d => typeof d === 'string')))
|
|
109
200
|
)
|
|
110
201
|
}
|
|
111
202
|
|
|
203
|
+
function isMoiAppletMessage(value: unknown): value is MoiAppletMessage {
|
|
204
|
+
if (!isParamsRecord(value)) return false
|
|
205
|
+
const v = value as { source?: unknown; context?: unknown }
|
|
206
|
+
return (
|
|
207
|
+
typeof v.source === 'string' &&
|
|
208
|
+
v.source.length > 0 &&
|
|
209
|
+
(v.context === undefined || isParamsRecord(v.context))
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
112
213
|
// Claude Code: the envelope rides as its OWN text block wrapped in
|
|
113
214
|
// `<system-reminder>`, placed before the user's text block. Keeping it out of
|
|
114
215
|
// the user's string matters: the SDK's first-prompt extraction (session
|
package/lib/themes.ts
CHANGED
|
@@ -1,89 +1,127 @@
|
|
|
1
|
-
|
|
1
|
+
import { colord, extend } from 'colord'
|
|
2
|
+
import a11yPlugin from 'colord/plugins/a11y'
|
|
3
|
+
|
|
4
|
+
// Registers optional WCAG helpers such as luminance() on Colord.
|
|
5
|
+
extend([a11yPlugin])
|
|
6
|
+
|
|
7
|
+
export type FontTheme = 'default' | 'serif' | 'mono' | 'blobby' | 'geometric' | 'awkward'
|
|
2
8
|
|
|
3
9
|
export type FontThemeConfig = {
|
|
4
10
|
label: string
|
|
11
|
+
feel: string
|
|
5
12
|
sans: string
|
|
6
13
|
mono: string
|
|
7
|
-
feel: string
|
|
8
14
|
googleFontsQuery?: string // passed as `family=` param to Google Fonts API
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
export const FONT_THEMES: Record<FontTheme, FontThemeConfig> = {
|
|
12
18
|
default: {
|
|
13
19
|
label: 'Default',
|
|
20
|
+
feel: 'System font',
|
|
14
21
|
sans: 'system-ui',
|
|
15
|
-
mono: '
|
|
16
|
-
|
|
17
|
-
googleFontsQuery: 'JetBrains+Mono:wght@400;500'
|
|
22
|
+
mono: 'Geist Mono',
|
|
23
|
+
googleFontsQuery: 'Geist+Mono:wght@400;500'
|
|
18
24
|
},
|
|
19
25
|
serif: {
|
|
20
26
|
label: 'Serif',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
googleFontsQuery: '
|
|
27
|
+
feel: 'Literata',
|
|
28
|
+
sans: 'Literata',
|
|
29
|
+
mono: 'Geist Mono',
|
|
30
|
+
googleFontsQuery: 'Literata:wght@400;600;700&family=Geist+Mono:wght@400;500'
|
|
25
31
|
},
|
|
26
32
|
mono: {
|
|
27
33
|
label: 'Mono',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
googleFontsQuery: '
|
|
34
|
+
feel: 'Geist Mono',
|
|
35
|
+
sans: 'Geist Mono',
|
|
36
|
+
mono: 'Geist Mono',
|
|
37
|
+
googleFontsQuery: 'Geist+Mono:wght@400;500;600'
|
|
32
38
|
},
|
|
33
|
-
|
|
34
|
-
label: '
|
|
35
|
-
|
|
39
|
+
blobby: {
|
|
40
|
+
label: 'Blobby',
|
|
41
|
+
feel: 'Sour Gummy',
|
|
42
|
+
sans: 'Sour Gummy',
|
|
36
43
|
mono: 'Azeret Mono',
|
|
37
|
-
|
|
38
|
-
googleFontsQuery: 'Fredoka:wght@400;500;600&family=Azeret+Mono:wght@400;500'
|
|
44
|
+
googleFontsQuery: 'Sour+Gummy:wght@400;500;600&family=Azeret+Mono:wght@400;500'
|
|
39
45
|
},
|
|
40
46
|
geometric: {
|
|
41
47
|
label: 'Geometric',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
googleFontsQuery: '
|
|
48
|
+
feel: 'Manrope',
|
|
49
|
+
sans: 'Manrope',
|
|
50
|
+
mono: 'Geist Mono',
|
|
51
|
+
googleFontsQuery: 'Manrope:wght@400;500;600&family=Geist+Mono:wght@400;500'
|
|
46
52
|
},
|
|
47
|
-
|
|
48
|
-
label: '
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
googleFontsQuery: '
|
|
53
|
+
awkward: {
|
|
54
|
+
label: 'Awkward',
|
|
55
|
+
feel: 'Averia Sans Libre',
|
|
56
|
+
sans: 'Averia Sans Libre',
|
|
57
|
+
mono: 'Azeret Mono',
|
|
58
|
+
googleFontsQuery: 'Averia+Sans+Libre:wght@400;500;600&family=Azeret+Mono:wght@400;500'
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
export type ColorTheme = 'default' | 'paper' | 'sand' | 'rose' | 'lavender' | 'mint' | 'sky'
|
|
57
63
|
|
|
64
|
+
function foregroundForPrimary(primary: string): string {
|
|
65
|
+
if (!/^#[0-9a-f]{6}$/i.test(primary)) {
|
|
66
|
+
throw new Error(`Primary theme color must use #rrggbb: ${primary}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return colord(primary).luminance() > 0.24 ? '#000000' : '#ffffff'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const THEME_COLOR_DERIVATIONS = {
|
|
73
|
+
primary: primary => primary,
|
|
74
|
+
primaryForeground: primary => foregroundForPrimary(primary),
|
|
75
|
+
background: () => 'color-mix(in oklch, var(--primary) 3%, white 97%)',
|
|
76
|
+
foreground: () => 'color-mix(in oklch, var(--primary) 24%, black 76%)',
|
|
77
|
+
muted: () => 'color-mix(in oklch, var(--background) 95%, var(--foreground) 5%)',
|
|
78
|
+
mutedForeground: () => 'color-mix(in oklch, var(--background) 58%, var(--foreground) 42%)',
|
|
79
|
+
accent: () => 'color-mix(in oklch, var(--primary) 4%, var(--foreground) 4%)'
|
|
80
|
+
} satisfies Record<string, (primary: string) => string>
|
|
81
|
+
|
|
82
|
+
export type ThemeColorToken = keyof typeof THEME_COLOR_DERIVATIONS
|
|
83
|
+
export type ThemeColors = Record<ThemeColorToken, string>
|
|
84
|
+
|
|
58
85
|
export type ColorThemeConfig = {
|
|
59
86
|
label: string
|
|
60
|
-
// undefined
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
87
|
+
// undefined primary = no override, reveals :root defaults
|
|
88
|
+
primary?: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const THEME_COLOR_TOKENS = Object.keys(THEME_COLOR_DERIVATIONS) as ThemeColorToken[]
|
|
92
|
+
|
|
93
|
+
export function deriveThemeColors(primary: string): ThemeColors {
|
|
94
|
+
const colors = {} as ThemeColors
|
|
95
|
+
for (const token of THEME_COLOR_TOKENS) {
|
|
96
|
+
colors[token] = THEME_COLOR_DERIVATIONS[token](primary)
|
|
97
|
+
}
|
|
98
|
+
return colors
|
|
64
99
|
}
|
|
65
100
|
|
|
66
101
|
export const COLOR_THEMES: Record<ColorTheme, ColorThemeConfig> = {
|
|
67
|
-
default: { label: 'Default'
|
|
102
|
+
default: { label: 'Default' },
|
|
68
103
|
paper: {
|
|
69
104
|
label: 'Paper',
|
|
70
|
-
|
|
71
|
-
foreground: '#2c2825',
|
|
72
|
-
feel: 'Warm off-white'
|
|
105
|
+
primary: '#453521'
|
|
73
106
|
},
|
|
74
107
|
sand: {
|
|
75
108
|
label: 'Sand',
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
109
|
+
primary: '#ff8700'
|
|
110
|
+
},
|
|
111
|
+
rose: {
|
|
112
|
+
label: 'Rose',
|
|
113
|
+
primary: '#f13c3c'
|
|
79
114
|
},
|
|
80
|
-
rose: { label: 'Rose', background: '#fdf2f4', foreground: '#3b1c26', feel: 'Soft blush' },
|
|
81
115
|
lavender: {
|
|
82
116
|
label: 'Lavender',
|
|
83
|
-
|
|
84
|
-
foreground: '#2b2640',
|
|
85
|
-
feel: 'Cool violet'
|
|
117
|
+
primary: '#9051ff'
|
|
86
118
|
},
|
|
87
|
-
mint: {
|
|
88
|
-
|
|
119
|
+
mint: {
|
|
120
|
+
label: 'Tropics',
|
|
121
|
+
primary: '#009155'
|
|
122
|
+
},
|
|
123
|
+
sky: {
|
|
124
|
+
label: 'Sky',
|
|
125
|
+
primary: '#007ae3'
|
|
126
|
+
}
|
|
89
127
|
}
|
package/lib/types.ts
CHANGED
|
@@ -68,9 +68,13 @@ export type ViewBuilder = {
|
|
|
68
68
|
// ---- Applet error journal (see docs/self-correction.md) ------------------
|
|
69
69
|
|
|
70
70
|
// Where an applet error was observed. `build` and `rpc` are recorded
|
|
71
|
-
// server-side (bundle pipeline, RPC route); `load`/`render`/`window`
|
|
72
|
-
// browser-side and reach the journal via POST
|
|
73
|
-
|
|
71
|
+
// server-side (bundle pipeline, RPC route); `load`/`render`/`window`/`runtime`
|
|
72
|
+
// are browser-side and reach the journal via POST
|
|
73
|
+
// /api/workspaces/:id/applet-log. `runtime` is the applet API refusing a
|
|
74
|
+
// request rather than code throwing — a `focusTab` at a tab that no longer
|
|
75
|
+
// exists, a `sendChatMessage` dropped by the rate limit — which the applet's
|
|
76
|
+
// own code never sees.
|
|
77
|
+
export type AppletLogSource = 'build' | 'load' | 'render' | 'window' | 'rpc' | 'runtime'
|
|
74
78
|
|
|
75
79
|
// One journal entry, as returned to `moi debug logs`. `kind`/`name` attribute
|
|
76
80
|
// the applet when known; `module`/`fn` pin down the server function for `rpc`
|
|
@@ -89,12 +93,14 @@ export type AppletLogEntry = {
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
// The browser-reported subset (the server-side sources can't be spoofed by a
|
|
92
|
-
// tab — the POST route rejects them).
|
|
93
|
-
|
|
96
|
+
// tab — the POST route rejects them). `kind`/`name` are optional because a
|
|
97
|
+
// `runtime` entry may have no applet to blame: a stale bookmark pointing at a
|
|
98
|
+
// deleted view is the host redirecting, not an applet misbehaving.
|
|
99
|
+
export type AppletClientErrorSource = 'load' | 'render' | 'window' | 'runtime'
|
|
94
100
|
export type AppletClientError = {
|
|
95
101
|
source: AppletClientErrorSource
|
|
96
|
-
kind
|
|
97
|
-
name
|
|
102
|
+
kind?: AppletKind
|
|
103
|
+
name?: string
|
|
98
104
|
message: string
|
|
99
105
|
stack?: string
|
|
100
106
|
}
|
|
@@ -259,6 +265,15 @@ export type ThreadConfig = {
|
|
|
259
265
|
effort?: string
|
|
260
266
|
}
|
|
261
267
|
|
|
268
|
+
// App-wide settings, persisted server-side as `settings.json` in moi's data
|
|
269
|
+
// dir and exposed via GET/PATCH /api/settings. Every key has a default, so
|
|
270
|
+
// GET always returns a complete object.
|
|
271
|
+
export type AppSettings = {
|
|
272
|
+
// Apply bundled workspace-skill updates automatically when a workspace
|
|
273
|
+
// with outdated skills is opened, instead of prompting each time.
|
|
274
|
+
autoUpdateSkills: boolean
|
|
275
|
+
}
|
|
276
|
+
|
|
262
277
|
// Re-export the display format
|
|
263
278
|
export type {
|
|
264
279
|
Citation,
|
|
@@ -352,6 +367,21 @@ export type WorkspaceSwitchMessage = {
|
|
|
352
367
|
|
|
353
368
|
export type WorkspaceType = 'claude-code' | 'openclaw' | 'codex'
|
|
354
369
|
|
|
370
|
+
export type WorkspaceSkillStatus = {
|
|
371
|
+
name: string
|
|
372
|
+
installed: string | null
|
|
373
|
+
bundled: string | null
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export type WorkspaceSkillsStatus = {
|
|
377
|
+
skills: WorkspaceSkillStatus[]
|
|
378
|
+
updateAvailable: boolean
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export type WorkspaceSkillsUpdateFailure = WorkspaceSkillsStatus & {
|
|
382
|
+
error: string
|
|
383
|
+
}
|
|
384
|
+
|
|
355
385
|
// Whether an agent backend's runtime is installed on this machine. `reason` is
|
|
356
386
|
// user-facing copy explaining what to do next. Surfaced by
|
|
357
387
|
// GET /api/workspaces/create (per-type map, drives setup dialogs) and
|
|
@@ -447,6 +477,11 @@ export type WorkspaceTabId =
|
|
|
447
477
|
| `view:${string}`
|
|
448
478
|
| `view-builder:${string}`
|
|
449
479
|
|
|
480
|
+
// Open tabs plus the workspace's saved DEFAULT tab. `active` is not live focus
|
|
481
|
+
// state — the live active tab is each browser tab's URL (`/workspace/:id/<tab>`).
|
|
482
|
+
// The saved default answers one question: where a bare `/workspace/:id` lands
|
|
483
|
+
// (and which row `moi tabs` marks). Navigating writes it, so it tracks the last
|
|
484
|
+
// tab switch, last writer wins across clients.
|
|
450
485
|
export type WorkspaceTabsState = {
|
|
451
486
|
open: WorkspaceTabId[]
|
|
452
487
|
active: WorkspaceTabId
|
|
@@ -481,8 +516,7 @@ export type WorkspaceLayout = {
|
|
|
481
516
|
selectedEffort?: string
|
|
482
517
|
theme?: {
|
|
483
518
|
font: import('./themes').FontTheme
|
|
484
|
-
|
|
485
|
-
foreground?: string
|
|
519
|
+
primary?: string
|
|
486
520
|
}
|
|
487
521
|
// Widget thumbnails captured client-side from the live grid, used for
|
|
488
522
|
// home-screen previews. Saved through their own endpoint (PUT
|
|
@@ -514,6 +548,7 @@ export type WorkspacePreview = {
|
|
|
514
548
|
thumbnails: string[]
|
|
515
549
|
firstUserMessage?: string
|
|
516
550
|
updatedAt?: number
|
|
551
|
+
theme?: WorkspaceLayout['theme']
|
|
517
552
|
}
|
|
518
553
|
|
|
519
554
|
// One effective env var, as surfaced by GET /api/workspaces/:id/env. Values are
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Workspace tab addressing, shared by the client router, the control server,
|
|
2
|
+
// and the CLI. A tab id doubles as the URL suffix of `/workspace/:id/<tab>` —
|
|
3
|
+
// ids are URL-safe as-is (`:` is a legal path character), so building a path
|
|
4
|
+
// is plain concatenation and parsing is plain validation.
|
|
5
|
+
import type { WorkspaceTabId } from './types'
|
|
6
|
+
|
|
7
|
+
export function isWorkspaceTabId(value: unknown): value is WorkspaceTabId {
|
|
8
|
+
return (
|
|
9
|
+
value === 'agent' ||
|
|
10
|
+
value === 'widgets' ||
|
|
11
|
+
value === 'scratchpad' ||
|
|
12
|
+
// One path segment: a URL wildcard can span segments, a tab id never does.
|
|
13
|
+
(typeof value === 'string' &&
|
|
14
|
+
(/^view:[^/]+$/.test(value) || /^view-builder:[^/]+$/.test(value)))
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// The tab id carried by a URL's wildcard segment, or null when the segment is
|
|
19
|
+
// missing or isn't a tab id (bare `/workspace/:id`, stale or mangled links).
|
|
20
|
+
export function parseWorkspaceTab(segment: string | null | undefined): WorkspaceTabId | null {
|
|
21
|
+
return isWorkspaceTabId(segment) ? segment : null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function workspaceTabPath(workspaceId: string, tab: WorkspaceTabId): string {
|
|
25
|
+
return `/workspace/${workspaceId}/${tab}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const viewTabId = (viewId: string): WorkspaceTabId => `view:${viewId}`
|
|
29
|
+
export const viewIdFromTab = (tab: WorkspaceTabId): string | null =>
|
|
30
|
+
tab.startsWith('view:') ? tab.slice('view:'.length) : null
|
|
31
|
+
export const viewBuilderTabId = (builderId: string): WorkspaceTabId => `view-builder:${builderId}`
|
|
32
|
+
export const viewBuilderIdFromTab = (tab: WorkspaceTabId): string | null =>
|
|
33
|
+
tab.startsWith('view-builder:') ? tab.slice('view-builder:'.length) : null
|
|
34
|
+
|
|
35
|
+
// The only params shape focusTab / `moi tab focus` carry: one JSON-plain
|
|
36
|
+
// object. Arrays and null are valid JSON but not a params record.
|
|
37
|
+
export function isParamsRecord(value: unknown): value is Record<string, unknown> {
|
|
38
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Applet params as read back from navigation state (`state.appletParams`).
|
|
42
|
+
// Anything malformed degrades to `{}` — a view must render with empty params
|
|
43
|
+
// anyway (fresh mount, new browser tab, plain tab-bar click).
|
|
44
|
+
export function readAppletParams(state: unknown): Record<string, unknown> {
|
|
45
|
+
if (!isParamsRecord(state)) return {}
|
|
46
|
+
const params = (state as { appletParams?: unknown }).appletParams
|
|
47
|
+
return isParamsRecord(params) ? params : {}
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moi-computer",
|
|
3
|
-
"version": "0.4.0",
|
|
3
|
+
"version": "0.4.1-next.0",
|
|
4
4
|
"description": "Local AI workspace powered by the Claude Agent SDK, Bun, React, and Tailwind. Requires Bun.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -69,6 +69,8 @@
|
|
|
69
69
|
"citty": "^0.2.1",
|
|
70
70
|
"class-variance-authority": "^0.7.1",
|
|
71
71
|
"clsx": "^2.1.1",
|
|
72
|
+
"colord": "^2.9.3",
|
|
73
|
+
"conf": "^15.1.0",
|
|
72
74
|
"devalue": "^5.6.4",
|
|
73
75
|
"env-paths": "^4.0.0",
|
|
74
76
|
"frimousse": "^0.3.0",
|
|
@@ -77,6 +79,7 @@
|
|
|
77
79
|
"lru-cache": "^11.3.5",
|
|
78
80
|
"modern-screenshot": "^4.7.0",
|
|
79
81
|
"motion": "^12.35.1",
|
|
82
|
+
"nanoevents": "^10.0.0",
|
|
80
83
|
"nanoid": "^6.0.0",
|
|
81
84
|
"pathe": "^2.0.3",
|
|
82
85
|
"picocolors": "^1.1.1",
|