diff --git a/README.md b/README.md index 90ab03e..cab6cfe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # OpenShell Control -THIS IS VERSION LOCKED TO OpenShell v0.0.36, NemoClaw v0.0.37, and OpenClaw 2026.4.27. +THIS IS TRACKING current NVIDIA NemoClaw `main` with the OpenShell version declared compatible by NemoClaw's blueprint. OpenShell Control is a local, development-stage dashboard for operating OpenShell sandboxes and their OpenClaw gateway dashboards. @@ -43,29 +43,26 @@ It is currently built for active development and lab use. It includes a simple p Screenshot 2026-04-27 at 3 42 37 PM -## Version Lock +## Compatibility Targets -This dashboard is validated against the following runtime/toolchain versions: +This dashboard is validated against the current NVIDIA NemoClaw repo and the OpenShell version range declared in NemoClaw's `nemoclaw-blueprint/blueprint.yaml`, not the older April 2026 point releases. Current NemoClaw `main` pins OpenShell exactly to `0.0.44`, so the bundled refresh helper defaults to: + +- OpenShell installer release: `v0.0.44` (`OPENSHELL_VERSION=v0.0.44`) +- NemoClaw source ref: `main` (`NEMOCLAW_INSTALL_REF=main`) +- OpenClaw base-image build arg: `2026.5.22` unless overridden by `OPENCLAW_VERSION` + +Runtime/toolchain versions used during development: - Ubuntu/Linux host -- Node.js `v22.22.2` -- npm `10.9.7` -- Docker `29.1.3` -- OpenShell CLI and gateway `v0.0.36` -- NemoClaw CLI `v0.0.37` -- OpenClaw `2026.4.27` - -Minimum expected versions: - -- Node.js `20+` +- Node.js `20+` (Node `22.x` recommended for parity with NemoClaw) - npm `10+` - Docker `24+` -- OpenShell CLI and gateway compatible with `v0.0.36` -- NemoClaw CLI compatible with `v0.0.37` +- OpenShell CLI and gateway compatible with current `NVIDIA/NemoClaw` blueprint constraints +- NemoClaw CLI compatible with the current `NVIDIA/NemoClaw` repo -Use `./install_versioned_nemoclaw_openshell.sh` to install or refresh the locked OpenShell/NemoClaw pair. Override the versions only when intentionally testing a newer pair. +Use `./install_versioned_nemoclaw_openshell.sh` to install or refresh the OpenShell/NemoClaw pair. Override `OPENSHELL_VERSION`, `NEMOCLAW_INSTALL_REF`, or `OPENCLAW_VERSION` only when intentionally testing a different pair. -The app uses Next.js `14.2.35`, React `18.3.1`, TypeScript, Tailwind CSS, `ws`, `node-pty`, and the official MCP TypeScript SDK. +The app uses Next.js `15.5.15`, React `18.3.1`, TypeScript, Tailwind CSS, `ws`, `node-pty`, and the official MCP TypeScript SDK. ## Prerequisites @@ -101,7 +98,7 @@ Install or refresh the locked OpenShell/NemoClaw pair first: ./install_versioned_nemoclaw_openshell.sh ``` -That helper defaults to `OPENSHELL_VERSION=v0.0.36`, `NEMOCLAW_INSTALL_TAG=v0.0.37`, and `OPENCLAW_VERSION=2026.4.27`. +That helper defaults to `OPENSHELL_VERSION=v0.0.44`, `NEMOCLAW_INSTALL_REF=main`, and `OPENCLAW_VERSION=2026.5.22`. Then install the dashboard from the repository root: @@ -165,6 +162,8 @@ Default ports: - `3000`: dashboard HTTP server - `3011`: operator terminal upstream +If you set `OPENSHELL_TERMINAL_ATTACH_TEMPLATE`, leave `{sandboxId}` and `{alias}` unquoted in the template. The terminal bridge validates sandbox IDs and shell-quotes those placeholder values before executing the template. + The dashboard WebSocket proxy is served on the same listener by default, using `/api/openshell/dashboard/proxy` or `/api/openshell/instances/[instanceId]/dashboard/proxy`. Set `OPENCLAW_DASHBOARD_WS_PROXY_PORT=3001` only if you intentionally want the legacy dedicated sidecar listener. ## Ollama Inference @@ -217,9 +216,10 @@ The dashboard shells out to the OpenShell CLI for several operations: - `openshell list` - `openshell sandbox exec` - `openshell sandbox delete` -- `openshell rule get` -- `openshell rule approve` -- `openshell rule reject` +- `openshell policy get` +- `openshell policy update` +- `openshell provider create/update/delete/list` +- `openshell inference set/get/update` OpenClaw dashboard access is loopback-only inside the host/sandbox context, so the UI uses local proxy routes: diff --git a/app/api/ollama/models/route.ts b/app/api/ollama/models/route.ts index 1cefac7..f4375a9 100644 --- a/app/api/ollama/models/route.ts +++ b/app/api/ollama/models/route.ts @@ -3,7 +3,7 @@ import { execFile } from "node:child_process" import { existsSync, statSync } from "node:fs" import { readdir, readFile } from "node:fs/promises" import { isIP } from "node:net" -import { release } from "node:os" +import { platform, release } from "node:os" import { promisify } from "node:util" const DEFAULT_OLLAMA_URL = "http://127.0.0.1:11434" @@ -127,7 +127,7 @@ function formatBytes(size: unknown) { function modelRowsFromTags(data: any, origin: OllamaProbeCandidate): OllamaModelRow[] { return Array.isArray(data?.models) - ? data.models.map((item: OllamaTag) => { + ? data.models.filter((item: OllamaTag) => isChatModelName(item.model || item.name || "")).map((item: OllamaTag) => { const name = item.model || item.name || "" return { id: `${origin.hostKind}:${name}`, @@ -150,6 +150,10 @@ function modelRowsFromTags(data: any, origin: OllamaProbeCandidate): OllamaModel : [] } +function isChatModelName(name: string) { + return !/(^|[-_:/.])(embed|embedding|rerank|bge|nomic-embed)([-_:/.]|$)/i.test(name) +} + async function isWslRuntime() { if (process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP) return true const kernelRelease = release().toLowerCase() @@ -253,6 +257,8 @@ function customHostUrl(host: string) { async function buildProbeCandidates() { const candidates: OllamaProbeCandidate[] = [] const wsl = await isWslRuntime() + const localHostLabel = platform() === "darwin" ? "MAC" : "LINUX" + const localSource = platform() === "darwin" ? "mac-localhost" : "localhost" addFetchCandidate(candidates, process.env.OPENSHELL_OLLAMA_BASE_URL, "OPENSHELL_OLLAMA_BASE_URL", "custom", "CUSTOM") addFetchCandidate(candidates, process.env.OLLAMA_BASE_URL, "OLLAMA_BASE_URL", "custom", "CUSTOM") @@ -260,7 +266,7 @@ async function buildProbeCandidates() { for (const host of customHostCandidates()) { addFetchCandidate(candidates, customHostUrl(host), "OPENSHELL_OLLAMA_HOSTS", "custom", "CUSTOM") } - addFetchCandidate(candidates, DEFAULT_OLLAMA_URL, wsl ? "wsl-localhost" : "localhost", wsl ? "wsl2" : "linux", wsl ? "WSL2" : "LINUX") + addFetchCandidate(candidates, DEFAULT_OLLAMA_URL, wsl ? "wsl-localhost" : localSource, wsl ? "wsl2" : "linux", wsl ? "WSL2" : localHostLabel) if (wsl) { for (const host of await readWslHostCandidates()) { diff --git a/app/api/sandbox/[sandboxId]/health/route.ts b/app/api/sandbox/[sandboxId]/health/route.ts index 72e9f82..1babfce 100644 --- a/app/api/sandbox/[sandboxId]/health/route.ts +++ b/app/api/sandbox/[sandboxId]/health/route.ts @@ -3,11 +3,15 @@ import { execOpenShell, normalizeSandboxPhase, resolveSandboxRef } from "@/app/l import { listBackupCatalog } from "@/app/lib/backupCatalog" import { getNemoClawDoctorReport } from "@/app/lib/nemoclawCli" +function stripAnsi(value: string) { + return value.replace(/\u001b\[[0-9;]*m/g, "") +} + function parseField(output: string, label: string) { const normalizedLabel = label.toLowerCase() const line = output .split(/\r?\n/) - .map((entry) => entry.trim()) + .map((entry) => stripAnsi(entry).trim()) .find((entry) => entry.toLowerCase().startsWith(`${normalizedLabel}:`)) return line ? line.slice(label.length + 1).trim() : null diff --git a/app/components/InferenceEndpointPanel.tsx b/app/components/InferenceEndpointPanel.tsx index 6a241f9..4a4e393 100644 --- a/app/components/InferenceEndpointPanel.tsx +++ b/app/components/InferenceEndpointPanel.tsx @@ -46,7 +46,7 @@ const providerTypeOptions = [ ] const OLLAMA_PROVIDER_NAME = "ollama-local" -const OLLAMA_BASE_URL = "http://host.docker.internal:11434/v1" +const OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1" const DEFAULT_VLLM_CONTAINER = "vllm-bigboy" const DEFAULT_VLLM_IMAGE = "nvcr.io/nvidia/vllm:26.03.post1-py3" const DEFAULT_VLLM_MODEL = "vllm-local" @@ -467,6 +467,11 @@ export default function InferenceEndpointPanel() { setProviders(Array.isArray(data.providers) ? data.providers : []) if (data.gateway?.provider) setName(data.gateway.provider) if (data.gateway?.model) setModel(data.gateway.model) + if (data.gateway?.provider?.toLowerCase().includes("ollama")) { + setType("openai") + setBaseUrl(OLLAMA_BASE_URL) + setCredentialKey("OLLAMA_API_KEY") + } if (data.gateway?.provider && isVllmEndpoint(data.gateway.provider, "")) setType("vllm") } catch (error) { setMessage(error instanceof Error ? error.message : "Failed to load inference configuration") @@ -516,7 +521,7 @@ export default function InferenceEndpointPanel() { setType("openai") setModel(modelName) setBaseUrl(ollamaOpenAiBaseUrl(item)) - setCredentialKey("OPENAI_API_KEY") + setCredentialKey("OLLAMA_API_KEY") setApiKey("") setRoute("gateway") setNoVerify(true) @@ -530,6 +535,7 @@ export default function InferenceEndpointPanel() { setCredentialKey(provider.credentialKeys[0] || "OPENAI_API_KEY") if (provider.name.toLowerCase().includes("ollama")) { setBaseUrl(OLLAMA_BASE_URL) + setCredentialKey(provider.credentialKeys[0] || "OLLAMA_API_KEY") setApiKey("") } setMessage(`Loaded ${provider.name}. Enter a model and save to make it active.`) diff --git a/app/lib/openshellHost.ts b/app/lib/openshellHost.ts index 1e97b03..e9fcb2f 100644 --- a/app/lib/openshellHost.ts +++ b/app/lib/openshellHost.ts @@ -4,7 +4,7 @@ import { HOST_PATH, OPENCLAW_BIN, OPENSHELL_BIN, hostCommandEnv } from "./hostCo import { getDefaultOpenClawInstance, getOpenClawDashboardPortForSandbox, resolveOpenClawInstance } from "./openclawInstances" const execFileAsync = promisify(execFile) -const OPENSHELL_GATEWAY = process.env.OPENSHELL_GATEWAY || "openshell" +const OPENSHELL_GATEWAY = process.env.OPENSHELL_GATEWAY?.trim() || undefined const OPENSHELL_NAMESPACE = "agent-sandbox-system" const SANDBOX_DASHBOARD_REMOTE_PORT = Number.parseInt(process.env.OPENCLAW_SANDBOX_DASHBOARD_REMOTE_PORT || "18789", 10) diff --git a/app/operator-terminal/page.tsx b/app/operator-terminal/page.tsx index 42f3340..2f70880 100644 --- a/app/operator-terminal/page.tsx +++ b/app/operator-terminal/page.tsx @@ -44,6 +44,7 @@ interface LiveTerminalSession { sandboxId: string dashboardSessionId: string replay?: string + transport?: string websocketUrl: string sshHostAlias?: string reconnectKey?: string @@ -184,6 +185,7 @@ function OperatorTerminalInner() { sandboxId: result.sandboxId, dashboardSessionId: result.dashboardSessionId || dashboardSessionId, replay: result.replay, + transport: result.transport, websocketUrl: result.websocketUrl, sshHostAlias: result.sshHostAlias, reconnectKey: String(reconnectCounterRef.current), @@ -292,9 +294,10 @@ function OperatorTerminalInner() { socket.addEventListener('open', () => { setTerminalState('connected') + const transportLabel = liveSession.transport ? ` via ${liveSession.transport}` : '' setTerminalStatus(shouldLaunchHermes - ? `Live terminal connected for ${liveSession.sandboxId}; launching Hermes…` - : `Live terminal connected for ${liveSession.sandboxId}.`) + ? `Live terminal connected for ${liveSession.sandboxId}${transportLabel}; launching Hermes…` + : `Live terminal connected for ${liveSession.sandboxId}${transportLabel}.`) try { fitAddonRef.current?.fit() } catch { diff --git a/install_versioned_nemoclaw_openshell.sh b/install_versioned_nemoclaw_openshell.sh index 07adf28..4d3afb5 100755 --- a/install_versioned_nemoclaw_openshell.sh +++ b/install_versioned_nemoclaw_openshell.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install the OpenShell/NemoClaw versions this dashboard is validated against. +# Install the OpenShell/NemoClaw revisions this dashboard is validated against. set -euo pipefail @@ -8,11 +8,11 @@ YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' -OPENSHELL_VERSION="${OPENSHELL_VERSION:-v0.0.36}" +OPENSHELL_VERSION="${OPENSHELL_VERSION:-v0.0.44}" OPENSHELL_INSTALL_URL="${OPENSHELL_INSTALL_URL:-https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh}" -NEMOCLAW_INSTALL_TAG="${NEMOCLAW_INSTALL_TAG:-v0.0.37}" -NEMOCLAW_ZIP_URL="${NEMOCLAW_ZIP_URL:-https://github.com/NVIDIA/NemoClaw/archive/refs/tags/${NEMOCLAW_INSTALL_TAG}.zip}" -OPENCLAW_VERSION="${OPENCLAW_VERSION:-2026.4.27}" +NEMOCLAW_INSTALL_REF="${NEMOCLAW_INSTALL_REF:-${NEMOCLAW_INSTALL_TAG:-main}}" +NEMOCLAW_SOURCE_URL="${NEMOCLAW_SOURCE_URL:-https://github.com/NVIDIA/NemoClaw.git}" +OPENCLAW_VERSION="${OPENCLAW_VERSION:-2026.5.22}" NEMOCLAW_BASE_IMAGE="${NEMOCLAW_BASE_IMAGE:-ghcr.io/nvidia/nemoclaw/sandbox-base:latest}" NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE="${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-1}" NEMOCLAW_NON_INTERACTIVE="${NEMOCLAW_NON_INTERACTIVE:-1}" @@ -37,7 +37,7 @@ Options: Defaults: OPENSHELL_VERSION=$OPENSHELL_VERSION - NEMOCLAW_INSTALL_TAG=$NEMOCLAW_INSTALL_TAG + NEMOCLAW_INSTALL_REF=$NEMOCLAW_INSTALL_REF OPENCLAW_VERSION=$OPENCLAW_VERSION NEMOCLAW_BASE_IMAGE=$NEMOCLAW_BASE_IMAGE NEMOCLAW_EXPERIMENTAL=$NEMOCLAW_EXPERIMENTAL @@ -46,8 +46,9 @@ Defaults: Environment overrides: OPENSHELL_VERSION OPENSHELL_INSTALL_URL - NEMOCLAW_INSTALL_TAG - NEMOCLAW_ZIP_URL + NEMOCLAW_INSTALL_REF + NEMOCLAW_INSTALL_TAG (legacy alias for NEMOCLAW_INSTALL_REF) + NEMOCLAW_SOURCE_URL OPENCLAW_VERSION NEMOCLAW_BASE_IMAGE NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE @@ -105,23 +106,6 @@ 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 @@ -130,30 +114,31 @@ install_openshell() { } install_nemoclaw() { - require_command curl require_command sh + require_command git require_command docker - local work_dir zip_path source_dir + local work_dir source_dir work_dir="$(mktemp -d)" - zip_path="$work_dir/nemoclaw-${NEMOCLAW_INSTALL_TAG}.zip" trap 'rm -rf "$work_dir"' RETURN + source_dir="$work_dir/NemoClaw" - 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." + log "Cloning NemoClaw $NEMOCLAW_INSTALL_REF" + git init --quiet "$source_dir" + git -C "$source_dir" remote add origin "$NEMOCLAW_SOURCE_URL" + git -C "$source_dir" fetch --quiet --depth 1 origin "$NEMOCLAW_INSTALL_REF" + git -C "$source_dir" -c advice.detachedHead=false checkout --quiet --detach FETCH_HEAD + [[ -n "$source_dir" && -f "$source_dir/install.sh" ]] || fail "Could not find NemoClaw install.sh in source checkout." 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" + log "Installing NemoClaw $NEMOCLAW_INSTALL_REF" ( cd "$source_dir" - NEMOCLAW_INSTALL_TAG="$NEMOCLAW_INSTALL_TAG" \ + NEMOCLAW_INSTALL_REF="$NEMOCLAW_INSTALL_REF" \ + NEMOCLAW_INSTALL_TAG="$NEMOCLAW_INSTALL_REF" \ NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE="$NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE" \ NEMOCLAW_NON_INTERACTIVE="$NEMOCLAW_NON_INTERACTIVE" \ NEMOCLAW_EXPERIMENTAL="$NEMOCLAW_EXPERIMENTAL" \ @@ -172,7 +157,7 @@ install_nemoclaw() { echo -e "${GREEN}=== Versioned OpenShell/NemoClaw Installer ===${NC}" echo "OpenShell: $OPENSHELL_VERSION" -echo "NemoClaw: $NEMOCLAW_INSTALL_TAG" +echo "NemoClaw: $NEMOCLAW_INSTALL_REF" echo "OpenClaw: $OPENCLAW_VERSION" echo "Base image: $NEMOCLAW_BASE_IMAGE" echo "Provider: $NEMOCLAW_PROVIDER (experimental=$NEMOCLAW_EXPERIMENTAL)" diff --git a/terminal-server.mjs b/terminal-server.mjs index 8edf75d..0000ae7 100644 --- a/terminal-server.mjs +++ b/terminal-server.mjs @@ -87,24 +87,49 @@ function shellEscape(value) { return `'${String(value).replace(/'/g, `'"'"'`)}'` } +function normalizeSandboxId(value) { + const sandboxId = String(value || '').trim() || 'host' + if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(sandboxId)) { + throw new Error('Invalid sandboxId. Use letters, numbers, dot, underscore, or dash only.') + } + return sandboxId +} + function openshellBin() { return process.env.OPENSHELL_BIN || 'openshell' } function buildAttachCommand(sandboxId) { if (process.env.OPENSHELL_TERMINAL_ATTACH_TEMPLATE) { - const alias = `openshell-${sandboxId}` - return process.env.OPENSHELL_TERMINAL_ATTACH_TEMPLATE.replaceAll('{sandboxId}', sandboxId).replaceAll('{alias}', alias) + const safeSandboxId = shellEscape(normalizeSandboxId(sandboxId)) + const safeAlias = shellEscape(`openshell-${normalizeSandboxId(sandboxId)}`) + return process.env.OPENSHELL_TERMINAL_ATTACH_TEMPLATE.replaceAll('{sandboxId}', safeSandboxId).replaceAll('{alias}', safeAlias) } return shellForPlatform() } +function buildSessionCommand(sandboxId) { + if (sandboxId && sandboxId !== 'host' && process.env.OPENSHELL_TERMINAL_ATTACH_TEMPLATE) { + return buildAttachCommand(sandboxId) + } + return `${shellForPlatform()} -i` +} + +function buildSessionExec(sandboxId) { + const sessionCommand = buildSessionCommand(sandboxId) + if (sandboxId && sandboxId !== 'host' && process.env.OPENSHELL_TERMINAL_ATTACH_TEMPLATE) { + return `exec ${shellForPlatform()} -lc ${shellEscape(sessionCommand)}` + } + return `exec ${sessionCommand}` +} + function buildBootstrapShell(sandboxId) { + const sessionExec = buildSessionExec(sandboxId) return [ `export PATH=${shellEscape(effectivePath())}`, `export OPENSHELL_SANDBOX_ID=${shellEscape(sandboxId)}`, `export PS1='[operator:${sandboxId || 'host'}] \\u@\\h:\\w\\$ '`, - `exec ${shellForPlatform()} -i`, + sessionExec, ].join('; ') } @@ -261,12 +286,23 @@ function createStreamTransport(sandboxId) { } function createTransport(sandboxId) { - return runtime.mode === 'pty' ? createPtyTransport(sandboxId) : createStreamTransport(sandboxId) + if (runtime.mode !== 'pty') return createStreamTransport(sandboxId) + + try { + return createPtyTransport(sandboxId) + } catch (error) { + if ((process.env.TERMINAL_TRANSPORT || 'auto').trim().toLowerCase() === 'pty') { + throw error + } + + console.warn(`terminal pty spawn failed; falling back to stream transport: ${error instanceof Error ? error.message : String(error)}`) + return createStreamTransport(sandboxId) + } } function createSessionIdentity(sandboxId, dashboardSessionId) { return { - sandboxId, + sandboxId: normalizeSandboxId(sandboxId), dashboardSessionId: dashboardSessionId && dashboardSessionId.trim() ? dashboardSessionId.trim() : 'dashboard-host', } } @@ -280,7 +316,7 @@ function createSession(identity) { id, sandboxId: identity.sandboxId, dashboardSessionId: identity.dashboardSessionId, - attachCommand: buildAttachCommand(identity.sandboxId), + attachCommand: buildSessionCommand(identity.sandboxId), transport, createdAt: Date.now(), updatedAt: Date.now(), @@ -330,7 +366,7 @@ function serializeSession(session) { dashboardSessionId: session.dashboardSessionId, attachCommand: session.attachCommand, replay: session.buffer, - transport: runtime.mode, + transport: session.transport.kind, clientReady: session.clientReady, initialStreamSettled: session.initialStreamSettled, } @@ -356,7 +392,7 @@ const server = http.createServer((req, res) => { req.on('end', () => { try { const parsed = body ? JSON.parse(body) : {} - const sandboxId = typeof parsed.sandboxId === 'string' && parsed.sandboxId.trim() ? parsed.sandboxId.trim() : 'host' + const sandboxId = normalizeSandboxId(parsed.sandboxId) const requestedSessionId = typeof parsed.sessionId === 'string' ? parsed.sessionId.trim() : '' const dashboardSessionId = typeof parsed.dashboardSessionId === 'string' ? parsed.dashboardSessionId.trim() : 'dashboard-host' const identity = createSessionIdentity(sandboxId, dashboardSessionId) @@ -364,7 +400,9 @@ const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }) res.end(JSON.stringify(serializeSession(session))) } catch (error) { - res.writeHead(500, { 'Content-Type': 'application/json' }) + const message = error instanceof Error ? error.message : 'session init failed' + const statusCode = message.startsWith('Invalid sandboxId') ? 400 : 500 + res.writeHead(statusCode, { 'Content-Type': 'application/json' }) res.end(JSON.stringify({ ok: false, error: error instanceof Error ? error.message : 'session init failed' })) } }) @@ -380,9 +418,15 @@ const wss = new WebSocketServer({ server, path: '/ws' }) wss.on('connection', (socket, req) => { const url = new URL(req.url || '/', `http://${req.headers.host || `${HOST}:${PORT}`}`) const sessionId = url.searchParams.get('sessionId') || '' - const sandboxId = url.searchParams.get('sandboxId') || 'host' const dashboardSessionId = url.searchParams.get('dashboardSessionId') || 'dashboard-host' - const identity = createSessionIdentity(sandboxId, dashboardSessionId) + let identity + try { + identity = createSessionIdentity(url.searchParams.get('sandboxId') || 'host', dashboardSessionId) + } catch (error) { + socket.send(JSON.stringify({ type: 'error', error: error instanceof Error ? error.message : 'invalid sandboxId' })) + socket.close() + return + } const session = getOrCreateSession(sessionId, identity) session.sockets.add(socket) session.updatedAt = Date.now() @@ -394,7 +438,7 @@ wss.on('connection', (socket, req) => { dashboardSessionId: session.dashboardSessionId, attachCommand: session.attachCommand, replay: session.buffer, - transport: runtime.mode, + transport: session.transport.kind, clientReady: session.clientReady, initialStreamSettled: session.initialStreamSettled, })) diff --git a/tests/dashboard-session-check.mjs b/tests/dashboard-session-check.mjs index 2144ddf..376cab6 100644 --- a/tests/dashboard-session-check.mjs +++ b/tests/dashboard-session-check.mjs @@ -47,6 +47,83 @@ assert.match( /dashboardSessionId: session\.dashboardSessionId/, 'terminal server responses must expose dashboardSessionId metadata' ) +assert.match( + terminalSource, + /falling back to stream transport/, + 'terminal server must fall back to stream transport when auto PTY spawn fails' +) +assert.match( + terminalSource, + /transport: session\.transport\.kind/, + 'terminal server must report the actual per-session transport after fallback' +) +assert.match( + terminalSource, + /function buildSessionCommand\(sandboxId\)/, + 'terminal server must resolve the real command it will execute for each session' +) +assert.match( + terminalSource, + /function normalizeSandboxId\(value\)/, + 'terminal server must validate request-controlled sandbox IDs before using them in shell templates' +) +assert.match( + terminalSource, + /\^\[A-Za-z0-9\]\[A-Za-z0-9_\.-\]/, + 'terminal server sandbox ID validation must reject shell metacharacters and whitespace' +) +assert.match( + terminalSource, + /OPENSHELL_TERMINAL_ATTACH_TEMPLATE[\s\S]*return buildAttachCommand\(sandboxId\)/, + 'terminal server must honor OPENSHELL_TERMINAL_ATTACH_TEMPLATE for sandbox sessions instead of only displaying it' +) +assert.match( + terminalSource, + /replaceAll\('\{sandboxId\}', safeSandboxId\)/, + 'terminal server must shell-escape sandboxId before substituting it into attach templates' +) +assert.match( + terminalSource, + /replaceAll\('\{alias\}', safeAlias\)/, + 'terminal server must shell-escape aliases before substituting them into attach templates' +) +assert.match( + terminalSource, + /attachCommand: buildSessionCommand\(identity\.sandboxId\)/, + 'terminal server attachCommand metadata must match the command family it executes for the session' +) +assert.match( + terminalSource, + /statusCode = message\.startsWith\('Invalid sandboxId'\) \? 400 : 500/, + 'terminal server should report invalid sandbox IDs as client errors' +) +assert.match( + terminalSource, + /function buildSessionExec\(sandboxId\)/, + 'terminal server must build an executable shell command for each session' +) +assert.match( + terminalSource, + /shellForPlatform\(\)} -lc \$\{shellEscape\(sessionCommand\)\}/, + 'terminal server must run attach templates through a shell so compound commands are preserved' +) +assert.match( + terminalSource, + /sessionExec/, + 'terminal bootstrap must execute the resolved session command' +) + +const operatorTerminalSource = await readFile(path.join(root, 'app/operator-terminal/page.tsx'), 'utf8') +assert.match( + operatorTerminalSource, + /transport\?: string/, + 'operator terminal UI must track actual transport metadata' +) +assert.match( + operatorTerminalSource, + /via \$\{liveSession\.transport\}/, + 'operator terminal status must disclose the actual live transport to avoid misleading readiness copy' +) const buildOperatorTerminalRoute = ({ sandboxId, dashboardSessionId, launch }) => { const searchParams = new URLSearchParams() diff --git a/tests/portable-install-check.mjs b/tests/portable-install-check.mjs index fe70a31..8f066fd 100644 --- a/tests/portable-install-check.mjs +++ b/tests/portable-install-check.mjs @@ -54,11 +54,12 @@ 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\.36\}"/, 'versioned installer must pin OpenShell v0.0.36 by default') -assert.match(versionedInstallSource, /NEMOCLAW_INSTALL_TAG="\$\{NEMOCLAW_INSTALL_TAG:-v0\.0\.37\}"/, 'versioned installer must pin NemoClaw v0.0.37 by default') +assert.match(versionedInstallSource, /OPENSHELL_VERSION="\$\{OPENSHELL_VERSION:-v0\.0\.44\}"/, 'versioned installer must default to the OpenShell release supported by current NemoClaw main') +assert.match(versionedInstallSource, /NEMOCLAW_INSTALL_REF="\$\{NEMOCLAW_INSTALL_REF:-\$\{NEMOCLAW_INSTALL_TAG:-main\}\}"/, 'versioned installer must track the current NemoClaw main ref by default') +assert.match(versionedInstallSource, /NEMOCLAW_SOURCE_URL="\$\{NEMOCLAW_SOURCE_URL:-https:\/\/github\.com\/NVIDIA\/NemoClaw\.git\}"/, 'versioned installer must use the NemoClaw source repository URL') 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, /git -C "\$source_dir" fetch[\s\S]*"\$NEMOCLAW_INSTALL_REF"/, 'versioned installer must fetch NemoClaw from the selected git ref') +assert.match(versionedInstallSource, /OPENSHELL_VERSION="\$OPENSHELL_VERSION" sh/, 'versioned installer must pass the selected 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, /NEMOCLAW_EXPERIMENTAL="\$\{NEMOCLAW_EXPERIMENTAL:-1\}"/, 'versioned installer must default NemoClaw to experimental mode') diff --git a/tests/runtime-authority-resolution-check.mjs b/tests/runtime-authority-resolution-check.mjs index 26076cb..984fcfb 100644 --- a/tests/runtime-authority-resolution-check.mjs +++ b/tests/runtime-authority-resolution-check.mjs @@ -11,10 +11,11 @@ const terminalLivePath = path.join(root, 'app/api/openshell/terminal/live/route. const terminalReadinessPath = path.join(root, 'app/api/openshell/terminal/readiness/route.ts') const telemetryPath = path.join(root, 'app/api/telemetry/real/route.ts') const openshellHostPath = path.join(root, 'app/lib/openshellHost.ts') +const sandboxHealthPath = path.join(root, 'app/api/sandbox/[sandboxId]/health/route.ts') const packageJsonPath = path.join(root, 'package.json') const serverPath = path.join(root, 'server.mjs') -const [runtimeAuthoritySource, dashboardOpenSource, dashboardProxySource, terminalLiveSource, terminalReadinessSource, telemetrySource, openshellHostSource, packageJsonSource, serverSource] = await Promise.all([ +const [runtimeAuthoritySource, dashboardOpenSource, dashboardProxySource, terminalLiveSource, terminalReadinessSource, telemetrySource, openshellHostSource, sandboxHealthSource, packageJsonSource, serverSource] = await Promise.all([ readFile(runtimeAuthorityPath, 'utf8'), readFile(dashboardOpenPath, 'utf8'), readFile(dashboardProxySharedPath, 'utf8'), @@ -22,6 +23,7 @@ const [runtimeAuthoritySource, dashboardOpenSource, dashboardProxySource, termin readFile(terminalReadinessPath, 'utf8'), readFile(telemetryPath, 'utf8'), readFile(openshellHostPath, 'utf8'), + readFile(sandboxHealthPath, 'utf8'), readFile(packageJsonPath, 'utf8'), readFile(serverPath, 'utf8'), ]) @@ -52,6 +54,8 @@ assert.match(terminalReadinessSource, /const authority = resolveRuntimeAuthority assert.match(telemetrySource, /authoritySource: "runtimeAuthority"/, 'inventory route must declare shared authority source') assert.match(telemetrySource, /authorities: authorities\.map\(/, 'inventory route must expose per-sandbox authority metadata') +assert.match(openshellHostSource, /const OPENSHELL_GATEWAY = process\.env\.OPENSHELL_GATEWAY\?\.trim\(\) \|\| undefined/, 'OpenShell host commands must not force the legacy openshell gateway when NemoClaw has selected the nemoclaw gateway') +assert.match(sandboxHealthSource, /stripAnsi/, 'sandbox health must strip OpenShell ANSI styling before parsing fields such as Phase') assert.match(openshellHostSource, /const canMintBootstrapFromCli = instance\.id === defaultInstance\.id/, 'bootstrap minting should only use CLI for the default OpenClaw instance') assert.match(openshellHostSource, /readSandboxOpenClawDashboardToken/, 'sandbox dashboard bootstrap must fall back to the sandbox OpenClaw token when CLI output is bare') assert.match(openshellHostSource, /openclaw dashboard', 15000\)\.catch/, 'sandbox dashboard bootstrap should let OpenClaw initialize before reading the fallback token') diff --git a/tests/sandbox-lifecycle-check.mjs b/tests/sandbox-lifecycle-check.mjs index cad5276..4e1f048 100644 --- a/tests/sandbox-lifecycle-check.mjs +++ b/tests/sandbox-lifecycle-check.mjs @@ -98,7 +98,10 @@ assert.match(createRouteSource, /NEMOCLAW_EXPERIMENTAL = "1"/, 'blueprint create 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(versionedInstallerSource, /OPENCLAW_VERSION="\$\{OPENCLAW_VERSION:-2026\.4\.27\}"/, 'versioned installer must pin the dashboard-compatible NemoClaw OpenClaw version') +assert.match(versionedInstallerSource, /OPENSHELL_VERSION="\$\{OPENSHELL_VERSION:-v0\.0\.44\}"/, 'versioned installer must default to the OpenShell release supported by current NemoClaw main') +assert.match(versionedInstallerSource, /NEMOCLAW_INSTALL_REF="\$\{NEMOCLAW_INSTALL_REF:-\$\{NEMOCLAW_INSTALL_TAG:-main\}\}"/, 'versioned installer must track the current NemoClaw main ref by default while preserving the legacy tag override') +assert.match(versionedInstallerSource, /OPENCLAW_VERSION="\$\{OPENCLAW_VERSION:-2026\.5\.22\}"/, 'versioned installer must pin the current NemoClaw-compatible OpenClaw base image version') +assert.match(versionedInstallerSource, /git -C "\$source_dir" fetch[\s\S]*"\$NEMOCLAW_INSTALL_REF"/, 'versioned installer must fetch NemoClaw by git ref so branch heads and tags both work') assert.match(versionedInstallerSource, /docker build[\s\S]*Dockerfile\.base[\s\S]*--build-arg "OPENCLAW_VERSION=\$OPENCLAW_VERSION"[\s\S]*"\$source_dir"/, 'versioned installer must rebuild the stock NemoClaw base image with the pinned OpenClaw version') assert.doesNotMatch(createRouteSource, /repairOpenClawRuntimePolicy|runtimePolicyRepair/, 'sandbox create must not mutate OpenShell filesystem policy for OpenClaw') assert.doesNotMatch(createRouteSource, /stabilizeOpenClawGatewayConfig|gatewayConfigRepair|repairOpenClawWorkspacePermissions|workspaceRepair/, 'sandbox create must not patch OpenClaw internals after the Monday rollback') @@ -233,15 +236,19 @@ assert.match(vllmRestartRouteSource, /\^vllm/, 'vLLM restart route must restrict assert.doesNotMatch(inferencePanelSource, /nvidia\/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4/, 'settings UI must not default rebuilt inference routes to the NVIDIA Nemotron model') assert.match(inferencePanelSource, /method: "DELETE"/, 'settings UI must expose provider deletion') assert.match(inferencePanelSource, /\/api\/ollama\/models/, 'settings UI must poll local Ollama models') -assert.match(inferencePanelSource, /window\.setInterval\(\(\) => loadOllamaModels\(\{ silent: true \}\), 10000\)/, 'settings UI must autopoll Ollama while the endpoint panel is open') +assert.match(inferencePanelSource, /OLLAMA_BASE_URL = "http:\/\/127\.0\.0\.1:11434\/v1"/, 'settings UI must preset Ollama to the host OpenAI-compatible URL used by the OpenShell gateway') assert.match(inferencePanelSource, /function applyOllamaModelPreset\(item: OllamaModel\)/, 'settings UI must provide a click preset for local Ollama models') +assert.match(inferencePanelSource, /setCredentialKey\("OLLAMA_API_KEY"\)/, 'settings UI must use a dedicated Ollama credential key for local Ollama presets') +assert.match(inferencePanelSource, /data\.gateway\?\.provider\?\.toLowerCase\(\)\.includes\("ollama"\)/, 'settings UI must hydrate the form with Ollama URL/key defaults when the active route is Ollama') assert.match(inferencePanelSource, /function ollamaOpenAiBaseUrl\(item: OllamaModel\)[\s\S]*item\.baseUrl[\s\S]*`\$\{baseUrl\}\/v1`/, 'Ollama preset must derive the OpenAI-compatible endpoint from the discovered model source') assert.match(inferencePanelSource, /function ollamaProviderName\(item: OllamaModel\)[\s\S]*item\.hostKind === "win" \? "ollama-win" : OLLAMA_PROVIDER_NAME/, 'Ollama preset must distinguish Windows-host Ollama from local Ollama') assert.match(inferencePanelSource, /setName\(ollamaProviderName\(item\)\)[\s\S]*setType\("openai"\)[\s\S]*setModel\(modelName\)[\s\S]*setBaseUrl\(ollamaOpenAiBaseUrl\(item\)\)/, 'Ollama model preset must fill provider name, provider type, model, and discovered endpoint URL') assert.match(inferencePanelSource, /onClick=\{\(\) => applyOllamaModelPreset\(item\)\}/, 'clicking an Ollama model must load the endpoint preset') -assert.match(inferencePanelSource, /const OLLAMA_BASE_URL = "http:\/\/host\.docker\.internal:11434\/v1"/, 'Ollama preset must keep a fallback host-reachable OpenAI-compatible endpoint') +assert.match(inferencePanelSource, /const OLLAMA_BASE_URL = "http:\/\/127\.0\.0\.1:11434\/v1"/, 'Ollama preset must keep a fallback host-reachable OpenAI-compatible endpoint') assert.match(ollamaModelsRouteSource, /\/api\/tags/, 'Ollama models route must query the Ollama tags API') assert.match(ollamaModelsRouteSource, /OLLAMA_BASE_URL/, 'Ollama models route must support a configurable Ollama base URL') +assert.match(ollamaModelsRouteSource, /isChatModelName/, 'Ollama models route must hide embedding-only models from chat inference presets') +assert.match(ollamaModelsRouteSource, /MAC/, 'Ollama models route must label macOS localhost probes clearly instead of calling them Linux') assert.match(sandboxInferenceRouteSource, /parseRoutes/, 'sandbox inference route must accept multiple provider/model routes') assert.match(sandboxInferenceRouteSource, /primaryRouteId/, 'sandbox inference route must preserve the primary route selection') assert.match(sandboxInferenceRouteSource, /saveSandboxInferenceConfig/, 'sandbox inference route must persist per-sandbox inference profiles')