diff --git a/src/lib/actions/sandbox/connect-flow.test.ts b/src/lib/actions/sandbox/connect-flow.test.ts index ff78e8b0ef8..a97337e3a15 100644 --- a/src/lib/actions/sandbox/connect-flow.test.ts +++ b/src/lib/actions/sandbox/connect-flow.test.ts @@ -38,6 +38,8 @@ type ConnectHarnessOptions = { spawnSignal?: NodeJS.Signals | null; spawnStatus?: number | null; sttyThrows?: boolean; + versionCheck?: unknown; + versionWarningLines?: string[]; }; function throwSttyFailure(): never { @@ -108,8 +110,12 @@ function createConnectHarness(options: ConnectHarnessOptions = {}): ConnectHarne detected: true, sessions: [{ pid: 1 }, { pid: 2 }], }); - vi.spyOn(sandboxVersion, "checkAgentVersion").mockReturnValue({ isStale: false }); - vi.spyOn(sandboxVersion, "formatStalenessWarning").mockReturnValue([]); + vi.spyOn(sandboxVersion, "checkAgentVersion").mockReturnValue( + (options.versionCheck ?? { isStale: false }) as never, + ); + vi.spyOn(sandboxVersion, "formatStalenessWarning").mockReturnValue( + options.versionWarningLines ?? [], + ); const checkAndRecoverSpy = vi .spyOn(processRecovery, "checkAndRecoverSandboxProcesses") .mockReturnValue(options.processCheck ?? { checked: true, wasRunning: true, recovered: false }); @@ -373,6 +379,30 @@ describe("connectSandbox flow", () => { expect(exitSpy).toHaveBeenCalledWith(0); }); + it("prints stale Hermes Desktop compatibility guidance before connecting", async () => { + const harness = createConnectHarness({ + agentName: "hermes", + versionCheck: { + sandboxVersion: "2026.5.16", + expectedVersion: "2026.6.19", + isStale: true, + detectionMethod: "registry", + }, + versionWarningLines: [ + "", + " Hermes Desktop requires Hermes Agent v2026.6.5+ (2026.5.16 lacks /api/profiles/sessions).", + " Rebuild this sandbox before connecting it from Hermes Desktop.", + ], + }); + + await expect(harness.connectSandbox("alpha")).rejects.toThrow("process.exit(0)"); + + const errorOutput = harness.errorSpy.mock.calls.map((call) => String(call[0] ?? "")).join("\n"); + expect(errorOutput).toContain("Hermes Desktop requires Hermes Agent v2026.6.5+"); + expect(errorOutput).toContain("/api/profiles/sessions"); + expect(errorOutput).toContain("Rebuild this sandbox"); + }); + it("stops before opening SSH when the sandbox list reports a terminal failure phase", async () => { const harness = createConnectHarness({ listOutput: "alpha Error" }); diff --git a/src/lib/actions/sandbox/status-flow.test.ts b/src/lib/actions/sandbox/status-flow.test.ts index 01eee2b0a08..869489f5549 100644 --- a/src/lib/actions/sandbox/status-flow.test.ts +++ b/src/lib/actions/sandbox/status-flow.test.ts @@ -234,6 +234,28 @@ describe("showSandboxStatus flow", () => { }); }); + it("prints Hermes Desktop compatibility guidance for stale Hermes backends", async () => { + const harness = createStatusFlowHarness({ + sandboxEntry: { + agent: "hermes", + agentVersion: "2026.5.16", + }, + }); + harness.checkAgentVersionSpy.mockReturnValue({ + sandboxVersion: "2026.5.16", + expectedVersion: "2026.6.19", + isStale: true, + detectionMethod: "registry", + }); + + await expect(harness.showSandboxStatus("alpha")).resolves.toBeUndefined(); + + const output = harness.logSpy.mock.calls.map((call) => String(call[0])).join("\n"); + expect(output).toContain("Hermes Desktop requires Hermes Agent v2026.6.5+"); + expect(output).toContain("/api/profiles/sessions"); + expect(output).toContain("Rebuild this sandbox"); + }); + it("preserves the registry entry and exits when the live gateway is missing the sandbox", async () => { const harness = createStatusFlowHarness({ lookupState: "missing" }); diff --git a/src/lib/actions/sandbox/status.ts b/src/lib/actions/sandbox/status.ts index 48ebee9a758..67262654640 100644 --- a/src/lib/actions/sandbox/status.ts +++ b/src/lib/actions/sandbox/status.ts @@ -286,6 +286,12 @@ export async function showSandboxStatus(sandboxName: string): Promise { if (versionCheck.isStale) { console.log(` ${YW}Update: v${versionCheck.expectedVersion} available${R}`); console.log(` Run \`${CLI_NAME} ${sandboxName} rebuild\` to upgrade`); + for (const line of sandboxVersion.formatHermesDesktopCompatibilityWarning( + sandboxName, + versionCheck, + )) { + console.log(line); + } } else if ( shouldProbeRuntimeVersion && versionCheck.detectionMethod === "unavailable" && diff --git a/src/lib/sandbox/version.test.ts b/src/lib/sandbox/version.test.ts index 0df468d200b..cebdbb8d525 100644 --- a/src/lib/sandbox/version.test.ts +++ b/src/lib/sandbox/version.test.ts @@ -55,7 +55,11 @@ import { spawnSync } from "child_process"; import { captureSandboxSshConfigCommand } from "../adapters/openshell/client.js"; import { OPENSHELL_PROBE_TIMEOUT_MS } from "../adapters/openshell/timeouts.js"; import * as registry from "../state/registry.js"; -import { checkAgentVersion, formatStalenessWarning } from "./version.js"; +import { + checkAgentVersion, + formatHermesDesktopCompatibilityWarning, + formatStalenessWarning, +} from "./version.js"; describe("checkAgentVersion", () => { let tmpDir: string; @@ -261,4 +265,42 @@ describe("formatStalenessWarning", () => { expect(joined).toContain("2026.5.27"); expect(joined).toContain("rebuild"); }); + + it("explains the Hermes Desktop API mismatch for old Hermes sandboxes", () => { + registry.registerSandbox({ name: "my-hermes", agent: "hermes" }); + + const lines = formatHermesDesktopCompatibilityWarning("my-hermes", { + sandboxVersion: "2026.5.16", + expectedVersion: "2026.6.19", + isStale: true, + detectionMethod: "registry", + }); + const joined = lines.join("\n"); + + expect(joined).toContain("Hermes Desktop requires Hermes Agent v2026.6.5+"); + expect(joined).toContain("/api/profiles/sessions"); + expect(joined).toContain("Rebuild this sandbox"); + }); + + it("does not show the Hermes Desktop warning for current Hermes or other agents", () => { + registry.registerSandbox({ name: "my-hermes", agent: "hermes" }); + + expect( + formatHermesDesktopCompatibilityWarning("my-hermes", { + sandboxVersion: "2026.6.19", + expectedVersion: "2026.6.19", + isStale: false, + detectionMethod: "registry", + }), + ).toEqual([]); + + expect( + formatHermesDesktopCompatibilityWarning("my-sb", { + sandboxVersion: "2026.5.16", + expectedVersion: "2026.6.19", + isStale: true, + detectionMethod: "registry", + }), + ).toEqual([]); + }); }); diff --git a/src/lib/sandbox/version.ts b/src/lib/sandbox/version.ts index 1b21d4f6679..ce369b4c967 100644 --- a/src/lib/sandbox/version.ts +++ b/src/lib/sandbox/version.ts @@ -18,9 +18,12 @@ import { import { resolveOpenshell } from "../adapters/openshell/resolve.js"; import { OPENSHELL_PROBE_TIMEOUT_MS } from "../adapters/openshell/timeouts.js"; import { loadAgent } from "../agent/defs.js"; +import { D, R } from "../cli/terminal-style.js"; import * as registry from "../state/registry.js"; import { createTempSshConfig } from "./temp-ssh-config.js"; +const HERMES_DESKTOP_MIN_VERSION = "2026.6.5"; + export interface VersionCheckResult { sandboxVersion: string | null; expectedVersion: string | null; @@ -170,6 +173,24 @@ export function formatStalenessWarning(sandboxName: string, result: VersionCheck "", ` \u26a0 Sandbox '${sandboxName}' is running ${agentName} ${result.sandboxVersion} (current: ${result.expectedVersion})`, ` Run: nemoclaw ${sandboxName} rebuild`, + ...formatHermesDesktopCompatibilityWarning(sandboxName, result), "", ]; } + +/** + * Explain the Hermes Desktop/backend API mismatch for old Hermes sandboxes. + */ +export function formatHermesDesktopCompatibilityWarning( + sandboxName: string, + result: VersionCheckResult, +): string[] { + const agent = resolveAgentForSandbox(sandboxName); + if (agent.name !== "hermes") return []; + if (!result.sandboxVersion) return []; + if (versionGte(result.sandboxVersion, HERMES_DESKTOP_MIN_VERSION)) return []; + return [ + ` ${D}Hermes Desktop requires Hermes Agent v${HERMES_DESKTOP_MIN_VERSION}+ (${result.sandboxVersion} lacks /api/profiles/sessions).${R}`, + " Rebuild this sandbox before connecting it from Hermes Desktop.", + ]; +}