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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// Applet thumbnail store: `.moi/.cache/thumbnails/` holds one image file per
|
|
2
|
+
// captured applet plus an `index.json` of freshness records. Kept out of
|
|
3
|
+
// `.workspace.json` on purpose — images are heavy, machine-local derived state,
|
|
4
|
+
// and the layout file is meant to be small and shareable. Everything here is
|
|
5
|
+
// re-creatable by opening the workspace in a browser, so `.moi/.cache` is safe
|
|
6
|
+
// to delete (and to gitignore) wholesale.
|
|
7
|
+
import { mkdir, rename, rm } from 'node:fs/promises'
|
|
8
|
+
import { join } from 'node:path'
|
|
9
|
+
|
|
10
|
+
import type { AppletKind, AppletThumbnail, AppletThumbnailBatch } from '@/lib/types'
|
|
11
|
+
|
|
12
|
+
import { ensureMoiGitignore } from './moi-scaffold'
|
|
13
|
+
|
|
14
|
+
// Index records carry the image file name (`widget-clock.webp`) so existence
|
|
15
|
+
// and content type never need an fs probe. Server-internal — the API strips it.
|
|
16
|
+
type StoredAppletThumbnail = AppletThumbnail & { file?: string }
|
|
17
|
+
|
|
18
|
+
const INDEX_FILE = 'index.json'
|
|
19
|
+
|
|
20
|
+
// Applet ids become file names under the cache dir, so anything outside this
|
|
21
|
+
// set (`../`, separators) is a path-traversal attempt. Enforced on every
|
|
22
|
+
// entry point that derives a path — the PUT batch, prune, and serve.
|
|
23
|
+
const APPLET_ID_RE = /^[a-zA-Z0-9_-]+$/
|
|
24
|
+
|
|
25
|
+
export function isValidAppletId(id: string): boolean {
|
|
26
|
+
return APPLET_ID_RE.test(id)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const DATA_URL_RE = /^data:(image\/(?:webp|png|jpeg));base64,([A-Za-z0-9+/=]+)$/
|
|
30
|
+
|
|
31
|
+
const EXT_BY_MIME: Record<string, string> = {
|
|
32
|
+
'image/webp': 'webp',
|
|
33
|
+
'image/png': 'png',
|
|
34
|
+
'image/jpeg': 'jpg'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const MIME_BY_EXT: Record<string, string> = {
|
|
38
|
+
webp: 'image/webp',
|
|
39
|
+
png: 'image/png',
|
|
40
|
+
jpg: 'image/jpeg'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getThumbnailsDir(workspacePath: string): string {
|
|
44
|
+
return join(workspacePath, '.moi', '.cache', 'thumbnails')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function loadIndex(dir: string): Promise<StoredAppletThumbnail[]> {
|
|
48
|
+
try {
|
|
49
|
+
const parsed: unknown = JSON.parse(await Bun.file(join(dir, INDEX_FILE)).text())
|
|
50
|
+
if (Array.isArray(parsed)) return parsed as StoredAppletThumbnail[]
|
|
51
|
+
} catch {}
|
|
52
|
+
return []
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Write through a temp sibling + atomic rename so a crash mid-write never
|
|
56
|
+
// leaves a truncated index or image (same recipe as scratchpad assets).
|
|
57
|
+
async function writeAtomic(dir: string, name: string, data: string | Uint8Array): Promise<void> {
|
|
58
|
+
const tmp = join(dir, `.tmp-${crypto.randomUUID()}`)
|
|
59
|
+
await Bun.write(tmp, data)
|
|
60
|
+
await rename(tmp, join(dir, name))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function saveIndex(dir: string, records: StoredAppletThumbnail[]): Promise<void> {
|
|
64
|
+
await writeAtomic(dir, INDEX_FILE, JSON.stringify(records, null, 2))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function getAppletThumbnailRecords(workspacePath: string): Promise<AppletThumbnail[]> {
|
|
68
|
+
const records = await loadIndex(getThumbnailsDir(workspacePath))
|
|
69
|
+
return records.map(({ file: _file, ...record }) => record)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The widget and view capture passes can land concurrently; serialize the
|
|
73
|
+
// read-modify-write per workspace so neither batch clobbers the other's index.
|
|
74
|
+
const saveQueues = new Map<string, Promise<void>>()
|
|
75
|
+
|
|
76
|
+
function enqueue(workspacePath: string, task: () => Promise<void>): Promise<void> {
|
|
77
|
+
const next = (saveQueues.get(workspacePath) ?? Promise.resolve()).then(task, task)
|
|
78
|
+
saveQueues.set(workspacePath, next)
|
|
79
|
+
return next
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Merge a settled capture batch into the store. A data-URL image replaces the
|
|
83
|
+
// applet's file, null records a failed or skipped attempt while keeping any
|
|
84
|
+
// previous file, and an omitted image only updates visit recency.
|
|
85
|
+
export function saveAppletThumbnails(
|
|
86
|
+
workspacePath: string,
|
|
87
|
+
kind: AppletKind,
|
|
88
|
+
updates: AppletThumbnailBatch['thumbnails']
|
|
89
|
+
): Promise<void> {
|
|
90
|
+
return enqueue(workspacePath, async () => {
|
|
91
|
+
const dir = getThumbnailsDir(workspacePath)
|
|
92
|
+
await mkdir(dir, { recursive: true })
|
|
93
|
+
// The cache must be ignored the moment it can hold data — this is also the
|
|
94
|
+
// backfill path for workspaces scaffolded before `.moi/.gitignore` existed.
|
|
95
|
+
await ensureMoiGitignore(workspacePath)
|
|
96
|
+
const now = new Date().toISOString()
|
|
97
|
+
const records = await loadIndex(dir)
|
|
98
|
+
|
|
99
|
+
for (const update of updates) {
|
|
100
|
+
if (!isValidAppletId(update.id)) continue
|
|
101
|
+
const index = records.findIndex(record => record.kind === kind && record.id === update.id)
|
|
102
|
+
const previous = index >= 0 ? records[index] : undefined
|
|
103
|
+
|
|
104
|
+
if (update.image === undefined) {
|
|
105
|
+
if (previous) records[index] = { ...previous, viewedAt: now }
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let file = previous?.file
|
|
110
|
+
if (typeof update.image === 'string') {
|
|
111
|
+
const parsed = DATA_URL_RE.exec(update.image)
|
|
112
|
+
if (!parsed) continue
|
|
113
|
+
const next = `${kind}-${update.id}.${EXT_BY_MIME[parsed[1]]}`
|
|
114
|
+
await writeAtomic(dir, next, Buffer.from(parsed[2], 'base64'))
|
|
115
|
+
if (previous?.file && previous.file !== next) {
|
|
116
|
+
await rm(join(dir, previous.file), { force: true }).catch(() => {})
|
|
117
|
+
}
|
|
118
|
+
file = next
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const record: StoredAppletThumbnail = {
|
|
122
|
+
kind,
|
|
123
|
+
id: update.id,
|
|
124
|
+
revision: update.revision,
|
|
125
|
+
capturedAt: now,
|
|
126
|
+
viewedAt: now,
|
|
127
|
+
...(update.captureMs !== undefined && { captureMs: update.captureMs }),
|
|
128
|
+
...(file !== undefined && { file })
|
|
129
|
+
}
|
|
130
|
+
if (previous) records[index] = record
|
|
131
|
+
else records.push(record)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
await saveIndex(dir, records)
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Drop records (and their image files) for applets of `kind` that no longer
|
|
139
|
+
// exist. Called from the build pipeline beside the stale-bundle prune, so a
|
|
140
|
+
// deleted applet's thumbnail dies with its bundle.
|
|
141
|
+
export function pruneAppletThumbnails(
|
|
142
|
+
workspacePath: string,
|
|
143
|
+
kind: AppletKind,
|
|
144
|
+
keepIds: readonly string[]
|
|
145
|
+
): Promise<void> {
|
|
146
|
+
return enqueue(workspacePath, async () => {
|
|
147
|
+
const dir = getThumbnailsDir(workspacePath)
|
|
148
|
+
const records = await loadIndex(dir)
|
|
149
|
+
const keep = new Set(keepIds)
|
|
150
|
+
const stale = records.filter(record => record.kind === kind && !keep.has(record.id))
|
|
151
|
+
if (stale.length === 0) return
|
|
152
|
+
for (const record of stale) {
|
|
153
|
+
if (record.file) await rm(join(dir, record.file), { force: true }).catch(() => {})
|
|
154
|
+
}
|
|
155
|
+
await saveIndex(
|
|
156
|
+
dir,
|
|
157
|
+
records.filter(record => !stale.includes(record))
|
|
158
|
+
)
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Records that actually have an image on disk, for the home-card preview.
|
|
163
|
+
export async function getCapturedThumbnails(
|
|
164
|
+
workspacePath: string
|
|
165
|
+
): Promise<{ kind: AppletKind; id: string; viewedAt: string }[]> {
|
|
166
|
+
const records = await loadIndex(getThumbnailsDir(workspacePath))
|
|
167
|
+
return records
|
|
168
|
+
.filter(record => record.file !== undefined)
|
|
169
|
+
.map(({ kind, id, viewedAt }) => ({ kind, id, viewedAt }))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// One thumbnail image. Same caching story as applet bundles: strong ETag from
|
|
173
|
+
// size+mtime with `private, no-cache`, so an unchanged file costs a bodyless
|
|
174
|
+
// 304 and a re-capture busts every consumer on the next revalidation.
|
|
175
|
+
export async function serveAppletThumbnail(
|
|
176
|
+
workspacePath: string,
|
|
177
|
+
kind: AppletKind,
|
|
178
|
+
id: string,
|
|
179
|
+
ifNoneMatch?: string | null
|
|
180
|
+
): Promise<Response> {
|
|
181
|
+
if (!isValidAppletId(id)) return new Response('Invalid id', { status: 400 })
|
|
182
|
+
const dir = getThumbnailsDir(workspacePath)
|
|
183
|
+
const records = await loadIndex(dir)
|
|
184
|
+
const record = records.find(item => item.kind === kind && item.id === id)
|
|
185
|
+
if (!record?.file) return new Response('Not found', { status: 404 })
|
|
186
|
+
const file = Bun.file(join(dir, record.file))
|
|
187
|
+
if (!(await file.exists())) return new Response('Not found', { status: 404 })
|
|
188
|
+
|
|
189
|
+
const etag = `"${file.size}-${Math.trunc(file.lastModified)}"`
|
|
190
|
+
const headers = {
|
|
191
|
+
ETag: etag,
|
|
192
|
+
'Cache-Control': 'private, no-cache',
|
|
193
|
+
'Content-Type': MIME_BY_EXT[record.file.split('.').pop() ?? ''] ?? 'application/octet-stream'
|
|
194
|
+
}
|
|
195
|
+
if (ifNoneMatch === etag) return new Response(null, { status: 304, headers })
|
|
196
|
+
return new Response(file, { headers })
|
|
197
|
+
}
|
package/server/view-builders.ts
CHANGED
|
@@ -145,10 +145,12 @@ export async function beginViewBuilder(
|
|
|
145
145
|
workspaceId: string,
|
|
146
146
|
workspacePath: string,
|
|
147
147
|
builderId: string,
|
|
148
|
-
requirements: string
|
|
148
|
+
requirements: string,
|
|
149
|
+
hasSketch = false
|
|
149
150
|
): Promise<ViewBuilder> {
|
|
150
151
|
const text = requirements.trim()
|
|
151
|
-
if (!text
|
|
152
|
+
if (!text && !hasSketch)
|
|
153
|
+
throw new ViewBuilderError('View requirements or a sketch are required', 400)
|
|
152
154
|
const builder = await mutateBuilders(workspacePath, builders => {
|
|
153
155
|
const [current, index] = findBuilder(builders, builderId)
|
|
154
156
|
if (current.status !== 'draft') {
|
package/server/views.ts
CHANGED
|
@@ -3,7 +3,14 @@ import { existsSync } from 'node:fs'
|
|
|
3
3
|
import type { ViewConfig, ViewInfo } from '@/lib/types'
|
|
4
4
|
|
|
5
5
|
import { syncAppletLogAfterBuild } from './applet-log'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
buildApplets,
|
|
8
|
+
getAppletPaths,
|
|
9
|
+
getAppletRevision,
|
|
10
|
+
listBuilt,
|
|
11
|
+
scanSources,
|
|
12
|
+
serveApplet
|
|
13
|
+
} from './applets'
|
|
7
14
|
import { reloadModules } from './functions'
|
|
8
15
|
import { markViewBuilderReady } from './view-builders'
|
|
9
16
|
|
|
@@ -106,8 +113,10 @@ export async function getViewList(workspacePath: string): Promise<ViewInfo[]> {
|
|
|
106
113
|
const raw = manifest.config[id] ?? {}
|
|
107
114
|
const icon = typeof raw.icon === 'string' && raw.icon ? raw.icon : undefined
|
|
108
115
|
const requiredEnv = Array.isArray(raw.requiredEnv) ? raw.requiredEnv : undefined
|
|
116
|
+
const revision = getAppletRevision(workspacePath, 'view', id)
|
|
109
117
|
return {
|
|
110
118
|
id,
|
|
119
|
+
...(revision ? { revision } : {}),
|
|
111
120
|
config: {
|
|
112
121
|
title: raw.title || id,
|
|
113
122
|
...(icon ? { icon } : {}),
|
package/server/widgets.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { existsSync
|
|
2
|
-
import { join } from 'path'
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
3
2
|
|
|
4
3
|
import type { WidgetConfig, WidgetInfo } from '@/lib/types'
|
|
5
4
|
|
|
6
5
|
import { syncAppletLogAfterBuild } from './applet-log'
|
|
7
|
-
import { buildApplets, getAppletPaths, listBuilt, serveApplet } from './applets'
|
|
6
|
+
import { buildApplets, getAppletPaths, getAppletRevision, listBuilt, serveApplet } from './applets'
|
|
8
7
|
import { reloadModules } from './functions'
|
|
9
8
|
|
|
10
9
|
const DEFAULT_CONFIG: WidgetConfig = { rowSpan: 1, colSpan: 2 }
|
|
@@ -79,34 +78,21 @@ export function listBuiltWidgets(workspacePath: string): Promise<string[]> {
|
|
|
79
78
|
return listBuilt(buildDir)
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
// Content tag of a widget's built bundle: size+mtime of its entry, the same
|
|
83
|
-
// recipe as the serve ETag. Changes on every rebundle, so clients can use it
|
|
84
|
-
// to invalidate cached artifacts (widget thumbnails).
|
|
85
|
-
function widgetTag(buildDir: string, id: string): string | undefined {
|
|
86
|
-
try {
|
|
87
|
-
const stat = statSync(join(buildDir, id, 'index.js'))
|
|
88
|
-
return `${stat.size}-${Math.trunc(stat.mtimeMs)}`
|
|
89
|
-
} catch {
|
|
90
|
-
return undefined
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
81
|
async function getWidgetList(workspacePath: string): Promise<WidgetInfo[]> {
|
|
95
82
|
const [names, manifest] = await Promise.all([
|
|
96
83
|
listBuiltWidgets(workspacePath),
|
|
97
84
|
readManifest(workspacePath)
|
|
98
85
|
])
|
|
99
|
-
const { buildDir } = getAppletPaths(workspacePath, 'widget')
|
|
100
86
|
return names.map(id => {
|
|
101
87
|
const raw = manifest[id] ?? {}
|
|
102
88
|
const rowSpan = VALID_SPANS.includes(raw.rowSpan) ? raw.rowSpan : DEFAULT_CONFIG.rowSpan
|
|
103
89
|
const colSpan = VALID_SPANS.includes(raw.colSpan) ? raw.colSpan : DEFAULT_CONFIG.colSpan
|
|
104
90
|
const requiredEnv = Array.isArray(raw.requiredEnv) ? raw.requiredEnv : undefined
|
|
105
|
-
const
|
|
91
|
+
const revision = getAppletRevision(workspacePath, 'widget', id)
|
|
106
92
|
return {
|
|
107
93
|
id,
|
|
108
94
|
config: { rowSpan, colSpan, ...(requiredEnv ? { requiredEnv } : {}) } as WidgetConfig,
|
|
109
|
-
...(
|
|
95
|
+
...(revision ? { revision } : {})
|
|
110
96
|
}
|
|
111
97
|
})
|
|
112
98
|
}
|
|
@@ -2,6 +2,8 @@ import { resolve } from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
import type { WorkspaceType } from '@/lib/types'
|
|
4
4
|
|
|
5
|
+
import { discoverHermesProfiles } from './harness/hermes/discovery'
|
|
6
|
+
import type { HermesProfile } from './harness/hermes/discovery'
|
|
5
7
|
import { discoverOpenClawAgents } from './harness/openclaw/discovery'
|
|
6
8
|
import type { OpenClawAgent } from './harness/openclaw/discovery'
|
|
7
9
|
|
|
@@ -13,6 +15,7 @@ export type WorkspaceImportMetadata = {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
type DiscoverOpenClawAgents = () => Promise<OpenClawAgent[]>
|
|
18
|
+
type DiscoverHermesProfiles = () => Promise<HermesProfile[]>
|
|
16
19
|
|
|
17
20
|
function compareOpenClawAgents(a: OpenClawAgent, b: OpenClawAgent): number {
|
|
18
21
|
if (a.isDefault !== b.isDefault) return a.isDefault ? -1 : 1
|
|
@@ -20,11 +23,37 @@ function compareOpenClawAgents(a: OpenClawAgent, b: OpenClawAgent): number {
|
|
|
20
23
|
return byLastRun || a.agentId.localeCompare(b.agentId)
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
// A Hermes workspace belongs to a profile, so a UI import has to capture the
|
|
27
|
+
// same metadata `moi hermes init` does. Without it the entry has no agentId —
|
|
28
|
+
// every profile renders as a generic "Hermes agent" and the harness falls back
|
|
29
|
+
// to matching by path at spawn time.
|
|
30
|
+
async function resolveHermesImportMetadata(
|
|
31
|
+
path: string,
|
|
32
|
+
discoverProfiles: DiscoverHermesProfiles
|
|
33
|
+
): Promise<WorkspaceImportMetadata> {
|
|
34
|
+
const normalizedPath = resolve(path)
|
|
35
|
+
const profile = (await discoverProfiles()).find(
|
|
36
|
+
candidate => resolve(candidate.path) === normalizedPath
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
if (!profile) {
|
|
40
|
+
throw new Error('No Hermes profile owns this folder')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...(profile.name ? { name: profile.name } : {}),
|
|
45
|
+
agentId: profile.agentId,
|
|
46
|
+
...(profile.isDefault ? { isDefault: true } : {})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
23
50
|
export async function resolveWorkspaceImportMetadata(
|
|
24
51
|
path: string,
|
|
25
52
|
type: WorkspaceType,
|
|
26
|
-
discoverAgents: DiscoverOpenClawAgents = discoverOpenClawAgents
|
|
53
|
+
discoverAgents: DiscoverOpenClawAgents = discoverOpenClawAgents,
|
|
54
|
+
discoverProfiles: DiscoverHermesProfiles = discoverHermesProfiles
|
|
27
55
|
): Promise<WorkspaceImportMetadata> {
|
|
56
|
+
if (type === 'hermes') return resolveHermesImportMetadata(path, discoverProfiles)
|
|
28
57
|
if (type !== 'openclaw') return {}
|
|
29
58
|
|
|
30
59
|
const normalizedPath = resolve(path)
|
|
@@ -90,6 +90,15 @@ my-agent-folder/
|
|
|
90
90
|
.scratchpad/ <- Scratchpad image files. Internal — pull pixels via `moi scratch read-image`, never open it.
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
Every dot-prefixed file or folder inside `.moi/` (`.build/`, `.cache/`, `.workspace.json`,
|
|
94
|
+
`.scratchpad*`, `.gitignore`, …) is a moi internal: auto-generated and liable to change format
|
|
95
|
+
without notice. Avoid them as much as possible — do not read, edit, or delete them, and never point
|
|
96
|
+
tooling at them; go through the `moi` CLI instead. Version control needs no special handling: the
|
|
97
|
+
scaffolded `.moi/.gitignore` already excludes the machine-local entries (`.build/`, `.cache/`,
|
|
98
|
+
`node_modules/`), while `.workspace.json` and `.scratchpad.json` are workspace state that ships
|
|
99
|
+
with the repo — commit them as-is, just never hand-edit them. Your surface is the non-dot files:
|
|
100
|
+
`widgets/`, `views/`, `package.json`, and code you place under `.moi/` yourself.
|
|
101
|
+
|
|
93
102
|
# Build environment
|
|
94
103
|
|
|
95
104
|
- Bun is the required dependency of moi, so it must be installed
|
|
@@ -338,6 +347,9 @@ After the final successful bundle and any checks, always make tab focus the fina
|
|
|
338
347
|
- After building or editing a view, run `moi tab focus view:<view-id>`, using its file name or claimed
|
|
339
348
|
builder id.
|
|
340
349
|
|
|
350
|
+
The focused applet is the handoff. Keep the final reply brief and user-facing. Do not include file
|
|
351
|
+
or storage links, file paths, or bundle, test, and runtime-log summaries.
|
|
352
|
+
|
|
341
353
|
# Debugging applets
|
|
342
354
|
|
|
343
355
|
`moi bundle` only proves an applet compiles — it can still fail to load in the browser, crash on
|
|
@@ -406,4 +418,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
|
|
|
406
418
|
- **Then** — if you updated, mention it.
|
|
407
419
|
|
|
408
420
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
409
|
-
<moi-skill version="0.
|
|
421
|
+
<moi-skill version="0.13.0" />
|