Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(hermes): implement hermes agent chain logic (#15189)

LiJian47b6f3503a75
diff --git a/apps/cli/src/tools/checkPlatformCapability.ts b/apps/cli/src/tools/checkPlatformCapability.ts
index 63a1c14147d..bbfb214a94f 100644
--- a/apps/cli/src/tools/checkPlatformCapability.ts
+++ b/apps/cli/src/tools/checkPlatformCapability.ts
@@ -1,7 +1,5 @@
import { execFileSync } from 'node:child_process';
-import { getHermesPort } from './heteroTask';
-
export interface CheckPlatformCapabilityParams {
platform: 'hermes' | 'openclaw';
}
@@ -42,26 +40,19 @@ export async function checkPlatformCapability(
}
if (platform === 'hermes') {
- const port = getHermesPort();
try {
- const res = await fetch(`http://localhost:${port}/health`, {
- signal: AbortSignal.timeout(5000),
- });
- if (res.ok) {
- let version: string | undefined;
- try {
- const body = (await res.json()) as { version?: string };
- version = body.version;
- } catch {
- /* ignore parse errors */
- }
- return { available: true, version };
- }
- return { available: false, reason: `Hermes gateway returned HTTP ${res.status}` };
+ const output = execFileSync('hermes', ['--version'], {
+ encoding: 'utf8',
+ timeout: 5000,
+ }).trim();
+ // output is typically "Hermes Agent vX.Y.Z (...)"
+ const versionMatch = output.match(/v(\d+\.\d+\.\d+)/);
+ const version = versionMatch ? versionMatch[1] : output.split(/\s+/).at(-1);
+ return { available: true, version };
} catch (err) {
return {
available: false,
- reason: err instanceof Error ? err.message : `Hermes gateway not reachable on port ${port}`,
+ reason: err instanceof Error ? err.message : 'hermes not found or failed to run',
};
}
}
diff --git a/apps/cli/src/tools/getAgentProfile.ts b/apps/cli/src/tools/getAgentProfile.ts
index b775284db3e..3f50a127ecc 100644
--- a/apps/cli/src/tools/getAgentProfile.ts
+++ b/apps/cli/src/tools/getAgentProfile.ts
@@ -1,5 +1,6 @@
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
+import os from 'node:os';
import path from 'node:path';
import type { RemoteHeterogeneousAgentType } from '@lobechat/heterogeneous-agents';
@@ -80,13 +81,92 @@ function getOpenClawProfile(agentId?: string): AgentProfileResult {
return { avatar, description, title };
}
+/**
+ * Read the active Hermes profile name from `hermes profile list` output.
+ * The active profile is marked with ◆ in the first column.
+ */
+function getActiveHermesProfileName(): string | undefined {
+ try {
+ const output = execFileSync('hermes', ['profile', 'list'], {
+ encoding: 'utf8',
+ timeout: 5000,
+ });
+ const match = output.match(/◆(\S+)/);
+ return match?.[1];
+ } catch {
+ return undefined;
+ }
+}
+
+/**
+ * Read the filesystem path of a Hermes profile from `hermes profile show <name>`.
+ */
+function getHermesProfilePath(profileName: string): string | undefined {
+ try {
+ const output = execFileSync('hermes', ['profile', 'show', profileName], {
+ encoding: 'utf8',
+ timeout: 5000,
+ });
+ const match = output.match(/^Path:\s+(.+)/m);
+ const raw = match?.[1]?.trim();
+ // Expand leading `~` — Node does not auto-expand home-dir shorthands.
+ return raw?.replace(/^~(?=\/|$)/, os.homedir());
+ } catch {
+ return undefined;
+ }
+}
+
+/**
+ * Extract a one-line description from a Hermes SOUL.md file.
+ * Strips HTML comments and Markdown headings, then returns the first
+ * non-empty line of actual content.
+ */
+function readHermesSoulDescription(soulPath: string): string | undefined {
+ try {
+ const content = fs.readFileSync(soulPath, 'utf8');
+ // Loop until stable to handle any malformed/nested comment sequences.
+ let stripped = content;
+ let previous: string;
+ do {
+ previous = stripped;
+ stripped = stripped
+ .replaceAll(/<!--[\s\S]*?-->/g, '') // strip complete HTML comments
+ .replaceAll(/[<>]/g, '') // strip any remaining HTML delimiter chars
+ .replaceAll(/^#+\s.*$/gm, ''); // strip Markdown headings
+ } while (stripped !== previous);
+ const line = stripped
+ .split('\n')
+ .map((l) => l.trim())
+ .find((l) => l.length > 0);
+ return line || undefined;
+ } catch {
+ return undefined;
+ }
+}
+
+function getHermesProfile(): AgentProfileResult {
+ const profileName = getActiveHermesProfileName();
+ if (!profileName) return {};
+
+ const profilePath = getHermesProfilePath(profileName);
+ const description = profilePath
+ ? readHermesSoulDescription(path.join(profilePath, 'SOUL.md'))
+ : undefined;
+
+ return {
+ avatar: '⚡',
+ description,
+ title: profileName,
+ };
+}
+
/**
* Fetch the agent profile (title, avatar, description) from the platform
* installed on this device. Dispatched by the server via `device.getAgentProfile`.
*
* - openclaw: `openclaw agents list --json` for name + emoji, workspace
* IDENTITY.md for description fallback
- * - hermes: not yet implemented — returns empty profile
+ * - hermes: active profile name + SOUL.md description
*/
export async function getAgentProfile(params: GetAgentProfileParams): Promise<AgentProfileResult> {
const { platform, agentId } = params;
@@ -96,8 +176,7 @@ export async function getAgentProfile(params: GetAgentProfileParams): Promise<Ag
}
if (platform === 'hermes') {
- // Profile fetch not yet implemented for Hermes — return empty
- return {};
+ return getHermesProfile();
}
return {};
diff --git a/apps/cli/src/tools/heteroTask.ts b/apps/cli/src/tools/heteroTask.ts
index 99b61766dee..635c1eb36bf 100644
--- a/apps/cli/src/tools/heteroTask.ts
+++ b/apps/cli/src/tools/heteroTask.ts
@@ -1,4 +1,7 @@
import { execFileSync, spawn } from 'node:child_process';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
import type { RemoteHeterogeneousAgentType } from '@lobechat/heterogeneous-agents';
@@ -6,7 +9,36 @@ import { getTrpcClient } from '../api/client';
import { getTask, listTasks, removeTask, saveTask } from '../daemon/taskRegistry';
import { log } from '../utils/logger';
-const DEFAULT_HERMES_PORT = 3456;
+// ─── Hermes session persistence ───
+// Maps topicId → hermes session_id so multi-turn conversations can resume
+// the same session across separate `runHeteroTask` invocations.
+
+const LOBEHUB_DIR_NAME = process.env.LOBEHUB_CLI_HOME || '.lobehub';
+const HERMES_SESSIONS_FILE = path.join(os.homedir(), LOBEHUB_DIR_NAME, 'hermes-sessions.json');
+
+function getHermesSessionId(topicId: string): string | undefined {
+ try {
+ const data = JSON.parse(fs.readFileSync(HERMES_SESSIONS_FILE, 'utf8')) as Record<
+ string,
+ string
+ >;
+ return data[topicId];
+ } catch {
+ return undefined;
+ }
+}
+
+function saveHermesSessionId(topicId: string, sessionId: string): void {
+ let data: Record<string, string> = {};
+ try {
+ data = JSON.parse(fs.readFileSync(HERMES_SESSIONS_FILE, 'utf8')) as Record<string, string>;
+ } catch {
+ // File doesn't exist yet — start fresh.
+ }
+ data[topicId] = sessionId;
+ fs.mkdirSync(path.dirname(HERMES_SESSIONS_FILE), { recursive: true });
+ fs.writeFileSync(HERMES_SESSIONS_FILE, JSON.stringify(data), 'utf8');
+}
/** Resolve the absolute path to the `lh` binary to avoid PATH issues in child processes. */
function resolveLhPath(): string {
@@ -32,40 +64,6 @@ export interface CancelHeteroTaskParams {
taskId: string;
}
-export function getHermesPort(): number {
- const env = process.env.HERMES_GATEWAY_PORT;
- if (env) {
- const parsed = Number.parseInt(env, 10);
- if (!Number.isNaN(parsed)) return parsed;
- }
- return DEFAULT_HERMES_PORT;
-}
-
-async function isHermesGatewayRunning(port: number): Promise<boolean> {
- try {
- const res = await fetch(`http://localhost:${port}/health`);
- return res.ok;
- } catch {
- return false;
- }
-}
-
-async function startHermesGateway(port: number): Promise<void> {
- const child = spawn('hermes', ['gateway', 'start'], {
- detached: true,
- env: { ...process.env },
- stdio: 'ignore',
- });
- child.unref();
-
- const deadline = Date.now() + 10_000;
- while (Date.now() < deadline) {
- await new Promise<void>((r) => setTimeout(r, 500));
- if (await isHermesGatewayRunning(port)) return;
- }
- throw new Error(`Hermes gateway did not start within 10s on port ${port}`);
-}
-
async function sendAutoNotify(
topicId: string,
taskId: string,
@@ -231,37 +229,84 @@ export async function runHeteroTask(params: RunHeteroTaskParams): Promise<string
}
if (agentType === 'hermes') {
- const port = getHermesPort();
+ // Kill any existing hermes process for this topicId before spawning a new one.
+ for (const existing of listTasks()) {
+ if (existing.topicId === topicId && existing.agentType === 'hermes') {
+ try {
+ process.kill(existing.pid, 'SIGTERM');
+ } catch {
+ // Already exited — nothing to do.
+ }
+ removeTask(existing.taskId);
+ }
+ }
- if (!(await isHermesGatewayRunning(port))) {
- log.info(`Hermes gateway not running on port ${port}, starting...`);
- await startHermesGateway(port);
+ // Resume the previous session for this topic if one exists.
+ const existingSessionId = getHermesSessionId(topicId);
+ const hermesArgs: string[] = ['chat', '--query', prompt, '--quiet', '--accept-hooks'];
+ if (existingSessionId) {
+ hermesArgs.push('--resume', existingSessionId);
}
- const res = await fetch(`http://localhost:${port}/message`, {
- body: JSON.stringify({ content: prompt, operationId }),
- headers: { 'Content-Type': 'application/json' },
- method: 'POST',
+ // Hermes prints "session_id: <id>\n<response>" to stdout in --quiet mode.
+ // We capture stdout, parse both fields on exit, and relay the response via notify.
+ const child = spawn('hermes', hermesArgs, {
+ cwd: workDir,
+ detached: true,
+ env: { ...process.env },
+ stdio: ['ignore', 'pipe', 'ignore'],
});
- if (!res.ok) {
- throw new Error(`Hermes gateway returned ${res.status}: ${await res.text()}`);
- }
+ const pid = child.pid;
+ if (pid === undefined) throw new Error('Failed to get PID for hermes process');
+ child.unref();
- // pid is 0 for Hermes — the gateway is long-lived and cancellation uses
- // the HTTP /stop API rather than direct signal delivery.
saveTask({
agentId,
agentType,
operationId,
- pid: 0,
+ pid,
startedAt: new Date().toISOString(),
taskId,
topicId,
});
- log.info(`Hermes task dispatched: taskId=${taskId} operationId=${operationId}`);
+ log.info(`Hermes task started: taskId=${taskId} pid=${pid}`);
+
+ let stdout = '';
+ child.stdout.on('data', (chunk: Buffer) => {
+ stdout += chunk.toString();
+ });
+
+ child.on('close', (code, signal) => {
+ removeTask(taskId);
- return JSON.stringify({ operationId, taskId });
+ if (code !== 0 || signal !== null) {
+ const text = signal
+ ? `Task cancelled (signal: ${signal})`
+ : `Task failed (exit code: ${code})`;
+ void sendAutoNotify(topicId, taskId, text, agentId).finally(() =>
+ sendDoneSignal(topicId, agentId),
+ );
+ return;
+ }
+
+ // Parse "session_id: <id>" from the first line, response from the rest.
+ const sessionIdMatch = stdout.match(/^session_id:\s*(\S+)/m);
+ const sessionId = sessionIdMatch?.[1];
+ const response = stdout.replace(/^session_id:[^\n]*\n?/, '').trim();
+
+ if (sessionId) saveHermesSessionId(topicId, sessionId);
+
+ if (response) {
+ void sendAutoNotify(topicId, taskId, response, agentId).finally(() =>
+ sendDoneSignal(topicId, agentId),
+ );
+ } else {
+ void sendDoneSignal(topicId, agentId);
+ }
+ });
+
+ return JSON.stringify({ pid, taskId });
}
throw new Error(`Unsupported agentType: ${agentType as string}`);
@@ -275,25 +320,7 @@ export async function cancelHeteroTask(params: CancelHeteroTaskParams): Promise<
return JSON.stringify({ message: `No task found with taskId: ${taskId}`, success: false });
}
- if (entry.agentType === 'hermes') {
- const port = getHermesPort();
- try {
- await fetch(`http://localhost:${port}/stop`, {
- body: JSON.stringify({ operationId: entry.operationId }),
- headers: { 'Content-Type': 'application/json' },
- method: 'POST',
- });
- } catch (err) {
- log.warn(
- `Failed to send /stop to Hermes gateway: ${err instanceof Error ? err.message : String(err)}`,
- );
- }
- removeTask(taskId);
- await sendAutoNotify(entry.topicId, taskId, 'Task cancelled', entry.agentId);
- return JSON.stringify({ taskId });
- }
-
- // OpenClaw: kill by PID and let the child's close handler send the notify.
+ // Both openclaw and hermes: kill by PID and let the child's close handler send the notify.
try {
process.kill(entry.pid, signal);
} catch (err) {
diff --git a/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts b/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts
index f0613cb1043..41ccbcf0ee8 100644
--- a/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts
+++ b/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts
@@ -1,5 +1,6 @@
import { execFileSync, execSync, spawn } from 'node:child_process';
import fs from 'node:fs';
+import os from 'node:os';
import path from 'node:path';
import type { AgentRunRequestMessage } from '@lobechat/device-gateway-client';
@@ -13,8 +14,6 @@ import LocalFileCtr from './LocalFileCtr';
import RemoteServerConfigCtr from './RemoteServerConfigCtr';
import ShellCommandCtr from './ShellCommandCtr';
-const DEFAULT_HERMES_PORT = 3456;
-
/**
* Inject the lh-notify protocol into the first turn of a new hetero-agent session.
* Tells the agent binary how to push results back to the LobeHub chat UI via `lh notify`.
@@ -66,6 +65,9 @@ export default class GatewayConnectionCtr extends ControllerModule {
/** In-memory registry for running platform agent tasks (openclaw / hermes). */
private readonly platformTasks = new Map<string, PlatformTaskEntry>();
+ /** Maps topicId → hermes session_id for multi-turn conversation continuity. */
+ private readonly hermesSessionMap = new Map<string, string>();
+
// ─── Service Accessor ───
private get service() {
@@ -301,10 +303,71 @@ export default class GatewayConnectionCtr extends ControllerModule {
return this.getOpenClawProfile(agentId);
}
- // hermes and unknown platforms: not yet implemented
+ if (platform === 'hermes') {
+ return this.getHermesProfile();
+ }
+
return {};
}
+ private getHermesProfile(): { avatar?: string; description?: string; title?: string } {
+ // Find the active profile (marked with ◆ in `hermes profile list`).
+ let profileName: string | undefined;
+ try {
+ const listOutput = execFileSync('hermes', ['profile', 'list'], {
+ encoding: 'utf8',
+ timeout: 5000,
+ });
+ profileName = listOutput.match(/◆(\S+)/)?.[1];
+ } catch {
+ return {};
+ }
+ if (!profileName) return {};
+
+ // Get the profile's filesystem path.
+ let profilePath: string | undefined;
+ try {
+ const showOutput = execFileSync('hermes', ['profile', 'show', profileName], {
+ encoding: 'utf8',
+ timeout: 5000,
+ });
+ const raw = showOutput.match(/^Path:\s+(.+)/m)?.[1]?.trim();
+ profilePath = raw?.replace(/^~(?=\/|$)/, os.homedir());
+ } catch {
+ // Profile path unavailable — still return name + avatar.
+ }
+
+ const description = profilePath
+ ? this.readHermesSoulDescription(path.join(profilePath, 'SOUL.md'))
+ : undefined;
+
+ return { avatar: '⚡', description, title: profileName };
+ }
+
+ private readHermesSoulDescription(soulPath: string): string | undefined {
+ try {
+ const content = fs.readFileSync(soulPath, 'utf8');
+ // Loop until stable to handle any malformed/nested comment sequences.
+ let stripped = content;
+ let previous: string;
+ do {
+ previous = stripped;
+ stripped = stripped
+ .replaceAll(/<!--[\s\S]*?-->/g, '') // strip complete HTML comments
+ .replaceAll(/[<>]/g, '') // strip any remaining HTML delimiter chars
+ .replaceAll(/^#+\s.*$/gm, ''); // strip Markdown headings
+ } while (stripped !== previous);
+ return (
+ stripped
+ .split('\n')
+ .map((l) => l.trim())
+ .find((l) => l.length > 0) || undefined
+ );
+ } catch {
+ return undefined;
+ }
+ }
+
private getOpenClawProfile(agentId?: string): {
avatar?: string;
description?: string;
@@ -442,20 +505,74 @@ export default class GatewayConnectionCtr extends ControllerModule {
}
if (agentType === 'hermes') {
- const port = this.getHermesPort();
- if (!(await this.isHermesRunning(port))) {
- await this.startHermesGateway(port);
+ // Kill any existing hermes process for this topicId before spawning a new one.
+ for (const [existingTaskId, entry] of this.platformTasks) {
+ if (entry.topicId === topicId && entry.agentType === 'hermes') {
+ try {
+ process.kill(entry.pid, 'SIGTERM');
+ } catch {
+ // Already exited — nothing to do.
+ }
+ this.platformTasks.delete(existingTaskId);
+ }
}
- const res = await fetch(`http://localhost:${port}/message`, {
- body: JSON.stringify({ content: prompt, operationId }),
- headers: { 'Content-Type': 'application/json' },
- method: 'POST',
+ // Resume the previous session for this topic if one exists.
+ const existingSessionId = this.hermesSessionMap.get(topicId);
+ const hermesArgs: string[] = ['chat', '--query', prompt, '--quiet', '--accept-hooks'];
+ if (existingSessionId) {
+ hermesArgs.push('--resume', existingSessionId);
+ }
+
+ // Hermes prints "session_id: <id>\n<response>" to stdout in --quiet mode.
+ const child = spawn('hermes', hermesArgs, {
+ cwd: workDir,
+ detached: true,
+ env: { ...process.env },
+ stdio: ['ignore', 'pipe', 'ignore'],
+ });
+
+ const pid = child.pid;
+ if (pid === undefined) throw new Error('Failed to get PID for hermes process');
+ child.unref();
+
+ this.platformTasks.set(taskId, { agentId, agentType, operationId, pid, topicId });
+
+ let stdout = '';
+ child.stdout.on('data', (chunk: Buffer) => {
+ stdout += chunk.toString();
+ });
+
+ child.on('close', (code, signal) => {
+ this.platformTasks.delete(taskId);
+
+ if (code !== 0 || signal !== null) {
+ const text = signal
+ ? `Task cancelled (signal: ${signal})`
+ : `Task failed (exit code: ${code})`;
+ void this.sendNotify({ agentId, content: text, role: 'assistant', topicId }).finally(() =>
+ this.sendNotify({ agentId, content: '', done: true, role: 'assistant', topicId }),
+ );
+ return;
+ }
+
+ // Parse "session_id: <id>" from the first line, response from the rest.
+ const sessionIdMatch = stdout.match(/^session_id:\s*(\S+)/m);
+ const sessionId = sessionIdMatch?.[1];
+ const response = stdout.replace(/^session_id:[^\n]*\n?/, '').trim();
+
+ if (sessionId) this.hermesSessionMap.set(topicId, sessionId);
+
+ if (response) {
+ void this.sendNotify({ agentId, content: response, role: 'assistant', topicId }).finally(
+ () => this.sendNotify({ agentId, content: '', done: true, role: 'assistant', topicId }),
+ );
+ } else {
+ void this.sendNotify({ agentId, content: '', done: true, role: 'assistant', topicId });
+ }
});
- if (!res.ok) throw new Error(`Hermes gateway returned ${res.status}: ${await res.text()}`);
- this.platformTasks.set(taskId, { agentId, agentType, operationId, pid: 0, topicId });
- return JSON.stringify({ operationId, taskId });
+ return JSON.stringify({ pid, taskId });
}
throw new Error(`Unsupported agentType: ${agentType}`);
@@ -469,28 +586,7 @@ export default class GatewayConnectionCtr extends ControllerModule {
return JSON.stringify({ message: `No task found with taskId: ${taskId}`, success: false });
}
- if (entry.agentType === 'hermes') {
- const port = this.getHermesPort();
- try {
- await fetch(`http://localhost:${port}/stop`, {
- body: JSON.stringify({ operationId: entry.operationId }),
- headers: { 'Content-Type': 'application/json' },
- method: 'POST',
- });
- } catch {
- // Hermes gateway may already have stopped; ignore
- }
- this.platformTasks.delete(taskId);
- await this.sendNotify({
- agentId: entry.agentId,
- content: 'Task cancelled',
- role: 'assistant',
- topicId: entry.topicId,
- });
- return JSON.stringify({ taskId });
- }
-
- // openclaw: kill by PID; the close handler sends the done signal.
+ // Both openclaw and hermes: kill by PID; the close handler sends the done signal.
try {
process.kill(entry.pid, signal);
} catch {
@@ -547,37 +643,4 @@ export default class GatewayConnectionCtr extends ControllerModule {
return 'lh';
}
}
-
- private getHermesPort(): number {
- const env = process.env['HERMES_GATEWAY_PORT'];
- if (env) {
- const parsed = Number.parseInt(env, 10);
- if (!Number.isNaN(parsed)) return parsed;
- }
- return DEFAULT_HERMES_PORT;
- }
-
- private async isHermesRunning(port: number): Promise<boolean> {
- try {
- return (await fetch(`http://localhost:${port}/health`)).ok;
- } catch {
- return false;
- }
- }
-
- private async startHermesGateway(port: number): Promise<void> {
- const child = spawn('hermes', ['gateway', 'start'], {
- detached: true,
- env: { ...process.env },
- stdio: 'ignore',
- });
- child.unref();
-
- const deadline = Date.now() + 10_000;
- while (Date.now() < deadline) {
- await new Promise<void>((r) => setTimeout(r, 500));
- if (await this.isHermesRunning(port)) return;
- }
- throw new Error(`Hermes gateway did not start within 10s on port ${port}`);
- }
}
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index bace4a7946e..1deae16bd6f 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -378,8 +378,10 @@
"platformAgent.create.comingSoon": "Coming Soon",
"platformAgent.create.create": "Create Agent",
"platformAgent.create.creating": "Creating...",
+ "platformAgent.create.desc.amp": "Connect to Amp running on one of your devices",
"platformAgent.create.desc.hermes": "Connect to Hermes running on one of your devices",
"platformAgent.create.desc.openclaw": "Connect to OpenClaw running on one of your devices",
+ "platformAgent.create.desc.opencode": "Connect to OpenCode running on one of your devices",
"platformAgent.create.descriptionPlaceholder": "Brief description (optional)",
"platformAgent.create.downloadDesktop": "Download Desktop App",
"platformAgent.create.fetchingProfile": "Fetching profile...",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index ea78c7a17d4..b47920073fe 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -378,8 +378,10 @@
"platformAgent.create.comingSoon": "即将推出",
"platformAgent.create.create": "创建 Agent",
"platformAgent.create.creating": "创建中...",
+ "platformAgent.create.desc.amp": "连接你某台设备上的 Amp Agent",
"platformAgent.create.desc.hermes": "连接你某台设备上的 Hermes Agent",
"platformAgent.create.desc.openclaw": "连接你某台设备上的 OpenClaw Agent",
+ "platformAgent.create.desc.opencode": "连接你某台设备上的 OpenCode Agent",
"platformAgent.create.descriptionPlaceholder": "简短描述(可选)",
"platformAgent.create.downloadDesktop": "下载桌面端",
"platformAgent.create.fetchingProfile": "正在读取配置...",
diff --git a/packages/device-gateway-client/src/http.ts b/packages/device-gateway-client/src/http.ts
index 9264a5deedf..cc28dc6eb4e 100644
--- a/packages/device-gateway-client/src/http.ts
+++ b/packages/device-gateway-client/src/http.ts
@@ -74,7 +74,7 @@ export class GatewayHttpClient {
}
async dispatchAgentRun(params: {
- agentType: 'claude-code' | 'codex' | 'hermes' | 'openclaw';
+ agentType: string;
cwd?: string;
deviceId?: string;
jwt: string;
diff --git a/packages/device-gateway-client/src/types.ts b/packages/device-gateway-client/src/types.ts
index ff2ca3dbf50..48df13f251e 100644
--- a/packages/device-gateway-client/src/types.ts
+++ b/packages/device-gateway-client/src/types.ts
@@ -90,7 +90,7 @@ export interface SystemInfoResponseMessage {
/** Server → Client: request the desktop to spawn `lh hetero exec`. */
export interface AgentRunRequestMessage {
- agentType: 'claude-code' | 'codex' | 'hermes' | 'openclaw';
+ agentType: string;
cwd?: string;
jwt: string;
operationId: string;
diff --git a/packages/heterogeneous-agents/src/client/index.ts b/packages/heterogeneous-agents/src/client/index.ts
index 686a77b36a6..acaa0c93ebb 100644
--- a/packages/heterogeneous-agents/src/client/index.ts
+++ b/packages/heterogeneous-agents/src/client/index.ts
@@ -5,8 +5,11 @@ import {
getHeterogeneousAgentConfig,
HETEROGENEOUS_AGENT_CONFIGS,
type HeterogeneousAgentConfig,
+ isRemoteHeterogeneousType,
} from '../config';
+export { isRemoteHeterogeneousType };
+
export interface HeterogeneousAgentClientConfig extends HeterogeneousAgentConfig {
avatar: string;
icon: IconType;
diff --git a/packages/heterogeneous-agents/src/config.ts b/packages/heterogeneous-agents/src/config.ts
index 25098abd770..fdeb9498a7b 100644
--- a/packages/heterogeneous-agents/src/config.ts
+++ b/packages/heterogeneous-agents/src/config.ts
@@ -45,12 +45,14 @@ export const getHeterogeneousAgentConfig = (type: string) =>
*/
export interface RemoteHeterogeneousAgentConfig {
title: string;
- type: 'hermes' | 'openclaw';
+ type: 'amp' | 'hermes' | 'opencode' | 'openclaw';
}
export const REMOTE_HETEROGENEOUS_AGENT_CONFIGS = [
{ title: 'OpenClaw', type: 'openclaw' },
{ title: 'Hermes', type: 'hermes' },
+ { title: 'Amp', type: 'amp' },
+ { title: 'OpenCode', type: 'opencode' },
] as const satisfies readonly RemoteHeterogeneousAgentConfig[];
/** Union of all local CLI hetero types. */
diff --git a/packages/types/src/agent/agencyConfig.ts b/packages/types/src/agent/agencyConfig.ts
index 60eacd0236a..c94767acd92 100644
--- a/packages/types/src/agent/agencyConfig.ts
+++ b/packages/types/src/agent/agencyConfig.ts
@@ -8,7 +8,7 @@
* - **Local CLI** (`claude-code` | `codex`): spawned as a child process on the
* desktop; uses `command`, `args`, `env`, `systemContext`.
*
- * - **Remote device** (`openclaw` | `hermes`): dispatched to a machine
+ * - **Remote device** (`openclaw` | `hermes` | `amp` | `opencode`): dispatched to a machine
* connected via `lh connect`; device is identified by `LobeAgentAgencyConfig.boundDeviceId`.
* `platformAgentId` selects the named agent on the remote platform (defaults to `'main'`).
*/
@@ -33,7 +33,7 @@ export interface HeterogeneousProviderConfig {
*/
systemContext?: string;
/** Agent runtime type. */
- type: 'claude-code' | 'codex' | 'hermes' | 'openclaw';
+ type: 'amp' | 'claude-code' | 'codex' | 'hermes' | 'opencode' | 'openclaw';
}
/**
diff --git a/src/features/CreatePlatformAgent/index.tsx b/src/features/CreatePlatformAgent/index.tsx
index ff5be166454..c3092af7647 100644
--- a/src/features/CreatePlatformAgent/index.tsx
+++ b/src/features/CreatePlatformAgent/index.tsx
@@ -124,7 +124,7 @@ const CreatePlatformAgentModal = memo<CreatePlatformAgentModalProps>(
// Platforms that are not yet ready for production use.
// Remove a type from this set when the platform is fully supported.
- const COMING_SOON_PLATFORMS = new Set<RemoteHeterogeneousAgentType>(['hermes']);
+ const COMING_SOON_PLATFORMS = new Set<RemoteHeterogeneousAgentType>(['amp', 'opencode']);
// Derive platform display list from the registry — adding a new platform to
// REMOTE_HETEROGENEOUS_AGENT_CONFIGS automatically includes it here.
diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts
index edb5a091d9e..8736f4592f6 100644
--- a/src/locales/default/chat.ts
+++ b/src/locales/default/chat.ts
@@ -374,6 +374,8 @@ export default {
// Platform agent: per-platform descriptions shown in step 0 of the creation modal
'platformAgent.create.desc.openclaw': 'Connect to OpenClaw running on one of your devices',
'platformAgent.create.desc.hermes': 'Connect to Hermes running on one of your devices',
+ 'platformAgent.create.desc.amp': 'Connect to Amp running on one of your devices',
+ 'platformAgent.create.desc.opencode': 'Connect to OpenCode running on one of your devices',
// Platform agent: shared device status label (used in Select option labels)
'platformAgent.device.online': 'Online',
diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.test.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.test.tsx
index 7da735b8ab5..06ca6a15f5a 100644
--- a/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.test.tsx
+++ b/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.test.tsx
@@ -28,6 +28,8 @@ vi.mock('@lobechat/heterogeneous-agents/client', () => ({
icon: () => <span>Codex Icon</span>,
title: 'Codex',
},
+ isRemoteHeterogeneousType: (type: string) =>
+ ['openclaw', 'hermes', 'amp', 'opencode'].includes(type),
}));
vi.mock('@lobehub/ui', () => ({
diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.tsx
index 54e87bd884f..118b25b987e 100644
--- a/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.tsx
+++ b/src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.tsx
@@ -2,7 +2,10 @@
import { isDesktop } from '@lobechat/const';
import { type ClaudeAuthStatus, type ToolStatus } from '@lobechat/electron-client-ipc';
-import { getHeterogeneousAgentClientConfig } from '@lobechat/heterogeneous-agents/client';
+import {
+ getHeterogeneousAgentClientConfig,
+ isRemoteHeterogeneousType,
+} from '@lobechat/heterogeneous-agents/client';
import type { HeterogeneousProviderConfig } from '@lobechat/types';
import { ActionIcon, CopyButton, Flexbox, Icon, Input, Tag, Text, Tooltip } from '@lobehub/ui';
import { createStyles } from 'antd-style';
@@ -250,13 +253,8 @@ const HeterogeneousAgentStatusCard = memo<HeterogeneousAgentStatusCardProps>(
}, [provider.type, resolvedCommand]);
const detect = useCallback(async () => {
- // openclaw / hermes are remote device agents — no local CLI to detect.
- if (
- provider.type === 'openclaw' ||
- provider.type === 'hermes' ||
- !isDesktop ||
- !resolvedCommand
- ) {
+ // Remote platform agents (openclaw, hermes, amp, opencode, …) have no local CLI to detect.
+ if (isRemoteHeterogeneousType(provider.type) || !isDesktop || !resolvedCommand) {
setDetecting(false);
return;
}