moi-computer 0.9.0 → 0.9.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/app-config.ts +51 -0
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/routes/WorkspaceRoute.tsx +4 -2
- package/client/assets/hermes.png +0 -0
- package/client/components/shared/IconGhost.tsx +15 -18
- package/client/components/ui/button.tsx +2 -2
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/popover.tsx +3 -1
- package/client/features/applets/api.ts +38 -0
- package/client/features/applets/applet-thumbnail.ts +208 -0
- package/client/features/chat/ChatEmptyState.tsx +30 -10
- package/client/features/chat/ChatPanel.tsx +67 -31
- package/client/features/chat/ChatPopup.tsx +3 -2
- package/client/features/chat/ChatPromptBubbles.tsx +1 -1
- package/client/features/chat/ChatSelector.tsx +29 -10
- package/client/features/chat/MarkdownContent.tsx +3 -3
- package/client/features/chat/attachment-staging.ts +153 -0
- package/client/features/chat/chat-send.ts +55 -0
- package/client/features/chat/chat-store.ts +32 -8
- package/client/features/chat/composer/ChatComposer.tsx +190 -77
- package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
- package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
- package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
- package/client/features/chat/tool-group/format/claude.ts +48 -0
- package/client/features/chat/tool-group/format/codex.ts +126 -0
- package/client/features/chat/tool-group/format/hermes.ts +68 -0
- package/client/features/chat/tool-group/format/index.ts +34 -0
- package/client/features/chat/tool-group/format/mcp.ts +64 -0
- package/client/features/chat/tool-group/format/openclaw.ts +116 -0
- package/client/features/chat/tool-group/format/shared.ts +49 -0
- package/client/features/chat/useChat.ts +5 -10
- package/client/features/drawings/DrawingLayer.tsx +49 -0
- package/client/features/drawings/DrawingToolbar.tsx +95 -0
- package/client/features/drawings/capture-element.ts +45 -0
- package/client/features/drawings/useChatAnnotation.ts +222 -0
- package/client/features/drawings/useDrawingLayer.ts +758 -0
- package/client/features/drawings/useViewBuilderSketch.ts +151 -0
- package/client/features/home/HomePage.tsx +13 -0
- package/client/features/home/WorkspacePreview.tsx +10 -5
- package/client/features/home/workspace-presentation.tsx +6 -2
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
- package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +13 -7
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
- package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
- package/client/features/views/ViewBuilder.tsx +238 -0
- package/client/features/views/ViewManager.tsx +18 -2
- package/client/features/views/api.ts +1 -0
- package/client/features/views/useViewBuilderActions.ts +24 -3
- package/client/features/views/useViewBuilderDrafts.ts +66 -0
- package/client/features/widgets/WidgetFrame.tsx +1 -1
- package/client/features/widgets/WidgetGrid.tsx +1 -1
- package/client/features/widgets/Widgets.tsx +39 -54
- package/client/features/workspace/CustomizePanel.tsx +30 -9
- package/client/features/workspace/WorkspaceScreen.tsx +158 -64
- package/client/features/workspace/WorkspaceTabs.tsx +3 -3
- package/client/features/workspace/useFitsSplitLayout.ts +14 -8
- package/client/index.css +8 -0
- package/client/index.tsx +6 -1
- package/client/runtime/useWorkspaceEvents.ts +17 -0
- package/client/runtime/workspace-theme.ts +29 -6
- package/client/store/ui.ts +19 -0
- package/client/theme.css +33 -8
- package/dist/chunk-5c19v3zr.js +10 -0
- package/dist/chunk-6wx91x8j.js +1 -0
- package/dist/chunk-8s41nd3g.js +1 -0
- package/dist/{chunk-kkj86722.js → chunk-a7fzp0z0.js} +78 -78
- package/dist/{chunk-2vaafjp4.js → chunk-b959mdkj.js} +1 -1
- package/dist/chunk-cagtq45k.js +1 -0
- package/dist/chunk-cva7jpt4.js +82 -0
- package/dist/chunk-sapvd7he.css +1 -0
- package/dist/{chunk-35fq49qa.js → chunk-zbeq02yc.js} +1 -1
- package/dist/chunk-zbt8emsw.js +2 -0
- package/dist/chunk-zfz3b4xg.js +2 -0
- package/dist/hermes-pznd63x9.png +0 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +1 -1
- package/lib/themes.ts +8 -8
- package/lib/types.ts +68 -42
- package/lib/workspace-types.ts +2 -1
- package/package.json +2 -1
- package/server/api.ts +90 -33
- package/server/app-config.ts +144 -0
- package/server/applets.ts +17 -0
- package/server/cli.ts +235 -14
- package/server/harness/README.md +64 -17
- package/server/harness/acp/adapter.ts +220 -0
- package/server/harness/acp/archived.ts +88 -0
- package/server/harness/acp/client.ts +328 -0
- package/server/harness/acp/discovery.ts +130 -0
- package/server/harness/acp/run-durations.ts +68 -0
- package/server/harness/acp/session.ts +788 -0
- package/server/harness/acp/wire.ts +132 -0
- package/server/harness/executable.ts +15 -1
- package/server/harness/hermes/NOTES.md +815 -0
- package/server/harness/hermes/discovery.ts +155 -0
- package/server/harness/hermes/index.ts +155 -0
- package/server/harness/hermes/models.ts +79 -0
- package/server/harness/registry.ts +3 -1
- package/server/layout.ts +40 -45
- package/server/moi-scaffold.ts +37 -1
- package/server/thumbnails.ts +197 -0
- package/server/view-builders.ts +4 -2
- package/server/views.ts +10 -1
- package/server/widgets.ts +4 -18
- package/server/workspace-import.ts +30 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
- package/client/features/chat/tool-group/format.ts +0 -384
- package/client/features/views/ViewBuilderTab.tsx +0 -152
- package/client/features/widgets/api.ts +0 -47
- package/client/features/widgets/useWidgetThumbnails.ts +0 -107
- package/client/features/widgets/widget-snapshot.ts +0 -71
- package/dist/chunk-3b3rkjet.js +0 -1
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-ty1sqbmn.js +0 -80
- package/dist/chunk-xeyxk7ep.js +0 -10
- package/dist/chunk-yz6wd5vc.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var j=Object.create;var{getPrototypeOf:k,defineProperty:f,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,s=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of l(a))if(!m.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0});if(g)h.set(a,d);return d};var t=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var u=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var v=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
|
|
2
|
-
export{s as
|
|
2
|
+
export{s as Sc,t as Tc,u as Uc,v as Vc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Oc as w,Qc as s}from"/chunk-zfz3b4xg.js";import{Sc as q}from"/chunk-zbeq02yc.js";var R=q(w(),1);async function i(o,t){let a=await o.text();return Error(a||t)}async function u(o,t,a="Request failed"){let n=await fetch(o,t);if(!n.ok)throw await i(n,a);return n.json()}async function T(o,t,a="Request failed"){let n=await fetch(o,t);if(!n.ok)throw await i(n,a)}function y(o,t){return{method:o,headers:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)}}var r={cloudDemo:!1,experiments:[],demoInstallUrl:"https://moi.computer"},d=r,e=new Set;function I(o){return e.add(o),()=>{e.delete(o)}}async function f(){try{d=await u("/api/config");for(let o of e)o()}catch{}}async function c(){await f(),s(()=>{f()})}function h(){return R.useSyncExternalStore(I,()=>d)}
|
|
2
|
+
export{u as Jc,T as Kc,y as Lc,c as Mc,h as Nc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Sc as H,Tc as w}from"/chunk-zbeq02yc.js";var t=w((S,b)=>{b.exports=globalThis.__esm.react});var a=H(t(),1);function y(o){return`${location.protocol==="https:"?"wss":"ws"}://${location.host}${o}`}var i=new Set,T=new Set,$=!1,p=null,h=!1;function u(){if(p||h)return;h=!0;let o=new WebSocket(y("/api/workspaces/ws"));o.onopen=()=>{if(p=o,h=!1,$)for(let m of T)m();$=!0},o.onmessage=(m)=>{try{let g=JSON.parse(m.data);for(let x of i)x(g)}catch{}},o.onclose=()=>{if(p=null,h=!1,i.size>0)setTimeout(u,2000)},o.onerror=()=>{o.close()}}function B(o){return T.add(o),()=>{T.delete(o)}}function P(o){let m=a.useRef(o);m.current=o,a.useEffect(()=>{let g=(x)=>m.current(x);return i.add(g),u(),()=>{if(i.delete(g),i.size===0&&p)p.close(),p=null}},[])}
|
|
2
|
+
export{t as Oc,y as Pc,B as Qc,P as Rc};
|
|
Binary file
|
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-sapvd7he.css"><script type="module" crossorigin src="/chunk-6wx91x8j.js"></script></head>
|
|
25
25
|
<body>
|
|
26
26
|
<div id="root"></div>
|
|
27
27
|
|
package/lib/format.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type ToolCall = {
|
|
|
36
36
|
// for the same canonical action (`read` vs `Read`, `exec` vs `Bash`).
|
|
37
37
|
// Adapters are responsible for setting it; UI defaults to a generic
|
|
38
38
|
// rendering when absent.
|
|
39
|
-
provider?: 'claude-code' | 'openclaw' | 'codex'
|
|
39
|
+
provider?: 'claude-code' | 'openclaw' | 'codex' | 'hermes'
|
|
40
40
|
mcpServer?: string
|
|
41
41
|
state: ToolState
|
|
42
42
|
input: unknown
|
package/lib/themes.ts
CHANGED
|
@@ -104,24 +104,24 @@ const THEME_COLOR_DERIVATIONS = {
|
|
|
104
104
|
workspace: {
|
|
105
105
|
primary: primary => primary,
|
|
106
106
|
primaryForeground: primary => foregroundForPrimary(primary),
|
|
107
|
-
background: () => 'color-mix(var(--primary) 3%, oklch(1 0 0) 97%)',
|
|
107
|
+
background: () => 'color-mix(in oklch, var(--primary) 3%, oklch(1 0 0) 97%)',
|
|
108
108
|
foreground: () => 'color-mix(var(--primary) 20%, oklch(0 0 0) 80%)',
|
|
109
|
-
muted: () => 'color-mix(var(--background)
|
|
109
|
+
muted: () => 'color-mix(in oklch, var(--background) 97%, var(--foreground) 3%)',
|
|
110
110
|
mutedForeground: () => 'color-mix(var(--background) 50%, var(--foreground) 50%)',
|
|
111
|
-
accent: () => 'color-mix(var(--primary) 4%, var(--foreground) 4%)',
|
|
111
|
+
accent: () => 'color-mix(in oklch, var(--primary) 4%, var(--foreground) 4%)',
|
|
112
112
|
accentForeground: () => 'var(--foreground)',
|
|
113
|
-
border: () => 'color-mix(var(--foreground) 7%, transparent)'
|
|
113
|
+
border: () => 'color-mix(in oklch, var(--foreground) 7%, transparent)'
|
|
114
114
|
},
|
|
115
115
|
widget: {
|
|
116
116
|
background: primary => primary,
|
|
117
117
|
foreground: primary => foregroundForPrimary(primary),
|
|
118
|
-
primary: () => 'color-mix(var(--background) 3%, oklch(1 0 0) 97%)',
|
|
118
|
+
primary: () => 'color-mix(in oklch, var(--background) 3%, oklch(1 0 0) 97%)',
|
|
119
119
|
primaryForeground: () => 'color-mix(var(--background) 20%, oklch(0 0 0) 80%)',
|
|
120
|
-
muted: () => 'color-mix(var(--background) 97%, var(--foreground) 3%)',
|
|
120
|
+
muted: () => 'color-mix(in oklch, var(--background) 97%, var(--foreground) 3%)',
|
|
121
121
|
mutedForeground: () => 'color-mix(var(--background) 50%, var(--foreground) 50%)',
|
|
122
|
-
accent: () => 'color-mix(var(--primary) 4%, var(--foreground) 4%)',
|
|
122
|
+
accent: () => 'color-mix(in oklch, var(--primary) 4%, var(--foreground) 4%)',
|
|
123
123
|
accentForeground: () => 'var(--foreground)',
|
|
124
|
-
border: () => 'color-mix(var(--foreground) 15%, transparent)'
|
|
124
|
+
border: () => 'color-mix(in oklch, var(--foreground) 15%, transparent)'
|
|
125
125
|
}
|
|
126
126
|
} satisfies Record<ThemeColorMode, Record<string, (primary: string) => string>>
|
|
127
127
|
|
package/lib/types.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { PreviewBlock, StreamEvent } from './format'
|
|
2
2
|
|
|
3
|
+
// A custom UI unit embedded in a workspace.
|
|
4
|
+
export type AppletKind = 'view' | 'widget'
|
|
5
|
+
|
|
6
|
+
export type AppletInfo = {
|
|
7
|
+
id: string
|
|
8
|
+
// Content revision of the built bundle (`<size>-<mtime>` of index.js).
|
|
9
|
+
// Absent when the build output cannot be statted.
|
|
10
|
+
revision?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
export type WidgetConfig = {
|
|
4
14
|
rowSpan: 1 | 2 | 3 | 4
|
|
5
15
|
colSpan: 1 | 2 | 3 | 4
|
|
@@ -9,14 +19,8 @@ export type WidgetConfig = {
|
|
|
9
19
|
requiredEnv?: string[]
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
export type WidgetInfo = {
|
|
13
|
-
id: string
|
|
22
|
+
export type WidgetInfo = AppletInfo & {
|
|
14
23
|
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
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
// A view is a full-screen, agent-authored "app" (`.moi/views/<name>.tsx`),
|
|
@@ -31,19 +35,12 @@ export type ViewConfig = {
|
|
|
31
35
|
requiredEnv?: string[]
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
export type ViewInfo = {
|
|
35
|
-
id: string
|
|
38
|
+
export type ViewInfo = AppletInfo & {
|
|
36
39
|
config: ViewConfig
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export type ViewBuilderStatus = 'draft' | 'building' | 'waiting' | 'ready'
|
|
40
43
|
|
|
41
|
-
// The kind of an applet — a custom UI unit embedded in a workspace. Shared by
|
|
42
|
-
// the bundler pipeline and the build-status records. On a builder record the
|
|
43
|
-
// field is absent for rows written before it existed; treat a missing kind as
|
|
44
|
-
// 'view' (only views surface in the UI — the view builder page is view-only).
|
|
45
|
-
export type AppletKind = 'view' | 'widget'
|
|
46
|
-
|
|
47
44
|
export type ViewBuilderInput = {
|
|
48
45
|
requirements: string
|
|
49
46
|
}
|
|
@@ -288,6 +285,20 @@ export type AppSettings = {
|
|
|
288
285
|
autoUpdateSkills: boolean
|
|
289
286
|
}
|
|
290
287
|
|
|
288
|
+
// Client-safe subset of the startup config (`config.json` in the data dir +
|
|
289
|
+
// `MOI_*` env overrides), served by GET /api/config. Frozen for the process
|
|
290
|
+
// lifetime — changing it requires a server restart, so clients may cache it
|
|
291
|
+
// forever. See server/app-config.ts.
|
|
292
|
+
export type ClientAppConfig = {
|
|
293
|
+
// Cloud demo deployment: workspace creation is blocked; the UI offers the
|
|
294
|
+
// install-moi dialog instead.
|
|
295
|
+
cloudDemo: boolean
|
|
296
|
+
// Enabled experimental features, checked by slug.
|
|
297
|
+
experiments: string[]
|
|
298
|
+
// Link target for the install-moi dialog in the cloud demo.
|
|
299
|
+
demoInstallUrl: string
|
|
300
|
+
}
|
|
301
|
+
|
|
291
302
|
// Re-export the display format
|
|
292
303
|
export type {
|
|
293
304
|
Citation,
|
|
@@ -381,7 +392,7 @@ export type WorkspaceSwitchMessage = {
|
|
|
381
392
|
workspaceId: string
|
|
382
393
|
}
|
|
383
394
|
|
|
384
|
-
export type WorkspaceType = 'claude-code' | 'openclaw' | 'codex'
|
|
395
|
+
export type WorkspaceType = 'claude-code' | 'openclaw' | 'codex' | 'hermes'
|
|
385
396
|
|
|
386
397
|
export type WorkspaceSkillStatus = {
|
|
387
398
|
name: string
|
|
@@ -551,32 +562,40 @@ export type WorkspaceLayout = {
|
|
|
551
562
|
// Fast-mode default for new sessions. Undefined inherits the provider setting.
|
|
552
563
|
selectedFastMode?: boolean
|
|
553
564
|
theme?: import('./themes').WorkspaceTheme
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
//
|
|
566
|
-
//
|
|
567
|
-
//
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// One applet's thumbnail freshness record. Image bytes live as files in the
|
|
568
|
+
// workspace's `.moi/.cache/thumbnails/` (server/thumbnails.ts), never in
|
|
569
|
+
// `.workspace.json` — the layout file stays small and commit-safe.
|
|
570
|
+
export type AppletThumbnail = {
|
|
571
|
+
kind: AppletKind
|
|
572
|
+
id: string
|
|
573
|
+
revision: string
|
|
574
|
+
capturedAt: string
|
|
575
|
+
viewedAt: string
|
|
576
|
+
// How long the last successful capture took on this client, in ms. Lets the
|
|
577
|
+
// capture hook skip routine re-captures of applets that are slow to
|
|
578
|
+
// screenshot (see SLOW_CAPTURE_MS) instead of janking the main thread.
|
|
579
|
+
captureMs?: number
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
export type AppletThumbnailUpdate = {
|
|
583
|
+
id: string
|
|
584
|
+
revision: string
|
|
585
|
+
// A string replaces the stored image, null records a failed or skipped
|
|
586
|
+
// attempt (the previous image survives), undefined only touches recency.
|
|
587
|
+
image?: string | null
|
|
588
|
+
captureMs?: number
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export type AppletThumbnailBatch = {
|
|
592
|
+
kind: AppletKind
|
|
593
|
+
thumbnails: AppletThumbnailUpdate[]
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// Home-screen workspace card preview: widgets in grid order, then recent views,
|
|
597
|
+
// capped to the loose stack's visible depth. A workspace with no captured
|
|
598
|
+
// applets may instead carry its oldest session's first message.
|
|
580
599
|
export type WorkspacePreview = {
|
|
581
600
|
thumbnails: string[]
|
|
582
601
|
firstUserMessage?: string
|
|
@@ -626,6 +645,13 @@ export type Model = {
|
|
|
626
645
|
displayName: string
|
|
627
646
|
// " · "-joined blurb (Claude): "<headline> · <tagline> · …". Absent for OpenClaw.
|
|
628
647
|
description?: string
|
|
648
|
+
// Heading this model sits under in the picker (Hermes: the upstream provider,
|
|
649
|
+
// e.g. 'Ollama'). Absent when the backend serves one flat catalog.
|
|
650
|
+
group?: string
|
|
651
|
+
// Machine id of that group (Hermes: 'ollama-launch' for the 'Ollama' heading).
|
|
652
|
+
// Unlike `group`, the backend does not reword it — use it as the key whenever
|
|
653
|
+
// a provider needs pinning, ordering or storing.
|
|
654
|
+
providerId?: string
|
|
629
655
|
// Effort/reasoning support (Claude). `supportedEffortLevels` can include values
|
|
630
656
|
// the SDK under-types (e.g. 'xhigh'), so it stays string[].
|
|
631
657
|
supportsEffort?: boolean
|
package/lib/workspace-types.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { WorkspaceType } from './types'
|
|
|
3
3
|
export const WORKSPACE_TYPE_ORDER = [
|
|
4
4
|
'claude-code',
|
|
5
5
|
'codex',
|
|
6
|
-
'openclaw'
|
|
6
|
+
'openclaw',
|
|
7
|
+
'hermes'
|
|
7
8
|
] as const satisfies readonly WorkspaceType[]
|
|
8
9
|
|
|
9
10
|
export function orderWorkspaceTypes(types: Iterable<WorkspaceType>): WorkspaceType[] {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moi-computer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"openclaw": "2026.7.1"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
+
"@agentclientprotocol/sdk": "^1.3.0",
|
|
109
110
|
"@babel/types": "^7.29.8",
|
|
110
111
|
"@types/bun": "latest",
|
|
111
112
|
"@types/culori": "^4.0.1",
|
package/server/api.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { basename, join, resolve } from 'node:path'
|
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
8
|
AppletKind,
|
|
9
|
+
AppletThumbnailBatch,
|
|
9
10
|
AppSettings,
|
|
10
11
|
HarnessAvailability,
|
|
11
12
|
SessionInfo,
|
|
@@ -19,6 +20,7 @@ import type { MoiContext } from '@/lib/moi-context'
|
|
|
19
20
|
import { viewBuilderDirectives } from '@/lib/view-builder-directives'
|
|
20
21
|
|
|
21
22
|
import { agentStore } from './agent'
|
|
23
|
+
import { clientAppConfig, getAppConfig } from './app-config'
|
|
22
24
|
import { getAppSettings, pickAppSettingsPatch, saveAppSettings } from './app-settings'
|
|
23
25
|
import { appletForModule, recordAppletError } from './applet-log'
|
|
24
26
|
import { apiBaseFor, parseAppletTail, serveWorkspaceFile } from './applets'
|
|
@@ -26,13 +28,13 @@ import { applyEnvChanged } from './env-apply'
|
|
|
26
28
|
import { publishEvent } from './events'
|
|
27
29
|
import { callFunction, parseFunctionPath } from './functions'
|
|
28
30
|
import { processIcon } from './icon'
|
|
31
|
+
import { getWorkspacePreview, loadLayout, mergeLayoutForSave, saveLayout } from './layout'
|
|
29
32
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} from './layout'
|
|
33
|
+
getAppletThumbnailRecords,
|
|
34
|
+
isValidAppletId,
|
|
35
|
+
saveAppletThumbnails,
|
|
36
|
+
serveAppletThumbnail
|
|
37
|
+
} from './thumbnails'
|
|
36
38
|
import { getClientFrameLog, getWireLog } from './harness/debug'
|
|
37
39
|
import { allHarnesses, harnessFor, isHarnessType } from './harness/registry'
|
|
38
40
|
import { broadcast } from './state'
|
|
@@ -150,10 +152,16 @@ one.use('*', withWorkspace)
|
|
|
150
152
|
|
|
151
153
|
one.get('/preview', async c => {
|
|
152
154
|
const ws = c.get('ws')
|
|
155
|
+
const wsId = c.req.param('id')
|
|
156
|
+
const views = await getViewList(ws.path)
|
|
153
157
|
return c.json(
|
|
154
|
-
await getWorkspacePreview(ws.path,
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
await getWorkspacePreview(ws.path, {
|
|
159
|
+
getProviderPreview: includeFirstUserMessage =>
|
|
160
|
+
harnessFor(ws).workspacePreview(ws, includeFirstUserMessage),
|
|
161
|
+
viewIds: views.map(view => view.id),
|
|
162
|
+
thumbnailUrl: (kind, id) =>
|
|
163
|
+
`/api/workspaces/${wsId}/applet-thumbnails/${kind}/${encodeURIComponent(id)}`
|
|
164
|
+
})
|
|
157
165
|
)
|
|
158
166
|
})
|
|
159
167
|
|
|
@@ -250,6 +258,7 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
250
258
|
fastMode?: boolean
|
|
251
259
|
stream?: boolean
|
|
252
260
|
availableIcons?: unknown
|
|
261
|
+
attachments?: unknown
|
|
253
262
|
}>()
|
|
254
263
|
if (typeof body?.input?.requirements !== 'string') {
|
|
255
264
|
return c.text('Expected { input: { requirements: string } }', 400)
|
|
@@ -259,6 +268,17 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
259
268
|
}
|
|
260
269
|
const availableIcons = parseAvailableViewIcons(body.availableIcons)
|
|
261
270
|
if (!availableIcons) return c.text('Available view icons are required', 400)
|
|
271
|
+
const attachments = body.attachments ?? []
|
|
272
|
+
if (
|
|
273
|
+
!Array.isArray(attachments) ||
|
|
274
|
+
attachments.length > 1 ||
|
|
275
|
+
!attachments.every(id => typeof id === 'string' && /^[a-f0-9]{64}$/.test(id))
|
|
276
|
+
) {
|
|
277
|
+
return c.text('Invalid sketch attachment', 400)
|
|
278
|
+
}
|
|
279
|
+
if (attachments.some(id => getUpload(ws.id, id)?.kind !== 'image')) {
|
|
280
|
+
return c.text('Sketch attachment not found or expired', 400)
|
|
281
|
+
}
|
|
262
282
|
const availability = await workspaceTypeAvailability(ws.type ?? 'claude-code')
|
|
263
283
|
if (!availability.available) return c.text(availability.reason, 400)
|
|
264
284
|
try {
|
|
@@ -266,14 +286,20 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
266
286
|
ws.id,
|
|
267
287
|
ws.path,
|
|
268
288
|
c.req.param('builderId'),
|
|
269
|
-
body.input.requirements
|
|
289
|
+
body.input.requirements,
|
|
290
|
+
attachments.length > 0
|
|
270
291
|
)
|
|
271
292
|
// The bootstrap instructions ride the moi-context envelope, injected by
|
|
272
293
|
// the harness like any other ambient context; the user text stays bare.
|
|
273
294
|
// The user submits from the builder's own tab, so that's the active tab.
|
|
274
295
|
const context: MoiContext = {
|
|
275
296
|
activeTab: `view-builder:${builder.id}`,
|
|
276
|
-
directives:
|
|
297
|
+
directives: [
|
|
298
|
+
...viewBuilderDirectives(builder.id, availableIcons),
|
|
299
|
+
...(attachments.length > 0
|
|
300
|
+
? ["The attached image is the user's sketch of the intended view layout."]
|
|
301
|
+
: [])
|
|
302
|
+
]
|
|
277
303
|
}
|
|
278
304
|
try {
|
|
279
305
|
publishSelectedSession(ws.id, await saveSelectedSession(ws.path, builder.sessionId))
|
|
@@ -283,6 +309,7 @@ one.post('/view-builders/:builderId/submit', async c => {
|
|
|
283
309
|
sessionId: builder.sessionId,
|
|
284
310
|
isNew: true,
|
|
285
311
|
content: builder.input.requirements,
|
|
312
|
+
attachments,
|
|
286
313
|
context,
|
|
287
314
|
optimisticId: body.optimisticId,
|
|
288
315
|
model: typeof body.model === 'string' ? body.model : undefined,
|
|
@@ -808,16 +835,9 @@ one.delete('/icon', async c => {
|
|
|
808
835
|
// DELETE unregisters.
|
|
809
836
|
one.get('/', async c => {
|
|
810
837
|
const ws = c.get('ws')
|
|
811
|
-
|
|
812
|
-
// path (PUT .../thumbnails); the layout ships `widgetThumbnails` without
|
|
813
|
-
// them — just `key`/`at`, which clients compare against the live grid to
|
|
814
|
-
// decide when to re-capture.
|
|
815
|
-
const { widgetThumbnails, ...layout } = await loadLayout(ws.path)
|
|
838
|
+
const layout = await loadLayout(ws.path)
|
|
816
839
|
return c.json({
|
|
817
840
|
...layout,
|
|
818
|
-
...(widgetThumbnails && {
|
|
819
|
-
widgetThumbnails: { key: widgetThumbnails.key, at: widgetThumbnails.at }
|
|
820
|
-
}),
|
|
821
841
|
// Resolved display name: the settings override, or the folder name.
|
|
822
842
|
name: layout.name || basename(ws.path),
|
|
823
843
|
cwd: ws.path,
|
|
@@ -826,21 +846,46 @@ one.get('/', async c => {
|
|
|
826
846
|
})
|
|
827
847
|
})
|
|
828
848
|
|
|
829
|
-
//
|
|
830
|
-
//
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
849
|
+
// Thumbnail freshness records, without image bytes — the capture hook compares
|
|
850
|
+
// these against live bundle revisions. Images are served per-applet below.
|
|
851
|
+
one.get('/applet-thumbnails', async c =>
|
|
852
|
+
c.json({ thumbnails: await getAppletThumbnailRecords(c.get('ws').path) })
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
one.get('/applet-thumbnails/:kind/:name', c => {
|
|
856
|
+
const kind = c.req.param('kind')
|
|
857
|
+
if (kind !== 'widget' && kind !== 'view') return c.text('Not found', 404)
|
|
858
|
+
return serveAppletThumbnail(
|
|
859
|
+
c.get('ws').path,
|
|
860
|
+
kind,
|
|
861
|
+
c.req.param('name'),
|
|
862
|
+
c.req.header('if-none-match')
|
|
863
|
+
)
|
|
864
|
+
})
|
|
865
|
+
|
|
866
|
+
// Settled widget and view visits share one batch endpoint and storage path.
|
|
867
|
+
one.put('/applet-thumbnails', async c => {
|
|
835
868
|
const body: unknown = await c.req.json().catch(() => null)
|
|
836
|
-
if (!body || typeof body !== 'object') return c.text('Bad request', 400)
|
|
837
|
-
const
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
869
|
+
if (!body || typeof body !== 'object' || Array.isArray(body)) return c.text('Bad request', 400)
|
|
870
|
+
const input = body as AppletThumbnailBatch
|
|
871
|
+
const valid =
|
|
872
|
+
(input.kind === 'widget' || input.kind === 'view') &&
|
|
873
|
+
Array.isArray(input.thumbnails) &&
|
|
874
|
+
input.thumbnails.every(
|
|
875
|
+
thumbnail =>
|
|
876
|
+
thumbnail &&
|
|
877
|
+
typeof thumbnail === 'object' &&
|
|
878
|
+
!Array.isArray(thumbnail) &&
|
|
879
|
+
typeof thumbnail.id === 'string' &&
|
|
880
|
+
isValidAppletId(thumbnail.id) &&
|
|
881
|
+
typeof thumbnail.revision === 'string' &&
|
|
882
|
+
(thumbnail.image === undefined ||
|
|
883
|
+
thumbnail.image === null ||
|
|
884
|
+
typeof thumbnail.image === 'string') &&
|
|
885
|
+
(thumbnail.captureMs === undefined || typeof thumbnail.captureMs === 'number')
|
|
886
|
+
)
|
|
887
|
+
if (!valid) return c.text('Bad request', 400)
|
|
888
|
+
await saveAppletThumbnails(c.get('ws').path, input.kind, input.thumbnails)
|
|
844
889
|
return c.body(null, 204)
|
|
845
890
|
})
|
|
846
891
|
|
|
@@ -898,7 +943,14 @@ workspaces.put('/order', async c => {
|
|
|
898
943
|
}
|
|
899
944
|
})
|
|
900
945
|
|
|
946
|
+
// One message for both creation routes: in the cloud demo the instance is
|
|
947
|
+
// provisioned with its workspaces; the UI never sends these requests (it opens
|
|
948
|
+
// the install-moi dialog instead), so a 403 here means the API was called
|
|
949
|
+
// directly.
|
|
950
|
+
const DEMO_CREATE_BLOCKED = 'Workspace creation is not available in the moi demo'
|
|
951
|
+
|
|
901
952
|
workspaces.post('/', async c => {
|
|
953
|
+
if (getAppConfig().cloudDemo) return c.text(DEMO_CREATE_BLOCKED, 403)
|
|
902
954
|
const body = await c.req.json()
|
|
903
955
|
if (!body?.path) return c.text('Missing path', 400)
|
|
904
956
|
const requestedType: unknown = body?.type ?? 'claude-code'
|
|
@@ -964,6 +1016,7 @@ workspaces.get('/create', async c =>
|
|
|
964
1016
|
// Create a brand-new workspace: a fresh folder under CREATED_WORKSPACES_ROOT,
|
|
965
1017
|
// provisioned (skills + `.moi/` scaffold) and registered.
|
|
966
1018
|
workspaces.post('/create', async c => {
|
|
1019
|
+
if (getAppConfig().cloudDemo) return c.text(DEMO_CREATE_BLOCKED, 403)
|
|
967
1020
|
const body = await c.req.json()
|
|
968
1021
|
const requestedType: unknown = body?.type ?? 'claude-code'
|
|
969
1022
|
if (!isHarnessType(requestedType)) {
|
|
@@ -1002,6 +1055,10 @@ export const api = new Hono()
|
|
|
1002
1055
|
|
|
1003
1056
|
api.route('/api/workspaces', workspaces)
|
|
1004
1057
|
|
|
1058
|
+
// Startup config (config.json in the data dir + MOI_* env), client-safe
|
|
1059
|
+
// subset. Immutable for the process lifetime — clients cache it forever.
|
|
1060
|
+
api.get('/api/config', c => c.json(clientAppConfig()))
|
|
1061
|
+
|
|
1005
1062
|
// App-wide settings (settings.json in the data dir). GET returns every key
|
|
1006
1063
|
// with defaults applied; PATCH merges a partial body and returns the result.
|
|
1007
1064
|
api.get('/api/settings', c => c.json(getAppSettings()))
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
|
|
4
|
+
import type { ClientAppConfig } from '@/lib/types'
|
|
5
|
+
|
|
6
|
+
import { DATA_DIR } from './data-dir'
|
|
7
|
+
|
|
8
|
+
// Startup (deployment) config, read once per process from `config.json` in
|
|
9
|
+
// moi's data dir and overridable by `MOI_*` env vars (env wins). Distinct from
|
|
10
|
+
// `settings.json` (user settings: conf-backed, API-mutable, changes at
|
|
11
|
+
// runtime): config.json describes the deployment itself — nothing here changes
|
|
12
|
+
// without a server restart, and no API writes it.
|
|
13
|
+
//
|
|
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.
|
|
17
|
+
export type AppConfig = {
|
|
18
|
+
// Cloud demo deployment: workspace creation is blocked (UI shows the
|
|
19
|
+
// install-moi dialog instead) and `moi` system commands are disabled.
|
|
20
|
+
cloudDemo: boolean
|
|
21
|
+
// Gated experimental features, checked by slug.
|
|
22
|
+
experiments: string[]
|
|
23
|
+
// Link target for the install-moi dialog in the cloud demo.
|
|
24
|
+
demoInstallUrl: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const DEFAULTS: AppConfig = {
|
|
28
|
+
cloudDemo: false,
|
|
29
|
+
experiments: [],
|
|
30
|
+
demoInstallUrl: 'https://moi.computer'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const APP_CONFIG_FILE = join(DATA_DIR, 'config.json')
|
|
34
|
+
|
|
35
|
+
function warn(message: string): void {
|
|
36
|
+
console.error(`[moi] config: ${message}`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// '1'/'true' (case-insensitive) are true, '0'/'false' are false, anything
|
|
40
|
+
// else — including empty — leaves the lower-precedence value in place.
|
|
41
|
+
function parseBool(raw: string | undefined): boolean | undefined {
|
|
42
|
+
if (raw === undefined) return undefined
|
|
43
|
+
const value = raw.trim().toLowerCase()
|
|
44
|
+
if (value === '1' || value === 'true') return true
|
|
45
|
+
if (value === '0' || value === 'false') return false
|
|
46
|
+
return undefined
|
|
47
|
+
}
|
|
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
|
+
|
|
59
|
+
function parseString(raw: string | undefined): string | undefined {
|
|
60
|
+
if (raw === undefined || raw.trim() === '') return undefined
|
|
61
|
+
return raw.trim()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function fileValues(file: string): Partial<AppConfig> {
|
|
65
|
+
let text: string
|
|
66
|
+
try {
|
|
67
|
+
text = readFileSync(file, 'utf8')
|
|
68
|
+
} catch (err) {
|
|
69
|
+
// Only a missing file is silent (the normal local case). Anything else —
|
|
70
|
+
// permissions, mount errors — is loud: a deployment relying on config.json
|
|
71
|
+
// must not boot un-gated without a diagnostic. Deployments that need the
|
|
72
|
+
// demo gate guaranteed should pin MOI_CLOUD_DEMO=1 in the environment,
|
|
73
|
+
// which has no read-failure mode.
|
|
74
|
+
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
75
|
+
warn(`could not read ${file}: ${err instanceof Error ? err.message : String(err)}`)
|
|
76
|
+
}
|
|
77
|
+
return {}
|
|
78
|
+
}
|
|
79
|
+
let parsed: unknown
|
|
80
|
+
try {
|
|
81
|
+
parsed = JSON.parse(text)
|
|
82
|
+
} catch (err) {
|
|
83
|
+
warn(`ignoring ${file} — invalid JSON: ${err instanceof Error ? err.message : String(err)}`)
|
|
84
|
+
return {}
|
|
85
|
+
}
|
|
86
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
87
|
+
warn(`ignoring ${file} — expected a JSON object`)
|
|
88
|
+
return {}
|
|
89
|
+
}
|
|
90
|
+
const raw = parsed as Record<string, unknown>
|
|
91
|
+
const out: Partial<AppConfig> = {}
|
|
92
|
+
if (raw.cloudDemo !== undefined) {
|
|
93
|
+
if (typeof raw.cloudDemo === 'boolean') out.cloudDemo = raw.cloudDemo
|
|
94
|
+
else warn('ignoring "cloudDemo" — expected a boolean')
|
|
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
|
+
}
|
|
101
|
+
if (raw.demoInstallUrl !== undefined) {
|
|
102
|
+
if (typeof raw.demoInstallUrl === 'string') out.demoInstallUrl = raw.demoInstallUrl
|
|
103
|
+
else warn('ignoring "demoInstallUrl" — expected a string')
|
|
104
|
+
}
|
|
105
|
+
return out
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Pure resolver, exported for tests. `getAppConfig` is the cached entrypoint.
|
|
109
|
+
export function loadAppConfig(
|
|
110
|
+
file: string = APP_CONFIG_FILE,
|
|
111
|
+
env: Record<string, string | undefined> = process.env
|
|
112
|
+
): AppConfig {
|
|
113
|
+
const fromFile = fileValues(file)
|
|
114
|
+
const fromEnv: Partial<AppConfig> = {
|
|
115
|
+
cloudDemo: parseBool(env.MOI_CLOUD_DEMO),
|
|
116
|
+
experiments: parseList(env.MOI_EXPERIMENTS),
|
|
117
|
+
demoInstallUrl: parseString(env.MOI_DEMO_INSTALL_URL)
|
|
118
|
+
}
|
|
119
|
+
const merged = { ...DEFAULTS, ...fromFile }
|
|
120
|
+
for (const key of Object.keys(fromEnv) as (keyof AppConfig)[]) {
|
|
121
|
+
if (fromEnv[key] === undefined) delete fromEnv[key]
|
|
122
|
+
}
|
|
123
|
+
return Object.freeze({ ...merged, ...fromEnv })
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let _config: AppConfig | null = null
|
|
127
|
+
|
|
128
|
+
export function getAppConfig(): AppConfig {
|
|
129
|
+
_config ??= loadAppConfig()
|
|
130
|
+
return _config
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Test seam: drop the cached config so the next getAppConfig() re-resolves
|
|
134
|
+
// (tests point MOI_DATA_DIR elsewhere or set MOI_CLOUD_DEMO).
|
|
135
|
+
export function resetAppConfig(): void {
|
|
136
|
+
_config = null
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// The only shape that reaches the browser (GET /api/config). Server-only keys
|
|
140
|
+
// added to AppConfig later stay out unless explicitly forwarded here.
|
|
141
|
+
export function clientAppConfig(): ClientAppConfig {
|
|
142
|
+
const { cloudDemo, experiments, demoInstallUrl } = getAppConfig()
|
|
143
|
+
return { cloudDemo, experiments: [...experiments], demoInstallUrl }
|
|
144
|
+
}
|