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,155 @@
|
|
|
1
|
+
// Hermes profile discovery — the "agents" moi can import.
|
|
2
|
+
//
|
|
3
|
+
// A Hermes profile is a self-contained agent identity: its own model
|
|
4
|
+
// (config.yaml), keys (.env), persona (SOUL.md), skills, memories and session
|
|
5
|
+
// store. Profiles are the same shape as OpenClaw agents, so moi imports them
|
|
6
|
+
// the same way: discovered here, installed with `moi hermes init <profile>`,
|
|
7
|
+
// never created from the UI.
|
|
8
|
+
//
|
|
9
|
+
// Discovery reads the filesystem rather than parsing `hermes profile list` —
|
|
10
|
+
// that command prints an ASCII table with no --json mode.
|
|
11
|
+
import { readdir, readFile, stat } from 'node:fs/promises'
|
|
12
|
+
import { homedir } from 'node:os'
|
|
13
|
+
import { basename, dirname, join } from 'node:path'
|
|
14
|
+
|
|
15
|
+
export const DEFAULT_PROFILE = 'default'
|
|
16
|
+
|
|
17
|
+
const WORKSPACE_DIR = 'workspace'
|
|
18
|
+
|
|
19
|
+
export type HermesProfile = {
|
|
20
|
+
// Profile id, as passed to `hermes -p <id>`. 'default' is the unnamed one.
|
|
21
|
+
agentId: string
|
|
22
|
+
// Profile home ($HERMES_HOME for default, else <home>/profiles/<id>).
|
|
23
|
+
home: string
|
|
24
|
+
// Workspace directory the agent runs in — the moi workspace path.
|
|
25
|
+
path: string
|
|
26
|
+
name?: string
|
|
27
|
+
isDefault: boolean
|
|
28
|
+
model?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function hermesHome(): string {
|
|
32
|
+
return process.env.HERMES_HOME?.trim() || join(homedir(), '.hermes')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Each profile's agent workspace. Named profiles get `<home>/workspace` from
|
|
36
|
+
// `hermes profile create`; the default profile has no such directory, so moi
|
|
37
|
+
// uses the same convention under $HERMES_HOME and creates it on init.
|
|
38
|
+
export function profileWorkspace(home: string): string {
|
|
39
|
+
return join(home, WORKSPACE_DIR)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Exact inverse of `profileWorkspace` — keep the pair together. Hermes reads
|
|
43
|
+
// skills from `$HERMES_HOME/skills` (the profile home), never from the session
|
|
44
|
+
// cwd, so anything scoped to a workspace has to climb back to its profile.
|
|
45
|
+
// Returns null for a path moi did not lay out, so callers can fall back rather
|
|
46
|
+
// than write into a surprising directory.
|
|
47
|
+
export function profileHomeFromWorkspace(workspacePath: string): string | null {
|
|
48
|
+
return basename(workspacePath) === WORKSPACE_DIR ? dirname(workspacePath) : null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function isDir(path: string): Promise<boolean> {
|
|
52
|
+
try {
|
|
53
|
+
return (await stat(path)).isDirectory()
|
|
54
|
+
} catch {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// `model.default` out of a profile's config.yaml. Parsed with a narrow regex
|
|
60
|
+
// rather than a YAML dependency — this is a display hint, and a miss just
|
|
61
|
+
// leaves the column blank.
|
|
62
|
+
async function readProfileModel(home: string): Promise<string | undefined> {
|
|
63
|
+
try {
|
|
64
|
+
const text = await readFile(join(home, 'config.yaml'), 'utf8')
|
|
65
|
+
const section = /^model:\s*$([\s\S]*?)(?=^\S)/m.exec(text)?.[1] ?? text
|
|
66
|
+
const match = /^\s{2,}(?:default|model):\s*["']?([^"'\n#]+)/m.exec(section)
|
|
67
|
+
return match?.[1].trim() || undefined
|
|
68
|
+
} catch {
|
|
69
|
+
return undefined
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function readProfileDescription(home: string): Promise<string | undefined> {
|
|
74
|
+
try {
|
|
75
|
+
const text = await readFile(join(home, 'profile.yaml'), 'utf8')
|
|
76
|
+
return /^description:\s*["']?([^"'\n#]+)/m.exec(text)?.[1].trim() || undefined
|
|
77
|
+
} catch {
|
|
78
|
+
return undefined
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function loadProfile(agentId: string, home: string): Promise<HermesProfile | null> {
|
|
83
|
+
// A profile without config.yaml is not provisioned (or not a profile at all).
|
|
84
|
+
try {
|
|
85
|
+
await stat(join(home, 'config.yaml'))
|
|
86
|
+
} catch {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
const [model, name] = await Promise.all([readProfileModel(home), readProfileDescription(home)])
|
|
90
|
+
return {
|
|
91
|
+
agentId,
|
|
92
|
+
home,
|
|
93
|
+
path: profileWorkspace(home),
|
|
94
|
+
isDefault: agentId === DEFAULT_PROFILE,
|
|
95
|
+
...(name ? { name } : {}),
|
|
96
|
+
...(model ? { model } : {})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function discoverHermesProfiles(): Promise<HermesProfile[]> {
|
|
101
|
+
const home = hermesHome()
|
|
102
|
+
if (!(await isDir(home))) return []
|
|
103
|
+
|
|
104
|
+
const out: HermesProfile[] = []
|
|
105
|
+
const base = await loadProfile(DEFAULT_PROFILE, home)
|
|
106
|
+
if (base) out.push(base)
|
|
107
|
+
|
|
108
|
+
const profilesDir = join(home, 'profiles')
|
|
109
|
+
if (await isDir(profilesDir)) {
|
|
110
|
+
let entries: string[] = []
|
|
111
|
+
try {
|
|
112
|
+
entries = await readdir(profilesDir)
|
|
113
|
+
} catch {
|
|
114
|
+
entries = []
|
|
115
|
+
}
|
|
116
|
+
const loaded = await Promise.all(
|
|
117
|
+
entries.map(async name => {
|
|
118
|
+
const dir = join(profilesDir, name)
|
|
119
|
+
return (await isDir(dir)) ? loadProfile(name, dir) : null
|
|
120
|
+
})
|
|
121
|
+
)
|
|
122
|
+
for (const p of loaded) if (p) out.push(p)
|
|
123
|
+
}
|
|
124
|
+
return out
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Match a query against `agentId` (exact) or `name` (case-insensitive).
|
|
128
|
+
export function matchHermesProfile(
|
|
129
|
+
profiles: readonly HermesProfile[],
|
|
130
|
+
query: string
|
|
131
|
+
): HermesProfile | null {
|
|
132
|
+
return (
|
|
133
|
+
profiles.find(p => p.agentId === query) ??
|
|
134
|
+
profiles.find(p => p.name?.toLowerCase() === query.toLowerCase()) ??
|
|
135
|
+
null
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function findHermesProfile(query: string): Promise<HermesProfile | null> {
|
|
140
|
+
return matchHermesProfile(await discoverHermesProfiles(), query)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Which profile owns a registered workspace. Falls back to matching the
|
|
144
|
+
// workspace path, so entries saved before agentId was captured still resolve.
|
|
145
|
+
export async function resolveHermesProfile(
|
|
146
|
+
workspacePath: string,
|
|
147
|
+
agentId?: string
|
|
148
|
+
): Promise<HermesProfile | null> {
|
|
149
|
+
const profiles = await discoverHermesProfiles()
|
|
150
|
+
if (agentId) {
|
|
151
|
+
const byId = profiles.find(p => p.agentId === agentId)
|
|
152
|
+
if (byId) return byId
|
|
153
|
+
}
|
|
154
|
+
return profiles.find(p => p.path === workspacePath) ?? null
|
|
155
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Hermes Agent as a Harness, over ACP. Thin wiring: the protocol lives in
|
|
2
|
+
// ../acp/, this folder holds only what is Hermes-specific — profile discovery
|
|
3
|
+
// (the importable "agents"), the spawn command, and availability.
|
|
4
|
+
//
|
|
5
|
+
// See ./NOTES.md for the protocol research and the two backend quirks the ACP
|
|
6
|
+
// layer works around.
|
|
7
|
+
import type { DiscoveredWorkspaceCandidate, Harness } from '../types'
|
|
8
|
+
import { join } from 'node:path'
|
|
9
|
+
|
|
10
|
+
import type { HarnessAvailability } from '@/lib/types'
|
|
11
|
+
|
|
12
|
+
import { acpWorkspacePreview, listAcpModels, listAcpSessions } from '../acp/discovery'
|
|
13
|
+
import {
|
|
14
|
+
type AcpProviderConfig,
|
|
15
|
+
ensureAcpSessionLive,
|
|
16
|
+
forgetAcpWorkspaceSessions,
|
|
17
|
+
forgetAcpSession,
|
|
18
|
+
forgetAllAcpSessions,
|
|
19
|
+
getAcpActiveSessions,
|
|
20
|
+
getLiveAcpEvents,
|
|
21
|
+
interruptAcpRun,
|
|
22
|
+
sendAcpMessage
|
|
23
|
+
} from '../acp/session'
|
|
24
|
+
import { archiveAcpSession } from '../acp/archived'
|
|
25
|
+
import { getAcpProcessInfo, killAcpWorkspace, killAllAcpClients } from '../acp/client'
|
|
26
|
+
import {
|
|
27
|
+
DEFAULT_PROFILE,
|
|
28
|
+
discoverHermesProfiles,
|
|
29
|
+
profileHomeFromWorkspace,
|
|
30
|
+
resolveHermesProfile
|
|
31
|
+
} from './discovery'
|
|
32
|
+
import { hermesModels } from './models'
|
|
33
|
+
import { findHarnessExecutable, pathHarnessAvailability } from '../executable'
|
|
34
|
+
|
|
35
|
+
// Hermes ships three session modes; `dont_ask` is the one that auto-allows
|
|
36
|
+
// file edits without an approval round-trip, matching moi's
|
|
37
|
+
// bypass-permissions trust model (NOTES.md §3.5).
|
|
38
|
+
const NO_PROMPT_MODE = 'dont_ask'
|
|
39
|
+
|
|
40
|
+
const config: AcpProviderConfig = {
|
|
41
|
+
id: 'hermes',
|
|
42
|
+
provider: 'hermes',
|
|
43
|
+
noPromptModeId: NO_PROMPT_MODE,
|
|
44
|
+
mapModels: hermesModels,
|
|
45
|
+
supportsImages: true,
|
|
46
|
+
async spawn(ctx) {
|
|
47
|
+
const bin = findHarnessExecutable('hermes')
|
|
48
|
+
if (!bin) throw new Error('hermes executable not found')
|
|
49
|
+
// Profiles are separate agent identities; `-p` selects one. The default
|
|
50
|
+
// profile takes no flag.
|
|
51
|
+
const profile = await resolveHermesProfile(ctx.workspacePath, ctx.agentId)
|
|
52
|
+
const agentId = profile?.agentId ?? ctx.agentId ?? DEFAULT_PROFILE
|
|
53
|
+
const args = agentId === DEFAULT_PROFILE ? ['acp'] : ['-p', agentId, 'acp']
|
|
54
|
+
return {
|
|
55
|
+
provider: 'hermes',
|
|
56
|
+
command: bin,
|
|
57
|
+
args,
|
|
58
|
+
workspacePath: ctx.workspacePath
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function ctxOf(ws: { id: string; path: string; agentId?: string }) {
|
|
64
|
+
return { workspaceId: ws.id, workspacePath: ws.path, agentId: ws.agentId }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const hermesHarness: Harness = {
|
|
68
|
+
id: 'hermes',
|
|
69
|
+
capabilities: {
|
|
70
|
+
supportsStreaming: true, // ACP always streams deltas; moi gates forwarding
|
|
71
|
+
imagesInline: 'base64',
|
|
72
|
+
// `session/set_model` works mid-session, but drops session-scoped MCP
|
|
73
|
+
// servers (NOTES.md §3.10). Safe today because moi attaches none.
|
|
74
|
+
liveModelSwitch: true,
|
|
75
|
+
liveEffortSwitch: false, // ACP has no reasoning-effort concept
|
|
76
|
+
nativeUserEcho: false // ACP never echoes the send; moi synthesizes the turn
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
sendMessage: input => sendAcpMessage(config, input),
|
|
80
|
+
interrupt: (workspaceId, sessionId) => interruptAcpRun(config, { workspaceId, sessionId }),
|
|
81
|
+
// Hermes answers ACP's `session/delete` with "Method not found" and exposes
|
|
82
|
+
// its own archive flag only over `hermes serve`, so moi hides the chat on its
|
|
83
|
+
// side — see ../acp/archived.ts.
|
|
84
|
+
archiveSession: async (ws, sessionId) => {
|
|
85
|
+
await archiveAcpSession(ws.path, sessionId)
|
|
86
|
+
forgetAcpSession(ws.id, sessionId)
|
|
87
|
+
},
|
|
88
|
+
activeSessions: () => getAcpActiveSessions(),
|
|
89
|
+
|
|
90
|
+
listSessions: ws => listAcpSessions(config, ctxOf(ws)),
|
|
91
|
+
workspacePreview: (ws, includeFirstUserMessage) =>
|
|
92
|
+
acpWorkspacePreview(config, ctxOf(ws), includeFirstUserMessage),
|
|
93
|
+
// Prefer the live view when one exists; otherwise resume the session so WS
|
|
94
|
+
// frames upsert into the same view. Replay is higher-fidelity than the live
|
|
95
|
+
// stream here (NOTES.md §3.4), so there is no static fallback worth having.
|
|
96
|
+
sessionEvents: async (ws, sessionId) => {
|
|
97
|
+
const live = getLiveAcpEvents(ws.id, sessionId)
|
|
98
|
+
if (live) return live
|
|
99
|
+
try {
|
|
100
|
+
return await ensureAcpSessionLive(config, { ...ctxOf(ws), sessionId })
|
|
101
|
+
} catch {
|
|
102
|
+
return []
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
listModels: ws => listAcpModels(config, ctxOf(ws)),
|
|
106
|
+
|
|
107
|
+
// Profiles moi has not imported yet. Like OpenClaw, agents are only ever
|
|
108
|
+
// imported — `moi hermes init <profile>` is the install path, and there is
|
|
109
|
+
// no create-from-UI flow.
|
|
110
|
+
discoverWorkspaces: async registeredPaths => {
|
|
111
|
+
const profiles = await discoverHermesProfiles()
|
|
112
|
+
return profiles
|
|
113
|
+
.filter(p => !registeredPaths.has(p.path))
|
|
114
|
+
.map((p): DiscoveredWorkspaceCandidate => ({ path: p.path, type: 'hermes' }))
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
availability: async (ws): Promise<HarnessAvailability> => {
|
|
118
|
+
const runtime = await pathHarnessAvailability('hermes')
|
|
119
|
+
if (!runtime.available || !ws) return runtime
|
|
120
|
+
const profile = await resolveHermesProfile(ws.path, ws.agentId)
|
|
121
|
+
if (profile) return { available: true }
|
|
122
|
+
return {
|
|
123
|
+
available: false,
|
|
124
|
+
reason: 'Hermes profile not found — run moi hermes init to re-import it',
|
|
125
|
+
loginCommand: 'hermes profile list'
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
onEnvChanged: workspacePath => {
|
|
130
|
+
forgetAcpWorkspaceSessions(workspacePath)
|
|
131
|
+
killAcpWorkspace(workspacePath)
|
|
132
|
+
},
|
|
133
|
+
shutdown: () => {
|
|
134
|
+
forgetAllAcpSessions()
|
|
135
|
+
killAllAcpClients()
|
|
136
|
+
},
|
|
137
|
+
// Hermes reads skills from the PROFILE home (`$HERMES_HOME/skills`) and has
|
|
138
|
+
// no cwd-relative skill path, so installing into the workspace would leave
|
|
139
|
+
// them invisible to `skill view` / `skills list` — see NOTES.md §13. That
|
|
140
|
+
// makes moi's skills profile-global: every session on this profile sees
|
|
141
|
+
// them, including plain `hermes` runs and gateway chats.
|
|
142
|
+
skillsDir: workspaceRoot =>
|
|
143
|
+
join(profileHomeFromWorkspace(workspaceRoot) ?? workspaceRoot, 'skills'),
|
|
144
|
+
debugInfo: ws => getAcpProcessInfo(ws.path, findHarnessExecutable('hermes')),
|
|
145
|
+
wireScope: ws => ws.path,
|
|
146
|
+
|
|
147
|
+
statusLines: () => {
|
|
148
|
+
const active = getAcpActiveSessions()
|
|
149
|
+
return [
|
|
150
|
+
`hermes executable ${findHarnessExecutable('hermes') ?? '(not found)'}`,
|
|
151
|
+
`live Hermes runs ${active.length}`,
|
|
152
|
+
...active.map(r => ` ▶ busy ws=${r.workspaceId} session=${r.sessionId}`)
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Hermes model catalog → moi's `Model`.
|
|
2
|
+
//
|
|
3
|
+
// Hermes merges every configured provider into one flat list (59 entries on a
|
|
4
|
+
// stock install) and names the provider in `description`, the same string for
|
|
5
|
+
// every model behind it:
|
|
6
|
+
//
|
|
7
|
+
// { modelId: 'nous:anthropic/claude-opus-5',
|
|
8
|
+
// name: 'Nous Portal · anthropic/claude-opus-5',
|
|
9
|
+
// description: 'Provider: Nous Portal' }
|
|
10
|
+
//
|
|
11
|
+
// Passed through as-is that description makes the picker render dozens of
|
|
12
|
+
// identical rows, so the provider is hoisted to a group heading and stripped
|
|
13
|
+
// off the front of `name` where Hermes repeats it there. It does not always:
|
|
14
|
+
// the Ollama rows carry a bare `name` ('gpt-oss:20b') and name their provider
|
|
15
|
+
// in `description` alone, which is why the group comes from that field.
|
|
16
|
+
import type { Model } from '@/lib/types'
|
|
17
|
+
|
|
18
|
+
import type { AcpModelInfo } from '../acp/wire'
|
|
19
|
+
|
|
20
|
+
const PROVIDER_PREFIX = /^Provider:\s*/
|
|
21
|
+
// Hermes marks the model it would pick itself; moi tracks its own selection.
|
|
22
|
+
const CURRENT_SUFFIX = /\s*•\s*current$/
|
|
23
|
+
|
|
24
|
+
function providerOf(description: string | undefined): string | undefined {
|
|
25
|
+
if (!description || !PROVIDER_PREFIX.test(description)) return undefined
|
|
26
|
+
return description.replace(PROVIDER_PREFIX, '').replace(CURRENT_SUFFIX, '').trim() || undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// `custom:` namespaces a provider configured in config.yaml
|
|
30
|
+
// (`custom:ollama-launch:…`), but is also a provider id in its own right when
|
|
31
|
+
// nothing follows it (`custom:kimi-k2.7-code`, the base_url escape hatch, §2).
|
|
32
|
+
const CUSTOM_NAMESPACE = 'custom:'
|
|
33
|
+
|
|
34
|
+
// The provider half of `<provider>:<model>`, recovered by peeling the model
|
|
35
|
+
// label off the end rather than splitting on the first colon — model ids carry
|
|
36
|
+
// their own colons (`gpt-oss:20b`) and the namespace occupies the first slot.
|
|
37
|
+
function providerIdOf(modelId: string, displayName: string): string | undefined {
|
|
38
|
+
if (!modelId.includes(':')) return undefined
|
|
39
|
+
const suffix = `:${displayName}`
|
|
40
|
+
const head = modelId.endsWith(suffix) ? modelId.slice(0, -suffix.length) : modelId.split(':')[0]
|
|
41
|
+
if (!head) return undefined
|
|
42
|
+
return head.startsWith(CUSTOM_NAMESPACE) ? head.slice(CUSTOM_NAMESPACE.length) : head
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function hermesModel(info: AcpModelInfo): Model {
|
|
46
|
+
const group = providerOf(info.description)
|
|
47
|
+
const name = info.name?.trim() || info.modelId
|
|
48
|
+
const prefix = group ? `${group} · ` : ''
|
|
49
|
+
const stripped = prefix && name.startsWith(prefix) ? name.slice(prefix.length).trim() : ''
|
|
50
|
+
const displayName = stripped || name
|
|
51
|
+
const providerId = providerIdOf(info.modelId, displayName)
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
value: info.modelId,
|
|
55
|
+
displayName,
|
|
56
|
+
...(group ? { group } : {}),
|
|
57
|
+
...(providerId ? { providerId } : {}),
|
|
58
|
+
// A description that is not the provider label is real prose — keep it.
|
|
59
|
+
...(!group && info.description ? { description: info.description } : {})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// A configured provider is listed twice — once under its own id
|
|
64
|
+
// (`ollama-launch:gpt-oss:20b`) and once namespaced (`custom:ollama-launch:…`)
|
|
65
|
+
// — for the same endpoint and model. Both spellings work, so keep the first
|
|
66
|
+
// and drop rows the picker would render as an exact duplicate. Keyed on
|
|
67
|
+
// `providerId` where there is one, since both spellings normalize to it.
|
|
68
|
+
export function hermesModels(infos: AcpModelInfo[]): Model[] {
|
|
69
|
+
const seen = new Set<string>()
|
|
70
|
+
const out: Model[] = []
|
|
71
|
+
for (const info of infos) {
|
|
72
|
+
const model = hermesModel(info)
|
|
73
|
+
const key = `${model.providerId ?? model.group ?? ''} ${model.displayName}`
|
|
74
|
+
if (seen.has(key)) continue
|
|
75
|
+
seen.add(key)
|
|
76
|
+
out.push(model)
|
|
77
|
+
}
|
|
78
|
+
return out
|
|
79
|
+
}
|
|
@@ -6,6 +6,7 @@ import type { WorkspaceEntry, WorkspaceType } from '@/lib/types'
|
|
|
6
6
|
|
|
7
7
|
import { claudeCodeHarness } from './claude-code'
|
|
8
8
|
import { codexHarness } from './codex'
|
|
9
|
+
import { hermesHarness } from './hermes'
|
|
9
10
|
import { openclawHarness } from './openclaw'
|
|
10
11
|
import type { Harness } from './types'
|
|
11
12
|
|
|
@@ -14,7 +15,8 @@ export type { Harness, HarnessCapabilities, SendMessageInput } from './types'
|
|
|
14
15
|
const harnesses = {
|
|
15
16
|
'claude-code': claudeCodeHarness,
|
|
16
17
|
openclaw: openclawHarness,
|
|
17
|
-
codex: codexHarness
|
|
18
|
+
codex: codexHarness,
|
|
19
|
+
hermes: hermesHarness
|
|
18
20
|
} satisfies Partial<Record<WorkspaceType, Harness>>
|
|
19
21
|
|
|
20
22
|
// An untyped registry entry is a Claude Code workspace (pre-typing legacy).
|
package/server/layout.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
2
|
|
|
3
|
-
import type { WorkspaceLayout, WorkspacePreview } from '@/lib/types'
|
|
3
|
+
import type { AppletKind, WorkspaceLayout, WorkspacePreview } from '@/lib/types'
|
|
4
4
|
import { createDefaultWorkspaceLayout, createDefaultWorkspaceTabs } from '@/lib/workspace-layout'
|
|
5
5
|
import { isWorkspaceTabId } from '@/lib/workspace-tabs'
|
|
6
6
|
|
|
7
|
+
import { getCapturedThumbnails } from './thumbnails'
|
|
8
|
+
|
|
7
9
|
function normalizeTabs(value: unknown): WorkspaceLayout['tabs'] {
|
|
8
10
|
if (!value || typeof value !== 'object') return createDefaultWorkspaceTabs()
|
|
9
11
|
const raw = value as Record<string, unknown>
|
|
@@ -22,6 +24,12 @@ function normalizeLayout(parsed: Record<string, unknown>): WorkspaceLayout {
|
|
|
22
24
|
layout.layoutMode = defaults.layoutMode
|
|
23
25
|
}
|
|
24
26
|
layout.tabs = normalizeTabs(layout.tabs)
|
|
27
|
+
// Legacy thumbnail caches are intentionally dropped, not migrated — images
|
|
28
|
+
// now live as files under `.moi/.cache/thumbnails` (server/thumbnails.ts)
|
|
29
|
+
// and applets are simply captured again there.
|
|
30
|
+
delete layout.widgetThumbnails
|
|
31
|
+
delete layout.viewThumbnails
|
|
32
|
+
delete layout.appletThumbnails
|
|
25
33
|
delete layout.sectionMode
|
|
26
34
|
delete layout.chatMode
|
|
27
35
|
return layout as unknown as WorkspaceLayout
|
|
@@ -54,53 +62,24 @@ export async function saveLayout(layout: WorkspaceLayout, workspacePath: string)
|
|
|
54
62
|
// A blind overwrite therefore erases a `moi config`-set name (and could revert an
|
|
55
63
|
// icon). So drop whatever identity the body carries and re-apply the server-owned
|
|
56
64
|
// fields from `existing` — conditionally, so an absent field never serializes
|
|
57
|
-
// as `name: undefined`.
|
|
58
|
-
// write: they have their own endpoint (saveWidgetThumbnails), and the layout
|
|
59
|
-
// GET doesn't even ship the map — a round-trip would erase it.
|
|
65
|
+
// as `name: undefined`.
|
|
60
66
|
export function mergeLayoutForSave(
|
|
61
67
|
existing: WorkspaceLayout,
|
|
62
68
|
body: WorkspaceLayout
|
|
63
69
|
): WorkspaceLayout {
|
|
64
|
-
const { name: _name, icon: _icon,
|
|
70
|
+
const { name: _name, icon: _icon, ...editor } = body
|
|
71
|
+
// Stale clients may still round-trip the pre-`.cache` thumbnail records;
|
|
72
|
+
// never let a layout PUT resurrect them in `.workspace.json`.
|
|
73
|
+
delete (editor as Record<string, unknown>).appletThumbnails
|
|
65
74
|
return {
|
|
66
75
|
...editor,
|
|
67
76
|
...(existing.name !== undefined && { name: existing.name }),
|
|
68
|
-
...(existing.icon !== undefined && { icon: existing.icon })
|
|
69
|
-
...(existing.widgetThumbnails !== undefined && {
|
|
70
|
-
widgetThumbnails: existing.widgetThumbnails
|
|
71
|
-
})
|
|
77
|
+
...(existing.icon !== undefined && { icon: existing.icon })
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
// theme saves never carry the base64 map, and a thumbnail save can't touch
|
|
78
|
-
// the grid. Entries merge over the existing map — removed widgets keep their
|
|
79
|
-
// last image.
|
|
80
|
-
export async function saveWidgetThumbnails(
|
|
81
|
-
workspacePath: string,
|
|
82
|
-
key: string,
|
|
83
|
-
images: Record<string, string>
|
|
84
|
-
): Promise<void> {
|
|
85
|
-
const existing = await loadLayout(workspacePath)
|
|
86
|
-
await saveLayout(
|
|
87
|
-
{
|
|
88
|
-
...existing,
|
|
89
|
-
widgetThumbnails: {
|
|
90
|
-
key,
|
|
91
|
-
// Server clock, so age-based invalidation doesn't trust client time.
|
|
92
|
-
at: new Date().toISOString(),
|
|
93
|
-
images: { ...existing.widgetThumbnails?.images, ...images }
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
workspacePath
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Thumbnails for the home screen's workspace card: a few captured widget
|
|
101
|
-
// images from the stored layout (see saveWidgetThumbnails). The card renders
|
|
102
|
-
// them as a loose stack, so the cap just keeps the payload small — anything
|
|
103
|
-
// past it would hide under the pile anyway.
|
|
81
|
+
// Thumbnails for the home screen's workspace card. Widgets take the front
|
|
82
|
+
// slots in grid order, then recent views fill what remains.
|
|
104
83
|
const PREVIEW_LIMIT = 3
|
|
105
84
|
const PREVIEW_MESSAGE_LIMIT = 240
|
|
106
85
|
|
|
@@ -111,21 +90,37 @@ function normalizePreviewMessage(message: string | undefined): string | undefine
|
|
|
111
90
|
return `${normalized.slice(0, PREVIEW_MESSAGE_LIMIT - 1).trimEnd()}…`
|
|
112
91
|
}
|
|
113
92
|
|
|
114
|
-
export
|
|
115
|
-
workspacePath: string,
|
|
93
|
+
export type WorkspacePreviewOptions = {
|
|
116
94
|
getProviderPreview?: (includeFirstUserMessage: boolean) => Promise<{
|
|
117
95
|
firstUserMessage?: string
|
|
118
96
|
updatedAt?: number
|
|
119
97
|
}>
|
|
98
|
+
viewIds?: readonly string[]
|
|
99
|
+
// Maps a captured applet to the image URL the home card should render —
|
|
100
|
+
// the API layer owns the route shape (GET .../applet-thumbnails/:kind/:id).
|
|
101
|
+
thumbnailUrl: (kind: AppletKind, id: string) => string
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function getWorkspacePreview(
|
|
105
|
+
workspacePath: string,
|
|
106
|
+
{ getProviderPreview, viewIds = [], thumbnailUrl }: WorkspacePreviewOptions
|
|
120
107
|
): Promise<WorkspacePreview> {
|
|
121
108
|
try {
|
|
122
109
|
const layout = await loadLayout(workspacePath)
|
|
123
|
-
const
|
|
124
|
-
const
|
|
110
|
+
const captured = await getCapturedThumbnails(workspacePath)
|
|
111
|
+
const validViewIds = new Set(viewIds)
|
|
112
|
+
const capturedWidgets = new Set(
|
|
113
|
+
captured.filter(record => record.kind === 'widget').map(record => record.id)
|
|
114
|
+
)
|
|
115
|
+
const widgetImages = [...layout.widgetGrid]
|
|
125
116
|
.sort((a, b) => a.y - b.y || a.x - b.x)
|
|
126
|
-
.
|
|
127
|
-
.
|
|
128
|
-
|
|
117
|
+
.filter(item => capturedWidgets.has(item.i))
|
|
118
|
+
.map(item => thumbnailUrl('widget', item.i))
|
|
119
|
+
const viewImages = captured
|
|
120
|
+
.filter(record => record.kind === 'view' && validViewIds.has(record.id))
|
|
121
|
+
.sort((a, b) => Date.parse(b.viewedAt) - Date.parse(a.viewedAt))
|
|
122
|
+
.map(record => thumbnailUrl('view', record.id))
|
|
123
|
+
const thumbnails = [...widgetImages, ...viewImages].slice(0, PREVIEW_LIMIT)
|
|
129
124
|
// The message bubble is the card's fallback for "nothing to show": gate on
|
|
130
125
|
// captured thumbnails, not grid emptiness — a workspace with widgets that
|
|
131
126
|
// were never captured (never opened in a browser) still renders an empty
|
package/server/moi-scaffold.ts
CHANGED
|
@@ -49,6 +49,36 @@ async function runBunInstall(moiDir: string): Promise<number> {
|
|
|
49
49
|
return install.exited
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// Keep machine-local state out of workspaces that are git repos: build output,
|
|
53
|
+
// derived caches (applet thumbnails), and installed dependencies are all
|
|
54
|
+
// re-creatable and would otherwise churn or bloat the repo. The applet sources,
|
|
55
|
+
// package.json, and lockfile stay committable — they ARE the workspace.
|
|
56
|
+
const REQUIRED_IGNORES = ['.build/', '.cache/', 'node_modules/'] as const
|
|
57
|
+
|
|
58
|
+
export const MOI_GITIGNORE = `# moi internals — machine-local, re-creatable state
|
|
59
|
+
${REQUIRED_IGNORES.join('\n')}
|
|
60
|
+
`
|
|
61
|
+
|
|
62
|
+
// Create `.moi/.gitignore` when missing, or append required entries a
|
|
63
|
+
// pre-gitignore or hand-edited file lacks. Never rewrites existing content —
|
|
64
|
+
// user additions survive. Safe to call often; no-ops once the file is right.
|
|
65
|
+
export async function ensureMoiGitignore(workspacePath: string): Promise<void> {
|
|
66
|
+
const moiDir = join(workspacePath, '.moi')
|
|
67
|
+
if (!(await isDirectory(moiDir))) return
|
|
68
|
+
const path = join(moiDir, '.gitignore')
|
|
69
|
+
const file = Bun.file(path)
|
|
70
|
+
if (!(await file.exists())) {
|
|
71
|
+
await Bun.write(path, MOI_GITIGNORE)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
const text = await file.text()
|
|
75
|
+
// Match entries with or without the trailing slash or a leading slash.
|
|
76
|
+
const present = new Set(text.split('\n').map(line => line.trim().replace(/^\/|\/$/g, '')))
|
|
77
|
+
const missing = REQUIRED_IGNORES.filter(entry => !present.has(entry.replace(/\/$/, '')))
|
|
78
|
+
if (missing.length === 0) return
|
|
79
|
+
await Bun.write(path, `${text.replace(/\n*$/, '\n')}${missing.join('\n')}\n`)
|
|
80
|
+
}
|
|
81
|
+
|
|
52
82
|
// Ambient types for applets (widgets & views). Editor DX only — the moi
|
|
53
83
|
// bundler resolves the `moi` module and asset imports at build time without any
|
|
54
84
|
// declarations. Lives at `.moi/` root, NOT inside widgets/views, so it isn't
|
|
@@ -134,12 +164,18 @@ export async function scaffoldMoiDir(
|
|
|
134
164
|
}
|
|
135
165
|
const moiDir = join(workspacePath, '.moi')
|
|
136
166
|
const packagePath = join(moiDir, 'package.json')
|
|
137
|
-
if (await Bun.file(packagePath).exists())
|
|
167
|
+
if (await Bun.file(packagePath).exists()) {
|
|
168
|
+
// Repair path: workspaces scaffolded before `.moi/.gitignore` existed pick
|
|
169
|
+
// it up on the next `moi init` instead of leaking cache files into git.
|
|
170
|
+
await ensureMoiGitignore(workspacePath)
|
|
171
|
+
return 'exists'
|
|
172
|
+
}
|
|
138
173
|
// A bare `.moi/` dir without package.json counts as not-bootstrapped —
|
|
139
174
|
// fill in the missing pieces.
|
|
140
175
|
|
|
141
176
|
await mkdir(join(moiDir, 'widgets'), { recursive: true })
|
|
142
177
|
await Bun.write(packagePath, JSON.stringify(MOI_PACKAGE_JSON, null, 2) + '\n')
|
|
178
|
+
await ensureMoiGitignore(workspacePath)
|
|
143
179
|
await writeAppletEnvDts(workspacePath)
|
|
144
180
|
|
|
145
181
|
const exited = installDependencies(moiDir)
|