Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion src/lib/inventory-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface SandboxEntry {
policies?: string[] | null;
messagingChannels?: string[] | null;
agent?: string | null;
dashboardPort?: number | null;
}

export interface MessagingBridgeHealth {
Expand Down Expand Up @@ -123,6 +124,9 @@ export async function listSandboxesCommand(deps: ListSandboxesCommandDeps): Prom
if (providerDrifted) parts.push(`provider=${sb.provider || "unknown"}`);
log(` (onboarded: ${parts.join(", ")})`);
}
if (sb.dashboardPort) {
log(` dashboard: http://127.0.0.1:${sb.dashboardPort}/`);
}
}
log("");
log(" * = default sandbox");
Expand Down Expand Up @@ -151,7 +155,8 @@ export function showStatusCommand(deps: ShowStatusCommandDeps): void {
// agrees with `openshell inference get` (#2369).
const liveModel = isDefault && live ? live.model : null;
const model = liveModel || sb.model;
log(` ${sb.name}${def}${model ? ` (${model})` : ""}`);
const portSuffix = sb.dashboardPort ? ` :${sb.dashboardPort}` : "";
log(` ${sb.name}${def}${model ? ` (${model})` : ""}${portSuffix}`);
if (isDefault && liveModel && liveModel !== sb.model) {
log(` (onboarded: ${sb.model || "unknown"})`);
}
Expand Down
75 changes: 75 additions & 0 deletions src/lib/onboard-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("onboard command", () => {
acceptThirdPartySoftware: true,
agent: null,
dangerouslySkipPermissions: false,
controlUiPort: null,
});
});

Expand All @@ -57,6 +58,7 @@ describe("onboard command", () => {
acceptThirdPartySoftware: true,
agent: null,
dangerouslySkipPermissions: false,
controlUiPort: null,
});
});

Expand All @@ -81,6 +83,7 @@ describe("onboard command", () => {
acceptThirdPartySoftware: false,
agent: null,
dangerouslySkipPermissions: false,
controlUiPort: null,
});
});

Expand Down Expand Up @@ -128,6 +131,7 @@ describe("onboard command", () => {
acceptThirdPartySoftware: false,
agent: null,
dangerouslySkipPermissions: false,
controlUiPort: null,
});
});

Expand Down Expand Up @@ -191,6 +195,7 @@ describe("onboard command", () => {
acceptThirdPartySoftware: false,
agent: "openclaw",
dangerouslySkipPermissions: true,
controlUiPort: null,
});
});

Expand All @@ -215,6 +220,75 @@ describe("onboard command", () => {
expect(errors.join("\n")).toContain("Usage: nemoclaw onboard");
});

it("parses --control-ui-port with a valid port", () => {
const result = parseOnboardArgs(
["--control-ui-port", "18790"],
"--yes-i-accept-third-party-software",
"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE",
{
env: {},
error: () => {},
exit: ((code: number) => {
throw new Error(String(code));
}) as never,
},
);
expect(result.controlUiPort).toBe(18790);
});

it("exits when --control-ui-port is missing its value", () => {
expect(() =>
parseOnboardArgs(
["--control-ui-port"],
"--yes-i-accept-third-party-software",
"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE",
{
env: {},
error: () => {},
exit: ((code: number) => {
throw new Error(`exit:${code}`);
}) as never,
},
),
).toThrow("exit:1");
});

it("exits when --control-ui-port value is out of range", () => {
const errors: string[] = [];
expect(() =>
parseOnboardArgs(
["--control-ui-port", "80"],
"--yes-i-accept-third-party-software",
"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE",
{
env: {},
error: (message = "") => errors.push(message),
exit: ((code: number) => {
throw new Error(`exit:${code}`);
}) as never,
},
),
).toThrow("exit:1");
expect(errors.join("\n")).toContain("1024-65535");
});

it("--help includes --control-ui-port in usage", async () => {
const lines: string[] = [];
await runOnboardCommand({
args: ["--help"],
noticeAcceptFlag: "--yes-i-accept-third-party-software",
noticeAcceptEnv: "NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE",
env: {},
runOnboard: vi.fn(async () => {}),
log: (message = "") => lines.push(message),
error: () => {},
exit: ((code: number) => {
throw new Error(String(code));
}) as never,
});
expect(lines.join("\n")).toContain("--control-ui-port");
});

it("prints the setup-spark deprecation text before delegating", async () => {
const lines: string[] = [];
const runOnboard = vi.fn(async () => {});
Expand Down Expand Up @@ -242,6 +316,7 @@ describe("onboard command", () => {
acceptThirdPartySoftware: false,
agent: null,
dangerouslySkipPermissions: false,
controlUiPort: null,
});
});

Expand Down
23 changes: 22 additions & 1 deletion src/lib/onboard-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface OnboardCommandOptions {
acceptThirdPartySoftware: boolean;
agent: string | null;
dangerouslySkipPermissions: boolean;
controlUiPort: number | null;
}

export interface RunOnboardCommandDeps {
Expand Down Expand Up @@ -36,7 +37,7 @@ const ONBOARD_BASE_ARGS = [

function onboardUsageLines(noticeAcceptFlag: string): string[] {
return [
` Usage: nemoclaw onboard [--non-interactive] [--resume] [--recreate-sandbox] [--from <Dockerfile>] [--agent <name>] [--dangerously-skip-permissions] [${noticeAcceptFlag}]`,
` Usage: nemoclaw onboard [--non-interactive] [--resume] [--recreate-sandbox] [--from <Dockerfile>] [--agent <name>] [--control-ui-port <N>] [--dangerously-skip-permissions] [${noticeAcceptFlag}]`,
"",
];
}
Expand Down Expand Up @@ -88,6 +89,25 @@ export function parseOnboardArgs(
parsedArgs.splice(agentIdx, 2);
}

let controlUiPort: number | null = null;
const portIdx = parsedArgs.indexOf("--control-ui-port");
if (portIdx !== -1) {
const portValue = parsedArgs[portIdx + 1];
if (typeof portValue !== "string" || portValue.startsWith("--")) {
error(" --control-ui-port requires a port number");
printOnboardUsage(error, noticeAcceptFlag);
exit(1);
}
const parsed = Number(portValue);
if (!Number.isInteger(parsed) || parsed < 1024 || parsed > 65535) {
error(` --control-ui-port: ${portValue} is not a valid port (1024-65535)`);
printOnboardUsage(error, noticeAcceptFlag);
exit(1);
}
controlUiPort = parsed;
parsedArgs.splice(portIdx, 2);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const allowedArgs = new Set([...ONBOARD_BASE_ARGS, noticeAcceptFlag]);
const unknownArgs = parsedArgs.filter((arg) => !allowedArgs.has(arg));
if (unknownArgs.length > 0) {
Expand All @@ -105,6 +125,7 @@ export function parseOnboardArgs(
parsedArgs.includes(noticeAcceptFlag) || String(deps.env[noticeAcceptEnv] || "") === "1",
agent,
dangerouslySkipPermissions: parsedArgs.includes("--dangerously-skip-permissions"),
controlUiPort,
};
}

Expand Down
Loading
Loading