From 3ff1a664d7021ae736d65aa48048bd11f130a676 Mon Sep 17 00:00:00 2001 From: mmckeen-nv Date: Thu, 30 Apr 2026 06:55:53 -0700 Subject: [PATCH] Restore version-locked sandbox create flow --- README.md | 2 + app/api/sandbox/create/route.ts | 245 ++++++++---------------- app/components/ConfigurationPanel.tsx | 82 +++++++- install.sh | 4 + install_versioned_nemoclaw_openshell.sh | 167 ++++++++++++++++ tests/portable-install-check.mjs | 12 ++ tests/sandbox-lifecycle-check.mjs | 20 +- 7 files changed, 357 insertions(+), 175 deletions(-) create mode 100755 install_versioned_nemoclaw_openshell.sh diff --git a/README.md b/README.md index 9efaa0e..760a5e3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # OpenShell Control +THIS IS VERSION LOCKED TO OpenShell v0.0.26 and NemoClaw v0.0.15. + OpenShell Control is a local, development-stage dashboard for operating OpenShell sandboxes and their OpenClaw gateway dashboards. It is currently built for active development and lab use. It includes a simple password gate, but it is not a hardened production control plane yet. diff --git a/app/api/sandbox/create/route.ts b/app/api/sandbox/create/route.ts index 7f6af5c..c44b723 100644 --- a/app/api/sandbox/create/route.ts +++ b/app/api/sandbox/create/route.ts @@ -1,10 +1,6 @@ import { NextResponse } from "next/server" import { execFile, spawn } from "node:child_process" -import { existsSync } from "node:fs" -import { readFile, writeFile } from "node:fs/promises" -import path from "node:path" import { promisify } from "node:util" -import { normalizeInferenceBaseUrlForGateway } from "@/app/lib/inferenceEndpointUrl" import { inspectSandbox } from "@/app/lib/openshellHost" import { commandExists, @@ -16,7 +12,6 @@ import { NEMOCLAW_SETUP_CANDIDATES, NODE_BIN, OPENSHELL_BIN, - hostCommandEnv, } from "@/app/lib/hostCommands" const execFileAsync = promisify(execFile) @@ -48,161 +43,80 @@ type SandboxVerification = { const AUTHORITATIVE_SUCCESS_PHASE = "Ready" const NO_PENDING_DEVICE_REQUESTS = /no pending device pairing requests/i -type ConfiguredInferenceRoute = { - provider: string - model: string -} - function elapsedMs(start: number) { return Date.now() - start } -function stripAnsi(value: string) { - return value.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, "") -} - -function readField(output: string, label: string) { - const match = output.match(new RegExp(`^\\s*${label}:\\s*(.+?)\\s*$`, "im")) - return match ? match[1].trim() : "" -} - -function parseConfiguredInferenceRoute(output: string, label: "Gateway inference" | "System inference"): ConfiguredInferenceRoute | null { - const otherLabel = label === "Gateway inference" ? "System inference" : "Gateway inference" - const pattern = new RegExp(`${label}:\\s*([\\s\\S]*?)(?:\\n\\s*${otherLabel}:|$)`, "i") - const section = output.match(pattern)?.[1] ?? "" - if (!section || /Not configured/i.test(section)) return null - const provider = readField(section, "Provider") - const model = readField(section, "Model") - return provider && model ? { provider, model } : null -} - -async function resolveConfiguredPrimaryInferenceRoute() { - try { - const { stdout } = await execFileAsync(OPENSHELL_BIN, ["inference", "get"], { - env: hostCommandEnv({ - OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw", - }), - timeout: 30000, - maxBuffer: 5 * 1024 * 1024, - }) - const output = stripAnsi(String(stdout).trim()) - return parseConfiguredInferenceRoute(output, "Gateway inference") || parseConfiguredInferenceRoute(output, "System inference") - } catch { - return null - } -} - -function mapOpenShellProviderToNemoClawProvider(provider: string) { - const normalized = provider.trim().toLowerCase() - const mappings: Record = { - "nvidia-inference": "build", - "nvidia-prod": "build", - "nvidia": "build", - "nvidia-nim": "nim-local", - "nim-local": "nim-local", - "ollama-local": "ollama", - "ollama": "ollama", - "vllm-local": "vllm", - "vllm": "vllm", - "openai-api": "openai", - "openai": "openai", - "anthropic-prod": "anthropic", - "anthropic": "anthropic", - "compatible-anthropic-endpoint": "anthropicCompatible", - "anthropiccompatible": "anthropicCompatible", - "compatible-endpoint": "custom", - "custom": "custom", - } - return mappings[normalized] || "" -} - -function applyConfiguredInferenceToOnboardEnv(env: NodeJS.ProcessEnv, route: ConfiguredInferenceRoute | null) { - if (!route) return null - const provider = mapOpenShellProviderToNemoClawProvider(route.provider) - if (!provider) return null - - env.NEMOCLAW_PROVIDER = provider - env.NEMOCLAW_MODEL = route.model - if (provider === "nim-local" || provider === "vllm") { - env.NEMOCLAW_EXPERIMENTAL = env.NEMOCLAW_EXPERIMENTAL || "1" - } - if (provider === "custom") { - const endpointUrl = process.env.NEMOCLAW_ENDPOINT_URL || process.env.OPENAI_BASE_URL || process.env.VLLM_BASE_URL || "" - const normalizedEndpointUrl = normalizeInferenceBaseUrlForGateway(endpointUrl, "openai") - if (normalizedEndpointUrl) env.NEMOCLAW_ENDPOINT_URL = normalizedEndpointUrl - const providerKey = process.env.NEMOCLAW_PROVIDER_KEY || process.env.OPENAI_API_KEY || process.env.VLLM_API_KEY || "" - if (providerKey) env.NEMOCLAW_PROVIDER_KEY = providerKey - } - return { - openshellProvider: route.provider, - nemoclawProvider: provider, - model: route.model, - } -} - function appendNote(...parts: Array) { return parts.filter(Boolean).join(" ") } -function resolvePreferredNemoClawDockerfile() { - const home = process.env.HOME || "" - const candidates = [ - process.env.NEMOCLAW_DOCKERFILE, - home ? path.join(home, ".nemoclaw/source/Dockerfile") : undefined, - NEMOCLAW_CWD ? path.join(NEMOCLAW_CWD, "Dockerfile") : undefined, - home ? path.join(home, "NemoClaw/Dockerfile") : undefined, - ].filter((candidate): candidate is string => Boolean(candidate)) - return candidates.find((candidate) => existsSync(candidate)) || null -} - -async function relaxKnownNemoClawDockerfileOpenClawPatch(dockerfilePath: string | null) { - if (!dockerfilePath) return null - try { - const source = await readFile(dockerfilePath, "utf8") - const strictAssertion = "assert old in src, 'writeConfigFile(params.nextConfig) pattern not found'" - if (!source.includes(strictAssertion)) { - return { dockerfilePath, patched: false, reason: "no-known-brittle-openclaw-patch" } - } - - let next = source.replace( - strictAssertion, - "print('[nemoclaw] replaceConfigFile shape changed; skipping optional EACCES compatibility patch', file=sys.stderr)", - ) - next = next.replace( - /grep -REq\s+--include='\*\.js'\s+'OPENSHELL_SANDBOX\.\*EACCES'\s+"\$rcf_file"\s+\|\|\s+\{\s+echo\s+"ERROR: Patch 4 \(replaceConfigFile EACCES\) not applied"\s+>&2;\s+exit 1;\s+\}/g, - "grep -REq --include='*.js' 'OPENSHELL_SANDBOX.*EACCES' \"$rcf_file\" || echo \"WARN: Patch 4 (replaceConfigFile EACCES) not applied; OpenClaw write shape changed\" >&2", - ) - if (next !== source) { - await writeFile(dockerfilePath, next) - return { dockerfilePath, patched: true, reason: "relaxed-brittle-openclaw-patch" } - } - return { dockerfilePath, patched: false, reason: "known-patch-present-but-unmodified" } - } catch (error) { - const message = error instanceof Error ? error.message : String(error ?? "unknown error") - return { dockerfilePath, patched: false, reason: `patch-check-failed: ${message}` } - } -} - type NemoClawCreateCommand = { file: string args: string[] mode: "cli-onboard" | "legacy-setup" - dockerfilePath?: string | null +} + +type CreateInferenceMode = "auto" | "vllm" | "nim" + +type CreateInferenceSettings = { + mode: CreateInferenceMode + model: string + hasApiKey: boolean + envSummary: string[] +} + +function parseCreateInferenceSettings(body: any): CreateInferenceSettings { + const raw = body?.createInference && typeof body.createInference === "object" ? body.createInference : {} + const requestedMode = typeof raw.mode === "string" ? raw.mode : "auto" + const mode: CreateInferenceMode = requestedMode === "vllm" || requestedMode === "nim" ? requestedMode : "auto" + const model = typeof raw.model === "string" ? raw.model.trim() : "" + const apiKey = typeof raw.apiKey === "string" ? raw.apiKey.trim() : "" + + return { + mode, + model, + hasApiKey: Boolean(apiKey), + envSummary: [], + } +} + +function applyCreateInferenceEnv(env: NodeJS.ProcessEnv, settings: CreateInferenceSettings, body: any) { + if (settings.mode === "auto") return settings + + env.NEMOCLAW_EXPERIMENTAL = "1" + settings.envSummary.push("NEMOCLAW_EXPERIMENTAL=1") + + if (settings.mode === "vllm") { + env.NEMOCLAW_PROVIDER = "vllm" + settings.envSummary.push("NEMOCLAW_PROVIDER=vllm") + } + + if (settings.mode === "nim") { + env.NEMOCLAW_PROVIDER = "nim-local" + settings.envSummary.push("NEMOCLAW_PROVIDER=nim-local") + const apiKey = typeof body?.createInference?.apiKey === "string" ? body.createInference.apiKey.trim() : "" + if (apiKey) { + env.NVIDIA_API_KEY = apiKey + env.NEMOCLAW_PROVIDER_KEY = apiKey + settings.envSummary.push("NVIDIA_API_KEY=", "NEMOCLAW_PROVIDER_KEY=") + } + } + + if (settings.model) { + env.NEMOCLAW_MODEL = settings.model + settings.envSummary.push(`NEMOCLAW_MODEL=${settings.model}`) + } + + return settings } function buildNemoClawCreateCommand(): NemoClawCreateCommand { if (NEMOCLAW_BIN && commandExists(NEMOCLAW_BIN)) { - const dockerfilePath = resolvePreferredNemoClawDockerfile() - const args = [ - "onboard", - "--non-interactive", - "--recreate-sandbox", - "--yes-i-accept-third-party-software", - ...(dockerfilePath ? ["--from", dockerfilePath] : []), - ] + const args = ["onboard", "--non-interactive", "--recreate-sandbox", "--yes-i-accept-third-party-software"] return /\.(?:c?m?js|ts)$/i.test(NEMOCLAW_BIN) - ? { file: NODE_BIN, args: [NEMOCLAW_BIN, ...args], mode: "cli-onboard", dockerfilePath } - : { file: NEMOCLAW_BIN, args, mode: "cli-onboard", dockerfilePath } + ? { file: NODE_BIN, args: [NEMOCLAW_BIN, ...args], mode: "cli-onboard" } + : { file: NEMOCLAW_BIN, args, mode: "cli-onboard" } } if (NEMOCLAW_SETUP && commandExists(NEMOCLAW_SETUP)) { return { file: "/bin/bash", args: [NEMOCLAW_SETUP], mode: "legacy-setup" } @@ -380,9 +294,14 @@ async function approveOpenClawDeviceRequests(sandboxName: string) { "sh", "-lc", "openclaw devices approve --latest --json --timeout 10000", - ], hostCommandEnv({ + ], { + ...process.env, + PATH: HOST_PATH, OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw", - }), 15000) + NO_COLOR: "1", + CLICOLOR: "0", + CLICOLOR_FORCE: "0", + }, 15000) const combinedOutput = `${result.stdout}\n${result.stderr}`.trim() const noPending = NO_PENDING_DEVICE_REQUESTS.test(combinedOutput) @@ -466,7 +385,8 @@ export async function POST(request: Request) { const sandboxName = validateSandboxName(typeof body?.sandboxName === "string" ? body.sandboxName.trim() : "") const policy = body?.policy && typeof body.policy === "object" ? body.policy : null const enableTailscale = Boolean(body?.enableTailscale) - console.log(`[sandbox/create] request:parsed sandbox=${sandboxName} blueprint=${blueprint} enableTailscale=${enableTailscale} elapsedMs=${elapsedMs(requestStartedAt)}`) + const createInference = parseCreateInferenceSettings(body) + console.log(`[sandbox/create] request:parsed sandbox=${sandboxName} blueprint=${blueprint} enableTailscale=${enableTailscale} inferenceMode=${createInference.mode} elapsedMs=${elapsedMs(requestStartedAt)}`) if (!blueprint) { return NextResponse.json({ ok: false, error: "blueprint is required" }, { status: 400 }) @@ -474,24 +394,22 @@ export async function POST(request: Request) { if (blueprint === "nemoclaw-blueprint") { const createCommand = buildNemoClawCreateCommand() - const dockerfileCompatibility = await relaxKnownNemoClawDockerfileOpenClawPatch(createCommand.dockerfilePath ?? null) - const configuredInferenceRoute = await resolveConfiguredPrimaryInferenceRoute() - const env: NodeJS.ProcessEnv = hostCommandEnv({ + const env: NodeJS.ProcessEnv = { + ...process.env, + PATH: HOST_PATH, NEMOCLAW_SANDBOX_NAME: sandboxName, NEMOCLAW_NON_INTERACTIVE: "1", NEMOCLAW_RECREATE_SANDBOX: "1", NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1", OPENSHELL_GATEWAY: process.env.OPENSHELL_GATEWAY || "nemoclaw", - }) - const onboardInference = applyConfiguredInferenceToOnboardEnv(env, configuredInferenceRoute) - console.log( - `[sandbox/create] inference-default sandbox=${sandboxName} openshellProvider=${onboardInference?.openshellProvider || "unconfigured"} nemoclawProvider=${onboardInference?.nemoclawProvider || "default"} model=${onboardInference?.model || "default"} elapsedMs=${elapsedMs(requestStartedAt)}`, - ) + } - if (!enableTailscale && !onboardInference) { + if (!enableTailscale) { env.NVIDIA_API_KEY = env.NVIDIA_API_KEY || "optional-local-mode" } + applyCreateInferenceEnv(env, createInference, body) + const result = await runCommand( createCommand.file, createCommand.mode === "legacy-setup" ? [...createCommand.args, sandboxName] : createCommand.args, @@ -508,10 +426,7 @@ export async function POST(request: Request) { blueprint, sandboxName, enableTailscale, - configuredInferenceRoute, - onboardInference, - createCommand, - dockerfileCompatibility, + createInference, }, { status: 500 }) } @@ -536,10 +451,8 @@ export async function POST(request: Request) { verification, mode: "nemoclaw-blueprint", enableTailscale, - configuredInferenceRoute, - onboardInference, + createInference, createCommand, - dockerfileCompatibility, hostPath: HOST_PATH, readiness: { attempts: readiness.attempts, @@ -560,7 +473,13 @@ export async function POST(request: Request) { } if (blueprint === "custom-sandbox") { - const env: NodeJS.ProcessEnv = hostCommandEnv() + const env: NodeJS.ProcessEnv = { + ...process.env, + PATH: HOST_PATH, + NO_COLOR: "1", + CLICOLOR: "0", + CLICOLOR_FORCE: "0", + } const createAttempt = await runCreateCommandBounded(OPENSHELL_BIN, ["sandbox", "create", "--name", sandboxName], env, 15000) if (createAttempt.completed && createAttempt.exitCode !== 0) { diff --git a/app/components/ConfigurationPanel.tsx b/app/components/ConfigurationPanel.tsx index 731f380..eec1e1e 100644 --- a/app/components/ConfigurationPanel.tsx +++ b/app/components/ConfigurationPanel.tsx @@ -7,6 +7,7 @@ type EndpointProtocol = "" | "rest" type EndpointTls = "" | "terminate" | "passthrough" type EndpointEnforcement = "" | "enforce" | "audit" type EndpointAccess = "" | "read-only" | "read-write" | "full" +type CreateInferenceMode = "auto" | "vllm" | "nim" interface NetworkRule { method: string; path: string } interface NetworkEndpoint { host: string; port: string; protocol: EndpointProtocol; tls: EndpointTls; enforcement: EndpointEnforcement; access: EndpointAccess; rules: NetworkRule[] } @@ -87,6 +88,9 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre const [selectedBlueprint, setSelectedBlueprint] = useState('nemoclaw-blueprint') const [sandboxName, setSandboxName] = useState('') const [enableTailscale, setEnableTailscale] = useState(false) + const [createInferenceMode, setCreateInferenceMode] = useState("vllm") + const [createInferenceModel, setCreateInferenceModel] = useState("") + const [createNvidiaApiKey, setCreateNvidiaApiKey] = useState("") const [restoreFromBackup, setRestoreFromBackup] = useState(false) const [restoreArchive, setRestoreArchive] = useState(null) const [restorePath, setRestorePath] = useState('/sandbox') @@ -134,7 +138,12 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre if (mode === 'create') { if (!sandboxName.trim()) throw new Error('sandbox name is required') if (restoreFromBackup && !restoreArchive) throw new Error('backup archive is required when restore from backup is enabled') - const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, policy: assembledPolicy, preset: selectedPreset || null }) }) + const createInference = { + mode: createInferenceMode, + model: createInferenceModel.trim(), + apiKey: createInferenceMode === 'nim' ? createNvidiaApiKey.trim() : '', + } + const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, createInference, policy: assembledPolicy, preset: selectedPreset || null }) }) const data = await res.json() if (!res.ok) throw new Error([data.error, data.verification?.summary, data.verification?.error, data.stdout, data.stderr].filter(Boolean).join('\n\n')) const createdSandboxId = data.verification?.details?.id || data.verification?.details?.name || data.sandboxName @@ -188,7 +197,76 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre )} {loading ?
Loading policy…
:
- {mode === 'create' &&
Create Sandbox

Choose a template and enter a sandbox name.

{blueprints.map((bp) => )}
setSandboxName(e.target.value)} placeholder={selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : 'custom-sandbox'} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" />
{activeBlueprint?.supportsTailscale && }{enableTailscale &&
Tailscale-enabled creation requires NVIDIA_API_KEY in the dashboard process environment.
}
{restoreFromBackup &&
setRestoreArchive(e.target.files?.[0] || null)} className="block w-full text-xs text-[var(--foreground-dim)] file:mr-3 file:rounded-sm file:border file:border-[var(--border-subtle)] file:bg-[var(--background-tertiary)] file:px-3 file:py-2 file:text-xs file:font-mono file:uppercase file:text-[var(--foreground)]" />
setRestorePath(e.target.value)} placeholder="/sandbox" className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" />
}
} + {mode === 'create' && ( +
+
+
Create Sandbox
+

Choose a template and enter a sandbox name.

+
+
+ {blueprints.map((bp) => ( + + ))} +
+
+ + setSandboxName(e.target.value)} placeholder={selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : 'custom-sandbox'} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" /> +
+ {activeBlueprint?.supportsTailscale && ( + + )} + {enableTailscale &&
Tailscale-enabled creation requires NVIDIA_API_KEY in the dashboard process environment.
} +
+
+
Inference at Create
+

Choose the provider NemoClaw should use while onboarding this sandbox.

+
+
+ + + +
+ {createInferenceMode !== 'auto' && ( +
+
+ + setCreateInferenceModel(e.target.value)} placeholder={createInferenceMode === 'vllm' ? 'auto-detect from vLLM' : 'model name'} className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" /> +
+ {createInferenceMode === 'nim' && ( +
+ + setCreateNvidiaApiKey(e.target.value)} placeholder="nvapi-..." className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" /> +
+ )} +
+ )} +
+
+ + {restoreFromBackup &&
setRestoreArchive(e.target.files?.[0] || null)} className="block w-full text-xs text-[var(--foreground-dim)] file:mr-3 file:rounded-sm file:border file:border-[var(--border-subtle)] file:bg-[var(--background-tertiary)] file:px-3 file:py-2 file:text-xs file:font-mono file:uppercase file:text-[var(--foreground)]" />
setRestorePath(e.target.value)} placeholder="/sandbox" className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" />
} +
+
+ )}
Security Presets

