Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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: 1 addition & 1 deletion bin/nemoclaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

require("../dist/nemoclaw");
module.exports = require("../dist/nemoclaw");
2 changes: 1 addition & 1 deletion bin/nemohermes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
//
// NemoHermes — alias for NemoClaw with the Hermes agent pre-selected.
process.env.NEMOCLAW_AGENT = "hermes";
require("../dist/nemoclaw");
module.exports = require("../dist/nemoclaw");
51 changes: 51 additions & 0 deletions src/lib/channels-mutate-cli-commands.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 {
ChannelsAddCommand,
ChannelsRemoveCommand,
ChannelsStartCommand,
ChannelsStopCommand,
setChannelsRuntimeBridgeFactoryForTest,
} from "./channels-mutate-cli-commands";

const rootDir = process.cwd();

describe("channels mutation oclif commands", () => {
it("maps add flags to the legacy argv shape", async () => {
const runtime = {
sandboxChannelsAdd: vi.fn().mockResolvedValue(undefined),
sandboxChannelsRemove: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStart: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStop: vi.fn().mockResolvedValue(undefined),
};
setChannelsRuntimeBridgeFactoryForTest(() => runtime);

await ChannelsAddCommand.run(["alpha", "telegram", "--dry-run"], rootDir);

expect(runtime.sandboxChannelsAdd).toHaveBeenCalledWith("alpha", ["telegram", "--dry-run"]);
});

it("maps remove/start/stop to the legacy argv shape", async () => {
const runtime = {
sandboxChannelsAdd: vi.fn().mockResolvedValue(undefined),
sandboxChannelsRemove: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStart: vi.fn().mockResolvedValue(undefined),
sandboxChannelsStop: vi.fn().mockResolvedValue(undefined),
};
setChannelsRuntimeBridgeFactoryForTest(() => runtime);

await ChannelsRemoveCommand.run(["alpha", "telegram"], rootDir);
await ChannelsStartCommand.run(["alpha", "telegram", "--dry-run"], rootDir);
await ChannelsStopCommand.run(["alpha", "slack"], rootDir);

expect(runtime.sandboxChannelsRemove).toHaveBeenCalledWith("alpha", ["telegram"]);
expect(runtime.sandboxChannelsStart).toHaveBeenCalledWith("alpha", [
"telegram",
"--dry-run",
]);
expect(runtime.sandboxChannelsStop).toHaveBeenCalledWith("alpha", ["slack"]);
});
});
102 changes: 102 additions & 0 deletions src/lib/channels-mutate-cli-commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// 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";

type RuntimeBridge = {
sandboxChannelsAdd: (sandboxName: string, args?: string[]) => Promise<void>;
sandboxChannelsRemove: (sandboxName: string, args?: string[]) => Promise<void>;
sandboxChannelsStart: (sandboxName: string, args?: string[]) => Promise<void>;
sandboxChannelsStop: (sandboxName: string, args?: string[]) => Promise<void>;
};

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

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

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

const sandboxNameArg = Args.string({ name: "sandbox", description: "Sandbox name", required: true });
const channelArg = Args.string({ name: "channel", description: "Messaging channel", required: false });

function buildArgs(channel: string | undefined, flags: { "dry-run"?: boolean }): string[] {
const args: string[] = [];
if (channel) args.push(channel);
if (flags["dry-run"]) args.push("--dry-run");
return args;
}

const channelMutationArgs = {
sandboxName: sandboxNameArg,
channel: channelArg,
};
const channelMutationFlags = {
help: Flags.help({ char: "h" }),
"dry-run": Flags.boolean({ description: "Preview the change without applying it" }),
};

export class ChannelsAddCommand extends Command {
static id = "sandbox:channels:add";
static strict = true;
static summary = "Save messaging channel credentials and rebuild";
static description = "Store credentials for a messaging channel and queue a sandbox rebuild.";
static usage = ["<name> channels add <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsAddCommand);
await getRuntimeBridge().sandboxChannelsAdd(args.sandboxName, buildArgs(args.channel, flags));
}
}

export class ChannelsRemoveCommand extends Command {
static id = "sandbox:channels:remove";
static strict = true;
static summary = "Clear messaging channel credentials and rebuild";
static description = "Remove credentials for a messaging channel and queue a sandbox rebuild.";
static usage = ["<name> channels remove <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsRemoveCommand);
await getRuntimeBridge().sandboxChannelsRemove(args.sandboxName, buildArgs(args.channel, flags));
}
}

export class ChannelsStopCommand extends Command {
static id = "sandbox:channels:stop";
static strict = true;
static summary = "Disable channel without wiping credentials";
static description = "Disable a messaging channel while keeping credentials in the gateway.";
static usage = ["<name> channels stop <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsStopCommand);
await getRuntimeBridge().sandboxChannelsStop(args.sandboxName, buildArgs(args.channel, flags));
}
}

export class ChannelsStartCommand extends Command {
static id = "sandbox:channels:start";
static strict = true;
static summary = "Re-enable a stopped messaging channel";
static description = "Re-enable a previously stopped messaging channel.";
static usage = ["<name> channels start <channel> [--dry-run]"];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsStartCommand);
await getRuntimeBridge().sandboxChannelsStart(args.sandboxName, buildArgs(args.channel, flags));
}
}
33 changes: 33 additions & 0 deletions src/lib/connect-cli-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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";

type RuntimeBridge = {
sandboxConnect: (sandboxName: string) => Promise<void>;
};

function getRuntimeBridge(): RuntimeBridge {
return require("../nemoclaw") as RuntimeBridge;
}

export default class ConnectCliCommand extends Command {
static id = "sandbox:connect";
static strict = true;
static summary = "Shell into a running sandbox";
static description = "Connect to a running sandbox.";
static usage = ["<name> connect"];
static args = {
sandboxName: Args.string({ name: "sandbox", description: "Sandbox name", required: true }),
};
static flags = {
help: Flags.help({ char: "h" }),
};

public async run(): Promise<void> {
const { args } = await this.parse(ConnectCliCommand);
await getRuntimeBridge().sandboxConnect(args.sandboxName);
}
}
Loading
Loading