moi-computer 0.3.0 → 0.3.1-next.1
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/workspace-keys.ts +2 -2
- package/client/app/AppRouter.tsx +0 -2
- package/client/app/routes/WorkspaceRoute.tsx +3 -1
- package/client/app/shell/SidebarLayout.tsx +3 -16
- package/client/assets/openai.svg +1 -3
- package/client/components/shared/Composer.tsx +112 -0
- package/client/components/ui/button.tsx +1 -1
- package/client/components/ui/dropdown-menu.tsx +3 -3
- package/client/components/ui/tooltip.tsx +12 -15
- package/client/features/applets/WidgetErrorBoundary.tsx +19 -3
- package/client/features/applets/WidgetShell.tsx +8 -1
- package/client/features/applets/applet-log.ts +100 -0
- package/client/features/applets/useApplet.ts +21 -7
- package/client/features/chat/ChatComposer.tsx +33 -30
- package/client/features/chat/ChatPanel.tsx +5 -2
- package/client/features/chat/MarkdownContent.tsx +20 -2
- package/client/features/chat/ModelPicker.tsx +29 -41
- package/client/features/chat/TurnView.tsx +2 -2
- package/client/features/chat/chat-frames.ts +14 -6
- package/client/features/chat/chat-send.ts +1 -1
- package/client/features/chat/chat-store.ts +22 -17
- package/client/features/chat/model-order.ts +47 -0
- package/client/features/chat/tool-group/ToolOutput.tsx +4 -12
- package/client/features/chat/tool-group/format.ts +0 -6
- package/client/features/chat/useChat.ts +15 -2
- package/client/features/connectors/McpServerCards.tsx +95 -0
- package/client/features/connectors/api.ts +0 -11
- package/client/features/home/HomePage.tsx +45 -42
- package/client/features/home/WorkspacePreview.tsx +179 -38
- package/client/features/home/api.ts +24 -12
- package/client/features/home/workspace-presentation.tsx +17 -15
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +243 -0
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +95 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +230 -0
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +35 -0
- package/client/features/home/workspace-setup/useWorkspaceImport.ts +61 -0
- package/client/features/settings/ConnectorsSettings.tsx +89 -0
- package/client/features/settings/GeneralSettings.tsx +12 -0
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +8 -4
- package/client/features/views/ViewBuilderTab.tsx +28 -29
- package/client/features/views/useViewBuilderActions.ts +1 -1
- package/client/features/widgets/WidgetFrame.tsx +3 -0
- package/client/features/widgets/WidgetGrid.tsx +1 -0
- package/client/features/widgets/Widgets.tsx +12 -3
- package/client/features/widgets/api.ts +47 -0
- package/client/features/widgets/useWidgetThumbnails.ts +107 -0
- package/client/features/widgets/widget-snapshot.ts +71 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -4
- package/client/features/workspace/WorkspaceScreen.tsx +19 -4
- package/client/features/workspace/api.ts +25 -3
- package/client/features/workspace/moi-context.ts +85 -0
- package/client/index.css +0 -5
- package/client/main.tsx +13 -4
- package/dist/{chunk-cs8vbert.js → chunk-1dfbr7n2.js} +2 -2
- package/dist/chunk-339jds4x.js +15 -0
- package/dist/chunk-3xsvsnhr.css +1 -0
- package/dist/{chunk-zpxrb1ce.js → chunk-anqmsbjt.js} +2 -2
- package/dist/chunk-hbvfb6sk.js +63 -0
- package/dist/chunk-jen6xcm1.js +14 -0
- package/dist/{chunk-kxmvv1ax.js → chunk-qwm5f6qk.js} +1 -1
- package/dist/{chunk-fjksw6xf.js → chunk-sxbfh73c.js} +1 -1
- package/dist/chunk-yp4srgqt.js +10 -0
- package/dist/index.html +1 -1
- package/dist/openai-ep9ht2pq.svg +1 -0
- package/lib/ids.ts +15 -0
- package/lib/moi-context.ts +170 -0
- package/lib/types.ts +95 -13
- package/lib/view-builder-directives.ts +16 -0
- package/lib/workspace-types.ts +12 -0
- package/package.json +4 -2
- package/server/api.ts +180 -34
- package/server/applet-log.ts +149 -0
- package/server/cli.ts +161 -7
- package/server/control.ts +81 -1
- package/server/functions.ts +44 -14
- package/server/harness/README.md +26 -9
- package/server/harness/claude-code/NOTES.md +20 -6
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/git-worktree.ts +32 -0
- package/server/harness/claude-code/index.ts +35 -13
- package/server/harness/claude-code/mcp.ts +16 -65
- package/server/harness/claude-code/models.ts +3 -0
- package/server/harness/claude-code/session.ts +196 -61
- package/server/harness/claude-code/sessions.ts +51 -0
- package/server/harness/codex/NOTES.md +41 -11
- package/server/harness/codex/adapter.ts +52 -6
- package/server/harness/codex/client.ts +69 -18
- package/server/harness/codex/discovery.ts +114 -0
- package/server/harness/codex/index.ts +12 -5
- package/server/harness/codex/probe.ts +4 -2
- package/server/harness/codex/session.ts +57 -5
- package/server/harness/executable.ts +82 -0
- package/server/harness/openclaw/adapter.ts +8 -1
- package/server/harness/openclaw/discovery.ts +139 -6
- package/server/harness/openclaw/gateway.ts +40 -18
- package/server/harness/openclaw/index.ts +12 -15
- package/server/harness/openclaw/session.ts +50 -10
- package/server/harness/openclaw/strip.ts +2 -2
- package/server/harness/shell-path.ts +79 -0
- package/server/harness/types.ts +37 -5
- package/server/layout.ts +81 -51
- package/server/registry.ts +57 -12
- package/server/scratchpad-assets.ts +41 -6
- package/server/scratchpad.ts +30 -0
- package/server/view-builders.ts +3 -2
- package/server/views.ts +5 -0
- package/server/web.ts +30 -8
- package/server/widgets.ts +23 -2
- package/server/workspace-import.ts +45 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -3
- package/client/features/connectors/ConnectorsPage.tsx +0 -92
- package/client/features/connectors/McpMenu.tsx +0 -145
- package/client/features/home/CreateWorkspaceDialog.tsx +0 -130
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +0 -234
- package/dist/chunk-4vf1t6v1.js +0 -10
- package/dist/chunk-4z52b2av.css +0 -1
- package/dist/chunk-b4b276wx.js +0 -15
- package/dist/chunk-y82s1jxm.js +0 -61
- package/dist/openai-h13pza4b.svg +0 -3
- package/lib/view-builder-meta.ts +0 -35
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// The moi context envelope: ambient workspace state that rides along with
|
|
2
|
+
// every user message so the agent knows it is running inside a moi workspace
|
|
3
|
+
// and what the user is looking at. Everything about the envelope lives here —
|
|
4
|
+
// the structured `MoiContext` form, the rendered `<moi-context>` text, the
|
|
5
|
+
// per-harness injection transforms, and the strip used to keep the envelope
|
|
6
|
+
// out of chat bubbles.
|
|
7
|
+
//
|
|
8
|
+
// Flow: a structured `MoiContext` is assembled at send time — by the client
|
|
9
|
+
// for chat sends (client/features/workspace/moi-context.ts, sent as the chat
|
|
10
|
+
// frame's `context`), by the server for view-builder requests — and travels
|
|
11
|
+
// structured all the way to the harness, which renders it with the transform
|
|
12
|
+
// matching its conventions:
|
|
13
|
+
// - Claude Code — `moiContextSystemReminder` as its own leading text block
|
|
14
|
+
// (mirrors how Claude Code itself injects ambient context; a string
|
|
15
|
+
// prefix would defeat the SDK's first-prompt extraction, which skips
|
|
16
|
+
// tag-leading text)
|
|
17
|
+
// - Codex — native `turn/start.additionalContext` (`renderMoiContextBody`,
|
|
18
|
+
// the entry key becomes the tag) on servers >= 0.135; `appendMoiContext`
|
|
19
|
+
// fallback below that
|
|
20
|
+
// - OpenClaw — `appendMoiContext` after the user's text
|
|
21
|
+
// Display paths strip with `stripMoiContext` so the envelope never surfaces
|
|
22
|
+
// in a bubble, live or replayed from a transcript.
|
|
23
|
+
import type { WorkspaceTabId } from './types'
|
|
24
|
+
|
|
25
|
+
const MOI_CONTEXT_OPEN = '<moi-context>'
|
|
26
|
+
const MOI_CONTEXT_CLOSE = '</moi-context>'
|
|
27
|
+
// Start of the first line inside the tag. Doubles as the strip guard: a user
|
|
28
|
+
// literally typing `<moi-context>` in their message won't have their text
|
|
29
|
+
// eaten. Keep this phrase byte-stable when rewording the envelope.
|
|
30
|
+
const MOI_CONTEXT_MARKER = 'You are running in a `moi` workspace'
|
|
31
|
+
|
|
32
|
+
const SYSTEM_REMINDER_OPEN = '<system-reminder>'
|
|
33
|
+
const SYSTEM_REMINDER_CLOSE = '</system-reminder>'
|
|
34
|
+
|
|
35
|
+
// The structured form built at send time — by the client for chat sends, by
|
|
36
|
+
// the server for programmatic sends (the view builder). Extend this (and
|
|
37
|
+
// `renderMoiContext`) when new ambient fields land.
|
|
38
|
+
export type MoiContext = {
|
|
39
|
+
// The workspace tab the user is on when they hit send — for a view-builder
|
|
40
|
+
// request that's the builder's own tab (`view-builder:<id>`).
|
|
41
|
+
activeTab: WorkspaceTabId
|
|
42
|
+
// UI label of the active tab when it differs from the id — a view's
|
|
43
|
+
// configured title (e.g. "Grading review" for `view:color-studio`), or a
|
|
44
|
+
// view builder's claimed title while the build runs. The tab bar falls
|
|
45
|
+
// back to the id when unset; so does the envelope.
|
|
46
|
+
tabTitle?: string
|
|
47
|
+
// One-shot imperative lines for this message only (e.g. the view-builder
|
|
48
|
+
// bootstrap instructions from lib/view-builder-directives.ts).
|
|
49
|
+
directives?: string[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// One sentence per tab, using the labels the user sees in the tab bar (except
|
|
53
|
+
// view-builder tabs, which print the builder id — that's what `moi builder
|
|
54
|
+
// set` needs). A view tab also names its backing file: the user speaks in
|
|
55
|
+
// titles ("fix the Grading review page") while the agent edits
|
|
56
|
+
// `.moi/views/<id>.tsx` — this line connects the two.
|
|
57
|
+
function describeTab(tab: WorkspaceTabId, title?: string): string {
|
|
58
|
+
if (tab === 'agent') return 'The user is on the "Agent" tab (full page chat).'
|
|
59
|
+
if (tab === 'widgets') return 'The user is on the "Widgets" tab.'
|
|
60
|
+
if (tab === 'scratchpad') return 'The user is on the "Scratchpad" tab.'
|
|
61
|
+
if (tab.startsWith('view-builder:')) {
|
|
62
|
+
const id = tab.slice('view-builder:'.length)
|
|
63
|
+
return title
|
|
64
|
+
? `The user is building a new view "${title}". Builder id "${id}".`
|
|
65
|
+
: `The user is building a new view. Builder id "${id}".`
|
|
66
|
+
}
|
|
67
|
+
if (tab.startsWith('view:')) {
|
|
68
|
+
const id = tab.slice('view:'.length)
|
|
69
|
+
return `The user is on the "${title ?? id}" view tab (.moi/views/${id}.tsx).`
|
|
70
|
+
}
|
|
71
|
+
return `The user is on the "${tab}" tab.`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Format (modeled on Claude Code's system-reminder context blocks): a short
|
|
75
|
+
// orientation preamble with the skill pointer, `# Section` headers with
|
|
76
|
+
// complete sentences under them, and an IMPORTANT footer with handling rules.
|
|
77
|
+
// The body renderer exists for transports that supply their own tag — Codex
|
|
78
|
+
// `additionalContext` renders the entry key as the tag, so shipping the
|
|
79
|
+
// wrapped text would double-wrap it.
|
|
80
|
+
export function renderMoiContextBody(ctx: MoiContext): string {
|
|
81
|
+
const preamble = [
|
|
82
|
+
`${MOI_CONTEXT_MARKER} — a shared UI the user chats with you from, which you can extend and customize.`,
|
|
83
|
+
'Read the **`moi-workspace` skill** before responding — even to a simple question — unless you already read it in this chat.'
|
|
84
|
+
].join('\n')
|
|
85
|
+
const sections = [`# Active tab\n${describeTab(ctx.activeTab, ctx.tabTitle)}`]
|
|
86
|
+
if (ctx.directives?.length) {
|
|
87
|
+
sections.push(`# This message only\n${ctx.directives.join('\n')}`)
|
|
88
|
+
}
|
|
89
|
+
const footer = [
|
|
90
|
+
'IMPORTANT: This context comes from moi, not from the user, and the user does not see it.',
|
|
91
|
+
'Only the newest of these blocks is current. Do not respond to it directly, and omit it from summaries and compaction.'
|
|
92
|
+
].join('\n')
|
|
93
|
+
return [preamble, ...sections, footer].join('\n\n')
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function renderMoiContext(ctx: MoiContext): string {
|
|
97
|
+
return `${MOI_CONTEXT_OPEN}\n${renderMoiContextBody(ctx)}\n${MOI_CONTEXT_CLOSE}`
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Wire-shape guard for the chat frame's `context` field (see web.ts).
|
|
101
|
+
export function isMoiContext(value: unknown): value is MoiContext {
|
|
102
|
+
if (typeof value !== 'object' || value === null) return false
|
|
103
|
+
const v = value as { activeTab?: unknown; tabTitle?: unknown; directives?: unknown }
|
|
104
|
+
return (
|
|
105
|
+
typeof v.activeTab === 'string' &&
|
|
106
|
+
(v.tabTitle === undefined || typeof v.tabTitle === 'string') &&
|
|
107
|
+
(v.directives === undefined ||
|
|
108
|
+
(Array.isArray(v.directives) && v.directives.every(d => typeof d === 'string')))
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Claude Code: the envelope rides as its OWN text block wrapped in
|
|
113
|
+
// `<system-reminder>`, placed before the user's text block. Keeping it out of
|
|
114
|
+
// the user's string matters: the SDK's first-prompt extraction (session
|
|
115
|
+
// titles, home-card previews) skips text starting with a tag, so a prefixed
|
|
116
|
+
// string would make every moi message invisible to it.
|
|
117
|
+
export function moiContextSystemReminder(contextText: string): string {
|
|
118
|
+
return `${SYSTEM_REMINDER_OPEN}\n${contextText}\n${SYSTEM_REMINDER_CLOSE}`
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Text-only harnesses (OpenClaw; Codex fallback): the envelope is appended
|
|
122
|
+
// after the user's text.
|
|
123
|
+
export function appendMoiContext(text: string, contextText: string): string {
|
|
124
|
+
return text ? `${text}\n\n${contextText}` : contextText
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Remove the envelope (and, for Claude Code transcripts, its enclosing
|
|
128
|
+
// system-reminder wrapper) from user-message text before display. Repeats
|
|
129
|
+
// until no marker-bearing envelope remains, so a user pasting a full envelope
|
|
130
|
+
// into their message can't shield the injected one from stripping.
|
|
131
|
+
export function stripMoiContext(text: string): string {
|
|
132
|
+
let out = text
|
|
133
|
+
for (;;) {
|
|
134
|
+
const next = stripOneMoiContext(out)
|
|
135
|
+
if (next === out) return out
|
|
136
|
+
out = next
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function stripOneMoiContext(text: string): string {
|
|
141
|
+
const start = text.indexOf(MOI_CONTEXT_OPEN)
|
|
142
|
+
if (start === -1) return text
|
|
143
|
+
const end = text.indexOf(MOI_CONTEXT_CLOSE, start)
|
|
144
|
+
if (end === -1) return text
|
|
145
|
+
if (!text.slice(start, end).includes(MOI_CONTEXT_MARKER)) return text
|
|
146
|
+
let before = text.slice(0, start)
|
|
147
|
+
let after = text.slice(end + MOI_CONTEXT_CLOSE.length)
|
|
148
|
+
if (
|
|
149
|
+
before.trimEnd().endsWith(SYSTEM_REMINDER_OPEN) &&
|
|
150
|
+
after.trimStart().startsWith(SYSTEM_REMINDER_CLOSE)
|
|
151
|
+
) {
|
|
152
|
+
before = before.trimEnd().slice(0, -SYSTEM_REMINDER_OPEN.length)
|
|
153
|
+
after = after.trimStart().slice(SYSTEM_REMINDER_CLOSE.length)
|
|
154
|
+
}
|
|
155
|
+
return `${before.trim()}\n\n${after.trim()}`.trim()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// For truncated snippets (session-list / home-card previews): like
|
|
159
|
+
// `stripMoiContext`, but also cuts an envelope (or its system-reminder
|
|
160
|
+
// wrapper) left unterminated by mid-envelope truncation. Skips the marker
|
|
161
|
+
// guard — cutting a preview short on a user-typed literal tag is harmless,
|
|
162
|
+
// unlike eating chat-bubble text.
|
|
163
|
+
export function stripMoiContextLoose(text: string): string {
|
|
164
|
+
let stripped = stripMoiContext(text)
|
|
165
|
+
const open = stripped.indexOf(MOI_CONTEXT_OPEN)
|
|
166
|
+
if (open !== -1) stripped = stripped.slice(0, open)
|
|
167
|
+
const reminder = stripped.indexOf(SYSTEM_REMINDER_OPEN)
|
|
168
|
+
if (reminder !== -1) stripped = stripped.slice(0, reminder)
|
|
169
|
+
return stripped.trimEnd()
|
|
170
|
+
}
|
package/lib/types.ts
CHANGED
|
@@ -12,6 +12,11 @@ export type WidgetConfig = {
|
|
|
12
12
|
export type WidgetInfo = {
|
|
13
13
|
id: string
|
|
14
14
|
config: WidgetConfig
|
|
15
|
+
// Content tag of the built bundle (`<size>-<mtime>` of its index.js) —
|
|
16
|
+
// changes whenever the widget is rebundled. Clients compare it against
|
|
17
|
+
// `WidgetThumbnail.tag` to decide which thumbnails are stale. Absent when
|
|
18
|
+
// the build output can't be statted.
|
|
19
|
+
tag?: string
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
// A view is a full-screen, agent-authored "app" (`.moi/views/<name>.tsx`),
|
|
@@ -60,6 +65,40 @@ export type ViewBuilder = {
|
|
|
60
65
|
updatedAt: number
|
|
61
66
|
}
|
|
62
67
|
|
|
68
|
+
// ---- Applet error journal (see docs/self-correction.md) ------------------
|
|
69
|
+
|
|
70
|
+
// Where an applet error was observed. `build` and `rpc` are recorded
|
|
71
|
+
// server-side (bundle pipeline, RPC route); `load`/`render`/`window` are
|
|
72
|
+
// browser-side and reach the journal via POST /api/workspaces/:id/applet-log.
|
|
73
|
+
export type AppletLogSource = 'build' | 'load' | 'render' | 'window' | 'rpc'
|
|
74
|
+
|
|
75
|
+
// One journal entry, as returned to `moi debug logs`. `kind`/`name` attribute
|
|
76
|
+
// the applet when known; `module`/`fn` pin down the server function for `rpc`
|
|
77
|
+
// entries. `count` dedups repeats of the identical error (crash loops are one
|
|
78
|
+
// line, not a hundred); `ts` is the LAST occurrence.
|
|
79
|
+
export type AppletLogEntry = {
|
|
80
|
+
ts: number
|
|
81
|
+
source: AppletLogSource
|
|
82
|
+
kind?: AppletKind
|
|
83
|
+
name?: string
|
|
84
|
+
module?: string
|
|
85
|
+
fn?: string
|
|
86
|
+
message: string
|
|
87
|
+
stack?: string
|
|
88
|
+
count: number
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The browser-reported subset (the server-side sources can't be spoofed by a
|
|
92
|
+
// tab — the POST route rejects them).
|
|
93
|
+
export type AppletClientErrorSource = 'load' | 'render' | 'window'
|
|
94
|
+
export type AppletClientError = {
|
|
95
|
+
source: AppletClientErrorSource
|
|
96
|
+
kind: AppletKind
|
|
97
|
+
name: string
|
|
98
|
+
message: string
|
|
99
|
+
stack?: string
|
|
100
|
+
}
|
|
101
|
+
|
|
63
102
|
// A Scratchpad draw/view operation issued by `moi scratch`. Mutations run
|
|
64
103
|
// server-side against a headless tldraw store; `view` relays to a live tab. The
|
|
65
104
|
// server assigns each add op a `name` (the `--id`, or a generated one) so the
|
|
@@ -191,6 +230,11 @@ export type ClientMessage =
|
|
|
191
230
|
// `supportsStreaming` (Claude Code); ignored otherwise. Like effort, a
|
|
192
231
|
// change forces the live session to rebuild.
|
|
193
232
|
stream?: boolean
|
|
233
|
+
// Structured moi context (lib/moi-context.ts): ambient workspace state
|
|
234
|
+
// snapshotted at send time, assembled by
|
|
235
|
+
// client/features/workspace/moi-context.ts. The server renders it per
|
|
236
|
+
// harness; display paths strip the rendered envelope from bubbles.
|
|
237
|
+
context?: import('./moi-context').MoiContext
|
|
194
238
|
}
|
|
195
239
|
| { type: 'stop'; workspaceId: string; sessionId: string }
|
|
196
240
|
// Reply to a relayed Scratchpad op (see ScratchpadOpMessage). Carries the
|
|
@@ -291,13 +335,14 @@ export type BroadcastFrame =
|
|
|
291
335
|
| Omit<ErrorFrame, 'workspaceId'>
|
|
292
336
|
| Omit<StoppedFrame, 'workspaceId'>
|
|
293
337
|
|
|
294
|
-
// Sent to a client right after it connects
|
|
295
|
-
//
|
|
296
|
-
// any session NOT listed is marked
|
|
297
|
-
// terminal `status
|
|
338
|
+
// Sent to a client right after it connects (and re-broadcast periodically): the
|
|
339
|
+
// authoritative set of non-idle sessions across all workspaces. The client
|
|
340
|
+
// treats it as ground truth — any session NOT listed is marked idle — which
|
|
341
|
+
// clears a spinner whose terminal `status` frame was lost (disconnect window,
|
|
342
|
+
// dropped frame, harness gap).
|
|
298
343
|
export type StatusSnapshotMessage = {
|
|
299
344
|
type: 'status_snapshot'
|
|
300
|
-
|
|
345
|
+
sessions: { workspaceId: string; sessionId: string; activity: SessionActivity }[]
|
|
301
346
|
}
|
|
302
347
|
|
|
303
348
|
export type WorkspaceSwitchMessage = {
|
|
@@ -307,6 +352,12 @@ export type WorkspaceSwitchMessage = {
|
|
|
307
352
|
|
|
308
353
|
export type WorkspaceType = 'claude-code' | 'openclaw' | 'codex'
|
|
309
354
|
|
|
355
|
+
// Whether an agent backend's runtime is installed on this machine. `reason` is
|
|
356
|
+
// user-facing copy explaining what to do next. Surfaced by
|
|
357
|
+
// GET /api/workspaces/create (per-type map, drives setup dialogs) and
|
|
358
|
+
// GET /api/workspaces/:id/availability (disables Send in existing workspaces).
|
|
359
|
+
export type HarnessAvailability = { available: true } | { available: false; reason: string }
|
|
360
|
+
|
|
310
361
|
// One MCP server's connection status, as surfaced by GET /api/workspaces/:id/mcp
|
|
311
362
|
// (a subset of the agent SDK's McpServerStatus — only what the UI renders).
|
|
312
363
|
export type McpServerState = 'connected' | 'failed' | 'needs-auth' | 'pending' | 'disabled'
|
|
@@ -340,12 +391,9 @@ export type WorkspaceEntry = {
|
|
|
340
391
|
|
|
341
392
|
export type DiscoveredWorkspace = {
|
|
342
393
|
path: string
|
|
343
|
-
type: WorkspaceType
|
|
344
|
-
name?: string
|
|
345
394
|
displayPath?: string
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
lastRunAt?: string
|
|
395
|
+
// Deduplicated in canonical provider order by the discovery API.
|
|
396
|
+
types: WorkspaceType[]
|
|
349
397
|
}
|
|
350
398
|
|
|
351
399
|
export type SessionRenamedMessage = {
|
|
@@ -368,11 +416,20 @@ export type StoppedFrame = {
|
|
|
368
416
|
sessionId: string
|
|
369
417
|
}
|
|
370
418
|
|
|
419
|
+
// Unified per-session activity state, mirrored from each harness's native
|
|
420
|
+
// lifecycle signal (CC `session_state_changed`, Codex `turn/*`, OpenClaw run
|
|
421
|
+
// lifecycle) rather than derived by counting messages:
|
|
422
|
+
// running — the agent is working; the client shows the loader/Stop
|
|
423
|
+
// requires-action — the agent is blocked on user input (permission prompt,
|
|
424
|
+
// MCP elicitation). Not rendered yet: no loader, no Stop.
|
|
425
|
+
// idle — everything else, including interrupted/failed turns
|
|
426
|
+
export type SessionActivity = 'idle' | 'running' | 'requires-action'
|
|
427
|
+
|
|
371
428
|
export type StatusMessage = {
|
|
372
429
|
type: 'status'
|
|
373
430
|
workspaceId: string
|
|
374
431
|
sessionId: string
|
|
375
|
-
|
|
432
|
+
activity: SessionActivity
|
|
376
433
|
}
|
|
377
434
|
|
|
378
435
|
// Workspace layout persistence
|
|
@@ -427,11 +484,36 @@ export type WorkspaceLayout = {
|
|
|
427
484
|
background?: string
|
|
428
485
|
foreground?: string
|
|
429
486
|
}
|
|
487
|
+
// Widget thumbnails captured client-side from the live grid, used for
|
|
488
|
+
// home-screen previews. Saved through their own endpoint (PUT
|
|
489
|
+
// .../thumbnails), never through the layout PUT.
|
|
490
|
+
widgetThumbnails?: WidgetThumbnails
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export type WidgetThumbnails = {
|
|
494
|
+
// Fingerprint of the grid state the set was captured from (visible widget
|
|
495
|
+
// ids + their bundle tags — see widgetThumbnailsKey()). A mismatch with the
|
|
496
|
+
// live grid re-captures the whole set.
|
|
497
|
+
key?: string
|
|
498
|
+
// Server-stamped ISO time of the last save. Widget DATA drifts even when
|
|
499
|
+
// bundles don't (a dashboard captured in January still shows January), so
|
|
500
|
+
// an old-enough set re-captures despite a matching key.
|
|
501
|
+
at?: string
|
|
502
|
+
// Widget id → WebP data URL (white background, the widget's own aspect
|
|
503
|
+
// ratio). Entries merge, never prune: a removed widget keeps its last image
|
|
504
|
+
// in case it comes back. Heavy — the layout GET strips this field; images
|
|
505
|
+
// reach the home screen via the preview endpoint.
|
|
506
|
+
images?: Record<string, string>
|
|
430
507
|
}
|
|
431
508
|
|
|
509
|
+
// Home-screen workspace card preview: a few captured widget thumbnails (WebP
|
|
510
|
+
// data URLs) from the stored layout, rendered as a loose stack, plus the latest
|
|
511
|
+
// provider session activity. A workspace with no widgets may instead carry its
|
|
512
|
+
// oldest thread's first user message.
|
|
432
513
|
export type WorkspacePreview = {
|
|
433
|
-
|
|
434
|
-
|
|
514
|
+
thumbnails: string[]
|
|
515
|
+
firstUserMessage?: string
|
|
516
|
+
updatedAt?: number
|
|
435
517
|
}
|
|
436
518
|
|
|
437
519
|
// One effective env var, as surfaced by GET /api/workspaces/:id/env. Values are
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// View-builder bootstrap instructions, delivered as one-shot directives inside
|
|
2
|
+
// the `<moi-context>` envelope (lib/moi-context.ts) via SendMessageInput's
|
|
3
|
+
// `context` channel — see the view-builder POST route in server/api.ts.
|
|
4
|
+
export function viewBuilderDirectives(builderId: string, availableIcons: string[]): string[] {
|
|
5
|
+
return [
|
|
6
|
+
'View builder request — this chat is linked to a pending view tab.',
|
|
7
|
+
`Builder id: ${builderId}`,
|
|
8
|
+
`Available view icons: ${availableIcons.join(', ')}`,
|
|
9
|
+
'Your first action must be to infer a stable view id, sentence-case title, and relevant icon from the requirements, then run:',
|
|
10
|
+
`moi builder set <view-id> --builder ${builderId} --kind view --title "<title>" --icon <icon-id>`,
|
|
11
|
+
'Do this before reading files, planning, or writing code. Choose the icon id from the available view icons above.',
|
|
12
|
+
'Capitalize only the first word of the title.',
|
|
13
|
+
'Use the same icon id in the view config.',
|
|
14
|
+
'After building the view, run `moi bundle --only views`.'
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WorkspaceType } from './types'
|
|
2
|
+
|
|
3
|
+
export const WORKSPACE_TYPE_ORDER = [
|
|
4
|
+
'claude-code',
|
|
5
|
+
'codex',
|
|
6
|
+
'openclaw'
|
|
7
|
+
] as const satisfies readonly WorkspaceType[]
|
|
8
|
+
|
|
9
|
+
export function orderWorkspaceTypes(types: Iterable<WorkspaceType>): WorkspaceType[] {
|
|
10
|
+
const unique = new Set(types)
|
|
11
|
+
return WORKSPACE_TYPE_ORDER.filter(type => unique.has(type))
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moi-computer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1-next.1",
|
|
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",
|
|
@@ -75,7 +75,9 @@
|
|
|
75
75
|
"highlight.js": "^10.7.3",
|
|
76
76
|
"hono": "^4.12.26",
|
|
77
77
|
"lru-cache": "^11.3.5",
|
|
78
|
+
"modern-screenshot": "^4.7.0",
|
|
78
79
|
"motion": "^12.35.1",
|
|
80
|
+
"nanoid": "^6.0.0",
|
|
79
81
|
"pathe": "^2.0.3",
|
|
80
82
|
"picocolors": "^1.1.1",
|
|
81
83
|
"postcss": "^8.5.19",
|
|
@@ -98,7 +100,7 @@
|
|
|
98
100
|
"zustand": "^5.0.12"
|
|
99
101
|
},
|
|
100
102
|
"optionalDependencies": {
|
|
101
|
-
"openclaw": "2026.
|
|
103
|
+
"openclaw": "2026.7.1"
|
|
102
104
|
},
|
|
103
105
|
"devDependencies": {
|
|
104
106
|
"@types/bun": "latest",
|