Use a canned profile for new sandboxes or switch an existing sandbox policy baseline on the fly.

{activePreset &&
{activePreset.label}

{activePreset.summary}

}
Filesystem Policy
Static
setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_only: v } })} placeholder="/usr\n/lib\n/etc" /> setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_write: v } })} placeholder="/sandbox\n/tmp" />
Network Policies
Dynamic
diff --git a/install.sh b/install.sh index 000555b..bb782d2 100755 --- a/install.sh +++ b/install.sh @@ -39,6 +39,9 @@ Options: This project is in development. The installer prepares a local dev/operator environment; it is not a systemd/production service installer. + +To install the OpenShell/NemoClaw versions validated with this dashboard, run: + ./install_versioned_nemoclaw_openshell.sh EOF } @@ -308,6 +311,7 @@ set_env() { echo -e "${GREEN}=== ${APP_NAME} Installer ===${NC}" echo "Development build: expect sharp edges; do not expose this UI broadly without hardening." +echo "This installs the dashboard only. For pinned OpenShell/NemoClaw dependencies, run ./install_versioned_nemoclaw_openshell.sh." echo "" if [[ "${EUID:-$(id -u)}" -eq 0 && "$ALLOW_ROOT" -ne 1 ]]; then diff --git a/install_versioned_nemoclaw_openshell.sh b/install_versioned_nemoclaw_openshell.sh new file mode 100755 index 0000000..50cdfe1 --- /dev/null +++ b/install_versioned_nemoclaw_openshell.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +# Install the OpenShell/NemoClaw versions this dashboard is validated against. + +set -euo pipefail + +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' + +OPENSHELL_VERSION="${OPENSHELL_VERSION:-v0.0.26}" +OPENSHELL_INSTALL_URL="${OPENSHELL_INSTALL_URL:-https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh}" +NEMOCLAW_INSTALL_TAG="${NEMOCLAW_INSTALL_TAG:-v0.0.15}" +NEMOCLAW_ZIP_URL="${NEMOCLAW_ZIP_URL:-https://github.com/NVIDIA/NemoClaw/archive/refs/tags/${NEMOCLAW_INSTALL_TAG}.zip}" +NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE="${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-1}" +NEMOCLAW_NON_INTERACTIVE="${NEMOCLAW_NON_INTERACTIVE:-1}" + +SKIP_OPENSHELL=0 +SKIP_NEMOCLAW=0 + +usage() { + cat <&2; exit 1; } + export NVIDIA_API_KEY="$2" + shift 2 + ;; + --skip-openshell) + SKIP_OPENSHELL=1 + shift + ;; + --skip-nemoclaw) + SKIP_NEMOCLAW=1 + shift + ;; + --help|-h) + usage + exit 0 + ;; + *) + echo -e "${RED}ERROR:${NC} Unknown option: $1" >&2 + usage + exit 1 + ;; + esac +done + +log() { + echo -e "${GREEN}==>${NC} $*" +} + +warn() { + echo -e "${YELLOW}WARN:${NC} $*" +} + +fail() { + echo -e "${RED}ERROR:${NC} $*" >&2 + exit 1 +} + +require_command() { + command -v "$1" >/dev/null 2>&1 || fail "$1 is required but was not found." +} + +extract_zip() { + local zip_path="$1" + local dest_dir="$2" + + if command -v unzip >/dev/null 2>&1; then + unzip -q "$zip_path" -d "$dest_dir" + return + fi + + if command -v python3 >/dev/null 2>&1; then + python3 -m zipfile -e "$zip_path" "$dest_dir" + return + fi + + fail "unzip or python3 is required to extract NemoClaw." +} + +install_openshell() { + require_command curl + require_command sh + log "Installing OpenShell $OPENSHELL_VERSION" + curl -LsSf "$OPENSHELL_INSTALL_URL" | OPENSHELL_VERSION="$OPENSHELL_VERSION" sh +} + +install_nemoclaw() { + require_command curl + require_command sh + + local work_dir zip_path source_dir + work_dir="$(mktemp -d)" + zip_path="$work_dir/nemoclaw-${NEMOCLAW_INSTALL_TAG}.zip" + trap 'rm -rf "$work_dir"' RETURN + + log "Downloading NemoClaw $NEMOCLAW_INSTALL_TAG" + curl -LsSf "$NEMOCLAW_ZIP_URL" -o "$zip_path" + extract_zip "$zip_path" "$work_dir" + + source_dir="$(find "$work_dir" -maxdepth 1 -type d -name 'NemoClaw-*' | head -n 1)" + [[ -n "$source_dir" && -f "$source_dir/install.sh" ]] || fail "Could not find NemoClaw install.sh in downloaded archive." + + if [[ -z "${NVIDIA_API_KEY:-}" ]]; then + warn "NVIDIA_API_KEY is not set. NemoClaw may require it for non-local provider setup." + fi + + log "Installing NemoClaw $NEMOCLAW_INSTALL_TAG" + ( + cd "$source_dir" + NEMOCLAW_INSTALL_TAG="$NEMOCLAW_INSTALL_TAG" \ + NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE="$NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE" \ + NEMOCLAW_NON_INTERACTIVE="$NEMOCLAW_NON_INTERACTIVE" \ + NVIDIA_API_KEY="${NVIDIA_API_KEY:-}" \ + ./install.sh + ) +} + +echo -e "${GREEN}=== Versioned OpenShell/NemoClaw Installer ===${NC}" +echo "OpenShell: $OPENSHELL_VERSION" +echo "NemoClaw: $NEMOCLAW_INSTALL_TAG" +echo "" + +if [[ "$SKIP_OPENSHELL" -eq 0 ]]; then + install_openshell +else + warn "Skipping OpenShell install" +fi + +if [[ "$SKIP_NEMOCLAW" -eq 0 ]]; then + install_nemoclaw +else + warn "Skipping NemoClaw install" +fi + +echo "" +echo -e "${GREEN}=== Versioned Install Complete ===${NC}" +echo "Run ./install.sh afterward to install or refresh the dashboard." diff --git a/tests/portable-install-check.mjs b/tests/portable-install-check.mjs index b454b37..d2c9b9e 100644 --- a/tests/portable-install-check.mjs +++ b/tests/portable-install-check.mjs @@ -6,6 +6,7 @@ const root = process.cwd() const [ installSource, + versionedInstallSource, hostCommandsSource, createRouteSource, deleteRouteSource, @@ -19,6 +20,7 @@ const [ mcpBrokerClientSource, ] = await Promise.all([ readFile(path.join(root, 'install.sh'), 'utf8'), + readFile(path.join(root, 'install_versioned_nemoclaw_openshell.sh'), 'utf8'), readFile(path.join(root, 'app/lib/hostCommands.ts'), 'utf8'), readFile(path.join(root, 'app/api/sandbox/create/route.ts'), 'utf8'), readFile(path.join(root, 'app/api/sandbox/delete/route.ts'), 'utf8'), @@ -32,6 +34,7 @@ const [ readFile(path.join(root, 'app/lib/mcpBrokerClient.ts'), 'utf8'), ]) +assert.match(installSource, /install_versioned_nemoclaw_openshell\.sh/, 'dashboard installer must point operators to the pinned OpenShell/NemoClaw installer') assert.match(installSource, /find_nemoclaw_bin\(\)/, 'installer must discover NemoClaw CLI') assert.match(installSource, /find_nemoclaw_setup\(\)/, 'installer may discover the legacy NemoClaw setup workflow') assert.match(installSource, /\$HOME\/nemoclaw\/scripts\/setup\.sh/, 'installer must check common lowercase ~/nemoclaw setup path') @@ -50,6 +53,15 @@ assert.match(installSource, /python3 -m venv "\$PROJECT_VENV"/, 'installer must assert.match(installSource, /\$venv_python" -m pip install --upgrade uv/, 'installer must install uvx into the virtual environment') assert.match(installSource, /set_env "OPENSHELL_CONTROL_VENV"/, 'installer must persist the virtual environment path for runtime MCP launches') +assert.match(versionedInstallSource, /OPENSHELL_VERSION="\$\{OPENSHELL_VERSION:-v0\.0\.26\}"/, 'versioned installer must pin OpenShell v0.0.26 by default') +assert.match(versionedInstallSource, /NEMOCLAW_INSTALL_TAG="\$\{NEMOCLAW_INSTALL_TAG:-v0\.0\.15\}"/, 'versioned installer must pin NemoClaw v0.0.15 by default') +assert.match(versionedInstallSource, /https:\/\/raw\.githubusercontent\.com\/NVIDIA\/OpenShell\/main\/install\.sh/, 'versioned installer must use the OpenShell installer URL') +assert.match(versionedInstallSource, /https:\/\/github\.com\/NVIDIA\/NemoClaw\/archive\/refs\/tags\/\$\{NEMOCLAW_INSTALL_TAG\}\.zip/, 'versioned installer must download NemoClaw from the pinned tag archive') +assert.match(versionedInstallSource, /OPENSHELL_VERSION="\$OPENSHELL_VERSION" sh/, 'versioned installer must pass the pinned OpenShell version to upstream install.sh') +assert.match(versionedInstallSource, /NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE="\$NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE"/, 'versioned installer must support non-interactive third-party acceptance') +assert.match(versionedInstallSource, /NEMOCLAW_NON_INTERACTIVE="\$NEMOCLAW_NON_INTERACTIVE"/, 'versioned installer must run NemoClaw non-interactively by default') +assert.match(versionedInstallSource, /NVIDIA_API_KEY="\$\{NVIDIA_API_KEY:-\}"/, 'versioned installer must pass NVIDIA_API_KEY through to NemoClaw install') + assert.match(hostCommandsSource, /export const HOST_PATH/, 'host command resolution must centralize PATH construction') assert.match(hostCommandsSource, /OPENSHELL_CONTROL_VENV/, 'host command resolution must include the installer-managed virtual environment') assert.match(hostCommandsSource, /\.venv\/bin/, 'host command resolution must include the default project virtual environment') diff --git a/tests/sandbox-lifecycle-check.mjs b/tests/sandbox-lifecycle-check.mjs index 25ac963..b33d405 100644 --- a/tests/sandbox-lifecycle-check.mjs +++ b/tests/sandbox-lifecycle-check.mjs @@ -55,15 +55,13 @@ assert.match( /readiness:\s*\{\s*attempts: readiness\.attempts,\s*elapsedMs: readiness\.elapsedMs,/, 'blueprint create response must expose readiness polling metadata', ) -assert.match(createRouteSource, /resolveConfiguredPrimaryInferenceRoute/, 'blueprint create must resolve the configured primary OpenShell inference route') -assert.match(createRouteSource, /applyConfiguredInferenceToOnboardEnv/, 'blueprint create must pass the configured inference route into NemoClaw onboarding') -assert.match(createRouteSource, /NEMOCLAW_PROVIDER/, 'blueprint create must set NemoClaw provider from inference configuration') -assert.match(createRouteSource, /NEMOCLAW_MODEL/, 'blueprint create must set NemoClaw model from inference configuration') -assert.match(createRouteSource, /!enableTailscale && !onboardInference/, 'blueprint create must not inject the optional NVIDIA placeholder when a primary inference route is configured') -assert.match(createRouteSource, /resolvePreferredNemoClawDockerfile/, 'blueprint create must pass an explicit NemoClaw Dockerfile to onboard') -assert.match(createRouteSource, /"--from", dockerfilePath/, 'blueprint create must make onboard use the selected Dockerfile instead of implicit refresh paths') -assert.match(createRouteSource, /relaxKnownNemoClawDockerfileOpenClawPatch/, 'blueprint create must self-heal the known brittle OpenClaw Dockerfile patch') -assert.match(createRouteSource, /writeConfigFile\(params\.nextConfig\) pattern not found/, 'Dockerfile compatibility guard must target the observed OpenClaw patch assertion') +assert.match(createRouteSource, /"onboard", "--non-interactive", "--recreate-sandbox"/, 'blueprint create must use the Monday-era normal NemoClaw onboard flow') +assert.doesNotMatch(createRouteSource, /"--from"|resolvePreferredNemoClawDockerfile|prepareDashboardOwnedNemoClawDockerfile/, 'blueprint create must not force the explicit Dockerfile path') +assert.match(createRouteSource, /NEMOCLAW_SANDBOX_NAME: sandboxName/, 'blueprint create must pass the requested sandbox name to NemoClaw onboarding') +assert.match(createRouteSource, /NEMOCLAW_EXPERIMENTAL = "1"/, 'blueprint create must support NemoClaw experimental provider onboarding') +assert.match(createRouteSource, /NEMOCLAW_PROVIDER = "vllm"/, 'blueprint create must support the vLLM onboarding provider') +assert.match(createRouteSource, /NEMOCLAW_PROVIDER = "nim-local"/, 'blueprint create must support the NVIDIA NIM onboarding provider') +assert.match(createRouteSource, /NEMOCLAW_PROVIDER_KEY = apiKey/, 'blueprint create must pass NVIDIA API keys through provider env without changing NemoClaw') assert.match(hookSource, /type RefreshOptions = \{\s*force\?: boolean\s*\}/, 'inventory refresh must accept a force option') assert.match(hookSource, /!refreshOptions\?\.force && inFlightRef\.current/, 'forced inventory refresh must bypass existing in-flight reads') @@ -94,7 +92,6 @@ assert.match(inferenceRouteSource, /isVllmEndpoint\(name, baseUrl\)/, 'inference assert.match(inferenceRouteSource, /normalizeProviderType\(requestedType, name, baseUrl\)/, 'inference route must force vLLM endpoints through the OpenAI-compatible provider type') assert.match(inferenceRouteSource, /normalizeInferenceBaseUrlForGateway\(\s*baseUrl,/, 'inference route must normalize endpoint URLs for the OpenShell gateway pod') assert.match(inferenceRouteSource, /OPENAI_BASE_URL=\$\{normalizedBaseUrl\}/, 'inference route must pass the normalized endpoint URL as provider config') -assert.match(createRouteSource, /normalizeInferenceBaseUrlForGateway\(endpointUrl, "openai"\)/, 'sandbox create must normalize env-derived OpenAI-compatible endpoints before NemoClaw onboarding') assert.match(inferenceEndpointUrlSource, /host\.docker\.internal/, 'endpoint normalization must rewrite host-local URLs to a gateway-reachable host alias') assert.match(inferenceEndpointUrlSource, /\/chat\/completions/, 'endpoint normalization must strip concrete OpenAI endpoint suffixes to the base URL') assert.match(inferencePanelSource, /INFERENCE ENDPOINTS/, 'settings UI must expose inference endpoint configuration') @@ -156,5 +153,8 @@ assert.match( ) assert.doesNotMatch(pageSource, /console\.log\('Destroying sandbox:'/, 'destroy workflow must not be a UI-only placeholder') assert.doesNotMatch(configPanelSource, /onInventoryRefresh/, 'create panel must leave post-create inventory orchestration to the parent') +assert.match(configPanelSource, /Use vLLM in experimental mode/, 'create panel must expose vLLM experimental onboarding') +assert.match(configPanelSource, /Use NVIDIA NIM/, 'create panel must expose NVIDIA NIM onboarding') +assert.match(configPanelSource, /createInference/, 'create panel must send create-time inference settings') console.log('sandbox-lifecycle-check: PASS create/destroy lifecycle assertions')