Skip to content
6 changes: 1 addition & 5 deletions scripts/install-openshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ required_driver_bins_present() {
command -v openshell-gateway >/dev/null 2>&1 && command -v openshell-sandbox >/dev/null 2>&1
;;
Darwin)
command -v openshell-gateway >/dev/null 2>&1 && command -v openshell-driver-vm >/dev/null 2>&1
command -v openshell-gateway >/dev/null 2>&1
;;
*)
return 0
Expand Down Expand Up @@ -275,8 +275,6 @@ if command -v openshell >/dev/null 2>&1; then
warn "openshell $INSTALLED_VERSION is missing Docker-driver binaries — reinstalling pinned OpenShell ${PIN_VERSION}..."
elif ! openshell_has_required_messaging_features; then
fail "${OPENSHELL_FEATURE_CHECK_ERROR:-openshell $INSTALLED_VERSION is missing required messaging credential rewrite support. Install an OpenShell build that includes provider aliases, WebSocket text rewrite, and request-body credential rewrite.}"
elif ! repair_existing_macos_vm_driver; then
warn "openshell $INSTALLED_VERSION has an unsigned macOS VM driver that could not be repaired in place — reinstalling pinned OpenShell ${PIN_VERSION}..."
else
info "openshell already installed: $INSTALLED_VERSION (>= $MIN_VERSION, <= $MAX_VERSION, messaging rewrite capable)"
exit 0
Expand Down Expand Up @@ -311,9 +309,7 @@ case "$OS" in
case "$ARCH_LABEL" in
aarch64)
ASSETS+=("openshell-gateway-aarch64-apple-darwin.tar.gz")
ASSETS+=("openshell-driver-vm-aarch64-apple-darwin.tar.gz")
CHECKSUM_FILES+=("openshell-gateway-checksums-sha256.txt")
CHECKSUM_FILES+=("openshell-checksums-sha256.txt")
;;
x86_64)
fail "OpenShell ${PIN_VERSION} does not publish macOS x86_64 standalone gateway assets."
Expand Down
36 changes: 18 additions & 18 deletions src/lib/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const { reportDockerDriverGatewayStartFailure } =
const dockerDriverGatewayEnv: typeof import("./onboard/docker-driver-gateway-env") =
require("./onboard/docker-driver-gateway-env");
const { getDockerDriverGatewayEndpoint } = dockerDriverGatewayEnv;
const vmDriverProcess: typeof import("./onboard/vm-driver-process") = require("./onboard/vm-driver-process");
const preflightUtils: typeof import("./onboard/preflight") = require("./onboard/preflight");
const clusterImagePatch: typeof import("./cluster-image-patch") = require("./cluster-image-patch");
const {
Expand Down Expand Up @@ -1344,7 +1345,7 @@ function validateSandboxGpuPreflight(config: SandboxGpuConfig): void {
process.exit(1);
}
if (!config.sandboxGpuEnabled) return;
if (!isLinuxDockerDriverGatewayPlatform()) return;
if (process.platform !== "linux") return;

const cdiSpecDirs = getDockerCdiSpecDirs();
const cdiSpecFiles = findReadableNvidiaCdiSpecFiles(cdiSpecDirs);
Expand Down Expand Up @@ -3114,20 +3115,13 @@ const {
run,
runCapture,
});

function isLinuxDockerDriverGatewayEnabled(
platform: NodeJS.Platform = process.platform,
arch: NodeJS.Architecture = process.arch,
): boolean {
return platform === "linux" || (platform === "darwin" && arch === "arm64");
}

function isLinuxDockerDriverGatewayPlatform(
platform: NodeJS.Platform = process.platform,
): boolean {
return platform === "linux";
}

