From 0ebbde09f903d8400928ea15b629ee771523c3ef Mon Sep 17 00:00:00 2001 From: Yanyun Liao Date: Fri, 3 Jul 2026 21:16:43 +0800 Subject: [PATCH 1/4] fix(sessions): route sessions passthrough at the sandbox's own agent binary `nemoclaw sessions [list]` and its `nemohermes hermes sessions` alias hardcoded `openclaw sessions` as the in-sandbox command. Hermes sandboxes ship the `hermes` binary at `/usr/local/bin/hermes` and do not carry `openclaw`, so `openshell sandbox exec --name -- openclaw sessions` fails with `openclaw: command not found` before the Hermes agent's sessions surface can respond. Look up the sandbox's agent via `registry.getSandbox(name)` and pick `hermes` when the agent is `hermes`, keeping `openclaw` as the default. The OpenClaw-specific warm-up filter (a NemoClaw onboard artifact) is now gated on the OpenClaw binary path; Hermes sandboxes go straight through `execSandbox` so their native output is preserved verbatim. Fixes #6247 Signed-off-by: Yanyun Liao --- .../sandbox/sessions/passthrough.test.ts | 38 +++++++++++++++++++ .../actions/sandbox/sessions/passthrough.ts | 11 +++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/lib/actions/sandbox/sessions/passthrough.test.ts b/src/lib/actions/sandbox/sessions/passthrough.test.ts index f0e2eff7e97..e833ba505d1 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.test.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.test.ts @@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; const captureMock = vi.hoisted(() => vi.fn()); const execMock = vi.hoisted(() => vi.fn(async () => {})); const ensureLiveMock = vi.hoisted(() => vi.fn(async () => ({}))); +const getSandboxMock = vi.hoisted(() => vi.fn(() => null as { agent?: string } | null)); vi.mock("../../../adapters/openshell/runtime", () => ({ captureOpenshell: captureMock, @@ -15,6 +16,7 @@ vi.mock("../exec", async () => { return { ...actual, execSandbox: execMock }; }); vi.mock("../gateway-state", () => ({ ensureLiveSandboxOrExit: ensureLiveMock })); +vi.mock("../../../state/registry", () => ({ getSandbox: getSandboxMock })); import { WARMUP_SESSION_ID_PREFIX } from "../warmup-session"; import { @@ -181,6 +183,8 @@ describe("runSessionsPassthrough", () => { captureMock.mockReset(); execMock.mockClear(); ensureLiveMock.mockClear(); + getSandboxMock.mockReset(); + getSandboxMock.mockReturnValue(null); stdoutSpy = vi.spyOn(process.stdout, "write").mockImplementation(() => true); stderrSpy = vi.spyOn(process.stderr, "write").mockImplementation(() => true); consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => undefined); @@ -342,6 +346,40 @@ describe("runSessionsPassthrough", () => { expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining("--limit")); }); + it("routes to the hermes binary and skips warm-up filtering on hermes sandboxes (#6247)", async () => { + getSandboxMock.mockReturnValue({ agent: "hermes" }); + + await runSessionsPassthrough("hermes", { extraArgs: [] }); + + expect(captureMock).not.toHaveBeenCalled(); + expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions"]); + }); + + it("uses openclaw binary for openclaw-agent sandboxes (#6247)", async () => { + getSandboxMock.mockReturnValue({ agent: "openclaw" }); + captureMock.mockReturnValueOnce({ status: 0, output: "Sessions listed: 0\n" }); + + await runSessionsPassthrough("alpha", { extraArgs: [] }); + + expect(execMock).not.toHaveBeenCalled(); + expect(captureMock).toHaveBeenCalledWith( + ["sandbox", "exec", "--name", "alpha", "--", "openclaw", "sessions"], + { ignoreError: true, includeStreams: true, maxBuffer: 64 * 1024 * 1024 }, + ); + }); + + it("routes hermes `sessions list` with forwarded flags via execSandbox (#6247)", async () => { + getSandboxMock.mockReturnValue({ agent: "hermes" }); + + await runSessionsPassthrough("hermes", { + verb: "list", + extraArgs: ["--json"], + }); + + expect(captureMock).not.toHaveBeenCalled(); + expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions", "list", "--json"]); + }); + it("prints captured output when OpenClaw exits non-zero", async () => { const exitSpy = vi.spyOn(process, "exit").mockImplementation((( code?: string | number | null, diff --git a/src/lib/actions/sandbox/sessions/passthrough.ts b/src/lib/actions/sandbox/sessions/passthrough.ts index 9a3bd6762ce..d8815a2b824 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.ts @@ -3,6 +3,7 @@ import { captureOpenshell } from "../../../adapters/openshell/runtime"; import { CLI_NAME } from "../../../cli/branding"; +import * as registry from "../../../state/registry"; import { buildOpenshellExecArgs, computeExitCode, execSandbox } from "../exec"; import { ensureLiveSandboxOrExit } from "../gateway-state"; import { isWarmupSessionId, WARMUP_SESSION_ID_PREFIX } from "../warmup-session"; @@ -202,10 +203,16 @@ export async function runSessionsPassthrough( { verb, extraArgs = [] }: SessionsPassthroughOptions = {}, ): Promise { await ensureLiveSandboxOrExit(sandboxName, { allowNonReadyPhase: true }); - const command = ["openclaw", "sessions"]; + // Hermes sandboxes ship the `hermes` binary in place of OpenClaw's + // `openclaw` binary, and `openclaw` does not exist inside them (#6247). + // Route the passthrough at the in-sandbox agent's own binary name and + // bypass the OpenClaw-specific warm-up filter for non-OpenClaw agents. + const sandboxAgent = registry.getSandbox(sandboxName)?.agent; + const inSandboxBinary = sandboxAgent === "hermes" ? "hermes" : "openclaw"; + const command = [inSandboxBinary, "sessions"]; if (verb) command.push(verb); for (const arg of extraArgs) command.push(arg); - if (isFilterableListPassthrough(verb)) { + if (isFilterableListPassthrough(verb) && inSandboxBinary === "openclaw") { const result = captureOpenshell(buildOpenshellExecArgs(sandboxName, command), { ignoreError: true, includeStreams: true, From a301f708a3073d4da8af55f901509742e869f305 Mon Sep 17 00:00:00 2001 From: Yanyun Liao Date: Fri, 3 Jul 2026 21:36:47 +0800 Subject: [PATCH 2/4] fix(sessions): agent-neutral help text + trust-boundary comment + default-agent tests Address PR review advisor feedback on #6249: - Update oclif command descriptions in `src/commands/sandbox/sessions.ts` and `src/commands/sandbox/sessions/list.ts`, and the `printSessionsPassthroughHelp` output, so hermes users are no longer told the command passes through to `openclaw sessions` or that all flags are OpenClaw flags. The help now names both agent binaries and scopes warm-up filtering + OpenClaw-only flags to OpenClaw sandboxes. - Add a code comment at the `registry.getSandbox` call documenting the trust boundary: the registry is CLI-owned and sandbox processes cannot mutate it, so the `agent` field is a trusted configuration input; unknown/missing values fall through to the default `openclaw` branch. - Add regression tests: default (null registry entry) uses openclaw binary + filter path; unknown agent value ('custom-future-agent') also falls through to openclaw + filter; help text asserts hermes is named and OpenClaw-only passthrough is not promised. Refs #6247 Signed-off-by: Yanyun Liao --- src/commands/sandbox/sessions.ts | 6 +- src/commands/sandbox/sessions/list.ts | 6 +- .../sandbox/sessions/passthrough.test.ts | 63 +++++++++++++++++++ .../actions/sandbox/sessions/passthrough.ts | 26 ++++++-- 4 files changed, 91 insertions(+), 10 deletions(-) diff --git a/src/commands/sandbox/sessions.ts b/src/commands/sandbox/sessions.ts index 593df0b69d9..758698ffd68 100644 --- a/src/commands/sandbox/sessions.ts +++ b/src/commands/sandbox/sessions.ts @@ -11,10 +11,10 @@ import { NemoClawCommand } from "../../lib/cli/nemoclaw-oclif-command"; export default class SandboxSessionsCommand extends NemoClawCommand { static id = "sandbox:sessions"; static strict = false; - static summary = "List OpenClaw conversation sessions in a sandbox"; + static summary = "List conversation sessions in a sandbox"; static description = - "Pass through to `openclaw sessions` in the sandbox. With no subcommand the in-sandbox CLI lists stored sessions for the configured default agent, hiding internal NemoClaw onboard warm-up sessions from default user-facing output. Additional OpenClaw flags are forwarded verbatim after the sandbox name."; - static usage = [" [openclaw-sessions-flags...]"]; + "Pass through to the sandbox agent's `sessions` command (`openclaw sessions` for OpenClaw sandboxes, `hermes sessions` for Hermes sandboxes). On OpenClaw sandboxes the in-sandbox CLI lists stored sessions for the configured default agent, and internal NemoClaw onboard warm-up sessions are hidden from default user-facing output; OpenClaw-specific flags are forwarded verbatim. Hermes sandboxes pass through their native output unchanged."; + static usage = [" [sessions-flags...]"]; static examples = [ "<%= config.bin %> sandbox sessions alpha", "<%= config.bin %> sandbox sessions alpha --all-agents", diff --git a/src/commands/sandbox/sessions/list.ts b/src/commands/sandbox/sessions/list.ts index b83155dfb7f..f1ea1220e9e 100644 --- a/src/commands/sandbox/sessions/list.ts +++ b/src/commands/sandbox/sessions/list.ts @@ -11,10 +11,10 @@ import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command"; export default class SandboxSessionsListCommand extends NemoClawCommand { static id = "sandbox:sessions:list"; static strict = false; - static summary = "List OpenClaw conversation sessions in a sandbox"; + static summary = "List conversation sessions in a sandbox"; static description = - "Pass through to `openclaw sessions list` in the sandbox, hiding internal NemoClaw onboard warm-up sessions from default user-facing output. All OpenClaw flags (--agent, --all-agents, --active, --limit, --json, --store, --verbose) are forwarded verbatim."; - static usage = [" [openclaw-sessions-list-flags...]"]; + "Pass through to the sandbox agent's `sessions list` command (`openclaw sessions list` for OpenClaw sandboxes, `hermes sessions list` for Hermes sandboxes). On OpenClaw sandboxes, internal NemoClaw onboard warm-up sessions are hidden from default user-facing output and OpenClaw flags (--agent, --all-agents, --active, --limit, --json, --store, --verbose) are forwarded verbatim. Hermes sandboxes pass through their native output unchanged."; + static usage = [" [sessions-list-flags...]"]; static examples = [ "<%= config.bin %> sandbox sessions list alpha", "<%= config.bin %> sandbox sessions list alpha --agent work --json", diff --git a/src/lib/actions/sandbox/sessions/passthrough.test.ts b/src/lib/actions/sandbox/sessions/passthrough.test.ts index e833ba505d1..58700b69d09 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.test.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.test.ts @@ -22,6 +22,7 @@ import { WARMUP_SESSION_ID_PREFIX } from "../warmup-session"; import { filterWarmupSessionsListJson, filterWarmupSessionsListText, + printSessionsPassthroughHelp, runSessionsPassthrough, } from "./passthrough"; @@ -174,6 +175,42 @@ describe("filterWarmupSessionsListText", () => { }); }); +describe("printSessionsPassthroughHelp", () => { + let logSpy: ReturnType; + + beforeEach(() => { + logSpy = vi.spyOn(console, "log").mockImplementation(() => undefined); + }); + + afterEach(() => { + logSpy.mockRestore(); + }); + + function capturedHelpText(): string { + return logSpy.mock.calls.map((call) => String(call[0] ?? "")).join("\n"); + } + + it("does not promise OpenClaw-only passthrough for the generic sessions command (#6247)", () => { + printSessionsPassthroughHelp(); + const help = capturedHelpText(); + + expect(help).not.toMatch(/Pass-through to `openclaw sessions/i); + expect(help).toMatch(/openclaw/i); + expect(help).toMatch(/hermes/i); + // Warm-up filtering is documented as OpenClaw-specific, not universal. + expect(help).toMatch(/warm-up[^\n]*OpenClaw|OpenClaw[^\n]*warm-up/i); + }); + + it("scopes the list-verb help to per-agent binaries and OpenClaw-only filtering (#6247)", () => { + printSessionsPassthroughHelp("list"); + const help = capturedHelpText(); + + expect(help).not.toMatch(/Pass-through to `openclaw sessions list/i); + expect(help).toMatch(/sessions list/); + expect(help).toMatch(/hermes/i); + }); +}); + describe("runSessionsPassthrough", () => { let stdoutSpy: ReturnType; let stderrSpy: ReturnType; @@ -380,6 +417,32 @@ describe("runSessionsPassthrough", () => { expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions", "list", "--json"]); }); + it("defaults to the openclaw binary + filter path when the registry has no entry (#6247)", async () => { + getSandboxMock.mockReturnValue(null); + captureMock.mockReturnValueOnce({ status: 0, output: "Sessions listed: 0\n" }); + + await runSessionsPassthrough("alpha", { extraArgs: [] }); + + expect(execMock).not.toHaveBeenCalled(); + expect(captureMock).toHaveBeenCalledWith( + ["sandbox", "exec", "--name", "alpha", "--", "openclaw", "sessions"], + { ignoreError: true, includeStreams: true, maxBuffer: 64 * 1024 * 1024 }, + ); + }); + + it("defaults to the openclaw binary for an unknown agent value (#6247)", async () => { + getSandboxMock.mockReturnValue({ agent: "custom-future-agent" }); + captureMock.mockReturnValueOnce({ status: 0, output: "Sessions listed: 0\n" }); + + await runSessionsPassthrough("alpha", { extraArgs: [] }); + + expect(execMock).not.toHaveBeenCalled(); + expect(captureMock).toHaveBeenCalledWith( + ["sandbox", "exec", "--name", "alpha", "--", "openclaw", "sessions"], + { ignoreError: true, includeStreams: true, maxBuffer: 64 * 1024 * 1024 }, + ); + }); + it("prints captured output when OpenClaw exits non-zero", async () => { const exitSpy = vi.spyOn(process, "exit").mockImplementation((( code?: string | number | null, diff --git a/src/lib/actions/sandbox/sessions/passthrough.ts b/src/lib/actions/sandbox/sessions/passthrough.ts index d8815a2b824..950c2574e05 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.ts @@ -28,15 +28,26 @@ export function hasSessionsPassthroughHelpToken(args: readonly string[]): boolea export function printSessionsPassthroughHelp(verb?: SessionsPassthroughVerb): void { const usageSuffix = verb ? ` ${verb}` : ""; - const flagsToken = verb ? `openclaw-sessions-${verb}-flags` : "openclaw-sessions-flags"; + const flagsToken = verb ? `sessions-${verb}-flags` : "sessions-flags"; console.log(""); console.log(` Usage: ${CLI_NAME} sessions${usageSuffix} [${flagsToken}...]`); console.log(""); console.log( - ` Pass-through to \`openclaw sessions${usageSuffix} ...\` inside the sandbox via \`openshell sandbox exec\`.`, + ` Pass-through to the sandbox agent's \`sessions${usageSuffix} ...\` command inside the sandbox`, ); - console.log(" Internal NemoClaw onboard warm-up sessions are hidden from default list output."); - console.log(" All flags accepted by the in-sandbox OpenClaw CLI are forwarded verbatim."); + console.log( + " via `openshell sandbox exec` — `openclaw sessions ...` for OpenClaw sandboxes, `hermes", + ); + console.log( + " sessions ...` for Hermes sandboxes; the in-sandbox binary is picked from the sandbox's agent.", + ); + console.log( + " On OpenClaw sandboxes, internal NemoClaw onboard warm-up sessions are hidden from default", + ); + console.log( + " list output and OpenClaw-specific flags are forwarded verbatim. Hermes sandboxes pass", + ); + console.log(" through their native output unchanged."); console.log(""); } @@ -207,6 +218,13 @@ export async function runSessionsPassthrough( // `openclaw` binary, and `openclaw` does not exist inside them (#6247). // Route the passthrough at the in-sandbox agent's own binary name and // bypass the OpenClaw-specific warm-up filter for non-OpenClaw agents. + // + // Trust boundary: `registry.getSandbox()` reads the local user-owned + // sandbox registry (~/.nemoclaw/state/*), which is written only by + // NemoClaw CLI commands (onboard, sandbox create, upgrade-sandboxes). + // Sandbox processes cannot mutate it, so the `agent` field here is a + // trusted configuration input; unknown / missing values fall through + // to the default `openclaw` branch below. const sandboxAgent = registry.getSandbox(sandboxName)?.agent; const inSandboxBinary = sandboxAgent === "hermes" ? "hermes" : "openclaw"; const command = [inSandboxBinary, "sessions"]; From bb76ce01a5e6ae601836841c540df71917bd6894 Mon Sep 17 00:00:00 2001 From: Yanyun Liao Date: Fri, 3 Jul 2026 21:41:44 +0800 Subject: [PATCH 3/4] fix(sessions): annotate capturedHelpText callback param to satisfy strict typecheck `build-typecheck` (`tsc -p tsconfig.cli.json`) has stricter `noImplicitAny` than the `build:cli` project graph, and flagged the `(call) => ...` callback parameter in the new `printSessionsPassthroughHelp` describe block as implicit `any`. Annotate it as `unknown[]` (matching vitest's `mock.calls` element type) so the typecheck passes. Refs #6247 Signed-off-by: Yanyun Liao --- src/lib/actions/sandbox/sessions/passthrough.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/actions/sandbox/sessions/passthrough.test.ts b/src/lib/actions/sandbox/sessions/passthrough.test.ts index 58700b69d09..74ac2ef615b 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.test.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.test.ts @@ -187,7 +187,7 @@ describe("printSessionsPassthroughHelp", () => { }); function capturedHelpText(): string { - return logSpy.mock.calls.map((call) => String(call[0] ?? "")).join("\n"); + return logSpy.mock.calls.map((call: unknown[]) => String(call[0] ?? "")).join("\n"); } it("does not promise OpenClaw-only passthrough for the generic sessions command (#6247)", () => { From 9c7cf1d8ed37e7a8c7374e65e355bdad1f84222d Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 3 Jul 2026 17:48:51 -0700 Subject: [PATCH 4/4] fix(sessions): list bare Hermes sessions (#6247) Map the parent command to Hermes' required list subcommand and align help, tests, and docs. Signed-off-by: Carlos Villela --- docs/reference/commands-nemohermes.mdx | 13 ++++---- docs/reference/commands.mdx | 30 +++++++++++++++++++ src/commands/sandbox/sessions.ts | 5 ++-- src/commands/sandbox/sessions/list.ts | 2 +- .../sandbox/sessions/passthrough.test.ts | 10 +++---- .../actions/sandbox/sessions/passthrough.ts | 19 ++++++------ src/lib/cli/public-display-sessions.ts | 8 ++--- 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/docs/reference/commands-nemohermes.mdx b/docs/reference/commands-nemohermes.mdx index b02cd493796..94c0660c0d9 100644 --- a/docs/reference/commands-nemohermes.mdx +++ b/docs/reference/commands-nemohermes.mdx @@ -1192,23 +1192,22 @@ nemohermes my-assistant agents delete work --force --json ### `nemohermes sessions` -List OpenClaw conversation sessions in the sandbox. -With no subcommand the in-sandbox CLI lists stored sessions for the configured default agent. -NemoClaw invokes `openclaw sessions` via `openshell sandbox exec` and forwards OpenClaw flags verbatim, but filters default list output so internal `nemoclaw-onboard-warmup-*` sessions created during onboarding are hidden from user-facing output. +List Hermes conversation sessions in the sandbox. +NemoClaw invokes `hermes sessions list` via `openshell sandbox exec`, forwards native Hermes flags such as `--source` and `--limit`, and streams the output unchanged. ```bash nemohermes my-assistant sessions -nemohermes my-assistant sessions --all-agents --json +nemohermes my-assistant sessions --source cli --limit 20 ``` ### `nemohermes sessions list` -Invoke `openclaw sessions list` inside the sandbox. -NemoClaw forwards every flag the in-sandbox CLI accepts (`--agent`, `--all-agents`, `--active`, `--limit`, `--json`, `--store`, `--verbose`) and filters the resulting default table or JSON so internal `nemoclaw-onboard-warmup-*` sessions are hidden. +Invoke `hermes sessions list` inside the sandbox. +NemoClaw forwards native Hermes flags such as `--source` and `--limit` and streams the output unchanged. ```bash nemohermes my-assistant sessions list -nemohermes my-assistant sessions list --agent work --json +nemohermes my-assistant sessions list --source cli --limit 20 ``` ### `nemohermes sessions reset ` diff --git a/docs/reference/commands.mdx b/docs/reference/commands.mdx index 68a2eb2d448..16ac9d04906 100644 --- a/docs/reference/commands.mdx +++ b/docs/reference/commands.mdx @@ -1538,6 +1538,8 @@ Pass `-f` / `--file ` to point at the manifest; `--yes` confirms th ### `$$nemoclaw sessions` + + List OpenClaw conversation sessions in the sandbox. With no subcommand the in-sandbox CLI lists stored sessions for the configured default agent. NemoClaw invokes `openclaw sessions` via `openshell sandbox exec` and forwards OpenClaw flags verbatim, but filters default list output so internal `nemoclaw-onboard-warmup-*` sessions created during onboarding are hidden from user-facing output. @@ -1547,8 +1549,23 @@ $$nemoclaw my-assistant sessions $$nemoclaw my-assistant sessions --all-agents --json ``` + + + +List Hermes conversation sessions in the sandbox. +NemoClaw invokes `hermes sessions list` via `openshell sandbox exec`, forwards native Hermes flags such as `--source` and `--limit`, and streams the output unchanged. + +```bash +$$nemoclaw my-assistant sessions +$$nemoclaw my-assistant sessions --source cli --limit 20 +``` + + + ### `$$nemoclaw sessions list` + + Invoke `openclaw sessions list` inside the sandbox. NemoClaw forwards every flag the in-sandbox CLI accepts (`--agent`, `--all-agents`, `--active`, `--limit`, `--json`, `--store`, `--verbose`) and filters the resulting default table or JSON so internal `nemoclaw-onboard-warmup-*` sessions are hidden. @@ -1557,6 +1574,19 @@ $$nemoclaw my-assistant sessions list $$nemoclaw my-assistant sessions list --agent work --json ``` + + + +Invoke `hermes sessions list` inside the sandbox. +NemoClaw forwards native Hermes flags such as `--source` and `--limit` and streams the output unchanged. + +```bash +$$nemoclaw my-assistant sessions list +$$nemoclaw my-assistant sessions list --source cli --limit 20 +``` + + + ### `$$nemoclaw sessions reset ` Archive a session and rebind its key to a fresh `sessionId` by invoking the OpenClaw gateway `sessions.reset` RPC inside the sandbox. diff --git a/src/commands/sandbox/sessions.ts b/src/commands/sandbox/sessions.ts index 758698ffd68..a1928029ba6 100644 --- a/src/commands/sandbox/sessions.ts +++ b/src/commands/sandbox/sessions.ts @@ -13,12 +13,11 @@ export default class SandboxSessionsCommand extends NemoClawCommand { static strict = false; static summary = "List conversation sessions in a sandbox"; static description = - "Pass through to the sandbox agent's `sessions` command (`openclaw sessions` for OpenClaw sandboxes, `hermes sessions` for Hermes sandboxes). On OpenClaw sandboxes the in-sandbox CLI lists stored sessions for the configured default agent, and internal NemoClaw onboard warm-up sessions are hidden from default user-facing output; OpenClaw-specific flags are forwarded verbatim. Hermes sandboxes pass through their native output unchanged."; + "Pass through to the sandbox agent's session-listing command (`openclaw sessions` for OpenClaw sandboxes, `hermes sessions list` for Hermes sandboxes). On OpenClaw sandboxes the in-sandbox CLI lists stored sessions for the configured default agent, and internal NemoClaw onboard warm-up sessions are hidden from default user-facing output; OpenClaw-specific flags are forwarded verbatim. Hermes sandboxes pass through their native output unchanged."; static usage = [" [sessions-flags...]"]; static examples = [ "<%= config.bin %> sandbox sessions alpha", - "<%= config.bin %> sandbox sessions alpha --all-agents", - "<%= config.bin %> sandbox sessions alpha --json", + "<%= config.bin %> sandbox sessions alpha --limit 20", ]; public async run(): Promise { diff --git a/src/commands/sandbox/sessions/list.ts b/src/commands/sandbox/sessions/list.ts index f1ea1220e9e..9bcbe8b7d34 100644 --- a/src/commands/sandbox/sessions/list.ts +++ b/src/commands/sandbox/sessions/list.ts @@ -17,7 +17,7 @@ export default class SandboxSessionsListCommand extends NemoClawCommand { static usage = [" [sessions-list-flags...]"]; static examples = [ "<%= config.bin %> sandbox sessions list alpha", - "<%= config.bin %> sandbox sessions list alpha --agent work --json", + "<%= config.bin %> sandbox sessions list alpha --limit 20", ]; public async run(): Promise { diff --git a/src/lib/actions/sandbox/sessions/passthrough.test.ts b/src/lib/actions/sandbox/sessions/passthrough.test.ts index 74ac2ef615b..127c957c1ea 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.test.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.test.ts @@ -196,7 +196,7 @@ describe("printSessionsPassthroughHelp", () => { expect(help).not.toMatch(/Pass-through to `openclaw sessions/i); expect(help).toMatch(/openclaw/i); - expect(help).toMatch(/hermes/i); + expect(help).toMatch(/hermes sessions list/i); // Warm-up filtering is documented as OpenClaw-specific, not universal. expect(help).toMatch(/warm-up[^\n]*OpenClaw|OpenClaw[^\n]*warm-up/i); }); @@ -383,13 +383,13 @@ describe("runSessionsPassthrough", () => { expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining("--limit")); }); - it("routes to the hermes binary and skips warm-up filtering on hermes sandboxes (#6247)", async () => { + it("routes the bare command to `hermes sessions list` and skips warm-up filtering (#6247)", async () => { getSandboxMock.mockReturnValue({ agent: "hermes" }); await runSessionsPassthrough("hermes", { extraArgs: [] }); expect(captureMock).not.toHaveBeenCalled(); - expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions"]); + expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions", "list"]); }); it("uses openclaw binary for openclaw-agent sandboxes (#6247)", async () => { @@ -410,11 +410,11 @@ describe("runSessionsPassthrough", () => { await runSessionsPassthrough("hermes", { verb: "list", - extraArgs: ["--json"], + extraArgs: ["--limit", "5"], }); expect(captureMock).not.toHaveBeenCalled(); - expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions", "list", "--json"]); + expect(execMock).toHaveBeenCalledWith("hermes", ["hermes", "sessions", "list", "--limit", "5"]); }); it("defaults to the openclaw binary + filter path when the registry has no entry (#6247)", async () => { diff --git a/src/lib/actions/sandbox/sessions/passthrough.ts b/src/lib/actions/sandbox/sessions/passthrough.ts index 950c2574e05..825382097ef 100644 --- a/src/lib/actions/sandbox/sessions/passthrough.ts +++ b/src/lib/actions/sandbox/sessions/passthrough.ts @@ -28,6 +28,7 @@ export function hasSessionsPassthroughHelpToken(args: readonly string[]): boolea export function printSessionsPassthroughHelp(verb?: SessionsPassthroughVerb): void { const usageSuffix = verb ? ` ${verb}` : ""; + const hermesUsageSuffix = verb ? ` ${verb}` : " list"; const flagsToken = verb ? `sessions-${verb}-flags` : "sessions-flags"; console.log(""); console.log(` Usage: ${CLI_NAME} sessions${usageSuffix} [${flagsToken}...]`); @@ -35,12 +36,11 @@ export function printSessionsPassthroughHelp(verb?: SessionsPassthroughVerb): vo console.log( ` Pass-through to the sandbox agent's \`sessions${usageSuffix} ...\` command inside the sandbox`, ); + console.log(" via `openshell sandbox exec` — `openclaw sessions ...` for OpenClaw sandboxes,"); console.log( - " via `openshell sandbox exec` — `openclaw sessions ...` for OpenClaw sandboxes, `hermes", - ); - console.log( - " sessions ...` for Hermes sandboxes; the in-sandbox binary is picked from the sandbox's agent.", + ` \`hermes sessions${hermesUsageSuffix} ...\` for Hermes sandboxes; the in-sandbox binary is picked`, ); + console.log(" from the sandbox's agent."); console.log( " On OpenClaw sandboxes, internal NemoClaw onboard warm-up sessions are hidden from default", ); @@ -219,16 +219,15 @@ export async function runSessionsPassthrough( // Route the passthrough at the in-sandbox agent's own binary name and // bypass the OpenClaw-specific warm-up filter for non-OpenClaw agents. // - // Trust boundary: `registry.getSandbox()` reads the local user-owned - // sandbox registry (~/.nemoclaw/state/*), which is written only by - // NemoClaw CLI commands (onboard, sandbox create, upgrade-sandboxes). - // Sandbox processes cannot mutate it, so the `agent` field here is a - // trusted configuration input; unknown / missing values fall through - // to the default `openclaw` branch below. + // Trust boundary: `registry.getSandbox()` reads the host-side, user-owned + // `~/.nemoclaw/sandboxes.json` registry (`REGISTRY_FILE`). Sandbox processes + // cannot access the host filesystem to change this agent selection; unknown + // or missing values deliberately default to `openclaw` below. const sandboxAgent = registry.getSandbox(sandboxName)?.agent; const inSandboxBinary = sandboxAgent === "hermes" ? "hermes" : "openclaw"; const command = [inSandboxBinary, "sessions"]; if (verb) command.push(verb); + else if (inSandboxBinary === "hermes") command.push("list"); for (const arg of extraArgs) command.push(arg); if (isFilterableListPassthrough(verb) && inSandboxBinary === "openclaw") { const result = captureOpenshell(buildOpenshellExecArgs(sandboxName, command), { diff --git a/src/lib/cli/public-display-sessions.ts b/src/lib/cli/public-display-sessions.ts index 86ab3110e86..3deda7626a6 100644 --- a/src/lib/cli/public-display-sessions.ts +++ b/src/lib/cli/public-display-sessions.ts @@ -8,16 +8,16 @@ export const SANDBOX_SESSIONS_DISPLAY_LAYOUT: Record