Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
17 changes: 17 additions & 0 deletions scripts/checks/layer-import-boundaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ function checkAdapterFile(absPath: string, repoPath: string, violations: Violati
}
}

function checkNoBinLibShimImport(absPath: string, repoPath: string, violations: Violation[]): void {
for (const ref of collectImportRefs(absPath)) {
const target = resolveInternalImport(absPath, ref.specifier);
if (target?.startsWith("bin/lib/") && !target.endsWith(".json")) {
addViolation(
violations,
repoPath,
ref.line,
ref.column,
"src-no-bin-lib-shims",
`src must import implementation modules directly instead of packaged shim ${target}`,
);
}
}
}

function checkCommandFile(absPath: string, repoPath: string, violations: Violation[]): void {
const sourceFile = sourceFileFor(absPath);
let commandClassCount = 0;
Expand Down Expand Up @@ -285,6 +301,7 @@ export function findLayerImportBoundaryViolations(root = SRC_ROOT): Violation[]
const violations: Violation[] = [];
for (const absPath of walk(root)) {
const repoPath = toRepoPath(absPath);
checkNoBinLibShimImport(absPath, repoPath, violations);
if (isDomainFile(repoPath)) checkDomainFile(absPath, repoPath, violations);
if (isActionFile(repoPath)) checkActionFile(absPath, repoPath, violations);
if (isAdapterFile(repoPath)) checkAdapterFile(absPath, repoPath, violations);
Expand Down
15 changes: 13 additions & 2 deletions src/commands/sandbox/channels/add.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import {
buildChannelArgs,
channelMutationOptions,
channelMutationArgs,
channelMutationFlags,
getChannelsRuntimeBridge,
Expand All @@ -17,14 +18,24 @@ export default class ChannelsAddCommand extends NemoClawCommand {
static description = "Store credentials for a messaging channel and queue a sandbox rebuild.";
static usage = ["<name> <channel> [--dry-run]"];
static examples = ["<%= config.bin %> sandbox channels add alpha telegram"];
static publicDisplay = [
{
usage: "nemoclaw <name> channels add",
description: "Save credentials and rebuild",
flags: "<channel> [--dry-run]",
group: "Messaging Channels",
scope: "sandbox",
order: 21,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsAddCommand);
await getChannelsRuntimeBridge().sandboxChannelsAdd(
args.sandboxName,
buildChannelArgs(args.channel, flags),
channelMutationOptions(args.channel, flags),
);
}
}
10 changes: 10 additions & 0 deletions src/commands/sandbox/channels/list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import { listSandboxChannels } from "../../../lib/actions/sandbox/policy-channel";
Expand All @@ -13,6 +14,15 @@ export default class SandboxChannelsListCommand extends NemoClawCommand {
static description = "List supported messaging channels for a sandbox.";
static usage = ["<name>"];
static examples = ["<%= config.bin %> sandbox channels list alpha"];
static publicDisplay = [
{
usage: "nemoclaw <name> channels list",
description: "List supported messaging channels",
group: "Messaging Channels",
scope: "sandbox",
order: 20,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = {
sandboxName: sandboxNameArg,
};
Expand Down
27 changes: 18 additions & 9 deletions src/commands/sandbox/channels/mutate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ChannelsStopCommand from "./stop";
const rootDir = process.cwd();

describe("channels mutation oclif commands", () => {
it("maps add flags to the legacy argv shape", async () => {
it("maps add flags to typed action options", async () => {
const runtime = {
sandboxChannelsAdd: vi.fn().mockResolvedValue(undefined),
sandboxChannelsRemove: vi.fn().mockResolvedValue(undefined),
Expand All @@ -23,10 +23,13 @@ describe("channels mutation oclif commands", () => {

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

expect(runtime.sandboxChannelsAdd).toHaveBeenCalledWith("alpha", ["telegram", "--dry-run"]);
expect(runtime.sandboxChannelsAdd).toHaveBeenCalledWith("alpha", {
channel: "telegram",
dryRun: true,
});
});

it("maps remove/start/stop to the legacy argv shape", async () => {
it("maps remove/start/stop to typed action options", async () => {
const runtime = {
sandboxChannelsAdd: vi.fn().mockResolvedValue(undefined),
sandboxChannelsRemove: vi.fn().mockResolvedValue(undefined),
Expand All @@ -39,12 +42,18 @@ describe("channels mutation oclif commands", () => {
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"]);
expect(runtime.sandboxChannelsRemove).toHaveBeenCalledWith("alpha", {
channel: "telegram",
dryRun: false,
});
expect(runtime.sandboxChannelsStart).toHaveBeenCalledWith("alpha", {
channel: "telegram",
dryRun: true,
});
expect(runtime.sandboxChannelsStop).toHaveBeenCalledWith("alpha", {
channel: "slack",
dryRun: false,
});
});

it("requires a channel before dispatch", async () => {
Expand Down
15 changes: 13 additions & 2 deletions src/commands/sandbox/channels/remove.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import {
buildChannelArgs,
channelMutationOptions,
channelMutationArgs,
channelMutationFlags,
getChannelsRuntimeBridge,
Expand All @@ -17,14 +18,24 @@ export default class ChannelsRemoveCommand extends NemoClawCommand {
static description = "Remove credentials for a messaging channel and queue a sandbox rebuild.";
static usage = ["<name> <channel> [--dry-run]"];
static examples = ["<%= config.bin %> sandbox channels remove alpha slack --dry-run"];
static publicDisplay = [
{
usage: "nemoclaw <name> channels remove",
description: "Remove a configured messaging channel",
flags: "<channel> [--dry-run]",
group: "Messaging Channels",
scope: "sandbox",
order: 22,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsRemoveCommand);
await getChannelsRuntimeBridge().sandboxChannelsRemove(
args.sandboxName,
buildChannelArgs(args.channel, flags),
channelMutationOptions(args.channel, flags),
);
}
}
15 changes: 13 additions & 2 deletions src/commands/sandbox/channels/start.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import {
buildChannelArgs,
channelMutationOptions,
channelMutationArgs,
channelMutationFlags,
getChannelsRuntimeBridge,
Expand All @@ -17,14 +18,24 @@ export default class ChannelsStartCommand extends NemoClawCommand {
static description = "Re-enable a previously stopped messaging channel.";
static usage = ["<name> <channel> [--dry-run]"];
static examples = ["<%= config.bin %> sandbox channels start alpha discord"];
static publicDisplay = [
{
usage: "nemoclaw <name> channels start",
description: "Re-enable a previously stopped channel",
flags: "<channel> [--dry-run]",
group: "Messaging Channels",
scope: "sandbox",
order: 24,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsStartCommand);
await getChannelsRuntimeBridge().sandboxChannelsStart(
args.sandboxName,
buildChannelArgs(args.channel, flags),
channelMutationOptions(args.channel, flags),
);
}
}
15 changes: 13 additions & 2 deletions src/commands/sandbox/channels/stop.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import {
buildChannelArgs,
channelMutationOptions,
channelMutationArgs,
channelMutationFlags,
getChannelsRuntimeBridge,
Expand All @@ -17,14 +18,24 @@ export default class ChannelsStopCommand extends NemoClawCommand {
static description = "Disable a messaging channel while keeping credentials in the gateway.";
static usage = ["<name> <channel> [--dry-run]"];
static examples = ["<%= config.bin %> sandbox channels stop alpha discord"];
static publicDisplay = [
{
usage: "nemoclaw <name> channels stop",
description: "Disable channel (keeps credentials)",
flags: "<channel> [--dry-run]",
group: "Messaging Channels",
scope: "sandbox",
order: 23,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = channelMutationArgs;
static flags = channelMutationFlags;

public async run(): Promise<void> {
const { args, flags } = await this.parse(ChannelsStopCommand);
await getChannelsRuntimeBridge().sandboxChannelsStop(
args.sandboxName,
buildChannelArgs(args.channel, flags),
channelMutationOptions(args.channel, flags),
);
}
}
25 changes: 18 additions & 7 deletions src/commands/sandbox/policy/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

import { Flags } from "@oclif/core";
import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import {
appendCommonPolicyFlags,
commonPolicyOptions,
getPolicyRuntimeBridge,
policyMutationArgs,
policyMutationFlags,
Expand All @@ -24,6 +25,16 @@ export default class PolicyAddCommand extends NemoClawCommand {
"<%= config.bin %> sandbox policy add alpha --from-file ./policy.yaml --dry-run",
"<%= config.bin %> sandbox policy add alpha --from-dir ./policies --yes",
];
static publicDisplay = [
{
usage: "nemoclaw <name> policy-add",
description: "Add a network or filesystem policy preset",
flags: "(--yes, -y, --dry-run, --from-file <path>, --from-dir <path>)",
group: "Policy Presets",
scope: "sandbox",
order: 17,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = policyMutationArgs;
static flags = {
...policyMutationFlags,
Expand All @@ -39,11 +50,11 @@ export default class PolicyAddCommand extends NemoClawCommand {

public async run(): Promise<void> {
const { args, flags } = await this.parse(PolicyAddCommand);
const legacyArgs: string[] = [];
if (args.preset) legacyArgs.push(args.preset);
appendCommonPolicyFlags(legacyArgs, flags);
if (flags["from-file"]) legacyArgs.push("--from-file", flags["from-file"]);
if (flags["from-dir"]) legacyArgs.push("--from-dir", flags["from-dir"]);
await getPolicyRuntimeBridge().sandboxPolicyAdd(args.sandboxName, legacyArgs);
await getPolicyRuntimeBridge().sandboxPolicyAdd(args.sandboxName, {
preset: args.preset,
...commonPolicyOptions(flags),
fromFile: flags["from-file"],
fromDir: flags["from-dir"],
});
}
}
10 changes: 10 additions & 0 deletions src/commands/sandbox/policy/list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { PublicCommandDisplayEntry } from "../../../lib/cli/command-display";
import { NemoClawCommand } from "../../../lib/cli/nemoclaw-oclif-command";

import { listSandboxPolicies } from "../../../lib/actions/sandbox/policy-channel";
Expand All @@ -13,6 +14,15 @@ export default class SandboxPolicyListCommand extends NemoClawCommand {
static description = "List built-in and custom policy presets and show which are applied.";
static usage = ["<name>"];
static examples = ["<%= config.bin %> sandbox policy list alpha"];
static publicDisplay = [
{
usage: "nemoclaw <name> policy-list",
description: "List presets (● = applied)",
group: "Policy Presets",
scope: "sandbox",
order: 19,
},
] satisfies readonly PublicCommandDisplayEntry[];
static args = {
sandboxName: sandboxNameArg,
};
Expand Down
30 changes: 16 additions & 14 deletions src/commands/sandbox/policy/mutate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PolicyRemoveCommand from "./remove";
const rootDir = process.cwd();

describe("policy mutation oclif commands", () => {
it("maps policy-add flags to the legacy argv shape", async () => {
it("maps policy-add flags to typed action options", async () => {
const runtime = {
sandboxPolicyAdd: vi.fn().mockResolvedValue(undefined),
sandboxPolicyRemove: vi.fn().mockResolvedValue(undefined),
Expand All @@ -22,16 +22,17 @@ describe("policy mutation oclif commands", () => {
rootDir,
);

expect(runtime.sandboxPolicyAdd).toHaveBeenCalledWith("alpha", [
"github",
"--yes",
"--dry-run",
"--from-file",
"/tmp/preset.yaml",
]);
expect(runtime.sandboxPolicyAdd).toHaveBeenCalledWith("alpha", {
preset: "github",
yes: true,
force: false,
dryRun: true,
fromFile: "/tmp/preset.yaml",
fromDir: undefined,
});
});

it("maps policy-remove flags to the legacy argv shape", async () => {
it("maps policy-remove flags to typed action options", async () => {
const runtime = {
sandboxPolicyAdd: vi.fn().mockResolvedValue(undefined),
sandboxPolicyRemove: vi.fn().mockResolvedValue(undefined),
Expand All @@ -40,11 +41,12 @@ describe("policy mutation oclif commands", () => {

await PolicyRemoveCommand.run(["alpha", "github", "-y", "--dry-run"], rootDir);

expect(runtime.sandboxPolicyRemove).toHaveBeenCalledWith("alpha", [
"github",
"--yes",
"--dry-run",
]);
expect(runtime.sandboxPolicyRemove).toHaveBeenCalledWith("alpha", {
preset: "github",
yes: true,
force: false,
dryRun: true,
});
});

it("rejects missing custom policy paths before dispatch", async () => {
Expand Down
Loading
Loading