function getDockerDriverGatewayStateDir(): string {
const configured = process.env.NEMOCLAW_OPENSHELL_GATEWAY_STATE_DIR;
if (configured && configured.trim()) return path.resolve(configured.trim());
Expand Down Expand Up @@ -3218,7 +3212,6 @@ function getDockerDriverGatewayEnv(
stateDir: getDockerDriverGatewayStateDir(),
dockerNetworkName: process.env.OPENSHELL_DOCKER_NETWORK_NAME || "openshell-docker",
getDockerSupervisorImage: () => getOpenShellDockerSupervisorImage(versionOutput),
resolveVmDriverBin: resolveOpenShellVmDriverBinary,
resolveSandboxBin: resolveOpenShellSandboxBinary,
});
}
Expand Down Expand Up @@ -3339,6 +3332,15 @@ function getDockerDriverGatewayRuntimeDrift(
gatewayBin?: string | null,
platform: NodeJS.Platform = process.platform,
): DockerDriverGatewayRuntimeDrift | null {
if (
platform === "darwin" &&
desiredEnv.OPENSHELL_DRIVERS === "docker" &&
vmDriverProcess.hasOpenShellVmDriverChildProcess(pid, (args) =>
runCapture([...args], { ignoreError: true }),
)
) {
return { reason: "VM driver child process is still attached to the gateway" };
}
if (!shouldRequireDockerDriverEnv(platform)) return null;
return getDockerDriverGatewayRuntimeDriftFromSnapshot({
processEnv: readProcessEnv(pid),
Expand Down Expand Up @@ -3791,8 +3793,8 @@ async function preflight(
if (host.runtime !== "unknown") {
console.log(` ✓ Container runtime: ${host.runtime}`);
}
if (isLinuxDockerDriverGatewayPlatform() && host.runtime === "podman") {
console.error(" ✗ NemoClaw Linux onboarding now uses OpenShell's Docker driver.");
if (isLinuxDockerDriverGatewayEnabled() && host.runtime === "podman") {
console.error(" ✗ NemoClaw onboarding now uses OpenShell's Docker driver.");
console.error(" Podman is not supported for this NemoClaw integration path.");
console.error(" Switch to Docker Engine and rerun onboarding.");
process.exit(1);
Comment on lines +3805 to 3809

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the resolved driver for these macOS branches.

These branches still equate darwin/arm64 with Docker. If a user exports OPENSHELL_DRIVERS=vm, preflight still rejects Podman, registry metadata still says "docker", and sandbox creation still disables the VM DNS/chmod paths. Please branch on the resolved driver selection here instead of isLinuxDockerDriverGatewayEnabled()/false. As per coding guidelines: src/lib/onboard.ts: This file contains core onboarding logic. Changes here affect the full sandbox creation and configuration flow.

Also applies to: 4825-4825, 5793-5795, 6120-6125

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard.ts` around lines 3796 - 3800, The current macOS/darwin/arm64
branches still branch on isLinuxDockerDriverGatewayEnabled() or hardcode Docker,
causing Podman/VM selections (via OPENSHELL_DRIVERS) to be ignored; update the
checks around the host.runtime === "podman" early-exit and the other noted sites
(around lines ~4825 and ~5793 and ~6120) to branch on the resolved driver
variable (e.g., resolvedDriver or the function that returns the final driver
selection) instead of isLinuxDockerDriverGatewayEnabled()/false or implicit
Docker assumptions, so that the code uses the actual selected driver for
preflight, registry metadata, and sandbox creation paths (VM DNS/chmod) across
the onboarding flow.

Expand Down Expand Up @@ -4820,11 +4822,7 @@ function getSandboxRuntimeRegistryFields(
sandboxGpuEnabled: config.sandboxGpuEnabled,
sandboxGpuMode: config.mode,
sandboxGpuDevice: config.sandboxGpuDevice,
openshellDriver: isLinuxDockerDriverGatewayEnabled()
? process.platform === "darwin"
? "vm"
: "docker"
: "kubernetes",
openshellDriver: isLinuxDockerDriverGatewayEnabled() ? "docker" : "kubernetes",
openshellVersion: getInstalledOpenshellVersion(
runCaptureOpenshell(["--version"], { ignoreError: true }),
),
Expand Down Expand Up @@ -5792,7 +5790,9 @@ async function createSandbox(
discordGuilds,
resolved ? resolved.ref : null,
telegramConfig,
process.platform === "darwin",
// Docker-on-Colima uses normal container ownership; keep the old VM chmod
// compatibility path disabled unless a future VM-specific flow opts in.
false,
sandboxInferenceBaseUrlOverride,
);
// Only pass non-sensitive env vars to the sandbox. Credentials flow through
Expand Down Expand Up @@ -6117,7 +6117,7 @@ async function createSandbox(

// DNS proxy — run a forwarder in the sandbox pod so the isolated
// sandbox namespace can resolve hostnames (fixes #626).
if (!isLinuxDockerDriverGatewayPlatform()) {
if (!isLinuxDockerDriverGatewayEnabled()) {
console.log(" Setting up sandbox DNS proxy...");
runFile("bash", [path.join(SCRIPTS, "setup-dns-proxy.sh"), GATEWAY_NAME, sandboxName], {
ignoreError: true,
Expand Down
43 changes: 42 additions & 1 deletion src/lib/onboard/docker-driver-gateway-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,41 @@ describe("buildDockerDriverGatewayEnv", () => {
platform: "linux",
stateDir: "/tmp/nemoclaw-gateway",
getDockerSupervisorImage: () => "ghcr.io/nvidia/openshell/supervisor:0.0.37",
resolveVmDriverBin: () => null,
resolveSandboxBin: () => "/usr/bin/openshell-sandbox",
}),
).toMatchObject({
OPENSHELL_DRIVERS: "docker",
OPENSHELL_BIND_ADDRESS: "127.0.0.1",
OPENSHELL_SERVER_PORT: "8080",
OPENSHELL_GRPC_ENDPOINT: "http://127.0.0.1:8080",
OPENSHELL_SSH_GATEWAY_HOST: "127.0.0.1",
OPENSHELL_SSH_GATEWAY_PORT: "8080",
OPENSHELL_DOCKER_NETWORK_NAME: "openshell-docker",
OPENSHELL_DOCKER_SUPERVISOR_IMAGE: "ghcr.io/nvidia/openshell/supervisor:0.0.37",
OPENSHELL_DOCKER_SUPERVISOR_BIN: "/usr/bin/openshell-sandbox",
});
});

it("uses the Docker driver on macOS without VM helper state", () => {
const env = buildDockerDriverGatewayEnv({
platform: "darwin",
stateDir: "/tmp/nemoclaw-gateway",
getDockerSupervisorImage: () => "ghcr.io/nvidia/openshell/supervisor:0.0.37",
resolveSandboxBin: () => "/usr/local/bin/openshell-sandbox",
});

expect(env).toMatchObject({
OPENSHELL_DRIVERS: "docker",
OPENSHELL_BIND_ADDRESS: "127.0.0.1",
OPENSHELL_SERVER_PORT: "8080",
OPENSHELL_GRPC_ENDPOINT: "http://127.0.0.1:8080",
OPENSHELL_DOCKER_NETWORK_NAME: "openshell-docker",
OPENSHELL_DOCKER_SUPERVISOR_IMAGE: "ghcr.io/nvidia/openshell/supervisor:0.0.37",
});
expect(env.OPENSHELL_DOCKER_SUPERVISOR_BIN).toBeUndefined();
expect(env.OPENSHELL_VM_DRIVER_STATE_DIR).toBeUndefined();
expect(env.OPENSHELL_DRIVER_DIR).toBeUndefined();
});
});

describe("buildDockerGatewayDebEnvFile", () => {
Expand All @@ -54,17 +78,34 @@ describe("buildDockerGatewayDebEnvFile", () => {
OPENSHELL_SSH_GATEWAY_PORT: "8990",
OPENSHELL_DOCKER_NETWORK_NAME: "openshell-docker",
OPENSHELL_DOCKER_SUPERVISOR_IMAGE: "new",
OPENSHELL_VM_DRIVER_STATE_DIR: "/tmp/old-vm-driver",
},
);

expect(next).toContain("KEEP_ME=1\n");
expect(next).toContain("OPENSHELL_BIND_ADDRESS=0.0.0.0\n");
expect(next).toContain("OPENSHELL_SERVER_PORT=8990\n");
expect(next).toContain("OPENSHELL_DOCKER_SUPERVISOR_IMAGE=new\n");
expect(next).toContain("OPENSHELL_VM_DRIVER_STATE_DIR=/tmp/old-vm-driver\n");
expect(next).not.toContain("OPENSHELL_BIND_ADDRESS=127.0.0.1");
expect(next).not.toContain("OPENSHELL_DOCKER_SUPERVISOR_IMAGE=old");
});

it("removes stale VM driver env keys when writing a Docker-driver env file", () => {
const next = buildDockerGatewayDebEnvFile(
[
"OPENSHELL_DRIVERS=vm",
"OPENSHELL_VM_DRIVER_STATE_DIR=/tmp/old-vm-driver",
"OPENSHELL_DRIVER_DIR=/tmp/old-driver-dir",
].join("\n"),
{
OPENSHELL_DRIVERS: "docker",
},
);

expect(next).toBe("OPENSHELL_DRIVERS=docker\n");
});

it("rejects multiline managed values", () => {
expect(() =>
buildDockerGatewayDebEnvFile("", {
Expand Down
23 changes: 7 additions & 16 deletions src/lib/onboard/docker-driver-gateway-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ export const DOCKER_DRIVER_GATEWAY_RUNTIME_ENV_KEYS = [
"OPENSHELL_DOCKER_NETWORK_NAME",
"OPENSHELL_DOCKER_SUPERVISOR_IMAGE",
"OPENSHELL_DOCKER_SUPERVISOR_BIN",
"OPENSHELL_VM_DRIVER_STATE_DIR",
"OPENSHELL_DRIVER_DIR",
] as const;

export interface BuildDockerDriverGatewayEnvOptions {
platform?: NodeJS.Platform;
stateDir: string;
dockerNetworkName?: string;
getDockerSupervisorImage: () => string;
resolveVmDriverBin: () => string | null;
resolveSandboxBin: () => string | null;
}

Expand Down Expand Up @@ -69,29 +70,19 @@ export function buildDockerDriverGatewayEnv({
stateDir,
dockerNetworkName = "openshell-docker",
getDockerSupervisorImage,
resolveVmDriverBin,
resolveSandboxBin,
}: BuildDockerDriverGatewayEnvOptions): Record<string, string> {
const env: Record<string, string> = {
OPENSHELL_DRIVERS: platform === "darwin" ? "vm" : "docker",
OPENSHELL_DRIVERS: "docker",
...getGatewayStartNetworkEnv(),
OPENSHELL_DISABLE_TLS: "true",
OPENSHELL_DISABLE_GATEWAY_AUTH: "true",
OPENSHELL_DB_URL: `sqlite:${path.join(stateDir, "openshell.db")}`,
OPENSHELL_GRPC_ENDPOINT:
platform === "darwin"
? `http://host.containers.internal:${GATEWAY_PORT}`
: getDockerDriverGatewayEndpoint(),
OPENSHELL_GRPC_ENDPOINT: getDockerDriverGatewayEndpoint(),
OPENSHELL_DOCKER_NETWORK_NAME: dockerNetworkName,
OPENSHELL_DOCKER_SUPERVISOR_IMAGE: getDockerSupervisorImage(),
};
if (platform === "darwin") {
env.OPENSHELL_VM_DRIVER_STATE_DIR = path.join(stateDir, "vm-driver");
const vmDriverBin = resolveVmDriverBin();
if (vmDriverBin) {
env.OPENSHELL_DRIVER_DIR = path.dirname(vmDriverBin);
}
} else {
env.OPENSHELL_DOCKER_NETWORK_NAME = dockerNetworkName;
env.OPENSHELL_DOCKER_SUPERVISOR_IMAGE = getDockerSupervisorImage();
if (platform === "linux") {
const sandboxBin = resolveSandboxBin();
if (sandboxBin) {
env.OPENSHELL_DOCKER_SUPERVISOR_BIN = sandboxBin;
Expand Down
12 changes: 1 addition & 11 deletions src/lib/onboard/openshell-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export function areRequiredDockerDriverBinariesPresent(
| "isLinuxDockerDriverGatewayEnabled"
| "resolveOpenShellGatewayBinary"
| "resolveOpenShellSandboxBinary"
| "resolveOpenShellVmDriverBinary"
>,
platform: NodeJS.Platform = process.platform,
binaries: DockerDriverBinaryOverrides = {},
Expand All @@ -129,12 +128,8 @@ export function areRequiredDockerDriverBinariesPresent(
const sandboxBinary = Object.prototype.hasOwnProperty.call(binaries, "sandboxBin")
? binaries.sandboxBin
: deps.resolveOpenShellSandboxBinary();
const vmDriverBinary = Object.prototype.hasOwnProperty.call(binaries, "vmDriverBin")
? binaries.vmDriverBin
: deps.resolveOpenShellVmDriverBinary();
if (!gatewayBinary) return false;
if (platform === "linux" && !sandboxBinary) return false;
if (platform === "darwin" && !vmDriverBinary) return false;
return true;
}

Expand Down Expand Up @@ -182,12 +177,7 @@ export function ensureOpenshellForOnboard(deps: OpenShellInstallDeps): OpenShell
if (needsDevChannel) {
deps.log(" OpenShell Docker-driver onboarding requires the dev channel. Upgrading...");
} else if (needsDockerDriverBinaries) {
const required =
platform === "linux"
? "gateway and sandbox"
: platform === "darwin"
? "gateway and VM driver"
: "gateway";
const required = platform === "linux" ? "gateway and sandbox" : "gateway";
deps.log(
` OpenShell standalone gateway onboarding requires the ${required} binaries. Reinstalling...`,
);
Expand Down
36 changes: 36 additions & 0 deletions src/lib/onboard/vm-driver-process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

export const PROCESS_LIST_ARGS = ["ps", "-axo", "pid=,ppid=,command="] as const;

export type ProcessListCapture = (args: typeof PROCESS_LIST_ARGS) => string;

export function hasOpenShellVmDriverChildProcessFromPsOutput(
gatewayPid: number,
psOutput: string,
): boolean {
if (!Number.isInteger(gatewayPid) || gatewayPid <= 0) return false;
return psOutput.split(/\r?\n/).some((line) => {
const match = line.trim().match(/^(\d+)\s+(\d+)\s+(.+)$/);
if (!match) return false;
const childPid = Number.parseInt(match[1], 10);
const parentPid = Number.parseInt(match[2], 10);
const command = match[3];
return (
Number.isInteger(childPid) &&
childPid > 0 &&
parentPid === gatewayPid &&
command.includes("openshell-driver-vm")
);
});
}

export function hasOpenShellVmDriverChildProcess(
gatewayPid: number,
captureProcessList: ProcessListCapture,
): boolean {
return hasOpenShellVmDriverChildProcessFromPsOutput(
gatewayPid,
captureProcessList(PROCESS_LIST_ARGS),
);
}
Loading
Loading