diff --git a/QUICKSTART.md b/QUICKSTART.md index 0832d2b..3ad3192 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -4,7 +4,7 @@ 1. **Navigate to project directory:** ```bash -cd /home/nvidia/.openclaw/workspace/nemo-shell-dashboard +cd /path/to/nemoclaw-dashboard ``` 2. **Install dependencies:** @@ -93,4 +93,4 @@ To make this production-ready: For issues or questions: - Check the main README.md - Review API route files for endpoint details -- Check browser console for errors \ No newline at end of file +- Check browser console for errors diff --git a/app/api/inference/route.ts b/app/api/inference/route.ts index 3b78154..1390bb6 100644 --- a/app/api/inference/route.ts +++ b/app/api/inference/route.ts @@ -1,28 +1,9 @@ import { NextResponse } from "next/server" import { execFile } from "node:child_process" -import { existsSync } from "node:fs" import { promisify } from "node:util" +import { HOST_PATH, OPENSHELL_BIN } from "@/app/lib/hostCommands" const execFileAsync = promisify(execFile) -const HOME = process.env.HOME || "" -const OPENSHELL_BIN_CANDIDATES = [ - process.env.OPENSHELL_BIN, - HOME ? `${HOME}/.local/bin/openshell` : undefined, - "/usr/local/bin/openshell", - "/opt/homebrew/bin/openshell", -].filter((value): value is string => Boolean(value)) -const OPENSHELL_BIN = - OPENSHELL_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENSHELL_BIN_CANDIDATES[0] -const HOST_PATH = [ - `${HOME}/.local/bin`, - `${HOME}/.nvm/versions/node/v22.22.2/bin`, - `${HOME}/.nvm/versions/node/v22.22.1/bin`, - "/usr/local/bin", - "/opt/homebrew/bin", - "/usr/bin", - "/bin", - process.env.PATH || "", -].filter(Boolean).join(":") const PROVIDER_TYPES = new Set(["openai", "anthropic", "nvidia", "generic", "claude", "opencode", "codex", "copilot", "gitlab", "github", "outlook"]) diff --git a/app/api/openshell/terminal/live/route.ts b/app/api/openshell/terminal/live/route.ts index 130d0ec..f1e21dc 100644 --- a/app/api/openshell/terminal/live/route.ts +++ b/app/api/openshell/terminal/live/route.ts @@ -8,6 +8,15 @@ const TERMINAL_WS_PROXY_PORT = process.env.TERMINAL_WS_PROXY_PORT || '' const PUBLIC_BROWSER_HOST = process.env.PUBLIC_BROWSER_HOST || process.env.PUBLIC_WS_HOST || null const PUBLIC_BASE_URL = process.env.PUBLIC_BASE_URL || null +function describeTerminalServerError(error: unknown, terminalServerUrl: string) { + const message = error instanceof Error ? error.message : String(error || 'unknown error') + const cause = error instanceof Error && error.cause instanceof Error ? ` (${error.cause.message})` : '' + if (/fetch failed|ECONNREFUSED|ENOTFOUND|EHOSTUNREACH|UND_ERR_SOCKET/i.test(`${message} ${cause}`)) { + return `Could not reach the operator terminal bridge at ${terminalServerUrl}. Restart the dashboard so it can auto-start the local bridge, or run npm run terminal-server in this repo. Details: ${message}${cause}` + } + return message +} + function isNonRoutableHost(candidate: string, protocol = 'http:') { const normalized = candidate.trim() if (!normalized) return true @@ -115,18 +124,26 @@ export async function POST(request: Request) { const terminalServerUrl = authority.terminalServerUrl || TERMINAL_SERVER_URL const resolvedSandboxId = authority.resolvedSandboxId || requestedSandboxId - const response = await fetch(`${terminalServerUrl}/session`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - sandboxId: resolvedSandboxId, - sessionId, - dashboardSessionId, - }), - cache: 'no-store', - }) + let response: Response + try { + response = await fetch(`${terminalServerUrl}/session`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + sandboxId: resolvedSandboxId, + sessionId, + dashboardSessionId, + }), + cache: 'no-store', + }) + } catch (error) { + return NextResponse.json({ + ok: false, + error: describeTerminalServerError(error, terminalServerUrl), + }, { status: 502 }) + } const result = await response.json() if (!response.ok) { diff --git a/app/api/sandbox/create/route.ts b/app/api/sandbox/create/route.ts index f8283fe..afcea7a 100644 --- a/app/api/sandbox/create/route.ts +++ b/app/api/sandbox/create/route.ts @@ -2,23 +2,9 @@ import { NextResponse } from "next/server" import { execFile, spawn } from "node:child_process" import { promisify } from "node:util" import { inspectSandbox } from "@/app/lib/openshellHost" +import { commandExists, HOST_PATH, NEMOCLAW_SETUP, OPENSHELL_BIN } from "@/app/lib/hostCommands" const execFileAsync = promisify(execFile) -const HOME = process.env.HOME || "" -const NEMOCLAW_SETUP = process.env.NEMOCLAW_SETUP || `${HOME}/NemoClaw/scripts/setup.sh` -const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell` -const HOST_PATH = [ - `${HOME}/.local/bin`, - `${HOME}/.nvm/versions/node/v22.22.2/bin`, - `${HOME}/.nvm/versions/node/v22.22.1/bin`, - "/opt/homebrew/bin", - "/usr/local/bin", - "/usr/bin", - "/bin", - "/usr/sbin", - "/sbin", - process.env.PATH || "", -].filter(Boolean).join(":") function validateSandboxName(name: string) { if (!name || typeof name !== "string") throw new Error("sandbox name is required") @@ -55,6 +41,13 @@ function appendNote(...parts: Array) { return parts.filter(Boolean).join(" ") } +function requireNemoClawSetup() { + if (NEMOCLAW_SETUP && commandExists(NEMOCLAW_SETUP)) return NEMOCLAW_SETUP + throw new Error( + "NemoClaw blueprint setup script was not found. Install NemoClaw on this host or set NEMOCLAW_SETUP in .env.local to the absolute path of scripts/setup.sh.", + ) +} + async function verifySandboxCreation(sandboxName: string): Promise { const startedAt = Date.now() console.log(`[sandbox/create] verify:start sandbox=${sandboxName}`) @@ -320,6 +313,7 @@ export async function POST(request: Request) { } if (blueprint === "nemoclaw-blueprint") { + const setupPath = requireNemoClawSetup() const env: NodeJS.ProcessEnv = { ...process.env, PATH: HOST_PATH, @@ -330,7 +324,7 @@ export async function POST(request: Request) { env.NVIDIA_API_KEY = env.NVIDIA_API_KEY || "optional-local-mode" } - const result = await runCommand("/bin/bash", [NEMOCLAW_SETUP, sandboxName], env) + const result = await runCommand("/bin/bash", [setupPath, sandboxName], env) if (!result.ok) { return NextResponse.json({ @@ -365,7 +359,7 @@ export async function POST(request: Request) { verification, mode: "nemoclaw-blueprint", enableTailscale, - setupPath: NEMOCLAW_SETUP, + setupPath, hostPath: HOST_PATH, readiness: { attempts: readiness.attempts, diff --git a/app/api/sandbox/delete/route.ts b/app/api/sandbox/delete/route.ts index 49d743b..e6f6837 100644 --- a/app/api/sandbox/delete/route.ts +++ b/app/api/sandbox/delete/route.ts @@ -2,23 +2,9 @@ import { NextResponse } from "next/server" import { execFile } from "node:child_process" import { promisify } from "node:util" import { resolveSandboxRef } from "@/app/lib/openshellHost" +import { HOST_PATH, NEMOCLAW_BIN, NEMOCLAW_CWD, OPENSHELL_BIN } from "@/app/lib/hostCommands" const execFileAsync = promisify(execFile) -const HOME = process.env.HOME || "" -const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell` -const NEMOCLAW_BIN = process.env.NEMOCLAW_BIN || `${HOME}/NemoClaw/bin/nemoclaw.js` -const HOST_PATH = [ - `${HOME}/.local/bin`, - `${HOME}/.nvm/versions/node/v22.22.2/bin`, - `${HOME}/.nvm/versions/node/v22.22.1/bin`, - "/opt/homebrew/bin", - "/usr/local/bin", - "/usr/bin", - "/bin", - "/usr/sbin", - "/sbin", - process.env.PATH || "", -].filter(Boolean).join(":") function elapsedMs(start: number) { return Date.now() - start @@ -106,7 +92,7 @@ async function cleanupNemoClawSandbox(sandboxName: string) { console.log(`[sandbox/delete] nemoclaw-cleanup:start sandbox=${sandboxName}`) try { const { stdout, stderr } = await execFileAsync(NEMOCLAW_BIN, [sandboxName, "destroy", "--yes"], { - cwd: `${HOME}/NemoClaw`, + cwd: NEMOCLAW_CWD, env: { ...process.env, PATH: HOST_PATH, diff --git a/app/api/support-bundle/route.ts b/app/api/support-bundle/route.ts index cb25df4..63422d3 100644 --- a/app/api/support-bundle/route.ts +++ b/app/api/support-bundle/route.ts @@ -3,6 +3,7 @@ import { promisify } from "node:util" import { NextResponse } from "next/server" import { listActivity } from "@/app/lib/activityLog" import { listBackupCatalog } from "@/app/lib/backupCatalog" +import { HOST_PATH, OPENSHELL_BIN } from "@/app/lib/hostCommands" const execFileAsync = promisify(execFile) @@ -12,7 +13,7 @@ async function run(command: string, args: string[]) { try { const { stdout, stderr } = await execFileAsync(command, args, { timeout: 10000, - env: { ...process.env, NO_COLOR: "1", CLICOLOR: "0", CLICOLOR_FORCE: "0" }, + env: { ...process.env, PATH: HOST_PATH, NO_COLOR: "1", CLICOLOR: "0", CLICOLOR_FORCE: "0" }, }) return { ok: true, stdout: stdout.trim(), stderr: stderr.trim() } } catch (error) { @@ -28,7 +29,7 @@ export async function GET() { const [gitHead, gitStatus, sandboxList, activity, backups] = await Promise.all([ run("git", ["rev-parse", "--short", "HEAD"]), run("git", ["status", "--short", "--branch"]), - run(process.env.OPENSHELL_BIN || `${process.env.HOME || ""}/.local/bin/openshell`, ["sandbox", "list"]), + run(OPENSHELL_BIN, ["sandbox", "list"]), listActivity(75), listBackupCatalog(), ]) diff --git a/app/api/telemetry/real/route.ts b/app/api/telemetry/real/route.ts index 6d44b5b..ee72a1b 100644 --- a/app/api/telemetry/real/route.ts +++ b/app/api/telemetry/real/route.ts @@ -1,55 +1,12 @@ import { NextResponse } from "next/server" import { execFile } from "node:child_process" -import { existsSync } from "node:fs" import { hostname, networkInterfaces } from "node:os" import { promisify } from "node:util" +import { HOST_PATH, NEMOCLAW_BIN, NODE_BIN, OPENSHELL_BIN } from "@/app/lib/hostCommands" import { resolveRuntimeAuthority } from "@/app/lib/runtimeAuthority" const execFileAsync = promisify(execFile) -const HOME = process.env.HOME || "" - -const NODE_BIN_CANDIDATES = [ - process.env.NODE_BIN, - HOME ? `${HOME}/.nvm/versions/node/v22.22.2/bin/node` : undefined, - HOME ? `${HOME}/.nvm/versions/node/v22.22.1/bin/node` : undefined, - "/Users/markmckeen/.nvm/versions/node/v22.22.2/bin/node", - "/Users/markmckeen/.nvm/versions/node/v22.22.1/bin/node", - "/opt/homebrew/bin/node", - "/usr/local/bin/node", - "/usr/bin/node", -].filter((value): value is string => Boolean(value)) -const NODE_BIN = NODE_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? NODE_BIN_CANDIDATES[0] -const NEMOCLAW_BIN_CANDIDATES = [ - process.env.NEMOCLAW_BIN, - HOME ? `${HOME}/.local/bin/nemoclaw` : undefined, - HOME ? `${HOME}/.nemoclaw/source/bin/nemoclaw.js` : undefined, - HOME ? `${HOME}/NemoClaw/bin/nemoclaw.js` : undefined, - HOME ? `${HOME}/.nvm/versions/node/v22.22.2/bin/nemoclaw` : undefined, - "/Users/markmckeen/.local/bin/nemoclaw", - "/Users/markmckeen/.nemoclaw/source/bin/nemoclaw.js", - "/Users/markmckeen/NemoClaw/bin/nemoclaw.js", - "/Users/markmckeen/NemoClaw-mmckeen/bin/nemoclaw.js", - "/Users/markmckeen/.nvm/versions/node/v22.22.2/bin/nemoclaw", - "/usr/local/bin/nemoclaw", - "/opt/homebrew/bin/nemoclaw", -].filter((value): value is string => Boolean(value)) -const NEMOCLAW_BIN = - NEMOCLAW_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? NEMOCLAW_BIN_CANDIDATES[0] - -const OPENSHELL_BIN_CANDIDATES = [ - process.env.OPENSHELL_BIN, - HOME ? `${HOME}/.local/bin/openshell` : undefined, - "/Users/markmckeen/.local/bin/openshell", - "/Users/markmckeen/OpenShell/target/release/openshell", - "/Users/markmckeen/openshell/target/release/openshell", - "/Users/markmckeen/openshell/scripts/bin/openshell", - "/usr/local/bin/openshell", - "/opt/homebrew/bin/openshell", -].filter((value): value is string => Boolean(value)) -const OPENSHELL_BIN = - OPENSHELL_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENSHELL_BIN_CANDIDATES[0] - type SandboxSummary = { id: string name: string @@ -191,7 +148,7 @@ function buildNemoClawSummary(output: string | null, defaultSandboxNames: Set { + if (!matcher.test(existingLine)) return true + if (replaced) return false + replaced = true + return true + }).map((existingLine) => (matcher.test(existingLine) ? line : existingLine)) + + if (!replaced) { + const trimmed = content.trimEnd() + return `${trimmed}${trimmed ? "\n" : ""}${line}\n` + } + + return `${nextLines.join("\n").trimEnd()}\n` } export function generateToken(bytes = 24) { diff --git a/app/lib/hostCommands.ts b/app/lib/hostCommands.ts new file mode 100644 index 0000000..0722e6c --- /dev/null +++ b/app/lib/hostCommands.ts @@ -0,0 +1,79 @@ +import { existsSync } from "node:fs" +import path from "node:path" + +const HOME = process.env.HOME || "" + +function firstExisting(candidates: Array, fallback: string) { + return candidates.filter((value): value is string => Boolean(value)).find((candidate) => existsSync(candidate)) || fallback +} + +function pathEntries() { + return [ + process.env.TERMINAL_EXTRA_PATH, + HOME ? path.join(HOME, ".local/bin") : undefined, + HOME ? path.join(HOME, ".nvm/versions/node/v22.22.2/bin") : undefined, + HOME ? path.join(HOME, ".nvm/versions/node/v22.22.1/bin") : undefined, + HOME ? path.join(HOME, ".nemoclaw/source/node_modules/.bin") : undefined, + HOME ? path.join(HOME, "NemoClaw/node_modules/.bin") : undefined, + "/opt/homebrew/bin", + "/usr/local/bin", + "/usr/bin", + "/bin", + "/usr/sbin", + "/sbin", + process.env.PATH, + ].filter((value): value is string => Boolean(value)) +} + +export const HOST_PATH = Array.from(new Set(pathEntries())).join(":") + +export const NODE_BIN = firstExisting([ + process.env.NODE_BIN, + HOME ? path.join(HOME, ".nvm/versions/node/v22.22.2/bin/node") : undefined, + HOME ? path.join(HOME, ".nvm/versions/node/v22.22.1/bin/node") : undefined, + "/opt/homebrew/bin/node", + "/usr/local/bin/node", + "/usr/bin/node", +], "node") + +export const OPENSHELL_BIN = firstExisting([ + process.env.OPENSHELL_BIN, + HOME ? path.join(HOME, ".local/bin/openshell") : undefined, + "/opt/homebrew/bin/openshell", + "/usr/local/bin/openshell", +], "openshell") + +export const OPENCLAW_BIN = firstExisting([ + process.env.OPENCLAW_BIN, + HOME ? path.join(HOME, ".local/bin/openclaw") : undefined, + HOME ? path.join(HOME, ".nemoclaw/source/node_modules/.bin/openclaw") : undefined, + HOME ? path.join(HOME, "NemoClaw/node_modules/.bin/openclaw") : undefined, + "/opt/homebrew/bin/openclaw", + "/usr/local/bin/openclaw", +], "openclaw") + +export const NEMOCLAW_BIN = firstExisting([ + process.env.NEMOCLAW_BIN, + HOME ? path.join(HOME, ".local/bin/nemoclaw") : undefined, + HOME ? path.join(HOME, ".nemoclaw/source/bin/nemoclaw.js") : undefined, + HOME ? path.join(HOME, "NemoClaw/bin/nemoclaw.js") : undefined, + HOME ? path.join(HOME, ".nvm/versions/node/v22.22.2/bin/nemoclaw") : undefined, + "/opt/homebrew/bin/nemoclaw", + "/usr/local/bin/nemoclaw", +], "nemoclaw") + +export const NEMOCLAW_SETUP = firstExisting([ + process.env.NEMOCLAW_SETUP, + HOME ? path.join(HOME, ".nemoclaw/source/scripts/setup.sh") : undefined, + HOME ? path.join(HOME, "NemoClaw/scripts/setup.sh") : undefined, +], "") + +export const NEMOCLAW_CWD = firstExisting([ + process.env.NEMOCLAW_CWD, + HOME ? path.join(HOME, ".nemoclaw/source") : undefined, + HOME ? path.join(HOME, "NemoClaw") : undefined, +], process.cwd()) + +export function commandExists(command: string) { + return command.includes("/") ? existsSync(command) : true +} diff --git a/app/lib/openshellHost.ts b/app/lib/openshellHost.ts index c4fb020..961786a 100644 --- a/app/lib/openshellHost.ts +++ b/app/lib/openshellHost.ts @@ -1,33 +1,9 @@ import { execFile, spawn } from "node:child_process" -import { existsSync } from "node:fs" import { promisify } from "node:util" +import { HOST_PATH, OPENCLAW_BIN, OPENSHELL_BIN } from "./hostCommands" import { getDefaultOpenClawInstance, getOpenClawDashboardPortForSandbox, resolveOpenClawInstance } from "./openclawInstances" const execFileAsync = promisify(execFile) - -const OPENSHELL_BIN_CANDIDATES = [ - process.env.OPENSHELL_BIN, - process.env.HOME ? `${process.env.HOME}/.local/bin/openshell` : undefined, - "/Users/markmckeen/.local/bin/openshell", - "/Users/markmckeen/OpenShell/target/release/openshell", - "/Users/markmckeen/openshell/target/release/openshell", - "/Users/markmckeen/openshell/scripts/bin/openshell", - "/usr/local/bin/openshell", - "/opt/homebrew/bin/openshell", -].filter((value): value is string => Boolean(value)) - -const OPENCLAW_BIN_CANDIDATES = [ - process.env.OPENCLAW_BIN, - process.env.HOME ? `${process.env.HOME}/NemoClaw/node_modules/.bin/openclaw` : undefined, - process.env.HOME ? `${process.env.HOME}/.local/bin/openclaw` : undefined, - "/usr/local/bin/openclaw", - "/opt/homebrew/bin/openclaw", -].filter((value): value is string => Boolean(value)) - -const OPENSHELL_BIN = - OPENSHELL_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENSHELL_BIN_CANDIDATES[0] -const OPENCLAW_BIN = - OPENCLAW_BIN_CANDIDATES.find((candidate) => existsSync(candidate)) ?? OPENCLAW_BIN_CANDIDATES[0] ?? "openclaw" const OPENSHELL_GATEWAY = process.env.OPENSHELL_GATEWAY || "openshell" const OPENSHELL_NAMESPACE = "agent-sandbox-system" const SANDBOX_DASHBOARD_REMOTE_PORT = Number.parseInt(process.env.OPENCLAW_SANDBOX_DASHBOARD_REMOTE_PORT || "18789", 10) @@ -70,6 +46,7 @@ export async function execOpenShell(args: string[]) { const { stdout, stderr } = await execFileAsync(OPENSHELL_BIN, args, { env: { ...process.env, + PATH: HOST_PATH, NO_COLOR: "1", CLICOLOR: "0", CLICOLOR_FORCE: "0", @@ -80,9 +57,7 @@ export async function execOpenShell(args: string[]) { function buildOpenClawEnv() { const pathEntries = [ - process.env.HOME ? `${process.env.HOME}/NemoClaw/node_modules/.bin` : null, - process.env.HOME ? `${process.env.HOME}/.local/bin` : null, - process.env.PATH, + HOST_PATH, ].filter(Boolean) return { diff --git a/app/lib/sandboxFiles.ts b/app/lib/sandboxFiles.ts index 7bcb31c..854c298 100644 --- a/app/lib/sandboxFiles.ts +++ b/app/lib/sandboxFiles.ts @@ -1,19 +1,8 @@ import { spawn } from "node:child_process" import path from "node:path" +import { HOST_PATH, OPENSHELL_BIN } from "./hostCommands" import { resolveSandboxRef } from "./openshellHost" -const HOME = process.env.HOME || "" -const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell` -const HOST_PATH = [ - `${HOME}/.local/bin`, - `${HOME}/.nvm/versions/node/v22.22.2/bin`, - `${HOME}/.nvm/versions/node/v22.22.1/bin`, - "/usr/local/bin", - "/usr/bin", - "/bin", - process.env.PATH || "", -].filter(Boolean).join(":") - export const MAX_FILE_BYTES = Number.parseInt(process.env.SANDBOX_FILE_TRANSFER_MAX_BYTES || String(128 * 1024 * 1024), 10) export const MAX_MULTIPART_REQUEST_BYTES = MAX_FILE_BYTES + Math.min(10 * 1024 * 1024, Math.max(1024 * 1024, Math.floor(MAX_FILE_BYTES / 10))) const ALLOWED_ROOTS = ["/sandbox", "/tmp"] diff --git a/app/lib/sandboxInferenceApply.ts b/app/lib/sandboxInferenceApply.ts index d88f2a6..a9fe543 100644 --- a/app/lib/sandboxInferenceApply.ts +++ b/app/lib/sandboxInferenceApply.ts @@ -1,21 +1,11 @@ import { execFile, spawn } from "node:child_process" import { promisify } from "node:util" +import { HOST_PATH, OPENSHELL_BIN } from "./hostCommands" import { getSandboxInferenceConfig, type SandboxInferenceRoute } from "./sandboxInferenceStore" const execFileAsync = promisify(execFile) -const HOME = process.env.HOME || "" -const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell` const DOCKER_BIN = process.env.DOCKER_BIN || "docker" const OPENSHELL_CLUSTER_CONTAINER = process.env.OPENSHELL_CLUSTER_CONTAINER || "openshell-cluster-nemoclaw" -const HOST_PATH = [ - `${HOME}/.local/bin`, - `${HOME}/.nvm/versions/node/v22.22.2/bin`, - `${HOME}/.nvm/versions/node/v22.22.1/bin`, - "/usr/local/bin", - "/usr/bin", - "/bin", - process.env.PATH || "", -].filter(Boolean).join(":") function modelEntry(route: SandboxInferenceRoute, openClawModelRef: string, compat: Record | null) { return { diff --git a/app/lib/sandboxPermissions.ts b/app/lib/sandboxPermissions.ts index 39c9f15..3dc4dc9 100644 --- a/app/lib/sandboxPermissions.ts +++ b/app/lib/sandboxPermissions.ts @@ -1,19 +1,9 @@ import { execFile } from "node:child_process" import { promisify } from "node:util" +import { HOST_PATH, OPENSHELL_BIN } from "./hostCommands" import { resolveSandboxRef } from "./openshellHost" const execFileAsync = promisify(execFile) -const HOME = process.env.HOME || "" -const OPENSHELL_BIN = process.env.OPENSHELL_BIN || `${HOME}/.local/bin/openshell` -const HOST_PATH = [ - `${HOME}/.local/bin`, - `${HOME}/.nvm/versions/node/v22.22.2/bin`, - `${HOME}/.nvm/versions/node/v22.22.1/bin`, - "/usr/local/bin", - "/usr/bin", - "/bin", - process.env.PATH || "", -].filter(Boolean).join(":") export type SandboxNetworkRule = { chunkId: string diff --git a/app/operator-terminal/page.tsx b/app/operator-terminal/page.tsx index 2fb7768..f56f27c 100644 --- a/app/operator-terminal/page.tsx +++ b/app/operator-terminal/page.tsx @@ -135,7 +135,9 @@ function OperatorTerminalInner() { }) const result = await response.json() if (!response.ok || !result.ok) { - throw new Error(result.error || 'Failed to initialize live terminal session.') + setTerminalState('error') + setTerminalStatus(result.error || 'Failed to initialize live terminal session.') + return } liveSessionIdRef.current = result.sessionId setLiveSession({ diff --git a/install.sh b/install.sh index 0097d27..5b6f0bd 100755 --- a/install.sh +++ b/install.sh @@ -134,6 +134,43 @@ find_openshell() { fi } +find_nemoclaw_bin() { + local candidate + for candidate in \ + "$HOME/.local/bin/nemoclaw" \ + "$HOME/.nemoclaw/source/bin/nemoclaw.js" \ + "$HOME/NemoClaw/bin/nemoclaw.js" \ + "/opt/homebrew/bin/nemoclaw" \ + "/usr/local/bin/nemoclaw" + do + [[ -x "$candidate" || -f "$candidate" ]] && printf '%s\n' "$candidate" && return + done + command -v nemoclaw 2>/dev/null || true +} + +find_nemoclaw_setup() { + local candidate + for candidate in \ + "$HOME/.nemoclaw/source/scripts/setup.sh" \ + "$HOME/NemoClaw/scripts/setup.sh" + do + [[ -f "$candidate" ]] && printf '%s\n' "$candidate" && return + done +} + +nemoclaw_cwd_for() { + local path_value="$1" + if [[ "$path_value" == "$HOME/.nemoclaw/source/"* ]]; then + printf '%s\n' "$HOME/.nemoclaw/source" + elif [[ "$path_value" == "$HOME/NemoClaw/"* ]]; then + printf '%s\n' "$HOME/NemoClaw" + elif [[ -d "$HOME/.nemoclaw/source" ]]; then + printf '%s\n' "$HOME/.nemoclaw/source" + elif [[ -d "$HOME/NemoClaw" ]]; then + printf '%s\n' "$HOME/NemoClaw" + fi +} + node_major() { node -p "Number(process.versions.node.split('.')[0])" } @@ -152,6 +189,19 @@ upsert_env() { printf '%s=%s\n' "$key" "$value" >> "$ENV_FILE" } +set_env() { + local key="$1" + local value="$2" + [[ -n "$value" ]] || return + touch "$ENV_FILE" + if grep -qE "^${key}=" "$ENV_FILE"; then + sed -i.bak -E "s|^${key}=.*$|${key}=${value}|" "$ENV_FILE" + rm -f "$ENV_FILE.bak" + return + fi + printf '%s=%s\n' "$key" "$value" >> "$ENV_FILE" +} + echo -e "${GREEN}=== ${APP_NAME} Installer ===${NC}" echo "Development build: expect sharp edges; do not expose this UI broadly without hardening." echo "" @@ -191,6 +241,23 @@ else warn "Sandbox create/delete, policy grants, terminal, and dashboard proxy features require it." fi +NEMOCLAW_BIN="$(find_nemoclaw_bin || true)" +NEMOCLAW_SETUP="$(find_nemoclaw_setup || true)" +NEMOCLAW_CWD="$(nemoclaw_cwd_for "${NEMOCLAW_BIN:-${NEMOCLAW_SETUP:-}}" || true)" + +if [[ -n "$NEMOCLAW_BIN" ]]; then + log "NemoClaw CLI: $NEMOCLAW_BIN" +else + warn "NemoClaw CLI was not found. NemoClaw inventory and cleanup features will be degraded." +fi + +if [[ -n "$NEMOCLAW_SETUP" ]]; then + log "NemoClaw setup workflow: $NEMOCLAW_SETUP" +else + warn "NemoClaw setup workflow was not found." + warn "The NemoClaw blueprint create button requires NEMOCLAW_SETUP to point at scripts/setup.sh." +fi + check_port 3000 "dashboard HTTP" check_port 3001 "OpenClaw dashboard websocket sidecar" check_port 3011 "operator terminal upstream" @@ -237,6 +304,11 @@ upsert_env "NEXT_PUBLIC_API_BASE" "/api" upsert_env "NEXT_PUBLIC_ENABLE_SANDBOX_OPERATIONS" "true" upsert_env "OPEN_SHELL_CONTAINER" "$OPEN_SHELL_CONTAINER_DEFAULT" upsert_env "OPENSHELL_GATEWAY" "nemoclaw" +set_env "OPENSHELL_BIN" "${OPENSHELL_BIN:-}" +set_env "NEMOCLAW_BIN" "${NEMOCLAW_BIN:-}" +set_env "NEMOCLAW_SETUP" "${NEMOCLAW_SETUP:-}" +set_env "NEMOCLAW_CWD" "${NEMOCLAW_CWD:-}" +upsert_env "TERMINAL_SERVER_AUTOSTART" "true" upsert_env "OPENSHELL_CONTROL_PASSWORD" "$(random_token 18)" upsert_env "OPENSHELL_CONTROL_AUTH_SECRET" "$(random_token 32)" upsert_env "OPENSHELL_CONTROL_RECOVERY_TOKEN" "$(random_token 18)" diff --git a/server.mjs b/server.mjs index 9bd2912..6442dcf 100644 --- a/server.mjs +++ b/server.mjs @@ -1,5 +1,6 @@ import http from 'node:http' import crypto from 'node:crypto' +import { spawn } from 'node:child_process' import { existsSync, readFileSync } from 'node:fs' import net from 'node:net' import tls from 'node:tls' @@ -303,12 +304,92 @@ function normalizeCloseCode(code) { : 1000 } +function shouldAutoStartTerminalServer() { + if (/^(0|false|no|off)$/i.test(process.env.TERMINAL_SERVER_AUTOSTART || '')) return false + if (terminalServerUrl.protocol !== 'http:') return false + return ['127.0.0.1', 'localhost', '[::1]', '::1'].includes(terminalServerUrl.hostname) +} + +async function isTerminalServerReachable() { + try { + const response = await fetch(new URL('/healthz', terminalServerUrl), { cache: 'no-store' }) + return response.ok + } catch { + return false + } +} + +async function waitForTerminalServer(timeoutMs = 3000) { + const deadline = Date.now() + timeoutMs + while (Date.now() < deadline) { + if (await isTerminalServerReachable()) return true + await new Promise((resolve) => setTimeout(resolve, 150)) + } + return false +} + +async function startLocalTerminalServerIfNeeded() { + if (!shouldAutoStartTerminalServer()) { + logBridge('terminal-server-autostart-skipped', { + terminalServerUrl: terminalServerUrl.toString(), + reason: 'disabled-or-nonlocal', + }) + return null + } + + if (await isTerminalServerReachable()) { + logBridge('terminal-server-existing', { terminalServerUrl: terminalServerUrl.toString() }) + return null + } + + const child = spawn(process.execPath, ['terminal-server.mjs'], { + cwd: process.cwd(), + env: { + ...process.env, + TERMINAL_SERVER_HOST: terminalServerUrl.hostname === 'localhost' ? '127.0.0.1' : terminalServerUrl.hostname.replace(/^\[|\]$/g, ''), + TERMINAL_SERVER_PORT: terminalServerUrl.port || '3011', + }, + stdio: ['ignore', 'inherit', 'inherit'], + }) + + logBridge('terminal-server-autostarted', { + pid: child.pid, + terminalServerUrl: terminalServerUrl.toString(), + }) + + child.once('exit', (code, signal) => { + logBridge('terminal-server-exited', { code, signal }) + }) + + const stopChild = () => { + if (!child.killed) child.kill('SIGTERM') + } + process.once('exit', stopChild) + process.once('SIGINT', () => { + stopChild() + process.exit(130) + }) + process.once('SIGTERM', () => { + stopChild() + process.exit(143) + }) + + if (!await waitForTerminalServer()) { + logBridge('terminal-server-autostart-not-ready', { + terminalServerUrl: terminalServerUrl.toString(), + }) + } + + return child +} + const app = next({ dev, hostname, port }) const handle = app.getRequestHandler() const handleUpgrade = typeof app.getUpgradeHandler === 'function' ? app.getUpgradeHandler() : null +await startLocalTerminalServerIfNeeded() await app.prepare() const server = http.createServer((req, res) => handle(req, res)) diff --git a/tests/control-auth-config-check.mjs b/tests/control-auth-config-check.mjs new file mode 100644 index 0000000..ef6d207 --- /dev/null +++ b/tests/control-auth-config-check.mjs @@ -0,0 +1,79 @@ +import assert from 'node:assert/strict' +import { existsSync, readFileSync } from 'node:fs' +import { mkdtemp, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import vm from 'node:vm' +import ts from 'typescript' +import { createRequire } from 'node:module' + +const root = process.cwd() +const sourcePath = path.join(root, 'app/lib/controlAuthConfig.ts') +const source = readFileSync(sourcePath, 'utf8') +const compiled = ts.transpileModule(source, { + compilerOptions: { + module: ts.ModuleKind.CommonJS, + target: ts.ScriptTarget.ES2022, + esModuleInterop: true, + }, +}).outputText + +const tempDir = await mkdtemp(path.join(tmpdir(), 'nemoclaw-auth-config-')) +const envPath = path.join(tempDir, '.env.local') +const originalCwd = process.cwd() +const originalEnv = { + password: process.env.OPENSHELL_CONTROL_PASSWORD, + secret: process.env.OPENSHELL_CONTROL_AUTH_SECRET, + recoveryToken: process.env.OPENSHELL_CONTROL_RECOVERY_TOKEN, +} + +try { + process.chdir(tempDir) + const module = { exports: {} } + vm.runInNewContext(compiled, { + require: createRequire(sourcePath), + exports: module.exports, + module, + process, + }, { filename: sourcePath }) + + await writeFile(envPath, [ + 'OPENSHELL_CONTROL_PASSWORD=old-first', + 'NEXT_PUBLIC_API_BASE=/api', + 'export OPENSHELL_CONTROL_PASSWORD=old-second', + 'OPENSHELL_CONTROL_AUTH_SECRET=old-secret', + 'OPENSHELL_CONTROL_RECOVERY_TOKEN=old-token', + '', + ].join('\n'), 'utf8') + + await module.exports.updateLocalAuthCredentials('new password with spaces') + + const updated = readFileSync(envPath, 'utf8') + assert.match(updated, /^OPENSHELL_CONTROL_PASSWORD="new password with spaces"$/m) + assert.equal([...updated.matchAll(/OPENSHELL_CONTROL_PASSWORD\s*=/g)].length, 1) + assert.equal([...updated.matchAll(/OPENSHELL_CONTROL_AUTH_SECRET\s*=/g)].length, 1) + assert.equal([...updated.matchAll(/OPENSHELL_CONTROL_RECOVERY_TOKEN\s*=/g)].length, 1) + assert.match(updated, /^NEXT_PUBLIC_API_BASE=\/api$/m) + assert.equal(process.env.OPENSHELL_CONTROL_PASSWORD, 'new password with spaces') + assert.ok(existsSync(envPath)) +} finally { + process.chdir(originalCwd) + if (originalEnv.password === undefined) { + delete process.env.OPENSHELL_CONTROL_PASSWORD + } else { + process.env.OPENSHELL_CONTROL_PASSWORD = originalEnv.password + } + if (originalEnv.secret === undefined) { + delete process.env.OPENSHELL_CONTROL_AUTH_SECRET + } else { + process.env.OPENSHELL_CONTROL_AUTH_SECRET = originalEnv.secret + } + if (originalEnv.recoveryToken === undefined) { + delete process.env.OPENSHELL_CONTROL_RECOVERY_TOKEN + } else { + process.env.OPENSHELL_CONTROL_RECOVERY_TOKEN = originalEnv.recoveryToken + } + await rm(tempDir, { recursive: true, force: true }) +} + +console.log('control-auth-config-check: PASS env auth credential update assertions') diff --git a/tests/portable-install-check.mjs b/tests/portable-install-check.mjs new file mode 100644 index 0000000..4beb77c --- /dev/null +++ b/tests/portable-install-check.mjs @@ -0,0 +1,60 @@ +import assert from 'node:assert/strict' +import { readFile } from 'node:fs/promises' +import path from 'node:path' + +const root = process.cwd() + +const [ + installSource, + hostCommandsSource, + createRouteSource, + deleteRouteSource, + telemetrySource, + openshellHostSource, + sandboxFilesSource, + sandboxPermissionsSource, + inferenceSource, + supportBundleSource, +] = await Promise.all([ + readFile(path.join(root, 'install.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'), + readFile(path.join(root, 'app/api/telemetry/real/route.ts'), 'utf8'), + readFile(path.join(root, 'app/lib/openshellHost.ts'), 'utf8'), + readFile(path.join(root, 'app/lib/sandboxFiles.ts'), 'utf8'), + readFile(path.join(root, 'app/lib/sandboxPermissions.ts'), 'utf8'), + readFile(path.join(root, 'app/api/inference/route.ts'), 'utf8'), + readFile(path.join(root, 'app/api/support-bundle/route.ts'), 'utf8'), +]) + +assert.match(installSource, /find_nemoclaw_bin\(\)/, 'installer must discover NemoClaw CLI') +assert.match(installSource, /find_nemoclaw_setup\(\)/, 'installer must discover NemoClaw setup workflow') +assert.match(installSource, /set_env "NEMOCLAW_SETUP"/, 'installer must persist discovered NemoClaw setup path') +assert.match(installSource, /set_env "NEMOCLAW_BIN"/, 'installer must persist discovered NemoClaw CLI path') +assert.match(installSource, /set_env "OPENSHELL_BIN"/, 'installer must persist discovered OpenShell path') +assert.match(installSource, /upsert_env "TERMINAL_SERVER_AUTOSTART" "true"/, 'installer must enable terminal bridge autostart by default') + +assert.match(hostCommandsSource, /export const HOST_PATH/, 'host command resolution must centralize PATH construction') +assert.match(hostCommandsSource, /\.nemoclaw\/source\/bin\/nemoclaw\.js/, 'host command resolution must support standard ~/.nemoclaw installs') +assert.match(hostCommandsSource, /\.nemoclaw\/source\/scripts\/setup\.sh/, 'host command resolution must support standard ~/.nemoclaw setup workflow') +assert.doesNotMatch(hostCommandsSource, /\/Users\/markmckeen|\/home\/nvidia/, 'host command resolution must not bake in developer machine paths') + +assert.match(createRouteSource, /requireNemoClawSetup\(\)/, 'NemoClaw blueprint create must validate setup workflow before running bash') +assert.match(createRouteSource, /NemoClaw blueprint setup script was not found/, 'missing setup workflow must produce an actionable error') +assert.match(createRouteSource, /from "@\/app\/lib\/hostCommands"/, 'create route must use shared command resolution') +assert.match(deleteRouteSource, /NEMOCLAW_CWD/, 'delete route must use resolved NemoClaw working directory') + +for (const [label, source] of [ + ['telemetry', telemetrySource], + ['openshell host', openshellHostSource], + ['sandbox files', sandboxFilesSource], + ['sandbox permissions', sandboxPermissionsSource], + ['inference', inferenceSource], + ['support bundle', supportBundleSource], +]) { + assert.match(source, /hostCommands/, `${label} must use shared host command resolution`) + assert.doesNotMatch(source, /\/Users\/markmckeen|\/home\/nvidia/, `${label} must not bake in developer machine paths`) +} + +console.log('portable-install-check: PASS installer and host command portability assertions') diff --git a/tests/post-authority-terminal-contract-check.mjs b/tests/post-authority-terminal-contract-check.mjs index 12f4ebd..0f32973 100644 --- a/tests/post-authority-terminal-contract-check.mjs +++ b/tests/post-authority-terminal-contract-check.mjs @@ -5,8 +5,10 @@ import path from 'node:path' const root = process.cwd() const routePath = path.join(root, 'app/api/openshell/terminal/live/route.ts') const pagePath = path.join(root, 'app/operator-terminal/page.tsx') +const serverPath = path.join(root, 'server.mjs') const routeSource = await readFile(routePath, 'utf8') +const serverSource = await readFile(serverPath, 'utf8') assert.match( routeSource, /throw new Error\('No routable browser host available for terminal websocket URL\. Set PUBLIC_BROWSER_HOST or PUBLIC_BASE_URL\.'\)/, @@ -27,6 +29,27 @@ assert.match( /return null/, 'terminal live route must return null when no routable browser host is available' ) +assert.match( + routeSource, + /Could not reach the operator terminal bridge at \$\{terminalServerUrl\}/, + 'terminal live route must explain terminal bridge connection failures' +) + +assert.match( + serverSource, + /startLocalTerminalServerIfNeeded/, + 'custom dashboard server must provision the local terminal bridge' +) +assert.match( + serverSource, + /TERMINAL_SERVER_AUTOSTART/, + 'terminal bridge autostart must have an environment override' +) +assert.match( + serverSource, + /spawn\(process\.execPath, \['terminal-server\.mjs'\]/, + 'dashboard dev server should start terminal-server.mjs for local terminal sessions' +) const pageSource = await readFile(pagePath, 'utf8') assert.match( @@ -44,5 +67,10 @@ assert.doesNotMatch( /Live operator terminal for the host machine\. The selected sandbox is preserved as context for helper commands and status lookups, but this shell is intentionally machine-scoped\./, 'operator terminal page must not keep the stale host-machine-only description' ) +assert.doesNotMatch( + pageSource, + /throw new Error\(result\.error \|\| 'Failed to initialize live terminal session\.'\)/, + 'operator terminal page should render terminal init failures instead of throwing' +) console.log('post-authority-terminal-contract-check: PASS websocket host + UI honesty assertions') diff --git a/tests/sandbox-lifecycle-check.mjs b/tests/sandbox-lifecycle-check.mjs index 7b64ae2..550fbf1 100644 --- a/tests/sandbox-lifecycle-check.mjs +++ b/tests/sandbox-lifecycle-check.mjs @@ -5,11 +5,13 @@ import path from 'node:path' const root = process.cwd() const createRoutePath = path.join(root, 'app/api/sandbox/create/route.ts') const deleteRoutePath = path.join(root, 'app/api/sandbox/delete/route.ts') +const hostCommandsPath = path.join(root, 'app/lib/hostCommands.ts') const telemetryRoutePath = path.join(root, 'app/api/telemetry/real/route.ts') const inferenceRoutePath = path.join(root, 'app/api/inference/route.ts') const ollamaModelsRoutePath = path.join(root, 'app/api/ollama/models/route.ts') const sandboxInferenceRoutePath = path.join(root, 'app/api/sandbox/[sandboxId]/inference/route.ts') const sandboxInferenceApplyRoutePath = path.join(root, 'app/api/sandbox/[sandboxId]/inference/apply/route.ts') +const sandboxInferenceApplyLibPath = path.join(root, 'app/lib/sandboxInferenceApply.ts') const sandboxRestartRoutePath = path.join(root, 'app/api/sandbox/[sandboxId]/restart/route.ts') const hookPath = path.join(root, 'app/hooks/useSandboxInventory.ts') const pagePath = path.join(root, 'app/page.tsx') @@ -21,11 +23,13 @@ const sandboxListPath = path.join(root, 'app/components/SandboxList.tsx') const createRouteSource = await readFile(createRoutePath, 'utf8') const deleteRouteSource = await readFile(deleteRoutePath, 'utf8') +const hostCommandsSource = await readFile(hostCommandsPath, 'utf8') const telemetryRouteSource = await readFile(telemetryRoutePath, 'utf8') const inferenceRouteSource = await readFile(inferenceRoutePath, 'utf8') const ollamaModelsRouteSource = await readFile(ollamaModelsRoutePath, 'utf8') const sandboxInferenceRouteSource = await readFile(sandboxInferenceRoutePath, 'utf8') const sandboxInferenceApplyRouteSource = await readFile(sandboxInferenceApplyRoutePath, 'utf8') +const sandboxInferenceApplyLibSource = await readFile(sandboxInferenceApplyLibPath, 'utf8') const sandboxRestartRouteSource = await readFile(sandboxRestartRoutePath, 'utf8') const hookSource = await readFile(hookPath, 'utf8') const pageSource = await readFile(pagePath, 'utf8') @@ -50,7 +54,8 @@ assert.match(hookSource, /type RefreshOptions = \{\s*force\?: boolean\s*\}/, 'in assert.match(hookSource, /!refreshOptions\?\.force && inFlightRef\.current/, 'forced inventory refresh must bypass existing in-flight reads') assert.match(hookSource, /requestIdRef = useRef\(0\)/, 'inventory refresh must guard against stale concurrent responses') -assert.match(deleteRouteSource, /OPENSHELL_BIN.*openshell/, 'delete route must use the OpenShell CLI') +assert.match(deleteRouteSource, /OPENSHELL_BIN/, 'delete route must use the shared OpenShell CLI resolver') +assert.match(hostCommandsSource, /export const OPENSHELL_BIN[\s\S]*"openshell"/, 'shared command resolver must fall back to the OpenShell CLI') assert.match(deleteRouteSource, /\["sandbox", "delete", sandboxName\]/, 'delete route must call openshell sandbox delete with the sandbox name') assert.match(deleteRouteSource, /validateSandboxName/, 'delete route must validate sandbox names before execution') assert.match(deleteRouteSource, /resolveSandboxRef/, 'delete route must resolve sandbox ids to names before deleting') @@ -81,15 +86,15 @@ assert.match(sandboxInferencePanelSource, /\/api\/sandbox\/\$\{encodeURIComponen assert.match(sandboxInferencePanelSource, /\/api\/ollama\/models/, 'selected sandbox UI must offer Ollama model selection') assert.match(sandboxInferencePanelSource, /Enabled Routes/, 'selected sandbox UI must show multiple enabled inference routes') assert.match(sandboxInferencePanelSource, /Add Route/, 'selected sandbox UI must allow adding provider/model routes') -assert.match(sandboxInferenceApplyRouteSource, /\/sandbox\/\.openclaw\/openclaw\.json/, 'live apply must patch OpenClaw config inside the running sandbox') -assert.match(sandboxInferenceApplyRouteSource, /sha256sum \/sandbox\/\.openclaw\/openclaw\.json > \/sandbox\/\.openclaw\/\.config-hash/, 'live apply must refresh the immutable OpenClaw config hash') -assert.match(sandboxInferenceApplyRouteSource, /\["inference", "set", "--no-verify", "--provider", primary\.provider, "--model", primary\.model\]/, 'live apply must point OpenShell inference at the primary route') +assert.match(sandboxInferenceApplyLibSource, /\/sandbox\/\.openclaw\/openclaw\.json/, 'live apply must patch OpenClaw config inside the running sandbox') +assert.match(sandboxInferenceApplyLibSource, /sha256sum \/sandbox\/\.openclaw\/openclaw\.json > \/sandbox\/\.openclaw\/\.config-hash/, 'live apply must refresh the immutable OpenClaw config hash') +assert.match(sandboxInferenceApplyLibSource, /\["inference", "set", "--no-verify", "--provider", primary\.provider, "--model", primary\.model\]/, 'live apply must point OpenShell inference at the primary route') assert.match(sandboxRestartRouteSource, /\["delete", "pod", sandboxName, "-n", OPENSHELL_SANDBOX_NAMESPACE, "--wait=false"\]/, 'restart route must restart the backing sandbox pod') assert.match(sandboxRestartRouteSource, /waitForSandboxReady\(sandboxName, 90000, 2000\)/, 'restart route must wait for OpenShell to report the sandbox ready') assert.match(sandboxListSource, /Restart Sandbox/, 'sandbox details must expose a restart sandbox button') assert.match(sandboxListSource, /\/api\/sandbox\/\$\{encodeURIComponent\(selectedSandbox\.id\)\}\/restart/, 'restart button must call the sandbox restart endpoint') -assert.match(sandboxListSource, //, 'sandbox list must render the per-sandbox inference profile panel for the selected sandbox') -assert.match(sidebarSource, /Inference Endpoints/, 'sidebar settings item must be named Inference Endpoints') +assert.match(sandboxListSource, /Inference/, 'settings view must render inference endpoint panel') assert.match(pageSource, /fetch\('\/api\/sandbox\/delete'/, 'destroy workflow must call the real sandbox delete endpoint')