moi-computer 0.8.1-next.0 → 0.9.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/chat/ChatEmptyState.tsx +25 -7
- package/client/features/chat/ChatPanel.tsx +70 -28
- package/client/features/chat/ChatPopup.tsx +3 -2
- package/client/features/chat/ChatPromptBubbles.tsx +1 -1
- package/client/features/chat/MarkdownContent.tsx +1 -1
- 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/dev/ChatStatesPage.tsx +40 -2
- package/client/features/drawings/DrawingLayer.tsx +49 -0
- package/client/features/drawings/DrawingToolbar.tsx +95 -0
- package/client/features/drawings/annotation-availability.ts +10 -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/workspace-presentation.tsx +6 -2
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +12 -6
- package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
- package/client/features/views/ViewBuilder.tsx +224 -0
- 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/Widgets.tsx +23 -39
- package/client/features/workspace/CustomizePanel.tsx +1 -1
- package/client/features/workspace/WorkspaceScreen.tsx +157 -57
- package/client/features/workspace/WorkspaceTabs.tsx +3 -3
- package/client/features/workspace/useFitsSplitLayout.ts +14 -8
- package/client/index.css +8 -0
- package/client/store/ui.ts +19 -0
- package/client/theme.css +33 -8
- package/dist/chunk-3becmq75.js +81 -0
- package/dist/{chunk-kkj86722.js → chunk-6w6j9g4b.js} +78 -78
- package/dist/{chunk-xeyxk7ep.js → chunk-8ew39cvq.js} +4 -4
- package/dist/chunk-c8gtrjwp.js +1 -0
- package/dist/{chunk-2vaafjp4.js → chunk-pp62fnxh.js} +1 -1
- package/dist/{chunk-35fq49qa.js → chunk-sxc24vfp.js} +1 -1
- package/dist/{chunk-xzx7c9hq.js → chunk-v964b5g7.js} +1 -1
- package/dist/chunk-zx33ts9d.css +1 -0
- package/dist/hermes-pznd63x9.png +0 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +21 -7
- package/lib/themes.ts +8 -8
- package/lib/types.ts +8 -1
- package/lib/workspace-types.ts +2 -1
- package/package.json +6 -4
- package/server/api.ts +21 -2
- package/server/bundler/build-applet.ts +35 -44
- package/server/cli-env.ts +2 -2
- package/server/cli.ts +227 -56
- package/server/constants.ts +8 -0
- package/server/control-client.ts +124 -0
- package/server/control.ts +2 -2
- package/server/harness/README.md +74 -23
- 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/openclaw/NOTES.md +196 -94
- package/server/harness/openclaw/adapter.ts +28 -55
- package/server/harness/openclaw/compat.ts +4 -8
- package/server/harness/openclaw/session.ts +257 -238
- package/server/harness/openclaw/strip.ts +10 -34
- package/server/harness/openclaw/thinking.ts +5 -53
- package/server/harness/registry.ts +3 -1
- package/server/service.ts +2 -2
- package/server/view-builders.ts +4 -2
- package/server/workspace-import.ts +30 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +6 -6
- package/client/features/chat/tool-group/format.ts +0 -359
- package/client/features/views/ViewBuilderTab.tsx +0 -152
- package/dist/chunk-gny990qx.css +0 -1
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-n7pga5x3.js +0 -80
- /package/workspace/.claude/skills/moi-workspace/{DESIGN.md → references/DESIGN.md} +0 -0
- /package/workspace/.claude/skills/moi-workspace/{SCRATCHPAD.md → references/SCRATCHPAD.md} +0 -0
|
@@ -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
|
+
}
|