fix: route remote mac browser through node host

This commit is contained in:
Peter Steinberger
2026-04-26 05:25:13 +01:00
parent b8aef04ccd
commit ae45eebef1
10 changed files with 175 additions and 10 deletions

View File

@@ -0,0 +1,45 @@
import { Command } from "commander";
import { describe, expect, it, vi } from "vitest";
import { registerNodeCli } from "./register.js";
const daemonMocks = vi.hoisted(() => ({
runNodeDaemonInstall: vi.fn(),
runNodeDaemonRestart: vi.fn(),
runNodeDaemonStart: vi.fn(),
runNodeDaemonStatus: vi.fn(),
runNodeDaemonStop: vi.fn(),
runNodeDaemonUninstall: vi.fn(),
}));
vi.mock("./daemon.js", () => daemonMocks);
vi.mock("../../node-host/config.js", () => ({
loadNodeHostConfig: vi.fn(async () => null),
}));
vi.mock("../../node-host/runner.js", () => ({
runNodeHost: vi.fn(),
}));
function createProgram(): Command {
const program = new Command();
program.exitOverride();
program.configureOutput({
writeErr: () => undefined,
writeOut: () => undefined,
});
registerNodeCli(program);
return program;
}
describe("registerNodeCli", () => {
it("registers node start for the macOS app node service manager", async () => {
const program = createProgram();
await program.parseAsync(["node", "start", "--json"], { from: "user" });
expect(daemonMocks.runNodeDaemonStart).toHaveBeenCalledWith(
expect.objectContaining({ json: true }),
);
});
});

View File

@@ -9,6 +9,7 @@ import { formatHelpExamples } from "../help-format.js";
import {
runNodeDaemonInstall,
runNodeDaemonRestart,
runNodeDaemonStart,
runNodeDaemonStatus,
runNodeDaemonStop,
runNodeDaemonUninstall,
@@ -33,6 +34,7 @@ export function registerNodeCli(program: Command) {
],
["openclaw node status", "Check node host service status."],
["openclaw node install", "Install the node host service."],
["openclaw node start", "Start the installed node host service."],
["openclaw node restart", "Restart the installed node host service."],
])}\n\n${theme.muted("Docs:")} ${formatDocsLink("/cli/node", "docs.openclaw.ai/cli/node")}\n`,
);
@@ -103,6 +105,14 @@ export function registerNodeCli(program: Command) {
await runNodeDaemonStop(opts);
});
node
.command("start")
.description("Start the node host service (launchd/systemd/schtasks)")
.option("--json", "Output JSON", false)
.action(async (opts) => {
await runNodeDaemonStart(opts);
});
node
.command("restart")
.description("Restart the node host service (launchd/systemd/schtasks)")