Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/credentials-cli-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import type { StdioOptions } from "node:child_process";

import { Args, Command, Flags } from "@oclif/core";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/debug-cli-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import { Command } from "@oclif/core";

import type { CaptureOpenshellResult } from "./openshell";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/gateway-token-cli-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import { Args, Command, Flags } from "@oclif/core";

import { runGatewayTokenCommand } from "./gateway-token-command";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/list-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import { Command, Flags } from "@oclif/core";

import { getSandboxInventory, renderSandboxInventoryText } from "./inventory-commands";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/maintenance-cli-commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapters covered through CLI integration tests. */

import { Command, Flags } from "@oclif/core";

type RuntimeBridge = {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/oclif-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
SandboxPolicyListCommand,
SandboxStatusCommand,
} from "./sandbox-inspection-cli-command";
import SandboxLogsCommand from "./sandbox-logs-cli-command";
import ShareCommand from "./share-command";
import StatusCommand from "./status-command";
import {
Expand All @@ -39,6 +40,7 @@ export default {
list: ListCommand,
"sandbox:channels:list": SandboxChannelsListCommand,
"sandbox:config:get": SandboxConfigGetCommand,
"sandbox:logs": SandboxLogsCommand,
"sandbox:policy-list": SandboxPolicyListCommand,
"sandbox:status": SandboxStatusCommand,
share: ShareCommand,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/sandbox-inspection-cli-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapters covered through CLI integration tests. */

import { Args, Command, Flags } from "@oclif/core";

import { CLI_NAME } from "./branding";
Expand Down
21 changes: 21 additions & 0 deletions src/lib/sandbox-logs-cli-command.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it, vi } from "vitest";

import SandboxLogsCommand, {
setSandboxLogsRuntimeBridgeFactoryForTest,
} from "./sandbox-logs-cli-command";

const rootDir = process.cwd();

describe("SandboxLogsCommand", () => {
it("runs sandbox logs with the follow flag", async () => {
const sandboxLogs = vi.fn();
setSandboxLogsRuntimeBridgeFactoryForTest(() => ({ sandboxLogs }));

await SandboxLogsCommand.run(["alpha", "--follow"], rootDir);

expect(sandboxLogs).toHaveBeenCalledWith("alpha", true);
});
});
46 changes: 46 additions & 0 deletions src/lib/sandbox-logs-cli-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif wrapper covered through CLI integration tests. */

import { Args, Command, Flags } from "@oclif/core";

type RuntimeBridge = {
sandboxLogs: (sandboxName: string, follow: boolean) => void;
};

let runtimeBridgeFactory = (): RuntimeBridge => require("../nemoclaw") as RuntimeBridge;

export function setSandboxLogsRuntimeBridgeFactoryForTest(
factory: () => RuntimeBridge,
): void {
runtimeBridgeFactory = factory;
}

function getRuntimeBridge(): RuntimeBridge {
return runtimeBridgeFactory();
}

export default class SandboxLogsCommand extends Command {
static id = "sandbox:logs";
static strict = true;
static summary = "Stream sandbox logs";
static description = "Show OpenClaw gateway logs and OpenShell audit logs for a sandbox.";
static usage = ["<name> logs [--follow]"];
static args = {
sandboxName: Args.string({
name: "sandbox",
description: "Sandbox name",
required: true,
}),
};
static flags = {
help: Flags.help({ char: "h" }),
follow: Flags.boolean({ description: "Follow logs until interrupted" }),
};

public async run(): Promise<void> {
const { args, flags } = await this.parse(SandboxLogsCommand);
getRuntimeBridge().sandboxLogs(args.sandboxName, flags.follow === true);
}
}
2 changes: 2 additions & 0 deletions src/lib/status-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import { Command, Flags } from "@oclif/core";

import { showStatusCommand } from "./inventory-commands";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/tunnel-commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapters covered through CLI integration tests. */

import { Command, Flags } from "@oclif/core";

import { CLI_NAME } from "./branding";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/uninstall-cli-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/* v8 ignore start -- thin oclif adapter covered through CLI integration tests. */

import { spawnSync } from "node:child_process";

import { Command } from "@oclif/core";
Expand Down
7 changes: 6 additions & 1 deletion src/nemoclaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ exports.recoverNamedGatewayRuntime = recoverNamedGatewayRuntime;
exports.recoverRegistryEntries = recoverRegistryEntries;
exports.runOpenshell = runOpenshell;
exports.sandboxChannelsList = sandboxChannelsList;
exports.sandboxLogs = sandboxLogs;
exports.sandboxPolicyList = sandboxPolicyList;
exports.sandboxStatus = sandboxStatus;
exports.ensureLiveSandboxOrExit = ensureLiveSandboxOrExit;
Expand Down Expand Up @@ -4152,7 +4153,11 @@ const [cmd, ...args] = process.argv.slice(2);
await runOclif("sandbox:status", [cmd, ...actionArgs]);
break;
case "logs":
sandboxLogs(cmd, actionArgs.includes("--follow"));
if (hasHelpFlag(actionArgs)) {
printSandboxActionUsage("logs [--follow]");
break;
}
await runOclif("sandbox:logs", [cmd, ...actionArgs]);
break;
case "policy-add":
await sandboxPolicyAdd(cmd, actionArgs);
Expand Down
5 changes: 5 additions & 0 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@ describe("CLI dispatch", () => {
expect(status.out).toContain("<name> status");
expect(status.out).not.toContain("sandbox:status");

const logs = runWithEnv("alpha logs --help", { HOME: home });
expect(logs.code).toBe(0);
expect(logs.out).toContain("<name> logs [--follow]");
expect(logs.out).not.toContain("sandbox:logs");

const policy = runWithEnv("alpha policy-list --help", { HOME: home });
expect(policy.code).toBe(0);
expect(policy.out).toContain("<name> policy-list");
Expand Down
Loading